diff --git a/dist/numero.js b/dist/numero.js index c5e8b52..df536aa 100644 --- a/dist/numero.js +++ b/dist/numero.js @@ -1,2 +1,2 @@ /*! For license information please see numero.js.LICENSE.txt */ -var num;(()=>{var e={1977:function(e,t){var n;!function(r){"use strict";var a=Math.cosh||function(e){return Math.abs(e)<1e-9?1-e:.5*(Math.exp(e)+Math.exp(-e))},i=Math.sinh||function(e){return Math.abs(e)<1e-9?e:.5*(Math.exp(e)-Math.exp(-e))},s=function(){throw SyntaxError("Invalid Param")};function o(e,t){var n=Math.abs(e),r=Math.abs(t);return 0===e?Math.log(r):0===t?Math.log(n):n<3e3&&r<3e3?.5*Math.log(e*e+t*t):(e/=2,t/=2,.5*Math.log(e*e+t*t)+Math.LN2)}function u(e,t){if(!(this instanceof u))return new u(e,t);var n=function(e,t){var n={re:0,im:0};if(null==e)n.re=n.im=0;else if(void 0!==t)n.re=e,n.im=t;else switch(typeof e){case"object":if("im"in e&&"re"in e)n.re=e.re,n.im=e.im;else if("abs"in e&&"arg"in e){if(!Number.isFinite(e.abs)&&Number.isFinite(e.arg))return u.INFINITY;n.re=e.abs*Math.cos(e.arg),n.im=e.abs*Math.sin(e.arg)}else if("r"in e&&"phi"in e){if(!Number.isFinite(e.r)&&Number.isFinite(e.phi))return u.INFINITY;n.re=e.r*Math.cos(e.phi),n.im=e.r*Math.sin(e.phi)}else 2===e.length?(n.re=e[0],n.im=e[1]):s();break;case"string":n.im=n.re=0;var r=e.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),a=1,i=0;null===r&&s();for(var o=0;o0&&s();break;case"number":n.im=0,n.re=e;break;default:s()}return isNaN(n.re)||isNaN(n.im),n}(e,t);this.re=n.re,this.im=n.im}u.prototype={re:0,im:0,sign:function(){var e=this.abs();return new u(this.re/e,this.im/e)},add:function(e,t){var n=new u(e,t);return this.isInfinite()&&n.isInfinite()?u.NAN:this.isInfinite()||n.isInfinite()?u.INFINITY:new u(this.re+n.re,this.im+n.im)},sub:function(e,t){var n=new u(e,t);return this.isInfinite()&&n.isInfinite()?u.NAN:this.isInfinite()||n.isInfinite()?u.INFINITY:new u(this.re-n.re,this.im-n.im)},mul:function(e,t){var n=new u(e,t);return this.isInfinite()&&n.isZero()||this.isZero()&&n.isInfinite()?u.NAN:this.isInfinite()||n.isInfinite()?u.INFINITY:0===n.im&&0===this.im?new u(this.re*n.re,0):new u(this.re*n.re-this.im*n.im,this.re*n.im+this.im*n.re)},div:function(e,t){var n=new u(e,t);if(this.isZero()&&n.isZero()||this.isInfinite()&&n.isInfinite())return u.NAN;if(this.isInfinite()||n.isZero())return u.INFINITY;if(this.isZero()||n.isInfinite())return u.ZERO;e=this.re,t=this.im;var r,a,i=n.re,s=n.im;return 0===s?new u(e/i,t/i):Math.abs(i)0)return new u(Math.pow(e,n.re),0);if(0===e)switch((n.re%4+4)%4){case 0:return new u(Math.pow(t,n.re),0);case 1:return new u(0,Math.pow(t,n.re));case 2:return new u(-Math.pow(t,n.re),0);case 3:return new u(0,-Math.pow(t,n.re))}}if(0===e&&0===t&&n.re>0&&n.im>=0)return u.ZERO;var r=Math.atan2(t,e),a=o(e,t);return e=Math.exp(n.re*a-n.im*r),t=n.im*a+n.re*r,new u(e*Math.cos(t),e*Math.sin(t))},sqrt:function(){var e,t,n=this.re,r=this.im,a=this.abs();if(n>=0){if(0===r)return new u(Math.sqrt(n),0);e=.5*Math.sqrt(2*(a+n))}else e=Math.abs(r)/Math.sqrt(2*(a-n));return t=n<=0?.5*Math.sqrt(2*(a-n)):Math.abs(r)/Math.sqrt(2*(a+n)),new u(e,r<0?-t:t)},exp:function(){var e=Math.exp(this.re);return this.im,new u(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){var e=this.re,t=this.im;return new u(Math.expm1(e)*Math.cos(t)+function(e){var t=Math.PI/4;if(-t>e||e>t)return Math.cos(e)-1;var n=e*e;return n*(n*(n*(n*(n*(n*(n*(n/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-.5)}(t),Math.exp(e)*Math.sin(t))},log:function(){var e=this.re,t=this.im;return new u(o(e,t),Math.atan2(t,e))},abs:function(){return e=this.re,t=this.im,n=Math.abs(e),r=Math.abs(t),n<3e3&&r<3e3?Math.sqrt(n*n+r*r):(n1&&0===t,r=1-e,a=1+e,i=r*r+t*t,s=0!==i?new u((a*r-t*t)/i,(t*r+a*t)/i):new u(-1!==e?e/0:0,0!==t?t/0:0),l=s.re;return s.re=o(s.re,s.im)/2,s.im=Math.atan2(s.im,l)/2,n&&(s.im=-s.im),s},acoth:function(){var e=this.re,t=this.im;if(0===e&&0===t)return new u(0,Math.PI/2);var n=e*e+t*t;return 0!==n?new u(e/n,-t/n).atanh():new u(0!==e?e/0:0,0!==t?-t/0:0).atanh()},acsch:function(){var e=this.re,t=this.im;if(0===t)return new u(0!==e?Math.log(e+Math.sqrt(e*e+1)):1/0,0);var n=e*e+t*t;return 0!==n?new u(e/n,-t/n).asinh():new u(0!==e?e/0:0,0!==t?-t/0:0).asinh()},asech:function(){var e=this.re,t=this.im;if(this.isZero())return u.INFINITY;var n=e*e+t*t;return 0!==n?new u(e/n,-t/n).acosh():new u(0!==e?e/0:0,0!==t?-t/0:0).acosh()},inverse:function(){if(this.isZero())return u.INFINITY;if(this.isInfinite())return u.ZERO;var e=this.re,t=this.im,n=e*e+t*t;return new u(e/n,-t/n)},conjugate:function(){return new u(this.re,-this.im)},neg:function(){return new u(-this.re,-this.im)},ceil:function(e){return e=Math.pow(10,e||0),new u(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=Math.pow(10,e||0),new u(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=Math.pow(10,e||0),new u(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,t){var n=new u(e,t);return Math.abs(n.re-this.re)<=u.EPSILON&&Math.abs(n.im-this.im)<=u.EPSILON},clone:function(){return new u(this.re,this.im)},toString:function(){var e=this.re,t=this.im,n="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)=t?e:""+Array(t+1-r.length).join(n)+e},y={s:g,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),a=n%60;return(t<=0?"+":"-")+g(r,2,"0")+":"+g(a,2,"0")},m:function e(t,n){if(t.date()1)return e(s[0])}else{var o=t.name;x[o]=t,a=o}return!r&&a&&(b=a),a||!r&&b},w=function(e,t){if(v(e))return e.clone();var n="object"==typeof t?t:{};return n.date=e,n.args=arguments,new N(n)},M=y;M.l=_,M.i=v,M.w=function(e,t){return w(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var N=function(){function m(e){this.$L=_(e.locale,null,!0),this.parse(e)}var g=m.prototype;return g.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(null===t)return new Date(NaN);if(M.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var r=t.match(h);if(r){var a=r[2]-1||0,i=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],a,r[3]||1,r[4]||0,r[5]||0,r[6]||0,i)):new Date(r[1],a,r[3]||1,r[4]||0,r[5]||0,r[6]||0,i)}}return new Date(t)}(e),this.$x=e.x||{},this.init()},g.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},g.$utils=function(){return M},g.isValid=function(){return!(this.$d.toString()===d)},g.isSame=function(e,t){var n=w(e);return this.startOf(t)<=n&&n<=this.endOf(t)},g.isAfter=function(e,t){return w(e)12?"م":"ص"},relativeTime:{future:"في %s",past:"منذ %s",s:"ثوان",m:"دقيقة",mm:"%d دقائق",h:"ساعة",hh:"%d ساعات",d:"يوم",dd:"%d أيام",M:"شهر",MM:"%d أشهر",y:"سنة",yy:"%d سنوات"}};return t.default.locale(n,null,!0),n}(n(7484))},7719:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ar-iq",weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),months:"كانون الثاني_شباط_آذار_نيسان_أيار_حزيران_تموز_آب_أيلول_تشرين الأول_ تشرين الثاني_كانون الأول".split("_"),weekStart:1,weekdaysShort:"أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت".split("_"),monthsShort:"كانون الثاني_شباط_آذار_نيسان_أيار_حزيران_تموز_آب_أيلول_تشرين الأول_ تشرين الثاني_كانون الأول".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},meridiem:function(e){return e>12?"م":"ص"},relativeTime:{future:"في %s",past:"منذ %s",s:"ثوان",m:"دقيقة",mm:"%d دقائق",h:"ساعة",hh:"%d ساعات",d:"يوم",dd:"%d أيام",M:"شهر",MM:"%d أشهر",y:"سنة",yy:"%d سنوات"}};return t.default.locale(n,null,!0),n}(n(7484))},2376:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ar-kw",weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),months:"يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر".split("_"),weekdaysShort:"احد_اثنين_ثلاثاء_اربعاء_خميس_جمعة_سبت".split("_"),monthsShort:"يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},meridiem:function(e){return e>12?"م":"ص"},relativeTime:{future:"في %s",past:"منذ %s",s:"ثوان",m:"دقيقة",mm:"%d دقائق",h:"ساعة",hh:"%d ساعات",d:"يوم",dd:"%d أيام",M:"شهر",MM:"%d أشهر",y:"سنة",yy:"%d سنوات"}};return t.default.locale(n,null,!0),n}(n(7484))},8540:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ar-ly",weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),months:"يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),weekStart:6,weekdaysShort:"أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت".split("_"),monthsShort:"يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),ordinal:function(e){return e},meridiem:function(e){return e>12?"م":"ص"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"D/‏M/‏YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},6817:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ar-ma",weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),months:"يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر".split("_"),weekStart:6,weekdaysShort:"احد_إثنين_ثلاثاء_اربعاء_خميس_جمعة_سبت".split("_"),monthsShort:"يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},meridiem:function(e){return e>12?"م":"ص"},relativeTime:{future:"في %s",past:"منذ %s",s:"ثوان",m:"دقيقة",mm:"%d دقائق",h:"ساعة",hh:"%d ساعات",d:"يوم",dd:"%d أيام",M:"شهر",MM:"%d أشهر",y:"سنة",yy:"%d سنوات"}};return t.default.locale(n,null,!0),n}(n(7484))},1573:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ar-sa",weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),months:"يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),weekdaysShort:"أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت".split("_"),monthsShort:"يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},meridiem:function(e){return e>12?"م":"ص"},relativeTime:{future:"في %s",past:"منذ %s",s:"ثوان",m:"دقيقة",mm:"%d دقائق",h:"ساعة",hh:"%d ساعات",d:"يوم",dd:"%d أيام",M:"شهر",MM:"%d أشهر",y:"سنة",yy:"%d سنوات"}};return t.default.locale(n,null,!0),n}(n(7484))},9339:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ar-tn",weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),months:"جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),weekStart:1,weekdaysShort:"أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت".split("_"),monthsShort:"جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},meridiem:function(e){return e>12?"م":"ص"},relativeTime:{future:"في %s",past:"منذ %s",s:"ثوان",m:"دقيقة",mm:"%d دقائق",h:"ساعة",hh:"%d ساعات",d:"يوم",dd:"%d أيام",M:"شهر",MM:"%d أشهر",y:"سنة",yy:"%d سنوات"}};return t.default.locale(n,null,!0),n}(n(7484))},3939:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n="يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),r={1:"١",2:"٢",3:"٣",4:"٤",5:"٥",6:"٦",7:"٧",8:"٨",9:"٩",0:"٠"},a={"١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","٠":"0"},i={name:"ar",weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),weekdaysShort:"أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),months:n,monthsShort:n,weekStart:6,relativeTime:{future:"بعد %s",past:"منذ %s",s:"ثانية واحدة",m:"دقيقة واحدة",mm:"%d دقائق",h:"ساعة واحدة",hh:"%d ساعات",d:"يوم واحد",dd:"%d أيام",M:"شهر واحد",MM:"%d أشهر",y:"عام واحد",yy:"%d أعوام"},preparse:function(e){return e.replace(/[١٢٣٤٥٦٧٨٩٠]/g,(function(e){return a[e]})).replace(/،/g,",")},postformat:function(e){return e.replace(/\d/g,(function(e){return r[e]})).replace(/,/g,"،")},ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"D/‏M/‏YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"}};return t.default.locale(i,null,!0),i}(n(7484))},8092:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"az",weekdays:"Bazar_Bazar ertəsi_Çərşənbə axşamı_Çərşənbə_Cümə axşamı_Cümə_Şənbə".split("_"),weekdaysShort:"Baz_BzE_ÇAx_Çər_CAx_Cüm_Şən".split("_"),weekdaysMin:"Bz_BE_ÇA_Çə_CA_Cü_Şə".split("_"),months:"yanvar_fevral_mart_aprel_may_iyun_iyul_avqust_sentyabr_oktyabr_noyabr_dekabr".split("_"),monthsShort:"yan_fev_mar_apr_may_iyn_iyl_avq_sen_okt_noy_dek".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY г.",LLL:"D MMMM YYYY г., H:mm",LLLL:"dddd, D MMMM YYYY г., H:mm"},relativeTime:{future:"%s sonra",past:"%s əvvəl",s:"bir neçə saniyə",m:"bir dəqiqə",mm:"%d dəqiqə",h:"bir saat",hh:"%d saat",d:"bir gün",dd:"%d gün",M:"bir ay",MM:"%d ay",y:"bir il",yy:"%d il"},ordinal:function(e){return e}};return t.default.locale(n,null,!0),n}(n(7484))},504:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"be",weekdays:"нядзелю_панядзелак_аўторак_сераду_чацвер_пятніцу_суботу".split("_"),months:"студзеня_лютага_сакавіка_красавіка_траўня_чэрвеня_ліпеня_жніўня_верасня_кастрычніка_лістапада_снежня".split("_"),weekStart:1,weekdaysShort:"нд_пн_ат_ср_чц_пт_сб".split("_"),monthsShort:"студ_лют_сак_крас_трав_чэрв_ліп_жнів_вер_каст_ліст_снеж".split("_"),weekdaysMin:"нд_пн_ат_ср_чц_пт_сб".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY г.",LLL:"D MMMM YYYY г., HH:mm",LLLL:"dddd, D MMMM YYYY г., HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},9091:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"bg",weekdays:"неделя_понеделник_вторник_сряда_четвъртък_петък_събота".split("_"),weekdaysShort:"нед_пон_вто_сря_чет_пет_съб".split("_"),weekdaysMin:"нд_пн_вт_ср_чт_пт_сб".split("_"),months:"януари_февруари_март_април_май_юни_юли_август_септември_октомври_ноември_декември".split("_"),monthsShort:"янр_фев_мар_апр_май_юни_юли_авг_сеп_окт_ное_дек".split("_"),weekStart:1,ordinal:function(e){var t=e%100;if(t>10&&t<20)return e+"-ти";var n=e%10;return 1===n?e+"-ви":2===n?e+"-ри":7===n||8===n?e+"-ми":e+"-ти"},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"D.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY H:mm",LLLL:"dddd, D MMMM YYYY H:mm"},relativeTime:{future:"след %s",past:"преди %s",s:"няколко секунди",m:"минута",mm:"%d минути",h:"час",hh:"%d часа",d:"ден",dd:"%d дена",M:"месец",MM:"%d месеца",y:"година",yy:"%d години"}};return t.default.locale(n,null,!0),n}(n(7484))},9149:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"bi",weekdays:"Sande_Mande_Tusde_Wenesde_Tosde_Fraede_Sarade".split("_"),months:"Januari_Februari_Maj_Eprel_Mei_Jun_Julae_Okis_Septemba_Oktoba_Novemba_Disemba".split("_"),weekStart:1,weekdaysShort:"San_Man_Tus_Wen_Tos_Frae_Sar".split("_"),monthsShort:"Jan_Feb_Maj_Epr_Mai_Jun_Jul_Oki_Sep_Okt_Nov_Dis".split("_"),weekdaysMin:"San_Ma_Tu_We_To_Fr_Sar".split("_"),ordinal:function(e){return e},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY h:mm A",LLLL:"dddd, D MMMM YYYY h:mm A"},relativeTime:{future:"lo %s",past:"%s bifo",s:"sam seken",m:"wan minit",mm:"%d minit",h:"wan haoa",hh:"%d haoa",d:"wan dei",dd:"%d dei",M:"wan manis",MM:"%d manis",y:"wan yia",yy:"%d yia"}};return t.default.locale(n,null,!0),n}(n(7484))},5287:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"bm",weekdays:"Kari_Ntɛnɛn_Tarata_Araba_Alamisa_Juma_Sibiri".split("_"),months:"Zanwuyekalo_Fewuruyekalo_Marisikalo_Awirilikalo_Mɛkalo_Zuwɛnkalo_Zuluyekalo_Utikalo_Sɛtanburukalo_ɔkutɔburukalo_Nowanburukalo_Desanburukalo".split("_"),weekStart:1,weekdaysShort:"Kar_Ntɛ_Tar_Ara_Ala_Jum_Sib".split("_"),monthsShort:"Zan_Few_Mar_Awi_Mɛ_Zuw_Zul_Uti_Sɛt_ɔku_Now_Des".split("_"),weekdaysMin:"Ka_Nt_Ta_Ar_Al_Ju_Si".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"MMMM [tile] D [san] YYYY",LLL:"MMMM [tile] D [san] YYYY [lɛrɛ] HH:mm",LLLL:"dddd MMMM [tile] D [san] YYYY [lɛrɛ] HH:mm"},relativeTime:{future:"%s kɔnɔ",past:"a bɛ %s bɔ",s:"sanga dama dama",m:"miniti kelen",mm:"miniti %d",h:"lɛrɛ kelen",hh:"lɛrɛ %d",d:"tile kelen",dd:"tile %d",M:"kalo kelen",MM:"kalo %d",y:"san kelen",yy:"san %d"}};return t.default.locale(n,null,!0),n}(n(7484))},5254:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={1:"১",2:"২",3:"৩",4:"৪",5:"৫",6:"৬",7:"৭",8:"৮",9:"৯",0:"০"},r={"১":"1","২":"2","৩":"3","৪":"4","৫":"5","৬":"6","৭":"7","৮":"8","৯":"9","০":"0"},a={name:"bn",weekdays:"রবিবার_সোমবার_মঙ্গলবার_বুধবার_বৃহস্পতিবার_শুক্রবার_শনিবার".split("_"),months:"জানুয়ারি_ফেব্রুয়ারি_মার্চ_এপ্রিল_মে_জুন_জুলাই_আগস্ট_সেপ্টেম্বর_অক্টোবর_নভেম্বর_ডিসেম্বর".split("_"),weekdaysShort:"রবি_সোম_মঙ্গল_বুধ_বৃহস্পতি_শুক্র_শনি".split("_"),monthsShort:"জানু_ফেব্রু_মার্চ_এপ্রিল_মে_জুন_জুলাই_আগস্ট_সেপ্ট_অক্টো_নভে_ডিসে".split("_"),weekdaysMin:"রবি_সোম_মঙ্গ_বুধ_বৃহঃ_শুক্র_শনি".split("_"),preparse:function(e){return e.replace(/[১২৩৪৫৬৭৮৯০]/g,(function(e){return r[e]}))},postformat:function(e){return e.replace(/\d/g,(function(e){return n[e]}))},ordinal:function(e){return e},formats:{LT:"A h:mm সময়",LTS:"A h:mm:ss সময়",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm সময়",LLLL:"dddd, D MMMM YYYY, A h:mm সময়"},relativeTime:{future:"%s পরে",past:"%s আগে",s:"কয়েক সেকেন্ড",m:"এক মিনিট",mm:"%d মিনিট",h:"এক ঘন্টা",hh:"%d ঘন্টা",d:"এক দিন",dd:"%d দিন",M:"এক মাস",MM:"%d মাস",y:"এক বছর",yy:"%d বছর"}};return t.default.locale(a,null,!0),a}(n(7484))},2502:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"bo",weekdays:"གཟའ་ཉི་མ་_གཟའ་ཟླ་བ་_གཟའ་མིག་དམར་_གཟའ་ལྷག་པ་_གཟའ་ཕུར་བུ_གཟའ་པ་སངས་_གཟའ་སྤེན་པ་".split("_"),weekdaysShort:"ཉི་མ་_ཟླ་བ་_མིག་དམར་_ལྷག་པ་_ཕུར་བུ_པ་སངས་_སྤེན་པ་".split("_"),weekdaysMin:"ཉི་མ་_ཟླ་བ་_མིག་དམར་_ལྷག་པ་_ཕུར་བུ_པ་སངས་_སྤེན་པ་".split("_"),months:"ཟླ་བ་དང་པོ_ཟླ་བ་གཉིས་པ_ཟླ་བ་གསུམ་པ_ཟླ་བ་བཞི་པ_ཟླ་བ་ལྔ་པ_ཟླ་བ་དྲུག་པ_ཟླ་བ་བདུན་པ_ཟླ་བ་བརྒྱད་པ_ཟླ་བ་དགུ་པ_ཟླ་བ་བཅུ་པ_ཟླ་བ་བཅུ་གཅིག་པ_ཟླ་བ་བཅུ་གཉིས་པ".split("_"),monthsShort:"ཟླ་དང་པོ_ཟླ་གཉིས་པ_ཟླ་གསུམ་པ_ཟླ་བཞི་པ_ཟླ་ལྔ་པ_ཟླ་དྲུག་པ_ཟླ་བདུན་པ_ཟླ་བརྒྱད་པ_ཟླ་དགུ་པ_ཟླ་བཅུ་པ_ཟླ་བཅུ་གཅིག་པ_ཟླ་བཅུ་གཉིས་པ".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm",LTS:"A h:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm",LLLL:"dddd, D MMMM YYYY, A h:mm"},relativeTime:{future:"%s ལ་",past:"%s སྔོན་ལ་",s:"ཏོག་ཙམ་",m:"སྐར་མ་གཅིག་",mm:"སྐར་མ་ %d",h:"ཆུ་ཚོད་གཅིག་",hh:"ཆུ་ཚོད་ %d",d:"ཉིན་གཅིག་",dd:"ཉིན་ %d",M:"ཟླ་བ་གཅིག་",MM:"ཟླ་བ་ %d",y:"ལོ་གཅིག་",yy:"ལོ་ %d"}};return t.default.locale(n,null,!0),n}(n(7484))},8864:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e);function n(e){return e>9?n(e%10):e}function r(e,t,n){return e+" "+function(e,t){return 2===t?function(e){return{m:"v",b:"v",d:"z"}[e.charAt(0)]+e.substring(1)}(e):e}({mm:"munutenn",MM:"miz",dd:"devezh"}[n],e)}var a={name:"br",weekdays:"Sul_Lun_Meurzh_Mercʼher_Yaou_Gwener_Sadorn".split("_"),months:"Genver_Cʼhwevrer_Meurzh_Ebrel_Mae_Mezheven_Gouere_Eost_Gwengolo_Here_Du_Kerzu".split("_"),weekStart:1,weekdaysShort:"Sul_Lun_Meu_Mer_Yao_Gwe_Sad".split("_"),monthsShort:"Gen_Cʼhwe_Meu_Ebr_Mae_Eve_Gou_Eos_Gwe_Her_Du_Ker".split("_"),weekdaysMin:"Su_Lu_Me_Mer_Ya_Gw_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"h[e]mm A",LTS:"h[e]mm:ss A",L:"DD/MM/YYYY",LL:"D [a viz] MMMM YYYY",LLL:"D [a viz] MMMM YYYY h[e]mm A",LLLL:"dddd, D [a viz] MMMM YYYY h[e]mm A"},relativeTime:{future:"a-benn %s",past:"%s ʼzo",s:"un nebeud segondennoù",m:"ur vunutenn",mm:r,h:"un eur",hh:"%d eur",d:"un devezh",dd:r,M:"ur miz",MM:r,y:"ur bloaz",yy:function(e){switch(n(e)){case 1:case 3:case 4:case 5:case 9:return e+" bloaz";default:return e+" vloaz"}}},meridiem:function(e){return e<12?"a.m.":"g.m."}};return t.default.locale(a,null,!0),a}(n(7484))},4502:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"bs",weekdays:"nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota".split("_"),months:"januar_februar_mart_april_maj_juni_juli_august_septembar_oktobar_novembar_decembar".split("_"),weekStart:1,weekdaysShort:"ned._pon._uto._sri._čet._pet._sub.".split("_"),monthsShort:"jan._feb._mar._apr._maj._jun._jul._aug._sep._okt._nov._dec.".split("_"),weekdaysMin:"ne_po_ut_sr_če_pe_su".split("_"),ordinal:function(e){return e},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd, D. MMMM YYYY H:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},3646:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ca",weekdays:"Diumenge_Dilluns_Dimarts_Dimecres_Dijous_Divendres_Dissabte".split("_"),weekdaysShort:"Dg._Dl._Dt._Dc._Dj._Dv._Ds.".split("_"),weekdaysMin:"Dg_Dl_Dt_Dc_Dj_Dv_Ds".split("_"),months:"Gener_Febrer_Març_Abril_Maig_Juny_Juliol_Agost_Setembre_Octubre_Novembre_Desembre".split("_"),monthsShort:"Gen._Febr._Març_Abr._Maig_Juny_Jul._Ag._Set._Oct._Nov._Des.".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM [de] YYYY",LLL:"D MMMM [de] YYYY [a les] H:mm",LLLL:"dddd D MMMM [de] YYYY [a les] H:mm",ll:"D MMM YYYY",lll:"D MMM YYYY, H:mm",llll:"ddd D MMM YYYY, H:mm"},relativeTime:{future:"d'aquí %s",past:"fa %s",s:"uns segons",m:"un minut",mm:"%d minuts",h:"una hora",hh:"%d hores",d:"un dia",dd:"%d dies",M:"un mes",MM:"%d mesos",y:"un any",yy:"%d anys"},ordinal:function(e){return e+(1===e||3===e?"r":2===e?"n":4===e?"t":"è")}};return t.default.locale(n,null,!0),n}(n(7484))},8507:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e);function n(e){return e>1&&e<5&&1!=~~(e/10)}function r(e,t,r,a){var i=e+" ";switch(r){case"s":return t||a?"pár sekund":"pár sekundami";case"m":return t?"minuta":a?"minutu":"minutou";case"mm":return t||a?i+(n(e)?"minuty":"minut"):i+"minutami";case"h":return t?"hodina":a?"hodinu":"hodinou";case"hh":return t||a?i+(n(e)?"hodiny":"hodin"):i+"hodinami";case"d":return t||a?"den":"dnem";case"dd":return t||a?i+(n(e)?"dny":"dní"):i+"dny";case"M":return t||a?"měsíc":"měsícem";case"MM":return t||a?i+(n(e)?"měsíce":"měsíců"):i+"měsíci";case"y":return t||a?"rok":"rokem";case"yy":return t||a?i+(n(e)?"roky":"let"):i+"lety"}}var a={name:"cs",weekdays:"neděle_pondělí_úterý_středa_čtvrtek_pátek_sobota".split("_"),weekdaysShort:"ne_po_út_st_čt_pá_so".split("_"),weekdaysMin:"ne_po_út_st_čt_pá_so".split("_"),months:"leden_únor_březen_duben_květen_červen_červenec_srpen_září_říjen_listopad_prosinec".split("_"),monthsShort:"led_úno_bře_dub_kvě_čvn_čvc_srp_zář_říj_lis_pro".split("_"),weekStart:1,yearStart:4,ordinal:function(e){return e+"."},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd D. MMMM YYYY H:mm",l:"D. M. YYYY"},relativeTime:{future:"za %s",past:"před %s",s:r,m:r,mm:r,h:r,hh:r,d:r,dd:r,M:r,MM:r,y:r,yy:r}};return t.default.locale(a,null,!0),a}(n(7484))},6636:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"cv",weekdays:"вырсарникун_тунтикун_ытларикун_юнкун_кӗҫнерникун_эрнекун_шӑматкун".split("_"),months:"кӑрлач_нарӑс_пуш_ака_май_ҫӗртме_утӑ_ҫурла_авӑн_юпа_чӳк_раштав".split("_"),weekStart:1,weekdaysShort:"выр_тун_ытл_юн_кӗҫ_эрн_шӑм".split("_"),monthsShort:"кӑр_нар_пуш_ака_май_ҫӗр_утӑ_ҫур_авн_юпа_чӳк_раш".split("_"),weekdaysMin:"вр_тн_ыт_юн_кҫ_эр_шм".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD-MM-YYYY",LL:"YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ]",LLL:"YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], HH:mm",LLLL:"dddd, YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},8792:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"cy",weekdays:"Dydd Sul_Dydd Llun_Dydd Mawrth_Dydd Mercher_Dydd Iau_Dydd Gwener_Dydd Sadwrn".split("_"),months:"Ionawr_Chwefror_Mawrth_Ebrill_Mai_Mehefin_Gorffennaf_Awst_Medi_Hydref_Tachwedd_Rhagfyr".split("_"),weekStart:1,weekdaysShort:"Sul_Llun_Maw_Mer_Iau_Gwe_Sad".split("_"),monthsShort:"Ion_Chwe_Maw_Ebr_Mai_Meh_Gor_Aws_Med_Hyd_Tach_Rhag".split("_"),weekdaysMin:"Su_Ll_Ma_Me_Ia_Gw_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"mewn %s",past:"%s yn ôl",s:"ychydig eiliadau",m:"munud",mm:"%d munud",h:"awr",hh:"%d awr",d:"diwrnod",dd:"%d diwrnod",M:"mis",MM:"%d mis",y:"blwyddyn",yy:"%d flynedd"}};return t.default.locale(n,null,!0),n}(n(7484))},7427:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"da",weekdays:"søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag".split("_"),weekdaysShort:"søn._man._tirs._ons._tors._fre._lør.".split("_"),weekdaysMin:"sø._ma._ti._on._to._fr._lø.".split("_"),months:"januar_februar_marts_april_maj_juni_juli_august_september_oktober_november_december".split("_"),monthsShort:"jan._feb._mar._apr._maj_juni_juli_aug._sept._okt._nov._dec.".split("_"),weekStart:1,ordinal:function(e){return e+"."},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY HH:mm",LLLL:"dddd [d.] D. MMMM YYYY [kl.] HH:mm"},relativeTime:{future:"om %s",past:"%s siden",s:"få sekunder",m:"et minut",mm:"%d minutter",h:"en time",hh:"%d timer",d:"en dag",dd:"%d dage",M:"en måned",MM:"%d måneder",y:"et år",yy:"%d år"}};return t.default.locale(n,null,!0),n}(n(7484))},3237:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={s:"ein paar Sekunden",m:["eine Minute","einer Minute"],mm:"%d Minuten",h:["eine Stunde","einer Stunde"],hh:"%d Stunden",d:["ein Tag","einem Tag"],dd:["%d Tage","%d Tagen"],M:["ein Monat","einem Monat"],MM:["%d Monate","%d Monaten"],y:["ein Jahr","einem Jahr"],yy:["%d Jahre","%d Jahren"]};function r(e,t,r){var a=n[r];return Array.isArray(a)&&(a=a[t?0:1]),a.replace("%d",e)}var a={name:"de-at",weekdays:"Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag".split("_"),weekdaysShort:"So._Mo._Di._Mi._Do._Fr._Sa.".split("_"),weekdaysMin:"So_Mo_Di_Mi_Do_Fr_Sa".split("_"),months:"Jänner_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember".split("_"),monthsShort:"Jän._Feb._März_Apr._Mai_Juni_Juli_Aug._Sep._Okt._Nov._Dez.".split("_"),ordinal:function(e){return e+"."},weekStart:1,formats:{LTS:"HH:mm:ss",LT:"HH:mm",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY HH:mm",LLLL:"dddd, D. MMMM YYYY HH:mm"},relativeTime:{future:"in %s",past:"vor %s",s:r,m:r,mm:r,h:r,hh:r,d:r,dd:r,M:r,MM:r,y:r,yy:r}};return t.default.locale(a,null,!0),a}(n(7484))},6148:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={s:"ein paar Sekunden",m:["eine Minute","einer Minute"],mm:"%d Minuten",h:["eine Stunde","einer Stunde"],hh:"%d Stunden",d:["ein Tag","einem Tag"],dd:["%d Tage","%d Tagen"],M:["ein Monat","einem Monat"],MM:["%d Monate","%d Monaten"],y:["ein Jahr","einem Jahr"],yy:["%d Jahre","%d Jahren"]};function r(e,t,r){var a=n[r];return Array.isArray(a)&&(a=a[t?0:1]),a.replace("%d",e)}var a={name:"de-ch",weekdays:"Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag".split("_"),weekdaysShort:"So_Mo_Di_Mi_Do_Fr_Sa".split("_"),weekdaysMin:"So_Mo_Di_Mi_Do_Fr_Sa".split("_"),months:"Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember".split("_"),monthsShort:"Jan._Feb._März_Apr._Mai_Juni_Juli_Aug._Sep._Okt._Nov._Dez.".split("_"),ordinal:function(e){return e+"."},weekStart:1,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY HH:mm",LLLL:"dddd, D. MMMM YYYY HH:mm"},relativeTime:{future:"in %s",past:"vor %s",s:r,m:r,mm:r,h:r,hh:r,d:r,dd:r,M:r,MM:r,y:r,yy:r}};return t.default.locale(a,null,!0),a}(n(7484))},790:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={s:"ein paar Sekunden",m:["eine Minute","einer Minute"],mm:"%d Minuten",h:["eine Stunde","einer Stunde"],hh:"%d Stunden",d:["ein Tag","einem Tag"],dd:["%d Tage","%d Tagen"],M:["ein Monat","einem Monat"],MM:["%d Monate","%d Monaten"],y:["ein Jahr","einem Jahr"],yy:["%d Jahre","%d Jahren"]};function r(e,t,r){var a=n[r];return Array.isArray(a)&&(a=a[t?0:1]),a.replace("%d",e)}var a={name:"de",weekdays:"Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag".split("_"),weekdaysShort:"So._Mo._Di._Mi._Do._Fr._Sa.".split("_"),weekdaysMin:"So_Mo_Di_Mi_Do_Fr_Sa".split("_"),months:"Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember".split("_"),monthsShort:"Jan._Feb._März_Apr._Mai_Juni_Juli_Aug._Sept._Okt._Nov._Dez.".split("_"),ordinal:function(e){return e+"."},weekStart:1,yearStart:4,formats:{LTS:"HH:mm:ss",LT:"HH:mm",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY HH:mm",LLLL:"dddd, D. MMMM YYYY HH:mm"},relativeTime:{future:"in %s",past:"vor %s",s:r,m:r,mm:r,h:r,hh:r,d:r,dd:r,M:r,MM:r,y:r,yy:r}};return t.default.locale(a,null,!0),a}(n(7484))},1794:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"dv",weekdays:"އާދިއްތަ_ހޯމަ_އަންގާރަ_ބުދަ_ބުރާސްފަތި_ހުކުރު_ހޮނިހިރު".split("_"),months:"ޖެނުއަރީ_ފެބްރުއަރީ_މާރިޗު_އޭޕްރީލު_މޭ_ޖޫން_ޖުލައި_އޯގަސްޓު_ސެޕްޓެމްބަރު_އޮކްޓޯބަރު_ނޮވެމްބަރު_ޑިސެމްބަރު".split("_"),weekStart:7,weekdaysShort:"އާދިއްތަ_ހޯމަ_އަންގާރަ_ބުދަ_ބުރާސްފަތި_ހުކުރު_ހޮނިހިރު".split("_"),monthsShort:"ޖެނުއަރީ_ފެބްރުއަރީ_މާރިޗު_އޭޕްރީލު_މޭ_ޖޫން_ޖުލައި_އޯގަސްޓު_ސެޕްޓެމްބަރު_އޮކްޓޯބަރު_ނޮވެމްބަރު_ޑިސެމްބަރު".split("_"),weekdaysMin:"އާދި_ހޯމަ_އަން_ބުދަ_ބުރާ_ހުކު_ހޮނި".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"D/M/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"ތެރޭގައި %s",past:"ކުރިން %s",s:"ސިކުންތުކޮޅެއް",m:"މިނިޓެއް",mm:"މިނިޓު %d",h:"ގަޑިއިރެއް",hh:"ގަޑިއިރު %d",d:"ދުވަހެއް",dd:"ދުވަސް %d",M:"މަހެއް",MM:"މަސް %d",y:"އަހަރެއް",yy:"އަހަރު %d"}};return t.default.locale(n,null,!0),n}(n(7484))},5423:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"el",weekdays:"Κυριακή_Δευτέρα_Τρίτη_Τετάρτη_Πέμπτη_Παρασκευή_Σάββατο".split("_"),weekdaysShort:"Κυρ_Δευ_Τρι_Τετ_Πεμ_Παρ_Σαβ".split("_"),weekdaysMin:"Κυ_Δε_Τρ_Τε_Πε_Πα_Σα".split("_"),months:"Ιανουάριος_Φεβρουάριος_Μάρτιος_Απρίλιος_Μάιος_Ιούνιος_Ιούλιος_Αύγουστος_Σεπτέμβριος_Οκτώβριος_Νοέμβριος_Δεκέμβριος".split("_"),monthsShort:"Ιαν_Φεβ_Μαρ_Απρ_Μαι_Ιουν_Ιουλ_Αυγ_Σεπτ_Οκτ_Νοε_Δεκ".split("_"),ordinal:function(e){return e},weekStart:1,relativeTime:{future:"σε %s",past:"πριν %s",s:"μερικά δευτερόλεπτα",m:"ένα λεπτό",mm:"%d λεπτά",h:"μία ώρα",hh:"%d ώρες",d:"μία μέρα",dd:"%d μέρες",M:"ένα μήνα",MM:"%d μήνες",y:"ένα χρόνο",yy:"%d χρόνια"},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY h:mm A",LLLL:"dddd, D MMMM YYYY h:mm A"}};return t.default.locale(n,null,!0),n}(n(7484))},5109:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-au",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),weekStart:1,weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY h:mm A",LLLL:"dddd, D MMMM YYYY h:mm A"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"}};return t.default.locale(n,null,!0),n}(n(7484))},5105:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-ca",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"YYYY-MM-DD",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"}};return t.default.locale(n,null,!0),n}(n(7484))},9517:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-gb",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekStart:1,yearStart:4,relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"}};return t.default.locale(n,null,!0),n}(n(7484))},758:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-ie",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),weekStart:1,weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"}};return t.default.locale(n,null,!0),n}(n(7484))},5805:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-il",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"}};return t.default.locale(n,null,!0),n}(n(7484))},8529:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-in",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekStart:1,yearStart:4,relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"}};return t.default.locale(n,null,!0),n}(n(7484))},302:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-nz",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),weekStart:1,weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY h:mm A",LLLL:"dddd, D MMMM YYYY h:mm A"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"}};return t.default.locale(n,null,!0),n}(n(7484))},5941:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-sg",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),weekStart:1,weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"}};return t.default.locale(n,null,!0),n}(n(7484))},6183:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-tt",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekStart:1,yearStart:4,relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"}};return t.default.locale(n,null,!0),n}(n(7484))},5054:function(e){e.exports=function(){"use strict";return{name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")}}()},4990:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"eo",weekdays:"dimanĉo_lundo_mardo_merkredo_ĵaŭdo_vendredo_sabato".split("_"),months:"januaro_februaro_marto_aprilo_majo_junio_julio_aŭgusto_septembro_oktobro_novembro_decembro".split("_"),weekStart:1,weekdaysShort:"dim_lun_mard_merk_ĵaŭ_ven_sab".split("_"),monthsShort:"jan_feb_mar_apr_maj_jun_jul_aŭg_sep_okt_nov_dec".split("_"),weekdaysMin:"di_lu_ma_me_ĵa_ve_sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"D[-a de] MMMM, YYYY",LLL:"D[-a de] MMMM, YYYY HH:mm",LLLL:"dddd, [la] D[-a de] MMMM, YYYY HH:mm"},relativeTime:{future:"post %s",past:"antaŭ %s",s:"sekundoj",m:"minuto",mm:"%d minutoj",h:"horo",hh:"%d horoj",d:"tago",dd:"%d tagoj",M:"monato",MM:"%d monatoj",y:"jaro",yy:"%d jaroj"}};return t.default.locale(n,null,!0),n}(n(7484))},3864:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"es-do",weekdays:"domingo_lunes_martes_miércoles_jueves_viernes_sábado".split("_"),weekdaysShort:"dom._lun._mar._mié._jue._vie._sáb.".split("_"),weekdaysMin:"do_lu_ma_mi_ju_vi_sá".split("_"),months:"enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),monthsShort:"ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"),weekStart:1,relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un año",yy:"%d años"},ordinal:function(e){return e+"º"},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY h:mm A",LLLL:"dddd, D [de] MMMM [de] YYYY h:mm A"}};return t.default.locale(n,null,!0),n}(n(7484))},7118:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"es-mx",weekdays:"domingo_lunes_martes_miércoles_jueves_viernes_sábado".split("_"),weekdaysShort:"dom._lun._mar._mié._jue._vie._sáb.".split("_"),weekdaysMin:"do_lu_ma_mi_ju_vi_sá".split("_"),months:"enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),monthsShort:"ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"),relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un año",yy:"%d años"},ordinal:function(e){return e+"º"},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY H:mm",LLLL:"dddd, D [de] MMMM [de] YYYY H:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},3521:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"es-pr",monthsShort:"ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"),weekdays:"domingo_lunes_martes_miércoles_jueves_viernes_sábado".split("_"),weekdaysShort:"dom._lun._mar._mié._jue._vie._sáb.".split("_"),weekdaysMin:"do_lu_ma_mi_ju_vi_sá".split("_"),months:"enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),weekStart:1,formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"MM/DD/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY h:mm A",LLLL:"dddd, D [de] MMMM [de] YYYY h:mm A"},relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un año",yy:"%d años"},ordinal:function(e){return e+"º"}};return t.default.locale(n,null,!0),n}(n(7484))},6165:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"es-us",weekdays:"domingo_lunes_martes_miércoles_jueves_viernes_sábado".split("_"),weekdaysShort:"dom._lun._mar._mié._jue._vie._sáb.".split("_"),weekdaysMin:"do_lu_ma_mi_ju_vi_sá".split("_"),months:"enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),monthsShort:"ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"),relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un año",yy:"%d años"},ordinal:function(e){return e+"º"},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"MM/DD/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY h:mm A",LLLL:"dddd, D [de] MMMM [de] YYYY h:mm A"}};return t.default.locale(n,null,!0),n}(n(7484))},7763:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"es",monthsShort:"ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"),weekdays:"domingo_lunes_martes_miércoles_jueves_viernes_sábado".split("_"),weekdaysShort:"dom._lun._mar._mié._jue._vie._sáb.".split("_"),weekdaysMin:"do_lu_ma_mi_ju_vi_sá".split("_"),months:"enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY H:mm",LLLL:"dddd, D [de] MMMM [de] YYYY H:mm"},relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un año",yy:"%d años"},ordinal:function(e){return e+"º"}};return t.default.locale(n,null,!0),n}(n(7484))},9670:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e);function n(e,t,n,r){var a={s:["mõne sekundi","mõni sekund","paar sekundit"],m:["ühe minuti","üks minut"],mm:["%d minuti","%d minutit"],h:["ühe tunni","tund aega","üks tund"],hh:["%d tunni","%d tundi"],d:["ühe päeva","üks päev"],M:["kuu aja","kuu aega","üks kuu"],MM:["%d kuu","%d kuud"],y:["ühe aasta","aasta","üks aasta"],yy:["%d aasta","%d aastat"]};return t?(a[n][2]?a[n][2]:a[n][1]).replace("%d",e):(r?a[n][0]:a[n][1]).replace("%d",e)}var r={name:"et",weekdays:"pühapäev_esmaspäev_teisipäev_kolmapäev_neljapäev_reede_laupäev".split("_"),weekdaysShort:"P_E_T_K_N_R_L".split("_"),weekdaysMin:"P_E_T_K_N_R_L".split("_"),months:"jaanuar_veebruar_märts_aprill_mai_juuni_juuli_august_september_oktoober_november_detsember".split("_"),monthsShort:"jaan_veebr_märts_apr_mai_juuni_juuli_aug_sept_okt_nov_dets".split("_"),ordinal:function(e){return e+"."},weekStart:1,relativeTime:{future:"%s pärast",past:"%s tagasi",s:n,m:n,mm:n,h:n,hh:n,d:n,dd:"%d päeva",M:n,MM:n,y:n,yy:n},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd, D. MMMM YYYY H:mm"}};return t.default.locale(r,null,!0),r}(n(7484))},6629:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"eu",weekdays:"igandea_astelehena_asteartea_asteazkena_osteguna_ostirala_larunbata".split("_"),months:"urtarrila_otsaila_martxoa_apirila_maiatza_ekaina_uztaila_abuztua_iraila_urria_azaroa_abendua".split("_"),weekStart:1,weekdaysShort:"ig._al._ar._az._og._ol._lr.".split("_"),monthsShort:"urt._ots._mar._api._mai._eka._uzt._abu._ira._urr._aza._abe.".split("_"),weekdaysMin:"ig_al_ar_az_og_ol_lr".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"YYYY[ko] MMMM[ren] D[a]",LLL:"YYYY[ko] MMMM[ren] D[a] HH:mm",LLLL:"dddd, YYYY[ko] MMMM[ren] D[a] HH:mm",l:"YYYY-M-D",ll:"YYYY[ko] MMM D[a]",lll:"YYYY[ko] MMM D[a] HH:mm",llll:"ddd, YYYY[ko] MMM D[a] HH:mm"},relativeTime:{future:"%s barru",past:"duela %s",s:"segundo batzuk",m:"minutu bat",mm:"%d minutu",h:"ordu bat",hh:"%d ordu",d:"egun bat",dd:"%d egun",M:"hilabete bat",MM:"%d hilabete",y:"urte bat",yy:"%d urte"}};return t.default.locale(n,null,!0),n}(n(7484))},6953:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"fa",weekdays:"یک‌شنبه_دوشنبه_سه‌شنبه_چهارشنبه_پنج‌شنبه_جمعه_شنبه".split("_"),weekdaysShort:"یک‌شنبه_دوشنبه_سه‌شنبه_چهارشنبه_پنج‌شنبه_جمعه_شنبه".split("_"),weekdaysMin:"ی_د_س_چ_پ_ج_ش".split("_"),weekStart:6,months:"ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر".split("_"),monthsShort:"ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"در %s",past:"%s پیش",s:"چند ثانیه",m:"یک دقیقه",mm:"%d دقیقه",h:"یک ساعت",hh:"%d ساعت",d:"یک روز",dd:"%d روز",M:"یک ماه",MM:"%d ماه",y:"یک سال",yy:"%d سال"}};return t.default.locale(n,null,!0),n}(n(7484))},7822:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e);function n(e,t,n,r){var a={s:"muutama sekunti",m:"minuutti",mm:"%d minuuttia",h:"tunti",hh:"%d tuntia",d:"päivä",dd:"%d päivää",M:"kuukausi",MM:"%d kuukautta",y:"vuosi",yy:"%d vuotta",numbers:"nolla_yksi_kaksi_kolme_neljä_viisi_kuusi_seitsemän_kahdeksan_yhdeksän".split("_")},i={s:"muutaman sekunnin",m:"minuutin",mm:"%d minuutin",h:"tunnin",hh:"%d tunnin",d:"päivän",dd:"%d päivän",M:"kuukauden",MM:"%d kuukauden",y:"vuoden",yy:"%d vuoden",numbers:"nollan_yhden_kahden_kolmen_neljän_viiden_kuuden_seitsemän_kahdeksan_yhdeksän".split("_")},s=r&&!t?i:a,o=s[n];return e<10?o.replace("%d",s.numbers[e]):o.replace("%d",e)}var r={name:"fi",weekdays:"sunnuntai_maanantai_tiistai_keskiviikko_torstai_perjantai_lauantai".split("_"),weekdaysShort:"su_ma_ti_ke_to_pe_la".split("_"),weekdaysMin:"su_ma_ti_ke_to_pe_la".split("_"),months:"tammikuu_helmikuu_maaliskuu_huhtikuu_toukokuu_kesäkuu_heinäkuu_elokuu_syyskuu_lokakuu_marraskuu_joulukuu".split("_"),monthsShort:"tammi_helmi_maalis_huhti_touko_kesä_heinä_elo_syys_loka_marras_joulu".split("_"),ordinal:function(e){return e+"."},weekStart:1,yearStart:4,relativeTime:{future:"%s päästä",past:"%s sitten",s:n,m:n,mm:n,h:n,hh:n,d:n,dd:n,M:n,MM:n,y:n,yy:n},formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD.MM.YYYY",LL:"D. MMMM[ta] YYYY",LLL:"D. MMMM[ta] YYYY, [klo] HH.mm",LLLL:"dddd, D. MMMM[ta] YYYY, [klo] HH.mm",l:"D.M.YYYY",ll:"D. MMM YYYY",lll:"D. MMM YYYY, [klo] HH.mm",llll:"ddd, D. MMM YYYY, [klo] HH.mm"}};return t.default.locale(r,null,!0),r}(n(7484))},9197:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"fo",weekdays:"sunnudagur_mánadagur_týsdagur_mikudagur_hósdagur_fríggjadagur_leygardagur".split("_"),months:"januar_februar_mars_apríl_mai_juni_juli_august_september_oktober_november_desember".split("_"),weekStart:1,weekdaysShort:"sun_mán_týs_mik_hós_frí_ley".split("_"),monthsShort:"jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des".split("_"),weekdaysMin:"su_má_tý_mi_hó_fr_le".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D. MMMM, YYYY HH:mm"},relativeTime:{future:"um %s",past:"%s síðani",s:"fá sekund",m:"ein minuttur",mm:"%d minuttir",h:"ein tími",hh:"%d tímar",d:"ein dagur",dd:"%d dagar",M:"ein mánaður",MM:"%d mánaðir",y:"eitt ár",yy:"%d ár"}};return t.default.locale(n,null,!0),n}(n(7484))},7989:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"fr-ca",weekdays:"dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi".split("_"),months:"janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre".split("_"),weekdaysShort:"dim._lun._mar._mer._jeu._ven._sam.".split("_"),monthsShort:"janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.".split("_"),weekdaysMin:"di_lu_ma_me_je_ve_sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"dans %s",past:"il y a %s",s:"quelques secondes",m:"une minute",mm:"%d minutes",h:"une heure",hh:"%d heures",d:"un jour",dd:"%d jours",M:"un mois",MM:"%d mois",y:"un an",yy:"%d ans"}};return t.default.locale(n,null,!0),n}(n(7484))},4254:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"fr-ch",weekdays:"dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi".split("_"),months:"janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre".split("_"),weekStart:1,weekdaysShort:"dim._lun._mar._mer._jeu._ven._sam.".split("_"),monthsShort:"janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.".split("_"),weekdaysMin:"di_lu_ma_me_je_ve_sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"dans %s",past:"il y a %s",s:"quelques secondes",m:"une minute",mm:"%d minutes",h:"une heure",hh:"%d heures",d:"un jour",dd:"%d jours",M:"un mois",MM:"%d mois",y:"un an",yy:"%d ans"}};return t.default.locale(n,null,!0),n}(n(7484))},6023:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"fr",weekdays:"dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi".split("_"),weekdaysShort:"dim._lun._mar._mer._jeu._ven._sam.".split("_"),weekdaysMin:"di_lu_ma_me_je_ve_sa".split("_"),months:"janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre".split("_"),monthsShort:"janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.".split("_"),weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"dans %s",past:"il y a %s",s:"quelques secondes",m:"une minute",mm:"%d minutes",h:"une heure",hh:"%d heures",d:"un jour",dd:"%d jours",M:"un mois",MM:"%d mois",y:"un an",yy:"%d ans"},ordinal:function(e){return e+(1===e?"er":"e")}};return t.default.locale(n,null,!0),n}(n(7484))},3220:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"fy",weekdays:"snein_moandei_tiisdei_woansdei_tongersdei_freed_sneon".split("_"),months:"jannewaris_febrewaris_maart_april_maaie_juny_july_augustus_septimber_oktober_novimber_desimber".split("_"),monthsShort:"jan._feb._mrt._apr._mai_jun._jul._aug._sep._okt._nov._des.".split("_"),weekStart:1,weekdaysShort:"si._mo._ti._wo._to._fr._so.".split("_"),weekdaysMin:"Si_Mo_Ti_Wo_To_Fr_So".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD-MM-YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"oer %s",past:"%s lyn",s:"in pear sekonden",m:"ien minút",mm:"%d minuten",h:"ien oere",hh:"%d oeren",d:"ien dei",dd:"%d dagen",M:"ien moanne",MM:"%d moannen",y:"ien jier",yy:"%d jierren"}};return t.default.locale(n,null,!0),n}(n(7484))},7467:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ga",weekdays:"Dé Domhnaigh_Dé Luain_Dé Máirt_Dé Céadaoin_Déardaoin_Dé hAoine_Dé Satharn".split("_"),months:"Eanáir_Feabhra_Márta_Aibreán_Bealtaine_Méitheamh_Iúil_Lúnasa_Meán Fómhair_Deaireadh Fómhair_Samhain_Nollaig".split("_"),weekStart:1,weekdaysShort:"Dom_Lua_Mái_Céa_Déa_hAo_Sat".split("_"),monthsShort:"Eaná_Feab_Márt_Aibr_Beal_Méit_Iúil_Lúna_Meán_Deai_Samh_Noll".split("_"),weekdaysMin:"Do_Lu_Má_Ce_Dé_hA_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"i %s",past:"%s ó shin",s:"cúpla soicind",m:"nóiméad",mm:"%d nóiméad",h:"uair an chloig",hh:"%d uair an chloig",d:"lá",dd:"%d lá",M:"mí",MM:"%d mí",y:"bliain",yy:"%d bliain"}};return t.default.locale(n,null,!0),n}(n(7484))},4855:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"gd",weekdays:"Didòmhnaich_Diluain_Dimàirt_Diciadain_Diardaoin_Dihaoine_Disathairne".split("_"),months:"Am Faoilleach_An Gearran_Am Màrt_An Giblean_An Cèitean_An t-Ògmhios_An t-Iuchar_An Lùnastal_An t-Sultain_An Dàmhair_An t-Samhain_An Dùbhlachd".split("_"),weekStart:1,weekdaysShort:"Did_Dil_Dim_Dic_Dia_Dih_Dis".split("_"),monthsShort:"Faoi_Gear_Màrt_Gibl_Cèit_Ògmh_Iuch_Lùn_Sult_Dàmh_Samh_Dùbh".split("_"),weekdaysMin:"Dò_Lu_Mà_Ci_Ar_Ha_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"ann an %s",past:"bho chionn %s",s:"beagan diogan",m:"mionaid",mm:"%d mionaidean",h:"uair",hh:"%d uairean",d:"latha",dd:"%d latha",M:"mìos",MM:"%d mìosan",y:"bliadhna",yy:"%d bliadhna"}};return t.default.locale(n,null,!0),n}(n(7484))},229:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"gl",weekdays:"domingo_luns_martes_mércores_xoves_venres_sábado".split("_"),months:"xaneiro_febreiro_marzo_abril_maio_xuño_xullo_agosto_setembro_outubro_novembro_decembro".split("_"),weekStart:1,weekdaysShort:"dom._lun._mar._mér._xov._ven._sáb.".split("_"),monthsShort:"xan._feb._mar._abr._mai._xuñ._xul._ago._set._out._nov._dec.".split("_"),weekdaysMin:"do_lu_ma_mé_xo_ve_sá".split("_"),ordinal:function(e){return e+"º"},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY H:mm",LLLL:"dddd, D [de] MMMM [de] YYYY H:mm"},relativeTime:{future:"en %s",past:"fai %s",s:"uns segundos",m:"un minuto",mm:"%d minutos",h:"unha hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un ano",yy:"%d anos"}};return t.default.locale(n,null,!0),n}(n(7484))},6312:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"gom-latn",weekdays:"Aitar_Somar_Mongllar_Budvar_Brestar_Sukrar_Son'var".split("_"),months:"Janer_Febrer_Mars_Abril_Mai_Jun_Julai_Agost_Setembr_Otubr_Novembr_Dezembr".split("_"),weekStart:1,weekdaysShort:"Ait._Som._Mon._Bud._Bre._Suk._Son.".split("_"),monthsShort:"Jan._Feb._Mars_Abr._Mai_Jun_Jul._Ago._Set._Otu._Nov._Dez.".split("_"),weekdaysMin:"Ai_Sm_Mo_Bu_Br_Su_Sn".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm [vazta]",LTS:"A h:mm:ss [vazta]",L:"DD-MM-YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY A h:mm [vazta]",LLLL:"dddd, MMMM[achea] Do, YYYY, A h:mm [vazta]",llll:"ddd, D MMM YYYY, A h:mm [vazta]"}};return t.default.locale(n,null,!0),n}(n(7484))},7632:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"gu",weekdays:"રવિવાર_સોમવાર_મંગળવાર_બુધ્વાર_ગુરુવાર_શુક્રવાર_શનિવાર".split("_"),months:"જાન્યુઆરી_ફેબ્રુઆરી_માર્ચ_એપ્રિલ_મે_જૂન_જુલાઈ_ઑગસ્ટ_સપ્ટેમ્બર_ઑક્ટ્બર_નવેમ્બર_ડિસેમ્બર".split("_"),weekdaysShort:"રવિ_સોમ_મંગળ_બુધ્_ગુરુ_શુક્ર_શનિ".split("_"),monthsShort:"જાન્યુ._ફેબ્રુ._માર્ચ_એપ્રિ._મે_જૂન_જુલા._ઑગ._સપ્ટે._ઑક્ટ્._નવે._ડિસે.".split("_"),weekdaysMin:"ર_સો_મં_બુ_ગુ_શુ_શ".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm વાગ્યે",LTS:"A h:mm:ss વાગ્યે",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm વાગ્યે",LLLL:"dddd, D MMMM YYYY, A h:mm વાગ્યે"},relativeTime:{future:"%s મા",past:"%s પેહલા",s:"અમુક પળો",m:"એક મિનિટ",mm:"%d મિનિટ",h:"એક કલાક",hh:"%d કલાક",d:"એક દિવસ",dd:"%d દિવસ",M:"એક મહિનો",MM:"%d મહિનો",y:"એક વર્ષ",yy:"%d વર્ષ"}};return t.default.locale(n,null,!0),n}(n(7484))},5418:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={s:"מספר שניות",ss:"%d שניות",m:"דקה",mm:"%d דקות",h:"שעה",hh:"%d שעות",hh2:"שעתיים",d:"יום",dd:"%d ימים",dd2:"יומיים",M:"חודש",MM:"%d חודשים",MM2:"חודשיים",y:"שנה",yy:"%d שנים",yy2:"שנתיים"};function r(e,t,r){return(n[r+(2===e?"2":"")]||n[r]).replace("%d",e)}var a={name:"he",weekdays:"ראשון_שני_שלישי_רביעי_חמישי_שישי_שבת".split("_"),weekdaysShort:"א׳_ב׳_ג׳_ד׳_ה׳_ו׳_ש׳".split("_"),weekdaysMin:"א׳_ב׳_ג׳_ד׳_ה׳_ו_ש׳".split("_"),months:"ינואר_פברואר_מרץ_אפריל_מאי_יוני_יולי_אוגוסט_ספטמבר_אוקטובר_נובמבר_דצמבר".split("_"),monthsShort:"ינו_פבר_מרץ_אפר_מאי_יונ_יול_אוג_ספט_אוק_נוב_דצמ".split("_"),relativeTime:{future:"בעוד %s",past:"לפני %s",s:r,m:r,mm:r,h:r,hh:r,d:r,dd:r,M:r,MM:r,y:r,yy:r},ordinal:function(e){return e},format:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D [ב]MMMM YYYY",LLL:"D [ב]MMMM YYYY HH:mm",LLLL:"dddd, D [ב]MMMM YYYY HH:mm",l:"D/M/YYYY",ll:"D MMM YYYY",lll:"D MMM YYYY HH:mm",llll:"ddd, D MMM YYYY HH:mm"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D [ב]MMMM YYYY",LLL:"D [ב]MMMM YYYY HH:mm",LLLL:"dddd, D [ב]MMMM YYYY HH:mm",l:"D/M/YYYY",ll:"D MMM YYYY",lll:"D MMM YYYY HH:mm",llll:"ddd, D MMM YYYY HH:mm"}};return t.default.locale(a,null,!0),a}(n(7484))},7573:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"hi",weekdays:"रविवार_सोमवार_मंगलवार_बुधवार_गुरूवार_शुक्रवार_शनिवार".split("_"),months:"जनवरी_फ़रवरी_मार्च_अप्रैल_मई_जून_जुलाई_अगस्त_सितम्बर_अक्टूबर_नवम्बर_दिसम्बर".split("_"),weekdaysShort:"रवि_सोम_मंगल_बुध_गुरू_शुक्र_शनि".split("_"),monthsShort:"जन._फ़र._मार्च_अप्रै._मई_जून_जुल._अग._सित._अक्टू._नव._दिस.".split("_"),weekdaysMin:"र_सो_मं_बु_गु_शु_श".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm बजे",LTS:"A h:mm:ss बजे",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm बजे",LLLL:"dddd, D MMMM YYYY, A h:mm बजे"},relativeTime:{future:"%s में",past:"%s पहले",s:"कुछ ही क्षण",m:"एक मिनट",mm:"%d मिनट",h:"एक घंटा",hh:"%d घंटे",d:"एक दिन",dd:"%d दिन",M:"एक महीने",MM:"%d महीने",y:"एक वर्ष",yy:"%d वर्ष"}};return t.default.locale(n,null,!0),n}(n(7484))},6257:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n="siječnja_veljače_ožujka_travnja_svibnja_lipnja_srpnja_kolovoza_rujna_listopada_studenoga_prosinca".split("_"),r="siječanj_veljača_ožujak_travanj_svibanj_lipanj_srpanj_kolovoz_rujan_listopad_studeni_prosinac".split("_"),a=/D[oD]?(\[[^[\]]*\]|\s)+MMMM?/,i=function(e,t){return a.test(t)?n[e.month()]:r[e.month()]};i.s=r,i.f=n;var s={name:"hr",weekdays:"nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota".split("_"),weekdaysShort:"ned._pon._uto._sri._čet._pet._sub.".split("_"),weekdaysMin:"ne_po_ut_sr_če_pe_su".split("_"),months:i,monthsShort:"sij._velj._ožu._tra._svi._lip._srp._kol._ruj._lis._stu._pro.".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd, D. MMMM YYYY H:mm"},relativeTime:{future:"za %s",past:"prije %s",s:"sekunda",m:"minuta",mm:"%d minuta",h:"sat",hh:"%d sati",d:"dan",dd:"%d dana",M:"mjesec",MM:"%d mjeseci",y:"godina",yy:"%d godine"},ordinal:function(e){return e+"."}};return t.default.locale(s,null,!0),s}(n(7484))},8889:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ht",weekdays:"dimanch_lendi_madi_mèkredi_jedi_vandredi_samdi".split("_"),months:"janvye_fevriye_mas_avril_me_jen_jiyè_out_septanm_oktòb_novanm_desanm".split("_"),weekdaysShort:"dim._len._mad._mèk._jed._van._sam.".split("_"),monthsShort:"jan._fev._mas_avr._me_jen_jiyè._out_sept._okt._nov._des.".split("_"),weekdaysMin:"di_le_ma_mè_je_va_sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"nan %s",past:"sa gen %s",s:"kèk segond",m:"yon minit",mm:"%d minit",h:"inèdtan",hh:"%d zè",d:"yon jou",dd:"%d jou",M:"yon mwa",MM:"%d mwa",y:"yon ane",yy:"%d ane"}};return t.default.locale(n,null,!0),n}(n(7484))},8562:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"hu",weekdays:"vasárnap_hétfő_kedd_szerda_csütörtök_péntek_szombat".split("_"),weekdaysShort:"vas_hét_kedd_sze_csüt_pén_szo".split("_"),weekdaysMin:"v_h_k_sze_cs_p_szo".split("_"),months:"január_február_március_április_május_június_július_augusztus_szeptember_október_november_december".split("_"),monthsShort:"jan_feb_márc_ápr_máj_jún_júl_aug_szept_okt_nov_dec".split("_"),ordinal:function(e){return e+"."},weekStart:1,relativeTime:{future:"%s múlva",past:"%s",s:function(e,t,n,r){return"néhány másodperc"+(r||t?"":"e")},m:function(e,t,n,r){return"egy perc"+(r||t?"":"e")},mm:function(e,t,n,r){return e+" perc"+(r||t?"":"e")},h:function(e,t,n,r){return"egy "+(r||t?"óra":"órája")},hh:function(e,t,n,r){return e+" "+(r||t?"óra":"órája")},d:function(e,t,n,r){return"egy "+(r||t?"nap":"napja")},dd:function(e,t,n,r){return e+" "+(r||t?"nap":"napja")},M:function(e,t,n,r){return"egy "+(r||t?"hónap":"hónapja")},MM:function(e,t,n,r){return e+" "+(r||t?"hónap":"hónapja")},y:function(e,t,n,r){return"egy "+(r||t?"év":"éve")},yy:function(e,t,n,r){return e+" "+(r||t?"év":"éve")}},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"YYYY.MM.DD.",LL:"YYYY. MMMM D.",LLL:"YYYY. MMMM D. H:mm",LLLL:"YYYY. MMMM D., dddd H:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},8242:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"hy-am",weekdays:"կիրակի_երկուշաբթի_երեքշաբթի_չորեքշաբթի_հինգշաբթի_ուրբաթ_շաբաթ".split("_"),months:"հունվարի_փետրվարի_մարտի_ապրիլի_մայիսի_հունիսի_հուլիսի_օգոստոսի_սեպտեմբերի_հոկտեմբերի_նոյեմբերի_դեկտեմբերի".split("_"),weekStart:1,weekdaysShort:"կրկ_երկ_երք_չրք_հնգ_ուրբ_շբթ".split("_"),monthsShort:"հնվ_փտր_մրտ_ապր_մյս_հնս_հլս_օգս_սպտ_հկտ_նմբ_դկտ".split("_"),weekdaysMin:"կրկ_երկ_երք_չրք_հնգ_ուրբ_շբթ".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY թ.",LLL:"D MMMM YYYY թ., HH:mm",LLLL:"dddd, D MMMM YYYY թ., HH:mm"},relativeTime:{future:"%s հետո",past:"%s առաջ",s:"մի քանի վայրկյան",m:"րոպե",mm:"%d րոպե",h:"ժամ",hh:"%d ժամ",d:"օր",dd:"%d օր",M:"ամիս",MM:"%d ամիս",y:"տարի",yy:"%d տարի"}};return t.default.locale(n,null,!0),n}(n(7484))},3783:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"id",weekdays:"Minggu_Senin_Selasa_Rabu_Kamis_Jumat_Sabtu".split("_"),months:"Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_November_Desember".split("_"),weekdaysShort:"Min_Sen_Sel_Rab_Kam_Jum_Sab".split("_"),monthsShort:"Jan_Feb_Mar_Apr_Mei_Jun_Jul_Agt_Sep_Okt_Nov_Des".split("_"),weekdaysMin:"Mg_Sn_Sl_Rb_Km_Jm_Sb".split("_"),weekStart:1,formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY [pukul] HH.mm",LLLL:"dddd, D MMMM YYYY [pukul] HH.mm"},relativeTime:{future:"dalam %s",past:"%s yang lalu",s:"beberapa detik",m:"semenit",mm:"%d menit",h:"sejam",hh:"%d jam",d:"sehari",dd:"%d hari",M:"sebulan",MM:"%d bulan",y:"setahun",yy:"%d tahun"},ordinal:function(e){return e+"."}};return t.default.locale(n,null,!0),n}(n(7484))},8980:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={s:["nokkrar sekúndur","nokkrar sekúndur","nokkrum sekúndum"],m:["mínúta","mínútu","mínútu"],mm:["mínútur","mínútur","mínútum"],h:["klukkustund","klukkustund","klukkustund"],hh:["klukkustundir","klukkustundir","klukkustundum"],d:["dagur","dag","degi"],dd:["dagar","daga","dögum"],M:["mánuður","mánuð","mánuði"],MM:["mánuðir","mánuði","mánuðum"],y:["ár","ár","ári"],yy:["ár","ár","árum"]};function r(e,t,r,a){var i=function(e,t,r,a){var i=a?0:r?1:2,s=2===e.length&&t%10==1?e[0]:e,o=n[s][i];return 1===e.length?o:"%d "+o}(r,e,a,t);return i.replace("%d",e)}var a={name:"is",weekdays:"sunnudagur_mánudagur_þriðjudagur_miðvikudagur_fimmtudagur_föstudagur_laugardagur".split("_"),months:"janúar_febrúar_mars_apríl_maí_júní_júlí_ágúst_september_október_nóvember_desember".split("_"),weekStart:1,weekdaysShort:"sun_mán_þri_mið_fim_fös_lau".split("_"),monthsShort:"jan_feb_mar_apr_maí_jún_júl_ágú_sep_okt_nóv_des".split("_"),weekdaysMin:"Su_Má_Þr_Mi_Fi_Fö_La".split("_"),ordinal:function(e){return e},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY [kl.] H:mm",LLLL:"dddd, D. MMMM YYYY [kl.] H:mm"},relativeTime:{future:"eftir %s",past:"fyrir %s síðan",s:r,m:r,mm:r,h:r,hh:r,d:r,dd:r,M:r,MM:r,y:r,yy:r}};return t.default.locale(a,null,!0),a}(n(7484))},3706:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"it-ch",weekdays:"domenica_lunedì_martedì_mercoledì_giovedì_venerdì_sabato".split("_"),months:"gennaio_febbraio_marzo_aprile_maggio_giugno_luglio_agosto_settembre_ottobre_novembre_dicembre".split("_"),weekStart:1,weekdaysShort:"dom_lun_mar_mer_gio_ven_sab".split("_"),monthsShort:"gen_feb_mar_apr_mag_giu_lug_ago_set_ott_nov_dic".split("_"),weekdaysMin:"do_lu_ma_me_gi_ve_sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"tra %s",past:"%s fa",s:"alcuni secondi",m:"un minuto",mm:"%d minuti",h:"un'ora",hh:"%d ore",d:"un giorno",dd:"%d giorni",M:"un mese",MM:"%d mesi",y:"un anno",yy:"%d anni"}};return t.default.locale(n,null,!0),n}(n(7484))},5551:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"it",weekdays:"domenica_lunedì_martedì_mercoledì_giovedì_venerdì_sabato".split("_"),weekdaysShort:"dom_lun_mar_mer_gio_ven_sab".split("_"),weekdaysMin:"do_lu_ma_me_gi_ve_sa".split("_"),months:"gennaio_febbraio_marzo_aprile_maggio_giugno_luglio_agosto_settembre_ottobre_novembre_dicembre".split("_"),weekStart:1,monthsShort:"gen_feb_mar_apr_mag_giu_lug_ago_set_ott_nov_dic".split("_"),formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"tra %s",past:"%s fa",s:"qualche secondo",m:"un minuto",mm:"%d minuti",h:"un' ora",hh:"%d ore",d:"un giorno",dd:"%d giorni",M:"un mese",MM:"%d mesi",y:"un anno",yy:"%d anni"},ordinal:function(e){return e+"º"}};return t.default.locale(n,null,!0),n}(n(7484))},6831:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ja",weekdays:"日曜日_月曜日_火曜日_水曜日_木曜日_金曜日_土曜日".split("_"),weekdaysShort:"日_月_火_水_木_金_土".split("_"),weekdaysMin:"日_月_火_水_木_金_土".split("_"),months:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),ordinal:function(e){return e+"日"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日 HH:mm",LLLL:"YYYY年M月D日 dddd HH:mm",l:"YYYY/MM/DD",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日(ddd) HH:mm"},meridiem:function(e){return e<12?"午前":"午後"},relativeTime:{future:"%s後",past:"%s前",s:"数秒",m:"1分",mm:"%d分",h:"1時間",hh:"%d時間",d:"1日",dd:"%d日",M:"1ヶ月",MM:"%dヶ月",y:"1年",yy:"%d年"}};return t.default.locale(n,null,!0),n}(n(7484))},2641:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"jv",weekdays:"Minggu_Senen_Seloso_Rebu_Kemis_Jemuwah_Septu".split("_"),months:"Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_Nopember_Desember".split("_"),weekStart:1,weekdaysShort:"Min_Sen_Sel_Reb_Kem_Jem_Sep".split("_"),monthsShort:"Jan_Feb_Mar_Apr_Mei_Jun_Jul_Ags_Sep_Okt_Nop_Des".split("_"),weekdaysMin:"Mg_Sn_Sl_Rb_Km_Jm_Sp".split("_"),ordinal:function(e){return e},formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY [pukul] HH.mm",LLLL:"dddd, D MMMM YYYY [pukul] HH.mm"},relativeTime:{future:"wonten ing %s",past:"%s ingkang kepengker",s:"sawetawis detik",m:"setunggal menit",mm:"%d menit",h:"setunggal jam",hh:"%d jam",d:"sedinten",dd:"%d dinten",M:"sewulan",MM:"%d wulan",y:"setaun",yy:"%d taun"}};return t.default.locale(n,null,!0),n}(n(7484))},6622:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ka",weekdays:"კვირა_ორშაბათი_სამშაბათი_ოთხშაბათი_ხუთშაბათი_პარასკევი_შაბათი".split("_"),weekdaysShort:"კვი_ორშ_სამ_ოთხ_ხუთ_პარ_შაბ".split("_"),weekdaysMin:"კვ_ორ_სა_ოთ_ხუ_პა_შა".split("_"),months:"იანვარი_თებერვალი_მარტი_აპრილი_მაისი_ივნისი_ივლისი_აგვისტო_სექტემბერი_ოქტომბერი_ნოემბერი_დეკემბერი".split("_"),monthsShort:"იან_თებ_მარ_აპრ_მაი_ივნ_ივლ_აგვ_სექ_ოქტ_ნოე_დეკ".split("_"),weekStart:1,formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY h:mm A",LLLL:"dddd, D MMMM YYYY h:mm A"},relativeTime:{future:"%s შემდეგ",past:"%s წინ",s:"წამი",m:"წუთი",mm:"%d წუთი",h:"საათი",hh:"%d საათის",d:"დღეს",dd:"%d დღის განმავლობაში",M:"თვის",MM:"%d თვის",y:"წელი",yy:"%d წლის"},ordinal:function(e){return e}};return t.default.locale(n,null,!0),n}(n(7484))},2921:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"kk",weekdays:"жексенбі_дүйсенбі_сейсенбі_сәрсенбі_бейсенбі_жұма_сенбі".split("_"),weekdaysShort:"жек_дүй_сей_сәр_бей_жұм_сен".split("_"),weekdaysMin:"жк_дй_сй_ср_бй_жм_сн".split("_"),months:"қаңтар_ақпан_наурыз_сәуір_мамыр_маусым_шілде_тамыз_қыркүйек_қазан_қараша_желтоқсан".split("_"),monthsShort:"қаң_ақп_нау_сәу_мам_мау_шіл_там_қыр_қаз_қар_жел".split("_"),weekStart:1,relativeTime:{future:"%s ішінде",past:"%s бұрын",s:"бірнеше секунд",m:"бір минут",mm:"%d минут",h:"бір сағат",hh:"%d сағат",d:"бір күн",dd:"%d күн",M:"бір ай",MM:"%d ай",y:"бір жыл",yy:"%d жыл"},ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},5567:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"km",weekdays:"អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍".split("_"),months:"មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ".split("_"),weekStart:1,weekdaysShort:"អា_ច_អ_ព_ព្រ_សុ_ស".split("_"),monthsShort:"មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ".split("_"),weekdaysMin:"អា_ច_អ_ព_ព្រ_សុ_ស".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"%sទៀត",past:"%sមុន",s:"ប៉ុន្មានវិនាទី",m:"មួយនាទី",mm:"%d នាទី",h:"មួយម៉ោង",hh:"%d ម៉ោង",d:"មួយថ្ងៃ",dd:"%d ថ្ងៃ",M:"មួយខែ",MM:"%d ខែ",y:"មួយឆ្នាំ",yy:"%d ឆ្នាំ"}};return t.default.locale(n,null,!0),n}(n(7484))},1113:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"kn",weekdays:"ಭಾನುವಾರ_ಸೋಮವಾರ_ಮಂಗಳವಾರ_ಬುಧವಾರ_ಗುರುವಾರ_ಶುಕ್ರವಾರ_ಶನಿವಾರ".split("_"),months:"ಜನವರಿ_ಫೆಬ್ರವರಿ_ಮಾರ್ಚ್_ಏಪ್ರಿಲ್_ಮೇ_ಜೂನ್_ಜುಲೈ_ಆಗಸ್ಟ್_ಸೆಪ್ಟೆಂಬರ್_ಅಕ್ಟೋಬರ್_ನವೆಂಬರ್_ಡಿಸೆಂಬರ್".split("_"),weekdaysShort:"ಭಾನು_ಸೋಮ_ಮಂಗಳ_ಬುಧ_ಗುರು_ಶುಕ್ರ_ಶನಿ".split("_"),monthsShort:"ಜನ_ಫೆಬ್ರ_ಮಾರ್ಚ್_ಏಪ್ರಿಲ್_ಮೇ_ಜೂನ್_ಜುಲೈ_ಆಗಸ್ಟ್_ಸೆಪ್ಟೆಂ_ಅಕ್ಟೋ_ನವೆಂ_ಡಿಸೆಂ".split("_"),weekdaysMin:"ಭಾ_ಸೋ_ಮಂ_ಬು_ಗು_ಶು_ಶ".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm",LTS:"A h:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm",LLLL:"dddd, D MMMM YYYY, A h:mm"},relativeTime:{future:"%s ನಂತರ",past:"%s ಹಿಂದೆ",s:"ಕೆಲವು ಕ್ಷಣಗಳು",m:"ಒಂದು ನಿಮಿಷ",mm:"%d ನಿಮಿಷ",h:"ಒಂದು ಗಂಟೆ",hh:"%d ಗಂಟೆ",d:"ಒಂದು ದಿನ",dd:"%d ದಿನ",M:"ಒಂದು ತಿಂಗಳು",MM:"%d ತಿಂಗಳು",y:"ಒಂದು ವರ್ಷ",yy:"%d ವರ್ಷ"}};return t.default.locale(n,null,!0),n}(n(7484))},9132:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ko",weekdays:"일요일_월요일_화요일_수요일_목요일_금요일_토요일".split("_"),weekdaysShort:"일_월_화_수_목_금_토".split("_"),weekdaysMin:"일_월_화_수_목_금_토".split("_"),months:"1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월".split("_"),monthsShort:"1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm",LTS:"A h:mm:ss",L:"YYYY.MM.DD.",LL:"YYYY년 MMMM D일",LLL:"YYYY년 MMMM D일 A h:mm",LLLL:"YYYY년 MMMM D일 dddd A h:mm",l:"YYYY.MM.DD.",ll:"YYYY년 MMMM D일",lll:"YYYY년 MMMM D일 A h:mm",llll:"YYYY년 MMMM D일 dddd A h:mm"},meridiem:function(e){return e<12?"오전":"오후"},relativeTime:{future:"%s 후",past:"%s 전",s:"몇 초",m:"1분",mm:"%d분",h:"한 시간",hh:"%d시간",d:"하루",dd:"%d일",M:"한 달",MM:"%d달",y:"일 년",yy:"%d년"}};return t.default.locale(n,null,!0),n}(n(7484))},4888:function(e,t,n){!function(e,t){"use strict";var n=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(t),r={1:"١",2:"٢",3:"٣",4:"٤",5:"٥",6:"٦",7:"٧",8:"٨",9:"٩",0:"٠"},a={"١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","٠":"0"},i=["کانوونی دووەم","شوبات","ئادار","نیسان","ئایار","حوزەیران","تەممووز","ئاب","ئەیلوول","تشرینی یەکەم","تشرینی دووەم","کانوونی یەکەم"],s={name:"ku",months:i,monthsShort:i,weekdays:"یەکشەممە_دووشەممە_سێشەممە_چوارشەممە_پێنجشەممە_هەینی_شەممە".split("_"),weekdaysShort:"یەکشەم_دووشەم_سێشەم_چوارشەم_پێنجشەم_هەینی_شەممە".split("_"),weekStart:6,weekdaysMin:"ی_د_س_چ_پ_هـ_ش".split("_"),preparse:function(e){return e.replace(/[١٢٣٤٥٦٧٨٩٠]/g,(function(e){return a[e]})).replace(/،/g,",")},postformat:function(e){return e.replace(/\d/g,(function(e){return r[e]})).replace(/,/g,"،")},ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},meridiem:function(e){return e<12?"پ.ن":"د.ن"},relativeTime:{future:"لە %s",past:"لەمەوپێش %s",s:"چەند چرکەیەک",m:"یەک خولەک",mm:"%d خولەک",h:"یەک کاتژمێر",hh:"%d کاتژمێر",d:"یەک ڕۆژ",dd:"%d ڕۆژ",M:"یەک مانگ",MM:"%d مانگ",y:"یەک ساڵ",yy:"%d ساڵ"}};n.default.locale(s,null,!0),e.default=s,e.englishToArabicNumbersMap=r,Object.defineProperty(e,"__esModule",{value:!0})}(t,n(7484))},466:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ky",weekdays:"Жекшемби_Дүйшөмбү_Шейшемби_Шаршемби_Бейшемби_Жума_Ишемби".split("_"),months:"январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь".split("_"),weekStart:1,weekdaysShort:"Жек_Дүй_Шей_Шар_Бей_Жум_Ише".split("_"),monthsShort:"янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек".split("_"),weekdaysMin:"Жк_Дй_Шй_Шр_Бй_Жм_Иш".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"%s ичинде",past:"%s мурун",s:"бирнече секунд",m:"бир мүнөт",mm:"%d мүнөт",h:"бир саат",hh:"%d саат",d:"бир күн",dd:"%d күн",M:"бир ай",MM:"%d ай",y:"бир жыл",yy:"%d жыл"}};return t.default.locale(n,null,!0),n}(n(7484))},1796:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"lb",weekdays:"Sonndeg_Méindeg_Dënschdeg_Mëttwoch_Donneschdeg_Freideg_Samschdeg".split("_"),months:"Januar_Februar_Mäerz_Abrëll_Mee_Juni_Juli_August_September_Oktober_November_Dezember".split("_"),weekStart:1,weekdaysShort:"So._Mé._Dë._Më._Do._Fr._Sa.".split("_"),monthsShort:"Jan._Febr._Mrz._Abr._Mee_Jun._Jul._Aug._Sept._Okt._Nov._Dez.".split("_"),weekdaysMin:"So_Mé_Dë_Më_Do_Fr_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"H:mm [Auer]",LTS:"H:mm:ss [Auer]",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm [Auer]",LLLL:"dddd, D. MMMM YYYY H:mm [Auer]"}};return t.default.locale(n,null,!0),n}(n(7484))},8894:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"lo",weekdays:"ອາທິດ_ຈັນ_ອັງຄານ_ພຸດ_ພະຫັດ_ສຸກ_ເສົາ".split("_"),months:"ມັງກອນ_ກຸມພາ_ມີນາ_ເມສາ_ພຶດສະພາ_ມິຖຸນາ_ກໍລະກົດ_ສິງຫາ_ກັນຍາ_ຕຸລາ_ພະຈິກ_ທັນວາ".split("_"),weekdaysShort:"ທິດ_ຈັນ_ອັງຄານ_ພຸດ_ພະຫັດ_ສຸກ_ເສົາ".split("_"),monthsShort:"ມັງກອນ_ກຸມພາ_ມີນາ_ເມສາ_ພຶດສະພາ_ມິຖຸນາ_ກໍລະກົດ_ສິງຫາ_ກັນຍາ_ຕຸລາ_ພະຈິກ_ທັນວາ".split("_"),weekdaysMin:"ທ_ຈ_ອຄ_ພ_ພຫ_ສກ_ສ".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"ວັນdddd D MMMM YYYY HH:mm"},relativeTime:{future:"ອີກ %s",past:"%sຜ່ານມາ",s:"ບໍ່ເທົ່າໃດວິນາທີ",m:"1 ນາທີ",mm:"%d ນາທີ",h:"1 ຊົ່ວໂມງ",hh:"%d ຊົ່ວໂມງ",d:"1 ມື້",dd:"%d ມື້",M:"1 ເດືອນ",MM:"%d ເດືອນ",y:"1 ປີ",yy:"%d ປີ"}};return t.default.locale(n,null,!0),n}(n(7484))},8768:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n="sausio_vasario_kovo_balandžio_gegužės_birželio_liepos_rugpjūčio_rugsėjo_spalio_lapkričio_gruodžio".split("_"),r="sausis_vasaris_kovas_balandis_gegužė_birželis_liepa_rugpjūtis_rugsėjis_spalis_lapkritis_gruodis".split("_"),a=/D[oD]?(\[[^\[\]]*\]|\s)+MMMM?|MMMM?(\[[^\[\]]*\]|\s)+D[oD]?/,i=function(e,t){return a.test(t)?n[e.month()]:r[e.month()]};i.s=r,i.f=n;var s={name:"lt",weekdays:"sekmadienis_pirmadienis_antradienis_trečiadienis_ketvirtadienis_penktadienis_šeštadienis".split("_"),weekdaysShort:"sek_pir_ant_tre_ket_pen_šeš".split("_"),weekdaysMin:"s_p_a_t_k_pn_š".split("_"),months:i,monthsShort:"sau_vas_kov_bal_geg_bir_lie_rgp_rgs_spa_lap_grd".split("_"),ordinal:function(e){return e+"."},weekStart:1,relativeTime:{future:"už %s",past:"prieš %s",s:"kelias sekundes",m:"minutę",mm:"%d minutes",h:"valandą",hh:"%d valandas",d:"dieną",dd:"%d dienas",M:"mėnesį",MM:"%d mėnesius",y:"metus",yy:"%d metus"},format:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"YYYY [m.] MMMM D [d.]",LLL:"YYYY [m.] MMMM D [d.], HH:mm [val.]",LLLL:"YYYY [m.] MMMM D [d.], dddd, HH:mm [val.]",l:"YYYY-MM-DD",ll:"YYYY [m.] MMMM D [d.]",lll:"YYYY [m.] MMMM D [d.], HH:mm [val.]",llll:"YYYY [m.] MMMM D [d.], ddd, HH:mm [val.]"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"YYYY [m.] MMMM D [d.]",LLL:"YYYY [m.] MMMM D [d.], HH:mm [val.]",LLLL:"YYYY [m.] MMMM D [d.], dddd, HH:mm [val.]",l:"YYYY-MM-DD",ll:"YYYY [m.] MMMM D [d.]",lll:"YYYY [m.] MMMM D [d.], HH:mm [val.]",llll:"YYYY [m.] MMMM D [d.], ddd, HH:mm [val.]"}};return t.default.locale(s,null,!0),s}(n(7484))},953:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"lv",weekdays:"svētdiena_pirmdiena_otrdiena_trešdiena_ceturtdiena_piektdiena_sestdiena".split("_"),months:"janvāris_februāris_marts_aprīlis_maijs_jūnijs_jūlijs_augusts_septembris_oktobris_novembris_decembris".split("_"),weekStart:1,weekdaysShort:"Sv_P_O_T_C_Pk_S".split("_"),monthsShort:"jan_feb_mar_apr_mai_jūn_jūl_aug_sep_okt_nov_dec".split("_"),weekdaysMin:"Sv_P_O_T_C_Pk_S".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY.",LL:"YYYY. [gada] D. MMMM",LLL:"YYYY. [gada] D. MMMM, HH:mm",LLLL:"YYYY. [gada] D. MMMM, dddd, HH:mm"},relativeTime:{future:"pēc %s",past:"pirms %s",s:"dažām sekundēm",m:"minūtes",mm:"%d minūtēm",h:"stundas",hh:"%d stundām",d:"dienas",dd:"%d dienām",M:"mēneša",MM:"%d mēnešiem",y:"gada",yy:"%d gadiem"}};return t.default.locale(n,null,!0),n}(n(7484))},8066:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"me",weekdays:"nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota".split("_"),months:"januar_februar_mart_april_maj_jun_jul_avgust_septembar_oktobar_novembar_decembar".split("_"),weekStart:1,weekdaysShort:"ned._pon._uto._sri._čet._pet._sub.".split("_"),monthsShort:"jan._feb._mar._apr._maj_jun_jul_avg._sep._okt._nov._dec.".split("_"),weekdaysMin:"ne_po_ut_sr_če_pe_su".split("_"),ordinal:function(e){return e},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd, D. MMMM YYYY H:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},8602:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"mi",weekdays:"Rātapu_Mane_Tūrei_Wenerei_Tāite_Paraire_Hātarei".split("_"),months:"Kohi-tāte_Hui-tanguru_Poutū-te-rangi_Paenga-whāwhā_Haratua_Pipiri_Hōngoingoi_Here-turi-kōkā_Mahuru_Whiringa-ā-nuku_Whiringa-ā-rangi_Hakihea".split("_"),weekStart:1,weekdaysShort:"Ta_Ma_Tū_We_Tāi_Pa_Hā".split("_"),monthsShort:"Kohi_Hui_Pou_Pae_Hara_Pipi_Hōngoi_Here_Mahu_Whi-nu_Whi-ra_Haki".split("_"),weekdaysMin:"Ta_Ma_Tū_We_Tāi_Pa_Hā".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY [i] HH:mm",LLLL:"dddd, D MMMM YYYY [i] HH:mm"},relativeTime:{future:"i roto i %s",past:"%s i mua",s:"te hēkona ruarua",m:"he meneti",mm:"%d meneti",h:"te haora",hh:"%d haora",d:"he ra",dd:"%d ra",M:"he marama",MM:"%d marama",y:"he tau",yy:"%d tau"}};return t.default.locale(n,null,!0),n}(n(7484))},1560:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"mk",weekdays:"недела_понеделник_вторник_среда_четврток_петок_сабота".split("_"),months:"јануари_февруари_март_април_мај_јуни_јули_август_септември_октомври_ноември_декември".split("_"),weekStart:1,weekdaysShort:"нед_пон_вто_сре_чет_пет_саб".split("_"),monthsShort:"јан_фев_мар_апр_мај_јун_јул_авг_сеп_окт_ное_дек".split("_"),weekdaysMin:"нe_пo_вт_ср_че_пе_сa".split("_"),ordinal:function(e){return e},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"D.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY H:mm",LLLL:"dddd, D MMMM YYYY H:mm"},relativeTime:{future:"после %s",past:"пред %s",s:"неколку секунди",m:"минута",mm:"%d минути",h:"час",hh:"%d часа",d:"ден",dd:"%d дена",M:"месец",MM:"%d месеци",y:"година",yy:"%d години"}};return t.default.locale(n,null,!0),n}(n(7484))},4017:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ml",weekdays:"ഞായറാഴ്ച_തിങ്കളാഴ്ച_ചൊവ്വാഴ്ച_ബുധനാഴ്ച_വ്യാഴാഴ്ച_വെള്ളിയാഴ്ച_ശനിയാഴ്ച".split("_"),months:"ജനുവരി_ഫെബ്രുവരി_മാർച്ച്_ഏപ്രിൽ_മേയ്_ജൂൺ_ജൂലൈ_ഓഗസ്റ്റ്_സെപ്റ്റംബർ_ഒക്ടോബർ_നവംബർ_ഡിസംബർ".split("_"),weekdaysShort:"ഞായർ_തിങ്കൾ_ചൊവ്വ_ബുധൻ_വ്യാഴം_വെള്ളി_ശനി".split("_"),monthsShort:"ജനു._ഫെബ്രു._മാർ._ഏപ്രി._മേയ്_ജൂൺ_ജൂലൈ._ഓഗ._സെപ്റ്റ._ഒക്ടോ._നവം._ഡിസം.".split("_"),weekdaysMin:"ഞാ_തി_ചൊ_ബു_വ്യാ_വെ_ശ".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm -നു",LTS:"A h:mm:ss -നു",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm -നു",LLLL:"dddd, D MMMM YYYY, A h:mm -നു"},relativeTime:{future:"%s കഴിഞ്ഞ്",past:"%s മുൻപ്",s:"അൽപ നിമിഷങ്ങൾ",m:"ഒരു മിനിറ്റ്",mm:"%d മിനിറ്റ്",h:"ഒരു മണിക്കൂർ",hh:"%d മണിക്കൂർ",d:"ഒരു ദിവസം",dd:"%d ദിവസം",M:"ഒരു മാസം",MM:"%d മാസം",y:"ഒരു വർഷം",yy:"%d വർഷം"}};return t.default.locale(n,null,!0),n}(n(7484))},4717:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"mn",weekdays:"Ням_Даваа_Мягмар_Лхагва_Пүрэв_Баасан_Бямба".split("_"),months:"Нэгдүгээр сар_Хоёрдугаар сар_Гуравдугаар сар_Дөрөвдүгээр сар_Тавдугаар сар_Зургадугаар сар_Долдугаар сар_Наймдугаар сар_Есдүгээр сар_Аравдугаар сар_Арван нэгдүгээр сар_Арван хоёрдугаар сар".split("_"),weekdaysShort:"Ням_Дав_Мяг_Лха_Пүр_Баа_Бям".split("_"),monthsShort:"1 сар_2 сар_3 сар_4 сар_5 сар_6 сар_7 сар_8 сар_9 сар_10 сар_11 сар_12 сар".split("_"),weekdaysMin:"Ня_Да_Мя_Лх_Пү_Ба_Бя".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"YYYY оны MMMMын D",LLL:"YYYY оны MMMMын D HH:mm",LLLL:"dddd, YYYY оны MMMMын D HH:mm"},relativeTime:{future:"%s",past:"%s",s:"саяхан",m:"м",mm:"%dм",h:"1ц",hh:"%dц",d:"1ө",dd:"%dө",M:"1с",MM:"%dс",y:"1ж",yy:"%dж"}};return t.default.locale(n,null,!0),n}(n(7484))},5473:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"mr",weekdays:"रविवार_सोमवार_मंगळवार_बुधवार_गुरूवार_शुक्रवार_शनिवार".split("_"),months:"जानेवारी_फेब्रुवारी_मार्च_एप्रिल_मे_जून_जुलै_ऑगस्ट_सप्टेंबर_ऑक्टोबर_नोव्हेंबर_डिसेंबर".split("_"),weekdaysShort:"रवि_सोम_मंगळ_बुध_गुरू_शुक्र_शनि".split("_"),monthsShort:"जाने._फेब्रु._मार्च._एप्रि._मे._जून._जुलै._ऑग._सप्टें._ऑक्टो._नोव्हें._डिसें.".split("_"),weekdaysMin:"र_सो_मं_बु_गु_शु_श".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm वाजता",LTS:"A h:mm:ss वाजता",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm वाजता",LLLL:"dddd, D MMMM YYYY, A h:mm वाजता"}};return t.default.locale(n,null,!0),n}(n(7484))},7387:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ms-my",weekdays:"Ahad_Isnin_Selasa_Rabu_Khamis_Jumaat_Sabtu".split("_"),months:"Januari_Februari_Mac_April_Mei_Jun_Julai_Ogos_September_Oktober_November_Disember".split("_"),weekStart:1,weekdaysShort:"Ahd_Isn_Sel_Rab_Kha_Jum_Sab".split("_"),monthsShort:"Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ogs_Sep_Okt_Nov_Dis".split("_"),weekdaysMin:"Ah_Is_Sl_Rb_Km_Jm_Sb".split("_"),ordinal:function(e){return e},formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY [pukul] HH.mm",LLLL:"dddd, D MMMM YYYY [pukul] HH.mm"},relativeTime:{future:"dalam %s",past:"%s yang lepas",s:"beberapa saat",m:"seminit",mm:"%d minit",h:"sejam",hh:"%d jam",d:"sehari",dd:"%d hari",M:"sebulan",MM:"%d bulan",y:"setahun",yy:"%d tahun"}};return t.default.locale(n,null,!0),n}(n(7484))},5742:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ms",weekdays:"Ahad_Isnin_Selasa_Rabu_Khamis_Jumaat_Sabtu".split("_"),weekdaysShort:"Ahd_Isn_Sel_Rab_Kha_Jum_Sab".split("_"),weekdaysMin:"Ah_Is_Sl_Rb_Km_Jm_Sb".split("_"),months:"Januari_Februari_Mac_April_Mei_Jun_Julai_Ogos_September_Oktober_November_Disember".split("_"),monthsShort:"Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ogs_Sep_Okt_Nov_Dis".split("_"),weekStart:1,formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH.mm",LLLL:"dddd, D MMMM YYYY HH.mm"},relativeTime:{future:"dalam %s",past:"%s yang lepas",s:"beberapa saat",m:"seminit",mm:"%d minit",h:"sejam",hh:"%d jam",d:"sehari",dd:"%d hari",M:"sebulan",MM:"%d bulan",y:"setahun",yy:"%d tahun"},ordinal:function(e){return e+"."}};return t.default.locale(n,null,!0),n}(n(7484))},8477:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"mt",weekdays:"Il-Ħadd_It-Tnejn_It-Tlieta_L-Erbgħa_Il-Ħamis_Il-Ġimgħa_Is-Sibt".split("_"),months:"Jannar_Frar_Marzu_April_Mejju_Ġunju_Lulju_Awwissu_Settembru_Ottubru_Novembru_Diċembru".split("_"),weekStart:1,weekdaysShort:"Ħad_Tne_Tli_Erb_Ħam_Ġim_Sib".split("_"),monthsShort:"Jan_Fra_Mar_Apr_Mej_Ġun_Lul_Aww_Set_Ott_Nov_Diċ".split("_"),weekdaysMin:"Ħa_Tn_Tl_Er_Ħa_Ġi_Si".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"f’ %s",past:"%s ilu",s:"ftit sekondi",m:"minuta",mm:"%d minuti",h:"siegħa",hh:"%d siegħat",d:"ġurnata",dd:"%d ġranet",M:"xahar",MM:"%d xhur",y:"sena",yy:"%d sni"}};return t.default.locale(n,null,!0),n}(n(7484))},2966:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"my",weekdays:"တနင်္ဂနွေ_တနင်္လာ_အင်္ဂါ_ဗုဒ္ဓဟူး_ကြာသပတေး_သောကြာ_စနေ".split("_"),months:"ဇန်နဝါရီ_ဖေဖော်ဝါရီ_မတ်_ဧပြီ_မေ_ဇွန်_ဇူလိုင်_သြဂုတ်_စက်တင်ဘာ_အောက်တိုဘာ_နိုဝင်ဘာ_ဒီဇင်ဘာ".split("_"),weekStart:1,weekdaysShort:"နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ".split("_"),monthsShort:"ဇန်_ဖေ_မတ်_ပြီ_မေ_ဇွန်_လိုင်_သြ_စက်_အောက်_နို_ဒီ".split("_"),weekdaysMin:"နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"လာမည့် %s မှာ",past:"လွန်ခဲ့သော %s က",s:"စက္ကန်.အနည်းငယ်",m:"တစ်မိနစ်",mm:"%d မိနစ်",h:"တစ်နာရီ",hh:"%d နာရီ",d:"တစ်ရက်",dd:"%d ရက်",M:"တစ်လ",MM:"%d လ",y:"တစ်နှစ်",yy:"%d နှစ်"}};return t.default.locale(n,null,!0),n}(n(7484))},9682:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"nb",weekdays:"søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag".split("_"),weekdaysShort:"sø._ma._ti._on._to._fr._lø.".split("_"),weekdaysMin:"sø_ma_ti_on_to_fr_lø".split("_"),months:"januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember".split("_"),monthsShort:"jan._feb._mars_april_mai_juni_juli_aug._sep._okt._nov._des.".split("_"),ordinal:function(e){return e+"."},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY [kl.] HH:mm",LLLL:"dddd D. MMMM YYYY [kl.] HH:mm"},relativeTime:{future:"om %s",past:"%s siden",s:"noen sekunder",m:"ett minutt",mm:"%d minutter",h:"en time",hh:"%d timer",d:"en dag",dd:"%d dager",M:"en måned",MM:"%d måneder",y:"ett år",yy:"%d år"}};return t.default.locale(n,null,!0),n}(n(7484))},4149:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ne",weekdays:"आइतबार_सोमबार_मङ्गलबार_बुधबार_बिहिबार_शुक्रबार_शनिबार".split("_"),weekdaysShort:"आइत._सोम._मङ्गल._बुध._बिहि._शुक्र._शनि.".split("_"),weekdaysMin:"आ._सो._मं._बु._बि._शु._श.".split("_"),months:"जनवरी_फेब्रुवरी_मार्च_अप्रिल_मे_जुन_जुलाई_अगष्ट_सेप्टेम्बर_अक्टोबर_नोभेम्बर_डिसेम्बर".split("_"),monthsShort:"जन._फेब्रु._मार्च_अप्रि._मई_जुन_जुलाई._अग._सेप्ट._अक्टो._नोभे._डिसे.".split("_"),relativeTime:{future:"%s पछि",past:"%s अघि",s:"सेकेन्ड",m:"एक मिनेट",mm:"%d मिनेट",h:"घन्टा",hh:"%d घन्टा",d:"एक दिन",dd:"%d दिन",M:"एक महिना",MM:"%d महिना",y:"एक वर्ष",yy:"%d वर्ष"},ordinal:function(e){return(""+e).replace(/\d/g,(function(e){return"०१२३४५६७८९"[e]}))},formats:{LT:"Aको h:mm बजे",LTS:"Aको h:mm:ss बजे",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, Aको h:mm बजे",LLLL:"dddd, D MMMM YYYY, Aको h:mm बजे"}};return t.default.locale(n,null,!0),n}(n(7484))},7496:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"nl-be",weekdays:"zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag".split("_"),months:"januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december".split("_"),monthsShort:"jan._feb._mrt._apr._mei_jun._jul._aug._sep._okt._nov._dec.".split("_"),weekStart:1,weekdaysShort:"zo._ma._di._wo._do._vr._za.".split("_"),weekdaysMin:"zo_ma_di_wo_do_vr_za".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"over %s",past:"%s geleden",s:"een paar seconden",m:"één minuut",mm:"%d minuten",h:"één uur",hh:"%d uur",d:"één dag",dd:"%d dagen",M:"één maand",MM:"%d maanden",y:"één jaar",yy:"%d jaar"}};return t.default.locale(n,null,!0),n}(n(7484))},9182:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"nl",weekdays:"zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag".split("_"),weekdaysShort:"zo._ma._di._wo._do._vr._za.".split("_"),weekdaysMin:"zo_ma_di_wo_do_vr_za".split("_"),months:"januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december".split("_"),monthsShort:"jan_feb_mrt_apr_mei_jun_jul_aug_sep_okt_nov_dec".split("_"),ordinal:function(e){return e+(1===e||8===e||e>=20?"ste":"de")},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD-MM-YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"over %s",past:"%s geleden",s:"een paar seconden",m:"een minuut",mm:"%d minuten",h:"een uur",hh:"%d uur",d:"een dag",dd:"%d dagen",M:"een maand",MM:"%d maanden",y:"een jaar",yy:"%d jaar"}};return t.default.locale(n,null,!0),n}(n(7484))},2722:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"nn",weekdays:"sundag_måndag_tysdag_onsdag_torsdag_fredag_laurdag".split("_"),weekdaysShort:"sun_mån_tys_ons_tor_fre_lau".split("_"),weekdaysMin:"su_må_ty_on_to_fr_la".split("_"),months:"januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember".split("_"),monthsShort:"jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des".split("_"),ordinal:function(e){return e+"."},weekStart:1,relativeTime:{future:"om %s",past:"for %s sidan",s:"nokre sekund",m:"eitt minutt",mm:"%d minutt",h:"ein time",hh:"%d timar",d:"ein dag",dd:"%d dagar",M:"ein månad",MM:"%d månadar",y:"eitt år",yy:"%d år"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY [kl.] H:mm",LLLL:"dddd D. MMMM YYYY [kl.] HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},6159:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"oc-lnc",weekdays:"dimenge_diluns_dimars_dimècres_dijòus_divendres_dissabte".split("_"),weekdaysShort:"Dg_Dl_Dm_Dc_Dj_Dv_Ds".split("_"),weekdaysMin:"dg_dl_dm_dc_dj_dv_ds".split("_"),months:"genièr_febrièr_març_abrial_mai_junh_julhet_agost_setembre_octòbre_novembre_decembre".split("_"),monthsShort:"gen_feb_març_abr_mai_junh_julh_ago_set_oct_nov_dec".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM [de] YYYY",LLL:"D MMMM [de] YYYY [a] H:mm",LLLL:"dddd D MMMM [de] YYYY [a] H:mm"},relativeTime:{future:"d'aquí %s",past:"fa %s",s:"unas segondas",m:"una minuta",mm:"%d minutas",h:"una ora",hh:"%d oras",d:"un jorn",dd:"%d jorns",M:"un mes",MM:"%d meses",y:"un an",yy:"%d ans"},ordinal:function(e){return e+"º"}};return t.default.locale(n,null,!0),n}(n(7484))},5914:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"pa-in",weekdays:"ਐਤਵਾਰ_ਸੋਮਵਾਰ_ਮੰਗਲਵਾਰ_ਬੁਧਵਾਰ_ਵੀਰਵਾਰ_ਸ਼ੁੱਕਰਵਾਰ_ਸ਼ਨੀਚਰਵਾਰ".split("_"),months:"ਜਨਵਰੀ_ਫ਼ਰਵਰੀ_ਮਾਰਚ_ਅਪ੍ਰੈਲ_ਮਈ_ਜੂਨ_ਜੁਲਾਈ_ਅਗਸਤ_ਸਤੰਬਰ_ਅਕਤੂਬਰ_ਨਵੰਬਰ_ਦਸੰਬਰ".split("_"),weekdaysShort:"ਐਤ_ਸੋਮ_ਮੰਗਲ_ਬੁਧ_ਵੀਰ_ਸ਼ੁਕਰ_ਸ਼ਨੀ".split("_"),monthsShort:"ਜਨਵਰੀ_ਫ਼ਰਵਰੀ_ਮਾਰਚ_ਅਪ੍ਰੈਲ_ਮਈ_ਜੂਨ_ਜੁਲਾਈ_ਅਗਸਤ_ਸਤੰਬਰ_ਅਕਤੂਬਰ_ਨਵੰਬਰ_ਦਸੰਬਰ".split("_"),weekdaysMin:"ਐਤ_ਸੋਮ_ਮੰਗਲ_ਬੁਧ_ਵੀਰ_ਸ਼ੁਕਰ_ਸ਼ਨੀ".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm ਵਜੇ",LTS:"A h:mm:ss ਵਜੇ",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm ਵਜੇ",LLLL:"dddd, D MMMM YYYY, A h:mm ਵਜੇ"},relativeTime:{future:"%s ਵਿੱਚ",past:"%s ਪਿਛਲੇ",s:"ਕੁਝ ਸਕਿੰਟ",m:"ਇਕ ਮਿੰਟ",mm:"%d ਮਿੰਟ",h:"ਇੱਕ ਘੰਟਾ",hh:"%d ਘੰਟੇ",d:"ਇੱਕ ਦਿਨ",dd:"%d ਦਿਨ",M:"ਇੱਕ ਮਹੀਨਾ",MM:"%d ਮਹੀਨੇ",y:"ਇੱਕ ਸਾਲ",yy:"%d ਸਾਲ"}};return t.default.locale(n,null,!0),n}(n(7484))},1987:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e);function n(e){return e%10<5&&e%10>1&&~~(e/10)%10!=1}function r(e,t,r){var a=e+" ";switch(r){case"m":return t?"minuta":"minutę";case"mm":return a+(n(e)?"minuty":"minut");case"h":return t?"godzina":"godzinę";case"hh":return a+(n(e)?"godziny":"godzin");case"MM":return a+(n(e)?"miesiące":"miesięcy");case"yy":return a+(n(e)?"lata":"lat")}}var a="stycznia_lutego_marca_kwietnia_maja_czerwca_lipca_sierpnia_września_października_listopada_grudnia".split("_"),i="styczeń_luty_marzec_kwiecień_maj_czerwiec_lipiec_sierpień_wrzesień_październik_listopad_grudzień".split("_"),s=/D MMMM/,o=function(e,t){return s.test(t)?a[e.month()]:i[e.month()]};o.s=i,o.f=a;var u={name:"pl",weekdays:"niedziela_poniedziałek_wtorek_środa_czwartek_piątek_sobota".split("_"),weekdaysShort:"ndz_pon_wt_śr_czw_pt_sob".split("_"),weekdaysMin:"Nd_Pn_Wt_Śr_Cz_Pt_So".split("_"),months:o,monthsShort:"sty_lut_mar_kwi_maj_cze_lip_sie_wrz_paź_lis_gru".split("_"),ordinal:function(e){return e+"."},weekStart:1,yearStart:4,relativeTime:{future:"za %s",past:"%s temu",s:"kilka sekund",m:r,mm:r,h:r,hh:r,d:"1 dzień",dd:"%d dni",M:"miesiąc",MM:r,y:"rok",yy:r},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"}};return t.default.locale(u,null,!0),u}(n(7484))},7548:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"pt-br",weekdays:"domingo_segunda-feira_terça-feira_quarta-feira_quinta-feira_sexta-feira_sábado".split("_"),weekdaysShort:"dom_seg_ter_qua_qui_sex_sáb".split("_"),weekdaysMin:"Do_2ª_3ª_4ª_5ª_6ª_Sá".split("_"),months:"janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro".split("_"),monthsShort:"jan_fev_mar_abr_mai_jun_jul_ago_set_out_nov_dez".split("_"),ordinal:function(e){return e+"º"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY [às] HH:mm",LLLL:"dddd, D [de] MMMM [de] YYYY [às] HH:mm"},relativeTime:{future:"em %s",past:"há %s",s:"poucos segundos",m:"um minuto",mm:"%d minutos",h:"uma hora",hh:"%d horas",d:"um dia",dd:"%d dias",M:"um mês",MM:"%d meses",y:"um ano",yy:"%d anos"}};return t.default.locale(n,null,!0),n}(n(7484))},5001:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"pt",weekdays:"domingo_segunda-feira_terça-feira_quarta-feira_quinta-feira_sexta-feira_sábado".split("_"),weekdaysShort:"dom_seg_ter_qua_qui_sex_sab".split("_"),weekdaysMin:"Do_2ª_3ª_4ª_5ª_6ª_Sa".split("_"),months:"janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro".split("_"),monthsShort:"jan_fev_mar_abr_mai_jun_jul_ago_set_out_nov_dez".split("_"),ordinal:function(e){return e+"º"},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY [às] HH:mm",LLLL:"dddd, D [de] MMMM [de] YYYY [às] HH:mm"},relativeTime:{future:"em %s",past:"há %s",s:"alguns segundos",m:"um minuto",mm:"%d minutos",h:"uma hora",hh:"%d horas",d:"um dia",dd:"%d dias",M:"um mês",MM:"%d meses",y:"um ano",yy:"%d anos"}};return t.default.locale(n,null,!0),n}(n(7484))},123:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"rn",weekdays:"Ku wa Mungu_Ku wa Mbere_Ku wa Kabiri_Ku wa Gatatu_Ku wa Kane_Ku wa Gatanu_Ku wa Gatandatu".split("_"),weekdaysShort:"Kngu_Kmbr_Kbri_Ktat_Kkan_Ktan_Kdat".split("_"),weekdaysMin:"K7_K1_K2_K3_K4_K5_K6".split("_"),months:"Nzero_Ruhuhuma_Ntwarante_Ndamukiza_Rusama_Ruhenshi_Mukakaro_Myandagaro_Nyakanga_Gitugutu_Munyonyo_Kigarama".split("_"),monthsShort:"Nzer_Ruhuh_Ntwar_Ndam_Rus_Ruhen_Muk_Myand_Nyak_Git_Muny_Kig".split("_"),weekStart:1,ordinal:function(e){return e},relativeTime:{future:"mu %s",past:"%s",s:"amasegonda",m:"Umunota",mm:"%d iminota",h:"isaha",hh:"%d amasaha",d:"Umunsi",dd:"%d iminsi",M:"ukwezi",MM:"%d amezi",y:"umwaka",yy:"%d imyaka"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},8146:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ro",weekdays:"Duminică_Luni_Marți_Miercuri_Joi_Vineri_Sâmbătă".split("_"),weekdaysShort:"Dum_Lun_Mar_Mie_Joi_Vin_Sâm".split("_"),weekdaysMin:"Du_Lu_Ma_Mi_Jo_Vi_Sâ".split("_"),months:"Ianuarie_Februarie_Martie_Aprilie_Mai_Iunie_Iulie_August_Septembrie_Octombrie_Noiembrie_Decembrie".split("_"),monthsShort:"Ian._Febr._Mart._Apr._Mai_Iun._Iul._Aug._Sept._Oct._Nov._Dec.".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY H:mm",LLLL:"dddd, D MMMM YYYY H:mm"},relativeTime:{future:"peste %s",past:"acum %s",s:"câteva secunde",m:"un minut",mm:"%d minute",h:"o oră",hh:"%d ore",d:"o zi",dd:"%d zile",M:"o lună",MM:"%d luni",y:"un an",yy:"%d ani"},ordinal:function(e){return e}};return t.default.locale(n,null,!0),n}(n(7484))},600:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n="января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря".split("_"),r="январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь".split("_"),a="янв._февр._мар._апр._мая_июня_июля_авг._сент._окт._нояб._дек.".split("_"),i="янв._февр._март_апр._май_июнь_июль_авг._сент._окт._нояб._дек.".split("_"),s=/D[oD]?(\[[^[\]]*\]|\s)+MMMM?/;function o(e,t,n){var r,a;return"m"===n?t?"минута":"минуту":e+" "+(r=+e,a={mm:t?"минута_минуты_минут":"минуту_минуты_минут",hh:"час_часа_часов",dd:"день_дня_дней",MM:"месяц_месяца_месяцев",yy:"год_года_лет"}[n].split("_"),r%10==1&&r%100!=11?a[0]:r%10>=2&&r%10<=4&&(r%100<10||r%100>=20)?a[1]:a[2])}var u=function(e,t){return s.test(t)?n[e.month()]:r[e.month()]};u.s=r,u.f=n;var l=function(e,t){return s.test(t)?a[e.month()]:i[e.month()]};l.s=i,l.f=a;var c={name:"ru",weekdays:"воскресенье_понедельник_вторник_среда_четверг_пятница_суббота".split("_"),weekdaysShort:"вск_пнд_втр_срд_чтв_птн_сбт".split("_"),weekdaysMin:"вс_пн_вт_ср_чт_пт_сб".split("_"),months:u,monthsShort:l,weekStart:1,yearStart:4,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY г.",LLL:"D MMMM YYYY г., H:mm",LLLL:"dddd, D MMMM YYYY г., H:mm"},relativeTime:{future:"через %s",past:"%s назад",s:"несколько секунд",m:o,mm:o,h:"час",hh:o,d:"день",dd:o,M:"месяц",MM:o,y:"год",yy:o},ordinal:function(e){return e},meridiem:function(e){return e<4?"ночи":e<12?"утра":e<17?"дня":"вечера"}};return t.default.locale(c,null,!0),c}(n(7484))},6509:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"rw",weekdays:"Ku Cyumweru_Kuwa Mbere_Kuwa Kabiri_Kuwa Gatatu_Kuwa Kane_Kuwa Gatanu_Kuwa Gatandatu".split("_"),months:"Mutarama_Gashyantare_Werurwe_Mata_Gicurasi_Kamena_Nyakanga_Kanama_Nzeri_Ukwakira_Ugushyingo_Ukuboza".split("_"),relativeTime:{future:"mu %s",past:"%s",s:"amasegonda",m:"Umunota",mm:"%d iminota",h:"isaha",hh:"%d amasaha",d:"Umunsi",dd:"%d iminsi",M:"ukwezi",MM:"%d amezi",y:"umwaka",yy:"%d imyaka"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},ordinal:function(e){return e}};return t.default.locale(n,null,!0),n}(n(7484))},5437:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"sd",weekdays:"آچر_سومر_اڱارو_اربع_خميس_جمع_ڇنڇر".split("_"),months:"جنوري_فيبروري_مارچ_اپريل_مئي_جون_جولاءِ_آگسٽ_سيپٽمبر_آڪٽوبر_نومبر_ڊسمبر".split("_"),weekStart:1,weekdaysShort:"آچر_سومر_اڱارو_اربع_خميس_جمع_ڇنڇر".split("_"),monthsShort:"جنوري_فيبروري_مارچ_اپريل_مئي_جون_جولاءِ_آگسٽ_سيپٽمبر_آڪٽوبر_نومبر_ڊسمبر".split("_"),weekdaysMin:"آچر_سومر_اڱارو_اربع_خميس_جمع_ڇنڇر".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd، D MMMM YYYY HH:mm"},relativeTime:{future:"%s پوء",past:"%s اڳ",s:"چند سيڪنڊ",m:"هڪ منٽ",mm:"%d منٽ",h:"هڪ ڪلاڪ",hh:"%d ڪلاڪ",d:"هڪ ڏينهن",dd:"%d ڏينهن",M:"هڪ مهينو",MM:"%d مهينا",y:"هڪ سال",yy:"%d سال"}};return t.default.locale(n,null,!0),n}(n(7484))},772:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"se",weekdays:"sotnabeaivi_vuossárga_maŋŋebárga_gaskavahkku_duorastat_bearjadat_lávvardat".split("_"),months:"ođđajagemánnu_guovvamánnu_njukčamánnu_cuoŋománnu_miessemánnu_geassemánnu_suoidnemánnu_borgemánnu_čakčamánnu_golggotmánnu_skábmamánnu_juovlamánnu".split("_"),weekStart:1,weekdaysShort:"sotn_vuos_maŋ_gask_duor_bear_láv".split("_"),monthsShort:"ođđj_guov_njuk_cuo_mies_geas_suoi_borg_čakč_golg_skáb_juov".split("_"),weekdaysMin:"s_v_m_g_d_b_L".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"MMMM D. [b.] YYYY",LLL:"MMMM D. [b.] YYYY [ti.] HH:mm",LLLL:"dddd, MMMM D. [b.] YYYY [ti.] HH:mm"},relativeTime:{future:"%s geažes",past:"maŋit %s",s:"moadde sekunddat",m:"okta minuhta",mm:"%d minuhtat",h:"okta diimmu",hh:"%d diimmut",d:"okta beaivi",dd:"%d beaivvit",M:"okta mánnu",MM:"%d mánut",y:"okta jahki",yy:"%d jagit"}};return t.default.locale(n,null,!0),n}(n(7484))},7109:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"si",weekdays:"ඉරිදා_සඳුදා_අඟහරුවාදා_බදාදා_බ්‍රහස්පතින්දා_සිකුරාදා_සෙනසුරාදා".split("_"),months:"දුරුතු_නවම්_මැදින්_බක්_වෙසක්_පොසොන්_ඇසළ_නිකිණි_බිනර_වප්_ඉල්_උඳුවප්".split("_"),weekdaysShort:"ඉරි_සඳු_අඟ_බදා_බ්‍රහ_සිකු_සෙන".split("_"),monthsShort:"දුරු_නව_මැදි_බක්_වෙස_පොසො_ඇස_නිකි_බින_වප්_ඉල්_උඳු".split("_"),weekdaysMin:"ඉ_ස_අ_බ_බ්‍ර_සි_සෙ".split("_"),ordinal:function(e){return e},formats:{LT:"a h:mm",LTS:"a h:mm:ss",L:"YYYY/MM/DD",LL:"YYYY MMMM D",LLL:"YYYY MMMM D, a h:mm",LLLL:"YYYY MMMM D [වැනි] dddd, a h:mm:ss"},relativeTime:{future:"%sකින්",past:"%sකට පෙර",s:"තත්පර කිහිපය",m:"විනාඩිය",mm:"විනාඩි %d",h:"පැය",hh:"පැය %d",d:"දිනය",dd:"දින %d",M:"මාසය",MM:"මාස %d",y:"වසර",yy:"වසර %d"}};return t.default.locale(n,null,!0),n}(n(7484))},5627:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e);function n(e){return e>1&&e<5&&1!=~~(e/10)}function r(e,t,r,a){var i=e+" ";switch(r){case"s":return t||a?"pár sekúnd":"pár sekundami";case"m":return t?"minúta":a?"minútu":"minútou";case"mm":return t||a?i+(n(e)?"minúty":"minút"):i+"minútami";case"h":return t?"hodina":a?"hodinu":"hodinou";case"hh":return t||a?i+(n(e)?"hodiny":"hodín"):i+"hodinami";case"d":return t||a?"deň":"dňom";case"dd":return t||a?i+(n(e)?"dni":"dní"):i+"dňami";case"M":return t||a?"mesiac":"mesiacom";case"MM":return t||a?i+(n(e)?"mesiace":"mesiacov"):i+"mesiacmi";case"y":return t||a?"rok":"rokom";case"yy":return t||a?i+(n(e)?"roky":"rokov"):i+"rokmi"}}var a={name:"sk",weekdays:"nedeľa_pondelok_utorok_streda_štvrtok_piatok_sobota".split("_"),weekdaysShort:"ne_po_ut_st_št_pi_so".split("_"),weekdaysMin:"ne_po_ut_st_št_pi_so".split("_"),months:"január_február_marec_apríl_máj_jún_júl_august_september_október_november_december".split("_"),monthsShort:"jan_feb_mar_apr_máj_jún_júl_aug_sep_okt_nov_dec".split("_"),weekStart:1,yearStart:4,ordinal:function(e){return e+"."},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd D. MMMM YYYY H:mm",l:"D. M. YYYY"},relativeTime:{future:"za %s",past:"pred %s",s:r,m:r,mm:r,h:r,hh:r,d:r,dd:r,M:r,MM:r,y:r,yy:r}};return t.default.locale(a,null,!0),a}(n(7484))},2544:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"sl",weekdays:"nedelja_ponedeljek_torek_sreda_četrtek_petek_sobota".split("_"),months:"januar_februar_marec_april_maj_junij_julij_avgust_september_oktober_november_december".split("_"),weekStart:1,weekdaysShort:"ned._pon._tor._sre._čet._pet._sob.".split("_"),monthsShort:"jan._feb._mar._apr._maj._jun._jul._avg._sep._okt._nov._dec.".split("_"),weekdaysMin:"ne_po_to_sr_če_pe_so".split("_"),ordinal:function(e){return e+"."},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd, D. MMMM YYYY H:mm"},relativeTime:{future:"čez %s",past:"pred %s",s:"nekaj sekund",m:"minuta",mm:"%d minut",h:"ura",hh:"%d ur",d:"dan",dd:"%d dni",M:"mesec",MM:"%d mesecev",y:"leto",yy:"%d let"}};return t.default.locale(n,null,!0),n}(n(7484))},8341:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"sq",weekdays:"E Diel_E Hënë_E Martë_E Mërkurë_E Enjte_E Premte_E Shtunë".split("_"),months:"Janar_Shkurt_Mars_Prill_Maj_Qershor_Korrik_Gusht_Shtator_Tetor_Nëntor_Dhjetor".split("_"),weekStart:1,weekdaysShort:"Die_Hën_Mar_Mër_Enj_Pre_Sht".split("_"),monthsShort:"Jan_Shk_Mar_Pri_Maj_Qer_Kor_Gus_Sht_Tet_Nën_Dhj".split("_"),weekdaysMin:"D_H_Ma_Më_E_P_Sh".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"në %s",past:"%s më parë",s:"disa sekonda",m:"një minutë",mm:"%d minuta",h:"një orë",hh:"%d orë",d:"një ditë",dd:"%d ditë",M:"një muaj",MM:"%d muaj",y:"një vit",yy:"%d vite"}};return t.default.locale(n,null,!0),n}(n(7484))},7101:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={words:{m:["један минут","једног минута"],mm:["%d минут","%d минута","%d минута"],h:["један сат","једног сата"],hh:["%d сат","%d сата","%d сати"],d:["један дан","једног дана"],dd:["%d дан","%d дана","%d дана"],M:["један месец","једног месеца"],MM:["%d месец","%d месеца","%d месеци"],y:["једну годину","једне године"],yy:["%d годину","%d године","%d година"]},correctGrammarCase:function(e,t){return e%10>=1&&e%10<=4&&(e%100<10||e%100>=20)?e%10==1?t[0]:t[1]:t[2]},relativeTimeFormatter:function(e,t,r,a){var i=n.words[r];if(1===r.length)return"y"===r&&t?"једна година":a||t?i[0]:i[1];var s=n.correctGrammarCase(e,i);return"yy"===r&&t&&"%d годину"===s?e+" година":s.replace("%d",e)}},r={name:"sr-cyrl",weekdays:"Недеља_Понедељак_Уторак_Среда_Четвртак_Петак_Субота".split("_"),weekdaysShort:"Нед._Пон._Уто._Сре._Чет._Пет._Суб.".split("_"),weekdaysMin:"не_по_ут_ср_че_пе_су".split("_"),months:"Јануар_Фебруар_Март_Април_Мај_Јун_Јул_Август_Септембар_Октобар_Новембар_Децембар".split("_"),monthsShort:"Јан._Феб._Мар._Апр._Мај_Јун_Јул_Авг._Сеп._Окт._Нов._Дец.".split("_"),weekStart:1,relativeTime:{future:"за %s",past:"пре %s",s:"неколико секунди",m:n.relativeTimeFormatter,mm:n.relativeTimeFormatter,h:n.relativeTimeFormatter,hh:n.relativeTimeFormatter,d:n.relativeTimeFormatter,dd:n.relativeTimeFormatter,M:n.relativeTimeFormatter,MM:n.relativeTimeFormatter,y:n.relativeTimeFormatter,yy:n.relativeTimeFormatter},ordinal:function(e){return e+"."},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"D. M. YYYY.",LL:"D. MMMM YYYY.",LLL:"D. MMMM YYYY. H:mm",LLLL:"dddd, D. MMMM YYYY. H:mm"}};return t.default.locale(r,null,!0),r}(n(7484))},617:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={words:{m:["jedan minut","jednog minuta"],mm:["%d minut","%d minuta","%d minuta"],h:["jedan sat","jednog sata"],hh:["%d sat","%d sata","%d sati"],d:["jedan dan","jednog dana"],dd:["%d dan","%d dana","%d dana"],M:["jedan mesec","jednog meseca"],MM:["%d mesec","%d meseca","%d meseci"],y:["jednu godinu","jedne godine"],yy:["%d godinu","%d godine","%d godina"]},correctGrammarCase:function(e,t){return e%10>=1&&e%10<=4&&(e%100<10||e%100>=20)?e%10==1?t[0]:t[1]:t[2]},relativeTimeFormatter:function(e,t,r,a){var i=n.words[r];if(1===r.length)return"y"===r&&t?"jedna godina":a||t?i[0]:i[1];var s=n.correctGrammarCase(e,i);return"yy"===r&&t&&"%d godinu"===s?e+" godina":s.replace("%d",e)}},r={name:"sr",weekdays:"Nedelja_Ponedeljak_Utorak_Sreda_Četvrtak_Petak_Subota".split("_"),weekdaysShort:"Ned._Pon._Uto._Sre._Čet._Pet._Sub.".split("_"),weekdaysMin:"ne_po_ut_sr_če_pe_su".split("_"),months:"Januar_Februar_Mart_April_Maj_Jun_Jul_Avgust_Septembar_Oktobar_Novembar_Decembar".split("_"),monthsShort:"Jan._Feb._Mar._Apr._Maj_Jun_Jul_Avg._Sep._Okt._Nov._Dec.".split("_"),weekStart:1,relativeTime:{future:"za %s",past:"pre %s",s:"nekoliko sekundi",m:n.relativeTimeFormatter,mm:n.relativeTimeFormatter,h:n.relativeTimeFormatter,hh:n.relativeTimeFormatter,d:n.relativeTimeFormatter,dd:n.relativeTimeFormatter,M:n.relativeTimeFormatter,MM:n.relativeTimeFormatter,y:n.relativeTimeFormatter,yy:n.relativeTimeFormatter},ordinal:function(e){return e+"."},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"D. M. YYYY.",LL:"D. MMMM YYYY.",LLL:"D. MMMM YYYY. H:mm",LLLL:"dddd, D. MMMM YYYY. H:mm"}};return t.default.locale(r,null,!0),r}(n(7484))},4127:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ss",weekdays:"Lisontfo_Umsombuluko_Lesibili_Lesitsatfu_Lesine_Lesihlanu_Umgcibelo".split("_"),months:"Bhimbidvwane_Indlovana_Indlov'lenkhulu_Mabasa_Inkhwekhweti_Inhlaba_Kholwane_Ingci_Inyoni_Imphala_Lweti_Ingongoni".split("_"),weekStart:1,weekdaysShort:"Lis_Umb_Lsb_Les_Lsi_Lsh_Umg".split("_"),monthsShort:"Bhi_Ina_Inu_Mab_Ink_Inh_Kho_Igc_Iny_Imp_Lwe_Igo".split("_"),weekdaysMin:"Li_Us_Lb_Lt_Ls_Lh_Ug".split("_"),ordinal:function(e){return e},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY h:mm A",LLLL:"dddd, D MMMM YYYY h:mm A"},relativeTime:{future:"nga %s",past:"wenteka nga %s",s:"emizuzwana lomcane",m:"umzuzu",mm:"%d emizuzu",h:"lihora",hh:"%d emahora",d:"lilanga",dd:"%d emalanga",M:"inyanga",MM:"%d tinyanga",y:"umnyaka",yy:"%d iminyaka"}};return t.default.locale(n,null,!0),n}(n(7484))},6421:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"sv-fi",weekdays:"söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag".split("_"),weekdaysShort:"sön_mån_tis_ons_tor_fre_lör".split("_"),weekdaysMin:"sö_må_ti_on_to_fr_lö".split("_"),months:"januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december".split("_"),monthsShort:"jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec".split("_"),weekStart:1,yearStart:4,ordinal:function(e){var t=e%10;return"["+e+(1===t||2===t?"a":"e")+"]"},formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY, [kl.] HH.mm",LLLL:"dddd, D. MMMM YYYY, [kl.] HH.mm",l:"D.M.YYYY",ll:"D. MMM YYYY",lll:"D. MMM YYYY, [kl.] HH.mm",llll:"ddd, D. MMM YYYY, [kl.] HH.mm"},relativeTime:{future:"om %s",past:"för %s sedan",s:"några sekunder",m:"en minut",mm:"%d minuter",h:"en timme",hh:"%d timmar",d:"en dag",dd:"%d dagar",M:"en månad",MM:"%d månader",y:"ett år",yy:"%d år"}};return t.default.locale(n,null,!0),n}(n(7484))},1876:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"sv",weekdays:"söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag".split("_"),weekdaysShort:"sön_mån_tis_ons_tor_fre_lör".split("_"),weekdaysMin:"sö_må_ti_on_to_fr_lö".split("_"),months:"januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december".split("_"),monthsShort:"jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec".split("_"),weekStart:1,yearStart:4,ordinal:function(e){var t=e%10;return"["+e+(1===t||2===t?"a":"e")+"]"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"D MMMM YYYY",LLL:"D MMMM YYYY [kl.] HH:mm",LLLL:"dddd D MMMM YYYY [kl.] HH:mm",lll:"D MMM YYYY HH:mm",llll:"ddd D MMM YYYY HH:mm"},relativeTime:{future:"om %s",past:"för %s sedan",s:"några sekunder",m:"en minut",mm:"%d minuter",h:"en timme",hh:"%d timmar",d:"en dag",dd:"%d dagar",M:"en månad",MM:"%d månader",y:"ett år",yy:"%d år"}};return t.default.locale(n,null,!0),n}(n(7484))},9723:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"sw",weekdays:"Jumapili_Jumatatu_Jumanne_Jumatano_Alhamisi_Ijumaa_Jumamosi".split("_"),weekdaysShort:"Jpl_Jtat_Jnne_Jtan_Alh_Ijm_Jmos".split("_"),weekdaysMin:"J2_J3_J4_J5_Al_Ij_J1".split("_"),months:"Januari_Februari_Machi_Aprili_Mei_Juni_Julai_Agosti_Septemba_Oktoba_Novemba_Desemba".split("_"),monthsShort:"Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ago_Sep_Okt_Nov_Des".split("_"),weekStart:1,ordinal:function(e){return e},relativeTime:{future:"%s baadaye",past:"tokea %s",s:"hivi punde",m:"dakika moja",mm:"dakika %d",h:"saa limoja",hh:"masaa %d",d:"siku moja",dd:"masiku %d",M:"mwezi mmoja",MM:"miezi %d",y:"mwaka mmoja",yy:"miaka %d"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},5596:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ta",weekdays:"ஞாயிற்றுக்கிழமை_திங்கட்கிழமை_செவ்வாய்கிழமை_புதன்கிழமை_வியாழக்கிழமை_வெள்ளிக்கிழமை_சனிக்கிழமை".split("_"),months:"ஜனவரி_பிப்ரவரி_மார்ச்_ஏப்ரல்_மே_ஜூன்_ஜூலை_ஆகஸ்ட்_செப்டெம்பர்_அக்டோபர்_நவம்பர்_டிசம்பர்".split("_"),weekdaysShort:"ஞாயிறு_திங்கள்_செவ்வாய்_புதன்_வியாழன்_வெள்ளி_சனி".split("_"),monthsShort:"ஜனவரி_பிப்ரவரி_மார்ச்_ஏப்ரல்_மே_ஜூன்_ஜூலை_ஆகஸ்ட்_செப்டெம்பர்_அக்டோபர்_நவம்பர்_டிசம்பர்".split("_"),weekdaysMin:"ஞா_தி_செ_பு_வி_வெ_ச".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, HH:mm",LLLL:"dddd, D MMMM YYYY, HH:mm"},relativeTime:{future:"%s இல்",past:"%s முன்",s:"ஒரு சில விநாடிகள்",m:"ஒரு நிமிடம்",mm:"%d நிமிடங்கள்",h:"ஒரு மணி நேரம்",hh:"%d மணி நேரம்",d:"ஒரு நாள்",dd:"%d நாட்கள்",M:"ஒரு மாதம்",MM:"%d மாதங்கள்",y:"ஒரு வருடம்",yy:"%d ஆண்டுகள்"}};return t.default.locale(n,null,!0),n}(n(7484))},5159:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"te",weekdays:"ఆదివారం_సోమవారం_మంగళవారం_బుధవారం_గురువారం_శుక్రవారం_శనివారం".split("_"),months:"జనవరి_ఫిబ్రవరి_మార్చి_ఏప్రిల్_మే_జూన్_జులై_ఆగస్టు_సెప్టెంబర్_అక్టోబర్_నవంబర్_డిసెంబర్".split("_"),weekdaysShort:"ఆది_సోమ_మంగళ_బుధ_గురు_శుక్ర_శని".split("_"),monthsShort:"జన._ఫిబ్ర._మార్చి_ఏప్రి._మే_జూన్_జులై_ఆగ._సెప్._అక్టో._నవ._డిసె.".split("_"),weekdaysMin:"ఆ_సో_మం_బు_గు_శు_శ".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm",LTS:"A h:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm",LLLL:"dddd, D MMMM YYYY, A h:mm"},relativeTime:{future:"%s లో",past:"%s క్రితం",s:"కొన్ని క్షణాలు",m:"ఒక నిమిషం",mm:"%d నిమిషాలు",h:"ఒక గంట",hh:"%d గంటలు",d:"ఒక రోజు",dd:"%d రోజులు",M:"ఒక నెల",MM:"%d నెలలు",y:"ఒక సంవత్సరం",yy:"%d సంవత్సరాలు"}};return t.default.locale(n,null,!0),n}(n(7484))},9157:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tet",weekdays:"Domingu_Segunda_Tersa_Kuarta_Kinta_Sesta_Sabadu".split("_"),months:"Janeiru_Fevereiru_Marsu_Abril_Maiu_Juñu_Jullu_Agustu_Setembru_Outubru_Novembru_Dezembru".split("_"),weekStart:1,weekdaysShort:"Dom_Seg_Ters_Kua_Kint_Sest_Sab".split("_"),monthsShort:"Jan_Fev_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez".split("_"),weekdaysMin:"Do_Seg_Te_Ku_Ki_Ses_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"iha %s",past:"%s liuba",s:"minutu balun",m:"minutu ida",mm:"minutu %d",h:"oras ida",hh:"oras %d",d:"loron ida",dd:"loron %d",M:"fulan ida",MM:"fulan %d",y:"tinan ida",yy:"tinan %d"}};return t.default.locale(n,null,!0),n}(n(7484))},9928:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tg",weekdays:"якшанбе_душанбе_сешанбе_чоршанбе_панҷшанбе_ҷумъа_шанбе".split("_"),months:"январ_феврал_март_апрел_май_июн_июл_август_сентябр_октябр_ноябр_декабр".split("_"),weekStart:1,weekdaysShort:"яшб_дшб_сшб_чшб_пшб_ҷум_шнб".split("_"),monthsShort:"янв_фев_мар_апр_май_июн_июл_авг_сен_окт_ноя_дек".split("_"),weekdaysMin:"яш_дш_сш_чш_пш_ҷм_шб".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"баъди %s",past:"%s пеш",s:"якчанд сония",m:"як дақиқа",mm:"%d дақиқа",h:"як соат",hh:"%d соат",d:"як рӯз",dd:"%d рӯз",M:"як моҳ",MM:"%d моҳ",y:"як сол",yy:"%d сол"}};return t.default.locale(n,null,!0),n}(n(7484))},2019:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"th",weekdays:"อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัสบดี_ศุกร์_เสาร์".split("_"),weekdaysShort:"อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัส_ศุกร์_เสาร์".split("_"),weekdaysMin:"อา._จ._อ._พ._พฤ._ศ._ส.".split("_"),months:"มกราคม_กุมภาพันธ์_มีนาคม_เมษายน_พฤษภาคม_มิถุนายน_กรกฎาคม_สิงหาคม_กันยายน_ตุลาคม_พฤศจิกายน_ธันวาคม".split("_"),monthsShort:"ม.ค._ก.พ._มี.ค._เม.ย._พ.ค._มิ.ย._ก.ค._ส.ค._ก.ย._ต.ค._พ.ย._ธ.ค.".split("_"),formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY เวลา H:mm",LLLL:"วันddddที่ D MMMM YYYY เวลา H:mm"},relativeTime:{future:"อีก %s",past:"%sที่แล้ว",s:"ไม่กี่วินาที",m:"1 นาที",mm:"%d นาที",h:"1 ชั่วโมง",hh:"%d ชั่วโมง",d:"1 วัน",dd:"%d วัน",M:"1 เดือน",MM:"%d เดือน",y:"1 ปี",yy:"%d ปี"},ordinal:function(e){return e+"."}};return t.default.locale(n,null,!0),n}(n(7484))},5817:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tk",weekdays:"Ýekşenbe_Duşenbe_Sişenbe_Çarşenbe_Penşenbe_Anna_Şenbe".split("_"),weekdaysShort:"Ýek_Duş_Siş_Çar_Pen_Ann_Şen".split("_"),weekdaysMin:"Ýk_Dş_Sş_Çr_Pn_An_Şn".split("_"),months:"Ýanwar_Fewral_Mart_Aprel_Maý_Iýun_Iýul_Awgust_Sentýabr_Oktýabr_Noýabr_Dekabr".split("_"),monthsShort:"Ýan_Few_Mar_Apr_Maý_Iýn_Iýl_Awg_Sen_Okt_Noý_Dek".split("_"),weekStart:1,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"%s soň",past:"%s öň",s:"birnäçe sekunt",m:"bir minut",mm:"%d minut",h:"bir sagat",hh:"%d sagat",d:"bir gün",dd:"%d gün",M:"bir aý",MM:"%d aý",y:"bir ýyl",yy:"%d ýyl"},ordinal:function(e){return e+"."}};return t.default.locale(n,null,!0),n}(n(7484))},6513:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tl-ph",weekdays:"Linggo_Lunes_Martes_Miyerkules_Huwebes_Biyernes_Sabado".split("_"),months:"Enero_Pebrero_Marso_Abril_Mayo_Hunyo_Hulyo_Agosto_Setyembre_Oktubre_Nobyembre_Disyembre".split("_"),weekStart:1,weekdaysShort:"Lin_Lun_Mar_Miy_Huw_Biy_Sab".split("_"),monthsShort:"Ene_Peb_Mar_Abr_May_Hun_Hul_Ago_Set_Okt_Nob_Dis".split("_"),weekdaysMin:"Li_Lu_Ma_Mi_Hu_Bi_Sab".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"MM/D/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY HH:mm",LLLL:"dddd, MMMM DD, YYYY HH:mm"},relativeTime:{future:"sa loob ng %s",past:"%s ang nakalipas",s:"ilang segundo",m:"isang minuto",mm:"%d minuto",h:"isang oras",hh:"%d oras",d:"isang araw",dd:"%d araw",M:"isang buwan",MM:"%d buwan",y:"isang taon",yy:"%d taon"}};return t.default.locale(n,null,!0),n}(n(7484))},7296:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tlh",weekdays:"lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj".split("_"),months:"tera’ jar wa’_tera’ jar cha’_tera’ jar wej_tera’ jar loS_tera’ jar vagh_tera’ jar jav_tera’ jar Soch_tera’ jar chorgh_tera’ jar Hut_tera’ jar wa’maH_tera’ jar wa’maH wa’_tera’ jar wa’maH cha’".split("_"),weekStart:1,weekdaysShort:"lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj".split("_"),monthsShort:"jar wa’_jar cha’_jar wej_jar loS_jar vagh_jar jav_jar Soch_jar chorgh_jar Hut_jar wa’maH_jar wa’maH wa’_jar wa’maH cha’".split("_"),weekdaysMin:"lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},3035:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tr",weekdays:"Pazar_Pazartesi_Salı_Çarşamba_Perşembe_Cuma_Cumartesi".split("_"),weekdaysShort:"Paz_Pts_Sal_Çar_Per_Cum_Cts".split("_"),weekdaysMin:"Pz_Pt_Sa_Ça_Pe_Cu_Ct".split("_"),months:"Ocak_Şubat_Mart_Nisan_Mayıs_Haziran_Temmuz_Ağustos_Eylül_Ekim_Kasım_Aralık".split("_"),monthsShort:"Oca_Şub_Mar_Nis_May_Haz_Tem_Ağu_Eyl_Eki_Kas_Ara".split("_"),weekStart:1,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"%s sonra",past:"%s önce",s:"birkaç saniye",m:"bir dakika",mm:"%d dakika",h:"bir saat",hh:"%d saat",d:"bir gün",dd:"%d gün",M:"bir ay",MM:"%d ay",y:"bir yıl",yy:"%d yıl"},ordinal:function(e){return e+"."}};return t.default.locale(n,null,!0),n}(n(7484))},7797:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tzl",weekdays:"Súladi_Lúneçi_Maitzi_Márcuri_Xhúadi_Viénerçi_Sáturi".split("_"),months:"Januar_Fevraglh_Març_Avrïu_Mai_Gün_Julia_Guscht_Setemvar_Listopäts_Noemvar_Zecemvar".split("_"),weekStart:1,weekdaysShort:"Súl_Lún_Mai_Már_Xhú_Vié_Sát".split("_"),monthsShort:"Jan_Fev_Mar_Avr_Mai_Gün_Jul_Gus_Set_Lis_Noe_Zec".split("_"),weekdaysMin:"Sú_Lú_Ma_Má_Xh_Vi_Sá".split("_"),ordinal:function(e){return e},formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD.MM.YYYY",LL:"D. MMMM [dallas] YYYY",LLL:"D. MMMM [dallas] YYYY HH.mm",LLLL:"dddd, [li] D. MMMM [dallas] YYYY HH.mm"}};return t.default.locale(n,null,!0),n}(n(7484))},261:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tzm-latn",weekdays:"asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas".split("_"),months:"innayr_brˤayrˤ_marˤsˤ_ibrir_mayyw_ywnyw_ywlywz_ɣwšt_šwtanbir_ktˤwbrˤ_nwwanbir_dwjnbir".split("_"),weekStart:6,weekdaysShort:"asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas".split("_"),monthsShort:"innayr_brˤayrˤ_marˤsˤ_ibrir_mayyw_ywnyw_ywlywz_ɣwšt_šwtanbir_ktˤwbrˤ_nwwanbir_dwjnbir".split("_"),weekdaysMin:"asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"dadkh s yan %s",past:"yan %s",s:"imik",m:"minuḍ",mm:"%d minuḍ",h:"saɛa",hh:"%d tassaɛin",d:"ass",dd:"%d ossan",M:"ayowr",MM:"%d iyyirn",y:"asgas",yy:"%d isgasn"}};return t.default.locale(n,null,!0),n}(n(7484))},4722:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tzm",weekdays:"ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ".split("_"),months:"ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ".split("_"),weekStart:6,weekdaysShort:"ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ".split("_"),monthsShort:"ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ".split("_"),weekdaysMin:"ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"ⴷⴰⴷⵅ ⵙ ⵢⴰⵏ %s",past:"ⵢⴰⵏ %s",s:"ⵉⵎⵉⴽ",m:"ⵎⵉⵏⵓⴺ",mm:"%d ⵎⵉⵏⵓⴺ",h:"ⵙⴰⵄⴰ",hh:"%d ⵜⴰⵙⵙⴰⵄⵉⵏ",d:"ⴰⵙⵙ",dd:"%d oⵙⵙⴰⵏ",M:"ⴰⵢoⵓⵔ",MM:"%d ⵉⵢⵢⵉⵔⵏ",y:"ⴰⵙⴳⴰⵙ",yy:"%d ⵉⵙⴳⴰⵙⵏ"}};return t.default.locale(n,null,!0),n}(n(7484))},313:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ug-cn",weekdays:"يەكشەنبە_دۈشەنبە_سەيشەنبە_چارشەنبە_پەيشەنبە_جۈمە_شەنبە".split("_"),months:"يانۋار_فېۋرال_مارت_ئاپرېل_ماي_ئىيۇن_ئىيۇل_ئاۋغۇست_سېنتەبىر_ئۆكتەبىر_نويابىر_دېكابىر".split("_"),weekStart:1,weekdaysShort:"يە_دۈ_سە_چا_پە_جۈ_شە".split("_"),monthsShort:"يانۋار_فېۋرال_مارت_ئاپرېل_ماي_ئىيۇن_ئىيۇل_ئاۋغۇست_سېنتەبىر_ئۆكتەبىر_نويابىر_دېكابىر".split("_"),weekdaysMin:"يە_دۈ_سە_چا_پە_جۈ_شە".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"YYYY-يىلىM-ئاينىڭD-كۈنى",LLL:"YYYY-يىلىM-ئاينىڭD-كۈنى، HH:mm",LLLL:"dddd، YYYY-يىلىM-ئاينىڭD-كۈنى، HH:mm"},relativeTime:{future:"%s كېيىن",past:"%s بۇرۇن",s:"نەچچە سېكونت",m:"بىر مىنۇت",mm:"%d مىنۇت",h:"بىر سائەت",hh:"%d سائەت",d:"بىر كۈن",dd:"%d كۈن",M:"بىر ئاي",MM:"%d ئاي",y:"بىر يىل",yy:"%d يىل"}};return t.default.locale(n,null,!0),n}(n(7484))},4144:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n="січня_лютого_березня_квітня_травня_червня_липня_серпня_вересня_жовтня_листопада_грудня".split("_"),r="січень_лютий_березень_квітень_травень_червень_липень_серпень_вересень_жовтень_листопад_грудень".split("_"),a=/D[oD]?(\[[^[\]]*\]|\s)+MMMM?/;function i(e,t,n){var r,a;return"m"===n?t?"хвилина":"хвилину":"h"===n?t?"година":"годину":e+" "+(r=+e,a={ss:t?"секунда_секунди_секунд":"секунду_секунди_секунд",mm:t?"хвилина_хвилини_хвилин":"хвилину_хвилини_хвилин",hh:t?"година_години_годин":"годину_години_годин",dd:"день_дні_днів",MM:"місяць_місяці_місяців",yy:"рік_роки_років"}[n].split("_"),r%10==1&&r%100!=11?a[0]:r%10>=2&&r%10<=4&&(r%100<10||r%100>=20)?a[1]:a[2])}var s=function(e,t){return a.test(t)?n[e.month()]:r[e.month()]};s.s=r,s.f=n;var o={name:"uk",weekdays:"неділя_понеділок_вівторок_середа_четвер_п’ятниця_субота".split("_"),weekdaysShort:"ндл_пнд_втр_срд_чтв_птн_сбт".split("_"),weekdaysMin:"нд_пн_вт_ср_чт_пт_сб".split("_"),months:s,monthsShort:"січ_лют_бер_квіт_трав_черв_лип_серп_вер_жовт_лист_груд".split("_"),weekStart:1,relativeTime:{future:"за %s",past:"%s тому",s:"декілька секунд",m:i,mm:i,h:i,hh:i,d:"день",dd:i,M:"місяць",MM:i,y:"рік",yy:i},ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY р.",LLL:"D MMMM YYYY р., HH:mm",LLLL:"dddd, D MMMM YYYY р., HH:mm"}};return t.default.locale(o,null,!0),o}(n(7484))},2957:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ur",weekdays:"اتوار_پیر_منگل_بدھ_جمعرات_جمعہ_ہفتہ".split("_"),months:"جنوری_فروری_مارچ_اپریل_مئی_جون_جولائی_اگست_ستمبر_اکتوبر_نومبر_دسمبر".split("_"),weekStart:1,weekdaysShort:"اتوار_پیر_منگل_بدھ_جمعرات_جمعہ_ہفتہ".split("_"),monthsShort:"جنوری_فروری_مارچ_اپریل_مئی_جون_جولائی_اگست_ستمبر_اکتوبر_نومبر_دسمبر".split("_"),weekdaysMin:"اتوار_پیر_منگل_بدھ_جمعرات_جمعہ_ہفتہ".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd، D MMMM YYYY HH:mm"},relativeTime:{future:"%s بعد",past:"%s قبل",s:"چند سیکنڈ",m:"ایک منٹ",mm:"%d منٹ",h:"ایک گھنٹہ",hh:"%d گھنٹے",d:"ایک دن",dd:"%d دن",M:"ایک ماہ",MM:"%d ماہ",y:"ایک سال",yy:"%d سال"}};return t.default.locale(n,null,!0),n}(n(7484))},8727:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"uz-latn",weekdays:"Yakshanba_Dushanba_Seshanba_Chorshanba_Payshanba_Juma_Shanba".split("_"),months:"Yanvar_Fevral_Mart_Aprel_May_Iyun_Iyul_Avgust_Sentabr_Oktabr_Noyabr_Dekabr".split("_"),weekStart:1,weekdaysShort:"Yak_Dush_Sesh_Chor_Pay_Jum_Shan".split("_"),monthsShort:"Yan_Fev_Mar_Apr_May_Iyun_Iyul_Avg_Sen_Okt_Noy_Dek".split("_"),weekdaysMin:"Ya_Du_Se_Cho_Pa_Ju_Sha".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"D MMMM YYYY, dddd HH:mm"},relativeTime:{future:"Yaqin %s ichida",past:"Bir necha %s oldin",s:"soniya",m:"bir daqiqa",mm:"%d daqiqa",h:"bir soat",hh:"%d soat",d:"bir kun",dd:"%d kun",M:"bir oy",MM:"%d oy",y:"bir yil",yy:"%d yil"}};return t.default.locale(n,null,!0),n}(n(7484))},7486:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"uz",weekdays:"Якшанба_Душанба_Сешанба_Чоршанба_Пайшанба_Жума_Шанба".split("_"),months:"январ_феврал_март_апрел_май_июн_июл_август_сентябр_октябр_ноябр_декабр".split("_"),weekStart:1,weekdaysShort:"Якш_Душ_Сеш_Чор_Пай_Жум_Шан".split("_"),monthsShort:"янв_фев_мар_апр_май_июн_июл_авг_сен_окт_ноя_дек".split("_"),weekdaysMin:"Як_Ду_Се_Чо_Па_Жу_Ша".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"D MMMM YYYY, dddd HH:mm"},relativeTime:{future:"Якин %s ичида",past:"Бир неча %s олдин",s:"фурсат",m:"бир дакика",mm:"%d дакика",h:"бир соат",hh:"%d соат",d:"бир кун",dd:"%d кун",M:"бир ой",MM:"%d ой",y:"бир йил",yy:"%d йил"}};return t.default.locale(n,null,!0),n}(n(7484))},7553:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"vi",weekdays:"chủ nhật_thứ hai_thứ ba_thứ tư_thứ năm_thứ sáu_thứ bảy".split("_"),months:"tháng 1_tháng 2_tháng 3_tháng 4_tháng 5_tháng 6_tháng 7_tháng 8_tháng 9_tháng 10_tháng 11_tháng 12".split("_"),weekStart:1,weekdaysShort:"CN_T2_T3_T4_T5_T6_T7".split("_"),monthsShort:"Th01_Th02_Th03_Th04_Th05_Th06_Th07_Th08_Th09_Th10_Th11_Th12".split("_"),weekdaysMin:"CN_T2_T3_T4_T5_T6_T7".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM [năm] YYYY",LLL:"D MMMM [năm] YYYY HH:mm",LLLL:"dddd, D MMMM [năm] YYYY HH:mm",l:"DD/M/YYYY",ll:"D MMM YYYY",lll:"D MMM YYYY HH:mm",llll:"ddd, D MMM YYYY HH:mm"},relativeTime:{future:"%s tới",past:"%s trước",s:"vài giây",m:"một phút",mm:"%d phút",h:"một giờ",hh:"%d giờ",d:"một ngày",dd:"%d ngày",M:"một tháng",MM:"%d tháng",y:"một năm",yy:"%d năm"}};return t.default.locale(n,null,!0),n}(n(7484))},5321:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"x-pseudo",weekdays:"S~úñdá~ý_Mó~ñdáý~_Túé~sdáý~_Wéd~ñésd~áý_T~húrs~dáý_~Fríd~áý_S~átúr~dáý".split("_"),months:"J~áñúá~rý_F~ébrú~árý_~Márc~h_Áp~ríl_~Máý_~Júñé~_Júl~ý_Áú~gúst~_Sép~témb~ér_Ó~ctób~ér_Ñ~óvém~bér_~Décé~mbér".split("_"),weekStart:1,weekdaysShort:"S~úñ_~Móñ_~Túé_~Wéd_~Thú_~Frí_~Sát".split("_"),monthsShort:"J~áñ_~Féb_~Már_~Ápr_~Máý_~Júñ_~Júl_~Áúg_~Sép_~Óct_~Ñóv_~Déc".split("_"),weekdaysMin:"S~ú_Mó~_Tú_~Wé_T~h_Fr~_Sá".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"í~ñ %s",past:"%s á~gó",s:"á ~féw ~sécó~ñds",m:"á ~míñ~úté",mm:"%d m~íñú~tés",h:"á~ñ hó~úr",hh:"%d h~óúrs",d:"á ~dáý",dd:"%d d~áýs",M:"á ~móñ~th",MM:"%d m~óñt~hs",y:"á ~ýéár",yy:"%d ý~éárs"}};return t.default.locale(n,null,!0),n}(n(7484))},4724:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"yo",weekdays:"Àìkú_Ajé_Ìsẹ́gun_Ọjọ́rú_Ọjọ́bọ_Ẹtì_Àbámẹ́ta".split("_"),months:"Sẹ́rẹ́_Èrèlè_Ẹrẹ̀nà_Ìgbé_Èbibi_Òkùdu_Agẹmo_Ògún_Owewe_Ọ̀wàrà_Bélú_Ọ̀pẹ̀̀".split("_"),weekStart:1,weekdaysShort:"Àìk_Ajé_Ìsẹ́_Ọjr_Ọjb_Ẹtì_Àbá".split("_"),monthsShort:"Sẹ́r_Èrl_Ẹrn_Ìgb_Èbi_Òkù_Agẹ_Ògú_Owe_Ọ̀wà_Bél_Ọ̀pẹ̀̀".split("_"),weekdaysMin:"Àì_Aj_Ìs_Ọr_Ọb_Ẹt_Àb".split("_"),ordinal:function(e){return e},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY h:mm A",LLLL:"dddd, D MMMM YYYY h:mm A"},relativeTime:{future:"ní %s",past:"%s kọjá",s:"ìsẹjú aayá die",m:"ìsẹjú kan",mm:"ìsẹjú %d",h:"wákati kan",hh:"wákati %d",d:"ọjọ́ kan",dd:"ọjọ́ %d",M:"osù kan",MM:"osù %d",y:"ọdún kan",yy:"ọdún %d"}};return t.default.locale(n,null,!0),n}(n(7484))},3852:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"zh-cn",weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"周日_周一_周二_周三_周四_周五_周六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),ordinal:function(e,t){return"W"===t?e+"周":e+"日"},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日Ah点mm分",LLLL:"YYYY年M月D日ddddAh点mm分",l:"YYYY/M/D",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日dddd HH:mm"},relativeTime:{future:"%s内",past:"%s前",s:"几秒",m:"1 分钟",mm:"%d 分钟",h:"1 小时",hh:"%d 小时",d:"1 天",dd:"%d 天",M:"1 个月",MM:"%d 个月",y:"1 年",yy:"%d 年"},meridiem:function(e,t){var n=100*e+t;return n<600?"凌晨":n<900?"早上":n<1100?"上午":n<1300?"中午":n<1800?"下午":"晚上"}};return t.default.locale(n,null,!0),n}(n(7484))},2390:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"zh-hk",months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"週日_週一_週二_週三_週四_週五_週六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),ordinal:function(e,t){return"W"===t?e+"週":e+"日"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日 HH:mm",LLLL:"YYYY年M月D日dddd HH:mm"},relativeTime:{future:"%s內",past:"%s前",s:"幾秒",m:"一分鐘",mm:"%d 分鐘",h:"一小時",hh:"%d 小時",d:"一天",dd:"%d 天",M:"一個月",MM:"%d 個月",y:"一年",yy:"%d 年"}};return t.default.locale(n,null,!0),n}(n(7484))},3901:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"zh-tw",weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"週日_週一_週二_週三_週四_週五_週六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),ordinal:function(e,t){return"W"===t?e+"週":e+"日"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日 HH:mm",LLLL:"YYYY年M月D日dddd HH:mm",l:"YYYY/M/D",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日dddd HH:mm"},relativeTime:{future:"%s內",past:"%s前",s:"幾秒",m:"1 分鐘",mm:"%d 分鐘",h:"1 小時",hh:"%d 小時",d:"1 天",dd:"%d 天",M:"1 個月",MM:"%d 個月",y:"1 年",yy:"%d 年"}};return t.default.locale(n,null,!0),n}(n(7484))},2009:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"zh",weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"周日_周一_周二_周三_周四_周五_周六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),ordinal:function(e,t){return"W"===t?e+"周":e+"日"},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日Ah点mm分",LLLL:"YYYY年M月D日ddddAh点mm分",l:"YYYY/M/D",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日dddd HH:mm"},relativeTime:{future:"%s后",past:"%s前",s:"几秒",m:"1 分钟",mm:"%d 分钟",h:"1 小时",hh:"%d 小时",d:"1 天",dd:"%d 天",M:"1 个月",MM:"%d 个月",y:"1 年",yy:"%d 年"},meridiem:function(e,t){var n=100*e+t;return n<600?"凌晨":n<900?"早上":n<1100?"上午":n<1300?"中午":n<1800?"下午":"晚上"}};return t.default.locale(n,null,!0),n}(n(7484))},285:function(e){e.exports=function(){"use strict";var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},t=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,n=/\d\d/,r=/\d\d?/,a=/\d*[^-_:/,()\s\d]+/,i={},s=function(e){return(e=+e)+(e>68?1900:2e3)},o=function(e){return function(t){this[e]=+t}},u=[/[+-]\d\d:?(\d\d)?|Z/,function(e){(this.zone||(this.zone={})).offset=function(e){if(!e)return 0;if("Z"===e)return 0;var t=e.match(/([+-]|\d\d)/g),n=60*t[1]+(+t[2]||0);return 0===n?0:"+"===t[0]?-n:n}(e)}],l=function(e){var t=i[e];return t&&(t.indexOf?t:t.s.concat(t.f))},c=function(e,t){var n,r=i.meridiem;if(r){for(var a=1;a<=24;a+=1)if(e.indexOf(r(a,0,t))>-1){n=a>12;break}}else n=e===(t?"pm":"PM");return n},p={A:[a,function(e){this.afternoon=c(e,!1)}],a:[a,function(e){this.afternoon=c(e,!0)}],S:[/\d/,function(e){this.milliseconds=100*+e}],SS:[n,function(e){this.milliseconds=10*+e}],SSS:[/\d{3}/,function(e){this.milliseconds=+e}],s:[r,o("seconds")],ss:[r,o("seconds")],m:[r,o("minutes")],mm:[r,o("minutes")],H:[r,o("hours")],h:[r,o("hours")],HH:[r,o("hours")],hh:[r,o("hours")],D:[r,o("day")],DD:[n,o("day")],Do:[a,function(e){var t=i.ordinal,n=e.match(/\d+/);if(this.day=n[0],t)for(var r=1;r<=31;r+=1)t(r).replace(/\[|\]/g,"")===e&&(this.day=r)}],M:[r,o("month")],MM:[n,o("month")],MMM:[a,function(e){var t=l("months"),n=(l("monthsShort")||t.map((function(e){return e.slice(0,3)}))).indexOf(e)+1;if(n<1)throw new Error;this.month=n%12||n}],MMMM:[a,function(e){var t=l("months").indexOf(e)+1;if(t<1)throw new Error;this.month=t%12||t}],Y:[/[+-]?\d+/,o("year")],YY:[n,function(e){this.year=s(e)}],YYYY:[/\d{4}/,o("year")],Z:u,ZZ:u};function d(n){var r,a;r=n,a=i&&i.formats;for(var s=(n=r.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,n,r){var i=r&&r.toUpperCase();return n||a[r]||e[r]||a[i].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}))).match(t),o=s.length,u=0;u-1)return new Date(("X"===t?1e3:1)*e);var r=d(t)(e),a=r.year,i=r.month,s=r.day,o=r.hours,u=r.minutes,l=r.seconds,c=r.milliseconds,p=r.zone,h=new Date,f=s||(a||i?1:h.getDate()),m=a||h.getFullYear(),g=0;a&&!i||(g=i>0?i-1:h.getMonth());var y=o||0,b=u||0,x=l||0,v=c||0;return p?new Date(Date.UTC(m,g,f,y,b,x,v+60*p.offset*1e3)):n?new Date(Date.UTC(m,g,f,y,b,x,v)):new Date(m,g,f,y,b,x,v)}catch(e){return new Date("")}}(t,o,r),this.init(),p&&!0!==p&&(this.$L=this.locale(p).$L),c&&t!=this.format(o)&&(this.$d=new Date("")),i={}}else if(o instanceof Array)for(var h=o.length,f=1;f<=h;f+=1){s[1]=o[f-1];var m=n.apply(this,s);if(m.isValid()){this.$d=m.$d,this.$L=m.$L,this.init();break}f===h&&(this.$d=new Date(""))}else a.call(this,e)}}}()},2997:function(e){e.exports=function(){"use strict";return function(e,t,n){t.prototype.dayOfYear=function(e){var t=Math.round((n(this).startOf("day")-n(this).startOf("year"))/864e5)+1;return null==e?t:this.add(e-t,"day")}}}()},6036:function(e){e.exports=function(){"use strict";return function(e,t,n){var r=t.prototype,a=function(e){return e&&(e.indexOf?e:e.s)},i=function(e,t,n,r,i){var s=e.name?e:e.$locale(),o=a(s[t]),u=a(s[n]),l=o||u.map((function(e){return e.slice(0,r)}));if(!i)return l;var c=s.weekStart;return l.map((function(e,t){return l[(t+(c||0))%7]}))},s=function(){return n.Ls[n.locale()]},o=function(e,t){return e.formats[t]||function(e){return e.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}(e.formats[t.toUpperCase()])},u=function(){var e=this;return{months:function(t){return t?t.format("MMMM"):i(e,"months")},monthsShort:function(t){return t?t.format("MMM"):i(e,"monthsShort","months",3)},firstDayOfWeek:function(){return e.$locale().weekStart||0},weekdays:function(t){return t?t.format("dddd"):i(e,"weekdays")},weekdaysMin:function(t){return t?t.format("dd"):i(e,"weekdaysMin","weekdays",2)},weekdaysShort:function(t){return t?t.format("ddd"):i(e,"weekdaysShort","weekdays",3)},longDateFormat:function(t){return o(e.$locale(),t)},meridiem:this.$locale().meridiem,ordinal:this.$locale().ordinal}};r.localeData=function(){return u.bind(this)()},n.localeData=function(){var e=s();return{firstDayOfWeek:function(){return e.weekStart||0},weekdays:function(){return n.weekdays()},weekdaysShort:function(){return n.weekdaysShort()},weekdaysMin:function(){return n.weekdaysMin()},months:function(){return n.months()},monthsShort:function(){return n.monthsShort()},longDateFormat:function(t){return o(e,t)},meridiem:e.meridiem,ordinal:e.ordinal}},n.months=function(){return i(s(),"months")},n.monthsShort=function(){return i(s(),"monthsShort","months",3)},n.weekdays=function(e){return i(s(),"weekdays",null,null,e)},n.weekdaysShort=function(e){return i(s(),"weekdaysShort","weekdays",3,e)},n.weekdaysMin=function(e){return i(s(),"weekdaysMin","weekdays",2,e)}}}()},6176:function(e){e.exports=function(){"use strict";var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};return function(t,n,r){var a=n.prototype,i=a.format;r.en.formats=e,a.format=function(t){void 0===t&&(t="YYYY-MM-DDTHH:mm:ssZ");var n=this.$locale().formats,r=function(t,n){return t.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,r,a){var i=a&&a.toUpperCase();return r||n[a]||e[a]||n[i].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}))}(t,void 0===n?{}:n);return i.call(this,r)}}}()},178:function(e){e.exports=function(){"use strict";var e="minute",t=/[+-]\d\d(?::?\d\d)?/g,n=/([+-]|\d\d)/g;return function(r,a,i){var s=a.prototype;i.utc=function(e){return new a({date:e,utc:!0,args:arguments})},s.utc=function(t){var n=i(this.toDate(),{locale:this.$L,utc:!0});return t?n.add(this.utcOffset(),e):n},s.local=function(){return i(this.toDate(),{locale:this.$L,utc:!1})};var o=s.parse;s.parse=function(e){e.utc&&(this.$u=!0),this.$utils().u(e.$offset)||(this.$offset=e.$offset),o.call(this,e)};var u=s.init;s.init=function(){if(this.$u){var e=this.$d;this.$y=e.getUTCFullYear(),this.$M=e.getUTCMonth(),this.$D=e.getUTCDate(),this.$W=e.getUTCDay(),this.$H=e.getUTCHours(),this.$m=e.getUTCMinutes(),this.$s=e.getUTCSeconds(),this.$ms=e.getUTCMilliseconds()}else u.call(this)};var l=s.utcOffset;s.utcOffset=function(r,a){var i=this.$utils().u;if(i(r))return this.$u?0:i(this.$offset)?l.call(this):this.$offset;if("string"==typeof r&&(r=function(e){void 0===e&&(e="");var r=e.match(t);if(!r)return null;var a=(""+r[0]).match(n)||["-",0,0],i=a[0],s=60*+a[1]+ +a[2];return 0===s?0:"+"===i?s:-s}(r),null===r))return this;var s=Math.abs(r)<=16?60*r:r,o=this;if(a)return o.$offset=s,o.$u=0===r,o;if(0!==r){var u=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(o=this.local().add(s+u,e)).$offset=s,o.$x.$localOffset=u}else o=this.utc();return o};var c=s.format;s.format=function(e){var t=e||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return c.call(this,t)},s.valueOf=function(){var e=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*e},s.isUTC=function(){return!!this.$u},s.toISOString=function(){return this.toDate().toISOString()},s.toString=function(){return this.toDate().toUTCString()};var p=s.toDate;s.toDate=function(e){return"s"===e&&this.$offset?i(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():p.call(this)};var d=s.diff;s.diff=function(e,t,n){if(e&&this.$u===e.$u)return d.call(this,e,t,n);var r=this.local(),a=i(e).local();return d.call(r,a,t,n)}}}()},3776:function(e,t,n){var r;!function(a){"use strict";var i,s,o,u=9e15,l=1e9,c="0123456789abcdef",p="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",d="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",h={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-u,maxE:u,crypto:!1},f=!0,m="[DecimalError] ",g=m+"Invalid argument: ",y=m+"Precision limit exceeded",b=m+"crypto unavailable",x="[object Decimal]",v=Math.floor,_=Math.pow,w=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,M=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,N=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,S=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,k=1e7,D=p.length-1,T=d.length-1,I={toStringTag:x};function E(e){var t,n,r,a=e.length-1,i="",s=e[0];if(a>0){for(i+=s,t=1;tn)throw Error(g+e)}function A(e,t,n,r){var a,i,s,o;for(i=e[0];i>=10;i/=10)--t;return--t<0?(t+=7,a=0):(a=Math.ceil((t+1)/7),t%=7),i=_(10,7-t),o=e[a]%i|0,null==r?t<3?(0==t?o=o/100|0:1==t&&(o=o/10|0),s=n<4&&99999==o||n>3&&49999==o||5e4==o||0==o):s=(n<4&&o+1==i||n>3&&o+1==i/2)&&(e[a+1]/i/100|0)==_(10,t-2)-1||(o==i/2||0==o)&&0==(e[a+1]/i/100|0):t<4?(0==t?o=o/1e3|0:1==t?o=o/100|0:2==t&&(o=o/10|0),s=(r||n<4)&&9999==o||!r&&n>3&&4999==o):s=((r||n<4)&&o+1==i||!r&&n>3&&o+1==i/2)&&(e[a+1]/i/1e3|0)==_(10,t-3)-1,s}function L(e,t,n){for(var r,a,i=[0],s=0,o=e.length;sn-1&&(void 0===i[r+1]&&(i[r+1]=0),i[r+1]+=i[r]/n|0,i[r]%=n)}return i.reverse()}I.absoluteValue=I.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),O(e)},I.ceil=function(){return O(new this.constructor(this),this.e+1,2)},I.clampedTo=I.clamp=function(e,t){var n=this,r=n.constructor;if(e=new r(e),t=new r(t),!e.s||!t.s)return new r(NaN);if(e.gt(t))throw Error(g+t);return n.cmp(e)<0?e:n.cmp(t)>0?t:new r(n)},I.comparedTo=I.cmp=function(e){var t,n,r,a,i=this,s=i.d,o=(e=new i.constructor(e)).d,u=i.s,l=e.s;if(!s||!o)return u&&l?u!==l?u:s===o?0:!s^u<0?1:-1:NaN;if(!s[0]||!o[0])return s[0]?u:o[0]?-l:0;if(u!==l)return u;if(i.e!==e.e)return i.e>e.e^u<0?1:-1;for(t=0,n=(r=s.length)<(a=o.length)?r:a;to[t]^u<0?1:-1;return r===a?0:r>a^u<0?1:-1},I.cosine=I.cos=function(){var e,t,n=this,r=n.constructor;return n.d?n.d[0]?(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+7,r.rounding=1,n=function(e,t){var n,r,a;if(t.isZero())return t;(r=t.d.length)<32?a=(1/X(4,n=Math.ceil(r/3))).toString():(n=16,a="2.3283064365386962890625e-10"),e.precision+=n,t=J(e,1,t.times(a),new e(1));for(var i=n;i--;){var s=t.times(t);t=s.times(s).minus(s).times(8).plus(1)}return e.precision-=n,t}(r,Z(r,n)),r.precision=e,r.rounding=t,O(2==o||3==o?n.neg():n,e,t,!0)):new r(1):new r(NaN)},I.cubeRoot=I.cbrt=function(){var e,t,n,r,a,i,s,o,u,l,c=this,p=c.constructor;if(!c.isFinite()||c.isZero())return new p(c);for(f=!1,(i=c.s*_(c.s*c,1/3))&&Math.abs(i)!=1/0?r=new p(i.toString()):(n=E(c.d),(i=((e=c.e)-n.length+1)%3)&&(n+=1==i||-2==i?"0":"00"),i=_(n,1/3),e=v((e+1)/3)-(e%3==(e<0?-1:2)),(r=new p(n=i==1/0?"5e"+e:(n=i.toExponential()).slice(0,n.indexOf("e")+1)+e)).s=c.s),s=(e=p.precision)+3;;)if(l=(u=(o=r).times(o).times(o)).plus(c),r=$(l.plus(c).times(o),l.plus(u),s+2,1),E(o.d).slice(0,s)===(n=E(r.d)).slice(0,s)){if("9999"!=(n=n.slice(s-3,s+1))&&(a||"4999"!=n)){+n&&(+n.slice(1)||"5"!=n.charAt(0))||(O(r,e+1,1),t=!r.times(r).times(r).eq(c));break}if(!a&&(O(o,e+1,0),o.times(o).times(o).eq(c))){r=o;break}s+=4,a=1}return f=!0,O(r,e,p.rounding,t)},I.decimalPlaces=I.dp=function(){var e,t=this.d,n=NaN;if(t){if(n=7*((e=t.length-1)-v(this.e/7)),e=t[e])for(;e%10==0;e/=10)n--;n<0&&(n=0)}return n},I.dividedBy=I.div=function(e){return $(this,new this.constructor(e))},I.dividedToIntegerBy=I.divToInt=function(e){var t=this.constructor;return O($(this,new t(e),0,1,1),t.precision,t.rounding)},I.equals=I.eq=function(e){return 0===this.cmp(e)},I.floor=function(){return O(new this.constructor(this),this.e+1,3)},I.greaterThan=I.gt=function(e){return this.cmp(e)>0},I.greaterThanOrEqualTo=I.gte=function(e){var t=this.cmp(e);return 1==t||0===t},I.hyperbolicCosine=I.cosh=function(){var e,t,n,r,a,i=this,s=i.constructor,o=new s(1);if(!i.isFinite())return new s(i.s?1/0:NaN);if(i.isZero())return o;n=s.precision,r=s.rounding,s.precision=n+Math.max(i.e,i.sd())+4,s.rounding=1,(a=i.d.length)<32?t=(1/X(4,e=Math.ceil(a/3))).toString():(e=16,t="2.3283064365386962890625e-10"),i=J(s,1,i.times(t),new s(1),!0);for(var u,l=e,c=new s(8);l--;)u=i.times(i),i=o.minus(u.times(c.minus(u.times(c))));return O(i,s.precision=n,s.rounding=r,!0)},I.hyperbolicSine=I.sinh=function(){var e,t,n,r,a=this,i=a.constructor;if(!a.isFinite()||a.isZero())return new i(a);if(t=i.precision,n=i.rounding,i.precision=t+Math.max(a.e,a.sd())+4,i.rounding=1,(r=a.d.length)<3)a=J(i,2,a,a,!0);else{e=(e=1.4*Math.sqrt(r))>16?16:0|e,a=J(i,2,a=a.times(1/X(5,e)),a,!0);for(var s,o=new i(5),u=new i(16),l=new i(20);e--;)s=a.times(a),a=a.times(o.plus(s.times(u.times(s).plus(l))))}return i.precision=t,i.rounding=n,O(a,t,n,!0)},I.hyperbolicTangent=I.tanh=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+7,r.rounding=1,$(n.sinh(),n.cosh(),r.precision=e,r.rounding=t)):new r(n.s)},I.inverseCosine=I.acos=function(){var e,t=this,n=t.constructor,r=t.abs().cmp(1),a=n.precision,i=n.rounding;return-1!==r?0===r?t.isNeg()?z(n,a,i):new n(0):new n(NaN):t.isZero()?z(n,a+4,i).times(.5):(n.precision=a+6,n.rounding=1,t=t.asin(),e=z(n,a+4,i).times(.5),n.precision=a,n.rounding=i,e.minus(t))},I.inverseHyperbolicCosine=I.acosh=function(){var e,t,n=this,r=n.constructor;return n.lte(1)?new r(n.eq(1)?0:NaN):n.isFinite()?(e=r.precision,t=r.rounding,r.precision=e+Math.max(Math.abs(n.e),n.sd())+4,r.rounding=1,f=!1,n=n.times(n).minus(1).sqrt().plus(n),f=!0,r.precision=e,r.rounding=t,n.ln()):new r(n)},I.inverseHyperbolicSine=I.asinh=function(){var e,t,n=this,r=n.constructor;return!n.isFinite()||n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+2*Math.max(Math.abs(n.e),n.sd())+6,r.rounding=1,f=!1,n=n.times(n).plus(1).sqrt().plus(n),f=!0,r.precision=e,r.rounding=t,n.ln())},I.inverseHyperbolicTangent=I.atanh=function(){var e,t,n,r,a=this,i=a.constructor;return a.isFinite()?a.e>=0?new i(a.abs().eq(1)?a.s/0:a.isZero()?a:NaN):(e=i.precision,t=i.rounding,r=a.sd(),Math.max(r,e)<2*-a.e-1?O(new i(a),e,t,!0):(i.precision=n=r-a.e,a=$(a.plus(1),new i(1).minus(a),n+e,1),i.precision=e+4,i.rounding=1,a=a.ln(),i.precision=e,i.rounding=t,a.times(.5))):new i(NaN)},I.inverseSine=I.asin=function(){var e,t,n,r,a=this,i=a.constructor;return a.isZero()?new i(a):(t=a.abs().cmp(1),n=i.precision,r=i.rounding,-1!==t?0===t?((e=z(i,n+4,r).times(.5)).s=a.s,e):new i(NaN):(i.precision=n+6,i.rounding=1,a=a.div(new i(1).minus(a.times(a)).sqrt().plus(1)).atan(),i.precision=n,i.rounding=r,a.times(2)))},I.inverseTangent=I.atan=function(){var e,t,n,r,a,i,s,o,u,l=this,c=l.constructor,p=c.precision,d=c.rounding;if(l.isFinite()){if(l.isZero())return new c(l);if(l.abs().eq(1)&&p+4<=T)return(s=z(c,p+4,d).times(.25)).s=l.s,s}else{if(!l.s)return new c(NaN);if(p+4<=T)return(s=z(c,p+4,d).times(.5)).s=l.s,s}for(c.precision=o=p+10,c.rounding=1,e=n=Math.min(28,o/7+2|0);e;--e)l=l.div(l.times(l).plus(1).sqrt().plus(1));for(f=!1,t=Math.ceil(o/7),r=1,u=l.times(l),s=new c(l),a=l;-1!==e;)if(a=a.times(u),i=s.minus(a.div(r+=2)),a=a.times(u),void 0!==(s=i.plus(a.div(r+=2))).d[t])for(e=t;s.d[e]===i.d[e]&&e--;);return n&&(s=s.times(2<this.d.length-2},I.isNaN=function(){return!this.s},I.isNegative=I.isNeg=function(){return this.s<0},I.isPositive=I.isPos=function(){return this.s>0},I.isZero=function(){return!!this.d&&0===this.d[0]},I.lessThan=I.lt=function(e){return this.cmp(e)<0},I.lessThanOrEqualTo=I.lte=function(e){return this.cmp(e)<1},I.logarithm=I.log=function(e){var t,n,r,a,i,s,o,u,l=this,c=l.constructor,p=c.precision,d=c.rounding;if(null==e)e=new c(10),t=!0;else{if(n=(e=new c(e)).d,e.s<0||!n||!n[0]||e.eq(1))return new c(NaN);t=e.eq(10)}if(n=l.d,l.s<0||!n||!n[0]||l.eq(1))return new c(n&&!n[0]?-1/0:1!=l.s?NaN:n?0:1/0);if(t)if(n.length>1)i=!0;else{for(a=n[0];a%10==0;)a/=10;i=1!==a}if(f=!1,s=W(l,o=p+5),r=t?Y(c,o+10):W(e,o),A((u=$(s,r,o,1)).d,a=p,d))do{if(s=W(l,o+=10),r=t?Y(c,o+10):W(e,o),u=$(s,r,o,1),!i){+E(u.d).slice(a+1,a+15)+1==1e14&&(u=O(u,p+1,0));break}}while(A(u.d,a+=10,d));return f=!0,O(u,p,d)},I.minus=I.sub=function(e){var t,n,r,a,i,s,o,u,l,c,p,d,h=this,m=h.constructor;if(e=new m(e),!h.d||!e.d)return h.s&&e.s?h.d?e.s=-e.s:e=new m(e.d||h.s!==e.s?h:NaN):e=new m(NaN),e;if(h.s!=e.s)return e.s=-e.s,h.plus(e);if(l=h.d,d=e.d,o=m.precision,u=m.rounding,!l[0]||!d[0]){if(d[0])e.s=-e.s;else{if(!l[0])return new m(3===u?-0:0);e=new m(h)}return f?O(e,o,u):e}if(n=v(e.e/7),c=v(h.e/7),l=l.slice(),i=c-n){for((p=i<0)?(t=l,i=-i,s=d.length):(t=d,n=c,s=l.length),i>(r=Math.max(Math.ceil(o/7),s)+2)&&(i=r,t.length=1),t.reverse(),r=i;r--;)t.push(0);t.reverse()}else{for((p=(r=l.length)<(s=d.length))&&(s=r),r=0;r0;--r)l[s++]=0;for(r=d.length;r>i;){if(l[--r](s=(i=Math.ceil(o/7))>s?i+1:s+1)&&(a=s,n.length=1),n.reverse();a--;)n.push(0);n.reverse()}for((s=l.length)-(a=c.length)<0&&(a=s,n=c,c=l,l=n),t=0;a;)t=(l[--a]=l[a]+c[a]+t)/k|0,l[a]%=k;for(t&&(l.unshift(t),++r),s=l.length;0==l[--s];)l.pop();return e.d=l,e.e=F(l,r),f?O(e,o,u):e},I.precision=I.sd=function(e){var t,n=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(g+e);return n.d?(t=B(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t},I.round=function(){var e=this,t=e.constructor;return O(new t(e),e.e+1,t.rounding)},I.sine=I.sin=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+7,r.rounding=1,n=function(e,t){var n,r=t.d.length;if(r<3)return t.isZero()?t:J(e,2,t,t);n=(n=1.4*Math.sqrt(r))>16?16:0|n,t=J(e,2,t=t.times(1/X(5,n)),t);for(var a,i=new e(5),s=new e(16),o=new e(20);n--;)a=t.times(t),t=t.times(i.plus(a.times(s.times(a).minus(o))));return t}(r,Z(r,n)),r.precision=e,r.rounding=t,O(o>2?n.neg():n,e,t,!0)):new r(NaN)},I.squareRoot=I.sqrt=function(){var e,t,n,r,a,i,s=this,o=s.d,u=s.e,l=s.s,c=s.constructor;if(1!==l||!o||!o[0])return new c(!l||l<0&&(!o||o[0])?NaN:o?s:1/0);for(f=!1,0==(l=Math.sqrt(+s))||l==1/0?(((t=E(o)).length+u)%2==0&&(t+="0"),l=Math.sqrt(t),u=v((u+1)/2)-(u<0||u%2),r=new c(t=l==1/0?"5e"+u:(t=l.toExponential()).slice(0,t.indexOf("e")+1)+u)):r=new c(l.toString()),n=(u=c.precision)+3;;)if(r=(i=r).plus($(s,i,n+2,1)).times(.5),E(i.d).slice(0,n)===(t=E(r.d)).slice(0,n)){if("9999"!=(t=t.slice(n-3,n+1))&&(a||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(O(r,u+1,1),e=!r.times(r).eq(s));break}if(!a&&(O(i,u+1,0),i.times(i).eq(s))){r=i;break}n+=4,a=1}return f=!0,O(r,u,c.rounding,e)},I.tangent=I.tan=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+10,r.rounding=1,(n=n.sin()).s=1,n=$(n,new r(1).minus(n.times(n)).sqrt(),e+10,0),r.precision=e,r.rounding=t,O(2==o||4==o?n.neg():n,e,t,!0)):new r(NaN)},I.times=I.mul=function(e){var t,n,r,a,i,s,o,u,l,c=this,p=c.constructor,d=c.d,h=(e=new p(e)).d;if(e.s*=c.s,!(d&&d[0]&&h&&h[0]))return new p(!e.s||d&&!d[0]&&!h||h&&!h[0]&&!d?NaN:d&&h?0*e.s:e.s/0);for(n=v(c.e/7)+v(e.e/7),(u=d.length)<(l=h.length)&&(i=d,d=h,h=i,s=u,u=l,l=s),i=[],r=s=u+l;r--;)i.push(0);for(r=l;--r>=0;){for(t=0,a=u+r;a>r;)o=i[a]+h[r]*d[a-r-1]+t,i[a--]=o%k|0,t=o/k|0;i[a]=(i[a]+t)%k|0}for(;!i[--s];)i.pop();return t?++n:i.shift(),e.d=i,e.e=F(i,n),f?O(e,p.precision,p.rounding):e},I.toBinary=function(e,t){return Q(this,2,e,t)},I.toDecimalPlaces=I.toDP=function(e,t){var n=this,r=n.constructor;return n=new r(n),void 0===e?n:(C(e,0,l),void 0===t?t=r.rounding:C(t,0,8),O(n,e+n.e+1,t))},I.toExponential=function(e,t){var n,r=this,a=r.constructor;return void 0===e?n=R(r,!0):(C(e,0,l),void 0===t?t=a.rounding:C(t,0,8),n=R(r=O(new a(r),e+1,t),!0,e+1)),r.isNeg()&&!r.isZero()?"-"+n:n},I.toFixed=function(e,t){var n,r,a=this,i=a.constructor;return void 0===e?n=R(a):(C(e,0,l),void 0===t?t=i.rounding:C(t,0,8),n=R(r=O(new i(a),e+a.e+1,t),!1,e+r.e+1)),a.isNeg()&&!a.isZero()?"-"+n:n},I.toFraction=function(e){var t,n,r,a,i,s,o,u,l,c,p,d,h=this,m=h.d,y=h.constructor;if(!m)return new y(h);if(l=n=new y(1),r=u=new y(0),s=(i=(t=new y(r)).e=B(m)-h.e-1)%7,t.d[0]=_(10,s<0?7+s:s),null==e)e=i>0?t:l;else{if(!(o=new y(e)).isInt()||o.lt(l))throw Error(g+o);e=o.gt(t)?i>0?t:l:o}for(f=!1,o=new y(E(m)),c=y.precision,y.precision=i=7*m.length*2;p=$(o,t,0,1,1),1!=(a=n.plus(p.times(r))).cmp(e);)n=r,r=a,a=l,l=u.plus(p.times(a)),u=a,a=t,t=o.minus(p.times(a)),o=a;return a=$(e.minus(n),r,0,1,1),u=u.plus(a.times(l)),n=n.plus(a.times(r)),u.s=l.s=h.s,d=$(l,r,i,1).minus(h).abs().cmp($(u,n,i,1).minus(h).abs())<1?[l,r]:[u,n],y.precision=c,f=!0,d},I.toHexadecimal=I.toHex=function(e,t){return Q(this,16,e,t)},I.toNearest=function(e,t){var n=this,r=n.constructor;if(n=new r(n),null==e){if(!n.d)return n;e=new r(1),t=r.rounding}else{if(e=new r(e),void 0===t?t=r.rounding:C(t,0,8),!n.d)return e.s?n:e;if(!e.d)return e.s&&(e.s=n.s),e}return e.d[0]?(f=!1,n=$(n,e,0,t,1).times(e),f=!0,O(n)):(e.s=n.s,n=e),n},I.toNumber=function(){return+this},I.toOctal=function(e,t){return Q(this,8,e,t)},I.toPower=I.pow=function(e){var t,n,r,a,i,s,o=this,u=o.constructor,l=+(e=new u(e));if(!(o.d&&e.d&&o.d[0]&&e.d[0]))return new u(_(+o,l));if((o=new u(o)).eq(1))return o;if(r=u.precision,i=u.rounding,e.eq(1))return O(o,r,i);if((t=v(e.e/7))>=e.d.length-1&&(n=l<0?-l:l)<=9007199254740991)return a=H(u,o,n,r),e.s<0?new u(1).div(a):O(a,r,i);if((s=o.s)<0){if(tu.maxE+1||t0?s/0:0):(f=!1,u.rounding=o.s=1,n=Math.min(12,(t+"").length),(a=q(e.times(W(o,r+n)),r)).d&&A((a=O(a,r+5,1)).d,r,i)&&(t=r+10,+E((a=O(q(e.times(W(o,t+n)),t),t+5,1)).d).slice(r+1,r+15)+1==1e14&&(a=O(a,r+1,0))),a.s=s,f=!0,u.rounding=i,O(a,r,i))},I.toPrecision=function(e,t){var n,r=this,a=r.constructor;return void 0===e?n=R(r,r.e<=a.toExpNeg||r.e>=a.toExpPos):(C(e,1,l),void 0===t?t=a.rounding:C(t,0,8),n=R(r=O(new a(r),e,t),e<=r.e||r.e<=a.toExpNeg,e)),r.isNeg()&&!r.isZero()?"-"+n:n},I.toSignificantDigits=I.toSD=function(e,t){var n=this.constructor;return void 0===e?(e=n.precision,t=n.rounding):(C(e,1,l),void 0===t?t=n.rounding:C(t,0,8)),O(new n(this),e,t)},I.toString=function(){var e=this,t=e.constructor,n=R(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+n:n},I.truncated=I.trunc=function(){return O(new this.constructor(this),this.e+1,1)},I.valueOf=I.toJSON=function(){var e=this,t=e.constructor,n=R(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+n:n};var $=function(){function e(e,t,n){var r,a=0,i=e.length;for(e=e.slice();i--;)r=e[i]*t+a,e[i]=r%n|0,a=r/n|0;return a&&e.unshift(a),e}function t(e,t,n,r){var a,i;if(n!=r)i=n>r?1:-1;else for(a=i=0;at[a]?1:-1;break}return i}function n(e,t,n,r){for(var a=0;n--;)e[n]-=a,a=e[n]1;)e.shift()}return function(r,a,i,o,u,l){var c,p,d,h,f,m,g,y,b,x,_,w,M,N,S,D,T,I,E,C,A=r.constructor,L=r.s==a.s?1:-1,$=r.d,R=a.d;if(!($&&$[0]&&R&&R[0]))return new A(r.s&&a.s&&($?!R||$[0]!=R[0]:R)?$&&0==$[0]||!R?0*L:L/0:NaN);for(l?(f=1,p=r.e-a.e):(l=k,f=7,p=v(r.e/f)-v(a.e/f)),E=R.length,T=$.length,x=(b=new A(L)).d=[],d=0;R[d]==($[d]||0);d++);if(R[d]>($[d]||0)&&p--,null==i?(N=i=A.precision,o=A.rounding):N=u?i+(r.e-a.e)+1:i,N<0)x.push(1),m=!0;else{if(N=N/f+2|0,d=0,1==E){for(h=0,R=R[0],N++;(d1&&(R=e(R,h,l),$=e($,h,l),E=R.length,T=$.length),D=E,w=(_=$.slice(0,E)).length;w=l/2&&++I;do{h=0,(c=t(R,_,E,w))<0?(M=_[0],E!=w&&(M=M*l+(_[1]||0)),(h=M/I|0)>1?(h>=l&&(h=l-1),1==(c=t(g=e(R,h,l),_,y=g.length,w=_.length))&&(h--,n(g,E=10;h/=10)d++;b.e=d+p*f-1,O(b,u?i+b.e+1:i,o,m)}return b}}();function O(e,t,n,r){var a,i,s,o,u,l,c,p,d,h=e.constructor;e:if(null!=t){if(!(p=e.d))return e;for(a=1,o=p[0];o>=10;o/=10)a++;if((i=t-a)<0)i+=7,s=t,u=(c=p[d=0])/_(10,a-s-1)%10|0;else if((d=Math.ceil((i+1)/7))>=(o=p.length)){if(!r)break e;for(;o++<=d;)p.push(0);c=u=0,a=1,s=(i%=7)-7+1}else{for(c=o=p[d],a=1;o>=10;o/=10)a++;u=(s=(i%=7)-7+a)<0?0:c/_(10,a-s-1)%10|0}if(r=r||t<0||void 0!==p[d+1]||(s<0?c:c%_(10,a-s-1)),l=n<4?(u||r)&&(0==n||n==(e.s<0?3:2)):u>5||5==u&&(4==n||r||6==n&&(i>0?s>0?c/_(10,a-s):0:p[d-1])%10&1||n==(e.s<0?8:7)),t<1||!p[0])return p.length=0,l?(t-=e.e+1,p[0]=_(10,(7-t%7)%7),e.e=-t||0):p[0]=e.e=0,e;if(0==i?(p.length=d,o=1,d--):(p.length=d+1,o=_(10,7-i),p[d]=s>0?(c/_(10,a-s)%_(10,s)|0)*o:0),l)for(;;){if(0==d){for(i=1,s=p[0];s>=10;s/=10)i++;for(s=p[0]+=o,o=1;s>=10;s/=10)o++;i!=o&&(e.e++,p[0]==k&&(p[0]=1));break}if(p[d]+=o,p[d]!=k)break;p[d--]=0,o=1}for(i=p.length;0===p[--i];)p.pop()}return f&&(e.e>h.maxE?(e.d=null,e.e=NaN):e.e0?i=i.charAt(0)+"."+i.slice(1)+P(r):s>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(e.e<0?"e":"e+")+e.e):a<0?(i="0."+P(-a-1)+i,n&&(r=n-s)>0&&(i+=P(r))):a>=s?(i+=P(a+1-s),n&&(r=n-a-1)>0&&(i=i+"."+P(r))):((r=a+1)0&&(a+1===s&&(i+="."),i+=P(r))),i}function F(e,t){var n=e[0];for(t*=7;n>=10;n/=10)t++;return t}function Y(e,t,n){if(t>D)throw f=!0,n&&(e.precision=n),Error(y);return O(new e(p),t,1,!0)}function z(e,t,n){if(t>T)throw Error(y);return O(new e(d),t,n,!0)}function B(e){var t=e.length-1,n=7*t+1;if(t=e[t]){for(;t%10==0;t/=10)n--;for(t=e[0];t>=10;t/=10)n++}return n}function P(e){for(var t="";e--;)t+="0";return t}function H(e,t,n,r){var a,i=new e(1),s=Math.ceil(r/7+4);for(f=!1;;){if(n%2&&ee((i=i.times(t)).d,s)&&(a=!0),0===(n=v(n/2))){n=i.d.length-1,a&&0===i.d[n]&&++i.d[n];break}ee((t=t.times(t)).d,s)}return f=!0,i}function j(e){return 1&e.d[e.d.length-1]}function U(e,t,n){for(var r,a=new e(t[0]),i=0;++i17)return new d(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(null==t?(f=!1,u=m):u=t,o=new d(.03125);e.e>-2;)e=e.times(o),p+=5;for(u+=r=Math.log(_(2,p))/Math.LN10*2+5|0,n=i=s=new d(1),d.precision=u;;){if(i=O(i.times(e),u,1),n=n.times(++c),E((o=s.plus($(i,n,u,1))).d).slice(0,u)===E(s.d).slice(0,u)){for(a=p;a--;)s=O(s.times(s),u,1);if(null!=t)return d.precision=m,s;if(!(l<3&&A(s.d,u-r,h,l)))return O(s,d.precision=m,h,f=!0);d.precision=u+=10,n=i=o=new d(1),c=0,l++}s=o}}function W(e,t){var n,r,a,i,s,o,u,l,c,p,d,h=1,m=e,g=m.d,y=m.constructor,b=y.rounding,x=y.precision;if(m.s<0||!g||!g[0]||!m.e&&1==g[0]&&1==g.length)return new y(g&&!g[0]?-1/0:1!=m.s?NaN:g?0:m);if(null==t?(f=!1,c=x):c=t,y.precision=c+=10,r=(n=E(g)).charAt(0),!(Math.abs(i=m.e)<15e14))return l=Y(y,c+2,x).times(i+""),m=W(new y(r+"."+n.slice(1)),c-10).plus(l),y.precision=x,null==t?O(m,x,b,f=!0):m;for(;r<7&&1!=r||1==r&&n.charAt(1)>3;)r=(n=E((m=m.times(e)).d)).charAt(0),h++;for(i=m.e,r>1?(m=new y("0."+n),i++):m=new y(r+"."+n.slice(1)),p=m,u=s=m=$(m.minus(1),m.plus(1),c,1),d=O(m.times(m),c,1),a=3;;){if(s=O(s.times(d),c,1),E((l=u.plus($(s,new y(a),c,1))).d).slice(0,c)===E(u.d).slice(0,c)){if(u=u.times(2),0!==i&&(u=u.plus(Y(y,c+2,x).times(i+""))),u=$(u,new y(h),c,1),null!=t)return y.precision=x,u;if(!A(u.d,c-10,b,o))return O(u,y.precision=x,b,f=!0);y.precision=c+=10,l=s=m=$(p.minus(1),p.plus(1),c,1),d=O(m.times(m),c,1),a=o=1}u=l,a+=2}}function V(e){return String(e.s*e.s/0)}function G(e,t){var n,r,a;for((n=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;48===t.charCodeAt(r);r++);for(a=t.length;48===t.charCodeAt(a-1);--a);if(t=t.slice(r,a)){if(a-=r,e.e=n=n-r-1,e.d=[],r=(n+1)%7,n<0&&(r+=7),re.constructor.maxE?(e.d=null,e.e=NaN):e.e-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),S.test(t))return G(e,t)}else if("Infinity"===t||"NaN"===t)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(M.test(t))n=16,t=t.toLowerCase();else if(w.test(t))n=2;else{if(!N.test(t))throw Error(g+t);n=8}for((s=t.search(/p/i))>0?(l=+t.slice(s+1),t=t.substring(2,s)):t=t.slice(2),o=(s=t.indexOf("."))>=0,r=e.constructor,o&&(s=(u=(t=t.replace(".","")).length)-s,a=H(r,new r(n),s,2*s)),s=p=(c=L(t,n,k)).length-1;0===c[s];--s)c.pop();return s<0?new r(0*e.s):(e.e=F(c,p),e.d=c,f=!1,o&&(e=$(e,a,4*u)),l&&(e=e.times(Math.abs(l)<54?_(2,l):i.pow(2,l))),f=!0,e)}function J(e,t,n,r,a){var i,s,o,u,l=e.precision,c=Math.ceil(l/7);for(f=!1,u=n.times(n),o=new e(r);;){if(s=$(o.times(u),new e(t++*t++),l,1),o=a?r.plus(s):r.minus(s),r=$(s.times(u),new e(t++*t++),l,1),void 0!==(s=o.plus(r)).d[c]){for(i=c;s.d[i]===o.d[i]&&i--;);if(-1==i)break}i=o,o=r,r=s,s=i}return f=!0,s.d.length=c+1,s}function X(e,t){for(var n=e;--t;)n*=e;return n}function Z(e,t){var n,r=t.s<0,a=z(e,e.precision,1),i=a.times(.5);if((t=t.abs()).lte(i))return o=r?4:1,t;if((n=t.divToInt(a)).isZero())o=r?3:2;else{if((t=t.minus(n.times(a))).lte(i))return o=j(n)?r?2:3:r?4:1,t;o=j(n)?r?1:4:r?3:2}return t.minus(a).abs()}function Q(e,t,n,r){var a,i,o,u,p,d,h,f,m,g=e.constructor,y=void 0!==n;if(y?(C(n,1,l),void 0===r?r=g.rounding:C(r,0,8)):(n=g.precision,r=g.rounding),e.isFinite()){for(y?(a=2,16==t?n=4*n-3:8==t&&(n=3*n-2)):a=t,(o=(h=R(e)).indexOf("."))>=0&&(h=h.replace(".",""),(m=new g(1)).e=h.length-o,m.d=L(R(m),10,a),m.e=m.d.length),i=p=(f=L(h,10,a)).length;0==f[--p];)f.pop();if(f[0]){if(o<0?i--:((e=new g(e)).d=f,e.e=i,f=(e=$(e,m,n,r,0,a)).d,i=e.e,d=s),o=f[n],u=a/2,d=d||void 0!==f[n+1],d=r<4?(void 0!==o||d)&&(0===r||r===(e.s<0?3:2)):o>u||o===u&&(4===r||d||6===r&&1&f[n-1]||r===(e.s<0?8:7)),f.length=n,d)for(;++f[--n]>a-1;)f[n]=0,n||(++i,f.unshift(1));for(p=f.length;!f[p-1];--p);for(o=0,h="";o1)if(16==t||8==t){for(o=16==t?4:3,--p;p%o;p++)h+="0";for(p=(f=L(h,a,t)).length;!f[p-1];--p);for(o=1,h="1.";op)for(i-=p;i--;)h+="0";else it)return e.length=t,!0}function te(e){return new this(e).abs()}function ne(e){return new this(e).acos()}function re(e){return new this(e).acosh()}function ae(e,t){return new this(e).plus(t)}function ie(e){return new this(e).asin()}function se(e){return new this(e).asinh()}function oe(e){return new this(e).atan()}function ue(e){return new this(e).atanh()}function le(e,t){e=new this(e),t=new this(t);var n,r=this.precision,a=this.rounding,i=r+4;return e.s&&t.s?e.d||t.d?!t.d||e.isZero()?(n=t.s<0?z(this,r,a):new this(0)).s=e.s:!e.d||t.isZero()?(n=z(this,i,1).times(.5)).s=e.s:t.s<0?(this.precision=i,this.rounding=1,n=this.atan($(e,t,i,1)),t=z(this,i,1),this.precision=r,this.rounding=a,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan($(e,t,i,1)):(n=z(this,i,1).times(t.s>0?.25:.75)).s=e.s:n=new this(NaN),n}function ce(e){return new this(e).cbrt()}function pe(e){return O(e=new this(e),e.e+1,2)}function de(e,t,n){return new this(e).clamp(t,n)}function he(e){if(!e||"object"!=typeof e)throw Error(m+"Object expected");var t,n,r,a=!0===e.defaults,i=["precision",1,l,"rounding",0,8,"toExpNeg",-u,0,"toExpPos",0,u,"maxE",0,u,"minE",-u,0,"modulo",0,9];for(t=0;t=i[t+1]&&r<=i[t+2]))throw Error(g+n+": "+r);this[n]=r}if(n="crypto",a&&(this[n]=h[n]),void 0!==(r=e[n])){if(!0!==r&&!1!==r&&0!==r&&1!==r)throw Error(g+n+": "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(b);this[n]=!0}else this[n]=!1}return this}function fe(e){return new this(e).cos()}function me(e){return new this(e).cosh()}function ge(e,t){return new this(e).div(t)}function ye(e){return new this(e).exp()}function be(e){return O(e=new this(e),e.e+1,3)}function xe(){var e,t,n=new this(0);for(f=!1,e=0;e=429e7?t[i]=crypto.getRandomValues(new Uint32Array(1))[0]:o[i++]=a%1e7;else{if(!crypto.randomBytes)throw Error(b);for(t=crypto.randomBytes(r*=4);i=214e7?crypto.randomBytes(4).copy(t,i):(o.push(a%1e7),i+=4);i=r/4}else for(;i=10;a/=10)r++;r<7&&(n-=7-r)}return s.e=n,s.d=o,s}function Ce(e){return O(e=new this(e),e.e+1,this.rounding)}function Ae(e){return(e=new this(e)).d?e.d[0]?e.s:0*e.s:e.s||NaN}function Le(e){return new this(e).sin()}function $e(e){return new this(e).sinh()}function Oe(e){return new this(e).sqrt()}function Re(e,t){return new this(e).sub(t)}function Fe(){var e=0,t=arguments,n=new this(t[e]);for(f=!1;n.s&&++ei.maxE?(a.e=NaN,a.d=null):e.e=10;n/=10)t++;return void(f?t>i.maxE?(a.e=NaN,a.d=null):t{"use strict";var t=Object.assign||function(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:{},s=i.preserveFormatting,o=void 0!==s&&s,u=i.escapeMapFn,l=void 0===u?a:u,c=String(e),p="",d=l(t({},n),o?t({},r):{}),h=Object.keys(d),f=function(){var e=!1;h.forEach((function(t,n){e||c.length>=t.length&&c.slice(0,t.length)===t&&(p+=d[h[n]],c=c.slice(t.length,c.length),e=!0)})),e||(p+=c.slice(0,1),c=c.slice(1,c.length))};c;)f();return p}},5628:function(e,t){var n;!function(r){"use strict";var a={s:1,n:0,d:1};function i(e,t){if(isNaN(e=parseInt(e,10)))throw c.InvalidParameter;return e*t}function s(e,t){if(0===t)throw c.DivisionByZero;var n=Object.create(c.prototype);n.s=e<0?-1:1;var r=l(e=e<0?-e:e,t);return n.n=e/r,n.d=t/r,n}function o(e){for(var t={},n=e,r=2,a=4;a<=n;){for(;n%r==0;)n/=r,t[r]=(t[r]||0)+1;a+=1+2*r++}return n!==e?n>1&&(t[n]=(t[n]||0)+1):t[e]=(t[e]||0)+1,t}var u=function(e,t){var n,r=0,s=1,o=1,u=0,l=0,p=0,d=1,h=1,f=0,m=1,g=1,y=1,b=1e7;if(null==e);else if(void 0!==t){if(o=(r=e)*(s=t),r%1!=0||s%1!=0)throw c.NonIntegerParameter}else switch(typeof e){case"object":if("d"in e&&"n"in e)r=e.n,s=e.d,"s"in e&&(r*=e.s);else{if(!(0 in e))throw c.InvalidParameter;r=e[0],1 in e&&(s=e[1])}o=r*s;break;case"number":if(e<0&&(o=e,e=-e),e%1==0)r=e;else if(e>0){for(e>=1&&(e/=h=Math.pow(10,Math.floor(1+Math.log(e)/Math.LN10)));m<=b&&y<=b;){if(e===(n=(f+g)/(m+y))){m+y<=b?(r=f+g,s=m+y):y>m?(r=g,s=y):(r=f,s=m);break}e>n?(f+=g,m+=y):(g+=f,y+=m),m>b?(r=g,s=y):(r=f,s=m)}r*=h}else(isNaN(e)||isNaN(t))&&(s=r=NaN);break;case"string":if(null===(m=e.match(/\d+|./g)))throw c.InvalidParameter;if("-"===m[f]?(o=-1,f++):"+"===m[f]&&f++,m.length===f+1?l=i(m[f++],o):"."===m[f+1]||"."===m[f]?("."!==m[f]&&(u=i(m[f++],o)),(1+ ++f===m.length||"("===m[f+1]&&")"===m[f+3]||"'"===m[f+1]&&"'"===m[f+3])&&(l=i(m[f],o),d=Math.pow(10,m[f].length),f++),("("===m[f]&&")"===m[f+2]||"'"===m[f]&&"'"===m[f+2])&&(p=i(m[f+1],o),h=Math.pow(10,m[f+1].length)-1,f+=3)):"/"===m[f+1]||":"===m[f+1]?(l=i(m[f],o),d=i(m[f+2],1),f+=3):"/"===m[f+3]&&" "===m[f+1]&&(u=i(m[f],o),l=i(m[f+2],o),d=i(m[f+4],1),f+=5),m.length<=f){o=r=p+(s=d*h)*u+h*l;break}default:throw c.InvalidParameter}if(0===s)throw c.DivisionByZero;a.s=o<0?-1:1,a.n=Math.abs(r),a.d=Math.abs(s)};function l(e,t){if(!e)return t;if(!t)return e;for(;;){if(!(e%=t))return t;if(!(t%=e))return e}}function c(e,t){if(u(e,t),!(this instanceof c))return s(a.s*a.n,a.d);e=l(a.d,a.n),this.s=a.s,this.n=a.n/e,this.d=a.d/e}c.DivisionByZero=new Error("Division by Zero"),c.InvalidParameter=new Error("Invalid argument"),c.NonIntegerParameter=new Error("Parameters must be integer"),c.prototype={s:1,n:0,d:1,abs:function(){return s(this.n,this.d)},neg:function(){return s(-this.s*this.n,this.d)},add:function(e,t){return u(e,t),s(this.s*this.n*a.d+a.s*this.d*a.n,this.d*a.d)},sub:function(e,t){return u(e,t),s(this.s*this.n*a.d-a.s*this.d*a.n,this.d*a.d)},mul:function(e,t){return u(e,t),s(this.s*a.s*this.n*a.n,this.d*a.d)},div:function(e,t){return u(e,t),s(this.s*a.s*this.n*a.d,this.d*a.n)},clone:function(){return s(this.s*this.n,this.d)},mod:function(e,t){if(isNaN(this.n)||isNaN(this.d))return new c(NaN);if(void 0===e)return s(this.s*this.n%this.d,1);if(u(e,t),0===a.n&&0===this.d)throw c.DivisionByZero;return s(this.s*(a.d*this.n)%(a.n*this.d),a.d*this.d)},gcd:function(e,t){return u(e,t),s(l(a.n,this.n)*l(a.d,this.d),a.d*this.d)},lcm:function(e,t){return u(e,t),0===a.n&&0===this.n?s(0,1):s(a.n*this.n,l(a.n,this.n)*l(a.d,this.d))},ceil:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new c(NaN):s(Math.ceil(e*this.s*this.n/this.d),e)},floor:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new c(NaN):s(Math.floor(e*this.s*this.n/this.d),e)},round:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new c(NaN):s(Math.round(e*this.s*this.n/this.d),e)},inverse:function(){return s(this.s*this.d,this.n)},pow:function(e,t){if(u(e,t),1===a.d)return a.s<0?s(Math.pow(this.s*this.d,a.n),Math.pow(this.n,a.n)):s(Math.pow(this.s*this.n,a.n),Math.pow(this.d,a.n));if(this.s<0)return null;var n=o(this.n),r=o(this.d),i=1,l=1;for(var c in n)if("1"!==c){if("0"===c){i=0;break}if(n[c]*=a.n,n[c]%a.d!=0)return null;n[c]/=a.d,i*=Math.pow(c,n[c])}for(var c in r)if("1"!==c){if(r[c]*=a.n,r[c]%a.d!=0)return null;r[c]/=a.d,l*=Math.pow(c,r[c])}return a.s<0?s(l,i):s(i,l)},equals:function(e,t){return u(e,t),this.s*this.n*a.d==a.s*a.n*this.d},compare:function(e,t){u(e,t);var n=this.s*this.n*a.d-a.s*a.n*this.d;return(0=0;i--)a=a.inverse().add(n[i]);if(a.sub(t).abs().valueOf()0&&(n+=t,n+=" ",r%=a),n+=r,n+="/",n+=a),n},toLatex:function(e){var t,n="",r=this.n,a=this.d;return this.s<0&&(n+="-"),1===a?n+=r:(e&&(t=Math.floor(r/a))>0&&(n+=t,r%=a),n+="\\frac{",n+=r,n+="}{",n+=a,n+="}"),n},toContinued:function(){var e,t=this.n,n=this.d,r=[];if(isNaN(t)||isNaN(n))return r;do{r.push(Math.floor(t/n)),e=t%n,t=n,n=e}while(1!==t);return r},toString:function(e){var t=this.n,n=this.d;if(isNaN(t)||isNaN(n))return"NaN";e=e||15;var r=function(e,t){for(;t%2==0;t/=2);for(;t%5==0;t/=5);if(1===t)return 0;for(var n=10%t,r=1;1!==n;r++)if(n=10*n%t,r>2e3)return 0;return r}(0,n),a=function(e,t,n){for(var r=1,a=function(e,t,n){for(var r=1;t>0;e=e*e%n,t>>=1)1&t&&(r=r*e%n);return r}(10,n,t),i=0;i<300;i++){if(r===a)return i;r=10*r%t,a=10*a%t}return 0}(0,n,r),i=this.s<0?"-":"";if(i+=t/n|0,t%=n,(t*=10)&&(i+="."),r){for(var s=a;s--;)i+=t/n|0,t%=n,t*=10;for(i+="(",s=r;s--;)i+=t/n|0,t%=n,t*=10;i+=")"}else for(s=e;t&&s--;)i+=t/n|0,t%=n,t*=10;return i}},void 0===(n=function(){return c}.apply(t,[]))||(e.exports=n)}()},3228:e=>{e.exports=function e(t,n){"use strict";var r,a,i=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,s=/(^[ ]*|[ ]*$)/g,o=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,u=/^0x[0-9a-f]+$/i,l=/^0/,c=function(t){return e.insensitive&&(""+t).toLowerCase()||""+t},p=c(t).replace(s,"")||"",d=c(n).replace(s,"")||"",h=p.replace(i,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),f=d.replace(i,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),m=parseInt(p.match(u),16)||1!==h.length&&p.match(o)&&Date.parse(p),g=parseInt(d.match(u),16)||m&&d.match(o)&&Date.parse(d)||null;if(g){if(mg)return 1}for(var y=0,b=Math.max(h.length,f.length);ya)return 1}return 0}},3720:e=>{e.exports=n;var t=null;try{t=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(e){}function n(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function r(e){return!0===(e&&e.__isLong__)}n.prototype.__isLong__,Object.defineProperty(n.prototype,"__isLong__",{value:!0}),n.isLong=r;var a={},i={};function s(e,t){var n,r,s;return t?(s=0<=(e>>>=0)&&e<256)&&(r=i[e])?r:(n=u(e,(0|e)<0?-1:0,!0),s&&(i[e]=n),n):(s=-128<=(e|=0)&&e<128)&&(r=a[e])?r:(n=u(e,e<0?-1:0,!1),s&&(a[e]=n),n)}function o(e,t){if(isNaN(e))return t?y:g;if(t){if(e<0)return y;if(e>=h)return w}else{if(e<=-f)return M;if(e+1>=f)return _}return e<0?o(-e,t).neg():u(e%d|0,e/d|0,t)}function u(e,t,r){return new n(e,t,r)}n.fromInt=s,n.fromNumber=o,n.fromBits=u;var l=Math.pow;function c(e,t,n){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return g;if("number"==typeof t?(n=t,t=!1):t=!!t,(n=n||10)<2||360)throw Error("interior hyphen");if(0===r)return c(e.substring(1),t,n).neg();for(var a=o(l(n,8)),i=g,s=0;s>>0:this.low},N.toNumber=function(){return this.unsigned?(this.high>>>0)*d+(this.low>>>0):this.high*d+(this.low>>>0)},N.toString=function(e){if((e=e||10)<2||36>>0).toString(e);if((i=u).isZero())return c+s;for(;c.length<6;)c="0"+c;s=""+c+s}},N.getHighBits=function(){return this.high},N.getHighBitsUnsigned=function(){return this.high>>>0},N.getLowBits=function(){return this.low},N.getLowBitsUnsigned=function(){return this.low>>>0},N.getNumBitsAbs=function(){if(this.isNegative())return this.eq(M)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&0==(e&1<=0},N.isOdd=function(){return 1==(1&this.low)},N.isEven=function(){return 0==(1&this.low)},N.equals=function(e){return r(e)||(e=p(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low},N.eq=N.equals,N.notEquals=function(e){return!this.eq(e)},N.neq=N.notEquals,N.ne=N.notEquals,N.lessThan=function(e){return this.comp(e)<0},N.lt=N.lessThan,N.lessThanOrEqual=function(e){return this.comp(e)<=0},N.lte=N.lessThanOrEqual,N.le=N.lessThanOrEqual,N.greaterThan=function(e){return this.comp(e)>0},N.gt=N.greaterThan,N.greaterThanOrEqual=function(e){return this.comp(e)>=0},N.gte=N.greaterThanOrEqual,N.ge=N.greaterThanOrEqual,N.compare=function(e){if(r(e)||(e=p(e)),this.eq(e))return 0;var t=this.isNegative(),n=e.isNegative();return t&&!n?-1:!t&&n?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},N.comp=N.compare,N.negate=function(){return!this.unsigned&&this.eq(M)?M:this.not().add(b)},N.neg=N.negate,N.add=function(e){r(e)||(e=p(e));var t=this.high>>>16,n=65535&this.high,a=this.low>>>16,i=65535&this.low,s=e.high>>>16,o=65535&e.high,l=e.low>>>16,c=0,d=0,h=0,f=0;return h+=(f+=i+(65535&e.low))>>>16,d+=(h+=a+l)>>>16,c+=(d+=n+o)>>>16,c+=t+s,u((h&=65535)<<16|(f&=65535),(c&=65535)<<16|(d&=65535),this.unsigned)},N.subtract=function(e){return r(e)||(e=p(e)),this.add(e.neg())},N.sub=N.subtract,N.multiply=function(e){if(this.isZero())return g;if(r(e)||(e=p(e)),t)return u(t.mul(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned);if(e.isZero())return g;if(this.eq(M))return e.isOdd()?M:g;if(e.eq(M))return this.isOdd()?M:g;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(m)&&e.lt(m))return o(this.toNumber()*e.toNumber(),this.unsigned);var n=this.high>>>16,a=65535&this.high,i=this.low>>>16,s=65535&this.low,l=e.high>>>16,c=65535&e.high,d=e.low>>>16,h=65535&e.low,f=0,y=0,b=0,x=0;return b+=(x+=s*h)>>>16,y+=(b+=i*h)>>>16,b&=65535,y+=(b+=s*d)>>>16,f+=(y+=a*h)>>>16,y&=65535,f+=(y+=i*d)>>>16,y&=65535,f+=(y+=s*c)>>>16,f+=n*h+a*d+i*c+s*l,u((b&=65535)<<16|(x&=65535),(f&=65535)<<16|(y&=65535),this.unsigned)},N.mul=N.multiply,N.divide=function(e){if(r(e)||(e=p(e)),e.isZero())throw Error("division by zero");var n,a,i;if(t)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?u((this.unsigned?t.div_u:t.div_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?y:g;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return y;if(e.gt(this.shru(1)))return x;i=y}else{if(this.eq(M))return e.eq(b)||e.eq(v)?M:e.eq(M)?b:(n=this.shr(1).div(e).shl(1)).eq(g)?e.isNegative()?b:v:(a=this.sub(e.mul(n)),i=n.add(a.div(e)));if(e.eq(M))return this.unsigned?y:g;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=g}for(a=this;a.gte(e);){n=Math.max(1,Math.floor(a.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(n)/Math.LN2),c=s<=48?1:l(2,s-48),d=o(n),h=d.mul(e);h.isNegative()||h.gt(a);)h=(d=o(n-=c,this.unsigned)).mul(e);d.isZero()&&(d=b),i=i.add(d),a=a.sub(h)}return i},N.div=N.divide,N.modulo=function(e){return r(e)||(e=p(e)),t?u((this.unsigned?t.rem_u:t.rem_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},N.mod=N.modulo,N.rem=N.modulo,N.not=function(){return u(~this.low,~this.high,this.unsigned)},N.and=function(e){return r(e)||(e=p(e)),u(this.low&e.low,this.high&e.high,this.unsigned)},N.or=function(e){return r(e)||(e=p(e)),u(this.low|e.low,this.high|e.high,this.unsigned)},N.xor=function(e){return r(e)||(e=p(e)),u(this.low^e.low,this.high^e.high,this.unsigned)},N.shiftLeft=function(e){return r(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?u(this.low<>>32-e,this.unsigned):u(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):u(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},N.shr=N.shiftRight,N.shiftRightUnsigned=function(e){if(r(e)&&(e=e.toInt()),0==(e&=63))return this;var t=this.high;return e<32?u(this.low>>>e|t<<32-e,t>>>e,this.unsigned):u(32===e?t:t>>>e-32,0,this.unsigned)},N.shru=N.shiftRightUnsigned,N.shr_u=N.shiftRightUnsigned,N.toSigned=function(){return this.unsigned?u(this.low,this.high,!1):this},N.toUnsigned=function(){return this.unsigned?this:u(this.low,this.high,!0)},N.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},N.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},N.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},n.fromBytes=function(e,t,r){return r?n.fromBytesLE(e,t):n.fromBytesBE(e,t)},n.fromBytesLE=function(e,t){return new n(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},n.fromBytesBE=function(e,t){return new n(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)}},6377:(e,t,n)=>{var r=n(4832),a=n(8652),i=n(801),s=n(2030),o=n(3618),u=n(9049),l=n(1971);l.alea=r,l.xor128=a,l.xorwow=i,l.xorshift7=s,l.xor4096=o,l.tychei=u,e.exports=l},4832:function(e,t,n){var r;!function(e,a,i){function s(e){var t,n=this,r=(t=4022871197,function(e){e=String(e);for(var n=0;n>>0,t=(r*=t)>>>0,t+=4294967296*(r-=t)}return 2.3283064365386963e-10*(t>>>0)});n.next=function(){var e=2091639*n.s0+2.3283064365386963e-10*n.c;return n.s0=n.s1,n.s1=n.s2,n.s2=e-(n.c=0|e)},n.c=1,n.s0=r(" "),n.s1=r(" "),n.s2=r(" "),n.s0-=r(e),n.s0<0&&(n.s0+=1),n.s1-=r(e),n.s1<0&&(n.s1+=1),n.s2-=r(e),n.s2<0&&(n.s2+=1),r=null}function o(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function u(e,t){var n=new s(e),r=t&&t.state,a=n.next;return a.int32=function(){return 4294967296*n.next()|0},a.double=function(){return a()+11102230246251565e-32*(2097152*a()|0)},a.quick=a,r&&("object"==typeof r&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.alea=u}(0,e=n.nmd(e),n.amdD)},9049:function(e,t,n){var r;!function(e,a,i){function s(e){var t=this,n="";t.next=function(){var e=t.b,n=t.c,r=t.d,a=t.a;return e=e<<25^e>>>7^n,n=n-r|0,r=r<<24^r>>>8^a,a=a-e|0,t.b=e=e<<20^e>>>12^n,t.c=n=n-r|0,t.d=r<<16^n>>>16^a,t.a=a-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=0|e):n+=e;for(var r=0;r>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&("object"==typeof r&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.tychei=u}(0,e=n.nmd(e),n.amdD)},8652:function(e,t,n){var r;!function(e,a,i){function s(e){var t=this,n="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:n+=e;for(var r=0;r>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&("object"==typeof r&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xor128=u}(0,e=n.nmd(e),n.amdD)},3618:function(e,t,n){var r;!function(e,a,i){function s(e){var t=this;t.next=function(){var e,n,r=t.w,a=t.X,i=t.i;return t.w=r=r+1640531527|0,n=a[i+34&127],e=a[i=i+1&127],n^=n<<13,e^=e<<17,n^=n>>>15,e^=e>>>12,n=a[i]=n^e,t.i=i,n+(r^r>>>16)|0},function(e,t){var n,r,a,i,s,o=[],u=128;for(t===(0|t)?(r=t,t=null):(t+="\0",r=0,u=Math.max(u,t.length)),a=0,i=-32;i>>15,r^=r<<4,r^=r>>>13,i>=0&&(s=s+1640531527|0,a=0==(n=o[127&i]^=r+s)?a+1:0);for(a>=128&&(o[127&(t&&t.length||0)]=-1),a=127,i=512;i>0;--i)r=o[a+34&127],n=o[a=a+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,o[a]=r^n;e.w=s,e.X=o,e.i=a}(t,e)}function o(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function u(e,t){null==e&&(e=+new Date);var n=new s(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&(r.X&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xor4096=u}(0,e=n.nmd(e),n.amdD)},2030:function(e,t,n){var r;!function(e,a,i){function s(e){var t=this;t.next=function(){var e,n,r=t.x,a=t.i;return e=r[a],n=(e^=e>>>7)^e<<24,n^=(e=r[a+1&7])^e>>>10,n^=(e=r[a+3&7])^e>>>3,n^=(e=r[a+4&7])^e<<7,e=r[a+7&7],n^=(e^=e<<13)^e<<9,r[a]=n,t.i=a+1&7,n},function(e,t){var n,r=[];if(t===(0|t))r[0]=t;else for(t=""+t,n=0;n0;--n)e.next()}(t,e)}function o(e,t){return t.x=e.x.slice(),t.i=e.i,t}function u(e,t){null==e&&(e=+new Date);var n=new s(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&(r.x&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xorshift7=u}(0,e=n.nmd(e),n.amdD)},801:function(e,t,n){var r;!function(e,a,i){function s(e){var t=this,n="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:n+=e;for(var r=0;r>>4),t.next()}function o(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function u(e,t){var n=new s(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&("object"==typeof r&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xorwow=u}(0,e=n.nmd(e),n.amdD)},1971:function(e,t,n){var r;!function(a,i,s){var o,u=256,l=s.pow(u,6),c=s.pow(2,52),p=2*c,d=255;function h(e,t,n){var r=[],d=y(g((t=1==t?{entropy:!0}:t||{}).entropy?[e,b(i)]:null==e?function(){try{var e;return o&&(e=o.randomBytes)?e=e(u):(e=new Uint8Array(u),(a.crypto||a.msCrypto).getRandomValues(e)),b(e)}catch(e){var t=a.navigator,n=t&&t.plugins;return[+new Date,a,n,a.screen,b(i)]}}():e,3),r),h=new f(r),x=function(){for(var e=h.g(6),t=l,n=0;e=p;)e/=2,t/=2,n>>>=1;return(e+n)/t};return x.int32=function(){return 0|h.g(4)},x.quick=function(){return h.g(4)/4294967296},x.double=x,y(b(h.S),i),(t.pass||n||function(e,t,n,r){return r&&(r.S&&m(r,h),e.state=function(){return m(h,{})}),n?(s.random=e,t):e})(x,d,"global"in t?t.global:this==s,t.state)}function f(e){var t,n=e.length,r=this,a=0,i=r.i=r.j=0,s=r.S=[];for(n||(e=[n++]);a{function t(){}t.prototype={on:function(e,t,n){var r=this.e||(this.e={});return(r[e]||(r[e]=[])).push({fn:t,ctx:n}),this},once:function(e,t,n){var r=this;function a(){r.off(e,a),t.apply(n,arguments)}return a._=t,this.on(e,a,n)},emit:function(e){for(var t=[].slice.call(arguments,1),n=((this.e||(this.e={}))[e]||[]).slice(),r=0,a=n.length;r3?e.slice(3):"any":e).split("|").map(L).filter($).filter(A),a=function(e,t){var n={};return e.forEach((function(e){-1!==t.indexOf(e.from)||-1===t.indexOf(e.to)||n[e.from]||(n[e.from]=e)})),Object.keys(n).map((function(e){return n[e]}))}(t,r),i=r.map((function(e){var t=l(e);return{name:e,typeIndex:c(t),test:t.test,conversion:null,conversionIndex:-1}})),s=a.map((function(e){var n=l(e.from);return{name:e.from,typeIndex:c(n),test:n.test,conversion:e,conversionIndex:t.indexOf(e)}}));return{types:i.concat(s),restParam:n}}function f(e){var t=F(e);return!!t&&t.restParam}function m(e){return e.types.some((function(e){return null!=e.conversion}))}function g(t){if(t&&0!==t.types.length){if(1===t.types.length)return l(t.types[0].name).test;if(2===t.types.length){var n=l(t.types[0].name).test,r=l(t.types[1].name).test;return function(e){return n(e)||r(e)}}var a=t.types.map((function(e){return l(e.name).test}));return function(e){for(var t=0;t=i+1}}return 0===e.length?function(e){return 0===e.length}:1===e.length?(n=g(e[0]),function(e){return n(e[0])&&1===e.length}):2===e.length?(n=g(e[0]),r=g(e[1]),function(e){return n(e[0])&&r(e[1])&&2===e.length}):(t=e.map(g),function(e){for(var n=0;n0){var l=p(t[i]);return(r=new TypeError("Unexpected type of argument in function "+s+" (expected: "+a.join(" or ")+", actual: "+l+", index: "+i+")")).data={category:"wrongType",fn:s,index:i,actual:l,expected:a},r}}else o=u}var c=o.map((function(e){return f(e.params)?1/0:e.params.length}));if(t.lengthd?((r=new TypeError("Too many arguments in function "+s+" (expected: "+d+", actual: "+t.length+")")).data={category:"tooManyArgs",fn:s,index:t.length,expectedLength:d},r):((r=new TypeError('Arguments of type "'+t.join(", ")+'" do not match any of the defined signatures of function '+s+".")).data={category:"mismatch",actual:t.map(p)},r)}function N(e){for(var t=999,n=0;n=a:o?a>=i:a===i}(t,e)}));if(t)throw new TypeError('Conflicting signatures "'+d(t.params)+'" and "'+d(e.params)+'".');a.push(e)}));var i=P(a,(function(e){return(e?I(e.params,!1):[]).map((function(t){return{params:t,fn:e.fn}}))})).filter(O);i.sort(D);var s=i[0]&&i[0].params.length<=2&&!f(i[0].params),o=i[1]&&i[1].params.length<=2&&!f(i[1].params),l=i[2]&&i[2].params.length<=2&&!f(i[2].params),c=i[3]&&i[3].params.length<=2&&!f(i[3].params),p=i[4]&&i[4].params.length<=2&&!f(i[4].params),b=i[5]&&i[5].params.length<=2&&!f(i[5].params),v=s&&o&&l&&c&&p&&b,_=i.map((function(e){return y(e.params)})),w=s?g(i[0].params[0]):t,M=o?g(i[1].params[0]):t,N=l?g(i[2].params[0]):t,S=c?g(i[3].params[0]):t,k=p?g(i[4].params[0]):t,E=b?g(i[5].params[0]):t,C=s?g(i[0].params[1]):t,A=o?g(i[1].params[1]):t,$=l?g(i[2].params[1]):t,F=c?g(i[3].params[1]):t,H=p?g(i[4].params[1]):t,j=b?g(i[5].params[1]):t,U=i.map((function(e){return function(e,t){var n=t;if(e.some(m)){var r=f(e),a=e.map(T);n=function(){for(var e=[],n=r?arguments.length-1:arguments.length,i=0;i{},8628:()=>{},1601:()=>{},7792:()=>{},4977:()=>{},5042:()=>{}},t={};function n(r){var a=t[r];if(void 0!==a)return a.exports;var i=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}n.amdD=function(){throw new Error("define cannot be used indirect")},n.amdO={},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var r={};(()=>{"use strict";n.r(r),n.d(r,{Tensor:()=>qie,Turtle:()=>Rie,abs:()=>Zie,acos:()=>dse,add:()=>Vie,asin:()=>hse,atan:()=>fse,atan2:()=>mse,average:()=>Qse,ceil:()=>Qie,compile:()=>Yie,complex:()=>xse,concat:()=>Ase,constrain:()=>ese,copy:()=>vse,cos:()=>gse,derivative:()=>zie,dispose:()=>qse,div:()=>Jie,dot:()=>Xie,endScope:()=>jse,evaluate:()=>Bie,exp:()=>tse,eye:()=>_se,fft:()=>zse,fill:()=>wse,flatten:()=>Ise,floor:()=>nse,fromImage:()=>Vse,getBackend:()=>que,keep:()=>Use,linspace:()=>Mse,log:()=>rse,math:()=>G,max:()=>ase,mean:()=>Zse,memory:()=>Bse,min:()=>ise,mod:()=>sse,mult:()=>Kie,ones:()=>Nse,pad:()=>Ese,parse:()=>Pie,percentile:()=>Jse,pow:()=>ose,ptp:()=>Kse,quantile:()=>Xse,random:()=>Sse,randomGaussian:()=>kse,range:()=>Dse,reshape:()=>Cse,reverse:()=>Lse,round:()=>use,scope:()=>Pse,sd:()=>eoe,setBackend:()=>Uue,simplify:()=>Hie,sin:()=>yse,slice:()=>$se,sort:()=>Yse,split:()=>Ose,sq:()=>lse,sqrt:()=>cse,stack:()=>Rse,startScope:()=>Hse,sub:()=>Gie,sum:()=>pse,tan:()=>bse,tf:()=>W,toDateTime:()=>jue,toImage:()=>Gse,unstack:()=>Fse,variance:()=>toe,zeros:()=>Tse});var e={};n.r(e),n.d(e,{arraysEqual:()=>de,assert:()=>se,assertNonNegativeIntegerDimensions:()=>He,assertNonNull:()=>ue,assertShapesMatch:()=>oe,bytesFromStringArray:()=>Ie,bytesPerElement:()=>Te,checkConversionForErrors:()=>Ne,clamp:()=>ee,computeStrides:()=>Re,createScalarValue:()=>Fa,createShuffledIndices:()=>ge,decodeString:()=>Ha,distSquared:()=>ie,encodeString:()=>Pa,fetch:()=>Ba,fingerPrint64:()=>Ra,flatten:()=>le,getArrayFromDType:()=>Me,getTypedArrayFromDType:()=>we,hasEncodingLoss:()=>ke,hexToLong:()=>Sa,indexToLoc:()=>Ue,inferDtype:()=>Le,inferFromImplicitShape:()=>xe,isBoolean:()=>Ce,isFunction:()=>$e,isInt:()=>he,isNumber:()=>Ae,isPromise:()=>qe,isScalarShape:()=>pe,isString:()=>Ee,isTypedArray:()=>De,isValidDtype:()=>Se,locToIndex:()=>je,makeOnesTypedArray:()=>ze,makeZerosNestedTypedArray:()=>Pe,makeZerosTypedArray:()=>Be,nearestDivisor:()=>Oe,nearestLargerEven:()=>te,now:()=>za,parseAxisParam:()=>ve,randUniform:()=>ae,repeatedTry:()=>be,rightPad:()=>ye,shuffle:()=>Z,shuffleCombo:()=>Q,sizeFromShape:()=>ce,sizeToSquarishShape:()=>me,squeezeShape:()=>_e,sum:()=>re,swap:()=>ne,tanh:()=>fe,toNestedArray:()=>Ye,toTypedArray:()=>Ya});var t={};n.r(t),n.d(t,{assertTypesMatch:()=>hi,getTensorsInContainer:()=>mi,isTensorInList:()=>fi,makeTypesMatch:()=>di});var a={};n.r(a),n.d(a,{isBrowser:()=>ki,isMobile:()=>Si,mockIsMobile:()=>Ni});var i={};n.r(i),n.d(i,{browserFiles:()=>zs,browserHTTPRequest:()=>Gs,concatenateArrayBuffers:()=>Ui,copyModel:()=>Ts,decodeWeights:()=>Bi,encodeWeights:()=>zi,fromMemory:()=>Zs,fromMemorySync:()=>Qs,getLoadHandlers:()=>es,getModelArtifactsForJSON:()=>Vi,getModelArtifactsInfoForJSON:()=>Gi,getSaveHandlers:()=>Qi,http:()=>Vs,isHTTPScheme:()=>qs,listModels:()=>ks,loadWeights:()=>Hs,moveModel:()=>Is,registerLoadRouter:()=>Zi,registerSaveRouter:()=>Xi,removeModel:()=>Ds,weightsLoaderFactory:()=>js,withSaveHandler:()=>eo,withSaveHandlerSync:()=>to});var s={};n.r(s),n.d(s,{confusionMatrix:()=>Eo});var o={};n.r(o),n.d(o,{assertAndGetBroadcastShape:()=>Lo,getBroadcastDims:()=>Co,getReductionAxes:()=>Ao});var u={};n.r(u),n.d(u,{fromPixels:()=>zo,fromPixelsAsync:()=>Fo,toPixels:()=>Yo});var l={};n.r(l),n.d(l,{prepareAndValidate:()=>Bo});var c={};n.r(c),n.d(c,{calculateShapes:()=>jo,validateInput:()=>Ho,validateUpdateShape:()=>Po});var p={};n.r(p),n.d(p,{assertParamsValid:()=>Uo,computeFlatOffset:()=>ru,computeOutShape:()=>Wo,getNormalizedAxes:()=>Jo,isSliceContinous:()=>nu,maskToAxes:()=>qo,parseSliceParams:()=>au,sliceInfo:()=>iu,startForAxis:()=>eu,startIndicesWithElidedDims:()=>Xo,stopForAxis:()=>tu,stopIndicesWithElidedDims:()=>Zo,stridesForAxis:()=>Qo,stridesWithElidedDims:()=>Vo});var d={};n.r(d),n.d(d,{Serializable:()=>ou,SerializationMap:()=>uu,registerClass:()=>lu});var h={};n.r(h),n.d(h,{TEST_EPSILON_FLOAT16:()=>cu,encodeStrings:()=>vu,expectArrayBuffersEqual:()=>xu,expectArraysClose:()=>pu,expectArraysEqual:()=>mu,expectNumbersClose:()=>gu,expectPromiseToFail:()=>fu,expectValuesInRange:()=>bu,testEpsilon:()=>du});var f={};n.r(f),n.d(f,{conv2d:()=>qd,depthwiseConv2d:()=>Gd,matMul:()=>Kd});var m={};n.r(m),n.d(m,{collectGatherOpShapeInfo:()=>Vf,computeOutShape:()=>Wf,segOpComputeOptimalWindowSize:()=>qf});var g={};n.r(g),n.d(g,{ERF_A1:()=>df,ERF_A2:()=>hf,ERF_A3:()=>ff,ERF_A4:()=>mf,ERF_A5:()=>gf,ERF_P:()=>pf,PARALLELIZE_THRESHOLD:()=>ef,SELU_SCALE:()=>cf,SELU_SCALEALPHA:()=>lf,applyActivation:()=>jd,assertAndGetBroadcastShape:()=>Lo,assertAxesAreInnerMostDims:()=>bc,assertParamsConsistent:()=>Zh,assignToTypedArray:()=>wf,axesAreInnerMostDims:()=>fc,calculateShapes:()=>jo,checkEinsumDimSizes:()=>Tf,checkPadOnDimRoundingMode:()=>wl,combineLocations:()=>mc,complexWithEvenIndex:()=>xf,complexWithOddIndex:()=>vf,computeConv2DInfo:()=>dl,computeConv3DInfo:()=>hl,computeDefaultPad:()=>fl,computeDilation2DInfo:()=>ll,computeOptimalWindowSize:()=>tf,computeOutAndReduceShapes:()=>gc,computeOutShape:()=>Qh,computePool2DInfo:()=>cl,computePool3DInfo:()=>pl,convertConv2DDataFormat:()=>_l,decodeEinsumEquation:()=>kf,eitherStridesOrDilationsAreOne:()=>vl,expandShapeToKeepDim:()=>yc,exponent:()=>Nf,exponents:()=>Mf,fromStringArrayToUint8:()=>Kf,fromUint8ToStringArray:()=>Gf,getAxesPermutation:()=>xc,getBroadcastDims:()=>Co,getComplexWithIndex:()=>_f,getEinsumComputePath:()=>If,getEinsumPermutation:()=>Df,getFusedBiasGradient:()=>Hd,getFusedDyActivation:()=>Pd,getImageCenter:()=>nf,getInnerMostAxes:()=>_c,getPermuted:()=>af,getReductionAxes:()=>Ao,getReshaped:()=>rf,getReshapedPermuted:()=>sf,getSliceBeginCoords:()=>of,getSliceSize:()=>uf,getSparseFillEmptyRowsIndicesDenseShapeMismatch:()=>Lf,getSparseFillEmptyRowsNegativeIndexErrorMessage:()=>$f,getSparseFillEmptyRowsOutOfRangeIndexErrorMessage:()=>Of,getSparseReshapeEmptyTensorZeroOutputDimErrorMessage:()=>Yf,getSparseReshapeInputOutputMismatchErrorMessage:()=>Bf,getSparseReshapeInputOutputMultipleErrorMessage:()=>zf,getSparseReshapeMultipleNegativeOneOutputDimErrorMessage:()=>Rf,getSparseReshapeNegativeOutputDimErrorMessage:()=>Ff,getSparseSegmentReductionIndicesOutOfRangeErrorMessage:()=>Uf,getSparseSegmentReductionNegativeSegmentIdsErrorMessage:()=>Pf,getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage:()=>Hf,getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage:()=>jf,getUndoAxesPermutation:()=>vc,isIdentityPermutation:()=>Ef,log:()=>pa,mergeRealAndImagArrays:()=>yf,prepareAndValidate:()=>Bo,prepareSplitSize:()=>Af,segment_util:()=>m,shouldFuse:()=>Ud,slice_util:()=>p,splitRealAndImagArrays:()=>bf,tupleValuesAreOne:()=>xl,upcastType:()=>ci,validateInput:()=>Ho,validateUpdateShape:()=>Po,warn:()=>ca});var y={};n.r(y),n.d(y,{nonMaxSuppressionV3Impl:()=>uh,nonMaxSuppressionV4Impl:()=>lh,nonMaxSuppressionV5Impl:()=>ch,whereImpl:()=>Id});var b={};n.r(b),n.d(b,{maxNorm:()=>$b,minMaxNorm:()=>Fb,nonNeg:()=>Rb,unitNorm:()=>Ob});var x={};n.r(x),n.d(x,{constant:()=>Bb,glorotNormal:()=>Vb,glorotUniform:()=>Wb,heNormal:()=>Gb,heUniform:()=>Kb,identity:()=>Ub,leCunNormal:()=>Jb,leCunUniform:()=>Xb,ones:()=>zb,orthogonal:()=>Zb,randomNormal:()=>Hb,randomUniform:()=>Pb,truncatedNormal:()=>jb,varianceScaling:()=>qb,zeros:()=>Yb});var v={};n.r(v),n.d(v,{Layer:()=>hb,RNN:()=>c_,RNNCell:()=>p_,activation:()=>Cw,add:()=>Bw,alphaDropout:()=>EM,average:()=>Pw,averagePooling1d:()=>Jw,averagePooling2d:()=>Qw,averagePooling3d:()=>nM,avgPool1d:()=>Xw,avgPool2d:()=>eM,avgPool3d:()=>rM,avgPooling1d:()=>Zw,avgPooling2d:()=>tM,avgPooling3d:()=>aM,batchNormalization:()=>Vw,bidirectional:()=>wM,concatenate:()=>Hw,conv1d:()=>ww,conv2d:()=>Mw,conv2dTranspose:()=>Nw,conv3d:()=>Sw,conv3dTranspose:()=>kw,convLstm2d:()=>bM,convLstm2dCell:()=>xM,cropping2D:()=>Tw,dense:()=>Aw,depthwiseConv2d:()=>Ew,dot:()=>Ww,dropout:()=>Lw,elu:()=>gw,embedding:()=>zw,flatten:()=>Ow,gaussianDropout:()=>IM,gaussianNoise:()=>TM,globalAveragePooling1d:()=>iM,globalAveragePooling2d:()=>sM,globalMaxPool1d:()=>NM,globalMaxPool2d:()=>SM,globalMaxPooling1d:()=>oM,globalMaxPooling2d:()=>uM,gru:()=>dM,gruCell:()=>hM,input:()=>pv,inputLayer:()=>mw,layerNormalization:()=>Gw,leakyReLU:()=>bw,lstm:()=>fM,lstmCell:()=>mM,masking:()=>CM,maxPool1d:()=>kM,maxPool2d:()=>DM,maxPooling1d:()=>lM,maxPooling2d:()=>cM,maxPooling3d:()=>pM,maximum:()=>jw,minimum:()=>Uw,multiply:()=>qw,permute:()=>Yw,prelu:()=>xw,reLU:()=>yw,repeatVector:()=>Rw,reshape:()=>Fw,rnn:()=>vM,separableConv2d:()=>Dw,simpleRNN:()=>gM,simpleRNNCell:()=>yM,softmax:()=>vw,spatialDropout1d:()=>$w,stackedRNNCells:()=>_M,thresholdedReLU:()=>_w,timeDistributed:()=>MM,upSampling2d:()=>Iw,zeroPadding2d:()=>Kw});var _={};n.r(_),n.d(_,{MAPE:()=>HM,MSE:()=>qM,binaryAccuracy:()=>AM,binaryCrossentropy:()=>LM,categoricalAccuracy:()=>OM,categoricalCrossentropy:()=>RM,cosineProximity:()=>zM,mape:()=>jM,meanAbsoluteError:()=>BM,meanAbsolutePercentageError:()=>PM,meanSquaredError:()=>UM,mse:()=>WM,precision:()=>FM,recall:()=>YM,sparseCategoricalAccuracy:()=>$M});var w={};n.r(w),n.d(w,{modelFromJSON:()=>sv});var M={};n.r(M),n.d(M,{l1:()=>GM,l1l2:()=>VM,l2:()=>KM});var N={};n.r(N),n.d(N,{json:()=>fN});var S={};n.r(S),n.d(S,{json:()=>mN});var k={};n.r(k),n.d(k,{json:()=>gN});var D={};n.r(D),n.d(D,{json:()=>yN});var T={};n.r(T),n.d(T,{json:()=>bN});var I={};n.r(I),n.d(I,{json:()=>xN});var E={};n.r(E),n.d(E,{json:()=>vN});var C={};n.r(C),n.d(C,{json:()=>_N});var A={};n.r(A),n.d(A,{json:()=>wN});var L={};n.r(L),n.d(L,{json:()=>MN});var $={};n.r($),n.d($,{json:()=>NN});var O={};n.r(O),n.d(O,{json:()=>SN});var R={};n.r(R),n.d(R,{json:()=>kN});var F={};n.r(F),n.d(F,{json:()=>DN});var Y={};n.r(Y),n.d(Y,{json:()=>TN});var z={};n.r(z),n.d(z,{json:()=>IN});var B={};n.r(B),n.d(B,{json:()=>EN});var P={};n.r(P),n.d(P,{json:()=>CN});var H={};n.r(H),n.d(H,{json:()=>AN});var j={};n.r(j),n.d(j,{OP_SCOPE_SUFFIX:()=>Li,abs:()=>Uu,acos:()=>Xu,acosh:()=>Zu,add:()=>wu,addN:()=>Qu,all:()=>el,any:()=>tl,argMax:()=>nl,argMin:()=>rl,asin:()=>al,asinh:()=>il,atan:()=>sl,atan2:()=>ol,atanh:()=>ul,avgPool:()=>Nl,avgPool3d:()=>Sl,basicLSTMCell:()=>El,batchNorm:()=>Al,batchNorm2d:()=>Ll,batchNorm3d:()=>$l,batchNorm4d:()=>Ol,batchToSpaceND:()=>Cl,bincount:()=>Rl,booleanMaskAsync:()=>Cd,broadcastArgs:()=>Fl,broadcastTo:()=>Yl,buffer:()=>As,cast:()=>Ls,ceil:()=>zl,clipByValue:()=>Bl,clone:()=>$s,complex:()=>Oi,concat:()=>kl,concat1d:()=>Pl,concat2d:()=>Hl,concat3d:()=>jl,concat4d:()=>Ul,conv1d:()=>Wl,conv2d:()=>ql,conv2dTranspose:()=>Gl,conv3d:()=>Kl,conv3dTranspose:()=>Xl,cos:()=>Zl,cosh:()=>Ql,cosineWindow:()=>Yd,cumprod:()=>ec,cumsum:()=>tc,denseBincount:()=>nc,depthToSpace:()=>rc,depthwiseConv2d:()=>ac,diag:()=>ic,dilation2d:()=>sc,div:()=>Nu,divNoNan:()=>lc,dot:()=>cc,dropout:()=>Rd,einsum:()=>pc,elu:()=>dc,enclosingPowerOfTwo:()=>Fd,equal:()=>oc,erf:()=>hc,euclideanNorm:()=>Dc,exp:()=>Tc,expandDims:()=>Ic,expm1:()=>Ec,eye:()=>Ac,fft:()=>sd,fill:()=>zu,floor:()=>Lc,floorDiv:()=>Mu,fused:()=>f,gather:()=>$c,gatherND:()=>Od,greater:()=>Oc,greaterEqual:()=>Rc,ifft:()=>od,imag:()=>ko,image:()=>Uh,inTopKAsync:()=>zd,irfft:()=>ud,isFinite:()=>Fc,isInf:()=>Yc,isNaN:()=>zc,leakyRelu:()=>Bc,less:()=>Pc,lessEqual:()=>Hc,linalg:()=>qh,linspace:()=>jc,localResponseNormalization:()=>Uc,log:()=>qc,log1p:()=>Wc,logSigmoid:()=>Gc,logSoftmax:()=>Kc,logSumExp:()=>Jc,logicalAnd:()=>Xc,logicalNot:()=>Zc,logicalOr:()=>Qc,logicalXor:()=>ep,losses:()=>Wh,lowerBound:()=>rp,matMul:()=>no,max:()=>wc,maxPool:()=>ap,maxPool3d:()=>ip,maxPoolWithArgmax:()=>sp,maximum:()=>qu,mean:()=>op,meshgrid:()=>cp,min:()=>Mc,minimum:()=>pp,mirrorPad:()=>dp,mod:()=>hp,moments:()=>fp,movingAverage:()=>Ad,mul:()=>Su,multiRNNCell:()=>mp,multinomial:()=>gp,neg:()=>Do,norm:()=>kc,notEqual:()=>yp,oneHot:()=>ro,ones:()=>lp,onesLike:()=>bp,op:()=>$i,outerProduct:()=>xp,pad:()=>vp,pad1d:()=>_p,pad2d:()=>wp,pad3d:()=>Mp,pad4d:()=>Np,pool:()=>kp,pow:()=>Pu,prelu:()=>Dp,print:()=>Os,prod:()=>Tp,rand:()=>Ip,randomGamma:()=>$p,randomNormal:()=>Op,randomStandardNormal:()=>Rp,randomUniform:()=>Fp,range:()=>Yp,real:()=>To,reciprocal:()=>zp,relu:()=>Bp,relu6:()=>Pp,reshape:()=>Ml,reverse:()=>Hp,reverse1d:()=>jp,reverse2d:()=>Up,reverse3d:()=>qp,reverse4d:()=>Wp,rfft:()=>cd,round:()=>Vp,rsqrt:()=>Gp,scalar:()=>Ru,scatterND:()=>Ld,searchSorted:()=>np,selu:()=>Kp,separableConv2d:()=>Jp,setdiff1dAsync:()=>Xp,sigmoid:()=>Dl,sign:()=>Zp,signal:()=>jh,sin:()=>Qp,sinh:()=>ed,slice:()=>Tl,slice1d:()=>td,slice2d:()=>nd,slice3d:()=>rd,slice4d:()=>ad,softmax:()=>id,softplus:()=>Vc,spaceToBatchND:()=>Sp,sparse:()=>Vh,sparseToDense:()=>$d,spectral:()=>Hh,split:()=>ld,sqrt:()=>ku,square:()=>Du,squaredDifference:()=>pd,squeeze:()=>dd,stack:()=>hd,step:()=>fd,stridedSlice:()=>md,string:()=>Gh,sub:()=>Hu,sum:()=>Nc,tan:()=>gd,tanh:()=>Il,tensor:()=>Fi,tensor1d:()=>yd,tensor2d:()=>bd,tensor3d:()=>$o,tensor4d:()=>xd,tensor5d:()=>vd,tensor6d:()=>_d,tile:()=>Cc,topk:()=>wd,transpose:()=>Io,truncatedNormal:()=>Md,unique:()=>Nd,unsortedSegmentSum:()=>Sd,unstack:()=>kd,upperBound:()=>Dd,variable:()=>Td,where:()=>uc,whereAsync:()=>Ed,zeros:()=>up,zerosLike:()=>Tu});var U={};n.r(U),n.d(U,{CSVDataset:()=>sk,Dataset:()=>GS,FileDataSource:()=>bk,TextLineDataset:()=>QS,URLDataSource:()=>xk,array:()=>JS,csv:()=>vk,func:()=>_k,generator:()=>wk,microphone:()=>Nk,version_data:()=>Sk,webcam:()=>Mk,zip:()=>XS});var q={};n.r(q),n.d(q,{addImpl:()=>iD,bincountImpl:()=>XD,bincountReduceImpl:()=>ZD,ceilImpl:()=>tT,concatImpl:()=>oT,equalImpl:()=>UT,expImpl:()=>tI,expm1Impl:()=>sI,floorImpl:()=>MI,gatherNdImpl:()=>CI,gatherV2Impl:()=>LI,greaterEqualImpl:()=>YI,greaterImpl:()=>OI,lessEqualImpl:()=>XI,lessImpl:()=>GI,linSpaceImpl:()=>eE,logImpl:()=>nE,maxImpl:()=>yE,maximumImpl:()=>vE,minimumImpl:()=>EE,multiplyImpl:()=>RT,negImpl:()=>BE,notEqualImpl:()=>GE,prodImpl:()=>oC,rangeImpl:()=>lC,rsqrtImpl:()=>_C,scatterImpl:()=>NC,sigmoidImpl:()=>Wk,simpleAbsImpl:()=>fD,sliceImpl:()=>VD,sparseFillEmptyRowsImpl:()=>UC,sparseReshapeImpl:()=>WC,sparseSegmentReductionImpl:()=>GC,sqrtImpl:()=>QC,squaredDifferenceImpl:()=>rA,stridedSliceImpl:()=>uA,stringNGramsImpl:()=>pA,stringSplitImpl:()=>fA,stringToHashBucketFastImpl:()=>gA,subImpl:()=>dI,tileImpl:()=>_A,topKImpl:()=>SA,transposeImpl:()=>_D,uniqueImpl:()=>AA});var W={};n.r(W),n.d(W,{Abs:()=>Qe,Acos:()=>et,Acosh:()=>tt,AdadeltaOptimizer:()=>Yu,AdagradOptimizer:()=>Bu,AdamOptimizer:()=>ju,AdamaxOptimizer:()=>Wu,Add:()=>nt,AddN:()=>rt,All:()=>at,Any:()=>it,ArgMax:()=>st,ArgMin:()=>ot,Asin:()=>ut,Asinh:()=>lt,Atan:()=>ct,Atan2:()=>dt,Atanh:()=>pt,AvgPool:()=>ht,AvgPool3D:()=>mt,AvgPool3DGrad:()=>gt,AvgPoolGrad:()=>ft,BatchMatMul:()=>yt,BatchToSpaceND:()=>bt,Bincount:()=>xt,BroadcastArgs:()=>_t,BroadcastTo:()=>vt,Callback:()=>JM,CallbackList:()=>rx,Cast:()=>wt,Ceil:()=>Mt,ClipByValue:()=>Nt,Complex:()=>St,ComplexAbs:()=>kt,Concat:()=>Dt,Conv2D:()=>Tt,Conv2DBackpropFilter:()=>It,Conv2DBackpropInput:()=>Et,Conv3D:()=>Ct,Conv3DBackpropFilterV2:()=>At,Conv3DBackpropInputV2:()=>Lt,Cos:()=>$t,Cosh:()=>Ot,CropAndResize:()=>Yt,Cumprod:()=>Rt,Cumsum:()=>Ft,CustomCallback:()=>sx,DataStorage:()=>K,DenseBincount:()=>zt,DepthToSpace:()=>Bt,DepthwiseConv2dNative:()=>Pt,DepthwiseConv2dNativeBackpropFilter:()=>Ht,DepthwiseConv2dNativeBackpropInput:()=>jt,Diag:()=>Ut,Dilation2D:()=>qt,Dilation2DBackpropFilter:()=>Vt,Dilation2DBackpropInput:()=>Wt,ENV:()=>Je,EarlyStopping:()=>QM,Einsum:()=>Kt,Elu:()=>Jt,EluGrad:()=>Xt,Environment:()=>We,Equal:()=>Qt,Erf:()=>Zt,Exp:()=>en,ExpandDims:()=>tn,Expm1:()=>nn,FFT:()=>rn,Fill:()=>an,FlipLeftRight:()=>sn,Floor:()=>on,FloorDiv:()=>un,FromPixels:()=>ia,FusedBatchNorm:()=>ln,FusedConv2D:()=>ua,FusedDepthwiseConv2D:()=>la,GatherNd:()=>pn,GatherV2:()=>cn,GraphModel:()=>mS,Greater:()=>dn,GreaterEqual:()=>hn,History:()=>ix,IFFT:()=>mn,Identity:()=>fn,Imag:()=>gn,InputSpec:()=>ub,IsFinite:()=>yn,IsInf:()=>bn,IsNan:()=>xn,KernelBackend:()=>J,LRN:()=>An,LRNGrad:()=>Ln,LayerVariable:()=>ib,LayersModel:()=>av,LeakyRelu:()=>vn,Less:()=>_n,LessEqual:()=>wn,LinSpace:()=>Mn,Log:()=>Nn,Log1p:()=>Sn,LogSoftmax:()=>En,LogicalAnd:()=>kn,LogicalNot:()=>Dn,LogicalOr:()=>Tn,LogicalXor:()=>In,LowerBound:()=>Cn,Max:()=>$n,MaxPool:()=>Rn,MaxPool3D:()=>Yn,MaxPool3DGrad:()=>zn,MaxPoolGrad:()=>Fn,MaxPoolWithArgmax:()=>Bn,Maximum:()=>On,Mean:()=>Pn,Min:()=>Hn,Minimum:()=>jn,MirrorPad:()=>Un,Mod:()=>qn,MomentumOptimizer:()=>Gu,Multinomial:()=>Wn,Multiply:()=>Vn,Neg:()=>Gn,NonMaxSuppressionV3:()=>Jn,NonMaxSuppressionV4:()=>Xn,NonMaxSuppressionV5:()=>Zn,NotEqual:()=>Kn,OP_SCOPE_SUFFIX:()=>Li,OneHot:()=>er,OnesLike:()=>Qn,Optimizer:()=>Fu,OptimizerConstructors:()=>Ju,Pack:()=>tr,PadV2:()=>nr,Pool:()=>rr,Pow:()=>ar,Prelu:()=>ir,Prod:()=>sr,RMSPropOptimizer:()=>Ku,RNN:()=>c_,Range:()=>or,Rank:()=>ai,Real:()=>ur,RealDiv:()=>Gt,Reciprocal:()=>lr,Reduction:()=>Sh,Relu:()=>cr,Relu6:()=>gr,Reshape:()=>pr,ResizeBilinear:()=>fr,ResizeBilinearGrad:()=>mr,ResizeNearestNeighbor:()=>dr,ResizeNearestNeighborGrad:()=>hr,Reverse:()=>yr,RotateWithOffset:()=>sa,Round:()=>br,Rsqrt:()=>xr,SGDOptimizer:()=>Vu,ScatterNd:()=>vr,SearchSorted:()=>_r,Select:()=>wr,Selu:()=>Mr,Sequential:()=>ov,Sigmoid:()=>Tr,Sign:()=>Dr,Sin:()=>Sr,Sinh:()=>kr,Slice:()=>Nr,Softmax:()=>$r,Softplus:()=>Ir,SpaceToBatchND:()=>Ar,SparseFillEmptyRows:()=>Or,SparseReshape:()=>Rr,SparseSegmentMean:()=>Fr,SparseSegmentSum:()=>Yr,SparseToDense:()=>zr,SplitV:()=>Lr,Sqrt:()=>Er,Square:()=>Pr,SquaredDifference:()=>Br,Step:()=>aa,StridedSlice:()=>Hr,StringNGrams:()=>jr,StringSplit:()=>Ur,StringToHashBucketFast:()=>qr,Sub:()=>Wr,Sum:()=>Cr,SymbolicTensor:()=>lb,Tan:()=>Vr,Tanh:()=>Gr,Tensor:()=>ti,TensorBuffer:()=>Xa,Tile:()=>Kr,TopK:()=>Jr,Transform:()=>Xr,Transpose:()=>Zr,Unique:()=>Qr,Unpack:()=>ea,UnsortedSegmentSum:()=>ta,UpperBound:()=>na,Variable:()=>ri,ZerosLike:()=>ra,_FusedMatMul:()=>oa,abs:()=>Uu,acos:()=>Xu,acosh:()=>Zu,add:()=>wu,addN:()=>Qu,all:()=>el,any:()=>tl,argMax:()=>nl,argMin:()=>rl,asin:()=>al,asinh:()=>il,atan:()=>sl,atan2:()=>ol,atanh:()=>ul,avgPool:()=>Nl,avgPool3d:()=>Sl,backend:()=>No,backend_util:()=>g,basicLSTMCell:()=>El,batchNorm:()=>Al,batchNorm2d:()=>Ll,batchNorm3d:()=>$l,batchNorm4d:()=>Ol,batchToSpaceND:()=>Cl,bincount:()=>Rl,booleanMaskAsync:()=>Cd,broadcastArgs:()=>Fl,broadcastTo:()=>Yl,broadcast_util:()=>o,browser:()=>u,buffer:()=>As,callbacks:()=>eN,cast:()=>Ls,ceil:()=>zl,clipByValue:()=>Bl,clone:()=>$s,complex:()=>Oi,concat:()=>kl,concat1d:()=>Pl,concat2d:()=>Hl,concat3d:()=>jl,concat4d:()=>Ul,constraints:()=>b,conv1d:()=>Wl,conv2d:()=>ql,conv2dTranspose:()=>Gl,conv3d:()=>Kl,conv3dTranspose:()=>Xl,copyRegisteredKernels:()=>_a,cos:()=>Zl,cosh:()=>Ql,cosineWindow:()=>Yd,cumprod:()=>ec,cumsum:()=>tc,customGrad:()=>$u,data:()=>U,denseBincount:()=>nc,deprecationWarn:()=>oo,depthToSpace:()=>rc,depthwiseConv2d:()=>ac,deregisterOp:()=>sN,device_util:()=>a,diag:()=>ic,dilation2d:()=>sc,disableDeprecationWarnings:()=>so,dispose:()=>fo,disposeVariables:()=>uo,div:()=>Nu,divNoNan:()=>lc,dot:()=>cc,dropout:()=>Rd,einsum:()=>pc,elu:()=>dc,enableDebugMode:()=>io,enableProdMode:()=>ao,enclosingPowerOfTwo:()=>Fd,engine:()=>lo,env:()=>Ge,equal:()=>oc,erf:()=>hc,euclideanNorm:()=>Dc,exp:()=>Tc,expandDims:()=>Ic,expm1:()=>Ec,eye:()=>Ac,fft:()=>sd,fill:()=>zu,findBackend:()=>_o,findBackendFactory:()=>wo,floor:()=>Lc,floorDiv:()=>Mu,fused:()=>f,gather:()=>$c,gatherND:()=>Od,gather_util:()=>l,getBackend:()=>xo,getGradient:()=>ma,getKernel:()=>fa,getKernelsForBackend:()=>ga,grad:()=>Iu,grads:()=>Eu,greater:()=>Oc,greaterEqual:()=>Rc,ifft:()=>od,imag:()=>ko,image:()=>Uh,inTopKAsync:()=>zd,initializers:()=>x,input:()=>pv,io:()=>i,irfft:()=>ud,isFinite:()=>Fc,isInf:()=>Yc,isNaN:()=>zc,keep:()=>mo,kernel_impls:()=>y,layers:()=>v,leakyRelu:()=>Bc,less:()=>Pc,lessEqual:()=>Hc,linalg:()=>qh,linspace:()=>jc,loadGraphModel:()=>gS,loadGraphModelSync:()=>yS,loadLayersModel:()=>cv,localResponseNormalization:()=>Uc,log:()=>qc,log1p:()=>Wc,logSigmoid:()=>Gc,logSoftmax:()=>Kc,logSumExp:()=>Jc,logicalAnd:()=>Xc,logicalNot:()=>Zc,logicalOr:()=>Qc,logicalXor:()=>ep,losses:()=>Wh,lowerBound:()=>rp,matMul:()=>no,math:()=>s,max:()=>wc,maxPool:()=>ap,maxPool3d:()=>ip,maxPoolWithArgmax:()=>sp,maximum:()=>qu,mean:()=>op,memory:()=>co,meshgrid:()=>cp,metrics:()=>_,min:()=>Mc,minimum:()=>pp,mirrorPad:()=>dp,mod:()=>hp,model:()=>uv,models:()=>w,moments:()=>fp,movingAverage:()=>Ad,mul:()=>Su,multiRNNCell:()=>mp,multinomial:()=>gp,neg:()=>Do,nextFrame:()=>Xh,norm:()=>kc,notEqual:()=>yp,oneHot:()=>ro,ones:()=>lp,onesLike:()=>bp,op:()=>$i,outerProduct:()=>xp,pad:()=>vp,pad1d:()=>_p,pad2d:()=>wp,pad3d:()=>Mp,pad4d:()=>Np,pool:()=>kp,pow:()=>Pu,prelu:()=>Dp,print:()=>Os,prod:()=>Tp,profile:()=>po,rand:()=>Ip,randomGamma:()=>$p,randomNormal:()=>Op,randomStandardNormal:()=>Rp,randomUniform:()=>Fp,range:()=>Yp,ready:()=>bo,real:()=>To,reciprocal:()=>zp,registerBackend:()=>Mo,registerCallbackConstructor:()=>dv,registerGradient:()=>ba,registerKernel:()=>ya,registerOp:()=>aN,regularizers:()=>M,relu:()=>Bp,relu6:()=>Pp,removeBackend:()=>vo,reshape:()=>Ml,reverse:()=>Hp,reverse1d:()=>jp,reverse2d:()=>Up,reverse3d:()=>qp,reverse4d:()=>Wp,rfft:()=>cd,round:()=>Vp,rsqrt:()=>Gp,scalar:()=>Ru,scatterND:()=>Ld,scatter_util:()=>c,searchSorted:()=>np,selu:()=>Kp,separableConv2d:()=>Jp,sequential:()=>lv,serialization:()=>d,setBackend:()=>yo,setPlatform:()=>So,setdiff1dAsync:()=>Xp,sigmoid:()=>Dl,sign:()=>Zp,signal:()=>jh,sin:()=>Qp,sinh:()=>ed,slice:()=>Tl,slice1d:()=>td,slice2d:()=>nd,slice3d:()=>rd,slice4d:()=>ad,slice_util:()=>p,softmax:()=>id,softplus:()=>Vc,spaceToBatchND:()=>Sp,sparse:()=>Vh,sparseToDense:()=>$d,spectral:()=>Hh,split:()=>ld,sqrt:()=>ku,square:()=>Du,squaredDifference:()=>pd,squeeze:()=>dd,stack:()=>hd,step:()=>fd,stridedSlice:()=>md,string:()=>Gh,sub:()=>Hu,sum:()=>Nc,sumOutType:()=>pi,tan:()=>gd,tanh:()=>Il,tensor:()=>Fi,tensor1d:()=>yd,tensor2d:()=>bd,tensor3d:()=>$o,tensor4d:()=>xd,tensor5d:()=>vd,tensor6d:()=>_d,tensor_util:()=>t,test_util:()=>h,tidy:()=>ho,tile:()=>Cc,time:()=>go,topk:()=>wd,train:()=>Kh,transpose:()=>Io,truncatedNormal:()=>Md,unique:()=>Nd,unregisterGradient:()=>va,unregisterKernel:()=>xa,unsortedSegmentSum:()=>Sd,unstack:()=>kd,upcastType:()=>ci,upperBound:()=>Dd,util:()=>e,valueAndGrad:()=>Cu,valueAndGrads:()=>Au,variable:()=>Td,variableGrads:()=>Lu,version:()=>$P,version_converter:()=>bS,version_core:()=>_u,version_layers:()=>Bx,where:()=>uc,whereAsync:()=>Ed,zeros:()=>up,zerosLike:()=>Tu});var V={};n.r(V),n.d(V,{createAbs:()=>wW,createAccessorNode:()=>S7,createAcos:()=>NW,createAcosh:()=>gK,createAcot:()=>jW,createAcoth:()=>GK,createAcsc:()=>qW,createAcsch:()=>bK,createAdd:()=>pZ,createAddScalar:()=>VW,createAnd:()=>GJ,createApply:()=>vK,createApplyTransform:()=>d8,createArg:()=>GW,createArrayNode:()=>f7,createAsec:()=>MK,createAsech:()=>JW,createAsin:()=>xQ,createAsinh:()=>XW,createAssignmentNode:()=>k7,createAtan:()=>ZW,createAtan2:()=>fZ,createAtanh:()=>eV,createAtomicMass:()=>bU,createAvogadro:()=>xU,createBellNumbers:()=>W0,createBigNumberClass:()=>PH,createBignumber:()=>tV,createBin:()=>NK,createBitAnd:()=>JJ,createBitNot:()=>xV,createBitOr:()=>gZ,createBitXor:()=>ZJ,createBlockNode:()=>m7,createBohrMagneton:()=>Zj,createBohrRadius:()=>aU,createBoltzmann:()=>vU,createBoolean:()=>_V,createCatalan:()=>bZ,createCbrt:()=>eX,createCeil:()=>MQ,createChain:()=>_7,createChainClass:()=>J6,createClassicalElectronRadius:()=>iU,createClone:()=>MV,createColumn:()=>a0,createColumnTransform:()=>S8,createCombinations:()=>DV,createCombinationsWithRep:()=>kK,createCompare:()=>nX,createCompareNatural:()=>_Z,createCompareText:()=>aX,createCompile:()=>z7,createComplex:()=>IV,createComplexClass:()=>pj,createComposition:()=>SQ,createConcat:()=>sX,createConcatTransform:()=>y8,createConditionalNode:()=>g7,createConductanceQuantum:()=>Qj,createConj:()=>CV,createConstantNode:()=>y7,createCos:()=>TK,createCosh:()=>LV,createCot:()=>KK,createCoth:()=>OV,createCoulomb:()=>Jj,createCount:()=>lX,createCreateUnit:()=>M0,createCross:()=>DQ,createCsc:()=>RV,createCsch:()=>EK,createCtranspose:()=>pX,createCube:()=>YV,createCumSum:()=>MZ,createCumSumTransform:()=>M8,createDeepEqual:()=>SZ,createDenseMatrixClass:()=>Sq,createDerivative:()=>r8,createDet:()=>TQ,createDeuteronMass:()=>pU,createDiag:()=>hX,createDiff:()=>DZ,createDiffTransform:()=>m8,createDistance:()=>EQ,createDivide:()=>A0,createDivideScalar:()=>mX,createDot:()=>TZ,createDotDivide:()=>yX,createDotMultiply:()=>AQ,createDotPow:()=>S0,createE:()=>Ej,createEfimovFactor:()=>yU,createEigs:()=>V0,createElectricConstant:()=>Gj,createElectronMass:()=>sU,createElementaryCharge:()=>Xj,createEqual:()=>xX,createEqualScalar:()=>PV,createEqualText:()=>EZ,createErf:()=>HV,createEvaluate:()=>G7,createExp:()=>GV,createExpm:()=>D0,createExpm1:()=>JV,createFactorial:()=>$0,createFalse:()=>Nj,createFaraday:()=>_U,createFermiCoupling:()=>oU,createFft:()=>vX,createFibonacciHeapClass:()=>LQ,createFilter:()=>XV,createFilterTransform:()=>o8,createFineStructure:()=>uU,createFirstRadiation:()=>wU,createFix:()=>FQ,createFlatten:()=>wX,createFloor:()=>$Z,createForEach:()=>eG,createForEachTransform:()=>l8,createFormat:()=>rG,createFraction:()=>JK,createFractionClass:()=>HU,createFunctionAssignmentNode:()=>w7,createFunctionNode:()=>E7,createGamma:()=>I0,createGasConstant:()=>NU,createGcd:()=>NX,createGetMatrixDataType:()=>iG,createGravitationConstant:()=>Uj,createGravity:()=>LU,createHartreeEnergy:()=>lU,createHasNumericValue:()=>kX,createHelp:()=>Q7,createHelpClass:()=>B7,createHex:()=>sG,createHypot:()=>TX,createI:()=>Yj,createIdentity:()=>RZ,createIfft:()=>EX,createIm:()=>oG,createImmutableDenseMatrixClass:()=>YQ,createIndex:()=>s0,createIndexClass:()=>zQ,createIndexNode:()=>D7,createIndexTransform:()=>k8,createInfinity:()=>kj,createIntersect:()=>BQ,createInv:()=>o0,createInverseConductanceQuantum:()=>eU,createInvmod:()=>YZ,createIsInteger:()=>lG,createIsNaN:()=>AK,createIsNegative:()=>gG,createIsNumeric:()=>ZK,createIsPositive:()=>bG,createIsPrime:()=>$K,createIsZero:()=>vG,createKldivergence:()=>f1,createKlitzing:()=>rU,createKron:()=>AX,createLN10:()=>Lj,createLN2:()=>Aj,createLOG10E:()=>Oj,createLOG2E:()=>$j,createLarger:()=>BZ,createLargerEq:()=>$X,createLcm:()=>PQ,createLeafCount:()=>H7,createLeftShift:()=>FX,createLgamma:()=>TG,createLog:()=>PZ,createLog10:()=>EG,createLog1p:()=>jQ,createLog2:()=>AG,createLoschmidt:()=>MU,createLsolve:()=>BX,createLsolveAll:()=>jZ,createLup:()=>O0,createLusolve:()=>t1,createMad:()=>N1,createMagneticConstant:()=>Vj,createMagneticFluxQuantum:()=>tU,createMap:()=>LG,createMapTransform:()=>c8,createMatrix:()=>eJ,createMatrixClass:()=>jU,createMatrixFromColumns:()=>HX,createMatrixFromFunction:()=>nJ,createMatrixFromRows:()=>qZ,createMax:()=>UQ,createMaxTransform:()=>b8,createMean:()=>K0,createMeanTransform:()=>D8,createMedian:()=>a1,createMin:()=>jX,createMinTransform:()=>x8,createMod:()=>cJ,createMode:()=>qX,createMolarMass:()=>CU,createMolarMassC12:()=>AU,createMolarPlanckConstant:()=>SU,createMolarVolume:()=>kU,createMultinomial:()=>F0,createMultiply:()=>VZ,createMultiplyScalar:()=>OG,createNaN:()=>Dj,createNeutronMass:()=>dU,createNode:()=>Z6,createNorm:()=>y1,createNot:()=>PG,createNthRoot:()=>fJ,createNthRoots:()=>VX,createNuclearMagneton:()=>nU,createNull:()=>Sj,createNumber:()=>HG,createNumeric:()=>bJ,createObjectNode:()=>Q6,createOct:()=>jG,createOnes:()=>GX,createOperatorNode:()=>p7,createOr:()=>xJ,createParenthesisNode:()=>d7,createParse:()=>A7,createParser:()=>i8,createParserClass:()=>e8,createPartitionSelect:()=>JX,createPermutations:()=>z0,createPhi:()=>Cj,createPi:()=>Tj,createPickRandom:()=>VG,createPinv:()=>l0,createPlanckCharge:()=>FU,createPlanckConstant:()=>qj,createPlanckLength:()=>$U,createPlanckMass:()=>OU,createPlanckTemperature:()=>YU,createPlanckTime:()=>RU,createPow:()=>c0,createPrint:()=>KG,createProd:()=>wJ,createProtonMass:()=>cU,createQr:()=>GZ,createQuantileSeq:()=>qQ,createQuantumOfCirculation:()=>hU,createRandom:()=>QG,createRandomInt:()=>RK,createRange:()=>JZ,createRangeClass:()=>UU,createRangeNode:()=>b7,createRangeTransform:()=>v8,createRationalize:()=>n8,createRe:()=>eK,createReducedPlanckConstant:()=>Wj,createRelationalNode:()=>h7,createReplacer:()=>kq,createReshape:()=>NJ,createResize:()=>ZX,createResolve:()=>L7,createResultSet:()=>qU,createReviver:()=>x7,createRightArithShift:()=>eZ,createRightLogShift:()=>ZZ,createRotate:()=>D1,createRotationMatrix:()=>v1,createRound:()=>rZ,createRow:()=>WQ,createRowTransform:()=>N8,createRydberg:()=>fU,createSQRT1_2:()=>Rj,createSQRT2:()=>Fj,createSackurTetrode:()=>DU,createSec:()=>tK,createSech:()=>YK,createSecondRadiation:()=>TU,createSetCartesian:()=>GQ,createSetDifference:()=>d0,createSetDistinct:()=>JQ,createSetIntersect:()=>C0,createSetIsSubset:()=>ZQ,createSetMultiplicity:()=>f0,createSetPowerset:()=>e0,createSetSize:()=>eQ,createSetSymDifference:()=>X0,createSetUnion:()=>o1,createSign:()=>rK,createSimplify:()=>U7,createSimplifyCore:()=>F7,createSin:()=>aK,createSinh:()=>BK,createSize:()=>kJ,createSlu:()=>hQ,createSmaller:()=>IJ,createSmallerEq:()=>iZ,createSort:()=>n0,createSpaClass:()=>m0,createSparse:()=>HK,createSparseMatrixClass:()=>iK,createSpeedOfLight:()=>jj,createSplitUnit:()=>oK,createSqrt:()=>jK,createSqrtm:()=>y0,createSquare:()=>lK,createSqueeze:()=>CJ,createStd:()=>w1,createStdTransform:()=>E8,createStefanBoltzmann:()=>IU,createStirlingS2:()=>H0,createString:()=>pK,createSubset:()=>LJ,createSubsetTransform:()=>g8,createSubtract:()=>BJ,createSum:()=>fQ,createSumTransform:()=>_8,createSymbolNode:()=>T7,createSymbolicEqual:()=>W7,createTan:()=>dK,createTanh:()=>UK,createTau:()=>Ij,createThomsonCrossSection:()=>mU,createTo:()=>HJ,createTrace:()=>mQ,createTranspose:()=>jJ,createTrue:()=>Mj,createTypeOf:()=>fK,createTyped:()=>Pq,createUnaryMinus:()=>WK,createUnaryPlus:()=>_W,createUnequal:()=>oZ,createUnitClass:()=>_0,createUnitFunction:()=>U0,createUppercaseE:()=>Bj,createUppercasePi:()=>zj,createUsolve:()=>lZ,createUsolveAll:()=>yQ,createVacuumImpedance:()=>Kj,createVariance:()=>p1,createVarianceTransform:()=>I8,createVersion:()=>Pj,createWeakMixingAngle:()=>gU,createWienDisplacement:()=>EU,createXgcd:()=>qJ,createXor:()=>cZ,createZeros:()=>VJ});var G={};n.r(G),n.d(G,{AccessorNode:()=>G8,AccessorNodeDependencies:()=>S9,ArgumentsError:()=>XX,ArrayNode:()=>B8,ArrayNodeDependencies:()=>P9,AssignmentNode:()=>K8,AssignmentNodeDependencies:()=>W9,BigNumber:()=>T1,BigNumberDependencies:()=>h9,BlockNode:()=>P8,BlockNodeDependencies:()=>Ree,Chain:()=>$8,ChainDependencies:()=>jee,Complex:()=>I1,ComplexDependencies:()=>f9,ConditionalNode:()=>H8,ConditionalNodeDependencies:()=>ite,ConstantNode:()=>j8,ConstantNodeDependencies:()=>ste,DenseMatrix:()=>K1,DenseMatrixDependencies:()=>g9,DimensionError:()=>eq,EDependencies:()=>Sie,FibonacciHeap:()=>s5,FibonacciHeapDependencies:()=>Ine,Fraction:()=>L1,FractionDependencies:()=>y9,FunctionAssignmentNode:()=>V8,FunctionAssignmentNodeDependencies:()=>ote,FunctionNode:()=>Z8,FunctionNodeDependencies:()=>lte,Help:()=>r9,HelpDependencies:()=>jne,ImmutableDenseMatrix:()=>u5,ImmutableDenseMatrixDependencies:()=>Gee,Index:()=>l5,IndexDependencies:()=>Kee,IndexError:()=>tq,IndexNode:()=>J8,IndexNodeDependencies:()=>cte,InfinityDependencies:()=>Jne,LN10:()=>R1,LN10Dependencies:()=>lre,LN2:()=>X1,LN2Dependencies:()=>cre,LOG10E:()=>F1,LOG10EDependencies:()=>pre,LOG2E:()=>z2,LOG2EDependencies:()=>dre,Matrix:()=>Y1,MatrixDependencies:()=>m9,NaNDependencies:()=>Gre,Node:()=>O8,NodeDependencies:()=>v9,ObjectNode:()=>R8,ObjectNodeDependencies:()=>pte,OperatorNode:()=>F8,OperatorNodeDependencies:()=>dte,PIDependencies:()=>kie,ParenthesisNode:()=>Y8,ParenthesisNodeDependencies:()=>hte,Parser:()=>l9,ParserDependencies:()=>aae,Range:()=>H1,RangeDependencies:()=>Mae,RangeNode:()=>U8,RangeNodeDependencies:()=>fte,RelationalNode:()=>z8,RelationalNodeDependencies:()=>mte,ResultSet:()=>j1,ResultSetDependencies:()=>Oee,SQRT1_2:()=>U1,SQRT1_2Dependencies:()=>Yae,SQRT2:()=>e2,SQRT2Dependencies:()=>zae,Spa:()=>I5,SpaDependencies:()=>Mre,SparseMatrix:()=>t3,SparseMatrixDependencies:()=>w9,SymbolNode:()=>X8,SymbolNodeDependencies:()=>ute,Unit:()=>C5,UnitDependencies:()=>vee,_Infinity:()=>O1,_NaN:()=>z1,_false:()=>C1,_null:()=>B1,_true:()=>V1,abs:()=>a2,absDependencies:()=>x9,acos:()=>i2,acosDependencies:()=>k9,acosh:()=>o3,acoshDependencies:()=>D9,acot:()=>s2,acotDependencies:()=>T9,acoth:()=>N3,acothDependencies:()=>I9,acsc:()=>o2,acscDependencies:()=>E9,acsch:()=>u3,acschDependencies:()=>C9,add:()=>D4,addDependencies:()=>L9,addScalar:()=>u2,addScalarDependencies:()=>A9,all:()=>Lie,and:()=>q3,andDependencies:()=>R9,apply:()=>l3,applyDependencies:()=>Y9,applyTransformDependencies:()=>z9,arg:()=>l2,argDependencies:()=>B9,asec:()=>c3,asecDependencies:()=>H9,asech:()=>c2,asechDependencies:()=>j9,asin:()=>Q4,asinDependencies:()=>U9,asinh:()=>p2,asinhDependencies:()=>q9,atan:()=>d2,atan2:()=>T4,atan2Dependencies:()=>G9,atanDependencies:()=>V9,atanh:()=>h2,atanhDependencies:()=>K9,atomicMass:()=>$5,atomicMassDependencies:()=>_ee,avogadro:()=>d6,avogadroDependencies:()=>wee,bellNumbers:()=>E6,bellNumbersDependencies:()=>Iee,bignumber:()=>f2,bignumberDependencies:()=>J9,bin:()=>p3,binDependencies:()=>Eee,bitAnd:()=>W3,bitAndDependencies:()=>Cee,bitNot:()=>m2,bitNotDependencies:()=>Aee,bitOr:()=>I4,bitOrDependencies:()=>Lee,bitXor:()=>V3,bitXorDependencies:()=>$ee,bohrMagneton:()=>O5,bohrMagnetonDependencies:()=>Fee,bohrRadius:()=>h6,bohrRadiusDependencies:()=>Yee,boltzmann:()=>R5,boltzmannDependencies:()=>zee,boolean:()=>g2,booleanDependencies:()=>Bee,catalan:()=>E4,catalanDependencies:()=>Pee,cbrt:()=>G3,cbrtDependencies:()=>Hee,ceil:()=>e5,ceilDependencies:()=>ree,chain:()=>W8,chainDependencies:()=>Uee,classicalElectronRadius:()=>F6,classicalElectronRadiusDependencies:()=>qee,clone:()=>y2,cloneDependencies:()=>Wee,column:()=>w5,columnDependencies:()=>Qee,columnTransformDependencies:()=>ete,combinations:()=>b2,combinationsDependencies:()=>Nee,combinationsWithRep:()=>d3,combinationsWithRepDependencies:()=>tte,compare:()=>K3,compareDependencies:()=>nte,compareNatural:()=>C4,compareNaturalDependencies:()=>rte,compareText:()=>J3,compareTextDependencies:()=>ate,compile:()=>n9,compileDependencies:()=>yte,complex:()=>x2,complexDependencies:()=>bte,composition:()=>t5,compositionDependencies:()=>vte,concat:()=>X3,concatDependencies:()=>_te,concatTransformDependencies:()=>wte,conductanceQuantum:()=>F5,conductanceQuantumDependencies:()=>Mte,config:()=>RH,conj:()=>v2,conjDependencies:()=>pee,cos:()=>h3,cosDependencies:()=>Nte,cosh:()=>_2,coshDependencies:()=>Ste,cot:()=>S3,cotDependencies:()=>kte,coth:()=>w2,cothDependencies:()=>Dte,coulomb:()=>f6,coulombDependencies:()=>Tte,count:()=>Z3,countDependencies:()=>Ete,create:()=>Oie,createAbs:()=>wW,createAccessorNode:()=>S7,createAcos:()=>NW,createAcosh:()=>gK,createAcot:()=>jW,createAcoth:()=>GK,createAcsc:()=>qW,createAcsch:()=>bK,createAdd:()=>pZ,createAddScalar:()=>VW,createAnd:()=>GJ,createApply:()=>vK,createApplyTransform:()=>d8,createArg:()=>GW,createArrayNode:()=>f7,createAsec:()=>MK,createAsech:()=>JW,createAsin:()=>xQ,createAsinh:()=>XW,createAssignmentNode:()=>k7,createAtan:()=>ZW,createAtan2:()=>fZ,createAtanh:()=>eV,createAtomicMass:()=>bU,createAvogadro:()=>xU,createBellNumbers:()=>W0,createBigNumberClass:()=>PH,createBignumber:()=>tV,createBin:()=>NK,createBitAnd:()=>JJ,createBitNot:()=>xV,createBitOr:()=>gZ,createBitXor:()=>ZJ,createBlockNode:()=>m7,createBohrMagneton:()=>Zj,createBohrRadius:()=>aU,createBoltzmann:()=>vU,createBoolean:()=>_V,createCatalan:()=>bZ,createCbrt:()=>eX,createCeil:()=>MQ,createChain:()=>_7,createChainClass:()=>J6,createClassicalElectronRadius:()=>iU,createClone:()=>MV,createColumn:()=>a0,createColumnTransform:()=>S8,createCombinations:()=>DV,createCombinationsWithRep:()=>kK,createCompare:()=>nX,createCompareNatural:()=>_Z,createCompareText:()=>aX,createCompile:()=>z7,createComplex:()=>IV,createComplexClass:()=>pj,createComposition:()=>SQ,createConcat:()=>sX,createConcatTransform:()=>y8,createConditionalNode:()=>g7,createConductanceQuantum:()=>Qj,createConj:()=>CV,createConstantNode:()=>y7,createCos:()=>TK,createCosh:()=>LV,createCot:()=>KK,createCoth:()=>OV,createCoulomb:()=>Jj,createCount:()=>lX,createCreateUnit:()=>M0,createCross:()=>DQ,createCsc:()=>RV,createCsch:()=>EK,createCtranspose:()=>pX,createCube:()=>YV,createCumSum:()=>MZ,createCumSumTransform:()=>M8,createDeepEqual:()=>SZ,createDenseMatrixClass:()=>Sq,createDerivative:()=>r8,createDet:()=>TQ,createDeuteronMass:()=>pU,createDiag:()=>hX,createDiff:()=>DZ,createDiffTransform:()=>m8,createDistance:()=>EQ,createDivide:()=>A0,createDivideScalar:()=>mX,createDot:()=>TZ,createDotDivide:()=>yX,createDotMultiply:()=>AQ,createDotPow:()=>S0,createE:()=>Ej,createEfimovFactor:()=>yU,createEigs:()=>V0,createElectricConstant:()=>Gj,createElectronMass:()=>sU,createElementaryCharge:()=>Xj,createEqual:()=>xX,createEqualScalar:()=>PV,createEqualText:()=>EZ,createErf:()=>HV,createEvaluate:()=>G7,createExp:()=>GV,createExpm:()=>D0,createExpm1:()=>JV,createFactorial:()=>$0,createFalse:()=>Nj,createFaraday:()=>_U,createFermiCoupling:()=>oU,createFft:()=>vX,createFibonacciHeapClass:()=>LQ,createFilter:()=>XV,createFilterTransform:()=>o8,createFineStructure:()=>uU,createFirstRadiation:()=>wU,createFix:()=>FQ,createFlatten:()=>wX,createFloor:()=>$Z,createForEach:()=>eG,createForEachTransform:()=>l8,createFormat:()=>rG,createFraction:()=>JK,createFractionClass:()=>HU,createFunctionAssignmentNode:()=>w7,createFunctionNode:()=>E7,createGamma:()=>I0,createGasConstant:()=>NU,createGcd:()=>NX,createGetMatrixDataType:()=>iG,createGravitationConstant:()=>Uj,createGravity:()=>LU,createHartreeEnergy:()=>lU,createHasNumericValue:()=>kX,createHelp:()=>Q7,createHelpClass:()=>B7,createHex:()=>sG,createHypot:()=>TX,createI:()=>Yj,createIdentity:()=>RZ,createIfft:()=>EX,createIm:()=>oG,createImmutableDenseMatrixClass:()=>YQ,createIndex:()=>s0,createIndexClass:()=>zQ,createIndexNode:()=>D7,createIndexTransform:()=>k8,createInfinity:()=>kj,createIntersect:()=>BQ,createInv:()=>o0,createInverseConductanceQuantum:()=>eU,createInvmod:()=>YZ,createIsInteger:()=>lG,createIsNaN:()=>AK,createIsNegative:()=>gG,createIsNumeric:()=>ZK,createIsPositive:()=>bG,createIsPrime:()=>$K,createIsZero:()=>vG,createKldivergence:()=>f1,createKlitzing:()=>rU,createKron:()=>AX,createLN10:()=>Lj,createLN2:()=>Aj,createLOG10E:()=>Oj,createLOG2E:()=>$j,createLarger:()=>BZ,createLargerEq:()=>$X,createLcm:()=>PQ,createLeafCount:()=>H7,createLeftShift:()=>FX,createLgamma:()=>TG,createLog:()=>PZ,createLog10:()=>EG,createLog1p:()=>jQ,createLog2:()=>AG,createLoschmidt:()=>MU,createLsolve:()=>BX,createLsolveAll:()=>jZ,createLup:()=>O0,createLusolve:()=>t1,createMad:()=>N1,createMagneticConstant:()=>Vj,createMagneticFluxQuantum:()=>tU,createMap:()=>LG,createMapTransform:()=>c8,createMatrix:()=>eJ,createMatrixClass:()=>jU,createMatrixFromColumns:()=>HX,createMatrixFromFunction:()=>nJ,createMatrixFromRows:()=>qZ,createMax:()=>UQ,createMaxTransform:()=>b8,createMean:()=>K0,createMeanTransform:()=>D8,createMedian:()=>a1,createMin:()=>jX,createMinTransform:()=>x8,createMod:()=>cJ,createMode:()=>qX,createMolarMass:()=>CU,createMolarMassC12:()=>AU,createMolarPlanckConstant:()=>SU,createMolarVolume:()=>kU,createMultinomial:()=>F0,createMultiply:()=>VZ,createMultiplyScalar:()=>OG,createNaN:()=>Dj,createNeutronMass:()=>dU,createNode:()=>Z6,createNorm:()=>y1,createNot:()=>PG,createNthRoot:()=>fJ,createNthRoots:()=>VX,createNuclearMagneton:()=>nU,createNull:()=>Sj,createNumber:()=>HG,createNumeric:()=>bJ,createObjectNode:()=>Q6,createOct:()=>jG,createOnes:()=>GX,createOperatorNode:()=>p7,createOr:()=>xJ,createParenthesisNode:()=>d7,createParse:()=>A7,createParser:()=>i8,createParserClass:()=>e8,createPartitionSelect:()=>JX,createPermutations:()=>z0,createPhi:()=>Cj,createPi:()=>Tj,createPickRandom:()=>VG,createPinv:()=>l0,createPlanckCharge:()=>FU,createPlanckConstant:()=>qj,createPlanckLength:()=>$U,createPlanckMass:()=>OU,createPlanckTemperature:()=>YU,createPlanckTime:()=>RU,createPow:()=>c0,createPrint:()=>KG,createProd:()=>wJ,createProtonMass:()=>cU,createQr:()=>GZ,createQuantileSeq:()=>qQ,createQuantumOfCirculation:()=>hU,createRandom:()=>QG,createRandomInt:()=>RK,createRange:()=>JZ,createRangeClass:()=>UU,createRangeNode:()=>b7,createRangeTransform:()=>v8,createRationalize:()=>n8,createRe:()=>eK,createReducedPlanckConstant:()=>Wj,createRelationalNode:()=>h7,createReplacer:()=>kq,createReshape:()=>NJ,createResize:()=>ZX,createResolve:()=>L7,createResultSet:()=>qU,createReviver:()=>x7,createRightArithShift:()=>eZ,createRightLogShift:()=>ZZ,createRotate:()=>D1,createRotationMatrix:()=>v1,createRound:()=>rZ,createRow:()=>WQ,createRowTransform:()=>N8,createRydberg:()=>fU,createSQRT1_2:()=>Rj,createSQRT2:()=>Fj,createSackurTetrode:()=>DU,createSec:()=>tK,createSech:()=>YK,createSecondRadiation:()=>TU,createSetCartesian:()=>GQ,createSetDifference:()=>d0,createSetDistinct:()=>JQ,createSetIntersect:()=>C0,createSetIsSubset:()=>ZQ,createSetMultiplicity:()=>f0,createSetPowerset:()=>e0,createSetSize:()=>eQ,createSetSymDifference:()=>X0,createSetUnion:()=>o1,createSign:()=>rK,createSimplify:()=>U7,createSimplifyCore:()=>F7,createSin:()=>aK,createSinh:()=>BK,createSize:()=>kJ,createSlu:()=>hQ,createSmaller:()=>IJ,createSmallerEq:()=>iZ,createSort:()=>n0,createSpaClass:()=>m0,createSparse:()=>HK,createSparseMatrixClass:()=>iK,createSpeedOfLight:()=>jj,createSplitUnit:()=>oK,createSqrt:()=>jK,createSqrtm:()=>y0,createSquare:()=>lK,createSqueeze:()=>CJ,createStd:()=>w1,createStdTransform:()=>E8,createStefanBoltzmann:()=>IU,createStirlingS2:()=>H0,createString:()=>pK,createSubset:()=>LJ,createSubsetTransform:()=>g8,createSubtract:()=>BJ,createSum:()=>fQ,createSumTransform:()=>_8,createSymbolNode:()=>T7,createSymbolicEqual:()=>W7,createTan:()=>dK,createTanh:()=>UK,createTau:()=>Ij,createThomsonCrossSection:()=>mU,createTo:()=>HJ,createTrace:()=>mQ,createTranspose:()=>jJ,createTrue:()=>Mj,createTypeOf:()=>fK,createTyped:()=>Pq,createUnaryMinus:()=>WK,createUnaryPlus:()=>_W,createUnequal:()=>oZ,createUnit:()=>Y5,createUnitClass:()=>_0,createUnitDependencies:()=>Cte,createUnitFunction:()=>U0,createUppercaseE:()=>Bj,createUppercasePi:()=>zj,createUsolve:()=>lZ,createUsolveAll:()=>yQ,createVacuumImpedance:()=>Kj,createVariance:()=>p1,createVarianceTransform:()=>I8,createVersion:()=>Pj,createWeakMixingAngle:()=>gU,createWienDisplacement:()=>EU,createXgcd:()=>qJ,createXor:()=>cZ,createZeros:()=>VJ,cross:()=>n5,crossDependencies:()=>Ate,csc:()=>M2,cscDependencies:()=>Lte,csch:()=>f3,cschDependencies:()=>$te,ctranspose:()=>Q3,ctransposeDependencies:()=>Rte,cube:()=>N2,cubeDependencies:()=>Fte,cumsum:()=>A4,cumsumDependencies:()=>zte,cumsumTransformDependencies:()=>Bte,deepEqual:()=>L4,deepEqualDependencies:()=>Pte,derivative:()=>p9,derivativeDependencies:()=>Wte,det:()=>r5,detDependencies:()=>yee,deuteronMass:()=>z5,deuteronMassDependencies:()=>Vte,diag:()=>e4,diagDependencies:()=>Gte,diff:()=>$4,diffDependencies:()=>Kte,diffTransformDependencies:()=>Jte,distance:()=>a5,distanceDependencies:()=>Zte,divide:()=>m6,divideDependencies:()=>Hte,divideScalar:()=>t4,divideScalarDependencies:()=>eee,docs:()=>X7,dot:()=>O4,dotDependencies:()=>hee,dotDivide:()=>n4,dotDivideDependencies:()=>Qte,dotMultiply:()=>i5,dotMultiplyDependencies:()=>ene,dotPow:()=>B5,dotPowDependencies:()=>tne,e:()=>E1,eDependencies:()=>nne,efimovFactor:()=>J1,efimovFactorDependencies:()=>rne,eigs:()=>C6,eigsDependencies:()=>hne,electricConstant:()=>P5,electricConstantDependencies:()=>fne,electronMass:()=>g6,electronMassDependencies:()=>mne,elementaryCharge:()=>H5,elementaryChargeDependencies:()=>gne,equal:()=>r4,equalDependencies:()=>tee,equalScalar:()=>S2,equalScalarDependencies:()=>_9,equalText:()=>R4,equalTextDependencies:()=>yne,erf:()=>k2,erfDependencies:()=>bne,evaluate:()=>o9,evaluateDependencies:()=>xne,exp:()=>D2,expDependencies:()=>vne,expm:()=>j5,expm1:()=>T2,expm1Dependencies:()=>wne,expmDependencies:()=>_ne,factorial:()=>y6,factorialDependencies:()=>kee,factory:()=>YH,falseDependencies:()=>Mne,faraday:()=>U5,faradayDependencies:()=>Nne,fermiCoupling:()=>A6,fermiCouplingDependencies:()=>Sne,fft:()=>a4,fftDependencies:()=>Tne,filter:()=>I2,filterDependencies:()=>Ene,filterTransformDependencies:()=>Cne,fineStructure:()=>A1,fineStructureDependencies:()=>Ane,firstRadiation:()=>q5,firstRadiationDependencies:()=>Lne,fix:()=>o5,fixDependencies:()=>iee,flatten:()=>i4,flattenDependencies:()=>ane,floor:()=>F4,floorDependencies:()=>aee,forEach:()=>E2,forEachDependencies:()=>$ne,forEachTransformDependencies:()=>One,format:()=>C2,formatDependencies:()=>see,fraction:()=>k3,fractionDependencies:()=>X9,gamma:()=>W5,gammaDependencies:()=>See,gasConstant:()=>W6,gasConstantDependencies:()=>Rne,gcd:()=>s4,gcdDependencies:()=>Fne,getMatrixDataType:()=>A2,getMatrixDataTypeDependencies:()=>Yne,gravitationConstant:()=>V5,gravitationConstantDependencies:()=>zne,gravity:()=>b6,gravityDependencies:()=>Bne,hartreeEnergy:()=>G5,hartreeEnergyDependencies:()=>Pne,hasNumericValue:()=>o4,hasNumericValueDependencies:()=>Hne,help:()=>u9,helpDependencies:()=>Une,hex:()=>L2,hexDependencies:()=>qne,hypot:()=>u4,hypotDependencies:()=>Wne,i:()=>$1,iDependencies:()=>kne,identity:()=>Y4,identityDependencies:()=>lee,ifft:()=>l4,ifftDependencies:()=>Vne,im:()=>$2,imDependencies:()=>ine,index:()=>M5,indexDependencies:()=>Gne,indexTransformDependencies:()=>Kne,intersect:()=>c5,intersectDependencies:()=>Xne,inv:()=>N5,invDependencies:()=>bee,inverseConductanceQuantum:()=>x6,inverseConductanceQuantumDependencies:()=>Zne,invmod:()=>z4,invmodDependencies:()=>tre,isAccessorNode:()=>iH,isArray:()=>jP,isArrayNode:()=>sH,isAssignmentNode:()=>oH,isBigNumber:()=>YP,isBlockNode:()=>uH,isBoolean:()=>JP,isChain:()=>vH,isCollection:()=>qP,isComplex:()=>zP,isConditionalNode:()=>lH,isConstantNode:()=>cH,isDate:()=>eH,isDenseMatrix:()=>WP,isFraction:()=>BP,isFunction:()=>QP,isFunctionAssignmentNode:()=>pH,isFunctionNode:()=>dH,isHelp:()=>ZP,isIndex:()=>KP,isIndexNode:()=>hH,isInteger:()=>O2,isIntegerDependencies:()=>F9,isMatrix:()=>UP,isNaN:()=>m3,isNaNDependencies:()=>nre,isNegative:()=>R2,isNegativeDependencies:()=>Mee,isNode:()=>fH,isNull:()=>rH,isNumber:()=>FP,isNumeric:()=>D3,isNumericDependencies:()=>oee,isObject:()=>nH,isObjectNode:()=>mH,isOperatorNode:()=>gH,isParenthesisNode:()=>yH,isPositive:()=>F2,isPositiveDependencies:()=>xte,isPrime:()=>g3,isPrimeDependencies:()=>rre,isRange:()=>GP,isRangeNode:()=>bH,isRegExp:()=>tH,isResultSet:()=>XP,isSparseMatrix:()=>VP,isString:()=>HP,isSymbolNode:()=>xH,isUndefined:()=>aH,isUnit:()=>PP,isZero:()=>Y2,isZeroDependencies:()=>cee,kldivergence:()=>H6,kldivergenceDependencies:()=>sre,klitzing:()=>K5,klitzingDependencies:()=>ore,kron:()=>c4,kronDependencies:()=>ure,larger:()=>B4,largerDependencies:()=>Dee,largerEq:()=>p4,largerEqDependencies:()=>Jee,lcm:()=>d5,lcmDependencies:()=>hre,leafCount:()=>a9,leafCountDependencies:()=>fre,leftShift:()=>d4,leftShiftDependencies:()=>mre,lgamma:()=>B2,lgammaDependencies:()=>gre,log:()=>P4,log10:()=>P2,log10Dependencies:()=>yre,log1p:()=>h5,log1pDependencies:()=>bre,log2:()=>H2,log2Dependencies:()=>xre,logDependencies:()=>are,loschmidt:()=>J5,loschmidtDependencies:()=>vre,lsolve:()=>h4,lsolveAll:()=>H4,lsolveAllDependencies:()=>wre,lsolveDependencies:()=>_re,lup:()=>v6,lupDependencies:()=>Nre,lusolve:()=>Y6,lusolveDependencies:()=>kre,mad:()=>G6,madDependencies:()=>Ere,magneticConstant:()=>X5,magneticConstantDependencies:()=>Cre,magneticFluxQuantum:()=>_6,magneticFluxQuantumDependencies:()=>Are,map:()=>j2,mapDependencies:()=>Dre,mapTransformDependencies:()=>Lre,matrix:()=>T3,matrixDependencies:()=>M9,matrixFromColumns:()=>f4,matrixFromColumnsDependencies:()=>sne,matrixFromFunction:()=>I3,matrixFromFunctionDependencies:()=>$re,matrixFromRows:()=>j4,matrixFromRowsDependencies:()=>Ore,max:()=>f5,maxDependencies:()=>Rre,maxTransformDependencies:()=>Fre,mean:()=>L6,meanDependencies:()=>Yre,meanTransformDependencies:()=>zre,median:()=>z6,medianDependencies:()=>Ire,min:()=>m4,minDependencies:()=>Bre,minTransformDependencies:()=>Pre,mod:()=>E3,modDependencies:()=>Qne,mode:()=>g4,modeDependencies:()=>Hre,molarMass:()=>Z5,molarMassC12:()=>w6,molarMassC12Dependencies:()=>Ure,molarMassDependencies:()=>jre,molarPlanckConstant:()=>Q5,molarPlanckConstantDependencies:()=>qre,molarVolume:()=>$6,molarVolumeDependencies:()=>Wre,multinomial:()=>M6,multinomialDependencies:()=>Vre,multiply:()=>U4,multiplyDependencies:()=>fee,multiplyScalar:()=>U2,multiplyScalarDependencies:()=>uee,neutronMass:()=>e6,neutronMassDependencies:()=>Kre,norm:()=>j6,normDependencies:()=>Jre,not:()=>q2,notDependencies:()=>$9,nthRoot:()=>C3,nthRootDependencies:()=>Xre,nthRoots:()=>y4,nthRootsDependencies:()=>Zre,nuclearMagneton:()=>t6,nuclearMagnetonDependencies:()=>Qre,nullDependencies:()=>eae,number:()=>W2,numberDependencies:()=>Z9,numeric:()=>A3,numericDependencies:()=>Q9,oct:()=>V2,octDependencies:()=>tae,ones:()=>b4,onesDependencies:()=>nae,or:()=>L3,orDependencies:()=>rae,parse:()=>Q8,parseDependencies:()=>gte,parser:()=>d9,parserDependencies:()=>iae,partitionSelect:()=>x4,partitionSelectDependencies:()=>Tre,permutations:()=>N6,permutationsDependencies:()=>sae,phi:()=>P1,phiDependencies:()=>oae,pi:()=>Z1,piDependencies:()=>uae,pickRandom:()=>G2,pickRandomDependencies:()=>lae,pinv:()=>S5,pinvDependencies:()=>cae,planckCharge:()=>n6,planckChargeDependencies:()=>pae,planckConstant:()=>O6,planckConstantDependencies:()=>dae,planckLength:()=>r6,planckLengthDependencies:()=>hae,planckMass:()=>S6,planckMassDependencies:()=>fae,planckTemperature:()=>a6,planckTemperatureDependencies:()=>mae,planckTime:()=>U6,planckTimeDependencies:()=>gae,pow:()=>k5,powDependencies:()=>xee,print:()=>K2,printDependencies:()=>yae,prod:()=>$3,prodDependencies:()=>Ite,protonMass:()=>i6,protonMassDependencies:()=>bae,qr:()=>q4,qrDependencies:()=>une,quantileSeq:()=>m5,quantileSeqDependencies:()=>xae,quantumOfCirculation:()=>k6,quantumOfCirculationDependencies:()=>vae,random:()=>J2,randomDependencies:()=>_ae,randomInt:()=>y3,randomIntDependencies:()=>wae,range:()=>W4,rangeDependencies:()=>Zee,rangeTransformDependencies:()=>Nae,rationalize:()=>c9,rationalizeDependencies:()=>Sae,re:()=>X2,reDependencies:()=>lne,reducedPlanckConstant:()=>s6,reducedPlanckConstantDependencies:()=>kae,replacer:()=>Q1,replacerDependencies:()=>Dae,reshape:()=>O3,reshapeDependencies:()=>Tae,resize:()=>v4,resizeDependencies:()=>Iae,resolve:()=>e9,resolveDependencies:()=>jte,reviver:()=>q8,reviverDependencies:()=>Eae,rightArithShift:()=>_4,rightArithShiftDependencies:()=>Cae,rightLogShift:()=>V4,rightLogShiftDependencies:()=>Aae,rotate:()=>K6,rotateDependencies:()=>$ae,rotationMatrix:()=>q6,rotationMatrixDependencies:()=>Lae,round:()=>w4,roundDependencies:()=>nee,row:()=>g5,rowDependencies:()=>Oae,rowTransformDependencies:()=>Rae,rydberg:()=>o6,rydbergDependencies:()=>Fae,sackurTetrode:()=>q1,sackurTetrodeDependencies:()=>Bae,sec:()=>Z2,secDependencies:()=>Pae,sech:()=>b3,sechDependencies:()=>Hae,secondRadiation:()=>D6,secondRadiationDependencies:()=>jae,setCartesian:()=>y5,setCartesianDependencies:()=>Uae,setDifference:()=>D5,setDifferenceDependencies:()=>qae,setDistinct:()=>b5,setDistinctDependencies:()=>Wae,setIntersect:()=>u6,setIntersectDependencies:()=>Vae,setIsSubset:()=>x5,setIsSubsetDependencies:()=>Gae,setMultiplicity:()=>T5,setMultiplicityDependencies:()=>Kae,setPowerset:()=>v5,setPowersetDependencies:()=>Jae,setSize:()=>G4,setSizeDependencies:()=>Xae,setSymDifference:()=>R6,setSymDifferenceDependencies:()=>Zae,setUnion:()=>B6,setUnionDependencies:()=>Qae,sign:()=>Q2,signDependencies:()=>one,simplify:()=>i9,simplifyCore:()=>t9,simplifyCoreDependencies:()=>Ute,simplifyDependencies:()=>qte,sin:()=>e3,sinDependencies:()=>cne,sinh:()=>x3,sinhDependencies:()=>eie,size:()=>R3,sizeDependencies:()=>dee,slu:()=>K4,sluDependencies:()=>Sre,smaller:()=>F3,smallerDependencies:()=>Vee,smallerEq:()=>M4,smallerEqDependencies:()=>Xee,sort:()=>_5,sortDependencies:()=>tie,sparse:()=>v3,sparseDependencies:()=>nie,speedOfLight:()=>l6,speedOfLightDependencies:()=>rie,splitUnit:()=>n3,splitUnitDependencies:()=>aie,sqrt:()=>_3,sqrtDependencies:()=>Xte,sqrtm:()=>E5,sqrtmDependencies:()=>iie,square:()=>r3,squareDependencies:()=>sie,squeeze:()=>Y3,squeezeDependencies:()=>oie,std:()=>V6,stdDependencies:()=>lie,stdTransformDependencies:()=>cie,stefanBoltzmann:()=>c6,stefanBoltzmannDependencies:()=>pie,stirlingS2:()=>T6,stirlingS2Dependencies:()=>Tee,string:()=>a3,stringDependencies:()=>die,subset:()=>z3,subsetDependencies:()=>N9,subsetTransformDependencies:()=>hie,subtract:()=>B3,subtractDependencies:()=>gee,sum:()=>J4,sumDependencies:()=>ire,sumTransformDependencies:()=>fie,symbolicEqual:()=>s9,symbolicEqualDependencies:()=>mie,tan:()=>i3,tanDependencies:()=>gie,tanh:()=>w3,tanhDependencies:()=>yie,tau:()=>W1,tauDependencies:()=>Dne,thomsonCrossSection:()=>p6,thomsonCrossSectionDependencies:()=>bie,to:()=>P3,toDependencies:()=>xie,trace:()=>X4,traceDependencies:()=>vie,transpose:()=>H3,transposeDependencies:()=>Ote,trueDependencies:()=>_ie,typeOf:()=>s3,typeOfDependencies:()=>wie,typed:()=>t2,typedDependencies:()=>b9,unaryMinus:()=>M3,unaryMinusDependencies:()=>mee,unaryPlus:()=>n2,unaryPlusDependencies:()=>Yte,unequal:()=>N4,unequalDependencies:()=>Mie,unit:()=>I6,unitDependencies:()=>Nie,usolve:()=>S4,usolveAll:()=>Z4,usolveAllDependencies:()=>dne,usolveDependencies:()=>pne,vacuumImpedance:()=>A5,vacuumImpedanceDependencies:()=>Die,variance:()=>P6,varianceDependencies:()=>uie,varianceTransformDependencies:()=>Tie,version:()=>G1,versionDependencies:()=>Iie,weakMixingAngle:()=>r2,weakMixingAngleDependencies:()=>Eie,wienDisplacement:()=>L5,wienDisplacementDependencies:()=>Cie,xgcd:()=>j3,xgcdDependencies:()=>ere,xor:()=>k4,xorDependencies:()=>Aie,zeros:()=>U3,zerosDependencies:()=>O9});class K{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 J{refCount(e){return X("refCount")}incRef(e){return X("incRef")}timerAvailable(){return!0}time(e){return X("time")}read(e){return X("read")}readSync(e){return X("readSync")}readToGPU(e,t){return X("readToGPU")}numDataIds(){return X("numDataIds")}disposeData(e,t){return X("disposeData")}write(e,t,n){return X("write")}move(e,t,n,r,a){return X("move")}memory(){return X("memory")}floatPrecision(){return X("floatPrecision")}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}dispose(){return X("dispose")}}function X(e){throw new Error(`'${e}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`)}function Z(e){let t=e.length,n=0;for(;t>0;)n=Math.random()*t|0,t--,ne(e,t,n)}function Q(e,t){if(e.length!==t.length)throw new Error(`Array sizes must match to be shuffled together First array length was ${e.length}Second array length was ${t.length}`);let n=e.length,r=0;for(;n>0;)r=Math.random()*n|0,n--,ne(e,n,r),ne(t,n,r)}function ee(e,t,n){return Math.max(e,Math.min(t,n))}function te(e){return e%2==0?e:e+1}function ne(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function re(e){let t=0;for(let n=0;nn+` Shapes ${e} and ${t} must match`))}function ue(e){se(null!=e,(()=>"The input to the tensor constructor must be a non-null value."))}function le(e,t=[],n=!1){if(null==t&&(t=[]),Array.isArray(e)||De(e)&&!n)for(let r=0;r0),n){return new Promise(((r,a)=>{let i=0;const s=()=>{if(e())return void r();i++;const o=t(i);null!=n&&i>=n?a():setTimeout(s,o)};s()}))}function xe(e,t){let n=1,r=-1;for(let t=0;t=0)n*=e[t];else if(-1===e[t]){if(-1!==r)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${r} and dim ${t}`);r=t}else if(e[t]<0)throw Error(`Shapes can not be < 0. Found ${e[t]} at dim ${t}`);if(-1===r){if(t>0&&t!==n)throw Error(`Size(${t}) must match the product of shape ${e}`);return e}if(0===n)throw Error(`Cannot infer the missing size in [${e}] when there are 0 elements`);if(t%n!=0)throw Error(`The implicit shape can't be a fractional number. Got ${t} / ${n}`);const a=e.slice();return a[r]=t/n,a}function ve(e,t){const n=t.length;return e=null==e?t.map(((e,t)=>t)):[].concat(e),se(e.every((e=>e>=-n&&e`All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`)),se(e.every((e=>he(e))),(()=>`All values in axis param must be integers but got axis ${e}`)),e.map((e=>e<0?n+e:e))}function _e(e,t){const n=[],r=[],a=null!=t&&Array.isArray(t)&&0===t.length,i=null==t||a?null:ve(t,e).sort();let s=0;for(let t=0;tt)&&1===e[t]&&(n.push(e[t]),r.push(t)),i[s]<=t&&s++}1!==e[t]&&(n.push(e[t]),r.push(t))}return{newShape:n,keptDims:r}}function we(e,t){let n=null;if(null==e||"float32"===e)n=new Float32Array(t);else if("int32"===e)n=new Int32Array(t);else{if("bool"!==e)throw new Error(`Unknown data type ${e}`);n=new Uint8Array(t)}return n}function Me(e,t){let n=null;if(null==e||"float32"===e)n=new Float32Array(t);else if("int32"===e)n=new Int32Array(t);else if("bool"===e)n=new Uint8Array(t);else{if("string"!==e)throw new Error(`Unknown data type ${e}`);n=new Array(t)}return n}function Ne(e,t){for(let n=0;nt+=e.length)),t}function Ee(e){return"string"==typeof e||e instanceof String}function Ce(e){return"boolean"==typeof e}function Ae(e){return"number"==typeof e}function Le(e){return Array.isArray(e)?Le(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":Ae(e)?"float32":Ee(e)?"string":Ce(e)?"bool":"float32"}function $e(e){return!!(e&&e.constructor&&e.call&&e.apply)}function Oe(e,t){for(let n=t;n=0;--r)n[r]=n[r+1]*e[r+1];return n}function Fe(e,t,n,r=!1){const a=new Array;if(1===t.length){const i=t[0]*(r?2:1);for(let t=0;te*t))*(r?2:1);for(let t=0;te*t))*(n?2:1);if(0===r)return[];if(r!==t.length)throw new Error(`[${e}] does not match the input size ${t.length}${n?" for a complex tensor":""}.`);return Fe(0,e,t,n)}function ze(e,t){const n=Be(e,t);for(let e=0;ee*t),1);if(null==t||"float32"===t)return Ye(e,new Float32Array(n));if("int32"===t)return Ye(e,new Int32Array(n));if("bool"===t)return Ye(e,new Uint8Array(n));throw new Error(`Unknown data type ${t}`)}function He(e){e.forEach((t=>{se(Number.isInteger(t)&&t>=0,(()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`))}))}function je(e,t,n){if(0===t)return 0;if(1===t)return e[0];let r=e[e.length-1];for(let t=0;t{const[t,n]=e.split(":");this.urlFlags[t]=function(e,t){if("true"===(t=t.toLowerCase())||"false"===t)return"true"===t;if(""+ +t===t)return+t;throw new Error(`Could not parse value flag value ${t} for flag ${e}.`)}(t,n)}))}}function Ve(e){const t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,((e,...n)=>(function(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||"")}(t,n[0],n[1]),n.join("=")))),t}function Ge(){return Je}let Ke,Je=null;function Xe(){if(null==Ke){let e;if("undefined"!=typeof window)e=window;else if(void 0!==n.g)e=n.g;else if("undefined"!=typeof process)e=process;else{if("undefined"==typeof self)throw new Error("Could not find a global object");e=self}Ke=e}return Ke}function Ze(e,t){const n=function(){const e=Xe();return null==e._tfGlobals&&(e._tfGlobals=new Map),e._tfGlobals}();if(n.has(e))return n.get(e);{const r=t();return n.set(e,r),n.get(e)}}const Qe="Abs",et="Acos",tt="Acosh",nt="Add",rt="AddN",at="All",it="Any",st="ArgMax",ot="ArgMin",ut="Asin",lt="Asinh",ct="Atan",pt="Atanh",dt="Atan2",ht="AvgPool",ft="AvgPoolGrad",mt="AvgPool3D",gt="AvgPool3DGrad",yt="BatchMatMul",bt="BatchToSpaceND",xt="Bincount",vt="BroadcastTo",_t="BroadcastArgs",wt="Cast",Mt="Ceil",Nt="ClipByValue",St="Complex",kt="ComplexAbs",Dt="Concat",Tt="Conv2D",It="Conv2DBackpropFilter",Et="Conv2DBackpropInput",Ct="Conv3D",At="Conv3DBackpropFilterV2",Lt="Conv3DBackpropInputV2",$t="Cos",Ot="Cosh",Rt="Cumprod",Ft="Cumsum",Yt="CropAndResize",zt="DenseBincount",Bt="DepthToSpace",Pt="DepthwiseConv2dNative",Ht="DepthwiseConv2dNativeBackpropFilter",jt="DepthwiseConv2dNativeBackpropInput",Ut="Diag",qt="Dilation2D",Wt="Dilation2DBackpropInput",Vt="Dilation2DBackpropFilter",Gt="RealDiv",Kt="Einsum",Jt="Elu",Xt="EluGrad",Zt="Erf",Qt="Equal",en="Exp",tn="ExpandDims",nn="Expm1",rn="FFT",an="Fill",sn="FlipLeftRight",on="Floor",un="FloorDiv",ln="FusedBatchNorm",cn="GatherV2",pn="GatherNd",dn="Greater",hn="GreaterEqual",fn="Identity",mn="IFFT",gn="Imag",yn="IsFinite",bn="IsInf",xn="IsNan",vn="LeakyRelu",_n="Less",wn="LessEqual",Mn="LinSpace",Nn="Log",Sn="Log1p",kn="LogicalAnd",Dn="LogicalNot",Tn="LogicalOr",In="LogicalXor",En="LogSoftmax",Cn="LowerBound",An="LRN",Ln="LRNGrad",$n="Max",On="Maximum",Rn="MaxPool",Fn="MaxPoolGrad",Yn="MaxPool3D",zn="MaxPool3DGrad",Bn="MaxPoolWithArgmax",Pn="Mean",Hn="Min",jn="Minimum",Un="MirrorPad",qn="Mod",Wn="Multinomial",Vn="Multiply",Gn="Neg",Kn="NotEqual",Jn="NonMaxSuppressionV3",Xn="NonMaxSuppressionV4",Zn="NonMaxSuppressionV5",Qn="OnesLike",er="OneHot",tr="Pack",nr="PadV2",rr="Pool",ar="Pow",ir="Prelu",sr="Prod",or="Range",ur="Real",lr="Reciprocal",cr="Relu",pr="Reshape",dr="ResizeNearestNeighbor",hr="ResizeNearestNeighborGrad",fr="ResizeBilinear",mr="ResizeBilinearGrad",gr="Relu6",yr="Reverse",br="Round",xr="Rsqrt",vr="ScatterNd",_r="SearchSorted",wr="Select",Mr="Selu",Nr="Slice",Sr="Sin",kr="Sinh",Dr="Sign",Tr="Sigmoid",Ir="Softplus",Er="Sqrt",Cr="Sum",Ar="SpaceToBatchND",Lr="SplitV",$r="Softmax",Or="SparseFillEmptyRows",Rr="SparseReshape",Fr="SparseSegmentMean",Yr="SparseSegmentSum",zr="SparseToDense",Br="SquaredDifference",Pr="Square",Hr="StridedSlice",jr="StringNGrams",Ur="StringSplit",qr="StringToHashBucketFast",Wr="Sub",Vr="Tan",Gr="Tanh",Kr="Tile",Jr="TopK",Xr="Transform",Zr="Transpose",Qr="Unique",ea="Unpack",ta="UnsortedSegmentSum",na="UpperBound",ra="ZerosLike",aa="Step",ia="FromPixels",sa="RotateWithOffset",oa="_FusedMatMul",ua="FusedConv2D",la="FusedDepthwiseConv2D";function ca(...e){Ge().getBool("IS_TEST")||Ge().getBool("PROD")||console.warn(...e)}function pa(...e){Ge().getBool("IS_TEST")||Ge().getBool("PROD")||console.log(...e)}const da=Ze("kernelRegistry",(()=>new Map)),ha=Ze("gradRegistry",(()=>new Map));function fa(e,t){const n=wa(e,t);return da.get(n)}function ma(e){return ha.get(e)}function ga(e){const t=da.entries(),n=[];for(;;){const{done:r,value:a}=t.next();if(r)break;const[i,s]=a,[o]=i.split("_");o===e&&n.push(s)}return n}function ya(e){const{kernelName:t,backendName:n}=e,r=wa(t,n);da.has(r)&&ca(`The kernel '${t}' for backend '${n}' is already registered`),da.set(r,e)}function ba(e){const{kernelName:t}=e;ha.has(t)&&Ge().getBool("DEBUG")&&ca(`Overriding the gradient for '${t}'`),ha.set(t,e)}function xa(e,t){const n=wa(e,t);if(!da.has(n))throw new Error(`The kernel '${e}' for backend '${t}' is not registered`);da.delete(n)}function va(e){if(!ha.has(e))throw new Error(`The gradient '${e}' for backend is not registered`);ha.delete(e)}function _a(e,t){ga(e).forEach((e=>{ya(Object.assign({},e,{backendName:t}))}))}function wa(e,t){return`${t}_${e}`}var Ma=n(3720);const Na=n.n(Ma)()||Ma;function Sa(e){return Na.fromString(e,!0,16)}const ka=Sa("c3a5c85c97cb3127"),Da=Sa("b492b66fbe98f273"),Ta=Sa("9ae16a3b2f90404f");function Ia(e){return e.xor(e.shru(47))}function Ea(e,t,n){const r=e.slice(t,t+n);return Na.fromBytes(Array.from(r),!0,!0)}function Ca(e,t){return Ea(e,t,8)}function Aa(e,t){return Ea(e,t,4)}function La(e,t){return 0===t?e:e.shru(t).or(e.shl(64-t))}function $a(e,t,n=Sa("9ddfea08eb382d69")){let r=e.xor(t).mul(n);r=r.xor(r.shru(47));let a=t.xor(r).mul(n);return a=a.xor(a.shru(47)),a=a.mul(n),a}function Oa(e,t,n,r){return function(e,t,n,r,a,i){a=a.add(e),i=La(i.add(a).add(r),21);const s=a;return a=(a=a.add(t)).add(n),i=i.add(La(a,44)),[a.add(r),i.add(s)]}(Ca(e,t),Ca(e,t+8),Ca(e,t+16),Ca(e,t+24),n,r)}function Ra(e,t=e.length){const n=Na.fromNumber(81,!0);if(t<=32)return t<=16?function(e,t=e.length){if(t>=8){const n=Ta.add(2*t),r=Ca(e,0).add(Ta),a=Ca(e,t-8);return $a(La(a,37).mul(n).add(r),La(r,25).add(a).mul(n),n)}if(t>=4){const n=Ta.add(2*t);return $a(Aa(e,0).shl(3).add(t),Aa(e,t-4),n)}if(t>0){const n=e[0]+(e[t>>1]<<8),r=t+(e[t-1]<<2);return Ia(Ta.mul(n).xor(ka.mul(r))).mul(Ta)}return Ta}(e,t):function(e,t=e.length){const n=Ta.add(2*t),r=Ca(e,0).mul(Da),a=Ca(e,8),i=Ca(e,t-8).mul(n),s=Ca(e,t-16).mul(Ta);return $a(La(r.add(a),43).add(La(i,30)).add(s),r.add(La(a.add(Ta),18)).add(i),n)}(e,t);if(t<=64)return function(e,t=e.length){const n=Ta.add(2*t),r=Ca(e,0).mul(Ta),a=Ca(e,8),i=Ca(e,t-8).mul(n),s=Ca(e,t-16).mul(Ta),o=La(r.add(a),43).add(La(i,30)).add(s),u=$a(o,r.add(La(a.add(Ta),18)).add(i),n),l=Ca(e,16).mul(n),c=Ca(e,24),p=o.add(Ca(e,t-32)).mul(n),d=u.add(Ca(e,t-24)).mul(n);return $a(La(l.add(c),43).add(La(p,30)).add(d),l.add(La(c.add(r),18)).add(p),n)}(e,t);let r=n,a=n.mul(Da).add(113),i=Ia(a.mul(Ta).add(113)).mul(Ta),s=[Na.UZERO,Na.UZERO],o=[Na.UZERO,Na.UZERO];r=r.mul(Ta).add(Ca(e,0));let u=0;const l=64*(t-1>>6),c=l+(t-1&63)-63;do{r=La(r.add(a).add(s[0]).add(Ca(e,u+8)),37).mul(Da),a=La(a.add(s[1]).add(Ca(e,u+48)),42).mul(Da),r=r.xor(o[1]),a=a.add(s[0]).add(Ca(e,u+40)),i=La(i.add(o[0]),33).mul(Da),s=Oa(e,u,s[1].mul(Da),r.add(o[0])),o=Oa(e,u+32,i.add(o[1]),a.add(Ca(e,u+16))),[i,r]=[r,i],u+=64}while(u!==l);const p=Da.add(i.and(255).shl(1));return u=c,o[0]=o[0].add(t-1&63),s[0]=s[0].add(o[0]),o[0]=o[0].add(s[0]),r=La(r.add(a).add(s[0]).add(Ca(e,u+8)),37).mul(p),a=La(a.add(s[1]).add(Ca(e,u+48)),42).mul(p),r=r.xor(o[1].mul(9)),a=a.add(s[0].mul(9).add(Ca(e,u+40))),i=La(i.add(o[0]),33).mul(p),s=Oa(e,u,s[1].mul(p),r.add(o[0])),o=Oa(e,u+32,i.add(o[1]),a.add(Ca(e,u+16))),[i,r]=[r,i],$a($a(s[0],o[0],p).add(Ia(a).mul(ka)).add(i),$a(s[1],o[1],p).add(r),p)}function Fa(e,t){return"string"===t?Pa(e):Ya([e],t)}function Ya(e,t){if("string"===t)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=le(e)),Ge().getBool("DEBUG")&&Ne(e,t),function(e,t){return e instanceof Float32Array&&"float32"===t||e instanceof Int32Array&&"int32"===t||e instanceof Uint8Array&&"bool"===t}(e,t))return e;if(null==t||"float32"===t||"complex64"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t){const t=new Uint8Array(e.length);for(let n=0;n{r=n()};let i;const s=za();if(this.backendTimer.timerAvailable())i=this.backendTimer.time(a);else{a();for(const e of r)e.dataSync();i=Promise.resolve({kernelMs:za()-s})}if(Ge().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let t=0;t{Ua(t,n.dtype,e)}))}return{kernelName:e,outputs:r,inputs:t,timeMs:i.then((e=>e.kernelMs)),extraInfo:i.then((e=>null!=e.getExtraProfileInfo?e.getExtraProfileInfo():""))}}logKernelProfile(e){const{kernelName:t,outputs:n,timeMs:r,inputs:a,extraInfo:i}=e;n.forEach((e=>{Promise.all([e.data(),r,i]).then((n=>{this.logger.logKernelProfile(t,e,n[0],n[1],a,n[2])}))}))}}function Ua(e,t,n){if("float32"!==t)return!1;for(let t=0;t0?r:""} `}}console.log(`%c${o}\t%c${s}\t%c${u}D ${c}\t%c${l}\t%c${p}\t%c${i}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}}function Wa(e,t,n,r){const a=Re(t),i=function(e,t,n,r){const a=ce(t),i=r[r.length-1],s=new Array(i).fill(0),o=t.length,u="complex64"===n?Ja(e):e;if(o>1)for(let e=0;e" "+e)).join("\n")),u.join("\n")}function Va(e,t,n){let r;return r=Array.isArray(e)?`${parseFloat(e[0].toFixed(7))} + ${parseFloat(e[1].toFixed(7))}j`:Ee(e)?`'${e}'`:"bool"===n?Ga(e):parseFloat(e.toFixed(7)).toString(),ye(r,t)}function Ga(e){return 0===e?"false":"true"}function Ka(e,t,n,r,a,i=!0){const s="complex64"===n?2:1,o=t[0],u=t.length;if(0===u)return"complex64"===n?[Va(Ja(e)[0],0,n)]:"bool"===n?[Ga(e[0])]:[e[0].toString()];if(1===u){if(o>20){const t=3*s;let r=Array.from(e.slice(0,t)),i=Array.from(e.slice((o-3)*s,o*s));return"complex64"===n&&(r=Ja(r),i=Ja(i)),["["+r.map(((e,t)=>Va(e,a[t],n))).join(", ")+", ..., "+i.map(((e,t)=>Va(e,a[o-3+t],n))).join(", ")+"]"]}return["["+("complex64"===n?Ja(e):Array.from(e)).map(((e,t)=>Va(e,a[t],n))).join(", ")+"]"]}const l=t.slice(1),c=r.slice(1),p=r[0]*s,d=[];if(o>20){for(let t=0;t<3;t++){const r=t*p,i=r+p;d.push(...Ka(e.slice(r,i),l,n,c,a,!1))}d.push("...");for(let t=o-3;t`Length of values '${e}' does not match the size inferred by the shape '${this.size}'.`))}if("complex64"===t)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=n||Me(t,this.size),this.strides=Re(e)}set(e,...t){0===t.length&&(t=[0]),se(t.length===this.rank,(()=>`The number of provided coordinates (${t.length}) must match the rank (${this.rank})`));const n=this.locToIndex(t);this.values[n]=e}get(...e){0===e.length&&(e=[0]);let t=0;for(const n of e){if(n<0||n>=this.shape[t]){const t=`Requested out of range element at ${e}. Buffer shape=${this.shape}`;throw new Error(t)}t++}let n=e[e.length-1];for(let t=0;tHa(e)))}catch(e){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(),Za().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();const e=Za().readSync(this.dataId);if("string"===this.dtype)try{return e.map((e=>Ha(e)))}catch(e){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 Za().read(this.dataId);return"string"===this.dtype?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(Za().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return Qa.print(this,e)}clone(){return this.throwIfDisposed(),Qa.clone(this)}toString(e=!1){return Wa(this.dataSync(),this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),Qa.cast(this,e)}variable(e=!0,t,n){return this.throwIfDisposed(),Za().makeVariable(this,e,t,n)}}function ni(){return Ze("Tensor",(()=>ti))}Object.defineProperty(ti,Symbol.hasInstance,{value:e=>!!e&&null!=e.data&&null!=e.dataSync&&null!=e.throwIfDisposed}),ni();class ri extends ti{constructor(e,t,n,r){super(e.shape,e.dtype,e.dataId,r),this.trainable=t,this.name=n}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(!de(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);Za().disposeTensor(this),this.dataId=e.dataId,Za().incRef(this,null)}dispose(){Za().disposeVariable(this),this.isDisposedInternal=!0}}var ai,ii,si,oi,ui;Object.defineProperty(ri,Symbol.hasInstance,{value:e=>e instanceof ti&&null!=e.assign&&e.assign instanceof Function}),function(e){e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6"}(ai||(ai={})),function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"}(ii||(ii={})),function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"}(si||(si={})),function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"}(oi||(oi={})),function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"}(ui||(ui={}));const li={float32:oi,int32:ii,bool:si,complex64:ui};function ci(e,t){if("string"===e||"string"===t){if("string"===e&&"string"===t)return"string";throw new Error(`Can not upcast ${e} with ${t}`)}return li[e][t]}function pi(e){return ci(e,"int32")}function di(e,t){if(e.dtype===t.dtype)return[e,t];const n=ci(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function hi(e,t){se(e.dtype===t.dtype,(()=>`The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`))}function fi(e,t){return t.some((t=>t.id===e.id))}function mi(e){const t=[];return gi(e,t,new Set),t}function gi(e,t,n){if(null==e)return;if(e instanceof ti)return void t.push(e);if(r=e,!Array.isArray(r)&&"object"!=typeof r)return;var r;const a=e;for(const e in a){const r=a[e];n.has(r)||(n.add(r),gi(r,t,n))}}function yi(e){return null!=e.kernelName}class bi{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 xi{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new bi}async ready(){if(null!=this.pendingBackendInit)return this.pendingBackendInit.then((()=>{}));if(null!=this.backendInstance)return;const e=this.getSortedBackends();for(let t=0;t{null!=e.setupFunc&&e.setupFunc(this.backendInstance)}))}disposeRegisteredKernels(e){ga(e).forEach((t=>{null!=t.disposeFunc&&t.disposeFunc(this.registry[e])}))}initializeBackend(e){const t=this.registryFactory[e];if(null==t)throw new Error(`Cannot initialize backend ${e}, no registration found.`);try{const n=t.factory();if(!n||n instanceof J||"function"!=typeof n.then)return this.registry[e]=n,{success:!0,asyncInit:!1};{const t=++this.pendingBackendInitId,r=n.then((n=>!(t(tthis.registryFactory[t].priority-this.registryFactory[e].priority))}initializeBackendsAndReturnBest(){const e=this.getSortedBackends();for(let t=0;tthis.startScope(r)),(()=>this.endScope(n)),(()=>(n=t(),n instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),n)))}scopedRun(e,t,n){e();try{const e=n();return t(),e}catch(e){throw t(),e}}nextTensorId(){return xi.nextTensorId++}nextVariableId(){return xi.nextVariableId++}clone(e){const t=_i.runKernel(fn,{x:e}),n={x:e};return this.addTapeNode(this.state.activeScope.name,n,[t],(e=>({x:()=>{const t={x:e};return _i.runKernel(wt,t,{dtype:"float32"})}})),[],{}),t}runKernel(e,t,n){if(null==this.backendName&&this.backend,null==fa(e,this.backendName))throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:e,inputs:t,attrs:n})}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(e,t,n){const r=this.backend.numDataIds();let a=0;n.forEach((e=>{a+="complex64"===e.dtype?3:1}));const i=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],s=r-t-a-i;if(s>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${s} data ids) after running '${e}'`)}runKernelFunc(e){let t,n=[];const r=this.isTapeOn(),a=this.state.numBytes,i=this.state.numTensors;let s,o;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0),null==this.backendName&&this.backend;const u=yi(e)?e.kernelName:null!=this.state.activeScope?this.state.activeScope.name:"";if(yi(e)){const{kernelName:t,inputs:a,attrs:i}=e;null==this.backendName&&this.backend;const u=fa(t,this.backendName);se(null!=u,(()=>`Cannot find registered kernel '${t}' for backend '${this.backendName}'`)),s=()=>{const e=this.backend.numDataIds();o=u.kernelFunc({inputs:a,attrs:i,backend:this.backend});const s=Array.isArray(o)?o:[o];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(t,e,s);const l=s.map((e=>null!=e.rank?e:this.makeTensorFromTensorInfo(e)));if(r){const e=this.getTensorsForGradient(t,a,l);n=this.saveTensorsForBackwardMode(e)}return l}}else{const{forwardFunc:t}=e,a=e=>{r&&(n=e.map((e=>this.keep(this.clone(e)))))};s=()=>{const e=this.backend.numDataIds();o=this.tidy((()=>t(this.backend,a)));const n=Array.isArray(o)?o:[o];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(u,e,n),n}}const{inputs:l,attrs:c}=e,p=yi(e)?null:e.backwardsFunc;let d;return this.scopedRun((()=>this.state.kernelDepth++),(()=>this.state.kernelDepth--),(()=>{this.ENV.getBool("DEBUG")||this.state.profiling?(d=this.profiler.profileKernel(u,l,(()=>s())),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(d),t=d.outputs):t=s()})),r&&this.addTapeNode(u,l,t,p,n,c),this.state.profiling&&this.state.activeProfile.kernels.push({name:u,bytesAdded:this.state.numBytes-a,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-i,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(l).map((e=>null!=l[e]?l[e].shape:null)),outputShapes:t.map((e=>e.shape)),kernelTimeMs:d.timeMs,extraInfo:d.extraInfo}),Array.isArray(o)?t:t[0]}saveTensorsForBackwardMode(e){const t=e.map((e=>this.keep(this.clone(e))));return t}getTensorsForGradient(e,t,n){const r=ma(e);if(null!=r){const e=r.inputsToSave||[],a=r.outputsToSave||[];let i;r.saveAllInputs?(se(Array.isArray(t),(()=>"saveAllInputs is true, expected inputs to be an array.")),i=Object.keys(t).map((e=>t[e]))):i=e.map((e=>t[e]));const s=n.filter(((e,t)=>a[t]));return i.concat(s)}return[]}makeTensor(e,t,n,r){if(null==e)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",r=r||this.backend;let a=e;"string"===n&&Ee(e[0])&&(a=e.map((e=>Pa(e))));const i=r.write(a,t,n),s=new ti(t,n,i,this.nextTensorId());if(this.trackTensor(s,r),"string"===n){const e=this.state.tensorInfo.get(i),t=Ie(a);this.state.numBytes+=t-e.bytes,e.bytes=t}return s}makeTensorFromDataId(e,t,n,r){const a={dataId:e,shape:t,dtype:n=n||"float32"};return this.makeTensorFromTensorInfo(a,r)}makeTensorFromTensorInfo(e,t){const{dataId:n,shape:r,dtype:a}=e,i=new ti(r,a,n,this.nextTensorId());return this.trackTensor(i,t),i}makeVariable(e,t=!0,n,r){n=n||this.nextVariableId().toString(),null!=r&&r!==e.dtype&&(e=e.cast(r));const a=new ri(e,t,n,this.nextTensorId());if(null!=this.state.registeredVariables[a.name])throw new Error(`Variable with name ${a.name} was already registered`);return this.state.registeredVariables[a.name]=a,this.incRef(a,this.backend),a}trackTensor(e,t){this.state.numTensors++,"string"===e.dtype&&this.state.numStringTensors++;let n=0;"complex64"!==e.dtype&&"string"!==e.dtype&&(n=e.size*Te(e.dtype)),this.state.numBytes+=n,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:n})),e instanceof ri||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--,"string"===e.dtype&&(this.state.numStringTensors--,this.state.numBytes-=t.bytes),"complex64"!==e.dtype&&"string"!==e.dtype){const t=e.size*Te(e.dtype);this.state.numBytes-=t}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),null!=this.state.registeredVariables[e.name]&&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,null==e.reasons&&(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,n=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((e=>e.totalBytesSnapshot))),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-n;for(const e of this.state.activeProfile.kernels)e.kernelTimeMs=await e.kernelTimeMs,e.extraInfo=await e.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&0===this.state.kernelDepth}addTapeNode(e,t,n,r,a,i){const s={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:a},o=ma(e);null!=o&&(r=o.gradFunc),null!=r&&(s.gradient=e=>(e=e.map(((e,t)=>{if(null==e){const e=n[t],r=Be(e.size,e.dtype);return this.makeTensor(r,e.shape,e.dtype)}return e})),r(e.length>1?e:e[0],a,i))),this.state.activeTape.push(s)}keep(e){return e.kept=!0,e}startTape(){0===this.state.gradientDepth&&(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=mi(e),n=new Set(t.map((e=>e.id)));for(let e=0;e{e.kept||e.scopeId!==r.id||this.track(e)}))}gradients(e,t,n,r=!1){if(se(t.length>0,(()=>"gradients() received an empty list of xs.")),null!=n&&"float32"!==n.dtype)throw new Error(`dy must have 'float32' dtype, but has '${n.dtype}'`);const a=this.scopedRun((()=>this.startTape()),(()=>this.endTape()),(()=>this.tidy("forward",e)));se(a instanceof ti,(()=>"The result y returned by f() must be a tensor."));const i=function(e,t,n){const r={},a={};for(let e=0;er[e.id]=!0)),o=!0,a[i.id]=!0;break}if(o)break}}const i={};i[n.id]=!0;const s={};for(let t=e.length-1;t>=0;t--){const n=e[t],r=n.inputs;for(let e=0;e0)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 e={};e[a.id]=null==n?function(e){const t=ze(ce(e),"float32");return _i.makeTensor(t,e,"float32")}(a.shape):n,function(e,t,n,r){for(let a=t.length-1;a>=0;a--){const i=t[a],s=[];if(i.outputs.forEach((t=>{const n=e[t.id];null!=n?s.push(n):s.push(null)})),null==i.gradient)throw new Error(`Cannot compute gradient: gradient function not found for ${i.kernelName}.`);const o=i.gradient(s);for(const t in i.inputs){if(!(t in o))throw new Error(`Cannot backprop through input ${t}. Available gradients found: ${Object.keys(o)}.`);const a=n((()=>o[t]()));if("float32"!==a.dtype)throw new Error(`Error in gradient for op ${i.kernelName}. The gradient of input ${t} must have 'float32' dtype, but has '${a.dtype}'`);const s=i.inputs[t];if(!de(a.shape,s.shape))throw new Error(`Error in gradient for op ${i.kernelName}. The gradient of input '${t}' has shape '${a.shape}', which does not match the shape of the input '${s.shape}'`);if(null==e[s.id])e[s.id]=a;else{const t=e[s.id];e[s.id]=r(t,a),t.dispose()}}}}(e,i,(e=>this.tidy(e)),wi);const r=t.map((t=>e[t.id]));return 0===this.state.gradientDepth&&(this.state.activeTape.forEach((e=>{for(const t of e.saved)t.dispose()})),this.state.activeTape=null),{value:a,grads:r}}))}customGrad(e){return se($e(e),(()=>"The f passed in customGrad(f) must be a function.")),(...t)=>{let n;se(t.every((e=>e instanceof ti)),(()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors"));const r={};return t.forEach(((e,t)=>{r[t]=e})),this.runKernelFunc({forwardFunc:(r,a)=>(n=e(...t,a),se(n.value instanceof ti,(()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor")),se($e(n.gradFunc),(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function.")),n.value),backwardsFunc:(e,r)=>{const a=n.gradFunc(e,r),i=Array.isArray(a)?a:[a];se(i.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(...).")),se(i.every((e=>e instanceof ti)),(()=>"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 s={};return i.forEach(((e,t)=>{s[t]=()=>e})),s},inputs:r})}}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=za(),n=await this.backend.time(e);return n.wallMs=za()-t,n}track(e){return null!=this.state.activeScope&&(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 bi;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}}function vi(){const e=Xe();if(null==e._tfengine){const t=new We(e);e._tfengine=new xi(t)}var t;return t=e._tfengine.ENV,Je=t,Za=()=>e._tfengine,e._tfengine}xi.nextTensorId=0,xi.nextVariableId=0;const _i=vi();function wi(e,t){const n={a:e,b:t};return _i.runKernel(nt,n)}let Mi;function Ni(e){Mi=e}function Si(e){if(void 0!==Mi)return Mi;if(e||"undefined"!=typeof navigator&&null!=navigator){if(e||(e=navigator),"ReactNative"===e.product)return!0;const t=e.userAgent||e.vendor||("undefined"!=typeof window?window.opera:"");if(!t){const t=e;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(t)||/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(t.substr(0,4))}return!1}function ki(){return"undefined"!=typeof window&&null!=window.document||"undefined"!=typeof WorkerGlobalScope}const Di=Ge();function Ti(e,t){let n=e;if(De(e))return"string"===t?[]:[e.length];if(!Array.isArray(e))return[];const r=[];for(;Array.isArray(n)||De(n)&&"string"!==t;)r.push(n.length),n=n[0];return Array.isArray(e)&&Ge().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&Ii(e,r,[]),r}function Ii(e,t,n){if(n=n||[],!Array.isArray(e)&&!De(e))return void se(0===t.length,(()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`));se(t.length>0,(()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`)),se(e.length===t[0],(()=>`Element arr[${n.join("][")}] should have ${t[0]} elements, but has ${e.length} elements`));const r=t.slice(1);for(let t=0;t=0&&(a=r),Ei(r,a,t,n),null==e||!De(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e){const r=null==e?"null":e.constructor.name;throw new Error(`Argument '${t}' passed to '${n}' must be a Tensor or TensorLike, but got '${r}'`)}const i=Ti(e,a);De(e)||Array.isArray(e)||(e=[e]);const s="string"!==a?Ya(e,a):le(e,[],!0);return _i.makeTensor(s,i,a)}function Ai(e,t,n,r="numeric"){if(!Array.isArray(e))throw new Error(`Argument ${t} passed to ${n} must be a \`Tensor[]\` or \`TensorLike[]\``);return e.map(((e,a)=>Ci(e,`${t}[${a}]`,n,r)))}Di.registerFlag("DEBUG",(()=>!1),(e=>{e&&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.")})),Di.registerFlag("IS_BROWSER",(()=>ki())),Di.registerFlag("IS_NODE",(()=>"undefined"!=typeof process&&void 0!==process.versions&&void 0!==process.versions.node)),Di.registerFlag("IS_CHROME",(()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor))),Di.registerFlag("PROD",(()=>!1)),Di.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",(()=>Di.getBool("DEBUG"))),Di.registerFlag("DEPRECATION_WARNINGS_ENABLED",(()=>!0)),Di.registerFlag("IS_TEST",(()=>!1)),Di.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",(()=>!0)),Di.registerFlag("WRAP_TO_IMAGEBITMAP",(()=>!1)),Di.registerFlag("ENGINE_COMPILE_ONLY",(()=>!1));const Li="__op";function $i(e){const t=Object.keys(e);if(1!==t.length)throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${t.length} keys.`);let n=t[0];const r=e[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n+=Li;const a=(...e)=>{_i.startScope(n);try{const t=r(...e);return qe(t)&&console.error("Cannot return a Promise inside of tidy."),_i.endScope(t),t}catch(e){throw _i.endScope(null),e}};return Object.defineProperty(a,"name",{value:n,configurable:!0}),a}const Oi=$i({complex_:function(e,t){const n=Ci(e,"real","complex"),r=Ci(t,"imag","complex");oe(n.shape,r.shape,`real and imag shapes, ${n.shape} and ${r.shape}, must match in call to tf.complex().`);const a={real:n,imag:r};return _i.runKernel(St,a)}});function Ri(e,t,n,r){if(null==r&&(r=Le(e)),"complex64"===r)throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!De(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e)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(null!=t){He(t);const e=ce(t),r=ce(n);se(e===r,(()=>`Based on the provided shape, [${t}], the tensor should have ${e} values but has ${r}`));for(let e=0;e`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `))}}return De(e)||Array.isArray(e)||(e=[e]),t=t||n,e="string"!==r?Ya(e,r):le(e,[],!0),_i.makeTensor(e,t,r)}function Fi(e,t,n){return Ri(e,t,Ti(e,n),n)}const Yi={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8};async function zi(e,t){const n=[],r=[],a=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);for(let i=0;i{const t=await o.bytes(),n=t.reduce(((e,t)=>e+t.length),0)+4*t.length,r=new Uint8Array(n);let a=0;for(let e=0;e{if(t+=e.byteLength,n.push(e.byteLength===e.buffer.byteLength?e:new e.constructor(e)),!(e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array))throw new Error(`Unsupported TypedArray subtype: ${e.constructor.name}`)}));const r=new Uint8Array(t);let a=0;return n.forEach((e=>{r.set(new Uint8Array(e.buffer),a),a+=e.byteLength})),r.buffer}const Hi="undefined"!=typeof Buffer&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function ji(e){return Hi?Buffer.byteLength(e):new Blob([e]).size}function Ui(e){if(1===e.length)return e[0];let t=0;e.forEach((e=>{t+=e.byteLength}));const n=new Uint8Array(t);let r=0;return e.forEach((e=>{n.set(new Uint8Array(e),r),r+=e.byteLength})),n.buffer}function qi(e){for(e=e.trim();e.endsWith("/");)e=e.slice(0,e.length-1);const t=e.split("/");return t[t.length-1]}function Wi(e,t){const n={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,weightsManifest:t};return null!=e.signature&&(n.signature=e.signature),null!=e.userDefinedMetadata&&(n.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(n.modelInitializer=e.modelInitializer),null!=e.trainingConfig&&(n.trainingConfig=e.trainingConfig),n}async function Vi(e,t){const n={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy};if(null!=e.trainingConfig&&(n.trainingConfig=e.trainingConfig),null!=e.weightsManifest){const[r,a]=await t(e.weightsManifest);n.weightSpecs=r,n.weightData=a}return null!=e.signature&&(n.signature=e.signature),null!=e.userDefinedMetadata&&(n.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(n.modelInitializer=e.modelInitializer),n}function Gi(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("Expected JSON model topology, received ArrayBuffer.");return{dateSaved:new Date,modelTopologyType:"JSON",modelTopologyBytes:null==e.modelTopology?0:ji(JSON.stringify(e.modelTopology)),weightSpecsBytes:null==e.weightSpecs?0:ji(JSON.stringify(e.weightSpecs)),weightDataBytes:null==e.weightData?0:e.weightData.byteLength}}function Ki(){const e=function(){const e=e=>{let t=e<<13,n=0;for(;0==(8388608&t);)n-=8388608,t<<=1;return t&=-8388609,n+=947912704,t|n},t=new Uint32Array(2048);t[0]=0;for(let n=1;n<1024;n++)t[n]=e(n);for(let e=1024;e<2048;e++)t[e]=939524096+(e-1024<<13);return t}(),t=function(){const e=new Uint32Array(64);e[0]=0,e[31]=1199570944,e[32]=2147483648,e[63]=3347054592;for(let t=1;t<31;t++)e[t]=t<<23;for(let t=33;t<63;t++)e[t]=2147483648+(t-32<<23);return e}(),n=function(){const e=new Uint32Array(64);for(let t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}();return r=>{const a=new ArrayBuffer(4*r.length),i=new Uint32Array(a);for(let a=0;a>10]+(1023&s)]+t[s>>10];i[a]=o}return new Float32Array(a)}}class Ji{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return null==Ji.instance&&(Ji.instance=new Ji),Ji.instance}static registerSaveRouter(e){Ji.getInstance().saveRouters.push(e)}static registerLoadRouter(e){Ji.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return Ji.getHandlers(e,"save")}static getLoadHandlers(e,t){return Ji.getHandlers(e,"load",t)}static getHandlers(e,t,n){const r=[];return("load"===t?Ji.getInstance().loadRouters:Ji.getInstance().saveRouters).forEach((t=>{const a=t(e,n);null!==a&&r.push(a)})),r}}const Xi=e=>Ji.registerSaveRouter(e),Zi=e=>Ji.registerLoadRouter(e),Qi=e=>Ji.getSaveHandlers(e),es=(e,t)=>Ji.getLoadHandlers(e,t),ts="tensorflowjs",ns="models_store",rs="model_info_store";function as(){if(!Ge().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");const e="undefined"==typeof window?self:window,t=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB||e.shimIndexedDB;if(null==t)throw new Error("The current browser does not appear to support IndexedDB.");return t}function is(e){const t=e.result;t.createObjectStore(ns,{keyPath:"modelPath"}),t.createObjectStore(rs,{keyPath:"modelPath"})}class ss{constructor(e){if(this.indexedDB=as(),null==e||!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(((e,n)=>{const r=this.indexedDB.open(ts,1);r.onupgradeneeded=()=>is(r),r.onsuccess=()=>{const a=r.result;if(null==t){const t=a.transaction(ns,"readonly"),r=t.objectStore(ns).get(this.modelPath);r.onsuccess=()=>{if(null==r.result)return a.close(),n(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));e(r.result.modelArtifacts)},r.onerror=e=>(a.close(),n(r.error)),t.oncomplete=()=>a.close()}else{const r=Gi(t),i=a.transaction(rs,"readwrite");let s=i.objectStore(rs);const o=s.put({modelPath:this.modelPath,modelArtifactsInfo:r});let u;o.onsuccess=()=>{u=a.transaction(ns,"readwrite");const o=u.objectStore(ns).put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:r});o.onsuccess=()=>e({modelArtifactsInfo:r}),o.onerror=e=>{s=i.objectStore(rs);const t=s.delete(this.modelPath);t.onsuccess=()=>(a.close(),n(o.error)),t.onerror=e=>(a.close(),n(o.error))}},o.onerror=e=>(a.close(),n(o.error)),i.oncomplete=()=>{null==u?a.close():u.oncomplete=()=>a.close()}}},r.onerror=e=>n(r.error)}))}}ss.URL_SCHEME="indexeddb://";const os=e=>{return Ge().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(ss.URL_SCHEME)?(t=e.slice(ss.URL_SCHEME.length),new ss(t)):null;var t};Ji.registerSaveRouter(os),Ji.registerLoadRouter(os);class us{constructor(){this.indexedDB=as()}async listModels(){return new Promise(((e,t)=>{const n=this.indexedDB.open(ts,1);n.onupgradeneeded=()=>is(n),n.onsuccess=()=>{const r=n.result,a=r.transaction(rs,"readonly"),i=a.objectStore(rs).getAll();i.onsuccess=()=>{const t={};for(const e of i.result)t[e.modelPath]=e.modelArtifactsInfo;e(t)},i.onerror=e=>(r.close(),t(i.error)),a.oncomplete=()=>r.close()},n.onerror=e=>t(n.error)}))}async removeModel(e){var t;return e=(t=e).startsWith(ss.URL_SCHEME)?t.slice(ss.URL_SCHEME.length):t,new Promise(((t,n)=>{const r=this.indexedDB.open(ts,1);r.onupgradeneeded=()=>is(r),r.onsuccess=()=>{const a=r.result,i=a.transaction(rs,"readwrite"),s=i.objectStore(rs),o=s.get(e);let u;o.onsuccess=()=>{if(null==o.result)return a.close(),n(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{const r=s.delete(e),i=()=>{u=a.transaction(ns,"readwrite");const r=u.objectStore(ns).delete(e);r.onsuccess=()=>t(o.result.modelArtifactsInfo),r.onerror=e=>n(o.error)};r.onsuccess=i,r.onerror=e=>(i(),a.close(),n(o.error))}},o.onerror=e=>(a.close(),n(o.error)),i.oncomplete=()=>{null==u?a.close():u.oncomplete=()=>a.close()}},r.onerror=e=>n(r.error)}))}}const ls="/",cs="tensorflowjs_models",ps="info",ds="model_topology",hs="weight_specs",fs="weight_data",ms="model_metadata";function gs(e){return{info:[cs,e,ps].join(ls),topology:[cs,e,ds].join(ls),weightSpecs:[cs,e,hs].join(ls),weightData:[cs,e,fs].join(ls),modelMetadata:[cs,e,ms].join(ls)}}function ys(e){for(const t of Object.values(e))window.localStorage.removeItem(t)}function bs(e){const t=e.split(ls);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(ls)}class xs{constructor(e){if(!Ge().getBool("IS_BROWSER")||"undefined"==typeof window||void 0===window.localStorage)throw new Error("The current environment does not support local storage.");if(this.LS=window.localStorage,null==e||!e)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=e,this.keys=gs(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),n=JSON.stringify(e.weightSpecs),r=Gi(e);try{this.LS.setItem(this.keys.info,JSON.stringify(r)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,n),this.LS.setItem(this.keys.weightData,function(e){if(Hi)return Buffer.from(e).toString("base64");const t=new Uint8Array(e);let n="";for(let e=0,r=t.length;e{return Ge().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(xs.URL_SCHEME)?(t=e.slice(xs.URL_SCHEME.length),new xs(t)):null;var t};Ji.registerSaveRouter(vs),Ji.registerLoadRouter(vs);class _s{constructor(){se(Ge().getBool("IS_BROWSER"),(()=>"Current environment is not a web browser")),se("undefined"==typeof window||void 0!==window.localStorage,(()=>"Current browser does not appear to support localStorage")),this.LS=window.localStorage}async listModels(){const e={},t=cs+ls,n=ls+ps;for(let r=0;r"scheme must not be undefined or null.")),e.endsWith(ws)&&(e=e.slice(0,e.indexOf(ws))),se(e.length>0,(()=>"scheme must not be an empty string."));const n=Ms.getInstance();se(null==n.managers[e],(()=>`A model store manager is already registered for scheme '${e}'.`)),n.managers[e]=t}static getManager(e){const t=Ms.getInstance().managers[e];if(null==t)throw new Error(`Cannot find model manager for scheme '${e}'`);return t}static getSchemes(){return Object.keys(Ms.getInstance().managers)}}function Ns(e){if(-1===e.indexOf(ws))throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${Ms.getSchemes().join(",")}`);return{scheme:e.split(ws)[0],path:e.split(ws)[1]}}async function Ss(e,t,n=!1){se(e!==t,(()=>`Old path and new path are the same: '${e}'`));const r=Ji.getLoadHandlers(e);se(r.length>0,(()=>`Copying failed because no load handler is found for source URL ${e}.`)),se(r.length<2,(()=>`Copying failed because more than one (${r.length}) load handlers for source URL ${e}.`));const a=r[0],i=Ji.getSaveHandlers(t);se(i.length>0,(()=>`Copying failed because no save handler is found for destination URL ${t}.`)),se(i.length<2,(()=>`Copying failed because more than one (${r.length}) save handlers for destination URL ${t}.`));const s=i[0],o=Ns(e).scheme,u=Ns(e).path,l=o===Ns(e).scheme,c=await a.load();n&&l&&await Ms.getManager(o).removeModel(u);const p=await s.save(c);return n&&!l&&await Ms.getManager(o).removeModel(u),p.modelArtifactsInfo}async function ks(){const e=Ms.getSchemes(),t={};for(const n of e){const e=await Ms.getManager(n).listModels();for(const r in e)t[n+ws+r]=e[r]}return t}async function Ds(e){const t=Ns(e);return Ms.getManager(t.scheme).removeModel(t.path)}async function Ts(e,t){return Ss(e,t,!1)}async function Is(e,t){return Ss(e,t,!0)}class Es{fetch(e,t){return fetch(e,t)}now(){return performance.now()}encode(e,t){if("utf-8"!==t&&"utf8"!==t)throw new Error(`Browser's encoder only supports utf-8, but got ${t}`);return null==this.textEncoder&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(e)}decode(e,t){return new TextDecoder(t).decode(e)}}if(Ge().get("IS_BROWSER")){Ge().setPlatform("browser",new Es);try{Ms.registerManager(xs.URL_SCHEME,new _s)}catch(e){}try{Ms.registerManager(ss.URL_SCHEME,new us)}catch(e){}}let Cs;function As(e,t="float32",n){return t=t||"float32",He(e),new Xa(e,t,n)}Ge().get("IS_NODE")&&!Ge().get("IS_BROWSER")&&Ge().setPlatform("node",new class{constructor(){this.util=n(8628),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return null!=Ge().global.fetch?Ge().global.fetch(e,t):(null==Cs&&(Cs=n(5410)),Cs(e,t))}now(){const e=process.hrtime();return 1e3*e[0]+e[1]/1e6}encode(e,t){if("utf-8"!==t&&"utf8"!==t)throw new Error(`Node built-in encoder only supports utf-8, but got ${t}`);return this.textEncoder.encode(e)}decode(e,t){return 0===e.length?"":new this.util.TextDecoder(t).decode(e)}});const Ls=$i({cast_:function(e,t){const n=Ci(e,"x","cast");if(!Se(t))throw new Error(`Failed to cast to unknown dtype ${t}`);if("string"===t&&"string"!==n.dtype||"string"!==t&&"string"===n.dtype)throw new Error("Only strings can be casted to strings");const r={x:n},a={dtype:t};return _i.runKernel(wt,r,a)}}),$s=$i({clone_:function(e){const t={x:Ci(e,"x","clone","string_or_numeric")};return _i.runKernel(fn,t)}});function Os(e,t=!1){console.log(e.toString(t))}function Rs(e){return new Promise((e=>setTimeout(e))).then(e)}vi(),Qa={buffer:As,cast:Ls,clone:$s,print:Os};class Fs{constructor(e){if(!Ge().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(Fs.URL_SCHEME)&&(e=e.slice(Fs.URL_SCHEME.length)),null!=e&&0!==e.length||(e="model"),this.modelJsonFileName=e+".json",this.weightDataFileName=e+".weights.bin"}async save(e){if("undefined"==typeof document)throw new Error("Browser downloads are not supported in this environment since `document` is not present");const t=window.URL.createObjectURL(new Blob([e.weightData],{type:"application/octet-stream"}));if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet.");{const n=Wi(e,[{paths:["./"+this.weightDataFileName],weights:e.weightSpecs}]),r=window.URL.createObjectURL(new Blob([JSON.stringify(n)],{type:"application/json"})),a=null==this.modelJsonAnchor?document.createElement("a"):this.modelJsonAnchor;if(a.download=this.modelJsonFileName,a.href=r,await Rs((()=>a.dispatchEvent(new MouseEvent("click")))),null!=e.weightData){const e=null==this.weightDataAnchor?document.createElement("a"):this.weightDataAnchor;e.download=this.weightDataFileName,e.href=t,await Rs((()=>e.dispatchEvent(new MouseEvent("click"))))}return{modelArtifactsInfo:Gi(e)}}}}Fs.URL_SCHEME="downloads://";class Ys{constructor(e){if(null==e||e.length<1)throw new Error(`When calling browserFiles, at least 1 file is required, but received ${e}`);this.jsonFile=e[0],this.weightsFiles=e.slice(1)}async load(){return new Promise(((e,t)=>{const n=new FileReader;n.onload=n=>{const r=JSON.parse(n.target.result),a=r.modelTopology;if(null==a)return void t(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`));if(null==r.weightsManifest)return void t(new Error(`weightManifest field is missing from file ${this.jsonFile.name}`));if(0===this.weightsFiles.length)return void e({modelTopology:a});const i=Vi(r,(e=>this.loadWeights(e)));e(i)},n.onerror=e=>t(`Failed to read model topology and weights manifest JSON from file '${this.jsonFile.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`),n.readAsText(this.jsonFile)}))}loadWeights(e){const t=[],n=[];for(const r of e)t.push(...r.weights),n.push(...r.paths);const r=this.checkManifestAndWeightFiles(e),a=n.map((e=>this.loadWeightsFile(e,r[e])));return Promise.all(a).then((e=>[t,Ui(e)]))}loadWeightsFile(e,t){return new Promise(((n,r)=>{const a=new FileReader;a.onload=e=>{const t=e.target.result;n(t)},a.onerror=t=>r(`Failed to weights data from file of path '${e}'.`),a.readAsArrayBuffer(t)}))}checkManifestAndWeightFiles(e){const t=[],n=this.weightsFiles.map((e=>qi(e.name))),r={};for(const a of e)a.paths.forEach((e=>{const a=qi(e);if(-1!==t.indexOf(a))throw new Error(`Duplicate file basename found in weights manifest: '${a}'`);if(t.push(a),-1===n.indexOf(a))throw new Error(`Weight file with basename '${a}' is not provided.`);r[e]=this.weightsFiles[n.indexOf(a)]}));if(t.length!==this.weightsFiles.length)throw new Error(`Mismatch in the number of files in weights manifest (${t.length}) and the number of weight files provided (${this.weightsFiles.length}).`);return r}}function zs(e){return new Ys(e)}function Bs(e,t,n,r){!function(e){se(null!=e&&Array.isArray(e)&&e.length>0,(()=>"promises must be a none empty array"))}(e),function(e,t){se(e>=0&&e<=1,(()=>`Progress fraction must be in range [0, 1], but got startFraction ${e}`)),se(t>=0&&t<=1,(()=>`Progress fraction must be in range [0, 1], but got endFraction ${t}`)),se(t>=e,(()=>`startFraction must be no more than endFraction, but got startFraction ${e} and endFraction ${t}`))}(n=null==n?0:n,r=null==r?1:r);let a=0;return Promise.all(e.map((i=>(i.then((i=>{const s=n+ ++a/e.length*(r-n);return t(s),i})),i))))}async function Ps(e,t){null==t&&(t={});const n=null==t.fetchFunc?Ge().platform.fetch:t.fetchFunc,r=e.map((e=>n(e,t.requestInit,{isBinary:!0}))),a=(null==t.onProgress?await Promise.all(r):await Bs(r,t.onProgress,0,.5)).map((e=>e.arrayBuffer()));return null==t.onProgress?await Promise.all(a):await Bs(a,t.onProgress,.5,1)}async function Hs(e,t="",n,r){return js((e=>Ps(e,{requestInit:r})))(e,t,n)}function js(e){return async(t,n="",r)=>{const a=t.map((()=>!1)),i={},s=null!=r?r.map((()=>!1)):[],o=[];if(t.forEach(((e,t)=>{let n=0;e.weights.forEach((e=>{const u="quantization"in e?e.quantization.dtype:e.dtype,l=Yi[u]*ce(e.shape),c=()=>{a[t]=!0,null==i[t]&&(i[t]=[]),i[t].push({manifestEntry:e,groupOffset:n,sizeBytes:l})};null!=r?r.forEach(((t,n)=>{t===e.name&&(c(),s[n]=!0)})):c(),o.push(e.name),n+=l}))})),!s.every((e=>e))){const e=r.filter(((e,t)=>!s[t]));throw new Error(`Could not find weights in manifest with names: ${e.join(", ")}. \nManifest JSON has weights with names: ${o.join(", ")}.`)}const u=a.reduce(((e,t,n)=>(t&&e.push(n),e)),[]),l=[];u.forEach((e=>{t[e].paths.forEach((e=>{const t=n+(n.endsWith("/")?"":"/")+e;l.push(t)}))}));const c=await e(l),p={};let d=0;return u.forEach((e=>{const n=t[e].paths.length;let r=0;for(let e=0;e{const t=Bi(a.slice(e.groupOffset,e.groupOffset+e.sizeBytes),[e.manifestEntry]);for(const e in t)p[e]=t[e]})),d+=n})),p}}Ji.registerSaveRouter((e=>Ge().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Fs.URL_SCHEME)?function(e="model"){return new Fs(e)}(e.slice(Fs.URL_SCHEME.length)):null));class Us{constructor(e,t){if(this.DEFAULT_METHOD="POST",null==t&&(t={}),this.weightPathPrefix=t.weightPathPrefix,this.onProgress=t.onProgress,this.weightUrlConverter=t.weightUrlConverter,null!=t.fetchFunc?(se("function"==typeof t.fetchFunc,(()=>"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=Ge().platform.fetch,se(null!=e&&e.length>0,(()=>"URL path for http must not be null, undefined or empty.")),Array.isArray(e)&&se(2===e.length,(()=>`URL paths for http must have a length of 2, (actual length is ${e.length}).`)),this.path=e,null!=t.requestInit&&null!=t.requestInit.body)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=t.requestInit||{}}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 n=Wi(e,[{paths:["./model.weights.bin"],weights:e.weightSpecs}]);t.body.append("model.json",new Blob([JSON.stringify(n)],{type:"application/json"}),"model.json"),null!=e.weightData&&t.body.append("model.weights.bin",new Blob([e.weightData],{type:"application/octet-stream"}),"model.weights.bin");const r=await this.fetch(this.path,t);if(r.ok)return{modelArtifactsInfo:Gi(e),responses:[r]};throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${r.status}.`)}async load(){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(e){let t=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?t+=" 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.":t+=" Please make sure the server is serving valid JSON for this request.",new Error(t)}const n=t.modelTopology,r=t.weightsManifest;if(null==n&&null==r)throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);return Vi(t,(e=>this.loadWeights(e)))}async loadWeights(e){const t=Array.isArray(this.path)?this.path[1]:this.path,[n,r]=function(e){const t=e.lastIndexOf("/"),n=e.lastIndexOf("?");return[e.substring(0,t)+"/",n>t?e.substring(n):""]}(t),a=this.weightPathPrefix||n,i=[];for(const t of e)i.push(...t.weights);const s=[],o=[];for(const t of e)for(const e of t.paths)null!=this.weightUrlConverter?o.push(this.weightUrlConverter(e)):s.push(a+e+r);return this.weightUrlConverter&&s.push(...await Promise.all(o)),[i,Ui(await Ps(s,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress}))]}}function qs(e){return null!=e.match(Us.URL_SCHEME_REGEX)}Us.URL_SCHEME_REGEX=/^https?:\/\//;const Ws=(e,t)=>{if("undefined"==typeof fetch&&(null==t||null==t.fetchFunc))return null;{let n=!0;if(n=Array.isArray(e)?e.every((e=>qs(e))):qs(e),n)return Vs(e,t)}return null};function Vs(e,t){return new Us(e,t)}function Gs(e,t){return Vs(e,t)}Ji.registerSaveRouter(Ws),Ji.registerLoadRouter(Ws);class Ks{constructor(e){this.modelArtifacts=e}load(){return this.modelArtifacts}}class Js{constructor(e){this.saveHandler=e}save(e){return this.saveHandler(e)}}class Xs{constructor(e){e.load&&(this.load=()=>Promise.resolve(e.load())),e.save&&(this.save=t=>Promise.resolve(e.save(t)))}}function Zs(e,t,n,r){const a=arguments;return new Xs(Qs(...a))}function Qs(e,t,n,r){return 1===arguments.length?null!=e.modelTopology||null!=e.weightSpecs?new Ks(e):(console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new Ks({modelTopology:e})):(console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new Ks({modelTopology:e,weightSpecs:t,weightData:n,trainingConfig:r}))}function eo(e){return new Js(e)}function to(e){return new Js(e)}const no=$i({matMul_:function(e,t,n=!1,r=!1){let a=Ci(e,"a","matMul"),i=Ci(t,"b","matMul");[a,i]=di(a,i);const s={a,b:i},o={transposeA:n,transposeB:r};return _i.runKernel(yt,s,o)}}),ro=$i({oneHot_:function(e,t,n=1,r=0){if(t<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${t}`);const a={indices:Ci(e,"indices","oneHot","int32")},i={depth:t,onValue:n,offValue:r};return _i.runKernel(er,a,i)}});function ao(){Ge().set("PROD",!0)}function io(){Ge().set("DEBUG",!0)}function so(){Ge().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function oo(e){Ge().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(e+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}function uo(){_i.disposeVariables()}function lo(){return _i}function co(){return _i.memory()}function po(e){return _i.profile(e)}function ho(e,t){return _i.tidy(e,t)}function fo(e){mi(e).forEach((e=>e.dispose()))}function mo(e){return _i.keep(e)}function go(e){return _i.time(e)}function yo(e){return _i.setBackend(e)}function bo(){return _i.ready()}function xo(){return _i.backendName}function vo(e){_i.removeBackend(e)}function _o(e){return _i.findBackend(e)}function wo(e){return _i.findBackendFactory(e)}function Mo(e,t,n=1){return _i.registerBackend(e,t,n)}function No(){return _i.backend}function So(e,t){Ge().setPlatform(e,t)}ei=oo;const ko=$i({imag_:function(e){const t={input:Ci(e,"input","imag")};return _i.runKernel(gn,t)}}),Do=$i({neg_:function(e){const t={x:Ci(e,"x","neg")};return _i.runKernel(Gn,t)}}),To=$i({real_:function(e){const t={input:Ci(e,"input","real")};return _i.runKernel(ur,t)}}),Io=$i({transpose_:function(e,t,n){const r=Ci(e,"x","transpose");if(null==t&&(t=r.shape.map(((e,t)=>t)).reverse()),se(r.rank===t.length,(()=>`Error in transpose: rank of input ${r.rank} must match length of perm ${t}.`)),t.forEach((e=>{se(e>=0&&e"All entries in 'perm' must be between 0 and "+(r.rank-1)+` but got ${t}`))})),r.rank<=1)return r.clone();const a={x:r},i={perm:t};return"complex64"===r.dtype?ho((()=>{let e=To(r),t=ko(r);return e=_i.runKernel(Zr,{x:e},i),t=_i.runKernel(Zr,{x:t},i),n&&(t=Do(t)),Oi(e,t)})):_i.runKernel(Zr,a,i)}}),Eo=$i({confusionMatrix_:function(e,t,n){const r=Ci(e,"labels","confusionMatrix"),a=Ci(t,"predictions","confusionMatrix");se(null==n||n>0&&Number.isInteger(n),(()=>`If provided, numClasses must be a positive integer, but got ${n}`)),se(1===r.rank,(()=>`Expected the rank of labels to be 1, but got ${r.rank}`)),se(1===a.rank,(()=>`Expected the rank of predictions to be 1, but got ${a.rank}`)),se(r.shape[0]===a.shape[0],(()=>`Mismatch in the number of examples: ${r.shape[0]} vs. ${a.shape[0]}. Labels and predictions should have the same number of elements.`)),se(n>0&&Number.isInteger(n),(()=>`numClasses is required to be a positive integer, but got ${n}`));const i=ro(Ls(r,"int32"),n),s=ro(Ls(a,"int32"),n),o=Io(i),u=no(o,s);return Ls(u,"int32")}});function Co(e,t){const n=e.length,r=[];for(let a=0;a1&&1===s&&r.unshift(i)}return r}function Ao(e,t){const n=[];for(let r=0;r1)&&n.unshift(i)}return n}function Lo(e,t){const n=[],r=Math.max(e.length,t.length);for(let a=0;a4)throw new Error("Cannot construct Tensor with more than 4 channels from pixels.");if(null==e)throw new Error("pixels passed to tf.browser.fromPixels() can not be null");let n=!1,r=!1,a=!1,i=!1,s=!1,o=!1;if(e.data instanceof Uint8Array)n=!0;else if("undefined"!=typeof ImageData&&e instanceof ImageData)r=!0;else if("undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement)a=!0;else if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement)i=!0;else if(null!=e.getContext)s=!0;else{if(!("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap))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 ${e.constructor.name}`);o=!0}if(a){const t=2;if(a&&e.readyState element.")}if(null!=fa(ia,_i.backendName)){const n={pixels:e},r={numChannels:t};return _i.runKernel(ia,n,r)}const[u,l]=a?[e.videoWidth,e.videoHeight]:[e.width,e.height];let c,p;if(s)c=e.getContext("2d").getImageData(0,0,u,l).data;else if(r||n)c=e.data;else if(i||a||o){if(null==Oo)if("undefined"==typeof document){if("undefined"==typeof OffscreenCanvas||"undefined"==typeof OffscreenCanvasRenderingContext2D)throw new Error("Cannot parse input in current context. Reason: OffscreenCanvas Context2D rendering is not supported.");Oo=new OffscreenCanvas(1,1).getContext("2d")}else Oo=document.createElement("canvas").getContext("2d",{willReadFrequently:!0});Oo.canvas.width=u,Oo.canvas.height=l,Oo.drawImage(e,0,0,u,l),c=Oo.getImageData(0,0,u,l).data}if(4===t)p=new Int32Array(c);else{const e=u*l;p=new Int32Array(e*t);for(let n=0;n4||2===i)throw new Error(`toPixels only supports depth of size 1, 3 or 4 but got ${i}`);if("float32"!==n.dtype&&"int32"!==n.dtype)throw new Error(`Unsupported type for toPixels: ${n.dtype}. Please use float32 or int32 tensors.`);const s=await n.data(),o="float32"===n.dtype?255:1,u=new Uint8ClampedArray(a*r*4);for(let e=0;e1)throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${a}.`)}else if("int32"===n.dtype&&(a<0||a>255))throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${a}.`);1===i?(t[0]=a*o,t[1]=a*o,t[2]=a*o):t[r]=a*o}const r=4*e;u[r+0]=Math.round(t[0]),u[r+1]=Math.round(t[1]),u[r+2]=Math.round(t[2]),u[r+3]=Math.round(t[3])}if(null!=t){t.width=a,t.height=r;const e=t.getContext("2d"),n=new ImageData(u,a,r);e.putImageData(n,0,0)}return n!==e&&n.dispose(),u}const zo=$i({fromPixels_:Ro});function Bo(e,t){const n=e.shape.length,r=t.shape.length;if(n<1)throw new Error(`tf.gatherND() expects the input to be rank 1 or higher, but the rank was ${n}.`);if(r<1)throw new Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${r}.`);if("int32"!==t.dtype)throw new Error(`tf.gatherND() expects the indices to be int32 type, but the dtype was ${t.dtype}.`);if(t.shape[r-1]>n)throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${t.shape[r-1]} vs. ${n}`);if(0===ce(e.shape))throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${e.shape}.`);const a=t.shape,i=a[a.length-1];let s=1;for(let e=0;ee/l)),1].slice(0,i);return[u,s,l,c]}function Po(e,t,n){const r=t.rank>1?t.shape[t.rank-1]:1,a=t.rank>1?t.rank-1:1,i=`Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${n.shape}, indices.shape: ${t.shape}, shape: ${e}, sliceDim: ${r}, and batchDim: ${a}.`;if(n.rank1?t.shape[r-1]:1,i=n.length;let s=1;for(let e=a;e`Error in slice${r}D: Length of begin ${t} must match the rank of the array (${r}).`)),se(r===n.length,(()=>`Error in slice${r}D: Length of size ${n} must match the rank of the array (${r}).`));for(let a=0;a`Error in slice${r}D: begin[${a}] + size[${a}] (${t[a]+n[a]}) would overflow input.shape[${a}] (${e.shape[a]})`))}function qo(e){const t=[];let n=0;for(;e>0;)1&e&&t.push(n),e/=2,n++;return t}function Wo(e,t,n){const r=[];for(let a=0;a0){const u=t[0],l=n+1;c=Xo(s,u,l,r,e),p=Zo(o,u,l,a,e),d=Vo(i,u,l,e)}else for(let t=0;t-1)i[a]=0;else{const s=Go(t,n,a);let o=r[s];e&1<-1)i[a]=Number.MAX_SAFE_INTEGER;else{const s=Go(t,n,a);let o=r[s];e&1<0?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER);const u=r[a];return s<0&&(s+=u),s=ee(0,s,u-1),s}function tu(e,t,n,r,a,i){let s=t[a];const o=n[a]||1;(e&1<0?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER);const u=r[a];return s<0&&(s+=u),s=o>0?ee(0,s,u):ee(-1,s,u-1),s}function nu(e,t,n){let r=n.length;for(let e=0;e1){r=e;break}for(let a=r+1;a0||n[a]!==e[a])return!1;return!0}function ru(e,t){let n=e.length>0?e[e.length-1]:1;for(let r=0;r{se(-1!==e,(()=>"slice() does not support negative begin indexing."))})),i=null==n?new Array(a).fill(-1):"number"==typeof n?[n,...new Array(a-1).fill(-1)]:n.lengtht>=0?t:(se(-1===t,(()=>`Negative size values should be exactly -1 but got ${t} for the slice() size at index ${n}.`)),e.shape[n]-r[n]))),[r,i]}function iu(e,t,n,r,a,i,s,o,u){let l;if(null==r?(l=new Array(t.length),l.fill(1)):l=r,null!=s&&0!=(s&s-1))throw new Error("Multiple ellipses in slice is not allowed.");let c=!1;const p={dims:l.length,numAddAxisAfterEllipsis:0,begin:t.slice(),end:n.slice(),strides:l.slice(),beginMask:a,endMask:i,ellipsisMask:s,newAxisMask:o,shrinkAxisMask:u};for(let e=0;e0?0:-1,d.strides[t]>0?r:r-1];if(n&&d.strides[t]<=0)throw Error("only stride 1 allowed on non-range indexing.");m=m&&1===d.strides[t];const s=!!(d.beginMask&1<=r)throw Error(`slice index ${d.begin[t]} of dimension ${t} out of bounds.`)}else d.begin[t]=su(d.begin[t],0,d.strides[t],r,a,i),d.end[t]=su(d.end[t],1,d.strides[t],r,a,i);const e=1===d.strides[t]&&0===d.begin[t]&&d.end[t]===r;h=h&&e,f=f&&(0===t&&1===d.strides[t]||e)}else h=h&&1===d.strides[t]&&s,f=f&&(0===t&&1===d.strides[t]||s);let o,u=!1;if(d.beginValid&&d.endValid?(o=d.end[t]-d.begin[t],u=!0):n?(o=1,u=!0):s&&r>=0&&(o=d.strides[t]<0?-r:r,u=!0),u){let e;e=0===o||o<0!=d.strides[t]<0?0:Math.trunc(o/d.strides[t])+(o%d.strides[t]!=0?1:0),g.push(e)}else g.push(-1)}for(let e=0;e=0?y.push(g[t]):-2===t&&y.push(1)}const b=y.filter(((e,t)=>-2!==d.finalShapeGatherIndices[t]));return{finalShapeSparse:b,finalShape:y,isIdentity:h,sliceDim0:f,isSimpleSlice:m,begin:d.begin,end:d.end,strides:d.strides}}function su(e,t,n,r,a,i){if(a[t])return n>0?i[t]:i[t+1&1];{const t=e<0?r+e:e;return ti[1]?i[1]:t}}class ou{getClassName(){return this.constructor.className}static fromConfig(e,t){return new e(t)}}class uu{constructor(){this.classNameMap={}}static getMap(){return null==uu.instance&&(uu.instance=new uu),uu.instance}static register(e){uu.getMap().classNameMap[e.className]=[e,e.fromConfig]}}function lu(e){se(null!=e.className,(()=>"Class being registered does not have the static className property defined.")),se("string"==typeof e.className,(()=>"className is required to be a string, but got type "+typeof e.className)),se(e.className.length>0,(()=>"Class being registered has an empty-string as its className, which is disallowed.")),uu.register(e)}const cu=.1;function pu(e,t,n){return null==n&&(n=du()),hu(e,t,((e,t)=>yu(e,t,n)))}function du(){return 32===_i.backend.floatPrecision()?.001:cu}function hu(e,t,n){let r=!0;if((De(e)||De(t))&&(r=!1),De(e)&&De(t)&&(r=!0),r){const n=e.constructor.name,r=t.constructor.name;if(n!==r)throw new Error(`Arrays are of different type. Actual: ${n}. Expected: ${r}`)}if(Array.isArray(e)&&Array.isArray(t)){const n=Ti(e),r=Ti(t);if(!de(n,r))throw new Error(`Arrays have different shapes. Actual: [${n}]. Expected: [${r}]`)}const a=De(e)?e:le(e),i=De(t)?t:le(t);if(a.length!==i.length)throw new Error(`Arrays have different lengths actual: ${a.length} vs expected: ${i.length}.\nActual: ${a}.\nExpected: ${i}.`);for(let e=0;et.fail()),(()=>t()))}function mu(e,t){const n="string"==typeof t||"number"==typeof t||"boolean"==typeof t?[t]:t;return Ee(e)||Ee(e[0])||Ee(t)||Ee(t[0])?hu(e,n,((e,t)=>e==t)):hu(e,t,((e,t)=>yu(e,t,0)))}function gu(e,t,n){if(null==n&&(n=du()),!yu(e,t,n))throw new Error(`Numbers differ: actual === ${e}, expected === ${t}`)}function yu(e,t,n){return!isFinite(e)&&!isFinite(t)||!(isNaN(e)||isNaN(t)||Math.abs(e-t)>n)}function bu(e,t,n){for(let r=0;rn)throw new Error(`Value out of range:${e[r]} low: ${t}, high: ${n}`)}function xu(e,t){const n=new Float32Array(e),r=new Float32Array(t);if(n.length!==r.length)throw new Error(`Expected ArrayBuffer to be of length ${r.length}, but it was ${n.length}`);for(let e=0;e"The f passed in grad(f) must be a function")),(t,n)=>{const r=Ci(t,"x","tf.grad","string_or_numeric"),a=null!=n?Ci(n,"dy","tf.grad"):null;return _i.tidy((()=>{const{value:t,grads:n}=_i.gradients((()=>e(r)),[r],a);return null!=a&&oe(t.shape,a.shape,"The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"),Ou(n),n[0]}))}}function Eu(e){return se($e(e),(()=>"The f passed in grads(f) must be a function")),(t,n)=>{se(Array.isArray(t),(()=>"The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s"));const r=Ai(t,"args","tf.grads","string_or_numeric"),a=null!=n?Ci(n,"dy","tf.grads"):null;return _i.tidy((()=>{const{value:t,grads:n}=_i.gradients((()=>e(...r)),r,a);return null!=a&&oe(t.shape,a.shape,"The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),Ou(n),n}))}}function Cu(e){return se($e(e),(()=>"The f passed in valueAndGrad(f) must be a function")),(t,n)=>{se(t instanceof ti,(()=>"The x passed in valueAndGrad(f)(x) must be a tensor")),se(null==n||n instanceof ti,(()=>"The dy passed in valueAndGrad(f)(x, dy) must be a tensor"));const{grads:r,value:a}=_i.gradients((()=>e(t)),[t],n);return Ou(r),{grad:r[0],value:a}}}function Au(e){return se($e(e),(()=>"The f passed in valueAndGrads(f) must be a function")),(t,n)=>{se(Array.isArray(t)&&t.every((e=>e instanceof ti)),(()=>"The args passed in valueAndGrads(f)(args) must be array of tensors")),se(null==n||n instanceof ti,(()=>"The dy passed in valueAndGrads(f)(args, dy) must be a tensor"));const r=_i.gradients((()=>e(...t)),t,n);return null!=n&&oe(r.value.shape,n.shape,"The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),Ou(r.grads),r}}function Lu(e,t){se($e(e),(()=>"The f passed in variableGrads(f) must be a function")),se(null==t||Array.isArray(t)&&t.every((e=>e instanceof ri)),(()=>"The varList passed in variableGrads(f, varList) must be an array of variables"));const n=null!=t;if(!n){t=[];for(const e in _i.registeredVariables)t.push(_i.registeredVariables[e])}const r=n?t.filter((e=>!e.trainable)):null,a=t.length;t=t.filter((e=>e.trainable)),se(t.length>0,(()=>`variableGrads() expects at least one of the input variables to be trainable, but none of the ${a} variables is trainable.`));const{value:i,grads:s}=_i.gradients(e,t,null,!0);se(s.some((e=>null!=e)),(()=>"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().")),se(0===i.rank,(()=>`The f passed in variableGrads(f) must return a scalar, but it returned a rank-${i.rank} tensor`));const o={};return t.forEach(((e,t)=>{null!=s[t]&&(o[e.name]=s[t])})),null!=r&&r.forEach((e=>o[e.name]=null)),{value:i,grads:o}}function $u(e){return _i.customGrad(e)}function Ou(e){if(e.filter((e=>null==e)).length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that\n the f you passed encloses all operations that lead from x to y.")}function Ru(e,t){if((De(e)&&"string"!==t||Array.isArray(e))&&"complex64"!==t)throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");if("string"===t&&De(e)&&!(e instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return Ri(e,[],[],t)}class Fu extends ou{minimize(e,t=!1,n){const{value:r,grads:a}=this.computeGradients(e,n);if(null!=n){const e=n.map((e=>({name:e.name,tensor:a[e.name]})));this.applyGradients(e)}else this.applyGradients(a);return fo(a),t?r:(r.dispose(),null)}get iterations(){return null==this.iterations_&&(this.iterations_=0),this.iterations_}incrementIterations(){this.iterations_=this.iterations+1}computeGradients(e,t){return Lu(e,t)}dispose(){null!=this.iterations_&&fo(this.iterations_)}async saveIterations(){return null==this.iterations_&&(this.iterations_=0),{name:"iter",tensor:Ru(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(Fu,Symbol.hasInstance,{value:e=>null!=e.minimize&&null!=e.computeGradients&&null!=e.applyGradients});class Yu extends Fu{constructor(e,t,n=null){super(),this.learningRate=e,this.rho=t,this.epsilon=n,this.accumulatedGrads=[],this.accumulatedUpdates=[],null==n&&(this.epsilon=_i.backend.epsilon())}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=_i.registeredVariables[t];null==this.accumulatedGrads[n]&&(this.accumulatedGrads[n]={originalName:`${t}/accum_grad`,variable:ho((()=>Tu(r).variable(!1)))}),null==this.accumulatedUpdates[n]&&(this.accumulatedUpdates[n]={originalName:`${t}/accum_var`,variable:ho((()=>Tu(r).variable(!1)))});const a=Array.isArray(e)?e[n].tensor:e[t];if(null==a)return;const i=this.accumulatedGrads[n].variable,s=this.accumulatedUpdates[n].variable;ho((()=>{const e=wu(Su(i,this.rho),Su(Du(a),1-this.rho)),t=Su(Nu(ku(wu(s,this.epsilon)),ku(wu(i,this.epsilon))),a),n=wu(Su(s,this.rho),Su(Du(t),1-this.rho));i.assign(e),s.assign(n);const o=wu(Su(t,-this.learningRate),r);r.assign(o)}))})),this.incrementIterations()}dispose(){null!=this.accumulatedUpdates&&(fo(this.accumulatedGrads.map((e=>e.variable))),fo(this.accumulatedUpdates.map((e=>e.variable))))}async getWeights(){const e=[...this.accumulatedGrads,...this.accumulatedUpdates];return[await this.saveIterations()].concat(e.map((e=>({name:e.originalName,tensor:e.variable}))))}async setWeights(e){const t=(e=await this.extractIterations(e)).length/2;this.accumulatedGrads=e.slice(0,t).map((e=>({originalName:e.name,variable:e.tensor.variable(!1)}))),this.accumulatedUpdates=e.slice(t,2*t).map((e=>({originalName:e.name,variable:e.tensor.variable(!1)})))}getConfig(){return{learningRate:this.learningRate,rho:this.rho,epsilon:this.epsilon}}static fromConfig(e,t){return new e(t.learningRate,t.rho,t.epsilon)}}function zu(e,t,n){const r={shape:e,value:t,dtype:n};return _i.runKernel(an,{},r)}Yu.className="Adadelta",lu(Yu);class Bu extends Fu{constructor(e,t=.1){super(),this.learningRate=e,this.initialAccumulatorValue=t,this.accumulatedGrads=[]}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=_i.registeredVariables[t];if(null==this.accumulatedGrads[n]){const e=!1;this.accumulatedGrads[n]={originalName:`${t}/accumulator`,variable:ho((()=>zu(r.shape,this.initialAccumulatorValue).variable(e)))}}const a=Array.isArray(e)?e[n].tensor:e[t];if(null==a)return;const i=this.accumulatedGrads[n].variable;ho((()=>{const e=wu(i,Du(a));i.assign(e);const t=wu(Su(Nu(a,ku(wu(e,_i.backend.epsilon()))),-this.learningRate),r);r.assign(t)}))})),this.incrementIterations()}dispose(){null!=this.accumulatedGrads&&fo(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),this.accumulatedGrads=e.map((e=>({originalName:e.name,variable:e.tensor.variable(!1)})))}getConfig(){return{learningRate:this.learningRate,initialAccumulatorValue:this.initialAccumulatorValue}}static fromConfig(e,t){return new e(t.learningRate,t.initialAccumulatorValue)}}Bu.className="Adagrad",lu(Bu);const Pu=$i({pow_:function(e,t){let n=Ci(e,"base","pow"),r=Ci(t,"exp","pow");[n,r]=di(n,r);const a={a:n,b:r};return _i.runKernel(ar,a)}}),Hu=$i({sub_:function(e,t){let n=Ci(e,"a","sub"),r=Ci(t,"b","sub");[n,r]=di(n,r);const a={a:n,b:r};return _i.runKernel(Wr,a)}});class ju extends Fu{constructor(e,t,n,r=null){super(),this.learningRate=e,this.beta1=t,this.beta2=n,this.epsilon=r,this.accumulatedFirstMoment=[],this.accumulatedSecondMoment=[],ho((()=>{this.accBeta1=Ru(t).variable(),this.accBeta2=Ru(n).variable()})),null==r&&(this.epsilon=_i.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);ho((()=>{const n=Hu(1,this.accBeta1),r=Hu(1,this.accBeta2);t.forEach(((t,a)=>{const i=_i.registeredVariables[t];null==this.accumulatedFirstMoment[a]&&(this.accumulatedFirstMoment[a]={originalName:`${t}/m`,variable:ho((()=>Tu(i).variable(!1)))}),null==this.accumulatedSecondMoment[a]&&(this.accumulatedSecondMoment[a]={originalName:`${t}/v`,variable:ho((()=>Tu(i).variable(!1)))});const s=Array.isArray(e)?e[a].tensor:e[t];if(null==s)return;const o=this.accumulatedFirstMoment[a].variable,u=this.accumulatedSecondMoment[a].variable,l=wu(Su(o,this.beta1),Su(s,1-this.beta1)),c=wu(Su(u,this.beta2),Su(Du(s),1-this.beta2)),p=Nu(l,n),d=Nu(c,r);o.assign(l),u.assign(c);const h=wu(Su(Nu(p,wu(ku(d),this.epsilon)),-this.learningRate),i);i.assign(h)})),this.accBeta1.assign(Su(this.accBeta1,this.beta1)),this.accBeta2.assign(Su(this.accBeta2,this.beta2))})),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.accBeta2.dispose(),null!=this.accumulatedFirstMoment&&fo(this.accumulatedFirstMoment.map((e=>e.variable))),null!=this.accumulatedSecondMoment&&fo(this.accumulatedSecondMoment.map((e=>e.variable)))}async getWeights(){const e=[...this.accumulatedFirstMoment,...this.accumulatedSecondMoment];return[await this.saveIterations()].concat(e.map((e=>({name:e.originalName,tensor:e.variable}))))}async setWeights(e){e=await this.extractIterations(e),ho((()=>{this.accBeta1.assign(Pu(this.beta1,this.iterations_+1)),this.accBeta2.assign(Pu(this.beta2,this.iterations_+1))}));const t=e.length/2;this.accumulatedFirstMoment=e.slice(0,t).map((e=>({originalName:e.name,variable:e.tensor.variable(!1)}))),this.accumulatedSecondMoment=e.slice(t,2*t).map((e=>({originalName:e.name,variable:e.tensor.variable(!1)})))}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)}}ju.className="Adam",lu(ju);const Uu=$i({abs_:function(e){const t=Ci(e,"x","abs");if("complex64"===t.dtype){const e={x:t};return _i.runKernel(kt,e)}{const e={x:t};return _i.runKernel(Qe,e)}}}),qu=$i({maximum_:function(e,t){let n=Ci(e,"a","maximum"),r=Ci(t,"b","maximum");[n,r]=di(n,r),"bool"===n.dtype&&(n=Ls(n,"int32"),r=Ls(r,"int32")),Lo(n.shape,r.shape);const a={a:n,b:r};return _i.runKernel(On,a)}});class Wu extends Fu{constructor(e,t,n,r=null,a=0){super(),this.learningRate=e,this.beta1=t,this.beta2=n,this.epsilon=r,this.decay=a,this.accumulatedFirstMoment=[],this.accumulatedWeightedInfNorm=[],ho((()=>{this.iteration=Ru(0).variable(),this.accBeta1=Ru(t).variable()})),null==r&&(this.epsilon=_i.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);ho((()=>{const n=Hu(1,this.accBeta1),r=Nu(-this.learningRate,wu(Su(this.iteration,this.decay),1));t.forEach(((t,a)=>{const i=_i.registeredVariables[t];null==this.accumulatedFirstMoment[a]&&(this.accumulatedFirstMoment[a]={originalName:`${t}/m`,variable:Tu(i).variable(!1)}),null==this.accumulatedWeightedInfNorm[a]&&(this.accumulatedWeightedInfNorm[a]={originalName:`${t}/v`,variable:Tu(i).variable(!1)});const s=Array.isArray(e)?e[a].tensor:e[t];if(null==s)return;const o=this.accumulatedFirstMoment[a].variable,u=this.accumulatedWeightedInfNorm[a].variable,l=wu(Su(o,this.beta1),Su(s,1-this.beta1)),c=Su(u,this.beta2),p=Uu(s),d=qu(c,p);o.assign(l),u.assign(d);const h=wu(Su(Nu(r,n),Nu(l,wu(d,this.epsilon))),i);i.assign(h)})),this.iteration.assign(wu(this.iteration,1)),this.accBeta1.assign(Su(this.accBeta1,this.beta1))})),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.iteration.dispose(),null!=this.accumulatedFirstMoment&&fo(this.accumulatedFirstMoment.map((e=>e.variable))),null!=this.accumulatedWeightedInfNorm&&fo(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)}}Wu.className="Adamax",lu(Wu);class Vu extends Fu{constructor(e){super(),this.learningRate=e,this.setLearningRate(e)}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=Array.isArray(e)?e[n].tensor:e[t];if(null==r)return;const a=_i.registeredVariables[t];ho((()=>{const e=wu(Su(this.c,r),a);a.assign(e)}))})),this.incrementIterations()}setLearningRate(e){this.learningRate=e,null!=this.c&&this.c.dispose(),this.c=mo(Ru(-e))}dispose(){this.c.dispose()}async getWeights(){return[await this.saveIterations()]}async setWeights(e){if(0!==(e=await this.extractIterations(e)).length)throw new Error("SGD optimizer does not have settable weights.")}getConfig(){return{learningRate:this.learningRate}}static fromConfig(e,t){return new e(t.learningRate)}}Vu.className="SGD",lu(Vu);class Gu extends Vu{constructor(e,t,n=!1){super(e),this.learningRate=e,this.momentum=t,this.useNesterov=n,this.accumulations=[],this.m=Ru(this.momentum)}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=_i.registeredVariables[t];if(null==this.accumulations[n]){const e=!1;this.accumulations[n]={originalName:`${t}/momentum`,variable:ho((()=>Tu(r).variable(e)))}}const a=this.accumulations[n].variable,i=Array.isArray(e)?e[n].tensor:e[t];null!=i&&ho((()=>{let e;const t=wu(Su(this.m,a),i);e=this.useNesterov?wu(Su(this.c,wu(i,Su(t,this.m))),r):wu(Su(this.c,t),r),a.assign(t),r.assign(e)}))})),this.incrementIterations()}dispose(){this.m.dispose(),null!=this.accumulations&&fo(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),this.accumulations=e.map((e=>({originalName:e.name,variable:e.tensor.variable(!1)})))}getConfig(){return{learningRate:this.learningRate,momentum:this.momentum,useNesterov:this.useNesterov}}static fromConfig(e,t){return new e(t.learningRate,t.momentum,t.useNesterov)}}Gu.className="Momentum",lu(Gu);class Ku extends Fu{constructor(e,t=.9,n=0,r=null,a=!1){if(super(),this.learningRate=e,this.decay=t,this.momentum=n,this.epsilon=r,this.accumulatedMeanSquares=[],this.accumulatedMoments=[],this.accumulatedMeanGrads=[],this.centered=a,null==r&&(this.epsilon=_i.backend.epsilon()),null==e)throw new Error("learningRate for RMSPropOptimizer must be defined.")}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=_i.registeredVariables[t],a=!1;null==this.accumulatedMeanSquares[n]&&(this.accumulatedMeanSquares[n]={originalName:`${t}/rms`,variable:ho((()=>Tu(r).variable(a)))}),null==this.accumulatedMoments[n]&&(this.accumulatedMoments[n]={originalName:`${t}/momentum`,variable:ho((()=>Tu(r).variable(a)))}),null==this.accumulatedMeanGrads[n]&&this.centered&&(this.accumulatedMeanGrads[n]={originalName:`${t}/mg`,variable:ho((()=>Tu(r).variable(a)))});const i=Array.isArray(e)?e[n].tensor:e[t];if(null==i)return;const s=this.accumulatedMeanSquares[n].variable,o=this.accumulatedMoments[n].variable;ho((()=>{const e=wu(Su(s,this.decay),Su(Du(i),1-this.decay));if(this.centered){const t=this.accumulatedMeanGrads[n].variable,a=wu(Su(t,this.decay),Su(i,1-this.decay)),u=Nu(Su(i,this.learningRate),ku(Hu(e,wu(Du(a),this.epsilon)))),l=wu(Su(o,this.momentum),u);s.assign(e),t.assign(a),o.assign(l);const c=Hu(r,l);r.assign(c)}else{const e=wu(Su(s,this.decay),Su(Du(i),1-this.decay)),t=wu(Su(o,this.momentum),Nu(Su(i,this.learningRate),ku(wu(e,this.epsilon))));s.assign(e),o.assign(t);const n=Hu(r,t);r.assign(n)}}))})),this.incrementIterations()}dispose(){null!=this.accumulatedMeanSquares&&fo(this.accumulatedMeanSquares.map((e=>e.variable))),null!=this.accumulatedMeanGrads&&this.centered&&fo(this.accumulatedMeanGrads.map((e=>e.variable))),null!=this.accumulatedMoments&&fo(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((e=>({name:e.originalName,tensor:e.variable}))))}async setWeights(e){e=await this.extractIterations(e);const t=this.centered?e.length/3:e.length/2,n=!1;this.accumulatedMeanSquares=e.slice(0,t).map((e=>({originalName:e.name,variable:e.tensor.variable(n)}))),this.accumulatedMoments=e.slice(t,2*t).map((e=>({originalName:e.name,variable:e.tensor.variable(n)}))),this.centered&&(this.accumulatedMeanGrads=e.slice(2*t,3*t).map((e=>({originalName:e.name,variable:e.tensor.variable(n)}))))}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)}}Ku.className="RMSProp",lu(Ku);class Ju{static sgd(e){return new Vu(e)}static momentum(e,t,n=!1){return new Gu(e,t,n)}static rmsprop(e,t=.9,n=0,r=null,a=!1){return new Ku(e,t,n,r,a)}static adam(e=.001,t=.9,n=.999,r=null){return new ju(e,t,n,r)}static adadelta(e=.001,t=.95,n=null){return new Yu(e,t,n)}static adamax(e=.002,t=.9,n=.999,r=null,a=0){return new Wu(e,t,n,r,a)}static adagrad(e,t=.1){return new Bu(e,t)}}const Xu=$i({acos_:function(e){const t={x:Ci(e,"x","acos")};return _i.runKernel(et,t)}}),Zu=$i({acosh_:function(e){const t={x:Ci(e,"x","acosh")};return _i.runKernel(tt,t)}}),Qu=$i({addN_:function(e){se(Array.isArray(e),(()=>"The argument passed to tf.addN() must be a list of tensors")),se(e.length>=1,(()=>`Must pass at least one tensor to tf.addN(), but got ${e.length}`));const t=e.map(((e,t)=>Ci(e,`tensors${t}`,"addN"))),n=t[0];t.forEach((e=>{if(e.dtype!==n.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")})),t.forEach((e=>{if(!de(e.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")}));const r=t;return _i.runKernel(rt,r)}}),el=$i({all_:function(e,t=null,n=!1){const r={x:Ci(e,"x","all","bool")},a={axis:t,keepDims:n};return _i.runKernel(at,r,a)}}),tl=$i({any_:function(e,t=null,n=!1){const r={x:Ci(e,"x","any","bool")},a={axis:t,keepDims:n};return _i.runKernel(it,r,a)}}),nl=$i({argMax_:function(e,t=0){const n={x:Ci(e,"x","argMax")},r={axis:t};return _i.runKernel(st,n,r)}}),rl=$i({argMin_:function(e,t=0){const n={x:Ci(e,"x","argMin")},r={axis:t};return _i.runKernel(ot,n,r)}}),al=$i({asin_:function(e){const t={x:Ci(e,"x","asin")};return _i.runKernel(ut,t)}}),il=$i({asinh_:function(e){const t={x:Ci(e,"x","asinh")};return _i.runKernel(lt,t)}}),sl=$i({atan_:function(e){const t={x:Ci(e,"x","atan")};return _i.runKernel(ct,t)}}),ol=$i({atan2_:function(e,t){let n=Ci(e,"a","atan2"),r=Ci(t,"b","atan2");[n,r]=di(n,r);const a={a:n,b:r};return _i.runKernel(dt,a)}}),ul=$i({atanh_:function(e){const t={x:Ci(e,"x","atanh")};return _i.runKernel(pt,t)}});function ll(e,t,n,r,a="NHWC",i){return dl(e,[...t,e[3]],n,i,r,null,null,_l(a))}function cl(e,t,n,r,a,i,s="channelsLast"){const[o,u]=ml(t);let l;if("channelsLast"===s)l=[o,u,e[3],e[3]];else{if("channelsFirst"!==s)throw new Error(`Unknown dataFormat ${s}`);l=[o,u,e[1],e[1]]}return dl(e,l,n,r,a,i,!1,s)}function pl(e,t,n,r,a,i,s="NDHWC"){const[o,u,l]=gl(t);let c,p;if("NDHWC"===s)p="channelsLast",c=[o,u,l,e[4],e[4]];else{if("NCDHW"!==s)throw new Error(`Unknown dataFormat ${s}`);p="channelsFirst",c=[o,u,l,e[1],e[1]]}return hl(e,c,n,r,a,!1,p,i)}function dl(e,t,n,r,a,i,s=!1,o="channelsLast"){let[u,l,c,p]=[-1,-1,-1,-1];if("channelsLast"===o)[u,l,c,p]=e;else{if("channelsFirst"!==o)throw new Error(`Unknown dataFormat ${o}`);[u,p,l,c]=e}const[d,h,,f]=t,[m,g]=ml(n),[y,b]=ml(r),x=yl(d,y),v=yl(h,b),{padInfo:_,outHeight:w,outWidth:M}=function(e,t,n,r,a,i,s,o,u){let l,c,p;if("number"==typeof e){l={top:e,bottom:e,left:e,right:e,type:0===e?"VALID":"NUMBER"};const a=function(e,t,n,r,a){null==r&&(r=fl(e,t,n));const i=e[1];return[bl((e[0]-t+2*r)/n+1,a),bl((i-t+2*r)/n+1,a)]}([t,n],i,r,e,o);c=a[0],p=a[1]}else if("same"===e){c=Math.ceil(t/r),p=Math.ceil(n/a);const e=Math.max(0,(c-1)*r+i-t),o=Math.max(0,(p-1)*a+s-n),u=Math.floor(e/2),d=e-u,h=Math.floor(o/2);l={top:u,bottom:d,left:h,right:o-h,type:"SAME"}}else if("valid"===e)l={top:0,bottom:0,left:0,right:0,type:"VALID"},c=Math.ceil((t-i+1)/r),p=Math.ceil((n-s+1)/a);else{if("object"!=typeof e)throw Error(`Unknown padding parameter: ${e}`);{const d="channelsLast"===u?e[1][0]:e[2][0],h="channelsLast"===u?e[1][1]:e[2][1],f="channelsLast"===u?e[2][0]:e[3][0],m="channelsLast"===u?e[2][1]:e[3][1];l={top:d,bottom:h,left:f,right:m,type:0===d&&0===h&&0===f&&0===m?"VALID":"EXPLICIT"},c=bl((t-i+d+h)/r+1,o),p=bl((n-s+f+m)/a+1,o)}}return{padInfo:l,outHeight:c,outWidth:p}}(a,l,c,m,g,x,v,i,o),N=s?f*p:f;let S;return"channelsFirst"===o?S=[u,N,w,M]:"channelsLast"===o&&(S=[u,w,M,N]),{batchSize:u,dataFormat:o,inHeight:l,inWidth:c,inChannels:p,outHeight:w,outWidth:M,outChannels:N,padInfo:_,strideHeight:m,strideWidth:g,filterHeight:d,filterWidth:h,effectiveFilterHeight:x,effectiveFilterWidth:v,dilationHeight:y,dilationWidth:b,inShape:e,outShape:S,filterShape:t}}function hl(e,t,n,r,a,i=!1,s="channelsLast",o){let[u,l,c,p,d]=[-1,-1,-1,-1,-1];if("channelsLast"===s)[u,l,c,p,d]=e;else{if("channelsFirst"!==s)throw new Error(`Unknown dataFormat ${s}`);[u,d,l,c,p]=e}const[h,f,m,,g]=t,[y,b,x]=gl(n),[v,_,w]=gl(r),M=yl(h,v),N=yl(f,_),S=yl(m,w),{padInfo:k,outDepth:D,outHeight:T,outWidth:I}=function(e,t,n,r,a,i,s,o,u,l,c){let p,d,h,f;if("number"==typeof e){p={top:e,bottom:e,left:e,right:e,front:e,back:e,type:0===e?"VALID":"NUMBER"};const i=function(e,t,n,r,a,i){null==a&&(a=fl(e,t,r));const s=e[1],o=e[2];return[bl((e[0]-t+2*a)/r+1,i),bl((s-t+2*a)/r+1,i),bl((o-t+2*a)/r+1,i),1]}([t,n,r,1],o,0,a,e,c);d=i[0],h=i[1],f=i[2]}else if("same"===e){d=Math.ceil(t/a),h=Math.ceil(n/i),f=Math.ceil(r/s);const e=(d-1)*a+o-t,c=(h-1)*i+u-n,m=(f-1)*s+l-r,g=Math.floor(e/2),y=e-g,b=Math.floor(c/2),x=c-b,v=Math.floor(m/2);p={top:b,bottom:x,left:v,right:m-v,front:g,back:y,type:"SAME"}}else{if("valid"!==e)throw Error(`Unknown padding parameter: ${e}`);p={top:0,bottom:0,left:0,right:0,front:0,back:0,type:"VALID"},d=Math.ceil((t-o+1)/a),h=Math.ceil((n-u+1)/i),f=Math.ceil((r-l+1)/s)}return{padInfo:p,outDepth:d,outHeight:h,outWidth:f}}(a,l,c,p,y,b,x,M,N,S,o),E=i?g*d:g;let C;return"channelsFirst"===s?C=[u,E,D,T,I]:"channelsLast"===s&&(C=[u,D,T,I,E]),{batchSize:u,dataFormat:s,inDepth:l,inHeight:c,inWidth:p,inChannels:d,outDepth:D,outHeight:T,outWidth:I,outChannels:E,padInfo:k,strideDepth:y,strideHeight:b,strideWidth:x,filterDepth:h,filterHeight:f,filterWidth:m,effectiveFilterDepth:M,effectiveFilterHeight:N,effectiveFilterWidth:S,dilationDepth:v,dilationHeight:_,dilationWidth:w,inShape:e,outShape:C,filterShape:t}}function fl(e,t,n,r=1){const a=yl(t,r);return Math.floor((e[0]*(n-1)-n+a)/2)}function ml(e){return"number"==typeof e?[e,e,e]:2===e.length?[e[0],e[1],1]:e}function gl(e){return"number"==typeof e?[e,e,e]:e}function yl(e,t){return t<=1?e:e+(e-1)*(t-1)}function bl(e,t){if(!t)return Math.trunc(e);switch(t){case"round":return Math.round(e);case"ceil":return Math.ceil(e);case"floor":return Math.floor(e);default:throw new Error(`Unknown roundingMode ${t}`)}}function xl(e){const[t,n,r]=ml(e);return 1===t&&1===n&&1===r}function vl(e,t){return xl(e)||xl(t)}function _l(e){if("NHWC"===e)return"channelsLast";if("NCHW"===e)return"channelsFirst";throw new Error(`Unknown dataFormat ${e}`)}function wl(e,t,n){if(null!=n){if("string"==typeof t)throw Error(`Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`);if("number"==typeof t)se(he(t),(()=>`Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`));else{if("object"!=typeof t)throw Error(`Error in ${e}: Unknown padding parameter: ${t}`);t.forEach((t=>{t.forEach((t=>{se(he(t),(()=>`Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`))}))}))}}}const Ml=$i({reshape_:function(e,t){const n={x:Ci(e,"x","reshape","string_or_numeric")},r={shape:t};return _i.runKernel(pr,n,r)}}),Nl=$i({avgPool_:function(e,t,n,r,a){const i=Ci(e,"x","avgPool","float32");se(vl(n,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`));let s=i,o=!1;3===i.rank&&(o=!0,s=Ml(i,[1,i.shape[0],i.shape[1],i.shape[2]])),se(4===s.rank,(()=>`Error in avgPool: x must be rank 4 but got rank ${s.rank}.`)),wl("avgPool",r,a);const u={x:s},l={filterSize:t,strides:n,pad:r,dimRoundingMode:a};let c=_i.runKernel(ht,u,l);return c=Ls(c,i.dtype),o?Ml(c,[c.shape[1],c.shape[2],c.shape[3]]):c}}),Sl=$i({avgPool3d_:function(e,t,n,r,a,i="NDHWC"){const s=Ci(e,"x","avgPool3d","float32");let o=s,u=!1;4===s.rank&&(u=!0,o=Ml(s,[1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]])),se(5===o.rank,(()=>`Error in avgPool3d: x must be rank 5 but got rank ${o.rank}.`)),se("NDHWC"===i,(()=>`Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${i}`)),wl("avgPool3d",r,a);const l={x:o},c={filterSize:t,strides:n,pad:r,dimRoundingMode:a,dataFormat:i};let p=_i.runKernel(mt,l,c);return p=Ls(p,o.dtype),u?Ml(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}}),kl=$i({concat_:function(e,t=0){se(e.length>=1,(()=>"Pass at least one tensor to concat"));const n=Ai(e,"tensors","concat","string_or_numeric");if("complex64"===n[0].dtype&&n.forEach((e=>{if("complex64"!==e.dtype)throw new Error(`Cannot concatenate complex64 tensors with a tensor\n with dtype ${e.dtype}. `)})),1===n.length)return $s(n[0]);const r=n,a={axis:t};return _i.runKernel(Dt,r,a)}}),Dl=$i({sigmoid_:function(e){const t={x:Ci(e,"x","sigmoid","float32")};return _i.runKernel(Tr,t)}}),Tl=$i({slice_:function(e,t,n){const r=Ci(e,"x","slice","string_or_numeric");if(0===r.rank)throw new Error("Slicing scalar is not possible");const a={x:r},i={begin:t,size:n};return _i.runKernel(Nr,a,i)}}),Il=$i({tanh_:function(e){const t={x:Ci(e,"x","tanh","float32")};return _i.runKernel(Gr,t)}}),El=$i({basicLSTMCell_:function(e,t,n,r,a,i){const s=Ci(e,"forgetBias","basicLSTMCell"),o=Ci(t,"lstmKernel","basicLSTMCell"),u=Ci(n,"lstmBias","basicLSTMCell"),l=Ci(r,"data","basicLSTMCell"),c=Ci(a,"c","basicLSTMCell"),p=Ci(i,"h","basicLSTMCell"),d=kl([l,p],1),h=no(d,o),f=wu(h,u),m=f.shape[0],g=f.shape[1]/4,y=[m,g],b=Tl(f,[0,0],y),x=Tl(f,[0,g],y),v=Tl(f,[0,2*g],y),_=Tl(f,[0,3*g],y),w=wu(Su(Dl(b),Il(x)),Su(c,Dl(wu(s,v))));return[w,Su(Il(w),Dl(_))]}}),Cl=$i({batchToSpaceND_:function(e,t,n){const r=Ci(e,"x","batchToSpaceND"),a=t.reduce(((e,t)=>e*t));se(r.rank>=1+t.length,(()=>`input rank is ${r.rank} but should be > than blockShape.length ${t.length}`)),se(n.length===t.length,(()=>`crops.length is ${n.length} but should be equal to blockShape.length ${t.length}`)),se(r.shape[0]%a==0,(()=>`input tensor batch is ${r.shape[0]} but is not divisible by the product of the elements of blockShape ${t.join(" * ")} === ${a}`));const i={x:r},s={blockShape:t,crops:n};return _i.runKernel(bt,i,s)}}),Al=$i({batchNorm_:function(e,t,n,r,a,i){null==i&&(i=.001);const s=Ci(e,"x","batchNorm"),o=Ci(t,"mean","batchNorm"),u=Ci(n,"variance","batchNorm");let l,c;null!=a&&(l=Ci(a,"scale","batchNorm")),null!=r&&(c=Ci(r,"offset","batchNorm")),se(o.rank===u.rank,(()=>"Batch normalization gradient requires mean and variance to have equal ranks.")),se(null==c||o.rank===c.rank,(()=>"Batch normalization gradient requires mean and offset to have equal ranks.")),se(null==l||o.rank===l.rank,(()=>"Batch normalization gradient requires mean and scale to have equal ranks."));const p=function(e){let t;return t=0===e.rank||1===e.rank?Ml(e,[1,1,1,e.size]):2===e.rank?Ml(e,[1,1,e.shape[0],e.shape[1]]):3===e.rank?Ml(e,[1,e.shape[0],e.shape[1],e.shape[2]]):e,t}(s),d={x:p,scale:l,offset:c,mean:o,variance:u},h={varianceEpsilon:i},f=_i.runKernel(ln,d,h);return Ml(f,s.shape)}}),Ll=$i({batchNorm2d_:function(e,t,n,r,a,i){const s=Ci(e,"x","batchNorm"),o=Ci(t,"mean","batchNorm"),u=Ci(n,"variance","batchNorm");let l,c;return null!=a&&(l=Ci(a,"scale","batchNorm")),null!=r&&(c=Ci(r,"offset","batchNorm")),se(2===s.rank,(()=>`Error in batchNorm2D: x must be rank 2 but got rank ${s.rank}.`)),se(2===o.rank||1===o.rank,(()=>`Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${o.rank}.`)),se(2===u.rank||1===u.rank,(()=>`Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${u.rank}.`)),null!=l&&se(2===l.rank||1===l.rank,(()=>`Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${l.rank}.`)),null!=c&&se(2===c.rank||1===c.rank,(()=>`Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${c.rank}.`)),Al(s,o,u,c,l,i)}}),$l=$i({batchNorm3d_:function(e,t,n,r,a,i){const s=Ci(e,"x","batchNorm"),o=Ci(t,"mean","batchNorm"),u=Ci(n,"variance","batchNorm");let l,c;return null!=a&&(l=Ci(a,"scale","batchNorm")),null!=r&&(c=Ci(r,"offset","batchNorm")),se(3===s.rank,(()=>`Error in batchNorm3D: x must be rank 3 but got rank ${s.rank}.`)),se(3===o.rank||1===o.rank,(()=>`Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${o.rank}.`)),se(3===u.rank||1===u.rank,(()=>`Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${u.rank}.`)),null!=l&&se(3===l.rank||1===l.rank,(()=>`Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${l.rank}.`)),null!=c&&se(3===c.rank||1===c.rank,(()=>`Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${c.rank}.`)),Al(s,o,u,c,l,i)}}),Ol=$i({batchNorm4d_:function(e,t,n,r,a,i){const s=Ci(e,"x","batchNorm"),o=Ci(t,"mean","batchNorm"),u=Ci(n,"variance","batchNorm");let l,c;return null!=a&&(l=Ci(a,"scale","batchNorm")),null!=r&&(c=Ci(r,"offset","batchNorm")),se(4===s.rank,(()=>`Error in batchNorm4D: x must be rank 4 but got rank ${s.rank}.`)),se(4===o.rank||1===o.rank,(()=>`Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${o.rank}.`)),se(4===u.rank||1===u.rank,(()=>`Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${u.rank}.`)),null!=l&&se(4===l.rank||1===l.rank,(()=>`Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${l.rank}.`)),null!=c&&se(4===c.rank||1===c.rank,(()=>`Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${c.rank}.`)),Al(s,o,u,c,l,i)}}),Rl=$i({bincount_:function(e,t,n){const r=Ci(e,"x","bincount"),a=Ci(t,"weights","bincount");se("int32"===r.dtype,(()=>`Error in bincount: input dtype must be int32, but got ${r.dtype}`)),se(n>=0,(()=>`size must be non-negative, but got ${n}.`)),se(a.size===r.size||0===a.size,(()=>`Error in bincount: weights must have the same size as input or0-length, but got input shape: ${r.shape}, weights shape: ${a.shape}.`));const i={x:r,weights:a},s={size:n};return _i.runKernel(xt,i,s)}}),Fl=$i({broadcastArgs_:function(e,t){const n=Ci(e,"s0","broadcastArgs","int32"),r=Ci(t,"s1","broadcastArgs","int32");if(1!==n.rank)throw new Error(`broadcastArgs(): first input must be a vector (rank=1). Has rank ${n.rank}`);if(1!==r.rank)throw new Error(`broadcastArgs(): second input must be a vector (rank=1). Has rank ${r.rank}`);const a={s0:n,s1:r};return _i.runKernel(_t,a)}}),Yl=$i({broadcastTo_:function(e,t){let n=Ci(e,"broadcastTo","x");const r=n.shape;if(t.some((e=>!(e>0)||e%1!=0)))throw new Error(`broadcastTo(): Invalid broadcast shape [${t}].`);if(t.lengthn.rank){const e=n.shape.slice();for(;e.length=0;e--)if(a[e]===t[e])i[e]=1;else if(1!==n.shape[e])throw new Error(`broadcastTo(): [${r}] cannot be broadcast to [${t}].`);const s=i.map(((e,t)=>e>1?t:-1)).filter((e=>e>=0));if(0===s.length)return $s(n);const o={x:n},u={reps:i};return _i.runKernel(Kr,o,u)}}),zl=$i({ceil_:function(e){const t={x:Ci(e,"x","ceil","float32")};return _i.runKernel(Mt,t)}}),Bl=$i({clipByValue_:function(e,t,n){const r=Ci(e,"x","clipByValue");se(t<=n,(()=>`Error in clip: min (${t}) must be less than or equal to max (${n}).`));const a={x:r},i={clipValueMin:t,clipValueMax:n};return _i.runKernel(Nt,a,i)}}),Pl=$i({concat1d_:function(e){return kl(e,0)}}),Hl=$i({concat2d_:function(e,t){return kl(e,t)}}),jl=$i({concat3d_:function(e,t){return kl(e,t)}}),Ul=$i({concat4d_:function(e,t){return kl(e,t)}}),ql=$i({conv2d_:function(e,t,n,r,a="NHWC",i=[1,1],s){const o=Ci(e,"x","conv2d","float32"),u=Ci(t,"filter","conv2d","float32");let l=o,c=!1;3===o.rank&&(c=!0,l=Ml(o,[1,o.shape[0],o.shape[1],o.shape[2]])),se(4===l.rank,(()=>`Error in conv2d: input must be rank 4, but got rank ${l.rank}.`)),se(4===u.rank,(()=>`Error in conv2d: filter must be rank 4, but got rank ${u.rank}.`)),wl("conv2d",r,s);const p="NHWC"===a?l.shape[3]:l.shape[1];se(p===u.shape[2],(()=>`Error in conv2d: depth of input (${p}) must match input depth for filter ${u.shape[2]}.`)),se(vl(n,i),(()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${i}'`));const d={x:l,filter:u},h={strides:n,pad:r,dataFormat:a,dilations:i,dimRoundingMode:s},f=_i.runKernel(Tt,d,h);return c?Ml(f,[f.shape[1],f.shape[2],f.shape[3]]):f}}),Wl=$i({conv1d_:function(e,t,n,r,a="NWC",i=1,s){const o=Ci(e,"x","conv1d"),u=Ci(t,"filter","conv1d");let l=o,c=!1;2===o.rank&&(c=!0,l=Ml(o,[1,o.shape[0],o.shape[1]])),se(3===l.rank,(()=>`Error in conv1d: input must be rank 3, but got rank ${l.rank}.`)),se(3===u.rank,(()=>`Error in conv1d: filter must be rank 3, but got rank ${u.rank}.`)),wl("conv1d",r,s),se(l.shape[2]===u.shape[1],(()=>`Error in conv1d: depth of input (${l.shape[2]}) must match input depth for filter ${u.shape[1]}.`)),se(vl(n,i),(()=>`Error in conv1D: Either stride or dilation must be 1. Got stride ${n} and dilation '${i}'`)),se("NWC"===a,(()=>`Error in conv1d: got dataFormat of ${a} but only NWC is currently supported.`));const p=Ml(u,[1,u.shape[0],u.shape[1],u.shape[2]]),d=Ml(l,[l.shape[0],1,l.shape[1],l.shape[2]]),h=ql(d,p,[1,n],r,"NHWC",[1,i],s);return Ml(h,c?[h.shape[2],h.shape[3]]:[h.shape[0],h.shape[2],h.shape[3]])}}),Vl=$i({conv2DBackpropInput_:function(e,t,n,r,a,i="NHWC",s){se(e.length===t.rank,(()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`));let o=e,u=t,l=!1;3===t.rank&&(l=!0,u=Ml(t,[1,t.shape[0],t.shape[1],t.shape[2]]),o=[1,e[0],e[1],e[2]]),se(4===o.length,(()=>`Error in conv2dDerInput: inShape must be length 4, but got length ${o.length}.`)),se(4===u.rank,(()=>`Error in conv2dDerInput: dy must be rank 4, but got rank ${u.rank}`)),se(4===n.rank,(()=>`Error in conv2dDerInput: filter must be rank 4, but got rank ${n.rank}`));const c="NHWC"===i?o[3]:o[1],p="NHWC"===i?u.shape[3]:u.shape[1];se(c===n.shape[2],(()=>`Error in conv2dDerInput: depth of input (${c}) must match input depth for filter ${n.shape[2]}.`)),se(p===n.shape[3],(()=>`Error in conv2dDerInput: depth of output (${p}) must match output depth for filter ${n.shape[3]}.`)),wl("conv2dDerInput",a,s);const d={dy:u,filter:n},h={strides:r,pad:a,dataFormat:i,dimRoundingMode:s,inputShape:o},f=_i.runKernel(Et,d,h);return l?Ml(f,[f.shape[1],f.shape[2],f.shape[3]]):f}}),Gl=$i({conv2dTranspose_:function(e,t,n,r,a,i){const s=Ci(e,"x","conv2dTranspose"),o=Ci(t,"filter","conv2dTranspose");return Vl(n,s,o,r,a,"NHWC",i)}}),Kl=$i({conv3d_:function(e,t,n,r,a="NDHWC",i=[1,1,1]){const s=Ci(e,"x","conv3d"),o=Ci(t,"filter","conv3d");let u=s,l=!1;4===s.rank&&(l=!0,u=Ml(s,[1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]])),se(5===u.rank,(()=>`Error in conv3d: input must be rank 5, but got rank ${u.rank}.`)),se(5===o.rank,(()=>`Error in conv3d: filter must be rank 5, but got rank ${o.rank}.`)),se(u.shape[4]===o.shape[3],(()=>`Error in conv3d: depth of input (${u.shape[4]}) must match input depth for filter ${o.shape[3]}.`)),se(vl(n,i),(()=>`Error in conv3D: Either strides or dilations must be 1. Got strides ${n} and dilations '${i}'`)),se("NDHWC"===a,(()=>`Error in conv3d: got dataFormat of ${a} but only NDHWC is currently supported.`));const c={x:u,filter:o},p={strides:n,pad:r,dataFormat:a,dilations:i},d=_i.runKernel(Ct,c,p);return l?Ml(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}}),Jl=$i({conv3DBackpropInput_:function(e,t,n,r,a){se(e.length===t.rank,(()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`));let i=e,s=t,o=!1;4===t.rank&&(o=!0,s=Ml(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]]),i=[1,e[0],e[1],e[2],e[3]]);const u=i[4],l=s.shape[4];se(5===i.length,(()=>`Error in conv3dDerInput: inShape must be length 5, but got length ${i.length}.`)),se(5===s.rank,(()=>`Error in conv3dDerInput: dy must be rank 5, but got rank ${s.rank}`)),se(5===n.rank,(()=>`Error in conv3dDerInput: filter must be rank 5, but got rank ${n.rank}`)),se(u===n.shape[3],(()=>`Error in conv3dDerInput: depth of input (${u}) must match input depth for filter ${n.shape[3]}.`)),se(l===n.shape[4],(()=>`Error in conv3dDerInput: depth of output (${l}) must match output depth for filter ${n.shape[4]}.`));const c={dy:s,filter:n},p={pad:a,strides:r,inputShape:i},d=_i.runKernel(Lt,c,p);return o?Ml(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}}),Xl=$i({conv3dTranspose_:function(e,t,n,r,a){const i=Ci(e,"x","conv3dTranspose"),s=Ci(t,"filter","conv3dTranspose");return Jl(n,i,s,r,a)}}),Zl=$i({cos_:function(e){const t={x:Ci(e,"x","cos","float32")};return _i.runKernel($t,t)}}),Ql=$i({cosh_:function(e){const t={x:Ci(e,"x","cosh","float32")};return _i.runKernel(Ot,t)}}),ec=$i({cumprod_:function(e,t=0,n=!1,r=!1){const a={x:Ci(e,"x","cumprod")},i={axis:t,exclusive:n,reverse:r};return _i.runKernel(Rt,a,i)}}),tc=$i({cumsum_:function(e,t=0,n=!1,r=!1){const a={x:Ci(e,"x","cumsum")},i={axis:t,exclusive:n,reverse:r};return _i.runKernel(Ft,a,i)}}),nc=$i({denseBincount_:function(e,t,n,r=!1){const a=Ci(e,"x","denseBincount"),i=Ci(t,"weights","denseBincount");se("int32"===a.dtype,(()=>`Error in denseBincount: input dtype must be int32, but got ${a.dtype}`)),se(a.rank<=2,(()=>`Error in denseBincount: input must be at most rank 2, but got rank ${a.rank}.`)),se(n>=0,(()=>`size must be non-negative, but got ${n}.`)),se(i.size===a.size||0===i.size,(()=>`Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${a.shape}, weights shape: ${i.shape}.`));const s={x:a,weights:i},o={size:n,binaryOutput:r};return _i.runKernel(zt,s,o)}}),rc=$i({depthToSpace_:function(e,t,n="NHWC"){const r=Ci(e,"x","depthToSpace","float32"),a="NHWC"===n?r.shape[1]:r.shape[2],i="NHWC"===n?r.shape[2]:r.shape[3],s="NHWC"===n?r.shape[3]:r.shape[1];se(t>1,(()=>`blockSize should be > 1 for depthToSpace, but was: ${t}`)),se(a*t>=0,(()=>`Negative dimension size caused by overflow when multiplying\n ${a} and ${t} for depthToSpace with input shape\n ${r.shape}`)),se(i*t>=0,(()=>`Negative dimension size caused by overflow when multiplying\n ${i} and ${t} for depthToSpace with input shape\n ${r.shape}`)),se(s%(t*t)==0,(()=>`Dimension size must be evenly divisible by ${t*t} but is ${s} for depthToSpace with input shape ${r.shape}`));const o={x:r},u={blockSize:t,dataFormat:n};return _i.runKernel(Bt,o,u)}}),ac=$i({depthwiseConv2d_:function(e,t,n,r,a="NHWC",i=[1,1],s){const o=Ci(e,"x","depthwiseConv2d","float32"),u=Ci(t,"filter","depthwiseConv2d","float32");let l=o,c=!1;3===o.rank&&(c=!0,l=Ml(o,[1,o.shape[0],o.shape[1],o.shape[2]])),se(4===l.rank,(()=>`Error in depthwiseConv2d: input must be rank 4, but got rank ${l.rank}.`)),se(4===u.rank,(()=>`Error in depthwiseConv2d: filter must be rank 4, but got rank ${u.rank}.`));const p="NHWC"===a?l.shape[3]:l.shape[1];se(p===u.shape[2],(()=>`Error in depthwiseConv2d: number of input channels (${p}) must match the inChannels dimension in filter ${u.shape[2]}.`)),wl("depthwiseConv2d",r,s);const d={x:l,filter:u},h={strides:n,pad:r,dataFormat:a,dilations:i,dimRoundingMode:s},f=_i.runKernel(Pt,d,h);return c?Ml(f,[f.shape[1],f.shape[2],f.shape[3]]):f}}),ic=$i({diag_:function(e){const t={x:Ci(e,"x","diag")};return _i.runKernel(Ut,t)}}),sc=$i({dilation2d_:function(e,t,n,r,a=[1,1],i="NHWC"){const s=Ci(e,"x","dilation2d"),o=Ci(t,"filter","dilation2d");se(3===s.rank||4===s.rank,(()=>`Error in dilation2d: input must be rank 3 or 4, but got rank ${s.rank}.`)),se(3===o.rank,(()=>`Error in dilation2d: filter must be rank 3, but got rank ${o.rank}.`)),se("NHWC"===i,(()=>`Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${i}`));let u=s,l=!1;3===s.rank&&(u=Ml(s,[1,s.shape[0],s.shape[1],s.shape[2]]),l=!0);const c={x:u,filter:o},p={strides:n,pad:r,dilations:a},d=_i.runKernel(qt,c,p);return l?Ml(d,[d.shape[1],d.shape[2],d.shape[3]]):d}}),oc=$i({equal_:function(e,t){let n=Ci(e,"a","equal","string_or_numeric"),r=Ci(t,"b","equal","string_or_numeric");[n,r]=di(n,r),Lo(n.shape,r.shape);const a={a:n,b:r};return _i.runKernel(Qt,a)}}),uc=$i({where_:function(e,t,n){const r=Ci(t,"a","where"),a=Ci(n,"b","where"),i=Ci(e,"condition","where","bool"),s=Lo(Lo(i.shape,r.shape),a.shape),o={condition:Yl(i,s),t:Yl(r,s),e:Yl(a,s)};return _i.runKernel(wr,o)}}),lc=$i({divNoNan_:function(e,t){let n=Ci(e,"a","div"),r=Ci(t,"b","div");[n,r]=di(n,r);const a=Nu(n,r),i=Tu(a),s=oc(r,i);return uc(s,i,a)}}),cc=$i({dot_:function(e,t){const n=Ci(e,"t1","dot"),r=Ci(t,"t2","dot");se(!(1!==n.rank&&2!==n.rank||1!==r.rank&&2!==r.rank),(()=>`Error in dot: inputs must all be rank 1 or 2, but got ranks ${n.rank} and ${r.rank}.`));const a=1===n.rank?n.size:n.shape[1],i=1===r.rank?r.size:r.shape[0];if(se(a===i,(()=>`Error in dot: inner dimensions of inputs must match, but got ${a} and ${i}.`)),1===n.rank&&1===r.rank){const e=Ml(n,[1,-1]),t=Ml(r,[-1,1]),a=no(e,t);return Ml(a,[])}if(1===n.rank&&2===r.rank){const e=Ml(n,[1,-1]),t=Ml(r,[r.shape[0],r.shape[1]]),a=no(e,t);return Ml(a,[a.size])}if(2===n.rank&&1===r.rank){const e=Ml(r,[-1,1]),t=no(n,e);return Ml(t,[t.size])}{const e=Ml(r,[r.shape[0],r.shape[1]]);return no(n,e)}}}),pc=$i({einsum_:function(e,...t){const n=t.map(((e,t)=>Ci(e,`tensors${t}`,"einsum"))),r={equation:e};return _i.runKernel(Kt,n,r)}}),dc=$i({elu_:function(e){const t={x:Ci(e,"x","elu","float32")};return _i.runKernel(Jt,t)}}),hc=$i({erf_:function(e){let t=Ci(e,"x","erf");se("int32"===t.dtype||"float32"===t.dtype,(()=>"Input dtype must be `int32` or `float32`.")),"int32"===t.dtype&&(t=Ls(t,"float32"));const n={x:t};return _i.runKernel(Zt,n)}});function fc(e,t){for(let n=0;ne[t]))]}function yc(e,t){return mc(e,t.map((e=>1)),t)}function bc(e,t,n){se(fc(t,n),(()=>`${e} supports only inner-most axes for now. Got axes ${t} and rank-${n} input.`))}function xc(e,t){if(fc(e,t))return null;const n=[];for(let r=0;rn.push(e))),n}function vc(e){return e.map(((e,t)=>[t,e])).sort(((e,t)=>e[1]-t[1])).map((e=>e[0]))}function _c(e,t){const n=[];for(let r=t-e;r"Axis must be <= rank of the tensor"));const r={input:n},a={dim:t};return _i.runKernel(tn,r,a)}}),Ec=$i({expm1_:function(e){const t={x:Ci(e,"x","expm1")};return _i.runKernel(nn,t)}}),Cc=$i({tile_:function(e,t){const n=Ci(e,"x","tile","string_or_numeric");se(n.rank===t.length,(()=>`Error in transpose: rank of input ${n.rank} must match length of reps ${t}.`));const r={x:n},a={reps:t};return _i.runKernel(Kr,r,a)}}),Ac=$i({eye_:function(e,t,n,r="float32"){null==t&&(t=e);const a=As([e,t],r),i=e<=t?e:t;for(let e=0;e`Error in localResponseNormalization: x must be rank 3 or 4 but got\n rank ${i.rank}.`)),se(he(t),(()=>`Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${t}.`));let s=i,o=!1;3===i.rank&&(o=!0,s=Ml(i,[1,i.shape[0],i.shape[1],i.shape[2]]));const u={x:s},l={depthRadius:t,bias:n,alpha:r,beta:a},c=_i.runKernel(An,u,l);return o?Ml(c,[c.shape[1],c.shape[2],c.shape[3]]):c}}),qc=$i({log_:function(e){const t={x:Ci(e,"x","log","float32")};return _i.runKernel(Nn,t)}}),Wc=$i({log1p_:function(e){const t={x:Ci(e,"x","log1p")};return _i.runKernel(Sn,t)}}),Vc=$i({softplus_:function(e){const t={x:Ci(e,"x","softplus")};return _i.runKernel(Ir,t)}}),Gc=$i({logSigmoid_:function(e){const t=Ci(e,"x","logSigmoid"),n=$u((e=>({value:Do(Vc(Do(e))),gradFunc:t=>Su(t,Dl(Do(e)))})));return n(t)}}),Kc=$i({logSoftmax_:function(e,t=-1){const n=Ci(e,"logits","logSoftmax");if(-1===t&&(t=n.rank-1),t!==n.rank-1)throw Error(`Log Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank} and axis was ${t}`);const r=$u(((e,n)=>{const r=wc(e,t,!0),a=Hu(e,r),i=Hu(Ls(a,"float32"),qc(Nc(Tc(a),t,!0)));return n([i]),{value:i,gradFunc:(e,n)=>{const[r]=n,a=Tc(r);return Hu(e,Su(Nc(e,t,!0),a))}}}));return r(n)}}),Jc=$i({logSumExp_:function(e,t=null,n=!1){const r=Ci(e,"x","logSumExp"),a=ve(t,r.shape),i=wc(r,a,!0),s=Hu(r,i),o=Tc(s),u=Nc(o,a),l=qc(u),c=wu(Ml(i,l.shape),l);if(n){const e=yc(c.shape,a);return Ml(c,e)}return c}}),Xc=$i({logicalAnd_:function(e,t){const n=Ci(e,"a","logicalAnd","bool"),r=Ci(t,"b","logicalAnd","bool");Lo(n.shape,r.shape);const a={a:n,b:r};return _i.runKernel(kn,a)}}),Zc=$i({logicalNot_:function(e){const t={x:Ci(e,"x","logicalNot","bool")};return _i.runKernel(Dn,t)}}),Qc=$i({logicalOr_:function(e,t){const n=Ci(e,"a","logicalOr","bool"),r=Ci(t,"b","logicalOr","bool");Lo(n.shape,r.shape);const a={a:n,b:r};return _i.runKernel(Tn,a)}}),ep=$i({logicalXor_:function(e,t){const n=Ci(e,"a","logicalXor","bool"),r=Ci(t,"b","logicalXor","bool");return Lo(n.shape,r.shape),Xc(Qc(e,t),Zc(Xc(e,t)))}}),tp=2147483648,np=$i({searchSorted_:function(e,t,n="left"){const r=Ci(e,"sortedSequence","searchSorted"),a=Ci(t,"values","searchSorted"),i=r.shape[r.shape.length-1],s=a.shape[a.shape.length-1],o=Ml(r,[-1,i]),u=Ml(a,[-1,s]);if(o.rank<2)throw new Error("Sorted input argument must be at least 2-dimensional");if(o.shape[0]!==u.shape[0])throw new Error("Leading dimension of 'sortedSequence' and 'values' must match.");if(ce(u.shape)>=tp)throw new Error("values tensor size must less than 2147483648");if(o.shape[1]>=tp)throw new Error(`trailing dim_size must less than 2147483648 for int32 output type, was ${o.shape[1]}`);const l={sortedSequence:o,values:u},c={side:n};return _i.runKernel(_r,l,c)}});function rp(e,t){return np(e,t,"left")}const ap=$i({maxPool_:function(e,t,n,r,a){const i=Ci(e,"x","maxPool");let s=i,o=!1;3===i.rank&&(o=!0,s=Ml(i,[1,i.shape[0],i.shape[1],i.shape[2]])),se(4===s.rank,(()=>`Error in maxPool: input must be rank 4 but got rank ${s.rank}.`)),se(vl(n,1),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`)),wl("maxPool",r,a);const u={x:s},l={filterSize:t,strides:n,pad:r,dimRoundingMode:a},c=_i.runKernel(Rn,u,l);return o?Ml(c,[c.shape[1],c.shape[2],c.shape[3]]):c}}),ip=$i({maxPool3d_:function(e,t=[1,1,1],n,r,a,i="NDHWC"){const s=Ci(e,"x","maxPool3d");let o=s,u=!1;4===s.rank&&(u=!0,o=Ml(s,[1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]])),se(5===o.rank,(()=>`Error in maxPool3d: x must be rank 5 but got rank ${o.rank}.`)),se("NDHWC"===i,(()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${i}`)),wl("maxPool3d",r,a);const l={x:o},c={filterSize:t,strides:n,pad:r,dimRoundingMode:a,dataFormat:i},p=_i.runKernel(Yn,l,c);return u?Ml(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}}),sp=$i({maxPoolWithArgmax_:function(e,t,n,r,a=!1){const i={x:Ci(e,"x","maxPoolWithArgmax")},s={filterSize:t,strides:n,pad:r,includeBatchInIndex:a},o=_i.runKernel(Bn,i,s);return{result:o[0],indexes:o[1]}}}),op=$i({mean_:function(e,t=null,n=!1){const r={x:Ci(e,"x","mean")},a={axis:t,keepDims:n};return _i.runKernel(Pn,r,a)}});function up(e,t="float32"){if("complex64"===t){const t=up(e,"float32"),n=up(e,"float32");return Oi(t,n)}const n=Be(ce(e),t);return _i.makeTensor(n,e,t)}function lp(e,t="float32"){if("complex64"===t){const t=lp(e,"float32"),n=up(e,"float32");return Oi(t,n)}const n=ze(ce(e),t);return _i.makeTensor(n,e,t)}function cp(e,t,{indexing:n="xy"}={}){if("xy"!==n&&"ij"!==n)throw new TypeError(`${n} is not a valid third argument to meshgrid`);if(void 0===e)return[];let r=Ci(e,"x","meshgrid",e instanceof ti?e.dtype:"float32");if(void 0===t)return[r];let a=Ci(t,"y","meshgrid",t instanceof ti?t.dtype:"float32");const i=ce(r.shape),s=ce(a.shape);return"xy"===n?(r=Ml(r,[1,-1]),a=Ml(a,[-1,1]),[no(lp([s,1],r.dtype),r),no(a,lp([1,i],a.dtype))]):(r=Ml(r,[-1,1]),a=Ml(a,[1,-1]),[no(r,lp([1,s],r.dtype)),no(lp([i,1],a.dtype),a)])}const pp=$i({minimum_:function(e,t){let n=Ci(e,"a","minimum"),r=Ci(t,"b","minimum");[n,r]=di(n,r),"bool"===n.dtype&&(n=Ls(n,"int32"),r=Ls(r,"int32")),Lo(n.shape,r.shape);const a={a:n,b:r};return _i.runKernel(jn,a)}}),dp=$i({mirrorPad_:function(e,t,n){se("reflect"===n||"symmetric"===n,(()=>`Invalid mode. Mode must be either reflect or symmetric. Got ${n}.`));const r=Ci(e,"x","mirrorPad");if(0===r.rank)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");se(t.length===r.rank,(()=>`Padding doesn't match input. Must be ${r.rank}. Got ${t.length}.`));const a="reflect"===n?1:0;for(let e=0;e"Invalid number of paddings. Must be length of 2 each.")),se(t[e][0]>=0&&t[e][0]<=r.shape[e]-a&&t[e][1]>=0&&t[e][1]<=r.shape[e]-a,(()=>`Padding in dimension ${e} cannot be greater than or equal to ${r.shape[e]-a} or less than 0 for input of shape ${r.shape}`));const i={paddings:t,mode:n},s={x:r};return _i.runKernel(Un,s,i)}}),hp=$i({mod_:function(e,t){let n=Ci(e,"a","mod"),r=Ci(t,"b","mod");[n,r]=di(n,r);const a={a:n,b:r};return _i.runKernel(qn,a)}}),fp=$i({moments_:function(e,t=null,n=!1){const r=ve(t,(e=Ci(e,"x","moments")).shape),a=op(e,r,n);let i=a.shape;n||(i=yc(a.shape,r));const s=Du(Hu(Ls(e,"float32"),Ml(a,i)));return{mean:a,variance:op(s,r,n)}}}),mp=$i({multiRNNCell_:function(e,t,n,r){const a=Ci(t,"data","multiRNNCell"),i=Ai(n,"c","multiRNNCell"),s=Ai(r,"h","multiRNNCell");let o=a;const u=[];for(let t=0;t2)throw new Error(`Rank of probabilities must be 1 or 2, but is ${s}`);n=n||Math.random();const o={logits:1===s?Ml(a,[1,-1]):a},u={numSamples:t,seed:n,normalized:r},l=_i.runKernel(Wn,o,u);return 1===s?Ml(l,[l.size]):l}}),yp=$i({notEqual_:function(e,t){let n=Ci(e,"a","notEqual","string_or_numeric"),r=Ci(t,"b","notEqual","string_or_numeric");[n,r]=di(n,r),Lo(n.shape,r.shape);const a={a:n,b:r};return _i.runKernel(Kn,a)}}),bp=$i({onesLike_:function(e){const t={x:Ci(e,"x","onesLike")};return _i.runKernel(Qn,t)}}),xp=$i({outerProduct_:function(e,t){const n=Ci(e,"v1","outerProduct"),r=Ci(t,"v2","outerProduct");se(1===n.rank&&1===r.rank,(()=>`Error in outerProduct: inputs must be rank 1, but got ranks ${n.rank} and ${r.rank}.`));const a=Ml(n,[-1,1]),i=Ml(r,[1,-1]);return no(a,i)}}),vp=$i({pad_:function(e,t,n=0){const r=Ci(e,"x","pad");if(0===r.rank)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");const a={paddings:t,constantValue:n},i={x:r};return _i.runKernel(nr,i,a)}}),_p=$i({pad1d_:function(e,t,n=0){return se(2===t.length,(()=>"Invalid number of paddings. Must be length of 2.")),vp(e,[t],n)}}),wp=$i({pad2d_:function(e,t,n=0){return se(2===t.length&&2===t[0].length&&2===t[1].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),vp(e,t,n)}}),Mp=$i({pad3d_:function(e,t,n=0){return se(3===t.length&&2===t[0].length&&2===t[1].length&&2===t[2].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),vp(e,t,n)}}),Np=$i({pad4d_:function(e,t,n=0){return se(4===t.length&&2===t[0].length&&2===t[1].length&&2===t[2].length&&2===t[3].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),vp(e,t,n)}}),Sp=$i({spaceToBatchND_:function(e,t,n){const r=Ci(e,"x","spaceToBatchND");se(r.rank>=1+t.length,(()=>`input rank ${r.rank} should be > than [blockShape] ${t.length}`)),se(n.length===t.length,(()=>`paddings.shape[0] ${n.length} must be equal to [blockShape] ${t.length}`)),se(r.shape.reduce(((e,r,a)=>a>0&&a<=t.length?e&&(r+n[a-1][0]+n[a-1][1])%t[a-1]==0:e),!0),(()=>`input spatial dimensions ${r.shape.slice(1)} with paddings ${n.toString()} must be divisible by blockShapes ${t.toString()}`));const a={x:r},i={blockShape:t,paddings:n};return _i.runKernel(Ar,a,i)}}),kp=$i({pool_:function(e,t,n,r,a,i,s){null==a&&(a=[1,1]),null==i&&(i=1),0===r&&(r="valid");const o=Ci(e,"x","maxPool");let u=o,l=!1;3===o.rank&&(l=!0,u=Ml(o,[1,o.shape[0],o.shape[1],o.shape[2]])),se(vl(i,a),(()=>`Error in pool: Either strides or dilations must be 1. Got strides ${i} and dilations '${a}'`));const c=cl(u.shape,t,i,a,r),p=[c.dilationHeight,c.dilationWidth];let d;d="same"===r?function(e,t){const n=e.map(((e,n)=>e+(e-1)*(t[n]-1))),r=n.map((e=>e-1)),a=r.map((e=>Math.floor(e/2))),i=r.map(((e,t)=>e-a[t]));return r.map(((e,t)=>[a[t],i[t]]))}([c.filterHeight,c.filterWidth],p):[[0,0],[0,0]];const h=1===p[0]&&1===p[1],[f,m]=function(e,t,n){const r=n.map((e=>e[0])),a=n.map((e=>e[1])),i=e.concat(r,a),s=t.map(((e,t)=>(e-i[t]%e)%e)),o=a.map(((e,t)=>e+s[t])),u=t.map(((e,t)=>[r[t],o[t]])),l=t.map(((e,t)=>[0,s[t]]));return[u,l]}([c.inHeight,c.inWidth],p,d),g=h?r:"valid",y=h?u:Sp(u,p,f),b=("avg"===n?()=>Nl(y,t,i,g,s):()=>ap(y,t,i,g,s))(),x=h?b:Cl(b,p,m);return l?Ml(x,[x.shape[1],x.shape[2],x.shape[3]]):x}}),Dp=$i({prelu_:function(e,t){const n={x:Ci(e,"x","prelu"),alpha:Ci(t,"alpha","prelu")};return _i.runKernel(ir,n)}}),Tp=$i({prod_:function(e,t=null,n=!1){let r=Ci(e,"x","prod");"bool"===r.dtype&&(r=Ls(r,"int32"));const a={x:r},i={axis:t,keepDims:n};return _i.runKernel(sr,a,i)}}),Ip=$i({rand_:function(e,t,n){const r=ce(e);let a=null;if(null==n||"float32"===n)a=new Float32Array(r);else if("int32"===n)a=new Int32Array(r);else{if("bool"!==n)throw new Error(`Unknown data type ${n}`);a=new Uint8Array(r)}for(let e=0;e=1||0===i);const s=Math.sqrt(-2*Math.log(i)/i);e=this.mean+this.stdDev*r*s,t=this.mean+this.stdDev*a*s,this.truncated&&!this.isValidTruncated(e)||(n=!0)}return this.truncated&&!this.isValidTruncated(t)||(this.nextVal=this.convertValue(t)),this.convertValue(e)}convertValue(e){return null==this.dtype||"float32"===this.dtype?e:Math.round(e)}isValidTruncated(e){return e<=this.upper&&e>=this.lower}}class Ap{constructor(e,t,n,r){this.alpha=e,this.beta=1/t,this.dtype=n;const a=r||Math.random();this.randu=Ep.alea(a.toString()),this.randn=new Cp(0,1,n,!1,this.randu()),this.d=e<1?e+2/3:e-1/3,this.c=1/Math.sqrt(9*this.d)}nextValue(){let e,t,n,r,a,i;for(;;){do{r=this.randn.nextValue(),i=1+this.c*r}while(i<=0);if(i*=i*i,e=r*r,t=1-.331*e*e,n=.5*e+this.d*(1-i+Math.log(i)),a=this.randu(),anull==this.dtype||"float32"===this.dtype,this.min=e,this.range=t-e,this.dtype=n,null==r&&(r=Math.random()),"number"==typeof r&&(r=r.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error(`The difference between ${e} - ${t} <= 1 and dtype is not float`);this.random=Ep.alea(r)}convertValue(e){return this.canReturnFloat()?e:Math.round(e)}nextValue(){return this.convertValue(this.min+this.range*this.random())}}const $p=$i({randomGamma_:function(e,t,n=1,r="float32",a){if(null==n&&(n=1),null==r&&(r="float32"),"float32"!==r&&"int32"!==r)throw new Error(`Unsupported data type ${r}`);const i=new Ap(t,n,r,a),s=As(e,r);for(let e=0;e`Error in reverse1D: x must be rank 1 but got rank ${t.rank}.`)),Hp(t,0)}}),Up=$i({reverse2d_:function(e,t){const n=Ci(e,"x","reverse");return se(2===n.rank,(()=>`Error in reverse2D: x must be rank 2 but got rank ${n.rank}.`)),Hp(n,t)}}),qp=$i({reverse3d_:function(e,t){const n=Ci(e,"x","reverse");return se(3===n.rank,(()=>`Error in reverse3D: x must be rank 3 but got rank ${n.rank}.`)),Hp(n,t)}}),Wp=$i({reverse4d_:function(e,t){const n=Ci(e,"x","reverse");return se(4===n.rank,(()=>`Error in reverse4D: x must be rank 4 but got rank ${n.rank}.`)),Hp(n,t)}}),Vp=$i({round_:function(e){const t={x:Ci(e,"x","round")};return _i.runKernel(br,t)}}),Gp=$i({rsqrt_:function(e){const t={x:Ci(e,"x","rsqrt","float32")};return _i.runKernel(xr,t)}}),Kp=$i({selu_:function(e){const t={x:Ci(e,"x","selu")};return _i.runKernel(Mr,t)}}),Jp=$i({separableConv2d_:function(e,t,n,r,a,i=[1,1],s="NHWC"){const o=Ci(e,"x","separableConv2d"),u=Ci(t,"depthwiseFilter","separableConv2d"),l=Ci(n,"pointwiseFilter","separableConv2d");let c=o,p=!1;if(3===o.rank&&(p=!0,c=Ml(o,[1,o.shape[0],o.shape[1],o.shape[2]])),"NCHW"===s)throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");se(4===c.rank,(()=>`Error in separableConv2d: input must be rank 4, but got rank ${c.rank}.`)),se(4===u.rank,(()=>`Error in separableConv2d: depthwise filter must be rank 4, but got rank ${u.rank}.`)),se(4===l.rank,(()=>`Error in separableConv2d: pointwise filter must be rank 4, but got rank ${u.rank}.`)),se(1===l.shape[0],(()=>`Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${l.shape[0]}.`)),se(1===l.shape[1],(()=>`Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${l.shape[1]}.`));const d=u.shape[2],h=u.shape[3];se(l.shape[2]===d*h,(()=>`Error in separableConv2d: the third dimension of pointwise filter must be ${d*h}, but got ${l.shape[2]}.`));const f=ac(c,u,r,a,s,i),m=ql(f,l,1,"valid",s);return p?Ml(m,[m.shape[1],m.shape[2],m.shape[3]]):m}}),Xp=async function(e,t){const n=Ci(e,"x","setdiff1d"),r=Ci(t,"y","setdiff1d");se(n.dtype===r.dtype,(()=>`x and y should have the same dtype, but got x (${n.dtype}) and y (${r.dtype}).`)),se(1===n.rank,(()=>`x should be 1D tensor, but got x (${n.shape}).`)),se(1===r.rank,(()=>`y should be 1D tensor, but got y (${r.shape}).`));const a=await n.data(),i=await r.data(),s=new Set(i);let o=0;for(let e=0;e`slice1d expects a rank-1 tensor, but got a rank-${r.rank} tensor`)),Tl(r,[t],[n])}}),nd=$i({slice2d_:function(e,t,n){const r=Ci(e,"x","slice2d");return se(2===r.rank,(()=>`slice2d expects a rank-2 tensor, but got a rank-${r.rank} tensor`)),Tl(r,t,n)}}),rd=$i({slice3d_:function(e,t,n){const r=Ci(e,"x","slice3d");return se(3===r.rank,(()=>`slice3d expects a rank-3 tensor, but got a rank-${r.rank} tensor`)),Tl(r,t,n)}}),ad=$i({slice4d_:function(e,t,n){const r=Ci(e,"x","slice4d");return se(4===r.rank,(()=>`slice4d expects a rank-4 tensor, but got a rank-${r.rank} tensor`)),Tl(r,t,n)}}),id=$i({softmax_:function(e,t=-1){const n=Ci(e,"logits","softmax","float32");if(-1===t&&(t=n.rank-1),t!==n.rank-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank} and dim was ${t}`);const r={logits:n},a={dim:t};return _i.runKernel($r,r,a)}}),sd=$i({fft_:function(e){se("complex64"===e.dtype,(()=>`The dtype for tf.spectral.fft() must be complex64 but got ${e.dtype}.`));const t={input:e};return _i.runKernel(rn,t)}}),od=$i({ifft_:function(e){se("complex64"===e.dtype,(()=>`The dtype for tf.spectral.ifft() must be complex64 but got ${e.dtype}.`));const t={input:e};return _i.runKernel(mn,t)}}),ud=$i({irfft_:function(e){const t=e.shape[e.shape.length-1],n=e.size/t;let r;if(t<=2){const a=Ml(e,[n,t]);r=od(a)}else{const a=[n,2*(t-1)],i=Ml(To(e),[n,t]),s=Ml(ko(e),[n,t]),o=Hp(Tl(i,[0,1],[n,t-2]),1),u=Su(Hp(Tl(s,[0,1],[n,t-2]),1),Ru(-1)),l=kl([i,o],1),c=kl([s,u],1),p=Ml(Oi(l,c),[a[0],a[1]]);r=od(p)}if(r=To(r),3===e.rank&&0!==e.shape[0]){const t=r,n=e.shape[0];r=Ml(r,[n,r.shape[0]/n,r.shape[1]]),t.dispose()}return r}}),ld=$i({split_:function(e,t,n=0){const r={x:Ci(e,"x","split")},a={numOrSizeSplits:t,axis:n};return _i.runKernel(Lr,r,a)}}),cd=$i({rfft_:function(e,t){se("float32"===e.dtype,(()=>`The dtype for rfft() must be real value but got ${e.dtype}`));let n=e.shape[e.shape.length-1];const r=e.size/n;let a;if(null!=t&&t0)),i=e.shape.map((e=>e));i[e.shape.length-1]=t,a=Tl(e,r,i),n=t}else if(null!=t&&t>n){const r=e.shape.map((e=>e));r[e.shape.length-1]=t-n,a=kl([e,up(r)],e.shape.length-1),n=t}else a=e;const i=Tu(a),s=Ml(Oi(a,i),[r,n]),o=sd(s),u=Math.floor(n/2)+1,l=To(o),c=ko(o),p=ld(l,[u,n-u],l.shape.length-1),d=ld(c,[u,n-u],c.shape.length-1),h=a.shape.slice();return h[a.shape.length-1]=u,Ml(Oi(p[0],d[0]),h)}}),pd=$i({squaredDifference_:function(e,t){let n=Ci(e,"a","squaredDifference"),r=Ci(t,"b","squaredDifference");[n,r]=di(n,r),Lo(n.shape,r.shape);const a={a:n,b:r};return _i.runKernel(Br,a,{})}}),dd=$i({squeeze_:function(e,t){const n=Ci(e,"x","squeeze","string_or_numeric");return Ml(n,_e(n.shape,t).newShape)}}),hd=$i({stack_:function(e,t=0){const n=Ai(e,"tensors","stack","string_or_numeric");se(n.length>=1,(()=>"Pass at least one tensor to tf.stack")),n.length>0&&se(t<=n[0].rank,(()=>"Axis must be <= rank of the tensor"));const r=n,a={axis:t};return _i.runKernel(tr,r,a)}}),fd=$i({step_:function(e,t=0){const n={x:Ci(e,"x","step")},r={alpha:t};return _i.runKernel(aa,n,r)}}),md=$i({stridedSlice_:function(e,t,n,r,a=0,i=0,s=0,o=0,u=0){const l={x:Ci(e,"x","stridedSlice","string_or_numeric")},c={begin:t,end:n,strides:r,beginMask:a,endMask:i,ellipsisMask:s,newAxisMask:o,shrinkAxisMask:u};return _i.runKernel(Hr,l,c)}}),gd=$i({tan_:function(e){const t={x:Ci(e,"x","tan","float32")};return _i.runKernel(Vr,t)}});function yd(e,t){ue(e);const n=Ti(e,t);if(1!==n.length)throw new Error("tensor1d() requires values to be a flat/TypedArray");return Ri(e,null,n,t)}function bd(e,t,n){if(ue(e),null!=t&&2!==t.length)throw new Error("tensor2d() requires shape to have two numbers");const r=Ti(e,n);if(2!==r.length&&1!==r.length)throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return Ri(e,t,r,n)}function xd(e,t,n){if(ue(e),null!=t&&4!==t.length)throw new Error("tensor4d() requires shape to have four numbers");const r=Ti(e,n);if(4!==r.length&&1!==r.length)throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");return Ri(e,t,r,n)}function vd(e,t,n){if(ue(e),null!=t&&5!==t.length)throw new Error("tensor5d() requires shape to have five numbers");const r=Ti(e,n);if(5!==r.length&&1!==r.length)throw new Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor5d() requires shape to be provided when `values` are a flat array");return Ri(e,t,r,n)}function _d(e,t,n){if(ue(e),null!=t&&6!==t.length)throw new Error("tensor6d() requires shape to have six numbers");const r=Ti(e,n);if(6!==r.length&&1!==r.length)throw new Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor6d() requires shape to be provided when `values` are a flat array");return Ri(e,t=t||r,r,n)}const wd=$i({topk_:function(e,t=1,n=!0){const r=Ci(e,"x","topk");if(0===r.rank)throw new Error("topk() expects the input to be of rank 1 or higher");const a=r.shape[r.shape.length-1];if(t<0)throw new Error(`'k' passed to topk() must be >= 0 but got ${t}`);if(t>a)throw new Error(`'k' passed to topk() must be <= the last dimension (${a}) but got ${t}`);const i={x:r},s={k:t,sorted:n},[o,u]=_i.runKernel(Jr,i,s);return{values:o,indices:u}}}),Md=$i({truncatedNormal_:function(e,t=0,n=1,r,a){if(null!=r&&"bool"===r)throw new Error("Unsupported data type $ { dtype }");const i=new Cp(t,n,r,!0,a),s=As(e,r);for(let e=0;e0,(()=>"The input tensor must be at least 1D"));const r={x:n},a={axis:t},[i,s]=_i.runKernel(Qr,r,a);return{values:i,indices:s}}}),Sd=$i({unsortedSegmentSum_:function(e,t,n){const r=Ci(e,"x","unsortedSegmentSum"),a=Ci(t,"segmentIds","unsortedSegmentSum","int32");se(he(n),(()=>"numSegments must be of dtype int"));const i={x:r,segmentIds:a},s={numSegments:n};return _i.runKernel(ta,i,s)}}),kd=$i({unstack_:function(e,t=0){const n=Ci(e,"x","unstack","string_or_numeric");se(t>=-n.shape.length&&t`Axis = ${t} is not in [-${n.shape.length}, ${n.shape.length})`));const r={value:n},a={axis:t};return _i.runKernel(ea,r,a)}});function Dd(e,t){return np(e,t,"right")}function Td(e,t=!0,n,r){return _i.makeVariable(e,t,n,r)}function Id(e,t){const n=[];for(let e=0;e0,(()=>"mask cannot be scalar")),oe(o.slice(i,i+s),a.shape,"mask's shape must match the first K dimensions of tensor's shape,");let u=1;for(let e=i;e"Shape mismatch in v and x"));const u=Ru(1),l=Hu(u,o);let c=Su(Hu(s,i),l);if(a){se(null!=r,(()=>"When using zeroDebias: true, step is required."));const e=Ci(r,"step","movingAverage");c=Nu(c,Hu(u,Pu(o,e)))}return wu(i,c)}}),Ld=$i({scatterND_:function(e,t,n){const r=Ci(e,"indices","scatterND","int32"),a=Ci(t,"updates","scatterND");Ho(a,r,n);const i={indices:r,updates:a},s={shape:n};return _i.runKernel(vr,i,s)}}),$d=$i({sparseToDense_:function(e,t,n,r=0){const a=Ci(e,"sparseIndices","sparseToDense","int32"),i=Ci(t,"sparseValues","sparseToDense","string_or_numeric"),s=Ci(r,"defaultValue","sparseToDense",i.dtype);!function(e,t,n,r){if("int32"!==e.dtype)throw new Error(`tf.sparseToDense() expects the indices to be int32 type, but the dtype was ${e.dtype}.`);if(e.rank>2)throw new Error(`sparseIndices should be a scalar, vector, or matrix, but got shape ${e.shape}.`);const a=e.rank>0?e.shape[0]:1,i=e.rank>1?e.shape[1]:1;if(n.length!==i)throw new Error(`outputShape has incorrect number of elements:, ${n.length}, should be: ${i}.`);const s=t.size;if(0!==t.rank&&(1!==t.rank||s!==a))throw new Error(`sparseValues has incorrect shape ${t.shape}, should be [] or [${a}]`);if(t.dtype!==r.dtype)throw new Error("sparseValues.dtype must match defaultValues.dtype")}(a,i,n,s);const o={sparseIndices:a,sparseValues:i,defaultValue:s},u={outputShape:n};return _i.runKernel(zr,o,u)}}),Od=$i({gatherND_:function(e,t){const n=Ci(t,"indices","gatherND","int32"),r={params:Ci(e,"x","gatherND","string_or_numeric"),indices:n};return _i.runKernel(pn,r)}}),Rd=$i({dropout_:function(e,t,n,r){const a=Ci(e,"x","dropout");if(se("float32"===a.dtype,(()=>`x has to be a floating point tensor since it's going to be scaled, but got a ${a.dtype} tensor instead.`)),se(t>=0&&t<1,(()=>`rate must be a float in the range [0, 1), but got ${t}.`)),0===t)return e instanceof ti?a.clone():a;const i=function(e,t){if(null==t)return e.shape.slice();if(de(e.shape,t))return t;if(e.shape.length===t.length){const n=[];for(let r=0;r1,(()=>`inTopK() expects the predictions to be of rank 2 or higher, but got ${r.rank}`)),se(r.rank-1===a.rank,(()=>`predictions rank should be 1 larger than targets rank, but got predictions rank ${r.rank} and targets rank ${a.rank}`)),oe(r.shape.slice(0,r.shape.length-1),a.shape,"predictions's shape should be align with the targets' shape, except the last dimension.");const i=r.shape[r.shape.length-1];se(n>0&&n<=i,(()=>`'k' passed to inTopK() must be > 0 && <= the predictions last dimension (${i}), but got ${n}`));const s=await r.data(),o=await a.data(),[u,l]=[s.length/i,i],c=we("bool",u);for(let e=0;et.value-e.value)),c[e]=0;for(let t=0;t`Error in conv2dDerFilter: input must be rank 4, but got shape ${o.shape}.`)),se(4===u.rank,(()=>`Error in conv2dDerFilter: dy must be rank 4, but got shape ${u.shape}.`)),se(4===n.length,(()=>`Error in conv2dDerFilter: filterShape must be length 4, but got ${n}.`));const l="NHWC"===i?o.shape[3]:o.shape[1],c="NHWC"===i?u.shape[3]:u.shape[1];se(l===n[2],(()=>`Error in conv2dDerFilter: depth of input ${l}) must match input depth in filter (${n[2]}.`)),se(c===n[3],(()=>`Error in conv2dDerFilter: depth of dy (${c}) must match output depth for filter (${n[3]}).`)),wl("conv2dDerFilter",a,s);const p={x:o,dy:u},d={strides:r,pad:a,dataFormat:i,dimRoundingMode:s,filterShape:n};return _i.runKernel(It,p,d)}});function Pd(e,t,n){if(null==n||"linear"===n)return e;if("relu"===n)return Su(e,fd(t));throw new Error(`Cannot compute gradient for fused activation ${n}.`)}function Hd(e,t){let n=t;const r=Ao(e.shape,t.shape);return r.length>0&&(n=Nc(n,r)),Ml(n,e.shape)}function jd(e,t,n,r){if("linear"===t)return e;if("relu"===t)return Bp(e);if("elu"===t)return dc(e);if("relu6"===t)return Pp(e);if("prelu"===t)return Dp(e,n);if("leakyrelu"===t)return Bc(e,r);if("sigmoid"===t)return Dl(e);throw new Error(`Unknown fused activation ${t}.`)}const Ud=(e,t)=>!(e>0)||"linear"===t,qd=$i({fusedConv2d_:function({x:e,filter:t,strides:n,pad:r,dataFormat:a="NHWC",dilations:i=[1,1],dimRoundingMode:s,bias:o,activation:u="linear",preluActivationWeights:l,leakyreluAlpha:c}){if(u=u||"linear",!1===Ud(_i.state.gradientDepth,u)){se("NHWC"===a,(()=>`Error in fused conv2d: got dataFormat of ${a} but only NHWC is currently supported for the case of gradient depth is 0 and the activation is not linear.`));let p=ql(e,t,n,r,a,i,s);return null!=o&&(p=wu(p,o)),jd(p,u,l,c)}const p=Ci(e,"x","conv2d","float32"),d=Ci(t,"filter","conv2d","float32");let h=p,f=!1;3===p.rank&&(f=!0,h=Ml(p,[1,p.shape[0],p.shape[1],p.shape[2]])),se(4===h.rank,(()=>`Error in fused conv2d: input must be rank 4, but got rank ${h.rank}.`)),se(4===d.rank,(()=>`Error in fused conv2d: filter must be rank 4, but got rank ${d.rank}.`)),wl("fused conv2d",r,s);const m="NHWC"===a?h.shape[3]:h.shape[1];se(d.shape[2]===m,(()=>`Error in conv2d: depth of input (${m}) must match input depth for filter ${d.shape[2]}.`)),se(vl(n,i),(()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${i}'`));const g=dl(h.shape,d.shape,n,i,r,s);let y,b;if(null!=o&&(y=Ci(o,"bias","fused conv2d"),[y]=di(y,p),"NHWC"===a?Lo(g.outShape,y.shape):(se(y.shape.length<=1,(()=>`Error in fused conv2d: only supports scalar or 1-D Tensor bias for NCHW format but got the bias of rank-${y.shape.length}.`)),se(0===y.shape.length||y.shape[0]===g.outChannels||1===y.shape[0],(()=>`Error in fused conv2d: bias shape (${y.shape}) is not compatible with the number of output channels (${g.outChannels})`)))),null!=l){const e=l.shape;if(se(e.length<=1||3===e.length,(()=>`Error in fused conv2d: only supports scalar, 1-D Tensor or 3-D Tensor PReLU activation weights but got a tensor of rank-${e.length}.`)),1===e.length)se(1===e[0]||e[0]===g.outChannels,(()=>`Error in fused conv2d: PReLU activation weights (${e}) is not compatible with the number of output channels (${g.outChannels}).`));else if(3===e.length)try{Lo(e,g.outShape)}catch(t){const n=`Error in fused conv2d: PReLU activation weights (${e}) is not compatible with the output shape of the conv2d (${g.outShape}).`;throw Error(n)}b=Ci(l,"prelu weights","fused conv2d")}const x=(e,t)=>{se("NHWC"===a,(()=>`Error in gradient of fused conv2D: got dataFormat of ${a} but only NHWC is currently supported.`));const[s,o,l,c]=t,p=Pd(e,l,u);se(xl(i),(()=>`Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${i}'`));const d=[Vl(o.shape,p,s,n,r),Bd(o,p,s.shape,n,r)];if(null!=c){const e=Hd(c,p);d.push(e)}return d},v={x:h,filter:d,bias:y,preluActivationWeights:b},_={strides:n,pad:r,dataFormat:a,dilations:i,dimRoundingMode:s,activation:u,leakyreluAlpha:c};if(null==o){const e=$u(((e,t,n)=>{let r=_i.runKernel(ua,v,_);return n([t,e,r]),f&&(r=Ml(r,[r.shape[1],r.shape[2],r.shape[3]])),{value:r,gradFunc:x}}));return e(h,d)}{const e=$u(((e,t,n,r)=>{let a=_i.runKernel(ua,v,_);return r([t,e,a,n]),f&&(a=Ml(a,[a.shape[1],a.shape[2],a.shape[3]])),{value:a,gradFunc:x}}));return e(h,d,y)}}}),Wd=$i({depthwiseConv2dNativeBackpropFilter_:function(e,t,n,r,a,i=[1,1],s){let o=e;3===e.rank&&(o=Ml(e,[1,e.shape[0],e.shape[1],e.shape[2]]));let u=t;3===u.rank&&(u=Ml(t,[1,t.shape[0],t.shape[1],t.shape[2]]));const l={x:o,dy:u},c={strides:r,pad:a,dimRoundingMode:s,dilations:i,filterShape:n};return _i.runKernel(Ht,l,c)}}),Vd=$i({depthwiseConv2dNativeBackpropInput_:function(e,t,n,r,a,i=[1,1],s){let o=t,u=!1;3===t.rank&&(u=!0,o=Ml(t,[1,t.shape[0],t.shape[1],t.shape[2]]));const l={dy:o,filter:n},c={strides:r,pad:a,dimRoundingMode:s,dilations:i,inputShape:e},p=_i.runKernel(jt,l,c);return u?Ml(p,[p.shape[1],p.shape[2],p.shape[3]]):p}}),Gd=$i({fusedDepthwiseConv2d_:function({x:e,filter:t,strides:n,pad:r,dataFormat:a="NHWC",dilations:i=[1,1],dimRoundingMode:s,bias:o,activation:u="linear",preluActivationWeights:l,leakyreluAlpha:c}){if(!1===Ud(_i.state.gradientDepth,u)){let p=ac(e,t,n,r,a,i,s);return null!=o&&(p=wu(p,o)),jd(p,u,l,c)}const p=Ci(e,"x","depthwiseConv2d","float32"),d=Ci(t,"filter","depthwiseConv2d","float32");let h=p,f=!1;3===p.rank&&(f=!0,h=Ml(p,[1,p.shape[0],p.shape[1],p.shape[2]])),se(4===h.rank,(()=>`Error in fused depthwiseConv2d: input must be rank 4, but got rank ${h.rank}.`)),se(4===d.rank,(()=>`Error in fused depthwiseConv2d: filter must be rank 4, but got rank ${d.rank}.`)),se(h.shape[3]===d.shape[2],(()=>`Error in fused depthwiseConv2d: number of input channels (${h.shape[3]}) must match the inChannels dimension in filter ${d.shape[2]}.`)),null==i&&(i=[1,1]),se(vl(n,i),(()=>`Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides ${n} and dilations '${i}'`)),wl("fused depthwiseConv2d",r,s);const m=dl(h.shape,d.shape,n,i,r,s,!0);let g,y;null!=o&&(g=Ci(o,"bias","fused conv2d"),[g]=di(g,p),Lo(m.outShape,g.shape)),null!=l&&(y=Ci(l,"prelu weights","fused depthwiseConv2d"));const b=(e,t)=>{se(xl(i),(()=>`Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '${i}'`));const[a,o,l,c]=t,p=Pd(e,l,u),d=Vd(o.shape,p,a,n,r,i,s),h=Wd(o,p,a.shape,n,r,i,s);return null!=c?[d,h,Hd(g,p)]:[d,h]},x={x:h,filter:d,bias:g,preluActivationWeights:y},v={strides:n,pad:r,dataFormat:a,dilations:i,dimRoundingMode:s,activation:u,leakyreluAlpha:c};if(null==o){const e=$u(((e,t,n)=>{let r=_i.runKernel(la,x,v);return n([t,e,r]),f&&(r=Ml(r,[r.shape[1],r.shape[2],r.shape[3]])),{value:r,gradFunc:b}}));return e(h,d)}{const e=$u(((e,t,n,r)=>{let a=_i.runKernel(la,x,v);return r([t,e,a,n]),f&&(a=Ml(a,[a.shape[1],a.shape[2],a.shape[3]])),{value:a,gradFunc:b}}));return e(h,d,g)}}}),Kd=$i({fusedMatMul_:function({a:e,b:t,transposeA:n=!1,transposeB:r=!1,bias:a,activation:i="linear",preluActivationWeights:s,leakyreluAlpha:o=.2}){if(!1===Ud(_i.state.gradientDepth,i)){let u=no(e,t,n,r);return null!=a&&(u=wu(u,a)),jd(u,i,s,o)}let u=Ci(e,"a","fused matMul"),l=Ci(t,"b","fused matMul");[u,l]=di(u,l);const c=n?u.shape[u.rank-2]:u.shape[u.rank-1],p=r?l.shape[l.rank-1]:l.shape[l.rank-2],d=n?u.shape[u.rank-1]:u.shape[u.rank-2],h=r?l.shape[l.rank-2]:l.shape[l.rank-1],f=u.shape.slice(0,-2),m=l.shape.slice(0,-2),g=ce(f),y=ce(m);se(c===p,(()=>`Error in fused matMul: inner shapes (${c}) and (${p}) of Tensors with shapes ${u.shape} and ${l.shape} and transposeA=${n} and transposeB=${r} must match.`));const b=Lo(u.shape.slice(0,-2),l.shape.slice(0,-2)).concat([d,h]),x=Ml(u,n?[g,c,d]:[g,d,c]),v=Ml(l,r?[y,h,p]:[y,p,h]);let _,w;null!=a&&(_=Ci(a,"bias","fused matMul"),[_]=di(_,u),Lo(b,_.shape)),null!=s&&(w=Ci(s,"prelu weights","fused matMul"));const M=(e,t)=>{const[s,o,u,l]=t,c=Pd(Ml(e,u.shape),u,i);let p,d;return n||r?!n&&r?(p=no(c,o,!1,!1),d=no(c,s,!0,!1)):n&&!r?(p=no(o,c,!1,!0),d=no(s,c,!1,!1)):(p=no(o,c,!0,!0),d=no(c,s,!0,!0)):(p=no(c,o,!1,!0),d=no(s,c,!0,!1)),null!=a?[p,d,Hd(l,c)]:[p,d]},N={a:x,b:v,bias:_,preluActivationWeights:w},S={transposeA:n,transposeB:r,activation:i,leakyreluAlpha:o};if(null==a){const e=$u(((e,t,n)=>{const r=_i.runKernel(oa,N,S);return n([e,t,r]),{value:Ml(r,b),gradFunc:M}}));return e(x,v)}{const e=$u(((e,t,n,r)=>{const a=_i.runKernel(oa,N,S);return r([e,t,a,n]),{value:Ml(a,b),gradFunc:M}}));return e(x,v,_)}}}),Jd=$i({hammingWindow_:function(e){return Yd(e,.54,.46)}}),Xd=$i({hannWindow_:function(e){return Yd(e,.5,.5)}}),Zd=$i({frame_:function(e,t,n,r=!1,a=0){let i=0;const s=[];for(;i+t<=e.size;)s.push(Tl(e,i,t)),i+=n;if(r)for(;i`Error in cropAndResize: image must be rank 4,but got rank ${s.rank}.`)),se(2===o.rank&&4===o.shape[1],(()=>`Error in cropAndResize: boxes must be have size [${l},4] but had shape ${o.shape}.`)),se(1===u.rank&&u.shape[0]===l,(()=>`Error in cropAndResize: boxInd must be have size [${l}] but had shape ${o.shape}.`)),se(2===r.length,(()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${r.length}.`)),se(r[0]>=1&&r[1]>=1,(()=>`cropSize must be atleast [1,1], but was ${r}`)),se("bilinear"===a||"nearest"===a,(()=>`method must be bilinear or nearest, but was ${a}`));const c={image:s,boxes:o,boxInd:u},p={method:a,extrapolationValue:i,cropSize:r};return _i.runKernel(Yt,c,p)}}),th=$i({flipLeftRight_:function(e){const t=Ci(e,"image","flipLeftRight","float32");se(4===t.rank,(()=>`Error in flipLeftRight: image must be rank 4,but got rank ${t.rank}.`));const n={image:t};return _i.runKernel(sn,n,{})}}),nh=$i({grayscaleToRGB_:function(e){const t=Ci(e,"image","grayscaleToRGB"),n=t.rank-1,r=t.shape[n];se(t.rank>=2,(()=>`Error in grayscaleToRGB: images must be at least rank 2, but got rank ${t.rank}.`)),se(1===r,(()=>`Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${r}.`));const a=new Array(t.rank);return a.fill(1,0,n),a[n]=3,Cc(t,a)}}),rh=$i({rotateWithOffset_:function(e,t,n=0,r=.5){const a=Ci(e,"image","rotateWithOffset","float32");se(4===a.rank,(()=>`Error in rotateWithOffset: image must be rank 4,but got rank ${a.rank}.`));const i={image:a},s={radians:t,fillValue:n,center:r};return _i.runKernel(sa,i,s)}});function ah(e,t,n,r,a,i){null==r&&(r=.5),null==a&&(a=Number.NEGATIVE_INFINITY),null==i&&(i=0);const s=e.shape[0];return n=Math.min(n,s),se(0<=r&&r<=1,(()=>`iouThreshold must be in [0, 1], but was '${r}'`)),se(2===e.rank,(()=>`boxes must be a 2D tensor, but was of rank '${e.rank}'`)),se(4===e.shape[1],(()=>`boxes must have 4 columns, but 2nd dimension was ${e.shape[1]}`)),se(1===t.rank,(()=>"scores must be a 1D tensor")),se(t.shape[0]===s,(()=>`scores has incompatible shape with boxes. Expected ${s}, but was ${t.shape[0]}`)),se(0<=i&&i<=1,(()=>`softNmsSigma must be in [0, 1], but was '${i}'`)),{maxOutputSize:n,iouThreshold:r,scoreThreshold:a,softNmsSigma:i}}const ih=$i({nonMaxSuppression_:function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY){const i=Ci(e,"boxes","nonMaxSuppression","float32"),s=Ci(t,"scores","nonMaxSuppression","float32"),o=ah(i,s,n,r,a),u={maxOutputSize:n=o.maxOutputSize,iouThreshold:r=o.iouThreshold,scoreThreshold:a=o.scoreThreshold};return _i.runKernel(Jn,{boxes:i,scores:s},u)}});function sh(e,t,n){const r=function(e,t,n){return function(e,t,n){let r=0,a=e.length,i=0,s=!1;for(;r>>1);const o=n(t,e[i]);o>0?r=i+1:(a=i,s=!o)}return s?r:-r-1}(e,t,n||oh)}(e,t,n),a=r<0?-(r+1):r;e.splice(a,0,t)}function oh(e,t){return e>t?1:ea&&l.push({score:t[e],boxIndex:e,suppressBeginIndex:0});l.sort(fh);const c=i>0?-.5/i:0,p=[],d=[];for(;p.length0;){const t=l.pop(),{score:n,boxIndex:i,suppressBeginIndex:s}=t;if(n=s;--n){const s=dh(e,i,p[n]);if(s>=r){o=!0;break}if(t.score=t.score*hh(r,c,s),t.score<=a)break}t.suppressBeginIndex=p.length,o||(t.score===n?(p.push(i),d.push(t.score)):t.score>a&&sh(l,t,fh))}const h=p.length,f=n-h;o&&f>0&&(p.push(...new Array(f).fill(0)),d.push(...new Array(f).fill(0)));const m={selectedIndices:p};return s&&(m.selectedScores=d),u&&(m.validOutputs=h),m}function dh(e,t,n){const r=e.subarray(4*t,4*t+4),a=e.subarray(4*n,4*n+4),i=Math.min(r[0],r[2]),s=Math.min(r[1],r[3]),o=Math.max(r[0],r[2]),u=Math.max(r[1],r[3]),l=Math.min(a[0],a[2]),c=Math.min(a[1],a[3]),p=Math.max(a[0],a[2]),d=Math.max(a[1],a[3]),h=(o-i)*(u-s),f=(p-l)*(d-c);if(h<=0||f<=0)return 0;const m=Math.max(i,l),g=Math.max(s,c),y=Math.min(o,p),b=Math.min(u,d),x=Math.max(y-m,0)*Math.max(b-g,0);return x/(h+f-x)}function hh(e,t,n){const r=Math.exp(t*n*n);return n<=e?r:0}function fh(e,t){return e.score-t.score||e.score===t.score&&t.boxIndex-e.boxIndex}const mh=$i({nonMaxSuppressionWithScore_:function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,i=0){const s=Ci(e,"boxes","nonMaxSuppression"),o=Ci(t,"scores","nonMaxSuppression"),u=ah(s,o,n,r,a,i),l={boxes:s,scores:o},c={maxOutputSize:n=u.maxOutputSize,iouThreshold:r=u.iouThreshold,scoreThreshold:a=u.scoreThreshold,softNmsSigma:i=u.softNmsSigma},p=_i.runKernel(Zn,l,c);return{selectedIndices:p[0],selectedScores:p[1]}}}),gh=$i({nonMaxSuppressionPadded_:function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,i=!1){const s=Ci(e,"boxes","nonMaxSuppression"),o=Ci(t,"scores","nonMaxSuppression"),u=ah(s,o,n,r,a,null),l={boxes:s,scores:o},c={maxOutputSize:u.maxOutputSize,iouThreshold:u.iouThreshold,scoreThreshold:u.scoreThreshold,padToMaxOutputSize:i},p=_i.runKernel(Xn,l,c);return{selectedIndices:p[0],validOutputs:p[1]}}}),yh=$i({resizeBilinear_:function(e,t,n=!1,r=!1){const a=Ci(e,"images","resizeBilinear");se(3===a.rank||4===a.rank,(()=>`Error in resizeBilinear: x must be rank 3 or 4, but got rank ${a.rank}.`)),se(2===t.length,(()=>`Error in resizeBilinear: new shape must 2D, but got shape ${t}.`)),se(!1===r||!1===n,(()=>"Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false."));let i=a,s=!1;3===a.rank&&(s=!0,i=Ml(a,[1,a.shape[0],a.shape[1],a.shape[2]]));const[]=t,o={images:i},u={alignCorners:n,halfPixelCenters:r,size:t},l=_i.runKernel(fr,o,u);return s?Ml(l,[l.shape[1],l.shape[2],l.shape[3]]):l}}),bh=$i({resizeNearestNeighbor_:function(e,t,n=!1,r=!1){const a=Ci(e,"images","resizeNearestNeighbor");se(3===a.rank||4===a.rank,(()=>`Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${a.rank}.`)),se(2===t.length,(()=>`Error in resizeNearestNeighbor: new shape must 2D, but got shape ${t}.`)),se("float32"===a.dtype||"int32"===a.dtype,(()=>"`images` must have `int32` or `float32` as dtype")),se(!1===r||!1===n,(()=>"Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false."));let i=a,s=!1;3===a.rank&&(s=!0,i=Ml(a,[1,a.shape[0],a.shape[1],a.shape[2]]));const[]=t,o={images:i},u={alignCorners:n,halfPixelCenters:r,size:t},l=_i.runKernel(dr,o,u);return s?Ml(l,[l.shape[1],l.shape[2],l.shape[3]]):l}}),xh=$i({threshold_:function(e,t="binary",n=!1,r=.5){const a=Ci(e,"image","threshold"),i=a.shape[0]*a.shape[1];let s,o,u,l,c=Su(yd([r]),255);if(se(3===a.rank,(()=>`Error in threshold: image must be rank 3,but got rank ${a.rank}.`)),se(3===a.shape[2]||1===a.shape[2],(()=>`Error in threshold: image color channel must be equal to 3 or 1but got ${a.shape[2]}.`)),se("int32"===a.dtype||"float32"===a.dtype,(()=>`Error in dtype: image dtype must be int32 or float32,but got dtype ${a.dtype}.`)),se("otsu"===t||"binary"===t,(()=>`Method must be binary or otsu, but was ${t}`)),3===a.shape[2]){[s,o,u]=ld(a,[1,1,1],-1);const e=Su(s,.2989),t=Su(o,.587),n=Su(u,.114);l=wu(wu(e,t),n)}else l=e;"otsu"===t&&(c=function(e,t){let n,r,a,i,s,o,u=yd([-1]),l=yd([0]),c=yd([0]);for(let p=0;p`Error in transform: image must be rank 4,but got rank ${s.rank}.`)),se(2===o.rank&&(o.shape[0]===s.shape[0]||1===o.shape[0])&&8===o.shape[1],(()=>"Error in transform: Input transform should be batch x 8 or 1 x 8")),se(null==i||2===i.length,(()=>`Error in transform: outputShape must be [height, width] or null, but got ${i}.`));const u={image:s,transforms:o},l={interpolation:n,fillMode:r,fillValue:a,outputShape:i};return _i.runKernel(Xr,u,l)}}),_h=$i({bandPart_:function(e,t,n){se(t%1==0,(()=>`bandPart(): numLower must be an integer, got ${t}.`)),se(n%1==0,(()=>`bandPart(): numUpper must be an integer, got ${n}.`));const r=Ci(e,"a","bandPart");se(r.rank>=2,(()=>`bandPart(): Rank must be at least 2, got ${r.rank}.`));const a=r.shape,[i,s]=r.shape.slice(-2);if(!(t<=i))throw new Error(`bandPart(): numLower (${t}) must not be greater than the number of rows (${i}).`);if(!(n<=s))throw new Error(`bandPart(): numUpper (${n}) must not be greater than the number of columns (${s}).`);t<0&&(t=i),n<0&&(n=s);const o=Ml(Yp(0,i,1,"int32"),[-1,1]),u=Yp(0,s,1,"int32"),l=Hu(o,u),c=Xc(Hc(l,Ru(+t,"int32")),Rc(l,Ru(-n,"int32"))),p=up([i,s],r.dtype);return Ml(hd(kd(Ml(r,[-1,i,s])).map((e=>uc(c,e,p)))),a)}}),wh=$i({gramSchmidt_:function(e){let t;if(Array.isArray(e)){t=!1,se(null!=e&&e.length>0,(()=>"Gram-Schmidt process: input must not be null, undefined, or empty"));const n=e[0].shape[0];for(let t=1;t`Gram-Schmidt: Non-unique lengths found in the input vectors: (${e[t].shape[0]} vs. ${n})`))}else t=!0,e=ld(e,e.shape[0],0).map((e=>dd(e,[0])));se(e.length<=e[0].shape[0],(()=>`Gram-Schmidt: Number of vectors (${e.length}) exceeds number of dimensions (${e[0].shape[0]}).`));const n=[],r=e;for(let t=0;t{let e=r[t];if(t>0)for(let r=0;r{se(2===e.shape.length,(()=>`qr2d() requires a 2D Tensor, but got a ${e.shape.length}D Tensor.`));const n=e.shape[0],r=e.shape[1];let a=Ac(n),i=$s(e);const s=bd([[1]],[1,1]);let o=$s(s);const u=n>=r?r:n;for(let e=0;e{const t=Tl(i,[e,e],[n-e,1]),u=kc(t),l=Tl(i,[e,e],[1,1]),c=uc(Oc(l,0),bd([[-1]]),bd([[1]])),p=Hu(l,Su(c,u)),d=Nu(t,p);o=1===d.shape[0]?$s(s):kl([s,Tl(d,[1,0],[d.shape[0]-1,d.shape[1]])],0);const h=Do(Nu(no(c,p),u)),f=Tl(i,[e,0],[n-e,r]),m=Su(h,o),g=Io(o);if(0===e)i=Hu(f,no(m,no(g,f)));else{const t=Hu(f,no(m,no(g,f)));i=kl([Tl(i,[0,0],[e,r]),t],0)}const y=Io(m),b=Tl(a,[0,e],[n,a.shape[1]-e]);if(0===e)a=Hu(b,no(no(b,o),y));else{const t=Hu(b,no(no(b,o),y));a=kl([Tl(a,[0,0],[n,e]),t],1)}return[o,i,a]})),fo([t,u,l])}return!t&&n>r&&(a=Tl(a,[0,0],[n,r]),i=Tl(i,[0,0],[r,r])),[a,i]}))}const Nh=$i({qr_:function(e,t=!1){if(se(e.rank>=2,(()=>`qr() requires input tensor to have a rank >= 2, but got rank ${e.rank}`)),2===e.rank)return Mh(e,t);{const n=e.shape.slice(0,e.shape.length-2).reduce(((e,t)=>e*t)),r=kd(Ml(e,[n,e.shape[e.shape.length-2],e.shape[e.shape.length-1]]),0),a=[],i=[];return r.forEach((e=>{const[n,r]=Mh(e,t);a.push(n),i.push(r)})),[Ml(hd(a,0),e.shape),Ml(hd(i,0),e.shape)]}}});var Sh;!function(e){e[e.NONE=0]="NONE",e[e.MEAN=1]="MEAN",e[e.SUM=2]="SUM",e[e.SUM_BY_NONZERO_WEIGHTS=3]="SUM_BY_NONZERO_WEIGHTS"}(Sh||(Sh={}));const kh=$i({computeWeightedLoss_:function(e,t,n=Sh.SUM_BY_NONZERO_WEIGHTS){const r=Ci(e,"losses","computeWeightedLoss");let a=null;null!=t&&(a=Ci(t,"weights","computeWeightedLoss"));const i=null==a?r:Su(r,a);if(n===Sh.NONE)return i;if(n===Sh.SUM)return Nc(i);if(n===Sh.MEAN){if(null==a)return op(i);{const e=r.size/a.size,t=Nu(Nc(i),Nc(a));return e>1?Nu(t,Ru(e)):t}}if(n===Sh.SUM_BY_NONZERO_WEIGHTS){if(null==a)return Nu(Nc(i),Ru(r.size));{const e=Su(a,lp(r.shape)),t=Ls(Nc(yp(e,Ru(0))),"float32");return Nu(Nc(i),t)}}throw Error(`Unknown reduction: ${n}`)}}),Dh=$i({absoluteDifference_:function(e,t,n,r=Sh.SUM_BY_NONZERO_WEIGHTS){const a=Ci(e,"labels","absoluteDifference"),i=Ci(t,"predictions","absoluteDifference");let s=null;null!=n&&(s=Ci(n,"weights","absoluteDifference")),oe(a.shape,i.shape,"Error in absoluteDifference: ");const o=Uu(Hu(a,i));return kh(o,s,r)}}),Th=$i({cosineDistance_:function(e,t,n,r,a=Sh.SUM_BY_NONZERO_WEIGHTS){const i=Ci(e,"labels","cosineDistance"),s=Ci(t,"predictions","cosineDistance");let o=null;null!=r&&(o=Ci(r,"weights","cosineDistance")),oe(i.shape,s.shape,"Error in cosineDistance: ");const u=Ru(1),l=Hu(u,Nc(Su(i,s),n,!0));return kh(l,o,a)}}),Ih=$i({hingeLoss_:function(e,t,n,r=Sh.SUM_BY_NONZERO_WEIGHTS){let a=Ci(e,"labels","hingeLoss");const i=Ci(t,"predictions","hingeLoss");let s=null;null!=n&&(s=Ci(n,"weights","hingeLoss")),oe(a.shape,i.shape,"Error in hingeLoss: ");const o=Ru(1);a=Hu(Su(Ru(2),a),o);const u=Bp(Hu(o,Su(a,i)));return kh(u,s,r)}}),Eh=$i({huberLoss_:function(e,t,n,r=1,a=Sh.SUM_BY_NONZERO_WEIGHTS){const i=Ci(e,"labels","huberLoss"),s=Ci(t,"predictions","huberLoss");let o=null;null!=n&&(o=Ci(n,"weights","huberLoss")),oe(i.shape,s.shape,"Error in huberLoss: ");const u=Ru(r),l=Uu(Hu(s,i)),c=pp(l,u),p=Hu(l,c),d=wu(Su(Ru(.5),Du(c)),Su(u,p));return kh(d,o,a)}}),Ch=$i({logLoss_:function(e,t,n,r=1e-7,a=Sh.SUM_BY_NONZERO_WEIGHTS){const i=Ci(e,"labels","logLoss"),s=Ci(t,"predictions","logLoss");let o=null;null!=n&&(o=Ci(n,"weights","logLoss")),oe(i.shape,s.shape,"Error in logLoss: ");const u=Ru(1),l=Ru(r),c=Do(Su(i,qc(wu(s,l)))),p=Su(Hu(u,i),qc(wu(Hu(u,s),l))),d=Hu(c,p);return kh(d,o,a)}}),Ah=$i({meanSquaredError_:function(e,t,n,r=Sh.SUM_BY_NONZERO_WEIGHTS){const a=Ci(e,"labels","meanSquaredError"),i=Ci(t,"predictions","meanSquaredError");let s=null;null!=n&&(s=Ci(n,"weights","meanSquaredError")),oe(a.shape,i.shape,"Error in meanSquaredError: ");const o=pd(a,i);return kh(o,s,r)}}),Lh=$i({sigmoidCrossEntropy_:function(e,t,n,r=0,a=Sh.SUM_BY_NONZERO_WEIGHTS){let i=Ci(e,"multiClassLabels","sigmoidCrossEntropy");const s=Ci(t,"logits","sigmoidCrossEntropy");let o=null;if(null!=n&&(o=Ci(n,"weights","sigmoidCrossEntropy")),oe(i.shape,s.shape,"Error in sigmoidCrossEntropy: "),r>0){const e=Ru(r),t=Ru(1),n=Ru(.5);i=wu(Su(i,Hu(t,e)),Su(n,e))}const u=function(e,t){const n=Ci(e,"labels","sigmoidCrossEntropyWithLogits"),r=Ci(t,"logits","sigmoidCrossEntropyWithLogits");oe(n.shape,r.shape,"Error in sigmoidCrossEntropyWithLogits: ");const a=Bp(r),i=Su(r,n),s=Wc(Tc(Do(Uu(r))));return wu(Hu(a,i),s)}(i,s);return kh(u,o,a)}}),$h=$i({softmaxCrossEntropy_:function(e,t,n,r=0,a=Sh.SUM_BY_NONZERO_WEIGHTS){let i=Ci(e,"onehotLabels","softmaxCrossEntropy");const s=Ci(t,"logits","softmaxCrossEntropy");let o=null;if(null!=n&&(o=Ci(n,"weights","softmaxCrossEntropy")),oe(i.shape,s.shape,"Error in softmaxCrossEntropy: "),r>0){const e=Ru(r),t=Ru(1),n=Ru(i.shape[1]);i=wu(Su(i,Hu(t,e)),Nu(e,n))}const u=function(e,t,n=-1){if(-1===n&&(n=t.rank-1),n!==t.rank-1)throw Error(`Softmax cross entropy along a non-last dimension is not yet supported. Labels / logits was rank ${t.rank} and dim was ${n}`);const r=$u(((e,t,r)=>{const a=Jc(t,[n],!0),i=Hu(Ls(t,"float32"),a);r([e,i]);const s=Do(Su(i,e));return{value:Nc(s,[n]),gradFunc:(e,t)=>{const[r,a]=t,i=yc(e.shape,[n]);return[Su(Ml(e,i),Hu(Ls(r,"float32"),Tc(a))),Su(Ml(e,i),Hu(Tc(a),Ls(r,"float32")))]}}}));return r(e,t)}(i,s);return kh(u,o,a)}}),Oh=$i({sparseFillEmptyRows_:function(e,t,n,r){const a=Ci(e,"indices","sparseFillEmptyRows","int32"),i=Ci(t,"values","sparseFillEmptyRows"),s=Ci(n,"denseShape","sparseFillEmptyRows","int32"),o=Ci(r,"defaultValue","sparseFillEmptyRows",i.dtype);if(2!==a.rank)throw new Error(`Indices should be Tensor2D but received shape\n ${a.shape}`);if(1!==i.rank)throw new Error(`Values should be Tensor1D but received shape ${i.shape}`);if(1!==s.rank)throw new Error(`Dense shape should be Tensor1D but received shape ${s.shape}`);if(0!==o.rank)throw new Error(`Default value should be a scalar but received shape ${o.shape}`);const u={indices:a,values:i,denseShape:s,defaultValue:o},l=_i.runKernel(Or,u);return{outputIndices:l[0],outputValues:l[1],emptyRowIndicator:l[2],reverseIndexMap:l[3]}}}),Rh=$i({sparseReshape_:function(e,t,n){const r=Ci(e,"inputIndices","sparseReshape","int32"),a=Ci(t,"inputShape","sparseReshape","int32"),i=Ci(n,"newShape","sparseReshape","int32");if(2!==r.rank)throw new Error(`Input indices should be Tensor2D but received shape\n ${r.shape}`);if(1!==a.rank)throw new Error(`Input shape should be Tensor1D but received shape ${a.shape}`);if(1!==i.rank)throw new Error(`New shape should be Tensor1D but received shape ${i.shape}`);const s={inputIndices:r,inputShape:a,newShape:i},o=_i.runKernel(Rr,s);return{outputIndices:o[0],outputShape:o[1]}}}),Fh=$i({sparseSegmentMean_:function(e,t,n){const r=Ci(e,"data","sparseSegmentMean"),a=Ci(t,"indices","sparseSegmentMean","int32"),i=Ci(n,"segmentIds","sparseSegmentMean","int32");if(r.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.rank)throw new Error(`Indices should be Tensor1D but received shape\n ${a.shape}`);if(1!==i.rank)throw new Error(`Segment ids should be Tensor1D but received shape\n ${i.shape}`);const s={data:r,indices:a,segmentIds:i};return _i.runKernel(Fr,s)}}),Yh=$i({sparseSegmentSum_:function(e,t,n){const r=Ci(e,"data","sparseSegmentSum"),a=Ci(t,"indices","sparseSegmentSum","int32"),i=Ci(n,"segmentIds","sparseSegmentSum","int32");if(r.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.rank)throw new Error(`Indices should be Tensor1D but received shape\n ${a.shape}`);if(1!==i.rank)throw new Error(`Segment ids should be Tensor1D but received shape\n ${i.shape}`);const s={data:r,indices:a,segmentIds:i};return _i.runKernel(Yr,s)}}),zh=$i({stringNGrams_:function(e,t,n,r,a,i,s,o){const u=Ci(e,"data","stringNGrams","string");if("string"!==u.dtype)throw new Error("Data must be of datatype string");if(1!==u.shape.length)throw new Error(`Data must be a vector, saw: ${u.shape}`);const l=Ci(t,"dataSplits","stringNGrams");if("int32"!==l.dtype)throw new Error("Data splits must be of datatype int32");const c={separator:n,nGramWidths:r,leftPad:a,rightPad:i,padWidth:s,preserveShortSequences:o},p={data:u,dataSplits:l},d=_i.runKernel(jr,p,c);return{nGrams:d[0],nGramsSplits:d[1]}}}),Bh=$i({stringSplit_:function(e,t,n=!0){const r=Ci(e,"input","stringSplit","string"),a=Ci(t,"delimiter","stringSplit","string");if(1!==r.rank)throw new Error(`Input should be Tensor1D but received shape ${r.shape}`);if(0!==a.rank)throw new Error(`Delimiter should be a scalar but received shape ${a.shape}`);const i={skipEmpty:n},s={input:r,delimiter:a},o=_i.runKernel(Ur,s,i);return{indices:o[0],values:o[1],shape:o[2]}}}),Ph=$i({stringToHashBucketFast_:function(e,t){const n=Ci(e,"input","stringToHashBucketFast","string"),r={numBuckets:t};if(t<=0)throw new Error("Number of buckets must be at least 1");const a={input:n};return _i.runKernel(qr,a,r)}}),Hh={fft:sd,ifft:od,rfft:cd,irfft:ud},jh={hammingWindow:Jd,hannWindow:Xd,frame:Zd,stft:Qd},Uh={flipLeftRight:th,grayscaleToRGB:nh,resizeNearestNeighbor:bh,resizeBilinear:yh,rotateWithOffset:rh,cropAndResize:eh,nonMaxSuppression:ih,nonMaxSuppressionAsync:async function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY){const i=Ci(e,"boxes","nonMaxSuppressionAsync"),s=Ci(t,"scores","nonMaxSuppressionAsync"),o=ah(i,s,n,r,a);n=o.maxOutputSize,r=o.iouThreshold,a=o.scoreThreshold;const u=await Promise.all([i.data(),s.data()]),l=u[0],c=u[1],{selectedIndices:p}=uh(l,c,n,r,a);return i!==e&&i.dispose(),s!==t&&s.dispose(),yd(p,"int32")},nonMaxSuppressionWithScore:mh,nonMaxSuppressionWithScoreAsync:async function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,i=0){const s=Ci(e,"boxes","nonMaxSuppressionAsync"),o=Ci(t,"scores","nonMaxSuppressionAsync"),u=ah(s,o,n,r,a,i);n=u.maxOutputSize,r=u.iouThreshold,a=u.scoreThreshold,i=u.softNmsSigma;const l=await Promise.all([s.data(),o.data()]),c=l[0],p=l[1],{selectedIndices:d,selectedScores:h}=ch(c,p,n,r,a,i);return s!==e&&s.dispose(),o!==t&&o.dispose(),{selectedIndices:yd(d,"int32"),selectedScores:yd(h)}},nonMaxSuppressionPadded:gh,nonMaxSuppressionPaddedAsync:async function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,i=!1){const s=Ci(e,"boxes","nonMaxSuppressionAsync"),o=Ci(t,"scores","nonMaxSuppressionAsync"),u=ah(s,o,n,r,a,null),l=u.maxOutputSize,c=u.iouThreshold,p=u.scoreThreshold,[d,h]=await Promise.all([s.data(),o.data()]),{selectedIndices:f,validOutputs:m}=lh(d,h,l,c,p,i);return s!==e&&s.dispose(),o!==t&&o.dispose(),{selectedIndices:yd(f,"int32"),validOutputs:Ru(m,"int32")}},threshold:xh,transform:vh},qh={bandPart:_h,gramSchmidt:wh,qr:Nh},Wh={absoluteDifference:Dh,computeWeightedLoss:kh,cosineDistance:Th,hingeLoss:Ih,huberLoss:Eh,logLoss:Ch,meanSquaredError:Ah,sigmoidCrossEntropy:Lh,softmaxCrossEntropy:$h},Vh={sparseFillEmptyRows:Oh,sparseReshape:Rh,sparseSegmentMean:Fh,sparseSegmentSum:Yh},Gh={stringNGrams:zh,stringSplit:Bh,stringToHashBucketFast:Ph},Kh={sgd:Ju.sgd,momentum:Ju.momentum,adadelta:Ju.adadelta,adagrad:Ju.adagrad,rmsprop:Ju.rmsprop,adamax:Ju.adamax,adam:Ju.adam},Jh="undefined"!=typeof requestAnimationFrame?requestAnimationFrame:"undefined"!=typeof setImmediate?setImmediate:e=>e();function Xh(){return new Promise((e=>Jh((()=>e()))))}function Zh(e,t){const n=e[0].length;e.forEach(((e,t)=>{se(e.length===n,(()=>`Error in concat${n}D: rank of tensors[${t}] must be the same as the rank of the rest (${n})`))})),se(t>=0&&t`Error in concat${n}D: axis must be between 0 and ${n-1}.`));const r=e[0];e.forEach(((e,a)=>{for(let i=0;i`Error in concat${n}D: Shape of tensors[${a}] (${e}) does not match the shape of the rest (${r}) along the non-concatenated axis ${a}.`))}))}function Qh(e,t){const n=e[0].slice();for(let r=1;r=2*t+1||r%2==1?a.push(r):n.push(r);r.push(...n),r.push(0),r.push(...a)}return r}function sf(e,t,n,r=!0){const a=[];r?a.push(e[0]/n):a.push(e[0]*n);for(let n=1;n/g;function kf(e,t){const n=((e=e.replace(/\s/g,"")).length-e.replace(Sf,"").length)/"->".length;if(n<1)throw new Error("Equations without an arrow are not supported.");if(n>1)throw new Error('Equation must contain exactly one arrow ("->").');const[r,a]=e.split("->");se(-1===r.indexOf("..."),(()=>'The ellipsis notation ("...") is not supported yet.'));const i=r.split(","),s=i.length;if(t!==s)throw new Error(`Expected ${s} input tensors, received ${t}`);if(s>2)throw new Error("Support for more than 2 input tensors is not implemented yet.");const o=[];for(let e=0;e-1!==e.indexOf(t))))throw new Error(`Output subscripts contain the label ${t} not present in the input subscripts.`);-1===o.indexOf(t)&&o.push(t)}for(let e=0;e-1!==e)),{permutationIndices:n,expandDims:r}}function Tf(e,t,n){const r=new Array(e);for(let e=0;e`Expected dimension ${r[t[e][n]]} at axis ${n} of input shaped ${JSON.stringify(a)}, but got dimension ${a[n]}`))}}function If(e,t){const n=e,r=[];let a=0;0===e.length&&n.push(-1),a=e.length+1;for(let e=0;ee===t))}function Cf(e,t){const n=[];for(let r=0;r"Number of splits must evenly divide the axis.")),r=new Array(t).fill(e.shape[n]/t);else{const a=t.reduce(((e,t)=>(-1===t&&(e+=1),e)),0);se(a<=1,(()=>"There should be only one negative value in split array."));const i=t.indexOf(-1);if(-1!==i){const r=t.reduce(((e,t)=>t>0?e+t:e));t[i]=e.shape[n]-r}se(e.shape[n]===t.reduce(((e,t)=>e+t)),(()=>"The sum of sizes must match the size of the axis dimension.")),r=t}return r}function Lf(e){return`Received SparseTensor with denseShape[0] = 0 but\n indices.shape[0] = ${e}`}function $f(e,t){return`indices(${e}, 0) is invalid: ${t} < 0`}function Of(e,t,n){return`indices(${e}, 0) is invalid: ${t} >= ${n}`}function Rf(e,t){return`only one output dimension may be -1, not both ${e} and ${t}`}function Ff(e,t){return`size ${e} must be non-negative, not ${t}`}function Yf(){return"reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero"}function zf(e,t){return`Input to reshape is a SparseTensor with ${ce(e)}\n dense values, but the requested shape requires a multiple of ${ce(t)}. inputShape=${e} outputShape= ${t}`}function Bf(e,t){return`Input to reshape is a tensor with ${ce(e)} dense values, but the requested shape has ${ce(t)}. inputShape=${e} outputShape=${t}`}function Pf(){return"segment ids must be >= 0"}function Hf(){return"segment ids are not increasing"}function jf(e,t){return`Segment id ${e} out of range [0, ${t}), possibly because segmentIds input is not sorted.`}function Uf(e,t,n){return`Bad: indices[${e}] == ${t} out of range [0, ${n})`}function qf(e,t){let n,r=!1;for(e<=ef?(n=e,r=!0):n=Oe(e,Math.floor(Math.sqrt(e)));!r;)n>t||n===e?r=!0:n=Oe(e,n+1);return n}function Wf(e,t,n){const r=[],a=e.length;for(let i=0;ia))throw new Error(`Expect batchDims in the range of [-${a}, ${a}], but got ${r}`);if(r<0&&(r+=a),r>i)throw new Error(`batchDims (${r}) must be less than rank(x) (\n ${i}).`);if(nHa(e)))}catch(e){throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${e}`)}}function Kf(e){return e.map((e=>Pa(e)))}const Jf={kernelName:Qe,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Su(e,fd(Ls(n,"float32"),-1))}}},Xf={kernelName:et,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>{const t=Du(Ls(n,"float32")),r=ku(Hu(Ru(1),t));return Do(Nu(e,r))}}}},Zf={kernelName:tt,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>{const t=ku(Hu(Du(Ls(n,"float32")),1));return Nu(e,t)}}}},Qf={kernelName:nt,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t,a=Lo(n.shape,r.shape);return{a:()=>{let t=e;const r=Ao(n.shape,a);return r.length>0&&(t=Nc(t,r)),Ml(t,n.shape)},b:()=>{let t=e;const n=Ao(r.shape,a);return n.length>0&&(t=Nc(t,n)),Ml(t,r.shape)}}}},em={kernelName:rt,saveAllInputs:!0,gradFunc:(e,t)=>{const n={};return t.forEach(((t,r)=>{n[r]=()=>e.clone()})),n}},tm={kernelName:st,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Tu(n)}}},nm={kernelName:ot,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Tu(n)}}},rm={kernelName:ut,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Nu(e,ku(Hu(Ru(1),Du(Ls(n,"float32")))))}}},am={kernelName:lt,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>{const t=ku(wu(Ru(1),Du(Ls(n,"float32"))));return Nu(e,t)}}}},im={kernelName:dt,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t,a=Lo(n.shape,r.shape);return{a:()=>{const t=wu(Du(n),Du(r));let i=Su(e,Nu(r,t));const s=Ao(n.shape,a);return s.length>0&&(i=Nc(i,s)),Ml(i,n.shape)},b:()=>{const t=wu(Du(n),Du(r));let i=Do(Su(e,Nu(n,t)));const s=Ao(r.shape,a);return s.length>0&&(i=Nc(i,s)),Ml(i,r.shape)}}}},sm={kernelName:ct,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Nu(e,wu(Du(Ls(n,"float32")),1))}}},om={kernelName:pt,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Nu(e,Hu(Ru(1),Du(Ls(n,"float32"))))}}},um=$i({avgPool3dGrad_:function(e,t,n,r,a,i){const s=Ci(e,"dy","avgPool3dGrad"),o=Ci(t,"input","avgPool3dGrad");let u=s,l=o,c=!1;4===o.rank&&(c=!0,u=Ml(s,[1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]]),l=Ml(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),se(5===u.rank,(()=>`Error in avgPool3dGrad: dy must be rank 5 but got rank ${u.rank}.`)),se(5===l.rank,(()=>`Error in avgPool3dGrad: input must be rank 5 but got rank ${l.rank}.`)),wl("avgPool3dGrad",a,i);const p={dy:u,input:l},d={filterSize:n,strides:r,pad:a,dimRoundingMode:i},h=_i.runKernel(gt,p,d);return c?Ml(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}}),lm={kernelName:mt,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{filterSize:a,strides:i,pad:s,dimRoundingMode:o}=n;return{x:()=>um(e,r,a,i,s,o)}}},cm=$i({avgPoolGrad_:function(e,t,n,r,a){const i=Ci(e,"dy","avgPoolGrad"),s=Ci(t,"input","avgPoolGrad");se(s.rank===i.rank,(()=>`Rank of input (${s.rank}) does not match rank of dy (${i.rank})`));let o=s,u=i,l=!1;3===s.rank&&(l=!0,o=Ml(s,[1,s.shape[0],s.shape[1],s.shape[2]]),u=Ml(i,[1,i.shape[0],i.shape[1],i.shape[2]])),se(4===u.rank,(()=>`Error in avgPoolGrad: dy must be rank 4 but got rank ${u.rank}.`)),se(4===o.rank,(()=>`Error in avgPoolGrad: input must be rank 4 but got rank ${o.rank}.`));const c={dy:u,input:o},p={filterSize:n,strides:r,pad:a},d=_i.runKernel(ft,c,p);return l?Ml(d,[d.shape[1],d.shape[2],d.shape[3]]):d}}),pm={kernelName:ht,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{filterSize:a,strides:i,pad:s}=n;return{x:()=>cm(e,r,a,i,s)}}},dm={kernelName:yt,inputsToSave:["a","b"],gradFunc:(e,t,n)=>{const[r,a]=t,{transposeA:i,transposeB:s}=n;return i||s?!i&&s?{a:()=>no(e,a,!1,!1),b:()=>no(e,r,!0,!1)}:i&&!s?{a:()=>no(a,e,!1,!0),b:()=>no(r,e,!1,!1)}:{a:()=>no(a,e,!0,!0),b:()=>no(e,r,!0,!0)}:{a:()=>no(e,a,!1,!0),b:()=>no(r,e,!0,!1)}}},hm={kernelName:bt,gradFunc:(e,t,n)=>{const{blockShape:r,crops:a}=n;return{x:()=>Sp(e,r,a)}}},fm={kernelName:vt,gradFunc:(e,t,n)=>{const r=n,a=r.inputShape,i=r.shape,s=Array.from(i);for(let e=a.length-1;e>=0;e--)if(a[e]===i[e])s[e]=1;else if(1!==a[e])throw new Error(`broadcastTo(): [${a}] cannot be broadcast to [${i}].`);const o=[];for(let e=0;e1&&o.push(e);return{x:()=>Nc(e,o,!0)}}},mm={kernelName:wt,gradFunc:e=>({x:()=>e.clone()})},gm={kernelName:Mt,gradFunc:e=>({x:()=>Tu(e)})},ym={kernelName:Nt,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{clipValueMin:a,clipValueMax:i}=n;return{x:()=>uc(Xc(Rc(r,a),Hc(r,i)),e,Tu(e))}}},bm={kernelName:kt,inputsToSave:["x"],gradFunc:Jf.gradFunc},xm={kernelName:Dt,saveAllInputs:!0,gradFunc:(e,t,n)=>{const r=t.map((e=>e.shape)),{axis:a}=n,i=ve(a,t[0].shape)[0],s=r.map((e=>e[i]));return ld(e,s,i).map((e=>()=>e))}},vm={kernelName:Tt,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{const[r,a]=t,{dilations:i,strides:s,pad:o,dataFormat:u}=n;return se(xl(i),(()=>`Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${i}'`)),{x:()=>Vl(r.shape,e,a,s,o,u),filter:()=>Bd(r,e,a.shape,s,o,u)}}},_m={kernelName:Et,inputsToSave:["dy","filter"],gradFunc:(e,t,n)=>{const[r,a]=t,{strides:i,pad:s,dataFormat:o,dimRoundingMode:u}=n;return{dy:()=>ql(e,a,i,s,o,1,u),filter:()=>Bd(e,r,a.shape,i,s,o,u)}}},wm=$i({conv3DBackpropFilter_:function(e,t,n,r,a){let i=e;4===e.rank&&(i=Ml(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]]));let s=t;4===s.rank&&(s=Ml(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]])),se(5===i.rank,(()=>`Error in conv3dDerFilter: input must be rank 5, but got shape ${i.shape}.`)),se(5===s.rank,(()=>`Error in conv3dDerFilter: dy must be rank 5, but got shape ${s.shape}.`)),se(5===n.length,(()=>`Error in conv3dDerFilter: filterShape must be length 5, but got ${n}.`)),se(i.shape[4]===n[3],(()=>`Error in conv3dDerFilter: depth of input ${i.shape[4]}) must match input depth in filter (${n[3]}.`)),se(s.shape[4]===n[4],(()=>`Error in conv3dDerFilter: depth of dy (${s.shape[4]}) must match output depth for filter (${n[4]}).`));const o={x:i,dy:s},u={strides:r,pad:a,filterShape:n};return _i.runKernel(At,o,u)}}),Mm={kernelName:Ct,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{const{dilations:r,strides:a,pad:i}=n;se(xl(r),(()=>`Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${r}'`));const[s,o]=t;return{x:()=>Jl(s.shape,e,o,a,i),filter:()=>wm(s,e,o.shape,a,i)}}},Nm={kernelName:$t,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Su(Do(Qp(Ls(n,"float32"))),e)}}},Sm={kernelName:Ot,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Su(ed(Ls(n,"float32")),e)}}},km={kernelName:Ft,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{axis:a,exclusive:i,reverse:s}=n;return{x:()=>{const t=xc([a],r.rank);let n=tc(e,a,i,!s);return null!=t&&(n=Io(n,t)),n}}}},Dm={kernelName:Pt,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{const{dilations:r,strides:a,pad:i,dimRoundingMode:s}=n,o=null==r?[1,1]:r;se(xl(o),(()=>`Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations '${o}'`));const[u,l]=t;return se(4===u.rank,(()=>`Error in gradient of depthwiseConv2dNative: input must be rank 4, but got rank ${u.rank}.`)),se(4===l.rank,(()=>`Error in gradient of depthwiseConv2dNative: filter must be rank 4, but got rank ${l.rank}.`)),se(u.shape[3]===l.shape[2],(()=>`Error in gradient of depthwiseConv2d: number of input channels (${u.shape[3]}) must match the inChannels dimension in filter ${l.shape[2]}.`)),se(vl(a,o),(()=>`Error in gradient of depthwiseConv2d: Either strides or dilations must be 1. Got strides ${a} and dilations '${o}'.`)),wl("depthwiseConv2d",i,s),{x:()=>Vd(u.shape,e,l,a,i,o,s),filter:()=>Wd(u,e,l.shape,a,i,o,s)}}},Tm={kernelName:qt,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{const[r,a]=t,i={x:r,filter:a,dy:e},s={x:r,filter:a,dy:e};return{x:()=>_i.runKernel(Wt,i,n),filter:()=>_i.runKernel(Vt,s,n)}}},Im={kernelName:Jt,outputsToSave:[!0],gradFunc:(e,t)=>{const[n]=t,r={dy:e,y:n};return{x:()=>_i.runKernel(Xt,r)}}},Em={kernelName:Zt,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t,r=Su(Tc(Do(Du(n))),2/Math.sqrt(Math.PI));return{x:()=>Su(e,r)}}},Cm={kernelName:en,outputsToSave:[!0],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Su(e,n)}}},Am={kernelName:tn,inputsToSave:["input"],gradFunc:(e,t)=>{const[n]=t;return{input:()=>Ml(e,n.shape)}}},Lm={kernelName:nn,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Su(e,Tc(n))}}},$m={kernelName:on,gradFunc:e=>({x:()=>Tu(e)})},Om={kernelName:un,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t,a=Lo(n.shape,r.shape);return{a:()=>{const t=Nu(e,Ls(r,"float32")),i=Ao(n.shape,a);return i.length>0?Ml(Nc(t,i),n.shape):t},b:()=>{let t=Su(e,Ls(n,"float32"));const i=Ao(r.shape,a);i.length>0&&(t=Ml(Nc(t,i),r.shape));const s=Du(r);return Do(Nu(t,Ls(s,"float32")))}}}},Rm={kernelName:ln,inputsToSave:["x","mean","variance","scale"],gradFunc:(e,t,n)=>{const{varianceEpsilon:r}=n,[a,i,s,o]=t,u=null==o?Ru(1):o,l=Ao(i.shape,a.shape),c=[];if(1===i.rank){for(let e=0;e1===i.rank?Ml(Su(Su(e,Cc(Ml(h,[1,1,1,i.shape[0]]),c)),u),a.shape):Ml(Su(Su(e,h),u),a.shape),mean:()=>{let e=Su(Su(h,Ru(-1)),d);return 1===i.rank&&(e=Nc(e,l)),Ml(e,i.shape)},variance:()=>{let e=Su(Su(f,p),d);return 1===i.rank&&(e=Nc(e,l)),Ml(e,i.shape)},scale:()=>{const t=Su(p,h);let n=Su(e,t);return 1===i.rank&&(n=Nc(n,l)),Ml(n,i.shape)},offset:()=>{let t=e;return 1===i.rank&&(t=Nc(t,l)),Ml(t,i.shape)}}}},Fm={kernelName:cn,inputsToSave:["x","indices"],gradFunc:(e,t,n)=>{const[r,a]=t,{axis:i}=n,s=ve(i,r.shape)[0];return{x:()=>{const t=r.shape,n=a.size,o=t.slice(0,s),u=o.length,l=t.slice(i,t.length).slice(1),c=l.length,p=Ym(0,u),d=Ym(u+1,u+1+c),h=zm([o,[n],l]),f=Ml(e,h),m=Ml(a,[n]),g=zm([[u],p,d]),y=Io(f,g);let b=Sd(y,m,r.shape[s]);const x=vc(g);return b=Io(b,x),b},indices:()=>a}}};function Ym(e,t){const n=[];for(let r=e;r{const[n,r]=t;return{a:()=>Tu(n),b:()=>Tu(r)}}},Pm={kernelName:fn,gradFunc:e=>({x:()=>Ls(e,"float32")})},Hm={kernelName:yn,gradFunc:e=>({x:()=>Tu(e)})},jm={kernelName:bn,gradFunc:e=>({x:()=>Tu(e)})},Um={kernelName:xn,gradFunc:e=>({x:()=>Tu(e)})},qm={kernelName:vn,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{alpha:a}=n,i=Oc(r,0);return{x:()=>uc(i,e,Su(e,a))}}},Wm={kernelName:Sn,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Nu(e,wu(n,1))}}},Vm={kernelName:Nn,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Nu(e,Ls(n,"float32"))}}},Gm={kernelName:En,inputsToSave:[],outputsToSave:[!0],gradFunc:(e,t,n)=>{const[r]=t,{axis:a}=n;return{logits:()=>{const t=Tc(r);return Hu(e,Su(Nc(e,a,!0),t))}}}},Km=$i({localResponseNormalizationBackprop_:function(e,t,n,r=5,a=1,i=1,s=.5){const o={x:e,y:t,dy:n},u={depthRadius:r,bias:a,alpha:i,beta:s};return _i.runKernel(Ln,o,u)}}),Jm={kernelName:An,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{const[r,a]=t,{depthRadius:i,bias:s,alpha:o,beta:u}=n;return{x:()=>Km(r,a,e,i,s,o,u)}}};function Xm(e,t,n,r){return t.rankSu(e,Ls(oc(n,t),e.dtype))}}const Zm={kernelName:$n,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{const r=n,{reductionIndices:a}=r,i=t[0],s=Xm(e,t[1],i,ve(a,i.shape));return{x:()=>s.x()}}},Qm={kernelName:On,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t;return{a:()=>Su(e,Ls(Rc(n,r),"float32")),b:()=>Su(e,Ls(Pc(n,r),"float32"))}}},eg=$i({maxPool3dGrad_:function(e,t,n,r,a,i,s){const o=Ci(e,"dy","maxPool3dGrad"),u=Ci(t,"input","maxPool3dGrad"),l=Ci(n,"output","maxPool3dGrad");let c=o,p=u,d=l,h=!1;4===u.rank&&(h=!0,c=Ml(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]]),p=Ml(u,[1,u.shape[0],u.shape[1],u.shape[2],u.shape[3]]),d=Ml(l,[1,l.shape[0],l.shape[1],l.shape[2],l.shape[3]])),se(5===c.rank,(()=>`Error in maxPool3dGrad: dy must be rank 5 but got rank ${c.rank}.`)),se(5===p.rank,(()=>`Error in maxPool3dGrad: input must be rank 5 but got rank ${p.rank}.`)),se(5===d.rank,(()=>`Error in maxPool3dGrad: output must be rank 5 but got rank ${d.rank}.`)),wl("maxPool3dGrad",i,s);const f={dy:c,input:p,output:d},m={filterSize:r,strides:a,pad:i,dimRoundingMode:s},g=_i.runKernel(zn,f,m);return h?Ml(g,[g.shape[1],g.shape[2],g.shape[3],g.shape[4]]):g}}),tg={kernelName:Yn,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{const[r,a]=t,{filterSize:i,strides:s,pad:o,dimRoundingMode:u}=n;return{x:()=>eg(e,r,a,i,s,o,u)}}},ng=$i({maxPoolGrad_:function(e,t,n,r,a,i,s){const o=Ci(e,"dy","maxPoolGrad"),u=Ci(t,"input","maxPoolGrad"),l=Ci(n,"output","maxPoolGrad");se(u.rank===o.rank,(()=>`Rank of input (${u.rank}) does not match rank of dy (${o.rank})`)),se(4===o.rank,(()=>`Error in maxPoolGrad: dy must be rank 4 but got rank ${o.rank}.`)),se(4===u.rank,(()=>`Error in maxPoolGrad: input must be rank 4 but got rank ${u.rank}.`)),wl("maxPoolGrad",i,s);const c={dy:o,input:u,output:l},p={filterSize:r,strides:a,pad:i,dimRoundingMode:s};return _i.runKernel(Fn,c,p)}}),rg={kernelName:Rn,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{const[r,a]=t,{filterSize:i,strides:s,pad:o}=n;return{x:()=>ng(e,r,a,i,s,o)}}},ag={kernelName:Pn,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{axis:a}=n,i=ve(a,r.shape),s=ce(gc(r.shape,i)[1]);return{x:()=>{const t=r.shape.slice();i.forEach((e=>{t[e]=1}));const n=Ml(e,t);return Nu(Su(n,lp(r.shape,"float32")),s)}}}},ig={kernelName:Hn,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{const r=n,{axis:a}=r,[i,s]=t,o=Xm(e,s,i,ve(a,i.shape));return{x:()=>o.x()}}},sg={kernelName:Un,inputsToSave:["x"],gradFunc:(e,t,n)=>{const r=t[0],{paddings:a}=n,i=a.map((e=>e[0]));return{x:()=>Tl(e,i,r.shape)}}},og={kernelName:tr,saveAllInputs:!0,gradFunc:(e,t,n)=>{const{axis:r}=n;return kd(e,r).map((e=>()=>e))}},ug={kernelName:nr,inputsToSave:["x"],gradFunc:(e,t,n)=>{const r=t[0],{paddings:a}=n,i=a.map((e=>e[0]));return{x:()=>Tl(e,i,r.shape)}}},lg={kernelName:ar,inputsToSave:["a","b"],outputsToSave:[!0],gradFunc:(e,t)=>{const[n,r,a]=t,i=n,s=r,o=Lo(i.shape,s.shape);return{a:()=>{const t=Ls(s,"float32");let n=Su(e,Su(t,Pu(i,Hu(t,Ru(1)))));const r=Ao(i.shape,o);return r.length>0&&(n=Nc(n,r)),Ml(n,i.shape)},b:()=>{const t=Oc(i,0),n=uc(t,qc(i),Tu(i));let r=Su(e,Su(a,n));const u=Ao(s.shape,o);return u.length>0&&(r=Nc(r,u)),Ml(r,s.shape)}}}};const cg={kernelName:sr,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{axis:a}=n;let i=[];return i=null==a?r.shape.map(((e,t)=>t)):"number"==typeof a?[a]:a,{x:()=>function(e,t,n){const r=e.shape.length,a=r-n.length,i=xc(n,r);let s=e;null!=i&&(s=Io(e,i));const o=s.shape.slice(),u=o.splice(r-n.length,n.length).reduce(((e,t)=>e*t),1);o.push(u);let l=function(e,t,n){const r=e.shape.slice();r[n]=1;const a=Ml(t,r),i=ec(e,n,!0,!1),s=ec(e,n,!0,!0),o=Su(i,s);return Su(a,o)}(s.reshape(o),t,a);if(l=l.reshape(s.shape),null!=i){const e=vc(i);l=Io(l,e)}return l}(r,e,i)}}},pg={kernelName:Mr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>{const t=Oc(n,Ru(0)),r=Ru(lf),a=Ru(cf),i=Su(e,a),s=Su(Su(e,r),Tc(Ls(n,"float32")));return uc(t,i,s)}}}},dg={kernelName:Nr,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{begin:a,size:i}=n,s=r.shape,[o,u]=au(r,a,i),l=[];for(let t=0;tvp(e,l)}}},hg={kernelName:Ar,gradFunc:(e,t,n)=>{const{blockShape:r,paddings:a}=n;return{x:()=>Cl(e,r,a)}}},fg={kernelName:Lr,gradFunc:(e,t,n)=>{const{axis:r}=n;return{x:()=>kl(e,r)}}},mg={kernelName:Cr,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,a=r.shape.slice(),{axis:i}=n;ve(i,r.shape).forEach((e=>{a[e]=1}));const s=Ml(e,a),o=Su(s,lp(r.shape,"float32"));return{x:()=>o}}},gg={kernelName:Kr,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{reps:a}=n;return{x:()=>{let t=Tu(r);if(1===r.rank)for(let n=0;n{const r=n,{axis:a}=r;return{value:()=>hd(e,a)}}},bg={kernelName:ta,inputsToSave:["segmentIds"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>function(e,t){const n=qu(t,Tu(t)),r=$c(e,n);let a=Rc(t,Ru(0,"int32"));const i=r.rank-a.rank;for(let e=0;e{const[n,r]=t,a=Lo(n.shape,r.shape);return{a:()=>{const t=Nu(e,Ls(r,"float32")),i=Ao(n.shape,a);return i.length>0?Ml(Nc(t,i),n.shape):t},b:()=>{let t=Su(e,Ls(n,"float32"));const i=Ao(r.shape,a);i.length>0&&(t=Ml(Nc(t,i),r.shape));const s=Du(r);return Do(Nu(t,Ls(s,"float32")))}}}},Im,Em,Cm,Am,Lm,Om,$m,Rm,Fm,Bm,Pm,Hm,jm,Um,qm,Wm,Vm,Gm,Jm,Zm,Zm,Qm,tg,rg,ag,ig,{kernelName:jn,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t;return{a:()=>Su(e,Ls(Hc(n,r),"float32")),b:()=>Su(e,Ls(Oc(n,r),"float32"))}}},sg,{kernelName:qn,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t,a=Lo(n.shape,r.shape);return{a:()=>{const t=Ao(n.shape,a);return t.length>0?Ml(Nc(e,t),n.shape):e},b:()=>{const t=Su(e,Do(Lc(Nu(n,r)))),i=Ao(r.shape,a);return i.length>0?Ml(Nc(t,i),r.shape):t}}}},{kernelName:Vn,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t,a=Lo(n.shape,r.shape);return{a:()=>{const t=Su(e,Ls(r,"float32")),i=Ao(n.shape,a);return i.length>0?Ml(Nc(t,i),n.shape):t},b:()=>{const t=Su(e,Ls(n,"float32")),i=Ao(r.shape,a);return i.length>0?Ml(Nc(t,i),r.shape):t}}}},{kernelName:Gn,gradFunc:e=>({x:()=>Do(e)})},{kernelName:er,inputsToSave:["indices"],gradFunc:(e,t)=>{const n=t[0];return{indices:()=>up(n.shape,"float32")}}},{kernelName:Qn,gradFunc:e=>({x:()=>Tu(e)})},og,ug,ug,lg,{kernelName:ir,inputsToSave:["x","alpha"],gradFunc:(e,t)=>{const[n,r]=t,a=Oc(n,0);return{x:()=>uc(a,e,Su(e,r)),alpha:()=>{let t=uc(a,Tu(e),Su(e,n));const i=Ao(r.shape,e.shape);return i.length>0&&(t=Nc(t,i)),Ml(t,r.shape)}}}},cg,{kernelName:lr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Nu(e,Do(Du(n)))}}},{kernelName:gr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t,r=Su(Hc(n,6),fd(n));return{x:()=>Su(e,Ls(r,"float32"))}}},{kernelName:cr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Su(e,Ls(fd(n),"float32"))}}},{kernelName:pr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Ml(e,n.shape)}}},{kernelName:fr,inputsToSave:["images"],gradFunc:(e,t,n)=>{const[r]=t,a={dy:e,images:r};return{images:()=>_i.runKernel(mr,a,n)}}},{kernelName:dr,inputsToSave:["images"],gradFunc:(e,t,n)=>{const[r]=t,a={dy:e,images:r};return{images:()=>_i.runKernel(hr,a,n)}}},{kernelName:yr,gradFunc:(e,t,n)=>{const{dims:r}=n,a=ve(r,e.shape);return{x:()=>Hp(e,a)}}},{kernelName:br,gradFunc:e=>({x:()=>Tu(e)})},{kernelName:xr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Do(Nu(e,Su(Pu(n,1.5),2)))}}},{kernelName:wr,inputsToSave:["condition"],gradFunc:(e,t)=>{const[n]=t;return{condition:()=>Ls(Tu(n),"float32"),t:()=>Su(e,Ls(n,e.dtype)),e:()=>Su(e,Ls(Zc(n),e.dtype))}}},pg,{kernelName:Tr,outputsToSave:[!0],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Su(e,Su(n,Hu(Ru(1),n)))}}},{kernelName:Dr,gradFunc:e=>({x:()=>Tu(e)})},{kernelName:Sr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Su(Zl(Ls(n,"float32")),e)}}},{kernelName:kr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Su(Ql(Ls(n,"float32")),e)}}},dg,{kernelName:$r,outputsToSave:[!0],gradFunc:(e,t,n)=>{const[r]=t,{dim:a}=n,i=Su(e,r);return{logits:()=>Hu(i,Su(Nc(i,[a],!0),r))}}},{kernelName:Ir,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Su(e,Dl(n))}}},hg,hg,fg,fg,{kernelName:Er,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Nu(e,Su(ku(Ls(n,"float32")),2))}}},{kernelName:Br,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t,a=Ru(2);return{a:()=>Su(e,Su(a,Hu(n,r))),b:()=>Su(e,Su(a,Hu(r,n)))}}},{kernelName:Pr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Su(e,Su(Ls(n,"float32"),2))}}},{kernelName:aa,gradFunc:e=>({x:()=>Tu(e)})},{kernelName:Wr,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t,a=Lo(n.shape,r.shape);return{a:()=>{let t=e;const r=Ao(n.shape,a);return r.length>0&&(t=Nc(t,r)),Ml(t,n.shape)},b:()=>{let t=e;const n=Ao(r.shape,a);return n.length>0&&(t=Nc(t,n)),Ml(Do(t),r.shape)}}}},mg,{kernelName:Vr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Nu(e,Du(Zl(n)))}}},{kernelName:Gr,outputsToSave:[!0],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Su(Hu(Ru(1),Du(n)),e)}}},gg,{kernelName:Zr,gradFunc:(e,t,n)=>{const r=n,{perm:a}=r,i=vc(a);return{x:()=>Io(e,i)}}},yg,bg,{kernelName:ra,gradFunc:e=>({x:()=>Tu(e)})}];for(const e of xg)ba(e);ni().prototype.abs=function(){return this.throwIfDisposed(),Uu(this)},ni().prototype.acos=function(){return this.throwIfDisposed(),Xu(this)},ni().prototype.acosh=function(){return this.throwIfDisposed(),Zu(this)},ni().prototype.add=function(e){return this.throwIfDisposed(),wu(this,e)},ni().prototype.all=function(e,t){return this.throwIfDisposed(),el(this,e,t)},ni().prototype.any=function(e,t){return this.throwIfDisposed(),tl(this,e,t)},ni().prototype.argMax=function(e){return this.throwIfDisposed(),nl(this,e)},ni().prototype.argMin=function(e){return this.throwIfDisposed(),rl(this,e)},ni().prototype.asScalar=function(){return this.throwIfDisposed(),se(1===this.size,(()=>"The array must have only 1 element.")),Ml(this,[])},ni().prototype.asType=function(e){return this.throwIfDisposed(),Ls(this,e)},ni().prototype.as1D=function(){return this.throwIfDisposed(),Ml(this,[this.size])},ni().prototype.as2D=function(e,t){return this.throwIfDisposed(),Ml(this,[e,t])},ni().prototype.as3D=function(e,t,n){return this.throwIfDisposed(),Ml(this,[e,t,n])},ni().prototype.as4D=function(e,t,n,r){return this.throwIfDisposed(),Ml(this,[e,t,n,r])},ni().prototype.as5D=function(e,t,n,r,a){return this.throwIfDisposed(),Ml(this,[e,t,n,r,a])},ni().prototype.asin=function(){return this.throwIfDisposed(),al(this)},ni().prototype.asinh=function(){return this.throwIfDisposed(),il(this)},ni().prototype.atan=function(){return this.throwIfDisposed(),sl(this)},ni().prototype.atan2=function(e){return this.throwIfDisposed(),ol(this,e)},ni().prototype.atanh=function(){return this.throwIfDisposed(),ul(this)},ni().prototype.avgPool=function(e,t,n,r){return this.throwIfDisposed(),Nl(this,e,t,n,r)},ni().prototype.batchToSpaceND=function(e,t){return this.throwIfDisposed(),Cl(this,e,t)},ni().prototype.batchNorm=function(e,t,n,r,a){return this.throwIfDisposed(),Al(this,e,t,n,r,a)},ni().prototype.broadcastTo=function(e){return this.throwIfDisposed(),Yl(this,e)},ni().prototype.cast=function(e){return this.throwIfDisposed(),Ls(this,e)},ni().prototype.ceil=function(){return this.throwIfDisposed(),zl(this)},ni().prototype.clipByValue=function(e,t){return this.throwIfDisposed(),Bl(this,e,t)},ni().prototype.concat=function(e,t){return this.throwIfDisposed(),e instanceof ti&&(e=[e]),kl([this,...e],t)},ni().prototype.conv1d=function(e,t,n,r,a,i){return this.throwIfDisposed(),Wl(this,e,t,n,r,a,i)},ni().prototype.conv2dTranspose=function(e,t,n,r,a){return this.throwIfDisposed(),Gl(this,e,t,n,r,a)},ni().prototype.conv2d=function(e,t,n,r,a,i){return this.throwIfDisposed(),ql(this,e,t,n,r,a,i)},ni().prototype.cos=function(){return this.throwIfDisposed(),Zl(this)},ni().prototype.cosh=function(){return this.throwIfDisposed(),Ql(this)},ni().prototype.cumprod=function(e,t,n){return this.throwIfDisposed(),ec(this,e,t,n)},ni().prototype.cumsum=function(e,t,n){return this.throwIfDisposed(),tc(this,e,t,n)},ni().prototype.depthToSpace=function(e,t){return this.throwIfDisposed(),rc(this,e,t)},ni().prototype.depthwiseConv2d=function(e,t,n,r,a,i){return this.throwIfDisposed(),ac(this,e,t,n,r,a,i)},ni().prototype.dilation2d=function(e,t,n,r,a){return this.throwIfDisposed(),sc(this,e,t,n,r,a)},ni().prototype.divNoNan=function(e){return this.throwIfDisposed(),lc(this,e)},ni().prototype.div=function(e){return this.throwIfDisposed(),Nu(this,e)},ni().prototype.dot=function(e){return this.throwIfDisposed(),cc(this,e)},ni().prototype.elu=function(){return this.throwIfDisposed(),dc(this)},ni().prototype.equal=function(e){return this.throwIfDisposed(),oc(this,e)},ni().prototype.erf=function(){return this.throwIfDisposed(),hc(this)},ni().prototype.euclideanNorm=function(e,t){return this.throwIfDisposed(),Dc(this,e,t)},ni().prototype.exp=function(){return this.throwIfDisposed(),Tc(this)},ni().prototype.expandDims=function(e){return this.throwIfDisposed(),Ic(this,e)},ni().prototype.expm1=function(){return this.throwIfDisposed(),Ec(this)},ni().prototype.fft=function(){return this.throwIfDisposed(),sd(this)},ni().prototype.flatten=function(){return this.throwIfDisposed(),Ml(this,[this.size])},ni().prototype.floor=function(){return this.throwIfDisposed(),Lc(this)},ni().prototype.floorDiv=function(e){return this.throwIfDisposed(),Mu(this,e)},ni().prototype.gather=function(e,t){return this.throwIfDisposed(),$c(this,e,t)},ni().prototype.greaterEqual=function(e){return this.throwIfDisposed(),Rc(this,e)},ni().prototype.greater=function(e){return this.throwIfDisposed(),Oc(this,e)},ni().prototype.ifft=function(){return this.throwIfDisposed(),od(this)},ni().prototype.irfft=function(){return this.throwIfDisposed(),ud(this)},ni().prototype.isFinite=function(){return this.throwIfDisposed(),Fc(this)},ni().prototype.isInf=function(){return this.throwIfDisposed(),Yc(this)},ni().prototype.isNaN=function(){return this.throwIfDisposed(),zc(this)},ni().prototype.leakyRelu=function(e){return this.throwIfDisposed(),Bc(this,e)},ni().prototype.lessEqual=function(e){return this.throwIfDisposed(),Hc(this,e)},ni().prototype.less=function(e){return this.throwIfDisposed(),Pc(this,e)},ni().prototype.localResponseNormalization=function(e,t,n,r){return this.throwIfDisposed(),Uc(this,e,t,n,r)},ni().prototype.logSigmoid=function(){return this.throwIfDisposed(),Gc(this)},ni().prototype.logSoftmax=function(e){return this.throwIfDisposed(),Kc(this,e)},ni().prototype.logSumExp=function(e,t){return this.throwIfDisposed(),Jc(this,e,t)},ni().prototype.log=function(){return this.throwIfDisposed(),qc(this)},ni().prototype.log1p=function(){return this.throwIfDisposed(),Wc(this)},ni().prototype.logicalAnd=function(e){return this.throwIfDisposed(),Xc(this,e)},ni().prototype.logicalNot=function(){return this.throwIfDisposed(),Zc(this)},ni().prototype.logicalOr=function(e){return this.throwIfDisposed(),Qc(this,e)},ni().prototype.logicalXor=function(e){return this.throwIfDisposed(),ep(this,e)},ni().prototype.matMul=function(e,t,n){return this.throwIfDisposed(),no(this,e,t,n)},ni().prototype.maxPool=function(e,t,n,r){return this.throwIfDisposed(),ap(this,e,t,n,r)},ni().prototype.max=function(e,t){return this.throwIfDisposed(),wc(this,e,t)},ni().prototype.maximum=function(e){return this.throwIfDisposed(),qu(this,e)},ni().prototype.mean=function(e,t){return this.throwIfDisposed(),op(this,e,t)},ni().prototype.min=function(e,t){return this.throwIfDisposed(),Mc(this,e,t)},ni().prototype.minimum=function(e){return this.throwIfDisposed(),pp(this,e)},ni().prototype.mirrorPad=function(e,t){return this.throwIfDisposed(),dp(this,e,t)},ni().prototype.mod=function(e){return this.throwIfDisposed(),hp(this,e)},ni().prototype.mul=function(e){return this.throwIfDisposed(),Su(this,e)},ni().prototype.neg=function(){return this.throwIfDisposed(),Do(this)},ni().prototype.norm=function(e,t,n){return this.throwIfDisposed(),kc(this,e,t,n)},ni().prototype.notEqual=function(e){return this.throwIfDisposed(),yp(this,e)},ni().prototype.oneHot=function(e,t=1,n=0){return this.throwIfDisposed(),ro(this,e,t,n)},ni().prototype.onesLike=function(){return this.throwIfDisposed(),bp(this)},ni().prototype.pad=function(e,t){return this.throwIfDisposed(),vp(this,e,t)},ni().prototype.pool=function(e,t,n,r,a,i){return this.throwIfDisposed(),kp(this,e,t,n,r,a,i)},ni().prototype.pow=function(e){return this.throwIfDisposed(),Pu(this,e)},ni().prototype.prelu=function(e){return this.throwIfDisposed(),Dp(this,e)},ni().prototype.prod=function(e,t){return this.throwIfDisposed(),Tp(this,e,t)},ni().prototype.reciprocal=function(){return this.throwIfDisposed(),zp(this)},ni().prototype.relu=function(){return this.throwIfDisposed(),Bp(this)},ni().prototype.relu6=function(){return this.throwIfDisposed(),Pp(this)},ni().prototype.reshapeAs=function(e){return this.throwIfDisposed(),Ml(this,e.shape)},ni().prototype.reshape=function(e){return this.throwIfDisposed(),Ml(this,e)},ni().prototype.resizeBilinear=function(e,t,n){return this.throwIfDisposed(),yh(this,e,t,n)},ni().prototype.resizeNearestNeighbor=function(e,t,n){return this.throwIfDisposed(),bh(this,e,t,n)},ni().prototype.reverse=function(e){return this.throwIfDisposed(),Hp(this,e)},ni().prototype.rfft=function(){return this.throwIfDisposed(),cd(this)},ni().prototype.round=function(){return this.throwIfDisposed(),Vp(this)},ni().prototype.rsqrt=function(){return this.throwIfDisposed(),Gp(this)},ni().prototype.selu=function(){return this.throwIfDisposed(),Kp(this)},ni().prototype.separableConv2d=function(e,t,n,r,a,i){return this.throwIfDisposed(),Jp(this,e,t,n,r,a,i)},ni().prototype.sigmoid=function(){return this.throwIfDisposed(),Dl(this)},ni().prototype.sign=function(){return this.throwIfDisposed(),Zp(this)},ni().prototype.sin=function(){return this.throwIfDisposed(),Qp(this)},ni().prototype.sinh=function(){return this.throwIfDisposed(),ed(this)},ni().prototype.slice=function(e,t){return this.throwIfDisposed(),Tl(this,e,t)},ni().prototype.softmax=function(e){return this.throwIfDisposed(),id(this,e)},ni().prototype.softplus=function(){return this.throwIfDisposed(),Vc(this)},ni().prototype.spaceToBatchND=function(e,t){return this.throwIfDisposed(),Sp(this,e,t)},ni().prototype.split=function(e,t){return this.throwIfDisposed(),ld(this,e,t)},ni().prototype.sqrt=function(){return this.throwIfDisposed(),ku(this)},ni().prototype.square=function(){return this.throwIfDisposed(),Du(this)},ni().prototype.squaredDifference=function(e){return this.throwIfDisposed(),pd(this,e)},ni().prototype.squeeze=function(e){return this.throwIfDisposed(),dd(this,e)},ni().prototype.stack=function(e,t){this.throwIfDisposed();const n=e instanceof ti?[this,e]:[this,...e];return hd(n,t)},ni().prototype.step=function(e){return this.throwIfDisposed(),fd(this,e)},ni().prototype.stridedSlice=function(e,t,n,r,a,i,s,o){return this.throwIfDisposed(),md(this,e,t,n,r,a,i,s,o)},ni().prototype.sub=function(e){return this.throwIfDisposed(),Hu(this,e)},ni().prototype.sum=function(e,t){return this.throwIfDisposed(),Nc(this,e,t)},ni().prototype.tan=function(){return this.throwIfDisposed(),gd(this)},ni().prototype.tanh=function(){return this.throwIfDisposed(),Il(this)},ni().prototype.tile=function(e){return this.throwIfDisposed(),Cc(this,e)},ni().prototype.toBool=function(){return this.throwIfDisposed(),Ls(this,"bool")},ni().prototype.toFloat=function(){return this.throwIfDisposed(),Ls(this,"float32")},ni().prototype.toInt=function(){return this.throwIfDisposed(),Ls(this,"int32")},ni().prototype.topk=function(e,t){return this.throwIfDisposed(),wd(this,e,t)},ni().prototype.transpose=function(e){return this.throwIfDisposed(),Io(this,e)},ni().prototype.unique=function(e){return this.throwIfDisposed(),Nd(this,e)},ni().prototype.unsortedSegmentSum=function(e,t){return this.throwIfDisposed(),Sd(this,e,t)},ni().prototype.unstack=function(e){return this.throwIfDisposed(),kd(this,e)},ni().prototype.where=function(e,t){return this.throwIfDisposed(),uc(e,this,t)},ni().prototype.zerosLike=function(){return this.throwIfDisposed(),Tu(this)};class vg extends Error{constructor(e){super(e),Object.setPrototypeOf(this,vg.prototype)}}class _g extends Error{constructor(e){super(e),Object.setPrototypeOf(this,_g.prototype)}}class wg extends Error{constructor(e){super(e),Object.setPrototypeOf(this,wg.prototype)}}class Mg extends Error{constructor(e){super(e),Object.setPrototypeOf(this,Mg.prototype)}}class Ng extends Error{constructor(e){super(e),Object.setPrototypeOf(this,Ng.prototype)}}Error;class Sg{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 e=this.cache.keys().next().value;this.cache.delete(e)}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;tt.toUpperCase()))}let Lg={};function $g(e){if(null==e)return null;const t={};return t.className=e.getClassName(),t.config=e.getConfig(),t}function Og(e){if(null!=e&&"object"==typeof e)if(Array.isArray(e))e.forEach((e=>Og(e)));else{const t=Object.keys(e);for(const n of t){const t=e[n];null!=t&&"object"==typeof t&&(Array.isArray(t)||"ndarray"!==t.type||"number"!=typeof t.value?Og(t):e[n]=t.value)}}}function Rg(e,t={},n={},r="object",a=!1){if("string"==typeof e){const a=e;let i;if(a in n)i=n[a];else if(a in Lg)i=Lg[a];else if(i=t[a],null==i)throw new wg(`Unknown ${r}: ${e}. This may be due to one of the following reasons:\n1. The ${r} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.\n2. The custom ${r} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);return i}{const i=e;if(null==i.className||null==i.config)throw new wg(`${r}: Improper config format: ${JSON.stringify(i)}.\n'className' and 'config' must set.`);const s=i.className;let o,u;if(s in n?[o,u]=n[s]:s in Lg?[o,u]=Lg.className:s in t&&([o,u]=t[s]),null==o)throw new wg(`Unknown ${r}: ${s}. This may be due to one of the following reasons:\n1. The ${r} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.\n2. The custom ${r} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);if(null!=u){const e={};for(const t of Object.keys(Lg))e[t]=Lg[t];for(const t of Object.keys(n))e[t]=n[t];i.config.customObjects=e;const t=Object.assign({},Lg);for(const e of Object.keys(n))Lg[e]=n[e];Og(i.config);const r=u(o,i.config,n,a);return Lg=Object.assign({},t),r}{const e=Object.assign({},Lg);for(const e of Object.keys(n))Lg[e]=n[e];const t=new o(i.config);return Lg=Object.assign({},e),t}}}function Fg(e,t){return-1*function(e,t){return et?1:0}(e,t)}function Yg(e){if(null==e)return e;const t=[];for(const n of e)-1===t.indexOf(n)&&t.push(n);return t}function zg(e){if(null==e)throw new wg(`Invalid value in obj: ${JSON.stringify(e)}`);for(const t in e)if(e.hasOwnProperty(t))return!1;return!0}function Bg(e,t,n){if(null!=n&&e.indexOf(n)<0)throw new wg(`${n} is not a valid ${t}. Valid values are ${e} or null/undefined.`)}function Pg(e,t,n=0,r=1/0){return Dg(n>=0),Dg(r>=n),Array.isArray(e)&&e.length>=n&&e.length<=r&&e.every((e=>typeof e===t))}function Hg(e,t){Array.isArray(e)?(se(e.length>0,(()=>`${t} is unexpectedly an empty array.`)),e.forEach(((e,n)=>Hg(e,`element ${n+1} of ${t}`)))):se(Number.isInteger(e)&&e>0,(()=>`Expected ${t} to be a positive integer, but got ${jg(e)}.`))}function jg(e){return null===e?"null":Array.isArray(e)?"["+e.map((e=>jg(e))).join(",")+"]":"string"==typeof e?`"${e}"`:`${e}`}function Ug(e){return"relu"===e?"relu":"linear"===e?"linear":"elu"===e?"elu":null}let qg=0;function Wg(){return qg++}const Vg={};function Gg(e=""){return e in Vg||(Vg[e]=0),Vg[e]+=1,e+Vg[e].toString()}const Kg=["channelsFirst","channelsLast"],Jg=["nearest","bilinear"],Xg=["valid","same","causal"],Zg=["max","avg"],Qg=["sum","mul","concat","ave"],ey=new Map;function ty(e){Bg(Kg,"DataFormat",e)}function ny(e){Bg(Xg,"PaddingMode",e)}function ry(e){Bg(Zg,"PoolMode",e)}const ay=[];function iy(e,t){ay.push(e);try{const e=t();return ay.pop(),e}catch(e){throw ay.pop(),e}}function sy(e){if(!ly(e))throw new Error("Not a valid tensor name: '"+e+"'");return(0===ay.length?"":ay.join("/")+"/")+e}function oy(e){if(!ly(e))throw new Error("Not a valid tensor name: '"+e+"'");ey.has(e)||ey.set(e,0);const t=ey.get(e);if(ey.set(e,ey.get(e)+1),t>0){const n=`${e}_${t}`;return ey.set(n,1),n}return e}const uy=new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);function ly(e){return!!e.match(uy)}function cy(e,t,n){null==t&&(t=0),null==n&&(n=e.length);let r=1;for(let a=t;at&&(t=r)}return t}function hy(e,t){if(t{switch(e.rank){case 1:return td(e,t,n);case 2:return nd(e,[t,0],[n,e.shape[1]]);case 3:return rd(e,[t,0,0],[n,e.shape[1],e.shape[2]]);case 4:return ad(e,[t,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3]]);case 5:return Tl(e,[t,0,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3],e.shape[4]]);case 6:return Tl(e,[t,0,0,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3],e.shape[4],e.shape[5]]);default:throw new wg(`sliceAlongFirstAxis() received an unsupported tensor rank: ${e.rank}`)}}))}function xy(e,t,n){return ho((()=>{switch(e.rank){case 1:return td(e,t,n);case 2:return nd(e,[0,t],[e.shape[0],n]);case 3:return rd(e,[0,0,t],[e.shape[0],e.shape[1],n]);case 4:return ad(e,[0,0,0,t],[e.shape[0],e.shape[1],e.shape[2],n]);default:throw new wg(`sliceAlongLastAxis() received an unsupported tensor rank: ${e.rank}`)}}))}function vy(e,t,n,r){return ho((()=>{switch(e.rank){case 1:return td(e,t,n);case 2:switch(r){case 1:return by(e,t,n);case 2:return xy(e,t,n);default:throw new wg(`The axis is not within the rank of the tensor ${r}`)}case 3:switch(r){case 1:return by(e,t,n);case 2:return rd(e,[0,t,0],[e.shape[0],n,e.shape[2]]);case 3:return xy(e,t,n);default:throw new wg(`The axis is not within the rank of the tensor ${r}`)}case 4:switch(r){case 1:return by(e,t,n);case 2:return ad(e,[0,t,0,0],[e.shape[0],n,e.shape[2],e.shape[3]]);case 3:return ad(e,[0,0,t,0],[e.shape[0],e.shape[1],n,e.shape[3]]);case 4:return xy(e,t,n);default:throw new wg(`The axis is not within the rank of the tensor ${r}`)}default:throw new wg(`sliceAlongLastAxis() received an unsupported tensor rank: ${e.rank}`)}}))}function _y(e,t=-1){let n;return t<0&&(n=e[0].rank,t=0!==n?n:0),t===e[0].rank&&(t=-1),kl(e,t)}function wy(e,t){switch(e.rank){case 1:return Pl([e,t]);case 2:return Hl([e,t],0);case 3:return jl([e,t],0);case 4:return Ul([e,t],0);default:throw new wg(`concatAlongFirstAxis() received an unsupported tensor rank: ${e.rank}`)}}function My(e,t){if(Array.isArray(t)||(t=[t]),e.rank!==t.length)throw new wg(`The length of input n (${t.length}) does not match the number of dimensions in input x (${e.rank})`);return Cc(e,t)}function Ny(e,t=0,n=1,r,a){return Op(e,t,n,r,a)}function Sy(e,t,n,r){if(e.rank<2||t.rank<2)throw new Mg(`dot requires both inputs to be rank >= 2 but got x shape = ${e.shape} and y shape = ${t.shape}`);if(t.rank>=3&&e.shape.slice(-1)[0]!==t.shape.slice(-2)[0])throw new Mg(`If rank y >= 3, then the second last dim of y must equal the last dim of x but got x shape = ${e.shape} and y shape = ${t.shape}`);if(2===e.rank&&2===t.rank)return Kd({a:e,b:t,transposeA:!1,transposeB:!1,bias:r?Ty(e.rank,r,"channelsLast"):null,activation:n});{const a=e.shape.slice(),i=a.pop();e=Ml(e,[-1,i]);const s=t.shape.slice(),o=s.pop(),u=s.pop(),l=[...s,o],c=Array.from({length:t.rank},((e,n)=>0===n?t.rank-2:n<=t.rank-2?n-1:n));t=Ml(Io(t,c),[u,-1]);const p=[...a,...l];return Ml(Kd({a:e,b:t,transposeA:!1,transposeB:!1,bias:r?Ty(e.rank,r,"channelsLast"):null,activation:n}),p)}}function ky(e,t,n){return ho((()=>(t=Array.isArray(t)?yd(t,"int32"):Ls(t,"int32"),$c(e,t,n))))}function Dy(e){return Su(e,e)}function Ty(e,t,n){const r=t.shape;if(1!==t.rank&&t.rank!==e)throw new wg(`Unexpected bias dimensions: ${t.rank}; expected it to be 1 or ${e}`);if(5===e){if("channelsFirst"===n)return 1===r.length?Ml(t,[1,r[0],1,1,1]):Ml(t,[1,r[3],r[0],r[1],r[2]]);if("channelsLast"===n)return 1===r.length?Ml(t,[1,1,1,1,r[0]]):Ml(t,[1].concat(r))}else if(4===e){if("channelsFirst"===n)return 1===r.length?Ml(t,[1,r[0],1,1]):Ml(t,[1,r[2],r[0],r[1]]);if("channelsLast"===n)return 1===r.length?Ml(t,[1,1,1,r[0]]):Ml(t,[1].concat(r))}else if(3===e){if("channelsFirst"===n)return 1===r.length?Ml(t,[1,r[0],1]):Ml(t,[1,r[1],r[0]]);if("channelsLast"===n)return 1===r.length?Ml(t,[1,1,r[0]]):Ml(t,[1].concat(r))}else if(e<3)return t;throw new wg(`Unsupported input rank by biasAdd: ${t.rank}`)}function Iy(e,t,n){return ho((()=>(null==n&&(n="channelsLast"),ty(n),wu(e,Ty(e.rank,t,n)))))}function Ey(e,t,n,r){return ho((()=>Rd(e,t,n,r)))}function Cy(e,t,n=!1){return n?e():t()}const Ay=["fanIn","fanOut","fanAvg"],Ly=["normal","uniform","truncatedNormal"];class $y extends ou{fromConfigUsesCustomObjects(){return!1}getConfig(){return{}}}class Oy extends $y{apply(e,t){return up(e,t)}}Oy.className="Zeros",lu(Oy);class Ry extends $y{apply(e,t){return lp(e,t)}}Ry.className="Ones",lu(Ry);class Fy extends $y{constructor(e){if(super(),"object"!=typeof e)throw new wg(`Expected argument of type ConstantConfig but got ${e}`);if(void 0===e.value)throw new wg(`config must have value set but got ${e}`);this.value=e.value}apply(e,t){return ho((()=>Su(Ru(this.value),lp(e,t))))}getConfig(){return{value:this.value}}}Fy.className="Constant",lu(Fy);class Yy extends $y{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 Fp(e,this.minval,this.maxval,t)}getConfig(){return{minval:this.minval,maxval:this.maxval,seed:this.seed}}}Yy.className="RandomUniform",lu(Yy);class zy extends $y{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("float32"!==(t=t||"float32")&&"int32"!==t)throw new Mg(`randomNormal does not support dType ${t}.`);return Ny(e,this.mean,this.stddev,t,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}zy.className="RandomNormal",lu(zy);class By extends $y{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("float32"!==(t=t||"float32")&&"int32"!==t)throw new Mg(`truncatedNormal does not support dType ${t}.`);return Md(e,this.mean,this.stddev,t,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}By.className="TruncatedNormal",lu(By);class Py extends $y{constructor(e){super(),this.gain=null!=e.gain?e.gain:1}apply(e,t){return ho((()=>{if(2!==e.length||e[0]!==e[1])throw new wg("Identity matrix initializer can only be used for 2D square matrices.");return Su(this.gain,Ac(e[0]))}))}getConfig(){return{gain:this.gain}}}Py.className="Identity",lu(Py);class Hy extends $y{constructor(e){if(super(),e.scale<0)throw new wg(`scale must be a positive float. Got: ${e.scale}`);var t;this.scale=null==e.scale?1:e.scale,this.mode=null==e.mode?"fanIn":e.mode,t=this.mode,Bg(Ay,"FanMode",t),this.distribution=null==e.distribution?"normal":e.distribution,function(e){Bg(Ly,"Distribution",e)}(this.distribution),this.seed=e.seed}apply(e,t){const n=function(e,t="channelsLast"){let n,r;if(ty(t),2===e.length)n=e[0],r=e[1];else if(-1!==[3,4,5].indexOf(e.length)){if("channelsFirst"===t){const t=cy(e,2);n=e[1]*t,r=e[0]*t}else if("channelsLast"===t){const t=cy(e,0,e.length-2);n=e[e.length-2]*t,r=e[e.length-1]*t}}else{const t=cy(e);n=Math.sqrt(t),r=Math.sqrt(t)}return[n,r]}(e),r=n[0],a=n[1];let i=this.scale;if("fanIn"===this.mode?i/=Math.max(1,r):"fanOut"===this.mode?i/=Math.max(1,a):i/=Math.max(1,(r+a)/2),"normal"===this.distribution){const n=Math.sqrt(i);if("float32"!==(t=t||"float32")&&"int32"!==t)throw new Mg(`${this.getClassName()} does not support dType ${t}.`);return Md(e,0,n,t,this.seed)}{const n=Math.sqrt(3*i);return Fp(e,-n,n,t)}}getConfig(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}}}Hy.className="VarianceScaling",lu(Hy);class jy extends Hy{constructor(e){super({scale:1,mode:"fanAvg",distribution:"uniform",seed:null==e?null:e.seed})}getClassName(){return Hy.className}}jy.className="GlorotUniform",lu(jy);class Uy extends Hy{constructor(e){super({scale:1,mode:"fanAvg",distribution:"normal",seed:null==e?null:e.seed})}getClassName(){return Hy.className}}Uy.className="GlorotNormal",lu(Uy);class qy extends Hy{constructor(e){super({scale:2,mode:"fanIn",distribution:"normal",seed:null==e?null:e.seed})}getClassName(){return Hy.className}}qy.className="HeNormal",lu(qy);class Wy extends Hy{constructor(e){super({scale:2,mode:"fanIn",distribution:"uniform",seed:null==e?null:e.seed})}getClassName(){return Hy.className}}Wy.className="HeUniform",lu(Wy);class Vy extends Hy{constructor(e){super({scale:1,mode:"fanIn",distribution:"normal",seed:null==e?null:e.seed})}getClassName(){return Hy.className}}Vy.className="LeCunNormal",lu(Vy);class Gy extends Hy{constructor(e){super({scale:1,mode:"fanIn",distribution:"uniform",seed:null==e?null:e.seed})}getClassName(){return Hy.className}}Gy.className="LeCunNormal",lu(Gy);class Ky extends $y{constructor(e){if(super(),this.DEFAULT_GAIN=1,this.gain=null==e.gain?this.DEFAULT_GAIN:e.gain,this.seed=e.seed,null!=this.seed)throw new Mg("Random seed is not implemented for Orthogonal Initializer yet.")}apply(e,t){return ho((()=>{if(e.length<2)throw new Mg("Shape must be at least 2D.");e[0]*e[1]>2e3&&console.warn(`Orthogonal initializer is being called on a matrix with more than 2000 (${e[0]*e[1]}) elements: Slowness may result.`);const t=Ny(e[0]>e[1]?[e[1],e[0]]:e,0,1,"float32");let n=qh.gramSchmidt(t);return e[0]>e[1]&&(n=Io(n)),Su(this.gain,n)}))}getConfig(){return{gain:this.gain,seed:this.seed}}}Ky.className="Orthogonal",lu(Ky);const Jy={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 Xy(e,t={}){return Rg(e,uu.getMap().classNameMap,t,"initializer")}function Zy(e){return $g(e)}function Qy(e){if("string"==typeof e){const t=e in Jy?Jy[e]:e;if("GlorotNormal"===t)return new Uy;if("GlorotUniform"===t)return new jy;if("HeNormal"===t)return new qy;if("HeUniform"===t)return new Wy;if("LeCunNormal"===t)return new Vy;if("LeCunUniform"===t)return new Gy;{const e={};return e.className=t,e.config={},Xy(e)}}return e instanceof $y?e:Xy(e)}function eb(e){return Array.isArray(e)&&Array.isArray(e[0])}function tb(e){return 0===e.length?[]:Array.isArray(e[0])?e:[e]}function nb(e){let t;if(Array.isArray(e)){if(1!==e.length)throw new wg(`Expected Tensor length to be 1; got ${e.length}`);t=e[0]}else t=e;return t}function rb(e){if(Array.isArray(e)&&Array.isArray(e[0])){if(1===e.length)return e[0];throw new wg(`Expected exactly 1 Shape; got ${e.length}`)}return e}function ab(e){let t=0;for(const n of e)0===n.shape.length?t+=1:t+=n.shape.reduce(((e,t)=>e*t));return t}class ib{constructor(e,t="float32",n="Variable",r=!0,a=null){this.dtype=null==t?"float32":t,this.shape=e.shape,this.id=Wg(),n=null==n?"Variable":n,this.originalName=sy(n),this.name=oy(this.originalName),this.trainable_=r,this.constraint=a,this.val=Td(e,this.trainable_,this.name,this.dtype)}read(){return this.assertNotDisposed(),this.val}write(e){return this.assertNotDisposed(),function(e,t){if(e.shape.toString()!==t.shape.toString())throw new Error("Shape mismatch: "+JSON.stringify(e.shape)+" vs. "+JSON.stringify(t.shape))}(this.val,e),this.val.id!==e.id&&(this.val.assign(e),null!=this.constraint&&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 sb(e){return e.map((e=>e.read()))}function ob(e){e.forEach((e=>{e[0].write(e[1])}))}class ub{constructor(e){this.dtype=e.dtype,this.shape=e.shape,null!=e.shape?this.ndim=e.shape.length:this.ndim=e.ndim,this.maxNDim=e.maxNDim,this.minNDim=e.minNDim,this.axes=e.axes||{}}}class lb{constructor(e,t,n,r,a,i,s){this.dtype=e,this.shape=t,this.sourceLayer=n,this.inputs=r,this.callArgs=a,this.outputTensorIndex=s,this.id=Wg(),null!=i&&(this.originalName=sy(i),this.name=oy(this.originalName)),this.rank=t.length}}let cb=0;class pb{constructor(e,t){this.callArgs=t,this.id=cb++,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 t of e.inboundLayers)null!=t&&t.outboundNodes.push(this);e.outboundLayer.inboundNodes.push(this)}getConfig(){const e=[];for(const t of this.inboundLayers)null!=t?e.push(t.name):e.push(null);return{outboundLayer:this.outboundLayer?this.outboundLayer.name:null,inboundLayers:e,nodeIndices:this.nodeIndices,tensorIndices:this.tensorIndices}}}let db=0;class hb extends ou{constructor(e={}){super(),this._callHook=null,this._addedWeightNames=[],this._stateful=!1,this.id=db++,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 e=this.getClassName();t=Cg(e)+"_"+Gg(e)}if(this.name=t,this.trainable_=null==e.trainable||e.trainable,null!=e.inputShape||null!=e.batchInputShape){let t;if(null!=e.batchInputShape)t=e.batchInputShape;else if(null!=e.inputShape){let n=null;null!=e.batchSize&&(n=e.batchSize),t=[n].concat(e.inputShape)}this.batchInputShape=t;let n=e.dtype;null==n&&(n=e.inputDType),null==n&&(n="float32"),this.dtype=n}null!=e.weights?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(0===this.inboundNodes.length)throw new _g(`The layer has never been called and thus has no defined ${t}.`);if(this.inboundNodes.length<=e)throw new wg(`Asked to get ${t} at node ${e}, but the layer has only ${this.inboundNodes.length} inbound nodes.`);return this.inboundNodes[e]}getInputAt(e){return Ig(this.getNodeAtIndex(e,"input").inputTensors)}getOutputAt(e){return Ig(this.getNodeAtIndex(e,"output").outputTensors)}get input(){if(this.inboundNodes.length>1)throw new vg(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer input" is ill-defined. Use \`getInputAt(nodeIndex)\` instead.`);if(0===this.inboundNodes.length)throw new vg(`Layer ${this.name} is not connected, no input to return.`);return Ig(this.getNodeAtIndex(0,"input").inputTensors)}get output(){if(0===this.inboundNodes.length)throw new vg(`Layer ${this.name} has no inbound nodes.`);if(this.inboundNodes.length>1)throw new vg(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use \`getOutputAt(nodeIndex)\` instead.`);return Ig(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){if(e=Eg(e),null==this.inputSpec||0===this.inputSpec.length)return;const t=Eg(this.inputSpec);if(e.length!==t.length)throw new wg(`Layer ${this.name} expects ${t.length} inputs, but it received ${e.length} input tensors. Input received: ${e}`);for(let n=0;na.maxNDim)throw new wg(`Input ${n} is incompatible with layer ${this.name}: expected max_ndim=${a.maxNDim}, found ndim=${i}`);if(null!=a.minNDim&&i=0?e[r]:e[e.length+r];if(null!=i&&-1===[i,null].indexOf(s))throw new wg(`Input ${n} is incompatible with layer ${this.name}: expected axis ${r} of input shape to have value ${i} but got shape ${e}.`)}}if(null!=a.shape)for(let e=0;e{if(!this.built){this.assertInputCompatibility(e);const t=[];for(const n of Eg(e))t.push(n.shape);this.build(Ig(t)),this.built=!0,this.initialWeights&&this.setWeights(this.initialWeights),null===this._refCount&&a&&(this._refCount=1)}if(this.assertInputCompatibility(e),a){let r=this.call(e,t);const a=Eg(r),i=[];for(let e of a)-1!==n.indexOf(e)&&(e=e.clone()),i.push(e);if(r=Ig(i),null!=this.activityRegularizer)throw new Mg("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return r}{const n=function(e){e=Eg(e);const t=[];for(const n of e)t.push(n.shape);return Ig(t)}(e),r=this.computeOutputShape(n);let a;const i="float32";if(this.warnOnIncompatibleInputShape(Array.isArray(e)?n[0]:n),a=null!=r&&r.length>0&&Array.isArray(r[0])?r.map(((n,r)=>new lb(i,n,this,Eg(e),t,this.name,r))):new lb(i,r,this,Eg(e),t,this.name),this.addInboundNode(e,a,null,null,n,r,t),this._refCount++,null!=this.activityRegularizer)throw new Mg("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return a}}))}warnOnIncompatibleInputShape(e){if(null!=this.batchInputShape)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(((n,r)=>{null!=n&&null!=e[r]&&e[r]!==n&&(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(null==this.inboundNodes||0===this.inboundNodes.length)throw new vg(`The layer ${this.name} has never been called and thus has no defined output shape.`);const e=[];for(const t of this.inboundNodes){const n=JSON.stringify(t.outputShapes);-1===e.indexOf(n)&&e.push(n)}if(1===e.length){const e=this.inboundNodes[0].outputShapes;return Array.isArray(e)&&Array.isArray(e[0])&&1===e.length?e[0]:e}throw new vg(`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 _g(`You tried to call countParams() on ${this.name}, but the layer is not built yet. Build it first by calling build(batchInputShape).`);return ab(this.weights)}build(e){this.built=!0}getWeights(e=!1){return sb(e?this.trainableWeights:this.weights)}setWeights(e){ho((()=>{const t=this.weights;if(t.length!==e.length)throw new wg(`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(0===t.length)return;const n=[],r=sb(t);for(let a=0;aa.apply(l.read()))),null==i&&(i=!0),i?this._trainableWeights.push(l):this._nonTrainableWeights.push(l),l}setFastWeightInitDuringBuild(e){this.fastWeightInitDuringBuild=e}addLoss(e){null==e||Array.isArray(e)&&0===e.length||(e=Eg(e),void 0!==this._losses&&null!==this._losses&&this.losses.push(...e))}computeOutputShape(e){return e}computeMask(e,t){if(!this.supportsMasking){if(null!=t){if(!Array.isArray(t))throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`);t.forEach((e=>{if(null!=e)throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`)}))}return null}return t}addInboundNode(e,t,n,r,a,i,s=null){const o=Eg(e);t=Eg(t),n=Eg(n),r=Eg(r),a=tb(a),i=tb(i);const u=[],l=[],c=[];for(const e of o)u.push(e.sourceLayer),l.push(e.nodeIndex),c.push(e.tensorIndex);new pb({outboundLayer:this,inboundLayers:u,nodeIndices:l,tensorIndices:c,inputTensors:o,outputTensors:t,inputMasks:n,outputMasks:r,inputShapes:a,outputShapes:i},s);for(let e=0;ee.dispose())),this.weights.length}assertNotDisposed(){if(0===this._refCount)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(null===this._refCount)throw new Error(`Cannot dispose Layer ${this.name} because it has not been used yet.`);this.assertNotDisposed();let e=0;return 0==--this._refCount&&(e=this.disposeWeights()),{refCountAfterDispose:this._refCount,numDisposedVariables:e}}}function fb(e,t,n){if((null==t||null!=n&&n>0)&&(t=e.sourceLayer,n=e.nodeIndex),0===t.inboundNodes.length)return[e];{const e=t.inboundNodes[n];if(0===e.inboundLayers.length)return e.inputTensors;{const t=[];for(let n=0;ne.name)),u=[],l=t.names();for(const e of o)-1!==l.indexOf(e)?u.push(t.getValue(e)):u.push(null);null!=r&&(r.maxNumTensors=-1/0,r.minNumTensors=1/0);const c=o.join(",")+"|"+t.names().sort().join(",");let p,d=bb.get(c);if(null==d){const e=function(e,t){se(null!=e&&e.length>0,(()=>"Expected at least one fetch, got none"));let n=[],r={};if(1===e.length){const a=wb(e[0],t);n=a.sorted,r=a.recipientMap}else{const a=new Set;for(const i of e){const{sorted:e,recipientMap:s}=wb(i,t);for(const t of e)a.has(t.name)||(n.push(t),a.add(t.name));for(const e in s)null==r[e]&&(r[e]=new Set),s[e].forEach((t=>r[e].add(t)))}}return{sorted:n,recipientCounts:_b(r)}}(s,t);d=e.sorted,p=e.recipientCounts,bb.put(c,d),xb.put(c,p)}p={},a||Object.assign(p,xb.get(c));const h=new yb(t);for(let e=0;er.maxNumTensors&&(r.maxNumTensors=e),e0;){const e=i[i.length-1];if(n.has(e.name)){i.pop();continue}const t=s[s.length-1]===i.length-1;if(0===e.inputs.length||t)i.pop(),r.push(e),n.add(e.name),t&&s.pop();else{s.push(i.length-1);for(const t of e.inputs)null==a[t.name]&&(a[t.name]=new Set),a[t.name].add(e.name),n.has(t.name)||i.push(t)}}return{sorted:r,recipientMap:a}}function Mb(e){let t;if(1===e.sourceLayer.inboundNodes.length)t=e.sourceLayer.output;else{let n=null;for(let t=0;tku(Nc(Su(e,e),t,!0))))}Ge().registerFlag("TOPOLOGICAL_SORT_CACHE_MAX_ENTRIES",(()=>100),(function(e){null!=bb&&bb.setMaxEntries(e),null!=xb&&xb.setMaxEntries(e)}));class Sb extends ou{getConfig(){return{}}}class kb extends Sb{constructor(e){super(),this.defaultMaxValue=2,this.defaultAxis=0,this.maxValue=null!=e.maxValue?e.maxValue:this.defaultMaxValue,this.axis=null!=e.axis?e.axis:this.defaultAxis}apply(e){return ho((()=>{const t=Nb(e,this.axis),n=Bl(t,0,this.maxValue);return Su(e,Nu(n,wu(my(),t)))}))}getConfig(){return{maxValue:this.maxValue,axis:this.axis}}}kb.className="MaxNorm",lu(kb);class Db extends Sb{constructor(e){super(),this.defaultAxis=0,this.axis=null!=e.axis?e.axis:this.defaultAxis}apply(e){return ho((()=>Nu(e,wu(my(),Nb(e,this.axis)))))}getConfig(){return{axis:this.axis}}}Db.className="UnitNorm",lu(Db);class Tb extends Sb{apply(e){return Bp(e)}}Tb.className="NonNeg",lu(Tb);class Ib extends Sb{constructor(e){super(),this.defaultMinValue=0,this.defaultMaxValue=1,this.defaultRate=1,this.defaultAxis=0,this.minValue=null!=e.minValue?e.minValue:this.defaultMinValue,this.maxValue=null!=e.maxValue?e.maxValue:this.defaultMaxValue,this.rate=null!=e.rate?e.rate:this.defaultRate,this.axis=null!=e.axis?e.axis:this.defaultAxis}apply(e){return ho((()=>{const t=Nb(e,this.axis),n=wu(Su(this.rate,Bl(t,this.minValue,this.maxValue)),Su(1-this.rate,t));return Su(e,Nu(n,wu(my(),t)))}))}getConfig(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}}}Ib.className="MinMaxNorm",lu(Ib);const Eb={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function Cb(e){return $g(e)}function Ab(e,t={}){return Rg(e,uu.getMap().classNameMap,t,"constraint")}function Lb(e){return null==e?null:"string"==typeof e?Ab({className:e in Eb?Eb[e]:e,config:{}}):e instanceof Sb?e:Ab(e)}function $b(e){return new kb(e)}function Ob(e){return new Db(e)}function Rb(){return new Tb}function Fb(e){return new Ib(e)}function Yb(){return new Oy}function zb(){return new Ry}function Bb(e){return new Fy(e)}function Pb(e){return new Yy(e)}function Hb(e){return new zy(e)}function jb(e){return new By(e)}function Ub(e){return new Py(e)}function qb(e){return new Hy(e)}function Wb(e){return new jy(e)}function Vb(e){return new Uy(e)}function Gb(e){return new qy(e)}function Kb(e){return new Wy(e)}function Jb(e){return new Vy(e)}function Xb(e){return new Gy(e)}function Zb(e){return new Ky(e)}async function Qb(e){if(null==e)return;const t=[],n=[],r=[];for(const a in e){const i=e[a];if("number"!=typeof i){const e=i;t.push(e.data()),n.push(a),r.push(e)}}if(t.length>0){const a=await Promise.all(t);for(let t=0;twu(this.totals[e],Su(r,n))));this.totals[e]=a,null!=t&&t.dispose()}}}async onEpochEnd(e,t){if(null!=t)for(const e of this.params.metrics)null!=this.totals[e]&&("number"==typeof this.totals[e]?t[e]=this.totals[e]/this.seen:ho((()=>{const n=Su(Nu(1,this.seen),this.totals[e]);t[e]=n,this.totals[e].dispose(),mo(t[e])})))}}class ix extends nx{async onTrainBegin(e){this.epoch=[],this.history={}}async onEpochEnd(e,t){null==t&&(t={}),this.epoch.push(e);for(const e in t)null==this.history[e]&&(this.history[e]=[]),this.history[e].push(t[e])}async syncData(){const e=[],t=[],n=[];for(const r in this.history){const a=this.history[r];for(let i=0;i{const s=null!=n?n():za();return s-anew sx(e,t)))}class ux{constructor(){}static registerCallbackConstructor(e,t){se(e>=0&&Number.isInteger(e),(()=>`Verbosity level is expected to be an integer >= 0, but got ${e}`)),ux.checkForDuplicate(t),null==ux.constructors[e]&&(ux.constructors[e]=[]),ux.constructors[e].push(t)}static checkForDuplicate(e){for(const t in ux.constructors)ux.constructors[+t].forEach((t=>{if(t===e)throw new wg("Duplicate callback constructor.")}))}static clear(){ux.constructors={}}static createCallbacks(e){const t=[];for(const n in ux.constructors){const r=+n;e>=r&&t.push(...ux.constructors[r])}return t.map((e=>new e))}}function lx(e,t,n,r,a,i,s,o,u){const l=new ix,c=[new ax,...ux.createCallbacks(t)];null!=e&&c.push(...e),c.push(l);const p=new rx(c);return p.setParams({epochs:n,initialEpoch:r,samples:a,steps:i,batchSize:s,verbose:t,doValidation:o,metrics:u}),{callbackList:p,history:l}}function cx(e,t={},n=!1){return Rg(e,uu.getMap().classNameMap,t,"layer",n)}function px(e,t){return ho((()=>{"float32"!==e.dtype&&(e=Ls(e,"float32"));const n=Nc(Dy(e),t,!0),r=zu(n.shape,my()),a=ku(qu(n,r));return Nu(e,a)}))}function dx(e,t){return ho((()=>op(Dy(Hu(t,e)),-1)))}function hx(e,t){return ho((()=>op(Uu(Hu(t,e)),-1)))}function fx(e,t){return ho((()=>{const n=Hu(e,t),r=Bl(Uu(e),my(),Number.MAX_VALUE),a=Uu(Nu(n,r));return Su(100,op(a,-1))}))}function mx(e,t,n=!1){return ho((()=>{if(n)t=id(t);else{const e=Nc(t,t.shape.length-1,!0);t=Nu(t,e)}return t=Bl(t,my(),1-my()),Do(Nc(Su(Ls(e,"float32"),qc(t)),t.shape.length-1))}))}function gx(e,t,n=!1){return ho((()=>{const r=Ls(Lc(function(e){const t=[cy(e.shape)];return Ml(e,t)}(e)),"int32"),a=(t=Bl(t,my(),1-my())).shape;return mx(Ml(ro(r,a[a.length-1]),a),t,n)}))}function yx(e,t){return ho((()=>{let n;return n=Bl(t,my(),1-my()),n=qc(Nu(n,Hu(1,n))),op(function(e,t){if(!de(e.shape,t.shape))throw new wg(`logits and labels must have the same shape, but got shapes ${JSON.stringify(e.shape)} and ${JSON.stringify(t.shape)}`);return ho((()=>{const n=Bp(t),r=Do(Uu(t));return wu(Hu(n,Su(t,e)),Wc(Tc(r)))}))}(e,n),-1)}))}function bx(e,t){return ho((()=>{const n=px(e,-1),r=px(t,-1),a=Su(n,r);return Do(Nc(a,-1))}))}ux.constructors={};const xx={meanSquaredError:dx,meanAbsoluteError:hx,meanAbsolutePercentageError:fx,meanSquaredLogarithmicError:function(e,t){return ho((()=>{const n=Bl(t,my(),Number.MAX_VALUE),r=qc(wu(1,n)),a=Bl(e,my(),Number.MAX_VALUE),i=qc(wu(1,a));return op(Dy(Hu(r,i)),-1)}))},squaredHinge:function(e,t){return ho((()=>{const n=qu(0,Hu(1,Su(e,t)));return op(Dy(n),-1)}))},hinge:function(e,t){return ho((()=>{const n=qu(0,Hu(1,Su(e,t)));return op(n,-1)}))},categoricalHinge:function(e,t){return ho((()=>{const n=Nc(Su(e,t),-1),r=wc(Su(Hu(1,e),t),-1);return qu(0,wu(1,Hu(r,n)))}))},logcosh:function(e,t){return ho((()=>{const n=Math.log(2),r=Hu(t,e),a=Hu(wu(r,Vc(Su(-2,r))),n);return op(a,-1)}))},categoricalCrossentropy:mx,sparseCategoricalCrossentropy:gx,binaryCrossentropy:yx,kullbackLeiblerDivergence:function(e,t){return ho((()=>{const n=Bl(e,my(),1),r=Bl(t,my(),1);return Nc(Su(e,qc(Nu(n,r))),-1)}))},poisson:function(e,t){return ho((()=>{const n=qc(wu(my(),t));return op(Hu(t,Su(e,n)),-1)}))},cosineProximity:bx};function vx(e){if("string"==typeof e){if(e in xx)return xx[e];let t=`Unknown loss ${e}`;throw e.toLowerCase().includes("softmaxcrossentropy")&&(t=`Unknown loss ${e}. Use "categoricalCrossentropy" as the string name for tf.losses.softmaxCrossEntropy`),new wg(t)}return e}function _x(e,t){return ho((()=>{const n=Su(.5,bp(t)),r=gy(Oc(t,n),e.dtype);return op(oc(e,r),-1)}))}function wx(e,t){return ho((()=>gy(oc(nl(e,-1),nl(t,-1)),"float32")))}function Mx(e,t){return ho((()=>Ls(Nc(Xc(oc(e,1),oc(t,1))),"float32")))}function Nx(e,t){return ho((()=>{const n=Mx(e,t),r=function(e,t){return ho((()=>Ls(Nc(Xc(oc(e,0),oc(t,1))),"float32")))}(e,t),a=wu(n,r);return Ls(uc(Oc(a,0),Nu(n,a),0),"float32")}))}function Sx(e,t){return yx(e,t)}function kx(e,t){return e.rank===t.rank&&(e=dd(e,[e.rank-1])),(t=nl(t,-1)).dtype!==e.dtype&&(t=Ls(t,e.dtype)),Ls(oc(e,t),"float32")}const Dx=mx,Tx=gx,Ix={binaryAccuracy:_x,categoricalAccuracy:wx,precision:Nx,categoricalCrossentropy:Dx,sparseCategoricalCrossentropy:Tx,mse:dx,MSE:dx,mae:hx,MAE:hx,mape:fx,MAPE:fx,cosine:bx};function Ex(e){if("string"==typeof e&&e in Ix)return Ix[e];if("string"!=typeof e&&null!=e)return e;throw new wg(`Unknown metric ${e}`)}function Cx(e){if(Dg(null!==e,`Unknown LossOrMetricFn ${e}`),"string"==typeof e)return e;{let t;for(const n of Object.keys(xx))if(xx[n]===e){t=n;break}if(void 0!==t)return t;for(const n of Object.keys(Ix))if(Ix[n]===e){t=n;break}return void 0!==t?t:e.name}}function Ax(e,t,n=!1){if(null==e||"object"!=typeof e||Object.getPrototypeOf(e)!==Object.prototype||!Lx(e))throw new Error("User-defined metadata is expected to be a JSON object, but is not.");if(n){const n=JSON.stringify(e);n.length>1048576&&console.warn(`User-defined metadata of model "${t}" is too large in size (length=${n.length} when serialized). It is not recommended to store such large objects in user-defined metadata. Please make sure its serialized length is <= 1048576.`)}}function Lx(e){if(null===e)return!0;if("object"==typeof e){if(Object.getPrototypeOf(e)===Object.prototype){const t=Object.keys(e);for(const n of t){if("string"!=typeof n)return!1;if(!Lx(e[n]))return!1}return!0}if(Array.isArray(e)){for(const t of e)if(!Lx(t))return!1;return!0}return!1}{const t=typeof e;return"string"===t||"number"===t||"boolean"===t}}function $x(e,t,n=console.log){let r="";for(let n=0;n0&&(r=r.slice(0,r.length-1)+" "),r+=e[n],r=r.slice(0,t[n]),r+=" ".repeat(t[n]-r.length);n(r)}function Ox(e,t,n){let r,a;try{a=e.inboundNodes.map((e=>JSON.stringify(e.inputShapes))).join(",")}catch(e){a="multiple"}try{r=JSON.stringify(e.outputShape)}catch(e){r="multiple"}$x([`${e.name} (${e.getClassName()})`,a,r,e.countParams().toString()],t,n)}function Rx(e,t,n,r){let a,i;try{i=e.inboundNodes.map((e=>JSON.stringify(e.inputShapes))).join(",")}catch(e){i="multiple"}try{a=JSON.stringify(e.outputShape)}catch(e){a="multiple"}const s=[];for(const t of e.inboundNodes)if(!(null!=n&&n.length>0&&-1===n.indexOf(t)))for(let e=0;ee.name))}`);Yg(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((e=>e.name))}`),this.inputLayers=[],this.inputLayersNodeIndices=[],this.inputLayersTensorIndices=[],this.outputLayers=[],this.outputLayersNodeIndices=[],this.outputLayersTensorIndices=[],this.layers=[],this.internalContainerRefs=[];for(const e of this.outputs){const t=e.sourceLayer,n=e.nodeIndex,r=e.tensorIndex;this.outputLayers.push(t),this.outputLayersNodeIndices.push(n),this.outputLayersTensorIndices.push(r)}for(const e of this.inputs){const t=e.sourceLayer,n=e.nodeIndex,r=e.tensorIndex;Dg(0===n,"input layer has >1 nodes"),Dg(0===r,"input layer has >1 tensors"),this.inputLayers.push(t),this.inputLayersNodeIndices.push(n),this.inputLayersTensorIndices.push(r)}this.inputNames=[],this.outputNames=[],this.feedInputShapes=[],this.feedInputNames=[],this.feedOutputNames=[];for(let t=0;te.shape)),this.internalOutputShapes=this.outputs.map((e=>e.shape));const t={},n={},r={},a={},i={},s=[],o=(e,t,n,r,a,u)=>{null!=r&&null!=a&&null!=u||(r=e.sourceLayer,a=e.nodeIndex,u=e.tensorIndex);const l=r.inboundNodes[a];if(-1!==n.indexOf(l))throw new _g(`The tensor ${e.name} at layer "${r.name}" is part of a cycle.`);if(-1!==t.indexOf(l))return;this.containerNodes.add(Px.nodeKey(r,a)),r.id in i||(i[r.id]=Object.keys(i).length),-1===n.indexOf(l)&&n.push(l);const c=l.inboundLayers.length;for(let e=0;e=0;)n.splice(n.indexOf(l),1);s.push(l)},u=[],l=[];for(const e of this.outputs)o(e,u,l);const c=s.slice().reverse();for(const e of c){n[e.id]=e,e.id in t||(t[e.id]=0);let i=t[e.id];const s=null==r[e.outboundLayer.id]?0:r[e.outboundLayer.id];i=Math.max(i,s),r[e.outboundLayer.id]=i,a[e.outboundLayer.id]=e.outboundLayer,t[e.id]=i;for(let r=0;rparseInt(e,10))).sort(Fg);this.layers=[];for(const e of h){const t=d[e];t.sort(((e,t)=>{const n=i[e.id],r=i[t.id];return nr?1:0}));for(const e of t)e instanceof Px&&this.internalContainerRefs.push(e),this.layers.push(e)}this.layersByDepth=d,h=Object.keys(p).map((e=>parseInt(e,10))).sort(Fg);const f=this.inputs.slice(),m=[];for(const e of h)for(const t of p[e]){const e=t.outboundLayer;if(null!=e){for(const n of t.inputTensors)if(-1===f.indexOf(n))throw new _g(`Graph disconnected: cannot obtain value for tensor ${n} at layer "${e.name}". The following previous layers were accessed without issue: ${m}`);for(const e of t.outputTensors)f.push(e);m.push(e.name)}}this.nodesByDepth=p;const g=this.layers.map((e=>e.name));for(const e of g){const t=g.filter((t=>t===e)).length;if(1!==t)throw new _g(`The name "${e}" is used ${t} times in the model. All layer names should be unique. Layer names: `+JSON.stringify(g))}this.outboundNodes=[],this.inboundNodes=[],new pb({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:this.inputs.map((e=>null)),outputMasks:this.outputs.map((e=>null)),inputShapes:this.inputs.map((e=>e.shape)),outputShapes:this.outputs.map((e=>e.shape))}),this.built=!0,this._refCount=1}assertNotDisposed(){if(0===this._refCount)throw new Error(`Container '${this.name}' is already disposed.`)}dispose(){this.assertNotDisposed();const e={refCountAfterDispose:null,numDisposedVariables:0};if(0==--this._refCount){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((t=>t.trainable=e))})),this.trainable_=e}get trainableWeights(){if(this._trainableWeights.length>0)throw new wg("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 e of this.layers)t.push(...e.trainableWeights);return t.concat(e)}return e}get weights(){return this.trainableWeights.concat(this.nonTrainableWeights)}loadWeights(e,t=!0){const n={};let r=0;for(const e of this.layers)for(const t of e.weights){if(null!=n[t.originalName])throw new wg(`Duplicate weight name: ${t.originalName}`);n[t.originalName]=t,r++}const a=[];for(const r in e){let i=r;if(null==n[r]){const e=r.split("/");i=e.slice(0,-2).concat([e[e.length-1]]).join("/")}if(null!=n[i])a.push([n[i],e[r]]);else if(t)throw new wg(`Provided weight data has no target variable: ${r}`);delete n[i]}if(t){const e=[];for(const t in n)e.push(t);if(e.length>0)throw new wg(`${e.length} of ${r} weights are not set: ${e}`)}ob(a)}updatedConfig(){const e=this.getConfig(),t={};return t.className=this.getClassName(),t.config=e,t.kerasVersion=`tfjs-layers ${Bx}`,t.backend="TensorFlow.js",t}toJSON(e,t=!0){const n=zx(this.updatedConfig());return t?JSON.stringify(n):n}call(e,t){return ho((()=>{e=Eg(e);const n=new yb;for(let t=0;t{let n;return e=Eg(e),n=null==t?kg(null,e.length):Eg(t),this.runInternalGraph(e,n)[1]}))}computeOutputShape(e){const t=tb(e);if(t.length!==this.inputLayers.length)throw new wg(`Invalid inputShape argument ${e}: model has ${this.inputLayers.length} tensor inputs.`);const n={};for(let e=0;eparseInt(e,10))).sort(Fg);if(r.length>1)for(const e of r){const t=this.nodesByDepth[e];for(const e of t){const t=e.outboundLayer;if(-1!==this.inputLayers.map((e=>e.id)).indexOf(t.id))continue;const r=[];for(let t=0;tparseInt(e,10))).sort(Fg);for(const e of r){const t=this.nodesByDepth[e];for(const e of t){const t=e.outboundLayer,r=e.inputTensors,a=e.outputTensors,i=new Array;for(const e of r)e.id in n&&i.push(n[e.id]);if(i.length===r.length){let r,s,o,u,l={};if(null!=e.callArgs&&(l=e.callArgs),1===i.length){const[e,n]=i[0];null==l.mask&&(l.mask=n),o=Eg(t.call(e,l)),u=Eg(t.computeMask(e,n)),r=[e],s=[n]}else r=i.map((e=>e[0])),s=i.map((e=>e[1])),null==l.mask&&(l.mask=s),o=Eg(t.call(r,l)),u=Eg(t.computeMask(r,s));if(t.activityRegularizer)throw new Mg("LayersModel invocation with concrete Tensor value(s) in the presence of activity regularizer(s) is not supported yet.");for(let e=0;e{const e=[];for(const t of this.layers)for(let n=0;n0){const e=[];for(let n=0;n0&&e.apply(Ig(n),r)}function u(e){const n=e.name,i=cx(e,null!=t.customObjects?t.customObjects:{});i.setFastWeightInitDuringBuild(r),a[n]=i,e.inboundNodes.forEach((e=>{if(!(e instanceof Array))throw new wg(`Corrupted configuration, expected array for nodeData: ${e}`);s(i,e)}))}const l=t.name,c=t.layers;for(const e of c)u(e);for(;!zg(i);)for(const e of c){const t=a[e.name];if(t.name in i){const e=i[t.name];delete i[t.name];for(const n of e)o(t,n)}}const p=[],d=[],h=t.inputLayers;for(const e of h){const t=e[0],n=e[1],r=e[2];Dg(t in a);const i=a[t].inboundNodes[n].outputTensors;p.push(i[r])}const f=t.outputLayers;for(const e of f){const t=e[0],n=e[1],r=e[2];Dg(t in a);const i=a[t].inboundNodes[n].outputTensors;d.push(i[r])}return new e({inputs:p,outputs:d,name:l})}get stateful(){if(this._stateful)throw new wg("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(){ho((()=>{this.layers.forEach((e=>{e.stateful&&e.resetStates()}))}))}}function Hx(e,t){return function(e,t,n){const r=t.length;if(null==e||Array.isArray(e)&&0===e.length)return t.map((e=>null));if(1===r)return Array.isArray(e)&&1===e.length?e:"object"==typeof e&&t[0]in e?[e[t[0]]]:[e];if(Array.isArray(e)){if(e.length!==r)throw new Error(`Provided ${n} is an array of ${e.length} element(s), but the model has ${r} outputs. Make sure a set of weights is provided for each model output.`);return e}if("object"==typeof e&&Object.keys(e).length>0&&"object"==typeof e[Object.keys(e)[0]]){const n=[];return t.forEach((t=>{t in e?n.push(e[t]):n.push(null)})),n}throw new Error(`The model has multiple (${r}) outputs, so ${n} must be either an array with ${r} elements or an object with ${t} keys. Provided ${n} not understood: ${JSON.stringify(e)}`)}(e,t,"classWeight")}async function jx(e,t,n,r){if(null!=t||null!=r)throw new Error("Support sampleWeight is not implemented yet");if(null!=n){const t=ho((()=>{if(1===e.shape.length)return $s(e);if(2===e.shape.length){if(e.shape[1]>1)return nl(e,1);if(1===e.shape[1])return Ml(e,[e.shape[0]]);throw new Error(`Encountered unexpected last-dimension size (${e.shape[1]}) during handling of class weights. The size is expected to be >= 1.`)}throw new Error(`Unexpected rank of target (y) tensor (${e.rank}) during handling of class weights. The rank is expected to be 1 or 2.`)})),r=Array.from(await t.data());fo(t);const a=[];return r.forEach((e=>{if(null==n[e])throw new Error(`classWeight must contain all classes in the training data. The class ${e} exists in the data but not in classWeight`);a.push(n[e])})),yd(a,"float32")}return null}function Ux(e,t){return Su(e,t)}function qx(e,t){let n,r;const a=t;n=a.xs,r=a.ys,se(null!=n&&null!=r,(()=>`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 ${t}`));const i=Wx("input",e.inputNames,n),s=Wx("output",e.outputNames,r),o=i[0].shape[0];se(i.length===e.inputs.length,(()=>`LayersModel has ${e.inputs.length} inputs, but the dataset provides ${i.length} inputs. (Expected input keys: ${JSON.stringify(e.inputNames)})`)),se(s.length===e.outputs.length,(()=>`LayersModel has ${e.outputs.length} outputs, but the dataset provides ${s.length} outputs. (Expected output keys: ${JSON.stringify(e.outputNames)})`));for(let t=0;t`Batch size mismatch: input ${e.inputNames[t]} has ${i[t].shape[0]}; expected ${o} based on input ${e.inputNames[0]}.`));for(let t=0;t`Batch size mismatch: output ${e.outputNames[t]} has ${s[t].shape[0]}; expected ${o} based on input ${e.inputNames[0]}.`));return{xs:i,ys:s}}function Wx(e,t,n){if(n instanceof ti)return[n];if(Array.isArray(n))return se(n.length===t.length,(()=>`Received an array of ${n.length} Tensors, but expected ${t.length} to match the ${e} keys ${t}.`)),n;{const r=[];for(const a of t){if(null==n[a])throw new wg(`The feature data generated by the dataset lacks the required ${e} key '${a}'.`);r.push(n[a])}return r}}function Vx(e){return"function"==typeof e.iterator}function Gx(e){se(e>0&&Number.isInteger(e),(()=>`batchSize is required to be a positive integer, but got ${e}`))}function Kx(e,t,n){return null==e?[null]:Array.isArray(e)?e.map((e=>by(e,t,n-t))):by(e,t,n-t)}function Jx(e,t){return ho((()=>null==e?null:Array.isArray(e)?e.map((e=>Jx(e,t))):ky(e,"int32"===t.dtype?t:Ls(t,"int32"))))}function Xx(e,t){const n=[];let r=0,a=null;for(;r=e&&(a=e),n.push([r,a]),r=a;return n}function Zx(e){const t=[];e instanceof ti&&(e=[e]);for(let n=0;nn.push(e.id)));else if(null!=t)for(const e in t){const r=t[e];n.push(r.id)}const r=[];if(e instanceof ti)-1===n.indexOf(e.id)&&r.push(e);else if(Array.isArray(e))e.forEach((e=>{-1===n.indexOf(e.id)&&r.push(e)}));else if(null!=e)for(const t in e){const a=e[t];-1===n.indexOf(a.id)&&r.push(a)}r.forEach((e=>{e.isDisposed||e.dispose()}))}function ev(e){return Array.isArray(e)}function tv(e){return!function(e){return e instanceof ti}(e)&&!ev(e)}function nv(e,t,n,r=!0,a=""){if(null==t||0===t.length){if(null!=e){let t=!1;if(ev(e)&&e.length>0)t=!0;else if(tv(e)){for(const n in e)if(e.hasOwnProperty(n)){t=!0;break}}else t=!0;if(t)throw new wg(`Error when checking model ${a} expected no data, but got ${e}`)}return[]}if(null==e)return t.map((e=>null));let i;if(tv(e)){i=[];for(const n of t){if(null==e[n])throw new wg(`No data provided for "${n}". Need data for each key in: ${t}`);i.push(e[n])}}else if(ev(e)){if(e.length!==t.length)throw new wg(`Error when checking model ${a}: the Array of Tensors that you are passing to your model is not the size the model expected. Expected to see ${t.length} Tensor(s), but instead got the following list of Tensor(s): ${e}`);i=e}else{if(t.length>1)throw new wg(`The model ${a} expects ${t.length} Tensor(s), but only received one Tensor. Found: Tensor with shape ${e.shape}`);i=[e]}if(i=Zx(i),null!=n)for(let e=0;e=0&&i!==o)throw new wg(`${a} expected a batch of elements where each example has shape [${n[e].slice(1,n[e].length)}] (i.e.,tensor shape [*,${n[e].slice(1,n[e].length)}]) but the ${a} received an input with ${s.shape[0]} examples, each with shape [${s.shape.slice(1,s.shape.length)}] (tensor shape [${s.shape}])`)}}return i}function rv(e,t,n,r=!0,a=""){let i;if(Array.isArray(e)){if(e.length!==t.length)throw new wg(`Error when checking model ${a}: the Array of Tensors that you are passing to your model is not the size the the model expected. Expected to see ${t.length} Tensor(s), but instead got ${e.length} Tensors(s).`);i=e}else{if(t.length>1)throw new wg(`The model expects ${t.length} ${a} Tensors, but only received one Tensor. Found: array with shape ${JSON.stringify(e.shape)}.`);i=[e]}if(null!=n)for(let e=0;e1||1===e.length&&e[0].inboundLayers.length>1){t=!1;break}r.push(...e)}if(t)for(const n of e.layers){let e=!1;for(const a of n.inboundNodes)if(-1!==r.indexOf(a)){if(e){t=!1;break}e=!0}if(!t)break}return t}(e),i=["Layer (type)","Input Shape","Output shape","Param #"];let s;if(a?(t=t||90,n=n||[.32,.61,.89,1]):(t=t||115,n=n||[.24,.48,.7,.8,1]),n[n.length-1]<=1&&(n=n.map((e=>Math.floor(t*e)))),!a){i.push("Receives inputs"),s=[];for(const t in e.nodesByDepth)s.push(...e.nodesByDepth[t])}r("_".repeat(t)),$x(i,n,r),r("=".repeat(t));const o=e.layers;for(let e=0;eKh.adagrad(.01),Adadelta:()=>Kh.adadelta(1,.95,my()),Adam:()=>Kh.adam(.001,.9,.999,my()),Adamax:()=>Kh.adamax(.002,.9,.999,my(),0),RMSProp:()=>Kh.rmsprop(.001,.9,0,my()),SGD:()=>Kh.sgd(.01)};if(t.adagrad=t.Adagrad,t.adadelta=t.Adadelta,t.adam=t.Adam,t.adamax=t.Adamax,t.rmsprop=t.RMSProp,t.sgd=t.SGD,e in t)return t[e]();throw new wg(`Unknown Optimizer ${e}`)}(e.optimizer),this.isOptimizerOwned=!0;else{if(!(e.optimizer instanceof Fu))throw new wg("User-defined optimizer must be an instance of tf.Optimizer.");this.optimizer_=e.optimizer,this.isOptimizerOwned=!1}let t=[];if(Array.isArray(e.loss)||"string"==typeof e.loss||"function"==typeof e.loss)if(Array.isArray(e.loss)){if(e.loss.length!==this.outputs.length)throw new wg(`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}.`);const n=e.loss;t=n.map((e=>vx(e)))}else{const n=vx(e.loss);this.outputs.forEach((e=>{t.push(n)}))}else{e.loss=e.loss;for(const t in e.loss)if(-1===this.outputNames.indexOf(t))throw new wg(`Unknown entry in loss dictionary: "${t}". Only expected the following keys: ${this.outputNames}`);for(const n of this.outputNames)null==e.loss[n]&&console.warn(`Output "${n}" is missing from loss dictionary. We assume this was done on purpose, and we will not be expecting data to be passed to ${n} during training`),t.push(vx(e.loss[n]))}this.lossFunctions=t,this.feedOutputNames=[],this.feedOutputShapes=[],this.feedLossFns=[];for(let e=0;e{for(let e=0;e1&&(this.metricsTensors.push([t,e]),this.metricsNames.push(this.outputNames[e]+"_loss"))}}));const r=function(e,t){if(null==e||Array.isArray(e)&&0===e.length)return t.map((e=>[]));let n;if("string"==typeof e||"function"==typeof e)n=[e];else{if(!Array.isArray(e)&&"object"!=typeof e)throw new TypeError(`Type of metrics argument not understood. Expected an string,function, Array, or Object, found: ${e}`);n=e}if(Array.isArray(n))return t.map((e=>n));{const e=[];for(const r of t){let t=n.hasOwnProperty(r)?n[r]:[];Array.isArray(t)||(t=[t]),e.push(t)}return e}}(e.metrics,this.outputNames),a=(e,t,n)=>{this.outputNames.length>1&&(t=this.outputNames[e]+"_"+t),this.metricsNames.push(t),this.metricsTensors.push([n,e])};iy("metric",(()=>{for(let e=0;e{let n,r,i;for(const s of t){if("string"==typeof s&&-1!==["accuracy","acc","crossentropy","ce"].indexOf(s)){const t=this.internalOutputShapes[e];let a;1===t[t.length-1]||this.lossFunctions[e]===yx?-1!==["accuracy","acc"].indexOf(s)?r=_x:-1!==["crossentropy","ce"].indexOf(s)&&(r=Sx):this.lossFunctions[e]===gx?-1!==["accuracy","acc"].indexOf(s)?r=kx:-1!==["crossentropy","ce"].indexOf(s)&&(r=Tx):-1!==["accuracy","acc"].indexOf(s)?r=wx:-1!==["crossentropy","ce"].indexOf(s)&&(r=Dx),-1!==["accuracy","acc"].indexOf(s)?a="acc":-1!==["crossentropy","ce"].indexOf(s)&&(a="ce"),i=r,n=""+a}else{const e=Ex(s);i=e,n=""+Cx(s)}let t;iy(n,(()=>{t=i})),a(e,n,t)}})(r[e])})),this.collectedTrainableWeights=this.trainableWeights}checkTrainableWeightsConsistency(){null!=this.collectedTrainableWeights&&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,n={}){const r=null==n.batchSize?32:n.batchSize;Gx(r);const a=this.standardizeUserDataXY(e,t,!0,r);try{const i=a[0].concat(a[1]);this.makeTestFunction();const s=this.testFunction;return Ig(this.testLoop(s,i,r,n.verbose,n.steps))}finally{Qx(a[0],e),Qx(a[1],t)}}async evaluateDataset(e,t){return this.makeTestFunction(),async function(e,t,n){const r=null!=(n=n||{}).batches,a=e.testFunction;let i=[];if(n.verbose>0)throw new Mg("Verbose mode is not implemented yet.");se(!r||n.batches>0&&Number.isInteger(n.batches),(()=>`Test loop expects \`batches\` to be a positive integer, but received ${JSON.stringify(n.batches)}`));const s="function"==typeof t.next?t:await t.iterator();let o=0,u=0;for(;!r||u{if(t.value){const{xs:n,ys:r}=qx(e,t.value),s=n.concat(r),l=ho((()=>a(s)));if(fo(s),0===u)for(let e=0;ewu(i[e],Su(c,t)))),u>0&&fo(n)}fo(l),o+=c,++u}return i})),t.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, ${n.batches} batches). You may need to use the repeat() function when building your dataset.`);break}}for(let e=0;ee.name));for(let r=0;r0){const n=[];throw t.forEach(((t,r)=>{null==t&&n.push(e[r])})),new wg(`Cannot find SymbolicTensors for output name(s): ${JSON.stringify(n)}`)}return t}predictLoop(e,t=32,n=!1){return ho((()=>{const r=this.checkNumSamples(e);if(n)throw new Mg("Verbose predictLoop() is not implemented yet.");const a=Xx(r,t),i=this.outputs.map((e=>[]));for(let t=0;t{const n=a[t][0],r=a[t][1],i=Kx(e,n,r),s=[];if(Array.isArray(i))for(let e=0;ei[t].push(e)))}return Ig(i.map((e=>kl(e,0))))}))}predict(e,t={}){const n=Zx(e);rv(n,this.inputNames,this.feedInputShapes,!1);try{const r=null==t.batchSize?32:t.batchSize;return Gx(r),this.predictLoop(n,r)}finally{Qx(n,e)}}predictOnBatch(e){rv(e,this.inputNames,this.feedInputShapes,!0);const t=(Array.isArray(e)?e[0]:e).shape[0];return this.predictLoop(e,t)}standardizeUserDataXY(e,t,n=!0,r){if(null==this.optimizer_)throw new _g("You must compile a model before training/testing. Use LayersModel.compile(modelCompileArgs).");const a=[];for(let e=0;ee.shape[0])));r.sort();const a=Yg(t.map((e=>e.shape[0])));if(a.sort(),r.length>1)throw new wg(`All input Tensors (x) should have the same number of samples. Got array shapes: ${JSON.stringify(e.map((e=>e.shape)))}`);if(a.length>1)throw new wg(`All target Tensors (y) should have the same number of samples. Got array shapes: ${JSON.stringify(t.map((e=>e.shape)))}`);if(r.length>0&&a.length>0&&!de(r,a))throw new wg(`Input Tensors should have the same number of samples as target Tensors. Found ${r[0]} input sample(s) and ${a[0]} target sample(s).`)}(e=nv(e,this.feedInputNames,this.feedInputShapes,!1,"input"),t=nv(t,this.feedOutputNames,a,!1,"target")),function(e,t,n){const r=[dx,yx,mx];for(let a=0;a0&&e[0].shape[0]%r!=0)throw new wg(`In a stateful network, you should only pass inputs with a number of samples that is divisible by the batch size ${r}. Found: ${e[0].shape[0]} sample(s).`);return[e,t]}async standardizeUserData(e,t,n,r,a=!0,i){const[s,o]=this.standardizeUserDataXY(e,t,a,i);if(null!=n)throw new Error("sample weight is not supported yet.");let u=null;if(null!=r){const e=Hx(r,this.outputNames);u=[];for(let t=0;t{const i=this.checkNumSamples(t,n,a,"steps"),s=[];if(r>0)throw new Mg("Verbose mode is not implemented yet.");if(null!=a)throw new Mg("steps mode in testLoop() is not implemented yet");{const r=Xx(i,n),a=yd(hy(0,i));for(let n=0;n1&&(a+=`_${Tg(e.slice(0,n),r)}`),t.push(a)}return t}makeTrainFunction(){return e=>{const t=[],n=e.slice(0,this.inputs.length),r=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),a=e.slice(this.inputs.length+this.outputs.length,this.inputs.length+2*this.outputs.length),i=[],s=this.collectedTrainableWeights.map((e=>e.read())),o=this.optimizer_.minimize((()=>{const e=[];for(let t=0;t1&&e{u=wu(u,e)})),u}),!0,s);return[o].concat(i)}}makeTestFunction(){this.testFunction=e=>ho((()=>{const t=[];let n;const r=e.slice(0,this.inputs.length),a=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),i=[];for(let e=0;e0){if(y=!0,2!==r.validationData.length)throw 3===r.validationData.length?new Mg("validationData including sample weights is not supported yet."):new wg(`When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; ${r.validationData} is invalid.`);u=r.validationData[0],l=r.validationData[1];const t=!0,n=await e.standardizeUserData(u,l,null,null,t,h);c=n[0],p=n[1],g=c.concat(p)}else if(null!=r.validationSplit&&r.validationSplit>0&&r.validationSplit<1){y=!0;const e=Math.floor(a[0].shape[0]*(1-r.validationSplit)),t=a[0].shape[0];c=Kx(a,e,t),s=a,a=Kx(a,0,e),p=Kx(i,e,t),o=i,i=Kx(i,0,e),g=c.concat(p)}else null!=r.validationSteps&&(y=!0);const b=a.concat(i).concat(d);e.checkTrainableWeightsConsistency();const x=e.makeTrainFunction(),v=e.getDedupedMetricsNames();let _,w;y?(e.makeTestFunction(),_=e.testFunction,w=v.slice().concat(v.map((e=>"val_"+e)))):(_=null,g=[],w=v.slice());const M=ox(r.callbacks,r.yieldEvery),N=await async function(e,t,n,r,a,i,s,o,u,l,c,p,d,h,f){null==a&&(a=32),null==i&&(i=1),null==c&&(c=!0),null==d&&(d=0);let m=!1;null!=u&&null!=l&&(m=!0);const g=e.checkNumSamples(n,a,h,"steps_per_epoch");let y;null!=g&&(y=hy(0,g)),null==s&&(s=1);const{callbackList:b,history:x}=lx(o,s,i,d,g,h,a,m,p);b.setModel(e),e.history=x,await b.onTrainBegin(),e.stopTraining_=!1;for(let s=d;s{const d=o[c][0],h=o[c][1],f=by(s,d,h-d);p.batch=c,p.size=h-d;const g=Jx(n,f),y=t(g);for(let e=0;e"You must compile a model before training/testing. Use LayersModel.compile(modelCompileConfig).")),se(null!=n,(()=>"For fitDataset(), the 2nd argument (config) is required, but it is not provided in this call.")),se(null!=n.epochs&&n.epochs>0&&Number.isInteger(n.epochs),(()=>`For fitDataset(), config.epochs is expected to be a positive integer, but got ${n.epochs}`)),se(!r||n.batchesPerEpoch>0&&Number.isInteger(n.batchesPerEpoch),(()=>`For fitDataset(), config.batchesPerEpoch is expected to be a positive integer if specified, but got ${n.batchesPerEpoch}`)),se(null==n.validationSplit,(()=>"`validationSplit` is not supported by `fitDataset()`. Use validationData instead.")),e.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");e.isTraining=!0;try{const a=null!=n.validationData;let i,s;if(a)if(Vx(n.validationData))se(null==n.validationBatches||n.validationBatches>0&&Number.isInteger(n.validationBatches),(()=>`For fitDataset() with dataset-based validation, config.validationBatches is expected not to be provided, or to be a positive integer, but got ${n.validationBatches}`));else{const e=function(e){if(3===e.length)throw new Mg("Validation with sample weights is not implemented yet.");return{xs:e[0],ys:e[1]}}(n.validationData);i=e.xs,s=e.ys}const o=e.makeTrainFunction(),u=e.getDedupedMetricsNames();let l;l=a?u.slice().concat(u.map((e=>"val_"+e))):u.slice();const c=ox(n.callbacks,n.yieldEvery),p=null==n.verbose?1:n.verbose,{callbackList:d,history:h}=lx(c,p,n.epochs,null,null,function(e,t){let n=null;return null!=t.batchesPerEpoch?n=t.batchesPerEpoch:Number.isFinite(e.size)&&(n=e.size),n}(t,n),null,a,l);d.setModel(e),e.history=h,await d.onTrainBegin(),e.stopTraining_=!1;let f=null==n.initialEpoch?0:n.initialEpoch,m=await t.iterator();for(;f=n.batchesPerEpoch:t.done){if(a){let t;t=Vx(n.validationData)?Eg(await e.evaluateDataset(n.validationData,{batches:n.validationBatches})):Eg(e.evaluate(i,s,{batchSize:null==n.validationBatchSize?32:n.validationBatchSize,verbose:0}));for(let n=0;nCg(e)))}else{const t=Object.keys(this.loss);e={};const n=this.loss;for(const r of t){if("string"!=typeof n[r])throw new Error("Serialization of non-string loss is not supported.");e[r]=Cg(n[r])}}return e}getMetricIdentifiers(){if("string"==typeof this.metrics||"function"==typeof this.metrics)return[Cg(Cx(this.metrics))];if(Array.isArray(this.metrics))return this.metrics.map((e=>Cg(Cx(e))));{const e={};for(const t in this.metrics)e[t]=Cg(Cx(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(null!=e.weighted_metrics)throw new Error("Loading weight_metrics is not supported yet.");if(null!=e.loss_weights)throw new Error("Loading loss_weights is not supported yet.");if(null!=e.sample_weight_mode)throw new Error("Loading sample_weight_mode is not supported yet.");const t=cx(Yx(e.optimizer_config));let n,r;if("string"==typeof e.loss)n=Ag(e.loss);else if(Array.isArray(e.loss))n=e.loss.map((e=>Ag(e)));else if(null!=e.loss){n={};for(const t in e.loss)n[t]=Ag(e.loss[t])}if(Array.isArray(e.metrics))r=e.metrics.map((e=>Ag(e)));else if(null!=e.metrics){r={};for(const t in e.metrics)r[t]=Ag(e.metrics[t])}this.compile({loss:n,metrics:r,optimizer:t})}async save(e,t){if("string"==typeof e){const t=Qi(e);if(0===t.length)throw new wg(`Cannot find any save handlers for URL '${e}'`);if(t.length>1)throw new wg(`Found more than one (${t.length}) save handlers for URL '${e}'`);e=t[0]}if(null==e.save)throw new wg("LayersModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");const n=await zi(this.getNamedWeights(t)),r={modelTopology:this.toJSON(null,!1),format:"layers-model",generatedBy:`TensorFlow.js tfjs-layers v${Bx}`,convertedBy:null};if(null!=t&&t.includeOptimizer&&null!=this.optimizer){r.trainingConfig=this.getTrainingConfig();const e="optimizer",{data:t,specs:a}=await zi(await this.optimizer.getWeights(),e);n.specs.push(...a),n.data=Ui([n.data,t])}if(null!=this.userDefinedMetadata){const e=!0;Ax(this.userDefinedMetadata,this.name,e),r.userDefinedMetadata=this.userDefinedMetadata}return r.weightData=n.data,r.weightSpecs=n.specs,e.save(r)}setUserDefinedMetadata(e){Ax(e,this.name),this.userDefinedMetadata=e}getUserDefinedMetadata(){return this.userDefinedMetadata}}av.className="Model",lu(av);class iv extends av{}async function sv(e,t){"modelTopology"in e||(e={modelTopology:e});let n=e.modelTopology;null!=n.model_config&&(n=n.model_config);const r=cx(Yx(n),t);if(null!=e.weightsManifest){const t=await Hs(e.weightsManifest,e.pathPrefix,r.weights.map((e=>e.originalName))),n={};for(const e of r.weights)n[e.originalName]=t[e.originalName];r.loadWeights(n),fo(t)}return r}iv.className="Functional",lu(iv);class ov extends av{constructor(e){if(super({inputs:[],outputs:[]}),e=e||{},this.trainable=!0,this.built=!1,this.name=null!=e.name?e.name:Gg("sequential_"),null!=e.layers)for(const t of e.layers)this.add(t)}checkShape(e){if(e.inboundNodes[0].outputTensors[0].shape.some((e=>e<0)))throw new wg(`Negative dimension size caused by adding layer ${e.name} with input shape [${e.inboundNodes[0].inputTensors[0].shape}]`)}add(e){const t=e instanceof ov||e instanceof av;let n;if(t){if(n=e,1!==n.outputs.length)throw new wg("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");if(1!==n.inputs.length)throw new wg("All layers in a Sequential model should have a single input tensor. For multi-input layers, use the functional API.")}if(0===this.outputs.length){if(0===e.inboundNodes.length){if(null==e.batchInputShape)throw new wg("The first layer in a Sequential model must get an `inputShape` or `batchInputShape` argument.");const t=gb({batchShape:e.batchInputShape,dtype:e.dtype,name:e.name+"_input"});e.apply(t)}if(t)this.outputs=n.outputs,this.inputs=n.inputs;else{if(1!==e.inboundNodes.length)throw new wg(`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(1!==e.inboundNodes[0].outputTensors.length)throw new wg("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=fb(this.outputs[0])}this.inboundNodes=[],new pb({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:kg(null,this.inputs.length),outputMasks:[null],inputShapes:this.inputs.map((e=>e.shape)),outputShapes:this.outputs[0].shape})}else{const t=e.apply(this.outputs[0]);if(Array.isArray(t))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=[t],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}this.layers.push(e),this.built=!1}pop(){if(0===this.layers.length)throw new TypeError("There are no layers in the model.");if(this.layers.pop(),0===this.layers.length)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 null==this.model&&this.build(),this.model.call(e,t)}build(e){if(rb(e),0===this.inputs.length||0===this.outputs.length)throw new TypeError("Sequential model cannot be built: model is empty. Add some layers first.");this.model=new av({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,n=console.log){this.built||this.build(),super.summary(e,t,n)}setWeights(e){null==this.model&&this.build(),this.model.setWeights(e)}evaluate(e,t,n={}){if(!this.built)throw new _g("The model needs to be compiled before being used.");return this.model.evaluate(e,t,n)}async evaluateDataset(e,t){if(!this.built)throw new _g("The model needs to be compiled before being used.");return this.model.evaluateDataset(e,t)}predict(e,t={}){return null==this.model&&this.build(),this.model.predict(e,t)}predictOnBatch(e){return null==this.model&&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 null==this.model?void 0:this.model.optimizer}set optimizer(e){this.model.optimizer=e}async fit(e,t,n={}){if(!this.built)throw new _g("The model needs to be compiled before being used.");return this.model.fit(e,t,n)}async fitDataset(e,t){if(!this.built)throw new _g("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,n={},r=!1){let a,i={};if(t instanceof Array){if(null==t[0].className||"Merge"===t[0].className)throw new wg("Legacy serialization format not supported yet.");a=t}else se(null!=t.layers,(()=>"When the config data for a Sequential model is not an Array, it must be an Object that contains the 'layers' field.")),a=t.layers,delete t.layers,i=t;const s=new e(i);if(!(s instanceof ov))throw new Mg(`Sequential.fromConfig called on non-Sequential input: ${s}`);for(const e of a){const t=cx(e,void 0,r);r&&t.setFastWeightInitDuringBuild(!0),s.add(t)}return s}set stopTraining(e){if(null==this.model)throw new wg("Cannot set the stopTraining property of a sequential model before it is compiled.");this.model.stopTraining=e}get stopTraining(){if(null==this.model)throw new wg("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 n={};n.className=t.getClassName(),n.config=t.getConfig(),e.push(n)}return{name:this.name,layers:e}}}function uv(e){return new av(e)}function lv(e){return new ov(e)}function cv(e,t){return null==t&&(t={}),async function(e,t){if(null==t&&(t={}),"string"==typeof e){const n=es(e,t);if(0===n.length)n.push(Gs(e,t));else if(n.length>1)throw new wg(`Found more than one (${n.length}) load handlers for URL '${e}'`);e=n[0]}return async function(e,t,n){if(null==n&&(n={}),null==e.load)throw new wg("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");const r=await e.load();let a=r.modelTopology;null!=a.model_config&&(a=a.model_config);const i=null==n.strict||n.strict,s=null!=r.weightData&&null!=r.weightSpecs&&i,o=cx(Yx(a),void 0,s),u=r.trainingConfig;if(null!=u&&o.loadTrainingConfig(u),null!=r.userDefinedMetadata&&o.setUserDefinedMetadata(r.userDefinedMetadata),null!=r.weightData){if(null==r.weightSpecs)throw new wg("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed.");const{modelWeights:e,optimizerWeights:t}=function(e,t){const n=Bi(e,t),r={},a=[];return t.forEach((e=>{"optimizer"===e.group?a.push({name:e.name,tensor:n[e.name]}):r[e.name]=n[e.name]})),{modelWeights:r,optimizerWeights:a}}(r.weightData,r.weightSpecs);o.loadWeights(e,i),null!=o.optimizer&&t.length>0&&await o.optimizer.setWeights(t),fo(e),fo(t.map((e=>e.tensor)))}return o}(e,0,t)}(e,t)}function pv(e){return gb(e)}function dv(e,t){ux.registerCallbackConstructor(e,t)}ov.className="Sequential",lu(ov);class hv extends ou{getConfig(){return{}}}class fv extends hv{apply(e,t=1){return function(e,t=1){if(1!==t)throw new Mg(`Support for alpha values other than 1 (${t}) is not implemented yet.`);return dc(e)}(e,t)}}fv.className="elu",lu(fv);class mv extends hv{apply(e){return Kp(e)}}mv.className="selu",lu(mv);class gv extends hv{apply(e){return Bp(e)}}gv.className="relu",lu(gv);class yv extends hv{apply(e){return ho((()=>pp(6,Bp(e))))}}yv.className="relu6",lu(yv);class bv extends hv{apply(e){return e}}bv.className="linear",lu(bv);class xv extends hv{apply(e){return Dl(e)}}xv.className="sigmoid",lu(xv);class vv extends hv{apply(e){return function(e){return ho((()=>{const t=wu(.5,Su(.2,e));return Bl(t,0,1)}))}(e)}}vv.className="hardSigmoid",lu(vv);class _v extends hv{apply(e){return Vc(e)}}_v.className="softplus",lu(_v);class wv extends hv{apply(e){return function(e){return ho((()=>Nu(e,wu(Uu(e),1))))}(e)}}wv.className="softsign",lu(wv);class Mv extends hv{apply(e){return Il(e)}}Mv.className="tanh",lu(Mv);class Nv extends hv{apply(e,t=-1){return id(e,t)}}Nv.className="softmax",lu(Nv);class Sv extends hv{apply(e,t=-1){return Kc(e,t)}}Sv.className="logSoftmax",lu(Sv);class kv extends hv{apply(e,t=1){return ho((()=>Su(Dl(Su(e,t)),e)))}}kv.className="swish",lu(kv);class Dv extends hv{apply(e){return ho((()=>Su(e,Il(Vc(e)))))}}function Tv(e){return e.getClassName()}function Iv(e,t={}){return Rg(e,uu.getMap().classNameMap,t,"activation")}function Ev(e){if(null==e){return Iv({className:"linear",config:{}})}if("string"==typeof e){const t={};return t.className=e,t.config={},Iv(t)}return e instanceof hv?e:Iv(e)}function Cv(e){if(null!=e&&"object"!=typeof e)throw new Error(`Argument to L1L2 regularizer's constructor is expected to be an object, but received: ${e}`)}Dv.className="mish",lu(Dv);class Av extends ou{}class Lv extends Av{constructor(e){super(),Cv(e),this.l1=null==e||null==e.l1?.01:e.l1,this.l2=null==e||null==e.l2?.01:e.l2,this.hasL1=0!==this.l1,this.hasL2=0!==this.l2}apply(e){return ho((()=>{let t=up([1]);return this.hasL1&&(t=wu(t,Nc(Su(this.l1,Uu(e))))),this.hasL2&&(t=wu(t,Nc(Su(this.l2,Dy(e))))),Ml(t,[])}))}getConfig(){return{l1:this.l1,l2:this.l2}}static fromConfig(e,t){return new e({l1:t.l1,l2:t.l2})}}Lv.className="L1L2",lu(Lv);const $v={l1l2:"L1L2"};function Ov(e){return $g(e)}function Rv(e,t={}){return Rg(e,uu.getMap().classNameMap,t,"regularizer")}function Fv(e){return null==e?null:"string"==typeof e?Rv({className:e in $v?$v[e]:e,config:{}}):e instanceof Av?e:Rv(e)}class Yv extends hb{constructor(e){super(null==e?{}:e),this.supportsMasking=!0,null!=e&&(this.maxValue=e.maxValue)}call(e,t){e=nb(e);let n=Bp(e);return null!=this.maxValue&&(n=Bl(n,0,this.maxValue)),n}computeOutputShape(e){return e}getConfig(){const e={maxValue:this.maxValue},t=super.getConfig();return Object.assign(e,t),e}}Yv.className="ReLU",lu(Yv);class zv extends hb{constructor(e){super(null==e?{}:e),this.DEFAULT_ALPHA=.3,null==e&&(e={}),this.alpha=null==e.alpha?this.DEFAULT_ALPHA:e.alpha}call(e,t){const n=nb(e);return Bc(n,this.alpha)}computeOutputShape(e){return e}getConfig(){const e={alpha:this.alpha},t=super.getConfig();return Object.assign(e,t),e}}zv.className="LeakyReLU",lu(zv);class Bv extends hb{constructor(e){if(super(null==e?{}:e),this.DEFAULT_ALPHA_INITIALIZER="zeros",null==e&&(e={}),this.supportsMasking=!0,this.alphaInitializer=Qy(e.alphaInitializer||this.DEFAULT_ALPHA_INITIALIZER),this.alphaRegularizer=Fv(e.alphaRegularizer),this.alphaConstraint=Lb(e.alphaConstraint),null==e.sharedAxes)this.sharedAxes=null;else if(Array.isArray(e.sharedAxes))this.sharedAxes=e.sharedAxes;else{if("number"!=typeof e.sharedAxes)throw new wg(`Expected sharedAxes to be a number or an array of numbers, but got ${e.sharedAxes}`);this.sharedAxes=[e.sharedAxes]}}build(e){const t=(e=rb(e)).slice(1);if(null!=this.sharedAxes)for(const e of this.sharedAxes)t[e-1]=1;this.alpha=this.addWeight("alpha",t,"float32",this.alphaInitializer,this.alphaRegularizer,!0,this.alphaConstraint);const n={};if(null!=this.sharedAxes)for(let t=1;t(ty(t),"channelsFirst"===t?Io(e,[0,2,3,1]):e)))}function Gv(e,t){return ho((()=>(ty(t),"channelsFirst"===t?Io(e,[0,2,3,4,1]):e)))}function Kv(e,t,n,r=[1,1],a="valid",i,s,o=null){return ho((()=>{if(null==i&&(i="channelsLast"),ty(i),3!==e.rank&&4!==e.rank)throw new wg(`conv2dWithBiasActivation expects input to be of rank 3 or 4, but received ${e.rank}.`);if(3!==t.rank&&4!==t.rank)throw new wg(`conv2dWithBiasActivation expects kernel to be of rank 3 or 4, but received ${e.rank}.`);let u=Vv(e,i);if("causal"===a)throw new Mg("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");return u=qd({x:u,filter:t,strides:r,pad:"same"===a?"same":"valid",dilations:s,dataFormat:"NHWC",bias:n,activation:o}),"channelsFirst"===i&&(u=Io(u,[0,3,1,2])),u}))}jv.className="Softmax",lu(jv);class Jv extends hb{constructor(e,t){if(super(t),this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",Jv.verifyArgs(t),this.rank=e,Hg(this.rank,"rank"),1!==this.rank&&2!==this.rank&&3!==this.rank)throw new Mg(`Convolution layer for rank other than 1, 2, or 3 (${this.rank}) is not implemented yet.`);if(this.kernelSize=Uv(t.kernelSize,e,"kernelSize"),this.strides=Uv(null==t.strides?1:t.strides,e,"strides"),this.padding=null==t.padding?"valid":t.padding,ny(this.padding),this.dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,ty(this.dataFormat),this.activation=Ev(t.activation),this.useBias=null==t.useBias||t.useBias,this.biasInitializer=Qy(t.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.biasConstraint=Lb(t.biasConstraint),this.biasRegularizer=Fv(t.biasRegularizer),this.activityRegularizer=Fv(t.activityRegularizer),this.dilationRate=Uv(null==t.dilationRate?1:t.dilationRate,e,"dilationRate"),1===this.rank&&Array.isArray(this.dilationRate)&&1!==this.dilationRate.length)throw new wg(`dilationRate must be a number or an array of a single number for 1D convolution, but received ${JSON.stringify(this.dilationRate)}`);if(2===this.rank){if("number"==typeof this.dilationRate)this.dilationRate=[this.dilationRate,this.dilationRate];else if(2!==this.dilationRate.length)throw new wg(`dilationRate must be a number or array of two numbers for 2D convolution, but received ${JSON.stringify(this.dilationRate)}`)}else if(3===this.rank)if("number"==typeof this.dilationRate)this.dilationRate=[this.dilationRate,this.dilationRate,this.dilationRate];else if(3!==this.dilationRate.length)throw new wg(`dilationRate must be a number or array of three numbers for 3D convolution, but received ${JSON.stringify(this.dilationRate)}`)}static verifyArgs(e){if(Dg("kernelSize"in e,"required key 'kernelSize' not in config"),"number"!=typeof e.kernelSize&&!Pg(e.kernelSize,"number",1,3))throw new wg(`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:Tv(this.activation),useBias:this.useBias,biasInitializer:Zy(this.biasInitializer),biasRegularizer:Ov(this.biasRegularizer),activityRegularizer:Ov(this.activityRegularizer),biasConstraint:Cb(this.biasConstraint)},t=super.getConfig();return Object.assign(e,t),e}}class Xv extends Jv{constructor(e,t){super(e,t),this.kernel=null,Xv.verifyArgs(t),this.filters=t.filters,Hg(this.filters,"filters"),this.kernelInitializer=Qy(t.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.kernelConstraint=Lb(t.kernelConstraint),this.kernelRegularizer=Fv(t.kernelRegularizer)}build(e){e=rb(e);const t="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[t])throw new wg(`The channel dimension of the input should be defined. Found ${e[t]}`);const n=e[t],r=this.kernelSize.concat([n,this.filters]);this.kernel=this.addWeight("kernel",r,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]:n}}],this.built=!0}call(e,t){return ho((()=>{let t;e=nb(e);const n=null==this.bias?null:this.bias.read(),r=Ug(this.activation.getClassName());if(null!=r&&2===this.rank)t=Kv(e,this.kernel.read(),n,this.strides,this.padding,this.dataFormat,this.dilationRate,r);else{if(1===this.rank)t=function(e,t,n,r=1,a="valid",i,s=1){return ho((()=>{if(null==i&&(i="channelsLast"),ty(i),3!==e.shape.length)throw new wg(`The input of a conv1dWithBias operation should be 3, but is ${e.shape.length} instead.`);if(3!==t.shape.length)throw new wg(`The kernel for a conv1dWithBias operation should be 3, but is ${t.shape.length} instead`);if(null!=n&&1!==n.shape.length)throw new wg(`The bias for a conv1dWithBias operation should be 1, but is ${t.shape.length} instead`);if("channelsFirst"===i&&(e=Io(e,[0,2,1])),"causal"===a)throw new Mg("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");let o=Wl(e,t,r,"same"===a?"same":"valid","NWC",s);return null!=n&&(o=Iy(o,n)),o}))}(e,this.kernel.read(),n,this.strides[0],this.padding,this.dataFormat,this.dilationRate[0]);else if(2===this.rank)t=Kv(e,this.kernel.read(),n,this.strides,this.padding,this.dataFormat,this.dilationRate);else{if(3!==this.rank)throw new Mg("convolutions greater than 3D are not implemented yet.");t=function(e,t,n,r=[1,1,1],a="valid",i,s){return ho((()=>{if(null==i&&(i="channelsLast"),ty(i),4!==e.rank&&5!==e.rank)throw new wg(`conv3dWithBias expects input to be of rank 4 or 5, but received ${e.rank}.`);if(4!==t.rank&&5!==t.rank)throw new wg(`conv3dWithBias expects kernel to be of rank 4 or 5, but received ${e.rank}.`);let o=Gv(e,i);if("causal"===a)throw new Mg("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");return o=Kl(o,t,r,"same"===a?"same":"valid","NDHWC",s),null!=n&&(o=Iy(o,n)),"channelsFirst"===i&&(o=Io(o,[0,4,1,2,3])),o}))}(e,this.kernel.read(),n,this.strides,this.padding,this.dataFormat,this.dilationRate)}null!=this.activation&&(t=this.activation.apply(t))}return t}))}computeOutputShape(e){e=rb(e);const t=[],n="channelsLast"===this.dataFormat?e.slice(1,e.length-1):e.slice(2);for(let e=0;e 0 but got ${JSON.stringify(e.filters)}`)}}class Zv extends Xv{constructor(e){super(2,e),Zv.verifyArgs(e)}getConfig(){const e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if("number"!=typeof e.kernelSize&&!Pg(e.kernelSize,"number",1,2))throw new wg(`Conv2D expects config.kernelSize to be number or number[] with length 1 or 2, but received ${JSON.stringify(e.kernelSize)}.`)}}Zv.className="Conv2D",lu(Zv);class Qv extends Xv{constructor(e){super(3,e),Qv.verifyArgs(e)}getConfig(){const e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if("number"!=typeof e.kernelSize&&(!Array.isArray(e.kernelSize)||1!==e.kernelSize.length&&3!==e.kernelSize.length))throw new wg(`Conv3D expects config.kernelSize to be number or [number, number, number], but received ${JSON.stringify(e.kernelSize)}.`)}}Qv.className="Conv3D",lu(Qv);class e_ extends Zv{constructor(e){if(super(e),this.inputSpec=[new ub({ndim:4})],"same"!==this.padding&&"valid"!==this.padding)throw new wg(`Conv2DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(4!==(e=rb(e)).length)throw new wg("Input should have rank 4; Received input shape: "+JSON.stringify(e));const t="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[t])throw new wg("The channel dimension of the inputs should be defined. Found `None`.");const n=e[t],r=this.kernelSize.concat([this.filters,n]);this.kernel=this.addWeight("kernel",r,"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 ub({ndim:4,axes:{[t]:n}})],this.built=!0}call(e,t){return ho((()=>{let t=nb(e);if(4!==t.shape.length)throw new wg(`Conv2DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${t.shape.length}`);const n=t.shape,r=n[0];let a,i;"channelsFirst"===this.dataFormat?(a=2,i=3):(a=1,i=2);const s=n[a],o=n[i],u=this.kernelSize[0],l=this.kernelSize[1],c=this.strides[0],p=this.strides[1],d=[r,Wv(s,c,u,this.padding),Wv(o,p,l,this.padding),this.filters];"channelsLast"!==this.dataFormat&&(t=Io(t,[0,2,3,1]));let h=Gl(t,this.kernel.read(),d,this.strides,this.padding);return"channelsLast"!==this.dataFormat&&(h=Io(h,[0,3,1,2])),null!=this.bias&&(h=Iy(h,this.bias.read(),this.dataFormat)),null!=this.activation&&(h=this.activation.apply(h)),h}))}computeOutputShape(e){const t=(e=rb(e)).slice();let n,r,a;"channelsFirst"===this.dataFormat?(n=1,r=2,a=3):(n=3,r=1,a=2);const i=this.kernelSize[0],s=this.kernelSize[1],o=this.strides[0],u=this.strides[1];return t[n]=this.filters,t[r]=Wv(t[r],o,i,this.padding),t[a]=Wv(t[a],u,s,this.padding),t}getConfig(){const e=super.getConfig();return delete e.dilationRate,e}}e_.className="Conv2DTranspose",lu(e_);class t_ extends Qv{constructor(e){if(super(e),this.inputSpec=[new ub({ndim:5})],"same"!==this.padding&&"valid"!==this.padding)throw new wg(`Conv3DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(5!==(e=rb(e)).length)throw new wg("Input should have rank 5; Received input shape: "+JSON.stringify(e));const t="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[t])throw new wg("The channel dimension of the inputs should be defined. Found `None`.");const n=e[t],r=this.kernelSize.concat([this.filters,n]);this.kernel=this.addWeight("kernel",r,"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 ub({ndim:5,axes:{[t]:n}})],this.built=!0}call(e,t){return ho((()=>{let t=nb(e);if(5!==t.shape.length)throw new wg(`Conv3DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${t.shape.length}`);const n=t.shape,r=n[0];let a,i,s;"channelsFirst"===this.dataFormat?(s=2,a=3,i=4):(s=1,a=2,i=3);const o=n[s],u=n[a],l=n[i],c=this.kernelSize[0],p=this.kernelSize[1],d=this.kernelSize[2],h=this.strides[0],f=this.strides[1],m=this.strides[2],g=[r,Wv(o,h,c,this.padding),Wv(u,f,p,this.padding),Wv(l,m,d,this.padding),this.filters];"channelsLast"!==this.dataFormat&&(t=Io(t,[0,2,3,4,1]));let y=Xl(t,this.kernel.read(),g,this.strides,this.padding);return"channelsLast"!==this.dataFormat&&(y=Io(y,[0,4,1,2,3])),null!==this.bias&&(y=Iy(y,this.bias.read(),this.dataFormat)),null!==this.activation&&(y=this.activation.apply(y)),y}))}computeOutputShape(e){const t=(e=rb(e)).slice();let n,r,a,i;"channelsFirst"===this.dataFormat?(n=1,r=2,a=3,i=4):(n=4,r=1,a=2,i=3);const s=this.kernelSize[0],o=this.kernelSize[1],u=this.kernelSize[2],l=this.strides[0],c=this.strides[1],p=this.strides[2];return t[n]=this.filters,t[r]=Wv(t[r],l,s,this.padding),t[a]=Wv(t[a],c,o,this.padding),t[i]=Wv(t[i],p,u,this.padding),t}getConfig(){const e=super.getConfig();return delete e.dilationRate,e}}t_.className="Conv3DTranspose",lu(t_);class n_ extends Xv{constructor(e,t){if(super(e,t),this.DEFAULT_DEPTHWISE_INITIALIZER="glorotUniform",this.DEFAULT_POINTWISE_INITIALIZER="glorotUniform",this.depthwiseKernel=null,this.pointwiseKernel=null,null==t.filters)throw new wg("The `filters` configuration field is required by SeparableConv, but is unspecified.");if(null!=t.kernelInitializer||null!=t.kernelRegularizer||null!=t.kernelConstraint)throw new wg("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead.");if(null!=t.padding&&"same"!==t.padding&&"valid"!==t.padding)throw new wg(`SeparableConv${this.rank}D supports only padding modes: 'same' and 'valid', but received ${JSON.stringify(t.padding)}`);this.depthMultiplier=null==t.depthMultiplier?1:t.depthMultiplier,this.depthwiseInitializer=Qy(t.depthwiseInitializer||this.DEFAULT_DEPTHWISE_INITIALIZER),this.depthwiseRegularizer=Fv(t.depthwiseRegularizer),this.depthwiseConstraint=Lb(t.depthwiseConstraint),this.pointwiseInitializer=Qy(t.depthwiseInitializer||this.DEFAULT_POINTWISE_INITIALIZER),this.pointwiseRegularizer=Fv(t.pointwiseRegularizer),this.pointwiseConstraint=Lb(t.pointwiseConstraint)}build(e){if((e=rb(e)).length{let t;if(e=nb(e),1===this.rank)throw new Mg("1D separable convolution is not implemented yet.");return 2===this.rank&&("channelsFirst"===this.dataFormat&&(e=Io(e,[0,2,3,1])),t=Jp(e,this.depthwiseKernel.read(),this.pointwiseKernel.read(),this.strides,this.padding,this.dilationRate,"NHWC")),this.useBias&&(t=Iy(t,this.bias.read(),this.dataFormat)),null!=this.activation&&(t=this.activation.apply(t)),"channelsFirst"===this.dataFormat&&(t=Io(t,[0,3,1,2])),t}))}getConfig(){const e=super.getConfig();return delete e.rank,delete e.kernelInitializer,delete e.kernelRegularizer,delete e.kernelConstraint,e.depthwiseInitializer=Zy(this.depthwiseInitializer),e.pointwiseInitializer=Zy(this.pointwiseInitializer),e.depthwiseRegularizer=Ov(this.depthwiseRegularizer),e.pointwiseRegularizer=Ov(this.pointwiseRegularizer),e.depthwiseConstraint=Cb(this.depthwiseConstraint),e.pointwiseConstraint=Cb(this.pointwiseConstraint),e}}n_.className="SeparableConv";class r_ extends n_{constructor(e){super(2,e)}}r_.className="SeparableConv2D",lu(r_);class a_ extends Xv{constructor(e){super(1,e),a_.verifyArgs(e),this.inputSpec=[{ndim:3}]}getConfig(){const e=super.getConfig();return delete e.rank,delete e.dataFormat,e}static verifyArgs(e){if("number"!=typeof e.kernelSize&&!Pg(e.kernelSize,"number",1,1))throw new wg(`Conv1D expects config.kernelSize to be number or number[] with length 1, but received ${JSON.stringify(e.kernelSize)}.`)}}a_.className="Conv1D",lu(a_);class i_ extends hb{constructor(e){super(e),"number"==typeof e.cropping?this.cropping=[[e.cropping,e.cropping],[e.cropping,e.cropping]]:"number"==typeof e.cropping[0]?this.cropping=[[e.cropping[0],e.cropping[0]],[e.cropping[1],e.cropping[1]]]:this.cropping=e.cropping,this.dataFormat=void 0===e.dataFormat?"channelsLast":e.dataFormat,this.inputSpec=[{ndim:4}]}computeOutputShape(e){return"channelsFirst"===this.dataFormat?[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 ho((()=>{if(e=nb(e),"channelsLast"===this.dataFormat){const t=vy(e,this.cropping[0][0],e.shape[1]-this.cropping[0][0]-this.cropping[0][1],2);return vy(t,this.cropping[1][0],e.shape[2]-this.cropping[1][1]-this.cropping[1][0],3)}{const t=vy(e,this.cropping[0][0],e.shape[2]-this.cropping[0][0]-this.cropping[0][1],3);return vy(t,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}}i_.className="Cropping2D",lu(i_);class s_ extends hb{constructor(e){var t;super(e),this.DEFAULT_SIZE=[2,2],this.inputSpec=[{ndim:4}],this.size=null==e.size?this.DEFAULT_SIZE:e.size,this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,ty(this.dataFormat),this.interpolation=null==e.interpolation?"nearest":e.interpolation,t=this.interpolation,Bg(Jg,"InterpolationFormat",t)}computeOutputShape(e){if("channelsFirst"===this.dataFormat){const t=null==e[2]?null:this.size[0]*e[2],n=null==e[3]?null:this.size[1]*e[3];return[e[0],e[1],t,n]}{const t=null==e[1]?null:this.size[0]*e[1],n=null==e[2]?null:this.size[1]*e[2];return[e[0],t,n,e[3]]}}call(e,t){return ho((()=>{let t=nb(e);const n=t.shape;if("channelsFirst"===this.dataFormat){t=Io(t,[0,2,3,1]);const e=this.size[0]*n[2],r=this.size[1]*n[3],a="nearest"===this.interpolation?Uh.resizeNearestNeighbor(t,[e,r]):Uh.resizeBilinear(t,[e,r]);return Io(a,[0,3,1,2])}{const e=this.size[0]*n[1],r=this.size[1]*n[2];return"nearest"===this.interpolation?Uh.resizeNearestNeighbor(t,[e,r]):Uh.resizeBilinear(t,[e,r])}}))}getConfig(){const e={size:this.size,dataFormat:this.dataFormat,interpolation:this.interpolation},t=super.getConfig();return Object.assign(e,t),e}}s_.className="UpSampling2D",lu(s_);class o_ extends Jv{constructor(e){super(2,e),this.depthwiseKernel=null,this.depthMultiplier=null==e.depthMultiplier?1:e.depthMultiplier,this.depthwiseInitializer=Qy(e.depthwiseInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.depthwiseConstraint=Lb(e.depthwiseConstraint),this.depthwiseRegularizer=Fv(e.depthwiseRegularizer)}build(e){if((e=rb(e)).length<4)throw new wg(`Inputs to DepthwiseConv2D should have rank 4. Received input shape: ${JSON.stringify(e)}.`);const t="channelsFirst"===this.dataFormat?1:3;if(null==e[t]||e[t]<0)throw new wg(`The channel dimension of the inputs to DepthwiseConv2D should be defined, but is not (${e[t]}).`);const n=e[t],r=[this.kernelSize[0],this.kernelSize[1],n,this.depthMultiplier];this.depthwiseKernel=this.addWeight("depthwise_kernel",r,null,this.depthwiseInitializer,this.depthwiseRegularizer,!0,this.depthwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[n*this.depthMultiplier],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return ho((()=>{let t=function(e,t,n=[1,1],r="valid",a,i){return ho((()=>{null==a&&(a="channelsLast"),ty(a);let s=Vv(e,a);if(4!==e.rank)throw new wg(`Input for depthwiseConv2d is required to be 4-D, but is instead ${e.rank}-D`);if(4!==t.rank)throw new wg(`depthwiseKernel is required to be 4-D, but is instead ${t.rank}-D`);return s=ac(s,t,n,"same"===r?"same":"valid","NHWC",i),"channelsFirst"===a&&(s=Io(s,[0,3,1,2])),s}))}(e=nb(e),this.depthwiseKernel.read(),this.strides,this.padding,this.dataFormat,null);return this.useBias&&(t=Iy(t,this.bias.read(),this.dataFormat)),null!=this.activation&&(t=this.activation.apply(t)),t}))}computeOutputShape(e){e=rb(e);const t="channelsFirst"===this.dataFormat?e[2]:e[1],n="channelsFirst"===this.dataFormat?e[3]:e[2],r="channelsFirst"===this.dataFormat?e[1]*this.depthMultiplier:e[3]*this.depthMultiplier,a=qv(t,this.kernelSize[0],this.padding,this.strides[0]),i=qv(n,this.kernelSize[1],this.padding,this.strides[1]);return"channelsFirst"===this.dataFormat?[e[0],r,a,i]:[e[0],a,i,r]}getConfig(){const e=super.getConfig();return e.depthMultiplier=this.depthMultiplier,e.depthwiseInitializer=Zy(this.depthwiseInitializer),e.depthwiseRegularizer=Ov(this.depthwiseRegularizer),e.depthwiseConstraint=Cb(this.depthwiseRegularizer),e}}function u_(e,t,n,r){if(Array.isArray(e)){if(null!=t||null!=n)throw new wg("When inputs is an array, neither initialState or constants should be provided");null!=r&&(n=e.slice(e.length-r,e.length),e=e.slice(0,e.length-r)),e.length>1&&(t=e.slice(1,e.length)),e=e[0]}function a(e){return null==e||Array.isArray(e)?e:[e]}return{inputs:e,initialState:t=a(t),constants:n=a(n)}}function l_(e,t,n,r=!1,a,i,s=!1,o=!1){return ho((()=>{const u=t.shape.length;if(u<3)throw new wg(`Input should be at least 3D, but is ${u}D.`);const l=[1,0].concat(hy(2,u));if(t=Io(t,l),null!=i)throw new Mg("The rnn() functoin of the deeplearn.js backend does not support constants yet.");s&&console.warn("Backend rnn(): the unroll = true option is not applicable to the imperative deeplearn.js backend."),null!=a&&((a=Ls(Ls(a,"bool"),"float32")).rank===u-1&&(a=Ic(a,-1)),a=Io(a,l)),r&&(t=Hp(t,0),null!=a&&(a=Hp(a,0)));const c=[];let p,d=n;const h=t.shape[0],f=kd(t);let m,g;null!=a&&(m=kd(a));for(let t=0;te(n,d)));if(null==a)p=r[0],d=r[1];else{const e=ho((()=>{const e=m[t],n=Hu(bp(e),e),a=wu(Su(r[0],e),Su(d[0],n)),i=d.map(((t,a)=>wu(Su(r[1][a],e),Su(t,n))));return{output:a,newStates:i}}));p=e.output,d=e.newStates}o&&c.push(p)}return o&&(g=hd(c,1)),[p,g,d]}))}o_.className="DepthwiseConv2D",lu(o_);class c_ extends hb{constructor(e){let t;if(super(e),null==e.cell)throw new wg("cell property is missing for the constructor of RNN.");if(t=Array.isArray(e.cell)?new b_({cells:e.cell}):e.cell,null==t.stateSize)throw new wg("The RNN cell should have an attribute `stateSize` (tuple of integers, one integer per RNN state).");this.cell=t,this.returnSequences=null!=e.returnSequences&&e.returnSequences,this.returnState=null!=e.returnState&&e.returnState,this.goBackwards=null!=e.goBackwards&&e.goBackwards,this._stateful=null!=e.stateful&&e.stateful,this.unroll=null!=e.unroll&&e.unroll,this.supportsMasking=!0,this.inputSpec=[new ub({ndim:3})],this.stateSpec=null,this.states_=null,this.numConstants=null,this.keptStates=[]}getStates(){return null==this.states_?hy(0,Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1).map((e=>null)):this.states_}setStates(e){this.states_=e}computeOutputShape(e){eb(e)&&(e=e[0]);let t=this.cell.stateSize;Array.isArray(t)||(t=[t]);const n=t[0];let r;if(r=this.returnSequences?[e[0],e[1],n]:[e[0],n],this.returnState){const n=[];for(const r of t)n.push([e[0],r]);return[r].concat(n)}return r}computeMask(e,t){return ho((()=>{Array.isArray(t)&&(t=t[0]);const e=this.returnSequences?t:null;if(this.returnState){const t=this.states.map((e=>null));return[e].concat(t)}return e}))}get states(){if(null==this.states_){const e=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1,t=[];for(let n=0;ne.shape[e.shape.length-1])),a))throw new wg(`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=a.map((e=>new ub({shape:[null,e]})));this.stateful&&this.resetStates()}resetStates(e,t=!1){ho((()=>{if(!this.stateful)throw new vg("Cannot call resetStates() on an RNN Layer that is not stateful.");const n=this.inputSpec[0].shape[0];if(null==n)throw new wg("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(null==this.states_)Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((e=>up([n,e]))):this.states_=[up([n,this.cell.stateSize])];else if(null==e)fo(this.states_),null!=this.keptStates&&(fo(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((e=>up([n,e]))):this.states_[0]=up([n,this.cell.stateSize]);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new wg(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`);!0===t?this.keptStates.push(this.states_.slice()):fo(this.states_);for(let t=0;tmo(e.clone())))}))}apply(e,t){let n=null==t?null:t.initialState,r=null==t?null:t.constants;null==t&&(t={});const a=u_(e,n,r,this.numConstants);e=a.inputs,n=a.initialState,r=a.constants;let i=[],s=[];if(null!=n){t.initialState=n,i=i.concat(n),this.stateSpec=[];for(const e of n)this.stateSpec.push(new ub({shape:e.shape}));s=s.concat(this.stateSpec)}if(null!=r&&(t.constants=r,i=i.concat(r),this.numConstants=r.length),i[0]instanceof lb){const n=[e].concat(i),r=this.inputSpec.concat(s),a=this.inputSpec;this.inputSpec=r;const o=super.apply(n,t);return this.inputSpec=a,o}return super.apply(e,t)}call(e,t){return ho((()=>{const n=null==t?null:t.mask,r=null==t?null:t.training;let a=null==t?null:t.initialState;e=nb(e),null==a&&(a=this.stateful?this.states_:this.getInitialState(e));const i=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1;if(a.length!==i)throw new wg(`RNN Layer has ${i} state(s) but was passed ${a.length} initial state(s).`);this.unroll&&console.warn("Ignoring unroll = true for RNN layer, due to imperative backend.");const s={training:r},o=l_(((e,t)=>{const n=this.cell.call([e].concat(t),s);return[n[0],n.slice(1)]}),e,a,this.goBackwards,n,null,this.unroll,this.returnSequences),u=o[0],l=o[1],c=o[2];this.stateful&&this.resetStates(c,r);const p=this.returnSequences?l:u;return this.returnState?[p].concat(c):p}))}getInitialState(e){return ho((()=>{let t=up(e.shape);return t=Nc(t,[1,2]),t=yy(t),Array.isArray(this.cell.stateSize)?this.cell.stateSize.map((e=>e>1?My(t,[1,e]):t)):this.cell.stateSize>1?[My(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),null!=this.cell&&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};null!=this.numConstants&&(t.numConstants=this.numConstants);const n=this.cell.getConfig();return this.getClassName()===c_.className&&(t.cell={className:this.cell.getClassName(),config:n}),Object.assign({},n,e,t)}static fromConfig(e,t,n={}){const r=cx(t.cell,n);return new e(Object.assign(t,{cell:r}))}}c_.className="RNN",lu(c_);class p_ extends hb{}class d_ extends p_{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,Hg(this.units,"units"),this.activation=Ev(null==e.activation?this.DEFAULT_ACTIVATION:e.activation),this.useBias=null==e.useBias||e.useBias,this.kernelInitializer=Qy(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=Qy(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=Qy(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=Fv(e.kernelRegularizer),this.recurrentRegularizer=Fv(e.recurrentRegularizer),this.biasRegularizer=Fv(e.biasRegularizer),this.kernelConstraint=Lb(e.kernelConstraint),this.recurrentConstraint=Lb(e.recurrentConstraint),this.biasConstraint=Lb(e.biasConstraint),this.dropout=py([1,dy([0,null==e.dropout?0:e.dropout])]),this.recurrentDropout=py([1,dy([0,null==e.recurrentDropout?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){e=rb(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 ho((()=>{if(2!==e.length)throw new wg(`SimpleRNNCell expects 2 input Tensors, got ${e.length}.`);let n=e[1];e=e[0];const r=null!=t.training&&t.training;let a;0bp(e),rate:this.dropout,training:r,dropoutFunc:this.dropoutFunc})),0bp(n),rate:this.recurrentDropout,training:r,dropoutFunc:this.dropoutFunc}));const i=this.dropoutMask,s=this.recurrentDropoutMask;a=Sy(null!=i?Su(e,i):e,this.kernel.read()),null!=this.bias&&(a=Iy(a,this.bias.read())),null!=s&&(n=Su(n,s));let o=wu(a,Sy(n,this.recurrentKernel.read()));return null!=this.activation&&(o=this.activation.apply(o)),[o,o]}))}getConfig(){const e=super.getConfig(),t={units:this.units,activation:Tv(this.activation),useBias:this.useBias,kernelInitializer:Zy(this.kernelInitializer),recurrentInitializer:Zy(this.recurrentInitializer),biasInitializer:Zy(this.biasInitializer),kernelRegularizer:Ov(this.kernelRegularizer),recurrentRegularizer:Ov(this.recurrentRegularizer),biasRegularizer:Ov(this.biasRegularizer),activityRegularizer:Ov(this.activityRegularizer),kernelConstraint:Cb(this.kernelConstraint),recurrentConstraint:Cb(this.recurrentConstraint),biasConstraint:Cb(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout};return Object.assign({},e,t)}}d_.className="SimpleRNNCell",lu(d_);class h_ extends c_{constructor(e){e.cell=new d_(e),super(e)}call(e,t){return ho((()=>{null!=this.cell.dropoutMask&&(fo(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(fo(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const n=null==t?null:t.mask,r=null==t?null:t.training,a=null==t?null:t.initialState;return super.call(e,{mask:n,training:r,initialState:a})}))}static fromConfig(e,t){return new e(t)}}h_.className="SimpleRNN",lu(h_);class f_ extends p_{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 wg("GRUCell does not support reset_after parameter set to true.");this.units=e.units,Hg(this.units,"units"),this.activation=Ev(void 0===e.activation?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=Ev(void 0===e.recurrentActivation?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=null==e.useBias||e.useBias,this.kernelInitializer=Qy(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=Qy(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=Qy(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=Fv(e.kernelRegularizer),this.recurrentRegularizer=Fv(e.recurrentRegularizer),this.biasRegularizer=Fv(e.biasRegularizer),this.kernelConstraint=Lb(e.kernelConstraint),this.recurrentConstraint=Lb(e.recurrentConstraint),this.biasConstraint=Lb(e.biasConstraint),this.dropout=py([1,dy([0,null==e.dropout?0:e.dropout])]),this.recurrentDropout=py([1,dy([0,null==e.recurrentDropout?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.implementation=e.implementation,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){const t=(e=rb(e))[e.length-1];this.kernel=this.addWeight("kernel",[t,3*this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,3*this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[3*this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return ho((()=>{if(2!==e.length)throw new wg(`GRUCell expects 2 input Tensors (inputs, h, c), got ${e.length}.`);const n=null!=t.training&&t.training;let r=e[1];e=e[0],0bp(e),rate:this.dropout,training:n,count:3,dropoutFunc:this.dropoutFunc})),0bp(r),rate:this.recurrentDropout,training:n,count:3,dropoutFunc:this.dropoutFunc}));const a=this.dropoutMask,i=this.recurrentDropoutMask;let s,o,u;0{null!=this.cell.dropoutMask&&(fo(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(fo(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const n=null==t?null:t.mask,r=null==t?null:t.training,a=null==t?null:t.initialState;return super.call(e,{mask:n,training:r,initialState:a})}))}static fromConfig(e,t){return 0===t.implmentation&&(t.implementation=1),new e(t)}}m_.className="GRU",lu(m_);class g_ extends p_{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,Hg(this.units,"units"),this.activation=Ev(void 0===e.activation?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=Ev(void 0===e.recurrentActivation?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=null==e.useBias||e.useBias,this.kernelInitializer=Qy(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=Qy(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=Qy(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.unitForgetBias=e.unitForgetBias,this.kernelRegularizer=Fv(e.kernelRegularizer),this.recurrentRegularizer=Fv(e.recurrentRegularizer),this.biasRegularizer=Fv(e.biasRegularizer),this.kernelConstraint=Lb(e.kernelConstraint),this.recurrentConstraint=Lb(e.recurrentConstraint),this.biasConstraint=Lb(e.biasConstraint),this.dropout=py([1,dy([0,null==e.dropout?0:e.dropout])]),this.recurrentDropout=py([1,dy([0,null==e.recurrentDropout?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;const n=(e=rb(e))[e.length-1];let r;if(this.kernel=this.addWeight("kernel",[n,4*this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,4*this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){if(this.unitForgetBias){const e=this.biasInitializer,n=this.units;r=new((t=class extends $y{apply(t,r){const a=e.apply([n]),i=(new Ry).apply([n]),s=e.apply([2*n]);return wy(wy(a,i),s)}}).className="CustomInit",t)}else r=this.biasInitializer;this.bias=this.addWeight("bias",[4*this.units],null,r,this.biasRegularizer,!0,this.biasConstraint)}else this.bias=null;this.built=!0}call(e,t){return ho((()=>{const n=null!=t.training&&t.training;if(3!==e.length)throw new wg(`LSTMCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);let r=e[1];const a=e[2];e=e[0],0bp(e),rate:this.dropout,training:n,count:4,dropoutFunc:this.dropoutFunc})),0bp(r),rate:this.recurrentDropout,training:n,count:4,dropoutFunc:this.dropoutFunc}));const i=this.dropoutMask,s=this.recurrentDropoutMask;let o,u,l,c;0{null!=this.cell.dropoutMask&&(fo(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(fo(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const n=null==t?null:t.mask,r=null==t?null:t.training,a=null==t?null:t.initialState;return super.call(e,{mask:n,training:r,initialState:a})}))}static fromConfig(e,t){return 0===t.implmentation&&(t.implementation=1),new e(t)}}y_.className="LSTM",lu(y_);class b_ extends p_{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 ho((()=>{let n=e.slice(1);const r=[];for(const e of this.cells.slice().reverse())Array.isArray(e.stateSize)?r.push(n.splice(0,e.stateSize.length)):r.push(n.splice(0,1));r.reverse();const a=[];let i;for(let s=0;s{iy(`RNNCell_${r}`,(()=>{n.build(e),t=Array.isArray(n.stateSize)?n.stateSize[0]:n.stateSize,e=[e[0],t]}))})),this.built=!0}getConfig(){const e=super.getConfig(),t={cells:this.cells.map((e=>({className:e.getClassName(),config:e.getConfig()})))};return Object.assign({},e,t)}static fromConfig(e,t,n={}){const r=[];for(const e of t.cells)r.push(cx(e,n));return new e({cells:r})}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 e of this.cells)t.push(...e.trainableWeights);return t.concat(e)}return e}getWeights(){const e=[];for(const t of this.cells)e.push(...t.weights);return sb(e)}setWeights(e){const t=[];for(const n of this.cells){const r=n.weights.length,a=e.splice(r);for(let e=0;enull!=i?i(t(),n):Ey(t(),n),o=()=>Cy(s,t,r);return!a||a<=1?mo(o().clone()):Array(a).fill(void 0).map(o).map((e=>mo(e.clone())))}b_.className="StackedRNNCells",lu(b_);class v_ extends c_{constructor(e){if(e.unroll)throw new Mg("Unrolling is not possible with convolutional RNNs.");if(Array.isArray(e.cell))throw new Mg("It is not possible at the moment to stack convolutional cells.");super(e),this.inputSpec=[new ub({ndim:5})]}call(e,t){return ho((()=>{if(null!=this.cell.dropoutMask&&(fo(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(fo(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null),t&&t.constants)throw new wg("ConvRNN2D cell does not support constants");const n=null==t?null:t.mask,r=null==t?null:t.training,a=null==t?null:t.initialState;return super.call(e,{mask:n,training:r,initialState:a})}))}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 ho((()=>{const{stateSize:t}=this.cell,n=e.shape,r=this.computeSingleOutputShape(n),a=up([r[0],...r.slice(2)]);return Array.isArray(t)?Array(t.length).fill(a):[a]}))}resetStates(e,t=!1){ho((()=>{if(!this.stateful)throw new vg("Cannot call resetStates() on an RNN Layer that is not stateful.");const n=this.inputSpec[0].shape,r=this.computeSingleOutputShape(n),a=[r[0],...r.slice(2)];if(null==n[0])throw new wg("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(null==this.getStates())Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((()=>up(a))):this.states_=[up(a)];else if(null==e)fo(this.states_),null!=this.keptStates&&(fo(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((()=>up(a))):this.states_[0]=up(a);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new wg(`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()):fo(this.states_);for(let t=0;tmo(e.clone())))}))}computeSingleOutputShape(e){const{dataFormat:t,filters:n,kernelSize:r,padding:a,strides:i,dilationRate:s}=this.cell,o="channelsFirst"===t,u=e[o?3:2],l=e[o?4:3],c=qv(u,r[0],a,i[0],s[0]),p=qv(l,r[1],a,i[1],s[1]);return[...e.slice(0,2),...o?[n,c,p]:[c,p,n]]}}v_.className="ConvRNN2D";class __ extends g_{constructor(e){const{filters:t,kernelSize:n,strides:r,padding:a,dataFormat:i,dilationRate:s}=e;super(Object.assign({},e,{units:t})),this.filters=t,Hg(this.filters,"filters"),this.kernelSize=Uv(n,2,"kernelSize"),this.kernelSize.forEach((e=>Hg(e,"kernelSize"))),this.strides=Uv(r||1,2,"strides"),this.strides.forEach((e=>Hg(e,"strides"))),this.padding=a||"valid",ny(this.padding),this.dataFormat=i||"channelsLast",ty(this.dataFormat),this.dilationRate=Uv(s||1,2,"dilationRate"),this.dilationRate.forEach((e=>Hg(e,"dilationRate")))}build(e){var t;e=rb(e);const n="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[n])throw new wg(`The channel dimension of the input should be defined. Found ${e[n]}`);const r=e[n],a=this.kernelSize.concat([r,4*this.filters]);this.kernel=this.addWeight("kernel",a,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint);const i=this.kernelSize.concat([this.filters,4*this.filters]);if(this.recurrentKernel=this.addWeight("recurrent_kernel",i,null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){let e;if(this.unitForgetBias){const n=this.biasInitializer,r=this.filters;e=new((t=class extends $y{apply(e,t){return _y([n.apply([r]),lp([r]),n.apply([2*r])])}}).className="CustomInit",t)}else e=this.biasInitializer;this.bias=this.addWeight("bias",[4*this.filters],null,e,this.biasRegularizer,!0,this.biasConstraint)}this.built=!0}call(e,t){return ho((()=>{if(3!==e.length)throw new wg(`ConvLSTM2DCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);const n=t.training||!1,r=e[0],a=e[1],i=e[2];0bp(r),rate:this.dropout,training:n,count:4,dropoutFunc:this.dropoutFunc}));const s=this.dropoutMask,o=(e,t,n)=>t&&t[n]?Su(t[n],e):e;let u=o(r,s,0),l=o(r,s,1),c=o(r,s,2),p=o(r,s,3);0bp(a),rate:this.recurrentDropout,training:n,count:4,dropoutFunc:this.dropoutFunc}));const d=this.recurrentDropoutMask;let h=o(a,d,0),f=o(a,d,1),m=o(a,d,2),g=o(a,d,3);const[y,b,x,v]=ld(this.kernel.read(),4,3),[_,w,M,N]=this.useBias?ld(this.bias.read(),4):[null,null,null,null];u=this.inputConv(u,y,_,this.padding),l=this.inputConv(l,b,w,this.padding),c=this.inputConv(c,x,M,this.padding),p=this.inputConv(p,v,N,this.padding);const[S,k,D,T]=ld(this.recurrentKernel.read(),4,3);h=this.recurrentConv(h,S),f=this.recurrentConv(f,k),m=this.recurrentConv(m,D),g=this.recurrentConv(g,T);const I=this.recurrentActivation.apply(wu(u,h)),E=this.recurrentActivation.apply(wu(l,f)),C=wu(Su(E,i),Su(I,this.activation.apply(wu(c,m)))),A=Su(this.recurrentActivation.apply(wu(p,g)),this.activation.apply(C));return[A,A,C]}))}getConfig(){const e=super.getConfig(),{units:t}=e,n=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a{this.invokeCallHook(e,t);const n=nb(e);if(0Ey(n,this.rate,r,this.seed)),(()=>n),e)}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()}}M_.className="Dropout",lu(M_);class N_ extends M_{constructor(e){super(e),this.inputSpec=[{ndim:3}]}getNoiseShape(e){const t=e.shape;return[t[0],1,t[2]]}}N_.className="SpatialDropout1D",lu(N_);class S_ extends hb{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",null==e.batchInputShape&&null==e.inputShape&&null!=e.inputDim){let t=null;null!=e.batchSize&&(t=e.batchSize),this.batchInputShape=[t,e.inputDim]}this.units=e.units,Hg(this.units,"units"),this.activation=Ev(e.activation),null!=e.useBias&&(this.useBias=e.useBias),this.kernelInitializer=Qy(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.biasInitializer=Qy(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelConstraint=Lb(e.kernelConstraint),this.biasConstraint=Lb(e.biasConstraint),this.kernelRegularizer=Fv(e.kernelRegularizer),this.biasRegularizer=Fv(e.biasRegularizer),this.activityRegularizer=Fv(e.activityRegularizer),this.supportsMasking=!0,this.inputSpec=[{minNDim:2}]}build(e){const t=(e=rb(e))[e.length-1];null==this.kernel&&(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){const t=(e=rb(e)).slice();return t[t.length-1]=this.units,t}call(e,t){return ho((()=>{this.invokeCallHook(e,t);const n=nb(e),r=Ug(this.activation.getClassName());let a;return null!=r?a=Sy(n,this.kernel.read(),r,this.bias?this.bias.read():null):(a=Sy(n,this.kernel.read()),null!=this.bias&&(a=Iy(a,this.bias.read())),null!=this.activation&&(a=this.activation.apply(a))),a}))}getConfig(){const e={units:this.units,activation:Tv(this.activation),useBias:this.useBias,kernelInitializer:Zy(this.kernelInitializer),biasInitializer:Zy(this.biasInitializer),kernelRegularizer:Ov(this.kernelRegularizer),biasRegularizer:Ov(this.biasRegularizer),activityRegularizer:Ov(this.activityRegularizer),kernelConstraint:Cb(this.kernelConstraint),biasConstraint:Cb(this.biasConstraint)},t=super.getConfig();return Object.assign(e,t),e}}S_.className="Dense",lu(S_);class k_ extends hb{constructor(e){super(e=e||{}),this.inputSpec=[{minNDim:3}],this.dataFormat=e.dataFormat}computeOutputShape(e){e=rb(e);for(const t of e.slice(1))if(null==t)throw new wg(`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],cy(e,1)]}call(e,t){return ho((()=>{this.invokeCallHook(e,t);let n=nb(e);if("channelsFirst"===this.dataFormat&&n.rank>1){const e=[0];for(let t=2;t{this.invokeCallHook(e,t);const n=nb(e);return this.activation.apply(n)}))}getConfig(){const e={activation:Tv(this.activation)},t=super.getConfig();return Object.assign(e,t),e}}D_.className="Activation",lu(D_);class T_ extends hb{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 ho((()=>function(e,t){return ho((()=>{if(2!==e.shape.length)throw new wg(`repeat() expects a rank-2 tensor, but received a rank-${e.shape.length} tensor.`);return My(yy(e,1),[1,t,1])}))}(e=nb(e),this.n)))}getConfig(){const e={n:this.n},t=super.getConfig();return Object.assign(e,t),e}}T_.className="RepeatVector",lu(T_);class I_ extends hb{constructor(e){super(e),this.targetShape=e.targetShape;for(let e=0;e{this.invokeCallHook(e,t);const n=nb(e),r=n.shape,a=r.slice(0,1).concat(this.fixUnknownDimension(r.slice(1),this.targetShape));return Ml(n,a)}))}getConfig(){const e={targetShape:this.targetShape},t=super.getConfig();return Object.assign(e,t),e}}I_.className="Reshape",lu(I_);class E_ extends hb{constructor(e){if(super(e),null==e.dims)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=hy(1,e.dims.length+1);if(!de(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 ub({ndim:this.dims.length+1})]}computeOutputShape(e){const t=(e=rb(e)).slice();return this.dims.forEach(((n,r)=>{t[r+1]=e[n]})),t}call(e,t){return Io(nb(e),this.dimsIncludingBatch)}getConfig(){const e={dims:this.dims},t=super.getConfig();return Object.assign(e,t),e}}E_.className="Permute",lu(E_);class C_ extends hb{constructor(e){super(null==e?{}:e),this.supportsMasking=!0,this.maskValue=null!=e?null==e.maskValue?0:e.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 n=nb(e);return tl(yp(n,this.maskValue),-1)}call(e,t){return ho((()=>{this.invokeCallHook(e,t);const n=nb(e),r=tl(yp(n,this.maskValue),-1,!0);return Su(n,Ls(r,n.dtype))}))}}C_.className="Masking",lu(C_);class A_ extends hb{constructor(e){if(super(e),this.embeddings=null,this.DEFAULT_EMBEDDINGS_INITIALIZER="randomUniform",null==e.batchInputShape&&null==e.inputShape){let t=null;null!=e.batchSize&&(t=e.batchSize),null==e.inputLength?this.batchInputShape=[t,null]:this.batchInputShape=[t].concat(Eg(e.inputLength))}this.inputDim=e.inputDim,Hg(this.inputDim,"inputDim"),this.outputDim=e.outputDim,Hg(this.outputDim,"outputDim"),this.embeddingsInitializer=Qy(e.embeddingsInitializer||this.DEFAULT_EMBEDDINGS_INITIALIZER),this.embeddingsRegularizer=Fv(e.embeddingsRegularizer),this.activityRegularizer=Fv(e.activityRegularizer),this.embeddingsConstraint=Lb(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 ho((()=>this.maskZero?(e=nb(e),yp(e,Tu(e))):null))}computeOutputShape(e){if(e=rb(e),null==this.inputLength)return[...e,this.outputDim];const t=Eg(this.inputLength);if(t.length!==e.length-1)throw new wg(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`);{let n=0;for(let r=0;r{this.invokeCallHook(e,t);let n=nb(e);"int32"!==n.dtype&&(n=gy(n,"int32"));const r=ky(this.embeddings.read(),Ml(n,[n.size]));return Ml(r,rb(this.computeOutputShape(n.shape)))}))}getConfig(){const e={inputDim:this.inputDim,outputDim:this.outputDim,embeddingsInitializer:Zy(this.embeddingsInitializer),embeddingsRegularizer:Ov(this.embeddingsRegularizer),activityRegularizer:Ov(this.activityRegularizer),embeddingsConstraint:Cb(this.embeddingsConstraint),maskZero:this.maskZero,inputLength:this.inputLength},t=super.getConfig();return Object.assign(e,t),e}}A_.className="Embedding",lu(A_);class L_ extends hb{constructor(e){super(e||{}),this.supportsMasking=!0}mergeFunction(e){throw new Mg}computeElementwiseOpOutputShape(e,t){if(null==e||null==t)return null;if(e.length1)throw new wg(`Can not merge tensors with different batch sizes. Got tensors with shapes: ${JSON.stringify(e)}.`);let n=null==e[0]?null:e[0].slice(1);for(let t=1;te.length));-1===e.indexOf(null)&&1===Yg(r).length?this.reshapeRequired=!1:this.reshapeRequired=!0}call(e,t){return ho((()=>{if(this.reshapeRequired){const t=[],n=e.map((e=>e.rank));if(-1===n.indexOf(null)){const r=dy(n);for(let n of e){const e=n.rank;for(let t=0;t1){const a=hy(1,e).concat([0]);t.push(Io(r,a)),n=!0}else t.push(r)}let r=this.mergeFunction(t);const a=r.rank;if(n)if(null==a){const e=r.shape,t=e[e.length-1],n=[t].concat(e.slice(0,e.length-1));r=Ml(Io(Ml(r,[-1,t]),[1,0]),n)}else if(a>1){const e=[a-1].concat(hy(0,a-1));r=Io(r,e)}return r}}return this.mergeFunction(e)}))}computeOutputShape(e){let t;t=null==e[0]?null:e[0].slice(1);for(let n=1;n{if(null==t)return null;if(!Array.isArray(t))throw new wg("`mask` should be an Array");if(!Array.isArray(e))throw new wg("`inputs` should be an Array");if(t.length!==e.length)throw new wg(`The Array 'inputs' and 'mask' are expected to have the same length, but have different lengths (${e.length} vs ${t.length})`);if(t.every((e=>null==e)))return null;let n=(t=t.map((e=>null==e?e:Ic(e,0))))[0];for(let e=1;e{let t=e[0].clone();for(let n=1;n{let t=e[0].clone();for(let n=1;n{let t=e[0].clone();for(let n=1;n{let t=e[0];for(let n=1;n{let t=e[0];for(let n=1;n1)throw new wg("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: "+JSON.stringify(e))}mergeFunction(e){return ho((()=>_y(e,this.axis)))}computeOutputShape(e){if(!Array.isArray(e)||!Array.isArray(e[0]))throw new wg("A `Concatenate` layer should be called on a list of inputs.");const t=e,n=t[0].slice(),r=this.axis<0?n.length+this.axis:this.axis;for(const e of t.slice(1)){if(null==n[r]||null==e[r]){n[r]=null;break}n[r]+=e[r]}return n}computeMask(e,t){if(null==t)return null;if(!Array.isArray(t))throw new wg("`mask` should be an array for Concatenate");if(!Array.isArray(e))throw new wg("`inputs` should be an array for Concatenate");if(t.length!==e.length)throw new wg(`Mismatch in the length of mask (${t.length}) and the legnth of inputs (${e.length})`);return ho((()=>{let n=!0;if(t.forEach((e=>{null==e||(n=!1)})),n)return null;const r=[];for(let n=0;n"A `Dot` layer should be called on a list of exactly 2 inputs."));const t=e[0],n=e[1];if(t.length>3||n.length>3)throw new Mg("Dot layer does not support tensors of 4D or higher rank yet.");const r=this.interpretAxes(t,n);if(t[r[0]]!==n[r[1]])throw new wg(`Dimension incompatibility: ${t[r[0]]} !== ${n[r[1]]}`)}mergeFunction(e){if(2!==e.length)throw new wg(`A \`Dot\` layer must be called on exactly 2 inputs, but received ${e.length} input(s).`);let t,n=e[0],r=e[1];return t=Array.isArray(this.axes)?this.axes.map(((t,n)=>B_(t,e[n].shape.length))):[B_(this.axes,n.shape.length),B_(this.axes,r.shape.length)],this.normalize&&(n=px(n,t[0]),r=px(r,t[1])),function(e,t,n){if(e.shape.length>3||t.shape.length>3)throw new Mg("batchDot is not implemented for tensors of 4D or higher rank yet");if(se(e.shape.length>=2,(()=>`batchDot requires the rank of x to be >= 2, but got ${e.shape.length}`)),se(e.shape.length>=2,(()=>`batchDot requires the rank of y to be >= 2, but got ${t.shape.length}`)),"number"==typeof n&&(n=[n,n]),"complex64"===e.dtype||"complex64"===t.dtype)throw new Mg("batchDot is not implemented for complex64-type Tensors yet.");const r=e.shape.length,a=t.shape.length;null==n&&(n=[r-1,a-2]);const i=n;return ho((()=>{let n,s;if(r>a){n=r-a;const e=[];for(let t=0;tr){n=a-r;const t=[];for(let e=0;e0){let e;e=r>a?r+a-3:r-1;const t=[];for(let r=e;r"A `Dot` layer should be called on a list of exactly 2 inputs."));const t=e[0].slice(),n=e[1].slice();if(t.length>3||n.length>3)throw new Mg("Dot layer does not support tensors of 4D or higher rank yet.");const r=this.interpretAxes(t,n);t.splice(r[0],1),n.splice(r[1],1),n.splice(0,1);const a=t.concat(n);return 1===a.length&&a.push(1),a}computeMask(e,t){return null}getConfig(){const e={axes:this.axes,normalize:this.normalize},t=super.getConfig();return Object.assign(e,t),e}}P_.className="Dot",lu(P_);class H_ extends hb{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 ho((()=>{this.invokeCallHook(e,t);const n=nb(e);return Cy((()=>wu(Ny(n.shape,0,this.stddev),n)),(()=>n),t.training||!1)}))}}H_.className="GaussianNoise",lu(H_);class j_ extends hb{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 ho((()=>{this.invokeCallHook(e,t);const n=nb(e);return this.rate>0&&this.rate<1?Cy((()=>{const e=Math.sqrt(this.rate/(1-this.rate));return Su(n,Ny(n.shape,1,e))}),(()=>n),t.training||!1):n}))}}j_.className="GaussianDropout",lu(j_);class U_ extends hb{constructor(e){super(e),this.supportsMasking=!0,this.rate=e.rate,this.noiseShape=e.noiseShape}_getNoiseShape(e){return this.noiseShape||nb(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 ho((()=>{if(this.rate<1&&this.rate>0){const n=this._getNoiseShape(e),r=()=>{const t=nb(e),r=-1.7580993408473766;let a=Rc(Fp(n),this.rate);a=gy(a,"float32");const i=((1-this.rate)*(1+this.rate*r**2))**-.5,s=-i*r*this.rate,o=wu(Su(t,a),Su(wu(a,-1),r));return wu(Su(o,i),s)};return Cy(r,(()=>nb(e)),t.training||!1)}return e}))}}function q_(e,t,n,r,a,i=.001){let s;if(2===e.rank)s=Ll(e,t,n,r,a,i);else if(3===e.rank)s=$l(e,t,n,r,a,i);else{if(4!==e.rank)throw new Mg(`batchNormalization is not implemented for array of rank ${e.rank} yet`);s=Ol(e,t,n,r,a,i)}return s}U_.className="AlphaDropout",lu(U_);class W_ extends hb{constructor(e){null==e&&(e={}),super(e),this.supportsMasking=!0,this.axis=null==e.axis?-1:e.axis,this.momentum=null==e.momentum?.99:e.momentum,this.epsilon=null==e.epsilon?.001:e.epsilon,this.center=null==e.center||e.center,this.scale=null==e.scale||e.scale,this.betaInitializer=Qy(e.betaInitializer||"zeros"),this.gammaInitializer=Qy(e.gammaInitializer||"ones"),this.movingMeanInitializer=Qy(e.movingMeanInitializer||"zeros"),this.movingVarianceInitializer=Qy(e.movingVarianceInitializer||"ones"),this.betaConstraint=Lb(e.betaConstraint),this.gammaConstraint=Lb(e.gammaConstraint),this.betaRegularizer=Fv(e.betaRegularizer),this.gammaRegularizer=Fv(e.gammaRegularizer)}build(e){e=rb(e);const t=this.axis>=0?this.axis:this.axis+e.length,n=e[t];if(null==n)throw new wg(`Axis ${t} of input tensor should have a defined dimension but the layer received an input with shape ${JSON.stringify(e)}.`);this.inputSpec=[new ub({ndim:e.length,axes:{[t]:n}})];const r=[n];this.scale&&(this.gamma=this.addWeight("gamma",r,null,this.gammaInitializer,this.gammaRegularizer,!0,this.gammaConstraint)),this.center&&(this.beta=this.addWeight("beta",r,null,this.betaInitializer,this.betaRegularizer,!0,this.betaConstraint)),this.movingMean=this.addWeight("moving_mean",r,null,this.movingMeanInitializer,null,!1),this.movingVariance=this.addWeight("moving_variance",r,null,this.movingVarianceInitializer,null,!1),this.built=!0}call(e,t){return ho((()=>{const n=null!=t.training&&t.training,r=nb(e),a=r.shape,i=a.length,s=hy(0,i),o=this.axis>=0?this.axis:this.axis+i;s.splice(o,1);const u=kg(1,i);u[o]=a[o];const l=s.slice();l.sort();const c=!de(l,hy(0,i).slice(0,i-1));if(!n)return(()=>{if(c){const e=Ml(this.movingMean.read(),u),t=Ml(this.movingVariance.read(),u),n=this.center?Ml(this.beta.read(),u):null,a=this.scale?Ml(this.gamma.read(),u):null;return q_(r,e,t,n,a,this.epsilon)}return q_(r,this.movingMean.read(),this.movingVariance.read(),null==this.beta?null:this.beta.read(),null==this.gamma?null:this.gamma.read(),this.epsilon)})();const[p,d,h]=function(e,t,n,r,a=.001){return de(r.slice().sort(),hy(0,e.rank-1))?function(e,t,n,r,a=.001){return ho((()=>{const i=fp(e,r),s=i.mean,o=i.variance;return[q_(e,s,o,n,t,a),s,o]}))}(e,t,n,r,a):function(e,t,n,r,a=.001){return ho((()=>{const i=fp(e,r),s=i.mean,o=i.variance,u=[];for(const t of hy(0,e.rank))-1!==r.indexOf(t)?u.push(1):u.push(e.shape[t]);const l=Ml(s,u),c=Ml(o,u),p=null==t?null:Ml(t,u),d=null==n?null:Ml(n,u);return[q_(e,l,c,d,p,a),s,o]}))}(e,t,n,r,a)}(r,this.gamma.read(),this.beta.read(),s,this.epsilon),f=(e,t,n)=>{ho((()=>{const r=1-n,a=e.read(),i=Su(Hu(a,t),r);e.write(Hu(a,i))}))};return(()=>{f(this.movingMean,d,this.momentum),f(this.movingVariance,h,this.momentum)})(),p}))}getConfig(){const e={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:Zy(this.betaInitializer),gammaInitializer:Zy(this.gammaInitializer),movingMeanInitializer:Zy(this.movingMeanInitializer),movingVarianceInitializer:Zy(this.movingVarianceInitializer),betaRegularizer:Ov(this.betaRegularizer),gammaRegularizer:Ov(this.gammaRegularizer),betaConstraint:Cb(this.betaConstraint),gammaConstraint:Cb(this.gammaConstraint)},t=super.getConfig();return Object.assign(e,t),e}}W_.className="BatchNormalization",lu(W_);class V_ extends hb{constructor(e){if(null==e&&(e={}),super(e),this.axis=null==e.axis?-1:e.axis,"number"==typeof this.axis){if(!Number.isInteger(this.axis))throw new Error(`Expected axis to be an integer, but received ${this.axis}`)}else{if(!Array.isArray(this.axis))throw new Error(`Expected axis to be an integer or an array of integers, but received ${JSON.stringify(this.axis)}`);for(const e of this.axis)if(!Number.isInteger(e))throw new Error(`Expected axis to be an array of integers, but received ${JSON.stringify(this.axis)}`)}this.epsilon=null==e.epsilon?.001:e.epsilon,this.center=null==e.center||e.center,this.scale=null==e.scale||e.scale,this.betaInitializer=Qy(e.betaInitializer||"zeros"),this.gammaInitializer=Qy(e.gammaInitializer||"ones"),this.betaRegularizer=Fv(e.betaRegularizer),this.gammaRegularizer=Fv(e.gammaRegularizer),this.supportsMasking=!0}build(e){const t=(e=rb(e)).length;"number"==typeof this.axis&&(this.axis=[this.axis]);for(let e=0;e=t)throw new Error(`Invalid axis: ${e}`);if(this.axis.length!==Yg(this.axis).length)throw new Error(`Found duplicate axes in: ${this.axis}`);const n=this.axis.map((t=>e[t]));this.scale?this.gamma=this.addWeight("gamma",n,"float32",this.gammaInitializer,this.gammaRegularizer,!0):this.gamma=null,this.center?this.beta=this.addWeight("beta",n,"float32",this.betaInitializer,this.betaRegularizer,!0):this.beta=null,this.built=!0}call(e,t){const n=nb(e),r=n.shape,a=r.length;return ho((()=>{let{mean:e,variance:t}=fp(n,this.axis,!0);const i=kg(1,a);for(const e of this.axis)i[e]=r[e];const s=e=>null!=e&&e.shape.length!==a?Ml(e,i):e;let o=this.scale?s(this.gamma.read()):null,u=this.center?s(this.beta.read()):null;const l=[],c=[];for(let e=0;e=0?e[2]+this.padding[0][0]+this.padding[0][1]:null,n=null!=e[3]&&e[3]>=0?e[3]+this.padding[1][0]+this.padding[1][1]:null,[e[0],e[1],t,n]):(t=null!=e[1]&&e[1]>=0?e[1]+this.padding[0][0]+this.padding[0][1]:null,n=null!=e[2]&&e[2]>=0?e[2]+this.padding[1][0]+this.padding[1][1]:null,[e[0],t,n,e[3]])}call(e,t){return ho((()=>{return t=nb(e),n=this.padding,r=this.dataFormat,ho((()=>{if(4!==t.rank)throw new wg(`temporalPadding expects input tensor to be 4-D, but received a ${t.rank}-D tensor.`);if(null==n&&(n=[[1,1],[1,1]]),2!==n.length||2!==n[0].length||2!==n[1].length)throw new wg("spatial2dPadding expects `padding` to be an Array of two Arrays, each of which is an Array of two integers.");if(null==r&&(r="channelsLast"),"channelsLast"!==r&&"channelsFirst"!==r)throw new wg(`Unknown data format: ${r}. Supported data formats are 'channelsLast' and 'channelsFirst.`);let e;return e="channelsFirst"===r?[[0,0],[0,0],n[0],n[1]]:[[0,0],n[0],n[1],[0,0]],vp(t,e)}));var t,n,r}))}getConfig(){const e={padding:this.padding,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}function K_(e,t,n,r,a,i){return ho((()=>{let s;ty(a),ry(i),ny(r),null==n&&(n=[1,1]),null==r&&(r="valid"),null==a&&(a="channelsLast"),null==i&&(i="max"),e=Vv(e,a);const o="same"===r?"same":"valid";return s="max"===i?ap(e,t,n,o):Nl(e,t,n,o),"channelsFirst"===a&&(s=Io(s,[0,3,1,2])),s}))}function J_(e,t,n,r,a,i){return ho((()=>{let s;ty(a),ry(i),ny(r),null==n&&(n=[1,1,1]),null==r&&(r="valid"),null==a&&(a="channelsLast"),null==i&&(i="max"),e=Gv(e,a);const o="same"===r?"same":"valid";return s="max"===i?ip(e,t,n,o):Sl(e,t,n,o),"channelsFirst"===a&&(s=Io(s,[0,4,1,2,3])),s}))}G_.className="ZeroPadding2D",lu(G_);class X_ extends hb{constructor(e){if(null==e.poolSize&&(e.poolSize=2),super(e),"number"==typeof e.poolSize)this.poolSize=[e.poolSize];else{if(!Array.isArray(e.poolSize)||1!==e.poolSize.length||"number"!=typeof e.poolSize[0])throw new wg(`poolSize for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.poolSize)}`);this.poolSize=e.poolSize}if(Hg(this.poolSize,"poolSize"),null==e.strides)this.strides=this.poolSize;else if("number"==typeof e.strides)this.strides=[e.strides];else{if(!Array.isArray(e.strides)||1!==e.strides.length||"number"!=typeof e.strides[0])throw new wg(`strides for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.strides)}`);this.strides=e.strides}Hg(this.strides,"strides"),this.padding=null==e.padding?"valid":e.padding,ny(this.padding),this.inputSpec=[new ub({ndim:3})]}computeOutputShape(e){const t=qv((e=rb(e))[1],this.poolSize[0],this.padding,this.strides[0]);return[e[0],t,e[2]]}call(e,t){return ho((()=>{this.invokeCallHook(e,t),e=yy(nb(e),2);const n=this.poolingFunction(nb(e),[this.poolSize[0],1],[this.strides[0],1],this.padding,"channelsLast");return dd(n,[2])}))}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides},t=super.getConfig();return Object.assign(e,t),e}}class Z_ extends X_{constructor(e){super(e)}poolingFunction(e,t,n,r,a){return ty(a),ny(r),K_(e,t,n,r,a,"max")}}Z_.className="MaxPooling1D",lu(Z_);class Q_ extends X_{constructor(e){super(e)}poolingFunction(e,t,n,r,a){return ty(a),ny(r),K_(e,t,n,r,a,"avg")}}Q_.className="AveragePooling1D",lu(Q_);class ew extends hb{constructor(e){if(null==e.poolSize&&(e.poolSize=[2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize],null==e.strides)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(2!==e.strides.length)throw new wg(`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];Hg(this.poolSize,"poolSize"),Hg(this.strides,"strides"),this.padding=null==e.padding?"valid":e.padding,this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,ty(this.dataFormat),ny(this.padding),this.inputSpec=[new ub({ndim:4})]}computeOutputShape(e){e=rb(e);let t="channelsFirst"===this.dataFormat?e[2]:e[1],n="channelsFirst"===this.dataFormat?e[3]:e[2];return t=qv(t,this.poolSize[0],this.padding,this.strides[0]),n=qv(n,this.poolSize[1],this.padding,this.strides[1]),"channelsFirst"===this.dataFormat?[e[0],e[1],t,n]:[e[0],t,n,e[3]]}call(e,t){return ho((()=>(this.invokeCallHook(e,t),this.poolingFunction(nb(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 tw extends ew{constructor(e){super(e)}poolingFunction(e,t,n,r,a){return ty(a),ny(r),K_(e,t,n,r,a,"max")}}tw.className="MaxPooling2D",lu(tw);class nw extends ew{constructor(e){super(e)}poolingFunction(e,t,n,r,a){return ty(a),ny(r),K_(e,t,n,r,a,"avg")}}nw.className="AveragePooling2D",lu(nw);class rw extends hb{constructor(e){if(null==e.poolSize&&(e.poolSize=[2,2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize,e.poolSize],null==e.strides)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(3!==e.strides.length)throw new wg(`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];Hg(this.poolSize,"poolSize"),Hg(this.strides,"strides"),this.padding=null==e.padding?"valid":e.padding,this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,ty(this.dataFormat),ny(this.padding),this.inputSpec=[new ub({ndim:5})]}computeOutputShape(e){e=rb(e);let t="channelsFirst"===this.dataFormat?e[2]:e[1],n="channelsFirst"===this.dataFormat?e[3]:e[2],r="channelsFirst"===this.dataFormat?e[4]:e[3];return t=qv(t,this.poolSize[0],this.padding,this.strides[0]),n=qv(n,this.poolSize[1],this.padding,this.strides[1]),r=qv(r,this.poolSize[2],this.padding,this.strides[2]),"channelsFirst"===this.dataFormat?[e[0],e[1],t,n,r]:[e[0],t,n,r,e[4]]}call(e,t){return ho((()=>(this.invokeCallHook(e,t),this.poolingFunction(nb(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 aw extends rw{constructor(e){super(e)}poolingFunction(e,t,n,r,a){return ty(a),ny(r),J_(e,t,n,r,a,"max")}}aw.className="MaxPooling3D",lu(aw);class iw extends rw{constructor(e){super(e)}poolingFunction(e,t,n,r,a){return ty(a),ny(r),J_(e,t,n,r,a,"avg")}}iw.className="AveragePooling3D",lu(iw);class sw extends hb{constructor(e){super(e),this.inputSpec=[new ub({ndim:3})]}computeOutputShape(e){return[e[0],e[2]]}call(e,t){throw new Mg}}class ow extends sw{constructor(e){super(e||{})}call(e,t){return ho((()=>{const t=nb(e);return op(t,1)}))}}ow.className="GlobalAveragePooling1D",lu(ow);class uw extends sw{constructor(e){super(e||{})}call(e,t){return ho((()=>{const t=nb(e);return wc(t,1)}))}}uw.className="GlobalMaxPooling1D",lu(uw);class lw extends hb{constructor(e){super(e),this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,ty(this.dataFormat),this.inputSpec=[new ub({ndim:4})]}computeOutputShape(e){return"channelsLast"===this.dataFormat?[e[0],e[3]]:[e[0],e[1]]}call(e,t){throw new Mg}getConfig(){const e={dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}class cw extends lw{call(e,t){return ho((()=>{const t=nb(e);return"channelsLast"===this.dataFormat?op(t,[1,2]):op(t,[2,3])}))}}cw.className="GlobalAveragePooling2D",lu(cw);class pw extends lw{call(e,t){return ho((()=>{const t=nb(e);return"channelsLast"===this.dataFormat?wc(t,[1,2]):wc(t,[2,3])}))}}pw.className="GlobalMaxPooling2D",lu(pw);class dw extends hb{constructor(e){super(e),this.layer=e.layer}build(e){this.built=!0}get trainable(){return null!=this.layer&&this.layer.trainable}set trainable(e){null!=this.layer&&(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),null!=this.layer&&this.layer.setFastWeightInitDuringBuild(e)}static fromConfig(e,t,n={}){const r=cx(t.layer,n);delete t.layer;const a={layer:r};return Object.assign(a,t),new e(a)}}class hw extends dw{constructor(e){super(e),this.supportsMasking=!0}build(e){if((e=rb(e)).length<3)throw new wg(`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){const t=[(e=rb(e))[0]].concat(e.slice(2)),n=this.layer.computeOutputShape(t),r=e[1];return[n[0],r].concat(n.slice(1))}call(e,t){return ho((()=>l_(((e,n)=>[nb(this.layer.call(e,t)),[]]),e=nb(e),[],!1,null,null,!1,!0)[1]))}}hw.className="TimeDistributed",lu(hw);class fw extends dw{constructor(e){super(e);const t=e.layer.getConfig(),n={};n.className=e.layer.getClassName(),n.config=t,this.forwardLayer=cx(n),t.goBackwards=!0!==t.goBackwards;const r={};var a;if(r.className=e.layer.getClassName(),r.config=t,this.backwardLayer=cx(r),this.forwardLayer.name="forward_"+this.forwardLayer.name,this.backwardLayer.name="backward_"+this.backwardLayer.name,this.mergeMode=void 0===e.mergeMode?"concat":e.mergeMode,a=this.mergeMode,Bg(Qg,"BidirectionalMergeMode",a),e.weights)throw new Mg("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,null!=this.forwardLayer&&(this.forwardLayer.trainable=e),null!=this.backwardLayer&&(this.backwardLayer.trainable=e)}getWeights(){return this.forwardLayer.getWeights().concat(this.backwardLayer.getWeights())}setWeights(e){const t=e.length,n=Math.floor(t/2);this.forwardLayer.setWeights(e.slice(0,n)),this.backwardLayer.setWeights(e.slice(n))}computeOutputShape(e){let t,n,r,a=this.forwardLayer.computeOutputShape(e);return Array.isArray(a)&&Array.isArray(a[0])||(a=[a]),this.returnState?(r=a.slice(1),t=a[0]):t=a[0],"concat"===this.mergeMode?(t[t.length-1]*=2,n=[t]):n=null==this.mergeMode?[t,t.slice()]:[t],this.returnState?null==this.mergeMode?n.concat(r).concat(r.slice()):[t].concat(r).concat(r.slice()):Ig(n)}apply(e,t){let n=null==t?null:t.initialState,r=null==t?null:t.constants;null==t&&(t={});const a=u_(e,n,r,this.numConstants);if(e=a.inputs,n=a.initialState,r=a.constants,Array.isArray(e)&&(n=e.slice(1),e=e[0]),(null==n||0===n.length)&&null==r)return super.apply(e,t);const i=[],s=[];if(null!=n){const e=n.length;if(e%2>0)throw new wg("When passing `initialState` to a Bidrectional RNN, the state should be an Array containing the states of the underlying RNNs.");t.initialState=n,i.push(...n);const r=n.map((e=>new ub({shape:e.shape})));this.forwardLayer.stateSpec=r.slice(0,e/2),this.backwardLayer.stateSpec=r.slice(e/2),s.push(...r)}if(null!=r)throw new Mg("Support for constants in Bidirectional layers is not implemented yet.");const o=i[0]instanceof lb;for(const e of i)if(e instanceof lb!==o)throw new wg("The initial state of a Bidirectional layer cannot be specified as a mix of symbolic and non-symbolic tensors");if(o){const n=[e].concat(i),r=this.inputSpec.concat(s),a=this.inputSpec;this.inputSpec=r;const o=super.apply(n,t);return this.inputSpec=a,o}return super.apply(e,t)}call(e,t){return ho((()=>{const n=t.initialState;let r,a,i,s;if(null==n)r=this.forwardLayer.call(e,t),a=this.backwardLayer.call(e,t);else{const i=n.slice(0,n.length/2),s=n.slice(n.length/2);r=this.forwardLayer.call(e,Object.assign(t,{initialState:i})),a=this.backwardLayer.call(e,Object.assign(t,{initialState:s}))}return this.returnState&&(Array.isArray(r)&&(i=r.slice(1).concat(a.slice(1))),r=r[0],a=a[0]),this.returnSequences&&(a=Hp(a,1)),"concat"===this.mergeMode?s=_y([r,a]):"sum"===this.mergeMode?s=wu(r,a):"ave"===this.mergeMode?s=Su(.5,wu(r,a)):"mul"===this.mergeMode?s=Su(r,a):null==this.mergeMode&&(s=[r,a]),this.returnState?null==this.mergeMode?s.concat(i):[s].concat(i):s}))}resetStates(e){this.forwardLayer.resetStates(),this.backwardLayer.resetStates()}build(e){iy(this.forwardLayer.name,(()=>{this.forwardLayer.build(e)})),iy(this.backwardLayer.name,(()=>{this.backwardLayer.build(e)})),this.built=!0}computeMask(e,t){let n;if(Array.isArray(t)&&(t=t[0]),n=this.returnSequences?null==this.mergeMode?[t,t]:t:null==this.mergeMode?[null,null]:null,this.returnState){const e=this.forwardLayer.states.map((e=>null));return Array.isArray(n)?n.concat(e).concat(e):[n].concat(e).concat(e)}return n}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),null!=this.forwardLayer&&this.forwardLayer.setFastWeightInitDuringBuild(e),null!=this.backwardLayer&&this.backwardLayer.setFastWeightInitDuringBuild(e)}getConfig(){const e={mergeMode:this.mergeMode},t=super.getConfig();return Object.assign(e,t),e}static fromConfig(e,t){const n=cx(t.layer);if(delete t.layer,null!=t.numConstants)throw new Mg("Deserialization of a Bidirectional layer with numConstants present is not supported yet.");const r=t;return r.layer=n,new e(r)}}function mw(e){return new mb(e)}function gw(e){return new Pv(e)}function yw(e){return new Yv(e)}function bw(e){return new zv(e)}function xw(e){return new Bv(e)}function vw(e){return new jv(e)}function _w(e){return new Hv(e)}function ww(e){return new a_(e)}function Mw(e){return new Zv(e)}function Nw(e){return new e_(e)}function Sw(e){return new Qv(e)}function kw(e){return new t_(e)}function Dw(e){return new r_(e)}function Tw(e){return new i_(e)}function Iw(e){return new s_(e)}function Ew(e){return new o_(e)}function Cw(e){return new D_(e)}function Aw(e){return new S_(e)}function Lw(e){return new M_(e)}function $w(e){return new N_(e)}function Ow(e){return new k_(e)}function Rw(e){return new T_(e)}function Fw(e){return new I_(e)}function Yw(e){return new E_(e)}function zw(e){return new A_(e)}function Bw(e){return new $_(e)}function Pw(e){return new R_(e)}function Hw(e){return new z_(e)}function jw(e){return new F_(e)}function Uw(e){return new Y_(e)}function qw(e){return new O_(e)}function Ww(e){return new P_(e)}function Vw(e){return new W_(e)}function Gw(e){return new V_(e)}function Kw(e){return new G_(e)}function Jw(e){return new Q_(e)}function Xw(e){return Jw(e)}function Zw(e){return Jw(e)}function Qw(e){return new nw(e)}function eM(e){return Qw(e)}function tM(e){return Qw(e)}function nM(e){return new iw(e)}function rM(e){return nM(e)}function aM(e){return nM(e)}function iM(e){return new ow(e)}function sM(e){return new cw(e)}function oM(e){return new uw(e)}function uM(e){return new pw(e)}function lM(e){return new Z_(e)}function cM(e){return new tw(e)}function pM(e){return new aw(e)}function dM(e){return new m_(e)}function hM(e){return new f_(e)}function fM(e){return new y_(e)}function mM(e){return new g_(e)}function gM(e){return new h_(e)}function yM(e){return new d_(e)}function bM(e){return new w_(e)}function xM(e){return new __(e)}function vM(e){return new c_(e)}function _M(e){return new b_(e)}function wM(e){return new fw(e)}function MM(e){return new hw(e)}fw.className="Bidirectional",lu(fw);const NM=oM,SM=uM,kM=lM,DM=cM;function TM(e){return new H_(e)}function IM(e){return new j_(e)}function EM(e){return new U_(e)}function CM(e){return new C_(e)}function AM(e,t){return _x(e,t)}function LM(e,t){return Sx(e,t)}function $M(e,t){return kx(e,t)}function OM(e,t){return wx(e,t)}function RM(e,t){return Dx(e,t)}function FM(e,t){return Nx(e,t)}function YM(e,t){return function(e,t){return ho((()=>{const n=Mx(e,t),r=function(e,t){return ho((()=>Ls(Nc(Xc(oc(e,1),oc(t,0))),"float32")))}(e,t),a=wu(n,r);return Ls(uc(Oc(a,0),Nu(n,a),0),"float32")}))}(e,t)}function zM(e,t){return bx(e,t)}function BM(e,t){return hx(e,t)}function PM(e,t){return fx(e,t)}function HM(e,t){return fx(e,t)}function jM(e,t){return fx(e,t)}function UM(e,t){return dx(e,t)}function qM(e,t){return dx(e,t)}function WM(e,t){return dx(e,t)}function VM(e){return new Lv(e)}function GM(e){return Cv(t=e),new Lv({l1:null!=t?t.l1:null,l2:0});var t}function KM(e){return Cv(t=e),new Lv({l2:null!=t?t.l2:null,l1:0});var t}class JM extends nx{constructor(){super(...arguments),this.model=null}setModel(e){if(!(e instanceof av))throw new Error("model must be a LayersModel, not some other Container");this.model=e}}function XM(e,t){return et}class QM extends JM{constructor(e){if(super(),null==e&&(e={}),e.restoreBestWeights)throw new Mg("restoreBestWeights = True is not implemented in EarlyStopping yet.");this.monitor=e.monitor||"val_loss",this.minDelta=Math.abs(e.minDelta||0),this.patience=e.patience||0,this.verbose=e.verbose||0,this.mode=e.mode||"auto",this.baseline=e.baseline,-1===["auto","min","max"].indexOf(this.mode)&&(console.warn(`EarlyStopping mode '${this.mode}' is invalid. Falling back to mode 'auto'.`),this.mode="auto"),"min"===this.mode?this.monitorFunc=XM:"max"===this.mode||-1!==this.monitor.indexOf("acc")?this.monitorFunc=ZM:this.monitorFunc=XM,this.monitorFunc===XM&&(this.minDelta*=-1)}async onTrainBegin(e){this.wait=0,this.stoppedEpoch=0,null!=this.baseline?this.best=this.baseline:this.best=this.monitorFunc===XM?1/0:-1/0}async onEpochEnd(e,t){await Qb(t);const n=this.getMonitorValue(t);null!=n&&(this.monitorFunc(n-this.minDelta,this.best)?(this.best=n,this.wait=0):(this.wait++,this.wait>=this.patience&&(this.stoppedEpoch=e,this.model.stopTraining=!0)))}async onTrainEnd(e){this.stoppedEpoch>0&&this.verbose&&console.log(`Epoch ${this.stoppedEpoch}: early stopping.`)}getMonitorValue(e){null==e&&(e={});const t=e[this.monitor];return null==t&&console.warn(`Metric for EarlyStopping ${this.monitor} is not available. Available metrics are: ${Object.keys(e)}`),t}}const eN={earlyStopping:function(e){return new QM(e)}};var tN,nN;Ge().registerFlag("KEEP_INTERMEDIATE_TENSORS",(()=>!1),(e=>{e&&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.")})),function(e){e[e.DT_INVALID=0]="DT_INVALID",e[e.DT_FLOAT=1]="DT_FLOAT",e[e.DT_DOUBLE=2]="DT_DOUBLE",e[e.DT_INT32=3]="DT_INT32",e[e.DT_UINT8=4]="DT_UINT8",e[e.DT_INT16=5]="DT_INT16",e[e.DT_INT8=6]="DT_INT8",e[e.DT_STRING=7]="DT_STRING",e[e.DT_COMPLEX64=8]="DT_COMPLEX64",e[e.DT_INT64=9]="DT_INT64",e[e.DT_BOOL=10]="DT_BOOL",e[e.DT_QINT8=11]="DT_QINT8",e[e.DT_QUINT8=12]="DT_QUINT8",e[e.DT_QINT32=13]="DT_QINT32",e[e.DT_BFLOAT16=14]="DT_BFLOAT16",e[e.DT_QINT16=15]="DT_QINT16",e[e.DT_QUINT16=16]="DT_QUINT16",e[e.DT_UINT16=17]="DT_UINT16",e[e.DT_COMPLEX128=18]="DT_COMPLEX128",e[e.DT_HALF=19]="DT_HALF",e[e.DT_RESOURCE=20]="DT_RESOURCE",e[e.DT_VARIANT=21]="DT_VARIANT",e[e.DT_UINT32=22]="DT_UINT32",e[e.DT_UINT64=23]="DT_UINT64",e[e.DT_FLOAT_REF=101]="DT_FLOAT_REF",e[e.DT_DOUBLE_REF=102]="DT_DOUBLE_REF",e[e.DT_INT32_REF=103]="DT_INT32_REF",e[e.DT_UINT8_REF=104]="DT_UINT8_REF",e[e.DT_INT16_REF=105]="DT_INT16_REF",e[e.DT_INT8_REF=106]="DT_INT8_REF",e[e.DT_STRING_REF=107]="DT_STRING_REF",e[e.DT_COMPLEX64_REF=108]="DT_COMPLEX64_REF",e[e.DT_INT64_REF=109]="DT_INT64_REF",e[e.DT_BOOL_REF=110]="DT_BOOL_REF",e[e.DT_QINT8_REF=111]="DT_QINT8_REF",e[e.DT_QUINT8_REF=112]="DT_QUINT8_REF",e[e.DT_QINT32_REF=113]="DT_QINT32_REF",e[e.DT_BFLOAT16_REF=114]="DT_BFLOAT16_REF",e[e.DT_QINT16_REF=115]="DT_QINT16_REF",e[e.DT_QUINT16_REF=116]="DT_QUINT16_REF",e[e.DT_UINT16_REF=117]="DT_UINT16_REF",e[e.DT_COMPLEX128_REF=118]="DT_COMPLEX128_REF",e[e.DT_HALF_REF=119]="DT_HALF_REF",e[e.DT_RESOURCE_REF=120]="DT_RESOURCE_REF",e[e.DT_VARIANT_REF=121]="DT_VARIANT_REF",e[e.DT_UINT32_REF=122]="DT_UINT32_REF",e[e.DT_UINT64_REF=123]="DT_UINT64_REF"}(tN||(tN={})),function(e){let t;!function(e){e[e.LEGACY=0]="LEGACY",e[e.V1=1]="V1",e[e.V2=2]="V2"}(t=e.CheckpointFormatVersion||(e.CheckpointFormatVersion={}))}(nN||(nN={}));const rN={};function aN(e,t){const n={tfOpName:e,category:"custom",inputs:[],attrs:[],customExecutor:t};rN[e]=n}function iN(e){return rN[e]}function sN(e){delete rN[e]}function oN(e,t,n,r,a){const i=t.inputParams[e];if(i&&void 0!==i.inputIndexStart){const e=i.inputIndexStart,s=0===i.inputIndexEnd?void 0:void 0===i.inputIndexEnd?e+1:i.inputIndexEnd;if("tensor"===i.type)return uN(t.inputNames[i.inputIndexStart],n,r,a);if("tensors"===i.type)return t.inputNames.slice(e,s).map((e=>uN(e,n,r,a)));const o=uN(t.inputNames.slice(e)[0],n,r,a),u=o.dataSync();return"number"===i.type?u[0]:Ye(o.shape,u)}const s=t.attrParams[e];return s&&s.value}function uN(e,t,n,r){const[a,i]=pN(e);if(null!=r){const e=r.getHashTableHandleByName(a);if(null!=e)return e}const s=n.currentContextIds.find((e=>!!t[cN(a,e)]));return void 0!==s?t[cN(a,s)][i]:void 0}function lN(e,t){const[n,r,a]=pN(e);return[cN(n,t&&t.currentContextId),r,a]}function cN(e,t){return t?`${e}-${t}`:e}function pN(e){const t=e.split(":");if(1===t.length)return[e,0,void 0];const n=t[0],r=3===t.length?t[1]:void 0;return[n,Number(t[t.length-1]),r]}function dN(e,t,n){let r=oN("pad",e,t,n);if("explicit"===r){r=oN("explicitPaddings",e,t,n);const a=[[0,0],[0,0],[0,0],[0,0]];for(let e=0;e<4;e++)a[e][0]=r[2*e],a[e][1]=r[2*e+1];return a}return r}function hN(e){return e.kept?e:$s(e)}const fN=[{tfOpName:"Add",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddV2",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddN",category:"arithmetic",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"BiasAdd",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"Sub",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"RealDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Div",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"DivNoNan",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mul",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Maximum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Minimum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Pow",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SquaredDifference",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorMod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],mN=[{tfOpName:"Abs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan2",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Ceil",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ClipByValue",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"clipValueMin",type:"number"},{start:2,name:"clipValueMax",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Complex",category:"basic_math",inputs:[{start:0,name:"real",type:"tensor"},{start:1,name:"imag",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ComplexAbs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Elu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Exp",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Floor",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Imag",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Neg",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Real",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Prelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"alpha",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu6",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Selu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sigmoid",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Rsqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Square",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sign",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Round",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Expm1",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log1p",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Reciprocal",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Softplus",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Erf",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Prod",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axes",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LeakyRelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"alpha",name:"alpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"IsNan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],gN=[{tfOpName:"EmptyTensorList",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"maxNumElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"LoopCond",category:"control",inputs:[{start:0,name:"pred",type:"tensor"}]},{tfOpName:"Switch",category:"control",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"pred",type:"tensor"}]},{tfOpName:"Merge",category:"control",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"Enter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"frame_name",name:"frameName",type:"string"},{tfName:"is_constant",name:"isConstant",type:"bool"}]},{tfOpName:"Exit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NextIteration",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayV3",category:"control",inputs:[{start:0,name:"size",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"dynamic_size",name:"dynamicSize",type:"bool"},{tfName:"clear_after_read",name:"clearAfterRead",type:"bool"},{tfName:"identical_element_shapes",name:"identicalElementShapes",type:"bool"},{tfName:"tensor_array_name",name:"name",type:"string"}]},{tfOpName:"TensorArrayWriteV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayReadV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayGatherV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"}]},{tfOpName:"TensorArrayScatterV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArrayConcatV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape_except0",name:"elementShapeExcept0",type:"shape",notSupported:!0}]},{tfOpName:"TensorArraySplitV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"tensor",type:"tensor"},{start:2,name:"lengths",type:"number[]"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArraySizeV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}]},{tfOpName:"TensorArrayCloseV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"}]},{tfOpName:"StatelessIf",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"If",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"StatelessWhile",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"While",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"TensorListScatter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListScatterV2",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"},{start:3,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGather",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListSetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListReserve",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListFromTensor",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListStack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"},{tfName:"num_elements",name:"numElements",type:"dtype"}]},{tfOpName:"TensorListSplit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"},{start:2,name:"lengths",type:"number[]"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcat",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcatV2",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPopBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPushBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListLength",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}]},{tfOpName:"TensorListResize",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"size",type:"number"}]}],yN=[{tfOpName:"AvgPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[],notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPoolWithArgmax",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"include_batch_in_index",name:"includeBatchInIndex",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AvgPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Conv1D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"stride",name:"stride",type:"number"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NWC"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"dilation",name:"dilation",type:"number",defaultValue:1}]},{tfOpName:"Conv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"useCudnnOnGpu",name:"useCudnnOnGpu",type:"bool"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"_FusedConv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"use_cudnn_on_gpu",name:"useCudnnOnGpu",type:"bool",defaultValue:!0},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"leakyrelu_alpha",name:"leakyreluAlpha",type:"number",defaultValue:.2}]},{tfOpName:"Conv2DBackpropInput",category:"convolution",inputs:[{start:2,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:0,name:"outputShape",type:"number[]"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]",notSupported:!0}]},{tfOpName:"DepthwiseConv2d",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"DepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"FusedDepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]}]},{tfOpName:"Conv3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"Dilation2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"rates",name:"dilations",type:"number[]"},{tfName:"padding",name:"pad",type:"string"}]}],bN=[{tfOpName:"Fill",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"},{start:1,name:"value",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"LinSpace",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"num",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"OneHot",category:"creation",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"depth",type:"number"},{start:2,name:"onValue",type:"number",defaultValue:1},{start:3,name:"offValue",type:"number",defaultValue:0}],attrs:[{tfName:"axis",name:"axis",type:"number",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Ones",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"OnesLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"RandomStandardNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"RandomUniform",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"minval",name:"minval",type:"number",defaultValue:0},{tfName:"maxval",name:"maxval",type:"number",defaultValue:1},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Range",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"step",type:"number",defaultValue:0}],attrs:[{tfName:"Tidx",name:"dtype",type:"dtype"}]},{tfOpName:"TruncatedNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"means",name:"mean",type:"number",defaultValue:0},{tfName:"stddev",name:"stdDev",type:"number",defaultValue:1},{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Zeros",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"ZerosLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"Multinomial",category:"creation",inputs:[{start:0,name:"logits",type:"tensor"},{start:1,name:"numSamples",type:"number"}],attrs:[{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number"},{tfName:"T",name:"dtype",type:"dtype"},{tfName:"output_dtype",name:"output_dtype",type:"dtype"}]}],xN=[{tfOpName:"NonMaxSuppressionV2",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV3",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV4",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"T_threshold",name:"threshold",type:"dtype",notSupported:!0},{tfName:"pad_to_max_output_size",name:"padToMaxOutputSize",type:"bool"}]},{tfOpName:"NonMaxSuppressionV5",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"},{start:5,name:"softNmsSigma",type:"number"}]},{tfOpName:"Where",category:"dynamic",inputs:[{start:0,name:"condition",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ListDiff",category:"dynamic",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],vN=[{tfOpName:"LowerBound",category:"evaluation",inputs:[{start:0,name:"sortedSequence",type:"tensor"},{start:1,name:"values",type:"tensor"}]},{tfOpName:"TopKV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"k",type:"number"}],attrs:[{tfName:"sorted",name:"sorted",type:"bool"}]},{tfOpName:"UpperBound",category:"evaluation",inputs:[{start:0,name:"sortedSequence",type:"tensor"},{start:1,name:"values",type:"tensor"}]},{tfOpName:"Unique",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"UniqueV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]}],_N=[{tfOpName:"PlaceholderWithDefault",category:"graph",inputs:[{start:0,name:"default",type:"tensor"}],attrs:[{tfName:"shape",name:"shape",type:"shape"},{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"Placeholder",category:"graph",attrs:[{tfName:"shape",name:"shape",type:"shape"},{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"Const",category:"graph"},{tfOpName:"Identity",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"IdentityN",category:"graph",inputs:[{start:0,end:0,name:"x",type:"tensors"}]},{tfOpName:"Snapshot",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Rank",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Size",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Shape",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"ShapeN",category:"graph",inputs:[{start:0,end:0,name:"x",type:"tensors"}]},{tfOpName:"Print",category:"graph",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"data",type:"tensors"}],attrs:[{tfName:"message",name:"message",type:"string"},{tfName:"first_n",name:"firstN",type:"number",notSupported:!0},{tfName:"summarize",name:"summarize",type:"number",defaultValue:3}]},{tfOpName:"NoOp",category:"graph",inputs:[]},{tfOpName:"StopGradient",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"FakeQuantWithMinMaxVars",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"min",name:"min",type:"number"},{tfName:"max",name:"max",type:"number"}]}],wN=[{tfOpName:"HashTable",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"HashTableV2",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"LookupTableImport",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableImportV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFind",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFindV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableSize",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]},{tfOpName:"LookupTableSizeV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]}],MN=[{tfOpName:"ResizeBilinear",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"half_pixel_centers",name:"halfPixelCenters",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ResizeNearestNeighbor",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"half_pixel_centers",name:"halfPixelCenters",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"CropAndResize",category:"image",inputs:[{start:0,name:"image",type:"tensor"},{start:1,name:"boxes",type:"tensor"},{start:2,name:"boxInd",type:"tensor"},{start:3,name:"cropSize",type:"number[]"}],attrs:[{tfName:"method",name:"method",type:"string"},{tfName:"extrapolation_value",name:"extrapolationValue",type:"number"}]},{tfOpName:"ImageProjectiveTransformV3",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"transforms",type:"tensor"},{start:2,name:"outputShape",type:"number[]"},{start:3,name:"fillValue",type:"number"}],attrs:[{tfName:"interpolation",name:"interpolation",type:"string"},{tfName:"fill_mode",name:"fillMode",type:"string"}]}],NN=[{tfOpName:"Equal",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NotEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Greater",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"GreaterEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Less",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LessEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalAnd",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalNot",category:"logical",inputs:[{start:0,name:"a",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalOr",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Select",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SelectV2",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],SN=[{tfOpName:"_FusedMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"leakyrelu_alpha",name:"leakyreluAlpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMulV2",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Transpose",category:"matrices",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"perm",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Einsum",category:"matrices",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"equation",name:"equation",type:"string"},{tfName:"N",name:"n",type:"number",defaultValue:2},{tfName:"T",name:"dtype",type:"dtype"}]}],kN=[{tfOpName:"EuclideanNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool",defaultValue:!1}]},{tfOpName:"FusedBatchNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV2",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV3",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"LRN",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"depth_radius",name:"radius",type:"number",defaultValue:5},{tfName:"bias",name:"bias",type:"number",defaultValue:1},{tfName:"alpha",name:"alpha",type:"number",defaultValue:1},{tfName:"beta",name:"beta",type:"number",defaultValue:.5}]},{tfOpName:"Softmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"LogSoftmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"SparseToDense",category:"normalization",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!0,notSupported:!0}]}],DN=[{tfOpName:"Bincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}]},{tfOpName:"DenseBincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}],attrs:[{tfName:"binary_output",name:"binaryOutput",type:"bool"}]},{tfOpName:"Max",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Mean",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Min",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Sum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"All",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Any",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"ArgMax",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"ArgMin",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"Prod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Cumprod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]},{tfOpName:"Cumsum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]}],TN=[{tfOpName:"ConcatV2",category:"slice_join",inputs:[{start:0,end:-1,name:"tensors",type:"tensors"},{start:-1,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"Concat",category:"slice_join",inputs:[{start:1,end:0,name:"tensors",type:"tensors"},{start:0,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"GatherV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"axis",type:"number",defaultValue:0}],attrs:[{tfName:"batch_dims",name:"batchDims",type:"number",defaultValue:0}]},{tfOpName:"Gather",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",notSupported:!0}]},{tfOpName:"Reverse",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"dims",type:"bool[]"}]},{tfOpName:"ReverseV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}]},{tfOpName:"Slice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"size",type:"number[]"}]},{tfOpName:"StridedSlice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"end",type:"number[]"},{start:3,name:"strides",type:"number[]"}],attrs:[{tfName:"begin_mask",name:"beginMask",type:"number",defaultValue:0},{tfName:"end_mask",name:"endMask",type:"number",defaultValue:0},{tfName:"new_axis_mask",name:"newAxisMask",type:"number",defaultValue:0},{tfName:"ellipsis_mask",name:"ellipsisMask",type:"number",defaultValue:0},{tfName:"shrink_axis_mask",name:"shrinkAxisMask",type:"number",defaultValue:0}]},{tfOpName:"Pack",category:"slice_join",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0}]},{tfOpName:"Unpack",category:"slice_join",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0},{tfName:"num",name:"num",type:"number",defaultValue:0,notSupported:!0}]},{tfOpName:"Tile",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"reps",type:"number[]"}]},{tfOpName:"Split",category:"slice_join",inputs:[{start:0,name:"axis",type:"number",defaultValue:0},{start:1,name:"x",type:"tensor"}],attrs:[{tfName:"num_split",name:"numOrSizeSplits",type:"number",defaultValue:1}]},{tfOpName:"SplitV",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"numOrSizeSplits",type:"number[]"},{start:2,name:"axis",type:"number",defaultValue:0}]},{tfOpName:"ScatterNd",category:"slice_join",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"shape",type:"number[]"}]},{tfOpName:"GatherNd",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}]},{tfOpName:"SparseToDense",category:"slice_join",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!1,notSupported:!0}]}],IN=[{tfOpName:"SparseFillEmptyRows",category:"sparse",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"denseShape",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}]},{tfOpName:"SparseReshape",category:"sparse",inputs:[{start:0,name:"inputIndices",type:"tensor"},{start:1,name:"inputShape",type:"tensor"},{start:2,name:"newShape",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SparseSegmentMean",category:"sparse",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"segmentIds",type:"tensor"}]},{tfOpName:"SparseSegmentSum",category:"sparse",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"segmentIds",type:"tensor"}]}],EN=[{tfOpName:"FFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"IFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"RFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"fft_length",type:"number",notSupported:!0}]},{tfOpName:"IRFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"fft_length",type:"number",notSupported:!0}]}],CN=[{tfOpName:"StringNGrams",category:"string",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"dataSplits",type:"tensor"}],attrs:[{tfName:"separator",name:"separator",type:"string"},{tfName:"ngram_widths",name:"nGramWidths",type:"number[]"},{tfName:"left_pad",name:"leftPad",type:"string"},{tfName:"right_pad",name:"rightPad",type:"string"},{tfName:"pad_width",name:"padWidth",type:"number"},{tfName:"preserve_short_sequences",name:"preserveShortSequences",type:"bool"}],outputs:["ngrams","ngrams_splits"]},{tfOpName:"StringSplit",category:"string",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"delimiter",type:"tensor"}],attrs:[{tfName:"skip_empty",name:"skipEmpty",type:"bool"}],outputs:["indices","values","shape"]},{tfOpName:"StringToHashBucketFast",category:"string",inputs:[{start:0,name:"input",type:"tensor"}],attrs:[{tfName:"num_buckets",name:"numBuckets",type:"number"}]}],AN=[{tfOpName:"Cast",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"SrcT",name:"sdtype",type:"dtype",notSupported:!0},{tfName:"DstT",name:"dtype",type:"dtype"}]},{tfOpName:"ExpandDims",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"MirrorPad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"mode",name:"mode",type:"string"}]},{tfOpName:"Pad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"constant_value",name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"PadV2",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"},{start:2,name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"Reshape",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}]},{tfOpName:"Squeeze",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"axis",tfDeprecatedName:"squeeze_dims",name:"axis",type:"number[]"}]},{tfOpName:"SpaceToBatchND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"paddings",type:"number[]"}]},{tfOpName:"BatchToSpaceND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"crops",type:"number[]"}]},{tfOpName:"DepthToSpace",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"block_size",name:"blockSize",type:"number"},{tfName:"data_format",name:"dataFormat",type:"string"}]},{tfOpName:"BroadcastTo",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}],attrs:[]},{tfOpName:"BroadcastArgs",category:"transformation",inputs:[{start:0,name:"s0",type:"tensor"},{start:1,name:"s1",type:"tensor"}],attrs:[]}];class LN{static get Instance(){return this._instance||(this._instance=new this)}constructor(){const e=[].concat(...[N,S,k,D,T,I,E,C,A,L,$,O,R,F,Y,z,B,P,H].map((e=>e.json)));this.opMappers=e.reduce(((e,t)=>(e[t.tfOpName]=t,e)),{})}transformGraph(e,t={}){const n=e.node,r=[],a=[],i=[],s=n.reduce(((e,t)=>(e[t.name]=this.mapNode(t),t.op.startsWith("Placeholder")?r.push(e[t.name]):"Const"===t.op?a.push(e[t.name]):null!=t.input&&0!==t.input.length||i.push(e[t.name]),e)),{});let o=[];const u=[];let l={},c={};null!=t&&(l=this.mapSignatureEntries(t.inputs),c=this.mapSignatureEntries(t.outputs));const p=Object.keys(s);p.forEach((e=>{const t=s[e];t.inputNames.forEach(((e,n)=>{const[r,,a]=lN(e),i=s[r];if(null!=i.outputs){const e=i.outputs.indexOf(a);if(-1!==e){const a=`${r}:${e}`;t.inputNames[n]=a}}t.inputs.push(i),i.children.push(t)}))})),0===Object.keys(c).length?p.forEach((e=>{const t=s[e];0===t.children.length&&u.push(t)})):Object.keys(c).forEach((e=>{const[t]=lN(e),n=s[t];null!=n&&(n.signatureKey=c[e],u.push(n))})),Object.keys(l).length>0?Object.keys(l).forEach((e=>{const[t]=lN(e),n=s[t];n&&(n.signatureKey=l[e],o.push(n))})):o=r;let d={};null!=e.library&&null!=e.library.function&&(d=e.library.function.reduce(((e,t)=>(e[t.signature.name]=this.mapFunction(t),e)),{}));const h={nodes:s,inputs:o,outputs:u,weights:a,placeholders:r,signature:t,functions:d};return i.length>0&&(h.initNodes=i),h}mapSignatureEntries(e){return Object.keys(e||{}).reduce(((t,n)=>(t[e[n].name]=n,t)),{})}mapNode(e){const t=iN(e.op)||this.opMappers[e.op]||{};null==e.attr&&(e.attr={});const n={name:e.name,op:e.op,category:t.category,inputNames:(e.input||[]).map((e=>e.startsWith("^")?e.slice(1):e)),inputs:[],children:[],inputParams:{},attrParams:{},rawAttrs:e.attr,outputs:t.outputs};return null!=t.inputs&&(n.inputParams=t.inputs.reduce(((e,t)=>(e[t.name]={type:t.type,inputIndexStart:t.start,inputIndexEnd:t.end},e)),{})),null!=t.attrs&&(n.attrParams=t.attrs.reduce(((t,n)=>{const r=n.type;let a;switch(n.type){case"string":a=ON(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=ON(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"string[]":a=qN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=qN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"number":a=FN(e.attr,n.tfName,n.defaultValue||0),void 0===a&&n.tfDeprecatedName&&(a=FN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"number[]":a=UN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=UN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool":a=RN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=RN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool[]":a=VN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=VN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape":a=jN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=jN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape[]":a=WN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=WN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype":a=BN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=BN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype[]":a=PN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=PN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"func":a=zN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=zN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"tensor":case"tensors":break;default:throw new Error(`Unsupported param type: ${n.type} for op: ${e.op}`)}return t[n.name]={value:a,type:r},t}),{})),n}mapFunction(e){const t=e.nodeDef,n=[];let r={};null!=t&&(r=t.reduce(((e,t)=>(e[t.name]=this.mapNode(t),"Const"===t.op&&n.push(e[t.name]),e)),{}));const a=[],i=[];e.signature.inputArg.forEach((e=>{const[t]=lN(e.name),n={name:t,op:"Placeholder",inputs:[],inputNames:[],category:"graph",inputParams:{},attrParams:{dtype:{value:YN(e.type),type:"dtype"}},children:[]};n.signatureKey=e.name,a.push(n),r[t]=n})),Object.keys(r).forEach((e=>{const t=r[e];t.inputNames.forEach(((e,n)=>{const[a,,i]=lN(e),s=r[a];if(null!=s.outputs){const e=s.outputs.indexOf(i);if(-1!==e){const r=`${a}:${e}`;t.inputNames[n]=r}}t.inputs.push(s),s.children.push(t)}))}));const s=e.ret;e.signature.outputArg.forEach((e=>{const[t,n]=lN(s[e.name]),a=r[t];null!=a&&(a.defaultOutput=n,i.push(a))}));const o=this.mapArgsToSignature(e);return{nodes:r,inputs:a,outputs:i,weights:n,placeholders:[],signature:o}}mapArgsToSignature(e){return{methodName:e.signature.name,inputs:e.signature.inputArg.reduce(((e,t)=>(e[t.name]=this.mapArgToTensorInfo(t),e)),{}),outputs:e.signature.outputArg.reduce(((t,n)=>(t[n.name]=this.mapArgToTensorInfo(n,e.ret),t)),{})}}mapArgToTensorInfo(e,t){let n=e.name;return null!=t&&(n=t[n]),{name:n,dtype:e.type}}}function $N(e,t){const n=Array.isArray(e)?String.fromCharCode.apply(null,e):function(e){const t=Ge().global;if(void 0!==t.atob)return t.atob(e);if("undefined"!=typeof Buffer)return new Buffer(e,"base64").toString();throw new Error("Unable to decode base64 in this environment. Missing built-in atob() or Buffer()")}(e);return t?n:n.toLowerCase()}function ON(e,t,n,r=!1){const a=e[t];return null!=a?$N(a.s,r):n}function RN(e,t,n){const r=e[t];return r?r.b:n}function FN(e,t,n){const r=e[t]||{},a=null!=r.i?r.i:null!=r.f?r.f:n;return"number"==typeof a?a:parseInt(a,10)}function YN(e){switch("string"==typeof e&&(e=tN[e]),e){case tN.DT_FLOAT:case tN.DT_HALF:return"float32";case tN.DT_INT32:case tN.DT_INT64:case tN.DT_INT8:case tN.DT_UINT8:return"int32";case tN.DT_BOOL:return"bool";case tN.DT_DOUBLE:return"float32";case tN.DT_STRING:return"string";default:return null}}function zN(e,t,n){const r=e[t];return r&&r.func?r.func.name:n}function BN(e,t,n){const r=e[t];return r&&r.type?YN(r.type):n}function PN(e,t,n){const r=e[t];return r&&r.list&&r.list.type?r.list.type.map((e=>YN(e))):n}function HN(e){if(!e.unknownRank)return null!=e.dim?e.dim.map((e=>"number"==typeof e.size?e.size:parseInt(e.size,10))):[]}function jN(e,t,n){const r=e[t];return r&&r.shape?HN(r.shape):n}function UN(e,t,n){const r=e[t];return r?((r.list.f&&r.list.f.length?r.list.f:r.list.i)||[]).map((e=>"number"==typeof e?e:parseInt(e,10))):n}function qN(e,t,n,r=!1){const a=e[t];return a&&a.list&&a.list.s?a.list.s.map((e=>$N(e,r))):n}function WN(e,t,n){const r=e[t];return r&&r.list&&r.list.shape?r.list.shape.map((e=>HN(e))):n}function VN(e,t,n){const r=e[t];return r&&r.list&&r.list.b?r.list.b:n}class GN{constructor(e,t,n){this.node=e,this.tensorMap=t,this.context=n,this.inputs=[],this.attrs={},this.inputs=e.inputNames.map((e=>this.getInput(e))),null!=e.rawAttrs&&(this.attrs=Object.keys(e.rawAttrs).reduce(((e,t)=>(e[t]=this.getAttr(t),e)),{}))}getInput(e){return uN(e,this.tensorMap,this.context)}getAttr(e,t){const n=this.node.rawAttrs[e];if(null!=n.tensor)return uN(e,this.tensorMap,this.context);if(null!=n.i||null!=n.f)return FN(this.node.rawAttrs,e,t);if(null!=n.s)return ON(this.node.rawAttrs,e,t);if(null!=n.b)return RN(this.node.rawAttrs,e,t);if(null!=n.shape)return jN(this.node.rawAttrs,e,t);if(null!=n.type)return BN(this.node.rawAttrs,e,t);if(null!=n.list){if(null!=n.list.i||null!=n.list.f)return UN(this.node.rawAttrs,e,t);if(null!=n.list.s)return qN(this.node.rawAttrs,e,t);if(null!=n.list.shape)return WN(this.node.rawAttrs,e,t);if(null!=n.list.b)return VN(this.node.rawAttrs,e,t);if(null!=n.list.type)return PN(this.node.rawAttrs,e,t)}return t}}function KN(e,t,n=""){if("number"!=typeof e&&"number"!=typeof t){se(e.length===t.length,(()=>n+` Shapes ${e} and ${t} must match`));for(let r=0;rn+` Shapes ${e} and ${t} must match`))}}}function JN(e){return"number"!=typeof e&&!e.some((e=>e<0))}function XN(e,t,n){let r=ZN(e,n);const a=!JN(r);if(a&&0===t.length)throw new Error(`Tried to calculate elements of an empty list with non-fully-defined elementShape: ${r}`);if(a&&t.forEach((e=>{r=ZN(e.shape,r)})),!JN(r))throw new Error(`Non-fully-defined elementShape: ${r}`);return r}function ZN(e,t){if("number"==typeof e)return t;if("number"==typeof t)return e;if(e.length!==t.length)throw new Error(`Incompatible ranks during merge: ${e} vs. ${t}`);const n=[];for(let r=0;r=0&&i>=0&&a!==i)throw new Error(`Incompatible shape during merge: ${e} vs. ${t}`);n[r]=a>=0?a:i}return n}class QN{constructor(e,t,n,r,a,i,s){this.name=e,this.dtype=t,this.maxSize=n,this.elementShape=r,this.identicalElementShapes=a,this.dynamicSize=i,this.clearAfterRead=s,this.tensors=[],this.closed_=!1,this.idTensor=Ru(0),mo(this.idTensor)}get id(){return this.idTensor.id}get closed(){return this.closed_}clearAndClose(e){this.tensors.forEach((t=>{null!=e&&e.has(t.tensor.id)||t.tensor.dispose()})),this.tensors=[],this.closed_=!0,this.idTensor.dispose()}size(){return this.tensors.length}read(e){if(this.closed_)throw new Error(`TensorArray ${this.name} has already been closed.`);if(e<0||e>=this.size())throw new Error(`Tried to read from index ${e}, but array size is: ${this.size()}`);const t=this.tensors[e];if(t.cleared)throw new Error(`TensorArray ${this.name}: Could not read index ${e} twice because it was cleared after a previous read (perhaps try setting clear_after_read = false?).`);return this.clearAfterRead&&(t.cleared=!0),t.read=!0,t.tensor}readMany(e){return e.map((e=>this.read(e)))}write(e,t){if(this.closed_)throw new Error(`TensorArray ${this.name} has already been closed.`);if(e<0||!this.dynamicSize&&e>=this.maxSize)throw new Error(`Tried to write to index ${e}, but array is not resizeable and size is: ${this.maxSize}`);const n=this.tensors[e]||{};if(t.dtype!==this.dtype)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e},\n because the value dtype is ${t.dtype}, but TensorArray dtype is ${this.dtype}.`);if(0!==this.size()||null!=this.elementShape&&0!==this.elementShape.length||(this.elementShape=t.shape),KN(this.elementShape,t.shape,`TensorArray ${this.name}: Could not write to TensorArray index ${e}.`),n.read)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been read.`);if(n.written)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been written.`);n.tensor=t,mo(t),n.written=!0,this.tensors[e]=n}writeMany(e,t){if(e.length!==t.length)throw new Error(`TensorArray ${this.name}: could not write multiple tensors,because the index size: ${e.length} is not the same as tensors size: ${t.length}.`);e.forEach(((e,n)=>this.write(e,t[n])))}gather(e,t){if(t&&t!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but gather requested dtype ${t}`);if(e)e=e.slice(0,this.size());else{e=[];for(let t=0;t=this.maxSize)throw new Error(`Max index must be < array size (${n} vs. ${this.maxSize})`);this.writeMany(e,kd(t,0))}split(e,t){if(t.dtype!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${t.dtype}`);let n=0;const r=e.map((e=>(n+=e,n)));if(n!==t.shape[0])throw new Error(`Expected sum of lengths to be equal to\n tensor.shape[0], but sum of lengths is\n ${n}, and tensor's shape is: ${t.shape}`);if(!this.dynamicSize&&e.length!==this.maxSize)throw new Error(`TensorArray's size is not equal to the size of lengths (${this.maxSize} vs. ${e.length}), and the TensorArray is not marked as dynamically resizeable`);const a=0===n?0:t.size/n,i=[];ho((()=>{t=Ml(t,[1,n,a]);for(let n=0;n{if(n!==e.dtype)throw new Error(`Invalid data types; op elements ${n}, but list elements ${e.dtype}`);KN(t,e.shape,"TensorList shape mismatch: "),mo(e)})),this.idTensor=Ru(0),this.maxNumElements=r,mo(this.idTensor)}get id(){return this.idTensor.id}copy(){return new eS([...this.tensors],this.elementShape,this.elementDtype)}clearAndClose(e){this.tensors.forEach((t=>{null!=e&&e.has(t.id)||t.dispose()})),this.tensors.length=0,this.idTensor.dispose()}size(){return this.tensors.length}stack(e,t,n=-1){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);if(-1!==n&&this.tensors.length!==n)throw new Error(`Operation expected a list with ${n} elements but got a list with ${this.tensors.length} elements.`);KN(e,this.elementShape,"TensorList shape mismatch: ");const r=XN(this.elementShape,this.tensors,e);return ho((()=>{const e=this.tensors.map((e=>Ml(e,r)));return hd(e,0)}))}popBack(e,t){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);if(0===this.size())throw new Error("Trying to pop from an empty list.");const n=XN(this.elementShape,this.tensors,e),r=this.tensors.pop();return KN(r.shape,e,"TensorList shape mismatch: "),Ml(r,n)}pushBack(e){if(e.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${this.elementDtype}`);if(KN(e.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw new Error("Trying to push element into a full list.");mo(e),this.tensors.push(e)}resize(e){if(e<0)throw new Error(`TensorListResize expects size to be non-negative. Got: ${e}`);if(-1!==this.maxNumElements&&e>this.maxNumElements)throw new Error(`TensorListResize input size ${e} is greater maxNumElement ${this.maxNumElements}.`);const t=new eS([],this.elementShape,this.elementDtype,this.maxNumElements);t.tensors.length=e;for(let n=0;nthis.tensors.length)throw new Error(`Trying to access element ${e} in a list with ${this.tensors.length} elements.`);if(null==this.tensors[e])throw new Error(`element at index ${e} is null.`);KN(this.tensors[e].shape,t,"TensorList shape mismatch: ");const r=XN(this.elementShape,this.tensors,t);return Ml(this.tensors[e],r)}setItem(e,t){if(t.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t.dtype}, but list elements ${this.elementDtype}`);if(e<0||-1!==this.maxNumElements&&e>=this.maxNumElements)throw new Error(`Trying to set element ${e} in a list with max ${this.maxNumElements} elements.`);KN(this.elementShape,t.shape,"TensorList shape mismatch: "),mo(t),this.tensors[e]=t}gather(e,t,n){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);KN(this.elementShape,n,"TensorList shape mismatch: "),e=e.slice(0,this.size());const r=XN(this.elementShape,this.tensors,n);return 0===e.length?Fi([],[0].concat(r)):ho((()=>{const t=e.map((e=>Ml(this.tensors[e],r)));return hd(t,0)}))}concat(e,t){if(e&&e!==this.elementDtype)throw new Error(`TensorList dtype is ${this.elementDtype} but concat requested dtype ${e}`);KN(this.elementShape,t,"TensorList shape mismatch: ");const n=XN(this.elementShape,this.tensors,t);return 0===this.size()?Fi([],[0].concat(n)):ho((()=>{const e=this.tensors.map((e=>Ml(e,n)));return kl(e,0)}))}}function tS(e,t,n){const[r,a]=oN("fusedOps",e,t,n),i="biasadd"===r,s=!i,o="prelu"===a,u="fusedbatchnorm"===r,l=oN("numArgs",e,t,n);if(i){if(o&&2!==l)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!o&&i&&1!==l)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias.")}if(u)throw new Error("FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported");const c=oN("strides",e,t,n),p=dN(e,t,n),d=oN("dataFormat",e,t,n).toUpperCase(),h=oN("dilations",e,t,n);let[f,m]=oN("args",e,t,n);return s&&(m=f,f=void 0),{stride:c,pad:p,dataFormat:d,dilations:h,biasArg:f,preluArg:m,activationFunc:a,leakyreluAlpha:oN("leakyreluAlpha",e,t,n)}}function nS(e,t,n){return{boxes:oN("boxes",e,t,n),scores:oN("scores",e,t,n),maxOutputSize:oN("maxOutputSize",e,t,n),iouThreshold:oN("iouThreshold",e,t,n),scoreThreshold:oN("scoreThreshold",e,t,n),softNmsSigma:oN("softNmsSigma",e,t,n)}}class rS{constructor(e,t){this.keyDType=e,this.valueDType=t,this.handle=Ru(0),this.tensorMap=new Map,mo(this.handle)}get id(){return this.handle.id}clearAndClose(){this.tensorMap.forEach((e=>e.dispose())),this.tensorMap.clear(),this.handle.dispose()}size(){return this.tensorMap.size}tensorSize(){return Ru(this.size(),"int32")}async import(e,t){this.checkKeyAndValueTensor(e,t);const n=await e.data();return this.tensorMap.forEach((e=>e.dispose())),this.tensorMap.clear(),ho((()=>{const e=kd(t),r=n.length,a=e.length;se(r===a,(()=>`The number of elements doesn't match, keys has ${r} elements, the values has ${a} elements.`));for(let t=0;t{const e=[];for(let r=0;r{switch(e.category){case"arithmetic":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"BiasAdd":case"AddV2":case"Add":return[r.add(oN("a",e,t,n),oN("b",e,t,n))];case"AddN":return[r.addN(oN("tensors",e,t,n))];case"FloorMod":case"Mod":return[r.mod(oN("a",e,t,n),oN("b",e,t,n))];case"Mul":return[r.mul(oN("a",e,t,n),oN("b",e,t,n))];case"RealDiv":case"Div":return[r.div(oN("a",e,t,n),oN("b",e,t,n))];case"DivNoNan":return[r.divNoNan(oN("a",e,t,n),oN("b",e,t,n))];case"FloorDiv":return[r.floorDiv(oN("a",e,t,n),oN("b",e,t,n))];case"Sub":return[r.sub(oN("a",e,t,n),oN("b",e,t,n))];case"Minimum":return[r.minimum(oN("a",e,t,n),oN("b",e,t,n))];case"Maximum":return[r.maximum(oN("a",e,t,n),oN("b",e,t,n))];case"Pow":return[r.pow(oN("a",e,t,n),oN("b",e,t,n))];case"SquaredDifference":return[r.squaredDifference(oN("a",e,t,n),oN("b",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"basic_math":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"Abs":case"ComplexAbs":return[r.abs(oN("x",e,t,n))];case"Acos":return[r.acos(oN("x",e,t,n))];case"Acosh":return[r.acosh(oN("x",e,t,n))];case"Asin":return[r.asin(oN("x",e,t,n))];case"Asinh":return[r.asinh(oN("x",e,t,n))];case"Atan":return[r.atan(oN("x",e,t,n))];case"Atan2":return[r.atan2(oN("x",e,t,n),oN("y",e,t,n))];case"Atanh":return[r.atanh(oN("x",e,t,n))];case"Ceil":return[r.ceil(oN("x",e,t,n))];case"Complex":return[r.complex(oN("real",e,t,n),oN("imag",e,t,n))];case"Cos":return[r.cos(oN("x",e,t,n))];case"Cosh":return[r.cosh(oN("x",e,t,n))];case"Elu":return[r.elu(oN("x",e,t,n))];case"Erf":return[r.erf(oN("x",e,t,n))];case"Exp":return[r.exp(oN("x",e,t,n))];case"Expm1":return[r.expm1(oN("x",e,t,n))];case"Floor":return[r.floor(oN("x",e,t,n))];case"Log":return[r.log(oN("x",e,t,n))];case"Log1p":return[r.log1p(oN("x",e,t,n))];case"Imag":return[r.imag(oN("x",e,t,n))];case"Neg":return[r.neg(oN("x",e,t,n))];case"Reciprocal":return[r.reciprocal(oN("x",e,t,n))];case"Real":return[r.real(oN("x",e,t,n))];case"Relu":return[r.relu(oN("x",e,t,n))];case"Round":return[r.round(oN("x",e,t,n))];case"Selu":return[r.selu(oN("x",e,t,n))];case"Sigmoid":return[r.sigmoid(oN("x",e,t,n))];case"Sin":return[r.sin(oN("x",e,t,n))];case"Sign":return[r.sign(oN("x",e,t,n))];case"Sinh":return[r.sinh(oN("x",e,t,n))];case"Softplus":return[r.softplus(oN("x",e,t,n))];case"Sqrt":return[r.sqrt(oN("x",e,t,n))];case"Square":return[r.square(oN("x",e,t,n))];case"Tanh":return[r.tanh(oN("x",e,t,n))];case"Tan":return[r.tan(oN("x",e,t,n))];case"ClipByValue":return[r.clipByValue(oN("x",e,t,n),oN("clipValueMin",e,t,n),oN("clipValueMax",e,t,n))];case"Relu6":return[r.relu6(oN("x",e,t,n))];case"Rsqrt":return[r.rsqrt(uN(e.inputNames[0],t,n))];case"Prod":return[r.prod(oN("x",e,t,n),oN("axes",e,t,n))];case"LeakyRelu":return[r.leakyRelu(oN("x",e,t,n),oN("alpha",e,t,n))];case"Prelu":return[r.prelu(oN("x",e,t,n),oN("alpha",e,t,n))];case"IsNan":return[r.isNaN(uN(e.inputNames[0],t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"control":return(async(e,t,n)=>{switch(e.op){case"If":case"StatelessIf":{const r=oN("thenBranch",e,t,n),a=oN("elseBranch",e,t,n),i=oN("cond",e,t,n),s=oN("args",e,t,n);return(await i.data())[0]?n.functionMap[r].executeFunctionAsync(s,n.tensorArrayMap,n.tensorListMap):n.functionMap[a].executeFunctionAsync(s,n.tensorArrayMap,n.tensorListMap)}case"While":case"StatelessWhile":{const r=oN("body",e,t,n),a=oN("cond",e,t,n),i=oN("args",e,t,n),s=await n.functionMap[a].executeFunctionAsync(i,n.tensorArrayMap,n.tensorListMap),o=i.map((e=>e.id));let u=await s[0].data();s.forEach((e=>{e.kept||-1!==o.indexOf(e.id)||e.dispose()}));let l=i;for(;u[0];){const e=l;l=await n.functionMap[r].executeFunctionAsync(l,n.tensorArrayMap,n.tensorListMap);const t=l.map((e=>e.id));e.forEach((e=>{e.kept||-1!==o.indexOf(e.id)||-1!==t.indexOf(e.id)||e.dispose()}));const i=await n.functionMap[a].executeFunctionAsync(l,n.tensorArrayMap,n.tensorListMap);u=await i[0].data(),i.forEach((e=>{e.kept||-1!==o.indexOf(e.id)||-1!==t.indexOf(e.id)||e.dispose()}))}return l}case"LoopCond":return[hN(oN("pred",e,t,n))];case"Switch":{const r=oN("pred",e,t,n);let a=oN("data",e,t,n);return a.kept||(a=hN(a)),(await r.data())[0]?[void 0,a]:[a,void 0]}case"Merge":{const r=e.inputNames.find((e=>void 0!==uN(e,t,n)));return r?[hN(uN(r,t,n))]:void 0}case"Enter":{const r=oN("frameName",e,t,n),a=oN("tensor",e,t,n);return n.enterFrame(r),[hN(a)]}case"Exit":{const r=oN("tensor",e,t,n);return n.exitFrame(),[hN(r)]}case"NextIteration":{const r=oN("tensor",e,t,n);return n.nextIteration(),[hN(r)]}case"TensorArrayV3":{const r=oN("size",e,t,n),a=oN("dtype",e,t,n),i=oN("elementShape",e,t,n),s=oN("dynamicSize",e,t,n),o=oN("clearAfterRead",e,t,n),u=oN("identicalElementShapes",e,t,n),l=oN("name",e,t,n),c=new QN(l,a,r,i,u,s,o);return n.addTensorArray(c),[c.idTensor,Ru(1)]}case"TensorArrayWriteV3":{const r=oN("tensorArrayId",e,t,n),a=oN("index",e,t,n),i=oN("tensor",e,t,n),s=n.getTensorArray(r.id);return s.write(a,i),[s.idTensor]}case"TensorArrayReadV3":{const r=oN("tensorArrayId",e,t,n),a=oN("index",e,t,n);return[n.getTensorArray(r.id).read(a)]}case"TensorArrayGatherV3":{const r=oN("tensorArrayId",e,t,n),a=oN("indices",e,t,n),i=oN("dtype",e,t,n);return[n.getTensorArray(r.id).gather(a,i)]}case"TensorArrayScatterV3":{const r=oN("tensorArrayId",e,t,n),a=oN("indices",e,t,n),i=oN("tensor",e,t,n),s=n.getTensorArray(r.id);return s.scatter(a,i),[s.idTensor]}case"TensorArrayConcatV3":{const r=oN("tensorArrayId",e,t,n),a=n.getTensorArray(r.id),i=oN("dtype",e,t,n);return[a.concat(i)]}case"TensorArraySplitV3":{const r=oN("tensorArrayId",e,t,n),a=oN("tensor",e,t,n),i=oN("lengths",e,t,n),s=n.getTensorArray(r.id);return s.split(i,a),[s.idTensor]}case"TensorArraySizeV3":{const r=oN("tensorArrayId",e,t,n);return[Ru(n.getTensorArray(r.id).size(),"int32")]}case"TensorArrayCloseV3":{const r=oN("tensorArrayId",e,t,n),a=n.getTensorArray(r.id);return a.clearAndClose(),[a.idTensor]}case"TensorListSetItem":{const r=oN("tensorListId",e,t,n),a=oN("index",e,t,n),i=oN("tensor",e,t,n),s=n.getTensorList(r.id);return s.setItem(a,i),[s.idTensor]}case"TensorListGetItem":{const r=oN("tensorListId",e,t,n),a=oN("index",e,t,n),i=oN("elementShape",e,t,n),s=oN("elementDType",e,t,n);return[n.getTensorList(r.id).getItem(a,i,s)]}case"TensorListScatterV2":case"TensorListScatter":{const r=oN("indices",e,t,n),a=function(e,t,n,r){if(t.length!==e.shape[0])throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${t.length} vs. ${e.shape[0]}`);const a=Math.max(...t);if(null!=r&&-1!==r&&a>=r)throw new Error(`Max index must be < array size (${a} vs. ${r})`);const i=new eS([],n,e.dtype,r),s=kd(e,0);return t.forEach(((e,t)=>{i.setItem(e,s[t])})),i}(oN("tensor",e,t,n),r,oN("elementShape",e,t,n),oN("numElements",e,t,n));return n.addTensorList(a),[a.idTensor]}case"TensorListReserve":case"EmptyTensorList":{const r=oN("elementShape",e,t,n),a=oN("elementDType",e,t,n);let i;i="TensorListReserve"===e.op?"numElements":"maxNumElements";const s=oN(i,e,t,n),o=function(e,t,n,r){return new eS([],e,t,r)}(r,a,0,"TensorListReserve"===e.op?-1:s);return n.addTensorList(o),[o.idTensor]}case"TensorListGather":{const r=oN("tensorListId",e,t,n),a=oN("indices",e,t,n),i=oN("elementShape",e,t,n),s=oN("elementDType",e,t,n);return[n.getTensorList(r.id).gather(a,s,i)]}case"TensorListStack":{const r=oN("tensorListId",e,t,n),a=oN("elementShape",e,t,n),i=oN("elementDType",e,t,n),s=oN("numElements",e,t,n);return[n.getTensorList(r.id).stack(a,i,s)]}case"TensorListFromTensor":{const r=function(e,t,n){const r=e.dtype;if(e.shape.length<1)throw new Error(`Tensor must be at least a vector, but saw shape: ${e.shape}`);if(e.dtype!==n)throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${n}`);KN(e.shape.slice(1),t,"TensorList shape mismatch: ");const a=kd(e);return new eS(a,t,r)}(oN("tensor",e,t,n),oN("elementShape",e,t,n),oN("elementDType",e,t,n));return n.addTensorList(r),[r.idTensor]}case"TensorListConcat":case"TensorListConcatV2":{const r=oN("tensorListId",e,t,n),a=n.getTensorList(r.id),i=oN("dtype",e,t,n),s=oN("elementShape",e,t,n);return[a.concat(i,s)]}case"TensorListPushBack":{const r=oN("tensorListId",e,t,n),a=oN("tensor",e,t,n),i=n.getTensorList(r.id);return i.pushBack(a),[i.idTensor]}case"TensorListPopBack":{const r=oN("tensorListId",e,t,n),a=oN("elementShape",e,t,n),i=oN("elementDType",e,t,n);return[n.getTensorList(r.id).popBack(a,i)]}case"TensorListSplit":{const r=oN("tensor",e,t,n),a=oN("elementShape",e,t,n),i=function(e,t,n){let r=0;const a=t.map((e=>(r+=e,r)));if(r!==e.shape[0])throw new Error(`Expected sum of lengths to be equal to\n tensor.shape[0], but sum of lengths is\n ${r}, and tensor's shape is: ${e.shape}`);const i=ZN(e.shape.slice(1),n),s=0===r?0:e.size/r,o=ho((()=>{const n=[];e=Ml(e,[1,r,s]);for(let r=0;r((e,t,n,r=j)=>{switch(e.op){case"Conv1D":{const a=oN("stride",e,t,n),i=oN("pad",e,t,n),s=oN("dataFormat",e,t,n).toUpperCase(),o=oN("dilation",e,t,n);return[r.conv1d(oN("x",e,t,n),oN("filter",e,t,n),a,i,s,o)]}case"Conv2D":{const a=oN("strides",e,t,n),i=dN(e,t,n),s=oN("dataFormat",e,t,n).toUpperCase(),o=oN("dilations",e,t,n);return[r.conv2d(oN("x",e,t,n),oN("filter",e,t,n),[a[1],a[2]],i,s,[o[1],o[2]])]}case"_FusedConv2D":{const{stride:a,pad:i,dataFormat:s,dilations:o,biasArg:u,preluArg:l,activationFunc:c,leakyreluAlpha:p}=tS(e,t,n);return[r.fused.conv2d({x:oN("x",e,t,n),filter:oN("filter",e,t,n),strides:[a[1],a[2]],pad:i,dataFormat:s,dilations:[o[1],o[2]],bias:u,activation:c,preluActivationWeights:l,leakyreluAlpha:p})]}case"FusedDepthwiseConv2dNative":{const{stride:a,pad:i,dataFormat:s,dilations:o,biasArg:u,preluArg:l,activationFunc:c,leakyreluAlpha:p}=tS(e,t,n);return[r.fused.depthwiseConv2d({x:oN("x",e,t,n),filter:oN("filter",e,t,n),strides:[a[1],a[2]],pad:i,dataFormat:s,dilations:[o[1],o[2]],bias:u,activation:c,preluActivationWeights:l,leakyreluAlpha:p})]}case"Conv2DBackpropInput":case"Conv2dTranspose":{const a=oN("outputShape",e,t,n),i=oN("strides",e,t,n),s=dN(e,t,n);return[r.conv2dTranspose(oN("x",e,t,n),oN("filter",e,t,n),a,[i[1],i[2]],s)]}case"DepthwiseConv2dNative":case"DepthwiseConv2d":{const a=oN("strides",e,t,n),i=dN(e,t,n),s=oN("dilations",e,t,n),o=oN("dataFormat",e,t,n).toUpperCase();return[r.depthwiseConv2d(oN("input",e,t,n),oN("filter",e,t,n),[a[1],a[2]],i,o,[s[1],s[2]])]}case"Conv3D":{const a=oN("strides",e,t,n),i=oN("pad",e,t,n),s=oN("dataFormat",e,t,n).toUpperCase(),o=oN("dilations",e,t,n);return[r.conv3d(oN("x",e,t,n),oN("filter",e,t,n),[a[1],a[2],a[3]],i,s,[o[1],o[2],o[3]])]}case"AvgPool":{const a=oN("strides",e,t,n),i=oN("pad",e,t,n),s=oN("kernelSize",e,t,n);return[r.avgPool(oN("x",e,t,n),[s[1],s[2]],[a[1],a[2]],i)]}case"MaxPool":{const a=oN("strides",e,t,n),i=oN("pad",e,t,n),s=oN("kernelSize",e,t,n);return[r.maxPool(oN("x",e,t,n),[s[1],s[2]],[a[1],a[2]],i)]}case"MaxPoolWithArgmax":{const a=oN("strides",e,t,n),i=oN("pad",e,t,n),s=oN("kernelSize",e,t,n),o=oN("includeBatchInIndex",e,t,n),{result:u,indexes:l}=r.maxPoolWithArgmax(oN("x",e,t,n),[s[1],s[2]],[a[1],a[2]],i,o);return[u,l]}case"AvgPool3D":{const a=oN("strides",e,t,n),i=oN("pad",e,t,n),s=oN("kernelSize",e,t,n);return[r.avgPool3d(oN("x",e,t,n),[s[1],s[2],s[3]],[a[1],a[2],a[3]],i)]}case"MaxPool3D":{const a=oN("strides",e,t,n),i=oN("pad",e,t,n),s=oN("kernelSize",e,t,n);return[r.maxPool3d(oN("x",e,t,n),[s[1],s[2],s[3]],[a[1],a[2],a[3]],i)]}case"Dilation2D":{const a=oN("strides",e,t,n),i=oN("pad",e,t,n),s=oN("dilations",e,t,n),o=a[1],u=a[2],l=s[1],c=s[2];return[r.dilation2d(oN("x",e,t,n),oN("filter",e,t,n),[o,u],i,[l,c],"NHWC")]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"creation":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"Fill":{const a=oN("shape",e,t,n),i=oN("dtype",e,t,n),s=oN("value",e,t,n);return[r.fill(a,s,i)]}case"LinSpace":{const a=oN("start",e,t,n),i=oN("stop",e,t,n),s=oN("num",e,t,n);return[r.linspace(a,i,s)]}case"Multinomial":{const a=oN("logits",e,t,n),i=oN("numSamples",e,t,n),s=oN("seed",e,t,n);return[r.multinomial(a,i,s)]}case"OneHot":{const a=oN("indices",e,t,n),i=oN("depth",e,t,n),s=oN("onValue",e,t,n),o=oN("offValue",e,t,n);return[r.oneHot(a,i,s,o)]}case"Ones":return[r.ones(oN("shape",e,t,n),oN("dtype",e,t,n))];case"OnesLike":return[r.onesLike(oN("x",e,t,n))];case"RandomStandardNormal":return[r.randomStandardNormal(oN("shape",e,t,n),oN("dtype",e,t,n),oN("seed",e,t,n))];case"RandomUniform":return[r.randomUniform(oN("shape",e,t,n),oN("minval",e,t,n),oN("maxval",e,t,n),oN("dtype",e,t,n))];case"Range":{const a=oN("start",e,t,n),i=oN("stop",e,t,n),s=oN("step",e,t,n);return[r.range(a,i,s,oN("dtype",e,t,n))]}case"TruncatedNormal":{const a=oN("shape",e,t,n),i=oN("mean",e,t,n),s=oN("stdDev",e,t,n),o=oN("seed",e,t,n);return[r.truncatedNormal(a,i,s,oN("dtype",e,t,n),o)]}case"Zeros":return[r.zeros(oN("shape",e,t,n),oN("dtype",e,t,n))];case"ZerosLike":return[r.zerosLike(oN("x",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"dynamic":return(async(e,t,n,r,a=j)=>{switch(e.op){case"NonMaxSuppressionV5":{const{boxes:r,scores:i,maxOutputSize:s,iouThreshold:o,scoreThreshold:u,softNmsSigma:l}=nS(e,t,n),c=await a.image.nonMaxSuppressionWithScoreAsync(r,i,s,o,u,l);return[c.selectedIndices,c.selectedScores]}case"NonMaxSuppressionV4":{const{boxes:r,scores:i,maxOutputSize:s,iouThreshold:o,scoreThreshold:u}=nS(e,t,n),l=oN("padToMaxOutputSize",e,t,n),c=await a.image.nonMaxSuppressionPaddedAsync(r,i,s,o,u,l);return[c.selectedIndices,c.validOutputs]}case"NonMaxSuppressionV3":case"NonMaxSuppressionV2":{const{boxes:r,scores:i,maxOutputSize:s,iouThreshold:o,scoreThreshold:u}=nS(e,t,n);return[await a.image.nonMaxSuppressionAsync(r,i,s,o,u)]}case"Where":{const r=a.cast(oN("condition",e,t,n),"bool"),i=[await a.whereAsync(r)];return r.dispose(),i}case"ListDiff":return a.setdiff1dAsync(oN("x",e,t,n),oN("y",e,t,n));default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n);case"evaluation":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"LowerBound":{const a=oN("sortedSequence",e,t,n),i=oN("values",e,t,n);return[r.lowerBound(a,i)]}case"TopKV2":{const a=oN("x",e,t,n),i=oN("k",e,t,n),s=oN("sorted",e,t,n),o=r.topk(a,i,s);return[o.values,o.indices]}case"UpperBound":{const a=oN("sortedSequence",e,t,n),i=oN("values",e,t,n);return[r.upperBound(a,i)]}case"Unique":{const a=oN("x",e,t,n),i=r.unique(a);return[i.values,i.indices]}case"UniqueV2":{const a=oN("x",e,t,n),i=oN("axis",e,t,n),s=r.unique(a,i);return[s.values,s.indices]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"image":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"ResizeBilinear":{const a=oN("images",e,t,n),i=oN("size",e,t,n),s=oN("alignCorners",e,t,n),o=oN("halfPixelCenters",e,t,n);return[r.image.resizeBilinear(a,[i[0],i[1]],s,o)]}case"ResizeNearestNeighbor":{const a=oN("images",e,t,n),i=oN("size",e,t,n),s=oN("alignCorners",e,t,n),o=oN("halfPixelCenters",e,t,n);return[r.image.resizeNearestNeighbor(a,[i[0],i[1]],s,o)]}case"CropAndResize":{const a=oN("image",e,t,n),i=oN("boxes",e,t,n),s=oN("boxInd",e,t,n),o=oN("cropSize",e,t,n),u=oN("method",e,t,n),l=oN("extrapolationValue",e,t,n);return[r.image.cropAndResize(a,i,s,o,u,l)]}case"ImageProjectiveTransformV3":{const a=oN("images",e,t,n),i=oN("transforms",e,t,n),s=oN("outputShape",e,t,n),o=oN("fillValue",e,t,n),u=oN("interpolation",e,t,n),l=oN("fillMode",e,t,n);return[r.image.transform(a,i,u.toLowerCase(),l.toLowerCase(),o,s)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"graph":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"Const":return t[e.name];case"PlaceholderWithDefault":const a=oN("default",e,t,n);return[uN(e.name,t,n)||a];case"Placeholder":return[uN(e.name,t,n)];case"Identity":case"StopGradient":case"FakeQuantWithMinMaxVars":case"Snapshot":return[hN(oN("x",e,t,n))];case"IdentityN":return oN("x",e,t,n).map((e=>hN(e)));case"Shape":return[r.tensor1d(oN("x",e,t,n).shape,"int32")];case"ShapeN":return oN("x",e,t,n).map((e=>r.tensor1d(e.shape)));case"Size":return[r.scalar(oN("x",e,t,n).size,"int32")];case"Rank":return[r.scalar(oN("x",e,t,n).rank,"int32")];case"NoOp":return[r.scalar(1)];case"Print":const i=oN("x",e,t,n),s=oN("data",e,t,n),o=oN("message",e,t,n),u=oN("summarize",e,t,n);console.warn("The graph has a tf.print() operation,usually used for debugging, which slows down performance."),console.log(o);for(let e=0;e((e,t,n,r=j)=>{switch(e.op){case"Equal":return[r.equal(oN("a",e,t,n),oN("b",e,t,n))];case"NotEqual":return[r.notEqual(oN("a",e,t,n),oN("b",e,t,n))];case"Greater":return[r.greater(oN("a",e,t,n),oN("b",e,t,n))];case"GreaterEqual":return[r.greaterEqual(oN("a",e,t,n),oN("b",e,t,n))];case"Less":return[r.less(oN("a",e,t,n),oN("b",e,t,n))];case"LessEqual":return[r.lessEqual(oN("a",e,t,n),oN("b",e,t,n))];case"LogicalAnd":return[r.logicalAnd(oN("a",e,t,n),oN("b",e,t,n))];case"LogicalNot":return[r.logicalNot(oN("a",e,t,n))];case"LogicalOr":return[r.logicalOr(oN("a",e,t,n),oN("b",e,t,n))];case"Select":case"SelectV2":return[r.where(oN("condition",e,t,n),oN("a",e,t,n),oN("b",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"matrices":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"BatchMatMul":case"BatchMatMulV2":case"MatMul":return[r.matMul(oN("a",e,t,n),oN("b",e,t,n),oN("transposeA",e,t,n),oN("transposeB",e,t,n))];case"Einsum":return[r.einsum(oN("equation",e,t,n),...oN("tensors",e,t,n))];case"Transpose":return[r.transpose(oN("x",e,t,n),oN("perm",e,t,n))];case"_FusedMatMul":const[a,i]=oN("fusedOps",e,t,n),s="biasadd"===a,o="prelu"===i,u=oN("numArgs",e,t,n),l=oN("leakyreluAlpha",e,t,n);if(s){if(o&&2!==u)throw new Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!o&&1!==u)throw new Error("Fused MatMul with BiasAdd must have one extra argument: bias.")}const[c,p]=oN("args",e,t,n);return[r.fused.matMul({a:oN("a",e,t,n),b:oN("b",e,t,n),transposeA:oN("transposeA",e,t,n),transposeB:oN("transposeB",e,t,n),bias:c,activation:i,preluActivationWeights:p,leakyreluAlpha:l})];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"normalization":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"EuclideanNorm":return[r.euclideanNorm(oN("x",e,t,n),oN("axis",e,t,n),oN("keepDims",e,t,n))];case"FusedBatchNorm":case"FusedBatchNormV2":case"FusedBatchNormV3":return[r.batchNorm(oN("x",e,t,n),oN("mean",e,t,n),oN("variance",e,t,n),oN("offset",e,t,n),oN("scale",e,t,n),oN("epsilon",e,t,n))];case"LRN":return[r.localResponseNormalization(oN("x",e,t,n),oN("radius",e,t,n),oN("bias",e,t,n),oN("alpha",e,t,n),oN("beta",e,t,n))];case"Softmax":return[r.softmax(oN("x",e,t,n))];case"LogSoftmax":return[r.logSoftmax(oN("x",e,t,n))];case"SparseToDense":return[r.sparseToDense(oN("sparseIndices",e,t,n),oN("outputShape",e,t,n),oN("sparseValues",e,t,n),oN("defaultValue",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"reduction":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"Max":{const a=oN("axis",e,t,n),i=oN("keepDims",e,t,n);return[r.max(oN("x",e,t,n),a,i)]}case"Mean":{const a=oN("axis",e,t,n),i=oN("keepDims",e,t,n);return[r.mean(oN("x",e,t,n),a,i)]}case"Min":{const a=oN("axis",e,t,n),i=oN("keepDims",e,t,n);return[r.min(oN("x",e,t,n),a,i)]}case"Sum":{const a=oN("axis",e,t,n),i=oN("keepDims",e,t,n);return[r.sum(oN("x",e,t,n),a,i)]}case"All":{const a=oN("axis",e,t,n),i=oN("keepDims",e,t,n);return[r.all(oN("x",e,t,n),a,i)]}case"Any":{const a=oN("axis",e,t,n),i=oN("keepDims",e,t,n);return[r.any(oN("x",e,t,n),a,i)]}case"ArgMax":{const a=oN("axis",e,t,n);return[r.argMax(oN("x",e,t,n),a)]}case"ArgMin":{const a=oN("axis",e,t,n);return[r.argMin(oN("x",e,t,n),a)]}case"Prod":{const a=oN("axis",e,t,n),i=oN("keepDims",e,t,n);return[r.prod(oN("x",e,t,n),a,i)]}case"Cumprod":{const a=oN("axis",e,t,n),i=oN("exclusive",e,t,n),s=oN("reverse",e,t,n);return[r.cumprod(oN("x",e,t,n),a,i,s)]}case"Cumsum":{const a=oN("axis",e,t,n),i=oN("exclusive",e,t,n),s=oN("reverse",e,t,n);return[r.cumsum(oN("x",e,t,n),a,i,s)]}case"Bincount":const a=oN("x",e,t,n),i=oN("weights",e,t,n),s=oN("size",e,t,n);return[r.bincount(a,i,s)];case"DenseBincount":{const a=oN("x",e,t,n),i=oN("weights",e,t,n),s=oN("size",e,t,n),o=oN("binaryOutput",e,t,n);return[r.denseBincount(a,i,s,o)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"slice_join":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"ConcatV2":case"Concat":{const a=oN("n",e,t,n),i=oN("axis",e,t,n);let s=oN("tensors",e,t,n);return s=s.slice(0,a),[r.concat(s,i)]}case"Gather":{const a=oN("x",e,t,n),i=oN("indices",e,t,n);return[r.gather(a,r.cast(i,"int32"),0)]}case"GatherV2":{const a=oN("axis",e,t,n),i=oN("batchDims",e,t,n),s=oN("x",e,t,n),o=oN("indices",e,t,n);return[r.gather(s,r.cast(o,"int32"),a,i)]}case"Reverse":{const a=oN("dims",e,t,n),i=[];for(let e=0;e{const a=oN("axis",e,t,n),i=oN("tensors",e,t,n),s=i[0].shape,o=r.squeeze(i[0]).shape,u=i.map((e=>{const t=de(e.shape,s);if(!t&&!de(r.squeeze(e).shape,o))throw new Error("the input tensors shape does not match");return t?e:r.reshape(e,s)}));return[r.stack(u,a)]}));case"Unpack":{const a=oN("axis",e,t,n),i=oN("tensor",e,t,n);return r.unstack(i,a)}case"Tile":{const a=oN("reps",e,t,n);return[r.tile(oN("x",e,t,n),a)]}case"Split":case"SplitV":{const a=oN("axis",e,t,n),i=oN("numOrSizeSplits",e,t,n),s=oN("x",e,t,n);return r.split(s,i,a)}case"ScatterNd":{const a=oN("indices",e,t,n),i=oN("values",e,t,n),s=oN("shape",e,t,n);return[r.scatterND(a,i,s)]}case"GatherNd":{const a=oN("x",e,t,n),i=oN("indices",e,t,n);return[r.gatherND(a,i)]}case"SparseToDense":{const a=oN("sparseIndices",e,t,n),i=oN("outputShape",e,t,n),s=oN("sparseValues",e,t,n),o=oN("defaultValue",e,t,n);return[r.sparseToDense(a,s,i,s.dtype===o.dtype?o:r.cast(o,s.dtype))]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"sparse":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"SparseFillEmptyRows":{const{outputIndices:a,outputValues:i,emptyRowIndicator:s,reverseIndexMap:o}=r.sparse.sparseFillEmptyRows(oN("indices",e,t,n),oN("values",e,t,n),oN("denseShape",e,t,n),oN("defaultValue",e,t,n));return[a,i,s,o]}case"SparseReshape":{const{outputIndices:a,outputShape:i}=r.sparse.sparseReshape(oN("inputIndices",e,t,n),oN("inputShape",e,t,n),oN("newShape",e,t,n));return[a,i]}case"SparseSegmentMean":return[r.sparse.sparseSegmentMean(oN("data",e,t,n),oN("indices",e,t,n),oN("segmentIds",e,t,n))];case"SparseSegmentSum":return[r.sparse.sparseSegmentSum(oN("data",e,t,n),oN("indices",e,t,n),oN("segmentIds",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"spectral":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"FFT":return[r.fft(oN("x",e,t,n))];case"IFFT":return[r.ifft(oN("x",e,t,n))];case"RFFT":return[r.rfft(oN("x",e,t,n))];case"IRFFT":return[r.irfft(oN("x",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"string":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"StringNGrams":{const{nGrams:a,nGramsSplits:i}=r.string.stringNGrams(oN("data",e,t,n),oN("dataSplits",e,t,n),oN("separator",e,t,n),oN("nGramWidths",e,t,n),oN("leftPad",e,t,n),oN("rightPad",e,t,n),oN("padWidth",e,t,n),oN("preserveShortSequences",e,t,n));return[a,i]}case"StringSplit":{const{indices:a,values:i,shape:s}=r.string.stringSplit(oN("input",e,t,n),oN("delimiter",e,t,n),oN("skipEmpty",e,t,n));return[a,i,s]}case"StringToHashBucketFast":return[r.string.stringToHashBucketFast(oN("input",e,t,n),oN("numBuckets",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"transformation":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"Cast":return[r.cast(oN("x",e,t,n),oN("dtype",e,t,n))];case"ExpandDims":{const a=oN("axis",e,t,n);return[r.expandDims(oN("x",e,t,n),a)]}case"Squeeze":{const a=oN("axis",e,t,n);return[r.squeeze(oN("x",e,t,n),a)]}case"Reshape":return[r.reshape(oN("x",e,t,n),oN("shape",e,t,n))];case"MirrorPad":return[r.mirrorPad(oN("x",e,t,n),oN("padding",e,t,n),oN("mode",e,t,n))];case"PadV2":case"Pad":return[r.pad(oN("x",e,t,n),oN("padding",e,t,n),oN("constantValue",e,t,n))];case"SpaceToBatchND":{const a=oN("blockShape",e,t,n),i=oN("paddings",e,t,n);return[r.spaceToBatchND(oN("x",e,t,n),a,i)]}case"BatchToSpaceND":{const a=oN("blockShape",e,t,n),i=oN("crops",e,t,n);return[r.batchToSpaceND(oN("x",e,t,n),a,i)]}case"DepthToSpace":{const a=oN("blockSize",e,t,n),i=oN("dataFormat",e,t,n).toUpperCase();return[r.depthToSpace(oN("x",e,t,n),a,i)]}case"BroadcastTo":return[r.broadcastTo(oN("x",e,t,n),oN("shape",e,t,n))];case"BroadcastArgs":return[r.broadcastArgs(oN("s0",e,t,n),oN("s1",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"hash_table":return(async(e,t,n,r)=>{switch(e.op){case"HashTable":case"HashTableV2":{const a=oN("keyDType",e,t,n),i=oN("valueDType",e,t,n),s=new rS(a,i);return r.addHashTable(e.name,s),[s.handle]}case"LookupTableImport":case"LookupTableImportV2":{const a=oN("tableHandle",e,t,n,r),i=oN("keys",e,t,n),s=oN("values",e,t,n),o=r.getHashTableById(a.id);return[await o.import(i,s)]}case"LookupTableFind":case"LookupTableFindV2":{const a=oN("tableHandle",e,t,n,r),i=oN("keys",e,t,n),s=oN("defaultValue",e,t,n),o=r.getHashTableById(a.id);return[await o.find(i,s)]}case"LookupTableSize":case"LookupTableSizeV2":{const a=oN("tableHandle",e,t,n,r);return[r.getHashTableById(a.id).tensorSize()]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n,r);case"custom":const i=iN(e.op);if(i&&i.customExecutor)return i.customExecutor(new GN(e,t,n));throw TypeError(`Custom op ${e.op} is not registered.`);default:throw TypeError(`Unknown op '${e.op}'. File an issue at https://github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp()`)}})(e,t,n);return qe(i)?i.then((e=>[].concat(e))):[].concat(i)}class iS{constructor(e={},t={},n={},r={}){this.weightMap=e,this.tensorArrayMap=t,this.tensorListMap=n,this.functionMap=r,this.rootContext={id:0,frameName:"",iterationId:0},this.contexts=[this.rootContext],this.lastId=0,this.generateCurrentContextIds()}newFrame(e,t){return{id:e,frameName:t,iterationId:0}}set currentContext(e){this.contexts!==e&&(this.contexts=e,this.generateCurrentContextIds())}get currentContext(){return this.contexts}get currentContextId(){return this._currentContextIds[0]}get currentContextIds(){return this._currentContextIds}generateCurrentContextIds(){const e=[];for(let t=0;t0===e.id&&0===e.iterationId?"":`${e.frameName}-${e.iterationId}`)).join("/"):""}enterFrame(e){this.contexts&&(this.lastId++,this.contexts=this.contexts.slice(),this.contexts.push(this.newFrame(this.lastId,e)),this._currentContextIds.unshift(this.contextIdforContexts(this.contexts)))}exitFrame(){if(!(this.contexts&&this.contexts.length>1))throw new Error("Cannot exit frame, the context is empty");this.contexts=this.contexts.slice(),this.contexts.splice(-1),this.currentContextIds.shift()}nextIteration(){if(!(this.contexts&&this.contexts.length>0))throw new Error("Cannot increase frame iteration, the context is empty");{this.contexts=this.contexts.slice(),this.lastId++;const e=Object.assign({},this.contexts[this.contexts.length-1]);e.iterationId+=1,e.id=this.lastId,this.contexts.splice(-1,1,e),this._currentContextIds.splice(0,1,this.contextIdforContexts(this.contexts))}}getWeight(e){return this.weightMap[e]}addTensorArray(e){this.tensorArrayMap[e.id]=e}getTensorArray(e){return this.tensorArrayMap[e]}addTensorList(e){this.tensorListMap[e.id]=e}getTensorList(e){return this.tensorListMap[e]}dispose(e){for(const t in this.tensorArrayMap)this.tensorArrayMap[t].clearAndClose(e);for(const t in this.tensorListMap)this.tensorListMap[t].clearAndClose(e)}}function sS(e,t,n,r){const a=new Set,i=[];let s=null,o=null;const u=new Set,l=Object.keys(e).map((e=>pN(e)[0]));let c=[];null!=r&&(c=r.map((e=>pN(e.name)[0])));const p=[...t];for(;p.length>0;){const e=p.pop();(cS(e)||pS(e)||dS(e))&&null==s&&(s=e,o=s.children.map((e=>e.name)).filter((e=>a.has(e)))),a.add(e.name),null==n[e.name]&&-1===l.indexOf(e.name)&&-1===c.indexOf(e.name)&&(0!==e.inputs.length?e.inputs.forEach((e=>{u.has(e.name)||(u.add(e.name),p.push(e))})):i.push(e.name))}return{inputs:e,outputs:t,usedNodes:a,missingInputs:i,dynamicNode:s,syncInputs:o}}const oS=["Switch","Merge","Enter","Exit","NextIteration","StatelessIf","StatelessWhile","if","While"],uS=["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"],lS=["HashTable","HashTableV2","LookupTableImport","LookupTableImportV2","LookupTableFind","LookupTableFindV2","LookupTableSize","LookupTableSizeV2"];function cS(e){return oS.indexOf(e.op)>=0}function pS(e){return uS.indexOf(e.op)>=0}function dS(e){return lS.indexOf(e.op)>=0}class hS{constructor(e,t){this.graph=e,this.parent=t,this.compiledMap=new Map,this._weightMap={},this.SEPERATOR=",",this._functions={},this._functionExecutorMap={},this.intermediateTensors={},this.keepTensorForDebug=!1,this._outputs=e.outputs,this._inputs=e.inputs,this._initNodes=e.initNodes,this._signature=e.signature,this._functions=e.functions,null!=e.functions&&Object.keys(e.functions).forEach((t=>{this._functionExecutorMap[t]=new hS(e.functions[t],this)}))}get weightIds(){return this.parent?this.parent.weightIds:this._weightIds}get functionExecutorMap(){return this.parent?this.parent.functionExecutorMap:this._functionExecutorMap}get weightMap(){return this.parent?this.parent.weightMap:this._weightMap}set weightMap(e){const t=Object.keys(e).map((t=>e[t].map((e=>e.id))));this._weightIds=[].concat(...t),this._weightMap=e}set resourceManager(e){this._resourceManager=e}get inputs(){return this._inputs.map((e=>({name:e.name,shape:e.attrParams.shape?e.attrParams.shape.value:void 0,dtype:e.attrParams.dtype?e.attrParams.dtype.value:void 0})))}get outputs(){return this._outputs.map((e=>({name:e.name,shape:e.attrParams.shape?e.attrParams.shape.value:void 0,dtype:e.attrParams.dtype?e.attrParams.dtype.value:void 0})))}get inputNodes(){return this._inputs.map((e=>e.signatureKey||e.name))}get outputNodes(){return this._outputs.map((e=>{const t=e.signatureKey||e.name;return e.defaultOutput?`${t}:${e.defaultOutput}`:t}))}get functions(){return Object.keys(this._functions).reduce(((e,t)=>(e[t]=this._functions[t].signature,e)),{})}getCompilationKey(e,t){const n=e.map((e=>e.name)).sort(),r=t.map((e=>e.name)).sort();return n.join(this.SEPERATOR)+"--"+r.join(this.SEPERATOR)}compile(e,t){const n=sS(e,t,this.weightMap,this._initNodes),{missingInputs:r,dynamicNode:a,syncInputs:i}=n;if(null!=a)throw new Error(`This execution contains the node '${a.name}', which has the dynamic op '${a.op}'. Please use model.executeAsync() instead. Alternatively, to avoid the dynamic ops, specify the inputs [${i}]`);if(r.length>0){const n=t.map((e=>e.name)),a=Object.keys(e);throw new Error(`Cannot compute the outputs [${n}] from the provided inputs [${a}]. Missing the following inputs: [${r}]`)}return function(e,t,n){const{usedNodes:r,inputs:a}=n,i=[],s=Object.keys(a).map((e=>pN(e)[0])).map((t=>e.nodes[t])),o=e.initNodes;s.forEach((e=>{r.has(e.name)&&i.push(e)})),e.weights.forEach((e=>{r.has(e.name)&&i.push(e)})),null!=o&&o.forEach((e=>{r.has(e.name)&&i.push(e)}));const u=new Set,l=[];for(;i.length>0;){const e=i.pop();u.add(e.name),t[e.name]||l.push(e),e.children.forEach((e=>{!u.has(e.name)&&r.has(e.name)&&e.inputs.every((e=>u.has(e.name)))&&i.push(e)}))}return l}(this.graph,this.weightMap,n)}execute(e,t){e=this.mapInputs(e);const n=Object.keys(e).sort();this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t);const r=n.map((e=>this.graph.nodes[pN(e)[0]])),a=t.map((e=>pN(e)[0]));let i=a.map((e=>this.graph.nodes[e]));this.resetIntermediateTensors(),0===i.length&&(i=this._outputs);const s=this.getCompilationKey(r,i);let o=this.compiledMap.get(s);null==o&&(o=this.compile(e,i),this.compiledMap.set(s,o));const u={},l={};return ho((()=>{const n=new iS(this.weightMap,u,l,this.functionExecutorMap),r=Object.assign({},this.weightMap);Object.keys(e).forEach((t=>{const[n,a]=pN(t),i=[];i[a]=e[t],r[n]=i}));const i=this.getFrozenTensorIds(r),s={};for(let e=0;euN(e,r,n)))}))}getFrozenTensorIds(e){const t=[].concat.apply([],Object.keys(e).map((t=>e[t])).map((e=>e.map((e=>e.id)))));return new Set(t)}checkTensorForDisposal(e,t,n,r,a,i,s){"control"!==t.category&&-1===i.indexOf(e)&&(n[e].forEach((e=>{null!=e&&(s[e.id]=(s[e.id]||0)+t.children.length)})),t.inputs.forEach((e=>{if("control"!==e.category){const i=function(e,t,n){return t[cN(e,n.currentContextId)]}(e.name,n,r);null!=i&&i.forEach((e=>{if(e&&!e.kept&&!a.has(e.id)){const n=s[e.id];if(1===n){if(this.keepTensorForDebug){const[n,a]=lN(t.name,r);this.intermediateTensors[n]||(this.intermediateTensors[n]=[]),this.intermediateTensors[n][a]=e}else e.dispose();delete s[e.id]}else null!=n&&s[e.id]--}}))}})))}async executeAsync(e,t){return this._executeAsync(e,t)}disposeIntermediateTensors(){this.intermediateTensors&&(Object.keys(this.intermediateTensors).forEach((e=>this.intermediateTensors[e].forEach((e=>e.dispose())))),this.disposeTensorsMap())}disposeTensorsMap(){this.tensorsMap&&Object.keys(this.tensorsMap).forEach((e=>{this.tensorsMap[e].forEach((e=>{!e||e.kept||e.isDisposed||this.keepIds.has(e.id)||e.dispose()}))}))}getIntermediateTensors(){return this.tensorsMap}resetIntermediateTensors(){for(const e in this.intermediateTensors)this.intermediateTensors[e].forEach((e=>e.dispose())),delete this.intermediateTensors[e]}async _executeAsync(e,t,n=!1,r={},a={}){n||(e=this.mapInputs(e),this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t));try{this.keepTensorForDebug=Ge().getBool("KEEP_INTERMEDIATE_TENSORS")}catch(e){console.warn(e.message)}this.resetIntermediateTensors();const i=new iS(this.weightMap,r,a,this.functionExecutorMap);this.tensorsMap=await this.executeWithControlFlow(e,i,t,n);const s=t.map((e=>uN(e,this.tensorsMap,i))),o=s.map((e=>e.id)),u=Object.keys(e).map((t=>e[t].id));return this.keepIds=new Set([...o,...u,...this.weightIds]),this.keepTensorForDebug||this.disposeTensorsMap(),null==this.parent&&i.dispose(this.keepIds),s}async executeFunctionAsync(e,t,n){const r=e.reduce(((e,t,n)=>(e[this.inputs[n].name]=t,e)),{});return this._executeAsync(r,this.outputNodes,!0,t,n)}async executeWithControlFlow(e,t,n,r){const a=Object.keys(e),i=a.map((e=>this.graph.nodes[pN(e)[0]])),s=n.map((e=>pN(e)[0]));let o=s.map((e=>this.graph.nodes[e]));0===o.length&&(o=this._outputs);const{usedNodes:u,missingInputs:l,dynamicNode:c,syncInputs:p}=sS(e,o,this.weightMap,this._initNodes),d=[...i,...this.graph.weights,...this._initNodes||[]].map((e=>({node:e,contexts:t.currentContext}))),h=Object.assign({},this.weightMap);Object.keys(e).forEach((t=>{const[n,r]=pN(t),a=[];a[r]=e[t],h[n]=a}));const f={},m=this.getFrozenTensorIds(h),g={};for(;d.length>0;){const e=this.processStack(i,d,t,h,g,m,s,f,u);await Promise.all(e)}null!=c||r||console.warn("This model execution did not contain any nodes with control flow or dynamic output shapes. You can use model.execute() instead.");const y=o.filter((e=>!cS(e)&&!uN(e.name,h,t))).map((e=>e.name));if(y.length>0){let e="";throw null!=c&&(e=`Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs [${p}]`),new Error(`Cannot compute the outputs [${y}] from the provided inputs [${a}]. Consider providing the following inputs: [${l}]. ${e}`)}return h}processStack(e,t,n,r,a,i,s,o,u){const l=[];for(;t.length>0;){const e=t.pop();n.currentContext=e.contexts;let c="";if("Enter"===e.node.op&&oN("isConstant",e.node,r,n)&&([c]=lN(e.node.name,n)),null==r[e.node.name]){const p=aS(e.node,r,n,this._resourceManager);c||([c]=lN(e.node.name,n));const d=n.currentContext;qe(p)?l.push(p.then((l=>(r[c]=l,n.currentContext=d,this.checkTensorForDisposal(c,e.node,r,n,i,s,o),this.processChildNodes(e.node,t,n,r,a,u),l)))):(r[c]=p,this.checkTensorForDisposal(c,e.node,r,n,i,s,o),this.processChildNodes(e.node,t,n,r,a,u))}else this.processChildNodes(e.node,t,n,r,a,u)}return l}processChildNodes(e,t,n,r,a,i){e.children.forEach((e=>{const[s]=lN(e.name,n);!a[s]&&i.has(e.name)&&("Merge"===e.op?e.inputNames.some((e=>!!uN(e,r,n)))&&(a[s]=!0,t.push({contexts:n.currentContext,node:e})):e.inputNames.every((e=>!!uN(e,r,n)))&&(a[s]=!0,t.push({contexts:n.currentContext,node:e})))}))}dispose(){Object.keys(this.weightMap).forEach((e=>this.weightMap[e].forEach((e=>e.dispose()))))}checkInputShapeAndType(e){Object.keys(e).forEach((t=>{const n=e[t],[r]=pN(t),a=this.graph.nodes[r];if(a.attrParams.shape&&a.attrParams.shape.value){const e=a.attrParams.shape.value,t=e.length===n.shape.length&&n.shape.every(((t,n)=>-1===e[n]||e[n]===t));se(t,(()=>`The shape of dict['${a.name}'] provided in model.execute(dict) must be [${e}], but was [${n.shape}]`))}a.attrParams.dtype&&a.attrParams.dtype.value&&se(n.dtype===a.attrParams.dtype.value,(()=>`The dtype of dict['${a.name}'] provided in model.execute(dict) must be ${a.attrParams.dtype.value}, but was ${n.dtype}`))}))}mapInputs(e){const t={};for(const n in e)null!=this._signature&&null!=this._signature.inputs&&null!=this._signature.inputs[n]?t[this._signature.inputs[n].name]=e[n]:t[n]=e[n];return t}checkInputs(e){const t=Object.keys(e).filter((e=>{const[t]=pN(e);return null==this.graph.nodes[t]}));if(t.length>0)throw new Error(`The dict provided in model.execute(dict) has keys: [${t}] that are not part of graph`)}mapOutputs(e){return e.map((e=>null!=this._signature&&null!=this._signature.outputs&&null!=this._signature.outputs[e]?this._signature.outputs[e].name:e),{})}checkOutputs(e){e.forEach((e=>{const[t]=pN(e);if(!this.graph.nodes[t])throw new Error(`The output '${e}' is not found in the graph`)}))}}class fS{constructor(e={},t={}){this.hashTableNameToHandle=e,this.hashTableMap=t}addHashTable(e,t){this.hashTableNameToHandle[e]=t.handle,this.hashTableMap[t.id]=t}getHashTableHandleByName(e){return this.hashTableNameToHandle[e]}getHashTableById(e){return this.hashTableMap[e]}dispose(){for(const e in this.hashTableMap)this.hashTableMap[e].clearAndClose(),delete this.hashTableMap[e];for(const e in this.hashTableNameToHandle)this.hashTableNameToHandle[e].dispose(),delete this.hashTableNameToHandle[e]}}class mS{constructor(e,t={},n=i){this.modelUrl=e,this.loadOptions=t,this.version="n/a",this.io=n,null==t&&(this.loadOptions={}),this.resourceManager=new fS}get modelVersion(){return this.version}get inputNodes(){return this.executor.inputNodes}get outputNodes(){return this.executor.outputNodes}get inputs(){return this.executor.inputs}get outputs(){return this.executor.outputs}get weights(){return this.executor.weightMap}get metadata(){return this.artifacts.userDefinedMetadata}get modelSignature(){return this.signature}get modelStructuredOutputKeys(){return this.structuredOutputKeys}findIOHandler(){const e=this.modelUrl;if(null!=e.load)this.handler=e;else if(null!=this.loadOptions.requestInit)this.handler=this.io.browserHTTPRequest(e,this.loadOptions);else{const t=this.io.getLoadHandlers(e,this.loadOptions);if(0===t.length)t.push(this.io.browserHTTPRequest(e,this.loadOptions));else if(t.length>1)throw new Error(`Found more than one (${t.length}) load handlers for URL '${[e]}'`);this.handler=t[0]}}load(){if(this.findIOHandler(),null==this.handler.load)throw new Error("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");const e=this.handler.load();return qe(e)?e.then((e=>this.loadSync(e))):this.loadSync(e)}loadSync(e){this.artifacts=e;const t=this.artifacts.modelTopology;let n=this.artifacts.signature;if(null!=this.artifacts.userDefinedMetadata){const e=this.artifacts.userDefinedMetadata;null!=e.signature&&(n=e.signature),null!=e.structuredOutputKeys&&(this.structuredOutputKeys=e.structuredOutputKeys)}this.signature=n,this.version=`${t.versions.producer}.${t.versions.minConsumer}`;const r=this.io.decodeWeights(this.artifacts.weightData,this.artifacts.weightSpecs);if(this.executor=new hS(LN.Instance.transformGraph(t,this.signature)),this.executor.weightMap=this.convertTensorMapToTensorsMap(r),this.executor.resourceManager=this.resourceManager,null!=e.modelInitializer&&null!=e.modelInitializer.node){const t=LN.Instance.transformGraph(e.modelInitializer);this.initializer=new hS(t),this.initializer.weightMap=this.executor.weightMap,this.initializer.resourceManager=this.resourceManager,this.initializer.executeAsync({},[])}return!0}async save(e,t){if("string"==typeof e){const t=this.io.getSaveHandlers(e);if(0===t.length)throw new Error(`Cannot find any save handlers for URL '${e}'`);if(t.length>1)throw new Error(`Found more than one (${t.length}) save handlers for URL '${e}'`);e=t[0]}if(null==e.save)throw new Error("GraphModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");return e.save(this.artifacts)}predict(e,t){const n=this.execute(e,this.outputNodes);if(this.structuredOutputKeys){const e={};return(n instanceof ti?[n]:n).forEach(((t,n)=>e[this.structuredOutputKeys[n]]=t)),e}return n}normalizeInputs(e){if(!(e instanceof ti||Array.isArray(e)))return e;if((e=Array.isArray(e)?e:[e]).length!==this.inputNodes.length)throw new Error(`Input tensor count mismatch,the graph model has ${this.inputNodes.length} placeholders, while there are ${e.length} input tensors.`);return this.inputNodes.reduce(((t,n,r)=>(t[n]=e[r],t)),{})}normalizeOutputs(e){return e=e||this.outputNodes,Array.isArray(e)?e:[e]}execute(e,t){e=this.normalizeInputs(e),t=this.normalizeOutputs(t);const n=this.executor.execute(e,t);return n.length>1?n:n[0]}async executeAsync(e,t){e=this.normalizeInputs(e),t=this.normalizeOutputs(t);const n=await this.executor.executeAsync(e,t);return n.length>1?n:n[0]}getIntermediateTensors(){return this.executor.getIntermediateTensors()}disposeIntermediateTensors(){this.executor.disposeIntermediateTensors()}convertTensorMapToTensorsMap(e){return Object.keys(e).reduce(((t,n)=>(t[n]=[e[n]],t)),{})}dispose(){this.executor.dispose(),this.initializer&&this.initializer.dispose(),this.resourceManager.dispose()}}async function gS(e,t={},n=i){if(null==e)throw new Error("modelUrl in loadGraphModel() cannot be null. Please provide a url or an IOHandler that loads the model");null==t&&(t={}),t.fromTFHub&&"string"==typeof e&&(e=function(e){return e.endsWith("/")||(e+="/"),`${e}model.json?tfjs-format=file`}(e));const r=new mS(e,t,n);return await r.load(),r}function yS(e){if(null==e)throw new Error("modelUrl in loadGraphModelSync() cannot be null. Please provide a url or an IOHandler that loads the model");if(!e.load)throw new Error(`modelUrl IO Handler ${e} has no load function`);const t=new mS(e);return t.load(),t}const bS="3.19.0";function xS(e,t,n=new Map,r=new Set){if(null==e)return null;if("function"==typeof Blob&&e instanceof Blob)return e.slice();if(r.has(e))throw new Error("Circular references are not supported.");if(n.has(e))return n.get(e);const a=t(e);if(a.recurse&&null!==a.value)throw new Error("A deep map function may not return both a value and recurse=true.");if(a.recurse){if(NS(e)){const a=Array.isArray(e)?[]:{};r.add(e);for(const i in e){const s=xS(e[i],t,n,r);a[i]=s}return r.delete(e),e.__proto__&&(a.__proto__=e.__proto__),a}throw new Error(`Can't recurse into non-iterable type: ${e}`)}return n.set(e,a.value),a.value}function vS(e,t=wS){return _S(e,t)}function _S(e,t,n=new Set){const r=e[0];if(n.has(r))throw new Error("Circular references are not supported.");const a=t(e);if(a.recurse&&null!==a.value)throw new Error("A deep zip function may not return both a value and recurse=true.");if(a.recurse){if(NS(r)){const a=Array.isArray(r)?[]:{};n.add(r);for(const i in r){const r=_S(e.map((e=>e[i])),t,n);a[i]=r}return n.delete(r),a}throw new Error(`Can't recurse into non-iterable type: ${r}`)}return a.value}function wS(e){return null===e?null:NS(e[0])?{value:null,recurse:!0}:{value:e,recurse:!1}}async function MS(e,t){const n=new Map;xS(e,t,n);for(const e of Array.from(n.keys())){const t=n.get(e);if(qe(t)){const r=await t;n.set(e,r)}}return xS(e,t,n)}function NS(e){let t=!1;if(Ge().get("IS_BROWSER"))t=e instanceof TextDecoder;else{const{StringDecoder:r}=n(4977);t=e instanceof r}return null!=e&&!ArrayBuffer.isView(e)&&(Array.isArray(e)||"object"==typeof e&&!(e instanceof ti)&&!(e instanceof Promise)&&!t)}function SS(e){return e instanceof ti?{value:e.clone(),recurse:!1}:NS(e)?{value:null,recurse:!0}:{value:e,recurse:!1}}class kS{constructor(e){if(this.capacity=e,this.begin=0,this.end=0,null==e)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(e<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(e),this.doubledCapacity=2*e}wrap(e){for(;e<0;)e+=this.doubledCapacity;return e%this.doubledCapacity}get(e){if(e<0)throw new RangeError("Can't get item at a negative index.");return this.data[e%this.capacity]}set(e,t){if(e<0)throw new RangeError("Can't set item at a negative index.");this.data[e%this.capacity]=t}length(){let e=this.end-this.begin;return e<0&&(e=this.doubledCapacity+e),e}isFull(){return this.length()===this.capacity}isEmpty(){return 0===this.length()}push(e){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,e),this.end=this.wrap(this.end+1)}pushAll(e){for(const t of e)this.push(t)}pop(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);const e=this.get(this.end);return this.set(this.end,void 0),e}unshift(e){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,e)}shift(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");const e=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),e}shuffleExcise(e){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");const t=this.wrap(this.begin+e),n=this.get(t);return this.set(t,this.pop()),n}}class DS extends kS{constructor(){super(DS.INITIAL_CAPACITY)}isFull(){return!1}push(e){super.isFull()&&this.expand(),super.push(e)}unshift(e){super.isFull()&&this.expand(),super.unshift(e)}expand(){const e=2*this.capacity,t=new Array(e),n=this.length();for(let e=0;e!0===e))}rowMajorBatch(e,t=!0){return new RS(this,e,t)}columnMajorBatch(e,t=!0,n=wS){return this.rowMajorBatch(e,t).map((e=>vS(e,n)))}concatenate(e,t){return new jS(TS([this,e]),t)}take(e){return e<0||null==e?this:new OS(this,e)}skip(e){return e<0||null==e?this:new $S(this,e)}prefetch(e){return new WS(this,e)}shuffle(e,t){return new VS(this,e,t)}serial(){return new LS(this)}}class CS extends ES{constructor(e){super(),this.items=e,this.trav=0}summary(){return`Array of ${this.items.length} items`}async next(){if(this.trav>=this.items.length)return{value:null,done:!0};const e=this.items[this.trav];return this.trav++,{value:(t=e,function(e,t){return xS(e,t)}(t,SS)),done:!1};var t}}class AS extends ES{constructor(e){super(),this.nextFn=e}summary(){return"Function call"}async next(){try{return this.nextFn()}catch(e){throw e.message=`Error thrown while iterating through a dataset: ${e.message}`,e}}}class LS extends ES{constructor(e){super(),this.upstream=e,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Serial`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){return this.upstream.next()}}class $S extends ES{constructor(e,t){super(),this.upstream=e,this.maxCount=t,this.count=0,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Skip`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;this.count++ Take`}async next(){return this.count++>=this.maxCount?{value:null,done:!0}:this.upstream.next()}}class RS extends ES{constructor(e,t,n=!0){super(),this.upstream=e,this.batchSize=t,this.enableSmallLastBatch=n,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> RowMajorBatch`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){const e=[];for(;e.length0?{value:e,done:!1}:{value:null,done:!0};e.push(t.value)}return{value:e,done:!1}}}class FS extends ES{constructor(e,t){super(),this.upstream=e,this.predicate=t,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Filter`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;;){const e=await this.upstream.next();if(e.done||this.predicate(e.value))return e;fo(e.value)}}}class YS extends ES{constructor(e,t){super(),this.upstream=e,this.transform=t}summary(){return`${this.upstream.summary()} -> Map`}async next(){const e=await this.upstream.next();if(e.done)return{value:null,done:!0};const t=mi(e.value),n=this.transform(e.value),r=mi(n);for(const e of t)fi(e,r)||e.dispose();return{value:n,done:!1}}}class zS extends ES{constructor(e,t){super(),this.upstream=e,this.handler=t,this.count=0,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> handleErrors`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;;)try{return await this.upstream.next()}catch(e){if(!this.handler(e))return{value:null,done:!0}}}}class BS extends ES{constructor(e,t){super(),this.upstream=e,this.transform=t}summary(){return`${this.upstream.summary()} -> AsyncMap`}async next(){const e=await this.upstream.next();if(e.done)return{value:null,done:!0};const t=mi(e.value),n=await this.transform(e.value),r=mi(n);for(const e of t)fi(e,r)||e.dispose();return{value:n,done:!1}}}class PS extends ES{constructor(){super(),this.outputQueue=new DS,this.lastRead=Promise.resolve({value:null,done:!1})}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;0===this.outputQueue.length();)if(!await this.pump())return{value:null,done:!0};return{value:this.outputQueue.shift(),done:!1}}}class HS extends PS{constructor(e,t){super(),this.upstream=e,this.transform=t}summary(){return`${this.upstream.summary()} -> Flatmap`}async pump(){const e=await this.upstream.next();if(e.done)return!1;const t=mi(e.value),n=this.transform(e.value),r=mi(n);this.outputQueue.pushAll(n);for(const e of t)fi(e,r)||e.dispose();return!0}}class jS extends ES{constructor(e,t){super(),this.baseErrorHandler=t,this.lastRead=null,this.iterator=null,this.moreIterators=e}summary(){return"TODO: fill in upstream of chained summaries -> Chained"}async next(){return this.lastRead=this.readFromChain(this.lastRead),this.lastRead}async readFromChain(e){if(await e,null==this.iterator){const e=await this.moreIterators.next();if(e.done)return{value:null,done:!0};this.iterator=e.value,null!=this.baseErrorHandler&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler))}const t=await this.iterator.next();return t.done?(this.iterator=null,this.readFromChain(e)):t}}var US;!function(e){e[e.FAIL=0]="FAIL",e[e.SHORTEST=1]="SHORTEST",e[e.LONGEST=2]="LONGEST"}(US||(US={}));class qS extends ES{constructor(e,t=US.FAIL){super(),this.iterators=e,this.mismatchMode=t,this.count=0,this.currentPromise=null}summary(){return"{TODO: fill in upstream of zip summaries} -> Zip"}async nextState(e){await e;let t=0,n=0;const r=await MS(this.iterators,(function(e){return e instanceof ES?{value:e.next().then((e=>(t++,e.done&&n++,e.value))),recurse:!1}:{value:null,recurse:!0}}));if(t===n)return{value:null,done:!0};if(n>0)switch(this.mismatchMode){case US.FAIL:throw new Error(`Zipped streams should have the same length. Mismatched at element ${this.count}.`);case US.SHORTEST:return{value:null,done:!0};case US.LONGEST:}return this.count++,{value:r,done:!1}}async next(){return this.currentPromise=this.nextState(this.currentPromise),this.currentPromise}}class WS extends ES{constructor(e,t){super(),this.upstream=e,this.bufferSize=t,this.buffer=new kS(t)}summary(){return`${this.upstream.summary()} -> Prefetch`}refill(){for(;!this.buffer.isFull();){const e=this.upstream.next();this.buffer.push(e)}}next(){return this.refill(),this.buffer.shift()}}class VS extends WS{constructor(e,t,n){super(e,t),this.upstream=e,this.windowSize=t,this.upstreamExhausted=!1,this.random=Ep.alea(n||za().toString()),this.lastRead=Promise.resolve({value:null,done:!1})}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}randomInt(e){return Math.floor(this.random()*e)}chooseIndex(){return this.randomInt(this.buffer.length())}async serialNext(){for(this.upstreamExhausted||this.refill();!this.buffer.isEmpty();){const e=this.chooseIndex(),t=await this.buffer.shuffleExcise(e);if(!t.done)return this.refill(),t;this.upstreamExhausted=!0}return{value:null,done:!0}}}class GS{constructor(){this.size=null}batch(e,t=!0){const n=this;let r;return se(e>0,(()=>`batchSize needs to be positive, but it is\n ${e}`)),r=this.size===1/0||null==this.size?this.size:t?Math.ceil(this.size/e):Math.floor(this.size/e),KS((async()=>(await n.iterator()).columnMajorBatch(e,t,ZS)),r)}concatenate(e){const t=this;let n;return n=this.size===1/0||e.size===1/0?1/0:null!=this.size&&null!=e.size?this.size+e.size:null,KS((async()=>(await t.iterator()).concatenate(await e.iterator())),n)}filter(e){const t=this;let n;return n=this.size===1/0?1/0:null,KS((async()=>(await t.iterator()).filter((t=>ho((()=>e(t)))))),n)}async forEachAsync(e){return(await this.iterator()).forEachAsync(e)}map(e){const t=this;return KS((async()=>(await t.iterator()).map((t=>ho((()=>e(t)))))),this.size)}mapAsync(e){const t=this;return KS((async()=>(await t.iterator()).mapAsync(e)),this.size)}prefetch(e){if(null==e)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");const t=this;return KS((async()=>(await t.iterator()).prefetch(e)),this.size)}repeat(e){const t=this;let n;return n=null!=this.size&&e>0?this.size*e:0===e?0:null!=this.size&&(void 0===e||e<0)?1/0:null,KS((async()=>{return n=IS((async()=>({value:await t.iterator(),done:!1}))).take(e),new jS(n,r);var n,r}),n)}skip(e){const t=this;let n;return n=null!=this.size&&e>=0&&this.size>=e?this.size-e:null!=this.size&&(this.size(await t.iterator()).skip(e)),n)}shuffle(e,t,n=!0){if(null==e||e<0)throw null==this.size?new RangeError("`Dataset.shuffle()` requires bufferSize to be specified."):new RangeError(`\`Dataset.shuffle()\` requires bufferSize to be specified. If your data fits in main memory (for regular JS objects), and/or GPU memory (for \`tf.Tensor\`s), consider setting bufferSize to the dataset size (${this.size} elements)`);const r=this,a=Ep.alea(t||za().toString());return KS((async()=>{let t=a.int32();return n&&(t+=a.int32()),(await r.iterator()).shuffle(e,t.toString())}),this.size)}take(e){const t=this;let n;return n=null!=this.size&&this.size>e?e:null!=this.size&&this.size<=e?this.size:null,KS((async()=>(await t.iterator()).take(e)),n)}async toArray(){if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArray()}async toArrayForTest(){if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArrayForTest()}}function KS(e,t=null){return new class extends GS{constructor(){super(...arguments),this.size=t}async iterator(){return e()}}}function JS(e){return KS((async()=>TS(e)),e.length)}function XS(e){if(!NS(e))throw new Error("The argument to zip() must be an object or array.");let t;if(Array.isArray(e))for(let n=0;nfunction(e,t=US.FAIL){return new qS(e,t)}(await MS(e,(e=>{if(e instanceof GS)return{value:e.iterator(),recurse:!1};if(NS(e))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")})),US.SHORTEST)),t)}function ZS(e){if(null===e)return null;return null==(t=e[0])||null===(n=t)||"object"!=typeof n&&"function"!=typeof n||Array.isArray(t)||"object"==typeof t&&t instanceof ti||De(t)?{value:function(e){if(0===e.length)throw new Error("Can't make a batch of zero elements.");return e[0]instanceof ti?hd(e):Fi(e)}(e),recurse:!1}:{value:null,recurse:!0};var t,n}GS.MAX_BUFFER_SIZE=1e4;class QS extends GS{constructor(e){super(),this.input=e}async iterator(){const e=(await this.input.iterator()).decodeUTF8().split("\n").map((e=>(e.endsWith("\r")&&(e=e.slice(0,-1)),e)));return e}}const ek='"',tk=Symbol("out"),nk=Symbol("field"),rk=Symbol("quote"),ak=Symbol("quoteafterquote"),ik=Symbol("quoteinquote");class sk extends GS{constructor(e,t){super(),this.input=e,this.hasHeader=!0,this.fullColumnNames=null,this.columnNamesValidated=!1,this.columnConfigs=null,this.configuredColumnsOnly=!1,this.delimiter=",",this.delimWhitespace=!1,this.base=new QS(e),t||(t={}),this.hasHeader=!1!==t.hasHeader,this.fullColumnNames=t.columnNames,this.columnConfigs=t.columnConfigs,this.configuredColumnsOnly=t.configuredColumnsOnly,t.delimWhitespace?(se(null==t.delimiter,(()=>"Delimiter should not be provided when delimWhitespace is true.")),this.delimWhitespace=!0,this.delimiter=" "):this.delimiter=t.delimiter?t.delimiter:","}async columnNames(){return this.columnNamesValidated||await this.setColumnNames(),this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames}async setColumnNames(){const e=await this.maybeReadHeaderLine();if(!this.fullColumnNames&&!e)throw new Error("Column names must be provided if there is no header line.");this.fullColumnNames&&e&&se(e.length===this.fullColumnNames.length,(()=>"The length of provided columnNames ("+this.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+e.length.toString()+").")),this.fullColumnNames||(this.fullColumnNames=e);const t=this.fullColumnNames.reduce(((e,t)=>(e[t]=e[t]+1||1,e)),{}),n=Object.keys(t).filter((e=>t[e]>1));if(se(0===n.length,(()=>"Duplicate column names found: "+n.toString())),this.columnConfigs)for(const e of Object.keys(this.columnConfigs))if(-1===this.fullColumnNames.indexOf(e))throw new Error('The key "'+e+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").");this.columnNamesValidated=!0}async maybeReadHeaderLine(){if(this.hasHeader){const e=await this.base.iterator(),t=await e.next();if(t.done)throw new Error("No data was found for CSV parsing.");const n=t.value;return this.parseRow(n,!1)}return null}async iterator(){this.columnNamesValidated||await this.setColumnNames();let e=await this.base.iterator();return this.hasHeader&&(e=e.skip(1)),e.map((e=>this.makeDataElement(e)))}makeDataElement(e){const t=this.parseRow(e),n={},r={};for(let a=0;a14||!Number.isInteger(t))throw new Error(`Invalid fftSize: it must be a power of 2 between 2 to 4 and 2 to 14, but got ${this.fftSize}`);if(this.numFrames=e.numFramesPerSpectrogram||43,this.sampleRateHz=e.sampleRateHz,this.columnTruncateLength=e.columnTruncateLength||this.fftSize,this.audioTrackConstraints=e.audioTrackConstraints,this.smoothingTimeConstant=e.smoothingTimeConstant||0,this.includeSpectrogram=!1!==e.includeSpectrogram,this.includeWaveform=!0===e.includeWaveform,!this.includeSpectrogram&&!this.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.")}summary(){return"microphone"}static async create(e={}){if(!Ge().get("IS_BROWSER"))throw new Error("microphone API is only supported in browser environment.");const t=new ok(e);return await t.start(),t}async start(){try{this.stream=await navigator.mediaDevices.getUserMedia({audio:null==this.audioTrackConstraints||this.audioTrackConstraints,video:!1})}catch(e){throw new Error(`Error thrown while initializing video stream: ${e.message}`)}if(!this.stream)throw new Error("Could not obtain audio from microphone.");const e=window.AudioContext||window.webkitAudioContext;if(this.audioContext=new e,this.sampleRateHz){if(this.audioContext.sampleRate!==this.sampleRateHz)throw new Error(`Mismatch in sampling rate: Expected: ${this.sampleRateHz}; Actual: ${this.audioContext.sampleRate}`)}else this.sampleRateHz=this.audioContext.sampleRate;const t=this.audioContext.createMediaStreamSource(this.stream);this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=2*this.fftSize,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,t.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize)}async next(){if(this.isClosed)return{value:null,done:!0};let e,t;const n=await this.getAudioData();if(this.includeSpectrogram){const t=this.flattenQueue(n.freqDataQueue);e=this.getTensorFromAudioDataArray(t,[this.numFrames,this.columnTruncateLength,1])}if(this.includeWaveform){const e=this.flattenQueue(n.timeDataQueue);t=this.getTensorFromAudioDataArray(e,[this.numFrames*this.fftSize,1])}return{value:{spectrogram:e,waveform:t},done:!1}}async capture(){return(await this.next()).value}async getAudioData(){const e=[],t=[];let n=0;return new Promise((r=>{const a=setInterval((()=>{this.includeSpectrogram&&(this.analyser.getFloatFrequencyData(this.freqData),this.freqData[0]===-1/0&&r({freqDataQueue:e,timeDataQueue:t}),e.push(this.freqData.slice(0,this.columnTruncateLength))),this.includeWaveform&&(this.analyser.getFloatTimeDomainData(this.timeData),t.push(this.timeData.slice())),++n===this.numFrames&&(clearInterval(a),r({freqDataQueue:e,timeDataQueue:t}))}),this.fftSize/this.sampleRateHz*1e3)}))}stop(){this.isClosed||(this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),null!=this.stream&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop())}toArray(){throw new Error("Can not convert infinite audio stream to array.")}getSampleRate(){return this.sampleRateHz}flattenQueue(e){const t=e[0].length,n=new Float32Array(e.length*t);return e.forEach(((e,r)=>n.set(e,r*t))),n}getTensorFromAudioDataArray(e,t){const n=new Float32Array(ce(t));return n.set(e,n.length-e.length),Fi(n,t)}}class uk extends ES{constructor(e,t){if(super(),this.webcamVideoElement=e,this.webcamConfig=t,this.isClosed=!0,this.resize=!1,this.needToResize())if(this.resize=!0,this.cropSize=[this.webcamConfig.resizeHeight,this.webcamConfig.resizeWidth],this.cropBoxInd=yd([0],"int32"),this.webcamConfig.centerCrop){const e=1*this.webcamConfig.resizeWidth/this.webcamVideoElement.width,t=1*this.webcamConfig.resizeHeight/this.webcamVideoElement.height,n=(1-e)/2,r=(1-t)/2,a=n+e,i=t+r;this.cropBox=bd([r,n,i,a],[1,4])}else this.cropBox=bd([0,0,1,1],[1,4])}summary(){return"webcam"}static async create(e,t={}){if(!Ge().get("IS_BROWSER"))throw new Error("tf.data.webcam is only supported in browser environment.");if(!e){if(e=document.createElement("video"),!t.resizeWidth||!t.resizeHeight)throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");e.width=t.resizeWidth,e.height=t.resizeHeight}const n=new uk(e,t);return await n.start(),n}async start(){this.webcamConfig.facingMode&&se("user"===this.webcamConfig.facingMode||"environment"===this.webcamConfig.facingMode,(()=>`Invalid webcam facing mode: ${this.webcamConfig.facingMode}. Please provide 'user' or 'environment'`));try{this.stream=await navigator.mediaDevices.getUserMedia({video:{deviceId:this.webcamConfig.deviceId,facingMode:this.webcamConfig.facingMode?this.webcamConfig.facingMode:"user",width:this.webcamVideoElement.width,height:this.webcamVideoElement.height}})}catch(e){throw e.message=`Error thrown while initializing video stream: ${e.message}`,e}if(!this.stream)throw new Error("Could not obtain video from webcam.");try{this.webcamVideoElement.srcObject=this.stream}catch(e){console.log(e),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,new Promise((e=>{this.webcamVideoElement.onloadedmetadata=()=>{e()}}))}async next(){if(this.isClosed)return{value:null,done:!0};let e;try{e=zo(this.webcamVideoElement)}catch(e){throw new Error(`Error thrown converting video to pixels: ${JSON.stringify(e)}`)}if(!this.resize)return{value:e,done:!1};try{return{value:this.cropAndResizeFrame(e),done:!1}}catch(e){throw new Error(`Error thrown cropping the video: ${e.message}`)}finally{e.dispose()}}needToResize(){return!(!this.webcamConfig.resizeWidth||!this.webcamConfig.resizeHeight||this.webcamVideoElement.width===this.webcamConfig.resizeWidth&&this.webcamVideoElement.height===this.webcamConfig.resizeHeight)}cropAndResizeFrame(e){return ho((()=>{const t=Ic(Ls(e,"float32"),0);let n;n=Uh.cropAndResize(t,this.cropBox,this.cropBoxInd,this.cropSize,"bilinear");const r=n.shape;return Ml(n,r.slice(1))}))}async capture(){return(await this.next()).value}stop(){this.stream.getTracks().forEach((e=>e.stop()));try{this.webcamVideoElement.srcObject=null}catch(e){console.log(e),this.webcamVideoElement.src=null}this.isClosed=!0}toArray(){throw new Error("Can not convert infinite video stream to array.")}}class lk{}class ck extends ES{split(e){return new pk(this,e)}}class pk extends ck{constructor(e,t){super(),this.upstream=e,this.impl=new dk(e,t)}summary(){return this.impl.summary()}async next(){return this.impl.next()}}class dk extends PS{constructor(e,t){super(),this.upstream=e,this.separator=t,this.carryover=""}summary(){return`${this.upstream.summary()} -> Split('${this.separator}')`}async pump(){const e=await this.upstream.next();if(e.done)return""!==this.carryover&&(this.outputQueue.push(this.carryover),this.carryover="",!0);const t=e.value.split(this.separator);t[0]=this.carryover+t[0];for(const e of t.slice(0,-1))this.outputQueue.push(e);return this.carryover=t[t.length-1],!0}}class hk extends ES{decodeUTF8(){return new fk(this)}}class fk extends ck{constructor(e){super(),this.upstream=e,this.impl=new mk(e)}summary(){return this.impl.summary()}async next(){return this.impl.next()}}class mk extends PS{constructor(e){if(super(),this.upstream=e,Ge().get("IS_BROWSER"))this.decoder=new TextDecoder("utf-8");else{const{StringDecoder:e}=n(1601);this.decoder=new e("utf8")}}summary(){return`${this.upstream.summary()} -> Utf8`}async pump(){const e=await this.upstream.next();let t,n;return!e.done&&(t=e.value,n=Ge().get("IS_BROWSER")?this.decoder.decode(t,{stream:!0}):this.decoder.write(Buffer.from(t.buffer)),this.outputQueue.push(n),!0)}}class gk extends hk{constructor(e,t={}){super(),this.file=e,this.options=t,se(e instanceof Uint8Array||!!Ge().get("IS_BROWSER")&&(e instanceof File||e instanceof Blob),(()=>"FileChunkIterator only supports File, Blob and Uint8Array right now.")),this.offset=t.offset||0,this.chunkSize=t.chunkSize||1048576}summary(){return`FileChunks ${this.file}`}async next(){if(this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size))return{value:null,done:!0};const e=new Promise(((e,t)=>{const n=this.offset+this.chunkSize;if(this.file instanceof Uint8Array)e(new Uint8Array(this.file.slice(this.offset,n)));else{const r=new FileReader;r.onload=n=>{let a=r.result;if(a instanceof ArrayBuffer&&(a=new Uint8Array(a)),!(a instanceof Uint8Array))return t(new TypeError("FileReader returned unknown type."));e(a)},r.onabort=e=>t(new Error("Aborted")),r.onerror=e=>t(new Error(e.type));const a=this.file.slice(this.offset,n);r.readAsArrayBuffer(a)}this.offset=n}));return{value:await e,done:!1}}}function yk(e){return"string"==typeof e&&"file://"===e.slice(0,7)}class bk extends lk{constructor(e,t={}){super(),this.input=e,this.options=t}async iterator(){if(yk(this.input)&&Ge().get("IS_NODE")){const e=n(7792);this.input=e.readFileSync(this.input.slice(7))}return new gk(this.input,this.options)}}class xk extends lk{constructor(e,t={}){super(),this.url=e,this.fileOptions=t}async iterator(){return yk(this.url)?new bk(this.url,this.fileOptions).iterator():async function(e,t={},n){let r,a;var i;"string"==typeof e?r=e:(r=e.url,a={method:(i=e).method,headers:i.headers,body:i.body,mode:i.mode,credentials:i.credentials,cache:i.cache,redirect:i.redirect,referrer:i.referrer,integrity:i.integrity});const s=await(n||Ba)(r,a);if(s.ok){const e=new Uint8Array(await s.arrayBuffer());return new gk(e,t)}throw new Error(s.statusText)}(this.url,this.fileOptions)}}function vk(e,t={}){return new sk(new xk(e),t)}function _k(e){const t=IS(e);return KS((async()=>t))}function wk(e){return KS((async()=>{const t=await e();return IS((()=>t.next()))}))}async function Mk(e,t){return uk.create(e,t)}async function Nk(e){return ok.create(e)}const Sk="3.19.0";function kk(e,t){Array.isArray(e)||(e=[e]),e.forEach((e=>{null!=e&&se("complex64"!==e.dtype,(()=>`${t} does not support complex64 tensors in the CPU backend.`))}))}const Dk=Id;class Tk extends J{constructor(){super(),this.blockSize=48,this.firstUse=!0,this.data=new K(this,lo())}nextDataId(){return Tk.nextDataId++}write(e,t,n){this.firstUse&&(this.firstUse=!1,Ge().get("IS_NODE")&&ca("\n============================\nHi, 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. \n============================"));const r={id:this.nextDataId()};return this.data.set(r,{values:e,dtype:n,refCount:1}),r}makeTensorInfo(e,t,n){let r;if("string"===t&&null!=n&&n.length>0&&Ee(n[0])){const a=n.map((e=>Pa(e)));r=this.write(a,e,t)}else r=this.write(n,e,t);return{dataId:r,shape:e,dtype:t}}refCount(e){return this.data.has(e)?this.data.get(e).refCount:0}incRef(e){this.data.get(e).refCount++}decRef(e){this.data.has(e)&&this.data.get(e).refCount--}move(e,t,n,r,a){this.data.set(e,{values:t,dtype:r,refCount:a})}numDataIds(){return this.data.numDataIds()}async read(e){return this.readSync(e)}readSync(e){const{dtype:t,complexTensorInfos:n}=this.data.get(e);return"complex64"===t?yf(this.readSync(n.real.dataId),this.readSync(n.imag.dataId)):this.data.get(e).values}bufferSync(e){const t=this.readSync(e.dataId);if("string"===e.dtype)try{const n=t.map((e=>Ha(e)));return As(e.shape,e.dtype,n)}catch(e){throw new Error("Failed to decode encoded string bytes into utf-8")}return As(e.shape,e.dtype,t)}makeOutput(e,t,n){return lo().makeTensorFromTensorInfo(this.makeTensorInfo(t,n,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:n}=this.data.get(e);null!=n&&(this.disposeData(n.real.dataId,!0),this.disposeData(n.imag.dataId,!0)),this.data.delete(e)}return!0}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}async time(e){const t=za();return e(),{kernelMs:za()-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){kk([e],"where");const t=this.readSync(e.dataId);return Dk(e.shape,t)}dispose(){}floatPrecision(){return 32}epsilon(){return super.epsilon()}}function Ik(e,t,n){return({inputs:r,attrs:a,backend:i})=>{const{x:s}=r;if(kk(s,e),"string"===s.dtype||"string"===n)throw new Error("unaryKernelFunc does not support string input/output");const o=i,u=o.data.get(s.dataId).values,l=ce(s.shape),c=n||s.dtype,p=Me(c,l);for(let e=0;e{const{x:s}=r;if(kk(s,e),"string"===s.dtype||"string"===n)throw new Error("unaryKernelFunc does not support string input/output");const o=i,u=o.data.get(s.dataId).values,l=n||s.dtype,c=t(u,l,a);return o.makeTensorInfo(s.shape,l,c)}}Tk.nextDataId=0,Mo("cpu",(()=>new Tk),1);const Ck=Ik(Jt,(e=>e>=0?e:Math.exp(e)-1)),Ak={kernelName:Jt,backendName:"cpu",kernelFunc:Ck};function Lk(e){const{inputs:t,backend:n}=e,{x:r}=t;return n.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}const $k={kernelName:fn,backendName:"cpu",kernelFunc:Lk};function Ok(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{alpha:i}=r;kk([a],"leakyRelu");const s=ce(a.shape),o=n.data.get(a.dataId).values,u=we("float32",s);for(let e=0;e{const s=Lo(t,n),o=s.length,u=Re(s),l=we(i,ce(s)),c=t.length,p=n.length,d=Re(t),h=Re(n),f=Co(t,s),m=Co(n,s);if(f.length+m.length===0)for(let t=0;ti[e]=0));const s=je(i,c,d),g=n.slice(-p);m.forEach((e=>g[e]=0));const y=je(g,p,h);l[t]=e(r[s],a[y])}return[l,s]}}const Yk=Fk(((e,t)=>e<0?t*e:e));function zk(e){const{inputs:t,backend:n}=e,{x:r,alpha:a}=t;kk([r,a],"prelu");const i=n.data.get(r.dataId).values,s=n.data.get(a.dataId).values,[o,u]=Yk(r.shape,a.shape,i,s,"float32");return n.makeTensorInfo(u,"float32",o)}const Bk={kernelName:ir,backendName:"cpu",kernelFunc:zk},Pk=Ik(cr,(e=>Math.max(0,e))),Hk={kernelName:cr,backendName:"cpu",kernelFunc:Pk},jk=Ik(gr,(e=>Math.min(Math.max(0,e),6))),Uk={kernelName:gr,backendName:"cpu",kernelFunc:jk};function qk(e){return(t,n,r)=>{const a=we(n,t.length);for(let n=0;n1/(1+Math.exp(-e)))),Vk=Ik(Tr,(e=>1/(1+Math.exp(-e)))),Gk={kernelName:Tr,backendName:"cpu",kernelFunc:Vk};function Kk(e,t,n,r,a){if("linear"===n)return Lk({inputs:{x:t},backend:e});if("relu"===n)return Pk({inputs:{x:t},backend:e});if("elu"===n)return Ck({inputs:{x:t},backend:e});if("relu6"===n)return jk({inputs:{x:t},backend:e});if("prelu"===n)return zk({inputs:{x:t,alpha:r},backend:e});if("leakyrelu"===n)return Ok({inputs:{x:t},backend:e,attrs:{alpha:a}});if("sigmoid"===n)return Vk({inputs:{x:t},backend:e});throw new Error(`Activation ${n} has not been implemented for the CPU backend.`)}function Jk(e){const{inputs:t,backend:n}=e,{real:r,imag:a}=t,i=n.data.get(r.dataId).values,s=n.data.get(a.dataId).values,o=n.makeTensorInfo(r.shape,"complex64");return n.data.get(o.dataId).complexTensorInfos={real:n.makeTensorInfo(r.shape,"float32",i),imag:n.makeTensorInfo(a.shape,"float32",s)},o}const Xk={kernelName:St,backendName:"cpu",kernelFunc:Jk};function Zk(e,t,n="float32"){if("complex64"===n)return Jk({inputs:{real:Zk(e,t,"float32"),imag:Zk(e,t,"float32")},backend:e});const r=Be(ce(t),n);return e.makeTensorInfo(t,n,r)}function Qk(e){const{inputs:t,backend:n}=e,{input:r}=t,a=n.data.get(r.dataId).complexTensorInfos.real,i=n.data.get(a.dataId).values;return n.makeTensorInfo(a.shape,a.dtype,i)}const eD={kernelName:ur,backendName:"cpu",kernelFunc:Qk};function tD(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{dtype:i}=r;if("complex64"===i){if("complex64"===a.dtype)return Lk({inputs:{x:a},backend:n});const e=Zk(n,a.shape,a.dtype),t=tD({inputs:{x:a},backend:n,attrs:{dtype:"float32"}}),r=Jk({inputs:{real:t,imag:e},backend:n});return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(t),r}if("complex64"===a.dtype){const e=Qk({inputs:{input:a},backend:n}),t=tD({inputs:{x:e},backend:n,attrs:{dtype:i}});return n.disposeIntermediateTensorInfo(e),t}if(!ke(a.dtype,i)){const e=Lk({inputs:{x:a},backend:n});return{dataId:e.dataId,shape:e.shape,dtype:i}}if("int32"===i){const e=n.data.get(a.dataId).values,t=Int32Array.from(e);return n.makeTensorInfo(a.shape,"int32",t)}if("bool"===i){const e=n.data.get(a.dataId).values,t=Ya([0],a.dtype),[r,i]=Fk(((e,t)=>e!==t?1:0))(a.shape,[],e,t,"bool");return n.makeTensorInfo(i,"bool",r)}throw new Error(`Error in Cast: failed to cast ${a.dtype} to ${i}`)}const nD={kernelName:wt,backendName:"cpu",kernelFunc:tD};function rD(e,t,n,r){return null==n?({inputs:n,backend:a})=>{const{a:i,b:s}=n,o=a;kk([i,s],e);const u=o.data.get(i.dataId).values,l=o.data.get(s.dataId).values,c="string"===i.dtype?Gf(u):u,p="string"===i.dtype?Gf(l):l,d=r||i.dtype,[h,f]=t(i.shape,s.shape,c,p,d);return o.makeTensorInfo(f,d,h)}:({inputs:e,backend:a})=>{const{a:i,b:s}=e,o=a;if("complex64"===i.dtype||"complex64"===s.dtype){const e=tD({inputs:{x:i},backend:o,attrs:{dtype:"complex64"}}),t=o.data.get(e.dataId),r=t.complexTensorInfos.real,a=t.complexTensorInfos.imag,u=o.data.get(r.dataId).values,l=o.data.get(a.dataId).values,c=tD({inputs:{x:s},backend:o,attrs:{dtype:"complex64"}}),p=o.data.get(c.dataId),d=p.complexTensorInfos.real,h=p.complexTensorInfos.imag,f=o.data.get(d.dataId).values,m=o.data.get(h.dataId).values,[g,y,b]=n(i.shape,s.shape,u,l,f,m),x=o.makeTensorInfo(b,"float32",g),v=o.makeTensorInfo(b,"float32",y),_=Jk({inputs:{real:x,imag:v},backend:o});return o.disposeIntermediateTensorInfo(e),o.disposeIntermediateTensorInfo(c),o.disposeIntermediateTensorInfo(x),o.disposeIntermediateTensorInfo(v),_}{const e=o.data.get(i.dataId).values,n=o.data.get(s.dataId).values,a=r||i.dtype,[u,l]=t(i.shape,s.shape,e,n,a);return o.makeTensorInfo(l,a,u)}}}function aD(e){return(t,n,r,a,i,s)=>{const o=Lo(t,n),u=ce(o),l=o.length,c=Re(o),p=we("float32",u),d=we("float32",u),h=Co(t,o),f=Co(n,o),m=yf(r,a),g=yf(i,s),y=t.length,b=Re(t),x=n.length,v=Re(n);if(h.length+f.length===0)for(let t=0;tr[e]=0));const a=je(r,y,b),i=n.slice(-x);f.forEach((e=>i[e]=0));const s=je(i,x,v),o=e(m[2*a],m[2*a+1],g[2*s],g[2*s+1]);p[t]=o.real,d[t]=o.imag}return[p,d,o]}}const iD=Fk(((e,t)=>e+t)),sD=aD(((e,t,n,r)=>({real:e+n,imag:t+r}))),oD=rD(nt,iD,sD),uD={kernelName:nt,backendName:"cpu",kernelFunc:oD};function lD(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{shape:i}=r,s=ce(a.shape),o=xe(i,s),u=ce(o);se(s===u,(()=>`The new shape (${o}) has ${u} elements and the old shape (${a.shape}) has ${s} elements. The new shape and old shape must have the same number of elements.`)),n.incRef(a.dataId);const l=n.data.get(a.dataId);if(null!=l.complexTensorInfos){const e=l.complexTensorInfos.real,t=l.complexTensorInfos.imag;e.shape=o,t.shape=o}return{dataId:a.dataId,shape:o,dtype:a.dtype}}const cD={kernelName:pr,backendName:"cpu",kernelFunc:lD};function pD(e){const{inputs:t,backend:n,attrs:r}=e,{a,b:i}=t,{transposeA:s,transposeB:o}=r;kk([a,i],"matMul");const u=a.shape.length,l=i.shape.length,c=s?a.shape[u-2]:a.shape[u-1],p=o?i.shape[l-1]:i.shape[l-2],d=s?a.shape[u-1]:a.shape[u-2],h=o?i.shape[l-2]:i.shape[l-1],f=a.shape.slice(0,-2),m=i.shape.slice(0,-2),g=ce(f),y=ce(m),b=Lo(a.shape.slice(0,-2),i.shape.slice(0,-2)).concat([d,h]);se(c===p,(()=>`Error in matMul: inner shapes (${c}) and (${p}) of Tensors with shapes ${a.shape} and ${i.shape} and transposeA=${s} and transposeB=${o} must match.`));const x=o?[y,h,p]:[y,p,h],v=lD({inputs:{x:a},backend:n,attrs:{shape:s?[g,c,d]:[g,d,c]}}),_=lD({inputs:{x:i},backend:n,attrs:{shape:x}}),w=s?v.shape[1]:v.shape[2],M=s?v.shape[2]:v.shape[1],N=o?_.shape[1]:_.shape[2],S=Math.max(g,y),k=n.data.get(v.dataId).values,D=n.data.get(_.dataId).values,T=Re(v.shape),I=Re(_.shape),[E,C,A]=s?[T[0],1,T[1]]:[T[0],T[1],1],[L,$,O]=o?[1,I[1],I[0]]:[I[1],1,I[0]],R=M*N,F=As([S,M,N],v.dtype),Y=F.values,z=n.blockSize;for(let e=0;e{const{x:t}=e.inputs,n=e.backend;kk(t,"abs");let r=new Float32Array(ce(t.shape));return r=fD(n.data.get(t.dataId).values),n.makeOutput(r,t.shape,t.dtype)}},gD=Ik(et,(e=>Math.acos(e))),yD={kernelName:et,backendName:"cpu",kernelFunc:gD},bD=Ik(tt,(e=>Math.acosh(e))),xD={kernelName:tt,backendName:"cpu",kernelFunc:bD},vD={kernelName:rt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,r=t;kk(t,"addN");const a=r.map((e=>n.data.get(e.dataId).values)),i=As(r[0].shape,r[0].dtype),s=i.values;for(let e=0;en&&(n=a,r=e)}d[e]=r}return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(c,"int32",d)}},DD={kernelName:ot,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i}=r;kk(a,"argMin");let s=ve(i,a.shape);const o=xc(s,a.shape.length);let u=a;const l=[];null!=o&&(u=wD({inputs:{x:a},backend:n,attrs:{perm:o}}),l.push(u),s=_c(s.length,u.shape.length)),s=[s[0]],bc("argMin",s,u.shape.length);const[c,p]=gc(u.shape,s),d=Be(ce(c),"int32"),h=ce(p),f=n.data.get(u.dataId).values;for(let e=0;en.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(c,"int32",d)}},TD=Ik(ut,(e=>Math.asin(e))),ID={kernelName:ut,backendName:"cpu",kernelFunc:TD},ED=Ik(lt,(e=>Math.asinh(e))),CD={kernelName:lt,backendName:"cpu",kernelFunc:ED},AD=Ik(ct,(e=>Math.atan(e))),LD={kernelName:ct,backendName:"cpu",kernelFunc:AD},$D=Fk(((e,t)=>Math.atan2(e,t))),OD=rD(dt,$D),RD={kernelName:dt,backendName:"cpu",kernelFunc:OD},FD=Ik(pt,(e=>Math.atanh(e))),YD={kernelName:pt,backendName:"cpu",kernelFunc:FD};function zD(e,t,n,r,a,i){const s=a.strideHeight,o=a.strideWidth,u=a.dilationHeight,l=a.dilationWidth,c=a.effectiveFilterHeight,p=a.effectiveFilterWidth,d=a.padInfo.top,h=a.padInfo.left,f="max"===i?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,m=As(a.outShape,n),g=m.values,y=a.outShape[1]*a.outShape[2]*a.outShape[3],b=a.outShape[2]*a.outShape[3],x=a.outShape[3];for(let t=0;ty?y=s:"avg"===i&&(b+=s,v++)}if(isNaN(y))break}g[M+n*x+t]="avg"===i?b/v:y}}}return m}function BD(e,t,n,r,a=!1,i=!1){const s=As(r.outShape,"int32"),o=r.strideHeight,u=r.strideWidth,l=r.dilationHeight,c=r.dilationWidth,p=r.effectiveFilterHeight,d=r.effectiveFilterWidth,h=r.padInfo.top,f=r.padInfo.left,m=As(t,n,e);for(let e=0;ev&&(v=l,_=a?i?((e*r.inHeight+n)*r.inWidth+o)*r.inChannels+t:(n*r.inWidth+o)*r.inChannels+t:s*d+u)}}s.set(_,e,n,o,t)}}return s}function PD(e,t,n,r,a,i){const s=a.strideDepth,o=a.strideHeight,u=a.strideWidth,l=a.dilationDepth,c=a.dilationHeight,p=a.dilationWidth,d=a.effectiveFilterDepth,h=a.effectiveFilterHeight,f=a.effectiveFilterWidth,m=a.padInfo.front,g=a.padInfo.top,y=a.padInfo.left,b="max"===i?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,x=As(a.outShape,n),v=x.values,_=a.outShape[1]*a.outShape[2]*a.outShape[3]*a.outShape[4],w=a.outShape[2]*a.outShape[3]*a.outShape[4],M=a.outShape[3]*a.outShape[4],N=a.outShape[4];for(let t=0;tw?w=a:"avg"===i&&(M+=a,S++),isNaN(w))break}if(isNaN(w))break}if(isNaN(w))break}v[g+t]="avg"===i?M/S:w}}}}return x}const HD={kernelName:ht,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t;kk(a,"avgPool");const{filterSize:i,strides:s,pad:o,dimRoundingMode:u}=r;se(vl(s,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${s} and dilations '1'`));const l=cl(a.shape,i,s,1,o,u);let c;if(1===l.filterWidth&&1===l.filterHeight&&de(l.inShape,l.outShape))c=Lk({inputs:{x:a},backend:n});else{const e=n.data.get(a.dataId).values,t=Re(a.shape),r=zD(e,a.shape,a.dtype,t,l,"avg");c=n.makeTensorInfo(l.outShape,a.dtype,r.values)}return c}},jD={kernelName:mt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{filterSize:i,strides:s,pad:o,dimRoundingMode:u,dataFormat:l}=r;kk(a,"avgPool3d");const c=pl(a.shape,i,s,1,o,u,l),p=PD(n.data.get(a.dataId).values,a.shape,a.dtype,Re(a.shape),c,"avg");return n.makeTensorInfo(p.shape,"float32",p.values)}},UD={kernelName:gt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i}=t,{filterSize:s,strides:o,pad:u,dimRoundingMode:l}=r;kk([a,i],"avgPool3DGrad");const c=pl(i.shape,s,o,1,u,l),p=c.strideDepth,d=c.strideHeight,h=c.strideWidth,f=c.filterDepth,m=c.filterHeight,g=c.filterWidth,y=c.dilationDepth,b=c.dilationHeight,x=c.dilationWidth,v=c.effectiveFilterDepth,_=c.effectiveFilterHeight,w=c.effectiveFilterWidth,M=v-1-c.padInfo.front,N=w-1-c.padInfo.left,S=_-1-c.padInfo.top,k=As(i.shape,"float32"),D=1/(f*m*g),T=n.bufferSync(a);for(let e=0;e=c.outDepth||Math.floor(r)!==r))for(let n=0;n<_;n+=b){const a=(s+n)/d;if(!(a<0||a>=c.outHeight||Math.floor(a)!==a))for(let n=0;n=c.outWidth||Math.floor(i)!==i||(u+=T.get(e,r,a,i,t))}}}k.set(u*D,e,n,r,a,t)}return n.makeTensorInfo(k.shape,k.dtype,k.values)}},qD={kernelName:ft,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i}=t,s=i;kk([a,i],"avgPoolGrad");const{filterSize:o,strides:u,pad:l}=r,c=cl(s.shape,o,u,1,l),p=c.strideHeight,d=c.strideWidth,h=c.filterHeight,f=c.filterWidth,m=c.dilationHeight,g=c.dilationWidth,y=c.effectiveFilterHeight,b=c.effectiveFilterWidth,x=b-1-c.padInfo.left,v=y-1-c.padInfo.top,_=As(s.shape,"float32"),w=1/(h*f),M=n.data.get(a.dataId).values,N=As(a.shape,"float32",M);for(let e=0;e=c.outHeight||Math.floor(r)!==r))for(let n=0;n=c.outWidth||Math.floor(a)!==a||(s+=N.get(e,r,a,t))}}_.set(s*w,e,n,r,t)}return n.makeTensorInfo(_.shape,_.dtype,_.values)}},WD={kernelName:ln,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,scale:i,offset:s,mean:o,variance:u}=t;se(o.shape.length===u.shape.length,(()=>"Batch normalization gradient requires mean and variance to have equal ranks.")),se(null==s||o.shape.length===s.shape.length,(()=>"Batch normalization gradient requires mean and offset to have equal ranks.")),se(null==i||o.shape.length===i.shape.length,(()=>"Batch normalization gradient requires mean and scale to have equal ranks.")),kk([a,o,u,i,s],"batchNorm");let{varianceEpsilon:l}=r;null==l&&(l=.001);const c=n.data.get(a.dataId).values,p=n.data.get(o.dataId).values,d=n.data.get(u.dataId).values,h=i?n.data.get(i.dataId).values:new Float32Array([1]),f=s?n.data.get(s.dataId).values:new Float32Array([0]),m=new Float32Array(c.length),g=f.length,y=h.length,b=d.length,x=p.length;let v=0,_=0,w=0,M=0;for(let e=0;e=g&&(v=0),_>=x&&(_=0),w>=y&&(w=0),M>=b&&(M=0);return n.makeTensorInfo(a.shape,a.dtype,m)}};function VD(e,t,n,r,a){const i=nu(r,t,n),s=ce(n),o=Re(r);if(i){const n=ru(t,o);return"string"===a?e.slice(n,n+s):e.subarray(n,n+s)}const u=As(r,a,"string"===a?Gf(e):e),l=As(n,a);for(let e=0;ee+t[n]));l.set(u.get(...r),...n)}return"string"===a?Kf(l.values):l.values}function GD(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{begin:i,size:s}=r;kk(a,"slice");const[o,u]=au(a,i,s);Uo(a,o,u);const l=VD(n.data.get(a.dataId).values,o,u,a.shape,a.dtype);return n.makeTensorInfo(u,a.dtype,l)}const KD={kernelName:Nr,backendName:"cpu",kernelFunc:GD},JD={kernelName:bt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockShape:i,crops:s}=r;kk([a],"batchToSpaceND");const o=i.reduce(((e,t)=>e*t)),u=rf(a.shape,i,o),l=af(u.length,i.length),c=sf(a.shape,i,o),p=of(s,i.length),d=uf(c,s,i.length),h=lD({inputs:{x:a},backend:n,attrs:{shape:u}}),f=wD({inputs:{x:h},backend:n,attrs:{perm:l}}),m=lD({inputs:{x:f},backend:n,attrs:{shape:c}}),g=GD({inputs:{x:m},backend:n,attrs:{begin:p,size:d}});return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),g}};function XD(e,t,n,r,a){const i=ce(r),s=Be(a,n);for(let n=0;n=a||(s[r]+=i>0?t[n]:1)}return s}function ZD(e,t,n,r=!1){const a=e.shape[0],i=e.shape[1],s=As([a,n],t.dtype);for(let o=0;o=n||(r?s.set(1,o,i):t.size>0?s.set(s.get(o,i)+t.get(o,a),o,i):s.set(s.get(o,i)+1,o,i))}return s}const QD={kernelName:xt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,weights:i}=t,{size:s}=r,o=XD(n.data.get(a.dataId).values,n.data.get(i.dataId).values,i.dtype,i.shape,s);return n.makeTensorInfo([s],i.dtype,o)}},eT={kernelName:_t,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{s0:r,s1:a}=t,i=n.data.get(r.dataId).values,s=n.data.get(a.dataId).values,o=Lo(Array.from(i),Array.from(s));return n.makeTensorInfo([o.length],"int32",Int32Array.from(o))}},tT=qk((e=>Math.ceil(e))),nT=Ek(Mt,tT),rT={kernelName:Mt,backendName:"cpu",kernelFunc:nT},aT=Ik(Nt,((e,t)=>{const n=t;return e>n.clipValueMax?n.clipValueMax:e{const{x:t}=e.inputs,n=e.backend,r=new Float32Array(ce(t.shape)),a=n.data.get(t.dataId),i=a.complexTensorInfos.real,s=a.complexTensorInfos.imag,o=n.data.get(i.dataId).values,u=n.data.get(s.dataId).values;for(let e=0;e{const n=ce(e.shape);a.set(e.vals,t),t+=n}))}else{let r=0;e.forEach((e=>{const i="string"===n?Gf(e.vals):e.vals;let s=0;for(let n=0;ne.shape)),i);if(0===ce(s))return n.makeTensorInfo(s,t[0].dtype,[]);const o=t.filter((e=>ce(e.shape)>0));if(1===o.length)return Lk({inputs:{x:o[0]},backend:n});if(Zh(o.map((e=>e.shape)),i),"complex64"===o[0].dtype){const e=o.map((e=>Qk({inputs:{input:e},backend:n}))),t=o.map((e=>uT({inputs:{input:e},backend:n}))),r=cT({inputs:e,backend:n,attrs:{axis:i}}),a=cT({inputs:t,backend:n,attrs:{axis:i}}),s=Jk({inputs:{real:r,imag:a},backend:n});return e.forEach((e=>n.disposeIntermediateTensorInfo(e))),t.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(a),s}const u=o.map((e=>{const t=ce(e.shape.slice(i));return lD({inputs:{x:e},backend:n,attrs:{shape:[-1,t]}})})),l=u.map((e=>({vals:n.data.get(e.dataId).values,shape:e.shape})));s=Qh(u.map((e=>e.shape)),1);const c=1===u[0].shape[0],p=oT(l,s,t[0].dtype,c),d=Qh(o.map((e=>e.shape)),i),h=n.makeTensorInfo(d,t[0].dtype,p);return u.forEach((e=>n.disposeIntermediateTensorInfo(e))),h}const pT={kernelName:Dt,backendName:"cpu",kernelFunc:cT};function dT(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i}=t,{strides:s,pad:o,dataFormat:u,dilations:l,dimRoundingMode:c}=r;kk([a,i],"conv2d");const p=_l(u),d=dl(a.shape,i.shape,s,l,o,c,!1,p),h=d.filterHeight,f=d.filterWidth,m=d.dilationHeight,g=d.dilationWidth,y=d.padInfo.left,b=d.padInfo.top,x="channelsLast"===d.dataFormat,v=new Xa(d.outShape,a.dtype),_=Re(a.shape),w=Re(i.shape),M=_[0],N=x?_[1]:_[2],S=x?_[2]:1,k=x?1:_[1],D=v.strides[0],T=x?v.strides[1]:v.strides[2],I=x?v.strides[2]:1,E=x?1:v.strides[1],C=n.data.get(a.dataId).values,A=n.data.get(i.dataId).values,L=v.values;for(let e=0;e=d.inHeight)continue;const i=e*w[0],s=t+n*N;for(let e=0;e=d.inWidth)continue;const a=s+r*S;let o=i+e*w[1];for(let e=0;e=l.inDepth)continue;const i=e*S[0],s=t+n*N[1];for(let e=0;e=l.inHeight)continue;const a=i+e*S[1],o=s+r*N[2];for(let e=0;e=l.inWidth)continue;const i=a+e*S[2],s=o+t*l.inChannels;let u=i;for(let e=0;eMath.cos(e))),vT={kernelName:$t,backendName:"cpu",kernelFunc:xT},_T=Ik(Ot,(e=>Math.cosh(e))),wT={kernelName:Ot,backendName:"cpu",kernelFunc:_T},MT={kernelName:Yt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{image:a,boxes:i,boxInd:s}=t,{cropSize:o,method:u,extrapolationValue:l}=r,[c,p,d,h]=a.shape,f=i.shape[0],[m,g]=o,y=As([f,m,g,h],"float32"),b=n.data.get(i.dataId).values,x=n.data.get(s.dataId).values,v=n.data.get(a.dataId).values,_=Re(a.shape),w=Re(y.shape);for(let e=0;e=c)continue;const o=m>1?(a-n)*(p-1)/(m-1):0,f=g>1?(i-r)*(d-1)/(g-1):0;for(let t=0;t1?n*(p-1)+t*o:.5*(n+a)*(p-1);if(c<0||c>p-1)for(let n=0;n1?r*(d-1)+u*f:.5*(r+i)*(d-1);if(c<0||c>d-1){for(let n=0;n1?r*(d-1)+n*f:.5*(r+i)*(d-1);if(a<0||a>d-1){for(let r=0;re+f-t-1:(e,t)=>e+t;for(let e=0;ee+f-t-1:(e,t)=>e+t;for(let e=0;e`Only NHWC dataFormat supported on CPU for depthToSpace. Got ${s}`));const o=a.shape[0],u=a.shape[1],l=a.shape[2],c=a.shape[3],p=u*i,d=l*i,h=c/(i*i),f=n.data.get(a.dataId).values,m=new Float32Array(o*p*d*h);let g=0;for(let e=0;e`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${s} and dilations '${d}'`));const h=dl(a.shape,i.shape,s,d,o,l,!0),{filterHeight:f,filterWidth:m,dilationHeight:g,dilationWidth:y,padInfo:b}=h,x=b.left,v=b.top,_=h.outChannels/h.inChannels,w=new Xa(h.outShape,a.dtype),M=n.data.get(a.dataId).values,N=n.data.get(i.dataId).values,S=w.values;for(let e=0;e=h.inHeight)continue;const i=e*p[0],s=t+n*c[1];for(let e=0;e=h.inWidth)continue;const a=i+e*p[1],o=s+r*h.inChannels;let u=t,l=a;for(let e=0;e{const{x:r,filter:a}=e,{strides:i,pad:s,dilations:o}=n,u=t,l=u.data.get(r.dataId).values,c=r.shape.length,p=u.data.get(a.dataId).values,d=a.shape.length,{batchSize:h,inHeight:f,inWidth:m,inChannels:g,outHeight:y,outWidth:b,padInfo:x,strideHeight:v,strideWidth:_,filterHeight:w,filterWidth:M,dilationHeight:N,dilationWidth:S,outShape:k}=ll(r.shape,a.shape,i,s,"NHWC",o),D=ce(k),T=k.length,I=Me(r.dtype,D);for(let e=0;e=0&&i=0&&hu&&(u=m)}}}I[je([e,t,i,o],T,Re(k))]=u}}}return{dataId:u.write(Ya(I,r.dtype),k,r.dtype),shape:k,dtype:r.dtype}}},$T={kernelName:Vt,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:r,filter:a,dy:i}=e,{strides:s,pad:o,dilations:u}=n,l=t,c=Ye(r.shape,l.data.get(r.dataId).values),p=Ye(a.shape,l.data.get(a.dataId).values),{batchSize:d,inHeight:h,inWidth:f,inChannels:m,outHeight:g,outWidth:y,padInfo:b,strideHeight:x,strideWidth:v,filterHeight:_,filterWidth:w,dilationHeight:M,dilationWidth:N,outShape:S}=ll(r.shape,a.shape,s,o,"NHWC",u);se(i.rank===S.length,(()=>`Error in ${Vt}, dy must have the same rank as output ${S.length}, but got ${i.rank}`));const k=Ye(S,l.data.get(i.dataId).values),D=Pe(a.shape,a.dtype);for(let e=0;e=0&&r=0&&ls&&(s=a,o=t,u=n)}}}D[o][u][i]+=k[e][t][r][i]}}}return{dataId:l.write(Ya(D,r.dtype),a.shape,a.dtype),shape:a.shape,dtype:a.dtype}}},OT={kernelName:Wt,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:r,filter:a,dy:i}=e,{strides:s,pad:o,dilations:u}=n,l=t,c=Ye(r.shape,l.data.get(r.dataId).values),p=Ye(a.shape,l.data.get(a.dataId).values),{batchSize:d,inHeight:h,inWidth:f,inChannels:m,outHeight:g,outWidth:y,padInfo:b,strideHeight:x,strideWidth:v,filterHeight:_,filterWidth:w,dilationHeight:M,dilationWidth:N,outShape:S}=ll(r.shape,a.shape,s,o,"NHWC",u);se(i.rank===S.length,(()=>`Error in ${Wt}, dy must have the same rank as output ${S.length}, but got ${i.rank}`));const k=Ye(S,l.data.get(i.dataId).values),D=Pe(r.shape,r.dtype);for(let e=0;e=0&&r=0&&ls&&(s=a,o=r,u=l)}}}D[e][o][u][i]+=k[e][t][r][i]}}}return{dataId:l.write(Ya(D,r.dtype),r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}},RT=Fk(((e,t)=>e*t)),FT=aD(((e,t,n,r)=>({real:e*n-t*r,imag:e*r+t*n}))),YT=rD(Vn,RT,FT),zT={kernelName:Vn,backendName:"cpu",kernelFunc:YT};function BT(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,keepDims:s}=r;let o;kk(a,"sum"),o="bool"===a.dtype?tD({inputs:{x:a},backend:n,attrs:{dtype:"int32"}}):Lk({inputs:{x:a},backend:n});const u=o.shape.length,l=ve(i,o.shape),c=xc(l,u);let p=l,d=o;null!=c&&(d=wD({inputs:{x:o},backend:n,attrs:{perm:c}}),p=_c(p.length,u)),bc("sum",p,d.shape.length);const[h,f]=gc(d.shape,p);let m=Zk(n,h,ci(d.dtype,"int32"));const g=ce(f),y=n.data.get(m.dataId).values,b=n.data.get(d.dataId).values;for(let e=0;e=0&&(d=BT({inputs:{x:d},backend:n,attrs:{axis:l[e]-(s.length-h),keepDims:!1}}),f.push(d)),h--)}for(const e of f)e!==d&&n.disposeIntermediateTensorInfo(e);return d}},jT={kernelName:Xt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{dy:r,y:a}=t;kk([r,a],"eluGrad");const i=new Float32Array(ce(a.shape)),s=n.data.get(a.dataId).values,o=n.data.get(r.dataId).values;for(let e=0;e=1?o[e]:o[e]*(t+1)}return n.makeTensorInfo(a.shape,"float32",i)}},UT=Fk(((e,t)=>e===t?1:0)),qT=rD(Qt,UT,null,"bool"),WT={kernelName:Qt,backendName:"cpu",kernelFunc:qT},VT=pf,GT=df,KT=hf,JT=ff,XT=mf,ZT=gf,QT=Ik(Zt,(e=>{const t=Math.sign(e),n=Math.abs(e),r=1/(1+VT*n);return t*(1-((((ZT*r+XT)*r+JT)*r+KT)*r+GT)*r*Math.exp(-n*n))})),eI={kernelName:Zt,backendName:"cpu",kernelFunc:QT},tI=qk((e=>Math.exp(e))),nI=Ek(en,tI,"float32"),rI={kernelName:en,backendName:"cpu",kernelFunc:nI};function aI(e){const{inputs:t,backend:n,attrs:r}=e,{input:a}=t,{dim:i}=r,s=a.shape.length,o=a.shape.slice();let u=i;return i<0&&(se(-(s+1)<=i,(()=>`Axis must be in the interval [${-(s+1)}, ${s}]`)),u=s+i+1),o.splice(u,0,1),lD({inputs:{x:a},backend:n,attrs:{shape:o}})}const iI={kernelName:tn,backendName:"cpu",kernelFunc:aI},sI=qk((e=>Math.expm1(e))),oI=Ek(nn,sI),uI={kernelName:nn,backendName:"cpu",kernelFunc:oI},lI=Fk(((e,t)=>e/t)),cI=rD(Gt,lI),pI={kernelName:Gt,backendName:"cpu",kernelFunc:cI},dI=Fk(((e,t)=>e-t)),hI=aD(((e,t,n,r)=>({real:e-n,imag:t-r}))),fI=rD(Wr,dI,hI),mI={kernelName:Wr,backendName:"cpu",kernelFunc:fI};function gI(e,t,n){const r=e.shape,a=r[0],i=r[1],s=n.data.get(e.dataId),o=s.complexTensorInfos.real,u=s.complexTensorInfos.imag,l=[a,i],c=ce(l),p=we("float32",c),d=we("float32",c);for(let e=0;e{const{image:r}=e,a=n,i=we(r.dtype,ce(r.shape)),[s,o,u,l]=r.shape,c=a.data.get(r.dataId).values;for(let e=0;e=0&&sMath.floor(e))),NI=Ek(on,MI),SI={kernelName:on,backendName:"cpu",kernelFunc:NI},kI=Fk(((e,t)=>Math.floor(e/t))),DI=rD(un,kI,null,"int32"),TI={kernelName:un,backendName:"cpu",kernelFunc:DI},II={kernelName:ua,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i,bias:s,preluActivationWeights:o}=t,{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:d,activation:h,leakyreluAlpha:f}=r;let m=dT({inputs:{x:a,filter:i},backend:n,attrs:{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:d}});if(s){const e=m;if("NCHW"===c&&1===s.shape.length&&1!==s.shape[0]){const e=lD({inputs:{x:s},backend:n,attrs:{shape:[s.shape[0],1,1]}});m=oD({inputs:{a:m,b:e},backend:n}),n.disposeIntermediateTensorInfo(e)}else m=oD({inputs:{a:m,b:s},backend:n});n.disposeIntermediateTensorInfo(e)}if(h){const e=m;if("NCHW"===c&&"prelu"===h&&1===o.shape.length&&1!==o.shape[0]){const e=lD({inputs:{x:o},backend:n,attrs:{shape:[o.shape[0],1,1]}});m=Kk(n,m,h,e,f),n.disposeIntermediateTensorInfo(e)}else m=Kk(n,m,h,o,f);n.disposeIntermediateTensorInfo(e)}return m}},EI={kernelName:la,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i,bias:s,preluActivationWeights:o}=t,{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:d,activation:h,leakyreluAlpha:f}=r;let m=TT({inputs:{x:a,filter:i},backend:n,attrs:{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:d}});if(s){const e=m;m=oD({inputs:{a:m,b:s},backend:n}),n.disposeIntermediateTensorInfo(e)}if(h){const e=m;m=Kk(n,m,h,o,f),n.disposeIntermediateTensorInfo(e)}return m}};function CI(e,t,n,r,a,i,s,o,u){const l=As([r,i],n);for(let n=0;n=u/i)throw new Error(`Invalid indices: ${r} does not index into ${o}`);for(let e=0;e=0,(()=>`GatherV2: the index value ${t} is not in [0, ${c-1}]`))}let p=o;null==o&&(p=0);const d=ce(i.shape),h=Vf(a,i,u,p),f=lD({inputs:{x:a},backend:n,attrs:{shape:[h.batchSize,h.outerSize,h.dimSize,h.sliceSize]}}),m=lD({inputs:{x:i},backend:n,attrs:{shape:[h.batchSize,d/h.batchSize]}}),g=[h.batchSize,h.outerSize,d/h.batchSize,h.sliceSize],y=n.bufferSync(m),b=LI(n.bufferSync(f),y,g);return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),n.makeTensorInfo(h.outputShape,b.dtype,b.values)}},OI=Fk(((e,t)=>e>t?1:0)),RI=rD(dn,OI,null,"bool"),FI={kernelName:dn,backendName:"cpu",kernelFunc:RI},YI=Fk(((e,t)=>e>=t?1:0)),zI=rD(hn,YI,null,"bool"),BI={kernelName:hn,backendName:"cpu",kernelFunc:zI},PI={kernelName:mn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{input:r}=t,a=ce(r.shape),i=r.shape[r.shape.length-1],s=lD({inputs:{x:r},backend:n,attrs:{shape:[a/i,i]}}),o=gI(s,!0,n),u=lD({inputs:{x:o},backend:n,attrs:{shape:r.shape}});return n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(o),u}},HI=Ik(yn,(e=>Number.isFinite(e)?1:0),"bool"),jI={kernelName:yn,backendName:"cpu",kernelFunc:HI},UI=Ik(bn,(e=>Math.abs(e)===1/0?1:0),"bool"),qI={kernelName:bn,backendName:"cpu",kernelFunc:UI},WI=Ik(xn,(e=>Number.isNaN(e)?1:0),"bool"),VI={kernelName:xn,backendName:"cpu",kernelFunc:WI},GI=Fk(((e,t)=>ee<=t?1:0)),ZI=rD(wn,XI,null,"bool"),QI={kernelName:wn,backendName:"cpu",kernelFunc:ZI};function eE(e,t,n){const r=(t-e)/(n-1),a=Be(n,"float32");a[0]=e;for(let e=1;eMath.log(e))),rE=Ek(Nn,nE),aE={kernelName:Nn,backendName:"cpu",kernelFunc:rE},iE=Ik(Sn,(e=>Math.log1p(e))),sE={kernelName:Sn,backendName:"cpu",kernelFunc:iE},oE=Fk(((e,t)=>e&&t)),uE=rD(kn,oE,null,"bool"),lE={kernelName:kn,backendName:"cpu",kernelFunc:uE},cE=Ik(Dn,(e=>e?0:1),"bool"),pE={kernelName:Dn,backendName:"cpu",kernelFunc:cE},dE=Fk(((e,t)=>e||t)),hE=rD(Tn,dE,null,"bool"),fE={kernelName:Tn,backendName:"cpu",kernelFunc:hE},mE={kernelName:An,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{depthRadius:i,bias:s,alpha:o,beta:u}=r;kk(a,"LRN");const l=a.shape[3],c=l-1,p=n.data.get(a.dataId).values,d=ce(a.shape),h=new Float32Array(d);function f(e){const t=e%l;let n=e-t+Math.max(0,t-i);const r=e-t+Math.min(t+i,c);let a=0;for(;n<=r;n++){const e=p[n];a+=e*e}return a}for(let e=0;ei)&&(i=t)}a[n]=i}return a}function bE(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{reductionIndices:i,keepDims:s}=r,o=n;let u=a.shape;const l=u.length,c=ve(i,u);let p=c;const d=xc(p,l);let h=o.data.get(a.dataId).values;if(null!=d){const e=new Array(l);for(let t=0;tMath.max(e,t))),_E=rD(On,vE),wE={kernelName:On,backendName:"cpu",kernelFunc:_E},ME={kernelName:Rn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t;kk(a,"maxPool");const{filterSize:i,strides:s,pad:o,dimRoundingMode:u}=r;se(vl(s,1),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${s} and dilations '1'`));const l=cl(a.shape,i,s,1,o,u);let c;if(1===l.filterWidth&&1===l.filterHeight&&de(l.inShape,l.outShape))c=Lk({inputs:{x:a},backend:n});else{const e=n.data.get(a.dataId).values,t=Re(a.shape),r=zD(e,a.shape,a.dtype,t,l,"max");c=n.makeTensorInfo(l.outShape,a.dtype,r.values)}return c}},NE={kernelName:Yn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{filterSize:i,strides:s,pad:o,dimRoundingMode:u,dataFormat:l}=r;kk(a,"maxPool3d");const c=pl(a.shape,i,s,1,o,u,l),p=PD(n.data.get(a.dataId).values,a.shape,a.dtype,Re(a.shape),c,"max");return n.makeTensorInfo(p.shape,"float32",p.values)}},SE={kernelName:zn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i}=t,{filterSize:s,strides:o,pad:u,dimRoundingMode:l}=r;kk([a,i],"maxPool3DGrad");const c=pl(i.shape,s,o,1,u,l),p=function(e,t){const n=As(t.outShape,"int32"),r=t.strideDepth,a=t.strideHeight,i=t.strideWidth,s=t.dilationDepth,o=t.dilationHeight,u=t.dilationWidth,l=t.effectiveFilterDepth,c=t.effectiveFilterHeight,p=t.effectiveFilterWidth,d=t.padInfo.front,h=t.padInfo.top,f=t.padInfo.left;for(let m=0;m=N&&(N=o,S=n*c*p+a*c+s)}}}n.set(S,m,y,r,a,g)}}}return n}(n.bufferSync(i),c),d=c.strideDepth,h=c.strideHeight,f=c.strideWidth,m=c.dilationDepth,g=c.dilationHeight,y=c.dilationWidth,b=c.effectiveFilterDepth,x=c.effectiveFilterHeight,v=c.effectiveFilterWidth,_=b-1-c.padInfo.front,w=v-1-c.padInfo.left,M=x-1-c.padInfo.top,N=As(i.shape,"float32"),S=n.bufferSync(a);for(let e=0;e=c.outDepth||Math.floor(r)!==r))for(let a=0;a=c.outHeight||Math.floor(i)!==i))for(let s=0;s=c.outWidth||Math.floor(l)!==l)continue;const d=b*x*v-1-p.get(e,r,i,l,t)===n*x*v+a*v+s?1:0;0!==d&&(u+=S.get(e,r,i,l,t)*d)}}}N.set(u,e,n,r,a,t)}return n.makeTensorInfo(N.shape,N.dtype,N.values)}},kE={kernelName:Fn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i,output:s}=t,o=i;kk([i,s],"maxPoolGrad");const{filterSize:u,strides:l,pad:c,dimRoundingMode:p}=r,d=cl(o.shape,u,l,1,c,p),h=n.data.get(o.dataId).values,f=As(d.outShape,o.dtype,BD(h,o.shape,o.dtype,d).values),m=d.strideHeight,g=d.strideWidth,y=d.dilationHeight,b=d.dilationWidth,x=d.effectiveFilterHeight,v=d.effectiveFilterWidth,_=v-1-d.padInfo.left,w=x-1-d.padInfo.top,M=As(o.shape,"float32"),N=n.data.get(a.dataId).values,S=As(a.shape,"float32",N);for(let e=0;e=d.outHeight||Math.floor(r)!==r))for(let a=0;a=d.outWidth||Math.floor(o)!==o)continue;const u=x*v-1-f.get(e,r,o,t)===n*v+a?1:0;0!==u&&(s+=S.get(e,r,o,t)*u)}}M.set(s,e,n,r,t)}return n.makeTensorInfo(M.shape,M.dtype,M.values)}},DE={kernelName:Bn,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{x:r}=e,{filterSize:a,strides:i,pad:s,includeBatchInIndex:o}=t,u=n;kk(r,"MaxPoolWithArgmax");const l=u.data.get(r.dataId).values,c=cl(r.shape,a,i,[1,1],s),[p,d]=function(e,t,n,r,a){const i=zD(e,0,n,Re(t),a,"max"),s=BD(e,t,n,a,!0,r);return[i.values,s.values]}(l,r.shape,r.dtype,o,c),h=u.write(p,c.outShape,r.dtype),f=u.write(d,c.outShape,r.dtype);return[{dataId:h,shape:c.outShape,dtype:r.dtype},{dataId:f,shape:c.outShape,dtype:"int32"}]}},TE={kernelName:Pn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,keepDims:s}=r,o=ve(i,a.shape),u=ce(gc(a.shape,o)[1]),l=[],c=n.makeTensorInfo([],"float32",new Float32Array([u]));l.push(c);const p=tD({inputs:{x:a},backend:n,attrs:{dtype:"float32"}});l.push(p);const d=cI({inputs:{a:p,b:c},backend:n});l.push(d);const h=BT({inputs:{x:d},backend:n,attrs:{axis:i,keepDims:s}});return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),h}},IE={kernelName:Hn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,keepDims:s}=r;kk(a,"min");const o=ve(i,a.shape);let u=o;const l=xc(u,a.shape.length);let c=a;null!=l&&(c=wD({inputs:{x:a},backend:n,attrs:{perm:l}}),u=_c(u.length,a.shape.length)),bc("min",u,c.shape.length);const[p,d]=gc(c.shape,u),h=ce(d),f=Be(ce(p),c.dtype),m=n.data.get(c.dataId).values;for(let e=0;eMath.min(e,t))),CE=rD(jn,EE),AE={kernelName:jn,backendName:"cpu",kernelFunc:CE},LE={kernelName:Un,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{paddings:i,mode:s}=r;kk(a,"mirrorPad");const o=i.map(((e,t)=>e[0]+a.shape[t]+e[1])),u=i.map((e=>e[0])),l=i.map(((e,t)=>e[0]+a.shape[t])),c="reflect"===s?0:1,p=n.data.get(a.dataId).values,d=a.shape.length,h=Re(a.shape),f=ce(o),m=o.length,g=Re(o),y=we(a.dtype,f);for(let e=0;e=l[e]&&(t[e]=2*(l[e]-1)-t[e]+c);t=t.map(((e,t)=>e-u[t]));const n=je(t,d,h);y[e]=p[n]}return{dataId:n.write(y,o,a.dtype),shape:o,dtype:a.dtype}}},$E=Fk(((e,t)=>{const n=e%t;return e<0&&t<0||e>=0&&t>=0?n:(n+t)%t})),OE=rD(qn,$E),RE={kernelName:qn,backendName:"cpu",kernelFunc:OE};function FE(e){const{inputs:t,backend:n,attrs:r}=e,{logits:a}=t,{dim:i}=r,s=a.shape.length;let o=i;if(-1===o&&(o=s-1),o!==s-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${s} and dim was ${o}`);const u=ve([o],a.shape),l=bE({inputs:{x:a},backend:n,attrs:{reductionIndices:u,keepDims:!1}}),c=yc(l.shape,u),p=lD({inputs:{x:l},backend:n,attrs:{shape:c}}),d=fI({inputs:{a,b:p},backend:n}),h=nI({inputs:{x:d},backend:n}),f=BT({inputs:{x:h},backend:n,attrs:{axis:u,keepDims:!1}}),m=lD({inputs:{x:f},backend:n,attrs:{shape:c}}),g=cI({inputs:{a:h,b:m},backend:n});return n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),g}const YE={kernelName:$r,backendName:"cpu",kernelFunc:FE},zE={kernelName:Wn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{logits:a}=t,{numSamples:i,seed:s,normalized:o}=r;kk(a,"multinomial");const u=o?a:FE({inputs:{logits:a},backend:n,attrs:{dim:-1}}),l=u.shape[0],c=u.shape[1],p=n.data.get(u.dataId).values,d=[l,i],h=Be(ce(d),"int32");for(let e=0;ee!==t?1:0)),KE=rD(Kn,GE,null,"bool"),JE={kernelName:Kn,backendName:"cpu",kernelFunc:KE},XE={kernelName:er,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{indices:a}=t,{depth:i,onValue:s,offValue:o}=r;kk(a,"oneHot");const u=ce(a.shape),l=new Float32Array(u*i);l.fill(o);const c=n.data.get(a.dataId).values;for(let e=0;e=0&&c[e]{oe(i,e.shape,"All tensors passed to stack must have matching shapes"),se(s===e.dtype,(()=>"All tensors passed to stack must have matching dtypes"))}));const o=[],u=cT({inputs:t.map((e=>{const t=aI({inputs:{input:e},backend:n,attrs:{dim:a}});return o.push(t),t})),backend:n,attrs:{axis:a}});return o.forEach((e=>n.disposeIntermediateTensorInfo(e))),u}const nC={kernelName:tr,backendName:"cpu",kernelFunc:tC},rC={kernelName:nr,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{paddings:i,constantValue:s}=r;kk(a,"pad");const o=i.map(((e,t)=>e[0]+a.shape[t]+e[1])),u=i.map((e=>e[0])),l=n.data.get(a.dataId).values,c=ce(a.shape),p=a.shape.length,d=Re(a.shape),h=ce(o),f=o.length,m=Re(o),g=we(a.dtype,h);0!==s&&g.fill(s);for(let e=0;ee+u[t])),f,m)]=l[e];return{dataId:n.write(g,o,a.dtype),shape:o,dtype:a.dtype}}},aC=Fk(((e,t)=>Math.pow(e,t))),iC=rD(ar,aC),sC={kernelName:ar,backendName:"cpu",kernelFunc:iC};function oC(e,t,n,r){const[a,i]=gc(e,r),s=ci(t,"int32"),o=Be(ce(a),s),u=ce(i);for(let e=0;en.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(y,g,f)}};function lC(e,t,n,r){if(e===t||e1)return Be(0,r);const a=Be(Math.abs(Math.ceil((t-e)/n)),r);t1/e)),dC={kernelName:lr,backendName:"cpu",kernelFunc:pC},hC={kernelName:fr,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:a}=t,{alignCorners:i,halfPixelCenters:s,size:o}=r;kk(a,"resizeBilinear");const u=Re(a.shape),[l,c]=o,[p,d,h,f]=a.shape,m=n.data.get(a.dataId).values,g=new Float32Array(ce([p,l,c,f])),y=[i&&l>1?d-1:d,i&&c>1?h-1:h],b=[i&&l>1?l-1:l,i&&c>1?c-1:c];let x=0;const v=y[0]/b[0],_=y[1]/b[1];for(let e=0;e1?l-1:l,s&&h>1?c-1:c],g=[s&&d>1?d-1:d,s&&h>1?h-1:h],y=m[0]/g[0],b=m[1]/g[1],x=n.data.get(i.dataId).values;let v=0;for(let e=0;e1?d-1:d,i&&c>1?h-1:h],b=[i&&l>1?l-1:l,i&&c>1?c-1:c],x=y[0]/b[0],v=y[1]/b[1];let _=0;for(let e=0;e1?c-1:c,s&&f>1?p-1:p],b=[s&&h>1?h-1:h,s&&f>1?f-1:f],x=y[0]/b[0],v=y[1]/b[1],_=1/x,w=1/v,M=2*Math.ceil(_)+2,N=2*Math.ceil(w)+2;for(let e=0;e=h)continue;const d=t+l*u[1],m=l*x;if(e===Math.min(c-1,s?Math.round(m):Math.floor(m)))for(let e=0;e=f)continue;const a=d+t*u[2],i=t*v;r===Math.min(p-1,s?Math.round(i):Math.floor(i))&&(o+=g[a+n])}}m[i+n]=o}}}}return n.makeTensorInfo(a.shape,a.dtype,m)}},yC={kernelName:yr,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{dims:i}=r;kk(a,"reverse");const s=a.shape.length,o=ve(i,a.shape);if(0===s)return Lk({inputs:{x:a},backend:n});const u=new Xa(a.shape,a.dtype),l=n.bufferSync(a);for(let e=0;en[e]=a.shape[e]-1-n[e])),u.set(l.get(...n),...t)}return n.makeTensorInfo(u.shape,u.dtype,u.values)}},bC={kernelName:sa,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{image:r}=e,{radians:a,fillValue:i,center:s}=t,o=n,u=we(r.dtype,ce(r.shape)),[l,c,p,d]=r.shape,[h,f]=nf(s,c,p),m=Math.sin(a),g=Math.cos(a),y=o.data.get(r.dataId).values;for(let e=0;e=0&&v=0&&_{const t=Math.floor(e);return e-t<.5?Math.floor(e):e-t>.5?Math.ceil(e):t%2==0?t:t+1})),vC={kernelName:br,backendName:"cpu",kernelFunc:xC},_C=qk((e=>1/Math.sqrt(e))),wC=Ek(xr,_C),MC={kernelName:xr,backendName:"cpu",kernelFunc:wC};function NC(e,t,n,r,a,i,s,o,u,l){const c=[r/a,a],p=e.values,d=t.values;if(0===r)return As(n,t.dtype);const h=As(c,t.dtype);"string"==typeof u||"number"==typeof u?h.values.fill(u):"boolean"==typeof u&&h.values.fill(+u);for(let e=0;e=r/a)throw new Error(`Invalid indices: ${i} does not index into ${n}`);for(let n=0;n1||1===a.shape.length?1:ce(a.shape.slice(1));for(let e=0;ee>=0?CC*e:EC*(Math.exp(e)-1))),LC={kernelName:Mr,backendName:"cpu",kernelFunc:AC},$C=Ik(Dr,(e=>e<0?-1:e>0?1:0)),OC={kernelName:Dr,backendName:"cpu",kernelFunc:$C},RC=Ik(Sr,(e=>Math.sin(e))),FC={kernelName:Sr,backendName:"cpu",kernelFunc:RC},YC=Ik(kr,(e=>Math.sinh(e))),zC={kernelName:kr,backendName:"cpu",kernelFunc:YC},BC=Math.log(1.1920928955078125e-7)+2,PC=Ik(Ir,(e=>{const t=e>-BC,n=e=u)throw new Error(Of(t,n,u));++f[n],d=d&&n>=h,h=n}let m=!0;for(let e=0;e0&&(f[e]+=f[e-1])}if(m&&d){const t=e,n=r;for(let e=0;eNumber(e))))),n.makeTensorInfo([m.length],r.dtype,new Int32Array(m))]}};function WC(e,t,n,r,a){const i=ce(r),s=t[0],o=a.length,u=[];let l=1,c=-1;for(let e=0;e0){d[p-1]=1;for(let e=p-2;e>=0;--e)d[e]=d[e+1]*r[e+1]}const h=[];if(o>0){h[o-1]=1;for(let e=o-2;e>=0;--e)h[e]=h[e+1]*u[e+1]}const f=Me(n,s*o);for(let t=0;t0?a[o-1]+1:0;if(c<0)throw new Error("segment ids must be >= 0");const p=t.slice();p[0]=c;const d=p.reduce(((e,t)=>e*t),1),h=Me(n,d);if(0===o)return c>0&&h.fill(s),[h,p];if(c<=0)throw new Error("segment ids must be >= 0");let f=0,m=1,g=0,y=a[f];for(;;){let t=0;if(m=t)throw new Error("segment ids are not increasing")}if(y<0||y>=c)throw new Error(jf(y,c));y>g&&h.fill(s,g*l,y*l);for(let t=f;t=u[0])throw new Error(Uf(t,r[t],u[0]));for(let t=0;to)break}return g{const t=[...c];t[o]=e;const r=GD({inputs:{x:a},backend:n,attrs:{begin:l,size:t}});return l[o]+=e,r}))}},QC=qk((e=>Math.sqrt(e))),eA=Ik(Er,(e=>Math.sqrt(e))),tA={kernelName:Er,backendName:"cpu",kernelFunc:eA},nA={kernelName:Pr,backendName:"cpu",kernelFunc:({inputs:e,backend:t})=>{const{x:n}=e,r=t;kk(n,"square");const a=r.data.get(n.dataId).values,i=new Float32Array(a.length);for(let e=0;e{const n=e-t;return n*n})),aA=rD(Br,rA),iA={kernelName:Br,backendName:"cpu",kernelFunc:aA},sA=Ik(aa,((e,t)=>{const n=t;return isNaN(e)?NaN:e>0?1:n.alpha})),oA={kernelName:aa,backendName:"cpu",kernelFunc:sA};function uA(e,t,n,r){const a=As(e,t.dtype);for(let e=0;e=1,(()=>`Input must have rank at least 1, got: ${a.shape.length}`));const e=Wo(b,x,v),t=GD({inputs:{x:a},backend:n,attrs:{begin:b,size:e}});_=lD({inputs:{x:t},backend:n,attrs:{shape:f}}),n.disposeIntermediateTensorInfo(t)}else{const e=uA(h,n.bufferSync(a),v,b);_=n.makeTensorInfo(f,e.dtype,e.values)}return _}};class cA{constructor(e,t,n,r,a,i){this.separator=Pa(e),this.nGramWidths=t,this.leftPad=Pa(n),this.rightPad=Pa(r),this.padWidth=a,this.preserveShort=i}getPadWidth(e){return Math.min(this.padWidth<0?e-1:this.padWidth,e-1)}getNumNGrams(e,t){const n=this.getPadWidth(t);return Math.max(0,e+2*n-t+1)}createNGrams(e,t,n,r,a,i){for(let s=0;s0?0:s-o);let d=0;d+=u*this.leftPad.length;for(let t=0;te.forEach((e=>h[f++]=e));for(let e=0;e0){m(e[p+c-1]);for(let e=0;e0){let e=t[0];if(0!==e)throw new Error(`First split value must be 0, got ${e}`);for(let a=1;a=e;if(r=r&&t[a]<=n,!r)throw new Error(`Invalid split value ${t[a]}, must be in [${e}, ${n}]`);e=t[a]}if(e!==n)throw new Error(`Last split value must be data size. Expected ${n}, got ${e}`)}const a=r-1,i=Me("int32",r);if(0===n||0===r){const e=new Array(n);for(let e=0;e<=a;++e)i[e]=0;return[e,i]}i[0]=0;for(let e=1;e<=a;++e){const n=t[e]-t[e-1];let r=0;this.nGramWidths.forEach((e=>{r+=this.getNumNGrams(n,e)})),this.preserveShort&&n>0&&0===r&&(r=1),i[e]=i[e-1]+r}const s=new Array(i[a]);for(let n=0;n{const o=t[n+1]-t[n],u=this.getNumNGrams(o,i);this.createNGrams(e,r,s,a,u,i),a+=u})),this.preserveShort&&a===i[n]){const i=t[n+1]-t[n];if(0===i)continue;const o=i+2*this.padWidth,u=1;this.createNGrams(e,r,s,a,u,o)}}return[s,i]}}function pA(e,t,n,r,a,i,s,o){return new cA(n,r,a,i,s,o).compute(e,t)}const dA={kernelName:jr,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{separator:a,nGramWidths:i,leftPad:s,rightPad:o,padWidth:u,preserveShortSequences:l}=r,{data:c,dataSplits:p}=t,d=n.data.get(c.dataId).values,h=n.data.get(p.dataId).values,[f,m]=pA(d,h,a,i,s,o,u,l);return[n.makeTensorInfo([f.length],"string",f),n.makeTensorInfo(p.shape,"int32",m)]}};function hA(e,t,n,r){if(!e.length)return;if(0===t.length){for(let t=0;tMath.tan(e))),xA={kernelName:Vr,backendName:"cpu",kernelFunc:bA},vA=Ik(Gr,(e=>Math.tanh(e)));function _A(e,t){const n=new Array(e.rank);for(let r=0;r{const n=t.value-e.value;return 0===n?e.index-t.index:n};function NA(e,t,n=0,r=e.length-1){for(;r>n;){if(r-n>600){const a=r-n+1,i=t-n+1,s=Math.log(a),o=.5*Math.exp(2*s/3),u=.5*Math.sqrt(s*o*(a-o)/a)*Math.sign(i-a/2);NA(e,t,Math.max(n,Math.floor(t-i*o/a+u)),Math.min(r,Math.floor(t+(a-i)*o/a+u)))}const a=e[t];let i=n,s=r;for(ne(e,n,t),MA(e[r],a)>0&&ne(e,n,r);i0;)s-=1}0===MA(e[n],a)?ne(e,n,s):(s+=1,ne(e,s,r)),s<=t&&(n=s+1),t<=s&&(r=s-1)}}function SA(e,t,n,r,a){const i=t[t.length-1],[s,o]=[e.length/i,i],u=we(n,s*r),l=we("int32",s*r);for(let t=0;ts[t]={value:e,index:t})),rt-1)if(t<=1)n=0;else{const e=2*t;n-=e*Math.trunc(n/e),n>=t&&(n=e-n-1)}return ee(0,n,t-1)}(e,t);case"wrap":return function(e,t){let n=e;if(n<0)if(t<=1)n=0;else{const e=t-1;n+=t*(Math.trunc(-n/e)+1)}else if(n>t-1)if(t<=1)n=0;else{const e=t-1;n-=t*Math.trunc(n/e)}return ee(0,n,t-1)}(e,t);case"nearest":return function(e,t){return ee(0,e,t-1)}(e,t);default:return function(e,t){return e}(e)}}function IA(e,t,n,r,a,i,s,o,u,l,c){return 0<=o&&o{for(let n=0;nn.disposeIntermediateTensorInfo(e))),p}},RA=[hD,mD,yD,xD,uD,vD,ND,SD,kD,DD,ID,CD,LD,RD,YD,HD,jD,UD,qD,dD,WD,JD,QD,eT,nD,rT,iT,Xk,sT,pT,hT,fT,mT,gT,yT,bT,vT,wT,MT,NT,ST,kT,DT,IT,ET,CT,AT,LT,$T,OT,HT,Ak,jT,WT,eI,rI,iI,uI,xI,_I,wI,SI,TI,II,EI,AI,$I,FI,BI,$k,PI,lT,jI,qI,VI,Rk,JI,QI,tE,aE,sE,lE,pE,fE,mE,gE,xE,wE,ME,NE,SE,kE,DE,TE,IE,AE,LE,RE,zE,zT,PE,jE,qE,VE,JE,XE,eC,nC,rC,sC,Bk,uC,cC,eD,pI,dC,Hk,Uk,cD,hC,fC,mC,gC,yC,bC,vC,MC,SC,TC,IC,LC,Gk,OC,FC,zC,KD,YE,HC,jC,qC,VC,KC,JC,XC,ZC,tA,nA,iA,oA,lA,dA,mA,yA,mI,PT,xA,{kernelName:Gr,backendName:"cpu",kernelFunc:vA},wA,kA,DA,MD,LA,$A,OA,QE];for(const e of RA)ya(e);const FA={},YA={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function zA(e,t){if(!(e in FA)||null!=t){const n=function(e,t){if(1!==e&&2!==e)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");const n=null==t?function(e){if("undefined"!=typeof OffscreenCanvas&&2===e)return new OffscreenCanvas(300,150);if("undefined"!=typeof document)return document.createElement("canvas");throw new Error("Cannot create a canvas in this context")}(e):t;return n.addEventListener("webglcontextlost",(t=>{t.preventDefault(),delete FA[e]}),!1),1===e?n.getContext("webgl",YA)||n.getContext("experimental-webgl",YA):n.getContext("webgl2",YA)}(e,t);if(null===n)return console.log("Could not get context for WebGL version",e),null;FA[e]=n}const n=FA[e];return null==n||n.isContextLost()?(delete FA[e],zA(e)):(n.disable(n.DEPTH_TEST),n.disable(n.STENCIL_TEST),n.disable(n.BLEND),n.disable(n.DITHER),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SAMPLE_COVERAGE),n.enable(n.SCISSOR_TEST),n.enable(n.CULL_FACE),n.cullFace(n.BACK),FA[e])}var BA,PA,HA;function jA(e,t){return[t,e]}function UA(e){const t=ce(e);return me(Math.ceil(t/4))}function qA(e,t){return[Math.max(1,Math.ceil(t/2)),Math.max(1,Math.ceil(e/2))]}function WA(e,t){const n=e;let r,a,i,s,o,u,l,c,p,d;return 2===Ge().getNumber("WEBGL_VERSION")?(r=n.R32F,a=n.R16F,i=n.RGBA16F,s=n.RGBA32F,o=n.RED,l=4,c=1,p=n.HALF_FLOAT,d=n.FLOAT,u=n.RGBA8):(r=e.RGBA,a=e.RGBA,i=e.RGBA,s=n.RGBA,o=e.RGBA,l=4,c=4,p=null!=t?t.HALF_FLOAT_OES:null,d=e.FLOAT,u=e.RGBA),{internalFormatFloat:r,internalFormatHalfFloat:a,internalFormatPackedHalfFloat:i,internalFormatPackedFloat:s,textureFormatFloat:o,downloadTextureFormat:u,downloadUnpackNumChannels:l,defaultNumChannels:c,textureTypeHalfFloat:p,textureTypeFloat:d}}function VA(e,t){const n=t();return Ge().getBool("DEBUG")&&function(e){const t=e.getError();if(t!==e.NO_ERROR)throw new Error("WebGL Error: "+function(e,t){switch(t){case e.NO_ERROR:return"NO_ERROR";case e.INVALID_ENUM:return"INVALID_ENUM";case e.INVALID_VALUE:return"INVALID_VALUE";case e.INVALID_OPERATION:return"INVALID_OPERATION";case e.INVALID_FRAMEBUFFER_OPERATION:return"INVALID_FRAMEBUFFER_OPERATION";case e.OUT_OF_MEMORY:return"OUT_OF_MEMORY";case e.CONTEXT_LOST_WEBGL:return"CONTEXT_LOST_WEBGL";default:return`Unknown error code ${t}`}}(e,t))}(e),n}function GA(e){return!!(Ge().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||0===e||5.96e-8e.getExtension(t)),'Extension "'+t+'" not supported on this browser.')}!function(e){e[e.DENSE=0]="DENSE",e[e.SHARED_BATCH=1]="SHARED_BATCH"}(BA||(BA={})),function(e){e[e.RENDER=0]="RENDER",e[e.UPLOAD=1]="UPLOAD",e[e.PIXELS=2]="PIXELS",e[e.DOWNLOAD=3]="DOWNLOAD"}(PA||(PA={})),function(e){e[e.UNPACKED_FLOAT16=0]="UNPACKED_FLOAT16",e[e.UNPACKED_FLOAT32=1]="UNPACKED_FLOAT32",e[e.PACKED_4X1_UNSIGNED_BYTE=2]="PACKED_4X1_UNSIGNED_BYTE",e[e.PACKED_2X2_FLOAT32=3]="PACKED_2X2_FLOAT32",e[e.PACKED_2X2_FLOAT16=4]="PACKED_2X2_FLOAT16"}(HA||(HA={}));const JA=/ERROR: [0-9]+:([0-9]+):/g;function XA(e,t){const n=JA.exec(t);if(null==n)return console.log(`Couldn't parse line number in error: ${t}`),void console.log(e);const r=+n[1],a=e.split("\n"),i=a.length.toString().length+2,s=a.map(((e,t)=>ye((t+1).toString(),i)+e));let o=0;for(let e=0;ee.validateProgram(t))),!1===e.getProgramParameter(t,e.VALIDATE_STATUS))throw console.log(e.getProgramInfoLog(t)),new Error("Shader program validation failed.")}function QA(e,t,n,r,a,i,s){const o=e.getAttribLocation(t,n);return-1!==o&&(VA(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,r))),VA(e,(()=>e.vertexAttribPointer(o,a,e.FLOAT,!1,i,s))),VA(e,(()=>e.enableVertexAttribArray(o))),!0)}function eL(e,t,n,r){VA(e,(()=>function(e,t,n){(function(e,t){const n=e.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,r=t+e.TEXTURE0;if(rn)throw new Error(`textureUnit must be in [gl.TEXTURE0, gl.TEXTURE${n}].`)})(e,n),VA(e,(()=>e.activeTexture(e.TEXTURE0+n))),VA(e,(()=>e.bindTexture(e.TEXTURE_2D,t)))}(e,t,r))),VA(e,(()=>e.uniform1i(n,r)))}function tL(e,t,n){VA(e,(()=>e.bindFramebuffer(e.FRAMEBUFFER,n))),VA(e,(()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)))}function nL(e,t){VA(e,(()=>e.bindFramebuffer(e.FRAMEBUFFER,t))),VA(e,(()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,null,0)))}function rL(e){const t=e.checkFramebufferStatus(e.FRAMEBUFFER);if(t!==e.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+function(e,t){switch(t){case e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case e.FRAMEBUFFER_UNSUPPORTED:return"FRAMEBUFFER_UNSUPPORTED";default:return`unknown error ${t}`}}(e,t))}function aL(e,t,n){const r=VA(e,(()=>t()));if(null==r)throw new Error(n);return r}function iL(e,t=2){return ce(e.slice(0,e.length-t))}function sL(e){if(0===e.length)throw Error("Cannot get rows and columns of an empty shape array.");return[e.length>1?e[e.length-2]:1,e[e.length-1]]}function oL(e){let t=[1,1,1];return 0===e.length||1===e.length&&1===e[0]||(t=[iL(e),...sL(e)]),t}function uL(e){return e%2==0}function lL(e,t){if(de(e=e.slice(-2),t=t.slice(-2)))return!0;if(!e.length||!t.length)return!0;if(0===e[0]||0===e[1]||0===t[0]||0===t[1])return!0;if(e.length!==t.length){const n=e.slice(-1)[0],r=t.slice(-1)[0];if(n===r)return!0;if(uL(n)&&uL(r)&&(1===e[0]||1===t[0]))return!0}return e[1]===t[1]&&uL(e[0])&&uL(t[0])}let cL,pL;function dL(e,t){return null!=e.getExtension(t)}function hL(e){try{if(null!=zA(e))return!0}catch(e){return console.log("Error when getting WebGL context: ",e),!1}return!1}function fL(e){const t=WA(e),n=e.createTexture();e.bindTexture(e.TEXTURE_2D,n),e.texImage2D(e.TEXTURE_2D,0,t.internalFormatFloat,1,1,0,t.textureFormatFloat,t.textureTypeFloat,null);const r=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,r),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0);const a=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(n),e.deleteFramebuffer(r),a}function mL(e,t){Array.isArray(e)||(e=[e]),e.forEach((e=>{null!=e&&se("complex64"!==e.dtype,(()=>`${t} does not support complex64 tensors in the WebGL backend.`))}))}const gL=Ge();function yL(){let e,t,n,r,a,i,s,o,u,l;return 2===Ge().getNumber("WEBGL_VERSION")?(e="#version 300 es",t="in",n="out",r="in",a="texture",i="outputColor",s="out vec4 outputColor;",o="\n bool isnan_custom(float val) {\n uint floatToUint = floatBitsToUint(val);\n return (floatToUint & 0x7fffffffu) > 0x7f800000u;\n }\n\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan_custom(val.x),\n isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w));\n }\n\n #define isnan(value) isnan_custom(value)\n ",u="",l="\n #define round(value) newRound(value)\n int newRound(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 newRound(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n "):(e="",t="attribute",n="varying",r="varying",a="texture2D",i="gl_FragColor",s="",o="\n #define isnan(value) isnan_custom(value)\n bool isnan_custom(float val) {\n return (val > 0. || val < 1. || val == 0.) ? false : true;\n }\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w));\n }\n ",u="\n uniform float INFINITY;\n\n bool isinf(float val) {\n return abs(val) == INFINITY;\n }\n bvec4 isinf(vec4 val) {\n return equal(abs(val), vec4(INFINITY));\n }\n ",l="\n int round(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 round(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n "),{version:e,attribute:t,varyingVs:n,varyingFs:r,texture2D:a,output:i,defineOutput:s,defineSpecialNaN:o,defineSpecialInf:u,defineRound:l}}function bL(e,t,n="index"){const r=Re(t);return r.map(((t,a)=>`int ${e[a]} = ${n} / ${t}; ${a===r.length-1?`int ${e[a+1]} = ${n} - ${e[a]} * ${t}`:`index -= ${e[a]} * ${t}`};`)).join("")}function xL(e,t,n="index"){const r=Re(t);return r.map(((t,a)=>`int ${e[a]} = ${n} / outShapeStrides[${a}]; ${a===r.length-1?`int ${e[a+1]} = ${n} - ${e[a]} * outShapeStrides[${a}]`:`index -= ${e[a]} * outShapeStrides[${a}]`};`)).join("")}function vL(e){const t=Re(e).map((e=>e.toString()));return`\n int getFlatIndex(ivec3 coords) {\n return coords.x * ${t[0]} + coords.y * ${t[1]} + coords.z;\n }\n`}gL.registerFlag("HAS_WEBGL",(()=>gL.getNumber("WEBGL_VERSION")>0)),gL.registerFlag("WEBGL_VERSION",(()=>hL(2)?2:hL(1)?1:0)),gL.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",(()=>!1)),gL.registerFlag("WEBGL_BUFFER_SUPPORTED",(()=>2===gL.get("WEBGL_VERSION"))),gL.registerFlag("WEBGL_CPU_FORWARD",(()=>!0)),gL.registerFlag("WEBGL_FORCE_F16_TEXTURES",(()=>!1)),gL.registerFlag("WEBGL_PACK",(()=>gL.getBool("HAS_WEBGL"))),gL.registerFlag("WEBGL_PACK_NORMALIZATION",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_PACK_CLIP",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_PACK_DEPTHWISECONV",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_PACK_REDUCE",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_LAZILY_UNPACK",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_CONV_IM2COL",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_MAX_TEXTURE_SIZE",(()=>function(e){if(null==cL){const t=zA(e);cL=t.getParameter(t.MAX_TEXTURE_SIZE)}return cL}(gL.getNumber("WEBGL_VERSION")))),gL.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",(()=>function(e){if(null==pL){const t=zA(e);pL=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,pL)}(gL.getNumber("WEBGL_VERSION")))),gL.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",(()=>{const e=gL.getNumber("WEBGL_VERSION");return 0===e?0:function(e){if(0===e)return 0;let t;const n=zA(e);return t=dL(n,"EXT_disjoint_timer_query_webgl2")&&2===e?2:dL(n,"EXT_disjoint_timer_query")?1:0,t}(e)})),gL.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",(()=>gL.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!Si())),gL.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",(()=>function(e){if(0===e)return!1;const t=zA(e);if(1===e){if(!dL(t,"OES_texture_float"))return!1}else if(!dL(t,"EXT_color_buffer_float"))return!1;return fL(t)}(gL.getNumber("WEBGL_VERSION")))),gL.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",(()=>!gL.getBool("WEBGL_FORCE_F16_TEXTURES")&&gL.getBool("WEBGL_RENDER_FLOAT32_CAPABLE"))),gL.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",(()=>function(e){if(0===e)return!1;const t=zA(e);if(1!==e){if(dL(t,"EXT_color_buffer_float"))return fL(t);const e="EXT_color_buffer_half_float";if(dL(t,e)){const n=t.getExtension(e);return function(e,t){const n=WA(e,t),r=e.createTexture();e.bindTexture(e.TEXTURE_2D,r),e.texImage2D(e.TEXTURE_2D,0,n.internalFormatHalfFloat,1,1,0,n.textureFormatFloat,n.textureTypeHalfFloat,null);const a=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,a),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,r,0);const i=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(r),e.deleteFramebuffer(a),i}(t,n)}return!1}return!!dL(t,"OES_texture_float")&&!!dL(t,"WEBGL_color_buffer_float")&&fL(t)}(gL.getNumber("WEBGL_VERSION")))),gL.registerFlag("WEBGL_FENCE_API_ENABLED",(()=>{return 2===(e=gL.getNumber("WEBGL_VERSION"))&&null!=zA(e).fenceSync;var e})),gL.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",(()=>gL.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0)),gL.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD",(()=>-1),(e=>{if(e<0&&-1!==e)throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never delete) or at least 0, but got ${e}.`)})),gL.registerFlag("WEBGL_FLUSH_THRESHOLD",(()=>Si()?1:-1),(e=>{if(e<0&&-1!==e)throw new Error(`WEBGL_FLUSH_THRESHOLD must be -1 (indicating never manual flush) or at least 0, but got ${e}.`)})),gL.registerFlag("CPU_HANDOFF_SIZE_THRESHOLD",(()=>128)),gL.registerFlag("WEBGL_USE_SHAPES_UNIFORMS",(()=>!1)),gL.registerFlag("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD",(()=>1e5)),gL.registerFlag("TOPK_K_CPU_HANDOFF_THRESHOLD",(()=>128));const _L="\n const float FLOAT_MAX = 1.70141184e38;\n const float FLOAT_MIN = 1.17549435e-38;\n\n lowp vec4 encode_float(highp float v) {\n if (isnan(v)) {\n return vec4(255, 255, 255, 255);\n }\n\n highp float av = abs(v);\n\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 255.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n highp float e = floor(log2(av));\n highp float m = exp2(fract(log2(av))) - 1.0;\n\n c[2] = floor(128.0 * m);\n m -= c[2] / 128.0;\n c[1] = floor(32768.0 * m);\n m -= c[1] / 32768.0;\n c[0] = floor(8388608.0 * m);\n\n highp float ebias = e + 127.0;\n c[3] = floor(ebias / 2.0);\n ebias -= c[3] * 2.0;\n c[2] += floor(ebias) * 128.0;\n\n c[3] += 128.0 * step(0.0, -v);\n\n return c / 255.0;\n }\n",{getBroadcastDims:wL}=g;function ML(e,t,n){const r=[];if(e.forEach((e=>{const t=ce(e.shapeInfo.logicalShape);if(e.shapeInfo.isUniform?r.push(`uniform float ${e.name}${t>1?`[${t}]`:""};`):(r.push(`uniform sampler2D ${e.name};`),r.push(`uniform int offset${e.name};`)),n.enableShapeUniforms){const{uniformShape:t}=LL(n.packedInputs,e.shapeInfo.logicalShape,e.shapeInfo.texShape);switch(t.length){case 1:r.push(`uniform int ${e.name}Shape;`);break;case 2:r.push(`uniform ivec2 ${e.name}Shape;`);break;case 3:r.push(`uniform ivec3 ${e.name}Shape;`);break;case 4:r.push(`uniform ivec4 ${e.name}Shape;`)}r.push(`uniform ivec2 ${e.name}TexShape;`)}})),n.enableShapeUniforms){switch(t.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;")}r.push("uniform ivec2 outTexShape;")}n.customUniforms&&n.customUniforms.forEach((e=>{r.push(`uniform ${e.type} ${e.name}${e.arrayIndex?`[${e.arrayIndex}]`:""};`)}));const a=r.join("\n"),i=e.map((e=>function(e,t,n=!1,r){let a="";a+=n?SL(e,r):NL(e,r);const i=e.shapeInfo.logicalShape,s=t.logicalShape;return i.length<=s.length&&(a+=n?function(e,t){const n=e.name,r=n.charAt(0).toUpperCase()+n.slice(1),a="get"+r+"AtOutCoords",i=e.shapeInfo.logicalShape.length,s=t.logicalShape.length,o=wL(e.shapeInfo.logicalShape,t.logicalShape),u=AL(s),l=s-i;let c;const p=["x","y","z","w","u","v"];c=0===i?"":s<2&&o.length>=1?"coords = 0;":o.map((e=>`coords.${p[e+l]} = 0;`)).join("\n");let d="";d=s<2&&i>0?"coords":e.shapeInfo.logicalShape.map(((e,t)=>`coords.${p[t+l]}`)).join(", ");let h="return outputValue;";const f=1===ce(e.shapeInfo.logicalShape),m=1===ce(t.logicalShape);if(1!==i||f||m){if(f&&!m)h=1===s?"\n return vec4(outputValue.x, outputValue.x, 0., 0.);\n ":"\n return vec4(outputValue.x);\n ";else if(o.length){const e=i-2,t=i-1;o.indexOf(e)>-1&&o.indexOf(t)>-1?h="return vec4(outputValue.x);":o.indexOf(e)>-1?h="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":o.indexOf(t)>-1&&(h="return vec4(outputValue.xx, outputValue.zz);")}}else h="\n return vec4(outputValue.xy, outputValue.xy);\n ";return`\n vec4 ${a}() {\n ${u} coords = getOutputCoords();\n ${c}\n vec4 outputValue = get${r}(${d});\n ${h}\n }\n `}(e,t):function(e,t){const n=e.name,r=n.charAt(0).toUpperCase()+n.slice(1),a="get"+r+"AtOutCoords",i=t.texShape,s=e.shapeInfo.texShape,o=e.shapeInfo.logicalShape.length,u=t.logicalShape.length;if(!e.shapeInfo.isUniform&&o===u&&null==e.shapeInfo.flatOffset&&de(s,i))return`\n float ${a}() {\n return sampleTexture(${n}, resultUV);\n }\n `;const l=AL(u),c=wL(e.shapeInfo.logicalShape,t.logicalShape),p=u-o;let d;const h=["x","y","z","w","u","v"];d=0===o?"":u<2&&c.length>=1?"coords = 0;":c.map((e=>`coords.${h[e+p]} = 0;`)).join("\n");let f="";return f=u<2&&o>0?"coords":e.shapeInfo.logicalShape.map(((e,t)=>`coords.${h[t+p]}`)).join(", "),`\n float ${a}() {\n ${l} coords = getOutputCoords();\n ${d}\n return get${r}(${f});\n }\n `}(e,t)),a}(e,t,n.packedInputs,n.enableShapeUniforms))).join("\n"),s=t.texShape,o=yL(),u=function(e){return`\n float sampleTexture(sampler2D textureSampler, vec2 uv) {\n return ${e.texture2D}(textureSampler, uv).r;\n }\n `}(o);let l,c,p=function(e){return`${e.version}\n precision highp float;\n precision highp int;\n precision highp sampler2D;\n ${e.varyingFs} vec2 resultUV;\n ${e.defineOutput}\n const vec2 halfCR = vec2(0.5, 0.5);\n\n struct ivec5\n {\n int x;\n int y;\n int z;\n int w;\n int u;\n };\n\n struct ivec6\n {\n int x;\n int y;\n int z;\n int w;\n int u;\n int v;\n };\n\n uniform float NAN;\n ${e.defineSpecialNaN}\n ${e.defineSpecialInf}\n ${e.defineRound}\n\n int imod(int x, int y) {\n return x - y * (x / y);\n }\n\n int idiv(int a, int b, float sign) {\n int res = a / b;\n int mod = imod(a, b);\n if (sign < 0. && mod != 0) {\n res -= 1;\n }\n return res;\n }\n\n //Based on the work of Dave Hoskins\n //https://www.shadertoy.com/view/4djSRW\n #define HASHSCALE1 443.8975\n float random(float seed){\n vec2 p = resultUV * seed;\n vec3 p3 = fract(vec3(p.xyx) * HASHSCALE1);\n p3 += dot(p3, p3.yzx + 19.19);\n return fract((p3.x + p3.y) * p3.z);\n }\n\n ${kL}\n ${DL}\n ${TL}\n `}(o);return t.isPacked?(l=function(e,t,n){switch(e.length){case 0:return"\n int getOutputCoords() {\n return 0;\n }\n ";case 1:return function(e,t,n){const r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];return 1===r[0]?n?"\n int getOutputCoords() {\n return 2 * int(resultUV.x * ceil(float(outTexShape[1]) / 2.0));\n }\n ":`\n int getOutputCoords() {\n return 2 * int(resultUV.x * ${r[1]}.0);\n }\n `:1===r[1]?n?"\n int getOutputCoords() {\n return 2 * int(resultUV.y * ceil(float(outTexShape[0]) / 2.0));\n }\n ":`\n int getOutputCoords() {\n return 2 * int(resultUV.y * ${r[0]}.0);\n }\n `:n?"\n int getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n return 2 * (resTexRC.x * packedTexShape[1] + resTexRC.y);\n }\n ":`\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n return 2 * (resTexRC.x * ${r[1]} + resTexRC.y);\n }\n `}(0,t,n);case 2:return function(e,t,n){const r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];if(de(e,t))return n?"\n ivec2 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n return 2 * ivec2(resultUV.yx * vec2(packedTexShape[0], packedTexShape[1]));\n }\n ":`\n ivec2 getOutputCoords() {\n return 2 * ivec2(resultUV.yx * vec2(${r[0]}, ${r[1]}));\n }\n `;const a=Math.ceil(e[1]/2);return n?"\n ivec2 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n int texelsInLogicalRow = int(ceil(float(outShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec2(r, c);\n }\n ":`\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n\n int index = resTexRC.x * ${r[1]} + resTexRC.y;\n int r = 2 * (index / ${a});\n int c = imod(index, ${a}) * 2;\n\n return ivec2(r, c);\n }\n `}(e,t,n);case 3:return function(e,t,n){if(n)return"\n ivec3 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n int texelsInLogicalRow = int(ceil(float(outShape[2]) / 2.0));\n int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n\n int b = index / texelsInBatch;\n index -= b * texelsInBatch;\n\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec3(b, r, c);\n }\n ";const r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],a=Math.ceil(e[2]/2),i=a*Math.ceil(e[1]/2);return`\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n int index = resTexRC.x * ${r[1]} + resTexRC.y;\n\n int b = index / ${i};\n index -= b * ${i};\n\n int r = 2 * (index / ${a});\n int c = imod(index, ${a}) * 2;\n\n return ivec3(b, r, c);\n }\n `}(e,t,n);default:return function(e,t,n){if(n)return"\n ivec4 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n\n int texelsInLogicalRow = int(ceil(float(outShape[3]) / 2.0));\n int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[2]) / 2.0));\n int texelsInBatchN = texelsInBatch * outShape[1];\n\n int b2 = index / texelsInBatchN;\n index -= b2 * texelsInBatchN;\n\n int b = index / texelsInBatch;\n index -= b * texelsInBatch;\n\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec4(b2, b, r, c);\n }\n ";const r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],a=Math.ceil(e[e.length-1]/2),i=a*Math.ceil(e[e.length-2]/2);let s=i,o="",u="b, r, c";for(let t=2;t1&&!de(t,n)&&r.lengthe[t])).join(", ")}function RL(e,t,n){const r={},a={},i={},s=[];let o,u,l,c=null,p=null;p=e.getUniformLocation(n,"NAN",!1),1===Ge().getNumber("WEBGL_VERSION")&&(c=e.getUniformLocation(n,"INFINITY",!1));const d=!1;for(let s=0;s{s[r]=e.getUniformLocation(n,t.name,d)})),{uniformLocations:r,customUniformLocations:s,infLoc:c,nanLoc:p,inShapesLocations:a,inTexShapesLocations:i,outShapeLocation:o,outShapeStridesLocation:l,outTexShapeLocation:u}}function FL(e,t){if(e.length!==t.length)throw Error(`Binary was compiled with ${e.length} inputs, but was executed with ${t.length} inputs`);e.forEach(((e,n)=>{const r=e.logicalShape,a=t[n],i=a.shape;if(!de(r,i))throw Error(`Binary was compiled with different shapes than the current args. Shapes ${r} and ${i} must match`);if(e.isUniform&&a.isUniform)return;const s=e.texShape,o=a.isUniform?null:a.texData.texShape;if(!de(s,o))throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${s} and ${o} must match`)}))}function YL(e){return Ge().getBool("WEBGL_USE_SHAPES_UNIFORMS")&&e<=4}class zL{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=BA.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const t=yL();this.outputShape=e,this.enableShapeUniforms=YL(this.outputShape.length),this.userCode=`\n ivec3 outCoordsFromFlatIndex(int index) {\n ${this.enableShapeUniforms?xL(["r","c","d"],e):bL(["r","c","d"],e)}\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));\n int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y);\n\n vec4 result = vec4(0.);\n\n for (int i=0; i<4; i++) {\n int flatIndex = index + i;\n ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n result[i] = getA(rc.x, rc.y, rc.z);\n }\n\n ${t.output} = result;\n }\n `}}class BL{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=BA.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const t=yL();this.outputShape=e,this.enableShapeUniforms=YL(this.outputShape.length),this.userCode=`\n ivec3 outCoordsFromFlatIndex(int index) {\n ${this.enableShapeUniforms?xL(["r","c","d"],e):bL(["r","c","d"],e)}\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));\n int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y);\n\n vec4 result = vec4(0.);\n\n for (int i=0; i<4; i++) {\n int flatIndex = index + i;\n ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z));\n }\n\n ${t.output} = result;\n }\n `}}class PL{constructor(e){this.variableNames=["A"],this.outTexUsage=PA.DOWNLOAD;const t=yL();this.outputShape=e,this.userCode=`\n ${_L}\n\n void main() {\n float x = getAAtOutCoords();\n ${t.output} = encode_float(x);\n }\n `}}class HL{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=PA.DOWNLOAD;const t=yL();this.outputShape=e,this.userCode=`\n ${_L}\n\n void main() {\n ivec3 coords = getOutputCoords();\n float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));\n ${t.output} = encode_float(x);\n }\n `}}class jL{constructor(e,t=!1){this.variableNames=["A"],this.customUniforms=[{name:"texShape",type:"ivec2"}];const n=yL();this.outputShape=e,this.enableShapeUniforms=YL(this.outputShape.length);let r="result";t&&(r="floor(result * 255. + 0.5)"),this.userCode=`\n ${this.enableShapeUniforms?"\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n":vL(e)}\n\n void main() {\n ivec3 coords = getOutputCoords();\n\n int flatIndex = getFlatIndex(coords);\n int offset = imod(flatIndex, 4);\n\n flatIndex = idiv(flatIndex, 4, 1.);\n\n int r = flatIndex / texShape[1];\n int c = imod(flatIndex, texShape[1]);\n vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);\n vec4 values = ${n.texture2D}(A, uv);\n\n float result;\n\n if(offset == 0) {\n result = values[0];\n } else if(offset == 1) {\n result = values[1];\n } else if(offset == 2) {\n result = values[2];\n } else {\n result = values[3];\n }\n\n ${n.output} = vec4(${r}, 0., 0., 0.);\n }\n `}}class UL{constructor(e,t=!1){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.customUniforms=[{name:"texShape",type:"ivec2"}];const n=yL();this.outputShape=e,this.enableShapeUniforms=YL(this.outputShape.length);let r="",a="result";t&&(a="floor(result * 255. + 0.5)");for(let t=0;t<=1;t++)for(let a=0;a<=1;a++){const i=2*t+a;r+=`\n localCoords = coords;\n if(localCoords[2] + ${a} < ${this.enableShapeUniforms?"outShape[2]":`${e[2]}`}) {\n localCoords[2] += ${a};\n if (localCoords[1] + ${t} < ${this.enableShapeUniforms?"outShape[1]":`${e[1]}`}) {\n localCoords[1] += ${t};\n\n flatIndex = getFlatIndex(localCoords);\n offset = imod(flatIndex, 4);\n\n flatIndex = idiv(flatIndex, 4, 1.);\n\n int r = flatIndex / texShape[1];\n int c = imod(flatIndex, texShape[1]);\n vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);\n values = ${n.texture2D}(A, uv);\n\n if (offset == 0) {\n result[${i}] = values[0];\n } else if (offset == 1) {\n result[${i}] = values[1];\n } else if (offset == 2) {\n result[${i}] = values[2];\n } else {\n result[${i}] = values[3];\n }\n }\n }\n `}this.userCode=`\n ${this.enableShapeUniforms?"\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n":vL(e)}\n\n void main() {\n ivec3 coords = getOutputCoords();\n\n vec4 result = vec4(0.);\n int flatIndex, r, c, offset;\n ivec3 localCoords;\n vec2 uv;\n vec4 values;\n\n ${r}\n\n ${n.output} = ${a};\n }\n `}}function qL(e,t,n,r,a,i){!function(e,t){const n=Ge().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(e<=0||t<=0)throw new Error(`Requested texture size [${e}x${t}] is invalid.`);if(e>n||t>n)throw new Error(`Requested texture size [${e}x${t}] greater than WebGL maximum on this browser / GPU [${n}x${n}].`)}(t,n);const s=function(e){return aL(e,(()=>e.createTexture()),"Unable to create WebGLTexture.")}(e),o=e.TEXTURE_2D;return VA(e,(()=>e.bindTexture(o,s))),VA(e,(()=>e.texParameteri(o,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE))),VA(e,(()=>e.texParameteri(o,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE))),VA(e,(()=>e.texParameteri(o,e.TEXTURE_MIN_FILTER,e.NEAREST))),VA(e,(()=>e.texParameteri(o,e.TEXTURE_MAG_FILTER,e.NEAREST))),1===Ge().getNumber("WEBGL_VERSION")?VA(e,(()=>e.texImage2D(o,0,r,t,n,0,a,i,null))):VA(e,(()=>e.texStorage2D(o,1,r,t,n))),VA(e,(()=>e.bindTexture(e.TEXTURE_2D,null))),{texture:s,texShape:[n,t]}}function WL(e){return e.internalFormatFloat}function VL(e){return e.internalFormatHalfFloat}function GL(e){return e.downloadTextureFormat}function KL(e){return e.internalFormatPackedFloat}function JL(e){return e.internalFormatPackedHalfFloat}class XL{constructor(e){this.outputTexture=null,this.program=null,this.disposed=!1,this.vertexAttrsAreBound=!1,this.itemsToPoll=[];const t=Ge().getNumber("WEBGL_VERSION");null!=e?(this.gl=e,function(e,t){FA[e]=t}(t,e)):this.gl=zA(t);let n="WEBGL_color_buffer_float";const r="EXT_color_buffer_half_float";if(this.parallelCompilationExtension=this.gl.getExtension("KHR_parallel_shader_compile"),1===Ge().getNumber("WEBGL_VERSION")){const e="OES_texture_float",t="OES_texture_half_float";if(this.textureFloatExtension=KA(this.gl,e),dL(this.gl,t))this.textureHalfFloatExtension=KA(this.gl,t);else if(Ge().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(n),dL(this.gl,r))this.colorBufferHalfFloatExtension=KA(this.gl,r);else if(Ge().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(n="EXT_color_buffer_float",dL(this.gl,n))this.colorBufferFloatExtension=this.gl.getExtension(n);else{if(!dL(this.gl,r))throw new Error("GL context does not support color renderable floats");this.colorBufferHalfFloatExtension=this.gl.getExtension(r)}this.vertexBuffer=function(e){return function(e,t){const n=aL(e,(()=>e.createBuffer()),"Unable to create WebGLBuffer");return VA(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,n))),VA(e,(()=>e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW))),n}(e,new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]))}(this.gl),this.indexBuffer=function(e){return function(e,t){const n=aL(e,(()=>e.createBuffer()),"Unable to create WebGLBuffer");return VA(e,(()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n))),VA(e,(()=>e.bufferData(e.ELEMENT_ARRAY_BUFFER,t,e.STATIC_DRAW))),n}(e,new Uint16Array([0,1,2,2,1,3]))}(this.gl),this.framebuffer=function(e){return aL(e,(()=>e.createFramebuffer()),"Unable to create WebGLFramebuffer.")}(this.gl),this.textureConfig=WA(this.gl,this.textureHalfFloatExtension)}get debug(){return Ge().getBool("DEBUG")}dispose(){if(this.disposed)return;null!=this.program&&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."),null!=this.outputTexture&&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;VA(e,(()=>e.finish())),VA(e,(()=>e.bindFramebuffer(e.FRAMEBUFFER,null))),VA(e,(()=>e.deleteFramebuffer(this.framebuffer))),VA(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,null))),VA(e,(()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null))),VA(e,(()=>e.deleteBuffer(this.indexBuffer))),this.disposed=!0}createFloat32MatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,i]=jA(t,n);return qL(e,a,i,WL(r),r.textureFormatFloat,e.FLOAT)}(this.gl,e,t,this.textureConfig)}createFloat16MatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,i]=jA(t,n);return qL(e,a,i,VL(r),r.textureFormatFloat,r.textureTypeHalfFloat)}(this.gl,e,t,this.textureConfig)}createUnsignedBytesMatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,i]=jA(t,n);return qL(e,a,i,GL(r),e.RGBA,e.UNSIGNED_BYTE)}(this.gl,e,t,this.textureConfig)}uploadPixelDataToTexture(e,t){this.throwIfDisposed(),function(e,t,n){VA(e,(()=>e.bindTexture(e.TEXTURE_2D,t))),n.data instanceof Uint8Array?2===Ge().getNumber("WEBGL_VERSION")?VA(e,(()=>e.texSubImage2D(e.TEXTURE_2D,0,0,0,n.width,n.height,e.RGBA,e.UNSIGNED_BYTE,n.data))):VA(e,(()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,n.width,n.height,0,e.RGBA,e.UNSIGNED_BYTE,n.data))):2===Ge().getNumber("WEBGL_VERSION")?VA(e,(()=>e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,n))):VA(e,(()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n))),VA(e,(()=>e.bindTexture(e.TEXTURE_2D,null)))}(this.gl,e,t)}uploadDenseMatrixToTexture(e,t,n,r){this.throwIfDisposed(),function(e,t,n,r,a,i){let s,o,u;VA(e,(()=>e.bindTexture(e.TEXTURE_2D,t))),a instanceof Uint8Array?(s=new Uint8Array(n*r*4),o=e.UNSIGNED_BYTE,u=e.RGBA):(s=new Float32Array(n*r*4),o=e.FLOAT,u=i.internalFormatPackedFloat),s.set(a),2===Ge().getNumber("WEBGL_VERSION")?VA(e,(()=>e.texSubImage2D(e.TEXTURE_2D,0,0,0,n,r,e.RGBA,o,s))):VA(e,(()=>e.texImage2D(e.TEXTURE_2D,0,u,n,r,0,e.RGBA,o,s))),VA(e,(()=>e.bindTexture(e.TEXTURE_2D,null)))}(this.gl,e,t,n,r,this.textureConfig)}createFloat16PackedMatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,i]=qA(t,n);return qL(e,a,i,JL(r),e.RGBA,r.textureTypeHalfFloat)}(this.gl,e,t,this.textureConfig)}createPackedMatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,i]=qA(t,n);return qL(e,a,i,KL(r),e.RGBA,e.FLOAT)}(this.gl,e,t,this.textureConfig)}deleteMatrixTexture(e){this.throwIfDisposed(),this.outputTexture===e&&(nL(this.gl,this.framebuffer),this.outputTexture=null),VA(this.gl,(()=>this.gl.deleteTexture(e)))}downloadByteEncodedFloatMatrixFromOutputTexture(e,t,n){return this.downloadMatrixDriver(e,(()=>function(e,t,n,r){const[a,i]=jA(t,n),s=new Uint8Array(t*n*4);return VA(e,(()=>e.readPixels(0,0,a,i,r.downloadTextureFormat,e.UNSIGNED_BYTE,s))),new Float32Array(s.buffer)}(this.gl,t,n,this.textureConfig)))}downloadPackedMatrixFromBuffer(e,t,n,r,a,i){return function(e,t,n,r,a,i,s,o){const u=e,l=new Float32Array(function(e,t){const[n,r]=qA(e,t);return n*r*4}(i,s));return u.bindBuffer(u.PIXEL_PACK_BUFFER,t),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,l),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),l}(this.gl,e,0,0,0,a,i,this.textureConfig)}downloadFloat32MatrixFromBuffer(e,t){return function(e,t,n){const r=e,a=new Float32Array(n);return r.bindBuffer(r.PIXEL_PACK_BUFFER,t),r.getBufferSubData(r.PIXEL_PACK_BUFFER,0,a),r.bindBuffer(r.PIXEL_PACK_BUFFER,null),a}(this.gl,e,t)}createBufferFromTexture(e,t,n){this.bindTextureToFrameBuffer(e);const r=function(e,t,n,r){const a=e.createBuffer();VA(e,(()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,a)));const i=16*t*n;return VA(e,(()=>e.bufferData(e.PIXEL_PACK_BUFFER,i,e.STREAM_READ))),VA(e,(()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,0))),VA(e,(()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,null))),a}(this.gl,t,n,this.textureConfig);return this.unbindTextureToFrameBuffer(),r}createAndWaitForFence(){const e=this.createFence(this.gl);return this.pollFence(e)}createFence(e){let t,n;if(Ge().getBool("WEBGL_FENCE_API_ENABLED")){const r=e,a=r.fenceSync(r.SYNC_GPU_COMMANDS_COMPLETE,0);e.flush(),n=()=>{const e=r.clientWaitSync(a,0,0);return e===r.ALREADY_SIGNALED||e===r.CONDITION_SATISFIED},t=a}else Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(t=this.beginQuery(),this.endQuery(),n=()=>this.isQueryAvailable(t,Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))):n=()=>!0;return{query:t,isFencePassed:n}}downloadMatrixFromPackedTexture(e,t,n){return this.downloadMatrixDriver(e,(()=>function(e,t,n){const r=new Float32Array(t*n*4);return VA(e,(()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,r))),r}(this.gl,t,n)))}createProgram(e){this.throwIfDisposed();const t=this.gl;null==this.vertexShader&&(this.vertexShader=function(e){const t=yL();return function(e,t){const n=aL(e,(()=>e.createShader(e.VERTEX_SHADER)),"Unable to create vertex WebGLShader.");if(VA(e,(()=>e.shaderSource(n,t))),VA(e,(()=>e.compileShader(n))),!1===e.getShaderParameter(n,e.COMPILE_STATUS))throw console.log(e.getShaderInfoLog(n)),new Error("Failed to compile vertex shader.");return n}(e,`${t.version}\n precision highp float;\n ${t.attribute} vec3 clipSpacePos;\n ${t.attribute} vec2 uv;\n ${t.varyingVs} vec2 resultUV;\n\n void main() {\n gl_Position = vec4(clipSpacePos, 1);\n resultUV = uv;\n }`)}(t));const n=function(e){return aL(e,(()=>e.createProgram()),"Unable to create WebGLProgram.")}(t);return VA(t,(()=>t.attachShader(n,this.vertexShader))),VA(t,(()=>t.attachShader(n,e))),function(e,t){if(VA(e,(()=>e.linkProgram(t))),!Ge().get("ENGINE_COMPILE_ONLY")&&!1===e.getProgramParameter(t,e.LINK_STATUS))throw console.log(e.getProgramInfoLog(t)),new Error("Failed to link vertex and fragment shaders.")}(t,n),this.debug&&ZA(t,n),this.vertexAttrsAreBound||(this.setProgram(n),this.vertexAttrsAreBound=function(e,t,n){return VA(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,n))),QA(e,t,"clipSpacePos",n,3,20,0)&&QA(e,t,"uv",n,2,20,12)}(t,this.program,this.vertexBuffer)),n}deleteProgram(e){this.throwIfDisposed(),e===this.program&&(this.program=null),null!=e&&VA(this.gl,(()=>this.gl.deleteProgram(e)))}setProgram(e){this.throwIfDisposed(),this.program=e,null!=this.program&&this.debug&&ZA(this.gl,this.program),VA(this.gl,(()=>this.gl.useProgram(e)))}getUniformLocation(e,t,n=!0){return this.throwIfDisposed(),n?function(e,t,n){return aL(e,(()=>e.getUniformLocation(t,n)),'uniform "'+n+'" not present in program.')}(this.gl,e,t):function(e,t,n){return e.getUniformLocation(t,n)}(this.gl,e,t)}getAttributeLocation(e,t){return this.throwIfDisposed(),VA(this.gl,(()=>this.gl.getAttribLocation(e,t)))}getUniformLocationNoThrow(e,t){return this.throwIfDisposed(),this.gl.getUniformLocation(e,t)}setInputMatrixTexture(e,t,n){this.throwIfDisposed(),this.throwIfNoProgram(),eL(this.gl,e,t,n)}setOutputMatrixTexture(e,t,n){this.setOutputMatrixTextureDriver(e,n,t)}setOutputPackedMatrixTexture(e,t,n){this.throwIfDisposed();const[r,a]=qA(t,n);this.setOutputMatrixTextureDriver(e,r,a)}setOutputMatrixWriteRegion(e,t,n,r){this.setOutputMatrixWriteRegionDriver(n,e,r,t)}setOutputPackedMatrixWriteRegion(e,t,n,r){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")}debugValidate(){null!=this.program&&ZA(this.gl,this.program),rL(this.gl)}executeProgram(){this.throwIfDisposed(),this.throwIfNoProgram();const e=this.gl;this.debug&&this.debugValidate(),VA(e,(()=>e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0)))}blockUntilAllProgramsCompleted(){this.throwIfDisposed(),VA(this.gl,(()=>this.gl.finish()))}getQueryTimerExtension(){return null==this.disjointQueryTimerExtension&&(this.disjointQueryTimerExtension=KA(this.gl,2===Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension}getQueryTimerExtensionWebGL2(){return this.getQueryTimerExtension()}getQueryTimerExtensionWebGL1(){return this.getQueryTimerExtension()}beginQuery(){if(2===Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){const e=this.gl,t=this.getQueryTimerExtensionWebGL2(),n=e.createQuery();return e.beginQuery(t.TIME_ELAPSED_EXT,n),n}const e=this.getQueryTimerExtensionWebGL1(),t=e.createQueryEXT();return e.beginQueryEXT(e.TIME_ELAPSED_EXT,t),t}endQuery(){if(2===Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){const e=this.gl,t=this.getQueryTimerExtensionWebGL2();return void e.endQuery(t.TIME_ELAPSED_EXT)}const e=this.getQueryTimerExtensionWebGL1();e.endQueryEXT(e.TIME_ELAPSED_EXT)}async waitForQueryAndGetTime(e){return await be((()=>this.disposed||this.isQueryAvailable(e,Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")))),this.getQueryTime(e,Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}getQueryTime(e,t){if(0===t)return null;if(2===t){const t=this.gl;return t.getQueryParameter(e,t.QUERY_RESULT)/1e6}{const t=this.getQueryTimerExtensionWebGL1();return t.getQueryObjectEXT(e,t.QUERY_RESULT_EXT)/1e6}}isQueryAvailable(e,t){if(0===t)return!0;if(2===t){const t=this.gl,n=this.getQueryTimerExtensionWebGL2(),r=t.getQueryParameter(e,t.QUERY_RESULT_AVAILABLE);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(n.GPU_DISJOINT_EXT)),r&&!this.disjoint}{const t=this.getQueryTimerExtensionWebGL1(),n=t.getQueryObjectEXT(e,t.QUERY_RESULT_AVAILABLE_EXT);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(t.GPU_DISJOINT_EXT)),n&&!this.disjoint}}pollFence(e){return new Promise((t=>{this.addItemToPoll((()=>e.isFencePassed()),(()=>t()))}))}pollItems(){const e=function(e){let t=0;for(;te.isDoneFn)));for(let t=0;t<=e;++t){const{resolveFn:e}=this.itemsToPoll[t];e()}this.itemsToPoll=this.itemsToPoll.slice(e+1)}addItemToPoll(e,t){this.itemsToPoll.push({isDoneFn:e,resolveFn:t}),this.itemsToPoll.length>1||be((()=>(this.pollItems(),0===this.itemsToPoll.length)))}bindTextureToFrameBuffer(e){this.throwIfDisposed(),tL(this.gl,e,this.framebuffer),this.debug&&rL(this.gl)}unbindTextureToFrameBuffer(){null!=this.outputTexture?(tL(this.gl,this.outputTexture,this.framebuffer),this.debug&&rL(this.gl)):nL(this.gl,this.framebuffer)}downloadMatrixDriver(e,t){this.bindTextureToFrameBuffer(e);const n=t();return this.unbindTextureToFrameBuffer(),n}setOutputMatrixTextureDriver(e,t,n){this.throwIfDisposed();const r=this.gl;tL(r,e,this.framebuffer),this.debug&&rL(r),this.outputTexture=e,VA(r,(()=>r.viewport(0,0,t,n))),VA(r,(()=>r.scissor(0,0,t,n)))}setOutputMatrixWriteRegionDriver(e,t,n,r){this.throwIfDisposed(),VA(this.gl,(()=>this.gl.scissor(e,t,n,r)))}throwIfDisposed(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.")}throwIfNoProgram(){if(null==this.program)throw new Error("No GPU program is currently set.")}}const{addImpl:ZL,bincountImpl:QL,bincountReduceImpl:e$,ceilImpl:t$,concatImpl:n$,equalImpl:r$,expImpl:a$,expm1Impl:i$,floorImpl:s$,gatherNdImpl:o$,gatherV2Impl:u$,greaterImpl:l$,greaterEqualImpl:c$,lessImpl:p$,lessEqualImpl:d$,linSpaceImpl:h$,logImpl:f$,maxImpl:m$,maximumImpl:g$,minimumImpl:y$,multiplyImpl:b$,negImpl:x$,notEqualImpl:v$,prodImpl:_$,rangeImpl:w$,rsqrtImpl:M$,scatterImpl:N$,sigmoidImpl:S$,simpleAbsImpl:k$,sliceImpl:D$,sparseFillEmptyRowsImpl:T$,sparseReshapeImpl:I$,sparseSegmentReductionImpl:E$,sqrtImpl:C$,stridedSliceImpl:A$,stringNGramsImpl:L$,stringSplitImpl:$$,stringToHashBucketFastImpl:O$,subImpl:R$,tileImpl:F$,topKImpl:Y$,transposeImpl:z$,uniqueImpl:B$}=q;function P$(e,t){return["x","y","z","w","u","v"].slice(0,t).map((t=>`${e}.${t}`))}function H$(e,t){return 1===t?[e]:P$(e,t)}class j${constructor(e){if(this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=e,this.rank=e.length,this.enableShapeUniforms=YL(this.outputShape.length),0===this.rank)this.userCode="\n void main() {\n setOutput(vec4(getA(), 0., 0., 0.));\n }\n ";else{const e=H$("rc",this.rank),t=AL(this.rank),n=this.getOutOfBoundsCondition(e),r=this.getSetup(e),a=this.getOutput(e);this.userCode=`\n void main() {\n ${t} rc = getOutputCoords();\n\n if(${n}) {\n setOutput(vec4(0));\n } else {\n ${r}\n\n setOutput(vec4(${a}));\n }\n }\n `}}getSourceCoordsArr(e){const t=[];for(let n=0;n<=1;n++)for(let r=0;r<=1;r++){let a=`${0===n?"r":"rp1"}, ${0===r?"c":"cp1"}`;for(let t=2;t ${this.enableShapeUniforms?"outShape":this.outputShape[0]}`;let t="";for(let n=this.rank-2;n= ${this.enableShapeUniforms?`outShape[${n}]`:this.outputShape[n]}`,n= ${n};\n bool rEdge = rp1 >= ${r};\n `}getOutput(e){const t=this.getSourceCoordsArr(e);return 1===this.rank?`getA(rc), (rc + 1 >= ${this.enableShapeUniforms?"outShape":this.outputShape[0]} ? 0. : getA(rc + 1)), 0, 0`:`getA(${t[0]}),\n cEdge ? 0. : getA(${t[1]}),\n rEdge ? 0. : getA(${t[2]}),\n rEdge || cEdge ? 0. : getA(${t[3]})`}}class U${constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec3"}],this.outputShape=e,this.enableShapeUniforms=YL(this.outputShape.length);let n="";for(let e=0;e<4;e++){let t="thisRC = rc;";e%2==1&&(t+="thisRC.z += 1;"),e>1&&(t+="thisRC.y += 1;"),n+=`\n ${t}\n ${e>0?"if(thisRC.y < rows && thisRC.z < cols){":""}\n int flatIndex = getFlatIndex(thisRC);\n\n ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex);\n vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z));\n\n result[${e}] =\n getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);\n ${e>0?"}":""}\n `}var r,a;this.userCode=`\n ${r=t,a=this.enableShapeUniforms,`\n ivec3 inputCoordsFromReshapedOutCoords(int index) {\n ${a?function(e,t,n="index"){const r=e.map(((e,t)=>t)),a=function(e,t){const n=e.length,r=e.map((e=>`${t}[${e}]`)),a=new Array(n-1);a[n-2]=r[n-1];for(let e=n-3;e>=0;--e)a[e]=`(${a[e+1]} * ${r[e+1]})`;return a}(r,t);return a.map(((t,r)=>`int ${e[r]} = ${n} / ${a[r]}; ${r===a.length-1?`int ${e[r+1]} = ${n} - ${e[r]} * ${a[r]}`:`index -= ${e[r]} * ${a[r]}`};`)).join("")}(["r","c","d"],"inputShape"):bL(["r","c","d"],r)}\n return ivec3(r, c, d);\n }\n `}\n ${this.enableShapeUniforms?"\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n":vL(e)}\n\n void main() {\n ivec3 rc = getOutputCoords();\n\n vec4 result = vec4(0.);\n\n ivec3 thisRC;\n int rows = ${this.enableShapeUniforms?"outShape[1]":e[1]};\n int cols = ${this.enableShapeUniforms?"outShape[2]":e[2]};\n\n ${n}\n\n setOutput(result);\n }\n `}}class q${constructor(e){this.gpgpu=e,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0,this.freeTextures={},this.logEnabled=!1,this.usedTextures={}}acquireTexture(e,t,n){const r=V$(t,n),a=G$(e,r,n);a in this.freeTextures||(this.freeTextures[a]=[]),a in this.usedTextures||(this.usedTextures[a]=[]);const i=W$(e,r,this.gpgpu.gl,this.gpgpu.textureConfig,n);if(this.freeTextures[a].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=i,this.log();const e=this.freeTextures[a].shift();return this.usedTextures[a].push(e),e}let s;return r===HA.PACKED_2X2_FLOAT32?s=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):r===HA.PACKED_2X2_FLOAT16?s=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):r===HA.UNPACKED_FLOAT32?s=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):r===HA.UNPACKED_FLOAT16?s=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):r===HA.PACKED_4X1_UNSIGNED_BYTE&&(s=this.gpgpu.createUnsignedBytesMatrixTexture(e[0],e[1])),this.usedTextures[a].push(s),this.numUsedTextures++,this._numBytesAllocated+=i,this.log(),s}releaseTexture(e,t,n,r){if(null==this.freeTextures)return;const a=V$(n,r),i=G$(t,a,r);i in this.freeTextures||(this.freeTextures[i]=[]);const s=W$(t,a,this.gpgpu.gl,this.gpgpu.textureConfig,r),o=Ge().get("WEBGL_DELETE_TEXTURE_THRESHOLD");-1!==o&&this._numBytesAllocated>o?(this.gpgpu.deleteMatrixTexture(e.texture),this._numBytesAllocated-=s):(this.freeTextures[i].push(e),this.numFreeTextures++,this._numBytesFree+=s),this.numUsedTextures--;const u=this.usedTextures[i],l=u.indexOf(e);if(l<0)throw new Error("Cannot release a texture that was never provided by this texture manager");u.splice(l,1),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(null!=this.freeTextures){for(const e in this.freeTextures)this.freeTextures[e].forEach((e=>{this.gpgpu.deleteMatrixTexture(e.texture)}));for(const e in this.usedTextures)this.usedTextures[e].forEach((e=>{this.gpgpu.deleteMatrixTexture(e.texture)}));this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0}}}function W$(e,t,n,r,a){const i=function(e,t){switch(e){case HA.PACKED_2X2_FLOAT32:return KL(t);case HA.PACKED_2X2_FLOAT16:return JL(t);case HA.UNPACKED_FLOAT32:return WL(t);case HA.UNPACKED_FLOAT16:return VL(t);case HA.PACKED_4X1_UNSIGNED_BYTE:return GL(t);default:throw new Error(`Unknown physical texture type ${e}`)}}(t,r);let s;if(a){const[t,n]=qA(e[0],e[1]);s=t*n}else{const[t,n]=jA(e[0],e[1]);s=t*n}const o=function(e,t){const n=e;if(t===n.R32F)return 4;if(t===n.R16F)return 2;if(t===n.RGBA32F)return 16;if(t===e.RGBA)return 16;if(t===n.RGBA16F)return 8;if(t===n.RGBA8)return 4;throw new Error(`Unknown internal format ${t}`)}(n,i);return s*o}function V$(e,t){if(e===PA.UPLOAD)return HA.PACKED_2X2_FLOAT32;if(e===PA.RENDER||null==e)return function(e){return Ge().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?e?HA.PACKED_2X2_FLOAT32:HA.UNPACKED_FLOAT32:e?HA.PACKED_2X2_FLOAT16:HA.UNPACKED_FLOAT16}(t);if(e===PA.DOWNLOAD||e===PA.PIXELS)return HA.PACKED_4X1_UNSIGNED_BYTE;throw new Error(`Unknown logical texture type ${e}`)}function G$(e,t,n){return`${e[0]}_${e[1]}_${t}_${n}`}class K${constructor(e,t){this.variableNames=["A"],this.outputShape=e,this.enableShapeUniforms=YL(this.outputShape.length),this.userCode=`\n float unaryOperation(float x) {\n ${t}\n }\n\n void main() {\n float x = getAAtOutCoords();\n float y = unaryOperation(x);\n\n setOutput(y);\n }\n `}}const J$="return abs(x);",X$="return x;";class Z${constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.enableShapeUniforms=YL(this.outputShape.length),this.userCode=`\n vec4 unaryOperation(vec4 x) {\n ${t}\n }\n\n void main() {\n vec4 x = getAAtOutCoords();\n vec4 y = unaryOperation(x);\n\n setOutput(y);\n }\n `}}class Q${constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=e,this.enableShapeUniforms=YL(this.outputShape.length);const t=e.length,n=H$("rc",t),r=AL(t),a=function(e,t){if(1===e)return"rc";let n="";for(let r=0;rt.push(e)))}const t=this.texData.get(e),{values:n,shape:r,slice:a,dtype:i,complexTensorInfos:s,isPacked:o}=t;if(null!=a){let t;t=o?new Z$(r,X$):new K$(r,X$);const n=this.runWebGLProgram(t,[{dataId:e,shape:r,dtype:i}],i),a=this.read(n.dataId);return this.disposeIntermediateTensorInfo(n),a}if(null!=n)return this.convertAndCacheOnCPU(e);if(Ge().getBool("DEBUG")&&!Ge().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&2===Ge().getNumber("WEBGL_VERSION"))throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");let u,l,c=null;if("complex64"!==i&&Ge().get("WEBGL_BUFFER_SUPPORTED")){u=this.decode(e);const t=this.texData.get(u.dataId);c=this.gpgpu.createBufferFromTexture(t.texture.texture,...UA(r))}if(this.pendingRead.set(e,[]),"complex64"!==i&&await this.gpgpu.createAndWaitForFence(),"complex64"===i){const e=await Promise.all([this.read(s.real.dataId),this.read(s.imag.dataId)]);l=yf(e[0],e[1])}else if(null==c)l=this.getValuesFromTexture(e);else{const e=ce(r);l=this.gpgpu.downloadFloat32MatrixFromBuffer(c,e)}if(null!=u&&this.disposeIntermediateTensorInfo(u),null!=c){const e=this.gpgpu.gl;VA(e,(()=>e.deleteBuffer(c)))}const p=this.convertAndCacheOnCPU(e,l),d=this.pendingRead.get(e);return this.pendingRead.delete(e),d.forEach((e=>e(p))),this.pendingDisposal.has(e)&&(this.pendingDisposal.delete(e),this.disposeData(e)&&lo().removeDataId(e,this),this.pendingDeletes--),p}readToGPU(e,t={}){const n=this.texData.get(e),{values:r,shape:a,slice:i,dtype:s,isPacked:o,texture:u}=n;if("complex64"===s)throw new Error("Does not support reading texture for complex64 dtype.");if(null!=i){let n;n=o?new Z$(a,X$):new K$(a,X$);const r=this.runWebGLProgram(n,[{dataId:e,shape:a,dtype:s}],s),i=this.readToGPU(r,t);return this.disposeIntermediateTensorInfo(r),i}if(null==u)throw null!=r?new Error("Data is not on GPU but on CPU."):new Error("There is no data on GPU or CPU.");const l=this.decode(e,t.customTexShape),c=lo().makeTensorFromTensorInfo(l),p=this.texData.get(l.dataId);return Object.assign({tensorRef:c},p.texture)}bufferSync(e){const t=this.readSync(e.dataId);if("string"===e.dtype)try{const n=t.map((e=>Ha(e)));return As(e.shape,e.dtype,n)}catch(e){throw new Error("Failed to decode encoded string bytes into utf-8")}return As(e.shape,e.dtype,t)}checkNumericalProblems(e){if(null!=e)for(let t=0;t0}time(e){const t=this.activeTimers,n=[];let r=!1;null==this.programTimersStack?(this.programTimersStack=n,r=!0):this.activeTimers.push(n),this.activeTimers=n,e();const a=le(this.activeTimers.map((e=>e.query))).filter((e=>null!=e)),i=le(this.activeTimers.map((e=>e.name))).filter((e=>null!=e));this.activeTimers=t,r&&(this.programTimersStack=null);const s={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null};return(async()=>{if(Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0){const e=await Promise.all(a);s.kernelMs=re(e),s.getExtraProfileInfo=()=>e.map(((e,t)=>({name:i[t],ms:e}))).map((e=>`${e.name}: ${e.ms}`)).join(", ")}else s.kernelMs={error:"WebGL query timers are not supported in this environment."};return this.uploadWaitMs=0,this.downloadWaitMs=0,s})()}memory(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU,numBytesInGPUAllocated:this.textureManager.numBytesAllocated,numBytesInGPUFree:this.textureManager.numBytesFree}}startTimer(){return Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:za(),endMs:null}}endTimer(e){return Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),e):(e.endMs=za(),e)}async getQueryTime(e){if(Ge().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:n}=this.texData.get(e);return null!=n&&(this.disposeData(n.real.dataId,t),this.disposeData(n.imag.dataId,t)),this.texData.delete(e),!0}releaseGPUData(e){const{texture:t,dtype:n,texShape:r,usage:a,isPacked:i,slice:s}=this.texData.get(e),o=s&&s.origDataId||e,u=this.dataRefCount.get(o);u>1?this.dataRefCount.set(o,u-1):(this.dataRefCount.delete(o),null!=t&&(this.numBytesInGPU-=this.computeBytes(r,n),this.textureManager.releaseTexture(t,r,a,i)));const l=this.texData.get(e);l.texture=null,l.texShape=null,l.isPacked=!1,l.slice=null}getTexture(e){return this.uploadToGPU(e),this.texData.get(e).texture.texture}getDataInfo(e){return this.texData.get(e)}shouldExecuteOnCPU(e,t=nO){return Ge().getBool("WEBGL_CPU_FORWARD")&&e.every((e=>null==this.texData.get(e.dataId).texture&&ce(e.shape)0&&Ee(n[0])){const a=n.map((e=>Pa(e)));r=this.write(a,e,t)}else r=this.write(n,e,t);return this.texData.get(r).usage=null,{dataId:r,shape:e,dtype:t}}makeOutput(e,t,n){return lo().makeTensorFromTensorInfo(this.makeTensorInfo(e,t,n),this)}unpackTensor(e){const t=new Q$(e.shape);return this.runWebGLProgram(t,[e],e.dtype)}packTensor(e){const t=new j$(e.shape);return this.runWebGLProgram(t,[e],e.dtype,null,!0)}packedReshape(e,t){const n=[iL(e.shape),...sL(e.shape)],r={dtype:e.dtype,shape:n,dataId:e.dataId},a=[iL(t),...sL(t)],i=new U$(a,n),s=[n],o=this.runWebGLProgram(i,[r],e.dtype,s,!0);return{dataId:o.dataId,shape:t,dtype:o.dtype}}decode(e,t){const n=this.texData.get(e),{isPacked:r,shape:a,dtype:i}=n;null!=t&&se(ce(a)<=t[0]*t[1]*4,(()=>"customTexShape is too small. Row * Column * 4 should be equal or larger than the size of the tensor data."));const s=oL(a);let o;o=r?new BL(s):new zL(s);const u=[null!=t?t:UA(s)];return{dtype:i,shape:a,dataId:this.runWebGLProgram(o,[{shape:s,dtype:i,dataId:e}],i,u,!0,t).dataId}}runWebGLProgram(e,t,n,r,a=!1,i){const s=this.makeTensorInfo(e.outputShape,n),o=this.texData.get(s.dataId);if(e.packedOutput&&(o.isPacked=!0),e.outPackingScheme===BA.DENSE){const t=null!=i?i:UA(e.outputShape);o.texShape=t.map((e=>2*e))}if(null!=e.outTexUsage&&(o.usage=e.outTexUsage),0===ce(s.shape))return o.values=we(s.dtype,0),s;const u=[],l=t.map((t=>{if("complex64"===t.dtype)throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");let n=this.texData.get(t.dataId);if(null==n.texture){if(!e.packedInputs&&ce(t.shape)<=Ge().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return{shape:t.shape,texData:null,isUniform:!0,uniformValues:n.values};e.packedInputs&&(n.isPacked=!0,n.shape=t.shape)}if(this.uploadToGPU(t.dataId),!!n.isPacked!=!!e.packedInputs)t=n.isPacked?this.unpackTensor(t):this.packTensor(t),u.push(t),n=this.texData.get(t.dataId);else if(n.isPacked&&!lL(n.shape,t.shape)){const e=t,r=t.shape;t.shape=n.shape,t=this.packedReshape(t,r),u.push(t),n=this.texData.get(t.dataId),e.shape=r}return{shape:t.shape,texData:n,isUniform:!1}}));this.uploadToGPU(s.dataId);const c={shape:s.shape,texData:o,isUniform:!1},p=function(e,t,n){let r="";t.concat(n).forEach((t=>{const a=null!=t.texData&&null!=t.texData.slice&&t.texData.slice.flatOffset>0;if(e.enableShapeUniforms&&!t.isUniform){const i=t.texData.texShape,{useSqueezeShape:s,uniformShape:o,keptDims:u}=LL(e.packedInputs,t.shape,i);let l="",c="",p="";if(1===o.length&&e.packedInputs){const e=[Math.ceil(i[0]/2),Math.ceil(i[1]/2)];l=`${e[0]>1}_${e[1]>1}`}else if(2!==o.length||e.packedInputs){if(o.length>2&&!e.packedInputs){const e=Re(o);p=`${e[0]===i[1]}_${e[e.length-1]===i[1]}`}}else c=`${o[0]>1}_${o[1]>1}`;const d=t.shape.length,h=2===o.length&&de(t.shape,i),f=1===ce(t.shape),m=Co(t.shape,n.shape),g=!e.packedInputs&&d===n.shape.length&&de(i,n.texData.texShape),y=e.packedInputs||o.length>2?"":`${i[0]>1}_${i[1]>1}`;r+=`${d}_${g}_${s?u:""}_${o.length}_${f}_${m}_${h}_${l}_${c}_${p}_${y}_${a}`}else{const e=t.isUniform?"uniform":t.texData.texShape;r+=`${t.shape}_${e}_${a}`}}));const a=e.userCode;let i=e.constructor.name;return i+="_"+r+"_"+a+`${Ge().getNumber("WEBGL_VERSION")}`,i}(e,l,c),d=this.getAndSaveBinary(p,(()=>function(e,t,n,r){const a=n.map(((e,n)=>{const r={logicalShape:e.shape,texShape:e.isUniform?null:e.texData.texShape,isUniform:e.isUniform,isPacked:!e.isUniform&&e.texData.isPacked,flatOffset:null};return null!=e.texData&&null!=e.texData.slice&&e.texData.slice.flatOffset>0&&(r.flatOffset=e.texData.slice.flatOffset),{name:t.variableNames[n],shapeInfo:r}})),i=a.map((e=>e.shapeInfo)),s={logicalShape:r.shape,texShape:r.texData.texShape,isUniform:!1,isPacked:r.texData.isPacked,flatOffset:null},o=ML(a,s,t),u=function(e,t){const n=aL(e,(()=>e.createShader(e.FRAGMENT_SHADER)),"Unable to create fragment WebGLShader.");if(VA(e,(()=>e.shaderSource(n,t))),VA(e,(()=>e.compileShader(n))),Ge().get("ENGINE_COMPILE_ONLY"))return n;if(!1===e.getShaderParameter(n,e.COMPILE_STATUS))throw XA(t,e.getShaderInfoLog(n)),new Error("Failed to compile fragment shader.");return n}(e.gl,o),l=e.createProgram(u);return Ge().get("ENGINE_COMPILE_ONLY")?{program:t,fragmentShader:u,source:o,webGLProgram:l,inShapeInfos:i,outShapeInfo:s,uniformLocations:null,customUniformLocations:null,infLoc:null,nanLoc:null,inShapesLocations:null,inTexShapesLocations:null,outShapeLocation:null,outShapeStridesLocation:null,outTexShapeLocation:null}:Object.assign({program:t,fragmentShader:u,source:o,webGLProgram:l,inShapeInfos:i,outShapeInfo:s},RL(e,t,l))}(this.gpgpu,e,l,c))),h=null!=this.activeTimers;let f;h&&(f=this.startTimer()),Ge().get("ENGINE_COMPILE_ONLY")||function(e,t,n,r,a){t.program.enableShapeUniforms||(FL(t.inShapeInfos,n),FL([t.outShapeInfo],[r]));const i=r.texData.texture,s=r.texData.texShape;r.texData.isPacked?e.setOutputPackedMatrixTexture(i.texture,s[0],s[1]):e.setOutputMatrixTexture(i.texture,s[0],s[1]),e.setProgram(t.webGLProgram),1===Ge().getNumber("WEBGL_VERSION")&&null!==t.infLoc&&e.gl.uniform1f(t.infLoc,1/0),null!==t.nanLoc&&e.gl.uniform1f(t.nanLoc,NaN),n.forEach(((n,r)=>{const a=t.program.variableNames[r],i=t.uniformLocations[a],s=t.uniformLocations[`offset${a}`],o=t.inShapesLocations[`${a}Shape`],u=t.inTexShapesLocations[`${a}TexShape`];if(o){const{uniformShape:r}=LL(t.program.packedInputs,n.shape,n.texData.texShape);switch(r.length){case 1:e.gl.uniform1iv(o,new Int32Array(r));break;case 2:e.gl.uniform2iv(o,new Int32Array(r));break;case 3:e.gl.uniform3iv(o,new Int32Array(r));break;case 4:e.gl.uniform4iv(o,new Int32Array(r))}}if(u&&e.gl.uniform2i(u,n.texData.texShape[0],n.texData.texShape[1]),null!=i)if(n.isUniform)if(ce(n.shape)<2)e.gl.uniform1f(i,n.uniformValues[0]);else{let t=n.uniformValues;t instanceof Float32Array||(t=new Float32Array(t)),e.gl.uniform1fv(i,t)}else null!=n.texData.slice&&null!=s&&e.gl.uniform1i(s,n.texData.slice.flatOffset),e.setInputMatrixTexture(n.texData.texture.texture,i,r)}));const o=t.outShapeLocation;if(o)switch(r.shape.length){case 1:e.gl.uniform1iv(o,new Int32Array(r.shape));break;case 2:e.gl.uniform2iv(o,new Int32Array(r.shape));break;case 3:e.gl.uniform3iv(o,new Int32Array(r.shape));break;case 4:e.gl.uniform4iv(o,new Int32Array(r.shape))}if(t.outShapeStridesLocation){const n=Re(r.shape);switch(r.shape.length){case 2:e.gl.uniform1iv(t.outShapeStridesLocation,new Int32Array(n));break;case 3:e.gl.uniform2iv(t.outShapeStridesLocation,new Int32Array(n));break;case 4:e.gl.uniform3iv(t.outShapeStridesLocation,new Int32Array(n))}}t.outTexShapeLocation&&e.gl.uniform2i(t.outTexShapeLocation,r.texData.texShape[0],r.texData.texShape[1]),t.program.customUniforms&&a&&t.program.customUniforms.forEach(((n,r)=>{const i=t.customUniformLocations[r],s=a[r];if("float"===n.type)e.gl.uniform1fv(i,s);else if("vec2"===n.type)e.gl.uniform2fv(i,s);else if("vec3"===n.type)e.gl.uniform3fv(i,s);else if("vec4"===n.type)e.gl.uniform4fv(i,s);else if("int"===n.type)e.gl.uniform1iv(i,s);else if("ivec2"===n.type)e.gl.uniform2iv(i,s);else if("ivec3"===n.type)e.gl.uniform3iv(i,s);else{if("ivec4"!==n.type)throw Error(`uniform type ${n.type} is not supported yet.`);e.gl.uniform4iv(i,s)}})),e.executeProgram()}(this.gpgpu,d,l,c,r),u.forEach((e=>this.disposeIntermediateTensorInfo(e))),h&&(f=this.endTimer(f),this.activeTimers.push({name:e.constructor.name,query:this.getQueryTime(f)}));const m=Ge().get("WEBGL_FLUSH_THRESHOLD");if(m>0){const e=za();e-this.lastGlFlushTime>m&&(this.gpgpu.gl.flush(),this.lastGlFlushTime=e)}if(!Ge().getBool("WEBGL_LAZILY_UNPACK")&&o.isPacked&&!1===a){const e=this.unpackTensor(s);return this.disposeIntermediateTensorInfo(s),e}return s}compileAndRun(e,t,n,r,a=!1){return n=n||t[0].dtype,this.runWebGLProgram(e,t,n,r,a)}getAndSaveBinary(e,t){return e in this.binaryCache||(this.binaryCache[e]=t()),this.binaryCache[e]}getTextureManager(){return this.textureManager}dispose(){this.disposed||(Ge().getBool("IS_TEST")||Object.keys(this.binaryCache).forEach((e=>{this.gpgpu.deleteProgram(this.binaryCache[e].webGLProgram),delete this.binaryCache[e]})),this.textureManager.dispose(),null!=this.canvas&&"undefined"!=typeof HTMLCanvasElement&&this.canvas instanceof HTMLCanvasElement?this.canvas.remove():this.canvas=null,this.gpgpuCreatedLocally&&(this.gpgpu.program=null,this.gpgpu.dispose()),this.disposed=!0)}floatPrecision(){return null==this.floatPrecisionValue&&(this.floatPrecisionValue=ho((()=>{if(!Ge().get("WEBGL_RENDER_FLOAT32_ENABLED")){const e=Ge().getBool("DEBUG");Ge().set("DEBUG",!1);const t=this.abs(Ru(1e-8)).dataSync()[0];if(Ge().set("DEBUG",e),t>0)return 32}return 16}))),this.floatPrecisionValue}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}uploadToGPU(e){const t=this.texData.get(e),{shape:n,dtype:r,values:a,texture:i,usage:s,isPacked:o}=t;if(null!=i)return;const u=null!=this.activeTimers;let l;u&&(l=za());let c=t.texShape;if(null==c&&(c=function(e,t=!1){let n=Ge().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(t&&(n*=2,e=e.map(((t,n)=>n>=e.length-2?te(e[n]):e[n])),1===e.length&&(e=[2,e[0]])),2!==e.length){const t=_e(e);e=t.newShape}let r=ce(e);if(e.length<=1&&r<=n)return[1,r];if(2===e.length&&e[0]<=n&&e[1]<=n)return e;if(3===e.length&&e[0]*e[1]<=n&&e[2]<=n)return[e[0]*e[1],e[2]];if(3===e.length&&e[0]<=n&&e[1]*e[2]<=n)return[e[0],e[1]*e[2]];if(4===e.length&&e[0]*e[1]*e[2]<=n&&e[3]<=n)return[e[0]*e[1]*e[2],e[3]];if(4===e.length&&e[0]<=n&&e[1]*e[2]*e[3]<=n)return[e[0],e[1]*e[2]*e[3]];if(t){const t=iL(e);let n=2,a=2;return e.length&&([n,a]=sL(e)),r=t*(n/2)*(a/2),me(r).map((e=>2*e))}return me(r)}(n,o),t.texShape=c),null!=a){const e=oL(n);let i,s=c[1],p=c[0];const d=a instanceof Uint8Array||a instanceof Uint8ClampedArray;!o&&d||([s,p]=qA(c[0],c[1])),i=o?new UL(e,d):new jL(e,d);const h=d?[p,s]:c,f=this.makeTensorInfo(h,r),m=this.texData.get(f.dataId);m.usage=d?PA.PIXELS:PA.UPLOAD,m.texShape=h,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(f.dataId),s,p,a);const g=[[p,s]],y=!0,b=this.runWebGLProgram(i,[f],r,g,y),x=this.texData.get(b.dataId);t.texShape=x.texShape,t.isPacked=x.isPacked,t.usage=x.usage,Ge().get("ENGINE_COMPILE_ONLY")?this.disposeData(b.dataId):(t.texture=x.texture,t.values=null,this.texData.delete(b.dataId)),this.disposeIntermediateTensorInfo(f),u&&(this.uploadWaitMs+=za()-l)}else{const e=this.acquireTexture(c,s,r,o);t.texture=e}}convertAndCacheOnCPU(e,t){const n=this.texData.get(e),{dtype:r}=n;return this.releaseGPUData(e),null!=t&&(n.values=function(e,t){if("float32"===t||"complex64"===t)return e;if("int32"===t||"bool"===t){const n="int32"===t?new Int32Array(e.length):new Uint8Array(e.length);for(let t=0;t1024*this.numMBBeforeWarning*1024){const e=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn(`High memory usage in GPU: ${e} MB, most likely due to a memory leak`)}return this.textureManager.acquireTexture(e,t,r)}computeBytes(e,t){return e[0]*e[1]*Te(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)}for(const[,t]of Object.entries(this.binaryCache)){const n=new Promise((e=>{try{this.checkCompletion_(t),e(!0)}catch(e){throw e}}));e.push(n)}return Promise.all(e)}async checkCompletionAsync_(e){return this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.parallelCompilationExtension.COMPLETION_STATUS_KHR)?this.checkCompletion_(e):(await Xh(),this.checkCompletionAsync_(e))}checkCompletion_(e){if(!1===this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.gl.LINK_STATUS)){if(console.log(this.gpgpu.gl.getProgramInfoLog(e.webGLProgram)),!1===this.gpgpu.gl.getShaderParameter(e.fragmentShader,this.gpgpu.gl.COMPILE_STATUS))throw XA(e.source,this.gpgpu.gl.getShaderInfoLog(e.fragmentShader)),new Error("Failed to compile fragment shader.");throw new Error("Failed to link vertex and fragment shaders.")}return!0}getUniformLocations(){for(const[,e]of Object.entries(this.binaryCache)){const{uniformLocations:t,customUniformLocations:n,infLoc:r,nanLoc:a,inShapesLocations:i,inTexShapesLocations:s,outShapeLocation:o,outShapeStridesLocation:u,outTexShapeLocation:l}=RL(this.gpgpu,e.program,e.webGLProgram);e.uniformLocations=t,e.customUniformLocations=n,e.infLoc=r,e.nanLoc=a,e.inShapesLocations=i,e.inTexShapesLocations=s,e.outShapeLocation=o,e.outShapeStridesLocation=u,e.outTexShapeLocation=l}}}rO.nextDataId=0,ki()&&Mo("webgl",(()=>new rO),2);class aO{constructor(e,t,n){this.variableNames=["A","B"],this.outputShape=Lo(t,n),this.enableShapeUniforms=YL(this.outputShape.length),this.userCode=`\n float binaryOperation(float a, float b) {\n ${e}\n }\n\n void main() {\n float a = getAAtOutCoords();\n float b = getBAtOutCoords();\n setOutput(binaryOperation(a, b));\n }\n `}}class iO{constructor(e,t,n,r=!1){this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=Lo(t,n);const a=this.outputShape.length;this.enableShapeUniforms=YL(a);let i="";if(r)if(0===a||1===ce(this.outputShape))i="\n result.y = 0.;\n result.z = 0.;\n result.w = 0.;\n ";else if(i=`\n ${AL(a)} coords = getOutputCoords();\n `,1===a)this.enableShapeUniforms?i+="\n result.y = (coords + 1) >= outShape ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n ":i+=`\n result.y = (coords + 1) >= ${this.outputShape[0]} ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n `;else{const e=H$("coords",a);this.enableShapeUniforms?i+=`\n bool nextRowOutOfBounds =\n (${e[a-2]} + 1) >= outShape[${a} - 2];\n bool nextColOutOfBounds =\n (${e[a-1]} + 1) >= outShape[${a} - 1];\n result.y = nextColOutOfBounds ? 0. : result.y;\n result.z = nextRowOutOfBounds ? 0. : result.z;\n result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n `:i+=`\n bool nextRowOutOfBounds =\n (${e[a-2]} + 1) >= ${this.outputShape[a-2]};\n bool nextColOutOfBounds =\n (${e[a-1]} + 1) >= ${this.outputShape[a-1]};\n result.y = nextColOutOfBounds ? 0. : result.y;\n result.z = nextRowOutOfBounds ? 0. : result.z;\n result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n `}this.userCode=`\n vec4 binaryOperation(vec4 a, vec4 b) {\n ${e}\n }\n\n void main() {\n vec4 a = getAAtOutCoords();\n vec4 b = getBAtOutCoords();\n\n vec4 result = binaryOperation(a, b);\n ${i}\n\n setOutput(result);\n }\n `}}function sO(e){const{inputs:t,backend:n}=e,{x:r}=t;return n.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}const oO={kernelName:fn,backendName:"webgl",kernelFunc:sO};function uO(e){const{inputs:t,backend:n}=e,{real:r,imag:a}=t,i=n.makeTensorInfo(r.shape,"complex64"),s=n.texData.get(i.dataId),o=sO({inputs:{x:r},backend:n}),u=sO({inputs:{x:a},backend:n});return s.complexTensorInfos={real:o,imag:u},i}const lO={kernelName:St,backendName:"webgl",kernelFunc:uO},cO="return (a < 0.) ? b * a : a;",pO="\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n",dO={kernelName:vn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{alpha:i}=r,s=n.makeTensorInfo([],"float32",Fa(i,"float32")),o=Ge().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new iO(pO,a.shape,s.shape):new aO(cO,a.shape,s.shape),u=n.runWebGLProgram(o,[a,s],"float32");return n.disposeIntermediateTensorInfo(s),u}},hO="return (a < 0.) ? b * a : a;",fO="\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n",mO={kernelName:ir,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r,alpha:a}=t,i=Ge().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new iO(fO,r.shape,a.shape):new aO(hO,r.shape,a.shape);return n.runWebGLProgram(i,[r,a],"float32")}};function gO({opSnippet:e,packedOpSnippet:t,cpuKernelImpl:n,dtype:r}){return({inputs:a,backend:i})=>{const{x:s}=a,o=i,u=r||s.dtype;if(o.shouldExecuteOnCPU([s])&&null!=n){const e=o.texData.get(s.dataId),t=n(e.values,u);return o.makeTensorInfo(s.shape,u,t)}let l;return l=Ge().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&null!=t?new Z$(s.shape,t):new K$(s.shape,e),o.runWebGLProgram(l,[s],u)}}function yO({opSnippet:e,packedOpSnippet:t,checkOutOfBounds:n=!1,supportsComplex:r=!1,cpuKernelImpl:a,dtype:i}){return({inputs:s,backend:o})=>{const{a:u,b:l}=s,c=o;if(r&&"complex64"===u.dtype){const t=c.texData.get(u.dataId),n=c.texData.get(l.dataId),[r,a]=[[t.complexTensorInfos.real,n.complexTensorInfos.real],[t.complexTensorInfos.imag,n.complexTensorInfos.imag]].map((t=>{const[n,r]=t,a={dataId:n.dataId,dtype:n.dtype,shape:u.shape},i={dataId:r.dataId,dtype:r.dtype,shape:l.shape},s=new aO(e,u.shape,l.shape);return c.runWebGLProgram(s,[a,i],ci(n.dtype,r.dtype))})),i=uO({inputs:{real:r,imag:a},backend:c});return c.disposeIntermediateTensorInfo(r),c.disposeIntermediateTensorInfo(a),i}const p=i||ci(u.dtype,l.dtype);if(("string"===u.dtype||"string"===l.dtype||c.shouldExecuteOnCPU([u,l]))&&null!=a){const e=c.texData.get(u.dataId).values,t=c.texData.get(l.dataId).values,n="string"===u.dtype?Gf(e):e,r="string"===u.dtype?Gf(t):t,[i,s]=a(u.shape,l.shape,n,r,p),o=c.makeTensorInfo(s,p);return c.texData.get(o.dataId).values=i,o}let d;return d=Ge().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&null!=t?new iO(t,u.shape,l.shape,n):new aO(e,u.shape,l.shape),c.runWebGLProgram(d,[u,l],p)}}function bO(e,t=!1){if("linear"===e)return"return x;";if("relu"===e)return t?"\n vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n":"if (isnan(x)) return x;\n return (x < 0.0) ? 0.0 : x;\n";if("elu"===e)return t?"\n vec4 result;\n\n result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);\n result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);\n result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);\n result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);\n\n return result;\n":"return (x >= 0.0) ? x : (exp(x) - 1.0);";if("relu6"===e)return t?"\n vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n":"if (isnan(x)) return x;\n return (x < 0.0) ? 0.0 : min(6.0, x);\n";if("prelu"===e)return t?fO:hO;if("leakyrelu"===e)return t?pO:cO;if("sigmoid"===e)return"return 1.0 / (1.0 + exp(-1.0 * x));";throw new Error(`Activation ${e} has not been implemented for the WebGL backend.`)}class xO{constructor(e,t,n,r=!1,a=!1,i=!1,s=null,o=!1,u=!1){this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=n,this.enableShapeUniforms=YL(this.outputShape.length);const l=r?e[1]:e[2],c=Math.ceil(l/2),p=r?"i * 2, rc.y":"rc.y, i * 2",d=a?"rc.z, i * 2":"i * 2, rc.z",h=r?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],f=a?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"];let m="",g="";s&&(m=o?`vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n ${s}\n }`:u?`vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n ${s}\n }`:`vec4 activation(vec4 x) {\n ${s}\n }`,g="result = activation(result);");const y=i?"result += getBiasAtOutCoords();":"";i&&this.variableNames.push("bias"),o&&this.variableNames.push("preluActivationWeights"),u&&this.variableNames.push("leakyreluAlpha");let b="rc.x",x="rc.x";e[0]`The new shape (${u}) has ${l} elements and the old shape (${a.shape}) has ${o} elements. The new shape and old shape must have the same number of elements.`));const c=s.texData.get(a.dataId);return!c.isPacked||lL(a.shape,u)||null!==c.texture&&lL(c.shape,u)?(s.incRef(a.dataId),{dataId:a.dataId,shape:u,dtype:a.dtype}):function(e,t,n){const r=[iL(e.shape),...sL(e.shape)],a={dtype:e.dtype,shape:r,dataId:e.dataId},i=[iL(t),...sL(t)],s=new U$(i,r),o=[r],u=n.runWebGLProgram(s,[a],e.dtype,o,!0);return{dataId:u.dataId,shape:t,dtype:u.dtype}}(a,u,s)}const SO={kernelName:pr,backendName:"webgl",kernelFunc:NO};class kO{constructor(e,t){this.variableNames=["x"];const{windowSize:n,batchSize:r,inSize:a,outSize:i}=e;this.outputShape=[r,i];const s=4*Math.floor(n/4),o=n%4;let u="sumValue += dot(values, ones);";if(null!=t){const e=1/t;u=`sumValue += dot(values * ${he(e)?e.toPrecision(2):e}, ones);`}let l="";a%n>0&&(l=`\n if (inIdx < 0 || inIdx >= ${a}) {\n return 0.0;\n }\n `),this.userCode=`\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n ${l}\n return getX(batch, inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * ${n};\n\n float sumValue = 0.0;\n\n for (int i = 0; i < ${s}; i += 4) {\n int inIdx = inOffset + i;\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n ${u}\n }\n\n int inIdx = inOffset + ${s};\n if (${1===o}) {\n vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0);\n\n ${u}\n } else if (${2===o}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1), 0.0, 0.0);\n\n ${u}\n } else if (${3===o}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2), 0.0);\n\n ${u}\n }\n setOutput(sumValue);\n }\n `}}class DO{constructor(e,t){this.variableNames=["x"];const{windowSize:n,batchSize:r,inSize:a,outSize:i}=e;this.outputShape=[r,i];let s="0.0",o="";"prod"===t?s="1.0":"min"===t?(s="1.0 / 1e-20",o="min"):"max"===t&&(s="-1.0 / 1e-20",o="max");let u=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"sum"===t?u="sumValue":"prod"===t?u="prodValue":"all"===t?u="allValue":"any"===t&&(u="anyValue");const l=4*Math.floor(n/4),c=n%4;let p=`\n if (${"sum"===t}) {\n sumValue += dot(values, ones);\n } else if (${"prod"===t}) {\n vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]);\n prodValue *= tmp[0] * tmp[1];\n } else {\n minMaxValue = ${o}(values, minMaxValue);\n if (${"min"===t} || ${"max"===t}) {\n minMaxValue = ${o}(values, minMaxValue);\n bvec4 isNaN = isnan(values);\n if (isNaN.r || isNaN.g || isNaN.b || isNaN.a) {\n minMaxValue = vec4(NAN);\n }\n }\n }\n `,d="vec4";"all"===t?(s="1.0",p="\n bool reducedAllValue = all(values);\n float floatedReducedAllValue = float(reducedAllValue);\n allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);\n ",d="bvec4"):"any"===t&&(s="0.0",p="\n bool reducedAnyValue = any(values);\n float floatedReducedAnyValue = float(reducedAnyValue);\n anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);\n ",d="bvec4");let h="";a%n>0&&(h=`\n if (inIdx < 0 || inIdx >= ${a}) {\n return initializationValue;\n }\n `),this.userCode=`\n const float initializationValue = ${s};\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n ${h}\n return getX(batch, inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * ${n};\n\n vec4 minMaxValue = vec4(${s});\n float prodValue = 1.0;\n float sumValue = 0.0;\n float allValue = 1.0;\n float anyValue = 0.0;\n\n for (int i = 0; i < ${l}; i += 4) {\n int inIdx = inOffset + i;\n ${d} values = ${d}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n ${p}\n }\n\n int inIdx = inOffset + ${l};\n if (${1===c}) {\n ${d} values = ${d}(\n getValue(batch, inIdx),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${p}\n } else if (${2===c}) {\n ${d} values = ${d}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n initializationValue,\n initializationValue\n );\n\n ${p}\n } else if (${3===c}) {\n ${d} values = ${d}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n initializationValue\n );\n\n ${p}\n }\n setOutput(${u});\n }\n `}}function TO(e,t,n,r){const a=function(e){const t=[];for(;0===t.length||1!==t[t.length-1].outSize;){const n=t.length?t[t.length-1].outSize:e[1],r=tf(n);t.push({inSize:n,windowSize:r,outSize:Math.ceil(n/r)})}return t}(e.shape);let i=e;for(let s=0;s6)throw Error(`Transpose for rank ${t} is not yet supported`);const n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],r=new Array(t);for(let t=0;t6)throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`);const r=AL(this.rank),a=P$("rc",this.rank),i=new Array(this.rank);for(let e=0;e`Error in matMul: inner shapes (${p}) and (${d}) of Tensors with shapes ${e.shape} and ${t.shape} and transposeA=${n} and transposeB=${r} must match.`));const v=n?[y,p,h]:[y,h,p],_=r?[b,f,d]:[b,d,f],w=NO({inputs:{x:e},backend:a,attrs:{shape:v}}),M=NO({inputs:{x:t},backend:a,attrs:{shape:_}}),N=[w,M],S=Math.max(y,b),k=n?w.shape[1]:w.shape[2],D=null!=i,T=null!=s,I="leakyrelu"===u,E=null!=u?bO(u,!0):null;let C;if((1===h||1===f)&&k>1e3&&!1===(D||T||I||null!=E)){let e=w,t=M;n&&(e=$O({inputs:{x:w},backend:a,attrs:{perm:[0,2,1]}}),N.push(e)),r&&(t=$O({inputs:{x:M},backend:a,attrs:{perm:[0,2,1]}}),N.push(t));const i=1===f;let s=e;1!==f&&(s=NO({inputs:{x:e},backend:a,attrs:{shape:[S,k,1]}}),N.push(s));const o=1===f?2:1;let u=t;i&&(u=NO({inputs:{x:t},backend:a,attrs:{shape:[S,1,k]}}),N.push(u));const l=wO({inputs:{a:s,b:u},backend:a});C=AO({inputs:{x:l},backend:a,attrs:{axis:o,keepDims:!0}}),N.push(l)}else{const u=ci(e.dtype,t.dtype),l=new xO(v,_,[S,h,f],n,r,D,E,T,I),c=[w,M];if(null!=i&&c.push(i),T&&c.push(s),I){const e=a.makeTensorInfo([],"float32",Fa(o,"float32"));c.push(e),N.push(e)}C=a.runWebGLProgram(l,c,u)}const A=NO({inputs:{x:C},backend:a,attrs:{shape:x}});N.push(C);for(const e of N)a.disposeIntermediateTensorInfo(e);return A}const FO={kernelName:oa,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{a,b:i,bias:s,preluActivationWeights:o}=t,{transposeA:u,transposeB:l,activation:c,leakyreluAlpha:p}=r;return RO({a,b:i,transposeA:u,transposeB:l,backend:n,bias:s,preluActivationWeights:o,leakyreluAlpha:p,activation:c})}},YO="return abs(x);",zO={kernelName:Qe,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r}=t;if(n.shouldExecuteOnCPU([r])&&"complex64"!==r.dtype){const e=n.texData.get(r.dataId),t=k$(e.values);return n.makeTensorInfo(r.shape,r.dtype,t)}let a;return a=Ge().getBool("WEBGL_PACK_UNARY_OPERATIONS")?new Z$(r.shape,YO):new K$(r.shape,YO),n.runWebGLProgram(a,[r],r.dtype)}},BO=gO({opSnippet:"if (isnan(x)) return x;\n if (abs(x) > 1.) {\n return NAN;\n }\n return acos(x);\n"}),PO={kernelName:et,backendName:"webgl",kernelFunc:BO},HO=gO({opSnippet:"if (isnan(x)) return x;\n if (x < 1.0) return NAN;\nreturn log(x + sqrt(x * x - 1.0));"}),jO={kernelName:tt,backendName:"webgl",kernelFunc:HO},UO="return a + b;",qO=yO({opSnippet:UO,packedOpSnippet:UO,supportsComplex:!0,cpuKernelImpl:ZL}),WO={kernelName:nt,backendName:"webgl",kernelFunc:qO};class VO{constructor(e,t){this.outputShape=[],this.outputShape=e,this.variableNames=t.map(((e,t)=>`T${t}`));const n=[];this.variableNames.forEach((e=>{n.push(`float v${e} = get${e}AtOutCoords();`)}));const r=this.variableNames.map((e=>`v${e}`)).join(" + ");this.userCode=`\n void main() {\n ${n.join("\n ")}\n\n float result = ${r};\n setOutput(result);\n }\n `}}class GO{constructor(e,t){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.variableNames=t.map(((e,t)=>`T${t}`));const n=[];this.variableNames.forEach((e=>{n.push(`vec4 v${e} = get${e}AtOutCoords();`)}));const r=this.variableNames.map((e=>`v${e}`)).join(" + ");this.userCode=`\n void main() {\n ${n.join("\n ")}\n\n vec4 result = ${r};\n setOutput(result);\n }\n `}}const KO={kernelName:rt,backendName:"webgl",kernelFunc:function e(t){const{inputs:n,backend:r}=t,a=n;if(1===a.length)return sO({inputs:{x:a[0]},backend:r});if(a.length>Ge().get("WEBGL_MAX_TEXTURES_IN_SHADER")){const t=Math.floor(a.length/2),n=e({inputs:a.slice(0,t),backend:r}),i=e({inputs:a.slice(t),backend:r});return e({inputs:[n,i],backend:r})}const i=a.map((e=>e.dtype)).reduce(((e,t)=>ci(e,t))),s=a.map((e=>e.shape)),o=Ge().getBool("WEBGL_PACK")?new GO(a[0].shape,s):new VO(a[0].shape,s);return r.runWebGLProgram(o,a,i)}},JO={kernelName:at,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,keepDims:s}=r,o=a.shape.length,u=ve(i,a.shape);let l=u;const c=xc(l,o);let p=a;null!=c&&(p=$O({inputs:{x:a},backend:n,attrs:{perm:c}}),l=_c(l.length,o)),bc("all",l,o);const[d,h]=gc(p.shape,l),f=NO({inputs:{x:p},backend:n,attrs:{shape:[-1,ce(h)]}}),m=TO(f,f.dtype,"all",n);let g;return g=NO(s?{inputs:{x:m},backend:n,attrs:{shape:yc(d,u)}}:{inputs:{x:m},backend:n,attrs:{shape:d}}),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),null!=c&&n.disposeIntermediateTensorInfo(p),g}},XO={kernelName:it,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,keepDims:s}=r,o=a.shape.length,u=ve(i,a.shape);let l=u;const c=xc(l,o);let p=a;null!=c&&(p=$O({inputs:{x:a},backend:n,attrs:{perm:c}}),l=_c(l.length,o)),bc("any",l,o);const[d,h]=gc(p.shape,l),f=NO({inputs:{x:p},backend:n,attrs:{shape:[-1,ce(h)]}}),m=TO(f,f.dtype,"any",n);let g;return g=NO(s?{inputs:{x:m},backend:n,attrs:{shape:yc(d,u)}}:{inputs:{x:m},backend:n,attrs:{shape:d}}),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),null!=c&&n.disposeIntermediateTensorInfo(p),g}};class ZO{constructor(e,t,n){this.variableNames=["A"];const{windowSize:r,batchSize:a,outSize:i}=e;n||this.variableNames.push("bestIndicesA"),this.outputShape=[a,i];const s="max"===t?">":"<",o=n?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));";this.userCode=`\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * ${r};\n\n int bestIndex = inOffset;\n float bestValue = getA(batch, bestIndex);\n\n for (int i = 0; i < ${r}; i++) {\n int inIdx = ${o};\n float candidate = getA(batch, inIdx);\n if (candidate ${s} bestValue) {\n bestValue = candidate;\n bestIndex = inIdx;\n }\n }\n setOutput(float(bestIndex));\n }\n `}}class QO{constructor(e,t,n,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,se(e.length>2,(()=>`Packed arg${n.charAt(0).toUpperCase()+n.slice(1)} supports only inputs with rank above 2.`));const a=e[e.length-1],i=Math.ceil(a/t);this.outputShape=e.slice(0,-1),i>1&&this.outputShape.push(i),r||this.variableNames.push("bestIndicesA");const s=this.outputShape,o=s.length,u=AL(o),l=H$("coords",o);let c,p;if(1===i){p=o+1;const e=AL(p);c=`\n ${e} sourceLocR = ${e}(${l.join()}, 0);\n ++${l[o-1]};\n ${e} sourceLocG = ${e}(${l.join()}, 0);\n ++${l[o-2]};\n ${e} sourceLocA = ${e}(${l.join()}, 0);\n --${l[o-1]};\n ${e} sourceLocB = ${e}(${l.join()}, 0);\n --${l[o-2]};`}else p=o,c=`\n ${u} sourceLocR = coords;\n ++${l[o-1]};\n ${u} sourceLocG = coords;\n ++${l[o-2]};\n ${u} sourceLocA = coords;\n --${l[o-1]};\n ${u} sourceLocB = coords;\n --${l[o-2]};`;const d=["x","y","z","w","u","v"].slice(0,p),h="."+d[p-1],f=d.map((e=>"int "+e)),m=H$("sourceLocR",p-1).concat("inIdx.r"),g=H$("sourceLocG",p-1).concat("inIdx.g"),y=H$("sourceLocB",p-1).concat("inIdx.b"),b=H$("sourceLocA",p-1).concat("inIdx.a"),x="max"===n?"greaterThan":"lessThan",v=r?"":`\n inIdx = round(vec4(getBestIndicesAChannel(${m.join()}),\n getBestIndicesAChannel(${g.join()}),\n getBestIndicesAChannel(${y.join()}),\n getBestIndicesAChannel(${b.join()})));`,_=`vec4(\n getAChannel(${m.join()}),\n hasNextCol ? getAChannel(${g.join()}) : 0.,\n hasNextRow ? getAChannel(${y.join()}) : 0.,\n hasNextRow && hasNextCol ? getAChannel(${b.join()}) : 0.)`,w=r?"":`\n float getBestIndicesAChannel(${f.join()}) {\n return getChannel(getBestIndicesA(${d.join()}),\n vec2(${d.slice(-2).join()}));\n }`;this.userCode=`\n float getAChannel(${f.join()}) {\n return getChannel(getA(${d.join()}),\n vec2(${d.slice(-2).join()}));\n }\n ${w}\n void main() {\n ${u} coords = getOutputCoords();\n bool hasNextCol = ${l[o-1]} < ${s[o-1]-1};\n bool hasNextRow = ${l[o-2]} < ${s[o-2]-1};\n ${c}\n ivec4 srcIdx = ivec4(sourceLocR${h}, sourceLocG${h},\n sourceLocB${h}, sourceLocA${h}) * ${t};\n ivec4 inIdx = srcIdx;\n vec4 bestIndex = vec4(inIdx);\n vec4 bestValue = ${_};\n\n for (int i = 0; i < ${t}; i++) {\n inIdx = srcIdx;\n ${v}\n vec4 candidate = ${_};\n bvec4 nan = isnan(candidate);\n bvec4 replace = bvec4(\n vec4(${x}(candidate, bestValue)) * (vec4(1.0) - vec4(nan)));\n\n bestValue = vec4(replace.x ? candidate.x : bestValue.x,\n replace.y ? candidate.y : bestValue.y,\n replace.z ? candidate.z : bestValue.z,\n replace.w ? candidate.w : bestValue.w);\n bestIndex = mix(bestIndex, vec4(inIdx), vec4(replace));\n srcIdx++;\n }\n setOutput(bestIndex);\n }\n `}}function eR(e,t,n,r=null){let a=t.shape[0],i=t.shape[1];null!=r&&(a=r.shape[0],i=r.shape[1]);const s=tf(i),o={windowSize:s,inSize:i,batchSize:a,outSize:Math.ceil(i/s)},u=new ZO(o,n,null==r),l=[t];null!=r&&l.push(r);const c=e.runWebGLProgram(u,l,"int32");if(1===c.shape[1])return c;const p=eR(e,t,n,c);return e.disposeIntermediateTensorInfo(c),p}function tR(e,t,n,r=null){const a=null!=r?r.shape:t.shape,i=tf(a[a.length-1]),s=new QO(a,i,n,null==r),o=null==r?[t]:[t,r],u=e.runWebGLProgram(s,o,"int32");if(u.shape.length===t.shape.length){const r=tR(e,t,n,u);return e.disposeIntermediateTensorInfo(u),r}return u}function nR(e,t,n,r){const a=[n];if(bc("arg"+r.charAt(0).toUpperCase()+r.slice(1),a,t.shape.length),!Ge().getBool("WEBGL_PACK_REDUCE")||t.shape.length<=2){const n=[],i=e.texData.get(t.dataId);let s=t;null!==i&&i.isPacked&&(s=e.unpackTensor(t),n.push(s));const[o,u]=gc(s.shape,a),l=ce(u),c=NO({inputs:{x:s},backend:e,attrs:{shape:[-1,l]}});n.push(c);const p=eR(e,c,r);n.push(p);const d=NO({inputs:{x:p},backend:e,attrs:{shape:o}});return n.forEach((t=>e.disposeIntermediateTensorInfo(t))),d}return tR(e,t,r)}const rR={kernelName:st,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i}=r;let s=ve(i,a.shape);const o=xc(s,a.shape.length);let u=a;const l=[];null!=o&&(u=$O({inputs:{x:a},backend:n,attrs:{perm:o}}),l.push(u),s=_c(s.length,u.shape.length)),bc("argMax",[s[0]],u.shape.length);const c=nR(n,u,s[0],"max");return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),c}},aR={kernelName:ot,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i}=r;let s=ve(i,a.shape);const o=xc(s,a.shape.length);let u=a;const l=[];null!=o&&(u=$O({inputs:{x:a},backend:n,attrs:{perm:o}}),l.push(u),s=_c(s.length,u.shape.length)),bc("argMin",[s[0]],u.shape.length);const c=nR(n,u,s[0],"min");return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),c}},iR=gO({opSnippet:"if (isnan(x)) return x;\n if (abs(x) > 1.) {\n return NAN;\n }\n return asin(x);\n"}),sR={kernelName:ut,backendName:"webgl",kernelFunc:iR},oR=gO({opSnippet:"if (isnan(x)) return x;return log(x + sqrt(x * x + 1.0));"}),uR={kernelName:lt,backendName:"webgl",kernelFunc:oR},lR=gO({opSnippet:"if (isnan(x)) return x;\n return atan(x);\n"}),cR={kernelName:ct,backendName:"webgl",kernelFunc:lR},pR=yO({opSnippet:"\n if (isnan(a)) return a;\n if (isnan(b)) return b;\n\n return atan(a, b);\n",packedOpSnippet:"\n vec4 result = atan(a, b);\n vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));\n \n result.r = isNaN.r > 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n"}),dR={kernelName:dt,backendName:"webgl",kernelFunc:pR},hR=gO({opSnippet:"if (isnan(x)) return x;\n if ((x < -1.0) || (x > 1.0)) return NAN;\nreturn (log(1.0 + x) - log(1.0 - x)) / 2.0;"}),fR={kernelName:pt,backendName:"webgl",kernelFunc:hR};class mR{constructor(e,t,n,r=!1,a=!1){if(this.variableNames=["x"],"avg"===t&&n)throw new Error("Cannot compute positions for average pool.");const i=e.filterWidth,s=e.strideHeight,o=e.strideWidth,u=e.dilationHeight,l=e.dilationWidth,c=e.effectiveFilterHeight,p=e.effectiveFilterWidth,d=e.padInfo.top,h=e.padInfo.left;this.outputShape=e.outShape;const f="avg"===t,m=`((batch * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + d`,g=`(xR * ${e.inWidth} + xC) * ${e.inChannels} + d`;let y="0.0";if(f||(y="-1.0 / 1e-20"),n){const t=">=";return void(this.userCode=`\n const ivec2 strides = ivec2(${s}, ${o});\n const ivec2 pads = ivec2(${d}, ${h});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d = coords[3];\n\n ivec2 xRCCorner = coords.yz * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // max/min x(?, ?, d) to get y(yR, yC, d).\n // ? = to be determined\n float minMaxValue = 0.0;\n float minMaxValueFound = 0.0;\n int minMaxPosition = 0;\n float avgValue = 0.0;\n\n for (int wR = 0; wR < ${c};\n wR += ${u}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${p};\n wC += ${l}) {\n int xC = xCCorner + wC;\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n float value = getX(batch, xR, xC, d);\n\n // If a min / max value has already been found, use it. If not,\n // use the current value.\n float currMinMaxValue = mix(\n value, minMaxValue, minMaxValueFound);\n if (value ${t} currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition = ${r?a?m:g:`wR * ${p} + wC`};\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n `)}let b=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"avg"===t&&(b="avgValue / count");const x=4*Math.floor(i/4),v=i%4,_=`\n if (${f}) {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n `;this.userCode=`\n const ivec2 strides = ivec2(${s}, ${o});\n const ivec2 pads = ivec2(${d}, ${h});\n const float initializationValue = ${y};\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float count = 0.0;\n\n float getValue(int batch, int xR, int xC, int d) {\n if (xC < 0 || xC >= ${e.inWidth}) {\n return initializationValue;\n }\n count += 1.0;\n return getX(batch, xR, xC, d);\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d = coords[3];\n\n ivec2 xRCCorner = coords.yz * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // max/min x(?, ?, d) to get y(yR, yC, d).\n // ? = to be determined\n vec4 minMaxValue = vec4(${y});\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wR = 0; wR < ${c};\n wR += ${u}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${x}; wC += 4) {\n int xC = xCCorner + wC * ${l};\n\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${l}, d),\n getValue(batch, xR, xC + 2 * ${l}, d),\n getValue(batch, xR, xC + 3 * ${l}, d)\n );\n\n ${_}\n }\n\n int xC = xCCorner + ${x};\n if (${1===v}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${_}\n } else if (${2===v}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${l}, d),\n initializationValue,\n initializationValue\n );\n\n ${_}\n } else if (${3===v}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${l}, d),\n getValue(batch, xR, xC + 2 * ${l}, d),\n initializationValue\n );\n\n ${_}\n }\n }\n setOutput(${b});\n }\n `}}class gR{constructor(e,t,n,r=!1,a=!1){if(this.variableNames=["x"],"avg"===t&&n)throw new Error("Cannot compute positions for average pool.");const i=e.filterWidth,s=e.strideDepth,o=e.strideHeight,u=e.strideWidth,l=e.dilationDepth,c=e.dilationHeight,p=e.dilationWidth,d=e.effectiveFilterDepth,h=e.effectiveFilterHeight,f=e.effectiveFilterWidth,m=e.padInfo.front,g=e.padInfo.top,y=e.padInfo.left;this.outputShape=e.outShape;const b="avg"===t;let x="0.0";if(b||(x="-1.0 / 1e-20"),n){const t=">=";return void(this.userCode=`\n const ivec3 strides =\n ivec3(${s}, ${o}, ${u});\n const ivec3 pads = ivec3(${m}, ${g}, ${y});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xDCorner = xCorner.x;\n int xRCorner = xCorner.y;\n int xCCorner = xCorner.z;\n\n // max/min x(?, ?, ?, ch) to get y(yD, yR, yC, ch).\n // ? = to be determined\n float minMaxValue = 0.0;\n float minMaxValueFound = 0.0;\n int minMaxPosition = 0;\n\n for (int wD = 0; wD < ${d};\n wD += ${l}) {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= ${e.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${h};\n wR += ${c}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${f};\n wC += ${p}) {\n int xC = xCCorner + wC;\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n float value = getX(batch, xD, xR, xC, ch);\n\n // If a min / max value has already been found, use it. If not,\n // use the current value.\n float currMinMaxValue = mix(\n value, minMaxValue, minMaxValueFound);\n if (value ${t} currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition = ${r?a?`(((batch * ${e.inDepth} + xD) * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`((xD * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`wD * ${h} * ${f} +\n wR * ${f} + wC`};\n }\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n `)}let v=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"avg"===t&&(v="avgValue / count");const _=4*Math.floor(i/4),w=i%4,M=`\n if (${b}) {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n `;this.userCode=`\n const ivec3 strides =\n ivec3(${s}, ${o}, ${u});\n const ivec3 pads = ivec3(${m}, ${g}, ${y});\n const float initializationValue = ${x};\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float count = 0.0;\n\n float getValue(int batch, int xD, int xR, int xC, int ch) {\n if (xC < 0 || xC >= ${e.inWidth}) {\n return initializationValue;\n }\n count += 1.0;\n return getX(batch, xD, xR, xC, ch);\n }\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xDCorner = xCorner.x;\n int xRCorner = xCorner.y;\n int xCCorner = xCorner.z;\n\n // max/min x(?, ?, ?, d) to get y(yD, yR, yC, ch).\n // ? = to be determined\n vec4 minMaxValue = vec4(${x});\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wD = 0; wD < ${d};\n wD += ${l}) {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= ${e.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${h};\n wR += ${c}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${_}; wC += 4) {\n int xC = xCCorner + wC * ${p};\n\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ${p}, ch),\n getValue(batch, xD, xR, xC + 2 * ${p}, ch),\n getValue(batch, xD, xR, xC + 3 * ${p}, ch)\n );\n\n ${M}\n }\n\n int xC = xCCorner + ${_};\n if (${1===w}) {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${M}\n } else if (${2===w}) {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ${p}, ch),\n initializationValue,\n initializationValue\n );\n\n ${M}\n } else if (${3===w}) {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ${p}, ch),\n getValue(batch, xD, xR, xC + 2 * ${p}, ch),\n initializationValue\n );\n\n ${M}\n }\n }\n setOutput(${v});\n }\n }\n `}}const yR={kernelName:ht,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t;mL(a,"avgPool");const{filterSize:i,strides:s,pad:o,dimRoundingMode:u}=r;se(vl(s,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${s} and dilations '1'`));const l=cl(a.shape,i,s,1,o,u);if(1===l.filterWidth&&1===l.filterHeight&&de(l.inShape,l.outShape))return sO({inputs:{x:a},backend:n});const c=new mR(l,"avg",!1);return n.runWebGLProgram(c,[a],"float32")}},bR={kernelName:mt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{filterSize:i,strides:s,pad:o,dimRoundingMode:u,dataFormat:l}=r,c=pl(a.shape,i,s,[1,1,1],o,u,l),p=new gR(c,"avg",!1);return n.runWebGLProgram(p,[a],"float32")}};class xR{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,a=e.strideWidth,i=e.dilationHeight,s=e.dilationWidth,o=e.effectiveFilterHeight,u=e.effectiveFilterWidth,l=o-1-e.padInfo.top,c=u-1-e.padInfo.left,p=1/(t*n);this.userCode=`\n const ivec2 pads = ivec2(${l}, ${c});\n const float avgMultiplier = float(${p});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n\n ivec2 dyRCCorner = coords.yz - pads;\n int dyRCorner = dyRCCorner.x;\n int dyCCorner = dyRCCorner.y;\n\n // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${o};\n wR += ${i}) {\n float dyR = float(dyRCorner + wR) / ${r}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${u};\n wC+= ${s}) {\n float dyC = float(dyCCorner + wC) / ${a}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(b, idyR, idyC, d);\n\n dotProd += dyValue * avgMultiplier;\n }\n }\n setOutput(dotProd);\n }\n `}}class vR{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const t=e.filterDepth,n=e.filterHeight,r=e.filterWidth,a=e.strideDepth,i=e.strideHeight,s=e.strideWidth,o=e.dilationDepth,u=e.dilationHeight,l=e.dilationWidth,c=e.effectiveFilterDepth,p=e.effectiveFilterHeight,d=e.effectiveFilterWidth,h=c-1-e.padInfo.front,f=p-1-e.padInfo.top,m=d-1-e.padInfo.left,g=1/(t*n*r);this.userCode=`\n const ivec3 pads = ivec3(${h}, ${f}, ${m});\n const float avgMultiplier = float(${g});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyDCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n // Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get\n // dx(xD, xR, xC, ch).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int wD = 0; wD < ${c};\n wD += ${o}) {\n float dyD = float(dyDCorner + wD) / ${a}.0;\n\n if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) {\n continue;\n }\n int idyD = int(dyD);\n\n for (int wR = 0; wR < ${p};\n wR += ${u}) {\n float dyR = float(dyRCorner + wR) / ${i}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${d};\n wC += ${l}) {\n float dyC = float(dyCCorner + wC) / ${s}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n\n dotProd += dyValue * avgMultiplier;\n }\n }\n }\n setOutput(dotProd);\n }\n `}}const _R={kernelName:gt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i}=t,s=i,{filterSize:o,strides:u,pad:l,dimRoundingMode:c}=r,p=pl(s.shape,o,u,[1,1,1],l,c),d=new vR(p);return n.runWebGLProgram(d,[a],s.dtype)}},wR={kernelName:ft,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i}=t,s=i;mL([a,i],"avgPoolGrad");const{filterSize:o,strides:u,pad:l}=r,c=cl(s.shape,o,u,1,l),p=new xR(c);return n.runWebGLProgram(p,[a],s.dtype)}},MR={kernelName:yt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{a,b:i}=t,{transposeA:s,transposeB:o}=r;return RO({a,b:i,transposeA:s,transposeB:o,backend:n})}};class NR{constructor(e,t,n,r,a,i){this.outputShape=[],this.variableNames=["x","mean","variance"],Lo(e,t),Lo(e,n);let s="0.0";null!=r&&(Lo(e,r),this.variableNames.push("offset"),s="getOffsetAtOutCoords()");let o="1.0";null!=a&&(Lo(e,a),this.variableNames.push("scale"),o="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=`\n void main() {\n float x = getXAtOutCoords();\n float mean = getMeanAtOutCoords();\n float variance = getVarianceAtOutCoords();\n float offset = ${s};\n float scale = ${o};\n float inv = scale * inversesqrt(variance + float(${i}));\n setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1)));\n }\n `}}class SR{constructor(e,t,n,r,a,i){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],Lo(e,t),Lo(e,n);let s="vec4(0.0)";null!=r&&(Lo(e,r),this.variableNames.push("offset"),s="getOffsetAtOutCoords()");let o="vec4(1.0)";null!=a&&(Lo(e,a),this.variableNames.push("scale"),o="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=`\n void main() {\n vec4 offset = ${s};\n vec4 scale = ${o};\n\n vec4 x = getXAtOutCoords();\n vec4 mean = getMeanAtOutCoords();\n vec4 variance = getVarianceAtOutCoords();\n\n vec4 inv = scale * inversesqrt(variance + vec4(${i}));\n\n setOutput((x - mean) * inv + offset);\n }\n `}}const kR={kernelName:ln,backendName:"webgl",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:r,mean:a,variance:i,offset:s,scale:o}=e;se(a.shape.length===i.shape.length,(()=>"Batch normalization gradient requires mean and variance to have equal ranks.")),se(null==s||a.shape.length===s.shape.length,(()=>"Batch normalization gradient requires mean and offset to have equal ranks.")),se(null==o||a.shape.length===o.shape.length,(()=>"Batch normalization gradient requires mean and scale to have equal ranks."));let{varianceEpsilon:u}=n;null==u&&(u=.001);const l=[r,a,i];let c=null;null!=s&&(c=s.shape,l.push(s));let p=null;null!=o&&(p=o.shape,l.push(o));const d=Ge().getBool("WEBGL_PACK_NORMALIZATION")?new SR(r.shape,a.shape,i.shape,c,p,u):new NR(r.shape,a.shape,i.shape,c,p,u);return t.runWebGLProgram(d,l,l[0].dtype)}};class DR{constructor(e){this.variableNames=["source"],this.outputShape=e,this.rank=e.length;const t=AL(this.rank);this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];const n=function(e){if(1===e)return"sourceLoc";if(e<=6)return TR.slice(0,e).map((e=>"sourceLoc."+e)).join(",");throw Error(`Slicing for rank ${e} is not yet supported`)}(this.rank);let r;const a=e.map(((e,t)=>`sourceLoc.${TR[t]} = start[${t}] + coords.${TR[t]};`));r=`\n ${t} sourceLoc;\n ${t} coords = getOutputCoords();\n ${a.join("\n")}\n `,this.userCode=`\n void main() {\n ${r}\n setOutput(getSource(${n}));\n }\n `}}const TR=["x","y","z","w","u","v"];class IR{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=AL(this.rank),n=H$("coords",this.rank),r=H$("sourceLoc",this.rank),a=1===this.rank?"sourceLoc":`vec2(${r.slice(-2).join()})`,i=`getChannel(getSource(${r.join()}), ${a})`,s=`\n result.x = ${i};\n if (++${n[this.rank-1]} < ${e[this.rank-1]}) {\n ++${r[this.rank-1]};\n result.y = ${i};\n --${r[this.rank-1]};\n }\n `,o=1===this.rank?"":`\n --${n[this.rank-1]};\n if (++${n[this.rank-2]} < ${e[this.rank-2]}) {\n ++${r[this.rank-2]};\n result.z = ${i};\n if (++${n[this.rank-1]} < ${e[this.rank-1]}) {\n ++${r[this.rank-1]};\n result.w = ${i};\n }\n }\n `,u=this.rank<=4?`sourceLoc = coords +\n ${t}(${e.map(((e,t)=>`start[${t}]`)).join()});`:e.map(((e,t)=>`${r[t]} = ${n[t]} + start[${t}];`)).join("\n");this.userCode=`\n void main() {\n ${t} coords = getOutputCoords();\n ${t} sourceLoc;\n ${u}\n vec4 result = vec4(0.);\n ${s}\n ${o}\n setOutput(result);\n }\n `}}function ER(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{begin:i,size:s}=r,[o,u]=au(a,i,s);if(Uo(a,o,u),0===ce(u))return n.makeTensorInfo(u,a.dtype,[]);if(n.shouldExecuteOnCPU([a])||"string"===a.dtype){const e=n.texData.get(a.dataId),t=D$(e.values,o,u,a.shape,a.dtype);return n.makeTensorInfo(u,a.dtype,t)}const{isPacked:l}=n.texData.get(a.dataId),c=nu(a.shape,o,u);if(l||!c){const e=Ge().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new IR(u):new DR(u),t=[o];return n.runWebGLProgram(e,[a],a.dtype,t)}return n.uploadToGPU(a.dataId),function(e,t,n,r){const a=r.texData.get(e.dataId),i=r.makeTensorInfo(n,e.dtype),s=r.texData.get(i.dataId);Object.assign(s,a),s.refCount=1,s.shape=n,s.dtype=e.dtype;let o=ru(t,Re(e.shape));a.slice&&(o+=a.slice.flatOffset),s.slice={flatOffset:o,origDataId:a.slice&&a.slice.origDataId||e.dataId};const u=r.dataRefCount.get(s.slice.origDataId)||1;return r.dataRefCount.set(s.slice.origDataId,u+1),i}(a,o,u,n)}const CR={kernelName:Nr,backendName:"webgl",kernelFunc:ER},AR={kernelName:bt,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockShape:i,crops:s}=r;se(a.shape.length<=4,(()=>"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet"));const o=i.reduce(((e,t)=>e*t)),u=rf(a.shape,i,o),l=af(u.length,i.length),c=sf(a.shape,i,o),p=of(s,i.length),d=uf(c,s,i.length),h=[],f=NO({inputs:{x:a},backend:n,attrs:{shape:u}}),m=$O({inputs:{x:f},backend:n,attrs:{perm:l}}),g=NO({inputs:{x:m},backend:n,attrs:{shape:c}}),y=ER({inputs:{x:g},backend:n,attrs:{begin:p,size:d}});return h.push(f),h.push(m),h.push(g),h.forEach((e=>n.disposeIntermediateTensorInfo(e))),y}},LR={kernelName:xt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,weights:i}=t,{size:s}=r,o=n.readSync(a.dataId),u=n.readSync(i.dataId),l=QL(o,u,i.dtype,i.shape,s);return n.makeTensorInfo([s],i.dtype,l)}},$R={kernelName:_t,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{s0:r,s1:a}=t,i=n.readSync(r.dataId),s=n.readSync(a.dataId),o=Lo(Array.from(i),Array.from(s));return n.makeTensorInfo([o.length],"int32",Int32Array.from(o))}},OR=yO({opSnippet:"return float(a != b);",cpuKernelImpl:v$,dtype:"bool"}),RR={kernelName:Kn,backendName:"webgl",kernelFunc:OR};function FR(e){const{inputs:t,backend:n}=e,{input:r}=t;return sO({inputs:{x:n.texData.get(r.dataId).complexTensorInfos.real},backend:n})}const YR={kernelName:ur,backendName:"webgl",kernelFunc:FR},zR={kernelName:wt,backendName:"webgl",kernelFunc:function e(t){const{inputs:n,backend:r,attrs:a}=t,{x:i}=n,{dtype:s}=a;if("complex64"===s){if("complex64"===i.dtype)return sO({inputs:{x:i},backend:r});const t=up(i.shape),n=e({inputs:{x:i},backend:r,attrs:{dtype:"float32"}}),a=uO({inputs:{real:n,imag:t},backend:r});return t.dispose(),r.disposeIntermediateTensorInfo(n),a}if("complex64"===i.dtype){const t=FR({inputs:{input:i},backend:r}),n=e({inputs:{x:t},backend:r,attrs:{dtype:s}});return r.disposeIntermediateTensorInfo(t),n}if(!ke(i.dtype,s)){const e=sO({inputs:{x:i},backend:r});return{dataId:e.dataId,shape:e.shape,dtype:s}}if("int32"===s)return function(e,t){const n=new K$(e.shape,"return float(int(x));"),r=t.runWebGLProgram(n,[e],"int32");return{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}(i,r);if("bool"===s){const e=r.makeTensorInfo([],"bool",we("bool",1)),t=OR({inputs:{a:i,b:e},backend:r});return r.disposeIntermediateTensorInfo(e),t}throw new Error(`Error in Cast: failed to cast ${i.dtype} to ${s}`)}},BR="return ceil(x);",PR=gO({opSnippet:BR,packedOpSnippet:BR,cpuKernelImpl:t$}),HR={kernelName:Mt,backendName:"webgl",kernelFunc:PR};class jR{constructor(e){this.variableNames=["A"],this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode="\n\n void main() {\n float value = getAAtOutCoords();\n if (isnan(value)) {\n setOutput(value);\n return;\n }\n\n setOutput(clamp(value, minVal, maxVal));\n }\n "}}class UR{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="\n void main() {\n vec4 value = getAAtOutCoords();\n\n if (any(isnan(value))) {\n setOutput(value);\n return;\n }\n\n setOutput(clamp(value, vec4(minVal), vec4(maxVal)));\n }\n "}}const qR={kernelName:Nt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{clipValueMin:i,clipValueMax:s}=r;let o;o=Ge().getBool("WEBGL_PACK_CLIP")?new UR(a.shape):new jR(a.shape);const u=[[i],[s]];return n.runWebGLProgram(o,[a],a.dtype,u)}};class WR{constructor(e){this.variableNames=["real","imag"],this.outputShape=e,this.userCode="\n void main() {\n float re = abs(getRealAtOutCoords());\n float im = abs(getImagAtOutCoords());\n float mx = max(re, im);\n\n // sadly the length function in glsl is not underflow-safe\n // (at least not on Intel GPUs). So the safe solution is\n // to ensure underflow-safety in all cases.\n setOutput(\n mx == 0.0 ? 0.0 : mx * length(vec2(1, min(re, im)/mx))\n );\n }\n "}}function VR(e,t){return{dataId:t.dataId,dtype:t.dtype,shape:e.shape}}const GR={kernelName:kt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r}=t,a=n.texData.get(r.dataId),i=new WR(r.shape),s=[VR(r,a.complexTensorInfos.real),VR(r,a.complexTensorInfos.imag)];return n.runWebGLProgram(i,s,s[0].dtype)}};class KR{constructor(e){this.outputShape=[],this.outputShape=Qh(e,1),this.variableNames=e.map(((e,t)=>`T${t}`));const t=new Array(e.length-1);t[0]=e[0][1];for(let n=1;n`T${t}`));const o=new Array(e.length-1);o[0]=e[0][t];for(let n=1;n= ${o[e-1]}) {\n return getChannel(\n getT${e}(${XR(s,u,t)}),\n vec2(${XR(l,u,t)}));\n }`}const d=o.length,h=o[o.length-1];p+=`\n return getChannel(\n getT${d}(${XR(s,u,h)}),\n vec2(${XR(l,u,h)}));`,this.userCode=`\n float getValue(${s.map((e=>"int "+e))}) {\n ${p}\n }\n\n void main() {\n ${a} coords = getOutputCoords();\n vec4 result = vec4(getValue(${i}), 0., 0., 0.);\n\n ${i[r-1]} = ${i[r-1]} + 1;\n if (${i[r-1]} < ${n[r-1]}) {\n result.g = getValue(${i});\n }\n\n ${i[r-2]} = ${i[r-2]} + 1;\n if (${i[r-2]} < ${n[r-2]}) {\n result.a = getValue(${i});\n }\n\n ${i[r-1]} = ${i[r-1]} - 1;\n if (${i[r-2]} < ${n[r-2]} &&\n ${i[r-1]} < ${n[r-1]}) {\n result.b = getValue(${i});\n }\n setOutput(result);\n }\n `}}function XR(e,t,n){const r=e.indexOf(t);return e.map(((e,t)=>t===r?`${e} - ${n}`:e)).join()}function ZR(e){const{inputs:t,backend:n}=e,{input:r}=t;return sO({inputs:{x:n.texData.get(r.dataId).complexTensorInfos.imag},backend:n})}const QR={kernelName:gn,backendName:"webgl",kernelFunc:ZR};function eF(e,t,n){const r=e[0].dtype;if("complex64"===r){const r=e.map((e=>FR({inputs:{input:e},backend:n}))),a=e.map((e=>ZR({inputs:{input:e},backend:n}))),i=eF(r,t,n),s=eF(a,t,n),o=uO({inputs:{real:i,imag:s},backend:n});return r.forEach((e=>n.disposeIntermediateTensorInfo(e))),a.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(s),o}let a=n.shouldExecuteOnCPU(e);if("string"===r&&(a=!0),a){const a=e.map((e=>{const r=ce(e.shape.slice(t));return NO({inputs:{x:e},backend:n,attrs:{shape:[-1,r]}})})),i=a.map((e=>({vals:n.readSync(e.dataId),shape:e.shape}))),s=Qh(a.map((e=>e.shape)),1),o=1===a[0].shape[0],u=n$(i,s,r,o),l=Qh(e.map((e=>e.shape)),t),c=n.makeTensorInfo(l,r,u);return a.forEach((e=>n.disposeIntermediateTensorInfo(e))),c}const i=Ge().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER");if(e.length>i){const r=[];for(let a=0;a1){const a=new JR(e.map((e=>e.shape)),t);return n.runWebGLProgram(a,e,r)}const{tensors2D:s,outShape:o}=function(e,t,n){const r=Qh(e.map((e=>e.shape)),t);return{tensors2D:e.map((e=>NO({inputs:{x:e},attrs:{shape:[-1,ce(e.shape.slice(t))]},backend:n}))),outShape:r}}(e,t,n),u=new KR(s.map((e=>e.shape))),l=n.runWebGLProgram(u,s,r);s.forEach((e=>n.disposeIntermediateTensorInfo(e)));const c=NO({inputs:{x:l},attrs:{shape:o},backend:n});return n.disposeIntermediateTensorInfo(l),c}function tF(e){const{inputs:t,backend:n,attrs:r}=e,{axis:a}=r,i=ve(a,t[0].shape)[0],s=Qh(t.map((e=>e.shape)),i);if(0===ce(s))return n.makeTensorInfo(s,t[0].dtype,[]);const o=t.filter((e=>ce(e.shape)>0));return 1===o.length?sO({inputs:{x:o[0]},backend:n}):(Zh(o.map((e=>e.shape)),i),eF(o,i,n))}const nF={kernelName:Dt,backendName:"webgl",kernelFunc:tF};class rF{constructor(e,t=!1,n=null,r=!1,a=!1){this.variableNames=["x","W"],this.outputShape=e.outShape;const i=e.padInfo.top,s=e.padInfo.left,o=e.strideHeight,u=e.strideWidth,l=e.dilationHeight,c=e.dilationWidth,p=e.filterHeight,d=e.filterWidth,h=4*Math.floor(e.inChannels/4),f=e.inChannels%4,m="channelsLast"===e.dataFormat,g=m?1:2,y=m?2:3,b=m?3:1;let x="",v="";n&&(x=r?`float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:a?`float activation(float a) {\n float b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`\n float activation(float x) {\n ${n}\n }\n `,v="result = activation(result);");const _=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${x}\n\n const ivec2 strides = ivec2(${o}, ${u});\n const ivec2 pads = ivec2(${i}, ${s});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d2 = coords[${b}];\n\n ivec2 xRCCorner =\n ivec2(coords[${g}], coords[${y}]) * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${p}; wR++) {\n int xR = xRCorner + wR * ${l};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${d}; wC++) {\n int xC = xCCorner + wC * ${c};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n for (int d1 = 0; d1 < ${h}; d1 += 4) {\n vec4 wValues = vec4(\n getW(wR, wC, d1, d2),\n getW(wR, wC, d1 + 1, d2),\n getW(wR, wC, d1 + 2, d2),\n getW(wR, wC, d1 + 3, d2)\n );\n\n if (${m}) {\n vec4 xValues = vec4(\n getX(batch, xR, xC, d1),\n getX(batch, xR, xC, d1 + 1),\n getX(batch, xR, xC, d1 + 2),\n getX(batch, xR, xC, d1 + 3)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec4 xValues = vec4(\n getX(batch, d1, xR, xC),\n getX(batch, d1 + 1, xR, xC),\n getX(batch, d1 + 2, xR, xC),\n getX(batch, d1 + 3, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n\n if (${1===f}) {\n\n if (${m}) {\n dotProd +=\n getX(batch, xR, xC, ${h}) *\n getW(wR, wC, ${h}, d2);\n } else {\n dotProd +=\n getX(batch, ${h}, xR, xC) *\n getW(wR, wC, ${h}, d2);\n }\n\n } else if (${2===f}) {\n vec2 wValues = vec2(\n getW(wR, wC, ${h}, d2),\n getW(wR, wC, ${h} + 1, d2)\n );\n\n if (${m}) {\n vec2 xValues = vec2(\n getX(batch, xR, xC, ${h}),\n getX(batch, xR, xC, ${h} + 1)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec2 xValues = vec2(\n getX(batch, ${h}, xR, xC),\n getX(batch, ${h} + 1, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n } else if (${3===f}) {\n vec3 wValues = vec3(\n getW(wR, wC, ${h}, d2),\n getW(wR, wC, ${h} + 1, d2),\n getW(wR, wC, ${h} + 2, d2)\n );\n\n if (${m}) {\n vec3 xValues = vec3(\n getX(batch, xR, xC, ${h}),\n getX(batch, xR, xC, ${h} + 1),\n getX(batch, xR, xC, ${h} + 2)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec3 xValues = vec3(\n getX(batch, ${h}, xR, xC),\n getX(batch, ${h} + 1, xR, xC),\n getX(batch, ${h} + 2, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n }\n }\n }\n\n float result = dotProd;\n ${_}\n ${v}\n setOutput(result);\n }\n `}}class aF{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const t=e.padInfo.front,n=e.padInfo.top,r=e.padInfo.left,a=e.strideDepth,i=e.strideHeight,s=e.strideWidth,o=e.dilationDepth,u=e.dilationHeight,l=e.dilationWidth,c=e.filterDepth,p=e.filterHeight,d=e.filterWidth,h=4*Math.floor(e.inChannels/4),f=e.inChannels%4;this.userCode=`\n const ivec3 strides = ivec3(${a}, ${i}, ${s});\n const ivec3 pads = ivec3(${t}, ${n}, ${r});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int d2 = coords.u;\n\n ivec3 xFRCCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xFCorner = xFRCCorner.x;\n int xRCorner = xFRCCorner.y;\n int xCCorner = xFRCCorner.z;\n\n // Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get\n // y(yF, yR, yC, d2). ? = to be determined. : = across all\n // values in that axis.\n float dotProd = 0.0;\n for (int wF = 0; wF < ${c}; wF++) {\n int xF = xFCorner + wF * ${o};\n\n if (xF < 0 || xF >= ${e.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${p}; wR++) {\n int xR = xRCorner + wR * ${u};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${d}; wC++) {\n int xC = xCCorner + wC * ${l};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n for (int d1 = 0; d1 < ${h}; d1 += 4) {\n vec4 xValues = vec4(\n getX(batch, xF, xR, xC, d1),\n getX(batch, xF, xR, xC, d1 + 1),\n getX(batch, xF, xR, xC, d1 + 2),\n getX(batch, xF, xR, xC, d1 + 3)\n );\n vec4 wValues = vec4(\n getW(wF, wR, wC, d1, d2),\n getW(wF, wR, wC, d1 + 1, d2),\n getW(wF, wR, wC, d1 + 2, d2),\n getW(wF, wR, wC, d1 + 3, d2)\n );\n\n dotProd += dot(xValues, wValues);\n }\n\n if (${1===f}) {\n dotProd +=\n getX(batch, xF, xR, xC, ${h}) *\n getW(wF, wR, wC, ${h}, d2);\n } else if (${2===f}) {\n vec2 xValues = vec2(\n getX(batch, xF, xR, xC, ${h}),\n getX(batch, xF, xR, xC, ${h} + 1)\n );\n vec2 wValues = vec2(\n getW(wF, wR, wC, ${h}, d2),\n getW(wF, wR, wC, ${h} + 1, d2)\n );\n dotProd += dot(xValues, wValues);\n } else if (${3===f}) {\n vec3 xValues = vec3(\n getX(batch, xF, xR, xC, ${h}),\n getX(batch, xF, xR, xC, ${h} + 1),\n getX(batch, xF, xR, xC, ${h} + 2)\n );\n vec3 wValues = vec3(\n getW(wF, wR, wC, ${h}, d2),\n getW(wF, wR, wC, ${h} + 1, d2),\n getW(wF, wR, wC, ${h} + 2, d2)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n }\n }\n setOutput(dotProd);\n }\n `}}class iF{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=YL(this.outputShape.length);const{dataFormat:n}=t,r=yL(),a="channelsLast"===n,i=a?1:2,s=a?2:3,o=this.enableShapeUniforms?"if(blockIndex < outShape[2] && pos < outShape[1]) {":`if(blockIndex < ${e[2]} && pos < ${e[1]}) {`;let u="";for(let e=0;e<=1;e++)for(let t=0;t<=1;t++)u+=`\n blockIndex = rc.z + ${t};\n pos = rc.y + ${e};\n\n ${o}\n offsetY = int(blockIndex / outWidth) * stride[0] - pad[0];\n d0 = offsetY + dilation[0] * (pos / itemsPerBlockRow);\n\n if(d0 < inputShape[${i}] && d0 >= 0) {\n // Use custom imod instead mod. On Intel GPU, mod may generate\n // unexpected value.\n // https://github.com/tensorflow/tfjs/issues/5447\n offsetX = imod(blockIndex, outWidth) * stride[1] - pad[1];\n d1 = offsetX + dilation[1] * (imod(pos, itemsPerBlockRow) /\n inChannels);\n\n if(d1 < inputShape[${s}] && d1 >= 0) {\n\n ch = imod(pos, inChannels);\n\n if (${a}) {\n innerDims = vec2(d1, ch);\n result[${2*e+t}] = getChannel(\n getA(rc.x, d0, int(innerDims.x),\n int(innerDims.y)), innerDims);\n } else {\n innerDims = vec2(d0, d1);\n result[${2*e+t}] = getChannel(\n getA(rc.x, ch, int(innerDims.x),\n int(innerDims.y)), innerDims);\n }\n }\n }\n }\n `;this.userCode=`\n void main() {\n ivec3 rc = getOutputCoords();\n\n vec4 result = vec4(0);\n\n int blockIndex, pos, offsetY, d0, offsetX, d1, ch;\n vec2 innerDims;\n\n ${u}\n\n ${r.output} = result;\n }\n `}}function sF(e,t){const n=e.length;return n>=3?t?[...e.slice(0,-3),e[n-3]*e[n-2],e[n-1]]:[...e.slice(0,-3),e[n-3],e[n-2]*e[n-1]]:!t&&1===n&&e[0]>1?[e[0],1]:null}function oF({x:e,filter:t,convInfo:n,backend:r,bias:a=null,preluActivationWeights:i=null,leakyreluAlpha:s=0,activation:o=null}){const u=e.shape,l=r.texData.get(e.dataId),c=n.inChannels,p=u[0]*u[1]*u[2],d=n.outChannels,h="channelsLast"===n.dataFormat;let f;const m=[];if(null!=i){const e=sF(i.shape,h);null!=e&&(i=NO({inputs:{x:i},backend:r,attrs:{shape:e}}),m.push(i))}if(null!=a){const e=sF(a.shape,h);null!=e&&(a=NO({inputs:{x:a},backend:r,attrs:{shape:e}}),m.push(a))}if((1!==p&&1!==d||!(c>1e3))&&l.isPacked&&h&&null!=l.texture&&u[2]%2!=0&&de(l.shape.slice(-3),u.slice(-3))){const c=u[0]*u[1]*(u[2]+1),p={dataId:e.dataId,shape:[1,c,n.inChannels],dtype:e.dtype},d=l.shape;l.shape=l.shape.slice(),l.shape[l.shape.length-2]++,se(lL(l.shape,p.shape),(()=>`packed reshape ${l.shape} to ${p.shape} isn't free`));const h=NO({inputs:{x:t},backend:r,attrs:{shape:[1,n.inChannels,n.outChannels]}});m.push(h);const g=RO({a:p,b:h,backend:r,transposeA:!1,transposeB:!1,bias:a,activation:o,preluActivationWeights:i,leakyreluAlpha:s}),y=r.texData.get(g.dataId);se(y.isPacked,(()=>"batchMatMul result is expected to be packed")),l.shape=d,y.shape=n.outShape,f=sO({inputs:{x:g},backend:r}),f.shape=n.outShape,m.push(g)}else{const u=n.outHeight*n.outWidth,l=NO({inputs:{x:e},backend:r,attrs:{shape:h?[n.batchSize,u,n.inChannels]:[n.batchSize,n.inChannels,u]}}),c=NO({inputs:{x:t},backend:r,attrs:{shape:[1,n.inChannels,n.outChannels]}}),p=RO({a:h?l:c,b:h?c:l,transposeA:!h,transposeB:!1,backend:r,bias:a,activation:o,preluActivationWeights:i,leakyreluAlpha:s});f=NO({inputs:{x:p},backend:r,attrs:{shape:n.outShape}}),m.push(l),m.push(c),m.push(p)}for(const e of m)r.disposeIntermediateTensorInfo(e);return f}function uF({x:e,filter:t,convInfo:n,backend:r,bias:a=null,preluActivationWeights:i=null,leakyreluAlpha:s=0,activation:o=null}){const{filterWidth:u,filterHeight:l,inChannels:c,outWidth:p,outHeight:d,dataFormat:h}=n,f="channelsLast"===h,m=u*l*c,g=d*p,y=[n.batchSize,m,g],b=[];if(null!=i){const e=sF(i.shape,f);null!=e&&(i=NO({inputs:{x:i},backend:r,attrs:{shape:e}}),b.push(i))}if(null!=a){const e=sF(a.shape,f);null!=e&&(a=NO({inputs:{x:a},backend:r,attrs:{shape:e}}),b.push(a))}const x=NO({inputs:{x:t},backend:r,attrs:{shape:[1,m,ce(t.shape)/m]}});b.push(x);const v=new iF(y,n),_=[e.shape,[n.padInfo.top,n.padInfo.left],[n.strideHeight,n.strideWidth],[n.dilationHeight,n.dilationWidth],[n.inChannels],[n.filterWidth*n.inChannels],[n.outWidth]],w=r.runWebGLProgram(v,[e],"float32",_),M=NO({inputs:{x:w},backend:r,attrs:{shape:y}});b.push(w),b.push(M);const N=null!=a,S=null!=i,k="leakyrelu"===o,D=o?bO(o,!0):null,T=new xO(f?M.shape:x.shape,f?x.shape:M.shape,f?[n.batchSize,g,n.outChannels]:[n.batchSize,n.outChannels,g],!0,!1,N,D,S,k),I=f?[M,x]:[x,M];if(a&&I.push(a),S&&I.push(i),k){const e=r.makeTensorInfo([],"float32",Fa(s,"float32"));I.push(e),b.push(e)}const E=r.runWebGLProgram(T,I,"float32"),C=NO({inputs:{x:E},backend:r,attrs:{shape:n.outShape}});b.push(E);for(const e of b)r.disposeIntermediateTensorInfo(e);return C}const lF={kernelName:Tt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i}=t,{strides:s,pad:o,dataFormat:u,dilations:l,dimRoundingMode:c}=r,p=_l(u),d=dl(a.shape,i.shape,s,l,o,c,!1,p);let h;if(1!==d.filterHeight||1!==d.filterWidth||1!==d.dilationHeight||1!==d.dilationWidth||1!==d.strideHeight||1!==d.strideWidth||"SAME"!==d.padInfo.type&&"VALID"!==d.padInfo.type)if(Ge().getBool("WEBGL_CONV_IM2COL"))h=uF({x:a,filter:i,convInfo:d,backend:n});else{const e=new rF(d);h=n.runWebGLProgram(e,[a,i],"float32")}else h=oF({x:a,filter:i,convInfo:d,backend:n});const f=NO({inputs:{x:h},backend:n,attrs:{shape:d.outShape}});return n.disposeIntermediateTensorInfo(h),f}};class cF{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideHeight,n=e.strideWidth,r=e.padInfo.top,a=e.padInfo.left,i="channelsLast"===e.dataFormat;this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int wR = coords.x;\n int wC = coords.y;\n int d1 = coords.z;\n int d2 = coords.w;\n\n // Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int b = 0; b < ${e.batchSize}; b++) {\n for (int yR = 0; yR < ${e.outHeight}; yR++) {\n int xR = wR + yR * ${t} - ${r};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int yC = 0; yC < ${e.outWidth}; yC++) {\n int xC = wC + yC * ${n} - ${a};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n if (${i}) {\n float dyValue = getDy(b, yR, yC, d2);\n float xValue = getX(b, xR, xC, d1);\n dotProd += (xValue * dyValue);\n } else {\n float dyValue = getDy(b, d2, yR, yC);\n float xValue = getX(b, d1, xR, xC);\n dotProd += (xValue * dyValue);\n }\n\n }\n }\n }\n setOutput(dotProd);\n }\n `}}class pF{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,a=e.strideWidth,i="channelsLast"===e.dataFormat,s=t-1-e.padInfo.top,o=n-1-e.padInfo.left,u=i?1:2,l=i?2:3,c=i?3:1;this.userCode=`\n const ivec2 pads = ivec2(${s}, ${o});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords[${c}];\n\n ivec2 dyCorner = ivec2(coords[${u}], coords[${l}]) - pads;\n int dyRCorner = dyCorner.x;\n int dyCCorner = dyCorner.y;\n\n // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${t}; wR++) {\n float dyR = float(dyRCorner + wR) / ${r}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = ${t} - 1 - wR;\n\n for (int wC = 0; wC < ${n}; wC++) {\n float dyC = float(dyCCorner + wC) / ${a}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = ${n} - 1 - wC;\n\n for (int d2 = 0; d2 < ${e.outChannels}; d2++) {\n\n if (${i}) {\n float xValue = getDy(batch, idyR, idyC, d2);\n float wValue = getW(wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n } else {\n float xValue = getDy(batch, d2, idyR, idyC);\n float wValue = getW(wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n }\n\n }\n }\n }\n setOutput(dotProd);\n }\n `}}class dF{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideDepth,n=e.strideHeight,r=e.strideWidth,a=e.padInfo.front,i=e.padInfo.top,s=e.padInfo.left;this.userCode=`\n void main() {\n ivec5 coords = getOutputCoords();\n int wF = coords.x;\n int wR = coords.y;\n int wC = coords.z;\n int d1 = coords.w;\n int d2 = coords.u;\n\n float dotProd = 0.0;\n\n for (int b = 0; b < ${e.batchSize}; b++) {\n for (int yF = 0; yF < ${e.outDepth}; yF++) {\n int xF = wF + yF * ${t} - ${a};\n\n if (xF < 0 || xF >= ${e.inDepth}) {\n continue;\n }\n\n for (int yR = 0; yR < ${e.outHeight}; yR++) {\n int xR = wR + yR * ${n} - ${i};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int yC = 0; yC < ${e.outWidth}; yC++) {\n int xC = wC + yC * ${r} - ${s};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n float dyValue = getDy(b, yF, yR, yC, d2);\n float xValue = getX(b, xF, xR, xC, d1);\n dotProd += (xValue * dyValue);\n }\n }\n }\n }\n setOutput(dotProd);\n }\n `}}class hF{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterDepth,n=e.filterHeight,r=e.filterWidth,a=e.strideDepth,i=e.strideHeight,s=e.strideWidth,o=t-1-e.padInfo.front,u=n-1-e.padInfo.top,l=r-1-e.padInfo.left;this.userCode=`\n const ivec3 pads = ivec3(${o}, ${u}, ${l});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int d1 = coords.u;\n\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyFCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n float dotProd = 0.0;\n for (int wF = 0; wF < ${t}; wF++) {\n float dyF = float(dyFCorner + wF) / ${a}.0;\n\n if (dyF < 0.0 || dyF >= ${e.outDepth}.0 || fract(dyF) > 0.0) {\n continue;\n }\n int idyF = int(dyF);\n\n int wFPerm = ${t} - 1 - wF;\n\n for (int wR = 0; wR < ${n}; wR++) {\n float dyR = float(dyRCorner + wR) / ${i}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = ${n} - 1 - wR;\n\n for (int wC = 0; wC < ${r}; wC++) {\n float dyC = float(dyCCorner + wC) / ${s}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = ${r} - 1 - wC;\n\n for (int d2 = 0; d2 < ${e.outChannels}; d2++) {\n float xValue = getDy(batch, idyF, idyR, idyC, d2);\n float wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n }\n }\n }\n }\n setOutput(dotProd);\n }\n `}}const fF={kernelName:It,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,dy:i}=t,{strides:s,pad:o,dataFormat:u,dimRoundingMode:l,filterShape:c}=r,p=_l(u),d=dl(a.shape,c,s,1,o,l,!1,p),h=new cF(d);return n.runWebGLProgram(h,[a,i],"float32")}},mF={kernelName:Et,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,filter:i}=t,{inputShape:s,strides:o,pad:u,dataFormat:l,dimRoundingMode:c}=r,p=_l(l),d=dl(s,i.shape,o,1,u,c,!1,p),h=new pF(d);return n.runWebGLProgram(h,[a,i],"float32")}},gF={kernelName:Ct,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i}=t,{strides:s,pad:o,dilations:u}=r,l=hl(a.shape,i.shape,s,u,o),c=new aF(l);return n.runWebGLProgram(c,[a,i],"float32")}},yF={kernelName:At,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,dy:i}=t,{strides:s,pad:o,filterShape:u}=r,l=hl(a.shape,u,s,1,o),c=new dF(l);return n.runWebGLProgram(c,[a,i],"float32")}},bF={kernelName:Lt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,filter:i}=t,{pad:s,strides:o,inputShape:u}=r,l=hl(u,i.shape,o,1,s),c=new hF(l);return n.runWebGLProgram(c,[a,i],"float32")}},xF=gO({opSnippet:"if (isnan(x)) return x;\n return cos(x);\n"}),vF={kernelName:$t,backendName:"webgl",kernelFunc:xF},_F=gO({opSnippet:"\n float e2x = exp(-x);\n return (e2x + 1.0 / e2x) / 2.0;\n"}),wF={kernelName:Ot,backendName:"webgl",kernelFunc:_F};class MF{constructor(e,t,n,r,a){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];const[i,s,o,u]=e,[l]=t,[c,p]=n;this.outputShape=[l,c,p,u];const d="bilinear"===r?1:0,[h,f]=[s-1+".0",o-1+".0"],[m,g,y]=c>1?[""+(s-1)/(c-1),"(y2-y1) * height_ratio",`y1*${h} + float(y)*(height_scale)`]:["0.0","0.0",`0.5 * (y1+y2) * ${h}`],[b,x,v]=p>1?[""+(o-1)/(p-1),"(x2-x1) * width_ratio",`x1*${f} + float(x)*(width_scale)`]:["0.0","0.0",`0.5 * (x1+x2) * ${f}`];this.userCode=`\n const float height_ratio = float(${m});\n const float width_ratio = float(${b});\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int y = coords[1];\n int x = coords[2];\n int d = coords[3];\n\n // get box vals\n float y1 = getBoxes(b,0);\n float x1 = getBoxes(b,1);\n float y2 = getBoxes(b,2);\n float x2 = getBoxes(b,3);\n\n // get image in batch index\n int bInd = round(getBoxInd(b));\n if(bInd < 0 || bInd >= ${i}) {\n return;\n }\n\n float height_scale = ${g};\n float width_scale = ${x};\n\n float in_y = ${y};\n if( in_y < 0.0 || in_y > ${h} ) {\n setOutput(float(${a}));\n return;\n }\n float in_x = ${v};\n if( in_x < 0.0 || in_x > ${f} ) {\n setOutput(float(${a}));\n return;\n }\n\n vec2 sourceFracIndexCR = vec2(in_x,in_y);\n if(${d} == 1) {\n // Compute the four integer indices.\n ivec2 sourceFloorCR = ivec2(sourceFracIndexCR);\n ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR));\n\n float topLeft = getImage(b, sourceFloorCR.y, sourceFloorCR.x, d);\n float bottomLeft = getImage(b, sourceCeilCR.y, sourceFloorCR.x, d);\n float topRight = getImage(b, sourceFloorCR.y, sourceCeilCR.x, d);\n float bottomRight = getImage(b, sourceCeilCR.y, sourceCeilCR.x, d);\n\n vec2 fracCR = sourceFracIndexCR - vec2(sourceFloorCR);\n\n float top = topLeft + (topRight - topLeft) * fracCR.x;\n float bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x;\n float newValue = top + (bottom - top) * fracCR.y;\n setOutput(newValue);\n } else {\n // Compute the coordinators of nearest neighbor point.\n ivec2 sourceNearestCR = ivec2(floor(\n sourceFracIndexCR + vec2(0.5,0.5)));\n float newValue = getImage(b, sourceNearestCR.y, sourceNearestCR.x, d);\n setOutput(newValue);\n }\n }\n `}}const NF={kernelName:Yt,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{image:a,boxes:i,boxInd:s}=t,{cropSize:o,method:u,extrapolationValue:l}=r,c=new MF(a.shape,i.shape,o,u,l);return n.runWebGLProgram(c,[a,i,s],"float32")}};var SF;!function(e){e.Prod="*",e.Sum="+"}(SF||(SF={}));class kF{constructor(e,t,n,r){this.op=e,this.outputShape=t,this.variableNames=["x"],this.customUniforms=[{name:"index",type:"float"}];const a=this.outputShape.length,i=this.op===SF.Prod?"1.0":"0.0",s=n?i:`getX(${DF(a,"coords",this.op)})`,o=this.outputShape[this.outputShape.length-1];let u="",l="";n?(u=r?"end != "+(o-1):"end != 0",l=r?"end + 1":"end - 1"):(u=r?`end + pow2 < ${o}`:"end >= pow2",l=r?"end + pow2":"end - pow2"),this.userCode=`\n void main() {\n ${AL(a)} coords = getOutputCoords();\n int end = ${TF(a,"coords",this.op)};\n float val = ${s};\n int pow2 = int(pow(2.0, index));\n if (${u}) {\n int idx = ${l};\n ${TF(a,"coords",this.op)} = idx;\n val ${this.op}= getX(${DF(a,"coords",this.op)});\n }\n setOutput(val);\n }\n `}}function DF(e,t,n){if(1===e)return`${t}`;if(2===e)return`${t}.x, ${t}.y`;if(3===e)return`${t}.x, ${t}.y, ${t}.z`;if(4===e)return`${t}.x, ${t}.y, ${t}.z, ${t}.w`;throw new Error(`Cumulative ${n} for rank ${e} is not yet supported`)}function TF(e,t,n){if(1===e)return`${t}`;if(2===e)return`${t}.y`;if(3===e)return`${t}.z`;if(4===e)return`${t}.w`;throw new Error(`Cumulative ${n} for rank ${e} is not yet supported`)}function IF(e,t,n,r,a,i){const s=t.shape.length,o=xc([r],s);let u=t;null!=o&&(u=$O({inputs:{x:t},backend:n,attrs:{perm:o}}));const l=_c(1,s)[0];if(l!==s-1)throw new Error(`WebGL cumprod shader expects an inner-most axis=${t.shape.length-1} but got axis=${r}`);const c=u.shape[l];let p=sO({inputs:{x:u},backend:n});for(let t=0;t<=Math.ceil(Math.log2(c))-1;t++){const r=new kF(e,u.shape,!1,i),a=[[t]],s=p;p=n.runWebGLProgram(r,[p],p.dtype,a),n.disposeIntermediateTensorInfo(s)}if(a){const t=new kF(e,u.shape,a,i),r=p;p=n.runWebGLProgram(t,[p],p.dtype),n.disposeIntermediateTensorInfo(r)}if(null!=o){const e=$O({inputs:{x:p},backend:n,attrs:{perm:vc(o)}});return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(u),e}return p}const EF={kernelName:Rt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,exclusive:s,reverse:o}=r;return IF(SF.Prod,a,n,i,s,o)}},CF={kernelName:Ft,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,exclusive:s,reverse:o}=r;return IF(SF.Sum,a,n,i,s,o)}},AF={kernelName:zt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,weights:i}=t,{size:s,binaryOutput:o}=r;if(1===a.shape.length){const e=n.readSync(a.dataId),t=n.readSync(i.dataId),r=QL(e,t,i.dtype,i.shape,s);return n.makeTensorInfo([s],i.dtype,r)}if(2===a.shape.length){const e=n.bufferSync(a),t=n.bufferSync(i),r=e$(e,t,s,o);return n.makeTensorInfo(r.shape,i.dtype,r.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${a.shape.length}.`)}};class LF{constructor(e,t,n){this.variableNames=["x"],this.outputShape=[],this.outputShape=e,this.blockSize=t,this.dataFormat=n,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int h = ${this.getHeightCoordString()};\n int w = ${this.getWidthCoordString()};\n int d = ${this.getDepthCoordString()};\n\n int in_h = h / ${t};\n int offset_h = imod(h, ${t});\n int in_w = w / ${t};\n int offset_w = imod(w, ${t});\n int offset_d = (offset_h * ${t} + offset_w) *\n ${this.getOutputDepthSize()};\n int in_d = d + offset_d;\n\n float result = ${this.getInputSamplingString()};\n setOutput(result);\n }\n `}getHeightCoordString(){return"NHWC"===this.dataFormat?"coords[1]":"coords[2]"}getWidthCoordString(){return"NHWC"===this.dataFormat?"coords[2]":"coords[3]"}getDepthCoordString(){return"NHWC"===this.dataFormat?"coords[3]":"coords[1]"}getOutputDepthSize(){return"NHWC"===this.dataFormat?this.outputShape[3]:this.outputShape[1]}getInputSamplingString(){return"NHWC"===this.dataFormat?"getX(b, in_h, in_w, in_d)":"getX(b, in_d, in_h, in_w)"}}const $F={kernelName:Bt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockSize:i,dataFormat:s}=r,o=a.shape[0],u=("NHWC"===s?a.shape[1]:a.shape[2])*i,l=("NHWC"===s?a.shape[2]:a.shape[3])*i,c=("NHWC"===s?a.shape[3]:a.shape[1])/(i*i),p=new LF("NHWC"===s?[o,u,l,c]:[o,c,u,l],i,s);return n.runWebGLProgram(p,[a],a.dtype)}};class OF{constructor(e,t=!1,n=null,r=!1,a=!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=YL(this.outputShape.length);const i=e.filterHeight,s=e.filterWidth,o=e.outChannels/e.inChannels;let u="",l="";n&&(u=r?`float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:a?`float activation(float a) {\n float b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`\n float activation(float x) {\n ${n}\n }\n `,l="result = activation(result);");const c=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${u}\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int d1 = d2 / ${o};\n int q = d2 - d1 * ${o};\n\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // Convolve x(?, ?, d1) with w(:, :, d1, q) to get y(yR, yC, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n // TO DO(dsmilkov): Flatten the two for loops and vec4 the operations.\n for (int wR = 0; wR < ${i}; wR++) {\n int xR = xRCorner + wR * dilations[0];\n\n if (xR < 0 || xR >= inDims[0]) {\n continue;\n }\n\n for (int wC = 0; wC < ${s}; wC++) {\n int xC = xCCorner + wC * dilations[1];\n\n if (xC < 0 || xC >= inDims[1]) {\n continue;\n }\n\n float xVal = getX(batch, xR, xC, d1);\n float wVal = getW(wR, wC, d1, q);\n dotProd += xVal * wVal;\n }\n }\n\n float result = dotProd;\n ${c}\n ${l}\n setOutput(result);\n }\n `}}class RF{constructor(e,t=!1,n=null,r=!1,a=!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=YL(this.outputShape.length);const i=e.outChannels/e.inChannels,s=e.padInfo.left,o=e.strideWidth,u=e.dilationWidth,l=e.filterHeight,c=e.filterWidth,p=c;let d="\n int xR; int xC; int xCOffset;\n vec4 wTexel; vec4 previous; vec4 final;";for(let e=0;e=0 && xR < inDims[0]) {\n ";for(let e=0;e<(p+1)/2;e++){const t=2*e;if(d+=`\n xC = xCCorner + ${t*u};\n `,1===o){if(t= 0 && xCOffset < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n `,d+=1===u&&t>0?`\n xC${t} = vec4(xTexelC${t-2}.zw, xTexelC${t}.xy);\n `:`\n xCOffset = xC + 1 - 2;\n\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n previous.zw = vec2(0.0);\n }\n\n xC${t} = vec4(previous.zw, xTexelC${t}.xy);\n } else {\n xC${t} = vec4(0.0, 0.0, xTexelC${t}.xy);\n }\n `):d+=`\n if (xC >= 0 && xC < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n\n xC${t} = xTexelC${t};\n `,t+1= 0 && xCOffset < inDims[1] && xTexelC${t+1}Ready == 0) {\n xTexelC${t+1} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t+1}.zw = vec2(0.0);\n }\n xTexelC${t+1}Ready = 1;\n }\n `,u>1&&(d+=`\n xCOffset -= 2;\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xCOffset, d1);\n xTexelC${t}Ready = 1;\n }\n `),d+=`\n xC${t+1} = vec4(xTexelC${t}.zw, xTexelC${t+1}.xy);\n `):d+=1===e?`\n xC${t+1} = xTexelC${t};\n `:`\n xCOffset = xC + ${e};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t+1}Ready == 0) {\n xTexelC${t+1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t+1}.zw = vec2(0.0);\n }\n xTexelC${t+1}Ready = 1;\n }\n\n xC${t+1} = xTexelC${t+1};\n `}}else t= 0 && xCOffset < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xCOffset, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n\n if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${t+1}Ready == 0) {\n xTexelC${t+1} = getX(batch, xR, xC + 1, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xC + 2 >= inDims[1]) {\n xTexelC${t+1}.zw = vec2(0.0);\n }\n xTexelC${t+1}Ready = 1;\n }\n\n xC${t} = vec4(xTexelC${t}.zw, xTexelC${t+1}.zw);\n `,t+1= 0 && xCOffset < inDims[1]) {\n final = getX(batch, xR, xCOffset, d1);\n }\n xC${t+1} = vec4(xTexelC${t+1}.xy, final.xy);\n `)):(d+=`\n if(xC >= 0 && xC < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n\n xCOffset = xC + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t+1}Ready == 0) {\n xTexelC${t+1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t+1}.zw = vec2(0.);\n }\n xTexelC${t+1}Ready = 1;\n }\n\n xC${t} = vec4(\n xTexelC${t}.xy, xTexelC${t+1}.xy);\n `,t+1`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${s} and dilations '${c}'`));const p=dl(a.shape,i.shape,s,c,o,l,!0);let d;d=Ge().getBool("WEBGL_PACK_DEPTHWISECONV")&&p.strideWidth<=2&&p.outChannels/p.inChannels==1?new RF(p):new OF(p);const h=[[p.padInfo.top,p.padInfo.left],[p.strideHeight,p.strideWidth],[p.dilationHeight,p.dilationWidth],[p.inHeight,p.inWidth]];return n.runWebGLProgram(d,[a,i],"float32",h)}};class YF{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideHeight,n=e.strideWidth,r=e.padInfo.top,a=e.padInfo.left,i=e.outChannels/e.inChannels;this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int wR = coords.x;\n int wC = coords.y;\n int d1 = coords.z;\n int dm = coords.w;\n int d2 = d1 * ${i} + dm;\n\n float dotProd = 0.0;\n\n // TO DO: Vec4 over the batch size\n for (int b = 0; b < ${e.batchSize}; b++) {\n for (int yR = 0; yR < ${e.outHeight}; yR++) {\n int xR = wR + yR * ${t} - ${r};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int yC = 0; yC < ${e.outWidth}; yC++) {\n int xC = wC + yC * ${n} - ${a};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n float dyValue = getDy(b, yR, yC, d2);\n float xValue = getX(b, xR, xC, d1);\n dotProd += (xValue * dyValue);\n }\n }\n }\n setOutput(dotProd);\n }\n `}}class zF{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,a=e.strideWidth,i=t-1-e.padInfo.top,s=n-1-e.padInfo.left,o=e.outChannels/e.inChannels;this.userCode=`\n const ivec2 pads = ivec2(${i}, ${s});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords[3];\n ivec2 dyCorner = coords.yz - pads;\n int dyRCorner = dyCorner.x;\n int dyCCorner = dyCorner.y;\n\n float dotProd = 0.0;\n\n for (int wR = 0; wR < ${t}; wR++) {\n float dyR = float(dyRCorner + wR) / ${r}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = ${t} - 1 - wR;\n\n for (int wC = 0; wC < ${n}; wC++) {\n float dyC = float(dyCCorner + wC) / ${a}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = ${n} - 1 - wC;\n\n // TO DO: Vec4 over the channelMul\n for (int dm = 0; dm < ${o}; dm++) {\n int d2 = d1 * ${o} + dm;\n float xValue = getDy(batch, idyR, idyC, d2);\n float wValue = getW(wRPerm, wCPerm, d1, dm);\n dotProd += xValue * wValue;\n }\n }\n }\n setOutput(dotProd);\n }\n `}}const BF={kernelName:Ht,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,dy:i}=t,{strides:s,dilations:o,pad:u,dimRoundingMode:l,filterShape:c}=r,p=dl(a.shape,c,s,o,u,l,!0),d=new YF(p);return n.runWebGLProgram(d,[a,i],"float32")}},PF={kernelName:jt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,filter:i}=t,{strides:s,dilations:o,pad:u,dimRoundingMode:l,inputShape:c}=r,p=dl(c,i.shape,s,o,u,l,!0),d=new zF(p);return n.runWebGLProgram(d,[a,i],"float32")}};class HF{constructor(e){this.variableNames=["X"],this.outputShape=[e,e],this.userCode="\n void main() {\n ivec2 coords = getOutputCoords();\n float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0;\n setOutput(val);\n }\n "}}const jF={kernelName:Ut,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r}=t,a=[...r.shape,...r.shape],i=ce(r.shape),s=NO({inputs:{x:r},backend:n,attrs:{shape:[i]}}),o=new HF(i),u=n.runWebGLProgram(o,[s],s.dtype),l=NO({inputs:{x:u},backend:n,attrs:{shape:a}});return n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(u),l}};class UF{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const{inHeight:t,inWidth:n,padInfo:r,strideHeight:a,strideWidth:i,filterHeight:s,filterWidth:o,dilationHeight:u,dilationWidth:l}=e,{top:c,left:p}=r;this.userCode=`\n const ivec2 strides = ivec2(${a}, ${i});\n const ivec2 pads = ivec2(${c}, ${p});\n const float neg_infinity = -3.4e38;\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n int d1 = coords.w;\n ivec2 outTopLeftCorner =\n coords.yz * strides - pads;\n int hBeg = outTopLeftCorner.x;\n int wBeg = outTopLeftCorner.y;\n\n float curVal = neg_infinity;\n for (int h = 0; h < ${s}; h++) {\n int hIn = hBeg + h * ${u};\n\n if (hIn >= 0 && hIn < ${t}) {\n for (int w = 0; w < ${o}; w++) {\n int wIn = wBeg + w * ${l};\n\n if (wIn >= 0 && wIn < ${n}) {\n float xVal = getX(batch, hIn, wIn, d1);\n float wVal = getW(h, w, d1);\n\n float val = xVal + wVal;\n if (val > curVal) {\n curVal = val;\n }\n }\n }\n }\n }\n\n float result = curVal;\n setOutput(result);\n }\n `}}const qF={kernelName:qt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i}=t,{strides:s,pad:o,dilations:u}=r,l=ll(a.shape,i.shape,s,o,"NHWC",u);let c;const p=new UF(l);c=n.runWebGLProgram(p,[a,i],"float32");const d=NO({inputs:{x:c},backend:n,attrs:{shape:l.outShape}});return n.disposeIntermediateTensorInfo(c),d}},WF={kernelName:Kt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{equation:a}=r,i=t,{allDims:s,summedDims:o,idDims:u}=kf(a,i.length);Tf(s.length,u,i);const{path:l,steps:c}=If(o,u),p=c.length;let d=null,h=s.length;const f=[];for(let e=0;e=0&&(d=AO({inputs:{x:d},backend:n,attrs:{axis:l[e]-(s.length-h),keepDims:!1}}),f.push(d)),h--)}for(const e of f)e!==d&&n.disposeIntermediateTensorInfo(e);return d}},VF=gO({opSnippet:"return (x >= 0.0) ? x : (exp(x) - 1.0);",packedOpSnippet:"\n vec4 result;\n\n result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);\n result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);\n result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);\n result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);\n\n return result;\n"}),GF={kernelName:Jt,backendName:"webgl",kernelFunc:VF},KF={kernelName:Xt,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n}=e,{dy:r,y:a}=t,i=Ge().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new iO("\n vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));\n return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));\n",r.shape,a.shape):new aO("return (b >= 1.0) ? a : a * (b + 1.0);",r.shape,a.shape);return n.runWebGLProgram(i,[r,a],r.dtype)}},JF=yO({opSnippet:"return float(a == b);",packedOpSnippet:"\n return vec4(equal(a, b));\n",dtype:"bool",cpuKernelImpl:r$}),XF={kernelName:Qt,backendName:"webgl",kernelFunc:JF},ZF=gO({opSnippet:`\n // Error function is calculated approximately with elementary function.\n // See "Handbook of Mathematical Functions with Formulas,\n // Graphs, and Mathematical Tables", Abramowitz and Stegun.\n float p = ${pf};\n float a1 = ${df};\n float a2 = ${hf};\n float a3 = ${ff};\n float a4 = ${mf};\n float a5 = ${gf};\n\n float sign = sign(x);\n x = abs(x);\n float t = 1.0 / (1.0 + p * x);\n return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x));\n`}),QF={kernelName:Zt,backendName:"webgl",kernelFunc:ZF},eY=gO({opSnippet:"if (isnan(x)) return x;\n return exp(x);\n",packedOpSnippet:"\n vec4 result = exp(x);\n bvec4 isNaN = isnan(x);\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n",cpuKernelImpl:a$,dtype:"float32"}),tY={kernelName:en,backendName:"webgl",kernelFunc:eY};function nY(e){const{inputs:t,attrs:n,backend:r}=e,{dim:a}=n,{input:i}=t,s=i.shape.length,o=i.shape.slice();let u=a;return a<0&&(se(-(s+1)<=a,(()=>`Axis must be in the interval [${-(s+1)}, ${s}]`)),u=s+a+1),o.splice(u,0,1),NO({inputs:{x:i},backend:r,attrs:{shape:o}})}const rY={kernelName:tn,backendName:"webgl",kernelFunc:nY},aY="return exp(x) - 1.0;",iY=gO({opSnippet:aY,packedOpSnippet:aY,cpuKernelImpl:i$}),sY={kernelName:nn,backendName:"webgl",kernelFunc:iY};class oY{constructor(e,t,n){this.variableNames=["real","imag"];const r=t[1];this.outputShape=t;const a=n?`2.0 * ${Math.PI}`:`-2.0 * ${Math.PI}`,i=n?`${r}.0`:"1.0";let s;if("real"===e)s="return real * expR - imag * expI;";else{if("imag"!==e)throw new Error(`FFT component must be either "real" or "imag", got ${e}.`);s="return real * expI + imag * expR;"}this.userCode=`\n const float exponentMultiplier = ${a};\n\n float unaryOpComplex(float real, float expR, float imag, float expI) {\n ${s}\n }\n\n float mulMatDFT(int batch, int index) {\n float indexRatio = float(index) / float(${r});\n float exponentMultiplierTimesIndexRatio =\n exponentMultiplier * indexRatio;\n\n float result = 0.0;\n\n for (int i = 0; i < ${r}; i++) {\n // x = (-2|2 * PI / N) * index * i;\n float x = exponentMultiplierTimesIndexRatio * float(i);\n float expR = cos(x);\n float expI = sin(x);\n float real = getReal(batch, i);\n float imag = getImag(batch, i);\n\n result +=\n unaryOpComplex(real, expR, imag, expI) / ${i};\n }\n\n return result;\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n setOutput(mulMatDFT(coords[0], coords[1]));\n }\n `}}function uY(e,t,n){const r=n.texData.get(e.dataId),a=ce(e.shape),i=e.shape[e.shape.length-1],s=NO({inputs:{x:e},backend:n,attrs:{shape:[a/i,i]}}),o=s.shape,u=new oY("real",o,t),l=new oY("imag",o,t),c=[{dataId:r.complexTensorInfos.real.dataId,dtype:r.complexTensorInfos.real.dtype,shape:o},{dataId:r.complexTensorInfos.imag.dataId,dtype:r.complexTensorInfos.imag.dtype,shape:o}],p=n.runWebGLProgram(u,c,"float32"),d=n.runWebGLProgram(l,c,"float32"),h=uO({inputs:{real:p,imag:d},backend:n});n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(d);const f=NO({inputs:{x:h},backend:n,attrs:{shape:e.shape}});return n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(h),f}const lY={kernelName:rn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{input:r}=t;return uY(r,!1,n)}};class cY{constructor(e,t){this.outputShape=[],this.customUniforms=[{name:"value",type:"float"}],this.variableNames=["x"],this.outputShape=e,this.userCode="\n void main() {\n // Input can be obtained from uniform value.\n setOutput(value);\n }\n "}}function pY(e){const{backend:t,attrs:n}=e,{shape:r,value:a}=n;let{dtype:i}=n;if(i=i||Le(a),"string"===i){const e=Me(i,ce(r));return e.fill(a),t.makeTensorInfo(r,i,e)}{const e=new cY(r,a),n=[[a]];return t.runWebGLProgram(e,[],i,n)}}const dY={kernelName:an,backendName:"webgl",kernelFunc:pY};class hY{constructor(e){this.variableNames=["Image"],this.outputShape=[];const t=e[2];this.outputShape=e,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int x = coords[2];\n\n int coordX = ${t} - x - 1;\n float outputValue;\n if(coordX >= 0 && coordX < ${t}) {\n outputValue = getImage(coords[0], coords[1], coordX, coords[3]);\n } else {\n outputValue = getImage(coords[0], coords[1], coords[2], coords[3]);\n }\n setOutput(outputValue);\n }\n `}}const fY={kernelName:sn,backendName:"webgl",kernelFunc:({inputs:e,backend:t})=>{const{image:n}=e,r=t,a=new hY(n.shape);return r.runWebGLProgram(a,[n],n.dtype)}},mY="return floor(x);",gY=gO({opSnippet:mY,packedOpSnippet:mY,cpuKernelImpl:s$}),yY={kernelName:on,backendName:"webgl",kernelFunc:gY},bY=yO({opSnippet:"\n float s = sign(a) * sign(b);\n int ia = round(a);\n int ib = round(b);\n if (ib != 0) {\n // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n return float(idiv(ia, ib, s));\n } else {\n return NAN;\n }\n",packedOpSnippet:"\n ivec4 ia = round(a);\n ivec4 ib = round(b);\n bvec4 cond = notEqual(ib, ivec4(0));\n ivec4 result = ivec4(0);\n vec4 s = sign(a) * sign(b);\n\n // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n if (cond[0]) {\n result[0] = idiv(ia[0], ib[0], s[0]);\n }\n if (cond[1]) {\n result[1] = idiv(ia[1], ib[1], s[1]);\n }\n if (cond[2]) {\n result[2] = idiv(ia[2], ib[2], s[2]);\n }\n if (cond[3]) {\n result[3] = idiv(ia[3], ib[3], s[3]);\n }\n return vec4(result);\n",dtype:"int32"}),xY={kernelName:un,backendName:"webgl",kernelFunc:bY};class vY{constructor(e){this.variableNames=["A"];const t=yL(),[n,r]=e;this.outputShape=e,this.userCode=`\n void main() {\n ivec3 coords = getOutputCoords();\n int texR = coords[0];\n int texC = coords[1];\n int depth = coords[2];\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${r}.0, ${n}.0);\n\n vec4 values = ${t.texture2D}(A, uv);\n float value;\n if (depth == 0) {\n value = values.r;\n } else if (depth == 1) {\n value = values.g;\n } else if (depth == 2) {\n value = values.b;\n } else if (depth == 3) {\n value = values.a;\n }\n\n setOutput(floor(value * 255.0 + 0.5));\n }\n `}}class _Y{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;const t=yL(),[n,r]=e;this.outputShape=e,this.userCode=`\n void main() {\n ivec3 coords = getOutputCoords();\n int texR = coords[0];\n int texC = coords[1];\n int depth = coords[2];\n\n vec4 result = vec4(0.);\n\n for(int row=0; row<=1; row++) {\n for(int col=0; col<=1; col++) {\n texC = coords[1] + row;\n depth = coords[2] + col;\n\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${r}.0, ${n}.0);\n vec4 values = ${t.texture2D}(A, uv);\n float value;\n if (depth == 0) {\n value = values.r;\n } else if (depth == 1) {\n value = values.g;\n } else if (depth == 2) {\n value = values.b;\n } else if (depth == 3) {\n value = values.a;\n }\n\n result[row * 2 + col] = floor(value * 255.0 + 0.5);\n }\n }\n\n ${t.output} = result;\n }\n `}}const wY={kernelName:ia,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e;let{pixels:a}=t;const{numChannels:i}=r,s="undefined"!=typeof HTMLVideoElement&&a instanceof HTMLVideoElement,o="undefined"!=typeof HTMLImageElement&&a instanceof HTMLImageElement,[u,l]=s?[a.videoWidth,a.videoHeight]:[a.width,a.height],c=[l,u],p=[l,u,i];(o||s)&&(null==MY&&(MY=document.createElement("canvas").getContext("2d")),MY.canvas.width=u,MY.canvas.height=l,MY.drawImage(a,0,0,u,l),a=MY.canvas);const d=n.makeTensorInfo(c,"int32");n.texData.get(d.dataId).usage=PA.PIXELS,n.gpgpu.uploadPixelDataToTexture(n.getTexture(d.dataId),a);const h=Ge().getBool("WEBGL_PACK")?new _Y(p):new vY(p),f=n.runWebGLProgram(h,[d],"int32");return n.disposeData(d.dataId),f}};let MY;const NY={kernelName:ua,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i,bias:s,preluActivationWeights:o}=t,{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:d,activation:h,leakyreluAlpha:f}=r,m=_l(c),g=dl(a.shape,i.shape,u,p,l,d,!1,m);let y;const b=[];if(1!==g.filterHeight||1!==g.filterWidth||1!==g.dilationHeight||1!==g.dilationWidth||1!==g.strideHeight||1!==g.strideWidth||"SAME"!==g.padInfo.type&&"VALID"!==g.padInfo.type)if(Ge().getBool("WEBGL_CONV_IM2COL"))y=uF({x:a,filter:i,convInfo:g,backend:n,bias:s,activation:h,preluActivationWeights:o,leakyreluAlpha:f});else{const e=null!=s,t=null!=o,r="leakyrelu"===h,u=h?bO(h,!1):null,l=new rF(g,e,u,t,r),p=[a,i],d=(e,t)=>{if("NCHW"===t&&1===e.shape.length&&1!==e.shape[0]){const t=NO({inputs:{x:e},backend:n,attrs:{shape:[e.shape[0],1,1]}});return b.push(t),t}return e};if(e&&p.push(d(s,c)),t&&p.push(d(o,c)),r){const e=n.makeTensorInfo([],"float32",Fa(f,"float32"));p.push(e),b.push(e)}y=n.runWebGLProgram(l,p,"float32")}else y=oF({x:a,filter:i,convInfo:g,backend:n,bias:s,activation:h,preluActivationWeights:o,leakyreluAlpha:f});const x=NO({inputs:{x:y},backend:n,attrs:{shape:g.outShape}});return b.push(y),b.forEach((e=>n.disposeIntermediateTensorInfo(e))),x}},SY={kernelName:la,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i,bias:s,preluActivationWeights:o}=t,{strides:u,pad:l,dilations:c,dimRoundingMode:p,activation:d,leakyreluAlpha:h}=r,f=[];let m=c;null==m&&(m=[1,1]),se(vl(u,m),(()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${u} and dilations '${m}'`));const g=dl(a.shape,i.shape,u,m,l,p,!0),y=Ge().getBool("WEBGL_PACK_DEPTHWISECONV")&&g.strideWidth<=2&&g.outChannels/g.inChannels==1,b=d?bO(d,y):null,x=[a,i],v=null!=s,_=null!=o,w="leakyrelu"===d;if(v&&x.push(s),_&&x.push(o),w){const e=n.makeTensorInfo([],"float32",Fa(h,"float32"));x.push(e),f.push(e)}let M;M=y?new RF(g,v,b,_,w):new OF(g,v,b,_,w);const N=[[g.padInfo.top,g.padInfo.left],[g.strideHeight,g.strideWidth],[g.dilationHeight,g.dilationWidth],[g.inHeight,g.inWidth]],S=n.runWebGLProgram(M,x,"float32",N);return f.forEach((e=>n.disposeIntermediateTensorInfo(e))),S}};class kY{constructor(e,t,n,r){this.sliceDim=e,this.strides=t,this.paramsShape=r,this.variableNames=["x","indices"],this.outputShape=n;const a=AL(t.length),i=AL(n.length),s=this.sliceDim>1?"strides[j]":"strides",o=AL(r.length),u=r.length>1?"paramsShape[j]":"paramsShape";this.userCode=`\n ${a} strides = ${a}(${this.strides});\n ${o} paramsShape = ${o}(${this.paramsShape});\n void main() {\n ${i} coords = getOutputCoords();\n int flattenIndex = 0;\n bool out_of_bounds = false;\n for (int j = 0; j < ${this.sliceDim}; j++) {\n int index = round(getIndices(coords[0], j));\n out_of_bounds = out_of_bounds || index < 0;\n out_of_bounds = out_of_bounds || index >= ${u};\n flattenIndex += index * ${s};\n }\n setOutput(out_of_bounds ? 0.0 : getX(flattenIndex, coords[1]));\n }\n `}}const DY={kernelName:pn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{params:r,indices:a}=t,i=a.shape,s=i[i.length-1],o=ce(r.shape),[u,l,c,p]=Bo(r,a),d=NO({inputs:{x:a},backend:n,attrs:{shape:[l,s]}}),h=NO({inputs:{x:r},backend:n,attrs:{shape:[ce(r.shape)/c,c]}});if(n.shouldExecuteOnCPU([r,a])||"string"===r.dtype){const e=n.readSync(a.dataId),t=n.bufferSync(r),i=o$(e,t,r.dtype,l,s,c,p,r.shape,o);return n.makeTensorInfo(u,r.dtype,i.values)}const f=new kY(s,p,[l,c],r.shape),m=n.runWebGLProgram(f,[h,d],h.dtype),g=NO({inputs:{x:m},backend:n,attrs:{shape:u}});return n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(m),g}};class TY{constructor(e,t){this.variableNames=["A","indices"],this.outputShape=t,this.rank=t.length;const n=AL(this.rank),r=function(e,t){const n=["resRC.x","resRC.y","resRC.z","resRC.w"],r=[];for(let t=0;t= 0) && (index < ${e[2]}) ? 1.0 : 0.0;\n setOutput(inBounds * getA(${r}));\n }\n `}}function IY(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,indices:i}=t,{axis:s,batchDims:o}=r,u=ve(s,a.shape)[0];if(Ge().get("DEBUG")){const e=n.readSync(i.dataId),t=a.shape[u];for(let n=0;n=0,(()=>`GatherV2: the index value ${r} is not in [0, ${t-1}]`))}}const l=Vf(a,i,u,o),c=ce(i.shape),p=[],d=NO({inputs:{x:a},backend:n,attrs:{shape:[l.batchSize,l.outerSize,l.dimSize,l.sliceSize]}}),h=NO({inputs:{x:i},backend:n,attrs:{shape:[l.batchSize,c/l.batchSize]}});p.push(d),p.push(h);const f=[l.batchSize,l.outerSize,c/l.batchSize,l.sliceSize];if(n.shouldExecuteOnCPU([a,i])||"string"===a.dtype){const e=n.bufferSync(h),t=n.bufferSync(d),r=u$(t,e,f);return p.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(l.outputShape,r.dtype,r.values)}const m=new TY(d.shape,f),g=n.runWebGLProgram(m,[d,h],d.dtype);p.push(g);const y=NO({inputs:{x:g},backend:n,attrs:{shape:l.outputShape}});return p.forEach((e=>n.disposeIntermediateTensorInfo(e))),y}const EY={kernelName:cn,backendName:"webgl",kernelFunc:IY},CY=yO({opSnippet:"return float(a > b);",packedOpSnippet:"\n return vec4(greaterThan(a, b));\n",cpuKernelImpl:l$,dtype:"bool"}),AY={kernelName:dn,backendName:"webgl",kernelFunc:CY},LY=yO({opSnippet:"return float(a >= b);",packedOpSnippet:"\n return vec4(greaterThanEqual(a, b));\n",dtype:"bool",cpuKernelImpl:c$}),$Y={kernelName:hn,backendName:"webgl",kernelFunc:LY},OY={kernelName:mn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{input:r}=t;return uY(r,!0,n)}},RY=gO({opSnippet:"return float(!isnan(x) && !isinf(x));",dtype:"bool"}),FY={kernelName:yn,backendName:"webgl",kernelFunc:RY},YY=gO({opSnippet:"return float(isinf(x));",dtype:"bool"}),zY={kernelName:bn,backendName:"webgl",kernelFunc:YY},BY=gO({opSnippet:"return float(isnan(x));",dtype:"bool"}),PY={kernelName:xn,backendName:"webgl",kernelFunc:BY},HY=yO({opSnippet:"return float(a < b);",packedOpSnippet:"\n return vec4(lessThan(a, b));\n",cpuKernelImpl:p$,dtype:"bool"}),jY={kernelName:_n,backendName:"webgl",kernelFunc:HY},UY=yO({opSnippet:"return float(a <= b);",packedOpSnippet:"\n return vec4(lessThanEqual(a, b));\n",cpuKernelImpl:d$,dtype:"bool"}),qY={kernelName:wn,backendName:"webgl",kernelFunc:UY},WY={kernelName:Mn,backendName:"webgl",kernelFunc:function(e){const{backend:t,attrs:n}=e,{start:r,stop:a,num:i}=n,s=h$(r,a,i);return t.makeTensorInfo([s.length],"float32",s)}},VY=gO({opSnippet:"if (isnan(x)) return x;\n return x < 0.0 ? 0./0. : log(x);\n",packedOpSnippet:"\n vec4 result = log(x);\n bvec4 isNaN = isnan(x);\n result.r = isNaN.r ? x.r : (x.r < 0.0 ? 0./0. : result.r);\n result.g = isNaN.g ? x.g : (x.g < 0.0 ? 0./0. : result.g);\n result.b = isNaN.b ? x.b : (x.b < 0.0 ? 0./0. : result.b);\n result.a = isNaN.a ? x.a : (x.a < 0.0 ? 0./0. : result.a);\n return result;\n",cpuKernelImpl:f$}),GY={kernelName:Nn,backendName:"webgl",kernelFunc:VY},KY=gO({opSnippet:"if (isnan(x)) return x;\n return log(1.0 + x);\n"}),JY={kernelName:Sn,backendName:"webgl",kernelFunc:KY},XY=yO({opSnippet:"return float(a >= 1.0 && b >= 1.0);",packedOpSnippet:"\n return vec4(\n vec4(greaterThanEqual(a, vec4(1.0))) *\n vec4(greaterThanEqual(b, vec4(1.0))));\n",dtype:"bool"}),ZY={kernelName:kn,backendName:"webgl",kernelFunc:XY},QY=gO({opSnippet:"return float(!(x >= 1.0));"}),ez={kernelName:Dn,backendName:"webgl",kernelFunc:QY},tz=yO({opSnippet:"return float(a >= 1.0 || b >= 1.0);",packedOpSnippet:"\n return min(\n vec4(greaterThanEqual(a, vec4(1.0))) +\n vec4(greaterThanEqual(b, vec4(1.0))),\n vec4(1.0));\n",dtype:"bool"}),nz={kernelName:Tn,backendName:"webgl",kernelFunc:tz};class rz{constructor(e,t,n,r,a){this.variableNames=["x"],this.outputShape=[];const i=t,s=e[3]-1;let o;this.outputShape=e;const u=`float(${n}) + float(${r}) * sum`;o=.5===a?`inversesqrt(${u})`:1===a?`1.0/(${u})`:`exp(log(${u}) * float(-${a}));`,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int r = coords[1];\n int c = coords[2];\n int d = coords[3];\n float x = getX(b, r, c, d);\n float sum = 0.0;\n for (int j = -${i}; j <= ${i}; j++) {\n int idx = d + j;\n if (idx >= 0 && idx <= ${s}) {\n float z = getX(b, r, c, idx);\n sum += z * z;\n }\n }\n float val = x * ${o};\n setOutput(val);\n }\n `}}class az{constructor(e,t,n,r,a){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;const i=t,s=e[3]-1;let o;this.outputShape=e;const u=`float(${n}) + float(${r}) * sum`;o=.5===a?`inversesqrt(${u})`:1===a?`1.0/(${u})`:`exp(log(${u}) * float(-${a}));`,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords.x;\n int r = coords.y;\n int c = coords.z;\n int d = coords.w;\n\n bool hasNextCol = d < ${this.outputShape[3]};\n bool hasNextRow = c < ${this.outputShape[2]};\n\n vec4 sum = vec4(0.);\n vec4 xFragAtOutputCoords = getX(b, r, c, d);\n\n vec4 xAtOutputCoords = vec4(\n getChannel(xFragAtOutputCoords, vec2(c, d)),\n hasNextCol ?\n getChannel(xFragAtOutputCoords, vec2(c, d + 1)) : 0.0,\n hasNextRow ?\n getChannel(xFragAtOutputCoords , vec2(c + 1, d)) : 0.0,\n (hasNextRow && hasNextCol) ?\n getChannel(xFragAtOutputCoords, vec2(c + 1, d + 1)) : 0.0\n );\n\n int firstChannel = d - ${i};\n vec2 cache = vec2(0.);\n if(firstChannel >= 0){\n vec4 firstChannelFrag = getX(b, r, c, firstChannel);\n cache.x = getChannel(firstChannelFrag, vec2(c, firstChannel));\n if(hasNextRow){\n cache.y = getChannel(firstChannelFrag, vec2(c + 1, firstChannel));\n }\n }\n\n ivec2 depth = ivec2(d, d + 1);\n for (int j = - ${i}; j <= ${i}; j++) {\n ivec2 idx = depth + j;\n bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0));\n bvec2 belowUpperBound = lessThanEqual(idx, ivec2(${s}));\n\n bool depthInRange = aboveLowerBound.x && belowUpperBound.x;\n bool depthPlusOneInRange = aboveLowerBound.y && belowUpperBound.y;\n\n if(depthInRange || depthPlusOneInRange){\n vec4 z = vec4(0.);\n vec4 xFragAtCurrentDepth;\n z.xz = cache.xy;\n if(depthPlusOneInRange && hasNextCol){\n xFragAtCurrentDepth = idx.y != d ?\n getX(b, r, c, idx.y) : xFragAtOutputCoords;\n z.y = getChannel(xFragAtCurrentDepth, vec2(c, idx.y));\n if(hasNextRow){\n z.w = getChannel(xFragAtCurrentDepth, vec2(c + 1, idx.y));\n }\n }\n cache.xy = z.yw;\n sum += z * z;\n }\n }\n vec4 result = xAtOutputCoords * ${o};\n setOutput(result);\n }\n `}}const iz={kernelName:An,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{depthRadius:i,bias:s,alpha:o,beta:u}=r,l=Ge().getBool("WEBGL_PACK_NORMALIZATION")?new az(a.shape,i,s,o,u):new rz(a.shape,i,s,o,u);return n.runWebGLProgram(l,[a],a.dtype)}};class sz{constructor(e,t,n,r,a){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=e,this.depth=e[3],this.depthRadius=t,this.bias=n,this.alpha=r,this.beta=a,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int r = coords[1];\n int c = coords[2];\n\n float result = 0.0;\n for (int d = 0; d < ${this.depth}; ++d) {\n int depthBegin = int(max(0.0, float(d - ${t})));\n int depthEnd = int(min(float(${this.depth}),\n float(d + ${t} + 1)));\n\n const int MIN_DEPTH_BEGIN = 0;\n const int MAX_DEPTH_END = ${this.depth};\n\n float norm = 0.0;\n for (int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k) {\n if (k < depthBegin){\n continue;\n }\n else if (k >= depthBegin && k < depthEnd) {\n norm += getInputImage(b, r, c, k) * getInputImage(b, r, c, k);\n }\n else {\n break;\n }\n }\n\n norm = float(${r}) * norm + float(${n});\n\n for(int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k){\n if (k < depthBegin){\n continue;\n }\n else if (k >= depthBegin && k < depthEnd){\n float dyi = -2.0 * float(${r})\n * float(${a})\n * getInputImage(b ,r ,c, k) * getOutputImage(b, r, c, d)\n / norm;\n if (k == d) {\n dyi += pow(norm, -1.0 * ${a});\n }\n if (k == coords[3]) {\n dyi *= getDy(b, r, c, d);\n result += dyi;\n }\n }\n else {\n break;\n }\n }\n }\n setOutput(result);\n }\n `}}const oz={kernelName:Ln,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{x:a,y:i,dy:s}=t,{depthRadius:o,bias:u,alpha:l,beta:c}=r,p=new sz(a.shape,o,u,l,c);return n.runWebGLProgram(p,[a,i,s],a.dtype)}};function uz(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{reductionIndices:i,keepDims:s}=r,o=a.shape.length,u=ve(i,a.shape);let l=u;const c=xc(l,o),p=null!=c,d=n.shouldExecuteOnCPU([a]);let h=a;if(p){if(d){const e=n.texData.get(h.dataId).values,t=new Array(o);for(let e=0;e 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n",cpuKernelImpl:g$}),pz={kernelName:On,backendName:"webgl",kernelFunc:cz},dz={kernelName:Rn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t;mL(a,"maxPool");const{filterSize:i,strides:s,pad:o,dimRoundingMode:u}=r;se(vl(s,1),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${s} and dilations '1'`));const l=cl(a.shape,i,s,1,o,u);if(1===l.filterWidth&&1===l.filterHeight&&de(l.inShape,l.outShape))return sO({inputs:{x:a},backend:n});const c=new mR(l,"max",!1);return n.runWebGLProgram(c,[a],a.dtype)}},hz={kernelName:Yn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{filterSize:i,strides:s,pad:o,dataFormat:u,dimRoundingMode:l}=r,c=pl(a.shape,i,s,[1,1,1],o,l,u),p=new gR(c,"max",!1);return n.runWebGLProgram(p,[a],a.dtype)}};class fz{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const t=e.strideHeight,n=e.strideWidth,r=e.dilationHeight,a=e.effectiveFilterHeight,i=e.effectiveFilterWidth,s=a-1-e.padInfo.top,o=i-1-e.padInfo.left,u=a*i-1;this.userCode=`\n const ivec2 pads = ivec2(${s}, ${o});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n\n ivec2 dyRCCorner = coords.yz - pads;\n int dyRCorner = dyRCCorner.x;\n int dyCCorner = dyRCCorner.y;\n\n // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${a};\n wR += ${r}) {\n float dyR = float(dyRCorner + wR) / ${t}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${i}; wC++) {\n float dyC = float(dyCCorner + wC) / ${n}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(b, idyR, idyC, d);\n int maxPosValue = ${u} - int(getMaxPos(b, idyR, idyC, d));\n\n // Get the current value, check it against the value from the\n // position matrix.\n int curPosValue = wR * ${i} + wC;\n float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n dotProd += dyValue * mask;\n }\n }\n setOutput(dotProd);\n }\n `}}class mz{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const t=e.strideDepth,n=e.strideHeight,r=e.strideWidth,a=e.dilationDepth,i=e.dilationHeight,s=e.dilationWidth,o=e.effectiveFilterDepth,u=e.effectiveFilterHeight,l=e.effectiveFilterWidth,c=o-1-e.padInfo.front,p=u-1-e.padInfo.top,d=l-1-e.padInfo.left,h=o*u*l-1;this.userCode=`\n const ivec3 pads = ivec3(${c}, ${p}, ${d});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyDCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n // Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get\n // dx(xD, xR, xC, ch).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int wD = 0; wD < ${o};\n wD += ${a}) {\n float dyD = float(dyDCorner + wD) / ${t}.0;\n\n if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) {\n continue;\n }\n int idyD = int(dyD);\n\n for (int wR = 0; wR < ${u};\n wR += ${i}) {\n float dyR = float(dyRCorner + wR) / ${n}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${l};\n wC += ${s}) {\n float dyC = float(dyCCorner + wC) / ${r}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n int maxPosValue = ${h} -\n int(getMaxPos(batch, idyD, idyR, idyC, ch));\n\n // Get the current value, check it against the value from the\n // position matrix.\n int curPosValue =\n wD * ${u} * ${l} +\n wR * ${l} + wC;\n float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n dotProd += dyValue * mask;\n }\n }\n }\n setOutput(dotProd);\n }\n `}}const gz={kernelName:zn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i}=t,s=i,{filterSize:o,strides:u,pad:l,dimRoundingMode:c}=r,p=pl(s.shape,o,u,[1,1,1],l,c),d=new gR(p,"max",!0),h=n.runWebGLProgram(d,[s],s.dtype),f=new mz(p),m=n.runWebGLProgram(f,[a,h],s.dtype);return n.disposeIntermediateTensorInfo(h),m}},yz={kernelName:Fn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i,output:s}=t,o=i;mL([i,s],"maxPoolGrad");const{filterSize:u,strides:l,pad:c,dimRoundingMode:p}=r,d=cl(o.shape,u,l,1,c,p),h=new mR(d,"max",!0),f=n.runWebGLProgram(h,[o],o.dtype),m=new fz(d),g=n.runWebGLProgram(m,[a,f],o.dtype);return n.disposeIntermediateTensorInfo(f),g}},bz={kernelName:Bn,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{x:r}=e,{filterSize:a,strides:i,pad:s,includeBatchInIndex:o}=t,u=n;se(4===r.shape.length,(()=>`Error in maxPool: input must be rank 4 but got rank ${r.shape.length}.`));const l=[1,1];se(vl(i,l),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${l}'`));const c=cl(r.shape,a,i,l,s),[p,d]=function(e,t,n,r){let a=new mR(n,"max",!1);const i=r.runWebGLProgram(a,[e],"float32");return a=new mR(n,"max",!0,!0,t),[i,r.runWebGLProgram(a,[e],"float32")]}(r,o,c,u);return[p,d]}},xz={kernelName:Pn,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{x:r}=e,{keepDims:a,axis:i}=t,s=n,o=r.shape.length,u=ve(i,r.shape);let l=u;const c=xc(l,o),p=null!=c,d=s.shouldExecuteOnCPU([r]),h=[];let f=r;if(p){if(d){const e=s.texData.get(f.dataId).values,t=new Array(o);for(let e=0;e 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n",cpuKernelImpl:y$}),wz={kernelName:jn,backendName:"webgl",kernelFunc:_z};class Mz{constructor(e,t,n){this.variableNames=["x"],this.outputShape=t.map(((t,n)=>t[0]+e[n]+t[1]));const r=e.length,a=AL(r),i=t.map((e=>e[0])).join(","),s=t.map(((t,n)=>t[0]+e[n])).join(","),o=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r),u="reflect"===n?0:1;this.userCode=1!==r?`\n ${a} start = ${a}(${i});\n ${a} end = ${a}(${s});\n\n void main() {\n ${a} outC = getOutputCoords();\n for (int i = 0; i < ${r}; i++) {\n if (outC[i] < start[i]) {\n outC[i] = start[i] * 2 - outC[i] - ${u};\n } else if(outC[i] >= end[i]) {\n outC[i] = (end[i] - 1) * 2 - outC[i] + ${u};\n }\n }\n ${a} coords = outC - start;\n setOutput(getX(${o}));\n }\n `:`\n int start = ${i};\n int end = ${s};\n\n void main() {\n int outC = getOutputCoords();\n if (outC < start) {\n outC = start * 2 - outC - ${u};\n } else if(outC >= end) {\n outC = (end - 1) * 2 - outC + ${u};\n }\n setOutput(getX(outC - start));\n }\n `}}class Nz{constructor(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.map(((t,n)=>t[0]+e[n]+t[1]));const r=e.length,a=AL(r),i=t.map((e=>e[0])).join(","),s=t.map(((t,n)=>t[0]+e[n])).join(","),o=H$("rc",r),u=H$("source",r),l=`${o[r-1]} < ${this.outputShape[r-1]}`,c=1===r?"source":`vec2(${u.slice(-2).join()})`,p="reflect"===n?0:1;let d="";if(1===r){const e=`\n ${a} source = rc;\n if (source < start) {\n source = start * 2 - source - ${p};\n } else if (source >= end) {\n source = (end - 1) * 2 - source + ${p};\n }\n source -= start;\n `;d=`\n ${a} rc = outputLoc;\n ${e}\n result[0] = getChannel(getX(${u.join()}), ${c});\n ${o[r-1]} += 1;\n if(${l}) {\n ${e}\n result[1] = getChannel(getX(${u.join()}), ${c});\n }\n `}else{const e=`\n ${a} source = rc;\n ${a} lt = ${a}(lessThan(source, start));\n ${a} gte = ${a}(greaterThanEqual(source, end));\n ${a} orig = 1 - (lt + gte);\n source = orig * source +\n lt * (start * 2 - source - ${p}) +\n gte * ((end - 1) * 2 - source + ${p});\n source -= start;\n `;d=`\n ${a} rc = outputLoc;\n ${e}\n result[0] = getChannel(getX(${u.join()}), ${c});\n ${o[r-1]} += 1;\n if(${l}) {\n ${e}\n result[1] = getChannel(getX(${u.join()}), ${c});\n }\n rc = outputLoc;\n ${o[r-2]} += 1;\n if(${o[r-2]} < ${this.outputShape[r-2]}) {\n ${e}\n result[2] = getChannel(getX(${u.join()}), ${c});\n ${o[r-1]} += 1;\n if(${l}) {\n ${e}\n result[3] = getChannel(getX(${u.join()}), ${c});\n }\n }\n `}this.userCode=`\n const ${a} start = ${a}(${i});\n const ${a} end = ${a}(${s});\n\n void main() {\n ${a} outputLoc = getOutputCoords();\n vec4 result = vec4(0.);\n ${d}\n setOutput(result);\n }\n `}}const Sz={kernelName:Un,backendName:"webgl",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:r}=e,{paddings:a,mode:i}=n,s=Ge().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Nz(r.shape,a,i):new Mz(r.shape,a,i);return t.runWebGLProgram(s,[r],r.dtype)}},kz=yO({opSnippet:"if (b == 0.0) return NAN;\n return mod(a, b);",packedOpSnippet:"\n vec4 result = mod(a, b);\n vec4 isNaN = vec4(equal(b, vec4(0.0)));\n \n result.r = isNaN.r > 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n"}),Dz={kernelName:qn,backendName:"webgl",kernelFunc:kz};class Tz{constructor(e,t,n){this.variableNames=["probs"],this.customUniforms=[{name:"seed",type:"float"}],this.outputShape=[e,n],this.userCode=`\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n\n float r = random(seed);\n float cdf = 0.0;\n\n for (int i = 0; i < ${t-1}; i++) {\n cdf += getProbs(batch, i);\n\n if (r < cdf) {\n setOutput(float(i));\n return;\n }\n }\n\n // If no other event happened, last event happened.\n setOutput(float(${t-1}));\n }\n `}}const Iz=yO({opSnippet:"\nif (a == b) {\n return 1.0;\n};\nreturn a / b;",packedOpSnippet:"\n // vec4 one = vec4(equal(a, b));\n // return one + (vec4(1.0) - one) * a / b;\n vec4 result = a / b;\n if(a.x == b.x) {\n result.x = 1.;\n }\n if(a.y == b.y) {\n result.y = 1.;\n }\n if(a.z == b.z) {\n result.z = 1.;\n }\n if(a.w == b.w) {\n result.w = 1.;\n }\n\n return result;\n",checkOutOfBounds:!0}),Ez={kernelName:Gt,backendName:"webgl",kernelFunc:Iz},Cz="return a - b;",Az=yO({opSnippet:Cz,packedOpSnippet:Cz,supportsComplex:!0,cpuKernelImpl:R$}),Lz={kernelName:Wr,backendName:"webgl",kernelFunc:Az};function $z(e){const{inputs:t,backend:n,attrs:r}=e,{logits:a}=t,{dim:i}=r,s=ve([i],a.shape),o=uz({inputs:{x:a},backend:n,attrs:{reductionIndices:s,keepDims:!1}}),u=yc(o.shape,s),l=NO({inputs:{x:o},backend:n,attrs:{shape:u}}),c=Az({inputs:{a,b:l},backend:n}),p=eY({inputs:{x:c},backend:n}),d=AO({inputs:{x:p},backend:n,attrs:{axis:s,keepDims:!1}}),h=NO({inputs:{x:d},backend:n,attrs:{shape:u}}),f=Iz({inputs:{a:p,b:h},backend:n});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(h),f}const Oz={kernelName:$r,backendName:"webgl",kernelFunc:$z},Rz={kernelName:Wn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{logits:a}=t,{numSamples:i,seed:s,normalized:o}=r,u=o?a:$z({inputs:{logits:a},backend:n,attrs:{dim:a.shape.length-1}}),l=u.shape[0],c=u.shape[1],p=new Tz(l,c,i),d=[[s]],h=n.runWebGLProgram(p,[u],"int32",d);return o||n.disposeIntermediateTensorInfo(u),h}},Fz={kernelName:Gn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r}=t;if(n.shouldExecuteOnCPU([r])){const e=n.texData.get(r.dataId),[t,a]=x$(e.values,r.shape,r.dtype);return n.makeTensorInfo(a,r.dtype,t)}let a;return a=Ge().getBool("WEBGL_PACK_UNARY_OPERATIONS")?new Z$(r.shape,"\n vec4 result = -x;\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n"):new K$(r.shape,"if (isnan(x)) return x;\n return -x;\n"),n.runWebGLProgram(a,[r],r.dtype)}},Yz=uh,zz={kernelName:Jn,backendName:"webgl",kernelFunc:function(e){ca("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:t,backend:n,attrs:r}=e,{boxes:a,scores:i}=t,{maxOutputSize:s,iouThreshold:o,scoreThreshold:u}=r,l=n.readSync(a.dataId),c=n.readSync(i.dataId),{selectedIndices:p}=Yz(l,c,s,o,u);return n.makeTensorInfo([p.length],"int32",new Int32Array(p))}},Bz=lh,Pz={kernelName:Xn,backendName:"webgl",kernelFunc:function(e){ca("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:t,backend:n,attrs:r}=e,{boxes:a,scores:i}=t,{maxOutputSize:s,iouThreshold:o,scoreThreshold:u,padToMaxOutputSize:l}=r,c=n.readSync(a.dataId),p=n.readSync(i.dataId),{selectedIndices:d,validOutputs:h}=Bz(c,p,s,o,u,l);return[n.makeTensorInfo([d.length],"int32",new Int32Array(d)),n.makeTensorInfo([],"int32",new Int32Array([h]))]}},Hz=ch,jz={kernelName:Zn,backendName:"webgl",kernelFunc:function(e){ca("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:t,backend:n,attrs:r}=e,{boxes:a,scores:i}=t,{maxOutputSize:s,iouThreshold:o,scoreThreshold:u,softNmsSigma:l}=r,c=n.readSync(a.dataId),p=n.readSync(i.dataId),d=s,h=o,f=u,m=l,{selectedIndices:g,selectedScores:y}=Hz(c,p,d,h,f,m);return[n.makeTensorInfo([g.length],"int32",new Int32Array(g)),n.makeTensorInfo([y.length],"float32",new Float32Array(y))]}};class Uz{constructor(e,t,n,r){this.variableNames=["indices"],this.outputShape=[e,t],this.userCode=`\n void main() {\n ivec2 coords = getOutputCoords();\n int index = round(getIndices(coords.x));\n setOutput(mix(float(${r}), float(${n}),\n float(index == coords.y)));\n }\n `}}const qz={kernelName:er,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{indices:a}=t,{depth:i,onValue:s,offValue:o}=r,u=ce(a.shape),l=new Uz(u,i,s,o),c=NO({inputs:{x:a},backend:n,attrs:{shape:[u]}}),p=n.runWebGLProgram(l,[c],a.dtype);n.disposeIntermediateTensorInfo(c);const d=NO({inputs:{x:p},backend:n,attrs:{shape:[...a.shape,i]}});return n.disposeIntermediateTensorInfo(p),d}};function Wz(e){const{inputs:t,backend:n}=e,{x:r}=t;if("complex64"===r.dtype){const e=FR({inputs:{input:r},backend:n}),t=Wz({inputs:{x:e},backend:n}),a=ZR({inputs:{input:r},backend:n}),i=Wz({inputs:{x:a},backend:n}),s=uO({inputs:{real:t,imag:i},backend:n});return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(t),n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(i),s}return pY({attrs:{shape:r.shape,dtype:r.dtype,value:"string"===r.dtype?"":0},backend:n})}const Vz={kernelName:ra,backendName:"webgl",kernelFunc:Wz},Gz={kernelName:Qn,backendName:"webgl",kernelFunc:function e(t){const{inputs:n,backend:r}=t,{x:a}=n;if("string"===a.dtype)throw new Error("onesLike is not supported under string dtype");if("complex64"===a.dtype){const t=FR({inputs:{input:a},backend:r}),n=e({inputs:{x:t},backend:r}),i=ZR({inputs:{input:a},backend:r}),s=Wz({inputs:{x:i},backend:r}),o=uO({inputs:{real:n,imag:s},backend:r});return r.disposeIntermediateTensorInfo(t),r.disposeIntermediateTensorInfo(n),r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(s),o}return pY({attrs:{shape:a.shape,dtype:a.dtype,value:1},backend:r})}},Kz={kernelName:tr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{axis:a}=r;if(1===t.length)return nY({inputs:{input:t[0]},backend:n,attrs:{dim:a}});const i=t[0].shape,s=t[0].dtype;t.forEach((e=>{oe(i,e.shape,"All tensors passed to stack must have matching shapes"),se(s===e.dtype,(()=>"All tensors passed to stack must have matching dtypes"))}));const o=[],u=tF({inputs:t.map((e=>{const t=nY({inputs:{input:e},backend:n,attrs:{dim:a}});return o.push(t),t})),backend:n,attrs:{axis:a}});return o.forEach((e=>n.disposeIntermediateTensorInfo(e))),u}};class Jz{constructor(e,t,n){this.variableNames=["x"],this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map(((t,n)=>t[0]+e[n]+t[1]));const r=e.length,a=AL(r),i=t.map((e=>e[0])).join(","),s=t.map(((t,n)=>t[0]+e[n])).join(","),o=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r);this.userCode=1!==r?`\n ${a} start = ${a}(${i});\n ${a} end = ${a}(${s});\n\n void main() {\n ${a} outC = getOutputCoords();\n if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {\n setOutput(value);\n } else {\n ${a} coords = outC - start;\n setOutput(getX(${o}));\n }\n }\n `:`\n int start = ${i};\n int end = ${s};\n\n void main() {\n int outC = getOutputCoords();\n if (outC < start || outC >= end) {\n setOutput(value);\n } else {\n setOutput(getX(outC - start));\n }\n }\n `}}class Xz{constructor(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map(((t,n)=>t[0]+e[n]+t[1]));const r=e.length,a=AL(r),i=t.map((e=>e[0])).join(","),s=t.map(((t,n)=>t[0]+e[n])).join(","),o=H$("rc",r),u=H$("source",r),l=`${o[r-1]} < ${this.outputShape[r-1]}`,c=1===r?"source":`vec2(${u.slice(-2).join()})`,p=[`${a} rc = outputLoc;`,`${o[r-1]} += 1;\n if(${l}) {\n `,1===r?"":`}\n rc = outputLoc;\n ${o[r-2]} += 1;\n if(${o[r-2]} < ${this.outputShape[r-2]}) {`,1===r?"":` ${o[r-1]} += 1;\n if(${l}) {`],d=1===r?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))";let h="";for(let e=0,t=1===r?2:4;e{const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{paddings:i,constantValue:s}=r;if(0===ce(a.shape)){const e=i.map(((e,t)=>e[0]+a.shape[t]+e[1]));return pY({backend:n,attrs:{shape:e,value:s,dtype:a.dtype}})}const o=Ge().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Xz(a.shape,i,s):new Jz(a.shape,i,s),u=[[s]];return n.runWebGLProgram(o,[a],a.dtype,u)},Qz={kernelName:nr,backendName:"webgl",kernelFunc:Zz},eB=yO({opSnippet:"\n if(a < 0.0 && floor(b) < b){\n return NAN;\n }\n if (b == 0.0) {\n return 1.0;\n }\n return (round(mod(b, 2.0)) != 1) ?\n pow(abs(a), b) : sign(a) * pow(abs(a), b);\n",packedOpSnippet:"\n // isModRound1 has 1 for components with round(mod(b, 2.0)) == 1, 0 otherwise.\n vec4 isModRound1 = vec4(equal(round(mod(b, 2.0)), ivec4(1)));\n vec4 multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1);\n vec4 result = multiplier * pow(abs(a), b);\n\n // Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS\n bvec4 isExpZero = equal(b, vec4(0.0));\n result.r = isExpZero.r ? 1.0 : result.r;\n result.g = isExpZero.g ? 1.0 : result.g;\n result.b = isExpZero.b ? 1.0 : result.b;\n result.a = isExpZero.a ? 1.0 : result.a;\n\n vec4 isNaN = vec4(lessThan(a, vec4(0.0))) * vec4(lessThan(floor(b), b));\n \n result.r = isNaN.r > 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n"}),tB={kernelName:ar,backendName:"webgl",kernelFunc:eB},nB={kernelName:sr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,keepDims:s}=r,o=a.shape.length,u=[],l=ve(i,a.shape);let c=l;const p=xc(c,o);let d,h=a;if(null!=p&&(h=$O({inputs:{x:a},backend:n,attrs:{perm:p}}),c=_c(c.length,o),u.push(h)),bc("prod",c,o),n.shouldExecuteOnCPU([h])){const e=n.texData.get(h.dataId).values,{outVals:t,outShape:r,outDtype:a}=_$(h.shape,h.dtype,e,c);d=n.makeTensorInfo(r,a,t)}else{const[e,t]=gc(h.shape,c),r=ce(t),i=NO({inputs:{x:h},backend:n,attrs:{shape:[-1,r]}}),s=TO(i,pi(a.dtype),"prod",n);d=NO({inputs:{x:s},backend:n,attrs:{shape:e}}),u.push(i),u.push(s)}if(s){u.push(d);const e=yc(d.shape,l);d=NO({inputs:{x:d},backend:n,attrs:{shape:e}})}return u.forEach((e=>n.disposeIntermediateTensorInfo(e))),d}},rB=e=>{const{backend:t,attrs:n}=e,{start:r,stop:a,step:i,dtype:s}=n,o=w$(r,a,i,s);return t.makeTensorInfo([o.length],s,o)},aB={kernelName:or,backendName:"webgl",kernelFunc:rB},iB=gO({opSnippet:"return 1.0 / x;"}),sB={kernelName:lr,backendName:"webgl",kernelFunc:iB},oB=gO({opSnippet:"if (isnan(x)) return x;\n return (x < 0.0) ? 0.0 : x;\n",packedOpSnippet:"\n vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n"}),uB={kernelName:cr,backendName:"webgl",kernelFunc:oB},lB=gO({opSnippet:"if (isnan(x)) return x;\n return (x < 0.0) ? 0.0 : min(6.0, x);\n",packedOpSnippet:"\n vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n"}),cB={kernelName:gr,backendName:"webgl",kernelFunc:lB};class pB{constructor(e,t,n,r,a){this.variableNames=["A"],this.outputShape=[];const[i,s,o,u]=e;this.outputShape=[i,t,n,u];const l=[r&&t>1?s-1:s,r&&n>1?o-1:o],c=[r&&t>1?t-1:t,r&&n>1?n-1:n];let p;p=a?"(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":"vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n ${l[0]/c[0]},\n ${l[1]/c[1]});\n const vec2 inputShapeRC = vec2(${s}.0, ${o}.0);\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n ivec2 yRC = coords.yz;\n\n // Fractional source index.\n vec2 sourceFracIndexRC = ${p};\n\n // Compute the four integer indices.\n ivec2 sourceFloorRC = ivec2(max(sourceFracIndexRC, vec2(0.0)));\n ivec2 sourceCeilRC = ivec2(\n min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n float topLeft = getA(b, sourceFloorRC.x, sourceFloorRC.y, d);\n float bottomLeft = getA(b, sourceCeilRC.x, sourceFloorRC.y, d);\n float topRight = getA(b, sourceFloorRC.x, sourceCeilRC.y, d);\n float bottomRight = getA(b, sourceCeilRC.x, sourceCeilRC.y, d);\n\n vec2 fracRC = sourceFracIndexRC - vec2(sourceFloorRC);\n\n float top = topLeft + (topRight - topLeft) * fracRC.y;\n float bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y;\n float newValue = top + (bottom - top) * fracRC.x;\n\n setOutput(newValue);\n }\n `}}class dB{constructor(e,t,n,r,a){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[i,s,o,u]=e;this.outputShape=[i,t,n,u];const l=[r&&t>1?s-1:s,r&&n>1?o-1:o],c=[r&&t>1?t-1:t,r&&n>1?n-1:n];let p;p=a?"(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":"vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec3 effectiveInputOverOutputRatioRC = vec3(\n ${l[0]/c[0]},\n ${l[1]/c[1]},\n ${l[1]/c[1]});\n const vec3 inputShapeRC = vec3(${s}.0, ${o}.0,\n ${o}.0);\n\n float getAValue(int b, int r, int c, int d) {\n return getChannel(getA(b, r, c, d), vec2(c, d));\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n // Calculate values for next column in yRC.z.\n ivec3 yRC = coords.yzz + ivec3(0, 0, 1);\n\n // Fractional source index.\n vec3 sourceFracIndexRC = ${p};\n\n // Compute the four integer indices.\n ivec3 sourceFloorRC = ivec3(max(sourceFracIndexRC, vec3(0.0)));\n ivec3 sourceCeilRC = ivec3(\n min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n // Should we calculate next column and row elements in 2x2 packed cell.\n bool hasNextCol = d < ${u-1};\n bool hasNextRow = coords.z < ${n-1};\n\n // In parallel, construct four corners for all four components in\n // packed 2x2 cell.\n vec4 topLeft = vec4(\n getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d),\n hasNextCol ? getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n vec4 bottomLeft = vec4(\n getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d),\n hasNextCol ? getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n vec4 topRight = vec4(\n getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d),\n hasNextCol ? getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n vec4 bottomRight = vec4(\n getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d),\n hasNextCol ? getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n vec3 fracRC = sourceFracIndexRC - vec3(sourceFloorRC);\n\n vec4 top = mix(topLeft, topRight, fracRC.yyzz);\n vec4 bottom = mix(bottomLeft, bottomRight, fracRC.yyzz);\n vec4 newValue = mix(top, bottom, fracRC.x);\n\n setOutput(newValue);\n }\n `}}const hB={kernelName:fr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:a}=t,{alignCorners:i,halfPixelCenters:s,size:o}=r,[u,l]=o,c=Ge().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new dB(a.shape,u,l,i,s):new pB(a.shape,u,l,i,s);return n.runWebGLProgram(c,[a],"float32")}};class fB{constructor(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;const[,r,a]=t,[,i,s]=e,o=[n&&i>1?r-1:r,n&&s>1?a-1:a],u=[n&&i>1?i-1:i,n&&s>1?s-1:s],l=o[0]/u[0],c=o[1]/u[1],p=1/l,d=1/c,h=2*Math.ceil(p)+2,f=2*Math.ceil(d)+2;this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n int r = coords[1];\n int c = coords[2];\n\n float accumulator = 0.0;\n\n const float heightScale = float(${l});\n const float widthScale = float(${c});\n\n const float invHeightScale = float(${p});\n const float invWidthScale = float(${d});\n\n const int winHeight = int(${h});\n const int winWidth = int(${f});\n\n // Compute bounds for where in dy we will look\n float startRLerp = floor(float(r) * invHeightScale);\n int startDyR = int(startRLerp - float(winHeight / 2));\n\n float startCLerp = floor(float(c) * invWidthScale);\n int startDyC = int(startCLerp - float(winWidth / 2));\n\n // Loop over dy\n for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {\n int dyR = dyROffset + startDyR;\n\n // Guard against the window exceeding the bounds of dy\n if (dyR < 0 || dyR >= ${i}) {\n continue;\n }\n\n for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {\n int dyC = dyCOffset + startDyC;\n\n // Guard against the window exceeding the bounds of dy\n if (dyC < 0 || dyC >= ${s}) {\n continue;\n }\n\n float dxR = float(dyR) * heightScale;\n int topDxRIndex = int(floor(dxR));\n int bottomDxRIndex = int(min(ceil(dxR), ${r-1}.0));\n float dxRLerp = dxR - float(topDxRIndex);\n float inverseDxRLerp = 1.0 - dxRLerp;\n\n float dxC = float(dyC) * widthScale;\n int leftDxCIndex = int(floor(dxC));\n int rightDxCIndex = int(min(ceil(dxC), ${a-1}.0));\n float dxCLerp = dxC - float(leftDxCIndex);\n float inverseDxCLerp = 1.0 - dxCLerp;\n\n if (r == topDxRIndex && c == leftDxCIndex) {\n // topLeft\n accumulator +=\n getDy(b, dyR, dyC, d) * inverseDxRLerp * inverseDxCLerp;\n }\n\n if (r == topDxRIndex && c == rightDxCIndex) {\n // topRight\n accumulator += getDy(b, dyR, dyC, d) * inverseDxRLerp * dxCLerp;\n }\n\n if (r == bottomDxRIndex && c == leftDxCIndex) {\n // bottomLeft\n accumulator += getDy(b, dyR, dyC, d) * dxRLerp * inverseDxCLerp;\n }\n\n if (r == bottomDxRIndex && c == rightDxCIndex) {\n // bottomRight\n accumulator += getDy(b, dyR, dyC, d) * dxRLerp * dxCLerp;\n }\n }\n }\n // End loop over dy\n\n setOutput(accumulator);\n }\n `}}const mB={kernelName:mr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:a,dy:i}=t,{alignCorners:s}=r,o=new fB(i.shape,a.shape,s);return n.runWebGLProgram(o,[i],i.dtype)}};class gB{constructor(e,t,n,r,a){this.variableNames=["A"],this.outputShape=[];const[i,s,o,u]=e;this.outputShape=[i,t,n,u];const l=[r&&t>1?s-1:s,r&&n>1?o-1:o],c=[r&&t>1?t-1:t,r&&n>1?n-1:n],p=r?"0.5":"0.0";let d;d=a?"max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))":"vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n ${l[0]/c[0]},\n ${l[1]/c[1]});\n const vec2 inputShapeRC = vec2(${s}.0, ${o}.0);\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n ivec2 yRC = coords.yz;\n\n // Fractional source index.\n vec2 sourceFracIndexRC = ${d};\n\n // Compute the coordinators of nearest neighbor point.\n ivec2 sourceNearestRC = ivec2(\n min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${p})));\n float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d);\n\n setOutput(newValue);\n }\n `}}class yB{constructor(e,t,n,r,a){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[i,s,o,u]=e;this.outputShape=[i,t,n,u];const l=[r&&t>1?s-1:s,r&&n>1?o-1:o],c=[r&&t>1?t-1:t,r&&n>1?n-1:n],p=r?"0.5":"0.0";let d;d=a?"max((vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC, vec3(0.0))":"vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec3 effectiveInputOverOutputRatioRC = vec3(\n ${l[0]/c[0]},\n ${l[1]/c[1]},\n ${l[1]/c[1]});\n const vec3 inputShapeRC = vec3(${s}.0, ${o}.0,\n ${o}.0);\n\n float getAValue(int b, int r, int c, int d) {\n return getChannel(getA(b, r, c, d), vec2(c, d));\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n // Calculate values for next column in yRC.z.\n ivec3 yRC = coords.yzz + ivec3(0, 0, 1);\n\n // Fractional source index.\n vec3 sourceFracIndexRC = ${d};\n\n // Compute the coordinators of nearest neighbor point.\n ivec3 sourceNearestRC = ivec3(\n min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${p})));\n\n // Should we calculate next column and row elements in 2x2 packed cell.\n bool hasNextCol = d < ${u-1};\n bool hasNextRow = coords.z < ${n-1};\n\n vec4 newValue = vec4(\n getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d),\n hasNextCol ? getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d + 1) : 0.0);\n\n setOutput(newValue);\n }\n `}}const bB={kernelName:dr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:a}=t,{alignCorners:i,halfPixelCenters:s,size:o}=r,[u,l]=o,c=Ge().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new yB(a.shape,u,l,i,s):new gB(a.shape,u,l,i,s);return n.runWebGLProgram(c,[a],a.dtype)}};class xB{constructor(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;const[,r,a]=t,[,i,s]=e,o=[n&&i>1?r-1:r,n&&s>1?a-1:a],u=[n&&i>1?i-1:i,n&&s>1?s-1:s],l=o[0]/u[0],c=o[1]/u[1],p=1/l,d=1/c,h=2*Math.ceil(p)+2,f=2*Math.ceil(d)+2;this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n int r = coords[1];\n int c = coords[2];\n\n float accumulator = 0.0;\n\n const float heightScale = float(${l});\n const float widthScale = float(${c});\n\n const float invHeightScale = float(${p});\n const float invWidthScale = float(${d});\n\n const int winHeight = int(${h});\n const int winWidth = int(${f});\n\n // Compute bounds for where in dy we will look\n float startRLerp = floor(float(r) * invHeightScale);\n int startDyR = int(floor(startRLerp - float(winHeight / 2)));\n\n float startCLerp = floor(float(c) * invWidthScale);\n int startDyC = int(floor(startCLerp - float(winWidth / 2)));\n\n // Loop over dy\n for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {\n int dyR = dyROffset + startDyR;\n\n // Guard against the window exceeding the bounds of dy\n if (dyR < 0 || dyR >= ${i}) {\n continue;\n }\n\n for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {\n int dyC = dyCOffset + startDyC;\n\n // Guard against the window exceeding the bounds of dy\n if (dyC < 0 || dyC >= ${s}) {\n continue;\n }\n\n float sourceFracRow =\n float(${o[0]}) *\n (float(dyR) / float(${u[0]}));\n\n float sourceFracCol =\n float(${o[1]}) *\n (float(dyC) / float(${u[1]}));\n\n int sourceNearestRow = int(min(\n float(int(${r}) - 1),\n ${n} ? float(round(sourceFracRow)) :\n float(floor(sourceFracRow))));\n\n int sourceNearestCol = int(min(\n float(int(${a}) - 1),\n ${n} ? float(round(sourceFracCol)) :\n float(floor(sourceFracCol))));\n\n if (r == sourceNearestRow && c == sourceNearestCol) {\n accumulator += getDy(b, dyR, dyC, d);\n }\n }\n }\n // End loop over dy\n\n setOutput(accumulator);\n }\n `}}const vB={kernelName:hr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:a,dy:i}=t,{alignCorners:s}=r,o=new xB(i.shape,a.shape,s);return n.runWebGLProgram(o,[i],i.dtype)}};class _B{constructor(e,t){this.variableNames=["x"];const n=e.length;if(n>4)throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`);if(this.outputShape=e,1===n)return void(this.userCode=`\n void main() {\n int coord = getOutputCoords();\n setOutput(getX(${e[0]} - coord - 1));\n }\n `);const r=e.map(((n,r)=>(n=>-1!==t.indexOf(n)&&1!==e[n]?`${e[n]} - coords[${n}] - 1`:`coords[${n}]`)(r))).join(","),a=AL(n);this.userCode=`\n void main() {\n ${a} coords = getOutputCoords();\n setOutput(getX(${r}));\n }\n `}}class wB{constructor(e,t){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;const n=e.length;if(n>4)throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`);this.outputShape=e;const r=H$("rc",n),a=`${r[n-1]} + 1 < ${this.outputShape[n-1]}`,i=`${r[n-2]} + 1 < ${this.outputShape[n-2]}`,s=AL(n);function o(n){const r=e.map(((r,a)=>function(n,r){return-1!==t.indexOf(n)&&1!==e[n]?`${e[n]} - ${r[n]} - 1`:`${r[n]}`}(a,n)));return`getChannel(getX(${r.join(",")}), vec2(${r.slice(-2).join(",")}))`}this.userCode=1===n?`\n void main(){\n int rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = getChannel(getX(${e[0]} - rc - 1),\n ${e[0]} - rc - 1);\n if(${a}){\n result.g = getChannel(getX(${e[0]} - (rc + 1) - 1),\n ${e[0]} - (rc + 1) - 1);\n }\n setOutput(result);\n }\n `:`\n void main() {\n ${s} rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = ${function(e){return o(e)}(r.slice())};\n if(${a}){\n result.g = ${function(e){return e[n-1]="("+e[n-1]+" + 1)",o(e)}(r.slice())};\n }\n if(${i}) {\n result.b = ${function(e){return e[n-2]="("+e[n-2]+" + 1)",o(e)}(r.slice())};\n if(${a}) {\n result.a = ${function(e){return e[n-1]="("+e[n-1]+" + 1)",e[n-2]="("+e[n-2]+" + 1)",o(e)}(r.slice())};\n }\n }\n setOutput(result);\n }\n `}}const MB={kernelName:yr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{dims:i}=r,s=a.shape.length,o=ve(i,a.shape);if(0===s)return sO({inputs:{x:a},backend:n});const u=Ge().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new wB(a.shape,o):new _B(a.shape,o);return n.runWebGLProgram(u,[a],a.dtype)}};class NB{constructor(e,t){this.variableNames=["Image"],this.outputShape=[],this.customUniforms=[{name:"params",type:"vec4"}];const n=e[1],r=e[2];this.outputShape=e;let a="";a="number"==typeof t?`float outputValue = ${t.toFixed(2)};`:`\n vec3 fill = vec3(${t.join(",")});\n float outputValue = fill[coords[3]];`,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int x = coords[2];\n int y = coords[1];\n float coordXFloat = (float(x) - params[0]) * params[3] -\n (float(y) - params[1]) * params[2];\n float coordYFloat = (float(x) - params[0]) * params[2] +\n (float(y) - params[1]) * params[3];\n int coordX = int(round(coordXFloat + params[0]));\n int coordY = int(round(coordYFloat + params[1]));\n ${a}\n if(coordX >= 0 && coordX < ${r} && coordY >= 0 && coordY < ${n}) {\n outputValue = getImage(coords[0], coordY, coordX, coords[3]);\n }\n setOutput(outputValue);\n }\n `}}const SB={kernelName:sa,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{image:r}=e,{radians:a,fillValue:i,center:s}=t,o=n,u=new NB(r.shape,i),[l,c]=nf(s,r.shape[1],r.shape[2]),p=[[l,c,Math.sin(a),Math.cos(a)]];return o.runWebGLProgram(u,[r],r.dtype,p)}},kB=gO({opSnippet:"\n // OpenGL ES does not support round function.\n // The algorithm is based on banker's rounding.\n float base = floor(x);\n if ((x - base) < 0.5) {\n return floor(x);\n } else if ((x - base) > 0.5) {\n return ceil(x);\n } else {\n if (mod(base, 2.0) == 0.0) {\n return base;\n } else {\n return base + 1.0;\n }\n }\n"}),DB={kernelName:br,backendName:"webgl",kernelFunc:kB},TB=gO({opSnippet:"return inversesqrt(x);",cpuKernelImpl:M$}),IB={kernelName:xr,backendName:"webgl",kernelFunc:TB};class EB{constructor(e,t,n,r,a,i,s=!0){this.variableNames=["updates","indices","defaultValue"],this.outputShape=i;const o=AL(a.length),u=AL(i.length);let l="";1===n?l="i":2===n&&(l="i, j");const c=`getIndices(${l})`;let p="";1===r?p="i":2===r&&(p="i, coords[1]");const d=`getUpdates(${p})`,h=t>1?"strides[j]":"strides";this.userCode=`\n ${o} strides = ${o}(${a});\n\n void main() {\n ${u} coords = getOutputCoords();\n float sum = 0.0;\n bool found = false;\n for (int i = 0; i < ${e}; i++) {\n int flattenedIndex = 0;\n for (int j = 0; j < ${t}; j++) {\n int index = round(${c});\n flattenedIndex += index * ${h};\n }\n if (flattenedIndex == coords[0]) {\n sum += ${d};\n found = true;\n }\n }\n setOutput(mix(getDefaultValue(), sum, float(found)));\n }\n `}}const CB={kernelName:vr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{indices:a,updates:i}=t,{shape:s}=r,{sliceRank:o,numUpdates:u,sliceSize:l,strides:c,outputSize:p}=jo(0,a,s),d=[p/l,l];if(0===p)return n.makeTensorInfo(s,a.dtype);const h=NO({inputs:{x:a},backend:n,attrs:{shape:[u,o]}}),f=NO({inputs:{x:i},backend:n,attrs:{shape:[u,l]}}),m=n.makeTensorInfo([],"float32",new Float32Array([0])),g=new EB(u,o,h.shape.length,f.shape.length,c,d),y=n.runWebGLProgram(g,[f,h,m],f.dtype),b=NO({inputs:{x:y},backend:n,attrs:{shape:s}});return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(y),n.disposeIntermediateTensorInfo(m),b}};class AB{constructor(e,t,n,r){this.variableNames=["sortedSequence","values"],this.customUniforms=[{name:"numInputs",type:"int"}],this.outputShape=[e,n];const a=`for (int i = 0; i < ${Math.ceil(Math.log2(t+1))}; ++i) { if (left >= right) break;`,i=2===Ge().getNumber("WEBGL_VERSION")?"while (left < right) {":a,s="left"===r?"<":"<=";this.userCode=`\n int findBound(int batch, float value) {\n int left = 0;\n int right = numInputs;\n int mid;\n ${i}\n mid = (left + right) / 2;\n if (getSortedSequence(batch, mid) ${s} value) {\n left = mid + 1;\n } else {\n right = mid;\n }\n }\n return right;\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int valueIndex = coords[1];\n\n float value = getValues(batch, valueIndex);\n\n setOutput(float(findBound(batch, value)));\n }\n `}}const LB={kernelName:_r,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{sortedSequence:a,values:i}=t,{side:s}=r,o=new AB(a.shape[0],a.shape[1],i.shape[1],s),u=[[a.shape[1]]];return n.runWebGLProgram(o,[a,i],"int32",u)}};class $B{constructor(e,t,n){let r,a;if(this.variableNames=["c","a","b"],this.outputShape=t,n>4)throw Error(`Where for rank ${n} is not yet supported`);if(1===n)a="resRC",r="resRC";else{const n=["resRC.x","resRC.y","resRC.z","resRC.w"],i=[],s=[];for(let r=0;r= 1.0) {\n setOutput(getA(${a}));\n } else {\n setOutput(getB(${a}));\n }\n }\n `}}const OB={kernelName:wr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{condition:r,t:a,e:i}=t,s=new $B(r.shape.length,a.shape,a.shape.length);return n.runWebGLProgram(s,[r,a,i],ci(a.dtype,i.dtype))}},RB=gO({opSnippet:`\n // Stable and Attracting Fixed Point (0, 1) for Normalized Weights.\n // see: https://arxiv.org/abs/1706.02515\n float scaleAlpha = ${lf};\n float scale = ${cf};\n return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);\n`}),FB={kernelName:Mr,backendName:"webgl",kernelFunc:RB},YB=gO({opSnippet:"if (isnan(x)) return x;\n return 1.0 / (1.0 + exp(-1.0 * x));\n",packedOpSnippet:"\n vec4 result = 1.0 / (1.0 + exp(-1.0 * x));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n",cpuKernelImpl:S$}),zB={kernelName:Tr,backendName:"webgl",kernelFunc:YB},BB=gO({opSnippet:"\n if (isnan(x)) { return 0.0; }\n return sign(x);\n"}),PB={kernelName:Dr,backendName:"webgl",kernelFunc:BB},HB=gO({opSnippet:"if (isnan(x)) return x;\n return sin(x);\n"}),jB={kernelName:Sr,backendName:"webgl",kernelFunc:HB},UB=gO({opSnippet:"\n float e2x = exp(x);\n return (e2x - 1.0 / e2x) / 2.0;\n"}),qB={kernelName:kr,backendName:"webgl",kernelFunc:UB},WB=gO({opSnippet:"\n float epsilon = 1.1920928955078125e-7;\n float threshold = log(epsilon) + 2.0;\n\n bool too_large = x > -threshold;\n bool too_small = x < threshold;\n\n float result;\n float exp_x = exp(x);\n\n if (too_large){\n result = x;\n }\n else if (too_small){\n result = exp_x;\n }\n else{\n result = log(exp_x + 1.0);\n }\n return result;\n"}),VB={kernelName:Ir,backendName:"webgl",kernelFunc:WB},GB={kernelName:Ar,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockShape:i,paddings:s}=r;se(a.shape.length<=4,(()=>"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet"));const o=i.reduce(((e,t)=>e*t)),u=[[0,0]];u.push(...s);for(let e=1+i.length;en.disposeIntermediateTensorInfo(e))),g}},KB={kernelName:Or,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{indices:r,values:a,denseShape:i,defaultValue:s}=t;if(1!==i.shape.length)throw new Error(`Dense shape must be a vector, saw:\n ${i.shape}`);if(2!==r.shape.length)throw new Error(`Indices must be a matrix, saw:\n ${r.shape}`);if(1!==a.shape.length)throw new Error(`Values must be a vector, saw:\n ${a.shape}`);if(0!==s.shape.length)throw new Error(`Default value must be a scalar, saw:\n ${s.shape}`);const o=n.readSync(r.dataId),u=n.readSync(a.dataId),l=n.readSync(i.dataId),c=n.readSync(s.dataId)[0],[p,d,h,f,m]=T$(o,r.shape,r.dtype,u,a.dtype,l,c);return[n.makeTensorInfo(d,r.dtype,p),n.makeTensorInfo([d[0]],a.dtype,h),n.makeTensorInfo([f.length],"bool",new Uint8Array(f.map((e=>Number(e))))),n.makeTensorInfo([m.length],r.dtype,new Int32Array(m))]}},JB={kernelName:Rr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{inputIndices:r,inputShape:a,newShape:i}=t;if(2!==r.shape.length)throw new Error(`Input indices should be a matrix but received shape ${r.shape}`);if(1!==a.shape.length)throw new Error(`Input shape should be a vector but received shape ${a.shape}`);if(1!==i.shape.length)throw new Error(`Target shape should be a vector but received shape ${i.shape}`);const s=Array.from(n.readSync(a.dataId)),o=n.readSync(r.dataId),u=Array.from(n.readSync(i.dataId)),[l,c,p]=I$(o,r.shape,r.dtype,s,u);return[n.makeTensorInfo(c,r.dtype,l),n.makeTensorInfo([p.length],i.dtype,new Int32Array(p))]}},XB={kernelName:Fr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{data:r,indices:a,segmentIds:i}=t;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.shape.length)throw new Error(`Indices should be a vector but received shape\n ${a.shape}`);if(1!==i.shape.length)throw new Error(`Segment ids should be a vector but received shape\n ${i.shape}`);const s=n.readSync(r.dataId),o=n.readSync(a.dataId),u=n.readSync(i.dataId),[l,c]=E$(s,r.shape,r.dtype,o,u,!0);return n.makeTensorInfo(c,r.dtype,l)}},ZB={kernelName:Yr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{data:r,indices:a,segmentIds:i}=t;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.shape.length)throw new Error(`Indices should be a vector but received shape\n ${a.shape}`);if(1!==i.shape.length)throw new Error(`Segment ids should be a vector but received shape\n ${i.shape}`);const s=n.readSync(r.dataId),o=n.readSync(a.dataId),u=n.readSync(i.dataId),[l,c]=E$(s,r.shape,r.dtype,o,u);return n.makeTensorInfo(c,r.dtype,l)}},QB={kernelName:zr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{sparseIndices:a,sparseValues:i,defaultValue:s}=t,{outputShape:o}=r,{sliceRank:u,numUpdates:l,sliceSize:c,strides:p,outputSize:d}=jo(0,a,o);if("string"===i.dtype){const e=n.bufferSync(a),t=n.bufferSync(i),r=Ha(n.readSync(s.dataId)[0]),h=N$(e,t,o,d,c,l,u,p,r,!1);return n.makeTensorInfo(o,h.dtype,h.values)}const h=new EB(l,u,a.shape.length,i.shape.length,p,[d,1],!1),f=n.runWebGLProgram(h,[i,a,s],i.dtype),m=NO({inputs:{x:f},backend:n,attrs:{shape:o}});return n.disposeIntermediateTensorInfo(f),m}},eP={kernelName:Lr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{numOrSizeSplits:i,axis:s}=r,o=ve(s,a.shape)[0],u=Af(a,i,o),l=a.shape.length,c=new Array(l).fill(0),p=a.shape.slice();return u.map((e=>{const t=[...p];t[o]=e;const r=ER({inputs:{x:a},backend:n,attrs:{begin:c,size:t}});return c[o]+=e,r}))}},tP="return sqrt(x);",nP=gO({opSnippet:tP,packedOpSnippet:tP,cpuKernelImpl:C$}),rP={kernelName:Er,backendName:"webgl",kernelFunc:nP},aP=gO({opSnippet:"return x * x;"}),iP={kernelName:Pr,backendName:"webgl",kernelFunc:aP},sP="return (a - b) * (a - b);",oP=yO({opSnippet:sP,packedOpSnippet:sP}),uP={kernelName:Br,backendName:"webgl",kernelFunc:oP},lP={kernelName:aa,backendName:"webgl",kernelFunc:function({inputs:e,attrs:t,backend:n}){const{x:r}=e,a=`if (isnan(x)) return x;\n return x > 0.0 ? 1.0 : float(${t.alpha});\n `,i=new K$(r.shape,a);return n.runWebGLProgram(i,[r],r.dtype)}};class cP{constructor(e,t,n){this.variableNames=["x"],this.outputShape=n;const r=n.length,a=AL(n.length),i=AL(n.length);let s="";if(1===r)s="coords * strides + begin";else{let e=0;s=n.map(((t,r)=>(e++,1===n.length?`coords * strides[${r}] + begin[${r}]`:`coords[${e-1}] * strides[${r}] + begin[${r}]`))).join(",")}this.userCode=`\n ${a} begin = ${a}(${e});\n ${a} strides = ${a}(${t});\n\n void main() {\n ${i} coords = getOutputCoords();\n setOutput(getX(${s}));\n }\n `}}const pP={kernelName:Hr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{begin:i,end:s,strides:o,beginMask:u,endMask:l,ellipsisMask:c,newAxisMask:p,shrinkAxisMask:d}=r,{finalShapeSparse:h,finalShape:f,isIdentity:m,sliceDim0:g,isSimpleSlice:y,begin:b,end:x,strides:v}=iu(a.shape,i,s,o,u,l,c,p,d);let _;if(m)_=NO({inputs:{x:a},backend:n,attrs:{shape:f}});else if(g||y){se(a.shape.length>=1,(()=>`Input must have rank at least 1, got: ${a.shape.length}`));const e=Wo(b,x,v),t=ER({inputs:{x:a},backend:n,attrs:{begin:b,size:e}});_=NO({inputs:{x:t},backend:n,attrs:{shape:f}}),n.disposeIntermediateTensorInfo(t)}else if(n.shouldExecuteOnCPU([a])){const e=n.readSync(a.dataId),t=As(a.shape,a.dtype,e),r=A$(h,t,v,b);_=n.makeTensorInfo(f,a.dtype,r.values)}else{const e=new cP(b,v,h);_=n.runWebGLProgram(e,[a],a.dtype)}const w=NO({inputs:{x:_},backend:n,attrs:{shape:f}});return n.disposeIntermediateTensorInfo(_),w}},dP={kernelName:jr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{separator:a,nGramWidths:i,leftPad:s,rightPad:o,padWidth:u,preserveShortSequences:l}=r,{data:c,dataSplits:p}=t,d=n.readSync(c.dataId),h=n.readSync(p.dataId),[f,m]=L$(d,h,a,i,s,o,u,l);return[n.makeTensorInfo([f.length],"string",f),n.makeTensorInfo(p.shape,"int32",m)]}},hP={kernelName:Ur,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{skipEmpty:a}=r,{input:i,delimiter:s}=t;if("string"!==i.dtype)throw new Error("Input must be of datatype string");if(1!==i.shape.length)throw new Error(`Input must be a vector, got shape: ${i.shape}`);if(0!==s.shape.length)throw new Error(`Delimiter must be a scalar, got shape: ${s.shape}`);const o=n.readSync(i.dataId),u=n.readSync(s.dataId)[0],[l,c,p]=$$(o,u,a),d=c.length;return[n.makeTensorInfo([d,2],"int32",l),n.makeTensorInfo([d],"string",c),n.makeTensorInfo([2],"int32",new Int32Array(p))]}},fP={kernelName:qr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{numBuckets:a}=r,{input:i}=t;if("string"!==i.dtype)throw new Error("Input must be of datatype string");if(a<=0)throw new Error("Number of buckets must be at least 1");const s=n.readSync(i.dataId),o=O$(s,a);return n.makeTensorInfo(i.shape,"int32",o)}},mP=gO({opSnippet:"return tan(x);"}),gP={kernelName:Vr,backendName:"webgl",kernelFunc:mP},yP=gO({opSnippet:"\n float e2x = exp(-2.0 * abs(x));\n return sign(x) * (1.0 - e2x) / (1.0 + e2x);\n"}),bP={kernelName:Gr,backendName:"webgl",kernelFunc:yP};class xP{constructor(e,t){this.variableNames=["A"];const n=new Array(e.length);for(let r=0;r5)throw Error(`Tile for rank ${t} is not yet supported`);if(1===t)return`imod(resRC, ${e[0]})`;const n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],r=[];for(let t=0;t5){const e=n.readSync(a.dataId),t="string"===a.dtype?e.map((e=>Ha(e))):e,r=As(a.shape,a.dtype,t),s=F$(r,i);return n.makeTensorInfo(s.shape,s.dtype,s.values)}const s=new xP(a.shape,i);return n.runWebGLProgram(s,[a],a.dtype)}const _P={kernelName:Kr,backendName:"webgl",kernelFunc:vP};class wP{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="\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int elemIdx = coords[1];\n\n // We compare elements pair-wise within a group of size 2 * inc.\n // The comparing rule for each group alternates between ascending\n // and descending. Within each group, we compare each pair at\n // positions i and i+inc. To decide whether an element at position i\n // is x0 or x1, we mod it by 2 * inc, if the result is smaller than\n // inc, it is in the first half of the group, we denote it as x0,\n // otherwise we denote it as x1.\n // For example, as shown in the Bitonic top K paper referenced above,\n // Figure5(a) shows that element[1] is in the\n // second half of the group when group size is 2, but it is in the\n // first half of the group when group size is 4.\n\n bool isFirstInPair = imod(elemIdx, 2 * inc) < inc;\n int i = isFirstInPair ? elemIdx : elemIdx - inc;\n\n int i0 = firstPass == 1 ? i : int(getIndices(batch, i));\n int i1 = firstPass == 1 ? i + inc : int(getIndices(batch, i + inc));\n float x0 = i0 < n ? getX(batch, i0) : negativeInf;\n float x1 = i1 < n ? getX(batch, i1) : negativeInf;\n\n // Denotes which direction indices are in (ascending or descending).\n bool reverse = imod(elemIdx, 2 * dir) >= dir;\n bool isGreater = x0 > x1 || (x0 == x1 && i1 > i0);\n if (reverse == isGreater) { // Elements in opposite order of direction\n int iTemp = i0;\n i0 = i1;\n i1 = iTemp;\n }\n if (isFirstInPair) {\n setOutput(float(i0));\n } else {\n setOutput(float(i1));\n }\n }\n "}}class MP{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="\n void main() {\n // Takes max of indices (0, k), (1, k + 1), (2, k + 2) ...\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int elemIdx = coords[1];\n\n // The output size is half of the previous size.\n // If the previous sequence is | | | | _ _ _ _ | | | | _ _ _ _ (k=4),\n // we only need to output the indices at positions |, the indices at\n // positions _ can be thrown away, see Figure5(b) After Phase 2\n // (Merge phase) in the Bitonic Top K paper referenced above.\n // For example, the paper shows we only need to output the orange bars.\n // The output sequence should look like this | | | | | | | |.\n // Because the sequence is halved, to map the output index back\n // to the previous sequence to find the corresponding value,\n // we need to double the index. When we double the index,\n // we basically interpolate a position, so 2i looks like\n // | _ | _ | _ | _ | _ | _ | _. We move the | to the first k position\n // of each 2k positions by - elemIdx % k. E.g. for output at\n // index 4,5,6,7, we want to get the corresponding element at\n // original index 8,9,10,11, for output at index 8,9,10,11,\n // we want to get the corresponding element at original index\n // 16,17,18,19, so on and so forth.\n\n int i = elemIdx < k ? elemIdx : (elemIdx * 2 - imod(elemIdx, k));\n int i0 = firstPass == 1 ? i : int(getIndices(batch, i));\n int i1 = firstPass == 1 ? i + k : int(getIndices(batch, i + k));\n\n float x0 = getX(batch, i0);\n float x1 = i1 < n ? getX(batch, i1) : x0;\n\n setOutput(x0 >= x1 ? float(i0) : float(i1));\n }\n "}}function NP(e,t){null!==t&&e.disposeIntermediateTensorInfo(t)}function SP(e){let t=1;for(;tu){const e=n.readSync(a.dataId),[t,r]=Y$(e,l,a.dtype,i,s);return[n.makeTensorInfo(t.shape,t.dtype,t.values),n.makeTensorInfo(r.shape,r.dtype,r.values)]}if(0===i)return l[l.length-1]=0,[n.makeTensorInfo(l,a.dtype,[]),n.makeTensorInfo(l,"int32",[])];if(1===c)return[a,pY({attrs:{shape:l,dtype:"int32",value:0},backend:n})];const p=n.texData.get(a.dataId),d=null!==p&&p.isPacked,h=d?n.unpackTensor(a):a,f=ce(l)/c,m=NO({inputs:{x:h},attrs:{shape:[f,c]},backend:n});d&&NP(n,h);const g=SP(i),y=SP(c);let b=null;const x=()=>null===b?[m,m]:[m,b],v=(e,t,r)=>{const a=x(),i=new wP(r),s=[[c],[null===b?1:0],[Number.NEGATIVE_INFINITY],[e],[t]],o=b;b=n.runWebGLProgram(i,a,"int32",s),NP(n,o)};for(let e=1;e=1;n/=2)v(t,n,[f,y])}for(let e=y;e>g;e/=2){const t=x(),r=new MP([f,e/2]),a=[[c],[null===b?1:0],[g]],i=b;b=n.runWebGLProgram(r,t,"int32",a),NP(n,i);const s=g/2,o=2*s;for(let e=s;e>=1;e/=2)v(o,e,b.shape)}let _=b;b=ER({inputs:{x:b},backend:n,attrs:{begin:0,size:[f,i]}}),NP(n,_);let w=IY({inputs:{x:m,indices:b},backend:n,attrs:{axis:1,batchDims:1}});NP(n,m);const M=l.slice(0,-1);M.push(i),_=b,b=NO({inputs:{x:b},attrs:{shape:M},backend:n}),NP(n,_);const N=w;return w=NO({inputs:{x:w},attrs:{shape:M},backend:n}),NP(n,N),[w,b]}};class DP{constructor(e,t,n,r,a,i){this.variableNames=["Image","Transforms"],this.outputShape=i;const s="nearest"===n?1:2;let o;switch(r){case"constant":default:o=1;break;case"reflect":o=2;break;case"wrap":o=3;break;case"nearest":o=4}this.userCode=`\n float mapCoord(float outCoord, float len) {\n float inCoord = outCoord;\n if(${o} == 2) {\n if (inCoord < 0.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz2 = 2.0 * len;\n if (inCoord < sz2) {\n inCoord = sz2 * float(int(float(-inCoord / sz2))) +\n inCoord;\n }\n inCoord = inCoord < -len ? inCoord + sz2 : -inCoord - 1.0;\n }\n } else if (inCoord > len - 1.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz2 = 2.0 * len;\n inCoord -= sz2 * float(int(float(inCoord / sz2)));\n if (inCoord >= len) {\n inCoord = sz2 - inCoord - 1.0;\n }\n }\n }\n return clamp(inCoord, 0.0, len - 1.0);\n } else if (${o} == 3) {\n if (inCoord < 0.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz = len - 1.0;\n inCoord += len * (float(int(float(-inCoord / sz))) + 1.0);\n }\n } else if (inCoord > len - 1.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz = len - 1.0;\n inCoord -= len * float(int(float(inCoord / sz)));\n }\n }\n return clamp(inCoord, 0.0, len - 1.0);\n } else if (${o} == 4) {\n return clamp(outCoord, 0.0, len - 1.0);\n } else {\n return outCoord;\n }\n }\n\n float readWithFillValue(int batch, int coordY, int coordX,\n int channel) {\n float outputValue;\n if (0 <= coordY && coordY < ${e} && 0 <= coordX && coordX < ${t}) {\n outputValue = getImage(batch, coordY, coordX, channel);\n } else {\n outputValue = float(${a});\n }\n return outputValue;\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n float outputValue;\n int batch = coords[0];\n int x = coords[2];\n int y = coords[1];\n int channel = coords[3];\n float xf = float(x);\n float yf = float(y);\n float a1 = getTransforms(batch, 0);\n float a2 = getTransforms(batch, 1);\n float a3 = getTransforms(batch, 2);\n float b1 = getTransforms(batch, 3);\n float b2 = getTransforms(batch, 4);\n float b3 = getTransforms(batch, 5);\n float c1 = getTransforms(batch, 6);\n float c2 = getTransforms(batch, 7);\n float projection = c1 * xf + c2 * yf + 1.0;\n if (projection == 0.0) {\n outputValue = float(${a});\n } else {\n float inX = (a1 * xf + a2 * yf + a3) / projection;\n float inY = (b1 * xf + b2 * yf + b3) / projection;\n float mapX = mapCoord(inX, float(${t}));\n float mapY = mapCoord(inY, float(${e}));\n\n if (${s} == 1) {\n int coordY = int(round(mapY));\n int coordX = int(round(mapX));\n outputValue = readWithFillValue(batch, coordY, coordX,\n channel);\n } else {\n float yFloor = floor(mapY);\n float xFloor = floor(mapX);\n float yCeil = yFloor + 1.0;\n float xCeil = xFloor + 1.0;\n float valueYFloor = (xCeil - mapX) *\n readWithFillValue(batch, int(yFloor), int(xFloor), channel) +\n (mapX - xFloor) *\n readWithFillValue(batch, int(yFloor), int(xCeil), channel);\n float valueYCeil = (xCeil - mapX) *\n readWithFillValue(batch, int(yCeil), int(xFloor), channel) +\n (mapX - xFloor) *\n readWithFillValue(batch, int(yCeil), int(xCeil), channel);\n outputValue = (yCeil - mapY) * valueYFloor +\n (mapY - yFloor) * valueYCeil;\n }\n }\n setOutput(outputValue);\n }\n `}}const TP={kernelName:Xr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{image:a,transforms:i}=t,{interpolation:s,fillMode:o,fillValue:u,outputShape:l}=r,[c,p,d,h]=a.shape,[f,m]=null!=l?l:[p,d],g=new DP(p,d,s,o,u,[c,f,m,h]);return n.runWebGLProgram(g,[a,i],"float32")}},IP={kernelName:Qr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,{axis:a}=n,{x:i}=t;mL(i,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");const s=r.readSync(i.dataId),{outputValues:o,outputShape:u,indices:l}=B$(s,a,i.shape,i.dtype);return[r.makeTensorInfo(u,i.dtype,o),r.makeTensorInfo([l.length],"int32",l)]}},EP={kernelName:ea,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{value:a}=t;let{axis:i}=r;i<0&&(i+=a.shape.length);const s=a,o=s.shape.length,u=a.shape[i],l=new Array(o-1);let c=0;for(let e=0;en.disposeIntermediateTensorInfo(e))),f}};class CP{constructor(e,t){this.variableNames=["x","segmentIds"];const n=e.windowSize,r=e.batchSize,a=e.inSize,i=e.numSegments,s=i*Math.ceil(a/n);this.outputShape=[r,s];const o=4*Math.floor(n/4),u=n%4,l="\n sumValue += dot(values, segFilter);\n ";let c="";a%n>0&&(c=`\n if (inIdx < 0 || inIdx >= ${a}) {\n return initializationValue;\n }\n `);let p="";a%n>0&&(p=`\n if (inIdx < 0 || inIdx >= ${a}) {\n return -1.0;\n }\n `),this.userCode=`\n const float initializationValue = 0.0;\n\n float getValue(int batch, int inIdx) {\n ${c}\n return getX(batch, inIdx);\n }\n\n float getSegmentIdAtIndex(int inIdx) {\n ${p}\n return getSegmentIds(inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = int(floor(float(outIdx) / float(\n ${i})) * float(${n}));\n int currentSeg = int(mod(float(outIdx), float(${i})));\n\n float sumValue = 0.0;\n\n for (int i = 0; i < ${o}; i += 4) {\n int inIdx = inOffset + i;\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 3)) == currentSeg ? 1 : 0\n );\n\n ${l}\n }\n\n int inIdx = inOffset + ${o};\n if (${1===u}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n int inIdxSeg = int(getSegmentIdAtIndex(inIdx));\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n 0,\n 0,\n 0\n );\n\n ${l}\n } else if (${2===u}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n initializationValue,\n initializationValue\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n 0,\n 0\n );\n\n ${l}\n } else if (${3===u}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n initializationValue\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,\n 0\n );\n\n ${l}\n }\n setOutput(sumValue);\n }\n `}}const AP={kernelName:ta,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,segmentIds:i}=t,{numSegments:s}=r,o=a.shape.length,u=[];let l=0;const c=xc([l],o);let p=a;null!=c&&(p=$O({inputs:{x:a},backend:n,attrs:{perm:c}}),u.push(p),l=_c(1,o)[0]);const d=Wf(p.shape,l,s),h=ce([p.shape[l]]),f=NO({inputs:{x:p},backend:n,attrs:{shape:[-1,h]}});u.push(f);const m=pi(a.dtype),g=(e,t,r,a,i)=>{const s=e.shape[0],o=e.shape[1],l=qf(o,i),c=new CP({windowSize:l,inSize:o,batchSize:s,numSegments:i},t),p=n.compileAndRun(c,[e,r],a);if(u.push(p),p.shape[1]===i)return p;const d=rB({backend:n,attrs:{start:0,stop:i,step:1,dtype:"float32"}}),h=vP({inputs:{x:d},backend:n,attrs:{reps:[o/l]}});return u.push(d),u.push(h),g(p,t,h,a,i)},y=NO({inputs:{x:g(f,"unsortedSegmentSum",i,m,s)},backend:n,attrs:{shape:d}});let b=y;if(null!=c){u.push(y);const e=vc(c);b=$O({inputs:{x:b},backend:n,attrs:{perm:e}})}return u.forEach((e=>n.disposeIntermediateTensorInfo(e))),b}},LP=[FO,zO,PO,jO,WO,KO,JO,XO,rR,aR,sR,uR,cR,dR,fR,yR,bR,_R,wR,MR,kR,AR,LR,$R,zR,HR,qR,lO,GR,nF,lF,fF,mF,gF,yF,bF,vF,wF,NF,EF,CF,AF,$F,FF,BF,PF,jF,qF,WF,GF,KF,XF,QF,tY,rY,sY,lY,dY,fY,yY,xY,wY,NY,SY,DY,EY,AY,$Y,oO,OY,QR,FY,zY,PY,dO,jY,qY,WY,GY,JY,ZY,ez,nz,iz,oz,lz,pz,dz,hz,gz,yz,bz,xz,vz,wz,Sz,Dz,Rz,MO,Fz,zz,Pz,jz,RR,qz,Gz,Kz,Qz,tB,mO,nB,aB,YR,Ez,sB,uB,cB,SO,hB,mB,bB,vB,MB,SB,DB,IB,CB,LB,OB,FB,zB,PB,jB,qB,CR,Oz,VB,GB,KB,JB,XB,ZB,QB,eP,rP,iP,uP,lP,pP,dP,hP,fP,Lz,LO,gP,bP,_P,kP,TP,OO,IP,EP,AP,Vz];for(const e of LP)ya(e);const $P={"tfjs-core":_u,"tfjs-backend-cpu":"3.19.0","tfjs-backend-webgl":"3.19.0","tfjs-data":Sk,"tfjs-layers":Bx,"tfjs-converter":bS,tfjs:"3.19.0"};function OP(){return OP=Object.assign?Object.assign.bind():function(e){for(var t=1;te[t]))}var AH=["Matrix","Array"],LH=["number","BigNumber","Fraction"];function $H(e,t){function n(n){if(n){var r=MH(e,wH);OH(n,"matrix",AH),OH(n,"number",LH),SH(e,n);var a=MH(e,wH),i=MH(n,wH);return t("config",a,r,i),a}return MH(e,wH)}return n.MATRIX_OPTIONS=AH,n.NUMBER_OPTIONS=LH,Object.keys(RP).forEach((t=>{Object.defineProperty(n,t,{get:()=>e[t],enumerable:!0,configurable:!0})})),n}function OH(e,t,n){void 0===e[t]||function(e,t){return-1!==e.indexOf(t)}(n,e[t])||console.warn('Warning: Unknown value "'+e[t]+'" for configuration option "'+t+'". Available options: '+n.map((e=>JSON.stringify(e))).join(", ")+".")}var RH=function(e){if(e)throw new Error("The global config is readonly. \nPlease create a mathjs instance if you want to change the default configuration. \nExample:\n\n import { create, all } from 'mathjs';\n const mathjs = create(all);\n mathjs.config({ number: 'BigNumber' });\n");return Object.freeze(RP)};OP(RH,RP,{MATRIX_OPTIONS:AH,NUMBER_OPTIONS:LH});var FH=n(3776);function YH(e,t,n,r){function a(r){var a=function(e,t){for(var n={},r=0;r!function(e){return e&&"?"===e[0]}(e))).every((e=>void 0!==n[e]))){var r=t.filter((e=>void 0===n[e]));throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(r.map((e=>'"'.concat(e,'"'))).join(", "),"."))}}(e,t,r),n(a)}return a.isFactory=!0,a.fn=e,a.dependencies=t.slice().sort(),r&&(a.meta=r),a}function zH(e){return"function"==typeof e&&"string"==typeof e.fn&&Array.isArray(e.dependencies)}function BH(e){return e&&"?"===e[0]?e.slice(1):e}var PH=YH("BigNumber",["?on","config"],(e=>{var{on:t,config:n}=e,r=FH.clone({precision:n.precision,modulo:FH.EUCLID});return r.prototype=Object.create(r.prototype),r.prototype.type="BigNumber",r.prototype.isBigNumber=!0,r.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},r.fromJSON=function(e){return new r(e.value)},t&&t("config",(function(e,t){e.precision!==t.precision&&r.config({precision:e.precision})})),r}),{isClass:!0}),HH=n(1977);function jH(e){return"boolean"==typeof e||!!isFinite(e)&&e===Math.round(e)}var UH=Math.sign||function(e){return e>0?1:e<0?-1:0},qH=Math.log2||function(e){return Math.log(e)/Math.LN2},WH=Math.log10||function(e){return Math.log(e)/Math.LN10},VH=Math.log1p||function(e){return Math.log(e+1)},GH=Math.cbrt||function(e){if(0===e)return e;var t,n=e<0;return n&&(e=-e),t=isFinite(e)?(e/((t=Math.exp(Math.log(e)/3))*t)+2*t)/3:e,n?-t:t},KH=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function JH(e,t,n){var r={2:"0b",8:"0o",16:"0x"}[t],a="";if(n){if(n<1)throw new Error("size must be in greater than 0");if(!jH(n))throw new Error("size must be an integer");if(e>2**(n-1)-1||e<-(2**(n-1)))throw new Error("Value must be in range [-2^".concat(n-1,", 2^").concat(n-1,"-1]"));if(!jH(e))throw new Error("Value must be an integer");e<0&&(e+=2**n),a="i".concat(n)}var i="";return e<0&&(e=-e,i="-"),"".concat(i).concat(r).concat(e.toString(t)).concat(a)}function XH(e,t){if("function"==typeof t)return t(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var n,r,a="auto";if(t&&(t.notation&&(a=t.notation),FP(t)?n=t:FP(t.precision)&&(n=t.precision),t.wordSize&&"number"!=typeof(r=t.wordSize)))throw new Error('Option "wordSize" must be a number');switch(a){case"fixed":return QH(e,n);case"exponential":return ej(e,n);case"engineering":return function(e,t){if(isNaN(e)||!isFinite(e))return String(e);var n=tj(ZH(e),t),r=n.exponent,a=n.coefficients,i=r%3==0?r:r<0?r-3-r%3:r-r%3;if(FP(t))for(;t>a.length||r-i+1>a.length;)a.push(0);else for(var s=Math.abs(r-i)-(a.length-1),o=0;o0;)l++,u--;var c=a.slice(l).join(""),p=FP(t)&&c.length||c.match(/[1-9]/)?"."+c:"",d=a.slice(0,l).join("")+p+"e"+(r>=0?"+":"")+i.toString();return n.sign+d}(e,n);case"bin":return JH(e,2,r);case"oct":return JH(e,8,r);case"hex":return JH(e,16,r);case"auto":return function(e,t,n){if(isNaN(e)||!isFinite(e))return String(e);var r=n&&void 0!==n.lowerExp?n.lowerExp:-3,a=n&&void 0!==n.upperExp?n.upperExp:5,i=ZH(e),s=t?tj(i,t):i;if(s.exponent=a)return ej(e,t);var o=s.coefficients,u=s.exponent;o.length0?u:0;return l<(o=nj(-u).concat(o)).length-1&&o.splice(l+1,0,"."),s.sign+o.join("")}(e,n,t&&t).replace(/((\.\d*?)(0+))($|e)/,(function(){var e=arguments[2],t=arguments[4];return"."!==e?e+t:t}));default:throw new Error('Unknown notation "'+a+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function ZH(e){var t=String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number "+e);var n=t[1],r=t[2],a=parseFloat(t[4]||"0"),i=r.indexOf(".");a+=-1!==i?i-1:r.length-1;var s=r.replace(".","").replace(/^0*/,(function(e){return a-=e.length,""})).replace(/0*$/,"").split("").map((function(e){return parseInt(e)}));return 0===s.length&&(s.push(0),a++),{sign:n,coefficients:s,exponent:a}}function QH(e,t){if(isNaN(e)||!isFinite(e))return String(e);var n=ZH(e),r="number"==typeof t?tj(n,n.exponent+1+t):n,a=r.coefficients,i=r.exponent+1,s=i+(t||0);return a.length0?"."+a.join(""):"")+"e"+(i>=0?"+":"")+i}function tj(e,t){for(var n={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},r=n.coefficients;t<=0;)r.unshift(0),n.exponent++,t++;if(r.length>t&&r.splice(t,r.length-t)[0]>=5){var a=t-1;for(r[a]++;10===r[a];)r.pop(),0===a&&(r.unshift(0),n.exponent++,a++),r[--a]++}return n}function nj(e){for(var t=[],n=0;n(HH.prototype.type="Complex",HH.prototype.isComplex=!0,HH.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},HH.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},HH.prototype.format=function(e){var t=this.im,n=this.re,r=XH(this.re,e),a=XH(this.im,e),i=FP(e)?e:e?e.precision:null;if(null!==i){var s=Math.pow(10,-i);Math.abs(n/t)t.re?1:e.ret.im?1:e.im1&&void 0!==arguments[1]?arguments[1]:{};return n=null==n?Number.POSITIVE_INFINITY:n,t=null==t?JSON.stringify:t,function r(){"object"!=typeof r.cache&&(r.cache={values:new Map,lru:dj(n||Number.POSITIVE_INFINITY)});for(var a=[],i=0;i!0)),Nj=YH("false",[],(()=>!1)),Sj=YH("null",[],(()=>null)),kj=Hj("Infinity",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(1/0):1/0})),Dj=Hj("NaN",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(NaN):NaN})),Tj=Hj("pi",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?yj(n):vj})),Ij=Hj("tau",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?bj(n):_j})),Ej=Hj("e",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?mj(n):wj})),Cj=Hj("phi",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?gj(n):1.618033988749895})),Aj=Hj("LN2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(2).ln():Math.LN2})),Lj=Hj("LN10",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(10).ln():Math.LN10})),$j=Hj("LOG2E",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(1).div(new n(2).ln()):Math.LOG2E})),Oj=Hj("LOG10E",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(1).div(new n(10).ln()):Math.LOG10E})),Rj=Hj("SQRT1_2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n("0.5").sqrt():Math.SQRT1_2})),Fj=Hj("SQRT2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(2).sqrt():Math.SQRT2})),Yj=Hj("i",["Complex"],(e=>{var{Complex:t}=e;return t.I})),zj=YH("PI",["pi"],(e=>{var{pi:t}=e;return t})),Bj=YH("E",["e"],(e=>{var{e:t}=e;return t})),Pj=YH("version",[],(()=>"10.6.4"));function Hj(e,t,n){return YH(e,t,n,{recreateOnConfigChange:!0})}var jj=zU("speedOfLight","299792458","m s^-1"),Uj=zU("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),qj=zU("planckConstant","6.62607015e-34","J s"),Wj=zU("reducedPlanckConstant","1.0545718176461565e-34","J s"),Vj=zU("magneticConstant","1.25663706212e-6","N A^-2"),Gj=zU("electricConstant","8.8541878128e-12","F m^-1"),Kj=zU("vacuumImpedance","376.730313667","ohm"),Jj=zU("coulomb","8.987551792261171e9","N m^2 C^-2"),Xj=zU("elementaryCharge","1.602176634e-19","C"),Zj=zU("bohrMagneton","9.2740100783e-24","J T^-1"),Qj=zU("conductanceQuantum","7.748091729863649e-5","S"),eU=zU("inverseConductanceQuantum","12906.403729652257","ohm"),tU=zU("magneticFluxQuantum","2.0678338484619295e-15","Wb"),nU=zU("nuclearMagneton","5.0507837461e-27","J T^-1"),rU=zU("klitzing","25812.807459304513","ohm"),aU=zU("bohrRadius","5.29177210903e-11","m"),iU=zU("classicalElectronRadius","2.8179403262e-15","m"),sU=zU("electronMass","9.1093837015e-31","kg"),oU=zU("fermiCoupling","1.1663787e-5","GeV^-2"),uU=BU("fineStructure",.0072973525693),lU=zU("hartreeEnergy","4.3597447222071e-18","J"),cU=zU("protonMass","1.67262192369e-27","kg"),pU=zU("deuteronMass","3.3435830926e-27","kg"),dU=zU("neutronMass","1.6749271613e-27","kg"),hU=zU("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),fU=zU("rydberg","10973731.568160","m^-1"),mU=zU("thomsonCrossSection","6.6524587321e-29","m^2"),gU=BU("weakMixingAngle",.2229),yU=BU("efimovFactor",22.7),bU=zU("atomicMass","1.66053906660e-27","kg"),xU=zU("avogadro","6.02214076e23","mol^-1"),vU=zU("boltzmann","1.380649e-23","J K^-1"),_U=zU("faraday","96485.33212331001","C mol^-1"),wU=zU("firstRadiation","3.7417718521927573e-16","W m^2"),MU=zU("loschmidt","2.686780111798444e25","m^-3"),NU=zU("gasConstant","8.31446261815324","J K^-1 mol^-1"),SU=zU("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),kU=zU("molarVolume","0.022413969545014137","m^3 mol^-1"),DU=BU("sackurTetrode",-1.16487052358),TU=zU("secondRadiation","0.014387768775039337","m K"),IU=zU("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),EU=zU("wienDisplacement","2.897771955e-3","m K"),CU=zU("molarMass","0.99999999965e-3","kg mol^-1"),AU=zU("molarMassC12","11.9999999958e-3","kg mol^-1"),LU=zU("gravity","9.80665","m s^-2"),$U=zU("planckLength","1.616255e-35","m"),OU=zU("planckMass","2.176435e-8","kg"),RU=zU("planckTime","5.391245e-44","s"),FU=zU("planckCharge","1.87554603778e-18","C"),YU=zU("planckTemperature","1.416785e+32","K");function zU(e,t,n){return YH(e,["config","Unit","BigNumber"],(e=>{var{config:r,Unit:a,BigNumber:i}=e,s=new a("BigNumber"===r.number?new i(t):parseFloat(t),n);return s.fixPrefix=!0,s}))}function BU(e,t){return YH(e,["config","BigNumber"],(e=>{var{config:n,BigNumber:r}=e;return"BigNumber"===n.number?new r(t):t}))}var PU=n(5628),HU=YH("Fraction",[],(()=>(PU.prototype.type="Fraction",PU.prototype.isFraction=!0,PU.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},PU.fromJSON=function(e){return new PU(e)},PU)),{isClass:!0}),jU=YH("Matrix",[],(()=>{function e(){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator")}return e.prototype.type="Matrix",e.prototype.isMatrix=!0,e.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},e.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},e.prototype.create=function(e,t){throw new Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(e,t,n){throw new Error("Cannot invoke subset on a Matrix interface")},e.prototype.get=function(e){throw new Error("Cannot invoke get on a Matrix interface")},e.prototype.set=function(e,t,n){throw new Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(e,t){throw new Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(e,t){throw new Error("Cannot invoke reshape on a Matrix interface")},e.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},e.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},e.prototype.map=function(e,t){throw new Error("Cannot invoke map on a Matrix interface")},e.prototype.forEach=function(e){throw new Error("Cannot invoke forEach on a Matrix interface")},e.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},e.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},e.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},e.prototype.format=function(e){throw new Error("Cannot invoke format on a Matrix interface")},e.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},e}),{isClass:!0}),UU=YH("Range",[],(()=>{function e(t,n,r){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");var a=null!=t,i=null!=n,s=null!=r;if(a)if(YP(t))t=t.toNumber();else if("number"!=typeof t)throw new TypeError("Parameter start must be a number");if(i)if(YP(n))n=n.toNumber();else if("number"!=typeof n)throw new TypeError("Parameter end must be a number");if(s)if(YP(r))r=r.toNumber();else if("number"!=typeof r)throw new TypeError("Parameter step must be a number");this.start=a?parseFloat(t):0,this.end=i?parseFloat(n):0,this.step=s?parseFloat(r):1}return e.prototype.type="Range",e.prototype.isRange=!0,e.parse=function(t){if("string"!=typeof t)return null;var n=t.split(":").map((function(e){return parseFloat(e)})),r=n.some((function(e){return isNaN(e)}));if(r)return null;switch(n.length){case 2:return new e(n[0],n[1]);case 3:return new e(n[0],n[2],n[1]);default:return null}},e.prototype.clone=function(){return new e(this.start,this.end,this.step)},e.prototype.size=function(){var e=0,t=this.start,n=this.step,r=this.end-t;return UH(n)===UH(r)?e=Math.ceil(r/n):0===r&&(e=0),isNaN(e)&&(e=0),[e]},e.prototype.min=function(){var e=this.size()[0];return e>0?this.step>0?this.start:this.start+(e-1)*this.step:void 0},e.prototype.max=function(){var e=this.size()[0];return e>0?this.step>0?this.start+(e-1)*this.step:this.start:void 0},e.prototype.forEach=function(e){var t=this.start,n=this.step,r=this.end,a=0;if(n>0)for(;tr;)e(t,[a],this),t+=n,a++},e.prototype.map=function(e){var t=[];return this.forEach((function(n,r,a){t[r[0]]=e(n,r,a)})),t},e.prototype.toArray=function(){var e=[];return this.forEach((function(t,n){e[n[0]]=t})),e},e.prototype.valueOf=function(){return this.toArray()},e.prototype.format=function(e){var t=XH(this.start,e);return 1!==this.step&&(t+=":"+XH(this.step,e)),t+":"+XH(this.end,e)},e.prototype.toString=function(){return this.format()},e.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},e.fromJSON=function(t){return new e(t.start,t.end,t.step)},e}),{isClass:!0}),qU=YH("ResultSet",[],(()=>{function e(t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");this.entries=t||[]}return e.prototype.type="ResultSet",e.prototype.isResultSet=!0,e.prototype.valueOf=function(){return this.entries},e.prototype.toString=function(){return"["+this.entries.join(", ")+"]"},e.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},e.fromJSON=function(t){return new e(t.entries)},e}),{isClass:!0});function WU(e,t,n){var r=new(0,e.constructor)(2),a="";if(n){if(n<1)throw new Error("size must be in greater than 0");if(!jH(n))throw new Error("size must be an integer");if(e.greaterThan(r.pow(n-1).sub(1))||e.lessThan(r.pow(n-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(n-1,", 2^").concat(n-1,"-1]"));if(!e.isInteger())throw new Error("Value must be an integer");e.lessThan(0)&&(e=e.add(r.pow(n))),a="i".concat(n)}switch(t){case 2:return"".concat(e.toBinary()).concat(a);case 8:return"".concat(e.toOctal()).concat(a);case 16:return"".concat(e.toHexadecimal()).concat(a);default:throw new Error("Base ".concat(t," not supported "))}}function VU(e,t){return void 0!==t?e.toExponential(t-1):e.toExponential()}function GU(e,t){var n=e.length-t.length,r=e.length;return e.substring(n,r)===t}function KU(e,t){var n=function(e,t){return"number"==typeof e?XH(e,t):YP(e)?function(e,t){if("function"==typeof t)return t(e);if(!e.isFinite())return e.isNaN()?"NaN":e.gt(0)?"Infinity":"-Infinity";var n,r,a="auto";if(void 0!==t&&(t.notation&&(a=t.notation),"number"==typeof t?n=t:t.precision&&(n=t.precision),t.wordSize&&"number"!=typeof(r=t.wordSize)))throw new Error('Option "wordSize" must be a number');switch(a){case"fixed":return function(e,t){return e.toFixed(t)}(e,n);case"exponential":return VU(e,n);case"engineering":return function(e,t){var n=e.e,r=n%3==0?n:n<0?n-3-n%3:n-n%3,a=e.mul(Math.pow(10,-r)),i=a.toPrecision(t);return-1!==i.indexOf("e")&&(i=a.toString()),i+"e"+(n>=0?"+":"")+r.toString()}(e,n);case"bin":return WU(e,2,r);case"oct":return WU(e,8,r);case"hex":return WU(e,16,r);case"auto":var i=t&&void 0!==t.lowerExp?t.lowerExp:-3,s=t&&void 0!==t.upperExp?t.upperExp:5;if(e.isZero())return"0";var o=e.toSignificantDigits(n),u=o.e;return(u>=i&&u'"'+n+'": '+KU(e[n],t))).join(", ")+"}":String(e)}(e,t);return t&&"object"==typeof t&&"truncate"in t&&n.length>t.truncate?n.substring(0,t.truncate-3)+"...":n}function JU(e){for(var t=String(e),n="",r=0;r/g,">")}function ZU(e,t){if(Array.isArray(e)){for(var n="[",r=e.length,a=0;at?1:-1}function eq(e,t,n){if(!(this instanceof eq))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=t,this.relation=n,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(t)?"["+t.join(", ")+"]":t)+")",this.stack=(new Error).stack}function tq(e,t,n){if(!(this instanceof tq))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=t):(this.min=t,this.max=n),void 0!==this.min&&this.index=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=(new Error).stack}function nq(e){for(var t=[];Array.isArray(e);)t.push(e.length),e=e[0];return t}function rq(e,t,n){var r,a=e.length;if(a!==t[n])throw new eq(a,t[n]);if(n")}function aq(e,t){if(0===t.length){if(Array.isArray(e))throw new eq(e.length,0)}else rq(e,t,0)}function iq(e,t){if(!FP(e)||!jH(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||"number"==typeof t&&e>=t)throw new tq(e,t)}function sq(e,t,n){if(!Array.isArray(e)||!Array.isArray(t))throw new TypeError("Array expected");if(0===t.length)throw new Error("Resizing to scalar is not supported");return t.forEach((function(e){if(!FP(e)||!jH(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+KU(t)+")")})),oq(e,t,0,void 0!==n?n:0),e}function oq(e,t,n,r){var a,i,s=e.length,o=t[n],u=Math.min(s,o);if(e.length=o,n=0){if(t%n!=0)throw new Error("Could not replace wildcard, since "+t+" is no multiple of "+-n);r[a]=-t/n}return r}function cq(e){return e.reduce(((e,t)=>e*t),1)}function pq(e,t){for(var n=t||nq(e);Array.isArray(e)&&1===e.length;)e=e[0],n.shift();for(var r=n.length;1===n[r-1];)r--;return rt.test(e)))}function vq(e,t){return Array.prototype.join.call(e,t)}function _q(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(0===e.length)return e;var t=[],n=0;t[0]={value:e[0],identifier:0};for(var r=1;r{var{Matrix:t}=e;function n(e,t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!HP(t))throw new Error("Invalid datatype: "+t);if(UP(e))"DenseMatrix"===e.type?(this._data=wH(e._data),this._size=wH(e._size),this._datatype=t||e._datatype):(this._data=e.toArray(),this._size=e.size(),this._datatype=t||e._datatype);else if(e&&jP(e.data)&&jP(e.size))this._data=e.data,this._size=e.size,aq(this._data,this._size),this._datatype=t||e.datatype;else if(jP(e))this._data=l(e),this._size=nq(this._data),aq(this._data,this._size),this._datatype=t;else{if(e)throw new TypeError("Unsupported type of data ("+_H(e)+")");this._data=[],this._size=[0],this._datatype=t}}function r(e,t){if(!KP(t))throw new TypeError("Invalid index");if(t.isScalar())return e.get(t.min());var r=t.size();if(r.length!==e._size.length)throw new eq(r.length,e._size.length);for(var i=t.min(),s=t.max(),o=0,u=e._size.length;o");var p=t.max().map((function(e){return e+1}));u(e,p,r);var d=i.length;s(e._data,t,n,d,0)}return e}function s(e,t,n,r,a){var i=a===r-1,o=t.dimension(a);i?o.forEach((function(t,r){iq(t),e[t]=n[r[0]]})):o.forEach((function(i,o){iq(i),s(e[i],t,n[o[0]],r,a+1)}))}function o(e,t,n){if(0===t.length){for(var r=e._data;jP(r);)r=r[0];return r}return e._size=t.slice(0),e._data=sq(e._data,e._size,n),e}function u(e,t,n){for(var r=e._size.slice(0),a=!1;r.lengthr[i]&&(r[i]=t[i],a=!0);a&&o(e,r,n)}function l(e){for(var t=0,n=e.length;tArray.isArray(e)&&1===e.length?e[0]:e));return o(n?this.clone():this,r,t)},n.prototype.reshape=function(e,t){var n=t?this.clone():this;n._data=uq(n._data,e);var r=n._size.reduce(((e,t)=>e*t));return n._size=lq(e,r),n},n.prototype.clone=function(){return new n({data:wH(this._data),size:wH(this._size),datatype:this._datatype})},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(e){var t=this,r=function n(r,a){return jP(r)?r.map((function(e,t){return n(e,a.concat(t))})):e(r,a,t)}(this._data,[]);return new n(r,void 0!==this._datatype?Mq(r,_H):void 0)},n.prototype.forEach=function(e){var t=this;!function n(r,a){jP(r)?r.forEach((function(e,t){n(e,a.concat(t))})):e(r,a,t)}(this._data,[])},n.prototype[Symbol.iterator]=function*(){yield*function*e(t,n){if(jP(t))for(var r=0;r[e[r]]));t.push(new n(i,e._datatype))},s=0;s0?e:0,r=e<0?-e:0,a=this._size[0],i=this._size[1],s=Math.min(a-r,i-t),o=[],u=0;u0?r:0,o=r<0?-r:0,u=e[0],l=e[1],c=Math.min(u-o,l-s);if(jP(t)){if(t.length!==c)throw new Error("Invalid value array length");i=function(e){return t[e]}}else if(UP(t)){var p=t.size();if(1!==p.length||p[0]!==c)throw new Error("Invalid matrix length");i=function(e){return t.get([e])}}else i=function(){return t};a||(a=YP(i(0))?i(0).mul(0):0);var d=[];if(e.length>0){d=sq(d,e,a);for(var h=0;hfunction(e,t){return"number"!=typeof t||isFinite(t)&&!isNaN(t)?t:{mathjs:"number",value:String(t)}})),Dq=n(2287);function Tq(e,t){if(Aq(e)&&Eq(e,t))return e[t];if("function"==typeof e[t]&&Cq(e,t))throw new Error('Cannot access method "'+t+'" as a property');throw new Error('No access to property "'+t+'"')}function Iq(e,t,n){if(Aq(e)&&Eq(e,t))return e[t]=n,n;throw new Error('No access to property "'+t+'"')}function Eq(e,t){return!(!e||"object"!=typeof e||!EH(Lq,t)&&(t in Object.prototype||t in Function.prototype))}function Cq(e,t){return!(null==e||"function"!=typeof e[t]||EH(e,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(e)||!EH($q,t)&&(t in Object.prototype||t in Function.prototype))}function Aq(e){return"object"==typeof e&&e&&e.constructor===Object}var Lq={length:!0,name:!0},$q={toString:!0,valueOf:!0,toLocaleString:!0};class Oq{constructor(e){this.wrappedObject=e}keys(){return Object.keys(this.wrappedObject)}get(e){return Tq(this.wrappedObject,e)}set(e,t){return Iq(this.wrappedObject,e,t),this}has(e){return e in this.wrappedObject}}function Rq(){return new Map}function Fq(e){if(!e)return Rq();if(Yq(e))return e;if(nH(e))return new Oq(e);throw new Error("createMap can create maps from objects or Maps")}function Yq(e){return!!e&&(e instanceof Map||e instanceof Oq||"function"==typeof e.set&&"function"==typeof e.get&&"function"==typeof e.keys&&"function"==typeof e.has)}function zq(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+e+"). Use function bignumber(x) to convert to BigNumber.");return new t(e)}},{from:"number",to:"Complex",convert:function(e){return n||jq(e),new n(e,0)}},{from:"number",to:"string",convert:function(e){return e+""}},{from:"BigNumber",to:"Complex",convert:function(e){return n||jq(e),new n(e.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(e){throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.")}},{from:"Fraction",to:"Complex",convert:function(e){return n||jq(e),new n(e.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(e){a||Uq(e);var t=new a(e);if(t.valueOf()!==e)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+e+"). Use function fraction(x) to convert to Fraction.");return t}},{from:"string",to:"number",convert:function(e){var t=Number(e);if(isNaN(t))throw new Error('Cannot convert "'+e+'" to a number');return t}},{from:"string",to:"BigNumber",convert:function(e){t||Hq(e);try{return new t(e)}catch(t){throw new Error('Cannot convert "'+e+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(e){a||Uq(e);try{return new a(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(e){n||jq(e);try{return new n(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Complex')}}},{from:"boolean",to:"number",convert:function(e){return+e}},{from:"boolean",to:"BigNumber",convert:function(e){return t||Hq(e),new t(+e)}},{from:"boolean",to:"Fraction",convert:function(e){return a||Uq(e),new a(+e)}},{from:"boolean",to:"string",convert:function(e){return String(e)}},{from:"Array",to:"Matrix",convert:function(e){return r||function(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}(),new r(e)}},{from:"Matrix",to:"Array",convert:function(e){return e.valueOf()}}],i}));function Hq(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function jq(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function Uq(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}function qq(e){var t,n,r=e.length,a=e[0].length,i=[];for(n=0;n=r.length)throw new tq(t,r.length);return UP(e)?e.create(Jq(e.valueOf(),t,n)):Jq(e,t,n)}function Jq(e,t,n){var r,a,i,s;if(t<=0){if(Array.isArray(e[0])){for(s=qq(e),a=[],r=0;r0)return e-t*Math.floor(e/t);if(0===t)return e;throw new Error("Cannot calculate mod for a negative divisor")}function fW(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,n=t<0;if(n&&(t=-t),0===t)throw new Error("Root must be non-zero");if(e<0&&Math.abs(t)%2!=1)throw new Error("Root must be odd when a is negative.");if(0===e)return n?1/0:0;if(!isFinite(e))return n?0:e;var r=Math.pow(Math.abs(e),1/t);return r=e<0?-r:r,n?1/r:r}function mW(e){return UH(e)}function gW(e){return e*e}function yW(e,t){var n,r,a,i=0,s=1,o=1,u=0;if(!jH(e)||!jH(t))throw new Error("Parameters in function xgcd must be integer numbers");for(;t;)a=e-(r=Math.floor(e/t))*t,n=i,i=s-r*i,s=n,n=o,o=u-r*o,u=n,e=t,t=a;return e<0?[-e,-s,-u]:[e,e?s:0,u]}function bW(e,t){return e*e<1&&t===1/0||e*e>1&&t===-1/0?0:Math.pow(e,t)}function xW(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!jH(t)||t<0||t>15)throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");return parseFloat(QH(e,t))}eW.signature=Zq,tW.signature=Qq,nW.signature=Qq,rW.signature=Zq,aW.signature=Zq,iW.signature=Zq,sW.signature=Zq,oW.signature=Zq,uW.signature=Zq,lW.signature=Qq,cW.signature=Qq,pW.signature=Zq,dW.signature=Zq,hW.signature=Qq,mW.signature=Zq,gW.signature=Zq,yW.signature=Qq,bW.signature=Qq;var vW="unaryPlus",_W=YH(vW,["typed","config","BigNumber"],(e=>{var{typed:t,config:n,BigNumber:r}=e;return t(vW,{number:aW,Complex:function(e){return e},BigNumber:function(e){return e},Fraction:function(e){return e},Unit:function(e){return e.clone()},"Array | Matrix":function(e){return Gq(e,this,!0)},"boolean | string":function(e){return"BigNumber"===n.number?new r(+e):+e}})})),wW=YH("abs",["typed"],(e=>{var{typed:t}=e;return t("abs",{number:eW,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},Fraction:function(e){return e.abs()},"Array | Matrix":function(e){return Gq(e,this,!0)},Unit:function(e){return e.abs()}})})),MW="acos",NW=YH(MW,["typed","config","Complex"],(e=>{var{typed:t,config:n,Complex:r}=e;return t(MW,{number:function(e){return e>=-1&&e<=1||n.predictable?Math.acos(e):new r(e,0).acos()},Complex:function(e){return e.acos()},BigNumber:function(e){return e.acos()},"Array | Matrix":function(e){return Gq(e,this)}})})),SW="number";function kW(e){return ij(e)}function DW(e){return Math.atan(1/e)}function TW(e){return isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}function IW(e){return Math.asin(1/e)}function EW(e){var t=1/e;return Math.log(t+Math.sqrt(t*t+1))}function CW(e){return Math.acos(1/e)}function AW(e){var t=1/e,n=Math.sqrt(t*t-1);return Math.log(n+t)}function LW(e){return sj(e)}function $W(e){return oj(e)}function OW(e){return 1/Math.tan(e)}function RW(e){var t=Math.exp(2*e);return(t+1)/(t-1)}function FW(e){return 1/Math.sin(e)}function YW(e){return 0===e?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*UH(e)}function zW(e){return 1/Math.cos(e)}function BW(e){return 2/(Math.exp(e)+Math.exp(-e))}function PW(e){return lj(e)}kW.signature=SW,DW.signature=SW,TW.signature=SW,IW.signature=SW,EW.signature=SW,CW.signature=SW,AW.signature=SW,LW.signature=SW,$W.signature=SW,OW.signature=SW,RW.signature=SW,FW.signature=SW,YW.signature=SW,zW.signature=SW,BW.signature=SW,PW.signature=SW;var HW="acot",jW=YH(HW,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t(HW,{number:DW,Complex:function(e){return e.acot()},BigNumber:function(e){return new n(1).div(e).atan()},"Array | Matrix":function(e){return Gq(e,this)}})})),UW="acsc",qW=YH(UW,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:n,Complex:r,BigNumber:a}=e;return t(UW,{number:function(e){return e<=-1||e>=1||n.predictable?IW(e):new r(e,0).acsc()},Complex:function(e){return e.acsc()},BigNumber:function(e){return new a(1).div(e).asin()},"Array | Matrix":function(e){return Gq(e,this)}})})),WW="addScalar",VW=YH(WW,["typed"],(e=>{var{typed:t}=e;return t(WW,{"number, number":tW,"Complex, Complex":function(e,t){return e.add(t)},"BigNumber, BigNumber":function(e,t){return e.plus(t)},"Fraction, Fraction":function(e,t){return e.add(t)},"Unit, Unit":function(e,t){if(null===e.value||void 0===e.value)throw new Error("Parameter x contains a unit with undefined value");if(null===t.value||void 0===t.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(t))throw new Error("Units do not match");var n=e.clone();return n.value=this(n.value,t.value),n.fixPrefix=!1,n}})})),GW=YH("arg",["typed"],(e=>{var{typed:t}=e;return t("arg",{number:function(e){return Math.atan2(0,e)},BigNumber:function(e){return e.constructor.atan2(0,e)},Complex:function(e){return e.arg()},"Array | Matrix":function(e){return Gq(e,this)}})})),KW="asech",JW=YH(KW,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:n,Complex:r,BigNumber:a}=e;return t(KW,{number:function(e){if(e<=1&&e>=-1||n.predictable){var t=1/e;if(t>0||n.predictable)return AW(e);var a=Math.sqrt(t*t-1);return new r(Math.log(a-t),Math.PI)}return new r(e,0).asech()},Complex:function(e){return e.asech()},BigNumber:function(e){return new a(1).div(e).acosh()},"Array | Matrix":function(e){return Gq(e,this)}})})),XW=YH("asinh",["typed"],(e=>{var{typed:t}=e;return t("asinh",{number:LW,Complex:function(e){return e.asinh()},BigNumber:function(e){return e.asinh()},"Array | Matrix":function(e){return Gq(e,this,!0)}})})),ZW=YH("atan",["typed"],(e=>{var{typed:t}=e;return t("atan",{number:function(e){return Math.atan(e)},Complex:function(e){return e.atan()},BigNumber:function(e){return e.atan()},"Array | Matrix":function(e){return Gq(e,this,!0)}})})),QW="atanh",eV=YH(QW,["typed","config","Complex"],(e=>{var{typed:t,config:n,Complex:r}=e;return t(QW,{number:function(e){return e<=1&&e>=-1||n.predictable?$W(e):new r(e,0).atanh()},Complex:function(e){return e.atanh()},BigNumber:function(e){return e.atanh()},"Array | Matrix":function(e){return Gq(e,this,!0)}})})),tV=YH("bignumber",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t("bignumber",{"":function(){return new n(0)},number:function(e){return new n(e+"")},string:function(e){var t=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(t){var r=t[2],a=n(t[1]),i=new n(2).pow(Number(r));if(a.gt(i.sub(1)))throw new SyntaxError('String "'.concat(e,'" is out of range'));var s=new n(2).pow(Number(r)-1);return a.gte(s)?a.sub(i):a}return new n(e)},BigNumber:function(e){return e},Fraction:function(e){return new n(e.n).div(e.d).times(e.s)},null:function(e){return new n(0)},"Array | Matrix":function(e){return Gq(e,this)}})}));function nV(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitAnd");var n=e.constructor;if(e.isNaN()||t.isNaN())return new n(NaN);if(e.isZero()||t.eq(-1)||e.eq(t))return e;if(t.isZero()||e.eq(-1))return t;if(!e.isFinite()||!t.isFinite()){if(!e.isFinite()&&!t.isFinite())return e.isNegative()===t.isNegative()?e:new n(0);if(!e.isFinite())return t.isNegative()?e:e.isNegative()?new n(0):t;if(!t.isFinite())return e.isNegative()?t:t.isNegative()?new n(0):e}return iV(e,t,(function(e,t){return e&t}))}function rV(e){if(e.isFinite()&&!e.isInteger())throw new Error("Integer expected in function bitNot");var t=e.constructor,n=t.precision;t.config({precision:1e9});var r=e.plus(new t(1));return r.s=-r.s||null,t.config({precision:n}),r}function aV(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitOr");var n=e.constructor;if(e.isNaN()||t.isNaN())return new n(NaN);var r=new n(-1);return e.isZero()||t.eq(r)||e.eq(t)?t:t.isZero()||e.eq(r)?e:e.isFinite()&&t.isFinite()?iV(e,t,(function(e,t){return e|t})):!e.isFinite()&&!e.isNegative()&&t.isNegative()||e.isNegative()&&!t.isNegative()&&!t.isFinite()?r:e.isNegative()&&t.isNegative()?e.isFinite()?e:t:e.isFinite()?t:e}function iV(e,t,n){var r,a,i,s,o,u=e.constructor,l=+(e.s<0),c=+(t.s<0);if(l){r=sV(rV(e));for(var p=0;p0;)n(i[--h],s[--f])===m&&(g=g.plus(y)),y=y.times(b);for(;f>0;)n(o,s[--f])===m&&(g=g.plus(y)),y=y.times(b);return u.config({precision:x}),0===m&&(g.s=-g.s),g}function sV(e){for(var t=e.d,n=t[0]+"",r=1;r0)if(++o>l)for(o-=l;o--;)u+="0";else o1&&(null!==c[h+1]&&void 0!==c[h+1]||(c[h+1]=0),c[h+1]+=c[h]>>1,c[h]&=1)}return c.reverse()}function oV(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitXor");var n=e.constructor;if(e.isNaN()||t.isNaN())return new n(NaN);if(e.isZero())return t;if(t.isZero())return e;if(e.eq(t))return new n(0);var r=new n(-1);return e.eq(r)?rV(t):t.eq(r)?rV(e):e.isFinite()&&t.isFinite()?iV(e,t,(function(e,t){return e^t})):e.isFinite()||t.isFinite()?new n(e.isNegative()===t.isNegative()?1/0:-1/0):r}function uV(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function leftShift");var n=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new n(NaN):e.isZero()||t.isZero()?e:e.isFinite()||t.isFinite()?t.lt(55)?e.times(Math.pow(2,t.toNumber())+""):e.times(new n(2).pow(t)):new n(NaN)}function lV(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function rightArithShift");var n=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new n(NaN):e.isZero()||t.isZero()?e:t.isFinite()?t.lt(55)?e.div(Math.pow(2,t.toNumber())+"").floor():e.div(new n(2).pow(t)).floor():e.isNegative()?new n(-1):e.isFinite()?new n(0):new n(NaN)}var cV="number, number";function pV(e,t){if(!jH(e)||!jH(t))throw new Error("Integers expected in function bitAnd");return e&t}function dV(e){if(!jH(e))throw new Error("Integer expected in function bitNot");return~e}function hV(e,t){if(!jH(e)||!jH(t))throw new Error("Integers expected in function bitOr");return e|t}function fV(e,t){if(!jH(e)||!jH(t))throw new Error("Integers expected in function bitXor");return e^t}function mV(e,t){if(!jH(e)||!jH(t))throw new Error("Integers expected in function leftShift");return e<>t}function yV(e,t){if(!jH(e)||!jH(t))throw new Error("Integers expected in function rightLogShift");return e>>>t}pV.signature=cV,dV.signature="number",hV.signature=cV,fV.signature=cV,mV.signature=cV,gV.signature=cV,yV.signature=cV;var bV="bitNot",xV=YH(bV,["typed"],(e=>{var{typed:t}=e;return t(bV,{number:dV,BigNumber:rV,"Array | Matrix":function(e){return Gq(e,this)}})})),vV="boolean",_V=YH(vV,["typed"],(e=>{var{typed:t}=e;return t(vV,{"":function(){return!1},boolean:function(e){return e},number:function(e){return!!e},null:function(e){return!1},BigNumber:function(e){return!e.isZero()},string:function(e){var t=e.toLowerCase();if("true"===t)return!0;if("false"===t)return!1;var n=Number(e);if(""!==e&&!isNaN(n))return!!n;throw new Error('Cannot convert "'+e+'" to a boolean')},"Array | Matrix":function(e){return Gq(e,this)}})})),wV="clone",MV=YH(wV,["typed"],(e=>{var{typed:t}=e;return t(wV,{any:wH})}));function NV(e,t){if(t>1;return NV(e,n)*NV(n+1,t)}function SV(e,t){if(!jH(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(!jH(t)||t<0)throw new TypeError("Positive integer value expected in function combinations");if(t>e)throw new TypeError("k must be less than or equal to n");for(var n=e-t,r=1,a=2,i=t{var{typed:t}=e;return t(kV,{"number, number":SV,"BigNumber, BigNumber":function(e,t){var n,r,a=e.constructor,i=e.minus(t),s=new a(1);if(!TV(e)||!TV(t))throw new TypeError("Positive integer value expected in function combinations");if(t.gt(e))throw new TypeError("k must be less than n in function combinations");if(n=s,t.lt(i))for(r=s;r.lte(i);r=r.plus(s))n=n.times(t.plus(r)).dividedBy(r);else for(r=s;r.lte(t);r=r.plus(s))n=n.times(i.plus(r)).dividedBy(r);return n}})}));function TV(e){return e.isInteger()&&e.gte(0)}var IV=YH("complex",["typed","Complex"],(e=>{var{typed:t,Complex:n}=e;return t("complex",{"":function(){return n.ZERO},number:function(e){return new n(e,0)},"number, number":function(e,t){return new n(e,t)},"BigNumber, BigNumber":function(e,t){return new n(e.toNumber(),t.toNumber())},Fraction:function(e){return new n(e.valueOf(),0)},Complex:function(e){return e.clone()},string:function(e){return n(e)},null:function(e){return n(0)},Object:function(e){if("re"in e&&"im"in e)return new n(e.re,e.im);if("r"in e&&"phi"in e||"abs"in e&&"arg"in e)return new n(e);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":function(e){return Gq(e,this)}})})),EV="conj",CV=YH(EV,["typed"],(e=>{var{typed:t}=e;return t(EV,{number:function(e){return e},BigNumber:function(e){return e},Complex:function(e){return e.conjugate()},"Array | Matrix":function(e){return Gq(e,this)}})})),AV="cosh",LV=YH(AV,["typed"],(e=>{var{typed:t}=e;return t(AV,{number:uj,Complex:function(e){return e.cosh()},BigNumber:function(e){return e.cosh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cosh is no angle");return this(e.value)},"Array | Matrix":function(e){return Gq(e,this)}})})),$V="coth",OV=YH($V,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t($V,{number:RW,Complex:function(e){return e.coth()},BigNumber:function(e){return new n(1).div(e.tanh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function coth is no angle");return this(e.value)},"Array | Matrix":function(e){return Gq(e,this)}})})),RV=YH("csc",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t("csc",{number:FW,Complex:function(e){return e.csc()},BigNumber:function(e){return new n(1).div(e.sin())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csc is no angle");return this(e.value)},"Array | Matrix":function(e){return Gq(e,this)}})})),FV="cube",YV=YH(FV,["typed"],(e=>{var{typed:t}=e;return t(FV,{number:sW,Complex:function(e){return e.mul(e).mul(e)},BigNumber:function(e){return e.times(e).times(e)},Fraction:function(e){return e.pow(3)},"Array | Matrix":function(e){return Gq(e,this,!0)},Unit:function(e){return e.pow(3)}})}));function zV(e,t,n){if(null==n)return e.eq(t);if(e.eq(t))return!0;if(e.isNaN()||t.isNaN())return!1;if(e.isFinite()&&t.isFinite()){var r=e.minus(t).abs();if(r.isZero())return!0;var a=e.constructor.max(e.abs(),t.abs());return r.lte(a.times(n))}return!1}var BV="equalScalar",PV=YH(BV,["typed","config"],(e=>{var{typed:t,config:n}=e;return t(BV,{"boolean, boolean":function(e,t){return e===t},"number, number":function(e,t){return aj(e,t,n.epsilon)},"BigNumber, BigNumber":function(e,t){return e.eq(t)||zV(e,t,n.epsilon)},"Fraction, Fraction":function(e,t){return e.equals(t)},"Complex, Complex":function(e,t){return function(e,t,n){return aj(e.re,t.re,n)&&aj(e.im,t.im,n)}(e,t,n.epsilon)},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)}})})),HV=(YH(BV,["typed","config"],(e=>{var{typed:t,config:n}=e;return t(BV,{"number, number":function(e,t){return aj(e,t,n.epsilon)}})})),YH("erf",["typed"],(e=>{var{typed:t}=e;return t("name",{number:function(e){var t=Math.abs(e);return t>=VV?UH(e):t<=jV?UH(e)*function(e){var t,n=e*e,r=qV[0][4]*n,a=n;for(t=0;t<3;t+=1)r=(r+qV[0][t])*n,a=(a+WV[0][t])*n;return e*(r+qV[0][3])/(a+WV[0][3])}(t):t<=4?UH(e)*(1-function(e){var t,n=qV[1][8]*e,r=e;for(t=0;t<7;t+=1)n=(n+qV[1][t])*e,r=(r+WV[1][t])*e;var a=(n+qV[1][7])/(r+WV[1][7]),i=parseInt(16*e)/16,s=(e-i)*(e+i);return Math.exp(-i*i)*Math.exp(-s)*a}(t)):UH(e)*(1-function(e){var t,n=1/(e*e),r=qV[2][5]*n,a=n;for(t=0;t<4;t+=1)r=(r+qV[2][t])*n,a=(a+WV[2][t])*n;var i=n*(r+qV[2][4])/(a+WV[2][4]);i=(UV-i)/e;var s=(e-(n=parseInt(16*e)/16))*(e+n);return Math.exp(-n*n)*Math.exp(-s)*i}(t))},"Array | Matrix":function(e){return Gq(e,this)}})}))),jV=.46875,UV=.5641895835477563,qV=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,2.1531153547440383e-8],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],WV=[[23.601290952344122,244.02463793444417,1282.6165260773723,2844.236833439171],[15.744926110709835,117.6939508913125,537.1811018620099,1621.3895745666903,3290.7992357334597,4362.619090143247,3439.3676741437216,1230.3393548037495],[2.568520192289822,1.8729528499234604,.5279051029514285,.06051834131244132,.0023352049762686918]],VV=Math.pow(2,53),GV=YH("exp",["typed"],(e=>{var{typed:t}=e;return t("exp",{number:oW,Complex:function(e){return e.exp()},BigNumber:function(e){return e.exp()},"Array | Matrix":function(e){return Gq(e,this)}})})),KV="expm1",JV=YH(KV,["typed","Complex"],(e=>{var{typed:t,Complex:n}=e;return t(KV,{number:uW,Complex:function(e){var t=Math.exp(e.re);return new n(t*Math.cos(e.im)-1,t*Math.sin(e.im))},BigNumber:function(e){return e.exp().minus(1)},"Array | Matrix":function(e){return Gq(e,this)}})})),XV=YH("filter",["typed"],(e=>{var{typed:t}=e;return t("filter",{"Array, function":ZV,"Matrix, function":function(e,t){return e.create(ZV(e.toArray(),t))},"Array, RegExp":xq,"Matrix, RegExp":function(e,t){return e.create(xq(e.toArray(),t))}})}));function ZV(e,t){var n=fj(t);return bq(e,(function(e,r,a){return 1===n?t(e):2===n?t(e,[r]):t(e,[r],a)}))}var QV="forEach",eG=YH(QV,["typed"],(e=>{var{typed:t}=e;return t(QV,{"Array, function":tG,"Matrix, function":function(e,t){return e.forEach(t)}})}));function tG(e,t){var n=fj(t);!function r(a,i){Array.isArray(a)?yq(a,(function(e,t){r(e,i.concat(t))})):1===n?t(a):2===n?t(a,i):t(a,i,e)}(e,[])}var nG="format",rG=YH(nG,["typed"],(e=>{var{typed:t}=e;return t(nG,{any:KU,"any, Object | function | number":KU})})),aG="getMatrixDataType",iG=YH(aG,["typed"],(e=>{var{typed:t}=e;return t(aG,{Array:function(e){return Mq(e,_H)},Matrix:function(e){return e.getDataType()}})})),sG=YH("hex",["typed","format"],(e=>{var{typed:t,format:n}=e;return t("hex",{"number | BigNumber":function(e){return n(e,{notation:"hex"})},"number | BigNumber, number":function(e,t){return n(e,{notation:"hex",wordSize:t})}})})),oG=YH("im",["typed"],(e=>{var{typed:t}=e;return t("im",{number:function(e){return 0},BigNumber:function(e){return e.mul(0)},Fraction:function(e){return e.mul(0)},Complex:function(e){return e.im},"Array | Matrix":function(e){return Gq(e,this)}})})),uG="isInteger",lG=YH(uG,["typed"],(e=>{var{typed:t}=e;return t(uG,{number:jH,BigNumber:function(e){return e.isInt()},Fraction:function(e){return 1===e.d&&isFinite(e.n)},"Array | Matrix":function(e){return Gq(e,this)}})})),cG="number";function pG(e){return e<0}function dG(e){return e>0}function hG(e){return 0===e}function fG(e){return Number.isNaN(e)}pG.signature=cG,dG.signature=cG,hG.signature=cG,fG.signature=cG;var mG="isNegative",gG=YH(mG,["typed"],(e=>{var{typed:t}=e;return t(mG,{number:pG,BigNumber:function(e){return e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s<0},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return Gq(e,this)}})})),yG="isPositive",bG=YH(yG,["typed"],(e=>{var{typed:t}=e;return t(yG,{number:dG,BigNumber:function(e){return!e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s>0&&e.n>0},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return Gq(e,this)}})})),xG="isZero",vG=YH(xG,["typed"],(e=>{var{typed:t}=e;return t(xG,{number:hG,BigNumber:function(e){return e.isZero()},Complex:function(e){return 0===e.re&&0===e.im},Fraction:function(e){return 1===e.d&&0===e.n},Unit:function(e){return this(e.value)},"Array | Matrix":function(e){return Gq(e,this)}})}));function _G(e){var t;if(jH(e))return e<=0?isFinite(e)?1/0:NaN:e>171?1/0:NV(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*_G(1-e));if(e>=171.35)return 1/0;if(e>85){var n=e*e,r=n*e,a=r*e,i=a*e;return Math.sqrt(2*Math.PI/e)*Math.pow(e/Math.E,e)*(1+1/(12*e)+1/(288*n)-139/(51840*r)-571/(2488320*a)+163879/(209018880*i)+5246819/(75246796800*i*e))}--e,t=MG[0];for(var s=1;s=1;r--)n+=SG[r]/(e+r);return NG+(e+.5)*Math.log(t)-t+Math.log(n)}kG.signature="number";var DG="lgamma",TG=YH(DG,["Complex","typed"],(e=>{var{Complex:t,typed:n}=e,r=[-.029550653594771242,.00641025641025641,-.0019175269175269176,.0008417508417508417,-.0005952380952380953,.0007936507936507937,-.002777777777777778,.08333333333333333];return n(DG,{number:kG,Complex:function(e){var n,r;if(e.isNaN())return new t(NaN,NaN);if(0===e.im)return new t(kG(e.re),0);if(e.re>=7||Math.abs(e.im)>=7)return a(e);if(e.re<=.1){var s=(n=6.283185307179586,(!0^((r=e.im)>0||!(r<0)&&1/r==1/0)?-n:n)*Math.floor(.5*e.re+.25)),o=e.mul(Math.PI).sin().log(),u=this(new t(1-e.re,-e.im));return new t(1.1447298858494002,s).sub(o).sub(u)}return e.im>=0?i(e):i(e.conjugate()).conjugate()},BigNumber:function(){throw new Error("mathjs doesn't yet provide an implementation of the algorithm lgamma for BigNumber")}});function a(e){for(var n=e.sub(.5).mul(e.log()).sub(e).add(NG),a=new t(1,0).div(e),i=a.div(e),s=r[0],o=r[1],u=2*i.re,l=i.re*i.re+i.im*i.im,c=2;c<8;c++){var p=o;o=-l*s+r[c],s=u*s+p}var d=a.mul(i.mul(s).add(o));return n.add(d)}function i(e){var n=0,r=0,i=e;for(e=e.add(1);e.re<=7;){var s=(i=i.mul(e)).im<0?1:0;0!==s&&0===r&&n++,r=s,e=e.add(1)}return a(e).sub(i.log()).sub(new t(0,2*n*Math.PI*1))}})),IG="log10",EG=YH(IG,["typed","config","Complex"],(e=>{var{typed:t,config:n,Complex:r}=e;return t(IG,{number:function(e){return e>=0||n.predictable?pW(e):new r(e,0).log().div(Math.LN10)},Complex:function(e){return new r(e).log().div(Math.LN10)},BigNumber:function(e){return!e.isNegative()||n.predictable?e.log():new r(e.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":function(e){return Gq(e,this)}})})),CG="log2",AG=YH(CG,["typed","config","Complex"],(e=>{var{typed:t,config:n,Complex:r}=e;return t(CG,{number:function(e){return e>=0||n.predictable?dW(e):a(new r(e,0))},Complex:a,BigNumber:function(e){return!e.isNegative()||n.predictable?e.log(2):a(new r(e.toNumber(),0))},"Array | Matrix":function(e){return Gq(e,this)}});function a(e){var t=Math.sqrt(e.re*e.re+e.im*e.im);return new r(Math.log2?Math.log2(t):Math.log(t)/Math.LN2,Math.atan2(e.im,e.re)/Math.LN2)}})),LG=YH("map",["typed"],(e=>{var{typed:t}=e;return t("map",{"Array, function":$G,"Matrix, function":function(e,t){return e.map(t)}})}));function $G(e,t){var n=fj(t);return function r(a,i){if(Array.isArray(a))return a.map((function(e,t){return r(e,i.concat(t))}));try{return 1===n?t(a):2===n?t(a,i):t(a,i,e)}catch(t){if(t instanceof TypeError&&"data"in t&&"wrongType"===t.data.category){var s="map attempted to call '".concat(t.data.fn,"(").concat(a),o=JSON.stringify(i);throw 2===n?s+=","+o:1!==n&&(s+=",".concat(o,",").concat(e)),s+=")' but argument ".concat(t.data.index+1," of type "),s+="".concat(t.data.actual," does not match expected type "),s+=t.data.expected.join(" or "),new TypeError(s)}throw t}}(e,[])}var OG=YH("multiplyScalar",["typed"],(e=>{var{typed:t}=e;return t("multiplyScalar",{"number, number":nW,"Complex, Complex":function(e,t){return e.mul(t)},"BigNumber, BigNumber":function(e,t){return e.times(t)},"Fraction, Fraction":function(e,t){return e.mul(t)},"number | Fraction | BigNumber | Complex, Unit":function(e,t){var n=t.clone();return n.value=null===n.value?n._normalize(e):this(n.value,e),n},"Unit, number | Fraction | BigNumber | Complex":function(e,t){var n=e.clone();return n.value=null===n.value?n._normalize(t):this(n.value,t),n},"Unit, Unit":function(e,t){return e.multiply(t)}})})),RG="number, number";function FG(e){return!e}function YG(e,t){return!(!e&&!t)}function zG(e,t){return!!e!=!!t}function BG(e,t){return!(!e||!t)}FG.signature="number",YG.signature=RG,zG.signature=RG,BG.signature=RG;var PG=YH("not",["typed"],(e=>{var{typed:t}=e;return t("not",{number:FG,Complex:function(e){return 0===e.re&&0===e.im},BigNumber:function(e){return e.isZero()||e.isNaN()},Unit:function(e){return null===e.value||this(e.value)},"Array | Matrix":function(e){return Gq(e,this)}})})),HG=YH("number",["typed"],(e=>{var{typed:t}=e,n=t("number",{"":function(){return 0},number:function(e){return e},string:function(e){if("NaN"===e)return NaN;var t=function(e){var t=e.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);return t?{input:e,radix:{"0b":2,"0o":8,"0x":16}[t[1]],integerPart:t[2],fractionalPart:t[3]}:null}(e);if(t)return function(e){for(var t=parseInt(e.integerPart,e.radix),n=0,r=0;r2**n-1)throw new SyntaxError('String "'.concat(e,'" is out of range'));a>=2**(n-1)&&(a-=2**n)}return a},BigNumber:function(e){return e.toNumber()},Fraction:function(e){return e.valueOf()},Unit:function(e){throw new Error("Second argument with valueless unit expected")},null:function(e){return 0},"Unit, string | Unit":function(e,t){return e.toNumber(t)},"Array | Matrix":function(e){return Gq(e,this)}});return n.fromJSON=function(e){return parseFloat(e.value)},n})),jG=YH("oct",["typed","format"],(e=>{var{typed:t,format:n}=e;return t("oct",{"number | BigNumber":function(e){return n(e,{notation:"oct"})},"number | BigNumber, number":function(e,t){return n(e,{notation:"oct",wordSize:t})}})})),UG=Ep(Date.now());function qG(e){var t,n;return t=null===(n=e)?UG:Ep(String(n)),function(){return t()}}var WG="pickRandom",VG=YH(WG,["typed","config","?on"],(e=>{var{typed:t,config:n,on:r}=e,a=qG(n.randomSeed);return r&&r("config",(function(e,t){e.randomSeed!==t.randomSeed&&(a=qG(e.randomSeed))})),t(WG,{"Array | Matrix":function(e){return i(e,{})},"Array | Matrix, Object":function(e,t){return i(e,t)},"Array | Matrix, number":function(e,t){return i(e,{number:t})},"Array | Matrix, Array | Matrix":function(e,t){return i(e,{weights:t})},"Array | Matrix, Array | Matrix, number":function(e,t,n){return i(e,{number:n,weights:t})},"Array | Matrix, number, Array | Matrix":function(e,t,n){return i(e,{number:t,weights:n})}});function i(e,t){var{number:n,weights:r,elementWise:i=!0}=t,s=void 0===n;s&&(n=1);var o=UP(e)?e.create:UP(r)?r.create:null;e=e.valueOf(),r&&(r=r.valueOf()),!0===i&&(e=mq(e),r=mq(r));var u=0;if(void 0!==r){if(r.length!==e.length)throw new Error("Weights must have the same length as possibles");for(var l=0,c=r.length;l{var{typed:t}=e;return t(GG,{"string, Object | Array":JG,"string, Object | Array, number | Object":JG})}));function JG(e,t,n){return e.replace(/\$([\w.]+)/g,(function(e,r){for(var a=r.split("."),i=t[a.shift()];a.length&&void 0!==i;){var s=a.shift();i=s?i[s]:i+"."}return void 0!==i?HP(i)?i:KU(i,n):e}))}function XG(e,t){var n=[];if((e=e.slice(0)).length>1)for(var r=0,a=e.shift();r{var{typed:t,config:n,on:r}=e,a=qG(n.randomSeed);return r&&r("config",(function(e,t){e.randomSeed!==t.randomSeed&&(a=qG(e.randomSeed))})),t(ZG,{"":()=>s(0,1),number:e=>s(0,e),"number, number":(e,t)=>s(e,t),"Array | Matrix":e=>i(e,0,1),"Array | Matrix, number":(e,t)=>i(e,0,t),"Array | Matrix, number, number":(e,t,n)=>i(e,t,n)});function i(e,t,n){var r=XG(e.valueOf(),(()=>s(t,n)));return UP(e)?e.create(r):r}function s(e,t){return e+a()*(t-e)}})),eK=YH("re",["typed"],(e=>{var{typed:t}=e;return t("re",{number:function(e){return e},BigNumber:function(e){return e},Fraction:function(e){return e},Complex:function(e){return e.re},"Array | Matrix":function(e){return Gq(e,this)}})})),tK=YH("sec",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t("sec",{number:zW,Complex:function(e){return e.sec()},BigNumber:function(e){return new n(1).div(e.cos())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sec is no angle");return this(e.value)},"Array | Matrix":function(e){return Gq(e,this)}})})),nK="sign",rK=YH(nK,["typed","BigNumber","Fraction","complex"],(e=>{var{typed:t,BigNumber:n,complex:r,Fraction:a}=e;return t(nK,{number:mW,Complex:function(e){return 0===e.im?r(mW(e.re)):e.sign()},BigNumber:function(e){return new n(e.cmp(0))},Fraction:function(e){return new a(e.s,1)},"Array | Matrix":function(e){return Gq(e,this,!0)},Unit:function(e){if(!e._isDerived()&&0!==e.units[0].unit.offset)throw new TypeError("sign is ambiguous for units with offset");return this(e.value)}})})),aK=YH("sin",["typed"],(e=>{var{typed:t}=e;return t("sin",{number:Math.sin,Complex:function(e){return e.sin()},BigNumber:function(e){return e.sin()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return this(e.value)},"Array | Matrix":function(e){return Gq(e,this,!0)}})})),iK=YH("SparseMatrix",["typed","equalScalar","Matrix"],(e=>{var{typed:t,equalScalar:n,Matrix:r}=e;function a(e,t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!HP(t))throw new Error("Invalid datatype: "+t);if(UP(e))!function(e,t,n){"SparseMatrix"===t.type?(e._values=t._values?wH(t._values):void 0,e._index=wH(t._index),e._ptr=wH(t._ptr),e._size=wH(t._size),e._datatype=n||t._datatype):i(e,t.valueOf(),n||t._datatype)}(this,e,t);else if(e&&jP(e.index)&&jP(e.ptr)&&jP(e.size))this._values=e.values,this._index=e.index,this._ptr=e.ptr,this._size=e.size,this._datatype=t||e.datatype;else if(jP(e))i(this,e,t);else{if(e)throw new TypeError("Unsupported type of data ("+_H(e)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=t}}function i(e,r,a){e._values=[],e._index=[],e._ptr=[],e._datatype=a;var i=r.length,s=0,o=n,u=0;if(HP(a)&&(o=t.find(n,[a,a])||n,u=t.convert(0,a)),i>0){var l=0;do{e._ptr.push(e._index.length);for(var c=0;c");if(1===i.length)t.dimension(0).forEach((function(t,a){iq(t),e.set([t,0],n[a[0]],r)}));else{var l=t.dimension(0),c=t.dimension(1);l.forEach((function(t,a){iq(t),c.forEach((function(i,s){iq(i),e.set([t,i],n[a[0]][s[0]],r)}))}))}}return e}function u(e,t,n,r){if(n-t==0)return n;for(var a=t;af){for(c=f;ch){if(d){var m=0;for(c=0;cr-1&&(e._values.splice(p,1),e._index.splice(p,1),y++)}e._ptr[c]=e._values.length}return e._size[0]=r,e._size[1]=a,e}function p(e,t,n,r,a){var i,s,o=r[0],u=r[1],l=[];for(i=0;io-1||s>p-1)&&(c(this,Math.max(i+1,o),Math.max(s+1,p),a),o=this._size[0],p=this._size[1]),iq(i,o),iq(s,p);var f=u(i,this._ptr[s],this._ptr[s+1],this._index);return fArray.isArray(e)&&1===e.length?e[0]:e));if(2!==r.length)throw new Error("Only two dimensions matrix are supported");return r.forEach((function(e){if(!FP(e)||!jH(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+KU(r)+")")})),c(n?this.clone():this,r[0],r[1],t)},a.prototype.reshape=function(e,t){if(!jP(e))throw new TypeError("Array expected");if(2!==e.length)throw new Error("Sparse matrices can only be reshaped in two dimensions");e.forEach((function(t){if(!FP(t)||!jH(t)||t<=-2||0===t)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+KU(e)+")")}));var n=this._size[0]*this._size[1];if(n!==(e=lq(e,n))[0]*e[1])throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var r=t?this.clone():this;if(this._size[0]===e[0]&&this._size[1]===e[1])return r;for(var a=[],i=0;i=0&&v<=i&&m(e._values[x],v-0,g-0)}else{for(var _={},w=y;w "+(this._values?KU(this._values[u],e):"X");return a},a.prototype.toString=function(){return KU(this.toArray())},a.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},a.prototype.diagonal=function(e){if(e){if(YP(e)&&(e=e.toNumber()),!FP(e)||!jH(e))throw new TypeError("The parameter k must be an integer number")}else e=0;var t=e>0?e:0,n=e<0?-e:0,r=this._size[0],i=this._size[1],s=Math.min(r-n,i-t),o=[],u=[],l=[];l[0]=0;for(var c=t;c0?i:0,d=i<0?-i:0,h=e[0],f=e[1],m=Math.min(h-d,f-p);if(jP(r)){if(r.length!==m)throw new Error("Invalid value array length");c=function(e){return r[e]}}else if(UP(r)){var g=r.size();if(1!==g.length||g[0]!==m)throw new Error("Invalid matrix length");c=function(e){return r.get([e])}}else c=function(){return r};for(var y=[],b=[],x=[],v=0;v=0&&_=l||a[p]!==t)){var h=r?r[c]:void 0;a.splice(p,0,t),r&&r.splice(p,0,h),a.splice(p<=c?c+1:c,1),r&&r.splice(p<=c?c+1:c,1)}else if(p=l||a[c]!==e)){var f=r?r[p]:void 0;a.splice(c,0,e),r&&r.splice(c,0,f),a.splice(c<=p?p+1:p,1),r&&r.splice(c<=p?p+1:p,1)}}},a}),{isClass:!0}),sK="splitUnit",oK=YH(sK,["typed"],(e=>{var{typed:t}=e;return t(sK,{"Unit, Array":function(e,t){return e.splitUnit(t)}})})),uK="square",lK=YH(uK,["typed"],(e=>{var{typed:t}=e;return t(uK,{number:gW,Complex:function(e){return e.mul(e)},BigNumber:function(e){return e.times(e)},Fraction:function(e){return e.mul(e)},"Array | Matrix":function(e){return Gq(e,this,!0)},Unit:function(e){return e.pow(2)}})})),cK="string",pK=YH(cK,["typed"],(e=>{var{typed:t}=e;return t(cK,{"":function(){return""},number:XH,null:function(e){return"null"},boolean:function(e){return e+""},string:function(e){return e},"Array | Matrix":function(e){return Gq(e,this)},any:function(e){return String(e)}})})),dK=YH("tan",["typed"],(e=>{var{typed:t}=e;return t("tan",{number:Math.tan,Complex:function(e){return e.tan()},BigNumber:function(e){return e.tan()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return this(e.value)},"Array | Matrix":function(e){return Gq(e,this,!0)}})})),hK="typeOf",fK=YH(hK,["typed"],(e=>{var{typed:t}=e;return t(hK,{any:_H})})),mK="acosh",gK=YH(mK,["typed","config","Complex"],(e=>{var{typed:t,config:n,Complex:r}=e;return t(mK,{number:function(e){return e>=1||n.predictable?kW(e):e<=-1?new r(Math.log(Math.sqrt(e*e-1)-e),Math.PI):new r(e,0).acosh()},Complex:function(e){return e.acosh()},BigNumber:function(e){return e.acosh()},"Array | Matrix":function(e){return Gq(e,this)}})})),yK="acsch",bK=YH(yK,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t(yK,{number:EW,Complex:function(e){return e.acsch()},BigNumber:function(e){return new n(1).div(e).asinh()},"Array | Matrix":function(e){return Gq(e,this)}})})),xK="apply",vK=YH(xK,["typed","isInteger"],(e=>{var{typed:t,isInteger:n}=e;return t(xK,{"Array | Matrix, number | BigNumber, function":function(e,t,r){if(!n(t))throw new TypeError("Integer number expected for dimension");var a=Array.isArray(e)?nq(e):e.size();if(t<0||t>=a.length)throw new tq(t,a.length);return UP(e)?e.create(_K(e.valueOf(),t,r)):_K(e,t,r)}})}));function _K(e,t,n){var r,a,i;if(t<=0){if(Array.isArray(e[0])){for(i=function(e){var t,n,r=e.length,a=e[0].length,i=[];for(n=0;n{var{typed:t,config:n,Complex:r,BigNumber:a}=e;return t(wK,{number:function(e){return e<=-1||e>=1||n.predictable?CW(e):new r(e,0).asec()},Complex:function(e){return e.asec()},BigNumber:function(e){return new a(1).div(e).acos()},"Array | Matrix":function(e){return Gq(e,this)}})})),NK=YH("bin",["typed","format"],(e=>{var{typed:t,format:n}=e;return t("bin",{"number | BigNumber":function(e){return n(e,{notation:"bin"})},"number | BigNumber, number":function(e,t){return n(e,{notation:"bin",wordSize:t})}})})),SK="combinationsWithRep",kK=YH(SK,["typed"],(e=>{var{typed:t}=e;return t(SK,{"number, number":function(e,t){if(!jH(e)||e<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!jH(t)||t<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(e<1)throw new TypeError("k must be less than or equal to n + k - 1");return t{var{typed:t}=e;return t("cos",{number:Math.cos,Complex:function(e){return e.cos()},BigNumber:function(e){return e.cos()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return this(e.value)},"Array | Matrix":function(e){return Gq(e,this)}})})),IK="csch",EK=YH(IK,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t(IK,{number:YW,Complex:function(e){return e.csch()},BigNumber:function(e){return new n(1).div(e.sinh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csch is no angle");return this(e.value)},"Array | Matrix":function(e){return Gq(e,this)}})})),CK="isNaN",AK=YH(CK,["typed"],(e=>{var{typed:t}=e;return t(CK,{number:fG,BigNumber:function(e){return e.isNaN()},Fraction:function(e){return!1},Complex:function(e){return e.isNaN()},Unit:function(e){return Number.isNaN(e.value)},"Array | Matrix":function(e){return Gq(e,Number.isNaN)}})})),LK="isPrime",$K=YH(LK,["typed"],(e=>{var{typed:t}=e;return t(LK,{number:function(e){if(0*e!=0)return!1;if(e<=3)return e>1;if(e%2==0||e%3==0)return!1;for(var t=5;t*t<=e;t+=6)if(e%t==0||e%(t+2)==0)return!1;return!0},BigNumber:function(e){if(0*e.toNumber()!=0)return!1;if(e.lte(3))return e.gt(1);if(e.mod(2).eq(0)||e.mod(3).eq(0))return!1;if(e.lt(Math.pow(2,32))){for(var t=e.toNumber(),n=5;n*n<=t;n+=6)if(t%n==0||t%(n+2)==0)return!1;return!0}function r(e,t,n){for(var r=1;!t.eq(0);)t.mod(2).eq(0)?(t=t.div(2),e=e.mul(e).mod(n)):(t=t.sub(1),r=e.mul(r).mod(n));return r}for(var a=e.constructor.clone({precision:2*e.toFixed(0).length}),i=0,s=(e=new a(e)).sub(1);s.mod(2).eq(0);)s=s.div(2),i+=1;var o=null;if(e.lt("3317044064679887385961981"))o=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter((t=>t{var{typed:t,config:n,on:r}=e,a=qG(n.randomSeed);return r&&r("config",(function(e,t){e.randomSeed!==t.randomSeed&&(a=qG(e.randomSeed))})),t(OK,{"":()=>s(0,1),number:e=>s(0,e),"number, number":(e,t)=>s(e,t),"Array | Matrix":e=>i(e,0,1),"Array | Matrix, number":(e,t)=>i(e,0,t),"Array | Matrix, number, number":(e,t,n)=>i(e,t,n)});function i(e,t,n){var r=XG(e.valueOf(),(()=>s(t,n)));return UP(e)?e.create(r):r}function s(e,t){return Math.floor(e+a()*(t-e))}})),FK="sech",YK=YH(FK,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t(FK,{number:BW,Complex:function(e){return e.sech()},BigNumber:function(e){return new n(1).div(e.cosh())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sech is no angle");return this(e.value)},"Array | Matrix":function(e){return Gq(e,this)}})})),zK="sinh",BK=YH(zK,["typed"],(e=>{var{typed:t}=e;return t(zK,{number:PW,Complex:function(e){return e.sinh()},BigNumber:function(e){return e.sinh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sinh is no angle");return this(e.value)},"Array | Matrix":function(e){return Gq(e,this,!0)}})})),PK="sparse",HK=YH(PK,["typed","SparseMatrix"],(e=>{var{typed:t,SparseMatrix:n}=e;return t(PK,{"":function(){return new n([])},string:function(e){return new n([],e)},"Array | Matrix":function(e){return new n(e)},"Array | Matrix, string":function(e,t){return new n(e,t)}})})),jK=YH("sqrt",["config","typed","Complex"],(e=>{var{config:t,typed:n,Complex:r}=e;return n("sqrt",{number:a,Complex:function(e){return e.sqrt()},BigNumber:function(e){return!e.isNegative()||t.predictable?e.sqrt():a(e.toNumber())},"Array | Matrix":function(e){return Gq(e,this,!0)},Unit:function(e){return e.pow(.5)}});function a(e){return isNaN(e)?NaN:e>=0||t.predictable?Math.sqrt(e):new r(e,0).sqrt()}})),UK=YH("tanh",["typed"],(e=>{var{typed:t}=e;return t("tanh",{number:cj,Complex:function(e){return e.tanh()},BigNumber:function(e){return e.tanh()},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tanh is no angle");return this(e.value)},"Array | Matrix":function(e){return Gq(e,this,!0)}})})),qK="unaryMinus",WK=YH(qK,["typed"],(e=>{var{typed:t}=e;return t(qK,{number:rW,Complex:function(e){return e.neg()},BigNumber:function(e){return e.neg()},Fraction:function(e){return e.neg()},Unit:function(e){var t=e.clone();return t.value=this(e.value),t},"Array | Matrix":function(e){return Gq(e,this,!0)}})})),VK="acoth",GK=YH(VK,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:n,Complex:r,BigNumber:a}=e;return t(VK,{number:function(e){return e>=1||e<=-1||n.predictable?TW(e):new r(e,0).acoth()},Complex:function(e){return e.acoth()},BigNumber:function(e){return new a(1).div(e).atanh()},"Array | Matrix":function(e){return Gq(e,this)}})})),KK=YH("cot",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t("cot",{number:OW,Complex:function(e){return e.cot()},BigNumber:function(e){return new n(1).div(e.tan())},Unit:function(e){if(!e.hasBase(e.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return this(e.value)},"Array | Matrix":function(e){return Gq(e,this)}})})),JK=YH("fraction",["typed","Fraction"],(e=>{var{typed:t,Fraction:n}=e;return t("fraction",{number:function(e){if(!isFinite(e)||isNaN(e))throw new Error(e+" cannot be represented as a fraction");return new n(e)},string:function(e){return new n(e)},"number, number":function(e,t){return new n(e,t)},null:function(e){return new n(0)},BigNumber:function(e){return new n(e.toString())},Fraction:function(e){return e},Object:function(e){return new n(e)},"Array | Matrix":function(e){return Gq(e,this)}})})),XK="isNumeric",ZK=YH(XK,["typed"],(e=>{var{typed:t}=e;return t(XK,{"number | BigNumber | Fraction | boolean":function(){return!0},"Complex | Unit | string | null | undefined | Node":function(){return!1},"Array | Matrix":function(e){return Gq(e,this)}})})),QK="matrix",eJ=YH(QK,["typed","Matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,Matrix:n,DenseMatrix:r,SparseMatrix:a}=e;return t(QK,{"":function(){return i([])},string:function(e){return i([],e)},"string, string":function(e,t){return i([],e,t)},Array:function(e){return i(e)},Matrix:function(e){return i(e,e.storage())},"Array | Matrix, string":i,"Array | Matrix, string, string":i});function i(e,t,n){if("dense"===t||"default"===t||void 0===t)return new r(e,n);if("sparse"===t)return new a(e,n);throw new TypeError("Unknown matrix type "+JSON.stringify(t)+".")}})),tJ="matrixFromFunction",nJ=YH(tJ,["typed","matrix","isZero"],(e=>{var{typed:t,matrix:n,isZero:r}=e;return t(tJ,{"Array | Matrix, function, string, string":function(e,t,n,r){return a(e,t,n,r)},"Array | Matrix, function, string":function(e,t,n){return a(e,t,n)},"Matrix, function":function(e,t){return a(e,t,"dense")},"Array, function":function(e,t){return a(e,t,"dense").toArray()},"Array | Matrix, string, function":function(e,t,n){return a(e,n,t)},"Array | Matrix, string, string, function":function(e,t,n,r){return a(e,r,t,n)}});function a(e,t,a,i){var s;return(s=void 0!==i?n(a,i):n(a)).resize(e),s.forEach((function(e,n){var a=t(n);r(a)||s.set(n,a)})),s}})),rJ=YH("algorithm02",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:n}=e;return function(e,r,a,i){var s=e._data,o=e._size,u=e._datatype,l=r._values,c=r._index,p=r._ptr,d=r._size,h=r._datatype;if(o.length!==d.length)throw new eq(o.length,d.length);if(o[0]!==d[0]||o[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+d+")");if(!l)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var f,m=o[0],g=o[1],y=n,b=0,x=a;"string"==typeof u&&u===h&&(f=u,y=t.find(n,[f,f]),b=t.convert(0,f),x=t.find(a,[f,f]));for(var v=[],_=[],w=[],M=0;M{var{typed:t}=e;return function(e,n,r,a){var i=e._data,s=e._size,o=e._datatype,u=n._values,l=n._index,c=n._ptr,p=n._size,d=n._datatype;if(s.length!==p.length)throw new eq(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");if(!u)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h,f=s[0],m=s[1],g=0,y=r;"string"==typeof o&&o===d&&(h=o,g=t.convert(0,h),y=t.find(r,[h,h]));for(var b=[],x=0;x{var{typed:t,equalScalar:n}=e;return function(e,r,a){var i=e._values,s=e._index,o=e._ptr,u=e._size,l=e._datatype,c=r._values,p=r._index,d=r._ptr,h=r._size,f=r._datatype;if(u.length!==h.length)throw new eq(u.length,h.length);if(u[0]!==h[0]||u[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+h+")");var m,g=u[0],y=u[1],b=n,x=0,v=a;"string"==typeof l&&l===f&&(m=l,b=t.find(n,[m,m]),x=t.convert(0,m),v=t.find(a,[m,m]));var _,w,M,N,S=i&&c?[]:void 0,k=[],D=[],T=S?[]:void 0,I=S?[]:void 0,E=[],C=[];for(w=0;w{var{typed:t,equalScalar:n}=e;return function(e,r,a,i){var s=e._values,o=e._index,u=e._ptr,l=e._size,c=e._datatype;if(!s)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p,d=l[0],h=l[1],f=n,m=0,g=a;"string"==typeof c&&(p=c,f=t.find(n,[p,p]),m=t.convert(0,p),r=t.convert(r,p),g=t.find(a,[p,p]));for(var y=[],b=[],x=[],v=0;v{var{typed:t,DenseMatrix:n}=e;return function(e,r,a,i){var s=e._values,o=e._index,u=e._ptr,l=e._size,c=e._datatype;if(!s)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p,d=l[0],h=l[1],f=a;"string"==typeof c&&(p=c,r=t.convert(r,p),f=t.find(a,[p,p]));for(var m=[],g=[],y=[],b=0;b{var{typed:t}=e;return function(e,r,a){var i,s=e._data,o=e._size,u=e._datatype,l=r._data,c=r._size,p=r._datatype,d=[];if(o.length!==c.length)throw new eq(o.length,c.length);for(var h=0;h0?n(f,0,d,d[0],s,l):[];return e.createDenseMatrix({data:m,size:d,datatype:i})};function n(e,t,r,a,i,s){var o=[];if(t===r.length-1)for(var u=0;u{var{typed:t}=e;return function(e,r,a,i){var s,o=e._data,u=e._size,l=e._datatype,c=a;"string"==typeof l&&(s=l,r=t.convert(r,s),c=t.find(a,[s,s]));var p=u.length>0?n(c,0,u,u[0],o,r,i):[];return e.createDenseMatrix({data:p,size:wH(u),datatype:s})};function n(e,t,r,a,i,s,o){var u=[];if(t===r.length-1)for(var l=0;l{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:a}=e,i=rJ({typed:t,equalScalar:r}),s=aJ({typed:t}),o=iJ({typed:t,equalScalar:r}),u=sJ({typed:t,equalScalar:r}),l=oJ({typed:t,DenseMatrix:a}),c=uJ({typed:t}),p=lJ({typed:t});return t("mod",{"number, number":hW,"BigNumber, BigNumber":function(e,t){if(t.isNeg())throw new Error("Cannot calculate mod for a negative divisor");return t.isZero()?e:e.mod(t)},"Fraction, Fraction":function(e,t){if(t.compare(0)<0)throw new Error("Cannot calculate mod for a negative divisor");return e.compare(0)>=0?e.mod(t):e.mod(t).add(t).mod(t)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return p(e,t,this,!1)},"any, SparseMatrix":function(e,t){return l(t,e,this,!0)},"any, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, any":function(e,t){return p(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return p(n(t),e,this,!0).valueOf()}})})),pJ=YH("algorithm01",["typed"],(e=>{var{typed:t}=e;return function(e,n,r,a){var i=e._data,s=e._size,o=e._datatype,u=n._values,l=n._index,c=n._ptr,p=n._size,d=n._datatype;if(s.length!==p.length)throw new eq(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");if(!u)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h,f,m=s[0],g=s[1],y="string"==typeof o&&o===d?o:void 0,b=y?t.find(r,[y,y]):r,x=[];for(h=0;h{var{typed:t,equalScalar:n}=e;return function(e,r,a){var i=e._values,s=e._size,o=e._datatype,u=r._values,l=r._size,c=r._datatype;if(s.length!==l.length)throw new eq(s.length,l.length);if(s[0]!==l[0]||s[1]!==l[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+l+")");var p,d=s[0],h=s[1],f=n,m=0,g=a;"string"==typeof o&&o===c&&(p=o,f=t.find(n,[p,p]),m=t.convert(0,p),g=t.find(a,[p,p]));for(var y=i&&u?[]:void 0,b=[],x=[],v=y?[]:void 0,_=[],w=[],M=0;M{var{typed:t,matrix:n,equalScalar:r,BigNumber:a}=e,i=pJ({typed:t}),s=rJ({typed:t,equalScalar:r}),o=dJ({typed:t,equalScalar:r}),u=sJ({typed:t,equalScalar:r}),l=uJ({typed:t}),c=lJ({typed:t}),p="Complex number not supported in function nthRoot. Use nthRoots instead.";return t(hJ,{number:fW,"number, number":fW,BigNumber:function(e){return d(e,new a(2))},Complex:function(e){throw new Error(p)},"Complex, number":function(e,t){throw new Error(p)},"BigNumber, BigNumber":d,"Array | Matrix":function(e){return this(e,2)},"SparseMatrix, SparseMatrix":function(e,t){if(1===t.density())return o(e,t,this);throw new Error("Root must be non-zero")},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){if(1===t.density())return i(e,t,this,!1);throw new Error("Root must be non-zero")},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){if(1===t.density())return u(t,e,this,!0);throw new Error("Root must be non-zero")},"number | BigNumber, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(n(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,n(t)).valueOf()}});function d(e,t){var n=a.precision,r=a.clone({precision:n+2}),i=new a(0),s=new r(1),o=t.isNegative();if(o&&(t=t.neg()),t.isZero())throw new Error("Root must be non-zero");if(e.isNegative()&&!t.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(e.isZero())return o?new r(1/0):0;if(!e.isFinite())return o?i:e;var u=e.abs().pow(s.div(t));return u=e.isNeg()?u.neg():u,new a((o?s.div(u):u).toPrecision(n))}}));function mJ(){throw new Error('No "bignumber" implementation available')}function gJ(){throw new Error('No "fraction" implementation available')}function yJ(){throw new Error('No "matrix" implementation available')}var bJ=YH("numeric",["number","?bignumber","?fraction"],(e=>{var{number:t,bignumber:n,fraction:r}=e,a={string:!0,number:!0,BigNumber:!0,Fraction:!0},i={number:e=>t(e),BigNumber:n?e=>n(e):mJ,Fraction:r?e=>r(e):gJ};return function(e,t){var n=_H(e);if(!(n in a))throw new TypeError("Cannot convert "+e+' of type "'+n+'"; valid input types are '+Object.keys(a).join(", "));if(!(t in i))throw new TypeError("Cannot convert "+e+' to type "'+t+'"; valid output types are '+Object.keys(i).join(", "));return t===n?e:i[t](e)}})),xJ=YH("or",["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:a}=e,i=aJ({typed:t}),s=iJ({typed:t,equalScalar:r}),o=oJ({typed:t,DenseMatrix:a}),u=uJ({typed:t}),l=lJ({typed:t});return t("or",{"number, number":YG,"Complex, Complex":function(e,t){return 0!==e.re||0!==e.im||0!==t.re||0!==t.im},"BigNumber, BigNumber":function(e,t){return!e.isZero()&&!e.isNaN()||!t.isZero()&&!t.isNaN()},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return l(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, any":function(e,t){return l(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return l(n(t),e,this,!0).valueOf()}})}));function vJ(e,t,n){var r;return-1!==String(e).indexOf("Unexpected type")?(r=arguments.length>2?" (type: "+_H(n)+", value: "+JSON.stringify(n)+")":" (type: "+e.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+r)):-1!==String(e).indexOf("complex numbers")?(r=arguments.length>2?" (type: "+_H(n)+", value: "+JSON.stringify(n)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+r)):e}var _J="prod",wJ=YH(_J,["typed","config","multiplyScalar","numeric"],(e=>{var{typed:t,config:n,multiplyScalar:r,numeric:a}=e;return t(_J,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("prod(A, dim) is not yet supported")},"...":function(e){return i(e)}});function i(e){var t;if(Vq(e,(function(e){try{t=void 0===t?e:r(t,e)}catch(t){throw vJ(t,"prod",e)}})),"string"==typeof t&&(t=a(t,n.number)),void 0===t)throw new Error("Cannot calculate prod of an empty array");return t}})),MJ="reshape",NJ=YH(MJ,["typed","isInteger","matrix"],(e=>{var{typed:t,isInteger:n}=e;return t(MJ,{"Matrix, Array":function(e,t){return e.reshape(t)},"Array, Array":function(e,t){return t.forEach((function(e){if(!n(e))throw new TypeError("Invalid size for dimension: "+e)})),uq(e,t)}})})),SJ="size",kJ=YH(SJ,["typed","config","?matrix"],(e=>{var{typed:t,config:n,matrix:r}=e;return t(SJ,{Matrix:function(e){return e.create(e.size())},Array:nq,string:function(e){return"Array"===n.matrix?[e.length]:r([e.length])},"number | Complex | BigNumber | Unit | boolean | null":function(e){return"Array"===n.matrix?[]:r?r([]):yJ()}})})),DJ=YH("algorithm07",["typed","DenseMatrix"],(e=>{var{typed:t,DenseMatrix:n}=e;return function(e,a,i){var s=e._size,o=e._datatype,u=a._size,l=a._datatype;if(s.length!==u.length)throw new eq(s.length,u.length);if(s[0]!==u[0]||s[1]!==u[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+u+")");var c,p,d,h=s[0],f=s[1],m=0,g=i;"string"==typeof o&&o===l&&(c=o,m=t.convert(0,c),g=t.find(i,[c,c]));var y=[];for(p=0;p{var{typed:t,config:n,matrix:r,DenseMatrix:a}=e,i=aJ({typed:t}),s=DJ({typed:t,DenseMatrix:a}),o=oJ({typed:t,DenseMatrix:a}),u=uJ({typed:t}),l=lJ({typed:t});return t(TJ,{"boolean, boolean":function(e,t){return e{var{typed:t,matrix:n}=e;return t(EJ,{Array:function(e){return pq(wH(e))},Matrix:function(e){var t=pq(e.toArray());return Array.isArray(t)?n(t):t},any:function(e){return wH(e)}})})),AJ="subset",LJ=YH(AJ,["typed","matrix"],(e=>{var{typed:t,matrix:n}=e;return t(AJ,{"Array, Index":function(e,t){var r=n(e).subset(t);return t.isScalar()?r:r.valueOf()},"Matrix, Index":function(e,t){return e.subset(t)},"Object, Index":RJ,"string, Index":$J,"Array, Index, any":function(e,t,r){return n(wH(e)).subset(t,r,void 0).valueOf()},"Array, Index, any, any":function(e,t,r,a){return n(wH(e)).subset(t,r,a).valueOf()},"Matrix, Index, any":function(e,t,n){return e.clone().subset(t,n)},"Matrix, Index, any, any":function(e,t,n,r){return e.clone().subset(t,n,r)},"string, Index, string":OJ,"string, Index, string, string":OJ,"Object, Index, any":FJ})}));function $J(e,t){if(!KP(t))throw new TypeError("Index expected");if(1!==t.size().length)throw new eq(t.size().length,1);var n=e.length;iq(t.min()[0],n),iq(t.max()[0],n);var r=t.dimension(0),a="";return r.forEach((function(t){a+=e.charAt(t)})),a}function OJ(e,t,n,r){if(!t||!0!==t.isIndex)throw new TypeError("Index expected");if(1!==t.size().length)throw new eq(t.size().length,1);if(void 0!==r){if("string"!=typeof r||1!==r.length)throw new TypeError("Single character expected as defaultValue")}else r=" ";var a=t.dimension(0);if(a.size()[0]!==n.length)throw new eq(a.size()[0],n.length);var i=e.length;iq(t.min()[0]),iq(t.max()[0]);for(var s=[],o=0;oi)for(var u=i-1,l=s.length;u{var{typed:t,DenseMatrix:n}=e;return function(e,r,a,i){var s=e._values,o=e._index,u=e._ptr,l=e._size,c=e._datatype;if(!s)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p,d=l[0],h=l[1],f=a;"string"==typeof c&&(p=c,r=t.convert(r,p),f=t.find(a,[p,p]));for(var m=[],g=[],y=[],b=0;b{var{typed:t,matrix:n,equalScalar:r,addScalar:a,unaryMinus:i,DenseMatrix:s}=e,o=pJ({typed:t}),u=aJ({typed:t}),l=iJ({typed:t,equalScalar:r}),c=YJ({typed:t,DenseMatrix:s}),p=uJ({typed:t}),d=lJ({typed:t});return t(zJ,{"number, number":function(e,t){return e-t},"Complex, Complex":function(e,t){return e.sub(t)},"BigNumber, BigNumber":function(e,t){return e.minus(t)},"Fraction, Fraction":function(e,t){return e.sub(t)},"Unit, Unit":function(e,t){if(null===e.value)throw new Error("Parameter x contains a unit with undefined value");if(null===t.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(t))throw new Error("Units do not match");var n=e.clone();return n.value=this(n.value,t.value),n.fixPrefix=!1,n},"SparseMatrix, SparseMatrix":function(e,t){return PJ(e,t),l(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return PJ(e,t),u(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return PJ(e,t),o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return PJ(e,t),p(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return c(e,i(t),a)},"DenseMatrix, any":function(e,t){return d(e,t,this)},"any, SparseMatrix":function(e,t){return c(t,e,this,!0)},"any, DenseMatrix":function(e,t){return d(t,e,this,!0)},"Array, any":function(e,t){return d(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return d(n(t),e,this,!0).valueOf()}})}));function PJ(e,t){var n=e.size(),r=t.size();if(n.length!==r.length)throw new eq(n.length,r.length)}var HJ=YH("to",["typed","matrix"],(e=>{var{typed:t,matrix:n}=e,r=uJ({typed:t}),a=lJ({typed:t});return t("to",{"Unit, Unit | string":function(e,t){return e.to(t)},"Matrix, Matrix":function(e,t){return r(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"Matrix, any":function(e,t){return a(e,t,this,!1)},"any, Matrix":function(e,t){return a(t,e,this,!0)},"Array, any":function(e,t){return a(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return a(n(t),e,this,!0).valueOf()}})})),jJ=YH("transpose",["typed","matrix"],(e=>{var{typed:t,matrix:n}=e;return t("transpose",{Array:function(e){return this(n(e)).valueOf()},Matrix:function(e){var t,n=e.size();switch(n.length){case 1:t=e.clone();break;case 2:var r=n[0],a=n[1];if(0===a)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+KU(n)+")");switch(e.storage()){case"dense":t=function(e,t,n){for(var r,a=e._data,i=[],s=0;s{var{typed:t,config:n,matrix:r,BigNumber:a}=e;return t(UJ,{"number, number":function(e,t){var a=yW(e,t);return"Array"===n.matrix?a:r(a)},"BigNumber, BigNumber":function(e,t){var i,s,o,u,l=new a(0),c=new a(1),p=l,d=c,h=c,f=l;if(!e.isInt()||!t.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!t.isZero();)s=e.div(t).floor(),o=e.mod(t),i=p,p=d.minus(s.times(p)),d=i,i=h,h=f.minus(s.times(h)),f=i,e=t,t=o;return u=e.lt(l)?[e.neg(),d.neg(),f.neg()]:[e,e.isZero()?0:d,f],"Array"===n.matrix?u:r(u)}})})),WJ="zeros",VJ=YH(WJ,["typed","config","matrix","BigNumber"],(e=>{var{typed:t,config:n,matrix:r,BigNumber:a}=e;return t(WJ,{"":function(){return"Array"===n.matrix?i([]):i([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var t=e.pop();return i(e,t)}return"Array"===n.matrix?i(e):i(e,"default")},Array:i,Matrix:function(e){var t=e.storage();return i(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return i(e.valueOf(),t)}});function i(e,t){var n=function(e){var t=!1;return e.forEach((function(e,n,r){YP(e)&&(t=!0,r[n]=e.toNumber())})),t}(e),i=n?new a(0):0;if(function(e){e.forEach((function(e){if("number"!=typeof e||!jH(e)||e<0)throw new Error("Parameters in function zeros must be positive integers")}))}(e),t){var s=r(t);return e.length>0?s.resize(e,i):s}var o=[];return e.length>0?sq(o,e,i):o}})),GJ=YH("and",["typed","matrix","equalScalar","zeros","not"],(e=>{var{typed:t,matrix:n,equalScalar:r,zeros:a,not:i}=e,s=rJ({typed:t,equalScalar:r}),o=dJ({typed:t,equalScalar:r}),u=sJ({typed:t,equalScalar:r}),l=uJ({typed:t}),c=lJ({typed:t});return t("and",{"number, number":BG,"Complex, Complex":function(e,t){return!(0===e.re&&0===e.im||0===t.re&&0===t.im)},"BigNumber, BigNumber":function(e,t){return!(e.isZero()||t.isZero()||e.isNaN()||t.isNaN())},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return i(t)?a(e.size(),e.storage()):u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return i(t)?a(e.size(),e.storage()):c(e,t,this,!1)},"any, SparseMatrix":function(e,t){return i(e)?a(e.size(),e.storage()):u(t,e,this,!0)},"any, DenseMatrix":function(e,t){return i(e)?a(e.size(),e.storage()):c(t,e,this,!0)},"Array, any":function(e,t){return this(n(e),t).valueOf()},"any, Array":function(e,t){return this(e,n(t)).valueOf()}})})),KJ="bitAnd",JJ=YH(KJ,["typed","matrix","equalScalar"],(e=>{var{typed:t,matrix:n,equalScalar:r}=e,a=rJ({typed:t,equalScalar:r}),i=dJ({typed:t,equalScalar:r}),s=sJ({typed:t,equalScalar:r}),o=uJ({typed:t}),u=lJ({typed:t});return t(KJ,{"number, number":pV,"BigNumber, BigNumber":nV,"SparseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return o(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(n(t),e,this,!0).valueOf()}})})),XJ="bitXor",ZJ=YH(XJ,["typed","matrix","DenseMatrix"],(e=>{var{typed:t,matrix:n,DenseMatrix:r}=e,a=aJ({typed:t}),i=DJ({typed:t,DenseMatrix:r}),s=oJ({typed:t,DenseMatrix:r}),o=uJ({typed:t}),u=lJ({typed:t});return t(XJ,{"number, number":fV,"BigNumber, BigNumber":oV,"SparseMatrix, SparseMatrix":function(e,t){return i(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return o(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(n(t),e,this,!0).valueOf()}})})),QJ="cbrt",eX=YH(QJ,["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],(e=>{var{config:t,typed:n,isNegative:r,unaryMinus:a,matrix:i,Complex:s,BigNumber:o,Fraction:u}=e;return n(QJ,{number:iW,Complex:l,"Complex, boolean":l,BigNumber:function(e){return e.cbrt()},Unit:function(e){if(e.value&&zP(e.value)){var t=e.clone();return t.value=1,(t=t.pow(1/3)).value=l(e.value),t}var n,i=r(e.value);i&&(e.value=a(e.value)),n=YP(e.value)?new o(1).div(3):BP(e.value)?new u(1,3):1/3;var s=e.pow(n);return i&&(s.value=a(s.value)),s},"Array | Matrix":function(e){return Gq(e,this,!0)}});function l(e,n){var r=e.arg()/3,a=e.abs(),o=new s(iW(a),0).mul(new s(0,r).exp());if(n){var u=[o,new s(iW(a),0).mul(new s(0,r+2*Math.PI/3).exp()),new s(iW(a),0).mul(new s(0,r-2*Math.PI/3).exp())];return"Array"===t.matrix?u:i(u)}return o}})),tX="compare",nX=YH(tX,["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix"],(e=>{var{typed:t,config:n,equalScalar:r,matrix:a,BigNumber:i,Fraction:s,DenseMatrix:o}=e,u=aJ({typed:t}),l=iJ({typed:t,equalScalar:r}),c=oJ({typed:t,DenseMatrix:o}),p=uJ({typed:t}),d=lJ({typed:t});return t(tX,{"boolean, boolean":function(e,t){return e===t?0:e>t?1:-1},"number, number":function(e,t){return aj(e,t,n.epsilon)?0:e>t?1:-1},"BigNumber, BigNumber":function(e,t){return zV(e,t,n.epsilon)?new i(0):new i(e.cmp(t))},"Fraction, Fraction":function(e,t){return new s(e.compare(t))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return l(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return u(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return p(e,t,this)},"Array, Array":function(e,t){return this(a(e),a(t)).valueOf()},"Array, Matrix":function(e,t){return this(a(e),t)},"Matrix, Array":function(e,t){return this(e,a(t))},"SparseMatrix, any":function(e,t){return c(e,t,this,!1)},"DenseMatrix, any":function(e,t){return d(e,t,this,!1)},"any, SparseMatrix":function(e,t){return c(t,e,this,!0)},"any, DenseMatrix":function(e,t){return d(t,e,this,!0)},"Array, any":function(e,t){return d(a(e),t,this,!1).valueOf()},"any, Array":function(e,t){return d(a(t),e,this,!0).valueOf()}})})),rX="compareText",aX=YH(rX,["typed","matrix"],(e=>{var{typed:t,matrix:n}=e,r=uJ({typed:t}),a=lJ({typed:t});return t(rX,{"any, any":QU,"DenseMatrix, DenseMatrix":function(e,t){return r(e,t,QU)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"DenseMatrix, any":function(e,t){return a(e,t,QU,!1)},"any, DenseMatrix":function(e,t){return a(t,e,QU,!0)},"Array, any":function(e,t){return a(n(e),t,QU,!1).valueOf()},"any, Array":function(e,t){return a(n(t),e,QU,!0).valueOf()}})})),iX="concat",sX=YH(iX,["typed","matrix","isInteger"],(e=>{var{typed:t,matrix:n,isInteger:r}=e;return t(iX,{"...Array | Matrix | number | BigNumber":function(e){var t,a,i=e.length,s=-1,o=!1,u=[];for(t=0;t0&&s>a)throw new tq(s,a+1)}else{var c=wH(l).valueOf(),p=nq(c);if(u[t]=c,a=s,s=p.length-1,t>0&&s!==a)throw new eq(a+1,s+1)}}if(0===u.length)throw new SyntaxError("At least one matrix expected");for(var d=u.shift();u.length;)d=oX(d,u.shift(),s,0);return o?n(d):d},"...string":function(e){return e.join("")}})}));function oX(e,t,n,r){if(r{var{typed:t,size:n,prod:r}=e;return t(uX,{string:function(e){return e.length},"Matrix | Array":function(e){return r(n(e))}})})),cX="ctranspose",pX=YH(cX,["typed","transpose","conj"],(e=>{var{typed:t,transpose:n,conj:r}=e;return t(cX,{any:function(e){return r(n(e))}})})),dX="diag",hX=YH(dX,["typed","matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,matrix:n,DenseMatrix:r,SparseMatrix:a}=e;return t(dX,{Array:function(e){return i(e,0,nq(e),null)},"Array, number":function(e,t){return i(e,t,nq(e),null)},"Array, BigNumber":function(e,t){return i(e,t.toNumber(),nq(e),null)},"Array, string":function(e,t){return i(e,0,nq(e),t)},"Array, number, string":function(e,t,n){return i(e,t,nq(e),n)},"Array, BigNumber, string":function(e,t,n){return i(e,t.toNumber(),nq(e),n)},Matrix:function(e){return i(e,0,e.size(),e.storage())},"Matrix, number":function(e,t){return i(e,t,e.size(),e.storage())},"Matrix, BigNumber":function(e,t){return i(e,t.toNumber(),e.size(),e.storage())},"Matrix, string":function(e,t){return i(e,0,e.size(),t)},"Matrix, number, string":function(e,t,n){return i(e,t,e.size(),n)},"Matrix, BigNumber, string":function(e,t,n){return i(e,t.toNumber(),e.size(),n)}});function i(e,t,i,s){if(!jH(t))throw new TypeError("Second parameter in function diag must be an integer");var o=t>0?t:0,u=t<0?-t:0;switch(i.length){case 1:return function(e,t,n,i,s,o){var u=[i+s,i+o];if(n&&"sparse"!==n&&"dense"!==n)throw new TypeError("Unknown matrix type ".concat(n,'"'));var l="sparse"===n?a.diagonal(u,e,t):r.diagonal(u,e,t);return null!==n?l:l.valueOf()}(e,t,s,i[0],u,o);case 2:return function(e,t,r,a,i,s){if(UP(e)){var o=e.diagonal(t);return null!==r?r!==o.storage()?n(o,r):o:o.valueOf()}for(var u=Math.min(a[0]-i,a[1]-s),l=[],c=0;c{var{typed:t,numeric:n}=e;return t(fX,{"number, number":function(e,t){return e/t},"Complex, Complex":function(e,t){return e.div(t)},"BigNumber, BigNumber":function(e,t){return e.div(t)},"Fraction, Fraction":function(e,t){return e.div(t)},"Unit, number | Fraction | BigNumber":function(e,t){var r=e.clone(),a=n(1,_H(t));return r.value=this(null===r.value?r._normalize(a):r.value,t),r},"number | Fraction | BigNumber, Unit":function(e,t){var r=t.clone();r=r.pow(-1);var a=n(1,_H(e));return r.value=this(e,null===t.value?t._normalize(a):t.value),r},"Unit, Unit":function(e,t){return e.divide(t)}})})),gX="dotDivide",yX=YH(gX,["typed","matrix","equalScalar","divideScalar","DenseMatrix"],(e=>{var{typed:t,matrix:n,equalScalar:r,divideScalar:a,DenseMatrix:i}=e,s=rJ({typed:t,equalScalar:r}),o=aJ({typed:t}),u=DJ({typed:t,DenseMatrix:i}),l=sJ({typed:t,equalScalar:r}),c=oJ({typed:t,DenseMatrix:i}),p=uJ({typed:t}),d=lJ({typed:t});return t(gX,{"any, any":a,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,a,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,a,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,a,!1)},"DenseMatrix, DenseMatrix":function(e,t){return p(e,t,a)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return l(e,t,a,!1)},"DenseMatrix, any":function(e,t){return d(e,t,a,!1)},"any, SparseMatrix":function(e,t){return c(t,e,a,!0)},"any, DenseMatrix":function(e,t){return d(t,e,a,!0)},"Array, any":function(e,t){return d(n(e),t,a,!1).valueOf()},"any, Array":function(e,t){return d(n(t),e,a,!0).valueOf()}})})),bX="equal",xX=YH(bX,["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:a}=e,i=aJ({typed:t}),s=DJ({typed:t,DenseMatrix:a}),o=oJ({typed:t,DenseMatrix:a}),u=uJ({typed:t}),l=lJ({typed:t});return t(bX,{"any, any":function(e,t){return null===e?null===t:null===t?null===e:void 0===e?void 0===t:void 0===t?void 0===e:r(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,r)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,r,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,r,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,r)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return o(e,t,r,!1)},"DenseMatrix, any":function(e,t){return l(e,t,r,!1)},"any, SparseMatrix":function(e,t){return o(t,e,r,!0)},"any, DenseMatrix":function(e,t){return l(t,e,r,!0)},"Array, any":function(e,t){return l(n(e),t,r,!1).valueOf()},"any, Array":function(e,t){return l(n(t),e,r,!0).valueOf()}})})),vX=(YH(bX,["typed","equalScalar"],(e=>{var{typed:t,equalScalar:n}=e;return t(bX,{"any, any":function(e,t){return null===e?null===t:null===t?null===e:void 0===e?void 0===t:void 0===t?void 0===e:n(e,t)}})})),YH("fft",["typed","matrix","addScalar","multiplyScalar","divideScalar","exp","tau","i"],(e=>{var{typed:t,matrix:n,addScalar:r,multiplyScalar:a,divideScalar:i,exp:s,tau:o,i:u}=e;return t("fft",{Array:l,Matrix:function(e){return e.create(l(e.toArray()))}});function l(e){var t=nq(e);return 1===t.length?p(e,t[0]):c(e.map((e=>l(e,t.slice(1)))),0)}function c(e,t){var n=nq(e);if(0!==t)return new Array(n[0]).fill(0).map(((n,r)=>c(e[r],t-1)));if(1===n.length)return p(e);function r(e){var t=nq(e);return new Array(t[1]).fill(0).map(((n,r)=>new Array(t[0]).fill(0).map(((t,n)=>e[n][r]))))}return r(c(r(e),1))}function p(e){var t=e.length;if(1===t)return[e[0]];if(t%2==0){for(var n=[...p(e.filter(((e,t)=>t%2==0))),...p(e.filter(((e,t)=>t%2==1)))],l=0;l{var{typed:t,matrix:n}=e;return t(_X,{Array:function(e){return mq(wH(e))},Matrix:function(e){var t=mq(wH(e.toArray()));return n(t)}})})),MX=YH("algorithm04",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:n}=e;return function(e,r,a){var i=e._values,s=e._index,o=e._ptr,u=e._size,l=e._datatype,c=r._values,p=r._index,d=r._ptr,h=r._size,f=r._datatype;if(u.length!==h.length)throw new eq(u.length,h.length);if(u[0]!==h[0]||u[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+h+")");var m,g=u[0],y=u[1],b=n,x=0,v=a;"string"==typeof l&&l===f&&(m=l,b=t.find(n,[m,m]),x=t.convert(0,m),v=t.find(a,[m,m]));var _,w,M,N,S,k=i&&c?[]:void 0,D=[],T=[],I=i&&c?[]:void 0,E=i&&c?[]:void 0,C=[],A=[];for(w=0;w{var{typed:t,matrix:n,equalScalar:r,BigNumber:a,DenseMatrix:i}=e,s=pJ({typed:t}),o=MX({typed:t,equalScalar:r}),u=YJ({typed:t,DenseMatrix:i}),l=uJ({typed:t}),c=lJ({typed:t});return t("gcd",{"number, number":lW,"BigNumber, BigNumber":function(e,t){if(!e.isInt()||!t.isInt())throw new Error("Parameters in function gcd must be integer numbers");for(var n=new a(0);!t.isZero();){var r=e.mod(t);e=t,t=r}return e.lt(n)?e.neg():e},"Fraction, Fraction":function(e,t){return e.gcd(t)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return u(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return c(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return c(n(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return c(n(t),e,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,t,n){for(var r=this(e,t),a=0;a{var{typed:t,isNumeric:n}=e;return t(SX,{string:function(e){return e.trim().length>0&&!isNaN(Number(e))},any:function(e){return n(e)}})})),DX="hypot",TX=YH(DX,["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],(e=>{var{typed:t,abs:n,addScalar:r,divideScalar:a,multiplyScalar:i,sqrt:s,smaller:o,isPositive:u}=e;return t(DX,{"... number | BigNumber":function(e){for(var t=0,l=0,c=0;c{var{typed:t,fft:n,dotDivide:r,conj:a}=e;return t(IX,{"Array | Matrix":function(e){var t=UP(e)?e.size():nq(e);return r(a(n(a(e))),t.reduce(((e,t)=>e*t),1))}})})),CX="kron",AX=YH(CX,["typed","matrix","multiplyScalar"],(e=>{var{typed:t,matrix:n,multiplyScalar:r}=e;return t(CX,{"Matrix, Matrix":function(e,t){return n(a(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return n(a(e.toArray(),t))},"Array, Matrix":function(e,t){return n(a(e,t.toArray()))},"Array, Array":a});function a(e,t){if(1===nq(e).length&&(e=[e]),1===nq(t).length&&(t=[t]),nq(e).length>2||nq(t).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(e.length)+", y = "+JSON.stringify(t.length)+")");var n=[],a=[];return e.map((function(e){return t.map((function(t){return a=[],n.push(a),e.map((function(e){return t.map((function(t){return a.push(r(e,t))}))}))}))}))&&n}})),LX="largerEq",$X=YH(LX,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:n,matrix:r,DenseMatrix:a}=e,i=aJ({typed:t}),s=DJ({typed:t,DenseMatrix:a}),o=oJ({typed:t,DenseMatrix:a}),u=uJ({typed:t}),l=lJ({typed:t});return t(LX,{"boolean, boolean":function(e,t){return e>=t},"number, number":function(e,t){return e>=t||aj(e,t,n.epsilon)},"BigNumber, BigNumber":function(e,t){return e.gte(t)||zV(e,t,n.epsilon)},"Fraction, Fraction":function(e,t){return-1!==e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return l(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, any":function(e,t){return l(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return l(r(t),e,this,!0).valueOf()}})})),OX=YH("algorithm08",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:n}=e;return function(e,r,a){var i=e._values,s=e._index,o=e._ptr,u=e._size,l=e._datatype,c=r._values,p=r._index,d=r._ptr,h=r._size,f=r._datatype;if(u.length!==h.length)throw new eq(u.length,h.length);if(u[0]!==h[0]||u[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+h+")");if(!i||!c)throw new Error("Cannot perform operation on Pattern Sparse Matrices");var m,g=u[0],y=u[1],b=n,x=0,v=a;"string"==typeof l&&l===f&&(m=l,b=t.find(n,[m,m]),x=t.convert(0,m),v=t.find(a,[m,m]));for(var _,w,M,N,S=[],k=[],D=[],T=[],I=[],E=0;E{var{typed:t,matrix:n,equalScalar:r,zeros:a,DenseMatrix:i}=e,s=pJ({typed:t}),o=rJ({typed:t,equalScalar:r}),u=OX({typed:t,equalScalar:r}),l=YJ({typed:t,DenseMatrix:i}),c=sJ({typed:t,equalScalar:r}),p=uJ({typed:t}),d=lJ({typed:t});return t(RX,{"number, number":mV,"BigNumber, BigNumber":uV,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return p(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, number | BigNumber":function(e,t){return r(t,0)?e.clone():c(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return r(t,0)?e.clone():d(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return r(e,0)?a(t.size(),t.storage()):l(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return r(e,0)?a(t.size(),t.storage()):d(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(n(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,n(t)).valueOf()}})}));function YX(e){var{DenseMatrix:t}=e;return function(e,n,r){var a=e.size();if(2!==a.length)throw new RangeError("Matrix must be two dimensional (size: "+KU(a)+")");var i=a[0];if(i!==a[1])throw new RangeError("Matrix must be square (size: "+KU(a)+")");var s=[];if(UP(n)){var o=n.size(),u=n._data;if(1===o.length){if(o[0]!==i)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var l=0;l{var{typed:t,matrix:n,divideScalar:r,multiplyScalar:a,subtract:i,equalScalar:s,DenseMatrix:o}=e,u=YX({DenseMatrix:o});return t(zX,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var n=(t=u(e,t,!0))._data,l=e._size[0],c=e._size[1],p=e._values,d=e._index,h=e._ptr,f=[],m=0;mm&&(b.push(p[w]),x.push(M))}if(s(y,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var N=r(g,y),S=0,k=x.length;S{var{typed:t,matrix:n,flatten:r,size:a}=e;return t(PX,{"...Array":function(e){return i(e)},"...Matrix":function(e){return n(i(e.map((e=>e.toArray()))))}});function i(e){if(0===e.length)throw new TypeError("At least one column is needed to construct a matrix.");for(var t=s(e[0]),n=[],a=0;a{var{typed:t,config:n,numeric:r,smaller:a}=e;return t("min",{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(e,t){return Kq(e,t.valueOf(),i)},"...":function(e){if(Wq(e))throw new TypeError("Scalar values expected in function min");return s(e)}});function i(e,t){try{return a(e,t)?e:t}catch(e){throw vJ(e,"min",t)}}function s(e){var t;if(Vq(e,(function(e){try{isNaN(e)&&"number"==typeof e?t=NaN:(void 0===t||a(e,t))&&(t=e)}catch(t){throw vJ(t,"min",e)}})),void 0===t)throw new Error("Cannot calculate min of an empty array");return"string"==typeof t&&(t=r(t,n.number)),t}})),UX="mode",qX=YH(UX,["typed","isNaN","isNumeric"],(e=>{var{typed:t,isNaN:n,isNumeric:r}=e;return t(UX,{"Array | Matrix":a,"...":function(e){return a(e)}});function a(e){if(0===(e=mq(e.valueOf())).length)throw new Error("Cannot calculate mode of an empty array");for(var t={},a=[],i=0,s=0;si&&(i=t[o],a=[o])}return a}})),WX="nthRoots",VX=YH(WX,["config","typed","divideScalar","Complex"],(e=>{var{typed:t,config:n,divideScalar:r,Complex:a}=e,i=[function(e){return new a(e,0)},function(e){return new a(0,e)},function(e){return new a(-e,0)},function(e){return new a(0,-e)}];function s(e,t){if(t<0)throw new Error("Root must be greater than zero");if(0===t)throw new Error("Root must be non-zero");if(t%1!=0)throw new Error("Root must be an integer");if(0===e||0===e.abs())return[new a(0,0)];var n,r="number"==typeof e;(r||0===e.re||0===e.im)&&(n=r?2*+(e<0):0===e.im?2*+(e.re<0):2*+(e.im<0)+1);for(var s=e.arg(),o=e.abs(),u=[],l=Math.pow(o,1/t),c=0;c{var{typed:t,config:n,matrix:r,BigNumber:a}=e;return t("ones",{"":function(){return"Array"===n.matrix?i([]):i([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var t=e.pop();return i(e,t)}return"Array"===n.matrix?i(e):i(e,"default")},Array:i,Matrix:function(e){var t=e.storage();return i(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return i(e.valueOf(),t)}});function i(e,t){var n=function(e){var t=!1;return e.forEach((function(e,n,r){YP(e)&&(t=!0,r[n]=e.toNumber())})),t}(e),i=n?new a(1):1;if(function(e){e.forEach((function(e){if("number"!=typeof e||!jH(e)||e<0)throw new Error("Parameters in function ones must be positive integers")}))}(e),t){var s=r(t);return e.length>0?s.resize(e,i):s}var o=[];return e.length>0?sq(o,e,i):o}})),KX="partitionSelect",JX=YH(KX,["typed","isNumeric","isNaN","compare"],(e=>{var{typed:t,isNumeric:n,isNaN:r,compare:a}=e,i=a,s=(e,t)=>-a(e,t);return t(KX,{"Array | Matrix, number":function(e,t){return o(e,t,i)},"Array | Matrix, number, string":function(e,t,n){if("asc"===n)return o(e,t,i);if("desc"===n)return o(e,t,s);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":o});function o(e,t,n){if(!jH(t)||t<0)throw new Error("k must be a non-negative integer");if(UP(e)){if(e.size().length>1)throw new Error("Only one dimensional matrices supported");return u(e.valueOf(),t,n)}if(Array.isArray(e))return u(e,t,n)}function u(e,t,a){if(t>=e.length)throw new Error("k out of bounds");for(var i=0;i=0){var p=e[l];e[l]=e[u],e[u]=p,--l}else++u;a(e[u],c)>0&&--u,t<=u?o=u:s=u+1}return e[t]}}));function XX(e,t,n,r){if(!(this instanceof XX))throw new SyntaxError("Constructor must be called with the new operator");this.fn=e,this.count=t,this.min=n,this.max=r,this.message="Wrong number of arguments in function "+e+" ("+t+" provided, "+n+(null!=r?"-"+r:"")+" expected)",this.stack=(new Error).stack}XX.prototype=new Error,XX.prototype.constructor=Error,XX.prototype.name="ArgumentsError",XX.prototype.isArgumentsError=!0;var ZX=YH("resize",["config","matrix"],(e=>{var{config:t,matrix:n}=e;return function(e,a,i){if(2!==arguments.length&&3!==arguments.length)throw new XX("resize",arguments.length,2,3);if(UP(a)&&(a=a.valueOf()),YP(a[0])&&(a=a.map((function(e){return YP(e)?e.toNumber():e}))),UP(e))return e.resize(a,i,!0);if("string"==typeof e)return r(e,a,i);var s=!Array.isArray(e)&&"Array"!==t.matrix;if(0===a.length){for(;Array.isArray(e);)e=e[0];return wH(e)}Array.isArray(e)||(e=[e]);var o=sq(e=wH(e),a,i);return s?n(o):o};function r(e,t,n){if(void 0!==n){if("string"!=typeof n||1!==n.length)throw new TypeError("Single character expected as defaultValue")}else n=" ";if(1!==t.length)throw new eq(t.length,1);var r=t[0];if("number"!=typeof r||!jH(r))throw new TypeError("Invalid size, must contain positive integers (size: "+KU(t)+")");if(e.length>r)return e.substring(0,r);if(e.length{var{typed:t,matrix:n,equalScalar:r,zeros:a,DenseMatrix:i}=e,s=pJ({typed:t}),o=rJ({typed:t,equalScalar:r}),u=OX({typed:t,equalScalar:r}),l=YJ({typed:t,DenseMatrix:i}),c=sJ({typed:t,equalScalar:r}),p=uJ({typed:t}),d=lJ({typed:t});return t(QX,{"number, number":gV,"BigNumber, BigNumber":lV,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return p(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, number | BigNumber":function(e,t){return r(t,0)?e.clone():c(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return r(t,0)?e.clone():d(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return r(e,0)?a(t.size(),t.storage()):l(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return r(e,0)?a(t.size(),t.storage()):d(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(n(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,n(t)).valueOf()}})})),tZ="Number of decimals in function round must be an integer",nZ="round",rZ=YH(nZ,["typed","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],(e=>{var{typed:t,matrix:n,equalScalar:r,zeros:a,BigNumber:i,DenseMatrix:s}=e,o=sJ({typed:t,equalScalar:r}),u=oJ({typed:t,DenseMatrix:s}),l=lJ({typed:t});return t(nZ,{number:xW,"number, number":xW,"number, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(tZ);return new i(e).toDecimalPlaces(t.toNumber())},Complex:function(e){return e.round()},"Complex, number":function(e,t){if(t%1)throw new TypeError(tZ);return e.round(t)},"Complex, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(tZ);var n=t.toNumber();return e.round(n)},BigNumber:function(e){return e.toDecimalPlaces(0)},"BigNumber, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(tZ);return e.toDecimalPlaces(t.toNumber())},Fraction:function(e){return e.round()},"Fraction, number":function(e,t){if(t%1)throw new TypeError(tZ);return e.round(t)},"Fraction, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(tZ);return e.round(t.toNumber())},"Array | Matrix":function(e){return Gq(e,this,!0)},"SparseMatrix, number | BigNumber":function(e,t){return o(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return l(e,t,this,!1)},"Array, number | BigNumber":function(e,t){return l(n(e),t,this,!1).valueOf()},"number | Complex | BigNumber | Fraction, SparseMatrix":function(e,t){return r(e,0)?a(t.size(),t.storage()):u(t,e,this,!0)},"number | Complex | BigNumber | Fraction, DenseMatrix":function(e,t){return r(e,0)?a(t.size(),t.storage()):l(t,e,this,!0)},"number | Complex | BigNumber | Fraction, Array":function(e,t){return l(n(t),e,this,!0).valueOf()}})})),aZ="smallerEq",iZ=YH(aZ,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:n,matrix:r,DenseMatrix:a}=e,i=aJ({typed:t}),s=DJ({typed:t,DenseMatrix:a}),o=oJ({typed:t,DenseMatrix:a}),u=uJ({typed:t}),l=lJ({typed:t});return t(aZ,{"boolean, boolean":function(e,t){return e<=t},"number, number":function(e,t){return e<=t||aj(e,t,n.epsilon)},"BigNumber, BigNumber":function(e,t){return e.lte(t)||zV(e,t,n.epsilon)},"Fraction, Fraction":function(e,t){return 1!==e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return l(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, any":function(e,t){return l(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return l(r(t),e,this,!0).valueOf()}})})),sZ="unequal",oZ=YH(sZ,["typed","config","equalScalar","matrix","DenseMatrix"],(e=>{var{typed:t,config:n,equalScalar:r,matrix:a,DenseMatrix:i}=e,s=aJ({typed:t}),o=DJ({typed:t,DenseMatrix:i}),u=oJ({typed:t,DenseMatrix:i}),l=uJ({typed:t}),c=lJ({typed:t});return t("unequal",{"any, any":function(e,t){return null===e?null!==t:null===t?null!==e:void 0===e?void 0!==t:void 0===t?void 0!==e:p(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,p)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,p,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,p,!1)},"DenseMatrix, DenseMatrix":function(e,t){return l(e,t,p)},"Array, Array":function(e,t){return this(a(e),a(t)).valueOf()},"Array, Matrix":function(e,t){return this(a(e),t)},"Matrix, Array":function(e,t){return this(e,a(t))},"SparseMatrix, any":function(e,t){return u(e,t,p,!1)},"DenseMatrix, any":function(e,t){return c(e,t,p,!1)},"any, SparseMatrix":function(e,t){return u(t,e,p,!0)},"any, DenseMatrix":function(e,t){return c(t,e,p,!0)},"Array, any":function(e,t){return c(a(e),t,p,!1).valueOf()},"any, Array":function(e,t){return c(a(t),e,p,!0).valueOf()}});function p(e,t){return!r(e,t)}})),uZ=(YH(sZ,["typed","equalScalar"],(e=>{var{typed:t,equalScalar:n}=e;return t(sZ,{"any, any":function(e,t){return null===e?null!==t:null===t?null!==e:void 0===e?void 0!==t:void 0===t?void 0!==e:!n(e,t)}})})),"usolve"),lZ=YH(uZ,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:n,divideScalar:r,multiplyScalar:a,subtract:i,equalScalar:s,DenseMatrix:o}=e,u=YX({DenseMatrix:o});return t(uZ,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var n=(t=u(e,t,!0))._data,l=e._size[0],c=e._size[1],p=e._values,d=e._index,h=e._ptr,f=[],m=c-1;m>=0;m--){var g=n[m][0]||0;if(s(g,0))f[m]=[0];else{for(var y=0,b=[],x=[],v=h[m],_=h[m+1]-1;_>=v;_--){var w=d[_];w===m?y=p[_]:w=0;h--){var f=n[h][0]||0,m=void 0;if(s(f,0))m=0;else{var g=d[h][h];if(s(g,0))throw new Error("Linear system cannot be solved since matrix is singular");m=r(f,g);for(var y=h-1;y>=0;y--)n[y]=[i(n[y][0]||0,a(m,d[y][h]))]}p[h]=[m]}return new o({data:p,size:[l,1]})}})),cZ=YH("xor",["typed","matrix","DenseMatrix"],(e=>{var{typed:t,matrix:n,DenseMatrix:r}=e,a=aJ({typed:t}),i=DJ({typed:t,DenseMatrix:r}),s=oJ({typed:t,DenseMatrix:r}),o=uJ({typed:t}),u=lJ({typed:t});return t("xor",{"number, number":zG,"Complex, Complex":function(e,t){return(0!==e.re||0!==e.im)!=(0!==t.re||0!==t.im)},"BigNumber, BigNumber":function(e,t){return(!e.isZero()&&!e.isNaN())!=(!t.isZero()&&!t.isNaN())},"Unit, Unit":function(e,t){return this(e.value||0,t.value||0)},"SparseMatrix, SparseMatrix":function(e,t){return i(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return o(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return s(e,t,this,!1)},"DenseMatrix, any":function(e,t){return u(e,t,this,!1)},"any, SparseMatrix":function(e,t){return s(t,e,this,!0)},"any, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, any":function(e,t){return u(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return u(n(t),e,this,!0).valueOf()}})})),pZ=YH("add",["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,matrix:n,addScalar:r,equalScalar:a,DenseMatrix:i,SparseMatrix:s}=e,o=pJ({typed:t}),u=MX({typed:t,equalScalar:a}),l=YJ({typed:t,DenseMatrix:i}),c=uJ({typed:t}),p=lJ({typed:t});return t("add",NH({"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,r)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,r,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,r,!0)},"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,r)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"DenseMatrix, any":function(e,t){return p(e,t,r,!1)},"SparseMatrix, any":function(e,t){return l(e,t,r,!1)},"any, DenseMatrix":function(e,t){return p(t,e,r,!0)},"any, SparseMatrix":function(e,t){return l(t,e,r,!0)},"Array, any":function(e,t){return p(n(e),t,r,!1).valueOf()},"any, Array":function(e,t){return p(n(t),e,r,!0).valueOf()},"any, any":r,"any, any, ...any":function(e,t,n){for(var r=this(e,t),a=0;a{var{typed:t,equalScalar:n}=e;return function(e,r,a){var i=e._values,s=e._index,o=e._ptr,u=e._size,l=e._datatype,c=r._values,p=r._index,d=r._ptr,h=r._size,f=r._datatype;if(u.length!==h.length)throw new eq(u.length,h.length);if(u[0]!==h[0]||u[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+h+")");var m,g=u[0],y=u[1],b=n,x=0,v=a;"string"==typeof l&&l===f&&(m=l,b=t.find(n,[m,m]),x=t.convert(0,m),v=t.find(a,[m,m]));var _,w,M,N,S,k=i&&c?[]:void 0,D=[],T=[],I=k?[]:void 0,E=[];for(w=0;w{var{typed:t,matrix:n,equalScalar:r,BigNumber:a,DenseMatrix:i}=e,s=rJ({typed:t,equalScalar:r}),o=aJ({typed:t}),u=dZ({typed:t,equalScalar:r}),l=sJ({typed:t,equalScalar:r}),c=oJ({typed:t,DenseMatrix:i}),p=uJ({typed:t}),d=lJ({typed:t});return t(hZ,{"number, number":Math.atan2,"BigNumber, BigNumber":function(e,t){return a.atan2(e,t)},"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return o(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return p(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, number | BigNumber":function(e,t){return l(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return d(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return c(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return d(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return d(n(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return d(n(t),e,this,!0).valueOf()}})})),mZ="bitOr",gZ=YH(mZ,["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:a}=e,i=pJ({typed:t}),s=MX({typed:t,equalScalar:r}),o=YJ({typed:t,DenseMatrix:a}),u=uJ({typed:t}),l=lJ({typed:t});return t(mZ,{"number, number":hV,"BigNumber, BigNumber":aV,"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return l(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, any":function(e,t){return l(n(e),t,this,!1).valueOf()},"any, Array":function(e,t){return l(n(t),e,this,!0).valueOf()}})})),yZ="catalan",bZ=YH(yZ,["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],(e=>{var{typed:t,addScalar:n,divideScalar:r,multiplyScalar:a,combinations:i,isNegative:s,isInteger:o}=e;return t(yZ,{"number | BigNumber":function(e){if(!o(e)||s(e))throw new TypeError("Non-negative integer value expected in function catalan");return r(i(a(e,2),e),n(e,1))}})})),xZ=n(3228),vZ="compareNatural",_Z=YH(vZ,["typed","compare"],(e=>{var{typed:t,compare:n}=e,r=n.signatures["boolean,boolean"];return t(vZ,{"any, any":function(e,t){var s,o=_H(e),u=_H(t);if(!("number"!==o&&"BigNumber"!==o&&"Fraction"!==o||"number"!==u&&"BigNumber"!==u&&"Fraction"!==u))return"0"!==(s=n(e,t)).toString()?s>0?1:-1:xZ(o,u);if("Array"===o||"Matrix"===o||"Array"===u||"Matrix"===u)return 0!==(s=a(this,e,t))?s:xZ(o,u);if(o!==u)return xZ(o,u);if("Complex"===o)return function(e,t){return e.re>t.re?1:e.ret.im?1:e.imn.length?1:t.length{var{typed:t,add:n,unaryPlus:r}=e;return t(wZ,{Array:a,Matrix:function(e){return e.create(a(e.valueOf()))},"Array, number | BigNumber":s,"Matrix, number | BigNumber":function(e,t){return e.create(s(e.valueOf(),t))},"...":function(e){if(Wq(e))throw new TypeError("All values expected to be scalar in function cumsum");return a(e)}});function a(e){try{return i(e)}catch(e){throw vJ(e,wZ)}}function i(e){if(0===e.length)return[];for(var t=[r(e[0])],a=1;a=n.length)throw new tq(t,n.length);try{return o(e,t)}catch(e){throw vJ(e,wZ)}}function o(e,t){var n,r,a;if(t<=0){var s=e[0][0];if(Array.isArray(s)){for(a=qq(e),r=[],n=0;n{var{typed:t,equal:n}=e;return t(NZ,{"any, any":function(e,t){return r(e.valueOf(),t.valueOf())}});function r(e,t){if(Array.isArray(e)){if(Array.isArray(t)){var a=e.length;if(a!==t.length)return!1;for(var i=0;i{var{typed:t,matrix:n,subtract:r,number:a}=e;return t(kZ,{"Array | Matrix":function(e){return UP(e)?n(s(e.toArray())):s(e)},"Array | Matrix, number":function(e,t){if(!jH(t))throw new RangeError("Dimension must be a whole number");return UP(e)?n(i(e.toArray(),t)):i(e,t)},"Array | Matrix, BigNumber":function(e,t){return this(e,a(t))}});function i(e,t){if(UP(e)&&(e=e.toArray()),!Array.isArray(e))throw RangeError("Array/Matrix does not have that many dimensions");if(t>0){var n=[];return e.forEach((e=>{n.push(i(e,t-1))})),n}if(0===t)return s(e);throw RangeError("Cannot have negative dimension")}function s(e){var t=[],n=e.length;if(n<2)return e;for(var r=1;r{var{typed:t,addScalar:n,multiplyScalar:r,conj:a,size:i}=e;return t("dot",{"Array | DenseMatrix, Array | DenseMatrix":function(e,i){var u=s(e,i),l=UP(e)?e._data:e,c=UP(e)?e._datatype:void 0,p=UP(i)?i._data:i,d=UP(i)?i._datatype:void 0,h=2===o(e).length,f=2===o(i).length,m=n,g=r;if(c&&d&&c===d&&"string"==typeof c){var y=c;m=t.find(n,[y,y]),g=t.find(r,[y,y])}if(!h&&!f){for(var b=g(a(l[0]),p[0]),x=1;xm?h++:f===m&&(l=c(l,p(i[d],u[h])),d++,h++)}return l}});function s(e,t){var n,r,a=o(e),i=o(t);if(1===a.length)n=a[0];else{if(2!==a.length||1!==a[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+a.join(", ")+")");n=a[0]}if(1===i.length)r=i[0];else{if(2!==i.length||1!==i[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+i.join(", ")+")");r=i[0]}if(n!==r)throw new RangeError("Vectors must have equal length ("+n+" != "+r+")");if(0===n)throw new RangeError("Cannot calculate the dot product of empty vectors");return n}function o(e){return UP(e)?e.size():i(e)}})),IZ="equalText",EZ=YH(IZ,["typed","compareText","isZero"],(e=>{var{typed:t,compareText:n,isZero:r}=e;return t(IZ,{"any, any":function(e,t){return r(n(e,t))}})})),CZ="floor",AZ=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],LZ=YH(CZ,["typed","config","round"],(e=>{var{typed:t,config:n,round:r}=e;return t(CZ,{number:function(e){return aj(e,r(e),n.epsilon)?r(e):Math.floor(e)},"number, number":function(e,t){if(aj(e,r(e,t),n.epsilon))return r(e,t);var[a,i]="".concat(e,"e").split("e"),s=Math.floor(Number("".concat(a,"e").concat(Number(i)+t)));return[a,i]="".concat(s,"e").split("e"),Number("".concat(a,"e").concat(Number(i)-t))}})})),$Z=YH(CZ,AZ,(e=>{var{typed:t,config:n,round:r,matrix:a,equalScalar:i,zeros:s,DenseMatrix:o}=e,u=sJ({typed:t,equalScalar:i}),l=oJ({typed:t,DenseMatrix:o}),c=lJ({typed:t}),p=LZ({typed:t,config:n,round:r});return t("floor",{number:p.signatures.number,"number,number":p.signatures["number,number"],Complex:function(e){return e.floor()},"Complex, number":function(e,t){return e.floor(t)},"Complex, BigNumber":function(e,t){return e.floor(t.toNumber())},BigNumber:function(e){return zV(e,r(e),n.epsilon)?r(e):e.floor()},"BigNumber, BigNumber":function(e,t){return zV(e,r(e,t),n.epsilon)?r(e,t):e.toDecimalPlaces(t.toNumber(),FH.ROUND_FLOOR)},Fraction:function(e){return e.floor()},"Fraction, number":function(e,t){return e.floor(t)},"Fraction, BigNumber":function(e,t){return e.floor(t.toNumber())},"Array | Matrix":function(e){return Gq(e,this,!0)},"Array, number | BigNumber":function(e,t){return Gq(e,(e=>this(e,t)),!0)},"SparseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"number | Complex | Fraction | BigNumber, Array":function(e,t){return c(a(t),e,this,!0).valueOf()},"number | Complex | Fraction | BigNumber, Matrix":function(e,t){return i(e,0)?s(t.size(),t.storage()):"dense"===t.storage()?c(t,e,this,!0):l(t,e,this,!0)}})})),OZ="identity",RZ=YH(OZ,["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,config:n,matrix:r,BigNumber:a,DenseMatrix:i,SparseMatrix:s}=e;return t(OZ,{"":function(){return"Matrix"===n.matrix?r([]):[]},string:function(e){return r(e)},"number | BigNumber":function(e){return u(e,e,"Matrix"===n.matrix?"dense":void 0)},"number | BigNumber, string":function(e,t){return u(e,e,t)},"number | BigNumber, number | BigNumber":function(e,t){return u(e,t,"Matrix"===n.matrix?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(e,t,n){return u(e,t,n)},Array:function(e){return o(e)},"Array, string":function(e,t){return o(e,t)},Matrix:function(e){return o(e.valueOf(),e.storage())},"Matrix, string":function(e,t){return o(e.valueOf(),t)}});function o(e,t){switch(e.length){case 0:return t?r(t):[];case 1:return u(e[0],e[0],t);case 2:return u(e[0],e[1],t);default:throw new Error("Vector containing two values expected")}}function u(e,t,n){var r=YP(e)||YP(t)?a:null;if(YP(e)&&(e=e.toNumber()),YP(t)&&(t=t.toNumber()),!jH(e)||e<1)throw new Error("Parameters in function identity must be positive integers");if(!jH(t)||t<1)throw new Error("Parameters in function identity must be positive integers");var o=r?new a(1):1,u=r?new r(0):0,l=[e,t];if(n){if("sparse"===n)return s.diagonal(l,o,0,u);if("dense"===n)return i.diagonal(l,o,0,u);throw new TypeError('Unknown matrix type "'.concat(n,'"'))}for(var c=sq([],l,u),p=e{var{typed:t,config:n,BigNumber:r,xgcd:a,equal:i,smaller:s,mod:o,add:u,isInteger:l}=e;return t(FZ,{"number, number":c,"BigNumber, BigNumber":c});function c(e,t){if(!l(e)||!l(t))throw new Error("Parameters in function invmod must be integer numbers");if(e=o(e,t),i(t,0))throw new Error("Divisor must be non zero");var n=a(e,t);n=n.valueOf();var[c,p]=n;return i(c,r(1))?(p=o(p,t),s(p,r(0))&&(p=u(p,t)),p):NaN}})),zZ="larger",BZ=YH(zZ,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:n,matrix:r,DenseMatrix:a}=e,i=aJ({typed:t}),s=DJ({typed:t,DenseMatrix:a}),o=oJ({typed:t,DenseMatrix:a}),u=uJ({typed:t}),l=lJ({typed:t});return t(zZ,{"boolean, boolean":function(e,t){return e>t},"number, number":function(e,t){return e>t&&!aj(e,t,n.epsilon)},"BigNumber, BigNumber":function(e,t){return e.gt(t)&&!zV(e,t,n.epsilon)},"Fraction, Fraction":function(e,t){return 1===e.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return this(e.value,t.value)},"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,this)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return o(e,t,this,!1)},"DenseMatrix, any":function(e,t){return l(e,t,this,!1)},"any, SparseMatrix":function(e,t){return o(t,e,this,!0)},"any, DenseMatrix":function(e,t){return l(t,e,this,!0)},"Array, any":function(e,t){return l(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return l(r(t),e,this,!0).valueOf()}})})),PZ=YH("log",["config","typed","divideScalar","Complex"],(e=>{var{typed:t,config:n,divideScalar:r,Complex:a}=e;return t("log",{number:function(e){return e>=0||n.predictable?function(e,t){return Math.log(e)}(e):new a(e,0).log()},Complex:function(e){return e.log()},BigNumber:function(e){return!e.isNegative()||n.predictable?e.ln():new a(e.toNumber(),0).log()},"Array | Matrix":function(e){return Gq(e,this)},"any, any":function(e,t){return r(this(e),this(t))}})})),HZ="lsolveAll",jZ=YH(HZ,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:n,divideScalar:r,multiplyScalar:a,subtract:i,equalScalar:s,DenseMatrix:o}=e,u=YX({DenseMatrix:o});return t(HZ,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var n=[u(e,t,!0)._data.map((e=>e[0]))],l=e._size[0],c=e._size[1],p=e._values,d=e._index,h=e._ptr,f=0;ff&&(b.push(p[M]),x.push(N))}if(s(w,0))if(s(y[f],0)){if(0===g){var S=[...y];S[f]=1;for(var k=0,D=x.length;knew o({data:e.map((e=>[e])),size:[l,1]})))}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return l(e,t)},"Array, Array | Matrix":function(e,t){return l(n(e),t).map((e=>e.valueOf()))}});function l(e,t){for(var n=[u(e,t,!0)._data.map((e=>e[0]))],l=e._data,c=e._size[0],p=e._size[1],d=0;dnew o({data:e.map((e=>[e])),size:[c,1]})))}})),UZ="matrixFromRows",qZ=YH(UZ,["typed","matrix","flatten","size"],(e=>{var{typed:t,matrix:n,flatten:r,size:a}=e;return t(UZ,{"...Array":function(e){return i(e)},"...Matrix":function(e){return n(i(e.map((e=>e.toArray()))))}});function i(e){if(0===e.length)throw new TypeError("At least one row is needed to construct a matrix.");var t=s(e[0]),n=[];for(var a of e){var i=s(a);if(i!==t)throw new TypeError("The vectors had different length: "+(0|t)+" ≠ "+(0|i));n.push(r(a))}return n}function s(e){var t=a(e);if(1===t.length)return t[0];if(2===t.length){if(1===t[0])return t[1];if(1===t[1])return t[0];throw new TypeError("At least one of the arguments is not a vector.")}throw new TypeError("Only one- or two-dimensional vectors are supported.")}})),WZ="multiply",VZ=YH(WZ,["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],(e=>{var{typed:t,matrix:n,addScalar:r,multiplyScalar:a,equalScalar:i,dot:s}=e,o=sJ({typed:t,equalScalar:i}),u=lJ({typed:t});function l(e,t){switch(e.length){case 1:switch(t.length){case 1:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+e[0]+") must match Matrix rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;case 2:switch(t.length){case 1:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+e[1]+") must match Vector length ("+t[0]+")");break;case 2:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+e[1]+") must match Matrix B rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+e.length+" dimensions)")}}var c=t("_multiplyMatrixVector",{"DenseMatrix, any":function(e,n){var i,s=e._data,o=e._size,u=e._datatype,l=n._data,c=n._datatype,p=o[0],d=o[1],h=r,f=a;u&&c&&u===c&&"string"==typeof u&&(i=u,h=t.find(r,[i,i]),f=t.find(a,[i,i]));for(var m=[],g=0;gk)for(var T=0,I=0;I{var{typed:t,matrix:n,zeros:r,identity:a,isZero:i,equal:s,sign:o,sqrt:u,conj:l,unaryMinus:c,addScalar:p,divideScalar:d,multiplyScalar:h,subtract:f,complex:m}=e;return OP(t("qr",{DenseMatrix:function(e){return y(e)},SparseMatrix:function(e){return function(e){throw new Error("qr not implemented for sparse matrices yet")}()},Array:function(e){var t=y(n(e));return{Q:t.Q.valueOf(),R:t.R.valueOf()}}}),{_denseQRimpl:g});function g(e){var t,n,m,g=e._size[0],y=e._size[1],b=a([g],"dense"),x=b._data,v=e.clone(),_=v._data,w=r([g],"");for(m=0;m0)for(var r="Complex"===n[0][0].type?m(0):0,a=0;a{var{typed:t,config:n,matrix:r,bignumber:a,smaller:i,smallerEq:s,larger:o,largerEq:u}=e;return t(KZ,{string:c,"string, boolean":c,"number, number":function(e,t){return l(p(e,t,1))},"number, number, number":function(e,t,n){return l(p(e,t,n))},"number, number, boolean":function(e,t,n){return l(n?d(e,t,1):p(e,t,1))},"number, number, number, boolean":function(e,t,n,r){return l(r?d(e,t,n):p(e,t,n))},"BigNumber, BigNumber":function(e,t){return l(h(e,t,new(0,e.constructor)(1)))},"BigNumber, BigNumber, BigNumber":function(e,t,n){return l(h(e,t,n))},"BigNumber, BigNumber, boolean":function(e,t,n){var r=e.constructor;return l(n?f(e,t,new r(1)):h(e,t,new r(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(e,t,n,r){return l(r?f(e,t,n):h(e,t,n))}});function l(e){return"Matrix"===n.matrix?r?r(e):yJ():e}function c(e,t){var r=function(e){var t=e.split(":").map((function(e){return Number(e)})),n=t.some((function(e){return isNaN(e)}));if(n)return null;switch(t.length){case 2:return{start:t[0],end:t[1],step:1};case 3:return{start:t[0],end:t[2],step:t[1]};default:return null}}(e);if(!r)throw new SyntaxError('String "'+e+'" is no valid range');return"BigNumber"===n.number?(void 0===a&&mJ(),l((t?f:h)(a(r.start),a(r.end),a(r.step)))):l((t?d:p)(r.start,r.end,r.step))}function p(e,t,n){var r=[],a=e;if(n>0)for(;i(a,t);)r.push(a),a+=n;else if(n<0)for(;o(a,t);)r.push(a),a+=n;return r}function d(e,t,n){var r=[],a=e;if(n>0)for(;s(a,t);)r.push(a),a+=n;else if(n<0)for(;u(a,t);)r.push(a),a+=n;return r}function h(e,t,n){var r=a(0),s=[],u=e;if(n.gt(r))for(;i(u,t);)s.push(u),u=u.plus(n);else if(n.lt(r))for(;o(u,t);)s.push(u),u=u.plus(n);return s}function f(e,t,n){var r=a(0),i=[],o=e;if(n.gt(r))for(;s(o,t);)i.push(o),o=o.plus(n);else if(n.lt(r))for(;u(o,t);)i.push(o),o=o.plus(n);return i}})),XZ="rightLogShift",ZZ=YH(XZ,["typed","matrix","equalScalar","zeros","DenseMatrix"],(e=>{var{typed:t,matrix:n,equalScalar:r,zeros:a,DenseMatrix:i}=e,s=pJ({typed:t}),o=rJ({typed:t,equalScalar:r}),u=OX({typed:t,equalScalar:r}),l=YJ({typed:t,DenseMatrix:i}),c=sJ({typed:t,equalScalar:r}),p=uJ({typed:t}),d=lJ({typed:t});return t(XZ,{"number, number":yV,"SparseMatrix, SparseMatrix":function(e,t){return u(e,t,this,!1)},"SparseMatrix, DenseMatrix":function(e,t){return o(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return p(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, number | BigNumber":function(e,t){return r(t,0)?e.clone():c(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return r(t,0)?e.clone():d(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return r(e,0)?a(t.size(),t.storage()):l(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return r(e,0)?a(t.size(),t.storage()):d(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return this(n(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return this(e,n(t)).valueOf()}})})),QZ="setSize",eQ=YH(QZ,["typed","compareNatural"],(e=>{var{typed:t,compareNatural:n}=e;return t(QZ,{"Array | Matrix":function(e){return Array.isArray(e)?mq(e).length:mq(e.toArray()).length},"Array | Matrix, boolean":function(e,t){if(!1===t||0===e.length)return Array.isArray(e)?mq(e).length:mq(e.toArray()).length;for(var r=mq(Array.isArray(e)?e:e.toArray()).sort(n),a=1,i=1;i=0;){var u=n[s+o],l=n[r+u];-1===l?(o--,i[t++]=u):(n[r+u]=n[a+l],n[s+ ++o]=l)}return t}function nQ(e){return-e-2}var rQ=YH("csAmd",["add","multiply","transpose"],(e=>{var{add:t,multiply:n,transpose:r}=e;return function(e,s){if(!s||e<=0||e>3)return null;var o=s._size,u=o[0],l=o[1],c=0,p=Math.max(16,10*Math.sqrt(l)),d=function(e,a,i,s,o){var u=r(a);if(1===e&&s===i)return t(a,u);if(2===e){for(var l=u._index,c=u._ptr,p=0,d=0;do))for(var f=c[d+1];hs)n[o+d]=0,n[a+d]=-1,p++,t[d]=nQ(e),n[o+e]++;else{var f=n[u+h];-1!==f&&(l[f]=d),n[c+d]=n[u+h],n[u+h]=d}}return p}(l,E,L,Y,F,z,p,$,R,P,O),U=0;jq?(b=m,x=G,v=L[0+m]-q):(x=E[b=I[G++]],v=L[0+b]),y=1;y<=v;y++)(_=L[$+(h=I[x++])])<=0||(V+=_,L[$+h]=-_,I[J++]=h,-1!==L[O+h]&&(P[L[O+h]]=P[h]),-1!==P[h]?L[O+P[h]]=L[O+h]:L[R+L[Y+h]]=L[O+h]);b!==m&&(E[b]=nQ(m),L[z+b]=0)}for(0!==q&&(C=J),L[Y+m]=V,E[m]=K,L[0+m]=J-K,L[F+m]=-2,H=a(H,c,L,z,l),w=K;w=H?L[z+b]-=_:0!==L[z+b]&&(L[z+b]=L[Y+b]+X)}for(w=K;w0?(T+=Z,I[k++]=b,D+=b):(E[b]=nQ(m),L[z+b]=0)}L[F+h]=k-N+1;var Q=k,ee=N+L[0+h];for(G=S+1;G=0))for(h=L[B+(D=P[h])],L[B+D]=-1;-1!==h&&-1!==L[O+h];h=L[O+h],H++){for(v=L[0+h],M=L[F+h],G=E[h]+1;G<=E[h]+v-1;G++)L[z+I[G]]=H;var ne=h;for(f=L[O+h];-1!==f;){var re=L[0+f]===v&&L[F+f]===M;for(G=E[f]+1;re&&G<=E[f]+v-1;G++)L[z+I[G]]!==H&&(re=0);re?(E[f]=nQ(h),L[$+h]+=L[$+f],L[$+f]=0,L[F+f]=-1,f=L[O+f],L[O+ne]=f):(ne=f,f=L[O+f])}}for(G=K,w=K;w=0;f--)L[$+f]>0||(L[O+f]=L[R+E[f]],L[R+E[f]]=f);for(b=l;b>=0;b--)L[$+b]<=0||-1!==E[b]&&(L[O+b]=L[R+E[b]],L[R+E[b]]=b);for(m=0,h=0;h<=l;h++)-1===E[h]&&(m=tQ(h,m,L,R,O,A,z));return A.splice(A.length-1,1),A};function a(e,t,n,r,a){if(e<2||e+t<0){for(var i=0;i{var{transpose:t}=e;return function(e,n,r,a){if(!e||!n||!r)return null;var i,s,o,u,l,c,p,d=e._size,h=d[0],f=d[1],m=4*f+(a?f+h+1:0),g=[],y=f,b=2*f,x=3*f,v=4*f,_=5*f+1;for(o=0;o=1&&w[s]++,2===k.jleaf&&w[k.q]--}-1!==n[s]&&(g[0+s]=n[s])}for(s=0;s{var{add:t,multiply:n,transpose:r}=e,a=rQ({add:t,multiply:n,transpose:r}),i=iQ({transpose:r});return function(e,t,n){var r,s=t._ptr,o=t._size[1],u={};if(u.q=a(e,t),e&&!u.q)return null;if(n){var l=e?function(e,t,n,r){for(var a=e._values,i=e._index,s=e._ptr,o=e._size,u=e._datatype,l=o[0],c=o[1],p=null,d=[],h=[],f=0,m=0;m=0;n--)-1!==e[n]&&(i[s+n]=i[0+e[n]],i[0+e[n]]=n);for(n=0;n=0;u--)for(c=n[u],p=n[u+1],l=c;l=0;o--)h[o]=-1,-1!==(u=f[o])&&(0==m[b+u]++&&(m[y+u]=o),m[0+o]=m[g+u],m[g+u]=o);for(t.lnz=0,t.m2=i,u=0;u=0;){e=r[p];var d=a?a[e]:e;oQ(l,e)||(uQ(l,e),r[c+p]=d<0?0:lQ(l[d]));var h=1;for(s=r[c+p],o=d<0?0:lQ(l[d+1]);s{var{divideScalar:t,multiply:n,subtract:r}=e;return function(e,a,i,s,o,u,l){var c,p,d,h,f=e._values,m=e._index,g=e._ptr,y=e._size[1],b=a._values,x=a._index,v=a._ptr,_=function(e,t,n,r,a){var i,s,o,u=e._ptr,l=e._size,c=t._index,p=t._ptr,d=l[1],h=d;for(s=p[n],o=p[n+1],i=s;i{var{abs:t,divideScalar:n,multiply:r,subtract:a,larger:i,largerEq:s,SparseMatrix:o}=e,u=pQ({divideScalar:n,multiply:r,subtract:a});return function(e,a,l){if(!e)return null;var c,p=e._size[1],d=100,h=100;a&&(c=a.q,d=a.lnz||d,h=a.unz||h);var f,m,g=[],y=[],b=[],x=new o({values:g,index:y,ptr:b,size:[p,p]}),v=[],_=[],w=[],M=new o({values:v,index:_,ptr:w,size:[p,p]}),N=[],S=[],k=[];for(f=0;f{var{typed:t,abs:n,add:r,multiply:a,transpose:i,divideScalar:s,subtract:o,larger:u,largerEq:l,SparseMatrix:c}=e,p=sQ({add:r,multiply:a,transpose:i}),d=dQ({abs:n,divideScalar:s,multiply:a,subtract:o,larger:u,largerEq:l,SparseMatrix:c});return t("slu",{"SparseMatrix, number, number":function(e,t,n){if(!jH(t)||t<0||t>3)throw new Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");if(n<0||n>1)throw new Error("Partial pivoting threshold must be a number from 0 to 1");var r=p(t,e,!1),a=d(e,r,n);return{L:a.L,U:a.U,p:a.pinv,q:r.q,toString:function(){return"L: "+this.L.toString()+"\nU: "+this.U.toString()+"\np: "+this.p.toString()+(this.q?"\nq: "+this.q.toString():"")+"\n"}}}})})),fQ=YH("sum",["typed","config","add","numeric"],(e=>{var{typed:t,config:n,add:r,numeric:a}=e;return t("sum",{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(e,t){try{return Kq(e,t,r)}catch(e){throw vJ(e,"sum")}},"...":function(e){if(Wq(e))throw new TypeError("Scalar values expected in function sum");return i(e)}});function i(e){var t;return Vq(e,(function(e){try{t=void 0===t?e:r(t,e)}catch(t){throw vJ(t,"sum",e)}})),void 0===t&&(t=a(0,n.number)),"string"==typeof t&&(t=a(t,n.number)),t}})),mQ=YH("trace",["typed","matrix","add"],(e=>{var{typed:t,matrix:n,add:r}=e;return t("trace",{Array:function(e){return a(n(e))},SparseMatrix:function(e){var t=e._values,n=e._index,a=e._ptr,i=e._size,s=i[0],o=i[1];if(s===o){var u=0;if(t.length>0)for(var l=0;ll)break}return u}throw new RangeError("Matrix must be square (size: "+KU(i)+")")},DenseMatrix:a,any:wH});function a(e){var t=e._size,n=e._data;switch(t.length){case 1:if(1===t[0])return wH(n[0]);throw new RangeError("Matrix must be square (size: "+KU(t)+")");case 2:var a=t[0];if(a===t[1]){for(var i=0,s=0;s{var{typed:t,matrix:n,divideScalar:r,multiplyScalar:a,subtract:i,equalScalar:s,DenseMatrix:o}=e,u=YX({DenseMatrix:o});return t(gQ,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var n=[u(e,t,!0)._data.map((e=>e[0]))],l=e._size[0],c=e._size[1],p=e._values,d=e._index,h=e._ptr,f=c-1;f>=0;f--)for(var m=n.length,g=0;g=v;w--){var M=d[w];M===f?_=p[w]:Mnew o({data:e.map((e=>[e])),size:[l,1]})))}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return l(e,t)},"Array, Array | Matrix":function(e,t){return l(n(e),t).map((e=>e.valueOf()))}});function l(e,t){for(var n=[u(e,t,!0)._data.map((e=>e[0]))],l=e._data,c=e._size[0],p=e._size[1]-1;p>=0;p--)for(var d=n.length,h=0;h=0;g--)m[g]=i(m[g],l[g][p]);n.push(m)}}else{if(0===h)return[];n.splice(h,1),h-=1,d-=1}else{f[p]=r(f[p],l[p][p]);for(var y=p-1;y>=0;y--)f[y]=i(f[y],a(f[p],l[y][p]))}}return n.map((e=>new o({data:e.map((e=>[e])),size:[c,1]})))}})),bQ="asin",xQ=YH(bQ,["typed","config","Complex"],(e=>{var{typed:t,config:n,Complex:r}=e;return t(bQ,{number:function(e){return e>=-1&&e<=1||n.predictable?Math.asin(e):new r(e,0).asin()},Complex:function(e){return e.asin()},BigNumber:function(e){return e.asin()},"Array | Matrix":function(e){return Gq(e,this,!0)}})})),vQ="ceil",_Q=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],wQ=YH(vQ,["typed","config","round"],(e=>{var{typed:t,config:n,round:r}=e;return t(vQ,{number:function(e){return aj(e,r(e),n.epsilon)?r(e):Math.ceil(e)},"number, number":function(e,t){if(aj(e,r(e,t),n.epsilon))return r(e,t);var[a,i]="".concat(e,"e").split("e"),s=Math.ceil(Number("".concat(a,"e").concat(Number(i)+t)));return[a,i]="".concat(s,"e").split("e"),Number("".concat(a,"e").concat(Number(i)-t))}})})),MQ=YH(vQ,_Q,(e=>{var{typed:t,config:n,round:r,matrix:a,equalScalar:i,zeros:s,DenseMatrix:o}=e,u=sJ({typed:t,equalScalar:i}),l=oJ({typed:t,DenseMatrix:o}),c=lJ({typed:t}),p=wQ({typed:t,config:n,round:r});return t("ceil",{number:p.signatures.number,"number,number":p.signatures["number,number"],Complex:function(e){return e.ceil()},"Complex, number":function(e,t){return e.ceil(t)},"Complex, BigNumber":function(e,t){return e.ceil(t.toNumber())},BigNumber:function(e){return zV(e,r(e),n.epsilon)?r(e):e.ceil()},"BigNumber, BigNumber":function(e,t){return zV(e,r(e,t),n.epsilon)?r(e,t):e.toDecimalPlaces(t.toNumber(),FH.ROUND_CEIL)},Fraction:function(e){return e.ceil()},"Fraction, number":function(e,t){return e.ceil(t)},"Fraction, BigNumber":function(e,t){return e.ceil(t.toNumber())},"Array | Matrix":function(e){return Gq(e,this,!0)},"Array, number | BigNumber":function(e,t){return Gq(e,(e=>this(e,t)),!0)},"SparseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return c(e,t,this,!1)},"number | Complex | Fraction | BigNumber, Array":function(e,t){return c(a(t),e,this,!0).valueOf()},"number | Complex | Fraction | BigNumber, Matrix":function(e,t){return i(e,0)?s(t.size(),t.storage()):"dense"===t.storage()?c(t,e,this,!0):l(t,e,this,!0)}})})),NQ="composition",SQ=YH(NQ,["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],(e=>{var{typed:t,addScalar:n,combinations:r,isPositive:a,isNegative:i,isInteger:s,larger:o}=e;return t(NQ,{"number | BigNumber, number | BigNumber":function(e,t){if(!(s(e)&&a(e)&&s(t)&&a(t)))throw new TypeError("Positive integer value expected in function composition");if(o(t,e))throw new TypeError("k must be less than or equal to n in function composition");return r(n(e,-1),n(t,-1))}})})),kQ="cross",DQ=YH(kQ,["typed","matrix","subtract","multiply"],(e=>{var{typed:t,matrix:n,subtract:r,multiply:a}=e;return t(kQ,{"Matrix, Matrix":function(e,t){return n(i(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return n(i(e.toArray(),t))},"Array, Matrix":function(e,t){return n(i(e,t.toArray()))},"Array, Array":i});function i(e,t){var n=Math.max(nq(e).length,nq(t).length);e=pq(e),t=pq(t);var i=nq(e),s=nq(t);if(1!==i.length||1!==s.length||3!==i[0]||3!==s[0])throw new RangeError("Vectors with length 3 expected (Size A = ["+i.join(", ")+"], B = ["+s.join(", ")+"])");var o=[r(a(e[1],t[2]),a(e[2],t[1])),r(a(e[2],t[0]),a(e[0],t[2])),r(a(e[0],t[1]),a(e[1],t[0]))];return n>1?[o]:o}})),TQ=YH("det",["typed","matrix","subtract","multiply","divideScalar","isZero","unaryMinus"],(e=>{var{typed:t,matrix:n,subtract:r,multiply:a,divideScalar:i,isZero:s,unaryMinus:o}=e;return t("det",{any:function(e){return wH(e)},"Array | Matrix":function(e){var t;switch((t=UP(e)?e.size():Array.isArray(e)?(e=n(e)).size():[]).length){case 0:return wH(e);case 1:if(1===t[0])return wH(e.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+KU(t)+")");case 2:var u=t[0];if(u===t[1])return function(e,t,n){if(1===t)return wH(e[0][0]);if(2===t)return r(a(e[0][0],e[1][1]),a(e[1][0],e[0][1]));for(var u=!1,l=new Array(t).fill(0).map(((e,t)=>t)),c=0;c{var{typed:t,addScalar:n,subtract:r,multiplyScalar:a,divideScalar:i,unaryMinus:s,sqrt:o,abs:u}=e;return t(IQ,{"Array, Array, Array":function(e,t,n){if(2===e.length&&2===t.length&&2===n.length){if(!c(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!c(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!c(n))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");var o=i(r(n[1],n[0]),r(t[1],t[0])),u=a(a(o,o),t[0]),l=s(a(o,t[0])),p=e[1];return m(e[0],e[1],u,l,p)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object, Object":function(e,t,n){if(2===Object.keys(e).length&&2===Object.keys(t).length&&2===Object.keys(n).length){if(!c(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!c(t))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!c(n))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"lineOnePtX"in t&&"lineOnePtY"in t&&"lineTwoPtX"in n&&"lineTwoPtY"in n){var o=i(r(n.lineTwoPtY,n.lineTwoPtX),r(t.lineOnePtY,t.lineOnePtX)),u=a(a(o,o),t.lineOnePtX),l=s(a(o,t.lineOnePtX)),p=e.pointX;return m(e.pointX,e.pointY,u,l,p)}throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},"Array, Array":function(e,t){if(2===e.length&&3===t.length){if(!c(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!p(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return m(e[0],e[1],t[0],t[1],t[2])}if(3===e.length&&6===t.length){if(!p(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!h(t))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return g(e[0],e[1],e[2],t[0],t[1],t[2],t[3],t[4],t[5])}if(e.length===t.length&&e.length>0){if(!d(e))throw new TypeError("All values of an array should be numbers or BigNumbers");if(!d(t))throw new TypeError("All values of an array should be numbers or BigNumbers");return y(e,t)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(e,t){if(2===Object.keys(e).length&&3===Object.keys(t).length){if(!c(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!p(t))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"xCoeffLine"in t&&"yCoeffLine"in t&&"constant"in t)return m(e.pointX,e.pointY,t.xCoeffLine,t.yCoeffLine,t.constant);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&6===Object.keys(t).length){if(!p(e))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!h(t))throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"x0"in t&&"y0"in t&&"z0"in t&&"a"in t&&"b"in t&&"c"in t)return g(e.pointX,e.pointY,e.pointZ,t.x0,t.y0,t.z0,t.a,t.b,t.c);throw new TypeError("Key names do not match")}if(2===Object.keys(e).length&&2===Object.keys(t).length){if(!c(e))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!c(t))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointTwoX"in t&&"pointTwoY"in t)return y([e.pointOneX,e.pointOneY],[t.pointTwoX,t.pointTwoY]);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&3===Object.keys(t).length){if(!p(e))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!p(t))throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointOneZ"in e&&"pointTwoX"in t&&"pointTwoY"in t&&"pointTwoZ"in t)return y([e.pointOneX,e.pointOneY,e.pointOneZ],[t.pointTwoX,t.pointTwoY,t.pointTwoZ]);throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},Array:function(e){if(!function(e){if(2===e[0].length&&l(e[0][0])&&l(e[0][1])){if(e.some((e=>2!==e.length||!l(e[0])||!l(e[1]))))return!1}else{if(!(3===e[0].length&&l(e[0][0])&&l(e[0][1])&&l(e[0][2])))return!1;if(e.some((e=>3!==e.length||!l(e[0])||!l(e[1])||!l(e[2]))))return!1}return!0}(e))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return function(e){for(var t=[],n=[],r=[],a=0;a{var{typed:t,matrix:n,equalScalar:r,multiplyScalar:a}=e,i=rJ({typed:t,equalScalar:r}),s=dZ({typed:t,equalScalar:r}),o=sJ({typed:t,equalScalar:r}),u=uJ({typed:t}),l=lJ({typed:t});return t(CQ,{"any, any":a,"SparseMatrix, SparseMatrix":function(e,t){return s(e,t,a,!1)},"SparseMatrix, DenseMatrix":function(e,t){return i(t,e,a,!0)},"DenseMatrix, SparseMatrix":function(e,t){return i(e,t,a,!1)},"DenseMatrix, DenseMatrix":function(e,t){return u(e,t,a)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, any":function(e,t){return o(e,t,a,!1)},"DenseMatrix, any":function(e,t){return l(e,t,a,!1)},"any, SparseMatrix":function(e,t){return o(t,e,a,!0)},"any, DenseMatrix":function(e,t){return l(t,e,a,!0)},"Array, any":function(e,t){return l(n(e),t,a,!1).valueOf()},"any, Array":function(e,t){return l(n(t),e,a,!0).valueOf()}})})),LQ=YH("FibonacciHeap",["smaller","larger"],(e=>{var{smaller:t,larger:n}=e,r=1/Math.log((1+Math.sqrt(5))/2);function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}function i(e,t,n){t.left.right=t.right,t.right.left=t.left,n.degree--,n.child===t&&(n.child=t.right),0===n.degree&&(n.child=null),t.left=e,t.right=e.right,e.right=t,t.right.left=t,t.parent=null,t.mark=!1}function s(e,t){var n=t.parent;n&&(t.mark?(i(e,t,n),s(n)):t.mark=!0)}a.prototype.type="FibonacciHeap",a.prototype.isFibonacciHeap=!0,a.prototype.insert=function(e,n){var r={key:e,value:n,degree:0};if(this._minimum){var a=this._minimum;r.left=a,r.right=a.right,a.right=r,r.right.left=r,t(e,a.key)&&(this._minimum=r)}else r.left=r,r.right=r,this._minimum=r;return this._size++,r},a.prototype.size=function(){return this._size},a.prototype.clear=function(){this._minimum=null,this._size=0},a.prototype.isEmpty=function(){return 0===this._size},a.prototype.extractMinimum=function(){var e=this._minimum;if(null===e)return e;for(var a=this._minimum,i=e.degree,s=e.child;i>0;){var u=s.right;s.left.right=s.right,s.right.left=s.left,s.left=a,s.right=a.right,a.right=s,s.right.left=s,s.parent=null,s=u,i--}return e.left.right=e.right,e.right.left=e.left,a=e===e.right?null:function(e,a){var i,s=Math.floor(Math.log(a)*r)+1,u=new Array(s),l=0,c=e;if(c)for(l++,c=c.right;c!==e;)l++,c=c.right;for(;l>0;){for(var p=c.degree,d=c.right;i=u[p];){if(n(c.key,i.key)){var h=i;i=c,c=h}o(i,c),u[p]=null,p++}u[p]=c,c=d,l--}e=null;for(var f=0;f{var{typed:t,ceil:n,floor:r}=e;return t($Q,{number:function(e){return e>0?r(e):n(e)},"number, number":function(e,t){return e>0?r(e,t):n(e,t)}})})),FQ=YH($Q,OQ,(e=>{var{typed:t,Complex:n,matrix:r,ceil:a,floor:i,equalScalar:s,zeros:o,DenseMatrix:u}=e,l=oJ({typed:t,DenseMatrix:u}),c=lJ({typed:t}),p=RQ({typed:t,ceil:a,floor:i});return t("fix",{number:p.signatures.number,"number, number | BigNumber":p.signatures["number,number"],Complex:function(e){return new n(e.re>0?Math.floor(e.re):Math.ceil(e.re),e.im>0?Math.floor(e.im):Math.ceil(e.im))},"Complex, number":function(e,t){return new n(e.re>0?i(e.re,t):a(e.re,t),e.im>0?i(e.im,t):a(e.im,t))},"Complex, BigNumber":function(e,t){var r=t.toNumber();return new n(e.re>0?i(e.re,r):a(e.re,r),e.im>0?i(e.im,r):a(e.im,r))},BigNumber:function(e){return e.isNegative()?a(e):i(e)},"BigNumber, number | BigNumber":function(e,t){return e.isNegative()?a(e,t):i(e,t)},Fraction:function(e){return e.s<0?e.ceil():e.floor()},"Fraction, number | BigNumber":function(e,t){return e.s<0?a(e,t):i(e,t)},"Array | Matrix":function(e){return Gq(e,this,!0)},"Array | Matrix, number | BigNumber":function(e,t){return Gq(e,(e=>this(e,t)),!0)},"number | Complex | Fraction | BigNumber, Array":function(e,t){return c(r(t),e,this,!0).valueOf()},"number | Complex | Fraction | BigNumber, Matrix":function(e,t){return s(e,0)?o(t.size(),t.storage()):"dense"===t.storage()?c(t,e,this,!0):l(t,e,this,!0)}})})),YQ=YH("ImmutableDenseMatrix",["smaller","DenseMatrix"],(e=>{var{smaller:t,DenseMatrix:n}=e;function r(e,t){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!HP(t))throw new Error("Invalid datatype: "+t);if(UP(e)||jP(e)){var a=new n(e,t);this._data=a._data,this._size=a._size,this._datatype=a._datatype,this._min=null,this._max=null}else if(e&&jP(e.data)&&jP(e.size))this._data=e.data,this._size=e.size,this._datatype=e.datatype,this._min=void 0!==e.min?e.min:null,this._max=void 0!==e.max?e.max:null;else{if(e)throw new TypeError("Unsupported type of data ("+_H(e)+")");this._data=[],this._size=[0],this._datatype=t,this._min=null,this._max=null}}return r.prototype=new n,r.prototype.type="ImmutableDenseMatrix",r.prototype.isImmutableDenseMatrix=!0,r.prototype.subset=function(e){switch(arguments.length){case 1:var t=n.prototype.subset.call(this,e);return UP(t)?new r({data:t._data,size:t._size,datatype:t._datatype}):t;case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},r.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},r.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},r.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},r.prototype.clone=function(){return new r({data:wH(this._data),size:wH(this._size),datatype:this._datatype})},r.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},r.fromJSON=function(e){return new r(e)},r.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},r.prototype.min=function(){if(null===this._min){var e=null;this.forEach((function(n){(null===e||t(n,e))&&(e=n)})),this._min=null!==e?e:void 0}return this._min},r.prototype.max=function(){if(null===this._max){var e=null;this.forEach((function(n){(null===e||t(e,n))&&(e=n)})),this._max=null!==e?e:void 0}return this._max},r}),{isClass:!0}),zQ=YH("Index",["ImmutableDenseMatrix"],(e=>{var{ImmutableDenseMatrix:t}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._isScalar=!0;for(var t=0,a=arguments.length;t{var{typed:t,config:n,abs:r,add:a,addScalar:i,matrix:s,multiply:o,multiplyScalar:u,divideScalar:l,subtract:c,smaller:p,equalScalar:d,flatten:h,isZero:f,isNumeric:m}=e;return t("intersect",{"Array, Array, Array":g,"Array, Array, Array, Array":y,"Matrix, Matrix, Matrix":function(e,t,n){var r=g(e.valueOf(),t.valueOf(),n.valueOf());return null===r?null:s(r)},"Matrix, Matrix, Matrix, Matrix":function(e,t,n,r){var a=y(e.valueOf(),t.valueOf(),n.valueOf(),r.valueOf());return null===a?null:s(a)}});function g(e,t,n){if(e=b(e),t=b(t),n=b(n),!v(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!v(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!function(e){return 4===e.length&&m(e[0])&&m(e[1])&&m(e[2])&&m(e[3])}(n))throw new TypeError("Array with 4 numbers expected as third argument");return function(e,t,n,r,a,s,o,p,d,h){var f=u(e,o),m=u(r,o),g=u(t,p),y=u(a,p),b=u(n,d),x=u(s,d),v=c(c(c(h,f),g),b),_=c(c(c(i(i(m,y),x),f),g),b),w=l(v,_);return[i(e,u(w,c(r,e))),i(t,u(w,c(a,t))),i(n,u(w,c(s,n)))]}(e[0],e[1],e[2],t[0],t[1],t[2],n[0],n[1],n[2],n[3])}function y(e,t,s,h){if(e=b(e),t=b(t),s=b(s),h=b(h),2===e.length){if(!x(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!x(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!x(s))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!x(h))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");return function(e,t,s,d){var h=e,m=s,g=c(h,t),y=c(m,d),b=c(u(g[0],y[1]),u(y[0],g[1]));if(f(b))return null;if(p(r(b),n.epsilon))return null;var x=u(y[0],h[1]),v=u(y[1],h[0]),_=u(y[0],m[1]),w=u(y[1],m[0]),M=l(i(c(c(x,v),_),w),b);return a(o(g,M),h)}(e,t,s,h)}if(3===e.length){if(!v(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!v(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!v(s))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!v(h))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");return function(e,t,n,r,a,s,o,p,h,m,g,y){var b=_(e,o,m,o,t,p,g,p,n,h,y,h),x=_(m,o,r,e,g,p,a,t,y,h,s,n),v=_(e,o,r,e,t,p,a,t,n,h,s,n),w=_(m,o,m,o,g,p,g,p,y,h,y,h),M=_(r,e,r,e,a,t,a,t,s,n,s,n),N=c(u(b,x),u(v,w)),S=c(u(M,w),u(x,x));if(f(S))return null;var k=l(N,S),D=l(i(b,u(k,x)),w),T=i(e,u(k,c(r,e))),I=i(t,u(k,c(a,t))),E=i(n,u(k,c(s,n))),C=i(o,u(D,c(m,o))),A=i(p,u(D,c(g,p))),L=i(h,u(D,c(y,h)));return d(T,C)&&d(I,A)&&d(E,L)?[T,I,E]:null}(e[0],e[1],e[2],t[0],t[1],t[2],s[0],s[1],s[2],h[0],h[1],h[2])}throw new TypeError("Arrays with two or thee dimensional points expected")}function b(e){return 1===e.length?e[0]:e.length>1&&Array.isArray(e[0])&&e.every((e=>Array.isArray(e)&&1===e.length))?h(e):e}function x(e){return 2===e.length&&m(e[0])&&m(e[1])}function v(e){return 3===e.length&&m(e[0])&&m(e[1])&&m(e[2])}function _(e,t,n,r,a,s,o,l,p,d,h,f){var m=u(c(e,t),c(n,r)),g=u(c(a,s),c(o,l)),y=u(c(p,d),c(h,f));return i(i(m,g),y)}})),PQ=YH("lcm",["typed","matrix","equalScalar"],(e=>{var{typed:t,matrix:n,equalScalar:r}=e,a=rJ({typed:t,equalScalar:r}),i=dJ({typed:t,equalScalar:r}),s=sJ({typed:t,equalScalar:r}),o=uJ({typed:t}),u=lJ({typed:t});return t("lcm",{"number, number":cW,"BigNumber, BigNumber":function(e,t){if(!e.isInt()||!t.isInt())throw new Error("Parameters in function lcm must be integer numbers");if(e.isZero())return e;if(t.isZero())return t;for(var n=e.times(t);!t.isZero();){var r=t;t=e.mod(r),e=r}return n.div(e).abs()},"Fraction, Fraction":function(e,t){return e.lcm(t)},"SparseMatrix, SparseMatrix":function(e,t){return i(e,t,this)},"SparseMatrix, DenseMatrix":function(e,t){return a(t,e,this,!0)},"DenseMatrix, SparseMatrix":function(e,t){return a(e,t,this,!1)},"DenseMatrix, DenseMatrix":function(e,t){return o(e,t,this)},"Array, Array":function(e,t){return this(n(e),n(t)).valueOf()},"Array, Matrix":function(e,t){return this(n(e),t)},"Matrix, Array":function(e,t){return this(e,n(t))},"SparseMatrix, number | BigNumber":function(e,t){return s(e,t,this,!1)},"DenseMatrix, number | BigNumber":function(e,t){return u(e,t,this,!1)},"number | BigNumber, SparseMatrix":function(e,t){return s(t,e,this,!0)},"number | BigNumber, DenseMatrix":function(e,t){return u(t,e,this,!0)},"Array, number | BigNumber":function(e,t){return u(n(e),t,this,!1).valueOf()},"number | BigNumber, Array":function(e,t){return u(n(t),e,this,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,t,n){for(var r=this(e,t),a=0;a{var{typed:t,config:n,divideScalar:r,log:a,Complex:i}=e;return t(HQ,{number:function(e){return e>=-1||n.predictable?VH(e):s(new i(e,0))},Complex:s,BigNumber:function(e){var t=e.plus(1);return!t.isNegative()||n.predictable?t.ln():s(new i(e.toNumber(),0))},"Array | Matrix":function(e){return Gq(e,this)},"any, any":function(e,t){return r(this(e),a(t))}});function s(e){var t=e.re+1;return new i(Math.log(Math.sqrt(t*t+e.im*e.im)),Math.atan2(e.im,t))}})),UQ=YH("max",["typed","config","numeric","larger"],(e=>{var{typed:t,config:n,numeric:r,larger:a}=e;return t("max",{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(e,t){return Kq(e,t.valueOf(),i)},"...":function(e){if(Wq(e))throw new TypeError("Scalar values expected in function max");return s(e)}});function i(e,t){try{return a(e,t)?e:t}catch(e){throw vJ(e,"max",t)}}function s(e){var t;if(Vq(e,(function(e){try{isNaN(e)&&"number"==typeof e?t=NaN:(void 0===t||a(e,t))&&(t=e)}catch(t){throw vJ(t,"max",e)}})),void 0===t)throw new Error("Cannot calculate max of an empty array");return"string"==typeof t&&(t=r(t,n.number)),t}})),qQ=YH("quantileSeq",["typed","add","multiply","partitionSelect","compare"],(e=>{var{typed:t,add:n,multiply:r,partitionSelect:a,compare:i}=e;function s(e,t,s){var u=mq(e),l=u.length;if(0===l)throw new Error("Cannot calculate quantile of an empty sequence");if(FP(t)){var c=t*(l-1),p=c%1;if(0===p){var d=s?u[c]:a(u,c);return o(d),d}var h,f,m=Math.floor(c);if(s)h=u[m],f=u[m+1];else{f=a(u,m+1),h=u[m];for(var g=0;g0&&(h=u[g])}return o(h),o(f),n(r(h,1-p),r(f,p))}var y=t.times(l-1);if(y.isInteger()){y=y.toNumber();var b=s?u[y]:a(u,y);return o(b),b}var x,v,_=y.floor(),w=y.minus(_),M=_.toNumber();if(s)x=u[M],v=u[M+1];else{v=a(u,M+1),x=u[M];for(var N=0;N0&&(x=u[N])}o(x),o(v);var S=new w.constructor(1);return n(r(x,S.minus(w)),r(v,w))}var o=t({"number | BigNumber | Unit":function(e){return e}});return function(e,t,n){var r,a,i;if(arguments.length<2||arguments.length>3)throw new SyntaxError("Function quantileSeq requires two or three parameters");if(qP(e)){if("boolean"==typeof(n=n||!1)){if(a=e.valueOf(),FP(t)){if(t<0)throw new Error("N/prob must be non-negative");if(t<=1)return s(a,t,n);if(t>1){if(!jH(t))throw new Error("N must be a positive integer");var o=t+1;r=new Array(t);for(var u=0;u4294967295)throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");var p=new l(c+1);r=new Array(c);for(var d=0;d1)throw new Error("Probability must be between 0 and 1, inclusive")}else{if(!YP(f))throw new TypeError("Unexpected type of argument in function quantileSeq");if(i=new f.constructor(1),f.isNegative()||f.gt(i))throw new Error("Probability must be between 0 and 1, inclusive")}r[h]=s(a,f,n)}return r}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}})),WQ=YH("row",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:n,matrix:r,range:a}=e;return t("row",{"Matrix, number":i,"Array, number":function(e,t){return i(r(wH(e)),t).valueOf()}});function i(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");iq(t,e.size()[0]);var r=a(0,e.size()[1]),i=new n(t,r);return e.subset(i)}})),VQ="setCartesian",GQ=YH(VQ,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:n,subset:r,compareNatural:a,Index:i,DenseMatrix:s}=e;return t(VQ,{"Array | Matrix, Array | Matrix":function(e,t){var o=[];if(0!==r(n(e),new i(0))&&0!==r(n(t),new i(0))){var u=mq(Array.isArray(e)?e:e.toArray()).sort(a),l=mq(Array.isArray(t)?t:t.toArray()).sort(a);o=[];for(var c=0;c{var{typed:t,size:n,subset:r,compareNatural:a,Index:i,DenseMatrix:s}=e;return t(KQ,{"Array | Matrix":function(e){var t;if(0===r(n(e),new i(0)))t=[];else{var o=mq(Array.isArray(e)?e:e.toArray()).sort(a);(t=[]).push(o[0]);for(var u=1;u{var{typed:t,size:n,subset:r,compareNatural:a,Index:i}=e;return t(XQ,{"Array | Matrix, Array | Matrix":function(e,t){if(0===r(n(e),new i(0)))return!0;if(0===r(n(t),new i(0)))return!1;for(var s,o=_q(mq(Array.isArray(e)?e:e.toArray()).sort(a)),u=_q(mq(Array.isArray(t)?t:t.toArray()).sort(a)),l=0;l{var{typed:t,size:n,subset:r,compareNatural:a,Index:i}=e;return t(QQ,{"Array | Matrix":function(e){if(0===r(n(e),new i(0)))return[];for(var t=mq(Array.isArray(e)?e:e.toArray()).sort(a),o=[],u=0;u.toString(2).length<=t.length;)o.push(s(t,u.toString(2).split("").reverse())),u++;return function(e){for(var t=[],n=e.length-1;n>0;n--)for(var r=0;re[r+1].length&&(t=e[r],e[r]=e[r+1],e[r+1]=t);return e}(o)}});function s(e,t){for(var n=[],r=0;r{var{typed:t,matrix:n,compare:r,compareNatural:a}=e,i=r,s=(e,t)=>-r(e,t);return t(t0,{Array:function(e){return u(e),e.sort(i)},Matrix:function(e){return l(e),n(e.toArray().sort(i),e.storage())},"Array, function":function(e,t){return u(e),e.sort(t)},"Matrix, function":function(e,t){return l(e),n(e.toArray().sort(t),e.storage())},"Array, string":function(e,t){return u(e),e.sort(o(t))},"Matrix, string":function(e,t){return l(e),n(e.toArray().sort(o(t)),e.storage())}});function o(e){if("asc"===e)return i;if("desc"===e)return s;if("natural"===e)return a;throw new Error('String "asc", "desc", or "natural" expected')}function u(e){if(1!==nq(e).length)throw new Error("One dimensional array expected")}function l(e){if(1!==e.size().length)throw new Error("One dimensional matrix expected")}})),r0="column",a0=YH(r0,["typed","Index","matrix","range"],(e=>{var{typed:t,Index:n,matrix:r,range:a}=e;return t(r0,{"Matrix, number":i,"Array, number":function(e,t){return i(r(wH(e)),t).valueOf()}});function i(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");iq(t,e.size()[1]);var r=a(0,e.size()[0]),i=new n(r,t);return e.subset(i)}})),i0="index",s0=YH(i0,["typed","Index"],(e=>{var{typed:t,Index:n}=e;return t(i0,{"...number | string | BigNumber | Range | Array | Matrix":function(e){var t=e.map((function(e){return YP(e)?e.toNumber():Array.isArray(e)||UP(e)?e.map((function(e){return YP(e)?e.toNumber():e})):e})),r=new n;return n.apply(r,t),r}})})),o0=YH("inv",["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],(e=>{var{typed:t,matrix:n,divideScalar:r,addScalar:a,multiply:i,unaryMinus:s,det:o,identity:u,abs:l}=e;return t("inv",{"Array | Matrix":function(e){var t=UP(e)?e.size():nq(e);switch(t.length){case 1:if(1===t[0])return UP(e)?n([r(1,e.valueOf()[0])]):[r(1,e[0])];throw new RangeError("Matrix must be square (size: "+KU(t)+")");case 2:var a=t[0],i=t[1];if(a===i)return UP(e)?n(c(e.valueOf(),a,i),e.storage()):c(e,a,i);throw new RangeError("Matrix must be square (size: "+KU(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+KU(t)+")")}},any:function(e){return r(1,e)}});function c(e,t,n){var c,p,d,h,f;if(1===t){if(0===(h=e[0][0]))throw Error("Cannot calculate inverse, determinant is zero");return[[r(1,h)]]}if(2===t){var m=o(e);if(0===m)throw Error("Cannot calculate inverse, determinant is zero");return[[r(e[1][1],m),r(s(e[0][1]),m)],[r(s(e[1][0]),m),r(e[0][0],m)]]}var g=e.concat();for(c=0;cx&&(x=l(g[c][b]),v=c),c++;if(0===x)throw Error("Cannot calculate inverse, determinant is zero");(c=v)!==b&&(f=g[b],g[b]=g[c],g[c]=f,f=y[b],y[b]=y[c],y[c]=f);var _=g[b],w=y[b];for(c=0;c{var{typed:t,matrix:n,inv:r,deepEqual:a,equal:i,dotDivide:s,dot:o,ctranspose:u,divideScalar:l,multiply:c,add:p,Complex:d}=e;return t(u0,{"Array | Matrix":function(e){var t=UP(e)?e.size():nq(e);switch(t.length){case 1:return m(e)?u(e):1===t[0]?r(e):s(u(e),o(e,e));case 2:if(m(e))return u(e);var a=t[0],i=t[1];if(a===i)try{return r(e)}catch(e){if(!(e instanceof Error&&e.message.match(/Cannot calculate inverse, determinant is zero/)))throw e}return UP(e)?n(h(e.valueOf(),a,i),e.storage()):h(e,a,i);default:throw new RangeError("Matrix must be two dimensional (size: "+KU(t)+")")}},any:function(e){return i(e,0)?wH(e):l(1,e)}});function h(e,t,n){var{C:a,F:i}=function(e,t,n){var r=function(e,t,n){for(var r=wH(e),a=0,i=0;ie.filter(((e,n)=>n!f(o(r[t],r[t]))));return{C:a,F:i}}(e,t,n),l=c(r(c(u(a),a)),u(a)),d=c(u(i),r(c(i,u(i))));return c(d,l)}function f(e){return i(p(e,d(1,1)),p(0,d(1,1)))}function m(e){return a(p(e,d(1,1)),p(c(e,0),d(1,1)))}})),c0=YH("pow",["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],(e=>{var{typed:t,config:n,identity:r,multiply:a,matrix:i,inv:s,number:o,fraction:u,Complex:l}=e;return t("pow",{"number, number":c,"Complex, Complex":function(e,t){return e.pow(t)},"BigNumber, BigNumber":function(e,t){return t.isInteger()||e>=0||n.predictable?e.pow(t):new l(e.toNumber(),0).pow(t.toNumber(),0)},"Fraction, Fraction":function(e,t){var r=e.pow(t);if(null!=r)return r;if(n.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return c(e.valueOf(),t.valueOf())},"Array, number":p,"Array, BigNumber":function(e,t){return p(e,t.toNumber())},"Matrix, number":d,"Matrix, BigNumber":function(e,t){return d(e,t.toNumber())},"Unit, number | BigNumber":function(e,t){return e.pow(t)}});function c(e,t){if(n.predictable&&!jH(t)&&e<0)try{var r=u(t),a=o(r);if((t===a||Math.abs((t-a)/t)<1e-14)&&r.d%2==1)return(r.n%2==0?1:-1)*Math.pow(-e,t)}catch(e){}return n.predictable&&(e<-1&&t===1/0||e>-1&&e<0&&t===-1/0)?NaN:jH(t)||e>=0||n.predictable?bW(e,t):e*e<1&&t===1/0||e*e>1&&t===-1/0?0:new l(e,0).pow(t,0)}function p(e,t){if(!jH(t))throw new TypeError("For A^b, b must be an integer (value is "+t+")");var n=nq(e);if(2!==n.length)throw new Error("For A^b, A must be 2 dimensional (A has "+n.length+" dimensions)");if(n[0]!==n[1])throw new Error("For A^b, A must be square (size is "+n[0]+"x"+n[1]+")");if(t<0)try{return p(s(e),-t)}catch(e){if("Cannot calculate inverse, determinant is zero"===e.message)throw new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+t+")");throw e}for(var i=r(n[0]).valueOf(),o=e;t>=1;)1==(1&t)&&(i=a(o,i)),t>>=1,o=a(o,o);return i}function d(e,t){return i(p(e.valueOf(),t))}})),p0="setDifference",d0=YH(p0,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:n,subset:r,compareNatural:a,Index:i,DenseMatrix:s}=e;return t(p0,{"Array | Matrix, Array | Matrix":function(e,t){var o;if(0===r(n(e),new i(0)))o=[];else{if(0===r(n(t),new i(0)))return mq(e.toArray());var u,l=_q(mq(Array.isArray(e)?e:e.toArray()).sort(a)),c=_q(mq(Array.isArray(t)?t:t.toArray()).sort(a));o=[];for(var p=0;p{var{typed:t,size:n,subset:r,compareNatural:a,Index:i}=e;return t(h0,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(e,t){if(0===r(n(t),new i(0)))return 0;for(var s=mq(Array.isArray(t)?t:t.toArray()),o=0,u=0;u{var{addScalar:t,equalScalar:n,FibonacciHeap:r}=e;function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new r}return a.prototype.type="Spa",a.prototype.isSpa=!0,a.prototype.set=function(e,t){if(this._values[e])this._values[e].value=t;else{var n=this._heap.insert(e,t);this._values[e]=n}},a.prototype.get=function(e){var t=this._values[e];return t?t.value:0},a.prototype.accumulate=function(e,n){var r=this._values[e];r?r.value=t(r.value,n):(r=this._heap.insert(e,n),this._values[e]=r)},a.prototype.forEach=function(e,t,r){var a=this._heap,i=this._values,s=[],o=a.extractMinimum();for(o&&s.push(o);o&&o.key<=t;)o.key>=e&&(n(o.value,0)||r(o.key,o.value,this)),(o=a.extractMinimum())&&s.push(o);for(var u=0;u{var{typed:t,abs:n,add:r,multiply:a,sqrt:i,subtract:s,inv:o,size:u,max:l,identity:c}=e,p=1e-6;function d(e){var t,i=0,d=e,h=c(u(e));do{var f=d;if(d=a(.5,r(f,o(h))),h=a(.5,r(h,o(f))),(t=l(n(s(d,f))))>p&&++i>1e3)throw new Error("computing square root of matrix: iterative method could not converge")}while(t>p);return d}return t(g0,{"Array | Matrix":function(e){var t=UP(e)?e.size():nq(e);switch(t.length){case 1:if(1===t[0])return i(e);throw new RangeError("Matrix must be square (size: "+KU(t)+")");case 2:if(t[0]===t[1])return d(e);throw new RangeError("Matrix must be square (size: "+KU(t)+")");default:throw new RangeError("Matrix must be at most two dimensional (size: "+KU(t)+")")}}})}));function b0(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function x0(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function v0(e){for(var t=1;t{var t,n,r,{on:a,config:i,addScalar:s,subtract:o,multiplyScalar:u,divideScalar:l,pow:c,abs:p,fix:d,round:h,equal:f,isNumeric:m,format:g,number:y,Complex:b,BigNumber:x,Fraction:v}=e,_=y;function w(e,t){if(!(this instanceof w))throw new Error("Constructor must be called with the new operator");if(null!=e&&!m(e)&&!zP(e))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(void 0!==t&&("string"!=typeof t||""===t))throw new TypeError("Second parameter in Unit constructor must be a string");if(void 0!==t){var n=w.parse(t);this.units=n.units,this.dimensions=n.dimensions}else{this.units=[{unit:R,prefix:A.NONE,power:0}],this.dimensions=[];for(var r=0;r="0"&&e<="9"}function S(){n++,r=t.charAt(n)}function k(e){n=e,r=t.charAt(n)}function D(){var e="",t=n;if("+"===r?S():"-"===r&&(e+=r,S()),!function(e){return e>="0"&&e<="9"||"."===e}(r))return k(t),null;if("."===r){if(e+=r,S(),!N(r))return k(t),null}else{for(;N(r);)e+=r,S();"."===r&&(e+=r,S())}for(;N(r);)e+=r,S();if("E"===r||"e"===r){var a="",i=n;if(a+=r,S(),"+"!==r&&"-"!==r||(a+=r,S()),!N(r))return k(i),e;for(e+=a;N(r);)e+=r,S()}return e}function T(){for(var e="";N(r)||w.isValidAlpha(r);)e+=r,S();var t=e.charAt(0);return w.isValidAlpha(t)?e:null}function I(e){return r===e?(S(),e):null}w.prototype.type="Unit",w.prototype.isUnit=!0,w.parse=function(e,a){if(a=a||{},n=-1,r="","string"!=typeof(t=e))throw new TypeError("Invalid argument in Unit.parse, string expected");var s=new w;s.units=[];var o=1,u=!1;S(),M();var l=D(),c=null;if(l){if("BigNumber"===i.number)c=new x(l);else if("Fraction"===i.number)try{c=new v(l)}catch(e){c=parseFloat(l)}else c=parseFloat(l);M(),I("*")?(o=1,u=!0):I("/")&&(o=-1,u=!0)}for(var p=[],d=1;;){for(M();"("===r;)p.push(o),d*=o,o=1,S(),M();var h;if(!r)break;var f=r;if(null===(h=T()))throw new SyntaxError('Unexpected "'+f+'" in "'+t+'" at index '+n.toString());var m=E(h);if(null===m)throw new SyntaxError('Unit "'+h+'" not found.');var g=o*d;if(M(),I("^")){M();var y=D();if(null===y)throw new SyntaxError('In "'+e+'", "^" must be followed by a floating-point number');g*=y}s.units.push({unit:m.unit,prefix:m.prefix,power:g});for(var b=0;b1||Math.abs(this.units[0].power-1)>1e-15)},w.prototype._normalize=function(e){if(null==e||0===this.units.length)return e;for(var t=e,n=w._getNumberConverter(_H(e)),r=0;r{if(EH(F,e)){var t=F[e];return{unit:t,prefix:t.prefixes[""]}}for(var n in F)if(EH(F,n)&&GU(e,n)){var r=F[n],a=e.length-n.length,i=e.substring(0,a),s=EH(r.prefixes,i)?r.prefixes[i]:void 0;if(void 0!==s)return{unit:r,prefix:s}}return null}),{hasher:e=>e[0],limit:100});function C(e){return e.equalBase($.NONE)&&null!==e.value&&!i.predictable?e.value:e}w.isValuelessUnit=function(e){return null!==E(e)},w.prototype.hasBase=function(e){if("string"==typeof e&&(e=$[e]),!e)return!1;for(var t=0;t1e-12)return!1;return!0},w.prototype.equalBase=function(e){for(var t=0;t1e-12)return!1;return!0},w.prototype.equals=function(e){return this.equalBase(e)&&f(this.value,e.value)},w.prototype.multiply=function(e){for(var t=this.clone(),n=0;n1e-12&&(EH(P,o)?r.push({unit:P[o].unit,prefix:P[o].prefix,power:n.dimensions[s]||0}):i=!0)}r.length1e-12){if(!EH(B.si,r))throw new Error("Cannot express custom unit "+r+" in SI units");t.push({unit:B.si[r].unit,prefix:B.si[r].prefix,power:e.dimensions[n]||0})}}return e.units=t,e.fixPrefix=!0,e.skipAutomaticSimplification=!0,e},w.prototype.formatUnits=function(){for(var e="",t="",n=0,r=0,a=0;a0?(n++,e+=" "+this.units[a].prefix.name+this.units[a].unit.name,Math.abs(this.units[a].power-1)>1e-15&&(e+="^"+this.units[a].power)):this.units[a].power<0&&r++;if(r>0)for(var i=0;i0?(t+=" "+this.units[i].prefix.name+this.units[i].unit.name,Math.abs(this.units[i].power+1)>1e-15&&(t+="^"+-this.units[i].power)):(t+=" "+this.units[i].prefix.name+this.units[i].unit.name,t+="^"+this.units[i].power));e=e.substr(1),t=t.substr(1),n>1&&r>0&&(e="("+e+")"),r>1&&n>0&&(t="("+t+")");var s=e;return n>0&&r>0&&(s+=" / "),s+t},w.prototype.format=function(e){var t=this.skipAutomaticSimplification||null===this.value?this.clone():this.simplify(),n=!1;for(var r in void 0!==t.value&&null!==t.value&&zP(t.value)&&(n=Math.abs(t.value.re)<1e-14),t.units)EH(t.units,r)&&t.units[r].unit&&("VA"===t.units[r].unit.name&&n?t.units[r].unit=F.VAR:"VAR"!==t.units[r].unit.name||n||(t.units[r].unit=F.VA));1!==t.units.length||t.fixPrefix||Math.abs(t.units[0].power-Math.round(t.units[0].power))<1e-14&&(t.units[0].prefix=t._bestPrefix());var a=t._denormalize(t.value),i=null!==t.value?g(a,e||{}):"",s=t.formatUnits();return t.value&&zP(t.value)&&(i="("+i+")"),s.length>0&&i.length>0&&(i+=" "),i+s},w.prototype._bestPrefix=function(){if(1!==this.units.length)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");if(Math.abs(this.units[0].power-Math.round(this.units[0].power))>=1e-14)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");var e=null!==this.value?p(this.value):0,t=p(this.units[0].unit.value),n=this.units[0].prefix;if(0===e)return n;var r=this.units[0].power,a=Math.log(e/Math.pow(n.value*t,r))/Math.LN10-1.2;if(a>-2.200001&&a<1.800001)return n;a=Math.abs(a);var i=this.units[0].unit.prefixes;for(var s in i)if(EH(i,s)){var o=i[s];if(o.scientific){var u=Math.abs(Math.log(e/Math.pow(o.value*t,r))/Math.LN10-1.2);(u0))},F={meter:{name:"meter",base:$.LENGTH,prefixes:A.LONG,value:1,offset:0},inch:{name:"inch",base:$.LENGTH,prefixes:A.NONE,value:.0254,offset:0},foot:{name:"foot",base:$.LENGTH,prefixes:A.NONE,value:.3048,offset:0},yard:{name:"yard",base:$.LENGTH,prefixes:A.NONE,value:.9144,offset:0},mile:{name:"mile",base:$.LENGTH,prefixes:A.NONE,value:1609.344,offset:0},link:{name:"link",base:$.LENGTH,prefixes:A.NONE,value:.201168,offset:0},rod:{name:"rod",base:$.LENGTH,prefixes:A.NONE,value:5.0292,offset:0},chain:{name:"chain",base:$.LENGTH,prefixes:A.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:$.LENGTH,prefixes:A.NONE,value:1e-10,offset:0},m:{name:"m",base:$.LENGTH,prefixes:A.SHORT,value:1,offset:0},in:{name:"in",base:$.LENGTH,prefixes:A.NONE,value:.0254,offset:0},ft:{name:"ft",base:$.LENGTH,prefixes:A.NONE,value:.3048,offset:0},yd:{name:"yd",base:$.LENGTH,prefixes:A.NONE,value:.9144,offset:0},mi:{name:"mi",base:$.LENGTH,prefixes:A.NONE,value:1609.344,offset:0},li:{name:"li",base:$.LENGTH,prefixes:A.NONE,value:.201168,offset:0},rd:{name:"rd",base:$.LENGTH,prefixes:A.NONE,value:5.02921,offset:0},ch:{name:"ch",base:$.LENGTH,prefixes:A.NONE,value:20.1168,offset:0},mil:{name:"mil",base:$.LENGTH,prefixes:A.NONE,value:254e-7,offset:0},m2:{name:"m2",base:$.SURFACE,prefixes:A.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:$.SURFACE,prefixes:A.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:$.SURFACE,prefixes:A.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:$.SURFACE,prefixes:A.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:$.SURFACE,prefixes:A.NONE,value:2589988.110336,offset:0},sqrd:{name:"sqrd",base:$.SURFACE,prefixes:A.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:$.SURFACE,prefixes:A.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:$.SURFACE,prefixes:A.NONE,value:6.4516e-10,offset:0},acre:{name:"acre",base:$.SURFACE,prefixes:A.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:$.SURFACE,prefixes:A.NONE,value:1e4,offset:0},m3:{name:"m3",base:$.VOLUME,prefixes:A.CUBIC,value:1,offset:0},L:{name:"L",base:$.VOLUME,prefixes:A.SHORT,value:.001,offset:0},l:{name:"l",base:$.VOLUME,prefixes:A.SHORT,value:.001,offset:0},litre:{name:"litre",base:$.VOLUME,prefixes:A.LONG,value:.001,offset:0},cuin:{name:"cuin",base:$.VOLUME,prefixes:A.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:$.VOLUME,prefixes:A.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:$.VOLUME,prefixes:A.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:$.VOLUME,prefixes:A.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:$.VOLUME,prefixes:A.NONE,value:15e-6,offset:0},drop:{name:"drop",base:$.VOLUME,prefixes:A.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:$.VOLUME,prefixes:A.NONE,value:5e-8,offset:0},minim:{name:"minim",base:$.VOLUME,prefixes:A.NONE,value:6.161152e-8,offset:0},fluiddram:{name:"fluiddram",base:$.VOLUME,prefixes:A.NONE,value:36966911e-13,offset:0},fluidounce:{name:"fluidounce",base:$.VOLUME,prefixes:A.NONE,value:2957353e-11,offset:0},gill:{name:"gill",base:$.VOLUME,prefixes:A.NONE,value:.0001182941,offset:0},cc:{name:"cc",base:$.VOLUME,prefixes:A.NONE,value:1e-6,offset:0},cup:{name:"cup",base:$.VOLUME,prefixes:A.NONE,value:.0002365882,offset:0},pint:{name:"pint",base:$.VOLUME,prefixes:A.NONE,value:.0004731765,offset:0},quart:{name:"quart",base:$.VOLUME,prefixes:A.NONE,value:.0009463529,offset:0},gallon:{name:"gallon",base:$.VOLUME,prefixes:A.NONE,value:.003785412,offset:0},beerbarrel:{name:"beerbarrel",base:$.VOLUME,prefixes:A.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:$.VOLUME,prefixes:A.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:$.VOLUME,prefixes:A.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:$.VOLUME,prefixes:A.NONE,value:36966911e-13,offset:0},floz:{name:"floz",base:$.VOLUME,prefixes:A.NONE,value:2957353e-11,offset:0},gi:{name:"gi",base:$.VOLUME,prefixes:A.NONE,value:.0001182941,offset:0},cp:{name:"cp",base:$.VOLUME,prefixes:A.NONE,value:.0002365882,offset:0},pt:{name:"pt",base:$.VOLUME,prefixes:A.NONE,value:.0004731765,offset:0},qt:{name:"qt",base:$.VOLUME,prefixes:A.NONE,value:.0009463529,offset:0},gal:{name:"gal",base:$.VOLUME,prefixes:A.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:$.VOLUME,prefixes:A.NONE,value:.1173478,offset:0},obl:{name:"obl",base:$.VOLUME,prefixes:A.NONE,value:.1589873,offset:0},g:{name:"g",base:$.MASS,prefixes:A.SHORT,value:.001,offset:0},gram:{name:"gram",base:$.MASS,prefixes:A.LONG,value:.001,offset:0},ton:{name:"ton",base:$.MASS,prefixes:A.SHORT,value:907.18474,offset:0},t:{name:"t",base:$.MASS,prefixes:A.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:$.MASS,prefixes:A.LONG,value:1e3,offset:0},grain:{name:"grain",base:$.MASS,prefixes:A.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:$.MASS,prefixes:A.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:$.MASS,prefixes:A.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:$.MASS,prefixes:A.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:$.MASS,prefixes:A.NONE,value:45.359237,offset:0},stick:{name:"stick",base:$.MASS,prefixes:A.NONE,value:.115,offset:0},stone:{name:"stone",base:$.MASS,prefixes:A.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:$.MASS,prefixes:A.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:$.MASS,prefixes:A.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:$.MASS,prefixes:A.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:$.MASS,prefixes:A.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:$.MASS,prefixes:A.NONE,value:45.359237,offset:0},s:{name:"s",base:$.TIME,prefixes:A.SHORT,value:1,offset:0},min:{name:"min",base:$.TIME,prefixes:A.NONE,value:60,offset:0},h:{name:"h",base:$.TIME,prefixes:A.NONE,value:3600,offset:0},second:{name:"second",base:$.TIME,prefixes:A.LONG,value:1,offset:0},sec:{name:"sec",base:$.TIME,prefixes:A.LONG,value:1,offset:0},minute:{name:"minute",base:$.TIME,prefixes:A.NONE,value:60,offset:0},hour:{name:"hour",base:$.TIME,prefixes:A.NONE,value:3600,offset:0},day:{name:"day",base:$.TIME,prefixes:A.NONE,value:86400,offset:0},week:{name:"week",base:$.TIME,prefixes:A.NONE,value:604800,offset:0},month:{name:"month",base:$.TIME,prefixes:A.NONE,value:2629800,offset:0},year:{name:"year",base:$.TIME,prefixes:A.NONE,value:31557600,offset:0},decade:{name:"decade",base:$.TIME,prefixes:A.NONE,value:315576e3,offset:0},century:{name:"century",base:$.TIME,prefixes:A.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:$.TIME,prefixes:A.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:$.FREQUENCY,prefixes:A.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:$.FREQUENCY,prefixes:A.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:$.ANGLE,prefixes:A.SHORT,value:1,offset:0},radian:{name:"radian",base:$.ANGLE,prefixes:A.LONG,value:1,offset:0},deg:{name:"deg",base:$.ANGLE,prefixes:A.SHORT,value:null,offset:0},degree:{name:"degree",base:$.ANGLE,prefixes:A.LONG,value:null,offset:0},grad:{name:"grad",base:$.ANGLE,prefixes:A.SHORT,value:null,offset:0},gradian:{name:"gradian",base:$.ANGLE,prefixes:A.LONG,value:null,offset:0},cycle:{name:"cycle",base:$.ANGLE,prefixes:A.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:$.ANGLE,prefixes:A.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:$.ANGLE,prefixes:A.NONE,value:null,offset:0},A:{name:"A",base:$.CURRENT,prefixes:A.SHORT,value:1,offset:0},ampere:{name:"ampere",base:$.CURRENT,prefixes:A.LONG,value:1,offset:0},K:{name:"K",base:$.TEMPERATURE,prefixes:A.NONE,value:1,offset:0},degC:{name:"degC",base:$.TEMPERATURE,prefixes:A.NONE,value:1,offset:273.15},degF:{name:"degF",base:$.TEMPERATURE,prefixes:A.NONE,value:1/1.8,offset:459.67},degR:{name:"degR",base:$.TEMPERATURE,prefixes:A.NONE,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:$.TEMPERATURE,prefixes:A.NONE,value:1,offset:0},celsius:{name:"celsius",base:$.TEMPERATURE,prefixes:A.NONE,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:$.TEMPERATURE,prefixes:A.NONE,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:$.TEMPERATURE,prefixes:A.NONE,value:1/1.8,offset:0},mol:{name:"mol",base:$.AMOUNT_OF_SUBSTANCE,prefixes:A.SHORT,value:1,offset:0},mole:{name:"mole",base:$.AMOUNT_OF_SUBSTANCE,prefixes:A.LONG,value:1,offset:0},cd:{name:"cd",base:$.LUMINOUS_INTENSITY,prefixes:A.SHORT,value:1,offset:0},candela:{name:"candela",base:$.LUMINOUS_INTENSITY,prefixes:A.LONG,value:1,offset:0},N:{name:"N",base:$.FORCE,prefixes:A.SHORT,value:1,offset:0},newton:{name:"newton",base:$.FORCE,prefixes:A.LONG,value:1,offset:0},dyn:{name:"dyn",base:$.FORCE,prefixes:A.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:$.FORCE,prefixes:A.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:$.FORCE,prefixes:A.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:$.FORCE,prefixes:A.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:$.FORCE,prefixes:A.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:$.FORCE,prefixes:A.NONE,value:9.80665,offset:0},J:{name:"J",base:$.ENERGY,prefixes:A.SHORT,value:1,offset:0},joule:{name:"joule",base:$.ENERGY,prefixes:A.SHORT,value:1,offset:0},erg:{name:"erg",base:$.ENERGY,prefixes:A.NONE,value:1e-7,offset:0},Wh:{name:"Wh",base:$.ENERGY,prefixes:A.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:$.ENERGY,prefixes:A.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:$.ENERGY,prefixes:A.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:$.ENERGY,prefixes:A.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:$.POWER,prefixes:A.SHORT,value:1,offset:0},watt:{name:"watt",base:$.POWER,prefixes:A.LONG,value:1,offset:0},hp:{name:"hp",base:$.POWER,prefixes:A.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:$.POWER,prefixes:A.SHORT,value:b.I,offset:0},VA:{name:"VA",base:$.POWER,prefixes:A.SHORT,value:1,offset:0},Pa:{name:"Pa",base:$.PRESSURE,prefixes:A.SHORT,value:1,offset:0},psi:{name:"psi",base:$.PRESSURE,prefixes:A.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:$.PRESSURE,prefixes:A.NONE,value:101325,offset:0},bar:{name:"bar",base:$.PRESSURE,prefixes:A.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:$.PRESSURE,prefixes:A.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:$.PRESSURE,prefixes:A.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:$.PRESSURE,prefixes:A.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:$.PRESSURE,prefixes:A.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:$.ELECTRIC_CHARGE,prefixes:A.LONG,value:1,offset:0},C:{name:"C",base:$.ELECTRIC_CHARGE,prefixes:A.SHORT,value:1,offset:0},farad:{name:"farad",base:$.ELECTRIC_CAPACITANCE,prefixes:A.LONG,value:1,offset:0},F:{name:"F",base:$.ELECTRIC_CAPACITANCE,prefixes:A.SHORT,value:1,offset:0},volt:{name:"volt",base:$.ELECTRIC_POTENTIAL,prefixes:A.LONG,value:1,offset:0},V:{name:"V",base:$.ELECTRIC_POTENTIAL,prefixes:A.SHORT,value:1,offset:0},ohm:{name:"ohm",base:$.ELECTRIC_RESISTANCE,prefixes:A.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:$.ELECTRIC_INDUCTANCE,prefixes:A.LONG,value:1,offset:0},H:{name:"H",base:$.ELECTRIC_INDUCTANCE,prefixes:A.SHORT,value:1,offset:0},siemens:{name:"siemens",base:$.ELECTRIC_CONDUCTANCE,prefixes:A.LONG,value:1,offset:0},S:{name:"S",base:$.ELECTRIC_CONDUCTANCE,prefixes:A.SHORT,value:1,offset:0},weber:{name:"weber",base:$.MAGNETIC_FLUX,prefixes:A.LONG,value:1,offset:0},Wb:{name:"Wb",base:$.MAGNETIC_FLUX,prefixes:A.SHORT,value:1,offset:0},tesla:{name:"tesla",base:$.MAGNETIC_FLUX_DENSITY,prefixes:A.LONG,value:1,offset:0},T:{name:"T",base:$.MAGNETIC_FLUX_DENSITY,prefixes:A.SHORT,value:1,offset:0},b:{name:"b",base:$.BIT,prefixes:A.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:$.BIT,prefixes:A.BINARY_LONG,value:1,offset:0},B:{name:"B",base:$.BIT,prefixes:A.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:$.BIT,prefixes:A.BINARY_LONG,value:8,offset:0}},Y={meters:"meter",inches:"inch",feet:"foot",yards:"yard",miles:"mile",links:"link",rods:"rod",chains:"chain",angstroms:"angstrom",lt:"l",litres:"litre",liter:"litre",liters:"litre",teaspoons:"teaspoon",tablespoons:"tablespoon",minims:"minim",fluiddrams:"fluiddram",fluidounces:"fluidounce",gills:"gill",cups:"cup",pints:"pint",quarts:"quart",gallons:"gallon",beerbarrels:"beerbarrel",oilbarrels:"oilbarrel",hogsheads:"hogshead",gtts:"gtt",grams:"gram",tons:"ton",tonnes:"tonne",grains:"grain",drams:"dram",ounces:"ounce",poundmasses:"poundmass",hundredweights:"hundredweight",sticks:"stick",lb:"lbm",lbs:"lbm",kips:"kip",kgf:"kilogramforce",acres:"acre",hectares:"hectare",sqfeet:"sqft",sqyard:"sqyd",sqmile:"sqmi",sqmiles:"sqmi",mmhg:"mmHg",mmh2o:"mmH2O",cmh2o:"cmH2O",seconds:"second",secs:"second",minutes:"minute",mins:"minute",hours:"hour",hr:"hour",hrs:"hour",days:"day",weeks:"week",months:"month",years:"year",decades:"decade",centuries:"century",millennia:"millennium",hertz:"hertz",radians:"radian",degrees:"degree",gradians:"gradian",cycles:"cycle",arcsecond:"arcsec",arcseconds:"arcsec",arcminute:"arcmin",arcminutes:"arcmin",BTUs:"BTU",watts:"watt",joules:"joule",amperes:"ampere",coulombs:"coulomb",volts:"volt",ohms:"ohm",farads:"farad",webers:"weber",teslas:"tesla",electronvolts:"electronvolt",moles:"mole",bit:"bits",byte:"bytes"};function z(e){if("BigNumber"===e.number){var t=yj(x);F.rad.value=new x(1),F.deg.value=t.div(180),F.grad.value=t.div(200),F.cycle.value=t.times(2),F.arcsec.value=t.div(648e3),F.arcmin.value=t.div(10800)}else F.rad.value=1,F.deg.value=Math.PI/180,F.grad.value=Math.PI/200,F.cycle.value=2*Math.PI,F.arcsec.value=Math.PI/648e3,F.arcmin.value=Math.PI/10800;F.radian.value=F.rad.value,F.degree.value=F.deg.value,F.gradian.value=F.grad.value}z(i),a&&a("config",(function(e,t){e.number!==t.number&&z(e)}));var B={si:{NONE:{unit:R,prefix:A.NONE[""]},LENGTH:{unit:F.m,prefix:A.SHORT[""]},MASS:{unit:F.g,prefix:A.SHORT.k},TIME:{unit:F.s,prefix:A.SHORT[""]},CURRENT:{unit:F.A,prefix:A.SHORT[""]},TEMPERATURE:{unit:F.K,prefix:A.SHORT[""]},LUMINOUS_INTENSITY:{unit:F.cd,prefix:A.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:F.mol,prefix:A.SHORT[""]},ANGLE:{unit:F.rad,prefix:A.SHORT[""]},BIT:{unit:F.bits,prefix:A.SHORT[""]},FORCE:{unit:F.N,prefix:A.SHORT[""]},ENERGY:{unit:F.J,prefix:A.SHORT[""]},POWER:{unit:F.W,prefix:A.SHORT[""]},PRESSURE:{unit:F.Pa,prefix:A.SHORT[""]},ELECTRIC_CHARGE:{unit:F.C,prefix:A.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:F.F,prefix:A.SHORT[""]},ELECTRIC_POTENTIAL:{unit:F.V,prefix:A.SHORT[""]},ELECTRIC_RESISTANCE:{unit:F.ohm,prefix:A.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:F.H,prefix:A.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:F.S,prefix:A.SHORT[""]},MAGNETIC_FLUX:{unit:F.Wb,prefix:A.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:F.T,prefix:A.SHORT[""]},FREQUENCY:{unit:F.Hz,prefix:A.SHORT[""]}}};B.cgs=JSON.parse(JSON.stringify(B.si)),B.cgs.LENGTH={unit:F.m,prefix:A.SHORT.c},B.cgs.MASS={unit:F.g,prefix:A.SHORT[""]},B.cgs.FORCE={unit:F.dyn,prefix:A.SHORT[""]},B.cgs.ENERGY={unit:F.erg,prefix:A.NONE[""]},B.us=JSON.parse(JSON.stringify(B.si)),B.us.LENGTH={unit:F.ft,prefix:A.NONE[""]},B.us.MASS={unit:F.lbm,prefix:A.NONE[""]},B.us.TEMPERATURE={unit:F.degF,prefix:A.NONE[""]},B.us.FORCE={unit:F.lbf,prefix:A.NONE[""]},B.us.ENERGY={unit:F.BTU,prefix:A.BTU[""]},B.us.POWER={unit:F.hp,prefix:A.NONE[""]},B.us.PRESSURE={unit:F.psi,prefix:A.NONE[""]},B.auto=JSON.parse(JSON.stringify(B.si));var P=B.auto;for(var H in w.setUnitSystem=function(e){if(!EH(B,e))throw new Error("Unit system "+e+" does not exist. Choices are: "+Object.keys(B).join(", "));P=B[e]},w.getUnitSystem=function(){for(var e in B)if(EH(B,e)&&B[e]===P)return e},w.typeConverters={BigNumber:function(e){return new x(e+"")},Fraction:function(e){return new v(e)},Complex:function(e){return e},number:function(e){return e}},w._getNumberConverter=function(e){if(!w.typeConverters[e])throw new TypeError('Unsupported type "'+e+'"');return w.typeConverters[e]},F)if(EH(F,H)){var j=F[H];j.dimensions=j.base.dimensions}for(var U in Y)if(EH(Y,U)){var q=F[Y[U]],W={};for(var V in q)EH(q,V)&&(W[V]=q[V]);W.name=U,F[U]=W}return w.isValidAlpha=function(e){return/^[a-zA-Z]$/.test(e)},w.createUnit=function(e,t){if("object"!=typeof e)throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(t&&t.override)for(var n in e)if(EH(e,n)&&w.deleteUnit(n),e[n].aliases)for(var r=0;r0&&!w.isValidAlpha(r)&&!N(r))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+e+'"')}}(e);var a,i,s,o=null,u=[],l=0;if(t&&"Unit"===t.type)o=t.clone();else if("string"==typeof t)""!==t&&(a=t);else{if("object"!=typeof t)throw new TypeError('Cannot create unit "'+e+'" from "'+t.toString()+'": expecting "string" or "Unit" or "Object"');a=t.definition,i=t.prefixes,l=t.offset,s=t.baseName,t.aliases&&(u=t.aliases.valueOf())}if(u)for(var c=0;c1e-12){f=!1;break}if(f){d=!0,p.base=$[h];break}}if(!d){s=s||e+"_STUFF";var g={dimensions:o.dimensions.slice(0)};g.key=s,$[s]=g,P[s]={unit:p,prefix:A.NONE[""]},p.base=$[s]}}else{if(s=s||e+"_STUFF",L.indexOf(s)>=0)throw new Error('Cannot create new base unit "'+e+'": a base unit with that name already exists (and cannot be overridden)');for(var y in L.push(s),$)EH($,y)&&($[y].dimensions[L.length-1]=0);for(var b={dimensions:[]},x=0;x{var{typed:t,Unit:n}=e;return t(w0,{"Object, Object":function(e,t){return n.createUnit(e,t)},Object:function(e){return n.createUnit(e,{})},"string, Unit | string | Object, Object":function(e,t,r){var a={};return a[e]=t,n.createUnit(a,r)},"string, Unit | string | Object":function(e,t){var r={};return r[e]=t,n.createUnit(r,{})},string:function(e){var t={};return t[e]={},n.createUnit(t,{})}})})),N0="dotPow",S0=YH(N0,["typed","equalScalar","matrix","pow","DenseMatrix"],(e=>{var{typed:t,equalScalar:n,matrix:r,pow:a,DenseMatrix:i}=e,s=aJ({typed:t}),o=DJ({typed:t,DenseMatrix:i}),u=sJ({typed:t,equalScalar:n}),l=oJ({typed:t,DenseMatrix:i}),c=uJ({typed:t}),p=lJ({typed:t});return t(N0,{"any, any":a,"SparseMatrix, SparseMatrix":function(e,t){return o(e,t,a,!1)},"SparseMatrix, DenseMatrix":function(e,t){return s(t,e,a,!0)},"DenseMatrix, SparseMatrix":function(e,t){return s(e,t,a,!1)},"DenseMatrix, DenseMatrix":function(e,t){return c(e,t,a)},"Array, Array":function(e,t){return this(r(e),r(t)).valueOf()},"Array, Matrix":function(e,t){return this(r(e),t)},"Matrix, Array":function(e,t){return this(e,r(t))},"SparseMatrix, any":function(e,t){return u(e,t,this,!1)},"DenseMatrix, any":function(e,t){return p(e,t,this,!1)},"any, SparseMatrix":function(e,t){return l(t,e,this,!0)},"any, DenseMatrix":function(e,t){return p(t,e,this,!0)},"Array, any":function(e,t){return p(r(e),t,this,!1).valueOf()},"any, Array":function(e,t){return p(r(t),e,this,!0).valueOf()}})})),k0="expm",D0=YH(k0,["typed","abs","add","identity","inv","multiply"],(e=>{var{typed:t,abs:n,add:r,identity:a,inv:i,multiply:s}=e;return t(k0,{Matrix:function(e){var t=e.size();if(2!==t.length||t[0]!==t[1])throw new RangeError("Matrix must be square (size: "+KU(t)+")");for(var u=t[0],l=function(e){for(var t=e.size()[0],r=0,a=0;a1&&(y=s(y,h),b=-b),f=r(f,s(g=g*(p-x+1)/((2*p-x+1)*x),y)),m=r(m,s(g*b,y));for(var v=s(i(m),f),_=0;_{var{typed:t,config:n,multiplyScalar:r,pow:a,BigNumber:i,Complex:s}=e;return t(T0,{number:_G,Complex:function(e){if(0===e.im)return this(e.re);if(e.re<.5){var t=new s(1-e.re,-e.im),n=new s(Math.PI*e.re,Math.PI*e.im);return new s(Math.PI).div(n.sin()).div(this(t))}e=new s(e.re-1,e.im);for(var r=new s(MG[0],0),a=1;a2;)u+=a-=2,s=s.times(u);return new i(s.toPrecision(i.precision))}})),E0="setIntersect",C0=YH(E0,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:n,subset:r,compareNatural:a,Index:i,DenseMatrix:s}=e;return t(E0,{"Array | Matrix, Array | Matrix":function(e,t){var o;if(0===r(n(e),new i(0))||0===r(n(t),new i(0)))o=[];else{var u=_q(mq(Array.isArray(e)?e:e.toArray()).sort(a)),l=_q(mq(Array.isArray(t)?t:t.toArray()).sort(a));o=[];for(var c=0;c{var{typed:t,matrix:n,multiply:r,equalScalar:a,divideScalar:i,inv:s}=e,o=sJ({typed:t,equalScalar:a}),u=lJ({typed:t});return t("divide",NH({"Array | Matrix, Array | Matrix":function(e,t){return r(e,s(t))},"DenseMatrix, any":function(e,t){return u(e,t,i,!1)},"SparseMatrix, any":function(e,t){return o(e,t,i,!1)},"Array, any":function(e,t){return u(n(e),t,i,!1).valueOf()},"any, Array | Matrix":function(e,t){return r(e,s(t))}},i.signatures))})),L0="factorial",$0=YH(L0,["typed","gamma"],(e=>{var{typed:t,gamma:n}=e;return t(L0,{number:function(e){if(e<0)throw new Error("Value must be non-negative");return n(e+1)},BigNumber:function(e){if(e.isNegative())throw new Error("Value must be non-negative");return n(e.plus(1))},"Array | Matrix":function(e){return Gq(e,this)}})})),O0=YH("lup",["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtract","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],(e=>{var{typed:t,matrix:n,abs:r,addScalar:a,divideScalar:i,multiplyScalar:s,subtract:o,larger:u,equalScalar:l,unaryMinus:c,DenseMatrix:p,SparseMatrix:d,Spa:h}=e;return t("lup",{DenseMatrix:function(e){return f(e)},SparseMatrix:function(e){return function(e){var t,n,a,o=e._size[0],p=e._size[1],f=Math.min(o,p),m=e._values,g=e._index,y=e._ptr,b=[],x=[],v=[],_=[o,f],w=[],M=[],N=[],S=[f,p],k=[],D=[];for(t=0;t0&&e.forEach(0,n-1,(function(t,n){d._forEachRow(t,b,x,v,(function(r,a){r>t&&e.accumulate(r,c(s(a,n)))}))}));var T,I,E,C,A=n,L=e.get(n),$=r(L);e.forEach(n+1,o-1,(function(e,t){var n=r(t);u(n,$)&&(A=e,$=n,L=t)})),n!==A&&(d._swapRows(n,A,_[1],b,x,v),d._swapRows(n,A,S[1],w,M,N),e.swap(n,A),I=A,E=D[T=n],C=D[I],k[E]=I,k[C]=T,D[T]=C,D[I]=E),e.forEach(0,o-1,(function(e,t){e<=n?(w.push(t),M.push(e)):(t=i(t,L),l(t,0)||(b.push(t),x.push(e)))}))};for(n=0;n0)for(t=0;t{var{typed:t,add:n,divide:r,multiply:a,factorial:i,isInteger:s,isPositive:o}=e;return t(R0,{"Array | Matrix":function(e){var t=0,u=1;return Vq(e,(function(e){if(!s(e)||!o(e))throw new TypeError("Positive integer value expected in function multinomial");t=n(t,e),u=a(u,i(e))})),r(i(t),u)}})})),Y0="permutations",z0=YH(Y0,["typed","factorial"],(e=>{var{typed:t,factorial:n}=e;return t(Y0,{"number | BigNumber":n,"number, number":function(e,t){if(!jH(e)||e<0)throw new TypeError("Positive integer value expected in function permutations");if(!jH(t)||t<0)throw new TypeError("Positive integer value expected in function permutations");if(t>e)throw new TypeError("second argument k must be less than or equal to first argument n");return NV(e-t+1,e)},"BigNumber, BigNumber":function(e,t){var n,r;if(!B0(e)||!B0(t))throw new TypeError("Positive integer value expected in function permutations");if(t.gt(e))throw new TypeError("second argument k must be less than or equal to first argument n");for(n=e.mul(0).add(1),r=e.minus(t).plus(1);r.lte(e);r=r.plus(1))n=n.times(r);return n}})}));function B0(e){return e.isInteger()&&e.gte(0)}var P0="stirlingS2",H0=YH(P0,["typed","addScalar","subtract","multiplyScalar","divideScalar","pow","factorial","combinations","isNegative","isInteger","number","?bignumber","larger"],(e=>{var{typed:t,addScalar:n,subtract:r,multiplyScalar:a,divideScalar:i,pow:s,factorial:o,combinations:u,isNegative:l,isInteger:c,number:p,bignumber:d,larger:h}=e,f=[],m=[];return t(P0,{"number | BigNumber, number | BigNumber":function(e,t){if(!c(e)||l(e)||!c(t)||l(t))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(h(t,e))throw new TypeError("k must be less than or equal to n in function stirlingS2");var r=!(FP(e)&&FP(t)),i=r?m:f,s=r?d:p,o=p(e),u=p(t);if(i[o]&&i[o].length>u)return i[o][u];for(var g=0;g<=o;++g)if(i[g]||(i[g]=[s(0===g?1:0)]),0!==g)for(var y=i[g],b=i[g-1],x=y.length;x<=g&&x<=u;++x)y[x]=x===g?1:n(a(s(x),b[x]),b[x-1]);return i[o][u]}})})),j0="unit",U0=YH(j0,["typed","Unit"],(e=>{var{typed:t,Unit:n}=e;return t(j0,{Unit:function(e){return e.clone()},string:function(e){return n.isValuelessUnit(e)?new n(null,e):n.parse(e,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string":function(e,t){return new n(e,t)},"Array | Matrix":function(e){return Gq(e,this)}})})),q0="bellNumbers",W0=YH(q0,["typed","addScalar","isNegative","isInteger","stirlingS2"],(e=>{var{typed:t,addScalar:n,isNegative:r,isInteger:a,stirlingS2:i}=e;return t(q0,{"number | BigNumber":function(e){if(!a(e)||r(e))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var t=0,s=0;s<=e;s++)t=n(t,i(e,s));return t}})}));var V0=YH("eigs",["config","typed","matrix","addScalar","equal","subtract","abs","atan","cos","sin","multiplyScalar","divideScalar","inv","bignumber","multiply","add","larger","column","flatten","number","complex","sqrt","diag","qr","usolve","usolveAll","im","re","smaller","matrixFromColumns","dot"],(e=>{var{config:t,typed:n,matrix:r,addScalar:a,subtract:i,equal:s,abs:o,atan:u,cos:l,sin:c,multiplyScalar:p,divideScalar:d,inv:h,bignumber:f,multiply:m,add:g,larger:y,column:b,flatten:x,number:v,complex:_,sqrt:w,diag:M,qr:N,usolve:S,usolveAll:k,im:D,re:T,smaller:I,matrixFromColumns:E,dot:C}=e,A=function(e){var{config:t,addScalar:n,subtract:r,abs:a,atan:i,cos:s,sin:o,multiplyScalar:u,inv:l,bignumber:c,multiply:p,add:d}=e;function h(e,n){for(var r,a=e.length,i=Math.abs(n/a),s=new Array(a),o=0;o=Math.abs(i);){var l=u[0][0],c=u[0][1];e=b(e,(p=e[l][l],d=e[c][c],h=e[l][c],f=void 0,f=d-p,r=Math.abs(f)<=t.epsilon?Math.PI/4:.5*Math.atan(2*h/(d-p))),l,c),s=m(s,r,l,c),u=x(e)}for(var p,d,h,f,g=w(a,0),y=0;y=a(d);){var b=m[0][0],x=m[0][1];e=y(e,(M=e[b][b],N=e[x][x],S=e[b][x],k=void 0,k=r(N,M),s=a(k)<=t.epsilon?c(-1).acos().div(4):u(.5,i(p(2,S,l(k))))),b,x),h=g(h,s,b,x),m=v(e)}for(var M,N,S,k,D=w(o,0),T=0;T2&&void 0!==arguments[2]?arguments[2]:t.epsilon,a=arguments.length>3?arguments[3]:void 0;if("number"===a)return h(e,r);if("BigNumber"===a)return f(e,r);throw TypeError("Unsupported data type: "+a)}}({config:t,addScalar:a,subtract:i,column:b,flatten:x,equal:s,abs:o,atan:u,cos:l,sin:c,multiplyScalar:p,inv:h,bignumber:f,complex:_,multiply:m,add:g}),L=function(e){var{addScalar:t,subtract:n,flatten:r,multiply:a,multiplyScalar:i,divideScalar:s,sqrt:o,abs:u,bignumber:l,diag:c,inv:p,qr:d,usolve:h,usolveAll:f,equal:m,complex:g,larger:y,smaller:b,matrixFromColumns:x,dot:v}=e;function _(e,t,r,a,i,s,o,c){var p="BigNumber"===c,d="Complex"===c,h=p?l(0):d?g(0):0,f=p?l(1):d?g(1):1;if(b(u(r),o))return[[f,h],[h,f]];if(y(u(n(i,s)),o))return[[n(i,a),n(s,a)],[r,r]];var m=n(e,i),x=n(t,i),v=n(r,i),_=n(a,i);return b(u(x),o)?[[m,f],[v,h]]:[[x,h],[_,f]]}function w(e,t){for(var n=0;n=5)return null;for(o=0;;){var u=h(e,i);if(b(D(k(i,[u])),r))break;if(++o>=10)return null;i=T(u)}return i}function S(e,t,n){var r="BigNumber"===n,a="Complex"===n,i=Array(e).fill(0).map((e=>2*Math.random()-1));return r&&(i=i.map((e=>l(e)))),a&&(i=i.map((e=>g(e)))),T(i=k(i,t),n)}function k(e,t){for(var r of t)e=n(e,a(s(v(r,e),v(r,r)),r));return e}function D(e){return u(o(v(e,e)))}function T(e,t){var n="Complex"===t,r="BigNumber"===t?l(1):n?g(1):1;return a(s(r,D(e)),e)}return function(e,h,v,S,k){void 0===k&&(k=!0);var D=function(e,n,r,a,o){var p,d="BigNumber"===a,h="Complex"===a,f=d?l(0):0,x=d?l(1):h?g(1):1,v=d?l(1):1,_=d?l(10):2,w=i(_,_);o&&(p=Array(n).fill(x));for(var M=!1;!M;){M=!0;for(var N=0;N1&&($=c(Array(C-1).fill(y)))),C-=1,I.pop();for(var B=0;B2&&($=c(Array(C-2).fill(y)))),C-=2,I.pop(),I.pop();for(var H=0;H+n(u(e),u(t)))),O>100){var j=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+E.join(", "));throw j.values=E,j.vectors=[],j}var U=h?a(L,function(e,t){for(var n=[],r=0;ra(m,e))),T.push(...c.map((e=>r(e))))},$=0;${var{typed:t,add:n,divide:r}=e;return t(G0,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,t){try{var a=Kq(e,t,n),i=Array.isArray(e)?nq(e):e.size();return r(a,i[t])}catch(e){throw vJ(e,"mean")}},"...":function(e){if(Wq(e))throw new TypeError("Scalar values expected in function mean");return a(e)}});function a(e){var t,a=0;if(Vq(e,(function(e){try{t=void 0===t?e:n(t,e),a++}catch(t){throw vJ(t,"mean",e)}})),0===a)throw new Error("Cannot calculate the mean of an empty array");return r(t,a)}})),J0="setSymDifference",X0=YH(J0,["typed","size","concat","subset","setDifference","Index"],(e=>{var{typed:t,size:n,concat:r,subset:a,setDifference:i,Index:s}=e;return t(J0,{"Array | Matrix, Array | Matrix":function(e,t){if(0===a(n(e),new s(0)))return mq(t);if(0===a(n(t),new s(0)))return mq(e);var o=mq(e),u=mq(t);return r(i(o,u),i(u,o))}})}));function Z0(e,t){var n,r=t.length,a=[];if(e)for(n=0;n{var{typed:t,matrix:n,lup:r,slu:a,usolve:i,lsolve:s,DenseMatrix:o}=e,u=YX({DenseMatrix:o});return t(Q0,{"Array, Array | Matrix":function(e,t){e=n(e);var a=r(e);return c(a.L,a.U,a.p,null,t).valueOf()},"DenseMatrix, Array | Matrix":function(e,t){var n=r(e);return c(n.L,n.U,n.p,null,t)},"SparseMatrix, Array | Matrix":function(e,t){var n=r(e);return c(n.L,n.U,n.p,null,t)},"SparseMatrix, Array | Matrix, number, number":function(e,t,n,r){var i=a(e,n,r);return c(i.L,i.U,i.p,i.q,t)},"Object, Array | Matrix":function(e,t){return c(e.L,e.U,e.p,e.q,t)}});function l(e){if(UP(e))return e;if(jP(e))return n(e);throw new TypeError("Invalid Matrix LU decomposition")}function c(e,t,n,r,a){e=l(e),t=l(t),n&&((a=u(e,a,!0))._data=Z0(n,a._data));var o=s(e,a),c=i(t,o);return r&&(c._data=Z0(r,c._data)),c}})),n1="median",r1=["typed","add","divide","compare","partitionSelect"],a1=YH(n1,r1,(e=>{var{typed:t,add:n,divide:r,compare:a,partitionSelect:i}=e;function s(e){try{var t=(e=mq(e.valueOf())).length;if(0===t)throw new Error("Cannot calculate median of an empty array");if(t%2==0){for(var n=t/2-1,r=i(e,n+1),s=e[n],l=0;l0&&(s=e[l]);return u(s,r)}var c=i(e,(t-1)/2);return o(c)}catch(e){throw vJ(e,"median")}}var o=t({"number | BigNumber | Complex | Unit":function(e){return e}}),u=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(e,t){return r(n(e,t),2)}});return t(n1,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("median(A, dim) is not yet supported")},"...":function(e){if(Wq(e))throw new TypeError("Scalar values expected in function median");return s(e)}})})),i1="setUnion",s1=["typed","size","concat","subset","setIntersect","setSymDifference","Index"],o1=YH(i1,s1,(e=>{var{typed:t,size:n,concat:r,subset:a,setIntersect:i,setSymDifference:s,Index:o}=e;return t(i1,{"Array | Matrix, Array | Matrix":function(e,t){if(0===a(n(e),new o(0)))return mq(t);if(0===a(n(t),new o(0)))return mq(e);var u=mq(e),l=mq(t);return r(s(u,l),i(u,l))}})})),u1="unbiased",l1="variance",c1=["typed","add","subtract","multiply","divide","apply","isNaN"],p1=YH(l1,c1,(e=>{var{typed:t,add:n,subtract:r,multiply:a,divide:i,apply:s,isNaN:o}=e;return t(l1,{"Array | Matrix":function(e){return u(e,u1)},"Array | Matrix, string":u,"Array | Matrix, number | BigNumber":function(e,t){return l(e,t,u1)},"Array | Matrix, number | BigNumber, string":l,"...":function(e){return u(e,u1)}});function u(e,t){var s,u=0;if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(Vq(e,(function(e){try{s=void 0===s?e:n(s,e),u++}catch(t){throw vJ(t,"variance",e)}})),0===u)throw new Error("Cannot calculate variance of an empty array");var l=i(s,u);if(s=void 0,Vq(e,(function(e){var t=r(e,l);s=void 0===s?a(t,t):n(s,a(t,t))})),o(s))return s;switch(t){case"uncorrected":return i(s,u);case"biased":return i(s,u+1);case"unbiased":var c=YP(s)?s.mul(0):0;return 1===u?c:i(s,u-1);default:throw new Error('Unknown normalization "'+t+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function l(e,t,n){try{if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return s(e,t,(e=>u(e,n)))}catch(e){throw vJ(e,"variance")}}})),d1="kldivergence",h1=["typed","matrix","divide","sum","multiply","dotDivide","log","isNumeric"],f1=YH(d1,h1,(e=>{var{typed:t,matrix:n,divide:r,sum:a,multiply:i,dotDivide:s,log:o,isNumeric:u}=e;return t(d1,{"Array, Array":function(e,t){return l(n(e),n(t))},"Matrix, Array":function(e,t){return l(e,n(t))},"Array, Matrix":function(e,t){return l(n(e),t)},"Matrix, Matrix":function(e,t){return l(e,t)}});function l(e,t){var n=t.size().length,l=e.size().length;if(n>1)throw new Error("first object must be one dimensional");if(l>1)throw new Error("second object must be one dimensional");if(n!==l)throw new Error("Length of two vectors must be equal");if(0===a(e))throw new Error("Sum of elements in first object must be non zero");if(0===a(t))throw new Error("Sum of elements in second object must be non zero");var c=r(e,a(e)),p=r(t,a(t)),d=a(i(c,o(s(c,p))));return u(d)?d:Number.NaN}})),m1="norm",g1=["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],y1=YH(m1,g1,(e=>{var{typed:t,abs:n,add:r,pow:a,conj:i,sqrt:s,multiply:o,equalScalar:u,larger:l,smaller:c,matrix:p,ctranspose:d,eigs:h}=e;return t(m1,{number:Math.abs,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},boolean:function(e){return Math.abs(e)},Array:function(e){return f(p(e),2)},Matrix:function(e){return f(e,2)},"number | Complex | BigNumber | boolean, number | BigNumber | string":function(e){return this(e)},"Array, number | BigNumber | string":function(e,t){return f(p(e),t)},"Matrix, number | BigNumber | string":function(e,t){return f(e,t)}});function f(e,t){var p=e.size();if(1===p.length)return function(e,t){if(t===Number.POSITIVE_INFINITY||"inf"===t)return function(e){var t=0;return e.forEach((function(e){var r=n(e);l(r,t)&&(t=r)}),!0),t}(e);if(t===Number.NEGATIVE_INFINITY||"-inf"===t)return function(e){var t;return e.forEach((function(e){var r=n(e);t&&!c(r,t)||(t=r)}),!0),t||0}(e);if("fro"===t)return f(e,2);if("number"==typeof t&&!isNaN(t)){if(!u(t,0)){var i=0;return e.forEach((function(e){i=r(a(n(e),t),i)}),!0),a(i,1/t)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}(e,t);if(2===p.length){if(p[0]&&p[1])return function(e,t){if(1===t)return function(e){var t=[],a=0;return e.forEach((function(e,i){var s=i[1],o=r(t[s]||0,n(e));l(o,a)&&(a=o),t[s]=o}),!0),a}(e);if(t===Number.POSITIVE_INFINITY||"inf"===t)return function(e){var t=[],a=0;return e.forEach((function(e,i){var s=i[0],o=r(t[s]||0,n(e));l(o,a)&&(a=o),t[s]=o}),!0),a}(e);if("fro"===t)return function(e){var t=0;return e.forEach((function(e,n){t=r(t,o(e,i(e)))})),n(s(t))}(e);if(2===t)return function(e){var t=e.size();if(t[0]!==t[1])throw new RangeError("Invalid matrix dimensions");var r=d(e),a=o(r,e),i=h(a).values.toArray(),u=i[i.length-1];return n(s(u))}(e);throw new Error("Unsupported parameter value "+t)}(e,t);throw new RangeError("Invalid matrix dimensions")}}})),b1="rotationMatrix",x1=["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],v1=YH(b1,x1,(e=>{var{typed:t,config:n,multiplyScalar:r,addScalar:a,unaryMinus:i,norm:s,BigNumber:o,matrix:u,DenseMatrix:l,SparseMatrix:c,cos:p,sin:d}=e;return t(b1,{"":function(){return"Matrix"===n.matrix?u([]):[]},string:function(e){return u(e)},"number | BigNumber | Complex | Unit":function(e){return h(e,"Matrix"===n.matrix?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(e,t){return h(e,t)},"number | BigNumber | Complex | Unit, Array":function(e,t){var n=u(t);return f(n),y(e,n,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(e,t){f(t);var r=t.storage()||("Matrix"===n.matrix?"dense":void 0);return y(e,t,r)},"number | BigNumber | Complex | Unit, Array, string":function(e,t,n){var r=u(t);return f(r),y(e,r,n)},"number | BigNumber | Complex | Unit, Matrix, string":function(e,t,n){return f(t),y(e,t,n)}});function h(e,t){var n=YP(e)?new o(-1):-1,a=p(e),i=d(e);return g([[a,r(n,i)],[i,a]],t)}function f(e){var t=e.size();if(t.length<1||3!==t[0])throw new RangeError("Vector must be of dimensions 1x3")}function m(e){return e.reduce(((e,t)=>r(e,t)))}function g(e,t){if(t){if("sparse"===t)return new c(e);if("dense"===t)return new l(e);throw new TypeError('Unknown matrix type "'.concat(t,'"'))}return e}function y(e,t,n){var r=s(t);if(0===r)throw new RangeError("Rotation around zero vector");var u=YP(e)?o:null,l=u?new u(1):1,c=u?new u(-1):-1,h=u?new u(t.get([0])/r):t.get([0])/r,f=u?new u(t.get([1])/r):t.get([1])/r,y=u?new u(t.get([2])/r):t.get([2])/r,b=p(e),x=a(l,i(b)),v=d(e);return g([[a(b,m([h,h,x])),a(m([h,f,x]),m([c,y,v])),a(m([h,y,x]),m([f,v]))],[a(m([h,f,x]),m([y,v])),a(b,m([f,f,x])),a(m([f,y,x]),m([c,h,v]))],[a(m([h,y,x]),m([c,f,v])),a(m([f,y,x]),m([h,v])),a(b,m([y,y,x]))]],n)}})),_1=["typed","sqrt","variance"],w1=YH("std",_1,(e=>{var{typed:t,sqrt:n,variance:r}=e;return t("std",{"Array | Matrix":a,"Array | Matrix, string":a,"Array | Matrix, number | BigNumber":a,"Array | Matrix, number | BigNumber, string":a,"...":function(e){return a(e)}});function a(e,t){if(0===e.length)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{return n(r.apply(null,arguments))}catch(e){throw e instanceof TypeError&&-1!==e.message.indexOf(" variance")?new TypeError(e.message.replace(" variance"," std")):e}}})),M1=["typed","abs","map","median","subtract"],N1=YH("mad",M1,(e=>{var{typed:t,abs:n,map:r,median:a,subtract:i}=e;return t("mad",{"Array | Matrix":s,"...":function(e){return s(e)}});function s(e){if(0===(e=mq(e.valueOf())).length)throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");try{var t=a(e);return a(r(e,(function(e){return n(i(e,t))})))}catch(e){throw e instanceof TypeError&&-1!==e.message.indexOf("median")?new TypeError(e.message.replace("median","mad")):vJ(e,"mad")}}})),S1="rotate",k1=["typed","multiply","rotationMatrix"],D1=YH(S1,k1,(e=>{var{typed:t,multiply:n,rotationMatrix:r}=e;return t(S1,{"Array , number | BigNumber | Complex | Unit":function(e,t){return a(e,2),n(r(t),e).toArray()},"Matrix , number | BigNumber | Complex | Unit":function(e,t){return a(e,2),n(r(t),e)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,i){return a(e,3),n(r(t,i),e)},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,i){return a(e,3),n(r(t,i),e)}});function a(e,t){var n=Array.isArray(e)?nq(e):e.size();if(n.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(t));if(2===n.length&&1!==n[1])throw new RangeError("Vector must be of dimensions 1x".concat(t));if(n[0]!==t)throw new RangeError("Vector must be of dimensions 1x".concat(t))}})),T1=PH({config:RH}),I1=pj({}),E1=Ej({BigNumber:T1,config:RH}),C1=Nj({}),A1=uU({BigNumber:T1,config:RH}),L1=HU({}),$1=Yj({Complex:I1}),O1=kj({BigNumber:T1,config:RH}),R1=Lj({BigNumber:T1,config:RH}),F1=Oj({BigNumber:T1,config:RH}),Y1=jU({}),z1=Dj({BigNumber:T1,config:RH}),B1=Sj({}),P1=Cj({BigNumber:T1,config:RH}),H1=UU({}),j1=qU({}),U1=Rj({BigNumber:T1,config:RH}),q1=DU({BigNumber:T1,config:RH}),W1=Ij({BigNumber:T1,config:RH}),V1=Mj({}),G1=Pj({}),K1=Sq({Matrix:Y1}),J1=yU({BigNumber:T1,config:RH}),X1=Aj({BigNumber:T1,config:RH}),Z1=Tj({BigNumber:T1,config:RH}),Q1=kq({}),e2=Fj({BigNumber:T1,config:RH}),t2=Pq({BigNumber:T1,Complex:I1,DenseMatrix:K1,Fraction:L1}),n2=_W({BigNumber:T1,config:RH,typed:t2}),r2=gU({BigNumber:T1,config:RH}),a2=wW({typed:t2}),i2=NW({Complex:I1,config:RH,typed:t2}),s2=jW({BigNumber:T1,typed:t2}),o2=qW({BigNumber:T1,Complex:I1,config:RH,typed:t2}),u2=VW({typed:t2}),l2=GW({typed:t2}),c2=JW({BigNumber:T1,Complex:I1,config:RH,typed:t2}),p2=XW({typed:t2}),d2=ZW({typed:t2}),h2=eV({Complex:I1,config:RH,typed:t2}),f2=tV({BigNumber:T1,typed:t2}),m2=xV({typed:t2}),g2=_V({typed:t2}),y2=MV({typed:t2}),b2=DV({typed:t2}),x2=IV({Complex:I1,typed:t2}),v2=CV({typed:t2}),_2=LV({typed:t2}),w2=OV({BigNumber:T1,typed:t2}),M2=RV({BigNumber:T1,typed:t2}),N2=YV({typed:t2}),S2=PV({config:RH,typed:t2}),k2=HV({typed:t2}),D2=GV({typed:t2}),T2=JV({Complex:I1,typed:t2}),I2=XV({typed:t2}),E2=eG({typed:t2}),C2=rG({typed:t2}),A2=iG({typed:t2}),L2=sG({format:C2,typed:t2}),$2=oG({typed:t2}),O2=lG({typed:t2}),R2=gG({typed:t2}),F2=bG({typed:t2}),Y2=vG({typed:t2}),z2=$j({BigNumber:T1,config:RH}),B2=TG({Complex:I1,typed:t2}),P2=EG({Complex:I1,config:RH,typed:t2}),H2=AG({Complex:I1,config:RH,typed:t2}),j2=LG({typed:t2}),U2=OG({typed:t2}),q2=PG({typed:t2}),W2=HG({typed:t2}),V2=jG({format:C2,typed:t2}),G2=VG({config:RH,typed:t2}),K2=KG({typed:t2}),J2=QG({config:RH,typed:t2}),X2=eK({typed:t2}),Z2=tK({BigNumber:T1,typed:t2}),Q2=rK({BigNumber:T1,Fraction:L1,complex:x2,typed:t2}),e3=aK({typed:t2}),t3=iK({Matrix:Y1,equalScalar:S2,typed:t2}),n3=oK({typed:t2}),r3=lK({typed:t2}),a3=pK({typed:t2}),i3=dK({typed:t2}),s3=fK({typed:t2}),o3=gK({Complex:I1,config:RH,typed:t2}),u3=bK({BigNumber:T1,typed:t2}),l3=vK({isInteger:O2,typed:t2}),c3=MK({BigNumber:T1,Complex:I1,config:RH,typed:t2}),p3=NK({format:C2,typed:t2}),d3=kK({typed:t2}),h3=TK({typed:t2}),f3=EK({BigNumber:T1,typed:t2}),m3=AK({typed:t2}),g3=$K({typed:t2}),y3=RK({config:RH,typed:t2}),b3=YK({BigNumber:T1,typed:t2}),x3=BK({typed:t2}),v3=HK({SparseMatrix:t3,typed:t2}),_3=jK({Complex:I1,config:RH,typed:t2}),w3=UK({typed:t2}),M3=WK({typed:t2}),N3=GK({BigNumber:T1,Complex:I1,config:RH,typed:t2}),S3=KK({BigNumber:T1,typed:t2}),k3=JK({Fraction:L1,typed:t2}),D3=ZK({typed:t2}),T3=eJ({DenseMatrix:K1,Matrix:Y1,SparseMatrix:t3,typed:t2}),I3=nJ({isZero:Y2,matrix:T3,typed:t2}),E3=cJ({DenseMatrix:K1,equalScalar:S2,matrix:T3,typed:t2}),C3=fJ({BigNumber:T1,equalScalar:S2,matrix:T3,typed:t2}),A3=bJ({bignumber:f2,fraction:k3,number:W2}),L3=xJ({DenseMatrix:K1,equalScalar:S2,matrix:T3,typed:t2}),$3=wJ({config:RH,multiplyScalar:U2,numeric:A3,typed:t2}),O3=NJ({isInteger:O2,matrix:T3,typed:t2}),R3=kJ({matrix:T3,config:RH,typed:t2}),F3=IJ({DenseMatrix:K1,config:RH,matrix:T3,typed:t2}),Y3=CJ({matrix:T3,typed:t2}),z3=LJ({matrix:T3,typed:t2}),B3=BJ({DenseMatrix:K1,addScalar:u2,equalScalar:S2,matrix:T3,typed:t2,unaryMinus:M3}),P3=HJ({matrix:T3,typed:t2}),H3=jJ({matrix:T3,typed:t2}),j3=qJ({BigNumber:T1,config:RH,matrix:T3,typed:t2}),U3=VJ({BigNumber:T1,config:RH,matrix:T3,typed:t2}),q3=GJ({equalScalar:S2,matrix:T3,not:q2,typed:t2,zeros:U3}),W3=JJ({equalScalar:S2,matrix:T3,typed:t2}),V3=ZJ({DenseMatrix:K1,matrix:T3,typed:t2}),G3=eX({BigNumber:T1,Complex:I1,Fraction:L1,config:RH,isNegative:R2,matrix:T3,typed:t2,unaryMinus:M3}),K3=nX({BigNumber:T1,DenseMatrix:K1,Fraction:L1,config:RH,equalScalar:S2,matrix:T3,typed:t2}),J3=aX({matrix:T3,typed:t2}),X3=sX({isInteger:O2,matrix:T3,typed:t2}),Z3=lX({prod:$3,size:R3,typed:t2}),Q3=pX({conj:v2,transpose:H3,typed:t2}),e4=hX({DenseMatrix:K1,SparseMatrix:t3,matrix:T3,typed:t2}),t4=mX({numeric:A3,typed:t2}),n4=yX({DenseMatrix:K1,divideScalar:t4,equalScalar:S2,matrix:T3,typed:t2}),r4=xX({DenseMatrix:K1,equalScalar:S2,matrix:T3,typed:t2}),a4=vX({addScalar:u2,divideScalar:t4,exp:D2,i:$1,matrix:T3,multiplyScalar:U2,tau:W1,typed:t2}),i4=wX({matrix:T3,typed:t2}),s4=NX({BigNumber:T1,DenseMatrix:K1,equalScalar:S2,matrix:T3,typed:t2}),o4=kX({isNumeric:D3,typed:t2}),u4=TX({abs:a2,addScalar:u2,divideScalar:t4,isPositive:F2,multiplyScalar:U2,smaller:F3,sqrt:_3,typed:t2}),l4=EX({conj:v2,dotDivide:n4,fft:a4,typed:t2}),c4=AX({matrix:T3,multiplyScalar:U2,typed:t2}),p4=$X({DenseMatrix:K1,config:RH,matrix:T3,typed:t2}),d4=FX({DenseMatrix:K1,equalScalar:S2,matrix:T3,typed:t2,zeros:U3}),h4=BX({DenseMatrix:K1,divideScalar:t4,equalScalar:S2,matrix:T3,multiplyScalar:U2,subtract:B3,typed:t2}),f4=HX({flatten:i4,matrix:T3,size:R3,typed:t2}),m4=jX({config:RH,numeric:A3,smaller:F3,typed:t2}),g4=qX({isNaN:m3,isNumeric:D3,typed:t2}),y4=VX({Complex:I1,config:RH,divideScalar:t4,typed:t2}),b4=GX({BigNumber:T1,config:RH,matrix:T3,typed:t2}),x4=JX({compare:K3,isNaN:m3,isNumeric:D3,typed:t2}),v4=ZX({config:RH,matrix:T3}),_4=eZ({DenseMatrix:K1,equalScalar:S2,matrix:T3,typed:t2,zeros:U3}),w4=rZ({BigNumber:T1,DenseMatrix:K1,equalScalar:S2,matrix:T3,typed:t2,zeros:U3}),M4=iZ({DenseMatrix:K1,config:RH,matrix:T3,typed:t2}),N4=oZ({DenseMatrix:K1,config:RH,equalScalar:S2,matrix:T3,typed:t2}),S4=lZ({DenseMatrix:K1,divideScalar:t4,equalScalar:S2,matrix:T3,multiplyScalar:U2,subtract:B3,typed:t2}),k4=cZ({DenseMatrix:K1,matrix:T3,typed:t2}),D4=pZ({DenseMatrix:K1,SparseMatrix:t3,addScalar:u2,equalScalar:S2,matrix:T3,typed:t2}),T4=fZ({BigNumber:T1,DenseMatrix:K1,equalScalar:S2,matrix:T3,typed:t2}),I4=gZ({DenseMatrix:K1,equalScalar:S2,matrix:T3,typed:t2}),E4=bZ({addScalar:u2,combinations:b2,divideScalar:t4,isInteger:O2,isNegative:R2,multiplyScalar:U2,typed:t2}),C4=_Z({compare:K3,typed:t2}),A4=MZ({add:D4,typed:t2,unaryPlus:n2}),L4=SZ({equal:r4,typed:t2}),$4=DZ({matrix:T3,number:W2,subtract:B3,typed:t2}),O4=TZ({addScalar:u2,conj:v2,multiplyScalar:U2,size:R3,typed:t2}),R4=EZ({compareText:J3,isZero:Y2,typed:t2}),F4=$Z({DenseMatrix:K1,config:RH,equalScalar:S2,matrix:T3,round:w4,typed:t2,zeros:U3}),Y4=RZ({BigNumber:T1,DenseMatrix:K1,SparseMatrix:t3,config:RH,matrix:T3,typed:t2}),z4=YZ({BigNumber:T1,add:D4,config:RH,equal:r4,isInteger:O2,mod:E3,smaller:F3,typed:t2,xgcd:j3}),B4=BZ({DenseMatrix:K1,config:RH,matrix:T3,typed:t2}),P4=PZ({Complex:I1,config:RH,divideScalar:t4,typed:t2}),H4=jZ({DenseMatrix:K1,divideScalar:t4,equalScalar:S2,matrix:T3,multiplyScalar:U2,subtract:B3,typed:t2}),j4=qZ({flatten:i4,matrix:T3,size:R3,typed:t2}),U4=VZ({addScalar:u2,dot:O4,equalScalar:S2,matrix:T3,multiplyScalar:U2,typed:t2}),q4=GZ({addScalar:u2,complex:x2,conj:v2,divideScalar:t4,equal:r4,identity:Y4,isZero:Y2,matrix:T3,multiplyScalar:U2,sign:Q2,sqrt:_3,subtract:B3,typed:t2,unaryMinus:M3,zeros:U3}),W4=JZ({bignumber:f2,matrix:T3,config:RH,larger:B4,largerEq:p4,smaller:F3,smallerEq:M4,typed:t2}),V4=ZZ({DenseMatrix:K1,equalScalar:S2,matrix:T3,typed:t2,zeros:U3}),G4=eQ({compareNatural:C4,typed:t2}),K4=hQ({SparseMatrix:t3,abs:a2,add:D4,divideScalar:t4,larger:B4,largerEq:p4,multiply:U4,subtract:B3,transpose:H3,typed:t2}),J4=fQ({add:D4,config:RH,numeric:A3,typed:t2}),X4=mQ({add:D4,matrix:T3,typed:t2}),Z4=yQ({DenseMatrix:K1,divideScalar:t4,equalScalar:S2,matrix:T3,multiplyScalar:U2,subtract:B3,typed:t2}),Q4=xQ({Complex:I1,config:RH,typed:t2}),e5=MQ({DenseMatrix:K1,config:RH,equalScalar:S2,matrix:T3,round:w4,typed:t2,zeros:U3}),t5=SQ({addScalar:u2,combinations:b2,isInteger:O2,isNegative:R2,isPositive:F2,larger:B4,typed:t2}),n5=DQ({matrix:T3,multiply:U4,subtract:B3,typed:t2}),r5=TQ({divideScalar:t4,isZero:Y2,matrix:T3,multiply:U4,subtract:B3,typed:t2,unaryMinus:M3}),a5=EQ({abs:a2,addScalar:u2,divideScalar:t4,multiplyScalar:U2,sqrt:_3,subtract:B3,typed:t2,unaryMinus:M3}),i5=AQ({equalScalar:S2,matrix:T3,multiplyScalar:U2,typed:t2}),s5=LQ({larger:B4,smaller:F3}),o5=FQ({Complex:I1,DenseMatrix:K1,ceil:e5,equalScalar:S2,floor:F4,matrix:T3,typed:t2,zeros:U3}),u5=YQ({DenseMatrix:K1,smaller:F3}),l5=zQ({ImmutableDenseMatrix:u5}),c5=BQ({abs:a2,add:D4,addScalar:u2,config:RH,divideScalar:t4,equalScalar:S2,flatten:i4,isNumeric:D3,isZero:Y2,matrix:T3,multiply:U4,multiplyScalar:U2,smaller:F3,subtract:B3,typed:t2}),d5=PQ({equalScalar:S2,matrix:T3,typed:t2}),h5=jQ({Complex:I1,config:RH,divideScalar:t4,log:P4,typed:t2}),f5=UQ({config:RH,larger:B4,numeric:A3,typed:t2}),m5=qQ({add:D4,compare:K3,multiply:U4,partitionSelect:x4,typed:t2}),g5=WQ({Index:l5,matrix:T3,range:W4,typed:t2}),y5=GQ({DenseMatrix:K1,Index:l5,compareNatural:C4,size:R3,subset:z3,typed:t2}),b5=JQ({DenseMatrix:K1,Index:l5,compareNatural:C4,size:R3,subset:z3,typed:t2}),x5=ZQ({Index:l5,compareNatural:C4,size:R3,subset:z3,typed:t2}),v5=e0({Index:l5,compareNatural:C4,size:R3,subset:z3,typed:t2}),_5=n0({compare:K3,compareNatural:C4,matrix:T3,typed:t2}),w5=a0({Index:l5,matrix:T3,range:W4,typed:t2}),M5=s0({Index:l5,typed:t2}),N5=o0({abs:a2,addScalar:u2,det:r5,divideScalar:t4,identity:Y4,matrix:T3,multiply:U4,typed:t2,unaryMinus:M3}),S5=l0({Complex:I1,add:D4,ctranspose:Q3,deepEqual:L4,divideScalar:t4,dot:O4,dotDivide:n4,equal:r4,inv:N5,matrix:T3,multiply:U4,typed:t2}),k5=c0({Complex:I1,config:RH,fraction:k3,identity:Y4,inv:N5,matrix:T3,multiply:U4,number:W2,typed:t2}),D5=d0({DenseMatrix:K1,Index:l5,compareNatural:C4,size:R3,subset:z3,typed:t2}),T5=f0({Index:l5,compareNatural:C4,size:R3,subset:z3,typed:t2}),I5=m0({FibonacciHeap:s5,addScalar:u2,equalScalar:S2}),E5=y0({abs:a2,add:D4,identity:Y4,inv:N5,max:f5,multiply:U4,size:R3,sqrt:_3,subtract:B3,typed:t2}),C5=_0({BigNumber:T1,Complex:I1,Fraction:L1,abs:a2,addScalar:u2,config:RH,divideScalar:t4,equal:r4,fix:o5,format:C2,isNumeric:D3,multiplyScalar:U2,number:W2,pow:k5,round:w4,subtract:B3}),A5=Kj({BigNumber:T1,Unit:C5,config:RH}),L5=EU({BigNumber:T1,Unit:C5,config:RH}),$5=bU({BigNumber:T1,Unit:C5,config:RH}),O5=Zj({BigNumber:T1,Unit:C5,config:RH}),R5=vU({BigNumber:T1,Unit:C5,config:RH}),F5=Qj({BigNumber:T1,Unit:C5,config:RH}),Y5=M0({Unit:C5,typed:t2}),z5=pU({BigNumber:T1,Unit:C5,config:RH}),B5=S0({DenseMatrix:K1,equalScalar:S2,matrix:T3,pow:k5,typed:t2}),P5=Gj({BigNumber:T1,Unit:C5,config:RH}),H5=Xj({BigNumber:T1,Unit:C5,config:RH}),j5=D0({abs:a2,add:D4,identity:Y4,inv:N5,multiply:U4,typed:t2}),U5=_U({BigNumber:T1,Unit:C5,config:RH}),q5=wU({BigNumber:T1,Unit:C5,config:RH}),W5=I0({BigNumber:T1,Complex:I1,config:RH,multiplyScalar:U2,pow:k5,typed:t2}),V5=Uj({BigNumber:T1,Unit:C5,config:RH}),G5=lU({BigNumber:T1,Unit:C5,config:RH}),K5=rU({BigNumber:T1,Unit:C5,config:RH}),J5=MU({BigNumber:T1,Unit:C5,config:RH}),X5=Vj({BigNumber:T1,Unit:C5,config:RH}),Z5=CU({BigNumber:T1,Unit:C5,config:RH}),Q5=SU({BigNumber:T1,Unit:C5,config:RH}),e6=dU({BigNumber:T1,Unit:C5,config:RH}),t6=nU({BigNumber:T1,Unit:C5,config:RH}),n6=FU({BigNumber:T1,Unit:C5,config:RH}),r6=$U({BigNumber:T1,Unit:C5,config:RH}),a6=YU({BigNumber:T1,Unit:C5,config:RH}),i6=cU({BigNumber:T1,Unit:C5,config:RH}),s6=Wj({BigNumber:T1,Unit:C5,config:RH}),o6=fU({BigNumber:T1,Unit:C5,config:RH}),u6=C0({DenseMatrix:K1,Index:l5,compareNatural:C4,size:R3,subset:z3,typed:t2}),l6=jj({BigNumber:T1,Unit:C5,config:RH}),c6=IU({BigNumber:T1,Unit:C5,config:RH}),p6=mU({BigNumber:T1,Unit:C5,config:RH}),d6=xU({BigNumber:T1,Unit:C5,config:RH}),h6=aU({BigNumber:T1,Unit:C5,config:RH}),f6=Jj({BigNumber:T1,Unit:C5,config:RH}),m6=A0({divideScalar:t4,equalScalar:S2,inv:N5,matrix:T3,multiply:U4,typed:t2}),g6=sU({BigNumber:T1,Unit:C5,config:RH}),y6=$0({gamma:W5,typed:t2}),b6=LU({BigNumber:T1,Unit:C5,config:RH}),x6=eU({BigNumber:T1,Unit:C5,config:RH}),v6=O0({DenseMatrix:K1,Spa:I5,SparseMatrix:t3,abs:a2,addScalar:u2,divideScalar:t4,equalScalar:S2,larger:B4,matrix:T3,multiplyScalar:U2,subtract:B3,typed:t2,unaryMinus:M3}),_6=tU({BigNumber:T1,Unit:C5,config:RH}),w6=AU({BigNumber:T1,Unit:C5,config:RH}),M6=F0({add:D4,divide:m6,factorial:y6,isInteger:O2,isPositive:F2,multiply:U4,typed:t2}),N6=z0({factorial:y6,typed:t2}),S6=OU({BigNumber:T1,Unit:C5,config:RH}),k6=hU({BigNumber:T1,Unit:C5,config:RH}),D6=TU({BigNumber:T1,Unit:C5,config:RH}),T6=H0({bignumber:f2,addScalar:u2,combinations:b2,divideScalar:t4,factorial:y6,isInteger:O2,isNegative:R2,larger:B4,multiplyScalar:U2,number:W2,pow:k5,subtract:B3,typed:t2}),I6=U0({Unit:C5,typed:t2}),E6=W0({addScalar:u2,isInteger:O2,isNegative:R2,stirlingS2:T6,typed:t2}),C6=V0({abs:a2,add:D4,addScalar:u2,atan:d2,bignumber:f2,column:w5,complex:x2,config:RH,cos:h3,diag:e4,divideScalar:t4,dot:O4,equal:r4,flatten:i4,im:$2,inv:N5,larger:B4,matrix:T3,matrixFromColumns:f4,multiply:U4,multiplyScalar:U2,number:W2,qr:q4,re:X2,sin:e3,smaller:F3,sqrt:_3,subtract:B3,typed:t2,usolve:S4,usolveAll:Z4}),A6=oU({BigNumber:T1,Unit:C5,config:RH}),L6=K0({add:D4,divide:m6,typed:t2}),$6=kU({BigNumber:T1,Unit:C5,config:RH}),O6=qj({BigNumber:T1,Unit:C5,config:RH}),R6=X0({Index:l5,concat:X3,setDifference:D5,size:R3,subset:z3,typed:t2}),F6=iU({BigNumber:T1,Unit:C5,config:RH}),Y6=t1({DenseMatrix:K1,lsolve:h4,lup:v6,matrix:T3,slu:K4,typed:t2,usolve:S4}),z6=a1({add:D4,compare:K3,divide:m6,partitionSelect:x4,typed:t2}),B6=o1({Index:l5,concat:X3,setIntersect:u6,setSymDifference:R6,size:R3,subset:z3,typed:t2}),P6=p1({add:D4,apply:l3,divide:m6,isNaN:m3,multiply:U4,subtract:B3,typed:t2}),H6=f1({divide:m6,dotDivide:n4,isNumeric:D3,log:P4,matrix:T3,multiply:U4,sum:J4,typed:t2}),j6=y1({abs:a2,add:D4,conj:v2,ctranspose:Q3,eigs:C6,equalScalar:S2,larger:B4,matrix:T3,multiply:U4,pow:k5,smaller:F3,sqrt:_3,typed:t2}),U6=RU({BigNumber:T1,Unit:C5,config:RH}),q6=v1({BigNumber:T1,DenseMatrix:K1,SparseMatrix:t3,addScalar:u2,config:RH,cos:h3,matrix:T3,multiplyScalar:U2,norm:j6,sin:e3,typed:t2,unaryMinus:M3}),W6=NU({BigNumber:T1,Unit:C5,config:RH}),V6=w1({sqrt:_3,typed:t2,variance:P6}),G6=N1({abs:a2,map:j2,median:z6,subtract:B3,typed:t2}),K6=D1({multiply:U4,rotationMatrix:q6,typed:t2}),J6=YH("Chain",["?on","math"],(e=>{var{on:t,math:n}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");vH(e)?this.value=e.value:this.value=e}function a(e,t){IH(r.prototype,e,(function(){var e=t();if("function"==typeof e)return i(e)}))}function i(e){return function(){for(var t=[this.value],n=0;ne[t]))};for(var o in e)n(o)}var u,l};var s={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return r.createProxy(n),t&&t("import",(function(e,t,n){n||a(e,t)})),r}),{isClass:!0}),X6=new Set(["end"]),Z6=YH("Node",["mathWithTransform"],(e=>{var{mathWithTransform:t}=e;function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator")}return n.prototype.evaluate=function(e){return this.compile().evaluate(e)},n.prototype.type="Node",n.prototype.isNode=!0,n.prototype.comment="",n.prototype.compile=function(){var e=this._compile(t,{}),n={};return{evaluate:function(t){var r=Fq(t);return function(e){for(var t of[...X6])if(e.has(t))throw new Error('Scope contains an illegal symbol, "'+t+'" is a reserved keyword')}(r),e(r,n,null)}}},n.prototype._compile=function(e,t){throw new Error("Method _compile should be implemented by type "+this.type)},n.prototype.forEach=function(e){throw new Error("Cannot run forEach on a Node interface")},n.prototype.map=function(e){throw new Error("Cannot run map on a Node interface")},n.prototype._ifNode=function(e){if(!fH(e))throw new TypeError("Callback function must return a Node");return e},n.prototype.traverse=function(e){e(this,null,null),function e(t,n){t.forEach((function(t,r,a){n(t,r,a),e(t,n)}))}(this,e)},n.prototype.transform=function(e){return function t(n,r,a){var i=e(n,r,a);return i!==n?i:n.map(t)}(this,null,null)},n.prototype.filter=function(e){var t=[];return this.traverse((function(n,r,a){e(n,r,a)&&t.push(n)})),t},n.prototype.clone=function(){throw new Error("Cannot clone a Node interface")},n.prototype.cloneDeep=function(){return this.map((function(e){return e.cloneDeep()}))},n.prototype.equals=function(e){return!!e&&kH(this,e)},n.prototype.toString=function(e){var t=this._getCustomString(e);return void 0!==t?t:this._toString(e)},n.prototype.toJSON=function(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)},n.prototype.toHTML=function(e){var t=this._getCustomString(e);return void 0!==t?t:this.toHTML(e)},n.prototype._toString=function(){throw new Error("_toString not implemented for "+this.type)},n.prototype.toTex=function(e){var t=this._getCustomString(e);return void 0!==t?t:this._toTex(e)},n.prototype._toTex=function(e){throw new Error("_toTex not implemented for "+this.type)},n.prototype._getCustomString=function(e){if(e&&"object"==typeof e)switch(typeof e.handler){case"object":case"undefined":return;case"function":return e.handler(this,e);default:throw new TypeError("Object or function expected as callback")}},n.prototype.getIdentifier=function(){return this.type},n.prototype.getContent=function(){return this},n}),{isClass:!0,isNode:!0}),Q6=YH("ObjectNode",["Node"],(e=>{var{Node:t}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(this.properties=e||{},e&&("object"!=typeof e||!Object.keys(e).every((function(t){return fH(e[t])}))))throw new TypeError("Object containing Nodes expected")}return n.prototype=new t,n.prototype.type="ObjectNode",n.prototype.isObjectNode=!0,n.prototype._compile=function(e,t){var n={};for(var r in this.properties)if(EH(this.properties,r)){var a=JU(r),i=JSON.parse(a);if(!Eq(this.properties,i))throw new Error('No access to property "'+i+'"');n[i]=this.properties[r]._compile(e,t)}return function(e,t,r){var a={};for(var i in n)EH(n,i)&&(a[i]=n[i](e,t,r));return a}},n.prototype.forEach=function(e){for(var t in this.properties)EH(this.properties,t)&&e(this.properties[t],"properties["+JU(t)+"]",this)},n.prototype.map=function(e){var t={};for(var r in this.properties)EH(this.properties,r)&&(t[r]=this._ifNode(e(this.properties[r],"properties["+JU(r)+"]",this)));return new n(t)},n.prototype.clone=function(){var e={};for(var t in this.properties)EH(this.properties,t)&&(e[t]=this.properties[t]);return new n(e)},n.prototype._toString=function(e){var t=[];for(var n in this.properties)EH(this.properties,n)&&t.push(JU(n)+": "+this.properties[n].toString(e));return"{"+t.join(", ")+"}"},n.prototype.toJSON=function(){return{mathjs:"ObjectNode",properties:this.properties}},n.fromJSON=function(e){return new n(e.properties)},n.prototype.toHTML=function(e){var t=[];for(var n in this.properties)EH(this.properties,n)&&t.push(''+XU(n)+':'+this.properties[n].toHTML(e));return'{'+t.join(',')+'}'},n.prototype._toTex=function(e){var t=[];for(var n in this.properties)EH(this.properties,n)&&t.push("\\mathbf{"+n+":} & "+this.properties[n].toTex(e)+"\\\\");return"\\left\\{\\begin{array}{ll}".concat(t.join("\n"),"\\end{array}\\right\\}")},n}),{isClass:!0,isNode:!0}),e7=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{associativity:"left",associativeWith:[]}},{"OperatorNode:xor":{associativity:"left",associativeWith:[]}},{"OperatorNode:and":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitOr":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitXor":{associativity:"left",associativeWith:[]}},{"OperatorNode:bitAnd":{associativity:"left",associativeWith:[]}},{"OperatorNode:equal":{associativity:"left",associativeWith:[]},"OperatorNode:unequal":{associativity:"left",associativeWith:[]},"OperatorNode:smaller":{associativity:"left",associativeWith:[]},"OperatorNode:larger":{associativity:"left",associativeWith:[]},"OperatorNode:smallerEq":{associativity:"left",associativeWith:[]},"OperatorNode:largerEq":{associativity:"left",associativeWith:[]},RelationalNode:{associativity:"left",associativeWith:[]}},{"OperatorNode:leftShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightArithShift":{associativity:"left",associativeWith:[]},"OperatorNode:rightLogShift":{associativity:"left",associativeWith:[]}},{"OperatorNode:to":{associativity:"left",associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{associativity:"left",associativeWith:["OperatorNode:add","OperatorNode:subtract"]},"OperatorNode:subtract":{associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]},"OperatorNode:divide":{associativity:"left",associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:doDivide"]},"OperatorNode:dotDivide":{associativity:"left",associativeWith:[]},"OperatorNode:mod":{associativity:"left",associativeWith:[]}},{"OperatorNode:unaryPlus":{associativity:"right"},"OperatorNode:unaryMinus":{associativity:"right"},"OperatorNode:bitNot":{associativity:"right"},"OperatorNode:not":{associativity:"right"}},{"OperatorNode:pow":{associativity:"right",associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{associativity:"right",associativeWith:[]}},{"OperatorNode:factorial":{associativity:"left"}},{"OperatorNode:transpose":{associativity:"left"}}];function t7(e,t){var n=e;"keep"!==t&&(n=e.getContent());for(var r=n.getIdentifier(),a=0;a>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"},o7={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(s7.add,"${args[1]}\\right)")},cbrt:{1:"\\sqrt[3]{${args[0]}}"},ceil:{1:"\\left\\lceil${args[0]}\\right\\rceil"},cube:{1:"\\left(${args[0]}\\right)^3"},divide:{2:"\\frac{${args[0]}}{${args[1]}}"},dotDivide:{2:"\\left(${args[0]}".concat(s7.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(s7.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(s7.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(s7.pow,"{${args[0]}}-1\\right)"),fix:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},floor:{1:"\\left\\lfloor${args[0]}\\right\\rfloor"},gcd:"\\gcd\\left(${args}\\right)",hypot:"\\hypot\\left(${args}\\right)",log:{1:"\\ln\\left(${args[0]}\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}\\right)"},log10:{1:"\\log_{10}\\left(${args[0]}\\right)"},log1p:{1:"\\ln\\left(${args[0]}+1\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}+1\\right)"},log2:"\\log_{2}\\left(${args[0]}\\right)",mod:{2:"\\left(${args[0]}".concat(s7.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(s7.multiply,"${args[1]}\\right)")},norm:{1:"\\left\\|${args[0]}\\right\\|",2:void 0},nthRoot:{2:"\\sqrt[${args[1]}]{${args[0]}}"},nthRoots:{2:"\\{y : $y^{args[1]} = {${args[0]}}\\}"},pow:{2:"\\left(${args[0]}\\right)".concat(s7.pow,"{${args[1]}}")},round:{1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},sign:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},sqrt:{1:"\\sqrt{${args[0]}}"},square:{1:"\\left(${args[0]}\\right)^2"},subtract:{2:"\\left(${args[0]}".concat(s7.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(s7.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(s7.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(s7.bitAnd,"${args[1]}\\right)")},bitNot:{1:s7.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(s7.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(s7.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(s7.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(s7.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(s7.rightLogShift,"${args[1]}\\right)")},bellNumbers:{1:"\\mathrm{B}_{${args[0]}}"},catalan:{1:"\\mathrm{C}_{${args[0]}}"},stirlingS2:{2:"\\mathrm{S}\\left(${args}\\right)"},arg:{1:"\\arg\\left(${args[0]}\\right)"},conj:{1:"\\left(${args[0]}\\right)^*"},im:{1:"\\Im\\left\\lbrace${args[0]}\\right\\rbrace"},re:{1:"\\Re\\left\\lbrace${args[0]}\\right\\rbrace"},and:{2:"\\left(${args[0]}".concat(s7.and,"${args[1]}\\right)")},not:{1:s7.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(s7.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(s7.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(s7.ctranspose)},det:{1:"\\det\\left(${args[0]}\\right)"},dot:{2:"\\left(${args[0]}\\cdot${args[1]}\\right)"},expm:{1:"\\exp\\left(${args[0]}\\right)"},inv:{1:"\\left(${args[0]}\\right)^{-1}"},pinv:{1:"\\left(${args[0]}\\right)^{+}"},sqrtm:{1:"{${args[0]}}".concat(s7.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(s7.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(s7.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},lgamma:{1:"\\ln\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(s7.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(s7.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(s7.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(s7.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(s7.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(s7.unequal,"${args[1]}\\right)")},erf:{1:"erf\\left(${args[0]}\\right)"},max:"\\max\\left(${args}\\right)",min:"\\min\\left(${args}\\right)",variance:"\\mathrm{Var}\\left(${args}\\right)",acos:{1:"\\cos^{-1}\\left(${args[0]}\\right)"},acosh:{1:"\\cosh^{-1}\\left(${args[0]}\\right)"},acot:{1:"\\cot^{-1}\\left(${args[0]}\\right)"},acoth:{1:"\\coth^{-1}\\left(${args[0]}\\right)"},acsc:{1:"\\csc^{-1}\\left(${args[0]}\\right)"},acsch:{1:"\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"},asec:{1:"\\sec^{-1}\\left(${args[0]}\\right)"},asech:{1:"\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"},asin:{1:"\\sin^{-1}\\left(${args[0]}\\right)"},asinh:{1:"\\sinh^{-1}\\left(${args[0]}\\right)"},atan:{1:"\\tan^{-1}\\left(${args[0]}\\right)"},atan2:{2:"\\mathrm{atan2}\\left(${args}\\right)"},atanh:{1:"\\tanh^{-1}\\left(${args[0]}\\right)"},cos:{1:"\\cos\\left(${args[0]}\\right)"},cosh:{1:"\\cosh\\left(${args[0]}\\right)"},cot:{1:"\\cot\\left(${args[0]}\\right)"},coth:{1:"\\coth\\left(${args[0]}\\right)"},csc:{1:"\\csc\\left(${args[0]}\\right)"},csch:{1:"\\mathrm{csch}\\left(${args[0]}\\right)"},sec:{1:"\\sec\\left(${args[0]}\\right)"},sech:{1:"\\mathrm{sech}\\left(${args[0]}\\right)"},sin:{1:"\\sin\\left(${args[0]}\\right)"},sinh:{1:"\\sinh\\left(${args[0]}\\right)"},tan:{1:"\\tan\\left(${args[0]}\\right)"},tanh:{1:"\\tanh\\left(${args[0]}\\right)"},to:{2:"\\left(${args[0]}".concat(s7.to,"${args[1]}\\right)")},numeric:function(e,t){return e.args[0].toTex()},number:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},string:{0:'\\mathtt{""}',1:"\\mathrm{string}\\left(${args[0]}\\right)"},bignumber:{0:"0",1:"\\left(${args[0]}\\right)"},complex:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)+".concat(i7.i,"\\cdot\\left(${args[1]}\\right)\\right)")},matrix:{0:"\\begin{bmatrix}\\end{bmatrix}",1:"\\left(${args[0]}\\right)",2:"\\left(${args[0]}\\right)"},sparse:{0:"\\begin{bsparse}\\end{bsparse}",1:"\\left(${args[0]}\\right)"},unit:{1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"}},u7={deg:"^\\circ"};function l7(e){return a7(e,{preserveFormatting:!0})}function c7(e,t){return(t=void 0!==t&&t)?EH(u7,e)?u7[e]:"\\mathrm{"+l7(e)+"}":EH(i7,e)?i7[e]:l7(e)}var p7=YH("OperatorNode",["Node"],(e=>{var{Node:t}=e;function n(e,t,r,a,i){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('string expected for parameter "op"');if("string"!=typeof t)throw new TypeError('string expected for parameter "fn"');if(!Array.isArray(r)||!r.every(fH))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=!0===a,this.isPercentage=!0===i,this.op=e,this.fn=t,this.args=r||[]}function r(e,t,n,r,a){var i,s=t7(e,t),o=n7(e,t);if("all"===t||r.length>2&&"OperatorNode:add"!==e.getIdentifier()&&"OperatorNode:multiply"!==e.getIdentifier())return r.map((function(e){switch(e.getContent().type){case"ArrayNode":case"ConstantNode":case"SymbolNode":case"ParenthesisNode":return!1;default:return!0}}));switch(r.length){case 0:i=[];break;case 1:var u=t7(r[0],t);if(a&&null!==u){var l,c;if("keep"===t?(l=r[0].getIdentifier(),c=e.getIdentifier()):(l=r[0].getContent().getIdentifier(),c=e.getContent().getIdentifier()),!1===e7[s][c].latexLeftParens){i=[!1];break}if(!1===e7[u][l].latexParens){i=[!1];break}}if(null===u){i=[!1];break}if(u<=s){i=[!0];break}i=[!1];break;case 2:var p,d,h=t7(r[0],t),f=r7(e,r[0],t);p=null!==h&&(h===s&&"right"===o&&!f||h=2&&"OperatorNode:multiply"===e.getIdentifier()&&e.implicit&&"auto"===t&&"hide"===n&&(i=r.map((function(e,t){var n="ParenthesisNode"===e.getIdentifier();return!(!i[t]&&!n)}))),i}return n.prototype=new t,n.prototype.type="OperatorNode",n.prototype.isOperatorNode=!0,n.prototype._compile=function(e,t){if("string"!=typeof this.fn||!Cq(e,this.fn))throw e[this.fn]?new Error('No access to function "'+this.fn+'"'):new Error("Function "+this.fn+' missing in provided namespace "math"');var n=Tq(e,this.fn),r=gq(this.args,(function(n){return n._compile(e,t)}));if(1===r.length){var a=r[0];return function(e,t,r){return n(a(e,t,r))}}if(2===r.length){var i=r[0],s=r[1];return function(e,t,r){return n(i(e,t,r),s(e,t,r))}}return function(e,t,a){return n.apply(null,gq(r,(function(n){return n(e,t,a)})))}},n.prototype.forEach=function(e){for(var t=0;t2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var p=a.map((function(t,n){return t=t.toString(e),i[n]&&(t="("+t+")"),t}));return this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===n?p.join(" "):p.join(" "+this.op+" ")}return this.fn+"("+this.args.join(", ")+")"},n.prototype.toJSON=function(){return{mathjs:"OperatorNode",op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}},n.fromJSON=function(e){return new n(e.op,e.fn,e.args,e.implicit,e.isPercentage)},n.prototype.toHTML=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",n=e&&e.implicit?e.implicit:"hide",a=this.args,i=r(this,t,n,a,!1);if(1===a.length){var s=n7(this,t),o=a[0].toHTML(e);return i[0]&&(o='('+o+')'),"right"===s?''+XU(this.op)+""+o:o+''+XU(this.op)+""}if(2===a.length){var u=a[0].toHTML(e),l=a[1].toHTML(e);return i[0]&&(u='('+u+')'),i[1]&&(l='('+l+')'),this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===n?u+''+l:u+''+XU(this.op)+""+l}var c=a.map((function(t,n){return t=t.toHTML(e),i[n]&&(t='('+t+')'),t}));return a.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())?this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===n?c.join(''):c.join(''+XU(this.op)+""):''+XU(this.fn)+'('+c.join(',')+')'},n.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",n=e&&e.implicit?e.implicit:"hide",a=this.args,i=r(this,t,n,a,!0),s=s7[this.fn];if(s=void 0===s?this.op:s,1===a.length){var o=n7(this,t),u=a[0].toTex(e);return i[0]&&(u="\\left(".concat(u,"\\right)")),"right"===o?s+u:u+s}if(2===a.length){var l=a[0],c=l.toTex(e);i[0]&&(c="\\left(".concat(c,"\\right)"));var p,d=a[1].toTex(e);switch(i[1]&&(d="\\left(".concat(d,"\\right)")),p="keep"===t?l.getIdentifier():l.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return s+"{"+c+"}{"+d+"}";case"OperatorNode:pow":switch(c="{"+c+"}",d="{"+d+"}",p){case"ConditionalNode":case"OperatorNode:divide":c="\\left(".concat(c,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&"hide"===n)return c+"~"+d}return c+s+d}if(a.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var h=a.map((function(t,n){return t=t.toTex(e),i[n]&&(t="\\left(".concat(t,"\\right)")),t}));return"OperatorNode:multiply"===this.getIdentifier()&&this.implicit?h.join("~"):h.join(s)}return"\\mathrm{"+this.fn+"}\\left("+a.map((function(t){return t.toTex(e)})).join(",")+"\\right)"},n.prototype.getIdentifier=function(){return this.type+":"+this.fn},n}),{isClass:!0,isNode:!0}),d7=YH("ParenthesisNode",["Node"],(e=>{var{Node:t}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!fH(e))throw new TypeError('Node expected for parameter "content"');this.content=e}return n.prototype=new t,n.prototype.type="ParenthesisNode",n.prototype.isParenthesisNode=!0,n.prototype._compile=function(e,t){return this.content._compile(e,t)},n.prototype.getContent=function(){return this.content.getContent()},n.prototype.forEach=function(e){e(this.content,"content",this)},n.prototype.map=function(e){return new n(e(this.content,"content",this))},n.prototype.clone=function(){return new n(this.content)},n.prototype._toString=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"("+this.content.toString(e)+")":this.content.toString(e)},n.prototype.toJSON=function(){return{mathjs:"ParenthesisNode",content:this.content}},n.fromJSON=function(e){return new n(e.content)},n.prototype.toHTML=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?'('+this.content.toHTML(e)+')':this.content.toHTML(e)},n.prototype._toTex=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"\\left(".concat(this.content.toTex(e),"\\right)"):this.content.toTex(e)},n}),{isClass:!0,isNode:!0}),h7=YH("RelationalNode",["Node"],(e=>{var{Node:t}=e;function n(e,t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(t))throw new TypeError("Parameter params must be an array");if(e.length!==t.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=e,this.params=t}return n.prototype=new t,n.prototype.type="RelationalNode",n.prototype.isRelationalNode=!0,n.prototype._compile=function(e,t){var n=this,r=this.params.map((n=>n._compile(e,t)));return function(t,a,i){for(var s,o=r[0](t,a,i),u=0;ue(t,"params["+n+"]",this)),this)},n.prototype.map=function(e){return new n(this.conditionals.slice(),this.params.map(((t,n)=>this._ifNode(e(t,"params["+n+"]",this))),this))},n.prototype.clone=function(){return new n(this.conditionals,this.params)},n.prototype._toString=function(e){for(var t=e&&e.parenthesis?e.parenthesis:"keep",n=t7(this,t),r=this.params.map((function(r,a){var i=t7(r,t);return"all"===t||null!==i&&i<=n?"("+r.toString(e)+")":r.toString(e)})),a={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},i=r[0],s=0;s('+r.toHTML(e)+')':r.toHTML(e)})),a={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="},i=r[0],s=0;s'+XU(a[this.conditionals[s]])+""+r[s+1];return i},n.prototype._toTex=function(e){for(var t=e&&e.parenthesis?e.parenthesis:"keep",n=t7(this,t),r=this.params.map((function(r,a){var i=t7(r,t);return"all"===t||null!==i&&i<=n?"\\left("+r.toTex(e)+"\right)":r.toTex(e)})),a=r[0],i=0;i{var{Node:t}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(this.items=e||[],!Array.isArray(this.items)||!this.items.every(fH))throw new TypeError("Array containing Nodes expected")}return n.prototype=new t,n.prototype.type="ArrayNode",n.prototype.isArrayNode=!0,n.prototype._compile=function(e,t){var n=gq(this.items,(function(n){return n._compile(e,t)}));if("Array"!==e.config.matrix){var r=e.matrix;return function(e,t,a){return r(gq(n,(function(n){return n(e,t,a)})))}}return function(e,t,r){return gq(n,(function(n){return n(e,t,r)}))}},n.prototype.forEach=function(e){for(var t=0;t['+this.items.map((function(t){return t.toHTML(e)})).join(',')+']'},n.prototype._toTex=function(e){return function t(n,r){var a=n.some(sH)&&!n.every(sH),i=r||a,s=i?"&":"\\\\",o=n.map((function(n){return n.items?t(n.items,!r):n.toTex(e)})).join(s);return a||!i||i&&!r?"\\begin{bmatrix}"+o+"\\end{bmatrix}":o}(this.items,!1)},n}),{isClass:!0,isNode:!0}),m7=YH("BlockNode",["ResultSet","Node"],(e=>{var{ResultSet:t,Node:n}=e;function r(e){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new Error("Array expected");this.blocks=e.map((function(e){var t=e&&e.node,n=!e||void 0===e.visible||e.visible;if(!fH(t))throw new TypeError('Property "node" must be a Node');if("boolean"!=typeof n)throw new TypeError('Property "visible" must be a boolean');return{node:t,visible:n}}))}return r.prototype=new n,r.prototype.type="BlockNode",r.prototype.isBlockNode=!0,r.prototype._compile=function(e,n){var r=gq(this.blocks,(function(t){return{evaluate:t.node._compile(e,n),visible:t.visible}}));return function(e,n,a){var i=[];return yq(r,(function(t){var r=t.evaluate(e,n,a);t.visible&&i.push(r)})),new t(i)}},r.prototype.forEach=function(e){for(var t=0;t;')})).join('
')},r.prototype._toTex=function(e){return this.blocks.map((function(t){return t.node.toTex(e)+(t.visible?"":";")})).join("\\;\\;\n")},r}),{isClass:!0,isNode:!0}),g7=YH("ConditionalNode",["Node"],(e=>{var{Node:t}=e;function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!fH(e))throw new TypeError("Parameter condition must be a Node");if(!fH(t))throw new TypeError("Parameter trueExpr must be a Node");if(!fH(r))throw new TypeError("Parameter falseExpr must be a Node");this.condition=e,this.trueExpr=t,this.falseExpr=r}return n.prototype=new t,n.prototype.type="ConditionalNode",n.prototype.isConditionalNode=!0,n.prototype._compile=function(e,t){var n=this.condition._compile(e,t),r=this.trueExpr._compile(e,t),a=this.falseExpr._compile(e,t);return function(e,t,i){return function(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e)return!!e;if(e){if(YP(e))return!e.isZero();if(zP(e))return!(!e.re&&!e.im);if(PP(e))return!!e.value}if(null==e)return!1;throw new TypeError('Unsupported type of condition "'+_H(e)+'"')}(n(e,t,i))?r(e,t,i):a(e,t,i)}},n.prototype.forEach=function(e){e(this.condition,"condition",this),e(this.trueExpr,"trueExpr",this),e(this.falseExpr,"falseExpr",this)},n.prototype.map=function(e){return new n(this._ifNode(e(this.condition,"condition",this)),this._ifNode(e(this.trueExpr,"trueExpr",this)),this._ifNode(e(this.falseExpr,"falseExpr",this)))},n.prototype.clone=function(){return new n(this.condition,this.trueExpr,this.falseExpr)},n.prototype._toString=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",n=t7(this,t),r=this.condition.toString(e),a=t7(this.condition,t);("all"===t||"OperatorNode"===this.condition.type||null!==a&&a<=n)&&(r="("+r+")");var i=this.trueExpr.toString(e),s=t7(this.trueExpr,t);("all"===t||"OperatorNode"===this.trueExpr.type||null!==s&&s<=n)&&(i="("+i+")");var o=this.falseExpr.toString(e),u=t7(this.falseExpr,t);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==u&&u<=n)&&(o="("+o+")"),r+" ? "+i+" : "+o},n.prototype.toJSON=function(){return{mathjs:"ConditionalNode",condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}},n.fromJSON=function(e){return new n(e.condition,e.trueExpr,e.falseExpr)},n.prototype.toHTML=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",n=t7(this,t),r=this.condition.toHTML(e),a=t7(this.condition,t);("all"===t||"OperatorNode"===this.condition.type||null!==a&&a<=n)&&(r='('+r+')');var i=this.trueExpr.toHTML(e),s=t7(this.trueExpr,t);("all"===t||"OperatorNode"===this.trueExpr.type||null!==s&&s<=n)&&(i='('+i+')');var o=this.falseExpr.toHTML(e),u=t7(this.falseExpr,t);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==u&&u<=n)&&(o='('+o+')'),r+'?'+i+':'+o},n.prototype._toTex=function(e){return"\\begin{cases} {"+this.trueExpr.toTex(e)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(e)+"}\\\\{"+this.falseExpr.toTex(e)+"}, &\\quad{\\text{otherwise}}\\end{cases}"},n}),{isClass:!0,isNode:!0}),y7=YH("ConstantNode",["Node"],(e=>{var{Node:t}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this.value=e}return n.prototype=new t,n.prototype.type="ConstantNode",n.prototype.isConstantNode=!0,n.prototype._compile=function(e,t){var n=this.value;return function(){return n}},n.prototype.forEach=function(e){},n.prototype.map=function(e){return this.clone()},n.prototype.clone=function(){return new n(this.value)},n.prototype._toString=function(e){return KU(this.value,e)},n.prototype.toHTML=function(e){var t=this._toString(e);switch(_H(this.value)){case"number":case"BigNumber":case"Fraction":return''+t+"";case"string":return''+t+"";case"boolean":return''+t+"";case"null":return''+t+"";case"undefined":return''+t+"";default:return''+t+""}},n.prototype.toJSON=function(){return{mathjs:"ConstantNode",value:this.value}},n.fromJSON=function(e){return new n(e.value)},n.prototype._toTex=function(e){var t=this._toString(e);switch(_H(this.value)){case"string":return"\\mathtt{"+l7(t)+"}";case"number":case"BigNumber":if(!isFinite(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";var n=t.toLowerCase().indexOf("e");return-1!==n?t.substring(0,n)+"\\cdot10^{"+t.substring(n+1)+"}":t;case"Fraction":return this.value.toLatex();default:return t}},n}),{isClass:!0,isNode:!0}),b7=YH("RangeNode",["Node"],(e=>{var{Node:t}=e;function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!fH(e))throw new TypeError("Node expected");if(!fH(t))throw new TypeError("Node expected");if(r&&!fH(r))throw new TypeError("Node expected");if(arguments.length>3)throw new Error("Too many arguments");this.start=e,this.end=t,this.step=r||null}function r(e,t){var n=t7(e,t),r={},a=t7(e.start,t);if(r.start=null!==a&&a<=n||"all"===t,e.step){var i=t7(e.step,t);r.step=null!==i&&i<=n||"all"===t}var s=t7(e.end,t);return r.end=null!==s&&s<=n||"all"===t,r}return n.prototype=new t,n.prototype.type="RangeNode",n.prototype.isRangeNode=!0,n.prototype.needsEnd=function(){return this.filter((function(e){return xH(e)&&"end"===e.name})).length>0},n.prototype._compile=function(e,t){var n=e.range,r=this.start._compile(e,t),a=this.end._compile(e,t);if(this.step){var i=this.step._compile(e,t);return function(e,t,s){return n(r(e,t,s),a(e,t,s),i(e,t,s))}}return function(e,t,i){return n(r(e,t,i),a(e,t,i))}},n.prototype.forEach=function(e){e(this.start,"start",this),e(this.end,"end",this),this.step&&e(this.step,"step",this)},n.prototype.map=function(e){return new n(this._ifNode(e(this.start,"start",this)),this._ifNode(e(this.end,"end",this)),this.step&&this._ifNode(e(this.step,"step",this)))},n.prototype.clone=function(){return new n(this.start,this.end,this.step&&this.step)},n.prototype._toString=function(e){var t,n=r(this,e&&e.parenthesis?e.parenthesis:"keep"),a=this.start.toString(e);if(n.start&&(a="("+a+")"),t=a,this.step){var i=this.step.toString(e);n.step&&(i="("+i+")"),t+=":"+i}var s=this.end.toString(e);return n.end&&(s="("+s+")"),t+":"+s},n.prototype.toJSON=function(){return{mathjs:"RangeNode",start:this.start,end:this.end,step:this.step}},n.fromJSON=function(e){return new n(e.start,e.end,e.step)},n.prototype.toHTML=function(e){var t,n=r(this,e&&e.parenthesis?e.parenthesis:"keep"),a=this.start.toHTML(e);if(n.start&&(a='('+a+')'),t=a,this.step){var i=this.step.toHTML(e);n.step&&(i='('+i+')'),t+=':'+i}var s=this.end.toHTML(e);return n.end&&(s='('+s+')'),t+':'+s},n.prototype._toTex=function(e){var t=r(this,e&&e.parenthesis?e.parenthesis:"keep"),n=this.start.toTex(e);if(t.start&&(n="\\left(".concat(n,"\\right)")),this.step){var a=this.step.toTex(e);t.step&&(a="\\left(".concat(a,"\\right)")),n+=":"+a}var i=this.end.toTex(e);return t.end&&(i="\\left(".concat(i,"\\right)")),n+":"+i},n}),{isClass:!0,isNode:!0}),x7=YH("reviver",["classes"],(e=>{var{classes:t}=e;return function(e,n){var r=t[n&&n.mathjs];return r&&"function"==typeof r.fromJSON?r.fromJSON(n):n}})),v7="chain",_7=YH(v7,["typed","Chain"],(e=>{var{typed:t,Chain:n}=e;return t(v7,{"":function(){return new n},any:function(e){return new n(e)}})})),w7=YH("FunctionAssignmentNode",["typed","Node"],(e=>{var{typed:t,Node:n}=e;function r(e,t,n){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('String expected for parameter "name"');if(!Array.isArray(t))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!fH(n))throw new TypeError('Node expected for parameter "expr"');if(X6.has(e))throw new Error('Illegal function name, "'+e+'" is a reserved keyword');this.name=e,this.params=t.map((function(e){return e&&e.name||e})),this.types=t.map((function(e){return e&&e.type||"any"})),this.expr=n}function a(e,t){var n=t7(e,t),r=t7(e.expr,t);return"all"===t||null!==r&&r<=n}return r.prototype=new n,r.prototype.type="FunctionAssignmentNode",r.prototype.isFunctionAssignmentNode=!0,r.prototype._compile=function(e,n){var r=Object.create(n);yq(this.params,(function(e){r[e]=!0}));var a=this.expr._compile(e,r),i=this.name,s=this.params,o=vq(this.types,","),u=i+"("+vq(this.params,", ")+")";return function(e,n,r){var l={};l[o]=function(){for(var t=Object.create(n),i=0;i'+XU(this.params[r])+"");var i=this.expr.toHTML(e);return a(this,t)&&(i='('+i+')'),''+XU(this.name)+'('+n.join(',')+')='+i},r.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",n=this.expr.toTex(e);return a(this,t)&&(n="\\left(".concat(n,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(c7).join(",")+"\\right):="+n},r}),{isClass:!0,isNode:!0});function M7(e){return e&&e.isIndexError?new tq(e.index+1,e.min+1,void 0!==e.max?e.max+1:void 0):e}function N7(e){var{subset:t}=e;return function(e,n){try{if(Array.isArray(e))return t(e,n);if(e&&"function"==typeof e.subset)return e.subset(n);if("string"==typeof e)return t(e,n);if("object"==typeof e){if(!n.isObjectProperty())throw new TypeError("Cannot apply a numeric index as object property");return Tq(e,n.getObjectProperty())}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw M7(e)}}}var S7=YH("AccessorNode",["subset","Node"],(e=>{var{subset:t,Node:n}=e,r=N7({subset:t});function a(e,t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!fH(e))throw new TypeError('Node expected for parameter "object"');if(!hH(t))throw new TypeError('IndexNode expected for parameter "index"');this.object=e||null,this.index=t,Object.defineProperty(this,"name",{get:function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}function i(e){return!(iH(e)||sH(e)||cH(e)||dH(e)||mH(e)||yH(e)||xH(e))}return a.prototype=new n,a.prototype.type="AccessorNode",a.prototype.isAccessorNode=!0,a.prototype._compile=function(e,t){var n=this.object._compile(e,t),a=this.index._compile(e,t);if(this.index.isObjectProperty()){var i=this.index.getObjectProperty();return function(e,t,r){return Tq(n(e,t,r),i)}}return function(e,t,i){var s=n(e,t,i),o=a(e,t,s);return r(s,o)}},a.prototype.forEach=function(e){e(this.object,"object",this),e(this.index,"index",this)},a.prototype.map=function(e){return new a(this._ifNode(e(this.object,"object",this)),this._ifNode(e(this.index,"index",this)))},a.prototype.clone=function(){return new a(this.object,this.index)},a.prototype._toString=function(e){var t=this.object.toString(e);return i(this.object)&&(t="("+t+")"),t+this.index.toString(e)},a.prototype.toHTML=function(e){var t=this.object.toHTML(e);return i(this.object)&&(t='('+t+')'),t+this.index.toHTML(e)},a.prototype._toTex=function(e){var t=this.object.toTex(e);return i(this.object)&&(t="\\left(' + object + '\\right)"),t+this.index.toTex(e)},a.prototype.toJSON=function(){return{mathjs:"AccessorNode",object:this.object,index:this.index}},a.fromJSON=function(e){return new a(e.object,e.index)},a}),{isClass:!0,isNode:!0}),k7=YH("AssignmentNode",["subset","?matrix","Node"],(e=>{var{subset:t,matrix:n,Node:r}=e,a=N7({subset:t}),i=function(e){var{subset:t,matrix:n}=e;return function(e,r,a){try{if(Array.isArray(e))return n(e).subset(r,a).valueOf();if(e&&"function"==typeof e.subset)return e.subset(r,a);if("string"==typeof e)return t(e,r,a);if("object"==typeof e){if(!r.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return Iq(e,r.getObjectProperty(),a),e}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw M7(e)}}}({subset:t,matrix:n});function s(e,t,n){if(!(this instanceof s))throw new SyntaxError("Constructor must be called with the new operator");if(this.object=e,this.index=n?t:null,this.value=n||t,!xH(e)&&!iH(e))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(xH(e)&&"end"===e.name)throw new Error('Cannot assign to symbol "end"');if(this.index&&!hH(this.index))throw new TypeError('IndexNode expected as "index"');if(!fH(this.value))throw new TypeError('Node expected as "value"');Object.defineProperty(this,"name",{get:function(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}function o(e,t){t||(t="keep");var n=t7(e,t),r=t7(e.value,t);return"all"===t||null!==r&&r<=n}return s.prototype=new r,s.prototype.type="AssignmentNode",s.prototype.isAssignmentNode=!0,s.prototype._compile=function(e,t){var n=this.object._compile(e,t),r=this.index?this.index._compile(e,t):null,s=this.value._compile(e,t),o=this.object.name;if(this.index){if(this.index.isObjectProperty()){var u=this.index.getObjectProperty();return function(e,t,r){var a=n(e,t,r),i=s(e,t,r);return Iq(a,u,i),i}}if(xH(this.object))return function(e,t,a){var u=n(e,t,a),l=s(e,t,a),c=r(e,t,u);return e.set(o,i(u,c,l)),l};var l=this.object.object._compile(e,t);if(this.object.index.isObjectProperty()){var c=this.object.index.getObjectProperty();return function(e,t,n){var a=l(e,t,n),o=Tq(a,c),u=r(e,t,o),p=s(e,t,n);return Iq(a,c,i(o,u,p)),p}}var p=this.object.index._compile(e,t);return function(e,t,n){var o=l(e,t,n),u=p(e,t,o),c=a(o,u),d=r(e,t,c),h=s(e,t,n);return i(o,u,i(c,d,h)),h}}if(!xH(this.object))throw new TypeError("SymbolNode expected as object");return function(e,t,n){var r=s(e,t,n);return e.set(o,r),r}},s.prototype.forEach=function(e){e(this.object,"object",this),this.index&&e(this.index,"index",this),e(this.value,"value",this)},s.prototype.map=function(e){return new s(this._ifNode(e(this.object,"object",this)),this.index?this._ifNode(e(this.index,"index",this)):null,this._ifNode(e(this.value,"value",this)))},s.prototype.clone=function(){return new s(this.object,this.index,this.value)},s.prototype._toString=function(e){var t=this.object.toString(e),n=this.index?this.index.toString(e):"",r=this.value.toString(e);return o(this,e&&e.parenthesis)&&(r="("+r+")"),t+n+" = "+r},s.prototype.toJSON=function(){return{mathjs:"AssignmentNode",object:this.object,index:this.index,value:this.value}},s.fromJSON=function(e){return new s(e.object,e.index,e.value)},s.prototype.toHTML=function(e){var t=this.object.toHTML(e),n=this.index?this.index.toHTML(e):"",r=this.value.toHTML(e);return o(this,e&&e.parenthesis)&&(r='('+r+')'),t+n+'='+r},s.prototype._toTex=function(e){var t=this.object.toTex(e),n=this.index?this.index.toTex(e):"",r=this.value.toTex(e);return o(this,e&&e.parenthesis)&&(r="\\left(".concat(r,"\\right)")),t+n+":="+r},s}),{isClass:!0,isNode:!0}),D7=YH("IndexNode",["Node","size"],(e=>{var{Node:t,size:n}=e;function r(e,t){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(this.dimensions=e,this.dotNotation=t||!1,!Array.isArray(e)||!e.every(fH))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw new Error("dotNotation only applicable for object properties")}return r.prototype=new t,r.prototype.type="IndexNode",r.prototype.isIndexNode=!0,r.prototype._compile=function(e,t){var r=gq(this.dimensions,(function(r,a){if(r.filter((e=>e.isSymbolNode&&"end"===e.name)).length>0){var i=Object.create(t);i.end=!0;var s=r._compile(e,i);return function(e,t,r){if(!UP(r)&&!jP(r)&&!HP(r))throw new TypeError('Cannot resolve "end": context must be a Matrix, Array, or string but is '+_H(r));var i=n(r).valueOf(),o=Object.create(t);return o.end=i[a],s(e,o,r)}}return r._compile(e,t)})),a=Tq(e,"index");return function(e,t,n){var i=gq(r,(function(r){return r(e,t,n)}));return a(...i)}},r.prototype.forEach=function(e){for(var t=0;t.'+XU(this.getObjectProperty())+"":'['+t.join(',')+']'},r.prototype._toTex=function(e){var t=this.dimensions.map((function(t){return t.toTex(e)}));return this.dotNotation?"."+this.getObjectProperty():"_{"+t.join(",")+"}"},r}),{isClass:!0,isNode:!0}),T7=YH("SymbolNode",["math","?Unit","Node"],(e=>{var{math:t,Unit:n,Node:r}=e;function a(e){return!!n&&n.isValuelessUnit(e)}function i(e){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('String expected for parameter "name"');this.name=e}return i.prototype=new r,i.prototype.type="SymbolNode",i.prototype.isSymbolNode=!0,i.prototype._compile=function(e,t){var r=this.name;if(!0===t[r])return function(e,t,n){return t[r]};if(r in e)return function(t,n,a){return t.has(r)?t.get(r):Tq(e,r)};var s=a(r);return function(e,t,a){return e.has(r)?e.get(r):s?new n(null,r):i.onUndefinedSymbol(r)}},i.prototype.forEach=function(e){},i.prototype.map=function(e){return this.clone()},i.onUndefinedSymbol=function(e){throw new Error("Undefined symbol "+e)},i.prototype.clone=function(){return new i(this.name)},i.prototype._toString=function(e){return this.name},i.prototype.toHTML=function(e){var t=XU(this.name);return"true"===t||"false"===t?''+t+"":"i"===t?''+t+"":"Infinity"===t?''+t+"":"NaN"===t?''+t+"":"null"===t?''+t+"":"undefined"===t?''+t+"":''+t+""},i.prototype.toJSON=function(){return{mathjs:"SymbolNode",name:this.name}},i.fromJSON=function(e){return new i(e.name)},i.prototype._toTex=function(e){var n=!1;void 0===t[this.name]&&a(this.name)&&(n=!0);var r=c7(this.name,n);return"\\"===r[0]?r:" "+r},i}),{isClass:!0,isNode:!0});function I7(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r{var{math:t,Node:n,SymbolNode:r}=e;function a(e,t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if("string"==typeof e&&(e=new r(e)),!fH(e))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(t)||!t.every(fH))throw new TypeError('Array containing Nodes expected for parameter "args"');this.fn=e,this.args=t||[],Object.defineProperty(this,"name",{get:function(){return this.fn.name||""}.bind(this),set:function(){throw new Error("Cannot assign a new name, name is read-only")}})}a.prototype=new n,a.prototype.type="FunctionNode",a.prototype.isFunctionNode=!0;var i=e=>KU(e,{truncate:78});a.prototype._compile=function(e,t){if(!(this instanceof a))throw new TypeError("No valid FunctionNode");var n=this.args.map((n=>n._compile(e,t)));if(!xH(this.fn)){if(iH(this.fn)&&hH(this.fn.index)&&this.fn.index.isObjectProperty()){var r=this.fn.object._compile(e,t),s=this.fn.index.getObjectProperty(),o=this.args;return function(t,a,i){var u=r(t,a,i);if(function(e,t){if(!Cq(e,t))throw new Error('No access to method "'+t+'"')}(u,s),u[s]&&u[s].rawArgs)return u[s](o,e,I7(t,a),t);var l=n.map((e=>e(t,a,i)));return u[s].apply(u,l)}}var u=this.fn.toString(),l=this.fn._compile(e,t),c=this.args;return function(t,r,a){var s=l(t,r,a);if("function"!=typeof s)throw new TypeError("Expression '".concat(u,"' did not evaluate to a function; value is:")+"\n ".concat(i(s)));if(s.rawArgs)return s(c,e,I7(t,r),t);var o=n.map((e=>e(t,r,a)));return s.apply(s,o)}}var p=this.fn.name;if(t[p]){var d=this.args;return function(t,r,a){var s=r[p];if("function"!=typeof s)throw new TypeError("Argument '".concat(p,"' was not a function; received: ").concat(i(s)));if(s.rawArgs)return s(d,e,I7(t,r),t);var o=n.map((e=>e(t,r,a)));return s.apply(s,o)}}var h=p in e?Tq(e,p):void 0,f="function"==typeof h&&!0===h.rawArgs,m=t=>{var n;if(t.has(p))n=t.get(p);else{if(!(p in e))return a.onUndefinedFunction(p);n=Tq(e,p)}if("function"==typeof n)return n;throw new TypeError("'".concat(p,"' is not a function; its value is:\n ").concat(i(n)))};if(f){var g=this.args;return function(t,n,r){return m(t)(g,e,I7(t,n),t)}}switch(n.length){case 0:return function(e,t,n){return m(e)()};case 1:return function(e,t,r){return m(e)((0,n[0])(e,t,r))};case 2:return function(e,t,r){var a=m(e),i=n[0],s=n[1];return a(i(e,t,r),s(e,t,r))};default:return function(e,t,r){return m(e)(...n.map((n=>n(e,t,r))))}}},a.prototype.forEach=function(e){e(this.fn,"fn",this);for(var t=0;t'+XU(this.fn)+'('+t.join(',')+')'};var u=a.prototype.toTex;return a.prototype.toTex=function(e){var t;return e&&"object"==typeof e.handler&&EH(e.handler,this.name)&&(t=e.handler[this.name](this,e)),void 0!==t?t:u.call(this,e)},a.prototype._toTex=function(e){var n,r,a=this.args.map((function(t){return t.toTex(e)}));switch(o7[this.name]&&(n=o7[this.name]),!t[this.name]||"function"!=typeof t[this.name].toTex&&"object"!=typeof t[this.name].toTex&&"string"!=typeof t[this.name].toTex||(n=t[this.name].toTex),typeof n){case"function":r=n(this,e);break;case"string":r=o(n,this,e);break;case"object":switch(typeof n[a.length]){case"function":r=n[a.length](this,e);break;case"string":r=o(n[a.length],this,e)}}return void 0!==r?r:o("\\mathrm{${name}}\\left(${args}\\right)",this,e)},a.prototype.getIdentifier=function(){return this.type+":"+this.name},a}),{isClass:!0,isNode:!0}),C7="parse",A7=YH(C7,["typed","numeric","config","AccessorNode","ArrayNode","AssignmentNode","BlockNode","ConditionalNode","ConstantNode","FunctionAssignmentNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","RangeNode","RelationalNode","SymbolNode"],(e=>{var{typed:t,numeric:n,config:r,AccessorNode:a,ArrayNode:i,AssignmentNode:s,BlockNode:o,ConditionalNode:u,ConstantNode:l,FunctionAssignmentNode:c,FunctionNode:p,IndexNode:d,ObjectNode:h,OperatorNode:f,ParenthesisNode:m,RangeNode:g,RelationalNode:y,SymbolNode:b}=e,x=t(C7,{string:function(e){return $(e,{})},"Array | Matrix":function(e){return v(e,{})},"string, Object":function(e,t){return $(e,void 0!==t.nodes?t.nodes:{})},"Array | Matrix, Object":v});function v(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=void 0!==t.nodes?t.nodes:{};return Gq(e,(function(e){if("string"!=typeof e)throw new TypeError("String expected");return $(e,n)}))}var _={",":!0,"(":!0,")":!0,"[":!0,"]":!0,"{":!0,"}":!0,'"':!0,"'":!0,";":!0,"+":!0,"-":!0,"*":!0,".*":!0,"/":!0,"./":!0,"%":!0,"^":!0,".^":!0,"~":!0,"!":!0,"&":!0,"|":!0,"^|":!0,"=":!0,":":!0,"?":!0,"==":!0,"!=":!0,"<":!0,">":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},w={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},M={true:!0,false:!1,null:null,undefined:void 0},N=["NaN","Infinity"];function S(e,t){return e.expression.substr(e.index,t)}function k(e){return S(e,1)}function D(e){e.index++}function T(e){return e.expression.charAt(e.index-1)}function I(e){return e.expression.charAt(e.index+1)}function E(e){for(e.tokenType=0,e.token="",e.comment="";;){if("#"===k(e))for(;"\n"!==k(e)&&""!==k(e);)e.comment+=k(e),D(e);if(!x.isWhitespace(k(e),e.nestingLevel))break;D(e)}if(""!==k(e)){if("\n"===k(e)&&!e.nestingLevel)return e.tokenType=1,e.token=k(e),void D(e);var t=k(e),n=S(e,2),r=S(e,3);if(3===r.length&&_[r])return e.tokenType=1,e.token=r,D(e),D(e),void D(e);if(2===n.length&&_[n])return e.tokenType=1,e.token=n,D(e),void D(e);if(_[t])return e.tokenType=1,e.token=t,void D(e);if(x.isDigitDot(t)){e.tokenType=2;var a=S(e,2);if("0b"===a||"0o"===a||"0x"===a){for(e.token+=k(e),D(e),e.token+=k(e),D(e);x.isHexDigit(k(e));)e.token+=k(e),D(e);if("."===k(e))for(e.token+=".",D(e);x.isHexDigit(k(e));)e.token+=k(e),D(e);else if("i"===k(e))for(e.token+="i",D(e);x.isDigit(k(e));)e.token+=k(e),D(e);return}if("."===k(e)){if(e.token+=k(e),D(e),!x.isDigit(k(e)))return void(e.tokenType=1)}else{for(;x.isDigit(k(e));)e.token+=k(e),D(e);x.isDecimalMark(k(e),I(e))&&(e.token+=k(e),D(e))}for(;x.isDigit(k(e));)e.token+=k(e),D(e);if("E"===k(e)||"e"===k(e))if(x.isDigit(I(e))||"-"===I(e)||"+"===I(e)){if(e.token+=k(e),D(e),"+"!==k(e)&&"-"!==k(e)||(e.token+=k(e),D(e)),!x.isDigit(k(e)))throw ne(e,'Digit expected, got "'+k(e)+'"');for(;x.isDigit(k(e));)e.token+=k(e),D(e);if(x.isDecimalMark(k(e),I(e)))throw ne(e,'Digit expected, got "'+k(e)+'"')}else if("."===I(e))throw D(e),ne(e,'Digit expected, got "'+k(e)+'"')}else{if(!x.isAlpha(k(e),T(e),I(e))){for(e.tokenType=4;""!==k(e);)e.token+=k(e),D(e);throw ne(e,'Syntax error in part "'+e.token+'"')}for(;x.isAlpha(k(e),T(e),I(e))||x.isDigit(k(e));)e.token+=k(e),D(e);EH(w,e.token)?e.tokenType=1:e.tokenType=3}}else e.tokenType=1}function C(e){do{E(e)}while("\n"===e.token)}function A(e){e.nestingLevel++}function L(e){e.nestingLevel--}function $(e,t){var n={extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:0,nestingLevel:0,conditionalLevel:null};OP(n,{expression:e,extraNodes:t}),E(n);var r=function(e){var t,n,r=[];for(""!==e.token&&"\n"!==e.token&&";"!==e.token&&((t=O(e)).comment=e.comment);"\n"===e.token||";"===e.token;)0===r.length&&t&&(n=";"!==e.token,r.push({node:t,visible:n})),E(e),"\n"!==e.token&&";"!==e.token&&""!==e.token&&((t=O(e)).comment=e.comment,n=";"!==e.token,r.push({node:t,visible:n}));return r.length>0?new o(r):(t||((t=new l(void 0)).comment=e.comment),t)}(n);if(""!==n.token)throw 1===n.tokenType?re(n,"Unexpected operator "+n.token):ne(n,'Unexpected part "'+n.token+'"');return r}function O(e){var t,n,r,a,i=function(e){for(var t=function(e){for(var t=R(e);"or"===e.token;)C(e),t=new f("or","or",[t,R(e)]);return t}(e);"?"===e.token;){var n=e.conditionalLevel;e.conditionalLevel=e.nestingLevel,C(e);var r=t,a=O(e);if(":"!==e.token)throw ne(e,"False part of conditional expression expected");e.conditionalLevel=null,C(e);var i=O(e);t=new u(r,a,i),e.conditionalLevel=n}return t}(e);if("="===e.token){if(xH(i))return t=i.name,C(e),r=O(e),new s(new b(t),r);if(iH(i))return C(e),r=O(e),new s(i.object,i.index,r);if(dH(i)&&xH(i.fn)&&(a=!0,n=[],t=i.name,i.args.forEach((function(e,t){xH(e)?n[t]=e.name:a=!1})),a))return C(e),r=O(e),new c(t,n,r);throw ne(e,"Invalid left hand side of assignment operator =")}return i}function R(e){for(var t=F(e);"xor"===e.token;)C(e),t=new f("xor","xor",[t,F(e)]);return t}function F(e){for(var t=Y(e);"and"===e.token;)C(e),t=new f("and","and",[t,Y(e)]);return t}function Y(e){for(var t=z(e);"|"===e.token;)C(e),t=new f("|","bitOr",[t,z(e)]);return t}function z(e){for(var t=B(e);"^|"===e.token;)C(e),t=new f("^|","bitXor",[t,B(e)]);return t}function B(e){for(var t=P(e);"&"===e.token;)C(e),t=new f("&","bitAnd",[t,P(e)]);return t}function P(e){for(var t=[H(e)],n=[],r={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};EH(r,e.token);){var a={name:e.token,fn:r[e.token]};n.push(a),C(e),t.push(H(e))}return 1===t.length?t[0]:2===t.length?new f(n[0].name,n[0].fn,t):new y(n.map((e=>e.fn)),t)}function H(e){var t,n,r,a;t=j(e);for(var i={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};EH(i,e.token);)r=i[n=e.token],C(e),a=[t,j(e)],t=new f(n,r,a);return t}function j(e){var t,n,r,a;t=U(e);for(var i={to:"to",in:"to"};EH(i,e.token);)r=i[n=e.token],C(e),"in"===n&&""===e.token?t=new f("*","multiply",[t,new b("in")],!0):(a=[t,U(e)],t=new f(n,r,a));return t}function U(e){var t,n=[];if(t=":"===e.token?new l(1):q(e),":"===e.token&&e.conditionalLevel!==e.nestingLevel){for(n.push(t);":"===e.token&&n.length<3;)C(e),")"===e.token||"]"===e.token||","===e.token||""===e.token?n.push(new b("end")):n.push(q(e));t=3===n.length?new g(n[0],n[2],n[1]):new g(n[0],n[1])}return t}function q(e){var t,n,r,a;t=W(e);for(var i={"+":"add","-":"subtract"};EH(i,e.token);){r=i[n=e.token],C(e);var s=W(e);a=s.isPercentage?[t,new f("*","multiply",[t,s])]:[t,s],t=new f(n,r,a)}return t}function W(e){var t,n,r,a;n=t=V(e);for(var i={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide"};EH(i,e.token);)a=i[r=e.token],C(e),n=V(e),t=new f(r,a,[t,n]);return t}function V(e){var t,n;for(n=t=G(e);3===e.tokenType||"in"===e.token&&cH(t)||!(2!==e.tokenType||cH(n)||gH(n)&&"!"!==n.op)||"("===e.token;)n=G(e),t=new f("*","multiply",[t,n],!0);return t}function G(e){for(var t=K(e),n=t,r=[];"/"===e.token&&cH(n);){if(r.push(OP({},e)),C(e),2!==e.tokenType){OP(e,r.pop());break}if(r.push(OP({},e)),C(e),3!==e.tokenType&&"("!==e.token){r.pop(),OP(e,r.pop());break}OP(e,r.pop()),r.pop(),n=K(e),t=new f("/","divide",[t,n])}return t}function K(e){var t,n,r,a;t=J(e);for(var i={"%":"mod",mod:"mod"};EH(i,e.token);)r=i[n=e.token],C(e),"%"===n&&1===e.tokenType&&"("!==e.token?t=new f("/","divide",[t,new l(100)],!1,!0):(a=[t,J(e)],t=new f(n,r,a));return t}function J(e){var t,a,s,o={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return EH(o,e.token)?(s=o[e.token],t=e.token,C(e),a=[J(e)],new f(t,s,a)):function(e){var t,a,s,o;return t=function(e){var t,a,s;t=function(e){var t=[];if(3===e.tokenType&&EH(e.extraNodes,e.token)){var a=e.extraNodes[e.token];if(E(e),"("===e.token){if(t=[],A(e),E(e),")"!==e.token)for(t.push(O(e));","===e.token;)E(e),t.push(O(e));if(")"!==e.token)throw ne(e,"Parenthesis ) expected");L(e),E(e)}return new a(t)}return function(e){var t;return 3===e.tokenType||1===e.tokenType&&e.token in w?(t=e.token,E(e),X(e,EH(M,t)?new l(M[t]):-1!==N.indexOf(t)?new l(n(t,"number")):new b(t))):function(e){var t;return'"'===e.token?(t=Z(e),X(e,new l(t))):function(e){var t;return"'"===e.token?(t=Q(e),X(e,new l(t))):function(e){var t,a,s,o;if("["===e.token){if(A(e),E(e),"]"!==e.token){var u=ee(e);if(";"===e.token){for(s=1,a=[u];";"===e.token;)E(e),a[s]=ee(e),s++;if("]"!==e.token)throw ne(e,"End of matrix ] expected");L(e),E(e),o=a[0].items.length;for(var c=1;c0},x.isDecimalMark=function(e,t){return"."===e&&"/"!==t&&"*"!==t&&"^"!==t},x.isDigitDot=function(e){return e>="0"&&e<="9"||"."===e},x.isDigit=function(e){return e>="0"&&e<="9"},x.isHexDigit=function(e){return e>="0"&&e<="9"||e>="a"&&e<="f"||e>="A"&&e<="F"},x})),L7=YH("resolve",["parse","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode"],(e=>{var{parse:t,ConstantNode:n,FunctionNode:r,OperatorNode:a,ParenthesisNode:i}=e;return function e(s,o){var u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Set;if(!o)return s;if(Yq(o)||(o=Fq(o)),xH(s)){if(u.has(s.name)){var l=Array.from(u).join(", ");throw new ReferenceError("recursive loop of variable definitions among {".concat(l,"}"))}var c=o.get(s.name);if(fH(c)){var p=new Set(u);return p.add(s.name),e(c,o,p)}return"number"==typeof c?t(String(c)):void 0!==c?new n(c):s}if(gH(s)){var d=s.args.map((function(t){return e(t,o,u)}));return new a(s.op,s.fn,d,s.implicit)}if(yH(s))return new i(e(s.content,o,u));if(dH(s)){var h=s.args.map((function(t){return e(t,o,u)}));return new r(s.name,h)}return s.map((t=>e(t,o,u)))}}));function $7(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function O7(e){for(var t=1;t{var{FunctionNode:t,OperatorNode:n,SymbolNode:r}=e,a=!0,i=!1,s="defaultF",o={add:{trivial:a,total:a,commutative:a,associative:a},unaryPlus:{trivial:a,total:a,commutative:a,associative:a},subtract:{trivial:i,total:a,commutative:i,associative:i},multiply:{trivial:a,total:a,commutative:a,associative:a},divide:{trivial:i,total:a,commutative:i,associative:i},paren:{trivial:a,total:a,commutative:a,associative:i},defaultF:{trivial:i,total:a,commutative:i,associative:i}};function u(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o,r=s;if("string"==typeof e?r=e:gH(e)?r=e.fn.toString():dH(e)?r=e.name:yH(e)&&(r="paren"),EH(n,r)){var a=n[r];if(EH(a,t))return a[t];if(EH(o,r))return o[r][t]}if(EH(n,s)){var i=n.defaultF;return EH(i,t)?i[t]:o.defaultF[t]}if(EH(o,r)){var u=o[r];if(EH(u,t))return u[t]}return o.defaultF[t]}function l(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o;return u(e,"associative",t)}function c(e,t){var n,r=[];return l(e,t)?(n=e.op,function e(t){for(var a=0;a1&&void 0!==arguments[1]?arguments[1]:o;return u(e,"commutative",t)},isAssociative:l,mergeContext:function(e,t){var n=O7({},e);for(var r in t)EH(e,r)?n[r]=O7(O7({},t[r]),e[r]):n[r]=t[r];return n},flatten:function e(t,n){if(!t.args||0===t.args.length)return t;t.args=c(t,n);for(var r=0;r2&&l(t,n)){for(var s=t.args.pop();t.args.length>0;)s=r([t.args.pop(),s]);t.args=s.args}}},unflattenl:function e(t,n){if(t.args&&0!==t.args.length){for(var r=p(t),a=t.args.length,i=0;i2&&l(t,n)){for(var s=t.args.shift();t.args.length>0;)s=r([s,t.args.shift()]);t.args=s.args}}},defaultContext:o,realContext:{divide:{total:i},log:{total:i}},positiveContext:{subtract:{total:i},abs:{trivial:a},log:{total:a}}}})),F7=YH("simplifyCore",["equal","isZero","add","subtract","multiply","divide","pow","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{equal:t,isZero:n,add:r,subtract:a,multiply:i,divide:s,pow:o,AccessorNode:u,ArrayNode:l,ConstantNode:c,FunctionNode:p,IndexNode:d,ObjectNode:h,OperatorNode:f,ParenthesisNode:m,SymbolNode:g}=e,y=new c(0),b=new c(1),{hasProperty:x,isCommutative:v}=R7({FunctionNode:p,OperatorNode:f,SymbolNode:g});return function e(m,g){var _=g?g.context:void 0;if(x(m,"trivial",_)){if(dH(m)&&1===m.args.length)return e(m.args[0],g);var w=!1,M=0;if(m.forEach((t=>{1==++M&&(w=e(t,g))})),1===M)return w}if(gH(m)&&m.isUnary()){var N=e(m.args[0],g);if("-"===m.op){if(gH(N)){if(N.isUnary()&&"-"===N.op)return N.args[0];if(N.isBinary()&&"subtract"===N.fn)return new f("-","subtract",[N.args[1],N.args[0]])}return new f(m.op,m.fn,[N])}}else{if(gH(m)&&m.isBinary()){var S=e(m.args[0],g),k=e(m.args[1],g);if("+"===m.op){if(cH(S)){if(n(S.value))return k;if(cH(k))return new c(r(S.value,k.value))}return cH(k)&&n(k.value)?S:gH(k)&&k.isUnary()&&"-"===k.op?new f("-","subtract",[S,k.args[0]]):new f(m.op,m.fn,k?[S,k]:[S])}if("-"===m.op){if(cH(S)&&k){if(cH(k))return new c(a(S.value,k.value));if(n(S.value))return new f("-","unaryMinus",[k])}if("subtract"===m.fn)return cH(k)&&n(k.value)?S:gH(k)&&k.isUnary()&&"-"===k.op?e(new f("+","add",[S,k.args[0]]),g):new f(m.op,m.fn,[S,k])}else{if("*"===m.op){if(cH(S)){if(n(S.value))return y;if(t(S.value,1))return k;if(cH(k))return new c(i(S.value,k.value))}if(cH(k)){if(n(k.value))return y;if(t(k.value,1))return S;if(gH(S)&&S.isBinary()&&S.op===m.op&&v(m,_)){var D=S.args[0];if(cH(D)){var T=new c(i(D.value,k.value));return new f(m.op,m.fn,[T,S.args[1]],m.implicit)}}return v(m,_)?new f(m.op,m.fn,[k,S],m.implicit):new f(m.op,m.fn,[S,k],m.implicit)}return new f(m.op,m.fn,[S,k],m.implicit)}if("/"===m.op){if(cH(S)){if(n(S.value))return y;if(cH(k)&&(t(k.value,1)||t(k.value,2)||t(k.value,4)))return new c(s(S.value,k.value))}return new f(m.op,m.fn,[S,k])}if("^"===m.op&&cH(k)){if(n(k.value))return b;if(t(k.value,1))return S;if(cH(S))return new c(o(S.value,k.value));if(gH(S)&&S.isBinary()&&"^"===S.op){var I=S.args[1];if(cH(I))return new f(m.op,m.fn,[S.args[0],new c(i(I.value,k.value))])}}}return new f(m.op,m.fn,[S,k])}if(dH(m))return new p(e(m.fn),m.args.map((t=>e(t,g))));if(sH(m))return new l(m.items.map((t=>e(t,g))));if(iH(m))return new u(e(m.object,g),e(m.index,g));if(hH(m))return new d(m.dimensions.map((t=>e(t,g))));if(mH(m)){var E={};for(var C in m.properties)E[C]=e(m.properties[C],g);return new h(E)}}return m}})),Y7="compile",z7=YH(Y7,["typed","parse"],(e=>{var{typed:t,parse:n}=e;return t(Y7,{string:function(e){return n(e).compile()},"Array | Matrix":function(e){return Gq(e,(function(e){return n(e).compile()}))}})})),B7=YH("Help",["parse"],(e=>{var{parse:t}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!e)throw new Error('Argument "doc" missing');this.doc=e}return n.prototype.type="Help",n.prototype.isHelp=!0,n.prototype.toString=function(){var e=this.doc||{},n="\n";if(e.name&&(n+="Name: "+e.name+"\n\n"),e.category&&(n+="Category: "+e.category+"\n\n"),e.description&&(n+="Description:\n "+e.description+"\n\n"),e.syntax&&(n+="Syntax:\n "+e.syntax.join("\n ")+"\n\n"),e.examples){n+="Examples:\n";for(var r={},a=0;a"mathjs"!==e)).forEach((n=>{t[n]=e[n]})),new n(t)},n.prototype.valueOf=n.prototype.toString,n}),{isClass:!0}),P7="leafCount",H7=YH(P7,["parse","typed"],(e=>{var{parse:t,typed:n}=e;function r(e){var t=0;return e.forEach((e=>{t+=r(e)})),t||1}return n(P7,{string:function(e){return this(t(e))},Node:function(e){return r(e)}})})),j7=YH("simplifyConstant",["typed","config","mathWithTransform","matrix","?fraction","?bignumber","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode"],(e=>{var{typed:t,config:n,mathWithTransform:r,matrix:a,fraction:i,bignumber:s,AccessorNode:o,ArrayNode:u,ConstantNode:l,FunctionNode:c,IndexNode:p,ObjectNode:d,OperatorNode:h,SymbolNode:f}=e,{isCommutative:m,isAssociative:g,allChildren:y,createMakeNodeFunction:b}=R7({FunctionNode:c,OperatorNode:h,SymbolNode:f});function x(e,t){return M(T(e,t))}function v(e){return BP(e)?e.valueOf():e instanceof Array?e.map(v):UP(e)?a(v(e.valueOf())):e}function _(e,t,n){try{return r[e].apply(null,t)}catch(a){return t=t.map(v),S(r[e].apply(null,t),n)}}var w=t({Fraction:function(e){var t,n=e.s*e.n;return t=n<0?new h("-","unaryMinus",[new l(-n)]):new l(n),1===e.d?t:new h("/","divide",[t,new l(e.d)])},number:function(e){return e<0?k(new l(-e)):new l(e)},BigNumber:function(e){return e<0?k(new l(-e)):new l(e)},Complex:function(e){throw new Error("Cannot convert Complex number to Node")},string:function(e){return new l(e)},Matrix:function(e){return new u(e.valueOf().map((e=>w(e))))}});function M(e){return fH(e)?e:w(e)}function N(e,t){if(t&&!1!==t.exactFractions&&isFinite(e)&&i){var n=i(e),r=t&&"number"==typeof t.fractionsLimit?t.fractionsLimit:1/0;if(n.valueOf()===e&&n.nT(e,t)));if(!n.some(fH))try{return _(e.name,n,t)}catch(e){}if("size"===e.name&&1===n.length&&sH(n[0])){for(var i=[],s=n[0];sH(s);)i.push(s.items.length),s=s.items[0];return a(i)}return new c(e.name,n.map(M))}case"OperatorNode":var h,f,v=e.fn.toString(),w=b(e);if(gH(e)&&e.isUnary())f=fH((h=[T(e.args[0],t)])[0])?w(h):_(v,h,t);else if(g(e,t.context))if(h=(h=y(e,t.context)).map((e=>T(e,t))),m(v,t.context)){for(var N=[],k=[],I=0;I1?(f=D(v,N,w,t),k.unshift(f),f=D(v,k,w,t)):f=D(v,h,w,t)}else f=D(v,h,w,t);else h=e.args.map((e=>T(e,t))),f=D(v,h,w,t);return f;case"ParenthesisNode":return T(e.content,t);case"AccessorNode":return function(e,t,n){if(!hH(t))return new o(M(e),M(t));if(sH(e)||UP(e)){for(var r=Array.from(t.dimensions);r.length>0;)if(cH(r[0])&&"string"!=typeof r[0].value){var i=S(r.shift().value,n);sH(e)?e=e.items[i-1]:(e=e.valueOf()[i-1])instanceof Array&&(e=a(e))}else{if(!(r.length>1&&cH(r[1])&&"string"!=typeof r[1].value))break;var s=S(r[1].value,n),c=[],d=sH(e)?e.items:e.valueOf();for(var h of d)if(sH(h))c.push(h.items[s-1]);else{if(!UP(e))break;c.push(h[s-1])}if(c.length!==d.length)break;e=sH(e)?new u(c):a(c),r.splice(1,1)}return r.length===t.dimensions.length?new o(M(e),t):r.length>0?(t=new p(r),new o(M(e),t)):e}if(mH(e)&&1===t.dimensions.length&&cH(t.dimensions[0])){var f=t.dimensions[0].value;return f in e.properties?e.properties[f]:new l}return new o(M(e),t)}(T(e.object,t),T(e.index,t),t);case"ArrayNode":var E=e.items.map((e=>T(e,t)));return E.some(fH)?new u(E.map(M)):a(E);case"IndexNode":return new p(e.dimensions.map((e=>x(e,t))));case"ObjectNode":var C={};for(var A in e.properties)C[A]=x(e.properties[A],t);return new d(C);default:throw new Error("Unimplemented node type in simplifyConstant: ".concat(e.type))}}return x})),U7=YH("simplify",["config","typed","parse","add","subtract","multiply","divide","pow","isZero","equal","resolve","simplifyCore","?fraction","?bignumber","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{config:t,typed:n,parse:r,add:a,subtract:i,multiply:s,divide:o,pow:u,isZero:l,equal:c,resolve:p,simplifyCore:d,fraction:h,bignumber:f,mathWithTransform:m,matrix:g,AccessorNode:y,ArrayNode:b,ConstantNode:x,FunctionNode:v,IndexNode:_,ObjectNode:w,OperatorNode:M,ParenthesisNode:N,SymbolNode:S}=e,k=j7({typed:n,config:t,mathWithTransform:m,matrix:g,fraction:h,bignumber:f,AccessorNode:y,ArrayNode:b,ConstantNode:x,FunctionNode:v,IndexNode:_,ObjectNode:w,OperatorNode:M,SymbolNode:S}),{hasProperty:D,isCommutative:T,isAssociative:I,mergeContext:E,flatten:C,unflattenr:A,unflattenl:L,createMakeNodeFunction:$,defaultContext:O,realContext:R,positiveContext:F}=R7({FunctionNode:v,OperatorNode:M,SymbolNode:S}),Y=n("simplify",{string:function(e){return this(r(e),this.rules,Rq(),{})},"string, Map | Object":function(e,t){return this(r(e),this.rules,t,{})},"string, Map | Object, Object":function(e,t,n){return this(r(e),this.rules,t,n)},"string, Array":function(e,t){return this(r(e),t,Rq(),{})},"string, Array, Map | Object":function(e,t,n){return this(r(e),t,n,{})},"string, Array, Map | Object, Object":function(e,t,n,a){return this(r(e),t,n,a)},"Node, Map | Object":function(e,t){return this(e,this.rules,t,{})},"Node, Map | Object, Object":function(e,t,n){return this(e,this.rules,t,n)},Node:function(e){return this(e,this.rules,Rq(),{})},"Node, Array":function(e,t){return this(e,t,Rq(),{})},"Node, Array, Map | Object":function(e,t,n){return this(e,t,n,{})},"Node, Array, Object, Object":function(e,t,n,r){return this(e,t,Fq(n),r)},"Node, Array, Map, Object":function(e,t,n,r){var a=r.consoleDebug;t=function(e,t){for(var n=[],r=0;r ").concat(t[l].r.toString()))),a){var d=i.toString({parenthesis:"all"});d!==u&&(console.log("Applying",c,"produced",d),u=d)}L(i,r.context)}o=i.toString({parenthesis:"all"})}return i}});function z(e){return e.transform((function(e,t,n){return yH(e)?z(e.content):e}))}Y.defaultContext=O,Y.realContext=R,Y.positiveContext=F;var B={true:!0,false:!0,e:!0,i:!0,Infinity:!0,LN2:!0,LN10:!0,LOG2E:!0,LOG10E:!0,NaN:!0,phi:!0,pi:!0,SQRT1_2:!0,SQRT2:!0,tau:!0};function P(e,t){var n={};if(e.s){var a=e.s.split("->");if(2!==a.length)throw SyntaxError("Could not parse rule: "+e.s);n.l=a[0],n.r=a[1]}else n.l=e.l,n.r=e.r;for(var i of(n.l=z(r(n.l)),n.r=z(r(n.r)),["imposeContext","repeat","assuming"]))i in e&&(n[i]=e[i]);if(e.evaluate&&(n.evaluate=r(e.evaluate)),I(n.l,t)){var s=$(n.l),o=new S("_p"+H++);n.expanded={},n.expanded.l=s([n.l.clone(),o]),C(n.expanded.l,t),A(n.expanded.l,t),n.expanded.r=s([n.r,o])}return n}Y.rules=[d,{l:"log(e)",r:"1"},{s:"n-n1 -> n+-n1",assuming:{subtract:{total:!0}}},{s:"n-n -> 0",assuming:{subtract:{total:!1}}},{s:"-(c*v) -> v * (-c)",assuming:{multiply:{commutative:!0},subtract:{total:!0}}},{s:"-(c*v) -> (-c) * v",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{s:"-(v*c) -> v * (-c)",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{l:"-(n1/n2)",r:"-n1/n2"},{l:"-v",r:"v * (-1)"},{l:"(n1 + n2)*(-1)",r:"n1*(-1) + n2*(-1)",repeat:!0},{l:"n/n1^n2",r:"n*n1^-n2"},{l:"n/n1",r:"n*n1^-1"},{s:"(n1*n2)^n3 -> n1^n3 * n2^n3",assuming:{multiply:{commutative:!0}}},{s:"(n1*n2)^(-1) -> n2^(-1) * n1^(-1)",assuming:{multiply:{commutative:!1}}},{s:"(n ^ n1) ^ n2 -> n ^ (n1 * n2)",assuming:{divide:{total:!0}}},{l:" v * ( v * n1 + n2)",r:"v^2 * n1 + v * n2"},{s:" v * (v^n4 * n1 + n2) -> v^(1+n4) * n1 + v * n2",assuming:{divide:{total:!0}}},{s:"v^n3 * ( v * n1 + n2) -> v^(n3+1) * n1 + v^n3 * n2",assuming:{divide:{total:!0}}},{s:"v^n3 * (v^n4 * n1 + n2) -> v^(n3+n4) * n1 + v^n3 * n2",assuming:{divide:{total:!0}}},{l:"n*n",r:"n^2"},{s:"n * n^n1 -> n^(n1+1)",assuming:{divide:{total:!0}}},{s:"n^n1 * n^n2 -> n^(n1+n2)",assuming:{divide:{total:!0}}},k,{s:"n+n -> 2*n",assuming:{add:{total:!0}}},{l:"n+-n",r:"0"},{l:"v*n + v",r:"v*(n+1)"},{l:"n3*n1 + n3*n2",r:"n3*(n1+n2)"},{l:"n3^(-n4)*n1 + n3 * n2",r:"n3^(-n4)*(n1 + n3^(n4+1) *n2)"},{l:"n3^(-n4)*n1 + n3^n5 * n2",r:"n3^(-n4)*(n1 + n3^(n4+n5)*n2)"},{s:"n*v + v -> (n+1)*v",assuming:{multiply:{commutative:!1}}},{s:"n1*n3 + n2*n3 -> (n1+n2)*n3",assuming:{multiply:{commutative:!1}}},{s:"n1*n3^(-n4) + n2 * n3 -> (n1 + n2*n3^(n4 + 1))*n3^(-n4)",assuming:{multiply:{commutative:!1}}},{s:"n1*n3^(-n4) + n2 * n3^n5 -> (n1 + n2*n3^(n4 + n5))*n3^(-n4)",assuming:{multiply:{commutative:!1}}},{l:"n*c + c",r:"(n+1)*c"},{s:"c*n + c -> c*(n+1)",assuming:{multiply:{commutative:!1}}},k,{s:"(-n)*n1 -> -(n*n1)",assuming:{subtract:{total:!0}}},{s:"n1*(-n) -> -(n1*n)",assuming:{subtract:{total:!0},multiply:{commutative:!1}}},{s:"c+v -> v+c",assuming:{add:{commutative:!0}},imposeContext:{add:{commutative:!1}}},{s:"v*c -> c*v",assuming:{multiply:{commutative:!0}},imposeContext:{multiply:{commutative:!1}}},{l:"n+-n1",r:"n-n1"},{s:"n*(n1^-1) -> n/n1",assuming:{multiply:{commutative:!0}}},{s:"n*n1^-n2 -> n/n1^n2",assuming:{multiply:{commutative:!0}}},{s:"n^-1 -> 1/n",assuming:{multiply:{commutative:!0}}},{l:"n^1",r:"n"},{s:"n*(n1/n2) -> (n*n1)/n2",assuming:{multiply:{associative:!0}}},{s:"n-(n1+n2) -> n-n1-n2",assuming:{addition:{associative:!0,commutative:!0}}},{l:"1*n",r:"n",imposeContext:{multiply:{commutative:!0}}},{s:"n1/(n2/n3) -> (n1*n3)/n2",assuming:{multiply:{associative:!0}}},{l:"n1/(-n2)",r:"-n1/n2"}];var H=0;function j(e,t,n){var r=e;if(e)for(var a=0;a=2&&2===e.args.length){for(var i=function(e,t){var n,r,a=[],i=$(e);if(T(e,t))for(var s=0;s1&&(u=i(e.args.slice(0,o))),n=1===(r=e.args.slice(o)).length?r[0]:i(r),a.push(i([u,n]))}return a}(t,n),s=[],o=0;o2)throw Error("Unexpected non-binary associative function: "+e.toString());return[]}for(var l=[],p=0;p2)throw new Error("permuting >2 commutative non-associative rule arguments not yet implemented");var h=V(e.args[0],t.args[1],n);if(0===h.length)return[];var f=V(e.args[1],t.args[0],n);if(0===f.length)return[];l=[h,f]}a=function(e){if(0===e.length)return e;for(var t=e.reduce(W),n=[],r={},a=0;a{var{parse:t,simplify:n,typed:r,OperatorNode:a}=e;return r(q7,{"string, string":function(e,n){return this(t(e),t(n),{})},"string, string, Object":function(e,n,r){return this(t(e),t(n),r)},"Node, string":function(e,n){return this(e,t(n),{})},"Node, string, Object":function(e,n,r){return this(e,t(n),r)},"string, Node":function(e,n){return this(t(e),n,{})},"string, Node, Object":function(e,n,r){return this(t(e),n,r)},"Node, Node":function(e,t){return this(e,t,{})},"Node, Node, Object":function(e,t,r){var i=new a("-","subtract",[e,t]),s=n(i,{},r);return cH(s)&&!s.value}})})),V7="evaluate",G7=YH(V7,["typed","parse"],(e=>{var{typed:t,parse:n}=e;return t(V7,{string:function(e){var t=Rq();return n(e).compile().evaluate(t)},"string, Map | Object":function(e,t){return n(e).compile().evaluate(t)},"Array | Matrix":function(e){var t=Rq();return Gq(e,(function(e){return n(e).compile().evaluate(t)}))},"Array | Matrix, Map | Object":function(e,t){return Gq(e,(function(e){return n(e).compile().evaluate(t)}))}})})),K7={name:"e",category:"Constants",syntax:["e"],description:"Euler's number, the base of the natural logarithm. Approximately equal to 2.71828",examples:["e","e ^ 2","exp(2)","log(e)"],seealso:["exp"]},J7={name:"pi",category:"Constants",syntax:["pi"],description:"The number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter, and is approximately equal to 3.14159",examples:["pi","sin(pi/2)"],seealso:["tau"]},X7={bignumber:{name:"bignumber",category:"Construction",syntax:["bignumber(x)"],description:"Create a big number from a number or string.",examples:["0.1 + 0.2","bignumber(0.1) + bignumber(0.2)",'bignumber("7.2")','bignumber("7.2e500")',"bignumber([0.1, 0.2, 0.3])"],seealso:["boolean","complex","fraction","index","matrix","string","unit"]},boolean:{name:"boolean",category:"Construction",syntax:["x","boolean(x)"],description:"Convert a string or number into a boolean.",examples:["boolean(0)","boolean(1)","boolean(3)",'boolean("true")','boolean("false")',"boolean([1, 0, 1, 1])"],seealso:["bignumber","complex","index","matrix","number","string","unit"]},complex:{name:"complex",category:"Construction",syntax:["complex()","complex(re, im)","complex(string)"],description:"Create a complex number.",examples:["complex()","complex(2, 3)",'complex("7 - 2i")'],seealso:["bignumber","boolean","index","matrix","number","string","unit"]},createUnit:{name:"createUnit",category:"Construction",syntax:["createUnit(definitions)","createUnit(name, definition)"],description:"Create a user-defined unit and register it with the Unit type.",examples:['createUnit("foo")','createUnit("knot", {definition: "0.514444444 m/s", aliases: ["knots", "kt", "kts"]})','createUnit("mph", "1 mile/hour")'],seealso:["unit","splitUnit"]},fraction:{name:"fraction",category:"Construction",syntax:["fraction(num)","fraction(matrix)","fraction(num,den)","fraction({n: num, d: den})"],description:"Create a fraction from a number or from integer numerator and denominator.",examples:["fraction(0.125)","fraction(1, 3) + fraction(2, 5)","fraction({n: 333, d: 53})","fraction([sqrt(9), sqrt(10), sqrt(11)])"],seealso:["bignumber","boolean","complex","index","matrix","string","unit"]},index:{name:"index",category:"Construction",syntax:["[start]","[start:end]","[start:step:end]","[start1, start 2, ...]","[start1:end1, start2:end2, ...]","[start1:step1:end1, start2:step2:end2, ...]"],description:"Create an index to get or replace a subset of a matrix",examples:["[]","[1, 2, 3]","A = [1, 2, 3; 4, 5, 6]","A[1, :]","A[1, 2] = 50","A[0:2, 0:2] = ones(2, 2)"],seealso:["bignumber","boolean","complex","matrix,","number","range","string","unit"]},matrix:{name:"matrix",category:"Construction",syntax:["[]","[a1, b1, ...; a2, b2, ...]","matrix()",'matrix("dense")',"matrix([...])"],description:"Create a matrix.",examples:["[]","[1, 2, 3]","[1, 2, 3; 4, 5, 6]","matrix()","matrix([3, 4])",'matrix([3, 4; 5, 6], "sparse")','matrix([3, 4; 5, 6], "sparse", "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","sparse"]},number:{name:"number",category:"Construction",syntax:["x","number(x)","number(unit, valuelessUnit)"],description:"Create a number or convert a string or boolean into a number.",examples:["2","2e3","4.05","number(2)",'number("7.2")',"number(true)","number([true, false, true, true])",'number(unit("52cm"), "m")'],seealso:["bignumber","boolean","complex","fraction","index","matrix","string","unit"]},sparse:{name:"sparse",category:"Construction",syntax:["sparse()","sparse([a1, b1, ...; a1, b2, ...])",'sparse([a1, b1, ...; a1, b2, ...], "number")'],description:"Create a sparse matrix.",examples:["sparse()","sparse([3, 4; 5, 6])",'sparse([3, 0; 5, 0], "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","matrix"]},splitUnit:{name:"splitUnit",category:"Construction",syntax:["splitUnit(unit: Unit, parts: Unit[])"],description:"Split a unit in an array of units whose sum is equal to the original unit.",examples:['splitUnit(1 m, ["feet", "inch"])'],seealso:["unit","createUnit"]},string:{name:"string",category:"Construction",syntax:['"text"',"string(x)"],description:"Create a string or convert a value to a string",examples:['"Hello World!"',"string(4.2)","string(3 + 2i)"],seealso:["bignumber","boolean","complex","index","matrix","number","unit"]},unit:{name:"unit",category:"Construction",syntax:["value unit","unit(value, unit)","unit(string)"],description:"Create a unit.",examples:["5.5 mm","3 inch",'unit(7.1, "kilogram")','unit("23 deg")'],seealso:["bignumber","boolean","complex","index","matrix","number","string"]},e:K7,E:K7,false:{name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]},i:{name:"i",category:"Constants",syntax:["i"],description:"Imaginary unit, defined as i*i=-1. A complex number is described as a + b*i, where a is the real part, and b is the imaginary part.",examples:["i","i * i","sqrt(-1)"],seealso:[]},Infinity:{name:"Infinity",category:"Constants",syntax:["Infinity"],description:"Infinity, a number which is larger than the maximum number that can be handled by a floating point number.",examples:["Infinity","1 / 0"],seealso:[]},LN2:{name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},LN10:{name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},LOG2E:{name:"LOG2E",category:"Constants",syntax:["LOG2E"],description:"Returns the base-2 logarithm of E, approximately equal to 1.442",examples:["LOG2E","log(e, 2)"],seealso:[]},LOG10E:{name:"LOG10E",category:"Constants",syntax:["LOG10E"],description:"Returns the base-10 logarithm of E, approximately equal to 0.434",examples:["LOG10E","log(e, 10)"],seealso:[]},NaN:{name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},null:{name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},pi:J7,PI:J7,phi:{name:"phi",category:"Constants",syntax:["phi"],description:"Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...",examples:["phi"],seealso:[]},SQRT1_2:{name:"SQRT1_2",category:"Constants",syntax:["SQRT1_2"],description:"Returns the square root of 1/2, approximately equal to 0.707",examples:["SQRT1_2","sqrt(1/2)"],seealso:[]},SQRT2:{name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},tau:{name:"tau",category:"Constants",syntax:["tau"],description:"Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi, approximately 6.2832.",examples:["tau","2 * pi"],seealso:["pi"]},true:{name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},version:{name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},speedOfLight:{description:"Speed of light in vacuum",examples:["speedOfLight"]},gravitationConstant:{description:"Newtonian constant of gravitation",examples:["gravitationConstant"]},planckConstant:{description:"Planck constant",examples:["planckConstant"]},reducedPlanckConstant:{description:"Reduced Planck constant",examples:["reducedPlanckConstant"]},magneticConstant:{description:"Magnetic constant (vacuum permeability)",examples:["magneticConstant"]},electricConstant:{description:"Electric constant (vacuum permeability)",examples:["electricConstant"]},vacuumImpedance:{description:"Characteristic impedance of vacuum",examples:["vacuumImpedance"]},coulomb:{description:"Coulomb's constant",examples:["coulomb"]},elementaryCharge:{description:"Elementary charge",examples:["elementaryCharge"]},bohrMagneton:{description:"Borh magneton",examples:["bohrMagneton"]},conductanceQuantum:{description:"Conductance quantum",examples:["conductanceQuantum"]},inverseConductanceQuantum:{description:"Inverse conductance quantum",examples:["inverseConductanceQuantum"]},magneticFluxQuantum:{description:"Magnetic flux quantum",examples:["magneticFluxQuantum"]},nuclearMagneton:{description:"Nuclear magneton",examples:["nuclearMagneton"]},klitzing:{description:"Von Klitzing constant",examples:["klitzing"]},bohrRadius:{description:"Borh radius",examples:["bohrRadius"]},classicalElectronRadius:{description:"Classical electron radius",examples:["classicalElectronRadius"]},electronMass:{description:"Electron mass",examples:["electronMass"]},fermiCoupling:{description:"Fermi coupling constant",examples:["fermiCoupling"]},fineStructure:{description:"Fine-structure constant",examples:["fineStructure"]},hartreeEnergy:{description:"Hartree energy",examples:["hartreeEnergy"]},protonMass:{description:"Proton mass",examples:["protonMass"]},deuteronMass:{description:"Deuteron Mass",examples:["deuteronMass"]},neutronMass:{description:"Neutron mass",examples:["neutronMass"]},quantumOfCirculation:{description:"Quantum of circulation",examples:["quantumOfCirculation"]},rydberg:{description:"Rydberg constant",examples:["rydberg"]},thomsonCrossSection:{description:"Thomson cross section",examples:["thomsonCrossSection"]},weakMixingAngle:{description:"Weak mixing angle",examples:["weakMixingAngle"]},efimovFactor:{description:"Efimov factor",examples:["efimovFactor"]},atomicMass:{description:"Atomic mass constant",examples:["atomicMass"]},avogadro:{description:"Avogadro's number",examples:["avogadro"]},boltzmann:{description:"Boltzmann constant",examples:["boltzmann"]},faraday:{description:"Faraday constant",examples:["faraday"]},firstRadiation:{description:"First radiation constant",examples:["firstRadiation"]},loschmidt:{description:"Loschmidt constant at T=273.15 K and p=101.325 kPa",examples:["loschmidt"]},gasConstant:{description:"Gas constant",examples:["gasConstant"]},molarPlanckConstant:{description:"Molar Planck constant",examples:["molarPlanckConstant"]},molarVolume:{description:"Molar volume of an ideal gas at T=273.15 K and p=101.325 kPa",examples:["molarVolume"]},sackurTetrode:{description:"Sackur-Tetrode constant at T=1 K and p=101.325 kPa",examples:["sackurTetrode"]},secondRadiation:{description:"Second radiation constant",examples:["secondRadiation"]},stefanBoltzmann:{description:"Stefan-Boltzmann constant",examples:["stefanBoltzmann"]},wienDisplacement:{description:"Wien displacement law constant",examples:["wienDisplacement"]},molarMass:{description:"Molar mass constant",examples:["molarMass"]},molarMassC12:{description:"Molar mass constant of carbon-12",examples:["molarMassC12"]},gravity:{description:"Standard acceleration of gravity (standard acceleration of free-fall on Earth)",examples:["gravity"]},planckLength:{description:"Planck length",examples:["planckLength"]},planckMass:{description:"Planck mass",examples:["planckMass"]},planckTime:{description:"Planck time",examples:["planckTime"]},planckCharge:{description:"Planck charge",examples:["planckCharge"]},planckTemperature:{description:"Planck temperature",examples:["planckTemperature"]},derivative:{name:"derivative",category:"Algebra",syntax:["derivative(expr, variable)","derivative(expr, variable, {simplify: boolean})"],description:"Takes the derivative of an expression expressed in parser Nodes. The derivative will be taken over the supplied variable in the second parameter. If there are multiple variables in the expression, it will return a partial derivative.",examples:['derivative("2x^3", "x")','derivative("2x^3", "x", {simplify: false})','derivative("2x^2 + 3x + 4", "x")','derivative("sin(2x)", "x")','f = parse("x^2 + x")','x = parse("x")',"df = derivative(f, x)","df.evaluate({x: 3})"],seealso:["simplify","parse","evaluate"]},lsolve:{name:"lsolve",category:"Algebra",syntax:["x=lsolve(L, b)"],description:"Finds one solution of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolveAll","lup","lusolve","usolve","matrix","sparse"]},lsolveAll:{name:"lsolveAll",category:"Algebra",syntax:["x=lsolveAll(L, b)"],description:"Finds all solutions of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolve","lup","lusolve","usolve","matrix","sparse"]},lup:{name:"lup",category:"Algebra",syntax:["lup(m)"],description:"Calculate the Matrix LU decomposition with partial pivoting. Matrix A is decomposed in three matrices (L, U, P) where P * A = L * U",examples:["lup([[2, 1], [1, 4]])","lup(matrix([[2, 1], [1, 4]]))","lup(sparse([[2, 1], [1, 4]]))"],seealso:["lusolve","lsolve","usolve","matrix","sparse","slu","qr"]},lusolve:{name:"lusolve",category:"Algebra",syntax:["x=lusolve(A, b)","x=lusolve(lu, b)"],description:"Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lusolve(a, b)"],seealso:["lup","slu","lsolve","usolve","matrix","sparse"]},leafCount:{name:"leafCount",category:"Algebra",syntax:["leafCount(expr)"],description:"Computes the number of leaves in the parse tree of the given expression",examples:['leafCount("e^(i*pi)-1")','leafCount(parse("{a: 22/7, b: 10^(1/2)}"))'],seealso:["simplify"]},resolve:{name:"resolve",category:"Algebra",syntax:["resolve(node, scope)"],description:"Recursively substitute variables in an expression tree.",examples:['resolve(parse("1 + x"), { x: 7 })','resolve(parse("size(text)"), { text: "Hello World" })','resolve(parse("x + y"), { x: parse("3z") })','resolve(parse("3x"), { x: parse("y+z"), z: parse("w^y") })'],seealso:["simplify","evaluate"],mayThrow:["ReferenceError"]},simplify:{name:"simplify",category:"Algebra",syntax:["simplify(expr)","simplify(expr, rules)"],description:"Simplify an expression tree.",examples:['simplify("3 + 2 / 4")','simplify("2x + x")','f = parse("x * (x + 2 + x)")',"simplified = simplify(f)","simplified.evaluate({x: 2})"],seealso:["simplifyCore","derivative","evaluate","parse","rationalize","resolve"]},simplifyCore:{name:"simplifyCore",category:"Algebra",syntax:["simplifyCore(node)"],description:"Perform simple one-pass simplifications on an expression tree.",examples:['simplifyCore(parse("0*x"))','simplifyCore(parse("(x+0)*2"))'],seealso:["simplify","evaluate"]},symbolicEqual:{name:"symbolicEqual",category:"Algebra",syntax:["symbolicEqual(expr1, expr2)","symbolicEqual(expr1, expr2, options)"],description:"Returns true if the difference of the expressions simplifies to 0",examples:['symbolicEqual("x*y","y*x")','symbolicEqual("abs(x^2)", "x^2")','symbolicEqual("abs(x)", "x", {context: {abs: {trivial: true}}})'],seealso:["simplify","evaluate"]},rationalize:{name:"rationalize",category:"Algebra",syntax:["rationalize(expr)","rationalize(expr, scope)","rationalize(expr, scope, detailed)"],description:"Transform a rationalizable expression in a rational fraction. If rational fraction is one variable polynomial then converts the numerator and denominator in canonical form, with decreasing exponents, returning the coefficients of numerator.",examples:['rationalize("2x/y - y/(x+1)")','rationalize("2x/y - y/(x+1)", true)'],seealso:["simplify"]},slu:{name:"slu",category:"Algebra",syntax:["slu(A, order, threshold)"],description:"Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U",examples:["slu(sparse([4.5, 0, 3.2, 0; 3.1, 2.9, 0, 0.9; 0, 1.7, 3, 0; 3.5, 0.4, 0, 1]), 1, 0.001)"],seealso:["lusolve","lsolve","usolve","matrix","sparse","lup","qr"]},usolve:{name:"usolve",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds one solution of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolveAll","lup","lusolve","lsolve","matrix","sparse"]},usolveAll:{name:"usolveAll",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds all solutions of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolve","lup","lusolve","lsolve","matrix","sparse"]},qr:{name:"qr",category:"Algebra",syntax:["qr(A)"],description:"Calculates the Matrix QR decomposition. Matrix `A` is decomposed in two matrices (`Q`, `R`) where `Q` is an orthogonal matrix and `R` is an upper triangular matrix.",examples:["qr([[1, -1, 4], [1, 4, -2], [1, 4, 2], [1, -1, 0]])"],seealso:["lup","slu","matrix"]},abs:{name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},add:{name:"add",category:"Operators",syntax:["x + y","add(x, y)"],description:"Add two values.",examples:["a = 2.1 + 3.6","a - 3.6","3 + 2i","3 cm + 2 inch",'"2.3" + "4"'],seealso:["subtract"]},cbrt:{name:"cbrt",category:"Arithmetic",syntax:["cbrt(x)","cbrt(x, allRoots)"],description:"Compute the cubic root value. If x = y * y * y, then y is the cubic root of x. When `x` is a number or complex number, an optional second argument `allRoots` can be provided to return all three cubic roots. If not provided, the principal root is returned",examples:["cbrt(64)","cube(4)","cbrt(-8)","cbrt(2 + 3i)","cbrt(8i)","cbrt(8i, true)","cbrt(27 m^3)"],seealso:["square","sqrt","cube","multiply"]},ceil:{name:"ceil",category:"Arithmetic",syntax:["ceil(x)"],description:"Round a value towards plus infinity. If x is complex, both real and imaginary part are rounded towards plus infinity.",examples:["ceil(3.2)","ceil(3.8)","ceil(-4.2)"],seealso:["floor","fix","round"]},cube:{name:"cube",category:"Arithmetic",syntax:["cube(x)"],description:"Compute the cube of a value. The cube of x is x * x * x.",examples:["cube(2)","2^3","2 * 2 * 2"],seealso:["multiply","square","pow"]},divide:{name:"divide",category:"Operators",syntax:["x / y","divide(x, y)"],description:"Divide two values.",examples:["a = 2 / 3","a * 3","4.5 / 2","3 + 4 / 2","(3 + 4) / 2","18 km / 4.5"],seealso:["multiply"]},dotDivide:{name:"dotDivide",category:"Operators",syntax:["x ./ y","dotDivide(x, y)"],description:"Divide two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a ./ b"],seealso:["multiply","dotMultiply","divide"]},dotMultiply:{name:"dotMultiply",category:"Operators",syntax:["x .* y","dotMultiply(x, y)"],description:"Multiply two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a .* b"],seealso:["multiply","divide","dotDivide"]},dotPow:{name:"dotPow",category:"Operators",syntax:["x .^ y","dotPow(x, y)"],description:"Calculates the power of x to y element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","a .^ 2"],seealso:["pow"]},exp:{name:"exp",category:"Arithmetic",syntax:["exp(x)"],description:"Calculate the exponent of a value.",examples:["exp(1.3)","e ^ 1.3","log(exp(1.3))","x = 2.4","(exp(i*x) == cos(x) + i*sin(x)) # Euler's formula"],seealso:["expm","expm1","pow","log"]},expm:{name:"expm",category:"Arithmetic",syntax:["exp(x)"],description:"Compute the matrix exponential, expm(A) = e^A. The matrix must be square. Not to be confused with exp(a), which performs element-wise exponentiation.",examples:["expm([[0,2],[0,0]])"],seealso:["exp"]},expm1:{name:"expm1",category:"Arithmetic",syntax:["expm1(x)"],description:"Calculate the value of subtracting 1 from the exponential value.",examples:["expm1(2)","pow(e, 2) - 1","log(expm1(2) + 1)"],seealso:["exp","pow","log"]},fix:{name:"fix",category:"Arithmetic",syntax:["fix(x)"],description:"Round a value towards zero. If x is complex, both real and imaginary part are rounded towards zero.",examples:["fix(3.2)","fix(3.8)","fix(-4.2)","fix(-4.8)"],seealso:["ceil","floor","round"]},floor:{name:"floor",category:"Arithmetic",syntax:["floor(x)"],description:"Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.",examples:["floor(3.2)","floor(3.8)","floor(-4.2)"],seealso:["ceil","fix","round"]},gcd:{name:"gcd",category:"Arithmetic",syntax:["gcd(a, b)","gcd(a, b, c, ...)"],description:"Compute the greatest common divisor.",examples:["gcd(8, 12)","gcd(-4, 6)","gcd(25, 15, -10)"],seealso:["lcm","xgcd"]},hypot:{name:"hypot",category:"Arithmetic",syntax:["hypot(a, b, c, ...)","hypot([a, b, c, ...])"],description:"Calculate the hypotenusa of a list with values. ",examples:["hypot(3, 4)","sqrt(3^2 + 4^2)","hypot(-2)","hypot([3, 4, 5])"],seealso:["abs","norm"]},lcm:{name:"lcm",category:"Arithmetic",syntax:["lcm(x, y)"],description:"Compute the least common multiple.",examples:["lcm(4, 6)","lcm(6, 21)","lcm(6, 21, 5)"],seealso:["gcd"]},log:{name:"log",category:"Arithmetic",syntax:["log(x)","log(x, base)"],description:"Compute the logarithm of a value. If no base is provided, the natural logarithm of x is calculated. If base if provided, the logarithm is calculated for the specified base. log(x, base) is defined as log(x) / log(base).",examples:["log(3.5)","a = log(2.4)","exp(a)","10 ^ 4","log(10000, 10)","log(10000) / log(10)","b = log(1024, 2)","2 ^ b"],seealso:["exp","log1p","log2","log10"]},log2:{name:"log2",category:"Arithmetic",syntax:["log2(x)"],description:"Calculate the 2-base of a value. This is the same as calculating `log(x, 2)`.",examples:["log2(0.03125)","log2(16)","log2(16) / log2(2)","pow(2, 4)"],seealso:["exp","log1p","log","log10"]},log1p:{name:"log1p",category:"Arithmetic",syntax:["log1p(x)","log1p(x, base)"],description:"Calculate the logarithm of a `value+1`",examples:["log1p(2.5)","exp(log1p(1.4))","pow(10, 4)","log1p(9999, 10)","log1p(9999) / log(10)"],seealso:["exp","log","log2","log10"]},log10:{name:"log10",category:"Arithmetic",syntax:["log10(x)"],description:"Compute the 10-base logarithm of a value.",examples:["log10(0.00001)","log10(10000)","10 ^ 4","log(10000) / log(10)","log(10000, 10)"],seealso:["exp","log"]},mod:{name:"mod",category:"Operators",syntax:["x % y","x mod y","mod(x, y)"],description:"Calculates the modulus, the remainder of an integer division.",examples:["7 % 3","11 % 2","10 mod 4","isOdd(x) = x % 2","isOdd(2)","isOdd(3)"],seealso:["divide"]},multiply:{name:"multiply",category:"Operators",syntax:["x * y","multiply(x, y)"],description:"multiply two values.",examples:["a = 2.1 * 3.4","a / 3.4","2 * 3 + 4","2 * (3 + 4)","3 * 2.1 km"],seealso:["divide"]},norm:{name:"norm",category:"Arithmetic",syntax:["norm(x)","norm(x, p)"],description:"Calculate the norm of a number, vector or matrix.",examples:["abs(-3.5)","norm(-3.5)","norm(3 - 4i)","norm([1, 2, -3], Infinity)","norm([1, 2, -3], -Infinity)","norm([3, 4], 2)","norm([[1, 2], [3, 4]], 1)",'norm([[1, 2], [3, 4]], "inf")','norm([[1, 2], [3, 4]], "fro")']},nthRoot:{name:"nthRoot",category:"Arithmetic",syntax:["nthRoot(a)","nthRoot(a, root)"],description:'Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation "x^root = A".',examples:["4 ^ 3","nthRoot(64, 3)","nthRoot(9, 2)","sqrt(9)"],seealso:["nthRoots","pow","sqrt"]},nthRoots:{name:"nthRoots",category:"Arithmetic",syntax:["nthRoots(A)","nthRoots(A, root)"],description:'Calculate the nth roots of a value. An nth root of a positive real number A, is a positive real solution of the equation "x^root = A". This function returns an array of complex values.',examples:["nthRoots(1)","nthRoots(1, 3)"],seealso:["sqrt","pow","nthRoot"]},pow:{name:"pow",category:"Operators",syntax:["x ^ y","pow(x, y)"],description:"Calculates the power of x to y, x^y.",examples:["2^3","2*2*2","1 + e ^ (pi * i)","math.pow([[1, 2], [4, 3]], 2)","math.pow([[1, 2], [4, 3]], -1)"],seealso:["multiply","nthRoot","nthRoots","sqrt"]},round:{name:"round",category:"Arithmetic",syntax:["round(x)","round(x, n)"],description:"round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.",examples:["round(3.2)","round(3.8)","round(-4.2)","round(-4.8)","round(pi, 3)","round(123.45678, 2)"],seealso:["ceil","floor","fix"]},sign:{name:"sign",category:"Arithmetic",syntax:["sign(x)"],description:"Compute the sign of a value. The sign of a value x is 1 when x>1, -1 when x<0, and 0 when x=0.",examples:["sign(3.5)","sign(-4.2)","sign(0)"],seealso:["abs"]},sqrt:{name:"sqrt",category:"Arithmetic",syntax:["sqrt(x)"],description:"Compute the square root value. If x = y * y, then y is the square root of x.",examples:["sqrt(25)","5 * 5","sqrt(-1)"],seealso:["square","sqrtm","multiply","nthRoot","nthRoots","pow"]},sqrtm:{name:"sqrtm",category:"Arithmetic",syntax:["sqrtm(x)"],description:"Calculate the principal square root of a square matrix. The principal square root matrix `X` of another matrix `A` is such that `X * X = A`.",examples:["sqrtm([[1, 2], [3, 4]])"],seealso:["sqrt","abs","square","multiply"]},square:{name:"square",category:"Arithmetic",syntax:["square(x)"],description:"Compute the square of a value. The square of x is x * x.",examples:["square(3)","sqrt(9)","3^2","3 * 3"],seealso:["multiply","pow","sqrt","cube"]},subtract:{name:"subtract",category:"Operators",syntax:["x - y","subtract(x, y)"],description:"subtract two values.",examples:["a = 5.3 - 2","a + 2","2/3 - 1/6","2 * 3 - 3","2.1 km - 500m"],seealso:["add"]},unaryMinus:{name:"unaryMinus",category:"Operators",syntax:["-x","unaryMinus(x)"],description:"Inverse the sign of a value. Converts booleans and strings to numbers.",examples:["-4.5","-(-5.6)",'-"22"'],seealso:["add","subtract","unaryPlus"]},unaryPlus:{name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},xgcd:{name:"xgcd",category:"Arithmetic",syntax:["xgcd(a, b)"],description:"Calculate the extended greatest common divisor for two values. The result is an array [d, x, y] with 3 entries, where d is the greatest common divisor, and d = x * a + y * b.",examples:["xgcd(8, 12)","gcd(8, 12)","xgcd(36163, 21199)"],seealso:["gcd","lcm"]},invmod:{name:"invmod",category:"Arithmetic",syntax:["invmod(a, b)"],description:"Calculate the (modular) multiplicative inverse of a modulo b. Solution to the equation ax ≣ 1 (mod b)",examples:["invmod(8, 12)=NaN","invmod(7, 13)=2","math.invmod(15151, 15122)=10429"],seealso:["gcd","xgcd"]},bitAnd:{name:"bitAnd",category:"Bitwise",syntax:["x & y","bitAnd(x, y)"],description:"Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0",examples:["5 & 3","bitAnd(53, 131)","[1, 12, 31] & 42"],seealso:["bitNot","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitNot:{name:"bitNot",category:"Bitwise",syntax:["~x","bitNot(x)"],description:"Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.",examples:["~1","~2","bitNot([2, -3, 4])"],seealso:["bitAnd","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitOr:{name:"bitOr",category:"Bitwise",syntax:["x | y","bitOr(x, y)"],description:"Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.",examples:["5 | 3","bitOr([1, 2, 3], 4)"],seealso:["bitAnd","bitNot","bitXor","leftShift","rightArithShift","rightLogShift"]},bitXor:{name:"bitXor",category:"Bitwise",syntax:["bitXor(x, y)"],description:"Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.",examples:["bitOr(1, 2)","bitXor([2, 3, 4], 4)"],seealso:["bitAnd","bitNot","bitOr","leftShift","rightArithShift","rightLogShift"]},leftShift:{name:"leftShift",category:"Bitwise",syntax:["x << y","leftShift(x, y)"],description:"Bitwise left logical shift of a value x by y number of bits.",examples:["4 << 1","8 >> 1"],seealso:["bitAnd","bitNot","bitOr","bitXor","rightArithShift","rightLogShift"]},rightArithShift:{name:"rightArithShift",category:"Bitwise",syntax:["x >> y","rightArithShift(x, y)"],description:"Bitwise right arithmetic shift of a value x by y number of bits.",examples:["8 >> 1","4 << 1","-12 >> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightLogShift"]},rightLogShift:{name:"rightLogShift",category:"Bitwise",syntax:["x >>> y","rightLogShift(x, y)"],description:"Bitwise right logical shift of a value x by y number of bits.",examples:["8 >>> 1","4 << 1","-12 >>> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightArithShift"]},bellNumbers:{name:"bellNumbers",category:"Combinatorics",syntax:["bellNumbers(n)"],description:"The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["bellNumbers(3)","bellNumbers(8)"],seealso:["stirlingS2"]},catalan:{name:"catalan",category:"Combinatorics",syntax:["catalan(n)"],description:"The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["catalan(3)","catalan(8)"],seealso:["bellNumbers"]},composition:{name:"composition",category:"Combinatorics",syntax:["composition(n, k)"],description:"The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.",examples:["composition(5, 3)"],seealso:["combinations"]},stirlingS2:{name:"stirlingS2",category:"Combinatorics",syntax:["stirlingS2(n, k)"],description:"he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.",examples:["stirlingS2(5, 3)"],seealso:["bellNumbers"]},config:{name:"config",category:"Core",syntax:["config()","config(options)"],description:"Get configuration or change configuration.",examples:["config()","1/3 + 1/4",'config({number: "Fraction"})',"1/3 + 1/4"],seealso:[]},import:{name:"import",category:"Core",syntax:["import(functions)","import(functions, options)"],description:"Import functions or constants from an object.",examples:["import({myFn: f(x)=x^2, myConstant: 32 })","myFn(2)","myConstant"],seealso:[]},typed:{name:"typed",category:"Core",syntax:["typed(signatures)","typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number": f(x)=x+x })',"double(2)",'double("hello")'],seealso:[]},arg:{name:"arg",category:"Complex",syntax:["arg(x)"],description:"Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).",examples:["arg(2 + 2i)","atan2(3, 2)","arg(2 + 3i)"],seealso:["re","im","conj","abs"]},conj:{name:"conj",category:"Complex",syntax:["conj(x)"],description:"Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.",examples:["conj(2 + 3i)","conj(2 - 3i)","conj(-5.2i)"],seealso:["re","im","abs","arg"]},re:{name:"re",category:"Complex",syntax:["re(x)"],description:"Get the real part of a complex number.",examples:["re(2 + 3i)","im(2 + 3i)","re(-5.2i)","re(2.4)"],seealso:["im","conj","abs","arg"]},im:{name:"im",category:"Complex",syntax:["im(x)"],description:"Get the imaginary part of a complex number.",examples:["im(2 + 3i)","re(2 + 3i)","im(-5.2i)","im(2.4)"],seealso:["re","conj","abs","arg"]},evaluate:{name:"evaluate",category:"Expression",syntax:["evaluate(expression)","evaluate([expr1, expr2, expr3, ...])"],description:"Evaluate an expression or an array with expressions.",examples:['evaluate("2 + 3")','evaluate("sqrt(" + 4 + ")")'],seealso:[]},help:{name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},distance:{name:"distance",category:"Geometry",syntax:["distance([x1, y1], [x2, y2])","distance([[x1, y1], [x2, y2]])"],description:"Calculates the Euclidean distance between two points.",examples:["distance([0,0], [4,4])","distance([[0,0], [4,4]])"],seealso:[]},intersect:{name:"intersect",category:"Geometry",syntax:["intersect(expr1, expr2, expr3, expr4)","intersect(expr1, expr2, expr3)"],description:"Computes the intersection point of lines and/or planes.",examples:["intersect([0, 0], [10, 10], [10, 0], [0, 10])","intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6])"],seealso:[]},and:{name:"and",category:"Logical",syntax:["x and y","and(x, y)"],description:"Logical and. Test whether two values are both defined with a nonzero/nonempty value.",examples:["true and false","true and true","2 and 4"],seealso:["not","or","xor"]},not:{name:"not",category:"Logical",syntax:["not x","not(x)"],description:"Logical not. Flips the boolean value of given argument.",examples:["not true","not false","not 2","not 0"],seealso:["and","or","xor"]},or:{name:"or",category:"Logical",syntax:["x or y","or(x, y)"],description:"Logical or. Test if at least one value is defined with a nonzero/nonempty value.",examples:["true or false","false or false","0 or 4"],seealso:["not","and","xor"]},xor:{name:"xor",category:"Logical",syntax:["x xor y","xor(x, y)"],description:"Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.",examples:["true xor false","false xor false","true xor true","0 xor 4"],seealso:["not","and","or"]},concat:{name:"concat",category:"Matrix",syntax:["concat(A, B, C, ...)","concat(A, B, C, ..., dim)"],description:"Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.",examples:["A = [1, 2; 5, 6]","B = [3, 4; 7, 8]","concat(A, B)","concat(A, B, 1)","concat(A, B, 2)"],seealso:["det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},count:{name:"count",category:"Matrix",syntax:["count(x)"],description:"Count the number of elements of a matrix, array or string.",examples:["a = [1, 2; 3, 4; 5, 6]","count(a)","size(a)",'count("hello world")'],seealso:["size"]},cross:{name:"cross",category:"Matrix",syntax:["cross(A, B)"],description:"Calculate the cross product for two vectors in three dimensional space.",examples:["cross([1, 1, 0], [0, 1, 1])","cross([3, -3, 1], [4, 9, 2])","cross([2, 3, 4], [5, 6, 7])"],seealso:["multiply","dot"]},column:{name:"column",category:"Matrix",syntax:["column(x, index)"],description:"Return a column from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","column(A, 1)","column(A, 2)"],seealso:["row","matrixFromColumns"]},ctranspose:{name:"ctranspose",category:"Matrix",syntax:["x'","ctranspose(x)"],description:"Complex Conjugate and Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","ctranspose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},det:{name:"det",category:"Matrix",syntax:["det(x)"],description:"Calculate the determinant of a matrix",examples:["det([1, 2; 3, 4])","det([-2, 2, 3; -1, 1, 3; 2, 0, -1])"],seealso:["concat","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},diag:{name:"diag",category:"Matrix",syntax:["diag(x)","diag(x, k)"],description:"Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.",examples:["diag(1:3)","diag(1:3, 1)","a = [1, 2, 3; 4, 5, 6; 7, 8, 9]","diag(a)"],seealso:["concat","det","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},diff:{name:"diff",category:"Matrix",syntax:["diff(arr)","diff(arr, dim)"],description:["Create a new matrix or array with the difference of the passed matrix or array.","Dim parameter is optional and used to indicant the dimension of the array/matrix to apply the difference","If no dimension parameter is passed it is assumed as dimension 0","Dimension is zero-based in javascript and one-based in the parser","Arrays must be 'rectangular' meaning arrays like [1, 2]","If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays"],examples:["diff([1, 2, 4, 7, 0])","diff([1, 2, 4, 7, 0], 0)","diff(matrix([1, 2, 4, 7, 0]))","diff([[1, 2], [3, 4]])","diff([[1, 2], [3, 4]], 0)","diff([[1, 2], [3, 4]], 1)","diff([[1, 2], [3, 4]], bignumber(1))","diff(matrix([[1, 2], [3, 4]]), 1)","diff([[1, 2], matrix([3, 4])], 1)"],seealso:["subtract","partitionSelect"]},dot:{name:"dot",category:"Matrix",syntax:["dot(A, B)","A * B"],description:"Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn",examples:["dot([2, 4, 1], [2, 2, 3])","[2, 4, 1] * [2, 2, 3]"],seealso:["multiply","cross"]},getMatrixDataType:{name:"getMatrixDataType",category:"Matrix",syntax:["getMatrixDataType(x)"],description:'Find the data type of all elements in a matrix or array, for example "number" if all items are a number and "Complex" if all values are complex numbers. If a matrix contains more than one data type, it will return "mixed".',examples:["getMatrixDataType([1, 2, 3])","getMatrixDataType([[5 cm], [2 inch]])",'getMatrixDataType([1, "text"])',"getMatrixDataType([1, bignumber(4)])"],seealso:["matrix","sparse","typeOf"]},identity:{name:"identity",category:"Matrix",syntax:["identity(n)","identity(m, n)","identity([m, n])"],description:"Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.",examples:["identity(3)","identity(3, 5)","a = [1, 2, 3; 4, 5, 6]","identity(size(a))"],seealso:["concat","det","diag","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},filter:{name:"filter",category:"Matrix",syntax:["filter(x, test)"],description:"Filter items in a matrix.",examples:["isPositive(x) = x > 0","filter([6, -2, -1, 4, 3], isPositive)","filter([6, -2, 0, 1, 0], x != 0)"],seealso:["sort","map","forEach"]},flatten:{name:"flatten",category:"Matrix",syntax:["flatten(x)"],description:"Flatten a multi dimensional matrix into a single dimensional matrix.",examples:["a = [1, 2, 3; 4, 5, 6]","size(a)","b = flatten(a)","size(b)"],seealso:["concat","resize","size","squeeze"]},forEach:{name:"forEach",category:"Matrix",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback function.",examples:["numberOfPets = {}","addPet(n) = numberOfPets[n] = (numberOfPets[n] ? numberOfPets[n]:0 ) + 1;",'forEach(["Dog","Cat","Cat"], addPet)',"numberOfPets"],seealso:["map","sort","filter"]},inv:{name:"inv",category:"Matrix",syntax:["inv(x)"],description:"Calculate the inverse of a matrix",examples:["inv([1, 2; 3, 4])","inv(4)","1 / 4"],seealso:["concat","det","diag","identity","ones","range","size","squeeze","subset","trace","transpose","zeros"]},pinv:{name:"pinv",category:"Matrix",syntax:["pinv(x)"],description:"Calculate the Moore–Penrose inverse of a matrix",examples:["pinv([1, 2; 3, 4])","pinv([[1, 0], [0, 1], [0, 1]])","pinv(4)"],seealso:["inv"]},eigs:{name:"eigs",category:"Matrix",syntax:["eigs(x)"],description:"Calculate the eigenvalues and eigenvectors of a real symmetric matrix",examples:["eigs([[5, 2.3], [2.3, 1]])"],seealso:["inv"]},kron:{name:"kron",category:"Matrix",syntax:["kron(x, y)"],description:"Calculates the kronecker product of 2 matrices or vectors.",examples:["kron([[1, 0], [0, 1]], [[1, 2], [3, 4]])","kron([1,1], [2,3,4])"],seealso:["multiply","dot","cross"]},matrixFromFunction:{name:"matrixFromFunction",category:"Matrix",syntax:["math.matrixFromFunction(size, fn)","math.matrixFromFunction(size, fn, format)","math.matrixFromFunction(size, fn, format, datatype)","math.matrixFromFunction(size, format, fn)","math.matrixFromFunction(size, format, datatype, fn)"],description:"Create a matrix by evaluating a generating function at each index.",examples:["f(I) = I[1] - I[2]","matrixFromFunction([3,3], f)","g(I) = I[1] - I[2] == 1 ? 4 : 0",'matrixFromFunction([100, 100], "sparse", g)',"matrixFromFunction([5], random)"],seealso:["matrix","matrixFromRows","matrixFromColumns","zeros"]},matrixFromRows:{name:"matrixFromRows",category:"Matrix",syntax:["math.matrixFromRows(...arr)","math.matrixFromRows(row1, row2)","math.matrixFromRows(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual rows.",examples:["matrixFromRows([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromColumns","matrixFromFunction","zeros"]},matrixFromColumns:{name:"matrixFromColumns",category:"Matrix",syntax:["math.matrixFromColumns(...arr)","math.matrixFromColumns(row1, row2)","math.matrixFromColumns(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual columns.",examples:["matrixFromColumns([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromRows","matrixFromFunction","zeros"]},map:{name:"map",category:"Matrix",syntax:["map(x, callback)"],description:"Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array.",examples:["map([1, 2, 3], square)"],seealso:["filter","forEach"]},ones:{name:"ones",category:"Matrix",syntax:["ones(m)","ones(m, n)","ones(m, n, p, ...)","ones([m])","ones([m, n])","ones([m, n, p, ...])"],description:"Create a matrix containing ones.",examples:["ones(3)","ones(3, 5)","ones([2,3]) * 4.5","a = [1, 2, 3; 4, 5, 6]","ones(size(a))"],seealso:["concat","det","diag","identity","inv","range","size","squeeze","subset","trace","transpose","zeros"]},partitionSelect:{name:"partitionSelect",category:"Matrix",syntax:["partitionSelect(x, k)","partitionSelect(x, k, compare)"],description:"Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.",examples:["partitionSelect([5, 10, 1], 2)",'partitionSelect(["C", "B", "A", "D"], 1)'],seealso:["sort"]},range:{name:"range",category:"Type",syntax:["start:end","start:step:end","range(start, end)","range(start, end, step)","range(string)"],description:"Create a range. Lower bound of the range is included, upper bound is excluded.",examples:["1:5","3:-1:-3","range(3, 7)","range(0, 12, 2)",'range("4:10")',"a = [1, 2, 3, 4; 5, 6, 7, 8]","a[1:2, 1:2]"],seealso:["concat","det","diag","identity","inv","ones","size","squeeze","subset","trace","transpose","zeros"]},resize:{name:"resize",category:"Matrix",syntax:["resize(x, size)","resize(x, size, defaultValue)"],description:"Resize a matrix.",examples:["resize([1,2,3,4,5], [3])","resize([1,2,3], [5])","resize([1,2,3], [5], -1)","resize(2, [2, 3])",'resize("hello", [8], "!")'],seealso:["size","subset","squeeze","reshape"]},reshape:{name:"reshape",category:"Matrix",syntax:["reshape(x, sizes)"],description:"Reshape a multi dimensional array to fit the specified dimensions.",examples:["reshape([1, 2, 3, 4, 5, 6], [2, 3])","reshape([[1, 2], [3, 4]], [1, 4])","reshape([[1, 2], [3, 4]], [4])"],seealso:["size","squeeze","resize"]},rotate:{name:"rotate",category:"Matrix",syntax:["rotate(w, theta)","rotate(w, theta, v)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotate([1, 0], math.pi / 2)",'rotate(matrix([1, 0]), unit("35deg"))','rotate([1, 0, 0], unit("90deg"), [0, 0, 1])','rotate(matrix([1, 0, 0]), unit("90deg"), matrix([0, 0, 1]))'],seealso:["matrix","rotationMatrix"]},rotationMatrix:{name:"rotationMatrix",category:"Matrix",syntax:["rotationMatrix(theta)","rotationMatrix(theta, v)","rotationMatrix(theta, v, format)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotationMatrix(pi / 2)",'rotationMatrix(unit("45deg"), [0, 0, 1])','rotationMatrix(1, matrix([0, 0, 1]), "sparse")'],seealso:["cos","sin"]},row:{name:"row",category:"Matrix",syntax:["row(x, index)"],description:"Return a row from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","row(A, 1)","row(A, 2)"],seealso:["column","matrixFromRows"]},size:{name:"size",category:"Matrix",syntax:["size(x)"],description:"Calculate the size of a matrix.",examples:["size(2.3)",'size("hello world")',"a = [1, 2; 3, 4; 5, 6]","size(a)","size(1:6)"],seealso:["concat","count","det","diag","identity","inv","ones","range","squeeze","subset","trace","transpose","zeros"]},sort:{name:"sort",category:"Matrix",syntax:["sort(x)","sort(x, compare)"],description:'Sort the items in a matrix. Compare can be a string "asc", "desc", "natural", or a custom sort function.',examples:["sort([5, 10, 1])",'sort(["C", "B", "A", "D"])',"sortByLength(a, b) = size(a)[1] - size(b)[1]",'sort(["Langdon", "Tom", "Sara"], sortByLength)','sort(["10", "1", "2"], "natural")'],seealso:["map","filter","forEach"]},squeeze:{name:"squeeze",category:"Matrix",syntax:["squeeze(x)"],description:"Remove inner and outer singleton dimensions from a matrix.",examples:["a = zeros(3,2,1)","size(squeeze(a))","b = zeros(1,1,3)","size(squeeze(b))"],seealso:["concat","det","diag","identity","inv","ones","range","size","subset","trace","transpose","zeros"]},subset:{name:"subset",category:"Matrix",syntax:["value(index)","value(index) = replacement","subset(value, [index])","subset(value, [index], replacement)"],description:"Get or set a subset of the entries of a matrix or characters of a string. Indexes are one-based. There should be one index specification for each dimension of the target. Each specification can be a single index, a list of indices, or a range in colon notation `l:u`. In a range, both the lower bound l and upper bound u are included; and if a bound is omitted it defaults to the most extreme valid value. The cartesian product of the indices specified in each dimension determines the target of the operation.",examples:["d = [1, 2; 3, 4]","e = []","e[1, 1:2] = [5, 6]","e[2, :] = [7, 8]","f = d * e","f[2, 1]","f[:, 1]","f[[1,2], [1,3]] = [9, 10; 11, 12]","f"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","trace","transpose","zeros"]},trace:{name:"trace",category:"Matrix",syntax:["trace(A)"],description:"Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.",examples:["A = [1, 2, 3; -1, 2, 3; 2, 0, 3]","trace(A)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","transpose","zeros"]},transpose:{name:"transpose",category:"Matrix",syntax:["x'","transpose(x)"],description:"Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","transpose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},zeros:{name:"zeros",category:"Matrix",syntax:["zeros(m)","zeros(m, n)","zeros(m, n, p, ...)","zeros([m])","zeros([m, n])","zeros([m, n, p, ...])"],description:"Create a matrix containing zeros.",examples:["zeros(3)","zeros(3, 5)","a = [1, 2, 3; 4, 5, 6]","zeros(size(a))"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose"]},fft:{name:"fft",category:"Matrix",syntax:["fft(x)"],description:"Calculate N-dimensional fourier transform",examples:["fft([[1, 0], [1, 0]])"],seealso:["ifft"]},ifft:{name:"ifft",category:"Matrix",syntax:["ifft(x)"],description:"Calculate N-dimensional inverse fourier transform",examples:["ifft([[2, 2], [0, 0]])"],seealso:["fft"]},combinations:{name:"combinations",category:"Probability",syntax:["combinations(n, k)"],description:"Compute the number of combinations of n items taken k at a time",examples:["combinations(7, 5)"],seealso:["combinationsWithRep","permutations","factorial"]},combinationsWithRep:{name:"combinationsWithRep",category:"Probability",syntax:["combinationsWithRep(n, k)"],description:"Compute the number of combinations of n items taken k at a time with replacements.",examples:["combinationsWithRep(7, 5)"],seealso:["combinations","permutations","factorial"]},factorial:{name:"factorial",category:"Probability",syntax:["n!","factorial(n)"],description:"Compute the factorial of a value",examples:["5!","5 * 4 * 3 * 2 * 1","3!"],seealso:["combinations","combinationsWithRep","permutations","gamma"]},gamma:{name:"gamma",category:"Probability",syntax:["gamma(n)"],description:"Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.",examples:["gamma(4)","3!","gamma(1/2)","sqrt(pi)"],seealso:["factorial"]},kldivergence:{name:"kldivergence",category:"Probability",syntax:["kldivergence(x, y)"],description:"Calculate the Kullback-Leibler (KL) divergence between two distributions.",examples:["kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])"],seealso:[]},lgamma:{name:"lgamma",category:"Probability",syntax:["lgamma(n)"],description:"Logarithm of the gamma function for real, positive numbers and complex numbers, using Lanczos approximation for numbers and Stirling series for complex numbers.",examples:["lgamma(4)","lgamma(1/2)","lgamma(math.i)","lgamma(complex(1.1, 2))"],seealso:["gamma"]},multinomial:{name:"multinomial",category:"Probability",syntax:["multinomial(A)"],description:"Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai > 0.",examples:["multinomial([1, 2, 1])"],seealso:["combinations","factorial"]},permutations:{name:"permutations",category:"Probability",syntax:["permutations(n)","permutations(n, k)"],description:"Compute the number of permutations of n items taken k at a time",examples:["permutations(5)","permutations(5, 3)"],seealso:["combinations","combinationsWithRep","factorial"]},pickRandom:{name:"pickRandom",category:"Probability",syntax:["pickRandom(array)","pickRandom(array, number)","pickRandom(array, weights)","pickRandom(array, number, weights)","pickRandom(array, weights, number)"],description:"Pick a random entry from a given array.",examples:["pickRandom(0:10)","pickRandom([1, 3, 1, 6])","pickRandom([1, 3, 1, 6], 2)","pickRandom([1, 3, 1, 6], [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], 2, [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], [2, 3, 2, 1], 2)"],seealso:["random","randomInt"]},random:{name:"random",category:"Probability",syntax:["random()","random(max)","random(min, max)","random(size)","random(size, max)","random(size, min, max)"],description:"Return a random number.",examples:["random()","random(10, 20)","random([2, 3])"],seealso:["pickRandom","randomInt"]},randomInt:{name:"randomInt",category:"Probability",syntax:["randomInt(max)","randomInt(min, max)","randomInt(size)","randomInt(size, max)","randomInt(size, min, max)"],description:"Return a random integer number",examples:["randomInt(10, 20)","randomInt([2, 3], 10)"],seealso:["pickRandom","random"]},compare:{name:"compare",category:"Relational",syntax:["compare(x, y)"],description:"Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compare(2, 3)","compare(3, 2)","compare(2, 2)","compare(5cm, 40mm)","compare(2, [1, 2, 3])"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compareNatural","compareText"]},compareNatural:{name:"compareNatural",category:"Relational",syntax:["compareNatural(x, y)"],description:"Compare two values of any type in a deterministic, natural way. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compareNatural(2, 3)","compareNatural(3, 2)","compareNatural(2, 2)","compareNatural(5cm, 40mm)",'compareNatural("2", "10")',"compareNatural(2 + 3i, 2 + 4i)","compareNatural([1, 2, 4], [1, 2, 3])","compareNatural([1, 5], [1, 2, 3])","compareNatural([1, 2], [1, 2])","compareNatural({a: 2}, {a: 4})"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare","compareText"]},compareText:{name:"compareText",category:"Relational",syntax:["compareText(x, y)"],description:"Compare two strings lexically. Comparison is case sensitive. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:['compareText("B", "A")','compareText("A", "B")','compareText("A", "A")','compareText("2", "10")','compare("2", "10")',"compare(2, 10)",'compareNatural("2", "10")','compareText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural"]},deepEqual:{name:"deepEqual",category:"Relational",syntax:["deepEqual(x, y)"],description:"Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.",examples:["deepEqual([1,3,4], [1,3,4])","deepEqual([1,3,4], [1,3])"],seealso:["equal","unequal","smaller","larger","smallerEq","largerEq","compare"]},equal:{name:"equal",category:"Relational",syntax:["x == y","equal(x, y)"],description:"Check equality of two values. Returns true if the values are equal, and false if not.",examples:["2+2 == 3","2+2 == 4","a = 3.2","b = 6-2.8","a == b","50cm == 0.5m"],seealso:["unequal","smaller","larger","smallerEq","largerEq","compare","deepEqual","equalText"]},equalText:{name:"equalText",category:"Relational",syntax:["equalText(x, y)"],description:"Check equality of two strings. Comparison is case sensitive. Returns true if the values are equal, and false if not.",examples:['equalText("Hello", "Hello")','equalText("a", "A")','equal("2e3", "2000")','equalText("2e3", "2000")','equalText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural","compareText","equal"]},larger:{name:"larger",category:"Relational",syntax:["x > y","larger(x, y)"],description:"Check if value x is larger than y. Returns true if x is larger than y, and false if not.",examples:["2 > 3","5 > 2*2","a = 3.3","b = 6-2.8","(a > b)","(b < a)","5 cm > 2 inch"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare"]},largerEq:{name:"largerEq",category:"Relational",syntax:["x >= y","largerEq(x, y)"],description:"Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.",examples:["2 >= 1+1","2 > 1+1","a = 3.2","b = 6-2.8","(a >= b)"],seealso:["equal","unequal","smallerEq","smaller","compare"]},smaller:{name:"smaller",category:"Relational",syntax:["x < y","smaller(x, y)"],description:"Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.",examples:["2 < 3","5 < 2*2","a = 3.3","b = 6-2.8","(a < b)","5 cm < 2 inch"],seealso:["equal","unequal","larger","smallerEq","largerEq","compare"]},smallerEq:{name:"smallerEq",category:"Relational",syntax:["x <= y","smallerEq(x, y)"],description:"Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.",examples:["2 <= 1+1","2 < 1+1","a = 3.2","b = 6-2.8","(a <= b)"],seealso:["equal","unequal","larger","smaller","largerEq","compare"]},unequal:{name:"unequal",category:"Relational",syntax:["x != y","unequal(x, y)"],description:"Check unequality of two values. Returns true if the values are unequal, and false if they are equal.",examples:["2+2 != 3","2+2 != 4","a = 3.2","b = 6-2.8","a != b","50cm != 0.5m","5 cm != 2 inch"],seealso:["equal","smaller","larger","smallerEq","largerEq","compare","deepEqual"]},setCartesian:{name:"setCartesian",category:"Set",syntax:["setCartesian(set1, set2)"],description:"Create the cartesian product of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays and the values will be sorted in ascending order before the operation.",examples:["setCartesian([1, 2], [3, 4])"],seealso:["setUnion","setIntersect","setDifference","setPowerset"]},setDifference:{name:"setDifference",category:"Set",syntax:["setDifference(set1, set2)"],description:"Create the difference of two (multi)sets: every element of set1, that is not the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setDifference([1, 2, 3, 4], [3, 4, 5, 6])","setDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setSymDifference"]},setDistinct:{name:"setDistinct",category:"Set",syntax:["setDistinct(set)"],description:"Collect the distinct elements of a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setDistinct([1, 1, 1, 2, 2, 3])"],seealso:["setMultiplicity"]},setIntersect:{name:"setIntersect",category:"Set",syntax:["setIntersect(set1, set2)"],description:"Create the intersection of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIntersect([1, 2, 3, 4], [3, 4, 5, 6])","setIntersect([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setDifference"]},setIsSubset:{name:"setIsSubset",category:"Set",syntax:["setIsSubset(set1, set2)"],description:"Check whether a (multi)set is a subset of another (multi)set: every element of set1 is the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIsSubset([1, 2], [3, 4, 5, 6])","setIsSubset([3, 4], [3, 4, 5, 6])"],seealso:["setUnion","setIntersect","setDifference"]},setMultiplicity:{name:"setMultiplicity",category:"Set",syntax:["setMultiplicity(element, set)"],description:"Count the multiplicity of an element in a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setMultiplicity(1, [1, 2, 2, 4])","setMultiplicity(2, [1, 2, 2, 4])"],seealso:["setDistinct","setSize"]},setPowerset:{name:"setPowerset",category:"Set",syntax:["setPowerset(set)"],description:"Create the powerset of a (multi)set: the powerset contains very possible subsets of a (multi)set. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setPowerset([1, 2, 3])"],seealso:["setCartesian"]},setSize:{name:"setSize",category:"Set",syntax:["setSize(set)","setSize(set, unique)"],description:'Count the number of elements of a (multi)set. When the second parameter "unique" is true, count only the unique values. A multi-dimension array will be converted to a single-dimension array before the operation.',examples:["setSize([1, 2, 2, 4])","setSize([1, 2, 2, 4], true)"],seealso:["setUnion","setIntersect","setDifference"]},setSymDifference:{name:"setSymDifference",category:"Set",syntax:["setSymDifference(set1, set2)"],description:"Create the symmetric difference of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setSymDifference([1, 2, 3, 4], [3, 4, 5, 6])","setSymDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setDifference"]},setUnion:{name:"setUnion",category:"Set",syntax:["setUnion(set1, set2)"],description:"Create the union of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setUnion([1, 2, 3, 4], [3, 4, 5, 6])","setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setIntersect","setDifference"]},erf:{name:"erf",category:"Special",syntax:["erf(x)"],description:"Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x",examples:["erf(0.2)","erf(-0.5)","erf(4)"],seealso:[]},cumsum:{name:"cumsum",category:"Statistics",syntax:["cumsum(a, b, c, ...)","cumsum(A)"],description:"Compute the cumulative sum of all values.",examples:["cumsum(2, 3, 4, 1)","cumsum([2, 3, 4, 1])","cumsum([1, 2; 3, 4])","cumsum([1, 2; 3, 4], 1)","cumsum([1, 2; 3, 4], 2)"],seealso:["max","mean","median","min","prod","std","sum","variance"]},mad:{name:"mad",category:"Statistics",syntax:["mad(a, b, c, ...)","mad(A)"],description:"Compute the median absolute deviation of a matrix or a list with values. The median absolute deviation is defined as the median of the absolute deviations from the median.",examples:["mad(10, 20, 30)","mad([1, 2, 3])"],seealso:["mean","median","std","abs"]},max:{name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dim)"],description:"Compute the maximum value of a list of values.",examples:["max(2, 3, 4, 1)","max([2, 3, 4, 1])","max([2, 5; 4, 3])","max([2, 5; 4, 3], 1)","max([2, 5; 4, 3], 2)","max(2.7, 7.1, -4.5, 2.0, 4.1)","min(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["mean","median","min","prod","std","sum","variance"]},mean:{name:"mean",category:"Statistics",syntax:["mean(a, b, c, ...)","mean(A)","mean(A, dim)"],description:"Compute the arithmetic mean of a list of values.",examples:["mean(2, 3, 4, 1)","mean([2, 3, 4, 1])","mean([2, 5; 4, 3])","mean([2, 5; 4, 3], 1)","mean([2, 5; 4, 3], 2)","mean([1.0, 2.7, 3.2, 4.0])"],seealso:["max","median","min","prod","std","sum","variance"]},median:{name:"median",category:"Statistics",syntax:["median(a, b, c, ...)","median(A)"],description:"Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.",examples:["median(5, 2, 7)","median([3, -1, 5, 7])"],seealso:["max","mean","min","prod","std","sum","variance","quantileSeq"]},min:{name:"min",category:"Statistics",syntax:["min(a, b, c, ...)","min(A)","min(A, dim)"],description:"Compute the minimum value of a list of values.",examples:["min(2, 3, 4, 1)","min([2, 3, 4, 1])","min([2, 5; 4, 3])","min([2, 5; 4, 3], 1)","min([2, 5; 4, 3], 2)","min(2.7, 7.1, -4.5, 2.0, 4.1)","max(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["max","mean","median","prod","std","sum","variance"]},mode:{name:"mode",category:"Statistics",syntax:["mode(a, b, c, ...)","mode(A)","mode(A, a, b, B, c, ...)"],description:"Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.",examples:["mode(2, 1, 4, 3, 1)","mode([1, 2.7, 3.2, 4, 2.7])","mode(1, 4, 6, 1, 6)"],seealso:["max","mean","min","median","prod","std","sum","variance"]},prod:{name:"prod",category:"Statistics",syntax:["prod(a, b, c, ...)","prod(A)"],description:"Compute the product of all values.",examples:["prod(2, 3, 4)","prod([2, 3, 4])","prod([2, 5; 4, 3])"],seealso:["max","mean","min","median","min","std","sum","variance"]},quantileSeq:{name:"quantileSeq",category:"Statistics",syntax:["quantileSeq(A, prob[, sorted])","quantileSeq(A, [prob1, prob2, ...][, sorted])","quantileSeq(A, N[, sorted])"],description:"Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probablity are: Number, BigNumber. \n\nIn case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.",examples:["quantileSeq([3, -1, 5, 7], 0.5)","quantileSeq([3, -1, 5, 7], [1/3, 2/3])","quantileSeq([3, -1, 5, 7], 2)","quantileSeq([-1, 3, 5, 7], 0.5, true)"],seealso:["mean","median","min","max","prod","std","sum","variance"]},std:{name:"std",category:"Statistics",syntax:["std(a, b, c, ...)","std(A)","std(A, normalization)"],description:'Compute the standard deviation of all values, defined as std(A) = sqrt(variance(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["std(2, 4, 6)","std([2, 4, 6, 8])",'std([2, 4, 6, 8], "uncorrected")','std([2, 4, 6, 8], "biased")',"std([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","prod","sum","variance"]},sum:{name:"sum",category:"Statistics",syntax:["sum(a, b, c, ...)","sum(A)"],description:"Compute the sum of all values.",examples:["sum(2, 3, 4, 1)","sum([2, 3, 4, 1])","sum([2, 5; 4, 3])"],seealso:["max","mean","median","min","prod","std","sum","variance"]},variance:{name:"variance",category:"Statistics",syntax:["variance(a, b, c, ...)","variance(A)","variance(A, normalization)"],description:'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["variance(2, 4, 6)","variance([2, 4, 6, 8])",'variance([2, 4, 6, 8], "uncorrected")','variance([2, 4, 6, 8], "biased")',"variance([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","min","prod","std","sum"]},acos:{name:"acos",category:"Trigonometry",syntax:["acos(x)"],description:"Compute the inverse cosine of a value in radians.",examples:["acos(0.5)","acos(cos(2.3))"],seealso:["cos","atan","asin"]},acosh:{name:"acosh",category:"Trigonometry",syntax:["acosh(x)"],description:"Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.",examples:["acosh(1.5)"],seealso:["cosh","asinh","atanh"]},acot:{name:"acot",category:"Trigonometry",syntax:["acot(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acot(0.5)","acot(cot(0.5))","acot(2)"],seealso:["cot","atan"]},acoth:{name:"acoth",category:"Trigonometry",syntax:["acoth(x)"],description:"Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.",examples:["acoth(2)","acoth(0.5)"],seealso:["acsch","asech"]},acsc:{name:"acsc",category:"Trigonometry",syntax:["acsc(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acsc(2)","acsc(csc(0.5))","acsc(0.5)"],seealso:["csc","asin","asec"]},acsch:{name:"acsch",category:"Trigonometry",syntax:["acsch(x)"],description:"Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",examples:["acsch(0.5)"],seealso:["asech","acoth"]},asec:{name:"asec",category:"Trigonometry",syntax:["asec(x)"],description:"Calculate the inverse secant of a value.",examples:["asec(0.5)","asec(sec(0.5))","asec(2)"],seealso:["acos","acot","acsc"]},asech:{name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},asin:{name:"asin",category:"Trigonometry",syntax:["asin(x)"],description:"Compute the inverse sine of a value in radians.",examples:["asin(0.5)","asin(sin(0.5))"],seealso:["sin","acos","atan"]},asinh:{name:"asinh",category:"Trigonometry",syntax:["asinh(x)"],description:"Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.",examples:["asinh(0.5)"],seealso:["acosh","atanh"]},atan:{name:"atan",category:"Trigonometry",syntax:["atan(x)"],description:"Compute the inverse tangent of a value in radians.",examples:["atan(0.5)","atan(tan(0.5))"],seealso:["tan","acos","asin"]},atanh:{name:"atanh",category:"Trigonometry",syntax:["atanh(x)"],description:"Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",examples:["atanh(0.5)"],seealso:["acosh","asinh"]},atan2:{name:"atan2",category:"Trigonometry",syntax:["atan2(y, x)"],description:"Computes the principal value of the arc tangent of y/x in radians.",examples:["atan2(2, 2) / pi","angle = 60 deg in rad","x = cos(angle)","y = sin(angle)","atan2(y, x)"],seealso:["sin","cos","tan"]},cos:{name:"cos",category:"Trigonometry",syntax:["cos(x)"],description:"Compute the cosine of x in radians.",examples:["cos(2)","cos(pi / 4) ^ 2","cos(180 deg)","cos(60 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["acos","sin","tan"]},cosh:{name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},cot:{name:"cot",category:"Trigonometry",syntax:["cot(x)"],description:"Compute the cotangent of x in radians. Defined as 1/tan(x)",examples:["cot(2)","1 / tan(2)"],seealso:["sec","csc","tan"]},coth:{name:"coth",category:"Trigonometry",syntax:["coth(x)"],description:"Compute the hyperbolic cotangent of x in radians.",examples:["coth(2)","1 / tanh(2)"],seealso:["sech","csch","tanh"]},csc:{name:"csc",category:"Trigonometry",syntax:["csc(x)"],description:"Compute the cosecant of x in radians. Defined as 1/sin(x)",examples:["csc(2)","1 / sin(2)"],seealso:["sec","cot","sin"]},csch:{name:"csch",category:"Trigonometry",syntax:["csch(x)"],description:"Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)",examples:["csch(2)","1 / sinh(2)"],seealso:["sech","coth","sinh"]},sec:{name:"sec",category:"Trigonometry",syntax:["sec(x)"],description:"Compute the secant of x in radians. Defined as 1/cos(x)",examples:["sec(2)","1 / cos(2)"],seealso:["cot","csc","cos"]},sech:{name:"sech",category:"Trigonometry",syntax:["sech(x)"],description:"Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)",examples:["sech(2)","1 / cosh(2)"],seealso:["coth","csch","cosh"]},sin:{name:"sin",category:"Trigonometry",syntax:["sin(x)"],description:"Compute the sine of x in radians.",examples:["sin(2)","sin(pi / 4) ^ 2","sin(90 deg)","sin(30 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["asin","cos","tan"]},sinh:{name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},tan:{name:"tan",category:"Trigonometry",syntax:["tan(x)"],description:"Compute the tangent of x in radians.",examples:["tan(0.5)","sin(0.5) / cos(0.5)","tan(pi / 4)","tan(45 deg)"],seealso:["atan","sin","cos"]},tanh:{name:"tanh",category:"Trigonometry",syntax:["tanh(x)"],description:"Compute the hyperbolic tangent of x in radians.",examples:["tanh(0.5)","sinh(0.5) / cosh(0.5)"],seealso:["sinh","cosh"]},to:{name:"to",category:"Units",syntax:["x to unit","to(x, unit)"],description:"Change the unit of a value.",examples:["5 inch to cm","3.2kg to g","16 bytes in bits"],seealso:[]},clone:{name:"clone",category:"Utils",syntax:["clone(x)"],description:"Clone a variable. Creates a copy of primitive variables,and a deep copy of matrices",examples:["clone(3.5)","clone(2 - 4i)","clone(45 deg)","clone([1, 2; 3, 4])",'clone("hello world")'],seealso:[]},format:{name:"format",category:"Utils",syntax:["format(value)","format(value, precision)"],description:"Format a value of any type as string.",examples:["format(2.3)","format(3 - 4i)","format([])","format(pi, 3)"],seealso:["print"]},bin:{name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},oct:{name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},hex:{name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},isNaN:{name:"isNaN",category:"Utils",syntax:["isNaN(x)"],description:"Test whether a value is NaN (not a number)",examples:["isNaN(2)","isNaN(0 / 0)","isNaN(NaN)","isNaN(Infinity)"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isInteger:{name:"isInteger",category:"Utils",syntax:["isInteger(x)"],description:"Test whether a value is an integer number.",examples:["isInteger(2)","isInteger(3.5)","isInteger([3, 0.5, -2])"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isNegative:{name:"isNegative",category:"Utils",syntax:["isNegative(x)"],description:"Test whether a value is negative: smaller than zero.",examples:["isNegative(2)","isNegative(0)","isNegative(-4)","isNegative([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isPositive","isZero"]},isNumeric:{name:"isNumeric",category:"Utils",syntax:["isNumeric(x)"],description:"Test whether a value is a numeric value. Returns true when the input is a number, BigNumber, Fraction, or boolean.",examples:["isNumeric(2)",'isNumeric("2")','hasNumericValue("2")',"isNumeric(0)","isNumeric(bignumber(500))","isNumeric(fraction(0.125))","isNumeric(2 + 3i)",'isNumeric([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","hasNumericValue"]},hasNumericValue:{name:"hasNumericValue",category:"Utils",syntax:["hasNumericValue(x)"],description:"Test whether a value is an numeric value. In case of a string, true is returned if the string contains a numeric value.",examples:["hasNumericValue(2)",'hasNumericValue("2")','isNumeric("2")',"hasNumericValue(0)","hasNumericValue(bignumber(500))","hasNumericValue(fraction(0.125))","hasNumericValue(2 + 3i)",'hasNumericValue([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","isNumeric"]},isPositive:{name:"isPositive",category:"Utils",syntax:["isPositive(x)"],description:"Test whether a value is positive: larger than zero.",examples:["isPositive(2)","isPositive(0)","isPositive(-4)","isPositive([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isPrime:{name:"isPrime",category:"Utils",syntax:["isPrime(x)"],description:"Test whether a value is prime: has no divisors other than itself and one.",examples:["isPrime(3)","isPrime(-2)","isPrime([2, 17, 100])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isZero:{name:"isZero",category:"Utils",syntax:["isZero(x)"],description:"Test whether a value is zero.",examples:["isZero(2)","isZero(0)","isZero(-4)","isZero([3, 0, -2, 0])"],seealso:["isInteger","isNumeric","isNegative","isPositive"]},print:{name:"print",category:"Utils",syntax:["print(template, values)","print(template, values, precision)"],description:"Interpolate values into a string template.",examples:['print("Lucy is $age years old", {age: 5})','print("The value of pi is $pi", {pi: pi}, 3)','print("Hello, $user.name!", {user: {name: "John"}})','print("Values: $0, $1, $2", [6, 9, 4])'],seealso:["format"]},typeOf:{name:"typeOf",category:"Utils",syntax:["typeOf(x)"],description:"Get the type of a variable.",examples:["typeOf(3.5)","typeOf(2 - 4i)","typeOf(45 deg)",'typeOf("hello world")'],seealso:["getMatrixDataType"]},numeric:{name:"numeric",category:"Utils",syntax:["numeric(x)"],description:"Convert a numeric input to a specific numeric type: number, BigNumber, or Fraction.",examples:['numeric("4")','numeric("4", "number")','numeric("4", "BigNumber")','numeric("4", "Fraction)','numeric(4, "Fraction")','numeric(fraction(2, 5), "number)'],seealso:["number","fraction","bignumber","string","format"]}},Z7="help",Q7=YH(Z7,["typed","mathWithTransform","Help"],(e=>{var{typed:t,mathWithTransform:n,Help:r}=e;return t(Z7,{any:function(e){var t,a=e;if("string"!=typeof e)for(t in n)if(EH(n,t)&&e===n[t]){a=t;break}var i=Tq(X7,a);if(!i){var s="function"==typeof a?a.name:a;throw new Error('No documentation found on "'+s+'"')}return new r(i)}})})),e8=YH("Parser",["evaluate"],(e=>{var{evaluate:t}=e;function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:Rq(),writable:!1})}return n.prototype.type="Parser",n.prototype.isParser=!0,n.prototype.evaluate=function(e){return t(e,this.scope)},n.prototype.get=function(e){if(this.scope.has(e))return this.scope.get(e)},n.prototype.getAll=function(){return function(e){if(e instanceof Oq)return e.wrappedObject;var t={};for(var n of e.keys())Iq(t,n,e.get(n));return t}(this.scope)},n.prototype.getAllAsMap=function(){return this.scope},n.prototype.set=function(e,t){return this.scope.set(e,t),t},n.prototype.remove=function(e){this.scope.delete(e)},n.prototype.clear=function(){this.scope.clear()},n}),{isClass:!0}),t8="rationalize",n8=YH(t8,["config","typed","equal","isZero","add","subtract","multiply","divide","pow","parse","simplifyCore","simplify","?bignumber","?fraction","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode","ParenthesisNode"],(e=>{var{config:t,typed:n,equal:r,isZero:a,add:i,subtract:s,multiply:o,divide:u,pow:l,parse:c,simplifyCore:p,simplify:d,fraction:h,bignumber:f,mathWithTransform:m,matrix:g,AccessorNode:y,ArrayNode:b,ConstantNode:x,FunctionNode:v,IndexNode:_,ObjectNode:w,OperatorNode:M,SymbolNode:N,ParenthesisNode:S}=e,k=j7({typed:n,config:t,mathWithTransform:m,matrix:g,fraction:h,bignumber:f,AccessorNode:y,ArrayNode:b,ConstantNode:x,FunctionNode:v,IndexNode:_,ObjectNode:w,OperatorNode:M,SymbolNode:N});return n(t8,{string:function(e){return this(c(e),{},!1)},"string, boolean":function(e,t){return this(c(e),{},t)},"string, Object":function(e,t){return this(c(e),t,!1)},"string, Object, boolean":function(e,t,n){return this(c(e),t,n)},Node:function(e){return this(e,{},!1)},"Node, boolean":function(e,t){return this(e,{},t)},"Node, Object":function(e,t){return this(e,t,!1)},"Node, Object, boolean":function(e,t,n){var r=function(){var e=[p,{l:"n+n",r:"2*n"},{l:"n+-n",r:"0"},k,{l:"n*(n1^-1)",r:"n/n1"},{l:"n*n1^-n2",r:"n/n1^n2"},{l:"n1^-1",r:"1/n1"},{l:"n*(n1/n2)",r:"(n*n1)/n2"},{l:"1*n",r:"n"}],t=[{l:"(-n1)/(-n2)",r:"n1/n2"},{l:"(-n1)*(-n2)",r:"n1*n2"},{l:"n1--n2",r:"n1+n2"},{l:"n1-n2",r:"n1+(-n2)"},{l:"(n1+n2)*n3",r:"(n1*n3 + n2*n3)"},{l:"n1*(n2+n3)",r:"(n1*n2+n1*n3)"},{l:"c1*n + c2*n",r:"(c1+c2)*n"},{l:"c1*n + n",r:"(c1+1)*n"},{l:"c1*n - c2*n",r:"(c1-c2)*n"},{l:"c1*n - n",r:"(c1-1)*n"},{l:"v/c",r:"(1/c)*v"},{l:"v/-c",r:"-(1/c)*v"},{l:"-v*-c",r:"c*v"},{l:"-v*c",r:"-c*v"},{l:"v*-c",r:"-c*v"},{l:"v*c",r:"c*v"},{l:"-(-n1*n2)",r:"(n1*n2)"},{l:"-(n1*n2)",r:"(-n1*n2)"},{l:"-(-n1+n2)",r:"(n1-n2)"},{l:"-(n1+n2)",r:"(-n1-n2)"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"},{l:"-(-n1/n2)",r:"(n1/n2)"},{l:"-(n1/n2)",r:"(-n1/n2)"}],n=[{l:"(n1/(n2/n3))",r:"((n1*n3)/n2)"},{l:"(n1/n2/n3)",r:"(n1/(n2*n3))"}],r={};return r.firstRules=e.concat(t,n),r.distrDivRules=[{l:"(n1/n2 + n3/n4)",r:"((n1*n4 + n3*n2)/(n2*n4))"},{l:"(n1/n2 + n3)",r:"((n1 + n3*n2)/n2)"},{l:"(n1 + n2/n3)",r:"((n1*n3 + n2)/n3)"}],r.sucDivRules=n,r.firstRulesAgain=e.concat(t),r.finalRules=[p,{l:"n*-n",r:"-n^2"},{l:"n*n",r:"n^2"},k,{l:"n*-n^n1",r:"-n^(n1+1)"},{l:"n*n^n1",r:"n^(n1+1)"},{l:"n^n1*-n^n2",r:"-n^(n1+n2)"},{l:"n^n1*n^n2",r:"n^(n1+n2)"},{l:"n^n1*-n",r:"-n^(n1+1)"},{l:"n^n1*n",r:"n^(n1+1)"},{l:"n^n1/-n",r:"-n^(n1-1)"},{l:"n^n1/n",r:"n^(n1-1)"},{l:"n/-n^n1",r:"-n^(1-n1)"},{l:"n/n^n1",r:"n^(1-n1)"},{l:"n^n1/-n^n2",r:"n^(n1-n2)"},{l:"n^n1/n^n2",r:"n^(n1-n2)"},{l:"n1+(-n2*n3)",r:"n1-n2*n3"},{l:"v*(-c)",r:"-c*v"},{l:"n1+-n2",r:"n1-n2"},{l:"v*c",r:"c*v"},{l:"(n1^n2)^n3",r:"(n1^(n2*n3))"}],r}(),a=function(e,t,n,r){var a=[],i=d(e,r,t,{exactFractions:!1}),s="+-*"+((n=!!n)?"/":"");!function e(t){var n=t.type;if("FunctionNode"===n)throw new Error("There is an unsolved function call");if("OperatorNode"===n)if("^"===t.op){if("ConstantNode"!==t.args[1].type||!jH(parseFloat(t.args[1].value)))throw new Error("There is a non-integer exponent");e(t.args[0])}else{if(-1===s.indexOf(t.op))throw new Error("Operator "+t.op+" invalid in polynomial expression");for(var r=0;r=1){var u,l;e=D(e);var c,h=!0,f=!1;for(e=d(e,r.firstRules,{},s);l=h?r.distrDivRules:r.sucDivRules,h=!h,(c=(e=d(e,l,{},o)).toString())!==u;)f=!0,u=c;f&&(e=d(e,r.firstRulesAgain,{},s)),e=d(e,r.finalRules,{},s)}var m=[],g={};return"OperatorNode"===e.type&&e.isBinary()&&"/"===e.op?(1===i&&(e.args[0]=T(e.args[0],m),e.args[1]=T(e.args[1])),n&&(g.numerator=e.args[0],g.denominator=e.args[1])):(1===i&&(e=T(e,m)),n&&(g.numerator=e,g.denominator=null)),n?(g.coefficients=m,g.variables=a.variables,g.expression=e,g):e}});function D(e,t,n){var r=e.type,a=arguments.length>1;if("OperatorNode"===r&&e.isBinary()){var i,s=!1;if("^"===e.op&&("ParenthesisNode"!==e.args[0].type&&"OperatorNode"!==e.args[0].type||"ConstantNode"!==e.args[1].type||(s=(i=parseFloat(e.args[1].value))>=2&&jH(i))),s){if(i>2){var o=e.args[0],u=new M("^","pow",[e.args[0].cloneDeep(),new x(i-1)]);e=new M("*","multiply",[o,u])}else e=new M("*","multiply",[e.args[0],e.args[0].cloneDeep()]);a&&("content"===n?t.content=e:t.args[n]=e)}}if("ParenthesisNode"===r)D(e.content,e,"content");else if("ConstantNode"!==r&&"SymbolNode"!==r)for(var l=0;ln&&(t[l]=0),t[l]+=s.cte*("+"===s.oper?1:-1),void(n=Math.max(l,n))}s.cte=l,""===s.fire&&(t[0]+=s.cte*("+"===s.oper?1:-1))}}(e,null,{cte:1,oper:"+",fire:""});for(var a,i=!0,s=n=t.length-1;s>=0;s--)if(0!==t[s]){var o=new x(i?t[s]:Math.abs(t[s])),u=t[s]<0?"-":"+";if(s>0){var l=new N(r);if(s>1){var c=new x(s);l=new M("^","pow",[l,c])}o=-1===t[s]&&i?new M("-","unaryMinus",[l]):1===Math.abs(t[s])?l:new M("*","multiply",[o,l])}a=i?o:"+"===u?new M("+","add",[a,o]):new M("-","subtract",[a,o]),i=!1}return i?new x(0):a}})),r8=YH("derivative",["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{typed:t,config:n,parse:r,simplify:a,equal:i,isZero:s,numeric:o,ConstantNode:u,FunctionNode:l,OperatorNode:c,ParenthesisNode:p,SymbolNode:d}=e,h=t("derivative",{"Node, SymbolNode, Object":function(e,t,n){var r={};m(r,e,t.name);var i=g(e,r);return n.simplify?a(i):i},"Node, SymbolNode":function(e,t){return this(e,t,{simplify:!0})},"string, SymbolNode":function(e,t){return this(r(e),t)},"string, SymbolNode, Object":function(e,t,n){return this(r(e),t,n)},"string, string":function(e,t){return this(r(e),r(t))},"string, string, Object":function(e,t,n){return this(r(e),r(t),n)},"Node, string":function(e,t){return this(e,r(t))},"Node, string, Object":function(e,t,n){return this(e,r(t),n)}});h._simplify=!0,h.toTex=function(e){return f.apply(null,e.args)};var f=t("_derivTex",{"Node, SymbolNode":function(e,t){return cH(e)&&"string"===_H(e.value)?f(r(e.value).toString(),t.toString(),1):f(e.toTex(),t.toString(),1)},"Node, ConstantNode":function(e,t){if("string"===_H(t.value))return f(e,r(t.value));throw new Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(e,t,n){return f(e.toString(),t.name,n.value)},"string, string, number":function(e,t,n){return(1===n?"{d\\over d"+t+"}":"{d^{"+n+"}\\over d"+t+"^{"+n+"}}")+"\\left[".concat(e,"\\right]")}}),m=t("constTag",{"Object, ConstantNode, string":function(e,t){return e[t]=!0,!0},"Object, SymbolNode, string":function(e,t,n){return t.name!==n&&(e[t]=!0,!0)},"Object, ParenthesisNode, string":function(e,t,n){return m(e,t.content,n)},"Object, FunctionAssignmentNode, string":function(e,t,n){return-1===t.params.indexOf(n)?(e[t]=!0,!0):m(e,t.expr,n)},"Object, FunctionNode | OperatorNode, string":function(e,t,n){if(t.args.length>0){for(var r=m(e,t.args[0],n),a=1;a0){var r=e.args.filter((function(e){return void 0===t[e]})),a=1===r.length?r[0]:new c("*","multiply",r),o=n.concat(g(a,t));return new c("*","multiply",o)}return new c("+","add",e.args.map((function(n){return new c("*","multiply",e.args.map((function(e){return e===n?g(e,t):e.clone()})))})))}if("/"===e.op&&e.isBinary()){var u=e.args[0],p=e.args[1];return void 0!==t[p]?new c("/","divide",[g(u,t),p]):void 0!==t[u]?new c("*","multiply",[new c("-","unaryMinus",[u]),new c("/","divide",[g(p,t),new c("^","pow",[p.clone(),y(2)])])]):new c("/","divide",[new c("-","subtract",[new c("*","multiply",[g(u,t),p.clone()]),new c("*","multiply",[u.clone(),g(p,t)])]),new c("^","pow",[p.clone(),y(2)])])}if("^"===e.op&&e.isBinary()){var d=e.args[0],h=e.args[1];if(void 0!==t[d])return cH(d)&&(s(d.value)||i(d.value,1))?y(0):new c("*","multiply",[e,new c("*","multiply",[new l("log",[d.clone()]),g(h.clone(),t)])]);if(void 0!==t[h]){if(cH(h)){if(s(h.value))return y(0);if(i(h.value,1))return g(d,t)}var f=new c("^","pow",[d.clone(),new c("-","subtract",[h,y(1)])]);return new c("*","multiply",[h.clone(),new c("*","multiply",[g(d,t),f])])}return new c("*","multiply",[new c("^","pow",[d.clone(),h.clone()]),new c("+","add",[new c("*","multiply",[g(d,t),new c("/","divide",[h.clone(),d.clone()])]),new c("*","multiply",[g(h,t),new l("log",[d.clone()])])])])}throw new Error('Operator "'+e.op+'" is not supported by derivative, or a wrong number of arguments is passed')}});function y(e,t){return new u(o(e,t||n.number))}return h})),a8="parser",i8=YH(a8,["typed","Parser"],(e=>{var{typed:t,Parser:n}=e;return t(a8,{"":function(){return new n}})}));function s8(e,t,n){var r=e.filter((function(e){return xH(e)&&!(e.name in t)&&!n.has(e.name)}))[0];if(!r)throw new Error('No undefined variable found in inline expression "'+e+'"');var a=r.name,i=I7(n),s=e.compile();return function(e){return i.set(a,e),s.evaluate(i)}}var o8=YH("filter",["typed"],(e=>{var{typed:t}=e;function n(e,t,n){var a,i;return e[0]&&(a=e[0].compile().evaluate(n)),e[1]&&(i=xH(e[1])||pH(e[1])?e[1].compile().evaluate(n):s8(e[1],t,n)),r(a,i)}n.rawArgs=!0;var r=t("filter",{"Array, function":u8,"Matrix, function":function(e,t){return e.create(u8(e.toArray(),t))},"Array, RegExp":xq,"Matrix, RegExp":function(e,t){return e.create(xq(e.toArray(),t))}});return n}),{isTransformFunction:!0});function u8(e,t){var n=fj(t);return bq(e,(function(e,r,a){return 1===n?t(e):2===n?t(e,[r+1]):t(e,[r+1],a)}))}var l8=YH("forEach",["typed"],(e=>{var{typed:t}=e;function n(e,t,n){var a,i;return e[0]&&(a=e[0].compile().evaluate(n)),e[1]&&(i=xH(e[1])||pH(e[1])?e[1].compile().evaluate(n):s8(e[1],t,n)),r(a,i)}n.rawArgs=!0;var r=t("forEach",{"Array | Matrix, function":function(e,t){var n=fj(t);!function r(a,i){Array.isArray(a)?yq(a,(function(e,t){r(e,i.concat(t+1))})):1===n?t(a):2===n?t(a,i):t(a,i,e)}(e.valueOf(),[])}});return n}),{isTransformFunction:!0}),c8=YH("map",["typed"],(e=>{var{typed:t}=e;function n(e,t,n){var a,i;return e[0]&&(a=e[0].compile().evaluate(n)),e[1]&&(i=xH(e[1])||pH(e[1])?e[1].compile().evaluate(n):s8(e[1],t,n)),r(a,i)}n.rawArgs=!0;var r=t("map",{"Array, function":function(e,t){return p8(e,t,e)},"Matrix, function":function(e,t){return e.create(p8(e.valueOf(),t,e))}});return n}),{isTransformFunction:!0});function p8(e,t,n){var r=fj(t);return function e(a,i){return Array.isArray(a)?gq(a,(function(t,n){return e(t,i.concat(n+1))})):1===r?t(a):2===r?t(a,i):t(a,i,n)}(e,[])}var d8=YH("apply",["typed","isInteger"],(e=>{var{typed:t,isInteger:n}=e,r=vK({typed:t,isInteger:n});return t("apply",{"...any":function(e){var t=e[1];FP(t)?e[1]=t-1:YP(t)&&(e[1]=t.minus(1));try{return r.apply(null,e)}catch(e){throw M7(e)}}})}),{isTransformFunction:!0});function h8(e){if(2===e.length&&qP(e[0])){var t=(e=e.slice())[1];FP(t)?e[1]=t-1:YP(t)&&(e[1]=t.minus(1))}return e}var f8="diff",m8=YH(f8,["typed","matrix","subtract","number","bignumber"],(e=>{var{typed:t,matrix:n,subtract:r,number:a,bignumber:i}=e,s=DZ({typed:t,matrix:n,subtract:r,number:a,bignumber:i});return t(f8,{"...any":function(e){e=h8(e);try{return s.apply(null,e)}catch(e){throw M7(e)}}})}),{isTransformFunction:!0}),g8=YH("subset",["typed","matrix"],(e=>{var{typed:t,matrix:n}=e,r=LJ({typed:t,matrix:n});return t("subset",{"...any":function(e){try{return r.apply(null,e)}catch(e){throw M7(e)}}})}),{isTransformFunction:!0}),y8=YH("concat",["typed","matrix","isInteger"],(e=>{var{typed:t,matrix:n,isInteger:r}=e,a=sX({typed:t,matrix:n,isInteger:r});return t("concat",{"...any":function(e){var t=e.length-1,n=e[t];FP(n)?e[t]=n-1:YP(n)&&(e[t]=n.minus(1));try{return a.apply(null,e)}catch(e){throw M7(e)}}})}),{isTransformFunction:!0}),b8=YH("max",["typed","config","numeric","larger"],(e=>{var{typed:t,config:n,numeric:r,larger:a}=e,i=UQ({typed:t,config:n,numeric:r,larger:a});return t("max",{"...any":function(e){e=h8(e);try{return i.apply(null,e)}catch(e){throw M7(e)}}})}),{isTransformFunction:!0}),x8=YH("min",["typed","config","numeric","smaller"],(e=>{var{typed:t,config:n,numeric:r,smaller:a}=e,i=jX({typed:t,config:n,numeric:r,smaller:a});return t("min",{"...any":function(e){e=h8(e);try{return i.apply(null,e)}catch(e){throw M7(e)}}})}),{isTransformFunction:!0}),v8=YH("range",["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],(e=>{var{typed:t,config:n,matrix:r,bignumber:a,smaller:i,smallerEq:s,larger:o,largerEq:u}=e,l=JZ({typed:t,config:n,matrix:r,bignumber:a,smaller:i,smallerEq:s,larger:o,largerEq:u});return t("range",{"...any":function(e){return"boolean"!=typeof e[e.length-1]&&e.push(!0),l.apply(null,e)}})}),{isTransformFunction:!0}),_8=YH("sum",["typed","config","add","numeric"],(e=>{var{typed:t,config:n,add:r,numeric:a}=e,i=fQ({typed:t,config:n,add:r,numeric:a});return t("sum",{"...any":function(e){e=h8(e);try{return i.apply(null,e)}catch(e){throw M7(e)}}})}),{isTransformFunction:!0}),w8="cumsum",M8=YH(w8,["typed","add","unaryPlus"],(e=>{var{typed:t,add:n,unaryPlus:r}=e,a=MZ({typed:t,add:n,unaryPlus:r});return t(w8,{"...any":function(e){if(2===e.length&&qP(e[0])){var t=e[1];FP(t)?e[1]=t-1:YP(t)&&(e[1]=t.minus(1))}try{return a.apply(null,e)}catch(e){throw M7(e)}}})}),{isTransformFunction:!0}),N8=YH("row",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:n,matrix:r,range:a}=e,i=WQ({typed:t,Index:n,matrix:r,range:a});return t("row",{"...any":function(e){var t=e.length-1,n=e[t];FP(n)&&(e[t]=n-1);try{return i.apply(null,e)}catch(e){throw M7(e)}}})}),{isTransformFunction:!0}),S8=YH("column",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:n,matrix:r,range:a}=e,i=a0({typed:t,Index:n,matrix:r,range:a});return t("column",{"...any":function(e){var t=e.length-1,n=e[t];FP(n)&&(e[t]=n-1);try{return i.apply(null,e)}catch(e){throw M7(e)}}})}),{isTransformFunction:!0}),k8=YH("index",["Index"],(e=>{var{Index:t}=e;return function(){for(var e=[],n=0,r=arguments.length;n0?0:2;else if(a&&!0===a.isSet)a=a.map((function(e){return e-1}));else if(jP(a)||UP(a))a=a.map((function(e){return e-1}));else if(FP(a))a--;else if(YP(a))a=a.toNumber()-1;else if("string"!=typeof a)throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");e[n]=a}var i=new t;return t.apply(i,e),i}}),{isTransformFunction:!0}),D8=YH("mean",["typed","add","divide"],(e=>{var{typed:t,add:n,divide:r}=e,a=K0({typed:t,add:n,divide:r});return t("mean",{"...any":function(e){e=h8(e);try{return a.apply(null,e)}catch(e){throw M7(e)}}})}),{isTransformFunction:!0}),T8="variance",I8=YH(T8,["typed","add","subtract","multiply","divide","apply","isNaN"],(e=>{var{typed:t,add:n,subtract:r,multiply:a,divide:i,apply:s,isNaN:o}=e,u=p1({typed:t,add:n,subtract:r,multiply:a,divide:i,apply:s,isNaN:o});return t(T8,{"...any":function(e){e=h8(e);try{return u.apply(null,e)}catch(e){throw M7(e)}}})}),{isTransformFunction:!0}),E8=YH("std",["typed","sqrt","variance"],(e=>{var{typed:t,sqrt:n,variance:r}=e,a=w1({typed:t,sqrt:n,variance:r});return t("std",{"...any":function(e){e=h8(e);try{return a.apply(null,e)}catch(e){throw M7(e)}}})}),{isTransformFunction:!0}),C8={},A8={},L8={},$8=J6({math:C8}),O8=Z6({mathWithTransform:A8}),R8=Q6({Node:O8}),F8=p7({Node:O8}),Y8=d7({Node:O8}),z8=h7({Node:O8}),B8=f7({Node:O8}),P8=m7({Node:O8,ResultSet:j1}),H8=g7({Node:O8}),j8=y7({Node:O8}),U8=b7({Node:O8}),q8=x7({classes:L8}),W8=_7({Chain:$8,typed:t2}),V8=w7({Node:O8,typed:t2}),G8=S7({Node:O8,subset:z3}),K8=k7({matrix:T3,Node:O8,subset:z3}),J8=D7({Node:O8,size:R3}),X8=T7({Unit:C5,Node:O8,math:C8}),Z8=E7({Node:O8,SymbolNode:X8,math:C8}),Q8=A7({AccessorNode:G8,ArrayNode:B8,AssignmentNode:K8,BlockNode:P8,ConditionalNode:H8,ConstantNode:j8,FunctionAssignmentNode:V8,FunctionNode:Z8,IndexNode:J8,ObjectNode:R8,OperatorNode:F8,ParenthesisNode:Y8,RangeNode:U8,RelationalNode:z8,SymbolNode:X8,config:RH,numeric:A3,typed:t2}),e9=L7({ConstantNode:j8,FunctionNode:Z8,OperatorNode:F8,ParenthesisNode:Y8,parse:Q8}),t9=F7({AccessorNode:G8,ArrayNode:B8,ConstantNode:j8,FunctionNode:Z8,IndexNode:J8,ObjectNode:R8,OperatorNode:F8,ParenthesisNode:Y8,SymbolNode:X8,add:D4,divide:m6,equal:r4,isZero:Y2,multiply:U4,pow:k5,subtract:B3}),n9=z7({parse:Q8,typed:t2}),r9=B7({parse:Q8}),a9=H7({parse:Q8,typed:t2}),i9=U7({bignumber:f2,fraction:k3,AccessorNode:G8,ArrayNode:B8,ConstantNode:j8,FunctionNode:Z8,IndexNode:J8,ObjectNode:R8,OperatorNode:F8,ParenthesisNode:Y8,SymbolNode:X8,add:D4,config:RH,divide:m6,equal:r4,isZero:Y2,mathWithTransform:A8,matrix:T3,multiply:U4,parse:Q8,pow:k5,resolve:e9,simplifyCore:t9,subtract:B3,typed:t2}),s9=W7({OperatorNode:F8,parse:Q8,simplify:i9,typed:t2}),o9=G7({parse:Q8,typed:t2}),u9=Q7({Help:r9,mathWithTransform:A8,typed:t2}),l9=e8({evaluate:o9}),c9=n8({bignumber:f2,fraction:k3,AccessorNode:G8,ArrayNode:B8,ConstantNode:j8,FunctionNode:Z8,IndexNode:J8,ObjectNode:R8,OperatorNode:F8,ParenthesisNode:Y8,SymbolNode:X8,add:D4,config:RH,divide:m6,equal:r4,isZero:Y2,mathWithTransform:A8,matrix:T3,multiply:U4,parse:Q8,pow:k5,simplify:i9,simplifyCore:t9,subtract:B3,typed:t2}),p9=r8({ConstantNode:j8,FunctionNode:Z8,OperatorNode:F8,ParenthesisNode:Y8,SymbolNode:X8,config:RH,equal:r4,isZero:Y2,numeric:A3,parse:Q8,simplify:i9,typed:t2}),d9=i8({Parser:l9,typed:t2});OP(C8,{e:E1,false:C1,fineStructure:A1,i:$1,Infinity:O1,LN10:R1,LOG10E:F1,NaN:z1,null:B1,phi:P1,SQRT1_2:U1,sackurTetrode:q1,tau:W1,true:V1,E:E1,version:G1,efimovFactor:J1,LN2:X1,pi:Z1,replacer:Q1,reviver:q8,SQRT2:e2,typed:t2,unaryPlus:n2,PI:Z1,weakMixingAngle:r2,abs:a2,acos:i2,acot:s2,acsc:o2,addScalar:u2,arg:l2,asech:c2,asinh:p2,atan:d2,atanh:h2,bignumber:f2,bitNot:m2,boolean:g2,chain:W8,clone:y2,combinations:b2,complex:x2,conj:v2,cosh:_2,coth:w2,csc:M2,cube:N2,equalScalar:S2,erf:k2,exp:D2,expm1:T2,filter:I2,forEach:E2,format:C2,getMatrixDataType:A2,hex:L2,im:$2,isInteger:O2,isNegative:R2,isPositive:F2,isZero:Y2,LOG2E:z2,lgamma:B2,log10:P2,log2:H2,map:j2,multiplyScalar:U2,not:q2,number:W2,oct:V2,pickRandom:G2,print:K2,random:J2,re:X2,sec:Z2,sign:Q2,sin:e3,splitUnit:n3,square:r3,string:a3,tan:i3,typeOf:s3,acosh:o3,acsch:u3,apply:l3,asec:c3,bin:p3,combinationsWithRep:d3,cos:h3,csch:f3,isNaN:m3,isPrime:g3,randomInt:y3,sech:b3,sinh:x3,sparse:v3,sqrt:_3,tanh:w3,unaryMinus:M3,acoth:N3,cot:S3,fraction:k3,isNumeric:D3,matrix:T3,matrixFromFunction:I3,mod:E3,nthRoot:C3,numeric:A3,or:L3,prod:$3,reshape:O3,size:R3,smaller:F3,squeeze:Y3,subset:z3,subtract:B3,to:P3,transpose:H3,xgcd:j3,zeros:U3,and:q3,bitAnd:W3,bitXor:V3,cbrt:G3,compare:K3,compareText:J3,concat:X3,count:Z3,ctranspose:Q3,diag:e4,divideScalar:t4,dotDivide:n4,equal:r4,fft:a4,flatten:i4,gcd:s4,hasNumericValue:o4,hypot:u4,ifft:l4,kron:c4,largerEq:p4,leftShift:d4,lsolve:h4,matrixFromColumns:f4,min:m4,mode:g4,nthRoots:y4,ones:b4,partitionSelect:x4,resize:v4,rightArithShift:_4,round:w4,smallerEq:M4,unequal:N4,usolve:S4,xor:k4,add:D4,atan2:T4,bitOr:I4,catalan:E4,compareNatural:C4,cumsum:A4,deepEqual:L4,diff:$4,dot:O4,equalText:R4,floor:F4,identity:Y4,invmod:z4,larger:B4,log:P4,lsolveAll:H4,matrixFromRows:j4,multiply:U4,qr:q4,range:W4,rightLogShift:V4,setSize:G4,slu:K4,sum:J4,trace:X4,usolveAll:Z4,asin:Q4,ceil:e5,composition:t5,cross:n5,det:r5,distance:a5,dotMultiply:i5,fix:o5,intersect:c5,lcm:d5,log1p:h5,max:f5,quantileSeq:m5,row:g5,setCartesian:y5,setDistinct:b5,setIsSubset:x5,setPowerset:v5,sort:_5,column:w5,index:M5,inv:N5,pinv:S5,pow:k5,setDifference:D5,setMultiplicity:T5,sqrtm:E5,vacuumImpedance:A5,wienDisplacement:L5,atomicMass:$5,bohrMagneton:O5,boltzmann:R5,conductanceQuantum:F5,createUnit:Y5,deuteronMass:z5,dotPow:B5,electricConstant:P5,elementaryCharge:H5,expm:j5,faraday:U5,firstRadiation:q5,gamma:W5,gravitationConstant:V5,hartreeEnergy:G5,klitzing:K5,loschmidt:J5,magneticConstant:X5,molarMass:Z5,molarPlanckConstant:Q5,neutronMass:e6,nuclearMagneton:t6,planckCharge:n6,planckLength:r6,planckTemperature:a6,protonMass:i6,reducedPlanckConstant:s6,rydberg:o6,setIntersect:u6,speedOfLight:l6,stefanBoltzmann:c6,thomsonCrossSection:p6,avogadro:d6,bohrRadius:h6,coulomb:f6,divide:m6,electronMass:g6,factorial:y6,gravity:b6,inverseConductanceQuantum:x6,lup:v6,magneticFluxQuantum:_6,molarMassC12:w6,multinomial:M6,parse:Q8,permutations:N6,planckMass:S6,quantumOfCirculation:k6,resolve:e9,secondRadiation:D6,simplifyCore:t9,stirlingS2:T6,unit:I6,bellNumbers:E6,compile:n9,eigs:C6,fermiCoupling:A6,leafCount:a9,mean:L6,molarVolume:$6,planckConstant:O6,setSymDifference:R6,simplify:i9,symbolicEqual:s9,classicalElectronRadius:F6,evaluate:o9,help:u9,lusolve:Y6,median:z6,rationalize:c9,setUnion:B6,variance:P6,derivative:p9,kldivergence:H6,norm:j6,planckTime:U6,rotationMatrix:q6,gasConstant:W6,parser:d9,std:V6,mad:G6,rotate:K6,config:RH}),OP(A8,C8,{filter:o8({typed:t2}),forEach:l8({typed:t2}),map:c8({typed:t2}),apply:d8({isInteger:O2,typed:t2}),diff:m8({bignumber:f2,matrix:T3,number:W2,subtract:B3,typed:t2}),subset:g8({matrix:T3,typed:t2}),concat:y8({isInteger:O2,matrix:T3,typed:t2}),max:b8({config:RH,larger:B4,numeric:A3,typed:t2}),min:x8({config:RH,numeric:A3,smaller:F3,typed:t2}),range:v8({bignumber:f2,matrix:T3,config:RH,larger:B4,largerEq:p4,smaller:F3,smallerEq:M4,typed:t2}),sum:_8({add:D4,config:RH,numeric:A3,typed:t2}),cumsum:M8({add:D4,typed:t2,unaryPlus:n2}),row:N8({Index:l5,matrix:T3,range:W4,typed:t2}),column:S8({Index:l5,matrix:T3,range:W4,typed:t2}),index:k8({Index:l5}),mean:D8({add:D4,divide:m6,typed:t2}),variance:I8({add:D4,apply:l3,divide:m6,isNaN:m3,multiply:U4,subtract:B3,typed:t2}),std:E8({sqrt:_3,typed:t2,variance:P6})}),OP(L8,{BigNumber:T1,Chain:$8,Complex:I1,Fraction:L1,Matrix:Y1,Node:O8,ObjectNode:R8,OperatorNode:F8,ParenthesisNode:Y8,Range:H1,RelationalNode:z8,ResultSet:j1,ArrayNode:B8,BlockNode:P8,ConditionalNode:H8,ConstantNode:j8,DenseMatrix:K1,RangeNode:U8,FunctionAssignmentNode:V8,SparseMatrix:t3,AccessorNode:G8,AssignmentNode:K8,IndexNode:J8,FibonacciHeap:s5,ImmutableDenseMatrix:u5,Index:l5,Spa:I5,Unit:C5,SymbolNode:X8,FunctionNode:Z8,Help:r9,Parser:l9}),$8.createProxy(C8);var h9={createBigNumberClass:PH},f9={createComplexClass:pj},m9={createMatrixClass:jU},g9={MatrixDependencies:m9,createDenseMatrixClass:Sq},y9={createFractionClass:HU},b9={BigNumberDependencies:h9,ComplexDependencies:f9,DenseMatrixDependencies:g9,FractionDependencies:y9,createTyped:Pq},x9={typedDependencies:b9,createAbs:wW},v9={createNode:Z6},_9={typedDependencies:b9,createEqualScalar:PV},w9={MatrixDependencies:m9,equalScalarDependencies:_9,typedDependencies:b9,createSparseMatrixClass:iK},M9={DenseMatrixDependencies:g9,MatrixDependencies:m9,SparseMatrixDependencies:w9,typedDependencies:b9,createMatrix:eJ},N9={matrixDependencies:M9,typedDependencies:b9,createSubset:LJ},S9={NodeDependencies:v9,subsetDependencies:N9,createAccessorNode:S7},k9={ComplexDependencies:f9,typedDependencies:b9,createAcos:NW},D9={ComplexDependencies:f9,typedDependencies:b9,createAcosh:gK},T9={BigNumberDependencies:h9,typedDependencies:b9,createAcot:jW},I9={BigNumberDependencies:h9,ComplexDependencies:f9,typedDependencies:b9,createAcoth:GK},E9={BigNumberDependencies:h9,ComplexDependencies:f9,typedDependencies:b9,createAcsc:qW},C9={BigNumberDependencies:h9,typedDependencies:b9,createAcsch:bK},A9={typedDependencies:b9,createAddScalar:VW},L9={DenseMatrixDependencies:g9,SparseMatrixDependencies:w9,addScalarDependencies:A9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,createAdd:pZ},$9={typedDependencies:b9,createNot:PG},O9={BigNumberDependencies:h9,matrixDependencies:M9,typedDependencies:b9,createZeros:VJ},R9={equalScalarDependencies:_9,matrixDependencies:M9,notDependencies:$9,typedDependencies:b9,zerosDependencies:O9,createAnd:GJ},F9={typedDependencies:b9,createIsInteger:lG},Y9={isIntegerDependencies:F9,typedDependencies:b9,createApply:vK},z9={isIntegerDependencies:F9,typedDependencies:b9,createApplyTransform:d8},B9={typedDependencies:b9,createArg:GW},P9={NodeDependencies:v9,createArrayNode:f7},H9={BigNumberDependencies:h9,ComplexDependencies:f9,typedDependencies:b9,createAsec:MK},j9={BigNumberDependencies:h9,ComplexDependencies:f9,typedDependencies:b9,createAsech:JW},U9={ComplexDependencies:f9,typedDependencies:b9,createAsin:xQ},q9={typedDependencies:b9,createAsinh:XW},W9={matrixDependencies:M9,NodeDependencies:v9,subsetDependencies:N9,createAssignmentNode:k7},V9={typedDependencies:b9,createAtan:ZW},G9={BigNumberDependencies:h9,DenseMatrixDependencies:g9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,createAtan2:fZ},K9={ComplexDependencies:f9,typedDependencies:b9,createAtanh:eV},J9={BigNumberDependencies:h9,typedDependencies:b9,createBignumber:tV},X9={FractionDependencies:y9,typedDependencies:b9,createFraction:JK},Z9={typedDependencies:b9,createNumber:HG},Q9={bignumberDependencies:J9,fractionDependencies:X9,numberDependencies:Z9,createNumeric:bJ},eee={numericDependencies:Q9,typedDependencies:b9,createDivideScalar:mX},tee={DenseMatrixDependencies:g9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,createEqual:xX},nee={BigNumberDependencies:h9,DenseMatrixDependencies:g9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,zerosDependencies:O9,createRound:rZ},ree={DenseMatrixDependencies:g9,equalScalarDependencies:_9,matrixDependencies:M9,roundDependencies:nee,typedDependencies:b9,zerosDependencies:O9,createCeil:MQ},aee={DenseMatrixDependencies:g9,equalScalarDependencies:_9,matrixDependencies:M9,roundDependencies:nee,typedDependencies:b9,zerosDependencies:O9,createFloor:$Z},iee={ComplexDependencies:f9,DenseMatrixDependencies:g9,ceilDependencies:ree,equalScalarDependencies:_9,floorDependencies:aee,matrixDependencies:M9,typedDependencies:b9,zerosDependencies:O9,createFix:FQ},see={typedDependencies:b9,createFormat:rG},oee={typedDependencies:b9,createIsNumeric:ZK},uee={typedDependencies:b9,createMultiplyScalar:OG},lee={BigNumberDependencies:h9,DenseMatrixDependencies:g9,SparseMatrixDependencies:w9,matrixDependencies:M9,typedDependencies:b9,createIdentity:RZ},cee={typedDependencies:b9,createIsZero:vG},pee={typedDependencies:b9,createConj:CV},dee={matrixDependencies:M9,typedDependencies:b9,createSize:kJ},hee={addScalarDependencies:A9,conjDependencies:pee,multiplyScalarDependencies:uee,sizeDependencies:dee,typedDependencies:b9,createDot:TZ},fee={addScalarDependencies:A9,dotDependencies:hee,equalScalarDependencies:_9,matrixDependencies:M9,multiplyScalarDependencies:uee,typedDependencies:b9,createMultiply:VZ},mee={typedDependencies:b9,createUnaryMinus:WK},gee={DenseMatrixDependencies:g9,addScalarDependencies:A9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,unaryMinusDependencies:mee,createSubtract:BJ},yee={divideScalarDependencies:eee,isZeroDependencies:cee,matrixDependencies:M9,multiplyDependencies:fee,subtractDependencies:gee,typedDependencies:b9,unaryMinusDependencies:mee,createDet:TQ},bee={absDependencies:x9,addScalarDependencies:A9,detDependencies:yee,divideScalarDependencies:eee,identityDependencies:lee,matrixDependencies:M9,multiplyDependencies:fee,typedDependencies:b9,unaryMinusDependencies:mee,createInv:o0},xee={ComplexDependencies:f9,fractionDependencies:X9,identityDependencies:lee,invDependencies:bee,matrixDependencies:M9,multiplyDependencies:fee,numberDependencies:Z9,typedDependencies:b9,createPow:c0},vee={BigNumberDependencies:h9,ComplexDependencies:f9,FractionDependencies:y9,absDependencies:x9,addScalarDependencies:A9,divideScalarDependencies:eee,equalDependencies:tee,fixDependencies:iee,formatDependencies:see,isNumericDependencies:oee,multiplyScalarDependencies:uee,numberDependencies:Z9,powDependencies:xee,roundDependencies:nee,subtractDependencies:gee,createUnitClass:_0},_ee={BigNumberDependencies:h9,UnitDependencies:vee,createAtomicMass:bU},wee={BigNumberDependencies:h9,UnitDependencies:vee,createAvogadro:xU},Mee={typedDependencies:b9,createIsNegative:gG},Nee={typedDependencies:b9,createCombinations:DV},See={BigNumberDependencies:h9,ComplexDependencies:f9,multiplyScalarDependencies:uee,powDependencies:xee,typedDependencies:b9,createGamma:I0},kee={gammaDependencies:See,typedDependencies:b9,createFactorial:$0},Dee={DenseMatrixDependencies:g9,matrixDependencies:M9,typedDependencies:b9,createLarger:BZ},Tee={bignumberDependencies:J9,addScalarDependencies:A9,combinationsDependencies:Nee,divideScalarDependencies:eee,factorialDependencies:kee,isIntegerDependencies:F9,isNegativeDependencies:Mee,largerDependencies:Dee,multiplyScalarDependencies:uee,numberDependencies:Z9,powDependencies:xee,subtractDependencies:gee,typedDependencies:b9,createStirlingS2:H0},Iee={addScalarDependencies:A9,isIntegerDependencies:F9,isNegativeDependencies:Mee,stirlingS2Dependencies:Tee,typedDependencies:b9,createBellNumbers:W0},Eee={formatDependencies:see,typedDependencies:b9,createBin:NK},Cee={equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,createBitAnd:JJ},Aee={typedDependencies:b9,createBitNot:xV},Lee={DenseMatrixDependencies:g9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,createBitOr:gZ},$ee={DenseMatrixDependencies:g9,matrixDependencies:M9,typedDependencies:b9,createBitXor:ZJ},Oee={createResultSet:qU},Ree={NodeDependencies:v9,ResultSetDependencies:Oee,createBlockNode:m7},Fee={BigNumberDependencies:h9,UnitDependencies:vee,createBohrMagneton:Zj},Yee={BigNumberDependencies:h9,UnitDependencies:vee,createBohrRadius:aU},zee={BigNumberDependencies:h9,UnitDependencies:vee,createBoltzmann:vU},Bee={typedDependencies:b9,createBoolean:_V},Pee={addScalarDependencies:A9,combinationsDependencies:Nee,divideScalarDependencies:eee,isIntegerDependencies:F9,isNegativeDependencies:Mee,multiplyScalarDependencies:uee,typedDependencies:b9,createCatalan:bZ},Hee={BigNumberDependencies:h9,ComplexDependencies:f9,FractionDependencies:y9,isNegativeDependencies:Mee,matrixDependencies:M9,typedDependencies:b9,unaryMinusDependencies:mee,createCbrt:eX},jee={createChainClass:J6},Uee={ChainDependencies:jee,typedDependencies:b9,createChain:_7},qee={BigNumberDependencies:h9,UnitDependencies:vee,createClassicalElectronRadius:iU},Wee={typedDependencies:b9,createClone:MV},Vee={DenseMatrixDependencies:g9,matrixDependencies:M9,typedDependencies:b9,createSmaller:IJ},Gee={DenseMatrixDependencies:g9,smallerDependencies:Vee,createImmutableDenseMatrixClass:YQ},Kee={ImmutableDenseMatrixDependencies:Gee,createIndexClass:zQ},Jee={DenseMatrixDependencies:g9,matrixDependencies:M9,typedDependencies:b9,createLargerEq:$X},Xee={DenseMatrixDependencies:g9,matrixDependencies:M9,typedDependencies:b9,createSmallerEq:iZ},Zee={bignumberDependencies:J9,matrixDependencies:M9,largerDependencies:Dee,largerEqDependencies:Jee,smallerDependencies:Vee,smallerEqDependencies:Xee,typedDependencies:b9,createRange:JZ},Qee={IndexDependencies:Kee,matrixDependencies:M9,rangeDependencies:Zee,typedDependencies:b9,createColumn:a0},ete={IndexDependencies:Kee,matrixDependencies:M9,rangeDependencies:Zee,typedDependencies:b9,createColumnTransform:S8},tte={typedDependencies:b9,createCombinationsWithRep:kK},nte={BigNumberDependencies:h9,DenseMatrixDependencies:g9,FractionDependencies:y9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,createCompare:nX},rte={compareDependencies:nte,typedDependencies:b9,createCompareNatural:_Z},ate={matrixDependencies:M9,typedDependencies:b9,createCompareText:aX},ite={NodeDependencies:v9,createConditionalNode:g7},ste={NodeDependencies:v9,createConstantNode:y7},ote={NodeDependencies:v9,typedDependencies:b9,createFunctionAssignmentNode:w7},ute={UnitDependencies:vee,NodeDependencies:v9,createSymbolNode:T7},lte={NodeDependencies:v9,SymbolNodeDependencies:ute,createFunctionNode:E7},cte={NodeDependencies:v9,sizeDependencies:dee,createIndexNode:D7},pte={NodeDependencies:v9,createObjectNode:Q6},dte={NodeDependencies:v9,createOperatorNode:p7},hte={NodeDependencies:v9,createParenthesisNode:d7},fte={NodeDependencies:v9,createRangeNode:b7},mte={NodeDependencies:v9,createRelationalNode:h7},gte={AccessorNodeDependencies:S9,ArrayNodeDependencies:P9,AssignmentNodeDependencies:W9,BlockNodeDependencies:Ree,ConditionalNodeDependencies:ite,ConstantNodeDependencies:ste,FunctionAssignmentNodeDependencies:ote,FunctionNodeDependencies:lte,IndexNodeDependencies:cte,ObjectNodeDependencies:pte,OperatorNodeDependencies:dte,ParenthesisNodeDependencies:hte,RangeNodeDependencies:fte,RelationalNodeDependencies:mte,SymbolNodeDependencies:ute,numericDependencies:Q9,typedDependencies:b9,createParse:A7},yte={parseDependencies:gte,typedDependencies:b9,createCompile:z7},bte={ComplexDependencies:f9,typedDependencies:b9,createComplex:IV},xte={typedDependencies:b9,createIsPositive:bG},vte={addScalarDependencies:A9,combinationsDependencies:Nee,isIntegerDependencies:F9,isNegativeDependencies:Mee,isPositiveDependencies:xte,largerDependencies:Dee,typedDependencies:b9,createComposition:SQ},_te={isIntegerDependencies:F9,matrixDependencies:M9,typedDependencies:b9,createConcat:sX},wte={isIntegerDependencies:F9,matrixDependencies:M9,typedDependencies:b9,createConcatTransform:y8},Mte={BigNumberDependencies:h9,UnitDependencies:vee,createConductanceQuantum:Qj},Nte={typedDependencies:b9,createCos:TK},Ste={typedDependencies:b9,createCosh:LV},kte={BigNumberDependencies:h9,typedDependencies:b9,createCot:KK},Dte={BigNumberDependencies:h9,typedDependencies:b9,createCoth:OV},Tte={BigNumberDependencies:h9,UnitDependencies:vee,createCoulomb:Jj},Ite={multiplyScalarDependencies:uee,numericDependencies:Q9,typedDependencies:b9,createProd:wJ},Ete={prodDependencies:Ite,sizeDependencies:dee,typedDependencies:b9,createCount:lX},Cte={UnitDependencies:vee,typedDependencies:b9,createCreateUnit:M0},Ate={matrixDependencies:M9,multiplyDependencies:fee,subtractDependencies:gee,typedDependencies:b9,createCross:DQ},Lte={BigNumberDependencies:h9,typedDependencies:b9,createCsc:RV},$te={BigNumberDependencies:h9,typedDependencies:b9,createCsch:EK},Ote={matrixDependencies:M9,typedDependencies:b9,createTranspose:jJ},Rte={conjDependencies:pee,transposeDependencies:Ote,typedDependencies:b9,createCtranspose:pX},Fte={typedDependencies:b9,createCube:YV},Yte={BigNumberDependencies:h9,typedDependencies:b9,createUnaryPlus:_W},zte={addDependencies:L9,typedDependencies:b9,unaryPlusDependencies:Yte,createCumSum:MZ},Bte={addDependencies:L9,typedDependencies:b9,unaryPlusDependencies:Yte,createCumSumTransform:M8},Pte={equalDependencies:tee,typedDependencies:b9,createDeepEqual:SZ},Hte={divideScalarDependencies:eee,equalScalarDependencies:_9,invDependencies:bee,matrixDependencies:M9,multiplyDependencies:fee,typedDependencies:b9,createDivide:A0},jte={ConstantNodeDependencies:ste,FunctionNodeDependencies:lte,OperatorNodeDependencies:dte,ParenthesisNodeDependencies:hte,parseDependencies:gte,createResolve:L7},Ute={AccessorNodeDependencies:S9,ArrayNodeDependencies:P9,ConstantNodeDependencies:ste,FunctionNodeDependencies:lte,IndexNodeDependencies:cte,ObjectNodeDependencies:pte,OperatorNodeDependencies:dte,ParenthesisNodeDependencies:hte,SymbolNodeDependencies:ute,addDependencies:L9,divideDependencies:Hte,equalDependencies:tee,isZeroDependencies:cee,multiplyDependencies:fee,powDependencies:xee,subtractDependencies:gee,createSimplifyCore:F7},qte={bignumberDependencies:J9,fractionDependencies:X9,AccessorNodeDependencies:S9,ArrayNodeDependencies:P9,ConstantNodeDependencies:ste,FunctionNodeDependencies:lte,IndexNodeDependencies:cte,ObjectNodeDependencies:pte,OperatorNodeDependencies:dte,ParenthesisNodeDependencies:hte,SymbolNodeDependencies:ute,addDependencies:L9,divideDependencies:Hte,equalDependencies:tee,isZeroDependencies:cee,matrixDependencies:M9,multiplyDependencies:fee,parseDependencies:gte,powDependencies:xee,resolveDependencies:jte,simplifyCoreDependencies:Ute,subtractDependencies:gee,typedDependencies:b9,createSimplify:U7},Wte={ConstantNodeDependencies:ste,FunctionNodeDependencies:lte,OperatorNodeDependencies:dte,ParenthesisNodeDependencies:hte,SymbolNodeDependencies:ute,equalDependencies:tee,isZeroDependencies:cee,numericDependencies:Q9,parseDependencies:gte,simplifyDependencies:qte,typedDependencies:b9,createDerivative:r8},Vte={BigNumberDependencies:h9,UnitDependencies:vee,createDeuteronMass:pU},Gte={DenseMatrixDependencies:g9,SparseMatrixDependencies:w9,matrixDependencies:M9,typedDependencies:b9,createDiag:hX},Kte={matrixDependencies:M9,numberDependencies:Z9,subtractDependencies:gee,typedDependencies:b9,createDiff:DZ},Jte={bignumberDependencies:J9,matrixDependencies:M9,numberDependencies:Z9,subtractDependencies:gee,typedDependencies:b9,createDiffTransform:m8},Xte={ComplexDependencies:f9,typedDependencies:b9,createSqrt:jK},Zte={absDependencies:x9,addScalarDependencies:A9,divideScalarDependencies:eee,multiplyScalarDependencies:uee,sqrtDependencies:Xte,subtractDependencies:gee,typedDependencies:b9,unaryMinusDependencies:mee,createDistance:EQ},Qte={DenseMatrixDependencies:g9,divideScalarDependencies:eee,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,createDotDivide:yX},ene={equalScalarDependencies:_9,matrixDependencies:M9,multiplyScalarDependencies:uee,typedDependencies:b9,createDotMultiply:AQ},tne={DenseMatrixDependencies:g9,equalScalarDependencies:_9,matrixDependencies:M9,powDependencies:xee,typedDependencies:b9,createDotPow:S0},nne={BigNumberDependencies:h9,createE:Ej},rne={BigNumberDependencies:h9,createEfimovFactor:yU},ane={matrixDependencies:M9,typedDependencies:b9,createFlatten:wX},ine={typedDependencies:b9,createIm:oG},sne={flattenDependencies:ane,matrixDependencies:M9,sizeDependencies:dee,typedDependencies:b9,createMatrixFromColumns:HX},one={BigNumberDependencies:h9,FractionDependencies:y9,complexDependencies:bte,typedDependencies:b9,createSign:rK},une={addScalarDependencies:A9,complexDependencies:bte,conjDependencies:pee,divideScalarDependencies:eee,equalDependencies:tee,identityDependencies:lee,isZeroDependencies:cee,matrixDependencies:M9,multiplyScalarDependencies:uee,signDependencies:one,sqrtDependencies:Xte,subtractDependencies:gee,typedDependencies:b9,unaryMinusDependencies:mee,zerosDependencies:O9,createQr:GZ},lne={typedDependencies:b9,createRe:eK},cne={typedDependencies:b9,createSin:aK},pne={DenseMatrixDependencies:g9,divideScalarDependencies:eee,equalScalarDependencies:_9,matrixDependencies:M9,multiplyScalarDependencies:uee,subtractDependencies:gee,typedDependencies:b9,createUsolve:lZ},dne={DenseMatrixDependencies:g9,divideScalarDependencies:eee,equalScalarDependencies:_9,matrixDependencies:M9,multiplyScalarDependencies:uee,subtractDependencies:gee,typedDependencies:b9,createUsolveAll:yQ},hne={absDependencies:x9,addDependencies:L9,addScalarDependencies:A9,atanDependencies:V9,bignumberDependencies:J9,columnDependencies:Qee,complexDependencies:bte,cosDependencies:Nte,diagDependencies:Gte,divideScalarDependencies:eee,dotDependencies:hee,equalDependencies:tee,flattenDependencies:ane,imDependencies:ine,invDependencies:bee,largerDependencies:Dee,matrixDependencies:M9,matrixFromColumnsDependencies:sne,multiplyDependencies:fee,multiplyScalarDependencies:uee,numberDependencies:Z9,qrDependencies:une,reDependencies:lne,sinDependencies:cne,smallerDependencies:Vee,sqrtDependencies:Xte,subtractDependencies:gee,typedDependencies:b9,usolveDependencies:pne,usolveAllDependencies:dne,createEigs:V0},fne={BigNumberDependencies:h9,UnitDependencies:vee,createElectricConstant:Gj},mne={BigNumberDependencies:h9,UnitDependencies:vee,createElectronMass:sU},gne={BigNumberDependencies:h9,UnitDependencies:vee,createElementaryCharge:Xj},yne={compareTextDependencies:ate,isZeroDependencies:cee,typedDependencies:b9,createEqualText:EZ},bne={typedDependencies:b9,createErf:HV},xne={parseDependencies:gte,typedDependencies:b9,createEvaluate:G7},vne={typedDependencies:b9,createExp:GV},_ne={absDependencies:x9,addDependencies:L9,identityDependencies:lee,invDependencies:bee,multiplyDependencies:fee,typedDependencies:b9,createExpm:D0},wne={ComplexDependencies:f9,typedDependencies:b9,createExpm1:JV},Mne={createFalse:Nj},Nne={BigNumberDependencies:h9,UnitDependencies:vee,createFaraday:_U},Sne={BigNumberDependencies:h9,UnitDependencies:vee,createFermiCoupling:oU},kne={ComplexDependencies:f9,createI:Yj},Dne={BigNumberDependencies:h9,createTau:Ij},Tne={addScalarDependencies:A9,divideScalarDependencies:eee,expDependencies:vne,iDependencies:kne,matrixDependencies:M9,multiplyScalarDependencies:uee,tauDependencies:Dne,typedDependencies:b9,createFft:vX},Ine={largerDependencies:Dee,smallerDependencies:Vee,createFibonacciHeapClass:LQ},Ene={typedDependencies:b9,createFilter:XV},Cne={typedDependencies:b9,createFilterTransform:o8},Ane={BigNumberDependencies:h9,createFineStructure:uU},Lne={BigNumberDependencies:h9,UnitDependencies:vee,createFirstRadiation:wU},$ne={typedDependencies:b9,createForEach:eG},One={typedDependencies:b9,createForEachTransform:l8},Rne={BigNumberDependencies:h9,UnitDependencies:vee,createGasConstant:NU},Fne={BigNumberDependencies:h9,DenseMatrixDependencies:g9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,createGcd:NX},Yne={typedDependencies:b9,createGetMatrixDataType:iG},zne={BigNumberDependencies:h9,UnitDependencies:vee,createGravitationConstant:Uj},Bne={BigNumberDependencies:h9,UnitDependencies:vee,createGravity:LU},Pne={BigNumberDependencies:h9,UnitDependencies:vee,createHartreeEnergy:lU},Hne={isNumericDependencies:oee,typedDependencies:b9,createHasNumericValue:kX},jne={parseDependencies:gte,createHelpClass:B7},Une={HelpDependencies:jne,typedDependencies:b9,createHelp:Q7},qne={formatDependencies:see,typedDependencies:b9,createHex:sG},Wne={absDependencies:x9,addScalarDependencies:A9,divideScalarDependencies:eee,isPositiveDependencies:xte,multiplyScalarDependencies:uee,smallerDependencies:Vee,sqrtDependencies:Xte,typedDependencies:b9,createHypot:TX},Vne={conjDependencies:pee,dotDivideDependencies:Qte,fftDependencies:Tne,typedDependencies:b9,createIfft:EX},Gne={IndexDependencies:Kee,typedDependencies:b9,createIndex:s0},Kne={IndexDependencies:Kee,createIndexTransform:k8},Jne={BigNumberDependencies:h9,createInfinity:kj},Xne={absDependencies:x9,addDependencies:L9,addScalarDependencies:A9,divideScalarDependencies:eee,equalScalarDependencies:_9,flattenDependencies:ane,isNumericDependencies:oee,isZeroDependencies:cee,matrixDependencies:M9,multiplyDependencies:fee,multiplyScalarDependencies:uee,smallerDependencies:Vee,subtractDependencies:gee,typedDependencies:b9,createIntersect:BQ},Zne={BigNumberDependencies:h9,UnitDependencies:vee,createInverseConductanceQuantum:eU},Qne={DenseMatrixDependencies:g9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,createMod:cJ},ere={BigNumberDependencies:h9,matrixDependencies:M9,typedDependencies:b9,createXgcd:qJ},tre={BigNumberDependencies:h9,addDependencies:L9,equalDependencies:tee,isIntegerDependencies:F9,modDependencies:Qne,smallerDependencies:Vee,typedDependencies:b9,xgcdDependencies:ere,createInvmod:YZ},nre={typedDependencies:b9,createIsNaN:AK},rre={typedDependencies:b9,createIsPrime:$K},are={ComplexDependencies:f9,divideScalarDependencies:eee,typedDependencies:b9,createLog:PZ},ire={addDependencies:L9,numericDependencies:Q9,typedDependencies:b9,createSum:fQ},sre={divideDependencies:Hte,dotDivideDependencies:Qte,isNumericDependencies:oee,logDependencies:are,matrixDependencies:M9,multiplyDependencies:fee,sumDependencies:ire,typedDependencies:b9,createKldivergence:f1},ore={BigNumberDependencies:h9,UnitDependencies:vee,createKlitzing:rU},ure={matrixDependencies:M9,multiplyScalarDependencies:uee,typedDependencies:b9,createKron:AX},lre={BigNumberDependencies:h9,createLN10:Lj},cre={BigNumberDependencies:h9,createLN2:Aj},pre={BigNumberDependencies:h9,createLOG10E:Oj},dre={BigNumberDependencies:h9,createLOG2E:$j},hre={equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,createLcm:PQ},fre={parseDependencies:gte,typedDependencies:b9,createLeafCount:H7},mre={DenseMatrixDependencies:g9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,zerosDependencies:O9,createLeftShift:FX},gre={ComplexDependencies:f9,typedDependencies:b9,createLgamma:TG},yre={ComplexDependencies:f9,typedDependencies:b9,createLog10:EG},bre={ComplexDependencies:f9,divideScalarDependencies:eee,logDependencies:are,typedDependencies:b9,createLog1p:jQ},xre={ComplexDependencies:f9,typedDependencies:b9,createLog2:AG},vre={BigNumberDependencies:h9,UnitDependencies:vee,createLoschmidt:MU},_re={DenseMatrixDependencies:g9,divideScalarDependencies:eee,equalScalarDependencies:_9,matrixDependencies:M9,multiplyScalarDependencies:uee,subtractDependencies:gee,typedDependencies:b9,createLsolve:BX},wre={DenseMatrixDependencies:g9,divideScalarDependencies:eee,equalScalarDependencies:_9,matrixDependencies:M9,multiplyScalarDependencies:uee,subtractDependencies:gee,typedDependencies:b9,createLsolveAll:jZ},Mre={FibonacciHeapDependencies:Ine,addScalarDependencies:A9,equalScalarDependencies:_9,createSpaClass:m0},Nre={DenseMatrixDependencies:g9,SpaDependencies:Mre,SparseMatrixDependencies:w9,absDependencies:x9,addScalarDependencies:A9,divideScalarDependencies:eee,equalScalarDependencies:_9,largerDependencies:Dee,matrixDependencies:M9,multiplyScalarDependencies:uee,subtractDependencies:gee,typedDependencies:b9,unaryMinusDependencies:mee,createLup:O0},Sre={SparseMatrixDependencies:w9,absDependencies:x9,addDependencies:L9,divideScalarDependencies:eee,largerDependencies:Dee,largerEqDependencies:Jee,multiplyDependencies:fee,subtractDependencies:gee,transposeDependencies:Ote,typedDependencies:b9,createSlu:hQ},kre={DenseMatrixDependencies:g9,lsolveDependencies:_re,lupDependencies:Nre,matrixDependencies:M9,sluDependencies:Sre,typedDependencies:b9,usolveDependencies:pne,createLusolve:t1},Dre={typedDependencies:b9,createMap:LG},Tre={compareDependencies:nte,isNaNDependencies:nre,isNumericDependencies:oee,typedDependencies:b9,createPartitionSelect:JX},Ire={addDependencies:L9,compareDependencies:nte,divideDependencies:Hte,partitionSelectDependencies:Tre,typedDependencies:b9,createMedian:a1},Ere={absDependencies:x9,mapDependencies:Dre,medianDependencies:Ire,subtractDependencies:gee,typedDependencies:b9,createMad:N1},Cre={BigNumberDependencies:h9,UnitDependencies:vee,createMagneticConstant:Vj},Are={BigNumberDependencies:h9,UnitDependencies:vee,createMagneticFluxQuantum:tU},Lre={typedDependencies:b9,createMapTransform:c8},$re={isZeroDependencies:cee,matrixDependencies:M9,typedDependencies:b9,createMatrixFromFunction:nJ},Ore={flattenDependencies:ane,matrixDependencies:M9,sizeDependencies:dee,typedDependencies:b9,createMatrixFromRows:qZ},Rre={largerDependencies:Dee,numericDependencies:Q9,typedDependencies:b9,createMax:UQ},Fre={largerDependencies:Dee,numericDependencies:Q9,typedDependencies:b9,createMaxTransform:b8},Yre={addDependencies:L9,divideDependencies:Hte,typedDependencies:b9,createMean:K0},zre={addDependencies:L9,divideDependencies:Hte,typedDependencies:b9,createMeanTransform:D8},Bre={numericDependencies:Q9,smallerDependencies:Vee,typedDependencies:b9,createMin:jX},Pre={numericDependencies:Q9,smallerDependencies:Vee,typedDependencies:b9,createMinTransform:x8},Hre={isNaNDependencies:nre,isNumericDependencies:oee,typedDependencies:b9,createMode:qX},jre={BigNumberDependencies:h9,UnitDependencies:vee,createMolarMass:CU},Ure={BigNumberDependencies:h9,UnitDependencies:vee,createMolarMassC12:AU},qre={BigNumberDependencies:h9,UnitDependencies:vee,createMolarPlanckConstant:SU},Wre={BigNumberDependencies:h9,UnitDependencies:vee,createMolarVolume:kU},Vre={addDependencies:L9,divideDependencies:Hte,factorialDependencies:kee,isIntegerDependencies:F9,isPositiveDependencies:xte,multiplyDependencies:fee,typedDependencies:b9,createMultinomial:F0},Gre={BigNumberDependencies:h9,createNaN:Dj},Kre={BigNumberDependencies:h9,UnitDependencies:vee,createNeutronMass:dU},Jre={absDependencies:x9,addDependencies:L9,conjDependencies:pee,ctransposeDependencies:Rte,eigsDependencies:hne,equalScalarDependencies:_9,largerDependencies:Dee,matrixDependencies:M9,multiplyDependencies:fee,powDependencies:xee,smallerDependencies:Vee,sqrtDependencies:Xte,typedDependencies:b9,createNorm:y1},Xre={BigNumberDependencies:h9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,createNthRoot:fJ},Zre={ComplexDependencies:f9,divideScalarDependencies:eee,typedDependencies:b9,createNthRoots:VX},Qre={BigNumberDependencies:h9,UnitDependencies:vee,createNuclearMagneton:nU},eae={createNull:Sj},tae={formatDependencies:see,typedDependencies:b9,createOct:jG},nae={BigNumberDependencies:h9,matrixDependencies:M9,typedDependencies:b9,createOnes:GX},rae={DenseMatrixDependencies:g9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,createOr:xJ},aae={evaluateDependencies:xne,createParserClass:e8},iae={ParserDependencies:aae,typedDependencies:b9,createParser:i8},sae={factorialDependencies:kee,typedDependencies:b9,createPermutations:z0},oae={BigNumberDependencies:h9,createPhi:Cj},uae={BigNumberDependencies:h9,createPi:Tj},lae={typedDependencies:b9,createPickRandom:VG},cae={ComplexDependencies:f9,addDependencies:L9,ctransposeDependencies:Rte,deepEqualDependencies:Pte,divideScalarDependencies:eee,dotDependencies:hee,dotDivideDependencies:Qte,equalDependencies:tee,invDependencies:bee,matrixDependencies:M9,multiplyDependencies:fee,typedDependencies:b9,createPinv:l0},pae={BigNumberDependencies:h9,UnitDependencies:vee,createPlanckCharge:FU},dae={BigNumberDependencies:h9,UnitDependencies:vee,createPlanckConstant:qj},hae={BigNumberDependencies:h9,UnitDependencies:vee,createPlanckLength:$U},fae={BigNumberDependencies:h9,UnitDependencies:vee,createPlanckMass:OU},mae={BigNumberDependencies:h9,UnitDependencies:vee,createPlanckTemperature:YU},gae={BigNumberDependencies:h9,UnitDependencies:vee,createPlanckTime:RU},yae={typedDependencies:b9,createPrint:KG},bae={BigNumberDependencies:h9,UnitDependencies:vee,createProtonMass:cU},xae={addDependencies:L9,compareDependencies:nte,multiplyDependencies:fee,partitionSelectDependencies:Tre,typedDependencies:b9,createQuantileSeq:qQ},vae={BigNumberDependencies:h9,UnitDependencies:vee,createQuantumOfCirculation:hU},_ae={typedDependencies:b9,createRandom:QG},wae={typedDependencies:b9,createRandomInt:RK},Mae={createRangeClass:UU},Nae={bignumberDependencies:J9,matrixDependencies:M9,largerDependencies:Dee,largerEqDependencies:Jee,smallerDependencies:Vee,smallerEqDependencies:Xee,typedDependencies:b9,createRangeTransform:v8},Sae={bignumberDependencies:J9,fractionDependencies:X9,AccessorNodeDependencies:S9,ArrayNodeDependencies:P9,ConstantNodeDependencies:ste,FunctionNodeDependencies:lte,IndexNodeDependencies:cte,ObjectNodeDependencies:pte,OperatorNodeDependencies:dte,ParenthesisNodeDependencies:hte,SymbolNodeDependencies:ute,addDependencies:L9,divideDependencies:Hte,equalDependencies:tee,isZeroDependencies:cee,matrixDependencies:M9,multiplyDependencies:fee,parseDependencies:gte,powDependencies:xee,simplifyDependencies:qte,simplifyCoreDependencies:Ute,subtractDependencies:gee,typedDependencies:b9,createRationalize:n8},kae={BigNumberDependencies:h9,UnitDependencies:vee,createReducedPlanckConstant:Wj},Dae={createReplacer:kq},Tae={isIntegerDependencies:F9,matrixDependencies:M9,typedDependencies:b9,createReshape:NJ},Iae={matrixDependencies:M9,createResize:ZX},Eae={createReviver:x7},Cae={DenseMatrixDependencies:g9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,zerosDependencies:O9,createRightArithShift:eZ},Aae={DenseMatrixDependencies:g9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,zerosDependencies:O9,createRightLogShift:ZZ},Lae={BigNumberDependencies:h9,DenseMatrixDependencies:g9,SparseMatrixDependencies:w9,addScalarDependencies:A9,cosDependencies:Nte,matrixDependencies:M9,multiplyScalarDependencies:uee,normDependencies:Jre,sinDependencies:cne,typedDependencies:b9,unaryMinusDependencies:mee,createRotationMatrix:v1},$ae={multiplyDependencies:fee,rotationMatrixDependencies:Lae,typedDependencies:b9,createRotate:D1},Oae={IndexDependencies:Kee,matrixDependencies:M9,rangeDependencies:Zee,typedDependencies:b9,createRow:WQ},Rae={IndexDependencies:Kee,matrixDependencies:M9,rangeDependencies:Zee,typedDependencies:b9,createRowTransform:N8},Fae={BigNumberDependencies:h9,UnitDependencies:vee,createRydberg:fU},Yae={BigNumberDependencies:h9,createSQRT1_2:Rj},zae={BigNumberDependencies:h9,createSQRT2:Fj},Bae={BigNumberDependencies:h9,createSackurTetrode:DU},Pae={BigNumberDependencies:h9,typedDependencies:b9,createSec:tK},Hae={BigNumberDependencies:h9,typedDependencies:b9,createSech:YK},jae={BigNumberDependencies:h9,UnitDependencies:vee,createSecondRadiation:TU},Uae={DenseMatrixDependencies:g9,IndexDependencies:Kee,compareNaturalDependencies:rte,sizeDependencies:dee,subsetDependencies:N9,typedDependencies:b9,createSetCartesian:GQ},qae={DenseMatrixDependencies:g9,IndexDependencies:Kee,compareNaturalDependencies:rte,sizeDependencies:dee,subsetDependencies:N9,typedDependencies:b9,createSetDifference:d0},Wae={DenseMatrixDependencies:g9,IndexDependencies:Kee,compareNaturalDependencies:rte,sizeDependencies:dee,subsetDependencies:N9,typedDependencies:b9,createSetDistinct:JQ},Vae={DenseMatrixDependencies:g9,IndexDependencies:Kee,compareNaturalDependencies:rte,sizeDependencies:dee,subsetDependencies:N9,typedDependencies:b9,createSetIntersect:C0},Gae={IndexDependencies:Kee,compareNaturalDependencies:rte,sizeDependencies:dee,subsetDependencies:N9,typedDependencies:b9,createSetIsSubset:ZQ},Kae={IndexDependencies:Kee,compareNaturalDependencies:rte,sizeDependencies:dee,subsetDependencies:N9,typedDependencies:b9,createSetMultiplicity:f0},Jae={IndexDependencies:Kee,compareNaturalDependencies:rte,sizeDependencies:dee,subsetDependencies:N9,typedDependencies:b9,createSetPowerset:e0},Xae={compareNaturalDependencies:rte,typedDependencies:b9,createSetSize:eQ},Zae={IndexDependencies:Kee,concatDependencies:_te,setDifferenceDependencies:qae,sizeDependencies:dee,subsetDependencies:N9,typedDependencies:b9,createSetSymDifference:X0},Qae={IndexDependencies:Kee,concatDependencies:_te,setIntersectDependencies:Vae,setSymDifferenceDependencies:Zae,sizeDependencies:dee,subsetDependencies:N9,typedDependencies:b9,createSetUnion:o1},eie={typedDependencies:b9,createSinh:BK},tie={compareDependencies:nte,compareNaturalDependencies:rte,matrixDependencies:M9,typedDependencies:b9,createSort:n0},nie={SparseMatrixDependencies:w9,typedDependencies:b9,createSparse:HK},rie={BigNumberDependencies:h9,UnitDependencies:vee,createSpeedOfLight:jj},aie={typedDependencies:b9,createSplitUnit:oK},iie={absDependencies:x9,addDependencies:L9,identityDependencies:lee,invDependencies:bee,maxDependencies:Rre,multiplyDependencies:fee,sizeDependencies:dee,sqrtDependencies:Xte,subtractDependencies:gee,typedDependencies:b9,createSqrtm:y0},sie={typedDependencies:b9,createSquare:lK},oie={matrixDependencies:M9,typedDependencies:b9,createSqueeze:CJ},uie={addDependencies:L9,applyDependencies:Y9,divideDependencies:Hte,isNaNDependencies:nre,multiplyDependencies:fee,subtractDependencies:gee,typedDependencies:b9,createVariance:p1},lie={sqrtDependencies:Xte,typedDependencies:b9,varianceDependencies:uie,createStd:w1},cie={sqrtDependencies:Xte,typedDependencies:b9,varianceDependencies:uie,createStdTransform:E8},pie={BigNumberDependencies:h9,UnitDependencies:vee,createStefanBoltzmann:IU},die={typedDependencies:b9,createString:pK},hie={matrixDependencies:M9,typedDependencies:b9,createSubsetTransform:g8},fie={addDependencies:L9,numericDependencies:Q9,typedDependencies:b9,createSumTransform:_8},mie={OperatorNodeDependencies:dte,parseDependencies:gte,simplifyDependencies:qte,typedDependencies:b9,createSymbolicEqual:W7},gie={typedDependencies:b9,createTan:dK},yie={typedDependencies:b9,createTanh:UK},bie={BigNumberDependencies:h9,UnitDependencies:vee,createThomsonCrossSection:mU},xie={matrixDependencies:M9,typedDependencies:b9,createTo:HJ},vie={addDependencies:L9,matrixDependencies:M9,typedDependencies:b9,createTrace:mQ},_ie={createTrue:Mj},wie={typedDependencies:b9,createTypeOf:fK},Mie={DenseMatrixDependencies:g9,equalScalarDependencies:_9,matrixDependencies:M9,typedDependencies:b9,createUnequal:oZ},Nie={UnitDependencies:vee,typedDependencies:b9,createUnitFunction:U0},Sie={eDependencies:nne,createUppercaseE:Bj},kie={piDependencies:uae,createUppercasePi:zj},Die={BigNumberDependencies:h9,UnitDependencies:vee,createVacuumImpedance:Kj},Tie={addDependencies:L9,applyDependencies:Y9,divideDependencies:Hte,isNaNDependencies:nre,multiplyDependencies:fee,subtractDependencies:gee,typedDependencies:b9,createVarianceTransform:I8},Iie={createVersion:Pj},Eie={BigNumberDependencies:h9,createWeakMixingAngle:gU},Cie={BigNumberDependencies:h9,UnitDependencies:vee,createWienDisplacement:EU},Aie={DenseMatrixDependencies:g9,matrixDependencies:M9,typedDependencies:b9,createXor:cZ},Lie=V,$ie=n(4279);function Oie(e,t){var n=OP({},RP,t);if("function"!=typeof Object.create)throw new Error("ES5 not supported by this JavaScript engine. Please load the es5-shim and es5-sham library for compatibility.");var r,a,i=(r={isNumber:FP,isComplex:zP,isBigNumber:YP,isFraction:BP,isUnit:PP,isString:HP,isArray:jP,isMatrix:UP,isCollection:qP,isDenseMatrix:WP,isSparseMatrix:VP,isRange:GP,isIndex:KP,isBoolean:JP,isResultSet:XP,isHelp:ZP,isFunction:QP,isDate:eH,isRegExp:tH,isObject:nH,isNull:rH,isUndefined:aH,isAccessorNode:iH,isArrayNode:sH,isAssignmentNode:oH,isBlockNode:uH,isConditionalNode:lH,isConstantNode:cH,isFunctionAssignmentNode:pH,isFunctionNode:dH,isIndexNode:hH,isNode:fH,isObjectNode:mH,isOperatorNode:gH,isParenthesisNode:yH,isRangeNode:bH,isSymbolNode:xH,isChain:vH},a=new $ie,r.on=a.on.bind(a),r.off=a.off.bind(a),r.once=a.once.bind(a),r.emit=a.emit.bind(a),r);i.config=$H(n,i.emit),i.expression={transform:{},mathWithTransform:{config:i.config}};var s={},o=function(e,t,n,r){function a(t,a,s){if(s.wrap&&"function"==typeof a&&(u=function(){for(var e=[],t=0,r=arguments.length;t2&&void 0!==arguments[2]?arguments[2]:t.fn;if(Nq(i,"."))throw new Error("Factory name should not contain a nested path. Name: "+JSON.stringify(i));var o=d(t)?n.expression.transform:n,u=i in n.expression.transform,c=EH(o,i)?o[i]:void 0,h=function(){var r={};t.dependencies.map(BH).forEach((e=>{if(Nq(e,"."))throw new Error("Factory dependency should not contain a nested path. Name: "+JSON.stringify(e));"math"===e?r.math=n:"mathWithTransform"===e?r.mathWithTransform=n.expression.mathWithTransform:"classes"===e?r.classes=n:r[e]=n[e]}));var s=t(r);if(s&&"function"==typeof s.transform)throw new Error('Transforms cannot be attached to factory functions. Please create a separate function for it with exports.path="expression.transform"');if(void 0===c||a.override)return s;if(l(c)&&l(s))return e(c,s);if(a.silent)return c;throw new Error('Cannot import "'+i+'": already exists')};t.meta&&!1===t.meta.lazy?(o[i]=h(),c&&u?s(i):(d(t)||p(t))&&IH(n.expression.mathWithTransform,i,(()=>o[i]))):(IH(o,i,h),c&&u?s(i):(d(t)||p(t))&&IH(n.expression.mathWithTransform,i,(()=>o[i]))),r[i]=t,n.emit("import",i,h)}function u(e){return"function"==typeof e||"number"==typeof e||"string"==typeof e||"boolean"==typeof e||null===e||PP(e)||zP(e)||YP(e)||BP(e)||UP(e)||Array.isArray(e)}function l(e){return"function"==typeof e&&"object"==typeof e.signatures}function c(e){return!EH(h,e)}function p(e){return!(-1!==e.fn.indexOf(".")||EH(h,e.fn)||e.meta&&e.meta.isClass)}function d(e){return void 0!==e&&void 0!==e.meta&&!0===e.meta.isTransformFunction||!1}var h={expression:!0,type:!0,docs:!0,error:!0,json:!0,chain:!0};return function(e,t){var n=arguments.length;if(1!==n&&2!==n)throw new XX("import",n,1,2);function r(e,n,a){if(Array.isArray(n))n.forEach((t=>r(e,t)));else if("object"==typeof n)for(var i in n)EH(n,i)&&r(e,n[i],i);else if(zH(n)||void 0!==a){var s=zH(n)?d(n)?n.fn+".transform":n.fn:a;if(EH(e,s)&&e[s]!==n&&!t.silent)throw new Error('Cannot import "'+s+'" twice');e[s]=n}else if(!t.silent)throw new TypeError("Factory, Object, or Array expected")}t||(t={});var i={};for(var s in r(i,e),i)if(EH(i,s)){var l=i[s];if(zH(l))o(l,t);else if(u(l))a(s,l,t);else if(!t.silent)throw new TypeError("Factory, Object, or Array expected")}}}((function(){for(var e=arguments.length,t=new Array(e),n=0;n{CH(s).forEach((e=>{e&&e.meta&&e.meta.recreateOnConfigChange&&o(e,{override:!0})}))})),i.create=Oie.bind(null,e),i.factory=YH,i.import(CH(DH(e))),i.ArgumentsError=XX,i.DimensionError=eq,i.IndexError=tq,i}class Rie{constructor(e){this.pInst=e,this.turtle={},this.home()}home(){this.turtle.x=this.pInst.width/2,this.turtle.y=this.pInst.height/2,this.turtle.angle=0,this.turtle.pen=!0,this.turtle.pencolor="black",this.turtle.penwidth=1}pencolor(e){this.turtle.pencolor=e}pensize(e){this.turtle.penwidth=e}pendown(){this.turtle.pen=!0}penup(){this.turtle.pen=!1}setposition(e,t){this.turtle.x=e,this.turtle.y=t}position(){return[this.turtle.x,this.turtle.y]}left(e){this.turtle.angle-=e}right(e){this.turtle.angle+=e}setheading(e){this.turtle.angle=e}heading(){return this.turtle.angle}forward(e){const t=this._angleMode;this.pInst.angleMode(this.pInst.DEGREES);const n=this.turtle.x+e*this.pInst.cos(this.turtle.angle-90),r=this.turtle.y+e*this.pInst.sin(this.turtle.angle-90);this.pInst.angleMode(t),this.turtle.pen&&(this.pInst.push(),this.pInst.strokeWeight(this.turtle.penwidth),this.pInst.stroke(this.turtle.pencolor),this.pInst.line(this.turtle.x,this.turtle.y,n,r),this.pInst.pop()),this.turtle.x=n,this.turtle.y=r}back(e){this.forward(-e)}circle(e){this.turtle.pen&&(this.pInst.push(),this.pInst.strokeWeight(this.turtle.penwidth),this.pInst.stroke(this.turtle.pencolor),this.pInst.circle(this.turtle.x,this.turtle.y,2*e),this.pInst.pop())}}const Fie=p5.prototype.circle;p5.prototype.circle=function(){Fie&&(1!==arguments.length?Fie.call(this,...arguments):this.getDefaultTurtle().circle(arguments[0]))},p5.prototype.createTurtle=function(){return new Rie(this)},p5.prototype.getDefaultTurtle=function(){return this.defaultTurtle||(this.defaultTurtle=this.createTurtle()),this.defaultTurtle},p5.prototype.home=function(){this.getDefaultTurtle().home()},p5.prototype.pencolor=function(e){this.getDefaultTurtle().pencolor(e)},p5.prototype.pensize=function(e){this.getDefaultTurtle().pensize(e)},p5.prototype.pendown=function(){this.getDefaultTurtle().pendown()},p5.prototype.penup=function(){this.getDefaultTurtle().penup()},p5.prototype.setposition=function(e,t){this.getDefaultTurtle().setposition(e,t)},p5.prototype.position=function(){return this.getDefaultTurtle().position()},p5.prototype.left=function(e){this.getDefaultTurtle().left(e)},p5.prototype.right=function(e){this.getDefaultTurtle().right(e)},p5.prototype.setheading=function(e){this.getDefaultTurtle().setheading(e)},p5.prototype.heading=function(){return this.getDefaultTurtle().heading()},p5.prototype.forward=function(e){this.getDefaultTurtle().forward(e)},p5.prototype.back=function(e){this.getDefaultTurtle().back(e)};var Yie=n9,zie=p9,Bie=o9,Pie=Q8,Hie=i9;const jie=p5;var Uie=jie.prototype.createVector,qie=function(){function e(t){if(this.isComplex=!1,"number"==typeof t)this.tensor=Ru(t);else if(t instanceof Array)this.tensor=Fi(t);else if(t instanceof jie.Vector){var n=t.array();this.tensor=Fi(n)}else if(t instanceof e)this.tensor=t.tensor;else{if(!(t instanceof ti))throw new Error("Tensors must be created from Numbers, Arrays, or p5.Vectors.");this.tensor=t}this.shape=this.tensor.shape}return e.prototype.toString=function(){return this.tensor.toString()},e.prototype.print=function(){this.tensor.print()},e.prototype.array=function(){return function(e,t,n,r){return new(n||(n=Promise))((function(a,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function o(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}u((r=r.apply(e,t||[])).next())}))}(this,void 0,void 0,(function(){var e,t;return function(e,t){var n,r,a,i,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function o(i){return function(o){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(a=2&i[0]?r.return:i[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,i[1])).done)return a;switch(r=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((a=(a=s.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]100)throw new Error("Percentile must be in the range [0, 100].");r.push(n*(e/100))})),r}if(t<0||t>100)throw new Error("Percentile must be in the range [0, 100].");return n*(t/100)},Xse=function(e,t){var n=Kse(e);if(t instanceof Array){var r=[];return t.forEach((function(e){if(e<0||e>1)throw new Error("Quantile must be in the range [0, 1].");r.push(n*e)})),r}if(t<0||t>1)throw new Error("Quantile must be in the range [0, 1].");return n*t},Zse=function(e,t,n){var r=e.tensor.mean(t,n);return new qie(r)},Qse=function(e,t){if(t instanceof qie){var n=e.mult(t),r=n.sum(),a=t.sum(),i=r.div(a);return n.dispose(),r.dispose(),a.dispose(),i}return Zse(e)},eoe=function(e){var t=ho((function(){var t=Zse(e),n=e.sub(t).sq().sum(),r=e.shape.reduce((function(e,t){return e*t}));return n.div(r).sqrt().tensor}));return new qie(t)},toe=function(e){var t=eoe(e),n=t.sq();return t.dispose(),n};const noe=function(e){var t=e.pg,n=e.originX,r=e.originY,a=e.width,i=e.height,s=e.annotationsPalette;t.push(),t.fill(s.backgroundColor),t.strokeWeight(1),t.stroke(s.backgroundColor),t.rect(n,r,a,-i),t.pop()};var roe=n(7484),aoe=function(e,t,n){void 0===n&&(n=50);for(var r=[],a=(t-e)/(n-1),i=0;it.value?1:e.value100?t.round(x,0):t.round(x,1)),t.text(b,f[y],g)}t.pop()}(this.props):function(e){var t=e.pg,n=e.dataset,r=e.x,a=e.y,i=e.originX,s=e.originY,o=e.majorTicks,u=e.minorTicks,l=e.tickSize,c=e.annotationsPalette,p=e.xRange;t.push(),t.fill(c.fontColor),t.noStroke(),t.textAlign(t.CENTER,t.CENTER),t.translate(i,s);for(var d=n.getSorted(r,a),h=p||d.xRange,f=ioe(e),m=aoe(h.min,h.max,o+1),g=4*l,y=0;y100?t.round(x,0):t.round(x,1)),t.text(b,f[y],g)}t.pop()}(this.props)},e.prototype.yticks=function(e){this.props=Loe(Loe({},this.props),e),function(e){var t,n=e.pg,r=e.dataset,a=e.x,i=e.y,s=e.originX,o=e.originY,u=e.majorTicks,l=e.minorTicks,c=e.tickSize,p=e.annotationsPalette,d=e.numBins,h=e.yRange;n.push(),n.fill(p.fontColor),n.noStroke(),n.textAlign(n.CENTER,n.CENTER),n.translate(s,o),t=h||(d>0?r.getBinned(a,d).xRange:r.getSorted(a,i).yRange);for(var f=soe(e),m=aoe(t.min,t.max,u+1),g=-5*c,y=0;y100?n.round(x,0):n.round(x,1)),n.text(b,g,-f[y])}n.pop()}(this.props)},e.prototype.background=function(e){this.props.annotationsPalette.backgroundColor=e||this.props.annotationsPalette.backgroundColor,this.layers.unshift({props:this.props,operation:noe})},e.prototype.margin=function(e){this.props.annotationsPalette.marginColor=e||this.props.annotationsPalette.marginColor,this.layers.unshift({props:this.props,operation:moe})},e.prototype.bar=function(e){this.props=Loe(Loe({},this.props),e),this.props.numBins=this.props.numBins||20,this.layers.push({props:this.props,operation:Noe})},e.prototype.point=function(e){this.props=Loe(Loe({},this.props),e),this.layers.push({props:this.props,operation:Soe})},e.prototype.line=function(e){this.props=Loe(Loe({},this.props),e),this.layers.push({props:this.props,operation:koe})},e}();p5.prototype.registerMethod("init",(function(){this._plots=[]})),p5.prototype.createPlot=function(e){var t=new $oe(this,e);return this._plots.push(t),t},p5.prototype.registerMethod("post",(function(){this._plots.forEach((function(e){e.clear()}))})),p5.prototype.registerMethod("remove",(function(){this._plots.forEach((function(e){return e.props.pg.remove()})),this._plots=void 0}));var Ooe=n(178);function Roe(e,...t){if("function"==typeof e)throw new Error("You must supply the data as the first argument to tidy()");let n=e;for(const e of t)e&&(n=e(n));return n}function Foe(e){return t=>t.filter(e)}function Yoe(e){return t=>t.map(e)}function zoe(e){return null==e?[]:Array.isArray(e)?e:[e]}function Boe(e,t){return et?1:e>=t?0:NaN}function Poe(e){return t=>{const n=zoe(e).map((e=>"function"==typeof e?1===e.length?Hoe(e):e:Hoe(e)));return t.slice().sort(((e,t)=>{for(const r of n){const n=r(e,t);if(n)return n}return 0}))}}function Hoe(e){const t="function"==typeof e?e:t=>t[e];return function(e,n){return Uoe(t(e),t(n),!1)}}function joe(e){const t="function"==typeof e?e:t=>t[e];return function(e,n){return Uoe(t(e),t(n),!0)}}function Uoe(e,t,n){let r=n?t:e,a=n?e:t;if(qoe(r)&&qoe(a)){const e=(r!=r?0:null===r?1:2)-(a!=a?0:null===a?1:2);return n?-e:e}return qoe(r)?n?-1:1:qoe(a)?n?1:-1:Boe(r,a)}function qoe(e){return null==e||e!=e}function Woe(e,t){return n=>{t=null!=t?t:{};const r={},a=Object.keys(e);for(const t of a)r[t]=e[t](n);if(t.rest&&n.length){const e=Object.keys(n[0]);for(const i of e)a.includes(i)||(r[i]=t.rest(i)(n))}return[r]}}function Voe(e,t,n,r){if(!e.length)return[];const a={};let i;if(null==r)i=Object.keys(e[0]);else{i=[];for(const t of zoe(r))"function"==typeof t?i.push(...t(e)):i.push(t)}for(const r of i)n&&!n(e.map((e=>e[r])))||(a[r]=t(r)(e));return[a]}function Goe(e){return t=>Voe(t,e)}function Koe(e,t){return n=>Voe(n,t,e)}function Joe(e,t){return n=>Voe(n,t,void 0,e)}function Xoe(e){return t=>{const n=[];for(const r of t){const t={...r};for(const n in e){const r=e[n],a="function"==typeof r?r(t):r;t[n]=a}n.push(t)}return n}}class Zoe extends Map{constructor(e,t=eue){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),null!=e)for(const[t,n]of e)this.set(t,n)}get(e){return super.get(Qoe(this,e))}has(e){return super.has(Qoe(this,e))}set(e,t){return super.set(function({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}(this,e),t)}delete(e){return super.delete(function({_intern:e,_key:t},n){const r=t(n);return e.has(r)&&(n=e.get(n),e.delete(r)),n}(this,e))}}function Qoe({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):n}function eue(e){return null!==e&&"object"==typeof e?e.valueOf():e}function tue(e){return e}function nue(e,t){if(null==e||"object"!=typeof e||Array.isArray(e))return e;const n=Object.fromEntries(t.filter((e=>"function"!=typeof e[0])));return Object.assign(n,e)}function rue(e,t,n,r,a,i=0){for(const[s,o]of e.entries()){const e=[...n,s];o instanceof Map?rue(o,r(t,e,i),e,r,a,i+1):a(t,e,o,i)}return t}function aue(e,t,n=(e=>e[e.length-1])){const r=new Map;return rue(e,r,[],(function(e,t){const r=new Map;return e.set(n(t),r),r}),(function(e,r,a){e.set(n(r),t(a,r))})),r}Set;const iue=e=>e;function sue(e,t,n){"function"==typeof t?t=[t]:2!==arguments.length||null==t||Array.isArray(t)||(n=t);const r=r=>{const a=oue(uue(r,e),t,null==n?void 0:n.addGroupKeys);if(null==n?void 0:n.export)switch(n.export){case"grouped":return a;case"levels":return pue(a,n);case"entries-obj":case"entriesObject":return pue(a,{...n,export:"levels",levels:["entries-object"]});default:return pue(a,{...n,export:"levels",levels:[n.export]})}return lue(a,null==n?void 0:n.addGroupKeys)};return r}function oue(e,t,n){let r=e;if(!(null==t?void 0:t.length))return r;for(const e of t)e&&(r=aue(r,((t,r)=>{let a=e(t,{groupKeys:r});return!1!==n&&(a=a.map((e=>nue(e,r)))),a})));return r}function uue(e,t){const n=function(e,...t){return function(e,t,n,r){return function e(a,i){if(i>=r.length)return n(a);const s=new Zoe,o=r[i++];let u=-1;for(const e of a){const t=o(e,++u,a),n=s.get(t);n?n.push(e):s.set(t,[e])}for(const[t,n]of s)s.set(t,e(n,i));return t(s)}(e,0)}(e,tue,tue,t)}(e,...zoe(t).map(((e,t)=>{const n="function"==typeof e?e:t=>t[e],r=new Map;return t=>{const a=n(t),i=function(e){const t=typeof e;return null!=e&&("object"===t||"function"===t)}(a)?a.valueOf():a;if(r.has(i))return r.get(i);const s=[e,a];return r.set(i,s),s}})));return n}function lue(e,t){const n=[];return rue(e,n,[],iue,((e,n,r)=>{let a=r;!1!==t&&(a=r.map((e=>nue(e,n)))),e.push(...a)})),n}sue.grouped=e=>({...e,export:"grouped"}),sue.entries=e=>({...e,export:"entries"}),sue.entriesObject=e=>({...e,export:"entries-object"}),sue.object=e=>({...e,export:"object"}),sue.map=e=>({...e,export:"map"}),sue.keys=e=>({...e,export:"keys"}),sue.values=e=>({...e,export:"values"}),sue.levels=e=>({...e,export:"levels"});const cue=e=>e.join("/");function pue(e,t){const{groupFn:n,keyFn:r}=function(e){var t;const{flat:n,single:r,mapLeaf:a=iue,mapLeaves:i=iue,addGroupKeys:s}=e;let o;return e.flat&&(o=null!=(t=e.compositeKey)?t:cue),{groupFn:(e,t)=>r?a(!1===s?e[0]:nue(e[0],t)):i(e.map((e=>a(!1===s?e:nue(e,t))))),keyFn:n?e=>o(e.map((e=>e[1]))):e=>e[e.length-1][1]}}(t);let{mapEntry:a=iue}=t;const{levels:i=["entries"]}=t,s=[];for(const e of i)switch(e){case"entries":case"entries-object":case"entries-obj":case"entriesObject":{const n="entries-object"!==e&&"entries-obj"!==e&&"entriesObject"!==e||null!=t.mapEntry?a:([e,t])=>({key:e,values:t});s.push({id:"entries",createEmptySubgroup:()=>[],addSubgroup:(e,t,r,a)=>{e.push(n([r,t],a))},addLeaf:(e,t,r,a)=>{e.push(n([t,r],a))}});break}case"map":s.push({id:"map",createEmptySubgroup:()=>new Map,addSubgroup:(e,t,n)=>{e.set(n,t)},addLeaf:(e,t,n)=>{e.set(t,n)}});break;case"object":s.push({id:"object",createEmptySubgroup:()=>({}),addSubgroup:(e,t,n)=>{e[n]=t},addLeaf:(e,t,n)=>{e[t]=n}});break;case"keys":s.push({id:"keys",createEmptySubgroup:()=>[],addSubgroup:(e,t,n)=>{e.push([n,t])},addLeaf:(e,t)=>{e.push(t)}});break;case"values":s.push({id:"values",createEmptySubgroup:()=>[],addSubgroup:(e,t)=>{e.push(t)},addLeaf:(e,t,n)=>{e.push(n)}});break;default:"object"==typeof e&&s.push(e)}return rue(e,s[0].createEmptySubgroup(),[],((e,n,a)=>{var i,o;if(t.flat)return e;const u=null!=(i=s[a])?i:s[s.length-1],l=(null!=(o=s[a+1])?o:u).createEmptySubgroup();return u.addSubgroup(e,l,r(n),a),l}),((e,t,a,i)=>{var o;(null!=(o=s[i])?o:s[s.length-1]).addLeaf(e,r(t),n(a,t),i)}))}class due{constructor(){this._partials=new Float64Array(32),this._n=0}add(e){const t=this._partials;let n=0;for(let r=0;r0){for(i=e[--a];a>0&&(t=i,n=e[--a],i=t+n,r=n-(i-t),!r););a>0&&(r<0&&e[a-1]<0||r>0&&e[a-1]>0)&&(n=2*r,t=i+n,n==t-i&&(i=t))}return i}}function hue(e,t){const n=new due;if(void 0===t)for(let t of e)(t=+t)&&n.add(t);else{let r=-1;for(let a of e)(a=+t(a,++r,e))&&n.add(a)}return+n}function fue(e){const t="function"==typeof e?e:t=>t[e];return e=>hue(e,t)}function mue(e){return t=>{const{name:n="n",wt:r}=null!=e?e:{},a=Woe({[n]:null==r?e=>e.length:fue(r)})(t);return a}}const gue=function(e){return function(t,n=0,r=t.length){let a=r-(n=+n);for(;a;){const r=e()*a--|0,i=t[a+n];t[a+n]=t[r+n],t[r+n]=i}return t}}(Math.random);function yue(e,t){return n=>n.slice(e,t)}function bue(e,t){if(0===e.length||0===t.length)return{};const n=Object.keys(e[0]),r=Object.keys(t[0]),a={};for(const e of n)r.includes(e)&&(a[e]=e);return a}function xue(e){if(Array.isArray(e)){const t={};for(const n of e)t[n]=n;return t}return"object"==typeof e?e:{[e]:e}}function vue(e,t,n){for(const r in n)if(e[n[r]]!==t[r])return!1;return!0}function _ue(e,t){return n=>{const r=null==(null==t?void 0:t.by)?bue(n,e):xue(t.by);return n.flatMap((t=>e.filter((e=>vue(t,e,r))).map((e=>({...t,...e})))))}}function wue(e,t){return n=>{if(!e.length)return n;const r=null==(null==t?void 0:t.by)?bue(n,e):xue(t.by),a=Object.keys(e[0]);return n.flatMap((t=>{const n=e.filter((e=>vue(t,e,r)));if(n.length)return n.map((e=>({...t,...e})));const i=Object.fromEntries(a.filter((e=>null==t[e])).map((e=>[e,void 0])));return{...t,...i}}))}}function Mue(e,t){return n=>{if(!e.length)return n;if(!n.length)return e;const r=null==(null==t?void 0:t.by)?bue(n,e):xue(t.by),a=new Map,i=Object.keys(e[0]),s=n.flatMap((t=>{const n=e.filter((e=>{const n=vue(t,e,r);return n&&a.set(e,!0),n}));if(n.length)return n.map((e=>({...t,...e})));const s=Object.fromEntries(i.filter((e=>null==t[e])).map((e=>[e,void 0])));return{...t,...s}}));if(a.size[e,void 0])));for(const n of e)a.has(n)||s.push({...t,...n})}return s}}function Nue(e){return e.length<1?[]:Object.keys(e[0])}function Sue(){return e=>Nue(e)}function kue(e){return t=>{let n=function(e,t){let n=[];for(const r of zoe(t))"function"==typeof r?n.push(...r(e)):n.push(r);n.length&&"-"===n[0][0]&&(n=[...Sue()(e),...n]);const r={},a=[];for(let e=n.length-1;e>=0;e--){const t=n[e];"-"!==t[0]?r[t]?r[t]=!1:a.unshift(t):r[t.substring(1)]=!0}return n=Array.from(new Set(a)),n}(t,e);return n.length?t.map((e=>{const t={};for(const r of n)t[r]=e[r];return t})):t}}function Due(e){return t=>"function"==typeof e?[...t,...zoe(e(t))]:[...t,...zoe(e)]}function Tue(e){return t=>{const n=function(e){if(Array.isArray(e)){const t={};for(const n of e)t[n]=n;return t}return"object"==typeof e?e:{[e]:e}}(e),r=[];for(const e in n){const a=n[e];let i;i="function"==typeof a?a(t):Array.isArray(a)?a:Array.from(new Set(t.map((t=>t[e])))),r.push(i.map((t=>({[e]:t}))))}return function(e){const t=[];return function e(t,n,r){if(!r.length&&null!=n)return void t.push(n);const a=r[0],i=r.slice(1);for(const r of a)e(t,{...n,...r},i)}(t,null,e),t}(r)}}function Iue(e,t){let n,r;if(void 0===t)for(const t of e)null!=t&&(void 0===n?t>=t&&(n=r=t):(n>t&&(n=t),r=i&&(n=r=i):(n>i&&(n=i),r{const n=[];for(const r of t){const t={...r};for(const n in e)null==t[n]&&(t[n]=e[n]);n.push(t)}return n}}function Aue(e){return t=>{const n=zoe(e),r={};return t.map((e=>{const t={...e};for(const e of n)null!=t[e]?r[e]=t[e]:null!=r[e]&&(t[e]=r[e]);return t}))}}function Lue(e,t,n){return null==e||null==t?void 0:0===t&&0===e?0:n||0!==t?e/t:void 0}function $ue(e,t){let n;if(void 0===t)for(const t of e)null!=t&&(n>t||void 0===n&&t>=t)&&(n=t);else{let r=-1;for(let a of e)null!=(a=t(a,++r,e))&&(n>a||void 0===n&&a>=a)&&(n=a)}return n}function Oue(e){const t="function"==typeof e?e:t=>t[e];return e=>$ue(e,t)}function Rue(e,t){let n;if(void 0===t)for(const t of e)null!=t&&(n=t)&&(n=t);else{let r=-1;for(let a of e)null!=(a=t(a,++r,e))&&(n=a)&&(n=a)}return n}function Fue(e){const t="function"==typeof e?e:t=>t[e];return e=>Rue(e,t)}function Yue(e,t,n=0,r=e.length-1,a=Boe){for(;r>n;){if(r-n>600){const i=r-n+1,s=t-n+1,o=Math.log(i),u=.5*Math.exp(2*o/3),l=.5*Math.sqrt(o*u*(i-u)/i)*(s-i/2<0?-1:1);Yue(e,t,Math.max(n,Math.floor(t-s*u/i+l)),Math.min(r,Math.floor(t+(i-s)*u/i+l)),a)}const i=e[t];let s=n,o=r;for(zue(e,n,t),a(e[r],i)>0&&zue(e,n,r);s0;)--o}0===a(e[n],i)?zue(e,n,o):(++o,zue(e,o,r)),o<=t&&(n=o+1),t<=o&&(r=o-1)}return e}function zue(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function Bue(e,t,n){if(e=Float64Array.from(function*(e,t){if(void 0===t)for(let t of e)null!=t&&(t=+t)>=t&&(yield t);else{let n=-1;for(let r of e)null!=(r=t(r,++n,e))&&(r=+r)>=r&&(yield r)}}(e,n)),r=e.length){if((t=+t)<=0||r<2)return $ue(e);if(t>=1)return Rue(e);var r,a=(r-1)*t,i=Math.floor(a),s=Rue(Yue(e,i).subarray(0,i+1));return s+($ue(e.subarray(i+1))-s)*(a-i)}}function Pue(e,t){let n,r=0,a=0,i=0;if(void 0===t)for(let t of e)null!=t&&(t=+t)>=t&&(n=t-a,a+=n/++r,i+=n*(t-a));else{let s=-1;for(let o of e)null!=(o=t(o,++s,e))&&(o=+o)>=o&&(n=o-a,a+=n/++r,i+=n*(o-a))}if(r>1)return i/(r-1)}var Hue=function(e,t,n){if(n||2===arguments.length)for(var r,a=0,i=t.length;a{const r=Tue(e)(n),a=wue(n)(r);return t?Cue(t)(a):a}},p5.prototype.count=function(e,t){return n=>{t=null!=t?t:{};const{name:r="n",sort:a}=t;return Roe(n,sue(e,[mue(t)]),a?Poe(joe(r)):iue)}},p5.prototype.debug=function(e,t){return(n,r)=>{var a;let i="[tidy.debug";if(null==(a=null==r?void 0:r.groupKeys)?void 0:a.length){const e=r.groupKeys.map((e=>e.join(": "))).join(", ");e.length&&(i+="|"+e)}t=null!=t?t:{};const{limit:s=10,output:o="table"}=t,u="--------------------------------------------------------------------------------";let l=u.length;const c=i+"]"+(null==e?"":" "+e);return l=Math.max(0,l-(c.length+2)),console.log(`${c} ${u.substring(0,l)}`),console[o](null==s||s>=n.length?n:n.slice(0,s)),n}},p5.prototype.distinct=function(e){return t=>{if(!(e=zoe(e)).length){const e=new Set;for(const n of t)e.add(n);return Array.from(e)}const n=new Map,r=[],a=e[e.length-1];for(const i of t){let t=n,s=!1;for(const n of e){const e="function"==typeof n?n(i):i[n];if(n===a){s=t.has(e),s||(r.push(i),t.set(e,!0));break}t.has(e)||t.set(e,new Map),t=t.get(e)}}return r}},p5.prototype.desc=joe,p5.prototype.expand=Tue,p5.prototype._pfill=p5.prototype.fill,p5.prototype.fill=function(){for(var e=[],t=0;t{const n=t.map((e=>({...e})));for(const r in e){const a=e[r],i="function"==typeof a?a(n):a,s=(null==i?void 0:i[Symbol.iterator])&&"string"!=typeof i?i:t.map((()=>i));let o=-1;for(const e of n)e[r]=s[++o]}return n}},p5.prototype.pick=kue,p5.prototype.rename=function(e){return t=>t.map((t=>{var n;const r={},a=Object.keys(t);for(const i of a)r[null!=(n=e[i])?n:i]=t[i];return r}))},p5.prototype.replaceNully=Cue,p5.prototype._pselect=p5.prototype.select,p5.prototype.select=function(){for(var e=[],t=0;tyue(0,e),p5.prototype.sliceTail=e=>yue(-e),p5.prototype.sliceMin=function(e,t){return n=>Poe(t)(n).slice(0,e)},p5.prototype.sliceMax=function(e,t){return n=>"function"==typeof t?Poe(t)(n).slice(-e).reverse():Poe(joe(t))(n).slice(0,e)},p5.prototype.sliceSample=function(e,t){t=null!=t?t:{};const{replace:n}=t;return t=>{if(!t.length)return t.slice();if(n){const n=[];for(let r=0;r{const r=Woe(e)(n),a=Xoe(t)(r);return[...n,...a]}},p5.prototype.totalAll=function(e,t){return n=>{const r=Goe(e)(n),a=Xoe(t)(r);return[...n,...a]}},p5.prototype.totalAt=function(e,t,n){return r=>{const a=Joe(e,t)(r),i=Xoe(n)(a);return[...r,...i]}},p5.prototype.totalIf=function(e,t,n){return r=>{const a=Koe(e,t)(r),i=Xoe(n)(a);return[...r,...i]}},p5.prototype.transmute=function(e){return t=>{const n=Xoe(e)(t);return kue(Object.keys(e))(n)}},p5.prototype.when=function(e,t){return n=>{if("function"==typeof e){if(!e(n))return n}else if(!e)return n;return Roe(n,...t)}},p5.prototype.deviation=function(e){const t="function"==typeof e?e:t=>t[e];return e=>function(e,t){const n=Pue(e,t);return n?Math.sqrt(n):n}(e,t)},p5.prototype.first=function(e){const t="function"==typeof e?e:t=>t[e];return e=>e.length?t(e[0]):void 0},p5.prototype.last=function(e){const t="function"==typeof e?e:t=>t[e];return e=>e.length?t(e[e.length-1]):void 0},p5.prototype._pmax=p5.prototype.max,p5.prototype.max=function(){for(var e=[],t=0;tt[e];return e=>function(e,t){let n=0;for(let r=0;rt[e],r="function"==typeof t?t:e=>e[t];return e=>Lue(hue(e,n),hue(e,r))},p5.prototype.median=function(e){const t="function"==typeof e?e:t=>t[e];return e=>function(e,t){return Bue(e,.5,t)}(e,t)},p5.prototype._pmin=p5.prototype.min,p5.prototype.min=function(){for(var e=[],t=0;te.length},p5.prototype.nDistinct=function(e,t={}){const n="function"==typeof e?e:t=>t[e];return e=>{const r=new Map;let a=0;for(const i of e){const e=n(i);if(!r.has(e)){if(!t.includeUndefined&&void 0===e||!1===t.includeNull&&null===e)continue;a+=1,r.set(e,!0)}}return a}},p5.prototype.sum=fue,p5.prototype.variance=function(e){const t="function"==typeof e?e:t=>t[e];return e=>Pue(e,t)},p5.prototype.cumsum=function(e){const t="function"==typeof e?e:t=>t[e];return e=>function(e,t){let n=new due,r=0;return Float64Array.from(e,(a=>n.add(+(t(a,r++,e)||0))))}(e,t)},p5.prototype.lag=function(e,t){const n="function"==typeof e?e:t=>t[e],{n:r=1,default:a}=null!=t?t:{};return e=>e.map(((t,i)=>{const s=e[i-r];return null==s?a:n(s)}))},p5.prototype.lead=function(e,t){const n="function"==typeof e?e:t=>t[e],{n:r=1,default:a}=null!=t?t:{};return e=>e.map(((t,i)=>{const s=e[i+r];return null==s?a:n(s)}))},p5.prototype.roll=function(e,t,n){const{partial:r=!1,align:a="right"}=null!=n?n:{},i=Math.floor(e/2);return n=>n.map(((s,o)=>{const u="right"===a?o:"center"===a?o+i:o+e-1;if(!r&&(u-e+1<0||u>=n.length))return;const l=Math.max(0,u-e+1),c=n.slice(l,u+1);return t(c,u)}))},p5.prototype.rate=function(e,t,n){const r="function"==typeof e?e:t=>t[e],a="function"==typeof t?t:e=>e[t],{predicate:i,allowDivideByZero:s}=null!=n?n:{};return null==i?e=>{const t=a(e);return Lue(r(e),t,s)}:e=>{if(!i(e))return;const t=a(e);return Lue(r(e),t,s)}},p5.prototype.fullSeq=function(e,t){return function(n){t=null!=t?t:1;const r="function"==typeof e?e:t=>t[e];return function(e,t=1){let[n,r]=Iue(e);const a=[];let i=n;for(;i<=r;)a.push(i),i+=t;return a}(n.map(r),t)}},p5.prototype.fullSeqDate=function(e,t,n){return function(r){t=null!=t?t:"day",n=null!=n?n:1;const a="function"==typeof e?e:t=>t[e];return Eue(r.map(a),t,n)}},p5.prototype.fullSeqDateISOString=function(e,t,n){return function(r){t=null!=t?t:"day",n=null!=n?n:1;const a="function"==typeof e?e:t=>t[e];return Eue(r.map((e=>new Date(a(e)))),t,n).map((e=>e.toISOString()))}},p5.prototype.contains=function(e,t=!0){return n=>{const r=new RegExp(e,t?"i":void 0);return Nue(n).filter((e=>r.test(e)))}},p5.prototype.endsWith=function(e,t=!0){return n=>{const r=new RegExp(`${e}$`,t?"i":void 0);return Nue(n).filter((e=>r.test(e)))}},p5.prototype.everything=Sue,p5.prototype.matches=function(e){return t=>Nue(t).filter((t=>e.test(t)))},p5.prototype.negate=function(e){return t=>{let n=new Set;for(const r of zoe(e))if("function"==typeof r){const e=r(t);for(const t of e)n.add(t)}else n.add(r);return Array.from(n).map((e=>`-${e}`))}},p5.prototype.numRange=function(e,t,n){return r=>{const a=Nue(r),i=[];for(let r=t[0];r<=t[1];++r){const t=null==n?r:new String("00000000"+r).slice(-n);i.push(`${e}${t}`)}return a.filter((e=>i.includes(e)))}},p5.prototype.startsWith=function(e,t=!0){return n=>{const r=new RegExp(`^${e}`,t?"i":void 0);return Nue(n).filter((e=>r.test(e)))}},roe.extend(Ooe),p5.prototype.utc=function(){for(var e=[],t=0;t{var e={1977:function(e,t){var n;!function(r){"use strict";var a=Math.cosh||function(e){return Math.abs(e)<1e-9?1-e:.5*(Math.exp(e)+Math.exp(-e))},i=Math.sinh||function(e){return Math.abs(e)<1e-9?e:.5*(Math.exp(e)-Math.exp(-e))},s=function(){throw SyntaxError("Invalid Param")};function o(e,t){var n=Math.abs(e),r=Math.abs(t);return 0===e?Math.log(r):0===t?Math.log(n):n<3e3&&r<3e3?.5*Math.log(e*e+t*t):(e/=2,t/=2,.5*Math.log(e*e+t*t)+Math.LN2)}function u(e,t){if(!(this instanceof u))return new u(e,t);var n=function(e,t){var n={re:0,im:0};if(null==e)n.re=n.im=0;else if(void 0!==t)n.re=e,n.im=t;else switch(typeof e){case"object":if("im"in e&&"re"in e)n.re=e.re,n.im=e.im;else if("abs"in e&&"arg"in e){if(!Number.isFinite(e.abs)&&Number.isFinite(e.arg))return u.INFINITY;n.re=e.abs*Math.cos(e.arg),n.im=e.abs*Math.sin(e.arg)}else if("r"in e&&"phi"in e){if(!Number.isFinite(e.r)&&Number.isFinite(e.phi))return u.INFINITY;n.re=e.r*Math.cos(e.phi),n.im=e.r*Math.sin(e.phi)}else 2===e.length?(n.re=e[0],n.im=e[1]):s();break;case"string":n.im=n.re=0;var r=e.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),a=1,i=0;null===r&&s();for(var o=0;o0&&s();break;case"number":n.im=0,n.re=e;break;default:s()}return isNaN(n.re)||isNaN(n.im),n}(e,t);this.re=n.re,this.im=n.im}u.prototype={re:0,im:0,sign:function(){var e=this.abs();return new u(this.re/e,this.im/e)},add:function(e,t){var n=new u(e,t);return this.isInfinite()&&n.isInfinite()?u.NAN:this.isInfinite()||n.isInfinite()?u.INFINITY:new u(this.re+n.re,this.im+n.im)},sub:function(e,t){var n=new u(e,t);return this.isInfinite()&&n.isInfinite()?u.NAN:this.isInfinite()||n.isInfinite()?u.INFINITY:new u(this.re-n.re,this.im-n.im)},mul:function(e,t){var n=new u(e,t);return this.isInfinite()&&n.isZero()||this.isZero()&&n.isInfinite()?u.NAN:this.isInfinite()||n.isInfinite()?u.INFINITY:0===n.im&&0===this.im?new u(this.re*n.re,0):new u(this.re*n.re-this.im*n.im,this.re*n.im+this.im*n.re)},div:function(e,t){var n=new u(e,t);if(this.isZero()&&n.isZero()||this.isInfinite()&&n.isInfinite())return u.NAN;if(this.isInfinite()||n.isZero())return u.INFINITY;if(this.isZero()||n.isInfinite())return u.ZERO;e=this.re,t=this.im;var r,a,i=n.re,s=n.im;return 0===s?new u(e/i,t/i):Math.abs(i)0)return new u(Math.pow(e,n.re),0);if(0===e)switch((n.re%4+4)%4){case 0:return new u(Math.pow(t,n.re),0);case 1:return new u(0,Math.pow(t,n.re));case 2:return new u(-Math.pow(t,n.re),0);case 3:return new u(0,-Math.pow(t,n.re))}}if(0===e&&0===t&&n.re>0&&n.im>=0)return u.ZERO;var r=Math.atan2(t,e),a=o(e,t);return e=Math.exp(n.re*a-n.im*r),t=n.im*a+n.re*r,new u(e*Math.cos(t),e*Math.sin(t))},sqrt:function(){var e,t,n=this.re,r=this.im,a=this.abs();if(n>=0){if(0===r)return new u(Math.sqrt(n),0);e=.5*Math.sqrt(2*(a+n))}else e=Math.abs(r)/Math.sqrt(2*(a-n));return t=n<=0?.5*Math.sqrt(2*(a-n)):Math.abs(r)/Math.sqrt(2*(a+n)),new u(e,r<0?-t:t)},exp:function(){var e=Math.exp(this.re);return this.im,new u(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){var e=this.re,t=this.im;return new u(Math.expm1(e)*Math.cos(t)+function(e){var t=Math.PI/4;if(-t>e||e>t)return Math.cos(e)-1;var n=e*e;return n*(n*(n*(n*(n*(n*(n*(n/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-.5)}(t),Math.exp(e)*Math.sin(t))},log:function(){var e=this.re,t=this.im;return new u(o(e,t),Math.atan2(t,e))},abs:function(){return e=this.re,t=this.im,n=Math.abs(e),r=Math.abs(t),n<3e3&&r<3e3?Math.sqrt(n*n+r*r):(n1&&0===t,r=1-e,a=1+e,i=r*r+t*t,s=0!==i?new u((a*r-t*t)/i,(t*r+a*t)/i):new u(-1!==e?e/0:0,0!==t?t/0:0),l=s.re;return s.re=o(s.re,s.im)/2,s.im=Math.atan2(s.im,l)/2,n&&(s.im=-s.im),s},acoth:function(){var e=this.re,t=this.im;if(0===e&&0===t)return new u(0,Math.PI/2);var n=e*e+t*t;return 0!==n?new u(e/n,-t/n).atanh():new u(0!==e?e/0:0,0!==t?-t/0:0).atanh()},acsch:function(){var e=this.re,t=this.im;if(0===t)return new u(0!==e?Math.log(e+Math.sqrt(e*e+1)):1/0,0);var n=e*e+t*t;return 0!==n?new u(e/n,-t/n).asinh():new u(0!==e?e/0:0,0!==t?-t/0:0).asinh()},asech:function(){var e=this.re,t=this.im;if(this.isZero())return u.INFINITY;var n=e*e+t*t;return 0!==n?new u(e/n,-t/n).acosh():new u(0!==e?e/0:0,0!==t?-t/0:0).acosh()},inverse:function(){if(this.isZero())return u.INFINITY;if(this.isInfinite())return u.ZERO;var e=this.re,t=this.im,n=e*e+t*t;return new u(e/n,-t/n)},conjugate:function(){return new u(this.re,-this.im)},neg:function(){return new u(-this.re,-this.im)},ceil:function(e){return e=Math.pow(10,e||0),new u(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=Math.pow(10,e||0),new u(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=Math.pow(10,e||0),new u(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,t){var n=new u(e,t);return Math.abs(n.re-this.re)<=u.EPSILON&&Math.abs(n.im-this.im)<=u.EPSILON},clone:function(){return new u(this.re,this.im)},toString:function(){var e=this.re,t=this.im,n="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)=t?e:""+Array(t+1-r.length).join(n)+e},y={s:g,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),a=n%60;return(t<=0?"+":"-")+g(r,2,"0")+":"+g(a,2,"0")},m:function e(t,n){if(t.date()1)return e(s[0])}else{var o=t.name;v[o]=t,a=o}return!r&&a&&(b=a),a||!r&&b},w=function(e,t){if(x(e))return e.clone();var n="object"==typeof t?t:{};return n.date=e,n.args=arguments,new N(n)},D=y;D.l=_,D.i=x,D.w=function(e,t){return w(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var N=function(){function m(e){this.$L=_(e.locale,null,!0),this.parse(e)}var g=m.prototype;return g.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(null===t)return new Date(NaN);if(D.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var r=t.match(h);if(r){var a=r[2]-1||0,i=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],a,r[3]||1,r[4]||0,r[5]||0,r[6]||0,i)):new Date(r[1],a,r[3]||1,r[4]||0,r[5]||0,r[6]||0,i)}}return new Date(t)}(e),this.$x=e.x||{},this.init()},g.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},g.$utils=function(){return D},g.isValid=function(){return!(this.$d.toString()===d)},g.isSame=function(e,t){var n=w(e);return this.startOf(t)<=n&&n<=this.endOf(t)},g.isAfter=function(e,t){return w(e)12?"م":"ص"},relativeTime:{future:"في %s",past:"منذ %s",s:"ثوان",m:"دقيقة",mm:"%d دقائق",h:"ساعة",hh:"%d ساعات",d:"يوم",dd:"%d أيام",M:"شهر",MM:"%d أشهر",y:"سنة",yy:"%d سنوات"}};return t.default.locale(n,null,!0),n}(n(7484))},7719:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ar-iq",weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),months:"كانون الثاني_شباط_آذار_نيسان_أيار_حزيران_تموز_آب_أيلول_تشرين الأول_ تشرين الثاني_كانون الأول".split("_"),weekStart:1,weekdaysShort:"أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت".split("_"),monthsShort:"كانون الثاني_شباط_آذار_نيسان_أيار_حزيران_تموز_آب_أيلول_تشرين الأول_ تشرين الثاني_كانون الأول".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},meridiem:function(e){return e>12?"م":"ص"},relativeTime:{future:"في %s",past:"منذ %s",s:"ثوان",m:"دقيقة",mm:"%d دقائق",h:"ساعة",hh:"%d ساعات",d:"يوم",dd:"%d أيام",M:"شهر",MM:"%d أشهر",y:"سنة",yy:"%d سنوات"}};return t.default.locale(n,null,!0),n}(n(7484))},2376:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ar-kw",weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),months:"يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر".split("_"),weekdaysShort:"احد_اثنين_ثلاثاء_اربعاء_خميس_جمعة_سبت".split("_"),monthsShort:"يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},meridiem:function(e){return e>12?"م":"ص"},relativeTime:{future:"في %s",past:"منذ %s",s:"ثوان",m:"دقيقة",mm:"%d دقائق",h:"ساعة",hh:"%d ساعات",d:"يوم",dd:"%d أيام",M:"شهر",MM:"%d أشهر",y:"سنة",yy:"%d سنوات"}};return t.default.locale(n,null,!0),n}(n(7484))},8540:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ar-ly",weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),months:"يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),weekStart:6,weekdaysShort:"أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت".split("_"),monthsShort:"يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),ordinal:function(e){return e},meridiem:function(e){return e>12?"م":"ص"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"D/‏M/‏YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},6817:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ar-ma",weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),months:"يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر".split("_"),weekStart:6,weekdaysShort:"احد_إثنين_ثلاثاء_اربعاء_خميس_جمعة_سبت".split("_"),monthsShort:"يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},meridiem:function(e){return e>12?"م":"ص"},relativeTime:{future:"في %s",past:"منذ %s",s:"ثوان",m:"دقيقة",mm:"%d دقائق",h:"ساعة",hh:"%d ساعات",d:"يوم",dd:"%d أيام",M:"شهر",MM:"%d أشهر",y:"سنة",yy:"%d سنوات"}};return t.default.locale(n,null,!0),n}(n(7484))},1573:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ar-sa",weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),months:"يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),weekdaysShort:"أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت".split("_"),monthsShort:"يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},meridiem:function(e){return e>12?"م":"ص"},relativeTime:{future:"في %s",past:"منذ %s",s:"ثوان",m:"دقيقة",mm:"%d دقائق",h:"ساعة",hh:"%d ساعات",d:"يوم",dd:"%d أيام",M:"شهر",MM:"%d أشهر",y:"سنة",yy:"%d سنوات"}};return t.default.locale(n,null,!0),n}(n(7484))},9339:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ar-tn",weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),months:"جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),weekStart:1,weekdaysShort:"أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت".split("_"),monthsShort:"جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},meridiem:function(e){return e>12?"م":"ص"},relativeTime:{future:"في %s",past:"منذ %s",s:"ثوان",m:"دقيقة",mm:"%d دقائق",h:"ساعة",hh:"%d ساعات",d:"يوم",dd:"%d أيام",M:"شهر",MM:"%d أشهر",y:"سنة",yy:"%d سنوات"}};return t.default.locale(n,null,!0),n}(n(7484))},3939:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n="يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر".split("_"),r={1:"١",2:"٢",3:"٣",4:"٤",5:"٥",6:"٦",7:"٧",8:"٨",9:"٩",0:"٠"},a={"١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","٠":"0"},i={name:"ar",weekdays:"الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت".split("_"),weekdaysShort:"أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت".split("_"),weekdaysMin:"ح_ن_ث_ر_خ_ج_س".split("_"),months:n,monthsShort:n,weekStart:6,relativeTime:{future:"بعد %s",past:"منذ %s",s:"ثانية واحدة",m:"دقيقة واحدة",mm:"%d دقائق",h:"ساعة واحدة",hh:"%d ساعات",d:"يوم واحد",dd:"%d أيام",M:"شهر واحد",MM:"%d أشهر",y:"عام واحد",yy:"%d أعوام"},preparse:function(e){return e.replace(/[١٢٣٤٥٦٧٨٩٠]/g,(function(e){return a[e]})).replace(/،/g,",")},postformat:function(e){return e.replace(/\d/g,(function(e){return r[e]})).replace(/,/g,"،")},ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"D/‏M/‏YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"}};return t.default.locale(i,null,!0),i}(n(7484))},8092:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"az",weekdays:"Bazar_Bazar ertəsi_Çərşənbə axşamı_Çərşənbə_Cümə axşamı_Cümə_Şənbə".split("_"),weekdaysShort:"Baz_BzE_ÇAx_Çər_CAx_Cüm_Şən".split("_"),weekdaysMin:"Bz_BE_ÇA_Çə_CA_Cü_Şə".split("_"),months:"yanvar_fevral_mart_aprel_may_iyun_iyul_avqust_sentyabr_oktyabr_noyabr_dekabr".split("_"),monthsShort:"yan_fev_mar_apr_may_iyn_iyl_avq_sen_okt_noy_dek".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY г.",LLL:"D MMMM YYYY г., H:mm",LLLL:"dddd, D MMMM YYYY г., H:mm"},relativeTime:{future:"%s sonra",past:"%s əvvəl",s:"bir neçə saniyə",m:"bir dəqiqə",mm:"%d dəqiqə",h:"bir saat",hh:"%d saat",d:"bir gün",dd:"%d gün",M:"bir ay",MM:"%d ay",y:"bir il",yy:"%d il"},ordinal:function(e){return e}};return t.default.locale(n,null,!0),n}(n(7484))},504:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"be",weekdays:"нядзелю_панядзелак_аўторак_сераду_чацвер_пятніцу_суботу".split("_"),months:"студзеня_лютага_сакавіка_красавіка_траўня_чэрвеня_ліпеня_жніўня_верасня_кастрычніка_лістапада_снежня".split("_"),weekStart:1,weekdaysShort:"нд_пн_ат_ср_чц_пт_сб".split("_"),monthsShort:"студ_лют_сак_крас_трав_чэрв_ліп_жнів_вер_каст_ліст_снеж".split("_"),weekdaysMin:"нд_пн_ат_ср_чц_пт_сб".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY г.",LLL:"D MMMM YYYY г., HH:mm",LLLL:"dddd, D MMMM YYYY г., HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},9091:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"bg",weekdays:"неделя_понеделник_вторник_сряда_четвъртък_петък_събота".split("_"),weekdaysShort:"нед_пон_вто_сря_чет_пет_съб".split("_"),weekdaysMin:"нд_пн_вт_ср_чт_пт_сб".split("_"),months:"януари_февруари_март_април_май_юни_юли_август_септември_октомври_ноември_декември".split("_"),monthsShort:"янр_фев_мар_апр_май_юни_юли_авг_сеп_окт_ное_дек".split("_"),weekStart:1,ordinal:function(e){var t=e%100;if(t>10&&t<20)return e+"-ти";var n=e%10;return 1===n?e+"-ви":2===n?e+"-ри":7===n||8===n?e+"-ми":e+"-ти"},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"D.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY H:mm",LLLL:"dddd, D MMMM YYYY H:mm"},relativeTime:{future:"след %s",past:"преди %s",s:"няколко секунди",m:"минута",mm:"%d минути",h:"час",hh:"%d часа",d:"ден",dd:"%d дена",M:"месец",MM:"%d месеца",y:"година",yy:"%d години"}};return t.default.locale(n,null,!0),n}(n(7484))},9149:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"bi",weekdays:"Sande_Mande_Tusde_Wenesde_Tosde_Fraede_Sarade".split("_"),months:"Januari_Februari_Maj_Eprel_Mei_Jun_Julae_Okis_Septemba_Oktoba_Novemba_Disemba".split("_"),weekStart:1,weekdaysShort:"San_Man_Tus_Wen_Tos_Frae_Sar".split("_"),monthsShort:"Jan_Feb_Maj_Epr_Mai_Jun_Jul_Oki_Sep_Okt_Nov_Dis".split("_"),weekdaysMin:"San_Ma_Tu_We_To_Fr_Sar".split("_"),ordinal:function(e){return e},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY h:mm A",LLLL:"dddd, D MMMM YYYY h:mm A"},relativeTime:{future:"lo %s",past:"%s bifo",s:"sam seken",m:"wan minit",mm:"%d minit",h:"wan haoa",hh:"%d haoa",d:"wan dei",dd:"%d dei",M:"wan manis",MM:"%d manis",y:"wan yia",yy:"%d yia"}};return t.default.locale(n,null,!0),n}(n(7484))},5287:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"bm",weekdays:"Kari_Ntɛnɛn_Tarata_Araba_Alamisa_Juma_Sibiri".split("_"),months:"Zanwuyekalo_Fewuruyekalo_Marisikalo_Awirilikalo_Mɛkalo_Zuwɛnkalo_Zuluyekalo_Utikalo_Sɛtanburukalo_ɔkutɔburukalo_Nowanburukalo_Desanburukalo".split("_"),weekStart:1,weekdaysShort:"Kar_Ntɛ_Tar_Ara_Ala_Jum_Sib".split("_"),monthsShort:"Zan_Few_Mar_Awi_Mɛ_Zuw_Zul_Uti_Sɛt_ɔku_Now_Des".split("_"),weekdaysMin:"Ka_Nt_Ta_Ar_Al_Ju_Si".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"MMMM [tile] D [san] YYYY",LLL:"MMMM [tile] D [san] YYYY [lɛrɛ] HH:mm",LLLL:"dddd MMMM [tile] D [san] YYYY [lɛrɛ] HH:mm"},relativeTime:{future:"%s kɔnɔ",past:"a bɛ %s bɔ",s:"sanga dama dama",m:"miniti kelen",mm:"miniti %d",h:"lɛrɛ kelen",hh:"lɛrɛ %d",d:"tile kelen",dd:"tile %d",M:"kalo kelen",MM:"kalo %d",y:"san kelen",yy:"san %d"}};return t.default.locale(n,null,!0),n}(n(7484))},5254:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={1:"১",2:"২",3:"৩",4:"৪",5:"৫",6:"৬",7:"৭",8:"৮",9:"৯",0:"০"},r={"১":"1","২":"2","৩":"3","৪":"4","৫":"5","৬":"6","৭":"7","৮":"8","৯":"9","০":"0"},a={name:"bn",weekdays:"রবিবার_সোমবার_মঙ্গলবার_বুধবার_বৃহস্পতিবার_শুক্রবার_শনিবার".split("_"),months:"জানুয়ারি_ফেব্রুয়ারি_মার্চ_এপ্রিল_মে_জুন_জুলাই_আগস্ট_সেপ্টেম্বর_অক্টোবর_নভেম্বর_ডিসেম্বর".split("_"),weekdaysShort:"রবি_সোম_মঙ্গল_বুধ_বৃহস্পতি_শুক্র_শনি".split("_"),monthsShort:"জানু_ফেব্রু_মার্চ_এপ্রিল_মে_জুন_জুলাই_আগস্ট_সেপ্ট_অক্টো_নভে_ডিসে".split("_"),weekdaysMin:"রবি_সোম_মঙ্গ_বুধ_বৃহঃ_শুক্র_শনি".split("_"),preparse:function(e){return e.replace(/[১২৩৪৫৬৭৮৯০]/g,(function(e){return r[e]}))},postformat:function(e){return e.replace(/\d/g,(function(e){return n[e]}))},ordinal:function(e){return e},formats:{LT:"A h:mm সময়",LTS:"A h:mm:ss সময়",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm সময়",LLLL:"dddd, D MMMM YYYY, A h:mm সময়"},relativeTime:{future:"%s পরে",past:"%s আগে",s:"কয়েক সেকেন্ড",m:"এক মিনিট",mm:"%d মিনিট",h:"এক ঘন্টা",hh:"%d ঘন্টা",d:"এক দিন",dd:"%d দিন",M:"এক মাস",MM:"%d মাস",y:"এক বছর",yy:"%d বছর"}};return t.default.locale(a,null,!0),a}(n(7484))},2502:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"bo",weekdays:"གཟའ་ཉི་མ་_གཟའ་ཟླ་བ་_གཟའ་མིག་དམར་_གཟའ་ལྷག་པ་_གཟའ་ཕུར་བུ_གཟའ་པ་སངས་_གཟའ་སྤེན་པ་".split("_"),weekdaysShort:"ཉི་མ་_ཟླ་བ་_མིག་དམར་_ལྷག་པ་_ཕུར་བུ_པ་སངས་_སྤེན་པ་".split("_"),weekdaysMin:"ཉི་མ་_ཟླ་བ་_མིག་དམར་_ལྷག་པ་_ཕུར་བུ_པ་སངས་_སྤེན་པ་".split("_"),months:"ཟླ་བ་དང་པོ_ཟླ་བ་གཉིས་པ_ཟླ་བ་གསུམ་པ_ཟླ་བ་བཞི་པ_ཟླ་བ་ལྔ་པ_ཟླ་བ་དྲུག་པ_ཟླ་བ་བདུན་པ_ཟླ་བ་བརྒྱད་པ_ཟླ་བ་དགུ་པ_ཟླ་བ་བཅུ་པ_ཟླ་བ་བཅུ་གཅིག་པ_ཟླ་བ་བཅུ་གཉིས་པ".split("_"),monthsShort:"ཟླ་དང་པོ_ཟླ་གཉིས་པ_ཟླ་གསུམ་པ_ཟླ་བཞི་པ_ཟླ་ལྔ་པ_ཟླ་དྲུག་པ_ཟླ་བདུན་པ_ཟླ་བརྒྱད་པ_ཟླ་དགུ་པ_ཟླ་བཅུ་པ_ཟླ་བཅུ་གཅིག་པ_ཟླ་བཅུ་གཉིས་པ".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm",LTS:"A h:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm",LLLL:"dddd, D MMMM YYYY, A h:mm"},relativeTime:{future:"%s ལ་",past:"%s སྔོན་ལ་",s:"ཏོག་ཙམ་",m:"སྐར་མ་གཅིག་",mm:"སྐར་མ་ %d",h:"ཆུ་ཚོད་གཅིག་",hh:"ཆུ་ཚོད་ %d",d:"ཉིན་གཅིག་",dd:"ཉིན་ %d",M:"ཟླ་བ་གཅིག་",MM:"ཟླ་བ་ %d",y:"ལོ་གཅིག་",yy:"ལོ་ %d"}};return t.default.locale(n,null,!0),n}(n(7484))},8864:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e);function n(e){return e>9?n(e%10):e}function r(e,t,n){return e+" "+function(e,t){return 2===t?function(e){return{m:"v",b:"v",d:"z"}[e.charAt(0)]+e.substring(1)}(e):e}({mm:"munutenn",MM:"miz",dd:"devezh"}[n],e)}var a={name:"br",weekdays:"Sul_Lun_Meurzh_Mercʼher_Yaou_Gwener_Sadorn".split("_"),months:"Genver_Cʼhwevrer_Meurzh_Ebrel_Mae_Mezheven_Gouere_Eost_Gwengolo_Here_Du_Kerzu".split("_"),weekStart:1,weekdaysShort:"Sul_Lun_Meu_Mer_Yao_Gwe_Sad".split("_"),monthsShort:"Gen_Cʼhwe_Meu_Ebr_Mae_Eve_Gou_Eos_Gwe_Her_Du_Ker".split("_"),weekdaysMin:"Su_Lu_Me_Mer_Ya_Gw_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"h[e]mm A",LTS:"h[e]mm:ss A",L:"DD/MM/YYYY",LL:"D [a viz] MMMM YYYY",LLL:"D [a viz] MMMM YYYY h[e]mm A",LLLL:"dddd, D [a viz] MMMM YYYY h[e]mm A"},relativeTime:{future:"a-benn %s",past:"%s ʼzo",s:"un nebeud segondennoù",m:"ur vunutenn",mm:r,h:"un eur",hh:"%d eur",d:"un devezh",dd:r,M:"ur miz",MM:r,y:"ur bloaz",yy:function(e){switch(n(e)){case 1:case 3:case 4:case 5:case 9:return e+" bloaz";default:return e+" vloaz"}}},meridiem:function(e){return e<12?"a.m.":"g.m."}};return t.default.locale(a,null,!0),a}(n(7484))},4502:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"bs",weekdays:"nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota".split("_"),months:"januar_februar_mart_april_maj_juni_juli_august_septembar_oktobar_novembar_decembar".split("_"),weekStart:1,weekdaysShort:"ned._pon._uto._sri._čet._pet._sub.".split("_"),monthsShort:"jan._feb._mar._apr._maj._jun._jul._aug._sep._okt._nov._dec.".split("_"),weekdaysMin:"ne_po_ut_sr_če_pe_su".split("_"),ordinal:function(e){return e},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd, D. MMMM YYYY H:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},3646:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ca",weekdays:"Diumenge_Dilluns_Dimarts_Dimecres_Dijous_Divendres_Dissabte".split("_"),weekdaysShort:"Dg._Dl._Dt._Dc._Dj._Dv._Ds.".split("_"),weekdaysMin:"Dg_Dl_Dt_Dc_Dj_Dv_Ds".split("_"),months:"Gener_Febrer_Març_Abril_Maig_Juny_Juliol_Agost_Setembre_Octubre_Novembre_Desembre".split("_"),monthsShort:"Gen._Febr._Març_Abr._Maig_Juny_Jul._Ag._Set._Oct._Nov._Des.".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM [de] YYYY",LLL:"D MMMM [de] YYYY [a les] H:mm",LLLL:"dddd D MMMM [de] YYYY [a les] H:mm",ll:"D MMM YYYY",lll:"D MMM YYYY, H:mm",llll:"ddd D MMM YYYY, H:mm"},relativeTime:{future:"d'aquí %s",past:"fa %s",s:"uns segons",m:"un minut",mm:"%d minuts",h:"una hora",hh:"%d hores",d:"un dia",dd:"%d dies",M:"un mes",MM:"%d mesos",y:"un any",yy:"%d anys"},ordinal:function(e){return e+(1===e||3===e?"r":2===e?"n":4===e?"t":"è")}};return t.default.locale(n,null,!0),n}(n(7484))},8507:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e);function n(e){return e>1&&e<5&&1!=~~(e/10)}function r(e,t,r,a){var i=e+" ";switch(r){case"s":return t||a?"pár sekund":"pár sekundami";case"m":return t?"minuta":a?"minutu":"minutou";case"mm":return t||a?i+(n(e)?"minuty":"minut"):i+"minutami";case"h":return t?"hodina":a?"hodinu":"hodinou";case"hh":return t||a?i+(n(e)?"hodiny":"hodin"):i+"hodinami";case"d":return t||a?"den":"dnem";case"dd":return t||a?i+(n(e)?"dny":"dní"):i+"dny";case"M":return t||a?"měsíc":"měsícem";case"MM":return t||a?i+(n(e)?"měsíce":"měsíců"):i+"měsíci";case"y":return t||a?"rok":"rokem";case"yy":return t||a?i+(n(e)?"roky":"let"):i+"lety"}}var a={name:"cs",weekdays:"neděle_pondělí_úterý_středa_čtvrtek_pátek_sobota".split("_"),weekdaysShort:"ne_po_út_st_čt_pá_so".split("_"),weekdaysMin:"ne_po_út_st_čt_pá_so".split("_"),months:"leden_únor_březen_duben_květen_červen_červenec_srpen_září_říjen_listopad_prosinec".split("_"),monthsShort:"led_úno_bře_dub_kvě_čvn_čvc_srp_zář_říj_lis_pro".split("_"),weekStart:1,yearStart:4,ordinal:function(e){return e+"."},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd D. MMMM YYYY H:mm",l:"D. M. YYYY"},relativeTime:{future:"za %s",past:"před %s",s:r,m:r,mm:r,h:r,hh:r,d:r,dd:r,M:r,MM:r,y:r,yy:r}};return t.default.locale(a,null,!0),a}(n(7484))},6636:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"cv",weekdays:"вырсарникун_тунтикун_ытларикун_юнкун_кӗҫнерникун_эрнекун_шӑматкун".split("_"),months:"кӑрлач_нарӑс_пуш_ака_май_ҫӗртме_утӑ_ҫурла_авӑн_юпа_чӳк_раштав".split("_"),weekStart:1,weekdaysShort:"выр_тун_ытл_юн_кӗҫ_эрн_шӑм".split("_"),monthsShort:"кӑр_нар_пуш_ака_май_ҫӗр_утӑ_ҫур_авн_юпа_чӳк_раш".split("_"),weekdaysMin:"вр_тн_ыт_юн_кҫ_эр_шм".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD-MM-YYYY",LL:"YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ]",LLL:"YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], HH:mm",LLLL:"dddd, YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},8792:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"cy",weekdays:"Dydd Sul_Dydd Llun_Dydd Mawrth_Dydd Mercher_Dydd Iau_Dydd Gwener_Dydd Sadwrn".split("_"),months:"Ionawr_Chwefror_Mawrth_Ebrill_Mai_Mehefin_Gorffennaf_Awst_Medi_Hydref_Tachwedd_Rhagfyr".split("_"),weekStart:1,weekdaysShort:"Sul_Llun_Maw_Mer_Iau_Gwe_Sad".split("_"),monthsShort:"Ion_Chwe_Maw_Ebr_Mai_Meh_Gor_Aws_Med_Hyd_Tach_Rhag".split("_"),weekdaysMin:"Su_Ll_Ma_Me_Ia_Gw_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"mewn %s",past:"%s yn ôl",s:"ychydig eiliadau",m:"munud",mm:"%d munud",h:"awr",hh:"%d awr",d:"diwrnod",dd:"%d diwrnod",M:"mis",MM:"%d mis",y:"blwyddyn",yy:"%d flynedd"}};return t.default.locale(n,null,!0),n}(n(7484))},7427:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"da",weekdays:"søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag".split("_"),weekdaysShort:"søn._man._tirs._ons._tors._fre._lør.".split("_"),weekdaysMin:"sø._ma._ti._on._to._fr._lø.".split("_"),months:"januar_februar_marts_april_maj_juni_juli_august_september_oktober_november_december".split("_"),monthsShort:"jan._feb._mar._apr._maj_juni_juli_aug._sept._okt._nov._dec.".split("_"),weekStart:1,ordinal:function(e){return e+"."},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY HH:mm",LLLL:"dddd [d.] D. MMMM YYYY [kl.] HH:mm"},relativeTime:{future:"om %s",past:"%s siden",s:"få sekunder",m:"et minut",mm:"%d minutter",h:"en time",hh:"%d timer",d:"en dag",dd:"%d dage",M:"en måned",MM:"%d måneder",y:"et år",yy:"%d år"}};return t.default.locale(n,null,!0),n}(n(7484))},3237:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={s:"ein paar Sekunden",m:["eine Minute","einer Minute"],mm:"%d Minuten",h:["eine Stunde","einer Stunde"],hh:"%d Stunden",d:["ein Tag","einem Tag"],dd:["%d Tage","%d Tagen"],M:["ein Monat","einem Monat"],MM:["%d Monate","%d Monaten"],y:["ein Jahr","einem Jahr"],yy:["%d Jahre","%d Jahren"]};function r(e,t,r){var a=n[r];return Array.isArray(a)&&(a=a[t?0:1]),a.replace("%d",e)}var a={name:"de-at",weekdays:"Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag".split("_"),weekdaysShort:"So._Mo._Di._Mi._Do._Fr._Sa.".split("_"),weekdaysMin:"So_Mo_Di_Mi_Do_Fr_Sa".split("_"),months:"Jänner_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember".split("_"),monthsShort:"Jän._Feb._März_Apr._Mai_Juni_Juli_Aug._Sep._Okt._Nov._Dez.".split("_"),ordinal:function(e){return e+"."},weekStart:1,formats:{LTS:"HH:mm:ss",LT:"HH:mm",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY HH:mm",LLLL:"dddd, D. MMMM YYYY HH:mm"},relativeTime:{future:"in %s",past:"vor %s",s:r,m:r,mm:r,h:r,hh:r,d:r,dd:r,M:r,MM:r,y:r,yy:r}};return t.default.locale(a,null,!0),a}(n(7484))},6148:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={s:"ein paar Sekunden",m:["eine Minute","einer Minute"],mm:"%d Minuten",h:["eine Stunde","einer Stunde"],hh:"%d Stunden",d:["ein Tag","einem Tag"],dd:["%d Tage","%d Tagen"],M:["ein Monat","einem Monat"],MM:["%d Monate","%d Monaten"],y:["ein Jahr","einem Jahr"],yy:["%d Jahre","%d Jahren"]};function r(e,t,r){var a=n[r];return Array.isArray(a)&&(a=a[t?0:1]),a.replace("%d",e)}var a={name:"de-ch",weekdays:"Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag".split("_"),weekdaysShort:"So_Mo_Di_Mi_Do_Fr_Sa".split("_"),weekdaysMin:"So_Mo_Di_Mi_Do_Fr_Sa".split("_"),months:"Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember".split("_"),monthsShort:"Jan._Feb._März_Apr._Mai_Juni_Juli_Aug._Sep._Okt._Nov._Dez.".split("_"),ordinal:function(e){return e+"."},weekStart:1,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY HH:mm",LLLL:"dddd, D. MMMM YYYY HH:mm"},relativeTime:{future:"in %s",past:"vor %s",s:r,m:r,mm:r,h:r,hh:r,d:r,dd:r,M:r,MM:r,y:r,yy:r}};return t.default.locale(a,null,!0),a}(n(7484))},790:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={s:"ein paar Sekunden",m:["eine Minute","einer Minute"],mm:"%d Minuten",h:["eine Stunde","einer Stunde"],hh:"%d Stunden",d:["ein Tag","einem Tag"],dd:["%d Tage","%d Tagen"],M:["ein Monat","einem Monat"],MM:["%d Monate","%d Monaten"],y:["ein Jahr","einem Jahr"],yy:["%d Jahre","%d Jahren"]};function r(e,t,r){var a=n[r];return Array.isArray(a)&&(a=a[t?0:1]),a.replace("%d",e)}var a={name:"de",weekdays:"Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag".split("_"),weekdaysShort:"So._Mo._Di._Mi._Do._Fr._Sa.".split("_"),weekdaysMin:"So_Mo_Di_Mi_Do_Fr_Sa".split("_"),months:"Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember".split("_"),monthsShort:"Jan._Feb._März_Apr._Mai_Juni_Juli_Aug._Sept._Okt._Nov._Dez.".split("_"),ordinal:function(e){return e+"."},weekStart:1,yearStart:4,formats:{LTS:"HH:mm:ss",LT:"HH:mm",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY HH:mm",LLLL:"dddd, D. MMMM YYYY HH:mm"},relativeTime:{future:"in %s",past:"vor %s",s:r,m:r,mm:r,h:r,hh:r,d:r,dd:r,M:r,MM:r,y:r,yy:r}};return t.default.locale(a,null,!0),a}(n(7484))},1794:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"dv",weekdays:"އާދިއްތަ_ހޯމަ_އަންގާރަ_ބުދަ_ބުރާސްފަތި_ހުކުރު_ހޮނިހިރު".split("_"),months:"ޖެނުއަރީ_ފެބްރުއަރީ_މާރިޗު_އޭޕްރީލު_މޭ_ޖޫން_ޖުލައި_އޯގަސްޓު_ސެޕްޓެމްބަރު_އޮކްޓޯބަރު_ނޮވެމްބަރު_ޑިސެމްބަރު".split("_"),weekStart:7,weekdaysShort:"އާދިއްތަ_ހޯމަ_އަންގާރަ_ބުދަ_ބުރާސްފަތި_ހުކުރު_ހޮނިހިރު".split("_"),monthsShort:"ޖެނުއަރީ_ފެބްރުއަރީ_މާރިޗު_އޭޕްރީލު_މޭ_ޖޫން_ޖުލައި_އޯގަސްޓު_ސެޕްޓެމްބަރު_އޮކްޓޯބަރު_ނޮވެމްބަރު_ޑިސެމްބަރު".split("_"),weekdaysMin:"އާދި_ހޯމަ_އަން_ބުދަ_ބުރާ_ހުކު_ހޮނި".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"D/M/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"ތެރޭގައި %s",past:"ކުރިން %s",s:"ސިކުންތުކޮޅެއް",m:"މިނިޓެއް",mm:"މިނިޓު %d",h:"ގަޑިއިރެއް",hh:"ގަޑިއިރު %d",d:"ދުވަހެއް",dd:"ދުވަސް %d",M:"މަހެއް",MM:"މަސް %d",y:"އަހަރެއް",yy:"އަހަރު %d"}};return t.default.locale(n,null,!0),n}(n(7484))},5423:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"el",weekdays:"Κυριακή_Δευτέρα_Τρίτη_Τετάρτη_Πέμπτη_Παρασκευή_Σάββατο".split("_"),weekdaysShort:"Κυρ_Δευ_Τρι_Τετ_Πεμ_Παρ_Σαβ".split("_"),weekdaysMin:"Κυ_Δε_Τρ_Τε_Πε_Πα_Σα".split("_"),months:"Ιανουάριος_Φεβρουάριος_Μάρτιος_Απρίλιος_Μάιος_Ιούνιος_Ιούλιος_Αύγουστος_Σεπτέμβριος_Οκτώβριος_Νοέμβριος_Δεκέμβριος".split("_"),monthsShort:"Ιαν_Φεβ_Μαρ_Απρ_Μαι_Ιουν_Ιουλ_Αυγ_Σεπτ_Οκτ_Νοε_Δεκ".split("_"),ordinal:function(e){return e},weekStart:1,relativeTime:{future:"σε %s",past:"πριν %s",s:"μερικά δευτερόλεπτα",m:"ένα λεπτό",mm:"%d λεπτά",h:"μία ώρα",hh:"%d ώρες",d:"μία μέρα",dd:"%d μέρες",M:"ένα μήνα",MM:"%d μήνες",y:"ένα χρόνο",yy:"%d χρόνια"},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY h:mm A",LLLL:"dddd, D MMMM YYYY h:mm A"}};return t.default.locale(n,null,!0),n}(n(7484))},5109:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-au",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),weekStart:1,weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY h:mm A",LLLL:"dddd, D MMMM YYYY h:mm A"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"}};return t.default.locale(n,null,!0),n}(n(7484))},5105:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-ca",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"YYYY-MM-DD",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"}};return t.default.locale(n,null,!0),n}(n(7484))},9517:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-gb",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekStart:1,yearStart:4,relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"}};return t.default.locale(n,null,!0),n}(n(7484))},758:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-ie",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),weekStart:1,weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"}};return t.default.locale(n,null,!0),n}(n(7484))},5805:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-il",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"}};return t.default.locale(n,null,!0),n}(n(7484))},8529:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-in",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekStart:1,yearStart:4,relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"}};return t.default.locale(n,null,!0),n}(n(7484))},302:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-nz",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),weekStart:1,weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY h:mm A",LLLL:"dddd, D MMMM YYYY h:mm A"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"}};return t.default.locale(n,null,!0),n}(n(7484))},5941:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-sg",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),weekStart:1,weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"}};return t.default.locale(n,null,!0),n}(n(7484))},6183:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"en-tt",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekStart:1,yearStart:4,relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"}};return t.default.locale(n,null,!0),n}(n(7484))},5054:function(e){e.exports=function(){"use strict";return{name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")}}()},4990:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"eo",weekdays:"dimanĉo_lundo_mardo_merkredo_ĵaŭdo_vendredo_sabato".split("_"),months:"januaro_februaro_marto_aprilo_majo_junio_julio_aŭgusto_septembro_oktobro_novembro_decembro".split("_"),weekStart:1,weekdaysShort:"dim_lun_mard_merk_ĵaŭ_ven_sab".split("_"),monthsShort:"jan_feb_mar_apr_maj_jun_jul_aŭg_sep_okt_nov_dec".split("_"),weekdaysMin:"di_lu_ma_me_ĵa_ve_sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"D[-a de] MMMM, YYYY",LLL:"D[-a de] MMMM, YYYY HH:mm",LLLL:"dddd, [la] D[-a de] MMMM, YYYY HH:mm"},relativeTime:{future:"post %s",past:"antaŭ %s",s:"sekundoj",m:"minuto",mm:"%d minutoj",h:"horo",hh:"%d horoj",d:"tago",dd:"%d tagoj",M:"monato",MM:"%d monatoj",y:"jaro",yy:"%d jaroj"}};return t.default.locale(n,null,!0),n}(n(7484))},3864:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"es-do",weekdays:"domingo_lunes_martes_miércoles_jueves_viernes_sábado".split("_"),weekdaysShort:"dom._lun._mar._mié._jue._vie._sáb.".split("_"),weekdaysMin:"do_lu_ma_mi_ju_vi_sá".split("_"),months:"enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),monthsShort:"ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"),weekStart:1,relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un año",yy:"%d años"},ordinal:function(e){return e+"º"},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY h:mm A",LLLL:"dddd, D [de] MMMM [de] YYYY h:mm A"}};return t.default.locale(n,null,!0),n}(n(7484))},7118:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"es-mx",weekdays:"domingo_lunes_martes_miércoles_jueves_viernes_sábado".split("_"),weekdaysShort:"dom._lun._mar._mié._jue._vie._sáb.".split("_"),weekdaysMin:"do_lu_ma_mi_ju_vi_sá".split("_"),months:"enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),monthsShort:"ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"),relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un año",yy:"%d años"},ordinal:function(e){return e+"º"},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY H:mm",LLLL:"dddd, D [de] MMMM [de] YYYY H:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},3521:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"es-pr",monthsShort:"ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"),weekdays:"domingo_lunes_martes_miércoles_jueves_viernes_sábado".split("_"),weekdaysShort:"dom._lun._mar._mié._jue._vie._sáb.".split("_"),weekdaysMin:"do_lu_ma_mi_ju_vi_sá".split("_"),months:"enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),weekStart:1,formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"MM/DD/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY h:mm A",LLLL:"dddd, D [de] MMMM [de] YYYY h:mm A"},relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un año",yy:"%d años"},ordinal:function(e){return e+"º"}};return t.default.locale(n,null,!0),n}(n(7484))},6165:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"es-us",weekdays:"domingo_lunes_martes_miércoles_jueves_viernes_sábado".split("_"),weekdaysShort:"dom._lun._mar._mié._jue._vie._sáb.".split("_"),weekdaysMin:"do_lu_ma_mi_ju_vi_sá".split("_"),months:"enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),monthsShort:"ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"),relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un año",yy:"%d años"},ordinal:function(e){return e+"º"},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"MM/DD/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY h:mm A",LLLL:"dddd, D [de] MMMM [de] YYYY h:mm A"}};return t.default.locale(n,null,!0),n}(n(7484))},7763:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"es",monthsShort:"ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"),weekdays:"domingo_lunes_martes_miércoles_jueves_viernes_sábado".split("_"),weekdaysShort:"dom._lun._mar._mié._jue._vie._sáb.".split("_"),weekdaysMin:"do_lu_ma_mi_ju_vi_sá".split("_"),months:"enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY H:mm",LLLL:"dddd, D [de] MMMM [de] YYYY H:mm"},relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un año",yy:"%d años"},ordinal:function(e){return e+"º"}};return t.default.locale(n,null,!0),n}(n(7484))},9670:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e);function n(e,t,n,r){var a={s:["mõne sekundi","mõni sekund","paar sekundit"],m:["ühe minuti","üks minut"],mm:["%d minuti","%d minutit"],h:["ühe tunni","tund aega","üks tund"],hh:["%d tunni","%d tundi"],d:["ühe päeva","üks päev"],M:["kuu aja","kuu aega","üks kuu"],MM:["%d kuu","%d kuud"],y:["ühe aasta","aasta","üks aasta"],yy:["%d aasta","%d aastat"]};return t?(a[n][2]?a[n][2]:a[n][1]).replace("%d",e):(r?a[n][0]:a[n][1]).replace("%d",e)}var r={name:"et",weekdays:"pühapäev_esmaspäev_teisipäev_kolmapäev_neljapäev_reede_laupäev".split("_"),weekdaysShort:"P_E_T_K_N_R_L".split("_"),weekdaysMin:"P_E_T_K_N_R_L".split("_"),months:"jaanuar_veebruar_märts_aprill_mai_juuni_juuli_august_september_oktoober_november_detsember".split("_"),monthsShort:"jaan_veebr_märts_apr_mai_juuni_juuli_aug_sept_okt_nov_dets".split("_"),ordinal:function(e){return e+"."},weekStart:1,relativeTime:{future:"%s pärast",past:"%s tagasi",s:n,m:n,mm:n,h:n,hh:n,d:n,dd:"%d päeva",M:n,MM:n,y:n,yy:n},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd, D. MMMM YYYY H:mm"}};return t.default.locale(r,null,!0),r}(n(7484))},6629:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"eu",weekdays:"igandea_astelehena_asteartea_asteazkena_osteguna_ostirala_larunbata".split("_"),months:"urtarrila_otsaila_martxoa_apirila_maiatza_ekaina_uztaila_abuztua_iraila_urria_azaroa_abendua".split("_"),weekStart:1,weekdaysShort:"ig._al._ar._az._og._ol._lr.".split("_"),monthsShort:"urt._ots._mar._api._mai._eka._uzt._abu._ira._urr._aza._abe.".split("_"),weekdaysMin:"ig_al_ar_az_og_ol_lr".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"YYYY[ko] MMMM[ren] D[a]",LLL:"YYYY[ko] MMMM[ren] D[a] HH:mm",LLLL:"dddd, YYYY[ko] MMMM[ren] D[a] HH:mm",l:"YYYY-M-D",ll:"YYYY[ko] MMM D[a]",lll:"YYYY[ko] MMM D[a] HH:mm",llll:"ddd, YYYY[ko] MMM D[a] HH:mm"},relativeTime:{future:"%s barru",past:"duela %s",s:"segundo batzuk",m:"minutu bat",mm:"%d minutu",h:"ordu bat",hh:"%d ordu",d:"egun bat",dd:"%d egun",M:"hilabete bat",MM:"%d hilabete",y:"urte bat",yy:"%d urte"}};return t.default.locale(n,null,!0),n}(n(7484))},6953:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"fa",weekdays:"یک‌شنبه_دوشنبه_سه‌شنبه_چهارشنبه_پنج‌شنبه_جمعه_شنبه".split("_"),weekdaysShort:"یک‌شنبه_دوشنبه_سه‌شنبه_چهارشنبه_پنج‌شنبه_جمعه_شنبه".split("_"),weekdaysMin:"ی_د_س_چ_پ_ج_ش".split("_"),weekStart:6,months:"ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر".split("_"),monthsShort:"ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"در %s",past:"%s پیش",s:"چند ثانیه",m:"یک دقیقه",mm:"%d دقیقه",h:"یک ساعت",hh:"%d ساعت",d:"یک روز",dd:"%d روز",M:"یک ماه",MM:"%d ماه",y:"یک سال",yy:"%d سال"}};return t.default.locale(n,null,!0),n}(n(7484))},7822:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e);function n(e,t,n,r){var a={s:"muutama sekunti",m:"minuutti",mm:"%d minuuttia",h:"tunti",hh:"%d tuntia",d:"päivä",dd:"%d päivää",M:"kuukausi",MM:"%d kuukautta",y:"vuosi",yy:"%d vuotta",numbers:"nolla_yksi_kaksi_kolme_neljä_viisi_kuusi_seitsemän_kahdeksan_yhdeksän".split("_")},i={s:"muutaman sekunnin",m:"minuutin",mm:"%d minuutin",h:"tunnin",hh:"%d tunnin",d:"päivän",dd:"%d päivän",M:"kuukauden",MM:"%d kuukauden",y:"vuoden",yy:"%d vuoden",numbers:"nollan_yhden_kahden_kolmen_neljän_viiden_kuuden_seitsemän_kahdeksan_yhdeksän".split("_")},s=r&&!t?i:a,o=s[n];return e<10?o.replace("%d",s.numbers[e]):o.replace("%d",e)}var r={name:"fi",weekdays:"sunnuntai_maanantai_tiistai_keskiviikko_torstai_perjantai_lauantai".split("_"),weekdaysShort:"su_ma_ti_ke_to_pe_la".split("_"),weekdaysMin:"su_ma_ti_ke_to_pe_la".split("_"),months:"tammikuu_helmikuu_maaliskuu_huhtikuu_toukokuu_kesäkuu_heinäkuu_elokuu_syyskuu_lokakuu_marraskuu_joulukuu".split("_"),monthsShort:"tammi_helmi_maalis_huhti_touko_kesä_heinä_elo_syys_loka_marras_joulu".split("_"),ordinal:function(e){return e+"."},weekStart:1,yearStart:4,relativeTime:{future:"%s päästä",past:"%s sitten",s:n,m:n,mm:n,h:n,hh:n,d:n,dd:n,M:n,MM:n,y:n,yy:n},formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD.MM.YYYY",LL:"D. MMMM[ta] YYYY",LLL:"D. MMMM[ta] YYYY, [klo] HH.mm",LLLL:"dddd, D. MMMM[ta] YYYY, [klo] HH.mm",l:"D.M.YYYY",ll:"D. MMM YYYY",lll:"D. MMM YYYY, [klo] HH.mm",llll:"ddd, D. MMM YYYY, [klo] HH.mm"}};return t.default.locale(r,null,!0),r}(n(7484))},9197:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"fo",weekdays:"sunnudagur_mánadagur_týsdagur_mikudagur_hósdagur_fríggjadagur_leygardagur".split("_"),months:"januar_februar_mars_apríl_mai_juni_juli_august_september_oktober_november_desember".split("_"),weekStart:1,weekdaysShort:"sun_mán_týs_mik_hós_frí_ley".split("_"),monthsShort:"jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des".split("_"),weekdaysMin:"su_má_tý_mi_hó_fr_le".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D. MMMM, YYYY HH:mm"},relativeTime:{future:"um %s",past:"%s síðani",s:"fá sekund",m:"ein minuttur",mm:"%d minuttir",h:"ein tími",hh:"%d tímar",d:"ein dagur",dd:"%d dagar",M:"ein mánaður",MM:"%d mánaðir",y:"eitt ár",yy:"%d ár"}};return t.default.locale(n,null,!0),n}(n(7484))},7989:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"fr-ca",weekdays:"dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi".split("_"),months:"janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre".split("_"),weekdaysShort:"dim._lun._mar._mer._jeu._ven._sam.".split("_"),monthsShort:"janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.".split("_"),weekdaysMin:"di_lu_ma_me_je_ve_sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"dans %s",past:"il y a %s",s:"quelques secondes",m:"une minute",mm:"%d minutes",h:"une heure",hh:"%d heures",d:"un jour",dd:"%d jours",M:"un mois",MM:"%d mois",y:"un an",yy:"%d ans"}};return t.default.locale(n,null,!0),n}(n(7484))},4254:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"fr-ch",weekdays:"dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi".split("_"),months:"janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre".split("_"),weekStart:1,weekdaysShort:"dim._lun._mar._mer._jeu._ven._sam.".split("_"),monthsShort:"janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.".split("_"),weekdaysMin:"di_lu_ma_me_je_ve_sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"dans %s",past:"il y a %s",s:"quelques secondes",m:"une minute",mm:"%d minutes",h:"une heure",hh:"%d heures",d:"un jour",dd:"%d jours",M:"un mois",MM:"%d mois",y:"un an",yy:"%d ans"}};return t.default.locale(n,null,!0),n}(n(7484))},6023:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"fr",weekdays:"dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi".split("_"),weekdaysShort:"dim._lun._mar._mer._jeu._ven._sam.".split("_"),weekdaysMin:"di_lu_ma_me_je_ve_sa".split("_"),months:"janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre".split("_"),monthsShort:"janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.".split("_"),weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"dans %s",past:"il y a %s",s:"quelques secondes",m:"une minute",mm:"%d minutes",h:"une heure",hh:"%d heures",d:"un jour",dd:"%d jours",M:"un mois",MM:"%d mois",y:"un an",yy:"%d ans"},ordinal:function(e){return e+(1===e?"er":"")}};return t.default.locale(n,null,!0),n}(n(7484))},3220:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"fy",weekdays:"snein_moandei_tiisdei_woansdei_tongersdei_freed_sneon".split("_"),months:"jannewaris_febrewaris_maart_april_maaie_juny_july_augustus_septimber_oktober_novimber_desimber".split("_"),monthsShort:"jan._feb._mrt._apr._mai_jun._jul._aug._sep._okt._nov._des.".split("_"),weekStart:1,weekdaysShort:"si._mo._ti._wo._to._fr._so.".split("_"),weekdaysMin:"Si_Mo_Ti_Wo_To_Fr_So".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD-MM-YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"oer %s",past:"%s lyn",s:"in pear sekonden",m:"ien minút",mm:"%d minuten",h:"ien oere",hh:"%d oeren",d:"ien dei",dd:"%d dagen",M:"ien moanne",MM:"%d moannen",y:"ien jier",yy:"%d jierren"}};return t.default.locale(n,null,!0),n}(n(7484))},7467:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ga",weekdays:"Dé Domhnaigh_Dé Luain_Dé Máirt_Dé Céadaoin_Déardaoin_Dé hAoine_Dé Satharn".split("_"),months:"Eanáir_Feabhra_Márta_Aibreán_Bealtaine_Méitheamh_Iúil_Lúnasa_Meán Fómhair_Deaireadh Fómhair_Samhain_Nollaig".split("_"),weekStart:1,weekdaysShort:"Dom_Lua_Mái_Céa_Déa_hAo_Sat".split("_"),monthsShort:"Eaná_Feab_Márt_Aibr_Beal_Méit_Iúil_Lúna_Meán_Deai_Samh_Noll".split("_"),weekdaysMin:"Do_Lu_Má_Ce_Dé_hA_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"i %s",past:"%s ó shin",s:"cúpla soicind",m:"nóiméad",mm:"%d nóiméad",h:"uair an chloig",hh:"%d uair an chloig",d:"lá",dd:"%d lá",M:"mí",MM:"%d mí",y:"bliain",yy:"%d bliain"}};return t.default.locale(n,null,!0),n}(n(7484))},4855:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"gd",weekdays:"Didòmhnaich_Diluain_Dimàirt_Diciadain_Diardaoin_Dihaoine_Disathairne".split("_"),months:"Am Faoilleach_An Gearran_Am Màrt_An Giblean_An Cèitean_An t-Ògmhios_An t-Iuchar_An Lùnastal_An t-Sultain_An Dàmhair_An t-Samhain_An Dùbhlachd".split("_"),weekStart:1,weekdaysShort:"Did_Dil_Dim_Dic_Dia_Dih_Dis".split("_"),monthsShort:"Faoi_Gear_Màrt_Gibl_Cèit_Ògmh_Iuch_Lùn_Sult_Dàmh_Samh_Dùbh".split("_"),weekdaysMin:"Dò_Lu_Mà_Ci_Ar_Ha_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"ann an %s",past:"bho chionn %s",s:"beagan diogan",m:"mionaid",mm:"%d mionaidean",h:"uair",hh:"%d uairean",d:"latha",dd:"%d latha",M:"mìos",MM:"%d mìosan",y:"bliadhna",yy:"%d bliadhna"}};return t.default.locale(n,null,!0),n}(n(7484))},229:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"gl",weekdays:"domingo_luns_martes_mércores_xoves_venres_sábado".split("_"),months:"xaneiro_febreiro_marzo_abril_maio_xuño_xullo_agosto_setembro_outubro_novembro_decembro".split("_"),weekStart:1,weekdaysShort:"dom._lun._mar._mér._xov._ven._sáb.".split("_"),monthsShort:"xan._feb._mar._abr._mai._xuñ._xul._ago._set._out._nov._dec.".split("_"),weekdaysMin:"do_lu_ma_mé_xo_ve_sá".split("_"),ordinal:function(e){return e+"º"},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY H:mm",LLLL:"dddd, D [de] MMMM [de] YYYY H:mm"},relativeTime:{future:"en %s",past:"fai %s",s:"uns segundos",m:"un minuto",mm:"%d minutos",h:"unha hora",hh:"%d horas",d:"un día",dd:"%d días",M:"un mes",MM:"%d meses",y:"un ano",yy:"%d anos"}};return t.default.locale(n,null,!0),n}(n(7484))},6312:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"gom-latn",weekdays:"Aitar_Somar_Mongllar_Budvar_Brestar_Sukrar_Son'var".split("_"),months:"Janer_Febrer_Mars_Abril_Mai_Jun_Julai_Agost_Setembr_Otubr_Novembr_Dezembr".split("_"),weekStart:1,weekdaysShort:"Ait._Som._Mon._Bud._Bre._Suk._Son.".split("_"),monthsShort:"Jan._Feb._Mars_Abr._Mai_Jun_Jul._Ago._Set._Otu._Nov._Dez.".split("_"),weekdaysMin:"Ai_Sm_Mo_Bu_Br_Su_Sn".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm [vazta]",LTS:"A h:mm:ss [vazta]",L:"DD-MM-YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY A h:mm [vazta]",LLLL:"dddd, MMMM[achea] Do, YYYY, A h:mm [vazta]",llll:"ddd, D MMM YYYY, A h:mm [vazta]"}};return t.default.locale(n,null,!0),n}(n(7484))},7632:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"gu",weekdays:"રવિવાર_સોમવાર_મંગળવાર_બુધ્વાર_ગુરુવાર_શુક્રવાર_શનિવાર".split("_"),months:"જાન્યુઆરી_ફેબ્રુઆરી_માર્ચ_એપ્રિલ_મે_જૂન_જુલાઈ_ઑગસ્ટ_સપ્ટેમ્બર_ઑક્ટ્બર_નવેમ્બર_ડિસેમ્બર".split("_"),weekdaysShort:"રવિ_સોમ_મંગળ_બુધ્_ગુરુ_શુક્ર_શનિ".split("_"),monthsShort:"જાન્યુ._ફેબ્રુ._માર્ચ_એપ્રિ._મે_જૂન_જુલા._ઑગ._સપ્ટે._ઑક્ટ્._નવે._ડિસે.".split("_"),weekdaysMin:"ર_સો_મં_બુ_ગુ_શુ_શ".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm વાગ્યે",LTS:"A h:mm:ss વાગ્યે",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm વાગ્યે",LLLL:"dddd, D MMMM YYYY, A h:mm વાગ્યે"},relativeTime:{future:"%s મા",past:"%s પેહલા",s:"અમુક પળો",m:"એક મિનિટ",mm:"%d મિનિટ",h:"એક કલાક",hh:"%d કલાક",d:"એક દિવસ",dd:"%d દિવસ",M:"એક મહિનો",MM:"%d મહિનો",y:"એક વર્ષ",yy:"%d વર્ષ"}};return t.default.locale(n,null,!0),n}(n(7484))},5418:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={s:"מספר שניות",ss:"%d שניות",m:"דקה",mm:"%d דקות",h:"שעה",hh:"%d שעות",hh2:"שעתיים",d:"יום",dd:"%d ימים",dd2:"יומיים",M:"חודש",MM:"%d חודשים",MM2:"חודשיים",y:"שנה",yy:"%d שנים",yy2:"שנתיים"};function r(e,t,r){return(n[r+(2===e?"2":"")]||n[r]).replace("%d",e)}var a={name:"he",weekdays:"ראשון_שני_שלישי_רביעי_חמישי_שישי_שבת".split("_"),weekdaysShort:"א׳_ב׳_ג׳_ד׳_ה׳_ו׳_ש׳".split("_"),weekdaysMin:"א׳_ב׳_ג׳_ד׳_ה׳_ו_ש׳".split("_"),months:"ינואר_פברואר_מרץ_אפריל_מאי_יוני_יולי_אוגוסט_ספטמבר_אוקטובר_נובמבר_דצמבר".split("_"),monthsShort:"ינו_פבר_מרץ_אפר_מאי_יונ_יול_אוג_ספט_אוק_נוב_דצמ".split("_"),relativeTime:{future:"בעוד %s",past:"לפני %s",s:r,m:r,mm:r,h:r,hh:r,d:r,dd:r,M:r,MM:r,y:r,yy:r},ordinal:function(e){return e},format:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D [ב]MMMM YYYY",LLL:"D [ב]MMMM YYYY HH:mm",LLLL:"dddd, D [ב]MMMM YYYY HH:mm",l:"D/M/YYYY",ll:"D MMM YYYY",lll:"D MMM YYYY HH:mm",llll:"ddd, D MMM YYYY HH:mm"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D [ב]MMMM YYYY",LLL:"D [ב]MMMM YYYY HH:mm",LLLL:"dddd, D [ב]MMMM YYYY HH:mm",l:"D/M/YYYY",ll:"D MMM YYYY",lll:"D MMM YYYY HH:mm",llll:"ddd, D MMM YYYY HH:mm"}};return t.default.locale(a,null,!0),a}(n(7484))},7573:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"hi",weekdays:"रविवार_सोमवार_मंगलवार_बुधवार_गुरूवार_शुक्रवार_शनिवार".split("_"),months:"जनवरी_फ़रवरी_मार्च_अप्रैल_मई_जून_जुलाई_अगस्त_सितम्बर_अक्टूबर_नवम्बर_दिसम्बर".split("_"),weekdaysShort:"रवि_सोम_मंगल_बुध_गुरू_शुक्र_शनि".split("_"),monthsShort:"जन._फ़र._मार्च_अप्रै._मई_जून_जुल._अग._सित._अक्टू._नव._दिस.".split("_"),weekdaysMin:"र_सो_मं_बु_गु_शु_श".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm बजे",LTS:"A h:mm:ss बजे",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm बजे",LLLL:"dddd, D MMMM YYYY, A h:mm बजे"},relativeTime:{future:"%s में",past:"%s पहले",s:"कुछ ही क्षण",m:"एक मिनट",mm:"%d मिनट",h:"एक घंटा",hh:"%d घंटे",d:"एक दिन",dd:"%d दिन",M:"एक महीने",MM:"%d महीने",y:"एक वर्ष",yy:"%d वर्ष"}};return t.default.locale(n,null,!0),n}(n(7484))},6257:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n="siječnja_veljače_ožujka_travnja_svibnja_lipnja_srpnja_kolovoza_rujna_listopada_studenoga_prosinca".split("_"),r="siječanj_veljača_ožujak_travanj_svibanj_lipanj_srpanj_kolovoz_rujan_listopad_studeni_prosinac".split("_"),a=/D[oD]?(\[[^[\]]*\]|\s)+MMMM?/,i=function(e,t){return a.test(t)?n[e.month()]:r[e.month()]};i.s=r,i.f=n;var s={name:"hr",weekdays:"nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota".split("_"),weekdaysShort:"ned._pon._uto._sri._čet._pet._sub.".split("_"),weekdaysMin:"ne_po_ut_sr_če_pe_su".split("_"),months:i,monthsShort:"sij._velj._ožu._tra._svi._lip._srp._kol._ruj._lis._stu._pro.".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd, D. MMMM YYYY H:mm"},relativeTime:{future:"za %s",past:"prije %s",s:"sekunda",m:"minuta",mm:"%d minuta",h:"sat",hh:"%d sati",d:"dan",dd:"%d dana",M:"mjesec",MM:"%d mjeseci",y:"godina",yy:"%d godine"},ordinal:function(e){return e+"."}};return t.default.locale(s,null,!0),s}(n(7484))},8889:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ht",weekdays:"dimanch_lendi_madi_mèkredi_jedi_vandredi_samdi".split("_"),months:"janvye_fevriye_mas_avril_me_jen_jiyè_out_septanm_oktòb_novanm_desanm".split("_"),weekdaysShort:"dim._len._mad._mèk._jed._van._sam.".split("_"),monthsShort:"jan._fev._mas_avr._me_jen_jiyè._out_sept._okt._nov._des.".split("_"),weekdaysMin:"di_le_ma_mè_je_va_sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"nan %s",past:"sa gen %s",s:"kèk segond",m:"yon minit",mm:"%d minit",h:"inèdtan",hh:"%d zè",d:"yon jou",dd:"%d jou",M:"yon mwa",MM:"%d mwa",y:"yon ane",yy:"%d ane"}};return t.default.locale(n,null,!0),n}(n(7484))},8562:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"hu",weekdays:"vasárnap_hétfő_kedd_szerda_csütörtök_péntek_szombat".split("_"),weekdaysShort:"vas_hét_kedd_sze_csüt_pén_szo".split("_"),weekdaysMin:"v_h_k_sze_cs_p_szo".split("_"),months:"január_február_március_április_május_június_július_augusztus_szeptember_október_november_december".split("_"),monthsShort:"jan_feb_márc_ápr_máj_jún_júl_aug_szept_okt_nov_dec".split("_"),ordinal:function(e){return e+"."},weekStart:1,relativeTime:{future:"%s múlva",past:"%s",s:function(e,t,n,r){return"néhány másodperc"+(r||t?"":"e")},m:function(e,t,n,r){return"egy perc"+(r||t?"":"e")},mm:function(e,t,n,r){return e+" perc"+(r||t?"":"e")},h:function(e,t,n,r){return"egy "+(r||t?"óra":"órája")},hh:function(e,t,n,r){return e+" "+(r||t?"óra":"órája")},d:function(e,t,n,r){return"egy "+(r||t?"nap":"napja")},dd:function(e,t,n,r){return e+" "+(r||t?"nap":"napja")},M:function(e,t,n,r){return"egy "+(r||t?"hónap":"hónapja")},MM:function(e,t,n,r){return e+" "+(r||t?"hónap":"hónapja")},y:function(e,t,n,r){return"egy "+(r||t?"év":"éve")},yy:function(e,t,n,r){return e+" "+(r||t?"év":"éve")}},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"YYYY.MM.DD.",LL:"YYYY. MMMM D.",LLL:"YYYY. MMMM D. H:mm",LLLL:"YYYY. MMMM D., dddd H:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},8242:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"hy-am",weekdays:"կիրակի_երկուշաբթի_երեքշաբթի_չորեքշաբթի_հինգշաբթի_ուրբաթ_շաբաթ".split("_"),months:"հունվարի_փետրվարի_մարտի_ապրիլի_մայիսի_հունիսի_հուլիսի_օգոստոսի_սեպտեմբերի_հոկտեմբերի_նոյեմբերի_դեկտեմբերի".split("_"),weekStart:1,weekdaysShort:"կրկ_երկ_երք_չրք_հնգ_ուրբ_շբթ".split("_"),monthsShort:"հնվ_փտր_մրտ_ապր_մյս_հնս_հլս_օգս_սպտ_հկտ_նմբ_դկտ".split("_"),weekdaysMin:"կրկ_երկ_երք_չրք_հնգ_ուրբ_շբթ".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY թ.",LLL:"D MMMM YYYY թ., HH:mm",LLLL:"dddd, D MMMM YYYY թ., HH:mm"},relativeTime:{future:"%s հետո",past:"%s առաջ",s:"մի քանի վայրկյան",m:"րոպե",mm:"%d րոպե",h:"ժամ",hh:"%d ժամ",d:"օր",dd:"%d օր",M:"ամիս",MM:"%d ամիս",y:"տարի",yy:"%d տարի"}};return t.default.locale(n,null,!0),n}(n(7484))},3783:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"id",weekdays:"Minggu_Senin_Selasa_Rabu_Kamis_Jumat_Sabtu".split("_"),months:"Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_November_Desember".split("_"),weekdaysShort:"Min_Sen_Sel_Rab_Kam_Jum_Sab".split("_"),monthsShort:"Jan_Feb_Mar_Apr_Mei_Jun_Jul_Agt_Sep_Okt_Nov_Des".split("_"),weekdaysMin:"Mg_Sn_Sl_Rb_Km_Jm_Sb".split("_"),weekStart:1,formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY [pukul] HH.mm",LLLL:"dddd, D MMMM YYYY [pukul] HH.mm"},relativeTime:{future:"dalam %s",past:"%s yang lalu",s:"beberapa detik",m:"semenit",mm:"%d menit",h:"sejam",hh:"%d jam",d:"sehari",dd:"%d hari",M:"sebulan",MM:"%d bulan",y:"setahun",yy:"%d tahun"},ordinal:function(e){return e+"."}};return t.default.locale(n,null,!0),n}(n(7484))},8980:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={s:["nokkrar sekúndur","nokkrar sekúndur","nokkrum sekúndum"],m:["mínúta","mínútu","mínútu"],mm:["mínútur","mínútur","mínútum"],h:["klukkustund","klukkustund","klukkustund"],hh:["klukkustundir","klukkustundir","klukkustundum"],d:["dagur","dag","degi"],dd:["dagar","daga","dögum"],M:["mánuður","mánuð","mánuði"],MM:["mánuðir","mánuði","mánuðum"],y:["ár","ár","ári"],yy:["ár","ár","árum"]};function r(e,t,r,a){var i=function(e,t,r,a){var i=a?0:r?1:2,s=2===e.length&&t%10==1?e[0]:e,o=n[s][i];return 1===e.length?o:"%d "+o}(r,e,a,t);return i.replace("%d",e)}var a={name:"is",weekdays:"sunnudagur_mánudagur_þriðjudagur_miðvikudagur_fimmtudagur_föstudagur_laugardagur".split("_"),months:"janúar_febrúar_mars_apríl_maí_júní_júlí_ágúst_september_október_nóvember_desember".split("_"),weekStart:1,weekdaysShort:"sun_mán_þri_mið_fim_fös_lau".split("_"),monthsShort:"jan_feb_mar_apr_maí_jún_júl_ágú_sep_okt_nóv_des".split("_"),weekdaysMin:"Su_Má_Þr_Mi_Fi_Fö_La".split("_"),ordinal:function(e){return e},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY [kl.] H:mm",LLLL:"dddd, D. MMMM YYYY [kl.] H:mm"},relativeTime:{future:"eftir %s",past:"fyrir %s síðan",s:r,m:r,mm:r,h:r,hh:r,d:r,dd:r,M:r,MM:r,y:r,yy:r}};return t.default.locale(a,null,!0),a}(n(7484))},3706:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"it-ch",weekdays:"domenica_lunedì_martedì_mercoledì_giovedì_venerdì_sabato".split("_"),months:"gennaio_febbraio_marzo_aprile_maggio_giugno_luglio_agosto_settembre_ottobre_novembre_dicembre".split("_"),weekStart:1,weekdaysShort:"dom_lun_mar_mer_gio_ven_sab".split("_"),monthsShort:"gen_feb_mar_apr_mag_giu_lug_ago_set_ott_nov_dic".split("_"),weekdaysMin:"do_lu_ma_me_gi_ve_sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"tra %s",past:"%s fa",s:"alcuni secondi",m:"un minuto",mm:"%d minuti",h:"un'ora",hh:"%d ore",d:"un giorno",dd:"%d giorni",M:"un mese",MM:"%d mesi",y:"un anno",yy:"%d anni"}};return t.default.locale(n,null,!0),n}(n(7484))},5551:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"it",weekdays:"domenica_lunedì_martedì_mercoledì_giovedì_venerdì_sabato".split("_"),weekdaysShort:"dom_lun_mar_mer_gio_ven_sab".split("_"),weekdaysMin:"do_lu_ma_me_gi_ve_sa".split("_"),months:"gennaio_febbraio_marzo_aprile_maggio_giugno_luglio_agosto_settembre_ottobre_novembre_dicembre".split("_"),weekStart:1,monthsShort:"gen_feb_mar_apr_mag_giu_lug_ago_set_ott_nov_dic".split("_"),formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"tra %s",past:"%s fa",s:"qualche secondo",m:"un minuto",mm:"%d minuti",h:"un' ora",hh:"%d ore",d:"un giorno",dd:"%d giorni",M:"un mese",MM:"%d mesi",y:"un anno",yy:"%d anni"},ordinal:function(e){return e+"º"}};return t.default.locale(n,null,!0),n}(n(7484))},6831:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ja",weekdays:"日曜日_月曜日_火曜日_水曜日_木曜日_金曜日_土曜日".split("_"),weekdaysShort:"日_月_火_水_木_金_土".split("_"),weekdaysMin:"日_月_火_水_木_金_土".split("_"),months:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),ordinal:function(e){return e+"日"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日 HH:mm",LLLL:"YYYY年M月D日 dddd HH:mm",l:"YYYY/MM/DD",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日(ddd) HH:mm"},meridiem:function(e){return e<12?"午前":"午後"},relativeTime:{future:"%s後",past:"%s前",s:"数秒",m:"1分",mm:"%d分",h:"1時間",hh:"%d時間",d:"1日",dd:"%d日",M:"1ヶ月",MM:"%dヶ月",y:"1年",yy:"%d年"}};return t.default.locale(n,null,!0),n}(n(7484))},2641:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"jv",weekdays:"Minggu_Senen_Seloso_Rebu_Kemis_Jemuwah_Septu".split("_"),months:"Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_Nopember_Desember".split("_"),weekStart:1,weekdaysShort:"Min_Sen_Sel_Reb_Kem_Jem_Sep".split("_"),monthsShort:"Jan_Feb_Mar_Apr_Mei_Jun_Jul_Ags_Sep_Okt_Nop_Des".split("_"),weekdaysMin:"Mg_Sn_Sl_Rb_Km_Jm_Sp".split("_"),ordinal:function(e){return e},formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY [pukul] HH.mm",LLLL:"dddd, D MMMM YYYY [pukul] HH.mm"},relativeTime:{future:"wonten ing %s",past:"%s ingkang kepengker",s:"sawetawis detik",m:"setunggal menit",mm:"%d menit",h:"setunggal jam",hh:"%d jam",d:"sedinten",dd:"%d dinten",M:"sewulan",MM:"%d wulan",y:"setaun",yy:"%d taun"}};return t.default.locale(n,null,!0),n}(n(7484))},6622:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ka",weekdays:"კვირა_ორშაბათი_სამშაბათი_ოთხშაბათი_ხუთშაბათი_პარასკევი_შაბათი".split("_"),weekdaysShort:"კვი_ორშ_სამ_ოთხ_ხუთ_პარ_შაბ".split("_"),weekdaysMin:"კვ_ორ_სა_ოთ_ხუ_პა_შა".split("_"),months:"იანვარი_თებერვალი_მარტი_აპრილი_მაისი_ივნისი_ივლისი_აგვისტო_სექტემბერი_ოქტომბერი_ნოემბერი_დეკემბერი".split("_"),monthsShort:"იან_თებ_მარ_აპრ_მაი_ივნ_ივლ_აგვ_სექ_ოქტ_ნოე_დეკ".split("_"),weekStart:1,formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY h:mm A",LLLL:"dddd, D MMMM YYYY h:mm A"},relativeTime:{future:"%s შემდეგ",past:"%s წინ",s:"წამი",m:"წუთი",mm:"%d წუთი",h:"საათი",hh:"%d საათის",d:"დღეს",dd:"%d დღის განმავლობაში",M:"თვის",MM:"%d თვის",y:"წელი",yy:"%d წლის"},ordinal:function(e){return e}};return t.default.locale(n,null,!0),n}(n(7484))},2921:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"kk",weekdays:"жексенбі_дүйсенбі_сейсенбі_сәрсенбі_бейсенбі_жұма_сенбі".split("_"),weekdaysShort:"жек_дүй_сей_сәр_бей_жұм_сен".split("_"),weekdaysMin:"жк_дй_сй_ср_бй_жм_сн".split("_"),months:"қаңтар_ақпан_наурыз_сәуір_мамыр_маусым_шілде_тамыз_қыркүйек_қазан_қараша_желтоқсан".split("_"),monthsShort:"қаң_ақп_нау_сәу_мам_мау_шіл_там_қыр_қаз_қар_жел".split("_"),weekStart:1,relativeTime:{future:"%s ішінде",past:"%s бұрын",s:"бірнеше секунд",m:"бір минут",mm:"%d минут",h:"бір сағат",hh:"%d сағат",d:"бір күн",dd:"%d күн",M:"бір ай",MM:"%d ай",y:"бір жыл",yy:"%d жыл"},ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},5567:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"km",weekdays:"អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍".split("_"),months:"មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ".split("_"),weekStart:1,weekdaysShort:"អា_ច_អ_ព_ព្រ_សុ_ស".split("_"),monthsShort:"មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ".split("_"),weekdaysMin:"អា_ច_អ_ព_ព្រ_សុ_ស".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"%sទៀត",past:"%sមុន",s:"ប៉ុន្មានវិនាទី",m:"មួយនាទី",mm:"%d នាទី",h:"មួយម៉ោង",hh:"%d ម៉ោង",d:"មួយថ្ងៃ",dd:"%d ថ្ងៃ",M:"មួយខែ",MM:"%d ខែ",y:"មួយឆ្នាំ",yy:"%d ឆ្នាំ"}};return t.default.locale(n,null,!0),n}(n(7484))},1113:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"kn",weekdays:"ಭಾನುವಾರ_ಸೋಮವಾರ_ಮಂಗಳವಾರ_ಬುಧವಾರ_ಗುರುವಾರ_ಶುಕ್ರವಾರ_ಶನಿವಾರ".split("_"),months:"ಜನವರಿ_ಫೆಬ್ರವರಿ_ಮಾರ್ಚ್_ಏಪ್ರಿಲ್_ಮೇ_ಜೂನ್_ಜುಲೈ_ಆಗಸ್ಟ್_ಸೆಪ್ಟೆಂಬರ್_ಅಕ್ಟೋಬರ್_ನವೆಂಬರ್_ಡಿಸೆಂಬರ್".split("_"),weekdaysShort:"ಭಾನು_ಸೋಮ_ಮಂಗಳ_ಬುಧ_ಗುರು_ಶುಕ್ರ_ಶನಿ".split("_"),monthsShort:"ಜನ_ಫೆಬ್ರ_ಮಾರ್ಚ್_ಏಪ್ರಿಲ್_ಮೇ_ಜೂನ್_ಜುಲೈ_ಆಗಸ್ಟ್_ಸೆಪ್ಟೆಂ_ಅಕ್ಟೋ_ನವೆಂ_ಡಿಸೆಂ".split("_"),weekdaysMin:"ಭಾ_ಸೋ_ಮಂ_ಬು_ಗು_ಶು_ಶ".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm",LTS:"A h:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm",LLLL:"dddd, D MMMM YYYY, A h:mm"},relativeTime:{future:"%s ನಂತರ",past:"%s ಹಿಂದೆ",s:"ಕೆಲವು ಕ್ಷಣಗಳು",m:"ಒಂದು ನಿಮಿಷ",mm:"%d ನಿಮಿಷ",h:"ಒಂದು ಗಂಟೆ",hh:"%d ಗಂಟೆ",d:"ಒಂದು ದಿನ",dd:"%d ದಿನ",M:"ಒಂದು ತಿಂಗಳು",MM:"%d ತಿಂಗಳು",y:"ಒಂದು ವರ್ಷ",yy:"%d ವರ್ಷ"}};return t.default.locale(n,null,!0),n}(n(7484))},9132:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ko",weekdays:"일요일_월요일_화요일_수요일_목요일_금요일_토요일".split("_"),weekdaysShort:"일_월_화_수_목_금_토".split("_"),weekdaysMin:"일_월_화_수_목_금_토".split("_"),months:"1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월".split("_"),monthsShort:"1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm",LTS:"A h:mm:ss",L:"YYYY.MM.DD.",LL:"YYYY년 MMMM D일",LLL:"YYYY년 MMMM D일 A h:mm",LLLL:"YYYY년 MMMM D일 dddd A h:mm",l:"YYYY.MM.DD.",ll:"YYYY년 MMMM D일",lll:"YYYY년 MMMM D일 A h:mm",llll:"YYYY년 MMMM D일 dddd A h:mm"},meridiem:function(e){return e<12?"오전":"오후"},relativeTime:{future:"%s 후",past:"%s 전",s:"몇 초",m:"1분",mm:"%d분",h:"한 시간",hh:"%d시간",d:"하루",dd:"%d일",M:"한 달",MM:"%d달",y:"일 년",yy:"%d년"}};return t.default.locale(n,null,!0),n}(n(7484))},4888:function(e,t,n){!function(e,t){"use strict";var n=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(t),r={1:"١",2:"٢",3:"٣",4:"٤",5:"٥",6:"٦",7:"٧",8:"٨",9:"٩",0:"٠"},a={"١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","٠":"0"},i=["کانوونی دووەم","شوبات","ئادار","نیسان","ئایار","حوزەیران","تەممووز","ئاب","ئەیلوول","تشرینی یەکەم","تشرینی دووەم","کانوونی یەکەم"],s={name:"ku",months:i,monthsShort:i,weekdays:"یەکشەممە_دووشەممە_سێشەممە_چوارشەممە_پێنجشەممە_هەینی_شەممە".split("_"),weekdaysShort:"یەکشەم_دووشەم_سێشەم_چوارشەم_پێنجشەم_هەینی_شەممە".split("_"),weekStart:6,weekdaysMin:"ی_د_س_چ_پ_هـ_ش".split("_"),preparse:function(e){return e.replace(/[١٢٣٤٥٦٧٨٩٠]/g,(function(e){return a[e]})).replace(/،/g,",")},postformat:function(e){return e.replace(/\d/g,(function(e){return r[e]})).replace(/,/g,"،")},ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},meridiem:function(e){return e<12?"پ.ن":"د.ن"},relativeTime:{future:"لە %s",past:"لەمەوپێش %s",s:"چەند چرکەیەک",m:"یەک خولەک",mm:"%d خولەک",h:"یەک کاتژمێر",hh:"%d کاتژمێر",d:"یەک ڕۆژ",dd:"%d ڕۆژ",M:"یەک مانگ",MM:"%d مانگ",y:"یەک ساڵ",yy:"%d ساڵ"}};n.default.locale(s,null,!0),e.default=s,e.englishToArabicNumbersMap=r,Object.defineProperty(e,"__esModule",{value:!0})}(t,n(7484))},466:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ky",weekdays:"Жекшемби_Дүйшөмбү_Шейшемби_Шаршемби_Бейшемби_Жума_Ишемби".split("_"),months:"январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь".split("_"),weekStart:1,weekdaysShort:"Жек_Дүй_Шей_Шар_Бей_Жум_Ише".split("_"),monthsShort:"янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек".split("_"),weekdaysMin:"Жк_Дй_Шй_Шр_Бй_Жм_Иш".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"%s ичинде",past:"%s мурун",s:"бирнече секунд",m:"бир мүнөт",mm:"%d мүнөт",h:"бир саат",hh:"%d саат",d:"бир күн",dd:"%d күн",M:"бир ай",MM:"%d ай",y:"бир жыл",yy:"%d жыл"}};return t.default.locale(n,null,!0),n}(n(7484))},1796:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"lb",weekdays:"Sonndeg_Méindeg_Dënschdeg_Mëttwoch_Donneschdeg_Freideg_Samschdeg".split("_"),months:"Januar_Februar_Mäerz_Abrëll_Mee_Juni_Juli_August_September_Oktober_November_Dezember".split("_"),weekStart:1,weekdaysShort:"So._Mé._Dë._Më._Do._Fr._Sa.".split("_"),monthsShort:"Jan._Febr._Mrz._Abr._Mee_Jun._Jul._Aug._Sept._Okt._Nov._Dez.".split("_"),weekdaysMin:"So_Mé_Dë_Më_Do_Fr_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"H:mm [Auer]",LTS:"H:mm:ss [Auer]",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm [Auer]",LLLL:"dddd, D. MMMM YYYY H:mm [Auer]"}};return t.default.locale(n,null,!0),n}(n(7484))},8894:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"lo",weekdays:"ອາທິດ_ຈັນ_ອັງຄານ_ພຸດ_ພະຫັດ_ສຸກ_ເສົາ".split("_"),months:"ມັງກອນ_ກຸມພາ_ມີນາ_ເມສາ_ພຶດສະພາ_ມິຖຸນາ_ກໍລະກົດ_ສິງຫາ_ກັນຍາ_ຕຸລາ_ພະຈິກ_ທັນວາ".split("_"),weekdaysShort:"ທິດ_ຈັນ_ອັງຄານ_ພຸດ_ພະຫັດ_ສຸກ_ເສົາ".split("_"),monthsShort:"ມັງກອນ_ກຸມພາ_ມີນາ_ເມສາ_ພຶດສະພາ_ມິຖຸນາ_ກໍລະກົດ_ສິງຫາ_ກັນຍາ_ຕຸລາ_ພະຈິກ_ທັນວາ".split("_"),weekdaysMin:"ທ_ຈ_ອຄ_ພ_ພຫ_ສກ_ສ".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"ວັນdddd D MMMM YYYY HH:mm"},relativeTime:{future:"ອີກ %s",past:"%sຜ່ານມາ",s:"ບໍ່ເທົ່າໃດວິນາທີ",m:"1 ນາທີ",mm:"%d ນາທີ",h:"1 ຊົ່ວໂມງ",hh:"%d ຊົ່ວໂມງ",d:"1 ມື້",dd:"%d ມື້",M:"1 ເດືອນ",MM:"%d ເດືອນ",y:"1 ປີ",yy:"%d ປີ"}};return t.default.locale(n,null,!0),n}(n(7484))},8768:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n="sausio_vasario_kovo_balandžio_gegužės_birželio_liepos_rugpjūčio_rugsėjo_spalio_lapkričio_gruodžio".split("_"),r="sausis_vasaris_kovas_balandis_gegužė_birželis_liepa_rugpjūtis_rugsėjis_spalis_lapkritis_gruodis".split("_"),a=/D[oD]?(\[[^\[\]]*\]|\s)+MMMM?|MMMM?(\[[^\[\]]*\]|\s)+D[oD]?/,i=function(e,t){return a.test(t)?n[e.month()]:r[e.month()]};i.s=r,i.f=n;var s={name:"lt",weekdays:"sekmadienis_pirmadienis_antradienis_trečiadienis_ketvirtadienis_penktadienis_šeštadienis".split("_"),weekdaysShort:"sek_pir_ant_tre_ket_pen_šeš".split("_"),weekdaysMin:"s_p_a_t_k_pn_š".split("_"),months:i,monthsShort:"sau_vas_kov_bal_geg_bir_lie_rgp_rgs_spa_lap_grd".split("_"),ordinal:function(e){return e+"."},weekStart:1,relativeTime:{future:"už %s",past:"prieš %s",s:"kelias sekundes",m:"minutę",mm:"%d minutes",h:"valandą",hh:"%d valandas",d:"dieną",dd:"%d dienas",M:"mėnesį",MM:"%d mėnesius",y:"metus",yy:"%d metus"},format:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"YYYY [m.] MMMM D [d.]",LLL:"YYYY [m.] MMMM D [d.], HH:mm [val.]",LLLL:"YYYY [m.] MMMM D [d.], dddd, HH:mm [val.]",l:"YYYY-MM-DD",ll:"YYYY [m.] MMMM D [d.]",lll:"YYYY [m.] MMMM D [d.], HH:mm [val.]",llll:"YYYY [m.] MMMM D [d.], ddd, HH:mm [val.]"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"YYYY [m.] MMMM D [d.]",LLL:"YYYY [m.] MMMM D [d.], HH:mm [val.]",LLLL:"YYYY [m.] MMMM D [d.], dddd, HH:mm [val.]",l:"YYYY-MM-DD",ll:"YYYY [m.] MMMM D [d.]",lll:"YYYY [m.] MMMM D [d.], HH:mm [val.]",llll:"YYYY [m.] MMMM D [d.], ddd, HH:mm [val.]"}};return t.default.locale(s,null,!0),s}(n(7484))},953:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"lv",weekdays:"svētdiena_pirmdiena_otrdiena_trešdiena_ceturtdiena_piektdiena_sestdiena".split("_"),months:"janvāris_februāris_marts_aprīlis_maijs_jūnijs_jūlijs_augusts_septembris_oktobris_novembris_decembris".split("_"),weekStart:1,weekdaysShort:"Sv_P_O_T_C_Pk_S".split("_"),monthsShort:"jan_feb_mar_apr_mai_jūn_jūl_aug_sep_okt_nov_dec".split("_"),weekdaysMin:"Sv_P_O_T_C_Pk_S".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY.",LL:"YYYY. [gada] D. MMMM",LLL:"YYYY. [gada] D. MMMM, HH:mm",LLLL:"YYYY. [gada] D. MMMM, dddd, HH:mm"},relativeTime:{future:"pēc %s",past:"pirms %s",s:"dažām sekundēm",m:"minūtes",mm:"%d minūtēm",h:"stundas",hh:"%d stundām",d:"dienas",dd:"%d dienām",M:"mēneša",MM:"%d mēnešiem",y:"gada",yy:"%d gadiem"}};return t.default.locale(n,null,!0),n}(n(7484))},8066:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"me",weekdays:"nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota".split("_"),months:"januar_februar_mart_april_maj_jun_jul_avgust_septembar_oktobar_novembar_decembar".split("_"),weekStart:1,weekdaysShort:"ned._pon._uto._sri._čet._pet._sub.".split("_"),monthsShort:"jan._feb._mar._apr._maj_jun_jul_avg._sep._okt._nov._dec.".split("_"),weekdaysMin:"ne_po_ut_sr_če_pe_su".split("_"),ordinal:function(e){return e},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd, D. MMMM YYYY H:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},8602:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"mi",weekdays:"Rātapu_Mane_Tūrei_Wenerei_Tāite_Paraire_Hātarei".split("_"),months:"Kohi-tāte_Hui-tanguru_Poutū-te-rangi_Paenga-whāwhā_Haratua_Pipiri_Hōngoingoi_Here-turi-kōkā_Mahuru_Whiringa-ā-nuku_Whiringa-ā-rangi_Hakihea".split("_"),weekStart:1,weekdaysShort:"Ta_Ma_Tū_We_Tāi_Pa_Hā".split("_"),monthsShort:"Kohi_Hui_Pou_Pae_Hara_Pipi_Hōngoi_Here_Mahu_Whi-nu_Whi-ra_Haki".split("_"),weekdaysMin:"Ta_Ma_Tū_We_Tāi_Pa_Hā".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY [i] HH:mm",LLLL:"dddd, D MMMM YYYY [i] HH:mm"},relativeTime:{future:"i roto i %s",past:"%s i mua",s:"te hēkona ruarua",m:"he meneti",mm:"%d meneti",h:"te haora",hh:"%d haora",d:"he ra",dd:"%d ra",M:"he marama",MM:"%d marama",y:"he tau",yy:"%d tau"}};return t.default.locale(n,null,!0),n}(n(7484))},1560:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"mk",weekdays:"недела_понеделник_вторник_среда_четврток_петок_сабота".split("_"),months:"јануари_февруари_март_април_мај_јуни_јули_август_септември_октомври_ноември_декември".split("_"),weekStart:1,weekdaysShort:"нед_пон_вто_сре_чет_пет_саб".split("_"),monthsShort:"јан_фев_мар_апр_мај_јун_јул_авг_сеп_окт_ное_дек".split("_"),weekdaysMin:"нe_пo_вт_ср_че_пе_сa".split("_"),ordinal:function(e){return e},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"D.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY H:mm",LLLL:"dddd, D MMMM YYYY H:mm"},relativeTime:{future:"после %s",past:"пред %s",s:"неколку секунди",m:"минута",mm:"%d минути",h:"час",hh:"%d часа",d:"ден",dd:"%d дена",M:"месец",MM:"%d месеци",y:"година",yy:"%d години"}};return t.default.locale(n,null,!0),n}(n(7484))},4017:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ml",weekdays:"ഞായറാഴ്ച_തിങ്കളാഴ്ച_ചൊവ്വാഴ്ച_ബുധനാഴ്ച_വ്യാഴാഴ്ച_വെള്ളിയാഴ്ച_ശനിയാഴ്ച".split("_"),months:"ജനുവരി_ഫെബ്രുവരി_മാർച്ച്_ഏപ്രിൽ_മേയ്_ജൂൺ_ജൂലൈ_ഓഗസ്റ്റ്_സെപ്റ്റംബർ_ഒക്ടോബർ_നവംബർ_ഡിസംബർ".split("_"),weekdaysShort:"ഞായർ_തിങ്കൾ_ചൊവ്വ_ബുധൻ_വ്യാഴം_വെള്ളി_ശനി".split("_"),monthsShort:"ജനു._ഫെബ്രു._മാർ._ഏപ്രി._മേയ്_ജൂൺ_ജൂലൈ._ഓഗ._സെപ്റ്റ._ഒക്ടോ._നവം._ഡിസം.".split("_"),weekdaysMin:"ഞാ_തി_ചൊ_ബു_വ്യാ_വെ_ശ".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm -നു",LTS:"A h:mm:ss -നു",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm -നു",LLLL:"dddd, D MMMM YYYY, A h:mm -നു"},relativeTime:{future:"%s കഴിഞ്ഞ്",past:"%s മുൻപ്",s:"അൽപ നിമിഷങ്ങൾ",m:"ഒരു മിനിറ്റ്",mm:"%d മിനിറ്റ്",h:"ഒരു മണിക്കൂർ",hh:"%d മണിക്കൂർ",d:"ഒരു ദിവസം",dd:"%d ദിവസം",M:"ഒരു മാസം",MM:"%d മാസം",y:"ഒരു വർഷം",yy:"%d വർഷം"}};return t.default.locale(n,null,!0),n}(n(7484))},4717:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"mn",weekdays:"Ням_Даваа_Мягмар_Лхагва_Пүрэв_Баасан_Бямба".split("_"),months:"Нэгдүгээр сар_Хоёрдугаар сар_Гуравдугаар сар_Дөрөвдүгээр сар_Тавдугаар сар_Зургадугаар сар_Долдугаар сар_Наймдугаар сар_Есдүгээр сар_Аравдугаар сар_Арван нэгдүгээр сар_Арван хоёрдугаар сар".split("_"),weekdaysShort:"Ням_Дав_Мяг_Лха_Пүр_Баа_Бям".split("_"),monthsShort:"1 сар_2 сар_3 сар_4 сар_5 сар_6 сар_7 сар_8 сар_9 сар_10 сар_11 сар_12 сар".split("_"),weekdaysMin:"Ня_Да_Мя_Лх_Пү_Ба_Бя".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"YYYY оны MMMMын D",LLL:"YYYY оны MMMMын D HH:mm",LLLL:"dddd, YYYY оны MMMMын D HH:mm"},relativeTime:{future:"%s",past:"%s",s:"саяхан",m:"м",mm:"%dм",h:"1ц",hh:"%dц",d:"1ө",dd:"%dө",M:"1с",MM:"%dс",y:"1ж",yy:"%dж"}};return t.default.locale(n,null,!0),n}(n(7484))},5473:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"mr",weekdays:"रविवार_सोमवार_मंगळवार_बुधवार_गुरूवार_शुक्रवार_शनिवार".split("_"),months:"जानेवारी_फेब्रुवारी_मार्च_एप्रिल_मे_जून_जुलै_ऑगस्ट_सप्टेंबर_ऑक्टोबर_नोव्हेंबर_डिसेंबर".split("_"),weekdaysShort:"रवि_सोम_मंगळ_बुध_गुरू_शुक्र_शनि".split("_"),monthsShort:"जाने._फेब्रु._मार्च._एप्रि._मे._जून._जुलै._ऑग._सप्टें._ऑक्टो._नोव्हें._डिसें.".split("_"),weekdaysMin:"र_सो_मं_बु_गु_शु_श".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm वाजता",LTS:"A h:mm:ss वाजता",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm वाजता",LLLL:"dddd, D MMMM YYYY, A h:mm वाजता"}};return t.default.locale(n,null,!0),n}(n(7484))},7387:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ms-my",weekdays:"Ahad_Isnin_Selasa_Rabu_Khamis_Jumaat_Sabtu".split("_"),months:"Januari_Februari_Mac_April_Mei_Jun_Julai_Ogos_September_Oktober_November_Disember".split("_"),weekStart:1,weekdaysShort:"Ahd_Isn_Sel_Rab_Kha_Jum_Sab".split("_"),monthsShort:"Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ogs_Sep_Okt_Nov_Dis".split("_"),weekdaysMin:"Ah_Is_Sl_Rb_Km_Jm_Sb".split("_"),ordinal:function(e){return e},formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY [pukul] HH.mm",LLLL:"dddd, D MMMM YYYY [pukul] HH.mm"},relativeTime:{future:"dalam %s",past:"%s yang lepas",s:"beberapa saat",m:"seminit",mm:"%d minit",h:"sejam",hh:"%d jam",d:"sehari",dd:"%d hari",M:"sebulan",MM:"%d bulan",y:"setahun",yy:"%d tahun"}};return t.default.locale(n,null,!0),n}(n(7484))},5742:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ms",weekdays:"Ahad_Isnin_Selasa_Rabu_Khamis_Jumaat_Sabtu".split("_"),weekdaysShort:"Ahd_Isn_Sel_Rab_Kha_Jum_Sab".split("_"),weekdaysMin:"Ah_Is_Sl_Rb_Km_Jm_Sb".split("_"),months:"Januari_Februari_Mac_April_Mei_Jun_Julai_Ogos_September_Oktober_November_Disember".split("_"),monthsShort:"Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ogs_Sep_Okt_Nov_Dis".split("_"),weekStart:1,formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH.mm",LLLL:"dddd, D MMMM YYYY HH.mm"},relativeTime:{future:"dalam %s",past:"%s yang lepas",s:"beberapa saat",m:"seminit",mm:"%d minit",h:"sejam",hh:"%d jam",d:"sehari",dd:"%d hari",M:"sebulan",MM:"%d bulan",y:"setahun",yy:"%d tahun"},ordinal:function(e){return e+"."}};return t.default.locale(n,null,!0),n}(n(7484))},8477:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"mt",weekdays:"Il-Ħadd_It-Tnejn_It-Tlieta_L-Erbgħa_Il-Ħamis_Il-Ġimgħa_Is-Sibt".split("_"),months:"Jannar_Frar_Marzu_April_Mejju_Ġunju_Lulju_Awwissu_Settembru_Ottubru_Novembru_Diċembru".split("_"),weekStart:1,weekdaysShort:"Ħad_Tne_Tli_Erb_Ħam_Ġim_Sib".split("_"),monthsShort:"Jan_Fra_Mar_Apr_Mej_Ġun_Lul_Aww_Set_Ott_Nov_Diċ".split("_"),weekdaysMin:"Ħa_Tn_Tl_Er_Ħa_Ġi_Si".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"f’ %s",past:"%s ilu",s:"ftit sekondi",m:"minuta",mm:"%d minuti",h:"siegħa",hh:"%d siegħat",d:"ġurnata",dd:"%d ġranet",M:"xahar",MM:"%d xhur",y:"sena",yy:"%d sni"}};return t.default.locale(n,null,!0),n}(n(7484))},2966:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"my",weekdays:"တနင်္ဂနွေ_တနင်္လာ_အင်္ဂါ_ဗုဒ္ဓဟူး_ကြာသပတေး_သောကြာ_စနေ".split("_"),months:"ဇန်နဝါရီ_ဖေဖော်ဝါရီ_မတ်_ဧပြီ_မေ_ဇွန်_ဇူလိုင်_သြဂုတ်_စက်တင်ဘာ_အောက်တိုဘာ_နိုဝင်ဘာ_ဒီဇင်ဘာ".split("_"),weekStart:1,weekdaysShort:"နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ".split("_"),monthsShort:"ဇန်_ဖေ_မတ်_ပြီ_မေ_ဇွန်_လိုင်_သြ_စက်_အောက်_နို_ဒီ".split("_"),weekdaysMin:"နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"လာမည့် %s မှာ",past:"လွန်ခဲ့သော %s က",s:"စက္ကန်.အနည်းငယ်",m:"တစ်မိနစ်",mm:"%d မိနစ်",h:"တစ်နာရီ",hh:"%d နာရီ",d:"တစ်ရက်",dd:"%d ရက်",M:"တစ်လ",MM:"%d လ",y:"တစ်နှစ်",yy:"%d နှစ်"}};return t.default.locale(n,null,!0),n}(n(7484))},9682:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"nb",weekdays:"søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag".split("_"),weekdaysShort:"sø._ma._ti._on._to._fr._lø.".split("_"),weekdaysMin:"sø_ma_ti_on_to_fr_lø".split("_"),months:"januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember".split("_"),monthsShort:"jan._feb._mars_april_mai_juni_juli_aug._sep._okt._nov._des.".split("_"),ordinal:function(e){return e+"."},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY [kl.] HH:mm",LLLL:"dddd D. MMMM YYYY [kl.] HH:mm"},relativeTime:{future:"om %s",past:"%s siden",s:"noen sekunder",m:"ett minutt",mm:"%d minutter",h:"en time",hh:"%d timer",d:"en dag",dd:"%d dager",M:"en måned",MM:"%d måneder",y:"ett år",yy:"%d år"}};return t.default.locale(n,null,!0),n}(n(7484))},4149:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ne",weekdays:"आइतबार_सोमबार_मङ्गलबार_बुधबार_बिहिबार_शुक्रबार_शनिबार".split("_"),weekdaysShort:"आइत._सोम._मङ्गल._बुध._बिहि._शुक्र._शनि.".split("_"),weekdaysMin:"आ._सो._मं._बु._बि._शु._श.".split("_"),months:"जनवरी_फेब्रुवरी_मार्च_अप्रिल_मे_जुन_जुलाई_अगष्ट_सेप्टेम्बर_अक्टोबर_नोभेम्बर_डिसेम्बर".split("_"),monthsShort:"जन._फेब्रु._मार्च_अप्रि._मई_जुन_जुलाई._अग._सेप्ट._अक्टो._नोभे._डिसे.".split("_"),relativeTime:{future:"%s पछि",past:"%s अघि",s:"सेकेन्ड",m:"एक मिनेट",mm:"%d मिनेट",h:"घन्टा",hh:"%d घन्टा",d:"एक दिन",dd:"%d दिन",M:"एक महिना",MM:"%d महिना",y:"एक वर्ष",yy:"%d वर्ष"},ordinal:function(e){return(""+e).replace(/\d/g,(function(e){return"०१२३४५६७८९"[e]}))},formats:{LT:"Aको h:mm बजे",LTS:"Aको h:mm:ss बजे",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, Aको h:mm बजे",LLLL:"dddd, D MMMM YYYY, Aको h:mm बजे"}};return t.default.locale(n,null,!0),n}(n(7484))},7496:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"nl-be",weekdays:"zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag".split("_"),months:"januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december".split("_"),monthsShort:"jan._feb._mrt._apr._mei_jun._jul._aug._sep._okt._nov._dec.".split("_"),weekStart:1,weekdaysShort:"zo._ma._di._wo._do._vr._za.".split("_"),weekdaysMin:"zo_ma_di_wo_do_vr_za".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"over %s",past:"%s geleden",s:"een paar seconden",m:"één minuut",mm:"%d minuten",h:"één uur",hh:"%d uur",d:"één dag",dd:"%d dagen",M:"één maand",MM:"%d maanden",y:"één jaar",yy:"%d jaar"}};return t.default.locale(n,null,!0),n}(n(7484))},9182:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"nl",weekdays:"zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag".split("_"),weekdaysShort:"zo._ma._di._wo._do._vr._za.".split("_"),weekdaysMin:"zo_ma_di_wo_do_vr_za".split("_"),months:"januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december".split("_"),monthsShort:"jan_feb_mrt_apr_mei_jun_jul_aug_sep_okt_nov_dec".split("_"),ordinal:function(e){return"["+e+(1===e||8===e||e>=20?"ste":"de")+"]"},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD-MM-YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"over %s",past:"%s geleden",s:"een paar seconden",m:"een minuut",mm:"%d minuten",h:"een uur",hh:"%d uur",d:"een dag",dd:"%d dagen",M:"een maand",MM:"%d maanden",y:"een jaar",yy:"%d jaar"}};return t.default.locale(n,null,!0),n}(n(7484))},2722:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"nn",weekdays:"sundag_måndag_tysdag_onsdag_torsdag_fredag_laurdag".split("_"),weekdaysShort:"sun_mån_tys_ons_tor_fre_lau".split("_"),weekdaysMin:"su_må_ty_on_to_fr_la".split("_"),months:"januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember".split("_"),monthsShort:"jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des".split("_"),ordinal:function(e){return e+"."},weekStart:1,relativeTime:{future:"om %s",past:"for %s sidan",s:"nokre sekund",m:"eitt minutt",mm:"%d minutt",h:"ein time",hh:"%d timar",d:"ein dag",dd:"%d dagar",M:"ein månad",MM:"%d månadar",y:"eitt år",yy:"%d år"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY [kl.] H:mm",LLLL:"dddd D. MMMM YYYY [kl.] HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},6159:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"oc-lnc",weekdays:"dimenge_diluns_dimars_dimècres_dijòus_divendres_dissabte".split("_"),weekdaysShort:"Dg_Dl_Dm_Dc_Dj_Dv_Ds".split("_"),weekdaysMin:"dg_dl_dm_dc_dj_dv_ds".split("_"),months:"genièr_febrièr_març_abrial_mai_junh_julhet_agost_setembre_octòbre_novembre_decembre".split("_"),monthsShort:"gen_feb_març_abr_mai_junh_julh_ago_set_oct_nov_dec".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM [de] YYYY",LLL:"D MMMM [de] YYYY [a] H:mm",LLLL:"dddd D MMMM [de] YYYY [a] H:mm"},relativeTime:{future:"d'aquí %s",past:"fa %s",s:"unas segondas",m:"una minuta",mm:"%d minutas",h:"una ora",hh:"%d oras",d:"un jorn",dd:"%d jorns",M:"un mes",MM:"%d meses",y:"un an",yy:"%d ans"},ordinal:function(e){return e+"º"}};return t.default.locale(n,null,!0),n}(n(7484))},5914:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"pa-in",weekdays:"ਐਤਵਾਰ_ਸੋਮਵਾਰ_ਮੰਗਲਵਾਰ_ਬੁਧਵਾਰ_ਵੀਰਵਾਰ_ਸ਼ੁੱਕਰਵਾਰ_ਸ਼ਨੀਚਰਵਾਰ".split("_"),months:"ਜਨਵਰੀ_ਫ਼ਰਵਰੀ_ਮਾਰਚ_ਅਪ੍ਰੈਲ_ਮਈ_ਜੂਨ_ਜੁਲਾਈ_ਅਗਸਤ_ਸਤੰਬਰ_ਅਕਤੂਬਰ_ਨਵੰਬਰ_ਦਸੰਬਰ".split("_"),weekdaysShort:"ਐਤ_ਸੋਮ_ਮੰਗਲ_ਬੁਧ_ਵੀਰ_ਸ਼ੁਕਰ_ਸ਼ਨੀ".split("_"),monthsShort:"ਜਨਵਰੀ_ਫ਼ਰਵਰੀ_ਮਾਰਚ_ਅਪ੍ਰੈਲ_ਮਈ_ਜੂਨ_ਜੁਲਾਈ_ਅਗਸਤ_ਸਤੰਬਰ_ਅਕਤੂਬਰ_ਨਵੰਬਰ_ਦਸੰਬਰ".split("_"),weekdaysMin:"ਐਤ_ਸੋਮ_ਮੰਗਲ_ਬੁਧ_ਵੀਰ_ਸ਼ੁਕਰ_ਸ਼ਨੀ".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm ਵਜੇ",LTS:"A h:mm:ss ਵਜੇ",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm ਵਜੇ",LLLL:"dddd, D MMMM YYYY, A h:mm ਵਜੇ"},relativeTime:{future:"%s ਵਿੱਚ",past:"%s ਪਿਛਲੇ",s:"ਕੁਝ ਸਕਿੰਟ",m:"ਇਕ ਮਿੰਟ",mm:"%d ਮਿੰਟ",h:"ਇੱਕ ਘੰਟਾ",hh:"%d ਘੰਟੇ",d:"ਇੱਕ ਦਿਨ",dd:"%d ਦਿਨ",M:"ਇੱਕ ਮਹੀਨਾ",MM:"%d ਮਹੀਨੇ",y:"ਇੱਕ ਸਾਲ",yy:"%d ਸਾਲ"}};return t.default.locale(n,null,!0),n}(n(7484))},1987:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e);function n(e){return e%10<5&&e%10>1&&~~(e/10)%10!=1}function r(e,t,r){var a=e+" ";switch(r){case"m":return t?"minuta":"minutę";case"mm":return a+(n(e)?"minuty":"minut");case"h":return t?"godzina":"godzinę";case"hh":return a+(n(e)?"godziny":"godzin");case"MM":return a+(n(e)?"miesiące":"miesięcy");case"yy":return a+(n(e)?"lata":"lat")}}var a="stycznia_lutego_marca_kwietnia_maja_czerwca_lipca_sierpnia_września_października_listopada_grudnia".split("_"),i="styczeń_luty_marzec_kwiecień_maj_czerwiec_lipiec_sierpień_wrzesień_październik_listopad_grudzień".split("_"),s=/D MMMM/,o=function(e,t){return s.test(t)?a[e.month()]:i[e.month()]};o.s=i,o.f=a;var u={name:"pl",weekdays:"niedziela_poniedziałek_wtorek_środa_czwartek_piątek_sobota".split("_"),weekdaysShort:"ndz_pon_wt_śr_czw_pt_sob".split("_"),weekdaysMin:"Nd_Pn_Wt_Śr_Cz_Pt_So".split("_"),months:o,monthsShort:"sty_lut_mar_kwi_maj_cze_lip_sie_wrz_paź_lis_gru".split("_"),ordinal:function(e){return e+"."},weekStart:1,yearStart:4,relativeTime:{future:"za %s",past:"%s temu",s:"kilka sekund",m:r,mm:r,h:r,hh:r,d:"1 dzień",dd:"%d dni",M:"miesiąc",MM:r,y:"rok",yy:r},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"}};return t.default.locale(u,null,!0),u}(n(7484))},7548:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"pt-br",weekdays:"domingo_segunda-feira_terça-feira_quarta-feira_quinta-feira_sexta-feira_sábado".split("_"),weekdaysShort:"dom_seg_ter_qua_qui_sex_sáb".split("_"),weekdaysMin:"Do_2ª_3ª_4ª_5ª_6ª_Sá".split("_"),months:"janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro".split("_"),monthsShort:"jan_fev_mar_abr_mai_jun_jul_ago_set_out_nov_dez".split("_"),ordinal:function(e){return e+"º"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY [às] HH:mm",LLLL:"dddd, D [de] MMMM [de] YYYY [às] HH:mm"},relativeTime:{future:"em %s",past:"há %s",s:"poucos segundos",m:"um minuto",mm:"%d minutos",h:"uma hora",hh:"%d horas",d:"um dia",dd:"%d dias",M:"um mês",MM:"%d meses",y:"um ano",yy:"%d anos"}};return t.default.locale(n,null,!0),n}(n(7484))},5001:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"pt",weekdays:"domingo_segunda-feira_terça-feira_quarta-feira_quinta-feira_sexta-feira_sábado".split("_"),weekdaysShort:"dom_seg_ter_qua_qui_sex_sab".split("_"),weekdaysMin:"Do_2ª_3ª_4ª_5ª_6ª_Sa".split("_"),months:"janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro".split("_"),monthsShort:"jan_fev_mar_abr_mai_jun_jul_ago_set_out_nov_dez".split("_"),ordinal:function(e){return e+"º"},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY [às] HH:mm",LLLL:"dddd, D [de] MMMM [de] YYYY [às] HH:mm"},relativeTime:{future:"em %s",past:"há %s",s:"alguns segundos",m:"um minuto",mm:"%d minutos",h:"uma hora",hh:"%d horas",d:"um dia",dd:"%d dias",M:"um mês",MM:"%d meses",y:"um ano",yy:"%d anos"}};return t.default.locale(n,null,!0),n}(n(7484))},123:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"rn",weekdays:"Ku wa Mungu_Ku wa Mbere_Ku wa Kabiri_Ku wa Gatatu_Ku wa Kane_Ku wa Gatanu_Ku wa Gatandatu".split("_"),weekdaysShort:"Kngu_Kmbr_Kbri_Ktat_Kkan_Ktan_Kdat".split("_"),weekdaysMin:"K7_K1_K2_K3_K4_K5_K6".split("_"),months:"Nzero_Ruhuhuma_Ntwarante_Ndamukiza_Rusama_Ruhenshi_Mukakaro_Myandagaro_Nyakanga_Gitugutu_Munyonyo_Kigarama".split("_"),monthsShort:"Nzer_Ruhuh_Ntwar_Ndam_Rus_Ruhen_Muk_Myand_Nyak_Git_Muny_Kig".split("_"),weekStart:1,ordinal:function(e){return e},relativeTime:{future:"mu %s",past:"%s",s:"amasegonda",m:"Umunota",mm:"%d iminota",h:"isaha",hh:"%d amasaha",d:"Umunsi",dd:"%d iminsi",M:"ukwezi",MM:"%d amezi",y:"umwaka",yy:"%d imyaka"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},8146:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ro",weekdays:"Duminică_Luni_Marți_Miercuri_Joi_Vineri_Sâmbătă".split("_"),weekdaysShort:"Dum_Lun_Mar_Mie_Joi_Vin_Sâm".split("_"),weekdaysMin:"Du_Lu_Ma_Mi_Jo_Vi_Sâ".split("_"),months:"Ianuarie_Februarie_Martie_Aprilie_Mai_Iunie_Iulie_August_Septembrie_Octombrie_Noiembrie_Decembrie".split("_"),monthsShort:"Ian._Febr._Mart._Apr._Mai_Iun._Iul._Aug._Sept._Oct._Nov._Dec.".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY H:mm",LLLL:"dddd, D MMMM YYYY H:mm"},relativeTime:{future:"peste %s",past:"acum %s",s:"câteva secunde",m:"un minut",mm:"%d minute",h:"o oră",hh:"%d ore",d:"o zi",dd:"%d zile",M:"o lună",MM:"%d luni",y:"un an",yy:"%d ani"},ordinal:function(e){return e}};return t.default.locale(n,null,!0),n}(n(7484))},600:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n="января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря".split("_"),r="январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь".split("_"),a="янв._февр._мар._апр._мая_июня_июля_авг._сент._окт._нояб._дек.".split("_"),i="янв._февр._март_апр._май_июнь_июль_авг._сент._окт._нояб._дек.".split("_"),s=/D[oD]?(\[[^[\]]*\]|\s)+MMMM?/;function o(e,t,n){var r,a;return"m"===n?t?"минута":"минуту":e+" "+(r=+e,a={mm:t?"минута_минуты_минут":"минуту_минуты_минут",hh:"час_часа_часов",dd:"день_дня_дней",MM:"месяц_месяца_месяцев",yy:"год_года_лет"}[n].split("_"),r%10==1&&r%100!=11?a[0]:r%10>=2&&r%10<=4&&(r%100<10||r%100>=20)?a[1]:a[2])}var u=function(e,t){return s.test(t)?n[e.month()]:r[e.month()]};u.s=r,u.f=n;var l=function(e,t){return s.test(t)?a[e.month()]:i[e.month()]};l.s=i,l.f=a;var c={name:"ru",weekdays:"воскресенье_понедельник_вторник_среда_четверг_пятница_суббота".split("_"),weekdaysShort:"вск_пнд_втр_срд_чтв_птн_сбт".split("_"),weekdaysMin:"вс_пн_вт_ср_чт_пт_сб".split("_"),months:u,monthsShort:l,weekStart:1,yearStart:4,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY г.",LLL:"D MMMM YYYY г., H:mm",LLLL:"dddd, D MMMM YYYY г., H:mm"},relativeTime:{future:"через %s",past:"%s назад",s:"несколько секунд",m:o,mm:o,h:"час",hh:o,d:"день",dd:o,M:"месяц",MM:o,y:"год",yy:o},ordinal:function(e){return e},meridiem:function(e){return e<4?"ночи":e<12?"утра":e<17?"дня":"вечера"}};return t.default.locale(c,null,!0),c}(n(7484))},6509:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"rw",weekdays:"Ku Cyumweru_Kuwa Mbere_Kuwa Kabiri_Kuwa Gatatu_Kuwa Kane_Kuwa Gatanu_Kuwa Gatandatu".split("_"),months:"Mutarama_Gashyantare_Werurwe_Mata_Gicurasi_Kamena_Nyakanga_Kanama_Nzeri_Ukwakira_Ugushyingo_Ukuboza".split("_"),relativeTime:{future:"mu %s",past:"%s",s:"amasegonda",m:"Umunota",mm:"%d iminota",h:"isaha",hh:"%d amasaha",d:"Umunsi",dd:"%d iminsi",M:"ukwezi",MM:"%d amezi",y:"umwaka",yy:"%d imyaka"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},ordinal:function(e){return e}};return t.default.locale(n,null,!0),n}(n(7484))},5437:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"sd",weekdays:"آچر_سومر_اڱارو_اربع_خميس_جمع_ڇنڇر".split("_"),months:"جنوري_فيبروري_مارچ_اپريل_مئي_جون_جولاءِ_آگسٽ_سيپٽمبر_آڪٽوبر_نومبر_ڊسمبر".split("_"),weekStart:1,weekdaysShort:"آچر_سومر_اڱارو_اربع_خميس_جمع_ڇنڇر".split("_"),monthsShort:"جنوري_فيبروري_مارچ_اپريل_مئي_جون_جولاءِ_آگسٽ_سيپٽمبر_آڪٽوبر_نومبر_ڊسمبر".split("_"),weekdaysMin:"آچر_سومر_اڱارو_اربع_خميس_جمع_ڇنڇر".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd، D MMMM YYYY HH:mm"},relativeTime:{future:"%s پوء",past:"%s اڳ",s:"چند سيڪنڊ",m:"هڪ منٽ",mm:"%d منٽ",h:"هڪ ڪلاڪ",hh:"%d ڪلاڪ",d:"هڪ ڏينهن",dd:"%d ڏينهن",M:"هڪ مهينو",MM:"%d مهينا",y:"هڪ سال",yy:"%d سال"}};return t.default.locale(n,null,!0),n}(n(7484))},772:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"se",weekdays:"sotnabeaivi_vuossárga_maŋŋebárga_gaskavahkku_duorastat_bearjadat_lávvardat".split("_"),months:"ođđajagemánnu_guovvamánnu_njukčamánnu_cuoŋománnu_miessemánnu_geassemánnu_suoidnemánnu_borgemánnu_čakčamánnu_golggotmánnu_skábmamánnu_juovlamánnu".split("_"),weekStart:1,weekdaysShort:"sotn_vuos_maŋ_gask_duor_bear_láv".split("_"),monthsShort:"ođđj_guov_njuk_cuo_mies_geas_suoi_borg_čakč_golg_skáb_juov".split("_"),weekdaysMin:"s_v_m_g_d_b_L".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"MMMM D. [b.] YYYY",LLL:"MMMM D. [b.] YYYY [ti.] HH:mm",LLLL:"dddd, MMMM D. [b.] YYYY [ti.] HH:mm"},relativeTime:{future:"%s geažes",past:"maŋit %s",s:"moadde sekunddat",m:"okta minuhta",mm:"%d minuhtat",h:"okta diimmu",hh:"%d diimmut",d:"okta beaivi",dd:"%d beaivvit",M:"okta mánnu",MM:"%d mánut",y:"okta jahki",yy:"%d jagit"}};return t.default.locale(n,null,!0),n}(n(7484))},7109:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"si",weekdays:"ඉරිදා_සඳුදා_අඟහරුවාදා_බදාදා_බ්‍රහස්පතින්දා_සිකුරාදා_සෙනසුරාදා".split("_"),months:"දුරුතු_නවම්_මැදින්_බක්_වෙසක්_පොසොන්_ඇසළ_නිකිණි_බිනර_වප්_ඉල්_උඳුවප්".split("_"),weekdaysShort:"ඉරි_සඳු_අඟ_බදා_බ්‍රහ_සිකු_සෙන".split("_"),monthsShort:"දුරු_නව_මැදි_බක්_වෙස_පොසො_ඇස_නිකි_බින_වප්_ඉල්_උඳු".split("_"),weekdaysMin:"ඉ_ස_අ_බ_බ්‍ර_සි_සෙ".split("_"),ordinal:function(e){return e},formats:{LT:"a h:mm",LTS:"a h:mm:ss",L:"YYYY/MM/DD",LL:"YYYY MMMM D",LLL:"YYYY MMMM D, a h:mm",LLLL:"YYYY MMMM D [වැනි] dddd, a h:mm:ss"},relativeTime:{future:"%sකින්",past:"%sකට පෙර",s:"තත්පර කිහිපය",m:"විනාඩිය",mm:"විනාඩි %d",h:"පැය",hh:"පැය %d",d:"දිනය",dd:"දින %d",M:"මාසය",MM:"මාස %d",y:"වසර",yy:"වසර %d"}};return t.default.locale(n,null,!0),n}(n(7484))},5627:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e);function n(e){return e>1&&e<5&&1!=~~(e/10)}function r(e,t,r,a){var i=e+" ";switch(r){case"s":return t||a?"pár sekúnd":"pár sekundami";case"m":return t?"minúta":a?"minútu":"minútou";case"mm":return t||a?i+(n(e)?"minúty":"minút"):i+"minútami";case"h":return t?"hodina":a?"hodinu":"hodinou";case"hh":return t||a?i+(n(e)?"hodiny":"hodín"):i+"hodinami";case"d":return t||a?"deň":"dňom";case"dd":return t||a?i+(n(e)?"dni":"dní"):i+"dňami";case"M":return t||a?"mesiac":"mesiacom";case"MM":return t||a?i+(n(e)?"mesiace":"mesiacov"):i+"mesiacmi";case"y":return t||a?"rok":"rokom";case"yy":return t||a?i+(n(e)?"roky":"rokov"):i+"rokmi"}}var a={name:"sk",weekdays:"nedeľa_pondelok_utorok_streda_štvrtok_piatok_sobota".split("_"),weekdaysShort:"ne_po_ut_st_št_pi_so".split("_"),weekdaysMin:"ne_po_ut_st_št_pi_so".split("_"),months:"január_február_marec_apríl_máj_jún_júl_august_september_október_november_december".split("_"),monthsShort:"jan_feb_mar_apr_máj_jún_júl_aug_sep_okt_nov_dec".split("_"),weekStart:1,yearStart:4,ordinal:function(e){return e+"."},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd D. MMMM YYYY H:mm",l:"D. M. YYYY"},relativeTime:{future:"za %s",past:"pred %s",s:r,m:r,mm:r,h:r,hh:r,d:r,dd:r,M:r,MM:r,y:r,yy:r}};return t.default.locale(a,null,!0),a}(n(7484))},2544:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"sl",weekdays:"nedelja_ponedeljek_torek_sreda_četrtek_petek_sobota".split("_"),months:"januar_februar_marec_april_maj_junij_julij_avgust_september_oktober_november_december".split("_"),weekStart:1,weekdaysShort:"ned._pon._tor._sre._čet._pet._sob.".split("_"),monthsShort:"jan._feb._mar._apr._maj._jun._jul._avg._sep._okt._nov._dec.".split("_"),weekdaysMin:"ne_po_to_sr_če_pe_so".split("_"),ordinal:function(e){return e+"."},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd, D. MMMM YYYY H:mm"},relativeTime:{future:"čez %s",past:"pred %s",s:"nekaj sekund",m:"minuta",mm:"%d minut",h:"ura",hh:"%d ur",d:"dan",dd:"%d dni",M:"mesec",MM:"%d mesecev",y:"leto",yy:"%d let"}};return t.default.locale(n,null,!0),n}(n(7484))},8341:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"sq",weekdays:"E Diel_E Hënë_E Martë_E Mërkurë_E Enjte_E Premte_E Shtunë".split("_"),months:"Janar_Shkurt_Mars_Prill_Maj_Qershor_Korrik_Gusht_Shtator_Tetor_Nëntor_Dhjetor".split("_"),weekStart:1,weekdaysShort:"Die_Hën_Mar_Mër_Enj_Pre_Sht".split("_"),monthsShort:"Jan_Shk_Mar_Pri_Maj_Qer_Kor_Gus_Sht_Tet_Nën_Dhj".split("_"),weekdaysMin:"D_H_Ma_Më_E_P_Sh".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"në %s",past:"%s më parë",s:"disa sekonda",m:"një minutë",mm:"%d minuta",h:"një orë",hh:"%d orë",d:"një ditë",dd:"%d ditë",M:"një muaj",MM:"%d muaj",y:"një vit",yy:"%d vite"}};return t.default.locale(n,null,!0),n}(n(7484))},7101:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={words:{m:["један минут","једног минута"],mm:["%d минут","%d минута","%d минута"],h:["један сат","једног сата"],hh:["%d сат","%d сата","%d сати"],d:["један дан","једног дана"],dd:["%d дан","%d дана","%d дана"],M:["један месец","једног месеца"],MM:["%d месец","%d месеца","%d месеци"],y:["једну годину","једне године"],yy:["%d годину","%d године","%d година"]},correctGrammarCase:function(e,t){return e%10>=1&&e%10<=4&&(e%100<10||e%100>=20)?e%10==1?t[0]:t[1]:t[2]},relativeTimeFormatter:function(e,t,r,a){var i=n.words[r];if(1===r.length)return"y"===r&&t?"једна година":a||t?i[0]:i[1];var s=n.correctGrammarCase(e,i);return"yy"===r&&t&&"%d годину"===s?e+" година":s.replace("%d",e)}},r={name:"sr-cyrl",weekdays:"Недеља_Понедељак_Уторак_Среда_Четвртак_Петак_Субота".split("_"),weekdaysShort:"Нед._Пон._Уто._Сре._Чет._Пет._Суб.".split("_"),weekdaysMin:"не_по_ут_ср_че_пе_су".split("_"),months:"Јануар_Фебруар_Март_Април_Мај_Јун_Јул_Август_Септембар_Октобар_Новембар_Децембар".split("_"),monthsShort:"Јан._Феб._Мар._Апр._Мај_Јун_Јул_Авг._Сеп._Окт._Нов._Дец.".split("_"),weekStart:1,relativeTime:{future:"за %s",past:"пре %s",s:"неколико секунди",m:n.relativeTimeFormatter,mm:n.relativeTimeFormatter,h:n.relativeTimeFormatter,hh:n.relativeTimeFormatter,d:n.relativeTimeFormatter,dd:n.relativeTimeFormatter,M:n.relativeTimeFormatter,MM:n.relativeTimeFormatter,y:n.relativeTimeFormatter,yy:n.relativeTimeFormatter},ordinal:function(e){return e+"."},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"D. M. YYYY.",LL:"D. MMMM YYYY.",LLL:"D. MMMM YYYY. H:mm",LLLL:"dddd, D. MMMM YYYY. H:mm"}};return t.default.locale(r,null,!0),r}(n(7484))},617:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={words:{m:["jedan minut","jednog minuta"],mm:["%d minut","%d minuta","%d minuta"],h:["jedan sat","jednog sata"],hh:["%d sat","%d sata","%d sati"],d:["jedan dan","jednog dana"],dd:["%d dan","%d dana","%d dana"],M:["jedan mesec","jednog meseca"],MM:["%d mesec","%d meseca","%d meseci"],y:["jednu godinu","jedne godine"],yy:["%d godinu","%d godine","%d godina"]},correctGrammarCase:function(e,t){return e%10>=1&&e%10<=4&&(e%100<10||e%100>=20)?e%10==1?t[0]:t[1]:t[2]},relativeTimeFormatter:function(e,t,r,a){var i=n.words[r];if(1===r.length)return"y"===r&&t?"jedna godina":a||t?i[0]:i[1];var s=n.correctGrammarCase(e,i);return"yy"===r&&t&&"%d godinu"===s?e+" godina":s.replace("%d",e)}},r={name:"sr",weekdays:"Nedelja_Ponedeljak_Utorak_Sreda_Četvrtak_Petak_Subota".split("_"),weekdaysShort:"Ned._Pon._Uto._Sre._Čet._Pet._Sub.".split("_"),weekdaysMin:"ne_po_ut_sr_če_pe_su".split("_"),months:"Januar_Februar_Mart_April_Maj_Jun_Jul_Avgust_Septembar_Oktobar_Novembar_Decembar".split("_"),monthsShort:"Jan._Feb._Mar._Apr._Maj_Jun_Jul_Avg._Sep._Okt._Nov._Dec.".split("_"),weekStart:1,relativeTime:{future:"za %s",past:"pre %s",s:"nekoliko sekundi",m:n.relativeTimeFormatter,mm:n.relativeTimeFormatter,h:n.relativeTimeFormatter,hh:n.relativeTimeFormatter,d:n.relativeTimeFormatter,dd:n.relativeTimeFormatter,M:n.relativeTimeFormatter,MM:n.relativeTimeFormatter,y:n.relativeTimeFormatter,yy:n.relativeTimeFormatter},ordinal:function(e){return e+"."},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"D. M. YYYY.",LL:"D. MMMM YYYY.",LLL:"D. MMMM YYYY. H:mm",LLLL:"dddd, D. MMMM YYYY. H:mm"}};return t.default.locale(r,null,!0),r}(n(7484))},4127:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ss",weekdays:"Lisontfo_Umsombuluko_Lesibili_Lesitsatfu_Lesine_Lesihlanu_Umgcibelo".split("_"),months:"Bhimbidvwane_Indlovana_Indlov'lenkhulu_Mabasa_Inkhwekhweti_Inhlaba_Kholwane_Ingci_Inyoni_Imphala_Lweti_Ingongoni".split("_"),weekStart:1,weekdaysShort:"Lis_Umb_Lsb_Les_Lsi_Lsh_Umg".split("_"),monthsShort:"Bhi_Ina_Inu_Mab_Ink_Inh_Kho_Igc_Iny_Imp_Lwe_Igo".split("_"),weekdaysMin:"Li_Us_Lb_Lt_Ls_Lh_Ug".split("_"),ordinal:function(e){return e},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY h:mm A",LLLL:"dddd, D MMMM YYYY h:mm A"},relativeTime:{future:"nga %s",past:"wenteka nga %s",s:"emizuzwana lomcane",m:"umzuzu",mm:"%d emizuzu",h:"lihora",hh:"%d emahora",d:"lilanga",dd:"%d emalanga",M:"inyanga",MM:"%d tinyanga",y:"umnyaka",yy:"%d iminyaka"}};return t.default.locale(n,null,!0),n}(n(7484))},6421:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"sv-fi",weekdays:"söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag".split("_"),weekdaysShort:"sön_mån_tis_ons_tor_fre_lör".split("_"),weekdaysMin:"sö_må_ti_on_to_fr_lö".split("_"),months:"januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december".split("_"),monthsShort:"jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec".split("_"),weekStart:1,yearStart:4,ordinal:function(e){var t=e%10;return"["+e+(1===t||2===t?"a":"e")+"]"},formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY, [kl.] HH.mm",LLLL:"dddd, D. MMMM YYYY, [kl.] HH.mm",l:"D.M.YYYY",ll:"D. MMM YYYY",lll:"D. MMM YYYY, [kl.] HH.mm",llll:"ddd, D. MMM YYYY, [kl.] HH.mm"},relativeTime:{future:"om %s",past:"för %s sedan",s:"några sekunder",m:"en minut",mm:"%d minuter",h:"en timme",hh:"%d timmar",d:"en dag",dd:"%d dagar",M:"en månad",MM:"%d månader",y:"ett år",yy:"%d år"}};return t.default.locale(n,null,!0),n}(n(7484))},1876:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"sv",weekdays:"söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag".split("_"),weekdaysShort:"sön_mån_tis_ons_tor_fre_lör".split("_"),weekdaysMin:"sö_må_ti_on_to_fr_lö".split("_"),months:"januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december".split("_"),monthsShort:"jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec".split("_"),weekStart:1,yearStart:4,ordinal:function(e){var t=e%10;return"["+e+(1===t||2===t?"a":"e")+"]"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"D MMMM YYYY",LLL:"D MMMM YYYY [kl.] HH:mm",LLLL:"dddd D MMMM YYYY [kl.] HH:mm",lll:"D MMM YYYY HH:mm",llll:"ddd D MMM YYYY HH:mm"},relativeTime:{future:"om %s",past:"för %s sedan",s:"några sekunder",m:"en minut",mm:"%d minuter",h:"en timme",hh:"%d timmar",d:"en dag",dd:"%d dagar",M:"en månad",MM:"%d månader",y:"ett år",yy:"%d år"}};return t.default.locale(n,null,!0),n}(n(7484))},9723:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"sw",weekdays:"Jumapili_Jumatatu_Jumanne_Jumatano_Alhamisi_Ijumaa_Jumamosi".split("_"),weekdaysShort:"Jpl_Jtat_Jnne_Jtan_Alh_Ijm_Jmos".split("_"),weekdaysMin:"J2_J3_J4_J5_Al_Ij_J1".split("_"),months:"Januari_Februari_Machi_Aprili_Mei_Juni_Julai_Agosti_Septemba_Oktoba_Novemba_Desemba".split("_"),monthsShort:"Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ago_Sep_Okt_Nov_Des".split("_"),weekStart:1,ordinal:function(e){return e},relativeTime:{future:"%s baadaye",past:"tokea %s",s:"hivi punde",m:"dakika moja",mm:"dakika %d",h:"saa limoja",hh:"masaa %d",d:"siku moja",dd:"masiku %d",M:"mwezi mmoja",MM:"miezi %d",y:"mwaka mmoja",yy:"miaka %d"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},5596:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ta",weekdays:"ஞாயிற்றுக்கிழமை_திங்கட்கிழமை_செவ்வாய்கிழமை_புதன்கிழமை_வியாழக்கிழமை_வெள்ளிக்கிழமை_சனிக்கிழமை".split("_"),months:"ஜனவரி_பிப்ரவரி_மார்ச்_ஏப்ரல்_மே_ஜூன்_ஜூலை_ஆகஸ்ட்_செப்டெம்பர்_அக்டோபர்_நவம்பர்_டிசம்பர்".split("_"),weekdaysShort:"ஞாயிறு_திங்கள்_செவ்வாய்_புதன்_வியாழன்_வெள்ளி_சனி".split("_"),monthsShort:"ஜனவரி_பிப்ரவரி_மார்ச்_ஏப்ரல்_மே_ஜூன்_ஜூலை_ஆகஸ்ட்_செப்டெம்பர்_அக்டோபர்_நவம்பர்_டிசம்பர்".split("_"),weekdaysMin:"ஞா_தி_செ_பு_வி_வெ_ச".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, HH:mm",LLLL:"dddd, D MMMM YYYY, HH:mm"},relativeTime:{future:"%s இல்",past:"%s முன்",s:"ஒரு சில விநாடிகள்",m:"ஒரு நிமிடம்",mm:"%d நிமிடங்கள்",h:"ஒரு மணி நேரம்",hh:"%d மணி நேரம்",d:"ஒரு நாள்",dd:"%d நாட்கள்",M:"ஒரு மாதம்",MM:"%d மாதங்கள்",y:"ஒரு வருடம்",yy:"%d ஆண்டுகள்"}};return t.default.locale(n,null,!0),n}(n(7484))},5159:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"te",weekdays:"ఆదివారం_సోమవారం_మంగళవారం_బుధవారం_గురువారం_శుక్రవారం_శనివారం".split("_"),months:"జనవరి_ఫిబ్రవరి_మార్చి_ఏప్రిల్_మే_జూన్_జులై_ఆగస్టు_సెప్టెంబర్_అక్టోబర్_నవంబర్_డిసెంబర్".split("_"),weekdaysShort:"ఆది_సోమ_మంగళ_బుధ_గురు_శుక్ర_శని".split("_"),monthsShort:"జన._ఫిబ్ర._మార్చి_ఏప్రి._మే_జూన్_జులై_ఆగ._సెప్._అక్టో._నవ._డిసె.".split("_"),weekdaysMin:"ఆ_సో_మం_బు_గు_శు_శ".split("_"),ordinal:function(e){return e},formats:{LT:"A h:mm",LTS:"A h:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm",LLLL:"dddd, D MMMM YYYY, A h:mm"},relativeTime:{future:"%s లో",past:"%s క్రితం",s:"కొన్ని క్షణాలు",m:"ఒక నిమిషం",mm:"%d నిమిషాలు",h:"ఒక గంట",hh:"%d గంటలు",d:"ఒక రోజు",dd:"%d రోజులు",M:"ఒక నెల",MM:"%d నెలలు",y:"ఒక సంవత్సరం",yy:"%d సంవత్సరాలు"}};return t.default.locale(n,null,!0),n}(n(7484))},9157:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tet",weekdays:"Domingu_Segunda_Tersa_Kuarta_Kinta_Sesta_Sabadu".split("_"),months:"Janeiru_Fevereiru_Marsu_Abril_Maiu_Juñu_Jullu_Agustu_Setembru_Outubru_Novembru_Dezembru".split("_"),weekStart:1,weekdaysShort:"Dom_Seg_Ters_Kua_Kint_Sest_Sab".split("_"),monthsShort:"Jan_Fev_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez".split("_"),weekdaysMin:"Do_Seg_Te_Ku_Ki_Ses_Sa".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"iha %s",past:"%s liuba",s:"minutu balun",m:"minutu ida",mm:"minutu %d",h:"oras ida",hh:"oras %d",d:"loron ida",dd:"loron %d",M:"fulan ida",MM:"fulan %d",y:"tinan ida",yy:"tinan %d"}};return t.default.locale(n,null,!0),n}(n(7484))},9928:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tg",weekdays:"якшанбе_душанбе_сешанбе_чоршанбе_панҷшанбе_ҷумъа_шанбе".split("_"),months:"январ_феврал_март_апрел_май_июн_июл_август_сентябр_октябр_ноябр_декабр".split("_"),weekStart:1,weekdaysShort:"яшб_дшб_сшб_чшб_пшб_ҷум_шнб".split("_"),monthsShort:"янв_фев_мар_апр_май_июн_июл_авг_сен_окт_ноя_дек".split("_"),weekdaysMin:"яш_дш_сш_чш_пш_ҷм_шб".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"баъди %s",past:"%s пеш",s:"якчанд сония",m:"як дақиқа",mm:"%d дақиқа",h:"як соат",hh:"%d соат",d:"як рӯз",dd:"%d рӯз",M:"як моҳ",MM:"%d моҳ",y:"як сол",yy:"%d сол"}};return t.default.locale(n,null,!0),n}(n(7484))},2019:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"th",weekdays:"อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัสบดี_ศุกร์_เสาร์".split("_"),weekdaysShort:"อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัส_ศุกร์_เสาร์".split("_"),weekdaysMin:"อา._จ._อ._พ._พฤ._ศ._ส.".split("_"),months:"มกราคม_กุมภาพันธ์_มีนาคม_เมษายน_พฤษภาคม_มิถุนายน_กรกฎาคม_สิงหาคม_กันยายน_ตุลาคม_พฤศจิกายน_ธันวาคม".split("_"),monthsShort:"ม.ค._ก.พ._มี.ค._เม.ย._พ.ค._มิ.ย._ก.ค._ส.ค._ก.ย._ต.ค._พ.ย._ธ.ค.".split("_"),formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY เวลา H:mm",LLLL:"วันddddที่ D MMMM YYYY เวลา H:mm"},relativeTime:{future:"อีก %s",past:"%sที่แล้ว",s:"ไม่กี่วินาที",m:"1 นาที",mm:"%d นาที",h:"1 ชั่วโมง",hh:"%d ชั่วโมง",d:"1 วัน",dd:"%d วัน",M:"1 เดือน",MM:"%d เดือน",y:"1 ปี",yy:"%d ปี"},ordinal:function(e){return e+"."}};return t.default.locale(n,null,!0),n}(n(7484))},5817:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tk",weekdays:"Ýekşenbe_Duşenbe_Sişenbe_Çarşenbe_Penşenbe_Anna_Şenbe".split("_"),weekdaysShort:"Ýek_Duş_Siş_Çar_Pen_Ann_Şen".split("_"),weekdaysMin:"Ýk_Dş_Sş_Çr_Pn_An_Şn".split("_"),months:"Ýanwar_Fewral_Mart_Aprel_Maý_Iýun_Iýul_Awgust_Sentýabr_Oktýabr_Noýabr_Dekabr".split("_"),monthsShort:"Ýan_Few_Mar_Apr_Maý_Iýn_Iýl_Awg_Sen_Okt_Noý_Dek".split("_"),weekStart:1,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"%s soň",past:"%s öň",s:"birnäçe sekunt",m:"bir minut",mm:"%d minut",h:"bir sagat",hh:"%d sagat",d:"bir gün",dd:"%d gün",M:"bir aý",MM:"%d aý",y:"bir ýyl",yy:"%d ýyl"},ordinal:function(e){return e+"."}};return t.default.locale(n,null,!0),n}(n(7484))},6513:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tl-ph",weekdays:"Linggo_Lunes_Martes_Miyerkules_Huwebes_Biyernes_Sabado".split("_"),months:"Enero_Pebrero_Marso_Abril_Mayo_Hunyo_Hulyo_Agosto_Setyembre_Oktubre_Nobyembre_Disyembre".split("_"),weekStart:1,weekdaysShort:"Lin_Lun_Mar_Miy_Huw_Biy_Sab".split("_"),monthsShort:"Ene_Peb_Mar_Abr_May_Hun_Hul_Ago_Set_Okt_Nob_Dis".split("_"),weekdaysMin:"Li_Lu_Ma_Mi_Hu_Bi_Sab".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"MM/D/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY HH:mm",LLLL:"dddd, MMMM DD, YYYY HH:mm"},relativeTime:{future:"sa loob ng %s",past:"%s ang nakalipas",s:"ilang segundo",m:"isang minuto",mm:"%d minuto",h:"isang oras",hh:"%d oras",d:"isang araw",dd:"%d araw",M:"isang buwan",MM:"%d buwan",y:"isang taon",yy:"%d taon"}};return t.default.locale(n,null,!0),n}(n(7484))},7296:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tlh",weekdays:"lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj".split("_"),months:"tera’ jar wa’_tera’ jar cha’_tera’ jar wej_tera’ jar loS_tera’ jar vagh_tera’ jar jav_tera’ jar Soch_tera’ jar chorgh_tera’ jar Hut_tera’ jar wa’maH_tera’ jar wa’maH wa’_tera’ jar wa’maH cha’".split("_"),weekStart:1,weekdaysShort:"lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj".split("_"),monthsShort:"jar wa’_jar cha’_jar wej_jar loS_jar vagh_jar jav_jar Soch_jar chorgh_jar Hut_jar wa’maH_jar wa’maH wa’_jar wa’maH cha’".split("_"),weekdaysMin:"lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"}};return t.default.locale(n,null,!0),n}(n(7484))},3035:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tr",weekdays:"Pazar_Pazartesi_Salı_Çarşamba_Perşembe_Cuma_Cumartesi".split("_"),weekdaysShort:"Paz_Pts_Sal_Çar_Per_Cum_Cts".split("_"),weekdaysMin:"Pz_Pt_Sa_Ça_Pe_Cu_Ct".split("_"),months:"Ocak_Şubat_Mart_Nisan_Mayıs_Haziran_Temmuz_Ağustos_Eylül_Ekim_Kasım_Aralık".split("_"),monthsShort:"Oca_Şub_Mar_Nis_May_Haz_Tem_Ağu_Eyl_Eki_Kas_Ara".split("_"),weekStart:1,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"%s sonra",past:"%s önce",s:"birkaç saniye",m:"bir dakika",mm:"%d dakika",h:"bir saat",hh:"%d saat",d:"bir gün",dd:"%d gün",M:"bir ay",MM:"%d ay",y:"bir yıl",yy:"%d yıl"},ordinal:function(e){return e+"."}};return t.default.locale(n,null,!0),n}(n(7484))},7797:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tzl",weekdays:"Súladi_Lúneçi_Maitzi_Márcuri_Xhúadi_Viénerçi_Sáturi".split("_"),months:"Januar_Fevraglh_Març_Avrïu_Mai_Gün_Julia_Guscht_Setemvar_Listopäts_Noemvar_Zecemvar".split("_"),weekStart:1,weekdaysShort:"Súl_Lún_Mai_Már_Xhú_Vié_Sát".split("_"),monthsShort:"Jan_Fev_Mar_Avr_Mai_Gün_Jul_Gus_Set_Lis_Noe_Zec".split("_"),weekdaysMin:"Sú_Lú_Ma_Má_Xh_Vi_Sá".split("_"),ordinal:function(e){return e},formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD.MM.YYYY",LL:"D. MMMM [dallas] YYYY",LLL:"D. MMMM [dallas] YYYY HH.mm",LLLL:"dddd, [li] D. MMMM [dallas] YYYY HH.mm"}};return t.default.locale(n,null,!0),n}(n(7484))},261:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tzm-latn",weekdays:"asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas".split("_"),months:"innayr_brˤayrˤ_marˤsˤ_ibrir_mayyw_ywnyw_ywlywz_ɣwšt_šwtanbir_ktˤwbrˤ_nwwanbir_dwjnbir".split("_"),weekStart:6,weekdaysShort:"asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas".split("_"),monthsShort:"innayr_brˤayrˤ_marˤsˤ_ibrir_mayyw_ywnyw_ywlywz_ɣwšt_šwtanbir_ktˤwbrˤ_nwwanbir_dwjnbir".split("_"),weekdaysMin:"asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"dadkh s yan %s",past:"yan %s",s:"imik",m:"minuḍ",mm:"%d minuḍ",h:"saɛa",hh:"%d tassaɛin",d:"ass",dd:"%d ossan",M:"ayowr",MM:"%d iyyirn",y:"asgas",yy:"%d isgasn"}};return t.default.locale(n,null,!0),n}(n(7484))},4722:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"tzm",weekdays:"ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ".split("_"),months:"ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ".split("_"),weekStart:6,weekdaysShort:"ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ".split("_"),monthsShort:"ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ".split("_"),weekdaysMin:"ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"ⴷⴰⴷⵅ ⵙ ⵢⴰⵏ %s",past:"ⵢⴰⵏ %s",s:"ⵉⵎⵉⴽ",m:"ⵎⵉⵏⵓⴺ",mm:"%d ⵎⵉⵏⵓⴺ",h:"ⵙⴰⵄⴰ",hh:"%d ⵜⴰⵙⵙⴰⵄⵉⵏ",d:"ⴰⵙⵙ",dd:"%d oⵙⵙⴰⵏ",M:"ⴰⵢoⵓⵔ",MM:"%d ⵉⵢⵢⵉⵔⵏ",y:"ⴰⵙⴳⴰⵙ",yy:"%d ⵉⵙⴳⴰⵙⵏ"}};return t.default.locale(n,null,!0),n}(n(7484))},313:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ug-cn",weekdays:"يەكشەنبە_دۈشەنبە_سەيشەنبە_چارشەنبە_پەيشەنبە_جۈمە_شەنبە".split("_"),months:"يانۋار_فېۋرال_مارت_ئاپرېل_ماي_ئىيۇن_ئىيۇل_ئاۋغۇست_سېنتەبىر_ئۆكتەبىر_نويابىر_دېكابىر".split("_"),weekStart:1,weekdaysShort:"يە_دۈ_سە_چا_پە_جۈ_شە".split("_"),monthsShort:"يانۋار_فېۋرال_مارت_ئاپرېل_ماي_ئىيۇن_ئىيۇل_ئاۋغۇست_سېنتەبىر_ئۆكتەبىر_نويابىر_دېكابىر".split("_"),weekdaysMin:"يە_دۈ_سە_چا_پە_جۈ_شە".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"YYYY-يىلىM-ئاينىڭD-كۈنى",LLL:"YYYY-يىلىM-ئاينىڭD-كۈنى، HH:mm",LLLL:"dddd، YYYY-يىلىM-ئاينىڭD-كۈنى، HH:mm"},relativeTime:{future:"%s كېيىن",past:"%s بۇرۇن",s:"نەچچە سېكونت",m:"بىر مىنۇت",mm:"%d مىنۇت",h:"بىر سائەت",hh:"%d سائەت",d:"بىر كۈن",dd:"%d كۈن",M:"بىر ئاي",MM:"%d ئاي",y:"بىر يىل",yy:"%d يىل"}};return t.default.locale(n,null,!0),n}(n(7484))},4144:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n="січня_лютого_березня_квітня_травня_червня_липня_серпня_вересня_жовтня_листопада_грудня".split("_"),r="січень_лютий_березень_квітень_травень_червень_липень_серпень_вересень_жовтень_листопад_грудень".split("_"),a=/D[oD]?(\[[^[\]]*\]|\s)+MMMM?/;function i(e,t,n){var r,a;return"m"===n?t?"хвилина":"хвилину":"h"===n?t?"година":"годину":e+" "+(r=+e,a={ss:t?"секунда_секунди_секунд":"секунду_секунди_секунд",mm:t?"хвилина_хвилини_хвилин":"хвилину_хвилини_хвилин",hh:t?"година_години_годин":"годину_години_годин",dd:"день_дні_днів",MM:"місяць_місяці_місяців",yy:"рік_роки_років"}[n].split("_"),r%10==1&&r%100!=11?a[0]:r%10>=2&&r%10<=4&&(r%100<10||r%100>=20)?a[1]:a[2])}var s=function(e,t){return a.test(t)?n[e.month()]:r[e.month()]};s.s=r,s.f=n;var o={name:"uk",weekdays:"неділя_понеділок_вівторок_середа_четвер_п’ятниця_субота".split("_"),weekdaysShort:"ндл_пнд_втр_срд_чтв_птн_сбт".split("_"),weekdaysMin:"нд_пн_вт_ср_чт_пт_сб".split("_"),months:s,monthsShort:"січ_лют_бер_квіт_трав_черв_лип_серп_вер_жовт_лист_груд".split("_"),weekStart:1,relativeTime:{future:"за %s",past:"%s тому",s:"декілька секунд",m:i,mm:i,h:i,hh:i,d:"день",dd:i,M:"місяць",MM:i,y:"рік",yy:i},ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY р.",LLL:"D MMMM YYYY р., HH:mm",LLLL:"dddd, D MMMM YYYY р., HH:mm"}};return t.default.locale(o,null,!0),o}(n(7484))},2957:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"ur",weekdays:"اتوار_پیر_منگل_بدھ_جمعرات_جمعہ_ہفتہ".split("_"),months:"جنوری_فروری_مارچ_اپریل_مئی_جون_جولائی_اگست_ستمبر_اکتوبر_نومبر_دسمبر".split("_"),weekStart:1,weekdaysShort:"اتوار_پیر_منگل_بدھ_جمعرات_جمعہ_ہفتہ".split("_"),monthsShort:"جنوری_فروری_مارچ_اپریل_مئی_جون_جولائی_اگست_ستمبر_اکتوبر_نومبر_دسمبر".split("_"),weekdaysMin:"اتوار_پیر_منگل_بدھ_جمعرات_جمعہ_ہفتہ".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd، D MMMM YYYY HH:mm"},relativeTime:{future:"%s بعد",past:"%s قبل",s:"چند سیکنڈ",m:"ایک منٹ",mm:"%d منٹ",h:"ایک گھنٹہ",hh:"%d گھنٹے",d:"ایک دن",dd:"%d دن",M:"ایک ماہ",MM:"%d ماہ",y:"ایک سال",yy:"%d سال"}};return t.default.locale(n,null,!0),n}(n(7484))},8727:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"uz-latn",weekdays:"Yakshanba_Dushanba_Seshanba_Chorshanba_Payshanba_Juma_Shanba".split("_"),months:"Yanvar_Fevral_Mart_Aprel_May_Iyun_Iyul_Avgust_Sentabr_Oktabr_Noyabr_Dekabr".split("_"),weekStart:1,weekdaysShort:"Yak_Dush_Sesh_Chor_Pay_Jum_Shan".split("_"),monthsShort:"Yan_Fev_Mar_Apr_May_Iyun_Iyul_Avg_Sen_Okt_Noy_Dek".split("_"),weekdaysMin:"Ya_Du_Se_Cho_Pa_Ju_Sha".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"D MMMM YYYY, dddd HH:mm"},relativeTime:{future:"Yaqin %s ichida",past:"Bir necha %s oldin",s:"soniya",m:"bir daqiqa",mm:"%d daqiqa",h:"bir soat",hh:"%d soat",d:"bir kun",dd:"%d kun",M:"bir oy",MM:"%d oy",y:"bir yil",yy:"%d yil"}};return t.default.locale(n,null,!0),n}(n(7484))},7486:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"uz",weekdays:"Якшанба_Душанба_Сешанба_Чоршанба_Пайшанба_Жума_Шанба".split("_"),months:"январ_феврал_март_апрел_май_июн_июл_август_сентябр_октябр_ноябр_декабр".split("_"),weekStart:1,weekdaysShort:"Якш_Душ_Сеш_Чор_Пай_Жум_Шан".split("_"),monthsShort:"янв_фев_мар_апр_май_июн_июл_авг_сен_окт_ноя_дек".split("_"),weekdaysMin:"Як_Ду_Се_Чо_Па_Жу_Ша".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"D MMMM YYYY, dddd HH:mm"},relativeTime:{future:"Якин %s ичида",past:"Бир неча %s олдин",s:"фурсат",m:"бир дакика",mm:"%d дакика",h:"бир соат",hh:"%d соат",d:"бир кун",dd:"%d кун",M:"бир ой",MM:"%d ой",y:"бир йил",yy:"%d йил"}};return t.default.locale(n,null,!0),n}(n(7484))},7553:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"vi",weekdays:"chủ nhật_thứ hai_thứ ba_thứ tư_thứ năm_thứ sáu_thứ bảy".split("_"),months:"tháng 1_tháng 2_tháng 3_tháng 4_tháng 5_tháng 6_tháng 7_tháng 8_tháng 9_tháng 10_tháng 11_tháng 12".split("_"),weekStart:1,weekdaysShort:"CN_T2_T3_T4_T5_T6_T7".split("_"),monthsShort:"Th01_Th02_Th03_Th04_Th05_Th06_Th07_Th08_Th09_Th10_Th11_Th12".split("_"),weekdaysMin:"CN_T2_T3_T4_T5_T6_T7".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM [năm] YYYY",LLL:"D MMMM [năm] YYYY HH:mm",LLLL:"dddd, D MMMM [năm] YYYY HH:mm",l:"DD/M/YYYY",ll:"D MMM YYYY",lll:"D MMM YYYY HH:mm",llll:"ddd, D MMM YYYY HH:mm"},relativeTime:{future:"%s tới",past:"%s trước",s:"vài giây",m:"một phút",mm:"%d phút",h:"một giờ",hh:"%d giờ",d:"một ngày",dd:"%d ngày",M:"một tháng",MM:"%d tháng",y:"một năm",yy:"%d năm"}};return t.default.locale(n,null,!0),n}(n(7484))},5321:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"x-pseudo",weekdays:"S~úñdá~ý_Mó~ñdáý~_Túé~sdáý~_Wéd~ñésd~áý_T~húrs~dáý_~Fríd~áý_S~átúr~dáý".split("_"),months:"J~áñúá~rý_F~ébrú~árý_~Márc~h_Áp~ríl_~Máý_~Júñé~_Júl~ý_Áú~gúst~_Sép~témb~ér_Ó~ctób~ér_Ñ~óvém~bér_~Décé~mbér".split("_"),weekStart:1,weekdaysShort:"S~úñ_~Móñ_~Túé_~Wéd_~Thú_~Frí_~Sát".split("_"),monthsShort:"J~áñ_~Féb_~Már_~Ápr_~Máý_~Júñ_~Júl_~Áúg_~Sép_~Óct_~Ñóv_~Déc".split("_"),weekdaysMin:"S~ú_Mó~_Tú_~Wé_T~h_Fr~_Sá".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"í~ñ %s",past:"%s á~gó",s:"á ~féw ~sécó~ñds",m:"á ~míñ~úté",mm:"%d m~íñú~tés",h:"á~ñ hó~úr",hh:"%d h~óúrs",d:"á ~dáý",dd:"%d d~áýs",M:"á ~móñ~th",MM:"%d m~óñt~hs",y:"á ~ýéár",yy:"%d ý~éárs"}};return t.default.locale(n,null,!0),n}(n(7484))},4724:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"yo",weekdays:"Àìkú_Ajé_Ìsẹ́gun_Ọjọ́rú_Ọjọ́bọ_Ẹtì_Àbámẹ́ta".split("_"),months:"Sẹ́rẹ́_Èrèlè_Ẹrẹ̀nà_Ìgbé_Èbibi_Òkùdu_Agẹmo_Ògún_Owewe_Ọ̀wàrà_Bélú_Ọ̀pẹ̀̀".split("_"),weekStart:1,weekdaysShort:"Àìk_Ajé_Ìsẹ́_Ọjr_Ọjb_Ẹtì_Àbá".split("_"),monthsShort:"Sẹ́r_Èrl_Ẹrn_Ìgb_Èbi_Òkù_Agẹ_Ògú_Owe_Ọ̀wà_Bél_Ọ̀pẹ̀̀".split("_"),weekdaysMin:"Àì_Aj_Ìs_Ọr_Ọb_Ẹt_Àb".split("_"),ordinal:function(e){return e},formats:{LT:"h:mm A",LTS:"h:mm:ss A",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY h:mm A",LLLL:"dddd, D MMMM YYYY h:mm A"},relativeTime:{future:"ní %s",past:"%s kọjá",s:"ìsẹjú aayá die",m:"ìsẹjú kan",mm:"ìsẹjú %d",h:"wákati kan",hh:"wákati %d",d:"ọjọ́ kan",dd:"ọjọ́ %d",M:"osù kan",MM:"osù %d",y:"ọdún kan",yy:"ọdún %d"}};return t.default.locale(n,null,!0),n}(n(7484))},3852:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"zh-cn",weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"周日_周一_周二_周三_周四_周五_周六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),ordinal:function(e,t){return"W"===t?e+"周":e+"日"},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日Ah点mm分",LLLL:"YYYY年M月D日ddddAh点mm分",l:"YYYY/M/D",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日dddd HH:mm"},relativeTime:{future:"%s内",past:"%s前",s:"几秒",m:"1 分钟",mm:"%d 分钟",h:"1 小时",hh:"%d 小时",d:"1 天",dd:"%d 天",M:"1 个月",MM:"%d 个月",y:"1 年",yy:"%d 年"},meridiem:function(e,t){var n=100*e+t;return n<600?"凌晨":n<900?"早上":n<1100?"上午":n<1300?"中午":n<1800?"下午":"晚上"}};return t.default.locale(n,null,!0),n}(n(7484))},2390:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"zh-hk",months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"週日_週一_週二_週三_週四_週五_週六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),ordinal:function(e,t){return"W"===t?e+"週":e+"日"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日 HH:mm",LLLL:"YYYY年M月D日dddd HH:mm"},relativeTime:{future:"%s內",past:"%s前",s:"幾秒",m:"一分鐘",mm:"%d 分鐘",h:"一小時",hh:"%d 小時",d:"一天",dd:"%d 天",M:"一個月",MM:"%d 個月",y:"一年",yy:"%d 年"}};return t.default.locale(n,null,!0),n}(n(7484))},3901:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"zh-tw",weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"週日_週一_週二_週三_週四_週五_週六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),ordinal:function(e,t){return"W"===t?e+"週":e+"日"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日 HH:mm",LLLL:"YYYY年M月D日dddd HH:mm",l:"YYYY/M/D",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日dddd HH:mm"},relativeTime:{future:"%s內",past:"%s前",s:"幾秒",m:"1 分鐘",mm:"%d 分鐘",h:"1 小時",hh:"%d 小時",d:"1 天",dd:"%d 天",M:"1 個月",MM:"%d 個月",y:"1 年",yy:"%d 年"}};return t.default.locale(n,null,!0),n}(n(7484))},2009:function(e,t,n){e.exports=function(e){"use strict";var t=function(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}(e),n={name:"zh",weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"周日_周一_周二_周三_周四_周五_周六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),ordinal:function(e,t){return"W"===t?e+"周":e+"日"},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日Ah点mm分",LLLL:"YYYY年M月D日ddddAh点mm分",l:"YYYY/M/D",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日dddd HH:mm"},relativeTime:{future:"%s后",past:"%s前",s:"几秒",m:"1 分钟",mm:"%d 分钟",h:"1 小时",hh:"%d 小时",d:"1 天",dd:"%d 天",M:"1 个月",MM:"%d 个月",y:"1 年",yy:"%d 年"},meridiem:function(e,t){var n=100*e+t;return n<600?"凌晨":n<900?"早上":n<1100?"上午":n<1300?"中午":n<1800?"下午":"晚上"}};return t.default.locale(n,null,!0),n}(n(7484))},285:function(e){e.exports=function(){"use strict";var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},t=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,n=/\d\d/,r=/\d\d?/,a=/\d*[^-_:/,()\s\d]+/,i={},s=function(e){return(e=+e)+(e>68?1900:2e3)},o=function(e){return function(t){this[e]=+t}},u=[/[+-]\d\d:?(\d\d)?|Z/,function(e){(this.zone||(this.zone={})).offset=function(e){if(!e)return 0;if("Z"===e)return 0;var t=e.match(/([+-]|\d\d)/g),n=60*t[1]+(+t[2]||0);return 0===n?0:"+"===t[0]?-n:n}(e)}],l=function(e){var t=i[e];return t&&(t.indexOf?t:t.s.concat(t.f))},c=function(e,t){var n,r=i.meridiem;if(r){for(var a=1;a<=24;a+=1)if(e.indexOf(r(a,0,t))>-1){n=a>12;break}}else n=e===(t?"pm":"PM");return n},p={A:[a,function(e){this.afternoon=c(e,!1)}],a:[a,function(e){this.afternoon=c(e,!0)}],S:[/\d/,function(e){this.milliseconds=100*+e}],SS:[n,function(e){this.milliseconds=10*+e}],SSS:[/\d{3}/,function(e){this.milliseconds=+e}],s:[r,o("seconds")],ss:[r,o("seconds")],m:[r,o("minutes")],mm:[r,o("minutes")],H:[r,o("hours")],h:[r,o("hours")],HH:[r,o("hours")],hh:[r,o("hours")],D:[r,o("day")],DD:[n,o("day")],Do:[a,function(e){var t=i.ordinal,n=e.match(/\d+/);if(this.day=n[0],t)for(var r=1;r<=31;r+=1)t(r).replace(/\[|\]/g,"")===e&&(this.day=r)}],M:[r,o("month")],MM:[n,o("month")],MMM:[a,function(e){var t=l("months"),n=(l("monthsShort")||t.map((function(e){return e.slice(0,3)}))).indexOf(e)+1;if(n<1)throw new Error;this.month=n%12||n}],MMMM:[a,function(e){var t=l("months").indexOf(e)+1;if(t<1)throw new Error;this.month=t%12||t}],Y:[/[+-]?\d+/,o("year")],YY:[n,function(e){this.year=s(e)}],YYYY:[/\d{4}/,o("year")],Z:u,ZZ:u};function d(n){var r,a;r=n,a=i&&i.formats;for(var s=(n=r.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,n,r){var i=r&&r.toUpperCase();return n||a[r]||e[r]||a[i].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}))).match(t),o=s.length,u=0;u-1)return new Date(("X"===t?1e3:1)*e);var r=d(t)(e),a=r.year,i=r.month,s=r.day,o=r.hours,u=r.minutes,l=r.seconds,c=r.milliseconds,p=r.zone,h=new Date,f=s||(a||i?1:h.getDate()),m=a||h.getFullYear(),g=0;a&&!i||(g=i>0?i-1:h.getMonth());var y=o||0,b=u||0,v=l||0,x=c||0;return p?new Date(Date.UTC(m,g,f,y,b,v,x+60*p.offset*1e3)):n?new Date(Date.UTC(m,g,f,y,b,v,x)):new Date(m,g,f,y,b,v,x)}catch(e){return new Date("")}}(t,o,r),this.init(),p&&!0!==p&&(this.$L=this.locale(p).$L),c&&t!=this.format(o)&&(this.$d=new Date("")),i={}}else if(o instanceof Array)for(var h=o.length,f=1;f<=h;f+=1){s[1]=o[f-1];var m=n.apply(this,s);if(m.isValid()){this.$d=m.$d,this.$L=m.$L,this.init();break}f===h&&(this.$d=new Date(""))}else a.call(this,e)}}}()},2997:function(e){e.exports=function(){"use strict";return function(e,t,n){t.prototype.dayOfYear=function(e){var t=Math.round((n(this).startOf("day")-n(this).startOf("year"))/864e5)+1;return null==e?t:this.add(e-t,"day")}}}()},6036:function(e){e.exports=function(){"use strict";return function(e,t,n){var r=t.prototype,a=function(e){return e&&(e.indexOf?e:e.s)},i=function(e,t,n,r,i){var s=e.name?e:e.$locale(),o=a(s[t]),u=a(s[n]),l=o||u.map((function(e){return e.slice(0,r)}));if(!i)return l;var c=s.weekStart;return l.map((function(e,t){return l[(t+(c||0))%7]}))},s=function(){return n.Ls[n.locale()]},o=function(e,t){return e.formats[t]||function(e){return e.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}(e.formats[t.toUpperCase()])},u=function(){var e=this;return{months:function(t){return t?t.format("MMMM"):i(e,"months")},monthsShort:function(t){return t?t.format("MMM"):i(e,"monthsShort","months",3)},firstDayOfWeek:function(){return e.$locale().weekStart||0},weekdays:function(t){return t?t.format("dddd"):i(e,"weekdays")},weekdaysMin:function(t){return t?t.format("dd"):i(e,"weekdaysMin","weekdays",2)},weekdaysShort:function(t){return t?t.format("ddd"):i(e,"weekdaysShort","weekdays",3)},longDateFormat:function(t){return o(e.$locale(),t)},meridiem:this.$locale().meridiem,ordinal:this.$locale().ordinal}};r.localeData=function(){return u.bind(this)()},n.localeData=function(){var e=s();return{firstDayOfWeek:function(){return e.weekStart||0},weekdays:function(){return n.weekdays()},weekdaysShort:function(){return n.weekdaysShort()},weekdaysMin:function(){return n.weekdaysMin()},months:function(){return n.months()},monthsShort:function(){return n.monthsShort()},longDateFormat:function(t){return o(e,t)},meridiem:e.meridiem,ordinal:e.ordinal}},n.months=function(){return i(s(),"months")},n.monthsShort=function(){return i(s(),"monthsShort","months",3)},n.weekdays=function(e){return i(s(),"weekdays",null,null,e)},n.weekdaysShort=function(e){return i(s(),"weekdaysShort","weekdays",3,e)},n.weekdaysMin=function(e){return i(s(),"weekdaysMin","weekdays",2,e)}}}()},6176:function(e){e.exports=function(){"use strict";var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};return function(t,n,r){var a=n.prototype,i=a.format;r.en.formats=e,a.format=function(t){void 0===t&&(t="YYYY-MM-DDTHH:mm:ssZ");var n=this.$locale().formats,r=function(t,n){return t.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,r,a){var i=a&&a.toUpperCase();return r||n[a]||e[a]||n[i].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}))}(t,void 0===n?{}:n);return i.call(this,r)}}}()},178:function(e){e.exports=function(){"use strict";var e="minute",t=/[+-]\d\d(?::?\d\d)?/g,n=/([+-]|\d\d)/g;return function(r,a,i){var s=a.prototype;i.utc=function(e){return new a({date:e,utc:!0,args:arguments})},s.utc=function(t){var n=i(this.toDate(),{locale:this.$L,utc:!0});return t?n.add(this.utcOffset(),e):n},s.local=function(){return i(this.toDate(),{locale:this.$L,utc:!1})};var o=s.parse;s.parse=function(e){e.utc&&(this.$u=!0),this.$utils().u(e.$offset)||(this.$offset=e.$offset),o.call(this,e)};var u=s.init;s.init=function(){if(this.$u){var e=this.$d;this.$y=e.getUTCFullYear(),this.$M=e.getUTCMonth(),this.$D=e.getUTCDate(),this.$W=e.getUTCDay(),this.$H=e.getUTCHours(),this.$m=e.getUTCMinutes(),this.$s=e.getUTCSeconds(),this.$ms=e.getUTCMilliseconds()}else u.call(this)};var l=s.utcOffset;s.utcOffset=function(r,a){var i=this.$utils().u;if(i(r))return this.$u?0:i(this.$offset)?l.call(this):this.$offset;if("string"==typeof r&&(r=function(e){void 0===e&&(e="");var r=e.match(t);if(!r)return null;var a=(""+r[0]).match(n)||["-",0,0],i=a[0],s=60*+a[1]+ +a[2];return 0===s?0:"+"===i?s:-s}(r),null===r))return this;var s=Math.abs(r)<=16?60*r:r,o=this;if(a)return o.$offset=s,o.$u=0===r,o;if(0!==r){var u=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(o=this.local().add(s+u,e)).$offset=s,o.$x.$localOffset=u}else o=this.utc();return o};var c=s.format;s.format=function(e){var t=e||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return c.call(this,t)},s.valueOf=function(){var e=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*e},s.isUTC=function(){return!!this.$u},s.toISOString=function(){return this.toDate().toISOString()},s.toString=function(){return this.toDate().toUTCString()};var p=s.toDate;s.toDate=function(e){return"s"===e&&this.$offset?i(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():p.call(this)};var d=s.diff;s.diff=function(e,t,n){if(e&&this.$u===e.$u)return d.call(this,e,t,n);var r=this.local(),a=i(e).local();return d.call(r,a,t,n)}}}()},7928:e=>{"use strict";var t=Object.assign||function(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:{},s=i.preserveFormatting,o=void 0!==s&&s,u=i.escapeMapFn,l=void 0===u?a:u,c=String(e),p="",d=l(t({},n),o?t({},r):{}),h=Object.keys(d),f=function(){var e=!1;h.forEach((function(t,n){e||c.length>=t.length&&c.slice(0,t.length)===t&&(p+=d[h[n]],c=c.slice(t.length,c.length),e=!0)})),e||(p+=c.slice(0,1),c=c.slice(1,c.length))};c;)f();return p}},5628:function(e,t){var n;!function(r){"use strict";var a={s:1,n:0,d:1};function i(e,t){if(isNaN(e=parseInt(e,10)))throw c.InvalidParameter;return e*t}function s(e,t){if(0===t)throw c.DivisionByZero;var n=Object.create(c.prototype);n.s=e<0?-1:1;var r=l(e=e<0?-e:e,t);return n.n=e/r,n.d=t/r,n}function o(e){for(var t={},n=e,r=2,a=4;a<=n;){for(;n%r==0;)n/=r,t[r]=(t[r]||0)+1;a+=1+2*r++}return n!==e?n>1&&(t[n]=(t[n]||0)+1):t[e]=(t[e]||0)+1,t}var u=function(e,t){var n,r=0,s=1,o=1,u=0,l=0,p=0,d=1,h=1,f=0,m=1,g=1,y=1,b=1e7;if(null==e);else if(void 0!==t){if(o=(r=e)*(s=t),r%1!=0||s%1!=0)throw c.NonIntegerParameter}else switch(typeof e){case"object":if("d"in e&&"n"in e)r=e.n,s=e.d,"s"in e&&(r*=e.s);else{if(!(0 in e))throw c.InvalidParameter;r=e[0],1 in e&&(s=e[1])}o=r*s;break;case"number":if(e<0&&(o=e,e=-e),e%1==0)r=e;else if(e>0){for(e>=1&&(e/=h=Math.pow(10,Math.floor(1+Math.log(e)/Math.LN10)));m<=b&&y<=b;){if(e===(n=(f+g)/(m+y))){m+y<=b?(r=f+g,s=m+y):y>m?(r=g,s=y):(r=f,s=m);break}e>n?(f+=g,m+=y):(g+=f,y+=m),m>b?(r=g,s=y):(r=f,s=m)}r*=h}else(isNaN(e)||isNaN(t))&&(s=r=NaN);break;case"string":if(null===(m=e.match(/\d+|./g)))throw c.InvalidParameter;if("-"===m[f]?(o=-1,f++):"+"===m[f]&&f++,m.length===f+1?l=i(m[f++],o):"."===m[f+1]||"."===m[f]?("."!==m[f]&&(u=i(m[f++],o)),(1+ ++f===m.length||"("===m[f+1]&&")"===m[f+3]||"'"===m[f+1]&&"'"===m[f+3])&&(l=i(m[f],o),d=Math.pow(10,m[f].length),f++),("("===m[f]&&")"===m[f+2]||"'"===m[f]&&"'"===m[f+2])&&(p=i(m[f+1],o),h=Math.pow(10,m[f+1].length)-1,f+=3)):"/"===m[f+1]||":"===m[f+1]?(l=i(m[f],o),d=i(m[f+2],1),f+=3):"/"===m[f+3]&&" "===m[f+1]&&(u=i(m[f],o),l=i(m[f+2],o),d=i(m[f+4],1),f+=5),m.length<=f){o=r=p+(s=d*h)*u+h*l;break}default:throw c.InvalidParameter}if(0===s)throw c.DivisionByZero;a.s=o<0?-1:1,a.n=Math.abs(r),a.d=Math.abs(s)};function l(e,t){if(!e)return t;if(!t)return e;for(;;){if(!(e%=t))return t;if(!(t%=e))return e}}function c(e,t){if(u(e,t),!(this instanceof c))return s(a.s*a.n,a.d);e=l(a.d,a.n),this.s=a.s,this.n=a.n/e,this.d=a.d/e}c.DivisionByZero=new Error("Division by Zero"),c.InvalidParameter=new Error("Invalid argument"),c.NonIntegerParameter=new Error("Parameters must be integer"),c.prototype={s:1,n:0,d:1,abs:function(){return s(this.n,this.d)},neg:function(){return s(-this.s*this.n,this.d)},add:function(e,t){return u(e,t),s(this.s*this.n*a.d+a.s*this.d*a.n,this.d*a.d)},sub:function(e,t){return u(e,t),s(this.s*this.n*a.d-a.s*this.d*a.n,this.d*a.d)},mul:function(e,t){return u(e,t),s(this.s*a.s*this.n*a.n,this.d*a.d)},div:function(e,t){return u(e,t),s(this.s*a.s*this.n*a.d,this.d*a.n)},clone:function(){return s(this.s*this.n,this.d)},mod:function(e,t){if(isNaN(this.n)||isNaN(this.d))return new c(NaN);if(void 0===e)return s(this.s*this.n%this.d,1);if(u(e,t),0===a.n&&0===this.d)throw c.DivisionByZero;return s(this.s*(a.d*this.n)%(a.n*this.d),a.d*this.d)},gcd:function(e,t){return u(e,t),s(l(a.n,this.n)*l(a.d,this.d),a.d*this.d)},lcm:function(e,t){return u(e,t),0===a.n&&0===this.n?s(0,1):s(a.n*this.n,l(a.n,this.n)*l(a.d,this.d))},ceil:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new c(NaN):s(Math.ceil(e*this.s*this.n/this.d),e)},floor:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new c(NaN):s(Math.floor(e*this.s*this.n/this.d),e)},round:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new c(NaN):s(Math.round(e*this.s*this.n/this.d),e)},inverse:function(){return s(this.s*this.d,this.n)},pow:function(e,t){if(u(e,t),1===a.d)return a.s<0?s(Math.pow(this.s*this.d,a.n),Math.pow(this.n,a.n)):s(Math.pow(this.s*this.n,a.n),Math.pow(this.d,a.n));if(this.s<0)return null;var n=o(this.n),r=o(this.d),i=1,l=1;for(var c in n)if("1"!==c){if("0"===c){i=0;break}if(n[c]*=a.n,n[c]%a.d!=0)return null;n[c]/=a.d,i*=Math.pow(c,n[c])}for(var c in r)if("1"!==c){if(r[c]*=a.n,r[c]%a.d!=0)return null;r[c]/=a.d,l*=Math.pow(c,r[c])}return a.s<0?s(l,i):s(i,l)},equals:function(e,t){return u(e,t),this.s*this.n*a.d==a.s*a.n*this.d},compare:function(e,t){u(e,t);var n=this.s*this.n*a.d-a.s*a.n*this.d;return(0=0;i--)a=a.inverse().add(n[i]);if(a.sub(t).abs().valueOf()0&&(n+=t,n+=" ",r%=a),n+=r,n+="/",n+=a),n},toLatex:function(e){var t,n="",r=this.n,a=this.d;return this.s<0&&(n+="-"),1===a?n+=r:(e&&(t=Math.floor(r/a))>0&&(n+=t,r%=a),n+="\\frac{",n+=r,n+="}{",n+=a,n+="}"),n},toContinued:function(){var e,t=this.n,n=this.d,r=[];if(isNaN(t)||isNaN(n))return r;do{r.push(Math.floor(t/n)),e=t%n,t=n,n=e}while(1!==t);return r},toString:function(e){var t=this.n,n=this.d;if(isNaN(t)||isNaN(n))return"NaN";e=e||15;var r=function(e,t){for(;t%2==0;t/=2);for(;t%5==0;t/=5);if(1===t)return 0;for(var n=10%t,r=1;1!==n;r++)if(n=10*n%t,r>2e3)return 0;return r}(0,n),a=function(e,t,n){for(var r=1,a=function(e,t,n){for(var r=1;t>0;e=e*e%n,t>>=1)1&t&&(r=r*e%n);return r}(10,n,t),i=0;i<300;i++){if(r===a)return i;r=10*r%t,a=10*a%t}return 0}(0,n,r),i=this.s<0?"-":"";if(i+=t/n|0,t%=n,(t*=10)&&(i+="."),r){for(var s=a;s--;)i+=t/n|0,t%=n,t*=10;for(i+="(",s=r;s--;)i+=t/n|0,t%=n,t*=10;i+=")"}else for(s=e;t&&s--;)i+=t/n|0,t%=n,t*=10;return i}},void 0===(n=function(){return c}.apply(t,[]))||(e.exports=n)}()},3228:e=>{e.exports=function e(t,n){"use strict";var r,a,i=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,s=/(^[ ]*|[ ]*$)/g,o=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,u=/^0x[0-9a-f]+$/i,l=/^0/,c=function(t){return e.insensitive&&(""+t).toLowerCase()||""+t},p=c(t).replace(s,"")||"",d=c(n).replace(s,"")||"",h=p.replace(i,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),f=d.replace(i,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),m=parseInt(p.match(u),16)||1!==h.length&&p.match(o)&&Date.parse(p),g=parseInt(d.match(u),16)||m&&d.match(o)&&Date.parse(d)||null;if(g){if(mg)return 1}for(var y=0,b=Math.max(h.length,f.length);ya)return 1}return 0}},3720:e=>{e.exports=n;var t=null;try{t=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(e){}function n(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function r(e){return!0===(e&&e.__isLong__)}n.prototype.__isLong__,Object.defineProperty(n.prototype,"__isLong__",{value:!0}),n.isLong=r;var a={},i={};function s(e,t){var n,r,s;return t?(s=0<=(e>>>=0)&&e<256)&&(r=i[e])?r:(n=u(e,(0|e)<0?-1:0,!0),s&&(i[e]=n),n):(s=-128<=(e|=0)&&e<128)&&(r=a[e])?r:(n=u(e,e<0?-1:0,!1),s&&(a[e]=n),n)}function o(e,t){if(isNaN(e))return t?y:g;if(t){if(e<0)return y;if(e>=h)return w}else{if(e<=-f)return D;if(e+1>=f)return _}return e<0?o(-e,t).neg():u(e%d|0,e/d|0,t)}function u(e,t,r){return new n(e,t,r)}n.fromInt=s,n.fromNumber=o,n.fromBits=u;var l=Math.pow;function c(e,t,n){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return g;if("number"==typeof t?(n=t,t=!1):t=!!t,(n=n||10)<2||360)throw Error("interior hyphen");if(0===r)return c(e.substring(1),t,n).neg();for(var a=o(l(n,8)),i=g,s=0;s>>0:this.low},N.toNumber=function(){return this.unsigned?(this.high>>>0)*d+(this.low>>>0):this.high*d+(this.low>>>0)},N.toString=function(e){if((e=e||10)<2||36>>0).toString(e);if((i=u).isZero())return c+s;for(;c.length<6;)c="0"+c;s=""+c+s}},N.getHighBits=function(){return this.high},N.getHighBitsUnsigned=function(){return this.high>>>0},N.getLowBits=function(){return this.low},N.getLowBitsUnsigned=function(){return this.low>>>0},N.getNumBitsAbs=function(){if(this.isNegative())return this.eq(D)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&0==(e&1<=0},N.isOdd=function(){return 1==(1&this.low)},N.isEven=function(){return 0==(1&this.low)},N.equals=function(e){return r(e)||(e=p(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low},N.eq=N.equals,N.notEquals=function(e){return!this.eq(e)},N.neq=N.notEquals,N.ne=N.notEquals,N.lessThan=function(e){return this.comp(e)<0},N.lt=N.lessThan,N.lessThanOrEqual=function(e){return this.comp(e)<=0},N.lte=N.lessThanOrEqual,N.le=N.lessThanOrEqual,N.greaterThan=function(e){return this.comp(e)>0},N.gt=N.greaterThan,N.greaterThanOrEqual=function(e){return this.comp(e)>=0},N.gte=N.greaterThanOrEqual,N.ge=N.greaterThanOrEqual,N.compare=function(e){if(r(e)||(e=p(e)),this.eq(e))return 0;var t=this.isNegative(),n=e.isNegative();return t&&!n?-1:!t&&n?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},N.comp=N.compare,N.negate=function(){return!this.unsigned&&this.eq(D)?D:this.not().add(b)},N.neg=N.negate,N.add=function(e){r(e)||(e=p(e));var t=this.high>>>16,n=65535&this.high,a=this.low>>>16,i=65535&this.low,s=e.high>>>16,o=65535&e.high,l=e.low>>>16,c=0,d=0,h=0,f=0;return h+=(f+=i+(65535&e.low))>>>16,d+=(h+=a+l)>>>16,c+=(d+=n+o)>>>16,c+=t+s,u((h&=65535)<<16|(f&=65535),(c&=65535)<<16|(d&=65535),this.unsigned)},N.subtract=function(e){return r(e)||(e=p(e)),this.add(e.neg())},N.sub=N.subtract,N.multiply=function(e){if(this.isZero())return g;if(r(e)||(e=p(e)),t)return u(t.mul(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned);if(e.isZero())return g;if(this.eq(D))return e.isOdd()?D:g;if(e.eq(D))return this.isOdd()?D:g;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(m)&&e.lt(m))return o(this.toNumber()*e.toNumber(),this.unsigned);var n=this.high>>>16,a=65535&this.high,i=this.low>>>16,s=65535&this.low,l=e.high>>>16,c=65535&e.high,d=e.low>>>16,h=65535&e.low,f=0,y=0,b=0,v=0;return b+=(v+=s*h)>>>16,y+=(b+=i*h)>>>16,b&=65535,y+=(b+=s*d)>>>16,f+=(y+=a*h)>>>16,y&=65535,f+=(y+=i*d)>>>16,y&=65535,f+=(y+=s*c)>>>16,f+=n*h+a*d+i*c+s*l,u((b&=65535)<<16|(v&=65535),(f&=65535)<<16|(y&=65535),this.unsigned)},N.mul=N.multiply,N.divide=function(e){if(r(e)||(e=p(e)),e.isZero())throw Error("division by zero");var n,a,i;if(t)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?u((this.unsigned?t.div_u:t.div_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?y:g;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return y;if(e.gt(this.shru(1)))return v;i=y}else{if(this.eq(D))return e.eq(b)||e.eq(x)?D:e.eq(D)?b:(n=this.shr(1).div(e).shl(1)).eq(g)?e.isNegative()?b:x:(a=this.sub(e.mul(n)),i=n.add(a.div(e)));if(e.eq(D))return this.unsigned?y:g;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=g}for(a=this;a.gte(e);){n=Math.max(1,Math.floor(a.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(n)/Math.LN2),c=s<=48?1:l(2,s-48),d=o(n),h=d.mul(e);h.isNegative()||h.gt(a);)h=(d=o(n-=c,this.unsigned)).mul(e);d.isZero()&&(d=b),i=i.add(d),a=a.sub(h)}return i},N.div=N.divide,N.modulo=function(e){return r(e)||(e=p(e)),t?u((this.unsigned?t.rem_u:t.rem_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},N.mod=N.modulo,N.rem=N.modulo,N.not=function(){return u(~this.low,~this.high,this.unsigned)},N.and=function(e){return r(e)||(e=p(e)),u(this.low&e.low,this.high&e.high,this.unsigned)},N.or=function(e){return r(e)||(e=p(e)),u(this.low|e.low,this.high|e.high,this.unsigned)},N.xor=function(e){return r(e)||(e=p(e)),u(this.low^e.low,this.high^e.high,this.unsigned)},N.shiftLeft=function(e){return r(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?u(this.low<>>32-e,this.unsigned):u(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):u(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},N.shr=N.shiftRight,N.shiftRightUnsigned=function(e){if(r(e)&&(e=e.toInt()),0==(e&=63))return this;var t=this.high;return e<32?u(this.low>>>e|t<<32-e,t>>>e,this.unsigned):u(32===e?t:t>>>e-32,0,this.unsigned)},N.shru=N.shiftRightUnsigned,N.shr_u=N.shiftRightUnsigned,N.toSigned=function(){return this.unsigned?u(this.low,this.high,!1):this},N.toUnsigned=function(){return this.unsigned?this:u(this.low,this.high,!0)},N.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},N.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},N.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},n.fromBytes=function(e,t,r){return r?n.fromBytesLE(e,t):n.fromBytesBE(e,t)},n.fromBytesLE=function(e,t){return new n(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},n.fromBytesBE=function(e,t){return new n(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)}},6377:(e,t,n)=>{var r=n(4832),a=n(8652),i=n(801),s=n(2030),o=n(3618),u=n(9049),l=n(1971);l.alea=r,l.xor128=a,l.xorwow=i,l.xorshift7=s,l.xor4096=o,l.tychei=u,e.exports=l},4832:function(e,t,n){var r;!function(e,a,i){function s(e){var t,n=this,r=(t=4022871197,function(e){e=String(e);for(var n=0;n>>0,t=(r*=t)>>>0,t+=4294967296*(r-=t)}return 2.3283064365386963e-10*(t>>>0)});n.next=function(){var e=2091639*n.s0+2.3283064365386963e-10*n.c;return n.s0=n.s1,n.s1=n.s2,n.s2=e-(n.c=0|e)},n.c=1,n.s0=r(" "),n.s1=r(" "),n.s2=r(" "),n.s0-=r(e),n.s0<0&&(n.s0+=1),n.s1-=r(e),n.s1<0&&(n.s1+=1),n.s2-=r(e),n.s2<0&&(n.s2+=1),r=null}function o(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function u(e,t){var n=new s(e),r=t&&t.state,a=n.next;return a.int32=function(){return 4294967296*n.next()|0},a.double=function(){return a()+11102230246251565e-32*(2097152*a()|0)},a.quick=a,r&&("object"==typeof r&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.alea=u}(0,e=n.nmd(e),n.amdD)},9049:function(e,t,n){var r;!function(e,a,i){function s(e){var t=this,n="";t.next=function(){var e=t.b,n=t.c,r=t.d,a=t.a;return e=e<<25^e>>>7^n,n=n-r|0,r=r<<24^r>>>8^a,a=a-e|0,t.b=e=e<<20^e>>>12^n,t.c=n=n-r|0,t.d=r<<16^n>>>16^a,t.a=a-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=0|e):n+=e;for(var r=0;r>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&("object"==typeof r&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.tychei=u}(0,e=n.nmd(e),n.amdD)},8652:function(e,t,n){var r;!function(e,a,i){function s(e){var t=this,n="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:n+=e;for(var r=0;r>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&("object"==typeof r&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xor128=u}(0,e=n.nmd(e),n.amdD)},3618:function(e,t,n){var r;!function(e,a,i){function s(e){var t=this;t.next=function(){var e,n,r=t.w,a=t.X,i=t.i;return t.w=r=r+1640531527|0,n=a[i+34&127],e=a[i=i+1&127],n^=n<<13,e^=e<<17,n^=n>>>15,e^=e>>>12,n=a[i]=n^e,t.i=i,n+(r^r>>>16)|0},function(e,t){var n,r,a,i,s,o=[],u=128;for(t===(0|t)?(r=t,t=null):(t+="\0",r=0,u=Math.max(u,t.length)),a=0,i=-32;i>>15,r^=r<<4,r^=r>>>13,i>=0&&(s=s+1640531527|0,a=0==(n=o[127&i]^=r+s)?a+1:0);for(a>=128&&(o[127&(t&&t.length||0)]=-1),a=127,i=512;i>0;--i)r=o[a+34&127],n=o[a=a+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,o[a]=r^n;e.w=s,e.X=o,e.i=a}(t,e)}function o(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function u(e,t){null==e&&(e=+new Date);var n=new s(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&(r.X&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xor4096=u}(0,e=n.nmd(e),n.amdD)},2030:function(e,t,n){var r;!function(e,a,i){function s(e){var t=this;t.next=function(){var e,n,r=t.x,a=t.i;return e=r[a],n=(e^=e>>>7)^e<<24,n^=(e=r[a+1&7])^e>>>10,n^=(e=r[a+3&7])^e>>>3,n^=(e=r[a+4&7])^e<<7,e=r[a+7&7],n^=(e^=e<<13)^e<<9,r[a]=n,t.i=a+1&7,n},function(e,t){var n,r=[];if(t===(0|t))r[0]=t;else for(t=""+t,n=0;n0;--n)e.next()}(t,e)}function o(e,t){return t.x=e.x.slice(),t.i=e.i,t}function u(e,t){null==e&&(e=+new Date);var n=new s(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&(r.x&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xorshift7=u}(0,e=n.nmd(e),n.amdD)},801:function(e,t,n){var r;!function(e,a,i){function s(e){var t=this,n="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:n+=e;for(var r=0;r>>4),t.next()}function o(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function u(e,t){var n=new s(e),r=t&&t.state,a=function(){return(n.next()>>>0)/4294967296};return a.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},a.int32=n.next,a.quick=a,r&&("object"==typeof r&&o(r,n),a.state=function(){return o(n,{})}),a}a&&a.exports?a.exports=u:n.amdD&&n.amdO?void 0===(r=function(){return u}.call(t,n,t,a))||(a.exports=r):this.xorwow=u}(0,e=n.nmd(e),n.amdD)},1971:function(e,t,n){var r;!function(a,i,s){var o,u=256,l=s.pow(u,6),c=s.pow(2,52),p=2*c,d=255;function h(e,t,n){var r=[],d=y(g((t=1==t?{entropy:!0}:t||{}).entropy?[e,b(i)]:null==e?function(){try{var e;return o&&(e=o.randomBytes)?e=e(u):(e=new Uint8Array(u),(a.crypto||a.msCrypto).getRandomValues(e)),b(e)}catch(e){var t=a.navigator,n=t&&t.plugins;return[+new Date,a,n,a.screen,b(i)]}}():e,3),r),h=new f(r),v=function(){for(var e=h.g(6),t=l,n=0;e=p;)e/=2,t/=2,n>>>=1;return(e+n)/t};return v.int32=function(){return 0|h.g(4)},v.quick=function(){return h.g(4)/4294967296},v.double=v,y(b(h.S),i),(t.pass||n||function(e,t,n,r){return r&&(r.S&&m(r,h),e.state=function(){return m(h,{})}),n?(s.random=e,t):e})(v,d,"global"in t?t.global:this==s,t.state)}function f(e){var t,n=e.length,r=this,a=0,i=r.i=r.j=0,s=r.S=[];for(n||(e=[n++]);a{function t(){}t.prototype={on:function(e,t,n){var r=this.e||(this.e={});return(r[e]||(r[e]=[])).push({fn:t,ctx:n}),this},once:function(e,t,n){var r=this;function a(){r.off(e,a),t.apply(n,arguments)}return a._=t,this.on(e,a,n)},emit:function(e){for(var t=[].slice.call(arguments,1),n=((this.e||(this.e={}))[e]||[]).slice(),r=0,a=n.length;r{const n=u.get(t);return!n.isAny&&n.test(e)}));return t.length?t:["any"]}function g(e){return e&&"function"==typeof e&&"_typedFunctionData"in e}function y(e,t,n){if(!g(e))throw new TypeError(r);const a=n&&n.exact,i=w(Array.isArray(t)?t.join(","):t),s=b(i);if(!a||s in e.signatures){const t=e._typedFunctionData.signatureMap.get(s);if(t)return t}const o=i.length;let u,l;if(a){let t;for(t in u=[],e.signatures)u.push(e._typedFunctionData.signatureMap.get(t))}else u=e._typedFunctionData.signatures;for(var c=0;c!t.has(e.name))))continue}t.push(n)}}if(u=t,0===u.length)break}for(l of u)if(l.params.length<=o)return l;throw new TypeError("Signature not found (signature: "+(e.name||"unnamed")+"("+b(i,", ")+"))")}function b(e,t=","){return e.map((e=>e.name)).join(t)}function v(e){const t=0===e.indexOf("..."),n=(t?e.length>3?e.slice(3):"any":e).split("|").map((e=>d(e.trim())));let r=!1,a=t?"...":"";return{types:n.map((function(e){return r=e.isAny||r,a+=e.name+"|",{name:e.name,typeIndex:e.index,test:e.test,isAny:e.isAny,conversion:null,conversionIndex:-1}})),name:a.slice(0,-1),hasAny:r,hasConversion:!1,restParam:t}}function x(e){const t=function(e){if(0===e.length)return[];const t=e.map(d);e.length>1&&t.sort(((e,t)=>e.index-t.index));let n=t[0].conversionsTo;if(1===e.length)return n;n=n.concat([]);const r=new Set(e);for(var a=1;ae.name)));let n=e.hasAny,r=e.name;const a=t.map((function(e){const t=d(e.from);return n=t.isAny||n,r+="|"+e.from,{name:e.from,typeIndex:t.index,test:t.test,isAny:t.isAny,conversion:e,conversionIndex:e.index}}));return{types:e.types.concat(a),name:r,hasAny:n,hasConversion:a.length>0,restParam:e.restParam}}function _(e){return e.typeSet||(e.typeSet=new Set,e.types.forEach((t=>e.typeSet.add(t.name)))),e.typeSet}function w(e){const t=[];if("string"!=typeof e)throw new TypeError("Signatures must be strings");const n=e.trim();if(""===n)return t;const r=n.split(",");for(var a=0;a=n+1}}return 0===e.length?function(e){return 0===e.length}:1===e.length?(n=N(e[0]),function(e){return n(e[0])&&1===e.length}):2===e.length?(n=N(e[0]),r=N(e[1]),function(e){return n(e[0])&&r(e[1])&&2===e.length}):(t=e.map(N),function(e){for(var n=0;n{const r=k(e.params,t);let a;for(a of r)n.add(a)})),n.has("any")?["any"]:Array.from(n)}function E(e,t,n){let r,a;const i=e||"unnamed";let s=n;for(var o=0;o{const r=N(S(n.params,o));(o0){const e=m(t[o]);return r=new TypeError("Unexpected type of argument in function "+i+" (expected: "+a.join(" or ")+", actual: "+e.join(" | ")+", index: "+o+")"),r.data={category:"wrongType",fn:i,index:o,actual:e,expected:a},r}}else s=e}const u=s.map((function(e){return D(e.params)?1/0:e.params.length}));if(t.lengthl)return r=new TypeError("Too many arguments in function "+i+" (expected: "+l+", actual: "+t.length+")"),r.data={category:"tooManyArgs",fn:i,index:t.length,expectedLength:l},r;const c=[];for(var p=0;p0)return 1;const r=I(e)-I(t);return r<0?-1:r>0?1:0}function F(e,t){const n=e.params,r=t.params,a=U(n),i=U(r),s=D(n),o=D(r);if(s&&a.hasAny){if(!o||!i.hasAny)return 1}else if(o&&i.hasAny)return-1;let u,l=0,c=0;for(u of n)u.hasAny&&++l,u.hasConversion&&++c;let p=0,d=0;for(u of r)u.hasAny&&++p,u.hasConversion&&++d;if(l!==p)return l-p;if(s&&a.hasConversion){if(!o||!i.hasConversion)return 1}else if(o&&i.hasConversion)return-1;if(c!==d)return c-d;if(s){if(!o)return 1}else if(o)return-1;const h=(n.length-r.length)*(s?-1:1);if(0!==h)return h;const f=[];let m,g=0;for(let e=0;ee.hasConversion))){const r=D(e),a=e.map(O);n=function(){const e=[],n=r?arguments.length-1:arguments.length;for(var i=0;ie.name)).join("|"),hasAny:e.some((e=>e.isAny)),hasConversion:!1,restParam:!0}),o.push(s)}else o=s.types.map((function(e){return{types:[e],name:e.name,hasAny:e.isAny,hasConversion:e.conversion,restParam:!1}}));return a=o,i=function(a){return e(t,n+1,r.concat([a]))},Array.prototype.concat.apply([],a.map(i))}var a,i;return[r]}(e,0,[])}function Y(e,t){const n=Math.max(e.length,t.length);for(var r=0;r=a:o?a>=i:a===i}function B(e,t,n){const r=[];let a;for(a of e){let e=n[a];if("number"!=typeof e)throw new TypeError('No definition for referenced signature "'+a+'"');if(e=t[e],"function"!=typeof e)return!1;r.push(e)}return r}function z(e,t,n){let r=function(e){return e.map((e=>K(e)?V(e.referToSelf.callback):G(e)?W(e.referTo.references,e.referTo.callback):e))}(e),a=!0;for(;a;){a=!1;let e=!0;for(var i=0;i{var r=e[n];if(t.test(r.toString()))throw new SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.")}))}(r);const a=[],i=[],s={},o=[];let u;for(u in r){if(!Object.prototype.hasOwnProperty.call(r,u))continue;const e=w(u);if(!e)continue;a.forEach((function(t){if(Y(t,e))throw new TypeError('Conflicting signatures "'+b(t)+'" and "'+b(e)+'".')})),a.push(e);const t=i.length;i.push(r[u]);const n=e.map(x);let l;for(l of R(n)){const e=b(l);o.push({params:l,name:e,fn:t}),l.every((e=>!e.hasConversion))&&(s[e]=t)}}o.sort(F);const l=z(i,s,ue);let c;for(c in s)Object.prototype.hasOwnProperty.call(s,c)&&(s[c]=l[s[c]]);const d=[],h=new Map;for(c of o)h.has(c.name)||(c.fn=l[c.fn],d.push(c),h.set(c.name,c));const f=d[0]&&d[0].params.length<=2&&!D(d[0].params),m=d[1]&&d[1].params.length<=2&&!D(d[1].params),g=d[2]&&d[2].params.length<=2&&!D(d[2].params),y=d[3]&&d[3].params.length<=2&&!D(d[3].params),v=d[4]&&d[4].params.length<=2&&!D(d[4].params),_=d[5]&&d[5].params.length<=2&&!D(d[5].params),S=f&&m&&g&&y&&v&&_;for(var k=0;ke.test)),se=d.map((e=>e.implementation)),oe=function(){for(var t=re;tb(w(e))));const t=U(arguments);if("function"!=typeof t)throw new TypeError("Callback function expected as last argument");return W(e,t)},p.referToSelf=V,p.convert=function(e,t){const n=d(t);if(n.test(e))return e;const r=n.conversionsTo;if(0===r.length)throw new Error("There are no conversions to "+t+" defined.");for(var a=0;at.from===e.from));if(!n)throw new Error("Attempt to remove nonexistent conversion from "+e.from+" to "+e.to);if(n.convert!==e.convert)throw new Error("Conversion to remove does not match existing conversion");const r=t.conversionsTo.indexOf(n);t.conversionsTo.splice(r,1)},p.resolve=function(e,t){if(!g(e))throw new TypeError(r);const n=e._typedFunctionData.signatures;for(var a=0;a{},8628:()=>{},1601:()=>{},7792:()=>{},4977:()=>{},5042:()=>{}},t={};function n(r){var a=t[r];if(void 0!==a)return a.exports;var i=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}n.amdD=function(){throw new Error("define cannot be used indirect")},n.amdO={},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var r={};(()=>{"use strict";n.r(r),n.d(r,{Tensor:()=>iue,Turtle:()=>Joe,abs:()=>due,acos:()=>Sue,add:()=>oue,asin:()=>kue,atan:()=>Tue,atan2:()=>Cue,average:()=>hle,ceil:()=>hue,compile:()=>Zoe,complex:()=>Lue,concat:()=>Wue,constrain:()=>fue,copy:()=>Fue,cos:()=>Eue,derivative:()=>Qoe,dispose:()=>ile,div:()=>cue,dot:()=>pue,endScope:()=>rle,evaluate:()=>eue,exp:()=>mue,eye:()=>$ue,fft:()=>Que,fill:()=>Oue,flatten:()=>jue,floor:()=>gue,fromImage:()=>ole,getBackend:()=>spe,keep:()=>ale,linspace:()=>Rue,log:()=>yue,math:()=>G,max:()=>bue,mean:()=>dle,memory:()=>ele,min:()=>vue,mod:()=>xue,mult:()=>lue,ones:()=>Yue,pad:()=>Uue,parse:()=>tue,percentile:()=>cle,pow:()=>_ue,ptp:()=>lle,quantile:()=>ple,random:()=>Bue,randomGaussian:()=>zue,range:()=>Pue,reshape:()=>que,reverse:()=>Vue,round:()=>wue,scope:()=>tle,sd:()=>fle,setBackend:()=>ipe,simplify:()=>nue,sin:()=>Aue,slice:()=>Gue,sort:()=>Zue,split:()=>Kue,sq:()=>Due,sqrt:()=>Nue,stack:()=>Jue,startScope:()=>nle,sub:()=>uue,sum:()=>Mue,tan:()=>Iue,tf:()=>W,toDateTime:()=>ape,toImage:()=>ule,unstack:()=>Xue,variance:()=>mle,zeros:()=>Hue});var e={};n.r(e),n.d(e,{arraysEqual:()=>de,assert:()=>se,assertNonNegativeIntegerDimensions:()=>He,assertNonNull:()=>ue,assertShapesMatch:()=>oe,bytesFromStringArray:()=>Ce,bytesPerElement:()=>Te,checkConversionForErrors:()=>Ne,clamp:()=>ee,computeStrides:()=>Oe,createScalarValue:()=>Ra,createShuffledIndices:()=>ge,decodeString:()=>Ha,distSquared:()=>ie,encodeString:()=>Pa,fetch:()=>za,fingerPrint64:()=>Oa,flatten:()=>le,getArrayFromDType:()=>De,getTypedArrayFromDType:()=>we,hasEncodingLoss:()=>Se,hexToLong:()=>Ma,indexToLoc:()=>Ue,inferDtype:()=>Le,inferFromImplicitShape:()=>ve,isBoolean:()=>Ae,isFunction:()=>Fe,isInt:()=>he,isNumber:()=>Ie,isPromise:()=>qe,isScalarShape:()=>pe,isString:()=>Ee,isTypedArray:()=>ke,isValidDtype:()=>Me,locToIndex:()=>je,makeOnesTypedArray:()=>Be,makeZerosNestedTypedArray:()=>Pe,makeZerosTypedArray:()=>ze,nearestDivisor:()=>$e,nearestLargerEven:()=>te,now:()=>Ba,parseAxisParam:()=>xe,randUniform:()=>ae,repeatedTry:()=>be,rightPad:()=>ye,shuffle:()=>Z,shuffleCombo:()=>Q,sizeFromShape:()=>ce,sizeToSquarishShape:()=>me,squeezeShape:()=>_e,sum:()=>re,swap:()=>ne,tanh:()=>fe,toNestedArray:()=>Ye,toTypedArray:()=>Ya});var t={};n.r(t),n.d(t,{assertTypesMatch:()=>hi,getTensorsInContainer:()=>mi,isTensorInList:()=>fi,makeTypesMatch:()=>di});var a={};n.r(a),n.d(a,{isBrowser:()=>Si,isMobile:()=>Mi,mockIsMobile:()=>Ni});var i={};n.r(i),n.d(i,{browserFiles:()=>Bs,browserHTTPRequest:()=>Gs,concatenateArrayBuffers:()=>Ui,copyModel:()=>Ts,decodeWeights:()=>zi,encodeWeights:()=>Bi,fromMemory:()=>Zs,fromMemorySync:()=>Qs,getLoadHandlers:()=>es,getModelArtifactsForJSON:()=>Vi,getModelArtifactsInfoForJSON:()=>Gi,getSaveHandlers:()=>Qi,http:()=>Vs,isHTTPScheme:()=>qs,listModels:()=>Ss,loadWeights:()=>Hs,moveModel:()=>Cs,registerLoadRouter:()=>Zi,registerSaveRouter:()=>Xi,removeModel:()=>ks,weightsLoaderFactory:()=>js,withSaveHandler:()=>eo,withSaveHandlerSync:()=>to});var s={};n.r(s),n.d(s,{confusionMatrix:()=>Eo});var o={};n.r(o),n.d(o,{assertAndGetBroadcastShape:()=>Lo,getBroadcastDims:()=>Ao,getReductionAxes:()=>Io});var u={};n.r(u),n.d(u,{fromPixels:()=>Bo,fromPixelsAsync:()=>Ro,toPixels:()=>Yo});var l={};n.r(l),n.d(l,{prepareAndValidate:()=>zo});var c={};n.r(c),n.d(c,{calculateShapes:()=>jo,validateInput:()=>Ho,validateUpdateShape:()=>Po});var p={};n.r(p),n.d(p,{assertParamsValid:()=>Uo,computeFlatOffset:()=>ru,computeOutShape:()=>Wo,getNormalizedAxes:()=>Jo,isSliceContinous:()=>nu,maskToAxes:()=>qo,parseSliceParams:()=>au,sliceInfo:()=>iu,startForAxis:()=>eu,startIndicesWithElidedDims:()=>Xo,stopForAxis:()=>tu,stopIndicesWithElidedDims:()=>Zo,stridesForAxis:()=>Qo,stridesWithElidedDims:()=>Vo});var d={};n.r(d),n.d(d,{Serializable:()=>ou,SerializationMap:()=>uu,registerClass:()=>lu});var h={};n.r(h),n.d(h,{TEST_EPSILON_FLOAT16:()=>cu,encodeStrings:()=>xu,expectArrayBuffersEqual:()=>vu,expectArraysClose:()=>pu,expectArraysEqual:()=>mu,expectNumbersClose:()=>gu,expectPromiseToFail:()=>fu,expectValuesInRange:()=>bu,testEpsilon:()=>du});var f={};n.r(f),n.d(f,{conv2d:()=>qd,depthwiseConv2d:()=>Gd,matMul:()=>Kd});var m={};n.r(m),n.d(m,{collectGatherOpShapeInfo:()=>Vf,computeOutShape:()=>Wf,segOpComputeOptimalWindowSize:()=>qf});var g={};n.r(g),n.d(g,{ERF_A1:()=>df,ERF_A2:()=>hf,ERF_A3:()=>ff,ERF_A4:()=>mf,ERF_A5:()=>gf,ERF_P:()=>pf,PARALLELIZE_THRESHOLD:()=>ef,SELU_SCALE:()=>cf,SELU_SCALEALPHA:()=>lf,applyActivation:()=>jd,assertAndGetBroadcastShape:()=>Lo,assertAxesAreInnerMostDims:()=>bc,assertParamsConsistent:()=>Zh,assignToTypedArray:()=>wf,axesAreInnerMostDims:()=>fc,calculateShapes:()=>jo,checkEinsumDimSizes:()=>Tf,checkPadOnDimRoundingMode:()=>wl,combineLocations:()=>mc,complexWithEvenIndex:()=>vf,complexWithOddIndex:()=>xf,computeConv2DInfo:()=>dl,computeConv3DInfo:()=>hl,computeDefaultPad:()=>fl,computeDilation2DInfo:()=>ll,computeOptimalWindowSize:()=>tf,computeOutAndReduceShapes:()=>gc,computeOutShape:()=>Qh,computePool2DInfo:()=>cl,computePool3DInfo:()=>pl,convertConv2DDataFormat:()=>_l,decodeEinsumEquation:()=>Sf,eitherStridesOrDilationsAreOne:()=>xl,expandShapeToKeepDim:()=>yc,exponent:()=>Nf,exponents:()=>Df,fromStringArrayToUint8:()=>Kf,fromUint8ToStringArray:()=>Gf,getAxesPermutation:()=>vc,getBroadcastDims:()=>Ao,getComplexWithIndex:()=>_f,getEinsumComputePath:()=>Cf,getEinsumPermutation:()=>kf,getFusedBiasGradient:()=>Hd,getFusedDyActivation:()=>Pd,getImageCenter:()=>nf,getInnerMostAxes:()=>_c,getPermuted:()=>af,getReductionAxes:()=>Io,getReshaped:()=>rf,getReshapedPermuted:()=>sf,getSliceBeginCoords:()=>of,getSliceSize:()=>uf,getSparseFillEmptyRowsIndicesDenseShapeMismatch:()=>Lf,getSparseFillEmptyRowsNegativeIndexErrorMessage:()=>Ff,getSparseFillEmptyRowsOutOfRangeIndexErrorMessage:()=>$f,getSparseReshapeEmptyTensorZeroOutputDimErrorMessage:()=>Yf,getSparseReshapeInputOutputMismatchErrorMessage:()=>zf,getSparseReshapeInputOutputMultipleErrorMessage:()=>Bf,getSparseReshapeMultipleNegativeOneOutputDimErrorMessage:()=>Of,getSparseReshapeNegativeOutputDimErrorMessage:()=>Rf,getSparseSegmentReductionIndicesOutOfRangeErrorMessage:()=>Uf,getSparseSegmentReductionNegativeSegmentIdsErrorMessage:()=>Pf,getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage:()=>Hf,getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage:()=>jf,getUndoAxesPermutation:()=>xc,isIdentityPermutation:()=>Ef,log:()=>pa,mergeRealAndImagArrays:()=>yf,prepareAndValidate:()=>zo,prepareSplitSize:()=>If,segment_util:()=>m,shouldFuse:()=>Ud,slice_util:()=>p,splitRealAndImagArrays:()=>bf,tupleValuesAreOne:()=>vl,upcastType:()=>ci,validateInput:()=>Ho,validateUpdateShape:()=>Po,warn:()=>ca});var y={};n.r(y),n.d(y,{nonMaxSuppressionV3Impl:()=>uh,nonMaxSuppressionV4Impl:()=>lh,nonMaxSuppressionV5Impl:()=>ch,whereImpl:()=>Cd});var b={};n.r(b),n.d(b,{maxNorm:()=>Fb,minMaxNorm:()=>Rb,nonNeg:()=>Ob,unitNorm:()=>$b});var v={};n.r(v),n.d(v,{constant:()=>zb,glorotNormal:()=>Vb,glorotUniform:()=>Wb,heNormal:()=>Gb,heUniform:()=>Kb,identity:()=>Ub,leCunNormal:()=>Jb,leCunUniform:()=>Xb,ones:()=>Bb,orthogonal:()=>Zb,randomNormal:()=>Hb,randomUniform:()=>Pb,truncatedNormal:()=>jb,varianceScaling:()=>qb,zeros:()=>Yb});var x={};n.r(x),n.d(x,{Layer:()=>hb,RNN:()=>c_,RNNCell:()=>p_,activation:()=>Aw,add:()=>zw,alphaDropout:()=>ED,average:()=>Pw,averagePooling1d:()=>Jw,averagePooling2d:()=>Qw,averagePooling3d:()=>nD,avgPool1d:()=>Xw,avgPool2d:()=>eD,avgPool3d:()=>rD,avgPooling1d:()=>Zw,avgPooling2d:()=>tD,avgPooling3d:()=>aD,batchNormalization:()=>Vw,bidirectional:()=>wD,concatenate:()=>Hw,conv1d:()=>ww,conv2d:()=>Dw,conv2dTranspose:()=>Nw,conv3d:()=>Mw,conv3dTranspose:()=>Sw,convLstm2d:()=>bD,convLstm2dCell:()=>vD,cropping2D:()=>Tw,dense:()=>Iw,depthwiseConv2d:()=>Ew,dot:()=>Ww,dropout:()=>Lw,elu:()=>gw,embedding:()=>Bw,flatten:()=>$w,gaussianDropout:()=>CD,gaussianNoise:()=>TD,globalAveragePooling1d:()=>iD,globalAveragePooling2d:()=>sD,globalMaxPool1d:()=>ND,globalMaxPool2d:()=>MD,globalMaxPooling1d:()=>oD,globalMaxPooling2d:()=>uD,gru:()=>dD,gruCell:()=>hD,input:()=>px,inputLayer:()=>mw,layerNormalization:()=>Gw,leakyReLU:()=>bw,lstm:()=>fD,lstmCell:()=>mD,masking:()=>AD,maxPool1d:()=>SD,maxPool2d:()=>kD,maxPooling1d:()=>lD,maxPooling2d:()=>cD,maxPooling3d:()=>pD,maximum:()=>jw,minimum:()=>Uw,multiply:()=>qw,permute:()=>Yw,prelu:()=>vw,reLU:()=>yw,repeatVector:()=>Ow,reshape:()=>Rw,rnn:()=>xD,separableConv2d:()=>kw,simpleRNN:()=>gD,simpleRNNCell:()=>yD,softmax:()=>xw,spatialDropout1d:()=>Fw,stackedRNNCells:()=>_D,thresholdedReLU:()=>_w,timeDistributed:()=>DD,upSampling2d:()=>Cw,zeroPadding2d:()=>Kw});var _={};n.r(_),n.d(_,{MAPE:()=>HD,MSE:()=>qD,binaryAccuracy:()=>ID,binaryCrossentropy:()=>LD,categoricalAccuracy:()=>$D,categoricalCrossentropy:()=>OD,cosineProximity:()=>BD,mape:()=>jD,meanAbsoluteError:()=>zD,meanAbsolutePercentageError:()=>PD,meanSquaredError:()=>UD,mse:()=>WD,precision:()=>RD,recall:()=>YD,sparseCategoricalAccuracy:()=>FD});var w={};n.r(w),n.d(w,{modelFromJSON:()=>sx});var D={};n.r(D),n.d(D,{l1:()=>GD,l1l2:()=>VD,l2:()=>KD});var N={};n.r(N),n.d(N,{json:()=>fN});var M={};n.r(M),n.d(M,{json:()=>mN});var S={};n.r(S),n.d(S,{json:()=>gN});var k={};n.r(k),n.d(k,{json:()=>yN});var T={};n.r(T),n.d(T,{json:()=>bN});var C={};n.r(C),n.d(C,{json:()=>vN});var E={};n.r(E),n.d(E,{json:()=>xN});var A={};n.r(A),n.d(A,{json:()=>_N});var I={};n.r(I),n.d(I,{json:()=>wN});var L={};n.r(L),n.d(L,{json:()=>DN});var F={};n.r(F),n.d(F,{json:()=>NN});var $={};n.r($),n.d($,{json:()=>MN});var O={};n.r(O),n.d(O,{json:()=>SN});var R={};n.r(R),n.d(R,{json:()=>kN});var Y={};n.r(Y),n.d(Y,{json:()=>TN});var B={};n.r(B),n.d(B,{json:()=>CN});var z={};n.r(z),n.d(z,{json:()=>EN});var P={};n.r(P),n.d(P,{json:()=>AN});var H={};n.r(H),n.d(H,{json:()=>IN});var j={};n.r(j),n.d(j,{OP_SCOPE_SUFFIX:()=>Li,abs:()=>Uu,acos:()=>Xu,acosh:()=>Zu,add:()=>wu,addN:()=>Qu,all:()=>el,any:()=>tl,argMax:()=>nl,argMin:()=>rl,asin:()=>al,asinh:()=>il,atan:()=>sl,atan2:()=>ol,atanh:()=>ul,avgPool:()=>Nl,avgPool3d:()=>Ml,basicLSTMCell:()=>El,batchNorm:()=>Il,batchNorm2d:()=>Ll,batchNorm3d:()=>Fl,batchNorm4d:()=>$l,batchToSpaceND:()=>Al,bincount:()=>Ol,booleanMaskAsync:()=>Ad,broadcastArgs:()=>Rl,broadcastTo:()=>Yl,buffer:()=>Is,cast:()=>Ls,ceil:()=>Bl,clipByValue:()=>zl,clone:()=>Fs,complex:()=>$i,concat:()=>Sl,concat1d:()=>Pl,concat2d:()=>Hl,concat3d:()=>jl,concat4d:()=>Ul,conv1d:()=>Wl,conv2d:()=>ql,conv2dTranspose:()=>Gl,conv3d:()=>Kl,conv3dTranspose:()=>Xl,cos:()=>Zl,cosh:()=>Ql,cosineWindow:()=>Yd,cumprod:()=>ec,cumsum:()=>tc,denseBincount:()=>nc,depthToSpace:()=>rc,depthwiseConv2d:()=>ac,diag:()=>ic,dilation2d:()=>sc,div:()=>Nu,divNoNan:()=>lc,dot:()=>cc,dropout:()=>Od,einsum:()=>pc,elu:()=>dc,enclosingPowerOfTwo:()=>Rd,equal:()=>oc,erf:()=>hc,euclideanNorm:()=>kc,exp:()=>Tc,expandDims:()=>Cc,expm1:()=>Ec,eye:()=>Ic,fft:()=>sd,fill:()=>Bu,floor:()=>Lc,floorDiv:()=>Du,fused:()=>f,gather:()=>Fc,gatherND:()=>$d,greater:()=>$c,greaterEqual:()=>Oc,ifft:()=>od,imag:()=>So,image:()=>Uh,inTopKAsync:()=>Bd,irfft:()=>ud,isFinite:()=>Rc,isInf:()=>Yc,isNaN:()=>Bc,leakyRelu:()=>zc,less:()=>Pc,lessEqual:()=>Hc,linalg:()=>qh,linspace:()=>jc,localResponseNormalization:()=>Uc,log:()=>qc,log1p:()=>Wc,logSigmoid:()=>Gc,logSoftmax:()=>Kc,logSumExp:()=>Jc,logicalAnd:()=>Xc,logicalNot:()=>Zc,logicalOr:()=>Qc,logicalXor:()=>ep,losses:()=>Wh,lowerBound:()=>rp,matMul:()=>no,max:()=>wc,maxPool:()=>ap,maxPool3d:()=>ip,maxPoolWithArgmax:()=>sp,maximum:()=>qu,mean:()=>op,meshgrid:()=>cp,min:()=>Dc,minimum:()=>pp,mirrorPad:()=>dp,mod:()=>hp,moments:()=>fp,movingAverage:()=>Id,mul:()=>Mu,multiRNNCell:()=>mp,multinomial:()=>gp,neg:()=>ko,norm:()=>Sc,notEqual:()=>yp,oneHot:()=>ro,ones:()=>lp,onesLike:()=>bp,op:()=>Fi,outerProduct:()=>vp,pad:()=>xp,pad1d:()=>_p,pad2d:()=>wp,pad3d:()=>Dp,pad4d:()=>Np,pool:()=>Sp,pow:()=>Pu,prelu:()=>kp,print:()=>$s,prod:()=>Tp,rand:()=>Cp,randomGamma:()=>Fp,randomNormal:()=>$p,randomStandardNormal:()=>Op,randomUniform:()=>Rp,range:()=>Yp,real:()=>To,reciprocal:()=>Bp,relu:()=>zp,relu6:()=>Pp,reshape:()=>Dl,reverse:()=>Hp,reverse1d:()=>jp,reverse2d:()=>Up,reverse3d:()=>qp,reverse4d:()=>Wp,rfft:()=>cd,round:()=>Vp,rsqrt:()=>Gp,scalar:()=>Ou,scatterND:()=>Ld,searchSorted:()=>np,selu:()=>Kp,separableConv2d:()=>Jp,setdiff1dAsync:()=>Xp,sigmoid:()=>kl,sign:()=>Zp,signal:()=>jh,sin:()=>Qp,sinh:()=>ed,slice:()=>Tl,slice1d:()=>td,slice2d:()=>nd,slice3d:()=>rd,slice4d:()=>ad,softmax:()=>id,softplus:()=>Vc,spaceToBatchND:()=>Mp,sparse:()=>Vh,sparseToDense:()=>Fd,spectral:()=>Hh,split:()=>ld,sqrt:()=>Su,square:()=>ku,squaredDifference:()=>pd,squeeze:()=>dd,stack:()=>hd,step:()=>fd,stridedSlice:()=>md,string:()=>Gh,sub:()=>Hu,sum:()=>Nc,tan:()=>gd,tanh:()=>Cl,tensor:()=>Ri,tensor1d:()=>yd,tensor2d:()=>bd,tensor3d:()=>Fo,tensor4d:()=>vd,tensor5d:()=>xd,tensor6d:()=>_d,tile:()=>Ac,topk:()=>wd,transpose:()=>Co,truncatedNormal:()=>Dd,unique:()=>Nd,unsortedSegmentSum:()=>Md,unstack:()=>Sd,upperBound:()=>kd,variable:()=>Td,where:()=>uc,whereAsync:()=>Ed,zeros:()=>up,zerosLike:()=>Tu});var U={};n.r(U),n.d(U,{CSVDataset:()=>sS,Dataset:()=>GM,FileDataSource:()=>bS,TextLineDataset:()=>QM,URLDataSource:()=>vS,array:()=>JM,csv:()=>xS,func:()=>_S,generator:()=>wS,microphone:()=>NS,version_data:()=>MS,webcam:()=>DS,zip:()=>XM});var q={};n.r(q),n.d(q,{addImpl:()=>ik,bincountImpl:()=>Xk,bincountReduceImpl:()=>Zk,ceilImpl:()=>tT,concatImpl:()=>oT,equalImpl:()=>UT,expImpl:()=>tC,expm1Impl:()=>sC,floorImpl:()=>DC,gatherNdImpl:()=>AC,gatherV2Impl:()=>LC,greaterEqualImpl:()=>YC,greaterImpl:()=>$C,lessEqualImpl:()=>XC,lessImpl:()=>GC,linSpaceImpl:()=>eE,logImpl:()=>nE,maxImpl:()=>yE,maximumImpl:()=>xE,minimumImpl:()=>EE,multiplyImpl:()=>OT,negImpl:()=>zE,notEqualImpl:()=>GE,prodImpl:()=>oA,rangeImpl:()=>lA,rsqrtImpl:()=>_A,scatterImpl:()=>NA,sigmoidImpl:()=>WS,simpleAbsImpl:()=>fk,sliceImpl:()=>Vk,sparseFillEmptyRowsImpl:()=>UA,sparseReshapeImpl:()=>WA,sparseSegmentReductionImpl:()=>GA,sqrtImpl:()=>QA,squaredDifferenceImpl:()=>rI,stridedSliceImpl:()=>uI,stringNGramsImpl:()=>pI,stringSplitImpl:()=>fI,stringToHashBucketFastImpl:()=>gI,subImpl:()=>dC,tileImpl:()=>_I,topKImpl:()=>MI,transposeImpl:()=>_k,uniqueImpl:()=>II});var W={};n.r(W),n.d(W,{Abs:()=>Qe,Acos:()=>et,Acosh:()=>tt,AdadeltaOptimizer:()=>Yu,AdagradOptimizer:()=>zu,AdamOptimizer:()=>ju,AdamaxOptimizer:()=>Wu,Add:()=>nt,AddN:()=>rt,All:()=>at,Any:()=>it,ArgMax:()=>st,ArgMin:()=>ot,Asin:()=>ut,Asinh:()=>lt,Atan:()=>ct,Atan2:()=>dt,Atanh:()=>pt,AvgPool:()=>ht,AvgPool3D:()=>mt,AvgPool3DGrad:()=>gt,AvgPoolGrad:()=>ft,BatchMatMul:()=>yt,BatchToSpaceND:()=>bt,Bincount:()=>vt,BroadcastArgs:()=>_t,BroadcastTo:()=>xt,Callback:()=>JD,CallbackList:()=>rv,Cast:()=>wt,Ceil:()=>Dt,ClipByValue:()=>Nt,Complex:()=>Mt,ComplexAbs:()=>St,Concat:()=>kt,Conv2D:()=>Tt,Conv2DBackpropFilter:()=>Ct,Conv2DBackpropInput:()=>Et,Conv3D:()=>At,Conv3DBackpropFilterV2:()=>It,Conv3DBackpropInputV2:()=>Lt,Cos:()=>Ft,Cosh:()=>$t,CropAndResize:()=>Yt,Cumprod:()=>Ot,Cumsum:()=>Rt,CustomCallback:()=>sv,DataStorage:()=>K,DenseBincount:()=>Bt,DepthToSpace:()=>zt,DepthwiseConv2dNative:()=>Pt,DepthwiseConv2dNativeBackpropFilter:()=>Ht,DepthwiseConv2dNativeBackpropInput:()=>jt,Diag:()=>Ut,Dilation2D:()=>qt,Dilation2DBackpropFilter:()=>Vt,Dilation2DBackpropInput:()=>Wt,ENV:()=>Je,EarlyStopping:()=>QD,Einsum:()=>Kt,Elu:()=>Jt,EluGrad:()=>Xt,Environment:()=>We,Equal:()=>Qt,Erf:()=>Zt,Exp:()=>en,ExpandDims:()=>tn,Expm1:()=>nn,FFT:()=>rn,Fill:()=>an,FlipLeftRight:()=>sn,Floor:()=>on,FloorDiv:()=>un,FromPixels:()=>ia,FusedBatchNorm:()=>ln,FusedConv2D:()=>ua,FusedDepthwiseConv2D:()=>la,GatherNd:()=>pn,GatherV2:()=>cn,GraphModel:()=>mM,Greater:()=>dn,GreaterEqual:()=>hn,History:()=>iv,IFFT:()=>mn,Identity:()=>fn,Imag:()=>gn,InputSpec:()=>ub,IsFinite:()=>yn,IsInf:()=>bn,IsNan:()=>vn,KernelBackend:()=>J,LRN:()=>In,LRNGrad:()=>Ln,LayerVariable:()=>ib,LayersModel:()=>ax,LeakyRelu:()=>xn,Less:()=>_n,LessEqual:()=>wn,LinSpace:()=>Dn,Log:()=>Nn,Log1p:()=>Mn,LogSoftmax:()=>En,LogicalAnd:()=>Sn,LogicalNot:()=>kn,LogicalOr:()=>Tn,LogicalXor:()=>Cn,LowerBound:()=>An,Max:()=>Fn,MaxPool:()=>On,MaxPool3D:()=>Yn,MaxPool3DGrad:()=>Bn,MaxPoolGrad:()=>Rn,MaxPoolWithArgmax:()=>zn,Maximum:()=>$n,Mean:()=>Pn,Min:()=>Hn,Minimum:()=>jn,MirrorPad:()=>Un,Mod:()=>qn,MomentumOptimizer:()=>Gu,Multinomial:()=>Wn,Multiply:()=>Vn,Neg:()=>Gn,NonMaxSuppressionV3:()=>Jn,NonMaxSuppressionV4:()=>Xn,NonMaxSuppressionV5:()=>Zn,NotEqual:()=>Kn,OP_SCOPE_SUFFIX:()=>Li,OneHot:()=>er,OnesLike:()=>Qn,Optimizer:()=>Ru,OptimizerConstructors:()=>Ju,Pack:()=>tr,PadV2:()=>nr,Pool:()=>rr,Pow:()=>ar,Prelu:()=>ir,Prod:()=>sr,RMSPropOptimizer:()=>Ku,RNN:()=>c_,Range:()=>or,Rank:()=>ai,Real:()=>ur,RealDiv:()=>Gt,Reciprocal:()=>lr,Reduction:()=>Mh,Relu:()=>cr,Relu6:()=>gr,Reshape:()=>pr,ResizeBilinear:()=>fr,ResizeBilinearGrad:()=>mr,ResizeNearestNeighbor:()=>dr,ResizeNearestNeighborGrad:()=>hr,Reverse:()=>yr,RotateWithOffset:()=>sa,Round:()=>br,Rsqrt:()=>vr,SGDOptimizer:()=>Vu,ScatterNd:()=>xr,SearchSorted:()=>_r,Select:()=>wr,Selu:()=>Dr,Sequential:()=>ox,Sigmoid:()=>Tr,Sign:()=>kr,Sin:()=>Mr,Sinh:()=>Sr,Slice:()=>Nr,Softmax:()=>Fr,Softplus:()=>Cr,SpaceToBatchND:()=>Ir,SparseFillEmptyRows:()=>$r,SparseReshape:()=>Or,SparseSegmentMean:()=>Rr,SparseSegmentSum:()=>Yr,SparseToDense:()=>Br,SplitV:()=>Lr,Sqrt:()=>Er,Square:()=>Pr,SquaredDifference:()=>zr,Step:()=>aa,StridedSlice:()=>Hr,StringNGrams:()=>jr,StringSplit:()=>Ur,StringToHashBucketFast:()=>qr,Sub:()=>Wr,Sum:()=>Ar,SymbolicTensor:()=>lb,Tan:()=>Vr,Tanh:()=>Gr,Tensor:()=>ti,TensorBuffer:()=>Xa,Tile:()=>Kr,TopK:()=>Jr,Transform:()=>Xr,Transpose:()=>Zr,Unique:()=>Qr,Unpack:()=>ea,UnsortedSegmentSum:()=>ta,UpperBound:()=>na,Variable:()=>ri,ZerosLike:()=>ra,_FusedMatMul:()=>oa,abs:()=>Uu,acos:()=>Xu,acosh:()=>Zu,add:()=>wu,addN:()=>Qu,all:()=>el,any:()=>tl,argMax:()=>nl,argMin:()=>rl,asin:()=>al,asinh:()=>il,atan:()=>sl,atan2:()=>ol,atanh:()=>ul,avgPool:()=>Nl,avgPool3d:()=>Ml,backend:()=>No,backend_util:()=>g,basicLSTMCell:()=>El,batchNorm:()=>Il,batchNorm2d:()=>Ll,batchNorm3d:()=>Fl,batchNorm4d:()=>$l,batchToSpaceND:()=>Al,bincount:()=>Ol,booleanMaskAsync:()=>Ad,broadcastArgs:()=>Rl,broadcastTo:()=>Yl,broadcast_util:()=>o,browser:()=>u,buffer:()=>Is,callbacks:()=>eN,cast:()=>Ls,ceil:()=>Bl,clipByValue:()=>zl,clone:()=>Fs,complex:()=>$i,concat:()=>Sl,concat1d:()=>Pl,concat2d:()=>Hl,concat3d:()=>jl,concat4d:()=>Ul,constraints:()=>b,conv1d:()=>Wl,conv2d:()=>ql,conv2dTranspose:()=>Gl,conv3d:()=>Kl,conv3dTranspose:()=>Xl,copyRegisteredKernels:()=>_a,cos:()=>Zl,cosh:()=>Ql,cosineWindow:()=>Yd,cumprod:()=>ec,cumsum:()=>tc,customGrad:()=>Fu,data:()=>U,denseBincount:()=>nc,deprecationWarn:()=>oo,depthToSpace:()=>rc,depthwiseConv2d:()=>ac,deregisterOp:()=>sN,device_util:()=>a,diag:()=>ic,dilation2d:()=>sc,disableDeprecationWarnings:()=>so,dispose:()=>fo,disposeVariables:()=>uo,div:()=>Nu,divNoNan:()=>lc,dot:()=>cc,dropout:()=>Od,einsum:()=>pc,elu:()=>dc,enableDebugMode:()=>io,enableProdMode:()=>ao,enclosingPowerOfTwo:()=>Rd,engine:()=>lo,env:()=>Ge,equal:()=>oc,erf:()=>hc,euclideanNorm:()=>kc,exp:()=>Tc,expandDims:()=>Cc,expm1:()=>Ec,eye:()=>Ic,fft:()=>sd,fill:()=>Bu,findBackend:()=>_o,findBackendFactory:()=>wo,floor:()=>Lc,floorDiv:()=>Du,fused:()=>f,gather:()=>Fc,gatherND:()=>$d,gather_util:()=>l,getBackend:()=>vo,getGradient:()=>ma,getKernel:()=>fa,getKernelsForBackend:()=>ga,grad:()=>Cu,grads:()=>Eu,greater:()=>$c,greaterEqual:()=>Oc,ifft:()=>od,imag:()=>So,image:()=>Uh,inTopKAsync:()=>Bd,initializers:()=>v,input:()=>px,io:()=>i,irfft:()=>ud,isFinite:()=>Rc,isInf:()=>Yc,isNaN:()=>Bc,keep:()=>mo,kernel_impls:()=>y,layers:()=>x,leakyRelu:()=>zc,less:()=>Pc,lessEqual:()=>Hc,linalg:()=>qh,linspace:()=>jc,loadGraphModel:()=>gM,loadGraphModelSync:()=>yM,loadLayersModel:()=>cx,localResponseNormalization:()=>Uc,log:()=>qc,log1p:()=>Wc,logSigmoid:()=>Gc,logSoftmax:()=>Kc,logSumExp:()=>Jc,logicalAnd:()=>Xc,logicalNot:()=>Zc,logicalOr:()=>Qc,logicalXor:()=>ep,losses:()=>Wh,lowerBound:()=>rp,matMul:()=>no,math:()=>s,max:()=>wc,maxPool:()=>ap,maxPool3d:()=>ip,maxPoolWithArgmax:()=>sp,maximum:()=>qu,mean:()=>op,memory:()=>co,meshgrid:()=>cp,metrics:()=>_,min:()=>Dc,minimum:()=>pp,mirrorPad:()=>dp,mod:()=>hp,model:()=>ux,models:()=>w,moments:()=>fp,movingAverage:()=>Id,mul:()=>Mu,multiRNNCell:()=>mp,multinomial:()=>gp,neg:()=>ko,nextFrame:()=>Xh,norm:()=>Sc,notEqual:()=>yp,oneHot:()=>ro,ones:()=>lp,onesLike:()=>bp,op:()=>Fi,outerProduct:()=>vp,pad:()=>xp,pad1d:()=>_p,pad2d:()=>wp,pad3d:()=>Dp,pad4d:()=>Np,pool:()=>Sp,pow:()=>Pu,prelu:()=>kp,print:()=>$s,prod:()=>Tp,profile:()=>po,rand:()=>Cp,randomGamma:()=>Fp,randomNormal:()=>$p,randomStandardNormal:()=>Op,randomUniform:()=>Rp,range:()=>Yp,ready:()=>bo,real:()=>To,reciprocal:()=>Bp,registerBackend:()=>Do,registerCallbackConstructor:()=>dx,registerGradient:()=>ba,registerKernel:()=>ya,registerOp:()=>aN,regularizers:()=>D,relu:()=>zp,relu6:()=>Pp,removeBackend:()=>xo,reshape:()=>Dl,reverse:()=>Hp,reverse1d:()=>jp,reverse2d:()=>Up,reverse3d:()=>qp,reverse4d:()=>Wp,rfft:()=>cd,round:()=>Vp,rsqrt:()=>Gp,scalar:()=>Ou,scatterND:()=>Ld,scatter_util:()=>c,searchSorted:()=>np,selu:()=>Kp,separableConv2d:()=>Jp,sequential:()=>lx,serialization:()=>d,setBackend:()=>yo,setPlatform:()=>Mo,setdiff1dAsync:()=>Xp,sigmoid:()=>kl,sign:()=>Zp,signal:()=>jh,sin:()=>Qp,sinh:()=>ed,slice:()=>Tl,slice1d:()=>td,slice2d:()=>nd,slice3d:()=>rd,slice4d:()=>ad,slice_util:()=>p,softmax:()=>id,softplus:()=>Vc,spaceToBatchND:()=>Mp,sparse:()=>Vh,sparseToDense:()=>Fd,spectral:()=>Hh,split:()=>ld,sqrt:()=>Su,square:()=>ku,squaredDifference:()=>pd,squeeze:()=>dd,stack:()=>hd,step:()=>fd,stridedSlice:()=>md,string:()=>Gh,sub:()=>Hu,sum:()=>Nc,sumOutType:()=>pi,tan:()=>gd,tanh:()=>Cl,tensor:()=>Ri,tensor1d:()=>yd,tensor2d:()=>bd,tensor3d:()=>Fo,tensor4d:()=>vd,tensor5d:()=>xd,tensor6d:()=>_d,tensor_util:()=>t,test_util:()=>h,tidy:()=>ho,tile:()=>Ac,time:()=>go,topk:()=>wd,train:()=>Kh,transpose:()=>Co,truncatedNormal:()=>Dd,unique:()=>Nd,unregisterGradient:()=>xa,unregisterKernel:()=>va,unsortedSegmentSum:()=>Md,unstack:()=>Sd,upcastType:()=>ci,upperBound:()=>kd,util:()=>e,valueAndGrad:()=>Au,valueAndGrads:()=>Iu,variable:()=>Td,variableGrads:()=>Lu,version:()=>FP,version_converter:()=>bM,version_core:()=>_u,version_layers:()=>zv,where:()=>uc,whereAsync:()=>Ed,zeros:()=>up,zerosLike:()=>Tu});var V={};n.r(V),n.d(V,{createAbs:()=>iG,createAccessorNode:()=>I9,createAcos:()=>oG,createAcosh:()=>tX,createAcot:()=>SG,createAcoth:()=>LX,createAcsc:()=>TG,createAcsch:()=>rX,createAdd:()=>i0,createAddScalar:()=>EG,createAnd:()=>$Z,createApply:()=>iX,createApplyTransform:()=>Nee,createArg:()=>AG,createArrayNode:()=>f9,createAsec:()=>uX,createAsech:()=>LG,createAsin:()=>f1,createAsinh:()=>FG,createAssignmentNode:()=>F9,createAtan:()=>$G,createAtan2:()=>u0,createAtanh:()=>RG,createAtomicMass:()=>tW,createAvogadro:()=>nW,createBellNumbers:()=>P2,createBigNumberClass:()=>NU,createBignumber:()=>YG,createBin:()=>lX,createBitAnd:()=>RZ,createBitNot:()=>nK,createBitOr:()=>c0,createBitXor:()=>BZ,createBlockNode:()=>g9,createBohrMagneton:()=>$q,createBohrRadius:()=>Pq,createBoltzmann:()=>rW,createBoolean:()=>aK,createCatalan:()=>d0,createCbrt:()=>PZ,createCeil:()=>b1,createChain:()=>T9,createChainClass:()=>N9,createClassicalElectronRadius:()=>Hq,createClone:()=>sK,createColumn:()=>Q1,createColumnTransform:()=>Ree,createCombinations:()=>cK,createCombinationsWithRep:()=>pX,createCompare:()=>jZ,createCompareNatural:()=>m0,createCompareText:()=>VZ,createCompile:()=>K9,createComplex:()=>dK,createComplexClass:()=>GU,createComposition:()=>x1,createConcat:()=>KZ,createConcatTransform:()=>Cee,createConditionalNode:()=>b9,createConductanceQuantum:()=>Oq,createConj:()=>fK,createConstantNode:()=>x9,createCos:()=>hX,createCosh:()=>gK,createCot:()=>FX,createCoth:()=>bK,createCoulomb:()=>Lq,createCount:()=>ZZ,createCreateUnit:()=>b2,createCross:()=>w1,createCsc:()=>xK,createCsch:()=>mX,createCtranspose:()=>eQ,createCube:()=>wK,createCumSum:()=>y0,createCumSumTransform:()=>$ee,createDeepEqual:()=>v0,createDenseMatrixClass:()=>uV,createDerivative:()=>mee,createDet:()=>D1,createDeuteronMass:()=>Gq,createDiag:()=>nQ,createDiff:()=>_0,createDiffTransform:()=>kee,createDistance:()=>M1,createDivide:()=>k2,createDivideScalar:()=>aQ,createDot:()=>w0,createDotDivide:()=>sQ,createDotMultiply:()=>k1,createDotPow:()=>x2,createE:()=>hq,createEfimovFactor:()=>eW,createEigs:()=>H2,createElectricConstant:()=>Aq,createElectronMass:()=>jq,createElementaryCharge:()=>Fq,createEqual:()=>uQ,createEqualScalar:()=>SK,createEqualText:()=>N0,createErf:()=>kK,createEvaluate:()=>nee,createExp:()=>LK,createExpm:()=>w2,createExpm1:()=>$K,createFactorial:()=>C2,createFalse:()=>oq,createFaraday:()=>aW,createFermiCoupling:()=>Uq,createFft:()=>cQ,createFibonacciHeapClass:()=>T1,createFilter:()=>OK,createFilterTransform:()=>vee,createFineStructure:()=>qq,createFirstRadiation:()=>iW,createFix:()=>I1,createFlatten:()=>dQ,createFloor:()=>T0,createForEach:()=>BK,createForEachTransform:()=>_ee,createFormat:()=>HK,createFraction:()=>$X,createFractionClass:()=>MW,createFunctionAssignmentNode:()=>S9,createFunctionNode:()=>z9,createGamma:()=>N2,createGasConstant:()=>oW,createGcd:()=>fQ,createGetMatrixDataType:()=>UK,createGravitationConstant:()=>kq,createGravity:()=>gW,createHartreeEnergy:()=>Wq,createHasNumericValue:()=>gQ,createHelp:()=>oee,createHelpClass:()=>J9,createHex:()=>qK,createHypot:()=>bQ,createI:()=>_q,createIdentity:()=>E0,createIfft:()=>xQ,createIm:()=>WK,createImmutableDenseMatrixClass:()=>L1,createIndex:()=>t2,createIndexClass:()=>F1,createIndexNode:()=>O9,createIndexTransform:()=>Yee,createInfinity:()=>lq,createIntersect:()=>$1,createInv:()=>n2,createInverseConductanceQuantum:()=>Rq,createInvmod:()=>I0,createIsInteger:()=>GK,createIsNaN:()=>yX,createIsNegative:()=>tJ,createIsNumeric:()=>RX,createIsPositive:()=>rJ,createIsPrime:()=>vX,createIsZero:()=>iJ,createKldivergence:()=>b3,createKlitzing:()=>zq,createKron:()=>wQ,createLN10:()=>gq,createLN2:()=>mq,createLOG10E:()=>bq,createLOG2E:()=>yq,createLarger:()=>F0,createLargerEq:()=>NQ,createLcm:()=>O1,createLeafCount:()=>Z9,createLeftShift:()=>CQ,createLgamma:()=>hJ,createLog:()=>O0,createLog10:()=>mJ,createLog1p:()=>Y1,createLog2:()=>yJ,createLoschmidt:()=>sW,createLsolve:()=>IQ,createLsolveAll:()=>Y0,createLup:()=>E2,createLusolve:()=>Q2,createMad:()=>l3,createMagneticConstant:()=>Eq,createMagneticFluxQuantum:()=>Yq,createMap:()=>bJ,createMapTransform:()=>wee,createMatrix:()=>BX,createMatrixClass:()=>SW,createMatrixFromColumns:()=>FQ,createMatrixFromFunction:()=>PX,createMatrixFromRows:()=>z0,createMax:()=>B1,createMaxTransform:()=>Eee,createMean:()=>U2,createMeanTransform:()=>Bee,createMedian:()=>n3,createMin:()=>$Q,createMinTransform:()=>Aee,createMod:()=>JX,createMode:()=>RQ,createMolarMass:()=>fW,createMolarMassC12:()=>mW,createMolarPlanckConstant:()=>uW,createMolarVolume:()=>lW,createMultinomial:()=>I2,createMultiply:()=>H0,createMultiplyScalar:()=>xJ,createNaN:()=>cq,createNeutronMass:()=>Kq,createNode:()=>q7,createNorm:()=>d3,createNot:()=>SJ,createNthRoot:()=>eZ,createNthRoots:()=>BQ,createNuclearMagneton:()=>Bq,createNull:()=>uq,createNumber:()=>kJ,createNumeric:()=>aZ,createObjectNode:()=>V7,createOct:()=>TJ,createOnes:()=>zQ,createOperatorNode:()=>u9,createOr:()=>iZ,createParenthesisNode:()=>c9,createParse:()=>H9,createParser:()=>cee,createParserClass:()=>uee,createPartitionSelect:()=>HQ,createPermutations:()=>F2,createPhi:()=>fq,createPi:()=>pq,createPickRandom:()=>IJ,createPinv:()=>a2,createPlanckCharge:()=>xW,createPlanckConstant:()=>Tq,createPlanckLength:()=>yW,createPlanckMass:()=>bW,createPlanckTemperature:()=>_W,createPlanckTime:()=>vW,createPow:()=>i2,createPrint:()=>FJ,createProd:()=>uZ,createProtonMass:()=>Vq,createQr:()=>j0,createQuantileSeq:()=>z1,createQuantumOfCirculation:()=>Jq,createRandom:()=>YJ,createRandomInt:()=>_X,createRange:()=>q0,createRangeClass:()=>kW,createRangeNode:()=>w9,createRangeTransform:()=>Iee,createRationalize:()=>yee,createRe:()=>BJ,createReducedPlanckConstant:()=>Cq,createRelationalNode:()=>d9,createReplacer:()=>lV,createReshape:()=>cZ,createResize:()=>UQ,createResolve:()=>j9,createResultSet:()=>TW,createReviver:()=>D9,createRightArithShift:()=>WQ,createRightLogShift:()=>V0,createRotate:()=>_3,createRotationMatrix:()=>m3,createRound:()=>KQ,createRow:()=>P1,createRowTransform:()=>Oee,createRydberg:()=>Xq,createSQRT1_2:()=>vq,createSQRT2:()=>xq,createSackurTetrode:()=>cW,createSec:()=>zJ,createSech:()=>DX,createSecondRadiation:()=>pW,createSetCartesian:()=>j1,createSetDifference:()=>o2,createSetDistinct:()=>q1,createSetIntersect:()=>S2,createSetIsSubset:()=>V1,createSetMultiplicity:()=>l2,createSetPowerset:()=>K1,createSetSize:()=>K0,createSetSymDifference:()=>W2,createSetUnion:()=>i3,createSign:()=>HJ,createSimplify:()=>pee,createSimplifyConstant:()=>V9,createSimplifyCore:()=>eee,createSin:()=>jJ,createSinh:()=>MX,createSize:()=>dZ,createSlu:()=>u1,createSmaller:()=>mZ,createSmallerEq:()=>XQ,createSort:()=>X1,createSpaClass:()=>c2,createSparse:()=>kX,createSparseMatrixClass:()=>UJ,createSpeedOfLight:()=>Sq,createSplitUnit:()=>WJ,createSqrt:()=>TX,createSqrtm:()=>d2,createSquare:()=>GJ,createSqueeze:()=>bZ,createStd:()=>o3,createStdTransform:()=>Hee,createStefanBoltzmann:()=>dW,createStirlingS2:()=>R2,createString:()=>JJ,createSubset:()=>xZ,createSubsetTransform:()=>Tee,createSubtract:()=>kZ,createSum:()=>l1,createSumTransform:()=>Lee,createSymbolNode:()=>R9,createSymbolicEqual:()=>hee,createTan:()=>XJ,createTanh:()=>CX,createTau:()=>dq,createThomsonCrossSection:()=>Zq,createTo:()=>TZ,createTrace:()=>c1,createTranspose:()=>EZ,createTrue:()=>sq,createTypeOf:()=>QJ,createTyped:()=>NV,createUnaryMinus:()=>AX,createUnaryPlus:()=>aG,createUnequal:()=>e0,createUnitClass:()=>g2,createUnitFunction:()=>B2,createUppercaseE:()=>Dq,createUppercasePi:()=>wq,createUsolve:()=>r0,createUsolveAll:()=>d1,createVacuumImpedance:()=>Iq,createVariance:()=>K2,createVarianceTransform:()=>Pee,createVersion:()=>Nq,createWeakMixingAngle:()=>Qq,createWienDisplacement:()=>hW,createXgcd:()=>IZ,createXor:()=>a0,createZeros:()=>FZ});var G={};n.r(G),n.d(G,{AccessorNode:()=>ste,AccessorNodeDependencies:()=>Yte,ArgumentsError:()=>jQ,ArrayNode:()=>Xee,ArrayNodeDependencies:()=>ene,AssignmentNode:()=>ote,AssignmentNodeDependencies:()=>ine,BigNumber:()=>w3,BigNumberDependencies:()=>Ste,BlockNode:()=>Zee,BlockNodeDependencies:()=>Kne,Chain:()=>rte,ChainDependencies:()=>nre,Complex:()=>D3,ComplexDependencies:()=>kte,ConditionalNode:()=>Qee,ConditionalNodeDependencies:()=>bre,ConstantNode:()=>ete,ConstantNodeDependencies:()=>vre,DenseMatrix:()=>j3,DenseMatrixDependencies:()=>Cte,DimensionError:()=>RW,EDependencies:()=>Boe,FibonacciHeap:()=>t6,FibonacciHeapDependencies:()=>jae,Fraction:()=>k3,FractionDependencies:()=>Ete,FunctionAssignmentNode:()=>ate,FunctionAssignmentNodeDependencies:()=>xre,FunctionNode:()=>cte,FunctionNodeDependencies:()=>wre,Help:()=>mte,HelpDependencies:()=>rie,ImmutableDenseMatrix:()=>r6,ImmutableDenseMatrixDependencies:()=>ore,Index:()=>a6,IndexDependencies:()=>ure,IndexError:()=>YW,IndexNode:()=>ute,IndexNodeDependencies:()=>Dre,InfinityDependencies:()=>cie,LN10:()=>E3,LN10Dependencies:()=>Nie,LN2:()=>q3,LN2Dependencies:()=>Mie,LOG10E:()=>A3,LOG10EDependencies:()=>Sie,LOG2E:()=>L4,LOG2EDependencies:()=>kie,Matrix:()=>I3,MatrixDependencies:()=>Tte,NaNDependencies:()=>use,Node:()=>Wee,NodeDependencies:()=>Lte,ObjectNode:()=>Vee,ObjectNodeDependencies:()=>Nre,OperatorNode:()=>Gee,OperatorNodeDependencies:()=>Mre,PIDependencies:()=>zoe,ParenthesisNode:()=>Kee,ParenthesisNodeDependencies:()=>Sre,Parser:()=>xte,ParserDependencies:()=>bse,Range:()=>O3,RangeDependencies:()=>Rse,RangeNode:()=>tte,RangeNodeDependencies:()=>kre,RelationalNode:()=>Jee,RelationalNodeDependencies:()=>Tre,ResultSet:()=>R3,ResultSetDependencies:()=>Gne,SQRT1_2:()=>Y3,SQRT1_2Dependencies:()=>Zse,SQRT2:()=>G3,SQRT2Dependencies:()=>Qse,Spa:()=>D6,SpaDependencies:()=>Yie,SparseMatrix:()=>K4,SparseMatrixDependencies:()=>$te,SymbolNode:()=>lte,SymbolNodeDependencies:()=>_re,Unit:()=>M6,UnitDependencies:()=>Lne,_Infinity:()=>C3,_NaN:()=>L3,_false:()=>M3,_null:()=>F3,_true:()=>P3,abs:()=>Z3,absDependencies:()=>Ite,acos:()=>Q3,acosDependencies:()=>Bte,acosh:()=>t5,acoshDependencies:()=>zte,acot:()=>e4,acotDependencies:()=>Pte,acoth:()=>v5,acothDependencies:()=>Hte,acsc:()=>t4,acscDependencies:()=>jte,acsch:()=>n5,acschDependencies:()=>Ute,add:()=>w8,addDependencies:()=>Wte,addScalar:()=>n4,addScalarDependencies:()=>qte,all:()=>Voe,and:()=>z5,andDependencies:()=>Kte,apply:()=>r5,applyDependencies:()=>Xte,applyTransformDependencies:()=>Zte,arg:()=>r4,argDependencies:()=>Qte,asec:()=>a5,asecDependencies:()=>tne,asech:()=>a4,asechDependencies:()=>nne,asin:()=>G8,asinDependencies:()=>rne,asinh:()=>i4,asinhDependencies:()=>ane,atan:()=>s4,atan2:()=>D8,atan2Dependencies:()=>one,atanDependencies:()=>sne,atanh:()=>o4,atanhDependencies:()=>une,atomicMass:()=>T6,atomicMassDependencies:()=>Fne,avogadro:()=>s7,avogadroDependencies:()=>$ne,bellNumbers:()=>N7,bellNumbersDependencies:()=>Hne,bignumber:()=>u4,bignumberDependencies:()=>lne,bin:()=>i5,binDependencies:()=>jne,bitAnd:()=>P5,bitAndDependencies:()=>Une,bitNot:()=>l4,bitNotDependencies:()=>qne,bitOr:()=>N8,bitOrDependencies:()=>Wne,bitXor:()=>H5,bitXorDependencies:()=>Vne,bohrMagneton:()=>C6,bohrMagnetonDependencies:()=>Jne,bohrRadius:()=>o7,bohrRadiusDependencies:()=>Xne,boltzmann:()=>E6,boltzmannDependencies:()=>Zne,boolean:()=>c4,booleanDependencies:()=>Qne,catalan:()=>M8,catalanDependencies:()=>ere,cbrt:()=>j5,cbrtDependencies:()=>tre,ceil:()=>K8,ceilDependencies:()=>gne,chain:()=>ite,chainDependencies:()=>rre,classicalElectronRadius:()=>I7,classicalElectronRadiusDependencies:()=>are,clone:()=>p4,cloneDependencies:()=>ire,column:()=>g6,columnDependencies:()=>dre,columnTransformDependencies:()=>hre,combinations:()=>d4,combinationsDependencies:()=>Rne,combinationsWithRep:()=>s5,combinationsWithRepDependencies:()=>fre,compare:()=>U5,compareDependencies:()=>mre,compareNatural:()=>S8,compareNaturalDependencies:()=>gre,compareText:()=>q5,compareTextDependencies:()=>yre,compile:()=>fte,compileDependencies:()=>Ere,complex:()=>h4,complexDependencies:()=>Are,composition:()=>J8,compositionDependencies:()=>Lre,concat:()=>W5,concatDependencies:()=>Fre,concatTransformDependencies:()=>$re,conductanceQuantum:()=>A6,conductanceQuantumDependencies:()=>Ore,config:()=>RH,conj:()=>f4,conjDependencies:()=>Nne,cos:()=>o5,cosDependencies:()=>Rre,cosh:()=>m4,coshDependencies:()=>Yre,cot:()=>x5,cotDependencies:()=>Bre,coth:()=>g4,cothDependencies:()=>zre,coulomb:()=>u7,coulombDependencies:()=>Pre,count:()=>V5,countDependencies:()=>jre,create:()=>Koe,createAbs:()=>iG,createAccessorNode:()=>I9,createAcos:()=>oG,createAcosh:()=>tX,createAcot:()=>SG,createAcoth:()=>LX,createAcsc:()=>TG,createAcsch:()=>rX,createAdd:()=>i0,createAddScalar:()=>EG,createAnd:()=>$Z,createApply:()=>iX,createApplyTransform:()=>Nee,createArg:()=>AG,createArrayNode:()=>f9,createAsec:()=>uX,createAsech:()=>LG,createAsin:()=>f1,createAsinh:()=>FG,createAssignmentNode:()=>F9,createAtan:()=>$G,createAtan2:()=>u0,createAtanh:()=>RG,createAtomicMass:()=>tW,createAvogadro:()=>nW,createBellNumbers:()=>P2,createBigNumberClass:()=>NU,createBignumber:()=>YG,createBin:()=>lX,createBitAnd:()=>RZ,createBitNot:()=>nK,createBitOr:()=>c0,createBitXor:()=>BZ,createBlockNode:()=>g9,createBohrMagneton:()=>$q,createBohrRadius:()=>Pq,createBoltzmann:()=>rW,createBoolean:()=>aK,createCatalan:()=>d0,createCbrt:()=>PZ,createCeil:()=>b1,createChain:()=>T9,createChainClass:()=>N9,createClassicalElectronRadius:()=>Hq,createClone:()=>sK,createColumn:()=>Q1,createColumnTransform:()=>Ree,createCombinations:()=>cK,createCombinationsWithRep:()=>pX,createCompare:()=>jZ,createCompareNatural:()=>m0,createCompareText:()=>VZ,createCompile:()=>K9,createComplex:()=>dK,createComplexClass:()=>GU,createComposition:()=>x1,createConcat:()=>KZ,createConcatTransform:()=>Cee,createConditionalNode:()=>b9,createConductanceQuantum:()=>Oq,createConj:()=>fK,createConstantNode:()=>x9,createCos:()=>hX,createCosh:()=>gK,createCot:()=>FX,createCoth:()=>bK,createCoulomb:()=>Lq,createCount:()=>ZZ,createCreateUnit:()=>b2,createCross:()=>w1,createCsc:()=>xK,createCsch:()=>mX,createCtranspose:()=>eQ,createCube:()=>wK,createCumSum:()=>y0,createCumSumTransform:()=>$ee,createDeepEqual:()=>v0,createDenseMatrixClass:()=>uV,createDerivative:()=>mee,createDet:()=>D1,createDeuteronMass:()=>Gq,createDiag:()=>nQ,createDiff:()=>_0,createDiffTransform:()=>kee,createDistance:()=>M1,createDivide:()=>k2,createDivideScalar:()=>aQ,createDot:()=>w0,createDotDivide:()=>sQ,createDotMultiply:()=>k1,createDotPow:()=>x2,createE:()=>hq,createEfimovFactor:()=>eW,createEigs:()=>H2,createElectricConstant:()=>Aq,createElectronMass:()=>jq,createElementaryCharge:()=>Fq,createEqual:()=>uQ,createEqualScalar:()=>SK,createEqualText:()=>N0,createErf:()=>kK,createEvaluate:()=>nee,createExp:()=>LK,createExpm:()=>w2,createExpm1:()=>$K,createFactorial:()=>C2,createFalse:()=>oq,createFaraday:()=>aW,createFermiCoupling:()=>Uq,createFft:()=>cQ,createFibonacciHeapClass:()=>T1,createFilter:()=>OK,createFilterTransform:()=>vee,createFineStructure:()=>qq,createFirstRadiation:()=>iW,createFix:()=>I1,createFlatten:()=>dQ,createFloor:()=>T0,createForEach:()=>BK,createForEachTransform:()=>_ee,createFormat:()=>HK,createFraction:()=>$X,createFractionClass:()=>MW,createFunctionAssignmentNode:()=>S9,createFunctionNode:()=>z9,createGamma:()=>N2,createGasConstant:()=>oW,createGcd:()=>fQ,createGetMatrixDataType:()=>UK,createGravitationConstant:()=>kq,createGravity:()=>gW,createHartreeEnergy:()=>Wq,createHasNumericValue:()=>gQ,createHelp:()=>oee,createHelpClass:()=>J9,createHex:()=>qK,createHypot:()=>bQ,createI:()=>_q,createIdentity:()=>E0,createIfft:()=>xQ,createIm:()=>WK,createImmutableDenseMatrixClass:()=>L1,createIndex:()=>t2,createIndexClass:()=>F1,createIndexNode:()=>O9,createIndexTransform:()=>Yee,createInfinity:()=>lq,createIntersect:()=>$1,createInv:()=>n2,createInverseConductanceQuantum:()=>Rq,createInvmod:()=>I0,createIsInteger:()=>GK,createIsNaN:()=>yX,createIsNegative:()=>tJ,createIsNumeric:()=>RX,createIsPositive:()=>rJ,createIsPrime:()=>vX,createIsZero:()=>iJ,createKldivergence:()=>b3,createKlitzing:()=>zq,createKron:()=>wQ,createLN10:()=>gq,createLN2:()=>mq,createLOG10E:()=>bq,createLOG2E:()=>yq,createLarger:()=>F0,createLargerEq:()=>NQ,createLcm:()=>O1,createLeafCount:()=>Z9,createLeftShift:()=>CQ,createLgamma:()=>hJ,createLog:()=>O0,createLog10:()=>mJ,createLog1p:()=>Y1,createLog2:()=>yJ,createLoschmidt:()=>sW,createLsolve:()=>IQ,createLsolveAll:()=>Y0,createLup:()=>E2,createLusolve:()=>Q2,createMad:()=>l3,createMagneticConstant:()=>Eq,createMagneticFluxQuantum:()=>Yq,createMap:()=>bJ,createMapTransform:()=>wee,createMatrix:()=>BX,createMatrixClass:()=>SW,createMatrixFromColumns:()=>FQ,createMatrixFromFunction:()=>PX,createMatrixFromRows:()=>z0,createMax:()=>B1,createMaxTransform:()=>Eee,createMean:()=>U2,createMeanTransform:()=>Bee,createMedian:()=>n3,createMin:()=>$Q,createMinTransform:()=>Aee,createMod:()=>JX,createMode:()=>RQ,createMolarMass:()=>fW,createMolarMassC12:()=>mW,createMolarPlanckConstant:()=>uW,createMolarVolume:()=>lW,createMultinomial:()=>I2,createMultiply:()=>H0,createMultiplyScalar:()=>xJ,createNaN:()=>cq,createNeutronMass:()=>Kq,createNode:()=>q7,createNorm:()=>d3,createNot:()=>SJ,createNthRoot:()=>eZ,createNthRoots:()=>BQ,createNuclearMagneton:()=>Bq,createNull:()=>uq,createNumber:()=>kJ,createNumeric:()=>aZ,createObjectNode:()=>V7,createOct:()=>TJ,createOnes:()=>zQ,createOperatorNode:()=>u9,createOr:()=>iZ,createParenthesisNode:()=>c9,createParse:()=>H9,createParser:()=>cee,createParserClass:()=>uee,createPartitionSelect:()=>HQ,createPermutations:()=>F2,createPhi:()=>fq,createPi:()=>pq,createPickRandom:()=>IJ,createPinv:()=>a2,createPlanckCharge:()=>xW,createPlanckConstant:()=>Tq,createPlanckLength:()=>yW,createPlanckMass:()=>bW,createPlanckTemperature:()=>_W,createPlanckTime:()=>vW,createPow:()=>i2,createPrint:()=>FJ,createProd:()=>uZ,createProtonMass:()=>Vq,createQr:()=>j0,createQuantileSeq:()=>z1,createQuantumOfCirculation:()=>Jq,createRandom:()=>YJ,createRandomInt:()=>_X,createRange:()=>q0,createRangeClass:()=>kW,createRangeNode:()=>w9,createRangeTransform:()=>Iee,createRationalize:()=>yee,createRe:()=>BJ,createReducedPlanckConstant:()=>Cq,createRelationalNode:()=>d9,createReplacer:()=>lV,createReshape:()=>cZ,createResize:()=>UQ,createResolve:()=>j9,createResultSet:()=>TW,createReviver:()=>D9,createRightArithShift:()=>WQ,createRightLogShift:()=>V0,createRotate:()=>_3,createRotationMatrix:()=>m3,createRound:()=>KQ,createRow:()=>P1,createRowTransform:()=>Oee,createRydberg:()=>Xq,createSQRT1_2:()=>vq,createSQRT2:()=>xq,createSackurTetrode:()=>cW,createSec:()=>zJ,createSech:()=>DX,createSecondRadiation:()=>pW,createSetCartesian:()=>j1,createSetDifference:()=>o2,createSetDistinct:()=>q1,createSetIntersect:()=>S2,createSetIsSubset:()=>V1,createSetMultiplicity:()=>l2,createSetPowerset:()=>K1,createSetSize:()=>K0,createSetSymDifference:()=>W2,createSetUnion:()=>i3,createSign:()=>HJ,createSimplify:()=>pee,createSimplifyConstant:()=>V9,createSimplifyCore:()=>eee,createSin:()=>jJ,createSinh:()=>MX,createSize:()=>dZ,createSlu:()=>u1,createSmaller:()=>mZ,createSmallerEq:()=>XQ,createSort:()=>X1,createSpaClass:()=>c2,createSparse:()=>kX,createSparseMatrixClass:()=>UJ,createSpeedOfLight:()=>Sq,createSplitUnit:()=>WJ,createSqrt:()=>TX,createSqrtm:()=>d2,createSquare:()=>GJ,createSqueeze:()=>bZ,createStd:()=>o3,createStdTransform:()=>Hee,createStefanBoltzmann:()=>dW,createStirlingS2:()=>R2,createString:()=>JJ,createSubset:()=>xZ,createSubsetTransform:()=>Tee,createSubtract:()=>kZ,createSum:()=>l1,createSumTransform:()=>Lee,createSymbolNode:()=>R9,createSymbolicEqual:()=>hee,createTan:()=>XJ,createTanh:()=>CX,createTau:()=>dq,createThomsonCrossSection:()=>Zq,createTo:()=>TZ,createTrace:()=>c1,createTranspose:()=>EZ,createTrue:()=>sq,createTypeOf:()=>QJ,createTyped:()=>NV,createUnaryMinus:()=>AX,createUnaryPlus:()=>aG,createUnequal:()=>e0,createUnit:()=>I6,createUnitClass:()=>g2,createUnitDependencies:()=>Ure,createUnitFunction:()=>B2,createUppercaseE:()=>Dq,createUppercasePi:()=>wq,createUsolve:()=>r0,createUsolveAll:()=>d1,createVacuumImpedance:()=>Iq,createVariance:()=>K2,createVarianceTransform:()=>Pee,createVersion:()=>Nq,createWeakMixingAngle:()=>Qq,createWienDisplacement:()=>hW,createXgcd:()=>IZ,createXor:()=>a0,createZeros:()=>FZ,cross:()=>X8,crossDependencies:()=>qre,csc:()=>y4,cscDependencies:()=>Wre,csch:()=>u5,cschDependencies:()=>Vre,ctranspose:()=>G5,ctransposeDependencies:()=>Kre,cube:()=>b4,cubeDependencies:()=>Jre,cumsum:()=>k8,cumsumDependencies:()=>Zre,cumsumTransformDependencies:()=>Qre,deepEqual:()=>T8,deepEqualDependencies:()=>eae,derivative:()=>Nte,derivativeDependencies:()=>sae,det:()=>Z8,detDependencies:()=>Ene,deuteronMass:()=>L6,deuteronMassDependencies:()=>oae,diag:()=>K5,diagDependencies:()=>uae,diff:()=>C8,diffDependencies:()=>lae,diffTransformDependencies:()=>cae,distance:()=>Q8,distanceDependencies:()=>dae,divide:()=>l7,divideDependencies:()=>tae,divideScalar:()=>J5,divideScalarDependencies:()=>hne,docs:()=>iee,dot:()=>E8,dotDependencies:()=>Sne,dotDivide:()=>X5,dotDivideDependencies:()=>hae,dotMultiply:()=>e6,dotMultiplyDependencies:()=>fae,dotPow:()=>F6,dotPowDependencies:()=>mae,e:()=>N3,eDependencies:()=>gae,efimovFactor:()=>U3,efimovFactorDependencies:()=>yae,eigs:()=>M7,eigsDependencies:()=>kae,electricConstant:()=>$6,electricConstantDependencies:()=>Tae,electronMass:()=>c7,electronMassDependencies:()=>Cae,elementaryCharge:()=>O6,elementaryChargeDependencies:()=>Eae,equal:()=>Z5,equalDependencies:()=>fne,equalScalar:()=>v4,equalScalarDependencies:()=>Fte,equalText:()=>A8,equalTextDependencies:()=>Aae,erf:()=>x4,erfDependencies:()=>Iae,evaluate:()=>bte,evaluateDependencies:()=>Lae,exp:()=>_4,expDependencies:()=>Fae,expm:()=>R6,expm1:()=>w4,expm1Dependencies:()=>Oae,expmDependencies:()=>$ae,factorial:()=>p7,factorialDependencies:()=>Bne,factory:()=>_U,falseDependencies:()=>Rae,faraday:()=>Y6,faradayDependencies:()=>Yae,fermiCoupling:()=>S7,fermiCouplingDependencies:()=>Bae,fft:()=>Q5,fftDependencies:()=>Hae,filter:()=>D4,filterDependencies:()=>Uae,filterTransformDependencies:()=>qae,fineStructure:()=>S3,fineStructureDependencies:()=>Wae,firstRadiation:()=>B6,firstRadiationDependencies:()=>Vae,fix:()=>n6,fixDependencies:()=>bne,flatten:()=>e8,flattenDependencies:()=>bae,floor:()=>I8,floorDependencies:()=>yne,forEach:()=>N4,forEachDependencies:()=>Gae,forEachTransformDependencies:()=>Kae,format:()=>M4,formatDependencies:()=>vne,fraction:()=>_5,fractionDependencies:()=>cne,gamma:()=>z6,gammaDependencies:()=>Yne,gasConstant:()=>R7,gasConstantDependencies:()=>Jae,gcd:()=>t8,gcdDependencies:()=>Xae,getMatrixDataType:()=>S4,getMatrixDataTypeDependencies:()=>Zae,gravitationConstant:()=>P6,gravitationConstantDependencies:()=>Qae,gravity:()=>d7,gravityDependencies:()=>eie,hartreeEnergy:()=>H6,hartreeEnergyDependencies:()=>tie,hasNumericValue:()=>n8,hasNumericValueDependencies:()=>nie,help:()=>vte,helpDependencies:()=>aie,hex:()=>k4,hexDependencies:()=>iie,hypot:()=>r8,hypotDependencies:()=>sie,i:()=>T3,iDependencies:()=>zae,identity:()=>L8,identityDependencies:()=>wne,ifft:()=>a8,ifftDependencies:()=>oie,im:()=>T4,imDependencies:()=>vae,index:()=>y6,indexDependencies:()=>uie,indexTransformDependencies:()=>lie,intersect:()=>i6,intersectDependencies:()=>pie,inv:()=>b6,invDependencies:()=>Ane,inverseConductanceQuantum:()=>h7,inverseConductanceQuantumDependencies:()=>die,invmod:()=>F8,invmodDependencies:()=>mie,isAccessorNode:()=>iH,isArray:()=>jP,isArrayNode:()=>sH,isAssignmentNode:()=>oH,isBigNumber:()=>YP,isBlockNode:()=>uH,isBoolean:()=>JP,isChain:()=>_H,isCollection:()=>qP,isComplex:()=>BP,isConditionalNode:()=>lH,isConstantNode:()=>cH,isDate:()=>eH,isDenseMatrix:()=>WP,isFraction:()=>zP,isFunction:()=>QP,isFunctionAssignmentNode:()=>dH,isFunctionNode:()=>hH,isHelp:()=>ZP,isIndex:()=>KP,isIndexNode:()=>fH,isInteger:()=>C4,isIntegerDependencies:()=>Jte,isMatrix:()=>UP,isNaN:()=>l5,isNaNDependencies:()=>gie,isNegative:()=>E4,isNegativeDependencies:()=>One,isNode:()=>mH,isNull:()=>rH,isNumber:()=>RP,isNumeric:()=>w5,isNumericDependencies:()=>xne,isObject:()=>nH,isObjectNode:()=>gH,isOperatorNode:()=>yH,isParenthesisNode:()=>bH,isPositive:()=>A4,isPositiveDependencies:()=>Ire,isPrime:()=>c5,isPrimeDependencies:()=>yie,isRange:()=>GP,isRangeNode:()=>vH,isRegExp:()=>tH,isResultSet:()=>XP,isSparseMatrix:()=>VP,isString:()=>HP,isSymbolNode:()=>xH,isUndefined:()=>aH,isUnit:()=>PP,isZero:()=>I4,isZeroDependencies:()=>Dne,kldivergence:()=>P7,kldivergenceDependencies:()=>_ie,klitzing:()=>j6,klitzingDependencies:()=>wie,kron:()=>i8,kronDependencies:()=>Die,larger:()=>$8,largerDependencies:()=>zne,largerEq:()=>s8,largerEqDependencies:()=>lre,lcm:()=>s6,lcmDependencies:()=>Tie,leafCount:()=>gte,leafCountDependencies:()=>Cie,leftShift:()=>o8,leftShiftDependencies:()=>Eie,lgamma:()=>F4,lgammaDependencies:()=>Aie,log:()=>O8,log10:()=>$4,log10Dependencies:()=>Iie,log1p:()=>o6,log1pDependencies:()=>Lie,log2:()=>O4,log2Dependencies:()=>Fie,logDependencies:()=>bie,loschmidt:()=>U6,loschmidtDependencies:()=>$ie,lsolve:()=>u8,lsolveAll:()=>R8,lsolveAllDependencies:()=>Rie,lsolveDependencies:()=>Oie,lup:()=>f7,lupDependencies:()=>Bie,lusolve:()=>L7,lusolveDependencies:()=>Pie,mad:()=>Y7,madDependencies:()=>Uie,magneticConstant:()=>q6,magneticConstantDependencies:()=>qie,magneticFluxQuantum:()=>m7,magneticFluxQuantumDependencies:()=>Wie,map:()=>R4,mapDependencies:()=>vie,mapTransformDependencies:()=>Vie,matrix:()=>D5,matrixDependencies:()=>Ote,matrixFromColumns:()=>l8,matrixFromColumnsDependencies:()=>xae,matrixFromFunction:()=>N5,matrixFromFunctionDependencies:()=>Gie,matrixFromRows:()=>Y8,matrixFromRowsDependencies:()=>Kie,max:()=>u6,maxDependencies:()=>Jie,maxTransformDependencies:()=>Xie,mean:()=>k7,meanDependencies:()=>Zie,meanTransformDependencies:()=>Qie,median:()=>F7,medianDependencies:()=>jie,min:()=>c8,minDependencies:()=>ese,minTransformDependencies:()=>tse,mod:()=>M5,modDependencies:()=>hie,mode:()=>p8,modeDependencies:()=>nse,molarMass:()=>W6,molarMassC12:()=>g7,molarMassC12Dependencies:()=>ase,molarMassDependencies:()=>rse,molarPlanckConstant:()=>V6,molarPlanckConstantDependencies:()=>ise,molarVolume:()=>T7,molarVolumeDependencies:()=>sse,multinomial:()=>y7,multinomialDependencies:()=>ose,multiply:()=>B8,multiplyDependencies:()=>kne,multiplyScalar:()=>Y4,multiplyScalarDependencies:()=>_ne,neutronMass:()=>G6,neutronMassDependencies:()=>lse,norm:()=>B7,normDependencies:()=>cse,not:()=>B4,notDependencies:()=>Vte,nthRoot:()=>S5,nthRootDependencies:()=>pse,nthRoots:()=>d8,nthRootsDependencies:()=>dse,nuclearMagneton:()=>K6,nuclearMagnetonDependencies:()=>hse,nullDependencies:()=>fse,number:()=>z4,numberDependencies:()=>pne,numeric:()=>k5,numericDependencies:()=>dne,oct:()=>P4,octDependencies:()=>mse,ones:()=>h8,onesDependencies:()=>gse,or:()=>T5,orDependencies:()=>yse,parse:()=>pte,parseDependencies:()=>Cre,parser:()=>_te,parserDependencies:()=>vse,partitionSelect:()=>f8,partitionSelectDependencies:()=>Hie,permutations:()=>b7,permutationsDependencies:()=>xse,phi:()=>$3,phiDependencies:()=>_se,pi:()=>W3,piDependencies:()=>wse,pickRandom:()=>H4,pickRandomDependencies:()=>Dse,pinv:()=>v6,pinvDependencies:()=>Nse,planckCharge:()=>J6,planckChargeDependencies:()=>Mse,planckConstant:()=>C7,planckConstantDependencies:()=>Sse,planckLength:()=>X6,planckLengthDependencies:()=>kse,planckMass:()=>v7,planckMassDependencies:()=>Tse,planckTemperature:()=>Z6,planckTemperatureDependencies:()=>Cse,planckTime:()=>j7,planckTimeDependencies:()=>Ese,pow:()=>x6,powDependencies:()=>Ine,print:()=>j4,printDependencies:()=>Ase,prod:()=>C5,prodDependencies:()=>Hre,protonMass:()=>Q6,protonMassDependencies:()=>Ise,qr:()=>z8,qrDependencies:()=>wae,quantileSeq:()=>l6,quantileSeqDependencies:()=>Lse,quantumOfCirculation:()=>x7,quantumOfCirculationDependencies:()=>Fse,random:()=>U4,randomDependencies:()=>$se,randomInt:()=>d5,randomIntDependencies:()=>Ose,range:()=>P8,rangeDependencies:()=>pre,rangeTransformDependencies:()=>Yse,rationalize:()=>Mte,rationalizeDependencies:()=>Bse,re:()=>q4,reDependencies:()=>Dae,reducedPlanckConstant:()=>e7,reducedPlanckConstantDependencies:()=>zse,replacer:()=>V3,replacerDependencies:()=>Pse,reshape:()=>E5,reshapeDependencies:()=>Hse,resize:()=>m8,resizeDependencies:()=>jse,resolve:()=>dte,resolveDependencies:()=>nae,reviver:()=>nte,reviverDependencies:()=>Use,rightArithShift:()=>g8,rightArithShiftDependencies:()=>qse,rightLogShift:()=>H8,rightLogShiftDependencies:()=>Wse,rotate:()=>H7,rotateDependencies:()=>Gse,rotationMatrix:()=>z7,rotationMatrixDependencies:()=>Vse,round:()=>y8,roundDependencies:()=>mne,row:()=>c6,rowDependencies:()=>Kse,rowTransformDependencies:()=>Jse,rydberg:()=>t7,rydbergDependencies:()=>Xse,sackurTetrode:()=>B3,sackurTetrodeDependencies:()=>eoe,sec:()=>W4,secDependencies:()=>toe,sech:()=>h5,sechDependencies:()=>noe,secondRadiation:()=>_7,secondRadiationDependencies:()=>roe,setCartesian:()=>p6,setCartesianDependencies:()=>aoe,setDifference:()=>_6,setDifferenceDependencies:()=>ioe,setDistinct:()=>d6,setDistinctDependencies:()=>soe,setIntersect:()=>n7,setIntersectDependencies:()=>ooe,setIsSubset:()=>h6,setIsSubsetDependencies:()=>uoe,setMultiplicity:()=>w6,setMultiplicityDependencies:()=>loe,setPowerset:()=>f6,setPowersetDependencies:()=>coe,setSize:()=>j8,setSizeDependencies:()=>poe,setSymDifference:()=>E7,setSymDifferenceDependencies:()=>doe,setUnion:()=>$7,setUnionDependencies:()=>hoe,sign:()=>V4,signDependencies:()=>_ae,simplify:()=>wte,simplifyConstant:()=>hte,simplifyConstantDependencies:()=>rae,simplifyCore:()=>yte,simplifyCoreDependencies:()=>aae,simplifyDependencies:()=>iae,sin:()=>G4,sinDependencies:()=>Nae,sinh:()=>f5,sinhDependencies:()=>foe,size:()=>A5,sizeDependencies:()=>Mne,slu:()=>U8,sluDependencies:()=>zie,smaller:()=>I5,smallerDependencies:()=>sre,smallerEq:()=>b8,smallerEqDependencies:()=>cre,sort:()=>m6,sortDependencies:()=>moe,sparse:()=>m5,sparseDependencies:()=>goe,speedOfLight:()=>r7,speedOfLightDependencies:()=>yoe,splitUnit:()=>J4,splitUnitDependencies:()=>boe,sqrt:()=>g5,sqrtDependencies:()=>pae,sqrtm:()=>N6,sqrtmDependencies:()=>voe,square:()=>X4,squareDependencies:()=>xoe,squeeze:()=>L5,squeezeDependencies:()=>_oe,std:()=>O7,stdDependencies:()=>Doe,stdTransformDependencies:()=>Noe,stefanBoltzmann:()=>a7,stefanBoltzmannDependencies:()=>Moe,stirlingS2:()=>w7,stirlingS2Dependencies:()=>Pne,string:()=>Z4,stringDependencies:()=>Soe,subset:()=>F5,subsetDependencies:()=>Rte,subsetTransformDependencies:()=>koe,subtract:()=>$5,subtractDependencies:()=>Cne,sum:()=>q8,sumDependencies:()=>xie,sumTransformDependencies:()=>Toe,symbolicEqual:()=>Dte,symbolicEqualDependencies:()=>Coe,tan:()=>Q4,tanDependencies:()=>Eoe,tanh:()=>y5,tanhDependencies:()=>Aoe,tau:()=>z3,tauDependencies:()=>Pae,thomsonCrossSection:()=>i7,thomsonCrossSectionDependencies:()=>Ioe,to:()=>O5,toDependencies:()=>Loe,trace:()=>W8,traceDependencies:()=>Foe,transpose:()=>R5,transposeDependencies:()=>Gre,trueDependencies:()=>$oe,typeOf:()=>e5,typeOfDependencies:()=>Ooe,typed:()=>K3,typedDependencies:()=>Ate,unaryMinus:()=>b5,unaryMinusDependencies:()=>Tne,unaryPlus:()=>J3,unaryPlusDependencies:()=>Xre,unequal:()=>v8,unequalDependencies:()=>Roe,unit:()=>D7,unitDependencies:()=>Yoe,usolve:()=>x8,usolveAll:()=>V8,usolveAllDependencies:()=>Sae,usolveDependencies:()=>Mae,vacuumImpedance:()=>S6,vacuumImpedanceDependencies:()=>Poe,variance:()=>A7,varianceDependencies:()=>woe,varianceTransformDependencies:()=>Hoe,version:()=>H3,versionDependencies:()=>joe,weakMixingAngle:()=>X3,weakMixingAngleDependencies:()=>Uoe,wienDisplacement:()=>k6,wienDisplacementDependencies:()=>qoe,xgcd:()=>Y5,xgcdDependencies:()=>fie,xor:()=>_8,xorDependencies:()=>Woe,zeros:()=>B5,zerosDependencies:()=>Gte});class K{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 J{refCount(e){return X("refCount")}incRef(e){return X("incRef")}timerAvailable(){return!0}time(e){return X("time")}read(e){return X("read")}readSync(e){return X("readSync")}readToGPU(e,t){return X("readToGPU")}numDataIds(){return X("numDataIds")}disposeData(e,t){return X("disposeData")}write(e,t,n){return X("write")}move(e,t,n,r,a){return X("move")}memory(){return X("memory")}floatPrecision(){return X("floatPrecision")}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}dispose(){return X("dispose")}}function X(e){throw new Error(`'${e}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`)}function Z(e){let t=e.length,n=0;for(;t>0;)n=Math.random()*t|0,t--,ne(e,t,n)}function Q(e,t){if(e.length!==t.length)throw new Error(`Array sizes must match to be shuffled together First array length was ${e.length}Second array length was ${t.length}`);let n=e.length,r=0;for(;n>0;)r=Math.random()*n|0,n--,ne(e,n,r),ne(t,n,r)}function ee(e,t,n){return Math.max(e,Math.min(t,n))}function te(e){return e%2==0?e:e+1}function ne(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function re(e){let t=0;for(let n=0;nn+` Shapes ${e} and ${t} must match`))}function ue(e){se(null!=e,(()=>"The input to the tensor constructor must be a non-null value."))}function le(e,t=[],n=!1){if(null==t&&(t=[]),Array.isArray(e)||ke(e)&&!n)for(let r=0;r0),n){return new Promise(((r,a)=>{let i=0;const s=()=>{if(e())return void r();i++;const o=t(i);null!=n&&i>=n?a():setTimeout(s,o)};s()}))}function ve(e,t){let n=1,r=-1;for(let t=0;t=0)n*=e[t];else if(-1===e[t]){if(-1!==r)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${r} and dim ${t}`);r=t}else if(e[t]<0)throw Error(`Shapes can not be < 0. Found ${e[t]} at dim ${t}`);if(-1===r){if(t>0&&t!==n)throw Error(`Size(${t}) must match the product of shape ${e}`);return e}if(0===n)throw Error(`Cannot infer the missing size in [${e}] when there are 0 elements`);if(t%n!=0)throw Error(`The implicit shape can't be a fractional number. Got ${t} / ${n}`);const a=e.slice();return a[r]=t/n,a}function xe(e,t){const n=t.length;return e=null==e?t.map(((e,t)=>t)):[].concat(e),se(e.every((e=>e>=-n&&e`All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`)),se(e.every((e=>he(e))),(()=>`All values in axis param must be integers but got axis ${e}`)),e.map((e=>e<0?n+e:e))}function _e(e,t){const n=[],r=[],a=null!=t&&Array.isArray(t)&&0===t.length,i=null==t||a?null:xe(t,e).sort();let s=0;for(let t=0;tt)&&1===e[t]&&(n.push(e[t]),r.push(t)),i[s]<=t&&s++}1!==e[t]&&(n.push(e[t]),r.push(t))}return{newShape:n,keptDims:r}}function we(e,t){let n=null;if(null==e||"float32"===e)n=new Float32Array(t);else if("int32"===e)n=new Int32Array(t);else{if("bool"!==e)throw new Error(`Unknown data type ${e}`);n=new Uint8Array(t)}return n}function De(e,t){let n=null;if(null==e||"float32"===e)n=new Float32Array(t);else if("int32"===e)n=new Int32Array(t);else if("bool"===e)n=new Uint8Array(t);else{if("string"!==e)throw new Error(`Unknown data type ${e}`);n=new Array(t)}return n}function Ne(e,t){for(let n=0;nt+=e.length)),t}function Ee(e){return"string"==typeof e||e instanceof String}function Ae(e){return"boolean"==typeof e}function Ie(e){return"number"==typeof e}function Le(e){return Array.isArray(e)?Le(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":Ie(e)?"float32":Ee(e)?"string":Ae(e)?"bool":"float32"}function Fe(e){return!!(e&&e.constructor&&e.call&&e.apply)}function $e(e,t){for(let n=t;n=0;--r)n[r]=n[r+1]*e[r+1];return n}function Re(e,t,n,r=!1){const a=new Array;if(1===t.length){const i=t[0]*(r?2:1);for(let t=0;te*t))*(r?2:1);for(let t=0;te*t))*(n?2:1);if(0===r)return[];if(r!==t.length)throw new Error(`[${e}] does not match the input size ${t.length}${n?" for a complex tensor":""}.`);return Re(0,e,t,n)}function Be(e,t){const n=ze(e,t);for(let e=0;ee*t),1);if(null==t||"float32"===t)return Ye(e,new Float32Array(n));if("int32"===t)return Ye(e,new Int32Array(n));if("bool"===t)return Ye(e,new Uint8Array(n));throw new Error(`Unknown data type ${t}`)}function He(e){e.forEach((t=>{se(Number.isInteger(t)&&t>=0,(()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`))}))}function je(e,t,n){if(0===t)return 0;if(1===t)return e[0];let r=e[e.length-1];for(let t=0;t{const[t,n]=e.split(":");this.urlFlags[t]=function(e,t){if("true"===(t=t.toLowerCase())||"false"===t)return"true"===t;if(""+ +t===t)return+t;throw new Error(`Could not parse value flag value ${t} for flag ${e}.`)}(t,n)}))}}function Ve(e){const t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,((e,...n)=>(function(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||"")}(t,n[0],n[1]),n.join("=")))),t}function Ge(){return Je}let Ke,Je=null;function Xe(){if(null==Ke){let e;if("undefined"!=typeof window)e=window;else if(void 0!==n.g)e=n.g;else if("undefined"!=typeof process)e=process;else{if("undefined"==typeof self)throw new Error("Could not find a global object");e=self}Ke=e}return Ke}function Ze(e,t){const n=function(){const e=Xe();return null==e._tfGlobals&&(e._tfGlobals=new Map),e._tfGlobals}();if(n.has(e))return n.get(e);{const r=t();return n.set(e,r),n.get(e)}}const Qe="Abs",et="Acos",tt="Acosh",nt="Add",rt="AddN",at="All",it="Any",st="ArgMax",ot="ArgMin",ut="Asin",lt="Asinh",ct="Atan",pt="Atanh",dt="Atan2",ht="AvgPool",ft="AvgPoolGrad",mt="AvgPool3D",gt="AvgPool3DGrad",yt="BatchMatMul",bt="BatchToSpaceND",vt="Bincount",xt="BroadcastTo",_t="BroadcastArgs",wt="Cast",Dt="Ceil",Nt="ClipByValue",Mt="Complex",St="ComplexAbs",kt="Concat",Tt="Conv2D",Ct="Conv2DBackpropFilter",Et="Conv2DBackpropInput",At="Conv3D",It="Conv3DBackpropFilterV2",Lt="Conv3DBackpropInputV2",Ft="Cos",$t="Cosh",Ot="Cumprod",Rt="Cumsum",Yt="CropAndResize",Bt="DenseBincount",zt="DepthToSpace",Pt="DepthwiseConv2dNative",Ht="DepthwiseConv2dNativeBackpropFilter",jt="DepthwiseConv2dNativeBackpropInput",Ut="Diag",qt="Dilation2D",Wt="Dilation2DBackpropInput",Vt="Dilation2DBackpropFilter",Gt="RealDiv",Kt="Einsum",Jt="Elu",Xt="EluGrad",Zt="Erf",Qt="Equal",en="Exp",tn="ExpandDims",nn="Expm1",rn="FFT",an="Fill",sn="FlipLeftRight",on="Floor",un="FloorDiv",ln="FusedBatchNorm",cn="GatherV2",pn="GatherNd",dn="Greater",hn="GreaterEqual",fn="Identity",mn="IFFT",gn="Imag",yn="IsFinite",bn="IsInf",vn="IsNan",xn="LeakyRelu",_n="Less",wn="LessEqual",Dn="LinSpace",Nn="Log",Mn="Log1p",Sn="LogicalAnd",kn="LogicalNot",Tn="LogicalOr",Cn="LogicalXor",En="LogSoftmax",An="LowerBound",In="LRN",Ln="LRNGrad",Fn="Max",$n="Maximum",On="MaxPool",Rn="MaxPoolGrad",Yn="MaxPool3D",Bn="MaxPool3DGrad",zn="MaxPoolWithArgmax",Pn="Mean",Hn="Min",jn="Minimum",Un="MirrorPad",qn="Mod",Wn="Multinomial",Vn="Multiply",Gn="Neg",Kn="NotEqual",Jn="NonMaxSuppressionV3",Xn="NonMaxSuppressionV4",Zn="NonMaxSuppressionV5",Qn="OnesLike",er="OneHot",tr="Pack",nr="PadV2",rr="Pool",ar="Pow",ir="Prelu",sr="Prod",or="Range",ur="Real",lr="Reciprocal",cr="Relu",pr="Reshape",dr="ResizeNearestNeighbor",hr="ResizeNearestNeighborGrad",fr="ResizeBilinear",mr="ResizeBilinearGrad",gr="Relu6",yr="Reverse",br="Round",vr="Rsqrt",xr="ScatterNd",_r="SearchSorted",wr="Select",Dr="Selu",Nr="Slice",Mr="Sin",Sr="Sinh",kr="Sign",Tr="Sigmoid",Cr="Softplus",Er="Sqrt",Ar="Sum",Ir="SpaceToBatchND",Lr="SplitV",Fr="Softmax",$r="SparseFillEmptyRows",Or="SparseReshape",Rr="SparseSegmentMean",Yr="SparseSegmentSum",Br="SparseToDense",zr="SquaredDifference",Pr="Square",Hr="StridedSlice",jr="StringNGrams",Ur="StringSplit",qr="StringToHashBucketFast",Wr="Sub",Vr="Tan",Gr="Tanh",Kr="Tile",Jr="TopK",Xr="Transform",Zr="Transpose",Qr="Unique",ea="Unpack",ta="UnsortedSegmentSum",na="UpperBound",ra="ZerosLike",aa="Step",ia="FromPixels",sa="RotateWithOffset",oa="_FusedMatMul",ua="FusedConv2D",la="FusedDepthwiseConv2D";function ca(...e){Ge().getBool("IS_TEST")||Ge().getBool("PROD")||console.warn(...e)}function pa(...e){Ge().getBool("IS_TEST")||Ge().getBool("PROD")||console.log(...e)}const da=Ze("kernelRegistry",(()=>new Map)),ha=Ze("gradRegistry",(()=>new Map));function fa(e,t){const n=wa(e,t);return da.get(n)}function ma(e){return ha.get(e)}function ga(e){const t=da.entries(),n=[];for(;;){const{done:r,value:a}=t.next();if(r)break;const[i,s]=a,[o]=i.split("_");o===e&&n.push(s)}return n}function ya(e){const{kernelName:t,backendName:n}=e,r=wa(t,n);da.has(r)&&ca(`The kernel '${t}' for backend '${n}' is already registered`),da.set(r,e)}function ba(e){const{kernelName:t}=e;ha.has(t)&&Ge().getBool("DEBUG")&&ca(`Overriding the gradient for '${t}'`),ha.set(t,e)}function va(e,t){const n=wa(e,t);if(!da.has(n))throw new Error(`The kernel '${e}' for backend '${t}' is not registered`);da.delete(n)}function xa(e){if(!ha.has(e))throw new Error(`The gradient '${e}' for backend is not registered`);ha.delete(e)}function _a(e,t){ga(e).forEach((e=>{ya(Object.assign({},e,{backendName:t}))}))}function wa(e,t){return`${t}_${e}`}var Da=n(3720);const Na=n.n(Da)()||Da;function Ma(e){return Na.fromString(e,!0,16)}const Sa=Ma("c3a5c85c97cb3127"),ka=Ma("b492b66fbe98f273"),Ta=Ma("9ae16a3b2f90404f");function Ca(e){return e.xor(e.shru(47))}function Ea(e,t,n){const r=e.slice(t,t+n);return Na.fromBytes(Array.from(r),!0,!0)}function Aa(e,t){return Ea(e,t,8)}function Ia(e,t){return Ea(e,t,4)}function La(e,t){return 0===t?e:e.shru(t).or(e.shl(64-t))}function Fa(e,t,n=Ma("9ddfea08eb382d69")){let r=e.xor(t).mul(n);r=r.xor(r.shru(47));let a=t.xor(r).mul(n);return a=a.xor(a.shru(47)),a=a.mul(n),a}function $a(e,t,n,r){return function(e,t,n,r,a,i){a=a.add(e),i=La(i.add(a).add(r),21);const s=a;return a=(a=a.add(t)).add(n),i=i.add(La(a,44)),[a.add(r),i.add(s)]}(Aa(e,t),Aa(e,t+8),Aa(e,t+16),Aa(e,t+24),n,r)}function Oa(e,t=e.length){const n=Na.fromNumber(81,!0);if(t<=32)return t<=16?function(e,t=e.length){if(t>=8){const n=Ta.add(2*t),r=Aa(e,0).add(Ta),a=Aa(e,t-8);return Fa(La(a,37).mul(n).add(r),La(r,25).add(a).mul(n),n)}if(t>=4){const n=Ta.add(2*t);return Fa(Ia(e,0).shl(3).add(t),Ia(e,t-4),n)}if(t>0){const n=e[0]+(e[t>>1]<<8),r=t+(e[t-1]<<2);return Ca(Ta.mul(n).xor(Sa.mul(r))).mul(Ta)}return Ta}(e,t):function(e,t=e.length){const n=Ta.add(2*t),r=Aa(e,0).mul(ka),a=Aa(e,8),i=Aa(e,t-8).mul(n),s=Aa(e,t-16).mul(Ta);return Fa(La(r.add(a),43).add(La(i,30)).add(s),r.add(La(a.add(Ta),18)).add(i),n)}(e,t);if(t<=64)return function(e,t=e.length){const n=Ta.add(2*t),r=Aa(e,0).mul(Ta),a=Aa(e,8),i=Aa(e,t-8).mul(n),s=Aa(e,t-16).mul(Ta),o=La(r.add(a),43).add(La(i,30)).add(s),u=Fa(o,r.add(La(a.add(Ta),18)).add(i),n),l=Aa(e,16).mul(n),c=Aa(e,24),p=o.add(Aa(e,t-32)).mul(n),d=u.add(Aa(e,t-24)).mul(n);return Fa(La(l.add(c),43).add(La(p,30)).add(d),l.add(La(c.add(r),18)).add(p),n)}(e,t);let r=n,a=n.mul(ka).add(113),i=Ca(a.mul(Ta).add(113)).mul(Ta),s=[Na.UZERO,Na.UZERO],o=[Na.UZERO,Na.UZERO];r=r.mul(Ta).add(Aa(e,0));let u=0;const l=64*(t-1>>6),c=l+(t-1&63)-63;do{r=La(r.add(a).add(s[0]).add(Aa(e,u+8)),37).mul(ka),a=La(a.add(s[1]).add(Aa(e,u+48)),42).mul(ka),r=r.xor(o[1]),a=a.add(s[0]).add(Aa(e,u+40)),i=La(i.add(o[0]),33).mul(ka),s=$a(e,u,s[1].mul(ka),r.add(o[0])),o=$a(e,u+32,i.add(o[1]),a.add(Aa(e,u+16))),[i,r]=[r,i],u+=64}while(u!==l);const p=ka.add(i.and(255).shl(1));return u=c,o[0]=o[0].add(t-1&63),s[0]=s[0].add(o[0]),o[0]=o[0].add(s[0]),r=La(r.add(a).add(s[0]).add(Aa(e,u+8)),37).mul(p),a=La(a.add(s[1]).add(Aa(e,u+48)),42).mul(p),r=r.xor(o[1].mul(9)),a=a.add(s[0].mul(9).add(Aa(e,u+40))),i=La(i.add(o[0]),33).mul(p),s=$a(e,u,s[1].mul(p),r.add(o[0])),o=$a(e,u+32,i.add(o[1]),a.add(Aa(e,u+16))),[i,r]=[r,i],Fa(Fa(s[0],o[0],p).add(Ca(a).mul(Sa)).add(i),Fa(s[1],o[1],p).add(r),p)}function Ra(e,t){return"string"===t?Pa(e):Ya([e],t)}function Ya(e,t){if("string"===t)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=le(e)),Ge().getBool("DEBUG")&&Ne(e,t),function(e,t){return e instanceof Float32Array&&"float32"===t||e instanceof Int32Array&&"int32"===t||e instanceof Uint8Array&&"bool"===t}(e,t))return e;if(null==t||"float32"===t||"complex64"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t){const t=new Uint8Array(e.length);for(let n=0;n{r=n()};let i;const s=Ba();if(this.backendTimer.timerAvailable())i=this.backendTimer.time(a);else{a();for(const e of r)e.dataSync();i=Promise.resolve({kernelMs:Ba()-s})}if(Ge().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let t=0;t{Ua(t,n.dtype,e)}))}return{kernelName:e,outputs:r,inputs:t,timeMs:i.then((e=>e.kernelMs)),extraInfo:i.then((e=>null!=e.getExtraProfileInfo?e.getExtraProfileInfo():""))}}logKernelProfile(e){const{kernelName:t,outputs:n,timeMs:r,inputs:a,extraInfo:i}=e;n.forEach((e=>{Promise.all([e.data(),r,i]).then((n=>{this.logger.logKernelProfile(t,e,n[0],n[1],a,n[2])}))}))}}function Ua(e,t,n){if("float32"!==t)return!1;for(let t=0;t0?r:""} `}}console.log(`%c${o}\t%c${s}\t%c${u}D ${c}\t%c${l}\t%c${p}\t%c${i}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}}function Wa(e,t,n,r){const a=Oe(t),i=function(e,t,n,r){const a=ce(t),i=r[r.length-1],s=new Array(i).fill(0),o=t.length,u="complex64"===n?Ja(e):e;if(o>1)for(let e=0;e
" "+e)).join("\n")),u.join("\n")}function Va(e,t,n){let r;return r=Array.isArray(e)?`${parseFloat(e[0].toFixed(7))} + ${parseFloat(e[1].toFixed(7))}j`:Ee(e)?`'${e}'`:"bool"===n?Ga(e):parseFloat(e.toFixed(7)).toString(),ye(r,t)}function Ga(e){return 0===e?"false":"true"}function Ka(e,t,n,r,a,i=!0){const s="complex64"===n?2:1,o=t[0],u=t.length;if(0===u)return"complex64"===n?[Va(Ja(e)[0],0,n)]:"bool"===n?[Ga(e[0])]:[e[0].toString()];if(1===u){if(o>20){const t=3*s;let r=Array.from(e.slice(0,t)),i=Array.from(e.slice((o-3)*s,o*s));return"complex64"===n&&(r=Ja(r),i=Ja(i)),["["+r.map(((e,t)=>Va(e,a[t],n))).join(", ")+", ..., "+i.map(((e,t)=>Va(e,a[o-3+t],n))).join(", ")+"]"]}return["["+("complex64"===n?Ja(e):Array.from(e)).map(((e,t)=>Va(e,a[t],n))).join(", ")+"]"]}const l=t.slice(1),c=r.slice(1),p=r[0]*s,d=[];if(o>20){for(let t=0;t<3;t++){const r=t*p,i=r+p;d.push(...Ka(e.slice(r,i),l,n,c,a,!1))}d.push("...");for(let t=o-3;t`Length of values '${e}' does not match the size inferred by the shape '${this.size}'.`))}if("complex64"===t)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=n||De(t,this.size),this.strides=Oe(e)}set(e,...t){0===t.length&&(t=[0]),se(t.length===this.rank,(()=>`The number of provided coordinates (${t.length}) must match the rank (${this.rank})`));const n=this.locToIndex(t);this.values[n]=e}get(...e){0===e.length&&(e=[0]);let t=0;for(const n of e){if(n<0||n>=this.shape[t]){const t=`Requested out of range element at ${e}. Buffer shape=${this.shape}`;throw new Error(t)}t++}let n=e[e.length-1];for(let t=0;tHa(e)))}catch(e){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(),Za().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();const e=Za().readSync(this.dataId);if("string"===this.dtype)try{return e.map((e=>Ha(e)))}catch(e){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 Za().read(this.dataId);return"string"===this.dtype?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(Za().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return Qa.print(this,e)}clone(){return this.throwIfDisposed(),Qa.clone(this)}toString(e=!1){return Wa(this.dataSync(),this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),Qa.cast(this,e)}variable(e=!0,t,n){return this.throwIfDisposed(),Za().makeVariable(this,e,t,n)}}function ni(){return Ze("Tensor",(()=>ti))}Object.defineProperty(ti,Symbol.hasInstance,{value:e=>!!e&&null!=e.data&&null!=e.dataSync&&null!=e.throwIfDisposed}),ni();class ri extends ti{constructor(e,t,n,r){super(e.shape,e.dtype,e.dataId,r),this.trainable=t,this.name=n}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(!de(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);Za().disposeTensor(this),this.dataId=e.dataId,Za().incRef(this,null)}dispose(){Za().disposeVariable(this),this.isDisposedInternal=!0}}var ai,ii,si,oi,ui;Object.defineProperty(ri,Symbol.hasInstance,{value:e=>e instanceof ti&&null!=e.assign&&e.assign instanceof Function}),function(e){e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6"}(ai||(ai={})),function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"}(ii||(ii={})),function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"}(si||(si={})),function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"}(oi||(oi={})),function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"}(ui||(ui={}));const li={float32:oi,int32:ii,bool:si,complex64:ui};function ci(e,t){if("string"===e||"string"===t){if("string"===e&&"string"===t)return"string";throw new Error(`Can not upcast ${e} with ${t}`)}return li[e][t]}function pi(e){return ci(e,"int32")}function di(e,t){if(e.dtype===t.dtype)return[e,t];const n=ci(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function hi(e,t){se(e.dtype===t.dtype,(()=>`The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`))}function fi(e,t){return t.some((t=>t.id===e.id))}function mi(e){const t=[];return gi(e,t,new Set),t}function gi(e,t,n){if(null==e)return;if(e instanceof ti)return void t.push(e);if(r=e,!Array.isArray(r)&&"object"!=typeof r)return;var r;const a=e;for(const e in a){const r=a[e];n.has(r)||(n.add(r),gi(r,t,n))}}function yi(e){return null!=e.kernelName}class bi{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 vi{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new bi}async ready(){if(null!=this.pendingBackendInit)return this.pendingBackendInit.then((()=>{}));if(null!=this.backendInstance)return;const e=this.getSortedBackends();for(let t=0;t{null!=e.setupFunc&&e.setupFunc(this.backendInstance)}))}disposeRegisteredKernels(e){ga(e).forEach((t=>{null!=t.disposeFunc&&t.disposeFunc(this.registry[e])}))}initializeBackend(e){const t=this.registryFactory[e];if(null==t)throw new Error(`Cannot initialize backend ${e}, no registration found.`);try{const n=t.factory();if(!n||n instanceof J||"function"!=typeof n.then)return this.registry[e]=n,{success:!0,asyncInit:!1};{const t=++this.pendingBackendInitId,r=n.then((n=>!(t(tthis.registryFactory[t].priority-this.registryFactory[e].priority))}initializeBackendsAndReturnBest(){const e=this.getSortedBackends();for(let t=0;tthis.startScope(r)),(()=>this.endScope(n)),(()=>(n=t(),n instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),n)))}scopedRun(e,t,n){e();try{const e=n();return t(),e}catch(e){throw t(),e}}nextTensorId(){return vi.nextTensorId++}nextVariableId(){return vi.nextVariableId++}clone(e){const t=_i.runKernel(fn,{x:e}),n={x:e};return this.addTapeNode(this.state.activeScope.name,n,[t],(e=>({x:()=>{const t={x:e};return _i.runKernel(wt,t,{dtype:"float32"})}})),[],{}),t}runKernel(e,t,n){if(null==this.backendName&&this.backend,null==fa(e,this.backendName))throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:e,inputs:t,attrs:n})}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(e,t,n){const r=this.backend.numDataIds();let a=0;n.forEach((e=>{a+="complex64"===e.dtype?3:1}));const i=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],s=r-t-a-i;if(s>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${s} data ids) after running '${e}'`)}runKernelFunc(e){let t,n=[];const r=this.isTapeOn(),a=this.state.numBytes,i=this.state.numTensors;let s,o;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0),null==this.backendName&&this.backend;const u=yi(e)?e.kernelName:null!=this.state.activeScope?this.state.activeScope.name:"";if(yi(e)){const{kernelName:t,inputs:a,attrs:i}=e;null==this.backendName&&this.backend;const u=fa(t,this.backendName);se(null!=u,(()=>`Cannot find registered kernel '${t}' for backend '${this.backendName}'`)),s=()=>{const e=this.backend.numDataIds();o=u.kernelFunc({inputs:a,attrs:i,backend:this.backend});const s=Array.isArray(o)?o:[o];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(t,e,s);const l=s.map((e=>null!=e.rank?e:this.makeTensorFromTensorInfo(e)));if(r){const e=this.getTensorsForGradient(t,a,l);n=this.saveTensorsForBackwardMode(e)}return l}}else{const{forwardFunc:t}=e,a=e=>{r&&(n=e.map((e=>this.keep(this.clone(e)))))};s=()=>{const e=this.backend.numDataIds();o=this.tidy((()=>t(this.backend,a)));const n=Array.isArray(o)?o:[o];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(u,e,n),n}}const{inputs:l,attrs:c}=e,p=yi(e)?null:e.backwardsFunc;let d;return this.scopedRun((()=>this.state.kernelDepth++),(()=>this.state.kernelDepth--),(()=>{this.ENV.getBool("DEBUG")||this.state.profiling?(d=this.profiler.profileKernel(u,l,(()=>s())),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(d),t=d.outputs):t=s()})),r&&this.addTapeNode(u,l,t,p,n,c),this.state.profiling&&this.state.activeProfile.kernels.push({name:u,bytesAdded:this.state.numBytes-a,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-i,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(l).map((e=>null!=l[e]?l[e].shape:null)),outputShapes:t.map((e=>e.shape)),kernelTimeMs:d.timeMs,extraInfo:d.extraInfo}),Array.isArray(o)?t:t[0]}saveTensorsForBackwardMode(e){const t=e.map((e=>this.keep(this.clone(e))));return t}getTensorsForGradient(e,t,n){const r=ma(e);if(null!=r){const e=r.inputsToSave||[],a=r.outputsToSave||[];let i;r.saveAllInputs?(se(Array.isArray(t),(()=>"saveAllInputs is true, expected inputs to be an array.")),i=Object.keys(t).map((e=>t[e]))):i=e.map((e=>t[e]));const s=n.filter(((e,t)=>a[t]));return i.concat(s)}return[]}makeTensor(e,t,n,r){if(null==e)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",r=r||this.backend;let a=e;"string"===n&&Ee(e[0])&&(a=e.map((e=>Pa(e))));const i=r.write(a,t,n),s=new ti(t,n,i,this.nextTensorId());if(this.trackTensor(s,r),"string"===n){const e=this.state.tensorInfo.get(i),t=Ce(a);this.state.numBytes+=t-e.bytes,e.bytes=t}return s}makeTensorFromDataId(e,t,n,r){const a={dataId:e,shape:t,dtype:n=n||"float32"};return this.makeTensorFromTensorInfo(a,r)}makeTensorFromTensorInfo(e,t){const{dataId:n,shape:r,dtype:a}=e,i=new ti(r,a,n,this.nextTensorId());return this.trackTensor(i,t),i}makeVariable(e,t=!0,n,r){n=n||this.nextVariableId().toString(),null!=r&&r!==e.dtype&&(e=e.cast(r));const a=new ri(e,t,n,this.nextTensorId());if(null!=this.state.registeredVariables[a.name])throw new Error(`Variable with name ${a.name} was already registered`);return this.state.registeredVariables[a.name]=a,this.incRef(a,this.backend),a}trackTensor(e,t){this.state.numTensors++,"string"===e.dtype&&this.state.numStringTensors++;let n=0;"complex64"!==e.dtype&&"string"!==e.dtype&&(n=e.size*Te(e.dtype)),this.state.numBytes+=n,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:n})),e instanceof ri||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--,"string"===e.dtype&&(this.state.numStringTensors--,this.state.numBytes-=t.bytes),"complex64"!==e.dtype&&"string"!==e.dtype){const t=e.size*Te(e.dtype);this.state.numBytes-=t}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),null!=this.state.registeredVariables[e.name]&&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,null==e.reasons&&(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,n=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((e=>e.totalBytesSnapshot))),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-n;for(const e of this.state.activeProfile.kernels)e.kernelTimeMs=await e.kernelTimeMs,e.extraInfo=await e.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&0===this.state.kernelDepth}addTapeNode(e,t,n,r,a,i){const s={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:a},o=ma(e);null!=o&&(r=o.gradFunc),null!=r&&(s.gradient=e=>(e=e.map(((e,t)=>{if(null==e){const e=n[t],r=ze(e.size,e.dtype);return this.makeTensor(r,e.shape,e.dtype)}return e})),r(e.length>1?e:e[0],a,i))),this.state.activeTape.push(s)}keep(e){return e.kept=!0,e}startTape(){0===this.state.gradientDepth&&(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=mi(e),n=new Set(t.map((e=>e.id)));for(let e=0;e{e.kept||e.scopeId!==r.id||this.track(e)}))}gradients(e,t,n,r=!1){if(se(t.length>0,(()=>"gradients() received an empty list of xs.")),null!=n&&"float32"!==n.dtype)throw new Error(`dy must have 'float32' dtype, but has '${n.dtype}'`);const a=this.scopedRun((()=>this.startTape()),(()=>this.endTape()),(()=>this.tidy("forward",e)));se(a instanceof ti,(()=>"The result y returned by f() must be a tensor."));const i=function(e,t,n){const r={},a={};for(let e=0;er[e.id]=!0)),o=!0,a[i.id]=!0;break}if(o)break}}const i={};i[n.id]=!0;const s={};for(let t=e.length-1;t>=0;t--){const n=e[t],r=n.inputs;for(let e=0;e0)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 e={};e[a.id]=null==n?function(e){const t=Be(ce(e),"float32");return _i.makeTensor(t,e,"float32")}(a.shape):n,function(e,t,n,r){for(let a=t.length-1;a>=0;a--){const i=t[a],s=[];if(i.outputs.forEach((t=>{const n=e[t.id];null!=n?s.push(n):s.push(null)})),null==i.gradient)throw new Error(`Cannot compute gradient: gradient function not found for ${i.kernelName}.`);const o=i.gradient(s);for(const t in i.inputs){if(!(t in o))throw new Error(`Cannot backprop through input ${t}. Available gradients found: ${Object.keys(o)}.`);const a=n((()=>o[t]()));if("float32"!==a.dtype)throw new Error(`Error in gradient for op ${i.kernelName}. The gradient of input ${t} must have 'float32' dtype, but has '${a.dtype}'`);const s=i.inputs[t];if(!de(a.shape,s.shape))throw new Error(`Error in gradient for op ${i.kernelName}. The gradient of input '${t}' has shape '${a.shape}', which does not match the shape of the input '${s.shape}'`);if(null==e[s.id])e[s.id]=a;else{const t=e[s.id];e[s.id]=r(t,a),t.dispose()}}}}(e,i,(e=>this.tidy(e)),wi);const r=t.map((t=>e[t.id]));return 0===this.state.gradientDepth&&(this.state.activeTape.forEach((e=>{for(const t of e.saved)t.dispose()})),this.state.activeTape=null),{value:a,grads:r}}))}customGrad(e){return se(Fe(e),(()=>"The f passed in customGrad(f) must be a function.")),(...t)=>{let n;se(t.every((e=>e instanceof ti)),(()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors"));const r={};return t.forEach(((e,t)=>{r[t]=e})),this.runKernelFunc({forwardFunc:(r,a)=>(n=e(...t,a),se(n.value instanceof ti,(()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor")),se(Fe(n.gradFunc),(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function.")),n.value),backwardsFunc:(e,r)=>{const a=n.gradFunc(e,r),i=Array.isArray(a)?a:[a];se(i.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(...).")),se(i.every((e=>e instanceof ti)),(()=>"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 s={};return i.forEach(((e,t)=>{s[t]=()=>e})),s},inputs:r})}}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=Ba(),n=await this.backend.time(e);return n.wallMs=Ba()-t,n}track(e){return null!=this.state.activeScope&&(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 bi;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}}function xi(){const e=Xe();if(null==e._tfengine){const t=new We(e);e._tfengine=new vi(t)}var t;return t=e._tfengine.ENV,Je=t,Za=()=>e._tfengine,e._tfengine}vi.nextTensorId=0,vi.nextVariableId=0;const _i=xi();function wi(e,t){const n={a:e,b:t};return _i.runKernel(nt,n)}let Di;function Ni(e){Di=e}function Mi(e){if(void 0!==Di)return Di;if(e||"undefined"!=typeof navigator&&null!=navigator){if(e||(e=navigator),"ReactNative"===e.product)return!0;const t=e.userAgent||e.vendor||("undefined"!=typeof window?window.opera:"");if(!t){const t=e;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(t)||/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(t.substr(0,4))}return!1}function Si(){return"undefined"!=typeof window&&null!=window.document||"undefined"!=typeof WorkerGlobalScope}const ki=Ge();function Ti(e,t){let n=e;if(ke(e))return"string"===t?[]:[e.length];if(!Array.isArray(e))return[];const r=[];for(;Array.isArray(n)||ke(n)&&"string"!==t;)r.push(n.length),n=n[0];return Array.isArray(e)&&Ge().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&Ci(e,r,[]),r}function Ci(e,t,n){if(n=n||[],!Array.isArray(e)&&!ke(e))return void se(0===t.length,(()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`));se(t.length>0,(()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`)),se(e.length===t[0],(()=>`Element arr[${n.join("][")}] should have ${t[0]} elements, but has ${e.length} elements`));const r=t.slice(1);for(let t=0;t=0&&(a=r),Ei(r,a,t,n),null==e||!ke(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e){const r=null==e?"null":e.constructor.name;throw new Error(`Argument '${t}' passed to '${n}' must be a Tensor or TensorLike, but got '${r}'`)}const i=Ti(e,a);ke(e)||Array.isArray(e)||(e=[e]);const s="string"!==a?Ya(e,a):le(e,[],!0);return _i.makeTensor(s,i,a)}function Ii(e,t,n,r="numeric"){if(!Array.isArray(e))throw new Error(`Argument ${t} passed to ${n} must be a \`Tensor[]\` or \`TensorLike[]\``);return e.map(((e,a)=>Ai(e,`${t}[${a}]`,n,r)))}ki.registerFlag("DEBUG",(()=>!1),(e=>{e&&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.")})),ki.registerFlag("IS_BROWSER",(()=>Si())),ki.registerFlag("IS_NODE",(()=>"undefined"!=typeof process&&void 0!==process.versions&&void 0!==process.versions.node)),ki.registerFlag("IS_CHROME",(()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor))),ki.registerFlag("PROD",(()=>!1)),ki.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",(()=>ki.getBool("DEBUG"))),ki.registerFlag("DEPRECATION_WARNINGS_ENABLED",(()=>!0)),ki.registerFlag("IS_TEST",(()=>!1)),ki.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",(()=>!0)),ki.registerFlag("WRAP_TO_IMAGEBITMAP",(()=>!1)),ki.registerFlag("ENGINE_COMPILE_ONLY",(()=>!1));const Li="__op";function Fi(e){const t=Object.keys(e);if(1!==t.length)throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${t.length} keys.`);let n=t[0];const r=e[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n+=Li;const a=(...e)=>{_i.startScope(n);try{const t=r(...e);return qe(t)&&console.error("Cannot return a Promise inside of tidy."),_i.endScope(t),t}catch(e){throw _i.endScope(null),e}};return Object.defineProperty(a,"name",{value:n,configurable:!0}),a}const $i=Fi({complex_:function(e,t){const n=Ai(e,"real","complex"),r=Ai(t,"imag","complex");oe(n.shape,r.shape,`real and imag shapes, ${n.shape} and ${r.shape}, must match in call to tf.complex().`);const a={real:n,imag:r};return _i.runKernel(Mt,a)}});function Oi(e,t,n,r){if(null==r&&(r=Le(e)),"complex64"===r)throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!ke(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e)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(null!=t){He(t);const e=ce(t),r=ce(n);se(e===r,(()=>`Based on the provided shape, [${t}], the tensor should have ${e} values but has ${r}`));for(let e=0;e`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `))}}return ke(e)||Array.isArray(e)||(e=[e]),t=t||n,e="string"!==r?Ya(e,r):le(e,[],!0),_i.makeTensor(e,t,r)}function Ri(e,t,n){return Oi(e,t,Ti(e,n),n)}const Yi={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8};async function Bi(e,t){const n=[],r=[],a=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);for(let i=0;i{const t=await o.bytes(),n=t.reduce(((e,t)=>e+t.length),0)+4*t.length,r=new Uint8Array(n);let a=0;for(let e=0;e{if(t+=e.byteLength,n.push(e.byteLength===e.buffer.byteLength?e:new e.constructor(e)),!(e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array))throw new Error(`Unsupported TypedArray subtype: ${e.constructor.name}`)}));const r=new Uint8Array(t);let a=0;return n.forEach((e=>{r.set(new Uint8Array(e.buffer),a),a+=e.byteLength})),r.buffer}const Hi="undefined"!=typeof Buffer&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function ji(e){return Hi?Buffer.byteLength(e):new Blob([e]).size}function Ui(e){if(1===e.length)return e[0];let t=0;e.forEach((e=>{t+=e.byteLength}));const n=new Uint8Array(t);let r=0;return e.forEach((e=>{n.set(new Uint8Array(e),r),r+=e.byteLength})),n.buffer}function qi(e){for(e=e.trim();e.endsWith("/");)e=e.slice(0,e.length-1);const t=e.split("/");return t[t.length-1]}function Wi(e,t){const n={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,weightsManifest:t};return null!=e.signature&&(n.signature=e.signature),null!=e.userDefinedMetadata&&(n.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(n.modelInitializer=e.modelInitializer),null!=e.trainingConfig&&(n.trainingConfig=e.trainingConfig),n}async function Vi(e,t){const n={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy};if(null!=e.trainingConfig&&(n.trainingConfig=e.trainingConfig),null!=e.weightsManifest){const[r,a]=await t(e.weightsManifest);n.weightSpecs=r,n.weightData=a}return null!=e.signature&&(n.signature=e.signature),null!=e.userDefinedMetadata&&(n.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(n.modelInitializer=e.modelInitializer),n}function Gi(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("Expected JSON model topology, received ArrayBuffer.");return{dateSaved:new Date,modelTopologyType:"JSON",modelTopologyBytes:null==e.modelTopology?0:ji(JSON.stringify(e.modelTopology)),weightSpecsBytes:null==e.weightSpecs?0:ji(JSON.stringify(e.weightSpecs)),weightDataBytes:null==e.weightData?0:e.weightData.byteLength}}function Ki(){const e=function(){const e=e=>{let t=e<<13,n=0;for(;0==(8388608&t);)n-=8388608,t<<=1;return t&=-8388609,n+=947912704,t|n},t=new Uint32Array(2048);t[0]=0;for(let n=1;n<1024;n++)t[n]=e(n);for(let e=1024;e<2048;e++)t[e]=939524096+(e-1024<<13);return t}(),t=function(){const e=new Uint32Array(64);e[0]=0,e[31]=1199570944,e[32]=2147483648,e[63]=3347054592;for(let t=1;t<31;t++)e[t]=t<<23;for(let t=33;t<63;t++)e[t]=2147483648+(t-32<<23);return e}(),n=function(){const e=new Uint32Array(64);for(let t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}();return r=>{const a=new ArrayBuffer(4*r.length),i=new Uint32Array(a);for(let a=0;a>10]+(1023&s)]+t[s>>10];i[a]=o}return new Float32Array(a)}}class Ji{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return null==Ji.instance&&(Ji.instance=new Ji),Ji.instance}static registerSaveRouter(e){Ji.getInstance().saveRouters.push(e)}static registerLoadRouter(e){Ji.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return Ji.getHandlers(e,"save")}static getLoadHandlers(e,t){return Ji.getHandlers(e,"load",t)}static getHandlers(e,t,n){const r=[];return("load"===t?Ji.getInstance().loadRouters:Ji.getInstance().saveRouters).forEach((t=>{const a=t(e,n);null!==a&&r.push(a)})),r}}const Xi=e=>Ji.registerSaveRouter(e),Zi=e=>Ji.registerLoadRouter(e),Qi=e=>Ji.getSaveHandlers(e),es=(e,t)=>Ji.getLoadHandlers(e,t),ts="tensorflowjs",ns="models_store",rs="model_info_store";function as(){if(!Ge().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");const e="undefined"==typeof window?self:window,t=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB||e.shimIndexedDB;if(null==t)throw new Error("The current browser does not appear to support IndexedDB.");return t}function is(e){const t=e.result;t.createObjectStore(ns,{keyPath:"modelPath"}),t.createObjectStore(rs,{keyPath:"modelPath"})}class ss{constructor(e){if(this.indexedDB=as(),null==e||!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(((e,n)=>{const r=this.indexedDB.open(ts,1);r.onupgradeneeded=()=>is(r),r.onsuccess=()=>{const a=r.result;if(null==t){const t=a.transaction(ns,"readonly"),r=t.objectStore(ns).get(this.modelPath);r.onsuccess=()=>{if(null==r.result)return a.close(),n(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));e(r.result.modelArtifacts)},r.onerror=e=>(a.close(),n(r.error)),t.oncomplete=()=>a.close()}else{const r=Gi(t),i=a.transaction(rs,"readwrite");let s=i.objectStore(rs);const o=s.put({modelPath:this.modelPath,modelArtifactsInfo:r});let u;o.onsuccess=()=>{u=a.transaction(ns,"readwrite");const o=u.objectStore(ns).put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:r});o.onsuccess=()=>e({modelArtifactsInfo:r}),o.onerror=e=>{s=i.objectStore(rs);const t=s.delete(this.modelPath);t.onsuccess=()=>(a.close(),n(o.error)),t.onerror=e=>(a.close(),n(o.error))}},o.onerror=e=>(a.close(),n(o.error)),i.oncomplete=()=>{null==u?a.close():u.oncomplete=()=>a.close()}}},r.onerror=e=>n(r.error)}))}}ss.URL_SCHEME="indexeddb://";const os=e=>{return Ge().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(ss.URL_SCHEME)?(t=e.slice(ss.URL_SCHEME.length),new ss(t)):null;var t};Ji.registerSaveRouter(os),Ji.registerLoadRouter(os);class us{constructor(){this.indexedDB=as()}async listModels(){return new Promise(((e,t)=>{const n=this.indexedDB.open(ts,1);n.onupgradeneeded=()=>is(n),n.onsuccess=()=>{const r=n.result,a=r.transaction(rs,"readonly"),i=a.objectStore(rs).getAll();i.onsuccess=()=>{const t={};for(const e of i.result)t[e.modelPath]=e.modelArtifactsInfo;e(t)},i.onerror=e=>(r.close(),t(i.error)),a.oncomplete=()=>r.close()},n.onerror=e=>t(n.error)}))}async removeModel(e){var t;return e=(t=e).startsWith(ss.URL_SCHEME)?t.slice(ss.URL_SCHEME.length):t,new Promise(((t,n)=>{const r=this.indexedDB.open(ts,1);r.onupgradeneeded=()=>is(r),r.onsuccess=()=>{const a=r.result,i=a.transaction(rs,"readwrite"),s=i.objectStore(rs),o=s.get(e);let u;o.onsuccess=()=>{if(null==o.result)return a.close(),n(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{const r=s.delete(e),i=()=>{u=a.transaction(ns,"readwrite");const r=u.objectStore(ns).delete(e);r.onsuccess=()=>t(o.result.modelArtifactsInfo),r.onerror=e=>n(o.error)};r.onsuccess=i,r.onerror=e=>(i(),a.close(),n(o.error))}},o.onerror=e=>(a.close(),n(o.error)),i.oncomplete=()=>{null==u?a.close():u.oncomplete=()=>a.close()}},r.onerror=e=>n(r.error)}))}}const ls="/",cs="tensorflowjs_models",ps="info",ds="model_topology",hs="weight_specs",fs="weight_data",ms="model_metadata";function gs(e){return{info:[cs,e,ps].join(ls),topology:[cs,e,ds].join(ls),weightSpecs:[cs,e,hs].join(ls),weightData:[cs,e,fs].join(ls),modelMetadata:[cs,e,ms].join(ls)}}function ys(e){for(const t of Object.values(e))window.localStorage.removeItem(t)}function bs(e){const t=e.split(ls);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(ls)}class vs{constructor(e){if(!Ge().getBool("IS_BROWSER")||"undefined"==typeof window||void 0===window.localStorage)throw new Error("The current environment does not support local storage.");if(this.LS=window.localStorage,null==e||!e)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=e,this.keys=gs(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),n=JSON.stringify(e.weightSpecs),r=Gi(e);try{this.LS.setItem(this.keys.info,JSON.stringify(r)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,n),this.LS.setItem(this.keys.weightData,function(e){if(Hi)return Buffer.from(e).toString("base64");const t=new Uint8Array(e);let n="";for(let e=0,r=t.length;e{return Ge().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(vs.URL_SCHEME)?(t=e.slice(vs.URL_SCHEME.length),new vs(t)):null;var t};Ji.registerSaveRouter(xs),Ji.registerLoadRouter(xs);class _s{constructor(){se(Ge().getBool("IS_BROWSER"),(()=>"Current environment is not a web browser")),se("undefined"==typeof window||void 0!==window.localStorage,(()=>"Current browser does not appear to support localStorage")),this.LS=window.localStorage}async listModels(){const e={},t=cs+ls,n=ls+ps;for(let r=0;r"scheme must not be undefined or null.")),e.endsWith(ws)&&(e=e.slice(0,e.indexOf(ws))),se(e.length>0,(()=>"scheme must not be an empty string."));const n=Ds.getInstance();se(null==n.managers[e],(()=>`A model store manager is already registered for scheme '${e}'.`)),n.managers[e]=t}static getManager(e){const t=Ds.getInstance().managers[e];if(null==t)throw new Error(`Cannot find model manager for scheme '${e}'`);return t}static getSchemes(){return Object.keys(Ds.getInstance().managers)}}function Ns(e){if(-1===e.indexOf(ws))throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${Ds.getSchemes().join(",")}`);return{scheme:e.split(ws)[0],path:e.split(ws)[1]}}async function Ms(e,t,n=!1){se(e!==t,(()=>`Old path and new path are the same: '${e}'`));const r=Ji.getLoadHandlers(e);se(r.length>0,(()=>`Copying failed because no load handler is found for source URL ${e}.`)),se(r.length<2,(()=>`Copying failed because more than one (${r.length}) load handlers for source URL ${e}.`));const a=r[0],i=Ji.getSaveHandlers(t);se(i.length>0,(()=>`Copying failed because no save handler is found for destination URL ${t}.`)),se(i.length<2,(()=>`Copying failed because more than one (${r.length}) save handlers for destination URL ${t}.`));const s=i[0],o=Ns(e).scheme,u=Ns(e).path,l=o===Ns(e).scheme,c=await a.load();n&&l&&await Ds.getManager(o).removeModel(u);const p=await s.save(c);return n&&!l&&await Ds.getManager(o).removeModel(u),p.modelArtifactsInfo}async function Ss(){const e=Ds.getSchemes(),t={};for(const n of e){const e=await Ds.getManager(n).listModels();for(const r in e)t[n+ws+r]=e[r]}return t}async function ks(e){const t=Ns(e);return Ds.getManager(t.scheme).removeModel(t.path)}async function Ts(e,t){return Ms(e,t,!1)}async function Cs(e,t){return Ms(e,t,!0)}class Es{fetch(e,t){return fetch(e,t)}now(){return performance.now()}encode(e,t){if("utf-8"!==t&&"utf8"!==t)throw new Error(`Browser's encoder only supports utf-8, but got ${t}`);return null==this.textEncoder&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(e)}decode(e,t){return new TextDecoder(t).decode(e)}}if(Ge().get("IS_BROWSER")){Ge().setPlatform("browser",new Es);try{Ds.registerManager(vs.URL_SCHEME,new _s)}catch(e){}try{Ds.registerManager(ss.URL_SCHEME,new us)}catch(e){}}let As;function Is(e,t="float32",n){return t=t||"float32",He(e),new Xa(e,t,n)}Ge().get("IS_NODE")&&!Ge().get("IS_BROWSER")&&Ge().setPlatform("node",new class{constructor(){this.util=n(8628),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return null!=Ge().global.fetch?Ge().global.fetch(e,t):(null==As&&(As=n(5410)),As(e,t))}now(){const e=process.hrtime();return 1e3*e[0]+e[1]/1e6}encode(e,t){if("utf-8"!==t&&"utf8"!==t)throw new Error(`Node built-in encoder only supports utf-8, but got ${t}`);return this.textEncoder.encode(e)}decode(e,t){return 0===e.length?"":new this.util.TextDecoder(t).decode(e)}});const Ls=Fi({cast_:function(e,t){const n=Ai(e,"x","cast");if(!Me(t))throw new Error(`Failed to cast to unknown dtype ${t}`);if("string"===t&&"string"!==n.dtype||"string"!==t&&"string"===n.dtype)throw new Error("Only strings can be casted to strings");const r={x:n},a={dtype:t};return _i.runKernel(wt,r,a)}}),Fs=Fi({clone_:function(e){const t={x:Ai(e,"x","clone","string_or_numeric")};return _i.runKernel(fn,t)}});function $s(e,t=!1){console.log(e.toString(t))}function Os(e){return new Promise((e=>setTimeout(e))).then(e)}xi(),Qa={buffer:Is,cast:Ls,clone:Fs,print:$s};class Rs{constructor(e){if(!Ge().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(Rs.URL_SCHEME)&&(e=e.slice(Rs.URL_SCHEME.length)),null!=e&&0!==e.length||(e="model"),this.modelJsonFileName=e+".json",this.weightDataFileName=e+".weights.bin"}async save(e){if("undefined"==typeof document)throw new Error("Browser downloads are not supported in this environment since `document` is not present");const t=window.URL.createObjectURL(new Blob([e.weightData],{type:"application/octet-stream"}));if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet.");{const n=Wi(e,[{paths:["./"+this.weightDataFileName],weights:e.weightSpecs}]),r=window.URL.createObjectURL(new Blob([JSON.stringify(n)],{type:"application/json"})),a=null==this.modelJsonAnchor?document.createElement("a"):this.modelJsonAnchor;if(a.download=this.modelJsonFileName,a.href=r,await Os((()=>a.dispatchEvent(new MouseEvent("click")))),null!=e.weightData){const e=null==this.weightDataAnchor?document.createElement("a"):this.weightDataAnchor;e.download=this.weightDataFileName,e.href=t,await Os((()=>e.dispatchEvent(new MouseEvent("click"))))}return{modelArtifactsInfo:Gi(e)}}}}Rs.URL_SCHEME="downloads://";class Ys{constructor(e){if(null==e||e.length<1)throw new Error(`When calling browserFiles, at least 1 file is required, but received ${e}`);this.jsonFile=e[0],this.weightsFiles=e.slice(1)}async load(){return new Promise(((e,t)=>{const n=new FileReader;n.onload=n=>{const r=JSON.parse(n.target.result),a=r.modelTopology;if(null==a)return void t(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`));if(null==r.weightsManifest)return void t(new Error(`weightManifest field is missing from file ${this.jsonFile.name}`));if(0===this.weightsFiles.length)return void e({modelTopology:a});const i=Vi(r,(e=>this.loadWeights(e)));e(i)},n.onerror=e=>t(`Failed to read model topology and weights manifest JSON from file '${this.jsonFile.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`),n.readAsText(this.jsonFile)}))}loadWeights(e){const t=[],n=[];for(const r of e)t.push(...r.weights),n.push(...r.paths);const r=this.checkManifestAndWeightFiles(e),a=n.map((e=>this.loadWeightsFile(e,r[e])));return Promise.all(a).then((e=>[t,Ui(e)]))}loadWeightsFile(e,t){return new Promise(((n,r)=>{const a=new FileReader;a.onload=e=>{const t=e.target.result;n(t)},a.onerror=t=>r(`Failed to weights data from file of path '${e}'.`),a.readAsArrayBuffer(t)}))}checkManifestAndWeightFiles(e){const t=[],n=this.weightsFiles.map((e=>qi(e.name))),r={};for(const a of e)a.paths.forEach((e=>{const a=qi(e);if(-1!==t.indexOf(a))throw new Error(`Duplicate file basename found in weights manifest: '${a}'`);if(t.push(a),-1===n.indexOf(a))throw new Error(`Weight file with basename '${a}' is not provided.`);r[e]=this.weightsFiles[n.indexOf(a)]}));if(t.length!==this.weightsFiles.length)throw new Error(`Mismatch in the number of files in weights manifest (${t.length}) and the number of weight files provided (${this.weightsFiles.length}).`);return r}}function Bs(e){return new Ys(e)}function zs(e,t,n,r){!function(e){se(null!=e&&Array.isArray(e)&&e.length>0,(()=>"promises must be a none empty array"))}(e),function(e,t){se(e>=0&&e<=1,(()=>`Progress fraction must be in range [0, 1], but got startFraction ${e}`)),se(t>=0&&t<=1,(()=>`Progress fraction must be in range [0, 1], but got endFraction ${t}`)),se(t>=e,(()=>`startFraction must be no more than endFraction, but got startFraction ${e} and endFraction ${t}`))}(n=null==n?0:n,r=null==r?1:r);let a=0;return Promise.all(e.map((i=>(i.then((i=>{const s=n+ ++a/e.length*(r-n);return t(s),i})),i))))}async function Ps(e,t){null==t&&(t={});const n=null==t.fetchFunc?Ge().platform.fetch:t.fetchFunc,r=e.map((e=>n(e,t.requestInit,{isBinary:!0}))),a=(null==t.onProgress?await Promise.all(r):await zs(r,t.onProgress,0,.5)).map((e=>e.arrayBuffer()));return null==t.onProgress?await Promise.all(a):await zs(a,t.onProgress,.5,1)}async function Hs(e,t="",n,r){return js((e=>Ps(e,{requestInit:r})))(e,t,n)}function js(e){return async(t,n="",r)=>{const a=t.map((()=>!1)),i={},s=null!=r?r.map((()=>!1)):[],o=[];if(t.forEach(((e,t)=>{let n=0;e.weights.forEach((e=>{const u="quantization"in e?e.quantization.dtype:e.dtype,l=Yi[u]*ce(e.shape),c=()=>{a[t]=!0,null==i[t]&&(i[t]=[]),i[t].push({manifestEntry:e,groupOffset:n,sizeBytes:l})};null!=r?r.forEach(((t,n)=>{t===e.name&&(c(),s[n]=!0)})):c(),o.push(e.name),n+=l}))})),!s.every((e=>e))){const e=r.filter(((e,t)=>!s[t]));throw new Error(`Could not find weights in manifest with names: ${e.join(", ")}. \nManifest JSON has weights with names: ${o.join(", ")}.`)}const u=a.reduce(((e,t,n)=>(t&&e.push(n),e)),[]),l=[];u.forEach((e=>{t[e].paths.forEach((e=>{const t=n+(n.endsWith("/")?"":"/")+e;l.push(t)}))}));const c=await e(l),p={};let d=0;return u.forEach((e=>{const n=t[e].paths.length;let r=0;for(let e=0;e{const t=zi(a.slice(e.groupOffset,e.groupOffset+e.sizeBytes),[e.manifestEntry]);for(const e in t)p[e]=t[e]})),d+=n})),p}}Ji.registerSaveRouter((e=>Ge().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Rs.URL_SCHEME)?function(e="model"){return new Rs(e)}(e.slice(Rs.URL_SCHEME.length)):null));class Us{constructor(e,t){if(this.DEFAULT_METHOD="POST",null==t&&(t={}),this.weightPathPrefix=t.weightPathPrefix,this.onProgress=t.onProgress,this.weightUrlConverter=t.weightUrlConverter,null!=t.fetchFunc?(se("function"==typeof t.fetchFunc,(()=>"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=Ge().platform.fetch,se(null!=e&&e.length>0,(()=>"URL path for http must not be null, undefined or empty.")),Array.isArray(e)&&se(2===e.length,(()=>`URL paths for http must have a length of 2, (actual length is ${e.length}).`)),this.path=e,null!=t.requestInit&&null!=t.requestInit.body)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=t.requestInit||{}}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 n=Wi(e,[{paths:["./model.weights.bin"],weights:e.weightSpecs}]);t.body.append("model.json",new Blob([JSON.stringify(n)],{type:"application/json"}),"model.json"),null!=e.weightData&&t.body.append("model.weights.bin",new Blob([e.weightData],{type:"application/octet-stream"}),"model.weights.bin");const r=await this.fetch(this.path,t);if(r.ok)return{modelArtifactsInfo:Gi(e),responses:[r]};throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${r.status}.`)}async load(){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(e){let t=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?t+=" 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.":t+=" Please make sure the server is serving valid JSON for this request.",new Error(t)}const n=t.modelTopology,r=t.weightsManifest;if(null==n&&null==r)throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);return Vi(t,(e=>this.loadWeights(e)))}async loadWeights(e){const t=Array.isArray(this.path)?this.path[1]:this.path,[n,r]=function(e){const t=e.lastIndexOf("/"),n=e.lastIndexOf("?");return[e.substring(0,t)+"/",n>t?e.substring(n):""]}(t),a=this.weightPathPrefix||n,i=[];for(const t of e)i.push(...t.weights);const s=[],o=[];for(const t of e)for(const e of t.paths)null!=this.weightUrlConverter?o.push(this.weightUrlConverter(e)):s.push(a+e+r);return this.weightUrlConverter&&s.push(...await Promise.all(o)),[i,Ui(await Ps(s,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress}))]}}function qs(e){return null!=e.match(Us.URL_SCHEME_REGEX)}Us.URL_SCHEME_REGEX=/^https?:\/\//;const Ws=(e,t)=>{if("undefined"==typeof fetch&&(null==t||null==t.fetchFunc))return null;{let n=!0;if(n=Array.isArray(e)?e.every((e=>qs(e))):qs(e),n)return Vs(e,t)}return null};function Vs(e,t){return new Us(e,t)}function Gs(e,t){return Vs(e,t)}Ji.registerSaveRouter(Ws),Ji.registerLoadRouter(Ws);class Ks{constructor(e){this.modelArtifacts=e}load(){return this.modelArtifacts}}class Js{constructor(e){this.saveHandler=e}save(e){return this.saveHandler(e)}}class Xs{constructor(e){e.load&&(this.load=()=>Promise.resolve(e.load())),e.save&&(this.save=t=>Promise.resolve(e.save(t)))}}function Zs(e,t,n,r){const a=arguments;return new Xs(Qs(...a))}function Qs(e,t,n,r){return 1===arguments.length?null!=e.modelTopology||null!=e.weightSpecs?new Ks(e):(console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new Ks({modelTopology:e})):(console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new Ks({modelTopology:e,weightSpecs:t,weightData:n,trainingConfig:r}))}function eo(e){return new Js(e)}function to(e){return new Js(e)}const no=Fi({matMul_:function(e,t,n=!1,r=!1){let a=Ai(e,"a","matMul"),i=Ai(t,"b","matMul");[a,i]=di(a,i);const s={a,b:i},o={transposeA:n,transposeB:r};return _i.runKernel(yt,s,o)}}),ro=Fi({oneHot_:function(e,t,n=1,r=0){if(t<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${t}`);const a={indices:Ai(e,"indices","oneHot","int32")},i={depth:t,onValue:n,offValue:r};return _i.runKernel(er,a,i)}});function ao(){Ge().set("PROD",!0)}function io(){Ge().set("DEBUG",!0)}function so(){Ge().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function oo(e){Ge().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(e+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}function uo(){_i.disposeVariables()}function lo(){return _i}function co(){return _i.memory()}function po(e){return _i.profile(e)}function ho(e,t){return _i.tidy(e,t)}function fo(e){mi(e).forEach((e=>e.dispose()))}function mo(e){return _i.keep(e)}function go(e){return _i.time(e)}function yo(e){return _i.setBackend(e)}function bo(){return _i.ready()}function vo(){return _i.backendName}function xo(e){_i.removeBackend(e)}function _o(e){return _i.findBackend(e)}function wo(e){return _i.findBackendFactory(e)}function Do(e,t,n=1){return _i.registerBackend(e,t,n)}function No(){return _i.backend}function Mo(e,t){Ge().setPlatform(e,t)}ei=oo;const So=Fi({imag_:function(e){const t={input:Ai(e,"input","imag")};return _i.runKernel(gn,t)}}),ko=Fi({neg_:function(e){const t={x:Ai(e,"x","neg")};return _i.runKernel(Gn,t)}}),To=Fi({real_:function(e){const t={input:Ai(e,"input","real")};return _i.runKernel(ur,t)}}),Co=Fi({transpose_:function(e,t,n){const r=Ai(e,"x","transpose");if(null==t&&(t=r.shape.map(((e,t)=>t)).reverse()),se(r.rank===t.length,(()=>`Error in transpose: rank of input ${r.rank} must match length of perm ${t}.`)),t.forEach((e=>{se(e>=0&&e"All entries in 'perm' must be between 0 and "+(r.rank-1)+` but got ${t}`))})),r.rank<=1)return r.clone();const a={x:r},i={perm:t};return"complex64"===r.dtype?ho((()=>{let e=To(r),t=So(r);return e=_i.runKernel(Zr,{x:e},i),t=_i.runKernel(Zr,{x:t},i),n&&(t=ko(t)),$i(e,t)})):_i.runKernel(Zr,a,i)}}),Eo=Fi({confusionMatrix_:function(e,t,n){const r=Ai(e,"labels","confusionMatrix"),a=Ai(t,"predictions","confusionMatrix");se(null==n||n>0&&Number.isInteger(n),(()=>`If provided, numClasses must be a positive integer, but got ${n}`)),se(1===r.rank,(()=>`Expected the rank of labels to be 1, but got ${r.rank}`)),se(1===a.rank,(()=>`Expected the rank of predictions to be 1, but got ${a.rank}`)),se(r.shape[0]===a.shape[0],(()=>`Mismatch in the number of examples: ${r.shape[0]} vs. ${a.shape[0]}. Labels and predictions should have the same number of elements.`)),se(n>0&&Number.isInteger(n),(()=>`numClasses is required to be a positive integer, but got ${n}`));const i=ro(Ls(r,"int32"),n),s=ro(Ls(a,"int32"),n),o=Co(i),u=no(o,s);return Ls(u,"int32")}});function Ao(e,t){const n=e.length,r=[];for(let a=0;a1&&1===s&&r.unshift(i)}return r}function Io(e,t){const n=[];for(let r=0;r1)&&n.unshift(i)}return n}function Lo(e,t){const n=[],r=Math.max(e.length,t.length);for(let a=0;a4)throw new Error("Cannot construct Tensor with more than 4 channels from pixels.");if(null==e)throw new Error("pixels passed to tf.browser.fromPixels() can not be null");let n=!1,r=!1,a=!1,i=!1,s=!1,o=!1;if(e.data instanceof Uint8Array)n=!0;else if("undefined"!=typeof ImageData&&e instanceof ImageData)r=!0;else if("undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement)a=!0;else if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement)i=!0;else if(null!=e.getContext)s=!0;else{if(!("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap))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 ${e.constructor.name}`);o=!0}if(a){const t=2;if(a&&e.readyState element.")}if(null!=fa(ia,_i.backendName)){const n={pixels:e},r={numChannels:t};return _i.runKernel(ia,n,r)}const[u,l]=a?[e.videoWidth,e.videoHeight]:[e.width,e.height];let c,p;if(s)c=e.getContext("2d").getImageData(0,0,u,l).data;else if(r||n)c=e.data;else if(i||a||o){if(null==$o)if("undefined"==typeof document){if("undefined"==typeof OffscreenCanvas||"undefined"==typeof OffscreenCanvasRenderingContext2D)throw new Error("Cannot parse input in current context. Reason: OffscreenCanvas Context2D rendering is not supported.");$o=new OffscreenCanvas(1,1).getContext("2d")}else $o=document.createElement("canvas").getContext("2d",{willReadFrequently:!0});$o.canvas.width=u,$o.canvas.height=l,$o.drawImage(e,0,0,u,l),c=$o.getImageData(0,0,u,l).data}if(4===t)p=new Int32Array(c);else{const e=u*l;p=new Int32Array(e*t);for(let n=0;n4||2===i)throw new Error(`toPixels only supports depth of size 1, 3 or 4 but got ${i}`);if("float32"!==n.dtype&&"int32"!==n.dtype)throw new Error(`Unsupported type for toPixels: ${n.dtype}. Please use float32 or int32 tensors.`);const s=await n.data(),o="float32"===n.dtype?255:1,u=new Uint8ClampedArray(a*r*4);for(let e=0;e1)throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${a}.`)}else if("int32"===n.dtype&&(a<0||a>255))throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${a}.`);1===i?(t[0]=a*o,t[1]=a*o,t[2]=a*o):t[r]=a*o}const r=4*e;u[r+0]=Math.round(t[0]),u[r+1]=Math.round(t[1]),u[r+2]=Math.round(t[2]),u[r+3]=Math.round(t[3])}if(null!=t){t.width=a,t.height=r;const e=t.getContext("2d"),n=new ImageData(u,a,r);e.putImageData(n,0,0)}return n!==e&&n.dispose(),u}const Bo=Fi({fromPixels_:Oo});function zo(e,t){const n=e.shape.length,r=t.shape.length;if(n<1)throw new Error(`tf.gatherND() expects the input to be rank 1 or higher, but the rank was ${n}.`);if(r<1)throw new Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${r}.`);if("int32"!==t.dtype)throw new Error(`tf.gatherND() expects the indices to be int32 type, but the dtype was ${t.dtype}.`);if(t.shape[r-1]>n)throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${t.shape[r-1]} vs. ${n}`);if(0===ce(e.shape))throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${e.shape}.`);const a=t.shape,i=a[a.length-1];let s=1;for(let e=0;ee/l)),1].slice(0,i);return[u,s,l,c]}function Po(e,t,n){const r=t.rank>1?t.shape[t.rank-1]:1,a=t.rank>1?t.rank-1:1,i=`Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${n.shape}, indices.shape: ${t.shape}, shape: ${e}, sliceDim: ${r}, and batchDim: ${a}.`;if(n.rank1?t.shape[r-1]:1,i=n.length;let s=1;for(let e=a;e`Error in slice${r}D: Length of begin ${t} must match the rank of the array (${r}).`)),se(r===n.length,(()=>`Error in slice${r}D: Length of size ${n} must match the rank of the array (${r}).`));for(let a=0;a`Error in slice${r}D: begin[${a}] + size[${a}] (${t[a]+n[a]}) would overflow input.shape[${a}] (${e.shape[a]})`))}function qo(e){const t=[];let n=0;for(;e>0;)1&e&&t.push(n),e/=2,n++;return t}function Wo(e,t,n){const r=[];for(let a=0;a0){const u=t[0],l=n+1;c=Xo(s,u,l,r,e),p=Zo(o,u,l,a,e),d=Vo(i,u,l,e)}else for(let t=0;t-1)i[a]=0;else{const s=Go(t,n,a);let o=r[s];e&1<-1)i[a]=Number.MAX_SAFE_INTEGER;else{const s=Go(t,n,a);let o=r[s];e&1<0?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER);const u=r[a];return s<0&&(s+=u),s=ee(0,s,u-1),s}function tu(e,t,n,r,a,i){let s=t[a];const o=n[a]||1;(e&1<0?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER);const u=r[a];return s<0&&(s+=u),s=o>0?ee(0,s,u):ee(-1,s,u-1),s}function nu(e,t,n){let r=n.length;for(let e=0;e1){r=e;break}for(let a=r+1;a0||n[a]!==e[a])return!1;return!0}function ru(e,t){let n=e.length>0?e[e.length-1]:1;for(let r=0;r{se(-1!==e,(()=>"slice() does not support negative begin indexing."))})),i=null==n?new Array(a).fill(-1):"number"==typeof n?[n,...new Array(a-1).fill(-1)]:n.lengtht>=0?t:(se(-1===t,(()=>`Negative size values should be exactly -1 but got ${t} for the slice() size at index ${n}.`)),e.shape[n]-r[n]))),[r,i]}function iu(e,t,n,r,a,i,s,o,u){let l;if(null==r?(l=new Array(t.length),l.fill(1)):l=r,null!=s&&0!=(s&s-1))throw new Error("Multiple ellipses in slice is not allowed.");let c=!1;const p={dims:l.length,numAddAxisAfterEllipsis:0,begin:t.slice(),end:n.slice(),strides:l.slice(),beginMask:a,endMask:i,ellipsisMask:s,newAxisMask:o,shrinkAxisMask:u};for(let e=0;e0?0:-1,d.strides[t]>0?r:r-1];if(n&&d.strides[t]<=0)throw Error("only stride 1 allowed on non-range indexing.");m=m&&1===d.strides[t];const s=!!(d.beginMask&1<=r)throw Error(`slice index ${d.begin[t]} of dimension ${t} out of bounds.`)}else d.begin[t]=su(d.begin[t],0,d.strides[t],r,a,i),d.end[t]=su(d.end[t],1,d.strides[t],r,a,i);const e=1===d.strides[t]&&0===d.begin[t]&&d.end[t]===r;h=h&&e,f=f&&(0===t&&1===d.strides[t]||e)}else h=h&&1===d.strides[t]&&s,f=f&&(0===t&&1===d.strides[t]||s);let o,u=!1;if(d.beginValid&&d.endValid?(o=d.end[t]-d.begin[t],u=!0):n?(o=1,u=!0):s&&r>=0&&(o=d.strides[t]<0?-r:r,u=!0),u){let e;e=0===o||o<0!=d.strides[t]<0?0:Math.trunc(o/d.strides[t])+(o%d.strides[t]!=0?1:0),g.push(e)}else g.push(-1)}for(let e=0;e=0?y.push(g[t]):-2===t&&y.push(1)}const b=y.filter(((e,t)=>-2!==d.finalShapeGatherIndices[t]));return{finalShapeSparse:b,finalShape:y,isIdentity:h,sliceDim0:f,isSimpleSlice:m,begin:d.begin,end:d.end,strides:d.strides}}function su(e,t,n,r,a,i){if(a[t])return n>0?i[t]:i[t+1&1];{const t=e<0?r+e:e;return ti[1]?i[1]:t}}class ou{getClassName(){return this.constructor.className}static fromConfig(e,t){return new e(t)}}class uu{constructor(){this.classNameMap={}}static getMap(){return null==uu.instance&&(uu.instance=new uu),uu.instance}static register(e){uu.getMap().classNameMap[e.className]=[e,e.fromConfig]}}function lu(e){se(null!=e.className,(()=>"Class being registered does not have the static className property defined.")),se("string"==typeof e.className,(()=>"className is required to be a string, but got type "+typeof e.className)),se(e.className.length>0,(()=>"Class being registered has an empty-string as its className, which is disallowed.")),uu.register(e)}const cu=.1;function pu(e,t,n){return null==n&&(n=du()),hu(e,t,((e,t)=>yu(e,t,n)))}function du(){return 32===_i.backend.floatPrecision()?.001:cu}function hu(e,t,n){let r=!0;if((ke(e)||ke(t))&&(r=!1),ke(e)&&ke(t)&&(r=!0),r){const n=e.constructor.name,r=t.constructor.name;if(n!==r)throw new Error(`Arrays are of different type. Actual: ${n}. Expected: ${r}`)}if(Array.isArray(e)&&Array.isArray(t)){const n=Ti(e),r=Ti(t);if(!de(n,r))throw new Error(`Arrays have different shapes. Actual: [${n}]. Expected: [${r}]`)}const a=ke(e)?e:le(e),i=ke(t)?t:le(t);if(a.length!==i.length)throw new Error(`Arrays have different lengths actual: ${a.length} vs expected: ${i.length}.\nActual: ${a}.\nExpected: ${i}.`);for(let e=0;et.fail()),(()=>t()))}function mu(e,t){const n="string"==typeof t||"number"==typeof t||"boolean"==typeof t?[t]:t;return Ee(e)||Ee(e[0])||Ee(t)||Ee(t[0])?hu(e,n,((e,t)=>e==t)):hu(e,t,((e,t)=>yu(e,t,0)))}function gu(e,t,n){if(null==n&&(n=du()),!yu(e,t,n))throw new Error(`Numbers differ: actual === ${e}, expected === ${t}`)}function yu(e,t,n){return!isFinite(e)&&!isFinite(t)||!(isNaN(e)||isNaN(t)||Math.abs(e-t)>n)}function bu(e,t,n){for(let r=0;rn)throw new Error(`Value out of range:${e[r]} low: ${t}, high: ${n}`)}function vu(e,t){const n=new Float32Array(e),r=new Float32Array(t);if(n.length!==r.length)throw new Error(`Expected ArrayBuffer to be of length ${r.length}, but it was ${n.length}`);for(let e=0;e"The f passed in grad(f) must be a function")),(t,n)=>{const r=Ai(t,"x","tf.grad","string_or_numeric"),a=null!=n?Ai(n,"dy","tf.grad"):null;return _i.tidy((()=>{const{value:t,grads:n}=_i.gradients((()=>e(r)),[r],a);return null!=a&&oe(t.shape,a.shape,"The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"),$u(n),n[0]}))}}function Eu(e){return se(Fe(e),(()=>"The f passed in grads(f) must be a function")),(t,n)=>{se(Array.isArray(t),(()=>"The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s"));const r=Ii(t,"args","tf.grads","string_or_numeric"),a=null!=n?Ai(n,"dy","tf.grads"):null;return _i.tidy((()=>{const{value:t,grads:n}=_i.gradients((()=>e(...r)),r,a);return null!=a&&oe(t.shape,a.shape,"The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),$u(n),n}))}}function Au(e){return se(Fe(e),(()=>"The f passed in valueAndGrad(f) must be a function")),(t,n)=>{se(t instanceof ti,(()=>"The x passed in valueAndGrad(f)(x) must be a tensor")),se(null==n||n instanceof ti,(()=>"The dy passed in valueAndGrad(f)(x, dy) must be a tensor"));const{grads:r,value:a}=_i.gradients((()=>e(t)),[t],n);return $u(r),{grad:r[0],value:a}}}function Iu(e){return se(Fe(e),(()=>"The f passed in valueAndGrads(f) must be a function")),(t,n)=>{se(Array.isArray(t)&&t.every((e=>e instanceof ti)),(()=>"The args passed in valueAndGrads(f)(args) must be array of tensors")),se(null==n||n instanceof ti,(()=>"The dy passed in valueAndGrads(f)(args, dy) must be a tensor"));const r=_i.gradients((()=>e(...t)),t,n);return null!=n&&oe(r.value.shape,n.shape,"The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),$u(r.grads),r}}function Lu(e,t){se(Fe(e),(()=>"The f passed in variableGrads(f) must be a function")),se(null==t||Array.isArray(t)&&t.every((e=>e instanceof ri)),(()=>"The varList passed in variableGrads(f, varList) must be an array of variables"));const n=null!=t;if(!n){t=[];for(const e in _i.registeredVariables)t.push(_i.registeredVariables[e])}const r=n?t.filter((e=>!e.trainable)):null,a=t.length;t=t.filter((e=>e.trainable)),se(t.length>0,(()=>`variableGrads() expects at least one of the input variables to be trainable, but none of the ${a} variables is trainable.`));const{value:i,grads:s}=_i.gradients(e,t,null,!0);se(s.some((e=>null!=e)),(()=>"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().")),se(0===i.rank,(()=>`The f passed in variableGrads(f) must return a scalar, but it returned a rank-${i.rank} tensor`));const o={};return t.forEach(((e,t)=>{null!=s[t]&&(o[e.name]=s[t])})),null!=r&&r.forEach((e=>o[e.name]=null)),{value:i,grads:o}}function Fu(e){return _i.customGrad(e)}function $u(e){if(e.filter((e=>null==e)).length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that\n the f you passed encloses all operations that lead from x to y.")}function Ou(e,t){if((ke(e)&&"string"!==t||Array.isArray(e))&&"complex64"!==t)throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");if("string"===t&&ke(e)&&!(e instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return Oi(e,[],[],t)}class Ru extends ou{minimize(e,t=!1,n){const{value:r,grads:a}=this.computeGradients(e,n);if(null!=n){const e=n.map((e=>({name:e.name,tensor:a[e.name]})));this.applyGradients(e)}else this.applyGradients(a);return fo(a),t?r:(r.dispose(),null)}get iterations(){return null==this.iterations_&&(this.iterations_=0),this.iterations_}incrementIterations(){this.iterations_=this.iterations+1}computeGradients(e,t){return Lu(e,t)}dispose(){null!=this.iterations_&&fo(this.iterations_)}async saveIterations(){return null==this.iterations_&&(this.iterations_=0),{name:"iter",tensor:Ou(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(Ru,Symbol.hasInstance,{value:e=>null!=e.minimize&&null!=e.computeGradients&&null!=e.applyGradients});class Yu extends Ru{constructor(e,t,n=null){super(),this.learningRate=e,this.rho=t,this.epsilon=n,this.accumulatedGrads=[],this.accumulatedUpdates=[],null==n&&(this.epsilon=_i.backend.epsilon())}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=_i.registeredVariables[t];null==this.accumulatedGrads[n]&&(this.accumulatedGrads[n]={originalName:`${t}/accum_grad`,variable:ho((()=>Tu(r).variable(!1)))}),null==this.accumulatedUpdates[n]&&(this.accumulatedUpdates[n]={originalName:`${t}/accum_var`,variable:ho((()=>Tu(r).variable(!1)))});const a=Array.isArray(e)?e[n].tensor:e[t];if(null==a)return;const i=this.accumulatedGrads[n].variable,s=this.accumulatedUpdates[n].variable;ho((()=>{const e=wu(Mu(i,this.rho),Mu(ku(a),1-this.rho)),t=Mu(Nu(Su(wu(s,this.epsilon)),Su(wu(i,this.epsilon))),a),n=wu(Mu(s,this.rho),Mu(ku(t),1-this.rho));i.assign(e),s.assign(n);const o=wu(Mu(t,-this.learningRate),r);r.assign(o)}))})),this.incrementIterations()}dispose(){null!=this.accumulatedUpdates&&(fo(this.accumulatedGrads.map((e=>e.variable))),fo(this.accumulatedUpdates.map((e=>e.variable))))}async getWeights(){const e=[...this.accumulatedGrads,...this.accumulatedUpdates];return[await this.saveIterations()].concat(e.map((e=>({name:e.originalName,tensor:e.variable}))))}async setWeights(e){const t=(e=await this.extractIterations(e)).length/2;this.accumulatedGrads=e.slice(0,t).map((e=>({originalName:e.name,variable:e.tensor.variable(!1)}))),this.accumulatedUpdates=e.slice(t,2*t).map((e=>({originalName:e.name,variable:e.tensor.variable(!1)})))}getConfig(){return{learningRate:this.learningRate,rho:this.rho,epsilon:this.epsilon}}static fromConfig(e,t){return new e(t.learningRate,t.rho,t.epsilon)}}function Bu(e,t,n){const r={shape:e,value:t,dtype:n};return _i.runKernel(an,{},r)}Yu.className="Adadelta",lu(Yu);class zu extends Ru{constructor(e,t=.1){super(),this.learningRate=e,this.initialAccumulatorValue=t,this.accumulatedGrads=[]}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=_i.registeredVariables[t];if(null==this.accumulatedGrads[n]){const e=!1;this.accumulatedGrads[n]={originalName:`${t}/accumulator`,variable:ho((()=>Bu(r.shape,this.initialAccumulatorValue).variable(e)))}}const a=Array.isArray(e)?e[n].tensor:e[t];if(null==a)return;const i=this.accumulatedGrads[n].variable;ho((()=>{const e=wu(i,ku(a));i.assign(e);const t=wu(Mu(Nu(a,Su(wu(e,_i.backend.epsilon()))),-this.learningRate),r);r.assign(t)}))})),this.incrementIterations()}dispose(){null!=this.accumulatedGrads&&fo(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),this.accumulatedGrads=e.map((e=>({originalName:e.name,variable:e.tensor.variable(!1)})))}getConfig(){return{learningRate:this.learningRate,initialAccumulatorValue:this.initialAccumulatorValue}}static fromConfig(e,t){return new e(t.learningRate,t.initialAccumulatorValue)}}zu.className="Adagrad",lu(zu);const Pu=Fi({pow_:function(e,t){let n=Ai(e,"base","pow"),r=Ai(t,"exp","pow");[n,r]=di(n,r);const a={a:n,b:r};return _i.runKernel(ar,a)}}),Hu=Fi({sub_:function(e,t){let n=Ai(e,"a","sub"),r=Ai(t,"b","sub");[n,r]=di(n,r);const a={a:n,b:r};return _i.runKernel(Wr,a)}});class ju extends Ru{constructor(e,t,n,r=null){super(),this.learningRate=e,this.beta1=t,this.beta2=n,this.epsilon=r,this.accumulatedFirstMoment=[],this.accumulatedSecondMoment=[],ho((()=>{this.accBeta1=Ou(t).variable(),this.accBeta2=Ou(n).variable()})),null==r&&(this.epsilon=_i.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);ho((()=>{const n=Hu(1,this.accBeta1),r=Hu(1,this.accBeta2);t.forEach(((t,a)=>{const i=_i.registeredVariables[t];null==this.accumulatedFirstMoment[a]&&(this.accumulatedFirstMoment[a]={originalName:`${t}/m`,variable:ho((()=>Tu(i).variable(!1)))}),null==this.accumulatedSecondMoment[a]&&(this.accumulatedSecondMoment[a]={originalName:`${t}/v`,variable:ho((()=>Tu(i).variable(!1)))});const s=Array.isArray(e)?e[a].tensor:e[t];if(null==s)return;const o=this.accumulatedFirstMoment[a].variable,u=this.accumulatedSecondMoment[a].variable,l=wu(Mu(o,this.beta1),Mu(s,1-this.beta1)),c=wu(Mu(u,this.beta2),Mu(ku(s),1-this.beta2)),p=Nu(l,n),d=Nu(c,r);o.assign(l),u.assign(c);const h=wu(Mu(Nu(p,wu(Su(d),this.epsilon)),-this.learningRate),i);i.assign(h)})),this.accBeta1.assign(Mu(this.accBeta1,this.beta1)),this.accBeta2.assign(Mu(this.accBeta2,this.beta2))})),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.accBeta2.dispose(),null!=this.accumulatedFirstMoment&&fo(this.accumulatedFirstMoment.map((e=>e.variable))),null!=this.accumulatedSecondMoment&&fo(this.accumulatedSecondMoment.map((e=>e.variable)))}async getWeights(){const e=[...this.accumulatedFirstMoment,...this.accumulatedSecondMoment];return[await this.saveIterations()].concat(e.map((e=>({name:e.originalName,tensor:e.variable}))))}async setWeights(e){e=await this.extractIterations(e),ho((()=>{this.accBeta1.assign(Pu(this.beta1,this.iterations_+1)),this.accBeta2.assign(Pu(this.beta2,this.iterations_+1))}));const t=e.length/2;this.accumulatedFirstMoment=e.slice(0,t).map((e=>({originalName:e.name,variable:e.tensor.variable(!1)}))),this.accumulatedSecondMoment=e.slice(t,2*t).map((e=>({originalName:e.name,variable:e.tensor.variable(!1)})))}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)}}ju.className="Adam",lu(ju);const Uu=Fi({abs_:function(e){const t=Ai(e,"x","abs");if("complex64"===t.dtype){const e={x:t};return _i.runKernel(St,e)}{const e={x:t};return _i.runKernel(Qe,e)}}}),qu=Fi({maximum_:function(e,t){let n=Ai(e,"a","maximum"),r=Ai(t,"b","maximum");[n,r]=di(n,r),"bool"===n.dtype&&(n=Ls(n,"int32"),r=Ls(r,"int32")),Lo(n.shape,r.shape);const a={a:n,b:r};return _i.runKernel($n,a)}});class Wu extends Ru{constructor(e,t,n,r=null,a=0){super(),this.learningRate=e,this.beta1=t,this.beta2=n,this.epsilon=r,this.decay=a,this.accumulatedFirstMoment=[],this.accumulatedWeightedInfNorm=[],ho((()=>{this.iteration=Ou(0).variable(),this.accBeta1=Ou(t).variable()})),null==r&&(this.epsilon=_i.backend.epsilon())}applyGradients(e){const t=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);ho((()=>{const n=Hu(1,this.accBeta1),r=Nu(-this.learningRate,wu(Mu(this.iteration,this.decay),1));t.forEach(((t,a)=>{const i=_i.registeredVariables[t];null==this.accumulatedFirstMoment[a]&&(this.accumulatedFirstMoment[a]={originalName:`${t}/m`,variable:Tu(i).variable(!1)}),null==this.accumulatedWeightedInfNorm[a]&&(this.accumulatedWeightedInfNorm[a]={originalName:`${t}/v`,variable:Tu(i).variable(!1)});const s=Array.isArray(e)?e[a].tensor:e[t];if(null==s)return;const o=this.accumulatedFirstMoment[a].variable,u=this.accumulatedWeightedInfNorm[a].variable,l=wu(Mu(o,this.beta1),Mu(s,1-this.beta1)),c=Mu(u,this.beta2),p=Uu(s),d=qu(c,p);o.assign(l),u.assign(d);const h=wu(Mu(Nu(r,n),Nu(l,wu(d,this.epsilon))),i);i.assign(h)})),this.iteration.assign(wu(this.iteration,1)),this.accBeta1.assign(Mu(this.accBeta1,this.beta1))})),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.iteration.dispose(),null!=this.accumulatedFirstMoment&&fo(this.accumulatedFirstMoment.map((e=>e.variable))),null!=this.accumulatedWeightedInfNorm&&fo(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)}}Wu.className="Adamax",lu(Wu);class Vu extends Ru{constructor(e){super(),this.learningRate=e,this.setLearningRate(e)}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=Array.isArray(e)?e[n].tensor:e[t];if(null==r)return;const a=_i.registeredVariables[t];ho((()=>{const e=wu(Mu(this.c,r),a);a.assign(e)}))})),this.incrementIterations()}setLearningRate(e){this.learningRate=e,null!=this.c&&this.c.dispose(),this.c=mo(Ou(-e))}dispose(){this.c.dispose()}async getWeights(){return[await this.saveIterations()]}async setWeights(e){if(0!==(e=await this.extractIterations(e)).length)throw new Error("SGD optimizer does not have settable weights.")}getConfig(){return{learningRate:this.learningRate}}static fromConfig(e,t){return new e(t.learningRate)}}Vu.className="SGD",lu(Vu);class Gu extends Vu{constructor(e,t,n=!1){super(e),this.learningRate=e,this.momentum=t,this.useNesterov=n,this.accumulations=[],this.m=Ou(this.momentum)}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=_i.registeredVariables[t];if(null==this.accumulations[n]){const e=!1;this.accumulations[n]={originalName:`${t}/momentum`,variable:ho((()=>Tu(r).variable(e)))}}const a=this.accumulations[n].variable,i=Array.isArray(e)?e[n].tensor:e[t];null!=i&&ho((()=>{let e;const t=wu(Mu(this.m,a),i);e=this.useNesterov?wu(Mu(this.c,wu(i,Mu(t,this.m))),r):wu(Mu(this.c,t),r),a.assign(t),r.assign(e)}))})),this.incrementIterations()}dispose(){this.m.dispose(),null!=this.accumulations&&fo(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),this.accumulations=e.map((e=>({originalName:e.name,variable:e.tensor.variable(!1)})))}getConfig(){return{learningRate:this.learningRate,momentum:this.momentum,useNesterov:this.useNesterov}}static fromConfig(e,t){return new e(t.learningRate,t.momentum,t.useNesterov)}}Gu.className="Momentum",lu(Gu);class Ku extends Ru{constructor(e,t=.9,n=0,r=null,a=!1){if(super(),this.learningRate=e,this.decay=t,this.momentum=n,this.epsilon=r,this.accumulatedMeanSquares=[],this.accumulatedMoments=[],this.accumulatedMeanGrads=[],this.centered=a,null==r&&(this.epsilon=_i.backend.epsilon()),null==e)throw new Error("learningRate for RMSPropOptimizer must be defined.")}applyGradients(e){(Array.isArray(e)?e.map((e=>e.name)):Object.keys(e)).forEach(((t,n)=>{const r=_i.registeredVariables[t],a=!1;null==this.accumulatedMeanSquares[n]&&(this.accumulatedMeanSquares[n]={originalName:`${t}/rms`,variable:ho((()=>Tu(r).variable(a)))}),null==this.accumulatedMoments[n]&&(this.accumulatedMoments[n]={originalName:`${t}/momentum`,variable:ho((()=>Tu(r).variable(a)))}),null==this.accumulatedMeanGrads[n]&&this.centered&&(this.accumulatedMeanGrads[n]={originalName:`${t}/mg`,variable:ho((()=>Tu(r).variable(a)))});const i=Array.isArray(e)?e[n].tensor:e[t];if(null==i)return;const s=this.accumulatedMeanSquares[n].variable,o=this.accumulatedMoments[n].variable;ho((()=>{const e=wu(Mu(s,this.decay),Mu(ku(i),1-this.decay));if(this.centered){const t=this.accumulatedMeanGrads[n].variable,a=wu(Mu(t,this.decay),Mu(i,1-this.decay)),u=Nu(Mu(i,this.learningRate),Su(Hu(e,wu(ku(a),this.epsilon)))),l=wu(Mu(o,this.momentum),u);s.assign(e),t.assign(a),o.assign(l);const c=Hu(r,l);r.assign(c)}else{const e=wu(Mu(s,this.decay),Mu(ku(i),1-this.decay)),t=wu(Mu(o,this.momentum),Nu(Mu(i,this.learningRate),Su(wu(e,this.epsilon))));s.assign(e),o.assign(t);const n=Hu(r,t);r.assign(n)}}))})),this.incrementIterations()}dispose(){null!=this.accumulatedMeanSquares&&fo(this.accumulatedMeanSquares.map((e=>e.variable))),null!=this.accumulatedMeanGrads&&this.centered&&fo(this.accumulatedMeanGrads.map((e=>e.variable))),null!=this.accumulatedMoments&&fo(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((e=>({name:e.originalName,tensor:e.variable}))))}async setWeights(e){e=await this.extractIterations(e);const t=this.centered?e.length/3:e.length/2,n=!1;this.accumulatedMeanSquares=e.slice(0,t).map((e=>({originalName:e.name,variable:e.tensor.variable(n)}))),this.accumulatedMoments=e.slice(t,2*t).map((e=>({originalName:e.name,variable:e.tensor.variable(n)}))),this.centered&&(this.accumulatedMeanGrads=e.slice(2*t,3*t).map((e=>({originalName:e.name,variable:e.tensor.variable(n)}))))}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)}}Ku.className="RMSProp",lu(Ku);class Ju{static sgd(e){return new Vu(e)}static momentum(e,t,n=!1){return new Gu(e,t,n)}static rmsprop(e,t=.9,n=0,r=null,a=!1){return new Ku(e,t,n,r,a)}static adam(e=.001,t=.9,n=.999,r=null){return new ju(e,t,n,r)}static adadelta(e=.001,t=.95,n=null){return new Yu(e,t,n)}static adamax(e=.002,t=.9,n=.999,r=null,a=0){return new Wu(e,t,n,r,a)}static adagrad(e,t=.1){return new zu(e,t)}}const Xu=Fi({acos_:function(e){const t={x:Ai(e,"x","acos")};return _i.runKernel(et,t)}}),Zu=Fi({acosh_:function(e){const t={x:Ai(e,"x","acosh")};return _i.runKernel(tt,t)}}),Qu=Fi({addN_:function(e){se(Array.isArray(e),(()=>"The argument passed to tf.addN() must be a list of tensors")),se(e.length>=1,(()=>`Must pass at least one tensor to tf.addN(), but got ${e.length}`));const t=e.map(((e,t)=>Ai(e,`tensors${t}`,"addN"))),n=t[0];t.forEach((e=>{if(e.dtype!==n.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")})),t.forEach((e=>{if(!de(e.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")}));const r=t;return _i.runKernel(rt,r)}}),el=Fi({all_:function(e,t=null,n=!1){const r={x:Ai(e,"x","all","bool")},a={axis:t,keepDims:n};return _i.runKernel(at,r,a)}}),tl=Fi({any_:function(e,t=null,n=!1){const r={x:Ai(e,"x","any","bool")},a={axis:t,keepDims:n};return _i.runKernel(it,r,a)}}),nl=Fi({argMax_:function(e,t=0){const n={x:Ai(e,"x","argMax")},r={axis:t};return _i.runKernel(st,n,r)}}),rl=Fi({argMin_:function(e,t=0){const n={x:Ai(e,"x","argMin")},r={axis:t};return _i.runKernel(ot,n,r)}}),al=Fi({asin_:function(e){const t={x:Ai(e,"x","asin")};return _i.runKernel(ut,t)}}),il=Fi({asinh_:function(e){const t={x:Ai(e,"x","asinh")};return _i.runKernel(lt,t)}}),sl=Fi({atan_:function(e){const t={x:Ai(e,"x","atan")};return _i.runKernel(ct,t)}}),ol=Fi({atan2_:function(e,t){let n=Ai(e,"a","atan2"),r=Ai(t,"b","atan2");[n,r]=di(n,r);const a={a:n,b:r};return _i.runKernel(dt,a)}}),ul=Fi({atanh_:function(e){const t={x:Ai(e,"x","atanh")};return _i.runKernel(pt,t)}});function ll(e,t,n,r,a="NHWC",i){return dl(e,[...t,e[3]],n,i,r,null,null,_l(a))}function cl(e,t,n,r,a,i,s="channelsLast"){const[o,u]=ml(t);let l;if("channelsLast"===s)l=[o,u,e[3],e[3]];else{if("channelsFirst"!==s)throw new Error(`Unknown dataFormat ${s}`);l=[o,u,e[1],e[1]]}return dl(e,l,n,r,a,i,!1,s)}function pl(e,t,n,r,a,i,s="NDHWC"){const[o,u,l]=gl(t);let c,p;if("NDHWC"===s)p="channelsLast",c=[o,u,l,e[4],e[4]];else{if("NCDHW"!==s)throw new Error(`Unknown dataFormat ${s}`);p="channelsFirst",c=[o,u,l,e[1],e[1]]}return hl(e,c,n,r,a,!1,p,i)}function dl(e,t,n,r,a,i,s=!1,o="channelsLast"){let[u,l,c,p]=[-1,-1,-1,-1];if("channelsLast"===o)[u,l,c,p]=e;else{if("channelsFirst"!==o)throw new Error(`Unknown dataFormat ${o}`);[u,p,l,c]=e}const[d,h,,f]=t,[m,g]=ml(n),[y,b]=ml(r),v=yl(d,y),x=yl(h,b),{padInfo:_,outHeight:w,outWidth:D}=function(e,t,n,r,a,i,s,o,u){let l,c,p;if("number"==typeof e){l={top:e,bottom:e,left:e,right:e,type:0===e?"VALID":"NUMBER"};const a=function(e,t,n,r,a){null==r&&(r=fl(e,t,n));const i=e[1];return[bl((e[0]-t+2*r)/n+1,a),bl((i-t+2*r)/n+1,a)]}([t,n],i,r,e,o);c=a[0],p=a[1]}else if("same"===e){c=Math.ceil(t/r),p=Math.ceil(n/a);const e=Math.max(0,(c-1)*r+i-t),o=Math.max(0,(p-1)*a+s-n),u=Math.floor(e/2),d=e-u,h=Math.floor(o/2);l={top:u,bottom:d,left:h,right:o-h,type:"SAME"}}else if("valid"===e)l={top:0,bottom:0,left:0,right:0,type:"VALID"},c=Math.ceil((t-i+1)/r),p=Math.ceil((n-s+1)/a);else{if("object"!=typeof e)throw Error(`Unknown padding parameter: ${e}`);{const d="channelsLast"===u?e[1][0]:e[2][0],h="channelsLast"===u?e[1][1]:e[2][1],f="channelsLast"===u?e[2][0]:e[3][0],m="channelsLast"===u?e[2][1]:e[3][1];l={top:d,bottom:h,left:f,right:m,type:0===d&&0===h&&0===f&&0===m?"VALID":"EXPLICIT"},c=bl((t-i+d+h)/r+1,o),p=bl((n-s+f+m)/a+1,o)}}return{padInfo:l,outHeight:c,outWidth:p}}(a,l,c,m,g,v,x,i,o),N=s?f*p:f;let M;return"channelsFirst"===o?M=[u,N,w,D]:"channelsLast"===o&&(M=[u,w,D,N]),{batchSize:u,dataFormat:o,inHeight:l,inWidth:c,inChannels:p,outHeight:w,outWidth:D,outChannels:N,padInfo:_,strideHeight:m,strideWidth:g,filterHeight:d,filterWidth:h,effectiveFilterHeight:v,effectiveFilterWidth:x,dilationHeight:y,dilationWidth:b,inShape:e,outShape:M,filterShape:t}}function hl(e,t,n,r,a,i=!1,s="channelsLast",o){let[u,l,c,p,d]=[-1,-1,-1,-1,-1];if("channelsLast"===s)[u,l,c,p,d]=e;else{if("channelsFirst"!==s)throw new Error(`Unknown dataFormat ${s}`);[u,d,l,c,p]=e}const[h,f,m,,g]=t,[y,b,v]=gl(n),[x,_,w]=gl(r),D=yl(h,x),N=yl(f,_),M=yl(m,w),{padInfo:S,outDepth:k,outHeight:T,outWidth:C}=function(e,t,n,r,a,i,s,o,u,l,c){let p,d,h,f;if("number"==typeof e){p={top:e,bottom:e,left:e,right:e,front:e,back:e,type:0===e?"VALID":"NUMBER"};const i=function(e,t,n,r,a,i){null==a&&(a=fl(e,t,r));const s=e[1],o=e[2];return[bl((e[0]-t+2*a)/r+1,i),bl((s-t+2*a)/r+1,i),bl((o-t+2*a)/r+1,i),1]}([t,n,r,1],o,0,a,e,c);d=i[0],h=i[1],f=i[2]}else if("same"===e){d=Math.ceil(t/a),h=Math.ceil(n/i),f=Math.ceil(r/s);const e=(d-1)*a+o-t,c=(h-1)*i+u-n,m=(f-1)*s+l-r,g=Math.floor(e/2),y=e-g,b=Math.floor(c/2),v=c-b,x=Math.floor(m/2);p={top:b,bottom:v,left:x,right:m-x,front:g,back:y,type:"SAME"}}else{if("valid"!==e)throw Error(`Unknown padding parameter: ${e}`);p={top:0,bottom:0,left:0,right:0,front:0,back:0,type:"VALID"},d=Math.ceil((t-o+1)/a),h=Math.ceil((n-u+1)/i),f=Math.ceil((r-l+1)/s)}return{padInfo:p,outDepth:d,outHeight:h,outWidth:f}}(a,l,c,p,y,b,v,D,N,M,o),E=i?g*d:g;let A;return"channelsFirst"===s?A=[u,E,k,T,C]:"channelsLast"===s&&(A=[u,k,T,C,E]),{batchSize:u,dataFormat:s,inDepth:l,inHeight:c,inWidth:p,inChannels:d,outDepth:k,outHeight:T,outWidth:C,outChannels:E,padInfo:S,strideDepth:y,strideHeight:b,strideWidth:v,filterDepth:h,filterHeight:f,filterWidth:m,effectiveFilterDepth:D,effectiveFilterHeight:N,effectiveFilterWidth:M,dilationDepth:x,dilationHeight:_,dilationWidth:w,inShape:e,outShape:A,filterShape:t}}function fl(e,t,n,r=1){const a=yl(t,r);return Math.floor((e[0]*(n-1)-n+a)/2)}function ml(e){return"number"==typeof e?[e,e,e]:2===e.length?[e[0],e[1],1]:e}function gl(e){return"number"==typeof e?[e,e,e]:e}function yl(e,t){return t<=1?e:e+(e-1)*(t-1)}function bl(e,t){if(!t)return Math.trunc(e);switch(t){case"round":return Math.round(e);case"ceil":return Math.ceil(e);case"floor":return Math.floor(e);default:throw new Error(`Unknown roundingMode ${t}`)}}function vl(e){const[t,n,r]=ml(e);return 1===t&&1===n&&1===r}function xl(e,t){return vl(e)||vl(t)}function _l(e){if("NHWC"===e)return"channelsLast";if("NCHW"===e)return"channelsFirst";throw new Error(`Unknown dataFormat ${e}`)}function wl(e,t,n){if(null!=n){if("string"==typeof t)throw Error(`Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`);if("number"==typeof t)se(he(t),(()=>`Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`));else{if("object"!=typeof t)throw Error(`Error in ${e}: Unknown padding parameter: ${t}`);t.forEach((t=>{t.forEach((t=>{se(he(t),(()=>`Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`))}))}))}}}const Dl=Fi({reshape_:function(e,t){const n={x:Ai(e,"x","reshape","string_or_numeric")},r={shape:t};return _i.runKernel(pr,n,r)}}),Nl=Fi({avgPool_:function(e,t,n,r,a){const i=Ai(e,"x","avgPool","float32");se(xl(n,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`));let s=i,o=!1;3===i.rank&&(o=!0,s=Dl(i,[1,i.shape[0],i.shape[1],i.shape[2]])),se(4===s.rank,(()=>`Error in avgPool: x must be rank 4 but got rank ${s.rank}.`)),wl("avgPool",r,a);const u={x:s},l={filterSize:t,strides:n,pad:r,dimRoundingMode:a};let c=_i.runKernel(ht,u,l);return c=Ls(c,i.dtype),o?Dl(c,[c.shape[1],c.shape[2],c.shape[3]]):c}}),Ml=Fi({avgPool3d_:function(e,t,n,r,a,i="NDHWC"){const s=Ai(e,"x","avgPool3d","float32");let o=s,u=!1;4===s.rank&&(u=!0,o=Dl(s,[1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]])),se(5===o.rank,(()=>`Error in avgPool3d: x must be rank 5 but got rank ${o.rank}.`)),se("NDHWC"===i,(()=>`Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${i}`)),wl("avgPool3d",r,a);const l={x:o},c={filterSize:t,strides:n,pad:r,dimRoundingMode:a,dataFormat:i};let p=_i.runKernel(mt,l,c);return p=Ls(p,o.dtype),u?Dl(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}}),Sl=Fi({concat_:function(e,t=0){se(e.length>=1,(()=>"Pass at least one tensor to concat"));const n=Ii(e,"tensors","concat","string_or_numeric");if("complex64"===n[0].dtype&&n.forEach((e=>{if("complex64"!==e.dtype)throw new Error(`Cannot concatenate complex64 tensors with a tensor\n with dtype ${e.dtype}. `)})),1===n.length)return Fs(n[0]);const r=n,a={axis:t};return _i.runKernel(kt,r,a)}}),kl=Fi({sigmoid_:function(e){const t={x:Ai(e,"x","sigmoid","float32")};return _i.runKernel(Tr,t)}}),Tl=Fi({slice_:function(e,t,n){const r=Ai(e,"x","slice","string_or_numeric");if(0===r.rank)throw new Error("Slicing scalar is not possible");const a={x:r},i={begin:t,size:n};return _i.runKernel(Nr,a,i)}}),Cl=Fi({tanh_:function(e){const t={x:Ai(e,"x","tanh","float32")};return _i.runKernel(Gr,t)}}),El=Fi({basicLSTMCell_:function(e,t,n,r,a,i){const s=Ai(e,"forgetBias","basicLSTMCell"),o=Ai(t,"lstmKernel","basicLSTMCell"),u=Ai(n,"lstmBias","basicLSTMCell"),l=Ai(r,"data","basicLSTMCell"),c=Ai(a,"c","basicLSTMCell"),p=Ai(i,"h","basicLSTMCell"),d=Sl([l,p],1),h=no(d,o),f=wu(h,u),m=f.shape[0],g=f.shape[1]/4,y=[m,g],b=Tl(f,[0,0],y),v=Tl(f,[0,g],y),x=Tl(f,[0,2*g],y),_=Tl(f,[0,3*g],y),w=wu(Mu(kl(b),Cl(v)),Mu(c,kl(wu(s,x))));return[w,Mu(Cl(w),kl(_))]}}),Al=Fi({batchToSpaceND_:function(e,t,n){const r=Ai(e,"x","batchToSpaceND"),a=t.reduce(((e,t)=>e*t));se(r.rank>=1+t.length,(()=>`input rank is ${r.rank} but should be > than blockShape.length ${t.length}`)),se(n.length===t.length,(()=>`crops.length is ${n.length} but should be equal to blockShape.length ${t.length}`)),se(r.shape[0]%a==0,(()=>`input tensor batch is ${r.shape[0]} but is not divisible by the product of the elements of blockShape ${t.join(" * ")} === ${a}`));const i={x:r},s={blockShape:t,crops:n};return _i.runKernel(bt,i,s)}}),Il=Fi({batchNorm_:function(e,t,n,r,a,i){null==i&&(i=.001);const s=Ai(e,"x","batchNorm"),o=Ai(t,"mean","batchNorm"),u=Ai(n,"variance","batchNorm");let l,c;null!=a&&(l=Ai(a,"scale","batchNorm")),null!=r&&(c=Ai(r,"offset","batchNorm")),se(o.rank===u.rank,(()=>"Batch normalization gradient requires mean and variance to have equal ranks.")),se(null==c||o.rank===c.rank,(()=>"Batch normalization gradient requires mean and offset to have equal ranks.")),se(null==l||o.rank===l.rank,(()=>"Batch normalization gradient requires mean and scale to have equal ranks."));const p=function(e){let t;return t=0===e.rank||1===e.rank?Dl(e,[1,1,1,e.size]):2===e.rank?Dl(e,[1,1,e.shape[0],e.shape[1]]):3===e.rank?Dl(e,[1,e.shape[0],e.shape[1],e.shape[2]]):e,t}(s),d={x:p,scale:l,offset:c,mean:o,variance:u},h={varianceEpsilon:i},f=_i.runKernel(ln,d,h);return Dl(f,s.shape)}}),Ll=Fi({batchNorm2d_:function(e,t,n,r,a,i){const s=Ai(e,"x","batchNorm"),o=Ai(t,"mean","batchNorm"),u=Ai(n,"variance","batchNorm");let l,c;return null!=a&&(l=Ai(a,"scale","batchNorm")),null!=r&&(c=Ai(r,"offset","batchNorm")),se(2===s.rank,(()=>`Error in batchNorm2D: x must be rank 2 but got rank ${s.rank}.`)),se(2===o.rank||1===o.rank,(()=>`Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${o.rank}.`)),se(2===u.rank||1===u.rank,(()=>`Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${u.rank}.`)),null!=l&&se(2===l.rank||1===l.rank,(()=>`Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${l.rank}.`)),null!=c&&se(2===c.rank||1===c.rank,(()=>`Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${c.rank}.`)),Il(s,o,u,c,l,i)}}),Fl=Fi({batchNorm3d_:function(e,t,n,r,a,i){const s=Ai(e,"x","batchNorm"),o=Ai(t,"mean","batchNorm"),u=Ai(n,"variance","batchNorm");let l,c;return null!=a&&(l=Ai(a,"scale","batchNorm")),null!=r&&(c=Ai(r,"offset","batchNorm")),se(3===s.rank,(()=>`Error in batchNorm3D: x must be rank 3 but got rank ${s.rank}.`)),se(3===o.rank||1===o.rank,(()=>`Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${o.rank}.`)),se(3===u.rank||1===u.rank,(()=>`Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${u.rank}.`)),null!=l&&se(3===l.rank||1===l.rank,(()=>`Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${l.rank}.`)),null!=c&&se(3===c.rank||1===c.rank,(()=>`Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${c.rank}.`)),Il(s,o,u,c,l,i)}}),$l=Fi({batchNorm4d_:function(e,t,n,r,a,i){const s=Ai(e,"x","batchNorm"),o=Ai(t,"mean","batchNorm"),u=Ai(n,"variance","batchNorm");let l,c;return null!=a&&(l=Ai(a,"scale","batchNorm")),null!=r&&(c=Ai(r,"offset","batchNorm")),se(4===s.rank,(()=>`Error in batchNorm4D: x must be rank 4 but got rank ${s.rank}.`)),se(4===o.rank||1===o.rank,(()=>`Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${o.rank}.`)),se(4===u.rank||1===u.rank,(()=>`Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${u.rank}.`)),null!=l&&se(4===l.rank||1===l.rank,(()=>`Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${l.rank}.`)),null!=c&&se(4===c.rank||1===c.rank,(()=>`Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${c.rank}.`)),Il(s,o,u,c,l,i)}}),Ol=Fi({bincount_:function(e,t,n){const r=Ai(e,"x","bincount"),a=Ai(t,"weights","bincount");se("int32"===r.dtype,(()=>`Error in bincount: input dtype must be int32, but got ${r.dtype}`)),se(n>=0,(()=>`size must be non-negative, but got ${n}.`)),se(a.size===r.size||0===a.size,(()=>`Error in bincount: weights must have the same size as input or0-length, but got input shape: ${r.shape}, weights shape: ${a.shape}.`));const i={x:r,weights:a},s={size:n};return _i.runKernel(vt,i,s)}}),Rl=Fi({broadcastArgs_:function(e,t){const n=Ai(e,"s0","broadcastArgs","int32"),r=Ai(t,"s1","broadcastArgs","int32");if(1!==n.rank)throw new Error(`broadcastArgs(): first input must be a vector (rank=1). Has rank ${n.rank}`);if(1!==r.rank)throw new Error(`broadcastArgs(): second input must be a vector (rank=1). Has rank ${r.rank}`);const a={s0:n,s1:r};return _i.runKernel(_t,a)}}),Yl=Fi({broadcastTo_:function(e,t){let n=Ai(e,"broadcastTo","x");const r=n.shape;if(t.some((e=>!(e>0)||e%1!=0)))throw new Error(`broadcastTo(): Invalid broadcast shape [${t}].`);if(t.lengthn.rank){const e=n.shape.slice();for(;e.length=0;e--)if(a[e]===t[e])i[e]=1;else if(1!==n.shape[e])throw new Error(`broadcastTo(): [${r}] cannot be broadcast to [${t}].`);const s=i.map(((e,t)=>e>1?t:-1)).filter((e=>e>=0));if(0===s.length)return Fs(n);const o={x:n},u={reps:i};return _i.runKernel(Kr,o,u)}}),Bl=Fi({ceil_:function(e){const t={x:Ai(e,"x","ceil","float32")};return _i.runKernel(Dt,t)}}),zl=Fi({clipByValue_:function(e,t,n){const r=Ai(e,"x","clipByValue");se(t<=n,(()=>`Error in clip: min (${t}) must be less than or equal to max (${n}).`));const a={x:r},i={clipValueMin:t,clipValueMax:n};return _i.runKernel(Nt,a,i)}}),Pl=Fi({concat1d_:function(e){return Sl(e,0)}}),Hl=Fi({concat2d_:function(e,t){return Sl(e,t)}}),jl=Fi({concat3d_:function(e,t){return Sl(e,t)}}),Ul=Fi({concat4d_:function(e,t){return Sl(e,t)}}),ql=Fi({conv2d_:function(e,t,n,r,a="NHWC",i=[1,1],s){const o=Ai(e,"x","conv2d","float32"),u=Ai(t,"filter","conv2d","float32");let l=o,c=!1;3===o.rank&&(c=!0,l=Dl(o,[1,o.shape[0],o.shape[1],o.shape[2]])),se(4===l.rank,(()=>`Error in conv2d: input must be rank 4, but got rank ${l.rank}.`)),se(4===u.rank,(()=>`Error in conv2d: filter must be rank 4, but got rank ${u.rank}.`)),wl("conv2d",r,s);const p="NHWC"===a?l.shape[3]:l.shape[1];se(p===u.shape[2],(()=>`Error in conv2d: depth of input (${p}) must match input depth for filter ${u.shape[2]}.`)),se(xl(n,i),(()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${i}'`));const d={x:l,filter:u},h={strides:n,pad:r,dataFormat:a,dilations:i,dimRoundingMode:s},f=_i.runKernel(Tt,d,h);return c?Dl(f,[f.shape[1],f.shape[2],f.shape[3]]):f}}),Wl=Fi({conv1d_:function(e,t,n,r,a="NWC",i=1,s){const o=Ai(e,"x","conv1d"),u=Ai(t,"filter","conv1d");let l=o,c=!1;2===o.rank&&(c=!0,l=Dl(o,[1,o.shape[0],o.shape[1]])),se(3===l.rank,(()=>`Error in conv1d: input must be rank 3, but got rank ${l.rank}.`)),se(3===u.rank,(()=>`Error in conv1d: filter must be rank 3, but got rank ${u.rank}.`)),wl("conv1d",r,s),se(l.shape[2]===u.shape[1],(()=>`Error in conv1d: depth of input (${l.shape[2]}) must match input depth for filter ${u.shape[1]}.`)),se(xl(n,i),(()=>`Error in conv1D: Either stride or dilation must be 1. Got stride ${n} and dilation '${i}'`)),se("NWC"===a,(()=>`Error in conv1d: got dataFormat of ${a} but only NWC is currently supported.`));const p=Dl(u,[1,u.shape[0],u.shape[1],u.shape[2]]),d=Dl(l,[l.shape[0],1,l.shape[1],l.shape[2]]),h=ql(d,p,[1,n],r,"NHWC",[1,i],s);return Dl(h,c?[h.shape[2],h.shape[3]]:[h.shape[0],h.shape[2],h.shape[3]])}}),Vl=Fi({conv2DBackpropInput_:function(e,t,n,r,a,i="NHWC",s){se(e.length===t.rank,(()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`));let o=e,u=t,l=!1;3===t.rank&&(l=!0,u=Dl(t,[1,t.shape[0],t.shape[1],t.shape[2]]),o=[1,e[0],e[1],e[2]]),se(4===o.length,(()=>`Error in conv2dDerInput: inShape must be length 4, but got length ${o.length}.`)),se(4===u.rank,(()=>`Error in conv2dDerInput: dy must be rank 4, but got rank ${u.rank}`)),se(4===n.rank,(()=>`Error in conv2dDerInput: filter must be rank 4, but got rank ${n.rank}`));const c="NHWC"===i?o[3]:o[1],p="NHWC"===i?u.shape[3]:u.shape[1];se(c===n.shape[2],(()=>`Error in conv2dDerInput: depth of input (${c}) must match input depth for filter ${n.shape[2]}.`)),se(p===n.shape[3],(()=>`Error in conv2dDerInput: depth of output (${p}) must match output depth for filter ${n.shape[3]}.`)),wl("conv2dDerInput",a,s);const d={dy:u,filter:n},h={strides:r,pad:a,dataFormat:i,dimRoundingMode:s,inputShape:o},f=_i.runKernel(Et,d,h);return l?Dl(f,[f.shape[1],f.shape[2],f.shape[3]]):f}}),Gl=Fi({conv2dTranspose_:function(e,t,n,r,a,i){const s=Ai(e,"x","conv2dTranspose"),o=Ai(t,"filter","conv2dTranspose");return Vl(n,s,o,r,a,"NHWC",i)}}),Kl=Fi({conv3d_:function(e,t,n,r,a="NDHWC",i=[1,1,1]){const s=Ai(e,"x","conv3d"),o=Ai(t,"filter","conv3d");let u=s,l=!1;4===s.rank&&(l=!0,u=Dl(s,[1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]])),se(5===u.rank,(()=>`Error in conv3d: input must be rank 5, but got rank ${u.rank}.`)),se(5===o.rank,(()=>`Error in conv3d: filter must be rank 5, but got rank ${o.rank}.`)),se(u.shape[4]===o.shape[3],(()=>`Error in conv3d: depth of input (${u.shape[4]}) must match input depth for filter ${o.shape[3]}.`)),se(xl(n,i),(()=>`Error in conv3D: Either strides or dilations must be 1. Got strides ${n} and dilations '${i}'`)),se("NDHWC"===a,(()=>`Error in conv3d: got dataFormat of ${a} but only NDHWC is currently supported.`));const c={x:u,filter:o},p={strides:n,pad:r,dataFormat:a,dilations:i},d=_i.runKernel(At,c,p);return l?Dl(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}}),Jl=Fi({conv3DBackpropInput_:function(e,t,n,r,a){se(e.length===t.rank,(()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`));let i=e,s=t,o=!1;4===t.rank&&(o=!0,s=Dl(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]]),i=[1,e[0],e[1],e[2],e[3]]);const u=i[4],l=s.shape[4];se(5===i.length,(()=>`Error in conv3dDerInput: inShape must be length 5, but got length ${i.length}.`)),se(5===s.rank,(()=>`Error in conv3dDerInput: dy must be rank 5, but got rank ${s.rank}`)),se(5===n.rank,(()=>`Error in conv3dDerInput: filter must be rank 5, but got rank ${n.rank}`)),se(u===n.shape[3],(()=>`Error in conv3dDerInput: depth of input (${u}) must match input depth for filter ${n.shape[3]}.`)),se(l===n.shape[4],(()=>`Error in conv3dDerInput: depth of output (${l}) must match output depth for filter ${n.shape[4]}.`));const c={dy:s,filter:n},p={pad:a,strides:r,inputShape:i},d=_i.runKernel(Lt,c,p);return o?Dl(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}}),Xl=Fi({conv3dTranspose_:function(e,t,n,r,a){const i=Ai(e,"x","conv3dTranspose"),s=Ai(t,"filter","conv3dTranspose");return Jl(n,i,s,r,a)}}),Zl=Fi({cos_:function(e){const t={x:Ai(e,"x","cos","float32")};return _i.runKernel(Ft,t)}}),Ql=Fi({cosh_:function(e){const t={x:Ai(e,"x","cosh","float32")};return _i.runKernel($t,t)}}),ec=Fi({cumprod_:function(e,t=0,n=!1,r=!1){const a={x:Ai(e,"x","cumprod")},i={axis:t,exclusive:n,reverse:r};return _i.runKernel(Ot,a,i)}}),tc=Fi({cumsum_:function(e,t=0,n=!1,r=!1){const a={x:Ai(e,"x","cumsum")},i={axis:t,exclusive:n,reverse:r};return _i.runKernel(Rt,a,i)}}),nc=Fi({denseBincount_:function(e,t,n,r=!1){const a=Ai(e,"x","denseBincount"),i=Ai(t,"weights","denseBincount");se("int32"===a.dtype,(()=>`Error in denseBincount: input dtype must be int32, but got ${a.dtype}`)),se(a.rank<=2,(()=>`Error in denseBincount: input must be at most rank 2, but got rank ${a.rank}.`)),se(n>=0,(()=>`size must be non-negative, but got ${n}.`)),se(i.size===a.size||0===i.size,(()=>`Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${a.shape}, weights shape: ${i.shape}.`));const s={x:a,weights:i},o={size:n,binaryOutput:r};return _i.runKernel(Bt,s,o)}}),rc=Fi({depthToSpace_:function(e,t,n="NHWC"){const r=Ai(e,"x","depthToSpace","float32"),a="NHWC"===n?r.shape[1]:r.shape[2],i="NHWC"===n?r.shape[2]:r.shape[3],s="NHWC"===n?r.shape[3]:r.shape[1];se(t>1,(()=>`blockSize should be > 1 for depthToSpace, but was: ${t}`)),se(a*t>=0,(()=>`Negative dimension size caused by overflow when multiplying\n ${a} and ${t} for depthToSpace with input shape\n ${r.shape}`)),se(i*t>=0,(()=>`Negative dimension size caused by overflow when multiplying\n ${i} and ${t} for depthToSpace with input shape\n ${r.shape}`)),se(s%(t*t)==0,(()=>`Dimension size must be evenly divisible by ${t*t} but is ${s} for depthToSpace with input shape ${r.shape}`));const o={x:r},u={blockSize:t,dataFormat:n};return _i.runKernel(zt,o,u)}}),ac=Fi({depthwiseConv2d_:function(e,t,n,r,a="NHWC",i=[1,1],s){const o=Ai(e,"x","depthwiseConv2d","float32"),u=Ai(t,"filter","depthwiseConv2d","float32");let l=o,c=!1;3===o.rank&&(c=!0,l=Dl(o,[1,o.shape[0],o.shape[1],o.shape[2]])),se(4===l.rank,(()=>`Error in depthwiseConv2d: input must be rank 4, but got rank ${l.rank}.`)),se(4===u.rank,(()=>`Error in depthwiseConv2d: filter must be rank 4, but got rank ${u.rank}.`));const p="NHWC"===a?l.shape[3]:l.shape[1];se(p===u.shape[2],(()=>`Error in depthwiseConv2d: number of input channels (${p}) must match the inChannels dimension in filter ${u.shape[2]}.`)),wl("depthwiseConv2d",r,s);const d={x:l,filter:u},h={strides:n,pad:r,dataFormat:a,dilations:i,dimRoundingMode:s},f=_i.runKernel(Pt,d,h);return c?Dl(f,[f.shape[1],f.shape[2],f.shape[3]]):f}}),ic=Fi({diag_:function(e){const t={x:Ai(e,"x","diag")};return _i.runKernel(Ut,t)}}),sc=Fi({dilation2d_:function(e,t,n,r,a=[1,1],i="NHWC"){const s=Ai(e,"x","dilation2d"),o=Ai(t,"filter","dilation2d");se(3===s.rank||4===s.rank,(()=>`Error in dilation2d: input must be rank 3 or 4, but got rank ${s.rank}.`)),se(3===o.rank,(()=>`Error in dilation2d: filter must be rank 3, but got rank ${o.rank}.`)),se("NHWC"===i,(()=>`Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${i}`));let u=s,l=!1;3===s.rank&&(u=Dl(s,[1,s.shape[0],s.shape[1],s.shape[2]]),l=!0);const c={x:u,filter:o},p={strides:n,pad:r,dilations:a},d=_i.runKernel(qt,c,p);return l?Dl(d,[d.shape[1],d.shape[2],d.shape[3]]):d}}),oc=Fi({equal_:function(e,t){let n=Ai(e,"a","equal","string_or_numeric"),r=Ai(t,"b","equal","string_or_numeric");[n,r]=di(n,r),Lo(n.shape,r.shape);const a={a:n,b:r};return _i.runKernel(Qt,a)}}),uc=Fi({where_:function(e,t,n){const r=Ai(t,"a","where"),a=Ai(n,"b","where"),i=Ai(e,"condition","where","bool"),s=Lo(Lo(i.shape,r.shape),a.shape),o={condition:Yl(i,s),t:Yl(r,s),e:Yl(a,s)};return _i.runKernel(wr,o)}}),lc=Fi({divNoNan_:function(e,t){let n=Ai(e,"a","div"),r=Ai(t,"b","div");[n,r]=di(n,r);const a=Nu(n,r),i=Tu(a),s=oc(r,i);return uc(s,i,a)}}),cc=Fi({dot_:function(e,t){const n=Ai(e,"t1","dot"),r=Ai(t,"t2","dot");se(!(1!==n.rank&&2!==n.rank||1!==r.rank&&2!==r.rank),(()=>`Error in dot: inputs must all be rank 1 or 2, but got ranks ${n.rank} and ${r.rank}.`));const a=1===n.rank?n.size:n.shape[1],i=1===r.rank?r.size:r.shape[0];if(se(a===i,(()=>`Error in dot: inner dimensions of inputs must match, but got ${a} and ${i}.`)),1===n.rank&&1===r.rank){const e=Dl(n,[1,-1]),t=Dl(r,[-1,1]),a=no(e,t);return Dl(a,[])}if(1===n.rank&&2===r.rank){const e=Dl(n,[1,-1]),t=Dl(r,[r.shape[0],r.shape[1]]),a=no(e,t);return Dl(a,[a.size])}if(2===n.rank&&1===r.rank){const e=Dl(r,[-1,1]),t=no(n,e);return Dl(t,[t.size])}{const e=Dl(r,[r.shape[0],r.shape[1]]);return no(n,e)}}}),pc=Fi({einsum_:function(e,...t){const n=t.map(((e,t)=>Ai(e,`tensors${t}`,"einsum"))),r={equation:e};return _i.runKernel(Kt,n,r)}}),dc=Fi({elu_:function(e){const t={x:Ai(e,"x","elu","float32")};return _i.runKernel(Jt,t)}}),hc=Fi({erf_:function(e){let t=Ai(e,"x","erf");se("int32"===t.dtype||"float32"===t.dtype,(()=>"Input dtype must be `int32` or `float32`.")),"int32"===t.dtype&&(t=Ls(t,"float32"));const n={x:t};return _i.runKernel(Zt,n)}});function fc(e,t){for(let n=0;ne[t]))]}function yc(e,t){return mc(e,t.map((e=>1)),t)}function bc(e,t,n){se(fc(t,n),(()=>`${e} supports only inner-most axes for now. Got axes ${t} and rank-${n} input.`))}function vc(e,t){if(fc(e,t))return null;const n=[];for(let r=0;rn.push(e))),n}function xc(e){return e.map(((e,t)=>[t,e])).sort(((e,t)=>e[1]-t[1])).map((e=>e[0]))}function _c(e,t){const n=[];for(let r=t-e;r"Axis must be <= rank of the tensor"));const r={input:n},a={dim:t};return _i.runKernel(tn,r,a)}}),Ec=Fi({expm1_:function(e){const t={x:Ai(e,"x","expm1")};return _i.runKernel(nn,t)}}),Ac=Fi({tile_:function(e,t){const n=Ai(e,"x","tile","string_or_numeric");se(n.rank===t.length,(()=>`Error in transpose: rank of input ${n.rank} must match length of reps ${t}.`));const r={x:n},a={reps:t};return _i.runKernel(Kr,r,a)}}),Ic=Fi({eye_:function(e,t,n,r="float32"){null==t&&(t=e);const a=Is([e,t],r),i=e<=t?e:t;for(let e=0;e`Error in localResponseNormalization: x must be rank 3 or 4 but got\n rank ${i.rank}.`)),se(he(t),(()=>`Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${t}.`));let s=i,o=!1;3===i.rank&&(o=!0,s=Dl(i,[1,i.shape[0],i.shape[1],i.shape[2]]));const u={x:s},l={depthRadius:t,bias:n,alpha:r,beta:a},c=_i.runKernel(In,u,l);return o?Dl(c,[c.shape[1],c.shape[2],c.shape[3]]):c}}),qc=Fi({log_:function(e){const t={x:Ai(e,"x","log","float32")};return _i.runKernel(Nn,t)}}),Wc=Fi({log1p_:function(e){const t={x:Ai(e,"x","log1p")};return _i.runKernel(Mn,t)}}),Vc=Fi({softplus_:function(e){const t={x:Ai(e,"x","softplus")};return _i.runKernel(Cr,t)}}),Gc=Fi({logSigmoid_:function(e){const t=Ai(e,"x","logSigmoid"),n=Fu((e=>({value:ko(Vc(ko(e))),gradFunc:t=>Mu(t,kl(ko(e)))})));return n(t)}}),Kc=Fi({logSoftmax_:function(e,t=-1){const n=Ai(e,"logits","logSoftmax");if(-1===t&&(t=n.rank-1),t!==n.rank-1)throw Error(`Log Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank} and axis was ${t}`);const r=Fu(((e,n)=>{const r=wc(e,t,!0),a=Hu(e,r),i=Hu(Ls(a,"float32"),qc(Nc(Tc(a),t,!0)));return n([i]),{value:i,gradFunc:(e,n)=>{const[r]=n,a=Tc(r);return Hu(e,Mu(Nc(e,t,!0),a))}}}));return r(n)}}),Jc=Fi({logSumExp_:function(e,t=null,n=!1){const r=Ai(e,"x","logSumExp"),a=xe(t,r.shape),i=wc(r,a,!0),s=Hu(r,i),o=Tc(s),u=Nc(o,a),l=qc(u),c=wu(Dl(i,l.shape),l);if(n){const e=yc(c.shape,a);return Dl(c,e)}return c}}),Xc=Fi({logicalAnd_:function(e,t){const n=Ai(e,"a","logicalAnd","bool"),r=Ai(t,"b","logicalAnd","bool");Lo(n.shape,r.shape);const a={a:n,b:r};return _i.runKernel(Sn,a)}}),Zc=Fi({logicalNot_:function(e){const t={x:Ai(e,"x","logicalNot","bool")};return _i.runKernel(kn,t)}}),Qc=Fi({logicalOr_:function(e,t){const n=Ai(e,"a","logicalOr","bool"),r=Ai(t,"b","logicalOr","bool");Lo(n.shape,r.shape);const a={a:n,b:r};return _i.runKernel(Tn,a)}}),ep=Fi({logicalXor_:function(e,t){const n=Ai(e,"a","logicalXor","bool"),r=Ai(t,"b","logicalXor","bool");return Lo(n.shape,r.shape),Xc(Qc(e,t),Zc(Xc(e,t)))}}),tp=2147483648,np=Fi({searchSorted_:function(e,t,n="left"){const r=Ai(e,"sortedSequence","searchSorted"),a=Ai(t,"values","searchSorted"),i=r.shape[r.shape.length-1],s=a.shape[a.shape.length-1],o=Dl(r,[-1,i]),u=Dl(a,[-1,s]);if(o.rank<2)throw new Error("Sorted input argument must be at least 2-dimensional");if(o.shape[0]!==u.shape[0])throw new Error("Leading dimension of 'sortedSequence' and 'values' must match.");if(ce(u.shape)>=tp)throw new Error("values tensor size must less than 2147483648");if(o.shape[1]>=tp)throw new Error(`trailing dim_size must less than 2147483648 for int32 output type, was ${o.shape[1]}`);const l={sortedSequence:o,values:u},c={side:n};return _i.runKernel(_r,l,c)}});function rp(e,t){return np(e,t,"left")}const ap=Fi({maxPool_:function(e,t,n,r,a){const i=Ai(e,"x","maxPool");let s=i,o=!1;3===i.rank&&(o=!0,s=Dl(i,[1,i.shape[0],i.shape[1],i.shape[2]])),se(4===s.rank,(()=>`Error in maxPool: input must be rank 4 but got rank ${s.rank}.`)),se(xl(n,1),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`)),wl("maxPool",r,a);const u={x:s},l={filterSize:t,strides:n,pad:r,dimRoundingMode:a},c=_i.runKernel(On,u,l);return o?Dl(c,[c.shape[1],c.shape[2],c.shape[3]]):c}}),ip=Fi({maxPool3d_:function(e,t=[1,1,1],n,r,a,i="NDHWC"){const s=Ai(e,"x","maxPool3d");let o=s,u=!1;4===s.rank&&(u=!0,o=Dl(s,[1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]])),se(5===o.rank,(()=>`Error in maxPool3d: x must be rank 5 but got rank ${o.rank}.`)),se("NDHWC"===i,(()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${i}`)),wl("maxPool3d",r,a);const l={x:o},c={filterSize:t,strides:n,pad:r,dimRoundingMode:a,dataFormat:i},p=_i.runKernel(Yn,l,c);return u?Dl(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}}),sp=Fi({maxPoolWithArgmax_:function(e,t,n,r,a=!1){const i={x:Ai(e,"x","maxPoolWithArgmax")},s={filterSize:t,strides:n,pad:r,includeBatchInIndex:a},o=_i.runKernel(zn,i,s);return{result:o[0],indexes:o[1]}}}),op=Fi({mean_:function(e,t=null,n=!1){const r={x:Ai(e,"x","mean")},a={axis:t,keepDims:n};return _i.runKernel(Pn,r,a)}});function up(e,t="float32"){if("complex64"===t){const t=up(e,"float32"),n=up(e,"float32");return $i(t,n)}const n=ze(ce(e),t);return _i.makeTensor(n,e,t)}function lp(e,t="float32"){if("complex64"===t){const t=lp(e,"float32"),n=up(e,"float32");return $i(t,n)}const n=Be(ce(e),t);return _i.makeTensor(n,e,t)}function cp(e,t,{indexing:n="xy"}={}){if("xy"!==n&&"ij"!==n)throw new TypeError(`${n} is not a valid third argument to meshgrid`);if(void 0===e)return[];let r=Ai(e,"x","meshgrid",e instanceof ti?e.dtype:"float32");if(void 0===t)return[r];let a=Ai(t,"y","meshgrid",t instanceof ti?t.dtype:"float32");const i=ce(r.shape),s=ce(a.shape);return"xy"===n?(r=Dl(r,[1,-1]),a=Dl(a,[-1,1]),[no(lp([s,1],r.dtype),r),no(a,lp([1,i],a.dtype))]):(r=Dl(r,[-1,1]),a=Dl(a,[1,-1]),[no(r,lp([1,s],r.dtype)),no(lp([i,1],a.dtype),a)])}const pp=Fi({minimum_:function(e,t){let n=Ai(e,"a","minimum"),r=Ai(t,"b","minimum");[n,r]=di(n,r),"bool"===n.dtype&&(n=Ls(n,"int32"),r=Ls(r,"int32")),Lo(n.shape,r.shape);const a={a:n,b:r};return _i.runKernel(jn,a)}}),dp=Fi({mirrorPad_:function(e,t,n){se("reflect"===n||"symmetric"===n,(()=>`Invalid mode. Mode must be either reflect or symmetric. Got ${n}.`));const r=Ai(e,"x","mirrorPad");if(0===r.rank)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");se(t.length===r.rank,(()=>`Padding doesn't match input. Must be ${r.rank}. Got ${t.length}.`));const a="reflect"===n?1:0;for(let e=0;e"Invalid number of paddings. Must be length of 2 each.")),se(t[e][0]>=0&&t[e][0]<=r.shape[e]-a&&t[e][1]>=0&&t[e][1]<=r.shape[e]-a,(()=>`Padding in dimension ${e} cannot be greater than or equal to ${r.shape[e]-a} or less than 0 for input of shape ${r.shape}`));const i={paddings:t,mode:n},s={x:r};return _i.runKernel(Un,s,i)}}),hp=Fi({mod_:function(e,t){let n=Ai(e,"a","mod"),r=Ai(t,"b","mod");[n,r]=di(n,r);const a={a:n,b:r};return _i.runKernel(qn,a)}}),fp=Fi({moments_:function(e,t=null,n=!1){const r=xe(t,(e=Ai(e,"x","moments")).shape),a=op(e,r,n);let i=a.shape;n||(i=yc(a.shape,r));const s=ku(Hu(Ls(e,"float32"),Dl(a,i)));return{mean:a,variance:op(s,r,n)}}}),mp=Fi({multiRNNCell_:function(e,t,n,r){const a=Ai(t,"data","multiRNNCell"),i=Ii(n,"c","multiRNNCell"),s=Ii(r,"h","multiRNNCell");let o=a;const u=[];for(let t=0;t2)throw new Error(`Rank of probabilities must be 1 or 2, but is ${s}`);n=n||Math.random();const o={logits:1===s?Dl(a,[1,-1]):a},u={numSamples:t,seed:n,normalized:r},l=_i.runKernel(Wn,o,u);return 1===s?Dl(l,[l.size]):l}}),yp=Fi({notEqual_:function(e,t){let n=Ai(e,"a","notEqual","string_or_numeric"),r=Ai(t,"b","notEqual","string_or_numeric");[n,r]=di(n,r),Lo(n.shape,r.shape);const a={a:n,b:r};return _i.runKernel(Kn,a)}}),bp=Fi({onesLike_:function(e){const t={x:Ai(e,"x","onesLike")};return _i.runKernel(Qn,t)}}),vp=Fi({outerProduct_:function(e,t){const n=Ai(e,"v1","outerProduct"),r=Ai(t,"v2","outerProduct");se(1===n.rank&&1===r.rank,(()=>`Error in outerProduct: inputs must be rank 1, but got ranks ${n.rank} and ${r.rank}.`));const a=Dl(n,[-1,1]),i=Dl(r,[1,-1]);return no(a,i)}}),xp=Fi({pad_:function(e,t,n=0){const r=Ai(e,"x","pad");if(0===r.rank)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");const a={paddings:t,constantValue:n},i={x:r};return _i.runKernel(nr,i,a)}}),_p=Fi({pad1d_:function(e,t,n=0){return se(2===t.length,(()=>"Invalid number of paddings. Must be length of 2.")),xp(e,[t],n)}}),wp=Fi({pad2d_:function(e,t,n=0){return se(2===t.length&&2===t[0].length&&2===t[1].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),xp(e,t,n)}}),Dp=Fi({pad3d_:function(e,t,n=0){return se(3===t.length&&2===t[0].length&&2===t[1].length&&2===t[2].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),xp(e,t,n)}}),Np=Fi({pad4d_:function(e,t,n=0){return se(4===t.length&&2===t[0].length&&2===t[1].length&&2===t[2].length&&2===t[3].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),xp(e,t,n)}}),Mp=Fi({spaceToBatchND_:function(e,t,n){const r=Ai(e,"x","spaceToBatchND");se(r.rank>=1+t.length,(()=>`input rank ${r.rank} should be > than [blockShape] ${t.length}`)),se(n.length===t.length,(()=>`paddings.shape[0] ${n.length} must be equal to [blockShape] ${t.length}`)),se(r.shape.reduce(((e,r,a)=>a>0&&a<=t.length?e&&(r+n[a-1][0]+n[a-1][1])%t[a-1]==0:e),!0),(()=>`input spatial dimensions ${r.shape.slice(1)} with paddings ${n.toString()} must be divisible by blockShapes ${t.toString()}`));const a={x:r},i={blockShape:t,paddings:n};return _i.runKernel(Ir,a,i)}}),Sp=Fi({pool_:function(e,t,n,r,a,i,s){null==a&&(a=[1,1]),null==i&&(i=1),0===r&&(r="valid");const o=Ai(e,"x","maxPool");let u=o,l=!1;3===o.rank&&(l=!0,u=Dl(o,[1,o.shape[0],o.shape[1],o.shape[2]])),se(xl(i,a),(()=>`Error in pool: Either strides or dilations must be 1. Got strides ${i} and dilations '${a}'`));const c=cl(u.shape,t,i,a,r),p=[c.dilationHeight,c.dilationWidth];let d;d="same"===r?function(e,t){const n=e.map(((e,n)=>e+(e-1)*(t[n]-1))),r=n.map((e=>e-1)),a=r.map((e=>Math.floor(e/2))),i=r.map(((e,t)=>e-a[t]));return r.map(((e,t)=>[a[t],i[t]]))}([c.filterHeight,c.filterWidth],p):[[0,0],[0,0]];const h=1===p[0]&&1===p[1],[f,m]=function(e,t,n){const r=n.map((e=>e[0])),a=n.map((e=>e[1])),i=e.concat(r,a),s=t.map(((e,t)=>(e-i[t]%e)%e)),o=a.map(((e,t)=>e+s[t])),u=t.map(((e,t)=>[r[t],o[t]])),l=t.map(((e,t)=>[0,s[t]]));return[u,l]}([c.inHeight,c.inWidth],p,d),g=h?r:"valid",y=h?u:Mp(u,p,f),b=("avg"===n?()=>Nl(y,t,i,g,s):()=>ap(y,t,i,g,s))(),v=h?b:Al(b,p,m);return l?Dl(v,[v.shape[1],v.shape[2],v.shape[3]]):v}}),kp=Fi({prelu_:function(e,t){const n={x:Ai(e,"x","prelu"),alpha:Ai(t,"alpha","prelu")};return _i.runKernel(ir,n)}}),Tp=Fi({prod_:function(e,t=null,n=!1){let r=Ai(e,"x","prod");"bool"===r.dtype&&(r=Ls(r,"int32"));const a={x:r},i={axis:t,keepDims:n};return _i.runKernel(sr,a,i)}}),Cp=Fi({rand_:function(e,t,n){const r=ce(e);let a=null;if(null==n||"float32"===n)a=new Float32Array(r);else if("int32"===n)a=new Int32Array(r);else{if("bool"!==n)throw new Error(`Unknown data type ${n}`);a=new Uint8Array(r)}for(let e=0;e=1||0===i);const s=Math.sqrt(-2*Math.log(i)/i);e=this.mean+this.stdDev*r*s,t=this.mean+this.stdDev*a*s,this.truncated&&!this.isValidTruncated(e)||(n=!0)}return this.truncated&&!this.isValidTruncated(t)||(this.nextVal=this.convertValue(t)),this.convertValue(e)}convertValue(e){return null==this.dtype||"float32"===this.dtype?e:Math.round(e)}isValidTruncated(e){return e<=this.upper&&e>=this.lower}}class Ip{constructor(e,t,n,r){this.alpha=e,this.beta=1/t,this.dtype=n;const a=r||Math.random();this.randu=Ep.alea(a.toString()),this.randn=new Ap(0,1,n,!1,this.randu()),this.d=e<1?e+2/3:e-1/3,this.c=1/Math.sqrt(9*this.d)}nextValue(){let e,t,n,r,a,i;for(;;){do{r=this.randn.nextValue(),i=1+this.c*r}while(i<=0);if(i*=i*i,e=r*r,t=1-.331*e*e,n=.5*e+this.d*(1-i+Math.log(i)),a=this.randu(),anull==this.dtype||"float32"===this.dtype,this.min=e,this.range=t-e,this.dtype=n,null==r&&(r=Math.random()),"number"==typeof r&&(r=r.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error(`The difference between ${e} - ${t} <= 1 and dtype is not float`);this.random=Ep.alea(r)}convertValue(e){return this.canReturnFloat()?e:Math.round(e)}nextValue(){return this.convertValue(this.min+this.range*this.random())}}const Fp=Fi({randomGamma_:function(e,t,n=1,r="float32",a){if(null==n&&(n=1),null==r&&(r="float32"),"float32"!==r&&"int32"!==r)throw new Error(`Unsupported data type ${r}`);const i=new Ip(t,n,r,a),s=Is(e,r);for(let e=0;e`Error in reverse1D: x must be rank 1 but got rank ${t.rank}.`)),Hp(t,0)}}),Up=Fi({reverse2d_:function(e,t){const n=Ai(e,"x","reverse");return se(2===n.rank,(()=>`Error in reverse2D: x must be rank 2 but got rank ${n.rank}.`)),Hp(n,t)}}),qp=Fi({reverse3d_:function(e,t){const n=Ai(e,"x","reverse");return se(3===n.rank,(()=>`Error in reverse3D: x must be rank 3 but got rank ${n.rank}.`)),Hp(n,t)}}),Wp=Fi({reverse4d_:function(e,t){const n=Ai(e,"x","reverse");return se(4===n.rank,(()=>`Error in reverse4D: x must be rank 4 but got rank ${n.rank}.`)),Hp(n,t)}}),Vp=Fi({round_:function(e){const t={x:Ai(e,"x","round")};return _i.runKernel(br,t)}}),Gp=Fi({rsqrt_:function(e){const t={x:Ai(e,"x","rsqrt","float32")};return _i.runKernel(vr,t)}}),Kp=Fi({selu_:function(e){const t={x:Ai(e,"x","selu")};return _i.runKernel(Dr,t)}}),Jp=Fi({separableConv2d_:function(e,t,n,r,a,i=[1,1],s="NHWC"){const o=Ai(e,"x","separableConv2d"),u=Ai(t,"depthwiseFilter","separableConv2d"),l=Ai(n,"pointwiseFilter","separableConv2d");let c=o,p=!1;if(3===o.rank&&(p=!0,c=Dl(o,[1,o.shape[0],o.shape[1],o.shape[2]])),"NCHW"===s)throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");se(4===c.rank,(()=>`Error in separableConv2d: input must be rank 4, but got rank ${c.rank}.`)),se(4===u.rank,(()=>`Error in separableConv2d: depthwise filter must be rank 4, but got rank ${u.rank}.`)),se(4===l.rank,(()=>`Error in separableConv2d: pointwise filter must be rank 4, but got rank ${u.rank}.`)),se(1===l.shape[0],(()=>`Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${l.shape[0]}.`)),se(1===l.shape[1],(()=>`Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${l.shape[1]}.`));const d=u.shape[2],h=u.shape[3];se(l.shape[2]===d*h,(()=>`Error in separableConv2d: the third dimension of pointwise filter must be ${d*h}, but got ${l.shape[2]}.`));const f=ac(c,u,r,a,s,i),m=ql(f,l,1,"valid",s);return p?Dl(m,[m.shape[1],m.shape[2],m.shape[3]]):m}}),Xp=async function(e,t){const n=Ai(e,"x","setdiff1d"),r=Ai(t,"y","setdiff1d");se(n.dtype===r.dtype,(()=>`x and y should have the same dtype, but got x (${n.dtype}) and y (${r.dtype}).`)),se(1===n.rank,(()=>`x should be 1D tensor, but got x (${n.shape}).`)),se(1===r.rank,(()=>`y should be 1D tensor, but got y (${r.shape}).`));const a=await n.data(),i=await r.data(),s=new Set(i);let o=0;for(let e=0;e`slice1d expects a rank-1 tensor, but got a rank-${r.rank} tensor`)),Tl(r,[t],[n])}}),nd=Fi({slice2d_:function(e,t,n){const r=Ai(e,"x","slice2d");return se(2===r.rank,(()=>`slice2d expects a rank-2 tensor, but got a rank-${r.rank} tensor`)),Tl(r,t,n)}}),rd=Fi({slice3d_:function(e,t,n){const r=Ai(e,"x","slice3d");return se(3===r.rank,(()=>`slice3d expects a rank-3 tensor, but got a rank-${r.rank} tensor`)),Tl(r,t,n)}}),ad=Fi({slice4d_:function(e,t,n){const r=Ai(e,"x","slice4d");return se(4===r.rank,(()=>`slice4d expects a rank-4 tensor, but got a rank-${r.rank} tensor`)),Tl(r,t,n)}}),id=Fi({softmax_:function(e,t=-1){const n=Ai(e,"logits","softmax","float32");if(-1===t&&(t=n.rank-1),t!==n.rank-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank} and dim was ${t}`);const r={logits:n},a={dim:t};return _i.runKernel(Fr,r,a)}}),sd=Fi({fft_:function(e){se("complex64"===e.dtype,(()=>`The dtype for tf.spectral.fft() must be complex64 but got ${e.dtype}.`));const t={input:e};return _i.runKernel(rn,t)}}),od=Fi({ifft_:function(e){se("complex64"===e.dtype,(()=>`The dtype for tf.spectral.ifft() must be complex64 but got ${e.dtype}.`));const t={input:e};return _i.runKernel(mn,t)}}),ud=Fi({irfft_:function(e){const t=e.shape[e.shape.length-1],n=e.size/t;let r;if(t<=2){const a=Dl(e,[n,t]);r=od(a)}else{const a=[n,2*(t-1)],i=Dl(To(e),[n,t]),s=Dl(So(e),[n,t]),o=Hp(Tl(i,[0,1],[n,t-2]),1),u=Mu(Hp(Tl(s,[0,1],[n,t-2]),1),Ou(-1)),l=Sl([i,o],1),c=Sl([s,u],1),p=Dl($i(l,c),[a[0],a[1]]);r=od(p)}if(r=To(r),3===e.rank&&0!==e.shape[0]){const t=r,n=e.shape[0];r=Dl(r,[n,r.shape[0]/n,r.shape[1]]),t.dispose()}return r}}),ld=Fi({split_:function(e,t,n=0){const r={x:Ai(e,"x","split")},a={numOrSizeSplits:t,axis:n};return _i.runKernel(Lr,r,a)}}),cd=Fi({rfft_:function(e,t){se("float32"===e.dtype,(()=>`The dtype for rfft() must be real value but got ${e.dtype}`));let n=e.shape[e.shape.length-1];const r=e.size/n;let a;if(null!=t&&t0)),i=e.shape.map((e=>e));i[e.shape.length-1]=t,a=Tl(e,r,i),n=t}else if(null!=t&&t>n){const r=e.shape.map((e=>e));r[e.shape.length-1]=t-n,a=Sl([e,up(r)],e.shape.length-1),n=t}else a=e;const i=Tu(a),s=Dl($i(a,i),[r,n]),o=sd(s),u=Math.floor(n/2)+1,l=To(o),c=So(o),p=ld(l,[u,n-u],l.shape.length-1),d=ld(c,[u,n-u],c.shape.length-1),h=a.shape.slice();return h[a.shape.length-1]=u,Dl($i(p[0],d[0]),h)}}),pd=Fi({squaredDifference_:function(e,t){let n=Ai(e,"a","squaredDifference"),r=Ai(t,"b","squaredDifference");[n,r]=di(n,r),Lo(n.shape,r.shape);const a={a:n,b:r};return _i.runKernel(zr,a,{})}}),dd=Fi({squeeze_:function(e,t){const n=Ai(e,"x","squeeze","string_or_numeric");return Dl(n,_e(n.shape,t).newShape)}}),hd=Fi({stack_:function(e,t=0){const n=Ii(e,"tensors","stack","string_or_numeric");se(n.length>=1,(()=>"Pass at least one tensor to tf.stack")),n.length>0&&se(t<=n[0].rank,(()=>"Axis must be <= rank of the tensor"));const r=n,a={axis:t};return _i.runKernel(tr,r,a)}}),fd=Fi({step_:function(e,t=0){const n={x:Ai(e,"x","step")},r={alpha:t};return _i.runKernel(aa,n,r)}}),md=Fi({stridedSlice_:function(e,t,n,r,a=0,i=0,s=0,o=0,u=0){const l={x:Ai(e,"x","stridedSlice","string_or_numeric")},c={begin:t,end:n,strides:r,beginMask:a,endMask:i,ellipsisMask:s,newAxisMask:o,shrinkAxisMask:u};return _i.runKernel(Hr,l,c)}}),gd=Fi({tan_:function(e){const t={x:Ai(e,"x","tan","float32")};return _i.runKernel(Vr,t)}});function yd(e,t){ue(e);const n=Ti(e,t);if(1!==n.length)throw new Error("tensor1d() requires values to be a flat/TypedArray");return Oi(e,null,n,t)}function bd(e,t,n){if(ue(e),null!=t&&2!==t.length)throw new Error("tensor2d() requires shape to have two numbers");const r=Ti(e,n);if(2!==r.length&&1!==r.length)throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return Oi(e,t,r,n)}function vd(e,t,n){if(ue(e),null!=t&&4!==t.length)throw new Error("tensor4d() requires shape to have four numbers");const r=Ti(e,n);if(4!==r.length&&1!==r.length)throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");return Oi(e,t,r,n)}function xd(e,t,n){if(ue(e),null!=t&&5!==t.length)throw new Error("tensor5d() requires shape to have five numbers");const r=Ti(e,n);if(5!==r.length&&1!==r.length)throw new Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor5d() requires shape to be provided when `values` are a flat array");return Oi(e,t,r,n)}function _d(e,t,n){if(ue(e),null!=t&&6!==t.length)throw new Error("tensor6d() requires shape to have six numbers");const r=Ti(e,n);if(6!==r.length&&1!==r.length)throw new Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor6d() requires shape to be provided when `values` are a flat array");return Oi(e,t=t||r,r,n)}const wd=Fi({topk_:function(e,t=1,n=!0){const r=Ai(e,"x","topk");if(0===r.rank)throw new Error("topk() expects the input to be of rank 1 or higher");const a=r.shape[r.shape.length-1];if(t<0)throw new Error(`'k' passed to topk() must be >= 0 but got ${t}`);if(t>a)throw new Error(`'k' passed to topk() must be <= the last dimension (${a}) but got ${t}`);const i={x:r},s={k:t,sorted:n},[o,u]=_i.runKernel(Jr,i,s);return{values:o,indices:u}}}),Dd=Fi({truncatedNormal_:function(e,t=0,n=1,r,a){if(null!=r&&"bool"===r)throw new Error("Unsupported data type $ { dtype }");const i=new Ap(t,n,r,!0,a),s=Is(e,r);for(let e=0;e0,(()=>"The input tensor must be at least 1D"));const r={x:n},a={axis:t},[i,s]=_i.runKernel(Qr,r,a);return{values:i,indices:s}}}),Md=Fi({unsortedSegmentSum_:function(e,t,n){const r=Ai(e,"x","unsortedSegmentSum"),a=Ai(t,"segmentIds","unsortedSegmentSum","int32");se(he(n),(()=>"numSegments must be of dtype int"));const i={x:r,segmentIds:a},s={numSegments:n};return _i.runKernel(ta,i,s)}}),Sd=Fi({unstack_:function(e,t=0){const n=Ai(e,"x","unstack","string_or_numeric");se(t>=-n.shape.length&&t`Axis = ${t} is not in [-${n.shape.length}, ${n.shape.length})`));const r={value:n},a={axis:t};return _i.runKernel(ea,r,a)}});function kd(e,t){return np(e,t,"right")}function Td(e,t=!0,n,r){return _i.makeVariable(e,t,n,r)}function Cd(e,t){const n=[];for(let e=0;e0,(()=>"mask cannot be scalar")),oe(o.slice(i,i+s),a.shape,"mask's shape must match the first K dimensions of tensor's shape,");let u=1;for(let e=i;e"Shape mismatch in v and x"));const u=Ou(1),l=Hu(u,o);let c=Mu(Hu(s,i),l);if(a){se(null!=r,(()=>"When using zeroDebias: true, step is required."));const e=Ai(r,"step","movingAverage");c=Nu(c,Hu(u,Pu(o,e)))}return wu(i,c)}}),Ld=Fi({scatterND_:function(e,t,n){const r=Ai(e,"indices","scatterND","int32"),a=Ai(t,"updates","scatterND");Ho(a,r,n);const i={indices:r,updates:a},s={shape:n};return _i.runKernel(xr,i,s)}}),Fd=Fi({sparseToDense_:function(e,t,n,r=0){const a=Ai(e,"sparseIndices","sparseToDense","int32"),i=Ai(t,"sparseValues","sparseToDense","string_or_numeric"),s=Ai(r,"defaultValue","sparseToDense",i.dtype);!function(e,t,n,r){if("int32"!==e.dtype)throw new Error(`tf.sparseToDense() expects the indices to be int32 type, but the dtype was ${e.dtype}.`);if(e.rank>2)throw new Error(`sparseIndices should be a scalar, vector, or matrix, but got shape ${e.shape}.`);const a=e.rank>0?e.shape[0]:1,i=e.rank>1?e.shape[1]:1;if(n.length!==i)throw new Error(`outputShape has incorrect number of elements:, ${n.length}, should be: ${i}.`);const s=t.size;if(0!==t.rank&&(1!==t.rank||s!==a))throw new Error(`sparseValues has incorrect shape ${t.shape}, should be [] or [${a}]`);if(t.dtype!==r.dtype)throw new Error("sparseValues.dtype must match defaultValues.dtype")}(a,i,n,s);const o={sparseIndices:a,sparseValues:i,defaultValue:s},u={outputShape:n};return _i.runKernel(Br,o,u)}}),$d=Fi({gatherND_:function(e,t){const n=Ai(t,"indices","gatherND","int32"),r={params:Ai(e,"x","gatherND","string_or_numeric"),indices:n};return _i.runKernel(pn,r)}}),Od=Fi({dropout_:function(e,t,n,r){const a=Ai(e,"x","dropout");if(se("float32"===a.dtype,(()=>`x has to be a floating point tensor since it's going to be scaled, but got a ${a.dtype} tensor instead.`)),se(t>=0&&t<1,(()=>`rate must be a float in the range [0, 1), but got ${t}.`)),0===t)return e instanceof ti?a.clone():a;const i=function(e,t){if(null==t)return e.shape.slice();if(de(e.shape,t))return t;if(e.shape.length===t.length){const n=[];for(let r=0;r1,(()=>`inTopK() expects the predictions to be of rank 2 or higher, but got ${r.rank}`)),se(r.rank-1===a.rank,(()=>`predictions rank should be 1 larger than targets rank, but got predictions rank ${r.rank} and targets rank ${a.rank}`)),oe(r.shape.slice(0,r.shape.length-1),a.shape,"predictions's shape should be align with the targets' shape, except the last dimension.");const i=r.shape[r.shape.length-1];se(n>0&&n<=i,(()=>`'k' passed to inTopK() must be > 0 && <= the predictions last dimension (${i}), but got ${n}`));const s=await r.data(),o=await a.data(),[u,l]=[s.length/i,i],c=we("bool",u);for(let e=0;et.value-e.value)),c[e]=0;for(let t=0;t`Error in conv2dDerFilter: input must be rank 4, but got shape ${o.shape}.`)),se(4===u.rank,(()=>`Error in conv2dDerFilter: dy must be rank 4, but got shape ${u.shape}.`)),se(4===n.length,(()=>`Error in conv2dDerFilter: filterShape must be length 4, but got ${n}.`));const l="NHWC"===i?o.shape[3]:o.shape[1],c="NHWC"===i?u.shape[3]:u.shape[1];se(l===n[2],(()=>`Error in conv2dDerFilter: depth of input ${l}) must match input depth in filter (${n[2]}.`)),se(c===n[3],(()=>`Error in conv2dDerFilter: depth of dy (${c}) must match output depth for filter (${n[3]}).`)),wl("conv2dDerFilter",a,s);const p={x:o,dy:u},d={strides:r,pad:a,dataFormat:i,dimRoundingMode:s,filterShape:n};return _i.runKernel(Ct,p,d)}});function Pd(e,t,n){if(null==n||"linear"===n)return e;if("relu"===n)return Mu(e,fd(t));throw new Error(`Cannot compute gradient for fused activation ${n}.`)}function Hd(e,t){let n=t;const r=Io(e.shape,t.shape);return r.length>0&&(n=Nc(n,r)),Dl(n,e.shape)}function jd(e,t,n,r){if("linear"===t)return e;if("relu"===t)return zp(e);if("elu"===t)return dc(e);if("relu6"===t)return Pp(e);if("prelu"===t)return kp(e,n);if("leakyrelu"===t)return zc(e,r);if("sigmoid"===t)return kl(e);throw new Error(`Unknown fused activation ${t}.`)}const Ud=(e,t)=>!(e>0)||"linear"===t,qd=Fi({fusedConv2d_:function({x:e,filter:t,strides:n,pad:r,dataFormat:a="NHWC",dilations:i=[1,1],dimRoundingMode:s,bias:o,activation:u="linear",preluActivationWeights:l,leakyreluAlpha:c}){if(u=u||"linear",!1===Ud(_i.state.gradientDepth,u)){se("NHWC"===a,(()=>`Error in fused conv2d: got dataFormat of ${a} but only NHWC is currently supported for the case of gradient depth is 0 and the activation is not linear.`));let p=ql(e,t,n,r,a,i,s);return null!=o&&(p=wu(p,o)),jd(p,u,l,c)}const p=Ai(e,"x","conv2d","float32"),d=Ai(t,"filter","conv2d","float32");let h=p,f=!1;3===p.rank&&(f=!0,h=Dl(p,[1,p.shape[0],p.shape[1],p.shape[2]])),se(4===h.rank,(()=>`Error in fused conv2d: input must be rank 4, but got rank ${h.rank}.`)),se(4===d.rank,(()=>`Error in fused conv2d: filter must be rank 4, but got rank ${d.rank}.`)),wl("fused conv2d",r,s);const m="NHWC"===a?h.shape[3]:h.shape[1];se(d.shape[2]===m,(()=>`Error in conv2d: depth of input (${m}) must match input depth for filter ${d.shape[2]}.`)),se(xl(n,i),(()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${i}'`));const g=dl(h.shape,d.shape,n,i,r,s);let y,b;if(null!=o&&(y=Ai(o,"bias","fused conv2d"),[y]=di(y,p),"NHWC"===a?Lo(g.outShape,y.shape):(se(y.shape.length<=1,(()=>`Error in fused conv2d: only supports scalar or 1-D Tensor bias for NCHW format but got the bias of rank-${y.shape.length}.`)),se(0===y.shape.length||y.shape[0]===g.outChannels||1===y.shape[0],(()=>`Error in fused conv2d: bias shape (${y.shape}) is not compatible with the number of output channels (${g.outChannels})`)))),null!=l){const e=l.shape;if(se(e.length<=1||3===e.length,(()=>`Error in fused conv2d: only supports scalar, 1-D Tensor or 3-D Tensor PReLU activation weights but got a tensor of rank-${e.length}.`)),1===e.length)se(1===e[0]||e[0]===g.outChannels,(()=>`Error in fused conv2d: PReLU activation weights (${e}) is not compatible with the number of output channels (${g.outChannels}).`));else if(3===e.length)try{Lo(e,g.outShape)}catch(t){const n=`Error in fused conv2d: PReLU activation weights (${e}) is not compatible with the output shape of the conv2d (${g.outShape}).`;throw Error(n)}b=Ai(l,"prelu weights","fused conv2d")}const v=(e,t)=>{se("NHWC"===a,(()=>`Error in gradient of fused conv2D: got dataFormat of ${a} but only NHWC is currently supported.`));const[s,o,l,c]=t,p=Pd(e,l,u);se(vl(i),(()=>`Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${i}'`));const d=[Vl(o.shape,p,s,n,r),zd(o,p,s.shape,n,r)];if(null!=c){const e=Hd(c,p);d.push(e)}return d},x={x:h,filter:d,bias:y,preluActivationWeights:b},_={strides:n,pad:r,dataFormat:a,dilations:i,dimRoundingMode:s,activation:u,leakyreluAlpha:c};if(null==o){const e=Fu(((e,t,n)=>{let r=_i.runKernel(ua,x,_);return n([t,e,r]),f&&(r=Dl(r,[r.shape[1],r.shape[2],r.shape[3]])),{value:r,gradFunc:v}}));return e(h,d)}{const e=Fu(((e,t,n,r)=>{let a=_i.runKernel(ua,x,_);return r([t,e,a,n]),f&&(a=Dl(a,[a.shape[1],a.shape[2],a.shape[3]])),{value:a,gradFunc:v}}));return e(h,d,y)}}}),Wd=Fi({depthwiseConv2dNativeBackpropFilter_:function(e,t,n,r,a,i=[1,1],s){let o=e;3===e.rank&&(o=Dl(e,[1,e.shape[0],e.shape[1],e.shape[2]]));let u=t;3===u.rank&&(u=Dl(t,[1,t.shape[0],t.shape[1],t.shape[2]]));const l={x:o,dy:u},c={strides:r,pad:a,dimRoundingMode:s,dilations:i,filterShape:n};return _i.runKernel(Ht,l,c)}}),Vd=Fi({depthwiseConv2dNativeBackpropInput_:function(e,t,n,r,a,i=[1,1],s){let o=t,u=!1;3===t.rank&&(u=!0,o=Dl(t,[1,t.shape[0],t.shape[1],t.shape[2]]));const l={dy:o,filter:n},c={strides:r,pad:a,dimRoundingMode:s,dilations:i,inputShape:e},p=_i.runKernel(jt,l,c);return u?Dl(p,[p.shape[1],p.shape[2],p.shape[3]]):p}}),Gd=Fi({fusedDepthwiseConv2d_:function({x:e,filter:t,strides:n,pad:r,dataFormat:a="NHWC",dilations:i=[1,1],dimRoundingMode:s,bias:o,activation:u="linear",preluActivationWeights:l,leakyreluAlpha:c}){if(!1===Ud(_i.state.gradientDepth,u)){let p=ac(e,t,n,r,a,i,s);return null!=o&&(p=wu(p,o)),jd(p,u,l,c)}const p=Ai(e,"x","depthwiseConv2d","float32"),d=Ai(t,"filter","depthwiseConv2d","float32");let h=p,f=!1;3===p.rank&&(f=!0,h=Dl(p,[1,p.shape[0],p.shape[1],p.shape[2]])),se(4===h.rank,(()=>`Error in fused depthwiseConv2d: input must be rank 4, but got rank ${h.rank}.`)),se(4===d.rank,(()=>`Error in fused depthwiseConv2d: filter must be rank 4, but got rank ${d.rank}.`)),se(h.shape[3]===d.shape[2],(()=>`Error in fused depthwiseConv2d: number of input channels (${h.shape[3]}) must match the inChannels dimension in filter ${d.shape[2]}.`)),null==i&&(i=[1,1]),se(xl(n,i),(()=>`Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides ${n} and dilations '${i}'`)),wl("fused depthwiseConv2d",r,s);const m=dl(h.shape,d.shape,n,i,r,s,!0);let g,y;null!=o&&(g=Ai(o,"bias","fused conv2d"),[g]=di(g,p),Lo(m.outShape,g.shape)),null!=l&&(y=Ai(l,"prelu weights","fused depthwiseConv2d"));const b=(e,t)=>{se(vl(i),(()=>`Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '${i}'`));const[a,o,l,c]=t,p=Pd(e,l,u),d=Vd(o.shape,p,a,n,r,i,s),h=Wd(o,p,a.shape,n,r,i,s);return null!=c?[d,h,Hd(g,p)]:[d,h]},v={x:h,filter:d,bias:g,preluActivationWeights:y},x={strides:n,pad:r,dataFormat:a,dilations:i,dimRoundingMode:s,activation:u,leakyreluAlpha:c};if(null==o){const e=Fu(((e,t,n)=>{let r=_i.runKernel(la,v,x);return n([t,e,r]),f&&(r=Dl(r,[r.shape[1],r.shape[2],r.shape[3]])),{value:r,gradFunc:b}}));return e(h,d)}{const e=Fu(((e,t,n,r)=>{let a=_i.runKernel(la,v,x);return r([t,e,a,n]),f&&(a=Dl(a,[a.shape[1],a.shape[2],a.shape[3]])),{value:a,gradFunc:b}}));return e(h,d,g)}}}),Kd=Fi({fusedMatMul_:function({a:e,b:t,transposeA:n=!1,transposeB:r=!1,bias:a,activation:i="linear",preluActivationWeights:s,leakyreluAlpha:o=.2}){if(!1===Ud(_i.state.gradientDepth,i)){let u=no(e,t,n,r);return null!=a&&(u=wu(u,a)),jd(u,i,s,o)}let u=Ai(e,"a","fused matMul"),l=Ai(t,"b","fused matMul");[u,l]=di(u,l);const c=n?u.shape[u.rank-2]:u.shape[u.rank-1],p=r?l.shape[l.rank-1]:l.shape[l.rank-2],d=n?u.shape[u.rank-1]:u.shape[u.rank-2],h=r?l.shape[l.rank-2]:l.shape[l.rank-1],f=u.shape.slice(0,-2),m=l.shape.slice(0,-2),g=ce(f),y=ce(m);se(c===p,(()=>`Error in fused matMul: inner shapes (${c}) and (${p}) of Tensors with shapes ${u.shape} and ${l.shape} and transposeA=${n} and transposeB=${r} must match.`));const b=Lo(u.shape.slice(0,-2),l.shape.slice(0,-2)).concat([d,h]),v=Dl(u,n?[g,c,d]:[g,d,c]),x=Dl(l,r?[y,h,p]:[y,p,h]);let _,w;null!=a&&(_=Ai(a,"bias","fused matMul"),[_]=di(_,u),Lo(b,_.shape)),null!=s&&(w=Ai(s,"prelu weights","fused matMul"));const D=(e,t)=>{const[s,o,u,l]=t,c=Pd(Dl(e,u.shape),u,i);let p,d;return n||r?!n&&r?(p=no(c,o,!1,!1),d=no(c,s,!0,!1)):n&&!r?(p=no(o,c,!1,!0),d=no(s,c,!1,!1)):(p=no(o,c,!0,!0),d=no(c,s,!0,!0)):(p=no(c,o,!1,!0),d=no(s,c,!0,!1)),null!=a?[p,d,Hd(l,c)]:[p,d]},N={a:v,b:x,bias:_,preluActivationWeights:w},M={transposeA:n,transposeB:r,activation:i,leakyreluAlpha:o};if(null==a){const e=Fu(((e,t,n)=>{const r=_i.runKernel(oa,N,M);return n([e,t,r]),{value:Dl(r,b),gradFunc:D}}));return e(v,x)}{const e=Fu(((e,t,n,r)=>{const a=_i.runKernel(oa,N,M);return r([e,t,a,n]),{value:Dl(a,b),gradFunc:D}}));return e(v,x,_)}}}),Jd=Fi({hammingWindow_:function(e){return Yd(e,.54,.46)}}),Xd=Fi({hannWindow_:function(e){return Yd(e,.5,.5)}}),Zd=Fi({frame_:function(e,t,n,r=!1,a=0){let i=0;const s=[];for(;i+t<=e.size;)s.push(Tl(e,i,t)),i+=n;if(r)for(;i`Error in cropAndResize: image must be rank 4,but got rank ${s.rank}.`)),se(2===o.rank&&4===o.shape[1],(()=>`Error in cropAndResize: boxes must be have size [${l},4] but had shape ${o.shape}.`)),se(1===u.rank&&u.shape[0]===l,(()=>`Error in cropAndResize: boxInd must be have size [${l}] but had shape ${o.shape}.`)),se(2===r.length,(()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${r.length}.`)),se(r[0]>=1&&r[1]>=1,(()=>`cropSize must be atleast [1,1], but was ${r}`)),se("bilinear"===a||"nearest"===a,(()=>`method must be bilinear or nearest, but was ${a}`));const c={image:s,boxes:o,boxInd:u},p={method:a,extrapolationValue:i,cropSize:r};return _i.runKernel(Yt,c,p)}}),th=Fi({flipLeftRight_:function(e){const t=Ai(e,"image","flipLeftRight","float32");se(4===t.rank,(()=>`Error in flipLeftRight: image must be rank 4,but got rank ${t.rank}.`));const n={image:t};return _i.runKernel(sn,n,{})}}),nh=Fi({grayscaleToRGB_:function(e){const t=Ai(e,"image","grayscaleToRGB"),n=t.rank-1,r=t.shape[n];se(t.rank>=2,(()=>`Error in grayscaleToRGB: images must be at least rank 2, but got rank ${t.rank}.`)),se(1===r,(()=>`Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${r}.`));const a=new Array(t.rank);return a.fill(1,0,n),a[n]=3,Ac(t,a)}}),rh=Fi({rotateWithOffset_:function(e,t,n=0,r=.5){const a=Ai(e,"image","rotateWithOffset","float32");se(4===a.rank,(()=>`Error in rotateWithOffset: image must be rank 4,but got rank ${a.rank}.`));const i={image:a},s={radians:t,fillValue:n,center:r};return _i.runKernel(sa,i,s)}});function ah(e,t,n,r,a,i){null==r&&(r=.5),null==a&&(a=Number.NEGATIVE_INFINITY),null==i&&(i=0);const s=e.shape[0];return n=Math.min(n,s),se(0<=r&&r<=1,(()=>`iouThreshold must be in [0, 1], but was '${r}'`)),se(2===e.rank,(()=>`boxes must be a 2D tensor, but was of rank '${e.rank}'`)),se(4===e.shape[1],(()=>`boxes must have 4 columns, but 2nd dimension was ${e.shape[1]}`)),se(1===t.rank,(()=>"scores must be a 1D tensor")),se(t.shape[0]===s,(()=>`scores has incompatible shape with boxes. Expected ${s}, but was ${t.shape[0]}`)),se(0<=i&&i<=1,(()=>`softNmsSigma must be in [0, 1], but was '${i}'`)),{maxOutputSize:n,iouThreshold:r,scoreThreshold:a,softNmsSigma:i}}const ih=Fi({nonMaxSuppression_:function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY){const i=Ai(e,"boxes","nonMaxSuppression","float32"),s=Ai(t,"scores","nonMaxSuppression","float32"),o=ah(i,s,n,r,a),u={maxOutputSize:n=o.maxOutputSize,iouThreshold:r=o.iouThreshold,scoreThreshold:a=o.scoreThreshold};return _i.runKernel(Jn,{boxes:i,scores:s},u)}});function sh(e,t,n){const r=function(e,t,n){return function(e,t,n){let r=0,a=e.length,i=0,s=!1;for(;r>>1);const o=n(t,e[i]);o>0?r=i+1:(a=i,s=!o)}return s?r:-r-1}(e,t,n||oh)}(e,t,n),a=r<0?-(r+1):r;e.splice(a,0,t)}function oh(e,t){return e>t?1:ea&&l.push({score:t[e],boxIndex:e,suppressBeginIndex:0});l.sort(fh);const c=i>0?-.5/i:0,p=[],d=[];for(;p.length0;){const t=l.pop(),{score:n,boxIndex:i,suppressBeginIndex:s}=t;if(n=s;--n){const s=dh(e,i,p[n]);if(s>=r){o=!0;break}if(t.score=t.score*hh(r,c,s),t.score<=a)break}t.suppressBeginIndex=p.length,o||(t.score===n?(p.push(i),d.push(t.score)):t.score>a&&sh(l,t,fh))}const h=p.length,f=n-h;o&&f>0&&(p.push(...new Array(f).fill(0)),d.push(...new Array(f).fill(0)));const m={selectedIndices:p};return s&&(m.selectedScores=d),u&&(m.validOutputs=h),m}function dh(e,t,n){const r=e.subarray(4*t,4*t+4),a=e.subarray(4*n,4*n+4),i=Math.min(r[0],r[2]),s=Math.min(r[1],r[3]),o=Math.max(r[0],r[2]),u=Math.max(r[1],r[3]),l=Math.min(a[0],a[2]),c=Math.min(a[1],a[3]),p=Math.max(a[0],a[2]),d=Math.max(a[1],a[3]),h=(o-i)*(u-s),f=(p-l)*(d-c);if(h<=0||f<=0)return 0;const m=Math.max(i,l),g=Math.max(s,c),y=Math.min(o,p),b=Math.min(u,d),v=Math.max(y-m,0)*Math.max(b-g,0);return v/(h+f-v)}function hh(e,t,n){const r=Math.exp(t*n*n);return n<=e?r:0}function fh(e,t){return e.score-t.score||e.score===t.score&&t.boxIndex-e.boxIndex}const mh=Fi({nonMaxSuppressionWithScore_:function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,i=0){const s=Ai(e,"boxes","nonMaxSuppression"),o=Ai(t,"scores","nonMaxSuppression"),u=ah(s,o,n,r,a,i),l={boxes:s,scores:o},c={maxOutputSize:n=u.maxOutputSize,iouThreshold:r=u.iouThreshold,scoreThreshold:a=u.scoreThreshold,softNmsSigma:i=u.softNmsSigma},p=_i.runKernel(Zn,l,c);return{selectedIndices:p[0],selectedScores:p[1]}}}),gh=Fi({nonMaxSuppressionPadded_:function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,i=!1){const s=Ai(e,"boxes","nonMaxSuppression"),o=Ai(t,"scores","nonMaxSuppression"),u=ah(s,o,n,r,a,null),l={boxes:s,scores:o},c={maxOutputSize:u.maxOutputSize,iouThreshold:u.iouThreshold,scoreThreshold:u.scoreThreshold,padToMaxOutputSize:i},p=_i.runKernel(Xn,l,c);return{selectedIndices:p[0],validOutputs:p[1]}}}),yh=Fi({resizeBilinear_:function(e,t,n=!1,r=!1){const a=Ai(e,"images","resizeBilinear");se(3===a.rank||4===a.rank,(()=>`Error in resizeBilinear: x must be rank 3 or 4, but got rank ${a.rank}.`)),se(2===t.length,(()=>`Error in resizeBilinear: new shape must 2D, but got shape ${t}.`)),se(!1===r||!1===n,(()=>"Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false."));let i=a,s=!1;3===a.rank&&(s=!0,i=Dl(a,[1,a.shape[0],a.shape[1],a.shape[2]]));const[]=t,o={images:i},u={alignCorners:n,halfPixelCenters:r,size:t},l=_i.runKernel(fr,o,u);return s?Dl(l,[l.shape[1],l.shape[2],l.shape[3]]):l}}),bh=Fi({resizeNearestNeighbor_:function(e,t,n=!1,r=!1){const a=Ai(e,"images","resizeNearestNeighbor");se(3===a.rank||4===a.rank,(()=>`Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${a.rank}.`)),se(2===t.length,(()=>`Error in resizeNearestNeighbor: new shape must 2D, but got shape ${t}.`)),se("float32"===a.dtype||"int32"===a.dtype,(()=>"`images` must have `int32` or `float32` as dtype")),se(!1===r||!1===n,(()=>"Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false."));let i=a,s=!1;3===a.rank&&(s=!0,i=Dl(a,[1,a.shape[0],a.shape[1],a.shape[2]]));const[]=t,o={images:i},u={alignCorners:n,halfPixelCenters:r,size:t},l=_i.runKernel(dr,o,u);return s?Dl(l,[l.shape[1],l.shape[2],l.shape[3]]):l}}),vh=Fi({threshold_:function(e,t="binary",n=!1,r=.5){const a=Ai(e,"image","threshold"),i=a.shape[0]*a.shape[1];let s,o,u,l,c=Mu(yd([r]),255);if(se(3===a.rank,(()=>`Error in threshold: image must be rank 3,but got rank ${a.rank}.`)),se(3===a.shape[2]||1===a.shape[2],(()=>`Error in threshold: image color channel must be equal to 3 or 1but got ${a.shape[2]}.`)),se("int32"===a.dtype||"float32"===a.dtype,(()=>`Error in dtype: image dtype must be int32 or float32,but got dtype ${a.dtype}.`)),se("otsu"===t||"binary"===t,(()=>`Method must be binary or otsu, but was ${t}`)),3===a.shape[2]){[s,o,u]=ld(a,[1,1,1],-1);const e=Mu(s,.2989),t=Mu(o,.587),n=Mu(u,.114);l=wu(wu(e,t),n)}else l=e;"otsu"===t&&(c=function(e,t){let n,r,a,i,s,o,u=yd([-1]),l=yd([0]),c=yd([0]);for(let p=0;p`Error in transform: image must be rank 4,but got rank ${s.rank}.`)),se(2===o.rank&&(o.shape[0]===s.shape[0]||1===o.shape[0])&&8===o.shape[1],(()=>"Error in transform: Input transform should be batch x 8 or 1 x 8")),se(null==i||2===i.length,(()=>`Error in transform: outputShape must be [height, width] or null, but got ${i}.`));const u={image:s,transforms:o},l={interpolation:n,fillMode:r,fillValue:a,outputShape:i};return _i.runKernel(Xr,u,l)}}),_h=Fi({bandPart_:function(e,t,n){se(t%1==0,(()=>`bandPart(): numLower must be an integer, got ${t}.`)),se(n%1==0,(()=>`bandPart(): numUpper must be an integer, got ${n}.`));const r=Ai(e,"a","bandPart");se(r.rank>=2,(()=>`bandPart(): Rank must be at least 2, got ${r.rank}.`));const a=r.shape,[i,s]=r.shape.slice(-2);if(!(t<=i))throw new Error(`bandPart(): numLower (${t}) must not be greater than the number of rows (${i}).`);if(!(n<=s))throw new Error(`bandPart(): numUpper (${n}) must not be greater than the number of columns (${s}).`);t<0&&(t=i),n<0&&(n=s);const o=Dl(Yp(0,i,1,"int32"),[-1,1]),u=Yp(0,s,1,"int32"),l=Hu(o,u),c=Xc(Hc(l,Ou(+t,"int32")),Oc(l,Ou(-n,"int32"))),p=up([i,s],r.dtype);return Dl(hd(Sd(Dl(r,[-1,i,s])).map((e=>uc(c,e,p)))),a)}}),wh=Fi({gramSchmidt_:function(e){let t;if(Array.isArray(e)){t=!1,se(null!=e&&e.length>0,(()=>"Gram-Schmidt process: input must not be null, undefined, or empty"));const n=e[0].shape[0];for(let t=1;t`Gram-Schmidt: Non-unique lengths found in the input vectors: (${e[t].shape[0]} vs. ${n})`))}else t=!0,e=ld(e,e.shape[0],0).map((e=>dd(e,[0])));se(e.length<=e[0].shape[0],(()=>`Gram-Schmidt: Number of vectors (${e.length}) exceeds number of dimensions (${e[0].shape[0]}).`));const n=[],r=e;for(let t=0;t{let e=r[t];if(t>0)for(let r=0;r{se(2===e.shape.length,(()=>`qr2d() requires a 2D Tensor, but got a ${e.shape.length}D Tensor.`));const n=e.shape[0],r=e.shape[1];let a=Ic(n),i=Fs(e);const s=bd([[1]],[1,1]);let o=Fs(s);const u=n>=r?r:n;for(let e=0;e{const t=Tl(i,[e,e],[n-e,1]),u=Sc(t),l=Tl(i,[e,e],[1,1]),c=uc($c(l,0),bd([[-1]]),bd([[1]])),p=Hu(l,Mu(c,u)),d=Nu(t,p);o=1===d.shape[0]?Fs(s):Sl([s,Tl(d,[1,0],[d.shape[0]-1,d.shape[1]])],0);const h=ko(Nu(no(c,p),u)),f=Tl(i,[e,0],[n-e,r]),m=Mu(h,o),g=Co(o);if(0===e)i=Hu(f,no(m,no(g,f)));else{const t=Hu(f,no(m,no(g,f)));i=Sl([Tl(i,[0,0],[e,r]),t],0)}const y=Co(m),b=Tl(a,[0,e],[n,a.shape[1]-e]);if(0===e)a=Hu(b,no(no(b,o),y));else{const t=Hu(b,no(no(b,o),y));a=Sl([Tl(a,[0,0],[n,e]),t],1)}return[o,i,a]})),fo([t,u,l])}return!t&&n>r&&(a=Tl(a,[0,0],[n,r]),i=Tl(i,[0,0],[r,r])),[a,i]}))}const Nh=Fi({qr_:function(e,t=!1){if(se(e.rank>=2,(()=>`qr() requires input tensor to have a rank >= 2, but got rank ${e.rank}`)),2===e.rank)return Dh(e,t);{const n=e.shape.slice(0,e.shape.length-2).reduce(((e,t)=>e*t)),r=Sd(Dl(e,[n,e.shape[e.shape.length-2],e.shape[e.shape.length-1]]),0),a=[],i=[];return r.forEach((e=>{const[n,r]=Dh(e,t);a.push(n),i.push(r)})),[Dl(hd(a,0),e.shape),Dl(hd(i,0),e.shape)]}}});var Mh;!function(e){e[e.NONE=0]="NONE",e[e.MEAN=1]="MEAN",e[e.SUM=2]="SUM",e[e.SUM_BY_NONZERO_WEIGHTS=3]="SUM_BY_NONZERO_WEIGHTS"}(Mh||(Mh={}));const Sh=Fi({computeWeightedLoss_:function(e,t,n=Mh.SUM_BY_NONZERO_WEIGHTS){const r=Ai(e,"losses","computeWeightedLoss");let a=null;null!=t&&(a=Ai(t,"weights","computeWeightedLoss"));const i=null==a?r:Mu(r,a);if(n===Mh.NONE)return i;if(n===Mh.SUM)return Nc(i);if(n===Mh.MEAN){if(null==a)return op(i);{const e=r.size/a.size,t=Nu(Nc(i),Nc(a));return e>1?Nu(t,Ou(e)):t}}if(n===Mh.SUM_BY_NONZERO_WEIGHTS){if(null==a)return Nu(Nc(i),Ou(r.size));{const e=Mu(a,lp(r.shape)),t=Ls(Nc(yp(e,Ou(0))),"float32");return Nu(Nc(i),t)}}throw Error(`Unknown reduction: ${n}`)}}),kh=Fi({absoluteDifference_:function(e,t,n,r=Mh.SUM_BY_NONZERO_WEIGHTS){const a=Ai(e,"labels","absoluteDifference"),i=Ai(t,"predictions","absoluteDifference");let s=null;null!=n&&(s=Ai(n,"weights","absoluteDifference")),oe(a.shape,i.shape,"Error in absoluteDifference: ");const o=Uu(Hu(a,i));return Sh(o,s,r)}}),Th=Fi({cosineDistance_:function(e,t,n,r,a=Mh.SUM_BY_NONZERO_WEIGHTS){const i=Ai(e,"labels","cosineDistance"),s=Ai(t,"predictions","cosineDistance");let o=null;null!=r&&(o=Ai(r,"weights","cosineDistance")),oe(i.shape,s.shape,"Error in cosineDistance: ");const u=Ou(1),l=Hu(u,Nc(Mu(i,s),n,!0));return Sh(l,o,a)}}),Ch=Fi({hingeLoss_:function(e,t,n,r=Mh.SUM_BY_NONZERO_WEIGHTS){let a=Ai(e,"labels","hingeLoss");const i=Ai(t,"predictions","hingeLoss");let s=null;null!=n&&(s=Ai(n,"weights","hingeLoss")),oe(a.shape,i.shape,"Error in hingeLoss: ");const o=Ou(1);a=Hu(Mu(Ou(2),a),o);const u=zp(Hu(o,Mu(a,i)));return Sh(u,s,r)}}),Eh=Fi({huberLoss_:function(e,t,n,r=1,a=Mh.SUM_BY_NONZERO_WEIGHTS){const i=Ai(e,"labels","huberLoss"),s=Ai(t,"predictions","huberLoss");let o=null;null!=n&&(o=Ai(n,"weights","huberLoss")),oe(i.shape,s.shape,"Error in huberLoss: ");const u=Ou(r),l=Uu(Hu(s,i)),c=pp(l,u),p=Hu(l,c),d=wu(Mu(Ou(.5),ku(c)),Mu(u,p));return Sh(d,o,a)}}),Ah=Fi({logLoss_:function(e,t,n,r=1e-7,a=Mh.SUM_BY_NONZERO_WEIGHTS){const i=Ai(e,"labels","logLoss"),s=Ai(t,"predictions","logLoss");let o=null;null!=n&&(o=Ai(n,"weights","logLoss")),oe(i.shape,s.shape,"Error in logLoss: ");const u=Ou(1),l=Ou(r),c=ko(Mu(i,qc(wu(s,l)))),p=Mu(Hu(u,i),qc(wu(Hu(u,s),l))),d=Hu(c,p);return Sh(d,o,a)}}),Ih=Fi({meanSquaredError_:function(e,t,n,r=Mh.SUM_BY_NONZERO_WEIGHTS){const a=Ai(e,"labels","meanSquaredError"),i=Ai(t,"predictions","meanSquaredError");let s=null;null!=n&&(s=Ai(n,"weights","meanSquaredError")),oe(a.shape,i.shape,"Error in meanSquaredError: ");const o=pd(a,i);return Sh(o,s,r)}}),Lh=Fi({sigmoidCrossEntropy_:function(e,t,n,r=0,a=Mh.SUM_BY_NONZERO_WEIGHTS){let i=Ai(e,"multiClassLabels","sigmoidCrossEntropy");const s=Ai(t,"logits","sigmoidCrossEntropy");let o=null;if(null!=n&&(o=Ai(n,"weights","sigmoidCrossEntropy")),oe(i.shape,s.shape,"Error in sigmoidCrossEntropy: "),r>0){const e=Ou(r),t=Ou(1),n=Ou(.5);i=wu(Mu(i,Hu(t,e)),Mu(n,e))}const u=function(e,t){const n=Ai(e,"labels","sigmoidCrossEntropyWithLogits"),r=Ai(t,"logits","sigmoidCrossEntropyWithLogits");oe(n.shape,r.shape,"Error in sigmoidCrossEntropyWithLogits: ");const a=zp(r),i=Mu(r,n),s=Wc(Tc(ko(Uu(r))));return wu(Hu(a,i),s)}(i,s);return Sh(u,o,a)}}),Fh=Fi({softmaxCrossEntropy_:function(e,t,n,r=0,a=Mh.SUM_BY_NONZERO_WEIGHTS){let i=Ai(e,"onehotLabels","softmaxCrossEntropy");const s=Ai(t,"logits","softmaxCrossEntropy");let o=null;if(null!=n&&(o=Ai(n,"weights","softmaxCrossEntropy")),oe(i.shape,s.shape,"Error in softmaxCrossEntropy: "),r>0){const e=Ou(r),t=Ou(1),n=Ou(i.shape[1]);i=wu(Mu(i,Hu(t,e)),Nu(e,n))}const u=function(e,t,n=-1){if(-1===n&&(n=t.rank-1),n!==t.rank-1)throw Error(`Softmax cross entropy along a non-last dimension is not yet supported. Labels / logits was rank ${t.rank} and dim was ${n}`);const r=Fu(((e,t,r)=>{const a=Jc(t,[n],!0),i=Hu(Ls(t,"float32"),a);r([e,i]);const s=ko(Mu(i,e));return{value:Nc(s,[n]),gradFunc:(e,t)=>{const[r,a]=t,i=yc(e.shape,[n]);return[Mu(Dl(e,i),Hu(Ls(r,"float32"),Tc(a))),Mu(Dl(e,i),Hu(Tc(a),Ls(r,"float32")))]}}}));return r(e,t)}(i,s);return Sh(u,o,a)}}),$h=Fi({sparseFillEmptyRows_:function(e,t,n,r){const a=Ai(e,"indices","sparseFillEmptyRows","int32"),i=Ai(t,"values","sparseFillEmptyRows"),s=Ai(n,"denseShape","sparseFillEmptyRows","int32"),o=Ai(r,"defaultValue","sparseFillEmptyRows",i.dtype);if(2!==a.rank)throw new Error(`Indices should be Tensor2D but received shape\n ${a.shape}`);if(1!==i.rank)throw new Error(`Values should be Tensor1D but received shape ${i.shape}`);if(1!==s.rank)throw new Error(`Dense shape should be Tensor1D but received shape ${s.shape}`);if(0!==o.rank)throw new Error(`Default value should be a scalar but received shape ${o.shape}`);const u={indices:a,values:i,denseShape:s,defaultValue:o},l=_i.runKernel($r,u);return{outputIndices:l[0],outputValues:l[1],emptyRowIndicator:l[2],reverseIndexMap:l[3]}}}),Oh=Fi({sparseReshape_:function(e,t,n){const r=Ai(e,"inputIndices","sparseReshape","int32"),a=Ai(t,"inputShape","sparseReshape","int32"),i=Ai(n,"newShape","sparseReshape","int32");if(2!==r.rank)throw new Error(`Input indices should be Tensor2D but received shape\n ${r.shape}`);if(1!==a.rank)throw new Error(`Input shape should be Tensor1D but received shape ${a.shape}`);if(1!==i.rank)throw new Error(`New shape should be Tensor1D but received shape ${i.shape}`);const s={inputIndices:r,inputShape:a,newShape:i},o=_i.runKernel(Or,s);return{outputIndices:o[0],outputShape:o[1]}}}),Rh=Fi({sparseSegmentMean_:function(e,t,n){const r=Ai(e,"data","sparseSegmentMean"),a=Ai(t,"indices","sparseSegmentMean","int32"),i=Ai(n,"segmentIds","sparseSegmentMean","int32");if(r.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.rank)throw new Error(`Indices should be Tensor1D but received shape\n ${a.shape}`);if(1!==i.rank)throw new Error(`Segment ids should be Tensor1D but received shape\n ${i.shape}`);const s={data:r,indices:a,segmentIds:i};return _i.runKernel(Rr,s)}}),Yh=Fi({sparseSegmentSum_:function(e,t,n){const r=Ai(e,"data","sparseSegmentSum"),a=Ai(t,"indices","sparseSegmentSum","int32"),i=Ai(n,"segmentIds","sparseSegmentSum","int32");if(r.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.rank)throw new Error(`Indices should be Tensor1D but received shape\n ${a.shape}`);if(1!==i.rank)throw new Error(`Segment ids should be Tensor1D but received shape\n ${i.shape}`);const s={data:r,indices:a,segmentIds:i};return _i.runKernel(Yr,s)}}),Bh=Fi({stringNGrams_:function(e,t,n,r,a,i,s,o){const u=Ai(e,"data","stringNGrams","string");if("string"!==u.dtype)throw new Error("Data must be of datatype string");if(1!==u.shape.length)throw new Error(`Data must be a vector, saw: ${u.shape}`);const l=Ai(t,"dataSplits","stringNGrams");if("int32"!==l.dtype)throw new Error("Data splits must be of datatype int32");const c={separator:n,nGramWidths:r,leftPad:a,rightPad:i,padWidth:s,preserveShortSequences:o},p={data:u,dataSplits:l},d=_i.runKernel(jr,p,c);return{nGrams:d[0],nGramsSplits:d[1]}}}),zh=Fi({stringSplit_:function(e,t,n=!0){const r=Ai(e,"input","stringSplit","string"),a=Ai(t,"delimiter","stringSplit","string");if(1!==r.rank)throw new Error(`Input should be Tensor1D but received shape ${r.shape}`);if(0!==a.rank)throw new Error(`Delimiter should be a scalar but received shape ${a.shape}`);const i={skipEmpty:n},s={input:r,delimiter:a},o=_i.runKernel(Ur,s,i);return{indices:o[0],values:o[1],shape:o[2]}}}),Ph=Fi({stringToHashBucketFast_:function(e,t){const n=Ai(e,"input","stringToHashBucketFast","string"),r={numBuckets:t};if(t<=0)throw new Error("Number of buckets must be at least 1");const a={input:n};return _i.runKernel(qr,a,r)}}),Hh={fft:sd,ifft:od,rfft:cd,irfft:ud},jh={hammingWindow:Jd,hannWindow:Xd,frame:Zd,stft:Qd},Uh={flipLeftRight:th,grayscaleToRGB:nh,resizeNearestNeighbor:bh,resizeBilinear:yh,rotateWithOffset:rh,cropAndResize:eh,nonMaxSuppression:ih,nonMaxSuppressionAsync:async function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY){const i=Ai(e,"boxes","nonMaxSuppressionAsync"),s=Ai(t,"scores","nonMaxSuppressionAsync"),o=ah(i,s,n,r,a);n=o.maxOutputSize,r=o.iouThreshold,a=o.scoreThreshold;const u=await Promise.all([i.data(),s.data()]),l=u[0],c=u[1],{selectedIndices:p}=uh(l,c,n,r,a);return i!==e&&i.dispose(),s!==t&&s.dispose(),yd(p,"int32")},nonMaxSuppressionWithScore:mh,nonMaxSuppressionWithScoreAsync:async function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,i=0){const s=Ai(e,"boxes","nonMaxSuppressionAsync"),o=Ai(t,"scores","nonMaxSuppressionAsync"),u=ah(s,o,n,r,a,i);n=u.maxOutputSize,r=u.iouThreshold,a=u.scoreThreshold,i=u.softNmsSigma;const l=await Promise.all([s.data(),o.data()]),c=l[0],p=l[1],{selectedIndices:d,selectedScores:h}=ch(c,p,n,r,a,i);return s!==e&&s.dispose(),o!==t&&o.dispose(),{selectedIndices:yd(d,"int32"),selectedScores:yd(h)}},nonMaxSuppressionPadded:gh,nonMaxSuppressionPaddedAsync:async function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,i=!1){const s=Ai(e,"boxes","nonMaxSuppressionAsync"),o=Ai(t,"scores","nonMaxSuppressionAsync"),u=ah(s,o,n,r,a,null),l=u.maxOutputSize,c=u.iouThreshold,p=u.scoreThreshold,[d,h]=await Promise.all([s.data(),o.data()]),{selectedIndices:f,validOutputs:m}=lh(d,h,l,c,p,i);return s!==e&&s.dispose(),o!==t&&o.dispose(),{selectedIndices:yd(f,"int32"),validOutputs:Ou(m,"int32")}},threshold:vh,transform:xh},qh={bandPart:_h,gramSchmidt:wh,qr:Nh},Wh={absoluteDifference:kh,computeWeightedLoss:Sh,cosineDistance:Th,hingeLoss:Ch,huberLoss:Eh,logLoss:Ah,meanSquaredError:Ih,sigmoidCrossEntropy:Lh,softmaxCrossEntropy:Fh},Vh={sparseFillEmptyRows:$h,sparseReshape:Oh,sparseSegmentMean:Rh,sparseSegmentSum:Yh},Gh={stringNGrams:Bh,stringSplit:zh,stringToHashBucketFast:Ph},Kh={sgd:Ju.sgd,momentum:Ju.momentum,adadelta:Ju.adadelta,adagrad:Ju.adagrad,rmsprop:Ju.rmsprop,adamax:Ju.adamax,adam:Ju.adam},Jh="undefined"!=typeof requestAnimationFrame?requestAnimationFrame:"undefined"!=typeof setImmediate?setImmediate:e=>e();function Xh(){return new Promise((e=>Jh((()=>e()))))}function Zh(e,t){const n=e[0].length;e.forEach(((e,t)=>{se(e.length===n,(()=>`Error in concat${n}D: rank of tensors[${t}] must be the same as the rank of the rest (${n})`))})),se(t>=0&&t`Error in concat${n}D: axis must be between 0 and ${n-1}.`));const r=e[0];e.forEach(((e,a)=>{for(let i=0;i`Error in concat${n}D: Shape of tensors[${a}] (${e}) does not match the shape of the rest (${r}) along the non-concatenated axis ${a}.`))}))}function Qh(e,t){const n=e[0].slice();for(let r=1;r=2*t+1||r%2==1?a.push(r):n.push(r);r.push(...n),r.push(0),r.push(...a)}return r}function sf(e,t,n,r=!0){const a=[];r?a.push(e[0]/n):a.push(e[0]*n);for(let n=1;n/g;function Sf(e,t){const n=((e=e.replace(/\s/g,"")).length-e.replace(Mf,"").length)/"->".length;if(n<1)throw new Error("Equations without an arrow are not supported.");if(n>1)throw new Error('Equation must contain exactly one arrow ("->").');const[r,a]=e.split("->");se(-1===r.indexOf("..."),(()=>'The ellipsis notation ("...") is not supported yet.'));const i=r.split(","),s=i.length;if(t!==s)throw new Error(`Expected ${s} input tensors, received ${t}`);if(s>2)throw new Error("Support for more than 2 input tensors is not implemented yet.");const o=[];for(let e=0;e-1!==e.indexOf(t))))throw new Error(`Output subscripts contain the label ${t} not present in the input subscripts.`);-1===o.indexOf(t)&&o.push(t)}for(let e=0;e-1!==e)),{permutationIndices:n,expandDims:r}}function Tf(e,t,n){const r=new Array(e);for(let e=0;e`Expected dimension ${r[t[e][n]]} at axis ${n} of input shaped ${JSON.stringify(a)}, but got dimension ${a[n]}`))}}function Cf(e,t){const n=e,r=[];let a=0;0===e.length&&n.push(-1),a=e.length+1;for(let e=0;ee===t))}function Af(e,t){const n=[];for(let r=0;r"Number of splits must evenly divide the axis.")),r=new Array(t).fill(e.shape[n]/t);else{const a=t.reduce(((e,t)=>(-1===t&&(e+=1),e)),0);se(a<=1,(()=>"There should be only one negative value in split array."));const i=t.indexOf(-1);if(-1!==i){const r=t.reduce(((e,t)=>t>0?e+t:e));t[i]=e.shape[n]-r}se(e.shape[n]===t.reduce(((e,t)=>e+t)),(()=>"The sum of sizes must match the size of the axis dimension.")),r=t}return r}function Lf(e){return`Received SparseTensor with denseShape[0] = 0 but\n indices.shape[0] = ${e}`}function Ff(e,t){return`indices(${e}, 0) is invalid: ${t} < 0`}function $f(e,t,n){return`indices(${e}, 0) is invalid: ${t} >= ${n}`}function Of(e,t){return`only one output dimension may be -1, not both ${e} and ${t}`}function Rf(e,t){return`size ${e} must be non-negative, not ${t}`}function Yf(){return"reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero"}function Bf(e,t){return`Input to reshape is a SparseTensor with ${ce(e)}\n dense values, but the requested shape requires a multiple of ${ce(t)}. inputShape=${e} outputShape= ${t}`}function zf(e,t){return`Input to reshape is a tensor with ${ce(e)} dense values, but the requested shape has ${ce(t)}. inputShape=${e} outputShape=${t}`}function Pf(){return"segment ids must be >= 0"}function Hf(){return"segment ids are not increasing"}function jf(e,t){return`Segment id ${e} out of range [0, ${t}), possibly because segmentIds input is not sorted.`}function Uf(e,t,n){return`Bad: indices[${e}] == ${t} out of range [0, ${n})`}function qf(e,t){let n,r=!1;for(e<=ef?(n=e,r=!0):n=$e(e,Math.floor(Math.sqrt(e)));!r;)n>t||n===e?r=!0:n=$e(e,n+1);return n}function Wf(e,t,n){const r=[],a=e.length;for(let i=0;ia))throw new Error(`Expect batchDims in the range of [-${a}, ${a}], but got ${r}`);if(r<0&&(r+=a),r>i)throw new Error(`batchDims (${r}) must be less than rank(x) (\n ${i}).`);if(nHa(e)))}catch(e){throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${e}`)}}function Kf(e){return e.map((e=>Pa(e)))}const Jf={kernelName:Qe,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Mu(e,fd(Ls(n,"float32"),-1))}}},Xf={kernelName:et,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>{const t=ku(Ls(n,"float32")),r=Su(Hu(Ou(1),t));return ko(Nu(e,r))}}}},Zf={kernelName:tt,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>{const t=Su(Hu(ku(Ls(n,"float32")),1));return Nu(e,t)}}}},Qf={kernelName:nt,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t,a=Lo(n.shape,r.shape);return{a:()=>{let t=e;const r=Io(n.shape,a);return r.length>0&&(t=Nc(t,r)),Dl(t,n.shape)},b:()=>{let t=e;const n=Io(r.shape,a);return n.length>0&&(t=Nc(t,n)),Dl(t,r.shape)}}}},em={kernelName:rt,saveAllInputs:!0,gradFunc:(e,t)=>{const n={};return t.forEach(((t,r)=>{n[r]=()=>e.clone()})),n}},tm={kernelName:st,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Tu(n)}}},nm={kernelName:ot,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Tu(n)}}},rm={kernelName:ut,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Nu(e,Su(Hu(Ou(1),ku(Ls(n,"float32")))))}}},am={kernelName:lt,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>{const t=Su(wu(Ou(1),ku(Ls(n,"float32"))));return Nu(e,t)}}}},im={kernelName:dt,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t,a=Lo(n.shape,r.shape);return{a:()=>{const t=wu(ku(n),ku(r));let i=Mu(e,Nu(r,t));const s=Io(n.shape,a);return s.length>0&&(i=Nc(i,s)),Dl(i,n.shape)},b:()=>{const t=wu(ku(n),ku(r));let i=ko(Mu(e,Nu(n,t)));const s=Io(r.shape,a);return s.length>0&&(i=Nc(i,s)),Dl(i,r.shape)}}}},sm={kernelName:ct,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Nu(e,wu(ku(Ls(n,"float32")),1))}}},om={kernelName:pt,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Nu(e,Hu(Ou(1),ku(Ls(n,"float32"))))}}},um=Fi({avgPool3dGrad_:function(e,t,n,r,a,i){const s=Ai(e,"dy","avgPool3dGrad"),o=Ai(t,"input","avgPool3dGrad");let u=s,l=o,c=!1;4===o.rank&&(c=!0,u=Dl(s,[1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]]),l=Dl(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),se(5===u.rank,(()=>`Error in avgPool3dGrad: dy must be rank 5 but got rank ${u.rank}.`)),se(5===l.rank,(()=>`Error in avgPool3dGrad: input must be rank 5 but got rank ${l.rank}.`)),wl("avgPool3dGrad",a,i);const p={dy:u,input:l},d={filterSize:n,strides:r,pad:a,dimRoundingMode:i},h=_i.runKernel(gt,p,d);return c?Dl(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}}),lm={kernelName:mt,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{filterSize:a,strides:i,pad:s,dimRoundingMode:o}=n;return{x:()=>um(e,r,a,i,s,o)}}},cm=Fi({avgPoolGrad_:function(e,t,n,r,a){const i=Ai(e,"dy","avgPoolGrad"),s=Ai(t,"input","avgPoolGrad");se(s.rank===i.rank,(()=>`Rank of input (${s.rank}) does not match rank of dy (${i.rank})`));let o=s,u=i,l=!1;3===s.rank&&(l=!0,o=Dl(s,[1,s.shape[0],s.shape[1],s.shape[2]]),u=Dl(i,[1,i.shape[0],i.shape[1],i.shape[2]])),se(4===u.rank,(()=>`Error in avgPoolGrad: dy must be rank 4 but got rank ${u.rank}.`)),se(4===o.rank,(()=>`Error in avgPoolGrad: input must be rank 4 but got rank ${o.rank}.`));const c={dy:u,input:o},p={filterSize:n,strides:r,pad:a},d=_i.runKernel(ft,c,p);return l?Dl(d,[d.shape[1],d.shape[2],d.shape[3]]):d}}),pm={kernelName:ht,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{filterSize:a,strides:i,pad:s}=n;return{x:()=>cm(e,r,a,i,s)}}},dm={kernelName:yt,inputsToSave:["a","b"],gradFunc:(e,t,n)=>{const[r,a]=t,{transposeA:i,transposeB:s}=n;return i||s?!i&&s?{a:()=>no(e,a,!1,!1),b:()=>no(e,r,!0,!1)}:i&&!s?{a:()=>no(a,e,!1,!0),b:()=>no(r,e,!1,!1)}:{a:()=>no(a,e,!0,!0),b:()=>no(e,r,!0,!0)}:{a:()=>no(e,a,!1,!0),b:()=>no(r,e,!0,!1)}}},hm={kernelName:bt,gradFunc:(e,t,n)=>{const{blockShape:r,crops:a}=n;return{x:()=>Mp(e,r,a)}}},fm={kernelName:xt,gradFunc:(e,t,n)=>{const r=n,a=r.inputShape,i=r.shape,s=Array.from(i);for(let e=a.length-1;e>=0;e--)if(a[e]===i[e])s[e]=1;else if(1!==a[e])throw new Error(`broadcastTo(): [${a}] cannot be broadcast to [${i}].`);const o=[];for(let e=0;e1&&o.push(e);return{x:()=>Nc(e,o,!0)}}},mm={kernelName:wt,gradFunc:e=>({x:()=>e.clone()})},gm={kernelName:Dt,gradFunc:e=>({x:()=>Tu(e)})},ym={kernelName:Nt,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{clipValueMin:a,clipValueMax:i}=n;return{x:()=>uc(Xc(Oc(r,a),Hc(r,i)),e,Tu(e))}}},bm={kernelName:St,inputsToSave:["x"],gradFunc:Jf.gradFunc},vm={kernelName:kt,saveAllInputs:!0,gradFunc:(e,t,n)=>{const r=t.map((e=>e.shape)),{axis:a}=n,i=xe(a,t[0].shape)[0],s=r.map((e=>e[i]));return ld(e,s,i).map((e=>()=>e))}},xm={kernelName:Tt,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{const[r,a]=t,{dilations:i,strides:s,pad:o,dataFormat:u}=n;return se(vl(i),(()=>`Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${i}'`)),{x:()=>Vl(r.shape,e,a,s,o,u),filter:()=>zd(r,e,a.shape,s,o,u)}}},_m={kernelName:Et,inputsToSave:["dy","filter"],gradFunc:(e,t,n)=>{const[r,a]=t,{strides:i,pad:s,dataFormat:o,dimRoundingMode:u}=n;return{dy:()=>ql(e,a,i,s,o,1,u),filter:()=>zd(e,r,a.shape,i,s,o,u)}}},wm=Fi({conv3DBackpropFilter_:function(e,t,n,r,a){let i=e;4===e.rank&&(i=Dl(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]]));let s=t;4===s.rank&&(s=Dl(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]])),se(5===i.rank,(()=>`Error in conv3dDerFilter: input must be rank 5, but got shape ${i.shape}.`)),se(5===s.rank,(()=>`Error in conv3dDerFilter: dy must be rank 5, but got shape ${s.shape}.`)),se(5===n.length,(()=>`Error in conv3dDerFilter: filterShape must be length 5, but got ${n}.`)),se(i.shape[4]===n[3],(()=>`Error in conv3dDerFilter: depth of input ${i.shape[4]}) must match input depth in filter (${n[3]}.`)),se(s.shape[4]===n[4],(()=>`Error in conv3dDerFilter: depth of dy (${s.shape[4]}) must match output depth for filter (${n[4]}).`));const o={x:i,dy:s},u={strides:r,pad:a,filterShape:n};return _i.runKernel(It,o,u)}}),Dm={kernelName:At,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{const{dilations:r,strides:a,pad:i}=n;se(vl(r),(()=>`Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${r}'`));const[s,o]=t;return{x:()=>Jl(s.shape,e,o,a,i),filter:()=>wm(s,e,o.shape,a,i)}}},Nm={kernelName:Ft,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Mu(ko(Qp(Ls(n,"float32"))),e)}}},Mm={kernelName:$t,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Mu(ed(Ls(n,"float32")),e)}}},Sm={kernelName:Rt,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{axis:a,exclusive:i,reverse:s}=n;return{x:()=>{const t=vc([a],r.rank);let n=tc(e,a,i,!s);return null!=t&&(n=Co(n,t)),n}}}},km={kernelName:Pt,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{const{dilations:r,strides:a,pad:i,dimRoundingMode:s}=n,o=null==r?[1,1]:r;se(vl(o),(()=>`Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations '${o}'`));const[u,l]=t;return se(4===u.rank,(()=>`Error in gradient of depthwiseConv2dNative: input must be rank 4, but got rank ${u.rank}.`)),se(4===l.rank,(()=>`Error in gradient of depthwiseConv2dNative: filter must be rank 4, but got rank ${l.rank}.`)),se(u.shape[3]===l.shape[2],(()=>`Error in gradient of depthwiseConv2d: number of input channels (${u.shape[3]}) must match the inChannels dimension in filter ${l.shape[2]}.`)),se(xl(a,o),(()=>`Error in gradient of depthwiseConv2d: Either strides or dilations must be 1. Got strides ${a} and dilations '${o}'.`)),wl("depthwiseConv2d",i,s),{x:()=>Vd(u.shape,e,l,a,i,o,s),filter:()=>Wd(u,e,l.shape,a,i,o,s)}}},Tm={kernelName:qt,inputsToSave:["x","filter"],gradFunc:(e,t,n)=>{const[r,a]=t,i={x:r,filter:a,dy:e},s={x:r,filter:a,dy:e};return{x:()=>_i.runKernel(Wt,i,n),filter:()=>_i.runKernel(Vt,s,n)}}},Cm={kernelName:Jt,outputsToSave:[!0],gradFunc:(e,t)=>{const[n]=t,r={dy:e,y:n};return{x:()=>_i.runKernel(Xt,r)}}},Em={kernelName:Zt,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t,r=Mu(Tc(ko(ku(n))),2/Math.sqrt(Math.PI));return{x:()=>Mu(e,r)}}},Am={kernelName:en,outputsToSave:[!0],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Mu(e,n)}}},Im={kernelName:tn,inputsToSave:["input"],gradFunc:(e,t)=>{const[n]=t;return{input:()=>Dl(e,n.shape)}}},Lm={kernelName:nn,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Mu(e,Tc(n))}}},Fm={kernelName:on,gradFunc:e=>({x:()=>Tu(e)})},$m={kernelName:un,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t,a=Lo(n.shape,r.shape);return{a:()=>{const t=Nu(e,Ls(r,"float32")),i=Io(n.shape,a);return i.length>0?Dl(Nc(t,i),n.shape):t},b:()=>{let t=Mu(e,Ls(n,"float32"));const i=Io(r.shape,a);i.length>0&&(t=Dl(Nc(t,i),r.shape));const s=ku(r);return ko(Nu(t,Ls(s,"float32")))}}}},Om={kernelName:ln,inputsToSave:["x","mean","variance","scale"],gradFunc:(e,t,n)=>{const{varianceEpsilon:r}=n,[a,i,s,o]=t,u=null==o?Ou(1):o,l=Io(i.shape,a.shape),c=[];if(1===i.rank){for(let e=0;e1===i.rank?Dl(Mu(Mu(e,Ac(Dl(h,[1,1,1,i.shape[0]]),c)),u),a.shape):Dl(Mu(Mu(e,h),u),a.shape),mean:()=>{let e=Mu(Mu(h,Ou(-1)),d);return 1===i.rank&&(e=Nc(e,l)),Dl(e,i.shape)},variance:()=>{let e=Mu(Mu(f,p),d);return 1===i.rank&&(e=Nc(e,l)),Dl(e,i.shape)},scale:()=>{const t=Mu(p,h);let n=Mu(e,t);return 1===i.rank&&(n=Nc(n,l)),Dl(n,i.shape)},offset:()=>{let t=e;return 1===i.rank&&(t=Nc(t,l)),Dl(t,i.shape)}}}},Rm={kernelName:cn,inputsToSave:["x","indices"],gradFunc:(e,t,n)=>{const[r,a]=t,{axis:i}=n,s=xe(i,r.shape)[0];return{x:()=>{const t=r.shape,n=a.size,o=t.slice(0,s),u=o.length,l=t.slice(i,t.length).slice(1),c=l.length,p=Ym(0,u),d=Ym(u+1,u+1+c),h=Bm([o,[n],l]),f=Dl(e,h),m=Dl(a,[n]),g=Bm([[u],p,d]),y=Co(f,g);let b=Md(y,m,r.shape[s]);const v=xc(g);return b=Co(b,v),b},indices:()=>a}}};function Ym(e,t){const n=[];for(let r=e;r{const[n,r]=t;return{a:()=>Tu(n),b:()=>Tu(r)}}},Pm={kernelName:fn,gradFunc:e=>({x:()=>Ls(e,"float32")})},Hm={kernelName:yn,gradFunc:e=>({x:()=>Tu(e)})},jm={kernelName:bn,gradFunc:e=>({x:()=>Tu(e)})},Um={kernelName:vn,gradFunc:e=>({x:()=>Tu(e)})},qm={kernelName:xn,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{alpha:a}=n,i=$c(r,0);return{x:()=>uc(i,e,Mu(e,a))}}},Wm={kernelName:Mn,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Nu(e,wu(n,1))}}},Vm={kernelName:Nn,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Nu(e,Ls(n,"float32"))}}},Gm={kernelName:En,inputsToSave:[],outputsToSave:[!0],gradFunc:(e,t,n)=>{const[r]=t,{axis:a}=n;return{logits:()=>{const t=Tc(r);return Hu(e,Mu(Nc(e,a,!0),t))}}}},Km=Fi({localResponseNormalizationBackprop_:function(e,t,n,r=5,a=1,i=1,s=.5){const o={x:e,y:t,dy:n},u={depthRadius:r,bias:a,alpha:i,beta:s};return _i.runKernel(Ln,o,u)}}),Jm={kernelName:In,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{const[r,a]=t,{depthRadius:i,bias:s,alpha:o,beta:u}=n;return{x:()=>Km(r,a,e,i,s,o,u)}}};function Xm(e,t,n,r){return t.rankMu(e,Ls(oc(n,t),e.dtype))}}const Zm={kernelName:Fn,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{const r=n,{reductionIndices:a}=r,i=t[0],s=Xm(e,t[1],i,xe(a,i.shape));return{x:()=>s.x()}}},Qm={kernelName:$n,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t;return{a:()=>Mu(e,Ls(Oc(n,r),"float32")),b:()=>Mu(e,Ls(Pc(n,r),"float32"))}}},eg=Fi({maxPool3dGrad_:function(e,t,n,r,a,i,s){const o=Ai(e,"dy","maxPool3dGrad"),u=Ai(t,"input","maxPool3dGrad"),l=Ai(n,"output","maxPool3dGrad");let c=o,p=u,d=l,h=!1;4===u.rank&&(h=!0,c=Dl(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]]),p=Dl(u,[1,u.shape[0],u.shape[1],u.shape[2],u.shape[3]]),d=Dl(l,[1,l.shape[0],l.shape[1],l.shape[2],l.shape[3]])),se(5===c.rank,(()=>`Error in maxPool3dGrad: dy must be rank 5 but got rank ${c.rank}.`)),se(5===p.rank,(()=>`Error in maxPool3dGrad: input must be rank 5 but got rank ${p.rank}.`)),se(5===d.rank,(()=>`Error in maxPool3dGrad: output must be rank 5 but got rank ${d.rank}.`)),wl("maxPool3dGrad",i,s);const f={dy:c,input:p,output:d},m={filterSize:r,strides:a,pad:i,dimRoundingMode:s},g=_i.runKernel(Bn,f,m);return h?Dl(g,[g.shape[1],g.shape[2],g.shape[3],g.shape[4]]):g}}),tg={kernelName:Yn,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{const[r,a]=t,{filterSize:i,strides:s,pad:o,dimRoundingMode:u}=n;return{x:()=>eg(e,r,a,i,s,o,u)}}},ng=Fi({maxPoolGrad_:function(e,t,n,r,a,i,s){const o=Ai(e,"dy","maxPoolGrad"),u=Ai(t,"input","maxPoolGrad"),l=Ai(n,"output","maxPoolGrad");se(u.rank===o.rank,(()=>`Rank of input (${u.rank}) does not match rank of dy (${o.rank})`)),se(4===o.rank,(()=>`Error in maxPoolGrad: dy must be rank 4 but got rank ${o.rank}.`)),se(4===u.rank,(()=>`Error in maxPoolGrad: input must be rank 4 but got rank ${u.rank}.`)),wl("maxPoolGrad",i,s);const c={dy:o,input:u,output:l},p={filterSize:r,strides:a,pad:i,dimRoundingMode:s};return _i.runKernel(Rn,c,p)}}),rg={kernelName:On,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{const[r,a]=t,{filterSize:i,strides:s,pad:o}=n;return{x:()=>ng(e,r,a,i,s,o)}}},ag={kernelName:Pn,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{axis:a}=n,i=xe(a,r.shape),s=ce(gc(r.shape,i)[1]);return{x:()=>{const t=r.shape.slice();i.forEach((e=>{t[e]=1}));const n=Dl(e,t);return Nu(Mu(n,lp(r.shape,"float32")),s)}}}},ig={kernelName:Hn,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(e,t,n)=>{const r=n,{axis:a}=r,[i,s]=t,o=Xm(e,s,i,xe(a,i.shape));return{x:()=>o.x()}}},sg={kernelName:Un,inputsToSave:["x"],gradFunc:(e,t,n)=>{const r=t[0],{paddings:a}=n,i=a.map((e=>e[0]));return{x:()=>Tl(e,i,r.shape)}}},og={kernelName:tr,saveAllInputs:!0,gradFunc:(e,t,n)=>{const{axis:r}=n;return Sd(e,r).map((e=>()=>e))}},ug={kernelName:nr,inputsToSave:["x"],gradFunc:(e,t,n)=>{const r=t[0],{paddings:a}=n,i=a.map((e=>e[0]));return{x:()=>Tl(e,i,r.shape)}}},lg={kernelName:ar,inputsToSave:["a","b"],outputsToSave:[!0],gradFunc:(e,t)=>{const[n,r,a]=t,i=n,s=r,o=Lo(i.shape,s.shape);return{a:()=>{const t=Ls(s,"float32");let n=Mu(e,Mu(t,Pu(i,Hu(t,Ou(1)))));const r=Io(i.shape,o);return r.length>0&&(n=Nc(n,r)),Dl(n,i.shape)},b:()=>{const t=$c(i,0),n=uc(t,qc(i),Tu(i));let r=Mu(e,Mu(a,n));const u=Io(s.shape,o);return u.length>0&&(r=Nc(r,u)),Dl(r,s.shape)}}}};const cg={kernelName:sr,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{axis:a}=n;let i=[];return i=null==a?r.shape.map(((e,t)=>t)):"number"==typeof a?[a]:a,{x:()=>function(e,t,n){const r=e.shape.length,a=r-n.length,i=vc(n,r);let s=e;null!=i&&(s=Co(e,i));const o=s.shape.slice(),u=o.splice(r-n.length,n.length).reduce(((e,t)=>e*t),1);o.push(u);let l=function(e,t,n){const r=e.shape.slice();r[n]=1;const a=Dl(t,r),i=ec(e,n,!0,!1),s=ec(e,n,!0,!0),o=Mu(i,s);return Mu(a,o)}(s.reshape(o),t,a);if(l=l.reshape(s.shape),null!=i){const e=xc(i);l=Co(l,e)}return l}(r,e,i)}}},pg={kernelName:Dr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>{const t=$c(n,Ou(0)),r=Ou(lf),a=Ou(cf),i=Mu(e,a),s=Mu(Mu(e,r),Tc(Ls(n,"float32")));return uc(t,i,s)}}}},dg={kernelName:Nr,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{begin:a,size:i}=n,s=r.shape,[o,u]=au(r,a,i),l=[];for(let t=0;txp(e,l)}}},hg={kernelName:Ir,gradFunc:(e,t,n)=>{const{blockShape:r,paddings:a}=n;return{x:()=>Al(e,r,a)}}},fg={kernelName:Lr,gradFunc:(e,t,n)=>{const{axis:r}=n;return{x:()=>Sl(e,r)}}},mg={kernelName:Ar,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,a=r.shape.slice(),{axis:i}=n;xe(i,r.shape).forEach((e=>{a[e]=1}));const s=Dl(e,a),o=Mu(s,lp(r.shape,"float32"));return{x:()=>o}}},gg={kernelName:Kr,inputsToSave:["x"],gradFunc:(e,t,n)=>{const[r]=t,{reps:a}=n;return{x:()=>{let t=Tu(r);if(1===r.rank)for(let n=0;n{const r=n,{axis:a}=r;return{value:()=>hd(e,a)}}},bg={kernelName:ta,inputsToSave:["segmentIds"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>function(e,t){const n=qu(t,Tu(t)),r=Fc(e,n);let a=Oc(t,Ou(0,"int32"));const i=r.rank-a.rank;for(let e=0;e{const[n,r]=t,a=Lo(n.shape,r.shape);return{a:()=>{const t=Nu(e,Ls(r,"float32")),i=Io(n.shape,a);return i.length>0?Dl(Nc(t,i),n.shape):t},b:()=>{let t=Mu(e,Ls(n,"float32"));const i=Io(r.shape,a);i.length>0&&(t=Dl(Nc(t,i),r.shape));const s=ku(r);return ko(Nu(t,Ls(s,"float32")))}}}},Cm,Em,Am,Im,Lm,$m,Fm,Om,Rm,zm,Pm,Hm,jm,Um,qm,Wm,Vm,Gm,Jm,Zm,Zm,Qm,tg,rg,ag,ig,{kernelName:jn,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t;return{a:()=>Mu(e,Ls(Hc(n,r),"float32")),b:()=>Mu(e,Ls($c(n,r),"float32"))}}},sg,{kernelName:qn,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t,a=Lo(n.shape,r.shape);return{a:()=>{const t=Io(n.shape,a);return t.length>0?Dl(Nc(e,t),n.shape):e},b:()=>{const t=Mu(e,ko(Lc(Nu(n,r)))),i=Io(r.shape,a);return i.length>0?Dl(Nc(t,i),r.shape):t}}}},{kernelName:Vn,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t,a=Lo(n.shape,r.shape);return{a:()=>{const t=Mu(e,Ls(r,"float32")),i=Io(n.shape,a);return i.length>0?Dl(Nc(t,i),n.shape):t},b:()=>{const t=Mu(e,Ls(n,"float32")),i=Io(r.shape,a);return i.length>0?Dl(Nc(t,i),r.shape):t}}}},{kernelName:Gn,gradFunc:e=>({x:()=>ko(e)})},{kernelName:er,inputsToSave:["indices"],gradFunc:(e,t)=>{const n=t[0];return{indices:()=>up(n.shape,"float32")}}},{kernelName:Qn,gradFunc:e=>({x:()=>Tu(e)})},og,ug,ug,lg,{kernelName:ir,inputsToSave:["x","alpha"],gradFunc:(e,t)=>{const[n,r]=t,a=$c(n,0);return{x:()=>uc(a,e,Mu(e,r)),alpha:()=>{let t=uc(a,Tu(e),Mu(e,n));const i=Io(r.shape,e.shape);return i.length>0&&(t=Nc(t,i)),Dl(t,r.shape)}}}},cg,{kernelName:lr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Nu(e,ko(ku(n)))}}},{kernelName:gr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t,r=Mu(Hc(n,6),fd(n));return{x:()=>Mu(e,Ls(r,"float32"))}}},{kernelName:cr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Mu(e,Ls(fd(n),"float32"))}}},{kernelName:pr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Dl(e,n.shape)}}},{kernelName:fr,inputsToSave:["images"],gradFunc:(e,t,n)=>{const[r]=t,a={dy:e,images:r};return{images:()=>_i.runKernel(mr,a,n)}}},{kernelName:dr,inputsToSave:["images"],gradFunc:(e,t,n)=>{const[r]=t,a={dy:e,images:r};return{images:()=>_i.runKernel(hr,a,n)}}},{kernelName:yr,gradFunc:(e,t,n)=>{const{dims:r}=n,a=xe(r,e.shape);return{x:()=>Hp(e,a)}}},{kernelName:br,gradFunc:e=>({x:()=>Tu(e)})},{kernelName:vr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>ko(Nu(e,Mu(Pu(n,1.5),2)))}}},{kernelName:wr,inputsToSave:["condition"],gradFunc:(e,t)=>{const[n]=t;return{condition:()=>Ls(Tu(n),"float32"),t:()=>Mu(e,Ls(n,e.dtype)),e:()=>Mu(e,Ls(Zc(n),e.dtype))}}},pg,{kernelName:Tr,outputsToSave:[!0],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Mu(e,Mu(n,Hu(Ou(1),n)))}}},{kernelName:kr,gradFunc:e=>({x:()=>Tu(e)})},{kernelName:Mr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Mu(Zl(Ls(n,"float32")),e)}}},{kernelName:Sr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Mu(Ql(Ls(n,"float32")),e)}}},dg,{kernelName:Fr,outputsToSave:[!0],gradFunc:(e,t,n)=>{const[r]=t,{dim:a}=n,i=Mu(e,r);return{logits:()=>Hu(i,Mu(Nc(i,[a],!0),r))}}},{kernelName:Cr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Mu(e,kl(n))}}},hg,hg,fg,fg,{kernelName:Er,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Nu(e,Mu(Su(Ls(n,"float32")),2))}}},{kernelName:zr,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t,a=Ou(2);return{a:()=>Mu(e,Mu(a,Hu(n,r))),b:()=>Mu(e,Mu(a,Hu(r,n)))}}},{kernelName:Pr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Mu(e,Mu(Ls(n,"float32"),2))}}},{kernelName:aa,gradFunc:e=>({x:()=>Tu(e)})},{kernelName:Wr,inputsToSave:["a","b"],gradFunc:(e,t)=>{const[n,r]=t,a=Lo(n.shape,r.shape);return{a:()=>{let t=e;const r=Io(n.shape,a);return r.length>0&&(t=Nc(t,r)),Dl(t,n.shape)},b:()=>{let t=e;const n=Io(r.shape,a);return n.length>0&&(t=Nc(t,n)),Dl(ko(t),r.shape)}}}},mg,{kernelName:Vr,inputsToSave:["x"],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Nu(e,ku(Zl(n)))}}},{kernelName:Gr,outputsToSave:[!0],gradFunc:(e,t)=>{const[n]=t;return{x:()=>Mu(Hu(Ou(1),ku(n)),e)}}},gg,{kernelName:Zr,gradFunc:(e,t,n)=>{const r=n,{perm:a}=r,i=xc(a);return{x:()=>Co(e,i)}}},yg,bg,{kernelName:ra,gradFunc:e=>({x:()=>Tu(e)})}];for(const e of vg)ba(e);ni().prototype.abs=function(){return this.throwIfDisposed(),Uu(this)},ni().prototype.acos=function(){return this.throwIfDisposed(),Xu(this)},ni().prototype.acosh=function(){return this.throwIfDisposed(),Zu(this)},ni().prototype.add=function(e){return this.throwIfDisposed(),wu(this,e)},ni().prototype.all=function(e,t){return this.throwIfDisposed(),el(this,e,t)},ni().prototype.any=function(e,t){return this.throwIfDisposed(),tl(this,e,t)},ni().prototype.argMax=function(e){return this.throwIfDisposed(),nl(this,e)},ni().prototype.argMin=function(e){return this.throwIfDisposed(),rl(this,e)},ni().prototype.asScalar=function(){return this.throwIfDisposed(),se(1===this.size,(()=>"The array must have only 1 element.")),Dl(this,[])},ni().prototype.asType=function(e){return this.throwIfDisposed(),Ls(this,e)},ni().prototype.as1D=function(){return this.throwIfDisposed(),Dl(this,[this.size])},ni().prototype.as2D=function(e,t){return this.throwIfDisposed(),Dl(this,[e,t])},ni().prototype.as3D=function(e,t,n){return this.throwIfDisposed(),Dl(this,[e,t,n])},ni().prototype.as4D=function(e,t,n,r){return this.throwIfDisposed(),Dl(this,[e,t,n,r])},ni().prototype.as5D=function(e,t,n,r,a){return this.throwIfDisposed(),Dl(this,[e,t,n,r,a])},ni().prototype.asin=function(){return this.throwIfDisposed(),al(this)},ni().prototype.asinh=function(){return this.throwIfDisposed(),il(this)},ni().prototype.atan=function(){return this.throwIfDisposed(),sl(this)},ni().prototype.atan2=function(e){return this.throwIfDisposed(),ol(this,e)},ni().prototype.atanh=function(){return this.throwIfDisposed(),ul(this)},ni().prototype.avgPool=function(e,t,n,r){return this.throwIfDisposed(),Nl(this,e,t,n,r)},ni().prototype.batchToSpaceND=function(e,t){return this.throwIfDisposed(),Al(this,e,t)},ni().prototype.batchNorm=function(e,t,n,r,a){return this.throwIfDisposed(),Il(this,e,t,n,r,a)},ni().prototype.broadcastTo=function(e){return this.throwIfDisposed(),Yl(this,e)},ni().prototype.cast=function(e){return this.throwIfDisposed(),Ls(this,e)},ni().prototype.ceil=function(){return this.throwIfDisposed(),Bl(this)},ni().prototype.clipByValue=function(e,t){return this.throwIfDisposed(),zl(this,e,t)},ni().prototype.concat=function(e,t){return this.throwIfDisposed(),e instanceof ti&&(e=[e]),Sl([this,...e],t)},ni().prototype.conv1d=function(e,t,n,r,a,i){return this.throwIfDisposed(),Wl(this,e,t,n,r,a,i)},ni().prototype.conv2dTranspose=function(e,t,n,r,a){return this.throwIfDisposed(),Gl(this,e,t,n,r,a)},ni().prototype.conv2d=function(e,t,n,r,a,i){return this.throwIfDisposed(),ql(this,e,t,n,r,a,i)},ni().prototype.cos=function(){return this.throwIfDisposed(),Zl(this)},ni().prototype.cosh=function(){return this.throwIfDisposed(),Ql(this)},ni().prototype.cumprod=function(e,t,n){return this.throwIfDisposed(),ec(this,e,t,n)},ni().prototype.cumsum=function(e,t,n){return this.throwIfDisposed(),tc(this,e,t,n)},ni().prototype.depthToSpace=function(e,t){return this.throwIfDisposed(),rc(this,e,t)},ni().prototype.depthwiseConv2d=function(e,t,n,r,a,i){return this.throwIfDisposed(),ac(this,e,t,n,r,a,i)},ni().prototype.dilation2d=function(e,t,n,r,a){return this.throwIfDisposed(),sc(this,e,t,n,r,a)},ni().prototype.divNoNan=function(e){return this.throwIfDisposed(),lc(this,e)},ni().prototype.div=function(e){return this.throwIfDisposed(),Nu(this,e)},ni().prototype.dot=function(e){return this.throwIfDisposed(),cc(this,e)},ni().prototype.elu=function(){return this.throwIfDisposed(),dc(this)},ni().prototype.equal=function(e){return this.throwIfDisposed(),oc(this,e)},ni().prototype.erf=function(){return this.throwIfDisposed(),hc(this)},ni().prototype.euclideanNorm=function(e,t){return this.throwIfDisposed(),kc(this,e,t)},ni().prototype.exp=function(){return this.throwIfDisposed(),Tc(this)},ni().prototype.expandDims=function(e){return this.throwIfDisposed(),Cc(this,e)},ni().prototype.expm1=function(){return this.throwIfDisposed(),Ec(this)},ni().prototype.fft=function(){return this.throwIfDisposed(),sd(this)},ni().prototype.flatten=function(){return this.throwIfDisposed(),Dl(this,[this.size])},ni().prototype.floor=function(){return this.throwIfDisposed(),Lc(this)},ni().prototype.floorDiv=function(e){return this.throwIfDisposed(),Du(this,e)},ni().prototype.gather=function(e,t){return this.throwIfDisposed(),Fc(this,e,t)},ni().prototype.greaterEqual=function(e){return this.throwIfDisposed(),Oc(this,e)},ni().prototype.greater=function(e){return this.throwIfDisposed(),$c(this,e)},ni().prototype.ifft=function(){return this.throwIfDisposed(),od(this)},ni().prototype.irfft=function(){return this.throwIfDisposed(),ud(this)},ni().prototype.isFinite=function(){return this.throwIfDisposed(),Rc(this)},ni().prototype.isInf=function(){return this.throwIfDisposed(),Yc(this)},ni().prototype.isNaN=function(){return this.throwIfDisposed(),Bc(this)},ni().prototype.leakyRelu=function(e){return this.throwIfDisposed(),zc(this,e)},ni().prototype.lessEqual=function(e){return this.throwIfDisposed(),Hc(this,e)},ni().prototype.less=function(e){return this.throwIfDisposed(),Pc(this,e)},ni().prototype.localResponseNormalization=function(e,t,n,r){return this.throwIfDisposed(),Uc(this,e,t,n,r)},ni().prototype.logSigmoid=function(){return this.throwIfDisposed(),Gc(this)},ni().prototype.logSoftmax=function(e){return this.throwIfDisposed(),Kc(this,e)},ni().prototype.logSumExp=function(e,t){return this.throwIfDisposed(),Jc(this,e,t)},ni().prototype.log=function(){return this.throwIfDisposed(),qc(this)},ni().prototype.log1p=function(){return this.throwIfDisposed(),Wc(this)},ni().prototype.logicalAnd=function(e){return this.throwIfDisposed(),Xc(this,e)},ni().prototype.logicalNot=function(){return this.throwIfDisposed(),Zc(this)},ni().prototype.logicalOr=function(e){return this.throwIfDisposed(),Qc(this,e)},ni().prototype.logicalXor=function(e){return this.throwIfDisposed(),ep(this,e)},ni().prototype.matMul=function(e,t,n){return this.throwIfDisposed(),no(this,e,t,n)},ni().prototype.maxPool=function(e,t,n,r){return this.throwIfDisposed(),ap(this,e,t,n,r)},ni().prototype.max=function(e,t){return this.throwIfDisposed(),wc(this,e,t)},ni().prototype.maximum=function(e){return this.throwIfDisposed(),qu(this,e)},ni().prototype.mean=function(e,t){return this.throwIfDisposed(),op(this,e,t)},ni().prototype.min=function(e,t){return this.throwIfDisposed(),Dc(this,e,t)},ni().prototype.minimum=function(e){return this.throwIfDisposed(),pp(this,e)},ni().prototype.mirrorPad=function(e,t){return this.throwIfDisposed(),dp(this,e,t)},ni().prototype.mod=function(e){return this.throwIfDisposed(),hp(this,e)},ni().prototype.mul=function(e){return this.throwIfDisposed(),Mu(this,e)},ni().prototype.neg=function(){return this.throwIfDisposed(),ko(this)},ni().prototype.norm=function(e,t,n){return this.throwIfDisposed(),Sc(this,e,t,n)},ni().prototype.notEqual=function(e){return this.throwIfDisposed(),yp(this,e)},ni().prototype.oneHot=function(e,t=1,n=0){return this.throwIfDisposed(),ro(this,e,t,n)},ni().prototype.onesLike=function(){return this.throwIfDisposed(),bp(this)},ni().prototype.pad=function(e,t){return this.throwIfDisposed(),xp(this,e,t)},ni().prototype.pool=function(e,t,n,r,a,i){return this.throwIfDisposed(),Sp(this,e,t,n,r,a,i)},ni().prototype.pow=function(e){return this.throwIfDisposed(),Pu(this,e)},ni().prototype.prelu=function(e){return this.throwIfDisposed(),kp(this,e)},ni().prototype.prod=function(e,t){return this.throwIfDisposed(),Tp(this,e,t)},ni().prototype.reciprocal=function(){return this.throwIfDisposed(),Bp(this)},ni().prototype.relu=function(){return this.throwIfDisposed(),zp(this)},ni().prototype.relu6=function(){return this.throwIfDisposed(),Pp(this)},ni().prototype.reshapeAs=function(e){return this.throwIfDisposed(),Dl(this,e.shape)},ni().prototype.reshape=function(e){return this.throwIfDisposed(),Dl(this,e)},ni().prototype.resizeBilinear=function(e,t,n){return this.throwIfDisposed(),yh(this,e,t,n)},ni().prototype.resizeNearestNeighbor=function(e,t,n){return this.throwIfDisposed(),bh(this,e,t,n)},ni().prototype.reverse=function(e){return this.throwIfDisposed(),Hp(this,e)},ni().prototype.rfft=function(){return this.throwIfDisposed(),cd(this)},ni().prototype.round=function(){return this.throwIfDisposed(),Vp(this)},ni().prototype.rsqrt=function(){return this.throwIfDisposed(),Gp(this)},ni().prototype.selu=function(){return this.throwIfDisposed(),Kp(this)},ni().prototype.separableConv2d=function(e,t,n,r,a,i){return this.throwIfDisposed(),Jp(this,e,t,n,r,a,i)},ni().prototype.sigmoid=function(){return this.throwIfDisposed(),kl(this)},ni().prototype.sign=function(){return this.throwIfDisposed(),Zp(this)},ni().prototype.sin=function(){return this.throwIfDisposed(),Qp(this)},ni().prototype.sinh=function(){return this.throwIfDisposed(),ed(this)},ni().prototype.slice=function(e,t){return this.throwIfDisposed(),Tl(this,e,t)},ni().prototype.softmax=function(e){return this.throwIfDisposed(),id(this,e)},ni().prototype.softplus=function(){return this.throwIfDisposed(),Vc(this)},ni().prototype.spaceToBatchND=function(e,t){return this.throwIfDisposed(),Mp(this,e,t)},ni().prototype.split=function(e,t){return this.throwIfDisposed(),ld(this,e,t)},ni().prototype.sqrt=function(){return this.throwIfDisposed(),Su(this)},ni().prototype.square=function(){return this.throwIfDisposed(),ku(this)},ni().prototype.squaredDifference=function(e){return this.throwIfDisposed(),pd(this,e)},ni().prototype.squeeze=function(e){return this.throwIfDisposed(),dd(this,e)},ni().prototype.stack=function(e,t){this.throwIfDisposed();const n=e instanceof ti?[this,e]:[this,...e];return hd(n,t)},ni().prototype.step=function(e){return this.throwIfDisposed(),fd(this,e)},ni().prototype.stridedSlice=function(e,t,n,r,a,i,s,o){return this.throwIfDisposed(),md(this,e,t,n,r,a,i,s,o)},ni().prototype.sub=function(e){return this.throwIfDisposed(),Hu(this,e)},ni().prototype.sum=function(e,t){return this.throwIfDisposed(),Nc(this,e,t)},ni().prototype.tan=function(){return this.throwIfDisposed(),gd(this)},ni().prototype.tanh=function(){return this.throwIfDisposed(),Cl(this)},ni().prototype.tile=function(e){return this.throwIfDisposed(),Ac(this,e)},ni().prototype.toBool=function(){return this.throwIfDisposed(),Ls(this,"bool")},ni().prototype.toFloat=function(){return this.throwIfDisposed(),Ls(this,"float32")},ni().prototype.toInt=function(){return this.throwIfDisposed(),Ls(this,"int32")},ni().prototype.topk=function(e,t){return this.throwIfDisposed(),wd(this,e,t)},ni().prototype.transpose=function(e){return this.throwIfDisposed(),Co(this,e)},ni().prototype.unique=function(e){return this.throwIfDisposed(),Nd(this,e)},ni().prototype.unsortedSegmentSum=function(e,t){return this.throwIfDisposed(),Md(this,e,t)},ni().prototype.unstack=function(e){return this.throwIfDisposed(),Sd(this,e)},ni().prototype.where=function(e,t){return this.throwIfDisposed(),uc(e,this,t)},ni().prototype.zerosLike=function(){return this.throwIfDisposed(),Tu(this)};class xg extends Error{constructor(e){super(e),Object.setPrototypeOf(this,xg.prototype)}}class _g extends Error{constructor(e){super(e),Object.setPrototypeOf(this,_g.prototype)}}class wg extends Error{constructor(e){super(e),Object.setPrototypeOf(this,wg.prototype)}}class Dg extends Error{constructor(e){super(e),Object.setPrototypeOf(this,Dg.prototype)}}class Ng extends Error{constructor(e){super(e),Object.setPrototypeOf(this,Ng.prototype)}}Error;class Mg{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 e=this.cache.keys().next().value;this.cache.delete(e)}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;tt.toUpperCase()))}let Lg={};function Fg(e){if(null==e)return null;const t={};return t.className=e.getClassName(),t.config=e.getConfig(),t}function $g(e){if(null!=e&&"object"==typeof e)if(Array.isArray(e))e.forEach((e=>$g(e)));else{const t=Object.keys(e);for(const n of t){const t=e[n];null!=t&&"object"==typeof t&&(Array.isArray(t)||"ndarray"!==t.type||"number"!=typeof t.value?$g(t):e[n]=t.value)}}}function Og(e,t={},n={},r="object",a=!1){if("string"==typeof e){const a=e;let i;if(a in n)i=n[a];else if(a in Lg)i=Lg[a];else if(i=t[a],null==i)throw new wg(`Unknown ${r}: ${e}. This may be due to one of the following reasons:\n1. The ${r} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.\n2. The custom ${r} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);return i}{const i=e;if(null==i.className||null==i.config)throw new wg(`${r}: Improper config format: ${JSON.stringify(i)}.\n'className' and 'config' must set.`);const s=i.className;let o,u;if(s in n?[o,u]=n[s]:s in Lg?[o,u]=Lg.className:s in t&&([o,u]=t[s]),null==o)throw new wg(`Unknown ${r}: ${s}. This may be due to one of the following reasons:\n1. The ${r} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.\n2. The custom ${r} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);if(null!=u){const e={};for(const t of Object.keys(Lg))e[t]=Lg[t];for(const t of Object.keys(n))e[t]=n[t];i.config.customObjects=e;const t=Object.assign({},Lg);for(const e of Object.keys(n))Lg[e]=n[e];$g(i.config);const r=u(o,i.config,n,a);return Lg=Object.assign({},t),r}{const e=Object.assign({},Lg);for(const e of Object.keys(n))Lg[e]=n[e];const t=new o(i.config);return Lg=Object.assign({},e),t}}}function Rg(e,t){return-1*function(e,t){return et?1:0}(e,t)}function Yg(e){if(null==e)return e;const t=[];for(const n of e)-1===t.indexOf(n)&&t.push(n);return t}function Bg(e){if(null==e)throw new wg(`Invalid value in obj: ${JSON.stringify(e)}`);for(const t in e)if(e.hasOwnProperty(t))return!1;return!0}function zg(e,t,n){if(null!=n&&e.indexOf(n)<0)throw new wg(`${n} is not a valid ${t}. Valid values are ${e} or null/undefined.`)}function Pg(e,t,n=0,r=1/0){return kg(n>=0),kg(r>=n),Array.isArray(e)&&e.length>=n&&e.length<=r&&e.every((e=>typeof e===t))}function Hg(e,t){Array.isArray(e)?(se(e.length>0,(()=>`${t} is unexpectedly an empty array.`)),e.forEach(((e,n)=>Hg(e,`element ${n+1} of ${t}`)))):se(Number.isInteger(e)&&e>0,(()=>`Expected ${t} to be a positive integer, but got ${jg(e)}.`))}function jg(e){return null===e?"null":Array.isArray(e)?"["+e.map((e=>jg(e))).join(",")+"]":"string"==typeof e?`"${e}"`:`${e}`}function Ug(e){return"relu"===e?"relu":"linear"===e?"linear":"elu"===e?"elu":null}let qg=0;function Wg(){return qg++}const Vg={};function Gg(e=""){return e in Vg||(Vg[e]=0),Vg[e]+=1,e+Vg[e].toString()}const Kg=["channelsFirst","channelsLast"],Jg=["nearest","bilinear"],Xg=["valid","same","causal"],Zg=["max","avg"],Qg=["sum","mul","concat","ave"],ey=new Map;function ty(e){zg(Kg,"DataFormat",e)}function ny(e){zg(Xg,"PaddingMode",e)}function ry(e){zg(Zg,"PoolMode",e)}const ay=[];function iy(e,t){ay.push(e);try{const e=t();return ay.pop(),e}catch(e){throw ay.pop(),e}}function sy(e){if(!ly(e))throw new Error("Not a valid tensor name: '"+e+"'");return(0===ay.length?"":ay.join("/")+"/")+e}function oy(e){if(!ly(e))throw new Error("Not a valid tensor name: '"+e+"'");ey.has(e)||ey.set(e,0);const t=ey.get(e);if(ey.set(e,ey.get(e)+1),t>0){const n=`${e}_${t}`;return ey.set(n,1),n}return e}const uy=new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);function ly(e){return!!e.match(uy)}function cy(e,t,n){null==t&&(t=0),null==n&&(n=e.length);let r=1;for(let a=t;at&&(t=r)}return t}function hy(e,t){if(t{switch(e.rank){case 1:return td(e,t,n);case 2:return nd(e,[t,0],[n,e.shape[1]]);case 3:return rd(e,[t,0,0],[n,e.shape[1],e.shape[2]]);case 4:return ad(e,[t,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3]]);case 5:return Tl(e,[t,0,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3],e.shape[4]]);case 6:return Tl(e,[t,0,0,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3],e.shape[4],e.shape[5]]);default:throw new wg(`sliceAlongFirstAxis() received an unsupported tensor rank: ${e.rank}`)}}))}function vy(e,t,n){return ho((()=>{switch(e.rank){case 1:return td(e,t,n);case 2:return nd(e,[0,t],[e.shape[0],n]);case 3:return rd(e,[0,0,t],[e.shape[0],e.shape[1],n]);case 4:return ad(e,[0,0,0,t],[e.shape[0],e.shape[1],e.shape[2],n]);default:throw new wg(`sliceAlongLastAxis() received an unsupported tensor rank: ${e.rank}`)}}))}function xy(e,t,n,r){return ho((()=>{switch(e.rank){case 1:return td(e,t,n);case 2:switch(r){case 1:return by(e,t,n);case 2:return vy(e,t,n);default:throw new wg(`The axis is not within the rank of the tensor ${r}`)}case 3:switch(r){case 1:return by(e,t,n);case 2:return rd(e,[0,t,0],[e.shape[0],n,e.shape[2]]);case 3:return vy(e,t,n);default:throw new wg(`The axis is not within the rank of the tensor ${r}`)}case 4:switch(r){case 1:return by(e,t,n);case 2:return ad(e,[0,t,0,0],[e.shape[0],n,e.shape[2],e.shape[3]]);case 3:return ad(e,[0,0,t,0],[e.shape[0],e.shape[1],n,e.shape[3]]);case 4:return vy(e,t,n);default:throw new wg(`The axis is not within the rank of the tensor ${r}`)}default:throw new wg(`sliceAlongLastAxis() received an unsupported tensor rank: ${e.rank}`)}}))}function _y(e,t=-1){let n;return t<0&&(n=e[0].rank,t=0!==n?n:0),t===e[0].rank&&(t=-1),Sl(e,t)}function wy(e,t){switch(e.rank){case 1:return Pl([e,t]);case 2:return Hl([e,t],0);case 3:return jl([e,t],0);case 4:return Ul([e,t],0);default:throw new wg(`concatAlongFirstAxis() received an unsupported tensor rank: ${e.rank}`)}}function Dy(e,t){if(Array.isArray(t)||(t=[t]),e.rank!==t.length)throw new wg(`The length of input n (${t.length}) does not match the number of dimensions in input x (${e.rank})`);return Ac(e,t)}function Ny(e,t=0,n=1,r,a){return $p(e,t,n,r,a)}function My(e,t,n,r){if(e.rank<2||t.rank<2)throw new Dg(`dot requires both inputs to be rank >= 2 but got x shape = ${e.shape} and y shape = ${t.shape}`);if(t.rank>=3&&e.shape.slice(-1)[0]!==t.shape.slice(-2)[0])throw new Dg(`If rank y >= 3, then the second last dim of y must equal the last dim of x but got x shape = ${e.shape} and y shape = ${t.shape}`);if(2===e.rank&&2===t.rank)return Kd({a:e,b:t,transposeA:!1,transposeB:!1,bias:r?Ty(e.rank,r,"channelsLast"):null,activation:n});{const a=e.shape.slice(),i=a.pop();e=Dl(e,[-1,i]);const s=t.shape.slice(),o=s.pop(),u=s.pop(),l=[...s,o],c=Array.from({length:t.rank},((e,n)=>0===n?t.rank-2:n<=t.rank-2?n-1:n));t=Dl(Co(t,c),[u,-1]);const p=[...a,...l];return Dl(Kd({a:e,b:t,transposeA:!1,transposeB:!1,bias:r?Ty(e.rank,r,"channelsLast"):null,activation:n}),p)}}function Sy(e,t,n){return ho((()=>(t=Array.isArray(t)?yd(t,"int32"):Ls(t,"int32"),Fc(e,t,n))))}function ky(e){return Mu(e,e)}function Ty(e,t,n){const r=t.shape;if(1!==t.rank&&t.rank!==e)throw new wg(`Unexpected bias dimensions: ${t.rank}; expected it to be 1 or ${e}`);if(5===e){if("channelsFirst"===n)return 1===r.length?Dl(t,[1,r[0],1,1,1]):Dl(t,[1,r[3],r[0],r[1],r[2]]);if("channelsLast"===n)return 1===r.length?Dl(t,[1,1,1,1,r[0]]):Dl(t,[1].concat(r))}else if(4===e){if("channelsFirst"===n)return 1===r.length?Dl(t,[1,r[0],1,1]):Dl(t,[1,r[2],r[0],r[1]]);if("channelsLast"===n)return 1===r.length?Dl(t,[1,1,1,r[0]]):Dl(t,[1].concat(r))}else if(3===e){if("channelsFirst"===n)return 1===r.length?Dl(t,[1,r[0],1]):Dl(t,[1,r[1],r[0]]);if("channelsLast"===n)return 1===r.length?Dl(t,[1,1,r[0]]):Dl(t,[1].concat(r))}else if(e<3)return t;throw new wg(`Unsupported input rank by biasAdd: ${t.rank}`)}function Cy(e,t,n){return ho((()=>(null==n&&(n="channelsLast"),ty(n),wu(e,Ty(e.rank,t,n)))))}function Ey(e,t,n,r){return ho((()=>Od(e,t,n,r)))}function Ay(e,t,n=!1){return n?e():t()}const Iy=["fanIn","fanOut","fanAvg"],Ly=["normal","uniform","truncatedNormal"];class Fy extends ou{fromConfigUsesCustomObjects(){return!1}getConfig(){return{}}}class $y extends Fy{apply(e,t){return up(e,t)}}$y.className="Zeros",lu($y);class Oy extends Fy{apply(e,t){return lp(e,t)}}Oy.className="Ones",lu(Oy);class Ry extends Fy{constructor(e){if(super(),"object"!=typeof e)throw new wg(`Expected argument of type ConstantConfig but got ${e}`);if(void 0===e.value)throw new wg(`config must have value set but got ${e}`);this.value=e.value}apply(e,t){return ho((()=>Mu(Ou(this.value),lp(e,t))))}getConfig(){return{value:this.value}}}Ry.className="Constant",lu(Ry);class Yy extends Fy{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 Rp(e,this.minval,this.maxval,t)}getConfig(){return{minval:this.minval,maxval:this.maxval,seed:this.seed}}}Yy.className="RandomUniform",lu(Yy);class By extends Fy{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("float32"!==(t=t||"float32")&&"int32"!==t)throw new Dg(`randomNormal does not support dType ${t}.`);return Ny(e,this.mean,this.stddev,t,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}By.className="RandomNormal",lu(By);class zy extends Fy{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("float32"!==(t=t||"float32")&&"int32"!==t)throw new Dg(`truncatedNormal does not support dType ${t}.`);return Dd(e,this.mean,this.stddev,t,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}zy.className="TruncatedNormal",lu(zy);class Py extends Fy{constructor(e){super(),this.gain=null!=e.gain?e.gain:1}apply(e,t){return ho((()=>{if(2!==e.length||e[0]!==e[1])throw new wg("Identity matrix initializer can only be used for 2D square matrices.");return Mu(this.gain,Ic(e[0]))}))}getConfig(){return{gain:this.gain}}}Py.className="Identity",lu(Py);class Hy extends Fy{constructor(e){if(super(),e.scale<0)throw new wg(`scale must be a positive float. Got: ${e.scale}`);var t;this.scale=null==e.scale?1:e.scale,this.mode=null==e.mode?"fanIn":e.mode,t=this.mode,zg(Iy,"FanMode",t),this.distribution=null==e.distribution?"normal":e.distribution,function(e){zg(Ly,"Distribution",e)}(this.distribution),this.seed=e.seed}apply(e,t){const n=function(e,t="channelsLast"){let n,r;if(ty(t),2===e.length)n=e[0],r=e[1];else if(-1!==[3,4,5].indexOf(e.length)){if("channelsFirst"===t){const t=cy(e,2);n=e[1]*t,r=e[0]*t}else if("channelsLast"===t){const t=cy(e,0,e.length-2);n=e[e.length-2]*t,r=e[e.length-1]*t}}else{const t=cy(e);n=Math.sqrt(t),r=Math.sqrt(t)}return[n,r]}(e),r=n[0],a=n[1];let i=this.scale;if("fanIn"===this.mode?i/=Math.max(1,r):"fanOut"===this.mode?i/=Math.max(1,a):i/=Math.max(1,(r+a)/2),"normal"===this.distribution){const n=Math.sqrt(i);if("float32"!==(t=t||"float32")&&"int32"!==t)throw new Dg(`${this.getClassName()} does not support dType ${t}.`);return Dd(e,0,n,t,this.seed)}{const n=Math.sqrt(3*i);return Rp(e,-n,n,t)}}getConfig(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}}}Hy.className="VarianceScaling",lu(Hy);class jy extends Hy{constructor(e){super({scale:1,mode:"fanAvg",distribution:"uniform",seed:null==e?null:e.seed})}getClassName(){return Hy.className}}jy.className="GlorotUniform",lu(jy);class Uy extends Hy{constructor(e){super({scale:1,mode:"fanAvg",distribution:"normal",seed:null==e?null:e.seed})}getClassName(){return Hy.className}}Uy.className="GlorotNormal",lu(Uy);class qy extends Hy{constructor(e){super({scale:2,mode:"fanIn",distribution:"normal",seed:null==e?null:e.seed})}getClassName(){return Hy.className}}qy.className="HeNormal",lu(qy);class Wy extends Hy{constructor(e){super({scale:2,mode:"fanIn",distribution:"uniform",seed:null==e?null:e.seed})}getClassName(){return Hy.className}}Wy.className="HeUniform",lu(Wy);class Vy extends Hy{constructor(e){super({scale:1,mode:"fanIn",distribution:"normal",seed:null==e?null:e.seed})}getClassName(){return Hy.className}}Vy.className="LeCunNormal",lu(Vy);class Gy extends Hy{constructor(e){super({scale:1,mode:"fanIn",distribution:"uniform",seed:null==e?null:e.seed})}getClassName(){return Hy.className}}Gy.className="LeCunNormal",lu(Gy);class Ky extends Fy{constructor(e){if(super(),this.DEFAULT_GAIN=1,this.gain=null==e.gain?this.DEFAULT_GAIN:e.gain,this.seed=e.seed,null!=this.seed)throw new Dg("Random seed is not implemented for Orthogonal Initializer yet.")}apply(e,t){return ho((()=>{if(e.length<2)throw new Dg("Shape must be at least 2D.");e[0]*e[1]>2e3&&console.warn(`Orthogonal initializer is being called on a matrix with more than 2000 (${e[0]*e[1]}) elements: Slowness may result.`);const t=Ny(e[0]>e[1]?[e[1],e[0]]:e,0,1,"float32");let n=qh.gramSchmidt(t);return e[0]>e[1]&&(n=Co(n)),Mu(this.gain,n)}))}getConfig(){return{gain:this.gain,seed:this.seed}}}Ky.className="Orthogonal",lu(Ky);const Jy={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 Xy(e,t={}){return Og(e,uu.getMap().classNameMap,t,"initializer")}function Zy(e){return Fg(e)}function Qy(e){if("string"==typeof e){const t=e in Jy?Jy[e]:e;if("GlorotNormal"===t)return new Uy;if("GlorotUniform"===t)return new jy;if("HeNormal"===t)return new qy;if("HeUniform"===t)return new Wy;if("LeCunNormal"===t)return new Vy;if("LeCunUniform"===t)return new Gy;{const e={};return e.className=t,e.config={},Xy(e)}}return e instanceof Fy?e:Xy(e)}function eb(e){return Array.isArray(e)&&Array.isArray(e[0])}function tb(e){return 0===e.length?[]:Array.isArray(e[0])?e:[e]}function nb(e){let t;if(Array.isArray(e)){if(1!==e.length)throw new wg(`Expected Tensor length to be 1; got ${e.length}`);t=e[0]}else t=e;return t}function rb(e){if(Array.isArray(e)&&Array.isArray(e[0])){if(1===e.length)return e[0];throw new wg(`Expected exactly 1 Shape; got ${e.length}`)}return e}function ab(e){let t=0;for(const n of e)0===n.shape.length?t+=1:t+=n.shape.reduce(((e,t)=>e*t));return t}class ib{constructor(e,t="float32",n="Variable",r=!0,a=null){this.dtype=null==t?"float32":t,this.shape=e.shape,this.id=Wg(),n=null==n?"Variable":n,this.originalName=sy(n),this.name=oy(this.originalName),this.trainable_=r,this.constraint=a,this.val=Td(e,this.trainable_,this.name,this.dtype)}read(){return this.assertNotDisposed(),this.val}write(e){return this.assertNotDisposed(),function(e,t){if(e.shape.toString()!==t.shape.toString())throw new Error("Shape mismatch: "+JSON.stringify(e.shape)+" vs. "+JSON.stringify(t.shape))}(this.val,e),this.val.id!==e.id&&(this.val.assign(e),null!=this.constraint&&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 sb(e){return e.map((e=>e.read()))}function ob(e){e.forEach((e=>{e[0].write(e[1])}))}class ub{constructor(e){this.dtype=e.dtype,this.shape=e.shape,null!=e.shape?this.ndim=e.shape.length:this.ndim=e.ndim,this.maxNDim=e.maxNDim,this.minNDim=e.minNDim,this.axes=e.axes||{}}}class lb{constructor(e,t,n,r,a,i,s){this.dtype=e,this.shape=t,this.sourceLayer=n,this.inputs=r,this.callArgs=a,this.outputTensorIndex=s,this.id=Wg(),null!=i&&(this.originalName=sy(i),this.name=oy(this.originalName)),this.rank=t.length}}let cb=0;class pb{constructor(e,t){this.callArgs=t,this.id=cb++,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 t of e.inboundLayers)null!=t&&t.outboundNodes.push(this);e.outboundLayer.inboundNodes.push(this)}getConfig(){const e=[];for(const t of this.inboundLayers)null!=t?e.push(t.name):e.push(null);return{outboundLayer:this.outboundLayer?this.outboundLayer.name:null,inboundLayers:e,nodeIndices:this.nodeIndices,tensorIndices:this.tensorIndices}}}let db=0;class hb extends ou{constructor(e={}){super(),this._callHook=null,this._addedWeightNames=[],this._stateful=!1,this.id=db++,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 e=this.getClassName();t=Ag(e)+"_"+Gg(e)}if(this.name=t,this.trainable_=null==e.trainable||e.trainable,null!=e.inputShape||null!=e.batchInputShape){let t;if(null!=e.batchInputShape)t=e.batchInputShape;else if(null!=e.inputShape){let n=null;null!=e.batchSize&&(n=e.batchSize),t=[n].concat(e.inputShape)}this.batchInputShape=t;let n=e.dtype;null==n&&(n=e.inputDType),null==n&&(n="float32"),this.dtype=n}null!=e.weights?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(0===this.inboundNodes.length)throw new _g(`The layer has never been called and thus has no defined ${t}.`);if(this.inboundNodes.length<=e)throw new wg(`Asked to get ${t} at node ${e}, but the layer has only ${this.inboundNodes.length} inbound nodes.`);return this.inboundNodes[e]}getInputAt(e){return Cg(this.getNodeAtIndex(e,"input").inputTensors)}getOutputAt(e){return Cg(this.getNodeAtIndex(e,"output").outputTensors)}get input(){if(this.inboundNodes.length>1)throw new xg(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer input" is ill-defined. Use \`getInputAt(nodeIndex)\` instead.`);if(0===this.inboundNodes.length)throw new xg(`Layer ${this.name} is not connected, no input to return.`);return Cg(this.getNodeAtIndex(0,"input").inputTensors)}get output(){if(0===this.inboundNodes.length)throw new xg(`Layer ${this.name} has no inbound nodes.`);if(this.inboundNodes.length>1)throw new xg(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use \`getOutputAt(nodeIndex)\` instead.`);return Cg(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){if(e=Eg(e),null==this.inputSpec||0===this.inputSpec.length)return;const t=Eg(this.inputSpec);if(e.length!==t.length)throw new wg(`Layer ${this.name} expects ${t.length} inputs, but it received ${e.length} input tensors. Input received: ${e}`);for(let n=0;na.maxNDim)throw new wg(`Input ${n} is incompatible with layer ${this.name}: expected max_ndim=${a.maxNDim}, found ndim=${i}`);if(null!=a.minNDim&&i=0?e[r]:e[e.length+r];if(null!=i&&-1===[i,null].indexOf(s))throw new wg(`Input ${n} is incompatible with layer ${this.name}: expected axis ${r} of input shape to have value ${i} but got shape ${e}.`)}}if(null!=a.shape)for(let e=0;e{if(!this.built){this.assertInputCompatibility(e);const t=[];for(const n of Eg(e))t.push(n.shape);this.build(Cg(t)),this.built=!0,this.initialWeights&&this.setWeights(this.initialWeights),null===this._refCount&&a&&(this._refCount=1)}if(this.assertInputCompatibility(e),a){let r=this.call(e,t);const a=Eg(r),i=[];for(let e of a)-1!==n.indexOf(e)&&(e=e.clone()),i.push(e);if(r=Cg(i),null!=this.activityRegularizer)throw new Dg("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return r}{const n=function(e){e=Eg(e);const t=[];for(const n of e)t.push(n.shape);return Cg(t)}(e),r=this.computeOutputShape(n);let a;const i="float32";if(this.warnOnIncompatibleInputShape(Array.isArray(e)?n[0]:n),a=null!=r&&r.length>0&&Array.isArray(r[0])?r.map(((n,r)=>new lb(i,n,this,Eg(e),t,this.name,r))):new lb(i,r,this,Eg(e),t,this.name),this.addInboundNode(e,a,null,null,n,r,t),this._refCount++,null!=this.activityRegularizer)throw new Dg("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return a}}))}warnOnIncompatibleInputShape(e){if(null!=this.batchInputShape)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(((n,r)=>{null!=n&&null!=e[r]&&e[r]!==n&&(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(null==this.inboundNodes||0===this.inboundNodes.length)throw new xg(`The layer ${this.name} has never been called and thus has no defined output shape.`);const e=[];for(const t of this.inboundNodes){const n=JSON.stringify(t.outputShapes);-1===e.indexOf(n)&&e.push(n)}if(1===e.length){const e=this.inboundNodes[0].outputShapes;return Array.isArray(e)&&Array.isArray(e[0])&&1===e.length?e[0]:e}throw new xg(`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 _g(`You tried to call countParams() on ${this.name}, but the layer is not built yet. Build it first by calling build(batchInputShape).`);return ab(this.weights)}build(e){this.built=!0}getWeights(e=!1){return sb(e?this.trainableWeights:this.weights)}setWeights(e){ho((()=>{const t=this.weights;if(t.length!==e.length)throw new wg(`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(0===t.length)return;const n=[],r=sb(t);for(let a=0;aa.apply(l.read()))),null==i&&(i=!0),i?this._trainableWeights.push(l):this._nonTrainableWeights.push(l),l}setFastWeightInitDuringBuild(e){this.fastWeightInitDuringBuild=e}addLoss(e){null==e||Array.isArray(e)&&0===e.length||(e=Eg(e),void 0!==this._losses&&null!==this._losses&&this.losses.push(...e))}computeOutputShape(e){return e}computeMask(e,t){if(!this.supportsMasking){if(null!=t){if(!Array.isArray(t))throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`);t.forEach((e=>{if(null!=e)throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`)}))}return null}return t}addInboundNode(e,t,n,r,a,i,s=null){const o=Eg(e);t=Eg(t),n=Eg(n),r=Eg(r),a=tb(a),i=tb(i);const u=[],l=[],c=[];for(const e of o)u.push(e.sourceLayer),l.push(e.nodeIndex),c.push(e.tensorIndex);new pb({outboundLayer:this,inboundLayers:u,nodeIndices:l,tensorIndices:c,inputTensors:o,outputTensors:t,inputMasks:n,outputMasks:r,inputShapes:a,outputShapes:i},s);for(let e=0;ee.dispose())),this.weights.length}assertNotDisposed(){if(0===this._refCount)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(null===this._refCount)throw new Error(`Cannot dispose Layer ${this.name} because it has not been used yet.`);this.assertNotDisposed();let e=0;return 0==--this._refCount&&(e=this.disposeWeights()),{refCountAfterDispose:this._refCount,numDisposedVariables:e}}}function fb(e,t,n){if((null==t||null!=n&&n>0)&&(t=e.sourceLayer,n=e.nodeIndex),0===t.inboundNodes.length)return[e];{const e=t.inboundNodes[n];if(0===e.inboundLayers.length)return e.inputTensors;{const t=[];for(let n=0;ne.name)),u=[],l=t.names();for(const e of o)-1!==l.indexOf(e)?u.push(t.getValue(e)):u.push(null);null!=r&&(r.maxNumTensors=-1/0,r.minNumTensors=1/0);const c=o.join(",")+"|"+t.names().sort().join(",");let p,d=bb.get(c);if(null==d){const e=function(e,t){se(null!=e&&e.length>0,(()=>"Expected at least one fetch, got none"));let n=[],r={};if(1===e.length){const a=wb(e[0],t);n=a.sorted,r=a.recipientMap}else{const a=new Set;for(const i of e){const{sorted:e,recipientMap:s}=wb(i,t);for(const t of e)a.has(t.name)||(n.push(t),a.add(t.name));for(const e in s)null==r[e]&&(r[e]=new Set),s[e].forEach((t=>r[e].add(t)))}}return{sorted:n,recipientCounts:_b(r)}}(s,t);d=e.sorted,p=e.recipientCounts,bb.put(c,d),vb.put(c,p)}p={},a||Object.assign(p,vb.get(c));const h=new yb(t);for(let e=0;er.maxNumTensors&&(r.maxNumTensors=e),e0;){const e=i[i.length-1];if(n.has(e.name)){i.pop();continue}const t=s[s.length-1]===i.length-1;if(0===e.inputs.length||t)i.pop(),r.push(e),n.add(e.name),t&&s.pop();else{s.push(i.length-1);for(const t of e.inputs)null==a[t.name]&&(a[t.name]=new Set),a[t.name].add(e.name),n.has(t.name)||i.push(t)}}return{sorted:r,recipientMap:a}}function Db(e){let t;if(1===e.sourceLayer.inboundNodes.length)t=e.sourceLayer.output;else{let n=null;for(let t=0;tSu(Nc(Mu(e,e),t,!0))))}Ge().registerFlag("TOPOLOGICAL_SORT_CACHE_MAX_ENTRIES",(()=>100),(function(e){null!=bb&&bb.setMaxEntries(e),null!=vb&&vb.setMaxEntries(e)}));class Mb extends ou{getConfig(){return{}}}class Sb extends Mb{constructor(e){super(),this.defaultMaxValue=2,this.defaultAxis=0,this.maxValue=null!=e.maxValue?e.maxValue:this.defaultMaxValue,this.axis=null!=e.axis?e.axis:this.defaultAxis}apply(e){return ho((()=>{const t=Nb(e,this.axis),n=zl(t,0,this.maxValue);return Mu(e,Nu(n,wu(my(),t)))}))}getConfig(){return{maxValue:this.maxValue,axis:this.axis}}}Sb.className="MaxNorm",lu(Sb);class kb extends Mb{constructor(e){super(),this.defaultAxis=0,this.axis=null!=e.axis?e.axis:this.defaultAxis}apply(e){return ho((()=>Nu(e,wu(my(),Nb(e,this.axis)))))}getConfig(){return{axis:this.axis}}}kb.className="UnitNorm",lu(kb);class Tb extends Mb{apply(e){return zp(e)}}Tb.className="NonNeg",lu(Tb);class Cb extends Mb{constructor(e){super(),this.defaultMinValue=0,this.defaultMaxValue=1,this.defaultRate=1,this.defaultAxis=0,this.minValue=null!=e.minValue?e.minValue:this.defaultMinValue,this.maxValue=null!=e.maxValue?e.maxValue:this.defaultMaxValue,this.rate=null!=e.rate?e.rate:this.defaultRate,this.axis=null!=e.axis?e.axis:this.defaultAxis}apply(e){return ho((()=>{const t=Nb(e,this.axis),n=wu(Mu(this.rate,zl(t,this.minValue,this.maxValue)),Mu(1-this.rate,t));return Mu(e,Nu(n,wu(my(),t)))}))}getConfig(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}}}Cb.className="MinMaxNorm",lu(Cb);const Eb={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function Ab(e){return Fg(e)}function Ib(e,t={}){return Og(e,uu.getMap().classNameMap,t,"constraint")}function Lb(e){return null==e?null:"string"==typeof e?Ib({className:e in Eb?Eb[e]:e,config:{}}):e instanceof Mb?e:Ib(e)}function Fb(e){return new Sb(e)}function $b(e){return new kb(e)}function Ob(){return new Tb}function Rb(e){return new Cb(e)}function Yb(){return new $y}function Bb(){return new Oy}function zb(e){return new Ry(e)}function Pb(e){return new Yy(e)}function Hb(e){return new By(e)}function jb(e){return new zy(e)}function Ub(e){return new Py(e)}function qb(e){return new Hy(e)}function Wb(e){return new jy(e)}function Vb(e){return new Uy(e)}function Gb(e){return new qy(e)}function Kb(e){return new Wy(e)}function Jb(e){return new Vy(e)}function Xb(e){return new Gy(e)}function Zb(e){return new Ky(e)}async function Qb(e){if(null==e)return;const t=[],n=[],r=[];for(const a in e){const i=e[a];if("number"!=typeof i){const e=i;t.push(e.data()),n.push(a),r.push(e)}}if(t.length>0){const a=await Promise.all(t);for(let t=0;twu(this.totals[e],Mu(r,n))));this.totals[e]=a,null!=t&&t.dispose()}}}async onEpochEnd(e,t){if(null!=t)for(const e of this.params.metrics)null!=this.totals[e]&&("number"==typeof this.totals[e]?t[e]=this.totals[e]/this.seen:ho((()=>{const n=Mu(Nu(1,this.seen),this.totals[e]);t[e]=n,this.totals[e].dispose(),mo(t[e])})))}}class iv extends nv{async onTrainBegin(e){this.epoch=[],this.history={}}async onEpochEnd(e,t){null==t&&(t={}),this.epoch.push(e);for(const e in t)null==this.history[e]&&(this.history[e]=[]),this.history[e].push(t[e])}async syncData(){const e=[],t=[],n=[];for(const r in this.history){const a=this.history[r];for(let i=0;i{const s=null!=n?n():Ba();return s-anew sv(e,t)))}class uv{constructor(){}static registerCallbackConstructor(e,t){se(e>=0&&Number.isInteger(e),(()=>`Verbosity level is expected to be an integer >= 0, but got ${e}`)),uv.checkForDuplicate(t),null==uv.constructors[e]&&(uv.constructors[e]=[]),uv.constructors[e].push(t)}static checkForDuplicate(e){for(const t in uv.constructors)uv.constructors[+t].forEach((t=>{if(t===e)throw new wg("Duplicate callback constructor.")}))}static clear(){uv.constructors={}}static createCallbacks(e){const t=[];for(const n in uv.constructors){const r=+n;e>=r&&t.push(...uv.constructors[r])}return t.map((e=>new e))}}function lv(e,t,n,r,a,i,s,o,u){const l=new iv,c=[new av,...uv.createCallbacks(t)];null!=e&&c.push(...e),c.push(l);const p=new rv(c);return p.setParams({epochs:n,initialEpoch:r,samples:a,steps:i,batchSize:s,verbose:t,doValidation:o,metrics:u}),{callbackList:p,history:l}}function cv(e,t={},n=!1){return Og(e,uu.getMap().classNameMap,t,"layer",n)}function pv(e,t){return ho((()=>{"float32"!==e.dtype&&(e=Ls(e,"float32"));const n=Nc(ky(e),t,!0),r=Bu(n.shape,my()),a=Su(qu(n,r));return Nu(e,a)}))}function dv(e,t){return ho((()=>op(ky(Hu(t,e)),-1)))}function hv(e,t){return ho((()=>op(Uu(Hu(t,e)),-1)))}function fv(e,t){return ho((()=>{const n=Hu(e,t),r=zl(Uu(e),my(),Number.MAX_VALUE),a=Uu(Nu(n,r));return Mu(100,op(a,-1))}))}function mv(e,t,n=!1){return ho((()=>{if(n)t=id(t);else{const e=Nc(t,t.shape.length-1,!0);t=Nu(t,e)}return t=zl(t,my(),1-my()),ko(Nc(Mu(Ls(e,"float32"),qc(t)),t.shape.length-1))}))}function gv(e,t,n=!1){return ho((()=>{const r=Ls(Lc(function(e){const t=[cy(e.shape)];return Dl(e,t)}(e)),"int32"),a=(t=zl(t,my(),1-my())).shape;return mv(Dl(ro(r,a[a.length-1]),a),t,n)}))}function yv(e,t){return ho((()=>{let n;return n=zl(t,my(),1-my()),n=qc(Nu(n,Hu(1,n))),op(function(e,t){if(!de(e.shape,t.shape))throw new wg(`logits and labels must have the same shape, but got shapes ${JSON.stringify(e.shape)} and ${JSON.stringify(t.shape)}`);return ho((()=>{const n=zp(t),r=ko(Uu(t));return wu(Hu(n,Mu(t,e)),Wc(Tc(r)))}))}(e,n),-1)}))}function bv(e,t){return ho((()=>{const n=pv(e,-1),r=pv(t,-1),a=Mu(n,r);return ko(Nc(a,-1))}))}uv.constructors={};const vv={meanSquaredError:dv,meanAbsoluteError:hv,meanAbsolutePercentageError:fv,meanSquaredLogarithmicError:function(e,t){return ho((()=>{const n=zl(t,my(),Number.MAX_VALUE),r=qc(wu(1,n)),a=zl(e,my(),Number.MAX_VALUE),i=qc(wu(1,a));return op(ky(Hu(r,i)),-1)}))},squaredHinge:function(e,t){return ho((()=>{const n=qu(0,Hu(1,Mu(e,t)));return op(ky(n),-1)}))},hinge:function(e,t){return ho((()=>{const n=qu(0,Hu(1,Mu(e,t)));return op(n,-1)}))},categoricalHinge:function(e,t){return ho((()=>{const n=Nc(Mu(e,t),-1),r=wc(Mu(Hu(1,e),t),-1);return qu(0,wu(1,Hu(r,n)))}))},logcosh:function(e,t){return ho((()=>{const n=Math.log(2),r=Hu(t,e),a=Hu(wu(r,Vc(Mu(-2,r))),n);return op(a,-1)}))},categoricalCrossentropy:mv,sparseCategoricalCrossentropy:gv,binaryCrossentropy:yv,kullbackLeiblerDivergence:function(e,t){return ho((()=>{const n=zl(e,my(),1),r=zl(t,my(),1);return Nc(Mu(e,qc(Nu(n,r))),-1)}))},poisson:function(e,t){return ho((()=>{const n=qc(wu(my(),t));return op(Hu(t,Mu(e,n)),-1)}))},cosineProximity:bv};function xv(e){if("string"==typeof e){if(e in vv)return vv[e];let t=`Unknown loss ${e}`;throw e.toLowerCase().includes("softmaxcrossentropy")&&(t=`Unknown loss ${e}. Use "categoricalCrossentropy" as the string name for tf.losses.softmaxCrossEntropy`),new wg(t)}return e}function _v(e,t){return ho((()=>{const n=Mu(.5,bp(t)),r=gy($c(t,n),e.dtype);return op(oc(e,r),-1)}))}function wv(e,t){return ho((()=>gy(oc(nl(e,-1),nl(t,-1)),"float32")))}function Dv(e,t){return ho((()=>Ls(Nc(Xc(oc(e,1),oc(t,1))),"float32")))}function Nv(e,t){return ho((()=>{const n=Dv(e,t),r=function(e,t){return ho((()=>Ls(Nc(Xc(oc(e,0),oc(t,1))),"float32")))}(e,t),a=wu(n,r);return Ls(uc($c(a,0),Nu(n,a),0),"float32")}))}function Mv(e,t){return yv(e,t)}function Sv(e,t){return e.rank===t.rank&&(e=dd(e,[e.rank-1])),(t=nl(t,-1)).dtype!==e.dtype&&(t=Ls(t,e.dtype)),Ls(oc(e,t),"float32")}const kv=mv,Tv=gv,Cv={binaryAccuracy:_v,categoricalAccuracy:wv,precision:Nv,categoricalCrossentropy:kv,sparseCategoricalCrossentropy:Tv,mse:dv,MSE:dv,mae:hv,MAE:hv,mape:fv,MAPE:fv,cosine:bv};function Ev(e){if("string"==typeof e&&e in Cv)return Cv[e];if("string"!=typeof e&&null!=e)return e;throw new wg(`Unknown metric ${e}`)}function Av(e){if(kg(null!==e,`Unknown LossOrMetricFn ${e}`),"string"==typeof e)return e;{let t;for(const n of Object.keys(vv))if(vv[n]===e){t=n;break}if(void 0!==t)return t;for(const n of Object.keys(Cv))if(Cv[n]===e){t=n;break}return void 0!==t?t:e.name}}function Iv(e,t,n=!1){if(null==e||"object"!=typeof e||Object.getPrototypeOf(e)!==Object.prototype||!Lv(e))throw new Error("User-defined metadata is expected to be a JSON object, but is not.");if(n){const n=JSON.stringify(e);n.length>1048576&&console.warn(`User-defined metadata of model "${t}" is too large in size (length=${n.length} when serialized). It is not recommended to store such large objects in user-defined metadata. Please make sure its serialized length is <= 1048576.`)}}function Lv(e){if(null===e)return!0;if("object"==typeof e){if(Object.getPrototypeOf(e)===Object.prototype){const t=Object.keys(e);for(const n of t){if("string"!=typeof n)return!1;if(!Lv(e[n]))return!1}return!0}if(Array.isArray(e)){for(const t of e)if(!Lv(t))return!1;return!0}return!1}{const t=typeof e;return"string"===t||"number"===t||"boolean"===t}}function Fv(e,t,n=console.log){let r="";for(let n=0;n0&&(r=r.slice(0,r.length-1)+" "),r+=e[n],r=r.slice(0,t[n]),r+=" ".repeat(t[n]-r.length);n(r)}function $v(e,t,n){let r,a;try{a=e.inboundNodes.map((e=>JSON.stringify(e.inputShapes))).join(",")}catch(e){a="multiple"}try{r=JSON.stringify(e.outputShape)}catch(e){r="multiple"}Fv([`${e.name} (${e.getClassName()})`,a,r,e.countParams().toString()],t,n)}function Ov(e,t,n,r){let a,i;try{i=e.inboundNodes.map((e=>JSON.stringify(e.inputShapes))).join(",")}catch(e){i="multiple"}try{a=JSON.stringify(e.outputShape)}catch(e){a="multiple"}const s=[];for(const t of e.inboundNodes)if(!(null!=n&&n.length>0&&-1===n.indexOf(t)))for(let e=0;ee.name))}`);Yg(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((e=>e.name))}`),this.inputLayers=[],this.inputLayersNodeIndices=[],this.inputLayersTensorIndices=[],this.outputLayers=[],this.outputLayersNodeIndices=[],this.outputLayersTensorIndices=[],this.layers=[],this.internalContainerRefs=[];for(const e of this.outputs){const t=e.sourceLayer,n=e.nodeIndex,r=e.tensorIndex;this.outputLayers.push(t),this.outputLayersNodeIndices.push(n),this.outputLayersTensorIndices.push(r)}for(const e of this.inputs){const t=e.sourceLayer,n=e.nodeIndex,r=e.tensorIndex;kg(0===n,"input layer has >1 nodes"),kg(0===r,"input layer has >1 tensors"),this.inputLayers.push(t),this.inputLayersNodeIndices.push(n),this.inputLayersTensorIndices.push(r)}this.inputNames=[],this.outputNames=[],this.feedInputShapes=[],this.feedInputNames=[],this.feedOutputNames=[];for(let t=0;te.shape)),this.internalOutputShapes=this.outputs.map((e=>e.shape));const t={},n={},r={},a={},i={},s=[],o=(e,t,n,r,a,u)=>{null!=r&&null!=a&&null!=u||(r=e.sourceLayer,a=e.nodeIndex,u=e.tensorIndex);const l=r.inboundNodes[a];if(-1!==n.indexOf(l))throw new _g(`The tensor ${e.name} at layer "${r.name}" is part of a cycle.`);if(-1!==t.indexOf(l))return;this.containerNodes.add(Pv.nodeKey(r,a)),r.id in i||(i[r.id]=Object.keys(i).length),-1===n.indexOf(l)&&n.push(l);const c=l.inboundLayers.length;for(let e=0;e=0;)n.splice(n.indexOf(l),1);s.push(l)},u=[],l=[];for(const e of this.outputs)o(e,u,l);const c=s.slice().reverse();for(const e of c){n[e.id]=e,e.id in t||(t[e.id]=0);let i=t[e.id];const s=null==r[e.outboundLayer.id]?0:r[e.outboundLayer.id];i=Math.max(i,s),r[e.outboundLayer.id]=i,a[e.outboundLayer.id]=e.outboundLayer,t[e.id]=i;for(let r=0;rparseInt(e,10))).sort(Rg);this.layers=[];for(const e of h){const t=d[e];t.sort(((e,t)=>{const n=i[e.id],r=i[t.id];return nr?1:0}));for(const e of t)e instanceof Pv&&this.internalContainerRefs.push(e),this.layers.push(e)}this.layersByDepth=d,h=Object.keys(p).map((e=>parseInt(e,10))).sort(Rg);const f=this.inputs.slice(),m=[];for(const e of h)for(const t of p[e]){const e=t.outboundLayer;if(null!=e){for(const n of t.inputTensors)if(-1===f.indexOf(n))throw new _g(`Graph disconnected: cannot obtain value for tensor ${n} at layer "${e.name}". The following previous layers were accessed without issue: ${m}`);for(const e of t.outputTensors)f.push(e);m.push(e.name)}}this.nodesByDepth=p;const g=this.layers.map((e=>e.name));for(const e of g){const t=g.filter((t=>t===e)).length;if(1!==t)throw new _g(`The name "${e}" is used ${t} times in the model. All layer names should be unique. Layer names: `+JSON.stringify(g))}this.outboundNodes=[],this.inboundNodes=[],new pb({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:this.inputs.map((e=>null)),outputMasks:this.outputs.map((e=>null)),inputShapes:this.inputs.map((e=>e.shape)),outputShapes:this.outputs.map((e=>e.shape))}),this.built=!0,this._refCount=1}assertNotDisposed(){if(0===this._refCount)throw new Error(`Container '${this.name}' is already disposed.`)}dispose(){this.assertNotDisposed();const e={refCountAfterDispose:null,numDisposedVariables:0};if(0==--this._refCount){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((t=>t.trainable=e))})),this.trainable_=e}get trainableWeights(){if(this._trainableWeights.length>0)throw new wg("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 e of this.layers)t.push(...e.trainableWeights);return t.concat(e)}return e}get weights(){return this.trainableWeights.concat(this.nonTrainableWeights)}loadWeights(e,t=!0){const n={};let r=0;for(const e of this.layers)for(const t of e.weights){if(null!=n[t.originalName])throw new wg(`Duplicate weight name: ${t.originalName}`);n[t.originalName]=t,r++}const a=[];for(const r in e){let i=r;if(null==n[r]){const e=r.split("/");i=e.slice(0,-2).concat([e[e.length-1]]).join("/")}if(null!=n[i])a.push([n[i],e[r]]);else if(t)throw new wg(`Provided weight data has no target variable: ${r}`);delete n[i]}if(t){const e=[];for(const t in n)e.push(t);if(e.length>0)throw new wg(`${e.length} of ${r} weights are not set: ${e}`)}ob(a)}updatedConfig(){const e=this.getConfig(),t={};return t.className=this.getClassName(),t.config=e,t.kerasVersion=`tfjs-layers ${zv}`,t.backend="TensorFlow.js",t}toJSON(e,t=!0){const n=Bv(this.updatedConfig());return t?JSON.stringify(n):n}call(e,t){return ho((()=>{e=Eg(e);const n=new yb;for(let t=0;t{let n;return e=Eg(e),n=null==t?Sg(null,e.length):Eg(t),this.runInternalGraph(e,n)[1]}))}computeOutputShape(e){const t=tb(e);if(t.length!==this.inputLayers.length)throw new wg(`Invalid inputShape argument ${e}: model has ${this.inputLayers.length} tensor inputs.`);const n={};for(let e=0;eparseInt(e,10))).sort(Rg);if(r.length>1)for(const e of r){const t=this.nodesByDepth[e];for(const e of t){const t=e.outboundLayer;if(-1!==this.inputLayers.map((e=>e.id)).indexOf(t.id))continue;const r=[];for(let t=0;tparseInt(e,10))).sort(Rg);for(const e of r){const t=this.nodesByDepth[e];for(const e of t){const t=e.outboundLayer,r=e.inputTensors,a=e.outputTensors,i=new Array;for(const e of r)e.id in n&&i.push(n[e.id]);if(i.length===r.length){let r,s,o,u,l={};if(null!=e.callArgs&&(l=e.callArgs),1===i.length){const[e,n]=i[0];null==l.mask&&(l.mask=n),o=Eg(t.call(e,l)),u=Eg(t.computeMask(e,n)),r=[e],s=[n]}else r=i.map((e=>e[0])),s=i.map((e=>e[1])),null==l.mask&&(l.mask=s),o=Eg(t.call(r,l)),u=Eg(t.computeMask(r,s));if(t.activityRegularizer)throw new Dg("LayersModel invocation with concrete Tensor value(s) in the presence of activity regularizer(s) is not supported yet.");for(let e=0;e{const e=[];for(const t of this.layers)for(let n=0;n0){const e=[];for(let n=0;n0&&e.apply(Cg(n),r)}function u(e){const n=e.name,i=cv(e,null!=t.customObjects?t.customObjects:{});i.setFastWeightInitDuringBuild(r),a[n]=i,e.inboundNodes.forEach((e=>{if(!(e instanceof Array))throw new wg(`Corrupted configuration, expected array for nodeData: ${e}`);s(i,e)}))}const l=t.name,c=t.layers;for(const e of c)u(e);for(;!Bg(i);)for(const e of c){const t=a[e.name];if(t.name in i){const e=i[t.name];delete i[t.name];for(const n of e)o(t,n)}}const p=[],d=[],h=t.inputLayers;for(const e of h){const t=e[0],n=e[1],r=e[2];kg(t in a);const i=a[t].inboundNodes[n].outputTensors;p.push(i[r])}const f=t.outputLayers;for(const e of f){const t=e[0],n=e[1],r=e[2];kg(t in a);const i=a[t].inboundNodes[n].outputTensors;d.push(i[r])}return new e({inputs:p,outputs:d,name:l})}get stateful(){if(this._stateful)throw new wg("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(){ho((()=>{this.layers.forEach((e=>{e.stateful&&e.resetStates()}))}))}}function Hv(e,t){return function(e,t,n){const r=t.length;if(null==e||Array.isArray(e)&&0===e.length)return t.map((e=>null));if(1===r)return Array.isArray(e)&&1===e.length?e:"object"==typeof e&&t[0]in e?[e[t[0]]]:[e];if(Array.isArray(e)){if(e.length!==r)throw new Error(`Provided ${n} is an array of ${e.length} element(s), but the model has ${r} outputs. Make sure a set of weights is provided for each model output.`);return e}if("object"==typeof e&&Object.keys(e).length>0&&"object"==typeof e[Object.keys(e)[0]]){const n=[];return t.forEach((t=>{t in e?n.push(e[t]):n.push(null)})),n}throw new Error(`The model has multiple (${r}) outputs, so ${n} must be either an array with ${r} elements or an object with ${t} keys. Provided ${n} not understood: ${JSON.stringify(e)}`)}(e,t,"classWeight")}async function jv(e,t,n,r){if(null!=t||null!=r)throw new Error("Support sampleWeight is not implemented yet");if(null!=n){const t=ho((()=>{if(1===e.shape.length)return Fs(e);if(2===e.shape.length){if(e.shape[1]>1)return nl(e,1);if(1===e.shape[1])return Dl(e,[e.shape[0]]);throw new Error(`Encountered unexpected last-dimension size (${e.shape[1]}) during handling of class weights. The size is expected to be >= 1.`)}throw new Error(`Unexpected rank of target (y) tensor (${e.rank}) during handling of class weights. The rank is expected to be 1 or 2.`)})),r=Array.from(await t.data());fo(t);const a=[];return r.forEach((e=>{if(null==n[e])throw new Error(`classWeight must contain all classes in the training data. The class ${e} exists in the data but not in classWeight`);a.push(n[e])})),yd(a,"float32")}return null}function Uv(e,t){return Mu(e,t)}function qv(e,t){let n,r;const a=t;n=a.xs,r=a.ys,se(null!=n&&null!=r,(()=>`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 ${t}`));const i=Wv("input",e.inputNames,n),s=Wv("output",e.outputNames,r),o=i[0].shape[0];se(i.length===e.inputs.length,(()=>`LayersModel has ${e.inputs.length} inputs, but the dataset provides ${i.length} inputs. (Expected input keys: ${JSON.stringify(e.inputNames)})`)),se(s.length===e.outputs.length,(()=>`LayersModel has ${e.outputs.length} outputs, but the dataset provides ${s.length} outputs. (Expected output keys: ${JSON.stringify(e.outputNames)})`));for(let t=0;t`Batch size mismatch: input ${e.inputNames[t]} has ${i[t].shape[0]}; expected ${o} based on input ${e.inputNames[0]}.`));for(let t=0;t`Batch size mismatch: output ${e.outputNames[t]} has ${s[t].shape[0]}; expected ${o} based on input ${e.inputNames[0]}.`));return{xs:i,ys:s}}function Wv(e,t,n){if(n instanceof ti)return[n];if(Array.isArray(n))return se(n.length===t.length,(()=>`Received an array of ${n.length} Tensors, but expected ${t.length} to match the ${e} keys ${t}.`)),n;{const r=[];for(const a of t){if(null==n[a])throw new wg(`The feature data generated by the dataset lacks the required ${e} key '${a}'.`);r.push(n[a])}return r}}function Vv(e){return"function"==typeof e.iterator}function Gv(e){se(e>0&&Number.isInteger(e),(()=>`batchSize is required to be a positive integer, but got ${e}`))}function Kv(e,t,n){return null==e?[null]:Array.isArray(e)?e.map((e=>by(e,t,n-t))):by(e,t,n-t)}function Jv(e,t){return ho((()=>null==e?null:Array.isArray(e)?e.map((e=>Jv(e,t))):Sy(e,"int32"===t.dtype?t:Ls(t,"int32"))))}function Xv(e,t){const n=[];let r=0,a=null;for(;r=e&&(a=e),n.push([r,a]),r=a;return n}function Zv(e){const t=[];e instanceof ti&&(e=[e]);for(let n=0;nn.push(e.id)));else if(null!=t)for(const e in t){const r=t[e];n.push(r.id)}const r=[];if(e instanceof ti)-1===n.indexOf(e.id)&&r.push(e);else if(Array.isArray(e))e.forEach((e=>{-1===n.indexOf(e.id)&&r.push(e)}));else if(null!=e)for(const t in e){const a=e[t];-1===n.indexOf(a.id)&&r.push(a)}r.forEach((e=>{e.isDisposed||e.dispose()}))}function ex(e){return Array.isArray(e)}function tx(e){return!function(e){return e instanceof ti}(e)&&!ex(e)}function nx(e,t,n,r=!0,a=""){if(null==t||0===t.length){if(null!=e){let t=!1;if(ex(e)&&e.length>0)t=!0;else if(tx(e)){for(const n in e)if(e.hasOwnProperty(n)){t=!0;break}}else t=!0;if(t)throw new wg(`Error when checking model ${a} expected no data, but got ${e}`)}return[]}if(null==e)return t.map((e=>null));let i;if(tx(e)){i=[];for(const n of t){if(null==e[n])throw new wg(`No data provided for "${n}". Need data for each key in: ${t}`);i.push(e[n])}}else if(ex(e)){if(e.length!==t.length)throw new wg(`Error when checking model ${a}: the Array of Tensors that you are passing to your model is not the size the model expected. Expected to see ${t.length} Tensor(s), but instead got the following list of Tensor(s): ${e}`);i=e}else{if(t.length>1)throw new wg(`The model ${a} expects ${t.length} Tensor(s), but only received one Tensor. Found: Tensor with shape ${e.shape}`);i=[e]}if(i=Zv(i),null!=n)for(let e=0;e=0&&i!==o)throw new wg(`${a} expected a batch of elements where each example has shape [${n[e].slice(1,n[e].length)}] (i.e.,tensor shape [*,${n[e].slice(1,n[e].length)}]) but the ${a} received an input with ${s.shape[0]} examples, each with shape [${s.shape.slice(1,s.shape.length)}] (tensor shape [${s.shape}])`)}}return i}function rx(e,t,n,r=!0,a=""){let i;if(Array.isArray(e)){if(e.length!==t.length)throw new wg(`Error when checking model ${a}: the Array of Tensors that you are passing to your model is not the size the the model expected. Expected to see ${t.length} Tensor(s), but instead got ${e.length} Tensors(s).`);i=e}else{if(t.length>1)throw new wg(`The model expects ${t.length} ${a} Tensors, but only received one Tensor. Found: array with shape ${JSON.stringify(e.shape)}.`);i=[e]}if(null!=n)for(let e=0;e1||1===e.length&&e[0].inboundLayers.length>1){t=!1;break}r.push(...e)}if(t)for(const n of e.layers){let e=!1;for(const a of n.inboundNodes)if(-1!==r.indexOf(a)){if(e){t=!1;break}e=!0}if(!t)break}return t}(e),i=["Layer (type)","Input Shape","Output shape","Param #"];let s;if(a?(t=t||90,n=n||[.32,.61,.89,1]):(t=t||115,n=n||[.24,.48,.7,.8,1]),n[n.length-1]<=1&&(n=n.map((e=>Math.floor(t*e)))),!a){i.push("Receives inputs"),s=[];for(const t in e.nodesByDepth)s.push(...e.nodesByDepth[t])}r("_".repeat(t)),Fv(i,n,r),r("=".repeat(t));const o=e.layers;for(let e=0;eKh.adagrad(.01),Adadelta:()=>Kh.adadelta(1,.95,my()),Adam:()=>Kh.adam(.001,.9,.999,my()),Adamax:()=>Kh.adamax(.002,.9,.999,my(),0),RMSProp:()=>Kh.rmsprop(.001,.9,0,my()),SGD:()=>Kh.sgd(.01)};if(t.adagrad=t.Adagrad,t.adadelta=t.Adadelta,t.adam=t.Adam,t.adamax=t.Adamax,t.rmsprop=t.RMSProp,t.sgd=t.SGD,e in t)return t[e]();throw new wg(`Unknown Optimizer ${e}`)}(e.optimizer),this.isOptimizerOwned=!0;else{if(!(e.optimizer instanceof Ru))throw new wg("User-defined optimizer must be an instance of tf.Optimizer.");this.optimizer_=e.optimizer,this.isOptimizerOwned=!1}let t=[];if(Array.isArray(e.loss)||"string"==typeof e.loss||"function"==typeof e.loss)if(Array.isArray(e.loss)){if(e.loss.length!==this.outputs.length)throw new wg(`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}.`);const n=e.loss;t=n.map((e=>xv(e)))}else{const n=xv(e.loss);this.outputs.forEach((e=>{t.push(n)}))}else{e.loss=e.loss;for(const t in e.loss)if(-1===this.outputNames.indexOf(t))throw new wg(`Unknown entry in loss dictionary: "${t}". Only expected the following keys: ${this.outputNames}`);for(const n of this.outputNames)null==e.loss[n]&&console.warn(`Output "${n}" is missing from loss dictionary. We assume this was done on purpose, and we will not be expecting data to be passed to ${n} during training`),t.push(xv(e.loss[n]))}this.lossFunctions=t,this.feedOutputNames=[],this.feedOutputShapes=[],this.feedLossFns=[];for(let e=0;e{for(let e=0;e1&&(this.metricsTensors.push([t,e]),this.metricsNames.push(this.outputNames[e]+"_loss"))}}));const r=function(e,t){if(null==e||Array.isArray(e)&&0===e.length)return t.map((e=>[]));let n;if("string"==typeof e||"function"==typeof e)n=[e];else{if(!Array.isArray(e)&&"object"!=typeof e)throw new TypeError(`Type of metrics argument not understood. Expected an string,function, Array, or Object, found: ${e}`);n=e}if(Array.isArray(n))return t.map((e=>n));{const e=[];for(const r of t){let t=n.hasOwnProperty(r)?n[r]:[];Array.isArray(t)||(t=[t]),e.push(t)}return e}}(e.metrics,this.outputNames),a=(e,t,n)=>{this.outputNames.length>1&&(t=this.outputNames[e]+"_"+t),this.metricsNames.push(t),this.metricsTensors.push([n,e])};iy("metric",(()=>{for(let e=0;e{let n,r,i;for(const s of t){if("string"==typeof s&&-1!==["accuracy","acc","crossentropy","ce"].indexOf(s)){const t=this.internalOutputShapes[e];let a;1===t[t.length-1]||this.lossFunctions[e]===yv?-1!==["accuracy","acc"].indexOf(s)?r=_v:-1!==["crossentropy","ce"].indexOf(s)&&(r=Mv):this.lossFunctions[e]===gv?-1!==["accuracy","acc"].indexOf(s)?r=Sv:-1!==["crossentropy","ce"].indexOf(s)&&(r=Tv):-1!==["accuracy","acc"].indexOf(s)?r=wv:-1!==["crossentropy","ce"].indexOf(s)&&(r=kv),-1!==["accuracy","acc"].indexOf(s)?a="acc":-1!==["crossentropy","ce"].indexOf(s)&&(a="ce"),i=r,n=""+a}else{const e=Ev(s);i=e,n=""+Av(s)}let t;iy(n,(()=>{t=i})),a(e,n,t)}})(r[e])})),this.collectedTrainableWeights=this.trainableWeights}checkTrainableWeightsConsistency(){null!=this.collectedTrainableWeights&&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,n={}){const r=null==n.batchSize?32:n.batchSize;Gv(r);const a=this.standardizeUserDataXY(e,t,!0,r);try{const i=a[0].concat(a[1]);this.makeTestFunction();const s=this.testFunction;return Cg(this.testLoop(s,i,r,n.verbose,n.steps))}finally{Qv(a[0],e),Qv(a[1],t)}}async evaluateDataset(e,t){return this.makeTestFunction(),async function(e,t,n){const r=null!=(n=n||{}).batches,a=e.testFunction;let i=[];if(n.verbose>0)throw new Dg("Verbose mode is not implemented yet.");se(!r||n.batches>0&&Number.isInteger(n.batches),(()=>`Test loop expects \`batches\` to be a positive integer, but received ${JSON.stringify(n.batches)}`));const s="function"==typeof t.next?t:await t.iterator();let o=0,u=0;for(;!r||u{if(t.value){const{xs:n,ys:r}=qv(e,t.value),s=n.concat(r),l=ho((()=>a(s)));if(fo(s),0===u)for(let e=0;ewu(i[e],Mu(c,t)))),u>0&&fo(n)}fo(l),o+=c,++u}return i})),t.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, ${n.batches} batches). You may need to use the repeat() function when building your dataset.`);break}}for(let e=0;ee.name));for(let r=0;r0){const n=[];throw t.forEach(((t,r)=>{null==t&&n.push(e[r])})),new wg(`Cannot find SymbolicTensors for output name(s): ${JSON.stringify(n)}`)}return t}predictLoop(e,t=32,n=!1){return ho((()=>{const r=this.checkNumSamples(e);if(n)throw new Dg("Verbose predictLoop() is not implemented yet.");const a=Xv(r,t),i=this.outputs.map((e=>[]));for(let t=0;t{const n=a[t][0],r=a[t][1],i=Kv(e,n,r),s=[];if(Array.isArray(i))for(let e=0;ei[t].push(e)))}return Cg(i.map((e=>Sl(e,0))))}))}predict(e,t={}){const n=Zv(e);rx(n,this.inputNames,this.feedInputShapes,!1);try{const r=null==t.batchSize?32:t.batchSize;return Gv(r),this.predictLoop(n,r)}finally{Qv(n,e)}}predictOnBatch(e){rx(e,this.inputNames,this.feedInputShapes,!0);const t=(Array.isArray(e)?e[0]:e).shape[0];return this.predictLoop(e,t)}standardizeUserDataXY(e,t,n=!0,r){if(null==this.optimizer_)throw new _g("You must compile a model before training/testing. Use LayersModel.compile(modelCompileArgs).");const a=[];for(let e=0;ee.shape[0])));r.sort();const a=Yg(t.map((e=>e.shape[0])));if(a.sort(),r.length>1)throw new wg(`All input Tensors (x) should have the same number of samples. Got array shapes: ${JSON.stringify(e.map((e=>e.shape)))}`);if(a.length>1)throw new wg(`All target Tensors (y) should have the same number of samples. Got array shapes: ${JSON.stringify(t.map((e=>e.shape)))}`);if(r.length>0&&a.length>0&&!de(r,a))throw new wg(`Input Tensors should have the same number of samples as target Tensors. Found ${r[0]} input sample(s) and ${a[0]} target sample(s).`)}(e=nx(e,this.feedInputNames,this.feedInputShapes,!1,"input"),t=nx(t,this.feedOutputNames,a,!1,"target")),function(e,t,n){const r=[dv,yv,mv];for(let a=0;a0&&e[0].shape[0]%r!=0)throw new wg(`In a stateful network, you should only pass inputs with a number of samples that is divisible by the batch size ${r}. Found: ${e[0].shape[0]} sample(s).`);return[e,t]}async standardizeUserData(e,t,n,r,a=!0,i){const[s,o]=this.standardizeUserDataXY(e,t,a,i);if(null!=n)throw new Error("sample weight is not supported yet.");let u=null;if(null!=r){const e=Hv(r,this.outputNames);u=[];for(let t=0;t{const i=this.checkNumSamples(t,n,a,"steps"),s=[];if(r>0)throw new Dg("Verbose mode is not implemented yet.");if(null!=a)throw new Dg("steps mode in testLoop() is not implemented yet");{const r=Xv(i,n),a=yd(hy(0,i));for(let n=0;n1&&(a+=`_${Tg(e.slice(0,n),r)}`),t.push(a)}return t}makeTrainFunction(){return e=>{const t=[],n=e.slice(0,this.inputs.length),r=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),a=e.slice(this.inputs.length+this.outputs.length,this.inputs.length+2*this.outputs.length),i=[],s=this.collectedTrainableWeights.map((e=>e.read())),o=this.optimizer_.minimize((()=>{const e=[];for(let t=0;t1&&e{u=wu(u,e)})),u}),!0,s);return[o].concat(i)}}makeTestFunction(){this.testFunction=e=>ho((()=>{const t=[];let n;const r=e.slice(0,this.inputs.length),a=e.slice(this.inputs.length,this.inputs.length+this.outputs.length),i=[];for(let e=0;e0){if(y=!0,2!==r.validationData.length)throw 3===r.validationData.length?new Dg("validationData including sample weights is not supported yet."):new wg(`When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; ${r.validationData} is invalid.`);u=r.validationData[0],l=r.validationData[1];const t=!0,n=await e.standardizeUserData(u,l,null,null,t,h);c=n[0],p=n[1],g=c.concat(p)}else if(null!=r.validationSplit&&r.validationSplit>0&&r.validationSplit<1){y=!0;const e=Math.floor(a[0].shape[0]*(1-r.validationSplit)),t=a[0].shape[0];c=Kv(a,e,t),s=a,a=Kv(a,0,e),p=Kv(i,e,t),o=i,i=Kv(i,0,e),g=c.concat(p)}else null!=r.validationSteps&&(y=!0);const b=a.concat(i).concat(d);e.checkTrainableWeightsConsistency();const v=e.makeTrainFunction(),x=e.getDedupedMetricsNames();let _,w;y?(e.makeTestFunction(),_=e.testFunction,w=x.slice().concat(x.map((e=>"val_"+e)))):(_=null,g=[],w=x.slice());const D=ov(r.callbacks,r.yieldEvery),N=await async function(e,t,n,r,a,i,s,o,u,l,c,p,d,h,f){null==a&&(a=32),null==i&&(i=1),null==c&&(c=!0),null==d&&(d=0);let m=!1;null!=u&&null!=l&&(m=!0);const g=e.checkNumSamples(n,a,h,"steps_per_epoch");let y;null!=g&&(y=hy(0,g)),null==s&&(s=1);const{callbackList:b,history:v}=lv(o,s,i,d,g,h,a,m,p);b.setModel(e),e.history=v,await b.onTrainBegin(),e.stopTraining_=!1;for(let s=d;s{const d=o[c][0],h=o[c][1],f=by(s,d,h-d);p.batch=c,p.size=h-d;const g=Jv(n,f),y=t(g);for(let e=0;e"You must compile a model before training/testing. Use LayersModel.compile(modelCompileConfig).")),se(null!=n,(()=>"For fitDataset(), the 2nd argument (config) is required, but it is not provided in this call.")),se(null!=n.epochs&&n.epochs>0&&Number.isInteger(n.epochs),(()=>`For fitDataset(), config.epochs is expected to be a positive integer, but got ${n.epochs}`)),se(!r||n.batchesPerEpoch>0&&Number.isInteger(n.batchesPerEpoch),(()=>`For fitDataset(), config.batchesPerEpoch is expected to be a positive integer if specified, but got ${n.batchesPerEpoch}`)),se(null==n.validationSplit,(()=>"`validationSplit` is not supported by `fitDataset()`. Use validationData instead.")),e.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");e.isTraining=!0;try{const a=null!=n.validationData;let i,s;if(a)if(Vv(n.validationData))se(null==n.validationBatches||n.validationBatches>0&&Number.isInteger(n.validationBatches),(()=>`For fitDataset() with dataset-based validation, config.validationBatches is expected not to be provided, or to be a positive integer, but got ${n.validationBatches}`));else{const e=function(e){if(3===e.length)throw new Dg("Validation with sample weights is not implemented yet.");return{xs:e[0],ys:e[1]}}(n.validationData);i=e.xs,s=e.ys}const o=e.makeTrainFunction(),u=e.getDedupedMetricsNames();let l;l=a?u.slice().concat(u.map((e=>"val_"+e))):u.slice();const c=ov(n.callbacks,n.yieldEvery),p=null==n.verbose?1:n.verbose,{callbackList:d,history:h}=lv(c,p,n.epochs,null,null,function(e,t){let n=null;return null!=t.batchesPerEpoch?n=t.batchesPerEpoch:Number.isFinite(e.size)&&(n=e.size),n}(t,n),null,a,l);d.setModel(e),e.history=h,await d.onTrainBegin(),e.stopTraining_=!1;let f=null==n.initialEpoch?0:n.initialEpoch,m=await t.iterator();for(;f=n.batchesPerEpoch:t.done){if(a){let t;t=Vv(n.validationData)?Eg(await e.evaluateDataset(n.validationData,{batches:n.validationBatches})):Eg(e.evaluate(i,s,{batchSize:null==n.validationBatchSize?32:n.validationBatchSize,verbose:0}));for(let n=0;nAg(e)))}else{const t=Object.keys(this.loss);e={};const n=this.loss;for(const r of t){if("string"!=typeof n[r])throw new Error("Serialization of non-string loss is not supported.");e[r]=Ag(n[r])}}return e}getMetricIdentifiers(){if("string"==typeof this.metrics||"function"==typeof this.metrics)return[Ag(Av(this.metrics))];if(Array.isArray(this.metrics))return this.metrics.map((e=>Ag(Av(e))));{const e={};for(const t in this.metrics)e[t]=Ag(Av(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(null!=e.weighted_metrics)throw new Error("Loading weight_metrics is not supported yet.");if(null!=e.loss_weights)throw new Error("Loading loss_weights is not supported yet.");if(null!=e.sample_weight_mode)throw new Error("Loading sample_weight_mode is not supported yet.");const t=cv(Yv(e.optimizer_config));let n,r;if("string"==typeof e.loss)n=Ig(e.loss);else if(Array.isArray(e.loss))n=e.loss.map((e=>Ig(e)));else if(null!=e.loss){n={};for(const t in e.loss)n[t]=Ig(e.loss[t])}if(Array.isArray(e.metrics))r=e.metrics.map((e=>Ig(e)));else if(null!=e.metrics){r={};for(const t in e.metrics)r[t]=Ig(e.metrics[t])}this.compile({loss:n,metrics:r,optimizer:t})}async save(e,t){if("string"==typeof e){const t=Qi(e);if(0===t.length)throw new wg(`Cannot find any save handlers for URL '${e}'`);if(t.length>1)throw new wg(`Found more than one (${t.length}) save handlers for URL '${e}'`);e=t[0]}if(null==e.save)throw new wg("LayersModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");const n=await Bi(this.getNamedWeights(t)),r={modelTopology:this.toJSON(null,!1),format:"layers-model",generatedBy:`TensorFlow.js tfjs-layers v${zv}`,convertedBy:null};if(null!=t&&t.includeOptimizer&&null!=this.optimizer){r.trainingConfig=this.getTrainingConfig();const e="optimizer",{data:t,specs:a}=await Bi(await this.optimizer.getWeights(),e);n.specs.push(...a),n.data=Ui([n.data,t])}if(null!=this.userDefinedMetadata){const e=!0;Iv(this.userDefinedMetadata,this.name,e),r.userDefinedMetadata=this.userDefinedMetadata}return r.weightData=n.data,r.weightSpecs=n.specs,e.save(r)}setUserDefinedMetadata(e){Iv(e,this.name),this.userDefinedMetadata=e}getUserDefinedMetadata(){return this.userDefinedMetadata}}ax.className="Model",lu(ax);class ix extends ax{}async function sx(e,t){"modelTopology"in e||(e={modelTopology:e});let n=e.modelTopology;null!=n.model_config&&(n=n.model_config);const r=cv(Yv(n),t);if(null!=e.weightsManifest){const t=await Hs(e.weightsManifest,e.pathPrefix,r.weights.map((e=>e.originalName))),n={};for(const e of r.weights)n[e.originalName]=t[e.originalName];r.loadWeights(n),fo(t)}return r}ix.className="Functional",lu(ix);class ox extends ax{constructor(e){if(super({inputs:[],outputs:[]}),e=e||{},this.trainable=!0,this.built=!1,this.name=null!=e.name?e.name:Gg("sequential_"),null!=e.layers)for(const t of e.layers)this.add(t)}checkShape(e){if(e.inboundNodes[0].outputTensors[0].shape.some((e=>e<0)))throw new wg(`Negative dimension size caused by adding layer ${e.name} with input shape [${e.inboundNodes[0].inputTensors[0].shape}]`)}add(e){const t=e instanceof ox||e instanceof ax;let n;if(t){if(n=e,1!==n.outputs.length)throw new wg("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");if(1!==n.inputs.length)throw new wg("All layers in a Sequential model should have a single input tensor. For multi-input layers, use the functional API.")}if(0===this.outputs.length){if(0===e.inboundNodes.length){if(null==e.batchInputShape)throw new wg("The first layer in a Sequential model must get an `inputShape` or `batchInputShape` argument.");const t=gb({batchShape:e.batchInputShape,dtype:e.dtype,name:e.name+"_input"});e.apply(t)}if(t)this.outputs=n.outputs,this.inputs=n.inputs;else{if(1!==e.inboundNodes.length)throw new wg(`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(1!==e.inboundNodes[0].outputTensors.length)throw new wg("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=fb(this.outputs[0])}this.inboundNodes=[],new pb({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:Sg(null,this.inputs.length),outputMasks:[null],inputShapes:this.inputs.map((e=>e.shape)),outputShapes:this.outputs[0].shape})}else{const t=e.apply(this.outputs[0]);if(Array.isArray(t))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=[t],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}this.layers.push(e),this.built=!1}pop(){if(0===this.layers.length)throw new TypeError("There are no layers in the model.");if(this.layers.pop(),0===this.layers.length)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 null==this.model&&this.build(),this.model.call(e,t)}build(e){if(rb(e),0===this.inputs.length||0===this.outputs.length)throw new TypeError("Sequential model cannot be built: model is empty. Add some layers first.");this.model=new ax({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,n=console.log){this.built||this.build(),super.summary(e,t,n)}setWeights(e){null==this.model&&this.build(),this.model.setWeights(e)}evaluate(e,t,n={}){if(!this.built)throw new _g("The model needs to be compiled before being used.");return this.model.evaluate(e,t,n)}async evaluateDataset(e,t){if(!this.built)throw new _g("The model needs to be compiled before being used.");return this.model.evaluateDataset(e,t)}predict(e,t={}){return null==this.model&&this.build(),this.model.predict(e,t)}predictOnBatch(e){return null==this.model&&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 null==this.model?void 0:this.model.optimizer}set optimizer(e){this.model.optimizer=e}async fit(e,t,n={}){if(!this.built)throw new _g("The model needs to be compiled before being used.");return this.model.fit(e,t,n)}async fitDataset(e,t){if(!this.built)throw new _g("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,n={},r=!1){let a,i={};if(t instanceof Array){if(null==t[0].className||"Merge"===t[0].className)throw new wg("Legacy serialization format not supported yet.");a=t}else se(null!=t.layers,(()=>"When the config data for a Sequential model is not an Array, it must be an Object that contains the 'layers' field.")),a=t.layers,delete t.layers,i=t;const s=new e(i);if(!(s instanceof ox))throw new Dg(`Sequential.fromConfig called on non-Sequential input: ${s}`);for(const e of a){const t=cv(e,void 0,r);r&&t.setFastWeightInitDuringBuild(!0),s.add(t)}return s}set stopTraining(e){if(null==this.model)throw new wg("Cannot set the stopTraining property of a sequential model before it is compiled.");this.model.stopTraining=e}get stopTraining(){if(null==this.model)throw new wg("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 n={};n.className=t.getClassName(),n.config=t.getConfig(),e.push(n)}return{name:this.name,layers:e}}}function ux(e){return new ax(e)}function lx(e){return new ox(e)}function cx(e,t){return null==t&&(t={}),async function(e,t){if(null==t&&(t={}),"string"==typeof e){const n=es(e,t);if(0===n.length)n.push(Gs(e,t));else if(n.length>1)throw new wg(`Found more than one (${n.length}) load handlers for URL '${e}'`);e=n[0]}return async function(e,t,n){if(null==n&&(n={}),null==e.load)throw new wg("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");const r=await e.load();let a=r.modelTopology;null!=a.model_config&&(a=a.model_config);const i=null==n.strict||n.strict,s=null!=r.weightData&&null!=r.weightSpecs&&i,o=cv(Yv(a),void 0,s),u=r.trainingConfig;if(null!=u&&o.loadTrainingConfig(u),null!=r.userDefinedMetadata&&o.setUserDefinedMetadata(r.userDefinedMetadata),null!=r.weightData){if(null==r.weightSpecs)throw new wg("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed.");const{modelWeights:e,optimizerWeights:t}=function(e,t){const n=zi(e,t),r={},a=[];return t.forEach((e=>{"optimizer"===e.group?a.push({name:e.name,tensor:n[e.name]}):r[e.name]=n[e.name]})),{modelWeights:r,optimizerWeights:a}}(r.weightData,r.weightSpecs);o.loadWeights(e,i),null!=o.optimizer&&t.length>0&&await o.optimizer.setWeights(t),fo(e),fo(t.map((e=>e.tensor)))}return o}(e,0,t)}(e,t)}function px(e){return gb(e)}function dx(e,t){uv.registerCallbackConstructor(e,t)}ox.className="Sequential",lu(ox);class hx extends ou{getConfig(){return{}}}class fx extends hx{apply(e,t=1){return function(e,t=1){if(1!==t)throw new Dg(`Support for alpha values other than 1 (${t}) is not implemented yet.`);return dc(e)}(e,t)}}fx.className="elu",lu(fx);class mx extends hx{apply(e){return Kp(e)}}mx.className="selu",lu(mx);class gx extends hx{apply(e){return zp(e)}}gx.className="relu",lu(gx);class yx extends hx{apply(e){return ho((()=>pp(6,zp(e))))}}yx.className="relu6",lu(yx);class bx extends hx{apply(e){return e}}bx.className="linear",lu(bx);class vx extends hx{apply(e){return kl(e)}}vx.className="sigmoid",lu(vx);class xx extends hx{apply(e){return function(e){return ho((()=>{const t=wu(.5,Mu(.2,e));return zl(t,0,1)}))}(e)}}xx.className="hardSigmoid",lu(xx);class _x extends hx{apply(e){return Vc(e)}}_x.className="softplus",lu(_x);class wx extends hx{apply(e){return function(e){return ho((()=>Nu(e,wu(Uu(e),1))))}(e)}}wx.className="softsign",lu(wx);class Dx extends hx{apply(e){return Cl(e)}}Dx.className="tanh",lu(Dx);class Nx extends hx{apply(e,t=-1){return id(e,t)}}Nx.className="softmax",lu(Nx);class Mx extends hx{apply(e,t=-1){return Kc(e,t)}}Mx.className="logSoftmax",lu(Mx);class Sx extends hx{apply(e,t=1){return ho((()=>Mu(kl(Mu(e,t)),e)))}}Sx.className="swish",lu(Sx);class kx extends hx{apply(e){return ho((()=>Mu(e,Cl(Vc(e)))))}}function Tx(e){return e.getClassName()}function Cx(e,t={}){return Og(e,uu.getMap().classNameMap,t,"activation")}function Ex(e){if(null==e){return Cx({className:"linear",config:{}})}if("string"==typeof e){const t={};return t.className=e,t.config={},Cx(t)}return e instanceof hx?e:Cx(e)}function Ax(e){if(null!=e&&"object"!=typeof e)throw new Error(`Argument to L1L2 regularizer's constructor is expected to be an object, but received: ${e}`)}kx.className="mish",lu(kx);class Ix extends ou{}class Lx extends Ix{constructor(e){super(),Ax(e),this.l1=null==e||null==e.l1?.01:e.l1,this.l2=null==e||null==e.l2?.01:e.l2,this.hasL1=0!==this.l1,this.hasL2=0!==this.l2}apply(e){return ho((()=>{let t=up([1]);return this.hasL1&&(t=wu(t,Nc(Mu(this.l1,Uu(e))))),this.hasL2&&(t=wu(t,Nc(Mu(this.l2,ky(e))))),Dl(t,[])}))}getConfig(){return{l1:this.l1,l2:this.l2}}static fromConfig(e,t){return new e({l1:t.l1,l2:t.l2})}}Lx.className="L1L2",lu(Lx);const Fx={l1l2:"L1L2"};function $x(e){return Fg(e)}function Ox(e,t={}){return Og(e,uu.getMap().classNameMap,t,"regularizer")}function Rx(e){return null==e?null:"string"==typeof e?Ox({className:e in Fx?Fx[e]:e,config:{}}):e instanceof Ix?e:Ox(e)}class Yx extends hb{constructor(e){super(null==e?{}:e),this.supportsMasking=!0,null!=e&&(this.maxValue=e.maxValue)}call(e,t){e=nb(e);let n=zp(e);return null!=this.maxValue&&(n=zl(n,0,this.maxValue)),n}computeOutputShape(e){return e}getConfig(){const e={maxValue:this.maxValue},t=super.getConfig();return Object.assign(e,t),e}}Yx.className="ReLU",lu(Yx);class Bx extends hb{constructor(e){super(null==e?{}:e),this.DEFAULT_ALPHA=.3,null==e&&(e={}),this.alpha=null==e.alpha?this.DEFAULT_ALPHA:e.alpha}call(e,t){const n=nb(e);return zc(n,this.alpha)}computeOutputShape(e){return e}getConfig(){const e={alpha:this.alpha},t=super.getConfig();return Object.assign(e,t),e}}Bx.className="LeakyReLU",lu(Bx);class zx extends hb{constructor(e){if(super(null==e?{}:e),this.DEFAULT_ALPHA_INITIALIZER="zeros",null==e&&(e={}),this.supportsMasking=!0,this.alphaInitializer=Qy(e.alphaInitializer||this.DEFAULT_ALPHA_INITIALIZER),this.alphaRegularizer=Rx(e.alphaRegularizer),this.alphaConstraint=Lb(e.alphaConstraint),null==e.sharedAxes)this.sharedAxes=null;else if(Array.isArray(e.sharedAxes))this.sharedAxes=e.sharedAxes;else{if("number"!=typeof e.sharedAxes)throw new wg(`Expected sharedAxes to be a number or an array of numbers, but got ${e.sharedAxes}`);this.sharedAxes=[e.sharedAxes]}}build(e){const t=(e=rb(e)).slice(1);if(null!=this.sharedAxes)for(const e of this.sharedAxes)t[e-1]=1;this.alpha=this.addWeight("alpha",t,"float32",this.alphaInitializer,this.alphaRegularizer,!0,this.alphaConstraint);const n={};if(null!=this.sharedAxes)for(let t=1;t(ty(t),"channelsFirst"===t?Co(e,[0,2,3,1]):e)))}function Gx(e,t){return ho((()=>(ty(t),"channelsFirst"===t?Co(e,[0,2,3,4,1]):e)))}function Kx(e,t,n,r=[1,1],a="valid",i,s,o=null){return ho((()=>{if(null==i&&(i="channelsLast"),ty(i),3!==e.rank&&4!==e.rank)throw new wg(`conv2dWithBiasActivation expects input to be of rank 3 or 4, but received ${e.rank}.`);if(3!==t.rank&&4!==t.rank)throw new wg(`conv2dWithBiasActivation expects kernel to be of rank 3 or 4, but received ${e.rank}.`);let u=Vx(e,i);if("causal"===a)throw new Dg("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");return u=qd({x:u,filter:t,strides:r,pad:"same"===a?"same":"valid",dilations:s,dataFormat:"NHWC",bias:n,activation:o}),"channelsFirst"===i&&(u=Co(u,[0,3,1,2])),u}))}jx.className="Softmax",lu(jx);class Jx extends hb{constructor(e,t){if(super(t),this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",Jx.verifyArgs(t),this.rank=e,Hg(this.rank,"rank"),1!==this.rank&&2!==this.rank&&3!==this.rank)throw new Dg(`Convolution layer for rank other than 1, 2, or 3 (${this.rank}) is not implemented yet.`);if(this.kernelSize=Ux(t.kernelSize,e,"kernelSize"),this.strides=Ux(null==t.strides?1:t.strides,e,"strides"),this.padding=null==t.padding?"valid":t.padding,ny(this.padding),this.dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,ty(this.dataFormat),this.activation=Ex(t.activation),this.useBias=null==t.useBias||t.useBias,this.biasInitializer=Qy(t.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.biasConstraint=Lb(t.biasConstraint),this.biasRegularizer=Rx(t.biasRegularizer),this.activityRegularizer=Rx(t.activityRegularizer),this.dilationRate=Ux(null==t.dilationRate?1:t.dilationRate,e,"dilationRate"),1===this.rank&&Array.isArray(this.dilationRate)&&1!==this.dilationRate.length)throw new wg(`dilationRate must be a number or an array of a single number for 1D convolution, but received ${JSON.stringify(this.dilationRate)}`);if(2===this.rank){if("number"==typeof this.dilationRate)this.dilationRate=[this.dilationRate,this.dilationRate];else if(2!==this.dilationRate.length)throw new wg(`dilationRate must be a number or array of two numbers for 2D convolution, but received ${JSON.stringify(this.dilationRate)}`)}else if(3===this.rank)if("number"==typeof this.dilationRate)this.dilationRate=[this.dilationRate,this.dilationRate,this.dilationRate];else if(3!==this.dilationRate.length)throw new wg(`dilationRate must be a number or array of three numbers for 3D convolution, but received ${JSON.stringify(this.dilationRate)}`)}static verifyArgs(e){if(kg("kernelSize"in e,"required key 'kernelSize' not in config"),"number"!=typeof e.kernelSize&&!Pg(e.kernelSize,"number",1,3))throw new wg(`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:Tx(this.activation),useBias:this.useBias,biasInitializer:Zy(this.biasInitializer),biasRegularizer:$x(this.biasRegularizer),activityRegularizer:$x(this.activityRegularizer),biasConstraint:Ab(this.biasConstraint)},t=super.getConfig();return Object.assign(e,t),e}}class Xx extends Jx{constructor(e,t){super(e,t),this.kernel=null,Xx.verifyArgs(t),this.filters=t.filters,Hg(this.filters,"filters"),this.kernelInitializer=Qy(t.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.kernelConstraint=Lb(t.kernelConstraint),this.kernelRegularizer=Rx(t.kernelRegularizer)}build(e){e=rb(e);const t="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[t])throw new wg(`The channel dimension of the input should be defined. Found ${e[t]}`);const n=e[t],r=this.kernelSize.concat([n,this.filters]);this.kernel=this.addWeight("kernel",r,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]:n}}],this.built=!0}call(e,t){return ho((()=>{let t;e=nb(e);const n=null==this.bias?null:this.bias.read(),r=Ug(this.activation.getClassName());if(null!=r&&2===this.rank)t=Kx(e,this.kernel.read(),n,this.strides,this.padding,this.dataFormat,this.dilationRate,r);else{if(1===this.rank)t=function(e,t,n,r=1,a="valid",i,s=1){return ho((()=>{if(null==i&&(i="channelsLast"),ty(i),3!==e.shape.length)throw new wg(`The input of a conv1dWithBias operation should be 3, but is ${e.shape.length} instead.`);if(3!==t.shape.length)throw new wg(`The kernel for a conv1dWithBias operation should be 3, but is ${t.shape.length} instead`);if(null!=n&&1!==n.shape.length)throw new wg(`The bias for a conv1dWithBias operation should be 1, but is ${t.shape.length} instead`);if("channelsFirst"===i&&(e=Co(e,[0,2,1])),"causal"===a)throw new Dg("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");let o=Wl(e,t,r,"same"===a?"same":"valid","NWC",s);return null!=n&&(o=Cy(o,n)),o}))}(e,this.kernel.read(),n,this.strides[0],this.padding,this.dataFormat,this.dilationRate[0]);else if(2===this.rank)t=Kx(e,this.kernel.read(),n,this.strides,this.padding,this.dataFormat,this.dilationRate);else{if(3!==this.rank)throw new Dg("convolutions greater than 3D are not implemented yet.");t=function(e,t,n,r=[1,1,1],a="valid",i,s){return ho((()=>{if(null==i&&(i="channelsLast"),ty(i),4!==e.rank&&5!==e.rank)throw new wg(`conv3dWithBias expects input to be of rank 4 or 5, but received ${e.rank}.`);if(4!==t.rank&&5!==t.rank)throw new wg(`conv3dWithBias expects kernel to be of rank 4 or 5, but received ${e.rank}.`);let o=Gx(e,i);if("causal"===a)throw new Dg("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");return o=Kl(o,t,r,"same"===a?"same":"valid","NDHWC",s),null!=n&&(o=Cy(o,n)),"channelsFirst"===i&&(o=Co(o,[0,4,1,2,3])),o}))}(e,this.kernel.read(),n,this.strides,this.padding,this.dataFormat,this.dilationRate)}null!=this.activation&&(t=this.activation.apply(t))}return t}))}computeOutputShape(e){e=rb(e);const t=[],n="channelsLast"===this.dataFormat?e.slice(1,e.length-1):e.slice(2);for(let e=0;e 0 but got ${JSON.stringify(e.filters)}`)}}class Zx extends Xx{constructor(e){super(2,e),Zx.verifyArgs(e)}getConfig(){const e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if("number"!=typeof e.kernelSize&&!Pg(e.kernelSize,"number",1,2))throw new wg(`Conv2D expects config.kernelSize to be number or number[] with length 1 or 2, but received ${JSON.stringify(e.kernelSize)}.`)}}Zx.className="Conv2D",lu(Zx);class Qx extends Xx{constructor(e){super(3,e),Qx.verifyArgs(e)}getConfig(){const e=super.getConfig();return delete e.rank,e}static verifyArgs(e){if("number"!=typeof e.kernelSize&&(!Array.isArray(e.kernelSize)||1!==e.kernelSize.length&&3!==e.kernelSize.length))throw new wg(`Conv3D expects config.kernelSize to be number or [number, number, number], but received ${JSON.stringify(e.kernelSize)}.`)}}Qx.className="Conv3D",lu(Qx);class e_ extends Zx{constructor(e){if(super(e),this.inputSpec=[new ub({ndim:4})],"same"!==this.padding&&"valid"!==this.padding)throw new wg(`Conv2DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(4!==(e=rb(e)).length)throw new wg("Input should have rank 4; Received input shape: "+JSON.stringify(e));const t="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[t])throw new wg("The channel dimension of the inputs should be defined. Found `None`.");const n=e[t],r=this.kernelSize.concat([this.filters,n]);this.kernel=this.addWeight("kernel",r,"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 ub({ndim:4,axes:{[t]:n}})],this.built=!0}call(e,t){return ho((()=>{let t=nb(e);if(4!==t.shape.length)throw new wg(`Conv2DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${t.shape.length}`);const n=t.shape,r=n[0];let a,i;"channelsFirst"===this.dataFormat?(a=2,i=3):(a=1,i=2);const s=n[a],o=n[i],u=this.kernelSize[0],l=this.kernelSize[1],c=this.strides[0],p=this.strides[1],d=[r,Wx(s,c,u,this.padding),Wx(o,p,l,this.padding),this.filters];"channelsLast"!==this.dataFormat&&(t=Co(t,[0,2,3,1]));let h=Gl(t,this.kernel.read(),d,this.strides,this.padding);return"channelsLast"!==this.dataFormat&&(h=Co(h,[0,3,1,2])),null!=this.bias&&(h=Cy(h,this.bias.read(),this.dataFormat)),null!=this.activation&&(h=this.activation.apply(h)),h}))}computeOutputShape(e){const t=(e=rb(e)).slice();let n,r,a;"channelsFirst"===this.dataFormat?(n=1,r=2,a=3):(n=3,r=1,a=2);const i=this.kernelSize[0],s=this.kernelSize[1],o=this.strides[0],u=this.strides[1];return t[n]=this.filters,t[r]=Wx(t[r],o,i,this.padding),t[a]=Wx(t[a],u,s,this.padding),t}getConfig(){const e=super.getConfig();return delete e.dilationRate,e}}e_.className="Conv2DTranspose",lu(e_);class t_ extends Qx{constructor(e){if(super(e),this.inputSpec=[new ub({ndim:5})],"same"!==this.padding&&"valid"!==this.padding)throw new wg(`Conv3DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(e){if(5!==(e=rb(e)).length)throw new wg("Input should have rank 5; Received input shape: "+JSON.stringify(e));const t="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[t])throw new wg("The channel dimension of the inputs should be defined. Found `None`.");const n=e[t],r=this.kernelSize.concat([this.filters,n]);this.kernel=this.addWeight("kernel",r,"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 ub({ndim:5,axes:{[t]:n}})],this.built=!0}call(e,t){return ho((()=>{let t=nb(e);if(5!==t.shape.length)throw new wg(`Conv3DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${t.shape.length}`);const n=t.shape,r=n[0];let a,i,s;"channelsFirst"===this.dataFormat?(s=2,a=3,i=4):(s=1,a=2,i=3);const o=n[s],u=n[a],l=n[i],c=this.kernelSize[0],p=this.kernelSize[1],d=this.kernelSize[2],h=this.strides[0],f=this.strides[1],m=this.strides[2],g=[r,Wx(o,h,c,this.padding),Wx(u,f,p,this.padding),Wx(l,m,d,this.padding),this.filters];"channelsLast"!==this.dataFormat&&(t=Co(t,[0,2,3,4,1]));let y=Xl(t,this.kernel.read(),g,this.strides,this.padding);return"channelsLast"!==this.dataFormat&&(y=Co(y,[0,4,1,2,3])),null!==this.bias&&(y=Cy(y,this.bias.read(),this.dataFormat)),null!==this.activation&&(y=this.activation.apply(y)),y}))}computeOutputShape(e){const t=(e=rb(e)).slice();let n,r,a,i;"channelsFirst"===this.dataFormat?(n=1,r=2,a=3,i=4):(n=4,r=1,a=2,i=3);const s=this.kernelSize[0],o=this.kernelSize[1],u=this.kernelSize[2],l=this.strides[0],c=this.strides[1],p=this.strides[2];return t[n]=this.filters,t[r]=Wx(t[r],l,s,this.padding),t[a]=Wx(t[a],c,o,this.padding),t[i]=Wx(t[i],p,u,this.padding),t}getConfig(){const e=super.getConfig();return delete e.dilationRate,e}}t_.className="Conv3DTranspose",lu(t_);class n_ extends Xx{constructor(e,t){if(super(e,t),this.DEFAULT_DEPTHWISE_INITIALIZER="glorotUniform",this.DEFAULT_POINTWISE_INITIALIZER="glorotUniform",this.depthwiseKernel=null,this.pointwiseKernel=null,null==t.filters)throw new wg("The `filters` configuration field is required by SeparableConv, but is unspecified.");if(null!=t.kernelInitializer||null!=t.kernelRegularizer||null!=t.kernelConstraint)throw new wg("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead.");if(null!=t.padding&&"same"!==t.padding&&"valid"!==t.padding)throw new wg(`SeparableConv${this.rank}D supports only padding modes: 'same' and 'valid', but received ${JSON.stringify(t.padding)}`);this.depthMultiplier=null==t.depthMultiplier?1:t.depthMultiplier,this.depthwiseInitializer=Qy(t.depthwiseInitializer||this.DEFAULT_DEPTHWISE_INITIALIZER),this.depthwiseRegularizer=Rx(t.depthwiseRegularizer),this.depthwiseConstraint=Lb(t.depthwiseConstraint),this.pointwiseInitializer=Qy(t.depthwiseInitializer||this.DEFAULT_POINTWISE_INITIALIZER),this.pointwiseRegularizer=Rx(t.pointwiseRegularizer),this.pointwiseConstraint=Lb(t.pointwiseConstraint)}build(e){if((e=rb(e)).length{let t;if(e=nb(e),1===this.rank)throw new Dg("1D separable convolution is not implemented yet.");return 2===this.rank&&("channelsFirst"===this.dataFormat&&(e=Co(e,[0,2,3,1])),t=Jp(e,this.depthwiseKernel.read(),this.pointwiseKernel.read(),this.strides,this.padding,this.dilationRate,"NHWC")),this.useBias&&(t=Cy(t,this.bias.read(),this.dataFormat)),null!=this.activation&&(t=this.activation.apply(t)),"channelsFirst"===this.dataFormat&&(t=Co(t,[0,3,1,2])),t}))}getConfig(){const e=super.getConfig();return delete e.rank,delete e.kernelInitializer,delete e.kernelRegularizer,delete e.kernelConstraint,e.depthwiseInitializer=Zy(this.depthwiseInitializer),e.pointwiseInitializer=Zy(this.pointwiseInitializer),e.depthwiseRegularizer=$x(this.depthwiseRegularizer),e.pointwiseRegularizer=$x(this.pointwiseRegularizer),e.depthwiseConstraint=Ab(this.depthwiseConstraint),e.pointwiseConstraint=Ab(this.pointwiseConstraint),e}}n_.className="SeparableConv";class r_ extends n_{constructor(e){super(2,e)}}r_.className="SeparableConv2D",lu(r_);class a_ extends Xx{constructor(e){super(1,e),a_.verifyArgs(e),this.inputSpec=[{ndim:3}]}getConfig(){const e=super.getConfig();return delete e.rank,delete e.dataFormat,e}static verifyArgs(e){if("number"!=typeof e.kernelSize&&!Pg(e.kernelSize,"number",1,1))throw new wg(`Conv1D expects config.kernelSize to be number or number[] with length 1, but received ${JSON.stringify(e.kernelSize)}.`)}}a_.className="Conv1D",lu(a_);class i_ extends hb{constructor(e){super(e),"number"==typeof e.cropping?this.cropping=[[e.cropping,e.cropping],[e.cropping,e.cropping]]:"number"==typeof e.cropping[0]?this.cropping=[[e.cropping[0],e.cropping[0]],[e.cropping[1],e.cropping[1]]]:this.cropping=e.cropping,this.dataFormat=void 0===e.dataFormat?"channelsLast":e.dataFormat,this.inputSpec=[{ndim:4}]}computeOutputShape(e){return"channelsFirst"===this.dataFormat?[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 ho((()=>{if(e=nb(e),"channelsLast"===this.dataFormat){const t=xy(e,this.cropping[0][0],e.shape[1]-this.cropping[0][0]-this.cropping[0][1],2);return xy(t,this.cropping[1][0],e.shape[2]-this.cropping[1][1]-this.cropping[1][0],3)}{const t=xy(e,this.cropping[0][0],e.shape[2]-this.cropping[0][0]-this.cropping[0][1],3);return xy(t,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}}i_.className="Cropping2D",lu(i_);class s_ extends hb{constructor(e){var t;super(e),this.DEFAULT_SIZE=[2,2],this.inputSpec=[{ndim:4}],this.size=null==e.size?this.DEFAULT_SIZE:e.size,this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,ty(this.dataFormat),this.interpolation=null==e.interpolation?"nearest":e.interpolation,t=this.interpolation,zg(Jg,"InterpolationFormat",t)}computeOutputShape(e){if("channelsFirst"===this.dataFormat){const t=null==e[2]?null:this.size[0]*e[2],n=null==e[3]?null:this.size[1]*e[3];return[e[0],e[1],t,n]}{const t=null==e[1]?null:this.size[0]*e[1],n=null==e[2]?null:this.size[1]*e[2];return[e[0],t,n,e[3]]}}call(e,t){return ho((()=>{let t=nb(e);const n=t.shape;if("channelsFirst"===this.dataFormat){t=Co(t,[0,2,3,1]);const e=this.size[0]*n[2],r=this.size[1]*n[3],a="nearest"===this.interpolation?Uh.resizeNearestNeighbor(t,[e,r]):Uh.resizeBilinear(t,[e,r]);return Co(a,[0,3,1,2])}{const e=this.size[0]*n[1],r=this.size[1]*n[2];return"nearest"===this.interpolation?Uh.resizeNearestNeighbor(t,[e,r]):Uh.resizeBilinear(t,[e,r])}}))}getConfig(){const e={size:this.size,dataFormat:this.dataFormat,interpolation:this.interpolation},t=super.getConfig();return Object.assign(e,t),e}}s_.className="UpSampling2D",lu(s_);class o_ extends Jx{constructor(e){super(2,e),this.depthwiseKernel=null,this.depthMultiplier=null==e.depthMultiplier?1:e.depthMultiplier,this.depthwiseInitializer=Qy(e.depthwiseInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.depthwiseConstraint=Lb(e.depthwiseConstraint),this.depthwiseRegularizer=Rx(e.depthwiseRegularizer)}build(e){if((e=rb(e)).length<4)throw new wg(`Inputs to DepthwiseConv2D should have rank 4. Received input shape: ${JSON.stringify(e)}.`);const t="channelsFirst"===this.dataFormat?1:3;if(null==e[t]||e[t]<0)throw new wg(`The channel dimension of the inputs to DepthwiseConv2D should be defined, but is not (${e[t]}).`);const n=e[t],r=[this.kernelSize[0],this.kernelSize[1],n,this.depthMultiplier];this.depthwiseKernel=this.addWeight("depthwise_kernel",r,null,this.depthwiseInitializer,this.depthwiseRegularizer,!0,this.depthwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[n*this.depthMultiplier],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return ho((()=>{let t=function(e,t,n=[1,1],r="valid",a,i){return ho((()=>{null==a&&(a="channelsLast"),ty(a);let s=Vx(e,a);if(4!==e.rank)throw new wg(`Input for depthwiseConv2d is required to be 4-D, but is instead ${e.rank}-D`);if(4!==t.rank)throw new wg(`depthwiseKernel is required to be 4-D, but is instead ${t.rank}-D`);return s=ac(s,t,n,"same"===r?"same":"valid","NHWC",i),"channelsFirst"===a&&(s=Co(s,[0,3,1,2])),s}))}(e=nb(e),this.depthwiseKernel.read(),this.strides,this.padding,this.dataFormat,null);return this.useBias&&(t=Cy(t,this.bias.read(),this.dataFormat)),null!=this.activation&&(t=this.activation.apply(t)),t}))}computeOutputShape(e){e=rb(e);const t="channelsFirst"===this.dataFormat?e[2]:e[1],n="channelsFirst"===this.dataFormat?e[3]:e[2],r="channelsFirst"===this.dataFormat?e[1]*this.depthMultiplier:e[3]*this.depthMultiplier,a=qx(t,this.kernelSize[0],this.padding,this.strides[0]),i=qx(n,this.kernelSize[1],this.padding,this.strides[1]);return"channelsFirst"===this.dataFormat?[e[0],r,a,i]:[e[0],a,i,r]}getConfig(){const e=super.getConfig();return e.depthMultiplier=this.depthMultiplier,e.depthwiseInitializer=Zy(this.depthwiseInitializer),e.depthwiseRegularizer=$x(this.depthwiseRegularizer),e.depthwiseConstraint=Ab(this.depthwiseRegularizer),e}}function u_(e,t,n,r){if(Array.isArray(e)){if(null!=t||null!=n)throw new wg("When inputs is an array, neither initialState or constants should be provided");null!=r&&(n=e.slice(e.length-r,e.length),e=e.slice(0,e.length-r)),e.length>1&&(t=e.slice(1,e.length)),e=e[0]}function a(e){return null==e||Array.isArray(e)?e:[e]}return{inputs:e,initialState:t=a(t),constants:n=a(n)}}function l_(e,t,n,r=!1,a,i,s=!1,o=!1){return ho((()=>{const u=t.shape.length;if(u<3)throw new wg(`Input should be at least 3D, but is ${u}D.`);const l=[1,0].concat(hy(2,u));if(t=Co(t,l),null!=i)throw new Dg("The rnn() functoin of the deeplearn.js backend does not support constants yet.");s&&console.warn("Backend rnn(): the unroll = true option is not applicable to the imperative deeplearn.js backend."),null!=a&&((a=Ls(Ls(a,"bool"),"float32")).rank===u-1&&(a=Cc(a,-1)),a=Co(a,l)),r&&(t=Hp(t,0),null!=a&&(a=Hp(a,0)));const c=[];let p,d=n;const h=t.shape[0],f=Sd(t);let m,g;null!=a&&(m=Sd(a));for(let t=0;te(n,d)));if(null==a)p=r[0],d=r[1];else{const e=ho((()=>{const e=m[t],n=Hu(bp(e),e),a=wu(Mu(r[0],e),Mu(d[0],n)),i=d.map(((t,a)=>wu(Mu(r[1][a],e),Mu(t,n))));return{output:a,newStates:i}}));p=e.output,d=e.newStates}o&&c.push(p)}return o&&(g=hd(c,1)),[p,g,d]}))}o_.className="DepthwiseConv2D",lu(o_);class c_ extends hb{constructor(e){let t;if(super(e),null==e.cell)throw new wg("cell property is missing for the constructor of RNN.");if(t=Array.isArray(e.cell)?new b_({cells:e.cell}):e.cell,null==t.stateSize)throw new wg("The RNN cell should have an attribute `stateSize` (tuple of integers, one integer per RNN state).");this.cell=t,this.returnSequences=null!=e.returnSequences&&e.returnSequences,this.returnState=null!=e.returnState&&e.returnState,this.goBackwards=null!=e.goBackwards&&e.goBackwards,this._stateful=null!=e.stateful&&e.stateful,this.unroll=null!=e.unroll&&e.unroll,this.supportsMasking=!0,this.inputSpec=[new ub({ndim:3})],this.stateSpec=null,this.states_=null,this.numConstants=null,this.keptStates=[]}getStates(){return null==this.states_?hy(0,Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1).map((e=>null)):this.states_}setStates(e){this.states_=e}computeOutputShape(e){eb(e)&&(e=e[0]);let t=this.cell.stateSize;Array.isArray(t)||(t=[t]);const n=t[0];let r;if(r=this.returnSequences?[e[0],e[1],n]:[e[0],n],this.returnState){const n=[];for(const r of t)n.push([e[0],r]);return[r].concat(n)}return r}computeMask(e,t){return ho((()=>{Array.isArray(t)&&(t=t[0]);const e=this.returnSequences?t:null;if(this.returnState){const t=this.states.map((e=>null));return[e].concat(t)}return e}))}get states(){if(null==this.states_){const e=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1,t=[];for(let n=0;ne.shape[e.shape.length-1])),a))throw new wg(`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=a.map((e=>new ub({shape:[null,e]})));this.stateful&&this.resetStates()}resetStates(e,t=!1){ho((()=>{if(!this.stateful)throw new xg("Cannot call resetStates() on an RNN Layer that is not stateful.");const n=this.inputSpec[0].shape[0];if(null==n)throw new wg("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(null==this.states_)Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((e=>up([n,e]))):this.states_=[up([n,this.cell.stateSize])];else if(null==e)fo(this.states_),null!=this.keptStates&&(fo(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((e=>up([n,e]))):this.states_[0]=up([n,this.cell.stateSize]);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new wg(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`);!0===t?this.keptStates.push(this.states_.slice()):fo(this.states_);for(let t=0;tmo(e.clone())))}))}apply(e,t){let n=null==t?null:t.initialState,r=null==t?null:t.constants;null==t&&(t={});const a=u_(e,n,r,this.numConstants);e=a.inputs,n=a.initialState,r=a.constants;let i=[],s=[];if(null!=n){t.initialState=n,i=i.concat(n),this.stateSpec=[];for(const e of n)this.stateSpec.push(new ub({shape:e.shape}));s=s.concat(this.stateSpec)}if(null!=r&&(t.constants=r,i=i.concat(r),this.numConstants=r.length),i[0]instanceof lb){const n=[e].concat(i),r=this.inputSpec.concat(s),a=this.inputSpec;this.inputSpec=r;const o=super.apply(n,t);return this.inputSpec=a,o}return super.apply(e,t)}call(e,t){return ho((()=>{const n=null==t?null:t.mask,r=null==t?null:t.training;let a=null==t?null:t.initialState;e=nb(e),null==a&&(a=this.stateful?this.states_:this.getInitialState(e));const i=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1;if(a.length!==i)throw new wg(`RNN Layer has ${i} state(s) but was passed ${a.length} initial state(s).`);this.unroll&&console.warn("Ignoring unroll = true for RNN layer, due to imperative backend.");const s={training:r},o=l_(((e,t)=>{const n=this.cell.call([e].concat(t),s);return[n[0],n.slice(1)]}),e,a,this.goBackwards,n,null,this.unroll,this.returnSequences),u=o[0],l=o[1],c=o[2];this.stateful&&this.resetStates(c,r);const p=this.returnSequences?l:u;return this.returnState?[p].concat(c):p}))}getInitialState(e){return ho((()=>{let t=up(e.shape);return t=Nc(t,[1,2]),t=yy(t),Array.isArray(this.cell.stateSize)?this.cell.stateSize.map((e=>e>1?Dy(t,[1,e]):t)):this.cell.stateSize>1?[Dy(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),null!=this.cell&&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};null!=this.numConstants&&(t.numConstants=this.numConstants);const n=this.cell.getConfig();return this.getClassName()===c_.className&&(t.cell={className:this.cell.getClassName(),config:n}),Object.assign({},n,e,t)}static fromConfig(e,t,n={}){const r=cv(t.cell,n);return new e(Object.assign(t,{cell:r}))}}c_.className="RNN",lu(c_);class p_ extends hb{}class d_ extends p_{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,Hg(this.units,"units"),this.activation=Ex(null==e.activation?this.DEFAULT_ACTIVATION:e.activation),this.useBias=null==e.useBias||e.useBias,this.kernelInitializer=Qy(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=Qy(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=Qy(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=Rx(e.kernelRegularizer),this.recurrentRegularizer=Rx(e.recurrentRegularizer),this.biasRegularizer=Rx(e.biasRegularizer),this.kernelConstraint=Lb(e.kernelConstraint),this.recurrentConstraint=Lb(e.recurrentConstraint),this.biasConstraint=Lb(e.biasConstraint),this.dropout=py([1,dy([0,null==e.dropout?0:e.dropout])]),this.recurrentDropout=py([1,dy([0,null==e.recurrentDropout?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){e=rb(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 ho((()=>{if(2!==e.length)throw new wg(`SimpleRNNCell expects 2 input Tensors, got ${e.length}.`);let n=e[1];e=e[0];const r=null!=t.training&&t.training;let a;0bp(e),rate:this.dropout,training:r,dropoutFunc:this.dropoutFunc})),0bp(n),rate:this.recurrentDropout,training:r,dropoutFunc:this.dropoutFunc}));const i=this.dropoutMask,s=this.recurrentDropoutMask;a=My(null!=i?Mu(e,i):e,this.kernel.read()),null!=this.bias&&(a=Cy(a,this.bias.read())),null!=s&&(n=Mu(n,s));let o=wu(a,My(n,this.recurrentKernel.read()));return null!=this.activation&&(o=this.activation.apply(o)),[o,o]}))}getConfig(){const e=super.getConfig(),t={units:this.units,activation:Tx(this.activation),useBias:this.useBias,kernelInitializer:Zy(this.kernelInitializer),recurrentInitializer:Zy(this.recurrentInitializer),biasInitializer:Zy(this.biasInitializer),kernelRegularizer:$x(this.kernelRegularizer),recurrentRegularizer:$x(this.recurrentRegularizer),biasRegularizer:$x(this.biasRegularizer),activityRegularizer:$x(this.activityRegularizer),kernelConstraint:Ab(this.kernelConstraint),recurrentConstraint:Ab(this.recurrentConstraint),biasConstraint:Ab(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout};return Object.assign({},e,t)}}d_.className="SimpleRNNCell",lu(d_);class h_ extends c_{constructor(e){e.cell=new d_(e),super(e)}call(e,t){return ho((()=>{null!=this.cell.dropoutMask&&(fo(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(fo(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const n=null==t?null:t.mask,r=null==t?null:t.training,a=null==t?null:t.initialState;return super.call(e,{mask:n,training:r,initialState:a})}))}static fromConfig(e,t){return new e(t)}}h_.className="SimpleRNN",lu(h_);class f_ extends p_{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 wg("GRUCell does not support reset_after parameter set to true.");this.units=e.units,Hg(this.units,"units"),this.activation=Ex(void 0===e.activation?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=Ex(void 0===e.recurrentActivation?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=null==e.useBias||e.useBias,this.kernelInitializer=Qy(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=Qy(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=Qy(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=Rx(e.kernelRegularizer),this.recurrentRegularizer=Rx(e.recurrentRegularizer),this.biasRegularizer=Rx(e.biasRegularizer),this.kernelConstraint=Lb(e.kernelConstraint),this.recurrentConstraint=Lb(e.recurrentConstraint),this.biasConstraint=Lb(e.biasConstraint),this.dropout=py([1,dy([0,null==e.dropout?0:e.dropout])]),this.recurrentDropout=py([1,dy([0,null==e.recurrentDropout?0:e.recurrentDropout])]),this.dropoutFunc=e.dropoutFunc,this.implementation=e.implementation,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(e){const t=(e=rb(e))[e.length-1];this.kernel=this.addWeight("kernel",[t,3*this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,3*this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[3*this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(e,t){return ho((()=>{if(2!==e.length)throw new wg(`GRUCell expects 2 input Tensors (inputs, h, c), got ${e.length}.`);const n=null!=t.training&&t.training;let r=e[1];e=e[0],0bp(e),rate:this.dropout,training:n,count:3,dropoutFunc:this.dropoutFunc})),0bp(r),rate:this.recurrentDropout,training:n,count:3,dropoutFunc:this.dropoutFunc}));const a=this.dropoutMask,i=this.recurrentDropoutMask;let s,o,u;0{null!=this.cell.dropoutMask&&(fo(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(fo(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const n=null==t?null:t.mask,r=null==t?null:t.training,a=null==t?null:t.initialState;return super.call(e,{mask:n,training:r,initialState:a})}))}static fromConfig(e,t){return 0===t.implmentation&&(t.implementation=1),new e(t)}}m_.className="GRU",lu(m_);class g_ extends p_{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,Hg(this.units,"units"),this.activation=Ex(void 0===e.activation?this.DEFAULT_ACTIVATION:e.activation),this.recurrentActivation=Ex(void 0===e.recurrentActivation?this.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),this.useBias=null==e.useBias||e.useBias,this.kernelInitializer=Qy(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=Qy(e.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=Qy(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.unitForgetBias=e.unitForgetBias,this.kernelRegularizer=Rx(e.kernelRegularizer),this.recurrentRegularizer=Rx(e.recurrentRegularizer),this.biasRegularizer=Rx(e.biasRegularizer),this.kernelConstraint=Lb(e.kernelConstraint),this.recurrentConstraint=Lb(e.recurrentConstraint),this.biasConstraint=Lb(e.biasConstraint),this.dropout=py([1,dy([0,null==e.dropout?0:e.dropout])]),this.recurrentDropout=py([1,dy([0,null==e.recurrentDropout?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;const n=(e=rb(e))[e.length-1];let r;if(this.kernel=this.addWeight("kernel",[n,4*this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,4*this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){if(this.unitForgetBias){const e=this.biasInitializer,n=this.units;r=new((t=class extends Fy{apply(t,r){const a=e.apply([n]),i=(new Oy).apply([n]),s=e.apply([2*n]);return wy(wy(a,i),s)}}).className="CustomInit",t)}else r=this.biasInitializer;this.bias=this.addWeight("bias",[4*this.units],null,r,this.biasRegularizer,!0,this.biasConstraint)}else this.bias=null;this.built=!0}call(e,t){return ho((()=>{const n=null!=t.training&&t.training;if(3!==e.length)throw new wg(`LSTMCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);let r=e[1];const a=e[2];e=e[0],0bp(e),rate:this.dropout,training:n,count:4,dropoutFunc:this.dropoutFunc})),0bp(r),rate:this.recurrentDropout,training:n,count:4,dropoutFunc:this.dropoutFunc}));const i=this.dropoutMask,s=this.recurrentDropoutMask;let o,u,l,c;0{null!=this.cell.dropoutMask&&(fo(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(fo(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const n=null==t?null:t.mask,r=null==t?null:t.training,a=null==t?null:t.initialState;return super.call(e,{mask:n,training:r,initialState:a})}))}static fromConfig(e,t){return 0===t.implmentation&&(t.implementation=1),new e(t)}}y_.className="LSTM",lu(y_);class b_ extends p_{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 ho((()=>{let n=e.slice(1);const r=[];for(const e of this.cells.slice().reverse())Array.isArray(e.stateSize)?r.push(n.splice(0,e.stateSize.length)):r.push(n.splice(0,1));r.reverse();const a=[];let i;for(let s=0;s{iy(`RNNCell_${r}`,(()=>{n.build(e),t=Array.isArray(n.stateSize)?n.stateSize[0]:n.stateSize,e=[e[0],t]}))})),this.built=!0}getConfig(){const e=super.getConfig(),t={cells:this.cells.map((e=>({className:e.getClassName(),config:e.getConfig()})))};return Object.assign({},e,t)}static fromConfig(e,t,n={}){const r=[];for(const e of t.cells)r.push(cv(e,n));return new e({cells:r})}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 e of this.cells)t.push(...e.trainableWeights);return t.concat(e)}return e}getWeights(){const e=[];for(const t of this.cells)e.push(...t.weights);return sb(e)}setWeights(e){const t=[];for(const n of this.cells){const r=n.weights.length,a=e.splice(r);for(let e=0;enull!=i?i(t(),n):Ey(t(),n),o=()=>Ay(s,t,r);return!a||a<=1?mo(o().clone()):Array(a).fill(void 0).map(o).map((e=>mo(e.clone())))}b_.className="StackedRNNCells",lu(b_);class x_ extends c_{constructor(e){if(e.unroll)throw new Dg("Unrolling is not possible with convolutional RNNs.");if(Array.isArray(e.cell))throw new Dg("It is not possible at the moment to stack convolutional cells.");super(e),this.inputSpec=[new ub({ndim:5})]}call(e,t){return ho((()=>{if(null!=this.cell.dropoutMask&&(fo(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(fo(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null),t&&t.constants)throw new wg("ConvRNN2D cell does not support constants");const n=null==t?null:t.mask,r=null==t?null:t.training,a=null==t?null:t.initialState;return super.call(e,{mask:n,training:r,initialState:a})}))}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 ho((()=>{const{stateSize:t}=this.cell,n=e.shape,r=this.computeSingleOutputShape(n),a=up([r[0],...r.slice(2)]);return Array.isArray(t)?Array(t.length).fill(a):[a]}))}resetStates(e,t=!1){ho((()=>{if(!this.stateful)throw new xg("Cannot call resetStates() on an RNN Layer that is not stateful.");const n=this.inputSpec[0].shape,r=this.computeSingleOutputShape(n),a=[r[0],...r.slice(2)];if(null==n[0])throw new wg("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(null==this.getStates())Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((()=>up(a))):this.states_=[up(a)];else if(null==e)fo(this.states_),null!=this.keptStates&&(fo(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((()=>up(a))):this.states_[0]=up(a);else{if(Array.isArray(e)||(e=[e]),e.length!==this.states_.length)throw new wg(`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()):fo(this.states_);for(let t=0;tmo(e.clone())))}))}computeSingleOutputShape(e){const{dataFormat:t,filters:n,kernelSize:r,padding:a,strides:i,dilationRate:s}=this.cell,o="channelsFirst"===t,u=e[o?3:2],l=e[o?4:3],c=qx(u,r[0],a,i[0],s[0]),p=qx(l,r[1],a,i[1],s[1]);return[...e.slice(0,2),...o?[n,c,p]:[c,p,n]]}}x_.className="ConvRNN2D";class __ extends g_{constructor(e){const{filters:t,kernelSize:n,strides:r,padding:a,dataFormat:i,dilationRate:s}=e;super(Object.assign({},e,{units:t})),this.filters=t,Hg(this.filters,"filters"),this.kernelSize=Ux(n,2,"kernelSize"),this.kernelSize.forEach((e=>Hg(e,"kernelSize"))),this.strides=Ux(r||1,2,"strides"),this.strides.forEach((e=>Hg(e,"strides"))),this.padding=a||"valid",ny(this.padding),this.dataFormat=i||"channelsLast",ty(this.dataFormat),this.dilationRate=Ux(s||1,2,"dilationRate"),this.dilationRate.forEach((e=>Hg(e,"dilationRate")))}build(e){var t;e=rb(e);const n="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[n])throw new wg(`The channel dimension of the input should be defined. Found ${e[n]}`);const r=e[n],a=this.kernelSize.concat([r,4*this.filters]);this.kernel=this.addWeight("kernel",a,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint);const i=this.kernelSize.concat([this.filters,4*this.filters]);if(this.recurrentKernel=this.addWeight("recurrent_kernel",i,null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){let e;if(this.unitForgetBias){const n=this.biasInitializer,r=this.filters;e=new((t=class extends Fy{apply(e,t){return _y([n.apply([r]),lp([r]),n.apply([2*r])])}}).className="CustomInit",t)}else e=this.biasInitializer;this.bias=this.addWeight("bias",[4*this.filters],null,e,this.biasRegularizer,!0,this.biasConstraint)}this.built=!0}call(e,t){return ho((()=>{if(3!==e.length)throw new wg(`ConvLSTM2DCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`);const n=t.training||!1,r=e[0],a=e[1],i=e[2];0bp(r),rate:this.dropout,training:n,count:4,dropoutFunc:this.dropoutFunc}));const s=this.dropoutMask,o=(e,t,n)=>t&&t[n]?Mu(t[n],e):e;let u=o(r,s,0),l=o(r,s,1),c=o(r,s,2),p=o(r,s,3);0bp(a),rate:this.recurrentDropout,training:n,count:4,dropoutFunc:this.dropoutFunc}));const d=this.recurrentDropoutMask;let h=o(a,d,0),f=o(a,d,1),m=o(a,d,2),g=o(a,d,3);const[y,b,v,x]=ld(this.kernel.read(),4,3),[_,w,D,N]=this.useBias?ld(this.bias.read(),4):[null,null,null,null];u=this.inputConv(u,y,_,this.padding),l=this.inputConv(l,b,w,this.padding),c=this.inputConv(c,v,D,this.padding),p=this.inputConv(p,x,N,this.padding);const[M,S,k,T]=ld(this.recurrentKernel.read(),4,3);h=this.recurrentConv(h,M),f=this.recurrentConv(f,S),m=this.recurrentConv(m,k),g=this.recurrentConv(g,T);const C=this.recurrentActivation.apply(wu(u,h)),E=this.recurrentActivation.apply(wu(l,f)),A=wu(Mu(E,i),Mu(C,this.activation.apply(wu(c,m)))),I=Mu(this.recurrentActivation.apply(wu(p,g)),this.activation.apply(A));return[I,I,A]}))}getConfig(){const e=super.getConfig(),{units:t}=e,n=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a{this.invokeCallHook(e,t);const n=nb(e);if(0Ey(n,this.rate,r,this.seed)),(()=>n),e)}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()}}D_.className="Dropout",lu(D_);class N_ extends D_{constructor(e){super(e),this.inputSpec=[{ndim:3}]}getNoiseShape(e){const t=e.shape;return[t[0],1,t[2]]}}N_.className="SpatialDropout1D",lu(N_);class M_ extends hb{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",null==e.batchInputShape&&null==e.inputShape&&null!=e.inputDim){let t=null;null!=e.batchSize&&(t=e.batchSize),this.batchInputShape=[t,e.inputDim]}this.units=e.units,Hg(this.units,"units"),this.activation=Ex(e.activation),null!=e.useBias&&(this.useBias=e.useBias),this.kernelInitializer=Qy(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.biasInitializer=Qy(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelConstraint=Lb(e.kernelConstraint),this.biasConstraint=Lb(e.biasConstraint),this.kernelRegularizer=Rx(e.kernelRegularizer),this.biasRegularizer=Rx(e.biasRegularizer),this.activityRegularizer=Rx(e.activityRegularizer),this.supportsMasking=!0,this.inputSpec=[{minNDim:2}]}build(e){const t=(e=rb(e))[e.length-1];null==this.kernel&&(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){const t=(e=rb(e)).slice();return t[t.length-1]=this.units,t}call(e,t){return ho((()=>{this.invokeCallHook(e,t);const n=nb(e),r=Ug(this.activation.getClassName());let a;return null!=r?a=My(n,this.kernel.read(),r,this.bias?this.bias.read():null):(a=My(n,this.kernel.read()),null!=this.bias&&(a=Cy(a,this.bias.read())),null!=this.activation&&(a=this.activation.apply(a))),a}))}getConfig(){const e={units:this.units,activation:Tx(this.activation),useBias:this.useBias,kernelInitializer:Zy(this.kernelInitializer),biasInitializer:Zy(this.biasInitializer),kernelRegularizer:$x(this.kernelRegularizer),biasRegularizer:$x(this.biasRegularizer),activityRegularizer:$x(this.activityRegularizer),kernelConstraint:Ab(this.kernelConstraint),biasConstraint:Ab(this.biasConstraint)},t=super.getConfig();return Object.assign(e,t),e}}M_.className="Dense",lu(M_);class S_ extends hb{constructor(e){super(e=e||{}),this.inputSpec=[{minNDim:3}],this.dataFormat=e.dataFormat}computeOutputShape(e){e=rb(e);for(const t of e.slice(1))if(null==t)throw new wg(`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],cy(e,1)]}call(e,t){return ho((()=>{this.invokeCallHook(e,t);let n=nb(e);if("channelsFirst"===this.dataFormat&&n.rank>1){const e=[0];for(let t=2;t{this.invokeCallHook(e,t);const n=nb(e);return this.activation.apply(n)}))}getConfig(){const e={activation:Tx(this.activation)},t=super.getConfig();return Object.assign(e,t),e}}k_.className="Activation",lu(k_);class T_ extends hb{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 ho((()=>function(e,t){return ho((()=>{if(2!==e.shape.length)throw new wg(`repeat() expects a rank-2 tensor, but received a rank-${e.shape.length} tensor.`);return Dy(yy(e,1),[1,t,1])}))}(e=nb(e),this.n)))}getConfig(){const e={n:this.n},t=super.getConfig();return Object.assign(e,t),e}}T_.className="RepeatVector",lu(T_);class C_ extends hb{constructor(e){super(e),this.targetShape=e.targetShape;for(let e=0;e{this.invokeCallHook(e,t);const n=nb(e),r=n.shape,a=r.slice(0,1).concat(this.fixUnknownDimension(r.slice(1),this.targetShape));return Dl(n,a)}))}getConfig(){const e={targetShape:this.targetShape},t=super.getConfig();return Object.assign(e,t),e}}C_.className="Reshape",lu(C_);class E_ extends hb{constructor(e){if(super(e),null==e.dims)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=hy(1,e.dims.length+1);if(!de(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 ub({ndim:this.dims.length+1})]}computeOutputShape(e){const t=(e=rb(e)).slice();return this.dims.forEach(((n,r)=>{t[r+1]=e[n]})),t}call(e,t){return Co(nb(e),this.dimsIncludingBatch)}getConfig(){const e={dims:this.dims},t=super.getConfig();return Object.assign(e,t),e}}E_.className="Permute",lu(E_);class A_ extends hb{constructor(e){super(null==e?{}:e),this.supportsMasking=!0,this.maskValue=null!=e?null==e.maskValue?0:e.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 n=nb(e);return tl(yp(n,this.maskValue),-1)}call(e,t){return ho((()=>{this.invokeCallHook(e,t);const n=nb(e),r=tl(yp(n,this.maskValue),-1,!0);return Mu(n,Ls(r,n.dtype))}))}}A_.className="Masking",lu(A_);class I_ extends hb{constructor(e){if(super(e),this.embeddings=null,this.DEFAULT_EMBEDDINGS_INITIALIZER="randomUniform",null==e.batchInputShape&&null==e.inputShape){let t=null;null!=e.batchSize&&(t=e.batchSize),null==e.inputLength?this.batchInputShape=[t,null]:this.batchInputShape=[t].concat(Eg(e.inputLength))}this.inputDim=e.inputDim,Hg(this.inputDim,"inputDim"),this.outputDim=e.outputDim,Hg(this.outputDim,"outputDim"),this.embeddingsInitializer=Qy(e.embeddingsInitializer||this.DEFAULT_EMBEDDINGS_INITIALIZER),this.embeddingsRegularizer=Rx(e.embeddingsRegularizer),this.activityRegularizer=Rx(e.activityRegularizer),this.embeddingsConstraint=Lb(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 ho((()=>this.maskZero?(e=nb(e),yp(e,Tu(e))):null))}computeOutputShape(e){if(e=rb(e),null==this.inputLength)return[...e,this.outputDim];const t=Eg(this.inputLength);if(t.length!==e.length-1)throw new wg(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`);{let n=0;for(let r=0;r{this.invokeCallHook(e,t);let n=nb(e);"int32"!==n.dtype&&(n=gy(n,"int32"));const r=Sy(this.embeddings.read(),Dl(n,[n.size]));return Dl(r,rb(this.computeOutputShape(n.shape)))}))}getConfig(){const e={inputDim:this.inputDim,outputDim:this.outputDim,embeddingsInitializer:Zy(this.embeddingsInitializer),embeddingsRegularizer:$x(this.embeddingsRegularizer),activityRegularizer:$x(this.activityRegularizer),embeddingsConstraint:Ab(this.embeddingsConstraint),maskZero:this.maskZero,inputLength:this.inputLength},t=super.getConfig();return Object.assign(e,t),e}}I_.className="Embedding",lu(I_);class L_ extends hb{constructor(e){super(e||{}),this.supportsMasking=!0}mergeFunction(e){throw new Dg}computeElementwiseOpOutputShape(e,t){if(null==e||null==t)return null;if(e.length1)throw new wg(`Can not merge tensors with different batch sizes. Got tensors with shapes: ${JSON.stringify(e)}.`);let n=null==e[0]?null:e[0].slice(1);for(let t=1;te.length));-1===e.indexOf(null)&&1===Yg(r).length?this.reshapeRequired=!1:this.reshapeRequired=!0}call(e,t){return ho((()=>{if(this.reshapeRequired){const t=[],n=e.map((e=>e.rank));if(-1===n.indexOf(null)){const r=dy(n);for(let n of e){const e=n.rank;for(let t=0;t1){const a=hy(1,e).concat([0]);t.push(Co(r,a)),n=!0}else t.push(r)}let r=this.mergeFunction(t);const a=r.rank;if(n)if(null==a){const e=r.shape,t=e[e.length-1],n=[t].concat(e.slice(0,e.length-1));r=Dl(Co(Dl(r,[-1,t]),[1,0]),n)}else if(a>1){const e=[a-1].concat(hy(0,a-1));r=Co(r,e)}return r}}return this.mergeFunction(e)}))}computeOutputShape(e){let t;t=null==e[0]?null:e[0].slice(1);for(let n=1;n{if(null==t)return null;if(!Array.isArray(t))throw new wg("`mask` should be an Array");if(!Array.isArray(e))throw new wg("`inputs` should be an Array");if(t.length!==e.length)throw new wg(`The Array 'inputs' and 'mask' are expected to have the same length, but have different lengths (${e.length} vs ${t.length})`);if(t.every((e=>null==e)))return null;let n=(t=t.map((e=>null==e?e:Cc(e,0))))[0];for(let e=1;e{let t=e[0].clone();for(let n=1;n{let t=e[0].clone();for(let n=1;n{let t=e[0].clone();for(let n=1;n{let t=e[0];for(let n=1;n{let t=e[0];for(let n=1;n1)throw new wg("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: "+JSON.stringify(e))}mergeFunction(e){return ho((()=>_y(e,this.axis)))}computeOutputShape(e){if(!Array.isArray(e)||!Array.isArray(e[0]))throw new wg("A `Concatenate` layer should be called on a list of inputs.");const t=e,n=t[0].slice(),r=this.axis<0?n.length+this.axis:this.axis;for(const e of t.slice(1)){if(null==n[r]||null==e[r]){n[r]=null;break}n[r]+=e[r]}return n}computeMask(e,t){if(null==t)return null;if(!Array.isArray(t))throw new wg("`mask` should be an array for Concatenate");if(!Array.isArray(e))throw new wg("`inputs` should be an array for Concatenate");if(t.length!==e.length)throw new wg(`Mismatch in the length of mask (${t.length}) and the legnth of inputs (${e.length})`);return ho((()=>{let n=!0;if(t.forEach((e=>{null==e||(n=!1)})),n)return null;const r=[];for(let n=0;n"A `Dot` layer should be called on a list of exactly 2 inputs."));const t=e[0],n=e[1];if(t.length>3||n.length>3)throw new Dg("Dot layer does not support tensors of 4D or higher rank yet.");const r=this.interpretAxes(t,n);if(t[r[0]]!==n[r[1]])throw new wg(`Dimension incompatibility: ${t[r[0]]} !== ${n[r[1]]}`)}mergeFunction(e){if(2!==e.length)throw new wg(`A \`Dot\` layer must be called on exactly 2 inputs, but received ${e.length} input(s).`);let t,n=e[0],r=e[1];return t=Array.isArray(this.axes)?this.axes.map(((t,n)=>z_(t,e[n].shape.length))):[z_(this.axes,n.shape.length),z_(this.axes,r.shape.length)],this.normalize&&(n=pv(n,t[0]),r=pv(r,t[1])),function(e,t,n){if(e.shape.length>3||t.shape.length>3)throw new Dg("batchDot is not implemented for tensors of 4D or higher rank yet");if(se(e.shape.length>=2,(()=>`batchDot requires the rank of x to be >= 2, but got ${e.shape.length}`)),se(e.shape.length>=2,(()=>`batchDot requires the rank of y to be >= 2, but got ${t.shape.length}`)),"number"==typeof n&&(n=[n,n]),"complex64"===e.dtype||"complex64"===t.dtype)throw new Dg("batchDot is not implemented for complex64-type Tensors yet.");const r=e.shape.length,a=t.shape.length;null==n&&(n=[r-1,a-2]);const i=n;return ho((()=>{let n,s;if(r>a){n=r-a;const e=[];for(let t=0;tr){n=a-r;const t=[];for(let e=0;e0){let e;e=r>a?r+a-3:r-1;const t=[];for(let r=e;r"A `Dot` layer should be called on a list of exactly 2 inputs."));const t=e[0].slice(),n=e[1].slice();if(t.length>3||n.length>3)throw new Dg("Dot layer does not support tensors of 4D or higher rank yet.");const r=this.interpretAxes(t,n);t.splice(r[0],1),n.splice(r[1],1),n.splice(0,1);const a=t.concat(n);return 1===a.length&&a.push(1),a}computeMask(e,t){return null}getConfig(){const e={axes:this.axes,normalize:this.normalize},t=super.getConfig();return Object.assign(e,t),e}}P_.className="Dot",lu(P_);class H_ extends hb{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 ho((()=>{this.invokeCallHook(e,t);const n=nb(e);return Ay((()=>wu(Ny(n.shape,0,this.stddev),n)),(()=>n),t.training||!1)}))}}H_.className="GaussianNoise",lu(H_);class j_ extends hb{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 ho((()=>{this.invokeCallHook(e,t);const n=nb(e);return this.rate>0&&this.rate<1?Ay((()=>{const e=Math.sqrt(this.rate/(1-this.rate));return Mu(n,Ny(n.shape,1,e))}),(()=>n),t.training||!1):n}))}}j_.className="GaussianDropout",lu(j_);class U_ extends hb{constructor(e){super(e),this.supportsMasking=!0,this.rate=e.rate,this.noiseShape=e.noiseShape}_getNoiseShape(e){return this.noiseShape||nb(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 ho((()=>{if(this.rate<1&&this.rate>0){const n=this._getNoiseShape(e),r=()=>{const t=nb(e),r=-1.7580993408473766;let a=Oc(Rp(n),this.rate);a=gy(a,"float32");const i=((1-this.rate)*(1+this.rate*r**2))**-.5,s=-i*r*this.rate,o=wu(Mu(t,a),Mu(wu(a,-1),r));return wu(Mu(o,i),s)};return Ay(r,(()=>nb(e)),t.training||!1)}return e}))}}function q_(e,t,n,r,a,i=.001){let s;if(2===e.rank)s=Ll(e,t,n,r,a,i);else if(3===e.rank)s=Fl(e,t,n,r,a,i);else{if(4!==e.rank)throw new Dg(`batchNormalization is not implemented for array of rank ${e.rank} yet`);s=$l(e,t,n,r,a,i)}return s}U_.className="AlphaDropout",lu(U_);class W_ extends hb{constructor(e){null==e&&(e={}),super(e),this.supportsMasking=!0,this.axis=null==e.axis?-1:e.axis,this.momentum=null==e.momentum?.99:e.momentum,this.epsilon=null==e.epsilon?.001:e.epsilon,this.center=null==e.center||e.center,this.scale=null==e.scale||e.scale,this.betaInitializer=Qy(e.betaInitializer||"zeros"),this.gammaInitializer=Qy(e.gammaInitializer||"ones"),this.movingMeanInitializer=Qy(e.movingMeanInitializer||"zeros"),this.movingVarianceInitializer=Qy(e.movingVarianceInitializer||"ones"),this.betaConstraint=Lb(e.betaConstraint),this.gammaConstraint=Lb(e.gammaConstraint),this.betaRegularizer=Rx(e.betaRegularizer),this.gammaRegularizer=Rx(e.gammaRegularizer)}build(e){e=rb(e);const t=this.axis>=0?this.axis:this.axis+e.length,n=e[t];if(null==n)throw new wg(`Axis ${t} of input tensor should have a defined dimension but the layer received an input with shape ${JSON.stringify(e)}.`);this.inputSpec=[new ub({ndim:e.length,axes:{[t]:n}})];const r=[n];this.scale&&(this.gamma=this.addWeight("gamma",r,null,this.gammaInitializer,this.gammaRegularizer,!0,this.gammaConstraint)),this.center&&(this.beta=this.addWeight("beta",r,null,this.betaInitializer,this.betaRegularizer,!0,this.betaConstraint)),this.movingMean=this.addWeight("moving_mean",r,null,this.movingMeanInitializer,null,!1),this.movingVariance=this.addWeight("moving_variance",r,null,this.movingVarianceInitializer,null,!1),this.built=!0}call(e,t){return ho((()=>{const n=null!=t.training&&t.training,r=nb(e),a=r.shape,i=a.length,s=hy(0,i),o=this.axis>=0?this.axis:this.axis+i;s.splice(o,1);const u=Sg(1,i);u[o]=a[o];const l=s.slice();l.sort();const c=!de(l,hy(0,i).slice(0,i-1));if(!n)return(()=>{if(c){const e=Dl(this.movingMean.read(),u),t=Dl(this.movingVariance.read(),u),n=this.center?Dl(this.beta.read(),u):null,a=this.scale?Dl(this.gamma.read(),u):null;return q_(r,e,t,n,a,this.epsilon)}return q_(r,this.movingMean.read(),this.movingVariance.read(),null==this.beta?null:this.beta.read(),null==this.gamma?null:this.gamma.read(),this.epsilon)})();const[p,d,h]=function(e,t,n,r,a=.001){return de(r.slice().sort(),hy(0,e.rank-1))?function(e,t,n,r,a=.001){return ho((()=>{const i=fp(e,r),s=i.mean,o=i.variance;return[q_(e,s,o,n,t,a),s,o]}))}(e,t,n,r,a):function(e,t,n,r,a=.001){return ho((()=>{const i=fp(e,r),s=i.mean,o=i.variance,u=[];for(const t of hy(0,e.rank))-1!==r.indexOf(t)?u.push(1):u.push(e.shape[t]);const l=Dl(s,u),c=Dl(o,u),p=null==t?null:Dl(t,u),d=null==n?null:Dl(n,u);return[q_(e,l,c,d,p,a),s,o]}))}(e,t,n,r,a)}(r,this.gamma.read(),this.beta.read(),s,this.epsilon),f=(e,t,n)=>{ho((()=>{const r=1-n,a=e.read(),i=Mu(Hu(a,t),r);e.write(Hu(a,i))}))};return(()=>{f(this.movingMean,d,this.momentum),f(this.movingVariance,h,this.momentum)})(),p}))}getConfig(){const e={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:Zy(this.betaInitializer),gammaInitializer:Zy(this.gammaInitializer),movingMeanInitializer:Zy(this.movingMeanInitializer),movingVarianceInitializer:Zy(this.movingVarianceInitializer),betaRegularizer:$x(this.betaRegularizer),gammaRegularizer:$x(this.gammaRegularizer),betaConstraint:Ab(this.betaConstraint),gammaConstraint:Ab(this.gammaConstraint)},t=super.getConfig();return Object.assign(e,t),e}}W_.className="BatchNormalization",lu(W_);class V_ extends hb{constructor(e){if(null==e&&(e={}),super(e),this.axis=null==e.axis?-1:e.axis,"number"==typeof this.axis){if(!Number.isInteger(this.axis))throw new Error(`Expected axis to be an integer, but received ${this.axis}`)}else{if(!Array.isArray(this.axis))throw new Error(`Expected axis to be an integer or an array of integers, but received ${JSON.stringify(this.axis)}`);for(const e of this.axis)if(!Number.isInteger(e))throw new Error(`Expected axis to be an array of integers, but received ${JSON.stringify(this.axis)}`)}this.epsilon=null==e.epsilon?.001:e.epsilon,this.center=null==e.center||e.center,this.scale=null==e.scale||e.scale,this.betaInitializer=Qy(e.betaInitializer||"zeros"),this.gammaInitializer=Qy(e.gammaInitializer||"ones"),this.betaRegularizer=Rx(e.betaRegularizer),this.gammaRegularizer=Rx(e.gammaRegularizer),this.supportsMasking=!0}build(e){const t=(e=rb(e)).length;"number"==typeof this.axis&&(this.axis=[this.axis]);for(let e=0;e=t)throw new Error(`Invalid axis: ${e}`);if(this.axis.length!==Yg(this.axis).length)throw new Error(`Found duplicate axes in: ${this.axis}`);const n=this.axis.map((t=>e[t]));this.scale?this.gamma=this.addWeight("gamma",n,"float32",this.gammaInitializer,this.gammaRegularizer,!0):this.gamma=null,this.center?this.beta=this.addWeight("beta",n,"float32",this.betaInitializer,this.betaRegularizer,!0):this.beta=null,this.built=!0}call(e,t){const n=nb(e),r=n.shape,a=r.length;return ho((()=>{let{mean:e,variance:t}=fp(n,this.axis,!0);const i=Sg(1,a);for(const e of this.axis)i[e]=r[e];const s=e=>null!=e&&e.shape.length!==a?Dl(e,i):e;let o=this.scale?s(this.gamma.read()):null,u=this.center?s(this.beta.read()):null;const l=[],c=[];for(let e=0;e=0?e[2]+this.padding[0][0]+this.padding[0][1]:null,n=null!=e[3]&&e[3]>=0?e[3]+this.padding[1][0]+this.padding[1][1]:null,[e[0],e[1],t,n]):(t=null!=e[1]&&e[1]>=0?e[1]+this.padding[0][0]+this.padding[0][1]:null,n=null!=e[2]&&e[2]>=0?e[2]+this.padding[1][0]+this.padding[1][1]:null,[e[0],t,n,e[3]])}call(e,t){return ho((()=>{return t=nb(e),n=this.padding,r=this.dataFormat,ho((()=>{if(4!==t.rank)throw new wg(`temporalPadding expects input tensor to be 4-D, but received a ${t.rank}-D tensor.`);if(null==n&&(n=[[1,1],[1,1]]),2!==n.length||2!==n[0].length||2!==n[1].length)throw new wg("spatial2dPadding expects `padding` to be an Array of two Arrays, each of which is an Array of two integers.");if(null==r&&(r="channelsLast"),"channelsLast"!==r&&"channelsFirst"!==r)throw new wg(`Unknown data format: ${r}. Supported data formats are 'channelsLast' and 'channelsFirst.`);let e;return e="channelsFirst"===r?[[0,0],[0,0],n[0],n[1]]:[[0,0],n[0],n[1],[0,0]],xp(t,e)}));var t,n,r}))}getConfig(){const e={padding:this.padding,dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}function K_(e,t,n,r,a,i){return ho((()=>{let s;ty(a),ry(i),ny(r),null==n&&(n=[1,1]),null==r&&(r="valid"),null==a&&(a="channelsLast"),null==i&&(i="max"),e=Vx(e,a);const o="same"===r?"same":"valid";return s="max"===i?ap(e,t,n,o):Nl(e,t,n,o),"channelsFirst"===a&&(s=Co(s,[0,3,1,2])),s}))}function J_(e,t,n,r,a,i){return ho((()=>{let s;ty(a),ry(i),ny(r),null==n&&(n=[1,1,1]),null==r&&(r="valid"),null==a&&(a="channelsLast"),null==i&&(i="max"),e=Gx(e,a);const o="same"===r?"same":"valid";return s="max"===i?ip(e,t,n,o):Ml(e,t,n,o),"channelsFirst"===a&&(s=Co(s,[0,4,1,2,3])),s}))}G_.className="ZeroPadding2D",lu(G_);class X_ extends hb{constructor(e){if(null==e.poolSize&&(e.poolSize=2),super(e),"number"==typeof e.poolSize)this.poolSize=[e.poolSize];else{if(!Array.isArray(e.poolSize)||1!==e.poolSize.length||"number"!=typeof e.poolSize[0])throw new wg(`poolSize for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.poolSize)}`);this.poolSize=e.poolSize}if(Hg(this.poolSize,"poolSize"),null==e.strides)this.strides=this.poolSize;else if("number"==typeof e.strides)this.strides=[e.strides];else{if(!Array.isArray(e.strides)||1!==e.strides.length||"number"!=typeof e.strides[0])throw new wg(`strides for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.strides)}`);this.strides=e.strides}Hg(this.strides,"strides"),this.padding=null==e.padding?"valid":e.padding,ny(this.padding),this.inputSpec=[new ub({ndim:3})]}computeOutputShape(e){const t=qx((e=rb(e))[1],this.poolSize[0],this.padding,this.strides[0]);return[e[0],t,e[2]]}call(e,t){return ho((()=>{this.invokeCallHook(e,t),e=yy(nb(e),2);const n=this.poolingFunction(nb(e),[this.poolSize[0],1],[this.strides[0],1],this.padding,"channelsLast");return dd(n,[2])}))}getConfig(){const e={poolSize:this.poolSize,padding:this.padding,strides:this.strides},t=super.getConfig();return Object.assign(e,t),e}}class Z_ extends X_{constructor(e){super(e)}poolingFunction(e,t,n,r,a){return ty(a),ny(r),K_(e,t,n,r,a,"max")}}Z_.className="MaxPooling1D",lu(Z_);class Q_ extends X_{constructor(e){super(e)}poolingFunction(e,t,n,r,a){return ty(a),ny(r),K_(e,t,n,r,a,"avg")}}Q_.className="AveragePooling1D",lu(Q_);class ew extends hb{constructor(e){if(null==e.poolSize&&(e.poolSize=[2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize],null==e.strides)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(2!==e.strides.length)throw new wg(`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];Hg(this.poolSize,"poolSize"),Hg(this.strides,"strides"),this.padding=null==e.padding?"valid":e.padding,this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,ty(this.dataFormat),ny(this.padding),this.inputSpec=[new ub({ndim:4})]}computeOutputShape(e){e=rb(e);let t="channelsFirst"===this.dataFormat?e[2]:e[1],n="channelsFirst"===this.dataFormat?e[3]:e[2];return t=qx(t,this.poolSize[0],this.padding,this.strides[0]),n=qx(n,this.poolSize[1],this.padding,this.strides[1]),"channelsFirst"===this.dataFormat?[e[0],e[1],t,n]:[e[0],t,n,e[3]]}call(e,t){return ho((()=>(this.invokeCallHook(e,t),this.poolingFunction(nb(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 tw extends ew{constructor(e){super(e)}poolingFunction(e,t,n,r,a){return ty(a),ny(r),K_(e,t,n,r,a,"max")}}tw.className="MaxPooling2D",lu(tw);class nw extends ew{constructor(e){super(e)}poolingFunction(e,t,n,r,a){return ty(a),ny(r),K_(e,t,n,r,a,"avg")}}nw.className="AveragePooling2D",lu(nw);class rw extends hb{constructor(e){if(null==e.poolSize&&(e.poolSize=[2,2,2]),super(e),this.poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize,e.poolSize],null==e.strides)this.strides=this.poolSize;else if(Array.isArray(e.strides)){if(3!==e.strides.length)throw new wg(`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];Hg(this.poolSize,"poolSize"),Hg(this.strides,"strides"),this.padding=null==e.padding?"valid":e.padding,this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,ty(this.dataFormat),ny(this.padding),this.inputSpec=[new ub({ndim:5})]}computeOutputShape(e){e=rb(e);let t="channelsFirst"===this.dataFormat?e[2]:e[1],n="channelsFirst"===this.dataFormat?e[3]:e[2],r="channelsFirst"===this.dataFormat?e[4]:e[3];return t=qx(t,this.poolSize[0],this.padding,this.strides[0]),n=qx(n,this.poolSize[1],this.padding,this.strides[1]),r=qx(r,this.poolSize[2],this.padding,this.strides[2]),"channelsFirst"===this.dataFormat?[e[0],e[1],t,n,r]:[e[0],t,n,r,e[4]]}call(e,t){return ho((()=>(this.invokeCallHook(e,t),this.poolingFunction(nb(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 aw extends rw{constructor(e){super(e)}poolingFunction(e,t,n,r,a){return ty(a),ny(r),J_(e,t,n,r,a,"max")}}aw.className="MaxPooling3D",lu(aw);class iw extends rw{constructor(e){super(e)}poolingFunction(e,t,n,r,a){return ty(a),ny(r),J_(e,t,n,r,a,"avg")}}iw.className="AveragePooling3D",lu(iw);class sw extends hb{constructor(e){super(e),this.inputSpec=[new ub({ndim:3})]}computeOutputShape(e){return[e[0],e[2]]}call(e,t){throw new Dg}}class ow extends sw{constructor(e){super(e||{})}call(e,t){return ho((()=>{const t=nb(e);return op(t,1)}))}}ow.className="GlobalAveragePooling1D",lu(ow);class uw extends sw{constructor(e){super(e||{})}call(e,t){return ho((()=>{const t=nb(e);return wc(t,1)}))}}uw.className="GlobalMaxPooling1D",lu(uw);class lw extends hb{constructor(e){super(e),this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,ty(this.dataFormat),this.inputSpec=[new ub({ndim:4})]}computeOutputShape(e){return"channelsLast"===this.dataFormat?[e[0],e[3]]:[e[0],e[1]]}call(e,t){throw new Dg}getConfig(){const e={dataFormat:this.dataFormat},t=super.getConfig();return Object.assign(e,t),e}}class cw extends lw{call(e,t){return ho((()=>{const t=nb(e);return"channelsLast"===this.dataFormat?op(t,[1,2]):op(t,[2,3])}))}}cw.className="GlobalAveragePooling2D",lu(cw);class pw extends lw{call(e,t){return ho((()=>{const t=nb(e);return"channelsLast"===this.dataFormat?wc(t,[1,2]):wc(t,[2,3])}))}}pw.className="GlobalMaxPooling2D",lu(pw);class dw extends hb{constructor(e){super(e),this.layer=e.layer}build(e){this.built=!0}get trainable(){return null!=this.layer&&this.layer.trainable}set trainable(e){null!=this.layer&&(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),null!=this.layer&&this.layer.setFastWeightInitDuringBuild(e)}static fromConfig(e,t,n={}){const r=cv(t.layer,n);delete t.layer;const a={layer:r};return Object.assign(a,t),new e(a)}}class hw extends dw{constructor(e){super(e),this.supportsMasking=!0}build(e){if((e=rb(e)).length<3)throw new wg(`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){const t=[(e=rb(e))[0]].concat(e.slice(2)),n=this.layer.computeOutputShape(t),r=e[1];return[n[0],r].concat(n.slice(1))}call(e,t){return ho((()=>l_(((e,n)=>[nb(this.layer.call(e,t)),[]]),e=nb(e),[],!1,null,null,!1,!0)[1]))}}hw.className="TimeDistributed",lu(hw);class fw extends dw{constructor(e){super(e);const t=e.layer.getConfig(),n={};n.className=e.layer.getClassName(),n.config=t,this.forwardLayer=cv(n),t.goBackwards=!0!==t.goBackwards;const r={};var a;if(r.className=e.layer.getClassName(),r.config=t,this.backwardLayer=cv(r),this.forwardLayer.name="forward_"+this.forwardLayer.name,this.backwardLayer.name="backward_"+this.backwardLayer.name,this.mergeMode=void 0===e.mergeMode?"concat":e.mergeMode,a=this.mergeMode,zg(Qg,"BidirectionalMergeMode",a),e.weights)throw new Dg("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,null!=this.forwardLayer&&(this.forwardLayer.trainable=e),null!=this.backwardLayer&&(this.backwardLayer.trainable=e)}getWeights(){return this.forwardLayer.getWeights().concat(this.backwardLayer.getWeights())}setWeights(e){const t=e.length,n=Math.floor(t/2);this.forwardLayer.setWeights(e.slice(0,n)),this.backwardLayer.setWeights(e.slice(n))}computeOutputShape(e){let t,n,r,a=this.forwardLayer.computeOutputShape(e);return Array.isArray(a)&&Array.isArray(a[0])||(a=[a]),this.returnState?(r=a.slice(1),t=a[0]):t=a[0],"concat"===this.mergeMode?(t[t.length-1]*=2,n=[t]):n=null==this.mergeMode?[t,t.slice()]:[t],this.returnState?null==this.mergeMode?n.concat(r).concat(r.slice()):[t].concat(r).concat(r.slice()):Cg(n)}apply(e,t){let n=null==t?null:t.initialState,r=null==t?null:t.constants;null==t&&(t={});const a=u_(e,n,r,this.numConstants);if(e=a.inputs,n=a.initialState,r=a.constants,Array.isArray(e)&&(n=e.slice(1),e=e[0]),(null==n||0===n.length)&&null==r)return super.apply(e,t);const i=[],s=[];if(null!=n){const e=n.length;if(e%2>0)throw new wg("When passing `initialState` to a Bidrectional RNN, the state should be an Array containing the states of the underlying RNNs.");t.initialState=n,i.push(...n);const r=n.map((e=>new ub({shape:e.shape})));this.forwardLayer.stateSpec=r.slice(0,e/2),this.backwardLayer.stateSpec=r.slice(e/2),s.push(...r)}if(null!=r)throw new Dg("Support for constants in Bidirectional layers is not implemented yet.");const o=i[0]instanceof lb;for(const e of i)if(e instanceof lb!==o)throw new wg("The initial state of a Bidirectional layer cannot be specified as a mix of symbolic and non-symbolic tensors");if(o){const n=[e].concat(i),r=this.inputSpec.concat(s),a=this.inputSpec;this.inputSpec=r;const o=super.apply(n,t);return this.inputSpec=a,o}return super.apply(e,t)}call(e,t){return ho((()=>{const n=t.initialState;let r,a,i,s;if(null==n)r=this.forwardLayer.call(e,t),a=this.backwardLayer.call(e,t);else{const i=n.slice(0,n.length/2),s=n.slice(n.length/2);r=this.forwardLayer.call(e,Object.assign(t,{initialState:i})),a=this.backwardLayer.call(e,Object.assign(t,{initialState:s}))}return this.returnState&&(Array.isArray(r)&&(i=r.slice(1).concat(a.slice(1))),r=r[0],a=a[0]),this.returnSequences&&(a=Hp(a,1)),"concat"===this.mergeMode?s=_y([r,a]):"sum"===this.mergeMode?s=wu(r,a):"ave"===this.mergeMode?s=Mu(.5,wu(r,a)):"mul"===this.mergeMode?s=Mu(r,a):null==this.mergeMode&&(s=[r,a]),this.returnState?null==this.mergeMode?s.concat(i):[s].concat(i):s}))}resetStates(e){this.forwardLayer.resetStates(),this.backwardLayer.resetStates()}build(e){iy(this.forwardLayer.name,(()=>{this.forwardLayer.build(e)})),iy(this.backwardLayer.name,(()=>{this.backwardLayer.build(e)})),this.built=!0}computeMask(e,t){let n;if(Array.isArray(t)&&(t=t[0]),n=this.returnSequences?null==this.mergeMode?[t,t]:t:null==this.mergeMode?[null,null]:null,this.returnState){const e=this.forwardLayer.states.map((e=>null));return Array.isArray(n)?n.concat(e).concat(e):[n].concat(e).concat(e)}return n}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),null!=this.forwardLayer&&this.forwardLayer.setFastWeightInitDuringBuild(e),null!=this.backwardLayer&&this.backwardLayer.setFastWeightInitDuringBuild(e)}getConfig(){const e={mergeMode:this.mergeMode},t=super.getConfig();return Object.assign(e,t),e}static fromConfig(e,t){const n=cv(t.layer);if(delete t.layer,null!=t.numConstants)throw new Dg("Deserialization of a Bidirectional layer with numConstants present is not supported yet.");const r=t;return r.layer=n,new e(r)}}function mw(e){return new mb(e)}function gw(e){return new Px(e)}function yw(e){return new Yx(e)}function bw(e){return new Bx(e)}function vw(e){return new zx(e)}function xw(e){return new jx(e)}function _w(e){return new Hx(e)}function ww(e){return new a_(e)}function Dw(e){return new Zx(e)}function Nw(e){return new e_(e)}function Mw(e){return new Qx(e)}function Sw(e){return new t_(e)}function kw(e){return new r_(e)}function Tw(e){return new i_(e)}function Cw(e){return new s_(e)}function Ew(e){return new o_(e)}function Aw(e){return new k_(e)}function Iw(e){return new M_(e)}function Lw(e){return new D_(e)}function Fw(e){return new N_(e)}function $w(e){return new S_(e)}function Ow(e){return new T_(e)}function Rw(e){return new C_(e)}function Yw(e){return new E_(e)}function Bw(e){return new I_(e)}function zw(e){return new F_(e)}function Pw(e){return new O_(e)}function Hw(e){return new B_(e)}function jw(e){return new R_(e)}function Uw(e){return new Y_(e)}function qw(e){return new $_(e)}function Ww(e){return new P_(e)}function Vw(e){return new W_(e)}function Gw(e){return new V_(e)}function Kw(e){return new G_(e)}function Jw(e){return new Q_(e)}function Xw(e){return Jw(e)}function Zw(e){return Jw(e)}function Qw(e){return new nw(e)}function eD(e){return Qw(e)}function tD(e){return Qw(e)}function nD(e){return new iw(e)}function rD(e){return nD(e)}function aD(e){return nD(e)}function iD(e){return new ow(e)}function sD(e){return new cw(e)}function oD(e){return new uw(e)}function uD(e){return new pw(e)}function lD(e){return new Z_(e)}function cD(e){return new tw(e)}function pD(e){return new aw(e)}function dD(e){return new m_(e)}function hD(e){return new f_(e)}function fD(e){return new y_(e)}function mD(e){return new g_(e)}function gD(e){return new h_(e)}function yD(e){return new d_(e)}function bD(e){return new w_(e)}function vD(e){return new __(e)}function xD(e){return new c_(e)}function _D(e){return new b_(e)}function wD(e){return new fw(e)}function DD(e){return new hw(e)}fw.className="Bidirectional",lu(fw);const ND=oD,MD=uD,SD=lD,kD=cD;function TD(e){return new H_(e)}function CD(e){return new j_(e)}function ED(e){return new U_(e)}function AD(e){return new A_(e)}function ID(e,t){return _v(e,t)}function LD(e,t){return Mv(e,t)}function FD(e,t){return Sv(e,t)}function $D(e,t){return wv(e,t)}function OD(e,t){return kv(e,t)}function RD(e,t){return Nv(e,t)}function YD(e,t){return function(e,t){return ho((()=>{const n=Dv(e,t),r=function(e,t){return ho((()=>Ls(Nc(Xc(oc(e,1),oc(t,0))),"float32")))}(e,t),a=wu(n,r);return Ls(uc($c(a,0),Nu(n,a),0),"float32")}))}(e,t)}function BD(e,t){return bv(e,t)}function zD(e,t){return hv(e,t)}function PD(e,t){return fv(e,t)}function HD(e,t){return fv(e,t)}function jD(e,t){return fv(e,t)}function UD(e,t){return dv(e,t)}function qD(e,t){return dv(e,t)}function WD(e,t){return dv(e,t)}function VD(e){return new Lx(e)}function GD(e){return Ax(t=e),new Lx({l1:null!=t?t.l1:null,l2:0});var t}function KD(e){return Ax(t=e),new Lx({l2:null!=t?t.l2:null,l1:0});var t}class JD extends nv{constructor(){super(...arguments),this.model=null}setModel(e){if(!(e instanceof ax))throw new Error("model must be a LayersModel, not some other Container");this.model=e}}function XD(e,t){return et}class QD extends JD{constructor(e){if(super(),null==e&&(e={}),e.restoreBestWeights)throw new Dg("restoreBestWeights = True is not implemented in EarlyStopping yet.");this.monitor=e.monitor||"val_loss",this.minDelta=Math.abs(e.minDelta||0),this.patience=e.patience||0,this.verbose=e.verbose||0,this.mode=e.mode||"auto",this.baseline=e.baseline,-1===["auto","min","max"].indexOf(this.mode)&&(console.warn(`EarlyStopping mode '${this.mode}' is invalid. Falling back to mode 'auto'.`),this.mode="auto"),"min"===this.mode?this.monitorFunc=XD:"max"===this.mode||-1!==this.monitor.indexOf("acc")?this.monitorFunc=ZD:this.monitorFunc=XD,this.monitorFunc===XD&&(this.minDelta*=-1)}async onTrainBegin(e){this.wait=0,this.stoppedEpoch=0,null!=this.baseline?this.best=this.baseline:this.best=this.monitorFunc===XD?1/0:-1/0}async onEpochEnd(e,t){await Qb(t);const n=this.getMonitorValue(t);null!=n&&(this.monitorFunc(n-this.minDelta,this.best)?(this.best=n,this.wait=0):(this.wait++,this.wait>=this.patience&&(this.stoppedEpoch=e,this.model.stopTraining=!0)))}async onTrainEnd(e){this.stoppedEpoch>0&&this.verbose&&console.log(`Epoch ${this.stoppedEpoch}: early stopping.`)}getMonitorValue(e){null==e&&(e={});const t=e[this.monitor];return null==t&&console.warn(`Metric for EarlyStopping ${this.monitor} is not available. Available metrics are: ${Object.keys(e)}`),t}}const eN={earlyStopping:function(e){return new QD(e)}};var tN,nN;Ge().registerFlag("KEEP_INTERMEDIATE_TENSORS",(()=>!1),(e=>{e&&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.")})),function(e){e[e.DT_INVALID=0]="DT_INVALID",e[e.DT_FLOAT=1]="DT_FLOAT",e[e.DT_DOUBLE=2]="DT_DOUBLE",e[e.DT_INT32=3]="DT_INT32",e[e.DT_UINT8=4]="DT_UINT8",e[e.DT_INT16=5]="DT_INT16",e[e.DT_INT8=6]="DT_INT8",e[e.DT_STRING=7]="DT_STRING",e[e.DT_COMPLEX64=8]="DT_COMPLEX64",e[e.DT_INT64=9]="DT_INT64",e[e.DT_BOOL=10]="DT_BOOL",e[e.DT_QINT8=11]="DT_QINT8",e[e.DT_QUINT8=12]="DT_QUINT8",e[e.DT_QINT32=13]="DT_QINT32",e[e.DT_BFLOAT16=14]="DT_BFLOAT16",e[e.DT_QINT16=15]="DT_QINT16",e[e.DT_QUINT16=16]="DT_QUINT16",e[e.DT_UINT16=17]="DT_UINT16",e[e.DT_COMPLEX128=18]="DT_COMPLEX128",e[e.DT_HALF=19]="DT_HALF",e[e.DT_RESOURCE=20]="DT_RESOURCE",e[e.DT_VARIANT=21]="DT_VARIANT",e[e.DT_UINT32=22]="DT_UINT32",e[e.DT_UINT64=23]="DT_UINT64",e[e.DT_FLOAT_REF=101]="DT_FLOAT_REF",e[e.DT_DOUBLE_REF=102]="DT_DOUBLE_REF",e[e.DT_INT32_REF=103]="DT_INT32_REF",e[e.DT_UINT8_REF=104]="DT_UINT8_REF",e[e.DT_INT16_REF=105]="DT_INT16_REF",e[e.DT_INT8_REF=106]="DT_INT8_REF",e[e.DT_STRING_REF=107]="DT_STRING_REF",e[e.DT_COMPLEX64_REF=108]="DT_COMPLEX64_REF",e[e.DT_INT64_REF=109]="DT_INT64_REF",e[e.DT_BOOL_REF=110]="DT_BOOL_REF",e[e.DT_QINT8_REF=111]="DT_QINT8_REF",e[e.DT_QUINT8_REF=112]="DT_QUINT8_REF",e[e.DT_QINT32_REF=113]="DT_QINT32_REF",e[e.DT_BFLOAT16_REF=114]="DT_BFLOAT16_REF",e[e.DT_QINT16_REF=115]="DT_QINT16_REF",e[e.DT_QUINT16_REF=116]="DT_QUINT16_REF",e[e.DT_UINT16_REF=117]="DT_UINT16_REF",e[e.DT_COMPLEX128_REF=118]="DT_COMPLEX128_REF",e[e.DT_HALF_REF=119]="DT_HALF_REF",e[e.DT_RESOURCE_REF=120]="DT_RESOURCE_REF",e[e.DT_VARIANT_REF=121]="DT_VARIANT_REF",e[e.DT_UINT32_REF=122]="DT_UINT32_REF",e[e.DT_UINT64_REF=123]="DT_UINT64_REF"}(tN||(tN={})),function(e){let t;!function(e){e[e.LEGACY=0]="LEGACY",e[e.V1=1]="V1",e[e.V2=2]="V2"}(t=e.CheckpointFormatVersion||(e.CheckpointFormatVersion={}))}(nN||(nN={}));const rN={};function aN(e,t){const n={tfOpName:e,category:"custom",inputs:[],attrs:[],customExecutor:t};rN[e]=n}function iN(e){return rN[e]}function sN(e){delete rN[e]}function oN(e,t,n,r,a){const i=t.inputParams[e];if(i&&void 0!==i.inputIndexStart){const e=i.inputIndexStart,s=0===i.inputIndexEnd?void 0:void 0===i.inputIndexEnd?e+1:i.inputIndexEnd;if("tensor"===i.type)return uN(t.inputNames[i.inputIndexStart],n,r,a);if("tensors"===i.type)return t.inputNames.slice(e,s).map((e=>uN(e,n,r,a)));const o=uN(t.inputNames.slice(e)[0],n,r,a),u=o.dataSync();return"number"===i.type?u[0]:Ye(o.shape,u)}const s=t.attrParams[e];return s&&s.value}function uN(e,t,n,r){const[a,i]=pN(e);if(null!=r){const e=r.getHashTableHandleByName(a);if(null!=e)return e}const s=n.currentContextIds.find((e=>!!t[cN(a,e)]));return void 0!==s?t[cN(a,s)][i]:void 0}function lN(e,t){const[n,r,a]=pN(e);return[cN(n,t&&t.currentContextId),r,a]}function cN(e,t){return t?`${e}-${t}`:e}function pN(e){const t=e.split(":");if(1===t.length)return[e,0,void 0];const n=t[0],r=3===t.length?t[1]:void 0;return[n,Number(t[t.length-1]),r]}function dN(e,t,n){let r=oN("pad",e,t,n);if("explicit"===r){r=oN("explicitPaddings",e,t,n);const a=[[0,0],[0,0],[0,0],[0,0]];for(let e=0;e<4;e++)a[e][0]=r[2*e],a[e][1]=r[2*e+1];return a}return r}function hN(e){return e.kept?e:Fs(e)}const fN=[{tfOpName:"Add",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddV2",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddN",category:"arithmetic",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"BiasAdd",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"Sub",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"RealDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Div",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"DivNoNan",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mul",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Maximum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Minimum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Pow",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SquaredDifference",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorMod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],mN=[{tfOpName:"Abs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan2",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Ceil",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ClipByValue",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"clipValueMin",type:"number"},{start:2,name:"clipValueMax",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Complex",category:"basic_math",inputs:[{start:0,name:"real",type:"tensor"},{start:1,name:"imag",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ComplexAbs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Elu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Exp",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Floor",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Imag",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Neg",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Real",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Prelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"alpha",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu6",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Selu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sigmoid",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Rsqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Square",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sign",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Round",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Expm1",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log1p",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Reciprocal",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Softplus",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Erf",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Prod",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axes",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LeakyRelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"alpha",name:"alpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"IsNan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],gN=[{tfOpName:"EmptyTensorList",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"maxNumElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"LoopCond",category:"control",inputs:[{start:0,name:"pred",type:"tensor"}]},{tfOpName:"Switch",category:"control",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"pred",type:"tensor"}]},{tfOpName:"Merge",category:"control",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"Enter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"frame_name",name:"frameName",type:"string"},{tfName:"is_constant",name:"isConstant",type:"bool"}]},{tfOpName:"Exit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NextIteration",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayV3",category:"control",inputs:[{start:0,name:"size",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"dynamic_size",name:"dynamicSize",type:"bool"},{tfName:"clear_after_read",name:"clearAfterRead",type:"bool"},{tfName:"identical_element_shapes",name:"identicalElementShapes",type:"bool"},{tfName:"tensor_array_name",name:"name",type:"string"}]},{tfOpName:"TensorArrayWriteV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayReadV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayGatherV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"}]},{tfOpName:"TensorArrayScatterV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArrayConcatV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape_except0",name:"elementShapeExcept0",type:"shape",notSupported:!0}]},{tfOpName:"TensorArraySplitV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"tensor",type:"tensor"},{start:2,name:"lengths",type:"number[]"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArraySizeV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}]},{tfOpName:"TensorArrayCloseV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"}]},{tfOpName:"StatelessIf",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"If",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"StatelessWhile",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"While",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"TensorListScatter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListScatterV2",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"},{start:3,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGather",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListSetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListReserve",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListFromTensor",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListStack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"},{tfName:"num_elements",name:"numElements",type:"dtype"}]},{tfOpName:"TensorListSplit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"},{start:2,name:"lengths",type:"number[]"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcat",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcatV2",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPopBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPushBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListLength",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}]},{tfOpName:"TensorListResize",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"size",type:"number"}]}],yN=[{tfOpName:"AvgPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[],notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPoolWithArgmax",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"include_batch_in_index",name:"includeBatchInIndex",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AvgPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Conv1D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"stride",name:"stride",type:"number"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NWC"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"dilation",name:"dilation",type:"number",defaultValue:1}]},{tfOpName:"Conv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"useCudnnOnGpu",name:"useCudnnOnGpu",type:"bool"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"_FusedConv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"use_cudnn_on_gpu",name:"useCudnnOnGpu",type:"bool",defaultValue:!0},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"leakyrelu_alpha",name:"leakyreluAlpha",type:"number",defaultValue:.2}]},{tfOpName:"Conv2DBackpropInput",category:"convolution",inputs:[{start:2,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:0,name:"outputShape",type:"number[]"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]",notSupported:!0}]},{tfOpName:"DepthwiseConv2d",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"DepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"FusedDepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]}]},{tfOpName:"Conv3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"Dilation2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"rates",name:"dilations",type:"number[]"},{tfName:"padding",name:"pad",type:"string"}]}],bN=[{tfOpName:"Fill",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"},{start:1,name:"value",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"LinSpace",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"num",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"OneHot",category:"creation",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"depth",type:"number"},{start:2,name:"onValue",type:"number",defaultValue:1},{start:3,name:"offValue",type:"number",defaultValue:0}],attrs:[{tfName:"axis",name:"axis",type:"number",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Ones",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"OnesLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"RandomStandardNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"RandomUniform",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"minval",name:"minval",type:"number",defaultValue:0},{tfName:"maxval",name:"maxval",type:"number",defaultValue:1},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Range",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"step",type:"number",defaultValue:0}],attrs:[{tfName:"Tidx",name:"dtype",type:"dtype"}]},{tfOpName:"TruncatedNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"means",name:"mean",type:"number",defaultValue:0},{tfName:"stddev",name:"stdDev",type:"number",defaultValue:1},{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Zeros",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"ZerosLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"Multinomial",category:"creation",inputs:[{start:0,name:"logits",type:"tensor"},{start:1,name:"numSamples",type:"number"}],attrs:[{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number"},{tfName:"T",name:"dtype",type:"dtype"},{tfName:"output_dtype",name:"output_dtype",type:"dtype"}]}],vN=[{tfOpName:"NonMaxSuppressionV2",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV3",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV4",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"T_threshold",name:"threshold",type:"dtype",notSupported:!0},{tfName:"pad_to_max_output_size",name:"padToMaxOutputSize",type:"bool"}]},{tfOpName:"NonMaxSuppressionV5",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"},{start:5,name:"softNmsSigma",type:"number"}]},{tfOpName:"Where",category:"dynamic",inputs:[{start:0,name:"condition",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ListDiff",category:"dynamic",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],xN=[{tfOpName:"LowerBound",category:"evaluation",inputs:[{start:0,name:"sortedSequence",type:"tensor"},{start:1,name:"values",type:"tensor"}]},{tfOpName:"TopKV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"k",type:"number"}],attrs:[{tfName:"sorted",name:"sorted",type:"bool"}]},{tfOpName:"UpperBound",category:"evaluation",inputs:[{start:0,name:"sortedSequence",type:"tensor"},{start:1,name:"values",type:"tensor"}]},{tfOpName:"Unique",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"UniqueV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]}],_N=[{tfOpName:"PlaceholderWithDefault",category:"graph",inputs:[{start:0,name:"default",type:"tensor"}],attrs:[{tfName:"shape",name:"shape",type:"shape"},{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"Placeholder",category:"graph",attrs:[{tfName:"shape",name:"shape",type:"shape"},{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"Const",category:"graph"},{tfOpName:"Identity",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"IdentityN",category:"graph",inputs:[{start:0,end:0,name:"x",type:"tensors"}]},{tfOpName:"Snapshot",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Rank",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Size",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Shape",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"ShapeN",category:"graph",inputs:[{start:0,end:0,name:"x",type:"tensors"}]},{tfOpName:"Print",category:"graph",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"data",type:"tensors"}],attrs:[{tfName:"message",name:"message",type:"string"},{tfName:"first_n",name:"firstN",type:"number",notSupported:!0},{tfName:"summarize",name:"summarize",type:"number",defaultValue:3}]},{tfOpName:"NoOp",category:"graph",inputs:[]},{tfOpName:"StopGradient",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"FakeQuantWithMinMaxVars",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"min",name:"min",type:"number"},{tfName:"max",name:"max",type:"number"}]}],wN=[{tfOpName:"HashTable",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"HashTableV2",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"LookupTableImport",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableImportV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFind",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFindV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableSize",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]},{tfOpName:"LookupTableSizeV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]}],DN=[{tfOpName:"ResizeBilinear",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"half_pixel_centers",name:"halfPixelCenters",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ResizeNearestNeighbor",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"half_pixel_centers",name:"halfPixelCenters",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"CropAndResize",category:"image",inputs:[{start:0,name:"image",type:"tensor"},{start:1,name:"boxes",type:"tensor"},{start:2,name:"boxInd",type:"tensor"},{start:3,name:"cropSize",type:"number[]"}],attrs:[{tfName:"method",name:"method",type:"string"},{tfName:"extrapolation_value",name:"extrapolationValue",type:"number"}]},{tfOpName:"ImageProjectiveTransformV3",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"transforms",type:"tensor"},{start:2,name:"outputShape",type:"number[]"},{start:3,name:"fillValue",type:"number"}],attrs:[{tfName:"interpolation",name:"interpolation",type:"string"},{tfName:"fill_mode",name:"fillMode",type:"string"}]}],NN=[{tfOpName:"Equal",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NotEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Greater",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"GreaterEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Less",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LessEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalAnd",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalNot",category:"logical",inputs:[{start:0,name:"a",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalOr",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Select",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SelectV2",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],MN=[{tfOpName:"_FusedMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"leakyrelu_alpha",name:"leakyreluAlpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMulV2",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Transpose",category:"matrices",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"perm",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Einsum",category:"matrices",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"equation",name:"equation",type:"string"},{tfName:"N",name:"n",type:"number",defaultValue:2},{tfName:"T",name:"dtype",type:"dtype"}]}],SN=[{tfOpName:"EuclideanNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool",defaultValue:!1}]},{tfOpName:"FusedBatchNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV2",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV3",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"LRN",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"depth_radius",name:"radius",type:"number",defaultValue:5},{tfName:"bias",name:"bias",type:"number",defaultValue:1},{tfName:"alpha",name:"alpha",type:"number",defaultValue:1},{tfName:"beta",name:"beta",type:"number",defaultValue:.5}]},{tfOpName:"Softmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"LogSoftmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"SparseToDense",category:"normalization",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!0,notSupported:!0}]}],kN=[{tfOpName:"Bincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}]},{tfOpName:"DenseBincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}],attrs:[{tfName:"binary_output",name:"binaryOutput",type:"bool"}]},{tfOpName:"Max",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Mean",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Min",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Sum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"All",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Any",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"ArgMax",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"ArgMin",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"Prod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Cumprod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]},{tfOpName:"Cumsum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]}],TN=[{tfOpName:"ConcatV2",category:"slice_join",inputs:[{start:0,end:-1,name:"tensors",type:"tensors"},{start:-1,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"Concat",category:"slice_join",inputs:[{start:1,end:0,name:"tensors",type:"tensors"},{start:0,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"GatherV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"axis",type:"number",defaultValue:0}],attrs:[{tfName:"batch_dims",name:"batchDims",type:"number",defaultValue:0}]},{tfOpName:"Gather",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",notSupported:!0}]},{tfOpName:"Reverse",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"dims",type:"bool[]"}]},{tfOpName:"ReverseV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}]},{tfOpName:"Slice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"size",type:"number[]"}]},{tfOpName:"StridedSlice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"end",type:"number[]"},{start:3,name:"strides",type:"number[]"}],attrs:[{tfName:"begin_mask",name:"beginMask",type:"number",defaultValue:0},{tfName:"end_mask",name:"endMask",type:"number",defaultValue:0},{tfName:"new_axis_mask",name:"newAxisMask",type:"number",defaultValue:0},{tfName:"ellipsis_mask",name:"ellipsisMask",type:"number",defaultValue:0},{tfName:"shrink_axis_mask",name:"shrinkAxisMask",type:"number",defaultValue:0}]},{tfOpName:"Pack",category:"slice_join",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0}]},{tfOpName:"Unpack",category:"slice_join",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0},{tfName:"num",name:"num",type:"number",defaultValue:0,notSupported:!0}]},{tfOpName:"Tile",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"reps",type:"number[]"}]},{tfOpName:"Split",category:"slice_join",inputs:[{start:0,name:"axis",type:"number",defaultValue:0},{start:1,name:"x",type:"tensor"}],attrs:[{tfName:"num_split",name:"numOrSizeSplits",type:"number",defaultValue:1}]},{tfOpName:"SplitV",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"numOrSizeSplits",type:"number[]"},{start:2,name:"axis",type:"number",defaultValue:0}]},{tfOpName:"ScatterNd",category:"slice_join",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"shape",type:"number[]"}]},{tfOpName:"GatherNd",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}]},{tfOpName:"SparseToDense",category:"slice_join",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!1,notSupported:!0}]}],CN=[{tfOpName:"SparseFillEmptyRows",category:"sparse",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"denseShape",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}]},{tfOpName:"SparseReshape",category:"sparse",inputs:[{start:0,name:"inputIndices",type:"tensor"},{start:1,name:"inputShape",type:"tensor"},{start:2,name:"newShape",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SparseSegmentMean",category:"sparse",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"segmentIds",type:"tensor"}]},{tfOpName:"SparseSegmentSum",category:"sparse",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"segmentIds",type:"tensor"}]}],EN=[{tfOpName:"FFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"IFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"RFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"fft_length",type:"number",notSupported:!0}]},{tfOpName:"IRFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"fft_length",type:"number",notSupported:!0}]}],AN=[{tfOpName:"StringNGrams",category:"string",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"dataSplits",type:"tensor"}],attrs:[{tfName:"separator",name:"separator",type:"string"},{tfName:"ngram_widths",name:"nGramWidths",type:"number[]"},{tfName:"left_pad",name:"leftPad",type:"string"},{tfName:"right_pad",name:"rightPad",type:"string"},{tfName:"pad_width",name:"padWidth",type:"number"},{tfName:"preserve_short_sequences",name:"preserveShortSequences",type:"bool"}],outputs:["ngrams","ngrams_splits"]},{tfOpName:"StringSplit",category:"string",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"delimiter",type:"tensor"}],attrs:[{tfName:"skip_empty",name:"skipEmpty",type:"bool"}],outputs:["indices","values","shape"]},{tfOpName:"StringToHashBucketFast",category:"string",inputs:[{start:0,name:"input",type:"tensor"}],attrs:[{tfName:"num_buckets",name:"numBuckets",type:"number"}]}],IN=[{tfOpName:"Cast",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"SrcT",name:"sdtype",type:"dtype",notSupported:!0},{tfName:"DstT",name:"dtype",type:"dtype"}]},{tfOpName:"ExpandDims",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"MirrorPad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"mode",name:"mode",type:"string"}]},{tfOpName:"Pad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"constant_value",name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"PadV2",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"},{start:2,name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"Reshape",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}]},{tfOpName:"Squeeze",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"axis",tfDeprecatedName:"squeeze_dims",name:"axis",type:"number[]"}]},{tfOpName:"SpaceToBatchND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"paddings",type:"number[]"}]},{tfOpName:"BatchToSpaceND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"crops",type:"number[]"}]},{tfOpName:"DepthToSpace",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"block_size",name:"blockSize",type:"number"},{tfName:"data_format",name:"dataFormat",type:"string"}]},{tfOpName:"BroadcastTo",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}],attrs:[]},{tfOpName:"BroadcastArgs",category:"transformation",inputs:[{start:0,name:"s0",type:"tensor"},{start:1,name:"s1",type:"tensor"}],attrs:[]}];class LN{static get Instance(){return this._instance||(this._instance=new this)}constructor(){const e=[].concat(...[N,M,S,k,T,C,E,A,I,L,F,$,O,R,Y,B,z,P,H].map((e=>e.json)));this.opMappers=e.reduce(((e,t)=>(e[t.tfOpName]=t,e)),{})}transformGraph(e,t={}){const n=e.node,r=[],a=[],i=[],s=n.reduce(((e,t)=>(e[t.name]=this.mapNode(t),t.op.startsWith("Placeholder")?r.push(e[t.name]):"Const"===t.op?a.push(e[t.name]):null!=t.input&&0!==t.input.length||i.push(e[t.name]),e)),{});let o=[];const u=[];let l={},c={};null!=t&&(l=this.mapSignatureEntries(t.inputs),c=this.mapSignatureEntries(t.outputs));const p=Object.keys(s);p.forEach((e=>{const t=s[e];t.inputNames.forEach(((e,n)=>{const[r,,a]=lN(e),i=s[r];if(null!=i.outputs){const e=i.outputs.indexOf(a);if(-1!==e){const a=`${r}:${e}`;t.inputNames[n]=a}}t.inputs.push(i),i.children.push(t)}))})),0===Object.keys(c).length?p.forEach((e=>{const t=s[e];0===t.children.length&&u.push(t)})):Object.keys(c).forEach((e=>{const[t]=lN(e),n=s[t];null!=n&&(n.signatureKey=c[e],u.push(n))})),Object.keys(l).length>0?Object.keys(l).forEach((e=>{const[t]=lN(e),n=s[t];n&&(n.signatureKey=l[e],o.push(n))})):o=r;let d={};null!=e.library&&null!=e.library.function&&(d=e.library.function.reduce(((e,t)=>(e[t.signature.name]=this.mapFunction(t),e)),{}));const h={nodes:s,inputs:o,outputs:u,weights:a,placeholders:r,signature:t,functions:d};return i.length>0&&(h.initNodes=i),h}mapSignatureEntries(e){return Object.keys(e||{}).reduce(((t,n)=>(t[e[n].name]=n,t)),{})}mapNode(e){const t=iN(e.op)||this.opMappers[e.op]||{};null==e.attr&&(e.attr={});const n={name:e.name,op:e.op,category:t.category,inputNames:(e.input||[]).map((e=>e.startsWith("^")?e.slice(1):e)),inputs:[],children:[],inputParams:{},attrParams:{},rawAttrs:e.attr,outputs:t.outputs};return null!=t.inputs&&(n.inputParams=t.inputs.reduce(((e,t)=>(e[t.name]={type:t.type,inputIndexStart:t.start,inputIndexEnd:t.end},e)),{})),null!=t.attrs&&(n.attrParams=t.attrs.reduce(((t,n)=>{const r=n.type;let a;switch(n.type){case"string":a=$N(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=$N(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"string[]":a=qN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=qN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"number":a=RN(e.attr,n.tfName,n.defaultValue||0),void 0===a&&n.tfDeprecatedName&&(a=RN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"number[]":a=UN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=UN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool":a=ON(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=ON(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool[]":a=VN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=VN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape":a=jN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=jN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape[]":a=WN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=WN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype":a=zN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=zN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype[]":a=PN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=PN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"func":a=BN(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=BN(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"tensor":case"tensors":break;default:throw new Error(`Unsupported param type: ${n.type} for op: ${e.op}`)}return t[n.name]={value:a,type:r},t}),{})),n}mapFunction(e){const t=e.nodeDef,n=[];let r={};null!=t&&(r=t.reduce(((e,t)=>(e[t.name]=this.mapNode(t),"Const"===t.op&&n.push(e[t.name]),e)),{}));const a=[],i=[];e.signature.inputArg.forEach((e=>{const[t]=lN(e.name),n={name:t,op:"Placeholder",inputs:[],inputNames:[],category:"graph",inputParams:{},attrParams:{dtype:{value:YN(e.type),type:"dtype"}},children:[]};n.signatureKey=e.name,a.push(n),r[t]=n})),Object.keys(r).forEach((e=>{const t=r[e];t.inputNames.forEach(((e,n)=>{const[a,,i]=lN(e),s=r[a];if(null!=s.outputs){const e=s.outputs.indexOf(i);if(-1!==e){const r=`${a}:${e}`;t.inputNames[n]=r}}t.inputs.push(s),s.children.push(t)}))}));const s=e.ret;e.signature.outputArg.forEach((e=>{const[t,n]=lN(s[e.name]),a=r[t];null!=a&&(a.defaultOutput=n,i.push(a))}));const o=this.mapArgsToSignature(e);return{nodes:r,inputs:a,outputs:i,weights:n,placeholders:[],signature:o}}mapArgsToSignature(e){return{methodName:e.signature.name,inputs:e.signature.inputArg.reduce(((e,t)=>(e[t.name]=this.mapArgToTensorInfo(t),e)),{}),outputs:e.signature.outputArg.reduce(((t,n)=>(t[n.name]=this.mapArgToTensorInfo(n,e.ret),t)),{})}}mapArgToTensorInfo(e,t){let n=e.name;return null!=t&&(n=t[n]),{name:n,dtype:e.type}}}function FN(e,t){const n=Array.isArray(e)?String.fromCharCode.apply(null,e):function(e){const t=Ge().global;if(void 0!==t.atob)return t.atob(e);if("undefined"!=typeof Buffer)return new Buffer(e,"base64").toString();throw new Error("Unable to decode base64 in this environment. Missing built-in atob() or Buffer()")}(e);return t?n:n.toLowerCase()}function $N(e,t,n,r=!1){const a=e[t];return null!=a?FN(a.s,r):n}function ON(e,t,n){const r=e[t];return r?r.b:n}function RN(e,t,n){const r=e[t]||{},a=null!=r.i?r.i:null!=r.f?r.f:n;return"number"==typeof a?a:parseInt(a,10)}function YN(e){switch("string"==typeof e&&(e=tN[e]),e){case tN.DT_FLOAT:case tN.DT_HALF:return"float32";case tN.DT_INT32:case tN.DT_INT64:case tN.DT_INT8:case tN.DT_UINT8:return"int32";case tN.DT_BOOL:return"bool";case tN.DT_DOUBLE:return"float32";case tN.DT_STRING:return"string";default:return null}}function BN(e,t,n){const r=e[t];return r&&r.func?r.func.name:n}function zN(e,t,n){const r=e[t];return r&&r.type?YN(r.type):n}function PN(e,t,n){const r=e[t];return r&&r.list&&r.list.type?r.list.type.map((e=>YN(e))):n}function HN(e){if(!e.unknownRank)return null!=e.dim?e.dim.map((e=>"number"==typeof e.size?e.size:parseInt(e.size,10))):[]}function jN(e,t,n){const r=e[t];return r&&r.shape?HN(r.shape):n}function UN(e,t,n){const r=e[t];return r?((r.list.f&&r.list.f.length?r.list.f:r.list.i)||[]).map((e=>"number"==typeof e?e:parseInt(e,10))):n}function qN(e,t,n,r=!1){const a=e[t];return a&&a.list&&a.list.s?a.list.s.map((e=>FN(e,r))):n}function WN(e,t,n){const r=e[t];return r&&r.list&&r.list.shape?r.list.shape.map((e=>HN(e))):n}function VN(e,t,n){const r=e[t];return r&&r.list&&r.list.b?r.list.b:n}class GN{constructor(e,t,n){this.node=e,this.tensorMap=t,this.context=n,this.inputs=[],this.attrs={},this.inputs=e.inputNames.map((e=>this.getInput(e))),null!=e.rawAttrs&&(this.attrs=Object.keys(e.rawAttrs).reduce(((e,t)=>(e[t]=this.getAttr(t),e)),{}))}getInput(e){return uN(e,this.tensorMap,this.context)}getAttr(e,t){const n=this.node.rawAttrs[e];if(null!=n.tensor)return uN(e,this.tensorMap,this.context);if(null!=n.i||null!=n.f)return RN(this.node.rawAttrs,e,t);if(null!=n.s)return $N(this.node.rawAttrs,e,t);if(null!=n.b)return ON(this.node.rawAttrs,e,t);if(null!=n.shape)return jN(this.node.rawAttrs,e,t);if(null!=n.type)return zN(this.node.rawAttrs,e,t);if(null!=n.list){if(null!=n.list.i||null!=n.list.f)return UN(this.node.rawAttrs,e,t);if(null!=n.list.s)return qN(this.node.rawAttrs,e,t);if(null!=n.list.shape)return WN(this.node.rawAttrs,e,t);if(null!=n.list.b)return VN(this.node.rawAttrs,e,t);if(null!=n.list.type)return PN(this.node.rawAttrs,e,t)}return t}}function KN(e,t,n=""){if("number"!=typeof e&&"number"!=typeof t){se(e.length===t.length,(()=>n+` Shapes ${e} and ${t} must match`));for(let r=0;rn+` Shapes ${e} and ${t} must match`))}}}function JN(e){return"number"!=typeof e&&!e.some((e=>e<0))}function XN(e,t,n){let r=ZN(e,n);const a=!JN(r);if(a&&0===t.length)throw new Error(`Tried to calculate elements of an empty list with non-fully-defined elementShape: ${r}`);if(a&&t.forEach((e=>{r=ZN(e.shape,r)})),!JN(r))throw new Error(`Non-fully-defined elementShape: ${r}`);return r}function ZN(e,t){if("number"==typeof e)return t;if("number"==typeof t)return e;if(e.length!==t.length)throw new Error(`Incompatible ranks during merge: ${e} vs. ${t}`);const n=[];for(let r=0;r=0&&i>=0&&a!==i)throw new Error(`Incompatible shape during merge: ${e} vs. ${t}`);n[r]=a>=0?a:i}return n}class QN{constructor(e,t,n,r,a,i,s){this.name=e,this.dtype=t,this.maxSize=n,this.elementShape=r,this.identicalElementShapes=a,this.dynamicSize=i,this.clearAfterRead=s,this.tensors=[],this.closed_=!1,this.idTensor=Ou(0),mo(this.idTensor)}get id(){return this.idTensor.id}get closed(){return this.closed_}clearAndClose(e){this.tensors.forEach((t=>{null!=e&&e.has(t.tensor.id)||t.tensor.dispose()})),this.tensors=[],this.closed_=!0,this.idTensor.dispose()}size(){return this.tensors.length}read(e){if(this.closed_)throw new Error(`TensorArray ${this.name} has already been closed.`);if(e<0||e>=this.size())throw new Error(`Tried to read from index ${e}, but array size is: ${this.size()}`);const t=this.tensors[e];if(t.cleared)throw new Error(`TensorArray ${this.name}: Could not read index ${e} twice because it was cleared after a previous read (perhaps try setting clear_after_read = false?).`);return this.clearAfterRead&&(t.cleared=!0),t.read=!0,t.tensor}readMany(e){return e.map((e=>this.read(e)))}write(e,t){if(this.closed_)throw new Error(`TensorArray ${this.name} has already been closed.`);if(e<0||!this.dynamicSize&&e>=this.maxSize)throw new Error(`Tried to write to index ${e}, but array is not resizeable and size is: ${this.maxSize}`);const n=this.tensors[e]||{};if(t.dtype!==this.dtype)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e},\n because the value dtype is ${t.dtype}, but TensorArray dtype is ${this.dtype}.`);if(0!==this.size()||null!=this.elementShape&&0!==this.elementShape.length||(this.elementShape=t.shape),KN(this.elementShape,t.shape,`TensorArray ${this.name}: Could not write to TensorArray index ${e}.`),n.read)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been read.`);if(n.written)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been written.`);n.tensor=t,mo(t),n.written=!0,this.tensors[e]=n}writeMany(e,t){if(e.length!==t.length)throw new Error(`TensorArray ${this.name}: could not write multiple tensors,because the index size: ${e.length} is not the same as tensors size: ${t.length}.`);e.forEach(((e,n)=>this.write(e,t[n])))}gather(e,t){if(t&&t!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but gather requested dtype ${t}`);if(e)e=e.slice(0,this.size());else{e=[];for(let t=0;t=this.maxSize)throw new Error(`Max index must be < array size (${n} vs. ${this.maxSize})`);this.writeMany(e,Sd(t,0))}split(e,t){if(t.dtype!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${t.dtype}`);let n=0;const r=e.map((e=>(n+=e,n)));if(n!==t.shape[0])throw new Error(`Expected sum of lengths to be equal to\n tensor.shape[0], but sum of lengths is\n ${n}, and tensor's shape is: ${t.shape}`);if(!this.dynamicSize&&e.length!==this.maxSize)throw new Error(`TensorArray's size is not equal to the size of lengths (${this.maxSize} vs. ${e.length}), and the TensorArray is not marked as dynamically resizeable`);const a=0===n?0:t.size/n,i=[];ho((()=>{t=Dl(t,[1,n,a]);for(let n=0;n{if(n!==e.dtype)throw new Error(`Invalid data types; op elements ${n}, but list elements ${e.dtype}`);KN(t,e.shape,"TensorList shape mismatch: "),mo(e)})),this.idTensor=Ou(0),this.maxNumElements=r,mo(this.idTensor)}get id(){return this.idTensor.id}copy(){return new eM([...this.tensors],this.elementShape,this.elementDtype)}clearAndClose(e){this.tensors.forEach((t=>{null!=e&&e.has(t.id)||t.dispose()})),this.tensors.length=0,this.idTensor.dispose()}size(){return this.tensors.length}stack(e,t,n=-1){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);if(-1!==n&&this.tensors.length!==n)throw new Error(`Operation expected a list with ${n} elements but got a list with ${this.tensors.length} elements.`);KN(e,this.elementShape,"TensorList shape mismatch: ");const r=XN(this.elementShape,this.tensors,e);return ho((()=>{const e=this.tensors.map((e=>Dl(e,r)));return hd(e,0)}))}popBack(e,t){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);if(0===this.size())throw new Error("Trying to pop from an empty list.");const n=XN(this.elementShape,this.tensors,e),r=this.tensors.pop();return KN(r.shape,e,"TensorList shape mismatch: "),Dl(r,n)}pushBack(e){if(e.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${this.elementDtype}`);if(KN(e.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw new Error("Trying to push element into a full list.");mo(e),this.tensors.push(e)}resize(e){if(e<0)throw new Error(`TensorListResize expects size to be non-negative. Got: ${e}`);if(-1!==this.maxNumElements&&e>this.maxNumElements)throw new Error(`TensorListResize input size ${e} is greater maxNumElement ${this.maxNumElements}.`);const t=new eM([],this.elementShape,this.elementDtype,this.maxNumElements);t.tensors.length=e;for(let n=0;nthis.tensors.length)throw new Error(`Trying to access element ${e} in a list with ${this.tensors.length} elements.`);if(null==this.tensors[e])throw new Error(`element at index ${e} is null.`);KN(this.tensors[e].shape,t,"TensorList shape mismatch: ");const r=XN(this.elementShape,this.tensors,t);return Dl(this.tensors[e],r)}setItem(e,t){if(t.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t.dtype}, but list elements ${this.elementDtype}`);if(e<0||-1!==this.maxNumElements&&e>=this.maxNumElements)throw new Error(`Trying to set element ${e} in a list with max ${this.maxNumElements} elements.`);KN(this.elementShape,t.shape,"TensorList shape mismatch: "),mo(t),this.tensors[e]=t}gather(e,t,n){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);KN(this.elementShape,n,"TensorList shape mismatch: "),e=e.slice(0,this.size());const r=XN(this.elementShape,this.tensors,n);return 0===e.length?Ri([],[0].concat(r)):ho((()=>{const t=e.map((e=>Dl(this.tensors[e],r)));return hd(t,0)}))}concat(e,t){if(e&&e!==this.elementDtype)throw new Error(`TensorList dtype is ${this.elementDtype} but concat requested dtype ${e}`);KN(this.elementShape,t,"TensorList shape mismatch: ");const n=XN(this.elementShape,this.tensors,t);return 0===this.size()?Ri([],[0].concat(n)):ho((()=>{const e=this.tensors.map((e=>Dl(e,n)));return Sl(e,0)}))}}function tM(e,t,n){const[r,a]=oN("fusedOps",e,t,n),i="biasadd"===r,s=!i,o="prelu"===a,u="fusedbatchnorm"===r,l=oN("numArgs",e,t,n);if(i){if(o&&2!==l)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!o&&i&&1!==l)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias.")}if(u)throw new Error("FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported");const c=oN("strides",e,t,n),p=dN(e,t,n),d=oN("dataFormat",e,t,n).toUpperCase(),h=oN("dilations",e,t,n);let[f,m]=oN("args",e,t,n);return s&&(m=f,f=void 0),{stride:c,pad:p,dataFormat:d,dilations:h,biasArg:f,preluArg:m,activationFunc:a,leakyreluAlpha:oN("leakyreluAlpha",e,t,n)}}function nM(e,t,n){return{boxes:oN("boxes",e,t,n),scores:oN("scores",e,t,n),maxOutputSize:oN("maxOutputSize",e,t,n),iouThreshold:oN("iouThreshold",e,t,n),scoreThreshold:oN("scoreThreshold",e,t,n),softNmsSigma:oN("softNmsSigma",e,t,n)}}class rM{constructor(e,t){this.keyDType=e,this.valueDType=t,this.handle=Ou(0),this.tensorMap=new Map,mo(this.handle)}get id(){return this.handle.id}clearAndClose(){this.tensorMap.forEach((e=>e.dispose())),this.tensorMap.clear(),this.handle.dispose()}size(){return this.tensorMap.size}tensorSize(){return Ou(this.size(),"int32")}async import(e,t){this.checkKeyAndValueTensor(e,t);const n=await e.data();return this.tensorMap.forEach((e=>e.dispose())),this.tensorMap.clear(),ho((()=>{const e=Sd(t),r=n.length,a=e.length;se(r===a,(()=>`The number of elements doesn't match, keys has ${r} elements, the values has ${a} elements.`));for(let t=0;t{const e=[];for(let r=0;r{switch(e.category){case"arithmetic":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"BiasAdd":case"AddV2":case"Add":return[r.add(oN("a",e,t,n),oN("b",e,t,n))];case"AddN":return[r.addN(oN("tensors",e,t,n))];case"FloorMod":case"Mod":return[r.mod(oN("a",e,t,n),oN("b",e,t,n))];case"Mul":return[r.mul(oN("a",e,t,n),oN("b",e,t,n))];case"RealDiv":case"Div":return[r.div(oN("a",e,t,n),oN("b",e,t,n))];case"DivNoNan":return[r.divNoNan(oN("a",e,t,n),oN("b",e,t,n))];case"FloorDiv":return[r.floorDiv(oN("a",e,t,n),oN("b",e,t,n))];case"Sub":return[r.sub(oN("a",e,t,n),oN("b",e,t,n))];case"Minimum":return[r.minimum(oN("a",e,t,n),oN("b",e,t,n))];case"Maximum":return[r.maximum(oN("a",e,t,n),oN("b",e,t,n))];case"Pow":return[r.pow(oN("a",e,t,n),oN("b",e,t,n))];case"SquaredDifference":return[r.squaredDifference(oN("a",e,t,n),oN("b",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"basic_math":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"Abs":case"ComplexAbs":return[r.abs(oN("x",e,t,n))];case"Acos":return[r.acos(oN("x",e,t,n))];case"Acosh":return[r.acosh(oN("x",e,t,n))];case"Asin":return[r.asin(oN("x",e,t,n))];case"Asinh":return[r.asinh(oN("x",e,t,n))];case"Atan":return[r.atan(oN("x",e,t,n))];case"Atan2":return[r.atan2(oN("x",e,t,n),oN("y",e,t,n))];case"Atanh":return[r.atanh(oN("x",e,t,n))];case"Ceil":return[r.ceil(oN("x",e,t,n))];case"Complex":return[r.complex(oN("real",e,t,n),oN("imag",e,t,n))];case"Cos":return[r.cos(oN("x",e,t,n))];case"Cosh":return[r.cosh(oN("x",e,t,n))];case"Elu":return[r.elu(oN("x",e,t,n))];case"Erf":return[r.erf(oN("x",e,t,n))];case"Exp":return[r.exp(oN("x",e,t,n))];case"Expm1":return[r.expm1(oN("x",e,t,n))];case"Floor":return[r.floor(oN("x",e,t,n))];case"Log":return[r.log(oN("x",e,t,n))];case"Log1p":return[r.log1p(oN("x",e,t,n))];case"Imag":return[r.imag(oN("x",e,t,n))];case"Neg":return[r.neg(oN("x",e,t,n))];case"Reciprocal":return[r.reciprocal(oN("x",e,t,n))];case"Real":return[r.real(oN("x",e,t,n))];case"Relu":return[r.relu(oN("x",e,t,n))];case"Round":return[r.round(oN("x",e,t,n))];case"Selu":return[r.selu(oN("x",e,t,n))];case"Sigmoid":return[r.sigmoid(oN("x",e,t,n))];case"Sin":return[r.sin(oN("x",e,t,n))];case"Sign":return[r.sign(oN("x",e,t,n))];case"Sinh":return[r.sinh(oN("x",e,t,n))];case"Softplus":return[r.softplus(oN("x",e,t,n))];case"Sqrt":return[r.sqrt(oN("x",e,t,n))];case"Square":return[r.square(oN("x",e,t,n))];case"Tanh":return[r.tanh(oN("x",e,t,n))];case"Tan":return[r.tan(oN("x",e,t,n))];case"ClipByValue":return[r.clipByValue(oN("x",e,t,n),oN("clipValueMin",e,t,n),oN("clipValueMax",e,t,n))];case"Relu6":return[r.relu6(oN("x",e,t,n))];case"Rsqrt":return[r.rsqrt(uN(e.inputNames[0],t,n))];case"Prod":return[r.prod(oN("x",e,t,n),oN("axes",e,t,n))];case"LeakyRelu":return[r.leakyRelu(oN("x",e,t,n),oN("alpha",e,t,n))];case"Prelu":return[r.prelu(oN("x",e,t,n),oN("alpha",e,t,n))];case"IsNan":return[r.isNaN(uN(e.inputNames[0],t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"control":return(async(e,t,n)=>{switch(e.op){case"If":case"StatelessIf":{const r=oN("thenBranch",e,t,n),a=oN("elseBranch",e,t,n),i=oN("cond",e,t,n),s=oN("args",e,t,n);return(await i.data())[0]?n.functionMap[r].executeFunctionAsync(s,n.tensorArrayMap,n.tensorListMap):n.functionMap[a].executeFunctionAsync(s,n.tensorArrayMap,n.tensorListMap)}case"While":case"StatelessWhile":{const r=oN("body",e,t,n),a=oN("cond",e,t,n),i=oN("args",e,t,n),s=await n.functionMap[a].executeFunctionAsync(i,n.tensorArrayMap,n.tensorListMap),o=i.map((e=>e.id));let u=await s[0].data();s.forEach((e=>{e.kept||-1!==o.indexOf(e.id)||e.dispose()}));let l=i;for(;u[0];){const e=l;l=await n.functionMap[r].executeFunctionAsync(l,n.tensorArrayMap,n.tensorListMap);const t=l.map((e=>e.id));e.forEach((e=>{e.kept||-1!==o.indexOf(e.id)||-1!==t.indexOf(e.id)||e.dispose()}));const i=await n.functionMap[a].executeFunctionAsync(l,n.tensorArrayMap,n.tensorListMap);u=await i[0].data(),i.forEach((e=>{e.kept||-1!==o.indexOf(e.id)||-1!==t.indexOf(e.id)||e.dispose()}))}return l}case"LoopCond":return[hN(oN("pred",e,t,n))];case"Switch":{const r=oN("pred",e,t,n);let a=oN("data",e,t,n);return a.kept||(a=hN(a)),(await r.data())[0]?[void 0,a]:[a,void 0]}case"Merge":{const r=e.inputNames.find((e=>void 0!==uN(e,t,n)));return r?[hN(uN(r,t,n))]:void 0}case"Enter":{const r=oN("frameName",e,t,n),a=oN("tensor",e,t,n);return n.enterFrame(r),[hN(a)]}case"Exit":{const r=oN("tensor",e,t,n);return n.exitFrame(),[hN(r)]}case"NextIteration":{const r=oN("tensor",e,t,n);return n.nextIteration(),[hN(r)]}case"TensorArrayV3":{const r=oN("size",e,t,n),a=oN("dtype",e,t,n),i=oN("elementShape",e,t,n),s=oN("dynamicSize",e,t,n),o=oN("clearAfterRead",e,t,n),u=oN("identicalElementShapes",e,t,n),l=oN("name",e,t,n),c=new QN(l,a,r,i,u,s,o);return n.addTensorArray(c),[c.idTensor,Ou(1)]}case"TensorArrayWriteV3":{const r=oN("tensorArrayId",e,t,n),a=oN("index",e,t,n),i=oN("tensor",e,t,n),s=n.getTensorArray(r.id);return s.write(a,i),[s.idTensor]}case"TensorArrayReadV3":{const r=oN("tensorArrayId",e,t,n),a=oN("index",e,t,n);return[n.getTensorArray(r.id).read(a)]}case"TensorArrayGatherV3":{const r=oN("tensorArrayId",e,t,n),a=oN("indices",e,t,n),i=oN("dtype",e,t,n);return[n.getTensorArray(r.id).gather(a,i)]}case"TensorArrayScatterV3":{const r=oN("tensorArrayId",e,t,n),a=oN("indices",e,t,n),i=oN("tensor",e,t,n),s=n.getTensorArray(r.id);return s.scatter(a,i),[s.idTensor]}case"TensorArrayConcatV3":{const r=oN("tensorArrayId",e,t,n),a=n.getTensorArray(r.id),i=oN("dtype",e,t,n);return[a.concat(i)]}case"TensorArraySplitV3":{const r=oN("tensorArrayId",e,t,n),a=oN("tensor",e,t,n),i=oN("lengths",e,t,n),s=n.getTensorArray(r.id);return s.split(i,a),[s.idTensor]}case"TensorArraySizeV3":{const r=oN("tensorArrayId",e,t,n);return[Ou(n.getTensorArray(r.id).size(),"int32")]}case"TensorArrayCloseV3":{const r=oN("tensorArrayId",e,t,n),a=n.getTensorArray(r.id);return a.clearAndClose(),[a.idTensor]}case"TensorListSetItem":{const r=oN("tensorListId",e,t,n),a=oN("index",e,t,n),i=oN("tensor",e,t,n),s=n.getTensorList(r.id);return s.setItem(a,i),[s.idTensor]}case"TensorListGetItem":{const r=oN("tensorListId",e,t,n),a=oN("index",e,t,n),i=oN("elementShape",e,t,n),s=oN("elementDType",e,t,n);return[n.getTensorList(r.id).getItem(a,i,s)]}case"TensorListScatterV2":case"TensorListScatter":{const r=oN("indices",e,t,n),a=function(e,t,n,r){if(t.length!==e.shape[0])throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${t.length} vs. ${e.shape[0]}`);const a=Math.max(...t);if(null!=r&&-1!==r&&a>=r)throw new Error(`Max index must be < array size (${a} vs. ${r})`);const i=new eM([],n,e.dtype,r),s=Sd(e,0);return t.forEach(((e,t)=>{i.setItem(e,s[t])})),i}(oN("tensor",e,t,n),r,oN("elementShape",e,t,n),oN("numElements",e,t,n));return n.addTensorList(a),[a.idTensor]}case"TensorListReserve":case"EmptyTensorList":{const r=oN("elementShape",e,t,n),a=oN("elementDType",e,t,n);let i;i="TensorListReserve"===e.op?"numElements":"maxNumElements";const s=oN(i,e,t,n),o=function(e,t,n,r){return new eM([],e,t,r)}(r,a,0,"TensorListReserve"===e.op?-1:s);return n.addTensorList(o),[o.idTensor]}case"TensorListGather":{const r=oN("tensorListId",e,t,n),a=oN("indices",e,t,n),i=oN("elementShape",e,t,n),s=oN("elementDType",e,t,n);return[n.getTensorList(r.id).gather(a,s,i)]}case"TensorListStack":{const r=oN("tensorListId",e,t,n),a=oN("elementShape",e,t,n),i=oN("elementDType",e,t,n),s=oN("numElements",e,t,n);return[n.getTensorList(r.id).stack(a,i,s)]}case"TensorListFromTensor":{const r=function(e,t,n){const r=e.dtype;if(e.shape.length<1)throw new Error(`Tensor must be at least a vector, but saw shape: ${e.shape}`);if(e.dtype!==n)throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${n}`);KN(e.shape.slice(1),t,"TensorList shape mismatch: ");const a=Sd(e);return new eM(a,t,r)}(oN("tensor",e,t,n),oN("elementShape",e,t,n),oN("elementDType",e,t,n));return n.addTensorList(r),[r.idTensor]}case"TensorListConcat":case"TensorListConcatV2":{const r=oN("tensorListId",e,t,n),a=n.getTensorList(r.id),i=oN("dtype",e,t,n),s=oN("elementShape",e,t,n);return[a.concat(i,s)]}case"TensorListPushBack":{const r=oN("tensorListId",e,t,n),a=oN("tensor",e,t,n),i=n.getTensorList(r.id);return i.pushBack(a),[i.idTensor]}case"TensorListPopBack":{const r=oN("tensorListId",e,t,n),a=oN("elementShape",e,t,n),i=oN("elementDType",e,t,n);return[n.getTensorList(r.id).popBack(a,i)]}case"TensorListSplit":{const r=oN("tensor",e,t,n),a=oN("elementShape",e,t,n),i=function(e,t,n){let r=0;const a=t.map((e=>(r+=e,r)));if(r!==e.shape[0])throw new Error(`Expected sum of lengths to be equal to\n tensor.shape[0], but sum of lengths is\n ${r}, and tensor's shape is: ${e.shape}`);const i=ZN(e.shape.slice(1),n),s=0===r?0:e.size/r,o=ho((()=>{const n=[];e=Dl(e,[1,r,s]);for(let r=0;r((e,t,n,r=j)=>{switch(e.op){case"Conv1D":{const a=oN("stride",e,t,n),i=oN("pad",e,t,n),s=oN("dataFormat",e,t,n).toUpperCase(),o=oN("dilation",e,t,n);return[r.conv1d(oN("x",e,t,n),oN("filter",e,t,n),a,i,s,o)]}case"Conv2D":{const a=oN("strides",e,t,n),i=dN(e,t,n),s=oN("dataFormat",e,t,n).toUpperCase(),o=oN("dilations",e,t,n);return[r.conv2d(oN("x",e,t,n),oN("filter",e,t,n),[a[1],a[2]],i,s,[o[1],o[2]])]}case"_FusedConv2D":{const{stride:a,pad:i,dataFormat:s,dilations:o,biasArg:u,preluArg:l,activationFunc:c,leakyreluAlpha:p}=tM(e,t,n);return[r.fused.conv2d({x:oN("x",e,t,n),filter:oN("filter",e,t,n),strides:[a[1],a[2]],pad:i,dataFormat:s,dilations:[o[1],o[2]],bias:u,activation:c,preluActivationWeights:l,leakyreluAlpha:p})]}case"FusedDepthwiseConv2dNative":{const{stride:a,pad:i,dataFormat:s,dilations:o,biasArg:u,preluArg:l,activationFunc:c,leakyreluAlpha:p}=tM(e,t,n);return[r.fused.depthwiseConv2d({x:oN("x",e,t,n),filter:oN("filter",e,t,n),strides:[a[1],a[2]],pad:i,dataFormat:s,dilations:[o[1],o[2]],bias:u,activation:c,preluActivationWeights:l,leakyreluAlpha:p})]}case"Conv2DBackpropInput":case"Conv2dTranspose":{const a=oN("outputShape",e,t,n),i=oN("strides",e,t,n),s=dN(e,t,n);return[r.conv2dTranspose(oN("x",e,t,n),oN("filter",e,t,n),a,[i[1],i[2]],s)]}case"DepthwiseConv2dNative":case"DepthwiseConv2d":{const a=oN("strides",e,t,n),i=dN(e,t,n),s=oN("dilations",e,t,n),o=oN("dataFormat",e,t,n).toUpperCase();return[r.depthwiseConv2d(oN("input",e,t,n),oN("filter",e,t,n),[a[1],a[2]],i,o,[s[1],s[2]])]}case"Conv3D":{const a=oN("strides",e,t,n),i=oN("pad",e,t,n),s=oN("dataFormat",e,t,n).toUpperCase(),o=oN("dilations",e,t,n);return[r.conv3d(oN("x",e,t,n),oN("filter",e,t,n),[a[1],a[2],a[3]],i,s,[o[1],o[2],o[3]])]}case"AvgPool":{const a=oN("strides",e,t,n),i=oN("pad",e,t,n),s=oN("kernelSize",e,t,n);return[r.avgPool(oN("x",e,t,n),[s[1],s[2]],[a[1],a[2]],i)]}case"MaxPool":{const a=oN("strides",e,t,n),i=oN("pad",e,t,n),s=oN("kernelSize",e,t,n);return[r.maxPool(oN("x",e,t,n),[s[1],s[2]],[a[1],a[2]],i)]}case"MaxPoolWithArgmax":{const a=oN("strides",e,t,n),i=oN("pad",e,t,n),s=oN("kernelSize",e,t,n),o=oN("includeBatchInIndex",e,t,n),{result:u,indexes:l}=r.maxPoolWithArgmax(oN("x",e,t,n),[s[1],s[2]],[a[1],a[2]],i,o);return[u,l]}case"AvgPool3D":{const a=oN("strides",e,t,n),i=oN("pad",e,t,n),s=oN("kernelSize",e,t,n);return[r.avgPool3d(oN("x",e,t,n),[s[1],s[2],s[3]],[a[1],a[2],a[3]],i)]}case"MaxPool3D":{const a=oN("strides",e,t,n),i=oN("pad",e,t,n),s=oN("kernelSize",e,t,n);return[r.maxPool3d(oN("x",e,t,n),[s[1],s[2],s[3]],[a[1],a[2],a[3]],i)]}case"Dilation2D":{const a=oN("strides",e,t,n),i=oN("pad",e,t,n),s=oN("dilations",e,t,n),o=a[1],u=a[2],l=s[1],c=s[2];return[r.dilation2d(oN("x",e,t,n),oN("filter",e,t,n),[o,u],i,[l,c],"NHWC")]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"creation":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"Fill":{const a=oN("shape",e,t,n),i=oN("dtype",e,t,n),s=oN("value",e,t,n);return[r.fill(a,s,i)]}case"LinSpace":{const a=oN("start",e,t,n),i=oN("stop",e,t,n),s=oN("num",e,t,n);return[r.linspace(a,i,s)]}case"Multinomial":{const a=oN("logits",e,t,n),i=oN("numSamples",e,t,n),s=oN("seed",e,t,n);return[r.multinomial(a,i,s)]}case"OneHot":{const a=oN("indices",e,t,n),i=oN("depth",e,t,n),s=oN("onValue",e,t,n),o=oN("offValue",e,t,n);return[r.oneHot(a,i,s,o)]}case"Ones":return[r.ones(oN("shape",e,t,n),oN("dtype",e,t,n))];case"OnesLike":return[r.onesLike(oN("x",e,t,n))];case"RandomStandardNormal":return[r.randomStandardNormal(oN("shape",e,t,n),oN("dtype",e,t,n),oN("seed",e,t,n))];case"RandomUniform":return[r.randomUniform(oN("shape",e,t,n),oN("minval",e,t,n),oN("maxval",e,t,n),oN("dtype",e,t,n))];case"Range":{const a=oN("start",e,t,n),i=oN("stop",e,t,n),s=oN("step",e,t,n);return[r.range(a,i,s,oN("dtype",e,t,n))]}case"TruncatedNormal":{const a=oN("shape",e,t,n),i=oN("mean",e,t,n),s=oN("stdDev",e,t,n),o=oN("seed",e,t,n);return[r.truncatedNormal(a,i,s,oN("dtype",e,t,n),o)]}case"Zeros":return[r.zeros(oN("shape",e,t,n),oN("dtype",e,t,n))];case"ZerosLike":return[r.zerosLike(oN("x",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"dynamic":return(async(e,t,n,r,a=j)=>{switch(e.op){case"NonMaxSuppressionV5":{const{boxes:r,scores:i,maxOutputSize:s,iouThreshold:o,scoreThreshold:u,softNmsSigma:l}=nM(e,t,n),c=await a.image.nonMaxSuppressionWithScoreAsync(r,i,s,o,u,l);return[c.selectedIndices,c.selectedScores]}case"NonMaxSuppressionV4":{const{boxes:r,scores:i,maxOutputSize:s,iouThreshold:o,scoreThreshold:u}=nM(e,t,n),l=oN("padToMaxOutputSize",e,t,n),c=await a.image.nonMaxSuppressionPaddedAsync(r,i,s,o,u,l);return[c.selectedIndices,c.validOutputs]}case"NonMaxSuppressionV3":case"NonMaxSuppressionV2":{const{boxes:r,scores:i,maxOutputSize:s,iouThreshold:o,scoreThreshold:u}=nM(e,t,n);return[await a.image.nonMaxSuppressionAsync(r,i,s,o,u)]}case"Where":{const r=a.cast(oN("condition",e,t,n),"bool"),i=[await a.whereAsync(r)];return r.dispose(),i}case"ListDiff":return a.setdiff1dAsync(oN("x",e,t,n),oN("y",e,t,n));default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n);case"evaluation":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"LowerBound":{const a=oN("sortedSequence",e,t,n),i=oN("values",e,t,n);return[r.lowerBound(a,i)]}case"TopKV2":{const a=oN("x",e,t,n),i=oN("k",e,t,n),s=oN("sorted",e,t,n),o=r.topk(a,i,s);return[o.values,o.indices]}case"UpperBound":{const a=oN("sortedSequence",e,t,n),i=oN("values",e,t,n);return[r.upperBound(a,i)]}case"Unique":{const a=oN("x",e,t,n),i=r.unique(a);return[i.values,i.indices]}case"UniqueV2":{const a=oN("x",e,t,n),i=oN("axis",e,t,n),s=r.unique(a,i);return[s.values,s.indices]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"image":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"ResizeBilinear":{const a=oN("images",e,t,n),i=oN("size",e,t,n),s=oN("alignCorners",e,t,n),o=oN("halfPixelCenters",e,t,n);return[r.image.resizeBilinear(a,[i[0],i[1]],s,o)]}case"ResizeNearestNeighbor":{const a=oN("images",e,t,n),i=oN("size",e,t,n),s=oN("alignCorners",e,t,n),o=oN("halfPixelCenters",e,t,n);return[r.image.resizeNearestNeighbor(a,[i[0],i[1]],s,o)]}case"CropAndResize":{const a=oN("image",e,t,n),i=oN("boxes",e,t,n),s=oN("boxInd",e,t,n),o=oN("cropSize",e,t,n),u=oN("method",e,t,n),l=oN("extrapolationValue",e,t,n);return[r.image.cropAndResize(a,i,s,o,u,l)]}case"ImageProjectiveTransformV3":{const a=oN("images",e,t,n),i=oN("transforms",e,t,n),s=oN("outputShape",e,t,n),o=oN("fillValue",e,t,n),u=oN("interpolation",e,t,n),l=oN("fillMode",e,t,n);return[r.image.transform(a,i,u.toLowerCase(),l.toLowerCase(),o,s)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"graph":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"Const":return t[e.name];case"PlaceholderWithDefault":const a=oN("default",e,t,n);return[uN(e.name,t,n)||a];case"Placeholder":return[uN(e.name,t,n)];case"Identity":case"StopGradient":case"FakeQuantWithMinMaxVars":case"Snapshot":return[hN(oN("x",e,t,n))];case"IdentityN":return oN("x",e,t,n).map((e=>hN(e)));case"Shape":return[r.tensor1d(oN("x",e,t,n).shape,"int32")];case"ShapeN":return oN("x",e,t,n).map((e=>r.tensor1d(e.shape)));case"Size":return[r.scalar(oN("x",e,t,n).size,"int32")];case"Rank":return[r.scalar(oN("x",e,t,n).rank,"int32")];case"NoOp":return[r.scalar(1)];case"Print":const i=oN("x",e,t,n),s=oN("data",e,t,n),o=oN("message",e,t,n),u=oN("summarize",e,t,n);console.warn("The graph has a tf.print() operation,usually used for debugging, which slows down performance."),console.log(o);for(let e=0;e((e,t,n,r=j)=>{switch(e.op){case"Equal":return[r.equal(oN("a",e,t,n),oN("b",e,t,n))];case"NotEqual":return[r.notEqual(oN("a",e,t,n),oN("b",e,t,n))];case"Greater":return[r.greater(oN("a",e,t,n),oN("b",e,t,n))];case"GreaterEqual":return[r.greaterEqual(oN("a",e,t,n),oN("b",e,t,n))];case"Less":return[r.less(oN("a",e,t,n),oN("b",e,t,n))];case"LessEqual":return[r.lessEqual(oN("a",e,t,n),oN("b",e,t,n))];case"LogicalAnd":return[r.logicalAnd(oN("a",e,t,n),oN("b",e,t,n))];case"LogicalNot":return[r.logicalNot(oN("a",e,t,n))];case"LogicalOr":return[r.logicalOr(oN("a",e,t,n),oN("b",e,t,n))];case"Select":case"SelectV2":return[r.where(oN("condition",e,t,n),oN("a",e,t,n),oN("b",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"matrices":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"BatchMatMul":case"BatchMatMulV2":case"MatMul":return[r.matMul(oN("a",e,t,n),oN("b",e,t,n),oN("transposeA",e,t,n),oN("transposeB",e,t,n))];case"Einsum":return[r.einsum(oN("equation",e,t,n),...oN("tensors",e,t,n))];case"Transpose":return[r.transpose(oN("x",e,t,n),oN("perm",e,t,n))];case"_FusedMatMul":const[a,i]=oN("fusedOps",e,t,n),s="biasadd"===a,o="prelu"===i,u=oN("numArgs",e,t,n),l=oN("leakyreluAlpha",e,t,n);if(s){if(o&&2!==u)throw new Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!o&&1!==u)throw new Error("Fused MatMul with BiasAdd must have one extra argument: bias.")}const[c,p]=oN("args",e,t,n);return[r.fused.matMul({a:oN("a",e,t,n),b:oN("b",e,t,n),transposeA:oN("transposeA",e,t,n),transposeB:oN("transposeB",e,t,n),bias:c,activation:i,preluActivationWeights:p,leakyreluAlpha:l})];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"normalization":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"EuclideanNorm":return[r.euclideanNorm(oN("x",e,t,n),oN("axis",e,t,n),oN("keepDims",e,t,n))];case"FusedBatchNorm":case"FusedBatchNormV2":case"FusedBatchNormV3":return[r.batchNorm(oN("x",e,t,n),oN("mean",e,t,n),oN("variance",e,t,n),oN("offset",e,t,n),oN("scale",e,t,n),oN("epsilon",e,t,n))];case"LRN":return[r.localResponseNormalization(oN("x",e,t,n),oN("radius",e,t,n),oN("bias",e,t,n),oN("alpha",e,t,n),oN("beta",e,t,n))];case"Softmax":return[r.softmax(oN("x",e,t,n))];case"LogSoftmax":return[r.logSoftmax(oN("x",e,t,n))];case"SparseToDense":return[r.sparseToDense(oN("sparseIndices",e,t,n),oN("outputShape",e,t,n),oN("sparseValues",e,t,n),oN("defaultValue",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"reduction":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"Max":{const a=oN("axis",e,t,n),i=oN("keepDims",e,t,n);return[r.max(oN("x",e,t,n),a,i)]}case"Mean":{const a=oN("axis",e,t,n),i=oN("keepDims",e,t,n);return[r.mean(oN("x",e,t,n),a,i)]}case"Min":{const a=oN("axis",e,t,n),i=oN("keepDims",e,t,n);return[r.min(oN("x",e,t,n),a,i)]}case"Sum":{const a=oN("axis",e,t,n),i=oN("keepDims",e,t,n);return[r.sum(oN("x",e,t,n),a,i)]}case"All":{const a=oN("axis",e,t,n),i=oN("keepDims",e,t,n);return[r.all(oN("x",e,t,n),a,i)]}case"Any":{const a=oN("axis",e,t,n),i=oN("keepDims",e,t,n);return[r.any(oN("x",e,t,n),a,i)]}case"ArgMax":{const a=oN("axis",e,t,n);return[r.argMax(oN("x",e,t,n),a)]}case"ArgMin":{const a=oN("axis",e,t,n);return[r.argMin(oN("x",e,t,n),a)]}case"Prod":{const a=oN("axis",e,t,n),i=oN("keepDims",e,t,n);return[r.prod(oN("x",e,t,n),a,i)]}case"Cumprod":{const a=oN("axis",e,t,n),i=oN("exclusive",e,t,n),s=oN("reverse",e,t,n);return[r.cumprod(oN("x",e,t,n),a,i,s)]}case"Cumsum":{const a=oN("axis",e,t,n),i=oN("exclusive",e,t,n),s=oN("reverse",e,t,n);return[r.cumsum(oN("x",e,t,n),a,i,s)]}case"Bincount":const a=oN("x",e,t,n),i=oN("weights",e,t,n),s=oN("size",e,t,n);return[r.bincount(a,i,s)];case"DenseBincount":{const a=oN("x",e,t,n),i=oN("weights",e,t,n),s=oN("size",e,t,n),o=oN("binaryOutput",e,t,n);return[r.denseBincount(a,i,s,o)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"slice_join":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"ConcatV2":case"Concat":{const a=oN("n",e,t,n),i=oN("axis",e,t,n);let s=oN("tensors",e,t,n);return s=s.slice(0,a),[r.concat(s,i)]}case"Gather":{const a=oN("x",e,t,n),i=oN("indices",e,t,n);return[r.gather(a,r.cast(i,"int32"),0)]}case"GatherV2":{const a=oN("axis",e,t,n),i=oN("batchDims",e,t,n),s=oN("x",e,t,n),o=oN("indices",e,t,n);return[r.gather(s,r.cast(o,"int32"),a,i)]}case"Reverse":{const a=oN("dims",e,t,n),i=[];for(let e=0;e{const a=oN("axis",e,t,n),i=oN("tensors",e,t,n),s=i[0].shape,o=r.squeeze(i[0]).shape,u=i.map((e=>{const t=de(e.shape,s);if(!t&&!de(r.squeeze(e).shape,o))throw new Error("the input tensors shape does not match");return t?e:r.reshape(e,s)}));return[r.stack(u,a)]}));case"Unpack":{const a=oN("axis",e,t,n),i=oN("tensor",e,t,n);return r.unstack(i,a)}case"Tile":{const a=oN("reps",e,t,n);return[r.tile(oN("x",e,t,n),a)]}case"Split":case"SplitV":{const a=oN("axis",e,t,n),i=oN("numOrSizeSplits",e,t,n),s=oN("x",e,t,n);return r.split(s,i,a)}case"ScatterNd":{const a=oN("indices",e,t,n),i=oN("values",e,t,n),s=oN("shape",e,t,n);return[r.scatterND(a,i,s)]}case"GatherNd":{const a=oN("x",e,t,n),i=oN("indices",e,t,n);return[r.gatherND(a,i)]}case"SparseToDense":{const a=oN("sparseIndices",e,t,n),i=oN("outputShape",e,t,n),s=oN("sparseValues",e,t,n),o=oN("defaultValue",e,t,n);return[r.sparseToDense(a,s,i,s.dtype===o.dtype?o:r.cast(o,s.dtype))]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"sparse":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"SparseFillEmptyRows":{const{outputIndices:a,outputValues:i,emptyRowIndicator:s,reverseIndexMap:o}=r.sparse.sparseFillEmptyRows(oN("indices",e,t,n),oN("values",e,t,n),oN("denseShape",e,t,n),oN("defaultValue",e,t,n));return[a,i,s,o]}case"SparseReshape":{const{outputIndices:a,outputShape:i}=r.sparse.sparseReshape(oN("inputIndices",e,t,n),oN("inputShape",e,t,n),oN("newShape",e,t,n));return[a,i]}case"SparseSegmentMean":return[r.sparse.sparseSegmentMean(oN("data",e,t,n),oN("indices",e,t,n),oN("segmentIds",e,t,n))];case"SparseSegmentSum":return[r.sparse.sparseSegmentSum(oN("data",e,t,n),oN("indices",e,t,n),oN("segmentIds",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"spectral":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"FFT":return[r.fft(oN("x",e,t,n))];case"IFFT":return[r.ifft(oN("x",e,t,n))];case"RFFT":return[r.rfft(oN("x",e,t,n))];case"IRFFT":return[r.irfft(oN("x",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"string":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"StringNGrams":{const{nGrams:a,nGramsSplits:i}=r.string.stringNGrams(oN("data",e,t,n),oN("dataSplits",e,t,n),oN("separator",e,t,n),oN("nGramWidths",e,t,n),oN("leftPad",e,t,n),oN("rightPad",e,t,n),oN("padWidth",e,t,n),oN("preserveShortSequences",e,t,n));return[a,i]}case"StringSplit":{const{indices:a,values:i,shape:s}=r.string.stringSplit(oN("input",e,t,n),oN("delimiter",e,t,n),oN("skipEmpty",e,t,n));return[a,i,s]}case"StringToHashBucketFast":return[r.string.stringToHashBucketFast(oN("input",e,t,n),oN("numBuckets",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"transformation":return a((()=>((e,t,n,r=j)=>{switch(e.op){case"Cast":return[r.cast(oN("x",e,t,n),oN("dtype",e,t,n))];case"ExpandDims":{const a=oN("axis",e,t,n);return[r.expandDims(oN("x",e,t,n),a)]}case"Squeeze":{const a=oN("axis",e,t,n);return[r.squeeze(oN("x",e,t,n),a)]}case"Reshape":return[r.reshape(oN("x",e,t,n),oN("shape",e,t,n))];case"MirrorPad":return[r.mirrorPad(oN("x",e,t,n),oN("padding",e,t,n),oN("mode",e,t,n))];case"PadV2":case"Pad":return[r.pad(oN("x",e,t,n),oN("padding",e,t,n),oN("constantValue",e,t,n))];case"SpaceToBatchND":{const a=oN("blockShape",e,t,n),i=oN("paddings",e,t,n);return[r.spaceToBatchND(oN("x",e,t,n),a,i)]}case"BatchToSpaceND":{const a=oN("blockShape",e,t,n),i=oN("crops",e,t,n);return[r.batchToSpaceND(oN("x",e,t,n),a,i)]}case"DepthToSpace":{const a=oN("blockSize",e,t,n),i=oN("dataFormat",e,t,n).toUpperCase();return[r.depthToSpace(oN("x",e,t,n),a,i)]}case"BroadcastTo":return[r.broadcastTo(oN("x",e,t,n),oN("shape",e,t,n))];case"BroadcastArgs":return[r.broadcastArgs(oN("s0",e,t,n),oN("s1",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"hash_table":return(async(e,t,n,r)=>{switch(e.op){case"HashTable":case"HashTableV2":{const a=oN("keyDType",e,t,n),i=oN("valueDType",e,t,n),s=new rM(a,i);return r.addHashTable(e.name,s),[s.handle]}case"LookupTableImport":case"LookupTableImportV2":{const a=oN("tableHandle",e,t,n,r),i=oN("keys",e,t,n),s=oN("values",e,t,n),o=r.getHashTableById(a.id);return[await o.import(i,s)]}case"LookupTableFind":case"LookupTableFindV2":{const a=oN("tableHandle",e,t,n,r),i=oN("keys",e,t,n),s=oN("defaultValue",e,t,n),o=r.getHashTableById(a.id);return[await o.find(i,s)]}case"LookupTableSize":case"LookupTableSizeV2":{const a=oN("tableHandle",e,t,n,r);return[r.getHashTableById(a.id).tensorSize()]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n,r);case"custom":const i=iN(e.op);if(i&&i.customExecutor)return i.customExecutor(new GN(e,t,n));throw TypeError(`Custom op ${e.op} is not registered.`);default:throw TypeError(`Unknown op '${e.op}'. File an issue at https://github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp()`)}})(e,t,n);return qe(i)?i.then((e=>[].concat(e))):[].concat(i)}class iM{constructor(e={},t={},n={},r={}){this.weightMap=e,this.tensorArrayMap=t,this.tensorListMap=n,this.functionMap=r,this.rootContext={id:0,frameName:"",iterationId:0},this.contexts=[this.rootContext],this.lastId=0,this.generateCurrentContextIds()}newFrame(e,t){return{id:e,frameName:t,iterationId:0}}set currentContext(e){this.contexts!==e&&(this.contexts=e,this.generateCurrentContextIds())}get currentContext(){return this.contexts}get currentContextId(){return this._currentContextIds[0]}get currentContextIds(){return this._currentContextIds}generateCurrentContextIds(){const e=[];for(let t=0;t0===e.id&&0===e.iterationId?"":`${e.frameName}-${e.iterationId}`)).join("/"):""}enterFrame(e){this.contexts&&(this.lastId++,this.contexts=this.contexts.slice(),this.contexts.push(this.newFrame(this.lastId,e)),this._currentContextIds.unshift(this.contextIdforContexts(this.contexts)))}exitFrame(){if(!(this.contexts&&this.contexts.length>1))throw new Error("Cannot exit frame, the context is empty");this.contexts=this.contexts.slice(),this.contexts.splice(-1),this.currentContextIds.shift()}nextIteration(){if(!(this.contexts&&this.contexts.length>0))throw new Error("Cannot increase frame iteration, the context is empty");{this.contexts=this.contexts.slice(),this.lastId++;const e=Object.assign({},this.contexts[this.contexts.length-1]);e.iterationId+=1,e.id=this.lastId,this.contexts.splice(-1,1,e),this._currentContextIds.splice(0,1,this.contextIdforContexts(this.contexts))}}getWeight(e){return this.weightMap[e]}addTensorArray(e){this.tensorArrayMap[e.id]=e}getTensorArray(e){return this.tensorArrayMap[e]}addTensorList(e){this.tensorListMap[e.id]=e}getTensorList(e){return this.tensorListMap[e]}dispose(e){for(const t in this.tensorArrayMap)this.tensorArrayMap[t].clearAndClose(e);for(const t in this.tensorListMap)this.tensorListMap[t].clearAndClose(e)}}function sM(e,t,n,r){const a=new Set,i=[];let s=null,o=null;const u=new Set,l=Object.keys(e).map((e=>pN(e)[0]));let c=[];null!=r&&(c=r.map((e=>pN(e.name)[0])));const p=[...t];for(;p.length>0;){const e=p.pop();(cM(e)||pM(e)||dM(e))&&null==s&&(s=e,o=s.children.map((e=>e.name)).filter((e=>a.has(e)))),a.add(e.name),null==n[e.name]&&-1===l.indexOf(e.name)&&-1===c.indexOf(e.name)&&(0!==e.inputs.length?e.inputs.forEach((e=>{u.has(e.name)||(u.add(e.name),p.push(e))})):i.push(e.name))}return{inputs:e,outputs:t,usedNodes:a,missingInputs:i,dynamicNode:s,syncInputs:o}}const oM=["Switch","Merge","Enter","Exit","NextIteration","StatelessIf","StatelessWhile","if","While"],uM=["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"],lM=["HashTable","HashTableV2","LookupTableImport","LookupTableImportV2","LookupTableFind","LookupTableFindV2","LookupTableSize","LookupTableSizeV2"];function cM(e){return oM.indexOf(e.op)>=0}function pM(e){return uM.indexOf(e.op)>=0}function dM(e){return lM.indexOf(e.op)>=0}class hM{constructor(e,t){this.graph=e,this.parent=t,this.compiledMap=new Map,this._weightMap={},this.SEPERATOR=",",this._functions={},this._functionExecutorMap={},this.intermediateTensors={},this.keepTensorForDebug=!1,this._outputs=e.outputs,this._inputs=e.inputs,this._initNodes=e.initNodes,this._signature=e.signature,this._functions=e.functions,null!=e.functions&&Object.keys(e.functions).forEach((t=>{this._functionExecutorMap[t]=new hM(e.functions[t],this)}))}get weightIds(){return this.parent?this.parent.weightIds:this._weightIds}get functionExecutorMap(){return this.parent?this.parent.functionExecutorMap:this._functionExecutorMap}get weightMap(){return this.parent?this.parent.weightMap:this._weightMap}set weightMap(e){const t=Object.keys(e).map((t=>e[t].map((e=>e.id))));this._weightIds=[].concat(...t),this._weightMap=e}set resourceManager(e){this._resourceManager=e}get inputs(){return this._inputs.map((e=>({name:e.name,shape:e.attrParams.shape?e.attrParams.shape.value:void 0,dtype:e.attrParams.dtype?e.attrParams.dtype.value:void 0})))}get outputs(){return this._outputs.map((e=>({name:e.name,shape:e.attrParams.shape?e.attrParams.shape.value:void 0,dtype:e.attrParams.dtype?e.attrParams.dtype.value:void 0})))}get inputNodes(){return this._inputs.map((e=>e.signatureKey||e.name))}get outputNodes(){return this._outputs.map((e=>{const t=e.signatureKey||e.name;return e.defaultOutput?`${t}:${e.defaultOutput}`:t}))}get functions(){return Object.keys(this._functions).reduce(((e,t)=>(e[t]=this._functions[t].signature,e)),{})}getCompilationKey(e,t){const n=e.map((e=>e.name)).sort(),r=t.map((e=>e.name)).sort();return n.join(this.SEPERATOR)+"--"+r.join(this.SEPERATOR)}compile(e,t){const n=sM(e,t,this.weightMap,this._initNodes),{missingInputs:r,dynamicNode:a,syncInputs:i}=n;if(null!=a)throw new Error(`This execution contains the node '${a.name}', which has the dynamic op '${a.op}'. Please use model.executeAsync() instead. Alternatively, to avoid the dynamic ops, specify the inputs [${i}]`);if(r.length>0){const n=t.map((e=>e.name)),a=Object.keys(e);throw new Error(`Cannot compute the outputs [${n}] from the provided inputs [${a}]. Missing the following inputs: [${r}]`)}return function(e,t,n){const{usedNodes:r,inputs:a}=n,i=[],s=Object.keys(a).map((e=>pN(e)[0])).map((t=>e.nodes[t])),o=e.initNodes;s.forEach((e=>{r.has(e.name)&&i.push(e)})),e.weights.forEach((e=>{r.has(e.name)&&i.push(e)})),null!=o&&o.forEach((e=>{r.has(e.name)&&i.push(e)}));const u=new Set,l=[];for(;i.length>0;){const e=i.pop();u.add(e.name),t[e.name]||l.push(e),e.children.forEach((e=>{!u.has(e.name)&&r.has(e.name)&&e.inputs.every((e=>u.has(e.name)))&&i.push(e)}))}return l}(this.graph,this.weightMap,n)}execute(e,t){e=this.mapInputs(e);const n=Object.keys(e).sort();this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t);const r=n.map((e=>this.graph.nodes[pN(e)[0]])),a=t.map((e=>pN(e)[0]));let i=a.map((e=>this.graph.nodes[e]));this.resetIntermediateTensors(),0===i.length&&(i=this._outputs);const s=this.getCompilationKey(r,i);let o=this.compiledMap.get(s);null==o&&(o=this.compile(e,i),this.compiledMap.set(s,o));const u={},l={};return ho((()=>{const n=new iM(this.weightMap,u,l,this.functionExecutorMap),r=Object.assign({},this.weightMap);Object.keys(e).forEach((t=>{const[n,a]=pN(t),i=[];i[a]=e[t],r[n]=i}));const i=this.getFrozenTensorIds(r),s={};for(let e=0;euN(e,r,n)))}))}getFrozenTensorIds(e){const t=[].concat.apply([],Object.keys(e).map((t=>e[t])).map((e=>e.map((e=>e.id)))));return new Set(t)}checkTensorForDisposal(e,t,n,r,a,i,s){"control"!==t.category&&-1===i.indexOf(e)&&(n[e].forEach((e=>{null!=e&&(s[e.id]=(s[e.id]||0)+t.children.length)})),t.inputs.forEach((e=>{if("control"!==e.category){const i=function(e,t,n){return t[cN(e,n.currentContextId)]}(e.name,n,r);null!=i&&i.forEach((e=>{if(e&&!e.kept&&!a.has(e.id)){const n=s[e.id];if(1===n){if(this.keepTensorForDebug){const[n,a]=lN(t.name,r);this.intermediateTensors[n]||(this.intermediateTensors[n]=[]),this.intermediateTensors[n][a]=e}else e.dispose();delete s[e.id]}else null!=n&&s[e.id]--}}))}})))}async executeAsync(e,t){return this._executeAsync(e,t)}disposeIntermediateTensors(){this.intermediateTensors&&(Object.keys(this.intermediateTensors).forEach((e=>this.intermediateTensors[e].forEach((e=>e.dispose())))),this.disposeTensorsMap())}disposeTensorsMap(){this.tensorsMap&&Object.keys(this.tensorsMap).forEach((e=>{this.tensorsMap[e].forEach((e=>{!e||e.kept||e.isDisposed||this.keepIds.has(e.id)||e.dispose()}))}))}getIntermediateTensors(){return this.tensorsMap}resetIntermediateTensors(){for(const e in this.intermediateTensors)this.intermediateTensors[e].forEach((e=>e.dispose())),delete this.intermediateTensors[e]}async _executeAsync(e,t,n=!1,r={},a={}){n||(e=this.mapInputs(e),this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t));try{this.keepTensorForDebug=Ge().getBool("KEEP_INTERMEDIATE_TENSORS")}catch(e){console.warn(e.message)}this.resetIntermediateTensors();const i=new iM(this.weightMap,r,a,this.functionExecutorMap);this.tensorsMap=await this.executeWithControlFlow(e,i,t,n);const s=t.map((e=>uN(e,this.tensorsMap,i))),o=s.map((e=>e.id)),u=Object.keys(e).map((t=>e[t].id));return this.keepIds=new Set([...o,...u,...this.weightIds]),this.keepTensorForDebug||this.disposeTensorsMap(),null==this.parent&&i.dispose(this.keepIds),s}async executeFunctionAsync(e,t,n){const r=e.reduce(((e,t,n)=>(e[this.inputs[n].name]=t,e)),{});return this._executeAsync(r,this.outputNodes,!0,t,n)}async executeWithControlFlow(e,t,n,r){const a=Object.keys(e),i=a.map((e=>this.graph.nodes[pN(e)[0]])),s=n.map((e=>pN(e)[0]));let o=s.map((e=>this.graph.nodes[e]));0===o.length&&(o=this._outputs);const{usedNodes:u,missingInputs:l,dynamicNode:c,syncInputs:p}=sM(e,o,this.weightMap,this._initNodes),d=[...i,...this.graph.weights,...this._initNodes||[]].map((e=>({node:e,contexts:t.currentContext}))),h=Object.assign({},this.weightMap);Object.keys(e).forEach((t=>{const[n,r]=pN(t),a=[];a[r]=e[t],h[n]=a}));const f={},m=this.getFrozenTensorIds(h),g={};for(;d.length>0;){const e=this.processStack(i,d,t,h,g,m,s,f,u);await Promise.all(e)}null!=c||r||console.warn("This model execution did not contain any nodes with control flow or dynamic output shapes. You can use model.execute() instead.");const y=o.filter((e=>!cM(e)&&!uN(e.name,h,t))).map((e=>e.name));if(y.length>0){let e="";throw null!=c&&(e=`Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs [${p}]`),new Error(`Cannot compute the outputs [${y}] from the provided inputs [${a}]. Consider providing the following inputs: [${l}]. ${e}`)}return h}processStack(e,t,n,r,a,i,s,o,u){const l=[];for(;t.length>0;){const e=t.pop();n.currentContext=e.contexts;let c="";if("Enter"===e.node.op&&oN("isConstant",e.node,r,n)&&([c]=lN(e.node.name,n)),null==r[e.node.name]){const p=aM(e.node,r,n,this._resourceManager);c||([c]=lN(e.node.name,n));const d=n.currentContext;qe(p)?l.push(p.then((l=>(r[c]=l,n.currentContext=d,this.checkTensorForDisposal(c,e.node,r,n,i,s,o),this.processChildNodes(e.node,t,n,r,a,u),l)))):(r[c]=p,this.checkTensorForDisposal(c,e.node,r,n,i,s,o),this.processChildNodes(e.node,t,n,r,a,u))}else this.processChildNodes(e.node,t,n,r,a,u)}return l}processChildNodes(e,t,n,r,a,i){e.children.forEach((e=>{const[s]=lN(e.name,n);!a[s]&&i.has(e.name)&&("Merge"===e.op?e.inputNames.some((e=>!!uN(e,r,n)))&&(a[s]=!0,t.push({contexts:n.currentContext,node:e})):e.inputNames.every((e=>!!uN(e,r,n)))&&(a[s]=!0,t.push({contexts:n.currentContext,node:e})))}))}dispose(){Object.keys(this.weightMap).forEach((e=>this.weightMap[e].forEach((e=>e.dispose()))))}checkInputShapeAndType(e){Object.keys(e).forEach((t=>{const n=e[t],[r]=pN(t),a=this.graph.nodes[r];if(a.attrParams.shape&&a.attrParams.shape.value){const e=a.attrParams.shape.value,t=e.length===n.shape.length&&n.shape.every(((t,n)=>-1===e[n]||e[n]===t));se(t,(()=>`The shape of dict['${a.name}'] provided in model.execute(dict) must be [${e}], but was [${n.shape}]`))}a.attrParams.dtype&&a.attrParams.dtype.value&&se(n.dtype===a.attrParams.dtype.value,(()=>`The dtype of dict['${a.name}'] provided in model.execute(dict) must be ${a.attrParams.dtype.value}, but was ${n.dtype}`))}))}mapInputs(e){const t={};for(const n in e)null!=this._signature&&null!=this._signature.inputs&&null!=this._signature.inputs[n]?t[this._signature.inputs[n].name]=e[n]:t[n]=e[n];return t}checkInputs(e){const t=Object.keys(e).filter((e=>{const[t]=pN(e);return null==this.graph.nodes[t]}));if(t.length>0)throw new Error(`The dict provided in model.execute(dict) has keys: [${t}] that are not part of graph`)}mapOutputs(e){return e.map((e=>null!=this._signature&&null!=this._signature.outputs&&null!=this._signature.outputs[e]?this._signature.outputs[e].name:e),{})}checkOutputs(e){e.forEach((e=>{const[t]=pN(e);if(!this.graph.nodes[t])throw new Error(`The output '${e}' is not found in the graph`)}))}}class fM{constructor(e={},t={}){this.hashTableNameToHandle=e,this.hashTableMap=t}addHashTable(e,t){this.hashTableNameToHandle[e]=t.handle,this.hashTableMap[t.id]=t}getHashTableHandleByName(e){return this.hashTableNameToHandle[e]}getHashTableById(e){return this.hashTableMap[e]}dispose(){for(const e in this.hashTableMap)this.hashTableMap[e].clearAndClose(),delete this.hashTableMap[e];for(const e in this.hashTableNameToHandle)this.hashTableNameToHandle[e].dispose(),delete this.hashTableNameToHandle[e]}}class mM{constructor(e,t={},n=i){this.modelUrl=e,this.loadOptions=t,this.version="n/a",this.io=n,null==t&&(this.loadOptions={}),this.resourceManager=new fM}get modelVersion(){return this.version}get inputNodes(){return this.executor.inputNodes}get outputNodes(){return this.executor.outputNodes}get inputs(){return this.executor.inputs}get outputs(){return this.executor.outputs}get weights(){return this.executor.weightMap}get metadata(){return this.artifacts.userDefinedMetadata}get modelSignature(){return this.signature}get modelStructuredOutputKeys(){return this.structuredOutputKeys}findIOHandler(){const e=this.modelUrl;if(null!=e.load)this.handler=e;else if(null!=this.loadOptions.requestInit)this.handler=this.io.browserHTTPRequest(e,this.loadOptions);else{const t=this.io.getLoadHandlers(e,this.loadOptions);if(0===t.length)t.push(this.io.browserHTTPRequest(e,this.loadOptions));else if(t.length>1)throw new Error(`Found more than one (${t.length}) load handlers for URL '${[e]}'`);this.handler=t[0]}}load(){if(this.findIOHandler(),null==this.handler.load)throw new Error("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");const e=this.handler.load();return qe(e)?e.then((e=>this.loadSync(e))):this.loadSync(e)}loadSync(e){this.artifacts=e;const t=this.artifacts.modelTopology;let n=this.artifacts.signature;if(null!=this.artifacts.userDefinedMetadata){const e=this.artifacts.userDefinedMetadata;null!=e.signature&&(n=e.signature),null!=e.structuredOutputKeys&&(this.structuredOutputKeys=e.structuredOutputKeys)}this.signature=n,this.version=`${t.versions.producer}.${t.versions.minConsumer}`;const r=this.io.decodeWeights(this.artifacts.weightData,this.artifacts.weightSpecs);if(this.executor=new hM(LN.Instance.transformGraph(t,this.signature)),this.executor.weightMap=this.convertTensorMapToTensorsMap(r),this.executor.resourceManager=this.resourceManager,null!=e.modelInitializer&&null!=e.modelInitializer.node){const t=LN.Instance.transformGraph(e.modelInitializer);this.initializer=new hM(t),this.initializer.weightMap=this.executor.weightMap,this.initializer.resourceManager=this.resourceManager,this.initializer.executeAsync({},[])}return!0}async save(e,t){if("string"==typeof e){const t=this.io.getSaveHandlers(e);if(0===t.length)throw new Error(`Cannot find any save handlers for URL '${e}'`);if(t.length>1)throw new Error(`Found more than one (${t.length}) save handlers for URL '${e}'`);e=t[0]}if(null==e.save)throw new Error("GraphModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");return e.save(this.artifacts)}predict(e,t){const n=this.execute(e,this.outputNodes);if(this.structuredOutputKeys){const e={};return(n instanceof ti?[n]:n).forEach(((t,n)=>e[this.structuredOutputKeys[n]]=t)),e}return n}normalizeInputs(e){if(!(e instanceof ti||Array.isArray(e)))return e;if((e=Array.isArray(e)?e:[e]).length!==this.inputNodes.length)throw new Error(`Input tensor count mismatch,the graph model has ${this.inputNodes.length} placeholders, while there are ${e.length} input tensors.`);return this.inputNodes.reduce(((t,n,r)=>(t[n]=e[r],t)),{})}normalizeOutputs(e){return e=e||this.outputNodes,Array.isArray(e)?e:[e]}execute(e,t){e=this.normalizeInputs(e),t=this.normalizeOutputs(t);const n=this.executor.execute(e,t);return n.length>1?n:n[0]}async executeAsync(e,t){e=this.normalizeInputs(e),t=this.normalizeOutputs(t);const n=await this.executor.executeAsync(e,t);return n.length>1?n:n[0]}getIntermediateTensors(){return this.executor.getIntermediateTensors()}disposeIntermediateTensors(){this.executor.disposeIntermediateTensors()}convertTensorMapToTensorsMap(e){return Object.keys(e).reduce(((t,n)=>(t[n]=[e[n]],t)),{})}dispose(){this.executor.dispose(),this.initializer&&this.initializer.dispose(),this.resourceManager.dispose()}}async function gM(e,t={},n=i){if(null==e)throw new Error("modelUrl in loadGraphModel() cannot be null. Please provide a url or an IOHandler that loads the model");null==t&&(t={}),t.fromTFHub&&"string"==typeof e&&(e=function(e){return e.endsWith("/")||(e+="/"),`${e}model.json?tfjs-format=file`}(e));const r=new mM(e,t,n);return await r.load(),r}function yM(e){if(null==e)throw new Error("modelUrl in loadGraphModelSync() cannot be null. Please provide a url or an IOHandler that loads the model");if(!e.load)throw new Error(`modelUrl IO Handler ${e} has no load function`);const t=new mM(e);return t.load(),t}const bM="3.19.0";function vM(e,t,n=new Map,r=new Set){if(null==e)return null;if("function"==typeof Blob&&e instanceof Blob)return e.slice();if(r.has(e))throw new Error("Circular references are not supported.");if(n.has(e))return n.get(e);const a=t(e);if(a.recurse&&null!==a.value)throw new Error("A deep map function may not return both a value and recurse=true.");if(a.recurse){if(NM(e)){const a=Array.isArray(e)?[]:{};r.add(e);for(const i in e){const s=vM(e[i],t,n,r);a[i]=s}return r.delete(e),e.__proto__&&(a.__proto__=e.__proto__),a}throw new Error(`Can't recurse into non-iterable type: ${e}`)}return n.set(e,a.value),a.value}function xM(e,t=wM){return _M(e,t)}function _M(e,t,n=new Set){const r=e[0];if(n.has(r))throw new Error("Circular references are not supported.");const a=t(e);if(a.recurse&&null!==a.value)throw new Error("A deep zip function may not return both a value and recurse=true.");if(a.recurse){if(NM(r)){const a=Array.isArray(r)?[]:{};n.add(r);for(const i in r){const r=_M(e.map((e=>e[i])),t,n);a[i]=r}return n.delete(r),a}throw new Error(`Can't recurse into non-iterable type: ${r}`)}return a.value}function wM(e){return null===e?null:NM(e[0])?{value:null,recurse:!0}:{value:e,recurse:!1}}async function DM(e,t){const n=new Map;vM(e,t,n);for(const e of Array.from(n.keys())){const t=n.get(e);if(qe(t)){const r=await t;n.set(e,r)}}return vM(e,t,n)}function NM(e){let t=!1;if(Ge().get("IS_BROWSER"))t=e instanceof TextDecoder;else{const{StringDecoder:r}=n(4977);t=e instanceof r}return null!=e&&!ArrayBuffer.isView(e)&&(Array.isArray(e)||"object"==typeof e&&!(e instanceof ti)&&!(e instanceof Promise)&&!t)}function MM(e){return e instanceof ti?{value:e.clone(),recurse:!1}:NM(e)?{value:null,recurse:!0}:{value:e,recurse:!1}}class SM{constructor(e){if(this.capacity=e,this.begin=0,this.end=0,null==e)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(e<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(e),this.doubledCapacity=2*e}wrap(e){for(;e<0;)e+=this.doubledCapacity;return e%this.doubledCapacity}get(e){if(e<0)throw new RangeError("Can't get item at a negative index.");return this.data[e%this.capacity]}set(e,t){if(e<0)throw new RangeError("Can't set item at a negative index.");this.data[e%this.capacity]=t}length(){let e=this.end-this.begin;return e<0&&(e=this.doubledCapacity+e),e}isFull(){return this.length()===this.capacity}isEmpty(){return 0===this.length()}push(e){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,e),this.end=this.wrap(this.end+1)}pushAll(e){for(const t of e)this.push(t)}pop(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);const e=this.get(this.end);return this.set(this.end,void 0),e}unshift(e){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,e)}shift(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");const e=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),e}shuffleExcise(e){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");const t=this.wrap(this.begin+e),n=this.get(t);return this.set(t,this.pop()),n}}class kM extends SM{constructor(){super(kM.INITIAL_CAPACITY)}isFull(){return!1}push(e){super.isFull()&&this.expand(),super.push(e)}unshift(e){super.isFull()&&this.expand(),super.unshift(e)}expand(){const e=2*this.capacity,t=new Array(e),n=this.length();for(let e=0;e!0===e))}rowMajorBatch(e,t=!0){return new OM(this,e,t)}columnMajorBatch(e,t=!0,n=wM){return this.rowMajorBatch(e,t).map((e=>xM(e,n)))}concatenate(e,t){return new jM(TM([this,e]),t)}take(e){return e<0||null==e?this:new $M(this,e)}skip(e){return e<0||null==e?this:new FM(this,e)}prefetch(e){return new WM(this,e)}shuffle(e,t){return new VM(this,e,t)}serial(){return new LM(this)}}class AM extends EM{constructor(e){super(),this.items=e,this.trav=0}summary(){return`Array of ${this.items.length} items`}async next(){if(this.trav>=this.items.length)return{value:null,done:!0};const e=this.items[this.trav];return this.trav++,{value:(t=e,function(e,t){return vM(e,t)}(t,MM)),done:!1};var t}}class IM extends EM{constructor(e){super(),this.nextFn=e}summary(){return"Function call"}async next(){try{return this.nextFn()}catch(e){throw e.message=`Error thrown while iterating through a dataset: ${e.message}`,e}}}class LM extends EM{constructor(e){super(),this.upstream=e,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Serial`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){return this.upstream.next()}}class FM extends EM{constructor(e,t){super(),this.upstream=e,this.maxCount=t,this.count=0,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Skip`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;this.count++ Take`}async next(){return this.count++>=this.maxCount?{value:null,done:!0}:this.upstream.next()}}class OM extends EM{constructor(e,t,n=!0){super(),this.upstream=e,this.batchSize=t,this.enableSmallLastBatch=n,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> RowMajorBatch`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){const e=[];for(;e.length0?{value:e,done:!1}:{value:null,done:!0};e.push(t.value)}return{value:e,done:!1}}}class RM extends EM{constructor(e,t){super(),this.upstream=e,this.predicate=t,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Filter`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;;){const e=await this.upstream.next();if(e.done||this.predicate(e.value))return e;fo(e.value)}}}class YM extends EM{constructor(e,t){super(),this.upstream=e,this.transform=t}summary(){return`${this.upstream.summary()} -> Map`}async next(){const e=await this.upstream.next();if(e.done)return{value:null,done:!0};const t=mi(e.value),n=this.transform(e.value),r=mi(n);for(const e of t)fi(e,r)||e.dispose();return{value:n,done:!1}}}class BM extends EM{constructor(e,t){super(),this.upstream=e,this.handler=t,this.count=0,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> handleErrors`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;;)try{return await this.upstream.next()}catch(e){if(!this.handler(e))return{value:null,done:!0}}}}class zM extends EM{constructor(e,t){super(),this.upstream=e,this.transform=t}summary(){return`${this.upstream.summary()} -> AsyncMap`}async next(){const e=await this.upstream.next();if(e.done)return{value:null,done:!0};const t=mi(e.value),n=await this.transform(e.value),r=mi(n);for(const e of t)fi(e,r)||e.dispose();return{value:n,done:!1}}}class PM extends EM{constructor(){super(),this.outputQueue=new kM,this.lastRead=Promise.resolve({value:null,done:!1})}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;0===this.outputQueue.length();)if(!await this.pump())return{value:null,done:!0};return{value:this.outputQueue.shift(),done:!1}}}class HM extends PM{constructor(e,t){super(),this.upstream=e,this.transform=t}summary(){return`${this.upstream.summary()} -> Flatmap`}async pump(){const e=await this.upstream.next();if(e.done)return!1;const t=mi(e.value),n=this.transform(e.value),r=mi(n);this.outputQueue.pushAll(n);for(const e of t)fi(e,r)||e.dispose();return!0}}class jM extends EM{constructor(e,t){super(),this.baseErrorHandler=t,this.lastRead=null,this.iterator=null,this.moreIterators=e}summary(){return"TODO: fill in upstream of chained summaries -> Chained"}async next(){return this.lastRead=this.readFromChain(this.lastRead),this.lastRead}async readFromChain(e){if(await e,null==this.iterator){const e=await this.moreIterators.next();if(e.done)return{value:null,done:!0};this.iterator=e.value,null!=this.baseErrorHandler&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler))}const t=await this.iterator.next();return t.done?(this.iterator=null,this.readFromChain(e)):t}}var UM;!function(e){e[e.FAIL=0]="FAIL",e[e.SHORTEST=1]="SHORTEST",e[e.LONGEST=2]="LONGEST"}(UM||(UM={}));class qM extends EM{constructor(e,t=UM.FAIL){super(),this.iterators=e,this.mismatchMode=t,this.count=0,this.currentPromise=null}summary(){return"{TODO: fill in upstream of zip summaries} -> Zip"}async nextState(e){await e;let t=0,n=0;const r=await DM(this.iterators,(function(e){return e instanceof EM?{value:e.next().then((e=>(t++,e.done&&n++,e.value))),recurse:!1}:{value:null,recurse:!0}}));if(t===n)return{value:null,done:!0};if(n>0)switch(this.mismatchMode){case UM.FAIL:throw new Error(`Zipped streams should have the same length. Mismatched at element ${this.count}.`);case UM.SHORTEST:return{value:null,done:!0};case UM.LONGEST:}return this.count++,{value:r,done:!1}}async next(){return this.currentPromise=this.nextState(this.currentPromise),this.currentPromise}}class WM extends EM{constructor(e,t){super(),this.upstream=e,this.bufferSize=t,this.buffer=new SM(t)}summary(){return`${this.upstream.summary()} -> Prefetch`}refill(){for(;!this.buffer.isFull();){const e=this.upstream.next();this.buffer.push(e)}}next(){return this.refill(),this.buffer.shift()}}class VM extends WM{constructor(e,t,n){super(e,t),this.upstream=e,this.windowSize=t,this.upstreamExhausted=!1,this.random=Ep.alea(n||Ba().toString()),this.lastRead=Promise.resolve({value:null,done:!1})}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}randomInt(e){return Math.floor(this.random()*e)}chooseIndex(){return this.randomInt(this.buffer.length())}async serialNext(){for(this.upstreamExhausted||this.refill();!this.buffer.isEmpty();){const e=this.chooseIndex(),t=await this.buffer.shuffleExcise(e);if(!t.done)return this.refill(),t;this.upstreamExhausted=!0}return{value:null,done:!0}}}class GM{constructor(){this.size=null}batch(e,t=!0){const n=this;let r;return se(e>0,(()=>`batchSize needs to be positive, but it is\n ${e}`)),r=this.size===1/0||null==this.size?this.size:t?Math.ceil(this.size/e):Math.floor(this.size/e),KM((async()=>(await n.iterator()).columnMajorBatch(e,t,ZM)),r)}concatenate(e){const t=this;let n;return n=this.size===1/0||e.size===1/0?1/0:null!=this.size&&null!=e.size?this.size+e.size:null,KM((async()=>(await t.iterator()).concatenate(await e.iterator())),n)}filter(e){const t=this;let n;return n=this.size===1/0?1/0:null,KM((async()=>(await t.iterator()).filter((t=>ho((()=>e(t)))))),n)}async forEachAsync(e){return(await this.iterator()).forEachAsync(e)}map(e){const t=this;return KM((async()=>(await t.iterator()).map((t=>ho((()=>e(t)))))),this.size)}mapAsync(e){const t=this;return KM((async()=>(await t.iterator()).mapAsync(e)),this.size)}prefetch(e){if(null==e)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");const t=this;return KM((async()=>(await t.iterator()).prefetch(e)),this.size)}repeat(e){const t=this;let n;return n=null!=this.size&&e>0?this.size*e:0===e?0:null!=this.size&&(void 0===e||e<0)?1/0:null,KM((async()=>{return n=CM((async()=>({value:await t.iterator(),done:!1}))).take(e),new jM(n,r);var n,r}),n)}skip(e){const t=this;let n;return n=null!=this.size&&e>=0&&this.size>=e?this.size-e:null!=this.size&&(this.size(await t.iterator()).skip(e)),n)}shuffle(e,t,n=!0){if(null==e||e<0)throw null==this.size?new RangeError("`Dataset.shuffle()` requires bufferSize to be specified."):new RangeError(`\`Dataset.shuffle()\` requires bufferSize to be specified. If your data fits in main memory (for regular JS objects), and/or GPU memory (for \`tf.Tensor\`s), consider setting bufferSize to the dataset size (${this.size} elements)`);const r=this,a=Ep.alea(t||Ba().toString());return KM((async()=>{let t=a.int32();return n&&(t+=a.int32()),(await r.iterator()).shuffle(e,t.toString())}),this.size)}take(e){const t=this;let n;return n=null!=this.size&&this.size>e?e:null!=this.size&&this.size<=e?this.size:null,KM((async()=>(await t.iterator()).take(e)),n)}async toArray(){if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArray()}async toArrayForTest(){if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArrayForTest()}}function KM(e,t=null){return new class extends GM{constructor(){super(...arguments),this.size=t}async iterator(){return e()}}}function JM(e){return KM((async()=>TM(e)),e.length)}function XM(e){if(!NM(e))throw new Error("The argument to zip() must be an object or array.");let t;if(Array.isArray(e))for(let n=0;nfunction(e,t=UM.FAIL){return new qM(e,t)}(await DM(e,(e=>{if(e instanceof GM)return{value:e.iterator(),recurse:!1};if(NM(e))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")})),UM.SHORTEST)),t)}function ZM(e){if(null===e)return null;return null==(t=e[0])||null===(n=t)||"object"!=typeof n&&"function"!=typeof n||Array.isArray(t)||"object"==typeof t&&t instanceof ti||ke(t)?{value:function(e){if(0===e.length)throw new Error("Can't make a batch of zero elements.");return e[0]instanceof ti?hd(e):Ri(e)}(e),recurse:!1}:{value:null,recurse:!0};var t,n}GM.MAX_BUFFER_SIZE=1e4;class QM extends GM{constructor(e){super(),this.input=e}async iterator(){const e=(await this.input.iterator()).decodeUTF8().split("\n").map((e=>(e.endsWith("\r")&&(e=e.slice(0,-1)),e)));return e}}const eS='"',tS=Symbol("out"),nS=Symbol("field"),rS=Symbol("quote"),aS=Symbol("quoteafterquote"),iS=Symbol("quoteinquote");class sS extends GM{constructor(e,t){super(),this.input=e,this.hasHeader=!0,this.fullColumnNames=null,this.columnNamesValidated=!1,this.columnConfigs=null,this.configuredColumnsOnly=!1,this.delimiter=",",this.delimWhitespace=!1,this.base=new QM(e),t||(t={}),this.hasHeader=!1!==t.hasHeader,this.fullColumnNames=t.columnNames,this.columnConfigs=t.columnConfigs,this.configuredColumnsOnly=t.configuredColumnsOnly,t.delimWhitespace?(se(null==t.delimiter,(()=>"Delimiter should not be provided when delimWhitespace is true.")),this.delimWhitespace=!0,this.delimiter=" "):this.delimiter=t.delimiter?t.delimiter:","}async columnNames(){return this.columnNamesValidated||await this.setColumnNames(),this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames}async setColumnNames(){const e=await this.maybeReadHeaderLine();if(!this.fullColumnNames&&!e)throw new Error("Column names must be provided if there is no header line.");this.fullColumnNames&&e&&se(e.length===this.fullColumnNames.length,(()=>"The length of provided columnNames ("+this.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+e.length.toString()+").")),this.fullColumnNames||(this.fullColumnNames=e);const t=this.fullColumnNames.reduce(((e,t)=>(e[t]=e[t]+1||1,e)),{}),n=Object.keys(t).filter((e=>t[e]>1));if(se(0===n.length,(()=>"Duplicate column names found: "+n.toString())),this.columnConfigs)for(const e of Object.keys(this.columnConfigs))if(-1===this.fullColumnNames.indexOf(e))throw new Error('The key "'+e+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").");this.columnNamesValidated=!0}async maybeReadHeaderLine(){if(this.hasHeader){const e=await this.base.iterator(),t=await e.next();if(t.done)throw new Error("No data was found for CSV parsing.");const n=t.value;return this.parseRow(n,!1)}return null}async iterator(){this.columnNamesValidated||await this.setColumnNames();let e=await this.base.iterator();return this.hasHeader&&(e=e.skip(1)),e.map((e=>this.makeDataElement(e)))}makeDataElement(e){const t=this.parseRow(e),n={},r={};for(let a=0;a14||!Number.isInteger(t))throw new Error(`Invalid fftSize: it must be a power of 2 between 2 to 4 and 2 to 14, but got ${this.fftSize}`);if(this.numFrames=e.numFramesPerSpectrogram||43,this.sampleRateHz=e.sampleRateHz,this.columnTruncateLength=e.columnTruncateLength||this.fftSize,this.audioTrackConstraints=e.audioTrackConstraints,this.smoothingTimeConstant=e.smoothingTimeConstant||0,this.includeSpectrogram=!1!==e.includeSpectrogram,this.includeWaveform=!0===e.includeWaveform,!this.includeSpectrogram&&!this.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.")}summary(){return"microphone"}static async create(e={}){if(!Ge().get("IS_BROWSER"))throw new Error("microphone API is only supported in browser environment.");const t=new oS(e);return await t.start(),t}async start(){try{this.stream=await navigator.mediaDevices.getUserMedia({audio:null==this.audioTrackConstraints||this.audioTrackConstraints,video:!1})}catch(e){throw new Error(`Error thrown while initializing video stream: ${e.message}`)}if(!this.stream)throw new Error("Could not obtain audio from microphone.");const e=window.AudioContext||window.webkitAudioContext;if(this.audioContext=new e,this.sampleRateHz){if(this.audioContext.sampleRate!==this.sampleRateHz)throw new Error(`Mismatch in sampling rate: Expected: ${this.sampleRateHz}; Actual: ${this.audioContext.sampleRate}`)}else this.sampleRateHz=this.audioContext.sampleRate;const t=this.audioContext.createMediaStreamSource(this.stream);this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=2*this.fftSize,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,t.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize)}async next(){if(this.isClosed)return{value:null,done:!0};let e,t;const n=await this.getAudioData();if(this.includeSpectrogram){const t=this.flattenQueue(n.freqDataQueue);e=this.getTensorFromAudioDataArray(t,[this.numFrames,this.columnTruncateLength,1])}if(this.includeWaveform){const e=this.flattenQueue(n.timeDataQueue);t=this.getTensorFromAudioDataArray(e,[this.numFrames*this.fftSize,1])}return{value:{spectrogram:e,waveform:t},done:!1}}async capture(){return(await this.next()).value}async getAudioData(){const e=[],t=[];let n=0;return new Promise((r=>{const a=setInterval((()=>{this.includeSpectrogram&&(this.analyser.getFloatFrequencyData(this.freqData),this.freqData[0]===-1/0&&r({freqDataQueue:e,timeDataQueue:t}),e.push(this.freqData.slice(0,this.columnTruncateLength))),this.includeWaveform&&(this.analyser.getFloatTimeDomainData(this.timeData),t.push(this.timeData.slice())),++n===this.numFrames&&(clearInterval(a),r({freqDataQueue:e,timeDataQueue:t}))}),this.fftSize/this.sampleRateHz*1e3)}))}stop(){this.isClosed||(this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),null!=this.stream&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop())}toArray(){throw new Error("Can not convert infinite audio stream to array.")}getSampleRate(){return this.sampleRateHz}flattenQueue(e){const t=e[0].length,n=new Float32Array(e.length*t);return e.forEach(((e,r)=>n.set(e,r*t))),n}getTensorFromAudioDataArray(e,t){const n=new Float32Array(ce(t));return n.set(e,n.length-e.length),Ri(n,t)}}class uS extends EM{constructor(e,t){if(super(),this.webcamVideoElement=e,this.webcamConfig=t,this.isClosed=!0,this.resize=!1,this.needToResize())if(this.resize=!0,this.cropSize=[this.webcamConfig.resizeHeight,this.webcamConfig.resizeWidth],this.cropBoxInd=yd([0],"int32"),this.webcamConfig.centerCrop){const e=1*this.webcamConfig.resizeWidth/this.webcamVideoElement.width,t=1*this.webcamConfig.resizeHeight/this.webcamVideoElement.height,n=(1-e)/2,r=(1-t)/2,a=n+e,i=t+r;this.cropBox=bd([r,n,i,a],[1,4])}else this.cropBox=bd([0,0,1,1],[1,4])}summary(){return"webcam"}static async create(e,t={}){if(!Ge().get("IS_BROWSER"))throw new Error("tf.data.webcam is only supported in browser environment.");if(!e){if(e=document.createElement("video"),!t.resizeWidth||!t.resizeHeight)throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");e.width=t.resizeWidth,e.height=t.resizeHeight}const n=new uS(e,t);return await n.start(),n}async start(){this.webcamConfig.facingMode&&se("user"===this.webcamConfig.facingMode||"environment"===this.webcamConfig.facingMode,(()=>`Invalid webcam facing mode: ${this.webcamConfig.facingMode}. Please provide 'user' or 'environment'`));try{this.stream=await navigator.mediaDevices.getUserMedia({video:{deviceId:this.webcamConfig.deviceId,facingMode:this.webcamConfig.facingMode?this.webcamConfig.facingMode:"user",width:this.webcamVideoElement.width,height:this.webcamVideoElement.height}})}catch(e){throw e.message=`Error thrown while initializing video stream: ${e.message}`,e}if(!this.stream)throw new Error("Could not obtain video from webcam.");try{this.webcamVideoElement.srcObject=this.stream}catch(e){console.log(e),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,new Promise((e=>{this.webcamVideoElement.onloadedmetadata=()=>{e()}}))}async next(){if(this.isClosed)return{value:null,done:!0};let e;try{e=Bo(this.webcamVideoElement)}catch(e){throw new Error(`Error thrown converting video to pixels: ${JSON.stringify(e)}`)}if(!this.resize)return{value:e,done:!1};try{return{value:this.cropAndResizeFrame(e),done:!1}}catch(e){throw new Error(`Error thrown cropping the video: ${e.message}`)}finally{e.dispose()}}needToResize(){return!(!this.webcamConfig.resizeWidth||!this.webcamConfig.resizeHeight||this.webcamVideoElement.width===this.webcamConfig.resizeWidth&&this.webcamVideoElement.height===this.webcamConfig.resizeHeight)}cropAndResizeFrame(e){return ho((()=>{const t=Cc(Ls(e,"float32"),0);let n;n=Uh.cropAndResize(t,this.cropBox,this.cropBoxInd,this.cropSize,"bilinear");const r=n.shape;return Dl(n,r.slice(1))}))}async capture(){return(await this.next()).value}stop(){this.stream.getTracks().forEach((e=>e.stop()));try{this.webcamVideoElement.srcObject=null}catch(e){console.log(e),this.webcamVideoElement.src=null}this.isClosed=!0}toArray(){throw new Error("Can not convert infinite video stream to array.")}}class lS{}class cS extends EM{split(e){return new pS(this,e)}}class pS extends cS{constructor(e,t){super(),this.upstream=e,this.impl=new dS(e,t)}summary(){return this.impl.summary()}async next(){return this.impl.next()}}class dS extends PM{constructor(e,t){super(),this.upstream=e,this.separator=t,this.carryover=""}summary(){return`${this.upstream.summary()} -> Split('${this.separator}')`}async pump(){const e=await this.upstream.next();if(e.done)return""!==this.carryover&&(this.outputQueue.push(this.carryover),this.carryover="",!0);const t=e.value.split(this.separator);t[0]=this.carryover+t[0];for(const e of t.slice(0,-1))this.outputQueue.push(e);return this.carryover=t[t.length-1],!0}}class hS extends EM{decodeUTF8(){return new fS(this)}}class fS extends cS{constructor(e){super(),this.upstream=e,this.impl=new mS(e)}summary(){return this.impl.summary()}async next(){return this.impl.next()}}class mS extends PM{constructor(e){if(super(),this.upstream=e,Ge().get("IS_BROWSER"))this.decoder=new TextDecoder("utf-8");else{const{StringDecoder:e}=n(1601);this.decoder=new e("utf8")}}summary(){return`${this.upstream.summary()} -> Utf8`}async pump(){const e=await this.upstream.next();let t,n;return!e.done&&(t=e.value,n=Ge().get("IS_BROWSER")?this.decoder.decode(t,{stream:!0}):this.decoder.write(Buffer.from(t.buffer)),this.outputQueue.push(n),!0)}}class gS extends hS{constructor(e,t={}){super(),this.file=e,this.options=t,se(e instanceof Uint8Array||!!Ge().get("IS_BROWSER")&&(e instanceof File||e instanceof Blob),(()=>"FileChunkIterator only supports File, Blob and Uint8Array right now.")),this.offset=t.offset||0,this.chunkSize=t.chunkSize||1048576}summary(){return`FileChunks ${this.file}`}async next(){if(this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size))return{value:null,done:!0};const e=new Promise(((e,t)=>{const n=this.offset+this.chunkSize;if(this.file instanceof Uint8Array)e(new Uint8Array(this.file.slice(this.offset,n)));else{const r=new FileReader;r.onload=n=>{let a=r.result;if(a instanceof ArrayBuffer&&(a=new Uint8Array(a)),!(a instanceof Uint8Array))return t(new TypeError("FileReader returned unknown type."));e(a)},r.onabort=e=>t(new Error("Aborted")),r.onerror=e=>t(new Error(e.type));const a=this.file.slice(this.offset,n);r.readAsArrayBuffer(a)}this.offset=n}));return{value:await e,done:!1}}}function yS(e){return"string"==typeof e&&"file://"===e.slice(0,7)}class bS extends lS{constructor(e,t={}){super(),this.input=e,this.options=t}async iterator(){if(yS(this.input)&&Ge().get("IS_NODE")){const e=n(7792);this.input=e.readFileSync(this.input.slice(7))}return new gS(this.input,this.options)}}class vS extends lS{constructor(e,t={}){super(),this.url=e,this.fileOptions=t}async iterator(){return yS(this.url)?new bS(this.url,this.fileOptions).iterator():async function(e,t={},n){let r,a;var i;"string"==typeof e?r=e:(r=e.url,a={method:(i=e).method,headers:i.headers,body:i.body,mode:i.mode,credentials:i.credentials,cache:i.cache,redirect:i.redirect,referrer:i.referrer,integrity:i.integrity});const s=await(n||za)(r,a);if(s.ok){const e=new Uint8Array(await s.arrayBuffer());return new gS(e,t)}throw new Error(s.statusText)}(this.url,this.fileOptions)}}function xS(e,t={}){return new sS(new vS(e),t)}function _S(e){const t=CM(e);return KM((async()=>t))}function wS(e){return KM((async()=>{const t=await e();return CM((()=>t.next()))}))}async function DS(e,t){return uS.create(e,t)}async function NS(e){return oS.create(e)}const MS="3.19.0";function SS(e,t){Array.isArray(e)||(e=[e]),e.forEach((e=>{null!=e&&se("complex64"!==e.dtype,(()=>`${t} does not support complex64 tensors in the CPU backend.`))}))}const kS=Cd;class TS extends J{constructor(){super(),this.blockSize=48,this.firstUse=!0,this.data=new K(this,lo())}nextDataId(){return TS.nextDataId++}write(e,t,n){this.firstUse&&(this.firstUse=!1,Ge().get("IS_NODE")&&ca("\n============================\nHi, 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. \n============================"));const r={id:this.nextDataId()};return this.data.set(r,{values:e,dtype:n,refCount:1}),r}makeTensorInfo(e,t,n){let r;if("string"===t&&null!=n&&n.length>0&&Ee(n[0])){const a=n.map((e=>Pa(e)));r=this.write(a,e,t)}else r=this.write(n,e,t);return{dataId:r,shape:e,dtype:t}}refCount(e){return this.data.has(e)?this.data.get(e).refCount:0}incRef(e){this.data.get(e).refCount++}decRef(e){this.data.has(e)&&this.data.get(e).refCount--}move(e,t,n,r,a){this.data.set(e,{values:t,dtype:r,refCount:a})}numDataIds(){return this.data.numDataIds()}async read(e){return this.readSync(e)}readSync(e){const{dtype:t,complexTensorInfos:n}=this.data.get(e);return"complex64"===t?yf(this.readSync(n.real.dataId),this.readSync(n.imag.dataId)):this.data.get(e).values}bufferSync(e){const t=this.readSync(e.dataId);if("string"===e.dtype)try{const n=t.map((e=>Ha(e)));return Is(e.shape,e.dtype,n)}catch(e){throw new Error("Failed to decode encoded string bytes into utf-8")}return Is(e.shape,e.dtype,t)}makeOutput(e,t,n){return lo().makeTensorFromTensorInfo(this.makeTensorInfo(t,n,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:n}=this.data.get(e);null!=n&&(this.disposeData(n.real.dataId,!0),this.disposeData(n.imag.dataId,!0)),this.data.delete(e)}return!0}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}async time(e){const t=Ba();return e(),{kernelMs:Ba()-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){SS([e],"where");const t=this.readSync(e.dataId);return kS(e.shape,t)}dispose(){}floatPrecision(){return 32}epsilon(){return super.epsilon()}}function CS(e,t,n){return({inputs:r,attrs:a,backend:i})=>{const{x:s}=r;if(SS(s,e),"string"===s.dtype||"string"===n)throw new Error("unaryKernelFunc does not support string input/output");const o=i,u=o.data.get(s.dataId).values,l=ce(s.shape),c=n||s.dtype,p=De(c,l);for(let e=0;e{const{x:s}=r;if(SS(s,e),"string"===s.dtype||"string"===n)throw new Error("unaryKernelFunc does not support string input/output");const o=i,u=o.data.get(s.dataId).values,l=n||s.dtype,c=t(u,l,a);return o.makeTensorInfo(s.shape,l,c)}}TS.nextDataId=0,Do("cpu",(()=>new TS),1);const AS=CS(Jt,(e=>e>=0?e:Math.exp(e)-1)),IS={kernelName:Jt,backendName:"cpu",kernelFunc:AS};function LS(e){const{inputs:t,backend:n}=e,{x:r}=t;return n.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}const FS={kernelName:fn,backendName:"cpu",kernelFunc:LS};function $S(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{alpha:i}=r;SS([a],"leakyRelu");const s=ce(a.shape),o=n.data.get(a.dataId).values,u=we("float32",s);for(let e=0;e{const s=Lo(t,n),o=s.length,u=Oe(s),l=we(i,ce(s)),c=t.length,p=n.length,d=Oe(t),h=Oe(n),f=Ao(t,s),m=Ao(n,s);if(f.length+m.length===0)for(let t=0;ti[e]=0));const s=je(i,c,d),g=n.slice(-p);m.forEach((e=>g[e]=0));const y=je(g,p,h);l[t]=e(r[s],a[y])}return[l,s]}}const YS=RS(((e,t)=>e<0?t*e:e));function BS(e){const{inputs:t,backend:n}=e,{x:r,alpha:a}=t;SS([r,a],"prelu");const i=n.data.get(r.dataId).values,s=n.data.get(a.dataId).values,[o,u]=YS(r.shape,a.shape,i,s,"float32");return n.makeTensorInfo(u,"float32",o)}const zS={kernelName:ir,backendName:"cpu",kernelFunc:BS},PS=CS(cr,(e=>Math.max(0,e))),HS={kernelName:cr,backendName:"cpu",kernelFunc:PS},jS=CS(gr,(e=>Math.min(Math.max(0,e),6))),US={kernelName:gr,backendName:"cpu",kernelFunc:jS};function qS(e){return(t,n,r)=>{const a=we(n,t.length);for(let n=0;n1/(1+Math.exp(-e)))),VS=CS(Tr,(e=>1/(1+Math.exp(-e)))),GS={kernelName:Tr,backendName:"cpu",kernelFunc:VS};function KS(e,t,n,r,a){if("linear"===n)return LS({inputs:{x:t},backend:e});if("relu"===n)return PS({inputs:{x:t},backend:e});if("elu"===n)return AS({inputs:{x:t},backend:e});if("relu6"===n)return jS({inputs:{x:t},backend:e});if("prelu"===n)return BS({inputs:{x:t,alpha:r},backend:e});if("leakyrelu"===n)return $S({inputs:{x:t},backend:e,attrs:{alpha:a}});if("sigmoid"===n)return VS({inputs:{x:t},backend:e});throw new Error(`Activation ${n} has not been implemented for the CPU backend.`)}function JS(e){const{inputs:t,backend:n}=e,{real:r,imag:a}=t,i=n.data.get(r.dataId).values,s=n.data.get(a.dataId).values,o=n.makeTensorInfo(r.shape,"complex64");return n.data.get(o.dataId).complexTensorInfos={real:n.makeTensorInfo(r.shape,"float32",i),imag:n.makeTensorInfo(a.shape,"float32",s)},o}const XS={kernelName:Mt,backendName:"cpu",kernelFunc:JS};function ZS(e,t,n="float32"){if("complex64"===n)return JS({inputs:{real:ZS(e,t,"float32"),imag:ZS(e,t,"float32")},backend:e});const r=ze(ce(t),n);return e.makeTensorInfo(t,n,r)}function QS(e){const{inputs:t,backend:n}=e,{input:r}=t,a=n.data.get(r.dataId).complexTensorInfos.real,i=n.data.get(a.dataId).values;return n.makeTensorInfo(a.shape,a.dtype,i)}const ek={kernelName:ur,backendName:"cpu",kernelFunc:QS};function tk(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{dtype:i}=r;if("complex64"===i){if("complex64"===a.dtype)return LS({inputs:{x:a},backend:n});const e=ZS(n,a.shape,a.dtype),t=tk({inputs:{x:a},backend:n,attrs:{dtype:"float32"}}),r=JS({inputs:{real:t,imag:e},backend:n});return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(t),r}if("complex64"===a.dtype){const e=QS({inputs:{input:a},backend:n}),t=tk({inputs:{x:e},backend:n,attrs:{dtype:i}});return n.disposeIntermediateTensorInfo(e),t}if(!Se(a.dtype,i)){const e=LS({inputs:{x:a},backend:n});return{dataId:e.dataId,shape:e.shape,dtype:i}}if("int32"===i){const e=n.data.get(a.dataId).values,t=Int32Array.from(e);return n.makeTensorInfo(a.shape,"int32",t)}if("bool"===i){const e=n.data.get(a.dataId).values,t=Ya([0],a.dtype),[r,i]=RS(((e,t)=>e!==t?1:0))(a.shape,[],e,t,"bool");return n.makeTensorInfo(i,"bool",r)}throw new Error(`Error in Cast: failed to cast ${a.dtype} to ${i}`)}const nk={kernelName:wt,backendName:"cpu",kernelFunc:tk};function rk(e,t,n,r){return null==n?({inputs:n,backend:a})=>{const{a:i,b:s}=n,o=a;SS([i,s],e);const u=o.data.get(i.dataId).values,l=o.data.get(s.dataId).values,c="string"===i.dtype?Gf(u):u,p="string"===i.dtype?Gf(l):l,d=r||i.dtype,[h,f]=t(i.shape,s.shape,c,p,d);return o.makeTensorInfo(f,d,h)}:({inputs:e,backend:a})=>{const{a:i,b:s}=e,o=a;if("complex64"===i.dtype||"complex64"===s.dtype){const e=tk({inputs:{x:i},backend:o,attrs:{dtype:"complex64"}}),t=o.data.get(e.dataId),r=t.complexTensorInfos.real,a=t.complexTensorInfos.imag,u=o.data.get(r.dataId).values,l=o.data.get(a.dataId).values,c=tk({inputs:{x:s},backend:o,attrs:{dtype:"complex64"}}),p=o.data.get(c.dataId),d=p.complexTensorInfos.real,h=p.complexTensorInfos.imag,f=o.data.get(d.dataId).values,m=o.data.get(h.dataId).values,[g,y,b]=n(i.shape,s.shape,u,l,f,m),v=o.makeTensorInfo(b,"float32",g),x=o.makeTensorInfo(b,"float32",y),_=JS({inputs:{real:v,imag:x},backend:o});return o.disposeIntermediateTensorInfo(e),o.disposeIntermediateTensorInfo(c),o.disposeIntermediateTensorInfo(v),o.disposeIntermediateTensorInfo(x),_}{const e=o.data.get(i.dataId).values,n=o.data.get(s.dataId).values,a=r||i.dtype,[u,l]=t(i.shape,s.shape,e,n,a);return o.makeTensorInfo(l,a,u)}}}function ak(e){return(t,n,r,a,i,s)=>{const o=Lo(t,n),u=ce(o),l=o.length,c=Oe(o),p=we("float32",u),d=we("float32",u),h=Ao(t,o),f=Ao(n,o),m=yf(r,a),g=yf(i,s),y=t.length,b=Oe(t),v=n.length,x=Oe(n);if(h.length+f.length===0)for(let t=0;tr[e]=0));const a=je(r,y,b),i=n.slice(-v);f.forEach((e=>i[e]=0));const s=je(i,v,x),o=e(m[2*a],m[2*a+1],g[2*s],g[2*s+1]);p[t]=o.real,d[t]=o.imag}return[p,d,o]}}const ik=RS(((e,t)=>e+t)),sk=ak(((e,t,n,r)=>({real:e+n,imag:t+r}))),ok=rk(nt,ik,sk),uk={kernelName:nt,backendName:"cpu",kernelFunc:ok};function lk(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{shape:i}=r,s=ce(a.shape),o=ve(i,s),u=ce(o);se(s===u,(()=>`The new shape (${o}) has ${u} elements and the old shape (${a.shape}) has ${s} elements. The new shape and old shape must have the same number of elements.`)),n.incRef(a.dataId);const l=n.data.get(a.dataId);if(null!=l.complexTensorInfos){const e=l.complexTensorInfos.real,t=l.complexTensorInfos.imag;e.shape=o,t.shape=o}return{dataId:a.dataId,shape:o,dtype:a.dtype}}const ck={kernelName:pr,backendName:"cpu",kernelFunc:lk};function pk(e){const{inputs:t,backend:n,attrs:r}=e,{a,b:i}=t,{transposeA:s,transposeB:o}=r;SS([a,i],"matMul");const u=a.shape.length,l=i.shape.length,c=s?a.shape[u-2]:a.shape[u-1],p=o?i.shape[l-1]:i.shape[l-2],d=s?a.shape[u-1]:a.shape[u-2],h=o?i.shape[l-2]:i.shape[l-1],f=a.shape.slice(0,-2),m=i.shape.slice(0,-2),g=ce(f),y=ce(m),b=Lo(a.shape.slice(0,-2),i.shape.slice(0,-2)).concat([d,h]);se(c===p,(()=>`Error in matMul: inner shapes (${c}) and (${p}) of Tensors with shapes ${a.shape} and ${i.shape} and transposeA=${s} and transposeB=${o} must match.`));const v=o?[y,h,p]:[y,p,h],x=lk({inputs:{x:a},backend:n,attrs:{shape:s?[g,c,d]:[g,d,c]}}),_=lk({inputs:{x:i},backend:n,attrs:{shape:v}}),w=s?x.shape[1]:x.shape[2],D=s?x.shape[2]:x.shape[1],N=o?_.shape[1]:_.shape[2],M=Math.max(g,y),S=n.data.get(x.dataId).values,k=n.data.get(_.dataId).values,T=Oe(x.shape),C=Oe(_.shape),[E,A,I]=s?[T[0],1,T[1]]:[T[0],T[1],1],[L,F,$]=o?[1,C[1],C[0]]:[C[1],1,C[0]],O=D*N,R=Is([M,D,N],x.dtype),Y=R.values,B=n.blockSize;for(let e=0;e{const{x:t}=e.inputs,n=e.backend;SS(t,"abs");let r=new Float32Array(ce(t.shape));return r=fk(n.data.get(t.dataId).values),n.makeOutput(r,t.shape,t.dtype)}},gk=CS(et,(e=>Math.acos(e))),yk={kernelName:et,backendName:"cpu",kernelFunc:gk},bk=CS(tt,(e=>Math.acosh(e))),vk={kernelName:tt,backendName:"cpu",kernelFunc:bk},xk={kernelName:rt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,r=t;SS(t,"addN");const a=r.map((e=>n.data.get(e.dataId).values)),i=Is(r[0].shape,r[0].dtype),s=i.values;for(let e=0;en&&(n=a,r=e)}d[e]=r}return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(c,"int32",d)}},kk={kernelName:ot,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i}=r;SS(a,"argMin");let s=xe(i,a.shape);const o=vc(s,a.shape.length);let u=a;const l=[];null!=o&&(u=wk({inputs:{x:a},backend:n,attrs:{perm:o}}),l.push(u),s=_c(s.length,u.shape.length)),s=[s[0]],bc("argMin",s,u.shape.length);const[c,p]=gc(u.shape,s),d=ze(ce(c),"int32"),h=ce(p),f=n.data.get(u.dataId).values;for(let e=0;en.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(c,"int32",d)}},Tk=CS(ut,(e=>Math.asin(e))),Ck={kernelName:ut,backendName:"cpu",kernelFunc:Tk},Ek=CS(lt,(e=>Math.asinh(e))),Ak={kernelName:lt,backendName:"cpu",kernelFunc:Ek},Ik=CS(ct,(e=>Math.atan(e))),Lk={kernelName:ct,backendName:"cpu",kernelFunc:Ik},Fk=RS(((e,t)=>Math.atan2(e,t))),$k=rk(dt,Fk),Ok={kernelName:dt,backendName:"cpu",kernelFunc:$k},Rk=CS(pt,(e=>Math.atanh(e))),Yk={kernelName:pt,backendName:"cpu",kernelFunc:Rk};function Bk(e,t,n,r,a,i){const s=a.strideHeight,o=a.strideWidth,u=a.dilationHeight,l=a.dilationWidth,c=a.effectiveFilterHeight,p=a.effectiveFilterWidth,d=a.padInfo.top,h=a.padInfo.left,f="max"===i?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,m=Is(a.outShape,n),g=m.values,y=a.outShape[1]*a.outShape[2]*a.outShape[3],b=a.outShape[2]*a.outShape[3],v=a.outShape[3];for(let t=0;ty?y=s:"avg"===i&&(b+=s,x++)}if(isNaN(y))break}g[D+n*v+t]="avg"===i?b/x:y}}}return m}function zk(e,t,n,r,a=!1,i=!1){const s=Is(r.outShape,"int32"),o=r.strideHeight,u=r.strideWidth,l=r.dilationHeight,c=r.dilationWidth,p=r.effectiveFilterHeight,d=r.effectiveFilterWidth,h=r.padInfo.top,f=r.padInfo.left,m=Is(t,n,e);for(let e=0;ex&&(x=l,_=a?i?((e*r.inHeight+n)*r.inWidth+o)*r.inChannels+t:(n*r.inWidth+o)*r.inChannels+t:s*d+u)}}s.set(_,e,n,o,t)}}return s}function Pk(e,t,n,r,a,i){const s=a.strideDepth,o=a.strideHeight,u=a.strideWidth,l=a.dilationDepth,c=a.dilationHeight,p=a.dilationWidth,d=a.effectiveFilterDepth,h=a.effectiveFilterHeight,f=a.effectiveFilterWidth,m=a.padInfo.front,g=a.padInfo.top,y=a.padInfo.left,b="max"===i?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,v=Is(a.outShape,n),x=v.values,_=a.outShape[1]*a.outShape[2]*a.outShape[3]*a.outShape[4],w=a.outShape[2]*a.outShape[3]*a.outShape[4],D=a.outShape[3]*a.outShape[4],N=a.outShape[4];for(let t=0;tw?w=a:"avg"===i&&(D+=a,M++),isNaN(w))break}if(isNaN(w))break}if(isNaN(w))break}x[g+t]="avg"===i?D/M:w}}}}return v}const Hk={kernelName:ht,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t;SS(a,"avgPool");const{filterSize:i,strides:s,pad:o,dimRoundingMode:u}=r;se(xl(s,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${s} and dilations '1'`));const l=cl(a.shape,i,s,1,o,u);let c;if(1===l.filterWidth&&1===l.filterHeight&&de(l.inShape,l.outShape))c=LS({inputs:{x:a},backend:n});else{const e=n.data.get(a.dataId).values,t=Oe(a.shape),r=Bk(e,a.shape,a.dtype,t,l,"avg");c=n.makeTensorInfo(l.outShape,a.dtype,r.values)}return c}},jk={kernelName:mt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{filterSize:i,strides:s,pad:o,dimRoundingMode:u,dataFormat:l}=r;SS(a,"avgPool3d");const c=pl(a.shape,i,s,1,o,u,l),p=Pk(n.data.get(a.dataId).values,a.shape,a.dtype,Oe(a.shape),c,"avg");return n.makeTensorInfo(p.shape,"float32",p.values)}},Uk={kernelName:gt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i}=t,{filterSize:s,strides:o,pad:u,dimRoundingMode:l}=r;SS([a,i],"avgPool3DGrad");const c=pl(i.shape,s,o,1,u,l),p=c.strideDepth,d=c.strideHeight,h=c.strideWidth,f=c.filterDepth,m=c.filterHeight,g=c.filterWidth,y=c.dilationDepth,b=c.dilationHeight,v=c.dilationWidth,x=c.effectiveFilterDepth,_=c.effectiveFilterHeight,w=c.effectiveFilterWidth,D=x-1-c.padInfo.front,N=w-1-c.padInfo.left,M=_-1-c.padInfo.top,S=Is(i.shape,"float32"),k=1/(f*m*g),T=n.bufferSync(a);for(let e=0;e=c.outDepth||Math.floor(r)!==r))for(let n=0;n<_;n+=b){const a=(s+n)/d;if(!(a<0||a>=c.outHeight||Math.floor(a)!==a))for(let n=0;n=c.outWidth||Math.floor(i)!==i||(u+=T.get(e,r,a,i,t))}}}S.set(u*k,e,n,r,a,t)}return n.makeTensorInfo(S.shape,S.dtype,S.values)}},qk={kernelName:ft,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i}=t,s=i;SS([a,i],"avgPoolGrad");const{filterSize:o,strides:u,pad:l}=r,c=cl(s.shape,o,u,1,l),p=c.strideHeight,d=c.strideWidth,h=c.filterHeight,f=c.filterWidth,m=c.dilationHeight,g=c.dilationWidth,y=c.effectiveFilterHeight,b=c.effectiveFilterWidth,v=b-1-c.padInfo.left,x=y-1-c.padInfo.top,_=Is(s.shape,"float32"),w=1/(h*f),D=n.data.get(a.dataId).values,N=Is(a.shape,"float32",D);for(let e=0;e=c.outHeight||Math.floor(r)!==r))for(let n=0;n=c.outWidth||Math.floor(a)!==a||(s+=N.get(e,r,a,t))}}_.set(s*w,e,n,r,t)}return n.makeTensorInfo(_.shape,_.dtype,_.values)}},Wk={kernelName:ln,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,scale:i,offset:s,mean:o,variance:u}=t;se(o.shape.length===u.shape.length,(()=>"Batch normalization gradient requires mean and variance to have equal ranks.")),se(null==s||o.shape.length===s.shape.length,(()=>"Batch normalization gradient requires mean and offset to have equal ranks.")),se(null==i||o.shape.length===i.shape.length,(()=>"Batch normalization gradient requires mean and scale to have equal ranks.")),SS([a,o,u,i,s],"batchNorm");let{varianceEpsilon:l}=r;null==l&&(l=.001);const c=n.data.get(a.dataId).values,p=n.data.get(o.dataId).values,d=n.data.get(u.dataId).values,h=i?n.data.get(i.dataId).values:new Float32Array([1]),f=s?n.data.get(s.dataId).values:new Float32Array([0]),m=new Float32Array(c.length),g=f.length,y=h.length,b=d.length,v=p.length;let x=0,_=0,w=0,D=0;for(let e=0;e=g&&(x=0),_>=v&&(_=0),w>=y&&(w=0),D>=b&&(D=0);return n.makeTensorInfo(a.shape,a.dtype,m)}};function Vk(e,t,n,r,a){const i=nu(r,t,n),s=ce(n),o=Oe(r);if(i){const n=ru(t,o);return"string"===a?e.slice(n,n+s):e.subarray(n,n+s)}const u=Is(r,a,"string"===a?Gf(e):e),l=Is(n,a);for(let e=0;ee+t[n]));l.set(u.get(...r),...n)}return"string"===a?Kf(l.values):l.values}function Gk(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{begin:i,size:s}=r;SS(a,"slice");const[o,u]=au(a,i,s);Uo(a,o,u);const l=Vk(n.data.get(a.dataId).values,o,u,a.shape,a.dtype);return n.makeTensorInfo(u,a.dtype,l)}const Kk={kernelName:Nr,backendName:"cpu",kernelFunc:Gk},Jk={kernelName:bt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockShape:i,crops:s}=r;SS([a],"batchToSpaceND");const o=i.reduce(((e,t)=>e*t)),u=rf(a.shape,i,o),l=af(u.length,i.length),c=sf(a.shape,i,o),p=of(s,i.length),d=uf(c,s,i.length),h=lk({inputs:{x:a},backend:n,attrs:{shape:u}}),f=wk({inputs:{x:h},backend:n,attrs:{perm:l}}),m=lk({inputs:{x:f},backend:n,attrs:{shape:c}}),g=Gk({inputs:{x:m},backend:n,attrs:{begin:p,size:d}});return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),g}};function Xk(e,t,n,r,a){const i=ce(r),s=ze(a,n);for(let n=0;n=a||(s[r]+=i>0?t[n]:1)}return s}function Zk(e,t,n,r=!1){const a=e.shape[0],i=e.shape[1],s=Is([a,n],t.dtype);for(let o=0;o=n||(r?s.set(1,o,i):t.size>0?s.set(s.get(o,i)+t.get(o,a),o,i):s.set(s.get(o,i)+1,o,i))}return s}const Qk={kernelName:vt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,weights:i}=t,{size:s}=r,o=Xk(n.data.get(a.dataId).values,n.data.get(i.dataId).values,i.dtype,i.shape,s);return n.makeTensorInfo([s],i.dtype,o)}},eT={kernelName:_t,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{s0:r,s1:a}=t,i=n.data.get(r.dataId).values,s=n.data.get(a.dataId).values,o=Lo(Array.from(i),Array.from(s));return n.makeTensorInfo([o.length],"int32",Int32Array.from(o))}},tT=qS((e=>Math.ceil(e))),nT=ES(Dt,tT),rT={kernelName:Dt,backendName:"cpu",kernelFunc:nT},aT=CS(Nt,((e,t)=>{const n=t;return e>n.clipValueMax?n.clipValueMax:e{const{x:t}=e.inputs,n=e.backend,r=new Float32Array(ce(t.shape)),a=n.data.get(t.dataId),i=a.complexTensorInfos.real,s=a.complexTensorInfos.imag,o=n.data.get(i.dataId).values,u=n.data.get(s.dataId).values;for(let e=0;e{const n=ce(e.shape);a.set(e.vals,t),t+=n}))}else{let r=0;e.forEach((e=>{const i="string"===n?Gf(e.vals):e.vals;let s=0;for(let n=0;ne.shape)),i);if(0===ce(s))return n.makeTensorInfo(s,t[0].dtype,[]);const o=t.filter((e=>ce(e.shape)>0));if(1===o.length)return LS({inputs:{x:o[0]},backend:n});if(Zh(o.map((e=>e.shape)),i),"complex64"===o[0].dtype){const e=o.map((e=>QS({inputs:{input:e},backend:n}))),t=o.map((e=>uT({inputs:{input:e},backend:n}))),r=cT({inputs:e,backend:n,attrs:{axis:i}}),a=cT({inputs:t,backend:n,attrs:{axis:i}}),s=JS({inputs:{real:r,imag:a},backend:n});return e.forEach((e=>n.disposeIntermediateTensorInfo(e))),t.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(a),s}const u=o.map((e=>{const t=ce(e.shape.slice(i));return lk({inputs:{x:e},backend:n,attrs:{shape:[-1,t]}})})),l=u.map((e=>({vals:n.data.get(e.dataId).values,shape:e.shape})));s=Qh(u.map((e=>e.shape)),1);const c=1===u[0].shape[0],p=oT(l,s,t[0].dtype,c),d=Qh(o.map((e=>e.shape)),i),h=n.makeTensorInfo(d,t[0].dtype,p);return u.forEach((e=>n.disposeIntermediateTensorInfo(e))),h}const pT={kernelName:kt,backendName:"cpu",kernelFunc:cT};function dT(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i}=t,{strides:s,pad:o,dataFormat:u,dilations:l,dimRoundingMode:c}=r;SS([a,i],"conv2d");const p=_l(u),d=dl(a.shape,i.shape,s,l,o,c,!1,p),h=d.filterHeight,f=d.filterWidth,m=d.dilationHeight,g=d.dilationWidth,y=d.padInfo.left,b=d.padInfo.top,v="channelsLast"===d.dataFormat,x=new Xa(d.outShape,a.dtype),_=Oe(a.shape),w=Oe(i.shape),D=_[0],N=v?_[1]:_[2],M=v?_[2]:1,S=v?1:_[1],k=x.strides[0],T=v?x.strides[1]:x.strides[2],C=v?x.strides[2]:1,E=v?1:x.strides[1],A=n.data.get(a.dataId).values,I=n.data.get(i.dataId).values,L=x.values;for(let e=0;e=d.inHeight)continue;const i=e*w[0],s=t+n*N;for(let e=0;e=d.inWidth)continue;const a=s+r*M;let o=i+e*w[1];for(let e=0;e=l.inDepth)continue;const i=e*M[0],s=t+n*N[1];for(let e=0;e=l.inHeight)continue;const a=i+e*M[1],o=s+r*N[2];for(let e=0;e=l.inWidth)continue;const i=a+e*M[2],s=o+t*l.inChannels;let u=i;for(let e=0;eMath.cos(e))),xT={kernelName:Ft,backendName:"cpu",kernelFunc:vT},_T=CS($t,(e=>Math.cosh(e))),wT={kernelName:$t,backendName:"cpu",kernelFunc:_T},DT={kernelName:Yt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{image:a,boxes:i,boxInd:s}=t,{cropSize:o,method:u,extrapolationValue:l}=r,[c,p,d,h]=a.shape,f=i.shape[0],[m,g]=o,y=Is([f,m,g,h],"float32"),b=n.data.get(i.dataId).values,v=n.data.get(s.dataId).values,x=n.data.get(a.dataId).values,_=Oe(a.shape),w=Oe(y.shape);for(let e=0;e=c)continue;const o=m>1?(a-n)*(p-1)/(m-1):0,f=g>1?(i-r)*(d-1)/(g-1):0;for(let t=0;t1?n*(p-1)+t*o:.5*(n+a)*(p-1);if(c<0||c>p-1)for(let n=0;n1?r*(d-1)+u*f:.5*(r+i)*(d-1);if(c<0||c>d-1){for(let n=0;n1?r*(d-1)+n*f:.5*(r+i)*(d-1);if(a<0||a>d-1){for(let r=0;re+f-t-1:(e,t)=>e+t;for(let e=0;ee+f-t-1:(e,t)=>e+t;for(let e=0;e`Only NHWC dataFormat supported on CPU for depthToSpace. Got ${s}`));const o=a.shape[0],u=a.shape[1],l=a.shape[2],c=a.shape[3],p=u*i,d=l*i,h=c/(i*i),f=n.data.get(a.dataId).values,m=new Float32Array(o*p*d*h);let g=0;for(let e=0;e`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${s} and dilations '${d}'`));const h=dl(a.shape,i.shape,s,d,o,l,!0),{filterHeight:f,filterWidth:m,dilationHeight:g,dilationWidth:y,padInfo:b}=h,v=b.left,x=b.top,_=h.outChannels/h.inChannels,w=new Xa(h.outShape,a.dtype),D=n.data.get(a.dataId).values,N=n.data.get(i.dataId).values,M=w.values;for(let e=0;e=h.inHeight)continue;const i=e*p[0],s=t+n*c[1];for(let e=0;e=h.inWidth)continue;const a=i+e*p[1],o=s+r*h.inChannels;let u=t,l=a;for(let e=0;e{const{x:r,filter:a}=e,{strides:i,pad:s,dilations:o}=n,u=t,l=u.data.get(r.dataId).values,c=r.shape.length,p=u.data.get(a.dataId).values,d=a.shape.length,{batchSize:h,inHeight:f,inWidth:m,inChannels:g,outHeight:y,outWidth:b,padInfo:v,strideHeight:x,strideWidth:_,filterHeight:w,filterWidth:D,dilationHeight:N,dilationWidth:M,outShape:S}=ll(r.shape,a.shape,i,s,"NHWC",o),k=ce(S),T=S.length,C=De(r.dtype,k);for(let e=0;e=0&&i=0&&hu&&(u=m)}}}C[je([e,t,i,o],T,Oe(S))]=u}}}return{dataId:u.write(Ya(C,r.dtype),S,r.dtype),shape:S,dtype:r.dtype}}},FT={kernelName:Vt,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:r,filter:a,dy:i}=e,{strides:s,pad:o,dilations:u}=n,l=t,c=Ye(r.shape,l.data.get(r.dataId).values),p=Ye(a.shape,l.data.get(a.dataId).values),{batchSize:d,inHeight:h,inWidth:f,inChannels:m,outHeight:g,outWidth:y,padInfo:b,strideHeight:v,strideWidth:x,filterHeight:_,filterWidth:w,dilationHeight:D,dilationWidth:N,outShape:M}=ll(r.shape,a.shape,s,o,"NHWC",u);se(i.rank===M.length,(()=>`Error in ${Vt}, dy must have the same rank as output ${M.length}, but got ${i.rank}`));const S=Ye(M,l.data.get(i.dataId).values),k=Pe(a.shape,a.dtype);for(let e=0;e=0&&r=0&&ls&&(s=a,o=t,u=n)}}}k[o][u][i]+=S[e][t][r][i]}}}return{dataId:l.write(Ya(k,r.dtype),a.shape,a.dtype),shape:a.shape,dtype:a.dtype}}},$T={kernelName:Wt,backendName:"cpu",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:r,filter:a,dy:i}=e,{strides:s,pad:o,dilations:u}=n,l=t,c=Ye(r.shape,l.data.get(r.dataId).values),p=Ye(a.shape,l.data.get(a.dataId).values),{batchSize:d,inHeight:h,inWidth:f,inChannels:m,outHeight:g,outWidth:y,padInfo:b,strideHeight:v,strideWidth:x,filterHeight:_,filterWidth:w,dilationHeight:D,dilationWidth:N,outShape:M}=ll(r.shape,a.shape,s,o,"NHWC",u);se(i.rank===M.length,(()=>`Error in ${Wt}, dy must have the same rank as output ${M.length}, but got ${i.rank}`));const S=Ye(M,l.data.get(i.dataId).values),k=Pe(r.shape,r.dtype);for(let e=0;e=0&&r=0&&ls&&(s=a,o=r,u=l)}}}k[e][o][u][i]+=S[e][t][r][i]}}}return{dataId:l.write(Ya(k,r.dtype),r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}},OT=RS(((e,t)=>e*t)),RT=ak(((e,t,n,r)=>({real:e*n-t*r,imag:e*r+t*n}))),YT=rk(Vn,OT,RT),BT={kernelName:Vn,backendName:"cpu",kernelFunc:YT};function zT(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,keepDims:s}=r;let o;SS(a,"sum"),o="bool"===a.dtype?tk({inputs:{x:a},backend:n,attrs:{dtype:"int32"}}):LS({inputs:{x:a},backend:n});const u=o.shape.length,l=xe(i,o.shape),c=vc(l,u);let p=l,d=o;null!=c&&(d=wk({inputs:{x:o},backend:n,attrs:{perm:c}}),p=_c(p.length,u)),bc("sum",p,d.shape.length);const[h,f]=gc(d.shape,p);let m=ZS(n,h,ci(d.dtype,"int32"));const g=ce(f),y=n.data.get(m.dataId).values,b=n.data.get(d.dataId).values;for(let e=0;e=0&&(d=zT({inputs:{x:d},backend:n,attrs:{axis:l[e]-(s.length-h),keepDims:!1}}),f.push(d)),h--)}for(const e of f)e!==d&&n.disposeIntermediateTensorInfo(e);return d}},jT={kernelName:Xt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{dy:r,y:a}=t;SS([r,a],"eluGrad");const i=new Float32Array(ce(a.shape)),s=n.data.get(a.dataId).values,o=n.data.get(r.dataId).values;for(let e=0;e=1?o[e]:o[e]*(t+1)}return n.makeTensorInfo(a.shape,"float32",i)}},UT=RS(((e,t)=>e===t?1:0)),qT=rk(Qt,UT,null,"bool"),WT={kernelName:Qt,backendName:"cpu",kernelFunc:qT},VT=pf,GT=df,KT=hf,JT=ff,XT=mf,ZT=gf,QT=CS(Zt,(e=>{const t=Math.sign(e),n=Math.abs(e),r=1/(1+VT*n);return t*(1-((((ZT*r+XT)*r+JT)*r+KT)*r+GT)*r*Math.exp(-n*n))})),eC={kernelName:Zt,backendName:"cpu",kernelFunc:QT},tC=qS((e=>Math.exp(e))),nC=ES(en,tC,"float32"),rC={kernelName:en,backendName:"cpu",kernelFunc:nC};function aC(e){const{inputs:t,backend:n,attrs:r}=e,{input:a}=t,{dim:i}=r,s=a.shape.length,o=a.shape.slice();let u=i;return i<0&&(se(-(s+1)<=i,(()=>`Axis must be in the interval [${-(s+1)}, ${s}]`)),u=s+i+1),o.splice(u,0,1),lk({inputs:{x:a},backend:n,attrs:{shape:o}})}const iC={kernelName:tn,backendName:"cpu",kernelFunc:aC},sC=qS((e=>Math.expm1(e))),oC=ES(nn,sC),uC={kernelName:nn,backendName:"cpu",kernelFunc:oC},lC=RS(((e,t)=>e/t)),cC=rk(Gt,lC),pC={kernelName:Gt,backendName:"cpu",kernelFunc:cC},dC=RS(((e,t)=>e-t)),hC=ak(((e,t,n,r)=>({real:e-n,imag:t-r}))),fC=rk(Wr,dC,hC),mC={kernelName:Wr,backendName:"cpu",kernelFunc:fC};function gC(e,t,n){const r=e.shape,a=r[0],i=r[1],s=n.data.get(e.dataId),o=s.complexTensorInfos.real,u=s.complexTensorInfos.imag,l=[a,i],c=ce(l),p=we("float32",c),d=we("float32",c);for(let e=0;e{const{image:r}=e,a=n,i=we(r.dtype,ce(r.shape)),[s,o,u,l]=r.shape,c=a.data.get(r.dataId).values;for(let e=0;e=0&&sMath.floor(e))),NC=ES(on,DC),MC={kernelName:on,backendName:"cpu",kernelFunc:NC},SC=RS(((e,t)=>Math.floor(e/t))),kC=rk(un,SC,null,"int32"),TC={kernelName:un,backendName:"cpu",kernelFunc:kC},CC={kernelName:ua,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i,bias:s,preluActivationWeights:o}=t,{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:d,activation:h,leakyreluAlpha:f}=r;let m=dT({inputs:{x:a,filter:i},backend:n,attrs:{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:d}});if(s){const e=m;if("NCHW"===c&&1===s.shape.length&&1!==s.shape[0]){const e=lk({inputs:{x:s},backend:n,attrs:{shape:[s.shape[0],1,1]}});m=ok({inputs:{a:m,b:e},backend:n}),n.disposeIntermediateTensorInfo(e)}else m=ok({inputs:{a:m,b:s},backend:n});n.disposeIntermediateTensorInfo(e)}if(h){const e=m;if("NCHW"===c&&"prelu"===h&&1===o.shape.length&&1!==o.shape[0]){const e=lk({inputs:{x:o},backend:n,attrs:{shape:[o.shape[0],1,1]}});m=KS(n,m,h,e,f),n.disposeIntermediateTensorInfo(e)}else m=KS(n,m,h,o,f);n.disposeIntermediateTensorInfo(e)}return m}},EC={kernelName:la,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i,bias:s,preluActivationWeights:o}=t,{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:d,activation:h,leakyreluAlpha:f}=r;let m=TT({inputs:{x:a,filter:i},backend:n,attrs:{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:d}});if(s){const e=m;m=ok({inputs:{a:m,b:s},backend:n}),n.disposeIntermediateTensorInfo(e)}if(h){const e=m;m=KS(n,m,h,o,f),n.disposeIntermediateTensorInfo(e)}return m}};function AC(e,t,n,r,a,i,s,o,u){const l=Is([r,i],n);for(let n=0;n=u/i)throw new Error(`Invalid indices: ${r} does not index into ${o}`);for(let e=0;e=0,(()=>`GatherV2: the index value ${t} is not in [0, ${c-1}]`))}let p=o;null==o&&(p=0);const d=ce(i.shape),h=Vf(a,i,u,p),f=lk({inputs:{x:a},backend:n,attrs:{shape:[h.batchSize,h.outerSize,h.dimSize,h.sliceSize]}}),m=lk({inputs:{x:i},backend:n,attrs:{shape:[h.batchSize,d/h.batchSize]}}),g=[h.batchSize,h.outerSize,d/h.batchSize,h.sliceSize],y=n.bufferSync(m),b=LC(n.bufferSync(f),y,g);return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),n.makeTensorInfo(h.outputShape,b.dtype,b.values)}},$C=RS(((e,t)=>e>t?1:0)),OC=rk(dn,$C,null,"bool"),RC={kernelName:dn,backendName:"cpu",kernelFunc:OC},YC=RS(((e,t)=>e>=t?1:0)),BC=rk(hn,YC,null,"bool"),zC={kernelName:hn,backendName:"cpu",kernelFunc:BC},PC={kernelName:mn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n}=e,{input:r}=t,a=ce(r.shape),i=r.shape[r.shape.length-1],s=lk({inputs:{x:r},backend:n,attrs:{shape:[a/i,i]}}),o=gC(s,!0,n),u=lk({inputs:{x:o},backend:n,attrs:{shape:r.shape}});return n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(o),u}},HC=CS(yn,(e=>Number.isFinite(e)?1:0),"bool"),jC={kernelName:yn,backendName:"cpu",kernelFunc:HC},UC=CS(bn,(e=>Math.abs(e)===1/0?1:0),"bool"),qC={kernelName:bn,backendName:"cpu",kernelFunc:UC},WC=CS(vn,(e=>Number.isNaN(e)?1:0),"bool"),VC={kernelName:vn,backendName:"cpu",kernelFunc:WC},GC=RS(((e,t)=>ee<=t?1:0)),ZC=rk(wn,XC,null,"bool"),QC={kernelName:wn,backendName:"cpu",kernelFunc:ZC};function eE(e,t,n){const r=(t-e)/(n-1),a=ze(n,"float32");a[0]=e;for(let e=1;eMath.log(e))),rE=ES(Nn,nE),aE={kernelName:Nn,backendName:"cpu",kernelFunc:rE},iE=CS(Mn,(e=>Math.log1p(e))),sE={kernelName:Mn,backendName:"cpu",kernelFunc:iE},oE=RS(((e,t)=>e&&t)),uE=rk(Sn,oE,null,"bool"),lE={kernelName:Sn,backendName:"cpu",kernelFunc:uE},cE=CS(kn,(e=>e?0:1),"bool"),pE={kernelName:kn,backendName:"cpu",kernelFunc:cE},dE=RS(((e,t)=>e||t)),hE=rk(Tn,dE,null,"bool"),fE={kernelName:Tn,backendName:"cpu",kernelFunc:hE},mE={kernelName:In,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{depthRadius:i,bias:s,alpha:o,beta:u}=r;SS(a,"LRN");const l=a.shape[3],c=l-1,p=n.data.get(a.dataId).values,d=ce(a.shape),h=new Float32Array(d);function f(e){const t=e%l;let n=e-t+Math.max(0,t-i);const r=e-t+Math.min(t+i,c);let a=0;for(;n<=r;n++){const e=p[n];a+=e*e}return a}for(let e=0;ei)&&(i=t)}a[n]=i}return a}function bE(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{reductionIndices:i,keepDims:s}=r,o=n;let u=a.shape;const l=u.length,c=xe(i,u);let p=c;const d=vc(p,l);let h=o.data.get(a.dataId).values;if(null!=d){const e=new Array(l);for(let t=0;tMath.max(e,t))),_E=rk($n,xE),wE={kernelName:$n,backendName:"cpu",kernelFunc:_E},DE={kernelName:On,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t;SS(a,"maxPool");const{filterSize:i,strides:s,pad:o,dimRoundingMode:u}=r;se(xl(s,1),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${s} and dilations '1'`));const l=cl(a.shape,i,s,1,o,u);let c;if(1===l.filterWidth&&1===l.filterHeight&&de(l.inShape,l.outShape))c=LS({inputs:{x:a},backend:n});else{const e=n.data.get(a.dataId).values,t=Oe(a.shape),r=Bk(e,a.shape,a.dtype,t,l,"max");c=n.makeTensorInfo(l.outShape,a.dtype,r.values)}return c}},NE={kernelName:Yn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{filterSize:i,strides:s,pad:o,dimRoundingMode:u,dataFormat:l}=r;SS(a,"maxPool3d");const c=pl(a.shape,i,s,1,o,u,l),p=Pk(n.data.get(a.dataId).values,a.shape,a.dtype,Oe(a.shape),c,"max");return n.makeTensorInfo(p.shape,"float32",p.values)}},ME={kernelName:Bn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i}=t,{filterSize:s,strides:o,pad:u,dimRoundingMode:l}=r;SS([a,i],"maxPool3DGrad");const c=pl(i.shape,s,o,1,u,l),p=function(e,t){const n=Is(t.outShape,"int32"),r=t.strideDepth,a=t.strideHeight,i=t.strideWidth,s=t.dilationDepth,o=t.dilationHeight,u=t.dilationWidth,l=t.effectiveFilterDepth,c=t.effectiveFilterHeight,p=t.effectiveFilterWidth,d=t.padInfo.front,h=t.padInfo.top,f=t.padInfo.left;for(let m=0;m=N&&(N=o,M=n*c*p+a*c+s)}}}n.set(M,m,y,r,a,g)}}}return n}(n.bufferSync(i),c),d=c.strideDepth,h=c.strideHeight,f=c.strideWidth,m=c.dilationDepth,g=c.dilationHeight,y=c.dilationWidth,b=c.effectiveFilterDepth,v=c.effectiveFilterHeight,x=c.effectiveFilterWidth,_=b-1-c.padInfo.front,w=x-1-c.padInfo.left,D=v-1-c.padInfo.top,N=Is(i.shape,"float32"),M=n.bufferSync(a);for(let e=0;e=c.outDepth||Math.floor(r)!==r))for(let a=0;a=c.outHeight||Math.floor(i)!==i))for(let s=0;s=c.outWidth||Math.floor(l)!==l)continue;const d=b*v*x-1-p.get(e,r,i,l,t)===n*v*x+a*x+s?1:0;0!==d&&(u+=M.get(e,r,i,l,t)*d)}}}N.set(u,e,n,r,a,t)}return n.makeTensorInfo(N.shape,N.dtype,N.values)}},SE={kernelName:Rn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i,output:s}=t,o=i;SS([i,s],"maxPoolGrad");const{filterSize:u,strides:l,pad:c,dimRoundingMode:p}=r,d=cl(o.shape,u,l,1,c,p),h=n.data.get(o.dataId).values,f=Is(d.outShape,o.dtype,zk(h,o.shape,o.dtype,d).values),m=d.strideHeight,g=d.strideWidth,y=d.dilationHeight,b=d.dilationWidth,v=d.effectiveFilterHeight,x=d.effectiveFilterWidth,_=x-1-d.padInfo.left,w=v-1-d.padInfo.top,D=Is(o.shape,"float32"),N=n.data.get(a.dataId).values,M=Is(a.shape,"float32",N);for(let e=0;e=d.outHeight||Math.floor(r)!==r))for(let a=0;a=d.outWidth||Math.floor(o)!==o)continue;const u=v*x-1-f.get(e,r,o,t)===n*x+a?1:0;0!==u&&(s+=M.get(e,r,o,t)*u)}}D.set(s,e,n,r,t)}return n.makeTensorInfo(D.shape,D.dtype,D.values)}},kE={kernelName:zn,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{x:r}=e,{filterSize:a,strides:i,pad:s,includeBatchInIndex:o}=t,u=n;SS(r,"MaxPoolWithArgmax");const l=u.data.get(r.dataId).values,c=cl(r.shape,a,i,[1,1],s),[p,d]=function(e,t,n,r,a){const i=Bk(e,0,n,Oe(t),a,"max"),s=zk(e,t,n,a,!0,r);return[i.values,s.values]}(l,r.shape,r.dtype,o,c),h=u.write(p,c.outShape,r.dtype),f=u.write(d,c.outShape,r.dtype);return[{dataId:h,shape:c.outShape,dtype:r.dtype},{dataId:f,shape:c.outShape,dtype:"int32"}]}},TE={kernelName:Pn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,keepDims:s}=r,o=xe(i,a.shape),u=ce(gc(a.shape,o)[1]),l=[],c=n.makeTensorInfo([],"float32",new Float32Array([u]));l.push(c);const p=tk({inputs:{x:a},backend:n,attrs:{dtype:"float32"}});l.push(p);const d=cC({inputs:{a:p,b:c},backend:n});l.push(d);const h=zT({inputs:{x:d},backend:n,attrs:{axis:i,keepDims:s}});return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),h}},CE={kernelName:Hn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,keepDims:s}=r;SS(a,"min");const o=xe(i,a.shape);let u=o;const l=vc(u,a.shape.length);let c=a;null!=l&&(c=wk({inputs:{x:a},backend:n,attrs:{perm:l}}),u=_c(u.length,a.shape.length)),bc("min",u,c.shape.length);const[p,d]=gc(c.shape,u),h=ce(d),f=ze(ce(p),c.dtype),m=n.data.get(c.dataId).values;for(let e=0;eMath.min(e,t))),AE=rk(jn,EE),IE={kernelName:jn,backendName:"cpu",kernelFunc:AE},LE={kernelName:Un,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{paddings:i,mode:s}=r;SS(a,"mirrorPad");const o=i.map(((e,t)=>e[0]+a.shape[t]+e[1])),u=i.map((e=>e[0])),l=i.map(((e,t)=>e[0]+a.shape[t])),c="reflect"===s?0:1,p=n.data.get(a.dataId).values,d=a.shape.length,h=Oe(a.shape),f=ce(o),m=o.length,g=Oe(o),y=we(a.dtype,f);for(let e=0;e=l[e]&&(t[e]=2*(l[e]-1)-t[e]+c);t=t.map(((e,t)=>e-u[t]));const n=je(t,d,h);y[e]=p[n]}return{dataId:n.write(y,o,a.dtype),shape:o,dtype:a.dtype}}},FE=RS(((e,t)=>{const n=e%t;return e<0&&t<0||e>=0&&t>=0?n:(n+t)%t})),$E=rk(qn,FE),OE={kernelName:qn,backendName:"cpu",kernelFunc:$E};function RE(e){const{inputs:t,backend:n,attrs:r}=e,{logits:a}=t,{dim:i}=r,s=a.shape.length;let o=i;if(-1===o&&(o=s-1),o!==s-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${s} and dim was ${o}`);const u=xe([o],a.shape),l=bE({inputs:{x:a},backend:n,attrs:{reductionIndices:u,keepDims:!1}}),c=yc(l.shape,u),p=lk({inputs:{x:l},backend:n,attrs:{shape:c}}),d=fC({inputs:{a,b:p},backend:n}),h=nC({inputs:{x:d},backend:n}),f=zT({inputs:{x:h},backend:n,attrs:{axis:u,keepDims:!1}}),m=lk({inputs:{x:f},backend:n,attrs:{shape:c}}),g=cC({inputs:{a:h,b:m},backend:n});return n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),g}const YE={kernelName:Fr,backendName:"cpu",kernelFunc:RE},BE={kernelName:Wn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{logits:a}=t,{numSamples:i,seed:s,normalized:o}=r;SS(a,"multinomial");const u=o?a:RE({inputs:{logits:a},backend:n,attrs:{dim:-1}}),l=u.shape[0],c=u.shape[1],p=n.data.get(u.dataId).values,d=[l,i],h=ze(ce(d),"int32");for(let e=0;ee!==t?1:0)),KE=rk(Kn,GE,null,"bool"),JE={kernelName:Kn,backendName:"cpu",kernelFunc:KE},XE={kernelName:er,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{indices:a}=t,{depth:i,onValue:s,offValue:o}=r;SS(a,"oneHot");const u=ce(a.shape),l=new Float32Array(u*i);l.fill(o);const c=n.data.get(a.dataId).values;for(let e=0;e=0&&c[e]{oe(i,e.shape,"All tensors passed to stack must have matching shapes"),se(s===e.dtype,(()=>"All tensors passed to stack must have matching dtypes"))}));const o=[],u=cT({inputs:t.map((e=>{const t=aC({inputs:{input:e},backend:n,attrs:{dim:a}});return o.push(t),t})),backend:n,attrs:{axis:a}});return o.forEach((e=>n.disposeIntermediateTensorInfo(e))),u}const nA={kernelName:tr,backendName:"cpu",kernelFunc:tA},rA={kernelName:nr,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{paddings:i,constantValue:s}=r;SS(a,"pad");const o=i.map(((e,t)=>e[0]+a.shape[t]+e[1])),u=i.map((e=>e[0])),l=n.data.get(a.dataId).values,c=ce(a.shape),p=a.shape.length,d=Oe(a.shape),h=ce(o),f=o.length,m=Oe(o),g=we(a.dtype,h);0!==s&&g.fill(s);for(let e=0;ee+u[t])),f,m)]=l[e];return{dataId:n.write(g,o,a.dtype),shape:o,dtype:a.dtype}}},aA=RS(((e,t)=>Math.pow(e,t))),iA=rk(ar,aA),sA={kernelName:ar,backendName:"cpu",kernelFunc:iA};function oA(e,t,n,r){const[a,i]=gc(e,r),s=ci(t,"int32"),o=ze(ce(a),s),u=ce(i);for(let e=0;en.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(y,g,f)}};function lA(e,t,n,r){if(e===t||e1)return ze(0,r);const a=ze(Math.abs(Math.ceil((t-e)/n)),r);t1/e)),dA={kernelName:lr,backendName:"cpu",kernelFunc:pA},hA={kernelName:fr,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:a}=t,{alignCorners:i,halfPixelCenters:s,size:o}=r;SS(a,"resizeBilinear");const u=Oe(a.shape),[l,c]=o,[p,d,h,f]=a.shape,m=n.data.get(a.dataId).values,g=new Float32Array(ce([p,l,c,f])),y=[i&&l>1?d-1:d,i&&c>1?h-1:h],b=[i&&l>1?l-1:l,i&&c>1?c-1:c];let v=0;const x=y[0]/b[0],_=y[1]/b[1];for(let e=0;e1?l-1:l,s&&h>1?c-1:c],g=[s&&d>1?d-1:d,s&&h>1?h-1:h],y=m[0]/g[0],b=m[1]/g[1],v=n.data.get(i.dataId).values;let x=0;for(let e=0;e1?d-1:d,i&&c>1?h-1:h],b=[i&&l>1?l-1:l,i&&c>1?c-1:c],v=y[0]/b[0],x=y[1]/b[1];let _=0;for(let e=0;e1?c-1:c,s&&f>1?p-1:p],b=[s&&h>1?h-1:h,s&&f>1?f-1:f],v=y[0]/b[0],x=y[1]/b[1],_=1/v,w=1/x,D=2*Math.ceil(_)+2,N=2*Math.ceil(w)+2;for(let e=0;e=h)continue;const d=t+l*u[1],m=l*v;if(e===Math.min(c-1,s?Math.round(m):Math.floor(m)))for(let e=0;e=f)continue;const a=d+t*u[2],i=t*x;r===Math.min(p-1,s?Math.round(i):Math.floor(i))&&(o+=g[a+n])}}m[i+n]=o}}}}return n.makeTensorInfo(a.shape,a.dtype,m)}},yA={kernelName:yr,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{dims:i}=r;SS(a,"reverse");const s=a.shape.length,o=xe(i,a.shape);if(0===s)return LS({inputs:{x:a},backend:n});const u=new Xa(a.shape,a.dtype),l=n.bufferSync(a);for(let e=0;en[e]=a.shape[e]-1-n[e])),u.set(l.get(...n),...t)}return n.makeTensorInfo(u.shape,u.dtype,u.values)}},bA={kernelName:sa,backendName:"cpu",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{image:r}=e,{radians:a,fillValue:i,center:s}=t,o=n,u=we(r.dtype,ce(r.shape)),[l,c,p,d]=r.shape,[h,f]=nf(s,c,p),m=Math.sin(a),g=Math.cos(a),y=o.data.get(r.dataId).values;for(let e=0;e=0&&x=0&&_{const t=Math.floor(e);return e-t<.5?Math.floor(e):e-t>.5?Math.ceil(e):t%2==0?t:t+1})),xA={kernelName:br,backendName:"cpu",kernelFunc:vA},_A=qS((e=>1/Math.sqrt(e))),wA=ES(vr,_A),DA={kernelName:vr,backendName:"cpu",kernelFunc:wA};function NA(e,t,n,r,a,i,s,o,u,l){const c=[r/a,a],p=e.values,d=t.values;if(0===r)return Is(n,t.dtype);const h=Is(c,t.dtype);"string"==typeof u||"number"==typeof u?h.values.fill(u):"boolean"==typeof u&&h.values.fill(+u);for(let e=0;e=r/a)throw new Error(`Invalid indices: ${i} does not index into ${n}`);for(let n=0;n1||1===a.shape.length?1:ce(a.shape.slice(1));for(let e=0;ee>=0?AA*e:EA*(Math.exp(e)-1))),LA={kernelName:Dr,backendName:"cpu",kernelFunc:IA},FA=CS(kr,(e=>e<0?-1:e>0?1:0)),$A={kernelName:kr,backendName:"cpu",kernelFunc:FA},OA=CS(Mr,(e=>Math.sin(e))),RA={kernelName:Mr,backendName:"cpu",kernelFunc:OA},YA=CS(Sr,(e=>Math.sinh(e))),BA={kernelName:Sr,backendName:"cpu",kernelFunc:YA},zA=Math.log(1.1920928955078125e-7)+2,PA=CS(Cr,(e=>{const t=e>-zA,n=e=u)throw new Error($f(t,n,u));++f[n],d=d&&n>=h,h=n}let m=!0;for(let e=0;e0&&(f[e]+=f[e-1])}if(m&&d){const t=e,n=r;for(let e=0;eNumber(e))))),n.makeTensorInfo([m.length],r.dtype,new Int32Array(m))]}};function WA(e,t,n,r,a){const i=ce(r),s=t[0],o=a.length,u=[];let l=1,c=-1;for(let e=0;e0){d[p-1]=1;for(let e=p-2;e>=0;--e)d[e]=d[e+1]*r[e+1]}const h=[];if(o>0){h[o-1]=1;for(let e=o-2;e>=0;--e)h[e]=h[e+1]*u[e+1]}const f=De(n,s*o);for(let t=0;t0?a[o-1]+1:0;if(c<0)throw new Error("segment ids must be >= 0");const p=t.slice();p[0]=c;const d=p.reduce(((e,t)=>e*t),1),h=De(n,d);if(0===o)return c>0&&h.fill(s),[h,p];if(c<=0)throw new Error("segment ids must be >= 0");let f=0,m=1,g=0,y=a[f];for(;;){let t=0;if(m=t)throw new Error("segment ids are not increasing")}if(y<0||y>=c)throw new Error(jf(y,c));y>g&&h.fill(s,g*l,y*l);for(let t=f;t=u[0])throw new Error(Uf(t,r[t],u[0]));for(let t=0;to)break}return g{const t=[...c];t[o]=e;const r=Gk({inputs:{x:a},backend:n,attrs:{begin:l,size:t}});return l[o]+=e,r}))}},QA=qS((e=>Math.sqrt(e))),eI=CS(Er,(e=>Math.sqrt(e))),tI={kernelName:Er,backendName:"cpu",kernelFunc:eI},nI={kernelName:Pr,backendName:"cpu",kernelFunc:({inputs:e,backend:t})=>{const{x:n}=e,r=t;SS(n,"square");const a=r.data.get(n.dataId).values,i=new Float32Array(a.length);for(let e=0;e{const n=e-t;return n*n})),aI=rk(zr,rI),iI={kernelName:zr,backendName:"cpu",kernelFunc:aI},sI=CS(aa,((e,t)=>{const n=t;return isNaN(e)?NaN:e>0?1:n.alpha})),oI={kernelName:aa,backendName:"cpu",kernelFunc:sI};function uI(e,t,n,r){const a=Is(e,t.dtype);for(let e=0;e=1,(()=>`Input must have rank at least 1, got: ${a.shape.length}`));const e=Wo(b,v,x),t=Gk({inputs:{x:a},backend:n,attrs:{begin:b,size:e}});_=lk({inputs:{x:t},backend:n,attrs:{shape:f}}),n.disposeIntermediateTensorInfo(t)}else{const e=uI(h,n.bufferSync(a),x,b);_=n.makeTensorInfo(f,e.dtype,e.values)}return _}};class cI{constructor(e,t,n,r,a,i){this.separator=Pa(e),this.nGramWidths=t,this.leftPad=Pa(n),this.rightPad=Pa(r),this.padWidth=a,this.preserveShort=i}getPadWidth(e){return Math.min(this.padWidth<0?e-1:this.padWidth,e-1)}getNumNGrams(e,t){const n=this.getPadWidth(t);return Math.max(0,e+2*n-t+1)}createNGrams(e,t,n,r,a,i){for(let s=0;s0?0:s-o);let d=0;d+=u*this.leftPad.length;for(let t=0;te.forEach((e=>h[f++]=e));for(let e=0;e0){m(e[p+c-1]);for(let e=0;e0){let e=t[0];if(0!==e)throw new Error(`First split value must be 0, got ${e}`);for(let a=1;a=e;if(r=r&&t[a]<=n,!r)throw new Error(`Invalid split value ${t[a]}, must be in [${e}, ${n}]`);e=t[a]}if(e!==n)throw new Error(`Last split value must be data size. Expected ${n}, got ${e}`)}const a=r-1,i=De("int32",r);if(0===n||0===r){const e=new Array(n);for(let e=0;e<=a;++e)i[e]=0;return[e,i]}i[0]=0;for(let e=1;e<=a;++e){const n=t[e]-t[e-1];let r=0;this.nGramWidths.forEach((e=>{r+=this.getNumNGrams(n,e)})),this.preserveShort&&n>0&&0===r&&(r=1),i[e]=i[e-1]+r}const s=new Array(i[a]);for(let n=0;n{const o=t[n+1]-t[n],u=this.getNumNGrams(o,i);this.createNGrams(e,r,s,a,u,i),a+=u})),this.preserveShort&&a===i[n]){const i=t[n+1]-t[n];if(0===i)continue;const o=i+2*this.padWidth,u=1;this.createNGrams(e,r,s,a,u,o)}}return[s,i]}}function pI(e,t,n,r,a,i,s,o){return new cI(n,r,a,i,s,o).compute(e,t)}const dI={kernelName:jr,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{separator:a,nGramWidths:i,leftPad:s,rightPad:o,padWidth:u,preserveShortSequences:l}=r,{data:c,dataSplits:p}=t,d=n.data.get(c.dataId).values,h=n.data.get(p.dataId).values,[f,m]=pI(d,h,a,i,s,o,u,l);return[n.makeTensorInfo([f.length],"string",f),n.makeTensorInfo(p.shape,"int32",m)]}};function hI(e,t,n,r){if(!e.length)return;if(0===t.length){for(let t=0;tMath.tan(e))),vI={kernelName:Vr,backendName:"cpu",kernelFunc:bI},xI=CS(Gr,(e=>Math.tanh(e)));function _I(e,t){const n=new Array(e.rank);for(let r=0;r{const n=t.value-e.value;return 0===n?e.index-t.index:n};function NI(e,t,n=0,r=e.length-1){for(;r>n;){if(r-n>600){const a=r-n+1,i=t-n+1,s=Math.log(a),o=.5*Math.exp(2*s/3),u=.5*Math.sqrt(s*o*(a-o)/a)*Math.sign(i-a/2);NI(e,t,Math.max(n,Math.floor(t-i*o/a+u)),Math.min(r,Math.floor(t+(a-i)*o/a+u)))}const a=e[t];let i=n,s=r;for(ne(e,n,t),DI(e[r],a)>0&&ne(e,n,r);i0;)s-=1}0===DI(e[n],a)?ne(e,n,s):(s+=1,ne(e,s,r)),s<=t&&(n=s+1),t<=s&&(r=s-1)}}function MI(e,t,n,r,a){const i=t[t.length-1],[s,o]=[e.length/i,i],u=we(n,s*r),l=we("int32",s*r);for(let t=0;ts[t]={value:e,index:t})),rt-1)if(t<=1)n=0;else{const e=2*t;n-=e*Math.trunc(n/e),n>=t&&(n=e-n-1)}return ee(0,n,t-1)}(e,t);case"wrap":return function(e,t){let n=e;if(n<0)if(t<=1)n=0;else{const e=t-1;n+=t*(Math.trunc(-n/e)+1)}else if(n>t-1)if(t<=1)n=0;else{const e=t-1;n-=t*Math.trunc(n/e)}return ee(0,n,t-1)}(e,t);case"nearest":return function(e,t){return ee(0,e,t-1)}(e,t);default:return function(e,t){return e}(e)}}function CI(e,t,n,r,a,i,s,o,u,l,c){return 0<=o&&o{for(let n=0;nn.disposeIntermediateTensorInfo(e))),p}},OI=[hk,mk,yk,vk,uk,xk,Nk,Mk,Sk,kk,Ck,Ak,Lk,Ok,Yk,Hk,jk,Uk,qk,dk,Wk,Jk,Qk,eT,nk,rT,iT,XS,sT,pT,hT,fT,mT,gT,yT,bT,xT,wT,DT,NT,MT,ST,kT,CT,ET,AT,IT,LT,FT,$T,HT,IS,jT,WT,eC,rC,iC,uC,vC,_C,wC,MC,TC,CC,EC,IC,FC,RC,zC,FS,PC,lT,jC,qC,VC,OS,JC,QC,tE,aE,sE,lE,pE,fE,mE,gE,vE,wE,DE,NE,ME,SE,kE,TE,CE,IE,LE,OE,BE,BT,PE,jE,qE,VE,JE,XE,eA,nA,rA,sA,zS,uA,cA,ek,pC,dA,HS,US,ck,hA,fA,mA,gA,yA,bA,xA,DA,MA,TA,CA,LA,GS,$A,RA,BA,Kk,YE,HA,jA,qA,VA,KA,JA,XA,ZA,tI,nI,iI,oI,lI,dI,mI,yI,mC,PT,vI,{kernelName:Gr,backendName:"cpu",kernelFunc:xI},wI,SI,kI,Dk,LI,FI,$I,QE];for(const e of OI)ya(e);const RI={},YI={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function BI(e,t){if(!(e in RI)||null!=t){const n=function(e,t){if(1!==e&&2!==e)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");const n=null==t?function(e){if("undefined"!=typeof OffscreenCanvas&&2===e)return new OffscreenCanvas(300,150);if("undefined"!=typeof document)return document.createElement("canvas");throw new Error("Cannot create a canvas in this context")}(e):t;return n.addEventListener("webglcontextlost",(t=>{t.preventDefault(),delete RI[e]}),!1),1===e?n.getContext("webgl",YI)||n.getContext("experimental-webgl",YI):n.getContext("webgl2",YI)}(e,t);if(null===n)return console.log("Could not get context for WebGL version",e),null;RI[e]=n}const n=RI[e];return null==n||n.isContextLost()?(delete RI[e],BI(e)):(n.disable(n.DEPTH_TEST),n.disable(n.STENCIL_TEST),n.disable(n.BLEND),n.disable(n.DITHER),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SAMPLE_COVERAGE),n.enable(n.SCISSOR_TEST),n.enable(n.CULL_FACE),n.cullFace(n.BACK),RI[e])}var zI,PI,HI;function jI(e,t){return[t,e]}function UI(e){const t=ce(e);return me(Math.ceil(t/4))}function qI(e,t){return[Math.max(1,Math.ceil(t/2)),Math.max(1,Math.ceil(e/2))]}function WI(e,t){const n=e;let r,a,i,s,o,u,l,c,p,d;return 2===Ge().getNumber("WEBGL_VERSION")?(r=n.R32F,a=n.R16F,i=n.RGBA16F,s=n.RGBA32F,o=n.RED,l=4,c=1,p=n.HALF_FLOAT,d=n.FLOAT,u=n.RGBA8):(r=e.RGBA,a=e.RGBA,i=e.RGBA,s=n.RGBA,o=e.RGBA,l=4,c=4,p=null!=t?t.HALF_FLOAT_OES:null,d=e.FLOAT,u=e.RGBA),{internalFormatFloat:r,internalFormatHalfFloat:a,internalFormatPackedHalfFloat:i,internalFormatPackedFloat:s,textureFormatFloat:o,downloadTextureFormat:u,downloadUnpackNumChannels:l,defaultNumChannels:c,textureTypeHalfFloat:p,textureTypeFloat:d}}function VI(e,t){const n=t();return Ge().getBool("DEBUG")&&function(e){const t=e.getError();if(t!==e.NO_ERROR)throw new Error("WebGL Error: "+function(e,t){switch(t){case e.NO_ERROR:return"NO_ERROR";case e.INVALID_ENUM:return"INVALID_ENUM";case e.INVALID_VALUE:return"INVALID_VALUE";case e.INVALID_OPERATION:return"INVALID_OPERATION";case e.INVALID_FRAMEBUFFER_OPERATION:return"INVALID_FRAMEBUFFER_OPERATION";case e.OUT_OF_MEMORY:return"OUT_OF_MEMORY";case e.CONTEXT_LOST_WEBGL:return"CONTEXT_LOST_WEBGL";default:return`Unknown error code ${t}`}}(e,t))}(e),n}function GI(e){return!!(Ge().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||0===e||5.96e-8e.getExtension(t)),'Extension "'+t+'" not supported on this browser.')}!function(e){e[e.DENSE=0]="DENSE",e[e.SHARED_BATCH=1]="SHARED_BATCH"}(zI||(zI={})),function(e){e[e.RENDER=0]="RENDER",e[e.UPLOAD=1]="UPLOAD",e[e.PIXELS=2]="PIXELS",e[e.DOWNLOAD=3]="DOWNLOAD"}(PI||(PI={})),function(e){e[e.UNPACKED_FLOAT16=0]="UNPACKED_FLOAT16",e[e.UNPACKED_FLOAT32=1]="UNPACKED_FLOAT32",e[e.PACKED_4X1_UNSIGNED_BYTE=2]="PACKED_4X1_UNSIGNED_BYTE",e[e.PACKED_2X2_FLOAT32=3]="PACKED_2X2_FLOAT32",e[e.PACKED_2X2_FLOAT16=4]="PACKED_2X2_FLOAT16"}(HI||(HI={}));const JI=/ERROR: [0-9]+:([0-9]+):/g;function XI(e,t){const n=JI.exec(t);if(null==n)return console.log(`Couldn't parse line number in error: ${t}`),void console.log(e);const r=+n[1],a=e.split("\n"),i=a.length.toString().length+2,s=a.map(((e,t)=>ye((t+1).toString(),i)+e));let o=0;for(let e=0;ee.validateProgram(t))),!1===e.getProgramParameter(t,e.VALIDATE_STATUS))throw console.log(e.getProgramInfoLog(t)),new Error("Shader program validation failed.")}function QI(e,t,n,r,a,i,s){const o=e.getAttribLocation(t,n);return-1!==o&&(VI(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,r))),VI(e,(()=>e.vertexAttribPointer(o,a,e.FLOAT,!1,i,s))),VI(e,(()=>e.enableVertexAttribArray(o))),!0)}function eL(e,t,n,r){VI(e,(()=>function(e,t,n){(function(e,t){const n=e.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,r=t+e.TEXTURE0;if(rn)throw new Error(`textureUnit must be in [gl.TEXTURE0, gl.TEXTURE${n}].`)})(e,n),VI(e,(()=>e.activeTexture(e.TEXTURE0+n))),VI(e,(()=>e.bindTexture(e.TEXTURE_2D,t)))}(e,t,r))),VI(e,(()=>e.uniform1i(n,r)))}function tL(e,t,n){VI(e,(()=>e.bindFramebuffer(e.FRAMEBUFFER,n))),VI(e,(()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)))}function nL(e,t){VI(e,(()=>e.bindFramebuffer(e.FRAMEBUFFER,t))),VI(e,(()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,null,0)))}function rL(e){const t=e.checkFramebufferStatus(e.FRAMEBUFFER);if(t!==e.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+function(e,t){switch(t){case e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case e.FRAMEBUFFER_UNSUPPORTED:return"FRAMEBUFFER_UNSUPPORTED";default:return`unknown error ${t}`}}(e,t))}function aL(e,t,n){const r=VI(e,(()=>t()));if(null==r)throw new Error(n);return r}function iL(e,t=2){return ce(e.slice(0,e.length-t))}function sL(e){if(0===e.length)throw Error("Cannot get rows and columns of an empty shape array.");return[e.length>1?e[e.length-2]:1,e[e.length-1]]}function oL(e){let t=[1,1,1];return 0===e.length||1===e.length&&1===e[0]||(t=[iL(e),...sL(e)]),t}function uL(e){return e%2==0}function lL(e,t){if(de(e=e.slice(-2),t=t.slice(-2)))return!0;if(!e.length||!t.length)return!0;if(0===e[0]||0===e[1]||0===t[0]||0===t[1])return!0;if(e.length!==t.length){const n=e.slice(-1)[0],r=t.slice(-1)[0];if(n===r)return!0;if(uL(n)&&uL(r)&&(1===e[0]||1===t[0]))return!0}return e[1]===t[1]&&uL(e[0])&&uL(t[0])}let cL,pL;function dL(e,t){return null!=e.getExtension(t)}function hL(e){try{if(null!=BI(e))return!0}catch(e){return console.log("Error when getting WebGL context: ",e),!1}return!1}function fL(e){const t=WI(e),n=e.createTexture();e.bindTexture(e.TEXTURE_2D,n),e.texImage2D(e.TEXTURE_2D,0,t.internalFormatFloat,1,1,0,t.textureFormatFloat,t.textureTypeFloat,null);const r=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,r),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0);const a=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(n),e.deleteFramebuffer(r),a}function mL(e,t){Array.isArray(e)||(e=[e]),e.forEach((e=>{null!=e&&se("complex64"!==e.dtype,(()=>`${t} does not support complex64 tensors in the WebGL backend.`))}))}const gL=Ge();function yL(){let e,t,n,r,a,i,s,o,u,l;return 2===Ge().getNumber("WEBGL_VERSION")?(e="#version 300 es",t="in",n="out",r="in",a="texture",i="outputColor",s="out vec4 outputColor;",o="\n bool isnan_custom(float val) {\n uint floatToUint = floatBitsToUint(val);\n return (floatToUint & 0x7fffffffu) > 0x7f800000u;\n }\n\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan_custom(val.x),\n isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w));\n }\n\n #define isnan(value) isnan_custom(value)\n ",u="",l="\n #define round(value) newRound(value)\n int newRound(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 newRound(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n "):(e="",t="attribute",n="varying",r="varying",a="texture2D",i="gl_FragColor",s="",o="\n #define isnan(value) isnan_custom(value)\n bool isnan_custom(float val) {\n return (val > 0. || val < 1. || val == 0.) ? false : true;\n }\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w));\n }\n ",u="\n uniform float INFINITY;\n\n bool isinf(float val) {\n return abs(val) == INFINITY;\n }\n bvec4 isinf(vec4 val) {\n return equal(abs(val), vec4(INFINITY));\n }\n ",l="\n int round(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 round(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n "),{version:e,attribute:t,varyingVs:n,varyingFs:r,texture2D:a,output:i,defineOutput:s,defineSpecialNaN:o,defineSpecialInf:u,defineRound:l}}function bL(e,t,n="index"){const r=Oe(t);return r.map(((t,a)=>`int ${e[a]} = ${n} / ${t}; ${a===r.length-1?`int ${e[a+1]} = ${n} - ${e[a]} * ${t}`:`index -= ${e[a]} * ${t}`};`)).join("")}function vL(e,t,n="index"){const r=Oe(t);return r.map(((t,a)=>`int ${e[a]} = ${n} / outShapeStrides[${a}]; ${a===r.length-1?`int ${e[a+1]} = ${n} - ${e[a]} * outShapeStrides[${a}]`:`index -= ${e[a]} * outShapeStrides[${a}]`};`)).join("")}function xL(e){const t=Oe(e).map((e=>e.toString()));return`\n int getFlatIndex(ivec3 coords) {\n return coords.x * ${t[0]} + coords.y * ${t[1]} + coords.z;\n }\n`}gL.registerFlag("HAS_WEBGL",(()=>gL.getNumber("WEBGL_VERSION")>0)),gL.registerFlag("WEBGL_VERSION",(()=>hL(2)?2:hL(1)?1:0)),gL.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",(()=>!1)),gL.registerFlag("WEBGL_BUFFER_SUPPORTED",(()=>2===gL.get("WEBGL_VERSION"))),gL.registerFlag("WEBGL_CPU_FORWARD",(()=>!0)),gL.registerFlag("WEBGL_FORCE_F16_TEXTURES",(()=>!1)),gL.registerFlag("WEBGL_PACK",(()=>gL.getBool("HAS_WEBGL"))),gL.registerFlag("WEBGL_PACK_NORMALIZATION",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_PACK_CLIP",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_PACK_DEPTHWISECONV",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_PACK_REDUCE",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_LAZILY_UNPACK",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_CONV_IM2COL",(()=>gL.getBool("WEBGL_PACK"))),gL.registerFlag("WEBGL_MAX_TEXTURE_SIZE",(()=>function(e){if(null==cL){const t=BI(e);cL=t.getParameter(t.MAX_TEXTURE_SIZE)}return cL}(gL.getNumber("WEBGL_VERSION")))),gL.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",(()=>function(e){if(null==pL){const t=BI(e);pL=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,pL)}(gL.getNumber("WEBGL_VERSION")))),gL.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",(()=>{const e=gL.getNumber("WEBGL_VERSION");return 0===e?0:function(e){if(0===e)return 0;let t;const n=BI(e);return t=dL(n,"EXT_disjoint_timer_query_webgl2")&&2===e?2:dL(n,"EXT_disjoint_timer_query")?1:0,t}(e)})),gL.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",(()=>gL.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!Mi())),gL.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",(()=>function(e){if(0===e)return!1;const t=BI(e);if(1===e){if(!dL(t,"OES_texture_float"))return!1}else if(!dL(t,"EXT_color_buffer_float"))return!1;return fL(t)}(gL.getNumber("WEBGL_VERSION")))),gL.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",(()=>!gL.getBool("WEBGL_FORCE_F16_TEXTURES")&&gL.getBool("WEBGL_RENDER_FLOAT32_CAPABLE"))),gL.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",(()=>function(e){if(0===e)return!1;const t=BI(e);if(1!==e){if(dL(t,"EXT_color_buffer_float"))return fL(t);const e="EXT_color_buffer_half_float";if(dL(t,e)){const n=t.getExtension(e);return function(e,t){const n=WI(e,t),r=e.createTexture();e.bindTexture(e.TEXTURE_2D,r),e.texImage2D(e.TEXTURE_2D,0,n.internalFormatHalfFloat,1,1,0,n.textureFormatFloat,n.textureTypeHalfFloat,null);const a=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,a),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,r,0);const i=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(r),e.deleteFramebuffer(a),i}(t,n)}return!1}return!!dL(t,"OES_texture_float")&&!!dL(t,"WEBGL_color_buffer_float")&&fL(t)}(gL.getNumber("WEBGL_VERSION")))),gL.registerFlag("WEBGL_FENCE_API_ENABLED",(()=>{return 2===(e=gL.getNumber("WEBGL_VERSION"))&&null!=BI(e).fenceSync;var e})),gL.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",(()=>gL.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0)),gL.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD",(()=>-1),(e=>{if(e<0&&-1!==e)throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never delete) or at least 0, but got ${e}.`)})),gL.registerFlag("WEBGL_FLUSH_THRESHOLD",(()=>Mi()?1:-1),(e=>{if(e<0&&-1!==e)throw new Error(`WEBGL_FLUSH_THRESHOLD must be -1 (indicating never manual flush) or at least 0, but got ${e}.`)})),gL.registerFlag("CPU_HANDOFF_SIZE_THRESHOLD",(()=>128)),gL.registerFlag("WEBGL_USE_SHAPES_UNIFORMS",(()=>!1)),gL.registerFlag("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD",(()=>1e5)),gL.registerFlag("TOPK_K_CPU_HANDOFF_THRESHOLD",(()=>128));const _L="\n const float FLOAT_MAX = 1.70141184e38;\n const float FLOAT_MIN = 1.17549435e-38;\n\n lowp vec4 encode_float(highp float v) {\n if (isnan(v)) {\n return vec4(255, 255, 255, 255);\n }\n\n highp float av = abs(v);\n\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 255.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n highp float e = floor(log2(av));\n highp float m = exp2(fract(log2(av))) - 1.0;\n\n c[2] = floor(128.0 * m);\n m -= c[2] / 128.0;\n c[1] = floor(32768.0 * m);\n m -= c[1] / 32768.0;\n c[0] = floor(8388608.0 * m);\n\n highp float ebias = e + 127.0;\n c[3] = floor(ebias / 2.0);\n ebias -= c[3] * 2.0;\n c[2] += floor(ebias) * 128.0;\n\n c[3] += 128.0 * step(0.0, -v);\n\n return c / 255.0;\n }\n",{getBroadcastDims:wL}=g;function DL(e,t,n){const r=[];if(e.forEach((e=>{const t=ce(e.shapeInfo.logicalShape);if(e.shapeInfo.isUniform?r.push(`uniform float ${e.name}${t>1?`[${t}]`:""};`):(r.push(`uniform sampler2D ${e.name};`),r.push(`uniform int offset${e.name};`)),n.enableShapeUniforms){const{uniformShape:t}=LL(n.packedInputs,e.shapeInfo.logicalShape,e.shapeInfo.texShape);switch(t.length){case 1:r.push(`uniform int ${e.name}Shape;`);break;case 2:r.push(`uniform ivec2 ${e.name}Shape;`);break;case 3:r.push(`uniform ivec3 ${e.name}Shape;`);break;case 4:r.push(`uniform ivec4 ${e.name}Shape;`)}r.push(`uniform ivec2 ${e.name}TexShape;`)}})),n.enableShapeUniforms){switch(t.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;")}r.push("uniform ivec2 outTexShape;")}n.customUniforms&&n.customUniforms.forEach((e=>{r.push(`uniform ${e.type} ${e.name}${e.arrayIndex?`[${e.arrayIndex}]`:""};`)}));const a=r.join("\n"),i=e.map((e=>function(e,t,n=!1,r){let a="";a+=n?ML(e,r):NL(e,r);const i=e.shapeInfo.logicalShape,s=t.logicalShape;return i.length<=s.length&&(a+=n?function(e,t){const n=e.name,r=n.charAt(0).toUpperCase()+n.slice(1),a="get"+r+"AtOutCoords",i=e.shapeInfo.logicalShape.length,s=t.logicalShape.length,o=wL(e.shapeInfo.logicalShape,t.logicalShape),u=IL(s),l=s-i;let c;const p=["x","y","z","w","u","v"];c=0===i?"":s<2&&o.length>=1?"coords = 0;":o.map((e=>`coords.${p[e+l]} = 0;`)).join("\n");let d="";d=s<2&&i>0?"coords":e.shapeInfo.logicalShape.map(((e,t)=>`coords.${p[t+l]}`)).join(", ");let h="return outputValue;";const f=1===ce(e.shapeInfo.logicalShape),m=1===ce(t.logicalShape);if(1!==i||f||m){if(f&&!m)h=1===s?"\n return vec4(outputValue.x, outputValue.x, 0., 0.);\n ":"\n return vec4(outputValue.x);\n ";else if(o.length){const e=i-2,t=i-1;o.indexOf(e)>-1&&o.indexOf(t)>-1?h="return vec4(outputValue.x);":o.indexOf(e)>-1?h="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":o.indexOf(t)>-1&&(h="return vec4(outputValue.xx, outputValue.zz);")}}else h="\n return vec4(outputValue.xy, outputValue.xy);\n ";return`\n vec4 ${a}() {\n ${u} coords = getOutputCoords();\n ${c}\n vec4 outputValue = get${r}(${d});\n ${h}\n }\n `}(e,t):function(e,t){const n=e.name,r=n.charAt(0).toUpperCase()+n.slice(1),a="get"+r+"AtOutCoords",i=t.texShape,s=e.shapeInfo.texShape,o=e.shapeInfo.logicalShape.length,u=t.logicalShape.length;if(!e.shapeInfo.isUniform&&o===u&&null==e.shapeInfo.flatOffset&&de(s,i))return`\n float ${a}() {\n return sampleTexture(${n}, resultUV);\n }\n `;const l=IL(u),c=wL(e.shapeInfo.logicalShape,t.logicalShape),p=u-o;let d;const h=["x","y","z","w","u","v"];d=0===o?"":u<2&&c.length>=1?"coords = 0;":c.map((e=>`coords.${h[e+p]} = 0;`)).join("\n");let f="";return f=u<2&&o>0?"coords":e.shapeInfo.logicalShape.map(((e,t)=>`coords.${h[t+p]}`)).join(", "),`\n float ${a}() {\n ${l} coords = getOutputCoords();\n ${d}\n return get${r}(${f});\n }\n `}(e,t)),a}(e,t,n.packedInputs,n.enableShapeUniforms))).join("\n"),s=t.texShape,o=yL(),u=function(e){return`\n float sampleTexture(sampler2D textureSampler, vec2 uv) {\n return ${e.texture2D}(textureSampler, uv).r;\n }\n `}(o);let l,c,p=function(e){return`${e.version}\n precision highp float;\n precision highp int;\n precision highp sampler2D;\n ${e.varyingFs} vec2 resultUV;\n ${e.defineOutput}\n const vec2 halfCR = vec2(0.5, 0.5);\n\n struct ivec5\n {\n int x;\n int y;\n int z;\n int w;\n int u;\n };\n\n struct ivec6\n {\n int x;\n int y;\n int z;\n int w;\n int u;\n int v;\n };\n\n uniform float NAN;\n ${e.defineSpecialNaN}\n ${e.defineSpecialInf}\n ${e.defineRound}\n\n int imod(int x, int y) {\n return x - y * (x / y);\n }\n\n int idiv(int a, int b, float sign) {\n int res = a / b;\n int mod = imod(a, b);\n if (sign < 0. && mod != 0) {\n res -= 1;\n }\n return res;\n }\n\n //Based on the work of Dave Hoskins\n //https://www.shadertoy.com/view/4djSRW\n #define HASHSCALE1 443.8975\n float random(float seed){\n vec2 p = resultUV * seed;\n vec3 p3 = fract(vec3(p.xyx) * HASHSCALE1);\n p3 += dot(p3, p3.yzx + 19.19);\n return fract((p3.x + p3.y) * p3.z);\n }\n\n ${SL}\n ${kL}\n ${TL}\n `}(o);return t.isPacked?(l=function(e,t,n){switch(e.length){case 0:return"\n int getOutputCoords() {\n return 0;\n }\n ";case 1:return function(e,t,n){const r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];return 1===r[0]?n?"\n int getOutputCoords() {\n return 2 * int(resultUV.x * ceil(float(outTexShape[1]) / 2.0));\n }\n ":`\n int getOutputCoords() {\n return 2 * int(resultUV.x * ${r[1]}.0);\n }\n `:1===r[1]?n?"\n int getOutputCoords() {\n return 2 * int(resultUV.y * ceil(float(outTexShape[0]) / 2.0));\n }\n ":`\n int getOutputCoords() {\n return 2 * int(resultUV.y * ${r[0]}.0);\n }\n `:n?"\n int getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n return 2 * (resTexRC.x * packedTexShape[1] + resTexRC.y);\n }\n ":`\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n return 2 * (resTexRC.x * ${r[1]} + resTexRC.y);\n }\n `}(0,t,n);case 2:return function(e,t,n){const r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];if(de(e,t))return n?"\n ivec2 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n return 2 * ivec2(resultUV.yx * vec2(packedTexShape[0], packedTexShape[1]));\n }\n ":`\n ivec2 getOutputCoords() {\n return 2 * ivec2(resultUV.yx * vec2(${r[0]}, ${r[1]}));\n }\n `;const a=Math.ceil(e[1]/2);return n?"\n ivec2 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n int texelsInLogicalRow = int(ceil(float(outShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec2(r, c);\n }\n ":`\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n\n int index = resTexRC.x * ${r[1]} + resTexRC.y;\n int r = 2 * (index / ${a});\n int c = imod(index, ${a}) * 2;\n\n return ivec2(r, c);\n }\n `}(e,t,n);case 3:return function(e,t,n){if(n)return"\n ivec3 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n int texelsInLogicalRow = int(ceil(float(outShape[2]) / 2.0));\n int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n\n int b = index / texelsInBatch;\n index -= b * texelsInBatch;\n\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec3(b, r, c);\n }\n ";const r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],a=Math.ceil(e[2]/2),i=a*Math.ceil(e[1]/2);return`\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n int index = resTexRC.x * ${r[1]} + resTexRC.y;\n\n int b = index / ${i};\n index -= b * ${i};\n\n int r = 2 * (index / ${a});\n int c = imod(index, ${a}) * 2;\n\n return ivec3(b, r, c);\n }\n `}(e,t,n);default:return function(e,t,n){if(n)return"\n ivec4 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n\n int texelsInLogicalRow = int(ceil(float(outShape[3]) / 2.0));\n int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[2]) / 2.0));\n int texelsInBatchN = texelsInBatch * outShape[1];\n\n int b2 = index / texelsInBatchN;\n index -= b2 * texelsInBatchN;\n\n int b = index / texelsInBatch;\n index -= b * texelsInBatch;\n\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec4(b2, b, r, c);\n }\n ";const r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],a=Math.ceil(e[e.length-1]/2),i=a*Math.ceil(e[e.length-2]/2);let s=i,o="",u="b, r, c";for(let t=2;t1&&!de(t,n)&&r.lengthe[t])).join(", ")}function OL(e,t,n){const r={},a={},i={},s=[];let o,u,l,c=null,p=null;p=e.getUniformLocation(n,"NAN",!1),1===Ge().getNumber("WEBGL_VERSION")&&(c=e.getUniformLocation(n,"INFINITY",!1));const d=!1;for(let s=0;s{s[r]=e.getUniformLocation(n,t.name,d)})),{uniformLocations:r,customUniformLocations:s,infLoc:c,nanLoc:p,inShapesLocations:a,inTexShapesLocations:i,outShapeLocation:o,outShapeStridesLocation:l,outTexShapeLocation:u}}function RL(e,t){if(e.length!==t.length)throw Error(`Binary was compiled with ${e.length} inputs, but was executed with ${t.length} inputs`);e.forEach(((e,n)=>{const r=e.logicalShape,a=t[n],i=a.shape;if(!de(r,i))throw Error(`Binary was compiled with different shapes than the current args. Shapes ${r} and ${i} must match`);if(e.isUniform&&a.isUniform)return;const s=e.texShape,o=a.isUniform?null:a.texData.texShape;if(!de(s,o))throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${s} and ${o} must match`)}))}function YL(e){return Ge().getBool("WEBGL_USE_SHAPES_UNIFORMS")&&e<=4}class BL{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=zI.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const t=yL();this.outputShape=e,this.enableShapeUniforms=YL(this.outputShape.length),this.userCode=`\n ivec3 outCoordsFromFlatIndex(int index) {\n ${this.enableShapeUniforms?vL(["r","c","d"],e):bL(["r","c","d"],e)}\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));\n int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y);\n\n vec4 result = vec4(0.);\n\n for (int i=0; i<4; i++) {\n int flatIndex = index + i;\n ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n result[i] = getA(rc.x, rc.y, rc.z);\n }\n\n ${t.output} = result;\n }\n `}}class zL{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=zI.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const t=yL();this.outputShape=e,this.enableShapeUniforms=YL(this.outputShape.length),this.userCode=`\n ivec3 outCoordsFromFlatIndex(int index) {\n ${this.enableShapeUniforms?vL(["r","c","d"],e):bL(["r","c","d"],e)}\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));\n int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y);\n\n vec4 result = vec4(0.);\n\n for (int i=0; i<4; i++) {\n int flatIndex = index + i;\n ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z));\n }\n\n ${t.output} = result;\n }\n `}}class PL{constructor(e){this.variableNames=["A"],this.outTexUsage=PI.DOWNLOAD;const t=yL();this.outputShape=e,this.userCode=`\n ${_L}\n\n void main() {\n float x = getAAtOutCoords();\n ${t.output} = encode_float(x);\n }\n `}}class HL{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=PI.DOWNLOAD;const t=yL();this.outputShape=e,this.userCode=`\n ${_L}\n\n void main() {\n ivec3 coords = getOutputCoords();\n float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));\n ${t.output} = encode_float(x);\n }\n `}}class jL{constructor(e,t=!1){this.variableNames=["A"],this.customUniforms=[{name:"texShape",type:"ivec2"}];const n=yL();this.outputShape=e,this.enableShapeUniforms=YL(this.outputShape.length);let r="result";t&&(r="floor(result * 255. + 0.5)"),this.userCode=`\n ${this.enableShapeUniforms?"\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n":xL(e)}\n\n void main() {\n ivec3 coords = getOutputCoords();\n\n int flatIndex = getFlatIndex(coords);\n int offset = imod(flatIndex, 4);\n\n flatIndex = idiv(flatIndex, 4, 1.);\n\n int r = flatIndex / texShape[1];\n int c = imod(flatIndex, texShape[1]);\n vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);\n vec4 values = ${n.texture2D}(A, uv);\n\n float result;\n\n if(offset == 0) {\n result = values[0];\n } else if(offset == 1) {\n result = values[1];\n } else if(offset == 2) {\n result = values[2];\n } else {\n result = values[3];\n }\n\n ${n.output} = vec4(${r}, 0., 0., 0.);\n }\n `}}class UL{constructor(e,t=!1){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.customUniforms=[{name:"texShape",type:"ivec2"}];const n=yL();this.outputShape=e,this.enableShapeUniforms=YL(this.outputShape.length);let r="",a="result";t&&(a="floor(result * 255. + 0.5)");for(let t=0;t<=1;t++)for(let a=0;a<=1;a++){const i=2*t+a;r+=`\n localCoords = coords;\n if(localCoords[2] + ${a} < ${this.enableShapeUniforms?"outShape[2]":`${e[2]}`}) {\n localCoords[2] += ${a};\n if (localCoords[1] + ${t} < ${this.enableShapeUniforms?"outShape[1]":`${e[1]}`}) {\n localCoords[1] += ${t};\n\n flatIndex = getFlatIndex(localCoords);\n offset = imod(flatIndex, 4);\n\n flatIndex = idiv(flatIndex, 4, 1.);\n\n int r = flatIndex / texShape[1];\n int c = imod(flatIndex, texShape[1]);\n vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);\n values = ${n.texture2D}(A, uv);\n\n if (offset == 0) {\n result[${i}] = values[0];\n } else if (offset == 1) {\n result[${i}] = values[1];\n } else if (offset == 2) {\n result[${i}] = values[2];\n } else {\n result[${i}] = values[3];\n }\n }\n }\n `}this.userCode=`\n ${this.enableShapeUniforms?"\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n":xL(e)}\n\n void main() {\n ivec3 coords = getOutputCoords();\n\n vec4 result = vec4(0.);\n int flatIndex, r, c, offset;\n ivec3 localCoords;\n vec2 uv;\n vec4 values;\n\n ${r}\n\n ${n.output} = ${a};\n }\n `}}function qL(e,t,n,r,a,i){!function(e,t){const n=Ge().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(e<=0||t<=0)throw new Error(`Requested texture size [${e}x${t}] is invalid.`);if(e>n||t>n)throw new Error(`Requested texture size [${e}x${t}] greater than WebGL maximum on this browser / GPU [${n}x${n}].`)}(t,n);const s=function(e){return aL(e,(()=>e.createTexture()),"Unable to create WebGLTexture.")}(e),o=e.TEXTURE_2D;return VI(e,(()=>e.bindTexture(o,s))),VI(e,(()=>e.texParameteri(o,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE))),VI(e,(()=>e.texParameteri(o,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE))),VI(e,(()=>e.texParameteri(o,e.TEXTURE_MIN_FILTER,e.NEAREST))),VI(e,(()=>e.texParameteri(o,e.TEXTURE_MAG_FILTER,e.NEAREST))),1===Ge().getNumber("WEBGL_VERSION")?VI(e,(()=>e.texImage2D(o,0,r,t,n,0,a,i,null))):VI(e,(()=>e.texStorage2D(o,1,r,t,n))),VI(e,(()=>e.bindTexture(e.TEXTURE_2D,null))),{texture:s,texShape:[n,t]}}function WL(e){return e.internalFormatFloat}function VL(e){return e.internalFormatHalfFloat}function GL(e){return e.downloadTextureFormat}function KL(e){return e.internalFormatPackedFloat}function JL(e){return e.internalFormatPackedHalfFloat}class XL{constructor(e){this.outputTexture=null,this.program=null,this.disposed=!1,this.vertexAttrsAreBound=!1,this.itemsToPoll=[];const t=Ge().getNumber("WEBGL_VERSION");null!=e?(this.gl=e,function(e,t){RI[e]=t}(t,e)):this.gl=BI(t);let n="WEBGL_color_buffer_float";const r="EXT_color_buffer_half_float";if(this.parallelCompilationExtension=this.gl.getExtension("KHR_parallel_shader_compile"),1===Ge().getNumber("WEBGL_VERSION")){const e="OES_texture_float",t="OES_texture_half_float";if(this.textureFloatExtension=KI(this.gl,e),dL(this.gl,t))this.textureHalfFloatExtension=KI(this.gl,t);else if(Ge().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(n),dL(this.gl,r))this.colorBufferHalfFloatExtension=KI(this.gl,r);else if(Ge().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(n="EXT_color_buffer_float",dL(this.gl,n))this.colorBufferFloatExtension=this.gl.getExtension(n);else{if(!dL(this.gl,r))throw new Error("GL context does not support color renderable floats");this.colorBufferHalfFloatExtension=this.gl.getExtension(r)}this.vertexBuffer=function(e){return function(e,t){const n=aL(e,(()=>e.createBuffer()),"Unable to create WebGLBuffer");return VI(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,n))),VI(e,(()=>e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW))),n}(e,new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]))}(this.gl),this.indexBuffer=function(e){return function(e,t){const n=aL(e,(()=>e.createBuffer()),"Unable to create WebGLBuffer");return VI(e,(()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n))),VI(e,(()=>e.bufferData(e.ELEMENT_ARRAY_BUFFER,t,e.STATIC_DRAW))),n}(e,new Uint16Array([0,1,2,2,1,3]))}(this.gl),this.framebuffer=function(e){return aL(e,(()=>e.createFramebuffer()),"Unable to create WebGLFramebuffer.")}(this.gl),this.textureConfig=WI(this.gl,this.textureHalfFloatExtension)}get debug(){return Ge().getBool("DEBUG")}dispose(){if(this.disposed)return;null!=this.program&&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."),null!=this.outputTexture&&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;VI(e,(()=>e.finish())),VI(e,(()=>e.bindFramebuffer(e.FRAMEBUFFER,null))),VI(e,(()=>e.deleteFramebuffer(this.framebuffer))),VI(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,null))),VI(e,(()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null))),VI(e,(()=>e.deleteBuffer(this.indexBuffer))),this.disposed=!0}createFloat32MatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,i]=jI(t,n);return qL(e,a,i,WL(r),r.textureFormatFloat,e.FLOAT)}(this.gl,e,t,this.textureConfig)}createFloat16MatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,i]=jI(t,n);return qL(e,a,i,VL(r),r.textureFormatFloat,r.textureTypeHalfFloat)}(this.gl,e,t,this.textureConfig)}createUnsignedBytesMatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,i]=jI(t,n);return qL(e,a,i,GL(r),e.RGBA,e.UNSIGNED_BYTE)}(this.gl,e,t,this.textureConfig)}uploadPixelDataToTexture(e,t){this.throwIfDisposed(),function(e,t,n){VI(e,(()=>e.bindTexture(e.TEXTURE_2D,t))),n.data instanceof Uint8Array?2===Ge().getNumber("WEBGL_VERSION")?VI(e,(()=>e.texSubImage2D(e.TEXTURE_2D,0,0,0,n.width,n.height,e.RGBA,e.UNSIGNED_BYTE,n.data))):VI(e,(()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,n.width,n.height,0,e.RGBA,e.UNSIGNED_BYTE,n.data))):2===Ge().getNumber("WEBGL_VERSION")?VI(e,(()=>e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,n))):VI(e,(()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n))),VI(e,(()=>e.bindTexture(e.TEXTURE_2D,null)))}(this.gl,e,t)}uploadDenseMatrixToTexture(e,t,n,r){this.throwIfDisposed(),function(e,t,n,r,a,i){let s,o,u;VI(e,(()=>e.bindTexture(e.TEXTURE_2D,t))),a instanceof Uint8Array?(s=new Uint8Array(n*r*4),o=e.UNSIGNED_BYTE,u=e.RGBA):(s=new Float32Array(n*r*4),o=e.FLOAT,u=i.internalFormatPackedFloat),s.set(a),2===Ge().getNumber("WEBGL_VERSION")?VI(e,(()=>e.texSubImage2D(e.TEXTURE_2D,0,0,0,n,r,e.RGBA,o,s))):VI(e,(()=>e.texImage2D(e.TEXTURE_2D,0,u,n,r,0,e.RGBA,o,s))),VI(e,(()=>e.bindTexture(e.TEXTURE_2D,null)))}(this.gl,e,t,n,r,this.textureConfig)}createFloat16PackedMatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,i]=qI(t,n);return qL(e,a,i,JL(r),e.RGBA,r.textureTypeHalfFloat)}(this.gl,e,t,this.textureConfig)}createPackedMatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,i]=qI(t,n);return qL(e,a,i,KL(r),e.RGBA,e.FLOAT)}(this.gl,e,t,this.textureConfig)}deleteMatrixTexture(e){this.throwIfDisposed(),this.outputTexture===e&&(nL(this.gl,this.framebuffer),this.outputTexture=null),VI(this.gl,(()=>this.gl.deleteTexture(e)))}downloadByteEncodedFloatMatrixFromOutputTexture(e,t,n){return this.downloadMatrixDriver(e,(()=>function(e,t,n,r){const[a,i]=jI(t,n),s=new Uint8Array(t*n*4);return VI(e,(()=>e.readPixels(0,0,a,i,r.downloadTextureFormat,e.UNSIGNED_BYTE,s))),new Float32Array(s.buffer)}(this.gl,t,n,this.textureConfig)))}downloadPackedMatrixFromBuffer(e,t,n,r,a,i){return function(e,t,n,r,a,i,s,o){const u=e,l=new Float32Array(function(e,t){const[n,r]=qI(e,t);return n*r*4}(i,s));return u.bindBuffer(u.PIXEL_PACK_BUFFER,t),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,l),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),l}(this.gl,e,0,0,0,a,i,this.textureConfig)}downloadFloat32MatrixFromBuffer(e,t){return function(e,t,n){const r=e,a=new Float32Array(n);return r.bindBuffer(r.PIXEL_PACK_BUFFER,t),r.getBufferSubData(r.PIXEL_PACK_BUFFER,0,a),r.bindBuffer(r.PIXEL_PACK_BUFFER,null),a}(this.gl,e,t)}createBufferFromTexture(e,t,n){this.bindTextureToFrameBuffer(e);const r=function(e,t,n,r){const a=e.createBuffer();VI(e,(()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,a)));const i=16*t*n;return VI(e,(()=>e.bufferData(e.PIXEL_PACK_BUFFER,i,e.STREAM_READ))),VI(e,(()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,0))),VI(e,(()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,null))),a}(this.gl,t,n,this.textureConfig);return this.unbindTextureToFrameBuffer(),r}createAndWaitForFence(){const e=this.createFence(this.gl);return this.pollFence(e)}createFence(e){let t,n;if(Ge().getBool("WEBGL_FENCE_API_ENABLED")){const r=e,a=r.fenceSync(r.SYNC_GPU_COMMANDS_COMPLETE,0);e.flush(),n=()=>{const e=r.clientWaitSync(a,0,0);return e===r.ALREADY_SIGNALED||e===r.CONDITION_SATISFIED},t=a}else Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(t=this.beginQuery(),this.endQuery(),n=()=>this.isQueryAvailable(t,Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))):n=()=>!0;return{query:t,isFencePassed:n}}downloadMatrixFromPackedTexture(e,t,n){return this.downloadMatrixDriver(e,(()=>function(e,t,n){const r=new Float32Array(t*n*4);return VI(e,(()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,r))),r}(this.gl,t,n)))}createProgram(e){this.throwIfDisposed();const t=this.gl;null==this.vertexShader&&(this.vertexShader=function(e){const t=yL();return function(e,t){const n=aL(e,(()=>e.createShader(e.VERTEX_SHADER)),"Unable to create vertex WebGLShader.");if(VI(e,(()=>e.shaderSource(n,t))),VI(e,(()=>e.compileShader(n))),!1===e.getShaderParameter(n,e.COMPILE_STATUS))throw console.log(e.getShaderInfoLog(n)),new Error("Failed to compile vertex shader.");return n}(e,`${t.version}\n precision highp float;\n ${t.attribute} vec3 clipSpacePos;\n ${t.attribute} vec2 uv;\n ${t.varyingVs} vec2 resultUV;\n\n void main() {\n gl_Position = vec4(clipSpacePos, 1);\n resultUV = uv;\n }`)}(t));const n=function(e){return aL(e,(()=>e.createProgram()),"Unable to create WebGLProgram.")}(t);return VI(t,(()=>t.attachShader(n,this.vertexShader))),VI(t,(()=>t.attachShader(n,e))),function(e,t){if(VI(e,(()=>e.linkProgram(t))),!Ge().get("ENGINE_COMPILE_ONLY")&&!1===e.getProgramParameter(t,e.LINK_STATUS))throw console.log(e.getProgramInfoLog(t)),new Error("Failed to link vertex and fragment shaders.")}(t,n),this.debug&&ZI(t,n),this.vertexAttrsAreBound||(this.setProgram(n),this.vertexAttrsAreBound=function(e,t,n){return VI(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,n))),QI(e,t,"clipSpacePos",n,3,20,0)&&QI(e,t,"uv",n,2,20,12)}(t,this.program,this.vertexBuffer)),n}deleteProgram(e){this.throwIfDisposed(),e===this.program&&(this.program=null),null!=e&&VI(this.gl,(()=>this.gl.deleteProgram(e)))}setProgram(e){this.throwIfDisposed(),this.program=e,null!=this.program&&this.debug&&ZI(this.gl,this.program),VI(this.gl,(()=>this.gl.useProgram(e)))}getUniformLocation(e,t,n=!0){return this.throwIfDisposed(),n?function(e,t,n){return aL(e,(()=>e.getUniformLocation(t,n)),'uniform "'+n+'" not present in program.')}(this.gl,e,t):function(e,t,n){return e.getUniformLocation(t,n)}(this.gl,e,t)}getAttributeLocation(e,t){return this.throwIfDisposed(),VI(this.gl,(()=>this.gl.getAttribLocation(e,t)))}getUniformLocationNoThrow(e,t){return this.throwIfDisposed(),this.gl.getUniformLocation(e,t)}setInputMatrixTexture(e,t,n){this.throwIfDisposed(),this.throwIfNoProgram(),eL(this.gl,e,t,n)}setOutputMatrixTexture(e,t,n){this.setOutputMatrixTextureDriver(e,n,t)}setOutputPackedMatrixTexture(e,t,n){this.throwIfDisposed();const[r,a]=qI(t,n);this.setOutputMatrixTextureDriver(e,r,a)}setOutputMatrixWriteRegion(e,t,n,r){this.setOutputMatrixWriteRegionDriver(n,e,r,t)}setOutputPackedMatrixWriteRegion(e,t,n,r){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")}debugValidate(){null!=this.program&&ZI(this.gl,this.program),rL(this.gl)}executeProgram(){this.throwIfDisposed(),this.throwIfNoProgram();const e=this.gl;this.debug&&this.debugValidate(),VI(e,(()=>e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0)))}blockUntilAllProgramsCompleted(){this.throwIfDisposed(),VI(this.gl,(()=>this.gl.finish()))}getQueryTimerExtension(){return null==this.disjointQueryTimerExtension&&(this.disjointQueryTimerExtension=KI(this.gl,2===Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension}getQueryTimerExtensionWebGL2(){return this.getQueryTimerExtension()}getQueryTimerExtensionWebGL1(){return this.getQueryTimerExtension()}beginQuery(){if(2===Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){const e=this.gl,t=this.getQueryTimerExtensionWebGL2(),n=e.createQuery();return e.beginQuery(t.TIME_ELAPSED_EXT,n),n}const e=this.getQueryTimerExtensionWebGL1(),t=e.createQueryEXT();return e.beginQueryEXT(e.TIME_ELAPSED_EXT,t),t}endQuery(){if(2===Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){const e=this.gl,t=this.getQueryTimerExtensionWebGL2();return void e.endQuery(t.TIME_ELAPSED_EXT)}const e=this.getQueryTimerExtensionWebGL1();e.endQueryEXT(e.TIME_ELAPSED_EXT)}async waitForQueryAndGetTime(e){return await be((()=>this.disposed||this.isQueryAvailable(e,Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")))),this.getQueryTime(e,Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}getQueryTime(e,t){if(0===t)return null;if(2===t){const t=this.gl;return t.getQueryParameter(e,t.QUERY_RESULT)/1e6}{const t=this.getQueryTimerExtensionWebGL1();return t.getQueryObjectEXT(e,t.QUERY_RESULT_EXT)/1e6}}isQueryAvailable(e,t){if(0===t)return!0;if(2===t){const t=this.gl,n=this.getQueryTimerExtensionWebGL2(),r=t.getQueryParameter(e,t.QUERY_RESULT_AVAILABLE);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(n.GPU_DISJOINT_EXT)),r&&!this.disjoint}{const t=this.getQueryTimerExtensionWebGL1(),n=t.getQueryObjectEXT(e,t.QUERY_RESULT_AVAILABLE_EXT);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(t.GPU_DISJOINT_EXT)),n&&!this.disjoint}}pollFence(e){return new Promise((t=>{this.addItemToPoll((()=>e.isFencePassed()),(()=>t()))}))}pollItems(){const e=function(e){let t=0;for(;te.isDoneFn)));for(let t=0;t<=e;++t){const{resolveFn:e}=this.itemsToPoll[t];e()}this.itemsToPoll=this.itemsToPoll.slice(e+1)}addItemToPoll(e,t){this.itemsToPoll.push({isDoneFn:e,resolveFn:t}),this.itemsToPoll.length>1||be((()=>(this.pollItems(),0===this.itemsToPoll.length)))}bindTextureToFrameBuffer(e){this.throwIfDisposed(),tL(this.gl,e,this.framebuffer),this.debug&&rL(this.gl)}unbindTextureToFrameBuffer(){null!=this.outputTexture?(tL(this.gl,this.outputTexture,this.framebuffer),this.debug&&rL(this.gl)):nL(this.gl,this.framebuffer)}downloadMatrixDriver(e,t){this.bindTextureToFrameBuffer(e);const n=t();return this.unbindTextureToFrameBuffer(),n}setOutputMatrixTextureDriver(e,t,n){this.throwIfDisposed();const r=this.gl;tL(r,e,this.framebuffer),this.debug&&rL(r),this.outputTexture=e,VI(r,(()=>r.viewport(0,0,t,n))),VI(r,(()=>r.scissor(0,0,t,n)))}setOutputMatrixWriteRegionDriver(e,t,n,r){this.throwIfDisposed(),VI(this.gl,(()=>this.gl.scissor(e,t,n,r)))}throwIfDisposed(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.")}throwIfNoProgram(){if(null==this.program)throw new Error("No GPU program is currently set.")}}const{addImpl:ZL,bincountImpl:QL,bincountReduceImpl:eF,ceilImpl:tF,concatImpl:nF,equalImpl:rF,expImpl:aF,expm1Impl:iF,floorImpl:sF,gatherNdImpl:oF,gatherV2Impl:uF,greaterImpl:lF,greaterEqualImpl:cF,lessImpl:pF,lessEqualImpl:dF,linSpaceImpl:hF,logImpl:fF,maxImpl:mF,maximumImpl:gF,minimumImpl:yF,multiplyImpl:bF,negImpl:vF,notEqualImpl:xF,prodImpl:_F,rangeImpl:wF,rsqrtImpl:DF,scatterImpl:NF,sigmoidImpl:MF,simpleAbsImpl:SF,sliceImpl:kF,sparseFillEmptyRowsImpl:TF,sparseReshapeImpl:CF,sparseSegmentReductionImpl:EF,sqrtImpl:AF,stridedSliceImpl:IF,stringNGramsImpl:LF,stringSplitImpl:FF,stringToHashBucketFastImpl:$F,subImpl:OF,tileImpl:RF,topKImpl:YF,transposeImpl:BF,uniqueImpl:zF}=q;function PF(e,t){return["x","y","z","w","u","v"].slice(0,t).map((t=>`${e}.${t}`))}function HF(e,t){return 1===t?[e]:PF(e,t)}class jF{constructor(e){if(this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=e,this.rank=e.length,this.enableShapeUniforms=YL(this.outputShape.length),0===this.rank)this.userCode="\n void main() {\n setOutput(vec4(getA(), 0., 0., 0.));\n }\n ";else{const e=HF("rc",this.rank),t=IL(this.rank),n=this.getOutOfBoundsCondition(e),r=this.getSetup(e),a=this.getOutput(e);this.userCode=`\n void main() {\n ${t} rc = getOutputCoords();\n\n if(${n}) {\n setOutput(vec4(0));\n } else {\n ${r}\n\n setOutput(vec4(${a}));\n }\n }\n `}}getSourceCoordsArr(e){const t=[];for(let n=0;n<=1;n++)for(let r=0;r<=1;r++){let a=`${0===n?"r":"rp1"}, ${0===r?"c":"cp1"}`;for(let t=2;t ${this.enableShapeUniforms?"outShape":this.outputShape[0]}`;let t="";for(let n=this.rank-2;n= ${this.enableShapeUniforms?`outShape[${n}]`:this.outputShape[n]}`,n= ${n};\n bool rEdge = rp1 >= ${r};\n `}getOutput(e){const t=this.getSourceCoordsArr(e);return 1===this.rank?`getA(rc), (rc + 1 >= ${this.enableShapeUniforms?"outShape":this.outputShape[0]} ? 0. : getA(rc + 1)), 0, 0`:`getA(${t[0]}),\n cEdge ? 0. : getA(${t[1]}),\n rEdge ? 0. : getA(${t[2]}),\n rEdge || cEdge ? 0. : getA(${t[3]})`}}class UF{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec3"}],this.outputShape=e,this.enableShapeUniforms=YL(this.outputShape.length);let n="";for(let e=0;e<4;e++){let t="thisRC = rc;";e%2==1&&(t+="thisRC.z += 1;"),e>1&&(t+="thisRC.y += 1;"),n+=`\n ${t}\n ${e>0?"if(thisRC.y < rows && thisRC.z < cols){":""}\n int flatIndex = getFlatIndex(thisRC);\n\n ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex);\n vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z));\n\n result[${e}] =\n getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);\n ${e>0?"}":""}\n `}var r,a;this.userCode=`\n ${r=t,a=this.enableShapeUniforms,`\n ivec3 inputCoordsFromReshapedOutCoords(int index) {\n ${a?function(e,t,n="index"){const r=e.map(((e,t)=>t)),a=function(e,t){const n=e.length,r=e.map((e=>`${t}[${e}]`)),a=new Array(n-1);a[n-2]=r[n-1];for(let e=n-3;e>=0;--e)a[e]=`(${a[e+1]} * ${r[e+1]})`;return a}(r,t);return a.map(((t,r)=>`int ${e[r]} = ${n} / ${a[r]}; ${r===a.length-1?`int ${e[r+1]} = ${n} - ${e[r]} * ${a[r]}`:`index -= ${e[r]} * ${a[r]}`};`)).join("")}(["r","c","d"],"inputShape"):bL(["r","c","d"],r)}\n return ivec3(r, c, d);\n }\n `}\n ${this.enableShapeUniforms?"\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n":xL(e)}\n\n void main() {\n ivec3 rc = getOutputCoords();\n\n vec4 result = vec4(0.);\n\n ivec3 thisRC;\n int rows = ${this.enableShapeUniforms?"outShape[1]":e[1]};\n int cols = ${this.enableShapeUniforms?"outShape[2]":e[2]};\n\n ${n}\n\n setOutput(result);\n }\n `}}class qF{constructor(e){this.gpgpu=e,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0,this.freeTextures={},this.logEnabled=!1,this.usedTextures={}}acquireTexture(e,t,n){const r=VF(t,n),a=GF(e,r,n);a in this.freeTextures||(this.freeTextures[a]=[]),a in this.usedTextures||(this.usedTextures[a]=[]);const i=WF(e,r,this.gpgpu.gl,this.gpgpu.textureConfig,n);if(this.freeTextures[a].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=i,this.log();const e=this.freeTextures[a].shift();return this.usedTextures[a].push(e),e}let s;return r===HI.PACKED_2X2_FLOAT32?s=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):r===HI.PACKED_2X2_FLOAT16?s=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):r===HI.UNPACKED_FLOAT32?s=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):r===HI.UNPACKED_FLOAT16?s=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):r===HI.PACKED_4X1_UNSIGNED_BYTE&&(s=this.gpgpu.createUnsignedBytesMatrixTexture(e[0],e[1])),this.usedTextures[a].push(s),this.numUsedTextures++,this._numBytesAllocated+=i,this.log(),s}releaseTexture(e,t,n,r){if(null==this.freeTextures)return;const a=VF(n,r),i=GF(t,a,r);i in this.freeTextures||(this.freeTextures[i]=[]);const s=WF(t,a,this.gpgpu.gl,this.gpgpu.textureConfig,r),o=Ge().get("WEBGL_DELETE_TEXTURE_THRESHOLD");-1!==o&&this._numBytesAllocated>o?(this.gpgpu.deleteMatrixTexture(e.texture),this._numBytesAllocated-=s):(this.freeTextures[i].push(e),this.numFreeTextures++,this._numBytesFree+=s),this.numUsedTextures--;const u=this.usedTextures[i],l=u.indexOf(e);if(l<0)throw new Error("Cannot release a texture that was never provided by this texture manager");u.splice(l,1),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(null!=this.freeTextures){for(const e in this.freeTextures)this.freeTextures[e].forEach((e=>{this.gpgpu.deleteMatrixTexture(e.texture)}));for(const e in this.usedTextures)this.usedTextures[e].forEach((e=>{this.gpgpu.deleteMatrixTexture(e.texture)}));this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0}}}function WF(e,t,n,r,a){const i=function(e,t){switch(e){case HI.PACKED_2X2_FLOAT32:return KL(t);case HI.PACKED_2X2_FLOAT16:return JL(t);case HI.UNPACKED_FLOAT32:return WL(t);case HI.UNPACKED_FLOAT16:return VL(t);case HI.PACKED_4X1_UNSIGNED_BYTE:return GL(t);default:throw new Error(`Unknown physical texture type ${e}`)}}(t,r);let s;if(a){const[t,n]=qI(e[0],e[1]);s=t*n}else{const[t,n]=jI(e[0],e[1]);s=t*n}const o=function(e,t){const n=e;if(t===n.R32F)return 4;if(t===n.R16F)return 2;if(t===n.RGBA32F)return 16;if(t===e.RGBA)return 16;if(t===n.RGBA16F)return 8;if(t===n.RGBA8)return 4;throw new Error(`Unknown internal format ${t}`)}(n,i);return s*o}function VF(e,t){if(e===PI.UPLOAD)return HI.PACKED_2X2_FLOAT32;if(e===PI.RENDER||null==e)return function(e){return Ge().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?e?HI.PACKED_2X2_FLOAT32:HI.UNPACKED_FLOAT32:e?HI.PACKED_2X2_FLOAT16:HI.UNPACKED_FLOAT16}(t);if(e===PI.DOWNLOAD||e===PI.PIXELS)return HI.PACKED_4X1_UNSIGNED_BYTE;throw new Error(`Unknown logical texture type ${e}`)}function GF(e,t,n){return`${e[0]}_${e[1]}_${t}_${n}`}class KF{constructor(e,t){this.variableNames=["A"],this.outputShape=e,this.enableShapeUniforms=YL(this.outputShape.length),this.userCode=`\n float unaryOperation(float x) {\n ${t}\n }\n\n void main() {\n float x = getAAtOutCoords();\n float y = unaryOperation(x);\n\n setOutput(y);\n }\n `}}const JF="return abs(x);",XF="return x;";class ZF{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.enableShapeUniforms=YL(this.outputShape.length),this.userCode=`\n vec4 unaryOperation(vec4 x) {\n ${t}\n }\n\n void main() {\n vec4 x = getAAtOutCoords();\n vec4 y = unaryOperation(x);\n\n setOutput(y);\n }\n `}}class QF{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=e,this.enableShapeUniforms=YL(this.outputShape.length);const t=e.length,n=HF("rc",t),r=IL(t),a=function(e,t){if(1===e)return"rc";let n="";for(let r=0;rt.push(e)))}const t=this.texData.get(e),{values:n,shape:r,slice:a,dtype:i,complexTensorInfos:s,isPacked:o}=t;if(null!=a){let t;t=o?new ZF(r,XF):new KF(r,XF);const n=this.runWebGLProgram(t,[{dataId:e,shape:r,dtype:i}],i),a=this.read(n.dataId);return this.disposeIntermediateTensorInfo(n),a}if(null!=n)return this.convertAndCacheOnCPU(e);if(Ge().getBool("DEBUG")&&!Ge().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&2===Ge().getNumber("WEBGL_VERSION"))throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");let u,l,c=null;if("complex64"!==i&&Ge().get("WEBGL_BUFFER_SUPPORTED")){u=this.decode(e);const t=this.texData.get(u.dataId);c=this.gpgpu.createBufferFromTexture(t.texture.texture,...UI(r))}if(this.pendingRead.set(e,[]),"complex64"!==i&&await this.gpgpu.createAndWaitForFence(),"complex64"===i){const e=await Promise.all([this.read(s.real.dataId),this.read(s.imag.dataId)]);l=yf(e[0],e[1])}else if(null==c)l=this.getValuesFromTexture(e);else{const e=ce(r);l=this.gpgpu.downloadFloat32MatrixFromBuffer(c,e)}if(null!=u&&this.disposeIntermediateTensorInfo(u),null!=c){const e=this.gpgpu.gl;VI(e,(()=>e.deleteBuffer(c)))}const p=this.convertAndCacheOnCPU(e,l),d=this.pendingRead.get(e);return this.pendingRead.delete(e),d.forEach((e=>e(p))),this.pendingDisposal.has(e)&&(this.pendingDisposal.delete(e),this.disposeData(e)&&lo().removeDataId(e,this),this.pendingDeletes--),p}readToGPU(e,t={}){const n=this.texData.get(e),{values:r,shape:a,slice:i,dtype:s,isPacked:o,texture:u}=n;if("complex64"===s)throw new Error("Does not support reading texture for complex64 dtype.");if(null!=i){let n;n=o?new ZF(a,XF):new KF(a,XF);const r=this.runWebGLProgram(n,[{dataId:e,shape:a,dtype:s}],s),i=this.readToGPU(r,t);return this.disposeIntermediateTensorInfo(r),i}if(null==u)throw null!=r?new Error("Data is not on GPU but on CPU."):new Error("There is no data on GPU or CPU.");const l=this.decode(e,t.customTexShape),c=lo().makeTensorFromTensorInfo(l),p=this.texData.get(l.dataId);return Object.assign({tensorRef:c},p.texture)}bufferSync(e){const t=this.readSync(e.dataId);if("string"===e.dtype)try{const n=t.map((e=>Ha(e)));return Is(e.shape,e.dtype,n)}catch(e){throw new Error("Failed to decode encoded string bytes into utf-8")}return Is(e.shape,e.dtype,t)}checkNumericalProblems(e){if(null!=e)for(let t=0;t0}time(e){const t=this.activeTimers,n=[];let r=!1;null==this.programTimersStack?(this.programTimersStack=n,r=!0):this.activeTimers.push(n),this.activeTimers=n,e();const a=le(this.activeTimers.map((e=>e.query))).filter((e=>null!=e)),i=le(this.activeTimers.map((e=>e.name))).filter((e=>null!=e));this.activeTimers=t,r&&(this.programTimersStack=null);const s={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null};return(async()=>{if(Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0){const e=await Promise.all(a);s.kernelMs=re(e),s.getExtraProfileInfo=()=>e.map(((e,t)=>({name:i[t],ms:e}))).map((e=>`${e.name}: ${e.ms}`)).join(", ")}else s.kernelMs={error:"WebGL query timers are not supported in this environment."};return this.uploadWaitMs=0,this.downloadWaitMs=0,s})()}memory(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU,numBytesInGPUAllocated:this.textureManager.numBytesAllocated,numBytesInGPUFree:this.textureManager.numBytesFree}}startTimer(){return Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:Ba(),endMs:null}}endTimer(e){return Ge().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),e):(e.endMs=Ba(),e)}async getQueryTime(e){if(Ge().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:n}=this.texData.get(e);return null!=n&&(this.disposeData(n.real.dataId,t),this.disposeData(n.imag.dataId,t)),this.texData.delete(e),!0}releaseGPUData(e){const{texture:t,dtype:n,texShape:r,usage:a,isPacked:i,slice:s}=this.texData.get(e),o=s&&s.origDataId||e,u=this.dataRefCount.get(o);u>1?this.dataRefCount.set(o,u-1):(this.dataRefCount.delete(o),null!=t&&(this.numBytesInGPU-=this.computeBytes(r,n),this.textureManager.releaseTexture(t,r,a,i)));const l=this.texData.get(e);l.texture=null,l.texShape=null,l.isPacked=!1,l.slice=null}getTexture(e){return this.uploadToGPU(e),this.texData.get(e).texture.texture}getDataInfo(e){return this.texData.get(e)}shouldExecuteOnCPU(e,t=n$){return Ge().getBool("WEBGL_CPU_FORWARD")&&e.every((e=>null==this.texData.get(e.dataId).texture&&ce(e.shape)0&&Ee(n[0])){const a=n.map((e=>Pa(e)));r=this.write(a,e,t)}else r=this.write(n,e,t);return this.texData.get(r).usage=null,{dataId:r,shape:e,dtype:t}}makeOutput(e,t,n){return lo().makeTensorFromTensorInfo(this.makeTensorInfo(e,t,n),this)}unpackTensor(e){const t=new QF(e.shape);return this.runWebGLProgram(t,[e],e.dtype)}packTensor(e){const t=new jF(e.shape);return this.runWebGLProgram(t,[e],e.dtype,null,!0)}packedReshape(e,t){const n=[iL(e.shape),...sL(e.shape)],r={dtype:e.dtype,shape:n,dataId:e.dataId},a=[iL(t),...sL(t)],i=new UF(a,n),s=[n],o=this.runWebGLProgram(i,[r],e.dtype,s,!0);return{dataId:o.dataId,shape:t,dtype:o.dtype}}decode(e,t){const n=this.texData.get(e),{isPacked:r,shape:a,dtype:i}=n;null!=t&&se(ce(a)<=t[0]*t[1]*4,(()=>"customTexShape is too small. Row * Column * 4 should be equal or larger than the size of the tensor data."));const s=oL(a);let o;o=r?new zL(s):new BL(s);const u=[null!=t?t:UI(s)];return{dtype:i,shape:a,dataId:this.runWebGLProgram(o,[{shape:s,dtype:i,dataId:e}],i,u,!0,t).dataId}}runWebGLProgram(e,t,n,r,a=!1,i){const s=this.makeTensorInfo(e.outputShape,n),o=this.texData.get(s.dataId);if(e.packedOutput&&(o.isPacked=!0),e.outPackingScheme===zI.DENSE){const t=null!=i?i:UI(e.outputShape);o.texShape=t.map((e=>2*e))}if(null!=e.outTexUsage&&(o.usage=e.outTexUsage),0===ce(s.shape))return o.values=we(s.dtype,0),s;const u=[],l=t.map((t=>{if("complex64"===t.dtype)throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");let n=this.texData.get(t.dataId);if(null==n.texture){if(!e.packedInputs&&ce(t.shape)<=Ge().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return{shape:t.shape,texData:null,isUniform:!0,uniformValues:n.values};e.packedInputs&&(n.isPacked=!0,n.shape=t.shape)}if(this.uploadToGPU(t.dataId),!!n.isPacked!=!!e.packedInputs)t=n.isPacked?this.unpackTensor(t):this.packTensor(t),u.push(t),n=this.texData.get(t.dataId);else if(n.isPacked&&!lL(n.shape,t.shape)){const e=t,r=t.shape;t.shape=n.shape,t=this.packedReshape(t,r),u.push(t),n=this.texData.get(t.dataId),e.shape=r}return{shape:t.shape,texData:n,isUniform:!1}}));this.uploadToGPU(s.dataId);const c={shape:s.shape,texData:o,isUniform:!1},p=function(e,t,n){let r="";t.concat(n).forEach((t=>{const a=null!=t.texData&&null!=t.texData.slice&&t.texData.slice.flatOffset>0;if(e.enableShapeUniforms&&!t.isUniform){const i=t.texData.texShape,{useSqueezeShape:s,uniformShape:o,keptDims:u}=LL(e.packedInputs,t.shape,i);let l="",c="",p="";if(1===o.length&&e.packedInputs){const e=[Math.ceil(i[0]/2),Math.ceil(i[1]/2)];l=`${e[0]>1}_${e[1]>1}`}else if(2!==o.length||e.packedInputs){if(o.length>2&&!e.packedInputs){const e=Oe(o);p=`${e[0]===i[1]}_${e[e.length-1]===i[1]}`}}else c=`${o[0]>1}_${o[1]>1}`;const d=t.shape.length,h=2===o.length&&de(t.shape,i),f=1===ce(t.shape),m=Ao(t.shape,n.shape),g=!e.packedInputs&&d===n.shape.length&&de(i,n.texData.texShape),y=e.packedInputs||o.length>2?"":`${i[0]>1}_${i[1]>1}`;r+=`${d}_${g}_${s?u:""}_${o.length}_${f}_${m}_${h}_${l}_${c}_${p}_${y}_${a}`}else{const e=t.isUniform?"uniform":t.texData.texShape;r+=`${t.shape}_${e}_${a}`}}));const a=e.userCode;let i=e.constructor.name;return i+="_"+r+"_"+a+`${Ge().getNumber("WEBGL_VERSION")}`,i}(e,l,c),d=this.getAndSaveBinary(p,(()=>function(e,t,n,r){const a=n.map(((e,n)=>{const r={logicalShape:e.shape,texShape:e.isUniform?null:e.texData.texShape,isUniform:e.isUniform,isPacked:!e.isUniform&&e.texData.isPacked,flatOffset:null};return null!=e.texData&&null!=e.texData.slice&&e.texData.slice.flatOffset>0&&(r.flatOffset=e.texData.slice.flatOffset),{name:t.variableNames[n],shapeInfo:r}})),i=a.map((e=>e.shapeInfo)),s={logicalShape:r.shape,texShape:r.texData.texShape,isUniform:!1,isPacked:r.texData.isPacked,flatOffset:null},o=DL(a,s,t),u=function(e,t){const n=aL(e,(()=>e.createShader(e.FRAGMENT_SHADER)),"Unable to create fragment WebGLShader.");if(VI(e,(()=>e.shaderSource(n,t))),VI(e,(()=>e.compileShader(n))),Ge().get("ENGINE_COMPILE_ONLY"))return n;if(!1===e.getShaderParameter(n,e.COMPILE_STATUS))throw XI(t,e.getShaderInfoLog(n)),new Error("Failed to compile fragment shader.");return n}(e.gl,o),l=e.createProgram(u);return Ge().get("ENGINE_COMPILE_ONLY")?{program:t,fragmentShader:u,source:o,webGLProgram:l,inShapeInfos:i,outShapeInfo:s,uniformLocations:null,customUniformLocations:null,infLoc:null,nanLoc:null,inShapesLocations:null,inTexShapesLocations:null,outShapeLocation:null,outShapeStridesLocation:null,outTexShapeLocation:null}:Object.assign({program:t,fragmentShader:u,source:o,webGLProgram:l,inShapeInfos:i,outShapeInfo:s},OL(e,t,l))}(this.gpgpu,e,l,c))),h=null!=this.activeTimers;let f;h&&(f=this.startTimer()),Ge().get("ENGINE_COMPILE_ONLY")||function(e,t,n,r,a){t.program.enableShapeUniforms||(RL(t.inShapeInfos,n),RL([t.outShapeInfo],[r]));const i=r.texData.texture,s=r.texData.texShape;r.texData.isPacked?e.setOutputPackedMatrixTexture(i.texture,s[0],s[1]):e.setOutputMatrixTexture(i.texture,s[0],s[1]),e.setProgram(t.webGLProgram),1===Ge().getNumber("WEBGL_VERSION")&&null!==t.infLoc&&e.gl.uniform1f(t.infLoc,1/0),null!==t.nanLoc&&e.gl.uniform1f(t.nanLoc,NaN),n.forEach(((n,r)=>{const a=t.program.variableNames[r],i=t.uniformLocations[a],s=t.uniformLocations[`offset${a}`],o=t.inShapesLocations[`${a}Shape`],u=t.inTexShapesLocations[`${a}TexShape`];if(o){const{uniformShape:r}=LL(t.program.packedInputs,n.shape,n.texData.texShape);switch(r.length){case 1:e.gl.uniform1iv(o,new Int32Array(r));break;case 2:e.gl.uniform2iv(o,new Int32Array(r));break;case 3:e.gl.uniform3iv(o,new Int32Array(r));break;case 4:e.gl.uniform4iv(o,new Int32Array(r))}}if(u&&e.gl.uniform2i(u,n.texData.texShape[0],n.texData.texShape[1]),null!=i)if(n.isUniform)if(ce(n.shape)<2)e.gl.uniform1f(i,n.uniformValues[0]);else{let t=n.uniformValues;t instanceof Float32Array||(t=new Float32Array(t)),e.gl.uniform1fv(i,t)}else null!=n.texData.slice&&null!=s&&e.gl.uniform1i(s,n.texData.slice.flatOffset),e.setInputMatrixTexture(n.texData.texture.texture,i,r)}));const o=t.outShapeLocation;if(o)switch(r.shape.length){case 1:e.gl.uniform1iv(o,new Int32Array(r.shape));break;case 2:e.gl.uniform2iv(o,new Int32Array(r.shape));break;case 3:e.gl.uniform3iv(o,new Int32Array(r.shape));break;case 4:e.gl.uniform4iv(o,new Int32Array(r.shape))}if(t.outShapeStridesLocation){const n=Oe(r.shape);switch(r.shape.length){case 2:e.gl.uniform1iv(t.outShapeStridesLocation,new Int32Array(n));break;case 3:e.gl.uniform2iv(t.outShapeStridesLocation,new Int32Array(n));break;case 4:e.gl.uniform3iv(t.outShapeStridesLocation,new Int32Array(n))}}t.outTexShapeLocation&&e.gl.uniform2i(t.outTexShapeLocation,r.texData.texShape[0],r.texData.texShape[1]),t.program.customUniforms&&a&&t.program.customUniforms.forEach(((n,r)=>{const i=t.customUniformLocations[r],s=a[r];if("float"===n.type)e.gl.uniform1fv(i,s);else if("vec2"===n.type)e.gl.uniform2fv(i,s);else if("vec3"===n.type)e.gl.uniform3fv(i,s);else if("vec4"===n.type)e.gl.uniform4fv(i,s);else if("int"===n.type)e.gl.uniform1iv(i,s);else if("ivec2"===n.type)e.gl.uniform2iv(i,s);else if("ivec3"===n.type)e.gl.uniform3iv(i,s);else{if("ivec4"!==n.type)throw Error(`uniform type ${n.type} is not supported yet.`);e.gl.uniform4iv(i,s)}})),e.executeProgram()}(this.gpgpu,d,l,c,r),u.forEach((e=>this.disposeIntermediateTensorInfo(e))),h&&(f=this.endTimer(f),this.activeTimers.push({name:e.constructor.name,query:this.getQueryTime(f)}));const m=Ge().get("WEBGL_FLUSH_THRESHOLD");if(m>0){const e=Ba();e-this.lastGlFlushTime>m&&(this.gpgpu.gl.flush(),this.lastGlFlushTime=e)}if(!Ge().getBool("WEBGL_LAZILY_UNPACK")&&o.isPacked&&!1===a){const e=this.unpackTensor(s);return this.disposeIntermediateTensorInfo(s),e}return s}compileAndRun(e,t,n,r,a=!1){return n=n||t[0].dtype,this.runWebGLProgram(e,t,n,r,a)}getAndSaveBinary(e,t){return e in this.binaryCache||(this.binaryCache[e]=t()),this.binaryCache[e]}getTextureManager(){return this.textureManager}dispose(){this.disposed||(Ge().getBool("IS_TEST")||Object.keys(this.binaryCache).forEach((e=>{this.gpgpu.deleteProgram(this.binaryCache[e].webGLProgram),delete this.binaryCache[e]})),this.textureManager.dispose(),null!=this.canvas&&"undefined"!=typeof HTMLCanvasElement&&this.canvas instanceof HTMLCanvasElement?this.canvas.remove():this.canvas=null,this.gpgpuCreatedLocally&&(this.gpgpu.program=null,this.gpgpu.dispose()),this.disposed=!0)}floatPrecision(){return null==this.floatPrecisionValue&&(this.floatPrecisionValue=ho((()=>{if(!Ge().get("WEBGL_RENDER_FLOAT32_ENABLED")){const e=Ge().getBool("DEBUG");Ge().set("DEBUG",!1);const t=this.abs(Ou(1e-8)).dataSync()[0];if(Ge().set("DEBUG",e),t>0)return 32}return 16}))),this.floatPrecisionValue}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}uploadToGPU(e){const t=this.texData.get(e),{shape:n,dtype:r,values:a,texture:i,usage:s,isPacked:o}=t;if(null!=i)return;const u=null!=this.activeTimers;let l;u&&(l=Ba());let c=t.texShape;if(null==c&&(c=function(e,t=!1){let n=Ge().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(t&&(n*=2,e=e.map(((t,n)=>n>=e.length-2?te(e[n]):e[n])),1===e.length&&(e=[2,e[0]])),2!==e.length){const t=_e(e);e=t.newShape}let r=ce(e);if(e.length<=1&&r<=n)return[1,r];if(2===e.length&&e[0]<=n&&e[1]<=n)return e;if(3===e.length&&e[0]*e[1]<=n&&e[2]<=n)return[e[0]*e[1],e[2]];if(3===e.length&&e[0]<=n&&e[1]*e[2]<=n)return[e[0],e[1]*e[2]];if(4===e.length&&e[0]*e[1]*e[2]<=n&&e[3]<=n)return[e[0]*e[1]*e[2],e[3]];if(4===e.length&&e[0]<=n&&e[1]*e[2]*e[3]<=n)return[e[0],e[1]*e[2]*e[3]];if(t){const t=iL(e);let n=2,a=2;return e.length&&([n,a]=sL(e)),r=t*(n/2)*(a/2),me(r).map((e=>2*e))}return me(r)}(n,o),t.texShape=c),null!=a){const e=oL(n);let i,s=c[1],p=c[0];const d=a instanceof Uint8Array||a instanceof Uint8ClampedArray;!o&&d||([s,p]=qI(c[0],c[1])),i=o?new UL(e,d):new jL(e,d);const h=d?[p,s]:c,f=this.makeTensorInfo(h,r),m=this.texData.get(f.dataId);m.usage=d?PI.PIXELS:PI.UPLOAD,m.texShape=h,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(f.dataId),s,p,a);const g=[[p,s]],y=!0,b=this.runWebGLProgram(i,[f],r,g,y),v=this.texData.get(b.dataId);t.texShape=v.texShape,t.isPacked=v.isPacked,t.usage=v.usage,Ge().get("ENGINE_COMPILE_ONLY")?this.disposeData(b.dataId):(t.texture=v.texture,t.values=null,this.texData.delete(b.dataId)),this.disposeIntermediateTensorInfo(f),u&&(this.uploadWaitMs+=Ba()-l)}else{const e=this.acquireTexture(c,s,r,o);t.texture=e}}convertAndCacheOnCPU(e,t){const n=this.texData.get(e),{dtype:r}=n;return this.releaseGPUData(e),null!=t&&(n.values=function(e,t){if("float32"===t||"complex64"===t)return e;if("int32"===t||"bool"===t){const n="int32"===t?new Int32Array(e.length):new Uint8Array(e.length);for(let t=0;t1024*this.numMBBeforeWarning*1024){const e=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn(`High memory usage in GPU: ${e} MB, most likely due to a memory leak`)}return this.textureManager.acquireTexture(e,t,r)}computeBytes(e,t){return e[0]*e[1]*Te(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)}for(const[,t]of Object.entries(this.binaryCache)){const n=new Promise((e=>{try{this.checkCompletion_(t),e(!0)}catch(e){throw e}}));e.push(n)}return Promise.all(e)}async checkCompletionAsync_(e){return this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.parallelCompilationExtension.COMPLETION_STATUS_KHR)?this.checkCompletion_(e):(await Xh(),this.checkCompletionAsync_(e))}checkCompletion_(e){if(!1===this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.gl.LINK_STATUS)){if(console.log(this.gpgpu.gl.getProgramInfoLog(e.webGLProgram)),!1===this.gpgpu.gl.getShaderParameter(e.fragmentShader,this.gpgpu.gl.COMPILE_STATUS))throw XI(e.source,this.gpgpu.gl.getShaderInfoLog(e.fragmentShader)),new Error("Failed to compile fragment shader.");throw new Error("Failed to link vertex and fragment shaders.")}return!0}getUniformLocations(){for(const[,e]of Object.entries(this.binaryCache)){const{uniformLocations:t,customUniformLocations:n,infLoc:r,nanLoc:a,inShapesLocations:i,inTexShapesLocations:s,outShapeLocation:o,outShapeStridesLocation:u,outTexShapeLocation:l}=OL(this.gpgpu,e.program,e.webGLProgram);e.uniformLocations=t,e.customUniformLocations=n,e.infLoc=r,e.nanLoc=a,e.inShapesLocations=i,e.inTexShapesLocations=s,e.outShapeLocation=o,e.outShapeStridesLocation=u,e.outTexShapeLocation=l}}}r$.nextDataId=0,Si()&&Do("webgl",(()=>new r$),2);class a${constructor(e,t,n){this.variableNames=["A","B"],this.outputShape=Lo(t,n),this.enableShapeUniforms=YL(this.outputShape.length),this.userCode=`\n float binaryOperation(float a, float b) {\n ${e}\n }\n\n void main() {\n float a = getAAtOutCoords();\n float b = getBAtOutCoords();\n setOutput(binaryOperation(a, b));\n }\n `}}class i${constructor(e,t,n,r=!1){this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=Lo(t,n);const a=this.outputShape.length;this.enableShapeUniforms=YL(a);let i="";if(r)if(0===a||1===ce(this.outputShape))i="\n result.y = 0.;\n result.z = 0.;\n result.w = 0.;\n ";else if(i=`\n ${IL(a)} coords = getOutputCoords();\n `,1===a)this.enableShapeUniforms?i+="\n result.y = (coords + 1) >= outShape ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n ":i+=`\n result.y = (coords + 1) >= ${this.outputShape[0]} ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n `;else{const e=HF("coords",a);this.enableShapeUniforms?i+=`\n bool nextRowOutOfBounds =\n (${e[a-2]} + 1) >= outShape[${a} - 2];\n bool nextColOutOfBounds =\n (${e[a-1]} + 1) >= outShape[${a} - 1];\n result.y = nextColOutOfBounds ? 0. : result.y;\n result.z = nextRowOutOfBounds ? 0. : result.z;\n result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n `:i+=`\n bool nextRowOutOfBounds =\n (${e[a-2]} + 1) >= ${this.outputShape[a-2]};\n bool nextColOutOfBounds =\n (${e[a-1]} + 1) >= ${this.outputShape[a-1]};\n result.y = nextColOutOfBounds ? 0. : result.y;\n result.z = nextRowOutOfBounds ? 0. : result.z;\n result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n `}this.userCode=`\n vec4 binaryOperation(vec4 a, vec4 b) {\n ${e}\n }\n\n void main() {\n vec4 a = getAAtOutCoords();\n vec4 b = getBAtOutCoords();\n\n vec4 result = binaryOperation(a, b);\n ${i}\n\n setOutput(result);\n }\n `}}function s$(e){const{inputs:t,backend:n}=e,{x:r}=t;return n.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}const o$={kernelName:fn,backendName:"webgl",kernelFunc:s$};function u$(e){const{inputs:t,backend:n}=e,{real:r,imag:a}=t,i=n.makeTensorInfo(r.shape,"complex64"),s=n.texData.get(i.dataId),o=s$({inputs:{x:r},backend:n}),u=s$({inputs:{x:a},backend:n});return s.complexTensorInfos={real:o,imag:u},i}const l$={kernelName:Mt,backendName:"webgl",kernelFunc:u$},c$="return (a < 0.) ? b * a : a;",p$="\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n",d$={kernelName:xn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{alpha:i}=r,s=n.makeTensorInfo([],"float32",Ra(i,"float32")),o=Ge().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new i$(p$,a.shape,s.shape):new a$(c$,a.shape,s.shape),u=n.runWebGLProgram(o,[a,s],"float32");return n.disposeIntermediateTensorInfo(s),u}},h$="return (a < 0.) ? b * a : a;",f$="\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n",m$={kernelName:ir,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r,alpha:a}=t,i=Ge().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new i$(f$,r.shape,a.shape):new a$(h$,r.shape,a.shape);return n.runWebGLProgram(i,[r,a],"float32")}};function g$({opSnippet:e,packedOpSnippet:t,cpuKernelImpl:n,dtype:r}){return({inputs:a,backend:i})=>{const{x:s}=a,o=i,u=r||s.dtype;if(o.shouldExecuteOnCPU([s])&&null!=n){const e=o.texData.get(s.dataId),t=n(e.values,u);return o.makeTensorInfo(s.shape,u,t)}let l;return l=Ge().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&null!=t?new ZF(s.shape,t):new KF(s.shape,e),o.runWebGLProgram(l,[s],u)}}function y$({opSnippet:e,packedOpSnippet:t,checkOutOfBounds:n=!1,supportsComplex:r=!1,cpuKernelImpl:a,dtype:i}){return({inputs:s,backend:o})=>{const{a:u,b:l}=s,c=o;if(r&&"complex64"===u.dtype){const t=c.texData.get(u.dataId),n=c.texData.get(l.dataId),[r,a]=[[t.complexTensorInfos.real,n.complexTensorInfos.real],[t.complexTensorInfos.imag,n.complexTensorInfos.imag]].map((t=>{const[n,r]=t,a={dataId:n.dataId,dtype:n.dtype,shape:u.shape},i={dataId:r.dataId,dtype:r.dtype,shape:l.shape},s=new a$(e,u.shape,l.shape);return c.runWebGLProgram(s,[a,i],ci(n.dtype,r.dtype))})),i=u$({inputs:{real:r,imag:a},backend:c});return c.disposeIntermediateTensorInfo(r),c.disposeIntermediateTensorInfo(a),i}const p=i||ci(u.dtype,l.dtype);if(("string"===u.dtype||"string"===l.dtype||c.shouldExecuteOnCPU([u,l]))&&null!=a){const e=c.texData.get(u.dataId).values,t=c.texData.get(l.dataId).values,n="string"===u.dtype?Gf(e):e,r="string"===u.dtype?Gf(t):t,[i,s]=a(u.shape,l.shape,n,r,p),o=c.makeTensorInfo(s,p);return c.texData.get(o.dataId).values=i,o}let d;return d=Ge().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&null!=t?new i$(t,u.shape,l.shape,n):new a$(e,u.shape,l.shape),c.runWebGLProgram(d,[u,l],p)}}function b$(e,t=!1){if("linear"===e)return"return x;";if("relu"===e)return t?"\n vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n":"if (isnan(x)) return x;\n return (x < 0.0) ? 0.0 : x;\n";if("elu"===e)return t?"\n vec4 result;\n\n result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);\n result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);\n result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);\n result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);\n\n return result;\n":"return (x >= 0.0) ? x : (exp(x) - 1.0);";if("relu6"===e)return t?"\n vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n":"if (isnan(x)) return x;\n return (x < 0.0) ? 0.0 : min(6.0, x);\n";if("prelu"===e)return t?f$:h$;if("leakyrelu"===e)return t?p$:c$;if("sigmoid"===e)return"return 1.0 / (1.0 + exp(-1.0 * x));";throw new Error(`Activation ${e} has not been implemented for the WebGL backend.`)}class v${constructor(e,t,n,r=!1,a=!1,i=!1,s=null,o=!1,u=!1){this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=n,this.enableShapeUniforms=YL(this.outputShape.length);const l=r?e[1]:e[2],c=Math.ceil(l/2),p=r?"i * 2, rc.y":"rc.y, i * 2",d=a?"rc.z, i * 2":"i * 2, rc.z",h=r?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],f=a?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"];let m="",g="";s&&(m=o?`vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n ${s}\n }`:u?`vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n ${s}\n }`:`vec4 activation(vec4 x) {\n ${s}\n }`,g="result = activation(result);");const y=i?"result += getBiasAtOutCoords();":"";i&&this.variableNames.push("bias"),o&&this.variableNames.push("preluActivationWeights"),u&&this.variableNames.push("leakyreluAlpha");let b="rc.x",v="rc.x";e[0]`The new shape (${u}) has ${l} elements and the old shape (${a.shape}) has ${o} elements. The new shape and old shape must have the same number of elements.`));const c=s.texData.get(a.dataId);return!c.isPacked||lL(a.shape,u)||null!==c.texture&&lL(c.shape,u)?(s.incRef(a.dataId),{dataId:a.dataId,shape:u,dtype:a.dtype}):function(e,t,n){const r=[iL(e.shape),...sL(e.shape)],a={dtype:e.dtype,shape:r,dataId:e.dataId},i=[iL(t),...sL(t)],s=new UF(i,r),o=[r],u=n.runWebGLProgram(s,[a],e.dtype,o,!0);return{dataId:u.dataId,shape:t,dtype:u.dtype}}(a,u,s)}const M$={kernelName:pr,backendName:"webgl",kernelFunc:N$};class S${constructor(e,t){this.variableNames=["x"];const{windowSize:n,batchSize:r,inSize:a,outSize:i}=e;this.outputShape=[r,i];const s=4*Math.floor(n/4),o=n%4;let u="sumValue += dot(values, ones);";if(null!=t){const e=1/t;u=`sumValue += dot(values * ${he(e)?e.toPrecision(2):e}, ones);`}let l="";a%n>0&&(l=`\n if (inIdx < 0 || inIdx >= ${a}) {\n return 0.0;\n }\n `),this.userCode=`\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n ${l}\n return getX(batch, inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * ${n};\n\n float sumValue = 0.0;\n\n for (int i = 0; i < ${s}; i += 4) {\n int inIdx = inOffset + i;\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n ${u}\n }\n\n int inIdx = inOffset + ${s};\n if (${1===o}) {\n vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0);\n\n ${u}\n } else if (${2===o}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1), 0.0, 0.0);\n\n ${u}\n } else if (${3===o}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2), 0.0);\n\n ${u}\n }\n setOutput(sumValue);\n }\n `}}class k${constructor(e,t){this.variableNames=["x"];const{windowSize:n,batchSize:r,inSize:a,outSize:i}=e;this.outputShape=[r,i];let s="0.0",o="";"prod"===t?s="1.0":"min"===t?(s="1.0 / 1e-20",o="min"):"max"===t&&(s="-1.0 / 1e-20",o="max");let u=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"sum"===t?u="sumValue":"prod"===t?u="prodValue":"all"===t?u="allValue":"any"===t&&(u="anyValue");const l=4*Math.floor(n/4),c=n%4;let p=`\n if (${"sum"===t}) {\n sumValue += dot(values, ones);\n } else if (${"prod"===t}) {\n vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]);\n prodValue *= tmp[0] * tmp[1];\n } else {\n minMaxValue = ${o}(values, minMaxValue);\n if (${"min"===t} || ${"max"===t}) {\n minMaxValue = ${o}(values, minMaxValue);\n bvec4 isNaN = isnan(values);\n if (isNaN.r || isNaN.g || isNaN.b || isNaN.a) {\n minMaxValue = vec4(NAN);\n }\n }\n }\n `,d="vec4";"all"===t?(s="1.0",p="\n bool reducedAllValue = all(values);\n float floatedReducedAllValue = float(reducedAllValue);\n allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);\n ",d="bvec4"):"any"===t&&(s="0.0",p="\n bool reducedAnyValue = any(values);\n float floatedReducedAnyValue = float(reducedAnyValue);\n anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);\n ",d="bvec4");let h="";a%n>0&&(h=`\n if (inIdx < 0 || inIdx >= ${a}) {\n return initializationValue;\n }\n `),this.userCode=`\n const float initializationValue = ${s};\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n ${h}\n return getX(batch, inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * ${n};\n\n vec4 minMaxValue = vec4(${s});\n float prodValue = 1.0;\n float sumValue = 0.0;\n float allValue = 1.0;\n float anyValue = 0.0;\n\n for (int i = 0; i < ${l}; i += 4) {\n int inIdx = inOffset + i;\n ${d} values = ${d}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n ${p}\n }\n\n int inIdx = inOffset + ${l};\n if (${1===c}) {\n ${d} values = ${d}(\n getValue(batch, inIdx),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${p}\n } else if (${2===c}) {\n ${d} values = ${d}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n initializationValue,\n initializationValue\n );\n\n ${p}\n } else if (${3===c}) {\n ${d} values = ${d}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n initializationValue\n );\n\n ${p}\n }\n setOutput(${u});\n }\n `}}function T$(e,t,n,r){const a=function(e){const t=[];for(;0===t.length||1!==t[t.length-1].outSize;){const n=t.length?t[t.length-1].outSize:e[1],r=tf(n);t.push({inSize:n,windowSize:r,outSize:Math.ceil(n/r)})}return t}(e.shape);let i=e;for(let s=0;s6)throw Error(`Transpose for rank ${t} is not yet supported`);const n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],r=new Array(t);for(let t=0;t6)throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`);const r=IL(this.rank),a=PF("rc",this.rank),i=new Array(this.rank);for(let e=0;e`Error in matMul: inner shapes (${p}) and (${d}) of Tensors with shapes ${e.shape} and ${t.shape} and transposeA=${n} and transposeB=${r} must match.`));const x=n?[y,p,h]:[y,h,p],_=r?[b,f,d]:[b,d,f],w=N$({inputs:{x:e},backend:a,attrs:{shape:x}}),D=N$({inputs:{x:t},backend:a,attrs:{shape:_}}),N=[w,D],M=Math.max(y,b),S=n?w.shape[1]:w.shape[2],k=null!=i,T=null!=s,C="leakyrelu"===u,E=null!=u?b$(u,!0):null;let A;if((1===h||1===f)&&S>1e3&&!1===(k||T||C||null!=E)){let e=w,t=D;n&&(e=F$({inputs:{x:w},backend:a,attrs:{perm:[0,2,1]}}),N.push(e)),r&&(t=F$({inputs:{x:D},backend:a,attrs:{perm:[0,2,1]}}),N.push(t));const i=1===f;let s=e;1!==f&&(s=N$({inputs:{x:e},backend:a,attrs:{shape:[M,S,1]}}),N.push(s));const o=1===f?2:1;let u=t;i&&(u=N$({inputs:{x:t},backend:a,attrs:{shape:[M,1,S]}}),N.push(u));const l=w$({inputs:{a:s,b:u},backend:a});A=I$({inputs:{x:l},backend:a,attrs:{axis:o,keepDims:!0}}),N.push(l)}else{const u=ci(e.dtype,t.dtype),l=new v$(x,_,[M,h,f],n,r,k,E,T,C),c=[w,D];if(null!=i&&c.push(i),T&&c.push(s),C){const e=a.makeTensorInfo([],"float32",Ra(o,"float32"));c.push(e),N.push(e)}A=a.runWebGLProgram(l,c,u)}const I=N$({inputs:{x:A},backend:a,attrs:{shape:v}});N.push(A);for(const e of N)a.disposeIntermediateTensorInfo(e);return I}const R$={kernelName:oa,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{a,b:i,bias:s,preluActivationWeights:o}=t,{transposeA:u,transposeB:l,activation:c,leakyreluAlpha:p}=r;return O$({a,b:i,transposeA:u,transposeB:l,backend:n,bias:s,preluActivationWeights:o,leakyreluAlpha:p,activation:c})}},Y$="return abs(x);",B$={kernelName:Qe,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r}=t;if(n.shouldExecuteOnCPU([r])&&"complex64"!==r.dtype){const e=n.texData.get(r.dataId),t=SF(e.values);return n.makeTensorInfo(r.shape,r.dtype,t)}let a;return a=Ge().getBool("WEBGL_PACK_UNARY_OPERATIONS")?new ZF(r.shape,Y$):new KF(r.shape,Y$),n.runWebGLProgram(a,[r],r.dtype)}},z$=g$({opSnippet:"if (isnan(x)) return x;\n if (abs(x) > 1.) {\n return NAN;\n }\n return acos(x);\n"}),P$={kernelName:et,backendName:"webgl",kernelFunc:z$},H$=g$({opSnippet:"if (isnan(x)) return x;\n if (x < 1.0) return NAN;\nreturn log(x + sqrt(x * x - 1.0));"}),j$={kernelName:tt,backendName:"webgl",kernelFunc:H$},U$="return a + b;",q$=y$({opSnippet:U$,packedOpSnippet:U$,supportsComplex:!0,cpuKernelImpl:ZL}),W$={kernelName:nt,backendName:"webgl",kernelFunc:q$};class V${constructor(e,t){this.outputShape=[],this.outputShape=e,this.variableNames=t.map(((e,t)=>`T${t}`));const n=[];this.variableNames.forEach((e=>{n.push(`float v${e} = get${e}AtOutCoords();`)}));const r=this.variableNames.map((e=>`v${e}`)).join(" + ");this.userCode=`\n void main() {\n ${n.join("\n ")}\n\n float result = ${r};\n setOutput(result);\n }\n `}}class G${constructor(e,t){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.variableNames=t.map(((e,t)=>`T${t}`));const n=[];this.variableNames.forEach((e=>{n.push(`vec4 v${e} = get${e}AtOutCoords();`)}));const r=this.variableNames.map((e=>`v${e}`)).join(" + ");this.userCode=`\n void main() {\n ${n.join("\n ")}\n\n vec4 result = ${r};\n setOutput(result);\n }\n `}}const K$={kernelName:rt,backendName:"webgl",kernelFunc:function e(t){const{inputs:n,backend:r}=t,a=n;if(1===a.length)return s$({inputs:{x:a[0]},backend:r});if(a.length>Ge().get("WEBGL_MAX_TEXTURES_IN_SHADER")){const t=Math.floor(a.length/2),n=e({inputs:a.slice(0,t),backend:r}),i=e({inputs:a.slice(t),backend:r});return e({inputs:[n,i],backend:r})}const i=a.map((e=>e.dtype)).reduce(((e,t)=>ci(e,t))),s=a.map((e=>e.shape)),o=Ge().getBool("WEBGL_PACK")?new G$(a[0].shape,s):new V$(a[0].shape,s);return r.runWebGLProgram(o,a,i)}},J$={kernelName:at,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,keepDims:s}=r,o=a.shape.length,u=xe(i,a.shape);let l=u;const c=vc(l,o);let p=a;null!=c&&(p=F$({inputs:{x:a},backend:n,attrs:{perm:c}}),l=_c(l.length,o)),bc("all",l,o);const[d,h]=gc(p.shape,l),f=N$({inputs:{x:p},backend:n,attrs:{shape:[-1,ce(h)]}}),m=T$(f,f.dtype,"all",n);let g;return g=N$(s?{inputs:{x:m},backend:n,attrs:{shape:yc(d,u)}}:{inputs:{x:m},backend:n,attrs:{shape:d}}),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),null!=c&&n.disposeIntermediateTensorInfo(p),g}},X$={kernelName:it,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,keepDims:s}=r,o=a.shape.length,u=xe(i,a.shape);let l=u;const c=vc(l,o);let p=a;null!=c&&(p=F$({inputs:{x:a},backend:n,attrs:{perm:c}}),l=_c(l.length,o)),bc("any",l,o);const[d,h]=gc(p.shape,l),f=N$({inputs:{x:p},backend:n,attrs:{shape:[-1,ce(h)]}}),m=T$(f,f.dtype,"any",n);let g;return g=N$(s?{inputs:{x:m},backend:n,attrs:{shape:yc(d,u)}}:{inputs:{x:m},backend:n,attrs:{shape:d}}),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),null!=c&&n.disposeIntermediateTensorInfo(p),g}};class Z${constructor(e,t,n){this.variableNames=["A"];const{windowSize:r,batchSize:a,outSize:i}=e;n||this.variableNames.push("bestIndicesA"),this.outputShape=[a,i];const s="max"===t?">":"<",o=n?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));";this.userCode=`\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * ${r};\n\n int bestIndex = inOffset;\n float bestValue = getA(batch, bestIndex);\n\n for (int i = 0; i < ${r}; i++) {\n int inIdx = ${o};\n float candidate = getA(batch, inIdx);\n if (candidate ${s} bestValue) {\n bestValue = candidate;\n bestIndex = inIdx;\n }\n }\n setOutput(float(bestIndex));\n }\n `}}class Q${constructor(e,t,n,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,se(e.length>2,(()=>`Packed arg${n.charAt(0).toUpperCase()+n.slice(1)} supports only inputs with rank above 2.`));const a=e[e.length-1],i=Math.ceil(a/t);this.outputShape=e.slice(0,-1),i>1&&this.outputShape.push(i),r||this.variableNames.push("bestIndicesA");const s=this.outputShape,o=s.length,u=IL(o),l=HF("coords",o);let c,p;if(1===i){p=o+1;const e=IL(p);c=`\n ${e} sourceLocR = ${e}(${l.join()}, 0);\n ++${l[o-1]};\n ${e} sourceLocG = ${e}(${l.join()}, 0);\n ++${l[o-2]};\n ${e} sourceLocA = ${e}(${l.join()}, 0);\n --${l[o-1]};\n ${e} sourceLocB = ${e}(${l.join()}, 0);\n --${l[o-2]};`}else p=o,c=`\n ${u} sourceLocR = coords;\n ++${l[o-1]};\n ${u} sourceLocG = coords;\n ++${l[o-2]};\n ${u} sourceLocA = coords;\n --${l[o-1]};\n ${u} sourceLocB = coords;\n --${l[o-2]};`;const d=["x","y","z","w","u","v"].slice(0,p),h="."+d[p-1],f=d.map((e=>"int "+e)),m=HF("sourceLocR",p-1).concat("inIdx.r"),g=HF("sourceLocG",p-1).concat("inIdx.g"),y=HF("sourceLocB",p-1).concat("inIdx.b"),b=HF("sourceLocA",p-1).concat("inIdx.a"),v="max"===n?"greaterThan":"lessThan",x=r?"":`\n inIdx = round(vec4(getBestIndicesAChannel(${m.join()}),\n getBestIndicesAChannel(${g.join()}),\n getBestIndicesAChannel(${y.join()}),\n getBestIndicesAChannel(${b.join()})));`,_=`vec4(\n getAChannel(${m.join()}),\n hasNextCol ? getAChannel(${g.join()}) : 0.,\n hasNextRow ? getAChannel(${y.join()}) : 0.,\n hasNextRow && hasNextCol ? getAChannel(${b.join()}) : 0.)`,w=r?"":`\n float getBestIndicesAChannel(${f.join()}) {\n return getChannel(getBestIndicesA(${d.join()}),\n vec2(${d.slice(-2).join()}));\n }`;this.userCode=`\n float getAChannel(${f.join()}) {\n return getChannel(getA(${d.join()}),\n vec2(${d.slice(-2).join()}));\n }\n ${w}\n void main() {\n ${u} coords = getOutputCoords();\n bool hasNextCol = ${l[o-1]} < ${s[o-1]-1};\n bool hasNextRow = ${l[o-2]} < ${s[o-2]-1};\n ${c}\n ivec4 srcIdx = ivec4(sourceLocR${h}, sourceLocG${h},\n sourceLocB${h}, sourceLocA${h}) * ${t};\n ivec4 inIdx = srcIdx;\n vec4 bestIndex = vec4(inIdx);\n vec4 bestValue = ${_};\n\n for (int i = 0; i < ${t}; i++) {\n inIdx = srcIdx;\n ${x}\n vec4 candidate = ${_};\n bvec4 nan = isnan(candidate);\n bvec4 replace = bvec4(\n vec4(${v}(candidate, bestValue)) * (vec4(1.0) - vec4(nan)));\n\n bestValue = vec4(replace.x ? candidate.x : bestValue.x,\n replace.y ? candidate.y : bestValue.y,\n replace.z ? candidate.z : bestValue.z,\n replace.w ? candidate.w : bestValue.w);\n bestIndex = mix(bestIndex, vec4(inIdx), vec4(replace));\n srcIdx++;\n }\n setOutput(bestIndex);\n }\n `}}function eO(e,t,n,r=null){let a=t.shape[0],i=t.shape[1];null!=r&&(a=r.shape[0],i=r.shape[1]);const s=tf(i),o={windowSize:s,inSize:i,batchSize:a,outSize:Math.ceil(i/s)},u=new Z$(o,n,null==r),l=[t];null!=r&&l.push(r);const c=e.runWebGLProgram(u,l,"int32");if(1===c.shape[1])return c;const p=eO(e,t,n,c);return e.disposeIntermediateTensorInfo(c),p}function tO(e,t,n,r=null){const a=null!=r?r.shape:t.shape,i=tf(a[a.length-1]),s=new Q$(a,i,n,null==r),o=null==r?[t]:[t,r],u=e.runWebGLProgram(s,o,"int32");if(u.shape.length===t.shape.length){const r=tO(e,t,n,u);return e.disposeIntermediateTensorInfo(u),r}return u}function nO(e,t,n,r){const a=[n];if(bc("arg"+r.charAt(0).toUpperCase()+r.slice(1),a,t.shape.length),!Ge().getBool("WEBGL_PACK_REDUCE")||t.shape.length<=2){const n=[],i=e.texData.get(t.dataId);let s=t;null!==i&&i.isPacked&&(s=e.unpackTensor(t),n.push(s));const[o,u]=gc(s.shape,a),l=ce(u),c=N$({inputs:{x:s},backend:e,attrs:{shape:[-1,l]}});n.push(c);const p=eO(e,c,r);n.push(p);const d=N$({inputs:{x:p},backend:e,attrs:{shape:o}});return n.forEach((t=>e.disposeIntermediateTensorInfo(t))),d}return tO(e,t,r)}const rO={kernelName:st,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i}=r;let s=xe(i,a.shape);const o=vc(s,a.shape.length);let u=a;const l=[];null!=o&&(u=F$({inputs:{x:a},backend:n,attrs:{perm:o}}),l.push(u),s=_c(s.length,u.shape.length)),bc("argMax",[s[0]],u.shape.length);const c=nO(n,u,s[0],"max");return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),c}},aO={kernelName:ot,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i}=r;let s=xe(i,a.shape);const o=vc(s,a.shape.length);let u=a;const l=[];null!=o&&(u=F$({inputs:{x:a},backend:n,attrs:{perm:o}}),l.push(u),s=_c(s.length,u.shape.length)),bc("argMin",[s[0]],u.shape.length);const c=nO(n,u,s[0],"min");return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),c}},iO=g$({opSnippet:"if (isnan(x)) return x;\n if (abs(x) > 1.) {\n return NAN;\n }\n return asin(x);\n"}),sO={kernelName:ut,backendName:"webgl",kernelFunc:iO},oO=g$({opSnippet:"if (isnan(x)) return x;return log(x + sqrt(x * x + 1.0));"}),uO={kernelName:lt,backendName:"webgl",kernelFunc:oO},lO=g$({opSnippet:"if (isnan(x)) return x;\n return atan(x);\n"}),cO={kernelName:ct,backendName:"webgl",kernelFunc:lO},pO=y$({opSnippet:"\n if (isnan(a)) return a;\n if (isnan(b)) return b;\n\n return atan(a, b);\n",packedOpSnippet:"\n vec4 result = atan(a, b);\n vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));\n \n result.r = isNaN.r > 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n"}),dO={kernelName:dt,backendName:"webgl",kernelFunc:pO},hO=g$({opSnippet:"if (isnan(x)) return x;\n if ((x < -1.0) || (x > 1.0)) return NAN;\nreturn (log(1.0 + x) - log(1.0 - x)) / 2.0;"}),fO={kernelName:pt,backendName:"webgl",kernelFunc:hO};class mO{constructor(e,t,n,r=!1,a=!1){if(this.variableNames=["x"],"avg"===t&&n)throw new Error("Cannot compute positions for average pool.");const i=e.filterWidth,s=e.strideHeight,o=e.strideWidth,u=e.dilationHeight,l=e.dilationWidth,c=e.effectiveFilterHeight,p=e.effectiveFilterWidth,d=e.padInfo.top,h=e.padInfo.left;this.outputShape=e.outShape;const f="avg"===t,m=`((batch * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + d`,g=`(xR * ${e.inWidth} + xC) * ${e.inChannels} + d`;let y="0.0";if(f||(y="-1.0 / 1e-20"),n){const t=">=";return void(this.userCode=`\n const ivec2 strides = ivec2(${s}, ${o});\n const ivec2 pads = ivec2(${d}, ${h});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d = coords[3];\n\n ivec2 xRCCorner = coords.yz * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // max/min x(?, ?, d) to get y(yR, yC, d).\n // ? = to be determined\n float minMaxValue = 0.0;\n float minMaxValueFound = 0.0;\n int minMaxPosition = 0;\n float avgValue = 0.0;\n\n for (int wR = 0; wR < ${c};\n wR += ${u}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${p};\n wC += ${l}) {\n int xC = xCCorner + wC;\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n float value = getX(batch, xR, xC, d);\n\n // If a min / max value has already been found, use it. If not,\n // use the current value.\n float currMinMaxValue = mix(\n value, minMaxValue, minMaxValueFound);\n if (value ${t} currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition = ${r?a?m:g:`wR * ${p} + wC`};\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n `)}let b=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"avg"===t&&(b="avgValue / count");const v=4*Math.floor(i/4),x=i%4,_=`\n if (${f}) {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n `;this.userCode=`\n const ivec2 strides = ivec2(${s}, ${o});\n const ivec2 pads = ivec2(${d}, ${h});\n const float initializationValue = ${y};\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float count = 0.0;\n\n float getValue(int batch, int xR, int xC, int d) {\n if (xC < 0 || xC >= ${e.inWidth}) {\n return initializationValue;\n }\n count += 1.0;\n return getX(batch, xR, xC, d);\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d = coords[3];\n\n ivec2 xRCCorner = coords.yz * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // max/min x(?, ?, d) to get y(yR, yC, d).\n // ? = to be determined\n vec4 minMaxValue = vec4(${y});\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wR = 0; wR < ${c};\n wR += ${u}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${v}; wC += 4) {\n int xC = xCCorner + wC * ${l};\n\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${l}, d),\n getValue(batch, xR, xC + 2 * ${l}, d),\n getValue(batch, xR, xC + 3 * ${l}, d)\n );\n\n ${_}\n }\n\n int xC = xCCorner + ${v};\n if (${1===x}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${_}\n } else if (${2===x}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${l}, d),\n initializationValue,\n initializationValue\n );\n\n ${_}\n } else if (${3===x}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${l}, d),\n getValue(batch, xR, xC + 2 * ${l}, d),\n initializationValue\n );\n\n ${_}\n }\n }\n setOutput(${b});\n }\n `}}class gO{constructor(e,t,n,r=!1,a=!1){if(this.variableNames=["x"],"avg"===t&&n)throw new Error("Cannot compute positions for average pool.");const i=e.filterWidth,s=e.strideDepth,o=e.strideHeight,u=e.strideWidth,l=e.dilationDepth,c=e.dilationHeight,p=e.dilationWidth,d=e.effectiveFilterDepth,h=e.effectiveFilterHeight,f=e.effectiveFilterWidth,m=e.padInfo.front,g=e.padInfo.top,y=e.padInfo.left;this.outputShape=e.outShape;const b="avg"===t;let v="0.0";if(b||(v="-1.0 / 1e-20"),n){const t=">=";return void(this.userCode=`\n const ivec3 strides =\n ivec3(${s}, ${o}, ${u});\n const ivec3 pads = ivec3(${m}, ${g}, ${y});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xDCorner = xCorner.x;\n int xRCorner = xCorner.y;\n int xCCorner = xCorner.z;\n\n // max/min x(?, ?, ?, ch) to get y(yD, yR, yC, ch).\n // ? = to be determined\n float minMaxValue = 0.0;\n float minMaxValueFound = 0.0;\n int minMaxPosition = 0;\n\n for (int wD = 0; wD < ${d};\n wD += ${l}) {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= ${e.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${h};\n wR += ${c}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${f};\n wC += ${p}) {\n int xC = xCCorner + wC;\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n float value = getX(batch, xD, xR, xC, ch);\n\n // If a min / max value has already been found, use it. If not,\n // use the current value.\n float currMinMaxValue = mix(\n value, minMaxValue, minMaxValueFound);\n if (value ${t} currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition = ${r?a?`(((batch * ${e.inDepth} + xD) * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`((xD * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch`:`wD * ${h} * ${f} +\n wR * ${f} + wC`};\n }\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n `)}let x=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"avg"===t&&(x="avgValue / count");const _=4*Math.floor(i/4),w=i%4,D=`\n if (${b}) {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n `;this.userCode=`\n const ivec3 strides =\n ivec3(${s}, ${o}, ${u});\n const ivec3 pads = ivec3(${m}, ${g}, ${y});\n const float initializationValue = ${v};\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float count = 0.0;\n\n float getValue(int batch, int xD, int xR, int xC, int ch) {\n if (xC < 0 || xC >= ${e.inWidth}) {\n return initializationValue;\n }\n count += 1.0;\n return getX(batch, xD, xR, xC, ch);\n }\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xDCorner = xCorner.x;\n int xRCorner = xCorner.y;\n int xCCorner = xCorner.z;\n\n // max/min x(?, ?, ?, d) to get y(yD, yR, yC, ch).\n // ? = to be determined\n vec4 minMaxValue = vec4(${v});\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wD = 0; wD < ${d};\n wD += ${l}) {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= ${e.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${h};\n wR += ${c}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${_}; wC += 4) {\n int xC = xCCorner + wC * ${p};\n\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ${p}, ch),\n getValue(batch, xD, xR, xC + 2 * ${p}, ch),\n getValue(batch, xD, xR, xC + 3 * ${p}, ch)\n );\n\n ${D}\n }\n\n int xC = xCCorner + ${_};\n if (${1===w}) {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${D}\n } else if (${2===w}) {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ${p}, ch),\n initializationValue,\n initializationValue\n );\n\n ${D}\n } else if (${3===w}) {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ${p}, ch),\n getValue(batch, xD, xR, xC + 2 * ${p}, ch),\n initializationValue\n );\n\n ${D}\n }\n }\n setOutput(${x});\n }\n }\n `}}const yO={kernelName:ht,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t;mL(a,"avgPool");const{filterSize:i,strides:s,pad:o,dimRoundingMode:u}=r;se(xl(s,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${s} and dilations '1'`));const l=cl(a.shape,i,s,1,o,u);if(1===l.filterWidth&&1===l.filterHeight&&de(l.inShape,l.outShape))return s$({inputs:{x:a},backend:n});const c=new mO(l,"avg",!1);return n.runWebGLProgram(c,[a],"float32")}},bO={kernelName:mt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{filterSize:i,strides:s,pad:o,dimRoundingMode:u,dataFormat:l}=r,c=pl(a.shape,i,s,[1,1,1],o,u,l),p=new gO(c,"avg",!1);return n.runWebGLProgram(p,[a],"float32")}};class vO{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,a=e.strideWidth,i=e.dilationHeight,s=e.dilationWidth,o=e.effectiveFilterHeight,u=e.effectiveFilterWidth,l=o-1-e.padInfo.top,c=u-1-e.padInfo.left,p=1/(t*n);this.userCode=`\n const ivec2 pads = ivec2(${l}, ${c});\n const float avgMultiplier = float(${p});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n\n ivec2 dyRCCorner = coords.yz - pads;\n int dyRCorner = dyRCCorner.x;\n int dyCCorner = dyRCCorner.y;\n\n // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${o};\n wR += ${i}) {\n float dyR = float(dyRCorner + wR) / ${r}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${u};\n wC+= ${s}) {\n float dyC = float(dyCCorner + wC) / ${a}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(b, idyR, idyC, d);\n\n dotProd += dyValue * avgMultiplier;\n }\n }\n setOutput(dotProd);\n }\n `}}class xO{constructor(e){this.variableNames=["dy"],this.outputShape=e.inShape;const t=e.filterDepth,n=e.filterHeight,r=e.filterWidth,a=e.strideDepth,i=e.strideHeight,s=e.strideWidth,o=e.dilationDepth,u=e.dilationHeight,l=e.dilationWidth,c=e.effectiveFilterDepth,p=e.effectiveFilterHeight,d=e.effectiveFilterWidth,h=c-1-e.padInfo.front,f=p-1-e.padInfo.top,m=d-1-e.padInfo.left,g=1/(t*n*r);this.userCode=`\n const ivec3 pads = ivec3(${h}, ${f}, ${m});\n const float avgMultiplier = float(${g});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyDCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n // Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get\n // dx(xD, xR, xC, ch).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int wD = 0; wD < ${c};\n wD += ${o}) {\n float dyD = float(dyDCorner + wD) / ${a}.0;\n\n if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) {\n continue;\n }\n int idyD = int(dyD);\n\n for (int wR = 0; wR < ${p};\n wR += ${u}) {\n float dyR = float(dyRCorner + wR) / ${i}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${d};\n wC += ${l}) {\n float dyC = float(dyCCorner + wC) / ${s}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n\n dotProd += dyValue * avgMultiplier;\n }\n }\n }\n setOutput(dotProd);\n }\n `}}const _O={kernelName:gt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i}=t,s=i,{filterSize:o,strides:u,pad:l,dimRoundingMode:c}=r,p=pl(s.shape,o,u,[1,1,1],l,c),d=new xO(p);return n.runWebGLProgram(d,[a],s.dtype)}},wO={kernelName:ft,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i}=t,s=i;mL([a,i],"avgPoolGrad");const{filterSize:o,strides:u,pad:l}=r,c=cl(s.shape,o,u,1,l),p=new vO(c);return n.runWebGLProgram(p,[a],s.dtype)}},DO={kernelName:yt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{a,b:i}=t,{transposeA:s,transposeB:o}=r;return O$({a,b:i,transposeA:s,transposeB:o,backend:n})}};class NO{constructor(e,t,n,r,a,i){this.outputShape=[],this.variableNames=["x","mean","variance"],Lo(e,t),Lo(e,n);let s="0.0";null!=r&&(Lo(e,r),this.variableNames.push("offset"),s="getOffsetAtOutCoords()");let o="1.0";null!=a&&(Lo(e,a),this.variableNames.push("scale"),o="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=`\n void main() {\n float x = getXAtOutCoords();\n float mean = getMeanAtOutCoords();\n float variance = getVarianceAtOutCoords();\n float offset = ${s};\n float scale = ${o};\n float inv = scale * inversesqrt(variance + float(${i}));\n setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1)));\n }\n `}}class MO{constructor(e,t,n,r,a,i){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],Lo(e,t),Lo(e,n);let s="vec4(0.0)";null!=r&&(Lo(e,r),this.variableNames.push("offset"),s="getOffsetAtOutCoords()");let o="vec4(1.0)";null!=a&&(Lo(e,a),this.variableNames.push("scale"),o="getScaleAtOutCoords()"),this.outputShape=e,this.userCode=`\n void main() {\n vec4 offset = ${s};\n vec4 scale = ${o};\n\n vec4 x = getXAtOutCoords();\n vec4 mean = getMeanAtOutCoords();\n vec4 variance = getVarianceAtOutCoords();\n\n vec4 inv = scale * inversesqrt(variance + vec4(${i}));\n\n setOutput((x - mean) * inv + offset);\n }\n `}}const SO={kernelName:ln,backendName:"webgl",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:r,mean:a,variance:i,offset:s,scale:o}=e;se(a.shape.length===i.shape.length,(()=>"Batch normalization gradient requires mean and variance to have equal ranks.")),se(null==s||a.shape.length===s.shape.length,(()=>"Batch normalization gradient requires mean and offset to have equal ranks.")),se(null==o||a.shape.length===o.shape.length,(()=>"Batch normalization gradient requires mean and scale to have equal ranks."));let{varianceEpsilon:u}=n;null==u&&(u=.001);const l=[r,a,i];let c=null;null!=s&&(c=s.shape,l.push(s));let p=null;null!=o&&(p=o.shape,l.push(o));const d=Ge().getBool("WEBGL_PACK_NORMALIZATION")?new MO(r.shape,a.shape,i.shape,c,p,u):new NO(r.shape,a.shape,i.shape,c,p,u);return t.runWebGLProgram(d,l,l[0].dtype)}};class kO{constructor(e){this.variableNames=["source"],this.outputShape=e,this.rank=e.length;const t=IL(this.rank);this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];const n=function(e){if(1===e)return"sourceLoc";if(e<=6)return TO.slice(0,e).map((e=>"sourceLoc."+e)).join(",");throw Error(`Slicing for rank ${e} is not yet supported`)}(this.rank);let r;const a=e.map(((e,t)=>`sourceLoc.${TO[t]} = start[${t}] + coords.${TO[t]};`));r=`\n ${t} sourceLoc;\n ${t} coords = getOutputCoords();\n ${a.join("\n")}\n `,this.userCode=`\n void main() {\n ${r}\n setOutput(getSource(${n}));\n }\n `}}const TO=["x","y","z","w","u","v"];class CO{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=IL(this.rank),n=HF("coords",this.rank),r=HF("sourceLoc",this.rank),a=1===this.rank?"sourceLoc":`vec2(${r.slice(-2).join()})`,i=`getChannel(getSource(${r.join()}), ${a})`,s=`\n result.x = ${i};\n if (++${n[this.rank-1]} < ${e[this.rank-1]}) {\n ++${r[this.rank-1]};\n result.y = ${i};\n --${r[this.rank-1]};\n }\n `,o=1===this.rank?"":`\n --${n[this.rank-1]};\n if (++${n[this.rank-2]} < ${e[this.rank-2]}) {\n ++${r[this.rank-2]};\n result.z = ${i};\n if (++${n[this.rank-1]} < ${e[this.rank-1]}) {\n ++${r[this.rank-1]};\n result.w = ${i};\n }\n }\n `,u=this.rank<=4?`sourceLoc = coords +\n ${t}(${e.map(((e,t)=>`start[${t}]`)).join()});`:e.map(((e,t)=>`${r[t]} = ${n[t]} + start[${t}];`)).join("\n");this.userCode=`\n void main() {\n ${t} coords = getOutputCoords();\n ${t} sourceLoc;\n ${u}\n vec4 result = vec4(0.);\n ${s}\n ${o}\n setOutput(result);\n }\n `}}function EO(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{begin:i,size:s}=r,[o,u]=au(a,i,s);if(Uo(a,o,u),0===ce(u))return n.makeTensorInfo(u,a.dtype,[]);if(n.shouldExecuteOnCPU([a])||"string"===a.dtype){const e=n.texData.get(a.dataId),t=kF(e.values,o,u,a.shape,a.dtype);return n.makeTensorInfo(u,a.dtype,t)}const{isPacked:l}=n.texData.get(a.dataId),c=nu(a.shape,o,u);if(l||!c){const e=Ge().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new CO(u):new kO(u),t=[o];return n.runWebGLProgram(e,[a],a.dtype,t)}return n.uploadToGPU(a.dataId),function(e,t,n,r){const a=r.texData.get(e.dataId),i=r.makeTensorInfo(n,e.dtype),s=r.texData.get(i.dataId);Object.assign(s,a),s.refCount=1,s.shape=n,s.dtype=e.dtype;let o=ru(t,Oe(e.shape));a.slice&&(o+=a.slice.flatOffset),s.slice={flatOffset:o,origDataId:a.slice&&a.slice.origDataId||e.dataId};const u=r.dataRefCount.get(s.slice.origDataId)||1;return r.dataRefCount.set(s.slice.origDataId,u+1),i}(a,o,u,n)}const AO={kernelName:Nr,backendName:"webgl",kernelFunc:EO},IO={kernelName:bt,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockShape:i,crops:s}=r;se(a.shape.length<=4,(()=>"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet"));const o=i.reduce(((e,t)=>e*t)),u=rf(a.shape,i,o),l=af(u.length,i.length),c=sf(a.shape,i,o),p=of(s,i.length),d=uf(c,s,i.length),h=[],f=N$({inputs:{x:a},backend:n,attrs:{shape:u}}),m=F$({inputs:{x:f},backend:n,attrs:{perm:l}}),g=N$({inputs:{x:m},backend:n,attrs:{shape:c}}),y=EO({inputs:{x:g},backend:n,attrs:{begin:p,size:d}});return h.push(f),h.push(m),h.push(g),h.forEach((e=>n.disposeIntermediateTensorInfo(e))),y}},LO={kernelName:vt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,weights:i}=t,{size:s}=r,o=n.readSync(a.dataId),u=n.readSync(i.dataId),l=QL(o,u,i.dtype,i.shape,s);return n.makeTensorInfo([s],i.dtype,l)}},FO={kernelName:_t,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{s0:r,s1:a}=t,i=n.readSync(r.dataId),s=n.readSync(a.dataId),o=Lo(Array.from(i),Array.from(s));return n.makeTensorInfo([o.length],"int32",Int32Array.from(o))}},$O=y$({opSnippet:"return float(a != b);",cpuKernelImpl:xF,dtype:"bool"}),OO={kernelName:Kn,backendName:"webgl",kernelFunc:$O};function RO(e){const{inputs:t,backend:n}=e,{input:r}=t;return s$({inputs:{x:n.texData.get(r.dataId).complexTensorInfos.real},backend:n})}const YO={kernelName:ur,backendName:"webgl",kernelFunc:RO},BO={kernelName:wt,backendName:"webgl",kernelFunc:function e(t){const{inputs:n,backend:r,attrs:a}=t,{x:i}=n,{dtype:s}=a;if("complex64"===s){if("complex64"===i.dtype)return s$({inputs:{x:i},backend:r});const t=up(i.shape),n=e({inputs:{x:i},backend:r,attrs:{dtype:"float32"}}),a=u$({inputs:{real:n,imag:t},backend:r});return t.dispose(),r.disposeIntermediateTensorInfo(n),a}if("complex64"===i.dtype){const t=RO({inputs:{input:i},backend:r}),n=e({inputs:{x:t},backend:r,attrs:{dtype:s}});return r.disposeIntermediateTensorInfo(t),n}if(!Se(i.dtype,s)){const e=s$({inputs:{x:i},backend:r});return{dataId:e.dataId,shape:e.shape,dtype:s}}if("int32"===s)return function(e,t){const n=new KF(e.shape,"return float(int(x));"),r=t.runWebGLProgram(n,[e],"int32");return{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}(i,r);if("bool"===s){const e=r.makeTensorInfo([],"bool",we("bool",1)),t=$O({inputs:{a:i,b:e},backend:r});return r.disposeIntermediateTensorInfo(e),t}throw new Error(`Error in Cast: failed to cast ${i.dtype} to ${s}`)}},zO="return ceil(x);",PO=g$({opSnippet:zO,packedOpSnippet:zO,cpuKernelImpl:tF}),HO={kernelName:Dt,backendName:"webgl",kernelFunc:PO};class jO{constructor(e){this.variableNames=["A"],this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode="\n\n void main() {\n float value = getAAtOutCoords();\n if (isnan(value)) {\n setOutput(value);\n return;\n }\n\n setOutput(clamp(value, minVal, maxVal));\n }\n "}}class UO{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="\n void main() {\n vec4 value = getAAtOutCoords();\n\n if (any(isnan(value))) {\n setOutput(value);\n return;\n }\n\n setOutput(clamp(value, vec4(minVal), vec4(maxVal)));\n }\n "}}const qO={kernelName:Nt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{clipValueMin:i,clipValueMax:s}=r;let o;o=Ge().getBool("WEBGL_PACK_CLIP")?new UO(a.shape):new jO(a.shape);const u=[[i],[s]];return n.runWebGLProgram(o,[a],a.dtype,u)}};class WO{constructor(e){this.variableNames=["real","imag"],this.outputShape=e,this.userCode="\n void main() {\n float re = abs(getRealAtOutCoords());\n float im = abs(getImagAtOutCoords());\n float mx = max(re, im);\n\n // sadly the length function in glsl is not underflow-safe\n // (at least not on Intel GPUs). So the safe solution is\n // to ensure underflow-safety in all cases.\n setOutput(\n mx == 0.0 ? 0.0 : mx * length(vec2(1, min(re, im)/mx))\n );\n }\n "}}function VO(e,t){return{dataId:t.dataId,dtype:t.dtype,shape:e.shape}}const GO={kernelName:St,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r}=t,a=n.texData.get(r.dataId),i=new WO(r.shape),s=[VO(r,a.complexTensorInfos.real),VO(r,a.complexTensorInfos.imag)];return n.runWebGLProgram(i,s,s[0].dtype)}};class KO{constructor(e){this.outputShape=[],this.outputShape=Qh(e,1),this.variableNames=e.map(((e,t)=>`T${t}`));const t=new Array(e.length-1);t[0]=e[0][1];for(let n=1;n`T${t}`));const o=new Array(e.length-1);o[0]=e[0][t];for(let n=1;n= ${o[e-1]}) {\n return getChannel(\n getT${e}(${XO(s,u,t)}),\n vec2(${XO(l,u,t)}));\n }`}const d=o.length,h=o[o.length-1];p+=`\n return getChannel(\n getT${d}(${XO(s,u,h)}),\n vec2(${XO(l,u,h)}));`,this.userCode=`\n float getValue(${s.map((e=>"int "+e))}) {\n ${p}\n }\n\n void main() {\n ${a} coords = getOutputCoords();\n vec4 result = vec4(getValue(${i}), 0., 0., 0.);\n\n ${i[r-1]} = ${i[r-1]} + 1;\n if (${i[r-1]} < ${n[r-1]}) {\n result.g = getValue(${i});\n }\n\n ${i[r-2]} = ${i[r-2]} + 1;\n if (${i[r-2]} < ${n[r-2]}) {\n result.a = getValue(${i});\n }\n\n ${i[r-1]} = ${i[r-1]} - 1;\n if (${i[r-2]} < ${n[r-2]} &&\n ${i[r-1]} < ${n[r-1]}) {\n result.b = getValue(${i});\n }\n setOutput(result);\n }\n `}}function XO(e,t,n){const r=e.indexOf(t);return e.map(((e,t)=>t===r?`${e} - ${n}`:e)).join()}function ZO(e){const{inputs:t,backend:n}=e,{input:r}=t;return s$({inputs:{x:n.texData.get(r.dataId).complexTensorInfos.imag},backend:n})}const QO={kernelName:gn,backendName:"webgl",kernelFunc:ZO};function eR(e,t,n){const r=e[0].dtype;if("complex64"===r){const r=e.map((e=>RO({inputs:{input:e},backend:n}))),a=e.map((e=>ZO({inputs:{input:e},backend:n}))),i=eR(r,t,n),s=eR(a,t,n),o=u$({inputs:{real:i,imag:s},backend:n});return r.forEach((e=>n.disposeIntermediateTensorInfo(e))),a.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(s),o}let a=n.shouldExecuteOnCPU(e);if("string"===r&&(a=!0),a){const a=e.map((e=>{const r=ce(e.shape.slice(t));return N$({inputs:{x:e},backend:n,attrs:{shape:[-1,r]}})})),i=a.map((e=>({vals:n.readSync(e.dataId),shape:e.shape}))),s=Qh(a.map((e=>e.shape)),1),o=1===a[0].shape[0],u=nF(i,s,r,o),l=Qh(e.map((e=>e.shape)),t),c=n.makeTensorInfo(l,r,u);return a.forEach((e=>n.disposeIntermediateTensorInfo(e))),c}const i=Ge().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER");if(e.length>i){const r=[];for(let a=0;a1){const a=new JO(e.map((e=>e.shape)),t);return n.runWebGLProgram(a,e,r)}const{tensors2D:s,outShape:o}=function(e,t,n){const r=Qh(e.map((e=>e.shape)),t);return{tensors2D:e.map((e=>N$({inputs:{x:e},attrs:{shape:[-1,ce(e.shape.slice(t))]},backend:n}))),outShape:r}}(e,t,n),u=new KO(s.map((e=>e.shape))),l=n.runWebGLProgram(u,s,r);s.forEach((e=>n.disposeIntermediateTensorInfo(e)));const c=N$({inputs:{x:l},attrs:{shape:o},backend:n});return n.disposeIntermediateTensorInfo(l),c}function tR(e){const{inputs:t,backend:n,attrs:r}=e,{axis:a}=r,i=xe(a,t[0].shape)[0],s=Qh(t.map((e=>e.shape)),i);if(0===ce(s))return n.makeTensorInfo(s,t[0].dtype,[]);const o=t.filter((e=>ce(e.shape)>0));return 1===o.length?s$({inputs:{x:o[0]},backend:n}):(Zh(o.map((e=>e.shape)),i),eR(o,i,n))}const nR={kernelName:kt,backendName:"webgl",kernelFunc:tR};class rR{constructor(e,t=!1,n=null,r=!1,a=!1){this.variableNames=["x","W"],this.outputShape=e.outShape;const i=e.padInfo.top,s=e.padInfo.left,o=e.strideHeight,u=e.strideWidth,l=e.dilationHeight,c=e.dilationWidth,p=e.filterHeight,d=e.filterWidth,h=4*Math.floor(e.inChannels/4),f=e.inChannels%4,m="channelsLast"===e.dataFormat,g=m?1:2,y=m?2:3,b=m?3:1;let v="",x="";n&&(v=r?`float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:a?`float activation(float a) {\n float b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`\n float activation(float x) {\n ${n}\n }\n `,x="result = activation(result);");const _=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${v}\n\n const ivec2 strides = ivec2(${o}, ${u});\n const ivec2 pads = ivec2(${i}, ${s});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d2 = coords[${b}];\n\n ivec2 xRCCorner =\n ivec2(coords[${g}], coords[${y}]) * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${p}; wR++) {\n int xR = xRCorner + wR * ${l};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${d}; wC++) {\n int xC = xCCorner + wC * ${c};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n for (int d1 = 0; d1 < ${h}; d1 += 4) {\n vec4 wValues = vec4(\n getW(wR, wC, d1, d2),\n getW(wR, wC, d1 + 1, d2),\n getW(wR, wC, d1 + 2, d2),\n getW(wR, wC, d1 + 3, d2)\n );\n\n if (${m}) {\n vec4 xValues = vec4(\n getX(batch, xR, xC, d1),\n getX(batch, xR, xC, d1 + 1),\n getX(batch, xR, xC, d1 + 2),\n getX(batch, xR, xC, d1 + 3)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec4 xValues = vec4(\n getX(batch, d1, xR, xC),\n getX(batch, d1 + 1, xR, xC),\n getX(batch, d1 + 2, xR, xC),\n getX(batch, d1 + 3, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n\n if (${1===f}) {\n\n if (${m}) {\n dotProd +=\n getX(batch, xR, xC, ${h}) *\n getW(wR, wC, ${h}, d2);\n } else {\n dotProd +=\n getX(batch, ${h}, xR, xC) *\n getW(wR, wC, ${h}, d2);\n }\n\n } else if (${2===f}) {\n vec2 wValues = vec2(\n getW(wR, wC, ${h}, d2),\n getW(wR, wC, ${h} + 1, d2)\n );\n\n if (${m}) {\n vec2 xValues = vec2(\n getX(batch, xR, xC, ${h}),\n getX(batch, xR, xC, ${h} + 1)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec2 xValues = vec2(\n getX(batch, ${h}, xR, xC),\n getX(batch, ${h} + 1, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n } else if (${3===f}) {\n vec3 wValues = vec3(\n getW(wR, wC, ${h}, d2),\n getW(wR, wC, ${h} + 1, d2),\n getW(wR, wC, ${h} + 2, d2)\n );\n\n if (${m}) {\n vec3 xValues = vec3(\n getX(batch, xR, xC, ${h}),\n getX(batch, xR, xC, ${h} + 1),\n getX(batch, xR, xC, ${h} + 2)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec3 xValues = vec3(\n getX(batch, ${h}, xR, xC),\n getX(batch, ${h} + 1, xR, xC),\n getX(batch, ${h} + 2, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n }\n }\n }\n\n float result = dotProd;\n ${_}\n ${x}\n setOutput(result);\n }\n `}}class aR{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const t=e.padInfo.front,n=e.padInfo.top,r=e.padInfo.left,a=e.strideDepth,i=e.strideHeight,s=e.strideWidth,o=e.dilationDepth,u=e.dilationHeight,l=e.dilationWidth,c=e.filterDepth,p=e.filterHeight,d=e.filterWidth,h=4*Math.floor(e.inChannels/4),f=e.inChannels%4;this.userCode=`\n const ivec3 strides = ivec3(${a}, ${i}, ${s});\n const ivec3 pads = ivec3(${t}, ${n}, ${r});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int d2 = coords.u;\n\n ivec3 xFRCCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xFCorner = xFRCCorner.x;\n int xRCorner = xFRCCorner.y;\n int xCCorner = xFRCCorner.z;\n\n // Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get\n // y(yF, yR, yC, d2). ? = to be determined. : = across all\n // values in that axis.\n float dotProd = 0.0;\n for (int wF = 0; wF < ${c}; wF++) {\n int xF = xFCorner + wF * ${o};\n\n if (xF < 0 || xF >= ${e.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${p}; wR++) {\n int xR = xRCorner + wR * ${u};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${d}; wC++) {\n int xC = xCCorner + wC * ${l};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n for (int d1 = 0; d1 < ${h}; d1 += 4) {\n vec4 xValues = vec4(\n getX(batch, xF, xR, xC, d1),\n getX(batch, xF, xR, xC, d1 + 1),\n getX(batch, xF, xR, xC, d1 + 2),\n getX(batch, xF, xR, xC, d1 + 3)\n );\n vec4 wValues = vec4(\n getW(wF, wR, wC, d1, d2),\n getW(wF, wR, wC, d1 + 1, d2),\n getW(wF, wR, wC, d1 + 2, d2),\n getW(wF, wR, wC, d1 + 3, d2)\n );\n\n dotProd += dot(xValues, wValues);\n }\n\n if (${1===f}) {\n dotProd +=\n getX(batch, xF, xR, xC, ${h}) *\n getW(wF, wR, wC, ${h}, d2);\n } else if (${2===f}) {\n vec2 xValues = vec2(\n getX(batch, xF, xR, xC, ${h}),\n getX(batch, xF, xR, xC, ${h} + 1)\n );\n vec2 wValues = vec2(\n getW(wF, wR, wC, ${h}, d2),\n getW(wF, wR, wC, ${h} + 1, d2)\n );\n dotProd += dot(xValues, wValues);\n } else if (${3===f}) {\n vec3 xValues = vec3(\n getX(batch, xF, xR, xC, ${h}),\n getX(batch, xF, xR, xC, ${h} + 1),\n getX(batch, xF, xR, xC, ${h} + 2)\n );\n vec3 wValues = vec3(\n getW(wF, wR, wC, ${h}, d2),\n getW(wF, wR, wC, ${h} + 1, d2),\n getW(wF, wR, wC, ${h} + 2, d2)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n }\n }\n setOutput(dotProd);\n }\n `}}class iR{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=YL(this.outputShape.length);const{dataFormat:n}=t,r=yL(),a="channelsLast"===n,i=a?1:2,s=a?2:3,o=this.enableShapeUniforms?"if(blockIndex < outShape[2] && pos < outShape[1]) {":`if(blockIndex < ${e[2]} && pos < ${e[1]}) {`;let u="";for(let e=0;e<=1;e++)for(let t=0;t<=1;t++)u+=`\n blockIndex = rc.z + ${t};\n pos = rc.y + ${e};\n\n ${o}\n offsetY = int(blockIndex / outWidth) * stride[0] - pad[0];\n d0 = offsetY + dilation[0] * (pos / itemsPerBlockRow);\n\n if(d0 < inputShape[${i}] && d0 >= 0) {\n // Use custom imod instead mod. On Intel GPU, mod may generate\n // unexpected value.\n // https://github.com/tensorflow/tfjs/issues/5447\n offsetX = imod(blockIndex, outWidth) * stride[1] - pad[1];\n d1 = offsetX + dilation[1] * (imod(pos, itemsPerBlockRow) /\n inChannels);\n\n if(d1 < inputShape[${s}] && d1 >= 0) {\n\n ch = imod(pos, inChannels);\n\n if (${a}) {\n innerDims = vec2(d1, ch);\n result[${2*e+t}] = getChannel(\n getA(rc.x, d0, int(innerDims.x),\n int(innerDims.y)), innerDims);\n } else {\n innerDims = vec2(d0, d1);\n result[${2*e+t}] = getChannel(\n getA(rc.x, ch, int(innerDims.x),\n int(innerDims.y)), innerDims);\n }\n }\n }\n }\n `;this.userCode=`\n void main() {\n ivec3 rc = getOutputCoords();\n\n vec4 result = vec4(0);\n\n int blockIndex, pos, offsetY, d0, offsetX, d1, ch;\n vec2 innerDims;\n\n ${u}\n\n ${r.output} = result;\n }\n `}}function sR(e,t){const n=e.length;return n>=3?t?[...e.slice(0,-3),e[n-3]*e[n-2],e[n-1]]:[...e.slice(0,-3),e[n-3],e[n-2]*e[n-1]]:!t&&1===n&&e[0]>1?[e[0],1]:null}function oR({x:e,filter:t,convInfo:n,backend:r,bias:a=null,preluActivationWeights:i=null,leakyreluAlpha:s=0,activation:o=null}){const u=e.shape,l=r.texData.get(e.dataId),c=n.inChannels,p=u[0]*u[1]*u[2],d=n.outChannels,h="channelsLast"===n.dataFormat;let f;const m=[];if(null!=i){const e=sR(i.shape,h);null!=e&&(i=N$({inputs:{x:i},backend:r,attrs:{shape:e}}),m.push(i))}if(null!=a){const e=sR(a.shape,h);null!=e&&(a=N$({inputs:{x:a},backend:r,attrs:{shape:e}}),m.push(a))}if((1!==p&&1!==d||!(c>1e3))&&l.isPacked&&h&&null!=l.texture&&u[2]%2!=0&&de(l.shape.slice(-3),u.slice(-3))){const c=u[0]*u[1]*(u[2]+1),p={dataId:e.dataId,shape:[1,c,n.inChannels],dtype:e.dtype},d=l.shape;l.shape=l.shape.slice(),l.shape[l.shape.length-2]++,se(lL(l.shape,p.shape),(()=>`packed reshape ${l.shape} to ${p.shape} isn't free`));const h=N$({inputs:{x:t},backend:r,attrs:{shape:[1,n.inChannels,n.outChannels]}});m.push(h);const g=O$({a:p,b:h,backend:r,transposeA:!1,transposeB:!1,bias:a,activation:o,preluActivationWeights:i,leakyreluAlpha:s}),y=r.texData.get(g.dataId);se(y.isPacked,(()=>"batchMatMul result is expected to be packed")),l.shape=d,y.shape=n.outShape,f=s$({inputs:{x:g},backend:r}),f.shape=n.outShape,m.push(g)}else{const u=n.outHeight*n.outWidth,l=N$({inputs:{x:e},backend:r,attrs:{shape:h?[n.batchSize,u,n.inChannels]:[n.batchSize,n.inChannels,u]}}),c=N$({inputs:{x:t},backend:r,attrs:{shape:[1,n.inChannels,n.outChannels]}}),p=O$({a:h?l:c,b:h?c:l,transposeA:!h,transposeB:!1,backend:r,bias:a,activation:o,preluActivationWeights:i,leakyreluAlpha:s});f=N$({inputs:{x:p},backend:r,attrs:{shape:n.outShape}}),m.push(l),m.push(c),m.push(p)}for(const e of m)r.disposeIntermediateTensorInfo(e);return f}function uR({x:e,filter:t,convInfo:n,backend:r,bias:a=null,preluActivationWeights:i=null,leakyreluAlpha:s=0,activation:o=null}){const{filterWidth:u,filterHeight:l,inChannels:c,outWidth:p,outHeight:d,dataFormat:h}=n,f="channelsLast"===h,m=u*l*c,g=d*p,y=[n.batchSize,m,g],b=[];if(null!=i){const e=sR(i.shape,f);null!=e&&(i=N$({inputs:{x:i},backend:r,attrs:{shape:e}}),b.push(i))}if(null!=a){const e=sR(a.shape,f);null!=e&&(a=N$({inputs:{x:a},backend:r,attrs:{shape:e}}),b.push(a))}const v=N$({inputs:{x:t},backend:r,attrs:{shape:[1,m,ce(t.shape)/m]}});b.push(v);const x=new iR(y,n),_=[e.shape,[n.padInfo.top,n.padInfo.left],[n.strideHeight,n.strideWidth],[n.dilationHeight,n.dilationWidth],[n.inChannels],[n.filterWidth*n.inChannels],[n.outWidth]],w=r.runWebGLProgram(x,[e],"float32",_),D=N$({inputs:{x:w},backend:r,attrs:{shape:y}});b.push(w),b.push(D);const N=null!=a,M=null!=i,S="leakyrelu"===o,k=o?b$(o,!0):null,T=new v$(f?D.shape:v.shape,f?v.shape:D.shape,f?[n.batchSize,g,n.outChannels]:[n.batchSize,n.outChannels,g],!0,!1,N,k,M,S),C=f?[D,v]:[v,D];if(a&&C.push(a),M&&C.push(i),S){const e=r.makeTensorInfo([],"float32",Ra(s,"float32"));C.push(e),b.push(e)}const E=r.runWebGLProgram(T,C,"float32"),A=N$({inputs:{x:E},backend:r,attrs:{shape:n.outShape}});b.push(E);for(const e of b)r.disposeIntermediateTensorInfo(e);return A}const lR={kernelName:Tt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i}=t,{strides:s,pad:o,dataFormat:u,dilations:l,dimRoundingMode:c}=r,p=_l(u),d=dl(a.shape,i.shape,s,l,o,c,!1,p);let h;if(1!==d.filterHeight||1!==d.filterWidth||1!==d.dilationHeight||1!==d.dilationWidth||1!==d.strideHeight||1!==d.strideWidth||"SAME"!==d.padInfo.type&&"VALID"!==d.padInfo.type)if(Ge().getBool("WEBGL_CONV_IM2COL"))h=uR({x:a,filter:i,convInfo:d,backend:n});else{const e=new rR(d);h=n.runWebGLProgram(e,[a,i],"float32")}else h=oR({x:a,filter:i,convInfo:d,backend:n});const f=N$({inputs:{x:h},backend:n,attrs:{shape:d.outShape}});return n.disposeIntermediateTensorInfo(h),f}};class cR{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideHeight,n=e.strideWidth,r=e.padInfo.top,a=e.padInfo.left,i="channelsLast"===e.dataFormat;this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int wR = coords.x;\n int wC = coords.y;\n int d1 = coords.z;\n int d2 = coords.w;\n\n // Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int b = 0; b < ${e.batchSize}; b++) {\n for (int yR = 0; yR < ${e.outHeight}; yR++) {\n int xR = wR + yR * ${t} - ${r};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int yC = 0; yC < ${e.outWidth}; yC++) {\n int xC = wC + yC * ${n} - ${a};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n if (${i}) {\n float dyValue = getDy(b, yR, yC, d2);\n float xValue = getX(b, xR, xC, d1);\n dotProd += (xValue * dyValue);\n } else {\n float dyValue = getDy(b, d2, yR, yC);\n float xValue = getX(b, d1, xR, xC);\n dotProd += (xValue * dyValue);\n }\n\n }\n }\n }\n setOutput(dotProd);\n }\n `}}class pR{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,a=e.strideWidth,i="channelsLast"===e.dataFormat,s=t-1-e.padInfo.top,o=n-1-e.padInfo.left,u=i?1:2,l=i?2:3,c=i?3:1;this.userCode=`\n const ivec2 pads = ivec2(${s}, ${o});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords[${c}];\n\n ivec2 dyCorner = ivec2(coords[${u}], coords[${l}]) - pads;\n int dyRCorner = dyCorner.x;\n int dyCCorner = dyCorner.y;\n\n // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${t}; wR++) {\n float dyR = float(dyRCorner + wR) / ${r}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = ${t} - 1 - wR;\n\n for (int wC = 0; wC < ${n}; wC++) {\n float dyC = float(dyCCorner + wC) / ${a}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = ${n} - 1 - wC;\n\n for (int d2 = 0; d2 < ${e.outChannels}; d2++) {\n\n if (${i}) {\n float xValue = getDy(batch, idyR, idyC, d2);\n float wValue = getW(wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n } else {\n float xValue = getDy(batch, d2, idyR, idyC);\n float wValue = getW(wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n }\n\n }\n }\n }\n setOutput(dotProd);\n }\n `}}class dR{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideDepth,n=e.strideHeight,r=e.strideWidth,a=e.padInfo.front,i=e.padInfo.top,s=e.padInfo.left;this.userCode=`\n void main() {\n ivec5 coords = getOutputCoords();\n int wF = coords.x;\n int wR = coords.y;\n int wC = coords.z;\n int d1 = coords.w;\n int d2 = coords.u;\n\n float dotProd = 0.0;\n\n for (int b = 0; b < ${e.batchSize}; b++) {\n for (int yF = 0; yF < ${e.outDepth}; yF++) {\n int xF = wF + yF * ${t} - ${a};\n\n if (xF < 0 || xF >= ${e.inDepth}) {\n continue;\n }\n\n for (int yR = 0; yR < ${e.outHeight}; yR++) {\n int xR = wR + yR * ${n} - ${i};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int yC = 0; yC < ${e.outWidth}; yC++) {\n int xC = wC + yC * ${r} - ${s};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n float dyValue = getDy(b, yF, yR, yC, d2);\n float xValue = getX(b, xF, xR, xC, d1);\n dotProd += (xValue * dyValue);\n }\n }\n }\n }\n setOutput(dotProd);\n }\n `}}class hR{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterDepth,n=e.filterHeight,r=e.filterWidth,a=e.strideDepth,i=e.strideHeight,s=e.strideWidth,o=t-1-e.padInfo.front,u=n-1-e.padInfo.top,l=r-1-e.padInfo.left;this.userCode=`\n const ivec3 pads = ivec3(${o}, ${u}, ${l});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int d1 = coords.u;\n\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyFCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n float dotProd = 0.0;\n for (int wF = 0; wF < ${t}; wF++) {\n float dyF = float(dyFCorner + wF) / ${a}.0;\n\n if (dyF < 0.0 || dyF >= ${e.outDepth}.0 || fract(dyF) > 0.0) {\n continue;\n }\n int idyF = int(dyF);\n\n int wFPerm = ${t} - 1 - wF;\n\n for (int wR = 0; wR < ${n}; wR++) {\n float dyR = float(dyRCorner + wR) / ${i}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = ${n} - 1 - wR;\n\n for (int wC = 0; wC < ${r}; wC++) {\n float dyC = float(dyCCorner + wC) / ${s}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = ${r} - 1 - wC;\n\n for (int d2 = 0; d2 < ${e.outChannels}; d2++) {\n float xValue = getDy(batch, idyF, idyR, idyC, d2);\n float wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n }\n }\n }\n }\n setOutput(dotProd);\n }\n `}}const fR={kernelName:Ct,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,dy:i}=t,{strides:s,pad:o,dataFormat:u,dimRoundingMode:l,filterShape:c}=r,p=_l(u),d=dl(a.shape,c,s,1,o,l,!1,p),h=new cR(d);return n.runWebGLProgram(h,[a,i],"float32")}},mR={kernelName:Et,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,filter:i}=t,{inputShape:s,strides:o,pad:u,dataFormat:l,dimRoundingMode:c}=r,p=_l(l),d=dl(s,i.shape,o,1,u,c,!1,p),h=new pR(d);return n.runWebGLProgram(h,[a,i],"float32")}},gR={kernelName:At,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i}=t,{strides:s,pad:o,dilations:u}=r,l=hl(a.shape,i.shape,s,u,o),c=new aR(l);return n.runWebGLProgram(c,[a,i],"float32")}},yR={kernelName:It,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,dy:i}=t,{strides:s,pad:o,filterShape:u}=r,l=hl(a.shape,u,s,1,o),c=new dR(l);return n.runWebGLProgram(c,[a,i],"float32")}},bR={kernelName:Lt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,filter:i}=t,{pad:s,strides:o,inputShape:u}=r,l=hl(u,i.shape,o,1,s),c=new hR(l);return n.runWebGLProgram(c,[a,i],"float32")}},vR=g$({opSnippet:"if (isnan(x)) return x;\n return cos(x);\n"}),xR={kernelName:Ft,backendName:"webgl",kernelFunc:vR},_R=g$({opSnippet:"\n float e2x = exp(-x);\n return (e2x + 1.0 / e2x) / 2.0;\n"}),wR={kernelName:$t,backendName:"webgl",kernelFunc:_R};class DR{constructor(e,t,n,r,a){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];const[i,s,o,u]=e,[l]=t,[c,p]=n;this.outputShape=[l,c,p,u];const d="bilinear"===r?1:0,[h,f]=[s-1+".0",o-1+".0"],[m,g,y]=c>1?[""+(s-1)/(c-1),"(y2-y1) * height_ratio",`y1*${h} + float(y)*(height_scale)`]:["0.0","0.0",`0.5 * (y1+y2) * ${h}`],[b,v,x]=p>1?[""+(o-1)/(p-1),"(x2-x1) * width_ratio",`x1*${f} + float(x)*(width_scale)`]:["0.0","0.0",`0.5 * (x1+x2) * ${f}`];this.userCode=`\n const float height_ratio = float(${m});\n const float width_ratio = float(${b});\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int y = coords[1];\n int x = coords[2];\n int d = coords[3];\n\n // get box vals\n float y1 = getBoxes(b,0);\n float x1 = getBoxes(b,1);\n float y2 = getBoxes(b,2);\n float x2 = getBoxes(b,3);\n\n // get image in batch index\n int bInd = round(getBoxInd(b));\n if(bInd < 0 || bInd >= ${i}) {\n return;\n }\n\n float height_scale = ${g};\n float width_scale = ${v};\n\n float in_y = ${y};\n if( in_y < 0.0 || in_y > ${h} ) {\n setOutput(float(${a}));\n return;\n }\n float in_x = ${x};\n if( in_x < 0.0 || in_x > ${f} ) {\n setOutput(float(${a}));\n return;\n }\n\n vec2 sourceFracIndexCR = vec2(in_x,in_y);\n if(${d} == 1) {\n // Compute the four integer indices.\n ivec2 sourceFloorCR = ivec2(sourceFracIndexCR);\n ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR));\n\n float topLeft = getImage(b, sourceFloorCR.y, sourceFloorCR.x, d);\n float bottomLeft = getImage(b, sourceCeilCR.y, sourceFloorCR.x, d);\n float topRight = getImage(b, sourceFloorCR.y, sourceCeilCR.x, d);\n float bottomRight = getImage(b, sourceCeilCR.y, sourceCeilCR.x, d);\n\n vec2 fracCR = sourceFracIndexCR - vec2(sourceFloorCR);\n\n float top = topLeft + (topRight - topLeft) * fracCR.x;\n float bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x;\n float newValue = top + (bottom - top) * fracCR.y;\n setOutput(newValue);\n } else {\n // Compute the coordinators of nearest neighbor point.\n ivec2 sourceNearestCR = ivec2(floor(\n sourceFracIndexCR + vec2(0.5,0.5)));\n float newValue = getImage(b, sourceNearestCR.y, sourceNearestCR.x, d);\n setOutput(newValue);\n }\n }\n `}}const NR={kernelName:Yt,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{image:a,boxes:i,boxInd:s}=t,{cropSize:o,method:u,extrapolationValue:l}=r,c=new DR(a.shape,i.shape,o,u,l);return n.runWebGLProgram(c,[a,i,s],"float32")}};var MR;!function(e){e.Prod="*",e.Sum="+"}(MR||(MR={}));class SR{constructor(e,t,n,r){this.op=e,this.outputShape=t,this.variableNames=["x"],this.customUniforms=[{name:"index",type:"float"}];const a=this.outputShape.length,i=this.op===MR.Prod?"1.0":"0.0",s=n?i:`getX(${kR(a,"coords",this.op)})`,o=this.outputShape[this.outputShape.length-1];let u="",l="";n?(u=r?"end != "+(o-1):"end != 0",l=r?"end + 1":"end - 1"):(u=r?`end + pow2 < ${o}`:"end >= pow2",l=r?"end + pow2":"end - pow2"),this.userCode=`\n void main() {\n ${IL(a)} coords = getOutputCoords();\n int end = ${TR(a,"coords",this.op)};\n float val = ${s};\n int pow2 = int(pow(2.0, index));\n if (${u}) {\n int idx = ${l};\n ${TR(a,"coords",this.op)} = idx;\n val ${this.op}= getX(${kR(a,"coords",this.op)});\n }\n setOutput(val);\n }\n `}}function kR(e,t,n){if(1===e)return`${t}`;if(2===e)return`${t}.x, ${t}.y`;if(3===e)return`${t}.x, ${t}.y, ${t}.z`;if(4===e)return`${t}.x, ${t}.y, ${t}.z, ${t}.w`;throw new Error(`Cumulative ${n} for rank ${e} is not yet supported`)}function TR(e,t,n){if(1===e)return`${t}`;if(2===e)return`${t}.y`;if(3===e)return`${t}.z`;if(4===e)return`${t}.w`;throw new Error(`Cumulative ${n} for rank ${e} is not yet supported`)}function CR(e,t,n,r,a,i){const s=t.shape.length,o=vc([r],s);let u=t;null!=o&&(u=F$({inputs:{x:t},backend:n,attrs:{perm:o}}));const l=_c(1,s)[0];if(l!==s-1)throw new Error(`WebGL cumprod shader expects an inner-most axis=${t.shape.length-1} but got axis=${r}`);const c=u.shape[l];let p=s$({inputs:{x:u},backend:n});for(let t=0;t<=Math.ceil(Math.log2(c))-1;t++){const r=new SR(e,u.shape,!1,i),a=[[t]],s=p;p=n.runWebGLProgram(r,[p],p.dtype,a),n.disposeIntermediateTensorInfo(s)}if(a){const t=new SR(e,u.shape,a,i),r=p;p=n.runWebGLProgram(t,[p],p.dtype),n.disposeIntermediateTensorInfo(r)}if(null!=o){const e=F$({inputs:{x:p},backend:n,attrs:{perm:xc(o)}});return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(u),e}return p}const ER={kernelName:Ot,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,exclusive:s,reverse:o}=r;return CR(MR.Prod,a,n,i,s,o)}},AR={kernelName:Rt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,exclusive:s,reverse:o}=r;return CR(MR.Sum,a,n,i,s,o)}},IR={kernelName:Bt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,weights:i}=t,{size:s,binaryOutput:o}=r;if(1===a.shape.length){const e=n.readSync(a.dataId),t=n.readSync(i.dataId),r=QL(e,t,i.dtype,i.shape,s);return n.makeTensorInfo([s],i.dtype,r)}if(2===a.shape.length){const e=n.bufferSync(a),t=n.bufferSync(i),r=eF(e,t,s,o);return n.makeTensorInfo(r.shape,i.dtype,r.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${a.shape.length}.`)}};class LR{constructor(e,t,n){this.variableNames=["x"],this.outputShape=[],this.outputShape=e,this.blockSize=t,this.dataFormat=n,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int h = ${this.getHeightCoordString()};\n int w = ${this.getWidthCoordString()};\n int d = ${this.getDepthCoordString()};\n\n int in_h = h / ${t};\n int offset_h = imod(h, ${t});\n int in_w = w / ${t};\n int offset_w = imod(w, ${t});\n int offset_d = (offset_h * ${t} + offset_w) *\n ${this.getOutputDepthSize()};\n int in_d = d + offset_d;\n\n float result = ${this.getInputSamplingString()};\n setOutput(result);\n }\n `}getHeightCoordString(){return"NHWC"===this.dataFormat?"coords[1]":"coords[2]"}getWidthCoordString(){return"NHWC"===this.dataFormat?"coords[2]":"coords[3]"}getDepthCoordString(){return"NHWC"===this.dataFormat?"coords[3]":"coords[1]"}getOutputDepthSize(){return"NHWC"===this.dataFormat?this.outputShape[3]:this.outputShape[1]}getInputSamplingString(){return"NHWC"===this.dataFormat?"getX(b, in_h, in_w, in_d)":"getX(b, in_d, in_h, in_w)"}}const FR={kernelName:zt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockSize:i,dataFormat:s}=r,o=a.shape[0],u=("NHWC"===s?a.shape[1]:a.shape[2])*i,l=("NHWC"===s?a.shape[2]:a.shape[3])*i,c=("NHWC"===s?a.shape[3]:a.shape[1])/(i*i),p=new LR("NHWC"===s?[o,u,l,c]:[o,c,u,l],i,s);return n.runWebGLProgram(p,[a],a.dtype)}};class $R{constructor(e,t=!1,n=null,r=!1,a=!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=YL(this.outputShape.length);const i=e.filterHeight,s=e.filterWidth,o=e.outChannels/e.inChannels;let u="",l="";n&&(u=r?`float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:a?`float activation(float a) {\n float b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`\n float activation(float x) {\n ${n}\n }\n `,l="result = activation(result);");const c=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${u}\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int d1 = d2 / ${o};\n int q = d2 - d1 * ${o};\n\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // Convolve x(?, ?, d1) with w(:, :, d1, q) to get y(yR, yC, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n // TO DO(dsmilkov): Flatten the two for loops and vec4 the operations.\n for (int wR = 0; wR < ${i}; wR++) {\n int xR = xRCorner + wR * dilations[0];\n\n if (xR < 0 || xR >= inDims[0]) {\n continue;\n }\n\n for (int wC = 0; wC < ${s}; wC++) {\n int xC = xCCorner + wC * dilations[1];\n\n if (xC < 0 || xC >= inDims[1]) {\n continue;\n }\n\n float xVal = getX(batch, xR, xC, d1);\n float wVal = getW(wR, wC, d1, q);\n dotProd += xVal * wVal;\n }\n }\n\n float result = dotProd;\n ${c}\n ${l}\n setOutput(result);\n }\n `}}class OR{constructor(e,t=!1,n=null,r=!1,a=!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=YL(this.outputShape.length);const i=e.outChannels/e.inChannels,s=e.padInfo.left,o=e.strideWidth,u=e.dilationWidth,l=e.filterHeight,c=e.filterWidth,p=c;let d="\n int xR; int xC; int xCOffset;\n vec4 wTexel; vec4 previous; vec4 final;";for(let e=0;e=0 && xR < inDims[0]) {\n ";for(let e=0;e<(p+1)/2;e++){const t=2*e;if(d+=`\n xC = xCCorner + ${t*u};\n `,1===o){if(t= 0 && xCOffset < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n `,d+=1===u&&t>0?`\n xC${t} = vec4(xTexelC${t-2}.zw, xTexelC${t}.xy);\n `:`\n xCOffset = xC + 1 - 2;\n\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n previous.zw = vec2(0.0);\n }\n\n xC${t} = vec4(previous.zw, xTexelC${t}.xy);\n } else {\n xC${t} = vec4(0.0, 0.0, xTexelC${t}.xy);\n }\n `):d+=`\n if (xC >= 0 && xC < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n\n xC${t} = xTexelC${t};\n `,t+1= 0 && xCOffset < inDims[1] && xTexelC${t+1}Ready == 0) {\n xTexelC${t+1} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t+1}.zw = vec2(0.0);\n }\n xTexelC${t+1}Ready = 1;\n }\n `,u>1&&(d+=`\n xCOffset -= 2;\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xCOffset, d1);\n xTexelC${t}Ready = 1;\n }\n `),d+=`\n xC${t+1} = vec4(xTexelC${t}.zw, xTexelC${t+1}.xy);\n `):d+=1===e?`\n xC${t+1} = xTexelC${t};\n `:`\n xCOffset = xC + ${e};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t+1}Ready == 0) {\n xTexelC${t+1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t+1}.zw = vec2(0.0);\n }\n xTexelC${t+1}Ready = 1;\n }\n\n xC${t+1} = xTexelC${t+1};\n `}}else t= 0 && xCOffset < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xCOffset, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n\n if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${t+1}Ready == 0) {\n xTexelC${t+1} = getX(batch, xR, xC + 1, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xC + 2 >= inDims[1]) {\n xTexelC${t+1}.zw = vec2(0.0);\n }\n xTexelC${t+1}Ready = 1;\n }\n\n xC${t} = vec4(xTexelC${t}.zw, xTexelC${t+1}.zw);\n `,t+1= 0 && xCOffset < inDims[1]) {\n final = getX(batch, xR, xCOffset, d1);\n }\n xC${t+1} = vec4(xTexelC${t+1}.xy, final.xy);\n `)):(d+=`\n if(xC >= 0 && xC < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n\n xCOffset = xC + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t+1}Ready == 0) {\n xTexelC${t+1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t+1}.zw = vec2(0.);\n }\n xTexelC${t+1}Ready = 1;\n }\n\n xC${t} = vec4(\n xTexelC${t}.xy, xTexelC${t+1}.xy);\n `,t+1`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${s} and dilations '${c}'`));const p=dl(a.shape,i.shape,s,c,o,l,!0);let d;d=Ge().getBool("WEBGL_PACK_DEPTHWISECONV")&&p.strideWidth<=2&&p.outChannels/p.inChannels==1?new OR(p):new $R(p);const h=[[p.padInfo.top,p.padInfo.left],[p.strideHeight,p.strideWidth],[p.dilationHeight,p.dilationWidth],[p.inHeight,p.inWidth]];return n.runWebGLProgram(d,[a,i],"float32",h)}};class YR{constructor(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;const t=e.strideHeight,n=e.strideWidth,r=e.padInfo.top,a=e.padInfo.left,i=e.outChannels/e.inChannels;this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int wR = coords.x;\n int wC = coords.y;\n int d1 = coords.z;\n int dm = coords.w;\n int d2 = d1 * ${i} + dm;\n\n float dotProd = 0.0;\n\n // TO DO: Vec4 over the batch size\n for (int b = 0; b < ${e.batchSize}; b++) {\n for (int yR = 0; yR < ${e.outHeight}; yR++) {\n int xR = wR + yR * ${t} - ${r};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int yC = 0; yC < ${e.outWidth}; yC++) {\n int xC = wC + yC * ${n} - ${a};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n float dyValue = getDy(b, yR, yC, d2);\n float xValue = getX(b, xR, xC, d1);\n dotProd += (xValue * dyValue);\n }\n }\n }\n setOutput(dotProd);\n }\n `}}class BR{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,a=e.strideWidth,i=t-1-e.padInfo.top,s=n-1-e.padInfo.left,o=e.outChannels/e.inChannels;this.userCode=`\n const ivec2 pads = ivec2(${i}, ${s});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords[3];\n ivec2 dyCorner = coords.yz - pads;\n int dyRCorner = dyCorner.x;\n int dyCCorner = dyCorner.y;\n\n float dotProd = 0.0;\n\n for (int wR = 0; wR < ${t}; wR++) {\n float dyR = float(dyRCorner + wR) / ${r}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = ${t} - 1 - wR;\n\n for (int wC = 0; wC < ${n}; wC++) {\n float dyC = float(dyCCorner + wC) / ${a}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = ${n} - 1 - wC;\n\n // TO DO: Vec4 over the channelMul\n for (int dm = 0; dm < ${o}; dm++) {\n int d2 = d1 * ${o} + dm;\n float xValue = getDy(batch, idyR, idyC, d2);\n float wValue = getW(wRPerm, wCPerm, d1, dm);\n dotProd += xValue * wValue;\n }\n }\n }\n setOutput(dotProd);\n }\n `}}const zR={kernelName:Ht,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,dy:i}=t,{strides:s,dilations:o,pad:u,dimRoundingMode:l,filterShape:c}=r,p=dl(a.shape,c,s,o,u,l,!0),d=new YR(p);return n.runWebGLProgram(d,[a,i],"float32")}},PR={kernelName:jt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,filter:i}=t,{strides:s,dilations:o,pad:u,dimRoundingMode:l,inputShape:c}=r,p=dl(c,i.shape,s,o,u,l,!0),d=new BR(p);return n.runWebGLProgram(d,[a,i],"float32")}};class HR{constructor(e){this.variableNames=["X"],this.outputShape=[e,e],this.userCode="\n void main() {\n ivec2 coords = getOutputCoords();\n float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0;\n setOutput(val);\n }\n "}}const jR={kernelName:Ut,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r}=t,a=[...r.shape,...r.shape],i=ce(r.shape),s=N$({inputs:{x:r},backend:n,attrs:{shape:[i]}}),o=new HR(i),u=n.runWebGLProgram(o,[s],s.dtype),l=N$({inputs:{x:u},backend:n,attrs:{shape:a}});return n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(u),l}};class UR{constructor(e){this.variableNames=["x","W"],this.outputShape=e.outShape;const{inHeight:t,inWidth:n,padInfo:r,strideHeight:a,strideWidth:i,filterHeight:s,filterWidth:o,dilationHeight:u,dilationWidth:l}=e,{top:c,left:p}=r;this.userCode=`\n const ivec2 strides = ivec2(${a}, ${i});\n const ivec2 pads = ivec2(${c}, ${p});\n const float neg_infinity = -3.4e38;\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n int d1 = coords.w;\n ivec2 outTopLeftCorner =\n coords.yz * strides - pads;\n int hBeg = outTopLeftCorner.x;\n int wBeg = outTopLeftCorner.y;\n\n float curVal = neg_infinity;\n for (int h = 0; h < ${s}; h++) {\n int hIn = hBeg + h * ${u};\n\n if (hIn >= 0 && hIn < ${t}) {\n for (int w = 0; w < ${o}; w++) {\n int wIn = wBeg + w * ${l};\n\n if (wIn >= 0 && wIn < ${n}) {\n float xVal = getX(batch, hIn, wIn, d1);\n float wVal = getW(h, w, d1);\n\n float val = xVal + wVal;\n if (val > curVal) {\n curVal = val;\n }\n }\n }\n }\n }\n\n float result = curVal;\n setOutput(result);\n }\n `}}const qR={kernelName:qt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i}=t,{strides:s,pad:o,dilations:u}=r,l=ll(a.shape,i.shape,s,o,"NHWC",u);let c;const p=new UR(l);c=n.runWebGLProgram(p,[a,i],"float32");const d=N$({inputs:{x:c},backend:n,attrs:{shape:l.outShape}});return n.disposeIntermediateTensorInfo(c),d}},WR={kernelName:Kt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{equation:a}=r,i=t,{allDims:s,summedDims:o,idDims:u}=Sf(a,i.length);Tf(s.length,u,i);const{path:l,steps:c}=Cf(o,u),p=c.length;let d=null,h=s.length;const f=[];for(let e=0;e=0&&(d=I$({inputs:{x:d},backend:n,attrs:{axis:l[e]-(s.length-h),keepDims:!1}}),f.push(d)),h--)}for(const e of f)e!==d&&n.disposeIntermediateTensorInfo(e);return d}},VR=g$({opSnippet:"return (x >= 0.0) ? x : (exp(x) - 1.0);",packedOpSnippet:"\n vec4 result;\n\n result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);\n result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);\n result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);\n result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);\n\n return result;\n"}),GR={kernelName:Jt,backendName:"webgl",kernelFunc:VR},KR={kernelName:Xt,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n}=e,{dy:r,y:a}=t,i=Ge().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new i$("\n vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));\n return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));\n",r.shape,a.shape):new a$("return (b >= 1.0) ? a : a * (b + 1.0);",r.shape,a.shape);return n.runWebGLProgram(i,[r,a],r.dtype)}},JR=y$({opSnippet:"return float(a == b);",packedOpSnippet:"\n return vec4(equal(a, b));\n",dtype:"bool",cpuKernelImpl:rF}),XR={kernelName:Qt,backendName:"webgl",kernelFunc:JR},ZR=g$({opSnippet:`\n // Error function is calculated approximately with elementary function.\n // See "Handbook of Mathematical Functions with Formulas,\n // Graphs, and Mathematical Tables", Abramowitz and Stegun.\n float p = ${pf};\n float a1 = ${df};\n float a2 = ${hf};\n float a3 = ${ff};\n float a4 = ${mf};\n float a5 = ${gf};\n\n float sign = sign(x);\n x = abs(x);\n float t = 1.0 / (1.0 + p * x);\n return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x));\n`}),QR={kernelName:Zt,backendName:"webgl",kernelFunc:ZR},eY=g$({opSnippet:"if (isnan(x)) return x;\n return exp(x);\n",packedOpSnippet:"\n vec4 result = exp(x);\n bvec4 isNaN = isnan(x);\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n",cpuKernelImpl:aF,dtype:"float32"}),tY={kernelName:en,backendName:"webgl",kernelFunc:eY};function nY(e){const{inputs:t,attrs:n,backend:r}=e,{dim:a}=n,{input:i}=t,s=i.shape.length,o=i.shape.slice();let u=a;return a<0&&(se(-(s+1)<=a,(()=>`Axis must be in the interval [${-(s+1)}, ${s}]`)),u=s+a+1),o.splice(u,0,1),N$({inputs:{x:i},backend:r,attrs:{shape:o}})}const rY={kernelName:tn,backendName:"webgl",kernelFunc:nY},aY="return exp(x) - 1.0;",iY=g$({opSnippet:aY,packedOpSnippet:aY,cpuKernelImpl:iF}),sY={kernelName:nn,backendName:"webgl",kernelFunc:iY};class oY{constructor(e,t,n){this.variableNames=["real","imag"];const r=t[1];this.outputShape=t;const a=n?`2.0 * ${Math.PI}`:`-2.0 * ${Math.PI}`,i=n?`${r}.0`:"1.0";let s;if("real"===e)s="return real * expR - imag * expI;";else{if("imag"!==e)throw new Error(`FFT component must be either "real" or "imag", got ${e}.`);s="return real * expI + imag * expR;"}this.userCode=`\n const float exponentMultiplier = ${a};\n\n float unaryOpComplex(float real, float expR, float imag, float expI) {\n ${s}\n }\n\n float mulMatDFT(int batch, int index) {\n float indexRatio = float(index) / float(${r});\n float exponentMultiplierTimesIndexRatio =\n exponentMultiplier * indexRatio;\n\n float result = 0.0;\n\n for (int i = 0; i < ${r}; i++) {\n // x = (-2|2 * PI / N) * index * i;\n float x = exponentMultiplierTimesIndexRatio * float(i);\n float expR = cos(x);\n float expI = sin(x);\n float real = getReal(batch, i);\n float imag = getImag(batch, i);\n\n result +=\n unaryOpComplex(real, expR, imag, expI) / ${i};\n }\n\n return result;\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n setOutput(mulMatDFT(coords[0], coords[1]));\n }\n `}}function uY(e,t,n){const r=n.texData.get(e.dataId),a=ce(e.shape),i=e.shape[e.shape.length-1],s=N$({inputs:{x:e},backend:n,attrs:{shape:[a/i,i]}}),o=s.shape,u=new oY("real",o,t),l=new oY("imag",o,t),c=[{dataId:r.complexTensorInfos.real.dataId,dtype:r.complexTensorInfos.real.dtype,shape:o},{dataId:r.complexTensorInfos.imag.dataId,dtype:r.complexTensorInfos.imag.dtype,shape:o}],p=n.runWebGLProgram(u,c,"float32"),d=n.runWebGLProgram(l,c,"float32"),h=u$({inputs:{real:p,imag:d},backend:n});n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(d);const f=N$({inputs:{x:h},backend:n,attrs:{shape:e.shape}});return n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(h),f}const lY={kernelName:rn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{input:r}=t;return uY(r,!1,n)}};class cY{constructor(e,t){this.outputShape=[],this.customUniforms=[{name:"value",type:"float"}],this.variableNames=["x"],this.outputShape=e,this.userCode="\n void main() {\n // Input can be obtained from uniform value.\n setOutput(value);\n }\n "}}function pY(e){const{backend:t,attrs:n}=e,{shape:r,value:a}=n;let{dtype:i}=n;if(i=i||Le(a),"string"===i){const e=De(i,ce(r));return e.fill(a),t.makeTensorInfo(r,i,e)}{const e=new cY(r,a),n=[[a]];return t.runWebGLProgram(e,[],i,n)}}const dY={kernelName:an,backendName:"webgl",kernelFunc:pY};class hY{constructor(e){this.variableNames=["Image"],this.outputShape=[];const t=e[2];this.outputShape=e,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int x = coords[2];\n\n int coordX = ${t} - x - 1;\n float outputValue;\n if(coordX >= 0 && coordX < ${t}) {\n outputValue = getImage(coords[0], coords[1], coordX, coords[3]);\n } else {\n outputValue = getImage(coords[0], coords[1], coords[2], coords[3]);\n }\n setOutput(outputValue);\n }\n `}}const fY={kernelName:sn,backendName:"webgl",kernelFunc:({inputs:e,backend:t})=>{const{image:n}=e,r=t,a=new hY(n.shape);return r.runWebGLProgram(a,[n],n.dtype)}},mY="return floor(x);",gY=g$({opSnippet:mY,packedOpSnippet:mY,cpuKernelImpl:sF}),yY={kernelName:on,backendName:"webgl",kernelFunc:gY},bY=y$({opSnippet:"\n float s = sign(a) * sign(b);\n int ia = round(a);\n int ib = round(b);\n if (ib != 0) {\n // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n return float(idiv(ia, ib, s));\n } else {\n return NAN;\n }\n",packedOpSnippet:"\n ivec4 ia = round(a);\n ivec4 ib = round(b);\n bvec4 cond = notEqual(ib, ivec4(0));\n ivec4 result = ivec4(0);\n vec4 s = sign(a) * sign(b);\n\n // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n if (cond[0]) {\n result[0] = idiv(ia[0], ib[0], s[0]);\n }\n if (cond[1]) {\n result[1] = idiv(ia[1], ib[1], s[1]);\n }\n if (cond[2]) {\n result[2] = idiv(ia[2], ib[2], s[2]);\n }\n if (cond[3]) {\n result[3] = idiv(ia[3], ib[3], s[3]);\n }\n return vec4(result);\n",dtype:"int32"}),vY={kernelName:un,backendName:"webgl",kernelFunc:bY};class xY{constructor(e){this.variableNames=["A"];const t=yL(),[n,r]=e;this.outputShape=e,this.userCode=`\n void main() {\n ivec3 coords = getOutputCoords();\n int texR = coords[0];\n int texC = coords[1];\n int depth = coords[2];\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${r}.0, ${n}.0);\n\n vec4 values = ${t.texture2D}(A, uv);\n float value;\n if (depth == 0) {\n value = values.r;\n } else if (depth == 1) {\n value = values.g;\n } else if (depth == 2) {\n value = values.b;\n } else if (depth == 3) {\n value = values.a;\n }\n\n setOutput(floor(value * 255.0 + 0.5));\n }\n `}}class _Y{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;const t=yL(),[n,r]=e;this.outputShape=e,this.userCode=`\n void main() {\n ivec3 coords = getOutputCoords();\n int texR = coords[0];\n int texC = coords[1];\n int depth = coords[2];\n\n vec4 result = vec4(0.);\n\n for(int row=0; row<=1; row++) {\n for(int col=0; col<=1; col++) {\n texC = coords[1] + row;\n depth = coords[2] + col;\n\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${r}.0, ${n}.0);\n vec4 values = ${t.texture2D}(A, uv);\n float value;\n if (depth == 0) {\n value = values.r;\n } else if (depth == 1) {\n value = values.g;\n } else if (depth == 2) {\n value = values.b;\n } else if (depth == 3) {\n value = values.a;\n }\n\n result[row * 2 + col] = floor(value * 255.0 + 0.5);\n }\n }\n\n ${t.output} = result;\n }\n `}}const wY={kernelName:ia,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e;let{pixels:a}=t;const{numChannels:i}=r,s="undefined"!=typeof HTMLVideoElement&&a instanceof HTMLVideoElement,o="undefined"!=typeof HTMLImageElement&&a instanceof HTMLImageElement,[u,l]=s?[a.videoWidth,a.videoHeight]:[a.width,a.height],c=[l,u],p=[l,u,i];(o||s)&&(null==DY&&(DY=document.createElement("canvas").getContext("2d")),DY.canvas.width=u,DY.canvas.height=l,DY.drawImage(a,0,0,u,l),a=DY.canvas);const d=n.makeTensorInfo(c,"int32");n.texData.get(d.dataId).usage=PI.PIXELS,n.gpgpu.uploadPixelDataToTexture(n.getTexture(d.dataId),a);const h=Ge().getBool("WEBGL_PACK")?new _Y(p):new xY(p),f=n.runWebGLProgram(h,[d],"int32");return n.disposeData(d.dataId),f}};let DY;const NY={kernelName:ua,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i,bias:s,preluActivationWeights:o}=t,{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:d,activation:h,leakyreluAlpha:f}=r,m=_l(c),g=dl(a.shape,i.shape,u,p,l,d,!1,m);let y;const b=[];if(1!==g.filterHeight||1!==g.filterWidth||1!==g.dilationHeight||1!==g.dilationWidth||1!==g.strideHeight||1!==g.strideWidth||"SAME"!==g.padInfo.type&&"VALID"!==g.padInfo.type)if(Ge().getBool("WEBGL_CONV_IM2COL"))y=uR({x:a,filter:i,convInfo:g,backend:n,bias:s,activation:h,preluActivationWeights:o,leakyreluAlpha:f});else{const e=null!=s,t=null!=o,r="leakyrelu"===h,u=h?b$(h,!1):null,l=new rR(g,e,u,t,r),p=[a,i],d=(e,t)=>{if("NCHW"===t&&1===e.shape.length&&1!==e.shape[0]){const t=N$({inputs:{x:e},backend:n,attrs:{shape:[e.shape[0],1,1]}});return b.push(t),t}return e};if(e&&p.push(d(s,c)),t&&p.push(d(o,c)),r){const e=n.makeTensorInfo([],"float32",Ra(f,"float32"));p.push(e),b.push(e)}y=n.runWebGLProgram(l,p,"float32")}else y=oR({x:a,filter:i,convInfo:g,backend:n,bias:s,activation:h,preluActivationWeights:o,leakyreluAlpha:f});const v=N$({inputs:{x:y},backend:n,attrs:{shape:g.outShape}});return b.push(y),b.forEach((e=>n.disposeIntermediateTensorInfo(e))),v}},MY={kernelName:la,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i,bias:s,preluActivationWeights:o}=t,{strides:u,pad:l,dilations:c,dimRoundingMode:p,activation:d,leakyreluAlpha:h}=r,f=[];let m=c;null==m&&(m=[1,1]),se(xl(u,m),(()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${u} and dilations '${m}'`));const g=dl(a.shape,i.shape,u,m,l,p,!0),y=Ge().getBool("WEBGL_PACK_DEPTHWISECONV")&&g.strideWidth<=2&&g.outChannels/g.inChannels==1,b=d?b$(d,y):null,v=[a,i],x=null!=s,_=null!=o,w="leakyrelu"===d;if(x&&v.push(s),_&&v.push(o),w){const e=n.makeTensorInfo([],"float32",Ra(h,"float32"));v.push(e),f.push(e)}let D;D=y?new OR(g,x,b,_,w):new $R(g,x,b,_,w);const N=[[g.padInfo.top,g.padInfo.left],[g.strideHeight,g.strideWidth],[g.dilationHeight,g.dilationWidth],[g.inHeight,g.inWidth]],M=n.runWebGLProgram(D,v,"float32",N);return f.forEach((e=>n.disposeIntermediateTensorInfo(e))),M}};class SY{constructor(e,t,n,r){this.sliceDim=e,this.strides=t,this.paramsShape=r,this.variableNames=["x","indices"],this.outputShape=n;const a=IL(t.length),i=IL(n.length),s=this.sliceDim>1?"strides[j]":"strides",o=IL(r.length),u=r.length>1?"paramsShape[j]":"paramsShape";this.userCode=`\n ${a} strides = ${a}(${this.strides});\n ${o} paramsShape = ${o}(${this.paramsShape});\n void main() {\n ${i} coords = getOutputCoords();\n int flattenIndex = 0;\n bool out_of_bounds = false;\n for (int j = 0; j < ${this.sliceDim}; j++) {\n int index = round(getIndices(coords[0], j));\n out_of_bounds = out_of_bounds || index < 0;\n out_of_bounds = out_of_bounds || index >= ${u};\n flattenIndex += index * ${s};\n }\n setOutput(out_of_bounds ? 0.0 : getX(flattenIndex, coords[1]));\n }\n `}}const kY={kernelName:pn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{params:r,indices:a}=t,i=a.shape,s=i[i.length-1],o=ce(r.shape),[u,l,c,p]=zo(r,a),d=N$({inputs:{x:a},backend:n,attrs:{shape:[l,s]}}),h=N$({inputs:{x:r},backend:n,attrs:{shape:[ce(r.shape)/c,c]}});if(n.shouldExecuteOnCPU([r,a])||"string"===r.dtype){const e=n.readSync(a.dataId),t=n.bufferSync(r),i=oF(e,t,r.dtype,l,s,c,p,r.shape,o);return n.makeTensorInfo(u,r.dtype,i.values)}const f=new SY(s,p,[l,c],r.shape),m=n.runWebGLProgram(f,[h,d],h.dtype),g=N$({inputs:{x:m},backend:n,attrs:{shape:u}});return n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(m),g}};class TY{constructor(e,t){this.variableNames=["A","indices"],this.outputShape=t,this.rank=t.length;const n=IL(this.rank),r=function(e,t){const n=["resRC.x","resRC.y","resRC.z","resRC.w"],r=[];for(let t=0;t= 0) && (index < ${e[2]}) ? 1.0 : 0.0;\n setOutput(inBounds * getA(${r}));\n }\n `}}function CY(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,indices:i}=t,{axis:s,batchDims:o}=r,u=xe(s,a.shape)[0];if(Ge().get("DEBUG")){const e=n.readSync(i.dataId),t=a.shape[u];for(let n=0;n=0,(()=>`GatherV2: the index value ${r} is not in [0, ${t-1}]`))}}const l=Vf(a,i,u,o),c=ce(i.shape),p=[],d=N$({inputs:{x:a},backend:n,attrs:{shape:[l.batchSize,l.outerSize,l.dimSize,l.sliceSize]}}),h=N$({inputs:{x:i},backend:n,attrs:{shape:[l.batchSize,c/l.batchSize]}});p.push(d),p.push(h);const f=[l.batchSize,l.outerSize,c/l.batchSize,l.sliceSize];if(n.shouldExecuteOnCPU([a,i])||"string"===a.dtype){const e=n.bufferSync(h),t=n.bufferSync(d),r=uF(t,e,f);return p.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(l.outputShape,r.dtype,r.values)}const m=new TY(d.shape,f),g=n.runWebGLProgram(m,[d,h],d.dtype);p.push(g);const y=N$({inputs:{x:g},backend:n,attrs:{shape:l.outputShape}});return p.forEach((e=>n.disposeIntermediateTensorInfo(e))),y}const EY={kernelName:cn,backendName:"webgl",kernelFunc:CY},AY=y$({opSnippet:"return float(a > b);",packedOpSnippet:"\n return vec4(greaterThan(a, b));\n",cpuKernelImpl:lF,dtype:"bool"}),IY={kernelName:dn,backendName:"webgl",kernelFunc:AY},LY=y$({opSnippet:"return float(a >= b);",packedOpSnippet:"\n return vec4(greaterThanEqual(a, b));\n",dtype:"bool",cpuKernelImpl:cF}),FY={kernelName:hn,backendName:"webgl",kernelFunc:LY},$Y={kernelName:mn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{input:r}=t;return uY(r,!0,n)}},OY=g$({opSnippet:"return float(!isnan(x) && !isinf(x));",dtype:"bool"}),RY={kernelName:yn,backendName:"webgl",kernelFunc:OY},YY=g$({opSnippet:"return float(isinf(x));",dtype:"bool"}),BY={kernelName:bn,backendName:"webgl",kernelFunc:YY},zY=g$({opSnippet:"return float(isnan(x));",dtype:"bool"}),PY={kernelName:vn,backendName:"webgl",kernelFunc:zY},HY=y$({opSnippet:"return float(a < b);",packedOpSnippet:"\n return vec4(lessThan(a, b));\n",cpuKernelImpl:pF,dtype:"bool"}),jY={kernelName:_n,backendName:"webgl",kernelFunc:HY},UY=y$({opSnippet:"return float(a <= b);",packedOpSnippet:"\n return vec4(lessThanEqual(a, b));\n",cpuKernelImpl:dF,dtype:"bool"}),qY={kernelName:wn,backendName:"webgl",kernelFunc:UY},WY={kernelName:Dn,backendName:"webgl",kernelFunc:function(e){const{backend:t,attrs:n}=e,{start:r,stop:a,num:i}=n,s=hF(r,a,i);return t.makeTensorInfo([s.length],"float32",s)}},VY=g$({opSnippet:"if (isnan(x)) return x;\n return x < 0.0 ? 0./0. : log(x);\n",packedOpSnippet:"\n vec4 result = log(x);\n bvec4 isNaN = isnan(x);\n result.r = isNaN.r ? x.r : (x.r < 0.0 ? 0./0. : result.r);\n result.g = isNaN.g ? x.g : (x.g < 0.0 ? 0./0. : result.g);\n result.b = isNaN.b ? x.b : (x.b < 0.0 ? 0./0. : result.b);\n result.a = isNaN.a ? x.a : (x.a < 0.0 ? 0./0. : result.a);\n return result;\n",cpuKernelImpl:fF}),GY={kernelName:Nn,backendName:"webgl",kernelFunc:VY},KY=g$({opSnippet:"if (isnan(x)) return x;\n return log(1.0 + x);\n"}),JY={kernelName:Mn,backendName:"webgl",kernelFunc:KY},XY=y$({opSnippet:"return float(a >= 1.0 && b >= 1.0);",packedOpSnippet:"\n return vec4(\n vec4(greaterThanEqual(a, vec4(1.0))) *\n vec4(greaterThanEqual(b, vec4(1.0))));\n",dtype:"bool"}),ZY={kernelName:Sn,backendName:"webgl",kernelFunc:XY},QY=g$({opSnippet:"return float(!(x >= 1.0));"}),eB={kernelName:kn,backendName:"webgl",kernelFunc:QY},tB=y$({opSnippet:"return float(a >= 1.0 || b >= 1.0);",packedOpSnippet:"\n return min(\n vec4(greaterThanEqual(a, vec4(1.0))) +\n vec4(greaterThanEqual(b, vec4(1.0))),\n vec4(1.0));\n",dtype:"bool"}),nB={kernelName:Tn,backendName:"webgl",kernelFunc:tB};class rB{constructor(e,t,n,r,a){this.variableNames=["x"],this.outputShape=[];const i=t,s=e[3]-1;let o;this.outputShape=e;const u=`float(${n}) + float(${r}) * sum`;o=.5===a?`inversesqrt(${u})`:1===a?`1.0/(${u})`:`exp(log(${u}) * float(-${a}));`,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int r = coords[1];\n int c = coords[2];\n int d = coords[3];\n float x = getX(b, r, c, d);\n float sum = 0.0;\n for (int j = -${i}; j <= ${i}; j++) {\n int idx = d + j;\n if (idx >= 0 && idx <= ${s}) {\n float z = getX(b, r, c, idx);\n sum += z * z;\n }\n }\n float val = x * ${o};\n setOutput(val);\n }\n `}}class aB{constructor(e,t,n,r,a){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;const i=t,s=e[3]-1;let o;this.outputShape=e;const u=`float(${n}) + float(${r}) * sum`;o=.5===a?`inversesqrt(${u})`:1===a?`1.0/(${u})`:`exp(log(${u}) * float(-${a}));`,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords.x;\n int r = coords.y;\n int c = coords.z;\n int d = coords.w;\n\n bool hasNextCol = d < ${this.outputShape[3]};\n bool hasNextRow = c < ${this.outputShape[2]};\n\n vec4 sum = vec4(0.);\n vec4 xFragAtOutputCoords = getX(b, r, c, d);\n\n vec4 xAtOutputCoords = vec4(\n getChannel(xFragAtOutputCoords, vec2(c, d)),\n hasNextCol ?\n getChannel(xFragAtOutputCoords, vec2(c, d + 1)) : 0.0,\n hasNextRow ?\n getChannel(xFragAtOutputCoords , vec2(c + 1, d)) : 0.0,\n (hasNextRow && hasNextCol) ?\n getChannel(xFragAtOutputCoords, vec2(c + 1, d + 1)) : 0.0\n );\n\n int firstChannel = d - ${i};\n vec2 cache = vec2(0.);\n if(firstChannel >= 0){\n vec4 firstChannelFrag = getX(b, r, c, firstChannel);\n cache.x = getChannel(firstChannelFrag, vec2(c, firstChannel));\n if(hasNextRow){\n cache.y = getChannel(firstChannelFrag, vec2(c + 1, firstChannel));\n }\n }\n\n ivec2 depth = ivec2(d, d + 1);\n for (int j = - ${i}; j <= ${i}; j++) {\n ivec2 idx = depth + j;\n bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0));\n bvec2 belowUpperBound = lessThanEqual(idx, ivec2(${s}));\n\n bool depthInRange = aboveLowerBound.x && belowUpperBound.x;\n bool depthPlusOneInRange = aboveLowerBound.y && belowUpperBound.y;\n\n if(depthInRange || depthPlusOneInRange){\n vec4 z = vec4(0.);\n vec4 xFragAtCurrentDepth;\n z.xz = cache.xy;\n if(depthPlusOneInRange && hasNextCol){\n xFragAtCurrentDepth = idx.y != d ?\n getX(b, r, c, idx.y) : xFragAtOutputCoords;\n z.y = getChannel(xFragAtCurrentDepth, vec2(c, idx.y));\n if(hasNextRow){\n z.w = getChannel(xFragAtCurrentDepth, vec2(c + 1, idx.y));\n }\n }\n cache.xy = z.yw;\n sum += z * z;\n }\n }\n vec4 result = xAtOutputCoords * ${o};\n setOutput(result);\n }\n `}}const iB={kernelName:In,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{depthRadius:i,bias:s,alpha:o,beta:u}=r,l=Ge().getBool("WEBGL_PACK_NORMALIZATION")?new aB(a.shape,i,s,o,u):new rB(a.shape,i,s,o,u);return n.runWebGLProgram(l,[a],a.dtype)}};class sB{constructor(e,t,n,r,a){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=e,this.depth=e[3],this.depthRadius=t,this.bias=n,this.alpha=r,this.beta=a,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int r = coords[1];\n int c = coords[2];\n\n float result = 0.0;\n for (int d = 0; d < ${this.depth}; ++d) {\n int depthBegin = int(max(0.0, float(d - ${t})));\n int depthEnd = int(min(float(${this.depth}),\n float(d + ${t} + 1)));\n\n const int MIN_DEPTH_BEGIN = 0;\n const int MAX_DEPTH_END = ${this.depth};\n\n float norm = 0.0;\n for (int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k) {\n if (k < depthBegin){\n continue;\n }\n else if (k >= depthBegin && k < depthEnd) {\n norm += getInputImage(b, r, c, k) * getInputImage(b, r, c, k);\n }\n else {\n break;\n }\n }\n\n norm = float(${r}) * norm + float(${n});\n\n for(int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k){\n if (k < depthBegin){\n continue;\n }\n else if (k >= depthBegin && k < depthEnd){\n float dyi = -2.0 * float(${r})\n * float(${a})\n * getInputImage(b ,r ,c, k) * getOutputImage(b, r, c, d)\n / norm;\n if (k == d) {\n dyi += pow(norm, -1.0 * ${a});\n }\n if (k == coords[3]) {\n dyi *= getDy(b, r, c, d);\n result += dyi;\n }\n }\n else {\n break;\n }\n }\n }\n setOutput(result);\n }\n `}}const oB={kernelName:Ln,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{x:a,y:i,dy:s}=t,{depthRadius:o,bias:u,alpha:l,beta:c}=r,p=new sB(a.shape,o,u,l,c);return n.runWebGLProgram(p,[a,i,s],a.dtype)}};function uB(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{reductionIndices:i,keepDims:s}=r,o=a.shape.length,u=xe(i,a.shape);let l=u;const c=vc(l,o),p=null!=c,d=n.shouldExecuteOnCPU([a]);let h=a;if(p){if(d){const e=n.texData.get(h.dataId).values,t=new Array(o);for(let e=0;e 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n",cpuKernelImpl:gF}),pB={kernelName:$n,backendName:"webgl",kernelFunc:cB},dB={kernelName:On,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t;mL(a,"maxPool");const{filterSize:i,strides:s,pad:o,dimRoundingMode:u}=r;se(xl(s,1),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${s} and dilations '1'`));const l=cl(a.shape,i,s,1,o,u);if(1===l.filterWidth&&1===l.filterHeight&&de(l.inShape,l.outShape))return s$({inputs:{x:a},backend:n});const c=new mO(l,"max",!1);return n.runWebGLProgram(c,[a],a.dtype)}},hB={kernelName:Yn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{filterSize:i,strides:s,pad:o,dataFormat:u,dimRoundingMode:l}=r,c=pl(a.shape,i,s,[1,1,1],o,l,u),p=new gO(c,"max",!1);return n.runWebGLProgram(p,[a],a.dtype)}};class fB{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const t=e.strideHeight,n=e.strideWidth,r=e.dilationHeight,a=e.effectiveFilterHeight,i=e.effectiveFilterWidth,s=a-1-e.padInfo.top,o=i-1-e.padInfo.left,u=a*i-1;this.userCode=`\n const ivec2 pads = ivec2(${s}, ${o});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n\n ivec2 dyRCCorner = coords.yz - pads;\n int dyRCorner = dyRCCorner.x;\n int dyCCorner = dyRCCorner.y;\n\n // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${a};\n wR += ${r}) {\n float dyR = float(dyRCorner + wR) / ${t}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${i}; wC++) {\n float dyC = float(dyCCorner + wC) / ${n}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(b, idyR, idyC, d);\n int maxPosValue = ${u} - int(getMaxPos(b, idyR, idyC, d));\n\n // Get the current value, check it against the value from the\n // position matrix.\n int curPosValue = wR * ${i} + wC;\n float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n dotProd += dyValue * mask;\n }\n }\n setOutput(dotProd);\n }\n `}}class mB{constructor(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;const t=e.strideDepth,n=e.strideHeight,r=e.strideWidth,a=e.dilationDepth,i=e.dilationHeight,s=e.dilationWidth,o=e.effectiveFilterDepth,u=e.effectiveFilterHeight,l=e.effectiveFilterWidth,c=o-1-e.padInfo.front,p=u-1-e.padInfo.top,d=l-1-e.padInfo.left,h=o*u*l-1;this.userCode=`\n const ivec3 pads = ivec3(${c}, ${p}, ${d});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyDCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n // Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get\n // dx(xD, xR, xC, ch).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int wD = 0; wD < ${o};\n wD += ${a}) {\n float dyD = float(dyDCorner + wD) / ${t}.0;\n\n if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) {\n continue;\n }\n int idyD = int(dyD);\n\n for (int wR = 0; wR < ${u};\n wR += ${i}) {\n float dyR = float(dyRCorner + wR) / ${n}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${l};\n wC += ${s}) {\n float dyC = float(dyCCorner + wC) / ${r}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n int maxPosValue = ${h} -\n int(getMaxPos(batch, idyD, idyR, idyC, ch));\n\n // Get the current value, check it against the value from the\n // position matrix.\n int curPosValue =\n wD * ${u} * ${l} +\n wR * ${l} + wC;\n float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n dotProd += dyValue * mask;\n }\n }\n }\n setOutput(dotProd);\n }\n `}}const gB={kernelName:Bn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i}=t,s=i,{filterSize:o,strides:u,pad:l,dimRoundingMode:c}=r,p=pl(s.shape,o,u,[1,1,1],l,c),d=new gO(p,"max",!0),h=n.runWebGLProgram(d,[s],s.dtype),f=new mB(p),m=n.runWebGLProgram(f,[a,h],s.dtype);return n.disposeIntermediateTensorInfo(h),m}},yB={kernelName:Rn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,input:i,output:s}=t,o=i;mL([i,s],"maxPoolGrad");const{filterSize:u,strides:l,pad:c,dimRoundingMode:p}=r,d=cl(o.shape,u,l,1,c,p),h=new mO(d,"max",!0),f=n.runWebGLProgram(h,[o],o.dtype),m=new fB(d),g=n.runWebGLProgram(m,[a,f],o.dtype);return n.disposeIntermediateTensorInfo(f),g}},bB={kernelName:zn,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{x:r}=e,{filterSize:a,strides:i,pad:s,includeBatchInIndex:o}=t,u=n;se(4===r.shape.length,(()=>`Error in maxPool: input must be rank 4 but got rank ${r.shape.length}.`));const l=[1,1];se(xl(i,l),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${l}'`));const c=cl(r.shape,a,i,l,s),[p,d]=function(e,t,n,r){let a=new mO(n,"max",!1);const i=r.runWebGLProgram(a,[e],"float32");return a=new mO(n,"max",!0,!0,t),[i,r.runWebGLProgram(a,[e],"float32")]}(r,o,c,u);return[p,d]}},vB={kernelName:Pn,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{x:r}=e,{keepDims:a,axis:i}=t,s=n,o=r.shape.length,u=xe(i,r.shape);let l=u;const c=vc(l,o),p=null!=c,d=s.shouldExecuteOnCPU([r]),h=[];let f=r;if(p){if(d){const e=s.texData.get(f.dataId).values,t=new Array(o);for(let e=0;e 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n",cpuKernelImpl:yF}),wB={kernelName:jn,backendName:"webgl",kernelFunc:_B};class DB{constructor(e,t,n){this.variableNames=["x"],this.outputShape=t.map(((t,n)=>t[0]+e[n]+t[1]));const r=e.length,a=IL(r),i=t.map((e=>e[0])).join(","),s=t.map(((t,n)=>t[0]+e[n])).join(","),o=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r),u="reflect"===n?0:1;this.userCode=1!==r?`\n ${a} start = ${a}(${i});\n ${a} end = ${a}(${s});\n\n void main() {\n ${a} outC = getOutputCoords();\n for (int i = 0; i < ${r}; i++) {\n if (outC[i] < start[i]) {\n outC[i] = start[i] * 2 - outC[i] - ${u};\n } else if(outC[i] >= end[i]) {\n outC[i] = (end[i] - 1) * 2 - outC[i] + ${u};\n }\n }\n ${a} coords = outC - start;\n setOutput(getX(${o}));\n }\n `:`\n int start = ${i};\n int end = ${s};\n\n void main() {\n int outC = getOutputCoords();\n if (outC < start) {\n outC = start * 2 - outC - ${u};\n } else if(outC >= end) {\n outC = (end - 1) * 2 - outC + ${u};\n }\n setOutput(getX(outC - start));\n }\n `}}class NB{constructor(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.map(((t,n)=>t[0]+e[n]+t[1]));const r=e.length,a=IL(r),i=t.map((e=>e[0])).join(","),s=t.map(((t,n)=>t[0]+e[n])).join(","),o=HF("rc",r),u=HF("source",r),l=`${o[r-1]} < ${this.outputShape[r-1]}`,c=1===r?"source":`vec2(${u.slice(-2).join()})`,p="reflect"===n?0:1;let d="";if(1===r){const e=`\n ${a} source = rc;\n if (source < start) {\n source = start * 2 - source - ${p};\n } else if (source >= end) {\n source = (end - 1) * 2 - source + ${p};\n }\n source -= start;\n `;d=`\n ${a} rc = outputLoc;\n ${e}\n result[0] = getChannel(getX(${u.join()}), ${c});\n ${o[r-1]} += 1;\n if(${l}) {\n ${e}\n result[1] = getChannel(getX(${u.join()}), ${c});\n }\n `}else{const e=`\n ${a} source = rc;\n ${a} lt = ${a}(lessThan(source, start));\n ${a} gte = ${a}(greaterThanEqual(source, end));\n ${a} orig = 1 - (lt + gte);\n source = orig * source +\n lt * (start * 2 - source - ${p}) +\n gte * ((end - 1) * 2 - source + ${p});\n source -= start;\n `;d=`\n ${a} rc = outputLoc;\n ${e}\n result[0] = getChannel(getX(${u.join()}), ${c});\n ${o[r-1]} += 1;\n if(${l}) {\n ${e}\n result[1] = getChannel(getX(${u.join()}), ${c});\n }\n rc = outputLoc;\n ${o[r-2]} += 1;\n if(${o[r-2]} < ${this.outputShape[r-2]}) {\n ${e}\n result[2] = getChannel(getX(${u.join()}), ${c});\n ${o[r-1]} += 1;\n if(${l}) {\n ${e}\n result[3] = getChannel(getX(${u.join()}), ${c});\n }\n }\n `}this.userCode=`\n const ${a} start = ${a}(${i});\n const ${a} end = ${a}(${s});\n\n void main() {\n ${a} outputLoc = getOutputCoords();\n vec4 result = vec4(0.);\n ${d}\n setOutput(result);\n }\n `}}const MB={kernelName:Un,backendName:"webgl",kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:r}=e,{paddings:a,mode:i}=n,s=Ge().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new NB(r.shape,a,i):new DB(r.shape,a,i);return t.runWebGLProgram(s,[r],r.dtype)}},SB=y$({opSnippet:"if (b == 0.0) return NAN;\n return mod(a, b);",packedOpSnippet:"\n vec4 result = mod(a, b);\n vec4 isNaN = vec4(equal(b, vec4(0.0)));\n \n result.r = isNaN.r > 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n"}),kB={kernelName:qn,backendName:"webgl",kernelFunc:SB};class TB{constructor(e,t,n){this.variableNames=["probs"],this.customUniforms=[{name:"seed",type:"float"}],this.outputShape=[e,n],this.userCode=`\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n\n float r = random(seed);\n float cdf = 0.0;\n\n for (int i = 0; i < ${t-1}; i++) {\n cdf += getProbs(batch, i);\n\n if (r < cdf) {\n setOutput(float(i));\n return;\n }\n }\n\n // If no other event happened, last event happened.\n setOutput(float(${t-1}));\n }\n `}}const CB=y$({opSnippet:"\nif (a == b) {\n return 1.0;\n};\nreturn a / b;",packedOpSnippet:"\n // vec4 one = vec4(equal(a, b));\n // return one + (vec4(1.0) - one) * a / b;\n vec4 result = a / b;\n if(a.x == b.x) {\n result.x = 1.;\n }\n if(a.y == b.y) {\n result.y = 1.;\n }\n if(a.z == b.z) {\n result.z = 1.;\n }\n if(a.w == b.w) {\n result.w = 1.;\n }\n\n return result;\n",checkOutOfBounds:!0}),EB={kernelName:Gt,backendName:"webgl",kernelFunc:CB},AB="return a - b;",IB=y$({opSnippet:AB,packedOpSnippet:AB,supportsComplex:!0,cpuKernelImpl:OF}),LB={kernelName:Wr,backendName:"webgl",kernelFunc:IB};function FB(e){const{inputs:t,backend:n,attrs:r}=e,{logits:a}=t,{dim:i}=r,s=xe([i],a.shape),o=uB({inputs:{x:a},backend:n,attrs:{reductionIndices:s,keepDims:!1}}),u=yc(o.shape,s),l=N$({inputs:{x:o},backend:n,attrs:{shape:u}}),c=IB({inputs:{a,b:l},backend:n}),p=eY({inputs:{x:c},backend:n}),d=I$({inputs:{x:p},backend:n,attrs:{axis:s,keepDims:!1}}),h=N$({inputs:{x:d},backend:n,attrs:{shape:u}}),f=CB({inputs:{a:p,b:h},backend:n});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(h),f}const $B={kernelName:Fr,backendName:"webgl",kernelFunc:FB},OB={kernelName:Wn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{logits:a}=t,{numSamples:i,seed:s,normalized:o}=r,u=o?a:FB({inputs:{logits:a},backend:n,attrs:{dim:a.shape.length-1}}),l=u.shape[0],c=u.shape[1],p=new TB(l,c,i),d=[[s]],h=n.runWebGLProgram(p,[u],"int32",d);return o||n.disposeIntermediateTensorInfo(u),h}},RB={kernelName:Gn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r}=t;if(n.shouldExecuteOnCPU([r])){const e=n.texData.get(r.dataId),[t,a]=vF(e.values,r.shape,r.dtype);return n.makeTensorInfo(a,r.dtype,t)}let a;return a=Ge().getBool("WEBGL_PACK_UNARY_OPERATIONS")?new ZF(r.shape,"\n vec4 result = -x;\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n"):new KF(r.shape,"if (isnan(x)) return x;\n return -x;\n"),n.runWebGLProgram(a,[r],r.dtype)}},YB=uh,BB={kernelName:Jn,backendName:"webgl",kernelFunc:function(e){ca("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:t,backend:n,attrs:r}=e,{boxes:a,scores:i}=t,{maxOutputSize:s,iouThreshold:o,scoreThreshold:u}=r,l=n.readSync(a.dataId),c=n.readSync(i.dataId),{selectedIndices:p}=YB(l,c,s,o,u);return n.makeTensorInfo([p.length],"int32",new Int32Array(p))}},zB=lh,PB={kernelName:Xn,backendName:"webgl",kernelFunc:function(e){ca("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:t,backend:n,attrs:r}=e,{boxes:a,scores:i}=t,{maxOutputSize:s,iouThreshold:o,scoreThreshold:u,padToMaxOutputSize:l}=r,c=n.readSync(a.dataId),p=n.readSync(i.dataId),{selectedIndices:d,validOutputs:h}=zB(c,p,s,o,u,l);return[n.makeTensorInfo([d.length],"int32",new Int32Array(d)),n.makeTensorInfo([],"int32",new Int32Array([h]))]}},HB=ch,jB={kernelName:Zn,backendName:"webgl",kernelFunc:function(e){ca("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:t,backend:n,attrs:r}=e,{boxes:a,scores:i}=t,{maxOutputSize:s,iouThreshold:o,scoreThreshold:u,softNmsSigma:l}=r,c=n.readSync(a.dataId),p=n.readSync(i.dataId),d=s,h=o,f=u,m=l,{selectedIndices:g,selectedScores:y}=HB(c,p,d,h,f,m);return[n.makeTensorInfo([g.length],"int32",new Int32Array(g)),n.makeTensorInfo([y.length],"float32",new Float32Array(y))]}};class UB{constructor(e,t,n,r){this.variableNames=["indices"],this.outputShape=[e,t],this.userCode=`\n void main() {\n ivec2 coords = getOutputCoords();\n int index = round(getIndices(coords.x));\n setOutput(mix(float(${r}), float(${n}),\n float(index == coords.y)));\n }\n `}}const qB={kernelName:er,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{indices:a}=t,{depth:i,onValue:s,offValue:o}=r,u=ce(a.shape),l=new UB(u,i,s,o),c=N$({inputs:{x:a},backend:n,attrs:{shape:[u]}}),p=n.runWebGLProgram(l,[c],a.dtype);n.disposeIntermediateTensorInfo(c);const d=N$({inputs:{x:p},backend:n,attrs:{shape:[...a.shape,i]}});return n.disposeIntermediateTensorInfo(p),d}};function WB(e){const{inputs:t,backend:n}=e,{x:r}=t;if("complex64"===r.dtype){const e=RO({inputs:{input:r},backend:n}),t=WB({inputs:{x:e},backend:n}),a=ZO({inputs:{input:r},backend:n}),i=WB({inputs:{x:a},backend:n}),s=u$({inputs:{real:t,imag:i},backend:n});return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(t),n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(i),s}return pY({attrs:{shape:r.shape,dtype:r.dtype,value:"string"===r.dtype?"":0},backend:n})}const VB={kernelName:ra,backendName:"webgl",kernelFunc:WB},GB={kernelName:Qn,backendName:"webgl",kernelFunc:function e(t){const{inputs:n,backend:r}=t,{x:a}=n;if("string"===a.dtype)throw new Error("onesLike is not supported under string dtype");if("complex64"===a.dtype){const t=RO({inputs:{input:a},backend:r}),n=e({inputs:{x:t},backend:r}),i=ZO({inputs:{input:a},backend:r}),s=WB({inputs:{x:i},backend:r}),o=u$({inputs:{real:n,imag:s},backend:r});return r.disposeIntermediateTensorInfo(t),r.disposeIntermediateTensorInfo(n),r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(s),o}return pY({attrs:{shape:a.shape,dtype:a.dtype,value:1},backend:r})}},KB={kernelName:tr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{axis:a}=r;if(1===t.length)return nY({inputs:{input:t[0]},backend:n,attrs:{dim:a}});const i=t[0].shape,s=t[0].dtype;t.forEach((e=>{oe(i,e.shape,"All tensors passed to stack must have matching shapes"),se(s===e.dtype,(()=>"All tensors passed to stack must have matching dtypes"))}));const o=[],u=tR({inputs:t.map((e=>{const t=nY({inputs:{input:e},backend:n,attrs:{dim:a}});return o.push(t),t})),backend:n,attrs:{axis:a}});return o.forEach((e=>n.disposeIntermediateTensorInfo(e))),u}};class JB{constructor(e,t,n){this.variableNames=["x"],this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map(((t,n)=>t[0]+e[n]+t[1]));const r=e.length,a=IL(r),i=t.map((e=>e[0])).join(","),s=t.map(((t,n)=>t[0]+e[n])).join(","),o=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r);this.userCode=1!==r?`\n ${a} start = ${a}(${i});\n ${a} end = ${a}(${s});\n\n void main() {\n ${a} outC = getOutputCoords();\n if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {\n setOutput(value);\n } else {\n ${a} coords = outC - start;\n setOutput(getX(${o}));\n }\n }\n `:`\n int start = ${i};\n int end = ${s};\n\n void main() {\n int outC = getOutputCoords();\n if (outC < start || outC >= end) {\n setOutput(value);\n } else {\n setOutput(getX(outC - start));\n }\n }\n `}}class XB{constructor(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map(((t,n)=>t[0]+e[n]+t[1]));const r=e.length,a=IL(r),i=t.map((e=>e[0])).join(","),s=t.map(((t,n)=>t[0]+e[n])).join(","),o=HF("rc",r),u=HF("source",r),l=`${o[r-1]} < ${this.outputShape[r-1]}`,c=1===r?"source":`vec2(${u.slice(-2).join()})`,p=[`${a} rc = outputLoc;`,`${o[r-1]} += 1;\n if(${l}) {\n `,1===r?"":`}\n rc = outputLoc;\n ${o[r-2]} += 1;\n if(${o[r-2]} < ${this.outputShape[r-2]}) {`,1===r?"":` ${o[r-1]} += 1;\n if(${l}) {`],d=1===r?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))";let h="";for(let e=0,t=1===r?2:4;e{const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{paddings:i,constantValue:s}=r;if(0===ce(a.shape)){const e=i.map(((e,t)=>e[0]+a.shape[t]+e[1]));return pY({backend:n,attrs:{shape:e,value:s,dtype:a.dtype}})}const o=Ge().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new XB(a.shape,i,s):new JB(a.shape,i,s),u=[[s]];return n.runWebGLProgram(o,[a],a.dtype,u)},QB={kernelName:nr,backendName:"webgl",kernelFunc:ZB},ez=y$({opSnippet:"\n if(a < 0.0 && floor(b) < b){\n return NAN;\n }\n if (b == 0.0) {\n return 1.0;\n }\n return (round(mod(b, 2.0)) != 1) ?\n pow(abs(a), b) : sign(a) * pow(abs(a), b);\n",packedOpSnippet:"\n // isModRound1 has 1 for components with round(mod(b, 2.0)) == 1, 0 otherwise.\n vec4 isModRound1 = vec4(equal(round(mod(b, 2.0)), ivec4(1)));\n vec4 multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1);\n vec4 result = multiplier * pow(abs(a), b);\n\n // Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS\n bvec4 isExpZero = equal(b, vec4(0.0));\n result.r = isExpZero.r ? 1.0 : result.r;\n result.g = isExpZero.g ? 1.0 : result.g;\n result.b = isExpZero.b ? 1.0 : result.b;\n result.a = isExpZero.a ? 1.0 : result.a;\n\n vec4 isNaN = vec4(lessThan(a, vec4(0.0))) * vec4(lessThan(floor(b), b));\n \n result.r = isNaN.r > 0. ? NAN : result.r;\n result.g = isNaN.g > 0. ? NAN : result.g;\n result.b = isNaN.b > 0. ? NAN : result.b;\n result.a = isNaN.a > 0. ? NAN : result.a;\n\n return result;\n"}),tz={kernelName:ar,backendName:"webgl",kernelFunc:ez},nz={kernelName:sr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,keepDims:s}=r,o=a.shape.length,u=[],l=xe(i,a.shape);let c=l;const p=vc(c,o);let d,h=a;if(null!=p&&(h=F$({inputs:{x:a},backend:n,attrs:{perm:p}}),c=_c(c.length,o),u.push(h)),bc("prod",c,o),n.shouldExecuteOnCPU([h])){const e=n.texData.get(h.dataId).values,{outVals:t,outShape:r,outDtype:a}=_F(h.shape,h.dtype,e,c);d=n.makeTensorInfo(r,a,t)}else{const[e,t]=gc(h.shape,c),r=ce(t),i=N$({inputs:{x:h},backend:n,attrs:{shape:[-1,r]}}),s=T$(i,pi(a.dtype),"prod",n);d=N$({inputs:{x:s},backend:n,attrs:{shape:e}}),u.push(i),u.push(s)}if(s){u.push(d);const e=yc(d.shape,l);d=N$({inputs:{x:d},backend:n,attrs:{shape:e}})}return u.forEach((e=>n.disposeIntermediateTensorInfo(e))),d}},rz=e=>{const{backend:t,attrs:n}=e,{start:r,stop:a,step:i,dtype:s}=n,o=wF(r,a,i,s);return t.makeTensorInfo([o.length],s,o)},az={kernelName:or,backendName:"webgl",kernelFunc:rz},iz=g$({opSnippet:"return 1.0 / x;"}),sz={kernelName:lr,backendName:"webgl",kernelFunc:iz},oz=g$({opSnippet:"if (isnan(x)) return x;\n return (x < 0.0) ? 0.0 : x;\n",packedOpSnippet:"\n vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n"}),uz={kernelName:cr,backendName:"webgl",kernelFunc:oz},lz=g$({opSnippet:"if (isnan(x)) return x;\n return (x < 0.0) ? 0.0 : min(6.0, x);\n",packedOpSnippet:"\n vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n"}),cz={kernelName:gr,backendName:"webgl",kernelFunc:lz};class pz{constructor(e,t,n,r,a){this.variableNames=["A"],this.outputShape=[];const[i,s,o,u]=e;this.outputShape=[i,t,n,u];const l=[r&&t>1?s-1:s,r&&n>1?o-1:o],c=[r&&t>1?t-1:t,r&&n>1?n-1:n];let p;p=a?"(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":"vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n ${l[0]/c[0]},\n ${l[1]/c[1]});\n const vec2 inputShapeRC = vec2(${s}.0, ${o}.0);\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n ivec2 yRC = coords.yz;\n\n // Fractional source index.\n vec2 sourceFracIndexRC = ${p};\n\n // Compute the four integer indices.\n ivec2 sourceFloorRC = ivec2(max(sourceFracIndexRC, vec2(0.0)));\n ivec2 sourceCeilRC = ivec2(\n min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n float topLeft = getA(b, sourceFloorRC.x, sourceFloorRC.y, d);\n float bottomLeft = getA(b, sourceCeilRC.x, sourceFloorRC.y, d);\n float topRight = getA(b, sourceFloorRC.x, sourceCeilRC.y, d);\n float bottomRight = getA(b, sourceCeilRC.x, sourceCeilRC.y, d);\n\n vec2 fracRC = sourceFracIndexRC - vec2(sourceFloorRC);\n\n float top = topLeft + (topRight - topLeft) * fracRC.y;\n float bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y;\n float newValue = top + (bottom - top) * fracRC.x;\n\n setOutput(newValue);\n }\n `}}class dz{constructor(e,t,n,r,a){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[i,s,o,u]=e;this.outputShape=[i,t,n,u];const l=[r&&t>1?s-1:s,r&&n>1?o-1:o],c=[r&&t>1?t-1:t,r&&n>1?n-1:n];let p;p=a?"(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":"vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec3 effectiveInputOverOutputRatioRC = vec3(\n ${l[0]/c[0]},\n ${l[1]/c[1]},\n ${l[1]/c[1]});\n const vec3 inputShapeRC = vec3(${s}.0, ${o}.0,\n ${o}.0);\n\n float getAValue(int b, int r, int c, int d) {\n return getChannel(getA(b, r, c, d), vec2(c, d));\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n // Calculate values for next column in yRC.z.\n ivec3 yRC = coords.yzz + ivec3(0, 0, 1);\n\n // Fractional source index.\n vec3 sourceFracIndexRC = ${p};\n\n // Compute the four integer indices.\n ivec3 sourceFloorRC = ivec3(max(sourceFracIndexRC, vec3(0.0)));\n ivec3 sourceCeilRC = ivec3(\n min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n // Should we calculate next column and row elements in 2x2 packed cell.\n bool hasNextCol = d < ${u-1};\n bool hasNextRow = coords.z < ${n-1};\n\n // In parallel, construct four corners for all four components in\n // packed 2x2 cell.\n vec4 topLeft = vec4(\n getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d),\n hasNextCol ? getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n vec4 bottomLeft = vec4(\n getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d),\n hasNextCol ? getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n vec4 topRight = vec4(\n getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d),\n hasNextCol ? getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n vec4 bottomRight = vec4(\n getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d),\n hasNextCol ? getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n vec3 fracRC = sourceFracIndexRC - vec3(sourceFloorRC);\n\n vec4 top = mix(topLeft, topRight, fracRC.yyzz);\n vec4 bottom = mix(bottomLeft, bottomRight, fracRC.yyzz);\n vec4 newValue = mix(top, bottom, fracRC.x);\n\n setOutput(newValue);\n }\n `}}const hz={kernelName:fr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:a}=t,{alignCorners:i,halfPixelCenters:s,size:o}=r,[u,l]=o,c=Ge().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new dz(a.shape,u,l,i,s):new pz(a.shape,u,l,i,s);return n.runWebGLProgram(c,[a],"float32")}};class fz{constructor(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;const[,r,a]=t,[,i,s]=e,o=[n&&i>1?r-1:r,n&&s>1?a-1:a],u=[n&&i>1?i-1:i,n&&s>1?s-1:s],l=o[0]/u[0],c=o[1]/u[1],p=1/l,d=1/c,h=2*Math.ceil(p)+2,f=2*Math.ceil(d)+2;this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n int r = coords[1];\n int c = coords[2];\n\n float accumulator = 0.0;\n\n const float heightScale = float(${l});\n const float widthScale = float(${c});\n\n const float invHeightScale = float(${p});\n const float invWidthScale = float(${d});\n\n const int winHeight = int(${h});\n const int winWidth = int(${f});\n\n // Compute bounds for where in dy we will look\n float startRLerp = floor(float(r) * invHeightScale);\n int startDyR = int(startRLerp - float(winHeight / 2));\n\n float startCLerp = floor(float(c) * invWidthScale);\n int startDyC = int(startCLerp - float(winWidth / 2));\n\n // Loop over dy\n for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {\n int dyR = dyROffset + startDyR;\n\n // Guard against the window exceeding the bounds of dy\n if (dyR < 0 || dyR >= ${i}) {\n continue;\n }\n\n for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {\n int dyC = dyCOffset + startDyC;\n\n // Guard against the window exceeding the bounds of dy\n if (dyC < 0 || dyC >= ${s}) {\n continue;\n }\n\n float dxR = float(dyR) * heightScale;\n int topDxRIndex = int(floor(dxR));\n int bottomDxRIndex = int(min(ceil(dxR), ${r-1}.0));\n float dxRLerp = dxR - float(topDxRIndex);\n float inverseDxRLerp = 1.0 - dxRLerp;\n\n float dxC = float(dyC) * widthScale;\n int leftDxCIndex = int(floor(dxC));\n int rightDxCIndex = int(min(ceil(dxC), ${a-1}.0));\n float dxCLerp = dxC - float(leftDxCIndex);\n float inverseDxCLerp = 1.0 - dxCLerp;\n\n if (r == topDxRIndex && c == leftDxCIndex) {\n // topLeft\n accumulator +=\n getDy(b, dyR, dyC, d) * inverseDxRLerp * inverseDxCLerp;\n }\n\n if (r == topDxRIndex && c == rightDxCIndex) {\n // topRight\n accumulator += getDy(b, dyR, dyC, d) * inverseDxRLerp * dxCLerp;\n }\n\n if (r == bottomDxRIndex && c == leftDxCIndex) {\n // bottomLeft\n accumulator += getDy(b, dyR, dyC, d) * dxRLerp * inverseDxCLerp;\n }\n\n if (r == bottomDxRIndex && c == rightDxCIndex) {\n // bottomRight\n accumulator += getDy(b, dyR, dyC, d) * dxRLerp * dxCLerp;\n }\n }\n }\n // End loop over dy\n\n setOutput(accumulator);\n }\n `}}const mz={kernelName:mr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:a,dy:i}=t,{alignCorners:s}=r,o=new fz(i.shape,a.shape,s);return n.runWebGLProgram(o,[i],i.dtype)}};class gz{constructor(e,t,n,r,a){this.variableNames=["A"],this.outputShape=[];const[i,s,o,u]=e;this.outputShape=[i,t,n,u];const l=[r&&t>1?s-1:s,r&&n>1?o-1:o],c=[r&&t>1?t-1:t,r&&n>1?n-1:n],p=r?"0.5":"0.0";let d;d=a?"max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))":"vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n ${l[0]/c[0]},\n ${l[1]/c[1]});\n const vec2 inputShapeRC = vec2(${s}.0, ${o}.0);\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n ivec2 yRC = coords.yz;\n\n // Fractional source index.\n vec2 sourceFracIndexRC = ${d};\n\n // Compute the coordinators of nearest neighbor point.\n ivec2 sourceNearestRC = ivec2(\n min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${p})));\n float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d);\n\n setOutput(newValue);\n }\n `}}class yz{constructor(e,t,n,r,a){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[i,s,o,u]=e;this.outputShape=[i,t,n,u];const l=[r&&t>1?s-1:s,r&&n>1?o-1:o],c=[r&&t>1?t-1:t,r&&n>1?n-1:n],p=r?"0.5":"0.0";let d;d=a?"max((vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC, vec3(0.0))":"vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec3 effectiveInputOverOutputRatioRC = vec3(\n ${l[0]/c[0]},\n ${l[1]/c[1]},\n ${l[1]/c[1]});\n const vec3 inputShapeRC = vec3(${s}.0, ${o}.0,\n ${o}.0);\n\n float getAValue(int b, int r, int c, int d) {\n return getChannel(getA(b, r, c, d), vec2(c, d));\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n // Calculate values for next column in yRC.z.\n ivec3 yRC = coords.yzz + ivec3(0, 0, 1);\n\n // Fractional source index.\n vec3 sourceFracIndexRC = ${d};\n\n // Compute the coordinators of nearest neighbor point.\n ivec3 sourceNearestRC = ivec3(\n min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${p})));\n\n // Should we calculate next column and row elements in 2x2 packed cell.\n bool hasNextCol = d < ${u-1};\n bool hasNextRow = coords.z < ${n-1};\n\n vec4 newValue = vec4(\n getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d),\n hasNextCol ? getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d + 1) : 0.0);\n\n setOutput(newValue);\n }\n `}}const bz={kernelName:dr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:a}=t,{alignCorners:i,halfPixelCenters:s,size:o}=r,[u,l]=o,c=Ge().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new yz(a.shape,u,l,i,s):new gz(a.shape,u,l,i,s);return n.runWebGLProgram(c,[a],a.dtype)}};class vz{constructor(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;const[,r,a]=t,[,i,s]=e,o=[n&&i>1?r-1:r,n&&s>1?a-1:a],u=[n&&i>1?i-1:i,n&&s>1?s-1:s],l=o[0]/u[0],c=o[1]/u[1],p=1/l,d=1/c,h=2*Math.ceil(p)+2,f=2*Math.ceil(d)+2;this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n int r = coords[1];\n int c = coords[2];\n\n float accumulator = 0.0;\n\n const float heightScale = float(${l});\n const float widthScale = float(${c});\n\n const float invHeightScale = float(${p});\n const float invWidthScale = float(${d});\n\n const int winHeight = int(${h});\n const int winWidth = int(${f});\n\n // Compute bounds for where in dy we will look\n float startRLerp = floor(float(r) * invHeightScale);\n int startDyR = int(floor(startRLerp - float(winHeight / 2)));\n\n float startCLerp = floor(float(c) * invWidthScale);\n int startDyC = int(floor(startCLerp - float(winWidth / 2)));\n\n // Loop over dy\n for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {\n int dyR = dyROffset + startDyR;\n\n // Guard against the window exceeding the bounds of dy\n if (dyR < 0 || dyR >= ${i}) {\n continue;\n }\n\n for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {\n int dyC = dyCOffset + startDyC;\n\n // Guard against the window exceeding the bounds of dy\n if (dyC < 0 || dyC >= ${s}) {\n continue;\n }\n\n float sourceFracRow =\n float(${o[0]}) *\n (float(dyR) / float(${u[0]}));\n\n float sourceFracCol =\n float(${o[1]}) *\n (float(dyC) / float(${u[1]}));\n\n int sourceNearestRow = int(min(\n float(int(${r}) - 1),\n ${n} ? float(round(sourceFracRow)) :\n float(floor(sourceFracRow))));\n\n int sourceNearestCol = int(min(\n float(int(${a}) - 1),\n ${n} ? float(round(sourceFracCol)) :\n float(floor(sourceFracCol))));\n\n if (r == sourceNearestRow && c == sourceNearestCol) {\n accumulator += getDy(b, dyR, dyC, d);\n }\n }\n }\n // End loop over dy\n\n setOutput(accumulator);\n }\n `}}const xz={kernelName:hr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:a,dy:i}=t,{alignCorners:s}=r,o=new vz(i.shape,a.shape,s);return n.runWebGLProgram(o,[i],i.dtype)}};class _z{constructor(e,t){this.variableNames=["x"];const n=e.length;if(n>4)throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`);if(this.outputShape=e,1===n)return void(this.userCode=`\n void main() {\n int coord = getOutputCoords();\n setOutput(getX(${e[0]} - coord - 1));\n }\n `);const r=e.map(((n,r)=>(n=>-1!==t.indexOf(n)&&1!==e[n]?`${e[n]} - coords[${n}] - 1`:`coords[${n}]`)(r))).join(","),a=IL(n);this.userCode=`\n void main() {\n ${a} coords = getOutputCoords();\n setOutput(getX(${r}));\n }\n `}}class wz{constructor(e,t){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;const n=e.length;if(n>4)throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`);this.outputShape=e;const r=HF("rc",n),a=`${r[n-1]} + 1 < ${this.outputShape[n-1]}`,i=`${r[n-2]} + 1 < ${this.outputShape[n-2]}`,s=IL(n);function o(n){const r=e.map(((r,a)=>function(n,r){return-1!==t.indexOf(n)&&1!==e[n]?`${e[n]} - ${r[n]} - 1`:`${r[n]}`}(a,n)));return`getChannel(getX(${r.join(",")}), vec2(${r.slice(-2).join(",")}))`}this.userCode=1===n?`\n void main(){\n int rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = getChannel(getX(${e[0]} - rc - 1),\n ${e[0]} - rc - 1);\n if(${a}){\n result.g = getChannel(getX(${e[0]} - (rc + 1) - 1),\n ${e[0]} - (rc + 1) - 1);\n }\n setOutput(result);\n }\n `:`\n void main() {\n ${s} rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = ${function(e){return o(e)}(r.slice())};\n if(${a}){\n result.g = ${function(e){return e[n-1]="("+e[n-1]+" + 1)",o(e)}(r.slice())};\n }\n if(${i}) {\n result.b = ${function(e){return e[n-2]="("+e[n-2]+" + 1)",o(e)}(r.slice())};\n if(${a}) {\n result.a = ${function(e){return e[n-1]="("+e[n-1]+" + 1)",e[n-2]="("+e[n-2]+" + 1)",o(e)}(r.slice())};\n }\n }\n setOutput(result);\n }\n `}}const Dz={kernelName:yr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{dims:i}=r,s=a.shape.length,o=xe(i,a.shape);if(0===s)return s$({inputs:{x:a},backend:n});const u=Ge().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new wz(a.shape,o):new _z(a.shape,o);return n.runWebGLProgram(u,[a],a.dtype)}};class Nz{constructor(e,t){this.variableNames=["Image"],this.outputShape=[],this.customUniforms=[{name:"params",type:"vec4"}];const n=e[1],r=e[2];this.outputShape=e;let a="";a="number"==typeof t?`float outputValue = ${t.toFixed(2)};`:`\n vec3 fill = vec3(${t.join(",")});\n float outputValue = fill[coords[3]];`,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int x = coords[2];\n int y = coords[1];\n float coordXFloat = (float(x) - params[0]) * params[3] -\n (float(y) - params[1]) * params[2];\n float coordYFloat = (float(x) - params[0]) * params[2] +\n (float(y) - params[1]) * params[3];\n int coordX = int(round(coordXFloat + params[0]));\n int coordY = int(round(coordYFloat + params[1]));\n ${a}\n if(coordX >= 0 && coordX < ${r} && coordY >= 0 && coordY < ${n}) {\n outputValue = getImage(coords[0], coordY, coordX, coords[3]);\n }\n setOutput(outputValue);\n }\n `}}const Mz={kernelName:sa,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{image:r}=e,{radians:a,fillValue:i,center:s}=t,o=n,u=new Nz(r.shape,i),[l,c]=nf(s,r.shape[1],r.shape[2]),p=[[l,c,Math.sin(a),Math.cos(a)]];return o.runWebGLProgram(u,[r],r.dtype,p)}},Sz=g$({opSnippet:"\n // OpenGL ES does not support round function.\n // The algorithm is based on banker's rounding.\n float base = floor(x);\n if ((x - base) < 0.5) {\n return floor(x);\n } else if ((x - base) > 0.5) {\n return ceil(x);\n } else {\n if (mod(base, 2.0) == 0.0) {\n return base;\n } else {\n return base + 1.0;\n }\n }\n"}),kz={kernelName:br,backendName:"webgl",kernelFunc:Sz},Tz=g$({opSnippet:"return inversesqrt(x);",cpuKernelImpl:DF}),Cz={kernelName:vr,backendName:"webgl",kernelFunc:Tz};class Ez{constructor(e,t,n,r,a,i,s=!0){this.variableNames=["updates","indices","defaultValue"],this.outputShape=i;const o=IL(a.length),u=IL(i.length);let l="";1===n?l="i":2===n&&(l="i, j");const c=`getIndices(${l})`;let p="";1===r?p="i":2===r&&(p="i, coords[1]");const d=`getUpdates(${p})`,h=t>1?"strides[j]":"strides";this.userCode=`\n ${o} strides = ${o}(${a});\n\n void main() {\n ${u} coords = getOutputCoords();\n float sum = 0.0;\n bool found = false;\n for (int i = 0; i < ${e}; i++) {\n int flattenedIndex = 0;\n for (int j = 0; j < ${t}; j++) {\n int index = round(${c});\n flattenedIndex += index * ${h};\n }\n if (flattenedIndex == coords[0]) {\n sum += ${d};\n found = true;\n }\n }\n setOutput(mix(getDefaultValue(), sum, float(found)));\n }\n `}}const Az={kernelName:xr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{indices:a,updates:i}=t,{shape:s}=r,{sliceRank:o,numUpdates:u,sliceSize:l,strides:c,outputSize:p}=jo(0,a,s),d=[p/l,l];if(0===p)return n.makeTensorInfo(s,a.dtype);const h=N$({inputs:{x:a},backend:n,attrs:{shape:[u,o]}}),f=N$({inputs:{x:i},backend:n,attrs:{shape:[u,l]}}),m=n.makeTensorInfo([],"float32",new Float32Array([0])),g=new Ez(u,o,h.shape.length,f.shape.length,c,d),y=n.runWebGLProgram(g,[f,h,m],f.dtype),b=N$({inputs:{x:y},backend:n,attrs:{shape:s}});return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(y),n.disposeIntermediateTensorInfo(m),b}};class Iz{constructor(e,t,n,r){this.variableNames=["sortedSequence","values"],this.customUniforms=[{name:"numInputs",type:"int"}],this.outputShape=[e,n];const a=`for (int i = 0; i < ${Math.ceil(Math.log2(t+1))}; ++i) { if (left >= right) break;`,i=2===Ge().getNumber("WEBGL_VERSION")?"while (left < right) {":a,s="left"===r?"<":"<=";this.userCode=`\n int findBound(int batch, float value) {\n int left = 0;\n int right = numInputs;\n int mid;\n ${i}\n mid = (left + right) / 2;\n if (getSortedSequence(batch, mid) ${s} value) {\n left = mid + 1;\n } else {\n right = mid;\n }\n }\n return right;\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int valueIndex = coords[1];\n\n float value = getValues(batch, valueIndex);\n\n setOutput(float(findBound(batch, value)));\n }\n `}}const Lz={kernelName:_r,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{sortedSequence:a,values:i}=t,{side:s}=r,o=new Iz(a.shape[0],a.shape[1],i.shape[1],s),u=[[a.shape[1]]];return n.runWebGLProgram(o,[a,i],"int32",u)}};class Fz{constructor(e,t,n){let r,a;if(this.variableNames=["c","a","b"],this.outputShape=t,n>4)throw Error(`Where for rank ${n} is not yet supported`);if(1===n)a="resRC",r="resRC";else{const n=["resRC.x","resRC.y","resRC.z","resRC.w"],i=[],s=[];for(let r=0;r= 1.0) {\n setOutput(getA(${a}));\n } else {\n setOutput(getB(${a}));\n }\n }\n `}}const $z={kernelName:wr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{condition:r,t:a,e:i}=t,s=new Fz(r.shape.length,a.shape,a.shape.length);return n.runWebGLProgram(s,[r,a,i],ci(a.dtype,i.dtype))}},Oz=g$({opSnippet:`\n // Stable and Attracting Fixed Point (0, 1) for Normalized Weights.\n // see: https://arxiv.org/abs/1706.02515\n float scaleAlpha = ${lf};\n float scale = ${cf};\n return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);\n`}),Rz={kernelName:Dr,backendName:"webgl",kernelFunc:Oz},Yz=g$({opSnippet:"if (isnan(x)) return x;\n return 1.0 / (1.0 + exp(-1.0 * x));\n",packedOpSnippet:"\n vec4 result = 1.0 / (1.0 + exp(-1.0 * x));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n",cpuKernelImpl:MF}),Bz={kernelName:Tr,backendName:"webgl",kernelFunc:Yz},zz=g$({opSnippet:"\n if (isnan(x)) { return 0.0; }\n return sign(x);\n"}),Pz={kernelName:kr,backendName:"webgl",kernelFunc:zz},Hz=g$({opSnippet:"if (isnan(x)) return x;\n return sin(x);\n"}),jz={kernelName:Mr,backendName:"webgl",kernelFunc:Hz},Uz=g$({opSnippet:"\n float e2x = exp(x);\n return (e2x - 1.0 / e2x) / 2.0;\n"}),qz={kernelName:Sr,backendName:"webgl",kernelFunc:Uz},Wz=g$({opSnippet:"\n float epsilon = 1.1920928955078125e-7;\n float threshold = log(epsilon) + 2.0;\n\n bool too_large = x > -threshold;\n bool too_small = x < threshold;\n\n float result;\n float exp_x = exp(x);\n\n if (too_large){\n result = x;\n }\n else if (too_small){\n result = exp_x;\n }\n else{\n result = log(exp_x + 1.0);\n }\n return result;\n"}),Vz={kernelName:Cr,backendName:"webgl",kernelFunc:Wz},Gz={kernelName:Ir,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockShape:i,paddings:s}=r;se(a.shape.length<=4,(()=>"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet"));const o=i.reduce(((e,t)=>e*t)),u=[[0,0]];u.push(...s);for(let e=1+i.length;en.disposeIntermediateTensorInfo(e))),g}},Kz={kernelName:$r,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{indices:r,values:a,denseShape:i,defaultValue:s}=t;if(1!==i.shape.length)throw new Error(`Dense shape must be a vector, saw:\n ${i.shape}`);if(2!==r.shape.length)throw new Error(`Indices must be a matrix, saw:\n ${r.shape}`);if(1!==a.shape.length)throw new Error(`Values must be a vector, saw:\n ${a.shape}`);if(0!==s.shape.length)throw new Error(`Default value must be a scalar, saw:\n ${s.shape}`);const o=n.readSync(r.dataId),u=n.readSync(a.dataId),l=n.readSync(i.dataId),c=n.readSync(s.dataId)[0],[p,d,h,f,m]=TF(o,r.shape,r.dtype,u,a.dtype,l,c);return[n.makeTensorInfo(d,r.dtype,p),n.makeTensorInfo([d[0]],a.dtype,h),n.makeTensorInfo([f.length],"bool",new Uint8Array(f.map((e=>Number(e))))),n.makeTensorInfo([m.length],r.dtype,new Int32Array(m))]}},Jz={kernelName:Or,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{inputIndices:r,inputShape:a,newShape:i}=t;if(2!==r.shape.length)throw new Error(`Input indices should be a matrix but received shape ${r.shape}`);if(1!==a.shape.length)throw new Error(`Input shape should be a vector but received shape ${a.shape}`);if(1!==i.shape.length)throw new Error(`Target shape should be a vector but received shape ${i.shape}`);const s=Array.from(n.readSync(a.dataId)),o=n.readSync(r.dataId),u=Array.from(n.readSync(i.dataId)),[l,c,p]=CF(o,r.shape,r.dtype,s,u);return[n.makeTensorInfo(c,r.dtype,l),n.makeTensorInfo([p.length],i.dtype,new Int32Array(p))]}},Xz={kernelName:Rr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{data:r,indices:a,segmentIds:i}=t;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.shape.length)throw new Error(`Indices should be a vector but received shape\n ${a.shape}`);if(1!==i.shape.length)throw new Error(`Segment ids should be a vector but received shape\n ${i.shape}`);const s=n.readSync(r.dataId),o=n.readSync(a.dataId),u=n.readSync(i.dataId),[l,c]=EF(s,r.shape,r.dtype,o,u,!0);return n.makeTensorInfo(c,r.dtype,l)}},Zz={kernelName:Yr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n}=e,{data:r,indices:a,segmentIds:i}=t;if(r.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.shape.length)throw new Error(`Indices should be a vector but received shape\n ${a.shape}`);if(1!==i.shape.length)throw new Error(`Segment ids should be a vector but received shape\n ${i.shape}`);const s=n.readSync(r.dataId),o=n.readSync(a.dataId),u=n.readSync(i.dataId),[l,c]=EF(s,r.shape,r.dtype,o,u);return n.makeTensorInfo(c,r.dtype,l)}},Qz={kernelName:Br,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{sparseIndices:a,sparseValues:i,defaultValue:s}=t,{outputShape:o}=r,{sliceRank:u,numUpdates:l,sliceSize:c,strides:p,outputSize:d}=jo(0,a,o);if("string"===i.dtype){const e=n.bufferSync(a),t=n.bufferSync(i),r=Ha(n.readSync(s.dataId)[0]),h=NF(e,t,o,d,c,l,u,p,r,!1);return n.makeTensorInfo(o,h.dtype,h.values)}const h=new Ez(l,u,a.shape.length,i.shape.length,p,[d,1],!1),f=n.runWebGLProgram(h,[i,a,s],i.dtype),m=N$({inputs:{x:f},backend:n,attrs:{shape:o}});return n.disposeIntermediateTensorInfo(f),m}},eP={kernelName:Lr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{numOrSizeSplits:i,axis:s}=r,o=xe(s,a.shape)[0],u=If(a,i,o),l=a.shape.length,c=new Array(l).fill(0),p=a.shape.slice();return u.map((e=>{const t=[...p];t[o]=e;const r=EO({inputs:{x:a},backend:n,attrs:{begin:c,size:t}});return c[o]+=e,r}))}},tP="return sqrt(x);",nP=g$({opSnippet:tP,packedOpSnippet:tP,cpuKernelImpl:AF}),rP={kernelName:Er,backendName:"webgl",kernelFunc:nP},aP=g$({opSnippet:"return x * x;"}),iP={kernelName:Pr,backendName:"webgl",kernelFunc:aP},sP="return (a - b) * (a - b);",oP=y$({opSnippet:sP,packedOpSnippet:sP}),uP={kernelName:zr,backendName:"webgl",kernelFunc:oP},lP={kernelName:aa,backendName:"webgl",kernelFunc:function({inputs:e,attrs:t,backend:n}){const{x:r}=e,a=`if (isnan(x)) return x;\n return x > 0.0 ? 1.0 : float(${t.alpha});\n `,i=new KF(r.shape,a);return n.runWebGLProgram(i,[r],r.dtype)}};class cP{constructor(e,t,n){this.variableNames=["x"],this.outputShape=n;const r=n.length,a=IL(n.length),i=IL(n.length);let s="";if(1===r)s="coords * strides + begin";else{let e=0;s=n.map(((t,r)=>(e++,1===n.length?`coords * strides[${r}] + begin[${r}]`:`coords[${e-1}] * strides[${r}] + begin[${r}]`))).join(",")}this.userCode=`\n ${a} begin = ${a}(${e});\n ${a} strides = ${a}(${t});\n\n void main() {\n ${i} coords = getOutputCoords();\n setOutput(getX(${s}));\n }\n `}}const pP={kernelName:Hr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{begin:i,end:s,strides:o,beginMask:u,endMask:l,ellipsisMask:c,newAxisMask:p,shrinkAxisMask:d}=r,{finalShapeSparse:h,finalShape:f,isIdentity:m,sliceDim0:g,isSimpleSlice:y,begin:b,end:v,strides:x}=iu(a.shape,i,s,o,u,l,c,p,d);let _;if(m)_=N$({inputs:{x:a},backend:n,attrs:{shape:f}});else if(g||y){se(a.shape.length>=1,(()=>`Input must have rank at least 1, got: ${a.shape.length}`));const e=Wo(b,v,x),t=EO({inputs:{x:a},backend:n,attrs:{begin:b,size:e}});_=N$({inputs:{x:t},backend:n,attrs:{shape:f}}),n.disposeIntermediateTensorInfo(t)}else if(n.shouldExecuteOnCPU([a])){const e=n.readSync(a.dataId),t=Is(a.shape,a.dtype,e),r=IF(h,t,x,b);_=n.makeTensorInfo(f,a.dtype,r.values)}else{const e=new cP(b,x,h);_=n.runWebGLProgram(e,[a],a.dtype)}const w=N$({inputs:{x:_},backend:n,attrs:{shape:f}});return n.disposeIntermediateTensorInfo(_),w}},dP={kernelName:jr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{separator:a,nGramWidths:i,leftPad:s,rightPad:o,padWidth:u,preserveShortSequences:l}=r,{data:c,dataSplits:p}=t,d=n.readSync(c.dataId),h=n.readSync(p.dataId),[f,m]=LF(d,h,a,i,s,o,u,l);return[n.makeTensorInfo([f.length],"string",f),n.makeTensorInfo(p.shape,"int32",m)]}},hP={kernelName:Ur,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{skipEmpty:a}=r,{input:i,delimiter:s}=t;if("string"!==i.dtype)throw new Error("Input must be of datatype string");if(1!==i.shape.length)throw new Error(`Input must be a vector, got shape: ${i.shape}`);if(0!==s.shape.length)throw new Error(`Delimiter must be a scalar, got shape: ${s.shape}`);const o=n.readSync(i.dataId),u=n.readSync(s.dataId)[0],[l,c,p]=FF(o,u,a),d=c.length;return[n.makeTensorInfo([d,2],"int32",l),n.makeTensorInfo([d],"string",c),n.makeTensorInfo([2],"int32",new Int32Array(p))]}},fP={kernelName:qr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{numBuckets:a}=r,{input:i}=t;if("string"!==i.dtype)throw new Error("Input must be of datatype string");if(a<=0)throw new Error("Number of buckets must be at least 1");const s=n.readSync(i.dataId),o=$F(s,a);return n.makeTensorInfo(i.shape,"int32",o)}},mP=g$({opSnippet:"return tan(x);"}),gP={kernelName:Vr,backendName:"webgl",kernelFunc:mP},yP=g$({opSnippet:"\n float e2x = exp(-2.0 * abs(x));\n return sign(x) * (1.0 - e2x) / (1.0 + e2x);\n"}),bP={kernelName:Gr,backendName:"webgl",kernelFunc:yP};class vP{constructor(e,t){this.variableNames=["A"];const n=new Array(e.length);for(let r=0;r5)throw Error(`Tile for rank ${t} is not yet supported`);if(1===t)return`imod(resRC, ${e[0]})`;const n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],r=[];for(let t=0;t5){const e=n.readSync(a.dataId),t="string"===a.dtype?e.map((e=>Ha(e))):e,r=Is(a.shape,a.dtype,t),s=RF(r,i);return n.makeTensorInfo(s.shape,s.dtype,s.values)}const s=new vP(a.shape,i);return n.runWebGLProgram(s,[a],a.dtype)}const _P={kernelName:Kr,backendName:"webgl",kernelFunc:xP};class wP{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="\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int elemIdx = coords[1];\n\n // We compare elements pair-wise within a group of size 2 * inc.\n // The comparing rule for each group alternates between ascending\n // and descending. Within each group, we compare each pair at\n // positions i and i+inc. To decide whether an element at position i\n // is x0 or x1, we mod it by 2 * inc, if the result is smaller than\n // inc, it is in the first half of the group, we denote it as x0,\n // otherwise we denote it as x1.\n // For example, as shown in the Bitonic top K paper referenced above,\n // Figure5(a) shows that element[1] is in the\n // second half of the group when group size is 2, but it is in the\n // first half of the group when group size is 4.\n\n bool isFirstInPair = imod(elemIdx, 2 * inc) < inc;\n int i = isFirstInPair ? elemIdx : elemIdx - inc;\n\n int i0 = firstPass == 1 ? i : int(getIndices(batch, i));\n int i1 = firstPass == 1 ? i + inc : int(getIndices(batch, i + inc));\n float x0 = i0 < n ? getX(batch, i0) : negativeInf;\n float x1 = i1 < n ? getX(batch, i1) : negativeInf;\n\n // Denotes which direction indices are in (ascending or descending).\n bool reverse = imod(elemIdx, 2 * dir) >= dir;\n bool isGreater = x0 > x1 || (x0 == x1 && i1 > i0);\n if (reverse == isGreater) { // Elements in opposite order of direction\n int iTemp = i0;\n i0 = i1;\n i1 = iTemp;\n }\n if (isFirstInPair) {\n setOutput(float(i0));\n } else {\n setOutput(float(i1));\n }\n }\n "}}class DP{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="\n void main() {\n // Takes max of indices (0, k), (1, k + 1), (2, k + 2) ...\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int elemIdx = coords[1];\n\n // The output size is half of the previous size.\n // If the previous sequence is | | | | _ _ _ _ | | | | _ _ _ _ (k=4),\n // we only need to output the indices at positions |, the indices at\n // positions _ can be thrown away, see Figure5(b) After Phase 2\n // (Merge phase) in the Bitonic Top K paper referenced above.\n // For example, the paper shows we only need to output the orange bars.\n // The output sequence should look like this | | | | | | | |.\n // Because the sequence is halved, to map the output index back\n // to the previous sequence to find the corresponding value,\n // we need to double the index. When we double the index,\n // we basically interpolate a position, so 2i looks like\n // | _ | _ | _ | _ | _ | _ | _. We move the | to the first k position\n // of each 2k positions by - elemIdx % k. E.g. for output at\n // index 4,5,6,7, we want to get the corresponding element at\n // original index 8,9,10,11, for output at index 8,9,10,11,\n // we want to get the corresponding element at original index\n // 16,17,18,19, so on and so forth.\n\n int i = elemIdx < k ? elemIdx : (elemIdx * 2 - imod(elemIdx, k));\n int i0 = firstPass == 1 ? i : int(getIndices(batch, i));\n int i1 = firstPass == 1 ? i + k : int(getIndices(batch, i + k));\n\n float x0 = getX(batch, i0);\n float x1 = i1 < n ? getX(batch, i1) : x0;\n\n setOutput(x0 >= x1 ? float(i0) : float(i1));\n }\n "}}function NP(e,t){null!==t&&e.disposeIntermediateTensorInfo(t)}function MP(e){let t=1;for(;tu){const e=n.readSync(a.dataId),[t,r]=YF(e,l,a.dtype,i,s);return[n.makeTensorInfo(t.shape,t.dtype,t.values),n.makeTensorInfo(r.shape,r.dtype,r.values)]}if(0===i)return l[l.length-1]=0,[n.makeTensorInfo(l,a.dtype,[]),n.makeTensorInfo(l,"int32",[])];if(1===c)return[a,pY({attrs:{shape:l,dtype:"int32",value:0},backend:n})];const p=n.texData.get(a.dataId),d=null!==p&&p.isPacked,h=d?n.unpackTensor(a):a,f=ce(l)/c,m=N$({inputs:{x:h},attrs:{shape:[f,c]},backend:n});d&&NP(n,h);const g=MP(i),y=MP(c);let b=null;const v=()=>null===b?[m,m]:[m,b],x=(e,t,r)=>{const a=v(),i=new wP(r),s=[[c],[null===b?1:0],[Number.NEGATIVE_INFINITY],[e],[t]],o=b;b=n.runWebGLProgram(i,a,"int32",s),NP(n,o)};for(let e=1;e=1;n/=2)x(t,n,[f,y])}for(let e=y;e>g;e/=2){const t=v(),r=new DP([f,e/2]),a=[[c],[null===b?1:0],[g]],i=b;b=n.runWebGLProgram(r,t,"int32",a),NP(n,i);const s=g/2,o=2*s;for(let e=s;e>=1;e/=2)x(o,e,b.shape)}let _=b;b=EO({inputs:{x:b},backend:n,attrs:{begin:0,size:[f,i]}}),NP(n,_);let w=CY({inputs:{x:m,indices:b},backend:n,attrs:{axis:1,batchDims:1}});NP(n,m);const D=l.slice(0,-1);D.push(i),_=b,b=N$({inputs:{x:b},attrs:{shape:D},backend:n}),NP(n,_);const N=w;return w=N$({inputs:{x:w},attrs:{shape:D},backend:n}),NP(n,N),[w,b]}};class kP{constructor(e,t,n,r,a,i){this.variableNames=["Image","Transforms"],this.outputShape=i;const s="nearest"===n?1:2;let o;switch(r){case"constant":default:o=1;break;case"reflect":o=2;break;case"wrap":o=3;break;case"nearest":o=4}this.userCode=`\n float mapCoord(float outCoord, float len) {\n float inCoord = outCoord;\n if(${o} == 2) {\n if (inCoord < 0.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz2 = 2.0 * len;\n if (inCoord < sz2) {\n inCoord = sz2 * float(int(float(-inCoord / sz2))) +\n inCoord;\n }\n inCoord = inCoord < -len ? inCoord + sz2 : -inCoord - 1.0;\n }\n } else if (inCoord > len - 1.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz2 = 2.0 * len;\n inCoord -= sz2 * float(int(float(inCoord / sz2)));\n if (inCoord >= len) {\n inCoord = sz2 - inCoord - 1.0;\n }\n }\n }\n return clamp(inCoord, 0.0, len - 1.0);\n } else if (${o} == 3) {\n if (inCoord < 0.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz = len - 1.0;\n inCoord += len * (float(int(float(-inCoord / sz))) + 1.0);\n }\n } else if (inCoord > len - 1.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz = len - 1.0;\n inCoord -= len * float(int(float(inCoord / sz)));\n }\n }\n return clamp(inCoord, 0.0, len - 1.0);\n } else if (${o} == 4) {\n return clamp(outCoord, 0.0, len - 1.0);\n } else {\n return outCoord;\n }\n }\n\n float readWithFillValue(int batch, int coordY, int coordX,\n int channel) {\n float outputValue;\n if (0 <= coordY && coordY < ${e} && 0 <= coordX && coordX < ${t}) {\n outputValue = getImage(batch, coordY, coordX, channel);\n } else {\n outputValue = float(${a});\n }\n return outputValue;\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n float outputValue;\n int batch = coords[0];\n int x = coords[2];\n int y = coords[1];\n int channel = coords[3];\n float xf = float(x);\n float yf = float(y);\n float a1 = getTransforms(batch, 0);\n float a2 = getTransforms(batch, 1);\n float a3 = getTransforms(batch, 2);\n float b1 = getTransforms(batch, 3);\n float b2 = getTransforms(batch, 4);\n float b3 = getTransforms(batch, 5);\n float c1 = getTransforms(batch, 6);\n float c2 = getTransforms(batch, 7);\n float projection = c1 * xf + c2 * yf + 1.0;\n if (projection == 0.0) {\n outputValue = float(${a});\n } else {\n float inX = (a1 * xf + a2 * yf + a3) / projection;\n float inY = (b1 * xf + b2 * yf + b3) / projection;\n float mapX = mapCoord(inX, float(${t}));\n float mapY = mapCoord(inY, float(${e}));\n\n if (${s} == 1) {\n int coordY = int(round(mapY));\n int coordX = int(round(mapX));\n outputValue = readWithFillValue(batch, coordY, coordX,\n channel);\n } else {\n float yFloor = floor(mapY);\n float xFloor = floor(mapX);\n float yCeil = yFloor + 1.0;\n float xCeil = xFloor + 1.0;\n float valueYFloor = (xCeil - mapX) *\n readWithFillValue(batch, int(yFloor), int(xFloor), channel) +\n (mapX - xFloor) *\n readWithFillValue(batch, int(yFloor), int(xCeil), channel);\n float valueYCeil = (xCeil - mapX) *\n readWithFillValue(batch, int(yCeil), int(xFloor), channel) +\n (mapX - xFloor) *\n readWithFillValue(batch, int(yCeil), int(xCeil), channel);\n outputValue = (yCeil - mapY) * valueYFloor +\n (mapY - yFloor) * valueYCeil;\n }\n }\n setOutput(outputValue);\n }\n `}}const TP={kernelName:Xr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{image:a,transforms:i}=t,{interpolation:s,fillMode:o,fillValue:u,outputShape:l}=r,[c,p,d,h]=a.shape,[f,m]=null!=l?l:[p,d],g=new kP(p,d,s,o,u,[c,f,m,h]);return n.runWebGLProgram(g,[a,i],"float32")}},CP={kernelName:Qr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,{axis:a}=n,{x:i}=t;mL(i,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");const s=r.readSync(i.dataId),{outputValues:o,outputShape:u,indices:l}=zF(s,a,i.shape,i.dtype);return[r.makeTensorInfo(u,i.dtype,o),r.makeTensorInfo([l.length],"int32",l)]}},EP={kernelName:ea,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{value:a}=t;let{axis:i}=r;i<0&&(i+=a.shape.length);const s=a,o=s.shape.length,u=a.shape[i],l=new Array(o-1);let c=0;for(let e=0;en.disposeIntermediateTensorInfo(e))),f}};class AP{constructor(e,t){this.variableNames=["x","segmentIds"];const n=e.windowSize,r=e.batchSize,a=e.inSize,i=e.numSegments,s=i*Math.ceil(a/n);this.outputShape=[r,s];const o=4*Math.floor(n/4),u=n%4,l="\n sumValue += dot(values, segFilter);\n ";let c="";a%n>0&&(c=`\n if (inIdx < 0 || inIdx >= ${a}) {\n return initializationValue;\n }\n `);let p="";a%n>0&&(p=`\n if (inIdx < 0 || inIdx >= ${a}) {\n return -1.0;\n }\n `),this.userCode=`\n const float initializationValue = 0.0;\n\n float getValue(int batch, int inIdx) {\n ${c}\n return getX(batch, inIdx);\n }\n\n float getSegmentIdAtIndex(int inIdx) {\n ${p}\n return getSegmentIds(inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = int(floor(float(outIdx) / float(\n ${i})) * float(${n}));\n int currentSeg = int(mod(float(outIdx), float(${i})));\n\n float sumValue = 0.0;\n\n for (int i = 0; i < ${o}; i += 4) {\n int inIdx = inOffset + i;\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 3)) == currentSeg ? 1 : 0\n );\n\n ${l}\n }\n\n int inIdx = inOffset + ${o};\n if (${1===u}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n int inIdxSeg = int(getSegmentIdAtIndex(inIdx));\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n 0,\n 0,\n 0\n );\n\n ${l}\n } else if (${2===u}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n initializationValue,\n initializationValue\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n 0,\n 0\n );\n\n ${l}\n } else if (${3===u}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n initializationValue\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,\n 0\n );\n\n ${l}\n }\n setOutput(sumValue);\n }\n `}}const IP={kernelName:ta,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,segmentIds:i}=t,{numSegments:s}=r,o=a.shape.length,u=[];let l=0;const c=vc([l],o);let p=a;null!=c&&(p=F$({inputs:{x:a},backend:n,attrs:{perm:c}}),u.push(p),l=_c(1,o)[0]);const d=Wf(p.shape,l,s),h=ce([p.shape[l]]),f=N$({inputs:{x:p},backend:n,attrs:{shape:[-1,h]}});u.push(f);const m=pi(a.dtype),g=(e,t,r,a,i)=>{const s=e.shape[0],o=e.shape[1],l=qf(o,i),c=new AP({windowSize:l,inSize:o,batchSize:s,numSegments:i},t),p=n.compileAndRun(c,[e,r],a);if(u.push(p),p.shape[1]===i)return p;const d=rz({backend:n,attrs:{start:0,stop:i,step:1,dtype:"float32"}}),h=xP({inputs:{x:d},backend:n,attrs:{reps:[o/l]}});return u.push(d),u.push(h),g(p,t,h,a,i)},y=N$({inputs:{x:g(f,"unsortedSegmentSum",i,m,s)},backend:n,attrs:{shape:d}});let b=y;if(null!=c){u.push(y);const e=xc(c);b=F$({inputs:{x:b},backend:n,attrs:{perm:e}})}return u.forEach((e=>n.disposeIntermediateTensorInfo(e))),b}},LP=[R$,B$,P$,j$,W$,K$,J$,X$,rO,aO,sO,uO,cO,dO,fO,yO,bO,_O,wO,DO,SO,IO,LO,FO,BO,HO,qO,l$,GO,nR,lR,fR,mR,gR,yR,bR,xR,wR,NR,ER,AR,IR,FR,RR,zR,PR,jR,qR,WR,GR,KR,XR,QR,tY,rY,sY,lY,dY,fY,yY,vY,wY,NY,MY,kY,EY,IY,FY,o$,$Y,QO,RY,BY,PY,d$,jY,qY,WY,GY,JY,ZY,eB,nB,iB,oB,lB,pB,dB,hB,gB,yB,bB,vB,xB,wB,MB,kB,OB,D$,RB,BB,PB,jB,OO,qB,GB,KB,QB,tz,m$,nz,az,YO,EB,sz,uz,cz,M$,hz,mz,bz,xz,Dz,Mz,kz,Cz,Az,Lz,$z,Rz,Bz,Pz,jz,qz,AO,$B,Vz,Gz,Kz,Jz,Xz,Zz,Qz,eP,rP,iP,uP,lP,pP,dP,hP,fP,LB,L$,gP,bP,_P,SP,TP,$$,CP,EP,IP,VB];for(const e of LP)ya(e);const FP={"tfjs-core":_u,"tfjs-backend-cpu":"3.19.0","tfjs-backend-webgl":"3.19.0","tfjs-data":MS,"tfjs-layers":zv,"tfjs-converter":bM,tfjs:"3.19.0"};function $P(){return $P=Object.assign?Object.assign.bind():function(e){for(var t=1;te[t]))}var LH=["Matrix","Array"],FH=["number","BigNumber","Fraction"];function $H(e,t){function n(n){if(n){var r=NH(e,DH);OH(n,"matrix",LH),OH(n,"number",FH),SH(e,n);var a=NH(e,DH),i=NH(n,DH);return t("config",a,r,i),a}return NH(e,DH)}return n.MATRIX_OPTIONS=LH,n.NUMBER_OPTIONS=FH,Object.keys(OP).forEach((t=>{Object.defineProperty(n,t,{get:()=>e[t],enumerable:!0,configurable:!0})})),n}function OH(e,t,n){void 0===e[t]||function(e,t){return-1!==e.indexOf(t)}(n,e[t])||console.warn('Warning: Unknown value "'+e[t]+'" for configuration option "'+t+'". Available options: '+n.map((e=>JSON.stringify(e))).join(", ")+".")}var RH=function(e){if(e)throw new Error("The global config is readonly. \nPlease create a mathjs instance if you want to change the default configuration. \nExample:\n\n import { create, all } from 'mathjs';\n const mathjs = create(all);\n mathjs.config({ number: 'BigNumber' });\n");return Object.freeze(OP)};$P(RH,OP,{MATRIX_OPTIONS:LH,NUMBER_OPTIONS:FH});var YH,BH,zH=9e15,PH=1e9,HH="0123456789abcdef",jH="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",UH="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",qH={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-zH,maxE:zH,crypto:!1},WH=!0,VH="[DecimalError] ",GH=VH+"Invalid argument: ",KH=VH+"Precision limit exceeded",JH=VH+"crypto unavailable",XH="[object Decimal]",ZH=Math.floor,QH=Math.pow,ej=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,tj=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,nj=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,rj=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,aj=1e7,ij=jH.length-1,sj=UH.length-1,oj={toStringTag:XH};function uj(e){var t,n,r,a=e.length-1,i="",s=e[0];if(a>0){for(i+=s,t=1;tn)throw Error(GH+e)}function cj(e,t,n,r){var a,i,s,o;for(i=e[0];i>=10;i/=10)--t;return--t<0?(t+=7,a=0):(a=Math.ceil((t+1)/7),t%=7),i=QH(10,7-t),o=e[a]%i|0,null==r?t<3?(0==t?o=o/100|0:1==t&&(o=o/10|0),s=n<4&&99999==o||n>3&&49999==o||5e4==o||0==o):s=(n<4&&o+1==i||n>3&&o+1==i/2)&&(e[a+1]/i/100|0)==QH(10,t-2)-1||(o==i/2||0==o)&&0==(e[a+1]/i/100|0):t<4?(0==t?o=o/1e3|0:1==t?o=o/100|0:2==t&&(o=o/10|0),s=(r||n<4)&&9999==o||!r&&n>3&&4999==o):s=((r||n<4)&&o+1==i||!r&&n>3&&o+1==i/2)&&(e[a+1]/i/1e3|0)==QH(10,t-3)-1,s}function pj(e,t,n){for(var r,a,i=[0],s=0,o=e.length;sn-1&&(void 0===i[r+1]&&(i[r+1]=0),i[r+1]+=i[r]/n|0,i[r]%=n)}return i.reverse()}oj.absoluteValue=oj.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),hj(e)},oj.ceil=function(){return hj(new this.constructor(this),this.e+1,2)},oj.clampedTo=oj.clamp=function(e,t){var n=this,r=n.constructor;if(e=new r(e),t=new r(t),!e.s||!t.s)return new r(NaN);if(e.gt(t))throw Error(GH+t);return n.cmp(e)<0?e:n.cmp(t)>0?t:new r(n)},oj.comparedTo=oj.cmp=function(e){var t,n,r,a,i=this,s=i.d,o=(e=new i.constructor(e)).d,u=i.s,l=e.s;if(!s||!o)return u&&l?u!==l?u:s===o?0:!s^u<0?1:-1:NaN;if(!s[0]||!o[0])return s[0]?u:o[0]?-l:0;if(u!==l)return u;if(i.e!==e.e)return i.e>e.e^u<0?1:-1;for(t=0,n=(r=s.length)<(a=o.length)?r:a;to[t]^u<0?1:-1;return r===a?0:r>a^u<0?1:-1},oj.cosine=oj.cos=function(){var e,t,n=this,r=n.constructor;return n.d?n.d[0]?(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+7,r.rounding=1,n=function(e,t){var n,r,a;if(t.isZero())return t;(r=t.d.length)<32?a=(1/Cj(4,n=Math.ceil(r/3))).toString():(n=16,a="2.3283064365386962890625e-10"),e.precision+=n,t=Tj(e,1,t.times(a),new e(1));for(var i=n;i--;){var s=t.times(t);t=s.times(s).minus(s).times(8).plus(1)}return e.precision-=n,t}(r,Ej(r,n)),r.precision=e,r.rounding=t,hj(2==BH||3==BH?n.neg():n,e,t,!0)):new r(1):new r(NaN)},oj.cubeRoot=oj.cbrt=function(){var e,t,n,r,a,i,s,o,u,l,c=this,p=c.constructor;if(!c.isFinite()||c.isZero())return new p(c);for(WH=!1,(i=c.s*QH(c.s*c,1/3))&&Math.abs(i)!=1/0?r=new p(i.toString()):(n=uj(c.d),(i=((e=c.e)-n.length+1)%3)&&(n+=1==i||-2==i?"0":"00"),i=QH(n,1/3),e=ZH((e+1)/3)-(e%3==(e<0?-1:2)),(r=new p(n=i==1/0?"5e"+e:(n=i.toExponential()).slice(0,n.indexOf("e")+1)+e)).s=c.s),s=(e=p.precision)+3;;)if(l=(u=(o=r).times(o).times(o)).plus(c),r=dj(l.plus(c).times(o),l.plus(u),s+2,1),uj(o.d).slice(0,s)===(n=uj(r.d)).slice(0,s)){if("9999"!=(n=n.slice(s-3,s+1))&&(a||"4999"!=n)){+n&&(+n.slice(1)||"5"!=n.charAt(0))||(hj(r,e+1,1),t=!r.times(r).times(r).eq(c));break}if(!a&&(hj(o,e+1,0),o.times(o).times(o).eq(c))){r=o;break}s+=4,a=1}return WH=!0,hj(r,e,p.rounding,t)},oj.decimalPlaces=oj.dp=function(){var e,t=this.d,n=NaN;if(t){if(n=7*((e=t.length-1)-ZH(this.e/7)),e=t[e])for(;e%10==0;e/=10)n--;n<0&&(n=0)}return n},oj.dividedBy=oj.div=function(e){return dj(this,new this.constructor(e))},oj.dividedToIntegerBy=oj.divToInt=function(e){var t=this.constructor;return hj(dj(this,new t(e),0,1,1),t.precision,t.rounding)},oj.equals=oj.eq=function(e){return 0===this.cmp(e)},oj.floor=function(){return hj(new this.constructor(this),this.e+1,3)},oj.greaterThan=oj.gt=function(e){return this.cmp(e)>0},oj.greaterThanOrEqualTo=oj.gte=function(e){var t=this.cmp(e);return 1==t||0===t},oj.hyperbolicCosine=oj.cosh=function(){var e,t,n,r,a,i=this,s=i.constructor,o=new s(1);if(!i.isFinite())return new s(i.s?1/0:NaN);if(i.isZero())return o;n=s.precision,r=s.rounding,s.precision=n+Math.max(i.e,i.sd())+4,s.rounding=1,(a=i.d.length)<32?t=(1/Cj(4,e=Math.ceil(a/3))).toString():(e=16,t="2.3283064365386962890625e-10"),i=Tj(s,1,i.times(t),new s(1),!0);for(var u,l=e,c=new s(8);l--;)u=i.times(i),i=o.minus(u.times(c.minus(u.times(c))));return hj(i,s.precision=n,s.rounding=r,!0)},oj.hyperbolicSine=oj.sinh=function(){var e,t,n,r,a=this,i=a.constructor;if(!a.isFinite()||a.isZero())return new i(a);if(t=i.precision,n=i.rounding,i.precision=t+Math.max(a.e,a.sd())+4,i.rounding=1,(r=a.d.length)<3)a=Tj(i,2,a,a,!0);else{e=(e=1.4*Math.sqrt(r))>16?16:0|e,a=Tj(i,2,a=a.times(1/Cj(5,e)),a,!0);for(var s,o=new i(5),u=new i(16),l=new i(20);e--;)s=a.times(a),a=a.times(o.plus(s.times(u.times(s).plus(l))))}return i.precision=t,i.rounding=n,hj(a,t,n,!0)},oj.hyperbolicTangent=oj.tanh=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+7,r.rounding=1,dj(n.sinh(),n.cosh(),r.precision=e,r.rounding=t)):new r(n.s)},oj.inverseCosine=oj.acos=function(){var e,t=this,n=t.constructor,r=t.abs().cmp(1),a=n.precision,i=n.rounding;return-1!==r?0===r?t.isNeg()?yj(n,a,i):new n(0):new n(NaN):t.isZero()?yj(n,a+4,i).times(.5):(n.precision=a+6,n.rounding=1,t=t.asin(),e=yj(n,a+4,i).times(.5),n.precision=a,n.rounding=i,e.minus(t))},oj.inverseHyperbolicCosine=oj.acosh=function(){var e,t,n=this,r=n.constructor;return n.lte(1)?new r(n.eq(1)?0:NaN):n.isFinite()?(e=r.precision,t=r.rounding,r.precision=e+Math.max(Math.abs(n.e),n.sd())+4,r.rounding=1,WH=!1,n=n.times(n).minus(1).sqrt().plus(n),WH=!0,r.precision=e,r.rounding=t,n.ln()):new r(n)},oj.inverseHyperbolicSine=oj.asinh=function(){var e,t,n=this,r=n.constructor;return!n.isFinite()||n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+2*Math.max(Math.abs(n.e),n.sd())+6,r.rounding=1,WH=!1,n=n.times(n).plus(1).sqrt().plus(n),WH=!0,r.precision=e,r.rounding=t,n.ln())},oj.inverseHyperbolicTangent=oj.atanh=function(){var e,t,n,r,a=this,i=a.constructor;return a.isFinite()?a.e>=0?new i(a.abs().eq(1)?a.s/0:a.isZero()?a:NaN):(e=i.precision,t=i.rounding,r=a.sd(),Math.max(r,e)<2*-a.e-1?hj(new i(a),e,t,!0):(i.precision=n=r-a.e,a=dj(a.plus(1),new i(1).minus(a),n+e,1),i.precision=e+4,i.rounding=1,a=a.ln(),i.precision=e,i.rounding=t,a.times(.5))):new i(NaN)},oj.inverseSine=oj.asin=function(){var e,t,n,r,a=this,i=a.constructor;return a.isZero()?new i(a):(t=a.abs().cmp(1),n=i.precision,r=i.rounding,-1!==t?0===t?((e=yj(i,n+4,r).times(.5)).s=a.s,e):new i(NaN):(i.precision=n+6,i.rounding=1,a=a.div(new i(1).minus(a.times(a)).sqrt().plus(1)).atan(),i.precision=n,i.rounding=r,a.times(2)))},oj.inverseTangent=oj.atan=function(){var e,t,n,r,a,i,s,o,u,l=this,c=l.constructor,p=c.precision,d=c.rounding;if(l.isFinite()){if(l.isZero())return new c(l);if(l.abs().eq(1)&&p+4<=sj)return(s=yj(c,p+4,d).times(.25)).s=l.s,s}else{if(!l.s)return new c(NaN);if(p+4<=sj)return(s=yj(c,p+4,d).times(.5)).s=l.s,s}for(c.precision=o=p+10,c.rounding=1,e=n=Math.min(28,o/7+2|0);e;--e)l=l.div(l.times(l).plus(1).sqrt().plus(1));for(WH=!1,t=Math.ceil(o/7),r=1,u=l.times(l),s=new c(l),a=l;-1!==e;)if(a=a.times(u),i=s.minus(a.div(r+=2)),a=a.times(u),void 0!==(s=i.plus(a.div(r+=2))).d[t])for(e=t;s.d[e]===i.d[e]&&e--;);return n&&(s=s.times(2<this.d.length-2},oj.isNaN=function(){return!this.s},oj.isNegative=oj.isNeg=function(){return this.s<0},oj.isPositive=oj.isPos=function(){return this.s>0},oj.isZero=function(){return!!this.d&&0===this.d[0]},oj.lessThan=oj.lt=function(e){return this.cmp(e)<0},oj.lessThanOrEqualTo=oj.lte=function(e){return this.cmp(e)<1},oj.logarithm=oj.log=function(e){var t,n,r,a,i,s,o,u,l=this,c=l.constructor,p=c.precision,d=c.rounding;if(null==e)e=new c(10),t=!0;else{if(n=(e=new c(e)).d,e.s<0||!n||!n[0]||e.eq(1))return new c(NaN);t=e.eq(10)}if(n=l.d,l.s<0||!n||!n[0]||l.eq(1))return new c(n&&!n[0]?-1/0:1!=l.s?NaN:n?0:1/0);if(t)if(n.length>1)i=!0;else{for(a=n[0];a%10==0;)a/=10;i=1!==a}if(WH=!1,s=Nj(l,o=p+5),r=t?gj(c,o+10):Nj(e,o),cj((u=dj(s,r,o,1)).d,a=p,d))do{if(s=Nj(l,o+=10),r=t?gj(c,o+10):Nj(e,o),u=dj(s,r,o,1),!i){+uj(u.d).slice(a+1,a+15)+1==1e14&&(u=hj(u,p+1,0));break}}while(cj(u.d,a+=10,d));return WH=!0,hj(u,p,d)},oj.minus=oj.sub=function(e){var t,n,r,a,i,s,o,u,l,c,p,d,h=this,f=h.constructor;if(e=new f(e),!h.d||!e.d)return h.s&&e.s?h.d?e.s=-e.s:e=new f(e.d||h.s!==e.s?h:NaN):e=new f(NaN),e;if(h.s!=e.s)return e.s=-e.s,h.plus(e);if(l=h.d,d=e.d,o=f.precision,u=f.rounding,!l[0]||!d[0]){if(d[0])e.s=-e.s;else{if(!l[0])return new f(3===u?-0:0);e=new f(h)}return WH?hj(e,o,u):e}if(n=ZH(e.e/7),c=ZH(h.e/7),l=l.slice(),i=c-n){for((p=i<0)?(t=l,i=-i,s=d.length):(t=d,n=c,s=l.length),i>(r=Math.max(Math.ceil(o/7),s)+2)&&(i=r,t.length=1),t.reverse(),r=i;r--;)t.push(0);t.reverse()}else{for((p=(r=l.length)<(s=d.length))&&(s=r),r=0;r0;--r)l[s++]=0;for(r=d.length;r>i;){if(l[--r](s=(i=Math.ceil(o/7))>s?i+1:s+1)&&(a=s,n.length=1),n.reverse();a--;)n.push(0);n.reverse()}for((s=l.length)-(a=c.length)<0&&(a=s,n=c,c=l,l=n),t=0;a;)t=(l[--a]=l[a]+c[a]+t)/aj|0,l[a]%=aj;for(t&&(l.unshift(t),++r),s=l.length;0==l[--s];)l.pop();return e.d=l,e.e=mj(l,r),WH?hj(e,o,u):e},oj.precision=oj.sd=function(e){var t,n=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(GH+e);return n.d?(t=bj(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t},oj.round=function(){var e=this,t=e.constructor;return hj(new t(e),e.e+1,t.rounding)},oj.sine=oj.sin=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+7,r.rounding=1,n=function(e,t){var n,r=t.d.length;if(r<3)return t.isZero()?t:Tj(e,2,t,t);n=(n=1.4*Math.sqrt(r))>16?16:0|n,t=Tj(e,2,t=t.times(1/Cj(5,n)),t);for(var a,i=new e(5),s=new e(16),o=new e(20);n--;)a=t.times(t),t=t.times(i.plus(a.times(s.times(a).minus(o))));return t}(r,Ej(r,n)),r.precision=e,r.rounding=t,hj(BH>2?n.neg():n,e,t,!0)):new r(NaN)},oj.squareRoot=oj.sqrt=function(){var e,t,n,r,a,i,s=this,o=s.d,u=s.e,l=s.s,c=s.constructor;if(1!==l||!o||!o[0])return new c(!l||l<0&&(!o||o[0])?NaN:o?s:1/0);for(WH=!1,0==(l=Math.sqrt(+s))||l==1/0?(((t=uj(o)).length+u)%2==0&&(t+="0"),l=Math.sqrt(t),u=ZH((u+1)/2)-(u<0||u%2),r=new c(t=l==1/0?"5e"+u:(t=l.toExponential()).slice(0,t.indexOf("e")+1)+u)):r=new c(l.toString()),n=(u=c.precision)+3;;)if(r=(i=r).plus(dj(s,i,n+2,1)).times(.5),uj(i.d).slice(0,n)===(t=uj(r.d)).slice(0,n)){if("9999"!=(t=t.slice(n-3,n+1))&&(a||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(hj(r,u+1,1),e=!r.times(r).eq(s));break}if(!a&&(hj(i,u+1,0),i.times(i).eq(s))){r=i;break}n+=4,a=1}return WH=!0,hj(r,u,c.rounding,e)},oj.tangent=oj.tan=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+10,r.rounding=1,(n=n.sin()).s=1,n=dj(n,new r(1).minus(n.times(n)).sqrt(),e+10,0),r.precision=e,r.rounding=t,hj(2==BH||4==BH?n.neg():n,e,t,!0)):new r(NaN)},oj.times=oj.mul=function(e){var t,n,r,a,i,s,o,u,l,c=this,p=c.constructor,d=c.d,h=(e=new p(e)).d;if(e.s*=c.s,!(d&&d[0]&&h&&h[0]))return new p(!e.s||d&&!d[0]&&!h||h&&!h[0]&&!d?NaN:d&&h?0*e.s:e.s/0);for(n=ZH(c.e/7)+ZH(e.e/7),(u=d.length)<(l=h.length)&&(i=d,d=h,h=i,s=u,u=l,l=s),i=[],r=s=u+l;r--;)i.push(0);for(r=l;--r>=0;){for(t=0,a=u+r;a>r;)o=i[a]+h[r]*d[a-r-1]+t,i[a--]=o%aj|0,t=o/aj|0;i[a]=(i[a]+t)%aj|0}for(;!i[--s];)i.pop();return t?++n:i.shift(),e.d=i,e.e=mj(i,n),WH?hj(e,p.precision,p.rounding):e},oj.toBinary=function(e,t){return Aj(this,2,e,t)},oj.toDecimalPlaces=oj.toDP=function(e,t){var n=this,r=n.constructor;return n=new r(n),void 0===e?n:(lj(e,0,PH),void 0===t?t=r.rounding:lj(t,0,8),hj(n,e+n.e+1,t))},oj.toExponential=function(e,t){var n,r=this,a=r.constructor;return void 0===e?n=fj(r,!0):(lj(e,0,PH),void 0===t?t=a.rounding:lj(t,0,8),n=fj(r=hj(new a(r),e+1,t),!0,e+1)),r.isNeg()&&!r.isZero()?"-"+n:n},oj.toFixed=function(e,t){var n,r,a=this,i=a.constructor;return void 0===e?n=fj(a):(lj(e,0,PH),void 0===t?t=i.rounding:lj(t,0,8),n=fj(r=hj(new i(a),e+a.e+1,t),!1,e+r.e+1)),a.isNeg()&&!a.isZero()?"-"+n:n},oj.toFraction=function(e){var t,n,r,a,i,s,o,u,l,c,p,d,h=this,f=h.d,m=h.constructor;if(!f)return new m(h);if(l=n=new m(1),r=u=new m(0),s=(i=(t=new m(r)).e=bj(f)-h.e-1)%7,t.d[0]=QH(10,s<0?7+s:s),null==e)e=i>0?t:l;else{if(!(o=new m(e)).isInt()||o.lt(l))throw Error(GH+o);e=o.gt(t)?i>0?t:l:o}for(WH=!1,o=new m(uj(f)),c=m.precision,m.precision=i=7*f.length*2;p=dj(o,t,0,1,1),1!=(a=n.plus(p.times(r))).cmp(e);)n=r,r=a,a=l,l=u.plus(p.times(a)),u=a,a=t,t=o.minus(p.times(a)),o=a;return a=dj(e.minus(n),r,0,1,1),u=u.plus(a.times(l)),n=n.plus(a.times(r)),u.s=l.s=h.s,d=dj(l,r,i,1).minus(h).abs().cmp(dj(u,n,i,1).minus(h).abs())<1?[l,r]:[u,n],m.precision=c,WH=!0,d},oj.toHexadecimal=oj.toHex=function(e,t){return Aj(this,16,e,t)},oj.toNearest=function(e,t){var n=this,r=n.constructor;if(n=new r(n),null==e){if(!n.d)return n;e=new r(1),t=r.rounding}else{if(e=new r(e),void 0===t?t=r.rounding:lj(t,0,8),!n.d)return e.s?n:e;if(!e.d)return e.s&&(e.s=n.s),e}return e.d[0]?(WH=!1,n=dj(n,e,0,t,1).times(e),WH=!0,hj(n)):(e.s=n.s,n=e),n},oj.toNumber=function(){return+this},oj.toOctal=function(e,t){return Aj(this,8,e,t)},oj.toPower=oj.pow=function(e){var t,n,r,a,i,s,o=this,u=o.constructor,l=+(e=new u(e));if(!(o.d&&e.d&&o.d[0]&&e.d[0]))return new u(QH(+o,l));if((o=new u(o)).eq(1))return o;if(r=u.precision,i=u.rounding,e.eq(1))return hj(o,r,i);if((t=ZH(e.e/7))>=e.d.length-1&&(n=l<0?-l:l)<=9007199254740991)return a=xj(u,o,n,r),e.s<0?new u(1).div(a):hj(a,r,i);if((s=o.s)<0){if(tu.maxE+1||t0?s/0:0):(WH=!1,u.rounding=o.s=1,n=Math.min(12,(t+"").length),(a=Dj(e.times(Nj(o,r+n)),r)).d&&cj((a=hj(a,r+5,1)).d,r,i)&&(t=r+10,+uj((a=hj(Dj(e.times(Nj(o,t+n)),t),t+5,1)).d).slice(r+1,r+15)+1==1e14&&(a=hj(a,r+1,0))),a.s=s,WH=!0,u.rounding=i,hj(a,r,i))},oj.toPrecision=function(e,t){var n,r=this,a=r.constructor;return void 0===e?n=fj(r,r.e<=a.toExpNeg||r.e>=a.toExpPos):(lj(e,1,PH),void 0===t?t=a.rounding:lj(t,0,8),n=fj(r=hj(new a(r),e,t),e<=r.e||r.e<=a.toExpNeg,e)),r.isNeg()&&!r.isZero()?"-"+n:n},oj.toSignificantDigits=oj.toSD=function(e,t){var n=this.constructor;return void 0===e?(e=n.precision,t=n.rounding):(lj(e,1,PH),void 0===t?t=n.rounding:lj(t,0,8)),hj(new n(this),e,t)},oj.toString=function(){var e=this,t=e.constructor,n=fj(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+n:n},oj.truncated=oj.trunc=function(){return hj(new this.constructor(this),this.e+1,1)},oj.valueOf=oj.toJSON=function(){var e=this,t=e.constructor,n=fj(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+n:n};var dj=function(){function e(e,t,n){var r,a=0,i=e.length;for(e=e.slice();i--;)r=e[i]*t+a,e[i]=r%n|0,a=r/n|0;return a&&e.unshift(a),e}function t(e,t,n,r){var a,i;if(n!=r)i=n>r?1:-1;else for(a=i=0;at[a]?1:-1;break}return i}function n(e,t,n,r){for(var a=0;n--;)e[n]-=a,a=e[n]1;)e.shift()}return function(r,a,i,s,o,u){var l,c,p,d,h,f,m,g,y,b,v,x,_,w,D,N,M,S,k,T,C=r.constructor,E=r.s==a.s?1:-1,A=r.d,I=a.d;if(!(A&&A[0]&&I&&I[0]))return new C(r.s&&a.s&&(A?!I||A[0]!=I[0]:I)?A&&0==A[0]||!I?0*E:E/0:NaN);for(u?(h=1,c=r.e-a.e):(u=aj,h=7,c=ZH(r.e/h)-ZH(a.e/h)),k=I.length,M=A.length,b=(y=new C(E)).d=[],p=0;I[p]==(A[p]||0);p++);if(I[p]>(A[p]||0)&&c--,null==i?(w=i=C.precision,s=C.rounding):w=o?i+(r.e-a.e)+1:i,w<0)b.push(1),f=!0;else{if(w=w/h+2|0,p=0,1==k){for(d=0,I=I[0],w++;(p1&&(I=e(I,d,u),A=e(A,d,u),k=I.length,M=A.length),N=k,x=(v=A.slice(0,k)).length;x=u/2&&++S;do{d=0,(l=t(I,v,k,x))<0?(_=v[0],k!=x&&(_=_*u+(v[1]||0)),(d=_/S|0)>1?(d>=u&&(d=u-1),1==(l=t(m=e(I,d,u),v,g=m.length,x=v.length))&&(d--,n(m,k=10;d/=10)p++;y.e=p+c*h-1,hj(y,o?i+y.e+1:i,s,f)}return y}}();function hj(e,t,n,r){var a,i,s,o,u,l,c,p,d,h=e.constructor;e:if(null!=t){if(!(p=e.d))return e;for(a=1,o=p[0];o>=10;o/=10)a++;if((i=t-a)<0)i+=7,s=t,u=(c=p[d=0])/QH(10,a-s-1)%10|0;else if((d=Math.ceil((i+1)/7))>=(o=p.length)){if(!r)break e;for(;o++<=d;)p.push(0);c=u=0,a=1,s=(i%=7)-7+1}else{for(c=o=p[d],a=1;o>=10;o/=10)a++;u=(s=(i%=7)-7+a)<0?0:c/QH(10,a-s-1)%10|0}if(r=r||t<0||void 0!==p[d+1]||(s<0?c:c%QH(10,a-s-1)),l=n<4?(u||r)&&(0==n||n==(e.s<0?3:2)):u>5||5==u&&(4==n||r||6==n&&(i>0?s>0?c/QH(10,a-s):0:p[d-1])%10&1||n==(e.s<0?8:7)),t<1||!p[0])return p.length=0,l?(t-=e.e+1,p[0]=QH(10,(7-t%7)%7),e.e=-t||0):p[0]=e.e=0,e;if(0==i?(p.length=d,o=1,d--):(p.length=d+1,o=QH(10,7-i),p[d]=s>0?(c/QH(10,a-s)%QH(10,s)|0)*o:0),l)for(;;){if(0==d){for(i=1,s=p[0];s>=10;s/=10)i++;for(s=p[0]+=o,o=1;s>=10;s/=10)o++;i!=o&&(e.e++,p[0]==aj&&(p[0]=1));break}if(p[d]+=o,p[d]!=aj)break;p[d--]=0,o=1}for(i=p.length;0===p[--i];)p.pop()}return WH&&(e.e>h.maxE?(e.d=null,e.e=NaN):e.e0?i=i.charAt(0)+"."+i.slice(1)+vj(r):s>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(e.e<0?"e":"e+")+e.e):a<0?(i="0."+vj(-a-1)+i,n&&(r=n-s)>0&&(i+=vj(r))):a>=s?(i+=vj(a+1-s),n&&(r=n-a-1)>0&&(i=i+"."+vj(r))):((r=a+1)0&&(a+1===s&&(i+="."),i+=vj(r))),i}function mj(e,t){var n=e[0];for(t*=7;n>=10;n/=10)t++;return t}function gj(e,t,n){if(t>ij)throw WH=!0,n&&(e.precision=n),Error(KH);return hj(new e(jH),t,1,!0)}function yj(e,t,n){if(t>sj)throw Error(KH);return hj(new e(UH),t,n,!0)}function bj(e){var t=e.length-1,n=7*t+1;if(t=e[t]){for(;t%10==0;t/=10)n--;for(t=e[0];t>=10;t/=10)n++}return n}function vj(e){for(var t="";e--;)t+="0";return t}function xj(e,t,n,r){var a,i=new e(1),s=Math.ceil(r/7+4);for(WH=!1;;){if(n%2&&Ij((i=i.times(t)).d,s)&&(a=!0),0===(n=ZH(n/2))){n=i.d.length-1,a&&0===i.d[n]&&++i.d[n];break}Ij((t=t.times(t)).d,s)}return WH=!0,i}function _j(e){return 1&e.d[e.d.length-1]}function wj(e,t,n){for(var r,a=new e(t[0]),i=0;++i17)return new d(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(null==t?(WH=!1,u=f):u=t,o=new d(.03125);e.e>-2;)e=e.times(o),p+=5;for(u+=r=Math.log(QH(2,p))/Math.LN10*2+5|0,n=i=s=new d(1),d.precision=u;;){if(i=hj(i.times(e),u,1),n=n.times(++c),uj((o=s.plus(dj(i,n,u,1))).d).slice(0,u)===uj(s.d).slice(0,u)){for(a=p;a--;)s=hj(s.times(s),u,1);if(null!=t)return d.precision=f,s;if(!(l<3&&cj(s.d,u-r,h,l)))return hj(s,d.precision=f,h,WH=!0);d.precision=u+=10,n=i=o=new d(1),c=0,l++}s=o}}function Nj(e,t){var n,r,a,i,s,o,u,l,c,p,d,h=1,f=e,m=f.d,g=f.constructor,y=g.rounding,b=g.precision;if(f.s<0||!m||!m[0]||!f.e&&1==m[0]&&1==m.length)return new g(m&&!m[0]?-1/0:1!=f.s?NaN:m?0:f);if(null==t?(WH=!1,c=b):c=t,g.precision=c+=10,r=(n=uj(m)).charAt(0),!(Math.abs(i=f.e)<15e14))return l=gj(g,c+2,b).times(i+""),f=Nj(new g(r+"."+n.slice(1)),c-10).plus(l),g.precision=b,null==t?hj(f,b,y,WH=!0):f;for(;r<7&&1!=r||1==r&&n.charAt(1)>3;)r=(n=uj((f=f.times(e)).d)).charAt(0),h++;for(i=f.e,r>1?(f=new g("0."+n),i++):f=new g(r+"."+n.slice(1)),p=f,u=s=f=dj(f.minus(1),f.plus(1),c,1),d=hj(f.times(f),c,1),a=3;;){if(s=hj(s.times(d),c,1),uj((l=u.plus(dj(s,new g(a),c,1))).d).slice(0,c)===uj(u.d).slice(0,c)){if(u=u.times(2),0!==i&&(u=u.plus(gj(g,c+2,b).times(i+""))),u=dj(u,new g(h),c,1),null!=t)return g.precision=b,u;if(!cj(u.d,c-10,y,o))return hj(u,g.precision=b,y,WH=!0);g.precision=c+=10,l=s=f=dj(p.minus(1),p.plus(1),c,1),d=hj(f.times(f),c,1),a=o=1}u=l,a+=2}}function Mj(e){return String(e.s*e.s/0)}function Sj(e,t){var n,r,a;for((n=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;48===t.charCodeAt(r);r++);for(a=t.length;48===t.charCodeAt(a-1);--a);if(t=t.slice(r,a)){if(a-=r,e.e=n=n-r-1,e.d=[],r=(n+1)%7,n<0&&(r+=7),re.constructor.maxE?(e.d=null,e.e=NaN):e.e-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),rj.test(t))return Sj(e,t)}else if("Infinity"===t||"NaN"===t)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(tj.test(t))n=16,t=t.toLowerCase();else if(ej.test(t))n=2;else{if(!nj.test(t))throw Error(GH+t);n=8}for((i=t.search(/p/i))>0?(u=+t.slice(i+1),t=t.substring(2,i)):t=t.slice(2),s=(i=t.indexOf("."))>=0,r=e.constructor,s&&(i=(o=(t=t.replace(".","")).length)-i,a=xj(r,new r(n),i,2*i)),i=c=(l=pj(t,n,aj)).length-1;0===l[i];--i)l.pop();return i<0?new r(0*e.s):(e.e=mj(l,c),e.d=l,WH=!1,s&&(e=dj(e,a,4*o)),u&&(e=e.times(Math.abs(u)<54?QH(2,u):vU.pow(2,u))),WH=!0,e)}function Tj(e,t,n,r,a){var i,s,o,u,l=e.precision,c=Math.ceil(l/7);for(WH=!1,u=n.times(n),o=new e(r);;){if(s=dj(o.times(u),new e(t++*t++),l,1),o=a?r.plus(s):r.minus(s),r=dj(s.times(u),new e(t++*t++),l,1),void 0!==(s=o.plus(r)).d[c]){for(i=c;s.d[i]===o.d[i]&&i--;);if(-1==i)break}i=o,o=r,r=s,s=i}return WH=!0,s.d.length=c+1,s}function Cj(e,t){for(var n=e;--t;)n*=e;return n}function Ej(e,t){var n,r=t.s<0,a=yj(e,e.precision,1),i=a.times(.5);if((t=t.abs()).lte(i))return BH=r?4:1,t;if((n=t.divToInt(a)).isZero())BH=r?3:2;else{if((t=t.minus(n.times(a))).lte(i))return BH=_j(n)?r?2:3:r?4:1,t;BH=_j(n)?r?1:4:r?3:2}return t.minus(a).abs()}function Aj(e,t,n,r){var a,i,s,o,u,l,c,p,d,h=e.constructor,f=void 0!==n;if(f?(lj(n,1,PH),void 0===r?r=h.rounding:lj(r,0,8)):(n=h.precision,r=h.rounding),e.isFinite()){for(f?(a=2,16==t?n=4*n-3:8==t&&(n=3*n-2)):a=t,(s=(c=fj(e)).indexOf("."))>=0&&(c=c.replace(".",""),(d=new h(1)).e=c.length-s,d.d=pj(fj(d),10,a),d.e=d.d.length),i=u=(p=pj(c,10,a)).length;0==p[--u];)p.pop();if(p[0]){if(s<0?i--:((e=new h(e)).d=p,e.e=i,p=(e=dj(e,d,n,r,0,a)).d,i=e.e,l=YH),s=p[n],o=a/2,l=l||void 0!==p[n+1],l=r<4?(void 0!==s||l)&&(0===r||r===(e.s<0?3:2)):s>o||s===o&&(4===r||l||6===r&&1&p[n-1]||r===(e.s<0?8:7)),p.length=n,l)for(;++p[--n]>a-1;)p[n]=0,n||(++i,p.unshift(1));for(u=p.length;!p[u-1];--u);for(s=0,c="";s1)if(16==t||8==t){for(s=16==t?4:3,--u;u%s;u++)c+="0";for(u=(p=pj(c,a,t)).length;!p[u-1];--u);for(s=1,c="1.";su)for(i-=u;i--;)c+="0";else it)return e.length=t,!0}function Lj(e){return new this(e).abs()}function Fj(e){return new this(e).acos()}function $j(e){return new this(e).acosh()}function Oj(e,t){return new this(e).plus(t)}function Rj(e){return new this(e).asin()}function Yj(e){return new this(e).asinh()}function Bj(e){return new this(e).atan()}function zj(e){return new this(e).atanh()}function Pj(e,t){e=new this(e),t=new this(t);var n,r=this.precision,a=this.rounding,i=r+4;return e.s&&t.s?e.d||t.d?!t.d||e.isZero()?(n=t.s<0?yj(this,r,a):new this(0)).s=e.s:!e.d||t.isZero()?(n=yj(this,i,1).times(.5)).s=e.s:t.s<0?(this.precision=i,this.rounding=1,n=this.atan(dj(e,t,i,1)),t=yj(this,i,1),this.precision=r,this.rounding=a,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan(dj(e,t,i,1)):(n=yj(this,i,1).times(t.s>0?.25:.75)).s=e.s:n=new this(NaN),n}function Hj(e){return new this(e).cbrt()}function jj(e){return hj(e=new this(e),e.e+1,2)}function Uj(e,t,n){return new this(e).clamp(t,n)}function qj(e){if(!e||"object"!=typeof e)throw Error(VH+"Object expected");var t,n,r,a=!0===e.defaults,i=["precision",1,PH,"rounding",0,8,"toExpNeg",-zH,0,"toExpPos",0,zH,"maxE",0,zH,"minE",-zH,0,"modulo",0,9];for(t=0;t=i[t+1]&&r<=i[t+2]))throw Error(GH+n+": "+r);this[n]=r}if(n="crypto",a&&(this[n]=qH[n]),void 0!==(r=e[n])){if(!0!==r&&!1!==r&&0!==r&&1!==r)throw Error(GH+n+": "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(JH);this[n]=!0}else this[n]=!1}return this}function Wj(e){return new this(e).cos()}function Vj(e){return new this(e).cosh()}function Gj(e,t){return new this(e).div(t)}function Kj(e){return new this(e).exp()}function Jj(e){return hj(e=new this(e),e.e+1,3)}function Xj(){var e,t,n=new this(0);for(WH=!1,e=0;e=429e7?t[i]=crypto.getRandomValues(new Uint32Array(1))[0]:o[i++]=a%1e7;else{if(!crypto.randomBytes)throw Error(JH);for(t=crypto.randomBytes(r*=4);i=214e7?crypto.randomBytes(4).copy(t,i):(o.push(a%1e7),i+=4);i=r/4}else for(;i=10;a/=10)r++;r<7&&(n-=7-r)}return s.e=n,s.d=o,s}function lU(e){return hj(e=new this(e),e.e+1,this.rounding)}function cU(e){return(e=new this(e)).d?e.d[0]?e.s:0*e.s:e.s||NaN}function pU(e){return new this(e).sin()}function dU(e){return new this(e).sinh()}function hU(e){return new this(e).sqrt()}function fU(e,t){return new this(e).sub(t)}function mU(){var e=0,t=arguments,n=new this(t[e]);for(WH=!1;n.s&&++ei.maxE?(a.e=NaN,a.d=null):e.e=10;n/=10)t++;return void(WH?t>i.maxE?(a.e=NaN,a.d=null):t!function(e){return e&&"?"===e[0]}(e))).every((e=>void 0!==n[e]))){var r=t.filter((e=>void 0===n[e]));throw new Error('Cannot create function "'.concat(e,'", ')+"some dependencies are missing: ".concat(r.map((e=>'"'.concat(e,'"'))).join(", "),"."))}}(e,t,r),n(a)}return a.isFactory=!0,a.fn=e,a.dependencies=t.slice().sort(),r&&(a.meta=r),a}function wU(e){return"function"==typeof e&&"string"==typeof e.fn&&Array.isArray(e.dependencies)}function DU(e){return e&&"?"===e[0]?e.slice(1):e}var NU=_U("BigNumber",["?on","config"],(e=>{var{on:t,config:n}=e,r=xU.clone({precision:n.precision,modulo:xU.EUCLID});return r.prototype=Object.create(r.prototype),r.prototype.type="BigNumber",r.prototype.isBigNumber=!0,r.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},r.fromJSON=function(e){return new r(e.value)},t&&t("config",(function(e,t){e.precision!==t.precision&&r.config({precision:e.precision})})),r}),{isClass:!0}),MU=n(1977);function SU(e){return"boolean"==typeof e||!!isFinite(e)&&e===Math.round(e)}var kU=Math.sign||function(e){return e>0?1:e<0?-1:0},TU=Math.log2||function(e){return Math.log(e)/Math.LN2},CU=Math.log10||function(e){return Math.log(e)/Math.LN10},EU=Math.log1p||function(e){return Math.log(e+1)},AU=Math.cbrt||function(e){if(0===e)return e;var t,n=e<0;return n&&(e=-e),t=isFinite(e)?(e/((t=Math.exp(Math.log(e)/3))*t)+2*t)/3:e,n?-t:t},IU=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function LU(e,t,n){var r={2:"0b",8:"0o",16:"0x"}[t],a="";if(n){if(n<1)throw new Error("size must be in greater than 0");if(!SU(n))throw new Error("size must be an integer");if(e>2**(n-1)-1||e<-(2**(n-1)))throw new Error("Value must be in range [-2^".concat(n-1,", 2^").concat(n-1,"-1]"));if(!SU(e))throw new Error("Value must be an integer");e<0&&(e+=2**n),a="i".concat(n)}var i="";return e<0&&(e=-e,i="-"),"".concat(i).concat(r).concat(e.toString(t)).concat(a)}function FU(e,t){if("function"==typeof t)return t(e);if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var n,r,a="auto";if(t&&(t.notation&&(a=t.notation),RP(t)?n=t:RP(t.precision)&&(n=t.precision),t.wordSize&&"number"!=typeof(r=t.wordSize)))throw new Error('Option "wordSize" must be a number');switch(a){case"fixed":return OU(e,n);case"exponential":return RU(e,n);case"engineering":return function(e,t){if(isNaN(e)||!isFinite(e))return String(e);var n=YU($U(e),t),r=n.exponent,a=n.coefficients,i=r%3==0?r:r<0?r-3-r%3:r-r%3;if(RP(t))for(;t>a.length||r-i+1>a.length;)a.push(0);else for(var s=Math.abs(r-i)-(a.length-1),o=0;o0;)l++,u--;var c=a.slice(l).join(""),p=RP(t)&&c.length||c.match(/[1-9]/)?"."+c:"",d=a.slice(0,l).join("")+p+"e"+(r>=0?"+":"")+i.toString();return n.sign+d}(e,n);case"bin":return LU(e,2,r);case"oct":return LU(e,8,r);case"hex":return LU(e,16,r);case"auto":return function(e,t,n){if(isNaN(e)||!isFinite(e))return String(e);var r=n&&void 0!==n.lowerExp?n.lowerExp:-3,a=n&&void 0!==n.upperExp?n.upperExp:5,i=$U(e),s=t?YU(i,t):i;if(s.exponent=a)return RU(e,t);var o=s.coefficients,u=s.exponent;o.length0?u:0;return l<(o=BU(-u).concat(o)).length-1&&o.splice(l+1,0,"."),s.sign+o.join("")}(e,n,t&&t).replace(/((\.\d*?)(0+))($|e)/,(function(){var e=arguments[2],t=arguments[4];return"."!==e?e+t:t}));default:throw new Error('Unknown notation "'+a+'". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.')}}function $U(e){var t=String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number "+e);var n=t[1],r=t[2],a=parseFloat(t[4]||"0"),i=r.indexOf(".");a+=-1!==i?i-1:r.length-1;var s=r.replace(".","").replace(/^0*/,(function(e){return a-=e.length,""})).replace(/0*$/,"").split("").map((function(e){return parseInt(e)}));return 0===s.length&&(s.push(0),a++),{sign:n,coefficients:s,exponent:a}}function OU(e,t){if(isNaN(e)||!isFinite(e))return String(e);var n=$U(e),r="number"==typeof t?YU(n,n.exponent+1+t):n,a=r.coefficients,i=r.exponent+1,s=i+(t||0);return a.length0?"."+a.join(""):"")+"e"+(i>=0?"+":"")+i}function YU(e,t){for(var n={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},r=n.coefficients;t<=0;)r.unshift(0),n.exponent++,t++;if(r.length>t&&r.splice(t,r.length-t)[0]>=5){var a=t-1;for(r[a]++;10===r[a];)r.pop(),0===a&&(r.unshift(0),n.exponent++,a++),r[--a]++}return n}function BU(e){for(var t=[],n=0;n(Object.defineProperty(MU,"name",{value:"Complex"}),MU.prototype.constructor=MU,MU.prototype.type="Complex",MU.prototype.isComplex=!0,MU.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},MU.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},MU.prototype.format=function(e){var t=this.im,n=this.re,r=FU(this.re,e),a=FU(this.im,e),i=RP(e)?e:e?e.precision:null;if(null!==i){var s=Math.pow(10,-i);Math.abs(n/t)t.re?1:e.ret.im?1:e.im1&&void 0!==arguments[1]?arguments[1]:{};return n=null==n?Number.POSITIVE_INFINITY:n,t=null==t?JSON.stringify:t,function r(){"object"!=typeof r.cache&&(r.cache={values:new Map,lru:KU(n||Number.POSITIVE_INFINITY)});for(var a=[],i=0;i!0)),oq=_U("false",[],(()=>!1)),uq=_U("null",[],(()=>null)),lq=Mq("Infinity",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(1/0):1/0})),cq=Mq("NaN",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(NaN):NaN})),pq=Mq("pi",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?eq(n):rq})),dq=Mq("tau",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?tq(n):aq})),hq=Mq("e",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?ZU(n):iq})),fq=Mq("phi",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?QU(n):1.618033988749895})),mq=Mq("LN2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(2).ln():Math.LN2})),gq=Mq("LN10",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(10).ln():Math.LN10})),yq=Mq("LOG2E",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(1).div(new n(2).ln()):Math.LOG2E})),bq=Mq("LOG10E",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(1).div(new n(10).ln()):Math.LOG10E})),vq=Mq("SQRT1_2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n("0.5").sqrt():Math.SQRT1_2})),xq=Mq("SQRT2",["config","?BigNumber"],(e=>{var{config:t,BigNumber:n}=e;return"BigNumber"===t.number?new n(2).sqrt():Math.SQRT2})),_q=Mq("i",["Complex"],(e=>{var{Complex:t}=e;return t.I})),wq=_U("PI",["pi"],(e=>{var{pi:t}=e;return t})),Dq=_U("E",["e"],(e=>{var{e:t}=e;return t})),Nq=_U("version",[],(()=>"11.0.1"));function Mq(e,t,n){return _U(e,t,n,{recreateOnConfigChange:!0})}var Sq=wW("speedOfLight","299792458","m s^-1"),kq=wW("gravitationConstant","6.67430e-11","m^3 kg^-1 s^-2"),Tq=wW("planckConstant","6.62607015e-34","J s"),Cq=wW("reducedPlanckConstant","1.0545718176461565e-34","J s"),Eq=wW("magneticConstant","1.25663706212e-6","N A^-2"),Aq=wW("electricConstant","8.8541878128e-12","F m^-1"),Iq=wW("vacuumImpedance","376.730313667","ohm"),Lq=wW("coulomb","8.987551792261171e9","N m^2 C^-2"),Fq=wW("elementaryCharge","1.602176634e-19","C"),$q=wW("bohrMagneton","9.2740100783e-24","J T^-1"),Oq=wW("conductanceQuantum","7.748091729863649e-5","S"),Rq=wW("inverseConductanceQuantum","12906.403729652257","ohm"),Yq=wW("magneticFluxQuantum","2.0678338484619295e-15","Wb"),Bq=wW("nuclearMagneton","5.0507837461e-27","J T^-1"),zq=wW("klitzing","25812.807459304513","ohm"),Pq=wW("bohrRadius","5.29177210903e-11","m"),Hq=wW("classicalElectronRadius","2.8179403262e-15","m"),jq=wW("electronMass","9.1093837015e-31","kg"),Uq=wW("fermiCoupling","1.1663787e-5","GeV^-2"),qq=DW("fineStructure",.0072973525693),Wq=wW("hartreeEnergy","4.3597447222071e-18","J"),Vq=wW("protonMass","1.67262192369e-27","kg"),Gq=wW("deuteronMass","3.3435830926e-27","kg"),Kq=wW("neutronMass","1.6749271613e-27","kg"),Jq=wW("quantumOfCirculation","3.6369475516e-4","m^2 s^-1"),Xq=wW("rydberg","10973731.568160","m^-1"),Zq=wW("thomsonCrossSection","6.6524587321e-29","m^2"),Qq=DW("weakMixingAngle",.2229),eW=DW("efimovFactor",22.7),tW=wW("atomicMass","1.66053906660e-27","kg"),nW=wW("avogadro","6.02214076e23","mol^-1"),rW=wW("boltzmann","1.380649e-23","J K^-1"),aW=wW("faraday","96485.33212331001","C mol^-1"),iW=wW("firstRadiation","3.7417718521927573e-16","W m^2"),sW=wW("loschmidt","2.686780111798444e25","m^-3"),oW=wW("gasConstant","8.31446261815324","J K^-1 mol^-1"),uW=wW("molarPlanckConstant","3.990312712893431e-10","J s mol^-1"),lW=wW("molarVolume","0.022413969545014137","m^3 mol^-1"),cW=DW("sackurTetrode",-1.16487052358),pW=wW("secondRadiation","0.014387768775039337","m K"),dW=wW("stefanBoltzmann","5.67037441918443e-8","W m^-2 K^-4"),hW=wW("wienDisplacement","2.897771955e-3","m K"),fW=wW("molarMass","0.99999999965e-3","kg mol^-1"),mW=wW("molarMassC12","11.9999999958e-3","kg mol^-1"),gW=wW("gravity","9.80665","m s^-2"),yW=wW("planckLength","1.616255e-35","m"),bW=wW("planckMass","2.176435e-8","kg"),vW=wW("planckTime","5.391245e-44","s"),xW=wW("planckCharge","1.87554603778e-18","C"),_W=wW("planckTemperature","1.416785e+32","K");function wW(e,t,n){return _U(e,["config","Unit","BigNumber"],(e=>{var{config:r,Unit:a,BigNumber:i}=e,s=new a("BigNumber"===r.number?new i(t):parseFloat(t),n);return s.fixPrefix=!0,s}))}function DW(e,t){return _U(e,["config","BigNumber"],(e=>{var{config:n,BigNumber:r}=e;return"BigNumber"===n.number?new r(t):t}))}var NW=n(5628),MW=_U("Fraction",[],(()=>(Object.defineProperty(NW,"name",{value:"Fraction"}),NW.prototype.constructor=NW,NW.prototype.type="Fraction",NW.prototype.isFraction=!0,NW.prototype.toJSON=function(){return{mathjs:"Fraction",n:this.s*this.n,d:this.d}},NW.fromJSON=function(e){return new NW(e)},NW)),{isClass:!0}),SW=_U("Matrix",[],(()=>{function e(){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator")}return e.prototype.type="Matrix",e.prototype.isMatrix=!0,e.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},e.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},e.prototype.create=function(e,t){throw new Error("Cannot invoke create on a Matrix interface")},e.prototype.subset=function(e,t,n){throw new Error("Cannot invoke subset on a Matrix interface")},e.prototype.get=function(e){throw new Error("Cannot invoke get on a Matrix interface")},e.prototype.set=function(e,t,n){throw new Error("Cannot invoke set on a Matrix interface")},e.prototype.resize=function(e,t){throw new Error("Cannot invoke resize on a Matrix interface")},e.prototype.reshape=function(e,t){throw new Error("Cannot invoke reshape on a Matrix interface")},e.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},e.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},e.prototype.map=function(e,t){throw new Error("Cannot invoke map on a Matrix interface")},e.prototype.forEach=function(e){throw new Error("Cannot invoke forEach on a Matrix interface")},e.prototype[Symbol.iterator]=function(){throw new Error("Cannot iterate a Matrix interface")},e.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},e.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},e.prototype.format=function(e){throw new Error("Cannot invoke format on a Matrix interface")},e.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},e}),{isClass:!0}),kW=_U("Range",[],(()=>{function e(t,n,r){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");var a=null!=t,i=null!=n,s=null!=r;if(a)if(YP(t))t=t.toNumber();else if("number"!=typeof t)throw new TypeError("Parameter start must be a number");if(i)if(YP(n))n=n.toNumber();else if("number"!=typeof n)throw new TypeError("Parameter end must be a number");if(s)if(YP(r))r=r.toNumber();else if("number"!=typeof r)throw new TypeError("Parameter step must be a number");this.start=a?parseFloat(t):0,this.end=i?parseFloat(n):0,this.step=s?parseFloat(r):1}return e.prototype.type="Range",e.prototype.isRange=!0,e.parse=function(t){if("string"!=typeof t)return null;var n=t.split(":").map((function(e){return parseFloat(e)})),r=n.some((function(e){return isNaN(e)}));if(r)return null;switch(n.length){case 2:return new e(n[0],n[1]);case 3:return new e(n[0],n[2],n[1]);default:return null}},e.prototype.clone=function(){return new e(this.start,this.end,this.step)},e.prototype.size=function(){var e=0,t=this.start,n=this.step,r=this.end-t;return kU(n)===kU(r)?e=Math.ceil(r/n):0===r&&(e=0),isNaN(e)&&(e=0),[e]},e.prototype.min=function(){var e=this.size()[0];return e>0?this.step>0?this.start:this.start+(e-1)*this.step:void 0},e.prototype.max=function(){var e=this.size()[0];return e>0?this.step>0?this.start+(e-1)*this.step:this.start:void 0},e.prototype.forEach=function(e){var t=this.start,n=this.step,r=this.end,a=0;if(n>0)for(;tr;)e(t,[a],this),t+=n,a++},e.prototype.map=function(e){var t=[];return this.forEach((function(n,r,a){t[r[0]]=e(n,r,a)})),t},e.prototype.toArray=function(){var e=[];return this.forEach((function(t,n){e[n[0]]=t})),e},e.prototype.valueOf=function(){return this.toArray()},e.prototype.format=function(e){var t=FU(this.start,e);return 1!==this.step&&(t+=":"+FU(this.step,e)),t+":"+FU(this.end,e)},e.prototype.toString=function(){return this.format()},e.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},e.fromJSON=function(t){return new e(t.start,t.end,t.step)},e}),{isClass:!0}),TW=_U("ResultSet",[],(()=>{function e(t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");this.entries=t||[]}return e.prototype.type="ResultSet",e.prototype.isResultSet=!0,e.prototype.valueOf=function(){return this.entries},e.prototype.toString=function(){return"["+this.entries.join(", ")+"]"},e.prototype.toJSON=function(){return{mathjs:"ResultSet",entries:this.entries}},e.fromJSON=function(t){return new e(t.entries)},e}),{isClass:!0});function CW(e,t,n){var r=new(0,e.constructor)(2),a="";if(n){if(n<1)throw new Error("size must be in greater than 0");if(!SU(n))throw new Error("size must be an integer");if(e.greaterThan(r.pow(n-1).sub(1))||e.lessThan(r.pow(n-1).mul(-1)))throw new Error("Value must be in range [-2^".concat(n-1,", 2^").concat(n-1,"-1]"));if(!e.isInteger())throw new Error("Value must be an integer");e.lessThan(0)&&(e=e.add(r.pow(n))),a="i".concat(n)}switch(t){case 2:return"".concat(e.toBinary()).concat(a);case 8:return"".concat(e.toOctal()).concat(a);case 16:return"".concat(e.toHexadecimal()).concat(a);default:throw new Error("Base ".concat(t," not supported "))}}function EW(e,t){return void 0!==t?e.toExponential(t-1):e.toExponential()}function AW(e,t){var n=e.length-t.length,r=e.length;return e.substring(n,r)===t}function IW(e,t){var n=function(e,t){return"number"==typeof e?FU(e,t):YP(e)?function(e,t){if("function"==typeof t)return t(e);if(!e.isFinite())return e.isNaN()?"NaN":e.gt(0)?"Infinity":"-Infinity";var n,r,a="auto";if(void 0!==t&&(t.notation&&(a=t.notation),"number"==typeof t?n=t:t.precision&&(n=t.precision),t.wordSize&&"number"!=typeof(r=t.wordSize)))throw new Error('Option "wordSize" must be a number');switch(a){case"fixed":return function(e,t){return e.toFixed(t)}(e,n);case"exponential":return EW(e,n);case"engineering":return function(e,t){var n=e.e,r=n%3==0?n:n<0?n-3-n%3:n-n%3,a=e.mul(Math.pow(10,-r)),i=a.toPrecision(t);return-1!==i.indexOf("e")&&(i=a.toString()),i+"e"+(n>=0?"+":"")+r.toString()}(e,n);case"bin":return CW(e,2,r);case"oct":return CW(e,8,r);case"hex":return CW(e,16,r);case"auto":var i=t&&void 0!==t.lowerExp?t.lowerExp:-3,s=t&&void 0!==t.upperExp?t.upperExp:5;if(e.isZero())return"0";var o=e.toSignificantDigits(n),u=o.e;return(u>=i&&u'"'+n+'": '+IW(e[n],t))).join(", ")+"}":String(e)}(e,t);return t&&"object"==typeof t&&"truncate"in t&&n.length>t.truncate?n.substring(0,t.truncate-3)+"...":n}function LW(e){for(var t=String(e),n="",r=0;r/g,">")}function $W(e,t){if(Array.isArray(e)){for(var n="[",r=e.length,a=0;at?1:-1}function RW(e,t,n){if(!(this instanceof RW))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=t,this.relation=n,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(t)?"["+t.join(", ")+"]":t)+")",this.stack=(new Error).stack}function YW(e,t,n){if(!(this instanceof YW))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=t):(this.min=t,this.max=n),void 0!==this.min&&this.index=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=(new Error).stack}function BW(e){for(var t=[];Array.isArray(e);)t.push(e.length),e=e[0];return t}function zW(e,t,n){var r,a=e.length;if(a!==t[n])throw new RW(a,t[n]);if(n")}function PW(e,t){if(0===t.length){if(Array.isArray(e))throw new RW(e.length,0)}else zW(e,t,0)}function HW(e,t){if(!RP(e)||!SU(e))throw new TypeError("Index must be an integer (value: "+e+")");if(e<0||"number"==typeof t&&e>=t)throw new YW(e,t)}function jW(e,t,n){if(!Array.isArray(e)||!Array.isArray(t))throw new TypeError("Array expected");if(0===t.length)throw new Error("Resizing to scalar is not supported");return t.forEach((function(e){if(!RP(e)||!SU(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+IW(t)+")")})),UW(e,t,0,void 0!==n?n:0),e}function UW(e,t,n,r){var a,i,s=e.length,o=t[n],u=Math.min(s,o);if(e.length=o,n=0){if(t%n!=0)throw new Error("Could not replace wildcard, since "+t+" is no multiple of "+-n);r[a]=-t/n}return r}function VW(e){return e.reduce(((e,t)=>e*t),1)}function GW(e,t){for(var n=t||BW(e);Array.isArray(e)&&1===e.length;)e=e[0],n.shift();for(var r=n.length;1===n[r-1];)r--;return rt.test(e)))}function rV(e,t){return Array.prototype.join.call(e,t)}function aV(e){if(!Array.isArray(e))throw new TypeError("Array input expected");if(0===e.length)return e;var t=[],n=0;t[0]={value:e[0],identifier:0};for(var r=1;r{var{Matrix:t}=e;function n(e,t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!HP(t))throw new Error("Invalid datatype: "+t);if(UP(e))"DenseMatrix"===e.type?(this._data=DH(e._data),this._size=DH(e._size),this._datatype=t||e._datatype):(this._data=e.toArray(),this._size=e.size(),this._datatype=t||e._datatype);else if(e&&jP(e.data)&&jP(e.size))this._data=e.data,this._size=e.size,PW(this._data,this._size),this._datatype=t||e.datatype;else if(jP(e))this._data=l(e),this._size=BW(this._data),PW(this._data,this._size),this._datatype=t;else{if(e)throw new TypeError("Unsupported type of data ("+wH(e)+")");this._data=[],this._size=[0],this._datatype=t}}function r(e,t){if(!KP(t))throw new TypeError("Invalid index");if(t.isScalar())return e.get(t.min());var r=t.size();if(r.length!==e._size.length)throw new RW(r.length,e._size.length);for(var i=t.min(),s=t.max(),o=0,u=e._size.length;o");var p=t.max().map((function(e){return e+1}));u(e,p,r);var d=i.length;s(e._data,t,n,d,0)}return e}function s(e,t,n,r,a){var i=a===r-1,o=t.dimension(a);i?o.forEach((function(t,r){HW(t),e[t]=n[r[0]]})):o.forEach((function(i,o){HW(i),s(e[i],t,n[o[0]],r,a+1)}))}function o(e,t,n){if(0===t.length){for(var r=e._data;jP(r);)r=r[0];return r}return e._size=t.slice(0),e._data=jW(e._data,e._size,n),e}function u(e,t,n){for(var r=e._size.slice(0),a=!1;r.lengthr[i]&&(r[i]=t[i],a=!0);a&&o(e,r,n)}function l(e){for(var t=0,n=e.length;tArray.isArray(e)&&1===e.length?e[0]:e));return o(n?this.clone():this,r,t)},n.prototype.reshape=function(e,t){var n=t?this.clone():this;n._data=qW(n._data,e);var r=n._size.reduce(((e,t)=>e*t));return n._size=WW(e,r),n},n.prototype.clone=function(){return new n({data:DH(this._data),size:DH(this._size),datatype:this._datatype})},n.prototype.size=function(){return this._size.slice(0)},n.prototype.map=function(e){var t=this,r=XU(e),a=function n(a,i){return jP(a)?a.map((function(e,t){return n(e,i.concat(t))})):1===r?e(a):2===r?e(a,i):e(a,i,t)}(this._data,[]);return new n(a,void 0!==this._datatype?sV(a,wH):void 0)},n.prototype.forEach=function(e){var t=this;!function n(r,a){jP(r)?r.forEach((function(e,t){n(e,a.concat(t))})):e(r,a,t)}(this._data,[])},n.prototype[Symbol.iterator]=function*(){yield*function*e(t,n){if(jP(t))for(var r=0;r[e[r]]));t.push(new n(i,e._datatype))},s=0;s0?e:0,r=e<0?-e:0,a=this._size[0],i=this._size[1],s=Math.min(a-r,i-t),o=[],u=0;u0?r:0,o=r<0?-r:0,u=e[0],l=e[1],c=Math.min(u-o,l-s);if(jP(t)){if(t.length!==c)throw new Error("Invalid value array length");i=function(e){return t[e]}}else if(UP(t)){var p=t.size();if(1!==p.length||p[0]!==c)throw new Error("Invalid matrix length");i=function(e){return t.get([e])}}else i=function(){return t};a||(a=YP(i(0))?i(0).mul(0):0);var d=[];if(e.length>0){d=jW(d,e,a);for(var h=0;hfunction(e,t){return"number"!=typeof t||isFinite(t)&&!isNaN(t)?t:{mathjs:"number",value:String(t)}})),cV=n(2287);function pV(e,t){if(mV(e)&&hV(e,t))return e[t];if("function"==typeof e[t]&&fV(e,t))throw new Error('Cannot access method "'+t+'" as a property');throw new Error('No access to property "'+t+'"')}function dV(e,t,n){if(mV(e)&&hV(e,t))return e[t]=n,n;throw new Error('No access to property "'+t+'"')}function hV(e,t){return!(!e||"object"!=typeof e||!AH(gV,t)&&(t in Object.prototype||t in Function.prototype))}function fV(e,t){return!(null==e||"function"!=typeof e[t]||AH(e,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(e)||!AH(yV,t)&&(t in Object.prototype||t in Function.prototype))}function mV(e){return"object"==typeof e&&e&&e.constructor===Object}var gV={length:!0,name:!0},yV={toString:!0,valueOf:!0,toLocaleString:!0};class bV{constructor(e){this.wrappedObject=e}keys(){return Object.keys(this.wrappedObject)}get(e){return pV(this.wrappedObject,e)}set(e,t){return dV(this.wrappedObject,e,t),this}has(e){return e in this.wrappedObject}}function vV(){return new Map}function xV(e){if(!e)return vV();if(_V(e))return e;if(nH(e))return new bV(e);throw new Error("createMap can create maps from objects or Maps")}function _V(e){return!!e&&(e instanceof Map||e instanceof bV||"function"==typeof e.set&&"function"==typeof e.get&&"function"==typeof e.keys&&"function"==typeof e.has)}function wV(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;rHP&&/^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF38\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])(?:[0-9A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF38\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])*$/.test(e)},{name:"string",test:HP},{name:"Chain",test:_H},{name:"Array",test:jP},{name:"Matrix",test:UP},{name:"DenseMatrix",test:WP},{name:"SparseMatrix",test:VP},{name:"Range",test:GP},{name:"Index",test:KP},{name:"boolean",test:JP},{name:"ResultSet",test:XP},{name:"Help",test:ZP},{name:"function",test:QP},{name:"Date",test:eH},{name:"RegExp",test:tH},{name:"null",test:rH},{name:"undefined",test:aH},{name:"AccessorNode",test:iH},{name:"ArrayNode",test:sH},{name:"AssignmentNode",test:oH},{name:"BlockNode",test:uH},{name:"ConditionalNode",test:lH},{name:"ConstantNode",test:cH},{name:"FunctionNode",test:hH},{name:"FunctionAssignmentNode",test:dH},{name:"IndexNode",test:fH},{name:"Node",test:mH},{name:"ObjectNode",test:gH},{name:"OperatorNode",test:yH},{name:"ParenthesisNode",test:bH},{name:"RangeNode",test:vH},{name:"SymbolNode",test:xH},{name:"Map",test:_V},{name:"Object",test:nH}]),i.addConversions([{from:"number",to:"BigNumber",convert:function(e){if(t||MV(e),e.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+e+"). Use function bignumber(x) to convert to BigNumber.");return new t(e)}},{from:"number",to:"Complex",convert:function(e){return n||SV(e),new n(e,0)}},{from:"BigNumber",to:"Complex",convert:function(e){return n||SV(e),new n(e.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(e){throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.")}},{from:"Fraction",to:"Complex",convert:function(e){return n||SV(e),new n(e.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(e){a||kV(e);var t=new a(e);if(t.valueOf()!==e)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+e+"). Use function fraction(x) to convert to Fraction.");return t}},{from:"string",to:"number",convert:function(e){var t=Number(e);if(isNaN(t))throw new Error('Cannot convert "'+e+'" to a number');return t}},{from:"string",to:"BigNumber",convert:function(e){t||MV(e);try{return new t(e)}catch(t){throw new Error('Cannot convert "'+e+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(e){a||kV(e);try{return new a(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(e){n||SV(e);try{return new n(e)}catch(t){throw new Error('Cannot convert "'+e+'" to Complex')}}},{from:"boolean",to:"number",convert:function(e){return+e}},{from:"boolean",to:"BigNumber",convert:function(e){return t||MV(e),new t(+e)}},{from:"boolean",to:"Fraction",convert:function(e){return a||kV(e),new a(+e)}},{from:"boolean",to:"string",convert:function(e){return String(e)}},{from:"Array",to:"Matrix",convert:function(e){return r||function(){throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided")}(),new r(e)}},{from:"Matrix",to:"Array",convert:function(e){return e.valueOf()}}]),i.onMismatch=(e,t,n)=>{var r=i.createError(e,t,n);if(["wrongType","mismatch"].includes(r.data.category)&&1===t.length&&qP(t[0])&&n.some((e=>!e.params.includes(",")))){var a=new TypeError("Function '".concat(e,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(e,")'."));throw a.data=r.data,a}throw r},i.onMismatch=(e,t,n)=>{var r=i.createError(e,t,n);if(["wrongType","mismatch"].includes(r.data.category)&&1===t.length&&qP(t[0])&&n.some((e=>!e.params.includes(",")))){var a=new TypeError("Function '".concat(e,"' doesn't apply to matrices. To call it ")+"elementwise on a matrix 'M', try 'map(M, ".concat(e,")'."));throw a.data=r.data,a}throw r},i}));function MV(e){throw new Error("Cannot convert value ".concat(e," into a BigNumber: no class 'BigNumber' provided"))}function SV(e){throw new Error("Cannot convert value ".concat(e," into a Complex number: no class 'Complex' provided"))}function kV(e){throw new Error("Cannot convert value ".concat(e," into a Fraction, no class 'Fraction' provided."))}function TV(e){var t,n,r=e.length,a=e[0].length,i=[];for(n=0;n=r.length)throw new YW(t,r.length);return UP(e)?e.create(LV(e.valueOf(),t,n)):LV(e,t,n)}function LV(e,t,n){var r,a,i,s;if(t<=0){if(Array.isArray(e[0])){for(s=TV(e),a=[],r=0;r0)return e-t*Math.floor(e/t);if(0===t)return e;throw new Error("Cannot calculate mod for a negative divisor")}function XV(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,n=t<0;if(n&&(t=-t),0===t)throw new Error("Root must be non-zero");if(e<0&&Math.abs(t)%2!=1)throw new Error("Root must be odd when a is negative.");if(0===e)return n?1/0:0;if(!isFinite(e))return n?0:e;var r=Math.pow(Math.abs(e),1/t);return r=e<0?-r:r,n?1/r:r}function ZV(e){return kU(e)}function QV(e){return e*e}function eG(e,t){var n,r,a,i=0,s=1,o=1,u=0;if(!SU(e)||!SU(t))throw new Error("Parameters in function xgcd must be integer numbers");for(;t;)a=e-(r=Math.floor(e/t))*t,n=i,i=s-r*i,s=n,n=o,o=u-r*o,u=n,e=t,t=a;return e<0?[-e,-s,-u]:[e,e?s:0,u]}function tG(e,t){return e*e<1&&t===1/0||e*e>1&&t===-1/0?0:Math.pow(e,t)}function nG(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!SU(t)||t<0||t>15)throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");return parseFloat(OU(e,t))}RV.signature=$V,YV.signature=OV,BV.signature=OV,zV.signature=$V,PV.signature=$V,HV.signature=$V,jV.signature=$V,UV.signature=$V,qV.signature=$V,WV.signature=OV,VV.signature=OV,GV.signature=$V,KV.signature=$V,JV.signature=OV,ZV.signature=$V,QV.signature=$V,eG.signature=OV,tG.signature=OV;var rG="unaryPlus",aG=_U(rG,["typed","config","BigNumber"],(e=>{var{typed:t,config:n,BigNumber:r}=e;return t(rG,{number:PV,Complex:function(e){return e},BigNumber:function(e){return e},Fraction:function(e){return e},Unit:function(e){return e.clone()},"Array | Matrix":t.referToSelf((e=>t=>AV(t,e,!0))),"boolean | string":function(e){return"BigNumber"===n.number?new r(+e):+e}})})),iG=_U("abs",["typed"],(e=>{var{typed:t}=e;return t("abs",{number:RV,"Complex | BigNumber | Fraction | Unit":e=>e.abs(),"Array | Matrix":t.referToSelf((e=>t=>AV(t,e,!0)))})})),sG="acos",oG=_U(sG,["typed","config","Complex"],(e=>{var{typed:t,config:n,Complex:r}=e;return t(sG,{number:function(e){return e>=-1&&e<=1||n.predictable?Math.acos(e):new r(e,0).acos()},Complex:function(e){return e.acos()},BigNumber:function(e){return e.acos()}})})),uG="number";function lG(e){return HU(e)}function cG(e){return Math.atan(1/e)}function pG(e){return isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}function dG(e){return Math.asin(1/e)}function hG(e){var t=1/e;return Math.log(t+Math.sqrt(t*t+1))}function fG(e){return Math.acos(1/e)}function mG(e){var t=1/e,n=Math.sqrt(t*t-1);return Math.log(n+t)}function gG(e){return jU(e)}function yG(e){return UU(e)}function bG(e){return 1/Math.tan(e)}function vG(e){var t=Math.exp(2*e);return(t+1)/(t-1)}function xG(e){return 1/Math.sin(e)}function _G(e){return 0===e?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*kU(e)}function wG(e){return 1/Math.cos(e)}function DG(e){return 2/(Math.exp(e)+Math.exp(-e))}function NG(e){return WU(e)}lG.signature=uG,cG.signature=uG,pG.signature=uG,dG.signature=uG,hG.signature=uG,fG.signature=uG,mG.signature=uG,gG.signature=uG,yG.signature=uG,bG.signature=uG,vG.signature=uG,xG.signature=uG,_G.signature=uG,wG.signature=uG,DG.signature=uG,NG.signature=uG;var MG="acot",SG=_U(MG,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t(MG,{number:cG,Complex:function(e){return e.acot()},BigNumber:function(e){return new n(1).div(e).atan()}})})),kG="acsc",TG=_U(kG,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:n,Complex:r,BigNumber:a}=e;return t(kG,{number:function(e){return e<=-1||e>=1||n.predictable?dG(e):new r(e,0).acsc()},Complex:function(e){return e.acsc()},BigNumber:function(e){return new a(1).div(e).asin()}})})),CG="addScalar",EG=_U(CG,["typed"],(e=>{var{typed:t}=e;return t(CG,{"number, number":YV,"Complex, Complex":function(e,t){return e.add(t)},"BigNumber, BigNumber":function(e,t){return e.plus(t)},"Fraction, Fraction":function(e,t){return e.add(t)},"Unit, Unit":t.referToSelf((e=>(n,r)=>{if(null===n.value||void 0===n.value)throw new Error("Parameter x contains a unit with undefined value");if(null===r.value||void 0===r.value)throw new Error("Parameter y contains a unit with undefined value");if(!n.equalBase(r))throw new Error("Units do not match");var a=n.clone();return a.value=t.find(e,[a.valueType(),r.valueType()])(a.value,r.value),a.fixPrefix=!1,a}))})})),AG=_U("arg",["typed"],(e=>{var{typed:t}=e;return t("arg",{number:function(e){return Math.atan2(0,e)},BigNumber:function(e){return e.constructor.atan2(0,e)},Complex:function(e){return e.arg()},"Array | Matrix":t.referToSelf((e=>t=>AV(t,e)))})})),IG="asech",LG=_U(IG,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:n,Complex:r,BigNumber:a}=e;return t(IG,{number:function(e){if(e<=1&&e>=-1||n.predictable){var t=1/e;if(t>0||n.predictable)return mG(e);var a=Math.sqrt(t*t-1);return new r(Math.log(a-t),Math.PI)}return new r(e,0).asech()},Complex:function(e){return e.asech()},BigNumber:function(e){return new a(1).div(e).acosh()}})})),FG=_U("asinh",["typed"],(e=>{var{typed:t}=e;return t("asinh",{number:gG,Complex:function(e){return e.asinh()},BigNumber:function(e){return e.asinh()}})})),$G=_U("atan",["typed"],(e=>{var{typed:t}=e;return t("atan",{number:function(e){return Math.atan(e)},Complex:function(e){return e.atan()},BigNumber:function(e){return e.atan()}})})),OG="atanh",RG=_U(OG,["typed","config","Complex"],(e=>{var{typed:t,config:n,Complex:r}=e;return t(OG,{number:function(e){return e<=1&&e>=-1||n.predictable?yG(e):new r(e,0).atanh()},Complex:function(e){return e.atanh()},BigNumber:function(e){return e.atanh()}})})),YG=_U("bignumber",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t("bignumber",{"":function(){return new n(0)},number:function(e){return new n(e+"")},string:function(e){var t=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(t){var r=t[2],a=n(t[1]),i=new n(2).pow(Number(r));if(a.gt(i.sub(1)))throw new SyntaxError('String "'.concat(e,'" is out of range'));var s=new n(2).pow(Number(r)-1);return a.gte(s)?a.sub(i):a}return new n(e)},BigNumber:function(e){return e},Fraction:function(e){return new n(e.n).div(e.d).times(e.s)},null:function(e){return new n(0)},"Array | Matrix":t.referToSelf((e=>t=>AV(t,e)))})}));function BG(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitAnd");var n=e.constructor;if(e.isNaN()||t.isNaN())return new n(NaN);if(e.isZero()||t.eq(-1)||e.eq(t))return e;if(t.isZero()||e.eq(-1))return t;if(!e.isFinite()||!t.isFinite()){if(!e.isFinite()&&!t.isFinite())return e.isNegative()===t.isNegative()?e:new n(0);if(!e.isFinite())return t.isNegative()?e:e.isNegative()?new n(0):t;if(!t.isFinite())return e.isNegative()?t:t.isNegative()?new n(0):e}return HG(e,t,(function(e,t){return e&t}))}function zG(e){if(e.isFinite()&&!e.isInteger())throw new Error("Integer expected in function bitNot");var t=e.constructor,n=t.precision;t.config({precision:1e9});var r=e.plus(new t(1));return r.s=-r.s||null,t.config({precision:n}),r}function PG(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitOr");var n=e.constructor;if(e.isNaN()||t.isNaN())return new n(NaN);var r=new n(-1);return e.isZero()||t.eq(r)||e.eq(t)?t:t.isZero()||e.eq(r)?e:e.isFinite()&&t.isFinite()?HG(e,t,(function(e,t){return e|t})):!e.isFinite()&&!e.isNegative()&&t.isNegative()||e.isNegative()&&!t.isNegative()&&!t.isFinite()?r:e.isNegative()&&t.isNegative()?e.isFinite()?e:t:e.isFinite()?t:e}function HG(e,t,n){var r,a,i,s,o,u=e.constructor,l=+(e.s<0),c=+(t.s<0);if(l){r=jG(zG(e));for(var p=0;p0;)n(i[--h],s[--f])===m&&(g=g.plus(y)),y=y.times(b);for(;f>0;)n(o,s[--f])===m&&(g=g.plus(y)),y=y.times(b);return u.config({precision:v}),0===m&&(g.s=-g.s),g}function jG(e){for(var t=e.d,n=t[0]+"",r=1;r0)if(++o>l)for(o-=l;o--;)u+="0";else o1&&(null!==c[h+1]&&void 0!==c[h+1]||(c[h+1]=0),c[h+1]+=c[h]>>1,c[h]&=1)}return c.reverse()}function UG(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitXor");var n=e.constructor;if(e.isNaN()||t.isNaN())return new n(NaN);if(e.isZero())return t;if(t.isZero())return e;if(e.eq(t))return new n(0);var r=new n(-1);return e.eq(r)?zG(t):t.eq(r)?zG(e):e.isFinite()&&t.isFinite()?HG(e,t,(function(e,t){return e^t})):e.isFinite()||t.isFinite()?new n(e.isNegative()===t.isNegative()?1/0:-1/0):r}function qG(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function leftShift");var n=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new n(NaN):e.isZero()||t.isZero()?e:e.isFinite()||t.isFinite()?t.lt(55)?e.times(Math.pow(2,t.toNumber())+""):e.times(new n(2).pow(t)):new n(NaN)}function WG(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function rightArithShift");var n=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new n(NaN):e.isZero()||t.isZero()?e:t.isFinite()?t.lt(55)?e.div(Math.pow(2,t.toNumber())+"").floor():e.div(new n(2).pow(t)).floor():e.isNegative()?new n(-1):e.isFinite()?new n(0):new n(NaN)}var VG="number, number";function GG(e,t){if(!SU(e)||!SU(t))throw new Error("Integers expected in function bitAnd");return e&t}function KG(e){if(!SU(e))throw new Error("Integer expected in function bitNot");return~e}function JG(e,t){if(!SU(e)||!SU(t))throw new Error("Integers expected in function bitOr");return e|t}function XG(e,t){if(!SU(e)||!SU(t))throw new Error("Integers expected in function bitXor");return e^t}function ZG(e,t){if(!SU(e)||!SU(t))throw new Error("Integers expected in function leftShift");return e<>t}function eK(e,t){if(!SU(e)||!SU(t))throw new Error("Integers expected in function rightLogShift");return e>>>t}GG.signature=VG,KG.signature="number",JG.signature=VG,XG.signature=VG,ZG.signature=VG,QG.signature=VG,eK.signature=VG;var tK="bitNot",nK=_U(tK,["typed"],(e=>{var{typed:t}=e;return t(tK,{number:KG,BigNumber:zG,"Array | Matrix":t.referToSelf((e=>t=>AV(t,e)))})})),rK="boolean",aK=_U(rK,["typed"],(e=>{var{typed:t}=e;return t(rK,{"":function(){return!1},boolean:function(e){return e},number:function(e){return!!e},null:function(e){return!1},BigNumber:function(e){return!e.isZero()},string:function(e){var t=e.toLowerCase();if("true"===t)return!0;if("false"===t)return!1;var n=Number(e);if(""!==e&&!isNaN(n))return!!n;throw new Error('Cannot convert "'+e+'" to a boolean')},"Array | Matrix":t.referToSelf((e=>t=>AV(t,e)))})})),iK="clone",sK=_U(iK,["typed"],(e=>{var{typed:t}=e;return t(iK,{any:DH})}));function oK(e,t){if(t>1;return oK(e,n)*oK(n+1,t)}function uK(e,t){if(!SU(e)||e<0)throw new TypeError("Positive integer value expected in function combinations");if(!SU(t)||t<0)throw new TypeError("Positive integer value expected in function combinations");if(t>e)throw new TypeError("k must be less than or equal to n");for(var n=e-t,r=1,a=2,i=t{var{typed:t}=e;return t(lK,{"number, number":uK,"BigNumber, BigNumber":function(e,t){var n,r,a=e.constructor,i=e.minus(t),s=new a(1);if(!pK(e)||!pK(t))throw new TypeError("Positive integer value expected in function combinations");if(t.gt(e))throw new TypeError("k must be less than n in function combinations");if(n=s,t.lt(i))for(r=s;r.lte(i);r=r.plus(s))n=n.times(t.plus(r)).dividedBy(r);else for(r=s;r.lte(t);r=r.plus(s))n=n.times(i.plus(r)).dividedBy(r);return n}})}));function pK(e){return e.isInteger()&&e.gte(0)}var dK=_U("complex",["typed","Complex"],(e=>{var{typed:t,Complex:n}=e;return t("complex",{"":function(){return n.ZERO},number:function(e){return new n(e,0)},"number, number":function(e,t){return new n(e,t)},"BigNumber, BigNumber":function(e,t){return new n(e.toNumber(),t.toNumber())},Fraction:function(e){return new n(e.valueOf(),0)},Complex:function(e){return e.clone()},string:function(e){return n(e)},null:function(e){return n(0)},Object:function(e){if("re"in e&&"im"in e)return new n(e.re,e.im);if("r"in e&&"phi"in e||"abs"in e&&"arg"in e)return new n(e);throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)")},"Array | Matrix":t.referToSelf((e=>t=>AV(t,e)))})})),hK="conj",fK=_U(hK,["typed"],(e=>{var{typed:t}=e;return t(hK,{"number | BigNumber | Fraction":e=>e,Complex:e=>e.conjugate(),"Array | Matrix":t.referToSelf((e=>t=>AV(t,e)))})})),mK="cosh",gK=_U(mK,["typed"],(e=>{var{typed:t}=e;return t(mK,{number:qU,"Complex | BigNumber":e=>e.cosh()})})),yK="coth",bK=_U(yK,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t(yK,{number:vG,Complex:e=>e.coth(),BigNumber:e=>new n(1).div(e.tanh())})})),vK=_U("trigUnit",["typed"],(e=>{var{typed:t}=e;return{Unit:t.referToSelf((e=>n=>{if(!n.hasBase(n.constructor.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return t.find(e,n.valueType())(n.value)}))}})),xK=_U("csc",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t("csc",{number:xG,Complex:e=>e.csc(),BigNumber:e=>new n(1).div(e.sin())},vK({typed:t}))})),_K="cube",wK=_U(_K,["typed"],(e=>{var{typed:t}=e;return t(_K,{number:jV,Complex:function(e){return e.mul(e).mul(e)},BigNumber:function(e){return e.times(e).times(e)},Fraction:function(e){return e.pow(3)},Unit:function(e){return e.pow(3)}})}));function DK(e,t,n){if(null==n)return e.eq(t);if(e.eq(t))return!0;if(e.isNaN()||t.isNaN())return!1;if(e.isFinite()&&t.isFinite()){var r=e.minus(t).abs();if(r.isZero())return!0;var a=e.constructor.max(e.abs(),t.abs());return r.lte(a.times(n))}return!1}var NK=_U("compareUnits",["typed"],(e=>{var{typed:t}=e;return{"Unit, Unit":t.referToSelf((e=>(n,r)=>{if(!n.equalBase(r))throw new Error("Cannot compare units with different base");return t.find(e,[n.valueType(),r.valueType()])(n.value,r.value)}))}})),MK="equalScalar",SK=_U(MK,["typed","config"],(e=>{var{typed:t,config:n}=e,r=NK({typed:t});return t(MK,{"boolean, boolean":function(e,t){return e===t},"number, number":function(e,t){return PU(e,t,n.epsilon)},"BigNumber, BigNumber":function(e,t){return e.eq(t)||DK(e,t,n.epsilon)},"Fraction, Fraction":function(e,t){return e.equals(t)},"Complex, Complex":function(e,t){return function(e,t,n){return PU(e.re,t.re,n)&&PU(e.im,t.im,n)}(e,t,n.epsilon)}},r)})),kK=(_U(MK,["typed","config"],(e=>{var{typed:t,config:n}=e;return t(MK,{"number, number":function(e,t){return PU(e,t,n.epsilon)}})})),_U("erf",["typed"],(e=>{var{typed:t}=e;return t("name",{number:function(e){var t=Math.abs(e);return t>=IK?kU(e):t<=TK?kU(e)*function(e){var t,n=e*e,r=EK[0][4]*n,a=n;for(t=0;t<3;t+=1)r=(r+EK[0][t])*n,a=(a+AK[0][t])*n;return e*(r+EK[0][3])/(a+AK[0][3])}(t):t<=4?kU(e)*(1-function(e){var t,n=EK[1][8]*e,r=e;for(t=0;t<7;t+=1)n=(n+EK[1][t])*e,r=(r+AK[1][t])*e;var a=(n+EK[1][7])/(r+AK[1][7]),i=parseInt(16*e)/16,s=(e-i)*(e+i);return Math.exp(-i*i)*Math.exp(-s)*a}(t)):kU(e)*(1-function(e){var t,n=1/(e*e),r=EK[2][5]*n,a=n;for(t=0;t<4;t+=1)r=(r+EK[2][t])*n,a=(a+AK[2][t])*n;var i=n*(r+EK[2][4])/(a+AK[2][4]);i=(CK-i)/e;var s=(e-(n=parseInt(16*e)/16))*(e+n);return Math.exp(-n*n)*Math.exp(-s)*i}(t))},"Array | Matrix":t.referToSelf((e=>t=>AV(t,e)))})}))),TK=.46875,CK=.5641895835477563,EK=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,2.1531153547440383e-8],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],AK=[[23.601290952344122,244.02463793444417,1282.6165260773723,2844.236833439171],[15.744926110709835,117.6939508913125,537.1811018620099,1621.3895745666903,3290.7992357334597,4362.619090143247,3439.3676741437216,1230.3393548037495],[2.568520192289822,1.8729528499234604,.5279051029514285,.06051834131244132,.0023352049762686918]],IK=Math.pow(2,53),LK=_U("exp",["typed"],(e=>{var{typed:t}=e;return t("exp",{number:UV,Complex:function(e){return e.exp()},BigNumber:function(e){return e.exp()}})})),FK="expm1",$K=_U(FK,["typed","Complex"],(e=>{var{typed:t,Complex:n}=e;return t(FK,{number:qV,Complex:function(e){var t=Math.exp(e.re);return new n(t*Math.cos(e.im)-1,t*Math.sin(e.im))},BigNumber:function(e){return e.exp().minus(1)}})})),OK=_U("filter",["typed"],(e=>{var{typed:t}=e;return t("filter",{"Array, function":RK,"Matrix, function":function(e,t){return e.create(RK(e.toArray(),t))},"Array, RegExp":nV,"Matrix, RegExp":function(e,t){return e.create(nV(e.toArray(),t))}})}));function RK(e,t){var n=XU(t);return tV(e,(function(e,r,a){return 1===n?t(e):2===n?t(e,[r]):t(e,[r],a)}))}var YK="forEach",BK=_U(YK,["typed"],(e=>{var{typed:t}=e;return t(YK,{"Array, function":zK,"Matrix, function":function(e,t){return e.forEach(t)}})}));function zK(e,t){var n=XU(t);!function r(a,i){Array.isArray(a)?eV(a,(function(e,t){r(e,i.concat(t))})):1===n?t(a):2===n?t(a,i):t(a,i,e)}(e,[])}var PK="format",HK=_U(PK,["typed"],(e=>{var{typed:t}=e;return t(PK,{any:IW,"any, Object | function | number":IW})})),jK="getMatrixDataType",UK=_U(jK,["typed"],(e=>{var{typed:t}=e;return t(jK,{Array:function(e){return sV(e,wH)},Matrix:function(e){return e.getDataType()}})})),qK=_U("hex",["typed","format"],(e=>{var{typed:t,format:n}=e;return t("hex",{"number | BigNumber":function(e){return n(e,{notation:"hex"})},"number | BigNumber, number":function(e,t){return n(e,{notation:"hex",wordSize:t})}})})),WK=_U("im",["typed"],(e=>{var{typed:t}=e;return t("im",{number:()=>0,"BigNumber | Fraction":e=>e.mul(0),Complex:e=>e.im,"Array | Matrix":t.referToSelf((e=>t=>AV(t,e)))})})),VK="isInteger",GK=_U(VK,["typed"],(e=>{var{typed:t}=e;return t(VK,{number:SU,BigNumber:function(e){return e.isInt()},Fraction:function(e){return 1===e.d&&isFinite(e.n)},"Array | Matrix":t.referToSelf((e=>t=>AV(t,e)))})})),KK="number";function JK(e){return e<0}function XK(e){return e>0}function ZK(e){return 0===e}function QK(e){return Number.isNaN(e)}JK.signature=KK,XK.signature=KK,ZK.signature=KK,QK.signature=KK;var eJ="isNegative",tJ=_U(eJ,["typed"],(e=>{var{typed:t}=e;return t(eJ,{number:JK,BigNumber:function(e){return e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s<0},Unit:t.referToSelf((e=>n=>t.find(e,n.valueType())(n.value))),"Array | Matrix":t.referToSelf((e=>t=>AV(t,e)))})})),nJ="isPositive",rJ=_U(nJ,["typed"],(e=>{var{typed:t}=e;return t(nJ,{number:XK,BigNumber:function(e){return!e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s>0&&e.n>0},Unit:t.referToSelf((e=>n=>t.find(e,n.valueType())(n.value))),"Array | Matrix":t.referToSelf((e=>t=>AV(t,e)))})})),aJ="isZero",iJ=_U(aJ,["typed"],(e=>{var{typed:t}=e;return t(aJ,{number:ZK,BigNumber:function(e){return e.isZero()},Complex:function(e){return 0===e.re&&0===e.im},Fraction:function(e){return 1===e.d&&0===e.n},Unit:t.referToSelf((e=>n=>t.find(e,n.valueType())(n.value))),"Array | Matrix":t.referToSelf((e=>t=>AV(t,e)))})}));function sJ(e){var t;if(SU(e))return e<=0?isFinite(e)?1/0:NaN:e>171?1/0:oK(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*sJ(1-e));if(e>=171.35)return 1/0;if(e>85){var n=e*e,r=n*e,a=r*e,i=a*e;return Math.sqrt(2*Math.PI/e)*Math.pow(e/Math.E,e)*(1+1/(12*e)+1/(288*n)-139/(51840*r)-571/(2488320*a)+163879/(209018880*i)+5246819/(75246796800*i*e))}--e,t=uJ[0];for(var s=1;s=1;r--)n+=cJ[r]/(e+r);return lJ+(e+.5)*Math.log(t)-t+Math.log(n)}pJ.signature="number";var dJ="lgamma",hJ=_U(dJ,["Complex","typed"],(e=>{var{Complex:t,typed:n}=e,r=[-.029550653594771242,.00641025641025641,-.0019175269175269176,.0008417508417508417,-.0005952380952380953,.0007936507936507937,-.002777777777777778,.08333333333333333];return n(dJ,{number:pJ,Complex:function e(n){if(n.isNaN())return new t(NaN,NaN);if(0===n.im)return new t(pJ(n.re),0);if(n.re>=7||Math.abs(n.im)>=7)return a(n);if(n.re<=.1){var r=(u=6.283185307179586,(!0^((l=n.im)>0||!(l<0)&&1/l==1/0)?-u:u)*Math.floor(.5*n.re+.25)),s=n.mul(Math.PI).sin().log(),o=e(new t(1-n.re,-n.im));return new t(1.1447298858494002,r).sub(s).sub(o)}return n.im>=0?i(n):i(n.conjugate()).conjugate();var u,l},BigNumber:function(){throw new Error("mathjs doesn't yet provide an implementation of the algorithm lgamma for BigNumber")}});function a(e){for(var n=e.sub(.5).mul(e.log()).sub(e).add(lJ),a=new t(1,0).div(e),i=a.div(e),s=r[0],o=r[1],u=2*i.re,l=i.re*i.re+i.im*i.im,c=2;c<8;c++){var p=o;o=-l*s+r[c],s=u*s+p}var d=a.mul(i.mul(s).add(o));return n.add(d)}function i(e){var n=0,r=0,i=e;for(e=e.add(1);e.re<=7;){var s=(i=i.mul(e)).im<0?1:0;0!==s&&0===r&&n++,r=s,e=e.add(1)}return a(e).sub(i.log()).sub(new t(0,2*n*Math.PI*1))}})),fJ="log10",mJ=_U(fJ,["typed","config","Complex"],(e=>{var{typed:t,config:n,Complex:r}=e;return t(fJ,{number:function(e){return e>=0||n.predictable?GV(e):new r(e,0).log().div(Math.LN10)},Complex:function(e){return new r(e).log().div(Math.LN10)},BigNumber:function(e){return!e.isNegative()||n.predictable?e.log():new r(e.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":t.referToSelf((e=>t=>AV(t,e)))})})),gJ="log2",yJ=_U(gJ,["typed","config","Complex"],(e=>{var{typed:t,config:n,Complex:r}=e;return t(gJ,{number:function(e){return e>=0||n.predictable?KV(e):a(new r(e,0))},Complex:a,BigNumber:function(e){return!e.isNegative()||n.predictable?e.log(2):a(new r(e.toNumber(),0))},"Array | Matrix":t.referToSelf((e=>t=>AV(t,e)))});function a(e){var t=Math.sqrt(e.re*e.re+e.im*e.im);return new r(Math.log2?Math.log2(t):Math.log(t)/Math.LN2,Math.atan2(e.im,e.re)/Math.LN2)}})),bJ=_U("map",["typed"],(e=>{var{typed:t}=e;return t("map",{"Array, function":vJ,"Matrix, function":function(e,t){return e.map(t)}})}));function vJ(e,t){var n=XU(t);return function r(a,i){if(Array.isArray(a))return a.map((function(e,t){return r(e,i.concat(t))}));try{return 1===n?t(a):2===n?t(a,i):t(a,i,e)}catch(t){if(t instanceof TypeError&&"data"in t&&"wrongType"===t.data.category){var s="map attempted to call '".concat(t.data.fn,"(").concat(a),o=JSON.stringify(i);throw 2===n?s+=","+o:1!==n&&(s+=",".concat(o,",").concat(e)),s+=")' but argument ".concat(t.data.index+1," of type "),s+="".concat(t.data.actual," does not match expected type "),s+=t.data.expected.join(" or "),new TypeError(s)}throw t}}(e,[])}var xJ=_U("multiplyScalar",["typed"],(e=>{var{typed:t}=e;return t("multiplyScalar",{"number, number":BV,"Complex, Complex":function(e,t){return e.mul(t)},"BigNumber, BigNumber":function(e,t){return e.times(t)},"Fraction, Fraction":function(e,t){return e.mul(t)},"number | Fraction | BigNumber | Complex, Unit":(e,t)=>t.multiply(e),"Unit, number | Fraction | BigNumber | Complex | Unit":(e,t)=>e.multiply(t)})})),_J="number, number";function wJ(e){return!e}function DJ(e,t){return!(!e&&!t)}function NJ(e,t){return!!e!=!!t}function MJ(e,t){return!(!e||!t)}wJ.signature="number",DJ.signature=_J,NJ.signature=_J,MJ.signature=_J;var SJ=_U("not",["typed"],(e=>{var{typed:t}=e;return t("not",{"null | undefined":()=>!0,number:wJ,Complex:function(e){return 0===e.re&&0===e.im},BigNumber:function(e){return e.isZero()||e.isNaN()},Unit:t.referToSelf((e=>n=>t.find(e,n.valueType())(n.value))),"Array | Matrix":t.referToSelf((e=>t=>AV(t,e)))})})),kJ=_U("number",["typed"],(e=>{var{typed:t}=e,n=t("number",{"":function(){return 0},number:function(e){return e},string:function(e){if("NaN"===e)return NaN;var t=function(e){var t=e.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);return t?{input:e,radix:{"0b":2,"0o":8,"0x":16}[t[1]],integerPart:t[2],fractionalPart:t[3]}:null}(e);if(t)return function(e){for(var t=parseInt(e.integerPart,e.radix),n=0,r=0;r2**n-1)throw new SyntaxError('String "'.concat(e,'" is out of range'));a>=2**(n-1)&&(a-=2**n)}return a},BigNumber:function(e){return e.toNumber()},Fraction:function(e){return e.valueOf()},Unit:function(e){throw new Error("Second argument with valueless unit expected")},null:function(e){return 0},"Unit, string | Unit":function(e,t){return e.toNumber(t)},"Array | Matrix":t.referToSelf((e=>t=>AV(t,e)))});return n.fromJSON=function(e){return parseFloat(e.value)},n})),TJ=_U("oct",["typed","format"],(e=>{var{typed:t,format:n}=e;return t("oct",{"number | BigNumber":function(e){return n(e,{notation:"oct"})},"number | BigNumber, number":function(e,t){return n(e,{notation:"oct",wordSize:t})}})})),CJ=Ep(Date.now());function EJ(e){var t,n;return t=null===(n=e)?CJ:Ep(String(n)),function(){return t()}}var AJ="pickRandom",IJ=_U(AJ,["typed","config","?on"],(e=>{var{typed:t,config:n,on:r}=e,a=EJ(n.randomSeed);return r&&r("config",(function(e,t){e.randomSeed!==t.randomSeed&&(a=EJ(e.randomSeed))})),t(AJ,{"Array | Matrix":function(e){return i(e,{})},"Array | Matrix, Object":function(e,t){return i(e,t)},"Array | Matrix, number":function(e,t){return i(e,{number:t})},"Array | Matrix, Array | Matrix":function(e,t){return i(e,{weights:t})},"Array | Matrix, Array | Matrix, number":function(e,t,n){return i(e,{number:n,weights:t})},"Array | Matrix, number, Array | Matrix":function(e,t,n){return i(e,{number:t,weights:n})}});function i(e,t){var{number:n,weights:r,elementWise:i=!0}=t,s=void 0===n;s&&(n=1);var o=UP(e)?e.create:UP(r)?r.create:null;e=e.valueOf(),r&&(r=r.valueOf()),!0===i&&(e=ZW(e),r=ZW(r));var u=0;if(void 0!==r){if(r.length!==e.length)throw new Error("Weights must have the same length as possibles");for(var l=0,c=r.length;l{var{typed:t}=e;return t(LJ,{"string, Object | Array":$J,"string, Object | Array, number | Object":$J})}));function $J(e,t,n){return e.replace(/\$([\w.]+)/g,(function(e,r){for(var a=r.split("."),i=t[a.shift()];a.length&&void 0!==i;){var s=a.shift();i=s?i[s]:i+"."}return void 0!==i?HP(i)?i:IW(i,n):e}))}function OJ(e,t){var n=[];if((e=e.slice(0)).length>1)for(var r=0,a=e.shift();r{var{typed:t,config:n,on:r}=e,a=EJ(n.randomSeed);return r&&r("config",(function(e,t){e.randomSeed!==t.randomSeed&&(a=EJ(e.randomSeed))})),t(RJ,{"":()=>s(0,1),number:e=>s(0,e),"number, number":(e,t)=>s(e,t),"Array | Matrix":e=>i(e,0,1),"Array | Matrix, number":(e,t)=>i(e,0,t),"Array | Matrix, number, number":(e,t,n)=>i(e,t,n)});function i(e,t,n){var r=OJ(e.valueOf(),(()=>s(t,n)));return UP(e)?e.create(r):r}function s(e,t){return e+a()*(t-e)}})),BJ=_U("re",["typed"],(e=>{var{typed:t}=e;return t("re",{"number | BigNumber | Fraction":e=>e,Complex:e=>e.re,"Array | Matrix":t.referToSelf((e=>t=>AV(t,e)))})})),zJ=_U("sec",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t("sec",{number:wG,Complex:e=>e.sec(),BigNumber:e=>new n(1).div(e.cos())},vK({typed:t}))})),PJ="sign",HJ=_U(PJ,["typed","BigNumber","Fraction","complex"],(e=>{var{typed:t,BigNumber:n,complex:r,Fraction:a}=e;return t(PJ,{number:ZV,Complex:function(e){return 0===e.im?r(ZV(e.re)):e.sign()},BigNumber:function(e){return new n(e.cmp(0))},Fraction:function(e){return new a(e.s,1)},"Array | Matrix":t.referToSelf((e=>t=>AV(t,e,!0))),Unit:t.referToSelf((e=>n=>{if(!n._isDerived()&&0!==n.units[0].unit.offset)throw new TypeError("sign is ambiguous for units with offset");return t.find(e,n.valueType())(n.value)}))})})),jJ=_U("sin",["typed"],(e=>{var{typed:t}=e,n=vK({typed:t});return t("sin",{number:Math.sin,"Complex | BigNumber":e=>e.sin()},n)})),UJ=_U("SparseMatrix",["typed","equalScalar","Matrix"],(e=>{var{typed:t,equalScalar:n,Matrix:r}=e;function a(e,t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!HP(t))throw new Error("Invalid datatype: "+t);if(UP(e))!function(e,t,n){"SparseMatrix"===t.type?(e._values=t._values?DH(t._values):void 0,e._index=DH(t._index),e._ptr=DH(t._ptr),e._size=DH(t._size),e._datatype=n||t._datatype):i(e,t.valueOf(),n||t._datatype)}(this,e,t);else if(e&&jP(e.index)&&jP(e.ptr)&&jP(e.size))this._values=e.values,this._index=e.index,this._ptr=e.ptr,this._size=e.size,this._datatype=t||e.datatype;else if(jP(e))i(this,e,t);else{if(e)throw new TypeError("Unsupported type of data ("+wH(e)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=t}}function i(e,r,a){e._values=[],e._index=[],e._ptr=[],e._datatype=a;var i=r.length,s=0,o=n,u=0;if(HP(a)&&(o=t.find(n,[a,a])||n,u=t.convert(0,a)),i>0){var l=0;do{e._ptr.push(e._index.length);for(var c=0;c");if(1===i.length)t.dimension(0).forEach((function(t,a){HW(t),e.set([t,0],n[a[0]],r)}));else{var l=t.dimension(0),c=t.dimension(1);l.forEach((function(t,a){HW(t),c.forEach((function(i,s){HW(i),e.set([t,i],n[a[0]][s[0]],r)}))}))}}return e}function u(e,t,n,r){if(n-t==0)return n;for(var a=t;af){for(c=f;ch){if(d){var m=0;for(c=0;cr-1&&(e._values.splice(p,1),e._index.splice(p,1),y++)}e._ptr[c]=e._values.length}return e._size[0]=r,e._size[1]=a,e}function p(e,t,n,r,a){var i,s,o=r[0],u=r[1],l=[];for(i=0;io-1||s>p-1)&&(c(this,Math.max(i+1,o),Math.max(s+1,p),a),o=this._size[0],p=this._size[1]),HW(i,o),HW(s,p);var f=u(i,this._ptr[s],this._ptr[s+1],this._index);return fArray.isArray(e)&&1===e.length?e[0]:e));if(2!==r.length)throw new Error("Only two dimensions matrix are supported");return r.forEach((function(e){if(!RP(e)||!SU(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+IW(r)+")")})),c(n?this.clone():this,r[0],r[1],t)},a.prototype.reshape=function(e,t){if(!jP(e))throw new TypeError("Array expected");if(2!==e.length)throw new Error("Sparse matrices can only be reshaped in two dimensions");e.forEach((function(t){if(!RP(t)||!SU(t)||t<=-2||0===t)throw new TypeError("Invalid size, must contain positive integers or -1 (size: "+IW(e)+")")}));var n=this._size[0]*this._size[1];if(n!==(e=WW(e,n))[0]*e[1])throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var r=t?this.clone():this;if(this._size[0]===e[0]&&this._size[1]===e[1])return r;for(var a=[],i=0;i=0&&x<=i&&m(e._values[v],x-0,g-0)}else{for(var _={},w=y;w "+(this._values?IW(this._values[u],e):"X");return a},a.prototype.toString=function(){return IW(this.toArray())},a.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},a.prototype.diagonal=function(e){if(e){if(YP(e)&&(e=e.toNumber()),!RP(e)||!SU(e))throw new TypeError("The parameter k must be an integer number")}else e=0;var t=e>0?e:0,n=e<0?-e:0,r=this._size[0],i=this._size[1],s=Math.min(r-n,i-t),o=[],u=[],l=[];l[0]=0;for(var c=t;c0?i:0,d=i<0?-i:0,h=e[0],f=e[1],m=Math.min(h-d,f-p);if(jP(r)){if(r.length!==m)throw new Error("Invalid value array length");c=function(e){return r[e]}}else if(UP(r)){var g=r.size();if(1!==g.length||g[0]!==m)throw new Error("Invalid matrix length");c=function(e){return r.get([e])}}else c=function(){return r};for(var y=[],b=[],v=[],x=0;x=0&&_=l||a[p]!==t)){var h=r?r[c]:void 0;a.splice(p,0,t),r&&r.splice(p,0,h),a.splice(p<=c?c+1:c,1),r&&r.splice(p<=c?c+1:c,1)}else if(p=l||a[c]!==e)){var f=r?r[p]:void 0;a.splice(c,0,e),r&&r.splice(c,0,f),a.splice(c<=p?p+1:p,1),r&&r.splice(c<=p?p+1:p,1)}}},a}),{isClass:!0}),qJ="splitUnit",WJ=_U(qJ,["typed"],(e=>{var{typed:t}=e;return t(qJ,{"Unit, Array":function(e,t){return e.splitUnit(t)}})})),VJ="square",GJ=_U(VJ,["typed"],(e=>{var{typed:t}=e;return t(VJ,{number:QV,Complex:function(e){return e.mul(e)},BigNumber:function(e){return e.times(e)},Fraction:function(e){return e.mul(e)},Unit:function(e){return e.pow(2)}})})),KJ="string",JJ=_U(KJ,["typed"],(e=>{var{typed:t}=e;return t(KJ,{"":function(){return""},number:FU,null:function(e){return"null"},boolean:function(e){return e+""},string:function(e){return e},"Array | Matrix":t.referToSelf((e=>t=>AV(t,e))),any:function(e){return String(e)}})})),XJ=_U("tan",["typed"],(e=>{var{typed:t}=e,n=vK({typed:t});return t("tan",{number:Math.tan,"Complex | BigNumber":e=>e.tan()},n)})),ZJ="typeOf",QJ=_U(ZJ,["typed"],(e=>{var{typed:t}=e;return t(ZJ,{any:wH})})),eX="acosh",tX=_U(eX,["typed","config","Complex"],(e=>{var{typed:t,config:n,Complex:r}=e;return t(eX,{number:function(e){return e>=1||n.predictable?lG(e):e<=-1?new r(Math.log(Math.sqrt(e*e-1)-e),Math.PI):new r(e,0).acosh()},Complex:function(e){return e.acosh()},BigNumber:function(e){return e.acosh()}})})),nX="acsch",rX=_U(nX,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t(nX,{number:hG,Complex:function(e){return e.acsch()},BigNumber:function(e){return new n(1).div(e).asinh()}})})),aX="apply",iX=_U(aX,["typed","isInteger"],(e=>{var{typed:t,isInteger:n}=e;return t(aX,{"Array | Matrix, number | BigNumber, function":function(e,t,r){if(!n(t))throw new TypeError("Integer number expected for dimension");var a=Array.isArray(e)?BW(e):e.size();if(t<0||t>=a.length)throw new YW(t,a.length);return UP(e)?e.create(sX(e.valueOf(),t,r)):sX(e,t,r)}})}));function sX(e,t,n){var r,a,i;if(t<=0){if(Array.isArray(e[0])){for(i=function(e){var t,n,r=e.length,a=e[0].length,i=[];for(n=0;n{var{typed:t,config:n,Complex:r,BigNumber:a}=e;return t(oX,{number:function(e){return e<=-1||e>=1||n.predictable?fG(e):new r(e,0).asec()},Complex:function(e){return e.asec()},BigNumber:function(e){return new a(1).div(e).acos()}})})),lX=_U("bin",["typed","format"],(e=>{var{typed:t,format:n}=e;return t("bin",{"number | BigNumber":function(e){return n(e,{notation:"bin"})},"number | BigNumber, number":function(e,t){return n(e,{notation:"bin",wordSize:t})}})})),cX="combinationsWithRep",pX=_U(cX,["typed"],(e=>{var{typed:t}=e;return t(cX,{"number, number":function(e,t){if(!SU(e)||e<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(!SU(t)||t<0)throw new TypeError("Positive integer value expected in function combinationsWithRep");if(e<1)throw new TypeError("k must be less than or equal to n + k - 1");return t{var{typed:t}=e,n=vK({typed:t});return t("cos",{number:Math.cos,"Complex | BigNumber":e=>e.cos()},n)})),fX="csch",mX=_U(fX,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t(fX,{number:_G,Complex:e=>e.csch(),BigNumber:e=>new n(1).div(e.sinh())})})),gX="isNaN",yX=_U(gX,["typed"],(e=>{var{typed:t}=e;return t(gX,{number:QK,BigNumber:function(e){return e.isNaN()},Fraction:function(e){return!1},Complex:function(e){return e.isNaN()},Unit:function(e){return Number.isNaN(e.value)},"Array | Matrix":function(e){return AV(e,Number.isNaN)}})})),bX="isPrime",vX=_U(bX,["typed"],(e=>{var{typed:t}=e;return t(bX,{number:function(e){if(0*e!=0)return!1;if(e<=3)return e>1;if(e%2==0||e%3==0)return!1;for(var t=5;t*t<=e;t+=6)if(e%t==0||e%(t+2)==0)return!1;return!0},BigNumber:function(e){if(0*e.toNumber()!=0)return!1;if(e.lte(3))return e.gt(1);if(e.mod(2).eq(0)||e.mod(3).eq(0))return!1;if(e.lt(Math.pow(2,32))){for(var t=e.toNumber(),n=5;n*n<=t;n+=6)if(t%n==0||t%(n+2)==0)return!1;return!0}function r(e,t,n){for(var r=1;!t.eq(0);)t.mod(2).eq(0)?(t=t.div(2),e=e.mul(e).mod(n)):(t=t.sub(1),r=e.mul(r).mod(n));return r}for(var a=e.constructor.clone({precision:2*e.toFixed(0).length}),i=0,s=(e=new a(e)).sub(1);s.mod(2).eq(0);)s=s.div(2),i+=1;var o=null;if(e.lt("3317044064679887385961981"))o=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter((t=>tt=>AV(t,e)))})})),xX="randomInt",_X=_U(xX,["typed","config","?on"],(e=>{var{typed:t,config:n,on:r}=e,a=EJ(n.randomSeed);return r&&r("config",(function(e,t){e.randomSeed!==t.randomSeed&&(a=EJ(e.randomSeed))})),t(xX,{"":()=>s(0,1),number:e=>s(0,e),"number, number":(e,t)=>s(e,t),"Array | Matrix":e=>i(e,0,1),"Array | Matrix, number":(e,t)=>i(e,0,t),"Array | Matrix, number, number":(e,t,n)=>i(e,t,n)});function i(e,t,n){var r=OJ(e.valueOf(),(()=>s(t,n)));return UP(e)?e.create(r):r}function s(e,t){return Math.floor(e+a()*(t-e))}})),wX="sech",DX=_U(wX,["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t(wX,{number:DG,Complex:e=>e.sech(),BigNumber:e=>new n(1).div(e.cosh())})})),NX="sinh",MX=_U(NX,["typed"],(e=>{var{typed:t}=e;return t(NX,{number:NG,"Complex | BigNumber":e=>e.sinh()})})),SX="sparse",kX=_U(SX,["typed","SparseMatrix"],(e=>{var{typed:t,SparseMatrix:n}=e;return t(SX,{"":function(){return new n([])},string:function(e){return new n([],e)},"Array | Matrix":function(e){return new n(e)},"Array | Matrix, string":function(e,t){return new n(e,t)}})})),TX=_U("sqrt",["config","typed","Complex"],(e=>{var{config:t,typed:n,Complex:r}=e;return n("sqrt",{number:a,Complex:function(e){return e.sqrt()},BigNumber:function(e){return!e.isNegative()||t.predictable?e.sqrt():a(e.toNumber())},Unit:function(e){return e.pow(.5)}});function a(e){return isNaN(e)?NaN:e>=0||t.predictable?Math.sqrt(e):new r(e,0).sqrt()}})),CX=_U("tanh",["typed"],(e=>{var{typed:t}=e;return t("tanh",{number:VU,"Complex | BigNumber":e=>e.tanh()})})),EX="unaryMinus",AX=_U(EX,["typed"],(e=>{var{typed:t}=e;return t(EX,{number:zV,"Complex | BigNumber | Fraction":e=>e.neg(),Unit:t.referToSelf((e=>n=>{var r=n.clone();return r.value=t.find(e,r.valueType())(n.value),r})),"Array | Matrix":t.referToSelf((e=>t=>AV(t,e,!0)))})})),IX="acoth",LX=_U(IX,["typed","config","Complex","BigNumber"],(e=>{var{typed:t,config:n,Complex:r,BigNumber:a}=e;return t(IX,{number:function(e){return e>=1||e<=-1||n.predictable?pG(e):new r(e,0).acoth()},Complex:function(e){return e.acoth()},BigNumber:function(e){return new a(1).div(e).atanh()}})})),FX=_U("cot",["typed","BigNumber"],(e=>{var{typed:t,BigNumber:n}=e;return t("cot",{number:bG,Complex:e=>e.cot(),BigNumber:e=>new n(1).div(e.tan())},vK({typed:t}))})),$X=_U("fraction",["typed","Fraction"],(e=>{var{typed:t,Fraction:n}=e;return t("fraction",{number:function(e){if(!isFinite(e)||isNaN(e))throw new Error(e+" cannot be represented as a fraction");return new n(e)},string:function(e){return new n(e)},"number, number":function(e,t){return new n(e,t)},null:function(e){return new n(0)},BigNumber:function(e){return new n(e.toString())},Fraction:function(e){return e},Object:function(e){return new n(e)},"Array | Matrix":t.referToSelf((e=>t=>AV(t,e)))})})),OX="isNumeric",RX=_U(OX,["typed"],(e=>{var{typed:t}=e;return t(OX,{"number | BigNumber | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":t.referToSelf((e=>t=>AV(t,e)))})})),YX="matrix",BX=_U(YX,["typed","Matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,Matrix:n,DenseMatrix:r,SparseMatrix:a}=e;return t(YX,{"":function(){return i([])},string:function(e){return i([],e)},"string, string":function(e,t){return i([],e,t)},Array:function(e){return i(e)},Matrix:function(e){return i(e,e.storage())},"Array | Matrix, string":i,"Array | Matrix, string, string":i});function i(e,t,n){if("dense"===t||"default"===t||void 0===t)return new r(e,n);if("sparse"===t)return new a(e,n);throw new TypeError("Unknown matrix type "+JSON.stringify(t)+".")}})),zX="matrixFromFunction",PX=_U(zX,["typed","matrix","isZero"],(e=>{var{typed:t,matrix:n,isZero:r}=e;return t(zX,{"Array | Matrix, function, string, string":function(e,t,n,r){return a(e,t,n,r)},"Array | Matrix, function, string":function(e,t,n){return a(e,t,n)},"Matrix, function":function(e,t){return a(e,t,"dense")},"Array, function":function(e,t){return a(e,t,"dense").toArray()},"Array | Matrix, string, function":function(e,t,n){return a(e,n,t)},"Array | Matrix, string, string, function":function(e,t,n,r){return a(e,r,t,n)}});function a(e,t,a,i){var s;return(s=void 0!==i?n(a,i):n(a)).resize(e),s.forEach((function(e,n){var a=t(n);r(a)||s.set(n,a)})),s}})),HX=_U("matAlgo02xDS0",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:n}=e;return function(e,r,a,i){var s=e._data,o=e._size,u=e._datatype,l=r._values,c=r._index,p=r._ptr,d=r._size,h=r._datatype;if(o.length!==d.length)throw new RW(o.length,d.length);if(o[0]!==d[0]||o[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+d+")");if(!l)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var f,m=o[0],g=o[1],y=n,b=0,v=a;"string"==typeof u&&u===h&&(f=u,y=t.find(n,[f,f]),b=t.convert(0,f),v=t.find(a,[f,f]));for(var x=[],_=[],w=[],D=0;D{var{typed:t}=e;return function(e,n,r,a){var i=e._data,s=e._size,o=e._datatype,u=n._values,l=n._index,c=n._ptr,p=n._size,d=n._datatype;if(s.length!==p.length)throw new RW(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");if(!u)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h,f=s[0],m=s[1],g=0,y=r;"string"==typeof o&&o===d&&(h=o,g=t.convert(0,h),y=t.find(r,[h,h]));for(var b=[],v=0;v{var{typed:t,equalScalar:n}=e;return function(e,r,a){var i=e._values,s=e._index,o=e._ptr,u=e._size,l=e._datatype,c=r._values,p=r._index,d=r._ptr,h=r._size,f=r._datatype;if(u.length!==h.length)throw new RW(u.length,h.length);if(u[0]!==h[0]||u[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+h+")");var m,g=u[0],y=u[1],b=n,v=0,x=a;"string"==typeof l&&l===f&&(m=l,b=t.find(n,[m,m]),v=t.convert(0,m),x=t.find(a,[m,m]));var _,w,D,N,M=i&&c?[]:void 0,S=[],k=[],T=M?[]:void 0,C=M?[]:void 0,E=[],A=[];for(w=0;w{var{typed:t,equalScalar:n}=e;return function(e,r,a,i){var s=e._values,o=e._index,u=e._ptr,l=e._size,c=e._datatype;if(!s)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p,d=l[0],h=l[1],f=n,m=0,g=a;"string"==typeof c&&(p=c,f=t.find(n,[p,p]),m=t.convert(0,p),r=t.convert(r,p),g=t.find(a,[p,p]));for(var y=[],b=[],v=[],x=0;x{var{typed:t,DenseMatrix:n}=e;return function(e,r,a,i){var s=e._values,o=e._index,u=e._ptr,l=e._size,c=e._datatype;if(!s)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p,d=l[0],h=l[1],f=a;"string"==typeof c&&(p=c,r=t.convert(r,p),f=t.find(a,[p,p]));for(var m=[],g=[],y=[],b=0;b{var{typed:t}=e;return function(e,r,a){var i,s=e._data,o=e._size,u=e._datatype,l=r._data,c=r._size,p=r._datatype,d=[];if(o.length!==c.length)throw new RW(o.length,c.length);for(var h=0;h0?n(f,0,d,d[0],s,l):[];return e.createDenseMatrix({data:m,size:d,datatype:i})};function n(e,t,r,a,i,s){var o=[];if(t===r.length-1)for(var u=0;u{var{typed:t}=e;return function(e,r,a,i){var s,o=e._data,u=e._size,l=e._datatype,c=a;"string"==typeof l&&(s=l,r=t.convert(r,s),c=t.find(a,[s,s]));var p=u.length>0?n(c,0,u,u[0],o,r,i):[];return e.createDenseMatrix({data:p,size:DH(u),datatype:s})};function n(e,t,r,a,i,s,o){var u=[];if(t===r.length-1)for(var l=0;l{var{typed:t,matrix:n}=e,r=VX({typed:t}),a=GX({typed:t});return function(e){var i,s=e.elop,o=e.SD||e.DS;s?(i={"DenseMatrix, DenseMatrix":(e,t)=>r(e,t,s),"Array, Array":(e,t)=>r(n(e),n(t),s).valueOf(),"Array, DenseMatrix":(e,t)=>r(n(e),t,s),"DenseMatrix, Array":(e,t)=>r(e,n(t),s)},e.SS&&(i["SparseMatrix, SparseMatrix"]=(t,n)=>e.SS(t,n,s,!1)),e.DS&&(i["DenseMatrix, SparseMatrix"]=(t,n)=>e.DS(t,n,s,!1),i["Array, SparseMatrix"]=(t,r)=>e.DS(n(t),r,s,!1)),o&&(i["SparseMatrix, DenseMatrix"]=(e,t)=>o(t,e,s,!0),i["SparseMatrix, Array"]=(e,t)=>o(n(t),e,s,!0))):(i={"DenseMatrix, DenseMatrix":t.referToSelf((e=>(t,n)=>r(t,n,e))),"Array, Array":t.referToSelf((e=>(t,a)=>r(n(t),n(a),e).valueOf())),"Array, DenseMatrix":t.referToSelf((e=>(t,a)=>r(n(t),a,e))),"DenseMatrix, Array":t.referToSelf((e=>(t,a)=>r(t,n(a),e)))},e.SS&&(i["SparseMatrix, SparseMatrix"]=t.referToSelf((t=>(n,r)=>e.SS(n,r,t,!1)))),e.DS&&(i["DenseMatrix, SparseMatrix"]=t.referToSelf((t=>(n,r)=>e.DS(n,r,t,!1))),i["Array, SparseMatrix"]=t.referToSelf((t=>(r,a)=>e.DS(n(r),a,t,!1)))),o&&(i["SparseMatrix, DenseMatrix"]=t.referToSelf((e=>(t,n)=>o(n,t,e,!0))),i["SparseMatrix, Array"]=t.referToSelf((e=>(t,r)=>o(n(r),t,e,!0)))));var u=e.scalar||"any";(e.Ds||e.Ss)&&(s?(i["DenseMatrix,"+u]=(e,t)=>a(e,t,s,!1),i[u+", DenseMatrix"]=(e,t)=>a(t,e,s,!0),i["Array,"+u]=(e,t)=>a(n(e),t,s,!1).valueOf(),i[u+", Array"]=(e,t)=>a(n(t),e,s,!0).valueOf()):(i["DenseMatrix,"+u]=t.referToSelf((e=>(t,n)=>a(t,n,e,!1))),i[u+", DenseMatrix"]=t.referToSelf((e=>(t,n)=>a(n,t,e,!0))),i["Array,"+u]=t.referToSelf((e=>(t,r)=>a(n(t),r,e,!1).valueOf())),i[u+", Array"]=t.referToSelf((e=>(t,r)=>a(n(r),t,e,!0).valueOf()))));var l=void 0!==e.sS?e.sS:e.Ss;return s?(e.Ss&&(i["SparseMatrix,"+u]=(t,n)=>e.Ss(t,n,s,!1)),l&&(i[u+", SparseMatrix"]=(e,t)=>l(t,e,s,!0))):(e.Ss&&(i["SparseMatrix,"+u]=t.referToSelf((t=>(n,r)=>e.Ss(n,r,t,!1)))),l&&(i[u+", SparseMatrix"]=t.referToSelf((e=>(t,n)=>l(n,t,e,!0))))),s&&s.signatures&&MH(i,s.signatures),i}})),JX=_U("mod",["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:a}=e,i=HX({typed:t,equalScalar:r}),s=jX({typed:t}),o=UX({typed:t,equalScalar:r}),u=qX({typed:t,equalScalar:r}),l=WX({typed:t,DenseMatrix:a});return t("mod",{"number, number":JV,"BigNumber, BigNumber":function(e,t){if(t.isNeg())throw new Error("Cannot calculate mod for a negative divisor");return t.isZero()?e:e.mod(t)},"Fraction, Fraction":function(e,t){if(t.compare(0)<0)throw new Error("Cannot calculate mod for a negative divisor");return e.compare(0)>=0?e.mod(t):e.mod(t).add(t).mod(t)}},KX({typed:t,matrix:n})({SS:o,DS:s,SD:i,Ss:u,sS:l}))})),XX=_U("matAlgo01xDSid",["typed"],(e=>{var{typed:t}=e;return function(e,n,r,a){var i=e._data,s=e._size,o=e._datatype,u=n._values,l=n._index,c=n._ptr,p=n._size,d=n._datatype;if(s.length!==p.length)throw new RW(s.length,p.length);if(s[0]!==p[0]||s[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+p+")");if(!u)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var h,f,m=s[0],g=s[1],y="string"==typeof o&&o===d?o:void 0,b=y?t.find(r,[y,y]):r,v=[];for(h=0;h{var{typed:t,equalScalar:n}=e;return function(e,r,a){var i=e._values,s=e._size,o=e._datatype,u=r._values,l=r._size,c=r._datatype;if(s.length!==l.length)throw new RW(s.length,l.length);if(s[0]!==l[0]||s[1]!==l[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+l+")");var p,d=s[0],h=s[1],f=n,m=0,g=a;"string"==typeof o&&o===c&&(p=o,f=t.find(n,[p,p]),m=t.convert(0,p),g=t.find(a,[p,p]));for(var y=i&&u?[]:void 0,b=[],v=[],x=y?[]:void 0,_=[],w=[],D=0;D{var{typed:t,matrix:n,equalScalar:r,BigNumber:a}=e,i=XX({typed:t}),s=HX({typed:t,equalScalar:r}),o=ZX({typed:t,equalScalar:r}),u=qX({typed:t,equalScalar:r}),l=KX({typed:t,matrix:n});function c(){throw new Error("Complex number not supported in function nthRoot. Use nthRoots instead.")}return t(QX,{number:XV,"number, number":XV,BigNumber:e=>p(e,new a(2)),"BigNumber, BigNumber":p,Complex:c,"Complex, number":c,Array:t.referTo("DenseMatrix,number",(e=>t=>e(n(t),2).valueOf())),DenseMatrix:t.referTo("DenseMatrix,number",(e=>t=>e(t,2))),SparseMatrix:t.referTo("SparseMatrix,number",(e=>t=>e(t,2))),"SparseMatrix, SparseMatrix":t.referToSelf((e=>(t,n)=>{if(1===n.density())return o(t,n,e);throw new Error("Root must be non-zero")})),"DenseMatrix, SparseMatrix":t.referToSelf((e=>(t,n)=>{if(1===n.density())return i(t,n,e,!1);throw new Error("Root must be non-zero")})),"Array, SparseMatrix":t.referTo("DenseMatrix,SparseMatrix",(e=>(t,r)=>e(n(t),r))),"number | BigNumber, SparseMatrix":t.referToSelf((e=>(t,n)=>{if(1===n.density())return u(n,t,e,!0);throw new Error("Root must be non-zero")}))},l({scalar:"number | BigNumber",SD:s,Ss:u,sS:!1}));function p(e,t){var n=a.precision,r=a.clone({precision:n+2}),i=new a(0),s=new r(1),o=t.isNegative();if(o&&(t=t.neg()),t.isZero())throw new Error("Root must be non-zero");if(e.isNegative()&&!t.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(e.isZero())return o?new r(1/0):0;if(!e.isFinite())return o?i:e;var u=e.abs().pow(s.div(t));return u=e.isNeg()?u.neg():u,new a((o?s.div(u):u).toPrecision(n))}}));function tZ(){throw new Error('No "bignumber" implementation available')}function nZ(){throw new Error('No "fraction" implementation available')}function rZ(){throw new Error('No "matrix" implementation available')}var aZ=_U("numeric",["number","?bignumber","?fraction"],(e=>{var{number:t,bignumber:n,fraction:r}=e,a={string:!0,number:!0,BigNumber:!0,Fraction:!0},i={number:e=>t(e),BigNumber:n?e=>n(e):tZ,Fraction:r?e=>r(e):nZ};return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"number",n=arguments.length>2?arguments[2]:void 0;if(void 0!==n)throw new SyntaxError("numeric() takes one or two arguments");var r=wH(e);if(!(r in a))throw new TypeError("Cannot convert "+e+' of type "'+r+'"; valid input types are '+Object.keys(a).join(", "));if(!(t in i))throw new TypeError("Cannot convert "+e+' to type "'+t+'"; valid output types are '+Object.keys(i).join(", "));return t===r?e:i[t](e)}})),iZ=_U("or",["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:a}=e,i=jX({typed:t}),s=UX({typed:t,equalScalar:r}),o=WX({typed:t,DenseMatrix:a}),u=KX({typed:t,matrix:n});return t("or",{"number, number":DJ,"Complex, Complex":function(e,t){return 0!==e.re||0!==e.im||0!==t.re||0!==t.im},"BigNumber, BigNumber":function(e,t){return!e.isZero()&&!e.isNaN()||!t.isZero()&&!t.isNaN()},"Unit, Unit":t.referToSelf((e=>(t,n)=>e(t.value||0,n.value||0)))},u({SS:s,DS:i,Ss:o}))}));function sZ(e,t,n){var r;return-1!==String(e).indexOf("Unexpected type")?(r=arguments.length>2?" (type: "+wH(n)+", value: "+JSON.stringify(n)+")":" (type: "+e.data.actual+")",new TypeError("Cannot calculate "+t+", unexpected type of argument"+r)):-1!==String(e).indexOf("complex numbers")?(r=arguments.length>2?" (type: "+wH(n)+", value: "+JSON.stringify(n)+")":"",new TypeError("Cannot calculate "+t+", no ordering relation is defined for complex numbers"+r)):e}var oZ="prod",uZ=_U(oZ,["typed","config","multiplyScalar","numeric"],(e=>{var{typed:t,config:n,multiplyScalar:r,numeric:a}=e;return t(oZ,{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("prod(A, dim) is not yet supported")},"...":function(e){return i(e)}});function i(e){var t;if(EV(e,(function(e){try{t=void 0===t?e:r(t,e)}catch(t){throw sZ(t,"prod",e)}})),"string"==typeof t&&(t=a(t,n.number)),void 0===t)throw new Error("Cannot calculate prod of an empty array");return t}})),lZ="reshape",cZ=_U(lZ,["typed","isInteger","matrix"],(e=>{var{typed:t,isInteger:n}=e;return t(lZ,{"Matrix, Array":function(e,t){return e.reshape(t)},"Array, Array":function(e,t){return t.forEach((function(e){if(!n(e))throw new TypeError("Invalid size for dimension: "+e)})),qW(e,t)}})})),pZ="size",dZ=_U(pZ,["typed","config","?matrix"],(e=>{var{typed:t,config:n,matrix:r}=e;return t(pZ,{Matrix:function(e){return e.create(e.size())},Array:BW,string:function(e){return"Array"===n.matrix?[e.length]:r([e.length])},"number | Complex | BigNumber | Unit | boolean | null":function(e){return"Array"===n.matrix?[]:r?r([]):rZ()}})})),hZ=_U("matAlgo07xSSf",["typed","DenseMatrix"],(e=>{var{typed:t,DenseMatrix:n}=e;return function(e,a,i){var s=e._size,o=e._datatype,u=a._size,l=a._datatype;if(s.length!==u.length)throw new RW(s.length,u.length);if(s[0]!==u[0]||s[1]!==u[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+u+")");var c,p,d,h=s[0],f=s[1],m=0,g=i;"string"==typeof o&&o===l&&(c=o,m=t.convert(0,c),g=t.find(i,[c,c]));var y=[];for(p=0;p{var{typed:t,config:n,matrix:r,DenseMatrix:a}=e,i=jX({typed:t}),s=hZ({typed:t,DenseMatrix:a}),o=WX({typed:t,DenseMatrix:a}),u=KX({typed:t,matrix:r}),l=NK({typed:t});return t(fZ,gZ({typed:t,config:n}),{"boolean, boolean":(e,t)=>e-1===e.compare(t),"Complex, Complex":function(e,t){throw new TypeError("No ordering relation is defined for complex numbers")}},l,u({SS:s,DS:i,Ss:o}))})),gZ=_U(fZ,["typed","config"],(e=>{var{typed:t,config:n}=e;return t(fZ,{"number, number":function(e,t){return e{var{typed:t,matrix:n}=e;return t(yZ,{Array:function(e){return GW(DH(e))},Matrix:function(e){var t=GW(e.toArray());return Array.isArray(t)?n(t):t},any:function(e){return DH(e)}})})),vZ="subset",xZ=_U(vZ,["typed","matrix"],(e=>{var{typed:t,matrix:n}=e;return t(vZ,{"Array, Index":function(e,t){var r=n(e).subset(t);return t.isScalar()?r:r.valueOf()},"Matrix, Index":function(e,t){return e.subset(t)},"Object, Index":DZ,"string, Index":_Z,"Array, Index, any":function(e,t,r){return n(DH(e)).subset(t,r,void 0).valueOf()},"Array, Index, any, any":function(e,t,r,a){return n(DH(e)).subset(t,r,a).valueOf()},"Matrix, Index, any":function(e,t,n){return e.clone().subset(t,n)},"Matrix, Index, any, any":function(e,t,n,r){return e.clone().subset(t,n,r)},"string, Index, string":wZ,"string, Index, string, string":wZ,"Object, Index, any":NZ})}));function _Z(e,t){if(!KP(t))throw new TypeError("Index expected");if(1!==t.size().length)throw new RW(t.size().length,1);var n=e.length;HW(t.min()[0],n),HW(t.max()[0],n);var r=t.dimension(0),a="";return r.forEach((function(t){a+=e.charAt(t)})),a}function wZ(e,t,n,r){if(!t||!0!==t.isIndex)throw new TypeError("Index expected");if(1!==t.size().length)throw new RW(t.size().length,1);if(void 0!==r){if("string"!=typeof r||1!==r.length)throw new TypeError("Single character expected as defaultValue")}else r=" ";var a=t.dimension(0);if(a.size()[0]!==n.length)throw new RW(a.size()[0],n.length);var i=e.length;HW(t.min()[0]),HW(t.max()[0]);for(var s=[],o=0;oi)for(var u=i-1,l=s.length;u{var{typed:t,DenseMatrix:n}=e;return function(e,r,a,i){var s=e._values,o=e._index,u=e._ptr,l=e._size,c=e._datatype;if(!s)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p,d=l[0],h=l[1],f=a;"string"==typeof c&&(p=c,r=t.convert(r,p),f=t.find(a,[p,p]));for(var m=[],g=[],y=[],b=0;b{var{typed:t,matrix:n,equalScalar:r,addScalar:a,unaryMinus:i,DenseMatrix:s}=e,o=XX({typed:t}),u=jX({typed:t}),l=UX({typed:t,equalScalar:r}),c=MZ({typed:t,DenseMatrix:s}),p=WX({typed:t,DenseMatrix:s}),d=KX({typed:t,matrix:n});return t(SZ,{"number, number":(e,t)=>e-t,"Complex, Complex":(e,t)=>e.sub(t),"BigNumber, BigNumber":(e,t)=>e.minus(t),"Fraction, Fraction":(e,t)=>e.sub(t),"Unit, Unit":t.referToSelf((e=>(n,r)=>{if(null===n.value)throw new Error("Parameter x contains a unit with undefined value");if(null===r.value)throw new Error("Parameter y contains a unit with undefined value");if(!n.equalBase(r))throw new Error("Units do not match");var a=n.clone();return a.value=t.find(e,[a.valueType(),r.valueType()])(a.value,r.value),a.fixPrefix=!1,a}))},d({SS:l,DS:o,SD:u,Ss:p,sS:c}))})),TZ=_U("to",["typed","matrix"],(e=>{var{typed:t,matrix:n}=e;return t("to",{"Unit, Unit | string":(e,t)=>e.to(t)},KX({typed:t,matrix:n})({Ds:!0}))})),CZ="transpose",EZ=_U(CZ,["typed","matrix"],(e=>{var{typed:t,matrix:n}=e;return t(CZ,{Array:e=>r(n(e)).valueOf(),Matrix:r,any:DH});function r(e){var t,n=e.size();switch(n.length){case 1:t=e.clone();break;case 2:var r=n[0],a=n[1];if(0===a)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+IW(n)+")");switch(e.storage()){case"dense":t=function(e,t,n){for(var r,a=e._data,i=[],s=0;s{var{typed:t,config:n,matrix:r,BigNumber:a}=e;return t(AZ,{"number, number":function(e,t){var a=eG(e,t);return"Array"===n.matrix?a:r(a)},"BigNumber, BigNumber":function(e,t){var i,s,o,u,l=new a(0),c=new a(1),p=l,d=c,h=c,f=l;if(!e.isInt()||!t.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!t.isZero();)s=e.div(t).floor(),o=e.mod(t),i=p,p=d.minus(s.times(p)),d=i,i=h,h=f.minus(s.times(h)),f=i,e=t,t=o;return u=e.lt(l)?[e.neg(),d.neg(),f.neg()]:[e,e.isZero()?0:d,f],"Array"===n.matrix?u:r(u)}})})),LZ="zeros",FZ=_U(LZ,["typed","config","matrix","BigNumber"],(e=>{var{typed:t,config:n,matrix:r,BigNumber:a}=e;return t(LZ,{"":function(){return"Array"===n.matrix?i([]):i([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var t=e.pop();return i(e,t)}return"Array"===n.matrix?i(e):i(e,"default")},Array:i,Matrix:function(e){var t=e.storage();return i(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return i(e.valueOf(),t)}});function i(e,t){var n=function(e){var t=!1;return e.forEach((function(e,n,r){YP(e)&&(t=!0,r[n]=e.toNumber())})),t}(e),i=n?new a(0):0;if(function(e){e.forEach((function(e){if("number"!=typeof e||!SU(e)||e<0)throw new Error("Parameters in function zeros must be positive integers")}))}(e),t){var s=r(t);return e.length>0?s.resize(e,i):s}var o=[];return e.length>0?jW(o,e,i):o}})),$Z=_U("and",["typed","matrix","equalScalar","zeros","not"],(e=>{var{typed:t,matrix:n,equalScalar:r,zeros:a,not:i}=e,s=HX({typed:t,equalScalar:r}),o=ZX({typed:t,equalScalar:r}),u=qX({typed:t,equalScalar:r}),l=GX({typed:t}),c=KX({typed:t,matrix:n});return t("and",{"number, number":MJ,"Complex, Complex":function(e,t){return!(0===e.re&&0===e.im||0===t.re&&0===t.im)},"BigNumber, BigNumber":function(e,t){return!(e.isZero()||t.isZero()||e.isNaN()||t.isNaN())},"Unit, Unit":t.referToSelf((e=>(t,n)=>e(t.value||0,n.value||0))),"SparseMatrix, any":t.referToSelf((e=>(t,n)=>i(n)?a(t.size(),t.storage()):u(t,n,e,!1))),"DenseMatrix, any":t.referToSelf((e=>(t,n)=>i(n)?a(t.size(),t.storage()):l(t,n,e,!1))),"any, SparseMatrix":t.referToSelf((e=>(t,n)=>i(t)?a(t.size(),t.storage()):u(n,t,e,!0))),"any, DenseMatrix":t.referToSelf((e=>(t,n)=>i(t)?a(t.size(),t.storage()):l(n,t,e,!0))),"Array, any":t.referToSelf((e=>(t,r)=>e(n(t),r).valueOf())),"any, Array":t.referToSelf((e=>(t,r)=>e(t,n(r)).valueOf()))},c({SS:o,DS:s}))})),OZ="bitAnd",RZ=_U(OZ,["typed","matrix","equalScalar"],(e=>{var{typed:t,matrix:n,equalScalar:r}=e,a=HX({typed:t,equalScalar:r}),i=ZX({typed:t,equalScalar:r}),s=qX({typed:t,equalScalar:r}),o=KX({typed:t,matrix:n});return t(OZ,{"number, number":GG,"BigNumber, BigNumber":BG},o({SS:i,DS:a,Ss:s}))})),YZ="bitXor",BZ=_U(YZ,["typed","matrix","DenseMatrix"],(e=>{var{typed:t,matrix:n,DenseMatrix:r}=e,a=jX({typed:t}),i=hZ({typed:t,DenseMatrix:r}),s=WX({typed:t,DenseMatrix:r}),o=KX({typed:t,matrix:n});return t(YZ,{"number, number":XG,"BigNumber, BigNumber":UG},o({SS:i,DS:a,Ss:s}))})),zZ="cbrt",PZ=_U(zZ,["config","typed","isNegative","unaryMinus","matrix","Complex","BigNumber","Fraction"],(e=>{var{config:t,typed:n,isNegative:r,unaryMinus:a,matrix:i,Complex:s,BigNumber:o,Fraction:u}=e;return n(zZ,{number:HV,Complex:l,"Complex, boolean":l,BigNumber:function(e){return e.cbrt()},Unit:function(e){if(e.value&&BP(e.value)){var t=e.clone();return t.value=1,(t=t.pow(1/3)).value=l(e.value),t}var n,i=r(e.value);i&&(e.value=a(e.value)),n=YP(e.value)?new o(1).div(3):zP(e.value)?new u(1,3):1/3;var s=e.pow(n);return i&&(s.value=a(s.value)),s}});function l(e,n){var r=e.arg()/3,a=e.abs(),o=new s(HV(a),0).mul(new s(0,r).exp());if(n){var u=[o,new s(HV(a),0).mul(new s(0,r+2*Math.PI/3).exp()),new s(HV(a),0).mul(new s(0,r-2*Math.PI/3).exp())];return"Array"===t.matrix?u:i(u)}return o}})),HZ="compare",jZ=_U(HZ,["typed","config","matrix","equalScalar","BigNumber","Fraction","DenseMatrix"],(e=>{var{typed:t,config:n,equalScalar:r,matrix:a,BigNumber:i,Fraction:s,DenseMatrix:o}=e,u=jX({typed:t}),l=UX({typed:t,equalScalar:r}),c=WX({typed:t,DenseMatrix:o}),p=KX({typed:t,matrix:a}),d=NK({typed:t});return t(HZ,UZ({typed:t,config:n}),{"boolean, boolean":function(e,t){return e===t?0:e>t?1:-1},"BigNumber, BigNumber":function(e,t){return DK(e,t,n.epsilon)?new i(0):new i(e.cmp(t))},"Fraction, Fraction":function(e,t){return new s(e.compare(t))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},d,p({SS:l,DS:u,Ss:c}))})),UZ=_U(HZ,["typed","config"],(e=>{var{typed:t,config:n}=e;return t(HZ,{"number, number":function(e,t){return PU(e,t,n.epsilon)?0:e>t?1:-1}})})),qZ="compareText",WZ=["typed","matrix"];OW.signature="any, any";var VZ=_U(qZ,WZ,(e=>{var{typed:t,matrix:n}=e,r=KX({typed:t,matrix:n});return t(qZ,OW,r({elop:OW,Ds:!0}))})),GZ="concat",KZ=_U(GZ,["typed","matrix","isInteger"],(e=>{var{typed:t,matrix:n,isInteger:r}=e;return t(GZ,{"...Array | Matrix | number | BigNumber":function(e){var t,a,i=e.length,s=-1,o=!1,u=[];for(t=0;t0&&s>a)throw new YW(s,a+1)}else{var c=DH(l).valueOf(),p=BW(c);if(u[t]=c,a=s,s=p.length-1,t>0&&s!==a)throw new RW(a+1,s+1)}}if(0===u.length)throw new SyntaxError("At least one matrix expected");for(var d=u.shift();u.length;)d=JZ(d,u.shift(),s,0);return o?n(d):d},"...string":function(e){return e.join("")}})}));function JZ(e,t,n,r){if(r{var{typed:t,size:n,prod:r}=e;return t(XZ,{string:function(e){return e.length},"Matrix | Array":function(e){return r(n(e))}})})),QZ="ctranspose",eQ=_U(QZ,["typed","transpose","conj"],(e=>{var{typed:t,transpose:n,conj:r}=e;return t(QZ,{any:function(e){return r(n(e))}})})),tQ="diag",nQ=_U(tQ,["typed","matrix","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,matrix:n,DenseMatrix:r,SparseMatrix:a}=e;return t(tQ,{Array:function(e){return i(e,0,BW(e),null)},"Array, number":function(e,t){return i(e,t,BW(e),null)},"Array, BigNumber":function(e,t){return i(e,t.toNumber(),BW(e),null)},"Array, string":function(e,t){return i(e,0,BW(e),t)},"Array, number, string":function(e,t,n){return i(e,t,BW(e),n)},"Array, BigNumber, string":function(e,t,n){return i(e,t.toNumber(),BW(e),n)},Matrix:function(e){return i(e,0,e.size(),e.storage())},"Matrix, number":function(e,t){return i(e,t,e.size(),e.storage())},"Matrix, BigNumber":function(e,t){return i(e,t.toNumber(),e.size(),e.storage())},"Matrix, string":function(e,t){return i(e,0,e.size(),t)},"Matrix, number, string":function(e,t,n){return i(e,t,e.size(),n)},"Matrix, BigNumber, string":function(e,t,n){return i(e,t.toNumber(),e.size(),n)}});function i(e,t,i,s){if(!SU(t))throw new TypeError("Second parameter in function diag must be an integer");var o=t>0?t:0,u=t<0?-t:0;switch(i.length){case 1:return function(e,t,n,i,s,o){var u=[i+s,i+o];if(n&&"sparse"!==n&&"dense"!==n)throw new TypeError("Unknown matrix type ".concat(n,'"'));var l="sparse"===n?a.diagonal(u,e,t):r.diagonal(u,e,t);return null!==n?l:l.valueOf()}(e,t,s,i[0],u,o);case 2:return function(e,t,r,a,i,s){if(UP(e)){var o=e.diagonal(t);return null!==r?r!==o.storage()?n(o,r):o:o.valueOf()}for(var u=Math.min(a[0]-i,a[1]-s),l=[],c=0;c{var{typed:t,numeric:n}=e;return t(rQ,{"number, number":function(e,t){return e/t},"Complex, Complex":function(e,t){return e.div(t)},"BigNumber, BigNumber":function(e,t){return e.div(t)},"Fraction, Fraction":function(e,t){return e.div(t)},"Unit, number | Complex | Fraction | BigNumber | Unit":(e,t)=>e.divide(t),"number | Fraction | Complex | BigNumber, Unit":(e,t)=>t.divideInto(e)})})),iQ="dotDivide",sQ=_U(iQ,["typed","matrix","equalScalar","divideScalar","DenseMatrix"],(e=>{var{typed:t,matrix:n,equalScalar:r,divideScalar:a,DenseMatrix:i}=e,s=HX({typed:t,equalScalar:r}),o=jX({typed:t}),u=hZ({typed:t,DenseMatrix:i}),l=qX({typed:t,equalScalar:r}),c=WX({typed:t,DenseMatrix:i}),p=KX({typed:t,matrix:n});return t(iQ,p({elop:a,SS:u,DS:o,SD:s,Ss:l,sS:c}))})),oQ="equal",uQ=_U(oQ,["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:a}=e,i=jX({typed:t}),s=hZ({typed:t,DenseMatrix:a}),o=WX({typed:t,DenseMatrix:a}),u=KX({typed:t,matrix:n});return t(oQ,lQ({typed:t,equalScalar:r}),u({elop:r,SS:s,DS:i,Ss:o}))})),lQ=_U(oQ,["typed","equalScalar"],(e=>{var{typed:t,equalScalar:n}=e;return t(oQ,{"any, any":function(e,t){return null===e?null===t:null===t?null===e:void 0===e?void 0===t:void 0===t?void 0===e:n(e,t)}})})),cQ=_U("fft",["typed","matrix","addScalar","multiplyScalar","divideScalar","exp","tau","i"],(e=>{var{typed:t,matrix:n,addScalar:r,multiplyScalar:a,divideScalar:i,exp:s,tau:o,i:u}=e;return t("fft",{Array:l,Matrix:function(e){return e.create(l(e.toArray()))}});function l(e){var t=BW(e);return 1===t.length?p(e,t[0]):c(e.map((e=>l(e,t.slice(1)))),0)}function c(e,t){var n=BW(e);if(0!==t)return new Array(n[0]).fill(0).map(((n,r)=>c(e[r],t-1)));if(1===n.length)return p(e);function r(e){var t=BW(e);return new Array(t[1]).fill(0).map(((n,r)=>new Array(t[0]).fill(0).map(((t,n)=>e[n][r]))))}return r(c(r(e),1))}function p(e){var t=e.length;if(1===t)return[e[0]];if(t%2==0){for(var n=[...p(e.filter(((e,t)=>t%2==0))),...p(e.filter(((e,t)=>t%2==1)))],l=0;l{var{typed:t,matrix:n}=e;return t(pQ,{Array:function(e){return ZW(DH(e))},Matrix:function(e){var t=ZW(DH(e.toArray()));return n(t)}})})),hQ=_U("matAlgo04xSidSid",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:n}=e;return function(e,r,a){var i=e._values,s=e._index,o=e._ptr,u=e._size,l=e._datatype,c=r._values,p=r._index,d=r._ptr,h=r._size,f=r._datatype;if(u.length!==h.length)throw new RW(u.length,h.length);if(u[0]!==h[0]||u[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+h+")");var m,g=u[0],y=u[1],b=n,v=0,x=a;"string"==typeof l&&l===f&&(m=l,b=t.find(n,[m,m]),v=t.convert(0,m),x=t.find(a,[m,m]));var _,w,D,N,M,S=i&&c?[]:void 0,k=[],T=[],C=i&&c?[]:void 0,E=i&&c?[]:void 0,A=[],I=[];for(w=0;w{var{typed:t,matrix:n,equalScalar:r,BigNumber:a,DenseMatrix:i}=e,s=XX({typed:t}),o=hQ({typed:t,equalScalar:r}),u=MZ({typed:t,DenseMatrix:i}),l=KX({typed:t,matrix:n}),c="number | BigNumber | Fraction | Matrix | Array",p={};return p["".concat(c,", ").concat(c,", ...").concat(c)]=t.referToSelf((e=>(t,n,r)=>{for(var a=e(t,n),i=0;ie.gcd(t)},l({SS:o,DS:s,Ss:u}),p)})),mQ="hasNumericValue",gQ=_U(mQ,["typed","isNumeric"],(e=>{var{typed:t,isNumeric:n}=e;return t(mQ,{boolean:()=>!0,string:function(e){return e.trim().length>0&&!isNaN(Number(e))},any:function(e){return n(e)}})})),yQ="hypot",bQ=_U(yQ,["typed","abs","addScalar","divideScalar","multiplyScalar","sqrt","smaller","isPositive"],(e=>{var{typed:t,abs:n,addScalar:r,divideScalar:a,multiplyScalar:i,sqrt:s,smaller:o,isPositive:u}=e;return t(yQ,{"... number | BigNumber":l,Array:l,Matrix:e=>l(ZW(e.toArray()))});function l(e){for(var t=0,l=0,c=0;c{var{typed:t,fft:n,dotDivide:r,conj:a}=e;return t(vQ,{"Array | Matrix":function(e){var t=UP(e)?e.size():BW(e);return r(a(n(a(e))),t.reduce(((e,t)=>e*t),1))}})})),_Q="kron",wQ=_U(_Q,["typed","matrix","multiplyScalar"],(e=>{var{typed:t,matrix:n,multiplyScalar:r}=e;return t(_Q,{"Matrix, Matrix":function(e,t){return n(a(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return n(a(e.toArray(),t))},"Array, Matrix":function(e,t){return n(a(e,t.toArray()))},"Array, Array":a});function a(e,t){if(1===BW(e).length&&(e=[e]),1===BW(t).length&&(t=[t]),BW(e).length>2||BW(t).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(e.length)+", y = "+JSON.stringify(t.length)+")");var n=[],a=[];return e.map((function(e){return t.map((function(t){return a=[],n.push(a),e.map((function(e){return t.map((function(t){return a.push(r(e,t))}))}))}))}))&&n}})),DQ="largerEq",NQ=_U(DQ,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:n,matrix:r,DenseMatrix:a}=e,i=jX({typed:t}),s=hZ({typed:t,DenseMatrix:a}),o=WX({typed:t,DenseMatrix:a}),u=KX({typed:t,matrix:r}),l=NK({typed:t});return t(DQ,MQ({typed:t,config:n}),{"boolean, boolean":(e,t)=>e>=t,"BigNumber, BigNumber":function(e,t){return e.gte(t)||DK(e,t,n.epsilon)},"Fraction, Fraction":(e,t)=>-1!==e.compare(t),"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},l,u({SS:s,DS:i,Ss:o}))})),MQ=_U(DQ,["typed","config"],(e=>{var{typed:t,config:n}=e;return t(DQ,{"number, number":function(e,t){return e>=t||PU(e,t,n.epsilon)}})})),SQ=_U("matAlgo08xS0Sid",["typed","equalScalar"],(e=>{var{typed:t,equalScalar:n}=e;return function(e,r,a){var i=e._values,s=e._index,o=e._ptr,u=e._size,l=e._datatype,c=r._values,p=r._index,d=r._ptr,h=r._size,f=r._datatype;if(u.length!==h.length)throw new RW(u.length,h.length);if(u[0]!==h[0]||u[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+h+")");if(!i||!c)throw new Error("Cannot perform operation on Pattern Sparse Matrices");var m,g=u[0],y=u[1],b=n,v=0,x=a;"string"==typeof l&&l===f&&(m=l,b=t.find(n,[m,m]),v=t.convert(0,m),x=t.find(a,[m,m]));for(var _,w,D,N,M=[],S=[],k=[],T=[],C=[],E=0;E{var{typed:t,matrix:n}=e;return{"Array, number":t.referTo("DenseMatrix, number",(e=>(t,r)=>e(n(t),r).valueOf())),"Array, BigNumber":t.referTo("DenseMatrix, BigNumber",(e=>(t,r)=>e(n(t),r).valueOf())),"number, Array":t.referTo("number, DenseMatrix",(e=>(t,r)=>e(t,n(r)).valueOf())),"BigNumber, Array":t.referTo("BigNumber, DenseMatrix",(e=>(t,r)=>e(t,n(r)).valueOf()))}})),TQ="leftShift",CQ=_U(TQ,["typed","matrix","equalScalar","zeros","DenseMatrix"],(e=>{var{typed:t,matrix:n,equalScalar:r,zeros:a,DenseMatrix:i}=e,s=XX({typed:t}),o=HX({typed:t,equalScalar:r}),u=SQ({typed:t,equalScalar:r}),l=MZ({typed:t,DenseMatrix:i}),c=qX({typed:t,equalScalar:r}),p=GX({typed:t}),d=KX({typed:t,matrix:n}),h=kQ({typed:t,matrix:n});return t(TQ,{"number, number":ZG,"BigNumber, BigNumber":qG,"SparseMatrix, number | BigNumber":t.referToSelf((e=>(t,n)=>r(n,0)?t.clone():c(t,n,e,!1))),"DenseMatrix, number | BigNumber":t.referToSelf((e=>(t,n)=>r(n,0)?t.clone():p(t,n,e,!1))),"number | BigNumber, SparseMatrix":t.referToSelf((e=>(t,n)=>r(t,0)?a(n.size(),n.storage()):l(n,t,e,!0))),"number | BigNumber, DenseMatrix":t.referToSelf((e=>(t,n)=>r(t,0)?a(n.size(),n.storage()):p(n,t,e,!0)))},h,d({SS:u,DS:s,SD:o}))}));function EQ(e){var{DenseMatrix:t}=e;return function(e,n,r){var a=e.size();if(2!==a.length)throw new RangeError("Matrix must be two dimensional (size: "+IW(a)+")");var i=a[0];if(i!==a[1])throw new RangeError("Matrix must be square (size: "+IW(a)+")");var s=[];if(UP(n)){var o=n.size(),u=n._data;if(1===o.length){if(o[0]!==i)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(var l=0;l{var{typed:t,matrix:n,divideScalar:r,multiplyScalar:a,subtract:i,equalScalar:s,DenseMatrix:o}=e,u=EQ({DenseMatrix:o});return t(AQ,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var n=(t=u(e,t,!0))._data,l=e._size[0],c=e._size[1],p=e._values,d=e._index,h=e._ptr,f=[],m=0;mm&&(b.push(p[w]),v.push(D))}if(s(y,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var N=r(g,y),M=0,S=v.length;M{var{typed:t,matrix:n,flatten:r,size:a}=e;return t(LQ,{"...Array":function(e){return i(e)},"...Matrix":function(e){return n(i(e.map((e=>e.toArray()))))}});function i(e){if(0===e.length)throw new TypeError("At least one column is needed to construct a matrix.");for(var t=s(e[0]),n=[],a=0;a{var{typed:t,config:n,numeric:r,smaller:a}=e;return t("min",{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(e,t){return IV(e,t.valueOf(),i)},"...":function(e){if(CV(e))throw new TypeError("Scalar values expected in function min");return s(e)}});function i(e,t){try{return a(e,t)?e:t}catch(e){throw sZ(e,"min",t)}}function s(e){var t;if(EV(e,(function(e){try{isNaN(e)&&"number"==typeof e?t=NaN:(void 0===t||a(e,t))&&(t=e)}catch(t){throw sZ(t,"min",e)}})),void 0===t)throw new Error("Cannot calculate min of an empty array");return"string"==typeof t&&(t=r(t,n.number)),t}})),OQ="mode",RQ=_U(OQ,["typed","isNaN","isNumeric"],(e=>{var{typed:t,isNaN:n,isNumeric:r}=e;return t(OQ,{"Array | Matrix":a,"...":function(e){return a(e)}});function a(e){if(0===(e=ZW(e.valueOf())).length)throw new Error("Cannot calculate mode of an empty array");for(var t={},a=[],i=0,s=0;si&&(i=t[o],a=[o])}return a}})),YQ="nthRoots",BQ=_U(YQ,["config","typed","divideScalar","Complex"],(e=>{var{typed:t,config:n,divideScalar:r,Complex:a}=e,i=[function(e){return new a(e,0)},function(e){return new a(0,e)},function(e){return new a(-e,0)},function(e){return new a(0,-e)}];function s(e,t){if(t<0)throw new Error("Root must be greater than zero");if(0===t)throw new Error("Root must be non-zero");if(t%1!=0)throw new Error("Root must be an integer");if(0===e||0===e.abs())return[new a(0,0)];var n,r="number"==typeof e;(r||0===e.re||0===e.im)&&(n=r?2*+(e<0):0===e.im?2*+(e.re<0):2*+(e.im<0)+1);for(var s=e.arg(),o=e.abs(),u=[],l=Math.pow(o,1/t),c=0;c{var{typed:t,config:n,matrix:r,BigNumber:a}=e;return t("ones",{"":function(){return"Array"===n.matrix?i([]):i([],"default")},"...number | BigNumber | string":function(e){if("string"==typeof e[e.length-1]){var t=e.pop();return i(e,t)}return"Array"===n.matrix?i(e):i(e,"default")},Array:i,Matrix:function(e){var t=e.storage();return i(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return i(e.valueOf(),t)}});function i(e,t){var n=function(e){var t=!1;return e.forEach((function(e,n,r){YP(e)&&(t=!0,r[n]=e.toNumber())})),t}(e),i=n?new a(1):1;if(function(e){e.forEach((function(e){if("number"!=typeof e||!SU(e)||e<0)throw new Error("Parameters in function ones must be positive integers")}))}(e),t){var s=r(t);return e.length>0?s.resize(e,i):s}var o=[];return e.length>0?jW(o,e,i):o}})),PQ="partitionSelect",HQ=_U(PQ,["typed","isNumeric","isNaN","compare"],(e=>{var{typed:t,isNumeric:n,isNaN:r,compare:a}=e,i=a,s=(e,t)=>-a(e,t);return t(PQ,{"Array | Matrix, number":function(e,t){return o(e,t,i)},"Array | Matrix, number, string":function(e,t,n){if("asc"===n)return o(e,t,i);if("desc"===n)return o(e,t,s);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":o});function o(e,t,n){if(!SU(t)||t<0)throw new Error("k must be a non-negative integer");if(UP(e)){if(e.size().length>1)throw new Error("Only one dimensional matrices supported");return u(e.valueOf(),t,n)}if(Array.isArray(e))return u(e,t,n)}function u(e,t,a){if(t>=e.length)throw new Error("k out of bounds");for(var i=0;i=0){var p=e[l];e[l]=e[u],e[u]=p,--l}else++u;a(e[u],c)>0&&--u,t<=u?o=u:s=u+1}return e[t]}}));function jQ(e,t,n,r){if(!(this instanceof jQ))throw new SyntaxError("Constructor must be called with the new operator");this.fn=e,this.count=t,this.min=n,this.max=r,this.message="Wrong number of arguments in function "+e+" ("+t+" provided, "+n+(null!=r?"-"+r:"")+" expected)",this.stack=(new Error).stack}jQ.prototype=new Error,jQ.prototype.constructor=Error,jQ.prototype.name="ArgumentsError",jQ.prototype.isArgumentsError=!0;var UQ=_U("resize",["config","matrix"],(e=>{var{config:t,matrix:n}=e;return function(e,a,i){if(2!==arguments.length&&3!==arguments.length)throw new jQ("resize",arguments.length,2,3);if(UP(a)&&(a=a.valueOf()),YP(a[0])&&(a=a.map((function(e){return YP(e)?e.toNumber():e}))),UP(e))return e.resize(a,i,!0);if("string"==typeof e)return r(e,a,i);var s=!Array.isArray(e)&&"Array"!==t.matrix;if(0===a.length){for(;Array.isArray(e);)e=e[0];return DH(e)}Array.isArray(e)||(e=[e]);var o=jW(e=DH(e),a,i);return s?n(o):o};function r(e,t,n){if(void 0!==n){if("string"!=typeof n||1!==n.length)throw new TypeError("Single character expected as defaultValue")}else n=" ";if(1!==t.length)throw new RW(t.length,1);var r=t[0];if("number"!=typeof r||!SU(r))throw new TypeError("Invalid size, must contain positive integers (size: "+IW(t)+")");if(e.length>r)return e.substring(0,r);if(e.length{var{typed:t,matrix:n,equalScalar:r,zeros:a,DenseMatrix:i}=e,s=XX({typed:t}),o=HX({typed:t,equalScalar:r}),u=SQ({typed:t,equalScalar:r}),l=MZ({typed:t,DenseMatrix:i}),c=qX({typed:t,equalScalar:r}),p=GX({typed:t}),d=KX({typed:t,matrix:n}),h=kQ({typed:t,matrix:n});return t(qQ,{"number, number":QG,"BigNumber, BigNumber":WG,"SparseMatrix, number | BigNumber":t.referToSelf((e=>(t,n)=>r(n,0)?t.clone():c(t,n,e,!1))),"DenseMatrix, number | BigNumber":t.referToSelf((e=>(t,n)=>r(n,0)?t.clone():p(t,n,e,!1))),"number | BigNumber, SparseMatrix":t.referToSelf((e=>(t,n)=>r(t,0)?a(n.size(),n.storage()):l(n,t,e,!0))),"number | BigNumber, DenseMatrix":t.referToSelf((e=>(t,n)=>r(t,0)?a(n.size(),n.storage()):p(n,t,e,!0)))},h,d({SS:u,DS:s,SD:o}))})),VQ="Number of decimals in function round must be an integer",GQ="round",KQ=_U(GQ,["typed","matrix","equalScalar","zeros","BigNumber","DenseMatrix"],(e=>{var{typed:t,matrix:n,equalScalar:r,zeros:a,BigNumber:i,DenseMatrix:s}=e,o=qX({typed:t,equalScalar:r}),u=WX({typed:t,DenseMatrix:s}),l=GX({typed:t});return t(GQ,{number:nG,"number, number":nG,"number, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(VQ);return new i(e).toDecimalPlaces(t.toNumber())},Complex:function(e){return e.round()},"Complex, number":function(e,t){if(t%1)throw new TypeError(VQ);return e.round(t)},"Complex, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(VQ);var n=t.toNumber();return e.round(n)},BigNumber:function(e){return e.toDecimalPlaces(0)},"BigNumber, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(VQ);return e.toDecimalPlaces(t.toNumber())},Fraction:function(e){return e.round()},"Fraction, number":function(e,t){if(t%1)throw new TypeError(VQ);return e.round(t)},"Fraction, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(VQ);return e.round(t.toNumber())},"Array | Matrix":t.referToSelf((e=>t=>AV(t,e,!0))),"SparseMatrix, number | BigNumber":t.referToSelf((e=>(t,n)=>o(t,n,e,!1))),"DenseMatrix, number | BigNumber":t.referToSelf((e=>(t,n)=>l(t,n,e,!1))),"Array, number | BigNumber":t.referToSelf((e=>(t,r)=>l(n(t),r,e,!1).valueOf())),"number | Complex | BigNumber | Fraction, SparseMatrix":t.referToSelf((e=>(t,n)=>r(t,0)?a(n.size(),n.storage()):u(n,t,e,!0))),"number | Complex | BigNumber | Fraction, DenseMatrix":t.referToSelf((e=>(t,n)=>r(t,0)?a(n.size(),n.storage()):l(n,t,e,!0))),"number | Complex | BigNumber | Fraction, Array":t.referToSelf((e=>(t,r)=>l(n(r),t,e,!0).valueOf()))})})),JQ="smallerEq",XQ=_U(JQ,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:n,matrix:r,DenseMatrix:a}=e,i=jX({typed:t}),s=hZ({typed:t,DenseMatrix:a}),o=WX({typed:t,DenseMatrix:a}),u=KX({typed:t,matrix:r}),l=NK({typed:t});return t(JQ,ZQ({typed:t,config:n}),{"boolean, boolean":(e,t)=>e<=t,"BigNumber, BigNumber":function(e,t){return e.lte(t)||DK(e,t,n.epsilon)},"Fraction, Fraction":(e,t)=>1!==e.compare(t),"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},l,u({SS:s,DS:i,Ss:o}))})),ZQ=_U(JQ,["typed","config"],(e=>{var{typed:t,config:n}=e;return t(JQ,{"number, number":function(e,t){return e<=t||PU(e,t,n.epsilon)}})})),QQ="unequal",e0=_U(QQ,["typed","config","equalScalar","matrix","DenseMatrix"],(e=>{var{typed:t,config:n,equalScalar:r,matrix:a,DenseMatrix:i}=e,s=jX({typed:t}),o=hZ({typed:t,DenseMatrix:i}),u=WX({typed:t,DenseMatrix:i}),l=KX({typed:t,matrix:a});return t(QQ,t0({typed:t,equalScalar:r}),l({elop:function(e,t){return!r(e,t)},SS:o,DS:s,Ss:u}))})),t0=_U(QQ,["typed","equalScalar"],(e=>{var{typed:t,equalScalar:n}=e;return t(QQ,{"any, any":function(e,t){return null===e?null!==t:null===t?null!==e:void 0===e?void 0!==t:void 0===t?void 0!==e:!n(e,t)}})})),n0="usolve",r0=_U(n0,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:n,divideScalar:r,multiplyScalar:a,subtract:i,equalScalar:s,DenseMatrix:o}=e,u=EQ({DenseMatrix:o});return t(n0,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var n=(t=u(e,t,!0))._data,l=e._size[0],c=e._size[1],p=e._values,d=e._index,h=e._ptr,f=[],m=c-1;m>=0;m--){var g=n[m][0]||0;if(s(g,0))f[m]=[0];else{for(var y=0,b=[],v=[],x=h[m],_=h[m+1]-1;_>=x;_--){var w=d[_];w===m?y=p[_]:w=0;h--){var f=n[h][0]||0,m=void 0;if(s(f,0))m=0;else{var g=d[h][h];if(s(g,0))throw new Error("Linear system cannot be solved since matrix is singular");m=r(f,g);for(var y=h-1;y>=0;y--)n[y]=[i(n[y][0]||0,a(m,d[y][h]))]}p[h]=[m]}return new o({data:p,size:[l,1]})}})),a0=_U("xor",["typed","matrix","DenseMatrix"],(e=>{var{typed:t,matrix:n,DenseMatrix:r}=e,a=jX({typed:t}),i=hZ({typed:t,DenseMatrix:r}),s=WX({typed:t,DenseMatrix:r}),o=KX({typed:t,matrix:n});return t("xor",{"number, number":NJ,"Complex, Complex":function(e,t){return(0!==e.re||0!==e.im)!=(0!==t.re||0!==t.im)},"BigNumber, BigNumber":function(e,t){return(!e.isZero()&&!e.isNaN())!=(!t.isZero()&&!t.isNaN())},"Unit, Unit":t.referToSelf((e=>(t,n)=>e(t.value||0,n.value||0)))},o({SS:i,DS:a,Ss:s}))})),i0=_U("add",["typed","matrix","addScalar","equalScalar","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,matrix:n,addScalar:r,equalScalar:a,DenseMatrix:i,SparseMatrix:s}=e,o=XX({typed:t}),u=hQ({typed:t,equalScalar:a}),l=MZ({typed:t,DenseMatrix:i}),c=KX({typed:t,matrix:n});return t("add",{"any, any":r,"any, any, ...any":t.referToSelf((e=>(t,n,r)=>{for(var a=e(t,n),i=0;i{var{typed:t,equalScalar:n}=e;return function(e,r,a){var i=e._values,s=e._index,o=e._ptr,u=e._size,l=e._datatype,c=r._values,p=r._index,d=r._ptr,h=r._size,f=r._datatype;if(u.length!==h.length)throw new RW(u.length,h.length);if(u[0]!==h[0]||u[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+h+")");var m,g=u[0],y=u[1],b=n,v=0,x=a;"string"==typeof l&&l===f&&(m=l,b=t.find(n,[m,m]),v=t.convert(0,m),x=t.find(a,[m,m]));var _,w,D,N,M,S=i&&c?[]:void 0,k=[],T=[],C=S?[]:void 0,E=[];for(w=0;w{var{typed:t,matrix:n,equalScalar:r,BigNumber:a,DenseMatrix:i}=e,s=HX({typed:t,equalScalar:r}),o=jX({typed:t}),u=s0({typed:t,equalScalar:r}),l=qX({typed:t,equalScalar:r}),c=WX({typed:t,DenseMatrix:i}),p=KX({typed:t,matrix:n});return t(o0,{"number, number":Math.atan2,"BigNumber, BigNumber":(e,t)=>a.atan2(e,t)},p({scalar:"number | BigNumber",SS:u,DS:o,SD:s,Ss:l,sS:c}))})),l0="bitOr",c0=_U(l0,["typed","matrix","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:a}=e,i=XX({typed:t}),s=hQ({typed:t,equalScalar:r}),o=MZ({typed:t,DenseMatrix:a}),u=KX({typed:t,matrix:n});return t(l0,{"number, number":JG,"BigNumber, BigNumber":PG},u({SS:s,DS:i,Ss:o}))})),p0="catalan",d0=_U(p0,["typed","addScalar","divideScalar","multiplyScalar","combinations","isNegative","isInteger"],(e=>{var{typed:t,addScalar:n,divideScalar:r,multiplyScalar:a,combinations:i,isNegative:s,isInteger:o}=e;return t(p0,{"number | BigNumber":function(e){if(!o(e)||s(e))throw new TypeError("Non-negative integer value expected in function catalan");return r(i(a(e,2),e),n(e,1))}})})),h0=n(3228),f0="compareNatural",m0=_U(f0,["typed","compare"],(e=>{var{typed:t,compare:n}=e,r=n.signatures["boolean,boolean"];return t(f0,{"any, any":function e(t,s){var o,u=wH(t),l=wH(s);if(!("number"!==u&&"BigNumber"!==u&&"Fraction"!==u||"number"!==l&&"BigNumber"!==l&&"Fraction"!==l))return"0"!==(o=n(t,s)).toString()?o>0?1:-1:h0(u,l);var c=["Array","DenseMatrix","SparseMatrix"];if(c.includes(u)||c.includes(l))return 0!==(o=a(e,t,s))?o:h0(u,l);if(u!==l)return h0(u,l);if("Complex"===u)return function(e,t){return e.re>t.re?1:e.ret.im?1:e.imn.length?1:t.length{var{typed:t,add:n,unaryPlus:r}=e;return t(g0,{Array:a,Matrix:function(e){return e.create(a(e.valueOf()))},"Array, number | BigNumber":s,"Matrix, number | BigNumber":function(e,t){return e.create(s(e.valueOf(),t))},"...":function(e){if(CV(e))throw new TypeError("All values expected to be scalar in function cumsum");return a(e)}});function a(e){try{return i(e)}catch(e){throw sZ(e,g0)}}function i(e){if(0===e.length)return[];for(var t=[r(e[0])],a=1;a=n.length)throw new YW(t,n.length);try{return o(e,t)}catch(e){throw sZ(e,g0)}}function o(e,t){var n,r,a;if(t<=0){var s=e[0][0];if(Array.isArray(s)){for(a=TV(e),r=[],n=0;n{var{typed:t,equal:n}=e;return t(b0,{"any, any":function(e,t){return r(e.valueOf(),t.valueOf())}});function r(e,t){if(Array.isArray(e)){if(Array.isArray(t)){var a=e.length;if(a!==t.length)return!1;for(var i=0;i{var{typed:t,matrix:n,subtract:r,number:a}=e;return t(x0,{"Array | Matrix":function(e){return UP(e)?n(s(e.toArray())):s(e)},"Array | Matrix, number":function(e,t){if(!SU(t))throw new RangeError("Dimension must be a whole number");return UP(e)?n(i(e.toArray(),t)):i(e,t)},"Array, BigNumber":t.referTo("Array,number",(e=>(t,n)=>e(t,a(n)))),"Matrix, BigNumber":t.referTo("Matrix,number",(e=>(t,n)=>e(t,a(n))))});function i(e,t){if(UP(e)&&(e=e.toArray()),!Array.isArray(e))throw RangeError("Array/Matrix does not have that many dimensions");if(t>0){var n=[];return e.forEach((e=>{n.push(i(e,t-1))})),n}if(0===t)return s(e);throw RangeError("Cannot have negative dimension")}function s(e){for(var t=[],n=e.length,r=1;r{var{typed:t,addScalar:n,multiplyScalar:r,conj:a,size:i}=e;return t("dot",{"Array | DenseMatrix, Array | DenseMatrix":function(e,i){var u=s(e,i),l=UP(e)?e._data:e,c=UP(e)?e._datatype:void 0,p=UP(i)?i._data:i,d=UP(i)?i._datatype:void 0,h=2===o(e).length,f=2===o(i).length,m=n,g=r;if(c&&d&&c===d&&"string"==typeof c){var y=c;m=t.find(n,[y,y]),g=t.find(r,[y,y])}if(!h&&!f){for(var b=g(a(l[0]),p[0]),v=1;vm?h++:f===m&&(l=c(l,p(i[d],u[h])),d++,h++)}return l}});function s(e,t){var n,r,a=o(e),i=o(t);if(1===a.length)n=a[0];else{if(2!==a.length||1!==a[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+a.join(", ")+")");n=a[0]}if(1===i.length)r=i[0];else{if(2!==i.length||1!==i[1])throw new RangeError("Expected a column vector, instead got a matrix of size ("+i.join(", ")+")");r=i[0]}if(n!==r)throw new RangeError("Vectors must have equal length ("+n+" != "+r+")");if(0===n)throw new RangeError("Cannot calculate the dot product of empty vectors");return n}function o(e){return UP(e)?e.size():i(e)}})),D0="equalText",N0=_U(D0,["typed","compareText","isZero"],(e=>{var{typed:t,compareText:n,isZero:r}=e;return t(D0,{"any, any":function(e,t){return r(n(e,t))}})})),M0="floor",S0=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],k0=_U(M0,["typed","config","round"],(e=>{var{typed:t,config:n,round:r}=e;return t(M0,{number:function(e){return PU(e,r(e),n.epsilon)?r(e):Math.floor(e)},"number, number":function(e,t){if(PU(e,r(e,t),n.epsilon))return r(e,t);var[a,i]="".concat(e,"e").split("e"),s=Math.floor(Number("".concat(a,"e").concat(Number(i)+t)));return[a,i]="".concat(s,"e").split("e"),Number("".concat(a,"e").concat(Number(i)-t))}})})),T0=_U(M0,S0,(e=>{var{typed:t,config:n,round:r,matrix:a,equalScalar:i,zeros:s,DenseMatrix:o}=e,u=qX({typed:t,equalScalar:i}),l=WX({typed:t,DenseMatrix:o}),c=GX({typed:t}),p=k0({typed:t,config:n,round:r});return t("floor",{number:p.signatures.number,"number,number":p.signatures["number,number"],Complex:function(e){return e.floor()},"Complex, number":function(e,t){return e.floor(t)},"Complex, BigNumber":function(e,t){return e.floor(t.toNumber())},BigNumber:function(e){return DK(e,r(e),n.epsilon)?r(e):e.floor()},"BigNumber, BigNumber":function(e,t){return DK(e,r(e,t),n.epsilon)?r(e,t):e.toDecimalPlaces(t.toNumber(),xU.ROUND_FLOOR)},Fraction:function(e){return e.floor()},"Fraction, number":function(e,t){return e.floor(t)},"Fraction, BigNumber":function(e,t){return e.floor(t.toNumber())},"Array | Matrix":t.referToSelf((e=>t=>AV(t,e,!0))),"Array, number | BigNumber":t.referToSelf((e=>(t,n)=>AV(t,(t=>e(t,n)),!0))),"SparseMatrix, number | BigNumber":t.referToSelf((e=>(t,n)=>u(t,n,e,!1))),"DenseMatrix, number | BigNumber":t.referToSelf((e=>(t,n)=>c(t,n,e,!1))),"number | Complex | Fraction | BigNumber, Array":t.referToSelf((e=>(t,n)=>c(a(n),t,e,!0).valueOf())),"number | Complex | Fraction | BigNumber, Matrix":t.referToSelf((e=>(t,n)=>i(t,0)?s(n.size(),n.storage()):"dense"===n.storage()?c(n,t,e,!0):l(n,t,e,!0)))})})),C0="identity",E0=_U(C0,["typed","config","matrix","BigNumber","DenseMatrix","SparseMatrix"],(e=>{var{typed:t,config:n,matrix:r,BigNumber:a,DenseMatrix:i,SparseMatrix:s}=e;return t(C0,{"":function(){return"Matrix"===n.matrix?r([]):[]},string:function(e){return r(e)},"number | BigNumber":function(e){return u(e,e,"Matrix"===n.matrix?"dense":void 0)},"number | BigNumber, string":function(e,t){return u(e,e,t)},"number | BigNumber, number | BigNumber":function(e,t){return u(e,t,"Matrix"===n.matrix?"dense":void 0)},"number | BigNumber, number | BigNumber, string":function(e,t,n){return u(e,t,n)},Array:function(e){return o(e)},"Array, string":function(e,t){return o(e,t)},Matrix:function(e){return o(e.valueOf(),e.storage())},"Matrix, string":function(e,t){return o(e.valueOf(),t)}});function o(e,t){switch(e.length){case 0:return t?r(t):[];case 1:return u(e[0],e[0],t);case 2:return u(e[0],e[1],t);default:throw new Error("Vector containing two values expected")}}function u(e,t,n){var r=YP(e)||YP(t)?a:null;if(YP(e)&&(e=e.toNumber()),YP(t)&&(t=t.toNumber()),!SU(e)||e<1)throw new Error("Parameters in function identity must be positive integers");if(!SU(t)||t<1)throw new Error("Parameters in function identity must be positive integers");var o=r?new a(1):1,u=r?new r(0):0,l=[e,t];if(n){if("sparse"===n)return s.diagonal(l,o,0,u);if("dense"===n)return i.diagonal(l,o,0,u);throw new TypeError('Unknown matrix type "'.concat(n,'"'))}for(var c=jW([],l,u),p=e{var{typed:t,config:n,BigNumber:r,xgcd:a,equal:i,smaller:s,mod:o,add:u,isInteger:l}=e;return t(A0,{"number, number":c,"BigNumber, BigNumber":c});function c(e,t){if(!l(e)||!l(t))throw new Error("Parameters in function invmod must be integer numbers");if(e=o(e,t),i(t,0))throw new Error("Divisor must be non zero");var n=a(e,t);n=n.valueOf();var[c,p]=n;return i(c,r(1))?(p=o(p,t),s(p,r(0))&&(p=u(p,t)),p):NaN}})),L0="larger",F0=_U(L0,["typed","config","matrix","DenseMatrix"],(e=>{var{typed:t,config:n,matrix:r,DenseMatrix:a}=e,i=jX({typed:t}),s=hZ({typed:t,DenseMatrix:a}),o=WX({typed:t,DenseMatrix:a}),u=KX({typed:t,matrix:r}),l=NK({typed:t});return t(L0,$0({typed:t,config:n}),{"boolean, boolean":(e,t)=>e>t,"BigNumber, BigNumber":function(e,t){return e.gt(t)&&!DK(e,t,n.epsilon)},"Fraction, Fraction":(e,t)=>1===e.compare(t),"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")}},l,u({SS:s,DS:i,Ss:o}))})),$0=_U(L0,["typed","config"],(e=>{var{typed:t,config:n}=e;return t(L0,{"number, number":function(e,t){return e>t&&!PU(e,t,n.epsilon)}})})),O0=_U("log",["config","typed","divideScalar","Complex"],(e=>{var{typed:t,config:n,divideScalar:r,Complex:a}=e;return t("log",{number:function(e){return e>=0||n.predictable?function(e,t){return Math.log(e)}(e):new a(e,0).log()},Complex:function(e){return e.log()},BigNumber:function(e){return!e.isNegative()||n.predictable?e.ln():new a(e.toNumber(),0).log()},"any, any":t.referToSelf((e=>(t,n)=>r(e(t),e(n))))})})),R0="lsolveAll",Y0=_U(R0,["typed","matrix","divideScalar","multiplyScalar","subtract","equalScalar","DenseMatrix"],(e=>{var{typed:t,matrix:n,divideScalar:r,multiplyScalar:a,subtract:i,equalScalar:s,DenseMatrix:o}=e,u=EQ({DenseMatrix:o});return t(R0,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var n=[u(e,t,!0)._data.map((e=>e[0]))],l=e._size[0],c=e._size[1],p=e._values,d=e._index,h=e._ptr,f=0;ff&&(b.push(p[D]),v.push(N))}if(s(w,0))if(s(y[f],0)){if(0===g){var M=[...y];M[f]=1;for(var S=0,k=v.length;Snew o({data:e.map((e=>[e])),size:[l,1]})))}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return l(e,t)},"Array, Array | Matrix":function(e,t){return l(n(e),t).map((e=>e.valueOf()))}});function l(e,t){for(var n=[u(e,t,!0)._data.map((e=>e[0]))],l=e._data,c=e._size[0],p=e._size[1],d=0;dnew o({data:e.map((e=>[e])),size:[c,1]})))}})),B0="matrixFromRows",z0=_U(B0,["typed","matrix","flatten","size"],(e=>{var{typed:t,matrix:n,flatten:r,size:a}=e;return t(B0,{"...Array":function(e){return i(e)},"...Matrix":function(e){return n(i(e.map((e=>e.toArray()))))}});function i(e){if(0===e.length)throw new TypeError("At least one row is needed to construct a matrix.");var t=s(e[0]),n=[];for(var a of e){var i=s(a);if(i!==t)throw new TypeError("The vectors had different length: "+(0|t)+" ≠ "+(0|i));n.push(r(a))}return n}function s(e){var t=a(e);if(1===t.length)return t[0];if(2===t.length){if(1===t[0])return t[1];if(1===t[1])return t[0];throw new TypeError("At least one of the arguments is not a vector.")}throw new TypeError("Only one- or two-dimensional vectors are supported.")}})),P0="multiply",H0=_U(P0,["typed","matrix","addScalar","multiplyScalar","equalScalar","dot"],(e=>{var{typed:t,matrix:n,addScalar:r,multiplyScalar:a,equalScalar:i,dot:s}=e,o=qX({typed:t,equalScalar:i}),u=GX({typed:t});function l(e,t){switch(e.length){case 1:switch(t.length){case 1:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+e[0]+") must match Matrix rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;case 2:switch(t.length){case 1:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+e[1]+") must match Vector length ("+t[0]+")");break;case 2:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+e[1]+") must match Matrix B rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+e.length+" dimensions)")}}var c=t("_multiplyMatrixVector",{"DenseMatrix, any":function(e,n){var i,s=e._data,o=e._size,u=e._datatype,l=n._data,c=n._datatype,p=o[0],d=o[1],h=r,f=a;u&&c&&u===c&&"string"==typeof u&&(i=u,h=t.find(r,[i,i]),f=t.find(a,[i,i]));for(var m=[],g=0;gS)for(var T=0,C=0;C(t,r)=>{l(BW(t),BW(r));var a=e(n(t),n(r));return UP(a)?a.valueOf():a})),"Matrix, Matrix":function(e,n){var i=e.size(),o=n.size();return l(i,o),1===i.length?1===o.length?function(e,t,n){if(0===n)throw new Error("Cannot multiply two empty vectors");return s(e,t)}(e,n,i[0]):function(e,n){if("dense"!==n.storage())throw new Error("Support for SparseMatrix not implemented");return function(e,n){var i,s=e._data,o=e._size,u=e._datatype,l=n._data,c=n._size,p=n._datatype,d=o[0],h=c[1],f=r,m=a;u&&p&&u===p&&"string"==typeof u&&(i=u,f=t.find(r,[i,i]),m=t.find(a,[i,i]));for(var g=[],y=0;y(t,r)=>e(t,n(r)))),"Array, Matrix":t.referToSelf((e=>(t,r)=>e(n(t,r.storage()),r))),"SparseMatrix, any":function(e,t){return o(e,t,a,!1)},"DenseMatrix, any":function(e,t){return u(e,t,a,!1)},"any, SparseMatrix":function(e,t){return o(t,e,a,!0)},"any, DenseMatrix":function(e,t){return u(t,e,a,!0)},"Array, any":function(e,t){return u(n(e),t,a,!1).valueOf()},"any, Array":function(e,t){return u(n(t),e,a,!0).valueOf()},"any, any":a,"any, any, ...any":t.referToSelf((e=>(t,n,r)=>{for(var a=e(t,n),i=0;i{var{typed:t,matrix:n,zeros:r,identity:a,isZero:i,equal:s,sign:o,sqrt:u,conj:l,unaryMinus:c,addScalar:p,divideScalar:d,multiplyScalar:h,subtract:f,complex:m}=e;return $P(t("qr",{DenseMatrix:function(e){return y(e)},SparseMatrix:function(e){return function(e){throw new Error("qr not implemented for sparse matrices yet")}()},Array:function(e){var t=y(n(e));return{Q:t.Q.valueOf(),R:t.R.valueOf()}}}),{_denseQRimpl:g});function g(e){var t,n,m,g=e._size[0],y=e._size[1],b=a([g],"dense"),v=b._data,x=e.clone(),_=x._data,w=r([g],"");for(m=0;m0)for(var r="Complex"===n[0][0].type?m(0):0,a=0;a{var{typed:t,config:n,matrix:r,bignumber:a,smaller:i,smallerEq:s,larger:o,largerEq:u}=e;return t(U0,{string:c,"string, boolean":c,"number, number":function(e,t){return l(p(e,t,1))},"number, number, number":function(e,t,n){return l(p(e,t,n))},"number, number, boolean":function(e,t,n){return l(n?d(e,t,1):p(e,t,1))},"number, number, number, boolean":function(e,t,n,r){return l(r?d(e,t,n):p(e,t,n))},"BigNumber, BigNumber":function(e,t){return l(h(e,t,new(0,e.constructor)(1)))},"BigNumber, BigNumber, BigNumber":function(e,t,n){return l(h(e,t,n))},"BigNumber, BigNumber, boolean":function(e,t,n){var r=e.constructor;return l(n?f(e,t,new r(1)):h(e,t,new r(1)))},"BigNumber, BigNumber, BigNumber, boolean":function(e,t,n,r){return l(r?f(e,t,n):h(e,t,n))}});function l(e){return"Matrix"===n.matrix?r?r(e):rZ():e}function c(e,t){var r=function(e){var t=e.split(":").map((function(e){return Number(e)})),n=t.some((function(e){return isNaN(e)}));if(n)return null;switch(t.length){case 2:return{start:t[0],end:t[1],step:1};case 3:return{start:t[0],end:t[2],step:t[1]};default:return null}}(e);if(!r)throw new SyntaxError('String "'+e+'" is no valid range');return"BigNumber"===n.number?(void 0===a&&tZ(),l((t?f:h)(a(r.start),a(r.end),a(r.step)))):l((t?d:p)(r.start,r.end,r.step))}function p(e,t,n){var r=[],a=e;if(n>0)for(;i(a,t);)r.push(a),a+=n;else if(n<0)for(;o(a,t);)r.push(a),a+=n;return r}function d(e,t,n){var r=[],a=e;if(n>0)for(;s(a,t);)r.push(a),a+=n;else if(n<0)for(;u(a,t);)r.push(a),a+=n;return r}function h(e,t,n){var r=a(0),s=[],u=e;if(n.gt(r))for(;i(u,t);)s.push(u),u=u.plus(n);else if(n.lt(r))for(;o(u,t);)s.push(u),u=u.plus(n);return s}function f(e,t,n){var r=a(0),i=[],o=e;if(n.gt(r))for(;s(o,t);)i.push(o),o=o.plus(n);else if(n.lt(r))for(;u(o,t);)i.push(o),o=o.plus(n);return i}})),W0="rightLogShift",V0=_U(W0,["typed","matrix","equalScalar","zeros","DenseMatrix"],(e=>{var{typed:t,matrix:n,equalScalar:r,zeros:a,DenseMatrix:i}=e,s=XX({typed:t}),o=HX({typed:t,equalScalar:r}),u=SQ({typed:t,equalScalar:r}),l=MZ({typed:t,DenseMatrix:i}),c=qX({typed:t,equalScalar:r}),p=GX({typed:t}),d=KX({typed:t,matrix:n}),h=kQ({typed:t,matrix:n});return t(W0,{"number, number":eK,"SparseMatrix, number | BigNumber":t.referToSelf((e=>(t,n)=>r(n,0)?t.clone():c(t,n,e,!1))),"DenseMatrix, number | BigNumber":t.referToSelf((e=>(t,n)=>r(n,0)?t.clone():p(t,n,e,!1))),"number | BigNumber, SparseMatrix":t.referToSelf((e=>(t,n)=>r(t,0)?a(n.size(),n.storage()):l(n,t,e,!0))),"number | BigNumber, DenseMatrix":t.referToSelf((e=>(t,n)=>r(t,0)?a(n.size(),n.storage()):p(n,t,e,!0)))},h,d({SS:u,DS:s,SD:o}))})),G0="setSize",K0=_U(G0,["typed","compareNatural"],(e=>{var{typed:t,compareNatural:n}=e;return t(G0,{"Array | Matrix":function(e){return Array.isArray(e)?ZW(e).length:ZW(e.toArray()).length},"Array | Matrix, boolean":function(e,t){if(!1===t||0===e.length)return Array.isArray(e)?ZW(e).length:ZW(e.toArray()).length;for(var r=ZW(Array.isArray(e)?e:e.toArray()).sort(n),a=1,i=1;i=0;){var u=n[s+o],l=n[r+u];-1===l?(o--,i[t++]=u):(n[r+u]=n[a+l],n[s+ ++o]=l)}return t}function X0(e){return-e-2}var Z0=_U("csAmd",["add","multiply","transpose"],(e=>{var{add:t,multiply:n,transpose:r}=e;return function(e,s){if(!s||e<=0||e>3)return null;var o=s._size,u=o[0],l=o[1],c=0,p=Math.max(16,10*Math.sqrt(l)),d=function(e,a,i,s,o){var u=r(a);if(1===e&&s===i)return t(a,u);if(2===e){for(var l=u._index,c=u._ptr,p=0,d=0;do))for(var f=c[d+1];hs)n[o+d]=0,n[a+d]=-1,p++,t[d]=X0(e),n[o+e]++;else{var f=n[u+h];-1!==f&&(l[f]=d),n[c+d]=n[u+h],n[u+h]=d}}return p}(l,E,L,Y,R,B,p,F,O,P,$),U=0;jq?(b=m,v=G,x=L[0+m]-q):(v=E[b=C[G++]],x=L[0+b]),y=1;y<=x;y++)(_=L[F+(h=C[v++])])<=0||(V+=_,L[F+h]=-_,C[J++]=h,-1!==L[$+h]&&(P[L[$+h]]=P[h]),-1!==P[h]?L[$+P[h]]=L[$+h]:L[O+L[Y+h]]=L[$+h]);b!==m&&(E[b]=X0(m),L[B+b]=0)}for(0!==q&&(A=J),L[Y+m]=V,E[m]=K,L[0+m]=J-K,L[R+m]=-2,H=a(H,c,L,B,l),w=K;w=H?L[B+b]-=_:0!==L[B+b]&&(L[B+b]=L[Y+b]+X)}for(w=K;w0?(T+=Z,C[S++]=b,k+=b):(E[b]=X0(m),L[B+b]=0)}L[R+h]=S-N+1;var Q=S,ee=N+L[0+h];for(G=M+1;G=0))for(h=L[z+(k=P[h])],L[z+k]=-1;-1!==h&&-1!==L[$+h];h=L[$+h],H++){for(x=L[0+h],D=L[R+h],G=E[h]+1;G<=E[h]+x-1;G++)L[B+C[G]]=H;var ne=h;for(f=L[$+h];-1!==f;){var re=L[0+f]===x&&L[R+f]===D;for(G=E[f]+1;re&&G<=E[f]+x-1;G++)L[B+C[G]]!==H&&(re=0);re?(E[f]=X0(h),L[F+h]+=L[F+f],L[F+f]=0,L[R+f]=-1,f=L[$+f],L[$+ne]=f):(ne=f,f=L[$+f])}}for(G=K,w=K;w=0;f--)L[F+f]>0||(L[$+f]=L[O+E[f]],L[O+E[f]]=f);for(b=l;b>=0;b--)L[F+b]<=0||-1!==E[b]&&(L[$+b]=L[O+E[b]],L[O+E[b]]=b);for(m=0,h=0;h<=l;h++)-1===E[h]&&(m=J0(h,m,L,O,$,I,B));return I.splice(I.length-1,1),I};function a(e,t,n,r,a){if(e<2||e+t<0){for(var i=0;i{var{transpose:t}=e;return function(e,n,r,a){if(!e||!n||!r)return null;var i,s,o,u,l,c,p,d=e._size,h=d[0],f=d[1],m=4*f+(a?f+h+1:0),g=[],y=f,b=2*f,v=3*f,x=4*f,_=5*f+1;for(o=0;o=1&&w[s]++,2===S.jleaf&&w[S.q]--}-1!==n[s]&&(g[0+s]=n[s])}for(s=0;s{var{add:t,multiply:n,transpose:r}=e,a=Z0({add:t,multiply:n,transpose:r}),i=e1({transpose:r});return function(e,t,n){var r,s=t._ptr,o=t._size[1],u={};if(u.q=a(e,t),e&&!u.q)return null;if(n){var l=e?function(e,t,n,r){for(var a=e._values,i=e._index,s=e._ptr,o=e._size,u=e._datatype,l=o[0],c=o[1],p=null,d=[],h=[],f=0,m=0;m=0;n--)-1!==e[n]&&(i[s+n]=i[0+e[n]],i[0+e[n]]=n);for(n=0;n=0;u--)for(c=n[u],p=n[u+1],l=c;l=0;o--)h[o]=-1,-1!==(u=f[o])&&(0==m[b+u]++&&(m[y+u]=o),m[0+o]=m[g+u],m[g+u]=o);for(t.lnz=0,t.m2=i,u=0;u=0;){e=r[p];var d=a?a[e]:e;n1(l,e)||(r1(l,e),r[c+p]=d<0?0:a1(l[d]));var h=1;for(s=r[c+p],o=d<0?0:a1(l[d+1]);s{var{divideScalar:t,multiply:n,subtract:r}=e;return function(e,a,i,s,o,u,l){var c,p,d,h,f=e._values,m=e._index,g=e._ptr,y=e._size[1],b=a._values,v=a._index,x=a._ptr,_=function(e,t,n,r,a){var i,s,o,u=e._ptr,l=e._size,c=t._index,p=t._ptr,d=l[1],h=d;for(s=p[n],o=p[n+1],i=s;i{var{abs:t,divideScalar:n,multiply:r,subtract:a,larger:i,largerEq:s,SparseMatrix:o}=e,u=s1({divideScalar:n,multiply:r,subtract:a});return function(e,a,l){if(!e)return null;var c,p=e._size[1],d=100,h=100;a&&(c=a.q,d=a.lnz||d,h=a.unz||h);var f,m,g=[],y=[],b=[],v=new o({values:g,index:y,ptr:b,size:[p,p]}),x=[],_=[],w=[],D=new o({values:x,index:_,ptr:w,size:[p,p]}),N=[],M=[],S=[];for(f=0;f{var{typed:t,abs:n,add:r,multiply:a,transpose:i,divideScalar:s,subtract:o,larger:u,largerEq:l,SparseMatrix:c}=e,p=t1({add:r,multiply:a,transpose:i}),d=o1({abs:n,divideScalar:s,multiply:a,subtract:o,larger:u,largerEq:l,SparseMatrix:c});return t("slu",{"SparseMatrix, number, number":function(e,t,n){if(!SU(t)||t<0||t>3)throw new Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");if(n<0||n>1)throw new Error("Partial pivoting threshold must be a number from 0 to 1");var r=p(t,e,!1),a=d(e,r,n);return{L:a.L,U:a.U,p:a.pinv,q:r.q,toString:function(){return"L: "+this.L.toString()+"\nU: "+this.U.toString()+"\np: "+this.p.toString()+(this.q?"\nq: "+this.q.toString():"")+"\n"}}}})})),l1=_U("sum",["typed","config","add","numeric"],(e=>{var{typed:t,config:n,add:r,numeric:a}=e;return t("sum",{"Array | Matrix":i,"Array | Matrix, number | BigNumber":function(e,t){try{return IV(e,t,r)}catch(e){throw sZ(e,"sum")}},"...":function(e){if(CV(e))throw new TypeError("Scalar values expected in function sum");return i(e)}});function i(e){var t;return EV(e,(function(e){try{t=void 0===t?e:r(t,e)}catch(t){throw sZ(t,"sum",e)}})),void 0===t&&(t=a(0,n.number)),"string"==typeof t&&(t=a(t,n.number)),t}})),c1=_U("trace",["typed","matrix","add"],(e=>{var{typed:t,matrix:n,add:r}=e;return t("trace",{Array:function(e){return a(n(e))},SparseMatrix:function(e){var t=e._values,n=e._index,a=e._ptr,i=e._size,s=i[0],o=i[1];if(s===o){var u=0;if(t.length>0)for(var l=0;ll)break}return u}throw new RangeError("Matrix must be square (size: "+IW(i)+")")},DenseMatrix:a,any:DH});function a(e){var t=e._size,n=e._data;switch(t.length){case 1:if(1===t[0])return DH(n[0]);throw new RangeError("Matrix must be square (size: "+IW(t)+")");case 2:var a=t[0];if(a===t[1]){for(var i=0,s=0;s{var{typed:t,matrix:n,divideScalar:r,multiplyScalar:a,subtract:i,equalScalar:s,DenseMatrix:o}=e,u=EQ({DenseMatrix:o});return t(p1,{"SparseMatrix, Array | Matrix":function(e,t){return function(e,t){for(var n=[u(e,t,!0)._data.map((e=>e[0]))],l=e._size[0],c=e._size[1],p=e._values,d=e._index,h=e._ptr,f=c-1;f>=0;f--)for(var m=n.length,g=0;g=x;w--){var D=d[w];D===f?_=p[w]:Dnew o({data:e.map((e=>[e])),size:[l,1]})))}(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return l(e,t)},"Array, Array | Matrix":function(e,t){return l(n(e),t).map((e=>e.valueOf()))}});function l(e,t){for(var n=[u(e,t,!0)._data.map((e=>e[0]))],l=e._data,c=e._size[0],p=e._size[1]-1;p>=0;p--)for(var d=n.length,h=0;h=0;g--)m[g]=i(m[g],l[g][p]);n.push(m)}}else{if(0===h)return[];n.splice(h,1),h-=1,d-=1}else{f[p]=r(f[p],l[p][p]);for(var y=p-1;y>=0;y--)f[y]=i(f[y],a(f[p],l[y][p]))}}return n.map((e=>new o({data:e.map((e=>[e])),size:[c,1]})))}})),h1="asin",f1=_U(h1,["typed","config","Complex"],(e=>{var{typed:t,config:n,Complex:r}=e;return t(h1,{number:function(e){return e>=-1&&e<=1||n.predictable?Math.asin(e):new r(e,0).asin()},Complex:function(e){return e.asin()},BigNumber:function(e){return e.asin()}})})),m1="ceil",g1=["typed","config","round","matrix","equalScalar","zeros","DenseMatrix"],y1=_U(m1,["typed","config","round"],(e=>{var{typed:t,config:n,round:r}=e;return t(m1,{number:function(e){return PU(e,r(e),n.epsilon)?r(e):Math.ceil(e)},"number, number":function(e,t){if(PU(e,r(e,t),n.epsilon))return r(e,t);var[a,i]="".concat(e,"e").split("e"),s=Math.ceil(Number("".concat(a,"e").concat(Number(i)+t)));return[a,i]="".concat(s,"e").split("e"),Number("".concat(a,"e").concat(Number(i)-t))}})})),b1=_U(m1,g1,(e=>{var{typed:t,config:n,round:r,matrix:a,equalScalar:i,zeros:s,DenseMatrix:o}=e,u=qX({typed:t,equalScalar:i}),l=WX({typed:t,DenseMatrix:o}),c=GX({typed:t}),p=y1({typed:t,config:n,round:r});return t("ceil",{number:p.signatures.number,"number,number":p.signatures["number,number"],Complex:function(e){return e.ceil()},"Complex, number":function(e,t){return e.ceil(t)},"Complex, BigNumber":function(e,t){return e.ceil(t.toNumber())},BigNumber:function(e){return DK(e,r(e),n.epsilon)?r(e):e.ceil()},"BigNumber, BigNumber":function(e,t){return DK(e,r(e,t),n.epsilon)?r(e,t):e.toDecimalPlaces(t.toNumber(),xU.ROUND_CEIL)},Fraction:function(e){return e.ceil()},"Fraction, number":function(e,t){return e.ceil(t)},"Fraction, BigNumber":function(e,t){return e.ceil(t.toNumber())},"Array | Matrix":t.referToSelf((e=>t=>AV(t,e,!0))),"Array, number | BigNumber":t.referToSelf((e=>(t,n)=>AV(t,(t=>e(t,n)),!0))),"SparseMatrix, number | BigNumber":t.referToSelf((e=>(t,n)=>u(t,n,e,!1))),"DenseMatrix, number | BigNumber":t.referToSelf((e=>(t,n)=>c(t,n,e,!1))),"number | Complex | Fraction | BigNumber, Array":t.referToSelf((e=>(t,n)=>c(a(n),t,e,!0).valueOf())),"number | Complex | Fraction | BigNumber, Matrix":t.referToSelf((e=>(t,n)=>i(t,0)?s(n.size(),n.storage()):"dense"===n.storage()?c(n,t,e,!0):l(n,t,e,!0)))})})),v1="composition",x1=_U(v1,["typed","addScalar","combinations","isNegative","isPositive","isInteger","larger"],(e=>{var{typed:t,addScalar:n,combinations:r,isPositive:a,isNegative:i,isInteger:s,larger:o}=e;return t(v1,{"number | BigNumber, number | BigNumber":function(e,t){if(!(s(e)&&a(e)&&s(t)&&a(t)))throw new TypeError("Positive integer value expected in function composition");if(o(t,e))throw new TypeError("k must be less than or equal to n in function composition");return r(n(e,-1),n(t,-1))}})})),_1="cross",w1=_U(_1,["typed","matrix","subtract","multiply"],(e=>{var{typed:t,matrix:n,subtract:r,multiply:a}=e;return t(_1,{"Matrix, Matrix":function(e,t){return n(i(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return n(i(e.toArray(),t))},"Array, Matrix":function(e,t){return n(i(e,t.toArray()))},"Array, Array":i});function i(e,t){var n=Math.max(BW(e).length,BW(t).length);e=GW(e),t=GW(t);var i=BW(e),s=BW(t);if(1!==i.length||1!==s.length||3!==i[0]||3!==s[0])throw new RangeError("Vectors with length 3 expected (Size A = ["+i.join(", ")+"], B = ["+s.join(", ")+"])");var o=[r(a(e[1],t[2]),a(e[2],t[1])),r(a(e[2],t[0]),a(e[0],t[2])),r(a(e[0],t[1]),a(e[1],t[0]))];return n>1?[o]:o}})),D1=_U("det",["typed","matrix","subtract","multiply","divideScalar","isZero","unaryMinus"],(e=>{var{typed:t,matrix:n,subtract:r,multiply:a,divideScalar:i,isZero:s,unaryMinus:o}=e;return t("det",{any:function(e){return DH(e)},"Array | Matrix":function(e){var t;switch((t=UP(e)?e.size():Array.isArray(e)?(e=n(e)).size():[]).length){case 0:return DH(e);case 1:if(1===t[0])return DH(e.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+IW(t)+")");case 2:var u=t[0];if(u===t[1])return function(e,t,n){if(1===t)return DH(e[0][0]);if(2===t)return r(a(e[0][0],e[1][1]),a(e[1][0],e[0][1]));for(var u=!1,l=new Array(t).fill(0).map(((e,t)=>t)),c=0;c{var{typed:t,addScalar:n,subtract:r,multiplyScalar:a,divideScalar:i,unaryMinus:s,sqrt:o,abs:u}=e;return t(N1,{"Array, Array, Array":function(e,t,n){if(2===e.length&&2===t.length&&2===n.length){if(!c(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!c(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!c(n))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");var o=i(r(n[1],n[0]),r(t[1],t[0])),u=a(a(o,o),t[0]),l=s(a(o,t[0])),p=e[1];return m(e[0],e[1],u,l,p)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object, Object":function(e,t,n){if(2===Object.keys(e).length&&2===Object.keys(t).length&&2===Object.keys(n).length){if(!c(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!c(t))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");if(!c(n))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"lineOnePtX"in t&&"lineOnePtY"in t&&"lineTwoPtX"in n&&"lineTwoPtY"in n){var o=i(r(n.lineTwoPtY,n.lineTwoPtX),r(t.lineOnePtY,t.lineOnePtX)),u=a(a(o,o),t.lineOnePtX),l=s(a(o,t.lineOnePtX)),p=e.pointX;return m(e.pointX,e.pointY,u,l,p)}throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},"Array, Array":function(e,t){if(2===e.length&&3===t.length){if(!c(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!p(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");return m(e[0],e[1],t[0],t[1],t[2])}if(3===e.length&&6===t.length){if(!p(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!h(t))throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");return g(e[0],e[1],e[2],t[0],t[1],t[2],t[3],t[4],t[5])}if(e.length===t.length&&e.length>0){if(!d(e))throw new TypeError("All values of an array should be numbers or BigNumbers");if(!d(t))throw new TypeError("All values of an array should be numbers or BigNumbers");return y(e,t)}throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(e,t){if(2===Object.keys(e).length&&3===Object.keys(t).length){if(!c(e))throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");if(!p(t))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"xCoeffLine"in t&&"yCoeffLine"in t&&"constant"in t)return m(e.pointX,e.pointY,t.xCoeffLine,t.yCoeffLine,t.constant);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&6===Object.keys(t).length){if(!p(e))throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");if(!h(t))throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers or BigNumbers");if("pointX"in e&&"pointY"in e&&"x0"in t&&"y0"in t&&"z0"in t&&"a"in t&&"b"in t&&"c"in t)return g(e.pointX,e.pointY,e.pointZ,t.x0,t.y0,t.z0,t.a,t.b,t.c);throw new TypeError("Key names do not match")}if(2===Object.keys(e).length&&2===Object.keys(t).length){if(!c(e))throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");if(!c(t))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointTwoX"in t&&"pointTwoY"in t)return y([e.pointOneX,e.pointOneY],[t.pointTwoX,t.pointTwoY]);throw new TypeError("Key names do not match")}if(3===Object.keys(e).length&&3===Object.keys(t).length){if(!p(e))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");if(!p(t))throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers");if("pointOneX"in e&&"pointOneY"in e&&"pointOneZ"in e&&"pointTwoX"in t&&"pointTwoY"in t&&"pointTwoZ"in t)return y([e.pointOneX,e.pointOneY,e.pointOneZ],[t.pointTwoX,t.pointTwoY,t.pointTwoZ]);throw new TypeError("Key names do not match")}throw new TypeError("Invalid Arguments: Try again")},Array:function(e){if(!function(e){if(2===e[0].length&&l(e[0][0])&&l(e[0][1])){if(e.some((e=>2!==e.length||!l(e[0])||!l(e[1]))))return!1}else{if(!(3===e[0].length&&l(e[0][0])&&l(e[0][1])&&l(e[0][2])))return!1;if(e.some((e=>3!==e.length||!l(e[0])||!l(e[1])||!l(e[2]))))return!1}return!0}(e))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return function(e){for(var t=[],n=[],r=[],a=0;a{var{typed:t,matrix:n,equalScalar:r,multiplyScalar:a}=e,i=HX({typed:t,equalScalar:r}),s=s0({typed:t,equalScalar:r}),o=qX({typed:t,equalScalar:r}),u=KX({typed:t,matrix:n});return t(S1,u({elop:a,SS:s,DS:i,Ss:o}))})),T1=_U("FibonacciHeap",["smaller","larger"],(e=>{var{smaller:t,larger:n}=e,r=1/Math.log((1+Math.sqrt(5))/2);function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}function i(e,t,n){t.left.right=t.right,t.right.left=t.left,n.degree--,n.child===t&&(n.child=t.right),0===n.degree&&(n.child=null),t.left=e,t.right=e.right,e.right=t,t.right.left=t,t.parent=null,t.mark=!1}function s(e,t){var n=t.parent;n&&(t.mark?(i(e,t,n),s(n)):t.mark=!0)}a.prototype.type="FibonacciHeap",a.prototype.isFibonacciHeap=!0,a.prototype.insert=function(e,n){var r={key:e,value:n,degree:0};if(this._minimum){var a=this._minimum;r.left=a,r.right=a.right,a.right=r,r.right.left=r,t(e,a.key)&&(this._minimum=r)}else r.left=r,r.right=r,this._minimum=r;return this._size++,r},a.prototype.size=function(){return this._size},a.prototype.clear=function(){this._minimum=null,this._size=0},a.prototype.isEmpty=function(){return 0===this._size},a.prototype.extractMinimum=function(){var e=this._minimum;if(null===e)return e;for(var a=this._minimum,i=e.degree,s=e.child;i>0;){var u=s.right;s.left.right=s.right,s.right.left=s.left,s.left=a,s.right=a.right,a.right=s,s.right.left=s,s.parent=null,s=u,i--}return e.left.right=e.right,e.right.left=e.left,a=e===e.right?null:function(e,a){var i,s=Math.floor(Math.log(a)*r)+1,u=new Array(s),l=0,c=e;if(c)for(l++,c=c.right;c!==e;)l++,c=c.right;for(;l>0;){for(var p=c.degree,d=c.right;i=u[p];){if(n(c.key,i.key)){var h=i;i=c,c=h}o(i,c),u[p]=null,p++}u[p]=c,c=d,l--}e=null;for(var f=0;f{var{typed:t,ceil:n,floor:r}=e;return t(C1,{number:function(e){return e>0?r(e):n(e)},"number, number":function(e,t){return e>0?r(e,t):n(e,t)}})})),I1=_U(C1,E1,(e=>{var{typed:t,Complex:n,matrix:r,ceil:a,floor:i,equalScalar:s,zeros:o,DenseMatrix:u}=e,l=WX({typed:t,DenseMatrix:u}),c=GX({typed:t}),p=A1({typed:t,ceil:a,floor:i});return t("fix",{number:p.signatures.number,"number, number | BigNumber":p.signatures["number,number"],Complex:function(e){return new n(e.re>0?Math.floor(e.re):Math.ceil(e.re),e.im>0?Math.floor(e.im):Math.ceil(e.im))},"Complex, number":function(e,t){return new n(e.re>0?i(e.re,t):a(e.re,t),e.im>0?i(e.im,t):a(e.im,t))},"Complex, BigNumber":function(e,t){var r=t.toNumber();return new n(e.re>0?i(e.re,r):a(e.re,r),e.im>0?i(e.im,r):a(e.im,r))},BigNumber:function(e){return e.isNegative()?a(e):i(e)},"BigNumber, number | BigNumber":function(e,t){return e.isNegative()?a(e,t):i(e,t)},Fraction:function(e){return e.s<0?e.ceil():e.floor()},"Fraction, number | BigNumber":function(e,t){return e.s<0?a(e,t):i(e,t)},"Array | Matrix":t.referToSelf((e=>t=>AV(t,e,!0))),"Array | Matrix, number | BigNumber":t.referToSelf((e=>(t,n)=>AV(t,(t=>e(t,n)),!0))),"number | Complex | Fraction | BigNumber, Array":t.referToSelf((e=>(t,n)=>c(r(n),t,e,!0).valueOf())),"number | Complex | Fraction | BigNumber, Matrix":t.referToSelf((e=>(t,n)=>s(t,0)?o(n.size(),n.storage()):"dense"===n.storage()?c(n,t,e,!0):l(n,t,e,!0)))})})),L1=_U("ImmutableDenseMatrix",["smaller","DenseMatrix"],(e=>{var{smaller:t,DenseMatrix:n}=e;function r(e,t){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!HP(t))throw new Error("Invalid datatype: "+t);if(UP(e)||jP(e)){var a=new n(e,t);this._data=a._data,this._size=a._size,this._datatype=a._datatype,this._min=null,this._max=null}else if(e&&jP(e.data)&&jP(e.size))this._data=e.data,this._size=e.size,this._datatype=e.datatype,this._min=void 0!==e.min?e.min:null,this._max=void 0!==e.max?e.max:null;else{if(e)throw new TypeError("Unsupported type of data ("+wH(e)+")");this._data=[],this._size=[0],this._datatype=t,this._min=null,this._max=null}}return r.prototype=new n,r.prototype.type="ImmutableDenseMatrix",r.prototype.isImmutableDenseMatrix=!0,r.prototype.subset=function(e){switch(arguments.length){case 1:var t=n.prototype.subset.call(this,e);return UP(t)?new r({data:t._data,size:t._size,datatype:t._datatype}):t;case 2:case 3:throw new Error("Cannot invoke set subset on an Immutable Matrix instance");default:throw new SyntaxError("Wrong number of arguments")}},r.prototype.set=function(){throw new Error("Cannot invoke set on an Immutable Matrix instance")},r.prototype.resize=function(){throw new Error("Cannot invoke resize on an Immutable Matrix instance")},r.prototype.reshape=function(){throw new Error("Cannot invoke reshape on an Immutable Matrix instance")},r.prototype.clone=function(){return new r({data:DH(this._data),size:DH(this._size),datatype:this._datatype})},r.prototype.toJSON=function(){return{mathjs:"ImmutableDenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},r.fromJSON=function(e){return new r(e)},r.prototype.swapRows=function(){throw new Error("Cannot invoke swapRows on an Immutable Matrix instance")},r.prototype.min=function(){if(null===this._min){var e=null;this.forEach((function(n){(null===e||t(n,e))&&(e=n)})),this._min=null!==e?e:void 0}return this._min},r.prototype.max=function(){if(null===this._max){var e=null;this.forEach((function(n){(null===e||t(e,n))&&(e=n)})),this._max=null!==e?e:void 0}return this._max},r}),{isClass:!0}),F1=_U("Index",["ImmutableDenseMatrix"],(e=>{var{ImmutableDenseMatrix:t}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._dimensions=[],this._isScalar=!0;for(var t=0,a=arguments.length;t{var{typed:t,config:n,abs:r,add:a,addScalar:i,matrix:s,multiply:o,multiplyScalar:u,divideScalar:l,subtract:c,smaller:p,equalScalar:d,flatten:h,isZero:f,isNumeric:m}=e;return t("intersect",{"Array, Array, Array":g,"Array, Array, Array, Array":y,"Matrix, Matrix, Matrix":function(e,t,n){var r=g(e.valueOf(),t.valueOf(),n.valueOf());return null===r?null:s(r)},"Matrix, Matrix, Matrix, Matrix":function(e,t,n,r){var a=y(e.valueOf(),t.valueOf(),n.valueOf(),r.valueOf());return null===a?null:s(a)}});function g(e,t,n){if(e=b(e),t=b(t),n=b(n),!x(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!x(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!function(e){return 4===e.length&&m(e[0])&&m(e[1])&&m(e[2])&&m(e[3])}(n))throw new TypeError("Array with 4 numbers expected as third argument");return function(e,t,n,r,a,s,o,p,d,h){var f=u(e,o),m=u(r,o),g=u(t,p),y=u(a,p),b=u(n,d),v=u(s,d),x=c(c(c(h,f),g),b),_=c(c(c(i(i(m,y),v),f),g),b),w=l(x,_);return[i(e,u(w,c(r,e))),i(t,u(w,c(a,t))),i(n,u(w,c(s,n)))]}(e[0],e[1],e[2],t[0],t[1],t[2],n[0],n[1],n[2],n[3])}function y(e,t,s,h){if(e=b(e),t=b(t),s=b(s),h=b(h),2===e.length){if(!v(e))throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");if(!v(t))throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");if(!v(s))throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");if(!v(h))throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");return function(e,t,s,d){var h=e,m=s,g=c(h,t),y=c(m,d),b=c(u(g[0],y[1]),u(y[0],g[1]));if(f(b))return null;if(p(r(b),n.epsilon))return null;var v=u(y[0],h[1]),x=u(y[1],h[0]),_=u(y[0],m[1]),w=u(y[1],m[0]),D=l(i(c(c(v,x),_),w),b);return a(o(g,D),h)}(e,t,s,h)}if(3===e.length){if(!x(e))throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");if(!x(t))throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");if(!x(s))throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");if(!x(h))throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");return function(e,t,n,r,a,s,o,p,h,m,g,y){var b=_(e,o,m,o,t,p,g,p,n,h,y,h),v=_(m,o,r,e,g,p,a,t,y,h,s,n),x=_(e,o,r,e,t,p,a,t,n,h,s,n),w=_(m,o,m,o,g,p,g,p,y,h,y,h),D=_(r,e,r,e,a,t,a,t,s,n,s,n),N=c(u(b,v),u(x,w)),M=c(u(D,w),u(v,v));if(f(M))return null;var S=l(N,M),k=l(i(b,u(S,v)),w),T=i(e,u(S,c(r,e))),C=i(t,u(S,c(a,t))),E=i(n,u(S,c(s,n))),A=i(o,u(k,c(m,o))),I=i(p,u(k,c(g,p))),L=i(h,u(k,c(y,h)));return d(T,A)&&d(C,I)&&d(E,L)?[T,C,E]:null}(e[0],e[1],e[2],t[0],t[1],t[2],s[0],s[1],s[2],h[0],h[1],h[2])}throw new TypeError("Arrays with two or thee dimensional points expected")}function b(e){return 1===e.length?e[0]:e.length>1&&Array.isArray(e[0])&&e.every((e=>Array.isArray(e)&&1===e.length))?h(e):e}function v(e){return 2===e.length&&m(e[0])&&m(e[1])}function x(e){return 3===e.length&&m(e[0])&&m(e[1])&&m(e[2])}function _(e,t,n,r,a,s,o,l,p,d,h,f){var m=u(c(e,t),c(n,r)),g=u(c(a,s),c(o,l)),y=u(c(p,d),c(h,f));return i(i(m,g),y)}})),O1=_U("lcm",["typed","matrix","equalScalar"],(e=>{var{typed:t,matrix:n,equalScalar:r}=e,a=HX({typed:t,equalScalar:r}),i=ZX({typed:t,equalScalar:r}),s=qX({typed:t,equalScalar:r}),o=KX({typed:t,matrix:n}),u="number | BigNumber | Fraction | Matrix | Array",l={};return l["".concat(u,", ").concat(u,", ...").concat(u)]=t.referToSelf((e=>(t,n,r)=>{for(var a=e(t,n),i=0;ie.lcm(t)},o({SS:i,DS:a,Ss:s}),l)})),R1="log1p",Y1=_U(R1,["typed","config","divideScalar","log","Complex"],(e=>{var{typed:t,config:n,divideScalar:r,log:a,Complex:i}=e;return t(R1,{number:function(e){return e>=-1||n.predictable?EU(e):s(new i(e,0))},Complex:s,BigNumber:function(e){var t=e.plus(1);return!t.isNegative()||n.predictable?t.ln():s(new i(e.toNumber(),0))},"Array | Matrix":t.referToSelf((e=>t=>AV(t,e))),"any, any":t.referToSelf((e=>(t,n)=>r(e(t),a(n))))});function s(e){var t=e.re+1;return new i(Math.log(Math.sqrt(t*t+e.im*e.im)),Math.atan2(e.im,t))}})),B1=_U("max",["typed","config","numeric","larger"],(e=>{var{typed:t,config:n,numeric:r,larger:a}=e;return t("max",{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(e,t){return IV(e,t.valueOf(),i)},"...":function(e){if(CV(e))throw new TypeError("Scalar values expected in function max");return s(e)}});function i(e,t){try{return a(e,t)?e:t}catch(e){throw sZ(e,"max",t)}}function s(e){var t;if(EV(e,(function(e){try{isNaN(e)&&"number"==typeof e?t=NaN:(void 0===t||a(e,t))&&(t=e)}catch(t){throw sZ(t,"max",e)}})),void 0===t)throw new Error("Cannot calculate max of an empty array");return"string"==typeof t&&(t=r(t,n.number)),t}})),z1=_U("quantileSeq",["typed","add","multiply","partitionSelect","compare"],(e=>{var{typed:t,add:n,multiply:r,partitionSelect:a,compare:i}=e;function s(e,t,s){var u=ZW(e),l=u.length;if(0===l)throw new Error("Cannot calculate quantile of an empty sequence");if(RP(t)){var c=t*(l-1),p=c%1;if(0===p){var d=s?u[c]:a(u,c);return o(d),d}var h,f,m=Math.floor(c);if(s)h=u[m],f=u[m+1];else{f=a(u,m+1),h=u[m];for(var g=0;g0&&(h=u[g])}return o(h),o(f),n(r(h,1-p),r(f,p))}var y=t.times(l-1);if(y.isInteger()){y=y.toNumber();var b=s?u[y]:a(u,y);return o(b),b}var v,x,_=y.floor(),w=y.minus(_),D=_.toNumber();if(s)v=u[D],x=u[D+1];else{x=a(u,D+1),v=u[D];for(var N=0;N0&&(v=u[N])}o(v),o(x);var M=new w.constructor(1);return n(r(v,M.minus(w)),r(x,w))}var o=t({"number | BigNumber | Unit":function(e){return e}});return function(e,t,n){var r,a,i;if(arguments.length<2||arguments.length>3)throw new SyntaxError("Function quantileSeq requires two or three parameters");if(qP(e)){if("boolean"==typeof(n=n||!1)){if(a=e.valueOf(),RP(t)){if(t<0)throw new Error("N/prob must be non-negative");if(t<=1)return s(a,t,n);if(t>1){if(!SU(t))throw new Error("N must be a positive integer");var o=t+1;r=new Array(t);for(var u=0;u4294967295)throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");var p=new l(c+1);r=new Array(c);for(var d=0;d1)throw new Error("Probability must be between 0 and 1, inclusive")}else{if(!YP(f))throw new TypeError("Unexpected type of argument in function quantileSeq");if(i=new f.constructor(1),f.isNegative()||f.gt(i))throw new Error("Probability must be between 0 and 1, inclusive")}r[h]=s(a,f,n)}return r}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}})),P1=_U("row",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:n,matrix:r,range:a}=e;return t("row",{"Matrix, number":i,"Array, number":function(e,t){return i(r(DH(e)),t).valueOf()}});function i(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");HW(t,e.size()[0]);var r=a(0,e.size()[1]),i=new n(t,r);return e.subset(i)}})),H1="setCartesian",j1=_U(H1,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:n,subset:r,compareNatural:a,Index:i,DenseMatrix:s}=e;return t(H1,{"Array | Matrix, Array | Matrix":function(e,t){var o=[];if(0!==r(n(e),new i(0))&&0!==r(n(t),new i(0))){var u=ZW(Array.isArray(e)?e:e.toArray()).sort(a),l=ZW(Array.isArray(t)?t:t.toArray()).sort(a);o=[];for(var c=0;c{var{typed:t,size:n,subset:r,compareNatural:a,Index:i,DenseMatrix:s}=e;return t(U1,{"Array | Matrix":function(e){var t;if(0===r(n(e),new i(0)))t=[];else{var o=ZW(Array.isArray(e)?e:e.toArray()).sort(a);(t=[]).push(o[0]);for(var u=1;u{var{typed:t,size:n,subset:r,compareNatural:a,Index:i}=e;return t(W1,{"Array | Matrix, Array | Matrix":function(e,t){if(0===r(n(e),new i(0)))return!0;if(0===r(n(t),new i(0)))return!1;for(var s,o=aV(ZW(Array.isArray(e)?e:e.toArray()).sort(a)),u=aV(ZW(Array.isArray(t)?t:t.toArray()).sort(a)),l=0;l{var{typed:t,size:n,subset:r,compareNatural:a,Index:i}=e;return t(G1,{"Array | Matrix":function(e){if(0===r(n(e),new i(0)))return[];for(var t=ZW(Array.isArray(e)?e:e.toArray()).sort(a),o=[],u=0;u.toString(2).length<=t.length;)o.push(s(t,u.toString(2).split("").reverse())),u++;return function(e){for(var t=[],n=e.length-1;n>0;n--)for(var r=0;re[r+1].length&&(t=e[r],e[r]=e[r+1],e[r+1]=t);return e}(o)}});function s(e,t){for(var n=[],r=0;r{var{typed:t,matrix:n,compare:r,compareNatural:a}=e,i=r,s=(e,t)=>-r(e,t);return t(J1,{Array:function(e){return u(e),e.sort(i)},Matrix:function(e){return l(e),n(e.toArray().sort(i),e.storage())},"Array, function":function(e,t){return u(e),e.sort(t)},"Matrix, function":function(e,t){return l(e),n(e.toArray().sort(t),e.storage())},"Array, string":function(e,t){return u(e),e.sort(o(t))},"Matrix, string":function(e,t){return l(e),n(e.toArray().sort(o(t)),e.storage())}});function o(e){if("asc"===e)return i;if("desc"===e)return s;if("natural"===e)return a;throw new Error('String "asc", "desc", or "natural" expected')}function u(e){if(1!==BW(e).length)throw new Error("One dimensional array expected")}function l(e){if(1!==e.size().length)throw new Error("One dimensional matrix expected")}})),Z1="column",Q1=_U(Z1,["typed","Index","matrix","range"],(e=>{var{typed:t,Index:n,matrix:r,range:a}=e;return t(Z1,{"Matrix, number":i,"Array, number":function(e,t){return i(r(DH(e)),t).valueOf()}});function i(e,t){if(2!==e.size().length)throw new Error("Only two dimensional matrix is supported");HW(t,e.size()[1]);var r=a(0,e.size()[0]),i=new n(r,t);return e.subset(i)}})),e2="index",t2=_U(e2,["typed","Index"],(e=>{var{typed:t,Index:n}=e;return t(e2,{"...number | string | BigNumber | Range | Array | Matrix":function(e){var t=e.map((function(e){return YP(e)?e.toNumber():Array.isArray(e)||UP(e)?e.map((function(e){return YP(e)?e.toNumber():e})):e})),r=new n;return n.apply(r,t),r}})})),n2=_U("inv",["typed","matrix","divideScalar","addScalar","multiply","unaryMinus","det","identity","abs"],(e=>{var{typed:t,matrix:n,divideScalar:r,addScalar:a,multiply:i,unaryMinus:s,det:o,identity:u,abs:l}=e;return t("inv",{"Array | Matrix":function(e){var t=UP(e)?e.size():BW(e);switch(t.length){case 1:if(1===t[0])return UP(e)?n([r(1,e.valueOf()[0])]):[r(1,e[0])];throw new RangeError("Matrix must be square (size: "+IW(t)+")");case 2:var a=t[0],i=t[1];if(a===i)return UP(e)?n(c(e.valueOf(),a,i),e.storage()):c(e,a,i);throw new RangeError("Matrix must be square (size: "+IW(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+IW(t)+")")}},any:function(e){return r(1,e)}});function c(e,t,n){var c,p,d,h,f;if(1===t){if(0===(h=e[0][0]))throw Error("Cannot calculate inverse, determinant is zero");return[[r(1,h)]]}if(2===t){var m=o(e);if(0===m)throw Error("Cannot calculate inverse, determinant is zero");return[[r(e[1][1],m),r(s(e[0][1]),m)],[r(s(e[1][0]),m),r(e[0][0],m)]]}var g=e.concat();for(c=0;cv&&(v=l(g[c][b]),x=c),c++;if(0===v)throw Error("Cannot calculate inverse, determinant is zero");(c=x)!==b&&(f=g[b],g[b]=g[c],g[c]=f,f=y[b],y[b]=y[c],y[c]=f);var _=g[b],w=y[b];for(c=0;c{var{typed:t,matrix:n,inv:r,deepEqual:a,equal:i,dotDivide:s,dot:o,ctranspose:u,divideScalar:l,multiply:c,add:p,Complex:d}=e;return t(r2,{"Array | Matrix":function(e){var t=UP(e)?e.size():BW(e);switch(t.length){case 1:return m(e)?u(e):1===t[0]?r(e):s(u(e),o(e,e));case 2:if(m(e))return u(e);var a=t[0],i=t[1];if(a===i)try{return r(e)}catch(e){if(!(e instanceof Error&&e.message.match(/Cannot calculate inverse, determinant is zero/)))throw e}return UP(e)?n(h(e.valueOf(),a,i),e.storage()):h(e,a,i);default:throw new RangeError("Matrix must be two dimensional (size: "+IW(t)+")")}},any:function(e){return i(e,0)?DH(e):l(1,e)}});function h(e,t,n){var{C:a,F:i}=function(e,t,n){var r=function(e,t,n){for(var r=DH(e),a=0,i=0;ie.filter(((e,n)=>n!f(o(r[t],r[t]))));return{C:a,F:i}}(e,t,n),l=c(r(c(u(a),a)),u(a)),d=c(u(i),r(c(i,u(i))));return c(d,l)}function f(e){return i(p(e,d(1,1)),p(0,d(1,1)))}function m(e){return a(p(e,d(1,1)),p(c(e,0),d(1,1)))}})),i2=_U("pow",["typed","config","identity","multiply","matrix","inv","fraction","number","Complex"],(e=>{var{typed:t,config:n,identity:r,multiply:a,matrix:i,inv:s,number:o,fraction:u,Complex:l}=e;return t("pow",{"number, number":c,"Complex, Complex":function(e,t){return e.pow(t)},"BigNumber, BigNumber":function(e,t){return t.isInteger()||e>=0||n.predictable?e.pow(t):new l(e.toNumber(),0).pow(t.toNumber(),0)},"Fraction, Fraction":function(e,t){var r=e.pow(t);if(null!=r)return r;if(n.predictable)throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");return c(e.valueOf(),t.valueOf())},"Array, number":p,"Array, BigNumber":function(e,t){return p(e,t.toNumber())},"Matrix, number":d,"Matrix, BigNumber":function(e,t){return d(e,t.toNumber())},"Unit, number | BigNumber":function(e,t){return e.pow(t)}});function c(e,t){if(n.predictable&&!SU(t)&&e<0)try{var r=u(t),a=o(r);if((t===a||Math.abs((t-a)/t)<1e-14)&&r.d%2==1)return(r.n%2==0?1:-1)*Math.pow(-e,t)}catch(e){}return n.predictable&&(e<-1&&t===1/0||e>-1&&e<0&&t===-1/0)?NaN:SU(t)||e>=0||n.predictable?tG(e,t):e*e<1&&t===1/0||e*e>1&&t===-1/0?0:new l(e,0).pow(t,0)}function p(e,t){if(!SU(t))throw new TypeError("For A^b, b must be an integer (value is "+t+")");var n=BW(e);if(2!==n.length)throw new Error("For A^b, A must be 2 dimensional (A has "+n.length+" dimensions)");if(n[0]!==n[1])throw new Error("For A^b, A must be square (size is "+n[0]+"x"+n[1]+")");if(t<0)try{return p(s(e),-t)}catch(e){if("Cannot calculate inverse, determinant is zero"===e.message)throw new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is "+t+")");throw e}for(var i=r(n[0]).valueOf(),o=e;t>=1;)1==(1&t)&&(i=a(o,i)),t>>=1,o=a(o,o);return i}function d(e,t){return i(p(e.valueOf(),t))}})),s2="setDifference",o2=_U(s2,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:n,subset:r,compareNatural:a,Index:i,DenseMatrix:s}=e;return t(s2,{"Array | Matrix, Array | Matrix":function(e,t){var o;if(0===r(n(e),new i(0)))o=[];else{if(0===r(n(t),new i(0)))return ZW(e.toArray());var u,l=aV(ZW(Array.isArray(e)?e:e.toArray()).sort(a)),c=aV(ZW(Array.isArray(t)?t:t.toArray()).sort(a));o=[];for(var p=0;p{var{typed:t,size:n,subset:r,compareNatural:a,Index:i}=e;return t(u2,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(e,t){if(0===r(n(t),new i(0)))return 0;for(var s=ZW(Array.isArray(t)?t:t.toArray()),o=0,u=0;u{var{addScalar:t,equalScalar:n,FibonacciHeap:r}=e;function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new r}return a.prototype.type="Spa",a.prototype.isSpa=!0,a.prototype.set=function(e,t){if(this._values[e])this._values[e].value=t;else{var n=this._heap.insert(e,t);this._values[e]=n}},a.prototype.get=function(e){var t=this._values[e];return t?t.value:0},a.prototype.accumulate=function(e,n){var r=this._values[e];r?r.value=t(r.value,n):(r=this._heap.insert(e,n),this._values[e]=r)},a.prototype.forEach=function(e,t,r){var a=this._heap,i=this._values,s=[],o=a.extractMinimum();for(o&&s.push(o);o&&o.key<=t;)o.key>=e&&(n(o.value,0)||r(o.key,o.value,this)),(o=a.extractMinimum())&&s.push(o);for(var u=0;u{var{typed:t,abs:n,add:r,multiply:a,map:i,sqrt:s,subtract:o,inv:u,size:l,max:c,identity:p}=e,d=1e-6;function h(e){var t,i=0,s=e,h=p(l(e));do{var f=s;if(s=a(.5,r(f,u(h))),h=a(.5,r(h,u(f))),(t=c(n(o(s,f))))>d&&++i>1e3)throw new Error("computing square root of matrix: iterative method could not converge")}while(t>d);return s}return t(p2,{"Array | Matrix":function(e){var t=UP(e)?e.size():BW(e);switch(t.length){case 1:if(1===t[0])return i(e,s);throw new RangeError("Matrix must be square (size: "+IW(t)+")");case 2:if(t[0]===t[1])return h(e);throw new RangeError("Matrix must be square (size: "+IW(t)+")");default:throw new RangeError("Matrix must be at most two dimensional (size: "+IW(t)+")")}}})}));function h2(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f2(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function m2(e){for(var t=1;t{var t,n,r,{on:a,config:i,addScalar:s,subtract:o,multiplyScalar:u,divideScalar:l,pow:c,abs:p,fix:d,round:h,equal:f,isNumeric:m,format:g,number:y,Complex:b,BigNumber:v,Fraction:x}=e,_=y;function w(e,t){if(!(this instanceof w))throw new Error("Constructor must be called with the new operator");if(null!=e&&!m(e)&&!BP(e))throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");if(void 0!==t&&("string"!=typeof t||""===t))throw new TypeError("Second parameter in Unit constructor must be a string");if(void 0!==t){var n=w.parse(t);this.units=n.units,this.dimensions=n.dimensions}else{this.units=[],this.dimensions=[];for(var r=0;r="0"&&e<="9"}function M(){n++,r=t.charAt(n)}function S(e){n=e,r=t.charAt(n)}function k(){var e="",t=n;if("+"===r?M():"-"===r&&(e+=r,M()),!function(e){return e>="0"&&e<="9"||"."===e}(r))return S(t),null;if("."===r){if(e+=r,M(),!N(r))return S(t),null}else{for(;N(r);)e+=r,M();"."===r&&(e+=r,M())}for(;N(r);)e+=r,M();if("E"===r||"e"===r){var a="",i=n;if(a+=r,M(),"+"!==r&&"-"!==r||(a+=r,M()),!N(r))return S(i),e;for(e+=a;N(r);)e+=r,M()}return e}function T(){for(var e="";N(r)||w.isValidAlpha(r);)e+=r,M();var t=e.charAt(0);return w.isValidAlpha(t)?e:null}function C(e){return r===e?(M(),e):null}Object.defineProperty(w,"name",{value:"Unit"}),w.prototype.constructor=w,w.prototype.type="Unit",w.prototype.isUnit=!0,w.parse=function(e,a){if(a=a||{},n=-1,r="","string"!=typeof(t=e))throw new TypeError("Invalid argument in Unit.parse, string expected");var s=new w;s.units=[];var o=1,u=!1;M(),D();var l=k(),c=null;if(l){if("BigNumber"===i.number)c=new v(l);else if("Fraction"===i.number)try{c=new x(l)}catch(e){c=parseFloat(l)}else c=parseFloat(l);D(),C("*")?(o=1,u=!0):C("/")&&(o=-1,u=!0)}for(var p=[],d=1;;){for(D();"("===r;)p.push(o),d*=o,o=1,M(),D();var h;if(!r)break;var f=r;if(null===(h=T()))throw new SyntaxError('Unexpected "'+f+'" in "'+t+'" at index '+n.toString());var m=E(h);if(null===m)throw new SyntaxError('Unit "'+h+'" not found.');var g=o*d;if(D(),C("^")){D();var y=k();if(null===y)throw new SyntaxError('In "'+e+'", "^" must be followed by a floating-point number');g*=y}s.units.push({unit:m.unit,prefix:m.prefix,power:g});for(var b=0;b1||Math.abs(this.units[0].power-1)>1e-15)},w.prototype._normalize=function(e){if(null==e||0===this.units.length)return e;for(var t=e,n=w._getNumberConverter(wH(e)),r=0;r{if(AH(R,e)){var t=R[e];return{unit:t,prefix:t.prefixes[""]}}for(var n in R)if(AH(R,n)&&AW(e,n)){var r=R[n],a=e.length-n.length,i=e.substring(0,a),s=AH(r.prefixes,i)?r.prefixes[i]:void 0;if(void 0!==s)return{unit:r,prefix:s}}return null}),{hasher:e=>e[0],limit:100});function A(e){return e.equalBase(F.NONE)&&null!==e.value&&!i.predictable?e.value:e}w.isValuelessUnit=function(e){return null!==E(e)},w.prototype.hasBase=function(e){if("string"==typeof e&&(e=F[e]),!e)return!1;for(var t=0;t1e-12)return!1;return!0},w.prototype.equalBase=function(e){for(var t=0;t1e-12)return!1;return!0},w.prototype.equals=function(e){return this.equalBase(e)&&f(this.value,e.value)},w.prototype.multiply=function(e){for(var t=this.clone(),n=PP(e)?e:new w(e),r=0;r1e-12&&(AH(P,o)?r.push({unit:P[o].unit,prefix:P[o].prefix,power:n.dimensions[s]||0}):i=!0)}r.length1e-12){if(!AH(z.si,r))throw new Error("Cannot express custom unit "+r+" in SI units");t.push({unit:z.si[r].unit,prefix:z.si[r].prefix,power:e.dimensions[n]||0})}}return e.units=t,e.fixPrefix=!0,e.skipAutomaticSimplification=!0,e},w.prototype.formatUnits=function(){for(var e="",t="",n=0,r=0,a=0;a0?(n++,e+=" "+this.units[a].prefix.name+this.units[a].unit.name,Math.abs(this.units[a].power-1)>1e-15&&(e+="^"+this.units[a].power)):this.units[a].power<0&&r++;if(r>0)for(var i=0;i0?(t+=" "+this.units[i].prefix.name+this.units[i].unit.name,Math.abs(this.units[i].power+1)>1e-15&&(t+="^"+-this.units[i].power)):(t+=" "+this.units[i].prefix.name+this.units[i].unit.name,t+="^"+this.units[i].power));e=e.substr(1),t=t.substr(1),n>1&&r>0&&(e="("+e+")"),r>1&&n>0&&(t="("+t+")");var s=e;return n>0&&r>0&&(s+=" / "),s+t},w.prototype.format=function(e){var t=this.skipAutomaticSimplification||null===this.value?this.clone():this.simplify(),n=!1;for(var r in void 0!==t.value&&null!==t.value&&BP(t.value)&&(n=Math.abs(t.value.re)<1e-14),t.units)AH(t.units,r)&&t.units[r].unit&&("VA"===t.units[r].unit.name&&n?t.units[r].unit=R.VAR:"VAR"!==t.units[r].unit.name||n||(t.units[r].unit=R.VA));1!==t.units.length||t.fixPrefix||Math.abs(t.units[0].power-Math.round(t.units[0].power))<1e-14&&(t.units[0].prefix=t._bestPrefix());var a=t._denormalize(t.value),i=null!==t.value?g(a,e||{}):"",s=t.formatUnits();return t.value&&BP(t.value)&&(i="("+i+")"),s.length>0&&i.length>0&&(i+=" "),i+s},w.prototype._bestPrefix=function(){if(1!==this.units.length)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");if(Math.abs(this.units[0].power-Math.round(this.units[0].power))>=1e-14)throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");var e=null!==this.value?p(this.value):0,t=p(this.units[0].unit.value),n=this.units[0].prefix;if(0===e)return n;var r=this.units[0].power,a=Math.log(e/Math.pow(n.value*t,r))/Math.LN10-1.2;if(a>-2.200001&&a<1.800001)return n;a=Math.abs(a);var i=this.units[0].unit.prefixes;for(var s in i)if(AH(i,s)){var o=i[s];if(o.scientific){var u=Math.abs(Math.log(e/Math.pow(o.value*t,r))/Math.LN10-1.2);(u0))},R={meter:{name:"meter",base:F.LENGTH,prefixes:I.LONG,value:1,offset:0},inch:{name:"inch",base:F.LENGTH,prefixes:I.NONE,value:.0254,offset:0},foot:{name:"foot",base:F.LENGTH,prefixes:I.NONE,value:.3048,offset:0},yard:{name:"yard",base:F.LENGTH,prefixes:I.NONE,value:.9144,offset:0},mile:{name:"mile",base:F.LENGTH,prefixes:I.NONE,value:1609.344,offset:0},link:{name:"link",base:F.LENGTH,prefixes:I.NONE,value:.201168,offset:0},rod:{name:"rod",base:F.LENGTH,prefixes:I.NONE,value:5.0292,offset:0},chain:{name:"chain",base:F.LENGTH,prefixes:I.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:F.LENGTH,prefixes:I.NONE,value:1e-10,offset:0},m:{name:"m",base:F.LENGTH,prefixes:I.SHORT,value:1,offset:0},in:{name:"in",base:F.LENGTH,prefixes:I.NONE,value:.0254,offset:0},ft:{name:"ft",base:F.LENGTH,prefixes:I.NONE,value:.3048,offset:0},yd:{name:"yd",base:F.LENGTH,prefixes:I.NONE,value:.9144,offset:0},mi:{name:"mi",base:F.LENGTH,prefixes:I.NONE,value:1609.344,offset:0},li:{name:"li",base:F.LENGTH,prefixes:I.NONE,value:.201168,offset:0},rd:{name:"rd",base:F.LENGTH,prefixes:I.NONE,value:5.02921,offset:0},ch:{name:"ch",base:F.LENGTH,prefixes:I.NONE,value:20.1168,offset:0},mil:{name:"mil",base:F.LENGTH,prefixes:I.NONE,value:254e-7,offset:0},m2:{name:"m2",base:F.SURFACE,prefixes:I.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:F.SURFACE,prefixes:I.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:F.SURFACE,prefixes:I.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:F.SURFACE,prefixes:I.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:F.SURFACE,prefixes:I.NONE,value:2589988.110336,offset:0},sqrd:{name:"sqrd",base:F.SURFACE,prefixes:I.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:F.SURFACE,prefixes:I.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:F.SURFACE,prefixes:I.NONE,value:6.4516e-10,offset:0},acre:{name:"acre",base:F.SURFACE,prefixes:I.NONE,value:4046.86,offset:0},hectare:{name:"hectare",base:F.SURFACE,prefixes:I.NONE,value:1e4,offset:0},m3:{name:"m3",base:F.VOLUME,prefixes:I.CUBIC,value:1,offset:0},L:{name:"L",base:F.VOLUME,prefixes:I.SHORT,value:.001,offset:0},l:{name:"l",base:F.VOLUME,prefixes:I.SHORT,value:.001,offset:0},litre:{name:"litre",base:F.VOLUME,prefixes:I.LONG,value:.001,offset:0},cuin:{name:"cuin",base:F.VOLUME,prefixes:I.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:F.VOLUME,prefixes:I.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:F.VOLUME,prefixes:I.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:F.VOLUME,prefixes:I.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:F.VOLUME,prefixes:I.NONE,value:15e-6,offset:0},drop:{name:"drop",base:F.VOLUME,prefixes:I.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:F.VOLUME,prefixes:I.NONE,value:5e-8,offset:0},minim:{name:"minim",base:F.VOLUME,prefixes:I.NONE,value:6.161152e-8,offset:0},fluiddram:{name:"fluiddram",base:F.VOLUME,prefixes:I.NONE,value:36966911e-13,offset:0},fluidounce:{name:"fluidounce",base:F.VOLUME,prefixes:I.NONE,value:2957353e-11,offset:0},gill:{name:"gill",base:F.VOLUME,prefixes:I.NONE,value:.0001182941,offset:0},cc:{name:"cc",base:F.VOLUME,prefixes:I.NONE,value:1e-6,offset:0},cup:{name:"cup",base:F.VOLUME,prefixes:I.NONE,value:.0002365882,offset:0},pint:{name:"pint",base:F.VOLUME,prefixes:I.NONE,value:.0004731765,offset:0},quart:{name:"quart",base:F.VOLUME,prefixes:I.NONE,value:.0009463529,offset:0},gallon:{name:"gallon",base:F.VOLUME,prefixes:I.NONE,value:.003785412,offset:0},beerbarrel:{name:"beerbarrel",base:F.VOLUME,prefixes:I.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:F.VOLUME,prefixes:I.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:F.VOLUME,prefixes:I.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:F.VOLUME,prefixes:I.NONE,value:36966911e-13,offset:0},floz:{name:"floz",base:F.VOLUME,prefixes:I.NONE,value:2957353e-11,offset:0},gi:{name:"gi",base:F.VOLUME,prefixes:I.NONE,value:.0001182941,offset:0},cp:{name:"cp",base:F.VOLUME,prefixes:I.NONE,value:.0002365882,offset:0},pt:{name:"pt",base:F.VOLUME,prefixes:I.NONE,value:.0004731765,offset:0},qt:{name:"qt",base:F.VOLUME,prefixes:I.NONE,value:.0009463529,offset:0},gal:{name:"gal",base:F.VOLUME,prefixes:I.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:F.VOLUME,prefixes:I.NONE,value:.1173478,offset:0},obl:{name:"obl",base:F.VOLUME,prefixes:I.NONE,value:.1589873,offset:0},g:{name:"g",base:F.MASS,prefixes:I.SHORT,value:.001,offset:0},gram:{name:"gram",base:F.MASS,prefixes:I.LONG,value:.001,offset:0},ton:{name:"ton",base:F.MASS,prefixes:I.SHORT,value:907.18474,offset:0},t:{name:"t",base:F.MASS,prefixes:I.SHORT,value:1e3,offset:0},tonne:{name:"tonne",base:F.MASS,prefixes:I.LONG,value:1e3,offset:0},grain:{name:"grain",base:F.MASS,prefixes:I.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:F.MASS,prefixes:I.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:F.MASS,prefixes:I.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:F.MASS,prefixes:I.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:F.MASS,prefixes:I.NONE,value:45.359237,offset:0},stick:{name:"stick",base:F.MASS,prefixes:I.NONE,value:.115,offset:0},stone:{name:"stone",base:F.MASS,prefixes:I.NONE,value:6.35029318,offset:0},gr:{name:"gr",base:F.MASS,prefixes:I.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:F.MASS,prefixes:I.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:F.MASS,prefixes:I.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:F.MASS,prefixes:I.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:F.MASS,prefixes:I.NONE,value:45.359237,offset:0},s:{name:"s",base:F.TIME,prefixes:I.SHORT,value:1,offset:0},min:{name:"min",base:F.TIME,prefixes:I.NONE,value:60,offset:0},h:{name:"h",base:F.TIME,prefixes:I.NONE,value:3600,offset:0},second:{name:"second",base:F.TIME,prefixes:I.LONG,value:1,offset:0},sec:{name:"sec",base:F.TIME,prefixes:I.LONG,value:1,offset:0},minute:{name:"minute",base:F.TIME,prefixes:I.NONE,value:60,offset:0},hour:{name:"hour",base:F.TIME,prefixes:I.NONE,value:3600,offset:0},day:{name:"day",base:F.TIME,prefixes:I.NONE,value:86400,offset:0},week:{name:"week",base:F.TIME,prefixes:I.NONE,value:604800,offset:0},month:{name:"month",base:F.TIME,prefixes:I.NONE,value:2629800,offset:0},year:{name:"year",base:F.TIME,prefixes:I.NONE,value:31557600,offset:0},decade:{name:"decade",base:F.TIME,prefixes:I.NONE,value:315576e3,offset:0},century:{name:"century",base:F.TIME,prefixes:I.NONE,value:315576e4,offset:0},millennium:{name:"millennium",base:F.TIME,prefixes:I.NONE,value:315576e5,offset:0},hertz:{name:"Hertz",base:F.FREQUENCY,prefixes:I.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:"Hz",base:F.FREQUENCY,prefixes:I.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:"rad",base:F.ANGLE,prefixes:I.SHORT,value:1,offset:0},radian:{name:"radian",base:F.ANGLE,prefixes:I.LONG,value:1,offset:0},deg:{name:"deg",base:F.ANGLE,prefixes:I.SHORT,value:null,offset:0},degree:{name:"degree",base:F.ANGLE,prefixes:I.LONG,value:null,offset:0},grad:{name:"grad",base:F.ANGLE,prefixes:I.SHORT,value:null,offset:0},gradian:{name:"gradian",base:F.ANGLE,prefixes:I.LONG,value:null,offset:0},cycle:{name:"cycle",base:F.ANGLE,prefixes:I.NONE,value:null,offset:0},arcsec:{name:"arcsec",base:F.ANGLE,prefixes:I.NONE,value:null,offset:0},arcmin:{name:"arcmin",base:F.ANGLE,prefixes:I.NONE,value:null,offset:0},A:{name:"A",base:F.CURRENT,prefixes:I.SHORT,value:1,offset:0},ampere:{name:"ampere",base:F.CURRENT,prefixes:I.LONG,value:1,offset:0},K:{name:"K",base:F.TEMPERATURE,prefixes:I.NONE,value:1,offset:0},degC:{name:"degC",base:F.TEMPERATURE,prefixes:I.NONE,value:1,offset:273.15},degF:{name:"degF",base:F.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:459.67},degR:{name:"degR",base:F.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:F.TEMPERATURE,prefixes:I.NONE,value:1,offset:0},celsius:{name:"celsius",base:F.TEMPERATURE,prefixes:I.NONE,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:F.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:F.TEMPERATURE,prefixes:I.NONE,value:1/1.8,offset:0},mol:{name:"mol",base:F.AMOUNT_OF_SUBSTANCE,prefixes:I.SHORT,value:1,offset:0},mole:{name:"mole",base:F.AMOUNT_OF_SUBSTANCE,prefixes:I.LONG,value:1,offset:0},cd:{name:"cd",base:F.LUMINOUS_INTENSITY,prefixes:I.SHORT,value:1,offset:0},candela:{name:"candela",base:F.LUMINOUS_INTENSITY,prefixes:I.LONG,value:1,offset:0},N:{name:"N",base:F.FORCE,prefixes:I.SHORT,value:1,offset:0},newton:{name:"newton",base:F.FORCE,prefixes:I.LONG,value:1,offset:0},dyn:{name:"dyn",base:F.FORCE,prefixes:I.SHORT,value:1e-5,offset:0},dyne:{name:"dyne",base:F.FORCE,prefixes:I.LONG,value:1e-5,offset:0},lbf:{name:"lbf",base:F.FORCE,prefixes:I.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:F.FORCE,prefixes:I.NONE,value:4.4482216152605,offset:0},kip:{name:"kip",base:F.FORCE,prefixes:I.LONG,value:4448.2216,offset:0},kilogramforce:{name:"kilogramforce",base:F.FORCE,prefixes:I.NONE,value:9.80665,offset:0},J:{name:"J",base:F.ENERGY,prefixes:I.SHORT,value:1,offset:0},joule:{name:"joule",base:F.ENERGY,prefixes:I.SHORT,value:1,offset:0},erg:{name:"erg",base:F.ENERGY,prefixes:I.NONE,value:1e-7,offset:0},Wh:{name:"Wh",base:F.ENERGY,prefixes:I.SHORT,value:3600,offset:0},BTU:{name:"BTU",base:F.ENERGY,prefixes:I.BTU,value:1055.05585262,offset:0},eV:{name:"eV",base:F.ENERGY,prefixes:I.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:"electronvolt",base:F.ENERGY,prefixes:I.LONG,value:1602176565e-28,offset:0},W:{name:"W",base:F.POWER,prefixes:I.SHORT,value:1,offset:0},watt:{name:"watt",base:F.POWER,prefixes:I.LONG,value:1,offset:0},hp:{name:"hp",base:F.POWER,prefixes:I.NONE,value:745.6998715386,offset:0},VAR:{name:"VAR",base:F.POWER,prefixes:I.SHORT,value:b.I,offset:0},VA:{name:"VA",base:F.POWER,prefixes:I.SHORT,value:1,offset:0},Pa:{name:"Pa",base:F.PRESSURE,prefixes:I.SHORT,value:1,offset:0},psi:{name:"psi",base:F.PRESSURE,prefixes:I.NONE,value:6894.75729276459,offset:0},atm:{name:"atm",base:F.PRESSURE,prefixes:I.NONE,value:101325,offset:0},bar:{name:"bar",base:F.PRESSURE,prefixes:I.SHORTLONG,value:1e5,offset:0},torr:{name:"torr",base:F.PRESSURE,prefixes:I.NONE,value:133.322,offset:0},mmHg:{name:"mmHg",base:F.PRESSURE,prefixes:I.NONE,value:133.322,offset:0},mmH2O:{name:"mmH2O",base:F.PRESSURE,prefixes:I.NONE,value:9.80665,offset:0},cmH2O:{name:"cmH2O",base:F.PRESSURE,prefixes:I.NONE,value:98.0665,offset:0},coulomb:{name:"coulomb",base:F.ELECTRIC_CHARGE,prefixes:I.LONG,value:1,offset:0},C:{name:"C",base:F.ELECTRIC_CHARGE,prefixes:I.SHORT,value:1,offset:0},farad:{name:"farad",base:F.ELECTRIC_CAPACITANCE,prefixes:I.LONG,value:1,offset:0},F:{name:"F",base:F.ELECTRIC_CAPACITANCE,prefixes:I.SHORT,value:1,offset:0},volt:{name:"volt",base:F.ELECTRIC_POTENTIAL,prefixes:I.LONG,value:1,offset:0},V:{name:"V",base:F.ELECTRIC_POTENTIAL,prefixes:I.SHORT,value:1,offset:0},ohm:{name:"ohm",base:F.ELECTRIC_RESISTANCE,prefixes:I.SHORTLONG,value:1,offset:0},henry:{name:"henry",base:F.ELECTRIC_INDUCTANCE,prefixes:I.LONG,value:1,offset:0},H:{name:"H",base:F.ELECTRIC_INDUCTANCE,prefixes:I.SHORT,value:1,offset:0},siemens:{name:"siemens",base:F.ELECTRIC_CONDUCTANCE,prefixes:I.LONG,value:1,offset:0},S:{name:"S",base:F.ELECTRIC_CONDUCTANCE,prefixes:I.SHORT,value:1,offset:0},weber:{name:"weber",base:F.MAGNETIC_FLUX,prefixes:I.LONG,value:1,offset:0},Wb:{name:"Wb",base:F.MAGNETIC_FLUX,prefixes:I.SHORT,value:1,offset:0},tesla:{name:"tesla",base:F.MAGNETIC_FLUX_DENSITY,prefixes:I.LONG,value:1,offset:0},T:{name:"T",base:F.MAGNETIC_FLUX_DENSITY,prefixes:I.SHORT,value:1,offset:0},b:{name:"b",base:F.BIT,prefixes:I.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:F.BIT,prefixes:I.BINARY_LONG,value:1,offset:0},B:{name:"B",base:F.BIT,prefixes:I.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:F.BIT,prefixes:I.BINARY_LONG,value:8,offset:0}},Y={meters:"meter",inches:"inch",feet:"foot",yards:"yard",miles:"mile",links:"link",rods:"rod",chains:"chain",angstroms:"angstrom",lt:"l",litres:"litre",liter:"litre",liters:"litre",teaspoons:"teaspoon",tablespoons:"tablespoon",minims:"minim",fluiddrams:"fluiddram",fluidounces:"fluidounce",gills:"gill",cups:"cup",pints:"pint",quarts:"quart",gallons:"gallon",beerbarrels:"beerbarrel",oilbarrels:"oilbarrel",hogsheads:"hogshead",gtts:"gtt",grams:"gram",tons:"ton",tonnes:"tonne",grains:"grain",drams:"dram",ounces:"ounce",poundmasses:"poundmass",hundredweights:"hundredweight",sticks:"stick",lb:"lbm",lbs:"lbm",kips:"kip",kgf:"kilogramforce",acres:"acre",hectares:"hectare",sqfeet:"sqft",sqyard:"sqyd",sqmile:"sqmi",sqmiles:"sqmi",mmhg:"mmHg",mmh2o:"mmH2O",cmh2o:"cmH2O",seconds:"second",secs:"second",minutes:"minute",mins:"minute",hours:"hour",hr:"hour",hrs:"hour",days:"day",weeks:"week",months:"month",years:"year",decades:"decade",centuries:"century",millennia:"millennium",hertz:"hertz",radians:"radian",degrees:"degree",gradians:"gradian",cycles:"cycle",arcsecond:"arcsec",arcseconds:"arcsec",arcminute:"arcmin",arcminutes:"arcmin",BTUs:"BTU",watts:"watt",joules:"joule",amperes:"ampere",coulombs:"coulomb",volts:"volt",ohms:"ohm",farads:"farad",webers:"weber",teslas:"tesla",electronvolts:"electronvolt",moles:"mole",bit:"bits",byte:"bytes"};function B(e){if("BigNumber"===e.number){var t=eq(v);R.rad.value=new v(1),R.deg.value=t.div(180),R.grad.value=t.div(200),R.cycle.value=t.times(2),R.arcsec.value=t.div(648e3),R.arcmin.value=t.div(10800)}else R.rad.value=1,R.deg.value=Math.PI/180,R.grad.value=Math.PI/200,R.cycle.value=2*Math.PI,R.arcsec.value=Math.PI/648e3,R.arcmin.value=Math.PI/10800;R.radian.value=R.rad.value,R.degree.value=R.deg.value,R.gradian.value=R.grad.value}B(i),a&&a("config",(function(e,t){e.number!==t.number&&B(e)}));var z={si:{NONE:{unit:O,prefix:I.NONE[""]},LENGTH:{unit:R.m,prefix:I.SHORT[""]},MASS:{unit:R.g,prefix:I.SHORT.k},TIME:{unit:R.s,prefix:I.SHORT[""]},CURRENT:{unit:R.A,prefix:I.SHORT[""]},TEMPERATURE:{unit:R.K,prefix:I.SHORT[""]},LUMINOUS_INTENSITY:{unit:R.cd,prefix:I.SHORT[""]},AMOUNT_OF_SUBSTANCE:{unit:R.mol,prefix:I.SHORT[""]},ANGLE:{unit:R.rad,prefix:I.SHORT[""]},BIT:{unit:R.bits,prefix:I.SHORT[""]},FORCE:{unit:R.N,prefix:I.SHORT[""]},ENERGY:{unit:R.J,prefix:I.SHORT[""]},POWER:{unit:R.W,prefix:I.SHORT[""]},PRESSURE:{unit:R.Pa,prefix:I.SHORT[""]},ELECTRIC_CHARGE:{unit:R.C,prefix:I.SHORT[""]},ELECTRIC_CAPACITANCE:{unit:R.F,prefix:I.SHORT[""]},ELECTRIC_POTENTIAL:{unit:R.V,prefix:I.SHORT[""]},ELECTRIC_RESISTANCE:{unit:R.ohm,prefix:I.SHORT[""]},ELECTRIC_INDUCTANCE:{unit:R.H,prefix:I.SHORT[""]},ELECTRIC_CONDUCTANCE:{unit:R.S,prefix:I.SHORT[""]},MAGNETIC_FLUX:{unit:R.Wb,prefix:I.SHORT[""]},MAGNETIC_FLUX_DENSITY:{unit:R.T,prefix:I.SHORT[""]},FREQUENCY:{unit:R.Hz,prefix:I.SHORT[""]}}};z.cgs=JSON.parse(JSON.stringify(z.si)),z.cgs.LENGTH={unit:R.m,prefix:I.SHORT.c},z.cgs.MASS={unit:R.g,prefix:I.SHORT[""]},z.cgs.FORCE={unit:R.dyn,prefix:I.SHORT[""]},z.cgs.ENERGY={unit:R.erg,prefix:I.NONE[""]},z.us=JSON.parse(JSON.stringify(z.si)),z.us.LENGTH={unit:R.ft,prefix:I.NONE[""]},z.us.MASS={unit:R.lbm,prefix:I.NONE[""]},z.us.TEMPERATURE={unit:R.degF,prefix:I.NONE[""]},z.us.FORCE={unit:R.lbf,prefix:I.NONE[""]},z.us.ENERGY={unit:R.BTU,prefix:I.BTU[""]},z.us.POWER={unit:R.hp,prefix:I.NONE[""]},z.us.PRESSURE={unit:R.psi,prefix:I.NONE[""]},z.auto=JSON.parse(JSON.stringify(z.si));var P=z.auto;for(var H in w.setUnitSystem=function(e){if(!AH(z,e))throw new Error("Unit system "+e+" does not exist. Choices are: "+Object.keys(z).join(", "));P=z[e]},w.getUnitSystem=function(){for(var e in z)if(AH(z,e)&&z[e]===P)return e},w.typeConverters={BigNumber:function(e){return new v(e+"")},Fraction:function(e){return new x(e)},Complex:function(e){return e},number:function(e){return e}},w.prototype._numberConverter=function(){var e=w.typeConverters[this.valueType()];if(e)return e;throw new TypeError('Unsupported Unit value type "'+this.valueType()+'"')},w._getNumberConverter=function(e){if(!w.typeConverters[e])throw new TypeError('Unsupported type "'+e+'"');return w.typeConverters[e]},R)if(AH(R,H)){var j=R[H];j.dimensions=j.base.dimensions}for(var U in Y)if(AH(Y,U)){var q=R[Y[U]],W={};for(var V in q)AH(q,V)&&(W[V]=q[V]);W.name=U,R[U]=W}return w.isValidAlpha=function(e){return/^[a-zA-Z]$/.test(e)},w.createUnit=function(e,t){if("object"!=typeof e)throw new TypeError("createUnit expects first parameter to be of type 'Object'");if(t&&t.override)for(var n in e)if(AH(e,n)&&w.deleteUnit(n),e[n].aliases)for(var r=0;r0&&!w.isValidAlpha(r)&&!N(r))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+e+'"')}}(e);var a,i,s,o=null,u=[],l=0;if(t&&"Unit"===t.type)o=t.clone();else if("string"==typeof t)""!==t&&(a=t);else{if("object"!=typeof t)throw new TypeError('Cannot create unit "'+e+'" from "'+t.toString()+'": expecting "string" or "Unit" or "Object"');a=t.definition,i=t.prefixes,l=t.offset,s=t.baseName,t.aliases&&(u=t.aliases.valueOf())}if(u)for(var c=0;c1e-12){f=!1;break}if(f){d=!0,p.base=F[h];break}}if(!d){s=s||e+"_STUFF";var g={dimensions:o.dimensions.slice(0)};g.key=s,F[s]=g,P[s]={unit:p,prefix:I.NONE[""]},p.base=F[s]}}else{if(s=s||e+"_STUFF",L.indexOf(s)>=0)throw new Error('Cannot create new base unit "'+e+'": a base unit with that name already exists (and cannot be overridden)');for(var y in L.push(s),F)AH(F,y)&&(F[y].dimensions[L.length-1]=0);for(var b={dimensions:[]},v=0;v{var{typed:t,Unit:n}=e;return t(y2,{"Object, Object":function(e,t){return n.createUnit(e,t)},Object:function(e){return n.createUnit(e,{})},"string, Unit | string | Object, Object":function(e,t,r){var a={};return a[e]=t,n.createUnit(a,r)},"string, Unit | string | Object":function(e,t){var r={};return r[e]=t,n.createUnit(r,{})},string:function(e){var t={};return t[e]={},n.createUnit(t,{})}})})),v2="dotPow",x2=_U(v2,["typed","equalScalar","matrix","pow","DenseMatrix"],(e=>{var{typed:t,equalScalar:n,matrix:r,pow:a,DenseMatrix:i}=e,s=jX({typed:t}),o=hZ({typed:t,DenseMatrix:i}),u=qX({typed:t,equalScalar:n}),l=WX({typed:t,DenseMatrix:i}),c=KX({typed:t,matrix:r}),p={};for(var d in a.signatures)Object.prototype.hasOwnProperty.call(a.signatures,d)&&(d.includes("Matrix")||d.includes("Array")||(p[d]=a.signatures[d]));var h=t(p);return t(v2,c({elop:h,SS:o,DS:s,Ss:u,sS:l}))})),_2="expm",w2=_U(_2,["typed","abs","add","identity","inv","multiply"],(e=>{var{typed:t,abs:n,add:r,identity:a,inv:i,multiply:s}=e;return t(_2,{Matrix:function(e){var t=e.size();if(2!==t.length||t[0]!==t[1])throw new RangeError("Matrix must be square (size: "+IW(t)+")");for(var u=t[0],l=function(e){for(var t=e.size()[0],r=0,a=0;a1&&(y=s(y,h),b=-b),f=r(f,s(g=g*(p-v+1)/((2*p-v+1)*v),y)),m=r(m,s(g*b,y));for(var x=s(i(m),f),_=0;_{var{typed:t,config:n,multiplyScalar:r,pow:a,BigNumber:i,Complex:s}=e;return t(D2,{number:sJ,Complex:function e(t){if(0===t.im)return sJ(t.re);if(t.re<.5){var n=new s(1-t.re,-t.im),r=new s(Math.PI*t.re,Math.PI*t.im);return new s(Math.PI).div(r.sin()).div(e(n))}t=new s(t.re-1,t.im);for(var a=new s(uJ[0],0),i=1;i2;)u+=a-=2,s=s.times(u);return new i(s.toPrecision(i.precision))}})),M2="setIntersect",S2=_U(M2,["typed","size","subset","compareNatural","Index","DenseMatrix"],(e=>{var{typed:t,size:n,subset:r,compareNatural:a,Index:i,DenseMatrix:s}=e;return t(M2,{"Array | Matrix, Array | Matrix":function(e,t){var o;if(0===r(n(e),new i(0))||0===r(n(t),new i(0)))o=[];else{var u=aV(ZW(Array.isArray(e)?e:e.toArray()).sort(a)),l=aV(ZW(Array.isArray(t)?t:t.toArray()).sort(a));o=[];for(var c=0;c{var{typed:t,matrix:n,multiply:r,equalScalar:a,divideScalar:i,inv:s}=e,o=qX({typed:t,equalScalar:a}),u=GX({typed:t});return t("divide",MH({"Array | Matrix, Array | Matrix":function(e,t){return r(e,s(t))},"DenseMatrix, any":function(e,t){return u(e,t,i,!1)},"SparseMatrix, any":function(e,t){return o(e,t,i,!1)},"Array, any":function(e,t){return u(n(e),t,i,!1).valueOf()},"any, Array | Matrix":function(e,t){return r(e,s(t))}},i.signatures))})),T2="factorial",C2=_U(T2,["typed","gamma"],(e=>{var{typed:t,gamma:n}=e;return t(T2,{number:function(e){if(e<0)throw new Error("Value must be non-negative");return n(e+1)},BigNumber:function(e){if(e.isNegative())throw new Error("Value must be non-negative");return n(e.plus(1))},"Array | Matrix":t.referToSelf((e=>t=>AV(t,e)))})})),E2=_U("lup",["typed","matrix","abs","addScalar","divideScalar","multiplyScalar","subtract","larger","equalScalar","unaryMinus","DenseMatrix","SparseMatrix","Spa"],(e=>{var{typed:t,matrix:n,abs:r,addScalar:a,divideScalar:i,multiplyScalar:s,subtract:o,larger:u,equalScalar:l,unaryMinus:c,DenseMatrix:p,SparseMatrix:d,Spa:h}=e;return t("lup",{DenseMatrix:function(e){return f(e)},SparseMatrix:function(e){return function(e){var t,n,a,o=e._size[0],p=e._size[1],f=Math.min(o,p),m=e._values,g=e._index,y=e._ptr,b=[],v=[],x=[],_=[o,f],w=[],D=[],N=[],M=[f,p],S=[],k=[];for(t=0;t0&&e.forEach(0,n-1,(function(t,n){d._forEachRow(t,b,v,x,(function(r,a){r>t&&e.accumulate(r,c(s(a,n)))}))}));var T,C,E,A,I=n,L=e.get(n),F=r(L);e.forEach(n+1,o-1,(function(e,t){var n=r(t);u(n,F)&&(I=e,F=n,L=t)})),n!==I&&(d._swapRows(n,I,_[1],b,v,x),d._swapRows(n,I,M[1],w,D,N),e.swap(n,I),C=I,E=k[T=n],A=k[C],S[E]=C,S[A]=T,k[T]=A,k[C]=E),e.forEach(0,o-1,(function(e,t){e<=n?(w.push(t),D.push(e)):(t=i(t,L),l(t,0)||(b.push(t),v.push(e)))}))};for(n=0;n0)for(t=0;t{var{typed:t,add:n,divide:r,multiply:a,factorial:i,isInteger:s,isPositive:o}=e;return t(A2,{"Array | Matrix":function(e){var t=0,u=1;return EV(e,(function(e){if(!s(e)||!o(e))throw new TypeError("Positive integer value expected in function multinomial");t=n(t,e),u=a(u,i(e))})),r(i(t),u)}})})),L2="permutations",F2=_U(L2,["typed","factorial"],(e=>{var{typed:t,factorial:n}=e;return t(L2,{"number | BigNumber":n,"number, number":function(e,t){if(!SU(e)||e<0)throw new TypeError("Positive integer value expected in function permutations");if(!SU(t)||t<0)throw new TypeError("Positive integer value expected in function permutations");if(t>e)throw new TypeError("second argument k must be less than or equal to first argument n");return oK(e-t+1,e)},"BigNumber, BigNumber":function(e,t){var n,r;if(!$2(e)||!$2(t))throw new TypeError("Positive integer value expected in function permutations");if(t.gt(e))throw new TypeError("second argument k must be less than or equal to first argument n");for(n=e.mul(0).add(1),r=e.minus(t).plus(1);r.lte(e);r=r.plus(1))n=n.times(r);return n}})}));function $2(e){return e.isInteger()&&e.gte(0)}var O2="stirlingS2",R2=_U(O2,["typed","addScalar","subtract","multiplyScalar","divideScalar","pow","factorial","combinations","isNegative","isInteger","number","?bignumber","larger"],(e=>{var{typed:t,addScalar:n,subtract:r,multiplyScalar:a,divideScalar:i,pow:s,factorial:o,combinations:u,isNegative:l,isInteger:c,number:p,bignumber:d,larger:h}=e,f=[],m=[];return t(O2,{"number | BigNumber, number | BigNumber":function(e,t){if(!c(e)||l(e)||!c(t)||l(t))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(h(t,e))throw new TypeError("k must be less than or equal to n in function stirlingS2");var r=!(RP(e)&&RP(t)),i=r?m:f,s=r?d:p,o=p(e),u=p(t);if(i[o]&&i[o].length>u)return i[o][u];for(var g=0;g<=o;++g)if(i[g]||(i[g]=[s(0===g?1:0)]),0!==g)for(var y=i[g],b=i[g-1],v=y.length;v<=g&&v<=u;++v)y[v]=v===g?1:n(a(s(v),b[v]),b[v-1]);return i[o][u]}})})),Y2="unit",B2=_U(Y2,["typed","Unit"],(e=>{var{typed:t,Unit:n}=e;return t(Y2,{Unit:function(e){return e.clone()},string:function(e){return n.isValuelessUnit(e)?new n(null,e):n.parse(e,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string":function(e,t){return new n(e,t)},"number | BigNumber | Fraction":function(e){return new n(e)},"Array | Matrix":t.referToSelf((e=>t=>AV(t,e)))})})),z2="bellNumbers",P2=_U(z2,["typed","addScalar","isNegative","isInteger","stirlingS2"],(e=>{var{typed:t,addScalar:n,isNegative:r,isInteger:a,stirlingS2:i}=e;return t(z2,{"number | BigNumber":function(e){if(!a(e)||r(e))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var t=0,s=0;s<=e;s++)t=n(t,i(e,s));return t}})}));var H2=_U("eigs",["config","typed","matrix","addScalar","equal","subtract","abs","atan","cos","sin","multiplyScalar","divideScalar","inv","bignumber","multiply","add","larger","column","flatten","number","complex","sqrt","diag","qr","usolve","usolveAll","im","re","smaller","matrixFromColumns","dot"],(e=>{var{config:t,typed:n,matrix:r,addScalar:a,subtract:i,equal:s,abs:o,atan:u,cos:l,sin:c,multiplyScalar:p,divideScalar:d,inv:h,bignumber:f,multiply:m,add:g,larger:y,column:b,flatten:v,number:x,complex:_,sqrt:w,diag:D,qr:N,usolve:M,usolveAll:S,im:k,re:T,smaller:C,matrixFromColumns:E,dot:A}=e,I=function(e){var{config:t,addScalar:n,subtract:r,abs:a,atan:i,cos:s,sin:o,multiplyScalar:u,inv:l,bignumber:c,multiply:p,add:d}=e;function h(e,n){for(var r,a=e.length,i=Math.abs(n/a),s=new Array(a),o=0;o=Math.abs(i);){var l=u[0][0],c=u[0][1];e=b(e,(p=e[l][l],d=e[c][c],h=e[l][c],f=void 0,f=d-p,r=Math.abs(f)<=t.epsilon?Math.PI/4:.5*Math.atan(2*h/(d-p))),l,c),s=m(s,r,l,c),u=v(e)}for(var p,d,h,f,g=w(a,0),y=0;y=a(d);){var b=m[0][0],v=m[0][1];e=y(e,(D=e[b][b],N=e[v][v],M=e[b][v],S=void 0,S=r(N,D),s=a(S)<=t.epsilon?c(-1).acos().div(4):u(.5,i(p(2,M,l(S))))),b,v),h=g(h,s,b,v),m=x(e)}for(var D,N,M,S,k=w(o,0),T=0;T2&&void 0!==arguments[2]?arguments[2]:t.epsilon,a=arguments.length>3?arguments[3]:void 0;if("number"===a)return h(e,r);if("BigNumber"===a)return f(e,r);throw TypeError("Unsupported data type: "+a)}}({config:t,addScalar:a,subtract:i,column:b,flatten:v,equal:s,abs:o,atan:u,cos:l,sin:c,multiplyScalar:p,inv:h,bignumber:f,complex:_,multiply:m,add:g}),L=function(e){var{addScalar:t,subtract:n,flatten:r,multiply:a,multiplyScalar:i,divideScalar:s,sqrt:o,abs:u,bignumber:l,diag:c,inv:p,qr:d,usolve:h,usolveAll:f,equal:m,complex:g,larger:y,smaller:b,matrixFromColumns:v,dot:x}=e;function _(e,t,r,a,i,s,o,c){var p="BigNumber"===c,d="Complex"===c,h=p?l(0):d?g(0):0,f=p?l(1):d?g(1):1;if(b(u(r),o))return[[f,h],[h,f]];if(y(u(n(i,s)),o))return[[n(i,a),n(s,a)],[r,r]];var m=n(e,i),v=n(t,i),x=n(r,i),_=n(a,i);return b(u(v),o)?[[m,f],[x,h]]:[[v,h],[_,f]]}function w(e,t){for(var n=0;n=5)return null;for(o=0;;){var u=h(e,i);if(b(k(S(i,[u])),r))break;if(++o>=10)return null;i=T(u)}return i}function M(e,t,n){var r="BigNumber"===n,a="Complex"===n,i=Array(e).fill(0).map((e=>2*Math.random()-1));return r&&(i=i.map((e=>l(e)))),a&&(i=i.map((e=>g(e)))),T(i=S(i,t),n)}function S(e,t){for(var r of t)e=n(e,a(s(x(r,e),x(r,r)),r));return e}function k(e){return u(o(x(e,e)))}function T(e,t){var n="Complex"===t,r="BigNumber"===t?l(1):n?g(1):1;return a(s(r,k(e)),e)}return function(e,h,x,M,S){void 0===S&&(S=!0);var k=function(e,n,r,a,o){var p,d="BigNumber"===a,h="Complex"===a,f=d?l(0):0,v=d?l(1):h?g(1):1,x=d?l(1):1,_=d?l(10):2,w=i(_,_);o&&(p=Array(n).fill(v));for(var D=!1;!D;){D=!0;for(var N=0;N1&&(F=c(Array(A-1).fill(y)))),A-=1,C.pop();for(var z=0;z2&&(F=c(Array(A-2).fill(y)))),A-=2,C.pop(),C.pop();for(var H=0;H+n(u(e),u(t)))),$>100){var j=Error("The eigenvalues failed to converge. Only found these eigenvalues: "+E.join(", "));throw j.values=E,j.vectors=[],j}var U=h?a(L,function(e,t){for(var n=[],r=0;ra(m,e))),T.push(...c.map((e=>r(e))))},F=0;F{var{typed:t,add:n,divide:r}=e;return t(j2,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,t){try{var a=IV(e,t,n),i=Array.isArray(e)?BW(e):e.size();return r(a,i[t])}catch(e){throw sZ(e,"mean")}},"...":function(e){if(CV(e))throw new TypeError("Scalar values expected in function mean");return a(e)}});function a(e){var t,a=0;if(EV(e,(function(e){try{t=void 0===t?e:n(t,e),a++}catch(t){throw sZ(t,"mean",e)}})),0===a)throw new Error("Cannot calculate the mean of an empty array");return r(t,a)}})),q2="setSymDifference",W2=_U(q2,["typed","size","concat","subset","setDifference","Index"],(e=>{var{typed:t,size:n,concat:r,subset:a,setDifference:i,Index:s}=e;return t(q2,{"Array | Matrix, Array | Matrix":function(e,t){if(0===a(n(e),new s(0)))return ZW(t);if(0===a(n(t),new s(0)))return ZW(e);var o=ZW(e),u=ZW(t);return r(i(o,u),i(u,o))}})})),V2="unbiased",G2="variance",K2=_U(G2,["typed","add","subtract","multiply","divide","apply","isNaN"],(e=>{var{typed:t,add:n,subtract:r,multiply:a,divide:i,apply:s,isNaN:o}=e;return t(G2,{"Array | Matrix":function(e){return u(e,V2)},"Array | Matrix, string":u,"Array | Matrix, number | BigNumber":function(e,t){return l(e,t,V2)},"Array | Matrix, number | BigNumber, string":l,"...":function(e){return u(e,V2)}});function u(e,t){var s,u=0;if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");if(EV(e,(function(e){try{s=void 0===s?e:n(s,e),u++}catch(t){throw sZ(t,"variance",e)}})),0===u)throw new Error("Cannot calculate variance of an empty array");var l=i(s,u);if(s=void 0,EV(e,(function(e){var t=r(e,l);s=void 0===s?a(t,t):n(s,a(t,t))})),o(s))return s;switch(t){case"uncorrected":return i(s,u);case"biased":return i(s,u+1);case"unbiased":var c=YP(s)?s.mul(0):0;return 1===u?c:i(s,u-1);default:throw new Error('Unknown normalization "'+t+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}function l(e,t,n){try{if(0===e.length)throw new SyntaxError("Function variance requires one or more parameters (0 provided)");return s(e,t,(e=>u(e,n)))}catch(e){throw sZ(e,"variance")}}}));function J2(e,t){var n,r=t.length,a=[];if(e)for(n=0;n{var{typed:t,matrix:n,lup:r,slu:a,usolve:i,lsolve:s,DenseMatrix:o}=e,u=EQ({DenseMatrix:o});return t(X2,{"Array, Array | Matrix":function(e,t){e=n(e);var a=r(e);return c(a.L,a.U,a.p,null,t).valueOf()},"DenseMatrix, Array | Matrix":function(e,t){var n=r(e);return c(n.L,n.U,n.p,null,t)},"SparseMatrix, Array | Matrix":function(e,t){var n=r(e);return c(n.L,n.U,n.p,null,t)},"SparseMatrix, Array | Matrix, number, number":function(e,t,n,r){var i=a(e,n,r);return c(i.L,i.U,i.p,i.q,t)},"Object, Array | Matrix":function(e,t){return c(e.L,e.U,e.p,e.q,t)}});function l(e){if(UP(e))return e;if(jP(e))return n(e);throw new TypeError("Invalid Matrix LU decomposition")}function c(e,t,n,r,a){e=l(e),t=l(t),n&&((a=u(e,a,!0))._data=J2(n,a._data));var o=s(e,a),c=i(t,o);return r&&(c._data=J2(r,c._data)),c}})),e3="median",t3=["typed","add","divide","compare","partitionSelect"],n3=_U(e3,t3,(e=>{var{typed:t,add:n,divide:r,compare:a,partitionSelect:i}=e;function s(e){try{var t=(e=ZW(e.valueOf())).length;if(0===t)throw new Error("Cannot calculate median of an empty array");if(t%2==0){for(var n=t/2-1,r=i(e,n+1),s=e[n],l=0;l0&&(s=e[l]);return u(s,r)}var c=i(e,(t-1)/2);return o(c)}catch(e){throw sZ(e,"median")}}var o=t({"number | BigNumber | Complex | Unit":function(e){return e}}),u=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(e,t){return r(n(e,t),2)}});return t(e3,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("median(A, dim) is not yet supported")},"...":function(e){if(CV(e))throw new TypeError("Scalar values expected in function median");return s(e)}})})),r3="setUnion",a3=["typed","size","concat","subset","setIntersect","setSymDifference","Index"],i3=_U(r3,a3,(e=>{var{typed:t,size:n,concat:r,subset:a,setIntersect:i,setSymDifference:s,Index:o}=e;return t(r3,{"Array | Matrix, Array | Matrix":function(e,t){if(0===a(n(e),new o(0)))return ZW(t);if(0===a(n(t),new o(0)))return ZW(e);var u=ZW(e),l=ZW(t);return r(s(u,l),i(u,l))}})})),s3=["typed","map","sqrt","variance"],o3=_U("std",s3,(e=>{var{typed:t,map:n,sqrt:r,variance:a}=e;return t("std",{"Array | Matrix":i,"Array | Matrix, string":i,"Array | Matrix, number | BigNumber":i,"Array | Matrix, number | BigNumber, string":i,"...":function(e){return i(e)}});function i(e,t){if(0===e.length)throw new SyntaxError("Function std requires one or more parameters (0 provided)");try{var i=a.apply(null,arguments);return qP(i)?n(i,r):r(i)}catch(e){throw e instanceof TypeError&&-1!==e.message.indexOf(" variance")?new TypeError(e.message.replace(" variance"," std")):e}}})),u3=["typed","abs","map","median","subtract"],l3=_U("mad",u3,(e=>{var{typed:t,abs:n,map:r,median:a,subtract:i}=e;return t("mad",{"Array | Matrix":s,"...":function(e){return s(e)}});function s(e){if(0===(e=ZW(e.valueOf())).length)throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");try{var t=a(e);return a(r(e,(function(e){return n(i(e,t))})))}catch(e){throw e instanceof TypeError&&-1!==e.message.indexOf("median")?new TypeError(e.message.replace("median","mad")):sZ(e,"mad")}}})),c3="norm",p3=["typed","abs","add","pow","conj","sqrt","multiply","equalScalar","larger","smaller","matrix","ctranspose","eigs"],d3=_U(c3,p3,(e=>{var{typed:t,abs:n,add:r,pow:a,conj:i,sqrt:s,multiply:o,equalScalar:u,larger:l,smaller:c,matrix:p,ctranspose:d,eigs:h}=e;return t(c3,{number:Math.abs,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},boolean:function(e){return Math.abs(e)},Array:function(e){return f(p(e),2)},Matrix:function(e){return f(e,2)},"Array, number | BigNumber | string":function(e,t){return f(p(e),t)},"Matrix, number | BigNumber | string":function(e,t){return f(e,t)}});function f(e,t){var p=e.size();if(1===p.length)return function(e,t){if(t===Number.POSITIVE_INFINITY||"inf"===t)return function(e){var t=0;return e.forEach((function(e){var r=n(e);l(r,t)&&(t=r)}),!0),t}(e);if(t===Number.NEGATIVE_INFINITY||"-inf"===t)return function(e){var t;return e.forEach((function(e){var r=n(e);t&&!c(r,t)||(t=r)}),!0),t||0}(e);if("fro"===t)return f(e,2);if("number"==typeof t&&!isNaN(t)){if(!u(t,0)){var i=0;return e.forEach((function(e){i=r(a(n(e),t),i)}),!0),a(i,1/t)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}(e,t);if(2===p.length){if(p[0]&&p[1])return function(e,t){if(1===t)return function(e){var t=[],a=0;return e.forEach((function(e,i){var s=i[1],o=r(t[s]||0,n(e));l(o,a)&&(a=o),t[s]=o}),!0),a}(e);if(t===Number.POSITIVE_INFINITY||"inf"===t)return function(e){var t=[],a=0;return e.forEach((function(e,i){var s=i[0],o=r(t[s]||0,n(e));l(o,a)&&(a=o),t[s]=o}),!0),a}(e);if("fro"===t)return function(e){var t=0;return e.forEach((function(e,n){t=r(t,o(e,i(e)))})),n(s(t))}(e);if(2===t)return function(e){var t=e.size();if(t[0]!==t[1])throw new RangeError("Invalid matrix dimensions");var r=d(e),a=o(r,e),i=h(a).values.toArray(),u=i[i.length-1];return n(s(u))}(e);throw new Error("Unsupported parameter value "+t)}(e,t);throw new RangeError("Invalid matrix dimensions")}}})),h3="rotationMatrix",f3=["typed","config","multiplyScalar","addScalar","unaryMinus","norm","matrix","BigNumber","DenseMatrix","SparseMatrix","cos","sin"],m3=_U(h3,f3,(e=>{var{typed:t,config:n,multiplyScalar:r,addScalar:a,unaryMinus:i,norm:s,BigNumber:o,matrix:u,DenseMatrix:l,SparseMatrix:c,cos:p,sin:d}=e;return t(h3,{"":function(){return"Matrix"===n.matrix?u([]):[]},string:function(e){return u(e)},"number | BigNumber | Complex | Unit":function(e){return h(e,"Matrix"===n.matrix?"dense":void 0)},"number | BigNumber | Complex | Unit, string":function(e,t){return h(e,t)},"number | BigNumber | Complex | Unit, Array":function(e,t){var n=u(t);return f(n),y(e,n,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(e,t){f(t);var r=t.storage()||("Matrix"===n.matrix?"dense":void 0);return y(e,t,r)},"number | BigNumber | Complex | Unit, Array, string":function(e,t,n){var r=u(t);return f(r),y(e,r,n)},"number | BigNumber | Complex | Unit, Matrix, string":function(e,t,n){return f(t),y(e,t,n)}});function h(e,t){var n=YP(e)?new o(-1):-1,a=p(e),i=d(e);return g([[a,r(n,i)],[i,a]],t)}function f(e){var t=e.size();if(t.length<1||3!==t[0])throw new RangeError("Vector must be of dimensions 1x3")}function m(e){return e.reduce(((e,t)=>r(e,t)))}function g(e,t){if(t){if("sparse"===t)return new c(e);if("dense"===t)return new l(e);throw new TypeError('Unknown matrix type "'.concat(t,'"'))}return e}function y(e,t,n){var r=s(t);if(0===r)throw new RangeError("Rotation around zero vector");var u=YP(e)?o:null,l=u?new u(1):1,c=u?new u(-1):-1,h=u?new u(t.get([0])/r):t.get([0])/r,f=u?new u(t.get([1])/r):t.get([1])/r,y=u?new u(t.get([2])/r):t.get([2])/r,b=p(e),v=a(l,i(b)),x=d(e);return g([[a(b,m([h,h,v])),a(m([h,f,v]),m([c,y,x])),a(m([h,y,v]),m([f,x]))],[a(m([h,f,v]),m([y,x])),a(b,m([f,f,v])),a(m([f,y,v]),m([c,h,x]))],[a(m([h,y,v]),m([c,f,x])),a(m([f,y,v]),m([h,x])),a(b,m([y,y,v]))]],n)}})),g3="kldivergence",y3=["typed","matrix","divide","sum","multiply","map","dotDivide","log","isNumeric"],b3=_U(g3,y3,(e=>{var{typed:t,matrix:n,divide:r,sum:a,multiply:i,map:s,dotDivide:o,log:u,isNumeric:l}=e;return t(g3,{"Array, Array":function(e,t){return c(n(e),n(t))},"Matrix, Array":function(e,t){return c(e,n(t))},"Array, Matrix":function(e,t){return c(n(e),t)},"Matrix, Matrix":function(e,t){return c(e,t)}});function c(e,t){var n=t.size().length,c=e.size().length;if(n>1)throw new Error("first object must be one dimensional");if(c>1)throw new Error("second object must be one dimensional");if(n!==c)throw new Error("Length of two vectors must be equal");if(0===a(e))throw new Error("Sum of elements in first object must be non zero");if(0===a(t))throw new Error("Sum of elements in second object must be non zero");var p=r(e,a(e)),d=r(t,a(t)),h=a(i(p,s(o(p,d),(e=>u(e)))));return l(h)?h:Number.NaN}})),v3="rotate",x3=["typed","multiply","rotationMatrix"],_3=_U(v3,x3,(e=>{var{typed:t,multiply:n,rotationMatrix:r}=e;return t(v3,{"Array , number | BigNumber | Complex | Unit":function(e,t){return a(e,2),n(r(t),e).toArray()},"Matrix , number | BigNumber | Complex | Unit":function(e,t){return a(e,2),n(r(t),e)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,i){return a(e,3),n(r(t,i),e)},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,i){return a(e,3),n(r(t,i),e)}});function a(e,t){var n=Array.isArray(e)?BW(e):e.size();if(n.length>2)throw new RangeError("Vector must be of dimensions 1x".concat(t));if(2===n.length&&1!==n[1])throw new RangeError("Vector must be of dimensions 1x".concat(t));if(n[0]!==t)throw new RangeError("Vector must be of dimensions 1x".concat(t))}})),w3=NU({config:RH}),D3=GU({}),N3=hq({BigNumber:w3,config:RH}),M3=oq({}),S3=qq({BigNumber:w3,config:RH}),k3=MW({}),T3=_q({Complex:D3}),C3=lq({BigNumber:w3,config:RH}),E3=gq({BigNumber:w3,config:RH}),A3=bq({BigNumber:w3,config:RH}),I3=SW({}),L3=cq({BigNumber:w3,config:RH}),F3=uq({}),$3=fq({BigNumber:w3,config:RH}),O3=kW({}),R3=TW({}),Y3=vq({BigNumber:w3,config:RH}),B3=cW({BigNumber:w3,config:RH}),z3=dq({BigNumber:w3,config:RH}),P3=sq({}),H3=Nq({}),j3=uV({Matrix:I3}),U3=eW({BigNumber:w3,config:RH}),q3=mq({BigNumber:w3,config:RH}),W3=pq({BigNumber:w3,config:RH}),V3=lV({}),G3=xq({BigNumber:w3,config:RH}),K3=NV({BigNumber:w3,Complex:D3,DenseMatrix:j3,Fraction:k3}),J3=aG({BigNumber:w3,config:RH,typed:K3}),X3=Qq({BigNumber:w3,config:RH}),Z3=iG({typed:K3}),Q3=oG({Complex:D3,config:RH,typed:K3}),e4=SG({BigNumber:w3,typed:K3}),t4=TG({BigNumber:w3,Complex:D3,config:RH,typed:K3}),n4=EG({typed:K3}),r4=AG({typed:K3}),a4=LG({BigNumber:w3,Complex:D3,config:RH,typed:K3}),i4=FG({typed:K3}),s4=$G({typed:K3}),o4=RG({Complex:D3,config:RH,typed:K3}),u4=YG({BigNumber:w3,typed:K3}),l4=nK({typed:K3}),c4=aK({typed:K3}),p4=sK({typed:K3}),d4=cK({typed:K3}),h4=dK({Complex:D3,typed:K3}),f4=fK({typed:K3}),m4=gK({typed:K3}),g4=bK({BigNumber:w3,typed:K3}),y4=xK({BigNumber:w3,typed:K3}),b4=wK({typed:K3}),v4=SK({config:RH,typed:K3}),x4=kK({typed:K3}),_4=LK({typed:K3}),w4=$K({Complex:D3,typed:K3}),D4=OK({typed:K3}),N4=BK({typed:K3}),M4=HK({typed:K3}),S4=UK({typed:K3}),k4=qK({format:M4,typed:K3}),T4=WK({typed:K3}),C4=GK({typed:K3}),E4=tJ({typed:K3}),A4=rJ({typed:K3}),I4=iJ({typed:K3}),L4=yq({BigNumber:w3,config:RH}),F4=hJ({Complex:D3,typed:K3}),$4=mJ({Complex:D3,config:RH,typed:K3}),O4=yJ({Complex:D3,config:RH,typed:K3}),R4=bJ({typed:K3}),Y4=xJ({typed:K3}),B4=SJ({typed:K3}),z4=kJ({typed:K3}),P4=TJ({format:M4,typed:K3}),H4=IJ({config:RH,typed:K3}),j4=FJ({typed:K3}),U4=YJ({config:RH,typed:K3}),q4=BJ({typed:K3}),W4=zJ({BigNumber:w3,typed:K3}),V4=HJ({BigNumber:w3,Fraction:k3,complex:h4,typed:K3}),G4=jJ({typed:K3}),K4=UJ({Matrix:I3,equalScalar:v4,typed:K3}),J4=WJ({typed:K3}),X4=GJ({typed:K3}),Z4=JJ({typed:K3}),Q4=XJ({typed:K3}),e5=QJ({typed:K3}),t5=tX({Complex:D3,config:RH,typed:K3}),n5=rX({BigNumber:w3,typed:K3}),r5=iX({isInteger:C4,typed:K3}),a5=uX({BigNumber:w3,Complex:D3,config:RH,typed:K3}),i5=lX({format:M4,typed:K3}),s5=pX({typed:K3}),o5=hX({typed:K3}),u5=mX({BigNumber:w3,typed:K3}),l5=yX({typed:K3}),c5=vX({typed:K3}),d5=_X({config:RH,typed:K3}),h5=DX({BigNumber:w3,typed:K3}),f5=MX({typed:K3}),m5=kX({SparseMatrix:K4,typed:K3}),g5=TX({Complex:D3,config:RH,typed:K3}),y5=CX({typed:K3}),b5=AX({typed:K3}),v5=LX({BigNumber:w3,Complex:D3,config:RH,typed:K3}),x5=FX({BigNumber:w3,typed:K3}),_5=$X({Fraction:k3,typed:K3}),w5=RX({typed:K3}),D5=BX({DenseMatrix:j3,Matrix:I3,SparseMatrix:K4,typed:K3}),N5=PX({isZero:I4,matrix:D5,typed:K3}),M5=JX({DenseMatrix:j3,equalScalar:v4,matrix:D5,typed:K3}),S5=eZ({BigNumber:w3,equalScalar:v4,matrix:D5,typed:K3}),k5=aZ({bignumber:u4,fraction:_5,number:z4}),T5=iZ({DenseMatrix:j3,equalScalar:v4,matrix:D5,typed:K3}),C5=uZ({config:RH,multiplyScalar:Y4,numeric:k5,typed:K3}),E5=cZ({isInteger:C4,matrix:D5,typed:K3}),A5=dZ({matrix:D5,config:RH,typed:K3}),I5=mZ({DenseMatrix:j3,config:RH,matrix:D5,typed:K3}),L5=bZ({matrix:D5,typed:K3}),F5=xZ({matrix:D5,typed:K3}),$5=kZ({DenseMatrix:j3,addScalar:n4,equalScalar:v4,matrix:D5,typed:K3,unaryMinus:b5}),O5=TZ({matrix:D5,typed:K3}),R5=EZ({matrix:D5,typed:K3}),Y5=IZ({BigNumber:w3,config:RH,matrix:D5,typed:K3}),B5=FZ({BigNumber:w3,config:RH,matrix:D5,typed:K3}),z5=$Z({equalScalar:v4,matrix:D5,not:B4,typed:K3,zeros:B5}),P5=RZ({equalScalar:v4,matrix:D5,typed:K3}),H5=BZ({DenseMatrix:j3,matrix:D5,typed:K3}),j5=PZ({BigNumber:w3,Complex:D3,Fraction:k3,config:RH,isNegative:E4,matrix:D5,typed:K3,unaryMinus:b5}),U5=jZ({BigNumber:w3,DenseMatrix:j3,Fraction:k3,config:RH,equalScalar:v4,matrix:D5,typed:K3}),q5=VZ({matrix:D5,typed:K3}),W5=KZ({isInteger:C4,matrix:D5,typed:K3}),V5=ZZ({prod:C5,size:A5,typed:K3}),G5=eQ({conj:f4,transpose:R5,typed:K3}),K5=nQ({DenseMatrix:j3,SparseMatrix:K4,matrix:D5,typed:K3}),J5=aQ({numeric:k5,typed:K3}),X5=sQ({DenseMatrix:j3,divideScalar:J5,equalScalar:v4,matrix:D5,typed:K3}),Z5=uQ({DenseMatrix:j3,equalScalar:v4,matrix:D5,typed:K3}),Q5=cQ({addScalar:n4,divideScalar:J5,exp:_4,i:T3,matrix:D5,multiplyScalar:Y4,tau:z3,typed:K3}),e8=dQ({matrix:D5,typed:K3}),t8=fQ({BigNumber:w3,DenseMatrix:j3,equalScalar:v4,matrix:D5,typed:K3}),n8=gQ({isNumeric:w5,typed:K3}),r8=bQ({abs:Z3,addScalar:n4,divideScalar:J5,isPositive:A4,multiplyScalar:Y4,smaller:I5,sqrt:g5,typed:K3}),a8=xQ({conj:f4,dotDivide:X5,fft:Q5,typed:K3}),i8=wQ({matrix:D5,multiplyScalar:Y4,typed:K3}),s8=NQ({DenseMatrix:j3,config:RH,matrix:D5,typed:K3}),o8=CQ({DenseMatrix:j3,equalScalar:v4,matrix:D5,typed:K3,zeros:B5}),u8=IQ({DenseMatrix:j3,divideScalar:J5,equalScalar:v4,matrix:D5,multiplyScalar:Y4,subtract:$5,typed:K3}),l8=FQ({flatten:e8,matrix:D5,size:A5,typed:K3}),c8=$Q({config:RH,numeric:k5,smaller:I5,typed:K3}),p8=RQ({isNaN:l5,isNumeric:w5,typed:K3}),d8=BQ({Complex:D3,config:RH,divideScalar:J5,typed:K3}),h8=zQ({BigNumber:w3,config:RH,matrix:D5,typed:K3}),f8=HQ({compare:U5,isNaN:l5,isNumeric:w5,typed:K3}),m8=UQ({config:RH,matrix:D5}),g8=WQ({DenseMatrix:j3,equalScalar:v4,matrix:D5,typed:K3,zeros:B5}),y8=KQ({BigNumber:w3,DenseMatrix:j3,equalScalar:v4,matrix:D5,typed:K3,zeros:B5}),b8=XQ({DenseMatrix:j3,config:RH,matrix:D5,typed:K3}),v8=e0({DenseMatrix:j3,config:RH,equalScalar:v4,matrix:D5,typed:K3}),x8=r0({DenseMatrix:j3,divideScalar:J5,equalScalar:v4,matrix:D5,multiplyScalar:Y4,subtract:$5,typed:K3}),_8=a0({DenseMatrix:j3,matrix:D5,typed:K3}),w8=i0({DenseMatrix:j3,SparseMatrix:K4,addScalar:n4,equalScalar:v4,matrix:D5,typed:K3}),D8=u0({BigNumber:w3,DenseMatrix:j3,equalScalar:v4,matrix:D5,typed:K3}),N8=c0({DenseMatrix:j3,equalScalar:v4,matrix:D5,typed:K3}),M8=d0({addScalar:n4,combinations:d4,divideScalar:J5,isInteger:C4,isNegative:E4,multiplyScalar:Y4,typed:K3}),S8=m0({compare:U5,typed:K3}),k8=y0({add:w8,typed:K3,unaryPlus:J3}),T8=v0({equal:Z5,typed:K3}),C8=_0({matrix:D5,number:z4,subtract:$5,typed:K3}),E8=w0({addScalar:n4,conj:f4,multiplyScalar:Y4,size:A5,typed:K3}),A8=N0({compareText:q5,isZero:I4,typed:K3}),I8=T0({DenseMatrix:j3,config:RH,equalScalar:v4,matrix:D5,round:y8,typed:K3,zeros:B5}),L8=E0({BigNumber:w3,DenseMatrix:j3,SparseMatrix:K4,config:RH,matrix:D5,typed:K3}),F8=I0({BigNumber:w3,add:w8,config:RH,equal:Z5,isInteger:C4,mod:M5,smaller:I5,typed:K3,xgcd:Y5}),$8=F0({DenseMatrix:j3,config:RH,matrix:D5,typed:K3}),O8=O0({Complex:D3,config:RH,divideScalar:J5,typed:K3}),R8=Y0({DenseMatrix:j3,divideScalar:J5,equalScalar:v4,matrix:D5,multiplyScalar:Y4,subtract:$5,typed:K3}),Y8=z0({flatten:e8,matrix:D5,size:A5,typed:K3}),B8=H0({addScalar:n4,dot:E8,equalScalar:v4,matrix:D5,multiplyScalar:Y4,typed:K3}),z8=j0({addScalar:n4,complex:h4,conj:f4,divideScalar:J5,equal:Z5,identity:L8,isZero:I4,matrix:D5,multiplyScalar:Y4,sign:V4,sqrt:g5,subtract:$5,typed:K3,unaryMinus:b5,zeros:B5}),P8=q0({bignumber:u4,matrix:D5,config:RH,larger:$8,largerEq:s8,smaller:I5,smallerEq:b8,typed:K3}),H8=V0({DenseMatrix:j3,equalScalar:v4,matrix:D5,typed:K3,zeros:B5}),j8=K0({compareNatural:S8,typed:K3}),U8=u1({SparseMatrix:K4,abs:Z3,add:w8,divideScalar:J5,larger:$8,largerEq:s8,multiply:B8,subtract:$5,transpose:R5,typed:K3}),q8=l1({add:w8,config:RH,numeric:k5,typed:K3}),W8=c1({add:w8,matrix:D5,typed:K3}),V8=d1({DenseMatrix:j3,divideScalar:J5,equalScalar:v4,matrix:D5,multiplyScalar:Y4,subtract:$5,typed:K3}),G8=f1({Complex:D3,config:RH,typed:K3}),K8=b1({DenseMatrix:j3,config:RH,equalScalar:v4,matrix:D5,round:y8,typed:K3,zeros:B5}),J8=x1({addScalar:n4,combinations:d4,isInteger:C4,isNegative:E4,isPositive:A4,larger:$8,typed:K3}),X8=w1({matrix:D5,multiply:B8,subtract:$5,typed:K3}),Z8=D1({divideScalar:J5,isZero:I4,matrix:D5,multiply:B8,subtract:$5,typed:K3,unaryMinus:b5}),Q8=M1({abs:Z3,addScalar:n4,divideScalar:J5,multiplyScalar:Y4,sqrt:g5,subtract:$5,typed:K3,unaryMinus:b5}),e6=k1({equalScalar:v4,matrix:D5,multiplyScalar:Y4,typed:K3}),t6=T1({larger:$8,smaller:I5}),n6=I1({Complex:D3,DenseMatrix:j3,ceil:K8,equalScalar:v4,floor:I8,matrix:D5,typed:K3,zeros:B5}),r6=L1({DenseMatrix:j3,smaller:I5}),a6=F1({ImmutableDenseMatrix:r6}),i6=$1({abs:Z3,add:w8,addScalar:n4,config:RH,divideScalar:J5,equalScalar:v4,flatten:e8,isNumeric:w5,isZero:I4,matrix:D5,multiply:B8,multiplyScalar:Y4,smaller:I5,subtract:$5,typed:K3}),s6=O1({equalScalar:v4,matrix:D5,typed:K3}),o6=Y1({Complex:D3,config:RH,divideScalar:J5,log:O8,typed:K3}),u6=B1({config:RH,larger:$8,numeric:k5,typed:K3}),l6=z1({add:w8,compare:U5,multiply:B8,partitionSelect:f8,typed:K3}),c6=P1({Index:a6,matrix:D5,range:P8,typed:K3}),p6=j1({DenseMatrix:j3,Index:a6,compareNatural:S8,size:A5,subset:F5,typed:K3}),d6=q1({DenseMatrix:j3,Index:a6,compareNatural:S8,size:A5,subset:F5,typed:K3}),h6=V1({Index:a6,compareNatural:S8,size:A5,subset:F5,typed:K3}),f6=K1({Index:a6,compareNatural:S8,size:A5,subset:F5,typed:K3}),m6=X1({compare:U5,compareNatural:S8,matrix:D5,typed:K3}),g6=Q1({Index:a6,matrix:D5,range:P8,typed:K3}),y6=t2({Index:a6,typed:K3}),b6=n2({abs:Z3,addScalar:n4,det:Z8,divideScalar:J5,identity:L8,matrix:D5,multiply:B8,typed:K3,unaryMinus:b5}),v6=a2({Complex:D3,add:w8,ctranspose:G5,deepEqual:T8,divideScalar:J5,dot:E8,dotDivide:X5,equal:Z5,inv:b6,matrix:D5,multiply:B8,typed:K3}),x6=i2({Complex:D3,config:RH,fraction:_5,identity:L8,inv:b6,matrix:D5,multiply:B8,number:z4,typed:K3}),_6=o2({DenseMatrix:j3,Index:a6,compareNatural:S8,size:A5,subset:F5,typed:K3}),w6=l2({Index:a6,compareNatural:S8,size:A5,subset:F5,typed:K3}),D6=c2({FibonacciHeap:t6,addScalar:n4,equalScalar:v4}),N6=d2({abs:Z3,add:w8,identity:L8,inv:b6,map:R4,max:u6,multiply:B8,size:A5,sqrt:g5,subtract:$5,typed:K3}),M6=g2({BigNumber:w3,Complex:D3,Fraction:k3,abs:Z3,addScalar:n4,config:RH,divideScalar:J5,equal:Z5,fix:n6,format:M4,isNumeric:w5,multiplyScalar:Y4,number:z4,pow:x6,round:y8,subtract:$5}),S6=Iq({BigNumber:w3,Unit:M6,config:RH}),k6=hW({BigNumber:w3,Unit:M6,config:RH}),T6=tW({BigNumber:w3,Unit:M6,config:RH}),C6=$q({BigNumber:w3,Unit:M6,config:RH}),E6=rW({BigNumber:w3,Unit:M6,config:RH}),A6=Oq({BigNumber:w3,Unit:M6,config:RH}),I6=b2({Unit:M6,typed:K3}),L6=Gq({BigNumber:w3,Unit:M6,config:RH}),F6=x2({DenseMatrix:j3,equalScalar:v4,matrix:D5,pow:x6,typed:K3}),$6=Aq({BigNumber:w3,Unit:M6,config:RH}),O6=Fq({BigNumber:w3,Unit:M6,config:RH}),R6=w2({abs:Z3,add:w8,identity:L8,inv:b6,multiply:B8,typed:K3}),Y6=aW({BigNumber:w3,Unit:M6,config:RH}),B6=iW({BigNumber:w3,Unit:M6,config:RH}),z6=N2({BigNumber:w3,Complex:D3,config:RH,multiplyScalar:Y4,pow:x6,typed:K3}),P6=kq({BigNumber:w3,Unit:M6,config:RH}),H6=Wq({BigNumber:w3,Unit:M6,config:RH}),j6=zq({BigNumber:w3,Unit:M6,config:RH}),U6=sW({BigNumber:w3,Unit:M6,config:RH}),q6=Eq({BigNumber:w3,Unit:M6,config:RH}),W6=fW({BigNumber:w3,Unit:M6,config:RH}),V6=uW({BigNumber:w3,Unit:M6,config:RH}),G6=Kq({BigNumber:w3,Unit:M6,config:RH}),K6=Bq({BigNumber:w3,Unit:M6,config:RH}),J6=xW({BigNumber:w3,Unit:M6,config:RH}),X6=yW({BigNumber:w3,Unit:M6,config:RH}),Z6=_W({BigNumber:w3,Unit:M6,config:RH}),Q6=Vq({BigNumber:w3,Unit:M6,config:RH}),e7=Cq({BigNumber:w3,Unit:M6,config:RH}),t7=Xq({BigNumber:w3,Unit:M6,config:RH}),n7=S2({DenseMatrix:j3,Index:a6,compareNatural:S8,size:A5,subset:F5,typed:K3}),r7=Sq({BigNumber:w3,Unit:M6,config:RH}),a7=dW({BigNumber:w3,Unit:M6,config:RH}),i7=Zq({BigNumber:w3,Unit:M6,config:RH}),s7=nW({BigNumber:w3,Unit:M6,config:RH}),o7=Pq({BigNumber:w3,Unit:M6,config:RH}),u7=Lq({BigNumber:w3,Unit:M6,config:RH}),l7=k2({divideScalar:J5,equalScalar:v4,inv:b6,matrix:D5,multiply:B8,typed:K3}),c7=jq({BigNumber:w3,Unit:M6,config:RH}),p7=C2({gamma:z6,typed:K3}),d7=gW({BigNumber:w3,Unit:M6,config:RH}),h7=Rq({BigNumber:w3,Unit:M6,config:RH}),f7=E2({DenseMatrix:j3,Spa:D6,SparseMatrix:K4,abs:Z3,addScalar:n4,divideScalar:J5,equalScalar:v4,larger:$8,matrix:D5,multiplyScalar:Y4,subtract:$5,typed:K3,unaryMinus:b5}),m7=Yq({BigNumber:w3,Unit:M6,config:RH}),g7=mW({BigNumber:w3,Unit:M6,config:RH}),y7=I2({add:w8,divide:l7,factorial:p7,isInteger:C4,isPositive:A4,multiply:B8,typed:K3}),b7=F2({factorial:p7,typed:K3}),v7=bW({BigNumber:w3,Unit:M6,config:RH}),x7=Jq({BigNumber:w3,Unit:M6,config:RH}),_7=pW({BigNumber:w3,Unit:M6,config:RH}),w7=R2({bignumber:u4,addScalar:n4,combinations:d4,divideScalar:J5,factorial:p7,isInteger:C4,isNegative:E4,larger:$8,multiplyScalar:Y4,number:z4,pow:x6,subtract:$5,typed:K3}),D7=B2({Unit:M6,typed:K3}),N7=P2({addScalar:n4,isInteger:C4,isNegative:E4,stirlingS2:w7,typed:K3}),M7=H2({abs:Z3,add:w8,addScalar:n4,atan:s4,bignumber:u4,column:g6,complex:h4,config:RH,cos:o5,diag:K5,divideScalar:J5,dot:E8,equal:Z5,flatten:e8,im:T4,inv:b6,larger:$8,matrix:D5,matrixFromColumns:l8,multiply:B8,multiplyScalar:Y4,number:z4,qr:z8,re:q4,sin:G4,smaller:I5,sqrt:g5,subtract:$5,typed:K3,usolve:x8,usolveAll:V8}),S7=Uq({BigNumber:w3,Unit:M6,config:RH}),k7=U2({add:w8,divide:l7,typed:K3}),T7=lW({BigNumber:w3,Unit:M6,config:RH}),C7=Tq({BigNumber:w3,Unit:M6,config:RH}),E7=W2({Index:a6,concat:W5,setDifference:_6,size:A5,subset:F5,typed:K3}),A7=K2({add:w8,apply:r5,divide:l7,isNaN:l5,multiply:B8,subtract:$5,typed:K3}),I7=Hq({BigNumber:w3,Unit:M6,config:RH}),L7=Q2({DenseMatrix:j3,lsolve:u8,lup:f7,matrix:D5,slu:U8,typed:K3,usolve:x8}),F7=n3({add:w8,compare:U5,divide:l7,partitionSelect:f8,typed:K3}),$7=i3({Index:a6,concat:W5,setIntersect:n7,setSymDifference:E7,size:A5,subset:F5,typed:K3}),O7=o3({map:R4,sqrt:g5,typed:K3,variance:A7}),R7=oW({BigNumber:w3,Unit:M6,config:RH}),Y7=l3({abs:Z3,map:R4,median:F7,subtract:$5,typed:K3}),B7=d3({abs:Z3,add:w8,conj:f4,ctranspose:G5,eigs:M7,equalScalar:v4,larger:$8,matrix:D5,multiply:B8,pow:x6,smaller:I5,sqrt:g5,typed:K3}),z7=m3({BigNumber:w3,DenseMatrix:j3,SparseMatrix:K4,addScalar:n4,config:RH,cos:o5,matrix:D5,multiplyScalar:Y4,norm:B7,sin:G4,typed:K3,unaryMinus:b5}),P7=b3({divide:l7,dotDivide:X5,isNumeric:w5,log:O8,map:R4,matrix:D5,multiply:B8,sum:q8,typed:K3}),H7=_3({multiply:B8,rotationMatrix:z7,typed:K3}),j7=vW({BigNumber:w3,Unit:M6,config:RH}),U7=new Set(["end"]),q7=_U("Node",["mathWithTransform"],(e=>{var{mathWithTransform:t}=e;return class{get type(){return"Node"}get isNode(){return!0}evaluate(e){return this.compile().evaluate(e)}compile(){var e=this._compile(t,{}),n={};return{evaluate:function(t){var r=xV(t);return function(e){for(var t of[...U7])if(e.has(t))throw new Error('Scope contains an illegal symbol, "'+t+'" is a reserved keyword')}(r),e(r,n,null)}}}_compile(e,t){throw new Error("Method _compile must be implemented by type "+this.type)}forEach(e){throw new Error("Cannot run forEach on a Node interface")}map(e){throw new Error("Cannot run map on a Node interface")}_ifNode(e){if(!mH(e))throw new TypeError("Callback function must return a Node");return e}traverse(e){e(this,null,null),function e(t,n){t.forEach((function(t,r,a){n(t,r,a),e(t,n)}))}(this,e)}transform(e){return function t(n,r,a){var i=e(n,r,a);return i!==n?i:n.map(t)}(this,null,null)}filter(e){var t=[];return this.traverse((function(n,r,a){e(n,r,a)&&t.push(n)})),t}clone(){throw new Error("Cannot clone a Node interface")}cloneDeep(){return this.map((function(e){return e.cloneDeep()}))}equals(e){return!!e&&this.type===e.type&&kH(this,e)}toString(e){var t=this._getCustomString(e);return void 0!==t?t:this._toString(e)}toJSON(){throw new Error("Cannot serialize object: toJSON not implemented by "+this.type)}toHTML(e){var t=this._getCustomString(e);return void 0!==t?t:this.toHTML(e)}_toString(){throw new Error("_toString not implemented for "+this.type)}toTex(e){var t=this._getCustomString(e);return void 0!==t?t:this._toTex(e)}_toTex(e){throw new Error("_toTex not implemented for "+this.type)}_getCustomString(e){if(e&&"object"==typeof e)switch(typeof e.handler){case"object":case"undefined":return;case"function":return e.handler(this,e);default:throw new TypeError("Object or function expected as callback")}}getIdentifier(){return this.type}getContent(){return this}}}),{isClass:!0,isNode:!0}),W7="ObjectNode",V7=_U(W7,["Node"],(e=>{var{Node:t}=e;class n extends t{constructor(e){if(super(),this.properties=e||{},e&&("object"!=typeof e||!Object.keys(e).every((function(t){return mH(e[t])}))))throw new TypeError("Object containing Nodes expected")}get type(){return W7}get isObjectNode(){return!0}_compile(e,t){var n={};for(var r in this.properties)if(AH(this.properties,r)){var a=LW(r),i=JSON.parse(a);if(!hV(this.properties,i))throw new Error('No access to property "'+i+'"');n[i]=this.properties[r]._compile(e,t)}return function(e,t,r){var a={};for(var i in n)AH(n,i)&&(a[i]=n[i](e,t,r));return a}}forEach(e){for(var t in this.properties)AH(this.properties,t)&&e(this.properties[t],"properties["+LW(t)+"]",this)}map(e){var t={};for(var r in this.properties)AH(this.properties,r)&&(t[r]=this._ifNode(e(this.properties[r],"properties["+LW(r)+"]",this)));return new n(t)}clone(){var e={};for(var t in this.properties)AH(this.properties,t)&&(e[t]=this.properties[t]);return new n(e)}_toString(e){var t=[];for(var n in this.properties)AH(this.properties,n)&&t.push(LW(n)+": "+this.properties[n].toString(e));return"{"+t.join(", ")+"}"}toJSON(){return{mathjs:W7,properties:this.properties}}static fromJSON(e){return new n(e.properties)}toHTML(e){var t=[];for(var n in this.properties)AH(this.properties,n)&&t.push(''+FW(n)+':'+this.properties[n].toHTML(e));return'{'+t.join(',')+'}'}_toTex(e){var t=[];for(var n in this.properties)AH(this.properties,n)&&t.push("\\mathbf{"+n+":} & "+this.properties[n].toTex(e)+"\\\\");return"\\left\\{\\begin{array}{ll}"+t.join("\n")+"\\end{array}\\right\\}"}}return h2(n,"name",W7),n}),{isClass:!0,isNode:!0}),G7=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{op:"or",associativity:"left",associativeWith:[]}},{"OperatorNode:xor":{op:"xor",associativity:"left",associativeWith:[]}},{"OperatorNode:and":{op:"and",associativity:"left",associativeWith:[]}},{"OperatorNode:bitOr":{op:"|",associativity:"left",associativeWith:[]}},{"OperatorNode:bitXor":{op:"^|",associativity:"left",associativeWith:[]}},{"OperatorNode:bitAnd":{op:"&",associativity:"left",associativeWith:[]}},{"OperatorNode:equal":{op:"==",associativity:"left",associativeWith:[]},"OperatorNode:unequal":{op:"!=",associativity:"left",associativeWith:[]},"OperatorNode:smaller":{op:"<",associativity:"left",associativeWith:[]},"OperatorNode:larger":{op:">",associativity:"left",associativeWith:[]},"OperatorNode:smallerEq":{op:"<=",associativity:"left",associativeWith:[]},"OperatorNode:largerEq":{op:">=",associativity:"left",associativeWith:[]},RelationalNode:{associativity:"left",associativeWith:[]}},{"OperatorNode:leftShift":{op:"<<",associativity:"left",associativeWith:[]},"OperatorNode:rightArithShift":{op:">>",associativity:"left",associativeWith:[]},"OperatorNode:rightLogShift":{op:">>>",associativity:"left",associativeWith:[]}},{"OperatorNode:to":{op:"to",associativity:"left",associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{op:"+",associativity:"left",associativeWith:["OperatorNode:add","OperatorNode:subtract"]},"OperatorNode:subtract":{op:"-",associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{op:"*",associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]},"OperatorNode:divide":{op:"/",associativity:"left",associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{op:".*",associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:doDivide"]},"OperatorNode:dotDivide":{op:"./",associativity:"left",associativeWith:[]},"OperatorNode:mod":{op:"mod",associativity:"left",associativeWith:[]}},{"OperatorNode:multiply":{associativity:"left",associativeWith:["OperatorNode:multiply","OperatorNode:divide","Operator:dotMultiply","Operator:dotDivide"]}},{"OperatorNode:unaryPlus":{op:"+",associativity:"right"},"OperatorNode:unaryMinus":{op:"-",associativity:"right"},"OperatorNode:bitNot":{op:"~",associativity:"right"},"OperatorNode:not":{op:"not",associativity:"right"}},{"OperatorNode:pow":{op:"^",associativity:"right",associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{op:".^",associativity:"right",associativeWith:[]}},{"OperatorNode:factorial":{op:"!",associativity:"left"}},{"OperatorNode:ctranspose":{op:"'",associativity:"left"}}];function K7(e,t){if(!t||"auto"!==t)return e;for(var n=e;bH(n);)n=n.content;return n}function J7(e,t,n,r){var a=e;"keep"!==t&&(a=e.getContent());for(var i=a.getIdentifier(),s=null,o=0;o>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"},r9={abs:{1:"\\left|${args[0]}\\right|"},add:{2:"\\left(${args[0]}".concat(n9.add,"${args[1]}\\right)")},cbrt:{1:"\\sqrt[3]{${args[0]}}"},ceil:{1:"\\left\\lceil${args[0]}\\right\\rceil"},cube:{1:"\\left(${args[0]}\\right)^3"},divide:{2:"\\frac{${args[0]}}{${args[1]}}"},dotDivide:{2:"\\left(${args[0]}".concat(n9.dotDivide,"${args[1]}\\right)")},dotMultiply:{2:"\\left(${args[0]}".concat(n9.dotMultiply,"${args[1]}\\right)")},dotPow:{2:"\\left(${args[0]}".concat(n9.dotPow,"${args[1]}\\right)")},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:"\\left(e".concat(n9.pow,"{${args[0]}}-1\\right)"),fix:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},floor:{1:"\\left\\lfloor${args[0]}\\right\\rfloor"},gcd:"\\gcd\\left(${args}\\right)",hypot:"\\hypot\\left(${args}\\right)",log:{1:"\\ln\\left(${args[0]}\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}\\right)"},log10:{1:"\\log_{10}\\left(${args[0]}\\right)"},log1p:{1:"\\ln\\left(${args[0]}+1\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}+1\\right)"},log2:"\\log_{2}\\left(${args[0]}\\right)",mod:{2:"\\left(${args[0]}".concat(n9.mod,"${args[1]}\\right)")},multiply:{2:"\\left(${args[0]}".concat(n9.multiply,"${args[1]}\\right)")},norm:{1:"\\left\\|${args[0]}\\right\\|",2:void 0},nthRoot:{2:"\\sqrt[${args[1]}]{${args[0]}}"},nthRoots:{2:"\\{y : $y^{args[1]} = {${args[0]}}\\}"},pow:{2:"\\left(${args[0]}\\right)".concat(n9.pow,"{${args[1]}}")},round:{1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},sign:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},sqrt:{1:"\\sqrt{${args[0]}}"},square:{1:"\\left(${args[0]}\\right)^2"},subtract:{2:"\\left(${args[0]}".concat(n9.subtract,"${args[1]}\\right)")},unaryMinus:{1:"".concat(n9.unaryMinus,"\\left(${args[0]}\\right)")},unaryPlus:{1:"".concat(n9.unaryPlus,"\\left(${args[0]}\\right)")},bitAnd:{2:"\\left(${args[0]}".concat(n9.bitAnd,"${args[1]}\\right)")},bitNot:{1:n9.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:"\\left(${args[0]}".concat(n9.bitOr,"${args[1]}\\right)")},bitXor:{2:"\\left(${args[0]}".concat(n9.bitXor,"${args[1]}\\right)")},leftShift:{2:"\\left(${args[0]}".concat(n9.leftShift,"${args[1]}\\right)")},rightArithShift:{2:"\\left(${args[0]}".concat(n9.rightArithShift,"${args[1]}\\right)")},rightLogShift:{2:"\\left(${args[0]}".concat(n9.rightLogShift,"${args[1]}\\right)")},bellNumbers:{1:"\\mathrm{B}_{${args[0]}}"},catalan:{1:"\\mathrm{C}_{${args[0]}}"},stirlingS2:{2:"\\mathrm{S}\\left(${args}\\right)"},arg:{1:"\\arg\\left(${args[0]}\\right)"},conj:{1:"\\left(${args[0]}\\right)^*"},im:{1:"\\Im\\left\\lbrace${args[0]}\\right\\rbrace"},re:{1:"\\Re\\left\\lbrace${args[0]}\\right\\rbrace"},and:{2:"\\left(${args[0]}".concat(n9.and,"${args[1]}\\right)")},not:{1:n9.not+"\\left(${args[0]}\\right)"},or:{2:"\\left(${args[0]}".concat(n9.or,"${args[1]}\\right)")},xor:{2:"\\left(${args[0]}".concat(n9.xor,"${args[1]}\\right)")},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:"\\left(${args[0]}\\right)".concat(n9.ctranspose)},det:{1:"\\det\\left(${args[0]}\\right)"},dot:{2:"\\left(${args[0]}\\cdot${args[1]}\\right)"},expm:{1:"\\exp\\left(${args[0]}\\right)"},inv:{1:"\\left(${args[0]}\\right)^{-1}"},pinv:{1:"\\left(${args[0]}\\right)^{+}"},sqrtm:{1:"{${args[0]}}".concat(n9.pow,"{\\frac{1}{2}}")},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:"\\left(${args[0]}\\right)".concat(n9.transpose)},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:"\\left(${args[0]}\\right)".concat(n9.factorial)},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},lgamma:{1:"\\ln\\Gamma\\left(${args[0]}\\right)"},equal:{2:"\\left(${args[0]}".concat(n9.equal,"${args[1]}\\right)")},larger:{2:"\\left(${args[0]}".concat(n9.larger,"${args[1]}\\right)")},largerEq:{2:"\\left(${args[0]}".concat(n9.largerEq,"${args[1]}\\right)")},smaller:{2:"\\left(${args[0]}".concat(n9.smaller,"${args[1]}\\right)")},smallerEq:{2:"\\left(${args[0]}".concat(n9.smallerEq,"${args[1]}\\right)")},unequal:{2:"\\left(${args[0]}".concat(n9.unequal,"${args[1]}\\right)")},erf:{1:"erf\\left(${args[0]}\\right)"},max:"\\max\\left(${args}\\right)",min:"\\min\\left(${args}\\right)",variance:"\\mathrm{Var}\\left(${args}\\right)",acos:{1:"\\cos^{-1}\\left(${args[0]}\\right)"},acosh:{1:"\\cosh^{-1}\\left(${args[0]}\\right)"},acot:{1:"\\cot^{-1}\\left(${args[0]}\\right)"},acoth:{1:"\\coth^{-1}\\left(${args[0]}\\right)"},acsc:{1:"\\csc^{-1}\\left(${args[0]}\\right)"},acsch:{1:"\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"},asec:{1:"\\sec^{-1}\\left(${args[0]}\\right)"},asech:{1:"\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"},asin:{1:"\\sin^{-1}\\left(${args[0]}\\right)"},asinh:{1:"\\sinh^{-1}\\left(${args[0]}\\right)"},atan:{1:"\\tan^{-1}\\left(${args[0]}\\right)"},atan2:{2:"\\mathrm{atan2}\\left(${args}\\right)"},atanh:{1:"\\tanh^{-1}\\left(${args[0]}\\right)"},cos:{1:"\\cos\\left(${args[0]}\\right)"},cosh:{1:"\\cosh\\left(${args[0]}\\right)"},cot:{1:"\\cot\\left(${args[0]}\\right)"},coth:{1:"\\coth\\left(${args[0]}\\right)"},csc:{1:"\\csc\\left(${args[0]}\\right)"},csch:{1:"\\mathrm{csch}\\left(${args[0]}\\right)"},sec:{1:"\\sec\\left(${args[0]}\\right)"},sech:{1:"\\mathrm{sech}\\left(${args[0]}\\right)"},sin:{1:"\\sin\\left(${args[0]}\\right)"},sinh:{1:"\\sinh\\left(${args[0]}\\right)"},tan:{1:"\\tan\\left(${args[0]}\\right)"},tanh:{1:"\\tanh\\left(${args[0]}\\right)"},to:{2:"\\left(${args[0]}".concat(n9.to,"${args[1]}\\right)")},numeric:function(e,t){return e.args[0].toTex()},number:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},string:{0:'\\mathtt{""}',1:"\\mathrm{string}\\left(${args[0]}\\right)"},bignumber:{0:"0",1:"\\left(${args[0]}\\right)"},complex:{0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)+".concat(t9.i,"\\cdot\\left(${args[1]}\\right)\\right)")},matrix:{0:"\\begin{bmatrix}\\end{bmatrix}",1:"\\left(${args[0]}\\right)",2:"\\left(${args[0]}\\right)"},sparse:{0:"\\begin{bsparse}\\end{bsparse}",1:"\\left(${args[0]}\\right)"},unit:{1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"}},a9={deg:"^\\circ"};function i9(e){return e9(e,{preserveFormatting:!0})}function s9(e,t){return(t=void 0!==t&&t)?AH(a9,e)?a9[e]:"\\mathrm{"+i9(e)+"}":AH(t9,e)?t9[e]:i9(e)}var o9="OperatorNode",u9=_U(o9,["Node"],(e=>{var{Node:t}=e;function n(e,t){var r=e;if("auto"===t)for(;bH(r);)r=r.content;return!!cH(r)||!!yH(r)&&n(r.args[0],t)}function r(e,t,r,a,i){var s,o=J7(e,t,r),u=X7(e,t);if("all"===t||a.length>2&&"OperatorNode:add"!==e.getIdentifier()&&"OperatorNode:multiply"!==e.getIdentifier())return a.map((function(e){switch(e.getContent().type){case"ArrayNode":case"ConstantNode":case"SymbolNode":case"ParenthesisNode":return!1;default:return!0}}));switch(a.length){case 0:s=[];break;case 1:var l=J7(a[0],t,r,e);if(i&&null!==l){var c,p;if("keep"===t?(c=a[0].getIdentifier(),p=e.getIdentifier()):(c=a[0].getContent().getIdentifier(),p=e.getContent().getIdentifier()),!1===G7[o][p].latexLeftParens){s=[!1];break}if(!1===G7[l][c].latexParens){s=[!1];break}}if(null===l){s=[!1];break}if(l<=o){s=[!0];break}s=[!1];break;case 2:var d,h,f=J7(a[0],t,r,e),m=Z7(e,a[0],t);d=null!==f&&(f===o&&"right"===u&&!m||f=2&&"OperatorNode:multiply"===e.getIdentifier()&&e.implicit&&"all"!==t&&"hide"===r)for(var _=1;_2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var p=a.map((function(t,n){return t=t.toString(e),i[n]&&(t="("+t+")"),t}));return this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===n?p.join(" "):p.join(" "+this.op+" ")}return this.fn+"("+this.args.join(", ")+")"}toJSON(){return{mathjs:o9,op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}}static fromJSON(e){return new a(e.op,e.fn,e.args,e.implicit,e.isPercentage)}toHTML(e){var t=e&&e.parenthesis?e.parenthesis:"keep",n=e&&e.implicit?e.implicit:"hide",a=this.args,i=r(this,t,n,a,!1);if(1===a.length){var s=X7(this,t),o=a[0].toHTML(e);return i[0]&&(o='('+o+')'),"right"===s?''+FW(this.op)+""+o:o+''+FW(this.op)+""}if(2===a.length){var u=a[0].toHTML(e),l=a[1].toHTML(e);return i[0]&&(u='('+u+')'),i[1]&&(l='('+l+')'),this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===n?u+''+l:u+''+FW(this.op)+""+l}var c=a.map((function(t,n){return t=t.toHTML(e),i[n]&&(t='('+t+')'),t}));return a.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())?this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===n?c.join(''):c.join(''+FW(this.op)+""):''+FW(this.fn)+'('+c.join(',')+')'}_toTex(e){var t=e&&e.parenthesis?e.parenthesis:"keep",n=e&&e.implicit?e.implicit:"hide",a=this.args,i=r(this,t,n,a,!0),s=n9[this.fn];if(s=void 0===s?this.op:s,1===a.length){var o=X7(this,t),u=a[0].toTex(e);return i[0]&&(u="\\left(".concat(u,"\\right)")),"right"===o?s+u:u+s}if(2===a.length){var l=a[0],c=l.toTex(e);i[0]&&(c="\\left(".concat(c,"\\right)"));var p,d=a[1].toTex(e);switch(i[1]&&(d="\\left(".concat(d,"\\right)")),p="keep"===t?l.getIdentifier():l.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return s+"{"+c+"}{"+d+"}";case"OperatorNode:pow":switch(c="{"+c+"}",d="{"+d+"}",p){case"ConditionalNode":case"OperatorNode:divide":c="\\left(".concat(c,"\\right)")}break;case"OperatorNode:multiply":if(this.implicit&&"hide"===n)return c+"~"+d}return c+s+d}if(a.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var h=a.map((function(t,n){return t=t.toTex(e),i[n]&&(t="\\left(".concat(t,"\\right)")),t}));return"OperatorNode:multiply"===this.getIdentifier()&&this.implicit&&"hide"===n?h.join("~"):h.join(s)}return"\\mathrm{"+this.fn+"}\\left("+a.map((function(t){return t.toTex(e)})).join(",")+"\\right)"}getIdentifier(){return this.type+":"+this.fn}}return h2(a,"name",o9),a}),{isClass:!0,isNode:!0}),l9="ParenthesisNode",c9=_U(l9,["Node"],(e=>{var{Node:t}=e;class n extends t{constructor(e){if(super(),!mH(e))throw new TypeError('Node expected for parameter "content"');this.content=e}get type(){return l9}get isParenthesisNode(){return!0}_compile(e,t){return this.content._compile(e,t)}getContent(){return this.content.getContent()}forEach(e){e(this.content,"content",this)}map(e){var t=e(this.content,"content",this);return new n(t)}clone(){return new n(this.content)}_toString(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"("+this.content.toString(e)+")":this.content.toString(e)}toJSON(){return{mathjs:l9,content:this.content}}static fromJSON(e){return new n(e.content)}toHTML(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?'('+this.content.toHTML(e)+')':this.content.toHTML(e)}_toTex(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"\\left(".concat(this.content.toTex(e),"\\right)"):this.content.toTex(e)}}return h2(n,"name",l9),n}),{isClass:!0,isNode:!0}),p9="RelationalNode",d9=_U(p9,["Node"],(e=>{var{Node:t}=e,n={equal:"==",unequal:"!=",smaller:"<",larger:">",smallerEq:"<=",largerEq:">="};class r extends t{constructor(e,t){if(super(),!Array.isArray(e))throw new TypeError("Parameter conditionals must be an array");if(!Array.isArray(t))throw new TypeError("Parameter params must be an array");if(e.length!==t.length-1)throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");this.conditionals=e,this.params=t}get type(){return p9}get isRelationalNode(){return!0}_compile(e,t){var n=this,r=this.params.map((n=>n._compile(e,t)));return function(t,a,i){for(var s,o=r[0](t,a,i),u=0;ue(t,"params["+n+"]",this)),this)}map(e){return new r(this.conditionals.slice(),this.params.map(((t,n)=>this._ifNode(e(t,"params["+n+"]",this))),this))}clone(){return new r(this.conditionals,this.params)}_toString(e){for(var t=e&&e.parenthesis?e.parenthesis:"keep",r=J7(this,t,e&&e.implicit),a=this.params.map((function(n,a){var i=J7(n,t,e&&e.implicit);return"all"===t||null!==i&&i<=r?"("+n.toString(e)+")":n.toString(e)})),i=a[0],s=0;s('+n.toHTML(e)+')':n.toHTML(e)})),i=a[0],s=0;s'+FW(n[this.conditionals[s]])+""+a[s+1];return i}_toTex(e){for(var t=e&&e.parenthesis?e.parenthesis:"keep",n=J7(this,t,e&&e.implicit),r=this.params.map((function(r,a){var i=J7(r,t,e&&e.implicit);return"all"===t||null!==i&&i<=n?"\\left("+r.toTex(e)+"\right)":r.toTex(e)})),a=r[0],i=0;i{var{Node:t}=e;class n extends t{constructor(e){if(super(),this.items=e||[],!Array.isArray(this.items)||!this.items.every(mH))throw new TypeError("Array containing Nodes expected")}get type(){return h9}get isArrayNode(){return!0}_compile(e,t){var n=QW(this.items,(function(n){return n._compile(e,t)}));if("Array"!==e.config.matrix){var r=e.matrix;return function(e,t,a){return r(QW(n,(function(n){return n(e,t,a)})))}}return function(e,t,r){return QW(n,(function(n){return n(e,t,r)}))}}forEach(e){for(var t=0;t['+this.items.map((function(t){return t.toHTML(e)})).join(',')+']'}_toTex(e){return function t(n,r){var a=n.some(sH)&&!n.every(sH),i=r||a,s=i?"&":"\\\\",o=n.map((function(n){return n.items?t(n.items,!r):n.toTex(e)})).join(s);return a||!i||i&&!r?"\\begin{bmatrix}"+o+"\\end{bmatrix}":o}(this.items,!1)}}return h2(n,"name",h9),n}),{isClass:!0,isNode:!0}),m9="BlockNode",g9=_U(m9,["ResultSet","Node"],(e=>{var{ResultSet:t,Node:n}=e;class r extends n{constructor(e){if(super(),!Array.isArray(e))throw new Error("Array expected");this.blocks=e.map((function(e){var t=e&&e.node,n=!e||void 0===e.visible||e.visible;if(!mH(t))throw new TypeError('Property "node" must be a Node');if("boolean"!=typeof n)throw new TypeError('Property "visible" must be a boolean');return{node:t,visible:n}}))}get type(){return m9}get isBlockNode(){return!0}_compile(e,n){var r=QW(this.blocks,(function(t){return{evaluate:t.node._compile(e,n),visible:t.visible}}));return function(e,n,a){var i=[];return eV(r,(function(t){var r=t.evaluate(e,n,a);t.visible&&i.push(r)})),new t(i)}}forEach(e){for(var t=0;t;')})).join('
')}_toTex(e){return this.blocks.map((function(t){return t.node.toTex(e)+(t.visible?"":";")})).join("\\;\\;\n")}}return h2(r,"name",m9),r}),{isClass:!0,isNode:!0}),y9="ConditionalNode",b9=_U(y9,["Node"],(e=>{var{Node:t}=e;class n extends t{constructor(e,t,n){if(super(),!mH(e))throw new TypeError("Parameter condition must be a Node");if(!mH(t))throw new TypeError("Parameter trueExpr must be a Node");if(!mH(n))throw new TypeError("Parameter falseExpr must be a Node");this.condition=e,this.trueExpr=t,this.falseExpr=n}get type(){return y9}get isConditionalNode(){return!0}_compile(e,t){var n=this.condition._compile(e,t),r=this.trueExpr._compile(e,t),a=this.falseExpr._compile(e,t);return function(e,t,i){return function(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e)return!!e;if(e){if(YP(e))return!e.isZero();if(BP(e))return!(!e.re&&!e.im);if(PP(e))return!!e.value}if(null==e)return!1;throw new TypeError('Unsupported type of condition "'+wH(e)+'"')}(n(e,t,i))?r(e,t,i):a(e,t,i)}}forEach(e){e(this.condition,"condition",this),e(this.trueExpr,"trueExpr",this),e(this.falseExpr,"falseExpr",this)}map(e){return new n(this._ifNode(e(this.condition,"condition",this)),this._ifNode(e(this.trueExpr,"trueExpr",this)),this._ifNode(e(this.falseExpr,"falseExpr",this)))}clone(){return new n(this.condition,this.trueExpr,this.falseExpr)}_toString(e){var t=e&&e.parenthesis?e.parenthesis:"keep",n=J7(this,t,e&&e.implicit),r=this.condition.toString(e),a=J7(this.condition,t,e&&e.implicit);("all"===t||"OperatorNode"===this.condition.type||null!==a&&a<=n)&&(r="("+r+")");var i=this.trueExpr.toString(e),s=J7(this.trueExpr,t,e&&e.implicit);("all"===t||"OperatorNode"===this.trueExpr.type||null!==s&&s<=n)&&(i="("+i+")");var o=this.falseExpr.toString(e),u=J7(this.falseExpr,t,e&&e.implicit);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==u&&u<=n)&&(o="("+o+")"),r+" ? "+i+" : "+o}toJSON(){return{mathjs:y9,condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}}static fromJSON(e){return new n(e.condition,e.trueExpr,e.falseExpr)}toHTML(e){var t=e&&e.parenthesis?e.parenthesis:"keep",n=J7(this,t,e&&e.implicit),r=this.condition.toHTML(e),a=J7(this.condition,t,e&&e.implicit);("all"===t||"OperatorNode"===this.condition.type||null!==a&&a<=n)&&(r='('+r+')');var i=this.trueExpr.toHTML(e),s=J7(this.trueExpr,t,e&&e.implicit);("all"===t||"OperatorNode"===this.trueExpr.type||null!==s&&s<=n)&&(i='('+i+')');var o=this.falseExpr.toHTML(e),u=J7(this.falseExpr,t,e&&e.implicit);return("all"===t||"OperatorNode"===this.falseExpr.type||null!==u&&u<=n)&&(o='('+o+')'),r+'?'+i+':'+o}_toTex(e){return"\\begin{cases} {"+this.trueExpr.toTex(e)+"}, &\\quad{\\text{if }\\;"+this.condition.toTex(e)+"}\\\\{"+this.falseExpr.toTex(e)+"}, &\\quad{\\text{otherwise}}\\end{cases}"}}return h2(n,"name",y9),n}),{isClass:!0,isNode:!0}),v9="ConstantNode",x9=_U(v9,["Node"],(e=>{var{Node:t}=e;class n extends t{constructor(e){super(),this.value=e}get type(){return v9}get isConstantNode(){return!0}_compile(e,t){var n=this.value;return function(){return n}}forEach(e){}map(e){return this.clone()}clone(){return new n(this.value)}_toString(e){return IW(this.value,e)}toHTML(e){var t=this._toString(e);switch(wH(this.value)){case"number":case"BigNumber":case"Fraction":return''+t+"";case"string":return''+t+"";case"boolean":return''+t+"";case"null":return''+t+"";case"undefined":return''+t+"";default:return''+t+""}}toJSON(){return{mathjs:v9,value:this.value}}static fromJSON(e){return new n(e.value)}_toTex(e){var t=this._toString(e);switch(wH(this.value)){case"string":return"\\mathtt{"+i9(t)+"}";case"number":case"BigNumber":if(!isFinite(this.value))return this.value.valueOf()<0?"-\\infty":"\\infty";var n=t.toLowerCase().indexOf("e");return-1!==n?t.substring(0,n)+"\\cdot10^{"+t.substring(n+1)+"}":t;case"Fraction":return this.value.toLatex();default:return t}}}return h2(n,"name",v9),n}),{isClass:!0,isNode:!0}),_9="RangeNode",w9=_U(_9,["Node"],(e=>{var{Node:t}=e;function n(e,t,n){var r=J7(e,t,n),a={},i=J7(e.start,t,n);if(a.start=null!==i&&i<=r||"all"===t,e.step){var s=J7(e.step,t,n);a.step=null!==s&&s<=r||"all"===t}var o=J7(e.end,t,n);return a.end=null!==o&&o<=r||"all"===t,a}class r extends t{constructor(e,t,n){if(super(),!mH(e))throw new TypeError("Node expected");if(!mH(t))throw new TypeError("Node expected");if(n&&!mH(n))throw new TypeError("Node expected");if(arguments.length>3)throw new Error("Too many arguments");this.start=e,this.end=t,this.step=n||null}get type(){return _9}get isRangeNode(){return!0}needsEnd(){return this.filter((function(e){return xH(e)&&"end"===e.name})).length>0}_compile(e,t){var n=e.range,r=this.start._compile(e,t),a=this.end._compile(e,t);if(this.step){var i=this.step._compile(e,t);return function(e,t,s){return n(r(e,t,s),a(e,t,s),i(e,t,s))}}return function(e,t,i){return n(r(e,t,i),a(e,t,i))}}forEach(e){e(this.start,"start",this),e(this.end,"end",this),this.step&&e(this.step,"step",this)}map(e){return new r(this._ifNode(e(this.start,"start",this)),this._ifNode(e(this.end,"end",this)),this.step&&this._ifNode(e(this.step,"step",this)))}clone(){return new r(this.start,this.end,this.step&&this.step)}_toString(e){var t,r=n(this,e&&e.parenthesis?e.parenthesis:"keep",e&&e.implicit),a=this.start.toString(e);if(r.start&&(a="("+a+")"),t=a,this.step){var i=this.step.toString(e);r.step&&(i="("+i+")"),t+=":"+i}var s=this.end.toString(e);return r.end&&(s="("+s+")"),t+":"+s}toJSON(){return{mathjs:_9,start:this.start,end:this.end,step:this.step}}static fromJSON(e){return new r(e.start,e.end,e.step)}toHTML(e){var t,r=n(this,e&&e.parenthesis?e.parenthesis:"keep",e&&e.implicit),a=this.start.toHTML(e);if(r.start&&(a='('+a+')'),t=a,this.step){var i=this.step.toHTML(e);r.step&&(i='('+i+')'),t+=':'+i}var s=this.end.toHTML(e);return r.end&&(s='('+s+')'),t+':'+s}_toTex(e){var t=n(this,e&&e.parenthesis?e.parenthesis:"keep",e&&e.implicit),r=this.start.toTex(e);if(t.start&&(r="\\left(".concat(r,"\\right)")),this.step){var a=this.step.toTex(e);t.step&&(a="\\left(".concat(a,"\\right)")),r+=":"+a}var i=this.end.toTex(e);return t.end&&(i="\\left(".concat(i,"\\right)")),r+":"+i}}return h2(r,"name",_9),r}),{isClass:!0,isNode:!0}),D9=_U("reviver",["classes"],(e=>{var{classes:t}=e;return function(e,n){var r=t[n&&n.mathjs];return r&&"function"==typeof r.fromJSON?r.fromJSON(n):n}})),N9=_U("Chain",["?on","math","typed"],(e=>{var{on:t,math:n,typed:r}=e;function a(e){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");_H(e)?this.value=e.value:this.value=e}function i(e,t){EH(a.prototype,e,(function(){var e=t();if("function"==typeof e)return s(e)}))}function s(e){return function(){if(0===arguments.length)return new a(e(this.value));for(var t=[this.value],n=0;ne[t]))};for(var r in e)n(r)}var u,l};var o={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return a.createProxy(n),t&&t("import",(function(e,t,n){n||i(e,t)})),a}),{isClass:!0}),M9="FunctionAssignmentNode",S9=_U(M9,["typed","Node"],(e=>{var{typed:t,Node:n}=e;function r(e,t,n){var r=J7(e,t,n),a=J7(e.expr,t,n);return"all"===t||null!==a&&a<=r}class a extends n{constructor(e,t,n){if(super(),"string"!=typeof e)throw new TypeError('String expected for parameter "name"');if(!Array.isArray(t))throw new TypeError('Array containing strings or objects expected for parameter "params"');if(!mH(n))throw new TypeError('Node expected for parameter "expr"');if(U7.has(e))throw new Error('Illegal function name, "'+e+'" is a reserved keyword');this.name=e,this.params=t.map((function(e){return e&&e.name||e})),this.types=t.map((function(e){return e&&e.type||"any"})),this.expr=n}get type(){return M9}get isFunctionAssignmentNode(){return!0}_compile(e,n){var r=Object.create(n);eV(this.params,(function(e){r[e]=!0}));var a=this.expr._compile(e,r),i=this.name,s=this.params,o=rV(this.types,","),u=i+"("+rV(this.params,", ")+")";return function(e,n,r){var l={};l[o]=function(){for(var t=Object.create(n),i=0;i'+FW(this.params[a])+"");var i=this.expr.toHTML(e);return r(this,t,e&&e.implicit)&&(i='('+i+')'),''+FW(this.name)+'('+n.join(',')+')='+i}_toTex(e){var t=e&&e.parenthesis?e.parenthesis:"keep",n=this.expr.toTex(e);return r(this,t,e&&e.implicit)&&(n="\\left(".concat(n,"\\right)")),"\\mathrm{"+this.name+"}\\left("+this.params.map(s9).join(",")+"\\right):="+n}}return h2(a,"name",M9),a}),{isClass:!0,isNode:!0}),k9="chain",T9=_U(k9,["typed","Chain"],(e=>{var{typed:t,Chain:n}=e;return t(k9,{"":function(){return new n},any:function(e){return new n(e)}})}));function C9(e){return e&&e.isIndexError?new YW(e.index+1,e.min+1,void 0!==e.max?e.max+1:void 0):e}function E9(e){var{subset:t}=e;return function(e,n){try{if(Array.isArray(e))return t(e,n);if(e&&"function"==typeof e.subset)return e.subset(n);if("string"==typeof e)return t(e,n);if("object"==typeof e){if(!n.isObjectProperty())throw new TypeError("Cannot apply a numeric index as object property");return pV(e,n.getObjectProperty())}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw C9(e)}}}var A9="AccessorNode",I9=_U(A9,["subset","Node"],(e=>{var{subset:t,Node:n}=e,r=E9({subset:t});function a(e){return!(iH(e)||sH(e)||cH(e)||hH(e)||gH(e)||bH(e)||xH(e))}class i extends n{constructor(e,t){if(super(),!mH(e))throw new TypeError('Node expected for parameter "object"');if(!fH(t))throw new TypeError('IndexNode expected for parameter "index"');this.object=e,this.index=t}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}get type(){return A9}get isAccessorNode(){return!0}_compile(e,t){var n=this.object._compile(e,t),a=this.index._compile(e,t);if(this.index.isObjectProperty()){var i=this.index.getObjectProperty();return function(e,t,r){return pV(n(e,t,r),i)}}return function(e,t,i){var s=n(e,t,i),o=a(e,t,s);return r(s,o)}}forEach(e){e(this.object,"object",this),e(this.index,"index",this)}map(e){return new i(this._ifNode(e(this.object,"object",this)),this._ifNode(e(this.index,"index",this)))}clone(){return new i(this.object,this.index)}_toString(e){var t=this.object.toString(e);return a(this.object)&&(t="("+t+")"),t+this.index.toString(e)}toHTML(e){var t=this.object.toHTML(e);return a(this.object)&&(t='('+t+')'),t+this.index.toHTML(e)}_toTex(e){var t=this.object.toTex(e);return a(this.object)&&(t="\\left(' + object + '\\right)"),t+this.index.toTex(e)}toJSON(){return{mathjs:A9,object:this.object,index:this.index}}static fromJSON(e){return new i(e.object,e.index)}}return h2(i,"name",A9),i}),{isClass:!0,isNode:!0}),L9="AssignmentNode",F9=_U(L9,["subset","?matrix","Node"],(e=>{var{subset:t,matrix:n,Node:r}=e,a=E9({subset:t}),i=function(e){var{subset:t,matrix:n}=e;return function(e,r,a){try{if(Array.isArray(e))return n(e).subset(r,a).valueOf();if(e&&"function"==typeof e.subset)return e.subset(r,a);if("string"==typeof e)return t(e,r,a);if("object"==typeof e){if(!r.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return dV(e,r.getObjectProperty(),a),e}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw C9(e)}}}({subset:t,matrix:n});function s(e,t,n){t||(t="keep");var r=J7(e,t,n),a=J7(e.value,t,n);return"all"===t||null!==a&&a<=r}class o extends r{constructor(e,t,n){if(super(),this.object=e,this.index=n?t:null,this.value=n||t,!xH(e)&&!iH(e))throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(xH(e)&&"end"===e.name)throw new Error('Cannot assign to symbol "end"');if(this.index&&!fH(this.index))throw new TypeError('IndexNode expected as "index"');if(!mH(this.value))throw new TypeError('Node expected as "value"')}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():"":this.object.name||""}get type(){return L9}get isAssignmentNode(){return!0}_compile(e,t){var n=this.object._compile(e,t),r=this.index?this.index._compile(e,t):null,s=this.value._compile(e,t),o=this.object.name;if(this.index){if(this.index.isObjectProperty()){var u=this.index.getObjectProperty();return function(e,t,r){var a=n(e,t,r),i=s(e,t,r);return dV(a,u,i),i}}if(xH(this.object))return function(e,t,a){var u=n(e,t,a),l=s(e,t,a),c=r(e,t,u);return e.set(o,i(u,c,l)),l};var l=this.object.object._compile(e,t);if(this.object.index.isObjectProperty()){var c=this.object.index.getObjectProperty();return function(e,t,n){var a=l(e,t,n),o=pV(a,c),u=r(e,t,o),p=s(e,t,n);return dV(a,c,i(o,u,p)),p}}var p=this.object.index._compile(e,t);return function(e,t,n){var o=l(e,t,n),u=p(e,t,o),c=a(o,u),d=r(e,t,c),h=s(e,t,n);return i(o,u,i(c,d,h)),h}}if(!xH(this.object))throw new TypeError("SymbolNode expected as object");return function(e,t,n){var r=s(e,t,n);return e.set(o,r),r}}forEach(e){e(this.object,"object",this),this.index&&e(this.index,"index",this),e(this.value,"value",this)}map(e){var t=this._ifNode(e(this.object,"object",this)),n=this.index?this._ifNode(e(this.index,"index",this)):null,r=this._ifNode(e(this.value,"value",this));return new o(t,n,r)}clone(){return new o(this.object,this.index,this.value)}_toString(e){var t=this.object.toString(e),n=this.index?this.index.toString(e):"",r=this.value.toString(e);return s(this,e&&e.parenthesis,e&&e.implicit)&&(r="("+r+")"),t+n+" = "+r}toJSON(){return{mathjs:L9,object:this.object,index:this.index,value:this.value}}static fromJSON(e){return new o(e.object,e.index,e.value)}toHTML(e){var t=this.object.toHTML(e),n=this.index?this.index.toHTML(e):"",r=this.value.toHTML(e);return s(this,e&&e.parenthesis,e&&e.implicit)&&(r='('+r+')'),t+n+'='+r}_toTex(e){var t=this.object.toTex(e),n=this.index?this.index.toTex(e):"",r=this.value.toTex(e);return s(this,e&&e.parenthesis,e&&e.implicit)&&(r="\\left(".concat(r,"\\right)")),t+n+":="+r}}return h2(o,"name",L9),o}),{isClass:!0,isNode:!0}),$9="IndexNode",O9=_U($9,["Node","size"],(e=>{var{Node:t,size:n}=e;class r extends t{constructor(e,t){if(super(),this.dimensions=e,this.dotNotation=t||!1,!Array.isArray(e)||!e.every(mH))throw new TypeError('Array containing Nodes expected for parameter "dimensions"');if(this.dotNotation&&!this.isObjectProperty())throw new Error("dotNotation only applicable for object properties")}get type(){return $9}get isIndexNode(){return!0}_compile(e,t){var r=QW(this.dimensions,(function(r,a){if(r.filter((e=>e.isSymbolNode&&"end"===e.name)).length>0){var i=Object.create(t);i.end=!0;var s=r._compile(e,i);return function(e,t,r){if(!UP(r)&&!jP(r)&&!HP(r))throw new TypeError('Cannot resolve "end": context must be a Matrix, Array, or string but is '+wH(r));var i=n(r).valueOf(),o=Object.create(t);return o.end=i[a],s(e,o,r)}}return r._compile(e,t)})),a=pV(e,"index");return function(e,t,n){var i=QW(r,(function(r){return r(e,t,n)}));return a(...i)}}forEach(e){for(var t=0;t.'+FW(this.getObjectProperty())+"":'['+t.join(',')+']'}_toTex(e){var t=this.dimensions.map((function(t){return t.toTex(e)}));return this.dotNotation?"."+this.getObjectProperty():"_{"+t.join(",")+"}"}}return h2(r,"name",$9),r}),{isClass:!0,isNode:!0}),R9=_U("SymbolNode",["math","?Unit","Node"],(e=>{var{math:t,Unit:n,Node:r}=e;function a(e){return!!n&&n.isValuelessUnit(e)}class i extends r{constructor(e){if(super(),"string"!=typeof e)throw new TypeError('String expected for parameter "name"');this.name=e}get type(){return"SymbolNode"}get isSymbolNode(){return!0}_compile(e,t){var r=this.name;if(!0===t[r])return function(e,t,n){return t[r]};if(r in e)return function(t,n,a){return t.has(r)?t.get(r):pV(e,r)};var s=a(r);return function(e,t,a){return e.has(r)?e.get(r):s?new n(null,r):i.onUndefinedSymbol(r)}}forEach(e){}map(e){return this.clone()}static onUndefinedSymbol(e){throw new Error("Undefined symbol "+e)}clone(){return new i(this.name)}_toString(e){return this.name}toHTML(e){var t=FW(this.name);return"true"===t||"false"===t?''+t+"":"i"===t?''+t+"":"Infinity"===t?''+t+"":"NaN"===t?''+t+"":"null"===t?''+t+"":"undefined"===t?''+t+"":''+t+""}toJSON(){return{mathjs:"SymbolNode",name:this.name}}static fromJSON(e){return new i(e.name)}_toTex(e){var n=!1;void 0===t[this.name]&&a(this.name)&&(n=!0);var r=s9(this.name,n);return"\\"===r[0]?r:" "+r}}return i}),{isClass:!0,isNode:!0});function Y9(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r{var{math:t,Node:n,SymbolNode:r}=e,a=e=>IW(e,{truncate:78});function i(e,t,n){for(var r,a="",i=/\$(?:\{([a-z_][a-z_0-9]*)(?:\[([0-9]+)\])?\}|\$)/gi,s=0;null!==(r=i.exec(e));)if(a+=e.substring(s,r.index),s=r.index,"$$"===r[0])a+="$",s++;else{s+=r[0].length;var o=t[r[1]];if(!o)throw new ReferenceError("Template: Property "+r[1]+" does not exist.");if(void 0===r[2])switch(typeof o){case"string":a+=o;break;case"object":if(mH(o))a+=o.toTex(n);else{if(!Array.isArray(o))throw new TypeError("Template: "+r[1]+" has to be a Node, String or array of Nodes");a+=o.map((function(e,t){if(mH(e))return e.toTex(n);throw new TypeError("Template: "+r[1]+"["+t+"] is not a Node.")})).join(",")}break;default:throw new TypeError("Template: "+r[1]+" has to be a Node, String or array of Nodes")}else{if(!mH(o[r[2]]&&o[r[2]]))throw new TypeError("Template: "+r[1]+"["+r[2]+"] is not a Node.");a+=o[r[2]].toTex(n)}}return a+e.slice(s)}class s extends n{constructor(e,t){if(super(),"string"==typeof e&&(e=new r(e)),!mH(e))throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(t)||!t.every(mH))throw new TypeError('Array containing Nodes expected for parameter "args"');this.fn=e,this.args=t||[]}get name(){return this.fn.name||""}get type(){return B9}get isFunctionNode(){return!0}_compile(e,t){var n=this.args.map((n=>n._compile(e,t)));if(!xH(this.fn)){if(iH(this.fn)&&fH(this.fn.index)&&this.fn.index.isObjectProperty()){var r=this.fn.object._compile(e,t),i=this.fn.index.getObjectProperty(),o=this.args;return function(t,a,s){var u=r(t,a,s);if(function(e,t){if(!fV(e,t))throw new Error('No access to method "'+t+'"')}(u,i),u[i]&&u[i].rawArgs)return u[i](o,e,Y9(t,a),t);var l=n.map((e=>e(t,a,s)));return u[i].apply(u,l)}}var u=this.fn.toString(),l=this.fn._compile(e,t),c=this.args;return function(t,r,i){var s=l(t,r,i);if("function"!=typeof s)throw new TypeError("Expression '".concat(u,"' did not evaluate to a function; value is:")+"\n ".concat(a(s)));if(s.rawArgs)return s(c,e,Y9(t,r),t);var o=n.map((e=>e(t,r,i)));return s.apply(s,o)}}var p=this.fn.name;if(t[p]){var d=this.args;return function(t,r,i){var s=r[p];if("function"!=typeof s)throw new TypeError("Argument '".concat(p,"' was not a function; received: ").concat(a(s)));if(s.rawArgs)return s(d,e,Y9(t,r),t);var o=n.map((e=>e(t,r,i)));return s.apply(s,o)}}var h=p in e?pV(e,p):void 0,f="function"==typeof h&&!0===h.rawArgs,m=t=>{var n;if(t.has(p))n=t.get(p);else{if(!(p in e))return s.onUndefinedFunction(p);n=pV(e,p)}if("function"==typeof n)return n;throw new TypeError("'".concat(p,"' is not a function; its value is:\n ").concat(a(n)))};if(f){var g=this.args;return function(t,n,r){return m(t)(g,e,Y9(t,n),t)}}switch(n.length){case 0:return function(e,t,n){return m(e)()};case 1:return function(e,t,r){return m(e)((0,n[0])(e,t,r))};case 2:return function(e,t,r){var a=m(e),i=n[0],s=n[1];return a(i(e,t,r),s(e,t,r))};default:return function(e,t,r){return m(e)(...n.map((n=>n(e,t,r))))}}}forEach(e){e(this.fn,"fn",this);for(var t=0;t'+FW(this.fn)+'('+t.join(',')+')'}toTex(e){var t;return e&&"object"==typeof e.handler&&AH(e.handler,this.name)&&(t=e.handler[this.name](this,e)),void 0!==t?t:super.toTex(e)}_toTex(e){var n,r,a=this.args.map((function(t){return t.toTex(e)}));switch(r9[this.name]&&(n=r9[this.name]),!t[this.name]||"function"!=typeof t[this.name].toTex&&"object"!=typeof t[this.name].toTex&&"string"!=typeof t[this.name].toTex||(n=t[this.name].toTex),typeof n){case"function":r=n(this,e);break;case"string":r=i(n,this,e);break;case"object":switch(typeof n[a.length]){case"function":r=n[a.length](this,e);break;case"string":r=i(n[a.length],this,e)}}return void 0!==r?r:i("\\mathrm{${name}}\\left(${args}\\right)",this,e)}getIdentifier(){return this.type+":"+this.name}}return h2(s,"name",B9),h2(s,"onUndefinedFunction",(function(e){throw new Error("Undefined function "+e)})),h2(s,"fromJSON",(function(e){return new s(e.fn,e.args)})),s}),{isClass:!0,isNode:!0}),P9="parse",H9=_U(P9,["typed","numeric","config","AccessorNode","ArrayNode","AssignmentNode","BlockNode","ConditionalNode","ConstantNode","FunctionAssignmentNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","RangeNode","RelationalNode","SymbolNode"],(e=>{var{typed:t,numeric:n,config:r,AccessorNode:a,ArrayNode:i,AssignmentNode:s,BlockNode:o,ConditionalNode:u,ConstantNode:l,FunctionAssignmentNode:c,FunctionNode:p,IndexNode:d,ObjectNode:h,OperatorNode:f,ParenthesisNode:m,RangeNode:g,RelationalNode:y,SymbolNode:b}=e,v=t(P9,{string:function(e){return F(e,{})},"Array | Matrix":function(e){return x(e,{})},"string, Object":function(e,t){return F(e,void 0!==t.nodes?t.nodes:{})},"Array | Matrix, Object":x});function x(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=void 0!==t.nodes?t.nodes:{};return AV(e,(function(e){if("string"!=typeof e)throw new TypeError("String expected");return F(e,n)}))}var _={",":!0,"(":!0,")":!0,"[":!0,"]":!0,"{":!0,"}":!0,'"':!0,"'":!0,";":!0,"+":!0,"-":!0,"*":!0,".*":!0,"/":!0,"./":!0,"%":!0,"^":!0,".^":!0,"~":!0,"!":!0,"&":!0,"|":!0,"^|":!0,"=":!0,":":!0,"?":!0,"==":!0,"!=":!0,"<":!0,">":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},w={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},D={true:!0,false:!1,null:null,undefined:void 0},N=["NaN","Infinity"];function M(e,t){return e.expression.substr(e.index,t)}function S(e){return M(e,1)}function k(e){e.index++}function T(e){return e.expression.charAt(e.index-1)}function C(e){return e.expression.charAt(e.index+1)}function E(e){for(e.tokenType=0,e.token="",e.comment="";;){if("#"===S(e))for(;"\n"!==S(e)&&""!==S(e);)e.comment+=S(e),k(e);if(!v.isWhitespace(S(e),e.nestingLevel))break;k(e)}if(""!==S(e)){if("\n"===S(e)&&!e.nestingLevel)return e.tokenType=1,e.token=S(e),void k(e);var t=S(e),n=M(e,2),r=M(e,3);if(3===r.length&&_[r])return e.tokenType=1,e.token=r,k(e),k(e),void k(e);if(2===n.length&&_[n])return e.tokenType=1,e.token=n,k(e),void k(e);if(_[t])return e.tokenType=1,e.token=t,void k(e);if(v.isDigitDot(t)){e.tokenType=2;var a=M(e,2);if("0b"===a||"0o"===a||"0x"===a){for(e.token+=S(e),k(e),e.token+=S(e),k(e);v.isHexDigit(S(e));)e.token+=S(e),k(e);if("."===S(e))for(e.token+=".",k(e);v.isHexDigit(S(e));)e.token+=S(e),k(e);else if("i"===S(e))for(e.token+="i",k(e);v.isDigit(S(e));)e.token+=S(e),k(e);return}if("."===S(e)){if(e.token+=S(e),k(e),!v.isDigit(S(e)))return void(e.tokenType=1)}else{for(;v.isDigit(S(e));)e.token+=S(e),k(e);v.isDecimalMark(S(e),C(e))&&(e.token+=S(e),k(e))}for(;v.isDigit(S(e));)e.token+=S(e),k(e);if("E"===S(e)||"e"===S(e))if(v.isDigit(C(e))||"-"===C(e)||"+"===C(e)){if(e.token+=S(e),k(e),"+"!==S(e)&&"-"!==S(e)||(e.token+=S(e),k(e)),!v.isDigit(S(e)))throw ne(e,'Digit expected, got "'+S(e)+'"');for(;v.isDigit(S(e));)e.token+=S(e),k(e);if(v.isDecimalMark(S(e),C(e)))throw ne(e,'Digit expected, got "'+S(e)+'"')}else if("."===C(e))throw k(e),ne(e,'Digit expected, got "'+S(e)+'"')}else{if(!v.isAlpha(S(e),T(e),C(e))){for(e.tokenType=4;""!==S(e);)e.token+=S(e),k(e);throw ne(e,'Syntax error in part "'+e.token+'"')}for(;v.isAlpha(S(e),T(e),C(e))||v.isDigit(S(e));)e.token+=S(e),k(e);AH(w,e.token)?e.tokenType=1:e.tokenType=3}}else e.tokenType=1}function A(e){do{E(e)}while("\n"===e.token)}function I(e){e.nestingLevel++}function L(e){e.nestingLevel--}function F(e,t){var n={extraNodes:{},expression:"",comment:"",index:0,token:"",tokenType:0,nestingLevel:0,conditionalLevel:null};$P(n,{expression:e,extraNodes:t}),E(n);var r=function(e){var t,n,r=[];for(""!==e.token&&"\n"!==e.token&&";"!==e.token&&(t=$(e),e.comment&&(t.comment=e.comment));"\n"===e.token||";"===e.token;)0===r.length&&t&&(n=";"!==e.token,r.push({node:t,visible:n})),E(e),"\n"!==e.token&&";"!==e.token&&""!==e.token&&(t=$(e),e.comment&&(t.comment=e.comment),n=";"!==e.token,r.push({node:t,visible:n}));return r.length>0?new o(r):(t||(t=new l(void 0),e.comment&&(t.comment=e.comment)),t)}(n);if(""!==n.token)throw 1===n.tokenType?re(n,"Unexpected operator "+n.token):ne(n,'Unexpected part "'+n.token+'"');return r}function $(e){var t,n,r,a,i=function(e){for(var t=function(e){for(var t=O(e);"or"===e.token;)A(e),t=new f("or","or",[t,O(e)]);return t}(e);"?"===e.token;){var n=e.conditionalLevel;e.conditionalLevel=e.nestingLevel,A(e);var r=t,a=$(e);if(":"!==e.token)throw ne(e,"False part of conditional expression expected");e.conditionalLevel=null,A(e);var i=$(e);t=new u(r,a,i),e.conditionalLevel=n}return t}(e);if("="===e.token){if(xH(i))return t=i.name,A(e),r=$(e),new s(new b(t),r);if(iH(i))return A(e),r=$(e),new s(i.object,i.index,r);if(hH(i)&&xH(i.fn)&&(a=!0,n=[],t=i.name,i.args.forEach((function(e,t){xH(e)?n[t]=e.name:a=!1})),a))return A(e),r=$(e),new c(t,n,r);throw ne(e,"Invalid left hand side of assignment operator =")}return i}function O(e){for(var t=R(e);"xor"===e.token;)A(e),t=new f("xor","xor",[t,R(e)]);return t}function R(e){for(var t=Y(e);"and"===e.token;)A(e),t=new f("and","and",[t,Y(e)]);return t}function Y(e){for(var t=B(e);"|"===e.token;)A(e),t=new f("|","bitOr",[t,B(e)]);return t}function B(e){for(var t=z(e);"^|"===e.token;)A(e),t=new f("^|","bitXor",[t,z(e)]);return t}function z(e){for(var t=P(e);"&"===e.token;)A(e),t=new f("&","bitAnd",[t,P(e)]);return t}function P(e){for(var t=[H(e)],n=[],r={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};AH(r,e.token);){var a={name:e.token,fn:r[e.token]};n.push(a),A(e),t.push(H(e))}return 1===t.length?t[0]:2===t.length?new f(n[0].name,n[0].fn,t):new y(n.map((e=>e.fn)),t)}function H(e){var t,n,r,a;t=j(e);for(var i={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};AH(i,e.token);)r=i[n=e.token],A(e),a=[t,j(e)],t=new f(n,r,a);return t}function j(e){var t,n,r,a;t=U(e);for(var i={to:"to",in:"to"};AH(i,e.token);)r=i[n=e.token],A(e),"in"===n&&""===e.token?t=new f("*","multiply",[t,new b("in")],!0):(a=[t,U(e)],t=new f(n,r,a));return t}function U(e){var t,n=[];if(t=":"===e.token?new l(1):q(e),":"===e.token&&e.conditionalLevel!==e.nestingLevel){for(n.push(t);":"===e.token&&n.length<3;)A(e),")"===e.token||"]"===e.token||","===e.token||""===e.token?n.push(new b("end")):n.push(q(e));t=3===n.length?new g(n[0],n[2],n[1]):new g(n[0],n[1])}return t}function q(e){var t,n,r,a;t=W(e);for(var i={"+":"add","-":"subtract"};AH(i,e.token);){r=i[n=e.token],A(e);var s=W(e);a=s.isPercentage?[t,new f("*","multiply",[t,s])]:[t,s],t=new f(n,r,a)}return t}function W(e){var t,n,r,a;n=t=V(e);for(var i={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide"};AH(i,e.token);)a=i[r=e.token],A(e),n=V(e),t=new f(r,a,[t,n]);return t}function V(e){var t,n;for(n=t=G(e);3===e.tokenType||"in"===e.token&&cH(t)||!(2!==e.tokenType||cH(n)||yH(n)&&"!"!==n.op)||"("===e.token;)n=G(e),t=new f("*","multiply",[t,n],!0);return t}function G(e){for(var t=K(e),n=t,r=[];"/"===e.token&&pH(n);){if(r.push($P({},e)),A(e),2!==e.tokenType){$P(e,r.pop());break}if(r.push($P({},e)),A(e),3!==e.tokenType&&"("!==e.token){r.pop(),$P(e,r.pop());break}$P(e,r.pop()),r.pop(),n=K(e),t=new f("/","divide",[t,n])}return t}function K(e){var t,n,r,a;t=J(e);for(var i={"%":"mod",mod:"mod"};AH(i,e.token);)r=i[n=e.token],A(e),"%"===n&&1===e.tokenType&&"("!==e.token?t=new f("/","divide",[t,new l(100)],!1,!0):(a=[t,J(e)],t=new f(n,r,a));return t}function J(e){var t,a,s,o={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"};return AH(o,e.token)?(s=o[e.token],t=e.token,A(e),a=[J(e)],new f(t,s,a)):function(e){var t,a,s,o;return t=function(e){var t,a,s;t=function(e){var t=[];if(3===e.tokenType&&AH(e.extraNodes,e.token)){var a=e.extraNodes[e.token];if(E(e),"("===e.token){if(t=[],I(e),E(e),")"!==e.token)for(t.push($(e));","===e.token;)E(e),t.push($(e));if(")"!==e.token)throw ne(e,"Parenthesis ) expected");L(e),E(e)}return new a(t)}return function(e){var t;return 3===e.tokenType||1===e.tokenType&&e.token in w?(t=e.token,E(e),X(e,AH(D,t)?new l(D[t]):-1!==N.indexOf(t)?new l(n(t,"number")):new b(t))):function(e){var t;return'"'===e.token?(t=Z(e),X(e,new l(t))):function(e){var t;return"'"===e.token?(t=Q(e),X(e,new l(t))):function(e){var t,a,s,o;if("["===e.token){if(I(e),E(e),"]"!==e.token){var u=ee(e);if(";"===e.token){for(s=1,a=[u];";"===e.token;)E(e),a[s]=ee(e),s++;if("]"!==e.token)throw ne(e,"End of matrix ] expected");L(e),E(e),o=a[0].items.length;for(var c=1;c0},v.isDecimalMark=function(e,t){return"."===e&&"/"!==t&&"*"!==t&&"^"!==t},v.isDigitDot=function(e){return e>="0"&&e<="9"||"."===e},v.isDigit=function(e){return e>="0"&&e<="9"},v.isHexDigit=function(e){return e>="0"&&e<="9"||e>="a"&&e<="f"||e>="A"&&e<="F"},t.addConversion({from:"string",to:"Node",convert:v}),v})),j9=_U("resolve",["typed","parse","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode"],(e=>{var{typed:t,parse:n,ConstantNode:r,FunctionNode:a,OperatorNode:i,ParenthesisNode:s}=e;function o(e,t){var u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Set;if(!t)return e;if(xH(e)){if(u.has(e.name)){var l=Array.from(u).join(", ");throw new ReferenceError("recursive loop of variable definitions among {".concat(l,"}"))}var c=t.get(e.name);if(mH(c)){var p=new Set(u);return p.add(e.name),o(c,t,p)}return"number"==typeof c?n(String(c)):void 0!==c?new r(c):e}if(yH(e)){var d=e.args.map((function(e){return o(e,t,u)}));return new i(e.op,e.fn,d,e.implicit)}if(bH(e))return new s(o(e.content,t,u));if(hH(e)){var h=e.args.map((function(e){return o(e,t,u)}));return new a(e.name,h)}return e.map((e=>o(e,t,u)))}return t("resolve",{Node:o,"Node, Map | null | undefined":o,"Node, Object":(e,t)=>o(e,xV(t)),"Array | Matrix":t.referToSelf((e=>t=>t.map((t=>e(t))))),"Array | Matrix, null | undefined":t.referToSelf((e=>t=>t.map((t=>e(t))))),"Array, Object":t.referTo("Array,Map",(e=>(t,n)=>e(t,xV(n)))),"Matrix, Object":t.referTo("Matrix,Map",(e=>(t,n)=>e(t,xV(n)))),"Array | Matrix, Map":t.referToSelf((e=>(t,n)=>t.map((t=>e(t,n)))))})}));function U9(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function q9(e){for(var t=1;t{var{FunctionNode:t,OperatorNode:n,SymbolNode:r}=e,a=!0,i=!1,s="defaultF",o={add:{trivial:a,total:a,commutative:a,associative:a},unaryPlus:{trivial:a,total:a,commutative:a,associative:a},subtract:{trivial:i,total:a,commutative:i,associative:i},multiply:{trivial:a,total:a,commutative:a,associative:a},divide:{trivial:i,total:a,commutative:i,associative:i},paren:{trivial:a,total:a,commutative:a,associative:i},defaultF:{trivial:i,total:a,commutative:i,associative:i}};function u(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o,r=s;if("string"==typeof e?r=e:yH(e)?r=e.fn.toString():hH(e)?r=e.name:bH(e)&&(r="paren"),AH(n,r)){var a=n[r];if(AH(a,t))return a[t];if(AH(o,r))return o[r][t]}if(AH(n,s)){var i=n.defaultF;return AH(i,t)?i[t]:o.defaultF[t]}if(AH(o,r)){var u=o[r];if(AH(u,t))return u[t]}return o.defaultF[t]}function l(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o;return u(e,"associative",t)}function c(e,t){var n,r=[];return l(e,t)?(n=e.op,function e(t){for(var a=0;a1&&void 0!==arguments[1]?arguments[1]:o;return u(e,"commutative",t)},isAssociative:l,mergeContext:function(e,t){var n=q9({},e);for(var r in t)AH(e,r)?n[r]=q9(q9({},t[r]),e[r]):n[r]=t[r];return n},flatten:function e(t,n){if(!t.args||0===t.args.length)return t;t.args=c(t,n);for(var r=0;r2&&l(t,n)){for(var s=t.args.pop();t.args.length>0;)s=r([t.args.pop(),s]);t.args=s.args}}},unflattenl:function e(t,n){if(t.args&&0!==t.args.length){for(var r=p(t),a=t.args.length,i=0;i2&&l(t,n)){for(var s=t.args.shift();t.args.length>0;)s=r([s,t.args.shift()]);t.args=s.args}}},defaultContext:o,realContext:{divide:{total:i},log:{total:i}},positiveContext:{subtract:{total:i},abs:{trivial:a},log:{total:a}}}})),V9=_U("simplifyConstant",["typed","parse","config","mathWithTransform","matrix","?fraction","?bignumber","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode"],(e=>{var{typed:t,parse:n,config:r,mathWithTransform:a,matrix:i,fraction:s,bignumber:o,AccessorNode:u,ArrayNode:l,ConstantNode:c,FunctionNode:p,IndexNode:d,ObjectNode:h,OperatorNode:f,SymbolNode:m}=e,{isCommutative:g,isAssociative:y,allChildren:b,createMakeNodeFunction:v}=W9({FunctionNode:p,OperatorNode:f,SymbolNode:m}),x=t("simplifyConstant",{Node:e=>N(C(e,{})),"Node, Object":function(e,t){return N(C(e,t))}});function _(e){return zP(e)?e.valueOf():e instanceof Array?e.map(_):UP(e)?i(_(e.valueOf())):e}function w(e,t,n){try{return a[e].apply(null,t)}catch(r){return t=t.map(_),S(a[e].apply(null,t),n)}}var D=t({Fraction:function(e){var t,n=e.s*e.n;return t=n<0?new f("-","unaryMinus",[new c(-n)]):new c(n),1===e.d?t:new f("/","divide",[t,new c(e.d)])},number:function(e){return e<0?k(new c(-e)):new c(e)},BigNumber:function(e){return e<0?k(new c(-e)):new c(e)},Complex:function(e){throw new Error("Cannot convert Complex number to Node")},string:function(e){return new c(e)},Matrix:function(e){return new l(e.valueOf().map((e=>D(e))))}});function N(e){return mH(e)?e:D(e)}function M(e,t){if(t&&!1!==t.exactFractions&&isFinite(e)&&s){var n=s(e),r=t&&"number"==typeof t.fractionsLimit?t.fractionsLimit:1/0;if(n.valueOf()===e&&n.nC(e,t)));if(!n.some(mH))try{return w(e.name,n,t)}catch(e){}if("size"===e.name&&1===n.length&&sH(n[0])){for(var r=[],s=n[0];sH(s);)r.push(s.items.length),s=s.items[0];return i(r)}return new p(e.name,n.map(N))}case"OperatorNode":var o,f,m=e.fn.toString(),_=v(e);if(yH(e)&&e.isUnary())f=mH((o=[C(e.args[0],t)])[0])?_(o):w(m,o,t);else if(y(e,t.context))if(o=(o=b(e,t.context)).map((e=>C(e,t))),g(m,t.context)){for(var D=[],M=[],k=0;k1?(f=T(m,D,_,t),M.unshift(f),f=T(m,M,_,t)):f=T(m,o,_,t)}else f=T(m,o,_,t);else o=e.args.map((e=>C(e,t))),f=T(m,o,_,t);return f;case"ParenthesisNode":return C(e.content,t);case"AccessorNode":return function(e,t,n){if(!fH(t))return new u(N(e),N(t));if(sH(e)||UP(e)){for(var r=Array.from(t.dimensions);r.length>0;)if(cH(r[0])&&"string"!=typeof r[0].value){var a=S(r.shift().value,n);sH(e)?e=e.items[a-1]:(e=e.valueOf()[a-1])instanceof Array&&(e=i(e))}else{if(!(r.length>1&&cH(r[1])&&"string"!=typeof r[1].value))break;var s=S(r[1].value,n),o=[],p=sH(e)?e.items:e.valueOf();for(var h of p)if(sH(h))o.push(h.items[s-1]);else{if(!UP(e))break;o.push(h[s-1])}if(o.length!==p.length)break;e=sH(e)?new l(o):i(o),r.splice(1,1)}return r.length===t.dimensions.length?new u(N(e),t):r.length>0?(t=new d(r),new u(N(e),t)):e}if(gH(e)&&1===t.dimensions.length&&cH(t.dimensions[0])){var f=t.dimensions[0].value;return f in e.properties?e.properties[f]:new c}return new u(N(e),t)}(C(e.object,t),C(e.index,t),t);case"ArrayNode":var E=e.items.map((e=>C(e,t)));return E.some(mH)?new l(E.map(N)):i(E);case"IndexNode":return new d(e.dimensions.map((e=>x(e,t))));case"ObjectNode":var A={};for(var I in e.properties)A[I]=x(e.properties[I],t);return new h(A);default:throw new Error("Unimplemented node type in simplifyConstant: ".concat(e.type))}}return x})),G9="compile",K9=_U(G9,["typed","parse"],(e=>{var{typed:t,parse:n}=e;return t(G9,{string:function(e){return n(e).compile()},"Array | Matrix":function(e){return AV(e,(function(e){return n(e).compile()}))}})})),J9=_U("Help",["parse"],(e=>{var{parse:t}=e;function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!e)throw new Error('Argument "doc" missing');this.doc=e}return n.prototype.type="Help",n.prototype.isHelp=!0,n.prototype.toString=function(){var e=this.doc||{},n="\n";if(e.name&&(n+="Name: "+e.name+"\n\n"),e.category&&(n+="Category: "+e.category+"\n\n"),e.description&&(n+="Description:\n "+e.description+"\n\n"),e.syntax&&(n+="Syntax:\n "+e.syntax.join("\n ")+"\n\n"),e.examples){n+="Examples:\n";for(var r={},a=0;a"mathjs"!==e)).forEach((n=>{t[n]=e[n]})),new n(t)},n.prototype.valueOf=n.prototype.toString,n}),{isClass:!0}),X9="leafCount",Z9=_U(X9,["parse","typed"],(e=>{var{parse:t,typed:n}=e;function r(e){var t=0;return e.forEach((e=>{t+=r(e)})),t||1}return n(X9,{Node:function(e){return r(e)}})})),Q9="simplifyCore",eee=_U(Q9,["typed","parse","equal","isZero","add","subtract","multiply","divide","pow","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{typed:t,parse:n,equal:r,isZero:a,add:i,subtract:s,multiply:o,divide:u,pow:l,AccessorNode:c,ArrayNode:p,ConstantNode:d,FunctionNode:h,IndexNode:f,ObjectNode:m,OperatorNode:g,ParenthesisNode:y,SymbolNode:b}=e,v=new d(0),x=new d(1),_=new d(!0),w=new d(!1);function D(e){return yH(e)&&["and","not","or"].includes(e.op)}var{hasProperty:N,isCommutative:M}=W9({FunctionNode:h,OperatorNode:g,SymbolNode:b});function S(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t?t.context:void 0;if(N(e,"trivial",n)){if(hH(e)&&1===e.args.length)return S(e.args[0],t);var i=!1,s=0;if(e.forEach((e=>{1==++s&&(i=S(e,t))})),1===s)return i}var o=e;if(hH(o)){var u=Q7(o.name);if(!u)return new h(S(o.fn),o.args.map((e=>S(e,t))));if(o.args.length>2&&N(o,"associative",n))for(;o.args.length>2;){var l=o.args.pop(),d=o.args.pop();o.args.push(new g(u,o.name,[l,d]))}o=new g(u,o.name,o.args)}if(yH(o)&&o.isUnary()){var y=S(o.args[0],t);if("~"===o.op&&yH(y)&&y.isUnary()&&"~"===y.op)return y.args[0];if("not"===o.op&&yH(y)&&y.isUnary()&&"not"===y.op&&D(y.args[0]))return y.args[0];var b=!0;if("-"===o.op&&yH(y)&&(y.isBinary()&&"subtract"===y.fn&&(o=new g("-","subtract",[y.args[1],y.args[0]]),b=!1),y.isUnary()&&"-"===y.op))return y.args[0];if(b)return new g(o.op,o.fn,[y])}if(yH(o)&&o.isBinary()){var k=S(o.args[0],t),T=S(o.args[1],t);if("+"===o.op){if(cH(k)&&a(k.value))return T;if(cH(T)&&a(T.value))return k;yH(T)&&T.isUnary()&&"-"===T.op&&(T=T.args[0],o=new g("-","subtract",[k,T]))}if("-"===o.op)return yH(T)&&T.isUnary()&&"-"===T.op?S(new g("+","add",[k,T.args[0]]),t):cH(k)&&a(k.value)?S(new g("-","unaryMinus",[T])):cH(T)&&a(T.value)?k:new g(o.op,o.fn,[k,T]);if("*"===o.op){if(cH(k)){if(a(k.value))return v;if(r(k.value,1))return T}if(cH(T)){if(a(T.value))return v;if(r(T.value,1))return k;if(M(o,n))return new g(o.op,o.fn,[T,k],o.implicit)}return new g(o.op,o.fn,[k,T],o.implicit)}if("/"===o.op)return cH(k)&&a(k.value)?v:cH(T)&&r(T.value,1)?k:new g(o.op,o.fn,[k,T]);if("^"===o.op&&cH(T)){if(a(T.value))return x;if(r(T.value,1))return k}if("and"===o.op){if(cH(k)){if(!k.value)return w;if(D(T))return T}if(cH(T)){if(!T.value)return w;if(D(k))return k}}if("or"===o.op){if(cH(k)){if(k.value)return _;if(D(T))return T}if(cH(T)){if(T.value)return _;if(D(k))return k}}return new g(o.op,o.fn,[k,T])}if(yH(o))return new g(o.op,o.fn,o.args.map((e=>S(e,t))));if(sH(o))return new p(o.items.map((e=>S(e,t))));if(iH(o))return new c(S(o.object,t),S(o.index,t));if(fH(o))return new f(o.dimensions.map((e=>S(e,t))));if(gH(o)){var C={};for(var E in o.properties)C[E]=S(o.properties[E],t);return new m(C)}return o}return t(Q9,{Node:S,"Node,Object":S})})),tee="evaluate",nee=_U(tee,["typed","parse"],(e=>{var{typed:t,parse:n}=e;return t(tee,{string:function(e){var t=vV();return n(e).compile().evaluate(t)},"string, Map | Object":function(e,t){return n(e).compile().evaluate(t)},"Array | Matrix":function(e){var t=vV();return AV(e,(function(e){return n(e).compile().evaluate(t)}))},"Array | Matrix, Map | Object":function(e,t){return AV(e,(function(e){return n(e).compile().evaluate(t)}))}})})),ree={name:"e",category:"Constants",syntax:["e"],description:"Euler's number, the base of the natural logarithm. Approximately equal to 2.71828",examples:["e","e ^ 2","exp(2)","log(e)"],seealso:["exp"]},aee={name:"pi",category:"Constants",syntax:["pi"],description:"The number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter, and is approximately equal to 3.14159",examples:["pi","sin(pi/2)"],seealso:["tau"]},iee={bignumber:{name:"bignumber",category:"Construction",syntax:["bignumber(x)"],description:"Create a big number from a number or string.",examples:["0.1 + 0.2","bignumber(0.1) + bignumber(0.2)",'bignumber("7.2")','bignumber("7.2e500")',"bignumber([0.1, 0.2, 0.3])"],seealso:["boolean","complex","fraction","index","matrix","string","unit"]},boolean:{name:"boolean",category:"Construction",syntax:["x","boolean(x)"],description:"Convert a string or number into a boolean.",examples:["boolean(0)","boolean(1)","boolean(3)",'boolean("true")','boolean("false")',"boolean([1, 0, 1, 1])"],seealso:["bignumber","complex","index","matrix","number","string","unit"]},complex:{name:"complex",category:"Construction",syntax:["complex()","complex(re, im)","complex(string)"],description:"Create a complex number.",examples:["complex()","complex(2, 3)",'complex("7 - 2i")'],seealso:["bignumber","boolean","index","matrix","number","string","unit"]},createUnit:{name:"createUnit",category:"Construction",syntax:["createUnit(definitions)","createUnit(name, definition)"],description:"Create a user-defined unit and register it with the Unit type.",examples:['createUnit("foo")','createUnit("knot", {definition: "0.514444444 m/s", aliases: ["knots", "kt", "kts"]})','createUnit("mph", "1 mile/hour")'],seealso:["unit","splitUnit"]},fraction:{name:"fraction",category:"Construction",syntax:["fraction(num)","fraction(matrix)","fraction(num,den)","fraction({n: num, d: den})"],description:"Create a fraction from a number or from integer numerator and denominator.",examples:["fraction(0.125)","fraction(1, 3) + fraction(2, 5)","fraction({n: 333, d: 53})","fraction([sqrt(9), sqrt(10), sqrt(11)])"],seealso:["bignumber","boolean","complex","index","matrix","string","unit"]},index:{name:"index",category:"Construction",syntax:["[start]","[start:end]","[start:step:end]","[start1, start 2, ...]","[start1:end1, start2:end2, ...]","[start1:step1:end1, start2:step2:end2, ...]"],description:"Create an index to get or replace a subset of a matrix",examples:["[]","[1, 2, 3]","A = [1, 2, 3; 4, 5, 6]","A[1, :]","A[1, 2] = 50","A[0:2, 0:2] = ones(2, 2)"],seealso:["bignumber","boolean","complex","matrix,","number","range","string","unit"]},matrix:{name:"matrix",category:"Construction",syntax:["[]","[a1, b1, ...; a2, b2, ...]","matrix()",'matrix("dense")',"matrix([...])"],description:"Create a matrix.",examples:["[]","[1, 2, 3]","[1, 2, 3; 4, 5, 6]","matrix()","matrix([3, 4])",'matrix([3, 4; 5, 6], "sparse")','matrix([3, 4; 5, 6], "sparse", "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","sparse"]},number:{name:"number",category:"Construction",syntax:["x","number(x)","number(unit, valuelessUnit)"],description:"Create a number or convert a string or boolean into a number.",examples:["2","2e3","4.05","number(2)",'number("7.2")',"number(true)","number([true, false, true, true])",'number(unit("52cm"), "m")'],seealso:["bignumber","boolean","complex","fraction","index","matrix","string","unit"]},sparse:{name:"sparse",category:"Construction",syntax:["sparse()","sparse([a1, b1, ...; a1, b2, ...])",'sparse([a1, b1, ...; a1, b2, ...], "number")'],description:"Create a sparse matrix.",examples:["sparse()","sparse([3, 4; 5, 6])",'sparse([3, 0; 5, 0], "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","matrix"]},splitUnit:{name:"splitUnit",category:"Construction",syntax:["splitUnit(unit: Unit, parts: Unit[])"],description:"Split a unit in an array of units whose sum is equal to the original unit.",examples:['splitUnit(1 m, ["feet", "inch"])'],seealso:["unit","createUnit"]},string:{name:"string",category:"Construction",syntax:['"text"',"string(x)"],description:"Create a string or convert a value to a string",examples:['"Hello World!"',"string(4.2)","string(3 + 2i)"],seealso:["bignumber","boolean","complex","index","matrix","number","unit"]},unit:{name:"unit",category:"Construction",syntax:["value unit","unit(value, unit)","unit(string)"],description:"Create a unit.",examples:["5.5 mm","3 inch",'unit(7.1, "kilogram")','unit("23 deg")'],seealso:["bignumber","boolean","complex","index","matrix","number","string"]},e:ree,E:ree,false:{name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]},i:{name:"i",category:"Constants",syntax:["i"],description:"Imaginary unit, defined as i*i=-1. A complex number is described as a + b*i, where a is the real part, and b is the imaginary part.",examples:["i","i * i","sqrt(-1)"],seealso:[]},Infinity:{name:"Infinity",category:"Constants",syntax:["Infinity"],description:"Infinity, a number which is larger than the maximum number that can be handled by a floating point number.",examples:["Infinity","1 / 0"],seealso:[]},LN2:{name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]},LN10:{name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]},LOG2E:{name:"LOG2E",category:"Constants",syntax:["LOG2E"],description:"Returns the base-2 logarithm of E, approximately equal to 1.442",examples:["LOG2E","log(e, 2)"],seealso:[]},LOG10E:{name:"LOG10E",category:"Constants",syntax:["LOG10E"],description:"Returns the base-10 logarithm of E, approximately equal to 0.434",examples:["LOG10E","log(e, 10)"],seealso:[]},NaN:{name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]},null:{name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]},pi:aee,PI:aee,phi:{name:"phi",category:"Constants",syntax:["phi"],description:"Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...",examples:["phi"],seealso:[]},SQRT1_2:{name:"SQRT1_2",category:"Constants",syntax:["SQRT1_2"],description:"Returns the square root of 1/2, approximately equal to 0.707",examples:["SQRT1_2","sqrt(1/2)"],seealso:[]},SQRT2:{name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]},tau:{name:"tau",category:"Constants",syntax:["tau"],description:"Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi, approximately 6.2832.",examples:["tau","2 * pi"],seealso:["pi"]},true:{name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]},version:{name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]},speedOfLight:{description:"Speed of light in vacuum",examples:["speedOfLight"]},gravitationConstant:{description:"Newtonian constant of gravitation",examples:["gravitationConstant"]},planckConstant:{description:"Planck constant",examples:["planckConstant"]},reducedPlanckConstant:{description:"Reduced Planck constant",examples:["reducedPlanckConstant"]},magneticConstant:{description:"Magnetic constant (vacuum permeability)",examples:["magneticConstant"]},electricConstant:{description:"Electric constant (vacuum permeability)",examples:["electricConstant"]},vacuumImpedance:{description:"Characteristic impedance of vacuum",examples:["vacuumImpedance"]},coulomb:{description:"Coulomb's constant",examples:["coulomb"]},elementaryCharge:{description:"Elementary charge",examples:["elementaryCharge"]},bohrMagneton:{description:"Borh magneton",examples:["bohrMagneton"]},conductanceQuantum:{description:"Conductance quantum",examples:["conductanceQuantum"]},inverseConductanceQuantum:{description:"Inverse conductance quantum",examples:["inverseConductanceQuantum"]},magneticFluxQuantum:{description:"Magnetic flux quantum",examples:["magneticFluxQuantum"]},nuclearMagneton:{description:"Nuclear magneton",examples:["nuclearMagneton"]},klitzing:{description:"Von Klitzing constant",examples:["klitzing"]},bohrRadius:{description:"Borh radius",examples:["bohrRadius"]},classicalElectronRadius:{description:"Classical electron radius",examples:["classicalElectronRadius"]},electronMass:{description:"Electron mass",examples:["electronMass"]},fermiCoupling:{description:"Fermi coupling constant",examples:["fermiCoupling"]},fineStructure:{description:"Fine-structure constant",examples:["fineStructure"]},hartreeEnergy:{description:"Hartree energy",examples:["hartreeEnergy"]},protonMass:{description:"Proton mass",examples:["protonMass"]},deuteronMass:{description:"Deuteron Mass",examples:["deuteronMass"]},neutronMass:{description:"Neutron mass",examples:["neutronMass"]},quantumOfCirculation:{description:"Quantum of circulation",examples:["quantumOfCirculation"]},rydberg:{description:"Rydberg constant",examples:["rydberg"]},thomsonCrossSection:{description:"Thomson cross section",examples:["thomsonCrossSection"]},weakMixingAngle:{description:"Weak mixing angle",examples:["weakMixingAngle"]},efimovFactor:{description:"Efimov factor",examples:["efimovFactor"]},atomicMass:{description:"Atomic mass constant",examples:["atomicMass"]},avogadro:{description:"Avogadro's number",examples:["avogadro"]},boltzmann:{description:"Boltzmann constant",examples:["boltzmann"]},faraday:{description:"Faraday constant",examples:["faraday"]},firstRadiation:{description:"First radiation constant",examples:["firstRadiation"]},loschmidt:{description:"Loschmidt constant at T=273.15 K and p=101.325 kPa",examples:["loschmidt"]},gasConstant:{description:"Gas constant",examples:["gasConstant"]},molarPlanckConstant:{description:"Molar Planck constant",examples:["molarPlanckConstant"]},molarVolume:{description:"Molar volume of an ideal gas at T=273.15 K and p=101.325 kPa",examples:["molarVolume"]},sackurTetrode:{description:"Sackur-Tetrode constant at T=1 K and p=101.325 kPa",examples:["sackurTetrode"]},secondRadiation:{description:"Second radiation constant",examples:["secondRadiation"]},stefanBoltzmann:{description:"Stefan-Boltzmann constant",examples:["stefanBoltzmann"]},wienDisplacement:{description:"Wien displacement law constant",examples:["wienDisplacement"]},molarMass:{description:"Molar mass constant",examples:["molarMass"]},molarMassC12:{description:"Molar mass constant of carbon-12",examples:["molarMassC12"]},gravity:{description:"Standard acceleration of gravity (standard acceleration of free-fall on Earth)",examples:["gravity"]},planckLength:{description:"Planck length",examples:["planckLength"]},planckMass:{description:"Planck mass",examples:["planckMass"]},planckTime:{description:"Planck time",examples:["planckTime"]},planckCharge:{description:"Planck charge",examples:["planckCharge"]},planckTemperature:{description:"Planck temperature",examples:["planckTemperature"]},derivative:{name:"derivative",category:"Algebra",syntax:["derivative(expr, variable)","derivative(expr, variable, {simplify: boolean})"],description:"Takes the derivative of an expression expressed in parser Nodes. The derivative will be taken over the supplied variable in the second parameter. If there are multiple variables in the expression, it will return a partial derivative.",examples:['derivative("2x^3", "x")','derivative("2x^3", "x", {simplify: false})','derivative("2x^2 + 3x + 4", "x")','derivative("sin(2x)", "x")','f = parse("x^2 + x")','x = parse("x")',"df = derivative(f, x)","df.evaluate({x: 3})"],seealso:["simplify","parse","evaluate"]},lsolve:{name:"lsolve",category:"Algebra",syntax:["x=lsolve(L, b)"],description:"Finds one solution of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolveAll","lup","lusolve","usolve","matrix","sparse"]},lsolveAll:{name:"lsolveAll",category:"Algebra",syntax:["x=lsolveAll(L, b)"],description:"Finds all solutions of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lsolve(a, b)"],seealso:["lsolve","lup","lusolve","usolve","matrix","sparse"]},lup:{name:"lup",category:"Algebra",syntax:["lup(m)"],description:"Calculate the Matrix LU decomposition with partial pivoting. Matrix A is decomposed in three matrices (L, U, P) where P * A = L * U",examples:["lup([[2, 1], [1, 4]])","lup(matrix([[2, 1], [1, 4]]))","lup(sparse([[2, 1], [1, 4]]))"],seealso:["lusolve","lsolve","usolve","matrix","sparse","slu","qr"]},lusolve:{name:"lusolve",category:"Algebra",syntax:["x=lusolve(A, b)","x=lusolve(lu, b)"],description:"Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.",examples:["a = [-2, 3; 2, 1]","b = [11, 9]","x = lusolve(a, b)"],seealso:["lup","slu","lsolve","usolve","matrix","sparse"]},leafCount:{name:"leafCount",category:"Algebra",syntax:["leafCount(expr)"],description:"Computes the number of leaves in the parse tree of the given expression",examples:['leafCount("e^(i*pi)-1")','leafCount(parse("{a: 22/7, b: 10^(1/2)}"))'],seealso:["simplify"]},resolve:{name:"resolve",category:"Algebra",syntax:["resolve(node, scope)"],description:"Recursively substitute variables in an expression tree.",examples:['resolve(parse("1 + x"), { x: 7 })','resolve(parse("size(text)"), { text: "Hello World" })','resolve(parse("x + y"), { x: parse("3z") })','resolve(parse("3x"), { x: parse("y+z"), z: parse("w^y") })'],seealso:["simplify","evaluate"],mayThrow:["ReferenceError"]},simplify:{name:"simplify",category:"Algebra",syntax:["simplify(expr)","simplify(expr, rules)"],description:"Simplify an expression tree.",examples:['simplify("3 + 2 / 4")','simplify("2x + x")','f = parse("x * (x + 2 + x)")',"simplified = simplify(f)","simplified.evaluate({x: 2})"],seealso:["simplifyCore","derivative","evaluate","parse","rationalize","resolve"]},simplifyConstant:{name:"simplifyConstant",category:"Algebra",syntax:["simplifyConstant(expr)","simplifyConstant(expr, options)"],description:"Replace constant subexpressions of node with their values.",examples:['simplifyConatant("(3-3)*x")','simplifyConstant(parse("z-cos(tau/8)"))'],seealso:["simplify","simplifyCore","evaluate"]},simplifyCore:{name:"simplifyCore",category:"Algebra",syntax:["simplifyCore(node)"],description:"Perform simple one-pass simplifications on an expression tree.",examples:['simplifyCore(parse("0*x"))','simplifyCore(parse("(x+0)*2"))'],seealso:["simplify","simplifyConstant","evaluate"]},symbolicEqual:{name:"symbolicEqual",category:"Algebra",syntax:["symbolicEqual(expr1, expr2)","symbolicEqual(expr1, expr2, options)"],description:"Returns true if the difference of the expressions simplifies to 0",examples:['symbolicEqual("x*y","y*x")','symbolicEqual("abs(x^2)", "x^2")','symbolicEqual("abs(x)", "x", {context: {abs: {trivial: true}}})'],seealso:["simplify","evaluate"]},rationalize:{name:"rationalize",category:"Algebra",syntax:["rationalize(expr)","rationalize(expr, scope)","rationalize(expr, scope, detailed)"],description:"Transform a rationalizable expression in a rational fraction. If rational fraction is one variable polynomial then converts the numerator and denominator in canonical form, with decreasing exponents, returning the coefficients of numerator.",examples:['rationalize("2x/y - y/(x+1)")','rationalize("2x/y - y/(x+1)", true)'],seealso:["simplify"]},slu:{name:"slu",category:"Algebra",syntax:["slu(A, order, threshold)"],description:"Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U",examples:["slu(sparse([4.5, 0, 3.2, 0; 3.1, 2.9, 0, 0.9; 0, 1.7, 3, 0; 3.5, 0.4, 0, 1]), 1, 0.001)"],seealso:["lusolve","lsolve","usolve","matrix","sparse","lup","qr"]},usolve:{name:"usolve",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds one solution of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolveAll","lup","lusolve","lsolve","matrix","sparse"]},usolveAll:{name:"usolveAll",category:"Algebra",syntax:["x=usolve(U, b)"],description:"Finds all solutions of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",examples:["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],seealso:["usolve","lup","lusolve","lsolve","matrix","sparse"]},qr:{name:"qr",category:"Algebra",syntax:["qr(A)"],description:"Calculates the Matrix QR decomposition. Matrix `A` is decomposed in two matrices (`Q`, `R`) where `Q` is an orthogonal matrix and `R` is an upper triangular matrix.",examples:["qr([[1, -1, 4], [1, 4, -2], [1, 4, 2], [1, -1, 0]])"],seealso:["lup","slu","matrix"]},abs:{name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},add:{name:"add",category:"Operators",syntax:["x + y","add(x, y)"],description:"Add two values.",examples:["a = 2.1 + 3.6","a - 3.6","3 + 2i","3 cm + 2 inch",'"2.3" + "4"'],seealso:["subtract"]},cbrt:{name:"cbrt",category:"Arithmetic",syntax:["cbrt(x)","cbrt(x, allRoots)"],description:"Compute the cubic root value. If x = y * y * y, then y is the cubic root of x. When `x` is a number or complex number, an optional second argument `allRoots` can be provided to return all three cubic roots. If not provided, the principal root is returned",examples:["cbrt(64)","cube(4)","cbrt(-8)","cbrt(2 + 3i)","cbrt(8i)","cbrt(8i, true)","cbrt(27 m^3)"],seealso:["square","sqrt","cube","multiply"]},ceil:{name:"ceil",category:"Arithmetic",syntax:["ceil(x)"],description:"Round a value towards plus infinity. If x is complex, both real and imaginary part are rounded towards plus infinity.",examples:["ceil(3.2)","ceil(3.8)","ceil(-4.2)"],seealso:["floor","fix","round"]},cube:{name:"cube",category:"Arithmetic",syntax:["cube(x)"],description:"Compute the cube of a value. The cube of x is x * x * x.",examples:["cube(2)","2^3","2 * 2 * 2"],seealso:["multiply","square","pow"]},divide:{name:"divide",category:"Operators",syntax:["x / y","divide(x, y)"],description:"Divide two values.",examples:["a = 2 / 3","a * 3","4.5 / 2","3 + 4 / 2","(3 + 4) / 2","18 km / 4.5"],seealso:["multiply"]},dotDivide:{name:"dotDivide",category:"Operators",syntax:["x ./ y","dotDivide(x, y)"],description:"Divide two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a ./ b"],seealso:["multiply","dotMultiply","divide"]},dotMultiply:{name:"dotMultiply",category:"Operators",syntax:["x .* y","dotMultiply(x, y)"],description:"Multiply two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a .* b"],seealso:["multiply","divide","dotDivide"]},dotPow:{name:"dotPow",category:"Operators",syntax:["x .^ y","dotPow(x, y)"],description:"Calculates the power of x to y element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","a .^ 2"],seealso:["pow"]},exp:{name:"exp",category:"Arithmetic",syntax:["exp(x)"],description:"Calculate the exponent of a value.",examples:["exp(1.3)","e ^ 1.3","log(exp(1.3))","x = 2.4","(exp(i*x) == cos(x) + i*sin(x)) # Euler's formula"],seealso:["expm","expm1","pow","log"]},expm:{name:"expm",category:"Arithmetic",syntax:["exp(x)"],description:"Compute the matrix exponential, expm(A) = e^A. The matrix must be square. Not to be confused with exp(a), which performs element-wise exponentiation.",examples:["expm([[0,2],[0,0]])"],seealso:["exp"]},expm1:{name:"expm1",category:"Arithmetic",syntax:["expm1(x)"],description:"Calculate the value of subtracting 1 from the exponential value.",examples:["expm1(2)","pow(e, 2) - 1","log(expm1(2) + 1)"],seealso:["exp","pow","log"]},fix:{name:"fix",category:"Arithmetic",syntax:["fix(x)"],description:"Round a value towards zero. If x is complex, both real and imaginary part are rounded towards zero.",examples:["fix(3.2)","fix(3.8)","fix(-4.2)","fix(-4.8)"],seealso:["ceil","floor","round"]},floor:{name:"floor",category:"Arithmetic",syntax:["floor(x)"],description:"Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.",examples:["floor(3.2)","floor(3.8)","floor(-4.2)"],seealso:["ceil","fix","round"]},gcd:{name:"gcd",category:"Arithmetic",syntax:["gcd(a, b)","gcd(a, b, c, ...)"],description:"Compute the greatest common divisor.",examples:["gcd(8, 12)","gcd(-4, 6)","gcd(25, 15, -10)"],seealso:["lcm","xgcd"]},hypot:{name:"hypot",category:"Arithmetic",syntax:["hypot(a, b, c, ...)","hypot([a, b, c, ...])"],description:"Calculate the hypotenusa of a list with values. ",examples:["hypot(3, 4)","sqrt(3^2 + 4^2)","hypot(-2)","hypot([3, 4, 5])"],seealso:["abs","norm"]},lcm:{name:"lcm",category:"Arithmetic",syntax:["lcm(x, y)"],description:"Compute the least common multiple.",examples:["lcm(4, 6)","lcm(6, 21)","lcm(6, 21, 5)"],seealso:["gcd"]},log:{name:"log",category:"Arithmetic",syntax:["log(x)","log(x, base)"],description:"Compute the logarithm of a value. If no base is provided, the natural logarithm of x is calculated. If base if provided, the logarithm is calculated for the specified base. log(x, base) is defined as log(x) / log(base).",examples:["log(3.5)","a = log(2.4)","exp(a)","10 ^ 4","log(10000, 10)","log(10000) / log(10)","b = log(1024, 2)","2 ^ b"],seealso:["exp","log1p","log2","log10"]},log2:{name:"log2",category:"Arithmetic",syntax:["log2(x)"],description:"Calculate the 2-base of a value. This is the same as calculating `log(x, 2)`.",examples:["log2(0.03125)","log2(16)","log2(16) / log2(2)","pow(2, 4)"],seealso:["exp","log1p","log","log10"]},log1p:{name:"log1p",category:"Arithmetic",syntax:["log1p(x)","log1p(x, base)"],description:"Calculate the logarithm of a `value+1`",examples:["log1p(2.5)","exp(log1p(1.4))","pow(10, 4)","log1p(9999, 10)","log1p(9999) / log(10)"],seealso:["exp","log","log2","log10"]},log10:{name:"log10",category:"Arithmetic",syntax:["log10(x)"],description:"Compute the 10-base logarithm of a value.",examples:["log10(0.00001)","log10(10000)","10 ^ 4","log(10000) / log(10)","log(10000, 10)"],seealso:["exp","log"]},mod:{name:"mod",category:"Operators",syntax:["x % y","x mod y","mod(x, y)"],description:"Calculates the modulus, the remainder of an integer division.",examples:["7 % 3","11 % 2","10 mod 4","isOdd(x) = x % 2","isOdd(2)","isOdd(3)"],seealso:["divide"]},multiply:{name:"multiply",category:"Operators",syntax:["x * y","multiply(x, y)"],description:"multiply two values.",examples:["a = 2.1 * 3.4","a / 3.4","2 * 3 + 4","2 * (3 + 4)","3 * 2.1 km"],seealso:["divide"]},norm:{name:"norm",category:"Arithmetic",syntax:["norm(x)","norm(x, p)"],description:"Calculate the norm of a number, vector or matrix.",examples:["abs(-3.5)","norm(-3.5)","norm(3 - 4i)","norm([1, 2, -3], Infinity)","norm([1, 2, -3], -Infinity)","norm([3, 4], 2)","norm([[1, 2], [3, 4]], 1)",'norm([[1, 2], [3, 4]], "inf")','norm([[1, 2], [3, 4]], "fro")']},nthRoot:{name:"nthRoot",category:"Arithmetic",syntax:["nthRoot(a)","nthRoot(a, root)"],description:'Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation "x^root = A".',examples:["4 ^ 3","nthRoot(64, 3)","nthRoot(9, 2)","sqrt(9)"],seealso:["nthRoots","pow","sqrt"]},nthRoots:{name:"nthRoots",category:"Arithmetic",syntax:["nthRoots(A)","nthRoots(A, root)"],description:'Calculate the nth roots of a value. An nth root of a positive real number A, is a positive real solution of the equation "x^root = A". This function returns an array of complex values.',examples:["nthRoots(1)","nthRoots(1, 3)"],seealso:["sqrt","pow","nthRoot"]},pow:{name:"pow",category:"Operators",syntax:["x ^ y","pow(x, y)"],description:"Calculates the power of x to y, x^y.",examples:["2^3","2*2*2","1 + e ^ (pi * i)","math.pow([[1, 2], [4, 3]], 2)","math.pow([[1, 2], [4, 3]], -1)"],seealso:["multiply","nthRoot","nthRoots","sqrt"]},round:{name:"round",category:"Arithmetic",syntax:["round(x)","round(x, n)"],description:"round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.",examples:["round(3.2)","round(3.8)","round(-4.2)","round(-4.8)","round(pi, 3)","round(123.45678, 2)"],seealso:["ceil","floor","fix"]},sign:{name:"sign",category:"Arithmetic",syntax:["sign(x)"],description:"Compute the sign of a value. The sign of a value x is 1 when x>1, -1 when x<0, and 0 when x=0.",examples:["sign(3.5)","sign(-4.2)","sign(0)"],seealso:["abs"]},sqrt:{name:"sqrt",category:"Arithmetic",syntax:["sqrt(x)"],description:"Compute the square root value. If x = y * y, then y is the square root of x.",examples:["sqrt(25)","5 * 5","sqrt(-1)"],seealso:["square","sqrtm","multiply","nthRoot","nthRoots","pow"]},sqrtm:{name:"sqrtm",category:"Arithmetic",syntax:["sqrtm(x)"],description:"Calculate the principal square root of a square matrix. The principal square root matrix `X` of another matrix `A` is such that `X * X = A`.",examples:["sqrtm([[1, 2], [3, 4]])"],seealso:["sqrt","abs","square","multiply"]},square:{name:"square",category:"Arithmetic",syntax:["square(x)"],description:"Compute the square of a value. The square of x is x * x.",examples:["square(3)","sqrt(9)","3^2","3 * 3"],seealso:["multiply","pow","sqrt","cube"]},subtract:{name:"subtract",category:"Operators",syntax:["x - y","subtract(x, y)"],description:"subtract two values.",examples:["a = 5.3 - 2","a + 2","2/3 - 1/6","2 * 3 - 3","2.1 km - 500m"],seealso:["add"]},unaryMinus:{name:"unaryMinus",category:"Operators",syntax:["-x","unaryMinus(x)"],description:"Inverse the sign of a value. Converts booleans and strings to numbers.",examples:["-4.5","-(-5.6)",'-"22"'],seealso:["add","subtract","unaryPlus"]},unaryPlus:{name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]},xgcd:{name:"xgcd",category:"Arithmetic",syntax:["xgcd(a, b)"],description:"Calculate the extended greatest common divisor for two values. The result is an array [d, x, y] with 3 entries, where d is the greatest common divisor, and d = x * a + y * b.",examples:["xgcd(8, 12)","gcd(8, 12)","xgcd(36163, 21199)"],seealso:["gcd","lcm"]},invmod:{name:"invmod",category:"Arithmetic",syntax:["invmod(a, b)"],description:"Calculate the (modular) multiplicative inverse of a modulo b. Solution to the equation ax ≣ 1 (mod b)",examples:["invmod(8, 12)=NaN","invmod(7, 13)=2","math.invmod(15151, 15122)=10429"],seealso:["gcd","xgcd"]},bitAnd:{name:"bitAnd",category:"Bitwise",syntax:["x & y","bitAnd(x, y)"],description:"Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0",examples:["5 & 3","bitAnd(53, 131)","[1, 12, 31] & 42"],seealso:["bitNot","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitNot:{name:"bitNot",category:"Bitwise",syntax:["~x","bitNot(x)"],description:"Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.",examples:["~1","~2","bitNot([2, -3, 4])"],seealso:["bitAnd","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]},bitOr:{name:"bitOr",category:"Bitwise",syntax:["x | y","bitOr(x, y)"],description:"Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.",examples:["5 | 3","bitOr([1, 2, 3], 4)"],seealso:["bitAnd","bitNot","bitXor","leftShift","rightArithShift","rightLogShift"]},bitXor:{name:"bitXor",category:"Bitwise",syntax:["bitXor(x, y)"],description:"Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.",examples:["bitOr(1, 2)","bitXor([2, 3, 4], 4)"],seealso:["bitAnd","bitNot","bitOr","leftShift","rightArithShift","rightLogShift"]},leftShift:{name:"leftShift",category:"Bitwise",syntax:["x << y","leftShift(x, y)"],description:"Bitwise left logical shift of a value x by y number of bits.",examples:["4 << 1","8 >> 1"],seealso:["bitAnd","bitNot","bitOr","bitXor","rightArithShift","rightLogShift"]},rightArithShift:{name:"rightArithShift",category:"Bitwise",syntax:["x >> y","rightArithShift(x, y)"],description:"Bitwise right arithmetic shift of a value x by y number of bits.",examples:["8 >> 1","4 << 1","-12 >> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightLogShift"]},rightLogShift:{name:"rightLogShift",category:"Bitwise",syntax:["x >>> y","rightLogShift(x, y)"],description:"Bitwise right logical shift of a value x by y number of bits.",examples:["8 >>> 1","4 << 1","-12 >>> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightArithShift"]},bellNumbers:{name:"bellNumbers",category:"Combinatorics",syntax:["bellNumbers(n)"],description:"The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["bellNumbers(3)","bellNumbers(8)"],seealso:["stirlingS2"]},catalan:{name:"catalan",category:"Combinatorics",syntax:["catalan(n)"],description:"The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.",examples:["catalan(3)","catalan(8)"],seealso:["bellNumbers"]},composition:{name:"composition",category:"Combinatorics",syntax:["composition(n, k)"],description:"The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.",examples:["composition(5, 3)"],seealso:["combinations"]},stirlingS2:{name:"stirlingS2",category:"Combinatorics",syntax:["stirlingS2(n, k)"],description:"he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.",examples:["stirlingS2(5, 3)"],seealso:["bellNumbers"]},config:{name:"config",category:"Core",syntax:["config()","config(options)"],description:"Get configuration or change configuration.",examples:["config()","1/3 + 1/4",'config({number: "Fraction"})',"1/3 + 1/4"],seealso:[]},import:{name:"import",category:"Core",syntax:["import(functions)","import(functions, options)"],description:"Import functions or constants from an object.",examples:["import({myFn: f(x)=x^2, myConstant: 32 })","myFn(2)","myConstant"],seealso:[]},typed:{name:"typed",category:"Core",syntax:["typed(signatures)","typed(name, signatures)"],description:"Create a typed function.",examples:['double = typed({ "number": f(x)=x+x })',"double(2)",'double("hello")'],seealso:[]},arg:{name:"arg",category:"Complex",syntax:["arg(x)"],description:"Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).",examples:["arg(2 + 2i)","atan2(3, 2)","arg(2 + 3i)"],seealso:["re","im","conj","abs"]},conj:{name:"conj",category:"Complex",syntax:["conj(x)"],description:"Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.",examples:["conj(2 + 3i)","conj(2 - 3i)","conj(-5.2i)"],seealso:["re","im","abs","arg"]},re:{name:"re",category:"Complex",syntax:["re(x)"],description:"Get the real part of a complex number.",examples:["re(2 + 3i)","im(2 + 3i)","re(-5.2i)","re(2.4)"],seealso:["im","conj","abs","arg"]},im:{name:"im",category:"Complex",syntax:["im(x)"],description:"Get the imaginary part of a complex number.",examples:["im(2 + 3i)","re(2 + 3i)","im(-5.2i)","im(2.4)"],seealso:["re","conj","abs","arg"]},evaluate:{name:"evaluate",category:"Expression",syntax:["evaluate(expression)","evaluate([expr1, expr2, expr3, ...])"],description:"Evaluate an expression or an array with expressions.",examples:['evaluate("2 + 3")','evaluate("sqrt(" + 4 + ")")'],seealso:[]},help:{name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]},distance:{name:"distance",category:"Geometry",syntax:["distance([x1, y1], [x2, y2])","distance([[x1, y1], [x2, y2]])"],description:"Calculates the Euclidean distance between two points.",examples:["distance([0,0], [4,4])","distance([[0,0], [4,4]])"],seealso:[]},intersect:{name:"intersect",category:"Geometry",syntax:["intersect(expr1, expr2, expr3, expr4)","intersect(expr1, expr2, expr3)"],description:"Computes the intersection point of lines and/or planes.",examples:["intersect([0, 0], [10, 10], [10, 0], [0, 10])","intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6])"],seealso:[]},and:{name:"and",category:"Logical",syntax:["x and y","and(x, y)"],description:"Logical and. Test whether two values are both defined with a nonzero/nonempty value.",examples:["true and false","true and true","2 and 4"],seealso:["not","or","xor"]},not:{name:"not",category:"Logical",syntax:["not x","not(x)"],description:"Logical not. Flips the boolean value of given argument.",examples:["not true","not false","not 2","not 0"],seealso:["and","or","xor"]},or:{name:"or",category:"Logical",syntax:["x or y","or(x, y)"],description:"Logical or. Test if at least one value is defined with a nonzero/nonempty value.",examples:["true or false","false or false","0 or 4"],seealso:["not","and","xor"]},xor:{name:"xor",category:"Logical",syntax:["x xor y","xor(x, y)"],description:"Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.",examples:["true xor false","false xor false","true xor true","0 xor 4"],seealso:["not","and","or"]},concat:{name:"concat",category:"Matrix",syntax:["concat(A, B, C, ...)","concat(A, B, C, ..., dim)"],description:"Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.",examples:["A = [1, 2; 5, 6]","B = [3, 4; 7, 8]","concat(A, B)","concat(A, B, 1)","concat(A, B, 2)"],seealso:["det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},count:{name:"count",category:"Matrix",syntax:["count(x)"],description:"Count the number of elements of a matrix, array or string.",examples:["a = [1, 2; 3, 4; 5, 6]","count(a)","size(a)",'count("hello world")'],seealso:["size"]},cross:{name:"cross",category:"Matrix",syntax:["cross(A, B)"],description:"Calculate the cross product for two vectors in three dimensional space.",examples:["cross([1, 1, 0], [0, 1, 1])","cross([3, -3, 1], [4, 9, 2])","cross([2, 3, 4], [5, 6, 7])"],seealso:["multiply","dot"]},column:{name:"column",category:"Matrix",syntax:["column(x, index)"],description:"Return a column from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","column(A, 1)","column(A, 2)"],seealso:["row","matrixFromColumns"]},ctranspose:{name:"ctranspose",category:"Matrix",syntax:["x'","ctranspose(x)"],description:"Complex Conjugate and Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","ctranspose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},det:{name:"det",category:"Matrix",syntax:["det(x)"],description:"Calculate the determinant of a matrix",examples:["det([1, 2; 3, 4])","det([-2, 2, 3; -1, 1, 3; 2, 0, -1])"],seealso:["concat","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},diag:{name:"diag",category:"Matrix",syntax:["diag(x)","diag(x, k)"],description:"Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.",examples:["diag(1:3)","diag(1:3, 1)","a = [1, 2, 3; 4, 5, 6; 7, 8, 9]","diag(a)"],seealso:["concat","det","identity","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},diff:{name:"diff",category:"Matrix",syntax:["diff(arr)","diff(arr, dim)"],description:["Create a new matrix or array with the difference of the passed matrix or array.","Dim parameter is optional and used to indicant the dimension of the array/matrix to apply the difference","If no dimension parameter is passed it is assumed as dimension 0","Dimension is zero-based in javascript and one-based in the parser","Arrays must be 'rectangular' meaning arrays like [1, 2]","If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays"],examples:["diff([1, 2, 4, 7, 0])","diff([1, 2, 4, 7, 0], 0)","diff(matrix([1, 2, 4, 7, 0]))","diff([[1, 2], [3, 4]])","diff([[1, 2], [3, 4]], 0)","diff([[1, 2], [3, 4]], 1)","diff([[1, 2], [3, 4]], bignumber(1))","diff(matrix([[1, 2], [3, 4]]), 1)","diff([[1, 2], matrix([3, 4])], 1)"],seealso:["subtract","partitionSelect"]},dot:{name:"dot",category:"Matrix",syntax:["dot(A, B)","A * B"],description:"Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn",examples:["dot([2, 4, 1], [2, 2, 3])","[2, 4, 1] * [2, 2, 3]"],seealso:["multiply","cross"]},getMatrixDataType:{name:"getMatrixDataType",category:"Matrix",syntax:["getMatrixDataType(x)"],description:'Find the data type of all elements in a matrix or array, for example "number" if all items are a number and "Complex" if all values are complex numbers. If a matrix contains more than one data type, it will return "mixed".',examples:["getMatrixDataType([1, 2, 3])","getMatrixDataType([[5 cm], [2 inch]])",'getMatrixDataType([1, "text"])',"getMatrixDataType([1, bignumber(4)])"],seealso:["matrix","sparse","typeOf"]},identity:{name:"identity",category:"Matrix",syntax:["identity(n)","identity(m, n)","identity([m, n])"],description:"Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.",examples:["identity(3)","identity(3, 5)","a = [1, 2, 3; 4, 5, 6]","identity(size(a))"],seealso:["concat","det","diag","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]},filter:{name:"filter",category:"Matrix",syntax:["filter(x, test)"],description:"Filter items in a matrix.",examples:["isPositive(x) = x > 0","filter([6, -2, -1, 4, 3], isPositive)","filter([6, -2, 0, 1, 0], x != 0)"],seealso:["sort","map","forEach"]},flatten:{name:"flatten",category:"Matrix",syntax:["flatten(x)"],description:"Flatten a multi dimensional matrix into a single dimensional matrix.",examples:["a = [1, 2, 3; 4, 5, 6]","size(a)","b = flatten(a)","size(b)"],seealso:["concat","resize","size","squeeze"]},forEach:{name:"forEach",category:"Matrix",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback function.",examples:["numberOfPets = {}","addPet(n) = numberOfPets[n] = (numberOfPets[n] ? numberOfPets[n]:0 ) + 1;",'forEach(["Dog","Cat","Cat"], addPet)',"numberOfPets"],seealso:["map","sort","filter"]},inv:{name:"inv",category:"Matrix",syntax:["inv(x)"],description:"Calculate the inverse of a matrix",examples:["inv([1, 2; 3, 4])","inv(4)","1 / 4"],seealso:["concat","det","diag","identity","ones","range","size","squeeze","subset","trace","transpose","zeros"]},pinv:{name:"pinv",category:"Matrix",syntax:["pinv(x)"],description:"Calculate the Moore–Penrose inverse of a matrix",examples:["pinv([1, 2; 3, 4])","pinv([[1, 0], [0, 1], [0, 1]])","pinv(4)"],seealso:["inv"]},eigs:{name:"eigs",category:"Matrix",syntax:["eigs(x)"],description:"Calculate the eigenvalues and eigenvectors of a real symmetric matrix",examples:["eigs([[5, 2.3], [2.3, 1]])"],seealso:["inv"]},kron:{name:"kron",category:"Matrix",syntax:["kron(x, y)"],description:"Calculates the kronecker product of 2 matrices or vectors.",examples:["kron([[1, 0], [0, 1]], [[1, 2], [3, 4]])","kron([1,1], [2,3,4])"],seealso:["multiply","dot","cross"]},matrixFromFunction:{name:"matrixFromFunction",category:"Matrix",syntax:["math.matrixFromFunction(size, fn)","math.matrixFromFunction(size, fn, format)","math.matrixFromFunction(size, fn, format, datatype)","math.matrixFromFunction(size, format, fn)","math.matrixFromFunction(size, format, datatype, fn)"],description:"Create a matrix by evaluating a generating function at each index.",examples:["f(I) = I[1] - I[2]","matrixFromFunction([3,3], f)","g(I) = I[1] - I[2] == 1 ? 4 : 0",'matrixFromFunction([100, 100], "sparse", g)',"matrixFromFunction([5], random)"],seealso:["matrix","matrixFromRows","matrixFromColumns","zeros"]},matrixFromRows:{name:"matrixFromRows",category:"Matrix",syntax:["math.matrixFromRows(...arr)","math.matrixFromRows(row1, row2)","math.matrixFromRows(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual rows.",examples:["matrixFromRows([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromColumns","matrixFromFunction","zeros"]},matrixFromColumns:{name:"matrixFromColumns",category:"Matrix",syntax:["math.matrixFromColumns(...arr)","math.matrixFromColumns(row1, row2)","math.matrixFromColumns(row1, row2, row3)"],description:"Create a dense matrix from vectors as individual columns.",examples:["matrixFromColumns([1, 2, 3], [[4],[5],[6]])"],seealso:["matrix","matrixFromRows","matrixFromFunction","zeros"]},map:{name:"map",category:"Matrix",syntax:["map(x, callback)"],description:"Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array.",examples:["map([1, 2, 3], square)"],seealso:["filter","forEach"]},ones:{name:"ones",category:"Matrix",syntax:["ones(m)","ones(m, n)","ones(m, n, p, ...)","ones([m])","ones([m, n])","ones([m, n, p, ...])"],description:"Create a matrix containing ones.",examples:["ones(3)","ones(3, 5)","ones([2,3]) * 4.5","a = [1, 2, 3; 4, 5, 6]","ones(size(a))"],seealso:["concat","det","diag","identity","inv","range","size","squeeze","subset","trace","transpose","zeros"]},partitionSelect:{name:"partitionSelect",category:"Matrix",syntax:["partitionSelect(x, k)","partitionSelect(x, k, compare)"],description:"Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.",examples:["partitionSelect([5, 10, 1], 2)",'partitionSelect(["C", "B", "A", "D"], 1)'],seealso:["sort"]},range:{name:"range",category:"Type",syntax:["start:end","start:step:end","range(start, end)","range(start, end, step)","range(string)"],description:"Create a range. Lower bound of the range is included, upper bound is excluded.",examples:["1:5","3:-1:-3","range(3, 7)","range(0, 12, 2)",'range("4:10")',"a = [1, 2, 3, 4; 5, 6, 7, 8]","a[1:2, 1:2]"],seealso:["concat","det","diag","identity","inv","ones","size","squeeze","subset","trace","transpose","zeros"]},resize:{name:"resize",category:"Matrix",syntax:["resize(x, size)","resize(x, size, defaultValue)"],description:"Resize a matrix.",examples:["resize([1,2,3,4,5], [3])","resize([1,2,3], [5])","resize([1,2,3], [5], -1)","resize(2, [2, 3])",'resize("hello", [8], "!")'],seealso:["size","subset","squeeze","reshape"]},reshape:{name:"reshape",category:"Matrix",syntax:["reshape(x, sizes)"],description:"Reshape a multi dimensional array to fit the specified dimensions.",examples:["reshape([1, 2, 3, 4, 5, 6], [2, 3])","reshape([[1, 2], [3, 4]], [1, 4])","reshape([[1, 2], [3, 4]], [4])"],seealso:["size","squeeze","resize"]},rotate:{name:"rotate",category:"Matrix",syntax:["rotate(w, theta)","rotate(w, theta, v)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotate([1, 0], math.pi / 2)",'rotate(matrix([1, 0]), unit("35deg"))','rotate([1, 0, 0], unit("90deg"), [0, 0, 1])','rotate(matrix([1, 0, 0]), unit("90deg"), matrix([0, 0, 1]))'],seealso:["matrix","rotationMatrix"]},rotationMatrix:{name:"rotationMatrix",category:"Matrix",syntax:["rotationMatrix(theta)","rotationMatrix(theta, v)","rotationMatrix(theta, v, format)"],description:"Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",examples:["rotationMatrix(pi / 2)",'rotationMatrix(unit("45deg"), [0, 0, 1])','rotationMatrix(1, matrix([0, 0, 1]), "sparse")'],seealso:["cos","sin"]},row:{name:"row",category:"Matrix",syntax:["row(x, index)"],description:"Return a row from a matrix or array.",examples:["A = [[1, 2], [3, 4]]","row(A, 1)","row(A, 2)"],seealso:["column","matrixFromRows"]},size:{name:"size",category:"Matrix",syntax:["size(x)"],description:"Calculate the size of a matrix.",examples:["size(2.3)",'size("hello world")',"a = [1, 2; 3, 4; 5, 6]","size(a)","size(1:6)"],seealso:["concat","count","det","diag","identity","inv","ones","range","squeeze","subset","trace","transpose","zeros"]},sort:{name:"sort",category:"Matrix",syntax:["sort(x)","sort(x, compare)"],description:'Sort the items in a matrix. Compare can be a string "asc", "desc", "natural", or a custom sort function.',examples:["sort([5, 10, 1])",'sort(["C", "B", "A", "D"])',"sortByLength(a, b) = size(a)[1] - size(b)[1]",'sort(["Langdon", "Tom", "Sara"], sortByLength)','sort(["10", "1", "2"], "natural")'],seealso:["map","filter","forEach"]},squeeze:{name:"squeeze",category:"Matrix",syntax:["squeeze(x)"],description:"Remove inner and outer singleton dimensions from a matrix.",examples:["a = zeros(3,2,1)","size(squeeze(a))","b = zeros(1,1,3)","size(squeeze(b))"],seealso:["concat","det","diag","identity","inv","ones","range","size","subset","trace","transpose","zeros"]},subset:{name:"subset",category:"Matrix",syntax:["value(index)","value(index) = replacement","subset(value, [index])","subset(value, [index], replacement)"],description:"Get or set a subset of the entries of a matrix or characters of a string. Indexes are one-based. There should be one index specification for each dimension of the target. Each specification can be a single index, a list of indices, or a range in colon notation `l:u`. In a range, both the lower bound l and upper bound u are included; and if a bound is omitted it defaults to the most extreme valid value. The cartesian product of the indices specified in each dimension determines the target of the operation.",examples:["d = [1, 2; 3, 4]","e = []","e[1, 1:2] = [5, 6]","e[2, :] = [7, 8]","f = d * e","f[2, 1]","f[:, 1]","f[[1,2], [1,3]] = [9, 10; 11, 12]","f"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","trace","transpose","zeros"]},trace:{name:"trace",category:"Matrix",syntax:["trace(A)"],description:"Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.",examples:["A = [1, 2, 3; -1, 2, 3; 2, 0, 3]","trace(A)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","transpose","zeros"]},transpose:{name:"transpose",category:"Matrix",syntax:["x'","transpose(x)"],description:"Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","transpose(a)"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","zeros"]},zeros:{name:"zeros",category:"Matrix",syntax:["zeros(m)","zeros(m, n)","zeros(m, n, p, ...)","zeros([m])","zeros([m, n])","zeros([m, n, p, ...])"],description:"Create a matrix containing zeros.",examples:["zeros(3)","zeros(3, 5)","a = [1, 2, 3; 4, 5, 6]","zeros(size(a))"],seealso:["concat","det","diag","identity","inv","ones","range","size","squeeze","subset","trace","transpose"]},fft:{name:"fft",category:"Matrix",syntax:["fft(x)"],description:"Calculate N-dimensional fourier transform",examples:["fft([[1, 0], [1, 0]])"],seealso:["ifft"]},ifft:{name:"ifft",category:"Matrix",syntax:["ifft(x)"],description:"Calculate N-dimensional inverse fourier transform",examples:["ifft([[2, 2], [0, 0]])"],seealso:["fft"]},combinations:{name:"combinations",category:"Probability",syntax:["combinations(n, k)"],description:"Compute the number of combinations of n items taken k at a time",examples:["combinations(7, 5)"],seealso:["combinationsWithRep","permutations","factorial"]},combinationsWithRep:{name:"combinationsWithRep",category:"Probability",syntax:["combinationsWithRep(n, k)"],description:"Compute the number of combinations of n items taken k at a time with replacements.",examples:["combinationsWithRep(7, 5)"],seealso:["combinations","permutations","factorial"]},factorial:{name:"factorial",category:"Probability",syntax:["n!","factorial(n)"],description:"Compute the factorial of a value",examples:["5!","5 * 4 * 3 * 2 * 1","3!"],seealso:["combinations","combinationsWithRep","permutations","gamma"]},gamma:{name:"gamma",category:"Probability",syntax:["gamma(n)"],description:"Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.",examples:["gamma(4)","3!","gamma(1/2)","sqrt(pi)"],seealso:["factorial"]},kldivergence:{name:"kldivergence",category:"Probability",syntax:["kldivergence(x, y)"],description:"Calculate the Kullback-Leibler (KL) divergence between two distributions.",examples:["kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])"],seealso:[]},lgamma:{name:"lgamma",category:"Probability",syntax:["lgamma(n)"],description:"Logarithm of the gamma function for real, positive numbers and complex numbers, using Lanczos approximation for numbers and Stirling series for complex numbers.",examples:["lgamma(4)","lgamma(1/2)","lgamma(math.i)","lgamma(complex(1.1, 2))"],seealso:["gamma"]},multinomial:{name:"multinomial",category:"Probability",syntax:["multinomial(A)"],description:"Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai > 0.",examples:["multinomial([1, 2, 1])"],seealso:["combinations","factorial"]},permutations:{name:"permutations",category:"Probability",syntax:["permutations(n)","permutations(n, k)"],description:"Compute the number of permutations of n items taken k at a time",examples:["permutations(5)","permutations(5, 3)"],seealso:["combinations","combinationsWithRep","factorial"]},pickRandom:{name:"pickRandom",category:"Probability",syntax:["pickRandom(array)","pickRandom(array, number)","pickRandom(array, weights)","pickRandom(array, number, weights)","pickRandom(array, weights, number)"],description:"Pick a random entry from a given array.",examples:["pickRandom(0:10)","pickRandom([1, 3, 1, 6])","pickRandom([1, 3, 1, 6], 2)","pickRandom([1, 3, 1, 6], [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], 2, [2, 3, 2, 1])","pickRandom([1, 3, 1, 6], [2, 3, 2, 1], 2)"],seealso:["random","randomInt"]},random:{name:"random",category:"Probability",syntax:["random()","random(max)","random(min, max)","random(size)","random(size, max)","random(size, min, max)"],description:"Return a random number.",examples:["random()","random(10, 20)","random([2, 3])"],seealso:["pickRandom","randomInt"]},randomInt:{name:"randomInt",category:"Probability",syntax:["randomInt(max)","randomInt(min, max)","randomInt(size)","randomInt(size, max)","randomInt(size, min, max)"],description:"Return a random integer number",examples:["randomInt(10, 20)","randomInt([2, 3], 10)"],seealso:["pickRandom","random"]},compare:{name:"compare",category:"Relational",syntax:["compare(x, y)"],description:"Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compare(2, 3)","compare(3, 2)","compare(2, 2)","compare(5cm, 40mm)","compare(2, [1, 2, 3])"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compareNatural","compareText"]},compareNatural:{name:"compareNatural",category:"Relational",syntax:["compareNatural(x, y)"],description:"Compare two values of any type in a deterministic, natural way. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:["compareNatural(2, 3)","compareNatural(3, 2)","compareNatural(2, 2)","compareNatural(5cm, 40mm)",'compareNatural("2", "10")',"compareNatural(2 + 3i, 2 + 4i)","compareNatural([1, 2, 4], [1, 2, 3])","compareNatural([1, 5], [1, 2, 3])","compareNatural([1, 2], [1, 2])","compareNatural({a: 2}, {a: 4})"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare","compareText"]},compareText:{name:"compareText",category:"Relational",syntax:["compareText(x, y)"],description:"Compare two strings lexically. Comparison is case sensitive. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",examples:['compareText("B", "A")','compareText("A", "B")','compareText("A", "A")','compareText("2", "10")','compare("2", "10")',"compare(2, 10)",'compareNatural("2", "10")','compareText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural"]},deepEqual:{name:"deepEqual",category:"Relational",syntax:["deepEqual(x, y)"],description:"Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.",examples:["deepEqual([1,3,4], [1,3,4])","deepEqual([1,3,4], [1,3])"],seealso:["equal","unequal","smaller","larger","smallerEq","largerEq","compare"]},equal:{name:"equal",category:"Relational",syntax:["x == y","equal(x, y)"],description:"Check equality of two values. Returns true if the values are equal, and false if not.",examples:["2+2 == 3","2+2 == 4","a = 3.2","b = 6-2.8","a == b","50cm == 0.5m"],seealso:["unequal","smaller","larger","smallerEq","largerEq","compare","deepEqual","equalText"]},equalText:{name:"equalText",category:"Relational",syntax:["equalText(x, y)"],description:"Check equality of two strings. Comparison is case sensitive. Returns true if the values are equal, and false if not.",examples:['equalText("Hello", "Hello")','equalText("a", "A")','equal("2e3", "2000")','equalText("2e3", "2000")','equalText("B", ["A", "B", "C"])'],seealso:["compare","compareNatural","compareText","equal"]},larger:{name:"larger",category:"Relational",syntax:["x > y","larger(x, y)"],description:"Check if value x is larger than y. Returns true if x is larger than y, and false if not.",examples:["2 > 3","5 > 2*2","a = 3.3","b = 6-2.8","(a > b)","(b < a)","5 cm > 2 inch"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare"]},largerEq:{name:"largerEq",category:"Relational",syntax:["x >= y","largerEq(x, y)"],description:"Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.",examples:["2 >= 1+1","2 > 1+1","a = 3.2","b = 6-2.8","(a >= b)"],seealso:["equal","unequal","smallerEq","smaller","compare"]},smaller:{name:"smaller",category:"Relational",syntax:["x < y","smaller(x, y)"],description:"Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.",examples:["2 < 3","5 < 2*2","a = 3.3","b = 6-2.8","(a < b)","5 cm < 2 inch"],seealso:["equal","unequal","larger","smallerEq","largerEq","compare"]},smallerEq:{name:"smallerEq",category:"Relational",syntax:["x <= y","smallerEq(x, y)"],description:"Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.",examples:["2 <= 1+1","2 < 1+1","a = 3.2","b = 6-2.8","(a <= b)"],seealso:["equal","unequal","larger","smaller","largerEq","compare"]},unequal:{name:"unequal",category:"Relational",syntax:["x != y","unequal(x, y)"],description:"Check unequality of two values. Returns true if the values are unequal, and false if they are equal.",examples:["2+2 != 3","2+2 != 4","a = 3.2","b = 6-2.8","a != b","50cm != 0.5m","5 cm != 2 inch"],seealso:["equal","smaller","larger","smallerEq","largerEq","compare","deepEqual"]},setCartesian:{name:"setCartesian",category:"Set",syntax:["setCartesian(set1, set2)"],description:"Create the cartesian product of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays and the values will be sorted in ascending order before the operation.",examples:["setCartesian([1, 2], [3, 4])"],seealso:["setUnion","setIntersect","setDifference","setPowerset"]},setDifference:{name:"setDifference",category:"Set",syntax:["setDifference(set1, set2)"],description:"Create the difference of two (multi)sets: every element of set1, that is not the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setDifference([1, 2, 3, 4], [3, 4, 5, 6])","setDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setSymDifference"]},setDistinct:{name:"setDistinct",category:"Set",syntax:["setDistinct(set)"],description:"Collect the distinct elements of a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setDistinct([1, 1, 1, 2, 2, 3])"],seealso:["setMultiplicity"]},setIntersect:{name:"setIntersect",category:"Set",syntax:["setIntersect(set1, set2)"],description:"Create the intersection of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIntersect([1, 2, 3, 4], [3, 4, 5, 6])","setIntersect([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setDifference"]},setIsSubset:{name:"setIsSubset",category:"Set",syntax:["setIsSubset(set1, set2)"],description:"Check whether a (multi)set is a subset of another (multi)set: every element of set1 is the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setIsSubset([1, 2], [3, 4, 5, 6])","setIsSubset([3, 4], [3, 4, 5, 6])"],seealso:["setUnion","setIntersect","setDifference"]},setMultiplicity:{name:"setMultiplicity",category:"Set",syntax:["setMultiplicity(element, set)"],description:"Count the multiplicity of an element in a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setMultiplicity(1, [1, 2, 2, 4])","setMultiplicity(2, [1, 2, 2, 4])"],seealso:["setDistinct","setSize"]},setPowerset:{name:"setPowerset",category:"Set",syntax:["setPowerset(set)"],description:"Create the powerset of a (multi)set: the powerset contains very possible subsets of a (multi)set. A multi-dimension array will be converted to a single-dimension array before the operation.",examples:["setPowerset([1, 2, 3])"],seealso:["setCartesian"]},setSize:{name:"setSize",category:"Set",syntax:["setSize(set)","setSize(set, unique)"],description:'Count the number of elements of a (multi)set. When the second parameter "unique" is true, count only the unique values. A multi-dimension array will be converted to a single-dimension array before the operation.',examples:["setSize([1, 2, 2, 4])","setSize([1, 2, 2, 4], true)"],seealso:["setUnion","setIntersect","setDifference"]},setSymDifference:{name:"setSymDifference",category:"Set",syntax:["setSymDifference(set1, set2)"],description:"Create the symmetric difference of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setSymDifference([1, 2, 3, 4], [3, 4, 5, 6])","setSymDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setUnion","setIntersect","setDifference"]},setUnion:{name:"setUnion",category:"Set",syntax:["setUnion(set1, set2)"],description:"Create the union of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",examples:["setUnion([1, 2, 3, 4], [3, 4, 5, 6])","setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],seealso:["setIntersect","setDifference"]},erf:{name:"erf",category:"Special",syntax:["erf(x)"],description:"Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x",examples:["erf(0.2)","erf(-0.5)","erf(4)"],seealso:[]},cumsum:{name:"cumsum",category:"Statistics",syntax:["cumsum(a, b, c, ...)","cumsum(A)"],description:"Compute the cumulative sum of all values.",examples:["cumsum(2, 3, 4, 1)","cumsum([2, 3, 4, 1])","cumsum([1, 2; 3, 4])","cumsum([1, 2; 3, 4], 1)","cumsum([1, 2; 3, 4], 2)"],seealso:["max","mean","median","min","prod","std","sum","variance"]},mad:{name:"mad",category:"Statistics",syntax:["mad(a, b, c, ...)","mad(A)"],description:"Compute the median absolute deviation of a matrix or a list with values. The median absolute deviation is defined as the median of the absolute deviations from the median.",examples:["mad(10, 20, 30)","mad([1, 2, 3])"],seealso:["mean","median","std","abs"]},max:{name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dim)"],description:"Compute the maximum value of a list of values.",examples:["max(2, 3, 4, 1)","max([2, 3, 4, 1])","max([2, 5; 4, 3])","max([2, 5; 4, 3], 1)","max([2, 5; 4, 3], 2)","max(2.7, 7.1, -4.5, 2.0, 4.1)","min(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["mean","median","min","prod","std","sum","variance"]},mean:{name:"mean",category:"Statistics",syntax:["mean(a, b, c, ...)","mean(A)","mean(A, dim)"],description:"Compute the arithmetic mean of a list of values.",examples:["mean(2, 3, 4, 1)","mean([2, 3, 4, 1])","mean([2, 5; 4, 3])","mean([2, 5; 4, 3], 1)","mean([2, 5; 4, 3], 2)","mean([1.0, 2.7, 3.2, 4.0])"],seealso:["max","median","min","prod","std","sum","variance"]},median:{name:"median",category:"Statistics",syntax:["median(a, b, c, ...)","median(A)"],description:"Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.",examples:["median(5, 2, 7)","median([3, -1, 5, 7])"],seealso:["max","mean","min","prod","std","sum","variance","quantileSeq"]},min:{name:"min",category:"Statistics",syntax:["min(a, b, c, ...)","min(A)","min(A, dim)"],description:"Compute the minimum value of a list of values.",examples:["min(2, 3, 4, 1)","min([2, 3, 4, 1])","min([2, 5; 4, 3])","min([2, 5; 4, 3], 1)","min([2, 5; 4, 3], 2)","min(2.7, 7.1, -4.5, 2.0, 4.1)","max(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["max","mean","median","prod","std","sum","variance"]},mode:{name:"mode",category:"Statistics",syntax:["mode(a, b, c, ...)","mode(A)","mode(A, a, b, B, c, ...)"],description:"Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.",examples:["mode(2, 1, 4, 3, 1)","mode([1, 2.7, 3.2, 4, 2.7])","mode(1, 4, 6, 1, 6)"],seealso:["max","mean","min","median","prod","std","sum","variance"]},prod:{name:"prod",category:"Statistics",syntax:["prod(a, b, c, ...)","prod(A)"],description:"Compute the product of all values.",examples:["prod(2, 3, 4)","prod([2, 3, 4])","prod([2, 5; 4, 3])"],seealso:["max","mean","min","median","min","std","sum","variance"]},quantileSeq:{name:"quantileSeq",category:"Statistics",syntax:["quantileSeq(A, prob[, sorted])","quantileSeq(A, [prob1, prob2, ...][, sorted])","quantileSeq(A, N[, sorted])"],description:"Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probablity are: Number, BigNumber. \n\nIn case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.",examples:["quantileSeq([3, -1, 5, 7], 0.5)","quantileSeq([3, -1, 5, 7], [1/3, 2/3])","quantileSeq([3, -1, 5, 7], 2)","quantileSeq([-1, 3, 5, 7], 0.5, true)"],seealso:["mean","median","min","max","prod","std","sum","variance"]},std:{name:"std",category:"Statistics",syntax:["std(a, b, c, ...)","std(A)","std(A, normalization)"],description:'Compute the standard deviation of all values, defined as std(A) = sqrt(variance(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["std(2, 4, 6)","std([2, 4, 6, 8])",'std([2, 4, 6, 8], "uncorrected")','std([2, 4, 6, 8], "biased")',"std([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","prod","sum","variance"]},sum:{name:"sum",category:"Statistics",syntax:["sum(a, b, c, ...)","sum(A)"],description:"Compute the sum of all values.",examples:["sum(2, 3, 4, 1)","sum([2, 3, 4, 1])","sum([2, 5; 4, 3])"],seealso:["max","mean","median","min","prod","std","sum","variance"]},variance:{name:"variance",category:"Statistics",syntax:["variance(a, b, c, ...)","variance(A)","variance(A, normalization)"],description:'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["variance(2, 4, 6)","variance([2, 4, 6, 8])",'variance([2, 4, 6, 8], "uncorrected")','variance([2, 4, 6, 8], "biased")',"variance([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","min","prod","std","sum"]},acos:{name:"acos",category:"Trigonometry",syntax:["acos(x)"],description:"Compute the inverse cosine of a value in radians.",examples:["acos(0.5)","acos(cos(2.3))"],seealso:["cos","atan","asin"]},acosh:{name:"acosh",category:"Trigonometry",syntax:["acosh(x)"],description:"Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.",examples:["acosh(1.5)"],seealso:["cosh","asinh","atanh"]},acot:{name:"acot",category:"Trigonometry",syntax:["acot(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acot(0.5)","acot(cot(0.5))","acot(2)"],seealso:["cot","atan"]},acoth:{name:"acoth",category:"Trigonometry",syntax:["acoth(x)"],description:"Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.",examples:["acoth(2)","acoth(0.5)"],seealso:["acsch","asech"]},acsc:{name:"acsc",category:"Trigonometry",syntax:["acsc(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acsc(2)","acsc(csc(0.5))","acsc(0.5)"],seealso:["csc","asin","asec"]},acsch:{name:"acsch",category:"Trigonometry",syntax:["acsch(x)"],description:"Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",examples:["acsch(0.5)"],seealso:["asech","acoth"]},asec:{name:"asec",category:"Trigonometry",syntax:["asec(x)"],description:"Calculate the inverse secant of a value.",examples:["asec(0.5)","asec(sec(0.5))","asec(2)"],seealso:["acos","acot","acsc"]},asech:{name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]},asin:{name:"asin",category:"Trigonometry",syntax:["asin(x)"],description:"Compute the inverse sine of a value in radians.",examples:["asin(0.5)","asin(sin(0.5))"],seealso:["sin","acos","atan"]},asinh:{name:"asinh",category:"Trigonometry",syntax:["asinh(x)"],description:"Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.",examples:["asinh(0.5)"],seealso:["acosh","atanh"]},atan:{name:"atan",category:"Trigonometry",syntax:["atan(x)"],description:"Compute the inverse tangent of a value in radians.",examples:["atan(0.5)","atan(tan(0.5))"],seealso:["tan","acos","asin"]},atanh:{name:"atanh",category:"Trigonometry",syntax:["atanh(x)"],description:"Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",examples:["atanh(0.5)"],seealso:["acosh","asinh"]},atan2:{name:"atan2",category:"Trigonometry",syntax:["atan2(y, x)"],description:"Computes the principal value of the arc tangent of y/x in radians.",examples:["atan2(2, 2) / pi","angle = 60 deg in rad","x = cos(angle)","y = sin(angle)","atan2(y, x)"],seealso:["sin","cos","tan"]},cos:{name:"cos",category:"Trigonometry",syntax:["cos(x)"],description:"Compute the cosine of x in radians.",examples:["cos(2)","cos(pi / 4) ^ 2","cos(180 deg)","cos(60 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["acos","sin","tan"]},cosh:{name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]},cot:{name:"cot",category:"Trigonometry",syntax:["cot(x)"],description:"Compute the cotangent of x in radians. Defined as 1/tan(x)",examples:["cot(2)","1 / tan(2)"],seealso:["sec","csc","tan"]},coth:{name:"coth",category:"Trigonometry",syntax:["coth(x)"],description:"Compute the hyperbolic cotangent of x in radians.",examples:["coth(2)","1 / tanh(2)"],seealso:["sech","csch","tanh"]},csc:{name:"csc",category:"Trigonometry",syntax:["csc(x)"],description:"Compute the cosecant of x in radians. Defined as 1/sin(x)",examples:["csc(2)","1 / sin(2)"],seealso:["sec","cot","sin"]},csch:{name:"csch",category:"Trigonometry",syntax:["csch(x)"],description:"Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)",examples:["csch(2)","1 / sinh(2)"],seealso:["sech","coth","sinh"]},sec:{name:"sec",category:"Trigonometry",syntax:["sec(x)"],description:"Compute the secant of x in radians. Defined as 1/cos(x)",examples:["sec(2)","1 / cos(2)"],seealso:["cot","csc","cos"]},sech:{name:"sech",category:"Trigonometry",syntax:["sech(x)"],description:"Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)",examples:["sech(2)","1 / cosh(2)"],seealso:["coth","csch","cosh"]},sin:{name:"sin",category:"Trigonometry",syntax:["sin(x)"],description:"Compute the sine of x in radians.",examples:["sin(2)","sin(pi / 4) ^ 2","sin(90 deg)","sin(30 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["asin","cos","tan"]},sinh:{name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]},tan:{name:"tan",category:"Trigonometry",syntax:["tan(x)"],description:"Compute the tangent of x in radians.",examples:["tan(0.5)","sin(0.5) / cos(0.5)","tan(pi / 4)","tan(45 deg)"],seealso:["atan","sin","cos"]},tanh:{name:"tanh",category:"Trigonometry",syntax:["tanh(x)"],description:"Compute the hyperbolic tangent of x in radians.",examples:["tanh(0.5)","sinh(0.5) / cosh(0.5)"],seealso:["sinh","cosh"]},to:{name:"to",category:"Units",syntax:["x to unit","to(x, unit)"],description:"Change the unit of a value.",examples:["5 inch to cm","3.2kg to g","16 bytes in bits"],seealso:[]},clone:{name:"clone",category:"Utils",syntax:["clone(x)"],description:"Clone a variable. Creates a copy of primitive variables,and a deep copy of matrices",examples:["clone(3.5)","clone(2 - 4i)","clone(45 deg)","clone([1, 2; 3, 4])",'clone("hello world")'],seealso:[]},format:{name:"format",category:"Utils",syntax:["format(value)","format(value, precision)"],description:"Format a value of any type as string.",examples:["format(2.3)","format(3 - 4i)","format([])","format(pi, 3)"],seealso:["print"]},bin:{name:"bin",category:"Utils",syntax:["bin(value)"],description:"Format a number as binary",examples:["bin(2)"],seealso:["oct","hex"]},oct:{name:"oct",category:"Utils",syntax:["oct(value)"],description:"Format a number as octal",examples:["oct(56)"],seealso:["bin","hex"]},hex:{name:"hex",category:"Utils",syntax:["hex(value)"],description:"Format a number as hexadecimal",examples:["hex(240)"],seealso:["bin","oct"]},isNaN:{name:"isNaN",category:"Utils",syntax:["isNaN(x)"],description:"Test whether a value is NaN (not a number)",examples:["isNaN(2)","isNaN(0 / 0)","isNaN(NaN)","isNaN(Infinity)"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isInteger:{name:"isInteger",category:"Utils",syntax:["isInteger(x)"],description:"Test whether a value is an integer number.",examples:["isInteger(2)","isInteger(3.5)","isInteger([3, 0.5, -2])"],seealso:["isNegative","isNumeric","isPositive","isZero"]},isNegative:{name:"isNegative",category:"Utils",syntax:["isNegative(x)"],description:"Test whether a value is negative: smaller than zero.",examples:["isNegative(2)","isNegative(0)","isNegative(-4)","isNegative([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isPositive","isZero"]},isNumeric:{name:"isNumeric",category:"Utils",syntax:["isNumeric(x)"],description:"Test whether a value is a numeric value. Returns true when the input is a number, BigNumber, Fraction, or boolean.",examples:["isNumeric(2)",'isNumeric("2")','hasNumericValue("2")',"isNumeric(0)","isNumeric(bignumber(500))","isNumeric(fraction(0.125))","isNumeric(2 + 3i)",'isNumeric([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","hasNumericValue"]},hasNumericValue:{name:"hasNumericValue",category:"Utils",syntax:["hasNumericValue(x)"],description:"Test whether a value is an numeric value. In case of a string, true is returned if the string contains a numeric value.",examples:["hasNumericValue(2)",'hasNumericValue("2")','isNumeric("2")',"hasNumericValue(0)","hasNumericValue(bignumber(500))","hasNumericValue(fraction(0.125))","hasNumericValue(2 + 3i)",'hasNumericValue([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN","isNumeric"]},isPositive:{name:"isPositive",category:"Utils",syntax:["isPositive(x)"],description:"Test whether a value is positive: larger than zero.",examples:["isPositive(2)","isPositive(0)","isPositive(-4)","isPositive([3, 0.5, -2])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isPrime:{name:"isPrime",category:"Utils",syntax:["isPrime(x)"],description:"Test whether a value is prime: has no divisors other than itself and one.",examples:["isPrime(3)","isPrime(-2)","isPrime([2, 17, 100])"],seealso:["isInteger","isNumeric","isNegative","isZero"]},isZero:{name:"isZero",category:"Utils",syntax:["isZero(x)"],description:"Test whether a value is zero.",examples:["isZero(2)","isZero(0)","isZero(-4)","isZero([3, 0, -2, 0])"],seealso:["isInteger","isNumeric","isNegative","isPositive"]},print:{name:"print",category:"Utils",syntax:["print(template, values)","print(template, values, precision)"],description:"Interpolate values into a string template.",examples:['print("Lucy is $age years old", {age: 5})','print("The value of pi is $pi", {pi: pi}, 3)','print("Hello, $user.name!", {user: {name: "John"}})','print("Values: $0, $1, $2", [6, 9, 4])'],seealso:["format"]},typeOf:{name:"typeOf",category:"Utils",syntax:["typeOf(x)"],description:"Get the type of a variable.",examples:["typeOf(3.5)","typeOf(2 - 4i)","typeOf(45 deg)",'typeOf("hello world")'],seealso:["getMatrixDataType"]},numeric:{name:"numeric",category:"Utils",syntax:["numeric(x)"],description:"Convert a numeric input to a specific numeric type: number, BigNumber, or Fraction.",examples:['numeric("4")','numeric("4", "number")','numeric("4", "BigNumber")','numeric("4", "Fraction)','numeric(4, "Fraction")','numeric(fraction(2, 5), "number)'],seealso:["number","fraction","bignumber","string","format"]}},see="help",oee=_U(see,["typed","mathWithTransform","Help"],(e=>{var{typed:t,mathWithTransform:n,Help:r}=e;return t(see,{any:function(e){var t,a=e;if("string"!=typeof e)for(t in n)if(AH(n,t)&&e===n[t]){a=t;break}var i=pV(iee,a);if(!i){var s="function"==typeof a?a.name:a;throw new Error('No documentation found on "'+s+'"')}return new r(i)}})})),uee=_U("Parser",["evaluate"],(e=>{var{evaluate:t}=e;function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");Object.defineProperty(this,"scope",{value:vV(),writable:!1})}return n.prototype.type="Parser",n.prototype.isParser=!0,n.prototype.evaluate=function(e){return t(e,this.scope)},n.prototype.get=function(e){if(this.scope.has(e))return this.scope.get(e)},n.prototype.getAll=function(){return function(e){if(e instanceof bV)return e.wrappedObject;var t={};for(var n of e.keys())dV(t,n,e.get(n));return t}(this.scope)},n.prototype.getAllAsMap=function(){return this.scope},n.prototype.set=function(e,t){return this.scope.set(e,t),t},n.prototype.remove=function(e){this.scope.delete(e)},n.prototype.clear=function(){this.scope.clear()},n}),{isClass:!0}),lee="parser",cee=_U(lee,["typed","Parser"],(e=>{var{typed:t,Parser:n}=e;return t(lee,{"":function(){return new n}})})),pee=_U("simplify",["config","typed","parse","add","subtract","multiply","divide","pow","isZero","equal","resolve","simplifyConstant","simplifyCore","?fraction","?bignumber","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{config:t,typed:n,parse:r,add:a,subtract:i,multiply:s,divide:o,pow:u,isZero:l,equal:c,resolve:p,simplifyConstant:d,simplifyCore:h,fraction:f,bignumber:m,mathWithTransform:g,matrix:y,AccessorNode:b,ArrayNode:v,ConstantNode:x,FunctionNode:_,IndexNode:w,ObjectNode:D,OperatorNode:N,ParenthesisNode:M,SymbolNode:S}=e,{hasProperty:k,isCommutative:T,isAssociative:C,mergeContext:E,flatten:A,unflattenr:I,unflattenl:L,createMakeNodeFunction:F,defaultContext:$,realContext:O,positiveContext:R}=W9({FunctionNode:_,OperatorNode:N,SymbolNode:S});n.addConversion({from:"Object",to:"Map",convert:xV});var Y=n("simplify",{Node:U,"Node, Map":(e,t)=>U(e,!1,t),"Node, Map, Object":(e,t,n)=>U(e,!1,t,n),"Node, Array":U,"Node, Array, Map":U,"Node, Array, Map, Object":U});function B(e){return e.transform((function(e,t,n){return bH(e)?B(e.content):e}))}n.removeConversion({from:"Object",to:"Map",convert:xV}),Y.defaultContext=$,Y.realContext=O,Y.positiveContext=R;var z={true:!0,false:!0,e:!0,i:!0,Infinity:!0,LN2:!0,LN10:!0,LOG2E:!0,LOG10E:!0,NaN:!0,phi:!0,pi:!0,SQRT1_2:!0,SQRT2:!0,tau:!0};function P(e,t){var n={};if(e.s){var a=e.s.split("->");if(2!==a.length)throw SyntaxError("Could not parse rule: "+e.s);n.l=a[0],n.r=a[1]}else n.l=e.l,n.r=e.r;for(var i of(n.l=B(r(n.l)),n.r=B(r(n.r)),["imposeContext","repeat","assuming"]))i in e&&(n[i]=e[i]);if(e.evaluate&&(n.evaluate=r(e.evaluate)),C(n.l,t)){var s=F(n.l),o=new S("_p"+j++);n.expanded={},n.expanded.l=s([n.l.clone(),o]),A(n.expanded.l,t),I(n.expanded.l,t),n.expanded.r=s([n.r,o])}return n}function H(e,t){for(var n=[],r=0;r n+-n1",assuming:{subtract:{total:!0}}},{s:"n-n -> 0",assuming:{subtract:{total:!1}}},{s:"-(c*v) -> v * (-c)",assuming:{multiply:{commutative:!0},subtract:{total:!0}}},{s:"-(c*v) -> (-c) * v",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{s:"-(v*c) -> v * (-c)",assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{l:"-(n1/n2)",r:"-n1/n2"},{l:"-v",r:"v * (-1)"},{l:"(n1 + n2)*(-1)",r:"n1*(-1) + n2*(-1)",repeat:!0},{l:"n/n1^n2",r:"n*n1^-n2"},{l:"n/n1",r:"n*n1^-1"},{s:"(n1*n2)^n3 -> n1^n3 * n2^n3",assuming:{multiply:{commutative:!0}}},{s:"(n1*n2)^(-1) -> n2^(-1) * n1^(-1)",assuming:{multiply:{commutative:!1}}},{s:"(n ^ n1) ^ n2 -> n ^ (n1 * n2)",assuming:{divide:{total:!0}}},{l:" v * ( v * n1 + n2)",r:"v^2 * n1 + v * n2"},{s:" v * (v^n4 * n1 + n2) -> v^(1+n4) * n1 + v * n2",assuming:{divide:{total:!0}}},{s:"v^n3 * ( v * n1 + n2) -> v^(n3+1) * n1 + v^n3 * n2",assuming:{divide:{total:!0}}},{s:"v^n3 * (v^n4 * n1 + n2) -> v^(n3+n4) * n1 + v^n3 * n2",assuming:{divide:{total:!0}}},{l:"n*n",r:"n^2"},{s:"n * n^n1 -> n^(n1+1)",assuming:{divide:{total:!0}}},{s:"n^n1 * n^n2 -> n^(n1+n2)",assuming:{divide:{total:!0}}},d,{s:"n+n -> 2*n",assuming:{add:{total:!0}}},{l:"n+-n",r:"0"},{l:"v*n + v",r:"v*(n+1)"},{l:"n3*n1 + n3*n2",r:"n3*(n1+n2)"},{l:"n3^(-n4)*n1 + n3 * n2",r:"n3^(-n4)*(n1 + n3^(n4+1) *n2)"},{l:"n3^(-n4)*n1 + n3^n5 * n2",r:"n3^(-n4)*(n1 + n3^(n4+n5)*n2)"},{s:"n*v + v -> (n+1)*v",assuming:{multiply:{commutative:!1}}},{s:"n1*n3 + n2*n3 -> (n1+n2)*n3",assuming:{multiply:{commutative:!1}}},{s:"n1*n3^(-n4) + n2 * n3 -> (n1 + n2*n3^(n4 + 1))*n3^(-n4)",assuming:{multiply:{commutative:!1}}},{s:"n1*n3^(-n4) + n2 * n3^n5 -> (n1 + n2*n3^(n4 + n5))*n3^(-n4)",assuming:{multiply:{commutative:!1}}},{l:"n*c + c",r:"(n+1)*c"},{s:"c*n + c -> c*(n+1)",assuming:{multiply:{commutative:!1}}},d,{s:"(-n)*n1 -> -(n*n1)",assuming:{subtract:{total:!0}}},{s:"n1*(-n) -> -(n1*n)",assuming:{subtract:{total:!0},multiply:{commutative:!1}}},{s:"c+v -> v+c",assuming:{add:{commutative:!0}},imposeContext:{add:{commutative:!1}}},{s:"v*c -> c*v",assuming:{multiply:{commutative:!0}},imposeContext:{multiply:{commutative:!1}}},{l:"n+-n1",r:"n-n1"},{s:"n*(n1^-1) -> n/n1",assuming:{multiply:{commutative:!0}}},{s:"n*n1^-n2 -> n/n1^n2",assuming:{multiply:{commutative:!0}}},{s:"n^-1 -> 1/n",assuming:{multiply:{commutative:!0}}},{l:"n^1",r:"n"},{s:"n*(n1/n2) -> (n*n1)/n2",assuming:{multiply:{associative:!0}}},{s:"n-(n1+n2) -> n-n1-n2",assuming:{addition:{associative:!0,commutative:!0}}},{l:"1*n",r:"n",imposeContext:{multiply:{commutative:!0}}},{s:"n1/(n2/n3) -> (n1*n3)/n2",assuming:{multiply:{associative:!0}}},{l:"n1/(-n2)",r:"-n1/n2"}];var j=0;function U(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:vV(),r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},a=r.consoleDebug;t=H(t||Y.rules,r.context);for(var i=p(e,n),s={},o=(i=B(i)).toString({parenthesis:"all"});!s[o];){s[o]=!0,j=0;var u=o;a&&console.log("Working on: ",o);for(var l=0;l ").concat(t[l].r.toString()))),a){var d=i.toString({parenthesis:"all"});d!==u&&(console.log("Applying",c,"produced",d),u=d)}L(i,r.context)}o=i.toString({parenthesis:"all"})}return i}function q(e,t,n){var r=e;if(e)for(var a=0;a=2&&2===e.args.length){for(var i=function(e,t){var n,r,a=[],i=F(e);if(T(e,t))for(var s=0;s1&&(u=i(e.args.slice(0,o))),n=1===(r=e.args.slice(o)).length?r[0]:i(r),a.push(i([u,n]))}return a}(t,n),s=[],o=0;o2)throw Error("Unexpected non-binary associative function: "+e.toString());return[]}for(var l=[],p=0;p2)throw new Error("permuting >2 commutative non-associative rule arguments not yet implemented");var h=K(e.args[0],t.args[1],n);if(0===h.length)return[];var f=K(e.args[1],t.args[0],n);if(0===f.length)return[];l=[h,f]}a=function(e){if(0===e.length)return e;for(var t=e.reduce(G),n=[],r={},a=0;a{var{parse:t,simplify:n,typed:r,OperatorNode:a}=e;function i(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=new a("-","subtract",[e,t]),s=n(i,{},r);return cH(s)&&!s.value}return r(dee,{"Node, Node":i,"Node, Node, Object":i})})),fee="derivative",mee=_U(fee,["typed","config","parse","simplify","equal","isZero","numeric","ConstantNode","FunctionNode","OperatorNode","ParenthesisNode","SymbolNode"],(e=>{var{typed:t,config:n,parse:r,simplify:a,equal:i,isZero:s,numeric:o,ConstantNode:u,FunctionNode:l,OperatorNode:c,ParenthesisNode:p,SymbolNode:d}=e;function h(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{simplify:!0},r={};g(r,e,t.name);var i=y(e,r);return n.simplify?a(i):i}t.addConversion({from:"identifier",to:"SymbolNode",convert:r});var f=t(fee,{"Node, SymbolNode":h,"Node, SymbolNode, Object":h});t.removeConversion({from:"identifier",to:"SymbolNode",convert:r}),f._simplify=!0,f.toTex=function(e){return m.apply(null,e.args)};var m=t("_derivTex",{"Node, SymbolNode":function(e,t){return cH(e)&&"string"===wH(e.value)?m(r(e.value).toString(),t.toString(),1):m(e.toTex(),t.toString(),1)},"Node, ConstantNode":function(e,t){if("string"===wH(t.value))return m(e,r(t.value));throw new Error("The second parameter to 'derivative' is a non-string constant")},"Node, SymbolNode, ConstantNode":function(e,t,n){return m(e.toString(),t.name,n.value)},"string, string, number":function(e,t,n){return(1===n?"{d\\over d"+t+"}":"{d^{"+n+"}\\over d"+t+"^{"+n+"}}")+"\\left[".concat(e,"\\right]")}}),g=t("constTag",{"Object, ConstantNode, string":function(e,t){return e[t]=!0,!0},"Object, SymbolNode, string":function(e,t,n){return t.name!==n&&(e[t]=!0,!0)},"Object, ParenthesisNode, string":function(e,t,n){return g(e,t.content,n)},"Object, FunctionAssignmentNode, string":function(e,t,n){return-1===t.params.indexOf(n)?(e[t]=!0,!0):g(e,t.expr,n)},"Object, FunctionNode | OperatorNode, string":function(e,t,n){if(t.args.length>0){for(var r=g(e,t.args[0],n),a=1;a0){var r=e.args.filter((function(e){return void 0===t[e]})),a=1===r.length?r[0]:new c("*","multiply",r),o=n.concat(y(a,t));return new c("*","multiply",o)}return new c("+","add",e.args.map((function(n){return new c("*","multiply",e.args.map((function(e){return e===n?y(e,t):e.clone()})))})))}if("/"===e.op&&e.isBinary()){var u=e.args[0],p=e.args[1];return void 0!==t[p]?new c("/","divide",[y(u,t),p]):void 0!==t[u]?new c("*","multiply",[new c("-","unaryMinus",[u]),new c("/","divide",[y(p,t),new c("^","pow",[p.clone(),b(2)])])]):new c("/","divide",[new c("-","subtract",[new c("*","multiply",[y(u,t),p.clone()]),new c("*","multiply",[u.clone(),y(p,t)])]),new c("^","pow",[p.clone(),b(2)])])}if("^"===e.op&&e.isBinary()){var d=e.args[0],h=e.args[1];if(void 0!==t[d])return cH(d)&&(s(d.value)||i(d.value,1))?b(0):new c("*","multiply",[e,new c("*","multiply",[new l("log",[d.clone()]),y(h.clone(),t)])]);if(void 0!==t[h]){if(cH(h)){if(s(h.value))return b(0);if(i(h.value,1))return y(d,t)}var f=new c("^","pow",[d.clone(),new c("-","subtract",[h,b(1)])]);return new c("*","multiply",[h.clone(),new c("*","multiply",[y(d,t),f])])}return new c("*","multiply",[new c("^","pow",[d.clone(),h.clone()]),new c("+","add",[new c("*","multiply",[y(d,t),new c("/","divide",[h.clone(),d.clone()])]),new c("*","multiply",[y(h,t),new l("log",[d.clone()])])])])}throw new Error('Operator "'+e.op+'" is not supported by derivative, or a wrong number of arguments is passed')}});function b(e,t){return new u(o(e,t||n.number))}return f})),gee="rationalize",yee=_U(gee,["config","typed","equal","isZero","add","subtract","multiply","divide","pow","parse","simplifyConstant","simplifyCore","simplify","?bignumber","?fraction","mathWithTransform","matrix","AccessorNode","ArrayNode","ConstantNode","FunctionNode","IndexNode","ObjectNode","OperatorNode","SymbolNode","ParenthesisNode"],(e=>{var{config:t,typed:n,equal:r,isZero:a,add:i,subtract:s,multiply:o,divide:u,pow:l,parse:c,simplifyConstant:p,simplifyCore:d,simplify:h,fraction:f,bignumber:m,mathWithTransform:g,matrix:y,AccessorNode:b,ArrayNode:v,ConstantNode:x,FunctionNode:_,IndexNode:w,ObjectNode:D,OperatorNode:N,SymbolNode:M,ParenthesisNode:S}=e;function k(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=C(),a=T(e,t,!0,r.firstRules),i=a.variables.length,s={exactFractions:!1},o={exactFractions:!0};if(e=a.expression,i>=1){var u,l;e=E(e);var c,p=!0,d=!1;for(e=h(e,r.firstRules,{},s);l=p?r.distrDivRules:r.sucDivRules,p=!p,(c=(e=h(e,l,{},o)).toString())!==u;)d=!0,u=c;d&&(e=h(e,r.firstRulesAgain,{},s)),e=h(e,r.finalRules,{},s)}var f=[],m={};return"OperatorNode"===e.type&&e.isBinary()&&"/"===e.op?(1===i&&(e.args[0]=A(e.args[0],f),e.args[1]=A(e.args[1])),n&&(m.numerator=e.args[0],m.denominator=e.args[1])):(1===i&&(e=A(e,f)),n&&(m.numerator=e,m.denominator=null)),n?(m.coefficients=f,m.variables=a.variables,m.expression=e,m):e}return n(gee,{Node:k,"Node, boolean":(e,t)=>k(e,{},t),"Node, Object":k,"Node, Object, boolean":k});function T(e,t,n,r){var a=[],i=h(e,r,t,{exactFractions:!1}),s="+-*"+((n=!!n)?"/":"");!function e(t){var n=t.type;if("FunctionNode"===n)throw new Error("There is an unsolved function call");if("OperatorNode"===n)if("^"===t.op){if("ConstantNode"!==t.args[1].type||!SU(parseFloat(t.args[1].value)))throw new Error("There is a non-integer exponent");e(t.args[0])}else{if(-1===s.indexOf(t.op))throw new Error("Operator "+t.op+" invalid in polynomial expression");for(var r=0;r1;if("OperatorNode"===r&&e.isBinary()){var i,s=!1;if("^"===e.op&&("ParenthesisNode"!==e.args[0].type&&"OperatorNode"!==e.args[0].type||"ConstantNode"!==e.args[1].type||(s=(i=parseFloat(e.args[1].value))>=2&&SU(i))),s){if(i>2){var o=e.args[0],u=new N("^","pow",[e.args[0].cloneDeep(),new x(i-1)]);e=new N("*","multiply",[o,u])}else e=new N("*","multiply",[e.args[0],e.args[0].cloneDeep()]);a&&("content"===n?t.content=e:t.args[n]=e)}}if("ParenthesisNode"===r)E(e.content,e,"content");else if("ConstantNode"!==r&&"SymbolNode"!==r)for(var l=0;ln&&(t[l]=0),t[l]+=s.cte*("+"===s.oper?1:-1),void(n=Math.max(l,n))}s.cte=l,""===s.fire&&(t[0]+=s.cte*("+"===s.oper?1:-1))}}(e,null,{cte:1,oper:"+",fire:""});for(var a,i=!0,s=n=t.length-1;s>=0;s--)if(0!==t[s]){var o=new x(i?t[s]:Math.abs(t[s])),u=t[s]<0?"-":"+";if(s>0){var l=new M(r);if(s>1){var c=new x(s);l=new N("^","pow",[l,c])}o=-1===t[s]&&i?new N("-","unaryMinus",[l]):1===Math.abs(t[s])?l:new N("*","multiply",[o,l])}a=i?o:"+"===u?new N("+","add",[a,o]):new N("-","subtract",[a,o]),i=!1}return i?new x(0):a}}));function bee(e,t,n){var r=e.filter((function(e){return xH(e)&&!(e.name in t)&&!n.has(e.name)}))[0];if(!r)throw new Error('No undefined variable found in inline expression "'+e+'"');var a=r.name,i=Y9(n),s=e.compile();return function(e){return i.set(a,e),s.evaluate(i)}}var vee=_U("filter",["typed"],(e=>{var{typed:t}=e;function n(e,t,n){var a,i;return e[0]&&(a=e[0].compile().evaluate(n)),e[1]&&(i=xH(e[1])||dH(e[1])?e[1].compile().evaluate(n):bee(e[1],t,n)),r(a,i)}n.rawArgs=!0;var r=t("filter",{"Array, function":xee,"Matrix, function":function(e,t){return e.create(xee(e.toArray(),t))},"Array, RegExp":nV,"Matrix, RegExp":function(e,t){return e.create(nV(e.toArray(),t))}});return n}),{isTransformFunction:!0});function xee(e,t){var n=XU(t);return tV(e,(function(e,r,a){return 1===n?t(e):2===n?t(e,[r+1]):t(e,[r+1],a)}))}var _ee=_U("forEach",["typed"],(e=>{var{typed:t}=e;function n(e,t,n){var a,i;return e[0]&&(a=e[0].compile().evaluate(n)),e[1]&&(i=xH(e[1])||dH(e[1])?e[1].compile().evaluate(n):bee(e[1],t,n)),r(a,i)}n.rawArgs=!0;var r=t("forEach",{"Array | Matrix, function":function(e,t){var n=XU(t);!function r(a,i){Array.isArray(a)?eV(a,(function(e,t){r(e,i.concat(t+1))})):1===n?t(a):2===n?t(a,i):t(a,i,e)}(e.valueOf(),[])}});return n}),{isTransformFunction:!0}),wee=_U("map",["typed"],(e=>{var{typed:t}=e;function n(e,t,n){var a,i;return e[0]&&(a=e[0].compile().evaluate(n)),e[1]&&(i=xH(e[1])||dH(e[1])?e[1].compile().evaluate(n):bee(e[1],t,n)),r(a,i)}n.rawArgs=!0;var r=t("map",{"Array, function":function(e,t){return Dee(e,t,e)},"Matrix, function":function(e,t){return e.create(Dee(e.valueOf(),t,e))}});return n}),{isTransformFunction:!0});function Dee(e,t,n){var r=XU(t);return function e(a,i){return Array.isArray(a)?QW(a,(function(t,n){return e(t,i.concat(n+1))})):1===r?t(a):2===r?t(a,i):t(a,i,n)}(e,[])}var Nee=_U("apply",["typed","isInteger"],(e=>{var{typed:t,isInteger:n}=e,r=iX({typed:t,isInteger:n});return t("apply",{"...any":function(e){var t=e[1];RP(t)?e[1]=t-1:YP(t)&&(e[1]=t.minus(1));try{return r.apply(null,e)}catch(e){throw C9(e)}}})}),{isTransformFunction:!0});function Mee(e){if(2===e.length&&qP(e[0])){var t=(e=e.slice())[1];RP(t)?e[1]=t-1:YP(t)&&(e[1]=t.minus(1))}return e}var See="diff",kee=_U(See,["typed","matrix","subtract","number","bignumber"],(e=>{var{typed:t,matrix:n,subtract:r,number:a,bignumber:i}=e,s=_0({typed:t,matrix:n,subtract:r,number:a,bignumber:i});return t(See,{"...any":function(e){e=Mee(e);try{return s.apply(null,e)}catch(e){throw C9(e)}}})}),{isTransformFunction:!0}),Tee=_U("subset",["typed","matrix"],(e=>{var{typed:t,matrix:n}=e,r=xZ({typed:t,matrix:n});return t("subset",{"...any":function(e){try{return r.apply(null,e)}catch(e){throw C9(e)}}})}),{isTransformFunction:!0}),Cee=_U("concat",["typed","matrix","isInteger"],(e=>{var{typed:t,matrix:n,isInteger:r}=e,a=KZ({typed:t,matrix:n,isInteger:r});return t("concat",{"...any":function(e){var t=e.length-1,n=e[t];RP(n)?e[t]=n-1:YP(n)&&(e[t]=n.minus(1));try{return a.apply(null,e)}catch(e){throw C9(e)}}})}),{isTransformFunction:!0}),Eee=_U("max",["typed","config","numeric","larger"],(e=>{var{typed:t,config:n,numeric:r,larger:a}=e,i=B1({typed:t,config:n,numeric:r,larger:a});return t("max",{"...any":function(e){e=Mee(e);try{return i.apply(null,e)}catch(e){throw C9(e)}}})}),{isTransformFunction:!0}),Aee=_U("min",["typed","config","numeric","smaller"],(e=>{var{typed:t,config:n,numeric:r,smaller:a}=e,i=$Q({typed:t,config:n,numeric:r,smaller:a});return t("min",{"...any":function(e){e=Mee(e);try{return i.apply(null,e)}catch(e){throw C9(e)}}})}),{isTransformFunction:!0}),Iee=_U("range",["typed","config","?matrix","?bignumber","smaller","smallerEq","larger","largerEq"],(e=>{var{typed:t,config:n,matrix:r,bignumber:a,smaller:i,smallerEq:s,larger:o,largerEq:u}=e,l=q0({typed:t,config:n,matrix:r,bignumber:a,smaller:i,smallerEq:s,larger:o,largerEq:u});return t("range",{"...any":function(e){return"boolean"!=typeof e[e.length-1]&&e.push(!0),l.apply(null,e)}})}),{isTransformFunction:!0}),Lee=_U("sum",["typed","config","add","numeric"],(e=>{var{typed:t,config:n,add:r,numeric:a}=e,i=l1({typed:t,config:n,add:r,numeric:a});return t("sum",{"...any":function(e){e=Mee(e);try{return i.apply(null,e)}catch(e){throw C9(e)}}})}),{isTransformFunction:!0}),Fee="cumsum",$ee=_U(Fee,["typed","add","unaryPlus"],(e=>{var{typed:t,add:n,unaryPlus:r}=e,a=y0({typed:t,add:n,unaryPlus:r});return t(Fee,{"...any":function(e){if(2===e.length&&qP(e[0])){var t=e[1];RP(t)?e[1]=t-1:YP(t)&&(e[1]=t.minus(1))}try{return a.apply(null,e)}catch(e){throw C9(e)}}})}),{isTransformFunction:!0}),Oee=_U("row",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:n,matrix:r,range:a}=e,i=P1({typed:t,Index:n,matrix:r,range:a});return t("row",{"...any":function(e){var t=e.length-1,n=e[t];RP(n)&&(e[t]=n-1);try{return i.apply(null,e)}catch(e){throw C9(e)}}})}),{isTransformFunction:!0}),Ree=_U("column",["typed","Index","matrix","range"],(e=>{var{typed:t,Index:n,matrix:r,range:a}=e,i=Q1({typed:t,Index:n,matrix:r,range:a});return t("column",{"...any":function(e){var t=e.length-1,n=e[t];RP(n)&&(e[t]=n-1);try{return i.apply(null,e)}catch(e){throw C9(e)}}})}),{isTransformFunction:!0}),Yee=_U("index",["Index"],(e=>{var{Index:t}=e;return function(){for(var e=[],n=0,r=arguments.length;n0?0:2;else if(a&&!0===a.isSet)a=a.map((function(e){return e-1}));else if(jP(a)||UP(a))a=a.map((function(e){return e-1}));else if(RP(a))a--;else if(YP(a))a=a.toNumber()-1;else if("string"!=typeof a)throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");e[n]=a}var i=new t;return t.apply(i,e),i}}),{isTransformFunction:!0}),Bee=_U("mean",["typed","add","divide"],(e=>{var{typed:t,add:n,divide:r}=e,a=U2({typed:t,add:n,divide:r});return t("mean",{"...any":function(e){e=Mee(e);try{return a.apply(null,e)}catch(e){throw C9(e)}}})}),{isTransformFunction:!0}),zee="variance",Pee=_U(zee,["typed","add","subtract","multiply","divide","apply","isNaN"],(e=>{var{typed:t,add:n,subtract:r,multiply:a,divide:i,apply:s,isNaN:o}=e,u=K2({typed:t,add:n,subtract:r,multiply:a,divide:i,apply:s,isNaN:o});return t(zee,{"...any":function(e){e=Mee(e);try{return u.apply(null,e)}catch(e){throw C9(e)}}})}),{isTransformFunction:!0}),Hee=_U("std",["typed","map","sqrt","variance"],(e=>{var{typed:t,map:n,sqrt:r,variance:a}=e,i=o3({typed:t,map:n,sqrt:r,variance:a});return t("std",{"...any":function(e){e=Mee(e);try{return i.apply(null,e)}catch(e){throw C9(e)}}})}),{isTransformFunction:!0}),jee={},Uee={},qee={},Wee=q7({mathWithTransform:Uee}),Vee=V7({Node:Wee}),Gee=u9({Node:Wee}),Kee=c9({Node:Wee}),Jee=d9({Node:Wee}),Xee=f9({Node:Wee}),Zee=g9({Node:Wee,ResultSet:R3}),Qee=b9({Node:Wee}),ete=x9({Node:Wee}),tte=w9({Node:Wee}),nte=D9({classes:qee}),rte=N9({math:jee,typed:K3}),ate=S9({Node:Wee,typed:K3}),ite=T9({Chain:rte,typed:K3}),ste=I9({Node:Wee,subset:F5}),ote=F9({matrix:D5,Node:Wee,subset:F5}),ute=O9({Node:Wee,size:A5}),lte=R9({Unit:M6,Node:Wee,math:jee}),cte=z9({Node:Wee,SymbolNode:lte,math:jee}),pte=H9({AccessorNode:ste,ArrayNode:Xee,AssignmentNode:ote,BlockNode:Zee,ConditionalNode:Qee,ConstantNode:ete,FunctionAssignmentNode:ate,FunctionNode:cte,IndexNode:ute,ObjectNode:Vee,OperatorNode:Gee,ParenthesisNode:Kee,RangeNode:tte,RelationalNode:Jee,SymbolNode:lte,config:RH,numeric:k5,typed:K3}),dte=j9({ConstantNode:ete,FunctionNode:cte,OperatorNode:Gee,ParenthesisNode:Kee,parse:pte,typed:K3}),hte=V9({bignumber:u4,fraction:_5,AccessorNode:ste,ArrayNode:Xee,ConstantNode:ete,FunctionNode:cte,IndexNode:ute,ObjectNode:Vee,OperatorNode:Gee,SymbolNode:lte,config:RH,mathWithTransform:Uee,matrix:D5,parse:pte,typed:K3}),fte=K9({parse:pte,typed:K3}),mte=J9({parse:pte}),gte=Z9({parse:pte,typed:K3}),yte=eee({AccessorNode:ste,ArrayNode:Xee,ConstantNode:ete,FunctionNode:cte,IndexNode:ute,ObjectNode:Vee,OperatorNode:Gee,ParenthesisNode:Kee,SymbolNode:lte,add:w8,divide:l7,equal:Z5,isZero:I4,multiply:B8,parse:pte,pow:x6,subtract:$5,typed:K3}),bte=nee({parse:pte,typed:K3}),vte=oee({Help:mte,mathWithTransform:Uee,typed:K3}),xte=uee({evaluate:bte}),_te=cee({Parser:xte,typed:K3}),wte=pee({bignumber:u4,fraction:_5,AccessorNode:ste,ArrayNode:Xee,ConstantNode:ete,FunctionNode:cte,IndexNode:ute,ObjectNode:Vee,OperatorNode:Gee,ParenthesisNode:Kee,SymbolNode:lte,add:w8,config:RH,divide:l7,equal:Z5,isZero:I4,mathWithTransform:Uee,matrix:D5,multiply:B8,parse:pte,pow:x6,resolve:dte,simplifyConstant:hte,simplifyCore:yte,subtract:$5,typed:K3}),Dte=hee({OperatorNode:Gee,parse:pte,simplify:wte,typed:K3}),Nte=mee({ConstantNode:ete,FunctionNode:cte,OperatorNode:Gee,ParenthesisNode:Kee,SymbolNode:lte,config:RH,equal:Z5,isZero:I4,numeric:k5,parse:pte,simplify:wte,typed:K3}),Mte=yee({bignumber:u4,fraction:_5,AccessorNode:ste,ArrayNode:Xee,ConstantNode:ete,FunctionNode:cte,IndexNode:ute,ObjectNode:Vee,OperatorNode:Gee,ParenthesisNode:Kee,SymbolNode:lte,add:w8,config:RH,divide:l7,equal:Z5,isZero:I4,mathWithTransform:Uee,matrix:D5,multiply:B8,parse:pte,pow:x6,simplify:wte,simplifyConstant:hte,simplifyCore:yte,subtract:$5,typed:K3});$P(jee,{e:N3,false:M3,fineStructure:S3,i:T3,Infinity:C3,LN10:E3,LOG10E:A3,NaN:L3,null:F3,phi:$3,SQRT1_2:Y3,sackurTetrode:B3,tau:z3,true:P3,E:N3,version:H3,efimovFactor:U3,LN2:q3,pi:W3,replacer:V3,reviver:nte,SQRT2:G3,typed:K3,unaryPlus:J3,PI:W3,weakMixingAngle:X3,abs:Z3,acos:Q3,acot:e4,acsc:t4,addScalar:n4,arg:r4,asech:a4,asinh:i4,atan:s4,atanh:o4,bignumber:u4,bitNot:l4,boolean:c4,clone:p4,combinations:d4,complex:h4,conj:f4,cosh:m4,coth:g4,csc:y4,cube:b4,equalScalar:v4,erf:x4,exp:_4,expm1:w4,filter:D4,forEach:N4,format:M4,getMatrixDataType:S4,hex:k4,im:T4,isInteger:C4,isNegative:E4,isPositive:A4,isZero:I4,LOG2E:L4,lgamma:F4,log10:$4,log2:O4,map:R4,multiplyScalar:Y4,not:B4,number:z4,oct:P4,pickRandom:H4,print:j4,random:U4,re:q4,sec:W4,sign:V4,sin:G4,splitUnit:J4,square:X4,string:Z4,tan:Q4,typeOf:e5,acosh:t5,acsch:n5,apply:r5,asec:a5,bin:i5,chain:ite,combinationsWithRep:s5,cos:o5,csch:u5,isNaN:l5,isPrime:c5,randomInt:d5,sech:h5,sinh:f5,sparse:m5,sqrt:g5,tanh:y5,unaryMinus:b5,acoth:v5,cot:x5,fraction:_5,isNumeric:w5,matrix:D5,matrixFromFunction:N5,mod:M5,nthRoot:S5,numeric:k5,or:T5,prod:C5,reshape:E5,size:A5,smaller:I5,squeeze:L5,subset:F5,subtract:$5,to:O5,transpose:R5,xgcd:Y5,zeros:B5,and:z5,bitAnd:P5,bitXor:H5,cbrt:j5,compare:U5,compareText:q5,concat:W5,count:V5,ctranspose:G5,diag:K5,divideScalar:J5,dotDivide:X5,equal:Z5,fft:Q5,flatten:e8,gcd:t8,hasNumericValue:n8,hypot:r8,ifft:a8,kron:i8,largerEq:s8,leftShift:o8,lsolve:u8,matrixFromColumns:l8,min:c8,mode:p8,nthRoots:d8,ones:h8,partitionSelect:f8,resize:m8,rightArithShift:g8,round:y8,smallerEq:b8,unequal:v8,usolve:x8,xor:_8,add:w8,atan2:D8,bitOr:N8,catalan:M8,compareNatural:S8,cumsum:k8,deepEqual:T8,diff:C8,dot:E8,equalText:A8,floor:I8,identity:L8,invmod:F8,larger:$8,log:O8,lsolveAll:R8,matrixFromRows:Y8,multiply:B8,qr:z8,range:P8,rightLogShift:H8,setSize:j8,slu:U8,sum:q8,trace:W8,usolveAll:V8,asin:G8,ceil:K8,composition:J8,cross:X8,det:Z8,distance:Q8,dotMultiply:e6,fix:n6,intersect:i6,lcm:s6,log1p:o6,max:u6,quantileSeq:l6,row:c6,setCartesian:p6,setDistinct:d6,setIsSubset:h6,setPowerset:f6,sort:m6,column:g6,index:y6,inv:b6,pinv:v6,pow:x6,setDifference:_6,setMultiplicity:w6,sqrtm:N6,vacuumImpedance:S6,wienDisplacement:k6,atomicMass:T6,bohrMagneton:C6,boltzmann:E6,conductanceQuantum:A6,createUnit:I6,deuteronMass:L6,dotPow:F6,electricConstant:$6,elementaryCharge:O6,expm:R6,faraday:Y6,firstRadiation:B6,gamma:z6,gravitationConstant:P6,hartreeEnergy:H6,klitzing:j6,loschmidt:U6,magneticConstant:q6,molarMass:W6,molarPlanckConstant:V6,neutronMass:G6,nuclearMagneton:K6,planckCharge:J6,planckLength:X6,planckTemperature:Z6,protonMass:Q6,reducedPlanckConstant:e7,rydberg:t7,setIntersect:n7,speedOfLight:r7,stefanBoltzmann:a7,thomsonCrossSection:i7,avogadro:s7,bohrRadius:o7,coulomb:u7,divide:l7,electronMass:c7,factorial:p7,gravity:d7,inverseConductanceQuantum:h7,lup:f7,magneticFluxQuantum:m7,molarMassC12:g7,multinomial:y7,parse:pte,permutations:b7,planckMass:v7,quantumOfCirculation:x7,resolve:dte,secondRadiation:_7,simplifyConstant:hte,stirlingS2:w7,unit:D7,bellNumbers:N7,compile:fte,eigs:M7,fermiCoupling:S7,leafCount:gte,mean:k7,molarVolume:T7,planckConstant:C7,setSymDifference:E7,simplifyCore:yte,variance:A7,classicalElectronRadius:I7,evaluate:bte,help:vte,lusolve:L7,median:F7,setUnion:$7,std:O7,gasConstant:R7,mad:Y7,parser:_te,simplify:wte,symbolicEqual:Dte,derivative:Nte,norm:B7,rationalize:Mte,rotationMatrix:z7,kldivergence:P7,rotate:H7,planckTime:j7,config:RH}),$P(Uee,jee,{filter:vee({typed:K3}),forEach:_ee({typed:K3}),map:wee({typed:K3}),apply:Nee({isInteger:C4,typed:K3}),diff:kee({bignumber:u4,matrix:D5,number:z4,subtract:$5,typed:K3}),subset:Tee({matrix:D5,typed:K3}),concat:Cee({isInteger:C4,matrix:D5,typed:K3}),max:Eee({config:RH,larger:$8,numeric:k5,typed:K3}),min:Aee({config:RH,numeric:k5,smaller:I5,typed:K3}),range:Iee({bignumber:u4,matrix:D5,config:RH,larger:$8,largerEq:s8,smaller:I5,smallerEq:b8,typed:K3}),sum:Lee({add:w8,config:RH,numeric:k5,typed:K3}),cumsum:$ee({add:w8,typed:K3,unaryPlus:J3}),row:Oee({Index:a6,matrix:D5,range:P8,typed:K3}),column:Ree({Index:a6,matrix:D5,range:P8,typed:K3}),index:Yee({Index:a6}),mean:Bee({add:w8,divide:l7,typed:K3}),variance:Pee({add:w8,apply:r5,divide:l7,isNaN:l5,multiply:B8,subtract:$5,typed:K3}),std:Hee({map:R4,sqrt:g5,typed:K3,variance:A7})}),$P(qee,{BigNumber:w3,Complex:D3,Fraction:k3,Matrix:I3,Node:Wee,ObjectNode:Vee,OperatorNode:Gee,ParenthesisNode:Kee,Range:O3,RelationalNode:Jee,ResultSet:R3,ArrayNode:Xee,BlockNode:Zee,ConditionalNode:Qee,ConstantNode:ete,DenseMatrix:j3,RangeNode:tte,Chain:rte,FunctionAssignmentNode:ate,SparseMatrix:K4,AccessorNode:ste,AssignmentNode:ote,IndexNode:ute,FibonacciHeap:t6,ImmutableDenseMatrix:r6,Index:a6,Spa:D6,Unit:M6,SymbolNode:lte,FunctionNode:cte,Help:mte,Parser:xte}),rte.createProxy(jee);var Ste={createBigNumberClass:NU},kte={createComplexClass:GU},Tte={createMatrixClass:SW},Cte={MatrixDependencies:Tte,createDenseMatrixClass:uV},Ete={createFractionClass:MW},Ate={BigNumberDependencies:Ste,ComplexDependencies:kte,DenseMatrixDependencies:Cte,FractionDependencies:Ete,createTyped:NV},Ite={typedDependencies:Ate,createAbs:iG},Lte={createNode:q7},Fte={typedDependencies:Ate,createEqualScalar:SK},$te={MatrixDependencies:Tte,equalScalarDependencies:Fte,typedDependencies:Ate,createSparseMatrixClass:UJ},Ote={DenseMatrixDependencies:Cte,MatrixDependencies:Tte,SparseMatrixDependencies:$te,typedDependencies:Ate,createMatrix:BX},Rte={matrixDependencies:Ote,typedDependencies:Ate,createSubset:xZ},Yte={NodeDependencies:Lte,subsetDependencies:Rte,createAccessorNode:I9},Bte={ComplexDependencies:kte,typedDependencies:Ate,createAcos:oG},zte={ComplexDependencies:kte,typedDependencies:Ate,createAcosh:tX},Pte={BigNumberDependencies:Ste,typedDependencies:Ate,createAcot:SG},Hte={BigNumberDependencies:Ste,ComplexDependencies:kte,typedDependencies:Ate,createAcoth:LX},jte={BigNumberDependencies:Ste,ComplexDependencies:kte,typedDependencies:Ate,createAcsc:TG},Ute={BigNumberDependencies:Ste,typedDependencies:Ate,createAcsch:rX},qte={typedDependencies:Ate,createAddScalar:EG},Wte={DenseMatrixDependencies:Cte,SparseMatrixDependencies:$te,addScalarDependencies:qte,equalScalarDependencies:Fte,matrixDependencies:Ote,typedDependencies:Ate,createAdd:i0},Vte={typedDependencies:Ate,createNot:SJ},Gte={BigNumberDependencies:Ste,matrixDependencies:Ote,typedDependencies:Ate,createZeros:FZ},Kte={equalScalarDependencies:Fte,matrixDependencies:Ote,notDependencies:Vte,typedDependencies:Ate,zerosDependencies:Gte,createAnd:$Z},Jte={typedDependencies:Ate,createIsInteger:GK},Xte={isIntegerDependencies:Jte,typedDependencies:Ate,createApply:iX},Zte={isIntegerDependencies:Jte,typedDependencies:Ate,createApplyTransform:Nee},Qte={typedDependencies:Ate,createArg:AG},ene={NodeDependencies:Lte,createArrayNode:f9},tne={BigNumberDependencies:Ste,ComplexDependencies:kte,typedDependencies:Ate,createAsec:uX},nne={BigNumberDependencies:Ste,ComplexDependencies:kte,typedDependencies:Ate,createAsech:LG},rne={ComplexDependencies:kte,typedDependencies:Ate,createAsin:f1},ane={typedDependencies:Ate,createAsinh:FG},ine={matrixDependencies:Ote,NodeDependencies:Lte,subsetDependencies:Rte,createAssignmentNode:F9},sne={typedDependencies:Ate,createAtan:$G},one={BigNumberDependencies:Ste,DenseMatrixDependencies:Cte,equalScalarDependencies:Fte,matrixDependencies:Ote,typedDependencies:Ate,createAtan2:u0},une={ComplexDependencies:kte,typedDependencies:Ate,createAtanh:RG},lne={BigNumberDependencies:Ste,typedDependencies:Ate,createBignumber:YG},cne={FractionDependencies:Ete,typedDependencies:Ate,createFraction:$X},pne={typedDependencies:Ate,createNumber:kJ},dne={bignumberDependencies:lne,fractionDependencies:cne,numberDependencies:pne,createNumeric:aZ},hne={numericDependencies:dne,typedDependencies:Ate,createDivideScalar:aQ},fne={DenseMatrixDependencies:Cte,equalScalarDependencies:Fte,matrixDependencies:Ote,typedDependencies:Ate,createEqual:uQ},mne={BigNumberDependencies:Ste,DenseMatrixDependencies:Cte,equalScalarDependencies:Fte,matrixDependencies:Ote,typedDependencies:Ate,zerosDependencies:Gte,createRound:KQ},gne={DenseMatrixDependencies:Cte,equalScalarDependencies:Fte,matrixDependencies:Ote,roundDependencies:mne,typedDependencies:Ate,zerosDependencies:Gte,createCeil:b1},yne={DenseMatrixDependencies:Cte,equalScalarDependencies:Fte,matrixDependencies:Ote,roundDependencies:mne,typedDependencies:Ate,zerosDependencies:Gte,createFloor:T0},bne={ComplexDependencies:kte,DenseMatrixDependencies:Cte,ceilDependencies:gne,equalScalarDependencies:Fte,floorDependencies:yne,matrixDependencies:Ote,typedDependencies:Ate,zerosDependencies:Gte,createFix:I1},vne={typedDependencies:Ate,createFormat:HK},xne={typedDependencies:Ate,createIsNumeric:RX},_ne={typedDependencies:Ate,createMultiplyScalar:xJ},wne={BigNumberDependencies:Ste,DenseMatrixDependencies:Cte,SparseMatrixDependencies:$te,matrixDependencies:Ote,typedDependencies:Ate,createIdentity:E0},Dne={typedDependencies:Ate,createIsZero:iJ},Nne={typedDependencies:Ate,createConj:fK},Mne={matrixDependencies:Ote,typedDependencies:Ate,createSize:dZ},Sne={addScalarDependencies:qte,conjDependencies:Nne,multiplyScalarDependencies:_ne,sizeDependencies:Mne,typedDependencies:Ate,createDot:w0},kne={addScalarDependencies:qte,dotDependencies:Sne,equalScalarDependencies:Fte,matrixDependencies:Ote,multiplyScalarDependencies:_ne,typedDependencies:Ate,createMultiply:H0},Tne={typedDependencies:Ate,createUnaryMinus:AX},Cne={DenseMatrixDependencies:Cte,addScalarDependencies:qte,equalScalarDependencies:Fte,matrixDependencies:Ote,typedDependencies:Ate,unaryMinusDependencies:Tne,createSubtract:kZ},Ene={divideScalarDependencies:hne,isZeroDependencies:Dne,matrixDependencies:Ote,multiplyDependencies:kne,subtractDependencies:Cne,typedDependencies:Ate,unaryMinusDependencies:Tne,createDet:D1},Ane={absDependencies:Ite,addScalarDependencies:qte,detDependencies:Ene,divideScalarDependencies:hne,identityDependencies:wne,matrixDependencies:Ote,multiplyDependencies:kne,typedDependencies:Ate,unaryMinusDependencies:Tne,createInv:n2},Ine={ComplexDependencies:kte,fractionDependencies:cne,identityDependencies:wne,invDependencies:Ane,matrixDependencies:Ote,multiplyDependencies:kne,numberDependencies:pne,typedDependencies:Ate,createPow:i2},Lne={BigNumberDependencies:Ste,ComplexDependencies:kte,FractionDependencies:Ete,absDependencies:Ite,addScalarDependencies:qte,divideScalarDependencies:hne,equalDependencies:fne,fixDependencies:bne,formatDependencies:vne,isNumericDependencies:xne,multiplyScalarDependencies:_ne,numberDependencies:pne,powDependencies:Ine,roundDependencies:mne,subtractDependencies:Cne,createUnitClass:g2},Fne={BigNumberDependencies:Ste,UnitDependencies:Lne,createAtomicMass:tW},$ne={BigNumberDependencies:Ste,UnitDependencies:Lne,createAvogadro:nW},One={typedDependencies:Ate,createIsNegative:tJ},Rne={typedDependencies:Ate,createCombinations:cK},Yne={BigNumberDependencies:Ste,ComplexDependencies:kte,multiplyScalarDependencies:_ne,powDependencies:Ine,typedDependencies:Ate,createGamma:N2},Bne={gammaDependencies:Yne,typedDependencies:Ate,createFactorial:C2},zne={DenseMatrixDependencies:Cte,matrixDependencies:Ote,typedDependencies:Ate,createLarger:F0},Pne={bignumberDependencies:lne,addScalarDependencies:qte,combinationsDependencies:Rne,divideScalarDependencies:hne,factorialDependencies:Bne,isIntegerDependencies:Jte,isNegativeDependencies:One,largerDependencies:zne,multiplyScalarDependencies:_ne,numberDependencies:pne,powDependencies:Ine,subtractDependencies:Cne,typedDependencies:Ate,createStirlingS2:R2},Hne={addScalarDependencies:qte,isIntegerDependencies:Jte,isNegativeDependencies:One,stirlingS2Dependencies:Pne,typedDependencies:Ate,createBellNumbers:P2},jne={formatDependencies:vne,typedDependencies:Ate,createBin:lX},Une={equalScalarDependencies:Fte,matrixDependencies:Ote,typedDependencies:Ate,createBitAnd:RZ},qne={typedDependencies:Ate,createBitNot:nK},Wne={DenseMatrixDependencies:Cte,equalScalarDependencies:Fte,matrixDependencies:Ote,typedDependencies:Ate,createBitOr:c0},Vne={DenseMatrixDependencies:Cte,matrixDependencies:Ote,typedDependencies:Ate,createBitXor:BZ},Gne={createResultSet:TW},Kne={NodeDependencies:Lte,ResultSetDependencies:Gne,createBlockNode:g9},Jne={BigNumberDependencies:Ste,UnitDependencies:Lne,createBohrMagneton:$q},Xne={BigNumberDependencies:Ste,UnitDependencies:Lne,createBohrRadius:Pq},Zne={BigNumberDependencies:Ste,UnitDependencies:Lne,createBoltzmann:rW},Qne={typedDependencies:Ate,createBoolean:aK},ere={addScalarDependencies:qte,combinationsDependencies:Rne,divideScalarDependencies:hne,isIntegerDependencies:Jte,isNegativeDependencies:One,multiplyScalarDependencies:_ne,typedDependencies:Ate,createCatalan:d0},tre={BigNumberDependencies:Ste,ComplexDependencies:kte,FractionDependencies:Ete,isNegativeDependencies:One,matrixDependencies:Ote,typedDependencies:Ate,unaryMinusDependencies:Tne,createCbrt:PZ},nre={typedDependencies:Ate,createChainClass:N9},rre={ChainDependencies:nre,typedDependencies:Ate,createChain:T9},are={BigNumberDependencies:Ste,UnitDependencies:Lne,createClassicalElectronRadius:Hq},ire={typedDependencies:Ate,createClone:sK},sre={DenseMatrixDependencies:Cte,matrixDependencies:Ote,typedDependencies:Ate,createSmaller:mZ},ore={DenseMatrixDependencies:Cte,smallerDependencies:sre,createImmutableDenseMatrixClass:L1},ure={ImmutableDenseMatrixDependencies:ore,createIndexClass:F1},lre={DenseMatrixDependencies:Cte,matrixDependencies:Ote,typedDependencies:Ate,createLargerEq:NQ},cre={DenseMatrixDependencies:Cte,matrixDependencies:Ote,typedDependencies:Ate,createSmallerEq:XQ},pre={bignumberDependencies:lne,matrixDependencies:Ote,largerDependencies:zne,largerEqDependencies:lre,smallerDependencies:sre,smallerEqDependencies:cre,typedDependencies:Ate,createRange:q0},dre={IndexDependencies:ure,matrixDependencies:Ote,rangeDependencies:pre,typedDependencies:Ate,createColumn:Q1},hre={IndexDependencies:ure,matrixDependencies:Ote,rangeDependencies:pre,typedDependencies:Ate,createColumnTransform:Ree},fre={typedDependencies:Ate,createCombinationsWithRep:pX},mre={BigNumberDependencies:Ste,DenseMatrixDependencies:Cte,FractionDependencies:Ete,equalScalarDependencies:Fte,matrixDependencies:Ote,typedDependencies:Ate,createCompare:jZ},gre={compareDependencies:mre,typedDependencies:Ate,createCompareNatural:m0},yre={matrixDependencies:Ote,typedDependencies:Ate,createCompareText:VZ},bre={NodeDependencies:Lte,createConditionalNode:b9},vre={NodeDependencies:Lte,createConstantNode:x9},xre={NodeDependencies:Lte,typedDependencies:Ate,createFunctionAssignmentNode:S9},_re={UnitDependencies:Lne,NodeDependencies:Lte,createSymbolNode:R9},wre={NodeDependencies:Lte,SymbolNodeDependencies:_re,createFunctionNode:z9},Dre={NodeDependencies:Lte,sizeDependencies:Mne,createIndexNode:O9},Nre={NodeDependencies:Lte,createObjectNode:V7},Mre={NodeDependencies:Lte,createOperatorNode:u9},Sre={NodeDependencies:Lte,createParenthesisNode:c9},kre={NodeDependencies:Lte,createRangeNode:w9},Tre={NodeDependencies:Lte,createRelationalNode:d9},Cre={AccessorNodeDependencies:Yte,ArrayNodeDependencies:ene,AssignmentNodeDependencies:ine,BlockNodeDependencies:Kne,ConditionalNodeDependencies:bre,ConstantNodeDependencies:vre,FunctionAssignmentNodeDependencies:xre,FunctionNodeDependencies:wre,IndexNodeDependencies:Dre,ObjectNodeDependencies:Nre,OperatorNodeDependencies:Mre,ParenthesisNodeDependencies:Sre,RangeNodeDependencies:kre,RelationalNodeDependencies:Tre,SymbolNodeDependencies:_re,numericDependencies:dne,typedDependencies:Ate,createParse:H9},Ere={parseDependencies:Cre,typedDependencies:Ate,createCompile:K9},Are={ComplexDependencies:kte,typedDependencies:Ate,createComplex:dK},Ire={typedDependencies:Ate,createIsPositive:rJ},Lre={addScalarDependencies:qte,combinationsDependencies:Rne,isIntegerDependencies:Jte,isNegativeDependencies:One,isPositiveDependencies:Ire,largerDependencies:zne,typedDependencies:Ate,createComposition:x1},Fre={isIntegerDependencies:Jte,matrixDependencies:Ote,typedDependencies:Ate,createConcat:KZ},$re={isIntegerDependencies:Jte,matrixDependencies:Ote,typedDependencies:Ate,createConcatTransform:Cee},Ore={BigNumberDependencies:Ste,UnitDependencies:Lne,createConductanceQuantum:Oq},Rre={typedDependencies:Ate,createCos:hX},Yre={typedDependencies:Ate,createCosh:gK},Bre={BigNumberDependencies:Ste,typedDependencies:Ate,createCot:FX},zre={BigNumberDependencies:Ste,typedDependencies:Ate,createCoth:bK},Pre={BigNumberDependencies:Ste,UnitDependencies:Lne,createCoulomb:Lq},Hre={multiplyScalarDependencies:_ne,numericDependencies:dne,typedDependencies:Ate,createProd:uZ},jre={prodDependencies:Hre,sizeDependencies:Mne,typedDependencies:Ate,createCount:ZZ},Ure={UnitDependencies:Lne,typedDependencies:Ate,createCreateUnit:b2},qre={matrixDependencies:Ote,multiplyDependencies:kne,subtractDependencies:Cne,typedDependencies:Ate,createCross:w1},Wre={BigNumberDependencies:Ste,typedDependencies:Ate,createCsc:xK},Vre={BigNumberDependencies:Ste,typedDependencies:Ate,createCsch:mX},Gre={matrixDependencies:Ote,typedDependencies:Ate,createTranspose:EZ},Kre={conjDependencies:Nne,transposeDependencies:Gre,typedDependencies:Ate,createCtranspose:eQ},Jre={typedDependencies:Ate,createCube:wK},Xre={BigNumberDependencies:Ste,typedDependencies:Ate,createUnaryPlus:aG},Zre={addDependencies:Wte,typedDependencies:Ate,unaryPlusDependencies:Xre,createCumSum:y0},Qre={addDependencies:Wte,typedDependencies:Ate,unaryPlusDependencies:Xre,createCumSumTransform:$ee},eae={equalDependencies:fne,typedDependencies:Ate,createDeepEqual:v0},tae={divideScalarDependencies:hne,equalScalarDependencies:Fte,invDependencies:Ane,matrixDependencies:Ote,multiplyDependencies:kne,typedDependencies:Ate,createDivide:k2},nae={ConstantNodeDependencies:vre,FunctionNodeDependencies:wre,OperatorNodeDependencies:Mre,ParenthesisNodeDependencies:Sre,parseDependencies:Cre,typedDependencies:Ate,createResolve:j9},rae={bignumberDependencies:lne,fractionDependencies:cne,AccessorNodeDependencies:Yte,ArrayNodeDependencies:ene,ConstantNodeDependencies:vre,FunctionNodeDependencies:wre,IndexNodeDependencies:Dre,ObjectNodeDependencies:Nre,OperatorNodeDependencies:Mre,SymbolNodeDependencies:_re,matrixDependencies:Ote,parseDependencies:Cre,typedDependencies:Ate,createSimplifyConstant:V9},aae={AccessorNodeDependencies:Yte,ArrayNodeDependencies:ene,ConstantNodeDependencies:vre,FunctionNodeDependencies:wre,IndexNodeDependencies:Dre,ObjectNodeDependencies:Nre,OperatorNodeDependencies:Mre,ParenthesisNodeDependencies:Sre,SymbolNodeDependencies:_re,addDependencies:Wte,divideDependencies:tae,equalDependencies:fne,isZeroDependencies:Dne,multiplyDependencies:kne,parseDependencies:Cre,powDependencies:Ine,subtractDependencies:Cne,typedDependencies:Ate,createSimplifyCore:eee},iae={bignumberDependencies:lne,fractionDependencies:cne,AccessorNodeDependencies:Yte,ArrayNodeDependencies:ene,ConstantNodeDependencies:vre,FunctionNodeDependencies:wre,IndexNodeDependencies:Dre,ObjectNodeDependencies:Nre,OperatorNodeDependencies:Mre,ParenthesisNodeDependencies:Sre,SymbolNodeDependencies:_re,addDependencies:Wte,divideDependencies:tae,equalDependencies:fne,isZeroDependencies:Dne,matrixDependencies:Ote,multiplyDependencies:kne,parseDependencies:Cre,powDependencies:Ine,resolveDependencies:nae,simplifyConstantDependencies:rae,simplifyCoreDependencies:aae,subtractDependencies:Cne,typedDependencies:Ate,createSimplify:pee},sae={ConstantNodeDependencies:vre,FunctionNodeDependencies:wre,OperatorNodeDependencies:Mre,ParenthesisNodeDependencies:Sre,SymbolNodeDependencies:_re,equalDependencies:fne,isZeroDependencies:Dne,numericDependencies:dne,parseDependencies:Cre,simplifyDependencies:iae,typedDependencies:Ate,createDerivative:mee},oae={BigNumberDependencies:Ste,UnitDependencies:Lne,createDeuteronMass:Gq},uae={DenseMatrixDependencies:Cte,SparseMatrixDependencies:$te,matrixDependencies:Ote,typedDependencies:Ate,createDiag:nQ},lae={matrixDependencies:Ote,numberDependencies:pne,subtractDependencies:Cne,typedDependencies:Ate,createDiff:_0},cae={bignumberDependencies:lne,matrixDependencies:Ote,numberDependencies:pne,subtractDependencies:Cne,typedDependencies:Ate,createDiffTransform:kee},pae={ComplexDependencies:kte,typedDependencies:Ate,createSqrt:TX},dae={absDependencies:Ite,addScalarDependencies:qte,divideScalarDependencies:hne,multiplyScalarDependencies:_ne,sqrtDependencies:pae,subtractDependencies:Cne,typedDependencies:Ate,unaryMinusDependencies:Tne,createDistance:M1},hae={DenseMatrixDependencies:Cte,divideScalarDependencies:hne,equalScalarDependencies:Fte,matrixDependencies:Ote,typedDependencies:Ate,createDotDivide:sQ},fae={equalScalarDependencies:Fte,matrixDependencies:Ote,multiplyScalarDependencies:_ne,typedDependencies:Ate,createDotMultiply:k1},mae={DenseMatrixDependencies:Cte,equalScalarDependencies:Fte,matrixDependencies:Ote,powDependencies:Ine,typedDependencies:Ate,createDotPow:x2},gae={BigNumberDependencies:Ste,createE:hq},yae={BigNumberDependencies:Ste,createEfimovFactor:eW},bae={matrixDependencies:Ote,typedDependencies:Ate,createFlatten:dQ},vae={typedDependencies:Ate,createIm:WK},xae={flattenDependencies:bae,matrixDependencies:Ote,sizeDependencies:Mne,typedDependencies:Ate,createMatrixFromColumns:FQ},_ae={BigNumberDependencies:Ste,FractionDependencies:Ete,complexDependencies:Are,typedDependencies:Ate,createSign:HJ},wae={addScalarDependencies:qte,complexDependencies:Are,conjDependencies:Nne,divideScalarDependencies:hne,equalDependencies:fne,identityDependencies:wne,isZeroDependencies:Dne,matrixDependencies:Ote,multiplyScalarDependencies:_ne,signDependencies:_ae,sqrtDependencies:pae,subtractDependencies:Cne,typedDependencies:Ate,unaryMinusDependencies:Tne,zerosDependencies:Gte,createQr:j0},Dae={typedDependencies:Ate,createRe:BJ},Nae={typedDependencies:Ate,createSin:jJ},Mae={DenseMatrixDependencies:Cte,divideScalarDependencies:hne,equalScalarDependencies:Fte,matrixDependencies:Ote,multiplyScalarDependencies:_ne,subtractDependencies:Cne,typedDependencies:Ate,createUsolve:r0},Sae={DenseMatrixDependencies:Cte,divideScalarDependencies:hne,equalScalarDependencies:Fte,matrixDependencies:Ote,multiplyScalarDependencies:_ne,subtractDependencies:Cne,typedDependencies:Ate,createUsolveAll:d1},kae={absDependencies:Ite,addDependencies:Wte,addScalarDependencies:qte,atanDependencies:sne,bignumberDependencies:lne,columnDependencies:dre,complexDependencies:Are,cosDependencies:Rre,diagDependencies:uae,divideScalarDependencies:hne,dotDependencies:Sne,equalDependencies:fne,flattenDependencies:bae,imDependencies:vae,invDependencies:Ane,largerDependencies:zne,matrixDependencies:Ote,matrixFromColumnsDependencies:xae,multiplyDependencies:kne,multiplyScalarDependencies:_ne,numberDependencies:pne,qrDependencies:wae,reDependencies:Dae,sinDependencies:Nae,smallerDependencies:sre,sqrtDependencies:pae,subtractDependencies:Cne,typedDependencies:Ate,usolveDependencies:Mae,usolveAllDependencies:Sae,createEigs:H2},Tae={BigNumberDependencies:Ste,UnitDependencies:Lne,createElectricConstant:Aq},Cae={BigNumberDependencies:Ste,UnitDependencies:Lne,createElectronMass:jq},Eae={BigNumberDependencies:Ste,UnitDependencies:Lne,createElementaryCharge:Fq},Aae={compareTextDependencies:yre,isZeroDependencies:Dne,typedDependencies:Ate,createEqualText:N0},Iae={typedDependencies:Ate,createErf:kK},Lae={parseDependencies:Cre,typedDependencies:Ate,createEvaluate:nee},Fae={typedDependencies:Ate,createExp:LK},$ae={absDependencies:Ite,addDependencies:Wte,identityDependencies:wne,invDependencies:Ane,multiplyDependencies:kne,typedDependencies:Ate,createExpm:w2},Oae={ComplexDependencies:kte,typedDependencies:Ate,createExpm1:$K},Rae={createFalse:oq},Yae={BigNumberDependencies:Ste,UnitDependencies:Lne,createFaraday:aW},Bae={BigNumberDependencies:Ste,UnitDependencies:Lne,createFermiCoupling:Uq},zae={ComplexDependencies:kte,createI:_q},Pae={BigNumberDependencies:Ste,createTau:dq},Hae={addScalarDependencies:qte,divideScalarDependencies:hne,expDependencies:Fae,iDependencies:zae,matrixDependencies:Ote,multiplyScalarDependencies:_ne,tauDependencies:Pae,typedDependencies:Ate,createFft:cQ},jae={largerDependencies:zne,smallerDependencies:sre,createFibonacciHeapClass:T1},Uae={typedDependencies:Ate,createFilter:OK},qae={typedDependencies:Ate,createFilterTransform:vee},Wae={BigNumberDependencies:Ste,createFineStructure:qq},Vae={BigNumberDependencies:Ste,UnitDependencies:Lne,createFirstRadiation:iW},Gae={typedDependencies:Ate,createForEach:BK},Kae={typedDependencies:Ate,createForEachTransform:_ee},Jae={BigNumberDependencies:Ste,UnitDependencies:Lne,createGasConstant:oW},Xae={BigNumberDependencies:Ste,DenseMatrixDependencies:Cte,equalScalarDependencies:Fte,matrixDependencies:Ote,typedDependencies:Ate,createGcd:fQ},Zae={typedDependencies:Ate,createGetMatrixDataType:UK},Qae={BigNumberDependencies:Ste,UnitDependencies:Lne,createGravitationConstant:kq},eie={BigNumberDependencies:Ste,UnitDependencies:Lne,createGravity:gW},tie={BigNumberDependencies:Ste,UnitDependencies:Lne,createHartreeEnergy:Wq},nie={isNumericDependencies:xne,typedDependencies:Ate,createHasNumericValue:gQ},rie={parseDependencies:Cre,createHelpClass:J9},aie={HelpDependencies:rie,typedDependencies:Ate,createHelp:oee},iie={formatDependencies:vne,typedDependencies:Ate,createHex:qK},sie={absDependencies:Ite,addScalarDependencies:qte,divideScalarDependencies:hne,isPositiveDependencies:Ire,multiplyScalarDependencies:_ne,smallerDependencies:sre,sqrtDependencies:pae,typedDependencies:Ate,createHypot:bQ},oie={conjDependencies:Nne,dotDivideDependencies:hae,fftDependencies:Hae,typedDependencies:Ate,createIfft:xQ},uie={IndexDependencies:ure,typedDependencies:Ate,createIndex:t2},lie={IndexDependencies:ure,createIndexTransform:Yee},cie={BigNumberDependencies:Ste,createInfinity:lq},pie={absDependencies:Ite,addDependencies:Wte,addScalarDependencies:qte,divideScalarDependencies:hne,equalScalarDependencies:Fte,flattenDependencies:bae,isNumericDependencies:xne,isZeroDependencies:Dne,matrixDependencies:Ote,multiplyDependencies:kne,multiplyScalarDependencies:_ne,smallerDependencies:sre,subtractDependencies:Cne,typedDependencies:Ate,createIntersect:$1},die={BigNumberDependencies:Ste,UnitDependencies:Lne,createInverseConductanceQuantum:Rq},hie={DenseMatrixDependencies:Cte,equalScalarDependencies:Fte,matrixDependencies:Ote,typedDependencies:Ate,createMod:JX},fie={BigNumberDependencies:Ste,matrixDependencies:Ote,typedDependencies:Ate,createXgcd:IZ},mie={BigNumberDependencies:Ste,addDependencies:Wte,equalDependencies:fne,isIntegerDependencies:Jte,modDependencies:hie,smallerDependencies:sre,typedDependencies:Ate,xgcdDependencies:fie,createInvmod:I0},gie={typedDependencies:Ate,createIsNaN:yX},yie={typedDependencies:Ate,createIsPrime:vX},bie={ComplexDependencies:kte,divideScalarDependencies:hne,typedDependencies:Ate,createLog:O0},vie={typedDependencies:Ate,createMap:bJ},xie={addDependencies:Wte,numericDependencies:dne,typedDependencies:Ate,createSum:l1},_ie={divideDependencies:tae,dotDivideDependencies:hae,isNumericDependencies:xne,logDependencies:bie,mapDependencies:vie,matrixDependencies:Ote,multiplyDependencies:kne,sumDependencies:xie,typedDependencies:Ate,createKldivergence:b3},wie={BigNumberDependencies:Ste,UnitDependencies:Lne,createKlitzing:zq},Die={matrixDependencies:Ote,multiplyScalarDependencies:_ne,typedDependencies:Ate,createKron:wQ},Nie={BigNumberDependencies:Ste,createLN10:gq},Mie={BigNumberDependencies:Ste,createLN2:mq},Sie={BigNumberDependencies:Ste,createLOG10E:bq},kie={BigNumberDependencies:Ste,createLOG2E:yq},Tie={equalScalarDependencies:Fte,matrixDependencies:Ote,typedDependencies:Ate,createLcm:O1},Cie={parseDependencies:Cre,typedDependencies:Ate,createLeafCount:Z9},Eie={DenseMatrixDependencies:Cte,equalScalarDependencies:Fte,matrixDependencies:Ote,typedDependencies:Ate,zerosDependencies:Gte,createLeftShift:CQ},Aie={ComplexDependencies:kte,typedDependencies:Ate,createLgamma:hJ},Iie={ComplexDependencies:kte,typedDependencies:Ate,createLog10:mJ},Lie={ComplexDependencies:kte,divideScalarDependencies:hne,logDependencies:bie,typedDependencies:Ate,createLog1p:Y1},Fie={ComplexDependencies:kte,typedDependencies:Ate,createLog2:yJ},$ie={BigNumberDependencies:Ste,UnitDependencies:Lne,createLoschmidt:sW},Oie={DenseMatrixDependencies:Cte,divideScalarDependencies:hne,equalScalarDependencies:Fte,matrixDependencies:Ote,multiplyScalarDependencies:_ne,subtractDependencies:Cne,typedDependencies:Ate,createLsolve:IQ},Rie={DenseMatrixDependencies:Cte,divideScalarDependencies:hne,equalScalarDependencies:Fte,matrixDependencies:Ote,multiplyScalarDependencies:_ne,subtractDependencies:Cne,typedDependencies:Ate,createLsolveAll:Y0},Yie={FibonacciHeapDependencies:jae,addScalarDependencies:qte,equalScalarDependencies:Fte,createSpaClass:c2},Bie={DenseMatrixDependencies:Cte,SpaDependencies:Yie,SparseMatrixDependencies:$te,absDependencies:Ite,addScalarDependencies:qte,divideScalarDependencies:hne,equalScalarDependencies:Fte,largerDependencies:zne,matrixDependencies:Ote,multiplyScalarDependencies:_ne,subtractDependencies:Cne,typedDependencies:Ate,unaryMinusDependencies:Tne,createLup:E2},zie={SparseMatrixDependencies:$te,absDependencies:Ite,addDependencies:Wte,divideScalarDependencies:hne,largerDependencies:zne,largerEqDependencies:lre,multiplyDependencies:kne,subtractDependencies:Cne,transposeDependencies:Gre,typedDependencies:Ate,createSlu:u1},Pie={DenseMatrixDependencies:Cte,lsolveDependencies:Oie,lupDependencies:Bie,matrixDependencies:Ote,sluDependencies:zie,typedDependencies:Ate,usolveDependencies:Mae,createLusolve:Q2},Hie={compareDependencies:mre,isNaNDependencies:gie,isNumericDependencies:xne,typedDependencies:Ate,createPartitionSelect:HQ},jie={addDependencies:Wte,compareDependencies:mre,divideDependencies:tae,partitionSelectDependencies:Hie,typedDependencies:Ate,createMedian:n3},Uie={absDependencies:Ite,mapDependencies:vie,medianDependencies:jie,subtractDependencies:Cne,typedDependencies:Ate,createMad:l3},qie={BigNumberDependencies:Ste,UnitDependencies:Lne,createMagneticConstant:Eq},Wie={BigNumberDependencies:Ste,UnitDependencies:Lne,createMagneticFluxQuantum:Yq},Vie={typedDependencies:Ate,createMapTransform:wee},Gie={isZeroDependencies:Dne,matrixDependencies:Ote,typedDependencies:Ate,createMatrixFromFunction:PX},Kie={flattenDependencies:bae,matrixDependencies:Ote,sizeDependencies:Mne,typedDependencies:Ate,createMatrixFromRows:z0},Jie={largerDependencies:zne,numericDependencies:dne,typedDependencies:Ate,createMax:B1},Xie={largerDependencies:zne,numericDependencies:dne,typedDependencies:Ate,createMaxTransform:Eee},Zie={addDependencies:Wte,divideDependencies:tae,typedDependencies:Ate,createMean:U2},Qie={addDependencies:Wte,divideDependencies:tae,typedDependencies:Ate,createMeanTransform:Bee},ese={numericDependencies:dne,smallerDependencies:sre,typedDependencies:Ate,createMin:$Q},tse={numericDependencies:dne,smallerDependencies:sre,typedDependencies:Ate,createMinTransform:Aee},nse={isNaNDependencies:gie,isNumericDependencies:xne,typedDependencies:Ate,createMode:RQ},rse={BigNumberDependencies:Ste,UnitDependencies:Lne,createMolarMass:fW},ase={BigNumberDependencies:Ste,UnitDependencies:Lne,createMolarMassC12:mW},ise={BigNumberDependencies:Ste,UnitDependencies:Lne,createMolarPlanckConstant:uW},sse={BigNumberDependencies:Ste,UnitDependencies:Lne,createMolarVolume:lW},ose={addDependencies:Wte,divideDependencies:tae,factorialDependencies:Bne,isIntegerDependencies:Jte,isPositiveDependencies:Ire,multiplyDependencies:kne,typedDependencies:Ate,createMultinomial:I2},use={BigNumberDependencies:Ste,createNaN:cq},lse={BigNumberDependencies:Ste,UnitDependencies:Lne,createNeutronMass:Kq},cse={absDependencies:Ite,addDependencies:Wte,conjDependencies:Nne,ctransposeDependencies:Kre,eigsDependencies:kae,equalScalarDependencies:Fte,largerDependencies:zne,matrixDependencies:Ote,multiplyDependencies:kne,powDependencies:Ine,smallerDependencies:sre,sqrtDependencies:pae,typedDependencies:Ate,createNorm:d3},pse={BigNumberDependencies:Ste,equalScalarDependencies:Fte,matrixDependencies:Ote,typedDependencies:Ate,createNthRoot:eZ},dse={ComplexDependencies:kte,divideScalarDependencies:hne,typedDependencies:Ate,createNthRoots:BQ},hse={BigNumberDependencies:Ste,UnitDependencies:Lne,createNuclearMagneton:Bq},fse={createNull:uq},mse={formatDependencies:vne,typedDependencies:Ate,createOct:TJ},gse={BigNumberDependencies:Ste,matrixDependencies:Ote,typedDependencies:Ate,createOnes:zQ},yse={DenseMatrixDependencies:Cte,equalScalarDependencies:Fte,matrixDependencies:Ote,typedDependencies:Ate,createOr:iZ},bse={evaluateDependencies:Lae,createParserClass:uee},vse={ParserDependencies:bse,typedDependencies:Ate,createParser:cee},xse={factorialDependencies:Bne,typedDependencies:Ate,createPermutations:F2},_se={BigNumberDependencies:Ste,createPhi:fq},wse={BigNumberDependencies:Ste,createPi:pq},Dse={typedDependencies:Ate,createPickRandom:IJ},Nse={ComplexDependencies:kte,addDependencies:Wte,ctransposeDependencies:Kre,deepEqualDependencies:eae,divideScalarDependencies:hne,dotDependencies:Sne,dotDivideDependencies:hae,equalDependencies:fne,invDependencies:Ane,matrixDependencies:Ote,multiplyDependencies:kne,typedDependencies:Ate,createPinv:a2},Mse={BigNumberDependencies:Ste,UnitDependencies:Lne,createPlanckCharge:xW},Sse={BigNumberDependencies:Ste,UnitDependencies:Lne,createPlanckConstant:Tq},kse={BigNumberDependencies:Ste,UnitDependencies:Lne,createPlanckLength:yW},Tse={BigNumberDependencies:Ste,UnitDependencies:Lne,createPlanckMass:bW},Cse={BigNumberDependencies:Ste,UnitDependencies:Lne,createPlanckTemperature:_W},Ese={BigNumberDependencies:Ste,UnitDependencies:Lne,createPlanckTime:vW},Ase={typedDependencies:Ate,createPrint:FJ},Ise={BigNumberDependencies:Ste,UnitDependencies:Lne,createProtonMass:Vq},Lse={addDependencies:Wte,compareDependencies:mre,multiplyDependencies:kne,partitionSelectDependencies:Hie,typedDependencies:Ate,createQuantileSeq:z1},Fse={BigNumberDependencies:Ste,UnitDependencies:Lne,createQuantumOfCirculation:Jq},$se={typedDependencies:Ate,createRandom:YJ},Ose={typedDependencies:Ate,createRandomInt:_X},Rse={createRangeClass:kW},Yse={bignumberDependencies:lne,matrixDependencies:Ote,largerDependencies:zne,largerEqDependencies:lre,smallerDependencies:sre,smallerEqDependencies:cre,typedDependencies:Ate,createRangeTransform:Iee},Bse={bignumberDependencies:lne,fractionDependencies:cne,AccessorNodeDependencies:Yte,ArrayNodeDependencies:ene,ConstantNodeDependencies:vre,FunctionNodeDependencies:wre,IndexNodeDependencies:Dre,ObjectNodeDependencies:Nre,OperatorNodeDependencies:Mre,ParenthesisNodeDependencies:Sre,SymbolNodeDependencies:_re,addDependencies:Wte,divideDependencies:tae,equalDependencies:fne,isZeroDependencies:Dne,matrixDependencies:Ote,multiplyDependencies:kne,parseDependencies:Cre,powDependencies:Ine,simplifyDependencies:iae,simplifyConstantDependencies:rae,simplifyCoreDependencies:aae,subtractDependencies:Cne,typedDependencies:Ate,createRationalize:yee},zse={BigNumberDependencies:Ste,UnitDependencies:Lne,createReducedPlanckConstant:Cq},Pse={createReplacer:lV},Hse={isIntegerDependencies:Jte,matrixDependencies:Ote,typedDependencies:Ate,createReshape:cZ},jse={matrixDependencies:Ote,createResize:UQ},Use={createReviver:D9},qse={DenseMatrixDependencies:Cte,equalScalarDependencies:Fte,matrixDependencies:Ote,typedDependencies:Ate,zerosDependencies:Gte,createRightArithShift:WQ},Wse={DenseMatrixDependencies:Cte,equalScalarDependencies:Fte,matrixDependencies:Ote,typedDependencies:Ate,zerosDependencies:Gte,createRightLogShift:V0},Vse={BigNumberDependencies:Ste,DenseMatrixDependencies:Cte,SparseMatrixDependencies:$te,addScalarDependencies:qte,cosDependencies:Rre,matrixDependencies:Ote,multiplyScalarDependencies:_ne,normDependencies:cse,sinDependencies:Nae,typedDependencies:Ate,unaryMinusDependencies:Tne,createRotationMatrix:m3},Gse={multiplyDependencies:kne,rotationMatrixDependencies:Vse,typedDependencies:Ate,createRotate:_3},Kse={IndexDependencies:ure,matrixDependencies:Ote,rangeDependencies:pre,typedDependencies:Ate,createRow:P1},Jse={IndexDependencies:ure,matrixDependencies:Ote,rangeDependencies:pre,typedDependencies:Ate,createRowTransform:Oee},Xse={BigNumberDependencies:Ste,UnitDependencies:Lne,createRydberg:Xq},Zse={BigNumberDependencies:Ste,createSQRT1_2:vq},Qse={BigNumberDependencies:Ste,createSQRT2:xq},eoe={BigNumberDependencies:Ste,createSackurTetrode:cW},toe={BigNumberDependencies:Ste,typedDependencies:Ate,createSec:zJ},noe={BigNumberDependencies:Ste,typedDependencies:Ate,createSech:DX},roe={BigNumberDependencies:Ste,UnitDependencies:Lne,createSecondRadiation:pW},aoe={DenseMatrixDependencies:Cte,IndexDependencies:ure,compareNaturalDependencies:gre,sizeDependencies:Mne,subsetDependencies:Rte,typedDependencies:Ate,createSetCartesian:j1},ioe={DenseMatrixDependencies:Cte,IndexDependencies:ure,compareNaturalDependencies:gre,sizeDependencies:Mne,subsetDependencies:Rte,typedDependencies:Ate,createSetDifference:o2},soe={DenseMatrixDependencies:Cte,IndexDependencies:ure,compareNaturalDependencies:gre,sizeDependencies:Mne,subsetDependencies:Rte,typedDependencies:Ate,createSetDistinct:q1},ooe={DenseMatrixDependencies:Cte,IndexDependencies:ure,compareNaturalDependencies:gre,sizeDependencies:Mne,subsetDependencies:Rte,typedDependencies:Ate,createSetIntersect:S2},uoe={IndexDependencies:ure,compareNaturalDependencies:gre,sizeDependencies:Mne,subsetDependencies:Rte,typedDependencies:Ate,createSetIsSubset:V1},loe={IndexDependencies:ure,compareNaturalDependencies:gre,sizeDependencies:Mne,subsetDependencies:Rte,typedDependencies:Ate,createSetMultiplicity:l2},coe={IndexDependencies:ure,compareNaturalDependencies:gre,sizeDependencies:Mne,subsetDependencies:Rte,typedDependencies:Ate,createSetPowerset:K1},poe={compareNaturalDependencies:gre,typedDependencies:Ate,createSetSize:K0},doe={IndexDependencies:ure,concatDependencies:Fre,setDifferenceDependencies:ioe,sizeDependencies:Mne,subsetDependencies:Rte,typedDependencies:Ate,createSetSymDifference:W2},hoe={IndexDependencies:ure,concatDependencies:Fre,setIntersectDependencies:ooe,setSymDifferenceDependencies:doe,sizeDependencies:Mne,subsetDependencies:Rte,typedDependencies:Ate,createSetUnion:i3},foe={typedDependencies:Ate,createSinh:MX},moe={compareDependencies:mre,compareNaturalDependencies:gre,matrixDependencies:Ote,typedDependencies:Ate,createSort:X1},goe={SparseMatrixDependencies:$te,typedDependencies:Ate,createSparse:kX},yoe={BigNumberDependencies:Ste,UnitDependencies:Lne,createSpeedOfLight:Sq},boe={typedDependencies:Ate,createSplitUnit:WJ},voe={absDependencies:Ite,addDependencies:Wte,identityDependencies:wne,invDependencies:Ane,mapDependencies:vie,maxDependencies:Jie,multiplyDependencies:kne,sizeDependencies:Mne,sqrtDependencies:pae,subtractDependencies:Cne,typedDependencies:Ate,createSqrtm:d2},xoe={typedDependencies:Ate,createSquare:GJ},_oe={matrixDependencies:Ote,typedDependencies:Ate,createSqueeze:bZ},woe={addDependencies:Wte,applyDependencies:Xte,divideDependencies:tae,isNaNDependencies:gie,multiplyDependencies:kne,subtractDependencies:Cne,typedDependencies:Ate,createVariance:K2},Doe={mapDependencies:vie,sqrtDependencies:pae,typedDependencies:Ate,varianceDependencies:woe,createStd:o3},Noe={mapDependencies:vie,sqrtDependencies:pae,typedDependencies:Ate,varianceDependencies:woe,createStdTransform:Hee},Moe={BigNumberDependencies:Ste,UnitDependencies:Lne,createStefanBoltzmann:dW},Soe={typedDependencies:Ate,createString:JJ},koe={matrixDependencies:Ote,typedDependencies:Ate,createSubsetTransform:Tee},Toe={addDependencies:Wte,numericDependencies:dne,typedDependencies:Ate,createSumTransform:Lee},Coe={OperatorNodeDependencies:Mre,parseDependencies:Cre,simplifyDependencies:iae,typedDependencies:Ate,createSymbolicEqual:hee},Eoe={typedDependencies:Ate,createTan:XJ},Aoe={typedDependencies:Ate,createTanh:CX},Ioe={BigNumberDependencies:Ste,UnitDependencies:Lne,createThomsonCrossSection:Zq},Loe={matrixDependencies:Ote,typedDependencies:Ate,createTo:TZ},Foe={addDependencies:Wte,matrixDependencies:Ote,typedDependencies:Ate,createTrace:c1},$oe={createTrue:sq},Ooe={typedDependencies:Ate,createTypeOf:QJ},Roe={DenseMatrixDependencies:Cte,equalScalarDependencies:Fte,matrixDependencies:Ote,typedDependencies:Ate,createUnequal:e0},Yoe={UnitDependencies:Lne,typedDependencies:Ate,createUnitFunction:B2},Boe={eDependencies:gae,createUppercaseE:Dq},zoe={piDependencies:wse,createUppercasePi:wq},Poe={BigNumberDependencies:Ste,UnitDependencies:Lne,createVacuumImpedance:Iq},Hoe={addDependencies:Wte,applyDependencies:Xte,divideDependencies:tae,isNaNDependencies:gie,multiplyDependencies:kne,subtractDependencies:Cne,typedDependencies:Ate,createVarianceTransform:Pee},joe={createVersion:Nq},Uoe={BigNumberDependencies:Ste,createWeakMixingAngle:Qq},qoe={BigNumberDependencies:Ste,UnitDependencies:Lne,createWienDisplacement:hW},Woe={DenseMatrixDependencies:Cte,matrixDependencies:Ote,typedDependencies:Ate,createXor:a0},Voe=V,Goe=n(4279);function Koe(e,t){var n=$P({},OP,t);if("function"!=typeof Object.create)throw new Error("ES5 not supported by this JavaScript engine. Please load the es5-shim and es5-sham library for compatibility.");var r,a,i=(r={isNumber:RP,isComplex:BP,isBigNumber:YP,isFraction:zP,isUnit:PP,isString:HP,isArray:jP,isMatrix:UP,isCollection:qP,isDenseMatrix:WP,isSparseMatrix:VP,isRange:GP,isIndex:KP,isBoolean:JP,isResultSet:XP,isHelp:ZP,isFunction:QP,isDate:eH,isRegExp:tH,isObject:nH,isNull:rH,isUndefined:aH,isAccessorNode:iH,isArrayNode:sH,isAssignmentNode:oH,isBlockNode:uH,isConditionalNode:lH,isConstantNode:cH,isFunctionAssignmentNode:dH,isFunctionNode:hH,isIndexNode:fH,isNode:mH,isObjectNode:gH,isOperatorNode:yH,isParenthesisNode:bH,isRangeNode:vH,isSymbolNode:xH,isChain:_H},a=new Goe,r.on=a.on.bind(a),r.off=a.off.bind(a),r.once=a.once.bind(a),r.emit=a.emit.bind(a),r);i.config=$H(n,i.emit),i.expression={transform:{},mathWithTransform:{config:i.config}};var s={};function o(){for(var e=arguments.length,t=new Array(e),n=0;n2&&void 0!==arguments[2]?arguments[2]:t.fn;if(oV(i,"."))throw new Error("Factory name should not contain a nested path. Name: "+JSON.stringify(i));var o=p(t)?n.expression.transform:n,u=i in n.expression.transform,l=AH(o,i)?o[i]:void 0,d=function(){var r={};t.dependencies.map(DU).forEach((e=>{if(oV(e,"."))throw new Error("Factory dependency should not contain a nested path. Name: "+JSON.stringify(e));"math"===e?r.math=n:"mathWithTransform"===e?r.mathWithTransform=n.expression.mathWithTransform:"classes"===e?r.classes=n:r[e]=n[e]}));var s=t(r);if(s&&"function"==typeof s.transform)throw new Error('Transforms cannot be attached to factory functions. Please create a separate function for it with exports.path="expression.transform"');if(void 0===l||a.override)return s;if(e.isTypedFunction(l)&&e.isTypedFunction(s))return e(l,s);if(a.silent)return l;throw new Error('Cannot import "'+i+'": already exists')};t.meta&&!1===t.meta.lazy?(o[i]=d(),l&&u?s(i):(p(t)||c(t))&&EH(n.expression.mathWithTransform,i,(()=>o[i]))):(EH(o,i,d),l&&u?s(i):(p(t)||c(t))&&EH(n.expression.mathWithTransform,i,(()=>o[i]))),r[i]=t,n.emit("import",i,d)}function u(e){return"function"==typeof e||"number"==typeof e||"string"==typeof e||"boolean"==typeof e||null===e||PP(e)||BP(e)||YP(e)||zP(e)||UP(e)||Array.isArray(e)}function l(e){return!AH(d,e)}function c(e){return!(-1!==e.fn.indexOf(".")||AH(d,e.fn)||e.meta&&e.meta.isClass)}function p(e){return void 0!==e&&void 0!==e.meta&&!0===e.meta.isTransformFunction||!1}var d={expression:!0,type:!0,docs:!0,error:!0,json:!0,chain:!0};return function(e,t){var n=arguments.length;if(1!==n&&2!==n)throw new jQ("import",n,1,2);function r(e,n,a){if(Array.isArray(n))n.forEach((t=>r(e,t)));else if("object"==typeof n)for(var i in n)AH(n,i)&&r(e,n[i],i);else if(wU(n)||void 0!==a){var s=wU(n)?p(n)?n.fn+".transform":n.fn:a;if(AH(e,s)&&e[s]!==n&&!t.silent)throw new Error('Cannot import "'+s+'" twice');e[s]=n}else if(!t.silent)throw new TypeError("Factory, Object, or Array expected")}t||(t={});var i={};for(var s in r(i,e),i)if(AH(i,s)){var l=i[s];if(wU(l))o(l,t);else if(u(l))a(s,l,t);else if(!t.silent)throw new TypeError("Factory, Object, or Array expected")}}}(o,0,i,s);return i.import=u,i.on("config",(()=>{IH(s).forEach((e=>{e&&e.meta&&e.meta.recreateOnConfigChange&&u(e,{override:!0})}))})),i.create=Koe.bind(null,e),i.factory=_U,i.import(IH(TH(e))),i.ArgumentsError=jQ,i.DimensionError=RW,i.IndexError=YW,i}class Joe{constructor(e){this.pInst=e,this.turtle={},this.home()}home(){this.turtle.x=this.pInst.width/2,this.turtle.y=this.pInst.height/2,this.turtle.angle=0,this.turtle.pen=!0,this.turtle.pencolor="black",this.turtle.penwidth=1}pencolor(e){this.turtle.pencolor=e}pensize(e){this.turtle.penwidth=e}pendown(){this.turtle.pen=!0}penup(){this.turtle.pen=!1}setposition(e,t){this.turtle.x=e,this.turtle.y=t}position(){return[this.turtle.x,this.turtle.y]}left(e){this.turtle.angle-=e}right(e){this.turtle.angle+=e}setheading(e){this.turtle.angle=e}heading(){return this.turtle.angle}forward(e){const t=this._angleMode;this.pInst.angleMode(this.pInst.DEGREES);const n=this.turtle.x+e*this.pInst.cos(this.turtle.angle-90),r=this.turtle.y+e*this.pInst.sin(this.turtle.angle-90);this.pInst.angleMode(t),this.turtle.pen&&(this.pInst.push(),this.pInst.strokeWeight(this.turtle.penwidth),this.pInst.stroke(this.turtle.pencolor),this.pInst.line(this.turtle.x,this.turtle.y,n,r),this.pInst.pop()),this.turtle.x=n,this.turtle.y=r}back(e){this.forward(-e)}circle(e){this.turtle.pen&&(this.pInst.push(),this.pInst.strokeWeight(this.turtle.penwidth),this.pInst.stroke(this.turtle.pencolor),this.pInst.circle(this.turtle.x,this.turtle.y,2*e),this.pInst.pop())}}const Xoe=p5.prototype.circle;p5.prototype.circle=function(){Xoe&&(1!==arguments.length?Xoe.call(this,...arguments):this.getDefaultTurtle().circle(arguments[0]))},p5.prototype.createTurtle=function(){return new Joe(this)},p5.prototype.getDefaultTurtle=function(){return this.defaultTurtle||(this.defaultTurtle=this.createTurtle()),this.defaultTurtle},p5.prototype.home=function(){this.getDefaultTurtle().home()},p5.prototype.pencolor=function(e){this.getDefaultTurtle().pencolor(e)},p5.prototype.pensize=function(e){this.getDefaultTurtle().pensize(e)},p5.prototype.pendown=function(){this.getDefaultTurtle().pendown()},p5.prototype.penup=function(){this.getDefaultTurtle().penup()},p5.prototype.setposition=function(e,t){this.getDefaultTurtle().setposition(e,t)},p5.prototype.position=function(){return this.getDefaultTurtle().position()},p5.prototype.left=function(e){this.getDefaultTurtle().left(e)},p5.prototype.right=function(e){this.getDefaultTurtle().right(e)},p5.prototype.setheading=function(e){this.getDefaultTurtle().setheading(e)},p5.prototype.heading=function(){return this.getDefaultTurtle().heading()},p5.prototype.forward=function(e){this.getDefaultTurtle().forward(e)},p5.prototype.back=function(e){this.getDefaultTurtle().back(e)};var Zoe=fte,Qoe=Nte,eue=bte,tue=pte,nue=wte;const rue=p5;var aue=rue.prototype.createVector,iue=function(){function e(t){if(this.isComplex=!1,"number"==typeof t)this.tensor=Ou(t);else if(t instanceof Array)this.tensor=Ri(t);else if(t instanceof rue.Vector){var n=t.array();this.tensor=Ri(n)}else if(t instanceof e)this.tensor=t.tensor;else{if(!(t instanceof ti))throw new Error("Tensors must be created from Numbers, Arrays, or p5.Vectors.");this.tensor=t}this.shape=this.tensor.shape}return e.prototype.toString=function(){return this.tensor.toString()},e.prototype.print=function(){this.tensor.print()},e.prototype.array=function(){return function(e,t,n,r){return new(n||(n=Promise))((function(a,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function o(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}u((r=r.apply(e,t||[])).next())}))}(this,void 0,void 0,(function(){var e,t;return function(e,t){var n,r,a,i,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function o(i){return function(o){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(a=2&i[0]?r.return:i[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,i[1])).done)return a;switch(r=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((a=(a=s.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]100)throw new Error("Percentile must be in the range [0, 100].");r.push(n*(e/100))})),r}if(t<0||t>100)throw new Error("Percentile must be in the range [0, 100].");return n*(t/100)},ple=function(e,t){var n=lle(e);if(t instanceof Array){var r=[];return t.forEach((function(e){if(e<0||e>1)throw new Error("Quantile must be in the range [0, 1].");r.push(n*e)})),r}if(t<0||t>1)throw new Error("Quantile must be in the range [0, 1].");return n*t},dle=function(e,t,n){var r=e.tensor.mean(t,n);return new iue(r)},hle=function(e,t){if(t instanceof iue){var n=e.mult(t),r=n.sum(),a=t.sum(),i=r.div(a);return n.dispose(),r.dispose(),a.dispose(),i}return dle(e)},fle=function(e){var t=ho((function(){var t=dle(e),n=e.sub(t).sq().sum(),r=e.shape.reduce((function(e,t){return e*t}));return n.div(r).sqrt().tensor}));return new iue(t)},mle=function(e){var t=fle(e),n=t.sq();return t.dispose(),n};const gle=function(e){var t=e.pg,n=e.originX,r=e.originY,a=e.width,i=e.height,s=e.annotationsPalette;t.push(),t.fill(s.backgroundColor),t.strokeWeight(1),t.stroke(s.backgroundColor),t.rect(n,r,a,-i),t.pop()};var yle=n(7484),ble=function(e,t,n){void 0===n&&(n=50);for(var r=[],a=(t-e)/(n-1),i=0;it.value?1:e.value100?t.round(v,0):t.round(v,1)),t.text(b,f[y],g)}t.pop()}(this.props):function(e){var t=e.pg,n=e.dataset,r=e.x,a=e.y,i=e.originX,s=e.originY,o=e.majorTicks,u=e.minorTicks,l=e.tickSize,c=e.annotationsPalette,p=e.xRange;t.push(),t.fill(c.fontColor),t.noStroke(),t.textAlign(t.CENTER,t.CENTER),t.translate(i,s);for(var d=n.getSorted(r,a),h=p||d.xRange,f=vle(e),m=ble(h.min,h.max,o+1),g=4*l,y=0;y100?t.round(v,0):t.round(v,1)),t.text(b,f[y],g)}t.pop()}(this.props)},e.prototype.yticks=function(e){this.props=Vle(Vle({},this.props),e),function(e){var t,n=e.pg,r=e.dataset,a=e.x,i=e.y,s=e.originX,o=e.originY,u=e.majorTicks,l=e.minorTicks,c=e.tickSize,p=e.annotationsPalette,d=e.numBins,h=e.yRange;n.push(),n.fill(p.fontColor),n.noStroke(),n.textAlign(n.CENTER,n.CENTER),n.translate(s,o),t=h||(d>0?r.getBinned(a,d).xRange:r.getSorted(a,i).yRange);for(var f=xle(e),m=ble(t.min,t.max,u+1),g=-5*c,y=0;y100?n.round(v,0):n.round(v,1)),n.text(b,g,-f[y])}n.pop()}(this.props)},e.prototype.background=function(e){this.props.annotationsPalette.backgroundColor=e||this.props.annotationsPalette.backgroundColor,this.layers.unshift({props:this.props,operation:gle})},e.prototype.margin=function(e){this.props.annotationsPalette.marginColor=e||this.props.annotationsPalette.marginColor,this.layers.unshift({props:this.props,operation:Cle})},e.prototype.bar=function(e){this.props=Vle(Vle({},this.props),e),this.props.numBins=this.props.numBins||20,this.layers.push({props:this.props,operation:Yle})},e.prototype.point=function(e){this.props=Vle(Vle({},this.props),e),this.layers.push({props:this.props,operation:Ble})},e.prototype.line=function(e){this.props=Vle(Vle({},this.props),e),this.layers.push({props:this.props,operation:zle})},e}();p5.prototype.registerMethod("init",(function(){this._plots=[]})),p5.prototype.createPlot=function(e){var t=new Gle(this,e);return this._plots.push(t),t},p5.prototype.registerMethod("post",(function(){this._plots.forEach((function(e){e.clear()}))})),p5.prototype.registerMethod("remove",(function(){this._plots.forEach((function(e){return e.props.pg.remove()})),this._plots=void 0}));var Kle=n(178);function Jle(e,...t){if("function"==typeof e)throw new Error("You must supply the data as the first argument to tidy()");let n=e;for(const e of t)e&&(n=e(n));return n}function Xle(e){return t=>t.filter(e)}function Zle(e){return t=>t.map(e)}function Qle(e){return null==e?[]:Array.isArray(e)?e:[e]}function ece(e,t){return et?1:e>=t?0:NaN}function tce(e){return t=>{const n=Qle(e).map((e=>"function"==typeof e?1===e.length?nce(e):e:nce(e)));return t.slice().sort(((e,t)=>{for(const r of n){const n=r(e,t);if(n)return n}return 0}))}}function nce(e){const t="function"==typeof e?e:t=>t[e];return function(e,n){return ace(t(e),t(n),!1)}}function rce(e){const t="function"==typeof e?e:t=>t[e];return function(e,n){return ace(t(e),t(n),!0)}}function ace(e,t,n){let r=n?t:e,a=n?e:t;if(ice(r)&&ice(a)){const e=(r!=r?0:null===r?1:2)-(a!=a?0:null===a?1:2);return n?-e:e}return ice(r)?n?-1:1:ice(a)?n?1:-1:ece(r,a)}function ice(e){return null==e||e!=e}function sce(e,t){return n=>{t=null!=t?t:{};const r={},a=Object.keys(e);for(const t of a)r[t]=e[t](n);if(t.rest&&n.length){const e=Object.keys(n[0]);for(const i of e)a.includes(i)||(r[i]=t.rest(i)(n))}return[r]}}function oce(e,t,n,r){if(!e.length)return[];const a={};let i;if(null==r)i=Object.keys(e[0]);else{i=[];for(const t of Qle(r))"function"==typeof t?i.push(...t(e)):i.push(t)}for(const r of i)n&&!n(e.map((e=>e[r])))||(a[r]=t(r)(e));return[a]}function uce(e){return t=>oce(t,e)}function lce(e,t){return n=>oce(n,t,e)}function cce(e,t){return n=>oce(n,t,void 0,e)}function pce(e){return t=>{const n=t.map((e=>({...e})));let r=0;for(const t of n){for(const a in e){const i=e[a],s="function"==typeof i?i(t,r,n):i;t[a]=s}++r}return n}}class dce extends Map{constructor(e,t=fce){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),null!=e)for(const[t,n]of e)this.set(t,n)}get(e){return super.get(hce(this,e))}has(e){return super.has(hce(this,e))}set(e,t){return super.set(function({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}(this,e),t)}delete(e){return super.delete(function({_intern:e,_key:t},n){const r=t(n);return e.has(r)&&(n=e.get(n),e.delete(r)),n}(this,e))}}function hce({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):n}function fce(e){return null!==e&&"object"==typeof e?e.valueOf():e}function mce(e){return e}function gce(e,t){if(null==e||"object"!=typeof e||Array.isArray(e))return e;const n=Object.fromEntries(t.filter((e=>"function"!=typeof e[0])));return Object.assign(n,e)}function yce(e,t,n,r,a,i=0){for(const[s,o]of e.entries()){const e=[...n,s];o instanceof Map?yce(o,r(t,e,i),e,r,a,i+1):a(t,e,o,i)}return t}function bce(e,t,n=(e=>e[e.length-1])){const r=new Map;return yce(e,r,[],(function(e,t){const r=new Map;return e.set(n(t),r),r}),(function(e,r,a){e.set(n(r),t(a,r))})),r}Set;const vce=e=>e;function xce(e,t,n){"function"==typeof t?t=[t]:2!==arguments.length||null==t||Array.isArray(t)||(n=t);const r=r=>{const a=_ce(wce(r,e),t,null==n?void 0:n.addGroupKeys);if(null==n?void 0:n.export)switch(n.export){case"grouped":return a;case"levels":return Mce(a,n);case"entries-obj":case"entriesObject":return Mce(a,{...n,export:"levels",levels:["entries-object"]});default:return Mce(a,{...n,export:"levels",levels:[n.export]})}return Dce(a,null==n?void 0:n.addGroupKeys)};return r}function _ce(e,t,n){let r=e;if(!(null==t?void 0:t.length))return r;for(const e of t)e&&(r=bce(r,((t,r)=>{let a=e(t,{groupKeys:r});return!1!==n&&(a=a.map((e=>gce(e,r)))),a})));return r}function wce(e,t){const n=function(e,...t){return function(e,t,n,r){return function e(a,i){if(i>=r.length)return n(a);const s=new dce,o=r[i++];let u=-1;for(const e of a){const t=o(e,++u,a),n=s.get(t);n?n.push(e):s.set(t,[e])}for(const[t,n]of s)s.set(t,e(n,i));return t(s)}(e,0)}(e,mce,mce,t)}(e,...Qle(t).map(((e,t)=>{const n="function"==typeof e?e:t=>t[e],r=new Map;return t=>{const a=n(t),i=function(e){const t=typeof e;return null!=e&&("object"===t||"function"===t)}(a)?a.valueOf():a;if(r.has(i))return r.get(i);const s=[e,a];return r.set(i,s),s}})));return n}function Dce(e,t){const n=[];return yce(e,n,[],vce,((e,n,r)=>{let a=r;!1!==t&&(a=r.map((e=>gce(e,n)))),e.push(...a)})),n}xce.grouped=e=>({...e,export:"grouped"}),xce.entries=e=>({...e,export:"entries"}),xce.entriesObject=e=>({...e,export:"entries-object"}),xce.object=e=>({...e,export:"object"}),xce.map=e=>({...e,export:"map"}),xce.keys=e=>({...e,export:"keys"}),xce.values=e=>({...e,export:"values"}),xce.levels=e=>({...e,export:"levels"});const Nce=e=>e.join("/");function Mce(e,t){const{groupFn:n,keyFn:r}=function(e){var t;const{flat:n,single:r,mapLeaf:a=vce,mapLeaves:i=vce,addGroupKeys:s}=e;let o;return e.flat&&(o=null!=(t=e.compositeKey)?t:Nce),{groupFn:(e,t)=>r?a(!1===s?e[0]:gce(e[0],t)):i(e.map((e=>a(!1===s?e:gce(e,t))))),keyFn:n?e=>o(e.map((e=>e[1]))):e=>e[e.length-1][1]}}(t);let{mapEntry:a=vce}=t;const{levels:i=["entries"]}=t,s=[];for(const e of i)switch(e){case"entries":case"entries-object":case"entries-obj":case"entriesObject":{const n="entries-object"!==e&&"entries-obj"!==e&&"entriesObject"!==e||null!=t.mapEntry?a:([e,t])=>({key:e,values:t});s.push({id:"entries",createEmptySubgroup:()=>[],addSubgroup:(e,t,r,a)=>{e.push(n([r,t],a))},addLeaf:(e,t,r,a)=>{e.push(n([t,r],a))}});break}case"map":s.push({id:"map",createEmptySubgroup:()=>new Map,addSubgroup:(e,t,n)=>{e.set(n,t)},addLeaf:(e,t,n)=>{e.set(t,n)}});break;case"object":s.push({id:"object",createEmptySubgroup:()=>({}),addSubgroup:(e,t,n)=>{e[n]=t},addLeaf:(e,t,n)=>{e[t]=n}});break;case"keys":s.push({id:"keys",createEmptySubgroup:()=>[],addSubgroup:(e,t,n)=>{e.push([n,t])},addLeaf:(e,t)=>{e.push(t)}});break;case"values":s.push({id:"values",createEmptySubgroup:()=>[],addSubgroup:(e,t)=>{e.push(t)},addLeaf:(e,t,n)=>{e.push(n)}});break;default:"object"==typeof e&&s.push(e)}return yce(e,s[0].createEmptySubgroup(),[],((e,n,a)=>{var i,o;if(t.flat)return e;const u=null!=(i=s[a])?i:s[s.length-1],l=(null!=(o=s[a+1])?o:u).createEmptySubgroup();return u.addSubgroup(e,l,r(n),a),l}),((e,t,a,i)=>{var o;(null!=(o=s[i])?o:s[s.length-1]).addLeaf(e,r(t),n(a,t),i)}))}function Sce(e){if(null==e?void 0:e.predicate){const t=e.predicate;return e=>e.reduce(((n,r,a)=>t(r,a,e)?n+1:n),0)}return e=>e.length}class kce{constructor(){this._partials=new Float64Array(32),this._n=0}add(e){const t=this._partials;let n=0;for(let r=0;r0){for(i=e[--a];a>0&&(t=i,n=e[--a],i=t+n,r=n-(i-t),!r););a>0&&(r<0&&e[a-1]<0||r>0&&e[a-1]>0)&&(n=2*r,t=i+n,n==t-i&&(i=t))}return i}}function Tce(e,t){const n=new kce;if(void 0===t)for(let t of e)(t=+t)&&n.add(t);else{let r=-1;for(let a of e)(a=+t(a,++r,e))&&n.add(a)}return+n}function Cce(e,t){let n="function"==typeof e?e:t=>t[e];if(null==t?void 0:t.predicate){const e=n,r=t.predicate;n=(t,n,a)=>r(t,n,a)?e(t,n,a):0}return e=>Tce(e,n)}function Ece(e){return t=>{const{name:n="n",wt:r}=null!=e?e:{};return sce({[n]:null==r?Sce():Cce(r)})(t)}}const Ace=function(e){return function(t,n=0,r=t.length){let a=r-(n=+n);for(;a;){const r=e()*a--|0,i=t[a+n];t[a+n]=t[r+n],t[r+n]=i}return t}}(Math.random);function Ice(e,t){return n=>n.slice(e,t)}function Lce(e,t){if(0===e.length||0===t.length)return{};const n=Object.keys(e[0]),r=Object.keys(t[0]),a={};for(const e of n)r.includes(e)&&(a[e]=e);return a}function Fce(e){if(Array.isArray(e)){const t={};for(const n of e)t[n]=n;return t}return"object"==typeof e?e:{[e]:e}}function $ce(e,t,n){for(const r in n)if(e[n[r]]!==t[r])return!1;return!0}function Oce(e,t){return n=>{const r=null==(null==t?void 0:t.by)?Lce(n,e):Fce(t.by);return n.flatMap((t=>e.filter((e=>$ce(t,e,r))).map((e=>({...t,...e})))))}}function Rce(e,t){return n=>{if(!e.length)return n;const r=null==(null==t?void 0:t.by)?Lce(n,e):Fce(t.by),a=Object.keys(e[0]);return n.flatMap((t=>{const n=e.filter((e=>$ce(t,e,r)));if(n.length)return n.map((e=>({...t,...e})));const i=Object.fromEntries(a.filter((e=>null==t[e])).map((e=>[e,void 0])));return{...t,...i}}))}}function Yce(e,t){return n=>{if(!e.length)return n;if(!n.length)return e;const r=null==(null==t?void 0:t.by)?Lce(n,e):Fce(t.by),a=new Map,i=Object.keys(e[0]),s=n.flatMap((t=>{const n=e.filter((e=>{const n=$ce(t,e,r);return n&&a.set(e,!0),n}));if(n.length)return n.map((e=>({...t,...e})));const s=Object.fromEntries(i.filter((e=>null==t[e])).map((e=>[e,void 0])));return{...t,...s}}));if(a.size[e,void 0])));for(const n of e)a.has(n)||s.push({...t,...n})}return s}}function Bce(e){return e.length<1?[]:Object.keys(e[0])}function zce(){return e=>Bce(e)}function Pce(e){return t=>{let n=function(e,t){let n=[];for(const r of Qle(t))"function"==typeof r?n.push(...r(e)):n.push(r);n.length&&"-"===n[0][0]&&(n=[...zce()(e),...n]);const r={},a=[];for(let e=n.length-1;e>=0;e--){const t=n[e];"-"!==t[0]?r[t]?r[t]=!1:a.unshift(t):r[t.substring(1)]=!0}return n=Array.from(new Set(a)),n}(t,e);return n.length?t.map((e=>{const t={};for(const r of n)t[r]=e[r];return t})):t}}function Hce(e){return t=>"function"==typeof e?[...t,...Qle(e(t))]:[...t,...Qle(e)]}function jce(e){return t=>{const n=function(e){if(Array.isArray(e)){const t={};for(const n of e)t[n]=n;return t}return"object"==typeof e?e:{[e]:e}}(e),r=[];for(const e in n){const a=n[e];let i;i="function"==typeof a?a(t):Array.isArray(a)?a:Array.from(new Set(t.map((t=>t[e])))),r.push(i.map((t=>({[e]:t}))))}return function(e){const t=[];return function e(t,n,r){if(!r.length&&null!=n)return void t.push(n);const a=r[0],i=r.slice(1);for(const r of a)e(t,{...n,...r},i)}(t,null,e),t}(r)}}function Uce(e,t){let n,r;if(void 0===t)for(const t of e)null!=t&&(void 0===n?t>=t&&(n=r=t):(n>t&&(n=t),r=i&&(n=r=i):(n>i&&(n=i),r{const n=[];for(const r of t){const t={...r};for(const n in e)null==t[n]&&(t[n]=e[n]);n.push(t)}return n}}function Vce(e){return t=>{const n=Qle(e),r={};return t.map((e=>{const t={...e};for(const e of n)null!=t[e]?r[e]=t[e]:null!=r[e]&&(t[e]=r[e]);return t}))}}function Gce(e,t,n){return null==e||null==t?void 0:0===t&&0===e?0:n||0!==t?e/t:void 0}function Kce(e,t){let n;if(void 0===t)for(const t of e)null!=t&&(n>t||void 0===n&&t>=t)&&(n=t);else{let r=-1;for(let a of e)null!=(a=t(a,++r,e))&&(n>a||void 0===n&&a>=a)&&(n=a)}return n}function Jce(e){const t="function"==typeof e?e:t=>t[e];return e=>Kce(e,t)}function Xce(e,t){let n;if(void 0===t)for(const t of e)null!=t&&(n=t)&&(n=t);else{let r=-1;for(let a of e)null!=(a=t(a,++r,e))&&(n=a)&&(n=a)}return n}function Zce(e){const t="function"==typeof e?e:t=>t[e];return e=>Xce(e,t)}function Qce(e,t,n=0,r=e.length-1,a=ece){for(;r>n;){if(r-n>600){const i=r-n+1,s=t-n+1,o=Math.log(i),u=.5*Math.exp(2*o/3),l=.5*Math.sqrt(o*u*(i-u)/i)*(s-i/2<0?-1:1);Qce(e,t,Math.max(n,Math.floor(t-s*u/i+l)),Math.min(r,Math.floor(t+(i-s)*u/i+l)),a)}const i=e[t];let s=n,o=r;for(epe(e,n,t),a(e[r],i)>0&&epe(e,n,r);s0;)--o}0===a(e[n],i)?epe(e,n,o):(++o,epe(e,o,r)),o<=t&&(n=o+1),t<=o&&(r=o-1)}return e}function epe(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function tpe(e,t,n){if(e=Float64Array.from(function*(e,t){if(void 0===t)for(let t of e)null!=t&&(t=+t)>=t&&(yield t);else{let n=-1;for(let r of e)null!=(r=t(r,++n,e))&&(r=+r)>=r&&(yield r)}}(e,n)),r=e.length){if((t=+t)<=0||r<2)return Kce(e);if(t>=1)return Xce(e);var r,a=(r-1)*t,i=Math.floor(a),s=Xce(Qce(e,i).subarray(0,i+1));return s+(Kce(e.subarray(i+1))-s)*(a-i)}}function npe(e,t){let n,r=0,a=0,i=0;if(void 0===t)for(let t of e)null!=t&&(t=+t)>=t&&(n=t-a,a+=n/++r,i+=n*(t-a));else{let s=-1;for(let o of e)null!=(o=t(o,++s,e))&&(o=+o)>=o&&(n=o-a,a+=n/++r,i+=n*(o-a))}if(r>1)return i/(r-1)}var rpe=function(e,t,n){if(n||2===arguments.length)for(var r,a=0,i=t.length;a{const r=jce(e)(n),a=Rce(n)(r);return t?Wce(t)(a):a}},p5.prototype.count=function(e,t){return n=>{t=null!=t?t:{};const{name:r="n",sort:a}=t;return Jle(n,xce(e,[Ece(t)]),a?tce(rce(r)):vce)}},p5.prototype.debug=function(e,t){return(n,r)=>{var a;let i="[tidy.debug";if(null==(a=null==r?void 0:r.groupKeys)?void 0:a.length){const e=r.groupKeys.map((e=>e.join(": "))).join(", ");e.length&&(i+="|"+e)}t=null!=t?t:{};const{limit:s=10,output:o="table"}=t,u="--------------------------------------------------------------------------------";let l=u.length;const c=i+"]"+(null==e?"":" "+e);return l=Math.max(0,l-(c.length+2)),console.log(`${c} ${u.substring(0,l)}`),console[o](null==s||s>=n.length?n:n.slice(0,s)),n}},p5.prototype.distinct=function(e){return t=>{if(!(e=Qle(e)).length){const e=new Set;for(const n of t)e.add(n);return Array.from(e)}const n=new Map,r=[],a=e[e.length-1];for(const i of t){let t=n,s=!1;for(const n of e){const e="function"==typeof n?n(i):i[n];if(n===a){s=t.has(e),s||(r.push(i),t.set(e,!0));break}t.has(e)||t.set(e,new Map),t=t.get(e)}}return r}},p5.prototype.desc=rce,p5.prototype.expand=jce,p5.prototype._pfill=p5.prototype.fill,p5.prototype.fill=function(){for(var e=[],t=0;t{const n=t.map((e=>({...e})));for(const r in e){const a=e[r],i="function"==typeof a?a(n):a,s=(null==i?void 0:i[Symbol.iterator])&&"string"!=typeof i?i:t.map((()=>i));let o=-1;for(const e of n)e[r]=s[++o]}return n}},p5.prototype.pick=Pce,p5.prototype.rename=function(e){return t=>t.map((t=>{var n;const r={},a=Object.keys(t);for(const i of a)r[null!=(n=e[i])?n:i]=t[i];return r}))},p5.prototype.replaceNully=Wce,p5.prototype._pselect=p5.prototype.select,p5.prototype.select=function(){for(var e=[],t=0;tIce(0,e),p5.prototype.sliceTail=e=>Ice(-e),p5.prototype.sliceMin=function(e,t){return n=>tce(t)(n).slice(0,e)},p5.prototype.sliceMax=function(e,t){return n=>"function"==typeof t?tce(t)(n).slice(-e).reverse():tce(rce(t))(n).slice(0,e)},p5.prototype.sliceSample=function(e,t){t=null!=t?t:{};const{replace:n}=t;return t=>{if(!t.length)return t.slice();if(n){const n=[];for(let r=0;r{const r=sce(e)(n),a=pce(t)(r);return[...n,...a]}},p5.prototype.totalAll=function(e,t){return n=>{const r=uce(e)(n),a=pce(t)(r);return[...n,...a]}},p5.prototype.totalAt=function(e,t,n){return r=>{const a=cce(e,t)(r),i=pce(n)(a);return[...r,...i]}},p5.prototype.totalIf=function(e,t,n){return r=>{const a=lce(e,t)(r),i=pce(n)(a);return[...r,...i]}},p5.prototype.transmute=function(e){return t=>{const n=pce(e)(t);return Pce(Object.keys(e))(n)}},p5.prototype.when=function(e,t){return n=>{if("function"==typeof e){if(!e(n))return n}else if(!e)return n;return Jle(n,...t)}},p5.prototype.deviation=function(e){const t="function"==typeof e?e:t=>t[e];return e=>function(e,t){const n=npe(e,t);return n?Math.sqrt(n):n}(e,t)},p5.prototype.first=function(e){const t="function"==typeof e?e:t=>t[e];return e=>e.length?t(e[0]):void 0},p5.prototype.last=function(e){const t="function"==typeof e?e:t=>t[e];return e=>e.length?t(e[e.length-1]):void 0},p5.prototype._pmax=p5.prototype.max,p5.prototype.max=function(){for(var e=[],t=0;tt[e];return e=>function(e,t){let n=0;for(let r=0;rt[e],r="function"==typeof t?t:e=>e[t];return e=>Gce(Tce(e,n),Tce(e,r))},p5.prototype.median=function(e){const t="function"==typeof e?e:t=>t[e];return e=>function(e,t){return tpe(e,.5,t)}(e,t)},p5.prototype._pmin=p5.prototype.min,p5.prototype.min=function(){for(var e=[],t=0;tt[e];return e=>{const r=new Map;let a=0,i=0;for(const s of e){const o=n(s,i++,e);if(!r.has(o)){if(!t.includeUndefined&&void 0===o||!1===t.includeNull&&null===o)continue;a+=1,r.set(o,!0)}}return a}},p5.prototype.sum=Cce,p5.prototype.variance=function(e){const t="function"==typeof e?e:t=>t[e];return e=>npe(e,t)},p5.prototype.cumsum=function(e){const t="function"==typeof e?e:t=>t[e];return e=>function(e,t){let n=new kce,r=0;return Float64Array.from(e,(a=>n.add(+(t(a,r++,e)||0))))}(e,t)},p5.prototype.lag=function(e,t){const n="function"==typeof e?e:t=>t[e],{n:r=1,default:a}=null!=t?t:{};return e=>e.map(((t,i)=>{const s=e[i-r];return null==s?a:n(s,i,e)}))},p5.prototype.lead=function(e,t){const n="function"==typeof e?e:t=>t[e],{n:r=1,default:a}=null!=t?t:{};return e=>e.map(((t,i)=>{const s=e[i+r];return null==s?a:n(s,i,e)}))},p5.prototype.roll=function(e,t,n){const{partial:r=!1,align:a="right"}=null!=n?n:{},i=Math.floor(e/2);return n=>n.map(((s,o)=>{const u="right"===a?o:"center"===a?o+i:o+e-1;if(!r&&(u-e+1<0||u>=n.length))return;const l=Math.max(0,u-e+1),c=n.slice(l,u+1);return t(c,u)}))},p5.prototype.rate=function(e,t,n){const r="function"==typeof e?e:t=>t[e],a="function"==typeof t?t:e=>e[t],{predicate:i,allowDivideByZero:s}=null!=n?n:{};return null==i?(e,t,n)=>{const i=a(e,t,n);return Gce(r(e,t,n),i,s)}:(e,t,n)=>{if(!i(e,t,n))return;const o=a(e,t,n);return Gce(r(e,t,n),o,s)}},p5.prototype.fullSeq=function(e,t){return function(n){t=null!=t?t:1;const r="function"==typeof e?e:t=>t[e];return function(e,t=1){let[n,r]=Uce(e);const a=[];let i=n;for(;i<=r;)a.push(i),i+=t;return a}(n.map(r),t)}},p5.prototype.fullSeqDate=function(e,t,n){return function(r){t=null!=t?t:"day",n=null!=n?n:1;const a="function"==typeof e?e:t=>t[e];return qce(r.map(a),t,n)}},p5.prototype.fullSeqDateISOString=function(e,t,n){return function(r){t=null!=t?t:"day",n=null!=n?n:1;const a="function"==typeof e?e:t=>t[e];return qce(r.map((e=>new Date(a(e)))),t,n).map((e=>e.toISOString()))}},p5.prototype.contains=function(e,t=!0){return n=>{const r=new RegExp(e,t?"i":void 0);return Bce(n).filter((e=>r.test(e)))}},p5.prototype.endsWith=function(e,t=!0){return n=>{const r=new RegExp(`${e}$`,t?"i":void 0);return Bce(n).filter((e=>r.test(e)))}},p5.prototype.everything=zce,p5.prototype.matches=function(e){return t=>Bce(t).filter((t=>e.test(t)))},p5.prototype.negate=function(e){return t=>{let n=new Set;for(const r of Qle(e))if("function"==typeof r){const e=r(t);for(const t of e)n.add(t)}else n.add(r);return Array.from(n).map((e=>`-${e}`))}},p5.prototype.numRange=function(e,t,n){return r=>{const a=Bce(r),i=[];for(let r=t[0];r<=t[1];++r){const t=null==n?r:new String("00000000"+r).slice(-n);i.push(`${e}${t}`)}return a.filter((e=>i.includes(e)))}},p5.prototype.startsWith=function(e,t=!0){return n=>{const r=new RegExp(`^${e}`,t?"i":void 0);return Bce(n).filter((e=>r.test(e)))}},yle.extend(Kle),p5.prototype.utc=function(){for(var e=[],t=0;t + * MIT Licence + */ + /** * @license * Copyright 2017 Google LLC. All Rights Reserved. diff --git a/karma.conf.js b/karma.conf.js index 12d3c05..8439a9f 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -16,4 +16,3 @@ module.exports = function(config) { concurrency: Infinity }) } - \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 11a01d6..458002b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,19 +1,19 @@ { "name": "numero", - "version": "0.2.4", + "version": "0.3.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "numero", - "version": "0.2.4", + "version": "0.3.1", "license": "MIT", "dependencies": { "@tensorflow/tfjs": "^3.19.0", - "@tidyjs/tidy": "^2.4.6", + "@tidyjs/tidy": "^2.5.1", "d3-array": "^3.2.0", - "dayjs": "^1.11.4", - "mathjs": "^10.6.4", + "dayjs": "^1.11.5", + "mathjs": "^11.0.1", "ts-toolbelt": "^9.6.0" }, "devDependencies": { @@ -315,9 +315,9 @@ } }, "node_modules/@tidyjs/tidy": { - "version": "2.4.6", - "resolved": "https://registry.npmjs.org/@tidyjs/tidy/-/tidy-2.4.6.tgz", - "integrity": "sha512-yzt03tlX94WELtlL7YfyjCc7+gBhe47hgwzUhtEGnYKrhV2SoIOQ+rfD3jHwwUp5VW3sEyoQ7McukUJmdeHomw==", + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@tidyjs/tidy/-/tidy-2.5.1.tgz", + "integrity": "sha512-T4LFjrkEq/sQjwuxLzbn/klwr2NNl8IFH9xAAGu7/pihR8GKXT9QOOHLEwqcjCi1zKgR6dgkI01DWlndITaAfg==", "dependencies": { "d3-array": "^2.9.1", "ts-toolbelt": "^8.0.7" @@ -1422,9 +1422,9 @@ } }, "node_modules/core-js": { - "version": "3.23.5", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.23.5.tgz", - "integrity": "sha512-7Vh11tujtAZy82da4duVreQysIoO2EvVrur7y6IzZkH1IHPSekuDi8Vuw1+YKjkbfWLRD7Nc9ICQ/sIUDutcyg==", + "version": "3.24.1", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.24.1.tgz", + "integrity": "sha512-0QTBSYSUZ6Gq21utGzkfITDylE8jWC9Ne1D2MrhvlsZBI1x39OdDIVbzSqtgMndIy6BlHxBXpMGqzZmnztg2rg==", "hasInstallScript": true, "funding": { "type": "opencollective", @@ -1485,9 +1485,9 @@ } }, "node_modules/dayjs": { - "version": "1.11.4", - "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.4.tgz", - "integrity": "sha512-Zj/lPM5hOvQ1Bf7uAvewDaUcsJoI6JmNqmHhHl3nyumwe0XHwt8sWdOVAPACJzCebL8gQCi+K49w7iKWnGwX9g==" + "version": "1.11.5", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.5.tgz", + "integrity": "sha512-CAdX5Q3YW3Gclyo5Vpqkgpj8fSdLQcRuzfX6mC6Phy0nfJ0eGYOeS7m4mt2plDWLAtA4TqTakvbboHvUxfe4iA==" }, "node_modules/debug": { "version": "4.3.4", @@ -1519,9 +1519,9 @@ } }, "node_modules/decimal.js": { - "version": "10.3.1", - "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.3.1.tgz", - "integrity": "sha512-V0pfhfr8suzyPGOx3nmq4aHqabehUZn6Ch9kyFpV79TGDTWFmHqUqXdabR7QHqxzrYolF4+tVmJhUG4OURg5dQ==" + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.0.tgz", + "integrity": "sha512-Nv6ENEzyPQ6AItkGwLE2PGKinZZ9g59vSh2BeH6NqPu0OTKZ5ruJsVqh/orbAnqXc9pBbgXAIrc2EyaCj8NpGg==" }, "node_modules/deep-eql": { "version": "3.0.1", @@ -3320,11 +3320,11 @@ } }, "node_modules/mathjs": { - "version": "10.6.4", - "resolved": "https://registry.npmjs.org/mathjs/-/mathjs-10.6.4.tgz", - "integrity": "sha512-omQyvRE1jIy+3k2qsqkWASOcd45aZguXZDckr3HtnTYyXk5+2xpVfC3kATgbO2Srjxlqww3TVdhD0oUdZ/hiFA==", + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/mathjs/-/mathjs-11.0.1.tgz", + "integrity": "sha512-Kgm+GcTxwD68zupr7BPK0yrlWpTh2q8sMH6VcBcQe5+JCBqcwOrBxBF11WPah7hVv0NCLDnJnFTiXtik1Phasg==", "dependencies": { - "@babel/runtime": "^7.18.6", + "@babel/runtime": "^7.18.9", "complex.js": "^2.1.1", "decimal.js": "^10.3.1", "escape-latex": "^1.2.0", @@ -3332,7 +3332,7 @@ "javascript-natural-sort": "^0.7.1", "seedrandom": "^3.0.5", "tiny-emitter": "^2.1.0", - "typed-function": "^2.1.0" + "typed-function": "^3.0.0" }, "bin": { "mathjs": "bin/cli.js" @@ -4789,11 +4789,11 @@ } }, "node_modules/typed-function": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/typed-function/-/typed-function-2.1.0.tgz", - "integrity": "sha512-bctQIOqx2iVbWGDGPWwIm18QScpu2XRmkC19D8rQGFsjKSgteq/o1hTZvIG/wuDq8fanpBDrLkLq+aEN/6y5XQ==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/typed-function/-/typed-function-3.0.0.tgz", + "integrity": "sha512-mKJKkt2xYxJUuMD7jyfgUxfn5KCsCxkEKBVjep5yYellJJ5aEDO2QUAmIGdvcZmfQnIrplkzELIaG+5b1475qg==", "engines": { - "node": ">= 10" + "node": ">= 14" } }, "node_modules/typedoc": { @@ -5485,9 +5485,9 @@ "requires": {} }, "@tidyjs/tidy": { - "version": "2.4.6", - "resolved": "https://registry.npmjs.org/@tidyjs/tidy/-/tidy-2.4.6.tgz", - "integrity": "sha512-yzt03tlX94WELtlL7YfyjCc7+gBhe47hgwzUhtEGnYKrhV2SoIOQ+rfD3jHwwUp5VW3sEyoQ7McukUJmdeHomw==", + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@tidyjs/tidy/-/tidy-2.5.1.tgz", + "integrity": "sha512-T4LFjrkEq/sQjwuxLzbn/klwr2NNl8IFH9xAAGu7/pihR8GKXT9QOOHLEwqcjCi1zKgR6dgkI01DWlndITaAfg==", "requires": { "d3-array": "^2.9.1", "ts-toolbelt": "^8.0.7" @@ -6348,9 +6348,9 @@ "dev": true }, "core-js": { - "version": "3.23.5", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.23.5.tgz", - "integrity": "sha512-7Vh11tujtAZy82da4duVreQysIoO2EvVrur7y6IzZkH1IHPSekuDi8Vuw1+YKjkbfWLRD7Nc9ICQ/sIUDutcyg==" + "version": "3.24.1", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.24.1.tgz", + "integrity": "sha512-0QTBSYSUZ6Gq21utGzkfITDylE8jWC9Ne1D2MrhvlsZBI1x39OdDIVbzSqtgMndIy6BlHxBXpMGqzZmnztg2rg==" }, "cors": { "version": "2.8.5", @@ -6394,9 +6394,9 @@ "dev": true }, "dayjs": { - "version": "1.11.4", - "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.4.tgz", - "integrity": "sha512-Zj/lPM5hOvQ1Bf7uAvewDaUcsJoI6JmNqmHhHl3nyumwe0XHwt8sWdOVAPACJzCebL8gQCi+K49w7iKWnGwX9g==" + "version": "1.11.5", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.5.tgz", + "integrity": "sha512-CAdX5Q3YW3Gclyo5Vpqkgpj8fSdLQcRuzfX6mC6Phy0nfJ0eGYOeS7m4mt2plDWLAtA4TqTakvbboHvUxfe4iA==" }, "debug": { "version": "4.3.4", @@ -6414,9 +6414,9 @@ "dev": true }, "decimal.js": { - "version": "10.3.1", - "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.3.1.tgz", - "integrity": "sha512-V0pfhfr8suzyPGOx3nmq4aHqabehUZn6Ch9kyFpV79TGDTWFmHqUqXdabR7QHqxzrYolF4+tVmJhUG4OURg5dQ==" + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.0.tgz", + "integrity": "sha512-Nv6ENEzyPQ6AItkGwLE2PGKinZZ9g59vSh2BeH6NqPu0OTKZ5ruJsVqh/orbAnqXc9pBbgXAIrc2EyaCj8NpGg==" }, "deep-eql": { "version": "3.0.1", @@ -7783,11 +7783,11 @@ "dev": true }, "mathjs": { - "version": "10.6.4", - "resolved": "https://registry.npmjs.org/mathjs/-/mathjs-10.6.4.tgz", - "integrity": "sha512-omQyvRE1jIy+3k2qsqkWASOcd45aZguXZDckr3HtnTYyXk5+2xpVfC3kATgbO2Srjxlqww3TVdhD0oUdZ/hiFA==", + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/mathjs/-/mathjs-11.0.1.tgz", + "integrity": "sha512-Kgm+GcTxwD68zupr7BPK0yrlWpTh2q8sMH6VcBcQe5+JCBqcwOrBxBF11WPah7hVv0NCLDnJnFTiXtik1Phasg==", "requires": { - "@babel/runtime": "^7.18.6", + "@babel/runtime": "^7.18.9", "complex.js": "^2.1.1", "decimal.js": "^10.3.1", "escape-latex": "^1.2.0", @@ -7795,7 +7795,7 @@ "javascript-natural-sort": "^0.7.1", "seedrandom": "^3.0.5", "tiny-emitter": "^2.1.0", - "typed-function": "^2.1.0" + "typed-function": "^3.0.0" } }, "media-typer": { @@ -8824,9 +8824,9 @@ } }, "typed-function": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/typed-function/-/typed-function-2.1.0.tgz", - "integrity": "sha512-bctQIOqx2iVbWGDGPWwIm18QScpu2XRmkC19D8rQGFsjKSgteq/o1hTZvIG/wuDq8fanpBDrLkLq+aEN/6y5XQ==" + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/typed-function/-/typed-function-3.0.0.tgz", + "integrity": "sha512-mKJKkt2xYxJUuMD7jyfgUxfn5KCsCxkEKBVjep5yYellJJ5aEDO2QUAmIGdvcZmfQnIrplkzELIaG+5b1475qg==" }, "typedoc": { "version": "0.23.8", diff --git a/package.json b/package.json index 46c51a4..018a19a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "numero", - "version": "0.3.0", + "version": "0.3.1", "description": "A friendly and intuitive math library for p5.js", "main": "index.js", "scripts": { @@ -37,10 +37,10 @@ }, "dependencies": { "@tensorflow/tfjs": "^3.19.0", - "@tidyjs/tidy": "^2.4.6", + "@tidyjs/tidy": "^2.5.1", "d3-array": "^3.2.0", - "dayjs": "^1.11.4", - "mathjs": "^10.6.4", + "dayjs": "^1.11.5", + "mathjs": "^11.0.1", "ts-toolbelt": "^9.6.0" } }