(()=>{var __webpack_modules__={936:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{cv_destroy_all:()=>cv_destroy_all,cv_face_classifier:()=>cv_face_classifier,cv_face_detect:()=>cv_face_detect,cv_face_detect_all:()=>cv_face_detect_all,cv_line_rect:()=>cv_line_rect,cv_read_image:()=>cv_read_image,cv_show_image:()=>cv_show_image,cv_text:()=>cv_text,cv_waitkey:()=>cv_waitkey,cv_write_image:()=>cv_write_image});const cv_read_image=function(t,e){return e.definitions_.import_cv2="import cv2",["cv2.imread("+e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},cv_show_image=function(t,e){return e.definitions_.import_cv2="import cv2","cv2.imshow("+e.valueToCode(this,"data",e.ORDER_ATOMIC)+","+e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+")\n"},cv_write_image=function(t,e){return e.definitions_.import_cv2="import cv2","cv2.imwrite("+e.valueToCode(this,"data",e.ORDER_ATOMIC)+","+e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+")\n"},cv_waitkey=function(t,e){return e.definitions_.import_cv2="import cv2","cv2.waitKey("+e.valueToCode(this,"data",e.ORDER_ATOMIC)+")\n"},cv_destroy_all=function(t,e){e.definitions_.import_cv2="import cv2";return"cv2.destroyAllWindows()\n"},cv_line_rect=function(_,generator){generator.definitions_.import_cv2="import cv2";var file=generator.valueToCode(this,"FILE",generator.ORDER_ATOMIC),x1=generator.valueToCode(this,"x1",generator.ORDER_ATOMIC),y1=generator.valueToCode(this,"y1",generator.ORDER_ATOMIC),x2=generator.valueToCode(this,"x2",generator.ORDER_ATOMIC),y2=generator.valueToCode(this,"y2",generator.ORDER_ATOMIC),thick=generator.valueToCode(this,"thick",generator.ORDER_ATOMIC),color=this.getFieldValue("FIELDNAME"),color1=eval("0x"+color[1]+color[2]),color2=eval("0x"+color[3]+color[4]),color3=eval("0x"+color[5]+color[6]),direction=this.getFieldValue("DIR"),code="cv2."+direction+"("+file+",("+x1+","+y1+"),("+x2+","+y2+"),("+color3+","+color2+","+color1+"),"+thick+")\n";return code},cv_text=function(_,generator){generator.definitions_.import_cv2="import cv2";var file=generator.valueToCode(this,"FILE",generator.ORDER_ATOMIC),x1=generator.valueToCode(this,"x1",generator.ORDER_ATOMIC),y1=generator.valueToCode(this,"y1",generator.ORDER_ATOMIC),data=generator.valueToCode(this,"data",generator.ORDER_ATOMIC),size=generator.valueToCode(this,"size",generator.ORDER_ATOMIC),thick=generator.valueToCode(this,"thick",generator.ORDER_ATOMIC),color=this.getFieldValue("FIELDNAME"),color1=eval("0x"+color[1]+color[2]),color2=eval("0x"+color[3]+color[4]),color3=eval("0x"+color[5]+color[6]),font=this.getFieldValue("font"),code="cv2.putText("+file+","+data+",("+x1+","+y1+"),cv2.FONT_HERSHEY_"+font+","+size+",("+color3+","+color2+","+color1+"),"+thick+")\n";return code},cv_face_classifier=function(t,e){return e.definitions_.import_cv2="import cv2",["cv2.CascadeClassifier("+e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},cv_face_detect=function(t,e){e.definitions_.import_cv2="import cv2";var n=e.valueToCode(this,"FILE",e.ORDER_ATOMIC);return[e.valueToCode(this,"FACE",e.ORDER_ATOMIC)+".detectMultiScale("+n+",scaleFactor="+e.valueToCode(this,"SCALE",e.ORDER_ATOMIC)+",minNeighbors="+e.valueToCode(this,"NEIGHBOR",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},cv_face_detect_all=function(t,e){e.definitions_.import_cv2="import cv2";var n=e.valueToCode(this,"FILE",e.ORDER_ATOMIC);return[e.valueToCode(this,"FACE",e.ORDER_ATOMIC)+".detectMultiScale("+n+",scaleFactor="+e.valueToCode(this,"SCALE",e.ORDER_ATOMIC)+",minNeighbors="+e.valueToCode(this,"NEIGHBOR",e.ORDER_ATOMIC)+",minSize=("+e.valueToCode(this,"x1",e.ORDER_ATOMIC)+","+e.valueToCode(this,"y1",e.ORDER_ATOMIC)+"),maxSize=("+e.valueToCode(this,"x2",e.ORDER_ATOMIC)+","+e.valueToCode(this,"y2",e.ORDER_ATOMIC)+"))",e.ORDER_ATOMIC]}},153:(t,e,n)=>{"use strict";const{SymbolDispose:i}=n(4184),{AbortError:s,codes:r}=n(6605),{isNodeStream:a,isWebStream:o,kControllerErrorFunction:l}=n(6569),u=n(9700),{ERR_INVALID_ARG_TYPE:h}=r;let p;t.exports.addAbortSignal=function(e,n){if(((t,e)=>{if("object"!=typeof t||!("aborted"in t))throw new h(e,"AbortSignal",t)})(e,"signal"),!a(n)&&!o(n))throw new h("stream",["ReadableStream","WritableStream","Stream"],n);return t.exports.addAbortSignalNoValidate(e,n)},t.exports.addAbortSignalNoValidate=function(t,e){if("object"!=typeof t||!("aborted"in t))return e;const r=a(e)?()=>{e.destroy(new s(void 0,{cause:t.reason}))}:()=>{e[l](new s(void 0,{cause:t.reason}))};if(t.aborted)r();else{p=p||n(798).addAbortListener;const s=p(t,r);u(e,s[i])}return e}},1515:(t,e,n)=>{"use strict";const{StringPrototypeSlice:i,SymbolIterator:s,TypedArrayPrototypeSet:r,Uint8Array:a}=n(4184),{Buffer:o}=n(8287),{inspect:l}=n(798);t.exports=class{constructor(){this.head=null,this.tail=null,this.length=0}push(t){const e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length}unshift(t){const e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}shift(){if(0===this.length)return;const t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}clear(){this.head=this.tail=null,this.length=0}join(t){if(0===this.length)return"";let e=this.head,n=""+e.data;for(;null!==(e=e.next);)n+=t+e.data;return n}concat(t){if(0===this.length)return o.alloc(0);const e=o.allocUnsafe(t>>>0);let n=this.head,i=0;for(;n;)r(e,n.data,i),i+=n.data.length,n=n.next;return e}consume(t,e){const n=this.head.data;if(tr.length)){t===r.length?(e+=r,++s,n.next?this.head=n.next:this.head=this.tail=null):(e+=i(r,0,t),this.head=n,n.data=i(r,t));break}e+=r,t-=r.length,++s}while(null!==(n=n.next));return this.length-=s,e}_getBuffer(t){const e=o.allocUnsafe(t),n=t;let i=this.head,s=0;do{const o=i.data;if(!(t>o.length)){t===o.length?(r(e,o,n-t),++s,i.next?this.head=i.next:this.head=this.tail=null):(r(e,new a(o.buffer,o.byteOffset,t),n-t),this.head=i,i.data=o.slice(t));break}r(e,o,n-t),t-=o.length,++s}while(null!==(i=i.next));return this.length-=s,e}[Symbol.for("nodejs.util.inspect.custom")](t,e){return l(this,{...e,depth:0,customInspect:!1})}}},6864:(t,e,n)=>{"use strict";const{pipeline:i}=n(872),s=n(4992),{destroyer:r}=n(2430),{isNodeStream:a,isReadable:o,isWritable:l,isWebStream:u,isTransformStream:h,isWritableStream:p,isReadableStream:c}=n(6569),{AbortError:d,codes:{ERR_INVALID_ARG_VALUE:f,ERR_MISSING_ARGS:m}}=n(6605),g=n(9700);t.exports=function(...t){if(0===t.length)throw new m("streams");if(1===t.length)return s.from(t[0]);const e=[...t];if("function"==typeof t[0]&&(t[0]=s.from(t[0])),"function"==typeof t[t.length-1]){const e=t.length-1;t[e]=s.from(t[e])}for(let n=0;n0&&!(l(t[n])||p(t[n])||h(t[n])))throw new f(`streams[${n}]`,e[n],"must be writable")}let n,_,T,y,I;const E=t[0],b=i(t,(function(t){const e=y;y=null,e?e(t):t?I.destroy(t):w||v||I.destroy()})),v=!!(l(E)||p(E)||h(E)),w=!!(o(b)||c(b)||h(b));if(I=new s({writableObjectMode:!(null==E||!E.writableObjectMode),readableObjectMode:!(null==b||!b.readableObjectMode),writable:v,readable:w}),v){if(a(E))I._write=function(t,e,i){E.write(t,e)?i():n=i},I._final=function(t){E.end(),_=t},E.on("drain",(function(){if(n){const t=n;n=null,t()}}));else if(u(E)){const t=(h(E)?E.writable:E).getWriter();I._write=async function(e,n,i){try{await t.ready,t.write(e).catch((()=>{})),i()}catch(t){i(t)}},I._final=async function(e){try{await t.ready,t.close().catch((()=>{})),_=e}catch(t){e(t)}}}const t=h(b)?b.readable:b;g(t,(()=>{if(_){const t=_;_=null,t()}}))}if(w)if(a(b))b.on("readable",(function(){if(T){const t=T;T=null,t()}})),b.on("end",(function(){I.push(null)})),I._read=function(){for(;;){const t=b.read();if(null===t)return void(T=I._read);if(!I.push(t))return}};else if(u(b)){const t=(h(b)?b.readable:b).getReader();I._read=async function(){for(;;)try{const{value:e,done:n}=await t.read();if(!I.push(e))return;if(n)return void I.push(null)}catch{return}}}return I._destroy=function(t,e){t||null===y||(t=new d),T=null,n=null,_=null,null===y?e(t):(y=e,a(b)&&r(b,t))},I}},2430:(t,e,n)=>{"use strict";const i=n(5606),{aggregateTwoErrors:s,codes:{ERR_MULTIPLE_CALLBACK:r},AbortError:a}=n(6605),{Symbol:o}=n(4184),{kIsDestroyed:l,isDestroyed:u,isFinished:h,isServerRequest:p}=n(6569),c=o("kDestroy"),d=o("kConstruct");function f(t,e,n){t&&(t.stack,e&&!e.errored&&(e.errored=t),n&&!n.errored&&(n.errored=t))}function m(t,e,n){let s=!1;function r(e){if(s)return;s=!0;const r=t._readableState,a=t._writableState;f(e,a,r),a&&(a.closed=!0),r&&(r.closed=!0),"function"==typeof n&&n(e),e?i.nextTick(g,t,e):i.nextTick(_,t)}try{t._destroy(e||null,r)}catch(e){r(e)}}function g(t,e){T(t,e),_(t)}function _(t){const e=t._readableState,n=t._writableState;n&&(n.closeEmitted=!0),e&&(e.closeEmitted=!0),(null!=n&&n.emitClose||null!=e&&e.emitClose)&&t.emit("close")}function T(t,e){const n=t._readableState,i=t._writableState;null!=i&&i.errorEmitted||null!=n&&n.errorEmitted||(i&&(i.errorEmitted=!0),n&&(n.errorEmitted=!0),t.emit("error",e))}function y(t,e,n){const s=t._readableState,r=t._writableState;if(null!=r&&r.destroyed||null!=s&&s.destroyed)return this;null!=s&&s.autoDestroy||null!=r&&r.autoDestroy?t.destroy(e):e&&(e.stack,r&&!r.errored&&(r.errored=e),s&&!s.errored&&(s.errored=e),n?i.nextTick(T,t,e):T(t,e))}function I(t){let e=!1;function n(n){if(e)return void y(t,null!=n?n:new r);e=!0;const s=t._readableState,a=t._writableState,o=a||s;s&&(s.constructed=!0),a&&(a.constructed=!0),o.destroyed?t.emit(c,n):n?y(t,n,!0):i.nextTick(E,t)}try{t._construct((t=>{i.nextTick(n,t)}))}catch(t){i.nextTick(n,t)}}function E(t){t.emit(d)}function b(t){return(null==t?void 0:t.setHeader)&&"function"==typeof t.abort}function v(t){t.emit("close")}function w(t,e){t.emit("error",e),i.nextTick(v,t)}t.exports={construct:function(t,e){if("function"!=typeof t._construct)return;const n=t._readableState,s=t._writableState;n&&(n.constructed=!1),s&&(s.constructed=!1),t.once(d,e),t.listenerCount(d)>1||i.nextTick(I,t)},destroyer:function(t,e){t&&!u(t)&&(e||h(t)||(e=new a),p(t)?(t.socket=null,t.destroy(e)):b(t)?t.abort():b(t.req)?t.req.abort():"function"==typeof t.destroy?t.destroy(e):"function"==typeof t.close?t.close():e?i.nextTick(w,t,e):i.nextTick(v,t),t.destroyed||(t[l]=!0))},destroy:function(t,e){const n=this._readableState,i=this._writableState,r=i||n;return null!=i&&i.destroyed||null!=n&&n.destroyed?("function"==typeof e&&e(),this):(f(t,i,n),i&&(i.destroyed=!0),n&&(n.destroyed=!0),r.constructed?m(this,t,e):this.once(c,(function(n){m(this,s(n,t),e)})),this)},undestroy:function(){const t=this._readableState,e=this._writableState;t&&(t.constructed=!0,t.closed=!1,t.closeEmitted=!1,t.destroyed=!1,t.errored=null,t.errorEmitted=!1,t.reading=!1,t.ended=!1===t.readable,t.endEmitted=!1===t.readable),e&&(e.constructed=!0,e.destroyed=!1,e.closed=!1,e.closeEmitted=!1,e.errored=null,e.errorEmitted=!1,e.finalCalled=!1,e.prefinished=!1,e.ended=!1===e.writable,e.ending=!1===e.writable,e.finished=!1===e.writable)},errorOrDestroy:y}},4992:(t,e,n)=>{"use strict";const{ObjectDefineProperties:i,ObjectGetOwnPropertyDescriptor:s,ObjectKeys:r,ObjectSetPrototypeOf:a}=n(4184);t.exports=u;const o=n(6566),l=n(394);a(u.prototype,o.prototype),a(u,o);{const t=r(l.prototype);for(let e=0;e{const i=n(5606),s=n(8287),{isReadable:r,isWritable:a,isIterable:o,isNodeStream:l,isReadableNodeStream:u,isWritableNodeStream:h,isDuplexNodeStream:p,isReadableStream:c,isWritableStream:d}=n(6569),f=n(9700),{AbortError:m,codes:{ERR_INVALID_ARG_TYPE:g,ERR_INVALID_RETURN_VALUE:_}}=n(6605),{destroyer:T}=n(2430),y=n(4992),I=n(6566),E=n(394),{createDeferredPromise:b}=n(798),v=n(3182),w=globalThis.Blob||s.Blob,S=void 0!==w?function(t){return t instanceof w}:function(t){return!1},x=globalThis.AbortController||n(5568).AbortController,{FunctionPrototypeCall:R}=n(4184);class A extends y{constructor(t){super(t),!1===(null==t?void 0:t.readable)&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),!1===(null==t?void 0:t.writable)&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)}}function O(t){const e=t.readable&&"function"!=typeof t.readable.read?I.wrap(t.readable):t.readable,n=t.writable;let i,s,o,l,u,h=!!r(e),p=!!a(n);function c(t){const e=l;l=null,e?e(t):t&&u.destroy(t)}return u=new A({readableObjectMode:!(null==e||!e.readableObjectMode),writableObjectMode:!(null==n||!n.writableObjectMode),readable:h,writable:p}),p&&(f(n,(t=>{p=!1,t&&T(e,t),c(t)})),u._write=function(t,e,s){n.write(t,e)?s():i=s},u._final=function(t){n.end(),s=t},n.on("drain",(function(){if(i){const t=i;i=null,t()}})),n.on("finish",(function(){if(s){const t=s;s=null,t()}}))),h&&(f(e,(t=>{h=!1,t&&T(e,t),c(t)})),e.on("readable",(function(){if(o){const t=o;o=null,t()}})),e.on("end",(function(){u.push(null)})),u._read=function(){for(;;){const t=e.read();if(null===t)return void(o=u._read);if(!u.push(t))return}}),u._destroy=function(t,r){t||null===l||(t=new m),o=null,i=null,s=null,null===l?r(t):(l=r,T(n,t),T(e,t))},u}t.exports=function t(e,n){if(p(e))return e;if(u(e))return O({readable:e});if(h(e))return O({writable:e});if(l(e))return O({writable:!1,readable:!1});if(c(e))return O({readable:I.fromWeb(e)});if(d(e))return O({writable:E.fromWeb(e)});if("function"==typeof e){const{value:t,write:s,final:r,destroy:a}=function(t){let{promise:e,resolve:n}=b();const s=new x,r=s.signal,a=t(async function*(){for(;;){const t=e;e=null;const{chunk:s,done:a,cb:o}=await t;if(i.nextTick(o),a)return;if(r.aborted)throw new m(void 0,{cause:r.reason});({promise:e,resolve:n}=b()),yield s}}(),{signal:r});return{value:a,write(t,e,i){const s=n;n=null,s({chunk:t,done:!1,cb:i})},final(t){const e=n;n=null,e({done:!0,cb:t})},destroy(t,e){s.abort(),e(t)}}}(e);if(o(t))return v(A,t,{objectMode:!0,write:s,final:r,destroy:a});const l=null==t?void 0:t.then;if("function"==typeof l){let e;const n=R(l,t,(t=>{if(null!=t)throw new _("nully","body",t)}),(t=>{T(e,t)}));return e=new A({objectMode:!0,readable:!1,write:s,final(t){r((async()=>{try{await n,i.nextTick(t,null)}catch(e){i.nextTick(t,e)}}))},destroy:a})}throw new _("Iterable, AsyncIterable or AsyncFunction",n,t)}if(S(e))return t(e.arrayBuffer());if(o(e))return v(A,e,{objectMode:!0,writable:!1});if(c(null==e?void 0:e.readable)&&d(null==e?void 0:e.writable))return A.fromWeb(e);if("object"==typeof(null==e?void 0:e.writable)||"object"==typeof(null==e?void 0:e.readable)){return O({readable:null!=e&&e.readable?u(null==e?void 0:e.readable)?null==e?void 0:e.readable:t(e.readable):void 0,writable:null!=e&&e.writable?h(null==e?void 0:e.writable)?null==e?void 0:e.writable:t(e.writable):void 0})}const s=null==e?void 0:e.then;if("function"==typeof s){let t;return R(s,e,(e=>{null!=e&&t.push(e),t.push(null)}),(e=>{T(t,e)})),t=new A({objectMode:!0,writable:!1,read(){}})}throw new g(n,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],e)}},9700:(t,e,n)=>{const i=n(5606),{AbortError:s,codes:r}=n(6605),{ERR_INVALID_ARG_TYPE:a,ERR_STREAM_PREMATURE_CLOSE:o}=r,{kEmptyObject:l,once:u}=n(798),{validateAbortSignal:h,validateFunction:p,validateObject:c,validateBoolean:d}=n(6283),{Promise:f,PromisePrototypeThen:m,SymbolDispose:g}=n(4184),{isClosed:_,isReadable:T,isReadableNodeStream:y,isReadableStream:I,isReadableFinished:E,isReadableErrored:b,isWritable:v,isWritableNodeStream:w,isWritableStream:S,isWritableFinished:x,isWritableErrored:R,isNodeStream:A,willEmitClose:O,kIsClosedPromise:M}=n(6569);let C;const N=()=>{};function k(t,e,r){var d,f;if(2===arguments.length?(r=e,e=l):null==e?e=l:c(e,"options"),p(r,"callback"),h(e.signal,"options.signal"),r=u(r),I(t)||S(t))return function(t,e,r){let a=!1,o=N;if(e.signal)if(o=()=>{a=!0,r.call(t,new s(void 0,{cause:e.signal.reason}))},e.signal.aborted)i.nextTick(o);else{C=C||n(798).addAbortListener;const i=C(e.signal,o),s=r;r=u(((...e)=>{i[g](),s.apply(t,e)}))}const l=(...e)=>{a||i.nextTick((()=>r.apply(t,e)))};return m(t[M].promise,l,l),N}(t,e,r);if(!A(t))throw new a("stream",["ReadableStream","WritableStream","Stream"],t);const k=null!==(d=e.readable)&&void 0!==d?d:y(t),D=null!==(f=e.writable)&&void 0!==f?f:w(t),L=t._writableState,F=t._readableState,P=()=>{t.writable||V()};let $=O(t)&&y(t)===k&&w(t)===D,B=x(t,!1);const V=()=>{B=!0,t.destroyed&&($=!1),(!$||t.readable&&!k)&&(k&&!U||r.call(t))};let U=E(t,!1);const Y=()=>{U=!0,t.destroyed&&($=!1),(!$||t.writable&&!D)&&(D&&!B||r.call(t))},G=e=>{r.call(t,e)};let H=_(t);const W=()=>{H=!0;const e=R(t)||b(t);return e&&"boolean"!=typeof e?r.call(t,e):k&&!U&&y(t,!0)&&!E(t,!1)?r.call(t,new o):!D||B||x(t,!1)?void r.call(t):r.call(t,new o)},z=()=>{H=!0;const e=R(t)||b(t);if(e&&"boolean"!=typeof e)return r.call(t,e);r.call(t)},X=()=>{t.req.on("finish",V)};!function(t){return t.setHeader&&"function"==typeof t.abort}(t)?D&&!L&&(t.on("end",P),t.on("close",P)):(t.on("complete",V),$||t.on("abort",W),t.req?X():t.on("request",X)),$||"boolean"!=typeof t.aborted||t.on("aborted",W),t.on("end",Y),t.on("finish",V),!1!==e.error&&t.on("error",G),t.on("close",W),H?i.nextTick(W):null!=L&&L.errorEmitted||null!=F&&F.errorEmitted?$||i.nextTick(z):(k||$&&!T(t)||!B&&!1!==v(t))&&(D||$&&!v(t)||!U&&!1!==T(t))?F&&t.req&&t.aborted&&i.nextTick(z):i.nextTick(z);const j=()=>{r=N,t.removeListener("aborted",W),t.removeListener("complete",V),t.removeListener("abort",W),t.removeListener("request",X),t.req&&t.req.removeListener("finish",V),t.removeListener("end",P),t.removeListener("close",P),t.removeListener("finish",V),t.removeListener("end",Y),t.removeListener("error",G),t.removeListener("close",W)};if(e.signal&&!H){const a=()=>{const n=r;j(),n.call(t,new s(void 0,{cause:e.signal.reason}))};if(e.signal.aborted)i.nextTick(a);else{C=C||n(798).addAbortListener;const i=C(e.signal,a),s=r;r=u(((...e)=>{i[g](),s.apply(t,e)}))}}return j}t.exports=k,t.exports.finished=function(t,e){var n;let i=!1;return null===e&&(e=l),null!==(n=e)&&void 0!==n&&n.cleanup&&(d(e.cleanup,"cleanup"),i=e.cleanup),new f(((n,s)=>{const r=k(t,e,(t=>{i&&r(),t?s(t):n()}))}))}},3182:(t,e,n)=>{"use strict";const i=n(5606),{PromisePrototypeThen:s,SymbolAsyncIterator:r,SymbolIterator:a}=n(4184),{Buffer:o}=n(8287),{ERR_INVALID_ARG_TYPE:l,ERR_STREAM_NULL_VALUES:u}=n(6605).codes;t.exports=function(t,e,n){let h,p;if("string"==typeof e||e instanceof o)return new t({objectMode:!0,...n,read(){this.push(e),this.push(null)}});if(e&&e[r])p=!0,h=e[r]();else{if(!e||!e[a])throw new l("iterable",["Iterable"],e);p=!1,h=e[a]()}const c=new t({objectMode:!0,highWaterMark:1,...n});let d=!1;return c._read=function(){d||(d=!0,async function(){for(;;){try{const{value:t,done:e}=p?await h.next():h.next();if(e)c.push(null);else{const e=t&&"function"==typeof t.then?await t:t;if(null===e)throw d=!1,new u;if(c.push(e))continue;d=!1}}catch(t){c.destroy(t)}break}}())},c._destroy=function(t,e){s(async function(t){const e=null!=t,n="function"==typeof h.throw;if(e&&n){const{value:e,done:n}=await h.throw(t);if(await e,n)return}if("function"==typeof h.return){const{value:t}=await h.return();await t}}(t),(()=>i.nextTick(e,t)),(n=>i.nextTick(e,n||t)))},c}},2913:(t,e,n)=>{"use strict";const{ArrayIsArray:i,ObjectSetPrototypeOf:s}=n(4184),{EventEmitter:r}=n(7007);function a(t){r.call(this,t)}function o(t,e,n){if("function"==typeof t.prependListener)return t.prependListener(e,n);t._events&&t._events[e]?i(t._events[e])?t._events[e].unshift(n):t._events[e]=[n,t._events[e]]:t.on(e,n)}s(a.prototype,r.prototype),s(a,r),a.prototype.pipe=function(t,e){const n=this;function i(e){t.writable&&!1===t.write(e)&&n.pause&&n.pause()}function s(){n.readable&&n.resume&&n.resume()}n.on("data",i),t.on("drain",s),t._isStdio||e&&!1===e.end||(n.on("end",l),n.on("close",u));let a=!1;function l(){a||(a=!0,t.end())}function u(){a||(a=!0,"function"==typeof t.destroy&&t.destroy())}function h(t){p(),0===r.listenerCount(this,"error")&&this.emit("error",t)}function p(){n.removeListener("data",i),t.removeListener("drain",s),n.removeListener("end",l),n.removeListener("close",u),n.removeListener("error",h),t.removeListener("error",h),n.removeListener("end",p),n.removeListener("close",p),t.removeListener("close",p)}return o(n,"error",h),o(t,"error",h),n.on("end",p),n.on("close",p),t.on("close",p),t.emit("pipe",n),t},t.exports={Stream:a,prependListener:o}},5589:(t,e,n)=>{"use strict";const i=globalThis.AbortController||n(5568).AbortController,{codes:{ERR_INVALID_ARG_VALUE:s,ERR_INVALID_ARG_TYPE:r,ERR_MISSING_ARGS:a,ERR_OUT_OF_RANGE:o},AbortError:l}=n(6605),{validateAbortSignal:u,validateInteger:h,validateObject:p}=n(6283),c=n(4184).Symbol("kWeak"),d=n(4184).Symbol("kResistStopPropagation"),{finished:f}=n(9700),m=n(6864),{addAbortSignalNoValidate:g}=n(153),{isWritable:_,isNodeStream:T}=n(6569),{deprecate:y}=n(798),{ArrayPrototypePush:I,Boolean:E,MathFloor:b,Number:v,NumberIsNaN:w,Promise:S,PromiseReject:x,PromiseResolve:R,PromisePrototypeThen:A,Symbol:O}=n(4184),M=O("kEmpty"),C=O("kEof");function N(t,e){if("function"!=typeof t)throw new r("fn",["Function","AsyncFunction"],t);null!=e&&p(e,"options"),null!=(null==e?void 0:e.signal)&&u(e.signal,"options.signal");let i=1;null!=(null==e?void 0:e.concurrency)&&(i=b(e.concurrency));let s=i-1;return null!=(null==e?void 0:e.highWaterMark)&&(s=b(e.highWaterMark)),h(i,"options.concurrency",1),h(s,"options.highWaterMark",0),s+=i,async function*(){const r=n(798).AbortSignalAny([null==e?void 0:e.signal].filter(E)),a=this,o=[],u={signal:r};let h,p,c=!1,d=0;function f(){c=!0,m()}function m(){d-=1,g()}function g(){p&&!c&&d=s||d>=i)&&await new S((t=>{p=t}))}o.push(C)}catch(t){const e=x(t);A(e,m,f),o.push(e)}finally{c=!0,h&&(h(),h=null)}}();try{for(;;){for(;o.length>0;){const t=await o[0];if(t===C)return;if(r.aborted)throw new l;t!==M&&(yield t),o.shift(),g()}await new S((t=>{h=t}))}}finally{c=!0,p&&(p(),p=null)}}.call(this)}async function k(t,e=void 0){for await(const n of D.call(this,t,e))return!0;return!1}function D(t,e){if("function"!=typeof t)throw new r("fn",["Function","AsyncFunction"],t);return N.call(this,(async function(e,n){return await t(e,n)?e:M}),e)}class L extends a{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}}function F(t){if(t=v(t),w(t))return 0;if(t<0)throw new o("number",">= 0",t);return t}t.exports.streamReturningOperators={asIndexedPairs:y((function(t=void 0){return null!=t&&p(t,"options"),null!=(null==t?void 0:t.signal)&&u(t.signal,"options.signal"),async function*(){let e=0;for await(const i of this){var n;if(null!=t&&null!==(n=t.signal)&&void 0!==n&&n.aborted)throw new l({cause:t.signal.reason});yield[e++,i]}}.call(this)}),"readable.asIndexedPairs will be removed in a future version."),drop:function(t,e=void 0){return null!=e&&p(e,"options"),null!=(null==e?void 0:e.signal)&&u(e.signal,"options.signal"),t=F(t),async function*(){var n;if(null!=e&&null!==(n=e.signal)&&void 0!==n&&n.aborted)throw new l;for await(const n of this){var i;if(null!=e&&null!==(i=e.signal)&&void 0!==i&&i.aborted)throw new l;t--<=0&&(yield n)}}.call(this)},filter:D,flatMap:function(t,e){const n=N.call(this,t,e);return async function*(){for await(const t of n)yield*t}.call(this)},map:N,take:function(t,e=void 0){return null!=e&&p(e,"options"),null!=(null==e?void 0:e.signal)&&u(e.signal,"options.signal"),t=F(t),async function*(){var n;if(null!=e&&null!==(n=e.signal)&&void 0!==n&&n.aborted)throw new l;for await(const n of this){var i;if(null!=e&&null!==(i=e.signal)&&void 0!==i&&i.aborted)throw new l;if(t-- >0&&(yield n),t<=0)return}}.call(this)},compose:function(t,e){if(null!=e&&p(e,"options"),null!=(null==e?void 0:e.signal)&&u(e.signal,"options.signal"),T(t)&&!_(t))throw new s("stream",t,"must be writable");const n=m(this,t);return null!=e&&e.signal&&g(e.signal,n),n}},t.exports.promiseReturningOperators={every:async function(t,e=void 0){if("function"!=typeof t)throw new r("fn",["Function","AsyncFunction"],t);return!await k.call(this,(async(...e)=>!await t(...e)),e)},forEach:async function(t,e){if("function"!=typeof t)throw new r("fn",["Function","AsyncFunction"],t);for await(const n of N.call(this,(async function(e,n){return await t(e,n),M}),e));},reduce:async function(t,e,n){var s;if("function"!=typeof t)throw new r("reducer",["Function","AsyncFunction"],t);null!=n&&p(n,"options"),null!=(null==n?void 0:n.signal)&&u(n.signal,"options.signal");let a=arguments.length>1;if(null!=n&&null!==(s=n.signal)&&void 0!==s&&s.aborted){const t=new l(void 0,{cause:n.signal.reason});throw this.once("error",(()=>{})),await f(this.destroy(t)),t}const o=new i,h=o.signal;if(null!=n&&n.signal){const t={once:!0,[c]:this,[d]:!0};n.signal.addEventListener("abort",(()=>o.abort()),t)}let m=!1;try{for await(const i of this){var g;if(m=!0,null!=n&&null!==(g=n.signal)&&void 0!==g&&g.aborted)throw new l;a?e=await t(e,i,{signal:h}):(e=i,a=!0)}if(!m&&!a)throw new L}finally{o.abort()}return e},toArray:async function(t){null!=t&&p(t,"options"),null!=(null==t?void 0:t.signal)&&u(t.signal,"options.signal");const e=[];for await(const i of this){var n;if(null!=t&&null!==(n=t.signal)&&void 0!==n&&n.aborted)throw new l(void 0,{cause:t.signal.reason});I(e,i)}return e},some:k,find:async function(t,e){for await(const n of D.call(this,t,e))return n}}},6898:(t,e,n)=>{"use strict";const{ObjectSetPrototypeOf:i}=n(4184);t.exports=r;const s=n(208);function r(t){if(!(this instanceof r))return new r(t);s.call(this,t)}i(r.prototype,s.prototype),i(r,s),r.prototype._transform=function(t,e,n){n(null,t)}},872:(t,e,n)=>{const i=n(5606),{ArrayIsArray:s,Promise:r,SymbolAsyncIterator:a,SymbolDispose:o}=n(4184),l=n(9700),{once:u}=n(798),h=n(2430),p=n(4992),{aggregateTwoErrors:c,codes:{ERR_INVALID_ARG_TYPE:d,ERR_INVALID_RETURN_VALUE:f,ERR_MISSING_ARGS:m,ERR_STREAM_DESTROYED:g,ERR_STREAM_PREMATURE_CLOSE:_},AbortError:T}=n(6605),{validateFunction:y,validateAbortSignal:I}=n(6283),{isIterable:E,isReadable:b,isReadableNodeStream:v,isNodeStream:w,isTransformStream:S,isWebStream:x,isReadableStream:R,isReadableFinished:A}=n(6569),O=globalThis.AbortController||n(5568).AbortController;let M,C,N;function k(t,e,n){let i=!1;t.on("close",(()=>{i=!0}));return{destroy:e=>{i||(i=!0,h.destroyer(t,e||new g("pipe")))},cleanup:l(t,{readable:e,writable:n},(t=>{i=!t}))}}function D(t){if(E(t))return t;if(v(t))return async function*(t){C||(C=n(6566));yield*C.prototype[a].call(t)}(t);throw new d("val",["Readable","Iterable","AsyncIterable"],t)}async function L(t,e,n,{end:i}){let s,a=null;const o=t=>{if(t&&(s=t),a){const t=a;a=null,t()}},u=()=>new r(((t,e)=>{s?e(s):a=()=>{s?e(s):t()}}));e.on("drain",o);const h=l(e,{readable:!1},o);try{e.writableNeedDrain&&await u();for await(const n of t)e.write(n)||await u();i&&(e.end(),await u()),n()}catch(t){n(s!==t?c(s,t):t)}finally{h(),e.off("drain",o)}}async function F(t,e,n,{end:i}){S(e)&&(e=e.writable);const s=e.getWriter();try{for await(const e of t)await s.ready,s.write(e).catch((()=>{}));await s.ready,i&&await s.close(),n()}catch(t){try{await s.abort(t),n(t)}catch(t){n(t)}}}function P(t,e,r){if(1===t.length&&s(t[0])&&(t=t[0]),t.length<2)throw new m("streams");const a=new O,l=a.signal,u=null==r?void 0:r.signal,h=[];function c(){V(new T)}let g,_,y;I(u,"options.signal"),N=N||n(798).addAbortListener,u&&(g=N(u,c));const A=[];let C,P=0;function B(t){V(t,0==--P)}function V(t,n){var s;if(!t||_&&"ERR_STREAM_PREMATURE_CLOSE"!==_.code||(_=t),_||n){for(;A.length;)A.shift()(_);null===(s=g)||void 0===s||s[o](),a.abort(),n&&(_||h.forEach((t=>t())),i.nextTick(e,_,y))}}for(let H=0;H0,j=z||!1!==(null==r?void 0:r.end),q=H===t.length-1;if(w(W)){if(j){const{destroy:K,cleanup:Q}=k(W,z,X);A.push(K),b(W)&&q&&h.push(Q)}function U(t){t&&"AbortError"!==t.name&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code&&B(t)}W.on("error",U),b(W)&&q&&h.push((()=>{W.removeListener("error",U)}))}if(0===H)if("function"==typeof W){if(C=W({signal:l}),!E(C))throw new f("Iterable, AsyncIterable or Stream","source",C)}else C=E(W)||v(W)||S(W)?W:p.from(W);else if("function"==typeof W){var Y;if(S(C))C=D(null===(Y=C)||void 0===Y?void 0:Y.readable);else C=D(C);if(C=W(C,{signal:l}),z){if(!E(C,!0))throw new f("AsyncIterable",`transform[${H-1}]`,C)}else{var G;M||(M=n(6898));const J=new M({objectMode:!0}),Z=null===(G=C)||void 0===G?void 0:G.then;if("function"==typeof Z)P++,Z.call(C,(t=>{y=t,null!=t&&J.write(t),j&&J.end(),i.nextTick(B)}),(t=>{J.destroy(t),i.nextTick(B,t)}));else if(E(C,!0))P++,L(C,J,B,{end:j});else{if(!R(C)&&!S(C))throw new f("AsyncIterable or Promise","destination",C);{const nt=C.readable||C;P++,L(nt,J,B,{end:j})}}C=J;const{destroy:tt,cleanup:et}=k(C,!1,!0);A.push(tt),q&&h.push(et)}}else if(w(W)){if(v(C)){P+=2;const it=$(C,W,B,{end:j});b(W)&&q&&h.push(it)}else if(S(C)||R(C)){const st=C.readable||C;P++,L(st,W,B,{end:j})}else{if(!E(C))throw new d("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],C);P++,L(C,W,B,{end:j})}C=W}else if(x(W)){if(v(C))P++,F(D(C),W,B,{end:j});else if(R(C)||E(C))P++,F(C,W,B,{end:j});else{if(!S(C))throw new d("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],C);P++,F(C.readable,W,B,{end:j})}C=W}else C=p.from(W)}return(null!=l&&l.aborted||null!=u&&u.aborted)&&i.nextTick(c),C}function $(t,e,n,{end:s}){let r=!1;if(e.on("close",(()=>{r||n(new _)})),t.pipe(e,{end:!1}),s){function a(){r=!0,e.end()}A(t)?i.nextTick(a):t.once("end",a)}else n();return l(t,{readable:!0,writable:!1},(e=>{const i=t._readableState;e&&"ERR_STREAM_PREMATURE_CLOSE"===e.code&&i&&i.ended&&!i.errored&&!i.errorEmitted?t.once("end",n).once("error",n):n(e)})),l(e,{readable:!1,writable:!0},n)}t.exports={pipelineImpl:P,pipeline:function(...t){return P(t,u(function(t){return y(t[t.length-1],"streams[stream.length - 1]"),t.pop()}(t)))}}},6566:(t,e,n)=>{const i=n(5606),{ArrayPrototypeIndexOf:s,NumberIsInteger:r,NumberIsNaN:a,NumberParseInt:o,ObjectDefineProperties:l,ObjectKeys:u,ObjectSetPrototypeOf:h,Promise:p,SafeSet:c,SymbolAsyncDispose:d,SymbolAsyncIterator:f,Symbol:m}=n(4184);t.exports=q,q.ReadableState=j;const{EventEmitter:g}=n(7007),{Stream:_,prependListener:T}=n(2913),{Buffer:y}=n(8287),{addAbortSignal:I}=n(153),E=n(9700);let b=n(798).debuglog("stream",(t=>{b=t}));const v=n(1515),w=n(2430),{getHighWaterMark:S,getDefaultHighWaterMark:x}=n(9153),{aggregateTwoErrors:R,codes:{ERR_INVALID_ARG_TYPE:A,ERR_METHOD_NOT_IMPLEMENTED:O,ERR_OUT_OF_RANGE:M,ERR_STREAM_PUSH_AFTER_EOF:C,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:N},AbortError:k}=n(6605),{validateObject:D}=n(6283),L=m("kPaused"),{StringDecoder:F}=n(8707),P=n(3182);h(q.prototype,_.prototype),h(q,_);const $=()=>{},{errorOrDestroy:B}=w,V=1,U=16,Y=32,G=64,H=2048,W=4096,z=65536;function X(t){return{enumerable:!1,get(){return!!(this.state&t)},set(e){e?this.state|=t:this.state&=~t}}}function j(t,e,i){"boolean"!=typeof i&&(i=e instanceof n(4992)),this.state=H|W|U|Y,t&&t.objectMode&&(this.state|=V),i&&t&&t.readableObjectMode&&(this.state|=V),this.highWaterMark=t?S(this,t,"readableHighWaterMark",i):x(!1),this.buffer=new v,this.length=0,this.pipes=[],this.flowing=null,this[L]=null,t&&!1===t.emitClose&&(this.state&=~H),t&&!1===t.autoDestroy&&(this.state&=~W),this.errored=null,this.defaultEncoding=t&&t.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.decoder=null,this.encoding=null,t&&t.encoding&&(this.decoder=new F(t.encoding),this.encoding=t.encoding)}function q(t){if(!(this instanceof q))return new q(t);const e=this instanceof n(4992);this._readableState=new j(t,this,e),t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.construct&&(this._construct=t.construct),t.signal&&!e&&I(t.signal,this)),_.call(this,t),w.construct(this,(()=>{this._readableState.needReadable&&et(this,this._readableState)}))}function K(t,e,n,i){b("readableAddChunk",e);const s=t._readableState;let r;if(s.state&V||("string"==typeof e?(n=n||s.defaultEncoding,s.encoding!==n&&(i&&s.encoding?e=y.from(e,n).toString(s.encoding):(e=y.from(e,n),n=""))):e instanceof y?n="":_._isUint8Array(e)?(e=_._uint8ArrayToBuffer(e),n=""):null!=e&&(r=new A("chunk",["string","Buffer","Uint8Array"],e))),r)B(t,r);else if(null===e)s.state&=-9,function(t,e){if(b("onEofChunk"),e.ended)return;if(e.decoder){const t=e.decoder.end();t&&t.length&&(e.buffer.push(t),e.length+=e.objectMode?1:t.length)}e.ended=!0,e.sync?Z(t):(e.needReadable=!1,e.emittedReadable=!0,tt(t))}(t,s);else if(s.state&V||e&&e.length>0)if(i)if(4&s.state)B(t,new N);else{if(s.destroyed||s.errored)return!1;Q(t,s,e,!0)}else if(s.ended)B(t,new C);else{if(s.destroyed||s.errored)return!1;s.state&=-9,s.decoder&&!n?(e=s.decoder.write(e),s.objectMode||0!==e.length?Q(t,s,e,!1):et(t,s)):Q(t,s,e,!1)}else i||(s.state&=-9,et(t,s));return!s.ended&&(s.length0?(e.state&z?e.awaitDrainWriters.clear():e.awaitDrainWriters=null,e.dataEmitted=!0,t.emit("data",n)):(e.length+=e.objectMode?1:n.length,i?e.buffer.unshift(n):e.buffer.push(n),e.state&G&&Z(t)),et(t,e)}l(j.prototype,{objectMode:X(V),ended:X(2),endEmitted:X(4),reading:X(8),constructed:X(U),sync:X(Y),needReadable:X(G),emittedReadable:X(128),readableListening:X(256),resumeScheduled:X(512),errorEmitted:X(1024),emitClose:X(H),autoDestroy:X(W),destroyed:X(8192),closed:X(16384),closeEmitted:X(32768),multiAwaitDrain:X(z),readingMore:X(1<<17),dataEmitted:X(1<<18)}),q.prototype.destroy=w.destroy,q.prototype._undestroy=w.undestroy,q.prototype._destroy=function(t,e){e(t)},q.prototype[g.captureRejectionSymbol]=function(t){this.destroy(t)},q.prototype[d]=function(){let t;return this.destroyed||(t=this.readableEnded?null:new k,this.destroy(t)),new p(((e,n)=>E(this,(i=>i&&i!==t?n(i):e(null)))))},q.prototype.push=function(t,e){return K(this,t,e,!1)},q.prototype.unshift=function(t,e){return K(this,t,e,!0)},q.prototype.isPaused=function(){const t=this._readableState;return!0===t[L]||!1===t.flowing},q.prototype.setEncoding=function(t){const e=new F(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;const n=this._readableState.buffer;let i="";for(const t of n)i+=e.write(t);return n.clear(),""!==i&&n.push(i),this._readableState.length=i.length,this};function J(t,e){return t<=0||0===e.length&&e.ended?0:e.state&V?1:a(t)?e.flowing&&e.length?e.buffer.first().length:e.length:t<=e.length?t:e.ended?e.length:0}function Z(t){const e=t._readableState;b("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(b("emitReadable",e.flowing),e.emittedReadable=!0,i.nextTick(tt,t))}function tt(t){const e=t._readableState;b("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||e.errored||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,at(t)}function et(t,e){!e.readingMore&&e.constructed&&(e.readingMore=!0,i.nextTick(nt,t,e))}function nt(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!1===e[L]?e.flowing=!0:t.listenerCount("data")>0?t.resume():e.readableListening||(e.flowing=null)}function st(t){b("readable nexttick read 0"),t.read(0)}function rt(t,e){b("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),at(t),e.flowing&&!e.reading&&t.read(0)}function at(t){const e=t._readableState;for(b("flow",e.flowing);e.flowing&&null!==t.read(););}function ot(t,e){"function"!=typeof t.read&&(t=q.wrap(t,{objectMode:!0}));const n=async function*(t,e){let n,i=$;function s(e){this===t?(i(),i=$):i=e}t.on("readable",s);const r=E(t,{writable:!1},(t=>{n=t?R(n,t):null,i(),i=$}));try{for(;;){const e=t.destroyed?null:t.read();if(null!==e)yield e;else{if(n)throw n;if(null===n)return;await new p(s)}}}catch(t){throw n=R(n,t),n}finally{!n&&!1===(null==e?void 0:e.destroyOnReturn)||void 0!==n&&!t._readableState.autoDestroy?(t.off("readable",s),r()):w.destroyer(t,null)}}(t,e);return n.stream=t,n}function lt(t,e){if(0===e.length)return null;let n;return e.objectMode?n=e.buffer.shift():!t||t>=e.length?(n=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):n=e.buffer.consume(t,e.decoder),n}function ut(t){const e=t._readableState;b("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,i.nextTick(ht,e,t))}function ht(t,e){if(b("endReadableNT",t.endEmitted,t.length),!t.errored&&!t.closeEmitted&&!t.endEmitted&&0===t.length)if(t.endEmitted=!0,e.emit("end"),e.writable&&!1===e.allowHalfOpen)i.nextTick(pt,e);else if(t.autoDestroy){const t=e._writableState;(!t||t.autoDestroy&&(t.finished||!1===t.writable))&&e.destroy()}}function pt(t){t.writable&&!t.writableEnded&&!t.destroyed&&t.end()}let ct;function dt(){return void 0===ct&&(ct={}),ct}q.prototype.read=function(t){b("read",t),void 0===t?t=NaN:r(t)||(t=o(t,10));const e=this._readableState,n=t;if(t>e.highWaterMark&&(e.highWaterMark=function(t){if(t>1073741824)throw new M("size","<= 1GiB",t);return t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,++t}(t)),0!==t&&(e.state&=-129),0===t&&e.needReadable&&((0!==e.highWaterMark?e.length>=e.highWaterMark:e.length>0)||e.ended))return b("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?ut(this):Z(this),null;if(0===(t=J(t,e))&&e.ended)return 0===e.length&&ut(this),null;let i,s=!!(e.state&G);if(b("need readable",s),(0===e.length||e.length-t0?lt(t,e):null,null===i?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.multiAwaitDrain?e.awaitDrainWriters.clear():e.awaitDrainWriters=null),0===e.length&&(e.ended||(e.needReadable=!0),n!==t&&e.ended&&ut(this)),null===i||e.errorEmitted||e.closeEmitted||(e.dataEmitted=!0,this.emit("data",i)),i},q.prototype._read=function(t){throw new O("_read()")},q.prototype.pipe=function(t,e){const n=this,s=this._readableState;1===s.pipes.length&&(s.multiAwaitDrain||(s.multiAwaitDrain=!0,s.awaitDrainWriters=new c(s.awaitDrainWriters?[s.awaitDrainWriters]:[]))),s.pipes.push(t),b("pipe count=%d opts=%j",s.pipes.length,e);const r=(!e||!1!==e.end)&&t!==i.stdout&&t!==i.stderr?o:g;function a(e,i){b("onunpipe"),e===n&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,function(){b("cleanup"),t.removeListener("close",f),t.removeListener("finish",m),l&&t.removeListener("drain",l);t.removeListener("error",d),t.removeListener("unpipe",a),n.removeListener("end",o),n.removeListener("end",g),n.removeListener("data",p),u=!0,l&&s.awaitDrainWriters&&(!t._writableState||t._writableState.needDrain)&&l()}())}function o(){b("onend"),t.end()}let l;s.endEmitted?i.nextTick(r):n.once("end",r),t.on("unpipe",a);let u=!1;function h(){u||(1===s.pipes.length&&s.pipes[0]===t?(b("false write response, pause",0),s.awaitDrainWriters=t,s.multiAwaitDrain=!1):s.pipes.length>1&&s.pipes.includes(t)&&(b("false write response, pause",s.awaitDrainWriters.size),s.awaitDrainWriters.add(t)),n.pause()),l||(l=function(t,e){return function(){const n=t._readableState;n.awaitDrainWriters===e?(b("pipeOnDrain",1),n.awaitDrainWriters=null):n.multiAwaitDrain&&(b("pipeOnDrain",n.awaitDrainWriters.size),n.awaitDrainWriters.delete(e)),n.awaitDrainWriters&&0!==n.awaitDrainWriters.size||!t.listenerCount("data")||t.resume()}}(n,t),t.on("drain",l))}function p(e){b("ondata");const n=t.write(e);b("dest.write",n),!1===n&&h()}function d(e){if(b("onerror",e),g(),t.removeListener("error",d),0===t.listenerCount("error")){const n=t._writableState||t._readableState;n&&!n.errorEmitted?B(t,e):t.emit("error",e)}}function f(){t.removeListener("finish",m),g()}function m(){b("onfinish"),t.removeListener("close",f),g()}function g(){b("unpipe"),n.unpipe(t)}return n.on("data",p),T(t,"error",d),t.once("close",f),t.once("finish",m),t.emit("pipe",n),!0===t.writableNeedDrain?h():s.flowing||(b("pipe resume"),n.resume()),t},q.prototype.unpipe=function(t){const e=this._readableState;if(0===e.pipes.length)return this;if(!t){const t=e.pipes;e.pipes=[],this.pause();for(let e=0;e0,!1!==s.flowing&&this.resume()):"readable"===t&&(s.endEmitted||s.readableListening||(s.readableListening=s.needReadable=!0,s.flowing=!1,s.emittedReadable=!1,b("on readable",s.length,s.reading),s.length?Z(this):s.reading||i.nextTick(st,this))),n},q.prototype.addListener=q.prototype.on,q.prototype.removeListener=function(t,e){const n=_.prototype.removeListener.call(this,t,e);return"readable"===t&&i.nextTick(it,this),n},q.prototype.off=q.prototype.removeListener,q.prototype.removeAllListeners=function(t){const e=_.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||i.nextTick(it,this),e},q.prototype.resume=function(){const t=this._readableState;return t.flowing||(b("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,i.nextTick(rt,t,e))}(this,t)),t[L]=!1,this},q.prototype.pause=function(){return b("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(b("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState[L]=!0,this},q.prototype.wrap=function(t){let e=!1;t.on("data",(n=>{!this.push(n)&&t.pause&&(e=!0,t.pause())})),t.on("end",(()=>{this.push(null)})),t.on("error",(t=>{B(this,t)})),t.on("close",(()=>{this.destroy()})),t.on("destroy",(()=>{this.destroy()})),this._read=()=>{e&&t.resume&&(e=!1,t.resume())};const n=u(t);for(let e=1;e{"use strict";const{MathFloor:i,NumberIsInteger:s}=n(4184),{validateInteger:r}=n(6283),{ERR_INVALID_ARG_VALUE:a}=n(6605).codes;let o=16384,l=16;function u(t){return t?l:o}t.exports={getHighWaterMark:function(t,e,n,r){const o=function(t,e,n){return null!=t.highWaterMark?t.highWaterMark:e?t[n]:null}(e,r,n);if(null!=o){if(!s(o)||o<0){throw new a(r?`options.${n}`:"options.highWaterMark",o)}return i(o)}return u(t.objectMode)},getDefaultHighWaterMark:u,setDefaultHighWaterMark:function(t,e){r(e,"value",0),t?l=e:o=e}}},208:(t,e,n)=>{"use strict";const{ObjectSetPrototypeOf:i,Symbol:s}=n(4184);t.exports=u;const{ERR_METHOD_NOT_IMPLEMENTED:r}=n(6605).codes,a=n(4992),{getHighWaterMark:o}=n(9153);i(u.prototype,a.prototype),i(u,a);const l=s("kCallback");function u(t){if(!(this instanceof u))return new u(t);const e=t?o(this,t,"readableHighWaterMark",!0):null;0===e&&(t={...t,highWaterMark:null,readableHighWaterMark:e,writableHighWaterMark:t.writableHighWaterMark||0}),a.call(this,t),this._readableState.sync=!1,this[l]=null,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",p)}function h(t){"function"!=typeof this._flush||this.destroyed?(this.push(null),t&&t()):this._flush(((e,n)=>{e?t?t(e):this.destroy(e):(null!=n&&this.push(n),this.push(null),t&&t())}))}function p(){this._final!==h&&h.call(this)}u.prototype._final=h,u.prototype._transform=function(t,e,n){throw new r("_transform()")},u.prototype._write=function(t,e,n){const i=this._readableState,s=this._writableState,r=i.length;this._transform(t,e,((t,e)=>{t?n(t):(null!=e&&this.push(e),s.ended||r===i.length||i.length{"use strict";const{SymbolAsyncIterator:i,SymbolIterator:s,SymbolFor:r}=n(4184),a=r("nodejs.stream.destroyed"),o=r("nodejs.stream.errored"),l=r("nodejs.stream.readable"),u=r("nodejs.stream.writable"),h=r("nodejs.stream.disturbed"),p=r("nodejs.webstream.isClosedPromise"),c=r("nodejs.webstream.controllerErrorFunction");function d(t,e=!1){var n;return!(!t||"function"!=typeof t.pipe||"function"!=typeof t.on||e&&("function"!=typeof t.pause||"function"!=typeof t.resume)||t._writableState&&!1===(null===(n=t._readableState)||void 0===n?void 0:n.readable)||t._writableState&&!t._readableState)}function f(t){var e;return!(!t||"function"!=typeof t.write||"function"!=typeof t.on||t._readableState&&!1===(null===(e=t._writableState)||void 0===e?void 0:e.writable))}function m(t){return t&&(t._readableState||t._writableState||"function"==typeof t.write&&"function"==typeof t.on||"function"==typeof t.pipe&&"function"==typeof t.on)}function g(t){return!(!t||m(t)||"function"!=typeof t.pipeThrough||"function"!=typeof t.getReader||"function"!=typeof t.cancel)}function _(t){return!(!t||m(t)||"function"!=typeof t.getWriter||"function"!=typeof t.abort)}function T(t){return!(!t||m(t)||"object"!=typeof t.readable||"object"!=typeof t.writable)}function y(t){if(!m(t))return null;const e=t._writableState,n=t._readableState,i=e||n;return!!(t.destroyed||t[a]||null!=i&&i.destroyed)}function I(t){if(!f(t))return null;if(!0===t.writableEnded)return!0;const e=t._writableState;return(null==e||!e.errored)&&("boolean"!=typeof(null==e?void 0:e.ended)?null:e.ended)}function E(t,e){if(!d(t))return null;const n=t._readableState;return(null==n||!n.errored)&&("boolean"!=typeof(null==n?void 0:n.endEmitted)?null:!!(n.endEmitted||!1===e&&!0===n.ended&&0===n.length))}function b(t){return t&&null!=t[l]?t[l]:"boolean"!=typeof(null==t?void 0:t.readable)?null:!y(t)&&(d(t)&&t.readable&&!E(t))}function v(t){return t&&null!=t[u]?t[u]:"boolean"!=typeof(null==t?void 0:t.writable)?null:!y(t)&&(f(t)&&t.writable&&!I(t))}function w(t){return"boolean"==typeof t._closed&&"boolean"==typeof t._defaultKeepAlive&&"boolean"==typeof t._removedConnection&&"boolean"==typeof t._removedContLen}function S(t){return"boolean"==typeof t._sent100&&w(t)}t.exports={isDestroyed:y,kIsDestroyed:a,isDisturbed:function(t){var e;return!(!t||!(null!==(e=t[h])&&void 0!==e?e:t.readableDidRead||t.readableAborted))},kIsDisturbed:h,isErrored:function(t){var e,n,i,s,r,a,l,u,h,p;return!(!t||!(null!==(e=null!==(n=null!==(i=null!==(s=null!==(r=null!==(a=t[o])&&void 0!==a?a:t.readableErrored)&&void 0!==r?r:t.writableErrored)&&void 0!==s?s:null===(l=t._readableState)||void 0===l?void 0:l.errorEmitted)&&void 0!==i?i:null===(u=t._writableState)||void 0===u?void 0:u.errorEmitted)&&void 0!==n?n:null===(h=t._readableState)||void 0===h?void 0:h.errored)&&void 0!==e?e:null===(p=t._writableState)||void 0===p?void 0:p.errored))},kIsErrored:o,isReadable:b,kIsReadable:l,kIsClosedPromise:p,kControllerErrorFunction:c,kIsWritable:u,isClosed:function(t){if(!m(t))return null;if("boolean"==typeof t.closed)return t.closed;const e=t._writableState,n=t._readableState;return"boolean"==typeof(null==e?void 0:e.closed)||"boolean"==typeof(null==n?void 0:n.closed)?(null==e?void 0:e.closed)||(null==n?void 0:n.closed):"boolean"==typeof t._closed&&w(t)?t._closed:null},isDuplexNodeStream:function(t){return!(!t||"function"!=typeof t.pipe||!t._readableState||"function"!=typeof t.on||"function"!=typeof t.write)},isFinished:function(t,e){return m(t)?!!y(t)||(!1===(null==e?void 0:e.readable)||!b(t))&&(!1===(null==e?void 0:e.writable)||!v(t)):null},isIterable:function(t,e){return null!=t&&(!0===e?"function"==typeof t[i]:!1===e?"function"==typeof t[s]:"function"==typeof t[i]||"function"==typeof t[s])},isReadableNodeStream:d,isReadableStream:g,isReadableEnded:function(t){if(!d(t))return null;if(!0===t.readableEnded)return!0;const e=t._readableState;return!(!e||e.errored)&&("boolean"!=typeof(null==e?void 0:e.ended)?null:e.ended)},isReadableFinished:E,isReadableErrored:function(t){var e,n;return m(t)?t.readableErrored?t.readableErrored:null!==(e=null===(n=t._readableState)||void 0===n?void 0:n.errored)&&void 0!==e?e:null:null},isNodeStream:m,isWebStream:function(t){return g(t)||_(t)||T(t)},isWritable:v,isWritableNodeStream:f,isWritableStream:_,isWritableEnded:I,isWritableFinished:function(t,e){if(!f(t))return null;if(!0===t.writableFinished)return!0;const n=t._writableState;return(null==n||!n.errored)&&("boolean"!=typeof(null==n?void 0:n.finished)?null:!!(n.finished||!1===e&&!0===n.ended&&0===n.length))},isWritableErrored:function(t){var e,n;return m(t)?t.writableErrored?t.writableErrored:null!==(e=null===(n=t._writableState)||void 0===n?void 0:n.errored)&&void 0!==e?e:null:null},isServerRequest:function(t){var e;return"boolean"==typeof t._consuming&&"boolean"==typeof t._dumped&&void 0===(null===(e=t.req)||void 0===e?void 0:e.upgradeOrConnect)},isServerResponse:S,willEmitClose:function(t){if(!m(t))return null;const e=t._writableState,n=t._readableState,i=e||n;return!i&&S(t)||!!(i&&i.autoDestroy&&i.emitClose&&!1===i.closed)},isTransformStream:T}},394:(t,e,n)=>{const i=n(5606),{ArrayPrototypeSlice:s,Error:r,FunctionPrototypeSymbolHasInstance:a,ObjectDefineProperty:o,ObjectDefineProperties:l,ObjectSetPrototypeOf:u,StringPrototypeToLowerCase:h,Symbol:p,SymbolHasInstance:c}=n(4184);t.exports=D,D.WritableState=N;const{EventEmitter:d}=n(7007),f=n(2913).Stream,{Buffer:m}=n(8287),g=n(2430),{addAbortSignal:_}=n(153),{getHighWaterMark:T,getDefaultHighWaterMark:y}=n(9153),{ERR_INVALID_ARG_TYPE:I,ERR_METHOD_NOT_IMPLEMENTED:E,ERR_MULTIPLE_CALLBACK:b,ERR_STREAM_CANNOT_PIPE:v,ERR_STREAM_DESTROYED:w,ERR_STREAM_ALREADY_FINISHED:S,ERR_STREAM_NULL_VALUES:x,ERR_STREAM_WRITE_AFTER_END:R,ERR_UNKNOWN_ENCODING:A}=n(6605).codes,{errorOrDestroy:O}=g;function M(){}u(D.prototype,f.prototype),u(D,f);const C=p("kOnFinished");function N(t,e,i){"boolean"!=typeof i&&(i=e instanceof n(4992)),this.objectMode=!(!t||!t.objectMode),i&&(this.objectMode=this.objectMode||!(!t||!t.writableObjectMode)),this.highWaterMark=t?T(this,t,"writableHighWaterMark",i):y(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;const s=!(!t||!1!==t.decodeStrings);this.decodeStrings=!s,this.defaultEncoding=t&&t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=$.bind(void 0,e),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,k(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!t||!1!==t.emitClose,this.autoDestroy=!t||!1!==t.autoDestroy,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[C]=[]}function k(t){t.buffered=[],t.bufferedIndex=0,t.allBuffers=!0,t.allNoop=!0}function D(t){const e=this instanceof n(4992);if(!e&&!a(D,this))return new D(t);this._writableState=new N(t,this,e),t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final),"function"==typeof t.construct&&(this._construct=t.construct),t.signal&&_(t.signal,this)),f.call(this,t),g.construct(this,(()=>{const t=this._writableState;t.writing||Y(this,t),W(this,t)}))}function L(t,e,n,s){const r=t._writableState;if("function"==typeof n)s=n,n=r.defaultEncoding;else{if(n){if("buffer"!==n&&!m.isEncoding(n))throw new A(n)}else n=r.defaultEncoding;"function"!=typeof s&&(s=M)}if(null===e)throw new x;if(!r.objectMode)if("string"==typeof e)!1!==r.decodeStrings&&(e=m.from(e,n),n="buffer");else if(e instanceof m)n="buffer";else{if(!f._isUint8Array(e))throw new I("chunk",["string","Buffer","Uint8Array"],e);e=f._uint8ArrayToBuffer(e),n="buffer"}let a;return r.ending?a=new R:r.destroyed&&(a=new w("write")),a?(i.nextTick(s,a),O(t,a,!0),a):(r.pendingcb++,function(t,e,n,i,s){const r=e.objectMode?1:n.length;e.length+=r;const a=e.lengthn.bufferedIndex&&Y(t,n),s?null!==n.afterWriteTickInfo&&n.afterWriteTickInfo.cb===r?n.afterWriteTickInfo.count++:(n.afterWriteTickInfo={count:1,cb:r,stream:t,state:n},i.nextTick(B,n.afterWriteTickInfo)):V(t,n,1,r))):O(t,new b)}function B({stream:t,state:e,count:n,cb:i}){return e.afterWriteTickInfo=null,V(t,e,n,i)}function V(t,e,n,i){for(!e.ending&&!t.destroyed&&0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"));n-- >0;)e.pendingcb--,i();e.destroyed&&U(e),W(t,e)}function U(t){if(t.writing)return;for(let n=t.bufferedIndex;n1&&t._writev){e.pendingcb-=a-1;const i=e.allNoop?M:t=>{for(let e=o;e256?(n.splice(0,o),e.bufferedIndex=0):e.bufferedIndex=o}e.bufferProcessing=!1}function G(t){return t.ending&&!t.destroyed&&t.constructed&&0===t.length&&!t.errored&&0===t.buffered.length&&!t.finished&&!t.writing&&!t.errorEmitted&&!t.closeEmitted}function H(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.finalCalled=!0,function(t,e){let n=!1;function s(s){if(n)O(t,null!=s?s:b());else if(n=!0,e.pendingcb--,s){const n=e[C].splice(0);for(let t=0;t{G(e)?z(t,e):e.pendingcb--}),t,e)):G(e)&&(e.pendingcb++,z(t,e))))}function z(t,e){e.pendingcb--,e.finished=!0;const n=e[C].splice(0);for(let t=0;t{"use strict";const{ArrayIsArray:i,ArrayPrototypeIncludes:s,ArrayPrototypeJoin:r,ArrayPrototypeMap:a,NumberIsInteger:o,NumberIsNaN:l,NumberMAX_SAFE_INTEGER:u,NumberMIN_SAFE_INTEGER:h,NumberParseInt:p,ObjectPrototypeHasOwnProperty:c,RegExpPrototypeExec:d,String:f,StringPrototypeToUpperCase:m,StringPrototypeTrim:g}=n(4184),{hideStackFrames:_,codes:{ERR_SOCKET_BAD_PORT:T,ERR_INVALID_ARG_TYPE:y,ERR_INVALID_ARG_VALUE:I,ERR_OUT_OF_RANGE:E,ERR_UNKNOWN_SIGNAL:b}}=n(6605),{normalizeEncoding:v}=n(798),{isAsyncFunction:w,isArrayBufferView:S}=n(798).types,x={};const R=/^[0-7]+$/;const A=_(((t,e,n=h,i=u)=>{if("number"!=typeof t)throw new y(e,"number",t);if(!o(t))throw new E(e,"an integer",t);if(ti)throw new E(e,`>= ${n} && <= ${i}`,t)})),O=_(((t,e,n=-2147483648,i=2147483647)=>{if("number"!=typeof t)throw new y(e,"number",t);if(!o(t))throw new E(e,"an integer",t);if(ti)throw new E(e,`>= ${n} && <= ${i}`,t)})),M=_(((t,e,n=!1)=>{if("number"!=typeof t)throw new y(e,"number",t);if(!o(t))throw new E(e,"an integer",t);const i=n?1:0,s=4294967295;if(ts)throw new E(e,`>= ${i} && <= ${s}`,t)}));function C(t,e){if("string"!=typeof t)throw new y(e,"string",t)}const N=_(((t,e,n)=>{if(!s(n,t)){const i=r(a(n,(t=>"string"==typeof t?`'${t}'`:f(t))),", ");throw new I(e,t,"must be one of: "+i)}}));function k(t,e){if("boolean"!=typeof t)throw new y(e,"boolean",t)}function D(t,e,n){return null!=t&&c(t,e)?t[e]:n}const L=_(((t,e,n=null)=>{const s=D(n,"allowArray",!1),r=D(n,"allowFunction",!1);if(!D(n,"nullable",!1)&&null===t||!s&&i(t)||"object"!=typeof t&&(!r||"function"!=typeof t))throw new y(e,"Object",t)})),F=_(((t,e)=>{if(null!=t&&"object"!=typeof t&&"function"!=typeof t)throw new y(e,"a dictionary",t)})),P=_(((t,e,n=0)=>{if(!i(t))throw new y(e,"Array",t);if(t.length{if(!S(t))throw new y(e,["Buffer","TypedArray","DataView"],t)}));const B=_(((t,e)=>{if(void 0!==t&&(null===t||"object"!=typeof t||!("aborted"in t)))throw new y(e,"AbortSignal",t)})),V=_(((t,e)=>{if("function"!=typeof t)throw new y(e,"Function",t)})),U=_(((t,e)=>{if("function"!=typeof t||w(t))throw new y(e,"Function",t)})),Y=_(((t,e)=>{if(void 0!==t)throw new y(e,"undefined",t)}));const G=/^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;function H(t,e){if(void 0===t||!d(G,t))throw new I(e,t,'must be an array or string of format "; rel=preload; as=style"')}t.exports={isInt32:function(t){return t===(0|t)},isUint32:function(t){return t===t>>>0},parseFileMode:function(t,e,n){if(void 0===t&&(t=n),"string"==typeof t){if(null===d(R,t))throw new I(e,t,"must be a 32-bit unsigned integer or an octal string");t=p(t,8)}return M(t,e),t},validateArray:P,validateStringArray:function(t,e){P(t,e);for(let n=0;ni||(null!=n||null!=i)&&l(t))throw new E(e,`${null!=n?`>= ${n}`:""}${null!=n&&null!=i?" && ":""}${null!=i?`<= ${i}`:""}`,t)},validateObject:L,validateOneOf:N,validatePlainFunction:U,validatePort:function(t,e="Port",n=!0){if("number"!=typeof t&&"string"!=typeof t||"string"==typeof t&&0===g(t).length||+t!=+t>>>0||t>65535||0===t&&!n)throw new T(e,t,n);return 0|t},validateSignalName:function(t,e="signal"){if(C(t,e),void 0===x[t]){if(void 0!==x[m(t)])throw new b(t+" (signals must use all capital letters)");throw new b(t)}},validateString:C,validateUint32:M,validateUndefined:Y,validateUnion:function(t,e,n){if(!s(n,t))throw new y(e,`('${r(n,"|")}')`,t)},validateAbortSignal:B,validateLinkHeaderValue:function(t){if("string"==typeof t)return H(t,"hints"),t;if(i(t)){const e=t.length;let n="";if(0===e)return n;for(let i=0;i; rel=preload; as=style"')}}},6248:(t,e,n)=>{"use strict";const i=n(4612),s=n(105),r=i.Readable.destroy;t.exports=i.Readable,t.exports._uint8ArrayToBuffer=i._uint8ArrayToBuffer,t.exports._isUint8Array=i._isUint8Array,t.exports.isDisturbed=i.isDisturbed,t.exports.isErrored=i.isErrored,t.exports.isReadable=i.isReadable,t.exports.Readable=i.Readable,t.exports.Writable=i.Writable,t.exports.Duplex=i.Duplex,t.exports.Transform=i.Transform,t.exports.PassThrough=i.PassThrough,t.exports.addAbortSignal=i.addAbortSignal,t.exports.finished=i.finished,t.exports.destroy=i.destroy,t.exports.destroy=r,t.exports.pipeline=i.pipeline,t.exports.compose=i.compose,Object.defineProperty(i,"promises",{configurable:!0,enumerable:!0,get:()=>s}),t.exports.Stream=i.Stream,t.exports.default=t.exports},6605:(t,e,n)=>{"use strict";const{format:i,inspect:s,AggregateError:r}=n(798),a=globalThis.AggregateError||r,o=Symbol("kIsNodeError"),l=["string","function","number","object","Function","Object","boolean","bigint","symbol"],u=/^([A-Z][a-z0-9]*)+$/,h={};function p(t,e){if(!t)throw new h.ERR_INTERNAL_ASSERTION(e)}function c(t){let e="",n=t.length;const i="-"===t[0]?1:0;for(;n>=i+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function d(t,e,n){n||(n=Error);class s extends n{constructor(...n){super(function(t,e,n){if("function"==typeof e)return p(e.length<=n.length,`Code: ${t}; The provided arguments length (${n.length}) does not match the required ones (${e.length}).`),e(...n);const s=(e.match(/%[dfijoOs]/g)||[]).length;return p(s===n.length,`Code: ${t}; The provided arguments length (${n.length}) does not match the required ones (${s}).`),0===n.length?e:i(e,...n)}(t,e,n))}toString(){return`${this.name} [${t}]: ${this.message}`}}Object.defineProperties(s.prototype,{name:{value:n.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${t}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),s.prototype.code=t,s.prototype[o]=!0,h[t]=s}function f(t){const e="__node_internal_"+t.name;return Object.defineProperty(t,"name",{value:e}),t}class m extends Error{constructor(t="The operation was aborted",e=void 0){if(void 0!==e&&"object"!=typeof e)throw new h.ERR_INVALID_ARG_TYPE("options","Object",e);super(t,e),this.code="ABORT_ERR",this.name="AbortError"}}d("ERR_ASSERTION","%s",Error),d("ERR_INVALID_ARG_TYPE",((t,e,n)=>{p("string"==typeof t,"'name' must be a string"),Array.isArray(e)||(e=[e]);let i="The ";t.endsWith(" argument")?i+=`${t} `:i+=`"${t}" ${t.includes(".")?"property":"argument"} `,i+="must be ";const r=[],a=[],o=[];for(const t of e)p("string"==typeof t,"All expected entries have to be of type string"),l.includes(t)?r.push(t.toLowerCase()):u.test(t)?a.push(t):(p("object"!==t,'The value "object" should be written as "Object"'),o.push(t));if(a.length>0){const t=r.indexOf("object");-1!==t&&(r.splice(r,t,1),a.push("Object"))}if(r.length>0){switch(r.length){case 1:i+=`of type ${r[0]}`;break;case 2:i+=`one of type ${r[0]} or ${r[1]}`;break;default:{const t=r.pop();i+=`one of type ${r.join(", ")}, or ${t}`}}(a.length>0||o.length>0)&&(i+=" or ")}if(a.length>0){switch(a.length){case 1:i+=`an instance of ${a[0]}`;break;case 2:i+=`an instance of ${a[0]} or ${a[1]}`;break;default:{const t=a.pop();i+=`an instance of ${a.join(", ")}, or ${t}`}}o.length>0&&(i+=" or ")}switch(o.length){case 0:break;case 1:o[0].toLowerCase()!==o[0]&&(i+="an "),i+=`${o[0]}`;break;case 2:i+=`one of ${o[0]} or ${o[1]}`;break;default:{const t=o.pop();i+=`one of ${o.join(", ")}, or ${t}`}}if(null==n)i+=`. Received ${n}`;else if("function"==typeof n&&n.name)i+=`. Received function ${n.name}`;else if("object"==typeof n){var h;if(null!==(h=n.constructor)&&void 0!==h&&h.name)i+=`. Received an instance of ${n.constructor.name}`;else{i+=`. Received ${s(n,{depth:-1})}`}}else{let t=s(n,{colors:!1});t.length>25&&(t=`${t.slice(0,25)}...`),i+=`. Received type ${typeof n} (${t})`}return i}),TypeError),d("ERR_INVALID_ARG_VALUE",((t,e,n="is invalid")=>{let i=s(e);i.length>128&&(i=i.slice(0,128)+"...");return`The ${t.includes(".")?"property":"argument"} '${t}' ${n}. Received ${i}`}),TypeError),d("ERR_INVALID_RETURN_VALUE",((t,e,n)=>{var i;return`Expected ${t} to be returned from the "${e}" function but got ${null!=n&&null!==(i=n.constructor)&&void 0!==i&&i.name?`instance of ${n.constructor.name}`:"type "+typeof n}.`}),TypeError),d("ERR_MISSING_ARGS",((...t)=>{let e;p(t.length>0,"At least one arg needs to be specified");const n=t.length;switch(t=(Array.isArray(t)?t:[t]).map((t=>`"${t}"`)).join(" or "),n){case 1:e+=`The ${t[0]} argument`;break;case 2:e+=`The ${t[0]} and ${t[1]} arguments`;break;default:{const n=t.pop();e+=`The ${t.join(", ")}, and ${n} arguments`}}return`${e} must be specified`}),TypeError),d("ERR_OUT_OF_RANGE",((t,e,n)=>{let i;return p(e,'Missing "range" argument'),Number.isInteger(n)&&Math.abs(n)>2**32?i=c(String(n)):"bigint"==typeof n?(i=String(n),(n>2n**32n||n<-(2n**32n))&&(i=c(i)),i+="n"):i=s(n),`The value of "${t}" is out of range. It must be ${e}. Received ${i}`}),RangeError),d("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error),d("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error),d("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error),d("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error),d("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error),d("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),d("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error),d("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error),d("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error),d("ERR_STREAM_WRITE_AFTER_END","write after end",Error),d("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError),t.exports={AbortError:m,aggregateTwoErrors:f((function(t,e){if(t&&e&&t!==e){if(Array.isArray(e.errors))return e.errors.push(t),e;const n=new a([e,t],e.message);return n.code=e.code,n}return t||e})),hideStackFrames:f,codes:h}},4184:t=>{"use strict";t.exports={ArrayIsArray:t=>Array.isArray(t),ArrayPrototypeIncludes:(t,e)=>t.includes(e),ArrayPrototypeIndexOf:(t,e)=>t.indexOf(e),ArrayPrototypeJoin:(t,e)=>t.join(e),ArrayPrototypeMap:(t,e)=>t.map(e),ArrayPrototypePop:(t,e)=>t.pop(e),ArrayPrototypePush:(t,e)=>t.push(e),ArrayPrototypeSlice:(t,e,n)=>t.slice(e,n),Error,FunctionPrototypeCall:(t,e,...n)=>t.call(e,...n),FunctionPrototypeSymbolHasInstance:(t,e)=>Function.prototype[Symbol.hasInstance].call(t,e),MathFloor:Math.floor,Number,NumberIsInteger:Number.isInteger,NumberIsNaN:Number.isNaN,NumberMAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,NumberParseInt:Number.parseInt,ObjectDefineProperties:(t,e)=>Object.defineProperties(t,e),ObjectDefineProperty:(t,e,n)=>Object.defineProperty(t,e,n),ObjectGetOwnPropertyDescriptor:(t,e)=>Object.getOwnPropertyDescriptor(t,e),ObjectKeys:t=>Object.keys(t),ObjectSetPrototypeOf:(t,e)=>Object.setPrototypeOf(t,e),Promise,PromisePrototypeCatch:(t,e)=>t.catch(e),PromisePrototypeThen:(t,e,n)=>t.then(e,n),PromiseReject:t=>Promise.reject(t),PromiseResolve:t=>Promise.resolve(t),ReflectApply:Reflect.apply,RegExpPrototypeTest:(t,e)=>t.test(e),SafeSet:Set,String,StringPrototypeSlice:(t,e,n)=>t.slice(e,n),StringPrototypeToLowerCase:t=>t.toLowerCase(),StringPrototypeToUpperCase:t=>t.toUpperCase(),StringPrototypeTrim:t=>t.trim(),Symbol,SymbolFor:Symbol.for,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,SymbolDispose:Symbol.dispose||Symbol("Symbol.dispose"),SymbolAsyncDispose:Symbol.asyncDispose||Symbol("Symbol.asyncDispose"),TypedArrayPrototypeSet:(t,e,n)=>t.set(e,n),Boolean,Uint8Array}},798:(t,e,n)=>{"use strict";const i=n(8287),{kResistStopPropagation:s,SymbolDispose:r}=n(4184),a=globalThis.AbortSignal||n(5568).AbortSignal,o=globalThis.AbortController||n(5568).AbortController,l=Object.getPrototypeOf((async function(){})).constructor,u=globalThis.Blob||i.Blob,h=void 0!==u?function(t){return t instanceof u}:function(t){return!1},p=(t,e)=>{if(void 0!==t&&(null===t||"object"!=typeof t||!("aborted"in t)))throw new ERR_INVALID_ARG_TYPE(e,"AbortSignal",t)};class c extends Error{constructor(t){if(!Array.isArray(t))throw new TypeError("Expected input to be an Array, got "+typeof t);let e="";for(let n=0;n{t=n,e=i})),resolve:t,reject:e}},promisify:t=>new Promise(((e,n)=>{t(((t,...i)=>t?n(t):e(...i)))})),debuglog:()=>function(){},format:(t,...e)=>t.replace(/%([sdifj])/g,(function(...[t,n]){const i=e.shift();if("f"===n)return i.toFixed(6);if("j"===n)return JSON.stringify(i);if("s"===n&&"object"==typeof i){return`${i.constructor!==Object?i.constructor.name:""} {}`.trim()}return i.toString()})),inspect(t){switch(typeof t){case"string":if(t.includes("'")){if(!t.includes('"'))return`"${t}"`;if(!t.includes("`")&&!t.includes("${"))return`\`${t}\``}return`'${t}'`;case"number":return isNaN(t)?"NaN":Object.is(t,-0)?String(t):t;case"bigint":return`${String(t)}n`;case"boolean":case"undefined":return String(t);case"object":return"{}"}},types:{isAsyncFunction:t=>t instanceof l,isArrayBufferView:t=>ArrayBuffer.isView(t)},isBlob:h,deprecate:(t,e)=>t,addAbortListener:n(7007).addAbortListener||function(t,e){if(void 0===t)throw new ERR_INVALID_ARG_TYPE("signal","AbortSignal",t);let n;return p(t,"signal"),((t,e)=>{if("function"!=typeof t)throw new ERR_INVALID_ARG_TYPE(e,"Function",t)})(e,"listener"),t.aborted?queueMicrotask((()=>e())):(t.addEventListener("abort",e,{__proto__:null,once:!0,[s]:!0}),n=()=>{t.removeEventListener("abort",e)}),{__proto__:null,[r](){var t;null===(t=n)||void 0===t||t()}}},AbortSignalAny:a.any||function(t){if(1===t.length)return t[0];const e=new o,n=()=>e.abort();return t.forEach((t=>{p(t,"signals"),t.addEventListener("abort",n,{once:!0})})),e.signal.addEventListener("abort",(()=>{t.forEach((t=>t.removeEventListener("abort",n)))}),{once:!0}),e.signal}},t.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")},4612:(t,e,n)=>{const{Buffer:i}=n(8287),{ObjectDefineProperty:s,ObjectKeys:r,ReflectApply:a}=n(4184),{promisify:{custom:o}}=n(798),{streamReturningOperators:l,promiseReturningOperators:u}=n(5589),{codes:{ERR_ILLEGAL_CONSTRUCTOR:h}}=n(6605),p=n(6864),{setDefaultHighWaterMark:c,getDefaultHighWaterMark:d}=n(9153),{pipeline:f}=n(872),{destroyer:m}=n(2430),g=n(9700),_=n(105),T=n(6569),y=t.exports=n(2913).Stream;y.isDestroyed=T.isDestroyed,y.isDisturbed=T.isDisturbed,y.isErrored=T.isErrored,y.isReadable=T.isReadable,y.isWritable=T.isWritable,y.Readable=n(6566);for(const b of r(l)){const v=l[b];function I(...t){if(new.target)throw h();return y.Readable.from(a(v,this,t))}s(I,"name",{__proto__:null,value:v.name}),s(I,"length",{__proto__:null,value:v.length}),s(y.Readable.prototype,b,{__proto__:null,value:I,enumerable:!1,configurable:!0,writable:!0})}for(const w of r(u)){const S=u[w];function I(...t){if(new.target)throw h();return a(S,this,t)}s(I,"name",{__proto__:null,value:S.name}),s(I,"length",{__proto__:null,value:S.length}),s(y.Readable.prototype,w,{__proto__:null,value:I,enumerable:!1,configurable:!0,writable:!0})}y.Writable=n(394),y.Duplex=n(4992),y.Transform=n(208),y.PassThrough=n(6898),y.pipeline=f;const{addAbortSignal:E}=n(153);y.addAbortSignal=E,y.finished=g,y.destroy=m,y.compose=p,y.setDefaultHighWaterMark=c,y.getDefaultHighWaterMark=d,s(y,"promises",{__proto__:null,configurable:!0,enumerable:!0,get:()=>_}),s(f,o,{__proto__:null,enumerable:!0,get:()=>_.pipeline}),s(g,o,{__proto__:null,enumerable:!0,get:()=>_.finished}),y.Stream=y,y._isUint8Array=function(t){return t instanceof Uint8Array},y._uint8ArrayToBuffer=function(t){return i.from(t.buffer,t.byteOffset,t.byteLength)}},105:(t,e,n)=>{"use strict";const{ArrayPrototypePop:i,Promise:s}=n(4184),{isIterable:r,isNodeStream:a,isWebStream:o}=n(6569),{pipelineImpl:l}=n(872),{finished:u}=n(9700);n(4612),t.exports={finished:u,pipeline:function(...t){return new s(((e,n)=>{let s,u;const h=t[t.length-1];if(h&&"object"==typeof h&&!a(h)&&!r(h)&&!o(h)){const e=i(t);s=e.signal,u=e.end}l(t,((t,i)=>{t?n(t):e(i)}),{signal:s,end:u})}))}}},8707:(t,e,n)=>{"use strict";var i=n(5242).Buffer,s=i.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function r(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(i.isEncoding===s||!s(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=l,this.end=u,e=4;break;case"utf8":this.fillLast=o,e=4;break;case"base64":this.text=h,this.end=p,e=3;break;default:return this.write=c,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(e)}function a(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function o(t){var e=this.lastTotal-this.lastNeed,n=function(t,e){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==n?n:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function l(t,e){if((t.length-e)%2==0){var n=t.toString("utf16le",e);if(n){var i=n.charCodeAt(n.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function u(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,n)}return e}function h(t,e){var n=(t.length-e)%3;return 0===n?t.toString("base64",e):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-n))}function p(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function c(t){return t.toString(this.encoding)}function d(t){return t&&t.length?this.write(t):""}e.StringDecoder=r,r.prototype.write=function(t){if(0===t.length)return"";var e,n;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n=0)return s>0&&(t.lastNeed=s-1),s;if(--i=0)return s>0&&(t.lastNeed=s-2),s;if(--i=0)return s>0&&(2===s?s=0:t.lastNeed=s-3),s;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=n;var i=t.length-(n-this.lastNeed);return t.copy(this.lastChar,0,i),t.toString("utf8",e,i)},r.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},5568:t=>{"use strict";const{AbortController:e,AbortSignal:n}="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0;t.exports=e,t.exports.AbortSignal=n,t.exports.default=e},4083:(t,e,n)=>{var i; /*! * async * https://github.com/caolan/async * * Copyright 2010-2014 Caolan McMahon * Released under the MIT license */!function(){var s,r={};function a(){}function o(t){return t}function l(t){return!!t}function u(t){return!t}var h="object"==typeof self&&self.self===self&&self||"object"==typeof n.g&&n.g.global===n.g&&n.g||this;function p(t){return function(){if(null===t)throw new Error("Callback was already called.");t.apply(this,arguments),t=null}}function c(t){return function(){null!==t&&(t.apply(this,arguments),t=null)}}null!=h&&(s=h.async),r.noConflict=function(){return h.async=s,r};var d=Object.prototype.toString,f=Array.isArray||function(t){return"[object Array]"===d.call(t)};function m(t){return f(t)||"number"==typeof t.length&&t.length>=0&&t.length%1==0}function g(t,e){for(var n=-1,i=t.length;++n3?t(i,s,l,o):(a=r,r=s,t(i,l,o))}}function D(t,e){return e}function L(t,e,n){n=n||a;var i=m(e)?[]:{};t(e,(function(t,e,n){t(b((function(t,s){s.length<=1&&(s=s[0]),i[e]=s,n(t)})))}),(function(t){n(t,i)}))}function F(t,e,n,i){var s=[];t(e,(function(t,e,i){n(t,(function(t,e){s=s.concat(e||[]),i(t)}))}),(function(t){i(t,s)}))}function P(t,e,n){if(null==e)e=1;else if(0===e)throw new Error("Concurrency must not be zero");function i(t,e,n,i){if(null!=i&&"function"!=typeof i)throw new Error("task callback must be a function");if(t.started=!0,f(e)||(e=[e]),0===e.length&&t.idle())return r.setImmediate((function(){t.drain()}));g(e,(function(e){var s={data:e,callback:i||a};n?t.tasks.unshift(s):t.tasks.push(s),t.tasks.length===t.concurrency&&t.saturated()})),r.setImmediate(t.process)}function s(t,e){return function(){o-=1;var n=!1,i=arguments;g(e,(function(t){g(l,(function(e,i){e!==t||n||(l.splice(i,1),n=!0)})),t.callback.apply(t,i)})),t.tasks.length+o===0&&t.drain(),t.process()}}var o=0,l=[],u={tasks:[],concurrency:e,payload:n,saturated:a,empty:a,drain:a,started:!1,paused:!1,push:function(t,e){i(u,t,!1,e)},kill:function(){u.drain=a,u.tasks=[]},unshift:function(t,e){i(u,t,!0,e)},process:function(){for(;!u.paused&&oi?1:0}r.map(t,(function(t,n){e(t,(function(e,i){e?n(e):n(null,{value:t,criteria:i})}))}),(function(t,e){if(t)return n(t);n(null,_(e.sort(i),(function(t){return t.value})))}))},r.auto=function(t,e,n){"function"==typeof arguments[1]&&(n=e,e=null),n=c(n||a);var i=I(t),s=i.length;if(!s)return n(null);e||(e=s);var o={},l=0,u=!1,h=[];function p(t){h.unshift(t)}function d(){s--,g(h.slice(0),(function(t){t()}))}p((function(){s||n(null,o)})),g(i,(function(i){if(!u){for(var s,a=f(t[i])?t[i]:[t[i]],c=b((function(t,e){if(l--,e.length<=1&&(e=e[0]),t){var s={};h=function(t,e){s[e]=t},g(I(a=o),(function(t){h(a[t],t)})),s[i]=e,u=!0,n(t,s)}else o[i]=e,r.setImmediate(d);var a,h})),m=a.slice(0,a.length-1),_=m.length;_--;){if(!(s=t[m[_]]))throw new Error("Has nonexistent dependency in "+m.join(", "));if(f(s)&&y(s,i)>=0)throw new Error("Has cyclic dependencies")}T()?(l++,a[a.length-1](c,o)):p((function t(){T()&&(l++,(e=y(h,t))>=0&&h.splice(e,1),a[a.length-1](c,o));var e}))}function T(){return l3)throw new Error("Invalid arguments - must be either (task), (task, callback), (times, task) or (times, task, callback)");function o(t,e){function n(t,n){return function(i){t((function(t,e){i(!t||n,{err:t,result:e})}),e)}}function a(t){return function(e){setTimeout((function(){e(null)}),t)}}for(;s.times;){var o=!(s.times-=1);i.push(n(s.task,o)),!o&&s.interval>0&&i.push(a(s.interval))}r.series(i,(function(e,n){n=n[n.length-1],(t||s.callback)(n.err,n.result)}))}return a<=2&&"function"==typeof t&&(n=e,e=t),"function"!=typeof t&&function(t,e){if("number"==typeof e)t.times=parseInt(e,10)||5;else{if("object"!=typeof e)throw new Error("Unsupported argument type for 'times': "+typeof e);t.times=parseInt(e.times,10)||5,t.interval=parseInt(e.interval,10)||0}}(s,t),s.callback=n,s.task=e,s.callback?o():o},r.waterfall=function(t,e){if(e=c(e||a),!f(t)){var n=new Error("First argument to waterfall must be an array of functions");return e(n)}if(!t.length)return e();!function t(n){return b((function(i,s){if(i)e.apply(null,[i].concat(s));else{var r=n.next();r?s.push(t(r)):s.push(e),U(n).apply(null,s)}}))}(r.iterator(t))()},r.parallel=function(t,e){L(r.eachOf,t,e)},r.parallelLimit=function(t,e,n){L(x(e),t,n)},r.series=function(t,e){L(r.eachOfSeries,t,e)},r.iterator=function(t){return function e(n){function i(){return t.length&&t[n].apply(null,arguments),i.next()}return i.next=function(){return n>>1);n(e,t[r])>=0?i=r:s=r-1}return i}(t.tasks,o,n)+1,0,o),t.tasks.length===t.concurrency&&t.saturated(),r.setImmediate(t.process)}))}(i,t,e,s)},delete i.unshift,i},r.cargo=function(t,e){return P(t,1,e)},r.log=$("log"),r.dir=$("dir"),r.memoize=function(t,e){var n={},i={},s=Object.prototype.hasOwnProperty;e=e||o;var a=b((function(a){var o=a.pop(),l=e.apply(null,a);s.call(n,l)?r.setImmediate((function(){o.apply(null,n[l])})):s.call(i,l)?i[l].push(o):(i[l]=[o],t.apply(null,a.concat([b((function(t){n[l]=t;var e=i[l];delete i[l];for(var s=0,r=e.length;s{"use strict";e.byteLength=function(t){var e=o(t),n=e[0],i=e[1];return 3*(n+i)/4-i},e.toByteArray=function(t){var e,n,r=o(t),a=r[0],l=r[1],u=new s(function(t,e,n){return 3*(e+n)/4-n}(0,a,l)),h=0,p=l>0?a-4:a;for(n=0;n>16&255,u[h++]=e>>8&255,u[h++]=255&e;2===l&&(e=i[t.charCodeAt(n)]<<2|i[t.charCodeAt(n+1)]>>4,u[h++]=255&e);1===l&&(e=i[t.charCodeAt(n)]<<10|i[t.charCodeAt(n+1)]<<4|i[t.charCodeAt(n+2)]>>2,u[h++]=e>>8&255,u[h++]=255&e);return u},e.fromByteArray=function(t){for(var e,i=t.length,s=i%3,r=[],a=16383,o=0,u=i-s;ou?u:o+a));1===s?(e=t[i-1],r.push(n[e>>2]+n[e<<4&63]+"==")):2===s&&(e=(t[i-2]<<8)+t[i-1],r.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return r.join("")};for(var n=[],i=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0;a<64;++a)n[a]=r[a],i[r.charCodeAt(a)]=a;function o(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function l(t,e,i){for(var s,r,a=[],o=e;o>18&63]+n[r>>12&63]+n[r>>6&63]+n[63&r]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},8287:(t,e,n)=>{"use strict"; /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */const i=n(7526),s=n(251),r="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=l,e.SlowBuffer=function(t){+t!=t&&(t=0);return l.alloc(+t)},e.INSPECT_MAX_BYTES=50;const a=2147483647;function o(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,l.prototype),e}function l(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return p(t)}return u(t,e,n)}function u(t,e,n){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!l.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const n=0|m(t,e);let i=o(n);const s=i.write(t,e);s!==n&&(i=i.slice(0,s));return i}(t,e);if(ArrayBuffer.isView(t))return function(t){if(q(t,Uint8Array)){const e=new Uint8Array(t);return d(e.buffer,e.byteOffset,e.byteLength)}return c(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(q(t,ArrayBuffer)||t&&q(t.buffer,ArrayBuffer))return d(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(q(t,SharedArrayBuffer)||t&&q(t.buffer,SharedArrayBuffer)))return d(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const i=t.valueOf&&t.valueOf();if(null!=i&&i!==t)return l.from(i,e,n);const s=function(t){if(l.isBuffer(t)){const e=0|f(t.length),n=o(e);return 0===n.length||t.copy(n,0,0,e),n}if(void 0!==t.length)return"number"!=typeof t.length||K(t.length)?o(0):c(t);if("Buffer"===t.type&&Array.isArray(t.data))return c(t.data)}(t);if(s)return s;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return l.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function h(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function p(t){return h(t),o(t<0?0:0|f(t))}function c(t){const e=t.length<0?0:0|f(t.length),n=o(e);for(let i=0;i=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function m(t,e){if(l.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||q(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const n=t.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===n)return 0;let s=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return z(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return X(t).length;default:if(s)return i?-1:z(t).length;e=(""+e).toLowerCase(),s=!0}}function g(t,e,n){let i=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return M(this,e,n);case"utf8":case"utf-8":return x(this,e,n);case"ascii":return A(this,e,n);case"latin1":case"binary":return O(this,e,n);case"base64":return S(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,n);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function _(t,e,n){const i=t[e];t[e]=t[n],t[n]=i}function T(t,e,n,i,s){if(0===t.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),K(n=+n)&&(n=s?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(s)return-1;n=t.length-1}else if(n<0){if(!s)return-1;n=0}if("string"==typeof e&&(e=l.from(e,i)),l.isBuffer(e))return 0===e.length?-1:y(t,e,n,i,s);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):y(t,[e],n,i,s);throw new TypeError("val must be string, number or Buffer")}function y(t,e,n,i,s){let r,a=1,o=t.length,l=e.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(t.length<2||e.length<2)return-1;a=2,o/=2,l/=2,n/=2}function u(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(s){let i=-1;for(r=n;ro&&(n=o-l),r=n;r>=0;r--){let n=!0;for(let i=0;is&&(i=s):i=s;const r=e.length;let a;for(i>r/2&&(i=r/2),a=0;a>8,s=n%256,r.push(s),r.push(i);return r}(e,t.length-n),t,n,i)}function S(t,e,n){return 0===e&&n===t.length?i.fromByteArray(t):i.fromByteArray(t.slice(e,n))}function x(t,e,n){n=Math.min(t.length,n);const i=[];let s=e;for(;s239?4:e>223?3:e>191?2:1;if(s+a<=n){let n,i,o,l;switch(a){case 1:e<128&&(r=e);break;case 2:n=t[s+1],128==(192&n)&&(l=(31&e)<<6|63&n,l>127&&(r=l));break;case 3:n=t[s+1],i=t[s+2],128==(192&n)&&128==(192&i)&&(l=(15&e)<<12|(63&n)<<6|63&i,l>2047&&(l<55296||l>57343)&&(r=l));break;case 4:n=t[s+1],i=t[s+2],o=t[s+3],128==(192&n)&&128==(192&i)&&128==(192&o)&&(l=(15&e)<<18|(63&n)<<12|(63&i)<<6|63&o,l>65535&&l<1114112&&(r=l))}}null===r?(r=65533,a=1):r>65535&&(r-=65536,i.push(r>>>10&1023|55296),r=56320|1023&r),i.push(r),s+=a}return function(t){const e=t.length;if(e<=R)return String.fromCharCode.apply(String,t);let n="",i=0;for(;ii.length?(l.isBuffer(e)||(e=l.from(e)),e.copy(i,s)):Uint8Array.prototype.set.call(i,e,s);else{if(!l.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(i,s)}s+=e.length}return i},l.byteLength=m,l.prototype._isBuffer=!0,l.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;en&&(t+=" ... "),""},r&&(l.prototype[r]=l.prototype.inspect),l.prototype.compare=function(t,e,n,i,s){if(q(t,Uint8Array)&&(t=l.from(t,t.offset,t.byteLength)),!l.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===i&&(i=0),void 0===s&&(s=this.length),e<0||n>t.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&e>=n)return 0;if(i>=s)return-1;if(e>=n)return 1;if(this===t)return 0;let r=(s>>>=0)-(i>>>=0),a=(n>>>=0)-(e>>>=0);const o=Math.min(r,a),u=this.slice(i,s),h=t.slice(e,n);for(let t=0;t>>=0,isFinite(n)?(n>>>=0,void 0===i&&(i="utf8")):(i=n,n=void 0)}const s=this.length-e;if((void 0===n||n>s)&&(n=s),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let r=!1;for(;;)switch(i){case"hex":return I(this,t,e,n);case"utf8":case"utf-8":return E(this,t,e,n);case"ascii":case"latin1":case"binary":return b(this,t,e,n);case"base64":return v(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,t,e,n);default:if(r)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),r=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const R=4096;function A(t,e,n){let i="";n=Math.min(t.length,n);for(let s=e;si)&&(n=i);let s="";for(let i=e;in)throw new RangeError("Trying to access beyond buffer length")}function k(t,e,n,i,s,r){if(!l.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>s||et.length)throw new RangeError("Index out of range")}function D(t,e,n,i,s){Y(e,i,s,t,n,7);let r=Number(e&BigInt(4294967295));t[n++]=r,r>>=8,t[n++]=r,r>>=8,t[n++]=r,r>>=8,t[n++]=r;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=a,a>>=8,t[n++]=a,a>>=8,t[n++]=a,a>>=8,t[n++]=a,n}function L(t,e,n,i,s){Y(e,i,s,t,n,7);let r=Number(e&BigInt(4294967295));t[n+7]=r,r>>=8,t[n+6]=r,r>>=8,t[n+5]=r,r>>=8,t[n+4]=r;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=a,a>>=8,t[n+2]=a,a>>=8,t[n+1]=a,a>>=8,t[n]=a,n+8}function F(t,e,n,i,s,r){if(n+i>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function P(t,e,n,i,r){return e=+e,n>>>=0,r||F(t,0,n,4),s.write(t,e,n,i,23,4),n+4}function $(t,e,n,i,r){return e=+e,n>>>=0,r||F(t,0,n,8),s.write(t,e,n,i,52,8),n+8}l.prototype.slice=function(t,e){const n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e>>=0,e>>>=0,n||N(t,e,this.length);let i=this[t],s=1,r=0;for(;++r>>=0,e>>>=0,n||N(t,e,this.length);let i=this[t+--e],s=1;for(;e>0&&(s*=256);)i+=this[t+--e]*s;return i},l.prototype.readUint8=l.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},l.prototype.readUint16LE=l.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},l.prototype.readUint16BE=l.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},l.prototype.readUint32LE=l.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},l.prototype.readUint32BE=l.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},l.prototype.readBigUInt64LE=J((function(t){G(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||H(t,this.length-8);const i=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,s=this[++t]+256*this[++t]+65536*this[++t]+n*2**24;return BigInt(i)+(BigInt(s)<>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||H(t,this.length-8);const i=e*2**24+65536*this[++t]+256*this[++t]+this[++t],s=this[++t]*2**24+65536*this[++t]+256*this[++t]+n;return(BigInt(i)<>>=0,e>>>=0,n||N(t,e,this.length);let i=this[t],s=1,r=0;for(;++r=s&&(i-=Math.pow(2,8*e)),i},l.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||N(t,e,this.length);let i=e,s=1,r=this[t+--i];for(;i>0&&(s*=256);)r+=this[t+--i]*s;return s*=128,r>=s&&(r-=Math.pow(2,8*e)),r},l.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},l.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},l.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},l.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},l.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},l.prototype.readBigInt64LE=J((function(t){G(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||H(t,this.length-8);const i=this[t+4]+256*this[t+5]+65536*this[t+6]+(n<<24);return(BigInt(i)<>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||H(t,this.length-8);const i=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(i)<>>=0,e||N(t,4,this.length),s.read(this,t,!0,23,4)},l.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),s.read(this,t,!1,23,4)},l.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),s.read(this,t,!0,52,8)},l.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),s.read(this,t,!1,52,8)},l.prototype.writeUintLE=l.prototype.writeUIntLE=function(t,e,n,i){if(t=+t,e>>>=0,n>>>=0,!i){k(this,t,e,n,Math.pow(2,8*n)-1,0)}let s=1,r=0;for(this[e]=255&t;++r>>=0,n>>>=0,!i){k(this,t,e,n,Math.pow(2,8*n)-1,0)}let s=n-1,r=1;for(this[e+s]=255&t;--s>=0&&(r*=256);)this[e+s]=t/r&255;return e+n},l.prototype.writeUint8=l.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,1,255,0),this[e]=255&t,e+1},l.prototype.writeUint16LE=l.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},l.prototype.writeUint16BE=l.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},l.prototype.writeUint32LE=l.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},l.prototype.writeUint32BE=l.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},l.prototype.writeBigUInt64LE=J((function(t,e=0){return D(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),l.prototype.writeBigUInt64BE=J((function(t,e=0){return L(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),l.prototype.writeIntLE=function(t,e,n,i){if(t=+t,e>>>=0,!i){const i=Math.pow(2,8*n-1);k(this,t,e,n,i-1,-i)}let s=0,r=1,a=0;for(this[e]=255&t;++s>>=0,!i){const i=Math.pow(2,8*n-1);k(this,t,e,n,i-1,-i)}let s=n-1,r=1,a=0;for(this[e+s]=255&t;--s>=0&&(r*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/r|0)-a&255;return e+n},l.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},l.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},l.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},l.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},l.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},l.prototype.writeBigInt64LE=J((function(t,e=0){return D(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),l.prototype.writeBigInt64BE=J((function(t,e=0){return L(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),l.prototype.writeFloatLE=function(t,e,n){return P(this,t,e,!0,n)},l.prototype.writeFloatBE=function(t,e,n){return P(this,t,e,!1,n)},l.prototype.writeDoubleLE=function(t,e,n){return $(this,t,e,!0,n)},l.prototype.writeDoubleBE=function(t,e,n){return $(this,t,e,!1,n)},l.prototype.copy=function(t,e,n,i){if(!l.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),i||0===i||(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(s=e;s=i+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function Y(t,e,n,i,s,r){if(t>n||t3?0===e||e===BigInt(0)?`>= 0${i} and < 2${i} ** ${8*(r+1)}${i}`:`>= -(2${i} ** ${8*(r+1)-1}${i}) and < 2 ** ${8*(r+1)-1}${i}`:`>= ${e}${i} and <= ${n}${i}`,new B.ERR_OUT_OF_RANGE("value",s,t)}!function(t,e,n){G(e,"offset"),void 0!==t[e]&&void 0!==t[e+n]||H(e,t.length-(n+1))}(i,s,r)}function G(t,e){if("number"!=typeof t)throw new B.ERR_INVALID_ARG_TYPE(e,"number",t)}function H(t,e,n){if(Math.floor(t)!==t)throw G(t,n),new B.ERR_OUT_OF_RANGE(n||"offset","an integer",t);if(e<0)throw new B.ERR_BUFFER_OUT_OF_BOUNDS;throw new B.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}V("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),V("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),V("ERR_OUT_OF_RANGE",(function(t,e,n){let i=`The value of "${t}" is out of range.`,s=n;return Number.isInteger(n)&&Math.abs(n)>2**32?s=U(String(n)):"bigint"==typeof n&&(s=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(s=U(s)),s+="n"),i+=` It must be ${e}. Received ${s}`,i}),RangeError);const W=/[^+/0-9A-Za-z-_]/g;function z(t,e){let n;e=e||1/0;const i=t.length;let s=null;const r=[];for(let a=0;a55295&&n<57344){if(!s){if(n>56319){(e-=3)>-1&&r.push(239,191,189);continue}if(a+1===i){(e-=3)>-1&&r.push(239,191,189);continue}s=n;continue}if(n<56320){(e-=3)>-1&&r.push(239,191,189),s=n;continue}n=65536+(s-55296<<10|n-56320)}else s&&(e-=3)>-1&&r.push(239,191,189);if(s=null,n<128){if((e-=1)<0)break;r.push(n)}else if(n<2048){if((e-=2)<0)break;r.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;r.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;r.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return r}function X(t){return i.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(W,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function j(t,e,n,i){let s;for(s=0;s=e.length||s>=t.length);++s)e[s+n]=t[s];return s}function q(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function K(t){return t!=t}const Q=function(){const t="0123456789abcdef",e=new Array(256);for(let n=0;n<16;++n){const i=16*n;for(let s=0;s<16;++s)e[i+s]=t[n]+t[s]}return e}();function J(t){return"undefined"==typeof BigInt?Z:t}function Z(){throw new Error("BigInt not supported")}},6570:t=>{"use strict";function e(t,e,i){i=i||2;var r,a,o,l,p,c,f,m=e&&e.length,g=m?e[0]*i:t.length,_=n(t,0,g,i,!0),T=[];if(!_||_.next===_.prev)return T;if(m&&(_=function(t,e,i,s){var r,a,o,l=[];for(r=0,a=e.length;r80*i){r=o=t[0],a=l=t[1];for(var y=i;yo&&(o=p),c>l&&(l=c);f=0!==(f=Math.max(o-r,l-a))?32767/f:0}return s(_,T,i,r,a,f,0),T}function n(t,e,n,i,s){var r,a;if(s===x(t,e,n,i)>0)for(r=e;r=e;r-=i)a=v(r,t[r],t[r+1],a);return a&&_(a,a.next)&&(w(a),a=a.next),a}function i(t,e){if(!t)return t;e||(e=t);var n,i=t;do{if(n=!1,i.steiner||!_(i,i.next)&&0!==g(i.prev,i,i.next))i=i.next;else{if(w(i),(i=e=i.prev)===i.next)break;n=!0}}while(n||i!==e);return e}function s(t,e,n,u,h,p,d){if(t){!d&&p&&function(t,e,n,i){var s=t;do{0===s.z&&(s.z=c(s.x,s.y,e,n,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,function(t){var e,n,i,s,r,a,o,l,u=1;do{for(n=t,t=null,r=null,a=0;n;){for(a++,i=n,o=0,e=0;e0||l>0&&i;)0!==o&&(0===l||!i||n.z<=i.z)?(s=n,n=n.nextZ,o--):(s=i,i=i.nextZ,l--),r?r.nextZ=s:t=s,s.prevZ=r,r=s;n=i}r.nextZ=null,u*=2}while(a>1)}(s)}(t,u,h,p);for(var f,m,g=t;t.prev!==t.next;)if(f=t.prev,m=t.next,p?a(t,u,h,p):r(t))e.push(f.i/n|0),e.push(t.i/n|0),e.push(m.i/n|0),w(t),t=m.next,g=m.next;else if((t=m)===g){d?1===d?s(t=o(i(t),e,n),e,n,u,h,p,2):2===d&&l(t,e,n,u,h,p):s(i(t),e,n,u,h,p,1);break}}}function r(t){var e=t.prev,n=t,i=t.next;if(g(e,n,i)>=0)return!1;for(var s=e.x,r=n.x,a=i.x,o=e.y,l=n.y,u=i.y,h=sr?s>a?s:a:r>a?r:a,d=o>l?o>u?o:u:l>u?l:u,m=i.next;m!==e;){if(m.x>=h&&m.x<=c&&m.y>=p&&m.y<=d&&f(s,o,r,l,a,u,m.x,m.y)&&g(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function a(t,e,n,i){var s=t.prev,r=t,a=t.next;if(g(s,r,a)>=0)return!1;for(var o=s.x,l=r.x,u=a.x,h=s.y,p=r.y,d=a.y,m=ol?o>u?o:u:l>u?l:u,y=h>p?h>d?h:d:p>d?p:d,I=c(m,_,e,n,i),E=c(T,y,e,n,i),b=t.prevZ,v=t.nextZ;b&&b.z>=I&&v&&v.z<=E;){if(b.x>=m&&b.x<=T&&b.y>=_&&b.y<=y&&b!==s&&b!==a&&f(o,h,l,p,u,d,b.x,b.y)&&g(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,v.x>=m&&v.x<=T&&v.y>=_&&v.y<=y&&v!==s&&v!==a&&f(o,h,l,p,u,d,v.x,v.y)&&g(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;b&&b.z>=I;){if(b.x>=m&&b.x<=T&&b.y>=_&&b.y<=y&&b!==s&&b!==a&&f(o,h,l,p,u,d,b.x,b.y)&&g(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;v&&v.z<=E;){if(v.x>=m&&v.x<=T&&v.y>=_&&v.y<=y&&v!==s&&v!==a&&f(o,h,l,p,u,d,v.x,v.y)&&g(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function o(t,e,n){var s=t;do{var r=s.prev,a=s.next.next;!_(r,a)&&T(r,s,s.next,a)&&E(r,a)&&E(a,r)&&(e.push(r.i/n|0),e.push(s.i/n|0),e.push(a.i/n|0),w(s),w(s.next),s=t=a),s=s.next}while(s!==t);return i(s)}function l(t,e,n,r,a,o){var l=t;do{for(var u=l.next.next;u!==l.prev;){if(l.i!==u.i&&m(l,u)){var h=b(l,u);return l=i(l,l.next),h=i(h,h.next),s(l,e,n,r,a,o,0),void s(h,e,n,r,a,o,0)}u=u.next}l=l.next}while(l!==t)}function u(t,e){return t.x-e.x}function h(t,e){var n=function(t,e){var n,i=e,s=t.x,r=t.y,a=-1/0;do{if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){var o=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(o<=s&&o>a&&(a=o,n=i.x=i.x&&i.x>=h&&s!==i.x&&f(rn.x||i.x===n.x&&p(n,i)))&&(n=i,d=l)),i=i.next}while(i!==u);return n}(t,e);if(!n)return e;var s=b(n,t);return i(s,s.next),i(n,n.next)}function p(t,e){return g(t.prev,t,e.prev)<0&&g(e.next,t,t.next)<0}function c(t,e,n,i,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*s|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*s|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function d(t){var e=t,n=t;do{(e.x=(t-a)*(r-o)&&(t-a)*(i-o)>=(n-a)*(e-o)&&(n-a)*(r-o)>=(s-a)*(i-o)}function m(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&T(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(E(t,e)&&E(e,t)&&function(t,e){var n=t,i=!1,s=(t.x+e.x)/2,r=(t.y+e.y)/2;do{n.y>r!=n.next.y>r&&n.next.y!==n.y&&s<(n.next.x-n.x)*(r-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==t);return i}(t,e)&&(g(t.prev,t,e.prev)||g(t,e.prev,e))||_(t,e)&&g(t.prev,t,t.next)>0&&g(e.prev,e,e.next)>0)}function g(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function _(t,e){return t.x===e.x&&t.y===e.y}function T(t,e,n,i){var s=I(g(t,e,n)),r=I(g(t,e,i)),a=I(g(n,i,t)),o=I(g(n,i,e));return s!==r&&a!==o||(!(0!==s||!y(t,n,e))||(!(0!==r||!y(t,i,e))||(!(0!==a||!y(n,t,i))||!(0!==o||!y(n,e,i)))))}function y(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function I(t){return t>0?1:t<0?-1:0}function E(t,e){return g(t.prev,t,t.next)<0?g(t,e,t.next)>=0&&g(t,t.prev,e)>=0:g(t,e,t.prev)<0||g(t,t.next,e)<0}function b(t,e){var n=new S(t.i,t.x,t.y),i=new S(e.i,e.x,e.y),s=t.next,r=e.prev;return t.next=e,e.prev=t,n.next=s,s.prev=n,i.next=n,n.prev=i,r.next=i,i.prev=r,i}function v(t,e,n,i){var s=new S(t,e,n);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function w(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function S(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function x(t,e,n,i){for(var s=0,r=e,a=n-i;r0&&(i+=t[s-1].length,n.holes.push(i))}return n}},228:t=>{"use strict";var e=Object.prototype.hasOwnProperty,n="~";function i(){}function s(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function r(t,e,i,r,a){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new s(i,r||t,a),l=n?n+e:e;return t._events[l]?t._events[l].fn?t._events[l]=[t._events[l],o]:t._events[l].push(o):(t._events[l]=o,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new i:delete t._events[e]}function o(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(n=!1)),o.prototype.eventNames=function(){var t,i,s=[];if(0===this._eventsCount)return s;for(i in t=this._events)e.call(t,i)&&s.push(n?i.slice(1):i);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(t)):s},o.prototype.listeners=function(t){var e=n?n+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var s=0,r=i.length,a=new Array(r);s{"use strict";var e,n="object"==typeof Reflect?Reflect:null,i=n&&"function"==typeof n.apply?n.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)};e=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var s=Number.isNaN||function(t){return t!=t};function r(){r.init.call(this)}t.exports=r,t.exports.once=function(t,e){return new Promise((function(n,i){function s(n){t.removeListener(e,r),i(n)}function r(){"function"==typeof t.removeListener&&t.removeListener("error",s),n([].slice.call(arguments))}m(t,e,r,{once:!0}),"error"!==e&&function(t,e,n){"function"==typeof t.on&&m(t,"error",e,n)}(t,s,{once:!0})}))},r.EventEmitter=r,r.prototype._events=void 0,r.prototype._eventsCount=0,r.prototype._maxListeners=void 0;var a=10;function o(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function l(t){return void 0===t._maxListeners?r.defaultMaxListeners:t._maxListeners}function u(t,e,n,i){var s,r,a,u;if(o(n),void 0===(r=t._events)?(r=t._events=Object.create(null),t._eventsCount=0):(void 0!==r.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),r=t._events),a=r[e]),void 0===a)a=r[e]=n,++t._eventsCount;else if("function"==typeof a?a=r[e]=i?[n,a]:[a,n]:i?a.unshift(n):a.push(n),(s=l(t))>0&&a.length>s&&!a.warned){a.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=t,h.type=e,h.count=a.length,u=h,console&&console.warn&&console.warn(u)}return t}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(t,e,n){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},s=h.bind(i);return s.listener=n,i.wrapFn=s,s}function c(t,e,n){var i=t._events;if(void 0===i)return[];var s=i[e];return void 0===s?[]:"function"==typeof s?n?[s.listener||s]:[s]:n?function(t){for(var e=new Array(t.length),n=0;n0&&(a=e[0]),a instanceof Error)throw a;var o=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw o.context=a,o}var l=r[t];if(void 0===l)return!1;if("function"==typeof l)i(l,this,e);else{var u=l.length,h=f(l,u);for(n=0;n=0;r--)if(n[r]===e||n[r].listener===e){a=n[r].listener,s=r;break}if(s<0)return this;0===s?n.shift():function(t,e){for(;e+1=0;i--)this.removeListener(t,e[i]);return this},r.prototype.listeners=function(t){return c(this,t,!0)},r.prototype.rawListeners=function(t){return c(this,t,!1)},r.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):d.call(t,e)},r.prototype.listenerCount=d,r.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},251:(t,e)=>{ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ e.read=function(t,e,n,i,s){var r,a,o=8*s-i-1,l=(1<>1,h=-7,p=n?s-1:0,c=n?-1:1,d=t[e+p];for(p+=c,r=d&(1<<-h)-1,d>>=-h,h+=o;h>0;r=256*r+t[e+p],p+=c,h-=8);for(a=r&(1<<-h)-1,r>>=-h,h+=i;h>0;a=256*a+t[e+p],p+=c,h-=8);if(0===r)r=1-u;else{if(r===l)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,i),r-=u}return(d?-1:1)*a*Math.pow(2,r-i)},e.write=function(t,e,n,i,s,r){var a,o,l,u=8*r-s-1,h=(1<>1,c=23===s?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:r-1,f=i?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=h):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),(e+=a+p>=1?c/l:c*Math.pow(2,1-p))*l>=2&&(a++,l/=2),a+p>=h?(o=0,a=h):a+p>=1?(o=(e*l-1)*Math.pow(2,s),a+=p):(o=e*Math.pow(2,p-1)*Math.pow(2,s),a=0));s>=8;t[n+d]=255&o,d+=f,o/=256,s-=8);for(a=a<0;t[n+d]=255&a,d+=f,a/=256,u-=8);t[n+d-f]|=128*m}},8570:t=>{t.exports=n;var e=null;try{e=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(t){}function n(t,e,n){this.low=0|t,this.high=0|e,this.unsigned=!!n}function i(t){return!0===(t&&t.__isLong__)}n.prototype.__isLong__,Object.defineProperty(n.prototype,"__isLong__",{value:!0}),n.isLong=i;var s={},r={};function a(t,e){var n,i,a;return e?(a=0<=(t>>>=0)&&t<256)&&(i=r[t])?i:(n=l(t,(0|t)<0?-1:0,!0),a&&(r[t]=n),n):(a=-128<=(t|=0)&&t<128)&&(i=s[t])?i:(n=l(t,t<0?-1:0,!1),a&&(s[t]=n),n)}function o(t,e){if(isNaN(t))return e?_:g;if(e){if(t<0)return _;if(t>=d)return b}else{if(t<=-f)return v;if(t+1>=f)return E}return t<0?o(-t,e).neg():l(t%c|0,t/c|0,e)}function l(t,e,i){return new n(t,e,i)}n.fromInt=a,n.fromNumber=o,n.fromBits=l;var u=Math.pow;function h(t,e,n){if(0===t.length)throw Error("empty string");if("NaN"===t||"Infinity"===t||"+Infinity"===t||"-Infinity"===t)return g;if("number"==typeof e?(n=e,e=!1):e=!!e,(n=n||10)<2||360)throw Error("interior hyphen");if(0===i)return h(t.substring(1),e,n).neg();for(var s=o(u(n,8)),r=g,a=0;a>>0:this.low},w.toNumber=function(){return this.unsigned?(this.high>>>0)*c+(this.low>>>0):this.high*c+(this.low>>>0)},w.toString=function(t){if((t=t||10)<2||36>>0).toString(t);if((r=l).isZero())return h+a;for(;h.length<6;)h="0"+h;a=""+h+a}},w.getHighBits=function(){return this.high},w.getHighBitsUnsigned=function(){return this.high>>>0},w.getLowBits=function(){return this.low},w.getLowBitsUnsigned=function(){return this.low>>>0},w.getNumBitsAbs=function(){if(this.isNegative())return this.eq(v)?64:this.neg().getNumBitsAbs();for(var t=0!=this.high?this.high:this.low,e=31;e>0&&!(t&1<=0},w.isOdd=function(){return!(1&~this.low)},w.isEven=function(){return!(1&this.low)},w.equals=function(t){return i(t)||(t=p(t)),(this.unsigned===t.unsigned||this.high>>>31!=1||t.high>>>31!=1)&&(this.high===t.high&&this.low===t.low)},w.eq=w.equals,w.notEquals=function(t){return!this.eq(t)},w.neq=w.notEquals,w.ne=w.notEquals,w.lessThan=function(t){return this.comp(t)<0},w.lt=w.lessThan,w.lessThanOrEqual=function(t){return this.comp(t)<=0},w.lte=w.lessThanOrEqual,w.le=w.lessThanOrEqual,w.greaterThan=function(t){return this.comp(t)>0},w.gt=w.greaterThan,w.greaterThanOrEqual=function(t){return this.comp(t)>=0},w.gte=w.greaterThanOrEqual,w.ge=w.greaterThanOrEqual,w.compare=function(t){if(i(t)||(t=p(t)),this.eq(t))return 0;var e=this.isNegative(),n=t.isNegative();return e&&!n?-1:!e&&n?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1},w.comp=w.compare,w.negate=function(){return!this.unsigned&&this.eq(v)?v:this.not().add(T)},w.neg=w.negate,w.add=function(t){i(t)||(t=p(t));var e=this.high>>>16,n=65535&this.high,s=this.low>>>16,r=65535&this.low,a=t.high>>>16,o=65535&t.high,u=t.low>>>16,h=0,c=0,d=0,f=0;return d+=(f+=r+(65535&t.low))>>>16,c+=(d+=s+u)>>>16,h+=(c+=n+o)>>>16,h+=e+a,l((d&=65535)<<16|(f&=65535),(h&=65535)<<16|(c&=65535),this.unsigned)},w.subtract=function(t){return i(t)||(t=p(t)),this.add(t.neg())},w.sub=w.subtract,w.multiply=function(t){if(this.isZero())return g;if(i(t)||(t=p(t)),e)return l(e.mul(this.low,this.high,t.low,t.high),e.get_high(),this.unsigned);if(t.isZero())return g;if(this.eq(v))return t.isOdd()?v:g;if(t.eq(v))return this.isOdd()?v:g;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(m)&&t.lt(m))return o(this.toNumber()*t.toNumber(),this.unsigned);var n=this.high>>>16,s=65535&this.high,r=this.low>>>16,a=65535&this.low,u=t.high>>>16,h=65535&t.high,c=t.low>>>16,d=65535&t.low,f=0,_=0,T=0,y=0;return T+=(y+=a*d)>>>16,_+=(T+=r*d)>>>16,T&=65535,_+=(T+=a*c)>>>16,f+=(_+=s*d)>>>16,_&=65535,f+=(_+=r*c)>>>16,_&=65535,f+=(_+=a*h)>>>16,f+=n*d+s*c+r*h+a*u,l((T&=65535)<<16|(y&=65535),(f&=65535)<<16|(_&=65535),this.unsigned)},w.mul=w.multiply,w.divide=function(t){if(i(t)||(t=p(t)),t.isZero())throw Error("division by zero");var n,s,r;if(e)return this.unsigned||-2147483648!==this.high||-1!==t.low||-1!==t.high?l((this.unsigned?e.div_u:e.div_s)(this.low,this.high,t.low,t.high),e.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?_:g;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return _;if(t.gt(this.shru(1)))return y;r=_}else{if(this.eq(v))return t.eq(T)||t.eq(I)?v:t.eq(v)?T:(n=this.shr(1).div(t).shl(1)).eq(g)?t.isNegative()?T:I:(s=this.sub(t.mul(n)),r=n.add(s.div(t)));if(t.eq(v))return this.unsigned?_:g;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();r=g}for(s=this;s.gte(t);){n=Math.max(1,Math.floor(s.toNumber()/t.toNumber()));for(var a=Math.ceil(Math.log(n)/Math.LN2),h=a<=48?1:u(2,a-48),c=o(n),d=c.mul(t);d.isNegative()||d.gt(s);)d=(c=o(n-=h,this.unsigned)).mul(t);c.isZero()&&(c=T),r=r.add(c),s=s.sub(d)}return r},w.div=w.divide,w.modulo=function(t){return i(t)||(t=p(t)),e?l((this.unsigned?e.rem_u:e.rem_s)(this.low,this.high,t.low,t.high),e.get_high(),this.unsigned):this.sub(this.div(t).mul(t))},w.mod=w.modulo,w.rem=w.modulo,w.not=function(){return l(~this.low,~this.high,this.unsigned)},w.and=function(t){return i(t)||(t=p(t)),l(this.low&t.low,this.high&t.high,this.unsigned)},w.or=function(t){return i(t)||(t=p(t)),l(this.low|t.low,this.high|t.high,this.unsigned)},w.xor=function(t){return i(t)||(t=p(t)),l(this.low^t.low,this.high^t.high,this.unsigned)},w.shiftLeft=function(t){return i(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?l(this.low<>>32-t,this.unsigned):l(0,this.low<>>t|this.high<<32-t,this.high>>t,this.unsigned):l(this.high>>t-32,this.high>=0?0:-1,this.unsigned)},w.shr=w.shiftRight,w.shiftRightUnsigned=function(t){if(i(t)&&(t=t.toInt()),0===(t&=63))return this;var e=this.high;return t<32?l(this.low>>>t|e<<32-t,e>>>t,this.unsigned):l(32===t?e:e>>>t-32,0,this.unsigned)},w.shru=w.shiftRightUnsigned,w.shr_u=w.shiftRightUnsigned,w.toSigned=function(){return this.unsigned?l(this.low,this.high,!1):this},w.toUnsigned=function(){return this.unsigned?this:l(this.low,this.high,!0)},w.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()},w.toBytesLE=function(){var t=this.high,e=this.low;return[255&e,e>>>8&255,e>>>16&255,e>>>24,255&t,t>>>8&255,t>>>16&255,t>>>24]},w.toBytesBE=function(){var t=this.high,e=this.low;return[t>>>24,t>>>16&255,t>>>8&255,255&t,e>>>24,e>>>16&255,e>>>8&255,255&e]},n.fromBytes=function(t,e,i){return i?n.fromBytesLE(t,e):n.fromBytesBE(t,e)},n.fromBytesLE=function(t,e){return new n(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,e)},n.fromBytesBE=function(t,e){return new n(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],e)}},5228:t=>{"use strict"; /* object-assign (c) Sindre Sorhus @license MIT */var e=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;t.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},n=0;n<10;n++)e["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(e).map((function(t){return e[t]})).join(""))return!1;var i={};return"abcdefghijklmnopqrst".split("").forEach((function(t){i[t]=t})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},i)).join("")}catch(t){return!1}}()?Object.assign:function(t,s){for(var r,a,o=function(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}(t),l=1;l{"use strict";t.exports=(t,e={})=>{if(!t)return;const n={key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:/?#]+):)?(?:\/\/([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/,loose:/^(?:(?![^:@]+:[^:@/]*@)([^:/?#.]+):)?(?:\/\/)?([^/?#]*)([^?#]*)(?:\?([^#]*))?(?:#(.*))?/}},i=(e.strictMode?n.parser.strict:n.parser.loose).exec(t);if(!i)return;const s={};if(s[n.key[0]]=t,s[n.key[1]]=i[1]||"",s[n.key[2]]=i[2]||"",s[n.key[8]]=i[3]||"",s[n.key[12]]=i[4]||"",s[n.key[13]]=i[5]||"",s[n.key[2]]){const t=/^(?:(([^:@]*)(?::([^:@]*))?)?@)?([^:/?#]*)(?::(\d*))?/.exec(s[n.key[2]]);t&&(s[n.key[3]]=t[1]||"",s[n.key[4]]=t[2]||"",s[n.key[5]]=t[3]||"",s[n.key[6]]=t[4]||"",s[n.key[7]]=t[5]||"")}return s[n.q.name]={},s[n.key[12]].replace(n.q.parser,(function(t,e,i){e&&(s[n.q.name][e]=i)})),s}},5585:t=>{"use strict";var e=Object.prototype.hasOwnProperty,n="function"!=typeof Object.create&&"~";function i(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function s(){}s.prototype._events=void 0,s.prototype.eventNames=function(){var t,i=this._events,s=[];if(!i)return s;for(t in i)e.call(i,t)&&s.push(n?t.slice(1):t);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(i)):s},s.prototype.listeners=function(t,e){var i=n?n+t:t,s=this._events&&this._events[i];if(e)return!!s;if(!s)return[];if(s.fn)return[s.fn];for(var r=0,a=s.length,o=new Array(a);r{var i={VERSION:n(1045).rE,PI_2:2*Math.PI,RAD_TO_DEG:180/Math.PI,DEG_TO_RAD:Math.PI/180,TARGET_FPMS:.06,RENDERER_TYPE:{UNKNOWN:0,WEBGL:1,CANVAS:2},BLEND_MODES:{NORMAL:0,ADD:1,MULTIPLY:2,SCREEN:3,OVERLAY:4,DARKEN:5,LIGHTEN:6,COLOR_DODGE:7,COLOR_BURN:8,HARD_LIGHT:9,SOFT_LIGHT:10,DIFFERENCE:11,EXCLUSION:12,HUE:13,SATURATION:14,COLOR:15,LUMINOSITY:16},DRAW_MODES:{POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},SCALE_MODES:{DEFAULT:0,LINEAR:0,NEAREST:1},RETINA_PREFIX:/@(.+)x/,RESOLUTION:1,FILTER_RESOLUTION:1,DEFAULT_RENDER_OPTIONS:{view:null,resolution:1,antialias:!1,forceFXAA:!1,autoResize:!1,transparent:!1,backgroundColor:0,clearBeforeRender:!0,preserveDrawingBuffer:!1,roundPixels:!1},SHAPES:{POLY:0,RECT:1,CIRC:2,ELIP:3,RREC:4},SPRITE_BATCH_SIZE:2e3};t.exports=i},7673:(t,e,n)=>{var i=n(4650),s=n(2295),r=n(7443),a=new i.Matrix;function o(){s.call(this),this.children=[]}o.prototype=Object.create(s.prototype),o.prototype.constructor=o,t.exports=o,Object.defineProperties(o.prototype,{width:{get:function(){return this.scale.x*this.getLocalBounds().width},set:function(t){var e=this.getLocalBounds().width;this.scale.x=0!==e?t/e:1,this._width=t}},height:{get:function(){return this.scale.y*this.getLocalBounds().height},set:function(t){var e=this.getLocalBounds().height;this.scale.y=0!==e?t/e:1,this._height=t}}}),o.prototype.onChildrenChange=function(){},o.prototype.addChild=function(t){return this.addChildAt(t,this.children.length)},o.prototype.addChildAt=function(t,e){if(t===this)return t;if(e>=0&&e<=this.children.length)return t.parent&&t.parent.removeChild(t),t.parent=this,this.children.splice(e,0,t),this.onChildrenChange(e),t.emit("added",this),t;throw new Error(t+"addChildAt: The index "+e+" supplied is out of bounds "+this.children.length)},o.prototype.swapChildren=function(t,e){if(t!==e){var n=this.getChildIndex(t),i=this.getChildIndex(e);if(n<0||i<0)throw new Error("swapChildren: Both the supplied DisplayObjects must be children of the caller.");this.children[n]=e,this.children[i]=t,this.onChildrenChange(n=this.children.length)throw new Error("The supplied index is out of bounds");var n=this.getChildIndex(t);this.children.splice(n,1),this.children.splice(e,0,t),this.onChildrenChange(e)},o.prototype.getChildAt=function(t){if(t<0||t>=this.children.length)throw new Error("getChildAt: Supplied index "+t+" does not exist in the child list, or the supplied DisplayObject is not a child of the caller");return this.children[t]},o.prototype.removeChild=function(t){var e=this.children.indexOf(t);if(-1!==e)return this.removeChildAt(e)},o.prototype.removeChildAt=function(t){var e=this.getChildAt(t);return e.parent=null,this.children.splice(t,1),this.onChildrenChange(t),e.emit("removed",this),e},o.prototype.removeChildren=function(t,e){var n,i,s=t||0,r="number"==typeof e?e:this.children.length,a=r-s;if(a>0&&a<=r){for(n=this.children.splice(s,a),i=0;i(e=t.width+t.x)?a:e,o=o>(n=t.height+t.y)?o:n)}if(!l)return i.Rectangle.EMPTY;var p=this._bounds;p.x=s,p.y=r,p.width=a-s,p.height=o-r,this._currentBounds=p}return this._currentBounds},o.prototype.containerGetBounds=o.prototype.getBounds,o.prototype.getLocalBounds=function(){var t=this.worldTransform;this.worldTransform=i.Matrix.IDENTITY;for(var e=0,n=this.children.length;e{var i=n(4650),s=n(7443),r=n(5585),a=n(6192),o=new i.Matrix,l={worldTransform:new i.Matrix,worldAlpha:1,children:[]};function u(){r.call(this),this.position=new i.Point,this.scale=new i.Point(1,1),this.pivot=new i.Point(0,0),this.rotation=0,this.alpha=1,this.visible=!0,this.renderable=!0,this.parent=null,this.worldAlpha=1,this.worldTransform=new i.Matrix,this.filterArea=null,this._sr=0,this._cr=1,this._bounds=new i.Rectangle(0,0,1,1),this._currentBounds=null,this._mask=null}u.prototype=Object.create(r.prototype),u.prototype.constructor=u,t.exports=u,Object.defineProperties(u.prototype,{x:{get:function(){return this.position.x},set:function(t){this.position.x=t}},y:{get:function(){return this.position.y},set:function(t){this.position.y=t}},worldVisible:{get:function(){var t=this;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}},mask:{get:function(){return this._mask},set:function(t){this._mask&&(this._mask.renderable=!0),this._mask=t,this._mask&&(this._mask.renderable=!1)}},filters:{get:function(){return this._filters&&this._filters.slice()},set:function(t){this._filters=t&&t.slice()}}}),u.prototype.updateTransform=function(){var t,e,n,i,s,r,o=this.parent.worldTransform,l=this.worldTransform;this.rotation%a.PI_2?(this.rotation!==this.rotationCache&&(this.rotationCache=this.rotation,this._sr=Math.sin(this.rotation),this._cr=Math.cos(this.rotation)),t=this._cr*this.scale.x,e=this._sr*this.scale.x,n=-this._sr*this.scale.y,i=this._cr*this.scale.y,s=this.position.x,r=this.position.y,(this.pivot.x||this.pivot.y)&&(s-=this.pivot.x*t+this.pivot.y*n,r-=this.pivot.x*e+this.pivot.y*i),l.a=t*o.a+e*o.c,l.b=t*o.b+e*o.d,l.c=n*o.a+i*o.c,l.d=n*o.b+i*o.d,l.tx=s*o.a+r*o.c+o.tx,l.ty=s*o.b+r*o.d+o.ty):(t=this.scale.x,i=this.scale.y,s=this.position.x-this.pivot.x*t,r=this.position.y-this.pivot.y*i,l.a=t*o.a,l.b=t*o.b,l.c=i*o.c,l.d=i*o.d,l.tx=s*o.a+r*o.c+o.tx,l.ty=s*o.b+r*o.d+o.ty),this.worldAlpha=this.alpha*this.parent.worldAlpha,this._currentBounds=null},u.prototype.displayObjectUpdateTransform=u.prototype.updateTransform,u.prototype.getBounds=function(t){return i.Rectangle.EMPTY},u.prototype.getLocalBounds=function(){return this.getBounds(i.Matrix.IDENTITY)},u.prototype.toGlobal=function(t){return this.parent?this.displayObjectUpdateTransform():(this.parent=l,this.displayObjectUpdateTransform(),this.parent=null),this.worldTransform.apply(t)},u.prototype.toLocal=function(t,e){return e&&(t=e.toGlobal(t)),this.parent?this.displayObjectUpdateTransform():(this.parent=l,this.displayObjectUpdateTransform(),this.parent=null),this.worldTransform.applyInverse(t)},u.prototype.renderWebGL=function(t){},u.prototype.renderCanvas=function(t){},u.prototype.generateTexture=function(t,e,n){var i=this.getLocalBounds(),r=new s(t,0|i.width,0|i.height,e,n);return o.tx=-i.x,o.ty=-i.y,r.render(this,o),r},u.prototype.setParent=function(t){if(!t||!t.addChild)throw new Error("setParent: Argument must be a Container");return t.addChild(this),t},u.prototype.destroy=function(){this.position=null,this.scale=null,this.pivot=null,this.parent=null,this._bounds=null,this._currentBounds=null,this._mask=null,this.worldTransform=null,this.filterArea=null}},6720:(t,e,n)=>{var i=n(7673),s=n(2699),r=n(1549),a=n(4694),o=n(7240),l=n(4650),u=n(6192),h=new l.Point;function p(){i.call(this),this.fillAlpha=1,this.lineWidth=0,this.lineColor=0,this.graphicsData=[],this.tint=16777215,this._prevTint=16777215,this.blendMode=u.BLEND_MODES.NORMAL,this.currentPath=null,this._webGL={},this.isMask=!1,this.boundsPadding=0,this._localBounds=new l.Rectangle(0,0,1,1),this.dirty=!0,this.glDirty=!1,this.boundsDirty=!0,this.cachedSpriteDirty=!1}p.prototype=Object.create(i.prototype),p.prototype.constructor=p,t.exports=p,p.prototype.clone=function(){var t=new p;t.renderable=this.renderable,t.fillAlpha=this.fillAlpha,t.lineWidth=this.lineWidth,t.lineColor=this.lineColor,t.tint=this.tint,t.blendMode=this.blendMode,t.isMask=this.isMask,t.boundsPadding=this.boundsPadding,t.dirty=!0,t.glDirty=!0,t.cachedSpriteDirty=this.cachedSpriteDirty;for(var e=0;eh*o)}return this.dirty=this.boundsDirty=!0,this},p.prototype.arc=function(t,e,n,i,s,r){if(i===s)return this;!(r=r||!1)&&s<=i?s+=2*Math.PI:r&&i<=s&&(i+=2*Math.PI);var a=r?-1*(i-s):s-i,o=40*Math.ceil(Math.abs(a)/(2*Math.PI));if(0===a)return this;var l=t+Math.cos(i)*n,u=e+Math.sin(i)*n;this.currentPath?this.currentPath.shape.points.push(l,u):this.moveTo(l,u);for(var h=this.currentPath.shape.points,p=a/(2*o),c=2*p,d=Math.cos(p),f=Math.sin(p),m=o-1,g=m%1/m,_=0;_<=m;_++){var T=p+i+c*(_+g*_),y=Math.cos(T),I=-Math.sin(T);h.push((d*y+f*I)*n+t,(d*-I+f*y)*n+e)}return this.dirty=this.boundsDirty=!0,this},p.prototype.beginFill=function(t,e){return this.filling=!0,this.fillColor=t||0,this.fillAlpha=void 0===e?1:e,this.currentPath&&this.currentPath.shape.points.length<=2&&(this.currentPath.fill=this.filling,this.currentPath.fillColor=this.fillColor,this.currentPath.fillAlpha=this.fillAlpha),this},p.prototype.endFill=function(){return this.filling=!1,this.fillColor=null,this.fillAlpha=1,this},p.prototype.drawRect=function(t,e,n,i){return this.drawShape(new l.Rectangle(t,e,n,i)),this},p.prototype.drawRoundedRect=function(t,e,n,i,s){return this.drawShape(new l.RoundedRectangle(t,e,n,i,s)),this},p.prototype.drawCircle=function(t,e,n){return this.drawShape(new l.Circle(t,e,n)),this},p.prototype.drawEllipse=function(t,e,n,i){return this.drawShape(new l.Ellipse(t,e,n,i)),this},p.prototype.drawPolygon=function(t){var e=t,n=!0;if(e instanceof l.Polygon&&(n=e.closed,e=e.points),!Array.isArray(e)){e=new Array(arguments.length);for(var i=0;i(b=T>(b=g>b?g:b)?T:b)?I:b,v=E>(v=y>(v=_>v?_:v)?y:v)?E:v,this._bounds.x=w,this._bounds.width=b-w,this._bounds.y=S,this._bounds.height=v-S,this._currentBounds=this._bounds}return this._currentBounds},p.prototype.containsPoint=function(t){this.worldTransform.applyInverse(t,h);for(var e=this.graphicsData,n=0;ne?a+l:e,n=oi?o+h:i;else if(d===u.SHAPES.CIRC)a=s.x,o=s.y,t=a-(l=s.radius+f/2)e?a+l:e,n=o-(h=s.radius+f/2)i?o+h:i;else if(d===u.SHAPES.ELIP)a=s.x,o=s.y,t=a-(l=s.width+f/2)e?a+l:e,n=o-(h=s.height+f/2)i?o+h:i;else{r=s.points;for(var m=0;me?a+f:e,n=(o=r[m+1])-fi?o+f:i}}else t=0,e=0,n=0,i=0;var g=this.boundsPadding;this._localBounds.x=t-g,this._localBounds.width=e-t+2*g,this._localBounds.y=n-g,this._localBounds.height=i-n+2*g},p.prototype.drawShape=function(t){this.currentPath&&this.currentPath.shape.points.length<=2&&this.graphicsData.pop(),this.currentPath=null;var e=new o(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.filling,t);return this.graphicsData.push(e),e.type===u.SHAPES.POLY&&(e.shape.closed=e.shape.closed||this.filling,this.currentPath=e),this.dirty=this.boundsDirty=!0,e},p.prototype.destroy=function(){i.prototype.destroy.apply(this,arguments);for(var t=0;t{function e(t,e,n,i,s,r,a){this.lineWidth=t,this.lineColor=e,this.lineAlpha=n,this._lineTint=e,this.fillColor=i,this.fillAlpha=s,this._fillTint=i,this.fill=r,this.shape=a,this.type=a.type}e.prototype.constructor=e,t.exports=e,e.prototype.clone=function(){return new e(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.fill,this.shape)},e.prototype.destroy=function(){this.shape=null}},4237:(t,e,n)=>{var i=n(501),s=n(4650),r=n(6192),a=n(1830),o=n(5092),l=n(5075),u=n(6570);function h(t){a.call(this,t),this.graphicsDataPool=[],this.primitiveShader=null,this.complexPrimitiveShader=null,this.maximumSimplePolySize=200}h.prototype=Object.create(a.prototype),h.prototype.constructor=h,t.exports=h,o.registerPlugin("graphics",h),h.prototype.onContextChange=function(){},h.prototype.destroy=function(){a.prototype.destroy.call(this);for(var t=0;t=6)if(o.points.length<2*this.maximumSimplePolySize)n=this.switchMode(s,0),this.buildPoly(o,n)||(n=this.switchMode(s,1),this.buildComplexPoly(o,n));else n=this.switchMode(s,1),this.buildComplexPoly(o,n);o.lineWidth>0&&(n=this.switchMode(s,0),this.buildLine(o,n))}else n=this.switchMode(s,0),o.type===r.SHAPES.RECT?this.buildRectangle(o,n):o.type===r.SHAPES.CIRC||o.type===r.SHAPES.ELIP?this.buildCircle(o,n):o.type===r.SHAPES.RREC&&this.buildRoundedRectangle(o,n);s.lastIndex++}for(e=0;e32e4||n.mode!==e||1===e)&&((n=this.graphicsDataPool.pop()||new l(t.gl)).mode=e,t.data.push(n)):((n=this.graphicsDataPool.pop()||new l(t.gl)).mode=e,t.data.push(n)),n.dirty=!0,n},h.prototype.buildRectangle=function(t,e){var n=t.shape,s=n.x,r=n.y,a=n.width,o=n.height;if(t.fill){var l=i.hex2rgb(t.fillColor),u=t.fillAlpha,h=l[0]*u,p=l[1]*u,c=l[2]*u,d=e.points,f=e.indices,m=d.length/6;d.push(s,r),d.push(h,p,c,u),d.push(s+a,r),d.push(h,p,c,u),d.push(s,r+o),d.push(h,p,c,u),d.push(s+a,r+o),d.push(h,p,c,u),f.push(m,m,m+1,m+2,m+3,m+3)}if(t.lineWidth){var g=t.points;t.points=[s,r,s+a,r,s+a,r+o,s,r+o,s,r],this.buildLine(t,e),t.points=g}},h.prototype.buildRoundedRectangle=function(t,e){var n=t.shape,s=n.x,r=n.y,a=n.width,o=n.height,l=n.radius,h=[];if(h.push(s,r+l),this.quadraticBezierCurve(s,r+o-l,s,r+o,s+l,r+o,h),this.quadraticBezierCurve(s+a-l,r+o,s+a,r+o,s+a,r+o-l,h),this.quadraticBezierCurve(s+a,r+l,s+a,r,s+a-l,r,h),this.quadraticBezierCurve(s+l,r,s,r,s,r+l+1e-10,h),t.fill){var p=i.hex2rgb(t.fillColor),c=t.fillAlpha,d=p[0]*c,f=p[1]*c,m=p[2]*c,g=e.points,_=e.indices,T=g.length/6,y=u(h,null,2),I=0;for(I=0;I19600?(b=T-I,v=y-E,b/=C=Math.sqrt(b*b+v*v),v/=C,b*=P,v*=P,N.push(f-b,m-v),N.push(V,U,Y,B),N.push(f+b,m+v),N.push(V,U,Y,B),N.push(f-b,m-v),N.push(V,U,Y,B),L++):(N.push(h,p),N.push(V,U,Y,B),N.push(f-(h-f),m-(p-m)),N.push(V,U,Y,B));for(c=r[2*(D-2)],d=r[2*(D-2)+1],f=r[2*(D-1)],T=-(d-(m=r[2*(D-1)+1])),y=c-f,T/=C=Math.sqrt(T*T+y*y),y/=C,T*=P,y*=P,N.push(f-T,m-y),N.push(V,U,Y,B),N.push(f+T,m+y),N.push(V,U,Y,B),k.push(F),n=0;nl?r:l,u=(a=n[p+1])h?a:h;n.push(o,u,l,u,l,h,o,h);var c=n.length/2;for(p=0;p{function e(t){this.gl=t,this.color=[0,0,0],this.points=[],this.indices=[],this.buffer=t.createBuffer(),this.indexBuffer=t.createBuffer(),this.mode=1,this.alpha=1,this.dirty=!0,this.glPoints=null,this.glIndices=null}e.prototype.constructor=e,t.exports=e,e.prototype.reset=function(){this.points.length=0,this.indices.length=0},e.prototype.upload=function(){var t=this.gl;this.glPoints=new Float32Array(this.points),t.bindBuffer(t.ARRAY_BUFFER,this.buffer),t.bufferData(t.ARRAY_BUFFER,this.glPoints,t.STATIC_DRAW),this.glIndices=new Uint16Array(this.indices),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.glIndices,t.STATIC_DRAW),this.dirty=!1},e.prototype.destroy=function(){this.color=null,this.points=null,this.indices=null,this.gl.deleteBuffer(this.buffer),this.gl.deleteBuffer(this.indexBuffer),this.gl=null,this.buffer=null,this.indexBuffer=null,this.glPoints=null,this.glIndices=null}},4651:(t,e,n)=>{ /** * @file Main export of the PIXI core library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ var i=t.exports=Object.assign(n(6192),n(4650),{utils:n(501),ticker:n(2410),DisplayObject:n(2295),Container:n(7673),Sprite:n(2861),ParticleContainer:n(3326),SpriteRenderer:n(7920),ParticleRenderer:n(2952),Text:n(9252),Graphics:n(6720),GraphicsData:n(7240),GraphicsRenderer:n(4237),Texture:n(2699),BaseTexture:n(1936),RenderTexture:n(7443),VideoBaseTexture:n(3367),TextureUvs:n(1507),CanvasRenderer:n(8010),CanvasGraphics:n(4694),CanvasBuffer:n(1549),WebGLRenderer:n(5092),ShaderManager:n(3779),Shader:n(8306),ObjectRenderer:n(1830),RenderTarget:n(7955),AbstractFilter:n(580),FXAAFilter:n(1438),SpriteMaskFilter:n(5207),autoDetectRenderer:function(t,e,n,s){return t=t||800,e=e||600,!s&&i.utils.isWebGLSupported()?new i.WebGLRenderer(t,e,n):new i.CanvasRenderer(t,e,n)}})},2825:(t,e,n)=>{var i=n(8840);function s(){this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0}s.prototype.constructor=s,t.exports=s,s.prototype.fromArray=function(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]},s.prototype.toArray=function(t,e){this.array||(this.array=new Float32Array(9));var n=e||this.array;return t?(n[0]=this.a,n[1]=this.b,n[2]=0,n[3]=this.c,n[4]=this.d,n[5]=0,n[6]=this.tx,n[7]=this.ty,n[8]=1):(n[0]=this.a,n[1]=this.c,n[2]=this.tx,n[3]=this.b,n[4]=this.d,n[5]=this.ty,n[6]=0,n[7]=0,n[8]=1),n},s.prototype.apply=function(t,e){e=e||new i;var n=t.x,s=t.y;return e.x=this.a*n+this.c*s+this.tx,e.y=this.b*n+this.d*s+this.ty,e},s.prototype.applyInverse=function(t,e){e=e||new i;var n=1/(this.a*this.d+this.c*-this.b),s=t.x,r=t.y;return e.x=this.d*n*s+-this.c*n*r+(this.ty*this.c-this.tx*this.d)*n,e.y=this.a*n*r+-this.b*n*s+(-this.ty*this.a+this.tx*this.b)*n,e},s.prototype.translate=function(t,e){return this.tx+=t,this.ty+=e,this},s.prototype.scale=function(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this},s.prototype.rotate=function(t){var e=Math.cos(t),n=Math.sin(t),i=this.a,s=this.c,r=this.tx;return this.a=i*e-this.b*n,this.b=i*n+this.b*e,this.c=s*e-this.d*n,this.d=s*n+this.d*e,this.tx=r*e-this.ty*n,this.ty=r*n+this.ty*e,this},s.prototype.append=function(t){var e=this.a,n=this.b,i=this.c,s=this.d;return this.a=t.a*e+t.b*i,this.b=t.a*n+t.b*s,this.c=t.c*e+t.d*i,this.d=t.c*n+t.d*s,this.tx=t.tx*e+t.ty*i+this.tx,this.ty=t.tx*n+t.ty*s+this.ty,this},s.prototype.prepend=function(t){var e=this.tx;if(1!==t.a||0!==t.b||0!==t.c||1!==t.d){var n=this.a,i=this.c;this.a=n*t.a+this.b*t.c,this.b=n*t.b+this.b*t.d,this.c=i*t.a+this.d*t.c,this.d=i*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this},s.prototype.invert=function(){var t=this.a,e=this.b,n=this.c,i=this.d,s=this.tx,r=t*i-e*n;return this.a=i/r,this.b=-e/r,this.c=-n/r,this.d=t/r,this.tx=(n*this.ty-i*s)/r,this.ty=-(t*this.ty-e*s)/r,this},s.prototype.identity=function(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this},s.prototype.clone=function(){var t=new s;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t},s.prototype.copy=function(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t},s.IDENTITY=new s,s.TEMP_MATRIX=new s},8840:t=>{function e(t,e){this.x=t||0,this.y=e||0}e.prototype.constructor=e,t.exports=e,e.prototype.clone=function(){return new e(this.x,this.y)},e.prototype.copy=function(t){this.set(t.x,t.y)},e.prototype.equals=function(t){return t.x===this.x&&t.y===this.y},e.prototype.set=function(t,e){this.x=t||0,this.y=e||(0!==e?this.x:0)}},4650:(t,e,n)=>{t.exports={Point:n(8840),Matrix:n(2825),Circle:n(5385),Ellipse:n(8419),Polygon:n(3671),Rectangle:n(2068),RoundedRectangle:n(1347)}},5385:(t,e,n)=>{var i=n(2068),s=n(6192);function r(t,e,n){this.x=t||0,this.y=e||0,this.radius=n||0,this.type=s.SHAPES.CIRC}r.prototype.constructor=r,t.exports=r,r.prototype.clone=function(){return new r(this.x,this.y,this.radius)},r.prototype.contains=function(t,e){if(this.radius<=0)return!1;var n=this.x-t,i=this.y-e;return(n*=n)+(i*=i)<=this.radius*this.radius},r.prototype.getBounds=function(){return new i(this.x-this.radius,this.y-this.radius,2*this.radius,2*this.radius)}},8419:(t,e,n)=>{var i=n(2068),s=n(6192);function r(t,e,n,i){this.x=t||0,this.y=e||0,this.width=n||0,this.height=i||0,this.type=s.SHAPES.ELIP}r.prototype.constructor=r,t.exports=r,r.prototype.clone=function(){return new r(this.x,this.y,this.width,this.height)},r.prototype.contains=function(t,e){if(this.width<=0||this.height<=0)return!1;var n=(t-this.x)/this.width,i=(e-this.y)/this.height;return(n*=n)+(i*=i)<=1},r.prototype.getBounds=function(){return new i(this.x-this.width,this.y-this.height,this.width,this.height)}},3671:(t,e,n)=>{var i=n(8840),s=n(6192);function r(t){var e=t;if(!Array.isArray(e)){e=new Array(arguments.length);for(var n=0;ne!=u>e&&t<(l-a)*(e-o)/(u-o)+a&&(n=!n)}return n}},2068:(t,e,n)=>{var i=n(6192);function s(t,e,n,s){this.x=t||0,this.y=e||0,this.width=n||0,this.height=s||0,this.type=i.SHAPES.RECT}s.prototype.constructor=s,t.exports=s,s.EMPTY=new s(0,0,0,0),s.prototype.clone=function(){return new s(this.x,this.y,this.width,this.height)},s.prototype.contains=function(t,e){return!(this.width<=0||this.height<=0)&&(t>=this.x&&t=this.y&&e{var i=n(6192);function s(t,e,n,s,r){this.x=t||0,this.y=e||0,this.width=n||0,this.height=s||0,this.radius=r||20,this.type=i.SHAPES.RREC}s.prototype.constructor=s,t.exports=s,s.prototype.clone=function(){return new s(this.x,this.y,this.width,this.height,this.radius)},s.prototype.contains=function(t,e){return!(this.width<=0||this.height<=0)&&(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height)}},3326:(t,e,n)=>{var i=n(7673),s=n(6192);function r(t,e,n){i.call(this);(n=n||15e3)>16384&&(n=16384),n>(t=t||15e3)&&(n=t),this._properties=[!1,!0,!1,!1,!1],this._maxSize=t,this._batchSize=n,this._buffers=null,this._bufferToUpdate=0,this.interactiveChildren=!1,this.blendMode=s.BLEND_MODES.NORMAL,this.roundPixels=!0,this.setProperties(e)}r.prototype=Object.create(i.prototype),r.prototype.constructor=r,t.exports=r,r.prototype.setProperties=function(t){t&&(this._properties[0]="scale"in t?!!t.scale:this._properties[0],this._properties[1]="position"in t?!!t.position:this._properties[1],this._properties[2]="rotation"in t?!!t.rotation:this._properties[2],this._properties[3]="uvs"in t?!!t.uvs:this._properties[3],this._properties[4]="alpha"in t?!!t.alpha:this._properties[4])},r.prototype.updateTransform=function(){this.displayObjectUpdateTransform()},r.prototype.renderWebGL=function(t){this.visible&&!(this.worldAlpha<=0)&&this.children.length&&this.renderable&&(t.setObjectRenderer(t.plugins.particle),t.plugins.particle.render(this))},r.prototype.onChildrenChange=function(t){var e=Math.floor(t/this._batchSize);e{function e(t,e,n,i){this.gl=t,this.vertSize=2,this.vertByteSize=4*this.vertSize,this.size=i,this.dynamicProperties=[],this.staticProperties=[];for(var s=0;s{var i=n(1830),s=n(5092),r=n(3646),a=n(3361),o=n(4650);function l(t){i.call(this,t);this.indices=new Uint16Array(98304);for(var e=0,n=0;e<98304;e+=6,n+=4)this.indices[e+0]=n+0,this.indices[e+1]=n+1,this.indices[e+2]=n+2,this.indices[e+3]=n+0,this.indices[e+4]=n+2,this.indices[e+5]=n+3;this.shader=null,this.indexBuffer=null,this.properties=null,this.tempMatrix=new o.Matrix}l.prototype=Object.create(i.prototype),l.prototype.constructor=l,t.exports=l,s.registerPlugin("particle",l),l.prototype.onContextChange=function(){var t=this.renderer.gl;this.shader=new r(this.renderer.shaderManager),this.indexBuffer=t.createBuffer(),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.indices,t.STATIC_DRAW),this.properties=[{attribute:this.shader.attributes.aVertexPosition,size:2,uploadFunction:this.uploadVertices,offset:0},{attribute:this.shader.attributes.aPositionCoord,size:2,uploadFunction:this.uploadPosition,offset:0},{attribute:this.shader.attributes.aRotation,size:1,uploadFunction:this.uploadRotation,offset:0},{attribute:this.shader.attributes.aTextureCoord,size:2,uploadFunction:this.uploadUvs,offset:0},{attribute:this.shader.attributes.aColor,size:1,uploadFunction:this.uploadAlpha,offset:0}]},l.prototype.start=function(){var t=this.renderer.gl;t.activeTexture(t.TEXTURE0),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var e=this.shader;this.renderer.shaderManager.setShader(e)},l.prototype.render=function(t){var e=t.children,n=e.length,i=t._maxSize,s=t._batchSize;if(0!==n){n>i&&(n=i),t._buffers||(t._buffers=this.generateBuffers(t)),this.renderer.blendModeManager.setBlendMode(t.blendMode);var r=this.renderer.gl,a=t.worldTransform.copy(this.tempMatrix);a.prepend(this.renderer.currentRenderTarget.projectionMatrix),r.uniformMatrix3fv(this.shader.uniforms.projectionMatrix._location,!1,a.toArray(!0)),r.uniform1f(this.shader.uniforms.uAlpha._location,t.worldAlpha);var o=e[0]._texture.baseTexture;if(o._glTextures[r.id])r.bindTexture(r.TEXTURE_2D,o._glTextures[r.id]);else{if(!this.renderer.updateTexture(o))return;t._properties[0]&&t._properties[3]||(t._bufferToUpdate=0)}for(var l=0,u=0;ls&&(h=s);var p=t._buffers[u];p.uploadDynamic(e,l,h),t._bufferToUpdate===u&&(p.uploadStatic(e,l,h),t._bufferToUpdate=u+1),p.bind(this.shader),r.drawElements(r.TRIANGLES,6*h,r.UNSIGNED_SHORT,0),this.renderer.drawCount++}}},l.prototype.generateBuffers=function(t){var e,n=this.renderer.gl,i=[],s=t._maxSize,r=t._batchSize,o=t._properties;for(e=0;e{var i=n(8297);function s(t){i.call(this,t,["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute float aColor;","attribute vec2 aPositionCoord;","attribute vec2 aScale;","attribute float aRotation;","uniform mat3 projectionMatrix;","varying vec2 vTextureCoord;","varying float vColor;","void main(void){"," vec2 v = aVertexPosition;"," v.x = (aVertexPosition.x) * cos(aRotation) - (aVertexPosition.y) * sin(aRotation);"," v.y = (aVertexPosition.x) * sin(aRotation) + (aVertexPosition.y) * cos(aRotation);"," v = v + aPositionCoord;"," gl_Position = vec4((projectionMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vColor = aColor;","}"].join("\n"),["precision lowp float;","varying vec2 vTextureCoord;","varying float vColor;","uniform sampler2D uSampler;","uniform float uAlpha;","void main(void){"," vec4 color = texture2D(uSampler, vTextureCoord) * vColor * uAlpha;"," if (color.a == 0.0) discard;"," gl_FragColor = color;","}"].join("\n"),{uAlpha:{type:"1f",value:1}},{aPositionCoord:0,aRotation:0})}s.prototype=Object.create(i.prototype),s.prototype.constructor=s,t.exports=s},6820:(t,e,n)=>{var i=n(501),s=n(4650),r=n(6192),a=n(5585);function o(t,e,n,o){if(a.call(this),i.sayHello(t),o)for(var l in r.DEFAULT_RENDER_OPTIONS)void 0===o[l]&&(o[l]=r.DEFAULT_RENDER_OPTIONS[l]);else o=r.DEFAULT_RENDER_OPTIONS;this.type=r.RENDERER_TYPE.UNKNOWN,this.width=e||800,this.height=n||600,this.view=o.view||document.createElement("canvas"),this.resolution=o.resolution,this.transparent=o.transparent,this.autoResize=o.autoResize||!1,this.blendModes=null,this.preserveDrawingBuffer=o.preserveDrawingBuffer,this.clearBeforeRender=o.clearBeforeRender,this.roundPixels=o.roundPixels,this._backgroundColor=0,this._backgroundColorRgb=[0,0,0],this._backgroundColorString="#000000",this.backgroundColor=o.backgroundColor||this._backgroundColor,this._tempDisplayObjectParent={worldTransform:new s.Matrix,worldAlpha:1,children:[]},this._lastObjectRendered=this._tempDisplayObjectParent}o.prototype=Object.create(a.prototype),o.prototype.constructor=o,t.exports=o,Object.defineProperties(o.prototype,{backgroundColor:{get:function(){return this._backgroundColor},set:function(t){this._backgroundColor=t,this._backgroundColorString=i.hex2string(t),i.hex2rgb(t,this._backgroundColorRgb)}}}),o.prototype.resize=function(t,e){this.width=t*this.resolution,this.height=e*this.resolution,this.view.width=this.width,this.view.height=this.height,this.autoResize&&(this.view.style.width=this.width/this.resolution+"px",this.view.style.height=this.height/this.resolution+"px")},o.prototype.destroy=function(t){t&&this.view.parentNode&&this.view.parentNode.removeChild(this.view),this.type=r.RENDERER_TYPE.UNKNOWN,this.width=0,this.height=0,this.view=null,this.resolution=0,this.transparent=!1,this.autoResize=!1,this.blendModes=null,this.preserveDrawingBuffer=!1,this.clearBeforeRender=!1,this.roundPixels=!1,this._backgroundColor=0,this._backgroundColorRgb=null,this._backgroundColorString=null}},8010:(t,e,n)=>{var i=n(6820),s=n(6871),r=n(501),a=n(4650),o=n(6192);function l(t,e,n){n=n||{},i.call(this,"Canvas",t,e,n),this.type=o.RENDERER_TYPE.CANVAS,this.context=this.view.getContext("2d",{alpha:this.transparent}),this.refresh=!0,this.maskManager=new s,this.smoothProperty="imageSmoothingEnabled",this.context.imageSmoothingEnabled||(this.context.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":this.context.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":this.context.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":this.context.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")),this.initPlugins(),this._mapBlendModes(),this._tempDisplayObjectParent={worldTransform:new a.Matrix,worldAlpha:1},this.resize(t,e)}l.prototype=Object.create(i.prototype),l.prototype.constructor=l,t.exports=l,r.pluginTarget.mixin(l),l.prototype.render=function(t){var e=t.parent;this._lastObjectRendered=t,t.parent=this._tempDisplayObjectParent,t.updateTransform(),t.parent=e,this.context.setTransform(1,0,0,1,0,0),this.context.globalAlpha=1,this.context.globalCompositeOperation=this.blendModes[o.BLEND_MODES.NORMAL],navigator.isCocoonJS&&this.view.screencanvas&&(this.context.fillStyle="black",this.context.clear()),this.clearBeforeRender&&(this.transparent?this.context.clearRect(0,0,this.width,this.height):(this.context.fillStyle=this._backgroundColorString,this.context.fillRect(0,0,this.width,this.height))),this.renderDisplayObject(t,this.context)},l.prototype.destroy=function(t){this.destroyPlugins(),i.prototype.destroy.call(this,t),this.context=null,this.refresh=!0,this.maskManager.destroy(),this.maskManager=null,this.smoothProperty=null},l.prototype.renderDisplayObject=function(t,e){var n=this.context;this.context=e,t.renderCanvas(this),this.context=n},l.prototype.resize=function(t,e){i.prototype.resize.call(this,t,e),this.smoothProperty&&(this.context[this.smoothProperty]=o.SCALE_MODES.DEFAULT===o.SCALE_MODES.LINEAR)},l.prototype._mapBlendModes=function(){this.blendModes||(this.blendModes={},r.canUseNewCanvasBlendModes()?(this.blendModes[o.BLEND_MODES.NORMAL]="source-over",this.blendModes[o.BLEND_MODES.ADD]="lighter",this.blendModes[o.BLEND_MODES.MULTIPLY]="multiply",this.blendModes[o.BLEND_MODES.SCREEN]="screen",this.blendModes[o.BLEND_MODES.OVERLAY]="overlay",this.blendModes[o.BLEND_MODES.DARKEN]="darken",this.blendModes[o.BLEND_MODES.LIGHTEN]="lighten",this.blendModes[o.BLEND_MODES.COLOR_DODGE]="color-dodge",this.blendModes[o.BLEND_MODES.COLOR_BURN]="color-burn",this.blendModes[o.BLEND_MODES.HARD_LIGHT]="hard-light",this.blendModes[o.BLEND_MODES.SOFT_LIGHT]="soft-light",this.blendModes[o.BLEND_MODES.DIFFERENCE]="difference",this.blendModes[o.BLEND_MODES.EXCLUSION]="exclusion",this.blendModes[o.BLEND_MODES.HUE]="hue",this.blendModes[o.BLEND_MODES.SATURATION]="saturate",this.blendModes[o.BLEND_MODES.COLOR]="color",this.blendModes[o.BLEND_MODES.LUMINOSITY]="luminosity"):(this.blendModes[o.BLEND_MODES.NORMAL]="source-over",this.blendModes[o.BLEND_MODES.ADD]="lighter",this.blendModes[o.BLEND_MODES.MULTIPLY]="source-over",this.blendModes[o.BLEND_MODES.SCREEN]="source-over",this.blendModes[o.BLEND_MODES.OVERLAY]="source-over",this.blendModes[o.BLEND_MODES.DARKEN]="source-over",this.blendModes[o.BLEND_MODES.LIGHTEN]="source-over",this.blendModes[o.BLEND_MODES.COLOR_DODGE]="source-over",this.blendModes[o.BLEND_MODES.COLOR_BURN]="source-over",this.blendModes[o.BLEND_MODES.HARD_LIGHT]="source-over",this.blendModes[o.BLEND_MODES.SOFT_LIGHT]="source-over",this.blendModes[o.BLEND_MODES.DIFFERENCE]="source-over",this.blendModes[o.BLEND_MODES.EXCLUSION]="source-over",this.blendModes[o.BLEND_MODES.HUE]="source-over",this.blendModes[o.BLEND_MODES.SATURATION]="source-over",this.blendModes[o.BLEND_MODES.COLOR]="source-over",this.blendModes[o.BLEND_MODES.LUMINOSITY]="source-over"))}},1549:t=>{function e(t,e){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),this.canvas.width=t,this.canvas.height=e}e.prototype.constructor=e,t.exports=e,Object.defineProperties(e.prototype,{width:{get:function(){return this.canvas.width},set:function(t){this.canvas.width=t}},height:{get:function(){return this.canvas.height},set:function(t){this.canvas.height=t}}}),e.prototype.clear=function(){this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.canvas.width,this.canvas.height)},e.prototype.resize=function(t,e){this.canvas.width=t,this.canvas.height=e},e.prototype.destroy=function(){this.context=null,this.canvas=null}},4694:(t,e,n)=>{var i=n(6192),s={};t.exports=s,s.renderGraphics=function(t,e){var n=t.worldAlpha;t.dirty&&(this.updateGraphicsTint(t),t.dirty=!1);for(var s=0;sR?R:x,e.beginPath(),e.moveTo(b,v+x),e.lineTo(b,v+S-x),e.quadraticCurveTo(b,v+S,b+x,v+S),e.lineTo(b+w-x,v+S),e.quadraticCurveTo(b+w,v+S,b+w,v+S-x),e.lineTo(b+w,v+x),e.quadraticCurveTo(b+w,v,b+w-x,v),e.lineTo(b+x,v),e.quadraticCurveTo(b,v,b,v+x),e.closePath(),(r.fillColor||0===r.fillColor)&&(e.globalAlpha=r.fillAlpha*n,e.fillStyle="#"+("00000"+(0|o).toString(16)).substr(-6),e.fill()),r.lineWidth&&(e.globalAlpha=r.lineAlpha*n,e.strokeStyle="#"+("00000"+(0|l).toString(16)).substr(-6),e.stroke())}}},s.renderGraphicsMask=function(t,e){var n=t.graphicsData.length;if(0!==n){e.beginPath();for(var s=0;sS?S:w,e.moveTo(I,E+w),e.lineTo(I,E+v-w),e.quadraticCurveTo(I,E+v,I+w,E+v),e.lineTo(I+b-w,E+v),e.quadraticCurveTo(I+b,E+v,I+b,E+v-w),e.lineTo(I+b,E+w),e.quadraticCurveTo(I+b,E,I+b-w,E),e.lineTo(I+w,E),e.quadraticCurveTo(I,E,I,E+w),e.closePath()}}}},s.updateGraphicsTint=function(t){if(16777215!==t.tint||t._prevTint!==t.tint){t._prevTint=t.tint;for(var e=(t.tint>>16&255)/255,n=(t.tint>>8&255)/255,i=(255&t.tint)/255,s=0;s>16&255)/255*e*255<<16)+((a>>8&255)/255*n*255<<8)+(255&a)/255*i*255,r._lineTint=((o>>16&255)/255*e*255<<16)+((o>>8&255)/255*n*255<<8)+(255&o)/255*i*255}}}},6871:(t,e,n)=>{var i=n(4694);function s(){}s.prototype.constructor=s,t.exports=s,s.prototype.pushMask=function(t,e){e.context.save();var n=t.alpha,s=t.worldTransform,r=e.resolution;e.context.setTransform(s.a*r,s.b*r,s.c*r,s.d*r,s.tx*r,s.ty*r),t.texture||(i.renderGraphicsMask(t,e.context),e.context.clip()),t.worldAlpha=n},s.prototype.popMask=function(t){t.context.restore()},s.prototype.destroy=function(){}},7809:(t,e,n)=>{var i=n(501),s={};t.exports=s,s.getTintedTexture=function(t,e){var n=t.texture,i="#"+("00000"+(0|(e=s.roundColor(e))).toString(16)).substr(-6);if(n.tintCache=n.tintCache||{},n.tintCache[i])return n.tintCache[i];var r=s.canvas||document.createElement("canvas");if(s.tintMethod(n,e,r),s.convertTintToImage){var a=new Image;a.src=r.toDataURL(),n.tintCache[i]=a}else n.tintCache[i]=r,s.canvas=null;return r},s.tintWithMultiply=function(t,e,n){var i=n.getContext("2d"),s=t.baseTexture.resolution,r=t.crop.clone();r.x*=s,r.y*=s,r.width*=s,r.height*=s,n.width=r.width,n.height=r.height,i.fillStyle="#"+("00000"+(0|e).toString(16)).substr(-6),i.fillRect(0,0,r.width,r.height),i.globalCompositeOperation="multiply",i.drawImage(t.baseTexture.source,r.x,r.y,r.width,r.height,0,0,r.width,r.height),i.globalCompositeOperation="destination-atop",i.drawImage(t.baseTexture.source,r.x,r.y,r.width,r.height,0,0,r.width,r.height)},s.tintWithOverlay=function(t,e,n){var i=n.getContext("2d"),s=t.baseTexture.resolution,r=t.crop.clone();r.x*=s,r.y*=s,r.width*=s,r.height*=s,n.width=r.width,n.height=r.height,i.globalCompositeOperation="copy",i.fillStyle="#"+("00000"+(0|e).toString(16)).substr(-6),i.fillRect(0,0,r.width,r.height),i.globalCompositeOperation="destination-atop",i.drawImage(t.baseTexture.source,r.x,r.y,r.width,r.height,0,0,r.width,r.height)},s.tintWithPerPixel=function(t,e,n){var s=n.getContext("2d"),r=t.baseTexture.resolution,a=t.crop.clone();a.x*=r,a.y*=r,a.width*=r,a.height*=r,n.width=a.width,n.height=a.height,s.globalCompositeOperation="copy",s.drawImage(t.baseTexture.source,a.x,a.y,a.width,a.height,0,0,a.width,a.height);for(var o=i.hex2rgb(e),l=o[0],u=o[1],h=o[2],p=s.getImageData(0,0,a.width,a.height),c=p.data,d=0;d{var i=n(6820),s=n(3779),r=n(9240),a=n(5468),o=n(4598),l=n(5396),u=n(7955),h=n(1830),p=n(1438),c=n(501),d=n(6192);function f(t,e,n){n=n||{},i.call(this,"WebGL",t,e,n),this.type=d.RENDERER_TYPE.WEBGL,this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this),this.view.addEventListener("webglcontextlost",this.handleContextLost,!1),this.view.addEventListener("webglcontextrestored",this.handleContextRestored,!1),this._useFXAA=!!n.forceFXAA&&n.antialias,this._FXAAFilter=null,this._contextOptions={alpha:this.transparent,antialias:n.antialias,premultipliedAlpha:this.transparent&&"notMultiplied"!==this.transparent,stencil:!0,preserveDrawingBuffer:n.preserveDrawingBuffer},this.drawCount=0,this.shaderManager=new s(this),this.maskManager=new r(this),this.stencilManager=new a(this),this.filterManager=new o(this),this.blendModeManager=new l(this),this.currentRenderTarget=null,this.currentRenderer=new h(this),this.initPlugins(),this._createContext(),this._initContext(),this._mapGlModes(),this._renderTargetStack=[]}f.prototype=Object.create(i.prototype),f.prototype.constructor=f,t.exports=f,c.pluginTarget.mixin(f),f.glContextId=0,f.prototype._createContext=function(){var t=this.view.getContext("webgl",this._contextOptions)||this.view.getContext("experimental-webgl",this._contextOptions);if(this.gl=t,!t)throw new Error("This browser does not support webGL. Try using the canvas renderer");this.glContextId=f.glContextId++,t.id=this.glContextId,t.renderer=this},f.prototype._initContext=function(){var t=this.gl;t.disable(t.DEPTH_TEST),t.disable(t.CULL_FACE),t.enable(t.BLEND),this.renderTarget=new u(t,this.width,this.height,null,this.resolution,!0),this.setRenderTarget(this.renderTarget),this.emit("context",t),this.resize(this.width,this.height),this._useFXAA||(this._useFXAA=this._contextOptions.antialias&&!t.getContextAttributes().antialias),this._useFXAA&&(window.console.warn("FXAA antialiasing being used instead of native antialiasing"),this._FXAAFilter=[new p])},f.prototype.render=function(t){if(!this.gl.isContextLost()){this.drawCount=0,this._lastObjectRendered=t,this._useFXAA&&(this._FXAAFilter[0].uniforms.resolution.value.x=this.width,this._FXAAFilter[0].uniforms.resolution.value.y=this.height,t.filterArea=this.renderTarget.size,t.filters=this._FXAAFilter);var e=t.parent;t.parent=this._tempDisplayObjectParent,t.updateTransform(),t.parent=e;var n=this.gl;this.setRenderTarget(this.renderTarget),this.clearBeforeRender&&(this.transparent?n.clearColor(0,0,0,0):n.clearColor(this._backgroundColorRgb[0],this._backgroundColorRgb[1],this._backgroundColorRgb[2],1),n.clear(n.COLOR_BUFFER_BIT)),this.renderDisplayObject(t,this.renderTarget)}},f.prototype.renderDisplayObject=function(t,e,n){this.setRenderTarget(e),n&&e.clear(),this.filterManager.setFilterStack(e.filterStack),t.renderWebGL(this),this.currentRenderer.flush()},f.prototype.setObjectRenderer=function(t){this.currentRenderer!==t&&(this.currentRenderer.stop(),this.currentRenderer=t,this.currentRenderer.start())},f.prototype.setRenderTarget=function(t){this.currentRenderTarget!==t&&(this.currentRenderTarget=t,this.currentRenderTarget.activate(),this.stencilManager.setMaskStack(t.stencilMaskStack))},f.prototype.resize=function(t,e){i.prototype.resize.call(this,t,e),this.filterManager.resize(t,e),this.renderTarget.resize(t,e),this.currentRenderTarget===this.renderTarget&&(this.renderTarget.activate(),this.gl.viewport(0,0,this.width,this.height))},f.prototype.updateTexture=function(t){if((t=t.baseTexture||t).hasLoaded){var e=this.gl;return t._glTextures[e.id]||(t._glTextures[e.id]=e.createTexture(),t.on("update",this.updateTexture,this),t.on("dispose",this.destroyTexture,this)),e.bindTexture(e.TEXTURE_2D,t._glTextures[e.id]),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultipliedAlpha),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t.source),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t.scaleMode===d.SCALE_MODES.LINEAR?e.LINEAR:e.NEAREST),t.mipmap&&t.isPowerOfTwo?(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t.scaleMode===d.SCALE_MODES.LINEAR?e.LINEAR_MIPMAP_LINEAR:e.NEAREST_MIPMAP_NEAREST),e.generateMipmap(e.TEXTURE_2D)):e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t.scaleMode===d.SCALE_MODES.LINEAR?e.LINEAR:e.NEAREST),t.isPowerOfTwo?(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.REPEAT)):(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)),t._glTextures[e.id]}},f.prototype.destroyTexture=function(t){(t=t.baseTexture||t).hasLoaded&&t._glTextures[this.gl.id]&&this.gl.deleteTexture(t._glTextures[this.gl.id])},f.prototype.handleContextLost=function(t){t.preventDefault()},f.prototype.handleContextRestored=function(){for(var t in this._initContext(),c.BaseTextureCache)c.BaseTextureCache[t]._glTextures.length=0},f.prototype.destroy=function(t){for(var e in this.destroyPlugins(),this.view.removeEventListener("webglcontextlost",this.handleContextLost),this.view.removeEventListener("webglcontextrestored",this.handleContextRestored),c.BaseTextureCache){var n=c.BaseTextureCache[e];n.off("update",this.updateTexture,this),n.off("dispose",this.destroyTexture,this)}i.prototype.destroy.call(this,t),this.uid=0,this.shaderManager.destroy(),this.maskManager.destroy(),this.stencilManager.destroy(),this.filterManager.destroy(),this.blendModeManager.destroy(),this.shaderManager=null,this.maskManager=null,this.filterManager=null,this.blendModeManager=null,this.currentRenderer=null,this.handleContextLost=null,this.handleContextRestored=null,this._contextOptions=null,this.drawCount=0,this.gl.useProgram(null),this.gl=null},f.prototype._mapGlModes=function(){var t=this.gl;this.blendModes||(this.blendModes={},this.blendModes[d.BLEND_MODES.NORMAL]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],this.blendModes[d.BLEND_MODES.ADD]=[t.SRC_ALPHA,t.DST_ALPHA],this.blendModes[d.BLEND_MODES.MULTIPLY]=[t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA],this.blendModes[d.BLEND_MODES.SCREEN]=[t.SRC_ALPHA,t.ONE],this.blendModes[d.BLEND_MODES.OVERLAY]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],this.blendModes[d.BLEND_MODES.DARKEN]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],this.blendModes[d.BLEND_MODES.LIGHTEN]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],this.blendModes[d.BLEND_MODES.COLOR_DODGE]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],this.blendModes[d.BLEND_MODES.COLOR_BURN]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],this.blendModes[d.BLEND_MODES.HARD_LIGHT]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],this.blendModes[d.BLEND_MODES.SOFT_LIGHT]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],this.blendModes[d.BLEND_MODES.DIFFERENCE]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],this.blendModes[d.BLEND_MODES.EXCLUSION]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],this.blendModes[d.BLEND_MODES.HUE]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],this.blendModes[d.BLEND_MODES.SATURATION]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],this.blendModes[d.BLEND_MODES.COLOR]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],this.blendModes[d.BLEND_MODES.LUMINOSITY]=[t.ONE,t.ONE_MINUS_SRC_ALPHA]),this.drawModes||(this.drawModes={},this.drawModes[d.DRAW_MODES.POINTS]=t.POINTS,this.drawModes[d.DRAW_MODES.LINES]=t.LINES,this.drawModes[d.DRAW_MODES.LINE_LOOP]=t.LINE_LOOP,this.drawModes[d.DRAW_MODES.LINE_STRIP]=t.LINE_STRIP,this.drawModes[d.DRAW_MODES.TRIANGLES]=t.TRIANGLES,this.drawModes[d.DRAW_MODES.TRIANGLE_STRIP]=t.TRIANGLE_STRIP,this.drawModes[d.DRAW_MODES.TRIANGLE_FAN]=t.TRIANGLE_FAN)}},580:(t,e,n)=>{var i=n(8297);function s(t,e,n){this.shaders=[],this.padding=0,this.uniforms=n||{},this.vertexSrc=t||i.defaultVertexSrc,this.fragmentSrc=e||i.defaultFragmentSrc}s.prototype.constructor=s,t.exports=s,s.prototype.getShader=function(t){var e=t.gl,n=this.shaders[e.id];return n||(n=new i(t.shaderManager,this.vertexSrc,this.fragmentSrc,this.uniforms,this.attributes),this.shaders[e.id]=n),n},s.prototype.applyFilter=function(t,e,n,i){var s=this.getShader(t);t.filterManager.applyFilter(s,e,n,i)},s.prototype.syncUniform=function(t){for(var e=0,n=this.shaders.length;e{var i=n(580),s=n(7425);function r(){i.call(this,s.readFileSync("//FXAA.vert","utf8"),s.readFileSync("//FXAA.frag","utf8"),{resolution:{type:"v2",value:{x:1,y:1}}})}r.prototype=Object.create(i.prototype),r.prototype.constructor=r,t.exports=r,r.prototype.applyFilter=function(t,e,n){var i=t.filterManager,s=this.getShader(t);i.applyFilter(s,e,n)}},5207:(t,e,n)=>{var i=n(580),s=n(4650),r=n(7425);function a(t){var e=new s.Matrix;i.call(this,r.readFileSync("//spriteMaskFilter.vert","utf8"),r.readFileSync("//spriteMaskFilter.frag","utf8"),{mask:{type:"sampler2D",value:t._texture},alpha:{type:"f",value:1},otherMatrix:{type:"mat3",value:e.toArray(!0)}}),this.maskSprite=t,this.maskMatrix=e}a.prototype=Object.create(i.prototype),a.prototype.constructor=a,t.exports=a,a.prototype.applyFilter=function(t,e,n){var i=t.filterManager;this.uniforms.mask.value=this.maskSprite._texture,i.calculateMappedMatrix(e.frame,this.maskSprite,this.maskMatrix),this.uniforms.otherMatrix.value=this.maskMatrix.toArray(!0),this.uniforms.alpha.value=this.maskSprite.worldAlpha;var s=this.getShader(t);i.applyFilter(s,e,n)},Object.defineProperties(a.prototype,{map:{get:function(){return this.uniforms.mask.value},set:function(t){this.uniforms.mask.value=t}},offset:{get:function(){return this.uniforms.offset.value},set:function(t){this.uniforms.offset.value=t}}})},5396:(t,e,n)=>{var i=n(1103);function s(t){i.call(this,t),this.currentBlendMode=99999}s.prototype=Object.create(i.prototype),s.prototype.constructor=s,t.exports=s,s.prototype.setBlendMode=function(t){if(this.currentBlendMode===t)return!1;this.currentBlendMode=t;var e=this.renderer.blendModes[this.currentBlendMode];return this.renderer.gl.blendFunc(e[0],e[1]),!0}},4598:(t,e,n)=>{var i=n(1103),s=n(7955),r=n(6192),a=n(3885),o=n(4650);function l(t){i.call(this,t),this.filterStack=[],this.filterStack.push({renderTarget:t.currentRenderTarget,filter:[],bounds:null}),this.texturePool=[],this.textureSize=new o.Rectangle(0,0,t.width,t.height),this.currentFrame=null}l.prototype=Object.create(i.prototype),l.prototype.constructor=l,t.exports=l,l.prototype.onContextChange=function(){this.texturePool.length=0;var t=this.renderer.gl;this.quad=new a(t)},l.prototype.setFilterStack=function(t){this.filterStack=t},l.prototype.pushFilter=function(t,e){var n=t.filterArea?t.filterArea.clone():t.getBounds();n.x=0|n.x,n.y=0|n.y,n.width=0|n.width,n.height=0|n.height;var i=0|e[0].padding;if(n.x-=i,n.y-=i,n.width+=2*i,n.height+=2*i,this.renderer.currentRenderTarget.transform){var s=this.renderer.currentRenderTarget.transform;n.x+=s.tx,n.y+=s.ty,this.capFilterArea(n),n.x-=s.tx,n.y-=s.ty}else this.capFilterArea(n);if(n.width>0&&n.height>0){this.currentFrame=n;var r=this.getRenderTarget();this.renderer.setRenderTarget(r),r.clear(),this.filterStack.push({renderTarget:r,filter:e})}else this.filterStack.push({renderTarget:null,filter:e})},l.prototype.popFilter=function(){var t=this.filterStack.pop(),e=this.filterStack[this.filterStack.length-1],n=t.renderTarget;if(t.renderTarget){var i=e.renderTarget,s=this.renderer.gl;this.currentFrame=n.frame,this.quad.map(this.textureSize,n.frame),s.bindBuffer(s.ARRAY_BUFFER,this.quad.vertexBuffer),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,this.quad.indexBuffer);var a=t.filter;if(s.vertexAttribPointer(this.renderer.shaderManager.defaultShader.attributes.aVertexPosition,2,s.FLOAT,!1,0,0),s.vertexAttribPointer(this.renderer.shaderManager.defaultShader.attributes.aTextureCoord,2,s.FLOAT,!1,0,32),s.vertexAttribPointer(this.renderer.shaderManager.defaultShader.attributes.aColor,4,s.FLOAT,!1,0,64),this.renderer.blendModeManager.setBlendMode(r.BLEND_MODES.NORMAL),1===a.length)a[0].uniforms.dimensions&&(a[0].uniforms.dimensions.value[0]=this.renderer.width,a[0].uniforms.dimensions.value[1]=this.renderer.height,a[0].uniforms.dimensions.value[2]=this.quad.vertices[0],a[0].uniforms.dimensions.value[3]=this.quad.vertices[5]),a[0].applyFilter(this.renderer,n,i),this.returnRenderTarget(n);else{for(var o=n,l=this.getRenderTarget(!0),u=0;uthis.textureSize.width&&(t.width=this.textureSize.width-t.x),t.y+t.height>this.textureSize.height&&(t.height=this.textureSize.height-t.y)},l.prototype.resize=function(t,e){this.textureSize.width=t,this.textureSize.height=e;for(var n=0;n{var i=n(1103),s=n(5207);function r(t){i.call(this,t),this.stencilStack=[],this.reverse=!0,this.count=0,this.alphaMaskPool=[]}r.prototype=Object.create(i.prototype),r.prototype.constructor=r,t.exports=r,r.prototype.pushMask=function(t,e){e.texture?this.pushSpriteMask(t,e):this.pushStencilMask(t,e)},r.prototype.popMask=function(t,e){e.texture?this.popSpriteMask(t,e):this.popStencilMask(t,e)},r.prototype.pushSpriteMask=function(t,e){var n=this.alphaMaskPool.pop();n||(n=[new s(e)]),n[0].maskSprite=e,this.renderer.filterManager.pushFilter(t,n)},r.prototype.popSpriteMask=function(){var t=this.renderer.filterManager.popFilter();this.alphaMaskPool.push(t)},r.prototype.pushStencilMask=function(t,e){this.renderer.stencilManager.pushMask(e)},r.prototype.popStencilMask=function(t,e){this.renderer.stencilManager.popMask(e)}},3779:(t,e,n)=>{var i=n(1103),s=n(8297),r=n(7151),a=n(9691),o=n(501);function l(t){i.call(this,t),this.maxAttibs=10,this.attribState=[],this.tempAttribState=[];for(var e=0;e{var i=n(1103),s=n(501);function r(t){i.call(this,t),this.stencilMaskStack=null}r.prototype=Object.create(i.prototype),r.prototype.constructor=r,t.exports=r,r.prototype.setMaskStack=function(t){this.stencilMaskStack=t;var e=this.renderer.gl;0===t.stencilStack.length?e.disable(e.STENCIL_TEST):e.enable(e.STENCIL_TEST)},r.prototype.pushStencil=function(t,e){this.renderer.currentRenderTarget.attachStencilBuffer();var n=this.renderer.gl,i=this.stencilMaskStack;this.bindGraphics(t,e),0===i.stencilStack.length&&(n.enable(n.STENCIL_TEST),n.clear(n.STENCIL_BUFFER_BIT),i.reverse=!0,i.count=0),i.stencilStack.push(e);var s=i.count;n.colorMask(!1,!1,!1,!1),n.stencilFunc(n.ALWAYS,0,255),n.stencilOp(n.KEEP,n.KEEP,n.INVERT),1===e.mode?(n.drawElements(n.TRIANGLE_FAN,e.indices.length-4,n.UNSIGNED_SHORT,0),i.reverse?(n.stencilFunc(n.EQUAL,255-s,255),n.stencilOp(n.KEEP,n.KEEP,n.DECR)):(n.stencilFunc(n.EQUAL,s,255),n.stencilOp(n.KEEP,n.KEEP,n.INCR)),n.drawElements(n.TRIANGLE_FAN,4,n.UNSIGNED_SHORT,2*(e.indices.length-4)),i.reverse?n.stencilFunc(n.EQUAL,255-(s+1),255):n.stencilFunc(n.EQUAL,s+1,255),i.reverse=!i.reverse):(i.reverse?(n.stencilFunc(n.EQUAL,s,255),n.stencilOp(n.KEEP,n.KEEP,n.INCR)):(n.stencilFunc(n.EQUAL,255-s,255),n.stencilOp(n.KEEP,n.KEEP,n.DECR)),n.drawElements(n.TRIANGLE_STRIP,e.indices.length,n.UNSIGNED_SHORT,0),i.reverse?n.stencilFunc(n.EQUAL,s+1,255):n.stencilFunc(n.EQUAL,255-(s+1),255)),n.colorMask(!0,!0,!0,!0),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),i.count++},r.prototype.bindGraphics=function(t,e){var n,i=this.renderer.gl;1===e.mode?(n=this.renderer.shaderManager.complexPrimitiveShader,this.renderer.shaderManager.setShader(n),i.uniformMatrix3fv(n.uniforms.translationMatrix._location,!1,t.worldTransform.toArray(!0)),i.uniformMatrix3fv(n.uniforms.projectionMatrix._location,!1,this.renderer.currentRenderTarget.projectionMatrix.toArray(!0)),i.uniform3fv(n.uniforms.tint._location,s.hex2rgb(t.tint)),i.uniform3fv(n.uniforms.color._location,e.color),i.uniform1f(n.uniforms.alpha._location,t.worldAlpha),i.bindBuffer(i.ARRAY_BUFFER,e.buffer),i.vertexAttribPointer(n.attributes.aVertexPosition,2,i.FLOAT,!1,8,0),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.indexBuffer)):(n=this.renderer.shaderManager.primitiveShader,this.renderer.shaderManager.setShader(n),i.uniformMatrix3fv(n.uniforms.translationMatrix._location,!1,t.worldTransform.toArray(!0)),i.uniformMatrix3fv(n.uniforms.projectionMatrix._location,!1,this.renderer.currentRenderTarget.projectionMatrix.toArray(!0)),i.uniform3fv(n.uniforms.tint._location,s.hex2rgb(t.tint)),i.uniform1f(n.uniforms.alpha._location,t.worldAlpha),i.bindBuffer(i.ARRAY_BUFFER,e.buffer),i.vertexAttribPointer(n.attributes.aVertexPosition,2,i.FLOAT,!1,24,0),i.vertexAttribPointer(n.attributes.aColor,4,i.FLOAT,!1,24,8),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.indexBuffer))},r.prototype.popStencil=function(t,e){var n=this.renderer.gl,i=this.stencilMaskStack;if(i.stencilStack.pop(),i.count--,0===i.stencilStack.length)n.disable(n.STENCIL_TEST);else{var s=i.count;this.bindGraphics(t,e),n.colorMask(!1,!1,!1,!1),1===e.mode?(i.reverse=!i.reverse,i.reverse?(n.stencilFunc(n.EQUAL,255-(s+1),255),n.stencilOp(n.KEEP,n.KEEP,n.INCR)):(n.stencilFunc(n.EQUAL,s+1,255),n.stencilOp(n.KEEP,n.KEEP,n.DECR)),n.drawElements(n.TRIANGLE_FAN,4,n.UNSIGNED_SHORT,2*(e.indices.length-4)),n.stencilFunc(n.ALWAYS,0,255),n.stencilOp(n.KEEP,n.KEEP,n.INVERT),n.drawElements(n.TRIANGLE_FAN,e.indices.length-4,n.UNSIGNED_SHORT,0),this.renderer.drawCount+=2,i.reverse?n.stencilFunc(n.EQUAL,s,255):n.stencilFunc(n.EQUAL,255-s,255)):(i.reverse?(n.stencilFunc(n.EQUAL,s+1,255),n.stencilOp(n.KEEP,n.KEEP,n.DECR)):(n.stencilFunc(n.EQUAL,255-(s+1),255),n.stencilOp(n.KEEP,n.KEEP,n.INCR)),n.drawElements(n.TRIANGLE_STRIP,e.indices.length,n.UNSIGNED_SHORT,0),this.renderer.drawCount++,i.reverse?n.stencilFunc(n.EQUAL,s,255):n.stencilFunc(n.EQUAL,255-s,255)),n.colorMask(!0,!0,!0,!0),n.stencilOp(n.KEEP,n.KEEP,n.KEEP)}},r.prototype.destroy=function(){i.prototype.destroy.call(this),this.stencilMaskStack.stencilStack=null},r.prototype.pushMask=function(t){this.renderer.setObjectRenderer(this.renderer.plugins.graphics),t.dirty&&this.renderer.plugins.graphics.updateGraphics(t,this.renderer.gl),t._webGL[this.renderer.gl.id].data.length&&this.pushStencil(t,t._webGL[this.renderer.gl.id].data[0])},r.prototype.popMask=function(t){this.renderer.setObjectRenderer(this.renderer.plugins.graphics),this.popStencil(t,t._webGL[this.renderer.gl.id].data[0])}},1103:t=>{function e(t){this.renderer=t,this.renderer.on("context",this.onContextChange,this)}e.prototype.constructor=e,t.exports=e,e.prototype.onContextChange=function(){},e.prototype.destroy=function(){this.renderer.off("context",this.onContextChange,this),this.renderer=null}},7151:(t,e,n)=>{var i=n(8306);function s(t){i.call(this,t,["attribute vec2 aVertexPosition;","uniform mat3 translationMatrix;","uniform mat3 projectionMatrix;","uniform vec3 tint;","uniform float alpha;","uniform vec3 color;","varying vec4 vColor;","void main(void){"," gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);"," vColor = vec4(color * alpha * tint, alpha);","}"].join("\n"),["precision mediump float;","varying vec4 vColor;","void main(void){"," gl_FragColor = vColor;","}"].join("\n"),{tint:{type:"3f",value:[0,0,0]},alpha:{type:"1f",value:0},color:{type:"3f",value:[0,0,0]},translationMatrix:{type:"mat3",value:new Float32Array(9)},projectionMatrix:{type:"mat3",value:new Float32Array(9)}},{aVertexPosition:0})}s.prototype=Object.create(i.prototype),s.prototype.constructor=s,t.exports=s},9691:(t,e,n)=>{var i=n(8306);function s(t){i.call(this,t,["attribute vec2 aVertexPosition;","attribute vec4 aColor;","uniform mat3 translationMatrix;","uniform mat3 projectionMatrix;","uniform float alpha;","uniform float flipY;","uniform vec3 tint;","varying vec4 vColor;","void main(void){"," gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);"," vColor = aColor * vec4(tint * alpha, alpha);","}"].join("\n"),["precision mediump float;","varying vec4 vColor;","void main(void){"," gl_FragColor = vColor;","}"].join("\n"),{tint:{type:"3f",value:[0,0,0]},alpha:{type:"1f",value:0},translationMatrix:{type:"mat3",value:new Float32Array(9)},projectionMatrix:{type:"mat3",value:new Float32Array(9)}},{aVertexPosition:0,aColor:0})}s.prototype=Object.create(i.prototype),s.prototype.constructor=s,t.exports=s},8306:(t,e,n)=>{var i=n(501);function s(t,e,n,s,r){if(!e||!n)throw new Error("Pixi.js Error. Shader requires vertexSrc and fragmentSrc");this.uid=i.uid(),this.gl=t.renderer.gl,this.shaderManager=t,this.program=null,this.uniforms=s||{},this.attributes=r||{},this.textureCount=1,this.vertexSrc=e,this.fragmentSrc=n,this.init()}s.prototype.constructor=s,t.exports=s,s.prototype.init=function(){this.compile(),this.gl.useProgram(this.program),this.cacheUniformLocations(Object.keys(this.uniforms)),this.cacheAttributeLocations(Object.keys(this.attributes))},s.prototype.cacheUniformLocations=function(t){for(var e=0;e{var i=n(8306);function s(t,e,n,r,a){var o={uSampler:{type:"sampler2D",value:0},projectionMatrix:{type:"mat3",value:new Float32Array([1,0,0,0,1,0,0,0,1])}};if(r)for(var l in r)o[l]=r[l];var u={aVertexPosition:0,aTextureCoord:0,aColor:0};if(a)for(var h in a)u[h]=a[h];e=e||s.defaultVertexSrc,n=n||s.defaultFragmentSrc,i.call(this,t,e,n,o,u)}s.prototype=Object.create(i.prototype),s.prototype.constructor=s,t.exports=s,s.defaultVertexSrc=["precision lowp float;","attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute vec4 aColor;","uniform mat3 projectionMatrix;","varying vec2 vTextureCoord;","varying vec4 vColor;","void main(void){"," gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vColor = vec4(aColor.rgb * aColor.a, aColor.a);","}"].join("\n"),s.defaultFragmentSrc=["precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","void main(void){"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"].join("\n")},1830:(t,e,n)=>{var i=n(1103);function s(t){i.call(this,t)}s.prototype=Object.create(i.prototype),s.prototype.constructor=s,t.exports=s,s.prototype.start=function(){},s.prototype.stop=function(){this.flush()},s.prototype.flush=function(){},s.prototype.render=function(t){}},3885:t=>{function e(t){this.gl=t,this.vertices=new Float32Array([0,0,200,0,200,200,0,200]),this.uvs=new Float32Array([0,0,1,0,1,1,0,1]),this.colors=new Float32Array([1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]),this.indices=new Uint16Array([0,1,2,0,3,2]),this.vertexBuffer=t.createBuffer(),this.indexBuffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,128,t.DYNAMIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.indices,t.STATIC_DRAW),this.upload()}e.prototype.constructor=e,e.prototype.map=function(t,e){var n=0,i=0;this.uvs[0]=n,this.uvs[1]=i,this.uvs[2]=n+e.width/t.width,this.uvs[3]=i,this.uvs[4]=n+e.width/t.width,this.uvs[5]=i+e.height/t.height,this.uvs[6]=n,this.uvs[7]=i+e.height/t.height,n=e.x,i=e.y,this.vertices[0]=n,this.vertices[1]=i,this.vertices[2]=n+e.width,this.vertices[3]=i,this.vertices[4]=n+e.width,this.vertices[5]=i+e.height,this.vertices[6]=n,this.vertices[7]=i+e.height,this.upload()},e.prototype.upload=function(){var t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bufferSubData(t.ARRAY_BUFFER,0,this.vertices),t.bufferSubData(t.ARRAY_BUFFER,32,this.uvs),t.bufferSubData(t.ARRAY_BUFFER,64,this.colors)},e.prototype.destroy=function(){var t=this.gl;t.deleteBuffer(this.vertexBuffer),t.deleteBuffer(this.indexBuffer)},t.exports=e},7955:(t,e,n)=>{var i=n(4650),s=n(501),r=n(6192),a=n(8614),o=function(t,e,n,o,l,u){(this.gl=t,this.frameBuffer=null,this.texture=null,this.size=new i.Rectangle(0,0,1,1),this.resolution=l||r.RESOLUTION,this.projectionMatrix=new i.Matrix,this.transform=null,this.frame=null,this.stencilBuffer=null,this.stencilMaskStack=new a,this.filterStack=[{renderTarget:this,filter:[],bounds:this.size}],this.scaleMode=o||r.SCALE_MODES.DEFAULT,this.root=u,this.root)||(this.frameBuffer=t.createFramebuffer(),this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,o===r.SCALE_MODES.LINEAR?t.LINEAR:t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,o===r.SCALE_MODES.LINEAR?t.LINEAR:t.NEAREST),s.isPowerOfTwo(e,n)?(t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.REPEAT)):(t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)),t.bindFramebuffer(t.FRAMEBUFFER,this.frameBuffer),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this.texture,0));this.resize(e,n)};o.prototype.constructor=o,t.exports=o,o.prototype.clear=function(t){var e=this.gl;t&&e.bindFramebuffer(e.FRAMEBUFFER,this.frameBuffer),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT)},o.prototype.attachStencilBuffer=function(){if(!this.stencilBuffer&&!this.root){var t=this.gl;this.stencilBuffer=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,this.stencilBuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,this.stencilBuffer),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,this.size.width*this.resolution,this.size.height*this.resolution)}},o.prototype.activate=function(){var t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,this.frameBuffer);var e=this.frame||this.size;this.calculateProjection(e),this.transform&&this.projectionMatrix.append(this.transform),t.viewport(0,0,e.width*this.resolution,e.height*this.resolution)},o.prototype.calculateProjection=function(t){var e=this.projectionMatrix;e.identity(),this.root?(e.a=1/t.width*2,e.d=-1/t.height*2,e.tx=-1-t.x*e.a,e.ty=1-t.y*e.d):(e.a=1/t.width*2,e.d=1/t.height*2,e.tx=-1-t.x*e.a,e.ty=-1-t.y*e.d)},o.prototype.resize=function(t,e){if(t|=0,e|=0,this.size.width!==t||this.size.height!==e){if(this.size.width=t,this.size.height=e,!this.root){var n=this.gl;n.bindTexture(n.TEXTURE_2D,this.texture),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,t*this.resolution,e*this.resolution,0,n.RGBA,n.UNSIGNED_BYTE,null),this.stencilBuffer&&(n.bindRenderbuffer(n.RENDERBUFFER,this.stencilBuffer),n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,t*this.resolution,e*this.resolution))}var i=this.frame||this.size;this.calculateProjection(i)}},o.prototype.destroy=function(){var t=this.gl;t.deleteRenderbuffer(this.stencilBuffer),t.deleteFramebuffer(this.frameBuffer),t.deleteTexture(this.texture),this.frameBuffer=null,this.texture=null}},8614:t=>{function e(){this.stencilStack=[],this.reverse=!0,this.count=0}e.prototype.constructor=e,t.exports=e},2861:(t,e,n)=>{var i=n(4650),s=n(2699),r=n(7673),a=n(7809),o=n(501),l=n(6192),u=new i.Point;function h(t){r.call(this),this.anchor=new i.Point,this._texture=null,this._width=0,this._height=0,this.tint=16777215,this.blendMode=l.BLEND_MODES.NORMAL,this.shader=null,this.cachedTint=16777215,this.texture=t||s.EMPTY}h.prototype=Object.create(r.prototype),h.prototype.constructor=h,t.exports=h,Object.defineProperties(h.prototype,{width:{get:function(){return Math.abs(this.scale.x)*this.texture._frame.width},set:function(t){this.scale.x=o.sign(this.scale.x)*t/this.texture._frame.width,this._width=t}},height:{get:function(){return Math.abs(this.scale.y)*this.texture._frame.height},set:function(t){this.scale.y=o.sign(this.scale.y)*t/this.texture._frame.height,this._height=t}},texture:{get:function(){return this._texture},set:function(t){this._texture!==t&&(this._texture=t,this.cachedTint=16777215,t&&(t.baseTexture.hasLoaded?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}}),h.prototype._onTextureUpdate=function(){this._width&&(this.scale.x=o.sign(this.scale.x)*this._width/this.texture.frame.width),this._height&&(this.scale.y=o.sign(this.scale.y)*this._height/this.texture.frame.height)},h.prototype._renderWebGL=function(t){t.setObjectRenderer(t.plugins.sprite),t.plugins.sprite.render(this)},h.prototype.getBounds=function(t){if(!this._currentBounds){var e,n,i,s,r=this._texture._frame.width,a=this._texture._frame.height,o=r*(1-this.anchor.x),l=r*-this.anchor.x,u=a*(1-this.anchor.y),h=a*-this.anchor.y,p=t||this.worldTransform,c=p.a,d=p.b,f=p.c,m=p.d,g=p.tx,_=p.ty;if(0===d&&0===f)c<0&&(c*=-1),m<0&&(m*=-1),e=c*l+g,n=c*o+g,i=m*h+_,s=m*u+_;else{var T=c*l+f*h+g,y=m*h+d*l+_,I=c*o+f*h+g,E=m*h+d*o+_,b=c*o+f*u+g,v=m*u+d*o+_,w=c*l+f*u+g,S=m*u+d*l+_;e=w<(e=b<(e=I<(e=T)?I:e)?b:e)?w:e,i=S<(i=v<(i=E<(i=y)?E:i)?v:i)?S:i,n=w>(n=b>(n=I>(n=T)?I:n)?b:n)?w:n,s=S>(s=v>(s=E>(s=y)?E:s)?v:s)?S:s}if(this.children.length){var x=this.containerGetBounds();o=x.x,l=x.x+x.width,e=el?n:l,s=s>(h=x.y+x.height)?s:h}var R=this._bounds;R.x=e,R.width=n-e,R.y=i,R.height=s-i,this._currentBounds=R}return this._currentBounds},h.prototype.getLocalBounds=function(){return this._bounds.x=-this._texture._frame.width*this.anchor.x,this._bounds.y=-this._texture._frame.height*this.anchor.y,this._bounds.width=this._texture._frame.width,this._bounds.height=this._texture._frame.height,this._bounds},h.prototype.containsPoint=function(t){this.worldTransform.applyInverse(t,u);var e,n=this._texture._frame.width,i=this._texture._frame.height,s=-n*this.anchor.x;return u.x>s&&u.xe&&u.y{var i=n(1830),s=n(5092),r=n(6192);function a(t){i.call(this,t),this.vertSize=5,this.vertByteSize=4*this.vertSize,this.size=r.SPRITE_BATCH_SIZE;var e=4*this.size*this.vertByteSize,n=6*this.size;this.vertices=new ArrayBuffer(e),this.positions=new Float32Array(this.vertices),this.colors=new Uint32Array(this.vertices),this.indices=new Uint16Array(n);for(var s=0,a=0;s=this.size&&this.flush();var n=e._uvs;if(n){var i,s,r,a,o=t.anchor.x,l=t.anchor.y;if(e.trim&&void 0===t.tileScale){var u=e.trim;i=(s=u.x-o*u.width)+e.crop.width,r=(a=u.y-l*u.height)+e.crop.height}else i=e._frame.width*(1-o),s=e._frame.width*-o,r=e._frame.height*(1-l),a=e._frame.height*-l;var h=this.currentBatchSize*this.vertByteSize,p=t.worldTransform,c=p.a,d=p.b,f=p.c,m=p.d,g=p.tx,_=p.ty,T=this.colors,y=this.positions;this.renderer.roundPixels?(y[h]=c*s+f*a+g|0,y[h+1]=m*a+d*s+_|0,y[h+5]=c*i+f*a+g|0,y[h+6]=m*a+d*i+_|0,y[h+10]=c*i+f*r+g|0,y[h+11]=m*r+d*i+_|0,y[h+15]=c*s+f*r+g|0,y[h+16]=m*r+d*s+_|0):(y[h]=c*s+f*a+g,y[h+1]=m*a+d*s+_,y[h+5]=c*i+f*a+g,y[h+6]=m*a+d*i+_,y[h+10]=c*i+f*r+g,y[h+11]=m*r+d*i+_,y[h+15]=c*s+f*r+g,y[h+16]=m*r+d*s+_),y[h+2]=n.x0,y[h+3]=n.y0,y[h+7]=n.x1,y[h+8]=n.y1,y[h+12]=n.x2,y[h+13]=n.y2,y[h+17]=n.x3,y[h+18]=n.y3;var I=t.tint;T[h+4]=T[h+9]=T[h+14]=T[h+19]=(I>>16)+(65280&I)+((255&I)<<16)+(255*t.worldAlpha<<24),this.sprites[this.currentBatchSize++]=t}},a.prototype.flush=function(){if(0!==this.currentBatchSize){var t,e,n,i,s=this.renderer.gl;if(this.currentBatchSize>.5*this.size)s.bufferSubData(s.ARRAY_BUFFER,0,this.vertices);else{var r=this.positions.subarray(0,this.currentBatchSize*this.vertByteSize);s.bufferSubData(s.ARRAY_BUFFER,0,r)}for(var a,o=0,l=0,u=null,h=this.renderer.blendModeManager.currentBlendMode,p=null,c=!1,d=!1,f=0,m=this.currentBatchSize;f{var i=n(2861),s=n(2699),r=n(4650),a=n(501),o=n(6192);function l(t,e,n){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),this.resolution=n||o.RESOLUTION,this._text=null,this._style=null;var a=s.fromCanvas(this.canvas);a.trim=new r.Rectangle,i.call(this,a),this.text=t,this.style=e}l.prototype=Object.create(i.prototype),l.prototype.constructor=l,t.exports=l,l.fontPropertiesCache={},l.fontPropertiesCanvas=document.createElement("canvas"),l.fontPropertiesContext=l.fontPropertiesCanvas.getContext("2d"),Object.defineProperties(l.prototype,{width:{get:function(){return this.dirty&&this.updateText(),this.scale.x*this._texture._frame.width},set:function(t){this.scale.x=t/this._texture._frame.width,this._width=t}},height:{get:function(){return this.dirty&&this.updateText(),this.scale.y*this._texture._frame.height},set:function(t){this.scale.y=t/this._texture._frame.height,this._height=t}},style:{get:function(){return this._style},set:function(t){"number"==typeof(t=t||{}).fill&&(t.fill=a.hex2string(t.fill)),"number"==typeof t.stroke&&(t.stroke=a.hex2string(t.stroke)),"number"==typeof t.dropShadowColor&&(t.dropShadowColor=a.hex2string(t.dropShadowColor)),t.font=t.font||"bold 20pt Arial",t.fill=t.fill||"black",t.align=t.align||"left",t.stroke=t.stroke||"black",t.strokeThickness=t.strokeThickness||0,t.wordWrap=t.wordWrap||!1,t.wordWrapWidth=t.wordWrapWidth||100,t.dropShadow=t.dropShadow||!1,t.dropShadowColor=t.dropShadowColor||"#000000",t.dropShadowAngle=t.dropShadowAngle||Math.PI/6,t.dropShadowDistance=t.dropShadowDistance||5,t.padding=t.padding||0,t.textBaseline=t.textBaseline||"alphabetic",t.lineJoin=t.lineJoin||"miter",t.miterLimit=t.miterLimit||10,this._style=t,this.dirty=!0}},text:{get:function(){return this._text},set:function(t){t=t.toString()||" ",this._text!==t&&(this._text=t,this.dirty=!0)}}}),l.prototype.updateText=function(){var t=this._style;this.context.font=t.font;for(var e=(t.wordWrap?this.wordWrap(this._text):this._text).split(/(?:\r\n|\r|\n)/),n=new Array(e.length),i=0,s=this.determineFontProperties(t.font),r=0;rr;o--){for(u=0;ur?(o>0&&(e+="\n"),e+=a[o],r=i-l):(r-=u,e+=" "+a[o])}s{var i=n(501),s=n(6192),r=n(5585);function a(t,e,n){r.call(this),this.uid=i.uid(),this.resolution=n||1,this.width=100,this.height=100,this.realWidth=100,this.realHeight=100,this.scaleMode=e||s.SCALE_MODES.DEFAULT,this.hasLoaded=!1,this.isLoading=!1,this.source=null,this.premultipliedAlpha=!0,this.imageUrl=null,this.isPowerOfTwo=!1,this.mipmap=!1,this._glTextures=[],t&&this.loadSource(t)}a.prototype=Object.create(r.prototype),a.prototype.constructor=a,t.exports=a,a.prototype.update=function(){this.realWidth=this.source.naturalWidth||this.source.width,this.realHeight=this.source.naturalHeight||this.source.height,this.width=this.realWidth/this.resolution,this.height=this.realHeight/this.resolution,this.isPowerOfTwo=i.isPowerOfTwo(this.realWidth,this.realHeight),this.emit("update",this)},a.prototype.loadSource=function(t){var e=this.isLoading;if(this.hasLoaded=!1,this.isLoading=!1,e&&this.source&&(this.source.onload=null,this.source.onerror=null),this.source=t,(this.source.complete||this.source.getContext)&&this.source.width&&this.source.height)this._sourceLoaded();else if(!t.getContext){this.isLoading=!0;var n=this;t.onload=function(){t.onload=null,t.onerror=null,n.isLoading&&(n.isLoading=!1,n._sourceLoaded(),n.emit("loaded",n))},t.onerror=function(){t.onload=null,t.onerror=null,n.isLoading&&(n.isLoading=!1,n.emit("error",n))},t.complete&&t.src&&(this.isLoading=!1,t.onload=null,t.onerror=null,t.width&&t.height?(this._sourceLoaded(),e&&this.emit("loaded",this)):e&&this.emit("error",this))}},a.prototype._sourceLoaded=function(){this.hasLoaded=!0,this.update()},a.prototype.destroy=function(){this.imageUrl?(delete i.BaseTextureCache[this.imageUrl],delete i.TextureCache[this.imageUrl],this.imageUrl=null,navigator.isCocoonJS||(this.source.src="")):this.source&&this.source._pixiId&&delete i.BaseTextureCache[this.source._pixiId],this.source=null,this.dispose()},a.prototype.dispose=function(){this.emit("dispose",this),this._glTextures.length=0},a.prototype.updateSourceImage=function(t){this.source.src=t,this.loadSource(this.source)},a.fromImage=function(t,e,n){var s=i.BaseTextureCache[t];if(void 0===e&&0!==t.indexOf("data:")&&(e=!0),!s){var r=new Image;e&&(r.crossOrigin=""),(s=new a(r,n)).imageUrl=t,r.src=t,i.BaseTextureCache[t]=s,s.resolution=i.getResolutionOfUrl(t)}return s},a.fromCanvas=function(t,e){t._pixiId||(t._pixiId="canvas_"+i.uid());var n=i.BaseTextureCache[t._pixiId];return n||(n=new a(t,e),i.BaseTextureCache[t._pixiId]=n),n}},7443:(t,e,n)=>{var i=n(1936),s=n(2699),r=n(7955),a=n(4598),o=n(1549),l=n(4650),u=n(6192),h=new l.Matrix;function p(t,e,n,h,p){if(!t)throw new Error("Unable to create RenderTexture, you must pass a renderer into the constructor.");e=e||100,n=n||100,p=p||u.RESOLUTION;var c=new i;if(c.width=e,c.height=n,c.resolution=p,c.scaleMode=h||u.SCALE_MODES.DEFAULT,c.hasLoaded=!0,s.call(this,c,new l.Rectangle(0,0,e,n)),this.width=e,this.height=n,this.resolution=p,this.render=null,this.renderer=t,this.renderer.type===u.RENDERER_TYPE.WEBGL){var d=this.renderer.gl;this.textureBuffer=new r(d,this.width,this.height,c.scaleMode,this.resolution),this.baseTexture._glTextures[d.id]=this.textureBuffer.texture,this.filterManager=new a(this.renderer),this.filterManager.onContextChange(),this.filterManager.resize(e,n),this.render=this.renderWebGL,this.renderer.currentRenderer.start(),this.renderer.currentRenderTarget.activate()}else this.render=this.renderCanvas,this.textureBuffer=new o(this.width*this.resolution,this.height*this.resolution),this.baseTexture.source=this.textureBuffer.canvas;this.valid=!0,this._updateUvs()}p.prototype=Object.create(s.prototype),p.prototype.constructor=p,t.exports=p,p.prototype.resize=function(t,e,n){t===this.width&&e===this.height||(this.valid=t>0&&e>0,this.width=this._frame.width=this.crop.width=t,this.height=this._frame.height=this.crop.height=e,n&&(this.baseTexture.width=this.width,this.baseTexture.height=this.height),this.valid&&(this.textureBuffer.resize(this.width,this.height),this.filterManager&&this.filterManager.resize(this.width,this.height)))},p.prototype.clear=function(){this.valid&&(this.renderer.type===u.RENDERER_TYPE.WEBGL&&this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER,this.textureBuffer.frameBuffer),this.textureBuffer.clear())},p.prototype.renderWebGL=function(t,e,n,i){if(this.valid){if(i=void 0===i||i,//!updateTransform; this.textureBuffer.transform=e,this.textureBuffer.activate(),t.worldAlpha=1,i){t.worldTransform.identity(),t.currentBounds=null;var s,r,a=t.children;for(s=0,r=a.length;s{var i=n(1936),s=n(3367),r=n(1507),a=n(5585),o=n(4650),l=n(501);function u(t,e,n,i,s){a.call(this),this.noFrame=!1,e||(this.noFrame=!0,e=new o.Rectangle(0,0,1,1)),t instanceof u&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=i,this.valid=!1,this.requiresUpdate=!1,this._uvs=null,this.width=0,this.height=0,this.crop=n||e,this.rotate=!!s,t.hasLoaded?(this.noFrame&&(e=new o.Rectangle(0,0,t.width,t.height),t.on("update",this.onBaseTextureUpdated,this)),this.frame=e):t.once("loaded",this.onBaseTextureLoaded,this)}u.prototype=Object.create(a.prototype),u.prototype.constructor=u,t.exports=u,Object.defineProperties(u.prototype,{frame:{get:function(){return this._frame},set:function(t){if(this._frame=t,this.noFrame=!1,this.width=t.width,this.height=t.height,!this.trim&&!this.rotate&&(t.x+t.width>this.baseTexture.width||t.y+t.height>this.baseTexture.height))throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this);this.valid=t&&t.width&&t.height&&this.baseTexture.hasLoaded,this.trim?(this.width=this.trim.width,this.height=this.trim.height,this._frame.width=this.trim.width,this._frame.height=this.trim.height):this.crop=t,this.valid&&this._updateUvs()}}}),u.prototype.update=function(){this.baseTexture.update()},u.prototype.onBaseTextureLoaded=function(t){this.noFrame?this.frame=new o.Rectangle(0,0,t.width,t.height):this.frame=this._frame,this.emit("update",this)},u.prototype.onBaseTextureUpdated=function(t){this._frame.width=t.width,this._frame.height=t.height,this.emit("update",this)},u.prototype.destroy=function(t){this.baseTexture&&(t&&this.baseTexture.destroy(),this.baseTexture.off("update",this.onBaseTextureUpdated,this),this.baseTexture.off("loaded",this.onBaseTextureLoaded,this),this.baseTexture=null),this._frame=null,this._uvs=null,this.trim=null,this.crop=null,this.valid=!1,this.off("dispose",this.dispose,this),this.off("update",this.update,this)},u.prototype.clone=function(){return new u(this.baseTexture,this.frame,this.crop,this.trim,this.rotate)},u.prototype._updateUvs=function(){this._uvs||(this._uvs=new r),this._uvs.set(this.crop,this.baseTexture,this.rotate)},u.fromImage=function(t,e,n){var s=l.TextureCache[t];return s||(s=new u(i.fromImage(t,e,n)),l.TextureCache[t]=s),s},u.fromFrame=function(t){var e=l.TextureCache[t];if(!e)throw new Error('The frameId "'+t+'" does not exist in the texture cache');return e},u.fromCanvas=function(t,e){return new u(i.fromCanvas(t,e))},u.fromVideo=function(t,e){return"string"==typeof t?u.fromVideoUrl(t,e):new u(s.fromVideo(t,e))},u.fromVideoUrl=function(t,e){return new u(s.fromUrl(t,e))},u.addTextureToCache=function(t,e){l.TextureCache[e]=t},u.removeTextureFromCache=function(t){var e=l.TextureCache[t];return delete l.TextureCache[t],delete l.BaseTextureCache[t],e},u.EMPTY=new u(new i)},1507:t=>{function e(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1}t.exports=e,e.prototype.set=function(t,e,n){var i=e.width,s=e.height;n?(this.x0=(t.x+t.height)/i,this.y0=t.y/s,this.x1=(t.x+t.height)/i,this.y1=(t.y+t.width)/s,this.x2=t.x/i,this.y2=(t.y+t.width)/s,this.x3=t.x/i,this.y3=t.y/s):(this.x0=t.x/i,this.y0=t.y/s,this.x1=(t.x+t.width)/i,this.y1=t.y/s,this.x2=(t.x+t.width)/i,this.y2=(t.y+t.height)/s,this.x3=t.x/i,this.y3=(t.y+t.height)/s)}},3367:(t,e,n)=>{var i=n(1936),s=n(501);function r(t,e){if(!t)throw new Error("No video source element specified.");(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),i.call(this,t,e),this.autoUpdate=!1,this._onUpdate=this._onUpdate.bind(this),this._onCanPlay=this._onCanPlay.bind(this),t.complete||(t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("play",this._onPlayStart.bind(this)),t.addEventListener("pause",this._onPlayStop.bind(this))),this.__loaded=!1}function a(t,e){e||(e="video/"+t.substr(t.lastIndexOf(".")+1));var n=document.createElement("source");return n.src=t,n.type=e,n}r.prototype=Object.create(i.prototype),r.prototype.constructor=r,t.exports=r,r.prototype._onUpdate=function(){this.autoUpdate&&(window.requestAnimationFrame(this._onUpdate),this.update())},r.prototype._onPlayStart=function(){this.autoUpdate||(window.requestAnimationFrame(this._onUpdate),this.autoUpdate=!0)},r.prototype._onPlayStop=function(){this.autoUpdate=!1},r.prototype._onCanPlay=function(){this.hasLoaded=!0,this.source&&(this.source.removeEventListener("canplay",this._onCanPlay),this.source.removeEventListener("canplaythrough",this._onCanPlay),this.width=this.source.videoWidth,this.height=this.source.videoHeight,this.source.play(),this.__loaded||(this.__loaded=!0,this.emit("loaded",this)))},r.prototype.destroy=function(){this.source&&this.source._pixiId&&(delete s.BaseTextureCache[this.source._pixiId],delete this.source._pixiId),i.prototype.destroy.call(this)},r.fromVideo=function(t,e){t._pixiId||(t._pixiId="video_"+s.uid());var n=s.BaseTextureCache[t._pixiId];return n||(n=new r(t,e),s.BaseTextureCache[t._pixiId]=n),n},r.fromUrl=function(t,e){var n=document.createElement("video");if(Array.isArray(t))for(var i=0;i{var i=n(6192),s=n(5585),r="tick";function a(){var t=this;this._tick=function(e){t._requestId=null,t.started&&(t.update(e),t.started&&null===t._requestId&&t._emitter.listeners(r,!0)&&(t._requestId=requestAnimationFrame(t._tick)))},this._emitter=new s,this._requestId=null,this._maxElapsedMS=100,this.autoStart=!1,this.deltaTime=1,this.elapsedMS=1/i.TARGET_FPMS,this.lastTime=0,this.speed=1,this.started=!1}Object.defineProperties(a.prototype,{FPS:{get:function(){return 1e3/this.elapsedMS}},minFPS:{get:function(){return 1e3/this._maxElapsedMS},set:function(t){var e=Math.min(Math.max(0,t)/1e3,i.TARGET_FPMS);this._maxElapsedMS=1/e}}}),a.prototype._requestIfNeeded=function(){null===this._requestId&&this._emitter.listeners(r,!0)&&(this.lastTime=performance.now(),this._requestId=requestAnimationFrame(this._tick))},a.prototype._cancelIfNeeded=function(){null!==this._requestId&&(cancelAnimationFrame(this._requestId),this._requestId=null)},a.prototype._startIfPossible=function(){this.started?this._requestIfNeeded():this.autoStart&&this.start()},a.prototype.add=function(t,e){return this._emitter.on(r,t,e),this._startIfPossible(),this},a.prototype.addOnce=function(t,e){return this._emitter.once(r,t,e),this._startIfPossible(),this},a.prototype.remove=function(t,e){return this._emitter.off(r,t,e),this._emitter.listeners(r,!0)||this._cancelIfNeeded(),this},a.prototype.start=function(){this.started||(this.started=!0,this._requestIfNeeded())},a.prototype.stop=function(){this.started&&(this.started=!1,this._cancelIfNeeded())},a.prototype.update=function(t){var e;t=t||performance.now(),(e=this.elapsedMS=t-this.lastTime)>this._maxElapsedMS&&(e=this._maxElapsedMS),this.deltaTime=e*i.TARGET_FPMS*this.speed,this._emitter.emit(r,this.deltaTime),this.lastTime=t},t.exports=a},2410:(t,e,n)=>{var i=n(7974),s=new i;s.autoStart=!0,t.exports={shared:s,Ticker:i}},501:(t,e,n)=>{var i=n(6192),s=t.exports={_uid:0,_saidHello:!1,EventEmitter:n(5585),pluginTarget:n(7987),async:n(4083),uid:function(){return++s._uid},hex2rgb:function(t,e){return(e=e||[])[0]=(t>>16&255)/255,e[1]=(t>>8&255)/255,e[2]=(255&t)/255,e},hex2string:function(t){return t=t.toString(16),"#"+(t="000000".substr(0,6-t.length)+t)},rgb2hex:function(t){return(255*t[0]<<16)+(255*t[1]<<8)+255*t[2]},canUseNewCanvasBlendModes:function(){if("undefined"==typeof document)return!1;var t="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/",e="AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==",n=new Image;n.src=t+"AP804Oa6"+e;var i=new Image;i.src=t+"/wCKxvRF"+e;var s=document.createElement("canvas");s.width=6,s.height=1;var r=s.getContext("2d");r.globalCompositeOperation="multiply",r.drawImage(n,0,0),r.drawImage(i,2,0);var a=r.getImageData(2,0,1,1).data;return 255===a[0]&&0===a[1]&&0===a[2]},getNextPowerOfTwo:function(t){if(t>0&&!(t&t-1))return t;for(var e=1;e0&&!(t&t-1)&&e>0&&!(e&e-1)},getResolutionOfUrl:function(t){var e=i.RETINA_PREFIX.exec(t);return e?parseFloat(e[1]):1},sayHello:function(t){if(!s._saidHello){if(navigator.userAgent.toLowerCase().indexOf("chrome")>-1){var e=["\n %c %c %c Pixi.js "+i.VERSION+" - ✰ "+t+" ✰ %c %c http://www.pixijs.com/ %c %c ♥%c♥%c♥ \n\n","background: #ff66a5; padding:5px 0;","background: #ff66a5; padding:5px 0;","color: #ff66a5; background: #030307; padding:5px 0;","background: #ff66a5; padding:5px 0;","background: #ffc3dc; padding:5px 0;","background: #ff66a5; padding:5px 0;","color: #ff2424; background: #fff; padding:5px 0;","color: #ff2424; background: #fff; padding:5px 0;","color: #ff2424; background: #fff; padding:5px 0;"];window.console.log.apply(console,e)}else window.console&&window.console.log("Pixi.js "+i.VERSION+" - "+t+" - http://www.pixijs.com/");s._saidHello=!0}},isWebGLSupported:function(){var t={stencil:!0};try{if(!window.WebGLRenderingContext)return!1;var e=document.createElement("canvas"),n=e.getContext("webgl",t)||e.getContext("experimental-webgl",t);return!(!n||!n.getContextAttributes().stencil)}catch(t){return!1}},sign:function(t){return t?t<0?-1:1:0},TextureCache:{},BaseTextureCache:{}}},7987:t=>{t.exports={mixin:function(t){!function(t){t.__plugins={},t.registerPlugin=function(e,n){t.__plugins[e]=n},t.prototype.initPlugins=function(){for(var e in this.plugins=this.plugins||{},t.__plugins)this.plugins[e]=new t.__plugins[e](this)},t.prototype.destroyPlugins=function(){for(var t in this.plugins)this.plugins[t].destroy(),this.plugins[t]=null;this.plugins=null}}(t)}}},9513:(t,e,n)=>{var i=n(4651),s=n(8653),r=n(3323),a=n(8319);i.SpriteBatch=function(){throw new ReferenceError("SpriteBatch does not exist any more, please use the new ParticleContainer instead.")},i.AssetLoader=function(){throw new ReferenceError("The loader system was overhauled in pixi v3, please see the new PIXI.loaders.Loader class.")},Object.defineProperties(i,{Stage:{get:function(){return console.warn("You do not need to use a PIXI Stage any more, you can simply render any container."),i.Container}},DisplayObjectContainer:{get:function(){return console.warn("DisplayObjectContainer has been shortened to Container, please use Container from now on."),i.Container}},Strip:{get:function(){return console.warn("The Strip class has been renamed to Mesh and moved to mesh.Mesh, please use mesh.Mesh from now on."),s.Mesh}},Rope:{get:function(){return console.warn("The Rope class has been moved to mesh.Rope, please use mesh.Rope from now on."),s.Rope}},MovieClip:{get:function(){return console.warn("The MovieClip class has been moved to extras.MovieClip, please use extras.MovieClip from now on."),r.MovieClip}},TilingSprite:{get:function(){return console.warn("The TilingSprite class has been moved to extras.TilingSprite, please use extras.TilingSprite from now on."),r.TilingSprite}},BitmapText:{get:function(){return console.warn("The BitmapText class has been moved to extras.BitmapText, please use extras.BitmapText from now on."),r.BitmapText}},blendModes:{get:function(){return console.warn("The blendModes has been moved to BLEND_MODES, please use BLEND_MODES from now on."),i.BLEND_MODES}},scaleModes:{get:function(){return console.warn("The scaleModes has been moved to SCALE_MODES, please use SCALE_MODES from now on."),i.SCALE_MODES}},BaseTextureCache:{get:function(){return console.warn("The BaseTextureCache class has been moved to utils.BaseTextureCache, please use utils.BaseTextureCache from now on."),i.utils.BaseTextureCache}},TextureCache:{get:function(){return console.warn("The TextureCache class has been moved to utils.TextureCache, please use utils.TextureCache from now on."),i.utils.TextureCache}},math:{get:function(){return console.warn("The math namespace is deprecated, please access members already accessible on PIXI."),i}}}),i.Sprite.prototype.setTexture=function(t){this.texture=t,console.warn("setTexture is now deprecated, please use the texture property, e.g : sprite.texture = texture;")},r.BitmapText.prototype.setText=function(t){this.text=t,console.warn("setText is now deprecated, please use the text property, e.g : myBitmapText.text = 'my text';")},i.Text.prototype.setText=function(t){this.text=t,console.warn("setText is now deprecated, please use the text property, e.g : myText.text = 'my text';")},i.Text.prototype.setStyle=function(t){this.style=t,console.warn("setStyle is now deprecated, please use the style property, e.g : myText.style = style;")},i.Texture.prototype.setFrame=function(t){this.frame=t,console.warn("setFrame is now deprecated, please use the frame property, e.g : myTexture.frame = frame;")},Object.defineProperties(a,{AbstractFilter:{get:function(){return console.warn("filters.AbstractFilter is an undocumented alias, please use AbstractFilter from now on."),i.AbstractFilter}},FXAAFilter:{get:function(){return console.warn("filters.FXAAFilter is an undocumented alias, please use FXAAFilter from now on."),i.FXAAFilter}},SpriteMaskFilter:{get:function(){return console.warn("filters.SpriteMaskFilter is an undocumented alias, please use SpriteMaskFilter from now on."),i.SpriteMaskFilter}}}),i.utils.uuid=function(){return console.warn("utils.uuid() is deprecated, please use utils.uid() from now on."),i.utils.uid()}},3635:(t,e,n)=>{var i=n(4651);function s(t,e){i.Container.call(this),e=e||{},this.textWidth=0,this.textHeight=0,this._glyphs=[],this._font={tint:void 0!==e.tint?e.tint:16777215,align:e.align||"left",name:null,size:0},this.font=e.font,this._text=t,this.maxWidth=0,this.maxLineHeight=0,this.dirty=!1,this.updateText()}s.prototype=Object.create(i.Container.prototype),s.prototype.constructor=s,t.exports=s,Object.defineProperties(s.prototype,{tint:{get:function(){return this._font.tint},set:function(t){this._font.tint="number"==typeof t&&t>=0?t:16777215,this.dirty=!0}},align:{get:function(){return this._font.align},set:function(t){this._font.align=t||"left",this.dirty=!0}},font:{get:function(){return this._font},set:function(t){t&&("string"==typeof t?(t=t.split(" "),this._font.name=1===t.length?t[0]:t.slice(1).join(" "),this._font.size=t.length>=2?parseInt(t[0],10):s.fonts[this._font.name].size):(this._font.name=t.name,this._font.size="number"==typeof t.size?t.size:parseInt(t.size,10)),this.dirty=!0)}},text:{get:function(){return this._text},set:function(t){t=t.toString()||" ",this._text!==t&&(this._text=t,this.dirty=!0)}}}),s.prototype.updateText=function(){for(var t=s.fonts[this._font.name],e=new i.Point,n=null,r=[],a=0,o=0,l=[],u=0,h=this._font.size/t.size,p=-1,c=0,d=0;d0&&e.x*h>this.maxWidth)r.splice(p,d-p),d=p,p=-1,l.push(a),o=Math.max(o,a),u++,e.x=0,e.y+=t.lineHeight,n=null;else{var m=t.chars[f];m&&(n&&m.kerning[n]&&(e.x+=m.kerning[n]),r.push({texture:m.texture,line:u,charCode:f,position:new i.Point(e.x+m.xOffset,e.y+m.yOffset)}),a=e.x+(m.texture.width+m.xOffset),e.x+=m.xAdvance,c=Math.max(c,m.yOffset+m.texture.height),n=f)}}l.push(a),o=Math.max(o,a);var g=[];for(d=0;d<=u;d++){var _=0;"right"===this._font.align?_=o-l[d]:"center"===this._font.align&&(_=(o-l[d])/2),g.push(_)}var T=r.length,y=this.tint;for(d=0;d{var i=n(4651);function s(t){i.Sprite.call(this,t[0]instanceof i.Texture?t[0]:t[0].texture),this._textures=null,this._durations=null,this.textures=t,this.animationSpeed=1,this.loop=!0,this.onComplete=null,this._currentTime=0,this.playing=!1}s.prototype=Object.create(i.Sprite.prototype),s.prototype.constructor=s,t.exports=s,Object.defineProperties(s.prototype,{totalFrames:{get:function(){return this._textures.length}},textures:{get:function(){return this._textures},set:function(t){if(t[0]instanceof i.Texture)this._textures=t,this._durations=null;else{this._textures=[],this._durations=[];for(var e=0;e=this._durations[this.currentFrame];)n-=this._durations[this.currentFrame]*i,this._currentTime+=i;this._currentTime+=n/this._durations[this.currentFrame]}else this._currentTime+=e;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):this._texture=this._textures[this.currentFrame]},s.prototype.destroy=function(){this.stop(),i.Sprite.prototype.destroy.call(this)},s.fromFrames=function(t){for(var e=[],n=0;n{var i=n(4651),s=new i.Point,r=n(7809);function a(t,e,n){i.Sprite.call(this,t),this.tileScale=new i.Point(1,1),this.tilePosition=new i.Point(0,0),this._width=e||100,this._height=n||100,this._uvs=new i.TextureUvs,this._canvasPattern=null,this.shader=new i.AbstractFilter(["precision lowp float;","attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute vec4 aColor;","uniform mat3 projectionMatrix;","uniform vec4 uFrame;","uniform vec4 uTransform;","varying vec2 vTextureCoord;","varying vec4 vColor;","void main(void){"," gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);"," vec2 coord = aTextureCoord;"," coord -= uTransform.xy;"," coord /= uTransform.zw;"," vTextureCoord = coord;"," vColor = vec4(aColor.rgb * aColor.a, aColor.a);","}"].join("\n"),["precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","uniform vec4 uFrame;","uniform vec2 uPixelSize;","void main(void){"," vec2 coord = mod(vTextureCoord, uFrame.zw);"," coord = clamp(coord, uPixelSize, uFrame.zw - uPixelSize);"," coord += uFrame.xy;"," gl_FragColor = texture2D(uSampler, coord) * vColor ;","}"].join("\n"),{uFrame:{type:"4fv",value:[0,0,1,1]},uTransform:{type:"4fv",value:[0,0,1,1]},uPixelSize:{type:"2fv",value:[1,1]}})}a.prototype=Object.create(i.Sprite.prototype),a.prototype.constructor=a,t.exports=a,Object.defineProperties(a.prototype,{width:{get:function(){return this._width},set:function(t){this._width=t}},height:{get:function(){return this._height},set:function(t){this._height=t}}}),a.prototype._onTextureUpdate=function(){},a.prototype._renderWebGL=function(t){var e=this._texture;if(e&&e._uvs){var n=e._uvs,i=e._frame.width,s=e._frame.height,r=e.baseTexture.width,a=e.baseTexture.height;e._uvs=this._uvs,e._frame.width=this.width,e._frame.height=this.height,this.shader.uniforms.uPixelSize.value[0]=1/r,this.shader.uniforms.uPixelSize.value[1]=1/a,this.shader.uniforms.uFrame.value[0]=n.x0,this.shader.uniforms.uFrame.value[1]=n.y0,this.shader.uniforms.uFrame.value[2]=n.x1-n.x0,this.shader.uniforms.uFrame.value[3]=n.y2-n.y0,this.shader.uniforms.uTransform.value[0]=this.tilePosition.x%(i*this.tileScale.x)/this._width,this.shader.uniforms.uTransform.value[1]=this.tilePosition.y%(s*this.tileScale.y)/this._height,this.shader.uniforms.uTransform.value[2]=r/this._width*this.tileScale.x,this.shader.uniforms.uTransform.value[3]=a/this._height*this.tileScale.y,t.setObjectRenderer(t.plugins.sprite),t.plugins.sprite.render(this),e._uvs=n,e._frame.width=i,e._frame.height=s}},a.prototype._renderCanvas=function(t){var e=this._texture;if(e.baseTexture.hasLoaded){var n=t.context,s=this.worldTransform,a=t.resolution,o=e.baseTexture,l=this.tilePosition.x/this.tileScale.x%e._frame.width,u=this.tilePosition.y/this.tileScale.y%e._frame.height;if(!this._canvasPattern){var h=new i.CanvasBuffer(e._frame.width,e._frame.height);16777215!==this.tint?(this.cachedTint!==this.tint&&(this.cachedTint=this.tint,this.tintedTexture=r.getTintedTexture(this,this.tint)),h.context.drawImage(this.tintedTexture,0,0)):h.context.drawImage(o.source,-e._frame.x,-e._frame.y),this._canvasPattern=h.context.createPattern(h.canvas,"repeat")}n.globalAlpha=this.worldAlpha,n.setTransform(s.a*a,s.b*a,s.c*a,s.d*a,s.tx*a,s.ty*a),n.scale(this.tileScale.x,this.tileScale.y),n.translate(l+this.anchor.x*-this._width,u+this.anchor.y*-this._height);var p=t.blendModes[this.blendMode];p!==t.context.globalCompositeOperation&&(n.globalCompositeOperation=p),n.fillStyle=this._canvasPattern,n.fillRect(-l,-u,this._width/this.tileScale.x,this._height/this.tileScale.y)}},a.prototype.getBounds=function(){var t,e,n,i,s=this._width,r=this._height,a=s*(1-this.anchor.x),o=s*-this.anchor.x,l=r*(1-this.anchor.y),u=r*-this.anchor.y,h=this.worldTransform,p=h.a,c=h.b,d=h.c,f=h.d,m=h.tx,g=h.ty,_=p*o+d*u+m,T=f*u+c*o+g,y=p*a+d*u+m,I=f*u+c*a+g,E=p*a+d*l+m,b=f*l+c*a+g,v=p*o+d*l+m,w=f*l+c*o+g;t=v<(t=E<(t=y<(t=_)?y:t)?E:t)?v:t,n=w<(n=b<(n=I<(n=T)?I:n)?b:n)?w:n,e=v>(e=E>(e=y>(e=_)?y:e)?E:e)?v:e,i=w>(i=b>(i=I>(i=T)?I:i)?b:i)?w:i;var S=this._bounds;return S.x=t,S.width=e-t,S.y=n,S.height=i-n,this._currentBounds=S,S},a.prototype.containsPoint=function(t){this.worldTransform.applyInverse(t,s);var e,n=this._width,i=this._height,r=-n*this.anchor.x;return s.x>r&&s.xe&&s.y{var i=n(4651),s=i.DisplayObject,r=new i.Matrix;s.prototype._cacheAsBitmap=!1,s.prototype._originalRenderWebGL=null,s.prototype._originalRenderCanvas=null,s.prototype._originalUpdateTransform=null,s.prototype._originalHitTest=null,s.prototype._originalDestroy=null,s.prototype._cachedSprite=null,Object.defineProperties(s.prototype,{cacheAsBitmap:{get:function(){return this._cacheAsBitmap},set:function(t){this._cacheAsBitmap!==t&&(this._cacheAsBitmap=t,t?(this._originalRenderWebGL=this.renderWebGL,this._originalRenderCanvas=this.renderCanvas,this._originalUpdateTransform=this.updateTransform,this._originalGetBounds=this.getBounds,this._originalDestroy=this.destroy,this._originalContainsPoint=this.containsPoint,this.renderWebGL=this._renderCachedWebGL,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):(this._cachedSprite&&this._destroyCachedDisplayObject(),this.renderWebGL=this._originalRenderWebGL,this.renderCanvas=this._originalRenderCanvas,this.getBounds=this._originalGetBounds,this.destroy=this._originalDestroy,this.updateTransform=this._originalUpdateTransform,this.containsPoint=this._originalContainsPoint))}}}),s.prototype._renderCachedWebGL=function(t){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(t),this._cachedSprite.worldAlpha=this.worldAlpha,t.setObjectRenderer(t.plugins.sprite),t.plugins.sprite.render(this._cachedSprite))},s.prototype._initCachedDisplayObject=function(t){if(!this._cachedSprite){t.currentRenderer.flush();var e=this.getLocalBounds().clone();if(this._filters){var n=this._filters[0].padding;e.x-=n,e.y-=n,e.width+=2*n,e.height+=2*n}var s=t.currentRenderTarget,a=t.filterManager.filterStack,o=new i.RenderTexture(t,0|e.width,0|e.height),l=r;l.tx=-e.x,l.ty=-e.y,this.renderWebGL=this._originalRenderWebGL,o.render(this,l,!0,!0),t.setRenderTarget(s),t.filterManager.filterStack=a,this.renderWebGL=this._renderCachedWebGL,this.updateTransform=this.displayObjectUpdateTransform,this.getBounds=this._getCachedBounds,this._cachedSprite=new i.Sprite(o),this._cachedSprite.worldTransform=this.worldTransform,this._cachedSprite.anchor.x=-e.x/e.width,this._cachedSprite.anchor.y=-e.y/e.height,this.updateTransform(),this.containsPoint=this._cachedSprite.containsPoint.bind(this._cachedSprite)}},s.prototype._renderCachedCanvas=function(t){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(t),this._cachedSprite.worldAlpha=this.worldAlpha,this._cachedSprite.renderCanvas(t))},s.prototype._initCachedDisplayObjectCanvas=function(t){if(!this._cachedSprite){var e=this.getLocalBounds(),n=t.context,s=new i.RenderTexture(t,0|e.width,0|e.height),a=r;a.tx=-e.x,a.ty=-e.y,this.renderCanvas=this._originalRenderCanvas,s.render(this,a,!0),t.context=n,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.getBounds=this._getCachedBounds,this._cachedSprite=new i.Sprite(s),this._cachedSprite.worldTransform=this.worldTransform,this._cachedSprite.anchor.x=-e.x/e.width,this._cachedSprite.anchor.y=-e.y/e.height,this.updateTransform(),this.containsPoint=this._cachedSprite.containsPoint.bind(this._cachedSprite)}},s.prototype._getCachedBounds=function(){return this._cachedSprite._currentBounds=null,this._cachedSprite.getBounds()},s.prototype._destroyCachedDisplayObject=function(){this._cachedSprite._texture.destroy(),this._cachedSprite=null},s.prototype._cacheAsBitmapDestroy=function(){this.cacheAsBitmap=!1,this._originalDestroy()}},7231:(t,e,n)=>{var i=n(4651);i.DisplayObject.prototype.name=null,i.Container.prototype.getChildByName=function(t){for(var e=0;e{var i=n(4651);i.DisplayObject.prototype.getGlobalPosition=function(t){return t=t||new i.Point,this.parent?(this.displayObjectUpdateTransform(),t.x=this.worldTransform.tx,t.y=this.worldTransform.ty):(t.x=this.position.x,t.y=this.position.y),t}},3323:(t,e,n)=>{ /** * @file Main export of the PIXI extras library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ n(4262),n(7231),n(4247),t.exports={MovieClip:n(7901),TilingSprite:n(7377),BitmapText:n(3635)}},4350:(t,e,n)=>{var i=n(4651),s=n(9496);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//ascii.frag","utf8"),{dimensions:{type:"4fv",value:new Float32Array([0,0,0,0])},pixelSize:{type:"1f",value:8}})}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,Object.defineProperties(r.prototype,{size:{get:function(){return this.uniforms.pixelSize.value},set:function(t){this.uniforms.pixelSize.value=t}}})},5966:(t,e,n)=>{var i=n(4651),s=n(4356),r=n(6160);function a(){i.AbstractFilter.call(this),this.blurXFilter=new s,this.blurYFilter=new r,this.defaultFilter=new i.AbstractFilter}a.prototype=Object.create(i.AbstractFilter.prototype),a.prototype.constructor=a,t.exports=a,a.prototype.applyFilter=function(t,e,n){var s=t.filterManager.getRenderTarget(!0);this.defaultFilter.applyFilter(t,e,n),this.blurXFilter.applyFilter(t,e,s),t.blendModeManager.setBlendMode(i.BLEND_MODES.SCREEN),this.blurYFilter.applyFilter(t,s,n),t.blendModeManager.setBlendMode(i.BLEND_MODES.NORMAL),t.filterManager.returnRenderTarget(s)},Object.defineProperties(a.prototype,{blur:{get:function(){return this.blurXFilter.blur},set:function(t){this.blurXFilter.blur=this.blurYFilter.blur=t}},blurX:{get:function(){return this.blurXFilter.blur},set:function(t){this.blurXFilter.blur=t}},blurY:{get:function(){return this.blurYFilter.blur},set:function(t){this.blurYFilter.blur=t}}})},415:(t,e,n)=>{var i=n(4651),s=n(6786);function r(t,e){i.AbstractFilter.call(this,s.readFileSync("//blurDir.vert","utf8"),s.readFileSync("//blurDir.frag","utf8"),{strength:{type:"1f",value:1},dirX:{type:"1f",value:t||0},dirY:{type:"1f",value:e||0}}),this.defaultFilter=new i.AbstractFilter,this.passes=1,this.dirX=t||0,this.dirY=e||0,this.strength=4}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,r.prototype.applyFilter=function(t,e,n,i){var s=this.getShader(t);if(this.uniforms.strength.value=this.strength/4/this.passes*(e.frame.width/e.size.width),1===this.passes)t.filterManager.applyFilter(s,e,n,i);else{var r=t.filterManager.getRenderTarget(!0);t.filterManager.applyFilter(s,e,r,i);for(var a=0;a{var i=n(4651),s=n(4356),r=n(6160);function a(){i.AbstractFilter.call(this),this.blurXFilter=new s,this.blurYFilter=new r}a.prototype=Object.create(i.AbstractFilter.prototype),a.prototype.constructor=a,t.exports=a,a.prototype.applyFilter=function(t,e,n){var i=t.filterManager.getRenderTarget(!0);this.blurXFilter.applyFilter(t,e,i),this.blurYFilter.applyFilter(t,i,n),t.filterManager.returnRenderTarget(i)},Object.defineProperties(a.prototype,{blur:{get:function(){return this.blurXFilter.blur},set:function(t){this.padding=.5*Math.abs(t),this.blurXFilter.blur=this.blurYFilter.blur=t}},passes:{get:function(){return this.blurXFilter.passes},set:function(t){this.blurXFilter.passes=this.blurYFilter.passes=t}},blurX:{get:function(){return this.blurXFilter.blur},set:function(t){this.blurXFilter.blur=t}},blurY:{get:function(){return this.blurYFilter.blur},set:function(t){this.blurYFilter.blur=t}}})},4356:(t,e,n)=>{var i=n(4651),s=n(6786);function r(){i.AbstractFilter.call(this,s.readFileSync("//blurX.vert","utf8"),s.readFileSync("//blur.frag","utf8"),{strength:{type:"1f",value:1}}),this.passes=1,this.strength=4}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,r.prototype.applyFilter=function(t,e,n,i){var s=this.getShader(t);if(this.uniforms.strength.value=this.strength/4/this.passes*(e.frame.width/e.size.width),1===this.passes)t.filterManager.applyFilter(s,e,n,i);else{for(var r=t.filterManager.getRenderTarget(!0),a=e,o=r,l=0;l{var i=n(4651),s=n(6786);function r(){i.AbstractFilter.call(this,s.readFileSync("//blurY.vert","utf8"),s.readFileSync("//blur.frag","utf8"),{strength:{type:"1f",value:1}}),this.passes=1,this.strength=4}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,r.prototype.applyFilter=function(t,e,n,i){var s=this.getShader(t);if(this.uniforms.strength.value=Math.abs(this.strength)/4/this.passes*(e.frame.height/e.size.height),1===this.passes)t.filterManager.applyFilter(s,e,n,i);else{for(var r=t.filterManager.getRenderTarget(!0),a=e,o=r,l=0;l{var i=n(4651),s=n(6786);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//smartBlur.frag","utf8"),{delta:{type:"v2",value:{x:.1,y:0}}})}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r},9375:(t,e,n)=>{var i=n(4651),s=n(8884);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//colorMatrix.frag","utf8"),{m:{type:"1fv",value:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]}})}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,r.prototype._loadMatrix=function(t,e){var n=t;(e=!!e)&&(this._multiply(n,this.uniforms.m.value,t),n=this._colorMatrix(n)),this.uniforms.m.value=n},r.prototype._multiply=function(t,e,n){return t[0]=e[0]*n[0]+e[1]*n[5]+e[2]*n[10]+e[3]*n[15],t[1]=e[0]*n[1]+e[1]*n[6]+e[2]*n[11]+e[3]*n[16],t[2]=e[0]*n[2]+e[1]*n[7]+e[2]*n[12]+e[3]*n[17],t[3]=e[0]*n[3]+e[1]*n[8]+e[2]*n[13]+e[3]*n[18],t[4]=e[0]*n[4]+e[1]*n[9]+e[2]*n[14]+e[3]*n[19],t[5]=e[5]*n[0]+e[6]*n[5]+e[7]*n[10]+e[8]*n[15],t[6]=e[5]*n[1]+e[6]*n[6]+e[7]*n[11]+e[8]*n[16],t[7]=e[5]*n[2]+e[6]*n[7]+e[7]*n[12]+e[8]*n[17],t[8]=e[5]*n[3]+e[6]*n[8]+e[7]*n[13]+e[8]*n[18],t[9]=e[5]*n[4]+e[6]*n[9]+e[7]*n[14]+e[8]*n[19],t[10]=e[10]*n[0]+e[11]*n[5]+e[12]*n[10]+e[13]*n[15],t[11]=e[10]*n[1]+e[11]*n[6]+e[12]*n[11]+e[13]*n[16],t[12]=e[10]*n[2]+e[11]*n[7]+e[12]*n[12]+e[13]*n[17],t[13]=e[10]*n[3]+e[11]*n[8]+e[12]*n[13]+e[13]*n[18],t[14]=e[10]*n[4]+e[11]*n[9]+e[12]*n[14]+e[13]*n[19],t[15]=e[15]*n[0]+e[16]*n[5]+e[17]*n[10]+e[18]*n[15],t[16]=e[15]*n[1]+e[16]*n[6]+e[17]*n[11]+e[18]*n[16],t[17]=e[15]*n[2]+e[16]*n[7]+e[17]*n[12]+e[18]*n[17],t[18]=e[15]*n[3]+e[16]*n[8]+e[17]*n[13]+e[18]*n[18],t[19]=e[15]*n[4]+e[16]*n[9]+e[17]*n[14]+e[18]*n[19],t},r.prototype._colorMatrix=function(t){var e=new Float32Array(t);return e[4]/=255,e[9]/=255,e[14]/=255,e[19]/=255,e},r.prototype.brightness=function(t,e){var n=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(n,e)},r.prototype.greyscale=function(t,e){var n=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(n,e)},r.prototype.grayscale=r.prototype.greyscale,r.prototype.blackAndWhite=function(t){this._loadMatrix([.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0],t)},r.prototype.hue=function(t,e){t=(t||0)/180*Math.PI;var n=Math.cos(t),i=Math.sin(t),s=.213,r=.715,a=.072,o=[s+.787*n+i*-s,r+n*-r+i*-r,a+n*-a+.928*i,0,0,s+n*-s+.143*i,r+n*(1-r)+.14*i,a+n*-a+-.283*i,0,0,s+n*-s+-.787*i,r+n*-r+i*r,a+.928*n+i*a,0,0,0,0,0,1,0];this._loadMatrix(o,e)},r.prototype.contrast=function(t,e){var n=(t||0)+1,i=-128*(n-1),s=[n,0,0,0,i,0,n,0,0,i,0,0,n,0,i,0,0,0,1,0];this._loadMatrix(s,e)},r.prototype.saturate=function(t,e){var n=2*(t||0)/3+1,i=-.5*(n-1),s=[n,i,i,0,0,i,n,i,0,0,i,i,n,0,0,0,0,0,1,0];this._loadMatrix(s,e)},r.prototype.desaturate=function(t){this.saturate(-1)},r.prototype.negative=function(t){this._loadMatrix([0,1,1,0,0,1,0,1,0,0,1,1,0,0,0,0,0,0,1,0],t)},r.prototype.sepia=function(t){this._loadMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0],t)},r.prototype.technicolor=function(t){this._loadMatrix([1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0],t)},r.prototype.polaroid=function(t){this._loadMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0],t)},r.prototype.toBGR=function(t){this._loadMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0],t)},r.prototype.kodachrome=function(t){this._loadMatrix([1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0],t)},r.prototype.browni=function(t){this._loadMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0],t)},r.prototype.vintage=function(t){this._loadMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0],t)},r.prototype.colorTone=function(t,e,n,i,s){var r=((n=n||16770432)>>16&255)/255,a=(n>>8&255)/255,o=(255&n)/255,l=((i=i||3375104)>>16&255)/255,u=(i>>8&255)/255,h=(255&i)/255,p=[.3,.59,.11,0,0,r,a,o,t=t||.2,0,l,u,h,e=e||.15,0,r-l,a-u,o-h,0,0];this._loadMatrix(p,s)},r.prototype.night=function(t,e){var n=[-2*(t=t||.1),-t,0,0,0,-t,0,t,0,0,0,t,2*t,0,0,0,0,0,1,0];this._loadMatrix(n,e)},r.prototype.predator=function(t,e){var n=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(n,e)},r.prototype.lsd=function(t){this._loadMatrix([2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0],t)},r.prototype.reset=function(){this._loadMatrix([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],!1)},Object.defineProperties(r.prototype,{matrix:{get:function(){return this.uniforms.m.value},set:function(t){this.uniforms.m.value=t}}})},3640:(t,e,n)=>{var i=n(4651),s=n(8884);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//colorStep.frag","utf8"),{step:{type:"1f",value:5}})}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,Object.defineProperties(r.prototype,{step:{get:function(){return this.uniforms.step.value},set:function(t){this.uniforms.step.value=t}}})},6982:(t,e,n)=>{var i=n(4651),s=n(8001);function r(t,e,n){i.AbstractFilter.call(this,null,s.readFileSync("//convolution.frag","utf8"),{matrix:{type:"1fv",value:new Float32Array(t)},texelSize:{type:"v2",value:{x:1/e,y:1/n}}})}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,Object.defineProperties(r.prototype,{matrix:{get:function(){return this.uniforms.matrix.value},set:function(t){this.uniforms.matrix.value=new Float32Array(t)}},width:{get:function(){return 1/this.uniforms.texelSize.value.x},set:function(t){this.uniforms.texelSize.value.x=1/t}},height:{get:function(){return 1/this.uniforms.texelSize.value.y},set:function(t){this.uniforms.texelSize.value.y=1/t}}})},6280:(t,e,n)=>{var i=n(4651),s=n(1613);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//crosshatch.frag","utf8"))}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r},8286:(t,e,n)=>{var i=n(4651),s=n(5312);function r(t,e){var n=new i.Matrix;t.renderable=!1,i.AbstractFilter.call(this,s.readFileSync("//displacement.vert","utf8"),s.readFileSync("//displacement.frag","utf8"),{mapSampler:{type:"sampler2D",value:t.texture},otherMatrix:{type:"mat3",value:n.toArray(!0)},scale:{type:"v2",value:{x:1,y:1}}}),this.maskSprite=t,this.maskMatrix=n,null==e&&(e=20),this.scale=new i.Point(e,e)}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,r.prototype.applyFilter=function(t,e,n){var i=t.filterManager;i.calculateMappedMatrix(e.frame,this.maskSprite,this.maskMatrix),this.uniforms.otherMatrix.value=this.maskMatrix.toArray(!0),this.uniforms.scale.value.x=this.scale.x*(1/e.frame.width),this.uniforms.scale.value.y=this.scale.y*(1/e.frame.height);var s=this.getShader(t);i.applyFilter(s,e,n)},Object.defineProperties(r.prototype,{map:{get:function(){return this.uniforms.mapSampler.value},set:function(t){this.uniforms.mapSampler.value=t}}})},3466:(t,e,n)=>{var i=n(4651),s=n(9032);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//dotScreen.frag","utf8"),{scale:{type:"1f",value:1},angle:{type:"1f",value:5},dimensions:{type:"4fv",value:[0,0,0,0]}})}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,Object.defineProperties(r.prototype,{scale:{get:function(){return this.uniforms.scale.value},set:function(t){this.uniforms.scale.value=t}},angle:{get:function(){return this.uniforms.angle.value},set:function(t){this.uniforms.angle.value=t}}})},5038:(t,e,n)=>{var i=n(4651),s=n(574);function r(){i.AbstractFilter.call(this,s.readFileSync("//blurYTint.vert","utf8"),s.readFileSync("//blurYTint.frag","utf8"),{blur:{type:"1f",value:1/512},color:{type:"c",value:[0,0,0]},alpha:{type:"1f",value:.7},offset:{type:"2f",value:[5,5]},strength:{type:"1f",value:1}}),this.passes=1,this.strength=4}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,r.prototype.applyFilter=function(t,e,n,i){var s=this.getShader(t);if(this.uniforms.strength.value=this.strength/4/this.passes*(e.frame.height/e.size.height),1===this.passes)t.filterManager.applyFilter(s,e,n,i);else{for(var r=t.filterManager.getRenderTarget(!0),a=e,o=r,l=0;l{var i=n(4651),s=n(4356),r=n(5038);function a(){i.AbstractFilter.call(this),this.blurXFilter=new s,this.blurYTintFilter=new r,this.defaultFilter=new i.AbstractFilter,this.padding=30,this._dirtyPosition=!0,this._angle=45*Math.PI/180,this._distance=10,this.alpha=.75,this.hideObject=!1,this.blendMode=i.BLEND_MODES.MULTIPLY}a.prototype=Object.create(i.AbstractFilter.prototype),a.prototype.constructor=a,t.exports=a,a.prototype.applyFilter=function(t,e,n){var s=t.filterManager.getRenderTarget(!0);this._dirtyPosition&&(this._dirtyPosition=!1,this.blurYTintFilter.uniforms.offset.value[0]=Math.sin(this._angle)*this._distance,this.blurYTintFilter.uniforms.offset.value[1]=Math.cos(this._angle)*this._distance),this.blurXFilter.applyFilter(t,e,s),t.blendModeManager.setBlendMode(this.blendMode),this.blurYTintFilter.applyFilter(t,s,n),t.blendModeManager.setBlendMode(i.BLEND_MODES.NORMAL),this.hideObject||this.defaultFilter.applyFilter(t,e,n),t.filterManager.returnRenderTarget(s)},Object.defineProperties(a.prototype,{blur:{get:function(){return this.blurXFilter.blur},set:function(t){this.blurXFilter.blur=this.blurYTintFilter.blur=t}},blurX:{get:function(){return this.blurXFilter.blur},set:function(t){this.blurXFilter.blur=t}},blurY:{get:function(){return this.blurYTintFilter.blur},set:function(t){this.blurYTintFilter.blur=t}},color:{get:function(){return i.utils.rgb2hex(this.blurYTintFilter.uniforms.color.value)},set:function(t){this.blurYTintFilter.uniforms.color.value=i.utils.hex2rgb(t)}},alpha:{get:function(){return this.blurYTintFilter.uniforms.alpha.value},set:function(t){this.blurYTintFilter.uniforms.alpha.value=t}},distance:{get:function(){return this._distance},set:function(t){this._dirtyPosition=!0,this._distance=t}},angle:{get:function(){return this._angle},set:function(t){this._dirtyPosition=!0,this._angle=t}}})},5518:(t,e,n)=>{var i=n(4651),s=n(2672);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//gray.frag","utf8"),{gray:{type:"1f",value:1}})}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,Object.defineProperties(r.prototype,{gray:{get:function(){return this.uniforms.gray.value},set:function(t){this.uniforms.gray.value=t}}})},8319:(t,e,n)=>{ /** * @file Main export of the PIXI filters library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ t.exports={AsciiFilter:n(4350),BloomFilter:n(5966),BlurFilter:n(6762),BlurXFilter:n(4356),BlurYFilter:n(6160),BlurDirFilter:n(415),ColorMatrixFilter:n(9375),ColorStepFilter:n(3640),ConvolutionFilter:n(6982),CrossHatchFilter:n(6280),DisplacementFilter:n(8286),DotScreenFilter:n(3466),GrayFilter:n(5518),DropShadowFilter:n(1726),InvertFilter:n(5976),NoiseFilter:n(7898),PixelateFilter:n(240),RGBSplitFilter:n(1952),ShockwaveFilter:n(2942),SepiaFilter:n(3578),SmartBlurFilter:n(1327),TiltShiftFilter:n(6422),TiltShiftXFilter:n(3080),TiltShiftYFilter:n(4407),TwistFilter:n(7326)}},5976:(t,e,n)=>{var i=n(4651),s=n(8215);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//invert.frag","utf8"),{invert:{type:"1f",value:1}})}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,Object.defineProperties(r.prototype,{invert:{get:function(){return this.uniforms.invert.value},set:function(t){this.uniforms.invert.value=t}}})},7898:(t,e,n)=>{var i=n(4651),s=n(1417);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//noise.frag","utf8"),{noise:{type:"1f",value:.5}})}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,Object.defineProperties(r.prototype,{noise:{get:function(){return this.uniforms.noise.value},set:function(t){this.uniforms.noise.value=t}}})},240:(t,e,n)=>{var i=n(4651),s=n(9391);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//pixelate.frag","utf8"),{dimensions:{type:"4fv",value:new Float32Array([0,0,0,0])},pixelSize:{type:"v2",value:{x:10,y:10}}})}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,Object.defineProperties(r.prototype,{size:{get:function(){return this.uniforms.pixelSize.value},set:function(t){this.uniforms.pixelSize.value=t}}})},1952:(t,e,n)=>{var i=n(4651),s=n(3220);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//rgbSplit.frag","utf8"),{red:{type:"v2",value:{x:20,y:20}},green:{type:"v2",value:{x:-20,y:20}},blue:{type:"v2",value:{x:20,y:-20}},dimensions:{type:"4fv",value:[0,0,0,0]}})}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,Object.defineProperties(r.prototype,{red:{get:function(){return this.uniforms.red.value},set:function(t){this.uniforms.red.value=t}},green:{get:function(){return this.uniforms.green.value},set:function(t){this.uniforms.green.value=t}},blue:{get:function(){return this.uniforms.blue.value},set:function(t){this.uniforms.blue.value=t}}})},3578:(t,e,n)=>{var i=n(4651),s=n(3985);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//sepia.frag","utf8"),{sepia:{type:"1f",value:1}})}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,Object.defineProperties(r.prototype,{sepia:{get:function(){return this.uniforms.sepia.value},set:function(t){this.uniforms.sepia.value=t}}})},2942:(t,e,n)=>{var i=n(4651),s=n(32);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//shockwave.frag","utf8"),{center:{type:"v2",value:{x:.5,y:.5}},params:{type:"v3",value:{x:10,y:.8,z:.1}},time:{type:"1f",value:0}})}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,Object.defineProperties(r.prototype,{center:{get:function(){return this.uniforms.center.value},set:function(t){this.uniforms.center.value=t}},params:{get:function(){return this.uniforms.params.value},set:function(t){this.uniforms.params.value=t}},time:{get:function(){return this.uniforms.time.value},set:function(t){this.uniforms.time.value=t}}})},1519:(t,e,n)=>{var i=n(4651),s=n(5650);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//tiltShift.frag","utf8"),{blur:{type:"1f",value:100},gradientBlur:{type:"1f",value:600},start:{type:"v2",value:{x:0,y:window.innerHeight/2}},end:{type:"v2",value:{x:600,y:window.innerHeight/2}},delta:{type:"v2",value:{x:30,y:30}},texSize:{type:"v2",value:{x:window.innerWidth,y:window.innerHeight}}}),this.updateDelta()}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,r.prototype.updateDelta=function(){this.uniforms.delta.value.x=0,this.uniforms.delta.value.y=0},Object.defineProperties(r.prototype,{blur:{get:function(){return this.uniforms.blur.value},set:function(t){this.uniforms.blur.value=t}},gradientBlur:{get:function(){return this.uniforms.gradientBlur.value},set:function(t){this.uniforms.gradientBlur.value=t}},start:{get:function(){return this.uniforms.start.value},set:function(t){this.uniforms.start.value=t,this.updateDelta()}},end:{get:function(){return this.uniforms.end.value},set:function(t){this.uniforms.end.value=t,this.updateDelta()}}})},6422:(t,e,n)=>{var i=n(4651),s=n(3080),r=n(4407);function a(){i.AbstractFilter.call(this),this.tiltShiftXFilter=new s,this.tiltShiftYFilter=new r}a.prototype=Object.create(i.AbstractFilter.prototype),a.prototype.constructor=a,t.exports=a,a.prototype.applyFilter=function(t,e,n){var i=t.filterManager.getRenderTarget(!0);this.tiltShiftXFilter.applyFilter(t,e,i),this.tiltShiftYFilter.applyFilter(t,i,n),t.filterManager.returnRenderTarget(i)},Object.defineProperties(a.prototype,{blur:{get:function(){return this.tiltShiftXFilter.blur},set:function(t){this.tiltShiftXFilter.blur=this.tiltShiftYFilter.blur=t}},gradientBlur:{get:function(){return this.tiltShiftXFilter.gradientBlur},set:function(t){this.tiltShiftXFilter.gradientBlur=this.tiltShiftYFilter.gradientBlur=t}},start:{get:function(){return this.tiltShiftXFilter.start},set:function(t){this.tiltShiftXFilter.start=this.tiltShiftYFilter.start=t}},end:{get:function(){return this.tiltShiftXFilter.end},set:function(t){this.tiltShiftXFilter.end=this.tiltShiftYFilter.end=t}}})},3080:(t,e,n)=>{var i=n(1519);function s(){i.call(this)}s.prototype=Object.create(i.prototype),s.prototype.constructor=s,t.exports=s,s.prototype.updateDelta=function(){var t=this.uniforms.end.value.x-this.uniforms.start.value.x,e=this.uniforms.end.value.y-this.uniforms.start.value.y,n=Math.sqrt(t*t+e*e);this.uniforms.delta.value.x=t/n,this.uniforms.delta.value.y=e/n}},4407:(t,e,n)=>{var i=n(1519);function s(){i.call(this)}s.prototype=Object.create(i.prototype),s.prototype.constructor=s,t.exports=s,s.prototype.updateDelta=function(){var t=this.uniforms.end.value.x-this.uniforms.start.value.x,e=this.uniforms.end.value.y-this.uniforms.start.value.y,n=Math.sqrt(t*t+e*e);this.uniforms.delta.value.x=-e/n,this.uniforms.delta.value.y=t/n}},7326:(t,e,n)=>{var i=n(4651),s=n(6644);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//twist.frag","utf8"),{radius:{type:"1f",value:.5},angle:{type:"1f",value:5},offset:{type:"v2",value:{x:.5,y:.5}}})}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,Object.defineProperties(r.prototype,{offset:{get:function(){return this.uniforms.offset.value},set:function(t){this.uniforms.offset.value=t}},radius:{get:function(){return this.uniforms.radius.value},set:function(t){this.uniforms.radius.value=t}},angle:{get:function(){return this.uniforms.angle.value},set:function(t){this.uniforms.angle.value=t}}})},6619:(t,e,n)=>{n(255);var i=t.exports=n(4651);i.extras=n(3323),i.filters=n(8319),i.interaction=n(4816),i.loaders=n(5296),i.mesh=n(8653),i.loader=new i.loaders.Loader,Object.assign(i,n(9513)),n.g.PIXI=i},9440:(t,e,n)=>{var i=n(4651);function s(){this.global=new i.Point,this.target=null,this.originalEvent=null}s.prototype.constructor=s,t.exports=s,s.prototype.getLocalPosition=function(t,e,n){return t.toLocal(n||this.global,e)}},509:(t,e,n)=>{var i=n(4651),s=n(9440);function r(t,e){e=e||{},this.renderer=t,this.autoPreventDefault=void 0===e.autoPreventDefault||e.autoPreventDefault,this.interactionFrequency=e.interactionFrequency||10,this.mouse=new s,this.eventData={stopped:!1,target:null,type:null,data:this.mouse,stopPropagation:function(){this.stopped=!0}},this.interactiveDataPool=[],this.interactionDOMElement=null,this.eventsAdded=!1,this.onMouseUp=this.onMouseUp.bind(this),this.processMouseUp=this.processMouseUp.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.processMouseDown=this.processMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.processMouseMove=this.processMouseMove.bind(this),this.onMouseOut=this.onMouseOut.bind(this),this.processMouseOverOut=this.processMouseOverOut.bind(this),this.onTouchStart=this.onTouchStart.bind(this),this.processTouchStart=this.processTouchStart.bind(this),this.onTouchEnd=this.onTouchEnd.bind(this),this.processTouchEnd=this.processTouchEnd.bind(this),this.onTouchMove=this.onTouchMove.bind(this),this.processTouchMove=this.processTouchMove.bind(this),this.last=0,this.currentCursorStyle="inherit",this._tempPoint=new i.Point,this.resolution=1,this.setTargetElement(this.renderer.view,this.renderer.resolution)}Object.assign(i.DisplayObject.prototype,n(4241)),r.prototype.constructor=r,t.exports=r,r.prototype.setTargetElement=function(t,e){this.removeEvents(),this.interactionDOMElement=t,this.resolution=e||1,this.addEvents()},r.prototype.addEvents=function(){this.interactionDOMElement&&(i.ticker.shared.add(this.update,this),window.navigator.msPointerEnabled&&(this.interactionDOMElement.style["-ms-content-zooming"]="none",this.interactionDOMElement.style["-ms-touch-action"]="none"),window.document.addEventListener("mousemove",this.onMouseMove,!0),this.interactionDOMElement.addEventListener("mousedown",this.onMouseDown,!0),this.interactionDOMElement.addEventListener("mouseout",this.onMouseOut,!0),this.interactionDOMElement.addEventListener("touchstart",this.onTouchStart,!0),this.interactionDOMElement.addEventListener("touchend",this.onTouchEnd,!0),this.interactionDOMElement.addEventListener("touchmove",this.onTouchMove,!0),window.addEventListener("mouseup",this.onMouseUp,!0),this.eventsAdded=!0)},r.prototype.removeEvents=function(){this.interactionDOMElement&&(i.ticker.shared.remove(this.update),window.navigator.msPointerEnabled&&(this.interactionDOMElement.style["-ms-content-zooming"]="",this.interactionDOMElement.style["-ms-touch-action"]=""),window.document.removeEventListener("mousemove",this.onMouseMove,!0),this.interactionDOMElement.removeEventListener("mousedown",this.onMouseDown,!0),this.interactionDOMElement.removeEventListener("mouseout",this.onMouseOut,!0),this.interactionDOMElement.removeEventListener("touchstart",this.onTouchStart,!0),this.interactionDOMElement.removeEventListener("touchend",this.onTouchEnd,!0),this.interactionDOMElement.removeEventListener("touchmove",this.onTouchMove,!0),this.interactionDOMElement=null,window.removeEventListener("mouseup",this.onMouseUp,!0),this.eventsAdded=!1)},r.prototype.update=function(t){this._deltaTime+=t,this._deltaTime=0;o--)!a&&i?a=this.processInteractive(t,r[o],n,!0,s):this.processInteractive(t,r[o],n,!1,!1);return s&&(i&&(e.hitArea?(e.worldTransform.applyInverse(t,this._tempPoint),a=e.hitArea.contains(this._tempPoint.x,this._tempPoint.y)):e.containsPoint&&(a=e.containsPoint(t))),e.interactive&&n(e,a)),a},r.prototype.onMouseDown=function(t){this.mouse.originalEvent=t,this.eventData.data=this.mouse,this.eventData.stopped=!1,this.mapPositionToPoint(this.mouse.global,t.clientX,t.clientY),this.autoPreventDefault&&this.mouse.originalEvent.preventDefault(),this.processInteractive(this.mouse.global,this.renderer._lastObjectRendered,this.processMouseDown,!0)},r.prototype.processMouseDown=function(t,e){var n=this.mouse.originalEvent,i=2===n.button||3===n.which;e&&(t[i?"_isRightDown":"_isLeftDown"]=!0,this.dispatchEvent(t,i?"rightdown":"mousedown",this.eventData))},r.prototype.onMouseUp=function(t){this.mouse.originalEvent=t,this.eventData.data=this.mouse,this.eventData.stopped=!1,this.mapPositionToPoint(this.mouse.global,t.clientX,t.clientY),this.processInteractive(this.mouse.global,this.renderer._lastObjectRendered,this.processMouseUp,!0)},r.prototype.processMouseUp=function(t,e){var n=this.mouse.originalEvent,i=2===n.button||3===n.which,s=i?"_isRightDown":"_isLeftDown";e?(this.dispatchEvent(t,i?"rightup":"mouseup",this.eventData),t[s]&&(t[s]=!1,this.dispatchEvent(t,i?"rightclick":"click",this.eventData))):t[s]&&(t[s]=!1,this.dispatchEvent(t,i?"rightupoutside":"mouseupoutside",this.eventData))},r.prototype.onMouseMove=function(t){this.mouse.originalEvent=t,this.eventData.data=this.mouse,this.eventData.stopped=!1,this.mapPositionToPoint(this.mouse.global,t.clientX,t.clientY),this.didMove=!0,this.cursor="inherit",this.processInteractive(this.mouse.global,this.renderer._lastObjectRendered,this.processMouseMove,!0),this.currentCursorStyle!==this.cursor&&(this.currentCursorStyle=this.cursor,this.interactionDOMElement.style.cursor=this.cursor)},r.prototype.processMouseMove=function(t,e){this.dispatchEvent(t,"mousemove",this.eventData),this.processMouseOverOut(t,e)},r.prototype.onMouseOut=function(t){this.mouse.originalEvent=t,this.eventData.stopped=!1,this.mapPositionToPoint(this.mouse.global,t.clientX,t.clientY),this.interactionDOMElement.style.cursor="inherit",this.mapPositionToPoint(this.mouse.global,t.clientX,t.clientY),this.processInteractive(this.mouse.global,this.renderer._lastObjectRendered,this.processMouseOverOut,!1)},r.prototype.processMouseOverOut=function(t,e){e?(t._over||(t._over=!0,this.dispatchEvent(t,"mouseover",this.eventData)),t.buttonMode&&(this.cursor=t.defaultCursor)):t._over&&(t._over=!1,this.dispatchEvent(t,"mouseout",this.eventData))},r.prototype.onTouchStart=function(t){this.autoPreventDefault&&t.preventDefault();for(var e=t.changedTouches,n=e.length,i=0;i{ /** * @file Main export of the PIXI interactions library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ t.exports={InteractionData:n(9440),InteractionManager:n(509),interactiveTarget:n(4241)}},4241:t=>{t.exports={interactive:!1,buttonMode:!1,interactiveChildren:!0,defaultCursor:"pointer",_over:!1,_touchDown:!1}},4095:(t,e,n)=>{var i=n(542).Resource,s=n(4651),r=n(3323),a=n(6944);function o(t,e){var n={},i=t.data.getElementsByTagName("info")[0],a=t.data.getElementsByTagName("common")[0];n.font=i.getAttribute("face"),n.size=parseInt(i.getAttribute("size"),10),n.lineHeight=parseInt(a.getAttribute("lineHeight"),10),n.chars={};for(var o=t.data.getElementsByTagName("char"),l=0;l{ /** * @file Main export of the PIXI loaders library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ t.exports={Loader:n(7397),bitmapFontParser:n(4095),spritesheetParser:n(6695),textureParser:n(3968),Resource:n(542).Resource}},7397:(t,e,n)=>{var i=n(542),s=n(3968),r=n(6695),a=n(4095);function o(t,e){i.call(this,t,e);for(var n=0;n{var i=n(542).Resource,s=n(6944),r=n(4651);t.exports=function(){return function(t,e){if(!t.data||!t.isJson||!t.data.frames)return e();var n={crossOrigin:t.crossOrigin,loadType:i.LOAD_TYPE.IMAGE},a=s.dirname(t.url.replace(this.baseUrl,"")),o=r.utils.getResolutionOfUrl(t.url);this.add(t.name+"_image",a+"/"+t.data.meta.image,n,(function(n){t.textures={};var i=t.data.frames;for(var s in i){var a=i[s].frame;if(a){var l=null,u=null;if(l=i[s].rotated?new r.Rectangle(a.x,a.y,a.h,a.w):new r.Rectangle(a.x,a.y,a.w,a.h),i[s].trimmed&&(u=new r.Rectangle(i[s].spriteSourceSize.x/o,i[s].spriteSourceSize.y/o,i[s].sourceSize.w/o,i[s].sourceSize.h/o)),i[s].rotated){var h=l.width;l.width=l.height,l.height=h}l.x/=o,l.y/=o,l.width/=o,l.height/=o,t.textures[s]=new r.Texture(n.texture.baseTexture,l,l.clone(),u,i[s].rotated),r.utils.TextureCache[s]=t.textures[s]}}e()}))}}},3968:(t,e,n)=>{var i=n(4651);t.exports=function(){return function(t,e){if(t.data&&t.isImage){var n=new i.BaseTexture(t.data,null,i.utils.getResolutionOfUrl(t.url));n.imageUrl=t.url,t.texture=new i.Texture(n),i.utils.BaseTextureCache[t.url]=n,i.utils.TextureCache[t.url]=t.texture}e()}}},2876:(t,e,n)=>{var i=n(4651),s=new i.Point,r=new i.Polygon;function a(t,e,n,s,r){i.Container.call(this),this._texture=null,this.uvs=n||new Float32Array([0,1,1,1,1,0,0,1]),this.vertices=e||new Float32Array([0,0,100,0,100,100,0,100]),this.indices=s||new Uint16Array([0,1,2,3]),this.dirty=!0,this.blendMode=i.BLEND_MODES.NORMAL,this.canvasPadding=0,this.drawMode=r||a.DRAW_MODES.TRIANGLE_MESH,this.texture=t}a.prototype=Object.create(i.Container.prototype),a.prototype.constructor=a,t.exports=a,Object.defineProperties(a.prototype,{texture:{get:function(){return this._texture},set:function(t){this._texture!==t&&(this._texture=t,t&&(t.baseTexture.hasLoaded?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}}),a.prototype._renderWebGL=function(t){t.setObjectRenderer(t.plugins.mesh),t.plugins.mesh.render(this)},a.prototype._renderCanvas=function(t){var e=t.context,n=this.worldTransform;t.roundPixels?e.setTransform(n.a,n.b,n.c,n.d,0|n.tx,0|n.ty):e.setTransform(n.a,n.b,n.c,n.d,n.tx,n.ty),this.drawMode===a.DRAW_MODES.TRIANGLE_MESH?this._renderCanvasTriangleMesh(e):this._renderCanvasTriangles(e)},a.prototype._renderCanvasTriangleMesh=function(t){for(var e=this.vertices,n=this.uvs,i=e.length/2,s=0;s0){var E=this.canvasPadding/this.worldTransform.a,b=this.canvasPadding/this.worldTransform.d,v=(u+h+p)/3,w=(c+d+f)/3,S=u-v,x=c-w,R=Math.sqrt(S*S+x*x);u=v+S/R*(R+E),c=w+x/R*(R+b),x=d-w,h=v+(S=h-v)/(R=Math.sqrt(S*S+x*x))*(R+E),d=w+x/R*(R+b),x=f-w,p=v+(S=p-v)/(R=Math.sqrt(S*S+x*x))*(R+E),f=w+x/R*(R+b)}t.save(),t.beginPath(),t.moveTo(u,c),t.lineTo(h,d),t.lineTo(p,f),t.closePath(),t.clip();var A=m*y+T*_+g*I-y*_-T*g-m*I,O=u*y+T*p+h*I-y*p-T*h-u*I,M=m*h+u*_+g*p-h*_-u*g-m*p,C=m*y*p+T*h*_+u*g*I-u*y*_-T*g*p-m*h*I,N=c*y+T*f+d*I-y*f-T*d-c*I,k=m*d+c*_+g*f-d*_-c*g-m*f,D=m*y*f+T*d*_+c*g*I-c*y*_-T*g*f-m*d*I;t.transform(O/A,N/A,M/A,k/A,C/A,D/A),t.drawImage(a,0,0),t.restore()},a.prototype.renderMeshFlat=function(t){var e=this.context,n=t.vertices,i=n.length/2;e.beginPath();for(var s=1;su?T:u,h=y>h?y:h}if(p===-1/0||h===1/0)return i.Rectangle.EMPTY;var I=this._bounds;I.x=p,I.width=u-p,I.y=c,I.height=h-c,this._currentBounds=I}return this._currentBounds},a.prototype.containsPoint=function(t){if(!this.getBounds().contains(t.x,t.y))return!1;this.worldTransform.applyInverse(t,s);var e,n,i=this.vertices,o=r.points;if(this.drawMode===a.DRAW_MODES.TRIANGLES){var l=this.indices;for(n=this.indices.length,e=0;e{var i=n(2876),s=n(4651);function r(t,e){i.call(this,t),this.points=e,this.vertices=new Float32Array(4*e.length),this.uvs=new Float32Array(4*e.length),this.colors=new Float32Array(2*e.length),this.indices=new Uint16Array(2*e.length),this._ready=!0,this.refresh()}r.prototype=Object.create(i.prototype),r.prototype.constructor=r,t.exports=r,r.prototype.refresh=function(){var t=this.points;if(!(t.length<1)&&this._texture._uvs){var e=this.uvs,n=this.indices,i=this.colors,r=this._texture._uvs,a=new s.Point(r.x0,r.y0),o=new s.Point(r.x2-r.x0,r.y2-r.y0);e[0]=0+a.x,e[1]=0+a.y,e[2]=0+a.x,e[3]=1*o.y+a.y,i[0]=1,i[1]=1,n[0]=0,n[1]=1;for(var l,u,h=t.length,p=1;p1&&1,o/=s=Math.sqrt(o*o+l*l),l/=s,o*=r=this._texture.height/2,l*=r,u[i]=n.x+o,u[i+1]=n.y+l,u[i+2]=n.x-o,u[i+3]=n.y-l,a=n;this.containerUpdateTransform()}}},8653:(t,e,n)=>{ /** * @file Main export of the PIXI extras library * @author Mat Groves * @copyright 2013-2015 GoodBoyDigital * @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License} */ t.exports={Mesh:n(2876),Rope:n(7005),MeshRenderer:n(6709),MeshShader:n(2003)}},6709:(t,e,n)=>{var i=n(4651),s=n(2876);function r(t){i.ObjectRenderer.call(this,t),this.indices=new Uint16Array(15e3);for(var e=0,n=0;e<15e3;e+=6,n+=4)this.indices[e+0]=n+0,this.indices[e+1]=n+1,this.indices[e+2]=n+2,this.indices[e+3]=n+0,this.indices[e+4]=n+2,this.indices[e+5]=n+3}r.prototype=Object.create(i.ObjectRenderer.prototype),r.prototype.constructor=r,t.exports=r,i.WebGLRenderer.registerPlugin("mesh",r),r.prototype.onContextChange=function(){},r.prototype.render=function(t){t._vertexBuffer||this._initWebGL(t);var e=this.renderer,n=e.gl,i=t._texture.baseTexture,r=e.shaderManager.plugins.meshShader,a=t.drawMode===s.DRAW_MODES.TRIANGLE_MESH?n.TRIANGLE_STRIP:n.TRIANGLES;e.blendModeManager.setBlendMode(t.blendMode),n.uniformMatrix3fv(r.uniforms.translationMatrix._location,!1,t.worldTransform.toArray(!0)),n.uniformMatrix3fv(r.uniforms.projectionMatrix._location,!1,e.currentRenderTarget.projectionMatrix.toArray(!0)),n.uniform1f(r.uniforms.alpha._location,t.worldAlpha),t.dirty?(t.dirty=!1,n.bindBuffer(n.ARRAY_BUFFER,t._vertexBuffer),n.bufferData(n.ARRAY_BUFFER,t.vertices,n.STATIC_DRAW),n.vertexAttribPointer(r.attributes.aVertexPosition,2,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,t._uvBuffer),n.bufferData(n.ARRAY_BUFFER,t.uvs,n.STATIC_DRAW),n.vertexAttribPointer(r.attributes.aTextureCoord,2,n.FLOAT,!1,0,0),n.activeTexture(n.TEXTURE0),i._glTextures[n.id]?n.bindTexture(n.TEXTURE_2D,i._glTextures[n.id]):this.renderer.updateTexture(i),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t._indexBuffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.indices,n.STATIC_DRAW)):(n.bindBuffer(n.ARRAY_BUFFER,t._vertexBuffer),n.bufferSubData(n.ARRAY_BUFFER,0,t.vertices),n.vertexAttribPointer(r.attributes.aVertexPosition,2,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,t._uvBuffer),n.vertexAttribPointer(r.attributes.aTextureCoord,2,n.FLOAT,!1,0,0),n.activeTexture(n.TEXTURE0),i._glTextures[n.id]?n.bindTexture(n.TEXTURE_2D,i._glTextures[n.id]):this.renderer.updateTexture(i),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t._indexBuffer),n.bufferSubData(n.ELEMENT_ARRAY_BUFFER,0,t.indices)),n.drawElements(a,t.indices.length,n.UNSIGNED_SHORT,0)},r.prototype._initWebGL=function(t){var e=this.renderer.gl;t._vertexBuffer=e.createBuffer(),t._indexBuffer=e.createBuffer(),t._uvBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,t._vertexBuffer),e.bufferData(e.ARRAY_BUFFER,t.vertices,e.DYNAMIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,t._uvBuffer),e.bufferData(e.ARRAY_BUFFER,t.uvs,e.STATIC_DRAW),t.colors&&(t._colorBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,t._colorBuffer),e.bufferData(e.ARRAY_BUFFER,t.colors,e.STATIC_DRAW)),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t._indexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,t.indices,e.STATIC_DRAW)},r.prototype.flush=function(){},r.prototype.start=function(){var t=this.renderer.shaderManager.plugins.meshShader;this.renderer.shaderManager.setShader(t)},r.prototype.destroy=function(){i.ObjectRenderer.prototype.destroy.call(this)}},2003:(t,e,n)=>{var i=n(4651);function s(t){i.Shader.call(this,t,["precision lowp float;","attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","uniform mat3 translationMatrix;","uniform mat3 projectionMatrix;","varying vec2 vTextureCoord;","void main(void){"," gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);"," vTextureCoord = aTextureCoord;","}"].join("\n"),["precision lowp float;","varying vec2 vTextureCoord;","uniform float alpha;","uniform sampler2D uSampler;","void main(void){"," gl_FragColor = texture2D(uSampler, vTextureCoord) * alpha ;","}"].join("\n"),{alpha:{type:"1f",value:0},translationMatrix:{type:"mat3",value:new Float32Array(9)},projectionMatrix:{type:"mat3",value:new Float32Array(9)}},{aVertexPosition:0,aTextureCoord:0})}s.prototype=Object.create(i.Shader.prototype),s.prototype.constructor=s,t.exports=s,i.ShaderManager.registerPlugin("meshShader",s)},9206:()=>{Math.sign||(Math.sign=function(t){return 0===(t=+t)||isNaN(t)?t:t>0?1:-1})},7537:(t,e,n)=>{Object.assign||(Object.assign=n(5228))},255:(t,e,n)=>{n(7537),n(4377),n(9206)},4377:(t,e,n)=>{if(Date.now&&Date.prototype.getTime||(Date.now=function(){return(new Date).getTime()}),!n.g.performance||!n.g.performance.now){var i=Date.now();n.g.performance||(n.g.performance={}),n.g.performance.now=function(){return Date.now()-i}}for(var s=Date.now(),r=["ms","moz","webkit","o"],a=0;a{var e,n,i=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function a(t){if(e===setTimeout)return setTimeout(t,0);if((e===s||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(n){try{return e.call(null,t,0)}catch(n){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:s}catch(t){e=s}try{n="function"==typeof clearTimeout?clearTimeout:r}catch(t){n=r}}();var o,l=[],u=!1,h=-1;function p(){u&&o&&(u=!1,o.length?l=o.concat(l):h=-1,l.length&&c())}function c(){if(!u){var t=a(p);u=!0;for(var e=l.length;e;){for(o=l,l=[];++h1)for(var n=1;n{"use strict";n.d(e,{D:()=>i});var i=function(){function t(t){var e=this;void 0===t&&(t=!1),this.ignoreMultipleSettles=t,this.isSettled=!1,this.promise=new Promise((function(t,n){e.resolveCallback=t,e.rejectCallback=n}))}return t.prototype.markAsSettled=function(){var t=this.isSettled;if(t&&!this.ignoreMultipleSettles)throw new Error("PromiseDelegate is already settled!");return this.isSettled=!0,!t},Object.defineProperty(t.prototype,"settled",{get:function(){return this.isSettled},enumerable:!1,configurable:!0}),t.prototype.resolve=function(t){this.markAsSettled()&&this.resolveCallback(t)},t.prototype.reject=function(t){this.markAsSettled()&&this.rejectCallback(t)},t}()},5006:t=>{"use strict";var e=Object.prototype.hasOwnProperty,n="~";function i(){}function s(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function r(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(n=!1)),r.prototype.eventNames=function(){var t,i,s=[];if(0===this._eventsCount)return s;for(i in t=this._events)e.call(t,i)&&s.push(n?i.slice(1):i);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(t)):s},r.prototype.listeners=function(t,e){var i=n?n+t:t,s=this._events[i];if(e)return!!s;if(!s)return[];if(s.fn)return[s.fn];for(var r=0,a=s.length,o=new Array(a);r{"use strict";var i=n(4678),s=n(978),r=n(8664),a=n(5006);function o(t,e){a.call(this),e=e||10,this.baseUrl=t||"",this.progress=0,this.loading=!1,this._progressChunk=0,this._beforeMiddleware=[],this._afterMiddleware=[],this._boundLoadResource=this._loadResource.bind(this),this._buffer=[],this._numToLoad=0,this._queue=s.queue(this._boundLoadResource,e),this.resources={}}o.prototype=Object.create(a.prototype),o.prototype.constructor=o,t.exports=o,o.prototype.add=o.prototype.enqueue=function(t,e,n,i){if(Array.isArray(t)){for(var s=0;s{"use strict";var i=n(5006),s=n(4678),r=!(!window.XDomainRequest||"withCredentials"in new XMLHttpRequest),a=null;function o(t,e,n){if(i.call(this),n=n||{},"string"!=typeof t||"string"!=typeof e)throw new Error("Both name and url are required for constructing a resource.");this.name=t,this.url=e,this.isDataUrl=0===this.url.indexOf("data:"),this.data=null,this.crossOrigin=!0===n.crossOrigin?"anonymous":n.crossOrigin,this.loadType=n.loadType||this._determineLoadType(),this.xhrType=n.xhrType,this.metadata=n.metadata||{},this.error=null,this.xhr=null,this.isJson=!1,this.isXml=!1,this.isImage=!1,this.isAudio=!1,this.isVideo=!1,this.isComplete=!1,this.isLoading=!1,this._dequeue=null,this._boundComplete=this.complete.bind(this),this._boundOnError=this._onError.bind(this),this._boundOnProgress=this._onProgress.bind(this),this._boundXhrOnError=this._xhrOnError.bind(this),this._boundXhrOnAbort=this._xhrOnAbort.bind(this),this._boundXhrOnLoad=this._xhrOnLoad.bind(this),this._boundXdrOnTimeout=this._xdrOnTimeout.bind(this)}function l(t){return t.toString().replace("object ","")}function u(t,e,n){e&&0===e.indexOf(".")&&(e=e.substring(1)),e&&(t[e]=n)}o.prototype=Object.create(i.prototype),o.prototype.constructor=o,t.exports=o,o.prototype.complete=function(){if(this.data&&this.data.removeEventListener&&(this.data.removeEventListener("error",this._boundOnError,!1),this.data.removeEventListener("load",this._boundComplete,!1),this.data.removeEventListener("progress",this._boundOnProgress,!1),this.data.removeEventListener("canplaythrough",this._boundComplete,!1)),this.xhr&&(this.xhr.removeEventListener?(this.xhr.removeEventListener("error",this._boundXhrOnError,!1),this.xhr.removeEventListener("abort",this._boundXhrOnAbort,!1),this.xhr.removeEventListener("progress",this._boundOnProgress,!1),this.xhr.removeEventListener("load",this._boundXhrOnLoad,!1)):(this.xhr.onerror=null,this.xhr.ontimeout=null,this.xhr.onprogress=null,this.xhr.onload=null)),this.isComplete)throw new Error("Complete called again for an already completed resource.");this.isComplete=!0,this.isLoading=!1,this.emit("complete",this)},o.prototype.abort=function(t){if(!this.error){if(this.error=new Error(t),this.xhr)this.xhr.abort();else if(this.xdr)this.xdr.abort();else if(this.data)if(void 0!==this.data.src)this.data.src="";else for(;this.data.firstChild;)this.data.removeChild(this.data.firstChild);this.complete()}},o.prototype.load=function(t){if(!this.isLoading)if(this.isComplete){if(t){var e=this;setTimeout((function(){t(e)}),1)}}else switch(t&&this.once("complete",t),this.isLoading=!0,this.emit("start",this),!1!==this.crossOrigin&&"string"==typeof this.crossOrigin||(this.crossOrigin=this._determineCrossOrigin(this.url)),this.loadType){case o.LOAD_TYPE.IMAGE:this._loadElement("image");break;case o.LOAD_TYPE.AUDIO:this._loadSourceElement("audio");break;case o.LOAD_TYPE.VIDEO:this._loadSourceElement("video");break;case o.LOAD_TYPE.XHR:default:r&&this.crossOrigin?this._loadXdr():this._loadXhr()}},o.prototype._loadElement=function(t){this.metadata.loadElement?this.data=this.metadata.loadElement:"image"===t&&void 0!==window.Image?this.data=new Image:this.data=document.createElement(t),this.crossOrigin&&(this.data.crossOrigin=this.crossOrigin),this.metadata.skipSource||(this.data.src=this.url);var e="is"+t[0].toUpperCase()+t.substring(1);!1===this[e]&&(this[e]=!0),this.data.addEventListener("error",this._boundOnError,!1),this.data.addEventListener("load",this._boundComplete,!1),this.data.addEventListener("progress",this._boundOnProgress,!1)},o.prototype._loadSourceElement=function(t){if(this.metadata.loadElement?this.data=this.metadata.loadElement:"audio"===t&&void 0!==window.Audio?this.data=new Audio:this.data=document.createElement(t),null!==this.data){if(!this.metadata.skipSource)if(navigator.isCocoonJS)this.data.src=Array.isArray(this.url)?this.url[0]:this.url;else if(Array.isArray(this.url))for(var e=0;e0){if(this.xhrType===o.XHR_RESPONSE_TYPE.TEXT)this.data=t.responseText;else if(this.xhrType===o.XHR_RESPONSE_TYPE.JSON)try{this.data=JSON.parse(t.responseText),this.isJson=!0}catch(t){return void this.abort("Error trying to parse loaded json:",t)}else if(this.xhrType===o.XHR_RESPONSE_TYPE.DOCUMENT)try{if(window.DOMParser){var n=new DOMParser;this.data=n.parseFromString(t.responseText,"text/xml")}else{var i=document.createElement("div");i.innerHTML=t.responseText,this.data=i}this.isXml=!0}catch(t){return void this.abort("Error trying to parse loaded xml:",t)}else this.data=t.response||t.responseText;this.complete()}else this.abort("["+t.status+"]"+t.statusText+":"+t.responseURL)},o.prototype._determineCrossOrigin=function(t,e){if(0===t.indexOf("data:"))return"";e=e||window.location,a||(a=document.createElement("a")),a.href=t;var n=!(t=s(a.href,{strictMode:!0})).port&&""===e.port||t.port===e.port,i=t.protocol?t.protocol+":":"";return t.host===e.hostname&&n&&i===e.protocol?"":"anonymous"},o.prototype._determineXhrType=function(){return o._xhrTypeMap[this._getExtension()]||o.XHR_RESPONSE_TYPE.TEXT},o.prototype._determineLoadType=function(){return o._loadTypeMap[this._getExtension()]||o.LOAD_TYPE.XHR},o.prototype._getExtension=function(){var t=this.url,e="";if(this.isDataUrl){var n=t.indexOf("/");e=t.substring(n+1,t.indexOf(";",n))}else{var i=t.indexOf("?");-1!==i&&(t=t.substring(0,i)),e=t.substring(t.lastIndexOf(".")+1)}return e.toLowerCase()},o.prototype._getMimeFromXhrType=function(t){switch(t){case o.XHR_RESPONSE_TYPE.BUFFER:return"application/octet-binary";case o.XHR_RESPONSE_TYPE.BLOB:return"application/blob";case o.XHR_RESPONSE_TYPE.DOCUMENT:return"application/xml";case o.XHR_RESPONSE_TYPE.JSON:return"application/json";case o.XHR_RESPONSE_TYPE.DEFAULT:case o.XHR_RESPONSE_TYPE.TEXT:default:return"text/plain"}},o.LOAD_TYPE={XHR:1,IMAGE:2,AUDIO:3,VIDEO:4},o.XHR_RESPONSE_TYPE={DEFAULT:"text",BUFFER:"arraybuffer",BLOB:"blob",DOCUMENT:"document",JSON:"json",TEXT:"text"},o._loadTypeMap={gif:o.LOAD_TYPE.IMAGE,png:o.LOAD_TYPE.IMAGE,bmp:o.LOAD_TYPE.IMAGE,jpg:o.LOAD_TYPE.IMAGE,jpeg:o.LOAD_TYPE.IMAGE,tif:o.LOAD_TYPE.IMAGE,tiff:o.LOAD_TYPE.IMAGE,webp:o.LOAD_TYPE.IMAGE,tga:o.LOAD_TYPE.IMAGE,"svg+xml":o.LOAD_TYPE.IMAGE},o._xhrTypeMap={xhtml:o.XHR_RESPONSE_TYPE.DOCUMENT,html:o.XHR_RESPONSE_TYPE.DOCUMENT,htm:o.XHR_RESPONSE_TYPE.DOCUMENT,xml:o.XHR_RESPONSE_TYPE.DOCUMENT,tmx:o.XHR_RESPONSE_TYPE.DOCUMENT,tsx:o.XHR_RESPONSE_TYPE.DOCUMENT,svg:o.XHR_RESPONSE_TYPE.DOCUMENT,gif:o.XHR_RESPONSE_TYPE.BLOB,png:o.XHR_RESPONSE_TYPE.BLOB,bmp:o.XHR_RESPONSE_TYPE.BLOB,jpg:o.XHR_RESPONSE_TYPE.BLOB,jpeg:o.XHR_RESPONSE_TYPE.BLOB,tif:o.XHR_RESPONSE_TYPE.BLOB,tiff:o.XHR_RESPONSE_TYPE.BLOB,webp:o.XHR_RESPONSE_TYPE.BLOB,tga:o.XHR_RESPONSE_TYPE.BLOB,json:o.XHR_RESPONSE_TYPE.JSON,text:o.XHR_RESPONSE_TYPE.TEXT,txt:o.XHR_RESPONSE_TYPE.TEXT},o.setExtensionLoadType=function(t,e){u(o._loadTypeMap,t,e)},o.setExtensionXhrType=function(t,e){u(o._xhrTypeMap,t,e)}},978:t=>{"use strict";function e(){}function n(t){return function(){if(null===t)throw new Error("Callback was already called.");var e=t;t=null,e.apply(this,arguments)}}t.exports={eachSeries:function(t,e,n){var i=0,s=t.length;!function r(a){a||i===s?n&&n(a):e(t[i++],r)}()},queue:function(t,i){if(null==i)i=1;else if(0===i)throw new Error("Concurrency must not be zero");var s=0,r={_tasks:[],concurrency:i,saturated:e,unsaturated:e,buffer:i/4,empty:e,drain:e,error:e,started:!1,paused:!1,push:function(t,e){a(t,!1,e)},kill:function(){r.drain=e,r._tasks=[]},unshift:function(t,e){a(t,!0,e)},process:function(){for(;!r.paused&&s{"use strict";t.exports={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encodeBinary:function(t){for(var e,n="",i=new Array(4),s=0,r=0;s>2,i[1]=(3&e[0])<<4|e[1]>>4,i[2]=(15&e[1])<<2|e[2]>>6,i[3]=63&e[2],s-(t.length-1)){case 2:i[3]=64,i[2]=64;break;case 1:i[3]=64}for(r=0;r{"use strict";t.exports=n(3723),t.exports.Resource=n(8664),t.exports.middleware={caching:{memory:n(9911)},parsing:{blob:n(2796)}},t.exports.async=n(978)},9911:t=>{"use strict";var e={};t.exports=function(){return function(t,n){e[t.url]?(t.data=e[t.url],t.complete()):t.once("complete",(function(){e[this.url]=this.data})),n()}}},2796:(t,e,n)=>{"use strict";var i=n(8664),s=n(9350),r=window.URL||window.webkitURL;t.exports=function(){return function(t,e){if(t.data){if(t.xhr&&t.xhrType===i.XHR_RESPONSE_TYPE.BLOB)if(window.Blob&&"string"!=typeof t.data){if(0===t.data.type.indexOf("image")){var n=r.createObjectURL(t.data);return t.blob=t.data,t.data=new Image,t.data.src=n,t.isImage=!0,void(t.data.onload=function(){r.revokeObjectURL(n),t.data.onload=null,e()})}}else{var a=t.xhr.getResponseHeader("content-type");if(a&&0===a.indexOf("image"))return t.data=new Image,t.data.src="data:"+a+";base64,"+s.encodeBinary(t.xhr.responseText),t.isImage=!0,void(t.data.onload=function(){t.data.onload=null,e()})}e()}else e()}}},5242:(t,e,n)=>{ /*! safe-buffer. MIT License. Feross Aboukhadijeh */ var i=n(8287),s=i.Buffer;function r(t,e){for(var n in t)e[n]=t[n]}function a(t,e,n){return s(t,e,n)}s.from&&s.alloc&&s.allocUnsafe&&s.allocUnsafeSlow?t.exports=i:(r(i,e),e.Buffer=a),a.prototype=Object.create(s.prototype),r(s,a),a.from=function(t,e,n){if("number"==typeof t)throw new TypeError("Argument must not be a number");return s(t,e,n)},a.alloc=function(t,e,n){if("number"!=typeof t)throw new TypeError("Argument must be a number");var i=s(t);return void 0!==e?"string"==typeof n?i.fill(e,n):i.fill(e):i.fill(0),i},a.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return s(t)},a.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i.SlowBuffer(t)}},7391:(t,e,n)=>{var i=n(7180),s=n(3181),r=n(3031),a=n(9067),o=n(6833),l=n(3717),u=n(4801);u.alea=i,u.xor128=s,u.xorwow=r,u.xorshift7=a,u.xor4096=o,u.tychei=l,t.exports=u},7180:function(t,e,n){var i;!function(t,s){function r(t){var e=this,n=function(){var t=4022871197,e=function(e){e=String(e);for(var n=0;n>>0,t=(i*=t)>>>0,t+=4294967296*(i-=t)}return 2.3283064365386963e-10*(t>>>0)};return e}();e.next=function(){var t=2091639*e.s0+2.3283064365386963e-10*e.c;return e.s0=e.s1,e.s1=e.s2,e.s2=t-(e.c=0|t)},e.c=1,e.s0=n(" "),e.s1=n(" "),e.s2=n(" "),e.s0-=n(t),e.s0<0&&(e.s0+=1),e.s1-=n(t),e.s1<0&&(e.s1+=1),e.s2-=n(t),e.s2<0&&(e.s2+=1),n=null}function a(t,e){return e.c=t.c,e.s0=t.s0,e.s1=t.s1,e.s2=t.s2,e}function o(t,e){var n=new r(t),i=e&&e.state,s=n.next;return s.int32=function(){return 4294967296*n.next()|0},s.double=function(){return s()+11102230246251565e-32*(2097152*s()|0)},s.quick=s,i&&("object"==typeof i&&a(i,n),s.state=function(){return a(n,{})}),s}s&&s.exports?s.exports=o:n.amdD&&n.amdO?void 0===(i=function(){return o}.call(e,n,e,s))||(s.exports=i):this.alea=o}(0,t=n.nmd(t),n.amdD)},3717:function(t,e,n){var i;!function(t,s){function r(t){var e=this,n="";e.next=function(){var t=e.b,n=e.c,i=e.d,s=e.a;return t=t<<25^t>>>7^n,n=n-i|0,i=i<<24^i>>>8^s,s=s-t|0,e.b=t=t<<20^t>>>12^n,e.c=n=n-i|0,e.d=i<<16^n>>>16^s,e.a=s-t|0},e.a=0,e.b=0,e.c=-1640531527,e.d=1367130551,t===Math.floor(t)?(e.a=t/4294967296|0,e.b=0|t):n+=t;for(var i=0;i>>0)/4294967296};return s.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},s.int32=n.next,s.quick=s,i&&("object"==typeof i&&a(i,n),s.state=function(){return a(n,{})}),s}s&&s.exports?s.exports=o:n.amdD&&n.amdO?void 0===(i=function(){return o}.call(e,n,e,s))||(s.exports=i):this.tychei=o}(0,t=n.nmd(t),n.amdD)},3181:function(t,e,n){var i;!function(t,s){function r(t){var e=this,n="";e.x=0,e.y=0,e.z=0,e.w=0,e.next=function(){var t=e.x^e.x<<11;return e.x=e.y,e.y=e.z,e.z=e.w,e.w^=e.w>>>19^t^t>>>8},t===(0|t)?e.x=t:n+=t;for(var i=0;i>>0)/4294967296};return s.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},s.int32=n.next,s.quick=s,i&&("object"==typeof i&&a(i,n),s.state=function(){return a(n,{})}),s}s&&s.exports?s.exports=o:n.amdD&&n.amdO?void 0===(i=function(){return o}.call(e,n,e,s))||(s.exports=i):this.xor128=o}(0,t=n.nmd(t),n.amdD)},6833:function(t,e,n){var i;!function(t,s){function r(t){var e=this;e.next=function(){var t,n,i=e.w,s=e.X,r=e.i;return e.w=i=i+1640531527|0,n=s[r+34&127],t=s[r=r+1&127],n^=n<<13,t^=t<<17,n^=n>>>15,t^=t>>>12,n=s[r]=n^t,e.i=r,n+(i^i>>>16)|0},function(t,e){var n,i,s,r,a,o=[],l=128;for(e===(0|e)?(i=e,e=null):(e+="\0",i=0,l=Math.max(l,e.length)),s=0,r=-32;r>>15,i^=i<<4,i^=i>>>13,r>=0&&(a=a+1640531527|0,s=0==(n=o[127&r]^=i+a)?s+1:0);for(s>=128&&(o[127&(e&&e.length||0)]=-1),s=127,r=512;r>0;--r)i=o[s+34&127],n=o[s=s+1&127],i^=i<<13,n^=n<<17,i^=i>>>15,n^=n>>>12,o[s]=i^n;t.w=a,t.X=o,t.i=s}(e,t)}function a(t,e){return e.i=t.i,e.w=t.w,e.X=t.X.slice(),e}function o(t,e){null==t&&(t=+new Date);var n=new r(t),i=e&&e.state,s=function(){return(n.next()>>>0)/4294967296};return s.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},s.int32=n.next,s.quick=s,i&&(i.X&&a(i,n),s.state=function(){return a(n,{})}),s}s&&s.exports?s.exports=o:n.amdD&&n.amdO?void 0===(i=function(){return o}.call(e,n,e,s))||(s.exports=i):this.xor4096=o}(0,t=n.nmd(t),n.amdD)},9067:function(t,e,n){var i;!function(t,s){function r(t){var e=this;e.next=function(){var t,n,i=e.x,s=e.i;return t=i[s],n=(t^=t>>>7)^t<<24,n^=(t=i[s+1&7])^t>>>10,n^=(t=i[s+3&7])^t>>>3,n^=(t=i[s+4&7])^t<<7,t=i[s+7&7],n^=(t^=t<<13)^t<<9,i[s]=n,e.i=s+1&7,n},function(t,e){var n,i=[];if(e===(0|e))i[0]=e;else for(e=""+e,n=0;n0;--n)t.next()}(e,t)}function a(t,e){return e.x=t.x.slice(),e.i=t.i,e}function o(t,e){null==t&&(t=+new Date);var n=new r(t),i=e&&e.state,s=function(){return(n.next()>>>0)/4294967296};return s.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},s.int32=n.next,s.quick=s,i&&(i.x&&a(i,n),s.state=function(){return a(n,{})}),s}s&&s.exports?s.exports=o:n.amdD&&n.amdO?void 0===(i=function(){return o}.call(e,n,e,s))||(s.exports=i):this.xorshift7=o}(0,t=n.nmd(t),n.amdD)},3031:function(t,e,n){var i;!function(t,s){function r(t){var e=this,n="";e.next=function(){var t=e.x^e.x>>>2;return e.x=e.y,e.y=e.z,e.z=e.w,e.w=e.v,(e.d=e.d+362437|0)+(e.v=e.v^e.v<<4^t^t<<1)|0},e.x=0,e.y=0,e.z=0,e.w=0,e.v=0,t===(0|t)?e.x=t:n+=t;for(var i=0;i>>4),e.next()}function a(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e.v=t.v,e.d=t.d,e}function o(t,e){var n=new r(t),i=e&&e.state,s=function(){return(n.next()>>>0)/4294967296};return s.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},s.int32=n.next,s.quick=s,i&&("object"==typeof i&&a(i,n),s.state=function(){return a(n,{})}),s}s&&s.exports?s.exports=o:n.amdD&&n.amdO?void 0===(i=function(){return o}.call(e,n,e,s))||(s.exports=i):this.xorwow=o}(0,t=n.nmd(t),n.amdD)},4801:function(t,e,n){var i;!function(s,r,a){var o,l=256,u=a.pow(l,6),h=a.pow(2,52),p=2*h,c=l-1;function d(t,e,n){var i=[],c=_(g((e=1==e?{entropy:!0}:e||{}).entropy?[t,T(r)]:null==t?function(){try{var t;return o&&(t=o.randomBytes)?t=t(l):(t=new Uint8Array(l),(s.crypto||s.msCrypto).getRandomValues(t)),T(t)}catch(t){var e=s.navigator,n=e&&e.plugins;return[+new Date,s,n,s.screen,T(r)]}}():t,3),i),d=new f(i),y=function(){for(var t=d.g(6),e=u,n=0;t=p;)t/=2,e/=2,n>>>=1;return(t+n)/e};return y.int32=function(){return 0|d.g(4)},y.quick=function(){return d.g(4)/4294967296},y.double=y,_(T(d.S),r),(e.pass||n||function(t,e,n,i){return i&&(i.S&&m(i,d),t.state=function(){return m(d,{})}),n?(a.random=t,e):t})(y,c,"global"in e?e.global:this==a,e.state)}function f(t){var e,n=t.length,i=this,s=0,r=i.i=i.j=0,a=i.S=[];for(n||(t=[n++]);s{"use strict";t.exports=path},5817:()=>{},8590:()=>{},4530:()=>{},8108:()=>{},551:()=>{},7425:()=>{},9496:()=>{},6786:()=>{},8884:()=>{},8001:()=>{},1613:()=>{},5312:()=>{},9032:()=>{},574:()=>{},2672:()=>{},8215:()=>{},1417:()=>{},9391:()=>{},3220:()=>{},3985:()=>{},32:()=>{},5650:()=>{},6644:()=>{},1234:()=>{},1045:t=>{"use strict";t.exports={rE:"3.0.8"}}},__webpack_module_cache__={},leafPrototypes,getProto,inProgress,dataWebpackPrefix;function __webpack_require__(t){var e=__webpack_module_cache__[t];if(void 0!==e)return e.exports;var n=__webpack_module_cache__[t]={id:t,loaded:!1,exports:{}};return __webpack_modules__[t].call(n.exports,n,n.exports,__webpack_require__),n.loaded=!0,n.exports}__webpack_require__.m=__webpack_modules__,__webpack_require__.amdD=function(){throw new Error("define cannot be used indirect")},__webpack_require__.amdO={},__webpack_require__.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return __webpack_require__.d(e,{a:e}),e},getProto=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__,__webpack_require__.t=function(t,e){if(1&e&&(t=this(t)),8&e)return t;if("object"==typeof t&&t){if(4&e&&t.__esModule)return t;if(16&e&&"function"==typeof t.then)return t}var n=Object.create(null);__webpack_require__.r(n);var i={};leafPrototypes=leafPrototypes||[null,getProto({}),getProto([]),getProto(getProto)];for(var s=2&e&&t;"object"==typeof s&&!~leafPrototypes.indexOf(s);s=getProto(s))Object.getOwnPropertyNames(s).forEach((e=>i[e]=()=>t[e]));return i.default=()=>t,__webpack_require__.d(n,i),n},__webpack_require__.d=(t,e)=>{for(var n in e)__webpack_require__.o(e,n)&&!__webpack_require__.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},__webpack_require__.f={},__webpack_require__.e=t=>Promise.all(Object.keys(__webpack_require__.f).reduce(((e,n)=>(__webpack_require__.f[n](t,e),e)),[])),__webpack_require__.u=t=>t+".bundle."+{38:"8f8d27e0",97:"2c190343",195:"9cae47ea",211:"788652b1",317:"a52389ac",837:"202ac045",950:"f4a05602",960:"35ce71c3",974:"0d9230d6"}[t]+".js",__webpack_require__.miniCssF=t=>"styles/"+t+".45554be0.css",__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),__webpack_require__.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),inProgress={},dataWebpackPrefix="@mixly/python-pyodide:",__webpack_require__.l=(t,e,n,i)=>{if(inProgress[t])inProgress[t].push(e);else{var s,r;if(void 0!==n)for(var a=document.getElementsByTagName("script"),o=0;o{s.onerror=s.onload=null,clearTimeout(h);var i=inProgress[t];if(delete inProgress[t],s.parentNode&&s.parentNode.removeChild(s),i&&i.forEach((t=>t(n))),e)return e(n)},h=setTimeout(u.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=u.bind(null,s.onerror),s.onload=u.bind(null,s.onload),r&&document.head.appendChild(s)}},__webpack_require__.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},__webpack_require__.nmd=t=>(t.paths=[],t.children||(t.children=[]),t),(()=>{var t;__webpack_require__.g.importScripts&&(t=__webpack_require__.g.location+"");var e=__webpack_require__.g.document;if(!t&&e&&(e.currentScript&&(t=e.currentScript.src),!t)){var n=e.getElementsByTagName("script");if(n.length)for(var i=n.length-1;i>-1&&(!t||!/^http(s?):/.test(t));)t=n[i--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),__webpack_require__.p=t})(),(()=>{if("undefined"!=typeof document){var t=t=>new Promise(((e,n)=>{var i=__webpack_require__.miniCssF(t),s=__webpack_require__.p+i;if(((t,e)=>{for(var n=document.getElementsByTagName("link"),i=0;i{var r=document.createElement("link");r.rel="stylesheet",r.type="text/css",__webpack_require__.nc&&(r.nonce=__webpack_require__.nc),r.onerror=r.onload=n=>{if(r.onerror=r.onload=null,"load"===n.type)i();else{var a=n&&n.type,o=n&&n.target&&n.target.href||e,l=new Error("Loading CSS chunk "+t+" failed.\n("+a+": "+o+")");l.name="ChunkLoadError",l.code="CSS_CHUNK_LOAD_FAILED",l.type=a,l.request=o,r.parentNode&&r.parentNode.removeChild(r),s(l)}},r.href=e,n?n.parentNode.insertBefore(r,n.nextSibling):document.head.appendChild(r)})(t,s,null,e,n)})),e={792:0};__webpack_require__.f.miniCss=(n,i)=>{e[n]?i.push(e[n]):0!==e[n]&&{317:1}[n]&&i.push(e[n]=t(n).then((()=>{e[n]=0}),(t=>{throw delete e[n],t})))}}})(),(()=>{var t={792:0};__webpack_require__.f.j=(e,n)=>{var i=__webpack_require__.o(t,e)?t[e]:void 0;if(0!==i)if(i)n.push(i[2]);else{var s=new Promise(((n,s)=>i=t[e]=[n,s]));n.push(i[2]=s);var r=__webpack_require__.p+__webpack_require__.u(e),a=new Error;__webpack_require__.l(r,(n=>{if(__webpack_require__.o(t,e)&&(0!==(i=t[e])&&(t[e]=void 0),i)){var s=n&&("load"===n.type?"missing":n.type),r=n&&n.target&&n.target.src;a.message="Loading chunk "+e+" failed.\n("+s+": "+r+")",a.name="ChunkLoadError",a.type=s,a.request=r,i[1](a)}}),"chunk-"+e,e)}};var e=(e,n)=>{var i,s,[r,a,o]=n,l=0;if(r.some((e=>0!==t[e]))){for(i in a)__webpack_require__.o(a,i)&&(__webpack_require__.m[i]=a[i]);if(o)o(__webpack_require__)}for(e&&e(n);l{"use strict";var t={};__webpack_require__.r(t),__webpack_require__.d(t,{controls_type:()=>ue,controls_typeLists:()=>he,lists_zip:()=>pe,lists_zip_container:()=>ce,lists_zip_item:()=>de,unpack_iterable_object:()=>fe,variables_change:()=>oe,variables_get:()=>re,variables_global:()=>le,variables_set:()=>ae});var e={};__webpack_require__.r(e),__webpack_require__.d(e,{base_setup:()=>_e,controls_delay:()=>Te,controls_end_program:()=>ye,controls_except:()=>Ne,controls_finally:()=>ke,controls_flow_statements:()=>Se,controls_for:()=>xe,controls_forEach:()=>be,controls_for_range:()=>Re,controls_if:()=>Ie,controls_if_else:()=>Me,controls_if_elseif:()=>Oe,controls_if_if:()=>Ae,controls_lambda:()=>Le,controls_main:()=>ge,controls_pass:()=>Fe,controls_range:()=>Ee,controls_repeat_ext:()=>De,controls_thread:()=>Pe,controls_try:()=>Ce,controls_try_finally:()=>we,controls_whileUntil:()=>ve,datetime_fromtimestamp:()=>Ge,do_while:()=>$e,garbage_collection:()=>Be,gene_unique_identifier:()=>He,get_mem_alloc:()=>Ve,get_mem_free:()=>Ue,get_unique_identifier:()=>Ye});var n={};__webpack_require__.r(n),__webpack_require__.d(n,{base_map:()=>cn,generate_cartesian_product:()=>fn,math_arithmetic:()=>qe,math_bit:()=>Qe,math_constant:()=>Xe,math_constant_mp:()=>je,math_constrain:()=>rn,math_dec:()=>Ze,math_degree_to_radian:()=>gn,math_indexer_number:()=>on,math_map:()=>an,math_max_min:()=>en,math_number:()=>ze,math_number_base_conversion:()=>nn,math_radian_to_degree:()=>mn,math_random:()=>sn,math_random_seed:()=>ln,math_round:()=>un,math_selfcalcu:()=>Ke,math_to_int:()=>tn,math_trig:()=>Je,text_to_number:()=>hn,text_to_number_skulpt:()=>pn,turn_to_int:()=>dn});var i={};__webpack_require__.r(i),__webpack_require__.d(i,{ascii_to_char:()=>vn,char_to_ascii:()=>wn,number_to_text:()=>Sn,os_system:()=>Kn,text:()=>Tn,text_bytes:()=>In,text_capital:()=>Dn,text_center:()=>Ln,text_char:()=>En,text_char_at:()=>An,text_char_at2:()=>Rn,text_char_at3:()=>zn,text_compareTo:()=>Wn,text_compare_to:()=>kn,text_create_with_container:()=>Yn,text_create_with_item:()=>Gn,text_encode:()=>jn,text_equals_starts_ends:()=>Nn,text_eval:()=>qn,text_find:()=>Fn,text_format:()=>Un,text_format_noreturn:()=>Xn,text_join:()=>bn,text_join_seq:()=>Pn,text_length:()=>xn,text_random_char:()=>On,text_replace:()=>$n,text_split:()=>Bn,text_strip:()=>Vn,text_substring:()=>Cn,text_substring2:()=>Mn,text_substring3:()=>Hn,text_textarea:()=>yn});var s={};__webpack_require__.r(s),__webpack_require__.d(s,{ENUMERATE:()=>Ni,content_in_lists:()=>Di,enumerate:()=>ki,list_many_input:()=>yi,list_tolist:()=>vi,list_tolist2:()=>Ci,list_trig:()=>gi,lists_2d_get_col_row_data:()=>ei,lists_2d_get_data_with_col_row:()=>ti,lists_append_extend:()=>oi,lists_change_to:()=>Ti,lists_change_to_general:()=>Ei,lists_clear:()=>ci,lists_create_with:()=>ni,lists_create_with2:()=>wi,lists_create_with_container:()=>si,lists_create_with_item:()=>ri,lists_create_with_noreturn:()=>Ii,lists_create_with_text:()=>ii,lists_create_with_text2:()=>Si,lists_del_general:()=>bi,lists_find:()=>mi,lists_getIndex3:()=>xi,lists_getSublist3:()=>Ri,lists_get_index:()=>Jn,lists_get_random_item:()=>li,lists_get_random_sublist:()=>ui,lists_get_sublist:()=>Zn,lists_insert_value:()=>hi,lists_insert_value2:()=>Oi,lists_pop:()=>fi,lists_remove_at:()=>di,lists_remove_at2:()=>Mi,lists_reverse:()=>pi,lists_setIndex3:()=>Ai,lists_set_index:()=>ai,lists_sort:()=>_i});var r={};__webpack_require__.r(r),__webpack_require__.d(r,{dicts_add_change_del:()=>Ki,dicts_add_or_change:()=>Yi,dicts_clear:()=>Wi,dicts_create_with:()=>Fi,dicts_create_with_container:()=>Pi,dicts_create_with_item:()=>$i,dicts_create_with_noreturn:()=>Zi,dicts_deldict:()=>qi,dicts_delete:()=>Gi,dicts_get:()=>Vi,dicts_get_default:()=>Ui,dicts_items:()=>zi,dicts_keys:()=>Bi,dicts_length:()=>ji,dicts_pop:()=>Qi,dicts_setdefault:()=>Ji,dicts_to_json:()=>es,dicts_to_json2:()=>ss,dicts_to_to:()=>is,dicts_todict:()=>ts,dicts_update:()=>Hi,dicts_values:()=>Xi,json_to_dicts:()=>ns});var a={};__webpack_require__.r(a),__webpack_require__.d(a,{logic_boolean:()=>hs,logic_compare:()=>as,logic_compare_continous:()=>os,logic_is:()=>fs,logic_is_in:()=>ds,logic_negate:()=>us,logic_null:()=>ps,logic_operation:()=>ls,logic_tobool:()=>ms,logic_true_or_false:()=>cs});var o={};__webpack_require__.r(o),__webpack_require__.d(o,{sdcard_mount:()=>$s,sdcard_use_spi_init:()=>Ps,storage_can_write_ornot:()=>ws,storage_change_dir:()=>Ls,storage_close_file:()=>xs,storage_delete_file:()=>As,storage_file_seek:()=>Cs,storage_file_tell:()=>Ms,storage_file_write:()=>Is,storage_fileopen:()=>_s,storage_fileopen_new:()=>Ts,storage_fileopen_new_encoding:()=>ys,storage_get_a_line:()=>vs,storage_get_contents:()=>bs,storage_get_contents_without_para:()=>Es,storage_get_current_dir:()=>Ns,storage_get_file_size:()=>Os,storage_get_filename:()=>Ss,storage_is_file:()=>Fs,storage_list_all_files:()=>Rs,storage_make_dir:()=>ks,storage_open_file_with_os:()=>gs,storage_rename:()=>Ds});var l={};__webpack_require__.r(l),__webpack_require__.d(l,{procedures_callnoreturn:()=>Gs,procedures_callreturn:()=>Hs,procedures_defnoreturn:()=>Bs,procedures_defreturn:()=>Vs,procedures_ifreturn:()=>Ws,procedures_mutatorarg:()=>Ys,procedures_mutatorcontainer:()=>Us,procedures_return:()=>zs});var u={};__webpack_require__.r(u),__webpack_require__.d(u,{tuple_change_to:()=>sr,tuple_create_with:()=>js,tuple_create_with_container:()=>qs,tuple_create_with_item:()=>Ks,tuple_create_with_noreturn:()=>lr,tuple_create_with_text2:()=>Qs,tuple_create_with_text_return:()=>Js,tuple_del:()=>er,tuple_find:()=>rr,tuple_getIndex:()=>Zs,tuple_getSublist:()=>or,tuple_get_random_item:()=>hr,tuple_get_sublist:()=>ur,tuple_input:()=>cr,tuple_join:()=>nr,tuple_length:()=>tr,tuple_max:()=>ir,tuple_totuple:()=>pr,tuple_trig:()=>ar});var h={};__webpack_require__.r(h),__webpack_require__.d(h,{set_add_discard:()=>br,set_clear:()=>yr,set_create_with:()=>fr,set_create_with_container:()=>mr,set_create_with_item:()=>gr,set_create_with_text_return:()=>Sr,set_length:()=>_r,set_operate:()=>Ir,set_operate_update:()=>Er,set_pop:()=>Tr,set_sub:()=>vr,set_toset:()=>xr,set_update:()=>wr});var p={};__webpack_require__.r(p),__webpack_require__.d(p,{html_content:()=>Cr,html_content_more:()=>Nr,html_document:()=>Ar,html_form:()=>Dr,html_head_body:()=>Mr,html_style:()=>kr,html_style_color:()=>Fr,html_style_content:()=>Lr,html_text:()=>Pr,html_title:()=>Or});var c={};__webpack_require__.r(c),__webpack_require__.d(c,{attribute_access:()=>Qr,function_call:()=>jr,function_call_container:()=>qr,function_call_item:()=>Kr,raw_block:()=>Vr,raw_empty:()=>Yr,raw_expression:()=>Ur,raw_table:()=>Br,text_comment:()=>Gr,text_print_multiple:()=>Wr,text_print_multiple_container:()=>zr,text_print_multiple_item:()=>Xr,type_check:()=>Hr});var d={};__webpack_require__.r(d),__webpack_require__.d(d,{controls_type:()=>na,controls_typeLists:()=>ia,lists_zip:()=>sa,unpack_iterable_object:()=>ra,variables_change:()=>ta,variables_get:()=>Jr,variables_global:()=>ea,variables_set:()=>Zr});var f={};__webpack_require__.r(f),__webpack_require__.d(f,{Panic_with_status_code:()=>ma,base_setup:()=>oa,controls_delay:()=>fa,controls_flow_statements:()=>da,controls_for:()=>ha,controls_forEach:()=>Ia,controls_for_range:()=>pa,controls_if:()=>la,controls_interrupts:()=>Ta,controls_lambda:()=>ba,controls_main:()=>aa,controls_millis:()=>ga,controls_nointerrupts:()=>ya,controls_pass:()=>wa,controls_range:()=>Ea,controls_repeat:()=>Na,controls_repeat_ext:()=>Ra,controls_thread:()=>Sa,controls_try_finally:()=>ua,controls_whileUntil:()=>ca,datetime_fromtimestamp:()=>ka,do_while:()=>xa,garbage_collection:()=>Aa,gene_unique_identifier:()=>Da,get_mem_alloc:()=>Oa,get_mem_free:()=>Ma,get_unique_identifier:()=>Ca,reset:()=>_a,time_sleep:()=>va});var m={};__webpack_require__.r(m),__webpack_require__.d(m,{base_map:()=>eo,generate_cartesian_product:()=>io,math_arithmetic:()=>Ba,math_bit:()=>$a,math_constant:()=>Fa,math_constant_mp:()=>Pa,math_constrain:()=>ja,math_dec:()=>Ga,math_degree_to_radian:()=>ro,math_indexer_number:()=>Qa,math_map:()=>Xa,math_max_min:()=>Wa,math_number:()=>La,math_number_base_conversion:()=>qa,math_radian_to_degree:()=>so,math_random:()=>za,math_random_seed:()=>Ka,math_round:()=>Ja,math_selfcalcu:()=>Va,math_single:()=>Ua,math_to_int:()=>Ha,math_trig:()=>Ya,text_to_number:()=>Za,text_to_number_skulpt:()=>to,turn_to_int:()=>no});var g={};__webpack_require__.r(g),__webpack_require__.d(g,{ascii_to_char:()=>po,char_to_ascii:()=>co,number_to_text:()=>fo,os_system:()=>Po,text:()=>ao,text_bytes:()=>lo,text_capital:()=>vo,text_center:()=>wo,text_char:()=>uo,text_char_at:()=>_o,text_char_at2:()=>go,text_char_at3:()=>Do,text_compareTo:()=>ko,text_compare_to:()=>Io,text_encode:()=>Lo,text_equals_starts_ends:()=>yo,text_eval:()=>Fo,text_find:()=>So,text_format:()=>Mo,text_format_noreturn:()=>Co,text_join:()=>ho,text_join_seq:()=>xo,text_length:()=>mo,text_random_char:()=>To,text_replace:()=>Ro,text_split:()=>Ao,text_strip:()=>Oo,text_substring:()=>bo,text_substring2:()=>Eo,text_substring3:()=>No,text_textarea:()=>oo});var _={};__webpack_require__.r(_),__webpack_require__.d(_,{content_in_lists:()=>_l,enumerate:()=>gl,list_many_input:()=>il,list_tolist:()=>fl,list_tolist2:()=>ml,list_trig:()=>tl,lists_2d_get_col_row_data:()=>Vo,lists_2d_get_data_with_col_row:()=>Bo,lists_append_extend:()=>Wo,lists_change_to:()=>nl,lists_change_to_general:()=>rl,lists_clear:()=>Ko,lists_create_with:()=>Uo,lists_create_with2:()=>ol,lists_create_with_noreturn:()=>sl,lists_create_with_text:()=>Yo,lists_create_with_text2:()=>ll,lists_del_general:()=>al,lists_find:()=>Qo,lists_getIndex3:()=>ul,lists_getSublist3:()=>hl,lists_get_index:()=>Go,lists_get_random_item:()=>zo,lists_get_random_sublist:()=>Xo,lists_get_sublist:()=>$o,lists_insert_value:()=>jo,lists_insert_value2:()=>cl,lists_pop:()=>Zo,lists_remove_at:()=>Jo,lists_remove_at2:()=>dl,lists_reverse:()=>qo,lists_setIndex3:()=>pl,lists_set_index:()=>Ho,lists_sort:()=>el});var T={};__webpack_require__.r(T),__webpack_require__.d(T,{dicts_add_change_del:()=>Ml,dicts_add_or_change:()=>bl,dicts_clear:()=>Sl,dicts_create_with:()=>Tl,dicts_create_with_noreturn:()=>kl,dicts_deldict:()=>Ol,dicts_delete:()=>vl,dicts_get:()=>Il,dicts_get_default:()=>El,dicts_items:()=>xl,dicts_keys:()=>yl,dicts_length:()=>Al,dicts_pop:()=>Cl,dicts_setdefault:()=>Nl,dicts_to_json:()=>Ll,dicts_to_json2:()=>$l,dicts_to_to:()=>Pl,dicts_todict:()=>Dl,dicts_update:()=>wl,dicts_values:()=>Rl,json_to_dicts:()=>Fl});var y={};__webpack_require__.r(y),__webpack_require__.d(y,{logic_boolean:()=>Gl,logic_compare:()=>Bl,logic_compare_continous:()=>Vl,logic_is:()=>Xl,logic_is_in:()=>zl,logic_negate:()=>Yl,logic_null:()=>Hl,logic_operation:()=>Ul,logic_tobool:()=>jl,logic_true_or_false:()=>Wl});var I={};__webpack_require__.r(I),__webpack_require__.d(I,{sdcard_mount:()=>_u,sdcard_use_spi_init:()=>gu,storage_can_write_ornot:()=>iu,storage_change_dir:()=>pu,storage_close_file:()=>ru,storage_delete_file:()=>ou,storage_file_seek:()=>hu,storage_file_tell:()=>uu,storage_file_write:()=>Zl,storage_fileopen:()=>Kl,storage_fileopen_new:()=>Ql,storage_fileopen_new_encoding:()=>Jl,storage_get_a_line:()=>nu,storage_get_contents:()=>eu,storage_get_contents_without_para:()=>tu,storage_get_current_dir:()=>cu,storage_get_file_size:()=>lu,storage_get_filename:()=>su,storage_is_file:()=>mu,storage_list_all_files:()=>au,storage_make_dir:()=>du,storage_open_file_with_os:()=>ql,storage_rename:()=>fu});var E={};__webpack_require__.r(E),__webpack_require__.d(E,{procedures_callnoreturn:()=>Eu,procedures_callreturn:()=>Iu,procedures_defnoreturn:()=>yu,procedures_defreturn:()=>Tu,procedures_ifreturn:()=>bu,procedures_return:()=>vu});var b={};__webpack_require__.r(b),__webpack_require__.d(b,{tuple_change_to:()=>Nu,tuple_create_with:()=>wu,tuple_create_with_noreturn:()=>Fu,tuple_create_with_text2:()=>Su,tuple_create_with_text_return:()=>xu,tuple_del:()=>Ou,tuple_find:()=>ku,tuple_getIndex:()=>Ru,tuple_getSublist:()=>Lu,tuple_get_random_item:()=>$u,tuple_get_sublist:()=>Pu,tuple_input:()=>Vu,tuple_join:()=>Mu,tuple_length:()=>Au,tuple_max:()=>Cu,tuple_totuple:()=>Bu,tuple_trig:()=>Du});var v={};__webpack_require__.r(v),__webpack_require__.d(v,{set_add_discard:()=>Xu,set_clear:()=>Hu,set_create_with:()=>Uu,set_create_with_text_return:()=>Ku,set_length:()=>Yu,set_operate:()=>Wu,set_operate_update:()=>zu,set_pop:()=>Gu,set_sub:()=>ju,set_toset:()=>Qu,set_update:()=>qu});var w={};__webpack_require__.r(w),__webpack_require__.d(w,{html_content:()=>eh,html_content_more:()=>nh,html_document:()=>Ju,html_form:()=>sh,html_head_body:()=>th,html_style:()=>ih,html_style_content:()=>rh,html_text:()=>ah,html_title:()=>Zu});var S={};__webpack_require__.r(S),__webpack_require__.d(S,{attribute_access:()=>dh,function_call:()=>ch,raw_block:()=>oh,raw_empty:()=>uh,raw_expression:()=>lh,raw_table:()=>hh,type_check:()=>ph});var x={};__webpack_require__.r(x),__webpack_require__.d(x,{AI_ChooseAndGet:()=>Th,AI_Face_match:()=>wh,AI_ImageClassify:()=>bh,AI_ImageClassify_Func:()=>vh,AI_Nlp:()=>Rh,AI_Nlp_Func:()=>Oh,AI_Nlp_Func_sim:()=>Mh,AI_Nlp_Sim:()=>Ah,AI_Nlp_Topic:()=>Ch,AI_Nlp_newsSummary:()=>Nh,AI_Ocr:()=>Sh,AI_Ocr_Func:()=>xh,AI_Speech_asr:()=>Eh,AI_Speech_synthesis:()=>Ih,AI_audio:()=>kh,AI_client:()=>yh,AI_photo:()=>Dh,AI_result:()=>Lh});var R={};__webpack_require__.r(R),__webpack_require__.d(R,{algorithm_add_path:()=>Yh,algorithm_add_school:()=>$h,algorithm_all_books:()=>sp,algorithm_all_books_sequence:()=>rp,algorithm_book_scale:()=>_p,algorithm_check_feet:()=>Ap,algorithm_chick_calculate:()=>Rp,algorithm_color_seclet:()=>zp,algorithm_current_school:()=>jh,algorithm_del_path:()=>Gh,algorithm_delete_book:()=>dp,algorithm_delete_books:()=>fp,algorithm_delete_books2:()=>mp,algorithm_divide_books:()=>pp,algorithm_find_path:()=>Bh,algorithm_first_book:()=>ap,algorithm_fz_calc:()=>Np,algorithm_fz_calc_first_min:()=>kp,algorithm_fz_compare:()=>Dp,algorithm_fz_move:()=>Fp,algorithm_fz_set_min:()=>Lp,algorithm_get_book_num:()=>Ep,algorithm_get_current_location:()=>Hp,algorithm_get_half_books:()=>cp,algorithm_hxdb_add:()=>Up,algorithm_hxdb_init_soldier:()=>$p,algorithm_hxdb_last_line:()=>Vp,algorithm_hxdb_result:()=>Yp,algorithm_hxdb_stand_in_line:()=>Bp,algorithm_init_fzsf:()=>Cp,algorithm_init_hxdb:()=>Pp,algorithm_init_jttl:()=>wp,algorithm_move_recent:()=>Jh,algorithm_new_path:()=>Vh,algorithm_next_book:()=>up,algorithm_no_left:()=>Wh,algorithm_no_path:()=>qh,algorithm_no_ring2:()=>op,algorithm_not_home:()=>Zh,algorithm_not_school:()=>tp,algorithm_number_add:()=>yp,algorithm_number_zero:()=>Tp,algorithm_prepare:()=>Ph,algorithm_prepare2:()=>Xh,algorithm_prepare_2_1:()=>Kh,algorithm_prepare_2_2:()=>Qh,algorithm_print_book2:()=>gp,algorithm_print_divide:()=>vp,algorithm_print_jttl_answer:()=>Op,algorithm_print_number:()=>Ip,algorithm_print_path:()=>zh,algorithm_print_path2:()=>ep,algorithm_print_sequence:()=>bp,algorithm_rabbit_add:()=>Mp,algorithm_rabbit_number_in_range:()=>xp,algorithm_rabbit_zero:()=>Sp,algorithm_return_path:()=>Hh,algorithm_set_path:()=>Uh,algorithm_two_left:()=>hp,algorithm_void_path:()=>Wp,algorithm_yes_ring2:()=>lp,hanoi_init:()=>np,hanoi_init_offline:()=>Gp,hanoi_move:()=>ip});var A={};__webpack_require__.r(A),__webpack_require__.d(A,{requests_attribute:()=>Qp,requests_get:()=>qp,requests_get_old:()=>jp,requests_method:()=>Jp,requests_post:()=>Kp});var O={};__webpack_require__.r(O),__webpack_require__.d(O,{cv_destroy_all:()=>sc,cv_face_classifier:()=>oc,cv_face_detect:()=>lc,cv_face_detect_all:()=>uc,cv_line_rect:()=>rc,cv_read_image:()=>tc,cv_show_image:()=>ec,cv_text:()=>ac,cv_waitkey:()=>ic,cv_write_image:()=>nc});var M={};__webpack_require__.r(M),__webpack_require__.d(M,{array_create:()=>xc,array_toarray:()=>Vc,dataframe_aggregate_func:()=>Ld,dataframe_create:()=>dc,dataframe_create_from_index:()=>mc,dataframe_create_from_one_index:()=>fc,dataframe_fillna:()=>Ed,dataframe_get:()=>Pc,dataframe_groupby:()=>Dd,dataframe_head_tail:()=>Nd,dataframe_info:()=>bd,dataframe_median:()=>Id,dataframe_select:()=>kd,dataframe_sort_values:()=>Cd,matrix_multiplication:()=>Td,matrix_transpose:()=>_d,numpy_argmin_template_match:()=>ud,numpy_astype:()=>ad,numpy_c_:()=>md,numpy_dot:()=>xd,numpy_linalg_det:()=>gd,numpy_linalg_inv:()=>yd,numpy_max:()=>wd,numpy_mean:()=>hd,numpy_mean_digit:()=>ld,numpy_min:()=>vd,numpy_ones:()=>fd,numpy_random_random:()=>Od,numpy_reshape:()=>rd,numpy_shape:()=>sd,numpy_size:()=>Sd,numpy_square:()=>Rd,numpy_std:()=>pd,numpy_sum:()=>Ad,numpy_trig:()=>Dc,pandas_drop_columns:()=>dd,pandas_dropna:()=>cd,pandas_readcsv:()=>Fc,pl_axes:()=>bc,pl_bar:()=>Mc,pl_hist:()=>Nc,pl_label:()=>Sc,pl_legend:()=>vc,pl_pie:()=>Cc,pl_plot:()=>Ic,pl_plot_bar:()=>Rc,pl_plot_easy:()=>yc,pl_plot_scatter:()=>Ac,pl_plot_xy:()=>Oc,pl_savefig:()=>$c,pl_show:()=>Ec,pl_subplot:()=>Lc,pl_text:()=>Bc,pl_ticks:()=>kc,pl_title:()=>wc,plot_axes:()=>Hc,plot_bar:()=>Qc,plot_cla:()=>Fd,plot_hist:()=>Zc,plot_label:()=>Xc,plot_legend:()=>Wc,plot_pie:()=>Jc,plot_plot:()=>Yc,plot_plot_bar:()=>jc,plot_plot_easy:()=>Uc,plot_plot_scatter:()=>qc,plot_plot_xy:()=>Kc,plot_savefig:()=>nd,plot_show:()=>Gc,plot_subplot:()=>ed,plot_text:()=>id,plot_ticks:()=>td,plot_title:()=>zc,py_sum:()=>Md,pylab_imshow:()=>od,series_create:()=>pc,series_create_from_index:()=>cc,series_create_from_text:()=>gc,series_get_num:()=>Tc,series_index_value:()=>_c});var C={};__webpack_require__.r(C),__webpack_require__.d(C,{ds_add_node_by_attr:()=>Wd,ds_add_node_by_name:()=>Hd,ds_create_linkedlist:()=>$d,ds_create_linkedlist_container:()=>Bd,ds_create_linkedlist_item:()=>Vd,ds_create_node:()=>Ud,ds_del_node_by_attr:()=>Xd,ds_del_node_by_name:()=>zd,ds_get_node_attr:()=>Yd,ds_reverse_linkedlist:()=>jd,ds_set_node_attr:()=>Gd});var N={};__webpack_require__.r(N),__webpack_require__.d(N,{factory_block:()=>af,factory_block_return:()=>of,factory_block_return_with_textarea:()=>uf,factory_block_with_textarea:()=>lf,factory_callMethod_noreturn:()=>sf,factory_callMethod_return:()=>rf,factory_create_with_container:()=>Zd,factory_create_with_item:()=>tf,factory_declare:()=>nf,factory_from_import:()=>Kd,factory_function_noreturn:()=>Jd,factory_function_return:()=>ef,factory_import:()=>Qd});var k={};__webpack_require__.r(k),__webpack_require__.d(k,{hardware_arduino_analog_read:()=>gf,hardware_arduino_analog_write:()=>mf,hardware_arduino_digital_read:()=>ff,hardware_arduino_digital_write:()=>df,hardware_arduino_start:()=>pf,inout_highlow:()=>cf});var D={};__webpack_require__.r(D),__webpack_require__.d(D,{inout_input:()=>_f,inout_print:()=>Tf,inout_print_container:()=>wf,inout_print_end:()=>If,inout_print_inline:()=>yf,inout_print_item:()=>Sf,inout_print_many:()=>vf,inout_type_input:()=>Ef,pyinout_type_input:()=>bf});var L={};__webpack_require__.r(L),__webpack_require__.d(L,{IOT_EMQX_INIT_AND_CONNECT_BY_MIXLY_CODE:()=>qf,IOT_EMQX_INIT_AND_CONNECT_BY_SHARE_CODE:()=>jf,IOT_EMQX_PING:()=>zf,IOT_FORMATTING:()=>Hf,IOT_FORMAT_STRING:()=>Wf,IOT_MIXIO_NTP:()=>Xf,IOT_MIXIO_PUBLISH:()=>Ff,IOT_MIXIO_SUBSCRIBE:()=>Pf,IOT_MIXIO_UNSUBSCRIBE:()=>$f,iot_checkonenet:()=>rm,iot_client_onboard:()=>Jf,iot_create_with_item:()=>Df,iot_http_client:()=>Zf,iot_http_data:()=>tm,iot_mixio_check:()=>Uf,iot_mixio_connect:()=>Lf,iot_mixio_connect_only:()=>Vf,iot_mixio_disconnect:()=>Bf,iot_mixio_format_msg:()=>Gf,iot_mixio_format_topic:()=>Yf,iot_mixly_key:()=>Qf,iot_mixly_key_py:()=>Kf,iot_mqtt_client:()=>em,iot_mqtt_data:()=>nm,iot_onenet_check:()=>Of,iot_onenet_connect:()=>Rf,iot_onenet_disconnect:()=>Af,iot_onenet_publish:()=>Cf,iot_onenet_publish_dict:()=>Mf,iot_onenetconnect:()=>im,iot_onenetdisconnect:()=>sm,iot_publish:()=>am,iot_publish_container:()=>Nf,iot_publish_item:()=>kf});var F={};__webpack_require__.r(F),__webpack_require__.d(F,{pins_analog_read:()=>pm,pins_analog_write:()=>hm,pins_digital_read:()=>um,pins_digital_write:()=>lm});var P={};__webpack_require__.r(P),__webpack_require__.d(P,{serial_close:()=>mm,serial_open:()=>cm,serial_read_b:()=>fm,serial_write:()=>dm});var B={};__webpack_require__.r(B),__webpack_require__.d(B,{sklearn_DecisionTreeClassifier_Regressor:()=>xm,sklearn_GaussianNB:()=>Om,sklearn_KMeans:()=>Nm,sklearn_KMeans_fit:()=>km,sklearn_KNeighborsClassifier_Regressor:()=>Am,sklearn_LinearRegression:()=>wm,sklearn_RandomForestClassifier_Regressor:()=>Rm,sklearn_Ridge:()=>Sm,sklearn_cluster_centers_labels_inertia:()=>Vm,sklearn_coef_intercept:()=>Bm,sklearn_data_target:()=>Em,sklearn_fit:()=>Dm,sklearn_fit_no_target:()=>Lm,sklearn_load:()=>Im,sklearn_make_blobs:()=>ym,sklearn_make_classification:()=>_m,sklearn_make_regression:()=>Tm,sklearn_pca:()=>Mm,sklearn_pca_fit_transform:()=>Cm,sklearn_predict:()=>Fm,sklearn_save_load_model:()=>Um,sklearn_score:()=>Pm,sklearn_score_no_target:()=>$m,sklearn_train_test_split:()=>bm,sklearn_train_test_split_no_target:()=>vm});var V={};__webpack_require__.r(V),__webpack_require__.d(V,{Panic_with_status_code:()=>zm,base_delay:()=>Gm,controls_millis:()=>Hm,controls_mstimer2:()=>jm,controls_mstimer2_start:()=>qm,controls_mstimer2_stop:()=>Km,reset:()=>Xm,time_localtime:()=>Wm,time_sleep:()=>Qm});var U={};__webpack_require__.r(U),__webpack_require__.d(U,{turtle_bgcolor:()=>Tg,turtle_bgcolor_hex:()=>Rg,turtle_bgcolor_hex_new:()=>bg,turtle_circle:()=>mg,turtle_circle_advanced:()=>gg,turtle_clear:()=>ug,turtle_clone:()=>Eg,turtle_color:()=>Sg,turtle_color_hex:()=>xg,turtle_color_seclet:()=>Pg,turtle_create:()=>Zm,turtle_done:()=>tg,turtle_exitonclick:()=>eg,turtle_fill:()=>pg,turtle_fillcolor:()=>Ig,turtle_fillcolor_hex:()=>Og,turtle_fillcolor_hex_new:()=>wg,turtle_getscreen:()=>$g,turtle_goto:()=>ag,turtle_listen:()=>Yg,turtle_move:()=>ng,turtle_numinput:()=>Ng,turtle_onclick:()=>Vg,turtle_onkey:()=>Bg,turtle_ontimer:()=>Ug,turtle_pencolor:()=>yg,turtle_pencolor_hex:()=>Ag,turtle_pencolor_hex_new:()=>vg,turtle_penup:()=>hg,turtle_pos_shape:()=>lg,turtle_rotate:()=>ig,turtle_screen_delay:()=>rg,turtle_screen_savefig:()=>Gg,turtle_setheading:()=>sg,turtle_setxy:()=>og,turtle_shape:()=>Mg,turtle_shapesize:()=>Cg,turtle_size:()=>dg,turtle_size_speed:()=>cg,turtle_speed:()=>fg,turtle_textinput:()=>kg,turtle_visible:()=>_g,turtle_write:()=>Dg,turtle_write_format:()=>Lg,turtle_write_format_skulpt:()=>Fg});var Y={};__webpack_require__.r(Y),__webpack_require__.d(Y,{AI_ChooseAndGet:()=>Hg,AI_Face_match:()=>qg,AI_ImageClassify:()=>jg,AI_ImageClassify_Func:()=>e_,AI_Nlp:()=>Qg,AI_Nlp_Func:()=>i_,AI_Nlp_Func_sim:()=>s_,AI_Nlp_Sim:()=>Jg,AI_Nlp_Topic:()=>Zg,AI_Nlp_newsSummary:()=>t_,AI_Ocr:()=>Kg,AI_Ocr_Func:()=>n_,AI_Speech_asr:()=>Xg,AI_Speech_synthesis:()=>zg,AI_audio:()=>r_,AI_client:()=>Wg,AI_photo:()=>a_,AI_result:()=>o_});var G={};__webpack_require__.r(G),__webpack_require__.d(G,{algorithm_add_path:()=>d_,algorithm_add_school:()=>u_,algorithm_all_books:()=>M_,algorithm_all_books_sequence:()=>O_,algorithm_book_scale:()=>V_,algorithm_check_feet:()=>j_,algorithm_chick_calculate:()=>X_,algorithm_color_seclet:()=>pT,algorithm_current_school:()=>y_,algorithm_del_path:()=>f_,algorithm_delete_book:()=>$_,algorithm_divide_books:()=>F_,algorithm_find_path:()=>h_,algorithm_first_book:()=>C_,algorithm_fz_calc:()=>J_,algorithm_fz_compare:()=>Z_,algorithm_fz_move:()=>eT,algorithm_fz_set_min:()=>tT,algorithm_get_current_location:()=>uT,algorithm_get_half_books:()=>P_,algorithm_hxdb_add:()=>aT,algorithm_hxdb_init_soldier:()=>iT,algorithm_hxdb_last_line:()=>rT,algorithm_hxdb_result:()=>oT,algorithm_hxdb_stand_in_line:()=>sT,algorithm_init_fzsf:()=>Q_,algorithm_init_hxdb:()=>nT,algorithm_init_jttl:()=>H_,algorithm_move_recent:()=>v_,algorithm_new_path:()=>p_,algorithm_next_book:()=>D_,algorithm_no_left:()=>g_,algorithm_no_path:()=>I_,algorithm_no_ring2:()=>N_,algorithm_not_home:()=>w_,algorithm_not_school:()=>S_,algorithm_number_add:()=>Y_,algorithm_number_zero:()=>U_,algorithm_prepare:()=>l_,algorithm_prepare2:()=>T_,algorithm_prepare_2_1:()=>E_,algorithm_prepare_2_2:()=>b_,algorithm_print_book2:()=>B_,algorithm_print_jttl_answer:()=>q_,algorithm_print_number:()=>G_,algorithm_print_path:()=>__,algorithm_print_path2:()=>x_,algorithm_rabbit_add:()=>K_,algorithm_rabbit_number_in_range:()=>z_,algorithm_rabbit_zero:()=>W_,algorithm_return_path:()=>m_,algorithm_set_path:()=>c_,algorithm_two_left:()=>L_,algorithm_void_path:()=>hT,algorithm_yes_ring2:()=>k_,hanoi_init:()=>R_,hanoi_init_offline:()=>lT,hanoi_move:()=>A_});var H={};__webpack_require__.r(H),__webpack_require__.d(H,{requests_attribute:()=>mT,requests_get:()=>dT,requests_get_old:()=>cT,requests_method:()=>gT,requests_post:()=>fT});var W={};__webpack_require__.r(W),__webpack_require__.d(W,{array_create:()=>kT,array_toarray:()=>XT,dataframe_aggregate_func:()=>Yy,dataframe_create:()=>IT,dataframe_create_from_index:()=>ET,dataframe_create_from_one_index:()=>bT,dataframe_fillna:()=>Ay,dataframe_get:()=>HT,dataframe_groupby:()=>Uy,dataframe_head_tail:()=>By,dataframe_info:()=>Oy,dataframe_median:()=>Ry,dataframe_select:()=>Vy,dataframe_sort_values:()=>$y,matrix_multiplication:()=>Sy,matrix_transpose:()=>wy,numpy_argmin_template_match:()=>gy,numpy_astype:()=>dy,numpy_c_:()=>by,numpy_dot:()=>ky,numpy_linalg_det:()=>vy,numpy_linalg_inv:()=>xy,numpy_max:()=>Cy,numpy_mean:()=>_y,numpy_mean_digit:()=>my,numpy_min:()=>My,numpy_ones:()=>Ey,numpy_random_random:()=>Fy,numpy_reshape:()=>cy,numpy_shape:()=>py,numpy_size:()=>Ny,numpy_square:()=>Dy,numpy_std:()=>Ty,numpy_sum:()=>Ly,numpy_trig:()=>UT,pandas_drop_columns:()=>Iy,pandas_dropna:()=>yy,pandas_readcsv:()=>GT,pl_axes:()=>RT,pl_bar:()=>PT,pl_hist:()=>BT,pl_label:()=>NT,pl_legend:()=>MT,pl_pie:()=>$T,pl_plot:()=>OT,pl_plot_bar:()=>DT,pl_plot_easy:()=>AT,pl_plot_scatter:()=>LT,pl_plot_xy:()=>FT,pl_savefig:()=>WT,pl_show:()=>xT,pl_subplot:()=>YT,pl_text:()=>zT,pl_ticks:()=>VT,pl_title:()=>CT,plot_axes:()=>qT,plot_bar:()=>sy,plot_cla:()=>Gy,plot_hist:()=>ay,plot_label:()=>ty,plot_legend:()=>JT,plot_pie:()=>ry,plot_plot:()=>QT,plot_plot_bar:()=>ey,plot_plot_easy:()=>KT,plot_plot_scatter:()=>ny,plot_plot_xy:()=>iy,plot_savefig:()=>uy,plot_show:()=>jT,plot_subplot:()=>ly,plot_text:()=>hy,plot_ticks:()=>oy,plot_title:()=>ZT,py_sum:()=>Py,pylab_imshow:()=>fy,series_create:()=>TT,series_create_from_index:()=>yT,series_create_from_text:()=>vT,series_get_num:()=>ST,series_index_value:()=>wT});var z={};__webpack_require__.r(z),__webpack_require__.d(z,{ds_add_node_by_attr:()=>qy,ds_add_node_by_name:()=>jy,ds_create_linkedlist:()=>Hy,ds_create_node:()=>Wy,ds_del_node_by_attr:()=>Qy,ds_del_node_by_name:()=>Ky,ds_get_node_attr:()=>zy,ds_reverse_linkedlist:()=>Jy,ds_set_node_attr:()=>Xy});var X={};__webpack_require__.r(X),__webpack_require__.d(X,{factory_block:()=>aI,factory_block_return:()=>oI,factory_block_return_with_textarea:()=>uI,factory_block_with_textarea:()=>lI,factory_callMethod_noreturn:()=>sI,factory_callMethod_return:()=>rI,factory_declare:()=>iI,factory_from_import:()=>Zy,factory_function_noreturn:()=>eI,factory_function_return:()=>nI,factory_import:()=>tI});var j={};__webpack_require__.r(j),__webpack_require__.d(j,{hardware_arduino_analog_read:()=>fI,hardware_arduino_analog_write:()=>mI,hardware_arduino_digital_read:()=>dI,hardware_arduino_digital_write:()=>cI,hardware_arduino_start:()=>hI,inout_highlow:()=>pI});var q={};__webpack_require__.r(q),__webpack_require__.d(q,{inout_input:()=>gI,inout_print:()=>_I,inout_print_end:()=>yI,inout_print_inline:()=>TI,inout_print_many:()=>bI,inout_type_input:()=>II,pyinout_type_input:()=>EI});var K={};__webpack_require__.r(K),__webpack_require__.d(K,{IOT_EMQX_INIT_AND_CONNECT_BY_MIXLY_CODE:()=>DI,IOT_EMQX_INIT_AND_CONNECT_BY_SHARE_CODE:()=>PI,IOT_EMQX_PING:()=>$I,IOT_FORMATTING:()=>NI,IOT_FORMAT_STRING:()=>kI,IOT_MIXIO_NTP:()=>BI,IOT_MIXIO_PUBLISH:()=>wI,IOT_MIXIO_SUBSCRIBE:()=>SI,IOT_MIXIO_UNSUBSCRIBE:()=>xI,iot_mixio_check:()=>OI,iot_mixio_connect:()=>vI,iot_mixio_connect_only:()=>AI,iot_mixio_disconnect:()=>RI,iot_mixio_format_msg:()=>CI,iot_mixio_format_topic:()=>MI,iot_mixly_key:()=>LI,iot_mixly_key_py:()=>FI});var Q={};__webpack_require__.r(Q),__webpack_require__.d(Q,{pins_analog_read:()=>HI,pins_analog_write:()=>GI,pins_digital:()=>VI,pins_digital_read:()=>YI,pins_digital_write:()=>UI});var J={};__webpack_require__.r(J),__webpack_require__.d(J,{serial_close:()=>jI,serial_open:()=>WI,serial_read_b:()=>XI,serial_write:()=>zI});var Z={};__webpack_require__.r(Z),__webpack_require__.d(Z,{sklearn_DecisionTreeClassifier_Regressor:()=>sE,sklearn_GaussianNB:()=>oE,sklearn_KMeans:()=>hE,sklearn_KMeans_fit:()=>pE,sklearn_KNeighborsClassifier_Regressor:()=>aE,sklearn_LinearRegression:()=>nE,sklearn_RandomForestClassifier_Regressor:()=>rE,sklearn_Ridge:()=>iE,sklearn_cluster_centers_labels_inertia:()=>TE,sklearn_coef_intercept:()=>_E,sklearn_data_target:()=>ZI,sklearn_fit:()=>cE,sklearn_fit_no_target:()=>dE,sklearn_load:()=>JI,sklearn_make_blobs:()=>QI,sklearn_make_classification:()=>qI,sklearn_make_regression:()=>KI,sklearn_pca:()=>lE,sklearn_pca_fit_transform:()=>uE,sklearn_predict:()=>fE,sklearn_save_load_model:()=>yE,sklearn_score:()=>mE,sklearn_score_no_target:()=>gE,sklearn_train_test_split:()=>tE,sklearn_train_test_split_no_target:()=>eE});var tt={};__webpack_require__.r(tt),__webpack_require__.d(tt,{controls_end_program:()=>EE,controls_millis:()=>IE,time_localtime:()=>bE});var et={};__webpack_require__.r(et),__webpack_require__.d(et,{turtle_bgcolor:()=>YE,turtle_bgcolor_hex:()=>zE,turtle_bgcolor_hex_new:()=>qE,turtle_circle:()=>$E,turtle_circle_advanced:()=>VE,turtle_clear:()=>NE,turtle_clone:()=>WE,turtle_color:()=>ZE,turtle_color_hex:()=>JE,turtle_color_seclet:()=>ob,turtle_create:()=>vE,turtle_done:()=>wE,turtle_exitonclick:()=>SE,turtle_fill:()=>DE,turtle_fillcolor:()=>HE,turtle_fillcolor_hex:()=>jE,turtle_fillcolor_hex_new:()=>QE,turtle_getscreen:()=>lb,turtle_goto:()=>ME,turtle_listen:()=>cb,turtle_move:()=>xE,turtle_numinput:()=>ib,turtle_onclick:()=>hb,turtle_onkey:()=>ub,turtle_ontimer:()=>pb,turtle_pencolor:()=>GE,turtle_pencolor_hex:()=>XE,turtle_pencolor_hex_new:()=>KE,turtle_penup:()=>kE,turtle_pos_shape:()=>CE,turtle_rotate:()=>RE,turtle_screen_delay:()=>OE,turtle_screen_savefig:()=>db,turtle_setheading:()=>AE,turtle_setxy:()=>BE,turtle_shape:()=>tb,turtle_shapesize:()=>eb,turtle_size:()=>FE,turtle_size_speed:()=>LE,turtle_speed:()=>PE,turtle_textinput:()=>nb,turtle_visible:()=>UE,turtle_write:()=>sb,turtle_write_format:()=>rb,turtle_write_format_skulpt:()=>ab});var nt={};__webpack_require__.r(nt),__webpack_require__.d(nt,{COPYFILE_EXCL:()=>Jb,COPYFILE_FICLONE:()=>Zb,COPYFILE_FICLONE_FORCE:()=>tv,F_OK:()=>jb,O_APPEND:()=>lv,O_CREAT:()=>sv,O_DIRECT:()=>mv,O_DIRECTORY:()=>uv,O_DSYNC:()=>dv,O_EXCL:()=>rv,O_NOATIME:()=>hv,O_NOCTTY:()=>av,O_NOFOLLOW:()=>pv,O_NONBLOCK:()=>gv,O_RDONLY:()=>ev,O_RDWR:()=>iv,O_SYMLINK:()=>fv,O_SYNC:()=>cv,O_TRUNC:()=>ov,O_WRONLY:()=>nv,R_OK:()=>qb,S_IFBLK:()=>Ev,S_IFCHR:()=>vv,S_IFDIR:()=>bv,S_IFIFO:()=>wv,S_IFLNK:()=>yv,S_IFMT:()=>_v,S_IFREG:()=>Iv,S_IFSOCK:()=>Tv,S_IRGRP:()=>kv,S_IROTH:()=>Pv,S_IRUSR:()=>Ov,S_IRWXG:()=>Nv,S_IRWXO:()=>Fv,S_IRWXU:()=>Av,S_ISGID:()=>xv,S_ISUID:()=>Sv,S_ISVTX:()=>Rv,S_IWGRP:()=>Dv,S_IWOTH:()=>$v,S_IWUSR:()=>Mv,S_IXGRP:()=>Lv,S_IXOTH:()=>Bv,S_IXUSR:()=>Cv,UV_FS_O_FILEMAP:()=>Vv,W_OK:()=>Kb,X_OK:()=>Qb,size_max:()=>Uv});var it={};__webpack_require__.r(it),__webpack_require__.d(it,{FileHandle:()=>lx,access:()=>Dx,appendFile:()=>yx,chmod:()=>Ax,chown:()=>xx,constants:()=>nt,copyFile:()=>Px,cp:()=>Bx,exists:()=>hx,lchmod:()=>Ox,lchown:()=>Rx,link:()=>vx,lstat:()=>cx,lutimes:()=>Cx,mkdir:()=>Ex,mkdtemp:()=>Fx,open:()=>gx,opendir:()=>$x,readFile:()=>_x,readdir:()=>bx,readlink:()=>Sx,realpath:()=>Nx,rename:()=>ux,rm:()=>Lx,rmdir:()=>Ix,stat:()=>px,statfs:()=>Vx,symlink:()=>wx,truncate:()=>dx,unlink:()=>fx,utimes:()=>Mx,watch:()=>kx,writeFile:()=>Tx});var st={};__webpack_require__.r(st),__webpack_require__.d(st,{BigIntStatsFs:()=>jv,Dir:()=>nx,Dirent:()=>ex,ReadStream:()=>sx,Stats:()=>Wv,StatsFs:()=>Xv,WriteStream:()=>rx,_synced:()=>Qw,access:()=>ER,accessSync:()=>zS,appendFile:()=>Qx,appendFileSync:()=>bS,chmod:()=>gR,chmodSync:()=>US,chown:()=>fR,chownSync:()=>BS,chroot:()=>nS,close:()=>Zx,closeSync:()=>wS,constants:()=>nt,copyFile:()=>MR,copyFileSync:()=>qS,cp:()=>DR,cpSync:()=>ZS,createReadStream:()=>xR,createWriteStream:()=>RR,exists:()=>Gx,existsSync:()=>pS,fchmod:()=>aR,fchmodSync:()=>CS,fchown:()=>rR,fchownSync:()=>MS,fdatasync:()=>nR,fdatasyncSync:()=>RS,fstat:()=>Jx,fstatSync:()=>vS,fsync:()=>eR,fsyncSync:()=>xS,ftruncate:()=>tR,ftruncateSync:()=>SS,futimes:()=>oR,futimesSync:()=>NS,lchmod:()=>_R,lchmodSync:()=>YS,lchown:()=>mR,lchownSync:()=>VS,link:()=>pR,linkSync:()=>FS,lopenSync:()=>TS,lstat:()=>Wx,lstatSync:()=>dS,lutimes:()=>yR,lutimesSync:()=>HS,mkdir:()=>uR,mkdirSync:()=>DS,mkdtemp:()=>OR,mkdtempSync:()=>jS,mount:()=>jw,mountObject:()=>tS,mounts:()=>Xw,open:()=>jx,openAsBlob:()=>FR,openSync:()=>_S,opendir:()=>kR,opendirSync:()=>JS,promises:()=>it,read:()=>sR,readFile:()=>qx,readFileSync:()=>IS,readSync:()=>OS,readdir:()=>hR,readdirSync:()=>LS,readlink:()=>dR,readlinkSync:()=>$S,readv:()=>CR,readvSync:()=>KS,realpath:()=>IR,realpathSync:()=>WS,rename:()=>Yx,renameSync:()=>hS,rm:()=>AR,rmSync:()=>XS,rmdir:()=>lR,rmdirSync:()=>kS,stat:()=>Hx,statSync:()=>cS,statfs:()=>LR,statfsSync:()=>tx,symlink:()=>cR,symlinkSync:()=>PS,truncate:()=>zx,truncateSync:()=>fS,umount:()=>qw,unlink:()=>Xx,unlinkSync:()=>mS,unwatchFile:()=>wR,utimes:()=>TR,utimesSync:()=>GS,watch:()=>SR,watchFile:()=>vR,write:()=>iR,writeFile:()=>Kx,writeFileSync:()=>ES,writeSync:()=>AS,writev:()=>NR,writevSync:()=>QS});var rt={};__webpack_require__.r(rt),__webpack_require__.d(rt,{arraysEqual:()=>SA,arraysEqualWithNull:()=>wA,assert:()=>yA,assertNonNegativeIntegerDimensions:()=>eO,assertNonNull:()=>EA,assertShapesMatch:()=>IA,bytesFromStringArray:()=>UA,bytesPerElement:()=>VA,checkConversionForErrors:()=>PA,clamp:()=>dA,computeStrides:()=>jA,convertBackendValuesAndArrayBuffer:()=>QA,createScalarValue:()=>rk,createShuffledIndices:()=>OA,decodeString:()=>hk,distSquared:()=>TA,encodeString:()=>uk,fetch:()=>lk,fingerPrint64:()=>sk,flatten:()=>ck,getArrayFromDType:()=>FA,getTypedArrayFromDType:()=>LA,hasEncodingLoss:()=>BA,hexToLong:()=>XN,indexToLoc:()=>iO,inferDtype:()=>WA,inferFromImplicitShape:()=>NA,isBoolean:()=>GA,isFunction:()=>zA,isInt:()=>xA,isNumber:()=>HA,isPromise:()=>sO,isScalarShape:()=>vA,isString:()=>YA,isTypedArray:()=>pk,isValidDtype:()=>$A,locToIndex:()=>nO,makeOnesTypedArray:()=>JA,makeZerosNestedTypedArray:()=>tO,makeZerosTypedArray:()=>ZA,nearestDivisor:()=>XA,nearestLargerEven:()=>fA,now:()=>ok,parseAxisParam:()=>kA,randUniform:()=>_A,repeatedTry:()=>CA,rightPad:()=>MA,shuffle:()=>pA,shuffleCombo:()=>cA,sizeFromShape:()=>bA,sizeToSquarishShape:()=>AA,squeezeShape:()=>DA,sum:()=>gA,swap:()=>mA,tanh:()=>RA,toNestedArray:()=>KA,toTypedArray:()=>ak});var at={};__webpack_require__.r(at),__webpack_require__.d(at,{assertTypesMatch:()=>Yk,getTensorsInContainer:()=>Hk,isTensorInList:()=>Gk,makeTypesMatch:()=>Uk});var ot={};__webpack_require__.r(ot),__webpack_require__.d(ot,{isBrowser:()=>eD,isMobile:()=>tD,mockIsMobile:()=>Zk});var lt={};__webpack_require__.r(lt),__webpack_require__.d(lt,{Serializable:()=>rF,SerializationMap:()=>aF,getRegisteredName:()=>lF,registerClass:()=>oF});var ut={};__webpack_require__.r(ut),__webpack_require__.d(ut,{assertAndGetBroadcastShape:()=>yF,getBroadcastDims:()=>_F,getReductionAxes:()=>TF});var ht={};__webpack_require__.r(ht),__webpack_require__.d(ht,{CompositeArrayBuffer:()=>fD,browserFiles:()=>OF,browserHTTPRequest:()=>$F,concatenateArrayBuffers:()=>XD,copyModel:()=>NL,decodeWeights:()=>$D,decodeWeightsStream:()=>GD,encodeWeights:()=>PD,fromMemory:()=>YF,fromMemorySync:()=>GF,getLoadHandlers:()=>sL,getModelArtifactsForJSON:()=>QD,getModelArtifactsForJSONSync:()=>KD,getModelArtifactsInfoForJSON:()=>JD,getSaveHandlers:()=>iL,getWeightSpecs:()=>ZD,http:()=>PF,isHTTPScheme:()=>LF,listModels:()=>ML,loadWeights:()=>NF,moveModel:()=>kL,registerLoadRouter:()=>nL,registerSaveRouter:()=>eL,removeModel:()=>CL,weightsLoaderFactory:()=>kF,withSaveHandler:()=>HF,withSaveHandlerSync:()=>WF});var pt={};__webpack_require__.r(pt),__webpack_require__.d(pt,{confusionMatrix:()=>JF});var ct={};__webpack_require__.r(ct),__webpack_require__.d(ct,{draw:()=>oP,fromPixels:()=>lP,fromPixelsAsync:()=>sP,toPixels:()=>aP});var dt={};__webpack_require__.r(dt),__webpack_require__.d(dt,{prepareAndValidate:()=>uP});var ft={};__webpack_require__.r(ft),__webpack_require__.d(ft,{calculateShapes:()=>cP,validateInput:()=>pP,validateUpdateShape:()=>hP});var mt={};__webpack_require__.r(mt),__webpack_require__.d(mt,{assertParamsValid:()=>mP,computeFlatOffset:()=>AP,computeOutShape:()=>_P,getNormalizedAxes:()=>EP,isSliceContinous:()=>RP,maskToAxes:()=>gP,parseSliceParams:()=>OP,sliceInfo:()=>MP,startForAxis:()=>SP,startIndicesWithElidedDims:()=>bP,stopForAxis:()=>xP,stopIndicesWithElidedDims:()=>vP,stridesForAxis:()=>wP,stridesWithElidedDims:()=>TP});var gt={};__webpack_require__.r(gt),__webpack_require__.d(gt,{TEST_EPSILON_FLOAT16:()=>kP,createVideoElement:()=>HP,encodeStrings:()=>GP,expectArrayBuffersEqual:()=>YP,expectArraysClose:()=>DP,expectArraysEqual:()=>$P,expectNumbersClose:()=>BP,expectPromiseToFail:()=>PP,expectValuesInRange:()=>UP,play:()=>WP,testEpsilon:()=>LP});var _t={};__webpack_require__.r(_t),__webpack_require__.d(_t,{conv2d:()=>KU,depthwiseConv2d:()=>ZU,matMul:()=>tY});var Tt={};__webpack_require__.r(Tt),__webpack_require__.d(Tt,{collectGatherOpShapeInfo:()=>hH,computeOutShape:()=>uH,segOpComputeOptimalWindowSize:()=>lH});var yt={};__webpack_require__.r(yt),__webpack_require__.d(yt,{ERF_A1:()=>xG,ERF_A2:()=>RG,ERF_A3:()=>AG,ERF_A4:()=>OG,ERF_A5:()=>MG,ERF_P:()=>SG,PARALLELIZE_THRESHOLD:()=>mG,RowPartitionType:()=>hG,SELU_SCALE:()=>wG,SELU_SCALEALPHA:()=>vG,applyActivation:()=>jU,assertAndGetBroadcastShape:()=>yF,assertAxesAreInnerMostDims:()=>TB,assertParamsConsistent:()=>lG,assignToTypedArray:()=>FG,axesAreInnerMostDims:()=>fB,calculateShapes:()=>cP,checkEinsumDimSizes:()=>WG,checkPadOnDimRoundingMode:()=>I$,combineLocations:()=>mB,combineRaggedTensorToTensorShapes:()=>pG,complexWithEvenIndex:()=>kG,complexWithOddIndex:()=>DG,computeConv2DInfo:()=>u$,computeConv3DInfo:()=>h$,computeDefaultPad:()=>p$,computeDilation2DInfo:()=>a$,computeOptimalWindowSize:()=>gG,computeOutAndReduceShapes:()=>gB,computeOutShape:()=>uG,computePool2DInfo:()=>o$,computePool3DInfo:()=>l$,convertConv2DDataFormat:()=>y$,decodeEinsumEquation:()=>GG,eitherStridesOrDilationsAreOne:()=>_$,expandShapeToKeepDim:()=>_B,exponent:()=>$G,exponents:()=>PG,fromStringArrayToUint8:()=>cH,fromUint8ToStringArray:()=>pH,getAxesPermutation:()=>yB,getBroadcastDims:()=>_F,getComplexWithIndex:()=>LG,getEinsumComputePath:()=>zG,getEinsumPermutation:()=>HG,getFusedBiasGradient:()=>XU,getFusedDyActivation:()=>zU,getImageCenter:()=>_G,getInnerMostAxes:()=>EB,getPermuted:()=>yG,getRaggedRank:()=>dG,getReductionAxes:()=>TF,getReshaped:()=>TG,getReshapedPermuted:()=>IG,getRowPartitionTypesHelper:()=>cG,getSliceBeginCoords:()=>EG,getSliceSize:()=>bG,getSparseFillEmptyRowsIndicesDenseShapeMismatch:()=>KG,getSparseFillEmptyRowsNegativeIndexErrorMessage:()=>QG,getSparseFillEmptyRowsOutOfRangeIndexErrorMessage:()=>JG,getSparseReshapeEmptyTensorZeroOutputDimErrorMessage:()=>eH,getSparseReshapeInputOutputMismatchErrorMessage:()=>iH,getSparseReshapeInputOutputMultipleErrorMessage:()=>nH,getSparseReshapeMultipleNegativeOneOutputDimErrorMessage:()=>ZG,getSparseReshapeNegativeOutputDimErrorMessage:()=>tH,getSparseSegmentReductionIndicesOutOfRangeErrorMessage:()=>oH,getSparseSegmentReductionNegativeSegmentIdsErrorMessage:()=>sH,getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage:()=>rH,getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage:()=>aH,getUndoAxesPermutation:()=>IB,isIdentityPermutation:()=>XG,log:()=>NN,mergeRealAndImagArrays:()=>CG,prepareAndValidate:()=>uP,prepareSplitSize:()=>qG,segment_util:()=>Tt,shouldFuse:()=>qU,slice_util:()=>mt,splitRealAndImagArrays:()=>NG,stridesOrDilationsArePositive:()=>T$,tupleValuesAreOne:()=>g$,upcastType:()=>Pk,validateDefaultValueShape:()=>fG,validateInput:()=>pP,validateUpdateShape:()=>hP,warn:()=>CN});var It={};__webpack_require__.r(It),__webpack_require__.d(It,{nonMaxSuppressionV3Impl:()=>fY,nonMaxSuppressionV4Impl:()=>mY,nonMaxSuppressionV5Impl:()=>gY,whereImpl:()=>DU});var Et={};__webpack_require__.r(Et),__webpack_require__.d(Et,{maxNorm:()=>WX,minMaxNorm:()=>jX,nonNeg:()=>XX,unitNorm:()=>zX});var bt={};__webpack_require__.r(bt),__webpack_require__.d(bt,{constant:()=>QX,glorotNormal:()=>sj,glorotUniform:()=>ij,heNormal:()=>rj,heUniform:()=>aj,identity:()=>ej,leCunNormal:()=>oj,leCunUniform:()=>lj,ones:()=>KX,orthogonal:()=>uj,randomNormal:()=>ZX,randomUniform:()=>JX,truncatedNormal:()=>tj,varianceScaling:()=>nj,zeros:()=>qX});var vt={};__webpack_require__.r(vt),__webpack_require__.d(vt,{Layer:()=>wX,RNN:()=>NK,RNNCell:()=>kK,activation:()=>cJ,add:()=>EJ,alphaDropout:()=>pZ,average:()=>bJ,averagePooling1d:()=>CJ,averagePooling2d:()=>DJ,averagePooling3d:()=>PJ,avgPool1d:()=>NJ,avgPool2d:()=>LJ,avgPool3d:()=>$J,avgPooling1d:()=>kJ,avgPooling2d:()=>FJ,avgPooling3d:()=>BJ,batchNormalization:()=>AJ,bidirectional:()=>iZ,categoryEncoding:()=>gZ,centerCrop:()=>fZ,concatenate:()=>vJ,conv1d:()=>iJ,conv2d:()=>sJ,conv2dTranspose:()=>rJ,conv3d:()=>aJ,conv3dTranspose:()=>oJ,convLstm2d:()=>ZJ,convLstm2dCell:()=>tZ,cropping2D:()=>uJ,dense:()=>dJ,depthwiseConv2d:()=>pJ,dot:()=>RJ,dropout:()=>fJ,elu:()=>QQ,embedding:()=>IJ,flatten:()=>gJ,gaussianDropout:()=>hZ,gaussianNoise:()=>uZ,globalAveragePooling1d:()=>VJ,globalAveragePooling2d:()=>UJ,globalMaxPool1d:()=>rZ,globalMaxPool2d:()=>aZ,globalMaxPooling1d:()=>YJ,globalMaxPooling2d:()=>GJ,gru:()=>XJ,gruCell:()=>jJ,input:()=>Oq,inputLayer:()=>KQ,layerNormalization:()=>OJ,leakyReLU:()=>ZQ,lstm:()=>qJ,lstmCell:()=>KJ,masking:()=>cZ,maxPool1d:()=>oZ,maxPool2d:()=>lZ,maxPooling1d:()=>HJ,maxPooling2d:()=>WJ,maxPooling3d:()=>zJ,maximum:()=>wJ,minimum:()=>SJ,multiply:()=>xJ,permute:()=>yJ,prelu:()=>tJ,randomWidth:()=>_Z,reLU:()=>JQ,repeatVector:()=>_J,rescaling:()=>dZ,reshape:()=>TJ,resizing:()=>mZ,rnn:()=>eZ,separableConv2d:()=>lJ,simpleRNN:()=>QJ,simpleRNNCell:()=>JJ,softmax:()=>eJ,spatialDropout1d:()=>mJ,stackedRNNCells:()=>nZ,thresholdedReLU:()=>nJ,timeDistributed:()=>sZ,upSampling2d:()=>hJ,zeroPadding2d:()=>MJ});var wt={};__webpack_require__.r(wt),__webpack_require__.d(wt,{MAPE:()=>AZ,MSE:()=>CZ,binaryAccuracy:()=>TZ,binaryCrossentropy:()=>yZ,categoricalAccuracy:()=>EZ,categoricalCrossentropy:()=>bZ,cosineProximity:()=>SZ,mape:()=>OZ,meanAbsoluteError:()=>xZ,meanAbsolutePercentageError:()=>RZ,meanSquaredError:()=>MZ,mse:()=>NZ,precision:()=>vZ,r2Score:()=>kZ,recall:()=>wZ,sparseCategoricalAccuracy:()=>IZ});var St={};__webpack_require__.r(St),__webpack_require__.d(St,{modelFromJSON:()=>wq});var xt={};__webpack_require__.r(xt),__webpack_require__.d(xt,{l1:()=>LZ,l1l2:()=>DZ,l2:()=>FZ});var Rt={};__webpack_require__.r(Rt),__webpack_require__.d(Rt,{json:()=>n0});var At={};__webpack_require__.r(At),__webpack_require__.d(At,{json:()=>i0});var Ot={};__webpack_require__.r(Ot),__webpack_require__.d(Ot,{json:()=>s0});var Mt={};__webpack_require__.r(Mt),__webpack_require__.d(Mt,{json:()=>r0});var Ct={};__webpack_require__.r(Ct),__webpack_require__.d(Ct,{json:()=>a0});var Nt={};__webpack_require__.r(Nt),__webpack_require__.d(Nt,{json:()=>o0});var kt={};__webpack_require__.r(kt),__webpack_require__.d(kt,{json:()=>l0});var Dt={};__webpack_require__.r(Dt),__webpack_require__.d(Dt,{json:()=>u0});var Lt={};__webpack_require__.r(Lt),__webpack_require__.d(Lt,{json:()=>h0});var Ft={};__webpack_require__.r(Ft),__webpack_require__.d(Ft,{json:()=>p0});var Pt={};__webpack_require__.r(Pt),__webpack_require__.d(Pt,{json:()=>c0});var $t={};__webpack_require__.r($t),__webpack_require__.d($t,{json:()=>d0});var Bt={};__webpack_require__.r(Bt),__webpack_require__.d(Bt,{json:()=>f0});var Vt={};__webpack_require__.r(Vt),__webpack_require__.d(Vt,{json:()=>m0});var Ut={};__webpack_require__.r(Ut),__webpack_require__.d(Ut,{json:()=>g0});var Yt={};__webpack_require__.r(Yt),__webpack_require__.d(Yt,{json:()=>_0});var Gt={};__webpack_require__.r(Gt),__webpack_require__.d(Gt,{json:()=>T0});var Ht={};__webpack_require__.r(Ht),__webpack_require__.d(Ht,{json:()=>y0});var Wt={};__webpack_require__.r(Wt),__webpack_require__.d(Wt,{json:()=>I0});var zt={};__webpack_require__.r(zt),__webpack_require__.d(zt,{OP_SCOPE_SUFFIX:()=>lD,abs:()=>gF,acos:()=>jP,acosh:()=>qP,add:()=>YL,addN:()=>KP,all:()=>QP,any:()=>JP,argMax:()=>ZP,argMin:()=>t$,asin:()=>e$,asinh:()=>n$,atan:()=>i$,atan2:()=>s$,atanh:()=>r$,avgPool:()=>b$,avgPool3d:()=>v$,basicLSTMCell:()=>A$,batchNorm:()=>M$,batchNorm2d:()=>C$,batchNorm3d:()=>N$,batchNorm4d:()=>k$,batchToSpaceND:()=>O$,bincount:()=>D$,bitwiseAnd:()=>L$,booleanMaskAsync:()=>FU,broadcastArgs:()=>F$,broadcastTo:()=>P$,buffer:()=>$L,cast:()=>BL,ceil:()=>$$,clipByValue:()=>B$,clone:()=>VL,complex:()=>hD,concat:()=>w$,concat1d:()=>V$,concat2d:()=>U$,concat3d:()=>Y$,concat4d:()=>G$,conv1d:()=>W$,conv2d:()=>H$,conv2dTranspose:()=>X$,conv3d:()=>j$,conv3dTranspose:()=>K$,cos:()=>Q$,cosh:()=>J$,cosineWindow:()=>GU,cumprod:()=>Z$,cumsum:()=>tB,denseBincount:()=>eB,depthToSpace:()=>nB,depthwiseConv2d:()=>iB,diag:()=>sB,dilation2d:()=>rB,div:()=>HL,divNoNan:()=>lB,dot:()=>uB,dropout:()=>UU,einsum:()=>hB,elu:()=>pB,enclosingPowerOfTwo:()=>YU,ensureShape:()=>cB,equal:()=>aB,erf:()=>dB,euclideanNorm:()=>RB,exp:()=>AB,expandDims:()=>OB,expm1:()=>MB,eye:()=>NB,fft:()=>hU,fill:()=>pF,floor:()=>kB,floorDiv:()=>GL,fused:()=>_t,gather:()=>DB,gatherND:()=>VU,greater:()=>LB,greaterEqual:()=>FB,ifft:()=>pU,imag:()=>jF,image:()=>tG,inTopKAsync:()=>HU,irfft:()=>cU,isFinite:()=>PB,isInf:()=>$B,isNaN:()=>BB,leakyRelu:()=>VB,less:()=>UB,lessEqual:()=>YB,linalg:()=>eG,linspace:()=>GB,localResponseNormalization:()=>HB,log:()=>WB,log1p:()=>zB,logSigmoid:()=>jB,logSoftmax:()=>qB,logSumExp:()=>KB,logicalAnd:()=>QB,logicalNot:()=>JB,logicalOr:()=>ZB,logicalXor:()=>tV,losses:()=>nG,lowerBound:()=>iV,matMul:()=>zF,max:()=>bB,maxPool:()=>sV,maxPool3d:()=>rV,maxPoolWithArgmax:()=>aV,maximum:()=>IF,mean:()=>oV,meshgrid:()=>hV,min:()=>vB,minimum:()=>pV,mirrorPad:()=>cV,mod:()=>dV,moments:()=>fV,movingAverage:()=>PU,mul:()=>WL,multiRNNCell:()=>mV,multinomial:()=>gV,neg:()=>qF,norm:()=>xB,notEqual:()=>_V,oneHot:()=>XF,ones:()=>uV,onesLike:()=>TV,op:()=>uD,outerProduct:()=>yV,pad:()=>IV,pad1d:()=>EV,pad2d:()=>bV,pad3d:()=>vV,pad4d:()=>wV,pool:()=>xV,pow:()=>dF,prelu:()=>RV,print:()=>UL,prod:()=>AV,raggedGather:()=>OV,raggedRange:()=>MV,raggedTensorToTensor:()=>CV,rand:()=>NV,randomGamma:()=>PV,randomNormal:()=>$V,randomStandardNormal:()=>BV,randomUniform:()=>VV,randomUniformInt:()=>UV,range:()=>YV,real:()=>KF,reciprocal:()=>GV,relu:()=>HV,relu6:()=>WV,reshape:()=>E$,reverse:()=>zV,reverse1d:()=>XV,reverse2d:()=>jV,reverse3d:()=>qV,reverse4d:()=>KV,rfft:()=>fU,round:()=>QV,rsqrt:()=>JV,scalar:()=>nF,scatterND:()=>$U,searchSorted:()=>nV,selu:()=>ZV,separableConv2d:()=>tU,setdiff1dAsync:()=>eU,sigmoid:()=>S$,sign:()=>nU,signal:()=>ZY,sin:()=>iU,sinh:()=>sU,slice:()=>x$,slice1d:()=>rU,slice2d:()=>aU,slice3d:()=>oU,slice4d:()=>lU,softmax:()=>uU,softplus:()=>XB,spaceToBatchND:()=>SV,sparse:()=>iG,sparseToDense:()=>BU,spectral:()=>JY,split:()=>dU,sqrt:()=>zL,square:()=>XL,squaredDifference:()=>mU,squeeze:()=>gU,stack:()=>_U,step:()=>TU,stridedSlice:()=>yU,string:()=>sG,sub:()=>fF,sum:()=>wB,tan:()=>IU,tanh:()=>R$,tensor:()=>cD,tensor1d:()=>EU,tensor2d:()=>bU,tensor3d:()=>ZF,tensor4d:()=>vU,tensor5d:()=>wU,tensor6d:()=>SU,tensorScatterUpdate:()=>xU,tile:()=>CB,topk:()=>RU,transpose:()=>QF,truncatedNormal:()=>AU,unique:()=>OU,unsortedSegmentSum:()=>MU,unstack:()=>CU,upperBound:()=>NU,variable:()=>kU,where:()=>oB,whereAsync:()=>LU,zeros:()=>lV,zerosLike:()=>jL});var Xt={};__webpack_require__.r(Xt),__webpack_require__.d(Xt,{CSVDataset:()=>e2,Dataset:()=>G1,FileDataSource:()=>f2,TextLineDataset:()=>j1,URLDataSource:()=>m2,array:()=>W1,csv:()=>g2,func:()=>_2,generator:()=>T2,microphone:()=>I2,version_data:()=>E2,webcam:()=>y2,zip:()=>z1});var jt={};__webpack_require__.r(jt),__webpack_require__.d(jt,{addImpl:()=>V2,bincountImpl:()=>H2,bincountReduceImpl:()=>W2,bitwiseAndImpl:()=>z2,castImpl:()=>L2,ceilImpl:()=>J2,concatImpl:()=>e3,equalImpl:()=>n3,expImpl:()=>r3,expm1Impl:()=>l3,floorDivImpl:()=>f3,floorImpl:()=>p3,gatherNdImpl:()=>_3,gatherV2Impl:()=>T3,greaterEqualImpl:()=>b3,greaterImpl:()=>y3,lessEqualImpl:()=>A3,lessImpl:()=>S3,linSpaceImpl:()=>C3,logImpl:()=>N3,maxImpl:()=>L3,maximumImpl:()=>F3,minimumImpl:()=>B3,multiplyImpl:()=>Y3,negImpl:()=>z3,notEqualImpl:()=>j3,prodImpl:()=>t4,raggedGatherImpl:()=>r4,raggedRangeImpl:()=>o4,raggedTensorToTensorImpl:()=>c4,rangeImpl:()=>d4,rsqrtImpl:()=>f4,scatterImpl:()=>_4,sigmoidImpl:()=>T4,simpleAbsImpl:()=>S2,sliceImpl:()=>E4,sparseFillEmptyRowsImpl:()=>w4,sparseReshapeImpl:()=>S4,sparseSegmentReductionImpl:()=>x4,sqrtImpl:()=>R4,squaredDifferenceImpl:()=>M4,staticRegexReplaceImpl:()=>k4,stridedSliceImpl:()=>F4,stringNGramsImpl:()=>$4,stringSplitImpl:()=>V4,stringToHashBucketFastImpl:()=>U4,subImpl:()=>Y4,tileImpl:()=>z4,topKImpl:()=>q4,transposeImpl:()=>Q3,uniqueImpl:()=>K4});var qt={};__webpack_require__.r(qt),__webpack_require__.d(qt,{assertNotComplex:()=>ptt,bindCanvasToFramebuffer:()=>B7,bindColorTextureToFramebuffer:()=>V7,bindTextureToProgramUniformSampler:()=>$7,bindTextureUnit:()=>D7,bindVertexBufferToProgramAttribute:()=>k7,callAndCheck:()=>f7,canBeRepresented:()=>_7,createFragmentShader:()=>E7,createFramebuffer:()=>N7,createProgram:()=>w7,createStaticIndexBuffer:()=>A7,createStaticVertexBuffer:()=>R7,createTexture:()=>M7,createVertexShader:()=>I7,getBatchDim:()=>z7,getExtensionOrThrow:()=>y7,getFramebufferErrorMessage:()=>G7,getMaxTexturesInShader:()=>itt,getNumChannels:()=>O7,getProgramUniformLocation:()=>P7,getProgramUniformLocationOrThrow:()=>F7,getRowsCols:()=>X7,getShapeAs3D:()=>j7,getTextureShapeFromLogicalShape:()=>q7,getWebGLDisjointQueryTimerVersion:()=>stt,getWebGLErrorMessage:()=>T7,getWebGLMaxTextureSize:()=>ttt,hasExtension:()=>rtt,isCapableOfRenderingToFloatTexture:()=>ott,isDownloadFloatTextureEnabled:()=>ltt,isReshapeFree:()=>Q7,isWebGLFenceEnabled:()=>htt,isWebGLVersionEnabled:()=>att,linkProgram:()=>S7,logShaderSourceAndInfoLog:()=>v7,resetMaxTextureSize:()=>ett,resetMaxTexturesInShader:()=>ntt,unbindColorTextureFromFramebuffer:()=>U7,unbindTextureUnit:()=>L7,validateFramebuffer:()=>Y7,validateProgram:()=>x7,validateTextureSize:()=>C7});var Kt={};__webpack_require__.r(Kt),__webpack_require__.d(Kt,{bindVertexProgramAttributeStreams:()=>set,createBufferFromOutputTexture:()=>oet,createFloat16MatrixTexture:()=>Qtt,createFloat16PackedMatrixTexture:()=>iet,createFloat32MatrixTexture:()=>qtt,createIndexBuffer:()=>ztt,createPackedMatrixTexture:()=>eet,createUnsignedBytesMatrixTexture:()=>Ztt,createVertexBuffer:()=>Wtt,createVertexShader:()=>Htt,downloadByteEncodedFloatMatrixFromOutputTexture:()=>het,downloadFloat32MatrixFromBuffer:()=>uet,downloadMatrixFromPackedOutputTexture:()=>cet,downloadPackedMatrixFromBuffer:()=>pet,getInternalFormatForFloat16MatrixTexture:()=>Ktt,getInternalFormatForFloat16PackedMatrixTexture:()=>net,getInternalFormatForFloat32MatrixTexture:()=>jtt,getInternalFormatForPackedMatrixTexture:()=>tet,getInternalFormatForUnsignedBytesMatrixTexture:()=>Jtt,uploadDenseMatrixToTexture:()=>ret,uploadPixelDataToTexture:()=>aet});var Qt={};__webpack_require__.r(Qt),__webpack_require__.d(Qt,{Abs:()=>dO,Acos:()=>fO,Acosh:()=>mO,AdadeltaOptimizer:()=>hF,AdagradOptimizer:()=>cF,AdamOptimizer:()=>mF,AdamaxOptimizer:()=>EF,Add:()=>gO,AddN:()=>_O,All:()=>TO,Any:()=>yO,ArgMax:()=>IO,ArgMin:()=>EO,Asin:()=>bO,Asinh:()=>vO,Atan:()=>wO,Atan2:()=>xO,Atanh:()=>SO,AvgPool:()=>RO,AvgPool3D:()=>OO,AvgPool3DGrad:()=>MO,AvgPoolGrad:()=>AO,BatchMatMul:()=>CO,BatchToSpaceND:()=>NO,Bincount:()=>kO,BitwiseAnd:()=>DO,BroadcastArgs:()=>FO,BroadcastTo:()=>LO,Callback:()=>PZ,CallbackList:()=>fj,Cast:()=>PO,Ceil:()=>$O,ClipByValue:()=>BO,Complex:()=>VO,ComplexAbs:()=>UO,Concat:()=>YO,Conv2D:()=>GO,Conv2DBackpropFilter:()=>HO,Conv2DBackpropInput:()=>WO,Conv3D:()=>zO,Conv3DBackpropFilterV2:()=>XO,Conv3DBackpropInputV2:()=>jO,Cos:()=>qO,Cosh:()=>KO,CropAndResize:()=>ZO,Cumprod:()=>QO,Cumsum:()=>JO,CustomCallback:()=>_j,DataStorage:()=>lA,DenseBincount:()=>tM,DepthToSpace:()=>eM,DepthwiseConv2dNative:()=>nM,DepthwiseConv2dNativeBackpropFilter:()=>iM,DepthwiseConv2dNativeBackpropInput:()=>sM,Diag:()=>rM,Dilation2D:()=>aM,Dilation2DBackpropFilter:()=>lM,Dilation2DBackpropInput:()=>oM,Draw:()=>uM,ENV:()=>hO,EarlyStopping:()=>VZ,Einsum:()=>pM,Elu:()=>cM,EluGrad:()=>dM,Environment:()=>aO,Equal:()=>mM,Erf:()=>fM,Exp:()=>gM,ExpandDims:()=>_M,Expm1:()=>TM,FFT:()=>yM,Fill:()=>IM,FlipLeftRight:()=>EM,Floor:()=>bM,FloorDiv:()=>vM,FromPixels:()=>xN,FusedBatchNorm:()=>wM,FusedConv2D:()=>ON,FusedDepthwiseConv2D:()=>MN,GPGPUContext:()=>det,GatherNd:()=>xM,GatherV2:()=>SM,GraphModel:()=>l1,Greater:()=>RM,GreaterEqual:()=>AM,History:()=>gj,IFFT:()=>MM,Identity:()=>OM,Imag:()=>CM,InputSpec:()=>yX,IsFinite:()=>NM,IsInf:()=>kM,IsNan:()=>DM,KernelBackend:()=>uA,LRN:()=>XM,LRNGrad:()=>jM,LayerVariable:()=>gX,LayersModel:()=>bq,LeakyRelu:()=>LM,Less:()=>FM,LessEqual:()=>PM,LinSpace:()=>$M,Log:()=>BM,Log1p:()=>VM,LogSoftmax:()=>WM,LogicalAnd:()=>UM,LogicalNot:()=>YM,LogicalOr:()=>GM,LogicalXor:()=>HM,LowerBound:()=>zM,MathBackendCPU:()=>w2,MathBackendWebGL:()=>Pnt,MatrixBandPart:()=>qM,Max:()=>KM,MaxPool:()=>JM,MaxPool3D:()=>tC,MaxPool3DGrad:()=>eC,MaxPoolGrad:()=>ZM,MaxPoolWithArgmax:()=>nC,Maximum:()=>QM,Mean:()=>iC,Min:()=>sC,Minimum:()=>rC,MirrorPad:()=>aC,Mod:()=>oC,MomentumOptimizer:()=>vF,Multinomial:()=>lC,Multiply:()=>uC,Neg:()=>hC,NonMaxSuppressionV3:()=>cC,NonMaxSuppressionV4:()=>dC,NonMaxSuppressionV5:()=>fC,NotEqual:()=>pC,OP_SCOPE_SUFFIX:()=>lD,OneHot:()=>gC,OnesLike:()=>mC,Optimizer:()=>uF,OptimizerConstructors:()=>XP,Pack:()=>_C,PadV2:()=>TC,Pool:()=>yC,Pow:()=>IC,Prelu:()=>EC,Prod:()=>bC,RMSPropOptimizer:()=>wF,RNN:()=>NK,RaggedGather:()=>vC,RaggedRange:()=>wC,RaggedTensorToTensor:()=>SC,Range:()=>xC,Rank:()=>Ck,Real:()=>RC,RealDiv:()=>hM,Reciprocal:()=>AC,Reduction:()=>DY,Relu:()=>OC,Relu6:()=>LC,Reshape:()=>MC,ResizeBilinear:()=>kC,ResizeBilinearGrad:()=>DC,ResizeNearestNeighbor:()=>CC,ResizeNearestNeighborGrad:()=>NC,Reverse:()=>FC,RotateWithOffset:()=>RN,Round:()=>PC,Rsqrt:()=>$C,SGDOptimizer:()=>bF,ScatterNd:()=>BC,SearchSorted:()=>UC,Select:()=>YC,Selu:()=>GC,Sequential:()=>xq,Sigmoid:()=>jC,Sign:()=>XC,Sin:()=>WC,Sinh:()=>zC,Slice:()=>HC,Softmax:()=>tN,Softplus:()=>qC,SpaceToBatchND:()=>JC,SparseFillEmptyRows:()=>eN,SparseReshape:()=>nN,SparseSegmentMean:()=>iN,SparseSegmentSum:()=>sN,SparseToDense:()=>rN,SplitV:()=>ZC,Sqrt:()=>KC,Square:()=>oN,SquaredDifference:()=>aN,StaticRegexReplace:()=>lN,Step:()=>SN,StridedSlice:()=>uN,StringNGrams:()=>hN,StringSplit:()=>pN,StringToHashBucketFast:()=>cN,Sub:()=>dN,Sum:()=>QC,SymbolicTensor:()=>IX,Tan:()=>fN,Tanh:()=>mN,Tensor:()=>Ak,TensorBuffer:()=>wk,TensorScatterUpdate:()=>VC,Tile:()=>gN,TopK:()=>_N,Transform:()=>TN,Transpose:()=>yN,Unique:()=>IN,Unpack:()=>EN,UnsortedSegmentSum:()=>bN,UpperBound:()=>vN,Variable:()=>Mk,ZerosLike:()=>wN,_FusedMatMul:()=>AN,abs:()=>gF,acos:()=>jP,acosh:()=>qP,add:()=>YL,addN:()=>KP,all:()=>QP,any:()=>JP,argMax:()=>ZP,argMin:()=>t$,asin:()=>e$,asinh:()=>n$,atan:()=>i$,atan2:()=>s$,atanh:()=>r$,avgPool:()=>b$,avgPool3d:()=>v$,backend:()=>DD,backend_util:()=>yt,basicLSTMCell:()=>A$,batchNorm:()=>M$,batchNorm2d:()=>C$,batchNorm3d:()=>N$,batchNorm4d:()=>k$,batchToSpaceND:()=>O$,bincount:()=>D$,bitwiseAnd:()=>L$,booleanMaskAsync:()=>FU,broadcastArgs:()=>F$,broadcastTo:()=>P$,broadcast_util:()=>ut,browser:()=>ct,buffer:()=>$L,callbacks:()=>UZ,cast:()=>BL,ceil:()=>$$,clipByValue:()=>B$,clone:()=>VL,complex:()=>hD,concat:()=>w$,concat1d:()=>V$,concat2d:()=>U$,concat3d:()=>Y$,concat4d:()=>G$,constraints:()=>Et,conv1d:()=>W$,conv2d:()=>H$,conv2dTranspose:()=>X$,conv3d:()=>j$,conv3dTranspose:()=>K$,copyRegisteredKernels:()=>YN,cos:()=>Q$,cosh:()=>J$,cosineWindow:()=>GU,cumprod:()=>Z$,cumsum:()=>tB,customGrad:()=>tF,data:()=>Xt,denseBincount:()=>eB,deprecationWarn:()=>TD,depthToSpace:()=>nB,depthwiseConv2d:()=>iB,deregisterOp:()=>XZ,device_util:()=>ot,diag:()=>sB,dilation2d:()=>rB,disableDeprecationWarnings:()=>_D,dispose:()=>wD,disposeVariables:()=>yD,div:()=>HL,divNoNan:()=>lB,dot:()=>uB,dropout:()=>UU,einsum:()=>hB,elu:()=>pB,enableDebugMode:()=>gD,enableProdMode:()=>mD,enclosingPowerOfTwo:()=>YU,engine:()=>ID,ensureShape:()=>cB,env:()=>lO,equal:()=>aB,erf:()=>dB,euclideanNorm:()=>RB,exp:()=>AB,expandDims:()=>OB,expm1:()=>MB,eye:()=>NB,fft:()=>hU,fill:()=>pF,findBackend:()=>CD,findBackendFactory:()=>ND,floor:()=>kB,floorDiv:()=>GL,forceHalfFloat:()=>Bnt,fused:()=>_t,gather:()=>DB,gatherND:()=>VU,gather_util:()=>dt,getBackend:()=>OD,getGradient:()=>FN,getKernel:()=>LN,getKernelsForBackend:()=>PN,gpgpu_util:()=>Kt,grad:()=>qL,grads:()=>KL,greater:()=>LB,greaterEqual:()=>FB,ifft:()=>pU,imag:()=>jF,image:()=>tG,inTopKAsync:()=>HU,initializers:()=>bt,input:()=>Oq,io:()=>ht,irfft:()=>cU,isFinite:()=>PB,isInf:()=>$B,isNaN:()=>BB,keep:()=>SD,kernel_impls:()=>It,layers:()=>vt,leakyRelu:()=>VB,less:()=>UB,lessEqual:()=>YB,linalg:()=>eG,linspace:()=>GB,loadGraphModel:()=>u1,loadGraphModelSync:()=>h1,loadLayersModel:()=>Sq,localResponseNormalization:()=>HB,log:()=>WB,log1p:()=>zB,logSigmoid:()=>jB,logSoftmax:()=>qB,logSumExp:()=>KB,logicalAnd:()=>QB,logicalNot:()=>JB,logicalOr:()=>ZB,logicalXor:()=>tV,losses:()=>nG,lowerBound:()=>iV,matMul:()=>zF,math:()=>pt,max:()=>bB,maxPool:()=>sV,maxPool3d:()=>rV,maxPoolWithArgmax:()=>aV,maximum:()=>IF,mean:()=>oV,memory:()=>ED,meshgrid:()=>hV,metrics:()=>wt,min:()=>vB,minimum:()=>pV,mirrorPad:()=>cV,mod:()=>dV,model:()=>Rq,models:()=>St,moments:()=>fV,movingAverage:()=>PU,mul:()=>WL,multiRNNCell:()=>mV,multinomial:()=>gV,neg:()=>qF,nextFrame:()=>oG,norm:()=>xB,notEqual:()=>_V,oneHot:()=>XF,ones:()=>uV,onesLike:()=>TV,op:()=>uD,outerProduct:()=>yV,pad:()=>IV,pad1d:()=>EV,pad2d:()=>bV,pad3d:()=>vV,pad4d:()=>wV,pool:()=>xV,pow:()=>dF,prelu:()=>RV,print:()=>UL,prod:()=>AV,profile:()=>bD,raggedGather:()=>OV,raggedRange:()=>MV,raggedTensorToTensor:()=>CV,rand:()=>NV,randomGamma:()=>PV,randomNormal:()=>$V,randomStandardNormal:()=>BV,randomUniform:()=>VV,randomUniformInt:()=>UV,range:()=>YV,ready:()=>AD,real:()=>KF,reciprocal:()=>GV,registerBackend:()=>kD,registerCallbackConstructor:()=>Mq,registerGradient:()=>BN,registerKernel:()=>$N,registerOp:()=>WZ,regularizers:()=>xt,relu:()=>HV,relu6:()=>WV,removeBackend:()=>MD,reshape:()=>E$,reverse:()=>zV,reverse1d:()=>XV,reverse2d:()=>jV,reverse3d:()=>qV,reverse4d:()=>KV,rfft:()=>fU,round:()=>QV,rsqrt:()=>JV,scalar:()=>nF,scatterND:()=>$U,scatter_util:()=>ft,searchSorted:()=>nV,selu:()=>ZV,separableConv2d:()=>tU,sequential:()=>Aq,serialization:()=>lt,setBackend:()=>RD,setPlatform:()=>LD,setWebGLContext:()=>r7,setdiff1dAsync:()=>eU,shared:()=>jt,sigmoid:()=>S$,sign:()=>nU,signal:()=>ZY,sin:()=>iU,sinh:()=>sU,slice:()=>x$,slice1d:()=>rU,slice2d:()=>aU,slice3d:()=>oU,slice4d:()=>lU,slice_util:()=>mt,softmax:()=>uU,softplus:()=>XB,spaceToBatchND:()=>SV,sparse:()=>iG,sparseToDense:()=>BU,spectral:()=>JY,split:()=>dU,sqrt:()=>zL,square:()=>XL,squaredDifference:()=>mU,squeeze:()=>gU,stack:()=>_U,step:()=>TU,stridedSlice:()=>yU,string:()=>sG,sub:()=>fF,sum:()=>wB,sumOutType:()=>$k,tan:()=>IU,tanh:()=>R$,tensor:()=>cD,tensor1d:()=>EU,tensor2d:()=>bU,tensor3d:()=>ZF,tensor4d:()=>vU,tensor5d:()=>wU,tensor6d:()=>SU,tensorScatterUpdate:()=>xU,tensor_util:()=>at,test_util:()=>gt,tidy:()=>vD,tile:()=>CB,time:()=>xD,topk:()=>RU,train:()=>rG,transpose:()=>QF,truncatedNormal:()=>AU,unique:()=>OU,unregisterGradient:()=>UN,unregisterKernel:()=>VN,unsortedSegmentSum:()=>MU,unstack:()=>CU,upcastType:()=>Pk,upperBound:()=>NU,util:()=>rt,valueAndGrad:()=>QL,valueAndGrads:()=>JL,variable:()=>kU,variableGrads:()=>ZL,version:()=>Dut,version_converter:()=>p1,version_core:()=>zP,version_cpu:()=>Q4,version_layers:()=>nq,version_webgl:()=>$nt,webgl:()=>Vnt,webgl_util:()=>qt,where:()=>oB,whereAsync:()=>LU,zeros:()=>lV,zerosLike:()=>jL});const Jt=Blockly;Object.assign(Jt.Lang.ZhHans,{PYTHON_PYODIDE_IMAGE:"图像",PYTHON_PYODIDE_LOADING:"Python3内核载入中...",PYTHON_PYODIDE_FILE_SYSTEM:"本地文件系统",PYTHON_PYODIDE_LOAD_FILE_SYSTEM:"载入本地文件夹"}),Object.assign(Jt.Lang.ZhHant,{PYTHON_PYODIDE_IMAGE:"影像",PYTHON_PYODIDE_LOADING:"Python3核心載入...",PYTHON_PYODIDE_FILE_SYSTEM:"本機檔案系統",PYTHON_PYODIDE_LOAD_FILE_SYSTEM:"載入本機資料夾"}),Object.assign(Jt.Lang.En,{PYTHON_PYODIDE_IMAGE:"Image",PYTHON_PYODIDE_LOADING:"Python3 kernel loading...",PYTHON_PYODIDE_FILE_SYSTEM:"Local File System",PYTHON_PYODIDE_LOAD_FILE_SYSTEM:"Load Local Folder"}),Object.assign(Jt.Lang.ZhHans.MSG,{}),Object.assign(Jt.Lang.ZhHant.MSG,{}),Object.assign(Jt.Lang.En.MSG,{});const Zt=Mixly,te={NAME_TYPE:"VARIABLE",allVariables:function(t){var e;if(t.getDescendants)e=t.getDescendants();else{if(!t.getAllBlocks)throw"Not Block or Workspace: "+t;e=t.getAllBlocks()}for(var n=Object.create(null),i=0;i1&&(a+=i)):n=a}else n="i";return n}},ee=te; /** * @license * Visual Blocks Editor * * Copyright 2012 Google Inc. * https://developers.google.com/blockly/ * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ class ne{constructor(t,e){if(this.variablePrefix_=e||"",this.reservedDict_=Object.create(null),t)for(var n=t.split(","),i=0;i0;s--)e.getInputTargetBlock("IF"+s)&&e.getInputTargetBlock("IF"+s).previousConnection?n[s]=e.getInputTargetBlock("IF"+s).previousConnection:n[s]=null,this.removeInput("IF"+s),e.getInputTargetBlock("DO"+s)&&e.getInputTargetBlock("DO"+s).previousConnection?i[s]=e.getInputTargetBlock("DO"+s).previousConnection:i[s]=null,this.removeInput("DO"+s);this.elseifCount_=parseInt(t.getAttribute("elseif"),10),this.elseCount_=parseInt(t.getAttribute("else"),10);for(s=1;s<=this.elseifCount_;s++)this.appendValueInput("IF"+s).setCheck([Boolean,Number]).appendField(Jt.Msg.CONTROLS_IF_MSG_ELSEIF),this.appendStatementInput("DO"+s).appendField(Jt.Msg.CONTROLS_IF_MSG_THEN);this.elseCount_&&this.appendStatementInput("ELSE").appendField(Jt.Msg.CONTROLS_IF_MSG_ELSE);for(s=n.length-2;s>0;s--)n[s]&&n[s].reconnect(this,"IF"+s);for(s=i.length-2;s>0;s--)i[s]&&i[s].reconnect(this,"DO"+s)},decompose:function(t){var e=t.newBlock("controls_if_if");e.initSvg();for(var n=e.getInput("STACK").connection,i=1;i<=this.elseifCount_;i++){var s=t.newBlock("controls_if_elseif");s.initSvg(),n.connect(s.previousConnection),n=s.nextConnection}if(this.elseCount_){var r=t.newBlock("controls_if_else");r.initSvg(),n.connect(r.previousConnection)}return e},compose:function(t){this.elseCount_&&this.removeInput("ELSE"),this.elseCount_=0;for(var e=this.elseifCount_;e>0;e--)this.removeInput("IF"+e),this.removeInput("DO"+e);this.elseifCount_=0;for(var n=t.getInputTargetBlock("STACK"),i=[null],s=[null],r=null;n;){switch(n.type){case"controls_if_elseif":this.elseifCount_++,i.push(n.valueConnection_),s.push(n.statementConnection_);break;case"controls_if_else":this.elseCount_++,r=n.statementConnection_;break;default:throw Error("Unknown block type: "+n.type)}n=n.nextConnection&&n.nextConnection.targetBlock()}this.updateShape_(),this.reconnectChildBlocks_(i,s,r)},saveConnections:function(t){for(var e=t.getInputTargetBlock("STACK"),n=1;e;){switch(e.type){case"controls_if_elseif":var i=this.getInput("IF"+n),s=this.getInput("DO"+n);e.valueConnection_=i&&i.connection.targetConnection,e.statementConnection_=s&&s.connection.targetConnection,n++;break;case"controls_if_else":s=this.getInput("ELSE");e.statementConnection_=s&&s.connection.targetConnection;break;default:throw"Unknown block type."}e=e.nextConnection&&e.nextConnection.targetBlock()}},rebuildShape_:function(){var t=[null],e=[null],n=null;this.getInput("ELSE")&&(n=this.getInput("ELSE").connection.targetConnection);for(var i=1;this.getInput("IF"+i);){var s=this.getInput("IF"+i),r=this.getInput("DO"+i);console.log(s.connection.targetConnection),t.push(s.connection.targetConnection),e.push(r.connection.targetConnection),i++}this.updateShape_(),this.reconnectChildBlocks_(t,e,n)},updateShape_:function(){this.getInput("ELSE")&&this.removeInput("ELSE");for(var t=1;this.getInput("IF"+t);)this.removeInput("IF"+t),this.removeInput("DO"+t),t++;for(t=1;t<=this.elseifCount_;t++)this.appendValueInput("IF"+t).setCheck([Number,Boolean]).appendField(Jt.Msg.CONTROLS_IF_MSG_ELSEIF),this.appendStatementInput("DO"+t).appendField(Jt.Msg.CONTROLS_IF_MSG_THEN);this.elseCount_&&this.appendStatementInput("ELSE").appendField(Jt.Msg.CONTROLS_IF_MSG_ELSE)},reconnectChildBlocks_:function(t,e,n){for(var i=1;i<=this.elseifCount_;i++)t[i]&&t[i].reconnect(this,"IF"+i),e[i]&&e[i].reconnect(this,"DO"+i);n&&n.reconnect(this,"ELSE")}},Ee={init:function(){this.setColour(me),this.appendValueInput("FROM").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.PYTHON_RANGE).appendField(Jt.Msg.LANG_CONTROLS_FOR_INPUT_FROM),this.appendValueInput("TO").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.LANG_CONTROLS_FOR_INPUT_TO),this.appendValueInput("STEP").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.PYTHON_RANGE_STEP),this.setInputsInline(!0),this.setOutput(!0),this.setTooltip(Jt.Msg.MIXLY_PYTHON_CONTROLS_RANGE_TOOLTIP)}},be={init:function(){this.setColour(me),this.appendValueInput("LIST").setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.CONTROLS_FOREACH_INPUT),this.appendValueInput("VAR").appendField(Jt.Msg.CONTROLS_FOREACH_INPUT_ITEM),this.appendStatementInput("DO").appendField(Jt.Msg.MIXLY_DO),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip((function(){return Jt.Msg.CONTROLS_FOR_TOOLTIP.replace("“%1”","")}))},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},ve={init:function(){this.setColour(me),this.appendValueInput("BOOL").setCheck([Boolean,Number]).appendField(Jt.Msg.MIXLY_MICROBIT_JS_CURRENT).appendField(new Jt.FieldDropdown(this.OPERATORS),"MODE"),this.appendStatementInput("DO").appendField(Jt.Msg.LANG_CONTROLS_WHILEUNTIL_TITLE_REPEAT+Jt.Msg.MIXLY_DO),this.setPreviousStatement(!0),this.setNextStatement(!0);var t=this;this.setTooltip((function(){var e=t.getFieldValue("MODE");return{WHILE:Jt.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_WHILE,UNTIL:Jt.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL}[e]}))}},we={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.MIXLY_PYTHON_TRY),this.appendStatementInput("try"),this.appendValueInput("IF1").appendField(Jt.Msg.MIXLY_PYTHON_EXCEPT),this.appendStatementInput("DO1").appendField(""),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setMutator(new Jt.icons.MutatorIcon(["controls_except","controls_finally"],this)),this.setTooltip(Jt.Msg.MIXLY_MIXPY_CONTROL_TRY_TOOLTIP),this.elseifCount_=1,this.elseCount_=0},mutationToDom:function(){if(!this.elseifCount_&&!this.elseCount_)return null;var t=document.createElement("mutation");return this.elseifCount_&&t.setAttribute("elseif",this.elseifCount_),this.elseCount_&&t.setAttribute("else",1),t},domToMutation:function(t){var e=this,n=[],i=[];this.elseCount_&&this.removeInput("ELSE");for(var s=this.elseifCount_;s>0;s--)e.getInputTargetBlock("IF"+s)&&e.getInputTargetBlock("IF"+s).previousConnection?n[s]=e.getInputTargetBlock("IF"+s).previousConnection:n[s]=null,this.removeInput("IF"+s),e.getInputTargetBlock("DO"+s)&&e.getInputTargetBlock("DO"+s).previousConnection?i[s]=e.getInputTargetBlock("DO"+s).previousConnection:i[s]=null,this.removeInput("DO"+s);this.elseifCount_=parseInt(t.getAttribute("elseif"),10),this.elseCount_=parseInt(t.getAttribute("else"),10);for(s=1;s<=this.elseifCount_;s++)this.appendValueInput("IF"+s).setCheck([Boolean,Number]).appendField(Jt.Msg.MIXLY_PYTHON_EXCEPT),this.appendStatementInput("DO"+s).appendField("");this.elseCount_&&this.appendStatementInput("ELSE").appendField(Jt.Msg.MIXLY_PYTHON_FINALLY);for(s=n.length-2;s>0;s--)n[s]&&n[s].reconnect(this,"IF"+s);for(s=i.length-2;s>0;s--)i[s]&&i[s].reconnect(this,"DO"+s)},decompose:function(t){var e=t.newBlock("controls_try");e.initSvg();for(var n=e.getInput("STACK").connection,i=1;i<=this.elseifCount_;i++){var s=t.newBlock("controls_except");s.initSvg(),n.connect(s.previousConnection),n=s.nextConnection}if(this.elseCount_){var r=t.newBlock("controls_finally");r.initSvg(),n.connect(r.previousConnection)}return e},compose:function(t){this.elseCount_&&this.removeInput("ELSE"),this.elseCount_=0;for(var e=this.elseifCount_;e>0;e--)this.removeInput("IF"+e),this.removeInput("DO"+e);this.elseifCount_=0;for(var n=t.getInputTargetBlock("STACK"),i=[null],s=[null],r=null;n;){switch(n.type){case"controls_except":this.elseifCount_++,i.push(n.valueConnection_),s.push(n.statementConnection_);break;case"controls_finally":this.elseCount_++,r=n.statementConnection_;break;default:throw Error("Unknown block type: "+n.type)}n=n.nextConnection&&n.nextConnection.targetBlock()}this.updateShape_(),this.reconnectChildBlocks_(i,s,r)},saveConnections:function(t){for(var e=t.getInputTargetBlock("STACK"),n=1;e;){switch(e.type){case"controls_except":var i=this.getInput("IF"+n),s=this.getInput("DO"+n);e.valueConnection_=i&&i.connection.targetConnection,e.statementConnection_=s&&s.connection.targetConnection,n++;break;case"controls_finally":s=this.getInput("ELSE");e.statementConnection_=s&&s.connection.targetConnection;break;default:throw"Unknown block type."}e=e.nextConnection&&e.nextConnection.targetBlock()}},rebuildShape_:function(){var t=[null],e=[null],n=null;this.getInput("ELSE")&&(n=this.getInput("ELSE").connection.targetConnection);for(var i=1;this.getInput("IF"+i);){var s=this.getInput("IF"+i),r=this.getInput("DO"+i);console.log(s.connection.targetConnection),t.push(s.connection.targetConnection),e.push(r.connection.targetConnection),i++}this.updateShape_(),this.reconnectChildBlocks_(t,e,n)},updateShape_:function(){this.getInput("ELSE")&&this.removeInput("ELSE");for(var t=1;this.getInput("IF"+t);)this.removeInput("IF"+t),this.removeInput("DO"+t),t++;for(t=1;t<=this.elseifCount_;t++)this.appendValueInput("IF"+t).setCheck([Number,Boolean]).appendField(Jt.Msg.MIXLY_PYTHON_EXCEPT),this.appendStatementInput("DO"+t).appendField("");this.elseCount_&&this.appendStatementInput("ELSE").appendField(Jt.Msg.MIXLY_PYTHON_FINALLY)},reconnectChildBlocks_:function(t,e,n){for(var i=1;i<=this.elseifCount_;i++)t[i]&&t[i].reconnect(this,"IF"+i),e[i]&&e[i].reconnect(this,"DO"+i);n&&n.reconnect(this,"ELSE")}},Se={init:function(){this.setColour(me);var t=new Jt.FieldDropdown(this.OPERATORS);this.appendDummyInput().appendField(t,"FLOW").appendField(Jt.Msg.LANG_CONTROLS_FLOW_STATEMENTS_INPUT_OFLOOP),this.setPreviousStatement(!0),this.setTooltip(Jt.Msg.MIXLY_PYTHON_CONTROLS_FLOW_STATEMENTS_TOOLTIP);var e=this;this.setTooltip((function(){var t=e.getFieldValue("FLOW");return{BREAK:Jt.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK,CONTINUE:Jt.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE}[t]}))},onchange:function(){if(this.workspace){var t=!1,e=this;do{if("controls_repeat"==e.type||"controls_for"==e.type||"controls_forEach"==e.type||"controls_repeat_ext"==e.type||"controls_whileUntil"==e.type||"do_while"==e.type){t=!0;break}e=e.getSurroundParent()}while(e);t?this.setWarningText(null):this.setWarningText(Jt.Msg.LANG_CONTROLS_FLOW_STATEMENTS_WARNING)}}},xe={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.LANG_CONTROLS_FOR_INPUT_WITH).appendField(new Jt.FieldTextInput("i"),"VAR"),this.appendValueInput("FROM").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.LANG_CONTROLS_FOR_INPUT_FROM),this.appendValueInput("TO").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.LANG_CONTROLS_FOR_INPUT_TO),this.appendValueInput("STEP").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MIXLY_STEP),this.appendStatementInput("DO").appendField(Jt.Msg.MIXLY_DO),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0);var t=this;this.setTooltip((function(){return Jt.Msg.CONTROLS_FOR_TOOLTIP.replace("%1",t.getFieldValue("VAR"))}))},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},Re={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.LANG_CONTROLS_FOR_INPUT_WITH).appendField(new Jt.FieldTextInput("i"),"VAR"),this.appendValueInput("FROM").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.LANG_CONTROLS_FOR_INPUT_FROM),this.appendValueInput("TO").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.LANG_CONTROLS_FOR_INPUT_TO),this.appendValueInput("STEP").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MIXLY_STEP),this.appendStatementInput("DO").appendField(Jt.Msg.MIXLY_DO),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0);var t=this;this.setTooltip((function(){return Jt.Msg.MIXLY_PYTHON_CONTROLS_FOR_RANGE_TOOLTIP.replace("%1",t.getFieldValue("VAR"))}))},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}};ve.OPERATORS=[[Jt.Msg.LANG_CONTROLS_WHILEUNTIL_OPERATOR_WHILE,"WHILE"],[Jt.Msg.LANG_CONTROLS_WHILEUNTIL_OPERATOR_UNTIL,"UNTIL"]],Se.OPERATORS=[[Jt.Msg.LANG_CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK,"BREAK"],[Jt.Msg.LANG_CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE,"CONTINUE"]];const Ae={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.CONTROLS_IF_IF_TITLE_IF),this.appendStatementInput("STACK"),this.setTooltip(Jt.Msg.CONTROLS_IF_IF_TOOLTIP),this.contextMenu=!1}},Oe={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.CONTROLS_IF_ELSEIF_TITLE_ELSEIF),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.CONTROLS_IF_ELSEIF_TOOLTIP),this.contextMenu=!1}},Me={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.CONTROLS_IF_ELSE_TITLE_ELSE),this.setPreviousStatement(!0),this.setTooltip(Jt.Msg.CONTROLS_IF_ELSE_TOOLTIP),this.contextMenu=!1}},Ce={init:function(){this.setColour(me),this.appendDummyInput().appendField("try"),this.appendStatementInput("STACK"),this.setPreviousStatement(!1),this.setNextStatement(!1),this.contextMenu=!1}},Ne={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.MIXLY_PYTHON_EXCEPT),this.setPreviousStatement(!0),this.setNextStatement(!0),this.contextMenu=!1,this.setTooltip(Jt.Msg.MIXLY_MIXPY_CONTROL_EXCEPT_TOOLTIP)}},ke={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.MIXLY_PYTHON_FINALLY),this.setPreviousStatement(!0),this.contextMenu=!1,this.setTooltip(Jt.Msg.MIXLY_MIXPY_CONTROL_FINALLY_TOOLTIP)}},De={init:function(){this.jsonInit({message0:Jt.Msg.CONTROLS_REPEAT_TITLE,args0:[{type:"input_value",name:"TIMES"}],previousStatement:null,nextStatement:null,colour:me,tooltip:Jt.Msg.CONTROLS_REPEAT_TOOLTIP,helpUrl:Jt.Msg.CONTROLS_REPEAT_HELPURL}),this.appendStatementInput("DO")}},Le={init:function(){this.setColour(me),this.appendValueInput("BOOL").appendField("lambda"),this.appendStatementInput("DO").appendField(Jt.Msg.MIXLY_STAT),this.setOutput(!0)}},Fe={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.MIXLY_PYTHON_PASS),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_PYTHON_CONTROLS_PASS_TOOLTIP)}},Pe={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.MIXLY_PYTHON_CONTROLS_THREAD_START),this.appendValueInput("callback").appendField(Jt.Msg.MIXLY_PYTHON_CONTROLS_THREAD_USE),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_PARAMS),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_PYTHON_CONTROLS_THREAD_TOOLTIP)}},$e={init:function(){this.appendDummyInput().appendField(Jt.Msg.CONTROLS_REPEAT_TITLE_REPEAT+Jt.Msg.MIXLY_DO),this.appendStatementInput("input_data").setCheck(null),this.appendValueInput("select_data").setCheck(null).appendField(Jt.Msg.CONTROLS_OPERATOR_UNTIL).appendField(new Jt.FieldDropdown([[Jt.Msg.LANG_CONTROLS_WHILEUNTIL_OPERATOR_WHILE,"true"],[Jt.Msg.LANG_CONTROLS_WHILEUNTIL_OPERATOR_UNTIL,"false"]]),"type"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(me),this.setTooltip("do-while loop"),this.setHelpUrl("")}},Be={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.MIXLY_OP_GARBAGE_COLLECT),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Ve={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.MIXLY_GET_MEM_ALLOC),this.setOutput(!0)}},Ue={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.MIXLY_GET_MEM_FREE),this.setOutput(!0)}},Ye={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.MIXLY_GET+Jt.Msg.MIXLY_DEVICE+"ID"),this.setInputsInline(!0),this.setOutput(!0),this.setTooltip(Jt.Msg.PROCEDURES_DEFRETURN_RETURN+Jt.Msg.MIXLY_GET_UNIQUE_IDEN)}},Ge={init:function(){this.setColour(me),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_RTC_TIMESTAMP),this.appendDummyInput().appendField(Jt.Msg.MIXLY_TIMESTAMP_TO_DATA),this.setInputsInline(!0),this.setOutput(!0,Number)}},He={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.MIXLY_GET_UNIQUE_IDEN),this.setOutput(!0)}},We=230;Jt.FieldTextInput.math_number_validator=function(t){return String(t)},Jt.FieldTextInput.math_number_validator_include_blank=function(t){if(""===t)return"";return/^-?(0X|0x|0O|0o|0B|0b)?[a-fA-F0-9]{1,}(\.[a-fA-F0-9]+)?$/.test(t)?String(t):null};const ze={init:function(){this.setColour(We),this.appendDummyInput().appendField(new Jt.FieldTextInput("0",Jt.FieldTextInput.math_number_validator),"NUM"),this.setOutput(!0,Number),this.setTooltip(Jt.Msg.MATH_NUMBER_TOOLTIP)}},Xe={init:function(){this.setColour(We);this.appendDummyInput("").appendField(Jt.Msg.MIXLY_PYTHON_MATH_CONSTANT).appendField(new Jt.FieldDropdown([["π","pi"],["e","e"]]),"CONSTANT"),this.setOutput(!0,Number);var t=this;this.setTooltip((function(){var e=t.getFieldValue("CONSTANT");return{pi:Jt.Msg.MIXLY_PYTHON_MATH_CONSTANT_PI_TOOLTIP,e:Jt.Msg.MIXLY_PYTHON_MATH_CONSTANT_E_TOOLTIP}[e]}))}},je={init:function(){this.setColour(We);this.appendDummyInput("").appendField(Jt.Msg.MIXLY_PYTHON_MATH_CONSTANT).appendField(new Jt.FieldDropdown([["π","pi"],["e","e"]]),"CONSTANT"),this.setOutput(!0,Number);var t=this;this.setTooltip((function(){var e=t.getFieldValue("CONSTANT");return{pi:Jt.Msg.MIXLY_PYTHON_MATH_CONSTANT_PI_MP_TOOLTIP,e:Jt.Msg.MIXLY_PYTHON_MATH_CONSTANT_E_MP_TOOLTIP}[e]}))}},qe={init:function(){this.setColour(We),this.setOutput(!0),this.appendValueInput("A"),this.appendValueInput("B").appendField(new Jt.FieldDropdown([["+","ADD"],["-","MINUS"],["×","MULTIPLY"],["÷","DIVIDE"],["%","QUYU"],["//","ZHENGCHU"],["**","POWER"]]),"OP"),this.setInputsInline(!0);var t=this;this.setTooltip((function(){var e=t.getFieldValue("OP");return{ADD:Jt.Msg.MATH_ARITHMETIC_TOOLTIP_ADD,MINUS:Jt.Msg.MATH_ARITHMETIC_TOOLTIP_MINUS,MULTIPLY:Jt.Msg.MATH_ARITHMETIC_TOOLTIP_MULTIPLY,DIVIDE:Jt.Msg.MATH_ARITHMETIC_TOOLTIP_DIVIDE,QUYU:Jt.Msg.MATH_MODULO_TOOLTIP,ZHENGCHU:Jt.Msg.MATH_ARITHMETIC_TOOLTIP_DIVIDE,POWER:Jt.Msg.MATH_ARITHMETIC_TOOLTIP_POWER}[e]}))}},Ke={init:function(){this.setColour(We),this.setPreviousStatement(!0),this.setNextStatement(!0),this.appendValueInput("A"),this.appendValueInput("B").appendField(new Jt.FieldDropdown([["+=","ADD"],["-=","MINUS"],["×=","MULTIPLY"],["÷=","DIVIDE"],["%=","QUYU"],["//=","ZHENGCHU"],["**=","POWER"]]),"OP"),this.setInputsInline(!0);var t=this;this.setTooltip((function(){var e=t.getFieldValue("OP");return{ADD:Jt.Msg.MATH_ARITHMETIC_TOOLTIP_ADD,MINUS:Jt.Msg.MATH_ARITHMETIC_TOOLTIP_MINUS,MULTIPLY:Jt.Msg.MATH_ARITHMETIC_TOOLTIP_MULTIPLY,DIVIDE:Jt.Msg.MATH_ARITHMETIC_TOOLTIP_DIVIDE,QUYU:Jt.Msg.MATH_MODULO_TOOLTIP,ZHENGCHU:Jt.Msg.MATH_ARITHMETIC_TOOLTIP_DIVIDE,POWER:Jt.Msg.MATH_ARITHMETIC_TOOLTIP_POWER}[e]}))}},Qe={init:function(){this.setColour(We),this.setOutput(!0,Number),this.appendValueInput("A").setCheck(Number),this.appendValueInput("B").setCheck(Number).appendField(new Jt.FieldDropdown([["&","&"],["|","|"],[">>",">>"],["<<","<<"]]),"OP"),this.setInputsInline(!0),this.setTooltip("位运算")}},Je={init:function(){this.setColour(We),this.setOutput(!0,Number),this.appendValueInput("NUM").setCheck(Number).appendField(new Jt.FieldDropdown([["sin","SIN"],["cos","COS"],["tan","TAN"],["asin","ASIN"],["acos","ACOS"],["atan","ATAN"],["-","-"],["ln","LN"],["log10","LOG10"],["e^","EXP"],["10^","POW10"]]),"OP");var t=this;this.setTooltip((function(){var e=t.getFieldValue("OP");return{SIN:Jt.Msg.MATH_TRIG_TOOLTIP_SIN,COS:Jt.Msg.MATH_TRIG_TOOLTIP_COS,TAN:Jt.Msg.MATH_TRIG_TOOLTIP_TAN,ASIN:Jt.Msg.MATH_TRIG_TOOLTIP_ASIN,ACOS:Jt.Msg.MATH_TRIG_TOOLTIP_ACOS,ATAN:Jt.Msg.MATH_TRIG_TOOLTIP_ATAN,LN:Jt.Msg.MATH_SINGLE_TOOLTIP_LN}[e]}))}},Ze={init:function(){var t=[[Jt.Msg.MATH_BIN,"bin"],[Jt.Msg.MATH_OCT,"oct"],[Jt.Msg.MATH_HEX,"hex"]];this.setColour(We),this.setOutput(!0,String),this.appendValueInput("NUM").setCheck(Number).appendField(new Jt.FieldDropdown(t),"OP");var e=this;this.setTooltip((function(){var t=e.getFieldValue("OP");return{bin:Jt.Msg.MATH_DEC_TOOLTIP_BIN,oct:Jt.Msg.MATH_DEC_TOOLTIP_OCT,hex:Jt.Msg.MATH_DEC_TOOLTIP_HEX}[t]}))}},tn={init:function(){var t=[[Jt.Msg.LANG_MATH_TO_ROUND,"round"],[Jt.Msg.LANG_MATH_TO_CEIL,"ceil"],[Jt.Msg.LANG_MATH_TO_FLOOR,"floor"],[Jt.Msg.MATH_ABS,"fabs"],[Jt.Msg.MATH_SQRT,"sqrt"]];this.setColour(We),this.appendValueInput("A").setCheck(Number).appendField(new Jt.FieldDropdown(t),"OP"),this.setOutput(!0,Number);var e=this;this.setTooltip((function(){var t=e.getFieldValue("OP");return{sqrt:Jt.Msg.MATH_SINGLE_TOOLTIP_ROOT,fabs:Jt.Msg.MATH_SINGLE_TOOLTIP_ABS,sq:Jt.Msg.MATH_SINGLE_TOOLTIP_SQ,round:Jt.Msg.MATH_SINGLE_TOOLTIP_ROUND,ceil:Jt.Msg.MATH_SINGLE_TOOLTIP_CEIL,floor:Jt.Msg.MATH_SINGLE_TOOLTIP_FLOOR}[t]}))}},en={init:function(){var t=[[Jt.Msg.MIXLY_MAX,"max"],[Jt.Msg.MIXLY_MIN,"min"]];this.setColour(We),this.appendValueInput("A").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(new Jt.FieldDropdown(t),"OP").appendField("("),this.appendValueInput("B").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(","),this.appendDummyInput("").setAlign(Jt.inputs.Align.RIGHT).appendField(")"),this.setInputsInline(!0),this.setOutput(!0,Number);var e=this;this.setTooltip((function(){var t=e.getFieldValue("OP");return{max:Jt.Msg.MIXLY_TOOLTIP_MATH_MAX,min:Jt.Msg.MIXLY_TOOLTIP_MATH_MIN}[t]}))}},nn={init:function(){var t=[[Jt.Msg.MATH_TWO,"two"],[Jt.Msg.MATH_EIGHT,"eight"],[Jt.Msg.MATH_TEN,"ten"],[Jt.Msg.MATH_SIXTEEN,"sixteen"]];this.setColour(We),this.appendDummyInput("").appendField(Jt.Msg.MATH_BA),this.appendValueInput("NUM").appendField(new Jt.FieldDropdown(t),"OP").appendField(Jt.Msg.MATH_JinZhi).setCheck(Number),this.appendDummyInput("").appendField(Jt.Msg.MATH_ZHW).appendField(new Jt.FieldDropdown(t),"OP2").appendField(Jt.Msg.MATH_JinZhi),this.setFieldValue("ten","OP2"),this.setOutput(!0),this.setInputsInline(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("OP"),n={two:Jt.Msg.MATH_Before_two,eight:Jt.Msg.MATH_Before_eight,ten:Jt.Msg.MATH_Before_ten,sixteen:Jt.Msg.MATH_Before_sixteen},i=e.getFieldValue("OP2"),s={two:Jt.Msg.MATH_Behind_two,eight:Jt.Msg.MATH_Behind_eight,ten:Jt.Msg.MATH_Behind_ten,sixteen:Jt.Msg.MATH_Behind_sixteen};return n[t]+s[i]}))}},sn={init:function(){var t=[[Jt.Msg.LANG_MATH_INT,"int"],[Jt.Msg.LANG_MATH_FLOAT,"float"]];this.setColour(We),this.setOutput(!0,Number),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_RANDOM).appendField(new Jt.FieldDropdown(t),"TYPE"),this.appendValueInput("FROM").setCheck(Number).appendField(Jt.Msg.LANG_CONTROLS_FOR_INPUT_FROM),this.appendValueInput("TO").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.LANG_MATH_RANDOM_INT_INPUT_TO),this.setInputsInline(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("TYPE"),n={int:Jt.Msg.LANG_MATH_INT,float:Jt.Msg.LANG_MATH_FLOAT_RANDOM};return Jt.Msg.MATH_RANDOM_INT_TOOLTIP+n[t]}))}},rn={init:function(){this.setColour(We),this.setOutput(!0,Number),this.appendValueInput("VALUE").setCheck(Number).appendField(Jt.Msg.LANG_MATH_CONSTRAIN_INPUT_CONSTRAIN),this.appendValueInput("LOW").setCheck(Number).appendField(Jt.Msg.LANG_MATH_CONSTRAIN_INPUT_LOW),this.appendValueInput("HIGH").setCheck(Number).appendField(Jt.Msg.LANG_MATH_CONSTRAIN_INPUT_HIGH),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MATH_CONSTRAIN_TOOLTIP)}},an={init:function(){this.setColour(We),this.appendValueInput("NUM",Number).appendField(Jt.Msg.MIXLY_MAP).setCheck(Number),this.appendValueInput("fromLow",Number).appendField(Jt.Msg.MIXLY_MAP_FROM).setCheck(Number),this.appendValueInput("fromHigh",Number).appendField(",").setCheck(Number),this.appendValueInput("toLow",Number).appendField(Jt.Msg.MIXLY_MAP_TO).setCheck(Number),this.appendValueInput("toHigh",Number).appendField(",").setCheck(Number),this.appendDummyInput("").appendField("]"),this.setInputsInline(!0),this.setOutput(!0),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_MATH_MAP)}},on={init:function(){this.setColour(We),this.appendDummyInput().appendField(new Jt.FieldTextInput("0",Jt.FieldTextInput.math_number_validator_include_blank),"NUM"),this.setOutput(!0),this.setTooltip(Jt.Msg.MATH_NUMBER_TOOLTIP)}},ln={init:function(){this.setColour(We),this.appendValueInput("NUM").setCheck(Number).appendField(Jt.Msg.LANG_MATH_RANDOM_SEED),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_MATH_RANDOM_SEED)}},un={init:function(){this.setColour(We),this.setOutput(!0,Number),this.appendValueInput("VALUE").setCheck(Number),this.appendValueInput("VAR").setCheck(Number).appendField(Jt.Msg.MATH_ROUND).appendField(Jt.Msg.TEXT_KEEP),this.appendDummyInput().appendField(Jt.Msg.TEXT_DECIMAL),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MATH_ROUND_NEW_TOOLTIP)}},hn={init:function(){var t=[[Jt.Msg.MIXLY_TO_INT,"int"],[Jt.Msg.MIXLY_TO_FLOAT,"float"],[Jt.Msg.MIXLY_TO_BITES,"b"],[Jt.Msg.LANG_MATH_BYTE+Jt.Msg.MIXLY_TO_INT,"bti"]];this.setColour(We),this.appendValueInput("VAR").appendField(new Jt.FieldDropdown(t),"TOWHAT"),this.setOutput(!0,Number);var e=this;this.setTooltip((function(){var t=e.getFieldValue("TOWHAT");return{int:Jt.Msg.MIXLY_PYTHON_TOOLTIP_TOINT,float:Jt.Msg.MIXLY_PYTHON_TOOLTIP_TOFLOAT,b:Jt.Msg.MIXLY_TOOLTIP_TEXT_TOBYTE}[t]}))}},pn={init:function(){var t=[[Jt.Msg.MIXLY_TO_INT,"int"],[Jt.Msg.MIXLY_TO_FLOAT,"float"]];this.setColour(We),this.appendValueInput("VAR").appendField(new Jt.FieldDropdown(t),"TOWHAT"),this.setOutput(!0,Number);var e=this;this.setTooltip((function(){var t=e.getFieldValue("TOWHAT");return{int:Jt.Msg.MIXLY_TOOLTIP_TEXT_TOINT,float:Jt.Msg.MIXLY_TOOLTIP_TEXT_TOFLOAT}[t]}))}},cn=an,dn={init:function(){this.setColour(We),this.appendValueInput("VAR").appendField(Jt.Msg.LANG_MATH_BYTE+Jt.Msg.MIXLY_TO_HEX),this.setOutput(!0,Number),this.setTooltip(Jt.Msg.MIXLY_PYTHON_TOOLTIP_TOHEX)}},fn={init:function(){this.setColour(We),this.itemCount_=1,this.setMutator(new Jt.icons.MutatorIcon(["lists_create_with_item"],this)),this.appendDummyInput("DUMMY").appendField(Jt.Msg.MIXLY_PRODUCT+Jt.Msg.MIXLY_GENERATE_CARTESIAN_PRODUCT),this.appendValueInput("REPEAT").appendField(Jt.Msg.MIXLY_EVERY_PER_ELEPER_ELEMENT),this.appendDummyInput().appendField(Jt.Msg.CONTROLS_REPEAT_TITLE_TIMES),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0),this.setTooltip(Jt.Msg.LISTS_CREATE_WITH_PYTHON_TOOLTIP),this.updateShape_()},mutationToDom:function(){var t=document.createElement("mutation");return t.setAttribute("items",this.itemCount_),t},domToMutation:function(t){this.itemCount_=parseInt(t.getAttribute("items"),10),this.updateShape_()},decompose:function(t){var e=t.newBlock("lists_create_with_container");e.initSvg();for(var n=e.getInput("STACK").connection,i=0;i1&&"\\"===t.charAt(0)){var e=t.charAt(1);if("0"===e||"b"===e||"f"===e||"n"===e||"r"===e||"t"===e||"\\"===e||"'"===e)return String(t).substring(0,2);if("x"===e&&"0"===t.charAt(2)&&"B"===t.charAt(3))return String(t).substring(0,4)}return String(t).substring(0,1)};const En={init:function(){this.setColour(_n),this.appendDummyInput().appendField(this.newQuote_(!0)).appendField(new Jt.FieldTextInput("",Jt.FieldTextInput.char_validator),"TEXT").appendField(this.newQuote_(!1)),this.setOutput(!0,Number),this.setTooltip(Jt.Msg.TEXT_CHAR_TOOLTIP)},newQuote_:function(t){if(1==t)var e="../../media/quote2.png";else e="../../media/quote3.png";return new Jt.FieldImage(e,7,12,'"')}},bn={init:function(){this.setColour(_n),this.appendValueInput("A").setCheck([String,Number]),this.appendValueInput("B").setCheck([String,Number]).appendField(Jt.Msg.MIXLY_TEXT_JOIN),this.setInputsInline(!0),this.setOutput(!0,String),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_TEXT_JOIN)}},vn={init:function(){this.setColour(_n),this.appendValueInput("VAR").setCheck(Number).appendField(Jt.Msg.MIXLY_TOCHAR),this.setOutput(!0,String),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_TEXT_TOCHAR)}},wn={init:function(){this.setColour(_n),this.appendValueInput("VAR").setCheck(String).appendField(Jt.Msg.MIXLY_TOASCII),this.setOutput(!0,Number),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_TEXT_TOASCII)}},Sn={init:function(){this.setColour(_n),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_TOSTRING),this.setOutput(!0,String),this.setTooltip(Jt.Msg.MIXLY_PYTHON_TOOLTIP_TOTEXT)}},xn={init:function(){this.setColour(_n),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_LENGTH),this.setOutput(!0,Number),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_TEXT_LENGTH)}},Rn={init:function(){this.WHERE_OPTIONS=[[Jt.Msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[Jt.Msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[Jt.Msg.TEXT_GET_INDEX_RANDOM+1+Jt.Msg.TEXT_CHARAT2,"RANDOM"]],this.setHelpUrl(Jt.Msg.LISTS_GET_INDEX_HELPURL),this.setColour(_n),this.appendValueInput("VAR").setCheck(String),this.appendValueInput("AT").setCheck(Number),this.appendDummyInput().appendField(Jt.Msg.LISTS_GET_INDEX_GET,"MODE"),Jt.Msg.LISTS_GET_INDEX_TAIL&&this.appendDummyInput("TAIL").appendField(Jt.Msg.LISTS_GET_INDEX_TAIL),this.setInputsInline(!0),this.setOutput(!0),this.updateAt_(!0);var t=this;this.setTooltip((function(){var e=t.getFieldValue("MODE"),n=t.getFieldValue("WHERE"),i="";switch(e+" "+n){case"GET FROM_START":case"GET FROM_END":i=Jt.Msg.LISTS_GET_INDEX_TOOLTIP_GET_FROM;break;case"GET RANDOM":i=Jt.Msg.LISTS_GET_INDEX_TOOLTIP_GET_RANDOM;break;case"GET_REMOVE FROM_START":case"GET_REMOVE FROM_END":i=Jt.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FROM;break;case"GET_REMOVE RANDOM":i=Jt.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_RANDOM}return"FROM_START"!=n&&"FROM_END"!=n||(i+=" "+Jt.Msg.LISTS_INDEX_FROM_START_TOOLTIP.replace("%1",Jt.Msg.ONE_BASED_INDEXING?"#1":"#0")),i}));var e=this;this.setTooltip((function(){var t=e.getFieldValue("WHERE"),n={FROM_START:Jt.Msg.LISTS_GET_INDEX_FROM_START,FROM_END:Jt.Msg.LISTS_GET_INDEX_FROM_END,RANDOM:Jt.Msg.TEXT_GET_INDEX_RANDOM};return Jt.Msg.PROCEDURES_DEFRETURN_RETURN+Jt.Msg.MIXLY_MICROBIT_TYPE_STRING+n[t]+"n"+Jt.Msg.TEXT_CHARAT2}))},mutationToDom:function(){var t=document.createElement("mutation");t.setAttribute("statement",!this.outputConnection);var e=this.getInput("AT").type==Jt.INPUT_VALUE;return t.setAttribute("at",e),t},domToMutation:function(t){var e="true"==t.getAttribute("statement");this.updateStatement_(e),t="false"!=t.getAttribute("at"),this.updateAt_(t)},updateStatement_:function(t){t!=!this.outputConnection&&(this.unplug(!0,!0),t?(this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0)):(this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0)))},updateAt_:function(t){this.removeInput("AT"),this.removeInput("ORDINAL",!0),t?(this.appendValueInput("AT").setCheck(Number),Jt.Msg.TEXT_CHARAT2&&this.appendDummyInput("ORDINAL").appendField(Jt.Msg.TEXT_CHARAT2)):this.appendDummyInput("AT");var e=new Jt.FieldDropdown(this.WHERE_OPTIONS,(function(e){var n="FROM_START"==e||"FROM_END"==e;if(n!=t){var i=this.sourceBlock_;return i.updateAt_(n),i.setFieldValue(e,"WHERE"),null}}));this.getInput("AT").appendField(e,"WHERE"),Jt.Msg.LISTS_GET_INDEX_TAIL&&this.moveInputBefore("TAIL",null)}},An={init:function(){this.setHelpUrl(Jt.Msg.LISTS_GET_INDEX_HELPURL),this.setColour(_n),this.appendValueInput("VAR").setCheck(String),this.appendValueInput("AT").setCheck(Number).appendField(Jt.Msg.LISTS_GET_INDEX_GET+" "+Jt.Msg.LISTS_GET_INDEX_FROM_START),this.appendDummyInput().appendField(Jt.Msg.TEXT_CHARAT2),this.setOutput(!0),this.setTooltip(Jt.Msg.PROCEDURES_DEFRETURN_RETURN+Jt.Msg.MIXLY_MICROBIT_TYPE_STRING+Jt.Msg.LISTS_GET_INDEX_FROM_START+"n"+Jt.Msg.TEXT_CHARAT2)}},On={init:function(){this.setHelpUrl(Jt.Msg.LISTS_GET_INDEX_HELPURL),this.setColour(_n),this.appendValueInput("VAR").setCheck(String),this.appendDummyInput().appendField(Jt.Msg.TEXT_RANDOM_CHAR),this.setOutput(!0),this.setTooltip(Jt.Msg.TEXT_RANDOM_CHAR_TOOLTIP)}},Mn={init:function(){this.WHERE_OPTIONS_1=[[Jt.Msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[Jt.Msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[Jt.Msg.LISTS_GET_SUBLIST_START_FIRST,"FIRST"]],this.WHERE_OPTIONS_2=[[Jt.Msg.LISTS_GET_SUBLIST_END_FROM_START,"FROM_START"],[Jt.Msg.LISTS_GET_SUBLIST_END_FROM_END,"FROM_END"],[Jt.Msg.LISTS_GET_SUBLIST_END_LAST,"LAST"]],this.setHelpUrl(Jt.Msg.LISTS_GET_SUBLIST_HELPURL),this.setColour(_n),this.appendValueInput("VAR").setCheck(String),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET),this.appendDummyInput("AT1"),this.appendDummyInput("AT2"),this.setInputsInline(!0),this.setOutput(!0,"List"),this.updateAt_(1,!0),this.updateAt_(2,!0),this.setTooltip(Jt.Msg._GET_TEXT_SUBLIST_TOOLTIP)},mutationToDom:function(){var t=document.createElement("mutation"),e=this.getInput("AT1").type==Jt.INPUT_VALUE;t.setAttribute("at1",e);var n=this.getInput("AT2").type==Jt.INPUT_VALUE;return t.setAttribute("at2",n),t},domToMutation:function(t){var e="true"==t.getAttribute("at1"),n="true"==t.getAttribute("at2");this.updateAt_(1,e),this.updateAt_(2,n)},updateAt_:function(t,e){this.removeInput("AT"+t),this.removeInput("ORDINAL"+t,!0),e?(this.appendValueInput("AT"+t).setCheck(Number),Jt.Msg.TEXT_CHARAT2&&this.appendDummyInput("ORDINAL"+t).appendField(Jt.Msg.TEXT_CHARAT2)):this.appendDummyInput("AT"+t);var n=new Jt.FieldDropdown(this["WHERE_OPTIONS_"+t],(function(n){var i="FROM_START"==n||"FROM_END"==n;if(i!=e){var s=this.sourceBlock_;return s.updateAt_(t,i),s.setFieldValue(n,"WHERE"+t),null}}));this.getInput("AT"+t).appendField(n,"WHERE"+t),1==t&&(this.moveInputBefore("AT1","AT2"),this.getInput("ORDINAL1")&&this.moveInputBefore("ORDINAL1","AT2"))}},Cn={init:function(){this.setHelpUrl(Jt.Msg.LISTS_GET_SUBLIST_HELPURL),this.setColour(_n),this.appendValueInput("VAR").setCheck(String),this.appendValueInput("AT1").appendField(Jt.Msg.LISTS_GET_INDEX_GET+" "+Jt.Msg.LISTS_GET_INDEX_FROM_START),this.appendValueInput("AT2").appendField(Jt.Msg.LISTS_GET_SUBLIST_END_FROM_START),this.appendDummyInput().appendField(Jt.Msg.TEXT_CHARAT2),this.setInputsInline(!0),this.setOutput(!0,["List",String]),this.setTooltip(Jt.Msg._GET_TEXT_SUBLIST_TOOLTIP)}},Nn={init:function(){var t=[[Jt.Msg.MIXLY_EQUALS,"==="],[Jt.Msg.MIXLY_STARTSWITH,"startswith"],[Jt.Msg.MIXLY_ENDSWITH,"endswith"]];this.setColour(_n),this.appendValueInput("STR1").setCheck(String),this.appendValueInput("STR2").appendField(new Jt.FieldDropdown(t),"DOWHAT").setCheck(String),this.setOutput(!0,[Boolean,Number]),this.setInputsInline(!0)}},kn={init:function(){this.setColour(_n),this.appendValueInput("STR1").setCheck(String),this.appendValueInput("STR2").appendField(Jt.Msg.MIXLY_COMPARETO).setCheck(String),this.setOutput(!0,Number),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_COMPARETO_HELP)}},Dn={init:function(){var t=[[Jt.Msg.TEXT_UPPER,"upper"],[Jt.Msg.TEXT_TITLE,"title"],[Jt.Msg.TEXT_CAPITALIZE,"capitalize"],[Jt.Msg.TEXT_SWAPCASE,"swapcase"],[Jt.Msg.TEXT_LOWER,"lower"]];this.setColour(_n),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET).appendField(new Jt.FieldDropdown(t),"CAPITAL").setCheck(String),this.setOutput(!0,String);var e=this;this.setTooltip((function(){var t=e.getFieldValue("CAPITAL");return{upper:Jt.Msg.MIXLY_MIXPY_TEXT_UPPER_TOOLTIP,title:Jt.Msg.MIXLY_MIXPY_TEXT_TITLE_TOOLTIP,swapcase:Jt.Msg.MIXLY_MIXPY_TEXT_SWAPCASE_TOOLTIP,capitalize:Jt.Msg.MIXLY_MIXPY_TEXT_CAPITALIZE_TOOLTIP,lower:Jt.Msg.MIXLY_MIXPY_TEXT_LOWER_TOOLTIP}[t]}))}},Ln={init:function(){var t=[[Jt.Msg.TEXT_LJUST,"ljust"],[Jt.Msg.TEXT_CENTER,"center"],[Jt.Msg.TEXT_RJUST,"rjust"]];this.setColour(_n),this.appendValueInput("VAR").appendField(new Jt.FieldDropdown(t),"CENTER").setCheck(String),this.appendValueInput("WID").appendField(Jt.Msg.MIXLY_WIDTH).setCheck(Number),this.appendValueInput("Symbol").appendField(Jt.Msg.MIXLY_RECT_Fill).setCheck(String),this.setInputsInline(!0),this.setOutput(!0,String),this.setTooltip(Jt.Msg.MIXLY_MIXPY_TEXT_CENTER_TOOLTIP)}},Fn={init:function(){this.setColour(_n),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET).setCheck(String),this.appendValueInput("STR").appendField(Jt.Msg.MIXLY_MID+Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_CHARACTER).setCheck(String),this.appendDummyInput().appendField(Jt.Msg.MIXLY_LIST_INDEX),this.setInputsInline(!0),this.setOutput(!0,String),this.setTooltip(Jt.Msg.MIXLY_MIXPY_TEXT_FIND_TOOLTIP)}},Pn={init:function(){this.setColour(_n),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_PYTHON_TEXT_JOIN_SEQ_USE_STR).setCheck(String),this.appendValueInput("LIST").appendField(Jt.Msg.MIXLY_PYTHON_TEXT_JOIN_SEQ_SEQ).setCheck("List","Tuple","Set","Dict"),this.appendDummyInput().appendField(Jt.Msg.MIXLY_PYTHON_TEXT_JOIN_SEQ_GET_STR),this.setInputsInline(!0),this.setOutput(!0,String),this.setTooltip(Jt.Msg.MIXLY_PYTHON_TEXT_JOIN_SEQ_TOOLTIP)}},$n={init:function(){this.setColour(_n),this.appendValueInput("VAR").setCheck(String),this.appendValueInput("STR1").appendField(Jt.Msg.MIXLY_MIXPY_REPLACE).setCheck(String),this.appendValueInput("STR2").appendField(Jt.Msg.LISTS_SET_INDEX_INPUT_TO).setCheck(String),this.setInputsInline(!0),this.setOutput(!0,String),this.setTooltip(Jt.Msg.MIXLY_MIXPY_TEXT_REPLACE_TOOLTIP)}},Bn={init:function(){this.setColour(_n),this.appendValueInput("VAR"),this.appendValueInput("VAL").appendField(Jt.Msg.LIST_SPLIT_AS),this.appendDummyInput("").appendField(Jt.Msg.LIST_SPLIT),this.setOutput(!0,"List"),this.setTooltip(Jt.Msg.MIXLY_MIXPY_TEXT_SPLIT_TOOLTIP),this.setInputsInline(!0)}},Vn={init:function(){var t=[[Jt.Msg.TEXT_TRIM_BOTH,"strip"],[Jt.Msg.TEXT_TRIM_LEFT,"lstrip"],[Jt.Msg.TEXT_TRIM_RIGHT,"rstrip"]];this.setColour(_n),this.appendValueInput("VAR"),this.appendDummyInput("").appendField(Jt.Msg.TEXT_STRIM),this.appendDummyInput("").appendField(new Jt.FieldDropdown(t),"TOWHAT"),this.appendDummyInput("").appendField(Jt.Msg.TEXT_BLANK),this.setOutput(!0,String),this.setInputsInline(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("TOWHAT");return{strip:Jt.Msg.TEXT_TRIM_BOTH_TOOLTIP,lstrip:Jt.Msg.TEXT_TRIM_LEFT_TOOLTIP,rstrip:Jt.Msg.TEXT_TRIM_RIGHT_TOOLTIP}[t]}))}},Un={init:function(){this.setColour(_n),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_MICROPYTHON_FORMAT),this.appendDummyInput("").appendField(new Jt.FieldTextInput("str"),"VAR"),this.itemCount_=1,this.updateShape_(),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setInputsInline(!0),this.setMutator(new Jt.icons.MutatorIcon(["text_create_with_item"],this)),this.setOutput(!0),this.setTooltip(Jt.Msg.MIXLY_MIXPY_TEXT_FORMAT_TOOLTIP)},mutationToDom:function(){var t=document.createElement("mutation");return t.setAttribute("items",this.itemCount_),t},domToMutation:function(t){this.itemCount_=parseInt(t.getAttribute("items"),10),this.updateShape_()},decompose:function(t){var e=t.newBlock("text_create_with_container");e.initSvg();for(var n=e.getInput("STACK").connection,i=0;ie?t[e]:0==e?'"key"':'"key'+(e+1)+'"'),"KEY"+e).appendField(":")}},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},Pi={init:function(){this.setColour(Li),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_TYPE_DICT),this.appendStatementInput("STACK"),this.setTooltip(Jt.Msg.DICTS_CREATE_WITH_CONTAINER_TOOLTIP),this.contextMenu=!1}},$i={init:function(){this.setColour(Li),this.appendDummyInput().appendField(Jt.Msg.DICTS_CREATE_WITH_ITEM_TITLE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.DICTS_CREATE_WITH_ITEM_TOOLTIP),this.contextMenu=!1}},Bi={init:function(){this.setColour(Li),this.appendValueInput("DICT").setCheck("Dict"),this.appendDummyInput("").appendField(Jt.Msg.DICT_KEYS),this.setTooltip(Jt.Msg.DICTS_KEYS_TOOLTIP),this.setOutput(!0,"List")}},Vi={init:function(){this.setColour(Li),this.appendValueInput("DICT").setCheck("Dict"),this.appendValueInput("KEY").appendField(Jt.Msg.DICTS_GET_IN),this.appendDummyInput("").appendField(Jt.Msg.DICTS_ADD_VALUE),this.setOutput(!0),this.setTooltip(Jt.Msg.DICTS_GET_TOOLTIP)}},Ui={init:function(){this.setColour(Li),this.appendValueInput("DICT").setCheck("Dict"),this.appendValueInput("KEY").appendField(Jt.Msg.DICTS_GET_IN),this.appendDummyInput("").appendField(Jt.Msg.DICTS_ADD_VALUE),this.appendValueInput("VAR").appendField(Jt.Msg.DICTS_DEFAULT_VALUE),this.setOutput(!0),this.setTooltip(Jt.Msg.DICTS_GET_DEFAULT_TOOLTIP)}},Yi={init:function(){this.setColour(Li),this.appendValueInput("DICT"),this.appendValueInput("KEY").appendField(Jt.Msg.DICTS_ADD),this.appendDummyInput(),this.appendValueInput("VAR").appendField(Jt.Msg.DICTS_ADD_VALUE),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.DICTS_ADD_OR_CHANGE_TOOLTIP)}},Gi={init:function(){this.setColour(Li),this.appendValueInput("DICT"),this.appendValueInput("KEY").appendField(Jt.Msg.DICTS_DELETE_IN),this.appendDummyInput("").appendField(Jt.Msg.DICTS_DELETE_VALUE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.DICTS_DELETE_TOOLTIP)}},Hi={init:function(){this.setColour(Li),this.appendValueInput("DICT2").setCheck("Dict").appendField(Jt.Msg.MAKE_DICT),this.appendValueInput("DICT").setCheck("Dict").appendField(Jt.Msg.DICT_UPDATE),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_MID),this.setTooltip(Jt.Msg.DICTS_UPDATE_TOOLTIP),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Wi={init:function(){this.setColour(Li),this.appendValueInput("DICT").setCheck("Dict"),this.appendDummyInput("").appendField(Jt.Msg.DICT_CLEAR),this.setTooltip(Jt.Msg.DICTS_CLEAR_TOOLTIP),this.setPreviousStatement(!0),this.setNextStatement(!0)}},zi={init:function(){this.setColour(Li),this.appendValueInput("DICT").setCheck("Dict"),this.appendDummyInput("").appendField(Jt.Msg.DICT_ITEMS),this.setTooltip(Jt.Msg.DICTS_ITEMS_TOOLTIP),this.setOutput(!0,"List")}},Xi={init:function(){this.setColour(Li),this.appendValueInput("DICT").setCheck("Dict"),this.appendDummyInput("").appendField(Jt.Msg.DICT_VALUES),this.setTooltip(Jt.Msg.DICTS_VALUES_TOOLTIP),this.setOutput(!0,"List")}},ji={init:function(){this.setColour(Li),this.appendValueInput("DICT").setCheck("Dict"),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_LENGTH),this.setTooltip(Jt.Msg.DICT_LENGTH_TOOLTIP),this.setOutput(!0,Number)}},qi={init:function(){this.setColour(Li),this.appendValueInput("DICT").setCheck("Dict"),this.appendDummyInput("").appendField(Jt.Msg.DICT_DELDICT),this.setTooltip(Jt.Msg.DICTS_DEL_TOOLTIP),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Ki={init:function(){this.MODE=[[Jt.Msg.DICTS_ADD_OR_CHANGE,"INSERT"],[Jt.Msg.MIXLY_MICROBIT_JS_DELETE_VAR,"DELETE"]],this.setHelpUrl(Jt.Msg.LISTS_GET_SUBLIST_HELPURL),this.setColour(Li),this.appendValueInput("DICT").setCheck("Dict"),this.appendDummyInput("AT2"),this.appendValueInput("KEY"),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_MICROPYTHON_SOCKET_MAKE).appendField(Jt.Msg.DICTS_ADD_VALUE),this.updateAt_(!0),this.setInputsInline(!0),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0);var t=this;this.setTooltip((function(){var e="";switch(t.getFieldValue("WHERE")){case"INSERT":e=Jt.Msg.DICTS_ADD_TOOLTIP;break;case"DELETE":e=Jt.Msg.DICTS_DELETE_TOOLTIP}return e}))},mutationToDom:function(){var t=document.createElement("mutation"),e=this.getInput("AT2").type==Jt.INPUT_VALUE;return t.setAttribute("at2",e),t},domToMutation:function(t){var e="true"==t.getAttribute("at2");this.updateAt_(e)},updateAt_:function(t){this.removeInput("AT2"),this.removeInput("ORDINAL",!0),t?this.appendValueInput("AT2").setCheck(Number):this.appendDummyInput("AT2");var e=new Jt.FieldDropdown(this.MODE,(function(e){var n="INSERT"==e;if(n!=t){var i=this.sourceBlock_;return i.updateAt_(n),i.setFieldValue(e,"WHERE"),null}}));this.getInput("AT2").appendField(e,"WHERE")}},Qi={init:function(){this.setColour(Li),this.appendValueInput("DICT").setCheck("Dict"),this.appendDummyInput("").appendField(Jt.Msg.blockpy_DICT_POP),this.appendValueInput("KEY"),this.appendDummyInput("").appendField(Jt.Msg.DICTS_ADD_VALUE),this.setTooltip(Jt.Msg.DICT_POP_TOOLTIP),this.setInputsInline(!0),this.setOutput(!0)}},Ji={init:function(){this.setColour(Li),this.appendValueInput("DICT").setCheck("Dict"),this.appendValueInput("KEY").appendField(Jt.Msg.DICTS_SET_DEFAULT),this.appendDummyInput("").appendField(Jt.Msg.DICTS_DEFAULT_VALUE),this.appendValueInput("VAR"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.DICTS_SETDEFAULT_TOOLTIP)}},Zi={init:function(){this.setColour(Li),this.appendDummyInput("").appendField(new Jt.FieldLabel(Jt.Msg.MIXLY_MICROBIT_TYPE_DICT),"TIP").appendField(" "),this.itemCount_=3,this.updateShape_(),this.setOutput(!0,"Dict"),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setMutator(new Jt.icons.MutatorIcon(["dicts_create_with_item"],this)),this.setTooltip(Jt.Msg.DICTS_CREATE_WITH_TOOLTIP)},mutationToDom:function(){var t=document.createElement("mutation");return t.setAttribute("items",this.itemCount_),t},domToMutation:function(t){this.itemCount_=parseInt(t.getAttribute("items"),10),this.updateShape_()},decompose:function(t){var e=t.newBlock("dicts_create_with_container");e.initSvg();for(var n=e.getInput("STACK").connection,i=0;ie?t[e]:0==e?'"key"':'"key'+(e+1)+'"'),"KEY"+e).appendField(":")}},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},ts={init:function(){this.setColour(Li),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_TODICT),this.setOutput(!0),this.setTooltip(Jt.Msg.MIXLY_PYTHON_TOOLTIP_TODICT)}},es={init:function(){this.setColour(Li),this.appendValueInput("DICT").setCheck("Dict"),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_TO_JSON),this.setTooltip(Jt.Msg.MIXLY_TO_JSON_TOOLTIP),this.setOutput(!0)}},ns={init:function(){this.setColour(Li),this.appendValueInput("VAR"),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_CONVERT_TO_JSON),this.setTooltip(Jt.Msg.MIXLY_CONVERT_TO_JSON_TOOLTIP),this.setOutput(!0)}},is={init:function(){this.setColour(Li),this.appendValueInput("DICT").setCheck("Dict"),this.appendValueInput("VAR1").appendField("key1"),this.appendValueInput("VAR2").appendField("index"),this.appendValueInput("VAR3").appendField("key2"),this.appendValueInput("VAR4").appendField("key3"),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_CONVERT_TO_JSON_TOOLTIP),this.setOutput(!0)}},ss={init:function(){this.setColour(Li),this.appendValueInput("DICT"),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_TO_JSON),this.setTooltip(Jt.Msg.MIXLY_TO_JSON_TOOLTIP),this.setOutput(!0)}},rs=210,as={init:function(){var t=Jt.RTL?[["=","EQ"],["≠","NEQ"],[">","LT"],["≥","LTE"],["<","GT"],["≤","GTE"]]:[["=","EQ"],["≠","NEQ"],["<","LT"],["≤","LTE"],[">","GT"],["≥","GTE"]];this.setColour(rs),this.setOutput(!0,Boolean),this.appendValueInput("A"),this.appendValueInput("B").appendField(new Jt.FieldDropdown(t),"OP"),this.setInputsInline(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("OP");return{EQ:Jt.Msg.LOGIC_COMPARE_TOOLTIP_EQ,NEQ:Jt.Msg.LOGIC_COMPARE_TOOLTIP_NEQ,LT:Jt.Msg.LOGIC_COMPARE_TOOLTIP_LT,LTE:Jt.Msg.LOGIC_COMPARE_TOOLTIP_LTE,GT:Jt.Msg.LOGIC_COMPARE_TOOLTIP_GT,GTE:Jt.Msg.LOGIC_COMPARE_TOOLTIP_GTE}[t]})),this.prevBlocks_=[null,null]}},os={init:function(){var t=Jt.RTL?[[">","LT"],["≥","LTE"],["<","GT"],["≤","GTE"]]:[["<","LT"],["≤","LTE"],[">","GT"],["≥","GTE"]],e=Jt.RTL?[[">","LT"],["≥","LTE"],["<","GT"],["≤","GTE"]]:[["<","LT"],["≤","LTE"],[">","GT"],["≥","GTE"]];this.setColour(rs),this.setOutput(!0,Boolean),this.appendValueInput("A"),this.appendValueInput("B").appendField(new Jt.FieldDropdown(t),"OP1"),this.appendValueInput("C").appendField(new Jt.FieldDropdown(e),"OP2"),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_PYTHON_LOGIC_COMPARE_CONTINOUS_TOOLTIP)}},ls={init:function(){var t=[[Jt.Msg.LOGIC_OPERATION_AND,"AND"],[Jt.Msg.LOGIC_OPERATION_OR,"OR"],[Jt.Msg.LOGIC_OPERATION_NOR,"NOR"],[Jt.Msg.LOGIC_OPERATION_XOR,"XOR"]];this.setColour(rs),this.setOutput(!0,Boolean),this.appendValueInput("A").setCheck([Boolean,Number]),this.appendValueInput("B").setCheck([Boolean,Number]).appendField(new Jt.FieldDropdown(t),"OP"),this.setInputsInline(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("OP");return{AND:Jt.Msg.LOGIC_OPERATION_TOOLTIP_AND,OR:Jt.Msg.LOGIC_OPERATION_TOOLTIP_OR,NOR:Jt.Msg.LOGIC_OPERATION_TOOLTIP_NOR,XOR:Jt.Msg.LOGIC_OPERATION_TOOLTIP_XOR}[t]}))}},us={init:function(){this.setColour(rs),this.setOutput(!0,Boolean),this.appendValueInput("BOOL").setCheck([Number,Boolean]).appendField(Jt.Msg.LOGIC_NEGATE_TITLE),this.setTooltip(Jt.Msg.LOGIC_NEGATE_TOOLTIP)}},hs={init:function(){var t=[[Jt.Msg.LOGIC_BOOLEAN_TRUE,"TRUE"],[Jt.Msg.LOGIC_BOOLEAN_FALSE,"FALSE"]];this.setColour(rs),this.setOutput(!0,Boolean),this.appendDummyInput().appendField(new Jt.FieldDropdown(t),"BOOL"),this.setTooltip(Jt.Msg.LOGIC_BOOLEAN_TOOLTIP)}},ps={init:function(){this.setColour(rs),this.setOutput(!0),this.appendDummyInput().appendField(Jt.Msg.LOGIC_NULL),this.setTooltip(Jt.Msg.LOGIC_NULL_TOOLTIP)}},cs={init:function(){this.setColour(rs),this.appendValueInput("A"),this.appendValueInput("B").appendField(Jt.Msg.LOGIC_TERNARY_IF_TRUE),this.appendValueInput("C").appendField(Jt.Msg.LOGIC_TERNARY_IF_FALSE),this.setOutput(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_LOGIT_TRUEORFALSE)}},ds={init:function(){var t=[[Jt.Msg.TEXT_APPEND_TO,"in"],[Jt.Msg.MIXLY_PYTHON_LOGIC_IS_NOT_IN,"not in"]];this.setColour(rs),this.appendValueInput("A"),this.appendValueInput("B").setCheck([String,"List"]).appendField(new Jt.FieldDropdown(t),"BOOL"),this.appendDummyInput("").appendField(Jt.Msg.MICROBIT_LOGIC_IS_IN),this.setOutput(!0,Boolean),this.setInputsInline(!0),this.setTooltip(Jt.Msg.IN)}},fs={init:function(){var t=[[Jt.Msg.MIXLY_PYTHON_LOGIC_IS,"is"],[Jt.Msg.MIXLY_PYTHON_LOGIC_IS_NOT,"is not"]];this.setColour(rs),this.appendValueInput("A"),this.appendValueInput("B").appendField(new Jt.FieldDropdown(t),"BOOL"),this.setOutput(!0,Boolean),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_PYTHON_LOGIC_IS_TOOLTIP)}},ms={init:function(){this.setColour(rs),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_TOBOOL),this.setOutput(!0,Boolean),this.setTooltip(Jt.Msg.MIXLY_PYTHON_TOOLTIP_TOBOOL)}},gs={init:function(){this.setColour(0),this.appendValueInput("fn").setCheck(String).appendField(Jt.Msg.MIXLY_PYTHON_STORAGE_OPEN_FILE_WITH_OS+"(For Windows)"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0)}},_s={init:function(){this.setColour(0),this.appendValueInput("FILENAME").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_OPEN_FILE),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_MODE).appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_READ,"r"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_WRITE,"w"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_BIT_READ,"rb"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_BIT_WRITE,"wb"],[Jt.Msg.MIXLY_ADD,"a"],[Jt.Msg.MATH_BIN+Jt.Msg.MIXLY_ADD,"ab"],[Jt.Msg.MIXLY_R_W,"r+"],[Jt.Msg.MATH_BIN+Jt.Msg.MIXLY_R_W,"rb+"],[Jt.Msg.MIXLY_W_R,"w+"],[Jt.Msg.MATH_BIN+Jt.Msg.MIXLY_W_R,"wb+"],[Jt.Msg.MIXLY_A_R,"a+"],[Jt.Msg.MATH_BIN+Jt.Msg.MIXLY_A_R,"ab+"]]),"MODE"),this.appendValueInput("FILE").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_AS),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0);var t=this;this.setTooltip((function(){var e=t.getFieldValue("MODE"),n=Jt.Msg.MIXLY_USE,i=Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_MODE,s=Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_OPEN_FILE,r=Jt.Msg.MIXLY_BELONG;return n+{r:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_READ,w:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_WRITE,rb:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_BIT_READ,wb:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_BIT_WRITE}[e]+r+i+s}))},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},Ts={init:function(){this.setColour(0),this.appendValueInput("FILENAME").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_OPEN_FILE),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_MODE).appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_READ,"r"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_WRITE,"w"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_BIT_READ,"rb"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_BIT_WRITE,"wb"]]),"MODE"),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setInputsInline(!0),this.setOutput(!0);var t=this;this.setTooltip((function(){var e=t.getFieldValue("MODE"),n=Jt.Msg.MIXLY_USE,i=Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_MODE,s=Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_OPEN_FILE,r=Jt.Msg.MIXLY_BELONG,a=Jt.Msg.PY_STORAGE_FILE_OBJECT;return n+{r:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_READ,w:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_WRITE,rb:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_BIT_READ,wb:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_BIT_WRITE}[e]+r+i+s+a}))}},ys={init:function(){this.setColour(0),this.appendValueInput("FILENAME").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_OPEN_FILE);this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_MODE).appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_READ,"r"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_WRITE,"w"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_BIT_READ,"rb"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_BIT_WRITE,"wb"]]),"MODE"),this.appendDummyInput().appendField(Jt.Msg.MIXPY_TEXT_ENCODE).appendField(new Jt.FieldDropdown([["ANSI","ANSI"],["gbk","gbk"],["utf-8","utf-8"]]),"CODE"),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setInputsInline(!0),this.setOutput(!0);var t=this;this.setTooltip((function(){var e=t.getFieldValue("MODE"),n=Jt.Msg.MIXLY_USE,i=Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_MODE,s=Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_OPEN_FILE,r=Jt.Msg.MIXLY_BELONG,a=Jt.Msg.PY_STORAGE_FILE_OBJECT;return n+{r:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_READ,w:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_WRITE,rb:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_BIT_READ,wb:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_BIT_WRITE}[e]+r+i+s+a}))}},Is={init:function(){this.setColour(0),this.appendValueInput("data").setCheck(String).appendField(Jt.Msg.MIXLY_MICROPYTHON_SOCKET_MAKE),this.appendValueInput("FILE").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FILE_WRITE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_MICROPYTHON_SOCKET_MAKE+Jt.Msg.MIXLY_MICROBIT_TYPE_STRING+Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FILE_WRITE)}},Es={init:function(){this.setColour(0),this.appendValueInput("FILE").setCheck("Variable").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FROM_FILE),this.appendDummyInput().appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_ALL,"read"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_ONE_LINE,"readline"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_ALL_LINES,"readlines"]]),"MODE"),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0,String)}},bs={init:function(){this.setColour(0),this.appendValueInput("FILE").setCheck("Variable").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FROM_FILE),this.appendDummyInput().appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_NO_MORE_THAN_SIZE,"read"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_ONE_LINE_NO_MORE_THAN_SIZE,"readline"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_ALL_LINES_NO_MORE_THAN_SIZE,"readlines"]]),"MODE"),this.appendValueInput("SIZE").setCheck(Number),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_CHARACTER),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0,String);var t=this;this.setTooltip((function(){var e=t.getFieldValue("MODE"),n=Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FROM_FILE,i=Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_CHARACTER;return n+{read:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_NO_MORE_THAN_SIZE,readline:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_ONE_LINE_NO_MORE_THAN_SIZE,readlines:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_ALL_LINES_NO_MORE_THAN_SIZE}[e]+"x"+i}))}},vs={init:function(){this.setColour(0),this.appendValueInput("FILE").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FROM_FILE),this.setNextStatement(!0),this.appendValueInput("SIZE").setCheck(Number).appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_ONE_LINE_NO_MORE_THAN_SIZE),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_CHARACTER),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0,String),this.setTooltip(Jt.Msg.MICROBIT_PYTHON_TYPE)}},ws={init:function(){this.setColour(0),this.appendValueInput("FILE").appendField(Jt.Msg.HTML_FILE),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_CAN_WRITE_ORNOT),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0,Boolean),this.setTooltip(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_CAN_WRITE_ORNOT1)}},Ss={init:function(){this.setColour(0),this.appendValueInput("FILE").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FILENAME),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0,String),this.setTooltip(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET_FILENAME)}},xs={init:function(){this.setColour(0),this.appendValueInput("FILE").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_CLOSE_FILE),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setOutput(!1),this.setTooltip(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_CLOSE_FILE)}},Rs={init:function(){this.setColour(0),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_LIST_ALL_FILES),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0,"List"),this.setTooltip(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_LIST_ALL_FILES)}};Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_DELETE_FILE;const As={init:function(){this.setColour(0),this.appendDummyInput().appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_DELETE_FILE,"remove"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_DELETE_DIRS,"removedirs"]]),"MODE"),this.appendValueInput("FILE").setCheck(String),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setOutput(!1),this.setTooltip(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_DELETE_FILE)}},Os={init:function(){this.setColour(0),this.appendValueInput("FILE").setCheck(String).appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET_FILE_SIZE),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_SIZE),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0,Number),this.setTooltip(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET_FILE_SIZE+Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_SIZE)}},Ms={init:function(){this.setColour(0),this.appendValueInput("FILE").setCheck(String).appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_RETURN_FILE),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_PRESENT_LOCATION),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0,Number),this.setTooltip(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FILE_TELL)}},Cs={init:function(){this.setColour(0),this.appendValueInput("FILE").setCheck("Variable").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_SET_FILE_POSITION),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_CURRENT_POSITION),this.appendDummyInput().appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FILE_SEEK_START,"start"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FILE_SEEK_CURRENT,"current"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FILE_SEEK_END,"end"]]),"MODE"),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FILE_SEEK_OFFSET),this.appendValueInput("SIZE").setCheck(Number),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_CHARACTER),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0);var t=this;this.setTooltip((function(){var e=t.getFieldValue("MODE"),n=Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_SET_FILE_POSITION+Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_CURRENT_POSITION,i=Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_CHARACTER,s=Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FILE_SEEK_OFFSET;return n+" "+{start:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FILE_SEEK_START,current:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FILE_SEEK_CURRENT,end:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FILE_SEEK_END}[e]+s+"x"+i}))}},Ns={init:function(){this.setColour(0),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET_CURRENT_DIR),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0,"List"),this.setTooltip(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET_CURRENT_DIR)}},ks={init:function(){this.setColour(0),this.appendValueInput("PATH").setCheck(String).appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_PATH),this.appendDummyInput().appendField(Jt.Msg.MIXLY_ESP32_SET),this.appendDummyInput().appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_MKDIR,"mkdir"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_MAKEDIRS,"makedirs"]]),"MODE"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setOutput(!1);var t=this;this.setTooltip((function(){var e=t.getFieldValue("MODE");return Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_PATH+"x"+Jt.Msg.MIXLY_ESP32_SET+{mkdir:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_MKDIR,makedirs:Jt.Msg.MIXLY_MICROPYTHON_SOCKET_MAKEDIRS}[e]}))}},Ds={init:function(){this.setColour(0),this.appendValueInput("FILE").setCheck(String).appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_RENAME),this.appendValueInput("NEWFILE").setCheck(String).appendField(Jt.Msg.MIXLY_AS),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setOutput(!1),this.setTooltip(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_RENAME)}},Ls={init:function(){this.setColour(0),this.appendValueInput("FILE").setCheck(String).appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_CHANGE_DIR),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setOutput(!1),this.setTooltip(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_CHANGE_DIR)}},Fs={init:function(){this.setColour(0),this.appendValueInput("FILE").setCheck(String).appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_THE_PATH),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_IS_OR_NOT),this.appendDummyInput().appendField(new Jt.FieldDropdown([[Jt.Msg.HTML_FILE,"isfile"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_IS_DIR,"isdir"]]),"MODE"),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0,Boolean);let t=this;this.setTooltip((function(){var e=t.getFieldValue("MODE");return Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_THE_PATH+"x"+Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_IS_OR_NOT+{isfile:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_MKDIR,isdir:Jt.Msg.MIXLY_MICROPYTHON_SOCKET_MAKEDIRS}[e]}))}},Ps={init:function(){this.setColour(0),this.appendValueInput("SPISUB").appendField(Jt.Msg.CONTROLS_FOR_INPUT_WITH+"SPI").setCheck("var"),this.appendValueInput("PINSUB").appendField("CS"),this.appendValueInput("SUB").appendField(Jt.Msg.MIXLY_MICROPYTHON_SOCKET_MAKE).setCheck("var"),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_SETUP+Jt.Msg.LISTS_SET_INDEX_INPUT_TO).appendField(Jt.Msg.MIXLY_SD_CARD),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},$s={init:function(){this.setColour(0),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_SD_CARD),this.appendValueInput("DIR").setCheck(String).appendField(Jt.Msg.MIXLY_SDCARD_MOUNT),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip()}},Bs={init:function(){var t=Jt.Procedures.findLegalName("",this),e=new Jt.FieldTextInput(t,Jt.Procedures.rename);e.setSpellcheck(!1),this.appendDummyInput().appendField(e,"NAME").appendField("","PARAMS"),this.setMutator(new Jt.icons.MutatorIcon(["procedures_mutatorarg"],this)),(this.workspace.options.comments||this.workspace.options.parentWorkspace&&this.workspace.options.parentWorkspace.options.comments)&&Jt.Msg.PROCEDURES_DEFNORETURN_COMMENT&&this.setCommentText(Jt.Msg.PROCEDURES_DEFNORETURN_COMMENT),this.setStyle("procedure_blocks"),this.setTooltip(Jt.Msg.PROCEDURES_DEFNORETURN_TOOLTIP),this.setHelpUrl(Jt.Msg.PROCEDURES_DEFNORETURN_HELPURL),this.arguments_=[],this.argumentVarModels_=[],this.setStatements_(!0),this.statementConnection_=null},setStatements_:function(t){this.hasStatements_!==t&&(t?(this.appendStatementInput("STACK").appendField(Jt.Msg.PROCEDURES_DEFNORETURN_DO),this.getInput("RETURN")&&this.moveInputBefore("STACK","RETURN")):this.removeInput("STACK",!0),this.hasStatements_=t)},updateParams_:function(){var t="";this.arguments_.length&&(t=Jt.Msg.PROCEDURES_BEFORE_PARAMS+" "+this.arguments_.join(", ")),Jt.Events.disable();try{this.setFieldValue(t,"PARAMS")}finally{Jt.Events.enable()}},mutationToDom:function(t){var e=Jt.utils.xml.createElement("mutation");t&&e.setAttribute("name",this.getFieldValue("NAME"));for(var n=0;n"),this.appendValueInput("style").appendField(Jt.Msg.MIXLY_AIP_ATTR).setAlign(Jt.inputs.Align.RIGHT),this.appendStatementInput("DO").appendField(""),this.setInputsInline(!1),this.setPreviousStatement(!0),this.setNextStatement(!0)}},kr={init:function(){this.setColour(Rr),this.appendDummyInput().appendField(Jt.Msg.HTML_STYLE),this.appendStatementInput("STYLE"),this.setOutput(!0)}},Dr={init:function(){this.setColour(Rr),this.appendDummyInput().appendField(Jt.Msg.HTML_FORM_CONTENT).appendField(new Jt.FieldDropdown([[Jt.Msg.HTML_TEXT,"text"],[Jt.Msg.HTML_EMAIL,"email"],[Jt.Msg.HTML_NUMBER,"number"],[Jt.Msg.HTML_PASSWORD,"password"],[Jt.Msg.HTML_CHECKBOX,"checkbox"],[Jt.Msg.HTML_RADIOBUTTON,"radiobutton"],[Jt.Msg.HTML_BUTTON,"button"],[Jt.Msg.HTML_COLOUR,"colour"],[Jt.Msg.HTML_DATE,"date"],[Jt.Msg.HTML_LOCALTIME,"local time"],[Jt.Msg.HTML_FILE,"file"],[Jt.Msg.HTML_HIDDEN,"hidden"],[Jt.Msg.HTML_IMAGE,"image"],[Jt.Msg.HTML_MONTH,"month"],[Jt.Msg.HTML_RANGE,"range"],[Jt.Msg.HTML_RESET,"reset"],[Jt.Msg.HTML_SEARCH,"search"],[Jt.Msg.HTML_SUBMIT,"submit"],[Jt.Msg.HTML_TELEPHONENUMBER,"telephone number"],[Jt.Msg.HTML_TIME,"time"],[Jt.Msg.HTML_URL,"url"],[Jt.Msg.HTML_WEEK,"week"]]),"LEVEL"),this.appendDummyInput().appendField(Jt.Msg.HTML_NAME).appendField(new Jt.FieldTextInput("car"),"NAME"),this.appendDummyInput().appendField(Jt.Msg.HTML_VALUE).appendField(new Jt.FieldTextInput("go"),"VALUE"),this.appendValueInput("style").appendField(Jt.Msg.MIXLY_AIP_ATTR).setAlign(Jt.inputs.Align.RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Lr={init:function(){this.setColour(Rr),this.appendDummyInput().appendField(new Jt.FieldTextInput("property"),"KEY").appendField(":").appendField(new Jt.FieldTextInput("value"),"VALUE"),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Fr={init:function(){this.setColour(Rr),this.appendDummyInput().appendField(new Jt.FieldTextInput("property"),"KEY").appendField(":").appendField(new Jt.FieldColour("#ff0000"),"RGB_LED_COLOR"),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Pr={init:function(){this.setColour(Rr),this.appendDummyInput().appendField(Jt.Msg.HTML_TEXT).appendField(new Jt.FieldTextInput("text"),"TEXT"),this.setPreviousStatement(!0),this.setNextStatement(!0)}},$r=160,Br={init:function(){this.setColour($r),this.setPreviousStatement(!0),this.setNextStatement(!0),this.appendDummyInput().appendField("Tabular Abstraction:"),this.appendDummyInput().appendField(new Jt.FieldTable(""),"TEXT")}},Vr={init:function(){this.setColour($r),this.setPreviousStatement(!0),this.setNextStatement(!0),this.appendDummyInput().appendField("Code Block:"),this.appendDummyInput().appendField(new Jt.FieldMultilineInput(""),"TEXT")}},Ur={init:function(){this.setColour($r),this.appendDummyInput().appendField("Code Expression:"),this.appendDummyInput().appendField(new Jt.FieldMultilineInput(""),"TEXT"),this.setOutput(!0)}},Yr={init:function(){this.setColour($r),this.setPreviousStatement(!0),this.setNextStatement(!0),this.appendValueInput("VALUE").appendField(""),this.setInputsInline(!1)}},Gr={init:function(){this.setColour($r),this.appendDummyInput().appendTitle("Comment:").appendTitle(new Jt.FieldTextInput(""),"TEXT"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("This comment will be ignored by Python")}},Hr={init:function(){this.setColour($r),this.appendValueInput("VALUE").appendField(Jt.Msg.TYPE_CHECK),this.setInputsInline(!1),this.setOutput(!0,"Type")}},Wr={init:function(){this.setColour($r),this.itemCount_=1,this.updateShape_(),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setMutator(new Jt.icons.MutatorIcon(["text_print_multiple_item"],this)),this.setTooltip(Jt.Msg.TEXT_PRINT_TOOLTIP)},mutationToDom:function(){var t=document.createElement("mutation");return t.setAttribute("items",this.itemCount_),t},domToMutation:function(t){this.itemCount_=parseInt(t.getAttribute("items"),10),this.updateShape_()},decompose:function(t){var e=Jt.Block.obtain(t,"text_print_multiple_container");e.initSvg();for(var n=e.getInput("STACK").connection,i=0;i= stop:"," yield start"," start -= abs(step)"])};if(t=function(t,e,n){return"("+t+" <= "+e+") and "+l()+"("+t+", "+e+", "+n+") or "+u()+"("+t+", "+e+", "+n+")"},Jt.isNumber(i)&&Jt.isNumber(s)&&Jt.isNumber(r))i=parseFloat(i),s=parseFloat(s),r=Math.abs(parseFloat(r)),0==i%1&&0==s%1&&0==r%1?(i<=s?(s++,t=0==i&&1==r?s:i+", "+s,1!=r&&(t+=", "+r)):t=i+", "+--s+", -"+r,t="range("+t+")"):(t=i",GTE:">="};const Ul=function(t,e){var n=this.getFieldValue("OP"),i="&&"==n?e.ORDER_LOGICAL_AND:e.ORDER_LOGICAL_OR,s=e.valueToCode(this,"A",i)||"False",r=e.valueToCode(this,"B",i)||"False";if("AND"==n)var a=s+" and "+r;else if("OR"==n)a=s+" or "+r;else if("NOR"==n)a="not("+s+"^"+r+")";else a=s+"^"+r;return[a,i]},Yl=function(t,e){var n=e.ORDER_UNARY_PREFIX;return["not "+(e.valueToCode(this,"BOOL",n)||"False"),n]},Gl=function(t,e){return["TRUE"==this.getFieldValue("BOOL")?"True":"False",e.ORDER_ATOMIC]},Hl=function(t,e){return["None",e.ORDER_ATOMIC]},Wl=function(t,e){var n=e.valueToCode(this,"A",e.ORDER_ATOMIC)||"False";return["("+(e.valueToCode(this,"B",e.ORDER_ATOMIC)||"False")+" if "+n+" else "+(e.valueToCode(this,"C",e.ORDER_ATOMIC)||"False")+")",e.ORDER_ATOMIC]},zl=function(t,e){var n=e.valueToCode(this,"A",e.ORDER_ATOMIC)||"''",i=e.valueToCode(this,"B",e.ORDER_ATOMIC)||"''";return[n+" "+this.getFieldValue("BOOL")+" "+i,e.ORDER_ATOMIC]},Xl=function(t,e){var n=e.valueToCode(this,"A",e.ORDER_ATOMIC)||"''",i=e.valueToCode(this,"B",e.ORDER_ATOMIC)||"''";return[n+" "+this.getFieldValue("BOOL")+" "+i,e.ORDER_ATOMIC]},jl=function(t,e){return["bool("+(e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||"0")+")",e.ORDER_ATOMIC]},ql=function(t,e){return e.definitions_.import_os="import os","os.startfile("+e.valueToCode(this,"fn",e.ORDER_ATOMIC)+")\n"},Kl=function(t,e){return e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+" = open("+e.valueToCode(this,"FILENAME",e.ORDER_ATOMIC)+", '"+this.getFieldValue("MODE")+"')\n"},Ql=function(t,e){return["open("+e.valueToCode(this,"FILENAME",e.ORDER_ATOMIC)+", '"+this.getFieldValue("MODE")+"')",e.ORDER_ATOMIC]},Jl=function(t,e){return["open("+e.valueToCode(this,"FILENAME",e.ORDER_ATOMIC)+", '"+this.getFieldValue("MODE")+"', encoding=\""+this.getFieldValue("CODE")+'")',e.ORDER_ATOMIC]},Zl=function(t,e){var n=e.valueToCode(this,"data",e.ORDER_ATOMIC);return e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+".write("+n+")\n"},tu=function(t,e){var n=this.getFieldValue("MODE");return[e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+"."+n+"()",e.ORDER_ATOMIC]},eu=function(t,e){var n=this.getFieldValue("MODE");return[e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+"."+n+"("+e.valueToCode(this,"SIZE",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},nu=function(t,e){return[e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+".readline("+e.valueToCode(this,"SIZE",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},iu=function(t,e){return[e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+".writable()",e.ORDER_ATOMIC]},su=function(t,e){return[e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+".name()",e.ORDER_ATOMIC]},ru=function(t,e){return e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+".close()\n"},au=function(t,e){e.definitions_.import_os="import os";return["os.listdir()",e.ORDER_ATOMIC]},ou=function(t,e){return e.definitions_.import_os="import os","os."+this.getFieldValue("MODE")+"("+e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+")\n"},lu=function(t,e){return e.definitions_.import_os="import os",["os.path.getsize("+e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},uu=function(t,e){return[e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+".tell()",e.ORDER_ATOMIC]},hu=function(t,e){var n=this.getFieldValue("MODE"),i=0;return i="start"==n?0:"current"==n?1:2,e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+".seek("+e.valueToCode(this,"SIZE",e.ORDER_ATOMIC)+","+i+")\n"},pu=function(t,e){return e.definitions_.import_os="import os","os.chdir("+e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+")\n"},cu=function(t,e){e.definitions_.import_os="import os";return["os.getcwd()",e.ORDER_ATOMIC]},du=function(t,e){return e.definitions_.import_os="import os","os."+this.getFieldValue("MODE")+"("+e.valueToCode(this,"PATH",e.ORDER_ATOMIC)+")\n"},fu=function(t,e){return e.definitions_.import_os="import os","os.rename("+e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+","+e.valueToCode(this,"NEWFILE",e.ORDER_ATOMIC)+")\n"},mu=function(t,e){e.definitions_.import_os="import os";var n=e.valueToCode(this,"FILE",e.ORDER_ATOMIC);return["os."+this.getFieldValue("MODE")+"("+n+")",e.ORDER_ATOMIC]},gu=function(t,e){return e.definitions_.import_os="import os",e.definitions_.import_sdcard="import sdcard",e.valueToCode(this,"SUB",e.ORDER_ATOMIC)+" = sdcard.SDCard("+e.valueToCode(this,"SPISUB",e.ORDER_ATOMIC)+","+e.valueToCode(this,"PINSUB",e.ORDER_ATOMIC)+")\n"},_u=function(t,e){return e.definitions_.import_os="import os",e.definitions_.import_sdcard="import sdcard","os.mount("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+","+e.valueToCode(this,"DIR",e.ORDER_ATOMIC)+")\n"},Tu=function(t,e){var n=e.variableDB_.getName(this.getFieldValue("NAME"),Jt.Procedures.NAME_TYPE),i=(this.getInput("STACK")&&e.statementToCode(this,"STACK"))??" pass\n";e.INFINITE_LOOP_TRAP&&(i=e.INFINITE_LOOP_TRAP.replace(/%1/g,"'"+this.id+"'")+i);var s=e.valueToCode(this,"RETURN",e.ORDER_NONE)||"";s&&(s=" return "+s+"\n");for(var r=[],a=0;a\n\n\n\t\n"+e.statementToCode(this,"HEAD")+"\n\n"+e.statementToCode(this,"BODY")+"\n\n'''",e.ORDER_ATOMIC]},Zu=function(t,e){var n=e.statementToCode(this,"DO"),i=this.getFieldValue("LEVEL");return"\n"+n+"\n"},th=function(t,e){var n=e.statementToCode(this,"DO"),i=this.getFieldValue("LEVEL");if("head"==i)var s="<"+i+'>\n\t\n'+n+"\n";else s="<"+i+">\n"+n+"\n";return s},eh=function(t,e){var n=e.statementToCode(this,"DO"),i=this.getFieldValue("LEVEL");return"<"+i+">\n"+n+"\n"},nh=function(t,e){var n=e.statementToCode(this,"DO"),i=e.valueToCode(this,"style"),s=this.getFieldValue("LEVEL");return"<"+s+" "+i+" >\n"+n+"\n"},ih=function(t,e){return['style="'+e.statementToCode(this,"STYLE")+'"',e.ORDER_ATOMIC]},sh=function(t,e){return'"},rh=function(){return this.getFieldValue("KEY")+":"+this.getFieldValue("VALUE")+";"},ah=function(){return this.getFieldValue("TEXT")+"\n"},oh=function(t){return t.getFieldValue("TEXT")+"\n"},lh=function(t,e){return[t.getFieldValue("TEXT"),e.ORDER_ATOMIC]},uh=function(t,e){return(e.valueToCode(t,"VALUE",e.ORDER_ATOMIC)||"")+"\n"},hh=function(){return""},ph=function(t,e){return["type("+(e.valueToCode(t,"VALUE",e.ORDER_MEMBER)||"___")+")",e.ORDER_ATOMIC]},ch=function(t,e){for(var n=t.getFieldValue("NAME"),i=t.hasReturn_,s=new Array(t.itemCount_),r=0;r0?e.join("\n")+n.join("\n")+i.join("\n")+a.join("\n")+o.join("")+t+"while True:\n"+l.join("")+u.join("\n"):e.join("\n")+n.join("\n")+i.join("\n")+a.join("\n")+o.join("")+t+u.join("\n")},gh.scrubNakedValue=function(t){return t+"\n"},gh.quote_=function(t){var e="'";return-1!==t.indexOf("'")&&(-1===t.indexOf('"')?e='"':t=t.replace(/'/g,"\\'")),e+t+e},gh.multiline_quote_=function(t){return"'''"+(t=t.replace(/'''/g,"\\'\\'\\'"))+"'''"},gh.scrub_=function(t,e,n){var i="";if(!t.outputConnection||!t.outputConnection.targetConnection){(r=t.getCommentText())&&(r=Jt.utils.string.wrap(r,gh.COMMENT_WRAP-3),i+=gh.prefixLines(r+"\n","# "));for(var s=0;s0?"int("+o+" + "+s+")":s<0?"int("+o+" - "+-s+")":"int("+o+")",i&&(o="-"+o)),o};const _h=205,Th={init:function(){this.setColour(_h),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_CHOOSE_AND_GET).appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_CHOOSE_AND_GET_ONE_FILE_NAME,"getOneFile"],[Jt.Msg.MIXLY_CHOOSE_AND_GET_MANY_FILE_NAMES,"getManyFiles"],[Jt.Msg.MIXLY_CHOOSE_AND_GET_DIR,"getDirectory"]]),"TYPE"),this.setInputsInline(!0),this.setOutput(!0)}},yh={init:function(){this.setColour(_h),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_SETUP).appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_AipImageClassify,"AipImageClassify"],[Jt.Msg.MIXLY_AipSpeech,"AipSpeech"],[Jt.Msg.MIXLY_AipImageCensor,"AipImageCensor"],[Jt.Msg.MIXLY_AipFace,"AipFace"],[Jt.Msg.MIXLY_AipOcr,"AipOcr"],[Jt.Msg.MIXLY_AipNlp,"AipNlp"]]),"CTYPE"),this.appendValueInput("SUB").appendField(Jt.Msg.MIXLY_Client).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("API_KEY").appendField("API_KEY").setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("SECRET_KEY").appendField("SECRET_KEY").setAlign(Jt.inputs.Align.RIGHT),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Ih={init:function(){this.setColour(_h),this.appendValueInput("SUB").appendField(Jt.Msg.MIXLY_AipSpeech_synthesis).appendField(Jt.Msg.MIXLY_Client).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("STR").appendField(Jt.Msg.OLED_STRING).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("ATTR").appendField(Jt.Msg.MIXLY_AIP_ATTR).setAlign(Jt.inputs.Align.RIGHT),this.setTooltip(Jt.Msg.MIXLY_AipSpeech_synthesis_TOOLTIP),this.setInputsInline(!1),this.setOutput(!0)}},Eh={init:function(){this.setColour(_h),this.appendValueInput("SUB").appendField(Jt.Msg.MIXLY_AipSpeech_asr).appendField(Jt.Msg.MIXLY_Client).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("FILE").appendField(Jt.Msg.MIXLY_AipSpeech_File).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("ATTR").appendField(Jt.Msg.MIXLY_AIP_ATTR).setAlign(Jt.inputs.Align.RIGHT),this.setTooltip(Jt.Msg.MIXLY_AipSpeech_ASR_TOOLTIP),this.setInputsInline(!1),this.setOutput(!0)}},bh={init:function(){this.setColour(_h),this.appendValueInput("SUB").appendField(Jt.Msg.MIXLY_AipImageClassify).appendField(Jt.Msg.MIXLY_Client).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("FUNC").appendField(Jt.Msg.MIXLY_AIP_FUNC).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("ADDR").appendField(Jt.Msg.MIXLY_AipImageClassify_Image).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("ATTR").appendField(Jt.Msg.MIXLY_AIP_ATTR).setAlign(Jt.inputs.Align.RIGHT),this.setTooltip(Jt.Msg.MIXLY_AipImageClassify_advancedGeneral_TOOLTIP),this.setInputsInline(!1),this.setOutput(!0)}},vh={init:function(){this.setColour(_h),this.appendDummyInput("").appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_AipImageClassify_advancedGeneral,"advancedGeneral"],[Jt.Msg.MIXLY_AipImageClassify_dishDetect,"dishDetect"],[Jt.Msg.MIXLY_AipImageClassify_carDetect,"carDetect"],[Jt.Msg.MIXLY_AipImageClassify_animalDetect,"animalDetect"],[Jt.Msg.MIXLY_AipImageClassify_plantDetect,"plantDetect"],[Jt.Msg.MIXLY_AipImageClassify_logoSearch,"logoSearch"]]),"TYPE"),this.setOutput(!0)}},wh={init:function(){this.setColour(_h),this.appendValueInput("SUB").appendField(Jt.Msg.MIXLY_AipFace_match).appendField(Jt.Msg.MIXLY_Client).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_AipImageClassify_Image+"1"+Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_THE_PATH).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("VAR2").appendField(Jt.Msg.MIXLY_AipImageClassify_Image+"2"+Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_THE_PATH).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("ATTR").appendField(Jt.Msg.MIXLY_AIP_ATTR).setAlign(Jt.inputs.Align.RIGHT),this.setTooltip(Jt.Msg.MIXLY_AipFace_match_TOOLTIP),this.setInputsInline(!1),this.setOutput(!0)}},Sh={init:function(){this.setColour(_h),this.appendValueInput("SUB").appendField(Jt.Msg.MIXLY_AipOcr).appendField(Jt.Msg.MIXLY_Client).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("FUNC").appendField(Jt.Msg.MIXLY_AIP_FUNC).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("ADDR").appendField(Jt.Msg.MIXLY_AipImageClassify_Image).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("ATTR").appendField(Jt.Msg.MIXLY_AIP_ATTR).setAlign(Jt.inputs.Align.RIGHT),this.setTooltip(Jt.Msg.MIXLY_AipOcr_TOOLTIP),this.setInputsInline(!1),this.setOutput(!0)}},xh={init:function(){this.setColour(_h),this.appendDummyInput("").appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_AipOcr_basicGeneral,"basicGeneral"],[Jt.Msg.MIXLY_AipOcr_webImage,"webImage"],[Jt.Msg.MIXLY_AipOcr_idcard,"idcard"],[Jt.Msg.MIXLY_AipOcr_bankcard,"bankcard"],[Jt.Msg.MIXLY_AipOcr_drivingLicense,"drivingLicense"],[Jt.Msg.MIXLY_AipOcr_vehicleLicense,"vehicleLicense"],[Jt.Msg.MIXLY_AipOcr_licensePlate,"licensePlate"],[Jt.Msg.MIXLY_AipOcr_businessLicense,"businessLicense"],[Jt.Msg.MIXLY_AipOcr_receipt,"receipt"],[Jt.Msg.MIXLY_AipOcr_trainTicket,"trainTicket"],[Jt.Msg.MIXLY_AipOcr_taxiReceipt,"taxiReceipt"],[Jt.Msg.MIXLY_AipOcr_form,"tableRecognition"],[Jt.Msg.MIXLY_AipOcr_vatInvoice,"vatInvoice"],[Jt.Msg.MIXLY_AipOcr_passport,"passport"],[Jt.Msg.MIXLY_AipOcr_handwriting,"handwriting"]]),"TYPE"),this.setOutput(!0)}},Rh={init:function(){this.setColour(_h),this.appendValueInput("SUB").appendField(Jt.Msg.MIXLY_AipNlp).appendField(Jt.Msg.MIXLY_Client).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("FUNC").appendField(Jt.Msg.MIXLY_AIP_FUNC).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("STR").appendField(Jt.Msg.OLED_STRING).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("ATTR").appendField(Jt.Msg.MIXLY_AIP_ATTR).setAlign(Jt.inputs.Align.RIGHT),this.setTooltip(Jt.Msg.MIXLY_AipNlp_TOOLTIP),this.setInputsInline(!1),this.setOutput(!0)}},Ah={init:function(){this.setColour(_h),this.appendValueInput("SUB").appendField(Jt.Msg.MIXLY_AipNlp_Sim).appendField(Jt.Msg.MIXLY_Client).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("FUNC").appendField(Jt.Msg.MIXLY_AIP_FUNC).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("STR1").appendField(Jt.Msg.OLED_STRING+"1").setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("STR2").appendField(Jt.Msg.OLED_STRING+"2").setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("ATTR").appendField(Jt.Msg.MIXLY_AIP_ATTR).setAlign(Jt.inputs.Align.RIGHT),this.setTooltip(Jt.Msg.MIXLY_AipNlp_Sim_TOOLTIP),this.setInputsInline(!1),this.setOutput(!0)}},Oh={init:function(){this.setColour(_h),this.appendDummyInput("").appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_AipNlp_lexer,"lexer"],[Jt.Msg.MIXLY_AipNlp_depParser,"depParser"],[Jt.Msg.MIXLY_AipNlp_wordEmbedding,"wordEmbedding"],[Jt.Msg.MIXLY_AipNlp_dnnlm,"dnnlm"],[Jt.Msg.MIXLY_AipNlp_commentTag,"commentTag"],[Jt.Msg.MIXLY_AipNlp_sentimentClassify,"sentimentClassify"],[Jt.Msg.MIXLY_AipNlp_keyword,"keyword"],[Jt.Msg.MIXLY_AipNlp_topic,"topic"],[Jt.Msg.MIXLY_AipNlp_ecnet,"ecnet"],[Jt.Msg.MIXLY_AipNlp_emotion,"emotion"]]),"TYPE"),this.setOutput(!0)}},Mh={init:function(){this.setColour(_h),this.appendDummyInput("").appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_AipNlp_wordSimEmbedding,"wordSimEmbedding"],[Jt.Msg.MIXLY_AipNlp_simnet,"simnet"]]),"TYPE"),this.setOutput(!0)}},Ch={init:function(){this.setColour(_h),this.appendValueInput("SUB").appendField(Jt.Msg.MIXLY_AipNlp_topic).appendField(Jt.Msg.MIXLY_Client).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("STR1").appendField(Jt.Msg.MIXLY_AipNlp_Topic_Title).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("STR2").appendField(Jt.Msg.MIXLY_AipNlp_Topic_Content).setAlign(Jt.inputs.Align.RIGHT),this.setTooltip(Jt.Msg.MIXLY_AipNlp_Topic_TOOLTIP),this.setInputsInline(!1),this.setOutput(!0)}},Nh={init:function(){this.setColour(_h),this.appendValueInput("SUB").appendField(Jt.Msg.MIXLY_AipNlp_summary).appendField(Jt.Msg.MIXLY_Client).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("STR").appendField(Jt.Msg.MIXLY_AipNlp_Topic_Content).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("LEN").appendField(Jt.Msg.MIXLY_LIST_LEN).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("ATTR").appendField(Jt.Msg.MIXLY_AIP_ATTR).setAlign(Jt.inputs.Align.RIGHT),this.setTooltip(Jt.Msg.MIXLY_AipNlp_Summary_TOOLTIP),this.setInputsInline(!1),this.setOutput(!0)}},kh={init:function(){this.setColour(_h),this.appendValueInput("VAR").appendField(Jt.Msg.MIXPY_AI_AUDIO),this.appendValueInput("TIME").appendField(Jt.Msg.MIXPY_AI_AUDIO_TIME),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXPY_AI_AUDIO_TOOLTIP)}},Dh={init:function(){this.setColour(_h),this.appendValueInput("VAR").appendField(Jt.Msg.MIXPY_AI_PHOTO),this.appendValueInput("BUT").appendField(Jt.Msg.MIXPY_AI_PHOTO_BUTTON),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXPY_AI_PHOTO_TOOLTIP)}},Lh={init:function(){this.setColour(_h),this.appendValueInput("AI").appendField(Jt.Msg.MIXPY_AI_RESULT).appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_AipImageClassify,"Image"],[Jt.Msg.MIXLY_AipSpeech_asr,"Speech"],[Jt.Msg.MIXLY_AipFace_match,"Face"],[Jt.Msg.MIXLY_AipOcr,"Ocr"],[Jt.Msg.MIXLY_AipNlp_simnet,"OcrSimilarity"],[Jt.Msg.MIXLY_AipNlp_sentimentClassify,"Emotion"]]),"CTYPE"),this.setOutput(!0),this.setTooltip(Jt.Msg.LOGIC_NEGATE_TOOLTIP)}},Fh="#526FC3",Ph={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_PREPARE),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},$h={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_ADD_SCHOOL),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Bh={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_FIND_PATH),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Vh={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_NEW_PATH),this.setOutput(!0)}},Uh={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_SET_PATH),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Yh={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_ADD_PATH),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Gh={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_DEL_PATH),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Hh={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_RETURN_PATH),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Wh={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_NO_LEFT),this.setOutput(!0)}},zh={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_PRINT_PATH),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Xh={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_PREPARE2),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},jh={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_CURRENT_SCHOOL),this.setOutput(!0)}},qh={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_NO_PATH),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Kh={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_PREPARE_2_1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Qh={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_PREPARE_2_2),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Jh={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_MOVE_RECENT),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Zh={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_NOT_HOME),this.setOutput(!0)}},tp={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_NOT_SCHOOL),this.setOutput(!0)}},ep={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_PRINT_PATH2),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},np={init:function(){this.appendDummyInput().appendField("准备").appendField(new Jt.FieldNumber(3,0,100,1),"NUM").appendField("层汉诺塔"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Fh),this.setTooltip(""),this.setHelpUrl("")}},ip={init:function(){this.appendDummyInput().appendField("移动圆盘从"),this.appendValueInput("FROM_NUM").setCheck(null).appendField("柱"),this.appendDummyInput().appendField("到"),this.appendValueInput("TO_NUM").setCheck(null).appendField("柱"),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Fh),this.setTooltip(""),this.setHelpUrl("")}},sp={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_ALL_BOOKS),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},rp={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_ALL_BOOKS2),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},ap={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_FIRST_BOOK),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},op={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_NO_RING),this.setOutput(!0)}},lp={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_YES_RING),this.setOutput(!0)}},up={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_NEXT_BOOK),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},hp={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_TWO_LEFT),this.setOutput(!0)}},pp={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_DIVIDE_BOOKS),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},cp={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_GET_HALF_BOOKS),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},dp={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_DELETE_BOOK),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},fp={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_DELETE_BOOKS),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},mp={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_DELETE_BOOKS2),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},gp={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_PRINT_BOOK),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},_p={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("设置待查书总数 N=").appendField(new Jt.FieldDropdown([["5","5"],["10","10"],["20","20"],["50","50"]]),"NUM"),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Fh),this.setTooltip(""),this.setHelpUrl("")}},Tp={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_NUMBER_ZERO),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},yp={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_NUMBER_ADD),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Ip={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_PRINT_NUMBER),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Ep={init:function(){this.setColour(Fh),this.appendDummyInput().appendField("n"+Jt.Msg.MIXLY_VALUE2).appendField(new Jt.FieldTextInput("50"),"NUM"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},bp={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_PRINT_SEQUENCE),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},vp={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_PRINT_DIVIDE),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},wp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("初始化鸡兔同笼问题:"),this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("有若干只鸡、兔在同一个笼子里。"),this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("从上面数鸡兔有10个头,"),this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("从下面数鸡兔有32只脚。"),this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("问笼中有多少只鸡和多少只兔?"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Fh),this.setTooltip(""),this.setHelpUrl("")}},Sp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("假设兔子的数量为0只"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Fh),this.setTooltip(""),this.setHelpUrl("")}},xp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("兔子的数量在范围之内"),this.setOutput(!0,null),this.setColour(Fh),this.setTooltip(""),this.setHelpUrl("")}},Rp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("根据(头数-兔子数)计算出鸡的数量"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Fh),this.setTooltip(""),this.setHelpUrl("")}},Ap={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("计算得到脚的数量正确"),this.setOutput(!0,null),this.setColour(Fh),this.setTooltip(""),this.setHelpUrl("")}},Op={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("输出鸡、兔的数量"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Fh),this.setTooltip(""),this.setHelpUrl("")}},Mp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("假设兔子数量要更多一只"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Fh),this.setTooltip(""),this.setHelpUrl("")}},Cp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("加载路线图"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Fh),this.setTooltip(""),this.setHelpUrl("")}},Np={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("计算").appendField(new Jt.FieldDropdown([["S1","1"],["S2","2"],["S3","3"],["S4","4"]]),"PATHNAME").appendField("长度"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Fh),this.setTooltip(""),this.setHelpUrl("")}},kp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("设置S1为Smin"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Fh),this.setTooltip(""),this.setHelpUrl("")}},Dp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField(new Jt.FieldDropdown([["S1","1"],["S2","2"],["S3","3"],["S4","4"]]),"PATHNAME").appendField("的长度比").appendField(new Jt.FieldDropdown([["S1","1"],["S2","2"],["S3","3"],["S4","4"]]),"PATHNAME2").appendField("短"),this.setOutput(!0,null),this.setColour(Fh),this.setTooltip(""),this.setHelpUrl("")}},Lp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("设置").appendField(new Jt.FieldDropdown([["S1","1"],["S2","2"],["S3","3"],["S4","4"]]),"PATHNAME").appendField("为Smin"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Fh),this.setTooltip(""),this.setHelpUrl("")}},Fp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("按照Smin移动"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Fh),this.setTooltip(""),this.setHelpUrl("")}},Pp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("初始化韩信点兵问题:"),this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("有未知数量的若干士兵。"),this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("若3人一排列队,多1人;"),this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("若5人一排列队,多2人;"),this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("若7人一排列队,多2人;"),this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("问士兵的数量最少是多少人?"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Fh),this.setTooltip(""),this.setHelpUrl("")}},$p={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("初始化士兵为").appendField(new Jt.FieldTextInput("7"),"NUM").appendField("个"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Fh),this.setTooltip(""),this.setHelpUrl("")}},Bp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("使士兵").appendField(new Jt.FieldDropdown([["3","3"],["5","5"],["7","7"]]),"NUM").appendField("人一排列队"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Fh),this.setTooltip(""),this.setHelpUrl("")}},Vp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("剩余").appendField(new Jt.FieldTextInput("1"),"NUM").appendField("个士兵"),this.setOutput(!0,null),this.setColour(Fh),this.setTooltip(""),this.setHelpUrl("")}},Up={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("增加1个士兵"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Fh),this.setTooltip(""),this.setHelpUrl("")}},Yp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("输出士兵数量"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Fh),this.setTooltip(""),this.setHelpUrl("")}},Gp={init:function(){this.appendDummyInput().appendField("准备").appendField(new Jt.FieldNumber(3,0,100,1),"NUM").appendField("层汉诺塔"),this.appendValueInput("VAR").setCheck(String).appendField(Jt.Msg.HTML_COLOUR),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Fh),this.setInputsInline(!0),this.setTooltip(""),this.setHelpUrl("")}},Hp={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_GET_CURRENT_LOCATION),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Wp={init:function(){this.setColour(Fh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_VOID_PATH),this.setOutput(!0)}},zp={init:function(){this.setColour(Fh),this.appendDummyInput("").setAlign(Jt.inputs.Align.RIGHT).appendField(new Jt.FieldColour("ff0000"),"COLOR"),this.setInputsInline(!0),this.setOutput(!0,String)}},Xp="#3288dd",jp={init:function(){this.setColour(Xp),this.appendValueInput("DOMAIN").appendField(Jt.Msg.DISPLAY_IMAGE_LET2).setCheck(String),this.appendDummyInput("").appendField(Jt.Msg.blockpy_REQUESTS_GET).appendField(new Jt.FieldTextInput("response"),"VAR"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.blockpy_REQUESTS_GET_TOOLTIP)},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},qp={init:function(){this.setColour(Xp),this.appendValueInput("URL").appendField(Jt.Msg.DISPLAY_IMAGE_LET2).setCheck(String),this.appendDummyInput("").appendField(Jt.Msg.blockpy_CONDUCT).appendField(new Jt.FieldDropdown([["get","get"],["head","head"],["delete","delete"]]),"TYPE").appendField(Jt.Msg.blockpy_REQUESTS).appendField(Jt.Msg.MIXPY_REQUESTS_GET_RESULT),this.setInputsInline(!0),this.setOutput(!0),this.setTooltip("")}},Kp={init:function(){this.setColour(Xp),this.appendValueInput("URL").appendField(Jt.Msg.DISPLAY_IMAGE_LET2).setCheck(String),this.appendDummyInput("").appendField(Jt.Msg.blockpy_CONDUCT).appendField(new Jt.FieldDropdown([["post","post"],["put","put"],["patch","patch"]]),"TYPE").appendField(Jt.Msg.blockpy_REQUESTS),this.appendValueInput("data").appendField(Jt.Msg.blockpy_REQUESTS+Jt.Msg.OLED_STRING),this.appendDummyInput("").appendField(Jt.Msg.MIXPY_REQUESTS_GET_RESULT),this.setInputsInline(!0),this.setOutput(!0),this.setTooltip("")}},Qp={init:function(){this.appendValueInput("VAL");var t=[[Jt.Msg.blockpy_REQUESTS_GET_ATTR_STATUS_CODE,"status_code"],[Jt.Msg.blockpy_REQUESTS_GET_ATTR_TEXT,"text"],[Jt.Msg.blockpy_REQUESTS_GET_ATTR_COOKIES,"cookies"],[Jt.Msg.blockpy_REQUESTS_GET_ATTR_CONTENT,"content"],[Jt.Msg.MIXPY_TEXT_ENCODE,"encoding"]];this.setColour(Xp),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_MICROBIT_JS_GET).appendField(new Jt.FieldDropdown(t),"ATTR"),this.setInputsInline(!0),this.setOutput(!0,String)}},Jp={init:function(){this.appendValueInput("VAR").appendField(Jt.Msg.DISPLAY_IMAGE_LET2).setCheck(String);this.setColour(Xp),this.appendDummyInput("").appendField(Jt.Msg.blockpy_CONDUCT).appendField(new Jt.FieldDropdown([["post","post"],["put","put"],["delete","delete"],["head","head"],["option","option"]]),"DIR"),this.appendDummyInput("").appendField(Jt.Msg.blockpy_REQUESTS),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0);var t=this;this.setTooltip((function(){var e=t.getFieldValue("DIR");return{forward:Jt.Msg.MIXLY_TOOLTIP_TURTEL_FORWARD,backward:Jt.Msg.MIXLY_TOOLTIP_TURTEL_BACKWARD}[e]}))}},Zp="f0a559",tc={init:function(){this.setColour(Zp),this.appendValueInput("FILE").setCheck(String).appendField(Jt.Msg.MIXLY_CV_IMREAD),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0)}},ec={init:function(){this.setColour(Zp),this.appendValueInput("FILE").appendField(Jt.Msg.OLED_BITMAP),this.appendValueInput("data").setCheck(String).appendField(Jt.Msg.MIXLY_AipNlp_Topic_Title),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0)}},nc={init:function(){this.setColour(Zp),this.appendValueInput("FILE").appendField(Jt.Msg.MIXLY_CV_IMWRITE),this.appendValueInput("data").setCheck(String).appendField(Jt.Msg.HTML_NAME),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0)}},ic={init:function(){this.setColour(Zp),this.appendValueInput("data").setCheck(Number).appendField(Jt.Msg.MIXLY_DELAY),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MILLIS+Jt.Msg.MIXLY_CV_OR_PRESS),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_CV_WAITKEY_TOOLTIP)}},sc={init:function(){this.setColour(Zp),this.appendDummyInput().appendField(Jt.Msg.MIXLY_CV_DESTROY_ALL),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0)}},rc={init:function(){this.setColour(Zp),this.appendValueInput("FILE").appendField(Jt.Msg.MIXLY_MICROBIT_IMAGE);var t=[[Jt.Msg.MIXLY_CV_RECT,"rectangle"],[Jt.Msg.MIXLY_CV_LINE,"line"]];this.appendValueInput("x1").setCheck(Number).appendField(Jt.Msg.MIXLY_DISPLAY_DRAW).appendField(new Jt.FieldDropdown(t),"DIR").appendField(Jt.Msg.MIXLY_CV_DRAWLINE_BEGIN+"(x1"),this.appendValueInput("y1").setCheck(Number).appendField(",y1"),this.appendValueInput("x2").setCheck(Number).appendField(") "+Jt.Msg.MIXLY_CV_DRAWLINE_END+"(x2"),this.appendValueInput("y2").setCheck(Number).appendField(",y2"),this.appendDummyInput().appendField(") "+Jt.Msg.MIXLY_CV_DRAWLINE_COLOR).appendField(new Jt.FieldColour("#ff0000"),"FIELDNAME"),this.appendValueInput("thick").setCheck(Number).appendField(Jt.Msg.MIXLY_CV_DRAWLINE_THICKNESS),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_CV_DRAWLINE_RECT_TOOLTIP)}},ac={init:function(){this.setColour(Zp),this.appendValueInput("FILE").appendField(Jt.Msg.MIXLY_MICROBIT_IMAGE);this.appendValueInput("data").setCheck(String).appendField(Jt.Msg.MIXLY_CV_DRAWTEXT),this.appendValueInput("x1").setCheck(Number).appendField(Jt.Msg.MIXLY_CV_DRAWLINE_BEGIN+"(x1"),this.appendValueInput("y1").setCheck(Number).appendField(",y1"),this.appendDummyInput().appendField(") "+Jt.Msg.MIXLY_TURTLE_WRITE_FONT_NAME).appendField(new Jt.FieldDropdown([["SIMPLEX","SIMPLEX"],["PLAIN","PLAIN"],["DUPLEX","DUPLEX"],["COMPLEX","COMPLEX"],["COMPLEX_SMALL","COMPLEX_SMALL"],["TRIPLEX","TRIPLEX"],["SCRIPT_SIMPLEX","SCRIPT_SIMPLEX"],["SCRIPT_COMPLEX","SCRIPT_COMPLEX"]]),"font"),this.appendValueInput("size").setCheck(Number).appendField(Jt.Msg.MIXLY_TURTLE_WRITE_FONT_NUM),this.appendDummyInput().appendField(") "+Jt.Msg.MIXLY_CV_DRAWLINE_COLOR).appendField(new Jt.FieldColour("#ff0000"),"FIELDNAME"),this.appendValueInput("thick").setCheck(Number).appendField(Jt.Msg.MIXLY_CV_DRAWLINE_THICKNESS),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_CV_DRAWLINE_RECT_TOOLTIP)}},oc={init:function(){this.setColour(Zp),this.appendValueInput("FILE").setCheck(String).appendField(Jt.Msg.MIXLY_CV_FACE_CLASSIFIER),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0)}},lc={init:function(){this.setColour(Zp),this.appendValueInput("FILE").appendField(Jt.Msg.MIXLY_MICROBIT_IMAGE),this.appendValueInput("FACE").appendField(Jt.Msg.MIXLY_CV_FACE_DETECT),this.appendValueInput("SCALE").setCheck(Number).appendField(Jt.Msg.MIXLY_CV_FACE_DETECT_SCALE),this.appendValueInput("NEIGHBOR").setCheck(Number).appendField(Jt.Msg.MIXLY_CV_FACE_DETECT_NEIGHBOR),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0)}},uc={init:function(){this.setColour(Zp),this.appendValueInput("FILE").appendField(Jt.Msg.MIXLY_MICROBIT_IMAGE),this.appendValueInput("FACE").appendField(Jt.Msg.MIXLY_CV_FACE_DETECT),this.appendValueInput("SCALE").setCheck(Number).appendField(Jt.Msg.MIXLY_CV_FACE_DETECT_SCALE),this.appendValueInput("NEIGHBOR").setCheck(Number).appendField(Jt.Msg.MIXLY_CV_FACE_DETECT_NEIGHBOR),this.appendValueInput("x1").setCheck(Number).appendField(Jt.Msg.MIXLY_CV_FACE_DETECT_RANGE).appendField(Jt.Msg.blockpy_TUPLE_MIN),this.appendValueInput("y1").setCheck(Number).appendField("×"),this.appendValueInput("x2").setCheck(Number).appendField(Jt.Msg.blockpy_TUPLE_MAX),this.appendValueInput("y2").setCheck(Number).appendField("×"),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0)}},hc=170,pc={init:function(){this.setColour(hc),this.appendDummyInput("").appendField(Jt.Msg.blockpy_series_create).appendField(new Jt.FieldTextInput("ser1"),"VAR"),this.appendValueInput("SER").appendField(Jt.Msg.blockpy_series_via),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.blockpy_series_create_TOOLTIP)},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},cc={init:function(){this.setColour(hc),this.appendDummyInput("").appendField(Jt.Msg.blockpy_series_create).appendField(new Jt.FieldTextInput("ser1"),"VAR"),this.appendValueInput("SER").appendField(Jt.Msg.blockpy_series_via),this.appendValueInput("INDEX").setCheck([String,"List"]).appendField(Jt.Msg.blockpy_series_set_index),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.blockpy_series_create_index_TOOLTIP)},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},dc={init:function(){this.setColour(hc),this.appendDummyInput("").appendField(Jt.Msg.blockpy_dataframe_create).appendField(new Jt.FieldTextInput("df1"),"VAR"),this.appendValueInput("SER").appendField(Jt.Msg.blockpy_series_via),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.blockpy_dataframe_create_TOOLTIP)},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},fc={init:function(){this.setColour(hc);var t=[[Jt.Msg.DATAFRAME_RAW,"index"],[Jt.Msg.DATAFRAME_COLUMN,"columns"]];this.appendDummyInput("").appendField(Jt.Msg.blockpy_dataframe_create).appendField(new Jt.FieldTextInput("df1"),"VAR"),this.appendValueInput("SER").appendField(Jt.Msg.blockpy_series_via),this.appendDummyInput("").appendField(new Jt.FieldDropdown(t),"COLUMN_RAW"),this.appendValueInput("INDEX").setCheck([String,"List"]).appendField(Jt.Msg.blockpy_series_set_index),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.blockpy_dataframe_create_index_TOOLTIP)},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},mc={init:function(){this.setColour(hc),this.appendDummyInput("").appendField(Jt.Msg.blockpy_dataframe_create).appendField(new Jt.FieldTextInput("df1"),"VAR"),this.appendValueInput("SER").appendField(Jt.Msg.blockpy_series_via),this.appendValueInput("INDEX_COLUMN").setCheck([String,"List"]).appendField(Jt.Msg.blockpy_dataframe_set_index_column),this.appendValueInput("INDEX_RAW").setCheck([String,"List"]).appendField(Jt.Msg.blockpy_dataframe_set_index_raw),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.blockpy_dataframe_create_index_TOOLTIP)},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},gc={init:function(){this.setColour(hc),this.appendDummyInput("").appendField(new Jt.FieldTextInput("ser1"),"VAR").appendField(" = [").appendField(new Jt.FieldTextInput("1,2,3"),"TEXT").appendField("]"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_SERIES_CREATE_FROM_TEXT)},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},_c={init:function(){this.setColour(hc);var t=[[Jt.Msg.SERIES_INDEX,"index"],[Jt.Msg.HTML_VALUE,"value"]];this.appendValueInput("SERIES").setCheck("Series"),this.appendDummyInput("").appendField(Jt.Msg.SERIES_INDEX_VALUE).appendField(new Jt.FieldDropdown(t),"INDEX_VALUE"),this.setOutput(!0,"List");var e=this;this.setTooltip((function(){var t=e.getFieldValue("INDEX_VALUE");return{index:Jt.Msg.SERIES_INDEX_TOOLTIP,value:Jt.Msg.HTML_VALUE_TOOLTIP}[t]}))}},Tc={init:function(){this.setColour(hc),this.setOutput(!0),this.appendValueInput("SER").setCheck("Series"),this.appendValueInput("AT").setCheck(Number).appendField(Jt.Msg.LANG_LISTS_GET_INDEX1),this.appendDummyInput("").appendField(Jt.Msg.LANG_LISTS_GET_INDEX2),this.setInputsInline(!0),this.setTooltip(Jt.Msg.TUPLE_GET_INDEX_TOOLTIP)}},yc={init:function(){this.setColour(hc),this.appendValueInput("SER").setCheck("Series").appendField(Jt.Msg.MIXLY_MICROPYTHON_SOCKET_MAKE),this.appendDummyInput().appendField(Jt.Msg.blockpy_PYLAB_PLOT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Ic={init:function(){this.setColour(hc);var t=[[Jt.Msg.blockpy_PYLAB_PLOT_LINE_SOLID,"-"],[Jt.Msg.blockpy_PYLAB_PLOT_LINE_DOTTED,"--"],[Jt.Msg.blockpy_PYLAB_PLOT_LINE_CHAIN,"-."],[Jt.Msg.blockpy_PYLAB_PLOT_LINE_POINT_DOTTED,":"],[Jt.Msg.MIXLY_MICROBIT_JS_INOUT_PULL_NONE,""]],e=[[Jt.Msg.COLOUR_RGB_BLUE,"b"],[Jt.Msg.COLOUR_RGB_GREEN,"g"],[Jt.Msg.COLOUR_RGB_RED,"r"],[Jt.Msg.COLOUR_CYAN,"c"],[Jt.Msg.COLOUR_MAGENTA,"m"],[Jt.Msg.COLOUR_YELLOW,"y"],[Jt.Msg.COLOUR_BLACK,"k"],[Jt.Msg.COLOUR_WHITE,"w"]],n=[[Jt.Msg.blockpy_PYLAB_PLOT_DOT_CIRCULAR,"."],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PIXEL,","],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_LARGE_DOT,"o"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_DOWN,"v"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_UP,"^"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_LEFT,"<"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_RIGHT,">"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_UP,"1"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_DOWN,"2"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_LEFT,"3"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_RIGHT,"4"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_SQUARE,"s"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PENTAGON,"p"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_STAR,"*"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HEXAGON_VERTICAL,"h"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HEXAGON_HORIZONTAL,"H"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PLUS,"+"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_CROSS,"x"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_DIAMOND,"D"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_DIAMOND_SMALL,"d"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_VERTICAL,"|"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HORIZONTAL,"_"]];this.appendValueInput("SER").setCheck("Series").appendField(Jt.Msg.MIXLY_MICROPYTHON_SOCKET_MAKE),this.appendDummyInput().appendField(Jt.Msg.blockpy_PYLAB_PLOT),this.appendDummyInput("").appendField(Jt.Msg.blockpy_PYLAB_PLOT_DOT).appendField(new Jt.FieldDropdown(n),"DOT"),this.appendDummyInput("").appendField(Jt.Msg.blockpy_PYLAB_PLOT_LINE).appendField(new Jt.FieldDropdown(t),"LINE"),this.appendDummyInput("").appendField(Jt.Msg.HTML_COLOUR).appendField(new Jt.FieldDropdown(e),"COLOR"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Ec={init:function(){this.setColour(hc),this.appendDummyInput().appendField(Jt.Msg.blockpy_PYLAB_SHOW),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},bc={init:function(){this.setColour(hc),this.appendDummyInput().appendField(Jt.Msg.mixpy_PL_AXES),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},vc={init:function(){this.setColour(hc),this.appendDummyInput().appendField(Jt.Msg.blockpy_PYLAB_LEGEND),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},wc={init:function(){this.setColour(hc),this.appendDummyInput().appendField(Jt.Msg.blockpy_PYLAB_TITLE),this.appendValueInput("TITLE").setCheck(String),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Sc={init:function(){this.setColour(hc);var t=[[Jt.Msg.PYLAB_LABEL_X,"x"],[Jt.Msg.PYLAB_LABEL_Y,"y"]];this.appendDummyInput().appendField(Jt.Msg.blockpy_PYLAB_SET_LABEL).appendField(new Jt.FieldDropdown(t),"DIR"),this.appendValueInput("LABEL").appendField(Jt.Msg.blockpy_PYLAB_LABEL).setCheck(String),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},xc={init:function(){this.setColour(hc),this.appendValueInput("FROM").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MIXLY_SPLITBYDOU).appendField(Jt.Msg.MIXPY_DATA_ARRAY_CREATE_FROM),this.appendValueInput("TO").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MIXPY_DATA_ARRAY_CREATE_TO),this.appendValueInput("STEP").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MIXLY_STEP),this.setInputsInline(!0),this.setOutput(!0),this.setTooltip(Jt.Msg.MIXLY_PYTHON_CONTROLS_RANGE_TOOLTIP)}},Rc={init:function(){this.setColour(hc);var t=[[Jt.Msg.mixpy_PYLAB_PLOT_BAR_PLOT,"plot"],[Jt.Msg.mixpy_PYLAB_PLOT_BAR_BAR,"bar"]];this.appendDummyInput().appendField(Jt.Msg.MIXLY_DISPLAY_DRAW).appendField(new Jt.FieldDropdown(t),"DIR"),this.appendValueInput("A").appendField(Jt.Msg.mixpy_PYLAB_PLOT_X),this.appendValueInput("B").appendField(Jt.Msg.mixpy_PYLAB_PLOT_Y),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("DIR");return{plot:Jt.Msg.mixpy_PYLAB_PLOT_XY_TOOLTIP,bar:Jt.Msg.mixpy_PYLAB_PLOT_BAR_EASY_TOOLTIP}[t]}))}},Ac={init:function(){this.setColour(hc);var t=[[Jt.Msg.COLOUR_RGB_BLUE,"b"],[Jt.Msg.COLOUR_RGB_GREEN,"g"],[Jt.Msg.COLOUR_RGB_RED,"r"],[Jt.Msg.COLOUR_CYAN,"c"],[Jt.Msg.COLOUR_MAGENTA,"m"],[Jt.Msg.COLOUR_YELLOW,"y"],[Jt.Msg.COLOUR_BLACK,"k"],[Jt.Msg.COLOUR_WHITE,"w"]],e=[[Jt.Msg.blockpy_PYLAB_PLOT_DOT_CIRCULAR,"."],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PIXEL,","],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_LARGE_DOT,"o"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_DOWN,"v"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_UP,"^"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_LEFT,"<"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_RIGHT,">"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_UP,"1"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_DOWN,"2"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_LEFT,"3"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_RIGHT,"4"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_SQUARE,"s"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PENTAGON,"p"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_STAR,"*"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HEXAGON_VERTICAL,"h"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HEXAGON_HORIZONTAL,"H"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PLUS,"+"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_CROSS,"x"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_DIAMOND,"D"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_DIAMOND_SMALL,"d"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_VERTICAL,"|"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HORIZONTAL,"_"]];this.appendValueInput("A").appendField(Jt.Msg.mixpy_PYLAB_SCATTER).appendField(Jt.Msg.mixpy_PYLAB_PLOT_X),this.appendValueInput("B").appendField(Jt.Msg.mixpy_PYLAB_PLOT_Y),this.appendValueInput("S").appendField(Jt.Msg.MIXLY_MICROBIT_JS_NUMBER),this.appendDummyInput("").appendField(Jt.Msg.blockpy_PYLAB_PLOT_DOT).appendField(new Jt.FieldDropdown(e),"DOT"),this.appendDummyInput("").appendField(Jt.Msg.HTML_COLOUR).appendField(new Jt.FieldDropdown(t),"COLOR"),this.appendValueInput("TAG").setCheck(String).appendField(Jt.Msg.mixpy_PYLAB_TICKS_TAG),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Oc={init:function(){this.setColour(hc);var t=[[Jt.Msg.blockpy_PYLAB_PLOT_LINE_SOLID,"-"],[Jt.Msg.blockpy_PYLAB_PLOT_LINE_DOTTED,"--"],[Jt.Msg.blockpy_PYLAB_PLOT_LINE_CHAIN,"-."],[Jt.Msg.blockpy_PYLAB_PLOT_LINE_POINT_DOTTED,":"],[Jt.Msg.MIXLY_MICROBIT_JS_INOUT_PULL_NONE,""]],e=[[Jt.Msg.COLOUR_RGB_BLUE,"b"],[Jt.Msg.COLOUR_RGB_GREEN,"g"],[Jt.Msg.COLOUR_RGB_RED,"r"],[Jt.Msg.COLOUR_CYAN,"c"],[Jt.Msg.COLOUR_MAGENTA,"m"],[Jt.Msg.COLOUR_YELLOW,"y"],[Jt.Msg.COLOUR_BLACK,"k"],[Jt.Msg.COLOUR_WHITE,"w"]],n=[[Jt.Msg.blockpy_PYLAB_PLOT_DOT_CIRCULAR,"."],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PIXEL,","],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_LARGE_DOT,"o"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_DOWN,"v"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_UP,"^"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_LEFT,"<"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_RIGHT,">"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_UP,"1"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_DOWN,"2"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_LEFT,"3"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_RIGHT,"4"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_SQUARE,"s"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PENTAGON,"p"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_STAR,"*"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HEXAGON_VERTICAL,"h"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HEXAGON_HORIZONTAL,"H"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PLUS,"+"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_CROSS,"x"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_DIAMOND,"D"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_DIAMOND_SMALL,"d"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_VERTICAL,"|"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HORIZONTAL,"_"]];this.appendValueInput("A").appendField(Jt.Msg.mixpy_PYLAB_PLOT_XY).appendField(Jt.Msg.mixpy_PYLAB_PLOT_X),this.appendValueInput("B").appendField(Jt.Msg.mixpy_PYLAB_PLOT_Y),this.appendDummyInput("").appendField(Jt.Msg.blockpy_PYLAB_PLOT_DOT).appendField(new Jt.FieldDropdown(n),"DOT"),this.appendDummyInput("").appendField(Jt.Msg.blockpy_PYLAB_PLOT_LINE).appendField(new Jt.FieldDropdown(t),"LINE"),this.appendDummyInput("").appendField(Jt.Msg.HTML_COLOUR).appendField(new Jt.FieldDropdown(e),"COLOR"),this.appendValueInput("TAG").setCheck(String).appendField(Jt.Msg.mixpy_PYLAB_TICKS_TAG),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.mixpy_PYLAB_PLOT_XY_TOOLTIP)}},Mc={init:function(){this.setColour(hc);var t=[[Jt.Msg.MIXLY_TURTLE_WRITE_ALIGN_CENTER,"center"],[Jt.Msg.AILGN_EDGE,"edge"]];this.appendValueInput("A").appendField(Jt.Msg.mixpy_PYLAB_BAR).appendField(Jt.Msg.mixpy_PYLAB_PLOT_X),this.appendValueInput("B").appendField(Jt.Msg.mixpy_PYLAB_PLOT_Y),this.appendValueInput("WIDTH").setCheck(Number).appendField(Jt.Msg.MIXLY_WIDTH),this.appendDummyInput("").appendField(Jt.Msg.mixpy_PYLAB_BAR_ALIGN).appendField(new Jt.FieldDropdown(t),"ALIGN"),this.appendDummyInput().appendField(Jt.Msg.HTML_COLOUR).appendField(new Jt.FieldColour("#0000ff"),"COLOR"),this.appendValueInput("TAG").setCheck(String).appendField(Jt.Msg.mixpy_PYLAB_TICKS_TAG),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.mixpy_PYLAB_PLOT_XY_TOOLTIP)}},Cc={init:function(){this.setColour(hc);var t=[[Jt.Msg.mixpy_PL_PIE_SHADOW_N,"False"],[Jt.Msg.mixpy_PL_PIE_SHADOW_Y,"True"]],e=[[Jt.Msg.mixpy_PL_PIE_SHADOW_N,"None"],[Jt.Msg.mixpy_PYLAB_PIE_AUTOPCT_Z,"%.0f%%"],[Jt.Msg.mixpy_PYLAB_PIE_AUTOPCT_O,"%.1f%%"],[Jt.Msg.mixpy_PYLAB_PIE_AUTOPCT_T,"%.2f%%"]];this.appendValueInput("A").appendField(Jt.Msg.mixpy_PYLAB_PIE).appendField(Jt.Msg.COLOUR_BLEND_RATIO),this.appendValueInput("B").appendField(Jt.Msg.mixpy_PYLAB_TICKS_TAG),this.appendValueInput("EXPLODE").appendField(Jt.Msg.mixpy_PYLAB_PIE_EXPLODE),this.appendDummyInput("").appendField(Jt.Msg.mixpy_PYLAB_PIE_AUTOPCT).appendField(new Jt.FieldDropdown(e),"autopct"),this.appendDummyInput("").appendField(Jt.Msg.mixpy_PYLAB_PIE_SHADOW).appendField(new Jt.FieldDropdown(t),"SHADOW"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.mixpy_PYLAB_PLOT_XY_TOOLTIP)}},Nc={init:function(){this.setColour(hc),this.appendValueInput("A").appendField(Jt.Msg.mixpy_PYLAB_HIST).appendField(Jt.Msg.MIXLY_SD_DATA),this.appendValueInput("B").appendField(Jt.Msg.MIXLY_MICROBIT_JS_MONITOR_SCROLL_INTERVAL),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},kc={init:function(){this.setColour(hc);var t=[[Jt.Msg.PYLAB_LABEL_X,"x"],[Jt.Msg.PYLAB_LABEL_Y,"y"]];this.appendDummyInput().appendField(Jt.Msg.MIXLY_SETTING).appendField(new Jt.FieldDropdown(t),"DIR"),this.appendValueInput("A").appendField(Jt.Msg.mixpy_PYLAB_TICKS).appendField(Jt.Msg.MIXLY_MICROBIT_JS_I2C_VALUE),this.appendValueInput("B").appendField(Jt.Msg.mixpy_PYLAB_TICKS_TAG),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.mixpy_PYLAB_TICKS_TOOLTIP)}},Dc={init:function(){var t=[["sin","sin"],["cos","cos"],["tan","tan"],["arcsin","arcsin"],["arccos","arccos"],["arctan","arctan"],[Jt.Msg.LANG_MATH_TO_ROUND,"round"],[Jt.Msg.LANG_MATH_TO_CEIL,"ceil"],[Jt.Msg.LANG_MATH_TO_FLOOR,"floor"]];this.setColour(hc),this.setOutput(!0),this.setInputsInline(!0),this.appendDummyInput().appendField(Jt.Msg.mixpy_NUMPY_TRIG),this.appendValueInput("NUM").setCheck(Number).appendField(new Jt.FieldDropdown(t),"OP"),this.setTooltip(Jt.Msg.mixpy_NUMPY_TRIG_TOOLTIP)}},Lc={init:function(){this.setColour(hc),this.appendValueInput("VET").setCheck(Number).appendField(Jt.Msg.mixpy_SUBPLOT).appendField(Jt.Msg.mixpy_SUBPLOT_VERTICLE),this.appendValueInput("HOR").setCheck(Number).appendField(Jt.Msg.mixpy_SUBPLOT_HORIZEN),this.appendValueInput("NUM").setCheck(Number).appendField(Jt.Msg.mixpy_SUBPLOT_NUM),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_PYTHON_CONTROLS_RANGE_TOOLTIP)}},Fc={init:function(){this.setColour(hc),this.appendValueInput("FILENAME").appendField(Jt.Msg.MIXPY_PANDAS_READ_CSV),this.appendDummyInput().appendField(new Jt.FieldDropdown([[Jt.Msg.mixpy_PANDAS_READCSV_HEADER_Y,"0"],[Jt.Msg.mixpy_PANDAS_READCSV_HEADER_N,"None"]]),"MODE"),this.appendDummyInput().appendField(Jt.Msg.mixpy_PANDAS_READCSV_TITLE),this.setOutput(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.mixpy_PANDAS_READCSV_TOOLTIP)},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},Pc={init:function(){this.setColour(hc),this.appendValueInput("DICT").setCheck("Dict"),this.appendValueInput("KEY").appendField(Jt.Msg.mixpy_DATAFRAME_GET),this.appendDummyInput("").appendField(Jt.Msg.mixpy_DATAFRAME_GET_INDEX).appendField(new Jt.FieldDropdown([[Jt.Msg.DATAFRAME_COLUMN,"column"],[Jt.Msg.DATAFRAME_RAW,"raw"]]),"MODE"),this.setOutput(!0),this.setTooltip(Jt.Msg.mixpy_DATAFRAME_GET_TOOLTIP)}},$c={init:function(){this.setColour(hc),this.appendValueInput("FILE").setCheck(String).appendField(Jt.Msg.mixpy_PL_SAVEFIG),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setOutput(!1),this.setTooltip(Jt.Msg.mixpy_PL_SAVEFIG_TOOLTIP)}},Bc={init:function(){this.setColour(hc);var t=[[Jt.Msg.TEXT_TRIM_LEFT,"right"],[Jt.Msg.mixpy_PL_TEXT_CENTER,"center"],[Jt.Msg.TEXT_TRIM_RIGHT,"left"]],e=[[Jt.Msg.mixpy_PL_TEXT_TOP,"bottom"],[Jt.Msg.mixpy_PL_TEXT_CENTER,"center"],[Jt.Msg.mixpy_PL_TEXT_BOTTOM,"top"]];this.appendValueInput("VET").setCheck(Number).appendField(Jt.Msg.MIXLY_SETTING).appendField(Jt.Msg.mixpy_PL_TEXT_X),this.appendValueInput("HOR").setCheck(Number).appendField(Jt.Msg.mixpy_PL_TEXT_Y),this.appendValueInput("NUM").setCheck(Number).appendField(Jt.Msg.mixpy_PL_TEXT_TAG),this.appendDummyInput("").appendField(Jt.Msg.mixpy_PL_TEXT_HOR).appendField(new Jt.FieldDropdown(t),"HALIGN"),this.appendDummyInput("").appendField(Jt.Msg.mixpy_PL_TEXT_VER).appendField(new Jt.FieldDropdown(e),"VALIGN"),this.appendValueInput("FONTNUM").setCheck(Number).appendField(Jt.Msg.MIXLY_TURTLE_WRITE_FONT_NUM),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.mixpy_PL_TEXT_TOOLTIP)}},Vc={init:function(){this.setColour(hc),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_TOARRAY),this.setOutput(!0,"List"),this.setTooltip(Jt.Msg.MIXLY_PYTHON_TOOLTIP_TOARRAY)}},Uc={init:function(){this.setColour(hc),this.appendValueInput("SER").setCheck("Series").appendField(Jt.Msg.MIXLY_MICROPYTHON_SOCKET_MAKE),this.appendDummyInput().appendField(Jt.Msg.blockpy_PYLAB_PLOT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Yc={init:function(){this.setColour(hc);var t=[[Jt.Msg.blockpy_PYLAB_PLOT_LINE_SOLID,"-"],[Jt.Msg.blockpy_PYLAB_PLOT_LINE_DOTTED,"--"],[Jt.Msg.blockpy_PYLAB_PLOT_LINE_CHAIN,"-."],[Jt.Msg.blockpy_PYLAB_PLOT_LINE_POINT_DOTTED,":"],[Jt.Msg.MIXLY_MICROBIT_JS_INOUT_PULL_NONE,""]],e=[[Jt.Msg.COLOUR_RGB_BLUE,"b"],[Jt.Msg.COLOUR_RGB_GREEN,"g"],[Jt.Msg.COLOUR_RGB_RED,"r"],[Jt.Msg.COLOUR_CYAN,"c"],[Jt.Msg.COLOUR_MAGENTA,"m"],[Jt.Msg.COLOUR_YELLOW,"y"],[Jt.Msg.COLOUR_BLACK,"k"],[Jt.Msg.COLOUR_WHITE,"w"]],n=[[Jt.Msg.blockpy_PYLAB_PLOT_DOT_CIRCULAR,"."],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PIXEL,","],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_LARGE_DOT,"o"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_DOWN,"v"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_UP,"^"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_LEFT,"<"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_RIGHT,">"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_UP,"1"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_DOWN,"2"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_LEFT,"3"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_RIGHT,"4"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_SQUARE,"s"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PENTAGON,"p"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_STAR,"*"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HEXAGON_VERTICAL,"h"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HEXAGON_HORIZONTAL,"H"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PLUS,"+"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_CROSS,"x"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_DIAMOND,"D"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_DIAMOND_SMALL,"d"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_VERTICAL,"|"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HORIZONTAL,"_"]];this.appendValueInput("SER").setCheck("Series").appendField(Jt.Msg.MIXLY_MICROPYTHON_SOCKET_MAKE),this.appendDummyInput().appendField(Jt.Msg.blockpy_PYLAB_PLOT),this.appendDummyInput("").appendField(Jt.Msg.blockpy_PYLAB_PLOT_DOT).appendField(new Jt.FieldDropdown(n),"DOT"),this.appendDummyInput("").appendField(Jt.Msg.blockpy_PYLAB_PLOT_LINE).appendField(new Jt.FieldDropdown(t),"LINE"),this.appendDummyInput("").appendField(Jt.Msg.HTML_COLOUR).appendField(new Jt.FieldDropdown(e),"COLOR"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Gc={init:function(){this.setColour(hc),this.appendDummyInput().appendField(Jt.Msg.blockpy_PYLAB_SHOW),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Hc={init:function(){this.setColour(hc),this.appendDummyInput().appendField(Jt.Msg.mixpy_PL_AXES),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Wc={init:function(){this.setColour(hc),this.appendDummyInput().appendField(Jt.Msg.blockpy_PYLAB_LEGEND),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},zc={init:function(){this.setColour(hc),this.appendDummyInput().appendField(Jt.Msg.blockpy_PYLAB_TITLE),this.appendValueInput("TITLE").setCheck(String),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Xc={init:function(){this.setColour(hc);var t=[[Jt.Msg.PYLAB_LABEL_X,"x"],[Jt.Msg.PYLAB_LABEL_Y,"y"]];this.appendDummyInput().appendField(Jt.Msg.blockpy_PYLAB_SET_LABEL).appendField(new Jt.FieldDropdown(t),"DIR"),this.appendValueInput("LABEL").appendField(Jt.Msg.blockpy_PYLAB_LABEL).setCheck(String),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},jc={init:function(){this.setColour(hc);var t=[[Jt.Msg.mixpy_PYLAB_PLOT_BAR_PLOT,"plot"],[Jt.Msg.mixpy_PYLAB_PLOT_BAR_BAR,"bar"]];this.appendDummyInput().appendField(Jt.Msg.MIXLY_DISPLAY_DRAW).appendField(new Jt.FieldDropdown(t),"DIR"),this.appendValueInput("A").appendField(Jt.Msg.mixpy_PYLAB_PLOT_X),this.appendValueInput("B").appendField(Jt.Msg.mixpy_PYLAB_PLOT_Y),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("DIR");return{plot:Jt.Msg.mixpy_PYLAB_PLOT_XY_TOOLTIP,bar:Jt.Msg.mixpy_PYLAB_PLOT_BAR_EASY_TOOLTIP}[t]}))}},qc={init:function(){this.setColour(hc);var t=[[Jt.Msg.COLOUR_RGB_BLUE,"b"],[Jt.Msg.COLOUR_RGB_GREEN,"g"],[Jt.Msg.COLOUR_RGB_RED,"r"],[Jt.Msg.COLOUR_CYAN,"c"],[Jt.Msg.COLOUR_MAGENTA,"m"],[Jt.Msg.COLOUR_YELLOW,"y"],[Jt.Msg.COLOUR_BLACK,"k"],[Jt.Msg.COLOUR_WHITE,"w"]],e=[[Jt.Msg.blockpy_PYLAB_PLOT_DOT_CIRCULAR,"."],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PIXEL,","],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_LARGE_DOT,"o"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_DOWN,"v"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_UP,"^"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_LEFT,"<"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_RIGHT,">"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_UP,"1"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_DOWN,"2"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_LEFT,"3"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_RIGHT,"4"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_SQUARE,"s"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PENTAGON,"p"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_STAR,"*"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HEXAGON_VERTICAL,"h"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HEXAGON_HORIZONTAL,"H"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PLUS,"+"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_CROSS,"x"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_DIAMOND,"D"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_DIAMOND_SMALL,"d"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_VERTICAL,"|"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HORIZONTAL,"_"]];this.appendValueInput("A").appendField(Jt.Msg.mixpy_PYLAB_SCATTER).appendField(Jt.Msg.mixpy_PYLAB_PLOT_X),this.appendValueInput("B").appendField(Jt.Msg.mixpy_PYLAB_PLOT_Y),this.appendValueInput("S").appendField(Jt.Msg.MIXLY_MICROBIT_JS_NUMBER),this.appendDummyInput("").appendField(Jt.Msg.blockpy_PYLAB_PLOT_DOT).appendField(new Jt.FieldDropdown(e),"DOT"),this.appendDummyInput("").appendField(Jt.Msg.HTML_COLOUR).appendField(new Jt.FieldDropdown(t),"COLOR"),this.appendValueInput("TAG").setCheck(String).appendField(Jt.Msg.mixpy_PYLAB_TICKS_TAG),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Kc={init:function(){this.setColour(hc);var t=[[Jt.Msg.blockpy_PYLAB_PLOT_LINE_SOLID,"-"],[Jt.Msg.blockpy_PYLAB_PLOT_LINE_DOTTED,"--"],[Jt.Msg.blockpy_PYLAB_PLOT_LINE_CHAIN,"-."],[Jt.Msg.blockpy_PYLAB_PLOT_LINE_POINT_DOTTED,":"],[Jt.Msg.MIXLY_MICROBIT_JS_INOUT_PULL_NONE,""]],e=[[Jt.Msg.COLOUR_RGB_BLUE,"b"],[Jt.Msg.COLOUR_RGB_GREEN,"g"],[Jt.Msg.COLOUR_RGB_RED,"r"],[Jt.Msg.COLOUR_CYAN,"c"],[Jt.Msg.COLOUR_MAGENTA,"m"],[Jt.Msg.COLOUR_YELLOW,"y"],[Jt.Msg.COLOUR_BLACK,"k"],[Jt.Msg.COLOUR_WHITE,"w"]],n=[[Jt.Msg.blockpy_PYLAB_PLOT_DOT_CIRCULAR,"."],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PIXEL,","],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_LARGE_DOT,"o"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_DOWN,"v"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_UP,"^"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_LEFT,"<"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_RIGHT,">"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_UP,"1"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_DOWN,"2"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_LEFT,"3"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_RIGHT,"4"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_SQUARE,"s"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PENTAGON,"p"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_STAR,"*"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HEXAGON_VERTICAL,"h"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HEXAGON_HORIZONTAL,"H"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PLUS,"+"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_CROSS,"x"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_DIAMOND,"D"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_DIAMOND_SMALL,"d"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_VERTICAL,"|"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HORIZONTAL,"_"]];this.appendValueInput("A").appendField(Jt.Msg.mixpy_PYLAB_PLOT_XY).appendField(Jt.Msg.mixpy_PYLAB_PLOT_X),this.appendValueInput("B").appendField(Jt.Msg.mixpy_PYLAB_PLOT_Y),this.appendDummyInput("").appendField(Jt.Msg.blockpy_PYLAB_PLOT_DOT).appendField(new Jt.FieldDropdown(n),"DOT"),this.appendDummyInput("").appendField(Jt.Msg.blockpy_PYLAB_PLOT_LINE).appendField(new Jt.FieldDropdown(t),"LINE"),this.appendDummyInput("").appendField(Jt.Msg.HTML_COLOUR).appendField(new Jt.FieldDropdown(e),"COLOR"),this.appendValueInput("TAG").setCheck(String).appendField(Jt.Msg.mixpy_PYLAB_TICKS_TAG),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.mixpy_PYLAB_PLOT_XY_TOOLTIP)}},Qc={init:function(){this.setColour(hc);var t=[[Jt.Msg.MIXLY_TURTLE_WRITE_ALIGN_CENTER,"center"],[Jt.Msg.AILGN_EDGE,"edge"]];this.appendValueInput("A").appendField(Jt.Msg.mixpy_PYLAB_BAR).appendField(Jt.Msg.mixpy_PYLAB_PLOT_X),this.appendValueInput("B").appendField(Jt.Msg.mixpy_PYLAB_PLOT_Y),this.appendValueInput("WIDTH").setCheck(Number).appendField(Jt.Msg.MIXLY_WIDTH),this.appendDummyInput("").appendField(Jt.Msg.mixpy_PYLAB_BAR_ALIGN).appendField(new Jt.FieldDropdown(t),"ALIGN"),this.appendDummyInput().appendField(Jt.Msg.HTML_COLOUR).appendField(new Jt.FieldColour("#0000ff"),"COLOR"),this.appendValueInput("TAG").setCheck(String).appendField(Jt.Msg.mixpy_PYLAB_TICKS_TAG),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.mixpy_PYLAB_PLOT_XY_TOOLTIP)}},Jc={init:function(){this.setColour(hc);var t=[[Jt.Msg.mixpy_PL_PIE_SHADOW_N,"False"],[Jt.Msg.mixpy_PL_PIE_SHADOW_Y,"True"]],e=[[Jt.Msg.mixpy_PL_PIE_SHADOW_N,"None"],[Jt.Msg.mixpy_PYLAB_PIE_AUTOPCT_Z,"%.0f%%"],[Jt.Msg.mixpy_PYLAB_PIE_AUTOPCT_O,"%.1f%%"],[Jt.Msg.mixpy_PYLAB_PIE_AUTOPCT_T,"%.2f%%"]];this.appendValueInput("A").appendField(Jt.Msg.mixpy_PYLAB_PIE).appendField(Jt.Msg.COLOUR_BLEND_RATIO),this.appendValueInput("B").appendField(Jt.Msg.mixpy_PYLAB_TICKS_TAG),this.appendValueInput("EXPLODE").appendField(Jt.Msg.mixpy_PYLAB_PIE_EXPLODE),this.appendDummyInput("").appendField(Jt.Msg.mixpy_PYLAB_PIE_AUTOPCT).appendField(new Jt.FieldDropdown(e),"autopct"),this.appendDummyInput("").appendField(Jt.Msg.mixpy_PYLAB_PIE_SHADOW).appendField(new Jt.FieldDropdown(t),"SHADOW"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.mixpy_PYLAB_PLOT_XY_TOOLTIP)}},Zc={init:function(){this.setColour(hc),this.appendValueInput("A").appendField(Jt.Msg.mixpy_PYLAB_HIST).appendField(Jt.Msg.MIXLY_SD_DATA),this.appendValueInput("B").appendField(Jt.Msg.MIXLY_MICROBIT_JS_MONITOR_SCROLL_INTERVAL),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},td={init:function(){this.setColour(hc);var t=[[Jt.Msg.PYLAB_LABEL_X,"x"],[Jt.Msg.PYLAB_LABEL_Y,"y"]];this.appendDummyInput().appendField(Jt.Msg.MIXLY_SETTING).appendField(new Jt.FieldDropdown(t),"DIR"),this.appendValueInput("A").appendField(Jt.Msg.mixpy_PYLAB_TICKS).appendField(Jt.Msg.MIXLY_MICROBIT_JS_I2C_VALUE),this.appendValueInput("B").appendField(Jt.Msg.mixpy_PYLAB_TICKS_TAG),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.mixpy_PYLAB_TICKS_TOOLTIP)}},ed={init:function(){this.setColour(hc),this.appendValueInput("VET").setCheck(Number).appendField(Jt.Msg.mixpy_SUBPLOT).appendField(Jt.Msg.mixpy_SUBPLOT_VERTICLE),this.appendValueInput("HOR").setCheck(Number).appendField(Jt.Msg.mixpy_SUBPLOT_HORIZEN),this.appendValueInput("NUM").setCheck(Number).appendField(Jt.Msg.mixpy_SUBPLOT_NUM),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_PYTHON_CONTROLS_RANGE_TOOLTIP)}},nd={init:function(){this.setColour(hc),this.appendDummyInput("").appendField(Jt.Msg.mixpy_PL_SAVEFIG),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setOutput(!1),this.setTooltip(Jt.Msg.mixpy_PL_SAVEFIG_TOOLTIP)}},id={init:function(){this.setColour(hc);var t=[[Jt.Msg.TEXT_TRIM_LEFT,"right"],[Jt.Msg.mixpy_PL_TEXT_CENTER,"center"],[Jt.Msg.TEXT_TRIM_RIGHT,"left"]],e=[[Jt.Msg.mixpy_PL_TEXT_TOP,"bottom"],[Jt.Msg.mixpy_PL_TEXT_CENTER,"center"],[Jt.Msg.mixpy_PL_TEXT_BOTTOM,"top"]];this.appendValueInput("VET").setCheck(Number).appendField(Jt.Msg.MIXLY_SETTING).appendField(Jt.Msg.mixpy_PL_TEXT_X),this.appendValueInput("HOR").setCheck(Number).appendField(Jt.Msg.mixpy_PL_TEXT_Y),this.appendValueInput("NUM").setCheck(Number).appendField(Jt.Msg.mixpy_PL_TEXT_TAG),this.appendDummyInput("").appendField(Jt.Msg.mixpy_PL_TEXT_HOR).appendField(new Jt.FieldDropdown(t),"HALIGN"),this.appendDummyInput("").appendField(Jt.Msg.mixpy_PL_TEXT_VER).appendField(new Jt.FieldDropdown(e),"VALIGN"),this.appendValueInput("FONTNUM").setCheck(Number).appendField(Jt.Msg.MIXLY_TURTLE_WRITE_FONT_NUM),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.mixpy_PL_TEXT_TOOLTIP)}},sd={init:function(){this.setColour(hc),this.appendValueInput("ARRAY").appendField("获取维度"),this.setOutput(!0),this.setTooltip("Returns the shape of the array.")}},rd={init:function(){this.setColour(hc),this.appendValueInput("ARRAY").appendField("变形"),this.appendValueInput("DIMENSIONS").appendField("后维度为"),this.setOutput(!0),this.setTooltip("Reshapes the array to the specified dimensions.")}},ad={init:function(){this.setColour(hc),this.appendValueInput("ARRAY").appendField("把"),this.appendDummyInput().appendField("转换为").appendField(new Jt.FieldDropdown([["uint8","numpy.uint8"],["int32","numpy.int32"],["float32","numpy.float32"],["float64","numpy.float64"]]),"TYPE"),this.setOutput(!0),this.setTooltip("Converts array to specified type.")}},od={init:function(){this.setColour(hc),this.appendValueInput("ARRAY").appendField("创建二维图"),this.appendDummyInput().appendField("颜色").appendField(new Jt.FieldDropdown([["gray","gray"],["viridis","viridis"],["plasma","plasma"],["inferno","inferno"],["magma","magma"],["cividis","cividis"],["hot","hot"],["cool","cool"],["spring","spring"],["summer","summer"],["autumn","autumn"],["winter","winter"],["jet","jet"]]),"COLORMAP"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setTooltip("Displays an image with the specified colormap.")}},ld={init:function(){this.setColour(hc),this.appendValueInput("X").appendField("从数据集"),this.appendValueInput("Y").appendField("获取平均图像,标签"),this.appendValueInput("DIGIT").appendField("为"),this.setOutput(!0),this.setTooltip("Computes the mean of X where y equals the specified digit.")}},ud={init:function(){this.setColour(hc),this.appendValueInput("IMAGE").appendField("获取模板匹配结果,图片:"),this.appendValueInput("TEMPLATES").appendField("模板:"),this.setOutput(!0),this.setTooltip("Finds the index of the template that minimizes the sum of absolute differences with the image.")}},hd={init:function(){this.setColour(hc),this.appendValueInput("ARRAY").appendField("获取平均值"),this.appendDummyInput().appendField("沿着axis").appendField(new Jt.FieldDropdown([["None","NONE"],["0","0"],["1","1"]]),"AXIS"),this.setOutput(!0),this.setTooltip("Computes the mean of the array along the specified axis.")}},pd={init:function(){this.setColour(hc),this.appendValueInput("ARRAY").appendField("获取标准差"),this.appendDummyInput().appendField("沿着axis").appendField(new Jt.FieldDropdown([["None","NONE"],["0","0"],["1","1"]]),"AXIS"),this.setOutput(!0),this.setTooltip("Computes the standard deviation of the array along the specified axis.")}},cd={init:function(){this.setColour(hc),this.appendValueInput("DF").appendField("丢弃缺省值"),this.setOutput(!0),this.setTooltip("Drops rows with NaN values from the dataframe.")}},dd={init:function(){this.setColour(hc),this.appendValueInput("DATAFRAME").appendField("从数据集"),this.appendValueInput("COLUMNS").appendField("中删除列").setCheck(String),this.setInputsInline(!0),this.setOutput(!0),this.setTooltip("从数据框中删除指定的列。用逗号分隔多个列名。")}},fd={init:function(){this.setColour(hc),this.appendValueInput("NUM").appendField("生成单位行向量"),this.setOutput(!0),this.setTooltip("Creates an array of ones with the specified length.")}},md={init:function(){this.setColour(hc),this.appendValueInput("ARRAY1").appendField("列拼接:数组1"),this.appendValueInput("ARRAY2").appendField("数组2"),this.setOutput(!0),this.setTooltip("Concatenates two arrays along the second axis using numpy.c_.")}},gd={init:function(){this.setColour(hc),this.appendValueInput("ARRAY").appendField("获取行列式"),this.setOutput(!0),this.setTooltip("Computes the determinant of an array using numpy.linalg.det.")}},_d={init:function(){this.setColour(hc),this.appendValueInput("MATRIX").appendField("获取转置"),this.setOutput(!0),this.setTooltip("Computes the transpose of the given matrix.")}},Td={init:function(){this.setColour(hc),this.appendValueInput("MATRIX1"),this.appendValueInput("MATRIX2").appendField("@"),this.setOutput(!0),this.setTooltip("Multiplies two matrices.")}},yd={init:function(){this.setColour(hc),this.appendValueInput("ARRAY").appendField("获取逆矩阵"),this.setOutput(!0),this.setTooltip("Computes the inverse of the given matrix using numpy.linalg.inv.")}},Id={init:function(){this.setColour(hc),this.appendValueInput("DATAFRAME").appendField("获取中位数"),this.setOutput(!0),this.setTooltip("Computes the median of the given dataframe.")}},Ed={init:function(){this.setColour(hc),this.appendValueInput("DATAFRAME").appendField("填充缺失值"),this.appendValueInput("VALUE").appendField("填充值"),this.appendDummyInput().appendField("是否修改原数据").appendField(new Jt.FieldDropdown([["True","True"],["False","False"]]),"INPLACE"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setTooltip("Fills NaN values in the dataframe with the specified value.")}},bd={init:function(){this.setColour(hc),this.appendValueInput("DATAFRAME").appendField("获取DataFrame信息"),this.setOutput(!0),this.setTooltip("Displays information about the DataFrame.")}},vd={init:function(){this.setColour(hc),this.appendValueInput("ARRAY").appendField("获取最小值"),this.appendDummyInput().appendField("沿着axis").appendField(new Jt.FieldDropdown([["None","None"],["行","0"],["列","1"]]),"AXIS"),this.setOutput(!0),this.setTooltip("Returns the minimum value along the specified axis.")}},wd={init:function(){this.setColour(hc),this.appendValueInput("ARRAY").appendField("获取最大值"),this.appendDummyInput().appendField("沿着axis").appendField(new Jt.FieldDropdown([["None","None"],["行","0"],["列","1"]]),"AXIS"),this.setOutput(!0),this.setTooltip("Returns the maximum value along the specified axis.")}},Sd={init:function(){this.setColour(hc),this.appendValueInput("ARRAY").appendField("获取数组大小"),this.setOutput(!0),this.setTooltip("Returns the size of the array.")}},xd={init:function(){this.setColour(hc),this.appendValueInput("ARRAY1").appendField("点乘数组1"),this.appendValueInput("ARRAY2").appendField("点乘数组2"),this.setOutput(!0),this.setTooltip("Returns the dot product of two arrays.")}},Rd={init:function(){this.setColour(hc),this.appendValueInput("ARRAY").appendField("获取平方数组"),this.setOutput(!0),this.setTooltip("Returns the element-wise square of the array.")}},Ad={init:function(){this.setColour(hc),this.appendValueInput("ARRAY").appendField("获取数组元素和"),this.setOutput(!0),this.setTooltip("Returns the sum of the array.")}},Od={init:function(){this.setColour(hc),this.appendValueInput("SIZE").appendField("生成随机数组"),this.setOutput(!0),this.setTooltip("Returns a random array of the specified size.")}},Md={init:function(){this.setColour(hc),this.appendValueInput("ARRAY").appendField("Python求和"),this.setOutput(!0),this.setTooltip("Returns the sum of the iterable.")}},Cd={init:function(){this.setColour(hc),this.appendValueInput("DICT").setAlign(Jt.inputs.Align.RIGHT).setCheck("Dict"),this.appendDummyInput().setAlign(Jt.inputs.Align.RIGHT).appendField("值排序"),this.appendValueInput("KEY").setAlign(Jt.inputs.Align.RIGHT).appendField("标签"),this.appendDummyInput().setAlign(Jt.inputs.Align.RIGHT).appendField("排序方式").appendField(new Jt.FieldDropdown([["升序","True"],["降序","False"]]),"AS_CENDING"),this.setOutput(!0),this.setInputsInline(!0),this.setTooltip("")}},Nd={init:function(){this.setColour(hc),this.appendValueInput("DICT").setAlign(Jt.inputs.Align.RIGHT).setCheck("Dict"),this.appendDummyInput().setAlign(Jt.inputs.Align.RIGHT).appendField("获取").appendField(new Jt.FieldDropdown([["前几行","head"],["最后几行","tail"]]),"TYPE"),this.appendValueInput("LINES").setAlign(Jt.inputs.Align.RIGHT).appendField("行数"),this.setOutput(!0),this.setInputsInline(!0),this.setTooltip("")}},kd={init:function(){this.setColour(hc),this.appendValueInput("DICT").setAlign(Jt.inputs.Align.RIGHT).setCheck("Dict"),this.appendDummyInput().setAlign(Jt.inputs.Align.RIGHT).appendField("筛选数据"),this.appendValueInput("KEY").setAlign(Jt.inputs.Align.RIGHT).appendField("满足条件"),this.setOutput(!0),this.setInputsInline(!0),this.setTooltip("")}},Dd={init:function(){this.setColour(hc),this.appendValueInput("DICT").setAlign(Jt.inputs.Align.RIGHT).setCheck("Dict"),this.appendValueInput("KEY").setAlign(Jt.inputs.Align.RIGHT).appendField("通过标签"),this.appendDummyInput().setAlign(Jt.inputs.Align.RIGHT).appendField("分组"),this.setOutput(!0),this.setInputsInline(!0),this.setTooltip("")}},Ld={init:function(){this.setColour(hc),this.appendDummyInput().setAlign(Jt.inputs.Align.RIGHT).appendField(new Jt.FieldDropdown([["求最小值","min"],["求最大值","max"],["求和","sum"],["求平均值","mean"],["求中位数","median"],["求标准差","std"]]),"TYPE"),this.appendValueInput("DICT").setAlign(Jt.inputs.Align.RIGHT).setCheck("Dict"),this.setOutput(!0),this.setInputsInline(!0),this.setTooltip("")}},Fd={init:function(){this.setColour(hc),this.appendDummyInput().appendField("清除已有图像"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Pd=80,$d={init:function(){this.setColour(Pd),this.appendDummyInput("").appendField(new Jt.FieldLabel(Jt.Msg.DS_CREATE_LINKEDLIST_NEW)),this.appendDummyInput("").appendField(new Jt.FieldLabel(Jt.Msg.DS_CREATE_LINKEDLIST_HEAD)).appendField(new Jt.FieldTextInput("head"),"VAR"),this.appendDummyInput("").appendField(new Jt.FieldLabel(Jt.Msg.DS_CREATE_LINKEDLIST_TYPE)).appendField(new Jt.FieldTextInput("tag"),"TYPE"),this.appendDummyInput().appendField(Jt.Msg.DS_CREATE_LINKEDLIST_ATTRIBUTE),this.itemCount_=1,this.updateShape_(),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setMutator(new Jt.icons.MutatorIcon(["ds_create_linkedlist_item"],this)),this.setTooltip(Jt.Msg.DS_CREATE_LINKEDLIST_TOOLTIP)},mutationToDom:function(){var t=document.createElement("mutation");return t.setAttribute("items",this.itemCount_),t},domToMutation:function(t){this.itemCount_=parseInt(t.getAttribute("items"),10),this.updateShape_()},decompose:function(t){var e=t.newBlock("ds_create_linkedlist_container");e.initSvg();for(var n=e.getInput("STACK").connection,i=0;ie?t[e]:"name"),"KEY"+e).appendField("=")},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},Bd={init:function(){this.setColour(Pd),this.appendDummyInput().appendField(Jt.Msg.DS_CREATE_LINKEDLIST_CONTAINER_TITLE),this.appendStatementInput("STACK"),this.setTooltip(Jt.Msg.DS_CREATE_LINKEDLIST_CONTAINER_TOOLTIP),this.contextMenu=!1}},Vd={init:function(){this.setColour(Pd),this.appendDummyInput().appendField(Jt.Msg.DS_CREATE_LINKEDLIST_ITEM_TITLE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.DS_CREATE_LINKEDLIST_ITEM_TOOLTIP),this.contextMenu=!1}},Ud={init:function(){this.setColour(Pd),this.appendDummyInput("").appendField(Jt.Msg.DS_CREATE_NODE_USE).appendField(new Jt.FieldTextInput("tag"),"TYPE"),this.appendDummyInput("").appendField(Jt.Msg.DS_CREATE_NODE_NEW),this.appendValueInput("NODE"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.DS_CREATE_NODE_TOOLTIP)}},Yd={init:function(){this.setColour(Pd),this.appendDummyInput("").appendField(Jt.Msg.DS_GET_NODE_ATTR_NODE),this.appendValueInput("NODE"),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_AIP_ATTR).appendField(new Jt.FieldTextInput("name"),"TYPE"),this.appendDummyInput("").appendField(Jt.Msg.DICTS_ADD_VALUE),this.setOutput(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.DS_GET_NODE_ATTR_TOOLTIP)}},Gd={init:function(){this.setColour(Pd),this.appendDummyInput("").appendField(Jt.Msg.DS_SET_NODE_ATTR_NODE),this.appendValueInput("NODE"),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_AIP_ATTR).appendField(new Jt.FieldTextInput("name"),"TYPE"),this.appendValueInput("VAR").appendField(Jt.Msg.DS_SET_NODE_ATTR_SET),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.DS_SET_NODE_ATTR_TOOLTIP)}},Hd={init:function(){this.setColour(Pd),this.appendValueInput("NODE").appendField(Jt.Msg.DS_ADD_NODE_HEAD_NODE);var t=[[Jt.Msg.DS_ADD_NODE_BEFORE,"before"],[Jt.Msg.DS_ADD_NODE_AFTER,"after"]];this.appendDummyInput("").appendField(Jt.Msg.DS_ADD_NODE_LINKEDLIST),this.appendValueInput("NODE2").appendField(Jt.Msg.DS_SET_NODE_ATTR_NODE),this.appendValueInput("NODE3").appendField(new Jt.FieldDropdown(t),"DIR").appendField(Jt.Msg.DS_ADD_NODE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.DS_ADD_NODE_TOOLTIP)}},Wd={init:function(){this.setColour(Pd),this.appendValueInput("NODE").appendField(Jt.Msg.DS_ADD_NODE_HEAD_NODE);var t=[[Jt.Msg.DS_ADD_NODE_BEFORE,"before"],[Jt.Msg.DS_ADD_NODE_AFTER,"after"]];this.appendDummyInput("").appendField(Jt.Msg.DS_ADD_NODE_LINKEDLIST),this.appendDummyInput("").appendField(Jt.Msg.DS_CREATE_LINKEDLIST_ITEM_TITLE).appendField(new Jt.FieldTextInput("name"),"TYPE"),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_AS),this.appendDummyInput("").appendField(Jt.Msg.DS_ADD_NODE_ATTR),this.appendValueInput("NODE3").appendField(new Jt.FieldDropdown(t),"DIR").appendField(Jt.Msg.DS_ADD_NODE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.DS_ADD_NODE_TOOLTIP)}},zd={init:function(){this.setColour(Pd),this.appendValueInput("NODE").appendField(Jt.Msg.DS_ADD_NODE_HEAD_NODE),this.appendDummyInput("").appendField(Jt.Msg.DS_ADD_NODE_LINKEDLIST),this.appendValueInput("NODE2").appendField(Jt.Msg.DS_DEL_NODE_NAME),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.DS_DEL_NODE_TOOLTIP)}},Xd={init:function(){this.setColour(Pd),this.appendValueInput("NODE").appendField(Jt.Msg.DS_ADD_NODE_HEAD_NODE),this.appendDummyInput("").appendField(Jt.Msg.DS_ADD_NODE_LINKEDLIST),this.appendDummyInput("").appendField(Jt.Msg.DS_DEL_NODE_ATTR).appendField(new Jt.FieldTextInput("name"),"TYPE"),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_AS),this.appendDummyInput("").appendField(Jt.Msg.DS_ADD_NODE_ATTR),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.DS_DEL_NODE_TOOLTIP)}},jd={init:function(){this.setColour(Pd),this.appendValueInput("NODE").appendField(Jt.Msg.DS_ADD_NODE_HEAD_NODE),this.appendDummyInput("").appendField(Jt.Msg.DS_REVERSE_LINKEDLIST),this.appendValueInput("NODE2").appendField(Jt.Msg.DS_REVERSE_LINKEDLIST_NEW_HEAD),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.DS_DEL_NODE_TOOLTIP)}},qd="#777777",Kd={init:function(){this.setColour(qd),this.appendDummyInput("").appendField("from ").appendField(new Jt.FieldTextInput("ESP32"),"path").appendField(" import ").appendField(new Jt.FieldTextInput("*"),"module"),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Qd={init:function(){this.setColour(qd),this.appendDummyInput("").appendField("import ").appendField(new Jt.FieldTextInput("module"),"module"),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Jd={init:function(){this.setColour(qd),this.appendDummyInput("").appendField(new Jt.FieldTextInput("my_function"),"NAME"),this.itemCount_=1,this.arguments_=["x"],this.updateShape_(),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setMutator(new Jt.icons.MutatorIcon(["factory_create_with_item"],this))},mutationToDom:function(){var t=document.createElement("mutation");t.setAttribute("items",this.itemCount_);for(var e=0;ee?t[e]:'"key'+(e+1)+'"'),"KEY"+e).appendField(":")}},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},Nf={init:function(){this.setColour(xf),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_TYPE_DICT),this.appendStatementInput("STACK"),this.setTooltip(Jt.Msg.DICTS_CREATE_WITH_CONTAINER_TOOLTIP),this.contextMenu=!1}},kf={init:function(){this.setColour(xf),this.appendDummyInput().appendField(Jt.Msg.DICTS_CREATE_WITH_ITEM_TITLE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.DICTS_CREATE_WITH_ITEM_TOOLTIP),this.contextMenu=!1}},Df={init:function(){this.setColour(xf),this.appendDummyInput().appendField(Jt.Msg.DICTS_CREATE_WITH_ITEM_TITLE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.DICTS_CREATE_WITH_ITEM_TOOLTIP),this.contextMenu=!1}},Lf={init:function(){this.setColour(xf),this.appendDummyInput().appendField(Jt.Msg.MIXLY_CREATE_MQTT_CLIENT_AND_CONNECT),this.appendValueInput("SERVER").setCheck(String).appendField(Jt.Msg.MIXLY_EMQX_SERVER).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("USERNAME").setCheck(String).appendField(Jt.Msg.MIXLY_WIFI_USERNAME).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("PASSWORD").setCheck(String).appendField(Jt.Msg.MIXLY_IOT_PASSWORD).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("PROJECT").setCheck(String).appendField(Jt.Msg.MIXLY_EMQX_PROJECT).setAlign(Jt.inputs.Align.RIGHT),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Ff={init:function(){this.setColour(xf),this.appendDummyInput().appendField("MixIO"),this.appendValueInput("TOPIC").appendField(Jt.Msg.MIXLY_EMQX_PUBLISH_NEW).appendField(Jt.Msg.MIXLY_EMQX_PUBLISH_TOPIC),this.appendValueInput("MSG").appendField(Jt.Msg.HTML_BODY),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_ESP32_IOT_EMQX_PUBLISH_TOOLTIP)}},Pf={init:function(){this.setColour(xf),this.appendDummyInput().appendField("MixIO"),this.appendValueInput("TOPIC").appendField(Jt.Msg.MIXLY_EMQX_SUBSCRIBE+Jt.Msg.MIXLY_MICROBIT_MSG).appendField(Jt.Msg.MIXLY_EMQX_PUBLISH_TOPIC),this.appendValueInput("METHOD").appendField(Jt.Msg.MIXLY_EMQX_SET_METHOD),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_ESP32_IOT_EMQX_SUBSCRIBE_TOOLTIP)}},$f={init:function(){this.setColour(xf),this.appendDummyInput().appendField("MixIO"),this.appendValueInput("TOPIC").appendField(Jt.Msg.MSG.stop+Jt.Msg.MIXLY_EMQX_SUBSCRIBE).appendField(Jt.Msg.MIXLY_EMQX_PUBLISH_TOPIC),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_ESP32_IOT_EMQX_SUBSCRIBE_TOOLTIP)}},Bf={init:function(){this.setColour(xf),this.appendDummyInput().appendField("MixIO"),this.appendDummyInput().appendField(Jt.Msg.MIXLY_ESP32_DISCONNECT_ONENET),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Vf={init:function(){this.setColour(xf),this.appendDummyInput().appendField("MixIO"),this.appendDummyInput().appendField(Jt.Msg.MIXLY_EMQX_CONNECT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Uf={init:function(){this.setColour(xf),this.appendDummyInput().appendField("MixIO"),this.appendDummyInput().appendField(Jt.Msg.MIXLY_ESP32_CHECK_ONENET),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Yf={init:function(){this.setColour(xf),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROPYTHON_FORMAT).appendField(Jt.MQTT_Topic),this.setInputsInline(!0),this.setOutput(!0)}},Gf={init:function(){this.setColour(xf),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROPYTHON_FORMAT).appendField(Jt.Msg.MIXLY_EMQX_PUBLISH_MSG),this.setInputsInline(!0),this.setOutput(!0)}},Hf={init:function(){this.setColour(xf),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_ESP32_IOT_MAP_FORMATING),this.setOutput(!0)}},Wf={init:function(){this.setColour(xf),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_MICROPYTHON_FORMAT+"(Json)"),this.setOutput(!0)}},zf={init:function(){this.setColour(xf),this.appendDummyInput().appendField("MixIO"),this.appendDummyInput().appendField(Jt.Msg.MIXLY_EMQX_PING),this.setInputsInline(!0),this.setOutput(!0),this.setTooltip(Jt.Msg.MIXLY_ESP32_IOT_EMQX_PING_TOOLTIP)}},Xf={init:function(){this.setColour(xf),this.appendDummyInput().appendField("MixIO").appendField(Jt.Msg.MIXLY_GET_NTP),this.appendValueInput("addr").appendField(Jt.blynk_SERVER_ADD),this.setInputsInline(!0),this.setOutput(!0)}},jf={init:function(){this.setColour(xf),this.appendDummyInput().appendField(Jt.Msg.MIXLY_CREATE_MQTT_CLIENT_AND_CONNECT),this.appendValueInput("SERVER").appendField(Jt.Msg.MIXLY_EMQX_SERVER).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("KEY").appendField(Jt.Msg.CONTROLS_FOR_INPUT_WITH+Jt.Msg.MIXLY_MIXIO_SHARE_KEY).setAlign(Jt.inputs.Align.RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},qf={init:function(){this.setColour(xf),this.appendDummyInput().appendField(Jt.Msg.MIXLY_CREATE_MQTT_CLIENT_AND_CONNECT),this.appendValueInput("SERVER").appendField(Jt.Msg.MIXLY_EMQX_SERVER).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("KEY").appendField(Jt.Msg.CONTROLS_FOR_INPUT_WITH+"Mixly Key").setAlign(Jt.inputs.Align.RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Kf={init:function(){this.VISITOR_ID=Zt.Config.BOARD.visitorId.str32.substring(0,8).toUpperCase(),this.setColour(xf),this.appendDummyInput("").appendField(this.newQuote_(!0)).appendField(new Jt.FieldTextInput(this.visitorId),"VISITOR_ID").appendField(this.newQuote_(!1)),this.setOutput(!0,null)},onchange:function(){const t=this.getFieldValue("VISITOR_ID");this.VISITOR_ID!==t&&this.setFieldValue(this.VISITOR_ID,"VISITOR_ID")},newQuote_:function(t){if(t==this.RTL)var e="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAqUlEQVQI1z3KvUpCcRiA8ef9E4JNHhI0aFEacm1o0BsI0Slx8wa8gLauoDnoBhq7DcfWhggONDmJJgqCPA7neJ7p934EOOKOnM8Q7PDElo/4x4lFb2DmuUjcUzS3URnGib9qaPNbuXvBO3sGPHJDRG6fGVdMSeWDP2q99FQdFrz26Gu5Tq7dFMzUvbXy8KXeAj57cOklgA+u1B5AoslLtGIHQMaCVnwDnADZIFIrXsoXrgAAAABJRU5ErkJggg==";else e="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAn0lEQVQI1z3OMa5BURSF4f/cQhAKjUQhuQmFNwGJEUi0RKN5rU7FHKhpjEH3TEMtkdBSCY1EIv8r7nFX9e29V7EBAOvu7RPjwmWGH/VuF8CyN9/OAdvqIXYLvtRaNjx9mMTDyo+NjAN1HNcl9ZQ5oQMM3dgDUqDo1l8DzvwmtZN7mnD+PkmLa+4mhrxVA9fRowBWmVBhFy5gYEjKMfz9AylsaRRgGzvZAAAAAElFTkSuQmCC";return new Jt.FieldImage(e,12,12,'"')}},Qf={init:function(){this.VISITOR_ID=Zt.Config.BOARD.visitorId.str32.substring(0,8).toUpperCase(),this.setColour(xf),this.appendDummyInput("").appendField(new Jt.FieldTextInput(this.visitorId),"VISITOR_ID"),this.setOutput(!0,null)},onchange:function(){const t=this.getFieldValue("VISITOR_ID");this.VISITOR_ID!==t&&this.setFieldValue(this.VISITOR_ID,"VISITOR_ID")}},Jf={init:function(){this.setColour(xf),this.appendDummyInput().appendField("MixIO").appendField(Jt.Msg.MSG.catEthernet_clinet),this.setOutput(!0),this.setInputsInline(!0)}},Zf={init:function(){this.setColour(xf),this.appendDummyInput().appendField("HTTP"+Jt.Msg.MIXLY_Client),this.appendValueInput("addr").appendField(Jt.Msg.DISPLAY_IMAGE_LET2),this.appendDummyInput().appendField(Jt.Msg.MIXLY_REQUESTS_GET).appendField(Jt.Msg.MIXLY_GET_CURRENT_TIME).appendField(Jt.Msg.MIXLY_OPEN_DEBUG).appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_TURTLE_WRITE_MOVE_TRUE,"True"],[Jt.Msg.MIXLY_TURTLE_WRITE_MOVE_FALSE,"False"]]),"key"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},tm={init:function(){this.setColour(xf),this.appendDummyInput().appendField("HTTP"+Jt.Msg.MIXLY_Client).appendField(Jt.Msg.MIXLY_GET).appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_REQUESTS_LEN,"client_len"],[Jt.Msg.MIXLY_REQUESTS_GET_LEN,"server_len"],[Jt.Msg.MIXLY_REQUESTS_MESSAGE,"text"]]),"key"),this.setOutput(!0),this.setInputsInline(!0)}},em={init:function(){this.setColour(xf),this.appendDummyInput().appendField("MQTT"+Jt.Msg.MIXLY_Client),this.appendValueInput("addr").appendField(Jt.Msg.MIXLY_CONNECTTO),this.appendDummyInput().appendField(Jt.Msg.MIXLY_INIT_SUBSCRIBE).appendField(Jt.MQTT_Topic).appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_GET_CURRENT_TIME,""]]),"key").appendField(Jt.Msg.MIXLY_OPEN_DEBUG).appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_TURTLE_WRITE_MOVE_TRUE,"True"],[Jt.Msg.MIXLY_TURTLE_WRITE_MOVE_FALSE,"False"]]),"key2"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},nm={init:function(){this.setColour(xf),this.appendDummyInput().appendField("MQTT"+Jt.Msg.MIXLY_Client).appendField(Jt.Msg.MIXLY_GET).appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_REQUESTS_LEN,"client_len"],[Jt.Msg.MIXLY_REQUESTS_GET_LEN,"server_len"],[Jt.Msg.MIXLY_REQUESTS_MESSAGE,"time_msg()"]]),"key"),this.setOutput(!0),this.setInputsInline(!0)}},im=Rf,sm=Af,rm=Of,am=Cf,om=230,lm={init:function(){this.setColour(om),this.appendDummyInput("").appendField(new Jt.FieldDropdown(Zt.Profile.default.digital_write),"PIN"),this.setOutput(!0)}},um={init:function(){this.setColour(om),this.appendDummyInput("").appendField(new Jt.FieldDropdown(Zt.Profile.default.digital_read),"PIN"),this.setOutput(!0)}},hm={init:function(){this.setColour(om),this.appendDummyInput("").appendField(new Jt.FieldDropdown(Zt.Profile.default.analog_write),"PIN"),this.setOutput(!0)}},pm={init:function(){this.setColour(om),this.appendDummyInput("").appendField(new Jt.FieldDropdown(Zt.Profile.default.analog_read),"PIN"),this.setOutput(!0)}},cm={init:function(){this.setColour(40),this.appendDummyInput("").appendField(new Jt.FieldLabel(Jt.Msg.MIXPY_SERIAL_OPEN)).appendField(new Jt.FieldTextInput("ser"),"SER"),this.appendDummyInput().appendField(Jt.Msg.MIXLY_SERIAL_BEGIN).appendField(new Jt.FieldDropdown([["115200","115200"],["256000","256000"],["128000","128000"],["57600","57600"],["56000","56000"],["43000","43000"],["38400","38400"],["28800","28800"],["19200","19200"],["9600","9600"],["4800","4800"],["2400","2400"],["1200","1200"],["600","600"],["300","300"],["110","110"]]),"BPS"),this.appendValueInput("VAR").appendField(Jt.Msg.MIXPY_SERIAL_OPEN_TIMEOUT),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setTooltip(Jt.Msg.MIXPY_SERIAL_OPEN_TOOLTIP)}},dm={init:function(){this.setColour(40),this.appendValueInput("SER"),this.appendValueInput("VAR").appendField(Jt.Msg.MIXPY_SERIAL_WRITE),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setTooltip(Jt.Msg.MIXPY_SERIAL_WRITE_TOOLTIP)}},fm={init:function(){this.setColour(40),this.appendValueInput("SER"),this.appendValueInput("VAR").setCheck(Number).appendField(Jt.Msg.MIXPY_SERIAL_READ),this.setInputsInline(!0),this.setOutput(!0,String),this.setTooltip(Jt.Msg.MIXPY_SERIAL_READ_TOOLTIP)}},mm={init:function(){this.setColour(40),this.appendValueInput("SER"),this.appendDummyInput().appendField(Jt.Msg.MIXPY_SERIAL_CLOSE),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setTooltip(Jt.Msg.MIXPY_SERIAL_CLOSE_TOOLTIP)}},gm=80,_m={init:function(){this.appendDummyInput().appendField(Jt.Msg.SKLEARN_CLASSIFICATION_GENERATION),this.appendValueInput("n_samples").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_SAMPLES),this.appendValueInput("n_features").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_FEATURES),this.appendValueInput("n_informative").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_EFFECTIVE_FEATURES),this.appendValueInput("n_redundant").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_REDUNDANT_FEATURES),this.appendValueInput("n_repeated").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_REPEATED_FEATURES),this.appendValueInput("n_classes").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_CLASSES),this.appendValueInput("n_clusters_per_class").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_CLUSTERS_PER_CLASSES),this.appendValueInput("random_state").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.RANDOM_SEED),this.setInputsInline(!1),this.setOutput(!0,null),this.setColour(gm),this.setTooltip(""),this.setHelpUrl("")}},Tm={init:function(){this.appendDummyInput().appendField(Jt.Msg.SKLEARN_REGRESSION_GENERATION),this.appendValueInput("n_samples").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_SAMPLES),this.appendValueInput("n_features").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_FEATURES),this.appendValueInput("n_informative").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_EFFECTIVE_FEATURES),this.appendValueInput("n_targets").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_LABELS),this.appendValueInput("bias").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.DEVIATION),this.appendValueInput("noise").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NOISE),this.appendValueInput("random_state").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.RANDOM_SEED),this.setInputsInline(!1),this.setOutput(!0,null),this.setColour(gm),this.setTooltip(""),this.setHelpUrl("")}},ym={init:function(){this.appendDummyInput().appendField(Jt.Msg.SKLEARN_CLUSTERING_GENERATION),this.appendValueInput("n_samples").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_SAMPLES),this.appendValueInput("n_features").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_FEATURES),this.appendValueInput("centers").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_CLUSTERS),this.appendValueInput("cluster_std").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.STANDARD_DEVIATION_OF_CLUSTER),this.appendValueInput("center_box").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.CLUSTER_BOUNDING_BOX),this.appendValueInput("shuffle").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.SHUFFLE_SAMPLES),this.appendValueInput("random_state").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.RANDOM_SEED),this.setInputsInline(!1),this.setOutput(!0,null),this.setColour(gm),this.setTooltip(""),this.setHelpUrl("")}},Im={init:function(){var t=[[Jt.Msg.SKLEARN_LOAD_IRIS,"load_iris"],[Jt.Msg.SKLEARN_LOAD_BOSTON,"load_boston"],[Jt.Msg.SKLEARN_LOAD_DIABETES,"load_diabetes"],[Jt.Msg.SKLEARN_LOAD_BREAST_CANCER,"load_breast_cancer"],[Jt.Msg.SKLEARN_LOAD_LINNERUD,"load_linnerud"],[Jt.Msg.SKLEARN_LOAD_DIGITS,"load_digits"]];this.appendDummyInput().appendField("sklearn "+Jt.Msg.LOAD).appendField(new Jt.FieldDropdown(t),"type").appendField(new Jt.FieldTextInput("iris"),"name"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(gm),this.setTooltip(""),this.setHelpUrl("")},getVars:function(){return[this.getFieldValue("name")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("name"))&&this.setTitleValue(e,"name")}},Em={init:function(){this.appendValueInput("name").setCheck(null).appendField("sklearn "+Jt.Msg.DATA_SET),this.appendDummyInput().setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MIXLY_GET).appendField(new Jt.FieldDropdown([[Jt.Msg.EIGENVALUES,"data"],[Jt.Msg.LABEL_VALUE,"target"],[Jt.Msg.FEATURE,"feature_names"],[Jt.Msg.mixpy_PYLAB_TICKS_TAG,"target_names"]]),"type"),this.setOutput(!0,null),this.setColour(gm),this.setTooltip(""),this.setHelpUrl("")}},bm={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.DATA_SEGMENTATION),this.appendValueInput("train_data").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.EIGENVALUES),this.appendValueInput("train_target").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.LABEL_VALUE),this.appendValueInput("test_size").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.TEST_SET_PROPORTION),this.appendValueInput("rondom_state").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.RANDOM_SEED),this.setInputsInline(!1),this.setOutput(!0,null),this.setColour(gm),this.setTooltip(""),this.setHelpUrl("")}},vm={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.DATA_SEGMENTATION),this.appendValueInput("train_data").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.EIGENVALUES),this.appendValueInput("test_size").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.TEST_SET_PROPORTION),this.appendValueInput("rondom_state").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.RANDOM_SEED),this.setInputsInline(!1),this.setOutput(!0,null),this.setColour(gm),this.setTooltip(""),this.setHelpUrl("")}},wm={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.SKLEARN_LINEARREGRESSION_INIT),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendValueInput("fit_intercept").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.SKLEARN_CALCULATE_MODEL_INTERRUPT),this.appendValueInput("normalize").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.SKLEARN_REGRESSION_NORMIALIZATION),this.appendValueInput("n_jobs").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.SKLEARN_THREADS),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(gm),this.setTooltip(""),this.setHelpUrl("")}},Sm={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.SKLEARN_RIDGE_INIT),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendValueInput("alpha").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.SKLEARN_REGULA_INTENSITY),this.appendValueInput("fit_intercept").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.SKLEARN_CALCULATE_MODEL_INTERRUPT),this.appendValueInput("normalize").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.SKLEARN_REGRESSION_NORMIALIZATION),this.appendValueInput("max_iter").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.SKLEARN_MAX_ITER),this.appendValueInput("random_state").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.RANDOM_SEED),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(gm),this.setTooltip(""),this.setHelpUrl("")}},xm={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.SKLEARN_DECISIONTREE_INIT).appendField(new Jt.FieldDropdown([[Jt.Msg.SKLEARN_CLASSIFICATION_ALGORITHM,"DecisionTreeClassifier"],[Jt.Msg.SKLEARN_REGRESSION_ALGORITHM,"DecisionTreeRegressor"]]),"type"),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendValueInput("max_depth").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.SKLEARN_MAXIMUM_TREE_DEPTH),this.appendValueInput("random_state").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.RANDOM_SEED),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(gm),this.setTooltip(""),this.setHelpUrl("")}},Rm={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.SKLEARN_RANDOMFOREST_INIT).appendField(new Jt.FieldDropdown([[Jt.Msg.SKLEARN_CLASSIFICATION_ALGORITHM,"RandomForestClassifier"],[Jt.Msg.SKLEARN_REGRESSION_ALGORITHM,"RandomForestRegressor"]]),"type"),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendValueInput("n_estimators").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_TREES),this.appendValueInput("max_depth").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.SKLEARN_MAXIMUM_TREE_DEPTH),this.appendValueInput("n_jobs").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.SKLEARN_THREADS),this.appendValueInput("random_state").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.RANDOM_SEED),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(gm),this.setTooltip(""),this.setHelpUrl("")}},Am={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.SKLEARN_KNN_INIT).appendField(new Jt.FieldDropdown([[Jt.Msg.SKLEARN_CLASSIFICATION_ALGORITHM,"KNeighborsClassifier"],[Jt.Msg.SKLEARN_REGRESSION_ALGORITHM,"KNeighborsRegressor"]]),"type"),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendValueInput("K").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField("K"),this.appendValueInput("n_jobs").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.SKLEARN_THREADS),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(gm),this.setTooltip(""),this.setHelpUrl("")}},Om={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.SKLEARN_GAUSSINNB_INIT),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(gm),this.setTooltip(""),this.setHelpUrl("")}},Mm={init:function(){this.appendDummyInput().appendField("sklearn 初始化 PCA 算法"),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendValueInput("n_components").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.SKLEARN_PCA_N_COMPONENTS),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(gm),this.setTooltip(""),this.setHelpUrl("")}},Cm={init:function(){this.appendDummyInput().appendField("sklearn PCA 降维"),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendValueInput("train_data").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.EIGENVALUES),this.setInputsInline(!0),this.setOutput(!0,null),this.setColour(gm),this.setTooltip(""),this.setHelpUrl("")}},Nm={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.SKLEARN_KMEANS_INIT),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendValueInput("n_clusters").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_CLUSTERS_JUST),this.appendValueInput("max_iter").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.SKLEARN_MAX_ITER),this.appendValueInput("random_state").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.RANDOM_SEED),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(gm),this.setTooltip(""),this.setHelpUrl("")}},km={init:function(){this.appendDummyInput().appendField("sklearn K-均值聚类"),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendValueInput("train_data").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.EIGENVALUES),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(gm),this.setTooltip(""),this.setHelpUrl("")}},Dm={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.TRAINING_MODEL),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendValueInput("train_data").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.EIGENVALUES),this.appendValueInput("train_target").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.LABEL_VALUE),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(gm),this.setTooltip(""),this.setHelpUrl("")}},Lm={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.TRAINING_MODEL),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendValueInput("train_data").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.EIGENVALUES),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(gm),this.setTooltip(""),this.setHelpUrl("")}},Fm={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.MODEL_PRODICTION),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendValueInput("train_data").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.EIGENVALUES),this.setInputsInline(!0),this.setOutput(!0,null),this.setColour(gm),this.setTooltip(""),this.setHelpUrl("")}},Pm={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.CALCULATE_THE_SCORE),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendValueInput("train_data").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.EIGENVALUES),this.appendValueInput("train_target").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.LABEL_VALUE),this.setInputsInline(!0),this.setOutput(!0,null),this.setColour(gm),this.setTooltip(""),this.setHelpUrl("")}},$m={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.CALCULATE_THE_SCORE),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendValueInput("train_data").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.EIGENVALUES),this.setInputsInline(!0),this.setOutput(!0,null),this.setColour(gm),this.setTooltip(""),this.setHelpUrl("")}},Bm={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.SKLEARN_GENERALIZED_LINEAR_REGRESSION),this.appendValueInput("model_name").setAlign(Jt.inputs.Align.RIGHT).setCheck(null).appendField(Jt.Msg.MODEL_NAME),this.appendDummyInput().setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MIXLY_GET).appendField(new Jt.FieldDropdown([[Jt.Msg.SKLEARN_COEF,"coef_"],[Jt.Msg.SKLEARN_INTERCEPT,"intercept_"]]),"type"),this.setOutput(!0,null),this.setColour(gm),this.setTooltip(""),this.setHelpUrl("")}},Vm={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.SKLEARN_CLUSTERING),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendDummyInput().appendField(Jt.Msg.MIXLY_GET).appendField(new Jt.FieldDropdown([[Jt.Msg.SKLEARN_CLUSTER_CENTER,"cluster_centers_"],[Jt.Msg.SKLEARN_LABELS_AFTER_CLUSTERING,"labels_"],[Jt.Msg.SKLEARN_CLUSTERING_SUM_OF_SQUARED_DISTANCES,"inertia_"]]),"type"),this.setInputsInline(!0),this.setOutput(!0,null),this.setColour(gm),this.setTooltip(""),this.setHelpUrl("")}},Um={init:function(){this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField("sklearn").appendField(new Jt.FieldDropdown([[Jt.Msg.SKLEARN_SAVE_MODEL,"dump"],[Jt.Msg.SKLEARN_LOAD_MODEL,"load"]]),"type").appendField(" "+Jt.Msg.MODEL_NAME),this.appendValueInput("address").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_THE_PATH),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(gm),this.setTooltip(""),this.setHelpUrl("")}},Ym=120,Gm={init:function(){this.setColour(Ym),this.appendValueInput("DELAY_TIME",Number).appendField(Jt.Msg.MIXLY_DELAY+"("+Jt.Msg.MIXLY_MILLIS+")").setCheck(Number),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_CONTROL_DELAY)}},Hm={init:function(){this.setColour(Ym),this.appendDummyInput().appendField(Jt.Msg.blockpy_time_time),this.setOutput(!0,Number),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_CONTROL_MILLIS)}},Wm={init:function(){this.setColour(Ym),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_SYSTEM_TIME_LOCALTIME),this.appendDummyInput().appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_SYSTEM_TIME_LOCALTIME_ALL,"all"],[Jt.Msg.MIXLY_SYSTEM_TIME_LOCALTIME_YEAR,"0"],[Jt.Msg.MIXLY_SYSTEM_TIME_LOCALTIME_MONTH,"1"],[Jt.Msg.MIXLY_SYSTEM_TIME_LOCALTIME_DATE,"2"],[Jt.Msg.MIXLY_SYSTEM_TIME_LOCALTIME_HOUR,"3"],[Jt.Msg.MIXLY_SYSTEM_TIME_LOCALTIME_MINUTE,"4"],[Jt.Msg.MIXLY_SYSTEM_TIME_LOCALTIME_SECOND,"5"],[Jt.Msg.MIXLY_SYSTEM_TIME_LOCALTIME_INWEEK,"6"],[Jt.Msg.MIXLY_SYSTEM_TIME_LOCALTIME_INYEAR,"7"],[Jt.Msg.MIXLY_SYSTEM_TIME_LOCALTIME_DST,"8"]]),"op"),this.setOutput(!0),this.setInputsInline(!0)}},zm={init:function(){this.setColour(Ym),this.appendValueInput("STATUS_CODE",Number).appendField(Jt.Msg.MIXLY_MICROBIT_Panic_with_status_code).setCheck(Number),this.setPreviousStatement(!0,null),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_CONTROL_DELAY)}},Xm={init:function(){this.setColour(Ym),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_Reset_micro),this.setPreviousStatement(!0)}},jm={init:function(){this.setColour(Ym),this.appendValueInput("TIME").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField("MsTimer2").appendField(Jt.Msg.MIXLY_MSTIMER2_EVERY),this.appendDummyInput().appendField("ms"),this.appendStatementInput("DO").appendField(Jt.Msg.MIXLY_MSTIMER2_DO),this.setPreviousStatement(!0),this.setNextStatement(!0)}},qm={init:function(){this.setColour(Ym),this.appendDummyInput().appendField("MsTimer2").appendField(Jt.Msg.MIXLY_MSTIMER2_START),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Km={init:function(){this.setColour(Ym),this.appendDummyInput().appendField("MsTimer2").appendField(Jt.Msg.MIXLY_STOP),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Qm={init:function(){this.setColour(Ym),this.appendValueInput("DELAY_TIME",Number).appendField(Jt.Msg.MIXLY_DELAY).setCheck(Number),this.appendDummyInput().appendField(Jt.Msg.MIXLY_SECOND),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_CONTROL_DELAY)}},Jm=180,Zm={init:function(){this.setColour(Jm),this.appendDummyInput("").appendField(Jt.Msg.blockpy_turtle_create).appendField(new Jt.FieldTextInput("tina"),"VAR"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.blockpy_turtle_create_TOOLTIP)},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},tg={init:function(){this.setColour(Jm),this.appendDummyInput().appendField(Jt.Msg.blockpy_TURTLE_DONE),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},eg={init:function(){this.setColour(Jm),this.appendDummyInput().appendField(Jt.Msg.MIXLY_PYTHON_TURTLE_EXITONCLICK),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},ng={init:function(){this.appendValueInput("TUR").setCheck("Turtle");var t=[[Jt.Msg.blockpy_forward,"forward"],[Jt.Msg.blockpy_backward,"backward"]];this.setColour(Jm),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_MICROBIT_JS_MOVE_BY).appendField(new Jt.FieldDropdown(t),"DIR").appendField(Jt.Msg.MIXLY_MICROBIT_JS_MOVE_BY_num),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("DIR");return{forward:Jt.Msg.MIXLY_TOOLTIP_TURTEL_FORWARD,backward:Jt.Msg.MIXLY_TOOLTIP_TURTEL_BACKWARD}[t]}))}},ig={init:function(){this.appendValueInput("TUR").setCheck("Turtle");var t=[[Jt.Msg.blockpy_left,"left"],[Jt.Msg.blockpy_right,"right"]];this.setColour(Jm),this.appendValueInput("VAR").appendField(Jt.Msg.blockpy_turtle_rotate).appendField(new Jt.FieldDropdown(t),"DIR").appendField(Jt.Msg.MIXLY_MICROBIT_JS_BY_ANGLE),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("DIR");return{left:Jt.Msg.MIXLY_TOOLTIP_TURTEL_LEFT,right:Jt.Msg.MIXLY_TOOLTIP_TURTEL_RIGHT}[t]}))}},sg={init:function(){this.setColour(Jm),this.appendValueInput("TUR").setCheck("Turtle"),this.appendValueInput("data").setCheck(Number).appendField(Jt.Msg.blockpy_setheading),this.appendDummyInput().appendField(Jt.Msg.blockpy_setheading_degree),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},rg={init:function(){this.setColour(Jm),this.appendValueInput("TUR").setCheck("Turtle"),this.appendValueInput("data").setCheck(Number).appendField(Jt.Msg.MIXLY_TURTLE_SCREEN_DELAY),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MILLIS),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_TURTEL_SCREEN_DELAY),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},ag={init:function(){this.setColour(Jm),this.appendValueInput("TUR").setCheck("Turtle"),this.appendValueInput("data").setCheck(Number).appendField(Jt.Msg.blockpy_turtle_goto),this.appendValueInput("val").setCheck(Number).appendField(Jt.Msg.blockpy_turtle_goto_y),this.appendDummyInput().appendField(Jt.Msg.blockpy_turtle_goto_position),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},og={init:function(){this.appendValueInput("TUR").setCheck("Turtle");var t=[[Jt.Msg.PYLAB_LABEL_X,"x"],[Jt.Msg.PYLAB_LABEL_Y,"y"]];this.setColour(Jm),this.appendValueInput("VAR").appendField(new Jt.FieldDropdown(t),"DIR").appendField(Jt.Msg.MIXLY_MIXPY_TURTLE_SETXY),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_MIXPY_TURTLE_SETXY_TOOLTIP)}},lg={init:function(){this.setColour(Jm);var t=[[Jt.Msg.TURTLE_POS,"pos"],[Jt.Msg.TURTLE_SHAPE,"shape"],[Jt.Msg.TURTLE_HEADING,"heading"],[Jt.Msg.MIXLY_MIXPY_TURTLE_WIDTH,"width"],[Jt.Msg.MIXLY_TURTEL_GET_SHAPESIZE,"shapesize"],[Jt.Msg.MIXLY_SPEED,"speed"]];this.appendValueInput("TUR").setCheck("Turtle"),this.appendDummyInput("").appendField(Jt.Msg.TURTLE_POS_SHAPE).appendField(new Jt.FieldDropdown(t),"DIR");var e=this;this.setTooltip((function(){var t=e.getFieldValue("DIR");return{pos:Jt.Msg.MIXLY_TOOLTIP_TURTEL_POS,shape:Jt.Msg.MIXLY_TOOLTIP_TURTEL_SHAPE,heading:Jt.Msg.MIXLY_TOOLTIP_TURTEL_HEADING,width:Jt.Msg.MIXLY_TOOLTIP_TURTEL_WIDTH,speed:Jt.Msg.MIXLY_TOOLTIP_TURTEL_GET_SPEED,shapesize:Jt.Msg.MIXLY_TURTEL_GET_SHAPESIZE_TOOLTIP}[t]})),this.setOutput(!0),this.setInputsInline(!0)}},ug={init:function(){this.appendValueInput("TUR").setCheck("Turtle");var t=[[Jt.Msg.MIXLY_LCD_STAT_CLEAR,"clear"],[Jt.Msg.blockpy_turtle_reset,"reset"],[Jt.Msg.blockpy_turtle_home,"home"]];this.setColour(Jm),this.appendDummyInput("").appendField(new Jt.FieldDropdown(t),"DIR"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("DIR");return{clear:Jt.Msg.MIXLY_TOOLTIP_TURTEL_CLEAR,reset:Jt.Msg.MIXLY_TOOLTIP_TURTEL_RESET,home:Jt.Msg.MIXLY_TOOLTIP_TURTEL_HOME}[t]}))}},hg={init:function(){this.appendValueInput("TUR").setCheck("Turtle");var t=[[Jt.Msg.blockpy_turtle_penup,"penup"],[Jt.Msg.blockpy_turtle_pendown,"pendown"]];this.setColour(Jm),this.appendDummyInput("").appendField(new Jt.FieldDropdown(t),"DIR"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("DIR");return{penup:Jt.Msg.MIXLY_TOOLTIP_TURTEL_PENUP,pendown:Jt.Msg.MIXLY_TOOLTIP_TURTEL_PENDOWN}[t]}))}},pg={init:function(){this.appendValueInput("TUR").setCheck("Turtle");var t=[[Jt.Msg.blockpy_turtle_beginfill,"begin"],[Jt.Msg.blockpy_turtle_endfill,"end"]];this.setColour(Jm),this.appendDummyInput("").appendField(new Jt.FieldDropdown(t),"DIR"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("DIR");return{begin:Jt.Msg.MIXLY_TOOLTIP_TURTEL_BEGINFILL,end:Jt.Msg.MIXLY_TOOLTIP_TURTEL_ENDFILL}[t]}))}},cg={init:function(){this.appendDummyInput("").appendField(new Jt.FieldTextInput("tina"),"TUR");var t=[[Jt.Msg.blockpy_turtle_size,"pensize"],[Jt.Msg.MIXLY_SPEED,"speed"]];this.setColour(Jm),this.appendValueInput("VAR").appendField(Jt.Msg.blockpy_turtle_set).appendField(new Jt.FieldDropdown(t),"DIR").appendField(Jt.Msg.blockpy_turtle_set_num),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("DIR");return{pensize:Jt.Msg.MIXLY_TOOLTIP_TURTEL_SIZE,speed:Jt.Msg.MIXLY_TOOLTIP_TURTEL_SPEED}[t]}))}},dg={init:function(){this.setColour(Jm),this.appendValueInput("TUR").setCheck("Turtle"),this.appendValueInput("data").setCheck(Number).appendField(Jt.Msg.blockpy_turtle_set_size),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_TURTEL_SIZE),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},fg={init:function(){this.setColour(Jm),this.appendValueInput("TUR").setCheck("Turtle"),this.appendValueInput("data").setCheck(Number).appendField(Jt.Msg.blockpy_turtle_set_speed),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_TURTEL_SPEED),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},mg={init:function(){this.appendValueInput("TUR").setCheck("Turtle");var t=[[Jt.Msg.blockpy_turtle_circle,"circle"],[Jt.Msg.blockpy_turtle_dot,"dot"]];this.setColour(Jm),this.appendValueInput("VAR").appendField(Jt.Msg.blockpy_turtle_draw).appendField(new Jt.FieldDropdown(t),"DIR").appendField(Jt.Msg.blockpy_turtle_radius),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("DIR");return{circle:Jt.Msg.MIXLY_TOOLTIP_TURTEL_CIRCLE,dot:Jt.Msg.MIXLY_TOOLTIP_TURTEL_DOT}[t]}))}},gg={init:function(){this.appendValueInput("TUR").setCheck("Turtle"),this.setColour(Jm),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_MIXPY_TURTLE_DRAW_CIRCLE).appendField(Jt.Msg.blockpy_turtle_radius),this.appendValueInput("data").setCheck(Number).appendField(Jt.Msg.blockpy_turtle_angle),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_TURTEL_CIRCLE)}},_g={init:function(){this.appendValueInput("TUR").setCheck("Turtle");var t=[[Jt.Msg.blockpy_turtle_hide,"hideturtle"],[Jt.Msg.blockpy_turtle_show,"showturtle"]];this.setColour(Jm),this.appendDummyInput("").appendField(new Jt.FieldDropdown(t),"DIR"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("DIR");return{hideturtle:Jt.Msg.MIXLY_TOOLTIP_TURTEL_HIDE,showturtle:Jt.Msg.MIXLY_TOOLTIP_TURTEL_SHOW}[t]}))}},Tg={init:function(){this.setColour(Jm),this.appendDummyInput().appendField(Jt.Msg.blockpy_turtle_bgcolor).appendField(new Jt.FieldColour("#ff0000"),"FIELDNAME"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},yg={init:function(){this.appendValueInput("TUR").setCheck("Turtle"),this.setColour(Jm),this.appendDummyInput().appendField(Jt.Msg.blockpy_turtle_pencolor).appendField(new Jt.FieldColour("#ff0000"),"FIELDNAME"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Ig={init:function(){this.appendValueInput("TUR").setCheck("Turtle"),this.setColour(Jm),this.appendDummyInput().appendField(Jt.Msg.blockpy_turtle_fillcolor).appendField(new Jt.FieldColour("#ff0000"),"FIELDNAME"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Eg={init:function(){this.setColour(Jm),this.appendValueInput("TUR").setCheck("Turtle"),this.appendDummyInput("").appendField(Jt.Msg.TURTLE_CLONE),this.setTooltip(Jt.Msg.TURTLE_CLONE_TOOLTIP),this.setOutput(!0)}},bg={init:function(){this.setColour(Jm),this.appendValueInput("VAR").setCheck(String).appendField(Jt.Msg.blockpy_turtle_bgcolor),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},vg={init:function(){this.appendValueInput("TUR").setCheck("Turtle"),this.setColour(Jm),this.appendValueInput("VAR").setCheck(String).appendField(Jt.Msg.blockpy_turtle_pencolor),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},wg={init:function(){this.appendValueInput("TUR").setCheck("Turtle"),this.setColour(Jm),this.appendValueInput("VAR").setCheck(String).appendField(Jt.Msg.blockpy_turtle_fillcolor),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Sg={init:function(){this.appendValueInput("TUR").setCheck("Turtle"),this.setColour(Jm),this.appendDummyInput().appendField(Jt.Msg.blockpy_turtle_pencolor).appendField(new Jt.FieldColour("#ff0000"),"FIELDNAME"),this.appendDummyInput().appendField(Jt.Msg.blockpy_turtle_fillcolor).appendField(new Jt.FieldColour("#ff0000"),"FIELDNAME2"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},xg={init:function(){this.appendValueInput("TUR").setCheck("Turtle"),this.setColour(Jm),this.appendValueInput("VAR1").setCheck(String).appendField(Jt.Msg.blockpy_turtle_pencolor),this.appendValueInput("VAR2").setCheck(String).appendField(Jt.Msg.blockpy_turtle_fillcolor),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Rg={init:function(){this.setColour(Jm),this.appendValueInput("VAR").setCheck(String).appendField(Jt.Msg.blockpy_turtle_bgcolor_hex),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Ag={init:function(){this.appendValueInput("TUR").setCheck("Turtle"),this.setColour(Jm),this.appendValueInput("VAR").setCheck(String).appendField(Jt.Msg.blockpy_turtle_pencolor_hex),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Og={init:function(){this.appendValueInput("TUR").setCheck("Turtle"),this.setColour(Jm),this.appendValueInput("VAR").setCheck(String).appendField(Jt.Msg.blockpy_turtle_fillcolor_hex),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Mg={init:function(){this.appendValueInput("TUR").setCheck("Turtle");var t=[[Jt.Msg.blockpy_turtle_shape_arrow,"arrow"],[Jt.Msg.blockpy_turtle_shape_turtle,"turtle"],[Jt.Msg.blockpy_turtle_shape_circle,"circle"],[Jt.Msg.blockpy_turtle_shape_square,"square"],[Jt.Msg.blockpy_turtle_shape_triangle,"triangle"],[Jt.Msg.blockpy_turtle_shape_classic,"classic"]];this.setColour(Jm),this.appendDummyInput("").appendField(Jt.Msg.blockpy_turtle_shape).appendField(new Jt.FieldDropdown(t),"DIR"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.TURTLE_SHAPE_TOOLTIP)}},Cg={init:function(){this.appendValueInput("TUR").setCheck("Turtle"),this.setColour(Jm),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_TURTEL_SHAPESIZE),this.appendValueInput("WID").setCheck(Number).appendField(Jt.Msg.MIXLY_TURTEL_SHAPESIZE_WID),this.appendValueInput("LEN").setCheck(Number).appendField(Jt.Msg.MIXLY_TURTEL_SHAPESIZE_LEN),this.appendValueInput("OUTLINE").setCheck(Number).appendField(Jt.Msg.MIXLY_TURTEL_SHAPESIZE_OUTLINE),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_SHAPESIZE)}},Ng={init:function(){this.appendDummyInput("").appendField(Jt.Msg.MIXLY_MIXPY_TURTLE_NUMINPUT),this.setColour(Jm),this.appendValueInput("TITLE").setCheck(String).appendField(Jt.Msg.MIXLY_MIXPY_TURTLE_TEXTINPUT_TITLE),this.appendValueInput("PROMPT").setCheck(String).appendField(Jt.Msg.MIXLY_MIXPY_TURTLE_TEXTINPUT_PROMPT),this.appendValueInput("DEFAULT").setCheck(Number).appendField(Jt.Msg.DICTS_DEFAULT_VALUE),this.appendValueInput("MIN").setCheck(Number).appendField(Jt.Msg.MATH_ONLIST_OPERATOR_MIN),this.appendValueInput("MAX").setCheck(Number).appendField(Jt.Msg.MATH_ONLIST_OPERATOR_MAX),this.setInputsInline(!0),this.setOutput(!0,Number),this.setTooltip(Jt.Msg.TURTLE_NUMINPUT_TOOLTIP)}},kg={init:function(){this.appendDummyInput("").appendField(Jt.Msg.MIXLY_MIXPY_TURTLE_TEXTINPUT),this.setColour(Jm),this.appendValueInput("TITLE").setCheck(String).appendField(Jt.Msg.MIXLY_MIXPY_TURTLE_TEXTINPUT_TITLE),this.appendValueInput("PROMPT").setCheck(String).appendField(Jt.Msg.MIXLY_MIXPY_TURTLE_TEXTINPUT_PROMPT),this.setInputsInline(!0),this.setOutput(!0,String),this.setTooltip(Jt.Msg.TURTLE_TEXTINPUT_TOOLTIP)}},Dg={init:function(){this.appendValueInput("TUR").setCheck("Turtle"),this.setColour(Jm),this.appendValueInput("VAR").setCheck(String).appendField(Jt.Msg.blockpy_turtle_write),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.TURTLE_WRITE_TOOLTIP)}},Lg={init:function(){var t=[[Jt.Msg.MIXLY_TURTLE_WRITE_MOVE_FALSE,"False"],[Jt.Msg.MIXLY_TURTLE_WRITE_MOVE_TRUE,"True"]],e=[[Jt.Msg.MIXLY_TURTLE_WRITE_ALIGN_LEFT,"left"],[Jt.Msg.MIXLY_TURTLE_WRITE_ALIGN_CENTER,"center"],[Jt.Msg.MIXLY_TURTLE_WRITE_ALIGN_RIGHT,"right"]],n=[[Jt.Msg.MIXLY_TURTLE_WRITE_FONT_TYPE_NORMAL,"normal"],[Jt.Msg.MIXLY_TURTLE_WRITE_FONT_TYPE_BOLD,"bold"],[Jt.Msg.MIXLY_TURTLE_WRITE_FONT_TYPE_ITALIC,"italic"],[Jt.Msg.MIXLY_TURTLE_WRITE_FONT_TYPE_BOLD_ITALIC,'bold","italic']];this.appendValueInput("TUR").setCheck("Turtle"),this.setColour(Jm),this.appendValueInput("VAR").setCheck(String).appendField(Jt.Msg.blockpy_turtle_write),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_TURTLE_WRITE_MOVE).appendField(new Jt.FieldDropdown(t),"MOVE"),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_TURTLE_WRITE_ALIGN).appendField(new Jt.FieldDropdown(e),"ALIGN"),this.appendValueInput("FONTNAME").setCheck(String).appendField(Jt.Msg.MIXLY_TURTLE_WRITE_FONT_NAME),this.appendValueInput("FONTNUM").setCheck(Number).appendField(Jt.Msg.MIXLY_TURTLE_WRITE_FONT_NUM),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_TURTLE_WRITE_FONT_TYPE).appendField(new Jt.FieldDropdown(n),"FONTTYPE"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.TURTLE_WRITE_TOOLTIP)}},Fg={init:function(){var t=[[Jt.Msg.MIXLY_TURTLE_WRITE_MOVE_FALSE,"False"],[Jt.Msg.MIXLY_TURTLE_WRITE_MOVE_TRUE,"True"]],e=[[Jt.Msg.MIXLY_TURTLE_WRITE_ALIGN_LEFT,"left"],[Jt.Msg.MIXLY_TURTLE_WRITE_ALIGN_CENTER,"center"],[Jt.Msg.MIXLY_TURTLE_WRITE_ALIGN_RIGHT,"right"]],n=[[Jt.Msg.MIXLY_TURTLE_WRITE_FONT_TYPE_NORMAL,"normal"],[Jt.Msg.MIXLY_TURTLE_WRITE_FONT_TYPE_BOLD,"bold"],[Jt.Msg.MIXLY_TURTLE_WRITE_FONT_TYPE_ITALIC,"italic"]];this.appendValueInput("TUR").setCheck("Turtle"),this.setColour(Jm),this.appendValueInput("VAR").setCheck(String).appendField(Jt.Msg.blockpy_turtle_write),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_TURTLE_WRITE_MOVE).appendField(new Jt.FieldDropdown(t),"MOVE"),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_TURTLE_WRITE_ALIGN).appendField(new Jt.FieldDropdown(e),"ALIGN"),this.appendValueInput("FONTNAME").setCheck(String).appendField(Jt.Msg.MIXLY_TURTLE_WRITE_FONT_NAME),this.appendValueInput("FONTNUM").setCheck(Number).appendField(Jt.Msg.MIXLY_TURTLE_WRITE_FONT_NUM),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_TURTLE_WRITE_FONT_TYPE).appendField(new Jt.FieldDropdown(n),"FONTTYPE"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.TURTLE_WRITE_TOOLTIP)}},Pg={init:function(){this.setColour(Jm),this.appendDummyInput("").setAlign(Jt.inputs.Align.RIGHT).appendField(new Jt.FieldColour("ff0000"),"COLOR"),this.setInputsInline(!0),this.setOutput(!0,String)}},$g={init:function(){this.setColour(Jm),this.appendValueInput("TUR").setCheck("Turtle"),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_TURTEL_GETSCREEN).appendField(new Jt.FieldTextInput("screen"),"VAR"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_TURTEL_GETSCREEN_TOOLTIP)},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},Bg={init:function(){this.setColour(Jm),this.appendValueInput("TUR"),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_TURTEL_EVENT_ONKEY),this.appendValueInput("callback").appendField(Jt.Msg.MIXLY_PYTHON_CONTROLS_THREAD_USE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_TURTEL_EVENT_ONKEY_TOOLTIP)}},Vg={init:function(){this.setColour(Jm),this.appendValueInput("TUR"),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_TURTEL_EVENT_ONCLICK),this.appendValueInput("callback").appendField(Jt.Msg.MIXLY_PYTHON_CONTROLS_THREAD_USE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_TURTEL_EVENT_ONCLICK_TOOLTIP)}},Ug={init:function(){this.setColour(Jm),this.appendValueInput("TUR"),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_TURTEL_EVENT_ONTIMER),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_mSecond),this.appendValueInput("callback").appendField(Jt.Msg.MIXLY_PYTHON_CONTROLS_THREAD_USE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_TURTEL_EVENT_ONTIMER_TOOLTIP)}},Yg={init:function(){this.setColour(Jm),this.appendValueInput("TUR"),this.appendDummyInput().appendField(Jt.Msg.MIXLY_TURTEL_SCREEN_LISTEN),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Gg={init:function(){this.setColour(Jm),this.appendValueInput("TUR"),this.appendValueInput("FILE").setCheck(String).appendField(Jt.Msg.mixpy_PL_SAVEFIG),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setOutput(!1),this.setTooltip(Jt.Msg.mixpy_TURTLE_SAVEFIG_TOOLTIP)}},Hg=function(t,e){var n=this.getFieldValue("TYPE");return e.definitions_.import_FileDialog="import FileDialog",["FileDialog."+n+"()",e.ORDER_ATOMIC]},Wg=function(t,e){var n=this.getFieldValue("CTYPE");return e.definitions_.import_aip="import aip",e.valueToCode(this,"SUB",e.ORDER_ATOMIC)+" = aip."+n+"("+e.valueToCode(this,"API_KEY",e.ORDER_ATOMIC)+", "+e.valueToCode(this,"SECRET_KEY",e.ORDER_ATOMIC)+")\n"},zg=function(t,e){return e.definitions_.import_aip="import aip",[e.valueToCode(this,"SUB",e.ORDER_ATOMIC)+".synthesis("+e.valueToCode(this,"STR",e.ORDER_ATOMIC)+", options="+(e.valueToCode(this,"ATTR",e.ORDER_ATOMIC)||"{}")+")",e.ORDER_ATOMIC]},Xg=function(t,e){return e.definitions_.import_aip="import aip",[e.valueToCode(this,"SUB",e.ORDER_ATOMIC)+".asr("+(e.valueToCode(this,"FILE",e.ORDER_ATOMIC)||'""')+", options="+(e.valueToCode(this,"ATTR",e.ORDER_ATOMIC)||"{}")+")",e.ORDER_ATOMIC]},jg=function(t,e){e.definitions_.import_aip="import aip";var n=e.valueToCode(this,"SUB",e.ORDER_ATOMIC),i=e.valueToCode(this,"ADDR",e.ORDER_ATOMIC);return[n+"."+e.valueToCode(this,"FUNC",e.ORDER_ATOMIC)+"("+i+", options="+(e.valueToCode(this,"ATTR",e.ORDER_ATOMIC)||"{}")+")",e.ORDER_ATOMIC]},qg=function(t,e){return e.definitions_.import_aip="import aip",[e.valueToCode(this,"SUB",e.ORDER_ATOMIC)+".match("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+","+e.valueToCode(this,"VAR2",e.ORDER_ATOMIC)+", options="+(e.valueToCode(this,"ATTR",e.ORDER_ATOMIC)||"{}")+")",e.ORDER_ATOMIC]},Kg=function(t,e){e.definitions_.import_aip="import aip";var n=e.valueToCode(this,"SUB",e.ORDER_ATOMIC),i=e.valueToCode(this,"ADDR",e.ORDER_ATOMIC);return[n+"."+e.valueToCode(this,"FUNC",e.ORDER_ATOMIC)+"("+i+", options="+(e.valueToCode(this,"ATTR",e.ORDER_ATOMIC)||"{}")+")",e.ORDER_ATOMIC]},Qg=function(t,e){e.definitions_.import_aip="import aip";var n=e.valueToCode(this,"SUB",e.ORDER_ATOMIC),i=e.valueToCode(this,"STR",e.ORDER_ATOMIC);return[n+"."+e.valueToCode(this,"FUNC",e.ORDER_ATOMIC)+"("+i+", options="+(e.valueToCode(this,"ATTR",e.ORDER_ATOMIC)||"{}")+")",e.ORDER_ATOMIC]},Jg=function(t,e){e.definitions_.import_aip="import aip";var n=e.valueToCode(this,"SUB",e.ORDER_ATOMIC),i=e.valueToCode(this,"STR1",e.ORDER_ATOMIC),s=e.valueToCode(this,"STR2",e.ORDER_ATOMIC);return[n+"."+e.valueToCode(this,"FUNC",e.ORDER_ATOMIC)+"("+i+","+s+", options="+(e.valueToCode(this,"ATTR",e.ORDER_ATOMIC)||"{}")+")",e.ORDER_ATOMIC]},Zg=function(t,e){return e.definitions_.import_aip="import aip",[e.valueToCode(this,"SUB",e.ORDER_ATOMIC)+".topic("+e.valueToCode(this,"STR1",e.ORDER_ATOMIC)+","+e.valueToCode(this,"STR2",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},t_=function(t,e){return e.definitions_.import_aip="import aip",[e.valueToCode(this,"SUB",e.ORDER_ATOMIC)+".newsSummary("+e.valueToCode(this,"STR",e.ORDER_ATOMIC)+","+e.valueToCode(this,"LEN",e.ORDER_ATOMIC)+", options="+(e.valueToCode(this,"ATTR",e.ORDER_ATOMIC)||"{}")+")",e.ORDER_ATOMIC]},e_=function(t,e){return[this.getFieldValue("TYPE"),e.ORDER_ATOMIC]},n_=function(t,e){return[this.getFieldValue("TYPE"),e.ORDER_ATOMIC]},i_=function(t,e){return[this.getFieldValue("TYPE"),e.ORDER_ATOMIC]},s_=function(t,e){return[this.getFieldValue("TYPE"),e.ORDER_ATOMIC]},r_=function(t,e){return e.definitions_.import_audio="import audio","audio.audio_record("+(e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||'""')+","+(e.valueToCode(this,"TIME",e.ORDER_ATOMIC)||"0")+")\n"},a_=function(t,e){return e.definitions_.import_audio="import cam","cam.photo_capture("+(e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||'""')+","+(e.valueToCode(this,"BUT",e.ORDER_ATOMIC)||'""')+")\n"},o_=function(t,e){var n=e.valueToCode(this,"AI",e.ORDER_ASSIGNMENT)||"0",i=this.getFieldValue("CTYPE");if("Image"==i)var s=n+'["result"][0]["keyword"]';if("Speech"==i)s=n+'["result"][0]';if("Face"==i||"OcrSimilarity"==i)s=n+'["score"]';if("Ocr"==i)s=n+'["words_result"]';return[s,e.ORDER_ATOMIC]},l_=function(t,e){e.definitions_.import_sprite="import sprite";return"g = [[0,0,0,0,0,0,0,0,0,0], [0,0,0,1,0,0,0,0,0,0], [0,0,0,1,0,0,1,0,0,0], [0,1,1,0,1,1,0,0,0,0], [0,0,0,1,0,0,0,1,0,0], [0,0,0,1,0,0,1,1,0,0], [0,0,1,0,0,1,0,1,0,0], [0,0,0,0,1,1,1,0,0,0]]\nmark = [[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,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,0,0,0,0,0,0,0,0]]\nvis = [0,1,0,0,0,0,0,0,0]\nposition = [[0, 0], [200, 200], [250, 60], [320, 200], [280, 380], [470, 250], [670, 90], [650, 340]]\nsprite.clearAllSprites()\nsprite.createBackground('ditu')\nmask = sprite.Sprite('white', 96, 354)\nmask.hide()\nhouse = [\n sprite.Sprite('mark', 150, 380),\n sprite.Sprite('xtxn', 96, 170),\n sprite.Sprite('xnvijx', 270, 45),\n sprite.Sprite('xnxbjx', 310, 182),\n sprite.Sprite('xnsijx', 300, 370),\n sprite.Sprite('xnkejx', 495, 220),\n sprite.Sprite('bwbwjx', 716, 85),\n sprite.Sprite('lelejx', 686, 314)\n]\nfor i in house:\n i.filterBrighter()\n i.hide()\n"},u_=function(){return"path = [1]\nmask.show()\ncar = sprite.Sprite('xnie', position[1][0], position[1][1])\nhouse[1].show()\ncar.nowPos = 1\ndef drive(n):\n if g[car.nowPos][n]==1:\n car.slideTo(position[n][0], position[n][1], 1)\n car.nowPos = n\n else:\n print('移动失败!程序有误!')\n exit()\n"},h_=function(t,e){e.definitions_.import_random="import random";return"f = path[(len(path) - 1)]\nflag = 0\nfor _my_variable in [6,5,4,3,2,1,0]:\n if vis[_my_variable+1] == 0 and g[f][_my_variable+1] == 1:\n if mark[f][_my_variable+1] == 0:\n flag = 1\n break\n"},p_=function(t,e){return["flag == 1",e.ORDER_ATOMIC]},c_=function(){return"mark[f][_my_variable+1] = 1\nvis[_my_variable+1] = 1\n"},d_=function(){return"path.append(_my_variable+1)\ndrive(path[len(path) - 1])\nhouse[_my_variable+1].show()\n"},f_=function(t,e){e.definitions_.import_time="import time";return"del path[len(path) - 1]\nhouse[0].show()\ntime.sleep(0.5)\nhouse[0].hide()\n"},m_=function(){var t="for i in range(7):\n mark[f][i+1] = 0\n vis[f] = 0\n";return t="house[f].hide()\ndrive(path[len(path) - 1])\n"+t},g_=function(t,e){return["len(path) == 7",e.ORDER_ATOMIC]},__=function(){return'name = ["","学校","小智家","小欣家","小思家","小科家","贝贝家","乐乐家"]\nres = ""\nfor i in path:\n res = res + name[i] + "-"\nprint(res[:-1])\n'},T_=function(t,e){e.definitions_.import_sprite="import sprite";return"g = [[0,0,0,0,0,0,0,0,0,0], [0,0,0,1,0,0,0,0,0,0], [0,0,0,1,0,0,1,0,0,0], [0,1,1,0,1,0,0,0,0,0], [0,0,0,1,0,0,0,1,0,0], [0,0,0,1,0,0,0,1,0,0], [0,0,1,0,0,0,0,1,0,0], [0,0,0,0,1,1,1,0,0,0]]\nmark = [[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,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,0,0,0,0,0,0,0,0]]\nvis = [0,1,0,0,0,0,0,0,0]\nposition = [[0, 0], [200, 200], [250, 60], [320, 200], [280, 380], [470, 250], [670, 90], [650, 340]]\nsprite.clearAllSprites()\nsprite.createBackground('ditu')\nmask = sprite.Sprite('white', 96, 354)\nmask.hide()\nhouse = [\n sprite.Sprite('mark', 150, 380),\n sprite.Sprite('xtxn', 96, 170),\n sprite.Sprite('xnvijx', 270, 45),\n sprite.Sprite('xnxbjx', 310, 182),\n sprite.Sprite('xnsijx', 300, 370),\n sprite.Sprite('xnkejx', 495, 220),\n sprite.Sprite('bwbwjx', 716, 85),\n sprite.Sprite('lelejx', 686, 314)\n]\nbarricade = sprite.Sprite('barricade', 610, 170)\nbarricade.enlargeTo(100)\nfor i in house:\n i.filterBrighter()\n i.hide()\n"},y_=function(t,e){return["f == 1",e.ORDER_ATOMIC]},I_=function(){return"print('没有符合条件的路线')\n"},E_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return'g = [[10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,10000],[10000,10000,500,300,10000,10000,10000,10000,10000,10000,10000],[10000,500,10000,10000,100,10000,10000,10000,10000,10000,10000],[10000,300,10000,10000,400,300,10000,10000,10000,10000,10000],[10000,10000,100,400,10000,10000,200,10000,10000,10000,10000],[10000,10000,10000,300,10000,10000,100,200,10000,10000,10000],[10000,10000,10000,10000,200,100,10000,10000,100,10000,10000],[10000,10000,10000,10000,10000,200,10000,10000,100,10000,10000],[10000,10000,10000,10000,10000,10000,100,100,10000,10000,10000]]\nnow=1\nlast=1\npath=[]\npath.append(1)\nname = ["","小思家","银行","邮局","餐厅","书店","医院","超市","小科家"]\nposition = [[0, 0], [60, 320], [510, 390], [240, 200], [750, 330], [410, 90], [540, 190], [550, 30], [720, 120]]\nsprite.clearAllSprites()\nsprite.createBackground(\'map_si_ke\')\nstu = sprite.Sprite(\'girl\', 60, 320)\nstu.enlargeTo(100)\ntime.sleep(1)\n\n'},b_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return'g =[[10000,10000,10000,10000,10000,10000,10000],[10000,10000,300,500,10000,10000,10000],[10000,300,10000,10000,300,700,10000],[10000,500,10000,10000,10000,100,10000],[10000,10000,300,10000,10000,10000,200],[10000,10000,700,100,10000,10000,100],[10000,10000,10000,10000,200,100,10000]]\nnow=1\nlast=1\npath=[]\npath.append(1)\nname = ["","小智家","邮局","银行","书店","餐厅","学校"]\nposition = [[0, 0], [70, 340], [70, 90], [550, 310], [420, 70], [730, 250], [650, 130]]\nsprite.clearAllSprites()\nsprite.createBackground(\'map_zhi_xue\')\nstu = sprite.Sprite(\'boy\', 70, 340)\nstu.enlargeTo(100)\ntime.sleep(1)\n\n'},v_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return'tmp=10000\nfor i in range(0, len(g), 1):\n if g[now][i]6:\n print("路线错乱!程序有误!")\n exit()\n'},w_=function(t,e){return["name[now] != '小科家'",e.ORDER_ATOMIC]},S_=function(t,e){return["name[now] != '学校'",e.ORDER_ATOMIC]},x_=function(){return'res = ""\nfor i in path:\n res = res + name[i] + "→"\nprint(res[:-1])\n'},R_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";var n=this.getFieldValue("NUM");if(n>=7)var i="print('层数过高!不得高于6层!')\nexit()\n";else i="sprite.clearAllSprites()\n_Hanoicolor = ['blue', 'red', 'yellow', 'green', 'purple', 'black']\n_Hanoi = [[], [], []]\nA = 0\nB = 1\nC = 2\n_n = "+n+"\n_HanoiColumn = [\n sprite.Sprite('HanoiColumn', 200, 320),\n sprite.Sprite('HanoiColumn', 400, 320),\n sprite.Sprite('HanoiColumn', 600, 320)\n]\n_HanoiColumnNumber = [\n sprite.Text('A', 190, 120),\n sprite.Text('B', 390, 120),\n sprite.Text('C', 590, 120)\n]\n_HanoiBlock = []\nfor i in range(0, _n, 1):\n _HanoiBlock.append(sprite.Sprite(_Hanoicolor[i], 200, 400-(_n-i-1)*27))\n _HanoiBlock[i].setScale(25, 30*i+30)\n _Hanoi[0].insert(0, _HanoiBlock[i])\n_steptext = sprite.Text('步数:0', 30, 30)\n_steps = {'steps' : 0}\ntime.sleep(1)\n";return i},A_=function(t,e){var n=e.valueToCode(this,"FROM_NUM",e.ORDER_ATOMIC)||"0",i=e.valueToCode(this,"TO_NUM",e.ORDER_ATOMIC)||"0";return`if len(_Hanoi[${n}])>0 :\n _HanoiBlockMoved = _Hanoi[${n}].pop()\n if len(_Hanoi[${i}]) > 0 :\n _HanoiBlockSuppressed = _Hanoi[${i}].pop()\n if _HanoiBlock.index(_HanoiBlockMoved) > _HanoiBlock.index(_HanoiBlockSuppressed):\n print('非法移动!程序有误!')\n exit()\n else:\n _Hanoi[${i}].append(_HanoiBlockSuppressed)\n _HanoiBlockMoved.slideTo(${n}*200+200, 180, 0.2)\n _HanoiBlockMoved.slideTo(${i}*200+200, 180, 0.5)\n _HanoiBlockMoved.slideTo(${i}*200+200, 400-len(_Hanoi[${i}])*27, 0.2)\n _Hanoi[${i}].append(_HanoiBlockMoved)\n _steps['steps'] += 1\n _steptext.changeText('步数:'+str(_steps['steps']))\nelse :\n print('非法移动!程序有误!')\n exit()\n`},O_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return"if 'mode' not in globals() or mode == 0:\n sprite.clearAllSprites()\n ring=[0,0,0,0,0,0,0,0,0,0]\n mode=1\n n=5\n ring[5]=1\n name=['小王子','海底两万里','荷花镇的早市','孔子的故事','夏洛的网','草房子','月下看猫头鹰','会唱歌的咖啡磨','父与子','城南旧事']\n Books = []\n for i in range(1, 11, 1):\n Books.append(sprite.Sprite('books/book'+str(i), (130*i-650) if i>5 else 130*i, 320 if i>5 else 120))\nelse:\n mode=2\n n=len(ring)-1\nring[n]=1\ntime.sleep(1)\n"},M_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return"if 'mode' not in globals() or mode == 0:\n sprite.clearAllSprites()\n ring=[0,0,0,0,0,0,0,0,0,0]\n mode=2\n n=5\n name=['小王子','海底两万里','荷花镇的早市','孔子的故事','夏洛的网','草房子','月下看猫头鹰','会唱歌的咖啡磨','父与子','城南旧事']\n Books = []\n for i in range(1, 11, 1):\n Books.append(sprite.Sprite('books/book'+str(i), (130*i-650) if i>5 else 130*i, 320 if i>5 else 120))\nelse:\n mode=1\n n=len(ring)-1\nring[n]=n\nlist=ring\ntemp=Books\ntime.sleep(1)\n"},C_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return"res=0\nflag=ring[res]\nBooks[res].filterBrighter()\ntime.sleep(0.1)\nBooks[res].filterOrigin()\n"},N_=function(t,e){return["(('mode' not in globals())or(mode==1 and flag==0)or(mode==2 and not any(value > 0 for value in qian))or(mode==0))",e.ORDER_ATOMIC]},k_=function(t,e){return["(('mode' in globals())and((mode==1 and flag!=0)or(mode==2 and any(value > 0 for value in qian))))",e.ORDER_ATOMIC]},D_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";var n="res+=1\nflag=ring[res]\n";return n="Books[res].filterGray()\ntime.sleep(0.3)\n"+(n+="Books[res].filterBrighter()\ntime.sleep(0.1)\nBooks[res].filterOrigin()\n")},L_=function(t,e){return["len(list)>=2",e.ORDER_ATOMIC]},F_=function(){return"mid = int(len(list)/2)\nqian = list[0:mid]\nhou = list[mid:]\nqiantemp = temp[0:mid]\nhoutemp = temp[mid:]\n"},P_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return"quchu = qian\nlist = hou\nquchutemp = qiantemp\ntemp = houtemp\nfor i in qiantemp:\n i.filterBrighter()\ntime.sleep(0.5)\nfor i in qiantemp:\n i.filterGray()\ntime.sleep(0.5)\n"},$_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return"list = quchu\ntemp = quchutemp\nfor i in qiantemp:\n i.filterBrighter()\ntime.sleep(0.5)\nfor i in qiantemp:\n i.filterOrigin()\nfor i in houtemp:\n\ti.filterBrighter()\ntime.sleep(0.5)\nfor i in houtemp:\n i.filterGray()\ntime.sleep(0.5)\n"},B_=function(){return"if 'list' in globals():\n res = list[0]\nBooks[res].filterBrighter()\nprint('未消磁的书籍是第'+str(res+1)+'本《'+name[res%10]+'》。')\nif res!=n:\n print('答案错误!请检查程序!')\nmode=0\n"},V_=function(t,e){var n=this.getFieldValue("NUM");return e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite",`sprite.clearAllSprites()\nring = []\nname = ['小王子','海底两万里','荷花镇的早市','孔子的故事','夏洛的网','草房子','月下看猫头鹰','会唱歌的咖啡磨','父与子','城南旧事']\nBooks = []\nfor i in range(${n}):\n ring.append(0)\nfor i in range(1, ${n}+1, 1):\n Books.append(sprite.Sprite('books/book'+str(i%10 if i%10!=0 else 10), ${{5:"130*i, 120",10:"(130*i-650) if i>5 else 130*i, 320 if i>5 else 120",20:"(65*i-650)+30 if i>10 else 65*i+30, 320 if i>10 else 120",50:"(26*i-650)+50 if i>25 else 26*i+50, 320 if i>25 else 120"}[n]}))\ntime.sleep(1)\nmode=3\n`},U_=function(t,e){e.definitions_.import_sprite="import sprite";return"cnt=0\ncntText = sprite.Text('计数器:0', 30, 200)\n"},Y_=function(t,e){e.definitions_.import_sprite="import sprite";return"cnt+=1\ncntText.changeText('计数器:'+str(cnt))\n"},G_=function(t,e){e.definitions_.import_sprite="import sprite";return"print('计数器大小:'+str(cnt))\n"},H_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return"sprite.clearAllSprites()\n_head = 10\n_foot = 32\n_footText = sprite.Text('脚的数量:', 20, 10)\n_sprite = []\n"},W_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return"_rabbit = 0\ntime.sleep(1)\n"},z_=function(t,e){return["_rabbit < _head",e.ORDER_ATOMIC]},X_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return"_chick = _head - _rabbit\nfor i in range(0, _chick, 1):\n _sprite.append(sprite.Sprite('jttl/chick', len(_sprite)*130+130 if len(_sprite)<5 else len(_sprite)*130+130-650, 120 if len(_sprite)<5 else 320))\n\ntime.sleep(0.5)\n_footText.changeText('脚的数量:'+str(_rabbit*4 + _chick*2))\ntime.sleep(1)\n"},j_=function(t,e){return["_rabbit*4 + _chick*2 == _foot",e.ORDER_ATOMIC]},q_=function(t,e){e.definitions_.import_sprite="import sprite";return"print('鸡的数量:'+str(_chick)+'只;\\n兔的数量:'+str(_rabbit)+'只。')\n"},K_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return"_rabbit += 1\nsprite.clearAllSprites()\n_sprite = []\n_footText = sprite.Text('脚的数量:', 20, 10)\nfor i in range(0, _rabbit, 1):\n _sprite.append(sprite.Sprite('jttl/rabbit', len(_sprite)*130+130 if len(_sprite)<5 else len(_sprite)*130+130-650, 120 if len(_sprite)<5 else 320))\ntime.sleep(0.5)\n"},Q_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return"sprite.clearAllSprites()\nsprite.createBackground('/fzsf/map_ck_xxjsjs')\n_S1 = sprite.Sprite('/fzsf/S1',400,225,'S1')\n_S2 = sprite.Sprite('/fzsf/S2',400,225,'S2')\n_S3 = sprite.Sprite('/fzsf/S3',400,225,'S3')\n_S4 = sprite.Sprite('/fzsf/S4',400,225,'S4')\n_S1.hide()\n_S2.hide()\n_S3.hide()\n_S4.hide()\n_text_1 = sprite.Text('S1:',0,0,'text')\n_text_2 = sprite.Text('S2:',0,30,'text2')\n_text_3 = sprite.Text('S3:',0,60,'text3')\n_text_4 = sprite.Text('S4:',0,90,'text4')\n_position = [[60, 270], [240, 50], [260, 380], [440, 190], [730, 60], [700, 400]]\n_Llen = [0, 170, 230, 100, 150, 10, 30, 50]\n_Slen = [0, 0, 0, 0, 0]\n_tag = [0, [0, 1, 3], [0, 2, 3], [3, 4, 5], [3, 5]]\nbear = sprite.Sprite('mixbear',60,270,'bear')\nbear.enlargeTo(80)\n_pos = 0\ntime.sleep(1)\n"},J_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";var n=this.getFieldValue("PATHNAME");const i=[0,[1,3],[2,4],[5,7],[6]];var s="";return s+=`_S${n}.show()\ntime.sleep(1)\n`,s+=4!=n?`_Slen[${n}] = _Llen[${i[n][0]}] + _Llen[${i[n][1]}]\n_text_${n}.changeText('S${n}:'+str(_Slen[${n}])+'m')\ntime.sleep(1)\n_S${n}.hide()\ntime.sleep(1)\n`:"_Slen[4] = _Llen[6]\n_text_4.changeText('S4:'+str(_Slen[4])+'m')\ntime.sleep(1)\n_S4.hide()\ntime.sleep(1)\n"},Z_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";var n="";return[n+=`_Slen[${this.getFieldValue("PATHNAME")}] < _Slen[${this.getFieldValue("PATHNAME2")}]`,e.ORDER_ATOMIC]},tT=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";var n=this.getFieldValue("PATHNAME"),i="";return i+=`\n_S1.hide()\n_S2.hide()\n_S3.hide()\n_S4.hide()\n_Smin = ${n}\n_S${n}.show()\ntime.sleep(0.5)\n_S${n}.hide()\ntime.sleep(0.5)\n_S${n}.show()\ntime.sleep(1)\n`},eT=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return"if(_pos == _tag[_Smin][0]):\n for i in range(1, len(_tag[_Smin]), 1):\n bear.slideTo(_position[_tag[_Smin][i]][0], _position[_tag[_Smin][i]][1], 1)\n _pos = _tag[_Smin][len(_tag[_Smin])-1]\nelse:\n print('移动错误!程序有误!')\n exit()\n_S1.hide()\n_S2.hide()\n_S3.hide()\n_S4.hide()\nif(_pos == 5):\n print('成功抵达信息科技教室!')\n"},nT=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return"sprite.clearAllSprites()\nsprite.createBackground('/hxdb/hxdbbg')\n_soldier = []\n_num = sprite.Text('目前士兵数量:0',0,0,'num')\n_last = sprite.Text('剩余:0',500,0,'last')\n_line = 3\n"},iT=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";var n="";return n+=`for i in range(0, ${this.getFieldValue("NUM")}, 1):\n _soldier.append(sprite.Sprite('/hxdb/soldier', 30 + (len(_soldier)%_line)*50 + (len(_soldier)//(4*_line))*(_line+1)*50 +(len(_soldier)%3-2), 80+(len(_soldier)//_line)*100-(len(_soldier)//(4*_line))*4*100+(len(_soldier)%2)))\n_num.changeText('目前士兵数量:'+str(len(_soldier)))\n`},sT=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";var n=this.getFieldValue("NUM");return`for i in range(0, len(_soldier), 1):\n _soldier[i].slideTo(30 + (i%${n})*50 + (i//(4*${n}))*(${n}+1)*50 +(i%3-2), 80+(i//${n})*100-(i//(4*${n}))*4*100+(i%2), 0.05)\n_line = ${n}\n_last.changeText('剩余:'+str(len(_soldier)%_line))\ntime.sleep(2)\n`},rT=function(t,e){return e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite",[`len(_soldier)%_line == ${this.getFieldValue("NUM")}`,e.ORDER_ATOMIC]},aT=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return"_num.changeText('目前士兵数量:'+str(len(_soldier)+1))\n_last.changeText('剩余:')\ntime.sleep(0.5)\n_soldier.append(sprite.Sprite('/hxdb/soldier', 30 + (len(_soldier)%_line)*50 + (len(_soldier)//(4*_line))*(_line+1)*50 +(len(_soldier)%3-2), 80+(len(_soldier)//_line)*100-(len(_soldier)//(4*_line))*4*100+(len(_soldier)%2)))\ntime.sleep(1)\n"},oT=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return"print('符合要求的士兵数量为:'+str(len(_soldier)))\n"},lT=function(t,e){e.definitions_.import_turtle="import turtle",e.definitions_.import_time="import time",e.definitions_.import_math="import math";var n=e.valueToCode(this,"VAR",e.ORDER_ATOMIC),i=this.getFieldValue("NUM");return e.setups_.init_Hanoi="\ndef init_Hanoi():\n pen = turtle.Turtle()\n pen.hideturtle()\n pen.speed(0)\n for i in range(0, 3, 1):\n pen.penup()\n pen.setheading(0)\n pen.goto(150 * i - 200,-100)\n pen.pendown()\n pen.pensize(5)\n pen.forward(100)\n pen.goto(150 * i - 150,-100)\n pen.setheading(90)\n pen.forward(200)",e.setups_.begin="\ndef begin(): \n s = turtle.Turtle()\n s.hideturtle()\n s.penup()\n s.speed(0)\n s.goto(0,-150)\n s.write('3')\n time.sleep(1)\n s.clear()\n s.write('2')\n time.sleep(1)\n s.clear()\n s.write('1')\n time.sleep(1)\n s.clear()\n s.write('Start!')\n time.sleep(1)\n s.clear()\n",e.setups_.move="\ndef move(x, y):\n try:\n t = tower[x].pop(-1)\n a = tower_num[x].pop(-1)\n if tower_num[y]!=[]:\n b = tower_num[y][-1]\n if a 1"}]`,e.ORDER_ATOMIC]},Uy=function(t,e){return[`${e.valueToCode(t,"DICT",e.ORDER_ATOMIC)||"df"}.groupby(by=${e.valueToCode(t,"KEY",e.ORDER_ATOMIC)||"'tag'"})`,e.ORDER_ATOMIC]},Yy=function(t,e){return[`${e.valueToCode(t,"DICT",e.ORDER_ATOMIC)||"df"}.${t.getFieldValue("TYPE")}()`,e.ORDER_ATOMIC]},Gy=function(t,e){e.definitions_.import_matplotlib_pyplot="import matplotlib.pyplot as plt";return"plt.cla()\n"},Hy=function(t,e){var n=e.variableDB_.getName(this.getFieldValue("VAR"),Jt.Variables.NAME_TYPE),i=e.variableDB_.getName(this.getFieldValue("TYPE"),Jt.Variables.NAME_TYPE),s="class "+i+":\n";s+=" def __init__(self):\n";for(var r=new Array(this.itemCount_),a=0;a{},displayTag:!1,processingDisplayEvent:null,successDisplayEvents:[],successProcessingDisplayEvents:[],startTime:performance.now(),timer:0,lastFrameTime:null,lastSecond:null,targetFPS:60,frameCount:0,currentFPS:60,canvasHeight:450,canvasWidth:800,gameLoop:()=>{1==yb.state&&(yb.repeatPlay(),yb.gameLoopDisplay()),yb.timer=performance.now()-yb.startTime},animate:t=>{t-yb.lastFrameTime>=1e3/yb.targetFPS&&(yb.frameCount++,yb.gameLoop(),yb.renderer.render(yb.stage),yb.lastFrameTime=t),t-yb.lastSecond>=1e3&&(yb.currentFPS=yb.frameCount,yb.frameCount=0,yb.lastSecond=t),requestAnimationFrame(yb.animate)}};yb.createBackground=(t,e=0)=>{var n;return 0==e&&(n=new(Tb().Sprite.fromImage)(`../common/media/spriteimg/${t}.png`)),n.name="background",n.anchor.set(.5),n.x=yb.canvasWidth/2,n.y=yb.canvasHeight/2,n.width=yb.canvasWidth,n.height=yb.canvasHeight,n.interactive=!0,n.buttonMode=!0,n.isDown=!1,n.isUp=!0,n.on("mousedown",(function(){this.isDown=!0,this.isUp=!1,yb.state&&this.runningMouseDown()})).on("mouseup",(function(){this.isDown=!1,this.isUp=!0})).on("mouseupoutside",(function(){this.isDown=!1,this.isUp=!0})),n.runningMouseDown=new Function(""),yb.backgroundSprite&&yb.backgroundSprite.parent&&yb.stage.removeChild(yb.backgroundSprite),yb.backgroundSprite=n,yb.stage.addChildAt(yb.backgroundSprite,0),0},yb.createASprite=(t,e=yb.canvasWidth/2,n=yb.canvasHeight/2,i="",s=0)=>{var r;return""==i&&(i="sprite"+ ++yb.counter),0==s&&(r=new(Tb().Sprite.fromImage)(`../common/media/spriteimg/${t}.png`)),yb.sprites[i]||yb.texts[i]||(r.name=i,r.anchor.set(.5),r.x=e,r.y=n,r.interactive=!0,r.buttonMode=!0,r.isDown=!1,r.isUp=!0,r.on("mousedown",(function(t){this.isDown=!0,this.isUp=!1,yb.state?this.runningMouseDown():(this.data=t.data,this.alpha=.5,this.dragging=!0)})).on("mouseup",(function(){this.isDown=!1,this.isUp=!0,yb.state||(this.alpha=1,this.dragging=!1,this.data=null)})).on("mouseupoutside",(function(){this.isDown=!1,this.isUp=!0,yb.state||(this.alpha=1,this.dragging=!1,this.data=null)})).on("mousemove",(function(){if(!yb.state&&this.dragging){var t=this.data.getLocalPosition(this.parent);this.position.x=t.x,this.position.y=t.y}})),r.runningMouseDown=new Function(""),r.show=function(){this.visible=!0},r.hide=function(){this.visible=!1},r.enlarge=function(t){const e=this.height/this.width;var n=Math.sqrt(this.height*this.width);n+=t,this.width=Math.sqrt(n*n/e),this.height=this.width*e},r.enlargeTo=function(t){var e=this.height/this.width;this.width=Math.sqrt(t*t/e),this.height=this.width*e},r.expandTo=async function(t,e=1){if(yb.running){yb.displayTag=!0,yb.processingDisplayEvent={sprite:this,targetS:t,totalTime:1e3*e,startTime:performance.now(),displayType:"expand"};var n=new Promise((t=>{if(!1===yb.displayTag)t();else{const e=setInterval((()=>{!1===yb.displayTag&&(clearInterval(e),t())}),10)}}));return await n}return yb.successProcessingDisplayEvents.push({sprite:this,targetS:t,totalTime:1e3*e,startTime:performance.now(),displayType:"expand"}),0},r.move=function(t){this.x+=t*Math.cos(this.rotation),this.y+=t*Math.sin(this.rotation)},r.moveTo=function(t,e){this.x=t,this.y=e},r.slideTo=async function(t,e,n=1){if(yb.running){yb.displayTag=!0,yb.processingDisplayEvent={sprite:this,targetX:t,targetY:e,totalTime:1e3*n,startTime:performance.now(),displayType:"slide"};var i=new Promise((t=>{const e=setInterval((()=>{!1===yb.displayTag&&(clearInterval(e),t())}),10)}));return await i}return yb.successProcessingDisplayEvents.push({sprite:this,targetX:t,targetY:e,totalTime:1e3*n,startTime:performance.now(),displayType:"slide"}),0},r.addX=function(t){this.x+=t},r.addY=function(t){this.y+=t},r.rotate=function(t){this.rotation+=Math.PI/180*t},r.rotateTo=function(t){this.rotation=Math.PI/180*t},r.circleTo=async function(t,e=1){if(yb.running){yb.displayTag=!0,yb.processingDisplayEvent={sprite:this,targetDegree:t,totalTime:1e3*e,startTime:performance.now(),displayType:"circle"};var n=new Promise((t=>{if(!1===yb.displayTag)t();else{const e=setInterval((()=>{!1===yb.displayTag&&(clearInterval(e),t())}),10)}}));return await n}return yb.successProcessingDisplayEvents.push({sprite:this,targetDegree:t,totalTime:1e3*e,startTime:performance.now(),displayType:"circle"}),0},r.hit=function(t){return yb.hitTestRectangle(this,t)},r.outOfScreen=function(){return this.y>=yb.renderer.height||this.y<=0||this.x<=0||this.x>=yb.renderer.width},r.mouseAction=function(t){this.runningMouseDown=t},r.setScale=function(t=0,e=0){0==t&&(t=this.height),0==e&&(e=this.width),this.height=t,this.width=e},r.filterGray=function(){const t=new(Tb().filters.ColorMatrixFilter);t.blackAndWhite(),this.filters=[t]},r.filterBrighter=function(){const t=new(Tb().filters.ColorMatrixFilter);t.brightness(1.25),this.filters=[t]},r.filterOrigin=function(){this.filters=null},yb.stage.addChild(r),yb.sprites[i]=r),i},yb.clearAllSprites=()=>{yb.backgroundSprite&&yb.backgroundSprite.parent&&yb.backgroundSprite.parent.removeChild(yb.backgroundSprite);for(const t in yb.sprites)yb.sprites[t].parent.removeChild(yb.sprites[t]),delete yb.sprites[t];for(const t in yb.texts)yb.texts[t].parent.removeChild(yb.texts[t]),delete yb.texts[t];return yb.counter=0,yb.clearTimer(),0},yb.createText=(t,e=yb.canvasWidth/2,n=yb.canvasHeight/2,i="")=>{if(""==i&&(i="text"+ ++yb.counter),!yb.sprites[i]&&!yb.texts[i]){var s=new(Tb().Text)(t);s.name=i,s.x=e,s.y=n,s.interactive=!0,s.buttonMode=!0,s.on("mousedown",(function(t){this.isDown=!0,this.isUp=!1,yb.state?this.runningMouseDown():(this.data=t.data,this.alpha=.5,this.dragging=!0)})).on("mouseup",(function(){this.isDown=!1,this.isUp=!0,yb.state||(this.alpha=1,this.dragging=!1,this.data=null)})).on("mouseupoutside",(function(){this.isDown=!1,this.isUp=!0,yb.state||(this.alpha=1,this.dragging=!1,this.data=null)})).on("mousemove",(function(){if(!yb.state&&this.dragging){var t=this.data.getLocalPosition(this.parent);this.position.x=t.x,this.position.y=t.y}})),s.runningMouseDown=new Function(""),s.changeText=function(t){this.text=t},s.show=function(){this.visible=!0},s.hide=function(){this.visible=!1},yb.stage.addChild(s),yb.texts[i]=s}return i},yb.hitTestRectangle=(t,e)=>{let n,i,s,r,a;return n=!1,t.centerX=t.x+t.width/2,t.centerY=t.y+t.height/2,e.centerX=e.x+e.width/2,e.centerY=e.y+e.height/2,t.halfWidth=t.width/2,t.halfHeight=t.height/2,e.halfWidth=e.width/2,e.halfHeight=e.height/2,r=t.centerX-e.centerX,a=t.centerY-e.centerY,i=t.halfWidth+e.halfWidth,s=t.halfHeight+e.halfHeight,n=Math.abs(r){yb.repeatPlay=t},yb.isKeyboardHit=t=>{if(!yb.keys[t]){let e=yb.keyboard(t);yb.keys[t]=e}return yb.keys[t].isDown},yb.keyboardListener=(t,e)=>{if(yb.keys[t])yb.keys[t].press=function(){yb.state&&e()};else{let n=yb.keyboard(t);n.press=function(){yb.state&&e()},yb.keys[t]=n}},yb.keyboard=t=>{let e={};e.value=t,e.isDown=!1,e.isUp=!0,e.press=void 0,e.release=void 0,e.downHandler=t=>{t.key===e.value&&(e.isUp&&e.press&&e.press(),e.isDown=!0,e.isUp=!1,t.preventDefault())},e.upHandler=t=>{t.key===e.value&&(e.isDown&&e.release&&e.release(),e.isDown=!1,e.isUp=!0,t.preventDefault())};const n=e.downHandler.bind(e),i=e.upHandler.bind(e);return window.addEventListener("keydown",n,!1),window.addEventListener("keyup",i,!1),e.unsubscribe=()=>{window.removeEventListener("keydown",n),window.removeEventListener("keyup",i)},e},yb.clearTimer=()=>{yb.startTime=performance.now()},yb.gameLoopDisplay=()=>{if(yb.processingDisplayEvent){const t=yb.processingDisplayEvent;switch(t.displayType){case"slide":if(performance.now()>=t.totalTime+t.startTime)t.sprite.moveTo(t.targetX,t.targetY),yb.displayTag=!1,yb.processingDisplayEvent=null;else(e=yb.currentFPS*(t.totalTime+t.startTime-performance.now())/1e3)>=1&&(t.sprite.addX((t.targetX-t.sprite.x)/e),t.sprite.addY((t.targetY-t.sprite.y)/e));break;case"expand":if(performance.now()>=t.totalTime+t.startTime)t.sprite.enlargeTo(t.targetS),yb.displayTag=!1,yb.processingDisplayEvent=null;else(e=yb.currentFPS*(t.totalTime+t.startTime-performance.now())/1e3)>=1&&t.sprite.enlarge((t.targetS-Math.sqrt(t.sprite.height*t.sprite.width))/e);break;case"circle":if(performance.now()>=t.totalTime+t.startTime)t.sprite.rotateTo(t.targetDegree),yb.displayTag=!1,yb.processingDisplayEvent=null;else(e=yb.currentFPS*(t.totalTime+t.startTime-performance.now())/1e3)>=1&&t.sprite.rotate((t.targetDegree-180*t.sprite.rotation/Math.PI)/e)}}if(!yb.running&&yb.successProcessingDisplayEvents.length)for(var t=yb.successProcessingDisplayEvents.length-1;t>=0;t--){const n=yb.successProcessingDisplayEvents[t];switch(n.displayType){case"slide":if(performance.now()>=n.totalTime+n.startTime)n.sprite.moveTo(n.targetX,n.targetY),yb.successProcessingDisplayEvents.splice(t,1);else(e=yb.currentFPS*(n.totalTime+n.startTime-performance.now())/1e3)>=1&&(n.sprite.addX((n.targetX-n.sprite.x)/e),n.sprite.addY((n.targetY-n.sprite.y)/e));break;case"expand":if(performance.now()>=n.totalTime+n.startTime)n.sprite.enlargeTo(n.targetS),yb.successProcessingDisplayEvents.splice(t,1);else(e=yb.currentFPS*(n.totalTime+n.startTime-performance.now())/1e3)>=1&&n.sprite.enlarge((n.targetS-Math.sqrt(n.sprite.height*n.sprite.width))/e);break;case"circle":var e;if(performance.now()>=n.totalTime+n.startTime)n.sprite.rotateTo(n.targetDegree),yb.successProcessingDisplayEvents.splice(t,1);else(e=yb.currentFPS*(n.totalTime+n.startTime-performance.now())/1e3)>=1&&n.sprite.rotate((n.targetDegree-180*n.sprite.rotation/Math.PI)/e)}}},yb.changeWidth=t=>{const e=gb()(yb.renderer.view),n=e.width(),i=e.height();e.width(t),e.height(t/n*i)},yb.kill=()=>{yb.state=!1,yb.repeatPlay=new Function;for(let t in yb.keys)yb.keys[t].unsubscribe(),delete yb.keys[t];yb.processingDisplayEvent=null,yb.displayTag=!1,yb.running=!1,yb.clearTimer()},yb.runit=t=>{const e=gb()(t);e.empty(),Tb().SCALE_MODES.DEFAULT=Tb().SCALE_MODES.NEAREST,yb.renderer=Tb().autoDetectRenderer(yb.canvasWidth,yb.canvasHeight,{backgroundColor:16777215}),e.append(yb.renderer.view),yb.pointer={x:0,y:0},yb.stage.sortableChildren=!0,yb.stage.interactive=!0,yb.stage.on("mousemove",((t=Tb().InteractionEvent)=>{yb.pointer.x=t.data.global.x,yb.pointer.y=t.data.global.y})),yb.lastFrameTime=0,yb.running=!0,yb.lastFrameTime||(yb.lastFrameTime=performance.now(),yb.lastSecond=performance.now()),yb.animate(performance.now()),yb.repeatPlay=new Function;for(let t in yb.keys)yb.keys[t].unsubscribe(),delete yb.keys[t];yb.backgroundSprite&&(yb.backgroundSprite.runningMouseDown=new Function);for(let t in yb.sprites)yb.sprites[t].runningMouseDown=new Function;for(let t in yb.texts)yb.texts[t].runningMouseDown=new Function;yb.processingDisplayEvent=null,yb.displayTag=!1,yb.clearTimer(),yb.changeWidth(gb()("body").width()/2),yb.state=!0},window.mixlySprite=yb;const Ib=yb;var Eb=__webpack_require__(9610);class bb{constructor(t,e){this._pageLoad=new Eb.D,this._kernelAvailable=new Eb.D,this._loaderId="basthon-loader",this._doNotHideLoader=!0;const n=t.language;if(null!=e&&(this._loaderId=e),"loading"===document.readyState){const t=()=>{document.removeEventListener("DOMContentLoaded",t),this._pageLoad.resolve()};document.addEventListener("DOMContentLoaded",t)}else this._pageLoad.resolve();(async()=>{switch(n){case"python":case"python3":case"python3.11":const{KernelPython3:e}=await __webpack_require__.e(211).then(__webpack_require__.bind(__webpack_require__,211));this._kernel=new e(t);break;case"python3-old":case"python3.8":const{KernelPython3Old:i}=await __webpack_require__.e(195).then(__webpack_require__.bind(__webpack_require__,5195));this._kernel=new i(t);break;case"js":case"javascript":const{KernelJavaScript:s}=await __webpack_require__.e(97).then(__webpack_require__.bind(__webpack_require__,4097));this._kernel=new s(t);break;case"sql":const{KernelSQL:r}=await Promise.all([__webpack_require__.e(960),__webpack_require__.e(837)]).then(__webpack_require__.bind(__webpack_require__,592));this._kernel=new r(t);break;case"ocaml":const{KernelOCaml:a}=await __webpack_require__.e(38).then(__webpack_require__.bind(__webpack_require__,38));this._kernel=new a(t);break;default:return window.console.error(`Kernel '${n}' not supported.`),void this._kernelAvailable.reject()}window.Basthon=this._kernel,this._kernelAvailable.resolve(this._kernel)})()}async pageLoad(){await this._pageLoad.promise}async kernelAvailable(){return await this._kernelAvailable.promise}async kernelLoaded(){const t=await this.kernelAvailable();return await t.loaded(),t}get kernel(){return this._kernel}get kernelSafe(){var t;return(null===(t=this.kernel)||void 0===t?void 0:t.ready)?this.kernel:null}async showLoader(t,e=!1,n=!0){this.kernelAvailable().then((()=>{var t;return null===(t=this.kernel)||void 0===t?void 0:t.init()})),__webpack_require__.e(317).then(__webpack_require__.bind(__webpack_require__,1317));const i="basthon-loader-"+(e?"full":"foot"),s=document.createElement("div");s.id=this._loaderId,s.classList.add("darklighted"),s.classList.add("basthon-loader-root"),s.classList.add(i);const r=document.createElement("div");r.classList.add("basthon-loader-container"),r.classList.add(i),s.appendChild(r);const a=document.createElement("div");a.classList.add("basthon-loader-spinner"),a.classList.add(i),a.innerHTML="",r.appendChild(a);const o=document.createElement("div");o.classList.add("basthon-loader-break"),o.classList.add(i),r.appendChild(o);const l=document.createElement("div");l.classList.add("basthon-loader-text"),l.classList.add(i),l.innerHTML=t,r.appendChild(l),this._loaderTextElem=l;const u=document.createElement("div");u.classList.add("basthon-loader-text"),u.classList.add(i),u.style.display="none",r.appendChild(u),this._loaderTextError=u,await this.pageLoad(),document.body.appendChild(s),this._rootLoader=s;try{await this.kernelLoaded()}catch(t){const e=this.browser();this.setErrorText(`Erreur de chargement de Basthon !!!
Vérifiez que votre navigateur est à jour.
Version détectée : ${e.name} ${e.version}.`);for(const t of document.body.querySelectorAll(".basthon-loader-foot"))t.classList.remove("basthon-loader-foot"),t.classList.add("basthon-loader-full");return a.classList.remove("basthon-loader-spinner"),a.classList.add("basthon-loader-error"),void(this._doNotHideLoader=!0)}this._doNotHideLoader=!1,n&&this.hideLoader()}setLoaderText(t){null!=this._loaderTextElem&&(this._loaderTextElem.innerHTML=t)}setErrorText(t){null!=this._loaderTextElem&&(this._loaderTextElem.style.display="none"),null!=this._loaderTextError&&(this._loaderTextError.style.display="",this._loaderTextError.innerHTML=t)}hideLoader(){if(this._doNotHideLoader)return;const t=this._rootLoader;null!=t&&(t.classList.add("basthon-loader-hide"),window.setTimeout((()=>{this._rootLoader=void 0,t.remove()}),1100))}browser(){var t,e=navigator.userAgent,n=e.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];return/trident/i.test(n[1])?{name:"IE",version:(t=/\brv[ :]+(\d+)/g.exec(e)||[])[1]||""}:"Chrome"===n[1]&&null!=(t=e.match(/\bOPR|Edge\/(\d+)/))?{name:"Opera",version:t[1]}:(n=n[2]?[n[1],n[2]]:[navigator.appName,navigator.appVersion,"-?"],null!=(t=e.match(/version\/(\d+)/i))&&n.splice(1,1,t[1]),{name:n[0],version:n[1]})}}class vb extends Zt.PageBase{static{Zt.HTMLTemplate.add("html/statusbar/statusbar-image.html",new Zt.HTMLTemplate('\r\n
')),this.init=function(){Zt.StatusBarsManager.typesRegistry.register(["images"],vb);const t=Zt.Workspace.getMain().getStatusBarsManager();return t.add({type:"images",id:"images",name:Jt.Msg.PYTHON_PYODIDE_IMAGE,title:Jt.Msg.PYTHON_PYODIDE_IMAGE}),t.changeTo("output"),t.get("images")}}constructor(){super();const t=gb()(Zt.HTMLTemplate.get("html/statusbar/statusbar-image.html").render());this.setContent(t)}init(){super.init(),this.hideCloseBtn()}clean(){this.getContent().empty()}display(t){const e=this.getContent(),n=function(t){t.style.width="auto",t.style.height="auto",t.style.maxWidth="100%",t.style.maxHeight="100%"};this.clean();let i=t.content,s=null,r=null;switch(t.display_type){case"p5":i.style.width="100%",i.style.height="100%",i.style.display="flex",i.style.justifyContent="center",i.style.alignItems="center",new MutationObserver((function(t){t.forEach((t=>t.addedNodes.forEach((t=>{const e=t;null!=e.tagName&&["canvas","video"].includes(e.tagName.toLowerCase())&&n(e)}))))})).observe(i,{childList:!0}),i.querySelectorAll("canvas,video").forEach(n),e.append(i);break;case"matplotlib":s=i.querySelector("canvas"),s&&(i=s),i.style.width="",i.style.height="",i.style.maxWidth="100%",i.style.maxHeight="100%",e.append(i);break;case"ocaml-canvas":i.style.width="",i.style.height="",i.style.maxWidth="100%",i.style.maxHeight="100%",e.append(i);break;case"turtle":i.setAttribute("width","100%"),i.setAttribute("height","100%"),e.append(i.outerHTML);break;case"sympy":e.append(t.content),void 0===window.MathJax?(console.log("Loading MathJax (Sympy expression needs it)."),function(){let t=document.createElement("script");t.type="text/javascript",t.src="https://cdn.jsdelivr.net/npm/mathjax@3.0.5/es5/tex-mml-chtml.js",document.getElementsByTagName("head")[0].appendChild(t)}()):window.MathJax.typeset();break;case"multiple":for(let n of["image/svg+xml","image/png","text/html","text/plain"])if(n in t.content){let i=t.content[n];"image/png"===n&&(i=''),e.append(i);break}break;case"tutor":if(e.append(gb()(t.content.replace("overflow-y%3A%20hidden%3B",""))),r=this.getContent()[0].getElementsByTagName("iframe")[0],null==r)return;r.style.maxHeight=r.style.minHeight="100%",new IntersectionObserver(((t,e)=>{const n=t[0];n&&!n.isIntersecting||(r.contentWindow?.postMessage({type:"redraw"},"*"),e.disconnect())})).observe(r);break;default:console.error(`Not supported node type '${t.display_type}' in eval.display result processing.`)}}}const wb=layui;var Sb;!function(t){t[t.EPERM=1]="EPERM",t[t.ENOENT=2]="ENOENT",t[t.EINTR=4]="EINTR",t[t.EIO=5]="EIO",t[t.ENXIO=6]="ENXIO",t[t.EBADF=9]="EBADF",t[t.EAGAIN=11]="EAGAIN",t[t.ENOMEM=12]="ENOMEM",t[t.EACCES=13]="EACCES",t[t.EFAULT=14]="EFAULT",t[t.ENOTBLK=15]="ENOTBLK",t[t.EBUSY=16]="EBUSY",t[t.EEXIST=17]="EEXIST",t[t.EXDEV=18]="EXDEV",t[t.ENODEV=19]="ENODEV",t[t.ENOTDIR=20]="ENOTDIR",t[t.EISDIR=21]="EISDIR",t[t.EINVAL=22]="EINVAL",t[t.ENFILE=23]="ENFILE",t[t.EMFILE=24]="EMFILE",t[t.ETXTBSY=26]="ETXTBSY",t[t.EFBIG=27]="EFBIG",t[t.ENOSPC=28]="ENOSPC",t[t.ESPIPE=29]="ESPIPE",t[t.EROFS=30]="EROFS",t[t.EMLINK=31]="EMLINK",t[t.EPIPE=32]="EPIPE",t[t.EDOM=33]="EDOM",t[t.ERANGE=34]="ERANGE",t[t.EDEADLK=35]="EDEADLK",t[t.ENAMETOOLONG=36]="ENAMETOOLONG",t[t.ENOLCK=37]="ENOLCK",t[t.ENOSYS=38]="ENOSYS",t[t.ENOTEMPTY=39]="ENOTEMPTY",t[t.ELOOP=40]="ELOOP",t[t.ENOMSG=42]="ENOMSG",t[t.EBADE=52]="EBADE",t[t.EBADR=53]="EBADR",t[t.EXFULL=54]="EXFULL",t[t.ENOANO=55]="ENOANO",t[t.EBADRQC=56]="EBADRQC",t[t.ENOSTR=60]="ENOSTR",t[t.ENODATA=61]="ENODATA",t[t.ETIME=62]="ETIME",t[t.ENOSR=63]="ENOSR",t[t.ENONET=64]="ENONET",t[t.EREMOTE=66]="EREMOTE",t[t.ENOLINK=67]="ENOLINK",t[t.ECOMM=70]="ECOMM",t[t.EPROTO=71]="EPROTO",t[t.EBADMSG=74]="EBADMSG",t[t.EOVERFLOW=75]="EOVERFLOW",t[t.EBADFD=77]="EBADFD",t[t.ESTRPIPE=86]="ESTRPIPE",t[t.ENOTSOCK=88]="ENOTSOCK",t[t.EDESTADDRREQ=89]="EDESTADDRREQ",t[t.EMSGSIZE=90]="EMSGSIZE",t[t.EPROTOTYPE=91]="EPROTOTYPE",t[t.ENOPROTOOPT=92]="ENOPROTOOPT",t[t.EPROTONOSUPPORT=93]="EPROTONOSUPPORT",t[t.ESOCKTNOSUPPORT=94]="ESOCKTNOSUPPORT",t[t.ENOTSUP=95]="ENOTSUP",t[t.ENETDOWN=100]="ENETDOWN",t[t.ENETUNREACH=101]="ENETUNREACH",t[t.ENETRESET=102]="ENETRESET",t[t.ETIMEDOUT=110]="ETIMEDOUT",t[t.ECONNREFUSED=111]="ECONNREFUSED",t[t.EHOSTDOWN=112]="EHOSTDOWN",t[t.EHOSTUNREACH=113]="EHOSTUNREACH",t[t.EALREADY=114]="EALREADY",t[t.EINPROGRESS=115]="EINPROGRESS",t[t.ESTALE=116]="ESTALE",t[t.EREMOTEIO=121]="EREMOTEIO",t[t.EDQUOT=122]="EDQUOT"}(Sb||(Sb={}));const xb={[Sb.EPERM]:"Operation not permitted",[Sb.ENOENT]:"No such file or directory",[Sb.EINTR]:"Interrupted system call",[Sb.EIO]:"Input/output error",[Sb.ENXIO]:"No such device or address",[Sb.EBADF]:"Bad file descriptor",[Sb.EAGAIN]:"Resource temporarily unavailable",[Sb.ENOMEM]:"Cannot allocate memory",[Sb.EACCES]:"Permission denied",[Sb.EFAULT]:"Bad address",[Sb.ENOTBLK]:"Block device required",[Sb.EBUSY]:"Resource busy or locked",[Sb.EEXIST]:"File exists",[Sb.EXDEV]:"Invalid cross-device link",[Sb.ENODEV]:"No such device",[Sb.ENOTDIR]:"File is not a directory",[Sb.EISDIR]:"File is a directory",[Sb.EINVAL]:"Invalid argument",[Sb.ENFILE]:"Too many open files in system",[Sb.EMFILE]:"Too many open files",[Sb.ETXTBSY]:"Text file busy",[Sb.EFBIG]:"File is too big",[Sb.ENOSPC]:"No space left on disk",[Sb.ESPIPE]:"Illegal seek",[Sb.EROFS]:"Cannot modify a read-only file system",[Sb.EMLINK]:"Too many links",[Sb.EPIPE]:"Broken pipe",[Sb.EDOM]:"Numerical argument out of domain",[Sb.ERANGE]:"Numerical result out of range",[Sb.EDEADLK]:"Resource deadlock would occur",[Sb.ENAMETOOLONG]:"File name too long",[Sb.ENOLCK]:"No locks available",[Sb.ENOSYS]:"Function not implemented",[Sb.ENOTEMPTY]:"Directory is not empty",[Sb.ELOOP]:"Too many levels of symbolic links",[Sb.ENOMSG]:"No message of desired type",[Sb.EBADE]:"Invalid exchange",[Sb.EBADR]:"Invalid request descriptor",[Sb.EXFULL]:"Exchange full",[Sb.ENOANO]:"No anode",[Sb.EBADRQC]:"Invalid request code",[Sb.ENOSTR]:"Device not a stream",[Sb.ENODATA]:"No data available",[Sb.ETIME]:"Timer expired",[Sb.ENOSR]:"Out of streams resources",[Sb.ENONET]:"Machine is not on the network",[Sb.EREMOTE]:"Object is remote",[Sb.ENOLINK]:"Link has been severed",[Sb.ECOMM]:"Communication error on send",[Sb.EPROTO]:"Protocol error",[Sb.EBADMSG]:"Bad message",[Sb.EOVERFLOW]:"Value too large for defined data type",[Sb.EBADFD]:"File descriptor in bad state",[Sb.ESTRPIPE]:"Streams pipe error",[Sb.ENOTSOCK]:"Socket operation on non-socket",[Sb.EDESTADDRREQ]:"Destination address required",[Sb.EMSGSIZE]:"Message too long",[Sb.EPROTOTYPE]:"Protocol wrong type for socket",[Sb.ENOPROTOOPT]:"Protocol not available",[Sb.EPROTONOSUPPORT]:"Protocol not supported",[Sb.ESOCKTNOSUPPORT]:"Socket type not supported",[Sb.ENOTSUP]:"Operation is not supported",[Sb.ENETDOWN]:"Network is down",[Sb.ENETUNREACH]:"Network is unreachable",[Sb.ENETRESET]:"Network dropped connection on reset",[Sb.ETIMEDOUT]:"Connection timed out",[Sb.ECONNREFUSED]:"Connection refused",[Sb.EHOSTDOWN]:"Host is down",[Sb.EHOSTUNREACH]:"No route to host",[Sb.EALREADY]:"Operation already in progress",[Sb.EINPROGRESS]:"Operation now in progress",[Sb.ESTALE]:"Stale file handle",[Sb.EREMOTEIO]:"Remote I/O error",[Sb.EDQUOT]:"Disk quota exceeded"};class Rb extends Error{static fromJSON(t){const e=new Rb(t.errno,t.message,t.path,t.syscall);return e.code=t.code,e.stack=t.stack,e}static With(t,e,n){return new Rb(Sb[t],xb[Sb[t]],e,n)}constructor(t,e=xb[t],n,i=""){super(e),this.errno=t,this.path=n,this.syscall=i,this.code=Sb[t],this.message=this.code+": "+e+(this.path?`, '${this.path}'`:"")}toString(){return this.message}toJSON(){return{errno:this.errno,code:this.code,path:this.path,stack:this.stack,message:this.message,syscall:this.syscall}}bufferSize(){return 4+JSON.stringify(this.toJSON()).length}}let Ab="/";function Ob(t,e){let n="",i=0,s=-1,r=0,a="\0";for(let o=0;o<=t.length;++o){if(o2){const t=n.lastIndexOf("/");-1===t?(n="",i=0):(n=n.slice(0,t),i=n.length-1-n.lastIndexOf("/")),s=o,r=0;continue}if(0!==n.length){n="",i=0,s=o,r=0;continue}}e&&(n+=n.length>0?"/..":"..",i=2)}else n.length>0?n+="/"+t.slice(s+1,o):n=t.slice(s+1,o),i=o-s-1;s=o,r=0}else"."===a&&-1!==r?++r:r=-1}return n}function Mb(...t){let e="";for(const n of[...t.reverse(),Ab])if(n.length&&(e=`${n}/${e}`,n.startsWith("/")))break;const n=e.startsWith("/");return e=Ob(e,!n),n?`/${e}`:e.length?e:"/"}function Cb(...t){if(!t.length)return".";const e=t.join("/");return e?.length?function(t){if(!t.length)return".";const e=t.startsWith("/"),n=t.endsWith("/");return(t=Ob(t,!e)).length?(n&&(t+="/"),e?`/${t}`:t):e?"/":n?"./":"."}(e):"."}function Nb(t){if(0===t.length)return".";const e="/"===t[0];let n=-1,i=!0;for(let e=t.length-1;e>=1;--e)if("/"===t[e]){if(!i){n=e;break}}else i=!1;return-1===n?e?"/":".":e&&1===n?"//":t.slice(0,n)}function kb(t,e){let n=0,i=-1,s=!0;if(void 0!==e&&e.length>0&&e.length<=t.length){if(e===t)return"";let r=e.length-1,a=-1;for(let o=t.length-1;o>=0;--o)if("/"===t[o]){if(!s){n=o+1;break}}else-1===a&&(s=!1,a=o+1),r>=0&&(t[o]===e[r]?-1==--r&&(i=o):(r=-1,i=a));return n===i?i=a:-1===i&&(i=t.length),t.slice(n,i)}for(let e=t.length-1;e>=0;--e)if("/"===t[e]){if(!s){n=e+1;break}}else-1===i&&(s=!1,i=e+1);return-1===i?"":t.slice(n,i)}function Db(t){const e=t.startsWith("/"),n={root:e?"/":"",dir:"",base:"",ext:"",name:""};if(0===t.length)return n;const i=e?1:0;let s=-1,r=0,a=-1,o=!0,l=t.length-1,u=0;for(;l>=i;--l)if("/"!==t[l])-1===a&&(o=!1,a=l+1),"."===t[l]?-1===s?s=l:1!==u&&(u=1):-1!==s&&(u=-1);else if(!o){r=l+1;break}if(-1!==a){const i=0===r&&e?1:r;-1===s||0===u||1===u&&s===a-1&&s===r+1?n.base=n.name=t.slice(i,a):(n.name=t.slice(i,s),n.base=t.slice(i,a),n.ext=t.slice(s,a))}return r>0?n.dir=t.slice(0,r-1):e&&(n.dir="/"),n}const Lb=new TextEncoder;function Fb(t){if("string"!=typeof t)throw new Rb(Sb.EINVAL,"Can not encode a non-string");return Lb.encode(t)}const Pb=new TextDecoder;function $b(t){if(!(t instanceof Uint8Array))throw new Rb(Sb.EINVAL,"Can not decode a non-Uint8Array");return Pb.decode(t)}function Bb(t){return JSON.parse($b(t),((t,e)=>""==t?e:BigInt(e)))}function Vb(t){return Fb(JSON.stringify(t,((t,e)=>""==t?e:e.toString())))}function Ub(t,e){if("number"==typeof t)return t;if("string"==typeof t){const e=parseInt(t,8);if(!isNaN(e))return e}if("number"==typeof e)return e;throw new Rb(Sb.EINVAL,"Invalid mode: "+t?.toString())}function Yb(t){if(t instanceof Date)return t;try{return new Date(t)}catch{throw new Rb(Sb.EINVAL,"Invalid time.")}}function Gb(t){if((t=t.toString()).includes("\0"))throw new Rb(Sb.EINVAL,"Path can not contain null character");if(0==t.length)throw new Rb(Sb.EINVAL,"Path can not be empty");return Mb(t.replaceAll(/[/\\]+/g,"/"))}function Hb(t,e="utf8",n,i=0){return"object"!=typeof t||null===t?{encoding:"string"==typeof t?t:e??null,flag:n,mode:i}:{encoding:"string"==typeof t?.encoding?t.encoding:e??null,flag:"string"==typeof t?.flag?t.flag:n,mode:Ub("mode"in t?t?.mode:null,i)}}function Wb(){return crypto.getRandomValues(new BigUint64Array(1))[0]}const zb={uid:0,gid:0,suid:0,sgid:0,euid:0,egid:0,groups:[]};function Xb(t){return{suid:t.uid,sgid:t.gid,euid:t.uid,egid:t.gid,groups:[],...t}}const jb=0,qb=4,Kb=2,Qb=1,Jb=1,Zb=2,tv=4,ev=0,nv=1,iv=2,sv=64,rv=128,av=256,ov=512,lv=1024,uv=65536,hv=262144,pv=131072,cv=1052672,dv=4096,fv=32768,mv=16384,gv=2048,_v=61440,Tv=49152,yv=40960,Iv=32768,Ev=24576,bv=16384,vv=8192,wv=4096,Sv=2048,xv=1024,Rv=512,Av=448,Ov=256,Mv=128,Cv=64,Nv=56,kv=32,Dv=16,Lv=8,Fv=7,Pv=4,$v=2,Bv=1,Vv=0,Uv=2**32-1,Yv={checkAccess:!0,updateOnRead:!0,syncImmediately:!0,unsafeBufferReplace:!1};Promise.withResolvers??(Promise.withResolvers=function(){let t,e;const n=new Promise(((n,i)=>{t=n,e=i}));return{promise:n,resolve:t,reject:e}}),Symbol.dispose??(Symbol.dispose=Symbol("Symbol.dispose")),Symbol.asyncDispose??(Symbol.asyncDispose=Symbol("Symbol.asyncDispose"));class Gv{_convert(t){return this._isBigint?BigInt(t):Number(t)}get blocks(){return this._convert(Math.ceil(Number(this.size)/512))}get atime(){return new Date(Number(this.atimeMs))}set atime(t){this.atimeMs=this._convert(t.getTime())}get mtime(){return new Date(Number(this.mtimeMs))}set mtime(t){this.mtimeMs=this._convert(t.getTime())}get ctime(){return new Date(Number(this.ctimeMs))}set ctime(t){this.ctimeMs=this._convert(t.getTime())}get birthtime(){return new Date(Number(this.birthtimeMs))}set birthtime(t){this.birthtimeMs=this._convert(t.getTime())}constructor({atimeMs:t,mtimeMs:e,ctimeMs:n,birthtimeMs:i,uid:s,gid:r,size:a,mode:o,ino:l}={}){this.dev=this._convert(0),this.ino=this._convert(0),this.rdev=this._convert(0),this.nlink=this._convert(1),this.blksize=this._convert(4096),this.uid=this._convert(0),this.gid=this._convert(0);const u=Date.now();this.atimeMs=this._convert(t??u),this.mtimeMs=this._convert(e??u),this.ctimeMs=this._convert(n??u),this.birthtimeMs=this._convert(i??u),this.uid=this._convert(s??0),this.gid=this._convert(r??0),this.size=this._convert(a??0),this.ino=this._convert(l??0),this.mode=this._convert(o??420&Iv),this.mode&_v||(this.mode=this.mode|this._convert(Iv))}isFile(){return(this.mode&_v)===Iv}isDirectory(){return(this.mode&_v)===bv}isSymbolicLink(){return(this.mode&_v)===yv}isSocket(){return(this.mode&_v)===Tv}isBlockDevice(){return(this.mode&_v)===Ev}isCharacterDevice(){return(this.mode&_v)===vv}isFIFO(){return(this.mode&_v)===wv}hasAccess(t,e){const n=e?.credentials||zb;if(this.isSymbolicLink()||0===n.euid||0===n.egid)return!0;let i=0;return n.uid===this.uid&&(this.mode&Ov&&(i|=qb),this.mode&Mv&&(i|=Kb),this.mode&Cv&&(i|=Qb)),(n.gid===this.gid||n.groups.includes(Number(this.gid)))&&(this.mode&kv&&(i|=qb),this.mode&Dv&&(i|=Kb),this.mode&Lv&&(i|=Qb)),this.mode&Pv&&(i|=qb),this.mode&$v&&(i|=Kb),this.mode&Bv&&(i|=Qb),(i&t)===t}chmod(t){this.mode=this._convert(this.mode&_v|t)}chown(t,e){t=Number(t),e=Number(e),!isNaN(t)&&0<=t&&t<2**32&&(this.uid=this._convert(t)),!isNaN(e)&&0<=e&&e<2**32&&(this.gid=this._convert(e))}get atimeNs(){return 1000n*BigInt(this.atimeMs)}get mtimeNs(){return 1000n*BigInt(this.mtimeMs)}get ctimeNs(){return 1000n*BigInt(this.ctimeMs)}get birthtimeNs(){return 1000n*BigInt(this.birthtimeMs)}}function Hv(t,e,n){!isNaN(e)&&0<=e&&e<2**32&&(t.uid=e),!isNaN(n)&&0<=n&&n<2**32&&(t.gid=n)}class Wv extends Gv{constructor(){super(...arguments),this._isBigint=!1}}class zv extends Gv{constructor(){super(...arguments),this._isBigint=!0}}class Xv{constructor(){this.type=525687744115,this.bsize=4096,this.blocks=0,this.bfree=0,this.bavail=0,this.files=Uv,this.ffree=Uv}}class jv{constructor(){this.type=0x7a656e6673n,this.bsize=4096n,this.blocks=0n,this.bfree=0n,this.bavail=0n,this.files=BigInt(Uv),this.ffree=BigInt(Uv)}}const qv=["r","r+","rs","rs+","w","wx","w+","wx+","a","ax","a+","ax+"];function Kv(t){if("number"==typeof t)return function(t){switch(t){case ev:return"r";case ev|cv:return"rs";case iv:return"r+";case iv|cv:return"rs+";case ov|sv|nv:return"w";case ov|sv|nv|rv:return"wx";case ov|sv|iv:return"w+";case ov|sv|iv|rv:return"wx+";case lv|sv|nv:return"a";case lv|sv|nv|rv:return"ax";case lv|sv|iv:return"a+";case lv|sv|iv|rv:return"ax+";default:throw new Error("Invalid flag number: "+t)}}(t);if(!qv.includes(t))throw new Error("Invalid flag string: "+t);return t}function Qv(t){let e=0;return e<<=1,e+=+Jv(t),e<<=1,e+=+Zv(t),e<<=1,e}function Jv(t){return-1!==t.indexOf("r")||-1!==t.indexOf("+")}function Zv(t){return-1!==t.indexOf("w")||-1!==t.indexOf("a")||-1!==t.indexOf("+")}function tw(t){return-1!==t.indexOf("w")}function ew(t){return-1!==t.indexOf("a")}function nw(t){return-1!==t.indexOf("x")}class iw{constructor(t,e){this.fs=t,this.path=e}async[Symbol.asyncDispose](){await this.close()}[Symbol.dispose](){this.closeSync()}datasync(){return this.sync()}datasyncSync(){return this.syncSync()}}class sw extends iw{constructor(t,e,n,i,s=new Uint8Array(new ArrayBuffer(0,t.metadata().noResizableBuffers?{}:{maxByteLength:Uv}))){if(super(t,e),this.flag=n,this.stats=i,this._buffer=s,this._position=0,this.dirty=!1,this.closed=!1,this.stats.size!=s.byteLength){if(Jv(this.flag))throw new Error(`Size mismatch: buffer length ${s.byteLength}, stats size ${this.stats.size}`);this.dirty=!0}}get buffer(){return this._buffer}get position(){return ew(this.flag)?this.stats.size:this._position}set position(t){this._position=t}async sync(){if(this.closed)throw Rb.With("EBADF",this.path,"File.sync");this.dirty&&(await this.fs.sync(this.path,this._buffer,this.stats),this.dirty=!1)}syncSync(){if(this.closed)throw Rb.With("EBADF",this.path,"File.sync");this.dirty&&(this.fs.syncSync(this.path,this._buffer,this.stats),this.dirty=!1)}async close(){if(this.closed)throw Rb.With("EBADF",this.path,"File.close");await this.sync(),this.dispose()}closeSync(){if(this.closed)throw Rb.With("EBADF",this.path,"File.close");this.syncSync(),this.dispose()}dispose(t){if(this.closed)throw Rb.With("EBADF",this.path,"File.dispose");if(this.dirty&&!t)throw Rb.With("EBUSY",this.path,"File.dispose");delete this._buffer,delete this.stats,this.closed=!0}stat(){if(this.closed)throw Rb.With("EBADF",this.path,"File.stat");return Promise.resolve(new Wv(this.stats))}statSync(){if(this.closed)throw Rb.With("EBADF",this.path,"File.stat");return new Wv(this.stats)}_truncate(t){if(this.closed)throw Rb.With("EBADF",this.path,"File.truncate");if(this.dirty=!0,!Zv(this.flag))throw new Rb(Sb.EPERM,"File not opened with a writeable mode.");if(this.stats.mtimeMs=Date.now(),t>this._buffer.length){const e=new Uint8Array(t-this._buffer.length);this._write(e,0,e.length,this._buffer.length)}else this.stats.size=t,this._buffer=t?this._buffer.slice(0,t):new Uint8Array}async truncate(t){this._truncate(t),Yv.syncImmediately&&await this.sync()}truncateSync(t){this._truncate(t),Yv.syncImmediately&&this.syncSync()}_write(t,e=0,n=this.stats.size,i=this.position){if(this.closed)throw Rb.With("EBADF",this.path,"File.write");if(!Zv(this.flag))throw new Rb(Sb.EPERM,"File not opened with a writeable mode.");this.dirty=!0;const s=i+n,r=t.slice(e,e+n);if(s>this.stats.size&&(this.stats.size=s,s>this._buffer.byteLength))if(this._buffer.buffer.resizable&&this._buffer.buffer.maxByteLength<=s)this._buffer.buffer.resize(s);else if(Yv.unsafeBufferReplace)this._buffer=r;else{const t=new Uint8Array(new ArrayBuffer(s,this.fs.metadata().noResizableBuffers?{}:{maxByteLength:Uv}));t.set(this._buffer),this._buffer=t}return this._buffer.set(r,i),this.stats.mtimeMs=Date.now(),this.position=i+r.byteLength,r.byteLength}async write(t,e,n,i){const s=this._write(t,e,n,i);return Yv.syncImmediately&&await this.sync(),s}writeSync(t,e=0,n=this.stats.size,i=this.position){const s=this._write(t,e,n,i);return Yv.syncImmediately&&this.syncSync(),s}_read(t,e=0,n=this.stats.size,i){if(this.closed)throw Rb.With("EBADF",this.path,"File.read");if(!Jv(this.flag))throw new Rb(Sb.EPERM,"File not opened with a readable mode.");Yv.updateOnRead&&(this.dirty=!0),this.stats.atimeMs=Date.now(),i??(i=this.position);let s=i+n;s>this.stats.size&&(s=i+Math.max(this.stats.size-i,0)),this._position=s;const r=s-i;return 0==r||new Uint8Array(t.buffer,e,n).set(this._buffer.slice(i,s)),r}async read(t,e,n,i){const s=this._read(t,e,n,i);return Yv.syncImmediately&&await this.sync(),{bytesRead:s,buffer:t}}readSync(t,e,n,i){const s=this._read(t,e,n,i);return Yv.syncImmediately&&this.syncSync(),s}async chmod(t){if(this.closed)throw Rb.With("EBADF",this.path,"File.chmod");this.dirty=!0,this.stats.mode=this.stats.mode&(t>_v?~_v:_v)|t,(Yv.syncImmediately||t>_v)&&await this.sync()}chmodSync(t){if(this.closed)throw Rb.With("EBADF",this.path,"File.chmod");this.dirty=!0,this.stats.mode=this.stats.mode&(t>_v?~_v:_v)|t,(Yv.syncImmediately||t>_v)&&this.syncSync()}async chown(t,e){if(this.closed)throw Rb.With("EBADF",this.path,"File.chown");this.dirty=!0,Hv(this.stats,t,e),Yv.syncImmediately&&await this.sync()}chownSync(t,e){if(this.closed)throw Rb.With("EBADF",this.path,"File.chown");this.dirty=!0,Hv(this.stats,t,e),Yv.syncImmediately&&this.syncSync()}async utimes(t,e){if(this.closed)throw Rb.With("EBADF",this.path,"File.utimes");this.dirty=!0,this.stats.atime=t,this.stats.mtime=e,Yv.syncImmediately&&await this.sync()}utimesSync(t,e){if(this.closed)throw Rb.With("EBADF",this.path,"File.utimes");this.dirty=!0,this.stats.atime=t,this.stats.mtime=e,Yv.syncImmediately&&this.syncSync()}}class rw{metadata(){return{name:this.constructor.name.toLowerCase(),readonly:!1,totalSpace:0,freeSpace:0,noResizableBuffers:!1,noAsyncCache:this._disableSync??!1,type:525687744115}}constructor(...t){}async ready(){}async exists(t){try{return await this.stat(t),!0}catch(t){return"ENOENT"!=t.code}}existsSync(t){try{return this.statSync(t),!0}catch(t){return"ENOENT"!=t.code}}}var aw=__webpack_require__(228);Symbol.toStringTag,Symbol.iterator;const ow=Intl.NumberFormat("en",{notation:"compact"});ow.format.bind(ow);function lw(t){return t.at(0).toUpperCase()+t.slice(1)}const uw=["int8","uint8","int16","uint16","int32","uint32","int64","uint64","float32","float64"],hw=[...uw,...uw.map((t=>lw(t))),"char"],pw=/^(u?int|float)(8|16|32|64)$/i;function cw(t){return"char"==t?"uint8":t.toLowerCase()}function dw(t){return pw.test(t.toString())}function fw(t){return"char"==t||pw.test(t.toString().toLowerCase())}Symbol.struct_init||=Symbol("struct_init"),Symbol.struct_metadata||=Symbol("struct_metadata");Symbol.struct_init,Symbol.struct_metadata;function mw(t){const e=Symbol.metadata||Object.getOwnPropertySymbols(t).find((t=>"Symbol.metadata"==t.description));var n;if(n=t,Symbol?.metadata&&(Symbol.metadata in n||Object.defineProperty(n,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:Object.create(null)})),!e)throw new ReferenceError("Could not get a reference to Symbol.metadata");return e}function gw(t){return"function"==typeof t&&mw(t)in t&&function(t){return null!=t&&"object"==typeof t&&Symbol.struct_metadata in t}(t[mw(t)])}function _w(t){return null!=t&&"object"==typeof t&&gw(t.constructor)}function Tw(t){if(!_w(t))throw new TypeError(("function"==typeof t?t.name:"object"==typeof t&&t?t.constructor.name:t)+" is not a struct instance")}function yw(t){if(!function(t){return _w(t)||gw(t)}(t))throw new TypeError(("function"==typeof t?t.name:"object"==typeof t&&t?t.constructor.name:t)+" is not a struct")}function Iw(t){if("string"==typeof t)return function(t){if(!fw(t))throw new TypeError("Not a valid primitive type: "+t)}(t),+cw(t).match(pw)[2]/8;yw(t);const e=gw(t)?t:t.constructor;return e[mw(e)][Symbol.struct_metadata].size}function Ew(t={}){return function(e,n){n.metadata??={},n.metadata[Symbol.struct_init]||=[];let i=0;const s=new Map;for(const e of n.metadata[Symbol.struct_init]){const{name:n,type:o,length:l}=e;if(!fw(o)&&!gw(o))throw new TypeError("Not a valid type: "+o);s.set(n,{offset:i,type:fw(o)?cw(o):o,length:l}),i+=Iw(o)*(l||1),r=i,a=t.align||1,i=Math.ceil(r/a)*a}var r,a;return n.metadata[Symbol.struct_metadata]={options:t,members:s,size:i},e}}function bw(t,e){return function(n,i){let s=i.name;if("symbol"==typeof s&&(console.warn("Symbol used for struct member name will be coerced to string: "+s.toString()),s=s.toString()),!s)throw new ReferenceError("Invalid name for struct member");return i.metadata??={},i.metadata[Symbol.struct_init]||=[],i.metadata[Symbol.struct_init].push({name:s,type:t,length:e}),n}}function vw(t){Tw(t);const{options:e,members:n}=t.constructor[mw(t.constructor)][Symbol.struct_metadata],i=new Uint8Array(Iw(t)),s=new DataView(i.buffer);for(const[r,{type:a,length:o,offset:l}]of n)for(let n=0;n<(o||1);n++){const u=l+Iw(a)*n;let h=o>0?t[r][n]:t[r];if("string"==typeof h&&(h=h.charCodeAt(0)),!dw(a)){i.set(h?vw(h):new Uint8Array(Iw(a)),u);continue}const p="set"+lw(a);"setInt64"!=p?"setUint64"!=p?s[p](u,Number(h),!e.bigEndian):s.setBigUint64(u,BigInt(h),!e.bigEndian):s.setBigInt64(u,BigInt(h),!e.bigEndian)}return i}function ww(t,e){Tw(t);const{options:n,members:i}=t.constructor[mw(t.constructor)][Symbol.struct_metadata],s=e instanceof Uint8Array?e:new Uint8Array("buffer"in e?e.buffer:e),r=new DataView(s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength));for(const[e,{type:a,offset:o,length:l}]of i)for(let i=0;i<(l||1);i++){let u=l>0?t[e]:t;const h=l>0?i:e,p=o+Iw(a)*i;if("string"==typeof t[e]){t[e]=t[e].slice(0,i)+String.fromCharCode(r.getUint8(p))+t[e].slice(i+1);continue}if(!dw(a)){if(null===u[h]||void 0===u[h])continue;ww(u[h],new Uint8Array(s.slice(p,p+Iw(a))));continue}l>0&&(u||=[]);const c="get"+lw(a);"getInt64"!=c?u[h]="getUint64"!=c?r[c](p,!n.bigEndian):r.getBigUint64(p,!n.bigEndian):u[h]=r.getBigInt64(p,!n.bigEndian)}}Symbol.metadata??=Symbol.for("Symbol.metadata");const Sw=Object.fromEntries(hw.map((t=>{return[t,(e=t,function(t,n){return"number"==typeof t?bw(e,t):bw(e)(t,n)})];var e})));var xw=function(t,e,n,i,s,r){function a(t){if(void 0!==t&&"function"!=typeof t)throw new TypeError("Function expected");return t}for(var o,l=i.kind,u="getter"===l?"get":"setter"===l?"set":"value",h=!e&&t?i.static?t:t.prototype:null,p=e||(h?Object.getOwnPropertyDescriptor(h,i.name):{}),c=!1,d=n.length-1;d>=0;d--){var f={};for(var m in i)f[m]="access"===m?{}:i[m];for(var m in i.access)f.access[m]=i.access[m];f.addInitializer=function(t){if(c)throw new TypeError("Cannot add initializers after decoration has completed");r.push(a(t||null))};var g=(0,n[d])("accessor"===l?{get:p.get,set:p.set}:p[u],f);if("accessor"===l){if(void 0===g)continue;if(null===g||"object"!=typeof g)throw new TypeError("Object expected");(o=a(g.get))&&(p.get=o),(o=a(g.set))&&(p.set=o),(o=a(g.init))&&s.unshift(o)}else(o=a(g))&&("field"===l?s.unshift(o):p[u]=o)}h&&Object.defineProperty(h,i.name,p),c=!0},Rw=function(t,e,n){for(var i=arguments.length>2,s=0;s{var t,e,n,i,s,r,a,o,l,u,h;let p,c,d,f,m,g,_,T,y,I,E,b,v,w=[Ew()],S=[],x=[],R=[],A=[],O=[],M=[],C=[],N=[],k=[],D=[],L=[],F=[],P=[],$=[],B=[],V=[],U=[],Y=[],G=[],H=[],W=[],z=[],X=[];var j=c=class{constructor(t){if(this.data=Rw(this,x,void 0),this.size=(Rw(this,R),Rw(this,A,void 0)),this.mode=(Rw(this,O),Rw(this,M,void 0)),this.nlink=(Rw(this,C),Rw(this,N,void 0)),this.uid=(Rw(this,k),Rw(this,D,void 0)),this.gid=(Rw(this,L),Rw(this,F,void 0)),this.atimeMs=(Rw(this,P),Rw(this,$,void 0)),this.birthtimeMs=(Rw(this,B),Rw(this,V,void 0)),this.mtimeMs=(Rw(this,U),Rw(this,Y,void 0)),this.ctimeMs=(Rw(this,G),Rw(this,H,void 0)),this.ino=(Rw(this,W),Rw(this,z,void 0)),Rw(this,X),t){const e=Iw(j),n=e-Iw("uint64");if(t.byteLength{const q="function"==typeof Symbol&&Symbol.metadata?Object.create(null):void 0;d=[(t=Sw).uint64.bind(t)],f=[(e=Sw).uint32.bind(e)],m=[(n=Sw).uint16.bind(n)],g=[(i=Sw).uint32.bind(i)],_=[(s=Sw).uint32.bind(s)],T=[(r=Sw).uint32.bind(r)],y=[(a=Sw).float64.bind(a)],I=[(o=Sw).float64.bind(o)],E=[(l=Sw).float64.bind(l)],b=[(u=Sw).float64.bind(u)],v=[(h=Sw).uint64.bind(h)],xw(null,null,d,{kind:"field",name:"data",static:!1,private:!1,access:{has:t=>"data"in t,get:t=>t.data,set:(t,e)=>{t.data=e}},metadata:q},x,R),xw(null,null,f,{kind:"field",name:"size",static:!1,private:!1,access:{has:t=>"size"in t,get:t=>t.size,set:(t,e)=>{t.size=e}},metadata:q},A,O),xw(null,null,m,{kind:"field",name:"mode",static:!1,private:!1,access:{has:t=>"mode"in t,get:t=>t.mode,set:(t,e)=>{t.mode=e}},metadata:q},M,C),xw(null,null,g,{kind:"field",name:"nlink",static:!1,private:!1,access:{has:t=>"nlink"in t,get:t=>t.nlink,set:(t,e)=>{t.nlink=e}},metadata:q},N,k),xw(null,null,_,{kind:"field",name:"uid",static:!1,private:!1,access:{has:t=>"uid"in t,get:t=>t.uid,set:(t,e)=>{t.uid=e}},metadata:q},D,L),xw(null,null,T,{kind:"field",name:"gid",static:!1,private:!1,access:{has:t=>"gid"in t,get:t=>t.gid,set:(t,e)=>{t.gid=e}},metadata:q},F,P),xw(null,null,y,{kind:"field",name:"atimeMs",static:!1,private:!1,access:{has:t=>"atimeMs"in t,get:t=>t.atimeMs,set:(t,e)=>{t.atimeMs=e}},metadata:q},$,B),xw(null,null,I,{kind:"field",name:"birthtimeMs",static:!1,private:!1,access:{has:t=>"birthtimeMs"in t,get:t=>t.birthtimeMs,set:(t,e)=>{t.birthtimeMs=e}},metadata:q},V,U),xw(null,null,E,{kind:"field",name:"mtimeMs",static:!1,private:!1,access:{has:t=>"mtimeMs"in t,get:t=>t.mtimeMs,set:(t,e)=>{t.mtimeMs=e}},metadata:q},Y,G),xw(null,null,b,{kind:"field",name:"ctimeMs",static:!1,private:!1,access:{has:t=>"ctimeMs"in t,get:t=>t.ctimeMs,set:(t,e)=>{t.ctimeMs=e}},metadata:q},H,W),xw(null,null,v,{kind:"field",name:"ino",static:!1,private:!1,access:{has:t=>"ino"in t,get:t=>t.ino,set:(t,e)=>{t.ino=e}},metadata:q},z,X),xw(null,p={value:c},w,{kind:"class",name:c.name,metadata:q},null,S),j=c=p.value,q&&Object.defineProperty(c,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:q}),Rw(c,S)})(),j=c})();var Mw=function(t,e,n){if(null!=e){if("object"!=typeof e&&"function"!=typeof e)throw new TypeError("Object expected.");var i,s;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");i=e[Symbol.asyncDispose]}if(void 0===i){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");i=e[Symbol.dispose],n&&(s=i)}if("function"!=typeof i)throw new TypeError("Object not disposable.");s&&(i=function(){try{s.call(this)}catch(t){return Promise.reject(t)}}),t.stack.push({value:e,dispose:i,async:n})}else n&&t.stack.push({async:!0});return e},Cw=function(t){return function(e){function n(n){e.error=e.hasError?new t(n,e.error,"An error was suppressed during disposal."):n,e.hasError=!0}return function t(){for(;e.stack.length;){var i=e.stack.pop();try{var s=i.dispose&&i.dispose.call(i.value);if(i.async)return Promise.resolve(s).then(t,(function(e){return n(e),t()}))}catch(t){n(t)}}if(e.hasError)throw e.error}()}}("function"==typeof SuppressedError?SuppressedError:function(t,e,n){var i=new Error(n);return i.name="SuppressedError",i.error=t,i.suppressed=e,i});class Nw extends rw{async ready(){this._initialized||(await this.checkRoot(),this._initialized=!0)}constructor(t){super(),this.store=t,this._initialized=!1}metadata(){return{...super.metadata(),name:this.store.name}}async empty(){await this.store.clear(),await this.checkRoot()}emptySync(){this.store.clearSync(),this.checkRootSync()}async rename(t,e){const n={stack:[],error:void 0,hasError:!1};try{const i=Mw(n,this.store.transaction(),!0),s=Db(t),r=Db(e),a=await this.findInode(i,s.dir,"rename"),o=Bb(await this.get(i,a.data,s.dir,"rename"));if(!o[s.base])throw Rb.With("ENOENT",t,"rename");const l=o[s.base];if(delete o[s.base],0===(r.dir+"/").indexOf(t+"/"))throw new Rb(Sb.EBUSY,s.dir);const u=r.dir==s.dir,h=u?a:await this.findInode(i,r.dir,"rename"),p=u?o:Bb(await this.get(i,h.data,r.dir,"rename"));if(p[r.base]){const t=new Ow(await this.get(i,p[r.base],e,"rename"));if(!t.toStats().isFile())throw Rb.With("EPERM",e,"rename");await i.remove(t.data),await i.remove(p[r.base])}p[r.base]=l,await i.set(a.data,Vb(o)),await i.set(h.data,Vb(p)),await i.commit()}catch(t){n.error=t,n.hasError=!0}finally{const t=Cw(n);t&&await t}}renameSync(t,e){const n={stack:[],error:void 0,hasError:!1};try{const i=Mw(n,this.store.transaction(),!1),s=Db(t),r=Db(e),a=this.findInodeSync(i,s.dir,"rename"),o=Bb(this.getSync(i,a.data,s.dir,"rename"));if(!o[s.base])throw Rb.With("ENOENT",t,"rename");const l=o[s.base];if(delete o[s.base],0==(r.dir+"/").indexOf(t+"/"))throw new Rb(Sb.EBUSY,s.dir);const u=r.dir===s.dir,h=u?a:this.findInodeSync(i,r.dir,"rename"),p=u?o:Bb(this.getSync(i,h.data,r.dir,"rename"));if(p[r.base]){const t=new Ow(this.getSync(i,p[r.base],e,"rename"));if(!t.toStats().isFile())throw Rb.With("EPERM",e,"rename");i.removeSync(t.data),i.removeSync(p[r.base])}p[r.base]=l,i.setSync(a.data,Vb(o)),i.setSync(h.data,Vb(p)),i.commitSync()}catch(t){n.error=t,n.hasError=!0}finally{Cw(n)}}async stat(t){const e={stack:[],error:void 0,hasError:!1};try{const n=Mw(e,this.store.transaction(),!0);return(await this.findInode(n,t,"stat")).toStats()}catch(t){e.error=t,e.hasError=!0}finally{const t=Cw(e);t&&await t}}statSync(t){const e={stack:[],error:void 0,hasError:!1};try{const n=Mw(e,this.store.transaction(),!1);return this.findInodeSync(n,t,"stat").toStats()}catch(t){e.error=t,e.hasError=!0}finally{Cw(e)}}async createFile(t,e,n){const i=await this.commitNew(t,Iv,n,new Uint8Array,"createFile");return new sw(this,t,e,i.toStats(),new Uint8Array)}createFileSync(t,e,n){const i=this.commitNewSync(t,Iv,n,new Uint8Array,"createFile");return new sw(this,t,e,i.toStats(),new Uint8Array)}async openFile(t,e){const n={stack:[],error:void 0,hasError:!1};try{const i=Mw(n,this.store.transaction(),!0),s=await this.findInode(i,t,"openFile"),r=await this.get(i,s.data,t,"openFile");return new sw(this,t,e,s.toStats(),r)}catch(t){n.error=t,n.hasError=!0}finally{const t=Cw(n);t&&await t}}openFileSync(t,e){const n={stack:[],error:void 0,hasError:!1};try{const i=Mw(n,this.store.transaction(),!1),s=this.findInodeSync(i,t,"openFile"),r=this.getSync(i,s.data,t,"openFile");return new sw(this,t,e,s.toStats(),r)}catch(t){n.error=t,n.hasError=!0}finally{Cw(n)}}async unlink(t){return this.remove(t,!1,"unlink")}unlinkSync(t){this.removeSync(t,!1,"unlink")}async rmdir(t){if((await this.readdir(t)).length)throw Rb.With("ENOTEMPTY",t,"rmdir");await this.remove(t,!0,"rmdir")}rmdirSync(t){if(this.readdirSync(t).length)throw Rb.With("ENOTEMPTY",t,"rmdir");this.removeSync(t,!0,"rmdir")}async mkdir(t,e){await this.commitNew(t,bv,e,Fb("{}"),"mkdir")}mkdirSync(t,e){this.commitNewSync(t,bv,e,Fb("{}"),"mkdir")}async readdir(t){const e={stack:[],error:void 0,hasError:!1};try{const n=Mw(e,this.store.transaction(),!0),i=await this.findInode(n,t,"readdir");return Object.keys(Bb(await this.get(n,i.data,t,"readdir")))}catch(t){e.error=t,e.hasError=!0}finally{const t=Cw(e);t&&await t}}readdirSync(t){const e={stack:[],error:void 0,hasError:!1};try{const n=Mw(e,this.store.transaction(),!1),i=this.findInodeSync(n,t,"readdir");return Object.keys(Bb(this.getSync(n,i.data,t,"readdir")))}catch(t){e.error=t,e.hasError=!0}finally{Cw(e)}}async sync(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{const s=Mw(i,this.store.transaction(),!0),r=await this._findInode(s,t,"sync"),a=new Ow(await this.get(s,r,t,"sync")),o=a.update(n);await s.set(a.data,e),o&&await s.set(r,vw(a)),await s.commit()}catch(t){i.error=t,i.hasError=!0}finally{const t=Cw(i);t&&await t}}syncSync(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{const s=Mw(i,this.store.transaction(),!1),r=this._findInodeSync(s,t,"sync"),a=new Ow(this.getSync(s,r,t,"sync")),o=a.update(n);s.setSync(a.data,e),o&&s.setSync(r,vw(a)),s.commitSync()}catch(t){i.error=t,i.hasError=!0}finally{Cw(i)}}async link(t,e){const n={stack:[],error:void 0,hasError:!1};try{const i=Mw(n,this.store.transaction(),!0),s=Nb(e),r=await this.findInode(i,s,"link"),a=Bb(await this.get(i,r.data,s,"link")),o=await this._findInode(i,t,"link"),l=new Ow(await this.get(i,o,t,"link"));l.nlink++,a[kb(e)]=o,i.setSync(o,vw(l)),i.setSync(r.data,Vb(a)),i.commitSync()}catch(t){n.error=t,n.hasError=!0}finally{const t=Cw(n);t&&await t}}linkSync(t,e){const n={stack:[],error:void 0,hasError:!1};try{const i=Mw(n,this.store.transaction(),!1),s=Nb(e),r=this.findInodeSync(i,s,"link"),a=Bb(this.getSync(i,r.data,s,"link")),o=this._findInodeSync(i,t,"link"),l=new Ow(this.getSync(i,o,t,"link"));l.nlink++,a[kb(e)]=o,i.setSync(o,vw(l)),i.setSync(r.data,Vb(a)),i.commitSync()}catch(t){n.error=t,n.hasError=!0}finally{Cw(n)}}async checkRoot(){const t={stack:[],error:void 0,hasError:!1};try{const e=Mw(t,this.store.transaction(),!0);if(await e.get(0n))return;const n=new Ow;n.ino=0n,n.mode=511|bv,await e.set(n.data,Fb("{}")),await e.set(0n,vw(n)),await e.commit()}catch(e){t.error=e,t.hasError=!0}finally{const e=Cw(t);e&&await e}}checkRootSync(){const t={stack:[],error:void 0,hasError:!1};try{const e=Mw(t,this.store.transaction(),!1);if(e.getSync(0n))return;const n=new Ow;n.ino=0n,n.mode=511|bv,e.setSync(n.data,Fb("{}")),e.setSync(0n,vw(n)),e.commitSync()}catch(e){t.error=e,t.hasError=!0}finally{Cw(t)}}async _findInode(t,e,n,i=new Set){if(i.has(e))throw new Rb(Sb.EIO,"Infinite loop detected while finding inode",e);if(i.add(e),"/"==e)return 0n;const{dir:s,base:r}=Db(e),a="/"==s?new Ow(await this.get(t,0n,s,n)):await this.findInode(t,s,n,i),o=Bb(await this.get(t,a.data,s,n));if(!(r in o))throw Rb.With("ENOENT",Mb(s,r),n);return o[r]}_findInodeSync(t,e,n,i=new Set){if(i.has(e))throw new Rb(Sb.EIO,"Infinite loop detected while finding inode",e);if(i.add(e),"/"==e)return 0n;const{dir:s,base:r}=Db(e),a="/"==s?new Ow(this.getSync(t,0n,s,n)):this.findInodeSync(t,s,n,i),o=Bb(this.getSync(t,a.data,s,n));if(!(r in o))throw Rb.With("ENOENT",Mb(s,r),n);return o[r]}async findInode(t,e,n,i=new Set){const s=await this._findInode(t,e,n,i);return new Ow(await this.get(t,s,e,n))}findInodeSync(t,e,n,i=new Set){const s=this._findInodeSync(t,e,n,i);return new Ow(this.getSync(t,s,e,n))}async get(t,e,n,i){const s=await t.get(e);if(!s)throw Rb.With("ENOENT",n,i);return s}getSync(t,e,n,i){const s=t.getSync(e);if(!s)throw Rb.With("ENOENT",n,i);return s}async allocNew(t,e,n){for(let e=0;e<5;e++){const e=Wb();if(!await t.get(e))return e}throw new Rb(Sb.ENOSPC,"No IDs available",e,n)}allocNewSync(t,e,n){for(let e=0;e<5;e++){const e=Wb();if(!t.getSync(e))return e}throw new Rb(Sb.ENOSPC,"No IDs available",e,n)}async commitNew(t,e,n,i,s){const r={stack:[],error:void 0,hasError:!1};try{if("/"==t)throw Rb.With("EEXIST",t,s);const a=Mw(r,this.store.transaction(),!0),{dir:o,base:l}=Db(t),u=await this.findInode(a,o,s),h=Bb(await this.get(a,u.data,o,s));if(h[l])throw Rb.With("EEXIST",t,s);const p=new Ow;return p.ino=await this.allocNew(a,t,s),p.data=await this.allocNew(a,t,s),p.mode=n|e,p.uid=u.mode&Sv?u.uid:zb.uid,p.gid=u.mode&xv?u.gid:zb.gid,p.size=i.length,await a.set(p.ino,vw(p)),await a.set(p.data,i),h[l]=p.ino,await a.set(u.data,Vb(h)),await a.commit(),p}catch(t){r.error=t,r.hasError=!0}finally{const t=Cw(r);t&&await t}}commitNewSync(t,e,n,i,s){const r={stack:[],error:void 0,hasError:!1};try{if("/"==t)throw Rb.With("EEXIST",t,s);const a=Mw(r,this.store.transaction(),!1),{dir:o,base:l}=Db(t),u=this.findInodeSync(a,o,s),h=Bb(this.getSync(a,u.data,o,s));if(h[l])throw Rb.With("EEXIST",t,s);const p=new Ow;return p.ino=this.allocNewSync(a,t,s),p.data=this.allocNewSync(a,t,s),p.size=i.length,p.mode=n|e,p.uid=u.mode&Sv?u.uid:zb.uid,p.gid=u.mode&xv?u.gid:zb.gid,a.setSync(p.ino,vw(p)),a.setSync(p.data,i),h[l]=p.ino,a.setSync(u.data,Vb(h)),a.commitSync(),p}catch(t){r.error=t,r.hasError=!0}finally{Cw(r)}}async remove(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{const s=Mw(i,this.store.transaction(),!0),{dir:r,base:a}=Db(t),o=await this.findInode(s,r,n),l=Bb(await this.get(s,o.data,r,n));if(!l[a])throw Rb.With("ENOENT",t,"remove");const u=l[a],h=new Ow(await this.get(s,u,t,n));if(delete l[a],!e&&h.toStats().isDirectory())throw Rb.With("EISDIR",t,"remove");await s.set(o.data,Vb(l)),--h.nlink<1&&(await s.remove(h.data),await s.remove(u)),await s.commit()}catch(t){i.error=t,i.hasError=!0}finally{const t=Cw(i);t&&await t}}removeSync(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{const s=Mw(i,this.store.transaction(),!1),{dir:r,base:a}=Db(t),o=this.findInodeSync(s,r,n),l=Bb(this.getSync(s,o.data,r,n)),u=l[a];if(!u)throw Rb.With("ENOENT",t,"remove");const h=new Ow(this.getSync(s,u,t,n));if(delete l[a],!e&&h.toStats().isDirectory())throw Rb.With("EISDIR",t,"remove");s.setSync(o.data,Vb(l)),--h.nlink<1&&(s.removeSync(h.data),s.removeSync(u)),s.commitSync()}catch(t){i.error=t,i.hasError=!0}finally{Cw(i)}}}class kw{constructor(t){this.store=t,this.done=!1}async[Symbol.asyncDispose](){this.done||await this.abort()}[Symbol.dispose](){this.done||this.abortSync()}}class Dw extends kw{async keys(){return this.keysSync()}async get(t){return this.getSync(t)}async set(t,e){return this.setSync(t,e)}async remove(t){return this.removeSync(t)}async commit(){return this.commitSync()}async abort(){return this.abortSync()}}class Lw extends Dw{constructor(){super(...arguments),this.originalData=new Map,this.modifiedKeys=new Set}keysSync(){return this.store.keys()}getSync(t){const e=this.store.get(t);return this.stashOldValue(t,e),e}setSync(t,e){return this.markModified(t),this.store.set(t,e)}removeSync(t){this.markModified(t),this.store.delete(t)}commitSync(){this.done=!0}abortSync(){if(this.done){for(const t of this.modifiedKeys){const e=this.originalData.get(t);e?this.store.set(t,e):this.store.delete(t)}this.done=!0}}stashOldValue(t,e){this.originalData.has(t)||this.originalData.set(t,e)}markModified(t){this.modifiedKeys.add(t),this.originalData.has(t)||this.originalData.set(t,this.store.get(t))}}class Fw extends Map{constructor(t="tmp"){super(),this.name=t}async sync(){}clearSync(){this.clear()}transaction(){return new Lw(this)}}const Pw={name:"InMemory",isAvailable:()=>!0,options:{name:{type:"string",required:!1}},create({name:t}){const e=new Nw(new Fw(t));return e.checkRootSync(),e}};"function"==typeof SuppressedError&&SuppressedError;class $w{constructor(){this.isEnabled=!1,this.sync=new Map,this.async=new Map}has(t){return this.isEnabled&&this.sync.has(t)}get(t){if(this.isEnabled)return this.sync.get(t)}set(t,e){this.isEnabled&&(this.sync.set(t,e),this.async.set(t,Promise.resolve(e)))}hasAsync(t){return this.isEnabled&&this.async.has(t)}getAsync(t){if(this.isEnabled)return this.async.get(t)}setAsync(t,e){this.isEnabled&&(this.async.set(t,e),e.then((e=>this.sync.set(t,e))))}clear(){this.isEnabled&&(this.sync.clear(),this.async.clear())}}const Bw=new $w,Vw=new $w;var Uw=__webpack_require__(8287);function Yw(t,e){return Object.fromEntries(Object.entries(t).map((([t,n])=>[t,"function"==typeof n?n.bind(e):n])))}const Gw=new Map;let Hw=100;function Ww(t){const e=Hw++;return Gw.set(e,t),e}function zw(t){if(!Gw.has(t))throw new Rb(Sb.EBADF);return Gw.get(t)}const Xw=new Map;function jw(t,e){if("/"!==t[0]&&(t="/"+t),t=Mb(t),Xw.has(t))throw new Rb(Sb.EINVAL,"Mount point "+t+" is already in use.");Xw.set(t,e),Vw.clear()}function qw(t){if("/"!==t[0]&&(t="/"+t),t=Mb(t),!Xw.has(t))throw new Rb(Sb.EINVAL,"Mount point "+t+" is already unmounted.");Xw.delete(t),Vw.clear()}function Kw(t,e){const n=e?.root||"/";t=Gb(Cb(n,t));const i=[...Xw].sort(((t,e)=>t[0].length>e[0].length?-1:1));for(const[e,s]of i)if(e.length<=t.length&&t.startsWith(e))return""===(t=t.slice(e.length>1?e.length:0))&&(t=n),{fs:s,path:t,mountPoint:e,root:n};throw new Rb(Sb.EIO,"No file system")}async function Qw(){await Promise.all([...Xw.values()].map((t=>t.ready())))}function Jw(t,e){for(const[n,i]of Object.entries(e))t=t?.replaceAll(n,i);return t}function Zw(t,e){"string"==typeof t.stack&&(t.stack=Jw(t.stack,e));try{t.message=Jw(t.message,e)}catch{}return t.path&&(t.path=Jw(t.path,e)),t}function tS(t){"/"in t&&qw("/");for(const[e,n]of Object.entries(t))jw(e,n)}function eS(t,e){const n=t.metadata(),i=n.blockSize||4096;return{type:(e?BigInt:Number)(n.type),bsize:(e?BigInt:Number)(i),ffree:(e?BigInt:Number)(n.freeNodes||Uv),files:(e?BigInt:Number)(n.totalNodes||Uv),bavail:(e?BigInt:Number)(n.freeSpace/i),bfree:(e?BigInt:Number)(n.freeSpace/i),blocks:(e?BigInt:Number)(n.totalSpace/i)}}function nS(t,e){const n=this?.credentials;if(n?.uid&&n?.gid&&n?.euid&&n?.egid)throw new Rb(Sb.EPERM,"Can not chroot() as non-root user");return e&&this?(this.root+=t,this):function(t,e=structuredClone(zb)){const n={root:t,credentials:Xb(e)},i=Yw(st,n),s=Yw(it,n);return{...n,...i,promises:s}}(Cb(this?.root||"/",t),n)}jw("/",Pw.create({name:"root"}));class iS extends aw{off(t,e,n,i){return super.off(t,e,n,i)}removeListener(t,e,n,i){return super.removeListener(t,e,n,i)}constructor(t){super(),this.path=t}setMaxListeners(){throw Rb.With("ENOSYS",this.path,"Watcher.setMaxListeners")}getMaxListeners(){throw Rb.With("ENOSYS",this.path,"Watcher.getMaxListeners")}prependListener(){throw Rb.With("ENOSYS",this.path,"Watcher.prependListener")}prependOnceListener(){throw Rb.With("ENOSYS",this.path,"Watcher.prependOnceListener")}rawListeners(){throw Rb.With("ENOSYS",this.path,"Watcher.rawListeners")}ref(){return this}unref(){return this}}class sS extends iS{constructor(t,e){super(t),this.options=e,function(t,e){const n=Gb(t);aS.has(n)||aS.set(n,new Set);aS.get(n).add(e)}(t.toString(),this)}close(){super.emit("close"),function(t,e){const n=Gb(t);aS.has(n)&&(aS.get(n).delete(e),0===aS.get(n).size&&aS.delete(n))}(this.path.toString(),this)}[Symbol.dispose](){this.close()}}class rS extends iS{constructor(t,e){super(t),this.options=e,this.start()}onInterval(){try{const n=cS(this.path);t=this.previous,e=n,(t.size!=e.size||+t.atime!=+e.atime||+t.mtime!=+e.mtime||+t.ctime!=+e.ctime||t.mode!=e.mode)&&(this.emit("change",n,this.previous),this.previous=n)}catch(t){this.emit("error",t)}var t,e}start(){const t=this.options.interval||5e3;try{this.previous=cS(this.path)}catch(t){return void this.emit("error",t)}this.intervalId=setInterval(this.onInterval.bind(this),t),this.options.persistent||"object"!=typeof this.intervalId||this.intervalId.unref()}stop(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=void 0),this.removeAllListeners()}}const aS=new Map;function oS(t,e){if(e=Gb(e),aS.has(e))for(const n of aS.get(e))n.emit("change",t,kb(e));let n,i=e;for(;i!==n;)if(n=i,i=Nb(i),aS.has(i))for(const n of aS.get(i))n.emit("change",t,e.slice(i.length+("/"==i?0:1)))}var lS=function(t,e,n){if(null!=e){if("object"!=typeof e&&"function"!=typeof e)throw new TypeError("Object expected.");var i,s;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");i=e[Symbol.asyncDispose]}if(void 0===i){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");i=e[Symbol.dispose],n&&(s=i)}if("function"!=typeof i)throw new TypeError("Object not disposable.");s&&(i=function(){try{s.call(this)}catch(t){return Promise.reject(t)}}),t.stack.push({value:e,dispose:i,async:n})}else n&&t.stack.push({async:!0});return e},uS=function(t){return function(e){function n(n){e.error=e.hasError?new t(n,e.error,"An error was suppressed during disposal."):n,e.hasError=!0}return function t(){for(;e.stack.length;){var i=e.stack.pop();try{var s=i.dispose&&i.dispose.call(i.value);if(i.async)return Promise.resolve(s).then(t,(function(e){return n(e),t()}))}catch(t){n(t)}}if(e.hasError)throw e.error}()}}("function"==typeof SuppressedError?SuppressedError:function(t,e,n){var i=new Error(n);return i.name="SuppressedError",i.error=t,i.suppressed=e,i});function hS(t,e){t=Gb(t),e=Gb(e);const n=Kw(t,this),i=Kw(e,this);if(Yv.checkAccess&&!cS.call(this,Nb(t)).hasAccess(Kb,this))throw Rb.With("EACCES",t,"rename");try{if(n===i)return n.fs.renameSync(n.path,i.path),oS("rename",t.toString()),void oS("change",e.toString());ES.call(this,e,IS(t)),mS.call(this,t),oS("rename",t.toString())}catch(s){throw Zw(s,{[n.path]:t,[i.path]:e})}}function pS(t){t=Gb(t);try{const{fs:e,path:n}=Kw(WS.call(this,t),this);return e.existsSync(n)}catch(t){if(t.errno==Sb.ENOENT)return!1;throw t}}function cS(t,e){t=Gb(t);const{fs:n,path:i}=Kw(WS.call(this,t),this);try{const t=n.statSync(i);if(Yv.checkAccess&&!t.hasAccess(qb,this))throw Rb.With("EACCES",i,"stat");return e?.bigint?new zv(t):t}catch(e){throw Zw(e,{[i]:t})}}function dS(t,e){t=Gb(t);const{fs:n,path:i}=Kw(t,this);try{const t=n.statSync(i);return e?.bigint?new zv(t):t}catch(e){throw Zw(e,{[i]:t})}}function fS(t,e=0){const n={stack:[],error:void 0,hasError:!1};try{const i=lS(n,gS.call(this,t,"r+"),!1);if(e||(e=0),e<0)throw new Rb(Sb.EINVAL);i.truncateSync(e)}catch(t){n.error=t,n.hasError=!0}finally{uS(n)}}function mS(t){t=Gb(t);const{fs:e,path:n}=Kw(t,this);try{if(Yv.checkAccess&&!(Bw.get(t)||e.statSync(n)).hasAccess(Kb,this))throw Rb.With("EACCES",n,"unlink");e.unlinkSync(n),oS("rename",t.toString())}catch(e){throw Zw(e,{[n]:t})}}function gS(t,e,n,i=!0){t=Gb(t);const s=Ub(n,420),r=Kv(e);t=i?WS.call(this,t):t;const{fs:a,path:o}=Kw(t,this);let l;try{l=a.statSync(o)}catch{}if(!l){if(!Zv(r)&&!ew(r)||"r+"==r)throw Rb.With("ENOENT",t,"_open");const e=a.statSync(Nb(o));if(Yv.checkAccess&&!e.hasAccess(Kb,this))throw Rb.With("EACCES",Nb(t),"_open");if(!e.isDirectory())throw Rb.With("ENOTDIR",Nb(t),"_open");return a.createFileSync(o,r,s)}if(Yv.checkAccess&&(!l.hasAccess(s,this)||!l.hasAccess(Qv(r),this)))throw Rb.With("EACCES",t,"_open");if(nw(r))throw Rb.With("EEXIST",t,"_open");const u=a.openFileSync(o,r);return tw(r)&&u.truncateSync(0),u}function _S(t,e,n=jb){return Ww(gS.call(this,t,e,n,!0))}function TS(t,e,n){return Ww(gS.call(this,t,e,n,!1))}function yS(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{const s=lS(i,gS.call(this,t,e,420,n),!1),r=s.statSync(),a=new Uint8Array(r.size);return s.readSync(a,0,r.size,0),a}catch(t){i.error=t,i.hasError=!0}finally{uS(i)}}function IS(t,e={}){const n=Hb(e,null,"r",420);if(!Jv(Kv(n.flag)))throw new Rb(Sb.EINVAL,"Flag passed to readFile must allow for reading.");const i=Uw.Buffer.from(yS.call(this,"number"==typeof t?zw(t).path:t.toString(),n.flag,!0));return n.encoding?i.toString(n.encoding):i}function ES(t,e,n={}){const i={stack:[],error:void 0,hasError:!1};try{const s=Hb(n,"utf8","w+",420),r=Kv(s.flag);if(!Zv(r))throw new Rb(Sb.EINVAL,"Flag passed to writeFile must allow for writing.");if("string"!=typeof e&&!s.encoding)throw new Rb(Sb.EINVAL,"Encoding not specified");const a="string"==typeof e?Uw.Buffer.from(e,s.encoding):new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(!a)throw new Rb(Sb.EINVAL,"Data not specified");lS(i,gS.call(this,"number"==typeof t?zw(t).path:t.toString(),r,s.mode,!0),!1).writeSync(a,0,a.byteLength,0),oS("change",t.toString())}catch(t){i.error=t,i.hasError=!0}finally{uS(i)}}function bS(t,e,n={}){const i={stack:[],error:void 0,hasError:!1};try{const s=Hb(n,"utf8","a+",420),r=Kv(s.flag);if(!ew(r))throw new Rb(Sb.EINVAL,"Flag passed to appendFile must allow for appending.");if("string"!=typeof e&&!s.encoding)throw new Rb(Sb.EINVAL,"Encoding not specified");const a="string"==typeof e?Uw.Buffer.from(e,s.encoding):new Uint8Array(e.buffer,e.byteOffset,e.byteLength);lS(i,gS.call(this,"number"==typeof t?zw(t).path:t.toString(),r,s.mode,!0),!1).writeSync(a,0,a.byteLength)}catch(t){i.error=t,i.hasError=!0}finally{uS(i)}}function vS(t,e){const n=zw(t).statSync();return e?.bigint?new zv(n):n}function wS(t){zw(t).closeSync(),Gw.delete(t)}function SS(t,e=0){if(e||(e=0),e<0)throw new Rb(Sb.EINVAL);zw(t).truncateSync(e)}function xS(t){zw(t).syncSync()}function RS(t){zw(t).datasyncSync()}function AS(t,e,n,i,s){let r,a,o,l;if("string"==typeof e){l="number"==typeof n?n:null;const t="string"==typeof i?i:"utf8";a=0,r=Uw.Buffer.from(e,t),o=r.byteLength}else r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),a=n,o=i,l="number"==typeof s?s:null;const u=zw(t);l??(l=u.position);const h=u.writeSync(r,a,o,l);return oS("change",u.path),h}function OS(t,e,n,i,s){const r=zw(t),a="object"==typeof n?n.offset:n;return"object"==typeof n&&(i=n.length,s=n.position),s=Number(s),isNaN(s)&&(s=r.position),r.readSync(e,a,i,s)}function MS(t,e,n){zw(t).chownSync(e,n)}function CS(t,e){const n=Ub(e,-1);if(n<0)throw new Rb(Sb.EINVAL,"Invalid mode.");zw(t).chmodSync(n)}function NS(t,e,n){zw(t).utimesSync(Yb(e),Yb(n))}function kS(t){t=Gb(t);const{fs:e,path:n}=Kw(WS.call(this,t),this);try{const i=Bw.get(t)||e.statSync(n);if(!i.isDirectory())throw Rb.With("ENOTDIR",n,"rmdir");if(Yv.checkAccess&&!i.hasAccess(Kb,this))throw Rb.With("EACCES",n,"rmdir");e.rmdirSync(n),oS("rename",t.toString())}catch(e){throw Zw(e,{[n]:t})}}function DS(t,e){e="object"==typeof e?e:{mode:e};const n=Ub(e?.mode,511);t=WS.call(this,t);const{fs:i,path:s,root:r}=Kw(t,this),a={[s]:t};try{if(!e?.recursive){if(Yv.checkAccess&&!i.statSync(Nb(s)).hasAccess(Kb,this))throw Rb.With("EACCES",Nb(s),"mkdir");return i.mkdirSync(s,n)}const o=[];for(let e=s,n=t;!i.existsSync(e);e=Nb(e),n=Nb(n))o.unshift(e),a[e]=n;for(const t of o){if(Yv.checkAccess&&!i.statSync(Nb(t)).hasAccess(Kb,this))throw Rb.With("EACCES",Nb(t),"mkdir");i.mkdirSync(t,n),oS("rename",t)}return 1==r.length?o[0]:o[0]?.slice(r.length)}catch(t){throw Zw(t,a)}}function LS(t,e){e="object"==typeof e?e:{encoding:e},t=Gb(t);const{fs:n,path:i}=Kw(WS.call(this,t),this);let s;try{const e=Bw.get(t)||n.statSync(i);if(Bw.set(t,e),Yv.checkAccess&&!e.hasAccess(qb,this))throw Rb.With("EACCES",i,"readdir");if(!e.isDirectory())throw Rb.With("ENOTDIR",i,"readdir");s=n.readdirSync(i)}catch(e){throw Zw(e,{[i]:t})}const r=[];for(const a of s){const s=Bw.get(Cb(t,a))||n.statSync(Cb(i,a));if(Bw.set(Cb(t,a),s),e?.withFileTypes?r.push(new ex(a,s)):"buffer"==e?.encoding?r.push(Uw.Buffer.from(a)):r.push(a),s.isDirectory()&&e?.recursive)for(const n of LS.call(this,Cb(t,a),{...e,_isIndirect:!0}))n instanceof ex?(n.path=Cb(a,n.path),r.push(n)):Uw.Buffer.isBuffer(n)?r.push(Uw.Buffer.from(Cb(a,$b(n)))):r.push(Cb(a,n))}return e?._isIndirect||Bw.clear(),r}function FS(t,e){if(t=Gb(t),Yv.checkAccess&&!cS(Nb(t)).hasAccess(qb,this))throw Rb.With("EACCES",Nb(t),"link");if(e=Gb(e),Yv.checkAccess&&!cS(Nb(e)).hasAccess(Kb,this))throw Rb.With("EACCES",Nb(e),"link");const{fs:n,path:i}=Kw(t,this),s=Kw(e,this);if(n!=s.fs)throw Rb.With("EXDEV",e,"link");try{if(Yv.checkAccess&&!n.statSync(i).hasAccess(qb,this))throw Rb.With("EACCES",i,"link");return n.linkSync(i,e)}catch(n){throw Zw(n,{[i]:t,[s.path]:e})}}function PS(t,e,n="file"){if(!["file","dir","junction"].includes(n))throw new Rb(Sb.EINVAL,"Invalid type: "+n);if(pS.call(this,e))throw Rb.With("EEXIST",e.toString(),"symlink");ES.call(this,e,t.toString());gS.call(this,e,"r+",420,!1).chmodSync(yv)}function $S(t,e){const n=Uw.Buffer.from(yS.call(this,t.toString(),"r",!1)),i="object"==typeof e?e?.encoding:e;return"buffer"==i?n:n.toString(i)}function BS(t,e,n){const i=_S.call(this,t,"r+");MS(i,e,n),wS(i)}function VS(t,e,n){const i=TS.call(this,t,"r+");MS(i,e,n),wS(i)}function US(t,e){const n=_S.call(this,t,"r+");CS(n,e),wS(n)}function YS(t,e){const n=TS.call(this,t,"r+");CS(n,e),wS(n)}function GS(t,e,n){const i=_S.call(this,t,"r+");NS(i,e,n),wS(i)}function HS(t,e,n){const i=TS.call(this,t,"r+");NS(i,e,n),wS(i)}function WS(t,e){t=Gb(t);const n=(this?.root||"")+t;if(Vw.has(n))return Vw.get(n);const{base:i,dir:s}=Db(t),r="/"==s?"/":Vw.get((this?.root||"")+s)||WS.call(this,s),a=Cb(r,i),{fs:o,path:l}=Kw(a,this);try{const i=Bw.get(a)||o.statSync(l);if(Bw.set(a,i),!i.isSymbolicLink())return Vw.set(t,a),a;const s=Mb(r,$S.call(this,a,e).toString()),u=Vw.get((this?.root||"")+s)||WS.call(this,s);return Vw.set(n,u),u}catch(e){if("ENOENT"==e.code)return t;throw Zw(e,{[l]:a})}}function zS(t,e=384){if(Yv.checkAccess&&!cS.call(this,t).hasAccess(e,this))throw new Rb(Sb.EACCES)}function XS(t,e){let n;t=Gb(t);try{n=Bw.get(t)||dS.bind(this)(t)}catch(t){if("ENOENT"!=t.code||!e?.force)throw t}if(n){switch(Bw.set(t,n),n.mode&_v){case bv:if(e?.recursive)for(const n of LS.call(this,t,{_isIndirect:!0}))XS.call(this,Cb(t,n),{...e,_isIndirect:!0});kS.call(this,t);break;case Iv:case yv:case Ev:case vv:mS.call(this,t);break;default:throw Bw.clear(),new Rb(Sb.EPERM,"File type not supported",t,"rm")}e?._isIndirect||Bw.clear()}}function jS(t,e){const n="object"==typeof e?e?.encoding:e||"utf8",i="/tmp/"+`${t}${Date.now()}-${Math.random().toString(36).slice(2)}`;return DS.call(this,i),"buffer"==n?Uw.Buffer.from(i):i}function qS(t,e,n){if(t=Gb(t),e=Gb(e),n&&n&Jb&&pS(e))throw new Rb(Sb.EEXIST,"Destination file already exists.",e,"copyFile");ES.call(this,e,IS(t)),oS("rename",e.toString())}function KS(t,e,n){const i=zw(t);let s=0;for(const t of e)s+=i.readSync(t,0,t.byteLength,n+s);return s}function QS(t,e,n){const i=zw(t);let s=0;for(const t of e)s+=i.writeSync(new Uint8Array(t.buffer),0,t.byteLength,n+s);return s}function JS(t,e){return t=Gb(t),new nx(t,this)}function ZS(t,e,n){t=Gb(t),e=Gb(e);const i=dS.call(this,t);if(n?.errorOnExist&&pS.call(this,e))throw new Rb(Sb.EEXIST,"Destination file or directory already exists.",e,"cp");switch(i.mode&_v){case bv:if(!n?.recursive)throw new Rb(Sb.EISDIR,t+" is a directory (not copied)",t,"cp");DS.call(this,e,{recursive:!0});for(const i of LS.call(this,t,{withFileTypes:!0}))n.filter&&!n.filter(Cb(t,i.name),Cb(e,i.name))||ZS.call(this,Cb(t,i.name),Cb(e,i.name),n);break;case Iv:case yv:qS.call(this,t,e);break;default:throw new Rb(Sb.EPERM,"File type not supported",t,"rm")}n?.preserveTimestamps&&GS.call(this,e,i.atime,i.mtime)}function tx(t,e){t=Gb(t);const{fs:n}=Kw(t,this);return eS(n,e?.bigint)}class ex{get name(){return kb(this.path)}constructor(t,e){this.path=t,this.stats=e}get parentPath(){return this.path}isFile(){return this.stats.isFile()}isDirectory(){return this.stats.isDirectory()}isBlockDevice(){return this.stats.isBlockDevice()}isCharacterDevice(){return this.stats.isCharacterDevice()}isSymbolicLink(){return this.stats.isSymbolicLink()}isFIFO(){return this.stats.isFIFO()}isSocket(){return this.stats.isSocket()}}class nx{checkClosed(){if(this.closed)throw new Rb(Sb.EBADF,"Can not use closed Dir")}constructor(t,e){this.path=t,this.context=e,this.closed=!1}close(t){if(this.closed=!0,!t)return Promise.resolve();t()}closeSync(){this.closed=!0}async _read(){return this.checkClosed(),this._entries??(this._entries=await bx.call(this.context,this.path,{withFileTypes:!0})),this._entries.length?this._entries.shift()??null:null}read(t){if(!t)return this._read();this._read().then((e=>t(void 0,e)))}readSync(){return this.checkClosed(),this._entries??(this._entries=LS.call(this.context,this.path,{withFileTypes:!0})),this._entries.length?this._entries.shift()??null:null}async next(){const t=await this._read();return t?{done:!1,value:t}:(await this.close(),{done:!0,value:void 0})}[Symbol.asyncIterator](){return this}}var ix=__webpack_require__(6248);class sx extends ix.Readable{close(t=()=>null){try{super.destroy(),super.emit("close"),t()}catch(e){t(new Rb(Sb.EIO,e.toString()))}}}class rx extends ix.Writable{close(t=()=>null){try{super.destroy(),super.emit("close"),t()}catch(e){t(new Rb(Sb.EIO,e.toString()))}}}var ax=function(t,e,n){if(null!=e){if("object"!=typeof e&&"function"!=typeof e)throw new TypeError("Object expected.");var i,s;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");i=e[Symbol.asyncDispose]}if(void 0===i){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");i=e[Symbol.dispose],n&&(s=i)}if("function"!=typeof i)throw new TypeError("Object not disposable.");s&&(i=function(){try{s.call(this)}catch(t){return Promise.reject(t)}}),t.stack.push({value:e,dispose:i,async:n})}else n&&t.stack.push({async:!0});return e},ox=function(t){return function(e){function n(n){e.error=e.hasError?new t(n,e.error,"An error was suppressed during disposal."):n,e.hasError=!0}return function t(){for(;e.stack.length;){var i=e.stack.pop();try{var s=i.dispose&&i.dispose.call(i.value);if(i.async)return Promise.resolve(s).then(t,(function(e){return n(e),t()}))}catch(t){n(t)}}if(e.hasError)throw e.error}()}}("function"==typeof SuppressedError?SuppressedError:function(t,e,n){var i=new Error(n);return i.name="SuppressedError",i.error=t,i.suppressed=e,i});class lx{constructor(t,e){this.context=e;const n="number"!=typeof t;this.fd=n?Ww(t):t,this.file=n?t:zw(t)}async chown(t,e){await this.file.chown(t,e),oS("change",this.file.path)}async chmod(t){const e=Ub(t,-1);if(e<0)throw new Rb(Sb.EINVAL,"Invalid mode.");await this.file.chmod(e),oS("change",this.file.path)}datasync(){return this.file.datasync()}sync(){return this.file.sync()}async truncate(t){if(t||(t=0),t<0)throw new Rb(Sb.EINVAL);await this.file.truncate(t),oS("change",this.file.path)}async utimes(t,e){await this.file.utimes(Yb(t),Yb(e)),oS("change",this.file.path)}async appendFile(t,e={}){const n=Hb(e,"utf8","a",420);if(!ew(Kv(n.flag)))throw new Rb(Sb.EINVAL,"Flag passed to appendFile must allow for appending.");if("string"!=typeof t&&!n.encoding)throw new Rb(Sb.EINVAL,"Encoding not specified");const i="string"==typeof t?Uw.Buffer.from(t,n.encoding):t;await this.file.write(i,0,i.length),oS("change",this.file.path)}read(t,e,n,i){return isNaN(+i)&&(i=this.file.position),this.file.read(t,e,n,i)}async readFile(t){const e=Hb(t,null,"r",292);if(!Jv(Kv(e.flag)))throw new Rb(Sb.EINVAL,"Flag passed must allow for reading.");const{size:n}=await this.stat(),{buffer:i}=await this.file.read(new Uint8Array(n),0,n,0),s=Uw.Buffer.from(i);return e.encoding?s.toString(e.encoding):s}readableWebStream(t={}){const e=globalThis;if(!("ReadableStream"in e))throw new Rb(Sb.ENOSYS,"ReadableStream is missing on globalThis");return new e.ReadableStream({start:async t=>{try{const e=65536,n=1e7;let i=0,s=0,r=NaN;for(;r>0;){const a=await this.read(new Uint8Array(e),0,e,s);if(!a.bytesRead)return void t.close();if(t.enqueue(a.buffer.slice(0,a.bytesRead)),s+=a.bytesRead,++i>=n)throw new Rb(Sb.EFBIG,"Too many iterations on readable stream",this.file.path,"FileHandle.readableWebStream");r=a.bytesRead}}catch(e){t.error(e)}},type:t.type})}readLines(t){throw Rb.With("ENOSYS",this.file.path,"FileHandle.readLines")}[Symbol.asyncDispose](){return this.close()}async stat(t){const e=await this.file.stat();if(Yv.checkAccess&&!e.hasAccess(qb,this.context))throw Rb.With("EACCES",this.file.path,"stat");return t?.bigint?new zv(e):e}async write(t,e,n,i){let s,r,a;if("string"==typeof t){i="number"==typeof e?e:null;const o="string"==typeof n?n:"utf8";r=0,s=Uw.Buffer.from(t,o),a=s.length}else s=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),r=e,a=n,i="number"==typeof i?i:null;i??(i=this.file.position);const o=await this.file.write(s,r,a,i);return oS("change",this.file.path),{buffer:s,bytesWritten:o}}async writeFile(t,e={}){const n=Hb(e,"utf8","w",420);if(!Zv(Kv(n.flag)))throw new Rb(Sb.EINVAL,"Flag passed must allow for writing.");if("string"!=typeof t&&!n.encoding)throw new Rb(Sb.EINVAL,"Encoding not specified");const i="string"==typeof t?Uw.Buffer.from(t,n.encoding):t;await this.file.write(i,0,i.length,0),oS("change",this.file.path)}async close(){await this.file.close(),Gw.delete(this.fd)}async writev(t,e){let n=0;for(const i of t)n+=(await this.write(i,0,i.length,e+n)).bytesWritten;return{bytesWritten:n,buffers:t}}async readv(t,e){let n=0;for(const i of t)n+=(await this.read(i,0,i.byteLength,e+n)).bytesRead;return{bytesRead:n,buffers:t}}createReadStream(t){const e=new sx({highWaterMark:t?.highWaterMark||65536,encoding:t.encoding,read:async t=>{try{const n=await this.read(new Uint8Array(t),0,t,this.file.position);e.push(n.bytesRead?n.buffer.slice(0,n.bytesRead):null),this.file.position+=n.bytesRead}catch(t){e.destroy(t)}}});return e.path=this.file.path,e}createWriteStream(t){const e=new rx({highWaterMark:t?.highWaterMark,encoding:t?.encoding,write:async(t,e,n)=>{try{const{bytesWritten:i}=await this.write(t,null,e);n(i==t.length?null:new Error("Failed to write full chunk"))}catch(t){n(t)}}});return e.path=this.file.path,e}}async function ux(t,e){t=Gb(t),e=Gb(e);const n=Kw(t,this),i=Kw(e,this);if(Yv.checkAccess&&!(await px.call(this,Nb(t))).hasAccess(Kb,this))throw Rb.With("EACCES",t,"rename");try{if(n.mountPoint==i.mountPoint)return await n.fs.rename(n.path,i.path),oS("rename",t.toString()),void oS("change",e.toString());await Tx.call(this,e,await _x(t)),await fx.call(this,t),oS("rename",t.toString())}catch(s){throw Zw(s,{[n.path]:t,[i.path]:e})}}async function hx(t){try{const{fs:e,path:n}=Kw(await Nx.call(this,t),this);return await e.exists(n)}catch(t){if(t instanceof Rb&&"ENOENT"==t.code)return!1;throw t}}async function px(t,e){t=Gb(t);const{fs:n,path:i}=Kw(await Nx.call(this,t),this);try{const t=await n.stat(i);if(Yv.checkAccess&&!t.hasAccess(qb,this))throw Rb.With("EACCES",i,"stat");return e?.bigint?new zv(t):t}catch(e){throw Zw(e,{[i]:t})}}async function cx(t,e){t=Gb(t);const{fs:n,path:i}=Kw(t,this);try{const t=await n.stat(i);return e?.bigint?new zv(t):t}catch(e){throw Zw(e,{[i]:t})}}async function dx(t,e=0){const n={stack:[],error:void 0,hasError:!1};try{const i=ax(n,await gx.call(this,t,"r+"),!0);await i.truncate(e)}catch(t){n.error=t,n.hasError=!0}finally{const t=ox(n);t&&await t}}async function fx(t){t=Gb(t);const{fs:e,path:n}=Kw(t,this);try{if(Yv.checkAccess&&!(await(Bw.getAsync(t)||e.stat(n))).hasAccess(Kb,this))throw Rb.With("EACCES",n,"unlink");await e.unlink(n),oS("rename",t.toString())}catch(e){throw Zw(e,{[n]:t})}}async function mx(t,e,n=420,i){t=Gb(t);const s=Ub(n,420),r=Kv(e);t=i?await Nx.call(this,t):t;const{fs:a,path:o}=Kw(t,this),l=await a.stat(o).catch((()=>null));if(!l){if(!Zv(r)&&!ew(r)||"r+"==r)throw Rb.With("ENOENT",t,"_open");const e=await a.stat(Nb(o));if(Yv.checkAccess&&!e.hasAccess(Kb,this))throw Rb.With("EACCES",Nb(t),"_open");if(!e.isDirectory())throw Rb.With("ENOTDIR",Nb(t),"_open");return new lx(await a.createFile(o,r,s),this)}if(Yv.checkAccess&&!l.hasAccess(Qv(r),this))throw Rb.With("EACCES",t,"_open");if(nw(r))throw Rb.With("EEXIST",t,"_open");const u=new lx(await a.openFile(o,r),this);return tw(r)&&await u.truncate(0),u}async function gx(t,e="r",n=420){return await mx.call(this,t,e,n,!0)}async function _x(t,e){const n={stack:[],error:void 0,hasError:!1};try{const i=Hb(e,null,"r",420),s=ax(n,"object"==typeof t&&"fd"in t?t:await gx.call(this,t,i.flag,i.mode),!0);return await s.readFile(i)}catch(t){n.error=t,n.hasError=!0}finally{const t=ox(n);t&&await t}}async function Tx(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{const s=Hb(n,"utf8","w+",420),r=ax(i,t instanceof lx?t:await gx.call(this,t.toString(),s.flag,s.mode),!0),a=e;if("string"!=typeof a&&!(a instanceof Uint8Array))throw new Rb(Sb.EINVAL,"Iterables and streams not supported",r.file.path,"writeFile");await r.writeFile(a,s)}catch(t){i.error=t,i.hasError=!0}finally{const t=ox(i);t&&await t}}async function yx(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{const s=Hb(n,"utf8","a",420);if(!ew(Kv(s.flag)))throw new Rb(Sb.EINVAL,"Flag passed to appendFile must allow for appending.");if("string"!=typeof e&&!s.encoding)throw new Rb(Sb.EINVAL,"Encoding not specified");const r="string"==typeof e?Uw.Buffer.from(e,s.encoding):new Uint8Array(e.buffer,e.byteOffset,e.byteLength),a=ax(i,"object"==typeof t&&"fd"in t?t:await gx.call(this,t,s.flag,s.mode),!0);await a.appendFile(r,s)}catch(t){i.error=t,i.hasError=!0}finally{const t=ox(i);t&&await t}}async function Ix(t){t=await Nx.call(this,t);const{fs:e,path:n}=Kw(t,this);try{const i=await(Bw.getAsync(t)||e.stat(n));if(!i)throw Rb.With("ENOENT",t,"rmdir");if(!i.isDirectory())throw Rb.With("ENOTDIR",n,"rmdir");if(Yv.checkAccess&&!i.hasAccess(Kb,this))throw Rb.With("EACCES",n,"rmdir");await e.rmdir(n),oS("rename",t.toString())}catch(e){throw Zw(e,{[n]:t})}}async function Ex(t,e){e="object"==typeof e?e:{mode:e};const n=Ub(e?.mode,511);t=await Nx.call(this,t);const{fs:i,path:s,root:r}=Kw(t,this),a={[s]:t};try{if(!e?.recursive){if(Yv.checkAccess&&!(await i.stat(Nb(s))).hasAccess(Kb,this))throw Rb.With("EACCES",Nb(s),"mkdir");return await i.mkdir(s,n),void oS("rename",t.toString())}const o=[];for(let e=s,n=t;!await i.exists(e);e=Nb(e),n=Nb(n))o.unshift(e),a[e]=n;for(const t of o){if(Yv.checkAccess&&!(await i.stat(Nb(t))).hasAccess(Kb,this))throw Rb.With("EACCES",Nb(t),"mkdir");await i.mkdir(t,n),oS("rename",t)}return 1==r.length?o[0]:o[0]?.slice(r.length)}catch(t){throw Zw(t,a)}}async function bx(t,e){e="object"==typeof e?e:{encoding:e},t=await Nx.call(this,t);const n=e=>{throw Zw(e,{[s]:t})},{fs:i,path:s}=Kw(t,this),r=Bw.getAsync(t)||i.stat(s).catch(n);Bw.setAsync(t,r);const a=await r;if(!a)throw Rb.With("ENOENT",t,"readdir");if(Yv.checkAccess&&!a.hasAccess(qb,this))throw Rb.With("EACCES",t,"readdir");if(!a.isDirectory())throw Rb.With("ENOTDIR",t,"readdir");const o=await i.readdir(s).catch(n),l=[];return await Promise.all(o.map((async r=>{let a;if(e?.recursive||e?.withFileTypes){const e=Bw.getAsync(Cb(t,r))||i.stat(Cb(s,r)).catch(n);Bw.setAsync(Cb(t,r),e),a=await e}if(e?.withFileTypes?l.push(new ex(r,a)):"buffer"==e?.encoding?l.push(Uw.Buffer.from(r)):l.push(r),e?.recursive&&a?.isDirectory())for(const n of await bx.call(this,Cb(t,r),{...e,_isIndirect:!0}))n instanceof ex?(n.path=Cb(r,n.path),l.push(n)):Uw.Buffer.isBuffer(n)?l.push(Uw.Buffer.from(Cb(r,$b(n)))):l.push(Cb(r,n))}))),e?._isIndirect||Bw.clear(),l}async function vx(t,e){t=Gb(t),e=Gb(e);const{fs:n,path:i}=Kw(t,this),s=Kw(e,this);if(n!=s.fs)throw Rb.With("EXDEV",e,"link");try{if(Yv.checkAccess&&!(await n.stat(Nb(t))).hasAccess(qb,this))throw Rb.With("EACCES",Nb(i),"link");if(Yv.checkAccess&&!(await px.call(this,Nb(e))).hasAccess(Kb,this))throw Rb.With("EACCES",Nb(e),"link");if(Yv.checkAccess&&!(await n.stat(i)).hasAccess(qb,this))throw Rb.With("EACCES",i,"link");return await n.link(i,s.path)}catch(n){throw Zw(n,{[s.path]:e,[i]:t})}}async function wx(t,e,n="file"){const i={stack:[],error:void 0,hasError:!1};try{if(!["file","dir","junction"].includes(n))throw new Rb(Sb.EINVAL,"Invalid symlink type: "+n);if(await hx.call(this,e))throw Rb.With("EEXIST",e.toString(),"symlink");const s=ax(i,await mx.call(this,e,"w+",420,!1),!0);await s.writeFile(t.toString()),await s.file.chmod(yv)}catch(t){i.error=t,i.hasError=!0}finally{const t=ox(i);t&&await t}}async function Sx(t,e){const n={stack:[],error:void 0,hasError:!1};try{const i=ax(n,await mx.call(this,Gb(t),"r",420,!1),!0),s=await i.readFile(),r="object"==typeof e?e?.encoding:e;return"buffer"==r?s:s.toString(r)}catch(t){n.error=t,n.hasError=!0}finally{const t=ox(n);t&&await t}}async function xx(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{const s=ax(i,await gx.call(this,t,"r+"),!0);await s.chown(e,n)}catch(t){i.error=t,i.hasError=!0}finally{const t=ox(i);t&&await t}}async function Rx(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{const s=ax(i,await mx.call(this,t,"r+",420,!1),!0);await s.chown(e,n)}catch(t){i.error=t,i.hasError=!0}finally{const t=ox(i);t&&await t}}async function Ax(t,e){const n={stack:[],error:void 0,hasError:!1};try{const i=ax(n,await gx.call(this,t,"r+"),!0);await i.chmod(e)}catch(t){n.error=t,n.hasError=!0}finally{const t=ox(n);t&&await t}}async function Ox(t,e){const n={stack:[],error:void 0,hasError:!1};try{const i=ax(n,await mx.call(this,t,"r+",420,!1),!0);await i.chmod(e)}catch(t){n.error=t,n.hasError=!0}finally{const t=ox(n);t&&await t}}async function Mx(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{const s=ax(i,await gx.call(this,t,"r+"),!0);await s.utimes(e,n)}catch(t){i.error=t,i.hasError=!0}finally{const t=ox(i);t&&await t}}async function Cx(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{const s=ax(i,await mx.call(this,t,"r+",420,!1),!0);await s.utimes(new Date(e),new Date(n))}catch(t){i.error=t,i.hasError=!0}finally{const t=ox(i);t&&await t}}async function Nx(t,e){t=Gb(t);const n=(this?.root||"")+t;if(Vw.hasAsync(n))return Vw.getAsync(n);const{base:i,dir:s}=Db(t),r="/"==s?"/":await(Vw.getAsync((this?.root||"")+s)||Nx.call(this,s)),a=Cb(r,i),{fs:o,path:l}=Kw(a,this);try{const e=Bw.getAsync(a)||o.stat(l);if(Bw.setAsync(a,e),!(await e).isSymbolicLink())return Vw.set(t,a),a;const i=Mb(r,(await Sx.call(this,a)).toString()),s=Vw.getAsync((this?.root||"")+i)||Nx.call(this,i);return Vw.setAsync(n,s),await s}catch(e){if("ENOENT"==e.code)return t;throw Zw(e,{[l]:a})}}function kx(t,e={}){return{[Symbol.asyncIterator](){const n=new sS(t.toString(),"string"!=typeof e?e:{encoding:e}),i=[];function s(){n.close();for(const t of i)t({value:null,done:!0});return i.length=0,Promise.resolve({value:null,done:!0})}return n.on("change",((t,e)=>{i.shift()?.({value:{eventType:t,filename:e},done:!1})})),{async next(){const{promise:t,resolve:e}=Promise.withResolvers();return i.push(e),t},return:s,throw:s}}}}async function Dx(t,e=jb){if(!Yv.checkAccess)return;if(!(await px.call(this,t)).hasAccess(e,this))throw new Rb(Sb.EACCES)}async function Lx(t,e){t=Gb(t);const n=await(Bw.getAsync(t)||cx.call(this,t).catch((t=>{if("ENOENT"!=t.code||!e?.force)throw t})));if(n){switch(Bw.set(t,n),n.mode&_v){case bv:if(e?.recursive)for(const n of await bx.call(this,t,{_isIndirect:!0}))await Lx.call(this,Cb(t,n),{...e,_isIndirect:!0});await Ix.call(this,t);break;case Iv:case yv:case Ev:case vv:await fx.call(this,t);break;default:throw Bw.clear(),new Rb(Sb.EPERM,"File type not supported",t,"rm")}e?._isIndirect||Bw.clear()}}async function Fx(t,e){const n="object"==typeof e?e?.encoding:e||"utf8",i="/tmp/"+`${t}${Date.now()}-${Math.random().toString(36).slice(2)}`;return await Ex.call(this,i),"buffer"==n?Uw.Buffer.from(i):i}async function Px(t,e,n){if(t=Gb(t),e=Gb(e),n&&n&Jb&&await hx.call(this,e))throw new Rb(Sb.EEXIST,"Destination file already exists.",e,"copyFile");await Tx.call(this,e,await _x.call(this,t)),oS("rename",e.toString())}function $x(t,e){return t=Gb(t),Promise.resolve(new nx(t,this))}async function Bx(t,e,n){t=Gb(t),e=Gb(e);const i=await cx.call(this,t);if(n?.errorOnExist&&await hx.call(this,e))throw new Rb(Sb.EEXIST,"Destination file or directory already exists.",e,"cp");switch(i.mode&_v){case bv:{if(!n?.recursive)throw new Rb(Sb.EISDIR,t+" is a directory (not copied)",t,"cp");const[i]=await Promise.all([bx.call(this,t,{withFileTypes:!0}),Ex.call(this,e,{recursive:!0})]),s=async i=>{n.filter&&!n.filter(Cb(t,i.name),Cb(e,i.name))||await Bx.call(this,Cb(t,i.name),Cb(e,i.name),n)};await Promise.all(i.map(s));break}case Iv:case yv:await Px.call(this,t,e);break;default:throw new Rb(Sb.EPERM,"File type not supported",t,"rm")}n?.preserveTimestamps&&await Mx.call(this,e,i.atime,i.mtime)}async function Vx(t,e){t=Gb(t);const{fs:n}=Kw(t,this);return Promise.resolve(eS(n,e?.bigint))}const Ux=()=>{};function Yx(t,e,n=Ux){ux.call(this,t,e).then((()=>n())).catch(n)}function Gx(t,e=Ux){hx.call(this,t).then(e).catch((()=>e(!1)))}function Hx(t,e,n=Ux){n="function"==typeof e?e:n,px.call(this,t,"function"!=typeof e?e:{}).then((t=>n(void 0,t))).catch(n)}function Wx(t,e,n=Ux){n="function"==typeof e?e:n,cx.call(this,t,"function"!=typeof e?e:{}).then((t=>n(void 0,t))).catch(n)}function zx(t,e=0,n=Ux){n="function"==typeof e?e:n;const i="number"==typeof e?e:0;dx.call(this,t,i).then((()=>n())).catch(n)}function Xx(t,e=Ux){fx.call(this,t).then((()=>e())).catch(e)}function jx(t,e,n,i=Ux){const s=Ub(n,420);i="function"==typeof n?n:i,gx.call(this,t,e,s).then((t=>i(void 0,t.fd))).catch(i)}function qx(t,e,n=Ux){n="function"==typeof e?e:n,_x.call(this,t,"function"==typeof e?null:e).then((t=>n(void 0,t))).catch(n)}function Kx(t,e,n,i=Ux){i="function"==typeof n?n:i,Tx.call(this,t,e,"function"!=typeof n?n:null).then((()=>i(void 0))).catch(i)}function Qx(t,e,n,i=Ux){const s="function"!=typeof n?n:void 0;i="function"==typeof n?n:i,yx.call(this,t,e,s).then((()=>i())).catch(i)}function Jx(t,e,n=Ux){n="function"==typeof e?e:n,zw(t).stat().then((t=>n(void 0,"object"==typeof e&&e?.bigint?new zv(t):t))).catch(n)}function Zx(t,e=Ux){const n=zw(t).close();Gw.delete(t),n.then((()=>e())).catch(e)}function tR(t,e,n=Ux){const i="number"==typeof e?e:0;n="function"==typeof e?e:n;const s=zw(t);if(i<0)throw new Rb(Sb.EINVAL);s.truncate(i).then((()=>n())).catch(n)}function eR(t,e=Ux){zw(t).sync().then((()=>e())).catch(e)}function nR(t,e=Ux){zw(t).datasync().then((()=>e())).catch(e)}function iR(t,e,n,i,s,r=Ux){let a,o,l,u,h;const p=new lx(t,this);if("string"==typeof e){switch(h="utf8",typeof n){case"function":r=n;break;case"number":u=n,h="string"==typeof i?i:"utf8",r="function"==typeof s?s:r;break;default:return void(r="function"==typeof i?i:"function"==typeof s?s:r)(new Rb(Sb.EINVAL,"Invalid arguments."))}a=Uw.Buffer.from(e),o=0,l=a.length;const t=r;p.write(a,o,l,u).then((({bytesWritten:e})=>t(void 0,e,a.toString(h)))).catch(t)}else{a=Uw.Buffer.from(e.buffer),o=n,l=i,u="number"==typeof s?s:null;const t="function"==typeof s?s:r;p.write(a,o,l,u).then((({bytesWritten:e})=>t(void 0,e,a))).catch(t)}}function sR(t,e,n,i,s,r=Ux){new lx(t,this).read(e,n,i,s).then((({bytesRead:t,buffer:e})=>r(void 0,t,e))).catch(r)}function rR(t,e,n,i=Ux){new lx(t,this).chown(e,n).then((()=>i())).catch(i)}function aR(t,e,n){new lx(t,this).chmod(e).then((()=>n())).catch(n)}function oR(t,e,n,i=Ux){new lx(t,this).utimes(e,n).then((()=>i())).catch(i)}function lR(t,e=Ux){Ix.call(this,t).then((()=>e())).catch(e)}function uR(t,e,n=Ux){Ex.call(this,t,e).then((()=>n())).catch(n)}function hR(t,e,n=Ux){n="function"==typeof e?e:n;const i="function"!=typeof e?e:{};bx.call(this,t,i).then((t=>n(void 0,t))).catch(n)}function pR(t,e,n=Ux){vx.call(this,t,e).then((()=>n())).catch(n)}function cR(t,e,n,i=Ux){const s="string"==typeof n?n:"file";i="function"==typeof n?n:i,wx.call(this,t,e,s).then((()=>i())).catch(i)}function dR(t,e,n=Ux){n="function"==typeof e?e:n,Sx.call(this,t).then((t=>n(void 0,t))).catch(n)}function fR(t,e,n,i=Ux){xx.call(this,t,e,n).then((()=>i())).catch(i)}function mR(t,e,n,i=Ux){Rx.call(this,t,e,n).then((()=>i())).catch(i)}function gR(t,e,n=Ux){Ax.call(this,t,e).then((()=>n())).catch(n)}function _R(t,e,n=Ux){Ox.call(this,t,e).then((()=>n())).catch(n)}function TR(t,e,n,i=Ux){Mx.call(this,t,e,n).then((()=>i())).catch(i)}function yR(t,e,n,i=Ux){Cx.call(this,t,e,n).then((()=>i())).catch(i)}function IR(t,e,n=Ux){n="function"==typeof e?e:n,Nx.call(this,t,"function"==typeof e?null:e).then((t=>n(void 0,t))).catch(n)}function ER(t,e,n=Ux){const i="number"==typeof e?e:qb;n="function"==typeof e?e:n,Dx.call(this,t,i).then((()=>n())).catch(n)}const bR=new Map;function vR(t,e,n){const i=Gb(t.toString()),s="function"!=typeof e?e:{};if("function"==typeof e&&(n=e),!n)throw new Rb(Sb.EINVAL,"No listener specified",t.toString(),"watchFile");if(bR.has(i)){const t=bR.get(i);return void(t&&t.listeners.add(n))}const r=new rS(i,s);r.on("change",((t,e)=>{const n=bR.get(i);if(n)for(const i of n.listeners)i(t,e)})),bR.set(i,{watcher:r,listeners:new Set})}function wR(t,e=Ux){const n=Gb(t.toString()),i=bR.get(n);i&&(e&&e!==Ux?i.listeners.delete(e):i.listeners.clear(),0===i.listeners.size&&(i.watcher.stop(),bR.delete(n)))}function SR(t,e,n){const i=new sS(Gb(t),"object"==typeof e?e:{});return n="function"==typeof e?e:n,i.on("change",n||Ux),i}function xR(t,e){const n=this;let i;const s=new sx({highWaterMark:(e="object"==typeof e?e:{encoding:e}).highWaterMark||65536,encoding:e.encoding||"utf8",async read(r){try{i||(i=await gx.call(n,t,"r",e?.mode));const a=await i.read(new Uint8Array(r),0,r,i.file.position);s.push(a.bytesRead?a.buffer.slice(0,a.bytesRead):null),i.file.position+=a.bytesRead,a.bytesRead||await i.close()}catch(t){await(i?.close()),s.destroy(t)}},destroy(t,e){i?.close().then((()=>e(t))).catch(Ux)}});return s.path=t.toString(),s}function RR(t,e){const n=this;let i;e="object"==typeof e?e:{encoding:e};const s=new rx({highWaterMark:e?.highWaterMark,async write(s,r,a){try{i||(i=await gx.call(n,t,"w",e?.mode||438)),await i.write(s,0,r),a(void 0)}catch(t){await(i?.close()),a(t)}},destroy(t,e){e(t),i?.close().then((()=>e(t))).catch(e)},final(t){i?.close().then((()=>t())).catch(t)}});return s.path=t.toString(),s}function AR(t,e,n=Ux){n="function"==typeof e?e:n,Lx.call(this,t,"function"==typeof e?void 0:e).then((()=>n(void 0))).catch(n)}function OR(t,e,n=Ux){n="function"==typeof e?e:n,Fx.call(this,t,"function"!=typeof e?e:null).then((t=>n(void 0,t))).catch(n)}function MR(t,e,n,i=Ux){i="function"==typeof n?n:i,Px.call(this,t,e,"function"==typeof n?void 0:n).then((()=>i(void 0))).catch(i)}function CR(t,e,n,i=Ux){i="function"==typeof n?n:i,new lx(t,this).readv(e,"function"==typeof n?void 0:n).then((({buffers:t,bytesRead:e})=>i(void 0,e,t))).catch(i)}function NR(t,e,n,i=Ux){i="function"==typeof n?n:i,new lx(t,this).writev(e,"function"==typeof n?void 0:n).then((({buffers:t,bytesWritten:e})=>i(void 0,e,t))).catch(i)}function kR(t,e,n=Ux){n="function"==typeof e?e:n,$x.call(this,t,"function"==typeof e?void 0:e).then((t=>n(void 0,t))).catch(n)}function DR(t,e,n,i=Ux){i="function"==typeof n?n:i,Bx.call(this,t,e,"function"==typeof n?void 0:n).then((()=>i(void 0))).catch(i)}function LR(t,e,n=Ux){n="function"==typeof e?e:n,Vx.call(this,t,"function"==typeof e?void 0:e).then((t=>n(void 0,t))).catch(n)}async function FR(t,e){const n=await gx.call(this,t.toString(),"r"),i=await n.readFile();return await n.close(),new Blob([i],e)}var PR=function(t,e,n){if(null!=e){if("object"!=typeof e&&"function"!=typeof e)throw new TypeError("Object expected.");var i,s;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");i=e[Symbol.asyncDispose]}if(void 0===i){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");i=e[Symbol.dispose],n&&(s=i)}if("function"!=typeof i)throw new TypeError("Object not disposable.");s&&(i=function(){try{s.call(this)}catch(t){return Promise.reject(t)}}),t.stack.push({value:e,dispose:i,async:n})}else n&&t.stack.push({async:!0});return e},$R=function(t){return function(e){function n(n){e.error=e.hasError?new t(n,e.error,"An error was suppressed during disposal."):n,e.hasError=!0}return function t(){for(;e.stack.length;){var i=e.stack.pop();try{var s=i.dispose&&i.dispose.call(i.value);if(i.async)return Promise.resolve(s).then(t,(function(e){return n(e),t()}))}catch(t){n(t)}}if(e.hasError)throw e.error}()}}("function"==typeof SuppressedError?SuppressedError:function(t,e,n){var i=new Error(n);return i.name="SuppressedError",i.error=t,i.suppressed=e,i});function BR(t){return class extends t{constructor(){super(...arguments),this._queue=[],this._isInitialized=!1}get _queueRunning(){return!!this._queue.length}queueDone(){return new Promise((t=>{const e=()=>this._queueRunning?setTimeout(e):t();e()}))}async ready(){if(await super.ready(),await this.queueDone(),!this._isInitialized&&!this._disableSync){if(this.checkSync(),await this._sync.ready(),this._sync instanceof Nw&&this instanceof Nw){const t=this._sync.store.transaction(),e=this.store.transaction(),n=[];for(const i of await e.keys())n.push(e.get(i).then((e=>t.setSync(i,e))));return await Promise.all(n),void(this._isInitialized=!0)}try{await this.crossCopy("/"),this._isInitialized=!0}catch(t){throw this._isInitialized=!1,t}}}checkSync(t,e){if(this._disableSync)throw new Rb(Sb.ENOTSUP,"Sync caching has been disabled for this async file system",t,e);if(!this._sync)throw new Rb(Sb.ENOTSUP,"No sync cache is attached to this async file system",t,e)}renameSync(t,e){this.checkSync(t,"rename"),this._sync.renameSync(t,e),this.queue("rename",t,e)}statSync(t){return this.checkSync(t,"stat"),this._sync.statSync(t)}createFileSync(t,e,n){return this.checkSync(t,"createFile"),this._sync.createFileSync(t,e,n),this.queue("createFile",t,e,n),this.openFileSync(t,e)}openFileSync(t,e){this.checkSync(t,"openFile");const n=this._sync.openFileSync(t,e+"+"),i=n.statSync(),s=new Uint8Array(i.size);return n.readSync(s),new sw(this,t,e,i,s)}unlinkSync(t){this.checkSync(t,"unlinkSync"),this._sync.unlinkSync(t),this.queue("unlink",t)}rmdirSync(t){this.checkSync(t,"rmdir"),this._sync.rmdirSync(t),this.queue("rmdir",t)}mkdirSync(t,e){this.checkSync(t,"mkdir"),this._sync.mkdirSync(t,e),this.queue("mkdir",t,e)}readdirSync(t){return this.checkSync(t,"readdir"),this._sync.readdirSync(t)}linkSync(t,e){this.checkSync(t,"link"),this._sync.linkSync(t,e),this.queue("link",t,e)}syncSync(t,e,n){this.checkSync(t,"sync"),this._sync.syncSync(t,e,n),this.queue("sync",t,e,n)}existsSync(t){return this.checkSync(t,"exists"),this._sync.existsSync(t)}async crossCopy(t){this.checkSync(t,"crossCopy");const e=await this.stat(t);if(!e.isDirectory()){const n={stack:[],error:void 0,hasError:!1};try{const i=PR(n,await this.openFile(t,Kv("r")),!0),s=PR(n,this._sync.createFileSync(t,Kv("w"),e.mode),!1),r=new Uint8Array(e.size);return await i.read(r),void s.writeSync(r,0,e.size)}catch(t){n.error=t,n.hasError=!0}finally{const t=$R(n);t&&await t}}if("/"!==t){const e=await this.stat(t);this._sync.mkdirSync(t,e.mode)}const n=[];for(const e of await this.readdir(t))n.push(this.crossCopy(Cb(t,e)));await Promise.all(n)}async _next(){if(!this._queueRunning)return;const[t,...e]=this._queue.shift();await this[t](...e),await this._next()}queue(...t){this._queue.push(t),this._next()}}}new Map;BR(rw);new Map;Map;VR=rw;var VR;var UR=function(t,e,n){if(null!=e){if("object"!=typeof e&&"function"!=typeof e)throw new TypeError("Object expected.");var i,s;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");i=e[Symbol.asyncDispose]}if(void 0===i){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");i=e[Symbol.dispose],n&&(s=i)}if("function"!=typeof i)throw new TypeError("Object not disposable.");s&&(i=function(){try{s.call(this)}catch(t){return Promise.reject(t)}}),t.stack.push({value:e,dispose:i,async:n})}else n&&t.stack.push({async:!0});return e},YR=function(t){return function(e){function n(n){e.error=e.hasError?new t(n,e.error,"An error was suppressed during disposal."):n,e.hasError=!0}return function t(){for(;e.stack.length;){var i=e.stack.pop();try{var s=i.dispose&&i.dispose.call(i.value);if(i.async)return Promise.resolve(s).then(t,(function(e){return n(e),t()}))}catch(t){n(t)}}if(e.hasError)throw e.error}()}}("function"==typeof SuppressedError?SuppressedError:function(t,e,n){var i=new Error(n);return i.name="SuppressedError",i.error=t,i.suppressed=e,i});class GR{get isLocked(){return this._isLocked}constructor(t){this.previous=t,this.current=Promise.withResolvers(),this._isLocked=!0}async done(){await(this.previous?.done()),await this.current.promise}unlock(){this.current.resolve(),this._isLocked=!1}[Symbol.dispose](){this.unlock()}}class HR{async ready(){return await this._fs.ready()}metadata(){return this._fs.metadata()}addLock(){const t=new GR(this.currentLock);return this.currentLock=t,t}async lock(t,e){const n=this.currentLock,i=this.addLock(),s=(new Error).stack;return setTimeout((()=>{if(i.isLocked){const n=Rb.With("EDEADLK",t,e);throw n.stack+=s?.slice(5),n}}),5e3),await(n?.done()),i}lockSync(t,e){if(this.currentLock?.isLocked)throw Rb.With("EBUSY",t,e);return this.addLock()}get isLocked(){return!!this.currentLock?.isLocked}async rename(t,e){const n={stack:[],error:void 0,hasError:!1};try{UR(n,await this.lock(t,"rename"),!1);await this._fs.rename(t,e)}catch(t){n.error=t,n.hasError=!0}finally{YR(n)}}renameSync(t,e){const n={stack:[],error:void 0,hasError:!1};try{UR(n,this.lockSync(t,"rename"),!1);return this._fs.renameSync(t,e)}catch(t){n.error=t,n.hasError=!0}finally{YR(n)}}async stat(t){const e={stack:[],error:void 0,hasError:!1};try{UR(e,await this.lock(t,"stat"),!1);return await this._fs.stat(t)}catch(t){e.error=t,e.hasError=!0}finally{YR(e)}}statSync(t){const e={stack:[],error:void 0,hasError:!1};try{UR(e,this.lockSync(t,"stat"),!1);return this._fs.statSync(t)}catch(t){e.error=t,e.hasError=!0}finally{YR(e)}}async openFile(t,e){const n={stack:[],error:void 0,hasError:!1};try{UR(n,await this.lock(t,"openFile"),!1);const i=await this._fs.openFile(t,e);return i.fs=this,i}catch(t){n.error=t,n.hasError=!0}finally{YR(n)}}openFileSync(t,e){const n={stack:[],error:void 0,hasError:!1};try{UR(n,this.lockSync(t,"openFile"),!1);const i=this._fs.openFileSync(t,e);return i.fs=this,i}catch(t){n.error=t,n.hasError=!0}finally{YR(n)}}async createFile(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{UR(i,await this.lock(t,"createFile"),!1);const s=await this._fs.createFile(t,e,n);return s.fs=this,s}catch(t){i.error=t,i.hasError=!0}finally{YR(i)}}createFileSync(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{UR(i,this.lockSync(t,"createFile"),!1);const s=this._fs.createFileSync(t,e,n);return s.fs=this,s}catch(t){i.error=t,i.hasError=!0}finally{YR(i)}}async unlink(t){const e={stack:[],error:void 0,hasError:!1};try{UR(e,await this.lock(t,"unlink"),!1);await this._fs.unlink(t)}catch(t){e.error=t,e.hasError=!0}finally{YR(e)}}unlinkSync(t){const e={stack:[],error:void 0,hasError:!1};try{UR(e,this.lockSync(t,"unlink"),!1);return this._fs.unlinkSync(t)}catch(t){e.error=t,e.hasError=!0}finally{YR(e)}}async rmdir(t){const e={stack:[],error:void 0,hasError:!1};try{UR(e,await this.lock(t,"rmdir"),!1);await this._fs.rmdir(t)}catch(t){e.error=t,e.hasError=!0}finally{YR(e)}}rmdirSync(t){const e={stack:[],error:void 0,hasError:!1};try{UR(e,this.lockSync(t,"rmdir"),!1);return this._fs.rmdirSync(t)}catch(t){e.error=t,e.hasError=!0}finally{YR(e)}}async mkdir(t,e){const n={stack:[],error:void 0,hasError:!1};try{UR(n,await this.lock(t,"mkdir"),!1);await this._fs.mkdir(t,e)}catch(t){n.error=t,n.hasError=!0}finally{YR(n)}}mkdirSync(t,e){const n={stack:[],error:void 0,hasError:!1};try{UR(n,this.lockSync(t,"mkdir"),!1);return this._fs.mkdirSync(t,e)}catch(t){n.error=t,n.hasError=!0}finally{YR(n)}}async readdir(t){const e={stack:[],error:void 0,hasError:!1};try{UR(e,await this.lock(t,"readdir"),!1);return await this._fs.readdir(t)}catch(t){e.error=t,e.hasError=!0}finally{YR(e)}}readdirSync(t){const e={stack:[],error:void 0,hasError:!1};try{UR(e,this.lockSync(t,"readdir"),!1);return this._fs.readdirSync(t)}catch(t){e.error=t,e.hasError=!0}finally{YR(e)}}async exists(t){const e={stack:[],error:void 0,hasError:!1};try{UR(e,await this.lock(t,"exists"),!1);return await this._fs.exists(t)}catch(t){e.error=t,e.hasError=!0}finally{YR(e)}}existsSync(t){const e={stack:[],error:void 0,hasError:!1};try{UR(e,this.lockSync(t,"exists"),!1);return this._fs.existsSync(t)}catch(t){e.error=t,e.hasError=!0}finally{YR(e)}}async link(t,e){const n={stack:[],error:void 0,hasError:!1};try{UR(n,await this.lock(t,"link"),!1);await this._fs.link(t,e)}catch(t){n.error=t,n.hasError=!0}finally{YR(n)}}linkSync(t,e){const n={stack:[],error:void 0,hasError:!1};try{UR(n,this.lockSync(t,"link"),!1);return this._fs.linkSync(t,e)}catch(t){n.error=t,n.hasError=!0}finally{YR(n)}}async sync(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{UR(i,await this.lock(t,"sync"),!1);await this._fs.sync(t,e,n)}catch(t){i.error=t,i.hasError=!0}finally{YR(i)}}syncSync(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{UR(i,this.lockSync(t,"sync"),!1);return this._fs.syncSync(t,e,n)}catch(t){i.error=t,i.hasError=!0}finally{YR(i)}}}var WR=function(t,e,n){if(null!=e){if("object"!=typeof e&&"function"!=typeof e)throw new TypeError("Object expected.");var i,s;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");i=e[Symbol.asyncDispose]}if(void 0===i){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");i=e[Symbol.dispose],n&&(s=i)}if("function"!=typeof i)throw new TypeError("Object not disposable.");s&&(i=function(){try{s.call(this)}catch(t){return Promise.reject(t)}}),t.stack.push({value:e,dispose:i,async:n})}else n&&t.stack.push({async:!0});return e},zR=function(t){return function(e){function n(n){e.error=e.hasError?new t(n,e.error,"An error was suppressed during disposal."):n,e.hasError=!0}return function t(){for(;e.stack.length;){var i=e.stack.pop();try{var s=i.dispose&&i.dispose.call(i.value);if(i.async)return Promise.resolve(s).then(t,(function(e){return n(e),t()}))}catch(t){n(t)}}if(e.hasError)throw e.error}()}}("function"==typeof SuppressedError?SuppressedError:function(t,e,n){var i=new Error(n);return i.name="SuppressedError",i.error=t,i.suppressed=e,i});const XR="/.deleted";class jR extends rw{async ready(){await this.readable.ready(),await this.writable.ready(),await this._ready}constructor({writable:t,readable:e}){if(super(),this._isInitialized=!1,this._deletedFiles=new Set,this._deleteLog="",this._deleteLogUpdatePending=!1,this._deleteLogUpdateNeeded=!1,this.writable=t,this.readable=e,this.writable.metadata().readonly)throw new Rb(Sb.EINVAL,"Writable file system must be writable.");this._ready=this._initialize()}metadata(){return{...super.metadata(),name:qR.name}}async sync(t,e,n){await this.copyForWrite(t),await this.writable.exists(t)||await this.writable.createFile(t,"w",420),await this.writable.sync(t,e,n)}syncSync(t,e,n){this.copyForWriteSync(t),this.writable.syncSync(t,e,n)}async _initialize(){if(!this._isInitialized){try{const t=await this.writable.openFile(XR,Kv("r")),{size:e}=await t.stat(),{buffer:n}=await t.read(new Uint8Array(e));this._deleteLog=$b(n)}catch(t){if(t.errno!==Sb.ENOENT)throw t}this._isInitialized=!0,this._reparseDeletionLog()}}getDeletionLog(){return this._deleteLog}async restoreDeletionLog(t){this._deleteLog=t,this._reparseDeletionLog(),await this.updateLog("")}async rename(t,e){this.checkInitialized(),this.checkPath(t),this.checkPath(e),await this.copyForWrite(t);try{await this.writable.rename(t,e)}catch{if(this._deletedFiles.has(t))throw Rb.With("ENOENT",t,"rename")}}renameSync(t,e){this.checkInitialized(),this.checkPath(t),this.checkPath(e),this.copyForWriteSync(t);try{this.writable.renameSync(t,e)}catch{if(this._deletedFiles.has(t))throw Rb.With("ENOENT",t,"rename")}}async stat(t){this.checkInitialized();try{return await this.writable.stat(t)}catch{if(this._deletedFiles.has(t))throw Rb.With("ENOENT",t,"stat");const e=await this.readable.stat(t);return e.mode|=146,e}}statSync(t){this.checkInitialized();try{return this.writable.statSync(t)}catch{if(this._deletedFiles.has(t))throw Rb.With("ENOENT",t,"stat");const e=this.readable.statSync(t);return e.mode|=146,e}}async openFile(t,e){if(await this.writable.exists(t))return this.writable.openFile(t,e);const n=await this.readable.openFile(t,Kv("r")),i=await n.stat(),{buffer:s}=await n.read(new Uint8Array(i.size));return new sw(this,t,e,i,s)}openFileSync(t,e){if(this.writable.existsSync(t))return this.writable.openFileSync(t,e);const n=this.readable.openFileSync(t,Kv("r")),i=n.statSync(),s=new Uint8Array(i.size);return n.readSync(s),new sw(this,t,e,i,s)}async createFile(t,e,n){return this.checkInitialized(),await this.writable.createFile(t,e,n),this.openFile(t,e)}createFileSync(t,e,n){return this.checkInitialized(),this.writable.createFileSync(t,e,n),this.openFileSync(t,e)}async link(t,e){this.checkInitialized(),await this.copyForWrite(t),await this.writable.link(t,e)}linkSync(t,e){this.checkInitialized(),this.copyForWriteSync(t),this.writable.linkSync(t,e)}async unlink(t){if(this.checkInitialized(),this.checkPath(t),!await this.exists(t))throw Rb.With("ENOENT",t,"unlink");await this.writable.exists(t)&&await this.writable.unlink(t),await this.exists(t)&&await this.deletePath(t)}unlinkSync(t){if(this.checkInitialized(),this.checkPath(t),!this.existsSync(t))throw Rb.With("ENOENT",t,"unlink");this.writable.existsSync(t)&&this.writable.unlinkSync(t),this.existsSync(t)&&this.deletePath(t)}async rmdir(t){if(this.checkInitialized(),!await this.exists(t))throw Rb.With("ENOENT",t,"rmdir");if(await this.writable.exists(t)&&await this.writable.rmdir(t),await this.exists(t)){if((await this.readdir(t)).length)throw Rb.With("ENOTEMPTY",t,"rmdir");await this.deletePath(t)}}rmdirSync(t){if(this.checkInitialized(),!this.existsSync(t))throw Rb.With("ENOENT",t,"rmdir");if(this.writable.existsSync(t)&&this.writable.rmdirSync(t),this.existsSync(t)){if(this.readdirSync(t).length)throw Rb.With("ENOTEMPTY",t,"rmdir");this.deletePath(t)}}async mkdir(t,e){if(this.checkInitialized(),await this.exists(t))throw Rb.With("EEXIST",t,"mkdir");await this.createParentDirectories(t),await this.writable.mkdir(t,e)}mkdirSync(t,e){if(this.checkInitialized(),this.existsSync(t))throw Rb.With("EEXIST",t,"mkdir");this.createParentDirectoriesSync(t),this.writable.mkdirSync(t,e)}async readdir(t){this.checkInitialized();const e=[];try{e.push(...await this.writable.readdir(t))}catch{}try{e.push(...(await this.readable.readdir(t)).filter((e=>!this._deletedFiles.has(`${t}/${e}`))))}catch{}const n={};return e.filter((t=>{const e=!n[t];return n[t]=!0,e}))}readdirSync(t){this.checkInitialized();let e=[];try{e=e.concat(this.writable.readdirSync(t))}catch{}try{e=e.concat(this.readable.readdirSync(t).filter((e=>!this._deletedFiles.has(`${t}/${e}`))))}catch{}const n={};return e.filter((t=>{const e=!n[t];return n[t]=!0,e}))}async deletePath(t){this._deletedFiles.add(t),await this.updateLog(`d${t}\n`)}async updateLog(t){if(this._deleteLog+=t,this._deleteLogUpdatePending)return void(this._deleteLogUpdateNeeded=!0);this._deleteLogUpdatePending=!0;const e=await this.writable.openFile(XR,Kv("w"));try{await e.write(Fb(this._deleteLog)),this._deleteLogUpdateNeeded&&(this._deleteLogUpdateNeeded=!1,await this.updateLog(""))}catch(t){this._deleteLogError=t}finally{this._deleteLogUpdatePending=!1}}_reparseDeletionLog(){this._deletedFiles.clear();for(const t of this._deleteLog.split("\n"))t.startsWith("d")&&this._deletedFiles.add(t.slice(1))}checkInitialized(){if(!this._isInitialized)throw new Rb(Sb.EPERM,"OverlayFS is not initialized. Please initialize OverlayFS using its initialize() method before using it.");if(!this._deleteLogError)return;const t=this._deleteLogError;throw delete this._deleteLogError,t}checkPath(t){if(t==XR)throw Rb.With("EPERM",t,"checkPath")}createParentDirectoriesSync(t){let e=Nb(t);const n=[];for(;!this.writable.existsSync(e);)n.push(e),e=Nb(e);for(const t of n.reverse())this.writable.mkdirSync(t,this.statSync(t).mode)}async createParentDirectories(t){let e=Nb(t);const n=[];for(;!await this.writable.exists(e);)n.push(e),e=Nb(e);for(const t of n.reverse()){const e=await this.stat(t);await this.writable.mkdir(t,e.mode)}}copyForWriteSync(t){if(!this.existsSync(t))throw Rb.With("ENOENT",t,"copyForWrite");this.writable.existsSync(Nb(t))||this.createParentDirectoriesSync(t),this.writable.existsSync(t)||this.copyToWritableSync(t)}async copyForWrite(t){if(!await this.exists(t))throw Rb.With("ENOENT",t,"copyForWrite");if(await this.writable.exists(Nb(t))||await this.createParentDirectories(t),!await this.writable.exists(t))return this.copyToWritable(t)}copyToWritableSync(t){const e={stack:[],error:void 0,hasError:!1};try{const n=this.statSync(t);if(n.isDirectory())return void this.writable.mkdirSync(t,n.mode);const i=new Uint8Array(n.size);WR(e,this.readable.openFileSync(t,"r"),!1).readSync(i);WR(e,this.writable.createFileSync(t,"w",146|n.mode),!1).writeSync(i)}catch(t){e.error=t,e.hasError=!0}finally{zR(e)}}async copyToWritable(t){const e={stack:[],error:void 0,hasError:!1};try{const n=await this.stat(t);if(n.isDirectory())return void await this.writable.mkdir(t,n.mode);const i=new Uint8Array(n.size),s=WR(e,await this.readable.openFile(t,"r"),!0);await s.read(i);const r=WR(e,await this.writable.createFile(t,"w",146|n.mode),!0);await r.write(i)}catch(t){e.error=t,e.hasError=!0}finally{const t=zR(e);t&&await t}}}class qR extends(function(t){return class extends HR{constructor(...e){super(),this._fs=new t(...e)}}}(jR)){}function KR(t,e,n){if(t instanceof Rb)return t;const i=t instanceof DOMException?Sb[function(t){switch(t.name){case"IndexSizeError":case"HierarchyRequestError":case"InvalidCharacterError":case"InvalidStateError":case"SyntaxError":case"NamespaceError":case"TypeMismatchError":case"ConstraintError":case"VersionError":case"URLMismatchError":case"InvalidNodeTypeError":return"EINVAL";case"WrongDocumentError":return"EXDEV";case"NoModificationAllowedError":case"InvalidModificationError":case"InvalidAccessError":case"SecurityError":case"NotAllowedError":return"EACCES";case"NotFoundError":return"ENOENT";case"NotSupportedError":return"ENOTSUP";case"InUseAttributeError":return"EBUSY";case"NetworkError":return"ENETDOWN";case"AbortError":return"EINTR";case"QuotaExceededError":return"ENOSPC";case"TimeoutError":return"ETIMEDOUT";case"ReadOnlyError":return"EROFS";default:return"EIO"}}(t)]:Sb.EIO,s=new Rb(i,t.message,e,n);return s.stack=t.stack,s.cause=t.cause,s}globalThis.__zenfs__=st;class QR extends(BR(rw)){constructor(t){super(),this._handles=new Map,this._sync=Pw.create({name:"accessfs-cache"}),this._handles.set("/",t)}metadata(){return{...super.metadata(),name:"WebAccess",noResizableBuffers:!0}}async sync(t,e){await this.writeFile(t,e)}async rename(t,e){const n=await this.getHandle(t);if(n instanceof FileSystemDirectoryHandle){const n=await this.readdir(t);if(await this.mkdir(e),!n.length)return void await this.unlink(t);for(const i of n)await this.rename(Cb(t,i),Cb(e,i)),await this.unlink(t);return}if(!(n instanceof FileSystemFileHandle))throw new Rb(Sb.ENOTSUP,"Not a file or directory handle",t,"rename");const i=await n.getFile().catch((e=>{throw KR(e,t,"rename")})),s=await this.getHandle(Nb(e));if(!(s instanceof FileSystemDirectoryHandle))return;const r=await s.getFileHandle(kb(e),{create:!0}).catch((t=>{throw KR(t,e,"rename")})),a=await r.createWritable();await a.write(await i.arrayBuffer()),await a.close(),await this.unlink(t)}async writeFile(t,e){if(e.buffer.resizable)throw new Rb(Sb.EINVAL,"Resizable buffers can not be written",t,"write");const n=await this.getHandle(Nb(t));if(!(n instanceof FileSystemDirectoryHandle))return;const i=await n.getFileHandle(kb(t),{create:!0}),s=await i.createWritable();await s.write(e),await s.close()}async createFile(t,e){return await this.writeFile(t,new Uint8Array),this.openFile(t,e)}async stat(t){const e=await this.getHandle(t);if(!e)throw Rb.With("ENOENT",t,"stat");if(e instanceof FileSystemDirectoryHandle)return new Wv({mode:511|bv,size:4096});if(e instanceof FileSystemFileHandle){const{lastModified:t,size:n}=await e.getFile();return new Wv({mode:511|Iv,size:n,mtimeMs:t})}throw new Rb(Sb.EBADE,"Handle is not a directory or file",t,"stat")}async openFile(t,e){const n=await this.getHandle(t);if(!(n instanceof FileSystemFileHandle))throw Rb.With("EISDIR",t,"openFile");const i=await n.getFile().catch((e=>{throw KR(e,t,"openFile")})),s=new Uint8Array(await i.arrayBuffer()),r=new Wv({mode:511|Iv,size:i.size,mtimeMs:i.lastModified});return new sw(this,t,e,r,s)}async unlink(t){const e=await this.getHandle(Nb(t));if(!(e instanceof FileSystemDirectoryHandle))throw Rb.With("ENOTDIR",Nb(t),"unlink");await e.removeEntry(kb(t),{recursive:!0}).catch((e=>{throw KR(e,t,"unlink")}))}async link(t){}async rmdir(t){return this.unlink(t)}async mkdir(t){if(await this.getHandle(t).catch((t=>{if("ENOENT"!=t.code)throw t})))throw Rb.With("EEXIST",t,"mkdir");const e=await this.getHandle(Nb(t));if(!(e instanceof FileSystemDirectoryHandle))throw Rb.With("ENOTDIR",t,"mkdir");await e.getDirectoryHandle(kb(t),{create:!0})}async readdir(t){const e=await this.getHandle(t);if(!(e instanceof FileSystemDirectoryHandle))throw Rb.With("ENOTDIR",t,"readdir");const n=[];for await(const t of e.keys())n.push(t);return n}async getHandle(t){if(this._handles.has(t))return this._handles.get(t);let e="/";for(const n of t.split("/").slice(1)){const t=this._handles.get(e);if(!(t instanceof FileSystemDirectoryHandle))throw Rb.With("ENOTDIR",e,"getHandle");e=Cb(e,n);const i=await t.getDirectoryHandle(n).catch((i=>{switch(i.name){case"TypeMismatchError":return t.getFileHandle(n).catch((t=>{}));case"TypeError":throw new Rb(Sb.ENOENT,i.message,e,"getHandle");default:throw KR(i,e,"getHandle")}}));i&&this._handles.set(e,i)}return this._handles.get(t)}}function JR(t){return new Promise(((e,n)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>n(t.error)}))}let ZR;function tA(){return ZR||(ZR=function(t,e){const n=indexedDB.open(t);n.onupgradeneeded=()=>n.result.createObjectStore(e);const i=JR(n);return(t,n)=>i.then((i=>n(i.transaction(e,t).objectStore(e))))}("keyval-store","keyval")),ZR}class eA extends QR{constructor(t){super(t)}async readFile(t){const e=await this.getHandle(t);if(e instanceof window.FileSystemFileHandle){const t=await e.getFile();return await t.text()}return""}}class nA extends Zt.FS{#t=null;#e=new TextEncoder;constructor(){super()}async showDirectoryPicker(){const t=await window.showDirectoryPicker({mode:"readwrite"});if("granted"!==await t.requestPermission({mode:"readwrite"}))throw new Error("readwrite access to directory not granted");return await this.setFSCache(t),this.#t=new eA(t),t}async loadFS(){let t=await this.getFSCache();if(!t)return null;if("granted"!==await t.requestPermission({mode:"readwrite"}))throw new Error("readwrite access to directory not granted");return this.#t=new eA(t),t}async getFSCache(){return function(t,e=tA()){return e("readonly",(e=>JR(e.get(t))))}("mixly-pyodide-fs")}async setFSCache(t){await function(t,e,n=tA()){return n("readwrite",(n=>(n.put(e,t),JR(n.transaction))))}("mixly-pyodide-fs",t)}async createFile(t){return this.#t.createFile(t,"")}async readFile(t){return this.#t.readFile(t)}async writeFile(t,e){const n=this.#e.encode(e);return this.#t.writeFile(t,n)}async isFile(t){const e=await this.#t.stat(t);return!(!e||33279!==e.mode)}async renameFile(t,e){return await this.#t.rename(t,e)}async moveFile(t,e){return this.renameFile(t,e)}async deleteFile(t){return this.#t.unlink(t)}async createDirectory(t){return this.#t.mkdir(t,511)}async readDirectory(t){return await this.#t.readdir(t)}async isDirectory(t){const e=await this.#t.stat(t);return!(!e||16895!==e.mode)}async isDirectoryEmpty(t){const e=await this.readDirectory(t);return!e?.length}async renameDirectory(t,e){return this.#t.rename(t,e)}async moveDirectory(t,e){return this.#t.rename(t,e)}async deleteDirectory(t){return this.#t.rmdir(t)}}class iA extends Zt.FileTree{constructor(){super(new nA)}async readFolder(t){let e=[];try{const n=this.getFS();if(!await n.isDirectory(t))return e;const i=await n.readDirectory(t);for(let s of i){const i=fb.join(t,s);if(await n.isDirectory(i)){const t=await n.isDirectoryEmpty(i);e.push({type:"folder",id:i,children:!t,title:`/${this.getRootFolderName()}${i}`})}else e.push({type:"file",id:i,children:!1,title:`/${this.getRootFolderName()}${i}`})}}catch(t){Zt.Debug.error(t)}return e}}class sA extends Zt.PageBase{static{Zt.HTMLTemplate.add("html/statusbar/statusbar-filesystem.html",new Zt.HTMLTemplate('\r\n
\r\n
\r\n
\r\n
')),Zt.HTMLTemplate.add("html/statusbar/statusbar-filesystem-open-fs.html",new Zt.HTMLTemplate('\r\n
\r\n \r\n
')),Zt.HTMLTemplate.add("html/statusbar/statusbar-filesystem-editor-empty.html",new Zt.HTMLTemplate('\r\n
\r\n
\r\n
')),this.init=function(){Zt.StatusBarsManager.typesRegistry.register(["file-system"],sA);const t=Zt.Workspace.getMain().getStatusBarsManager();return t.add({type:"file-system",id:"file-system",name:Jt.Msg.PYTHON_PYODIDE_FILE_SYSTEM,title:Jt.Msg.PYTHON_PYODIDE_FILE_SYSTEM}),t.changeTo("output"),t.get("file-system")}}#n=null;#i=null;#s=null;#r=null;#a=null;#o=null;#l=null;#u=null;#h=!1;#p=!1;#c=!1;#d=null;constructor(){super();const t=gb()(Zt.HTMLTemplate.get("html/statusbar/statusbar-filesystem.html").render());this.setContent(t),this.#l=new iA,this.#i=t.children(".file-tree"),this.#r=gb()(Zt.HTMLTemplate.get("html/statusbar/statusbar-filesystem-open-fs.html").render({msg:{loadFS:Jt.Msg.PYTHON_PYODIDE_LOAD_FILE_SYSTEM}})),this.#i.append(this.#r),this.#o=new Zt.StatusBar,this.#s=t.children(".editor"),this.#a=gb()(Zt.HTMLTemplate.get("html/statusbar/statusbar-filesystem-editor-empty.html").render()),this.#s.append(this.#a)}#f(){this.#u=new Zt.DragV(this.getContent()[0],{min:"150px",startSize:"15%",full:[!1,!1]}),this.#u.bind("sizeChanged",(()=>{this.resize()})),this.#r.children("button").click((()=>{this.selectFS().catch(Zt.Debug.error)})),this.#l.bind("beforeSelectLeaf",(t=>{const e=t[0].id,n=this.#o.getFileMode(fb.extname(e));return n?(this.#o.setMode(n),!0):(wb.layer.msg(Zt.Msg.Lang["statusbar.ampy.cannotEdit"],{time:1e3}),!1)})),this.#l.bind("afterSelectLeaf",(async t=>{const e=t[0].id;this.#l.showProgress();const n=this.#l.getFS();try{const t=await n.readFile(e);this.showEditor(),this.#o.setValue(t),this.#o.scrollToTop(),this.#o.focus(),this.setStatus(!1)}catch(t){Zt.Debug.error(t),this.hideEditor(),this.#l.deselectAll()}this.#l.hideProgress()})),this.#l.bind("afterCreateNode",(t=>{this.#l.refreshFolder(t)})),this.#l.bind("afterDeleteNode",(t=>{this.#l.refreshFolder(t)})),this.#l.bind("afterRenameNode",(t=>{this.#l.refreshFolder(t)})),this.#l.bind("afterRefreshNode",(()=>{this.#l.getSelectedNodeId()||this.hideEditor()}));const t=this.#l.getContextMenu().getItem("menu");t.add({weight:7,id:"copy_path",data:{isHtmlName:!0,name:Zt.Menu.getItem(Zt.Msg.Lang["fileTree.copyPath"]),callback:(t,{$trigger:e})=>{let n=null;n="root"===e.attr("type")?this.#l.getRootFolderTitle():e.attr("title"),navigator.clipboard.writeText(n).catch(Zt.Debug.error)}}}),t.add({weight:14,id:"sep5",preconditionFn:t=>{const e=this.#l.getSelectedNodeId();let n=t.attr("type"),i=t.attr("id");return"file"!==n||e===i},data:"---------"}),t.add({weight:15,id:"refresh",preconditionFn:t=>{const e=this.#l.getSelectedNodeId();let n=t.attr("type"),i=t.attr("id");return"file"!==n||e===i},data:{isHtmlName:!0,name:Zt.Menu.getItem(Zt.Msg.Lang["statusbar.ampy.refresh"]),callback:(t,{$trigger:e})=>{let n=e.attr("type");if("root"===n)this.#l.openRootFolder(),this.#l.refreshFolder("/");else if("folder"===n){let t=e.attr("id");this.#l.openNode(t),this.#l.refreshFolder(t)}else{const t=this.#l.getSelectedNodes();this.#l.runEvent("afterSelectLeaf",t)}}}}),t.add({weight:16,id:"sep6",preconditionFn:t=>{let e=t.attr("type");return["root"].includes(e)},data:"---------"}),t.add({weight:17,id:"exit",preconditionFn:t=>{let e=t.attr("type");return["root"].includes(e)},data:{isHtmlName:!0,name:Zt.Menu.getItem(Zt.Msg.Lang["statusbar.ampy.exit"]),callback:()=>{this.closeFS()}}}),t.remove("copy"),t.remove("cut"),t.remove("paste"),t.remove("sep2");const e=this.#o.getContextMenu().getItem("code");e.empty(),e.add({weight:0,id:"cut",data:{isHtmlName:!0,name:Zt.Menu.getItem(Zt.Msg.Lang["editor.contextMenu.cut"],"Ctrl+X"),callback:()=>this.#o.cut()}}),e.add({weight:1,id:"copy",data:{isHtmlName:!0,name:Zt.Menu.getItem(Zt.Msg.Lang["editor.contextMenu.copy"],"Ctrl+C"),callback:()=>this.#o.copy()}}),e.add({weight:2,id:"paste",data:{isHtmlName:!0,name:Zt.Menu.getItem(Zt.Msg.Lang["editor.contextMenu.paste"],"Ctrl+V"),callback:()=>this.#o.paste()}}),e.add({weight:3,id:"sep1",data:"---------"}),e.add({weight:4,id:"togglecomment",data:{isHtmlName:!0,name:Zt.Menu.getItem(Zt.Msg.Lang["editor.contextMenu.togglecomment"],"Ctrl+/"),callback:()=>this.#o.commentLine()}}),e.add({weight:6,id:"sep2",preconditionFn:()=>this.#c,data:"---------"}),e.add({weight:7,id:"save",preconditionFn:()=>this.#c,data:{isHtmlName:!0,name:Zt.Menu.getItem(Zt.Msg.Lang["file.save"],"Ctrl+S"),callback:async()=>{await this.put()}}});const{commands:n}=this.#o.getEditor();n.addCommand({name:"save",bindKey:"Ctrl-S",exec:async()=>{this.#c&&await this.put()}})}async put(){this.#l.showProgress();const t=this.#l.getSelectedNodeId(),e=this.#l.getFS();try{await e.writeFile(t,this.#o.getValue()),this.setStatus(!1)}catch(t){Zt.Debug.error(t)}finally{this.#l.hideProgress()}}showFileTree(){this.#h||(this.#r.detach(),this.#i.empty(),this.#i.append(this.#l.getContent()),this.#h=!0)}hideFileTree(){this.#h&&(this.#l.getContent().detach(),this.#i.empty(),this.#i.append(this.#r),this.#h=!1)}showEditor(){this.#p||(this.#a.detach(),this.#s.empty(),this.#s.append(this.#o.getContent()),this.#p=!0)}hideEditor(){this.#p&&(this.#o.getContent().detach(),this.#s.empty(),this.#s.append(this.#a),this.#p=!1,this.setStatus(!1))}getDrag(){return this.#u}init(){super.init(),this.hideCloseBtn(),this.#o.init(),this.#f();const t=this.#o.getEditor();t.setReadOnly(!1),t.renderer.setShowGutter(!0),t.setOptions({enableBasicAutocompletion:!0,enableSnippets:!0,enableLiveAutocompletion:!0,newLineMode:"unix"}),t.on("change",(()=>{this.setStatus(!0)})),this.loadFS().catch(Zt.Debug.error)}async loadFS(){const t=this.#l.getFS(),e=await t.loadFS();await this.openFS(e)}async selectFS(){const t=this.#l.getFS(),e=await t.showDirectoryPicker();await this.openFS(e)}async openFS(t){if(!t?.name)return;const e="/"+t.name;this.#l.setFolderPath("/"),this.#l.setRootFolderTitle(e),this.#l.setRootFolderName(t.name),this.#l.openRootFolder(),this.showFileTree(),this.#d=await window.pyodide.mountNativeFS(e,t)}closeFS(){const t=this.#l.getRootFolderTitle();if(Object.keys(window.pyodide.FS.root.contents).includes(fb.basename(t))){const e=window.pyodide.FS.lookupPath(t,{follow_mount:!1});window.pyodide.FS.isMountpoint(e.node)&&window.pyodide.FS.unmount(t)}this.#l.getFS().setFSCache(null),this.#l.deselectAll(),this.hideFileTree(),this.hideEditor(),this.setStatus(!1)}onMounted(){super.onMounted(),this.#o.onMounted(),this.#l.onMounted()}onUnmounted(){super.onUnmounted(),this.#o.onUnmounted(),this.#l.onUnmounted()}resize(){super.resize(),this.#o.resize(),this.#l.resize()}setStatus(t){this.#c!==t&&(this.#c=t)}getNativeFS(){return this.#d}dispose(){this.#o.dispose(),this.#o=null,this.#l.dispose(),this.#l=null,super.dispose()}}class rA{static{Zt.HTMLTemplate.add("html/statusbar/loader.html",new Zt.HTMLTemplate('\r\n
\r\n
\r\n

{{d.msg.loading}}

\r\n
')),this.pythonShell=null,this.kernelLoaded=!1,this.$loader=gb()(Zt.HTMLTemplate.get("html/statusbar/loader.html").render({msg:{loading:Jt.Msg.PYTHON_PYODIDE_LOADING}})),this.statusBarImage=null,this.statusBarFileSystem=null,this.init=async function(){Zt.app.getFooterBar().getContent().after(this.$loader);const t=fb.relative(Zt.Env.indexDirPath,Zt.Env.boardDirPath),e=new bb({rootPath:fb.join(t,"deps"),language:"python3"}),n=await e.kernelAvailable();n&&(await n.init(),await n.loaded(),this.loader=e,this.kernel=n,this.statusBarImage=vb.init(),this.statusBarFileSystem=sA.init(),this.pythonShell=new rA,this.pyodide=window.pyodide,this.interruptBuffer=new Uint8Array(new ArrayBuffer(1)),this.pyodide.setInterruptBuffer(this.interruptBuffer),this.kernelLoaded=!0,this.$loader.remove(),this.$loader=null)},this.run=async function(){if(!this.kernelLoaded)return;const t=Zt.Workspace.getMain().getEditorsManager().getActive().getCode();return this.pythonShell.run(t)},this.stop=async function(){if(this.kernelLoaded)return this.pythonShell.stop()}}#m=null;#g=null;#_=null;#T={row:0,column:0};#y="";#I=null;#E=null;#b=!1;#v=!1;#w=null;#S=()=>this.#x();#R=[{name:"REPL-Enter",bindKey:"Enter",exec:t=>{if(t.getSession().selection.getCursor().row===this.#T.row){const t=this.#m.getEndPos();let e=this.#m.getValueRange(this.#T,t);e=e.replace(this.#y,""),this.#I?.(e),this.#I=null,this.#E=null,this.#m.addValue("\n"),this.#A()}return!1}},{name:"REPL-ChangeEditor",bindKey:"Delete|Ctrl-X|Backspace",exec:t=>{const e=t.getSession().selection.getCursor();return e.row{this.#v=!1,this.#m.addValue(`\n==${Zt.Msg.Lang["shell.finish"]}==`),this.syncfs(!1).catch(Zt.Debug.error)})),this.#w.addEventListener("eval.output",(t=>{this.#m.addValue(t.content)})),this.#w.addEventListener("eval.error",(()=>{this.#v=!1,this.#m.addValue(`\n==${Zt.Msg.Lang["shell.finish"]}==`)})),this.#w.addEventListener("eval.input",(t=>{const e=String(t?.content?.prompt);this.#m.addValue(e),this.#y=e,this.#I=t.resolve,this.#E=t.reject,this.#O()})),this.#w.addEventListener("eval.display",(t=>{this.#_.changeTo("images"),this.#g.display(t)}))}#x(){const t=this.#m.getEditor(),e=t.getSession().selection.getCursor();t.setReadOnly(e.row{window.pyodide.FS.syncfs(t,e)}))}sleep(t){return new Promise((e=>setTimeout(e,t)))}}const aA={init:async function(){const t=Zt.app.getNav();t.register({icon:"icon-play-circled",title:"",id:"python-run-btn",displayText:Jt.Msg.MSG.run,preconditionFn:()=>!0,callback:()=>{rA.run().catch(Zt.Debug.error)},scopeType:Zt.Nav.Scope.LEFT,weight:4}),t.register({icon:"icon-cancel",title:"",id:"python-stop-btn",displayText:Jt.Msg.MSG.stop,preconditionFn:()=>!0,callback:()=>{rA.stop().catch(Zt.Debug.error)},scopeType:Zt.Nav.Scope.LEFT,weight:5}),await rA.init()}},oA=aA;class lA{constructor(t,e){this.backend=t,this.dataMover=e,this.data=new WeakMap,this.dataIdsCount=0}get(t){return this.data.has(t)||this.dataMover.moveData(this.backend,t),this.data.get(t)}set(t,e){this.dataIdsCount++,this.data.set(t,e)}has(t){return this.data.has(t)}delete(t){return this.dataIdsCount--,this.data.delete(t)}numDataIds(){return this.dataIdsCount}}class uA{refCount(t){return hA("refCount")}incRef(t){return hA("incRef")}timerAvailable(){return!0}time(t){return hA("time")}read(t){return hA("read")}readSync(t){return hA("readSync")}readToGPU(t,e){return hA("readToGPU")}numDataIds(){return hA("numDataIds")}disposeData(t,e){return hA("disposeData")}write(t,e,n){return hA("write")}move(t,e,n,i,s){return hA("move")}createTensorFromGPUData(t,e,n){return hA("createTensorFromGPUData")}memory(){return hA("memory")}floatPrecision(){return hA("floatPrecision")}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}dispose(){return hA("dispose")}}function hA(t){throw new Error(`'${t}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`)} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function pA(t){let e=t.length,n=0;for(;e>0;)n=Math.random()*e|0,e--,mA(t,e,n)}function cA(t,e){if(t.length!==e.length)throw new Error(`Array sizes must match to be shuffled together First array length was ${t.length}Second array length was ${e.length}`);let n=t.length,i=0;for(;n>0;)i=Math.random()*n|0,n--,mA(t,n,i),mA(e,n,i)}function dA(t,e,n){return Math.max(t,Math.min(e,n))}function fA(t){return t%2==0?t:t+1}function mA(t,e,n){const i=t[e];t[e]=t[n],t[n]=i}function gA(t){let e=0;for(let n=0;nn+` Shapes ${t} and ${e} must match`))}function EA(t){yA(null!=t,(()=>"The input to the tensor constructor must be a non-null value."))}function bA(t){if(0===t.length)return 1;let e=t[0];for(let n=1;n0,n,i){return new Promise(((s,r)=>{let a=0;const o=()=>{if(t())return void s();a++;const l=e(a);null!=n&&a>=n?r():null!=i?i(o,l):setTimeout(o,l)};o()}))}function NA(t,e){let n=1,i=-1;for(let e=0;e=0)n*=t[e];else if(-1===t[e]){if(-1!==i)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${i} and dim ${e}`);i=e}else if(t[e]<0)throw Error(`Shapes can not be < 0. Found ${t[e]} at dim ${e}`);if(-1===i){if(e>0&&e!==n)throw Error(`Size(${e}) must match the product of shape ${t}`);return t}if(0===n)throw Error(`Cannot infer the missing size in [${t}] when there are 0 elements`);if(e%n!=0)throw Error(`The implicit shape can't be a fractional number. Got ${e} / ${n}`);const s=t.slice();return s[i]=e/n,s}function kA(t,e){const n=e.length;return yA((t=null==t?e.map(((t,e)=>e)):[].concat(t)).every((t=>t>=-n&&t`All values in axis param must be in range [-${n}, ${n}) but got axis ${t}`)),yA(t.every((t=>xA(t))),(()=>`All values in axis param must be integers but got axis ${t}`)),t.map((t=>t<0?n+t:t))}function DA(t,e){const n=[],i=[],s=null!=e&&Array.isArray(e)&&0===e.length,r=null==e||s?null:kA(e,t).sort();let a=0;for(let e=0;ee)&&1===t[e]&&(n.push(t[e]),i.push(e)),r[a]<=e&&a++}1!==t[e]&&(n.push(t[e]),i.push(e))}return{newShape:n,keptDims:i}}function LA(t,e){return FA(t,e)}function FA(t,e){let n=null;if(null==t||"float32"===t)n=new Float32Array(e);else if("int32"===t)n=new Int32Array(e);else if("bool"===t)n=new Uint8Array(e);else{if("string"!==t)throw new Error(`Unknown data type ${t}`);n=new Array(e)}return n}function PA(t,e){for(let n=0;ne+=t.length)),e}function YA(t){return"string"==typeof t||t instanceof String}function GA(t){return"boolean"==typeof t}function HA(t){return"number"==typeof t}function WA(t){return Array.isArray(t)?WA(t[0]):t instanceof Float32Array?"float32":t instanceof Int32Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray?"int32":HA(t)?"float32":YA(t)?"string":GA(t)?"bool":"float32"}function zA(t){return!!(t&&t.constructor&&t.call&&t.apply)}function XA(t,e){for(let n=e;n=0;--i)n[i]=n[i+1]*t[i+1];return n}function qA(t,e,n,i=!1){const s=new Array;if(1===e.length){const r=e[0]*(i?2:1);for(let e=0;et*e))*(i?2:1);for(let e=0;et*e))*(n?2:1);if(0===i)return[];if(i!==e.length)throw new Error(`[${t}] does not match the input size ${e.length}${n?" for a complex tensor":""}.`);return qA(0,t,e,n)}function QA(t,e){if(Array.isArray(t))return t;if("float32"===e)return t instanceof Float32Array?t:new Float32Array(t);if("int32"===e)return t instanceof Int32Array?t:new Int32Array(t);if("bool"===e||"string"===e)return Uint8Array.from(new Int32Array(t));throw new Error(`Unknown dtype ${e}`)}function JA(t,e){const n=ZA(t,e);for(let t=0;tt*e),1);if(null==e||"float32"===e)return KA(t,new Float32Array(n));if("int32"===e)return KA(t,new Int32Array(n));if("bool"===e)return KA(t,new Uint8Array(n));throw new Error(`Unknown data type ${e}`)}function eO(t){t.forEach((e=>{yA(Number.isInteger(e)&&e>=0,(()=>`Tensor must have a shape comprised of positive integers but got shape [${t}].`))}))}function nO(t,e,n){if(0===e)return 0;if(1===e)return t[0];let i=t[t.length-1];for(let e=0;e{const[e,n]=t.split(":");this.urlFlags[e]=function(t,e){const n=e.toLowerCase();return"true"===n||"false"===n?"true"===n:""+ +n===n?+n:e}(0,n)}))}}}function oO(t){const e={};return t.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,((t,...n)=>(function(t,e,n){t[decodeURIComponent(e)]=decodeURIComponent(n||"")}(e,n[0],n[1]),n.join("=")))),e}function lO(){return hO}let uO,hO=null;function pO(){if(null==uO){let t;if("undefined"!=typeof window)t=window;else if(void 0!==__webpack_require__.g)t=__webpack_require__.g;else if("undefined"!=typeof process)t=process;else{if("undefined"==typeof self)throw new Error("Could not find a global object");t=self}uO=t}return uO}function cO(t,e){const n=function(){const t=pO();return null==t._tfGlobals&&(t._tfGlobals=new Map),t._tfGlobals}();if(n.has(t))return n.get(t);{const i=e();return n.set(t,i),n.get(t)}}const dO="Abs",fO="Acos",mO="Acosh",gO="Add",_O="AddN",TO="All",yO="Any",IO="ArgMax",EO="ArgMin",bO="Asin",vO="Asinh",wO="Atan",SO="Atanh",xO="Atan2",RO="AvgPool",AO="AvgPoolGrad",OO="AvgPool3D",MO="AvgPool3DGrad",CO="BatchMatMul",NO="BatchToSpaceND",kO="Bincount",DO="BitwiseAnd",LO="BroadcastTo",FO="BroadcastArgs",PO="Cast",$O="Ceil",BO="ClipByValue",VO="Complex",UO="ComplexAbs",YO="Concat",GO="Conv2D",HO="Conv2DBackpropFilter",WO="Conv2DBackpropInput",zO="Conv3D",XO="Conv3DBackpropFilterV2",jO="Conv3DBackpropInputV2",qO="Cos",KO="Cosh",QO="Cumprod",JO="Cumsum",ZO="CropAndResize",tM="DenseBincount",eM="DepthToSpace",nM="DepthwiseConv2dNative",iM="DepthwiseConv2dNativeBackpropFilter",sM="DepthwiseConv2dNativeBackpropInput",rM="Diag",aM="Dilation2D",oM="Dilation2DBackpropInput",lM="Dilation2DBackpropFilter",uM="Draw",hM="RealDiv",pM="Einsum",cM="Elu",dM="EluGrad",fM="Erf",mM="Equal",gM="Exp",_M="ExpandDims",TM="Expm1",yM="FFT",IM="Fill",EM="FlipLeftRight",bM="Floor",vM="FloorDiv",wM="FusedBatchNorm",SM="GatherV2",xM="GatherNd",RM="Greater",AM="GreaterEqual",OM="Identity",MM="IFFT",CM="Imag",NM="IsFinite",kM="IsInf",DM="IsNan",LM="LeakyRelu",FM="Less",PM="LessEqual",$M="LinSpace",BM="Log",VM="Log1p",UM="LogicalAnd",YM="LogicalNot",GM="LogicalOr",HM="LogicalXor",WM="LogSoftmax",zM="LowerBound",XM="LRN",jM="LRNGrad",qM="MatrixBandPart",KM="Max",QM="Maximum",JM="MaxPool",ZM="MaxPoolGrad",tC="MaxPool3D",eC="MaxPool3DGrad",nC="MaxPoolWithArgmax",iC="Mean",sC="Min",rC="Minimum",aC="MirrorPad",oC="Mod",lC="Multinomial",uC="Multiply",hC="Neg",pC="NotEqual",cC="NonMaxSuppressionV3",dC="NonMaxSuppressionV4",fC="NonMaxSuppressionV5",mC="OnesLike",gC="OneHot",_C="Pack",TC="PadV2",yC="Pool",IC="Pow",EC="Prelu",bC="Prod",vC="RaggedGather",wC="RaggedRange",SC="RaggedTensorToTensor",xC="Range",RC="Real",AC="Reciprocal",OC="Relu",MC="Reshape",CC="ResizeNearestNeighbor",NC="ResizeNearestNeighborGrad",kC="ResizeBilinear",DC="ResizeBilinearGrad",LC="Relu6",FC="Reverse",PC="Round",$C="Rsqrt",BC="ScatterNd",VC="TensorScatterUpdate",UC="SearchSorted",YC="Select",GC="Selu",HC="Slice",WC="Sin",zC="Sinh",XC="Sign",jC="Sigmoid",qC="Softplus",KC="Sqrt",QC="Sum",JC="SpaceToBatchND",ZC="SplitV",tN="Softmax",eN="SparseFillEmptyRows",nN="SparseReshape",iN="SparseSegmentMean",sN="SparseSegmentSum",rN="SparseToDense",aN="SquaredDifference",oN="Square",lN="StaticRegexReplace",uN="StridedSlice",hN="StringNGrams",pN="StringSplit",cN="StringToHashBucketFast",dN="Sub",fN="Tan",mN="Tanh",gN="Tile",_N="TopK",TN="Transform",yN="Transpose",IN="Unique",EN="Unpack",bN="UnsortedSegmentSum",vN="UpperBound",wN="ZerosLike",SN="Step",xN="FromPixels",RN="RotateWithOffset",AN="_FusedMatMul",ON="FusedConv2D",MN="FusedDepthwiseConv2D"; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function CN(...t){lO().getBool("IS_TEST")||lO().getBool("PROD")||console.warn(...t)}function NN(...t){lO().getBool("IS_TEST")||lO().getBool("PROD")||console.log(...t)} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const kN=cO("kernelRegistry",(()=>new Map)),DN=cO("gradRegistry",(()=>new Map));function LN(t,e){const n=GN(t,e);return kN.get(n)}function FN(t){return DN.get(t)}function PN(t){const e=kN.entries(),n=[];for(;;){const{done:i,value:s}=e.next();if(i)break;const[r,a]=s,[o]=r.split("_");o===t&&n.push(a)}return n}function $N(t){const{kernelName:e,backendName:n}=t,i=GN(e,n);kN.has(i)&&CN(`The kernel '${e}' for backend '${n}' is already registered`),kN.set(i,t)}function BN(t){const{kernelName:e}=t;DN.has(e)&&lO().getBool("DEBUG")&&CN(`Overriding the gradient for '${e}'`),DN.set(e,t)}function VN(t,e){const n=GN(t,e);if(!kN.has(n))throw new Error(`The kernel '${t}' for backend '${e}' is not registered`);kN.delete(n)}function UN(t){if(!DN.has(t))throw new Error(`The gradient '${t}' for backend is not registered`);DN.delete(t)}function YN(t,e){PN(t).forEach((t=>{$N(Object.assign({},t,{backendName:e}))}))}function GN(t,e){return`${e}_${t}`} /** * @license * Copyright 2023 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function HN(t){return t instanceof Float32Array||t instanceof Int32Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray}var WN=__webpack_require__(8570); /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const zN=__webpack_require__.n(WN)()||WN;function XN(t){return zN.fromString(t,!0,16)}const jN=XN("c3a5c85c97cb3127"),qN=XN("b492b66fbe98f273"),KN=XN("9ae16a3b2f90404f");function QN(t){return t.xor(t.shru(47))}function JN(t,e,n){const i=t.slice(e,e+n);return zN.fromBytes(Array.from(i),!0,!0)}function ZN(t,e){return JN(t,e,8)}function tk(t,e){return JN(t,e,4)}function ek(t,e){return 0===e?t:t.shru(e).or(t.shl(64-e))}function nk(t,e,n=XN("9ddfea08eb382d69")){let i=t.xor(e).mul(n);i=i.xor(i.shru(47));let s=e.xor(i).mul(n);return s=s.xor(s.shru(47)),s=s.mul(n),s}function ik(t,e,n,i){return function(t,e,n,i,s,r){s=s.add(t),r=ek(r.add(s).add(i),21);const a=s;return s=(s=s.add(e)).add(n),r=r.add(ek(s,44)),[s.add(i),r.add(a)]}(ZN(t,e),ZN(t,e+8),ZN(t,e+16),ZN(t,e+24),n,i)}function sk(t,e=t.length){const n=zN.fromNumber(81,!0);if(e<=32)return e<=16?function(t,e=t.length){if(e>=8){const n=KN.add(2*e),i=ZN(t,0).add(KN),s=ZN(t,e-8);return nk(ek(s,37).mul(n).add(i),ek(i,25).add(s).mul(n),n)}if(e>=4){const n=KN.add(2*e);return nk(tk(t,0).shl(3).add(e),tk(t,e-4),n)}if(e>0){const n=t[0]+(t[e>>1]<<8),i=e+(t[e-1]<<2);return QN(KN.mul(n).xor(jN.mul(i))).mul(KN)}return KN}(t,e):function(t,e=t.length){const n=KN.add(2*e),i=ZN(t,0).mul(qN),s=ZN(t,8),r=ZN(t,e-8).mul(n),a=ZN(t,e-16).mul(KN);return nk(ek(i.add(s),43).add(ek(r,30)).add(a),i.add(ek(s.add(KN),18)).add(r),n)}(t,e);if(e<=64)return function(t,e=t.length){const n=KN.add(2*e),i=ZN(t,0).mul(KN),s=ZN(t,8),r=ZN(t,e-8).mul(n),a=ZN(t,e-16).mul(KN),o=ek(i.add(s),43).add(ek(r,30)).add(a),l=nk(o,i.add(ek(s.add(KN),18)).add(r),n),u=ZN(t,16).mul(n),h=ZN(t,24),p=o.add(ZN(t,e-32)).mul(n),c=l.add(ZN(t,e-24)).mul(n);return nk(ek(u.add(h),43).add(ek(p,30)).add(c),u.add(ek(h.add(i),18)).add(p),n)}(t,e);let i=n,s=n.mul(qN).add(113),r=QN(s.mul(KN).add(113)).mul(KN),a=[zN.UZERO,zN.UZERO],o=[zN.UZERO,zN.UZERO];i=i.mul(KN).add(ZN(t,0));let l=0;const u=64*(e-1>>6),h=u+(e-1&63)-63;do{i=ek(i.add(s).add(a[0]).add(ZN(t,l+8)),37).mul(qN),s=ek(s.add(a[1]).add(ZN(t,l+48)),42).mul(qN),i=i.xor(o[1]),s=s.add(a[0]).add(ZN(t,l+40)),r=ek(r.add(o[0]),33).mul(qN),a=ik(t,l,a[1].mul(qN),i.add(o[0])),o=ik(t,l+32,r.add(o[1]),s.add(ZN(t,l+16))),[r,i]=[i,r],l+=64}while(l!==u);const p=qN.add(r.and(255).shl(1));return l=h,o[0]=o[0].add(e-1&63),a[0]=a[0].add(o[0]),o[0]=o[0].add(a[0]),i=ek(i.add(s).add(a[0]).add(ZN(t,l+8)),37).mul(p),s=ek(s.add(a[1]).add(ZN(t,l+48)),42).mul(p),i=i.xor(o[1].mul(9)),s=s.add(a[0].mul(9).add(ZN(t,l+40))),r=ek(r.add(o[0]),33).mul(p),a=ik(t,l,a[1].mul(p),i.add(o[0])),o=ik(t,l+32,r.add(o[1]),s.add(ZN(t,l+16))),[r,i]=[i,r],nk(nk(a[0],o[0],p).add(QN(s).mul(jN)).add(r),nk(a[1],o[1],p).add(i),p)} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function rk(t,e){return"string"===e?uk(t):ak([t],e)}function ak(t,e){if("string"===e)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(t)&&(t=ck(t)),lO().getBool("DEBUG")&&PA(t,e),function(t,e){return t instanceof Float32Array&&"float32"===e||t instanceof Int32Array&&"int32"===e||t instanceof Uint8Array&&"bool"===e}(t,e))return t;if(null==e||"float32"===e||"complex64"===e)return new Float32Array(t);if("int32"===e)return new Int32Array(t);if("bool"===e){const e=new Uint8Array(t.length);for(let n=0;n{i=n()};let r;const a=ok();if(this.backendTimer.timerAvailable())r=this.backendTimer.time(s);else{s();for(const t of i)t.dataSync();r=Promise.resolve({kernelMs:ok()-a})}if(lO().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let e=0;e{fk(e,n.dtype,t)}))}return{kernelName:t,outputs:i,inputs:e,timeMs:r.then((t=>t.kernelMs)),extraInfo:r.then((t=>null!=t.getExtraProfileInfo?t.getExtraProfileInfo():""))}}logKernelProfile(t){const{kernelName:e,outputs:n,timeMs:i,inputs:s,extraInfo:r}=t;n.forEach((t=>{Promise.all([t.data(),i,r]).then((n=>{this.logger.logKernelProfile(e,t,n[0],n[1],s,n[2])}))}))}}function fk(t,e,n){if("float32"!==e)return!1;for(let e=0;e0?i:""} `}}console.log(`%c${o}\t%c${a}\t%c${l}D ${h}\t%c${u}\t%c${p}\t%c${r}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const gk=20,_k=3,Tk=7;function yk(t,e,n,i){const s=jA(e),r=function(t,e,n,i){const s=bA(e),r=i[i.length-1],a=new Array(r).fill(0),o=e.length,l="complex64"===n?vk(t):t;if(o>1)for(let t=0;t" "+t)).join("\n")),l.join("\n")}function Ik(t,e,n){let i;return i=Array.isArray(t)?`${parseFloat(t[0].toFixed(Tk))} + ${parseFloat(t[1].toFixed(Tk))}j`:YA(t)?`'${t}'`:"bool"===n?Ek(t):parseFloat(t.toFixed(Tk)).toString(),MA(i,e)}function Ek(t){return 0===t?"false":"true"}function bk(t,e,n,i,s,r=!0){const a="complex64"===n?2:1,o=e[0],l=e.length;if(0===l){if("complex64"===n){return[Ik(vk(t)[0],0,n)]}return"bool"===n?[Ek(t[0])]:[t[0].toString()]}if(1===l){if(o>gk){const e=_k*a;let i=Array.from(t.slice(0,e)),r=Array.from(t.slice((o-_k)*a,o*a));return"complex64"===n&&(i=vk(i),r=vk(r)),["["+i.map(((t,e)=>Ik(t,s[e],n))).join(", ")+", ..., "+r.map(((t,e)=>Ik(t,s[o-_k+e],n))).join(", ")+"]"]}return["["+("complex64"===n?vk(t):Array.from(t)).map(((t,e)=>Ik(t,s[e],n))).join(", ")+"]"]}const u=e.slice(1),h=i.slice(1),p=i[0]*a,c=[];if(o>gk){for(let e=0;e<_k;e++){const i=e*p,r=i+p;c.push(...bk(t.slice(i,r),u,n,h,s,!1))}c.push("...");for(let e=o-_k;e0?c[0]+d:"");for(let t=1;t`Length of values '${t}' does not match the size inferred by the shape '${this.size}'.`))}if("complex64"===e)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||FA(e,this.size),this.strides=jA(t)}set(t,...e){0===e.length&&(e=[0]),yA(e.length===this.rank,(()=>`The number of provided coordinates (${e.length}) must match the rank (${this.rank})`));const n=this.locToIndex(e);this.values[n]=t}get(...t){0===t.length&&(t=[0]);let e=0;for(const n of t){if(n<0||n>=this.shape[e]){const e=`Requested out of range element at ${t}. Buffer shape=${this.shape}`;throw new Error(e)}e++}let n=t[t.length-1];for(let e=0;ehk(t)))}catch(t){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}}return t}dataToGPU(t){return this.throwIfDisposed(),Sk().readToGPU(this.dataId,t)}dataSync(){this.throwIfDisposed();const t=Sk().readSync(this.dataId);if("string"===this.dtype)try{return t.map((t=>hk(t)))}catch(t){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}return t}async bytes(){this.throwIfDisposed();const t=await Sk().read(this.dataId);return"string"===this.dtype?t:new Uint8Array(t.buffer)}dispose(){this.isDisposed||(this.kerasMask&&this.kerasMask.dispose(),Sk().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(t=!1){return xk.print(this,t)}clone(){return this.throwIfDisposed(),xk.clone(this)}toString(t=!1){return yk(this.dataSync(),this.shape,this.dtype,t)}cast(t){return this.throwIfDisposed(),xk.cast(this,t)}variable(t=!0,e,n){return this.throwIfDisposed(),Sk().makeVariable(this,t,e,n)}}function Ok(){return cO("Tensor",(()=>Ak))}Object.defineProperty(Ak,Symbol.hasInstance,{value:t=>!!t&&null!=t.data&&null!=t.dataSync&&null!=t.throwIfDisposed}),Ok();class Mk extends Ak{constructor(t,e,n,i){super(t.shape,t.dtype,t.dataId,i),this.trainable=e,this.name=n}assign(t){if(t.dtype!==this.dtype)throw new Error(`dtype of the new value (${t.dtype}) and previous value (${this.dtype}) must match`);if(!SA(t.shape,this.shape))throw new Error(`shape of the new value (${t.shape}) and previous value (${this.shape}) must match`);Sk().disposeTensor(this),this.dataId=t.dataId,Sk().incRef(this,null)}dispose(){Sk().disposeVariable(this),this.isDisposedInternal=!0}} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ var Ck,Nk,kk,Dk,Lk;Object.defineProperty(Mk,Symbol.hasInstance,{value:t=>t instanceof Ak&&null!=t.assign&&t.assign instanceof Function}),function(t){t.R0="R0",t.R1="R1",t.R2="R2",t.R3="R3",t.R4="R4",t.R5="R5",t.R6="R6"}(Ck||(Ck={})),function(t){t.float32="float32",t.int32="int32",t.bool="int32",t.complex64="complex64"}(Nk||(Nk={})),function(t){t.float32="float32",t.int32="int32",t.bool="bool",t.complex64="complex64"}(kk||(kk={})),function(t){t.float32="float32",t.int32="float32",t.bool="float32",t.complex64="complex64"}(Dk||(Dk={})),function(t){t.float32="complex64",t.int32="complex64",t.bool="complex64",t.complex64="complex64"}(Lk||(Lk={}));const Fk={float32:Dk,int32:Nk,bool:kk,complex64:Lk};function Pk(t,e){if("string"===t||"string"===e){if("string"===t&&"string"===e)return"string";throw new Error(`Can not upcast ${t} with ${e}`)}return Fk[t][e]}function $k(t){return Pk(t,"int32")}function Bk(t){return null!=t&&"object"==typeof t&&"texture"in t&&t.texture instanceof WebGLTexture}function Vk(t){return"undefined"!=typeof GPUBuffer&&null!=t&&"object"==typeof t&&"buffer"in t&&t.buffer instanceof GPUBuffer} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Uk(t,e){if(t.dtype===e.dtype)return[t,e];const n=Pk(t.dtype,e.dtype);return[t.cast(n),e.cast(n)]}function Yk(t,e){yA(t.dtype===e.dtype,(()=>`The dtypes of the first(${t.dtype}) and second(${e.dtype}) input must match`))}function Gk(t,e){return e.some((e=>e.id===t.id))}function Hk(t){const e=[];return Wk(t,e,new Set),e}function Wk(t,e,n){if(null==t)return;if(t instanceof Ak)return void e.push(t);if(i=t,!Array.isArray(i)&&"object"!=typeof i)return;var i;const s=t;for(const t in s){const i=s[t];n.has(i)||(n.add(i),Wk(i,e,n))}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function zk(t){return null!=t.kernelName}class Xk{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((t=>t.name))))}}}dispose(){for(const t in this.registeredVariables)this.registeredVariables[t].dispose()}}class jk{constructor(t){this.ENV=t,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new Xk}async ready(){if(null!=this.pendingBackendInit)return this.pendingBackendInit.then((()=>{}));if(null!=this.backendInstance)return;const t=this.getSortedBackends();for(let e=0;e{null!=t.setupFunc&&t.setupFunc(this.backendInstance)}))}disposeRegisteredKernels(t){PN(t).forEach((e=>{null!=e.disposeFunc&&e.disposeFunc(this.registry[t])}))}initializeBackend(t){const e=this.registryFactory[t];if(null==e)throw new Error(`Cannot initialize backend ${t}, no registration found.`);try{const n=e.factory();if(!n||n instanceof uA||"function"!=typeof n.then)return this.registry[t]=n,{success:!0,asyncInit:!1};{const e=++this.pendingBackendInitId,i=n.then((n=>!(e(ethis.registryFactory[e].priority-this.registryFactory[t].priority))}initializeBackendsAndReturnBest(){const t=this.getSortedBackends();for(let e=0;ethis.startScope(i)),(()=>this.endScope(n)),(()=>(n=e(),n instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),n)))}scopedRun(t,e,n){t();try{const t=n();return e(),t}catch(t){throw e(),t}}nextTensorId(){return jk.nextTensorId++}nextVariableId(){return jk.nextVariableId++}clone(t){const e=Kk.runKernel(OM,{x:t}),n={x:t};return this.addTapeNode(this.state.activeScope.name,n,[e],(t=>({x:()=>{const e={x:t},n={dtype:"float32"};return Kk.runKernel(PO,e,n)}})),[],{}),e}runKernel(t,e,n){null==this.backendName&&this.backend;if(!(null!=LN(t,this.backendName)))throw new Error(`Kernel '${t}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:t,inputs:e,attrs:n})}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(t,e,n){const i=this.backend.numDataIds();let s=0;n.forEach((t=>{s+="complex64"===t.dtype?3:1}));const r=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],a=i-e-s-r;if(a>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${a} data ids) after running '${t}'`)}runKernelFunc(t){let e,n=[];const i=this.isTapeOn(),s=this.state.numBytes,r=this.state.numTensors;let a,o;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0),null==this.backendName&&this.backend;const l=zk(t)?t.kernelName:null!=this.state.activeScope?this.state.activeScope.name:"";if(zk(t)){const{kernelName:e,inputs:s,attrs:r}=t;null==this.backendName&&this.backend;const l=LN(e,this.backendName);yA(null!=l,(()=>`Cannot find registered kernel '${e}' for backend '${this.backendName}'`)),a=()=>{const t=this.backend.numDataIds();o=l.kernelFunc({inputs:s,attrs:r,backend:this.backend});const a=Array.isArray(o)?o:[o];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(e,t,a);const u=a.map((t=>null!=t.rank?t:this.makeTensorFromTensorInfo(t)));if(i){const t=this.getTensorsForGradient(e,s,u);n=this.saveTensorsForBackwardMode(t)}return u}}else{const{forwardFunc:e}=t,s=t=>{i&&(n=t.map((t=>this.keep(this.clone(t)))))};a=()=>{const t=this.backend.numDataIds();o=this.tidy((()=>e(this.backend,s)));const n=Array.isArray(o)?o:[o];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(l,t,n),n}}const{inputs:u,attrs:h}=t,p=zk(t)?null:t.backwardsFunc;let c;return this.scopedRun((()=>this.state.kernelDepth++),(()=>this.state.kernelDepth--),(()=>{this.ENV.getBool("DEBUG")||this.state.profiling?(c=this.profiler.profileKernel(l,u,(()=>a())),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(c),e=c.outputs):e=a()})),i&&this.addTapeNode(l,u,e,p,n,h),this.state.profiling&&this.state.activeProfile.kernels.push({name:l,bytesAdded:this.state.numBytes-s,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-r,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(u).map((t=>null!=u[t]?u[t].shape:null)),outputShapes:e.map((t=>t.shape)),kernelTimeMs:c.timeMs,extraInfo:c.extraInfo}),Array.isArray(o)?e:e[0]}saveTensorsForBackwardMode(t){const e=t.map((t=>this.keep(this.clone(t))));return e}getTensorsForGradient(t,e,n){const i=FN(t);if(null!=i){const t=i.inputsToSave||[],s=i.outputsToSave||[];let r;i.saveAllInputs?(yA(Array.isArray(e),(()=>"saveAllInputs is true, expected inputs to be an array.")),r=Object.keys(e).map((t=>e[t]))):r=t.map((t=>e[t]));const a=n.filter(((t,e)=>s[e]));return r.concat(a)}return[]}makeTensor(t,e,n,i){if(null==t)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",i=i||this.backend;let s=t;"string"===n&&YA(t[0])&&(s=t.map((t=>uk(t))));const r=i.write(s,e,n),a=new Ak(e,n,r,this.nextTensorId());if(this.trackTensor(a,i),"string"===n){const t=this.state.tensorInfo.get(r),e=UA(s);this.state.numBytes+=e-t.bytes,t.bytes=e}return a}makeTensorFromDataId(t,e,n,i){const s={dataId:t,shape:e,dtype:n=n||"float32"};return this.makeTensorFromTensorInfo(s,i)}makeTensorFromTensorInfo(t,e){const{dataId:n,shape:i,dtype:s}=t,r=new Ak(i,s,n,this.nextTensorId());return this.trackTensor(r,e),r}makeVariable(t,e=!0,n,i){n=n||this.nextVariableId().toString(),null!=i&&i!==t.dtype&&(t=t.cast(i));const s=new Mk(t,e,n,this.nextTensorId());if(null!=this.state.registeredVariables[s.name])throw new Error(`Variable with name ${s.name} was already registered`);return this.state.registeredVariables[s.name]=s,this.incRef(s,this.backend),s}trackTensor(t,e){this.state.numTensors++,"string"===t.dtype&&this.state.numStringTensors++;let n=0;"complex64"!==t.dtype&&"string"!==t.dtype&&(n=t.size*VA(t.dtype)),this.state.numBytes+=n,this.state.tensorInfo.has(t.dataId)||(this.state.numDataBuffers++,this.state.tensorInfo.set(t.dataId,{backend:e||this.backend,dtype:t.dtype,shape:t.shape,bytes:n})),t instanceof Mk||this.track(t)}incRef(t,e){this.trackTensor(t,e),this.backend.incRef(t.dataId)}removeDataId(t,e){this.state.tensorInfo.has(t)&&this.state.tensorInfo.get(t).backend===e&&(this.state.tensorInfo.delete(t),this.state.numDataBuffers--)}disposeTensor(t){if(!this.state.tensorInfo.has(t.dataId))return;const e=this.state.tensorInfo.get(t.dataId);if(this.state.numTensors--,"string"===t.dtype&&(this.state.numStringTensors--,this.state.numBytes-=e.bytes),"complex64"!==t.dtype&&"string"!==t.dtype){const e=t.size*VA(t.dtype);this.state.numBytes-=e}e.backend.disposeData(t.dataId)&&this.removeDataId(t.dataId,e.backend)}disposeVariables(){for(const t in this.state.registeredVariables){const e=this.state.registeredVariables[t];this.disposeVariable(e)}}disposeVariable(t){this.disposeTensor(t),null!=this.state.registeredVariables[t.name]&&delete this.state.registeredVariables[t.name]}memory(){const t=this.backend.memory();return t.numTensors=this.state.numTensors,t.numDataBuffers=this.state.numDataBuffers,t.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(t.unreliable=!0,null==t.reasons&&(t.reasons=[]),t.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),t}async profile(t){this.state.profiling=!0;const e=this.state.numBytes,n=this.state.numTensors;this.state.activeProfile.kernels=[],this.state.activeProfile.result=await t(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max(...this.state.activeProfile.kernels.map((t=>t.totalBytesSnapshot))),this.state.activeProfile.newBytes=this.state.numBytes-e,this.state.activeProfile.newTensors=this.state.numTensors-n;for(const t of this.state.activeProfile.kernels)t.kernelTimeMs=await t.kernelTimeMs,t.extraInfo=await t.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&0===this.state.kernelDepth}addTapeNode(t,e,n,i,s,r){const a={id:this.state.nextTapeNodeId++,kernelName:t,inputs:e,outputs:n,saved:s},o=FN(t);null!=o&&(i=o.gradFunc),null!=i&&(a.gradient=t=>(t=t.map(((t,e)=>{if(null==t){const t=n[e],i=ZA(t.size,t.dtype);return this.makeTensor(i,t.shape,t.dtype)}return t})),i(t.length>1?t:t[0],s,r))),this.state.activeTape.push(a)}keep(t){return t.kept=!0,t}startTape(){0===this.state.gradientDepth&&(this.state.activeTape=[]),this.state.gradientDepth++}endTape(){this.state.gradientDepth--}startScope(t){const e={track:[],name:"unnamed scope",id:this.state.nextScopeId++};t&&(e.name=t),this.state.scopeStack.push(e),this.state.activeScope=e}endScope(t){const e=Hk(t),n=new Set(e.map((t=>t.id)));for(let t=0;t{t.kept||t.scopeId!==i.id||this.track(t)}))}gradients(t,e,n,i=!1){if(yA(e.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 s=this.scopedRun((()=>this.startTape()),(()=>this.endTape()),(()=>this.tidy("forward",t)));yA(s instanceof Ak,(()=>"The result y returned by f() must be a tensor."));const r= /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n){const i={},s={};for(let t=0;ti[t.id]=!0)),o=!0,s[r.id]=!0;break}if(o)break}}const r={};r[n.id]=!0;const a={};for(let e=t.length-1;e>=0;e--){const n=t[e],i=n.inputs;for(let t=0;t0)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 t={};t[s.id]=null==n?function(t){const e=JA(bA(t),"float32");return Kk.makeTensor(e,t,"float32")}(s.shape):n,function(t,e,n,i){for(let s=e.length-1;s>=0;s--){const r=e[s],a=[];if(r.outputs.forEach((e=>{const n=t[e.id];null!=n?a.push(n):a.push(null)})),null==r.gradient)throw new Error(`Cannot compute gradient: gradient function not found for ${r.kernelName}.`);const o=r.gradient(a);for(const e in r.inputs){if(!(e in o))throw new Error(`Cannot backprop through input ${e}. Available gradients found: ${Object.keys(o)}.`);const s=n((()=>o[e]()));if("float32"!==s.dtype)throw new Error(`Error in gradient for op ${r.kernelName}. The gradient of input ${e} must have 'float32' dtype, but has '${s.dtype}'`);const a=r.inputs[e];if(!SA(s.shape,a.shape))throw new Error(`Error in gradient for op ${r.kernelName}. The gradient of input '${e}' has shape '${s.shape}', which does not match the shape of the input '${a.shape}'`);if(null==t[a.id])t[a.id]=s;else{const e=t[a.id];t[a.id]=i(e,s),e.dispose()}}}}(t,r,(t=>this.tidy(t)),Qk);const i=e.map((e=>t[e.id]));return 0===this.state.gradientDepth&&(this.state.activeTape.forEach((t=>{for(const e of t.saved)e.dispose()})),this.state.activeTape=null),{value:s,grads:i}}))}customGrad(t){return yA(zA(t),(()=>"The f passed in customGrad(f) must be a function.")),(...e)=>{let n;yA(e.every((t=>t instanceof Ak)),(()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors"));const i={};e.forEach(((t,e)=>{i[e]=t}));return this.runKernelFunc({forwardFunc:(i,s)=>(n=t(...e,s),yA(n.value instanceof Ak,(()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor")),yA(zA(n.gradFunc),(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function.")),n.value),backwardsFunc:(t,i)=>{const s=n.gradFunc(t,i),r=Array.isArray(s)?s:[s];yA(r.length===e.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(...).")),yA(r.every((t=>t instanceof Ak)),(()=>"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 a={};return r.forEach(((t,e)=>{a[e]=()=>t})),a},inputs:i})}}readSync(t){return this.state.tensorInfo.get(t).backend.readSync(t)}read(t){return this.state.tensorInfo.get(t).backend.read(t)}readToGPU(t,e){return this.state.tensorInfo.get(t).backend.readToGPU(t,e)}async time(t){const e=ok(),n=await this.backend.time(t);return n.wallMs=ok()-e,n}track(t){return null!=this.state.activeScope&&(t.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(t)),t}get registeredVariables(){return this.state.registeredVariables}reset(){this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new Xk;for(const t in this.registry)this.disposeRegisteredKernels(t),this.registry[t].dispose(),delete this.registry[t];this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null}}function qk(){const t=pO();if(null==t._tfengine){const e=new aO(t);t._tfengine=new jk(e)}var e;return e=t._tfengine.ENV,hO=e,Sk=()=>t._tfengine,t._tfengine}jk.nextTensorId=0,jk.nextVariableId=0;const Kk=qk();function Qk(t,e){const n={a:t,b:e};return Kk.runKernel(gO,n)}let Jk;function Zk(t){Jk=t}function tD(t){if(void 0!==Jk)return Jk;if(t||"undefined"!=typeof navigator&&null!=navigator){if(t||(t=navigator),"ReactNative"===t.product)return!0;const e=t.userAgent||t.vendor||("undefined"!=typeof window?window.opera:"");if(!e){const e=t;return e.userAgentData&&e.userAgentData.mobile}return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4))}return!1}function eD(){return"undefined"!=typeof window&&null!=window.document||"undefined"!=typeof WorkerGlobalScope} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const nD=lO(); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function iD(t,e){let n=t;if(pk(t))return"string"===e?[]:[t.length];if(Bk(t)){const e=t.channels||"RGBA";return[t.height,t.width*e.length]}if(Vk(t))return[t.buffer.size/(null==e?4:VA(e))];if(!Array.isArray(t))return[];const i=[];for(;Array.isArray(n)||pk(n)&&"string"!==e;)i.push(n.length),n=n[0];return Array.isArray(t)&&lO().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&sD(t,i,[]),i}function sD(t,e,n){if(n=n||[],!Array.isArray(t)&&!pk(t))return void yA(0===e.length,(()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${e[0]} elements`));yA(e.length>0,(()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${t.length} elements`)),yA(t.length===e[0],(()=>`Element arr[${n.join("][")}] should have ${e[0]} elements, but has ${t.length} elements`));const i=e.slice(1);for(let e=0;e=0&&(s=i),rD(i,s,e,n),null==t||!pk(t)&&!Array.isArray(t)&&"number"!=typeof t&&"boolean"!=typeof t&&"string"!=typeof t){const i=null==t?"null":t.constructor.name;throw new Error(`Argument '${e}' passed to '${n}' must be a Tensor or TensorLike, but got '${i}'`)}const r=iD(t,s);pk(t)||Array.isArray(t)||(t=[t]);const a="string"!==s?ak(t,s):ck(t,[],!0);return Kk.makeTensor(a,r,s)}function oD(t,e,n,i="numeric"){if(!Array.isArray(t))throw new Error(`Argument ${e} passed to ${n} must be a \`Tensor[]\` or \`TensorLike[]\``);return t.map(((t,s)=>aD(t,`${e}[${s}]`,n,i)))}nD.registerFlag("DEBUG",(()=>!1),(t=>{t&&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.")})),nD.registerFlag("IS_BROWSER",(()=>eD())),nD.registerFlag("IS_NODE",(()=>"undefined"!=typeof process&&void 0!==process.versions&&void 0!==process.versions.node)),nD.registerFlag("IS_CHROME",(()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor))),nD.registerFlag("IS_SAFARI",(()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Safari/.test(navigator.userAgent)&&/Apple/.test(navigator.vendor))),nD.registerFlag("PROD",(()=>!1)),nD.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",(()=>nD.getBool("DEBUG"))),nD.registerFlag("DEPRECATION_WARNINGS_ENABLED",(()=>!0)),nD.registerFlag("IS_TEST",(()=>!1)),nD.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",(()=>nD.getBool("DEBUG"))),nD.registerFlag("WRAP_TO_IMAGEBITMAP",(()=>!1)),nD.registerFlag("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU",(()=>!1)),nD.registerFlag("USE_SETTIMEOUTCUSTOM",(()=>!1)); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const lD="__op";function uD(t){const e=Object.keys(t);if(1!==e.length)throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${e.length} keys.`);let n=e[0];const i=t[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n+=lD;const s=(...t)=>{Kk.startScope(n);try{const e=i(...t);return sO(e)&&console.error("Cannot return a Promise inside of tidy."),Kk.endScope(e),e}catch(t){throw Kk.endScope(null),t}};return Object.defineProperty(s,"name",{value:n,configurable:!0}),s}const hD=uD({complex_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){const n=aD(t,"real","complex"),i=aD(e,"imag","complex");IA(n.shape,i.shape,`real and imag shapes, ${n.shape} and ${i.shape}, must match in call to tf.complex().`);const s={real:n,imag:i};return Kk.runKernel(VO,s)}}); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function pD(t,e,n,i){if(null==i)i=WA(t);else if("complex64"===i)throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(Vk(t)||Bk(t)){if("float32"!==i&&"int32"!==i)throw new Error(`Creating tensor from GPU data only supports 'float32'|'int32' dtype, while the dtype is ${i}.`);return Kk.backend.createTensorFromGPUData(t,e||n,i)}if(!pk(t)&&!Array.isArray(t)&&"number"!=typeof t&&"boolean"!=typeof t&&"string"!=typeof t)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!=e){eO(e);const t=bA(e),i=bA(n);yA(t===i,(()=>`Based on the provided shape, [${e}], the tensor should have ${t} values but has ${i}`));for(let t=0;t`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${e}). `))}}return pk(t)||Array.isArray(t)||(t=[t]),e=e||n,t="string"!==i?ak(t,i):ck(t,[],!0),Kk.makeTensor(t,e,i)} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function cD(t,e,n){return pD(t,e,iD(t,n),n)} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const dD={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8};class fD{static join(t){return new fD(t).slice()}constructor(t){if(this.shards=[],this.previousShardIndex=0,null==t)return;if(t instanceof Array||(t=[t]),0===(t=t.map((t=>pk(t)?t.buffer:t))).length)return;this.bufferUniformSize=t[0].byteLength;let e=0;for(let n=0;n=this.byteLength)return-1;if(null!=this.bufferUniformSize)return this.previousShardIndex=Math.floor(t/this.bufferUniformSize),this.previousShardIndex;function e(e){return t=e.end?1:0}if(0===e(this.shards[this.previousShardIndex]))return this.previousShardIndex;const n=function(t,e){let n=0,i=t.length;for(;n<=i;){const s=Math.floor((i-n)/2)+n,r=e(t[s]);if(0===r)return s;r<0?i=s:n=s+1}return-1}(this.shards,e);return-1===n?-1:(this.previousShardIndex=n,this.previousShardIndex)}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function mD(){lO().set("PROD",!0)}function gD(){lO().set("DEBUG",!0)}function _D(){lO().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function TD(t){lO().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(t+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}function yD(){Kk.disposeVariables()}function ID(){return Kk}function ED(){return Kk.memory()}function bD(t){return Kk.profile(t)}function vD(t,e){return Kk.tidy(t,e)}function wD(t){Hk(t).forEach((t=>t.dispose()))}function SD(t){return Kk.keep(t)}function xD(t){return Kk.time(t)}function RD(t){return Kk.setBackend(t)}function AD(){return Kk.ready()}function OD(){return Kk.backendName}function MD(t){Kk.removeBackend(t)}function CD(t){return Kk.findBackend(t)}function ND(t){return Kk.findBackendFactory(t)}function kD(t,e,n=1){return Kk.registerBackend(t,e,n)}function DD(){return Kk.backend}function LD(t,e){lO().setPlatform(t,e)}Rk=TD; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const FD=4;async function PD(t,e){const n=[],i=[],s=Array.isArray(t)?t.map((t=>t.name)):Object.keys(t);for(let r=0;r{const e=await o.bytes(),n=e.reduce(((t,e)=>t+e.length),0)+FD*e.length,i=new Uint8Array(n);let s=0;for(let t=0;tn.slice(s+t,s+e)));i[t.name]=UD(t,n.slice(s,s+e)),s+=e}return i}function BD(t,e){const n=bA(t.shape);let i;if("quantization"in t){const e=t.quantization;i=dD[e.dtype]}else{if("string"===t.dtype){let t=0;for(let i=0;i{let e=t<<13,n=0;for(;!(8388608&e);)n-=8388608,e<<=1;return e&=-8388609,n+=947912704,e|n},e=new Uint32Array(2048);e[0]=0;for(let n=1;n<1024;n++)e[n]=t(n);for(let t=1024;t<2048;t++)e[t]=939524096+(t-1024<<13);return e}(),e=function(){const t=new Uint32Array(64);t[0]=0,t[31]=1199570944,t[32]=2147483648,t[63]=3347054592;for(let e=1;e<31;e++)t[e]=e<<23;for(let e=33;e<63;e++)t[e]=2147483648+(e-32<<23);return t}(),n=function(){const t=new Uint32Array(64);for(let e=0;e<64;e++)t[e]=1024;return t[0]=t[32]=0,t}();return i=>{const s=new ArrayBuffer(4*i.length),r=new Uint32Array(s);for(let s=0;s>10]+(1023&a)]+e[a>>10];r[s]=o}return new Float32Array(s)}}();a=t(u)}}else{if("int32"!==i)throw new Error(`Unsupported dtype in weight '${n}': ${i}`);if("uint8"!==s.dtype&&"uint16"!==s.dtype)throw new Error(`Unsupported quantization type ${s.dtype} for weight type int32.`);a=new Int32Array(u.length);for(let t=0;t(s=await YD(i,s,e),s.slice(t,e))));s=await YD(i,s,e);const r=s.slice(0,e);s=s.slice(e);const a=UD(t,r);if(n[t.name]=a,"webgpu"===OD()){const t=DD();"uploadToGPU"in t&&bA(a.shape)>=lO().get("WEBGPU_CPU_HANDOFF_SIZE_THRESHOLD")&&t.uploadToGPU(a.dataId)}}return n}function HD(t){if(null===t)throw new Error(`Invalid input value: ${JSON.stringify(t)}`);let e=0;const n=[];t.forEach((t=>{if(e+=t.byteLength,n.push(t.byteLength===t.buffer.byteLength?t:new t.constructor(t)),!(t instanceof Float32Array||t instanceof Int32Array||t instanceof Uint8Array))throw new Error(`Unsupported TypedArray subtype: ${t.constructor.name}`)}));const i=new Uint8Array(e);let s=0;return n.forEach((t=>{i.set(new Uint8Array(t.buffer),s),s+=t.byteLength})),i.buffer}const WD="undefined"!=typeof Buffer&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function zD(t){return WD?Buffer.byteLength(t,"utf8"):new Blob([t]).size}function XD(t){return fD.join(t)}function jD(t){for(t=t.trim();t.endsWith("/");)t=t.slice(0,t.length-1);const e=t.split("/");return e[e.length-1]}function qD(t,e){const n={modelTopology:t.modelTopology,format:t.format,generatedBy:t.generatedBy,convertedBy:t.convertedBy,weightsManifest:e};return null!=t.signature&&(n.signature=t.signature),null!=t.userDefinedMetadata&&(n.userDefinedMetadata=t.userDefinedMetadata),null!=t.modelInitializer&&(n.modelInitializer=t.modelInitializer),null!=t.initializerSignature&&(n.initializerSignature=t.initializerSignature),null!=t.trainingConfig&&(n.trainingConfig=t.trainingConfig),n}function KD(t,e,n){const i={modelTopology:t.modelTopology,format:t.format,generatedBy:t.generatedBy,convertedBy:t.convertedBy};if(null!=t.trainingConfig&&(i.trainingConfig=t.trainingConfig),null!=t.weightsManifest){if(!e)throw new Error("modelJSON has weightsManifest but weightSpecs is null");if(!n)throw new Error("modelJSON has weightsManifest but weightData is null");i.weightSpecs=e,i.weightData=n}return null!=t.signature&&(i.signature=t.signature),null!=t.userDefinedMetadata&&(i.userDefinedMetadata=t.userDefinedMetadata),null!=t.modelInitializer&&(i.modelInitializer=t.modelInitializer),null!=t.initializerSignature&&(i.initializerSignature=t.initializerSignature),i}async function QD(t,e){let n,i;return null!=t.weightsManifest&&([n,i]=await e(t.weightsManifest)),KD(t,n,i)}function JD(t){if(t.modelTopology instanceof ArrayBuffer)throw new Error("Expected JSON model topology, received ArrayBuffer.");return{dateSaved:new Date,modelTopologyType:"JSON",modelTopologyBytes:null==t.modelTopology?0:zD(JSON.stringify(t.modelTopology)),weightSpecsBytes:null==t.weightSpecs?0:zD(JSON.stringify(t.weightSpecs)),weightDataBytes:null==t.weightData?0:new fD(t.weightData).byteLength}}function ZD(t){const e=[];for(const n of t)e.push(...n.weights);return e} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class tL{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return null==tL.instance&&(tL.instance=new tL),tL.instance}static registerSaveRouter(t){tL.getInstance().saveRouters.push(t)}static registerLoadRouter(t){tL.getInstance().loadRouters.push(t)}static getSaveHandlers(t){return tL.getHandlers(t,"save")}static getLoadHandlers(t,e){return tL.getHandlers(t,"load",e)}static getHandlers(t,e,n){const i=[];return("load"===e?tL.getInstance().loadRouters:tL.getInstance().saveRouters).forEach((e=>{const s=e(t,n);null!==s&&i.push(s)})),i}}const eL=t=>tL.registerSaveRouter(t),nL=t=>tL.registerLoadRouter(t),iL=t=>tL.getSaveHandlers(t),sL=(t,e)=>tL.getLoadHandlers(t,e),rL="tensorflowjs",aL="models_store",oL="model_info_store";function lL(){if(!lO().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");const t="undefined"==typeof window?self:window,e=t.indexedDB||t.mozIndexedDB||t.webkitIndexedDB||t.msIndexedDB||t.shimIndexedDB;if(null==e)throw new Error("The current browser does not appear to support IndexedDB.");return e}function uL(t){const e=t.result;e.createObjectStore(aL,{keyPath:"modelPath"}),e.createObjectStore(oL,{keyPath:"modelPath"})}class hL{constructor(t){if(this.indexedDB=lL(),null==t||!t)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=t}async save(t){if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return this.databaseAction(this.modelPath,t)}async load(){return this.databaseAction(this.modelPath)}databaseAction(t,e){return new Promise(((t,n)=>{const i=this.indexedDB.open(rL,1);i.onupgradeneeded=()=>uL(i),i.onsuccess=()=>{const s=i.result;if(null==e){const e=s.transaction(aL,"readonly"),i=e.objectStore(aL).get(this.modelPath);i.onsuccess=()=>{if(null==i.result)return s.close(),n(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));t(i.result.modelArtifacts)},i.onerror=t=>(s.close(),n(i.error)),e.oncomplete=()=>s.close()}else{e.weightData=fD.join(e.weightData);const i=JD(e),r=s.transaction(oL,"readwrite");let a,o,l=r.objectStore(oL);try{a=l.put({modelPath:this.modelPath,modelArtifactsInfo:i})}catch(t){return n(t)}a.onsuccess=()=>{o=s.transaction(aL,"readwrite");const a=o.objectStore(aL);let u;try{u=a.put({modelPath:this.modelPath,modelArtifacts:e,modelArtifactsInfo:i})}catch(t){return n(t)}u.onsuccess=()=>t({modelArtifactsInfo:i}),u.onerror=t=>{l=r.objectStore(oL);const e=l.delete(this.modelPath);e.onsuccess=()=>(s.close(),n(u.error)),e.onerror=t=>(s.close(),n(u.error))}},a.onerror=t=>(s.close(),n(a.error)),r.oncomplete=()=>{null==o?s.close():o.oncomplete=()=>s.close()}}},i.onerror=t=>n(i.error)}))}}hL.URL_SCHEME="indexeddb://";const pL=t=>{return lO().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(hL.URL_SCHEME)?(e=t.slice(hL.URL_SCHEME.length),new hL(e)):null;var e};tL.registerSaveRouter(pL),tL.registerLoadRouter(pL);class cL{constructor(){this.indexedDB=lL()}async listModels(){return new Promise(((t,e)=>{const n=this.indexedDB.open(rL,1);n.onupgradeneeded=()=>uL(n),n.onsuccess=()=>{const i=n.result,s=i.transaction(oL,"readonly"),r=s.objectStore(oL).getAll();r.onsuccess=()=>{const e={};for(const t of r.result)e[t.modelPath]=t.modelArtifactsInfo;t(e)},r.onerror=t=>(i.close(),e(r.error)),s.oncomplete=()=>i.close()},n.onerror=t=>e(n.error)}))}async removeModel(t){var e;return t=(e=t).startsWith(hL.URL_SCHEME)?e.slice(hL.URL_SCHEME.length):e,new Promise(((e,n)=>{const i=this.indexedDB.open(rL,1);i.onupgradeneeded=()=>uL(i),i.onsuccess=()=>{const s=i.result,r=s.transaction(oL,"readwrite"),a=r.objectStore(oL),o=a.get(t);let l;o.onsuccess=()=>{if(null==o.result)return s.close(),n(new Error(`Cannot find model with path '${t}' in IndexedDB.`));{const i=a.delete(t),r=()=>{l=s.transaction(aL,"readwrite");const i=l.objectStore(aL).delete(t);i.onsuccess=()=>e(o.result.modelArtifactsInfo),i.onerror=t=>n(o.error)};i.onsuccess=r,i.onerror=t=>(r(),s.close(),n(o.error))}},o.onerror=t=>(s.close(),n(o.error)),r.oncomplete=()=>{null==l?s.close():l.oncomplete=()=>s.close()}},i.onerror=t=>n(i.error)}))}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const dL="/",fL="tensorflowjs_models",mL="info",gL="model_topology",_L="weight_specs",TL="weight_data",yL="model_metadata";function IL(t){return{info:[fL,t,mL].join(dL),topology:[fL,t,gL].join(dL),weightSpecs:[fL,t,_L].join(dL),weightData:[fL,t,TL].join(dL),modelMetadata:[fL,t,yL].join(dL)}}function EL(t){for(const e of Object.values(t))window.localStorage.removeItem(e)}function bL(t){const e=t.split(dL);if(e.length<3)throw new Error(`Invalid key format: ${t}`);return e.slice(1,e.length-1).join(dL)}class vL{constructor(t){if(!lO().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==t||!t)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=t,this.keys=IL(this.modelPath)}async save(t){if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");{const e=JSON.stringify(t.modelTopology),n=JSON.stringify(t.weightSpecs),i=JD(t),s=fD.join(t.weightData);try{this.LS.setItem(this.keys.info,JSON.stringify(i)),this.LS.setItem(this.keys.topology,e),this.LS.setItem(this.keys.weightSpecs,n),this.LS.setItem(this.keys.weightData,function(t){if(WD)return Buffer.from(t).toString("base64");const e=new Uint8Array(t);let n="";for(let t=0,i=e.length;t{return lO().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(vL.URL_SCHEME)?(e=t.slice(vL.URL_SCHEME.length),new vL(e)):null;var e};tL.registerSaveRouter(wL),tL.registerLoadRouter(wL);class SL{constructor(){yA(lO().getBool("IS_BROWSER"),(()=>"Current environment is not a web browser")),yA("undefined"==typeof window||void 0!==window.localStorage,(()=>"Current browser does not appear to support localStorage")),this.LS=window.localStorage}async listModels(){const t={},e=fL+dL,n=dL+mL;for(let i=0;i"scheme must not be undefined or null.")),t.endsWith(xL)&&(t=t.slice(0,t.indexOf(xL))),yA(t.length>0,(()=>"scheme must not be an empty string."));const n=RL.getInstance();yA(null==n.managers[t],(()=>`A model store manager is already registered for scheme '${t}'.`)),n.managers[t]=e}static getManager(t){const e=RL.getInstance().managers[t];if(null==e)throw new Error(`Cannot find model manager for scheme '${t}'`);return e}static getSchemes(){return Object.keys(RL.getInstance().managers)}}function AL(t){if(-1===t.indexOf(xL))throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${RL.getSchemes().join(",")}`);return{scheme:t.split(xL)[0],path:t.split(xL)[1]}}async function OL(t,e,n=!1){yA(t!==e,(()=>`Old path and new path are the same: '${t}'`));const i=tL.getLoadHandlers(t);yA(i.length>0,(()=>`Copying failed because no load handler is found for source URL ${t}.`)),yA(i.length<2,(()=>`Copying failed because more than one (${i.length}) load handlers for source URL ${t}.`));const s=i[0],r=tL.getSaveHandlers(e);yA(r.length>0,(()=>`Copying failed because no save handler is found for destination URL ${e}.`)),yA(r.length<2,(()=>`Copying failed because more than one (${i.length}) save handlers for destination URL ${e}.`));const a=r[0],o=AL(t).scheme,l=AL(t).path,u=o===AL(t).scheme,h=await s.load();n&&u&&await RL.getManager(o).removeModel(l);const p=await a.save(h);return n&&!u&&await RL.getManager(o).removeModel(l),p.modelArtifactsInfo}async function ML(){const t=RL.getSchemes(),e={};for(const n of t){const t=await RL.getManager(n).listModels();for(const i in t){e[n+xL+i]=t[i]}}return e}async function CL(t){const e=AL(t);return RL.getManager(e.scheme).removeModel(e.path)}async function NL(t,e){return OL(t,e,!1)}async function kL(t,e){return OL(t,e,!0)} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class DL{constructor(){this.messageName="setTimeoutCustom",this.functionRefs=[],this.handledMessageCount=0,this.hasEventListener=!1}fetch(t,e){return fetch(t,e)}now(){return performance.now()}encode(t,e){if("utf-8"!==e&&"utf8"!==e)throw new Error(`Browser's encoder only supports utf-8, but got ${e}`);return null==this.textEncoder&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(t)}decode(t,e){return new TextDecoder(e).decode(t)}setTimeoutCustom(t,e){"undefined"!=typeof window&&lO().getBool("USE_SETTIMEOUTCUSTOM")?(this.functionRefs.push(t),setTimeout((()=>{window.postMessage({name:this.messageName,index:this.functionRefs.length-1},"*")}),e),this.hasEventListener||(this.hasEventListener=!0,window.addEventListener("message",(t=>{if(t.source===window&&t.data.name===this.messageName){t.stopPropagation();(0,this.functionRefs[t.data.index])(),this.handledMessageCount++,this.handledMessageCount===this.functionRefs.length&&(this.functionRefs=[],this.handledMessageCount=0)}}),!0))):setTimeout(t,e)}isTypedArray(t){return HN(t)}}if(lO().get("IS_BROWSER")){lO().setPlatform("browser",new DL);try{RL.registerManager(vL.URL_SCHEME,new SL)}catch(t){}try{RL.registerManager(hL.URL_SCHEME,new cL)}catch(t){}} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const LL=()=>__webpack_require__(5817);let FL;class PL{constructor(){this.util=__webpack_require__(8590),this.textEncoder=new this.util.TextEncoder}fetch(t,e){return null!=lO().global.fetch?lO().global.fetch(t,e):(null==FL&&(FL=LL()),FL(t,e))}now(){const t=process.hrtime();return 1e3*t[0]+t[1]/1e6}encode(t,e){if("utf-8"!==e&&"utf8"!==e)throw new Error(`Node built-in encoder only supports utf-8, but got ${e}`);return this.textEncoder.encode(t)}decode(t,e){return 0===t.length?"":new this.util.TextDecoder(e).decode(t)}isTypedArray(t){return this.util.types.isFloat32Array(t)||this.util.types.isInt32Array(t)||this.util.types.isUint8Array(t)||this.util.types.isUint8ClampedArray(t)}} /** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function $L(t,e="float32",n){return e=e||"float32",eO(t),new wk(t,e,n)}lO().get("IS_NODE")&&!lO().get("IS_BROWSER")&&lO().setPlatform("node",new PL);const BL=uD({cast_: /** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){const n=aD(t,"x","cast");if(!$A(e))throw new Error(`Failed to cast to unknown dtype ${e}`);if("string"===e&&"string"!==n.dtype||"string"!==e&&"string"===n.dtype)throw new Error("Only strings can be casted to strings");const i={x:n},s={dtype:e};return Kk.runKernel(PO,i,s)}});const VL=uD({clone_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={x:aD(t,"x","clone","string_or_numeric")};return Kk.runKernel(OM,e)}}); /** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function UL(t,e=!1){console.log(t.toString(e))} /** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ qk();xk={buffer:$L,cast:BL,clone:VL,print:UL};const YL=uD({add_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){let n=aD(t,"a","add"),i=aD(e,"b","add");[n,i]=Uk(n,i);const s={a:n,b:i};return Kk.runKernel(gO,s)}});const GL=uD({floorDiv_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){let n=aD(t,"a","floorDiv"),i=aD(e,"b","floorDiv");[n,i]=Uk(n,i);const s={a:n,b:i};return Kk.runKernel(vM,s)}});const HL=uD({div_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){let n=aD(t,"a","div"),i=aD(e,"b","div");if([n,i]=Uk(n,i),"int32"===n.dtype&&"int32"===i.dtype)return GL(n,i);const s={a:n,b:i};return Kk.runKernel(hM,s,{})}});const WL=uD({mul_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){let n=aD(t,"a","mul"),i=aD(e,"b","mul");[n,i]=Uk(n,i);const s={a:n,b:i};return Kk.runKernel(uC,s)}});const zL=uD({sqrt_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={x:aD(t,"x","sqrt","float32")};return Kk.runKernel(KC,e)}});const XL=uD({square_: /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e=aD(t,"x","square");return Kk.runKernel("Square",{x:e},{})}});const jL=uD({zerosLike_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={x:aD(t,"x","zerosLike")};return Kk.runKernel(wN,e)}}); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function qL(t){return yA(zA(t),(()=>"The f passed in grad(f) must be a function")),(e,n)=>{const i=aD(e,"x","tf.grad","string_or_numeric"),s=null!=n?aD(n,"dy","tf.grad"):null;return Kk.tidy((()=>{const{value:e,grads:n}=Kk.gradients((()=>t(i)),[i],s);return null!=s&&IA(e.shape,s.shape,"The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"),eF(n),n[0]}))}}function KL(t){return yA(zA(t),(()=>"The f passed in grads(f) must be a function")),(e,n)=>{yA(Array.isArray(e),(()=>"The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s"));const i=oD(e,"args","tf.grads","string_or_numeric"),s=null!=n?aD(n,"dy","tf.grads"):null;return Kk.tidy((()=>{const{value:e,grads:n}=Kk.gradients((()=>t(...i)),i,s);return null!=s&&IA(e.shape,s.shape,"The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),eF(n),n}))}}function QL(t){return yA(zA(t),(()=>"The f passed in valueAndGrad(f) must be a function")),(e,n)=>{yA(e instanceof Ak,(()=>"The x passed in valueAndGrad(f)(x) must be a tensor")),yA(null==n||n instanceof Ak,(()=>"The dy passed in valueAndGrad(f)(x, dy) must be a tensor"));const{grads:i,value:s}=Kk.gradients((()=>t(e)),[e],n);return eF(i),{grad:i[0],value:s}}}function JL(t){return yA(zA(t),(()=>"The f passed in valueAndGrads(f) must be a function")),(e,n)=>{yA(Array.isArray(e)&&e.every((t=>t instanceof Ak)),(()=>"The args passed in valueAndGrads(f)(args) must be array of tensors")),yA(null==n||n instanceof Ak,(()=>"The dy passed in valueAndGrads(f)(args, dy) must be a tensor"));const i=Kk.gradients((()=>t(...e)),e,n);return null!=n&&IA(i.value.shape,n.shape,"The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),eF(i.grads),i}}function ZL(t,e){yA(zA(t),(()=>"The f passed in variableGrads(f) must be a function")),yA(null==e||Array.isArray(e)&&e.every((t=>t instanceof Mk)),(()=>"The varList passed in variableGrads(f, varList) must be an array of variables"));const n=null!=e;if(!n){e=[];for(const t in Kk.registeredVariables)e.push(Kk.registeredVariables[t])}const i=n?e.filter((t=>!t.trainable)):null,s=e.length;e=e.filter((t=>t.trainable)),yA(e.length>0,(()=>`variableGrads() expects at least one of the input variables to be trainable, but none of the ${s} variables is trainable.`));const{value:r,grads:a}=Kk.gradients(t,e,null,!0);yA(a.some((t=>null!=t)),(()=>"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().")),yA(0===r.rank,(()=>`The f passed in variableGrads(f) must return a scalar, but it returned a rank-${r.rank} tensor`));const o={};return e.forEach(((t,e)=>{null!=a[e]&&(o[t.name]=a[e])})),null!=i&&i.forEach((t=>o[t.name]=null)),{value:r,grads:o}}function tF(t){return Kk.customGrad(t)}function eF(t){if(t.filter((t=>null==t)).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.")} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function nF(t,e){if((pk(t)&&"string"!==e||Array.isArray(t))&&"complex64"!==e)throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");if("string"===e&&pk(t)&&!(t instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return pD(t,[],[],e)} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const iF=new Map,sF=new Map;class rF{getClassName(){return this.constructor.className}static fromConfig(t,e){return new t(e)}}class aF{constructor(){this.classNameMap={}}static getMap(){return null==aF.instance&&(aF.instance=new aF),aF.instance}static register(t){aF.getMap().classNameMap[t.className]=[t,t.fromConfig]}}function oF(t,e,n){yA(null!=t.className,(()=>"Class being registered does not have the static className property defined.")),yA("string"==typeof t.className,(()=>"className is required to be a string, but got type "+typeof t.className)),yA(t.className.length>0,(()=>"Class being registered has an empty-string as its className, which is disallowed.")),void 0===e&&(e="Custom"),void 0===n&&(n=t.className);const i=e+">"+n;return aF.register(t),iF.set(i,t),sF.set(t,i),t}function lF(t){return sF.has(t)?sF.get(t):t.className} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class uF extends rF{minimize(t,e=!1,n){const{value:i,grads:s}=this.computeGradients(t,n);if(null!=n){const t=n.map((t=>({name:t.name,tensor:s[t.name]})));this.applyGradients(t)}else this.applyGradients(s);return wD(s),e?i:(i.dispose(),null)}get iterations(){return null==this.iterations_&&(this.iterations_=0),this.iterations_}incrementIterations(){this.iterations_=this.iterations+1}computeGradients(t,e){return ZL(t,e)}dispose(){null!=this.iterations_&&wD(this.iterations_)}async saveIterations(){return null==this.iterations_&&(this.iterations_=0),{name:"iter",tensor:nF(this.iterations_,"int32")}}async getWeights(){throw new Error("getWeights() is not implemented for this optimizer yet.")}async setWeights(t){throw new Error(`setWeights() is not implemented for this optimizer class ${this.getClassName()}`)}async extractIterations(t){return this.iterations_=(await t[0].tensor.data())[0],t.slice(1)}}Object.defineProperty(uF,Symbol.hasInstance,{value:t=>null!=t.minimize&&null!=t.computeGradients&&null!=t.applyGradients}); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class hF extends uF{static get className(){return"Adadelta"}constructor(t,e,n=null){super(),this.learningRate=t,this.rho=e,this.epsilon=n,this.accumulatedGrads=[],this.accumulatedUpdates=[],null==n&&(this.epsilon=Kk.backend.epsilon())}applyGradients(t){(Array.isArray(t)?t.map((t=>t.name)):Object.keys(t)).forEach(((e,n)=>{const i=Kk.registeredVariables[e],s=!1;null==this.accumulatedGrads[n]&&(this.accumulatedGrads[n]={originalName:`${e}/accum_grad`,variable:vD((()=>jL(i).variable(s)))}),null==this.accumulatedUpdates[n]&&(this.accumulatedUpdates[n]={originalName:`${e}/accum_var`,variable:vD((()=>jL(i).variable(s)))});const r=Array.isArray(t)?t[n].tensor:t[e];if(null==r)return;const a=this.accumulatedGrads[n].variable,o=this.accumulatedUpdates[n].variable;vD((()=>{const t=YL(WL(a,this.rho),WL(XL(r),1-this.rho)),e=WL(HL(zL(YL(o,this.epsilon)),zL(YL(a,this.epsilon))),r),n=YL(WL(o,this.rho),WL(XL(e),1-this.rho));a.assign(t),o.assign(n);const s=YL(WL(e,-this.learningRate),i);i.assign(s)}))})),this.incrementIterations()}dispose(){null!=this.accumulatedUpdates&&(wD(this.accumulatedGrads.map((t=>t.variable))),wD(this.accumulatedUpdates.map((t=>t.variable))))}async getWeights(){const t=[...this.accumulatedGrads,...this.accumulatedUpdates];return[await this.saveIterations()].concat(t.map((t=>({name:t.originalName,tensor:t.variable}))))}async setWeights(t){const e=(t=await this.extractIterations(t)).length/2,n=!1;this.accumulatedGrads=t.slice(0,e).map((t=>({originalName:t.name,variable:t.tensor.variable(n)}))),this.accumulatedUpdates=t.slice(e,2*e).map((t=>({originalName:t.name,variable:t.tensor.variable(n)})))}getConfig(){return{learningRate:this.learningRate,rho:this.rho,epsilon:this.epsilon}}static fromConfig(t,e){return new t(e.learningRate,e.rho,e.epsilon)}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function pF(t,e,n){eO(t);const i={shape:t,value:e,dtype:n=n||WA(e)};return Kk.runKernel(IM,{},i)} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class cF extends uF{static get className(){return"Adagrad"}constructor(t,e=.1){super(),this.learningRate=t,this.initialAccumulatorValue=e,this.accumulatedGrads=[]}applyGradients(t){(Array.isArray(t)?t.map((t=>t.name)):Object.keys(t)).forEach(((e,n)=>{const i=Kk.registeredVariables[e];if(null==this.accumulatedGrads[n]){const t=!1;this.accumulatedGrads[n]={originalName:`${e}/accumulator`,variable:vD((()=>pF(i.shape,this.initialAccumulatorValue).variable(t)))}}const s=Array.isArray(t)?t[n].tensor:t[e];if(null==s)return;const r=this.accumulatedGrads[n].variable;vD((()=>{const t=YL(r,XL(s));r.assign(t);const e=YL(WL(HL(s,zL(YL(t,Kk.backend.epsilon()))),-this.learningRate),i);i.assign(e)}))})),this.incrementIterations()}dispose(){null!=this.accumulatedGrads&&wD(this.accumulatedGrads.map((t=>t.variable)))}async getWeights(){return[await this.saveIterations()].concat(this.accumulatedGrads.map((t=>({name:t.originalName,tensor:t.variable}))))}async setWeights(t){t=await this.extractIterations(t);this.accumulatedGrads=t.map((t=>({originalName:t.name,variable:t.tensor.variable(false)})))}getConfig(){return{learningRate:this.learningRate,initialAccumulatorValue:this.initialAccumulatorValue}}static fromConfig(t,e){return new t(e.learningRate,e.initialAccumulatorValue)}}const dF=uD({pow_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){let n=aD(t,"base","pow"),i=aD(e,"exp","pow");[n,i]=Uk(n,i);const s={a:n,b:i};return Kk.runKernel(IC,s)}});const fF=uD({sub_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){let n=aD(t,"a","sub"),i=aD(e,"b","sub");[n,i]=Uk(n,i);const s={a:n,b:i};return Kk.runKernel(dN,s)}}); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class mF extends uF{static get className(){return"Adam"}constructor(t,e,n,i=null){super(),this.learningRate=t,this.beta1=e,this.beta2=n,this.epsilon=i,this.accumulatedFirstMoment=[],this.accumulatedSecondMoment=[],vD((()=>{this.accBeta1=nF(e).variable(),this.accBeta2=nF(n).variable()})),null==i&&(this.epsilon=Kk.backend.epsilon())}applyGradients(t){const e=Array.isArray(t)?t.map((t=>t.name)):Object.keys(t);vD((()=>{const n=fF(1,this.accBeta1),i=fF(1,this.accBeta2);e.forEach(((e,s)=>{const r=Kk.registeredVariables[e],a=!1;null==this.accumulatedFirstMoment[s]&&(this.accumulatedFirstMoment[s]={originalName:`${e}/m`,variable:vD((()=>jL(r).variable(a)))}),null==this.accumulatedSecondMoment[s]&&(this.accumulatedSecondMoment[s]={originalName:`${e}/v`,variable:vD((()=>jL(r).variable(a)))});const o=Array.isArray(t)?t[s].tensor:t[e];if(null==o)return;const l=this.accumulatedFirstMoment[s].variable,u=this.accumulatedSecondMoment[s].variable,h=YL(WL(l,this.beta1),WL(o,1-this.beta1)),p=YL(WL(u,this.beta2),WL(XL(o),1-this.beta2)),c=HL(h,n),d=HL(p,i);l.assign(h),u.assign(p);const f=YL(WL(HL(c,YL(zL(d),this.epsilon)),-this.learningRate),r);r.assign(f)})),this.accBeta1.assign(WL(this.accBeta1,this.beta1)),this.accBeta2.assign(WL(this.accBeta2,this.beta2))})),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.accBeta2.dispose(),null!=this.accumulatedFirstMoment&&wD(this.accumulatedFirstMoment.map((t=>t.variable))),null!=this.accumulatedSecondMoment&&wD(this.accumulatedSecondMoment.map((t=>t.variable)))}async getWeights(){const t=[...this.accumulatedFirstMoment,...this.accumulatedSecondMoment];return[await this.saveIterations()].concat(t.map((t=>({name:t.originalName,tensor:t.variable}))))}async setWeights(t){t=await this.extractIterations(t),vD((()=>{this.accBeta1.assign(dF(this.beta1,this.iterations_+1)),this.accBeta2.assign(dF(this.beta2,this.iterations_+1))}));const e=t.length/2,n=!1;this.accumulatedFirstMoment=t.slice(0,e).map((t=>({originalName:t.name,variable:t.tensor.variable(n)}))),this.accumulatedSecondMoment=t.slice(e,2*e).map((t=>({originalName:t.name,variable:t.tensor.variable(n)})))}getConfig(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon}}static fromConfig(t,e){return new t(e.learningRate,e.beta1,e.beta2,e.epsilon)}}const gF=uD({abs_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e=aD(t,"x","abs");if("complex64"===e.dtype){const t={x:e};return Kk.runKernel(UO,t)}{const t={x:e};return Kk.runKernel(dO,t)}}}); /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function _F(t,e){const n=t.length,i=[];for(let s=0;s1&&1===a&&i.unshift(r)}return i}function TF(t,e){const n=[];for(let i=0;i1)&&n.unshift(r)}return n}function yF(t,e){const n=Math.max(t.length,e.length),i=new Array(n);for(let s=0;s{this.iteration=nF(0).variable(),this.accBeta1=nF(e).variable()})),null==i&&(this.epsilon=Kk.backend.epsilon())}applyGradients(t){const e=Array.isArray(t)?t.map((t=>t.name)):Object.keys(t);vD((()=>{const n=fF(1,this.accBeta1),i=HL(-this.learningRate,YL(WL(this.iteration,this.decay),1));e.forEach(((e,s)=>{const r=Kk.registeredVariables[e],a=!1;null==this.accumulatedFirstMoment[s]&&(this.accumulatedFirstMoment[s]={originalName:`${e}/m`,variable:jL(r).variable(a)}),null==this.accumulatedWeightedInfNorm[s]&&(this.accumulatedWeightedInfNorm[s]={originalName:`${e}/v`,variable:jL(r).variable(a)});const o=Array.isArray(t)?t[s].tensor:t[e];if(null==o)return;const l=this.accumulatedFirstMoment[s].variable,u=this.accumulatedWeightedInfNorm[s].variable,h=YL(WL(l,this.beta1),WL(o,1-this.beta1)),p=WL(u,this.beta2),c=gF(o),d=IF(p,c);l.assign(h),u.assign(d);const f=YL(WL(HL(i,n),HL(h,YL(d,this.epsilon))),r);r.assign(f)})),this.iteration.assign(YL(this.iteration,1)),this.accBeta1.assign(WL(this.accBeta1,this.beta1))})),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.iteration.dispose(),null!=this.accumulatedFirstMoment&&wD(this.accumulatedFirstMoment.map((t=>t.variable))),null!=this.accumulatedWeightedInfNorm&&wD(this.accumulatedWeightedInfNorm.map((t=>t.variable)))}async getWeights(){throw new Error("getWeights() is not implemented for Adamax yet.")}async setWeights(t){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(t,e){return new t(e.learningRate,e.beta1,e.beta2,e.epsilon,e.decay)}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class bF extends uF{static get className(){return"SGD"}constructor(t){super(),this.learningRate=t,this.setLearningRate(t)}applyGradients(t){(Array.isArray(t)?t.map((t=>t.name)):Object.keys(t)).forEach(((e,n)=>{const i=Array.isArray(t)?t[n].tensor:t[e];if(null==i)return;const s=Kk.registeredVariables[e];vD((()=>{const t=YL(WL(this.c,i),s);s.assign(t)}))})),this.incrementIterations()}setLearningRate(t){this.learningRate=t,null!=this.c&&this.c.dispose(),this.c=SD(nF(-t))}dispose(){this.c.dispose()}async getWeights(){return[await this.saveIterations()]}async setWeights(t){if(0!==(t=await this.extractIterations(t)).length)throw new Error("SGD optimizer does not have settable weights.")}getConfig(){return{learningRate:this.learningRate}}static fromConfig(t,e){return new t(e.learningRate)}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class vF extends bF{static get className(){return"Momentum"}constructor(t,e,n=!1){super(t),this.learningRate=t,this.momentum=e,this.useNesterov=n,this.accumulations=[],this.m=nF(this.momentum)}applyGradients(t){(Array.isArray(t)?t.map((t=>t.name)):Object.keys(t)).forEach(((e,n)=>{const i=Kk.registeredVariables[e];if(null==this.accumulations[n]){const t=!1;this.accumulations[n]={originalName:`${e}/momentum`,variable:vD((()=>jL(i).variable(t)))}}const s=this.accumulations[n].variable,r=Array.isArray(t)?t[n].tensor:t[e];null!=r&&vD((()=>{let t;const e=YL(WL(this.m,s),r);t=this.useNesterov?YL(WL(this.c,YL(r,WL(e,this.m))),i):YL(WL(this.c,e),i),s.assign(e),i.assign(t)}))})),this.incrementIterations()}dispose(){this.m.dispose(),null!=this.accumulations&&wD(this.accumulations.map((t=>t.variable)))}setMomentum(t){this.momentum=t}async getWeights(){return[await this.saveIterations()].concat(this.accumulations.map((t=>({name:t.originalName,tensor:t.variable}))))}async setWeights(t){t=await this.extractIterations(t);this.accumulations=t.map((t=>({originalName:t.name,variable:t.tensor.variable(false)})))}getConfig(){return{learningRate:this.learningRate,momentum:this.momentum,useNesterov:this.useNesterov}}static fromConfig(t,e){return new t(e.learningRate,e.momentum,e.useNesterov)}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class wF extends uF{static get className(){return"RMSProp"}constructor(t,e=.9,n=0,i=null,s=!1){if(super(),this.learningRate=t,this.decay=e,this.momentum=n,this.epsilon=i,this.accumulatedMeanSquares=[],this.accumulatedMoments=[],this.accumulatedMeanGrads=[],this.centered=s,null==i&&(this.epsilon=Kk.backend.epsilon()),null==t)throw new Error("learningRate for RMSPropOptimizer must be defined.")}applyGradients(t){(Array.isArray(t)?t.map((t=>t.name)):Object.keys(t)).forEach(((e,n)=>{const i=Kk.registeredVariables[e],s=!1;null==this.accumulatedMeanSquares[n]&&(this.accumulatedMeanSquares[n]={originalName:`${e}/rms`,variable:vD((()=>jL(i).variable(s)))}),null==this.accumulatedMoments[n]&&(this.accumulatedMoments[n]={originalName:`${e}/momentum`,variable:vD((()=>jL(i).variable(s)))}),null==this.accumulatedMeanGrads[n]&&this.centered&&(this.accumulatedMeanGrads[n]={originalName:`${e}/mg`,variable:vD((()=>jL(i).variable(s)))});const r=Array.isArray(t)?t[n].tensor:t[e];if(null==r)return;const a=this.accumulatedMeanSquares[n].variable,o=this.accumulatedMoments[n].variable;vD((()=>{const t=YL(WL(a,this.decay),WL(XL(r),1-this.decay));if(this.centered){const e=this.accumulatedMeanGrads[n].variable,s=YL(WL(e,this.decay),WL(r,1-this.decay)),l=HL(WL(r,this.learningRate),zL(fF(t,YL(XL(s),this.epsilon)))),u=YL(WL(o,this.momentum),l);a.assign(t),e.assign(s),o.assign(u);const h=fF(i,u);i.assign(h)}else{const t=YL(WL(a,this.decay),WL(XL(r),1-this.decay)),e=YL(WL(o,this.momentum),HL(WL(r,this.learningRate),zL(YL(t,this.epsilon))));a.assign(t),o.assign(e);const n=fF(i,e);i.assign(n)}}))})),this.incrementIterations()}dispose(){null!=this.accumulatedMeanSquares&&wD(this.accumulatedMeanSquares.map((t=>t.variable))),null!=this.accumulatedMeanGrads&&this.centered&&wD(this.accumulatedMeanGrads.map((t=>t.variable))),null!=this.accumulatedMoments&&wD(this.accumulatedMoments.map((t=>t.variable)))}async getWeights(){const t=[...this.accumulatedMeanSquares,...this.accumulatedMoments];return this.centered&&t.push(...this.accumulatedMeanGrads),[await this.saveIterations()].concat(t.map((t=>({name:t.originalName,tensor:t.variable}))))}async setWeights(t){t=await this.extractIterations(t);const e=this.centered?t.length/3:t.length/2,n=!1;this.accumulatedMeanSquares=t.slice(0,e).map((t=>({originalName:t.name,variable:t.tensor.variable(n)}))),this.accumulatedMoments=t.slice(e,2*e).map((t=>({originalName:t.name,variable:t.tensor.variable(n)}))),this.centered&&(this.accumulatedMeanGrads=t.slice(2*e,3*e).map((t=>({originalName:t.name,variable:t.tensor.variable(n)}))))}getConfig(){return{learningRate:this.learningRate,decay:this.decay,momentum:this.momentum,epsilon:this.epsilon,centered:this.centered}}static fromConfig(t,e){return new t(e.learningRate,e.decay,e.momentum,e.epsilon,e.centered)}} /** * @license * Copyright 2022 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const SF=[hF,cF,mF,EF,vF,wF,bF];function xF(t){return new Promise((t=>setTimeout(t))).then(t)}class RF{constructor(t){if(!lO().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");t.startsWith(RF.URL_SCHEME)&&(t=t.slice(RF.URL_SCHEME.length)),null!=t&&0!==t.length||(t="model"),this.modelJsonFileName=t+".json",this.weightDataFileName=t+".weights.bin"}async save(t){if("undefined"==typeof document)throw new Error("Browser downloads are not supported in this environment since `document` is not present");const e=fD.join(t.weightData),n=window.URL.createObjectURL(new Blob([e],{type:"application/octet-stream"}));if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet.");{const e=qD(t,[{paths:["./"+this.weightDataFileName],weights:t.weightSpecs}]),i=window.URL.createObjectURL(new Blob([JSON.stringify(e)],{type:"application/json"})),s=null==this.modelJsonAnchor?document.createElement("a"):this.modelJsonAnchor;if(s.download=this.modelJsonFileName,s.href=i,await xF((()=>s.dispatchEvent(new MouseEvent("click")))),null!=t.weightData){const t=null==this.weightDataAnchor?document.createElement("a"):this.weightDataAnchor;t.download=this.weightDataFileName,t.href=n,await xF((()=>t.dispatchEvent(new MouseEvent("click"))))}return{modelArtifactsInfo:JD(t)}}}}RF.URL_SCHEME="downloads://";class AF{constructor(t){if(null==t||t.length<1)throw new Error(`When calling browserFiles, at least 1 file is required, but received ${t}`);this.jsonFile=t[0],this.weightsFiles=t.slice(1)}async load(){return new Promise(((t,e)=>{const n=new FileReader;n.onload=n=>{const i=JSON.parse(n.target.result),s=i.modelTopology;if(null==s)return void e(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`));if(null==i.weightsManifest)return void e(new Error(`weightManifest field is missing from file ${this.jsonFile.name}`));if(0===this.weightsFiles.length)return void t({modelTopology:s});const r=QD(i,(t=>this.loadWeights(t)));t(r)},n.onerror=t=>e(`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(t){const e=[],n=[];for(const i of t)e.push(...i.weights),n.push(...i.paths);const i=this.checkManifestAndWeightFiles(t),s=n.map((t=>this.loadWeightsFile(t,i[t])));return Promise.all(s).then((t=>[e,t]))}loadWeightsFile(t,e){return new Promise(((n,i)=>{const s=new FileReader;s.onload=t=>{const e=t.target.result;n(e)},s.onerror=e=>i(`Failed to weights data from file of path '${t}'.`),s.readAsArrayBuffer(e)}))}checkManifestAndWeightFiles(t){const e=[],n=this.weightsFiles.map((t=>jD(t.name))),i={};for(const s of t)s.paths.forEach((t=>{const s=jD(t);if(-1!==e.indexOf(s))throw new Error(`Duplicate file basename found in weights manifest: '${s}'`);if(e.push(s),-1===n.indexOf(s))throw new Error(`Weight file with basename '${s}' is not provided.`);i[t]=this.weightsFiles[n.indexOf(s)]}));if(e.length!==this.weightsFiles.length)throw new Error(`Mismatch in the number of files in weights manifest (${e.length}) and the number of weight files provided (${this.weightsFiles.length}).`);return i}}function OF(t){return new AF(t)} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function MF(t,e,n,i){!function(t){yA(null!=t&&Array.isArray(t)&&t.length>0,(()=>"promises must be a none empty array"))}(t),function(t,e){yA(t>=0&&t<=1,(()=>`Progress fraction must be in range [0, 1], but got startFraction ${t}`)),yA(e>=0&&e<=1,(()=>`Progress fraction must be in range [0, 1], but got endFraction ${e}`)),yA(e>=t,(()=>`startFraction must be no more than endFraction, but got startFraction ${t} and endFraction ${e}`))}(n=null==n?0:n,i=null==i?1:i);let s=0;return Promise.all(t.map((r=>(r.then((r=>{const a=n+ ++s/t.length*(i-n);return e(a),r})),r))))} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ async function CF(t,e){null==e&&(e={});const n=null==e.fetchFunc?lO().platform.fetch:e.fetchFunc,i=t.map((t=>n(t,e.requestInit,{isBinary:!0}))),s=(null==e.onProgress?await Promise.all(i):await MF(i,e.onProgress,0,.5)).map((t=>t.arrayBuffer()));return null==e.onProgress?await Promise.all(s):await MF(s,e.onProgress,.5,1)}async function NF(t,e="",n,i){return kF((t=>CF(t,{requestInit:i})))(t,e,n)}function kF(t){return async(e,n="",i)=>{const s=e.map((()=>!1)),r={},a=null!=i?i.map((()=>!1)):[],o=[];if(e.forEach(((t,e)=>{let n=0;t.weights.forEach((t=>{const l="quantization"in t?t.quantization.dtype:t.dtype,u=dD[l]*bA(t.shape),h=()=>{s[e]=!0,null==r[e]&&(r[e]=[]),r[e].push({manifestEntry:t,groupOffset:n,sizeBytes:u})};null!=i?i.forEach(((e,n)=>{e===t.name&&(h(),a[n]=!0)})):h(),o.push(t.name),n+=u}))})),!a.every((t=>t))){const t=i.filter(((t,e)=>!a[e]));throw new Error(`Could not find weights in manifest with names: ${t.join(", ")}. \nManifest JSON has weights with names: ${o.join(", ")}.`)}const l=s.reduce(((t,e,n)=>(e&&t.push(n),t)),[]),u=[];l.forEach((t=>{e[t].paths.forEach((t=>{const e=n+(n.endsWith("/")?"":"/")+t;u.push(e)}))}));const h=await t(u),p={};let c=0;return l.forEach((t=>{const n=e[t].paths.length,i=new fD(h.slice(c,c+n));r[t].forEach((t=>{const e=$D(i.slice(t.groupOffset,t.groupOffset+t.sizeBytes),[t.manifestEntry]);for(const t in e)p[t]=e[t]})),c+=n})),p}}tL.registerSaveRouter((t=>lO().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(RF.URL_SCHEME)?function(t="model"){return new RF(t)}(t.slice(RF.URL_SCHEME.length)):null));class DF{constructor(t,e){if(this.DEFAULT_METHOD="POST",null==e&&(e={}),this.weightPathPrefix=e.weightPathPrefix,this.weightUrlConverter=e.weightUrlConverter,null!=e.fetchFunc?(yA("function"==typeof e.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=e.fetchFunc):this.fetch=lO().platform.fetch,yA(null!=t&&t.length>0,(()=>"URL path for http must not be null, undefined or empty.")),Array.isArray(t)&&yA(2===t.length,(()=>`URL paths for http must have a length of 2, (actual length is ${t.length}).`)),this.path=t,null!=e.requestInit&&null!=e.requestInit.body)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=e.requestInit||{},this.loadOptions=e}async save(t){if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");const e=Object.assign({method:this.DEFAULT_METHOD},this.requestInit);e.body=new FormData;const n=qD(t,[{paths:["./model.weights.bin"],weights:t.weightSpecs}]);if(e.body.append("model.json",new Blob([JSON.stringify(n)],{type:"application/json"}),"model.json"),null!=t.weightData){const n=fD.join(t.weightData);e.body.append("model.weights.bin",new Blob([n],{type:"application/octet-stream"}),"model.weights.bin")}const i=await this.fetch(this.path,e);if(i.ok)return{modelArtifactsInfo:JD(t),responses:[i]};throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${i.status}.`)}async loadModelJSON(){const t=await this.fetch(this.path,this.requestInit);if(!t.ok)throw new Error(`Request to ${this.path} failed with status code ${t.status}. Please verify this URL points to the model JSON of the model to load.`);let e;try{e=await t.json()}catch(t){let e=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?e+=" 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.":e+=" Please make sure the server is serving valid JSON for this request.",new Error(e)}const n=e.modelTopology,i=e.weightsManifest;if(null==n&&null==i)throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);return e}async load(){if(this.loadOptions.streamWeights)return this.loadStream();return QD(await this.loadModelJSON(),(t=>this.loadWeights(t)))}async loadStream(){const t=await this.loadModelJSON(),e=await this.getWeightUrls(t.weightsManifest),n=ZD(t.weightsManifest);return Object.assign(Object.assign({},t),{weightSpecs:n,getWeightStream:()=>function(t,e){var n;const i=null==e.fetchFunc?lO().platform.fetch:e.fetchFunc;let s,r=0;return null===(n=e.onProgress)||void 0===n||n.call(e,0),new ReadableStream({pull:async n=>{for(var a;re?t.substring(n):"";return[i+"/",s]}(e),s=this.weightPathPrefix||n,r=[],a=[];for(const e of t)for(const t of e.paths)null!=this.weightUrlConverter?a.push(this.weightUrlConverter(t)):r.push(s+t+i);return this.weightUrlConverter&&r.push(...await Promise.all(a)),r}async loadWeights(t){const e=await this.getWeightUrls(t);return[ZD(t),await CF(e,this.loadOptions)]}}function LF(t){return null!=t.match(DF.URL_SCHEME_REGEX)}DF.URL_SCHEME_REGEX=/^https?:\/\//;const FF=(t,e)=>{if("undefined"==typeof fetch&&(null==e||null==e.fetchFunc))return null;{let n=!0;if(n=Array.isArray(t)?t.every((t=>LF(t))):LF(t),n)return PF(t,e)}return null};function PF(t,e){return new DF(t,e)}function $F(t,e){return PF(t,e)}tL.registerSaveRouter(FF),tL.registerLoadRouter(FF); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class BF{constructor(t){this.modelArtifacts=t}load(){return this.modelArtifacts}}class VF{constructor(t){this.saveHandler=t}save(t){return this.saveHandler(t)}}class UF{constructor(t){t.load&&(this.load=()=>Promise.resolve(t.load())),t.save&&(this.save=e=>Promise.resolve(t.save(e)))}}function YF(t,e,n,i){return new UF(GF(...arguments))}function GF(t,e,n,i){if(1===arguments.length){return null!=t.modelTopology||null!=t.weightSpecs?new BF(t):(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 BF({modelTopology:t}))}return 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 BF({modelTopology:t,weightSpecs:e,weightData:n,trainingConfig:i})}function HF(t){return new VF(t)}function WF(t){return new VF(t)}const zF=uD({matMul_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n=!1,i=!1){let s=aD(t,"a","matMul"),r=aD(e,"b","matMul");[s,r]=Uk(s,r);const a={a:s,b:r},o={transposeA:n,transposeB:i};return Kk.runKernel(CO,a,o)}});const XF=uD({oneHot_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n=1,i=0,s="int32"){if(e<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${e}`);const r={indices:aD(t,"indices","oneHot","int32")},a={dtype:s,depth:e,onValue:n,offValue:i};return Kk.runKernel(gC,r,a)}});const jF=uD({imag_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={input:aD(t,"input","imag")};return Kk.runKernel(CM,e)}});const qF=uD({neg_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={x:aD(t,"x","neg")};return Kk.runKernel(hC,e)}});const KF=uD({real_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={input:aD(t,"input","real")};return Kk.runKernel(RC,e)}});const QF=uD({transpose_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n){const i=aD(t,"x","transpose");if(null==e&&(e=i.shape.map(((t,e)=>e)).reverse()),yA(i.rank===e.length,(()=>`Error in transpose: rank of input ${i.rank} must match length of perm ${e}.`)),e.forEach((t=>{yA(t>=0&&t"All entries in 'perm' must be between 0 and "+(i.rank-1)+` but got ${e}`))})),i.rank<=1)return i.clone();const s={x:i},r={perm:e};return"complex64"===i.dtype?vD((()=>{let t=KF(i),e=jF(i);return t=Kk.runKernel(yN,{x:t},r),e=Kk.runKernel(yN,{x:e},r),n&&(e=qF(e)),hD(t,e)})):Kk.runKernel(yN,s,r)}});const JF=uD({confusionMatrix_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n){const i=aD(t,"labels","confusionMatrix"),s=aD(e,"predictions","confusionMatrix");yA(null==n||n>0&&Number.isInteger(n),(()=>`If provided, numClasses must be a positive integer, but got ${n}`)),yA(1===i.rank,(()=>`Expected the rank of labels to be 1, but got ${i.rank}`)),yA(1===s.rank,(()=>`Expected the rank of predictions to be 1, but got ${s.rank}`)),yA(i.shape[0]===s.shape[0],(()=>`Mismatch in the number of examples: ${i.shape[0]} vs. ${s.shape[0]}. Labels and predictions should have the same number of elements.`)),yA(n>0&&Number.isInteger(n),(()=>`numClasses is required to be a positive integer, but got ${n}`));const r=XF(BL(i,"int32"),n),a=XF(BL(s,"int32"),n),o=QF(r),l=zF(o,a);return BL(l,"int32")}}); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function ZF(t,e,n){if(EA(t),null!=e&&3!==e.length)throw new Error("tensor3d() requires shape to have three numbers");const i=iD(t,n);if(3!==i.length&&1!==i.length)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(1===i.length&&null==e)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return pD(t,e,i,n)} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ let tP,eP=!1;function nP(t,e=3){if(e>4)throw new Error("Cannot construct Tensor with more than 4 channels from pixels.");if(null==t)throw new Error("pixels passed to tf.browser.fromPixels() can not be null");let n=!1,i=!1,s=!1,r=!1,a=!1,o=!1;if(t.data instanceof Uint8Array)n=!0;else if("undefined"!=typeof ImageData&&t instanceof ImageData)i=!0;else if("undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement)s=!0;else if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement)r=!0;else if(null!=t.getContext)a=!0;else{if(!("undefined"!=typeof ImageBitmap&&t 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 ${t.constructor.name}`);o=!0}if(null!=LN(xN,Kk.backendName)){const n={pixels:t},i={numChannels:e};return Kk.runKernel(xN,n,i)}const[l,u]=s?[t.videoWidth,t.videoHeight]:[t.width,t.height];let h,p;if(a)h=t.getContext("2d").getImageData(0,0,l,u).data;else if(i||n)h=t.data;else if(r||s||o){if(null==tP)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.");tP=new OffscreenCanvas(1,1).getContext("2d")}else tP=document.createElement("canvas").getContext("2d",{willReadFrequently:!0});tP.canvas.width=l,tP.canvas.height=u,tP.drawImage(t,0,0,l,u),h=tP.getImageData(0,0,l,u).data}if(4===e)p=new Int32Array(h);else{const t=l*u;p=new Int32Array(t*e);for(let n=0;n4||2===e)throw new Error(`toPixels only supports depth of size 1, 3 or 4 but got ${e}`);if("float32"!==t.dtype&&"int32"!==t.dtype)throw new Error(`Unsupported type for toPixels: ${t.dtype}. Please use float32 or int32 tensors.`)}async function aP(t,e){let n=aD(t,"img","toPixels");if(!(t instanceof Ak)){const t=n;n=BL(t,"int32"),t.dispose()}rP(n);const[i,s]=n.shape.slice(0,2),r=2===n.rank?1:n.shape[2],a=await n.data(),o="float32"===n.dtype?255:1,l=new Uint8ClampedArray(s*i*4);for(let t=0;t1)throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${s}.`)}else if("int32"===n.dtype&&(s<0||s>255))throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${s}.`);1===r?(e[0]=s*o,e[1]=s*o,e[2]=s*o):e[i]=s*o}const i=4*t;l[i+0]=Math.round(e[0]),l[i+1]=Math.round(e[1]),l[i+2]=Math.round(e[2]),l[i+3]=Math.round(e[3])}if(null!=e){if(!eP){null!=LN(uM,Kk.backendName)&&(console.warn("tf.browser.toPixels is not efficient to draw tensor on canvas. Please try tf.browser.draw instead."),eP=!0)}e.width=s,e.height=i;const t=e.getContext("2d"),n=new ImageData(l,s,i);t.putImageData(n,0,0)}return n!==t&&n.dispose(),l}function oP(t,e,n){let i=aD(t,"img","draw");if(!(t instanceof Ak)){const t=i;i=BL(t,"int32"),t.dispose()}rP(i),function(t){const e=(null==t?void 0:t.alpha)||1;if(e>1||e<0)throw new Error(`Alpha value ${e} is suppoed to be in range [0 - 1].`)}(null==n?void 0:n.imageOptions);const s={image:i},r={canvas:e,options:n};Kk.runKernel(uM,s,r)}const lP=uD({fromPixels_:nP});function uP(t,e){const n=t.shape.length,i=e.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(i<1)throw new Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${i}.`);if("int32"!==e.dtype)throw new Error(`tf.gatherND() expects the indices to be int32 type, but the dtype was ${e.dtype}.`);if(e.shape[i-1]>n)throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${e.shape[i-1]} vs. ${n}`);if(0===bA(t.shape))throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${t.shape}.`);const s=e.shape,r=s[s.length-1];let a=1;for(let t=0;tt/u)),1].slice(0,r);return[l,a,u,h]}function hP(t,e,n){const i=e.rank>1?e.shape[e.rank-1]:1,s=e.rank>1?e.rank-1:1,r=`Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${n.shape}, indices.shape: ${e.shape}, shape: ${t}, sliceDim: ${i}, and batchDim: ${s}.`;if(n.rank1?e.shape[i-1]:1,r=n.length;let a=1;for(let t=s;t`Error in slice${i}D: Length of begin ${e} must match the rank of the array (${i}).`)),yA(i===n.length,(()=>`Error in slice${i}D: Length of size ${n} must match the rank of the array (${i}).`));for(let s=0;s`Error in slice${i}D: begin[${s}] + size[${s}] (${e[s]+n[s]}) would overflow input.shape[${s}] (${t.shape[s]})`))}function gP(t){const e=[];let n=0;for(;t>0;)1&t&&e.push(n),t/=2,n++;return e}function _P(t,e,n){const i=[];for(let s=0;s0){const l=e[0],u=n+1;h=bP(a,l,u,i,t),p=vP(o,l,u,s,t),c=TP(r,l,u,t)}else for(let e=0;e-1)r[s]=0;else{const a=yP(e,n,s);let o=i[a];t&1<-1)r[s]=Number.MAX_SAFE_INTEGER;else{const a=yP(e,n,s);let o=i[a];t&1<0?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER);const l=i[s];return a<0&&(a+=l),a=dA(0,a,l-1),a}function xP(t,e,n,i,s,r){let a=e[s];const o=n[s]||1;(t&1<0?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER);const l=i[s];return a<0&&(a+=l),a=o>0?dA(0,a,l):dA(-1,a,l-1),a}function RP(t,e,n){let i=n.length;for(let t=0;t1){i=t;break}for(let s=i+1;s0||n[s]!==t[s])return!1;return!0}function AP(t,e){let n=t.length>0?t[t.length-1]:1;for(let i=0;i{yA(-1!==t,(()=>"slice() does not support negative begin indexing."))})),r=null==n?new Array(s).fill(-1):"number"==typeof n?[n,...new Array(s-1).fill(-1)]:n.lengthe>=0?e:(yA(-1===e,(()=>`Negative size values should be exactly -1 but got ${e} for the slice() size at index ${n}.`)),t.shape[n]-i[n]))),[i,r]}function MP(t,e,n,i,s,r,a,o,l){let u;if(null==i?(u=new Array(e.length),u.fill(1)):u=i,null!=a&&a&a-1)throw new Error("Multiple ellipses in slice is not allowed.");let h=!1;const p={dims:u.length,numAddAxisAfterEllipsis:0,begin:e.slice(),end:n.slice(),strides:u.slice(),beginMask:s,endMask:r,ellipsisMask:a,newAxisMask:o,shrinkAxisMask:l};for(let t=0;t0?0:-1,c.strides[e]>0?i:i-1];if(n&&c.strides[e]<=0)throw Error("only stride 1 allowed on non-range indexing.");m=m&&1===c.strides[e];const a=!!(c.beginMask&1<=i)throw Error(`slice index ${c.begin[e]} of dimension ${e} out of bounds.`)}else c.begin[e]=CP(c.begin[e],0,c.strides[e],i,s,r),c.end[e]=CP(c.end[e],1,c.strides[e],i,s,r);const t=1===c.strides[e]&&0===c.begin[e]&&c.end[e]===i;d=d&&t,f=f&&(0===e&&1===c.strides[e]||t)}else d=d&&1===c.strides[e]&&a,f=f&&(0===e&&1===c.strides[e]||a);let o,l=!1;if(c.beginValid&&c.endValid?(o=c.end[e]-c.begin[e],l=!0):n?(o=1,l=!0):a&&i>=0&&(o=c.strides[e]<0?-i:i,l=!0),l){let t;t=0===o||o<0!=c.strides[e]<0?0:Math.trunc(o/c.strides[e])+(o%c.strides[e]!=0?1:0),g.push(t)}else g.push(-1)}for(let t=0;t=0?_.push(g[e]):e===dP&&_.push(1)}return{finalShapeSparse:_.filter(((t,e)=>c.finalShapeGatherIndices[e]!==dP)),finalShape:_,isIdentity:d,sliceDim0:f,isSimpleSlice:m,begin:c.begin,end:c.end,strides:c.strides}}function CP(t,e,n,i,s,r){if(s[e])return n>0?r[e]:r[e+1&1];{const e=t<0?i+t:t;return er[1]?r[1]:e}} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const NP=.001,kP=.1;function DP(t,e,n){return null==n&&(n=LP()),FP(t,e,((t,e)=>VP(t,e,n)))}function LP(){return 32===Kk.backend.floatPrecision()?NP:kP}function FP(t,e,n){let i=!0;if((pk(t)||pk(e))&&(i=!1),pk(t)&&pk(e)&&(i=!0),i){const n=t.constructor.name,i=e.constructor.name;if(n!==i)throw new Error(`Arrays are of different type. Actual: ${n}. Expected: ${i}`)}if(Array.isArray(t)&&Array.isArray(e)){const n=iD(t),i=iD(e);if(!SA(n,i))throw new Error(`Arrays have different shapes. Actual: [${n}]. Expected: [${i}]`)}const s=pk(t)?t:ck(t),r=pk(e)?e:ck(e);if(s.length!==r.length)throw new Error(`Arrays have different lengths actual: ${s.length} vs expected: ${r.length}.\nActual: ${s}.\nExpected: ${r}.`);for(let t=0;te.fail()),(()=>e())),"undefined"!=typeof expect&&expect().nothing()}function $P(t,e){const n="string"==typeof e||"number"==typeof e||"boolean"==typeof e?[e]:e;return YA(t)||YA(t[0])||YA(e)||YA(e[0])?FP(t,n,((t,e)=>t==e)):FP(t,e,((t,e)=>VP(t,e,0)))}function BP(t,e,n){if(null==n&&(n=LP()),!VP(t,e,n))throw new Error(`Numbers differ: actual === ${t}, expected === ${e}`);"undefined"!=typeof expect&&expect().nothing()}function VP(t,e,n){return!isFinite(t)&&!isFinite(e)||!(isNaN(t)||isNaN(e)||Math.abs(t-e)>n)}function UP(t,e,n){for(let i=0;in)throw new Error(`Value out of range:${t[i]} low: ${e}, high: ${n}`)}function YP(t,e){const n=new Float32Array(t),i=new Float32Array(e);if(n.length!==i.length)throw new Error(`Expected ArrayBuffer to be of length ${i.length}, but it was ${n.length}`);for(let t=0;t{e.addEventListener("loadeddata",(n=>t(e))),e.load()}))}async function WP(t){await t.play(),"requestVideoFrameCallback"in t&&await new Promise((e=>{t.requestVideoFrameCallback(e)}))} /** @license See the LICENSE file. */ const zP="4.22.0"; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class XP{static sgd(t){return new bF(t)}static momentum(t,e,n=!1){return new vF(t,e,n)}static rmsprop(t,e=.9,n=0,i=null,s=!1){return new wF(t,e,n,i,s)}static adam(t=.001,e=.9,n=.999,i=null){return new mF(t,e,n,i)}static adadelta(t=.001,e=.95,n=null){return new hF(t,e,n)}static adamax(t=.002,e=.9,n=.999,i=null,s=0){return new EF(t,e,n,i,s)}static adagrad(t,e=.1){return new cF(t,e)}}const jP=uD({acos_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={x:aD(t,"x","acos")};return Kk.runKernel(fO,e)}});const qP=uD({acosh_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={x:aD(t,"x","acosh")};return Kk.runKernel(mO,e)}});const KP=uD({addN_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){yA(Array.isArray(t),(()=>"The argument passed to tf.addN() must be a list of tensors")),yA(t.length>=1,(()=>`Must pass at least one tensor to tf.addN(), but got ${t.length}`));const e=t.map(((t,e)=>aD(t,`tensors${e}`,"addN"))),n=e[0];e.forEach((t=>{if(t.dtype!==n.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")})),e.forEach((t=>{if(!SA(t.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")}));const i=e;return Kk.runKernel(_O,i)}});const QP=uD({all_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e=null,n=!1){const i={x:aD(t,"x","all","bool")},s={axis:e,keepDims:n};return Kk.runKernel(TO,i,s)}});const JP=uD({any_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e=null,n=!1){const i={x:aD(t,"x","any","bool")},s={axis:e,keepDims:n};return Kk.runKernel(yO,i,s)}});const ZP=uD({argMax_: /** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e=0){const n={x:aD(t,"x","argMax")},i={axis:e};return Kk.runKernel(IO,n,i)}});const t$=uD({argMin_: /** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e=0){const n={x:aD(t,"x","argMin")},i={axis:e};return Kk.runKernel(EO,n,i)}});const e$=uD({asin_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={x:aD(t,"x","asin")};return Kk.runKernel(bO,e)}});const n$=uD({asinh_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={x:aD(t,"x","asinh")};return Kk.runKernel(vO,e)}});const i$=uD({atan_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={x:aD(t,"x","atan")};return Kk.runKernel(wO,e)}});const s$=uD({atan2_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){let n=aD(t,"a","atan2"),i=aD(e,"b","atan2");[n,i]=Uk(n,i);const s={a:n,b:i};return Kk.runKernel(xO,s)}});const r$=uD({atanh_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={x:aD(t,"x","atanh")};return Kk.runKernel(SO,e)}}); /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function a$(t,e,n,i,s="NHWC",r){return u$(t,[...e,t[3]],n,r,i,null,null,y$(s))}function o$(t,e,n,i,s,r,a="channelsLast"){const[o,l]=c$(e);let u;if("channelsLast"===a)u=[o,l,t[3],t[3]];else{if("channelsFirst"!==a)throw new Error(`Unknown dataFormat ${a}`);u=[o,l,t[1],t[1]]}return u$(t,u,n,i,s,r,!1,a)}function l$(t,e,n,i,s,r,a="NDHWC"){const[o,l,u]=d$(e);let h,p;if("NDHWC"===a)p="channelsLast",h=[o,l,u,t[4],t[4]];else{if("NCDHW"!==a)throw new Error(`Unknown dataFormat ${a}`);p="channelsFirst",h=[o,l,u,t[1],t[1]]}return h$(t,h,n,i,s,!1,p,r)}function u$(t,e,n,i,s,r,a=!1,o="channelsLast"){let[l,u,h,p]=[-1,-1,-1,-1];if("channelsLast"===o)[l,u,h,p]=t;else{if("channelsFirst"!==o)throw new Error(`Unknown dataFormat ${o}`);[l,p,u,h]=t}const[c,d,,f]=e,[m,g]=c$(n),[_,T]=c$(i),y=f$(c,_),I=f$(d,T),{padInfo:E,outHeight:b,outWidth:v}=function(t,e,n,i,s,r,a,o,l){let u,h,p;if("number"==typeof t){u={top:t,bottom:t,left:t,right:t,type:0===t?"VALID":"NUMBER"};const s=function(t,e,n,i,s){null==i&&(i=p$(t,e,n));const r=t[0],a=t[1],o=m$((r-e+2*i)/n+1,s),l=m$((a-e+2*i)/n+1,s);return[o,l]}([e,n],r,i,t,o);h=s[0],p=s[1]}else if("same"===t){h=Math.ceil(e/i),p=Math.ceil(n/s);const t=Math.max(0,(h-1)*i+r-e),o=Math.max(0,(p-1)*s+a-n),l=Math.floor(t/2),c=t-l,d=Math.floor(o/2);u={top:l,bottom:c,left:d,right:o-d,type:"SAME"}}else if("valid"===t)u={top:0,bottom:0,left:0,right:0,type:"VALID"},h=Math.ceil((e-r+1)/i),p=Math.ceil((n-a+1)/s);else{if("object"!=typeof t)throw Error(`Unknown padding parameter: ${t}`);{const c="channelsLast"===l?t[1][0]:t[2][0],d="channelsLast"===l?t[1][1]:t[2][1],f="channelsLast"===l?t[2][0]:t[3][0],m="channelsLast"===l?t[2][1]:t[3][1];u={top:c,bottom:d,left:f,right:m,type:0===c&&0===d&&0===f&&0===m?"VALID":"EXPLICIT"},h=m$((e-r+c+d)/i+1,o),p=m$((n-a+f+m)/s+1,o)}}return{padInfo:u,outHeight:h,outWidth:p}}(s,u,h,m,g,y,I,r,o),w=a?f*p:f;let S;return"channelsFirst"===o?S=[l,w,b,v]:"channelsLast"===o&&(S=[l,b,v,w]),{batchSize:l,dataFormat:o,inHeight:u,inWidth:h,inChannels:p,outHeight:b,outWidth:v,outChannels:w,padInfo:E,strideHeight:m,strideWidth:g,filterHeight:c,filterWidth:d,effectiveFilterHeight:y,effectiveFilterWidth:I,dilationHeight:_,dilationWidth:T,inShape:t,outShape:S,filterShape:e}}function h$(t,e,n,i,s,r=!1,a="channelsLast",o){let[l,u,h,p,c]=[-1,-1,-1,-1,-1];if("channelsLast"===a)[l,u,h,p,c]=t;else{if("channelsFirst"!==a)throw new Error(`Unknown dataFormat ${a}`);[l,c,u,h,p]=t}const[d,f,m,,g]=e,[_,T,y]=d$(n),[I,E,b]=d$(i),v=f$(d,I),w=f$(f,E),S=f$(m,b),{padInfo:x,outDepth:R,outHeight:A,outWidth:O}=function(t,e,n,i,s,r,a,o,l,u,h){let p,c,d,f;"valid"===t&&(t=0);if("number"==typeof t){p={top:t,bottom:t,left:t,right:t,front:t,back:t,type:0===t?"VALID":"NUMBER"};const m=function(t,e,n,i,s,r){null==s&&(s=p$(t,e[0],i[0]));const a=[0,0,0,n];for(let n=0;n<3;n++)t[n]+2*s>=e[n]&&(a[n]=m$((t[n]-e[n]+2*s)/i[n]+1,r));return a}([e,n,i,1],[o,l,u],1,[s,r,a],t,h);c=m[0],d=m[1],f=m[2]}else{if("same"!==t)throw Error(`Unknown padding parameter: ${t}`);{c=Math.ceil(e/s),d=Math.ceil(n/r),f=Math.ceil(i/a);const t=(c-1)*s+o-e,h=(d-1)*r+l-n,m=(f-1)*a+u-i,g=Math.floor(t/2),_=t-g,T=Math.floor(h/2),y=h-T,I=Math.floor(m/2);p={top:T,bottom:y,left:I,right:m-I,front:g,back:_,type:"SAME"}}}return{padInfo:p,outDepth:c,outHeight:d,outWidth:f}}(s,u,h,p,_,T,y,v,w,S,o),M=r?g*c:g;let C;return"channelsFirst"===a?C=[l,M,R,A,O]:"channelsLast"===a&&(C=[l,R,A,O,M]),{batchSize:l,dataFormat:a,inDepth:u,inHeight:h,inWidth:p,inChannels:c,outDepth:R,outHeight:A,outWidth:O,outChannels:M,padInfo:x,strideDepth:_,strideHeight:T,strideWidth:y,filterDepth:d,filterHeight:f,filterWidth:m,effectiveFilterDepth:v,effectiveFilterHeight:w,effectiveFilterWidth:S,dilationDepth:I,dilationHeight:E,dilationWidth:b,inShape:t,outShape:C,filterShape:e}}function p$(t,e,n,i=1){const s=f$(e,i);return Math.floor((t[0]*(n-1)-n+s)/2)}function c$(t){return"number"==typeof t?[t,t,t]:2===t.length?[t[0],t[1],1]:t}function d$(t){return"number"==typeof t?[t,t,t]:t}function f$(t,e){return e<=1?t:t+(t-1)*(e-1)}function m$(t,e){if(!e)return Math.trunc(t);switch(e){case"round":return Math.round(t);case"ceil":return Math.ceil(t);case"floor":return Math.floor(t);default:throw new Error(`Unknown roundingMode ${e}`)}}function g$(t){const[e,n,i]=c$(t);return 1===e&&1===n&&1===i}function _$(t,e){return g$(t)||g$(e)}function T$(t){return c$(t).every((t=>t>0))}function y$(t){if("NHWC"===t)return"channelsLast";if("NCHW"===t)return"channelsFirst";throw new Error(`Unknown dataFormat ${t}`)}function I$(t,e,n){if(null!=n){if("string"==typeof e)throw Error(`Error in ${t}: pad must be an integer when using dimRoundingMode ${n} but got pad ${e}.`);if("number"==typeof e)yA(xA(e),(()=>`Error in ${t}: pad must be an integer when using dimRoundingMode ${n} but got pad ${e}.`));else{if("object"!=typeof e)throw Error(`Error in ${t}: Unknown padding parameter: ${e}`);e.forEach((e=>{e.forEach((e=>{yA(xA(e),(()=>`Error in ${t}: pad must be an integer when using dimRoundingMode ${n} but got pad ${e}.`))}))}))}}}const E$=uD({reshape_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){const n={x:aD(t,"x","reshape","string_or_numeric")},i={shape:e};return Kk.runKernel(MC,n,i)}});const b$=uD({avgPool_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i,s){const r=aD(t,"x","avgPool","float32");yA(_$(n,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`));let a=r,o=!1;3===r.rank&&(o=!0,a=E$(r,[1,r.shape[0],r.shape[1],r.shape[2]])),yA(4===a.rank,(()=>`Error in avgPool: x must be rank 4 but got rank ${a.rank}.`)),I$("avgPool",i,s);const l={x:a},u={filterSize:e,strides:n,pad:i,dimRoundingMode:s};let h=Kk.runKernel(RO,l,u);return h=BL(h,r.dtype),o?E$(h,[h.shape[1],h.shape[2],h.shape[3]]):h}});const v$=uD({avgPool3d_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i,s,r="NDHWC"){const a=aD(t,"x","avgPool3d","float32");let o=a,l=!1;4===a.rank&&(l=!0,o=E$(a,[1,a.shape[0],a.shape[1],a.shape[2],a.shape[3]])),yA(5===o.rank,(()=>`Error in avgPool3d: x must be rank 5 but got rank ${o.rank}.`)),yA("NDHWC"===r,(()=>`Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${r}`)),yA("number"==typeof n&&n>0||Array.isArray(n)&&n[0]>0&&n[1]>0&&n[2]>0,(()=>`Error in avgPool3d: Stride must be > 0, but got '${n}'`)),I$("avgPool3d",i,s);const u={x:o},h={filterSize:e,strides:n,pad:i,dimRoundingMode:s,dataFormat:r};let p=Kk.runKernel(OO,u,h);return p=BL(p,o.dtype),l?E$(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}});const w$=uD({concat_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e=0){yA(t.length>=1,(()=>"Pass at least one tensor to concat"));const n=oD(t,"tensors","concat","string_or_numeric");if("complex64"===n[0].dtype&&n.forEach((t=>{if("complex64"!==t.dtype)throw new Error(`Cannot concatenate complex64 tensors with a tensor\n with dtype ${t.dtype}. `)})),1===n.length)return VL(n[0]);const i=n,s={axis:e};return Kk.runKernel(YO,i,s)}});const S$=uD({sigmoid_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={x:aD(t,"x","sigmoid","float32")};return Kk.runKernel(jC,e)}});const x$=uD({slice_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n){const i=aD(t,"x","slice","string_or_numeric");if(0===i.rank)throw new Error("Slicing scalar is not possible");const s={x:i},r={begin:e,size:n};return Kk.runKernel(HC,s,r)}});const R$=uD({tanh_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={x:aD(t,"x","tanh","float32")};return Kk.runKernel(mN,e)}});const A$=uD({basicLSTMCell_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i,s,r){const a=aD(t,"forgetBias","basicLSTMCell"),o=aD(e,"lstmKernel","basicLSTMCell"),l=aD(n,"lstmBias","basicLSTMCell"),u=aD(i,"data","basicLSTMCell"),h=aD(s,"c","basicLSTMCell"),p=aD(r,"h","basicLSTMCell"),c=w$([u,p],1),d=zF(c,o),f=YL(d,l),m=f.shape[0],g=f.shape[1]/4,_=[m,g],T=x$(f,[0,0],_),y=x$(f,[0,g],_),I=x$(f,[0,2*g],_),E=x$(f,[0,3*g],_),b=YL(WL(S$(T),R$(y)),WL(h,S$(YL(a,I))));return[b,WL(R$(b),S$(E))]}});const O$=uD({batchToSpaceND_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n){const i=aD(t,"x","batchToSpaceND"),s=e.reduce(((t,e)=>t*e));yA(i.rank>=1+e.length,(()=>`input rank is ${i.rank} but should be > than blockShape.length ${e.length}`)),yA(n.length===e.length,(()=>`crops.length is ${n.length} but should be equal to blockShape.length ${e.length}`)),yA(i.shape[0]%s==0,(()=>`input tensor batch is ${i.shape[0]} but is not divisible by the product of the elements of blockShape ${e.join(" * ")} === ${s}`));const r={x:i},a={blockShape:e,crops:n};return Kk.runKernel(NO,r,a)}});const M$=uD({batchNorm_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i,s,r){null==r&&(r=.001);const a=aD(t,"x","batchNorm"),o=aD(e,"mean","batchNorm"),l=aD(n,"variance","batchNorm");let u,h;null!=s&&(u=aD(s,"scale","batchNorm")),null!=i&&(h=aD(i,"offset","batchNorm")),yA(o.rank===l.rank,(()=>"Batch normalization gradient requires mean and variance to have equal ranks.")),yA(null==h||o.rank===h.rank,(()=>"Batch normalization gradient requires mean and offset to have equal ranks.")),yA(null==u||o.rank===u.rank,(()=>"Batch normalization gradient requires mean and scale to have equal ranks."));const p={x:function(t){let e;return e=0===t.rank||1===t.rank?E$(t,[1,1,1,t.size]):2===t.rank?E$(t,[1,1,t.shape[0],t.shape[1]]):3===t.rank?E$(t,[1,t.shape[0],t.shape[1],t.shape[2]]):t,e}(a),scale:u,offset:h,mean:o,variance:l},c={varianceEpsilon:r},d=Kk.runKernel(wM,p,c);return E$(d,a.shape)}});const C$=uD({batchNorm2d_:function(t,e,n,i,s,r){const a=aD(t,"x","batchNorm"),o=aD(e,"mean","batchNorm"),l=aD(n,"variance","batchNorm");let u,h;return null!=s&&(u=aD(s,"scale","batchNorm")),null!=i&&(h=aD(i,"offset","batchNorm")),yA(2===a.rank,(()=>`Error in batchNorm2D: x must be rank 2 but got rank ${a.rank}.`)),yA(2===o.rank||1===o.rank,(()=>`Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${o.rank}.`)),yA(2===l.rank||1===l.rank,(()=>`Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${l.rank}.`)),null!=u&&yA(2===u.rank||1===u.rank,(()=>`Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${u.rank}.`)),null!=h&&yA(2===h.rank||1===h.rank,(()=>`Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${h.rank}.`)),M$(a,o,l,h,u,r)}});const N$=uD({batchNorm3d_:function(t,e,n,i,s,r){const a=aD(t,"x","batchNorm"),o=aD(e,"mean","batchNorm"),l=aD(n,"variance","batchNorm");let u,h;return null!=s&&(u=aD(s,"scale","batchNorm")),null!=i&&(h=aD(i,"offset","batchNorm")),yA(3===a.rank,(()=>`Error in batchNorm3D: x must be rank 3 but got rank ${a.rank}.`)),yA(3===o.rank||1===o.rank,(()=>`Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${o.rank}.`)),yA(3===l.rank||1===l.rank,(()=>`Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${l.rank}.`)),null!=u&&yA(3===u.rank||1===u.rank,(()=>`Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${u.rank}.`)),null!=h&&yA(3===h.rank||1===h.rank,(()=>`Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${h.rank}.`)),M$(a,o,l,h,u,r)}});const k$=uD({batchNorm4d_:function(t,e,n,i,s,r){const a=aD(t,"x","batchNorm"),o=aD(e,"mean","batchNorm"),l=aD(n,"variance","batchNorm");let u,h;return null!=s&&(u=aD(s,"scale","batchNorm")),null!=i&&(h=aD(i,"offset","batchNorm")),yA(4===a.rank,(()=>`Error in batchNorm4D: x must be rank 4 but got rank ${a.rank}.`)),yA(4===o.rank||1===o.rank,(()=>`Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${o.rank}.`)),yA(4===l.rank||1===l.rank,(()=>`Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${l.rank}.`)),null!=u&&yA(4===u.rank||1===u.rank,(()=>`Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${u.rank}.`)),null!=h&&yA(4===h.rank||1===h.rank,(()=>`Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${h.rank}.`)),M$(a,o,l,h,u,r)}});const D$=uD({bincount_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n){const i=aD(t,"x","bincount"),s=aD(e,"weights","bincount");yA("int32"===i.dtype,(()=>`Error in bincount: input dtype must be int32, but got ${i.dtype}`)),yA(n>=0,(()=>`size must be non-negative, but got ${n}.`)),yA(s.size===i.size||0===s.size,(()=>`Error in bincount: weights must have the same size as input or0-length, but got input shape: ${i.shape}, weights shape: ${s.shape}.`));const r={x:i,weights:s},a={size:n};return Kk.runKernel(kO,r,a)}});const L$=uD({bitwiseAnd_: /** * @license * Copyright 2023 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){const n=aD(t,"x","bitwiseAnd"),i=aD(e,"y","bitwiseAnd");if(!SA(n.shape,i.shape))throw new Error(`BitwiseAnd: Tensors must have the same shape. x: ${n.shape}, y: ${i.shape}`);if("int32"!==n.dtype||"int32"!==i.dtype)throw new Error(`BitwiseAnd: Only supports 'int32' values in tensor, found type of x: ${n.dtype} and type of y: ${i.dtype}`);const s={a:n,b:i};return Kk.runKernel(DO,s)}});const F$=uD({broadcastArgs_: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){const n=aD(t,"s0","broadcastArgs","int32"),i=aD(e,"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!==i.rank)throw new Error(`broadcastArgs(): second input must be a vector (rank=1). Has rank ${i.rank}`);const s={s0:n,s1:i};return Kk.runKernel(FO,s)}});const P$=uD({broadcastTo_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){let n=aD(t,"broadcastTo","x");const i=n.shape;if(eO(e),e.lengthn.rank){const t=n.shape.slice();for(;t.length=0;t--)if(s[t]===e[t])r[t]=1;else if(1!==n.shape[t])throw new Error(`broadcastTo(): [${i}] cannot be broadcast to [${e}].`);if(0===r.map(((t,e)=>t>1?e:-1)).filter((t=>t>=0)).length)return VL(n);const a={x:n},o={reps:r};return Kk.runKernel(gN,a,o)}});const $$=uD({ceil_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={x:aD(t,"x","ceil","float32")};return Kk.runKernel($O,e)}});const B$=uD({clipByValue_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n){const i=aD(t,"x","clipByValue");if(yA(e<=n,(()=>`Error in clip: min (${e}) must be less than or equal to max (${n}).`)),e===n)return pF(i.shape,e,i.dtype);const s={x:i},r={clipValueMin:e,clipValueMax:n};return Kk.runKernel(BO,s,r)}});const V$=uD({concat1d_:function(t){return w$(t,0)}});const U$=uD({concat2d_:function(t,e){return w$(t,e)}});const Y$=uD({concat3d_:function(t,e){return w$(t,e)}});const G$=uD({concat4d_:function(t,e){return w$(t,e)}});const H$=uD({conv2d_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i,s="NHWC",r=[1,1],a){const o=aD(t,"x","conv2d","float32"),l=aD(e,"filter","conv2d","float32");let u=o,h=!1;3===o.rank&&(h=!0,u=E$(o,[1,o.shape[0],o.shape[1],o.shape[2]])),yA(4===u.rank,(()=>`Error in conv2d: input must be rank 4, but got rank ${u.rank}.`)),yA(4===l.rank,(()=>`Error in conv2d: filter must be rank 4, but got rank ${l.rank}.`)),I$("conv2d",i,a);const p="NHWC"===s?u.shape[3]:u.shape[1];yA(p===l.shape[2],(()=>`Error in conv2d: depth of input (${p}) must match input depth for filter ${l.shape[2]}.`)),yA(_$(n,r),(()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${r}'`)),yA(T$(r),(()=>"Error in conv2D: Dilated rates should be larger than 0.")),yA(T$(n),(()=>"Error in conv2D: Strides should be larger than 0."));const c={x:u,filter:l},d={strides:n,pad:i,dataFormat:s,dilations:r,dimRoundingMode:a},f=Kk.runKernel(GO,c,d);return h?E$(f,[f.shape[1],f.shape[2],f.shape[3]]):f}});const W$=uD({conv1d_:function(t,e,n,i,s="NWC",r=1,a){const o=aD(t,"x","conv1d"),l=aD(e,"filter","conv1d");let u=o,h=!1;2===o.rank&&(h=!0,u=E$(o,[1,o.shape[0],o.shape[1]])),yA(3===u.rank,(()=>`Error in conv1d: input must be rank 3, but got rank ${u.rank}.`)),yA(3===l.rank,(()=>`Error in conv1d: filter must be rank 3, but got rank ${l.rank}.`)),I$("conv1d",i,a),yA(u.shape[2]===l.shape[1],(()=>`Error in conv1d: depth of input (${u.shape[2]}) must match input depth for filter ${l.shape[1]}.`)),yA(_$(n,r),(()=>`Error in conv1D: Either stride or dilation must be 1. Got stride ${n} and dilation '${r}'`)),yA(T$(r),(()=>"Error in conv1D: Dilated rates should be larger than 0.")),yA(T$(n),(()=>"Error in conv1D: Stride should be larger than 0.")),yA("NWC"===s,(()=>`Error in conv1d: got dataFormat of ${s} but only NWC is currently supported.`));const p=E$(l,[1,l.shape[0],l.shape[1],l.shape[2]]),c=E$(u,[u.shape[0],1,u.shape[1],u.shape[2]]),d=H$(c,p,[1,n],i,"NHWC",[1,r],a);return E$(d,h?[d.shape[2],d.shape[3]]:[d.shape[0],d.shape[2],d.shape[3]])}});const z$=uD({conv2DBackpropInput_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i,s,r="NHWC",a){yA(t.length===e.rank,(()=>`Length of inShape (${t.length}) and rank of dy (${e.rank}) must match`));let o=t,l=e,u=!1;3===e.rank&&(u=!0,l=E$(e,[1,e.shape[0],e.shape[1],e.shape[2]]),o=[1,t[0],t[1],t[2]]),yA(4===o.length,(()=>`Error in conv2dDerInput: inShape must be length 4, but got length ${o.length}.`)),yA(4===l.rank,(()=>`Error in conv2dDerInput: dy must be rank 4, but got rank ${l.rank}`)),yA(4===n.rank,(()=>`Error in conv2dDerInput: filter must be rank 4, but got rank ${n.rank}`));const h="NHWC"===r?o[3]:o[1],p="NHWC"===r?l.shape[3]:l.shape[1];yA(h===n.shape[2],(()=>`Error in conv2dDerInput: depth of input (${h}) must match input depth for filter ${n.shape[2]}.`)),yA(p===n.shape[3],(()=>`Error in conv2dDerInput: depth of output (${p}) must match output depth for filter ${n.shape[3]}.`)),I$("conv2dDerInput",s,a);const c={dy:l,filter:n},d={strides:i,pad:s,dataFormat:r,dimRoundingMode:a,inputShape:o},f=Kk.runKernel(WO,c,d);return u?E$(f,[f.shape[1],f.shape[2],f.shape[3]]):f}});const X$=uD({conv2dTranspose_:function(t,e,n,i,s,r){const a=aD(t,"x","conv2dTranspose"),o=aD(e,"filter","conv2dTranspose");return z$(n,a,o,i,s,"NHWC",r)}});const j$=uD({conv3d_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i,s="NDHWC",r=[1,1,1]){const a=aD(t,"x","conv3d"),o=aD(e,"filter","conv3d");let l=a,u=!1;4===a.rank&&(u=!0,l=E$(a,[1,a.shape[0],a.shape[1],a.shape[2],a.shape[3]])),yA(5===l.rank,(()=>`Error in conv3d: input must be rank 5, but got rank ${l.rank}.`)),yA(5===o.rank,(()=>`Error in conv3d: filter must be rank 5, but got rank ${o.rank}.`)),yA(l.shape[4]===o.shape[3],(()=>`Error in conv3d: depth of input (${l.shape[4]}) must match input depth for filter ${o.shape[3]}.`)),yA(_$(n,r),(()=>`Error in conv3D: Either strides or dilations must be 1. Got strides ${n} and dilations '${r}'`)),yA("NDHWC"===s,(()=>`Error in conv3d: got dataFormat of ${s} but only NDHWC is currently supported.`)),yA(T$(r),(()=>"Error in conv3D: Dilated rates should be larger than 0.")),yA(T$(n),(()=>"Error in conv3D: Strides should be larger than 0."));const h={x:l,filter:o},p={strides:n,pad:i,dataFormat:s,dilations:r},c=Kk.runKernel(zO,h,p);return u?E$(c,[c.shape[1],c.shape[2],c.shape[3],c.shape[4]]):c}});const q$=uD({conv3DBackpropInput_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i,s){yA(t.length===e.rank,(()=>`Length of inShape (${t.length}) and rank of dy (${e.rank}) must match`));let r=t,a=e,o=!1;4===e.rank&&(o=!0,a=E$(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]]),r=[1,t[0],t[1],t[2],t[3]]);const l=r[4],u=a.shape[4];yA(5===r.length,(()=>`Error in conv3dDerInput: inShape must be length 5, but got length ${r.length}.`)),yA(5===a.rank,(()=>`Error in conv3dDerInput: dy must be rank 5, but got rank ${a.rank}`)),yA(5===n.rank,(()=>`Error in conv3dDerInput: filter must be rank 5, but got rank ${n.rank}`)),yA(l===n.shape[3],(()=>`Error in conv3dDerInput: depth of input (${l}) must match input depth for filter ${n.shape[3]}.`)),yA(u===n.shape[4],(()=>`Error in conv3dDerInput: depth of output (${u}) must match output depth for filter ${n.shape[4]}.`));const h={dy:a,filter:n},p={pad:s,strides:i,inputShape:r},c=Kk.runKernel(jO,h,p);return o?E$(c,[c.shape[1],c.shape[2],c.shape[3],c.shape[4]]):c}});const K$=uD({conv3dTranspose_:function(t,e,n,i,s){const r=aD(t,"x","conv3dTranspose"),a=aD(e,"filter","conv3dTranspose");return q$(n,r,a,i,s)}});const Q$=uD({cos_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={x:aD(t,"x","cos","float32")};return Kk.runKernel(qO,e)}});const J$=uD({cosh_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={x:aD(t,"x","cosh","float32")};return Kk.runKernel(KO,e)}});const Z$=uD({cumprod_: /** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the 'License'); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e=0,n=!1,i=!1){const s={x:aD(t,"x","cumprod")},r={axis:e,exclusive:n,reverse:i};return Kk.runKernel(QO,s,r)}});const tB=uD({cumsum_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e=0,n=!1,i=!1){const s={x:aD(t,"x","cumsum")},r={axis:e,exclusive:n,reverse:i};return Kk.runKernel(JO,s,r)}});const eB=uD({denseBincount_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i=!1){const s=aD(t,"x","denseBincount"),r=aD(e,"weights","denseBincount");yA("int32"===s.dtype,(()=>`Error in denseBincount: input dtype must be int32, but got ${s.dtype}`)),yA(s.rank<=2,(()=>`Error in denseBincount: input must be at most rank 2, but got rank ${s.rank}.`)),yA(n>=0,(()=>`size must be non-negative, but got ${n}.`)),yA(r.size===s.size||0===r.size,(()=>`Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${s.shape}, weights shape: ${r.shape}.`));const a={x:s,weights:r},o={size:n,binaryOutput:i};return Kk.runKernel(tM,a,o)}});const nB=uD({depthToSpace_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n="NHWC"){const i=aD(t,"x","depthToSpace","float32"),s="NHWC"===n?i.shape[1]:i.shape[2],r="NHWC"===n?i.shape[2]:i.shape[3],a="NHWC"===n?i.shape[3]:i.shape[1];yA(e>1,(()=>`blockSize should be > 1 for depthToSpace, but was: ${e}`)),yA(s*e>=0,(()=>`Negative dimension size caused by overflow when multiplying\n ${s} and ${e} for depthToSpace with input shape\n ${i.shape}`)),yA(r*e>=0,(()=>`Negative dimension size caused by overflow when multiplying\n ${r} and ${e} for depthToSpace with input shape\n ${i.shape}`)),yA(a%(e*e)==0,(()=>`Dimension size must be evenly divisible by ${e*e} but is ${a} for depthToSpace with input shape ${i.shape}`));const o={x:i},l={blockSize:e,dataFormat:n};return Kk.runKernel(eM,o,l)}});const iB=uD({depthwiseConv2d_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i,s="NHWC",r=[1,1],a){const o=aD(t,"x","depthwiseConv2d","float32"),l=aD(e,"filter","depthwiseConv2d","float32");let u=o,h=!1;3===o.rank&&(h=!0,u=E$(o,[1,o.shape[0],o.shape[1],o.shape[2]])),yA(4===u.rank,(()=>`Error in depthwiseConv2d: input must be rank 4, but got rank ${u.rank}.`)),yA(4===l.rank,(()=>`Error in depthwiseConv2d: filter must be rank 4, but got rank ${l.rank}.`));const p="NHWC"===s?u.shape[3]:u.shape[1];yA(p===l.shape[2],(()=>`Error in depthwiseConv2d: number of input channels (${p}) must match the inChannels dimension in filter ${l.shape[2]}.`)),I$("depthwiseConv2d",i,a);const c={x:u,filter:l},d={strides:n,pad:i,dataFormat:s,dilations:r,dimRoundingMode:a},f=Kk.runKernel(nM,c,d);return h?E$(f,[f.shape[1],f.shape[2],f.shape[3]]):f}});const sB=uD({diag_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={x:aD(t,"x","diag")};return Kk.runKernel(rM,e)}});const rB=uD({dilation2d_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i,s=[1,1],r="NHWC"){const a=aD(t,"x","dilation2d"),o=aD(e,"filter","dilation2d");yA(3===a.rank||4===a.rank,(()=>`Error in dilation2d: input must be rank 3 or 4, but got rank ${a.rank}.`)),yA(3===o.rank,(()=>`Error in dilation2d: filter must be rank 3, but got rank ${o.rank}.`)),yA("NHWC"===r,(()=>`Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${r}`));let l=a,u=!1;3===a.rank&&(l=E$(a,[1,a.shape[0],a.shape[1],a.shape[2]]),u=!0),yA(l.shape[3]===o.shape[2],(()=>`Error in dilation2d: input and filter must have the same depth: ${l.shape[3]} vs ${o.shape[2]}`));const h={x:l,filter:o},p={strides:n,pad:i,dilations:s},c=Kk.runKernel(aM,h,p);return u?E$(c,[c.shape[1],c.shape[2],c.shape[3]]):c}});const aB=uD({equal_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){let n=aD(t,"a","equal","string_or_numeric"),i=aD(e,"b","equal","string_or_numeric");[n,i]=Uk(n,i),yF(n.shape,i.shape);const s={a:n,b:i};return Kk.runKernel(mM,s)}});const oB=uD({where_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n){const i=aD(e,"a","where"),s=aD(n,"b","where"),r=aD(t,"condition","where","bool"),a=yF(yF(r.shape,i.shape),s.shape),o={condition:P$(r,a),t:P$(i,a),e:P$(s,a)};return Kk.runKernel(YC,o)}});const lB=uD({divNoNan_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){let n=aD(t,"a","div"),i=aD(e,"b","div");[n,i]=Uk(n,i);const s=HL(n,i),r=jL(s),a=aB(i,r);return oB(a,r,s)}});const uB=uD({dot_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){const n=aD(t,"t1","dot"),i=aD(e,"t2","dot");yA(!(1!==n.rank&&2!==n.rank||1!==i.rank&&2!==i.rank),(()=>`Error in dot: inputs must all be rank 1 or 2, but got ranks ${n.rank} and ${i.rank}.`));const s=1===n.rank?n.size:n.shape[1],r=1===i.rank?i.size:i.shape[0];if(yA(s===r,(()=>`Error in dot: inner dimensions of inputs must match, but got ${s} and ${r}.`)),1===n.rank&&1===i.rank){const t=E$(n,[1,-1]),e=E$(i,[-1,1]),s=zF(t,e);return E$(s,[])}if(1===n.rank&&2===i.rank){const t=E$(n,[1,-1]),e=E$(i,[i.shape[0],i.shape[1]]),s=zF(t,e);return E$(s,[s.size])}if(2===n.rank&&1===i.rank){const t=E$(i,[-1,1]),e=zF(n,t);return E$(e,[e.size])}{const t=E$(i,[i.shape[0],i.shape[1]]);return zF(n,t)}}});const hB=uD({einsum_: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,...e){const n=e.map(((t,e)=>aD(t,`tensors${e}`,"einsum"))),i={equation:t};return Kk.runKernel(pM,n,i)}});const pB=uD({elu_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={x:aD(t,"x","elu","float32")};return Kk.runKernel(cM,e)}});const cB=uD({ensureShape_: /** * @license * Copyright 2023 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){const n=aD(t,"x","ensureShape","string_or_numeric");if(!wA(n.shape,e))throw new Error(`EnsureShape: Shape of tensor ${n.shape} is not compatible with expected shape ${e}`);return t}});const dB=uD({erf_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){let e=aD(t,"x","erf");yA("int32"===e.dtype||"float32"===e.dtype,(()=>"Input dtype must be `int32` or `float32`.")),"int32"===e.dtype&&(e=BL(e,"float32"));const n={x:e};return Kk.runKernel(fM,n)}}); /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function fB(t,e){for(let n=0;nt[e]))]}function _B(t,e){return mB(t,e.map((t=>1)),e)}function TB(t,e,n){yA(fB(e,n),(()=>`${t} supports only inner-most axes for now. Got axes ${e} and rank-${n} input.`))}function yB(t,e){if(fB(t,e))return null;const n=[];for(let i=0;in.push(t))),n}function IB(t){return t.map(((t,e)=>[e,t])).sort(((t,e)=>t[1]-e[1])).map((t=>t[0]))}function EB(t,e){const n=[];for(let i=e-t;i"Axis must be <= rank of the tensor"));const i={input:n},s={dim:e};return Kk.runKernel(_M,i,s)}});const MB=uD({expm1_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={x:aD(t,"x","expm1")};return Kk.runKernel(TM,e)}});const CB=uD({tile_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){const n=aD(t,"x","tile","string_or_numeric");yA(n.rank===e.length,(()=>`Error in transpose: rank of input ${n.rank} must match length of reps ${e}.`));const i={x:n},s={reps:e};return Kk.runKernel(gN,i,s)}});const NB=uD({eye_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i="float32"){null==e&&(e=t);const s=$L([t,e],i),r=t<=e?t:e;for(let t=0;t`Error in localResponseNormalization: x must be rank 3 or 4 but got\n rank ${r.rank}.`)),yA(xA(e),(()=>`Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${e}.`));let a=r,o=!1;3===r.rank&&(o=!0,a=E$(r,[1,r.shape[0],r.shape[1],r.shape[2]]));const l={x:a},u={depthRadius:e,bias:n,alpha:i,beta:s},h=Kk.runKernel(XM,l,u);return o?E$(h,[h.shape[1],h.shape[2],h.shape[3]]):h}});const WB=uD({log_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={x:aD(t,"x","log","float32")};return Kk.runKernel(BM,e)}});const zB=uD({log1p_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={x:aD(t,"x","log1p")};return Kk.runKernel(VM,e)}});const XB=uD({softplus_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={x:aD(t,"x","softplus")};return Kk.runKernel(qC,e)}});const jB=uD({logSigmoid_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e=aD(t,"x","logSigmoid");return tF((t=>({value:qF(XB(qF(t))),gradFunc:e=>WL(e,S$(qF(t)))})))(e)}});const qB=uD({logSoftmax_: /** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e=-1){const n=aD(t,"logits","logSoftmax");if(-1===e&&(e=n.rank-1),e!==n.rank-1)throw Error(`Log Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank} and axis was ${e}`);const i=tF(((t,n)=>{const i=bB(t,e,!0),s=fF(t,i),r=fF(BL(s,"float32"),WB(wB(AB(s),e,!0)));n([r]);return{value:r,gradFunc:(t,n)=>{const[i]=n,s=AB(i);return fF(t,WL(wB(t,e,!0),s))}}}));return i(n)}});const KB=uD({logSumExp_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e=null,n=!1){const i=aD(t,"x","logSumExp"),s=kA(e,i.shape),r=bB(i,s,!0),a=fF(i,r),o=AB(a),l=wB(o,s),u=WB(l),h=YL(E$(r,u.shape),u);if(n){const t=_B(h.shape,s);return E$(h,t)}return h}});const QB=uD({logicalAnd_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){const n=aD(t,"a","logicalAnd","bool"),i=aD(e,"b","logicalAnd","bool");yF(n.shape,i.shape);const s={a:n,b:i};return Kk.runKernel(UM,s)}});const JB=uD({logicalNot_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={x:aD(t,"x","logicalNot","bool")};return Kk.runKernel(YM,e)}});const ZB=uD({logicalOr_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){const n=aD(t,"a","logicalOr","bool"),i=aD(e,"b","logicalOr","bool");yF(n.shape,i.shape);const s={a:n,b:i};return Kk.runKernel(GM,s)}});const tV=uD({logicalXor_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){const n=aD(t,"a","logicalXor","bool"),i=aD(e,"b","logicalXor","bool");return yF(n.shape,i.shape),QB(ZB(t,e),JB(QB(t,e)))}}),eV=2147483648;const nV=uD({searchSorted_:function(t,e,n="left"){const i=aD(t,"sortedSequence","searchSorted"),s=aD(e,"values","searchSorted"),r=i.shape[i.shape.length-1],a=s.shape[s.shape.length-1],o=E$(i,[-1,r]),l=E$(s,[-1,a]);if(o.rank<2)throw new Error("Sorted input argument must be at least 2-dimensional");if(o.shape[0]!==l.shape[0])throw new Error("Leading dimension of 'sortedSequence' and 'values' must match.");if(bA(l.shape)>=eV)throw new Error("values tensor size must less than 2147483648");if(o.shape[1]>=eV)throw new Error(`trailing dim_size must less than 2147483648 for int32 output type, was ${o.shape[1]}`);const u={sortedSequence:o,values:l},h={side:n};return Kk.runKernel(UC,u,h)}}); /** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function iV(t,e){return nV(t,e,"left")}const sV=uD({maxPool_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i,s){const r=aD(t,"x","maxPool");let a=r,o=!1;3===r.rank&&(o=!0,a=E$(r,[1,r.shape[0],r.shape[1],r.shape[2]])),yA(4===a.rank,(()=>`Error in maxPool: input must be rank 4 but got rank ${a.rank}.`)),yA(_$(n,1),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`)),I$("maxPool",i,s);const l={x:a},u={filterSize:e,strides:n,pad:i,dimRoundingMode:s},h=Kk.runKernel(JM,l,u);return o?E$(h,[h.shape[1],h.shape[2],h.shape[3]]):h}});const rV=uD({maxPool3d_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e=[1,1,1],n,i,s,r="NDHWC"){const a=aD(t,"x","maxPool3d");let o=a,l=!1;4===a.rank&&(l=!0,o=E$(a,[1,a.shape[0],a.shape[1],a.shape[2],a.shape[3]])),yA(5===o.rank,(()=>`Error in maxPool3d: x must be rank 5 but got rank ${o.rank}.`)),yA("NDHWC"===r,(()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${r}`)),I$("maxPool3d",i,s);const u={x:o},h={filterSize:e,strides:n,pad:i,dimRoundingMode:s,dataFormat:r},p=Kk.runKernel(tC,u,h);return l?E$(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}});const aV=uD({maxPoolWithArgmax_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i,s=!1){const r={x:aD(t,"x","maxPoolWithArgmax")},a={filterSize:e,strides:n,pad:i,includeBatchInIndex:s},o=Kk.runKernel(nC,r,a);return{result:o[0],indexes:o[1]}}});const oV=uD({mean_: /** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e=null,n=!1){const i={x:aD(t,"x","mean")},s={axis:e,keepDims:n};return Kk.runKernel(iC,i,s)}}); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function lV(t,e="float32"){if(eO(t),"complex64"===e){const e=lV(t,"float32"),n=lV(t,"float32");return hD(e,n)}const n=ZA(bA(t),e);return Kk.makeTensor(n,t,e)} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function uV(t,e="float32"){if(eO(t),"complex64"===e){const e=uV(t,"float32"),n=lV(t,"float32");return hD(e,n)}const n=JA(bA(t),e);return Kk.makeTensor(n,t,e)} /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function hV(t,e,{indexing:n="xy"}={}){if("xy"!==n&&"ij"!==n)throw new TypeError(`${n} is not a valid third argument to meshgrid`);if(void 0===t)return[];let i=aD(t,"x","meshgrid",t instanceof Ak?t.dtype:"float32");if(void 0===e)return[i];let s=aD(e,"y","meshgrid",e instanceof Ak?e.dtype:"float32");const r=bA(i.shape),a=bA(s.shape);return"xy"===n?(i=E$(i,[1,-1]),s=E$(s,[-1,1]),[zF(uV([a,1],i.dtype),i),zF(s,uV([1,r],s.dtype))]):(i=E$(i,[-1,1]),s=E$(s,[1,-1]),[zF(i,uV([1,a],i.dtype)),zF(uV([r,1],s.dtype),s)])}const pV=uD({minimum_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){let n=aD(t,"a","minimum"),i=aD(e,"b","minimum");[n,i]=Uk(n,i),"bool"===n.dtype&&(n=BL(n,"int32"),i=BL(i,"int32")),yF(n.shape,i.shape);const s={a:n,b:i};return Kk.runKernel(rC,s)}});const cV=uD({mirrorPad_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n){yA("reflect"===n||"symmetric"===n,(()=>`Invalid mode. Mode must be either reflect or symmetric. Got ${n}.`));const i=aD(t,"x","mirrorPad");if(0===i.rank)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");yA(e.length===i.rank,(()=>`Padding doesn't match input. Must be ${i.rank}. Got ${e.length}.`));const s="reflect"===n?1:0;for(let t=0;t"Invalid number of paddings. Must be length of 2 each.")),yA(e[t][0]>=0&&e[t][0]<=i.shape[t]-s&&e[t][1]>=0&&e[t][1]<=i.shape[t]-s,(()=>`Padding in dimension ${t} cannot be greater than or equal to ${i.shape[t]-s} or less than 0 for input of shape ${i.shape}`));const r={paddings:e,mode:n},a={x:i};return Kk.runKernel(aC,a,r)}});const dV=uD({mod_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){let n=aD(t,"a","mod"),i=aD(e,"b","mod");[n,i]=Uk(n,i);const s={a:n,b:i};return Kk.runKernel(oC,s)}});const fV=uD({moments_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e=null,n=!1){const i=kA(e,(t=aD(t,"x","moments")).shape),s=oV(t,i,n);let r=s.shape;n||(r=_B(s.shape,i));const a=XL(fF(BL(t,"float32"),E$(s,r)));return{mean:s,variance:oV(a,i,n)}}});const mV=uD({multiRNNCell_:function(t,e,n,i){const s=aD(e,"data","multiRNNCell"),r=oD(n,"c","multiRNNCell"),a=oD(i,"h","multiRNNCell");let o=s;const l=[];for(let e=0;e2)throw new Error(`Rank of probabilities must be 1 or 2, but is ${a}`);n=n||Math.random();const o={logits:1===a?E$(s,[1,-1]):s},l={numSamples:e,seed:n,normalized:i},u=Kk.runKernel(lC,o,l);return 1===a?E$(u,[u.size]):u}});const _V=uD({notEqual_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){let n=aD(t,"a","notEqual","string_or_numeric"),i=aD(e,"b","notEqual","string_or_numeric");[n,i]=Uk(n,i),yF(n.shape,i.shape);const s={a:n,b:i};return Kk.runKernel(pC,s)}});const TV=uD({onesLike_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={x:aD(t,"x","onesLike")};return Kk.runKernel(mC,e)}});const yV=uD({outerProduct_:function(t,e){const n=aD(t,"v1","outerProduct"),i=aD(e,"v2","outerProduct");yA(1===n.rank&&1===i.rank,(()=>`Error in outerProduct: inputs must be rank 1, but got ranks ${n.rank} and ${i.rank}.`));const s=E$(n,[-1,1]),r=E$(i,[1,-1]);return zF(s,r)}});const IV=uD({pad_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n=0){const i=aD(t,"x","pad");if(0===i.rank)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");const s={paddings:e,constantValue:n},r={x:i};return Kk.runKernel(TC,r,s)}});const EV=uD({pad1d_:function(t,e,n=0){return yA(2===e.length,(()=>"Invalid number of paddings. Must be length of 2.")),IV(t,[e],n)}});const bV=uD({pad2d_:function(t,e,n=0){return yA(2===e.length&&2===e[0].length&&2===e[1].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),IV(t,e,n)}});const vV=uD({pad3d_:function(t,e,n=0){return yA(3===e.length&&2===e[0].length&&2===e[1].length&&2===e[2].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),IV(t,e,n)}});const wV=uD({pad4d_:function(t,e,n=0){return yA(4===e.length&&2===e[0].length&&2===e[1].length&&2===e[2].length&&2===e[3].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),IV(t,e,n)}});const SV=uD({spaceToBatchND_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n){const i=aD(t,"x","spaceToBatchND");yA(i.rank>=1+e.length,(()=>`input rank ${i.rank} should be > than [blockShape] ${e.length}`)),yA(n.length===e.length,(()=>`paddings.shape[0] ${n.length} must be equal to [blockShape] ${e.length}`)),yA(i.shape.reduce(((t,i,s)=>s>0&&s<=e.length?t&&(i+n[s-1][0]+n[s-1][1])%e[s-1]==0:t),!0),(()=>`input spatial dimensions ${i.shape.slice(1)} with paddings ${n.toString()} must be divisible by blockShapes ${e.toString()}`));const s={x:i},r={blockShape:e,paddings:n};return Kk.runKernel(JC,s,r)}});const xV=uD({pool_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i,s,r,a){null==s&&(s=[1,1]),null==r&&(r=1),0===i&&(i="valid");const o=aD(t,"x","maxPool");let l=o,u=!1;3===o.rank&&(u=!0,l=E$(o,[1,o.shape[0],o.shape[1],o.shape[2]])),yA(_$(r,s),(()=>`Error in pool: Either strides or dilations must be 1. Got strides ${r} and dilations '${s}'`));const h=o$(l.shape,e,r,s,i),p=[h.dilationHeight,h.dilationWidth];let c;c="same"===i?function(t,e){const n=t.map(((t,n)=>t+(t-1)*(e[n]-1))),i=n.map((t=>t-1)),s=i.map((t=>Math.floor(t/2))),r=i.map(((t,e)=>t-s[e]));return i.map(((t,e)=>[s[e],r[e]]))}([h.filterHeight,h.filterWidth],p):[[0,0],[0,0]];const d=1===p[0]&&1===p[1],[f,m]=function(t,e,n){const i=n.map((t=>t[0])),s=n.map((t=>t[1])),r=t.concat(i,s),a=e.map(((t,e)=>(t-r[e]%t)%t)),o=s.map(((t,e)=>t+a[e])),l=e.map(((t,e)=>[i[e],o[e]])),u=e.map(((t,e)=>[0,a[e]]));return[l,u]}([h.inHeight,h.inWidth],p,c),g=d?i:"valid",_=d?l:SV(l,p,f),T=("avg"===n?()=>b$(_,e,r,g,a):()=>sV(_,e,r,g,a))(),y=d?T:O$(T,p,m);return u?E$(y,[y.shape[1],y.shape[2],y.shape[3]]):y}});const RV=uD({prelu_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){const n={x:aD(t,"x","prelu"),alpha:aD(e,"alpha","prelu")};return Kk.runKernel(EC,n)}});const AV=uD({prod_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e=null,n=!1){let i=aD(t,"x","prod");"bool"===i.dtype&&(i=BL(i,"int32"));const s={x:i},r={axis:e,keepDims:n};return Kk.runKernel(bC,s,r)}});const OV=uD({raggedGather_: /** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i){const s={paramsNestedSplits:t.map(((t,e)=>aD(t,`tensors${e}`,"raggedGather","int32"))),paramsDenseValues:aD(e,"paramsDenseValues","raggedGather"),indices:aD(n,"indices","raggedGather","int32")},r={outputRaggedRank:i},a=Kk.runKernel(vC,s,r);return{outputNestedSplits:a.slice(0,a.length-1),outputDenseValues:a[a.length-1]}}});const MV=uD({raggedRange_: /** * @license * Copyright 2022 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n){const i=aD(t,"starts","raggedRange"),s={starts:i,limits:aD(e,"limits","raggedRange",i.dtype),deltas:aD(n,"deltas","raggedRange",i.dtype)},r=Kk.runKernel(wC,s);return{rtNestedSplits:r[0],rtDenseValues:r[1]}}});const CV=uD({raggedTensorToTensor_: /** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i,s){const r=aD(t,"shape","raggedTensorToTensor","int32"),a=aD(e,"values","raggedTensorToTensor"),o={shape:r,values:a,defaultValue:aD(n,"defaultValue","raggedTensorToTensor",a.dtype),rowPartitionTensors:i.map(((t,e)=>aD(t,`tensors${e}`,"raggedTensorToTensor","int32")))},l={rowPartitionTypes:s};return Kk.runKernel(SC,o,l)}});const NV=uD({rand_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n){eO(t);const i=bA(t);let s=null;if(null==n||"float32"===n)s=new Float32Array(i);else if("int32"===n)s=new Int32Array(i);else{if("bool"!==n)throw new Error(`Unknown data type ${n}`);s=new Uint8Array(i)}for(let t=0;t=1||0===r);const a=Math.sqrt(-2*Math.log(r)/r);t=this.mean+this.stdDev*i*a,e=this.mean+this.stdDev*s*a,this.truncated&&!this.isValidTruncated(t)||(n=!0)}return this.truncated&&!this.isValidTruncated(e)||(this.nextVal=this.convertValue(e)),this.convertValue(t)}convertValue(t){return null==this.dtype||"float32"===this.dtype?t:Math.round(t)}isValidTruncated(t){return t<=this.upper&&t>=this.lower}}class LV{constructor(t,e,n,i){this.alpha=t,this.beta=1/e,this.dtype=n;const s=i||Math.random();this.randu=kV.alea(s.toString()),this.randn=new DV(0,1,n,!1,this.randu()),this.d=t<1?t+2/3:t-1/3,this.c=1/Math.sqrt(9*this.d)}nextValue(){let t,e,n,i,s,r;for(;;){do{i=this.randn.nextValue(),r=1+this.c*i}while(r<=0);if(r*=r*r,t=i*i,e=1-.331*t*t,n=.5*t+this.d*(1-r+Math.log(r)),s=this.randu(),snull==this.dtype||"float32"===this.dtype,this.min=t,this.range=e-t,this.dtype=n,null==i&&(i=Math.random()),"number"==typeof i&&(i=i.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error(`The difference between ${t} - ${e} <= 1 and dtype is not float`);this.random=kV.alea(i)}convertValue(t){return this.canReturnFloat()?t:Math.round(t)}nextValue(){return this.convertValue(this.min+this.range*this.random())}}const PV=uD({randomGamma_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n=1,i="float32",s){if(eO(t),null==n&&(n=1),null==i&&(i="float32"),"float32"!==i&&"int32"!==i)throw new Error(`Unsupported data type ${i}`);const r=new LV(e,n,i,s),a=$L(t,i);for(let t=0;t`Error in reverse1D: x must be rank 1 but got rank ${e.rank}.`)),zV(e,0)}});const jV=uD({reverse2d_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){const n=aD(t,"x","reverse");return yA(2===n.rank,(()=>`Error in reverse2D: x must be rank 2 but got rank ${n.rank}.`)),zV(n,e)}});const qV=uD({reverse3d_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){const n=aD(t,"x","reverse");return yA(3===n.rank,(()=>`Error in reverse3D: x must be rank 3 but got rank ${n.rank}.`)),zV(n,e)}});const KV=uD({reverse4d_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){const n=aD(t,"x","reverse");return yA(4===n.rank,(()=>`Error in reverse4D: x must be rank 4 but got rank ${n.rank}.`)),zV(n,e)}});const QV=uD({round_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={x:aD(t,"x","round")};return Kk.runKernel(PC,e)}});const JV=uD({rsqrt_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={x:aD(t,"x","rsqrt","float32")};return Kk.runKernel($C,e)}});const ZV=uD({selu_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={x:aD(t,"x","selu")};return Kk.runKernel(GC,e)}});const tU=uD({separableConv2d_:function(t,e,n,i,s,r=[1,1],a="NHWC"){const o=aD(t,"x","separableConv2d"),l=aD(e,"depthwiseFilter","separableConv2d"),u=aD(n,"pointwiseFilter","separableConv2d");let h=o,p=!1;if(3===o.rank&&(p=!0,h=E$(o,[1,o.shape[0],o.shape[1],o.shape[2]])),"NCHW"===a)throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");yA(4===h.rank,(()=>`Error in separableConv2d: input must be rank 4, but got rank ${h.rank}.`)),yA(4===l.rank,(()=>`Error in separableConv2d: depthwise filter must be rank 4, but got rank ${l.rank}.`)),yA(4===u.rank,(()=>`Error in separableConv2d: pointwise filter must be rank 4, but got rank ${l.rank}.`)),yA(1===u.shape[0],(()=>`Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${u.shape[0]}.`)),yA(1===u.shape[1],(()=>`Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${u.shape[1]}.`));const c=l.shape[2],d=l.shape[3];yA(u.shape[2]===c*d,(()=>`Error in separableConv2d: the third dimension of pointwise filter must be ${c*d}, but got ${u.shape[2]}.`));const f=iB(h,l,i,s,a,r),m=H$(f,u,1,"valid",a);return p?E$(m,[m.shape[1],m.shape[2],m.shape[3]]):m}});const eU= /** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ async function(t,e){const n=aD(t,"x","setdiff1d"),i=aD(e,"y","setdiff1d");yA(n.dtype===i.dtype,(()=>`x and y should have the same dtype, but got x (${n.dtype}) and y (${i.dtype}).`)),yA(1===n.rank,(()=>`x should be 1D tensor, but got x (${n.shape}).`)),yA(1===i.rank,(()=>`y should be 1D tensor, but got y (${i.shape}).`));const s=await n.data(),r=await i.data(),a=new Set(r);let o=0;for(let t=0;t`slice1d expects a rank-1 tensor, but got a rank-${i.rank} tensor`)),x$(i,[e],[n])}});const aU=uD({slice2d_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n){const i=aD(t,"x","slice2d");return yA(2===i.rank,(()=>`slice2d expects a rank-2 tensor, but got a rank-${i.rank} tensor`)),x$(i,e,n)}});const oU=uD({slice3d_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n){const i=aD(t,"x","slice3d");return yA(3===i.rank,(()=>`slice3d expects a rank-3 tensor, but got a rank-${i.rank} tensor`)),x$(i,e,n)}});const lU=uD({slice4d_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n){const i=aD(t,"x","slice4d");return yA(4===i.rank,(()=>`slice4d expects a rank-4 tensor, but got a rank-${i.rank} tensor`)),x$(i,e,n)}});const uU=uD({softmax_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e=-1){const n=aD(t,"logits","softmax","float32");if(-1===e&&(e=n.rank-1),e!==n.rank-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank} and dim was ${e}`);const i={logits:n},s={dim:e};return Kk.runKernel(tN,i,s)}});const hU=uD({fft_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){yA("complex64"===t.dtype,(()=>`The dtype for tf.spectral.fft() must be complex64 but got ${t.dtype}.`));const e={input:t};return Kk.runKernel(yM,e)}});const pU=uD({ifft_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){yA("complex64"===t.dtype,(()=>`The dtype for tf.spectral.ifft() must be complex64 but got ${t.dtype}.`));const e={input:t};return Kk.runKernel(MM,e)}});const cU=uD({irfft_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e=t.shape[t.shape.length-1],n=t.size/e;let i;if(e<=2){const s=E$(t,[n,e]);i=pU(s)}else{const s=[n,2*(e-1)],r=E$(KF(t),[n,e]),a=E$(jF(t),[n,e]),o=zV(x$(r,[0,1],[n,e-2]),1),l=WL(zV(x$(a,[0,1],[n,e-2]),1),nF(-1)),u=w$([r,o],1),h=w$([a,l],1),p=E$(hD(u,h),[s[0],s[1]]);i=pU(p)}if(i=KF(i),3===t.rank&&0!==t.shape[0]){const e=i,n=t.shape[0];i=E$(i,[n,i.shape[0]/n,i.shape[1]]),e.dispose()}return i}});const dU=uD({split_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n=0){const i={x:aD(t,"x","split")},s={numOrSizeSplits:e,axis:n};return Kk.runKernel(ZC,i,s)}});const fU=uD({rfft_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){yA("float32"===t.dtype,(()=>`The dtype for rfft() must be real value but got ${t.dtype}`));let n=t.shape[t.shape.length-1];const i=t.size/n;let s;if(null!=e&&e0)),r=t.shape.map((t=>t));r[t.shape.length-1]=e,s=x$(t,i,r),n=e}else if(null!=e&&e>n){const i=t.shape.map((t=>t));i[t.shape.length-1]=e-n,s=w$([t,lV(i)],t.shape.length-1),n=e}else s=t;const r=jL(s),a=E$(hD(s,r),[i,n]),o=hU(a),l=Math.floor(n/2)+1,u=KF(o),h=jF(o),p=dU(u,[l,n-l],u.shape.length-1),c=dU(h,[l,n-l],h.shape.length-1),d=s.shape.slice();return d[s.shape.length-1]=l,E$(hD(p[0],c[0]),d)}});const mU=uD({squaredDifference_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){let n=aD(t,"a","squaredDifference"),i=aD(e,"b","squaredDifference");[n,i]=Uk(n,i),yF(n.shape,i.shape);const s={a:n,b:i};return Kk.runKernel(aN,s,{})}});const gU=uD({squeeze_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){const n=aD(t,"x","squeeze","string_or_numeric");return E$(n,DA(n.shape,e).newShape)}});const _U=uD({stack_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e=0){const n=oD(t,"tensors","stack","string_or_numeric");yA(n.length>=1,(()=>"Pass at least one tensor to tf.stack")),n.length>0&&yA(e<=n[0].rank,(()=>"Axis must be <= rank of the tensor"));const i=n,s={axis:e};return Kk.runKernel(_C,i,s)}});const TU=uD({step_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e=0){const n={x:aD(t,"x","step")},i={alpha:e};return Kk.runKernel(SN,n,i)}});const yU=uD({stridedSlice_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i,s=0,r=0,a=0,o=0,l=0){const u={x:aD(t,"x","stridedSlice","string_or_numeric")},h={begin:e,end:n,strides:i,beginMask:s,endMask:r,ellipsisMask:a,newAxisMask:o,shrinkAxisMask:l};return Kk.runKernel(uN,u,h)}});const IU=uD({tan_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e={x:aD(t,"x","tan","float32")};return Kk.runKernel(fN,e)}}); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function EU(t,e){EA(t);const n=iD(t,e);if(1!==n.length)throw new Error("tensor1d() requires values to be a flat/TypedArray");return pD(t,null,n,e)} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function bU(t,e,n){if(EA(t),null!=e&&2!==e.length)throw new Error("tensor2d() requires shape to have two numbers");const i=iD(t,n);if(2!==i.length&&1!==i.length)throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(1===i.length&&null==e)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return pD(t,e,i,n)} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function vU(t,e,n){if(EA(t),null!=e&&4!==e.length)throw new Error("tensor4d() requires shape to have four numbers");const i=iD(t,n);if(4!==i.length&&1!==i.length)throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");if(1===i.length&&null==e)throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");return pD(t,e,i,n)} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function wU(t,e,n){if(EA(t),null!=e&&5!==e.length)throw new Error("tensor5d() requires shape to have five numbers");const i=iD(t,n);if(5!==i.length&&1!==i.length)throw new Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray");if(1===i.length&&null==e)throw new Error("tensor5d() requires shape to be provided when `values` are a flat array");return pD(t,e,i,n)} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function SU(t,e,n){if(EA(t),null!=e&&6!==e.length)throw new Error("tensor6d() requires shape to have six numbers");const i=iD(t,n);if(6!==i.length&&1!==i.length)throw new Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray");if(1===i.length&&null==e)throw new Error("tensor6d() requires shape to be provided when `values` are a flat array");return pD(t,e=e||i,i,n)}const xU=uD({tensorScatterUpdate_: /** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n){const i=aD(t,"tensor","tensorScatterupdate"),s=aD(e,"indices","tensorScatterupdate","int32"),r=aD(n,"updates","tensorScatterupdate");if(pP(r,s,i.shape),i.dtype!==r.dtype)throw new Error(`tensor and updates must have the same dtype, instead they are ${i.dtype} and ${r.dtype}.`);const a={tensor:i,indices:s,updates:r};return Kk.runKernel(VC,a,{})}});const RU=uD({topk_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e=1,n=!0){const i=aD(t,"x","topk");if(0===i.rank)throw new Error("topk() expects the input to be of rank 1 or higher");const s=i.shape[i.shape.length-1];if(e<0)throw new Error(`'k' passed to topk() must be >= 0 but got ${e}`);if(e>s)throw new Error(`'k' passed to topk() must be <= the last dimension (${s}) but got ${e}`);const r={x:i},a={k:e,sorted:n},[o,l]=Kk.runKernel(_N,r,a);return{values:o,indices:l}}});const AU=uD({truncatedNormal_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e=0,n=1,i,s){if(eO(t),null!=i&&"bool"===i)throw new Error("Unsupported data type $ { dtype }");const r=new DV(e,n,i,!0,s),a=$L(t,i);for(let t=0;t0,(()=>"The input tensor must be at least 1D"));const i={x:n},s={axis:e},[r,a]=Kk.runKernel(IN,i,s);return{values:r,indices:a}}});const MU=uD({unsortedSegmentSum_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n){const i=aD(t,"x","unsortedSegmentSum"),s=aD(e,"segmentIds","unsortedSegmentSum","int32");yA(xA(n),(()=>"numSegments must be of dtype int"));const r={x:i,segmentIds:s},a={numSegments:n};return Kk.runKernel(bN,r,a)}});const CU=uD({unstack_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e=0){const n=aD(t,"x","unstack","string_or_numeric");yA(e>=-n.shape.length&&e`Axis = ${e} is not in [-${n.shape.length}, ${n.shape.length})`));const i={value:n},s={axis:e};return Kk.runKernel(EN,i,s)}}); /** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function NU(t,e){return nV(t,e,"right")} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function kU(t,e=!0,n,i){return Kk.makeVariable(t,e,n,i)} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function DU(t,e){const n=[];for(let t=0;t0,(()=>"mask cannot be scalar")),IA(o.slice(r,r+a),s.shape,"mask's shape must match the first K dimensions of tensor's shape,");let l=1;for(let t=r;t"Shape mismatch in v and x"));const l=nF(1),u=fF(l,o);let h=WL(fF(a,r),u);if(s){yA(null!=i,(()=>"When using zeroDebias: true, step is required."));const t=aD(i,"step","movingAverage");h=HL(h,fF(l,dF(o,t)))}return YL(r,h)}});const $U=uD({scatterND_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n){eO(n);const i=aD(t,"indices","scatterND","int32"),s=aD(e,"updates","scatterND");pP(s,i,n);const r={indices:i,updates:s},a={shape:n};return Kk.runKernel(BC,r,a)}});const BU=uD({sparseToDense_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i=0){eO(n);const s=aD(t,"sparseIndices","sparseToDense","int32"),r=aD(e,"sparseValues","sparseToDense","string_or_numeric"),a=aD(i,"defaultValue","sparseToDense",r.dtype);!function(t,e,n,i){if("int32"!==t.dtype)throw new Error(`tf.sparseToDense() expects the indices to be int32 type, but the dtype was ${t.dtype}.`);if(t.rank>2)throw new Error(`sparseIndices should be a scalar, vector, or matrix, but got shape ${t.shape}.`);const s=t.rank>0?t.shape[0]:1,r=t.rank>1?t.shape[1]:1;if(n.length!==r)throw new Error(`outputShape has incorrect number of elements:, ${n.length}, should be: ${r}.`);const a=e.size;if(0!==e.rank&&(1!==e.rank||a!==s))throw new Error(`sparseValues has incorrect shape ${e.shape}, should be [] or [${s}]`);if(e.dtype!==i.dtype)throw new Error("sparseValues.dtype must match defaultValues.dtype")}(s,r,n,a);const o={sparseIndices:s,sparseValues:r,defaultValue:a},l={outputShape:n};return Kk.runKernel(rN,o,l)}});const VU=uD({gatherND_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){const n=aD(e,"indices","gatherND","int32"),i={params:aD(t,"x","gatherND","string_or_numeric"),indices:n};return Kk.runKernel(xM,i)}});const UU=uD({dropout_: /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i){const s=aD(t,"x","dropout");if(yA("float32"===s.dtype,(()=>`x has to be a floating point tensor since it's going to be scaled, but got a ${s.dtype} tensor instead.`)),yA(e>=0&&e<1,(()=>`rate must be a float in the range [0, 1), but got ${e}.`)),0===e)return t instanceof Ak?s.clone():s;const r= /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){if(null==e)return t.shape.slice();if(SA(t.shape,e))return e;if(t.shape.length===e.length){const n=[];for(let i=0;i1,(()=>`inTopK() expects the predictions to be of rank 2 or higher, but got ${i.rank}`)),yA(i.rank-1===s.rank,(()=>`predictions rank should be 1 larger than targets rank, but got predictions rank ${i.rank} and targets rank ${s.rank}`)),IA(i.shape.slice(0,i.shape.length-1),s.shape,"predictions's shape should be align with the targets' shape, except the last dimension.");const r=i.shape[i.shape.length-1];yA(n>0&&n<=r,(()=>`'k' passed to inTopK() must be > 0 && <= the predictions last dimension (${r}), but got ${n}`));const a=await i.data(),o=await s.data(),[l,u]=[a.length/r,r],h=LA("bool",l);for(let t=0;te.value-t.value)),h[t]=0;for(let e=0;e`Error in conv2dDerFilter: input must be rank 4, but got shape ${o.shape}.`)),yA(4===l.rank,(()=>`Error in conv2dDerFilter: dy must be rank 4, but got shape ${l.shape}.`)),yA(4===n.length,(()=>`Error in conv2dDerFilter: filterShape must be length 4, but got ${n}.`));const u="NHWC"===r?o.shape[3]:o.shape[1],h="NHWC"===r?l.shape[3]:l.shape[1];yA(u===n[2],(()=>`Error in conv2dDerFilter: depth of input ${u}) must match input depth in filter (${n[2]}.`)),yA(h===n[3],(()=>`Error in conv2dDerFilter: depth of dy (${h}) must match output depth for filter (${n[3]}).`)),I$("conv2dDerFilter",s,a);const p={x:o,dy:l},c={strides:i,pad:s,dataFormat:r,dimRoundingMode:a,filterShape:n};return Kk.runKernel(HO,p,c)}}); /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function zU(t,e,n){if(null==n||"linear"===n)return t;if("relu"===n)return WL(t,TU(e));throw new Error(`Cannot compute gradient for fused activation ${n}.`)}function XU(t,e){let n=e;const i=TF(t.shape,e.shape);return i.length>0&&(n=wB(n,i)),E$(n,t.shape)}function jU(t,e,n,i){if("linear"===e)return t;if("relu"===e)return HV(t);if("elu"===e)return pB(t);if("relu6"===e)return WV(t);if("prelu"===e)return RV(t,n);if("leakyrelu"===e)return VB(t,i);if("sigmoid"===e)return S$(t);throw new Error(`Unknown fused activation ${e}.`)}const qU=(t,e)=>!(t>0)||"linear"===e;const KU=uD({fusedConv2d_: /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function({x:t,filter:e,strides:n,pad:i,dataFormat:s="NHWC",dilations:r=[1,1],dimRoundingMode:a,bias:o,activation:l="linear",preluActivationWeights:u,leakyreluAlpha:h}){if(l=l||"linear",!1===qU(Kk.state.gradientDepth,l)){yA("NHWC"===s,(()=>`Error in fused conv2d: got dataFormat of ${s} but only NHWC is currently supported for the case of gradient depth is 0 and the activation is not linear.`));let p=H$(t,e,n,i,s,r,a);return null!=o&&(p=YL(p,o)),jU(p,l,u,h)}const p=aD(t,"x","conv2d","float32"),c=aD(e,"filter","conv2d","float32");let d=p,f=!1;3===p.rank&&(f=!0,d=E$(p,[1,p.shape[0],p.shape[1],p.shape[2]])),yA(4===d.rank,(()=>`Error in fused conv2d: input must be rank 4, but got rank ${d.rank}.`)),yA(4===c.rank,(()=>`Error in fused conv2d: filter must be rank 4, but got rank ${c.rank}.`)),I$("fused conv2d",i,a);const m="NHWC"===s?d.shape[3]:d.shape[1];yA(c.shape[2]===m,(()=>`Error in conv2d: depth of input (${m}) must match input depth for filter ${c.shape[2]}.`)),yA(_$(n,r),(()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${r}'`));const g=u$(d.shape,c.shape,n,r,i,a);let _,T;if(null!=o&&(_=aD(o,"bias","fused conv2d"),[_]=Uk(_,p),"NHWC"===s?yF(g.outShape,_.shape):(yA(_.shape.length<=1,(()=>`Error in fused conv2d: only supports scalar or 1-D Tensor bias for NCHW format but got the bias of rank-${_.shape.length}.`)),yA(0===_.shape.length||_.shape[0]===g.outChannels||1===_.shape[0],(()=>`Error in fused conv2d: bias shape (${_.shape}) is not compatible with the number of output channels (${g.outChannels})`)))),null!=u){const t=u.shape;if(yA(t.length<=1||3===t.length,(()=>`Error in fused conv2d: only supports scalar, 1-D Tensor or 3-D Tensor PReLU activation weights but got a tensor of rank-${t.length}.`)),1===t.length)yA(1===t[0]||t[0]===g.outChannels,(()=>`Error in fused conv2d: PReLU activation weights (${t}) is not compatible with the number of output channels (${g.outChannels}).`));else if(3===t.length)try{yF(t,g.outShape)}catch(e){const n=`Error in fused conv2d: PReLU activation weights (${t}) is not compatible with the output shape of the conv2d (${g.outShape}).`;throw Error(n)}T=aD(u,"prelu weights","fused conv2d")}const y=(t,e)=>{yA("NHWC"===s,(()=>`Error in gradient of fused conv2D: got dataFormat of ${s} but only NHWC is currently supported.`));const[a,o,u,h]=e,p=zU(t,u,l);yA(g$(r),(()=>`Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${r}'`));const c=[z$(o.shape,p,a,n,i),WU(o,p,a.shape,n,i)];if(null!=h){const t=XU(h,p);c.push(t)}return c},I={x:d,filter:c,bias:_,preluActivationWeights:T},E={strides:n,pad:i,dataFormat:s,dilations:r,dimRoundingMode:a,activation:l,leakyreluAlpha:h};if(null==o){const t=tF(((t,e,n)=>{let i=Kk.runKernel(ON,I,E);return n([e,t,i]),f&&(i=E$(i,[i.shape[1],i.shape[2],i.shape[3]])),{value:i,gradFunc:y}}));return t(d,c)}{const t=tF(((t,e,n,i)=>{let s=Kk.runKernel(ON,I,E);return i([e,t,s,n]),f&&(s=E$(s,[s.shape[1],s.shape[2],s.shape[3]])),{value:s,gradFunc:y}}));return t(d,c,_)}}});const QU=uD({depthwiseConv2dNativeBackpropFilter_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i,s,r=[1,1],a){let o=t;3===t.rank&&(o=E$(t,[1,t.shape[0],t.shape[1],t.shape[2]]));let l=e;3===l.rank&&(l=E$(e,[1,e.shape[0],e.shape[1],e.shape[2]]));const u={x:o,dy:l},h={strides:i,pad:s,dimRoundingMode:a,dilations:r,filterShape:n};return Kk.runKernel(iM,u,h)}});const JU=uD({depthwiseConv2dNativeBackpropInput_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i,s,r=[1,1],a){let o=e,l=!1;3===e.rank&&(l=!0,o=E$(e,[1,e.shape[0],e.shape[1],e.shape[2]]));const u={dy:o,filter:n},h={strides:i,pad:s,dimRoundingMode:a,dilations:r,inputShape:t},p=Kk.runKernel(sM,u,h);return l?E$(p,[p.shape[1],p.shape[2],p.shape[3]]):p}});const ZU=uD({fusedDepthwiseConv2d_: /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function({x:t,filter:e,strides:n,pad:i,dataFormat:s="NHWC",dilations:r=[1,1],dimRoundingMode:a,bias:o,activation:l="linear",preluActivationWeights:u,leakyreluAlpha:h}){if(!1===qU(Kk.state.gradientDepth,l)){let p=iB(t,e,n,i,s,r,a);return null!=o&&(p=YL(p,o)),jU(p,l,u,h)}const p=aD(t,"x","depthwiseConv2d","float32"),c=aD(e,"filter","depthwiseConv2d","float32");let d=p,f=!1;3===p.rank&&(f=!0,d=E$(p,[1,p.shape[0],p.shape[1],p.shape[2]])),yA(4===d.rank,(()=>`Error in fused depthwiseConv2d: input must be rank 4, but got rank ${d.rank}.`)),yA(4===c.rank,(()=>`Error in fused depthwiseConv2d: filter must be rank 4, but got rank ${c.rank}.`)),yA(d.shape[3]===c.shape[2],(()=>`Error in fused depthwiseConv2d: number of input channels (${d.shape[3]}) must match the inChannels dimension in filter ${c.shape[2]}.`)),null==r&&(r=[1,1]),yA(_$(n,r),(()=>`Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides ${n} and dilations '${r}'`)),I$("fused depthwiseConv2d",i,a);const m=u$(d.shape,c.shape,n,r,i,a,!0);let g,_;null!=o&&(g=aD(o,"bias","fused conv2d"),[g]=Uk(g,p),yF(m.outShape,g.shape)),null!=u&&(_=aD(u,"prelu weights","fused depthwiseConv2d"));const T=(t,e)=>{yA(g$(r),(()=>`Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '${r}'`));const[s,o,u,h]=e,p=zU(t,u,l),c=JU(o.shape,p,s,n,i,r,a),d=QU(o,p,s.shape,n,i,r,a);if(null!=h){return[c,d,XU(g,p)]}return[c,d]},y={x:d,filter:c,bias:g,preluActivationWeights:_},I={strides:n,pad:i,dataFormat:s,dilations:r,dimRoundingMode:a,activation:l,leakyreluAlpha:h};if(null==o){const t=tF(((t,e,n)=>{let i=Kk.runKernel(MN,y,I);return n([e,t,i]),f&&(i=E$(i,[i.shape[1],i.shape[2],i.shape[3]])),{value:i,gradFunc:T}}));return t(d,c)}{const t=tF(((t,e,n,i)=>{let s=Kk.runKernel(MN,y,I);return i([e,t,s,n]),f&&(s=E$(s,[s.shape[1],s.shape[2],s.shape[3]])),{value:s,gradFunc:T}}));return t(d,c,g)}}});const tY=uD({fusedMatMul_: /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function({a:t,b:e,transposeA:n=!1,transposeB:i=!1,bias:s,activation:r="linear",preluActivationWeights:a,leakyreluAlpha:o=.2}){if(!1===qU(Kk.state.gradientDepth,r)){let l=zF(t,e,n,i);return null!=s&&(l=YL(l,s)),jU(l,r,a,o)}let l=aD(t,"a","fused matMul"),u=aD(e,"b","fused matMul");[l,u]=Uk(l,u);const h=n?l.shape[l.rank-2]:l.shape[l.rank-1],p=i?u.shape[u.rank-1]:u.shape[u.rank-2],c=n?l.shape[l.rank-1]:l.shape[l.rank-2],d=i?u.shape[u.rank-2]:u.shape[u.rank-1],f=l.shape.slice(0,-2),m=u.shape.slice(0,-2),g=bA(f),_=bA(m);yA(h===p,(()=>`Error in fused matMul: inner shapes (${h}) and (${p}) of Tensors with shapes ${l.shape} and ${u.shape} and transposeA=${n} and transposeB=${i} must match.`));const T=yF(l.shape.slice(0,-2),u.shape.slice(0,-2)).concat([c,d]),y=E$(l,n?[g,h,c]:[g,c,h]),I=E$(u,i?[_,d,p]:[_,p,d]);let E,b;null!=s&&(E=aD(s,"bias","fused matMul"),[E]=Uk(E,l),yF(T,E.shape)),null!=a&&(b=aD(a,"prelu weights","fused matMul"));const v=(t,e)=>{const[a,o,l,u]=e,h=zU(E$(t,l.shape),l,r);let p,c;if(n||i?!n&&i?(p=zF(h,o,!1,!1),c=zF(h,a,!0,!1)):n&&!i?(p=zF(o,h,!1,!0),c=zF(a,h,!1,!1)):(p=zF(o,h,!0,!0),c=zF(h,a,!0,!0)):(p=zF(h,o,!1,!0),c=zF(a,h,!0,!1)),null!=s){return[p,c,XU(u,h)]}return[p,c]},w={a:y,b:I,bias:E,preluActivationWeights:b},S={transposeA:n,transposeB:i,activation:r,leakyreluAlpha:o};if(null==s){const t=tF(((t,e,n)=>{const i=Kk.runKernel(AN,w,S);return n([t,e,i]),{value:E$(i,T),gradFunc:v}}));return t(y,I)}{const t=tF(((t,e,n,i)=>{const s=Kk.runKernel(AN,w,S);return i([t,e,s,n]),{value:E$(s,T),gradFunc:v}}));return t(y,I,E)}}});const eY=uD({hammingWindow_: /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){return GU(t,.54,.46)}});const nY=uD({hannWindow_: /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){return GU(t,.5,.5)}});const iY=uD({frame_: /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i=!1,s=0){let r=0;const a=[];for(;r+e<=t.size;)a.push(x$(t,r,e)),r+=n;if(i)for(;r`Error in cropAndResize: image must be rank 4,but got rank ${a.rank}.`)),yA(2===o.rank&&4===o.shape[1],(()=>`Error in cropAndResize: boxes must be have size [${u},4] but had shape ${o.shape}.`)),yA(1===l.rank&&l.shape[0]===u,(()=>`Error in cropAndResize: boxInd must be have size [${u}] but had shape ${o.shape}.`)),yA(2===i.length,(()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${i.length}.`)),yA(i[0]>=1&&i[1]>=1,(()=>`cropSize must be atleast [1,1], but was ${i}`)),yA("bilinear"===s||"nearest"===s,(()=>`method must be bilinear or nearest, but was ${s}`));const h={image:a,boxes:o,boxInd:l},p={method:s,extrapolationValue:r,cropSize:i};return Kk.runKernel(ZO,h,p)}});const aY=uD({flipLeftRight_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e=aD(t,"image","flipLeftRight","float32");yA(4===e.rank,(()=>`Error in flipLeftRight: image must be rank 4,but got rank ${e.rank}.`));const n={image:e};return Kk.runKernel(EM,n,{})}});const oY=uD({grayscaleToRGB_: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e=aD(t,"image","grayscaleToRGB"),n=e.rank-1,i=e.shape[n];yA(e.rank>=2,(()=>`Error in grayscaleToRGB: images must be at least rank 2, but got rank ${e.rank}.`)),yA(1===i,(()=>`Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${i}.`));const s=new Array(e.rank);return s.fill(1,0,n),s[n]=3,CB(e,s)}});const lY=uD({rgbToGrayscale_: /** * @license * Copyright 2023 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e=aD(t,"image","RGBToGrayscale"),n=e.rank-1,i=e.shape[n];yA(e.rank>=2,(()=>`Error in RGBToGrayscale: images must be at least rank 2, but got rank ${e.rank}.`)),yA(3===i,(()=>`Error in RGBToGrayscale: last dimension of an RGB image should be size 3, but got size ${i}.`));const s=e.dtype,r=BL(e,"float32"),a=EU([.2989,.587,.114]);let o;switch(e.rank){case 2:o=hB("ij,j->i",r,a);break;case 3:o=hB("ijk,k->ij",r,a);break;case 4:o=hB("ijkl,l->ijk",r,a);break;case 5:o=hB("ijklm,m->ijkl",r,a);break;case 6:o=hB("ijklmn,n->ijklm",r,a);break;default:throw new Error("Not a valid tensor rank.")}return o=OB(o,-1),BL(o,s)}});const uY=uD({rotateWithOffset_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n=0,i=.5){const s=aD(t,"image","rotateWithOffset","float32");yA(4===s.rank,(()=>`Error in rotateWithOffset: image must be rank 4,but got rank ${s.rank}.`));const r={image:s},a={radians:e,fillValue:n,center:i};return Kk.runKernel(RN,r,a)}}); /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function hY(t,e,n,i,s,r){null==i&&(i=.5),null==s&&(s=Number.NEGATIVE_INFINITY),null==r&&(r=0);const a=t.shape[0];return n=Math.min(n,a),yA(0<=i&&i<=1,(()=>`iouThreshold must be in [0, 1], but was '${i}'`)),yA(2===t.rank,(()=>`boxes must be a 2D tensor, but was of rank '${t.rank}'`)),yA(4===t.shape[1],(()=>`boxes must have 4 columns, but 2nd dimension was ${t.shape[1]}`)),yA(1===e.rank,(()=>"scores must be a 1D tensor")),yA(e.shape[0]===a,(()=>`scores has incompatible shape with boxes. Expected ${a}, but was ${e.shape[0]}`)),yA(0<=r&&r<=1,(()=>`softNmsSigma must be in [0, 1], but was '${r}'`)),{maxOutputSize:n,iouThreshold:i,scoreThreshold:s,softNmsSigma:r}}const pY=uD({nonMaxSuppression_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i=.5,s=Number.NEGATIVE_INFINITY){const r=aD(t,"boxes","nonMaxSuppression","float32"),a=aD(e,"scores","nonMaxSuppression","float32"),o=hY(r,a,n,i,s),l={maxOutputSize:n=o.maxOutputSize,iouThreshold:i=o.iouThreshold,scoreThreshold:s=o.scoreThreshold};return Kk.runKernel(cC,{boxes:r,scores:a},l)}}); /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function cY(t,e,n){const i=function(t,e,n){return function(t,e,n){let i=0,s=t.length,r=0,a=!1;for(;i>>1);const o=n(e,t[r]);o>0?i=r+1:(s=r,a=!o)}return a?i:-i-1}(t,e,n||dY)}(t,e,n),s=i<0?-(i+1):i;t.splice(s,0,e)}function dY(t,e){return t>e?1:ts&&u.push({score:e[t],boxIndex:t,suppressBeginIndex:0});u.sort(IY);const h=r>0?-.5/r:0,p=[],c=[];for(;p.length0;){const e=u.pop(),{score:n,boxIndex:r,suppressBeginIndex:a}=e;if(n=a;--n){const a=TY(t,r,p[n]);if(a>=i){o=!0;break}if(e.score=e.score*yY(i,h,a),e.score<=s)break}e.suppressBeginIndex=p.length,o||(e.score===n?(p.push(r),c.push(e.score)):e.score>s&&cY(u,e,IY))}const d=p.length,f=n-d;o&&f>0&&(p.push(...new Array(f).fill(0)),c.push(...new Array(f).fill(0)));const m={selectedIndices:p};return a&&(m.selectedScores=c),l&&(m.validOutputs=d),m}function TY(t,e,n){const i=t.subarray(4*e,4*e+4),s=t.subarray(4*n,4*n+4),r=Math.min(i[0],i[2]),a=Math.min(i[1],i[3]),o=Math.max(i[0],i[2]),l=Math.max(i[1],i[3]),u=Math.min(s[0],s[2]),h=Math.min(s[1],s[3]),p=Math.max(s[0],s[2]),c=Math.max(s[1],s[3]),d=(o-r)*(l-a),f=(p-u)*(c-h);if(d<=0||f<=0)return 0;const m=Math.max(r,u),g=Math.max(a,h),_=Math.min(o,p),T=Math.min(l,c),y=Math.max(_-m,0)*Math.max(T-g,0);return y/(d+f-y)}function yY(t,e,n){const i=Math.exp(e*n*n);return n<=t?i:0}function IY(t,e){return t.score-e.score||t.score===e.score&&e.boxIndex-t.boxIndex}const EY= /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ async function(t,e,n,i=.5,s=Number.NEGATIVE_INFINITY){const r=aD(t,"boxes","nonMaxSuppressionAsync"),a=aD(e,"scores","nonMaxSuppressionAsync"),o=hY(r,a,n,i,s);n=o.maxOutputSize,i=o.iouThreshold,s=o.scoreThreshold;const l=await Promise.all([r.data(),a.data()]),u=l[0],h=l[1],{selectedIndices:p}=fY(u,h,n,i,s);return r!==t&&r.dispose(),a!==e&&a.dispose(),EU(p,"int32")};const bY=uD({nonMaxSuppressionWithScore_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i=.5,s=Number.NEGATIVE_INFINITY,r=0){const a=aD(t,"boxes","nonMaxSuppression"),o=aD(e,"scores","nonMaxSuppression"),l=hY(a,o,n,i,s,r),u={boxes:a,scores:o},h={maxOutputSize:n=l.maxOutputSize,iouThreshold:i=l.iouThreshold,scoreThreshold:s=l.scoreThreshold,softNmsSigma:r=l.softNmsSigma},p=Kk.runKernel(fC,u,h);return{selectedIndices:p[0],selectedScores:p[1]}}});const vY= /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ async function(t,e,n,i=.5,s=Number.NEGATIVE_INFINITY,r=0){const a=aD(t,"boxes","nonMaxSuppressionAsync"),o=aD(e,"scores","nonMaxSuppressionAsync"),l=hY(a,o,n,i,s,r);n=l.maxOutputSize,i=l.iouThreshold,s=l.scoreThreshold,r=l.softNmsSigma;const u=await Promise.all([a.data(),o.data()]),h=u[0],p=u[1],{selectedIndices:c,selectedScores:d}=gY(h,p,n,i,s,r);return a!==t&&a.dispose(),o!==e&&o.dispose(),{selectedIndices:EU(c,"int32"),selectedScores:EU(d)}};const wY=uD({nonMaxSuppressionPadded_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i=.5,s=Number.NEGATIVE_INFINITY,r=!1){const a=aD(t,"boxes","nonMaxSuppression"),o=aD(e,"scores","nonMaxSuppression"),l=hY(a,o,n,i,s,null),u={boxes:a,scores:o},h={maxOutputSize:l.maxOutputSize,iouThreshold:l.iouThreshold,scoreThreshold:l.scoreThreshold,padToMaxOutputSize:r},p=Kk.runKernel(dC,u,h);return{selectedIndices:p[0],validOutputs:p[1]}}});const SY= /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ async function(t,e,n,i=.5,s=Number.NEGATIVE_INFINITY,r=!1){const a=aD(t,"boxes","nonMaxSuppressionAsync"),o=aD(e,"scores","nonMaxSuppressionAsync"),l=hY(a,o,n,i,s,null),u=l.maxOutputSize,h=l.iouThreshold,p=l.scoreThreshold,[c,d]=await Promise.all([a.data(),o.data()]),{selectedIndices:f,validOutputs:m}=mY(c,d,u,h,p,r);return a!==t&&a.dispose(),o!==e&&o.dispose(),{selectedIndices:EU(f,"int32"),validOutputs:nF(m,"int32")}};const xY=uD({resizeBilinear_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n=!1,i=!1){const s=aD(t,"images","resizeBilinear");yA(3===s.rank||4===s.rank,(()=>`Error in resizeBilinear: x must be rank 3 or 4, but got rank ${s.rank}.`)),yA(2===e.length,(()=>`Error in resizeBilinear: new shape must 2D, but got shape ${e}.`)),yA(!1===i||!1===n,(()=>"Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false."));let r=s,a=!1;3===s.rank&&(a=!0,r=E$(s,[1,s.shape[0],s.shape[1],s.shape[2]]));const[]=e,o={images:r},l={alignCorners:n,halfPixelCenters:i,size:e},u=Kk.runKernel(kC,o,l);return a?E$(u,[u.shape[1],u.shape[2],u.shape[3]]):u}});const RY=uD({resizeNearestNeighbor_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n=!1,i=!1){const s=aD(t,"images","resizeNearestNeighbor");yA(3===s.rank||4===s.rank,(()=>`Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${s.rank}.`)),yA(2===e.length,(()=>`Error in resizeNearestNeighbor: new shape must 2D, but got shape ${e}.`)),yA("float32"===s.dtype||"int32"===s.dtype,(()=>"`images` must have `int32` or `float32` as dtype")),yA(!1===i||!1===n,(()=>"Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false."));let r=s,a=!1;3===s.rank&&(a=!0,r=E$(s,[1,s.shape[0],s.shape[1],s.shape[2]]));const[]=e,o={images:r},l={alignCorners:n,halfPixelCenters:i,size:e},u=Kk.runKernel(CC,o,l);return a?E$(u,[u.shape[1],u.shape[2],u.shape[3]]):u}});const AY=uD({threshold_: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e="binary",n=!1,i=.5){const s=aD(t,"image","threshold"),r=s.shape[0]*s.shape[1];let a,o,l,u,h=WL(EU([i]),255);if(yA(3===s.rank,(()=>`Error in threshold: image must be rank 3,but got rank ${s.rank}.`)),yA(3===s.shape[2]||1===s.shape[2],(()=>`Error in threshold: image color channel must be equal to 3 or 1but got ${s.shape[2]}.`)),yA("int32"===s.dtype||"float32"===s.dtype,(()=>`Error in dtype: image dtype must be int32 or float32,but got dtype ${s.dtype}.`)),yA("otsu"===e||"binary"===e,(()=>`Method must be binary or otsu, but was ${e}`)),3===s.shape[2]){[a,o,l]=dU(s,[1,1,1],-1);const t=WL(a,.2989),e=WL(o,.587),n=WL(l,.114);u=YL(YL(t,e),n)}else u=t;if("otsu"===e){h=function(t,e){let n,i,s,r,a,o,l=EU([-1]),u=EU([0]),h=EU([0]);for(let p=0;p`Error in transform: image must be rank 4,but got rank ${a.rank}.`)),yA(2===o.rank&&(o.shape[0]===a.shape[0]||1===o.shape[0])&&8===o.shape[1],(()=>"Error in transform: Input transform should be batch x 8 or 1 x 8")),yA(null==r||2===r.length,(()=>`Error in transform: outputShape must be [height, width] or null, but got ${r}.`));const l={image:a,transforms:o},u={interpolation:n,fillMode:i,fillValue:s,outputShape:r};return Kk.runKernel(TN,l,u)}});const MY=uD({bandPart_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n){const i=aD(t,"a","bandPart");yA(i.rank>=2,(()=>`bandPart(): Rank must be at least 2, got ${i.rank}.`));const s=i.shape,[r,a]=i.shape.slice(-2);let o,l;"number"==typeof e?(yA(e%1==0,(()=>`bandPart(): numLower must be an integer, got ${e}.`)),yA(e<=r,(()=>`bandPart(): numLower (${e}) must not be greater than the number of rows (${r}).`)),o=aD(e<0?r:e,"numLower","bandPart")):(yA("int32"===e.dtype,(()=>"bandPart(): numLower's dtype must be an int32.")),o=oB(UB(e,0),r,pV(e,r))),"number"==typeof n?(yA(n%1==0,(()=>`bandPart(): numUpper must be an integer, got ${n}.`)),yA(n<=a,(()=>`bandPart(): numUpper (${n}) must not be greater than the number of columns (${a}).`)),l=aD(n<0?a:n,"numUpper","bandPart")):(yA("int32"===n.dtype,(()=>"bandPart(): numUpper's dtype must be an int32.")),l=oB(UB(n,0),a,pV(n,a)));const u=E$(YV(0,r,1,"int32"),[-1,1]),h=YV(0,a,1,"int32"),p=fF(u,h),c=QB(YB(p,o),FB(p,qF(l))),d=lV([r,a],i.dtype);return E$(_U(CU(E$(i,[-1,r,a])).map((t=>oB(c,t,d)))),s)}});const CY=uD({gramSchmidt_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){let e;if(Array.isArray(t)){e=!1,yA(null!=t&&t.length>0,(()=>"Gram-Schmidt process: input must not be null, undefined, or empty"));const n=t[0].shape[0];for(let e=1;e`Gram-Schmidt: Non-unique lengths found in the input vectors: (${t[e].shape[0]} vs. ${n})`))}else e=!0,t=dU(t,t.shape[0],0).map((t=>gU(t,[0])));yA(t.length<=t[0].shape[0],(()=>`Gram-Schmidt: Number of vectors (${t.length}) exceeds number of dimensions (${t[0].shape[0]}).`));const n=[],i=t;for(let e=0;e{let t=i[e];if(e>0)for(let i=0;i{yA(2===t.shape.length,(()=>`qr2d() requires a 2D Tensor, but got a ${t.shape.length}D Tensor.`));const n=t.shape[0],i=t.shape[1];let s=NB(n),r=VL(t);const a=bU([[1]],[1,1]);let o=VL(a);const l=n>=i?i:n;for(let t=0;t{const e=x$(r,[t,t],[n-t,1]),l=xB(e),u=x$(r,[t,t],[1,1]),h=oB(LB(u,0),bU([[-1]]),bU([[1]])),p=fF(u,WL(h,l)),c=HL(e,p);o=1===c.shape[0]?VL(a):w$([a,x$(c,[1,0],[c.shape[0]-1,c.shape[1]])],0);const d=qF(HL(zF(h,p),l)),f=x$(r,[t,0],[n-t,i]),m=WL(d,o),g=QF(o);if(0===t)r=fF(f,zF(m,zF(g,f)));else{const e=fF(f,zF(m,zF(g,f)));r=w$([x$(r,[0,0],[t,i]),e],0)}const _=QF(m),T=x$(s,[0,t],[n,s.shape[1]-t]);if(0===t)s=fF(T,zF(zF(T,o),_));else{const e=fF(T,zF(zF(T,o),_));s=w$([x$(s,[0,0],[n,t]),e],1)}return[o,r,s]})),wD([e,l,u])}return!e&&n>i&&(s=x$(s,[0,0],[n,i]),r=x$(r,[0,0],[i,i])),[s,r]}))}const kY=uD({qr_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e=!1){if(yA(t.rank>=2,(()=>`qr() requires input tensor to have a rank >= 2, but got rank ${t.rank}`)),2===t.rank)return NY(t,e);{const n=t.shape.slice(0,t.shape.length-2).reduce(((t,e)=>t*e)),i=CU(E$(t,[n,t.shape[t.shape.length-2],t.shape[t.shape.length-1]]),0),s=[],r=[];i.forEach((t=>{const[n,i]=NY(t,e);s.push(n),r.push(i)}));return[E$(_U(s,0),t.shape),E$(_U(r,0),t.shape)]}}}); /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ var DY;!function(t){t[t.NONE=0]="NONE",t[t.MEAN=1]="MEAN",t[t.SUM=2]="SUM",t[t.SUM_BY_NONZERO_WEIGHTS=3]="SUM_BY_NONZERO_WEIGHTS"}(DY||(DY={}));const LY=uD({computeWeightedLoss_:function(t,e,n=DY.SUM_BY_NONZERO_WEIGHTS){const i=aD(t,"losses","computeWeightedLoss");let s=null;null!=e&&(s=aD(e,"weights","computeWeightedLoss"));const r=null==s?i:WL(i,s);if(n===DY.NONE)return r;if(n===DY.SUM)return wB(r);if(n===DY.MEAN){if(null==s)return oV(r);{const t=i.size/s.size,e=HL(wB(r),wB(s));return t>1?HL(e,nF(t)):e}}if(n===DY.SUM_BY_NONZERO_WEIGHTS){if(null==s)return HL(wB(r),nF(i.size));{const t=WL(s,uV(i.shape)),e=BL(wB(_V(t,nF(0))),"float32");return HL(wB(r),e)}}throw Error(`Unknown reduction: ${n}`)}});const FY=uD({absoluteDifference_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i=DY.SUM_BY_NONZERO_WEIGHTS){const s=aD(t,"labels","absoluteDifference"),r=aD(e,"predictions","absoluteDifference");let a=null;null!=n&&(a=aD(n,"weights","absoluteDifference")),IA(s.shape,r.shape,"Error in absoluteDifference: ");const o=gF(fF(s,r));return LY(o,a,i)}});const PY=uD({cosineDistance_:function(t,e,n,i,s=DY.SUM_BY_NONZERO_WEIGHTS){const r=aD(t,"labels","cosineDistance"),a=aD(e,"predictions","cosineDistance");let o=null;null!=i&&(o=aD(i,"weights","cosineDistance")),IA(r.shape,a.shape,"Error in cosineDistance: ");const l=nF(1),u=fF(l,wB(WL(r,a),n,!0));return LY(u,o,s)}});const $Y=uD({hingeLoss_:function(t,e,n,i=DY.SUM_BY_NONZERO_WEIGHTS){let s=aD(t,"labels","hingeLoss");const r=aD(e,"predictions","hingeLoss");let a=null;null!=n&&(a=aD(n,"weights","hingeLoss")),IA(s.shape,r.shape,"Error in hingeLoss: ");const o=nF(1);s=fF(WL(nF(2),s),o);const l=HV(fF(o,WL(s,r)));return LY(l,a,i)}});const BY=uD({huberLoss_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i=1,s=DY.SUM_BY_NONZERO_WEIGHTS){const r=aD(t,"labels","huberLoss"),a=aD(e,"predictions","huberLoss");let o=null;null!=n&&(o=aD(n,"weights","huberLoss")),IA(r.shape,a.shape,"Error in huberLoss: ");const l=nF(i),u=gF(fF(a,r)),h=pV(u,l),p=fF(u,h),c=YL(WL(nF(.5),XL(h)),WL(l,p));return LY(c,o,s)}});const VY=uD({logLoss_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i=1e-7,s=DY.SUM_BY_NONZERO_WEIGHTS){const r=aD(t,"labels","logLoss"),a=aD(e,"predictions","logLoss");let o=null;null!=n&&(o=aD(n,"weights","logLoss")),IA(r.shape,a.shape,"Error in logLoss: ");const l=nF(1),u=nF(i),h=qF(WL(r,WB(YL(a,u)))),p=WL(fF(l,r),WB(YL(fF(l,a),u))),c=fF(h,p);return LY(c,o,s)}});const UY=uD({meanSquaredError_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i=DY.SUM_BY_NONZERO_WEIGHTS){const s=aD(t,"labels","meanSquaredError"),r=aD(e,"predictions","meanSquaredError");let a=null;null!=n&&(a=aD(n,"weights","meanSquaredError")),IA(s.shape,r.shape,"Error in meanSquaredError: ");const o=mU(s,r);return LY(o,a,i)}});const YY=uD({sigmoidCrossEntropy_:function(t,e,n,i=0,s=DY.SUM_BY_NONZERO_WEIGHTS){let r=aD(t,"multiClassLabels","sigmoidCrossEntropy");const a=aD(e,"logits","sigmoidCrossEntropy");let o=null;if(null!=n&&(o=aD(n,"weights","sigmoidCrossEntropy")),IA(r.shape,a.shape,"Error in sigmoidCrossEntropy: "),i>0){const t=nF(i),e=nF(1),n=nF(.5);r=YL(WL(r,fF(e,t)),WL(n,t))}const l= /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){const n=aD(t,"labels","sigmoidCrossEntropyWithLogits"),i=aD(e,"logits","sigmoidCrossEntropyWithLogits");IA(n.shape,i.shape,"Error in sigmoidCrossEntropyWithLogits: ");const s=HV(i),r=WL(i,n),a=zB(AB(qF(gF(i))));return YL(fF(s,r),a)}(r,a);return LY(l,o,s)}});const GY=uD({softmaxCrossEntropy_:function(t,e,n,i=0,s=DY.SUM_BY_NONZERO_WEIGHTS){let r=aD(t,"onehotLabels","softmaxCrossEntropy");const a=aD(e,"logits","softmaxCrossEntropy");let o=null;if(null!=n&&(o=aD(n,"weights","softmaxCrossEntropy")),IA(r.shape,a.shape,"Error in softmaxCrossEntropy: "),i>0){const t=nF(i),e=nF(1),n=nF(r.shape[1]);r=YL(WL(r,fF(e,t)),HL(t,n))}const l= /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n=-1){if(-1===n&&(n=e.rank-1),n!==e.rank-1)throw Error(`Softmax cross entropy along a non-last dimension is not yet supported. Labels / logits was rank ${e.rank} and dim was ${n}`);const i=tF(((t,e,i)=>{const s=KB(e,[n],!0),r=fF(BL(e,"float32"),s);i([t,r]);const a=qF(WL(r,t));return{value:wB(a,[n]),gradFunc:(t,e)=>{const[i,s]=e,r=_B(t.shape,[n]);return[WL(E$(t,r),fF(BL(i,"float32"),AB(s))),WL(E$(t,r),fF(AB(s),BL(i,"float32")))]}}}));return i(t,e)}(r,a);return LY(l,o,s)}});const HY=uD({sparseFillEmptyRows_: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i){const s=aD(t,"indices","sparseFillEmptyRows","int32"),r=aD(e,"values","sparseFillEmptyRows"),a=aD(n,"denseShape","sparseFillEmptyRows","int32"),o=aD(i,"defaultValue","sparseFillEmptyRows",r.dtype);if(2!==s.rank)throw new Error(`Indices should be Tensor2D but received shape\n ${s.shape}`);if(1!==r.rank)throw new Error(`Values should be Tensor1D but received shape ${r.shape}`);if(1!==a.rank)throw new Error(`Dense shape should be Tensor1D but received shape ${a.shape}`);if(0!==o.rank)throw new Error(`Default value should be a scalar but received shape ${o.shape}`);const l={indices:s,values:r,denseShape:a,defaultValue:o},u=Kk.runKernel(eN,l);return{outputIndices:u[0],outputValues:u[1],emptyRowIndicator:u[2],reverseIndexMap:u[3]}}});const WY=uD({sparseReshape_: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n){const i=aD(t,"inputIndices","sparseReshape","int32"),s=aD(e,"inputShape","sparseReshape","int32"),r=aD(n,"newShape","sparseReshape","int32");if(2!==i.rank)throw new Error(`Input indices should be Tensor2D but received shape\n ${i.shape}`);if(1!==s.rank)throw new Error(`Input shape should be Tensor1D but received shape ${s.shape}`);if(1!==r.rank)throw new Error(`New shape should be Tensor1D but received shape ${r.shape}`);const a={inputIndices:i,inputShape:s,newShape:r},o=Kk.runKernel(nN,a);return{outputIndices:o[0],outputShape:o[1]}}});const zY=uD({sparseSegmentMean_: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n){const i=aD(t,"data","sparseSegmentMean"),s=aD(e,"indices","sparseSegmentMean","int32"),r=aD(n,"segmentIds","sparseSegmentMean","int32");if(i.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==s.rank)throw new Error(`Indices should be Tensor1D but received shape\n ${s.shape}`);if(1!==r.rank)throw new Error(`Segment ids should be Tensor1D but received shape\n ${r.shape}`);const a={data:i,indices:s,segmentIds:r};return Kk.runKernel(iN,a)}});const XY=uD({sparseSegmentSum_: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n){const i=aD(t,"data","sparseSegmentSum"),s=aD(e,"indices","sparseSegmentSum","int32"),r=aD(n,"segmentIds","sparseSegmentSum","int32");if(i.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==s.rank)throw new Error(`Indices should be Tensor1D but received shape\n ${s.shape}`);if(1!==r.rank)throw new Error(`Segment ids should be Tensor1D but received shape\n ${r.shape}`);const a={data:i,indices:s,segmentIds:r};return Kk.runKernel(sN,a)}});const jY=uD({stringNGrams_: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i,s,r,a,o){const l=aD(t,"data","stringNGrams","string");if("string"!==l.dtype)throw new Error("Data must be of datatype string");if(1!==l.shape.length)throw new Error(`Data must be a vector, saw: ${l.shape}`);const u=aD(e,"dataSplits","stringNGrams");if("int32"!==u.dtype)throw new Error("Data splits must be of datatype int32");const h={separator:n,nGramWidths:i,leftPad:s,rightPad:r,padWidth:a,preserveShortSequences:o},p={data:l,dataSplits:u},c=Kk.runKernel(hN,p,h);return{nGrams:c[0],nGramsSplits:c[1]}}});const qY=uD({stringSplit_: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n=!0){const i=aD(t,"input","stringSplit","string"),s=aD(e,"delimiter","stringSplit","string");if(1!==i.rank)throw new Error(`Input should be Tensor1D but received shape ${i.shape}`);if(0!==s.rank)throw new Error(`Delimiter should be a scalar but received shape ${s.shape}`);const r={skipEmpty:n},a={input:i,delimiter:s},o=Kk.runKernel(pN,a,r);return{indices:o[0],values:o[1],shape:o[2]}}});const KY=uD({stringToHashBucketFast_: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e){const n=aD(t,"input","stringToHashBucketFast","string"),i={numBuckets:e};if(e<=0)throw new Error("Number of buckets must be at least 1");const s={input:n};return Kk.runKernel(cN,s,i)}});const QY=uD({staticRegexReplace_: /** * @license * Copyright 2023 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i=!0){const s=aD(t,"input","staticRegexReplace","string"),r={pattern:e,rewrite:n,replaceGlobal:i};return Kk.runKernel(lN,{x:s},r)}}),JY={fft:hU,ifft:pU,rfft:fU,irfft:cU},ZY={hammingWindow:eY,hannWindow:nY,frame:iY,stft:sY},tG={flipLeftRight:aY,grayscaleToRGB:oY,resizeNearestNeighbor:RY,resizeBilinear:xY,rgbToGrayscale:lY,rotateWithOffset:uY,cropAndResize:rY,nonMaxSuppression:pY,nonMaxSuppressionAsync:EY,nonMaxSuppressionWithScore:bY,nonMaxSuppressionWithScoreAsync:vY,nonMaxSuppressionPadded:wY,nonMaxSuppressionPaddedAsync:SY,threshold:AY,transform:OY},eG={bandPart:MY,gramSchmidt:CY,qr:kY},nG={absoluteDifference:FY,computeWeightedLoss:LY,cosineDistance:PY,hingeLoss:$Y,huberLoss:BY,logLoss:VY,meanSquaredError:UY,sigmoidCrossEntropy:YY,softmaxCrossEntropy:GY},iG={sparseFillEmptyRows:HY,sparseReshape:WY,sparseSegmentMean:zY,sparseSegmentSum:XY},sG={stringNGrams:jY,stringSplit:qY,stringToHashBucketFast:KY,staticRegexReplace:QY},rG=XP,aG="undefined"!=typeof requestAnimationFrame?requestAnimationFrame:"undefined"!=typeof setImmediate?setImmediate:t=>t();function oG(){return new Promise((t=>aG((()=>t()))))} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function lG(t,e){const n=t[0].length;t.forEach(((t,e)=>{yA(t.length===n,(()=>`Error in concat${n}D: rank of tensors[${e}] must be the same as the rank of the rest (${n})`))})),yA(e>=0&&e`Error in concat${n}D: axis must be between 0 and ${n-1}.`));const i=t[0];t.forEach(((t,s)=>{for(let r=0;r`Error in concat${n}D: Shape of tensors[${s}] (${t}) does not match the shape of the rest (${i}) along the non-concatenated axis ${s}.`))}))}function uG(t,e){const n=t[0].slice();for(let i=1;i=0)if(o>=0){if(o!==r)throw new Error(`rt input.shape and shape=${e} are incompatible: rt input.shape[${s+t}] = ${r} but shape[${s+t}] = ${o}`)}else i[a]=r}return i}function cG(t){const e={FIRST_DIM_SIZE:hG.FIRST_DIM_SIZE,VALUE_ROWIDS:hG.VALUE_ROWIDS,ROW_LENGTHS:hG.ROW_LENGTHS,ROW_SPLITS:hG.ROW_SPLITS,ROW_LIMITS:hG.ROW_LIMITS,ROW_STARTS:hG.ROW_STARTS},n=[];for(const i of t){if(!(i in e))break;n.push(e[i])}return n}function dG(t){return 0===t.length?0:t[0]===hG.FIRST_DIM_SIZE?t.length-1:t.length}function fG(t,e){if(null==t||null==e)return;const n=t.length,i=e.length;if(n>=i)throw new Error(`defaultValue.shape=${t} and ragged tensor flatValues.shape=${e}, are incompatible: defaultValue.rank = ${n} must be less than ragged tensor input flatValues.rank = ${i})`);for(let s=0;s=0&&i>=0&&1!==n&&n!==i)throw new Error(`defaultValue.shape=${t}, and ragged tensor input flatValues.shape=${e} are incompatible: defaultValue.shape[${s-t.length}] = ${n} but ragged tensor input.flatValues.shape[${s-t.length}] = ${i}`)}}!function(t){t[t.FIRST_DIM_SIZE=0]="FIRST_DIM_SIZE",t[t.VALUE_ROWIDS=1]="VALUE_ROWIDS",t[t.ROW_LENGTHS=2]="ROW_LENGTHS",t[t.ROW_SPLITS=3]="ROW_SPLITS",t[t.ROW_LIMITS=4]="ROW_LIMITS",t[t.ROW_STARTS=5]="ROW_STARTS"}(hG||(hG={})); /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const mG=30;function gG(t){return t<=mG?t:XA(t,Math.floor(Math.sqrt(t)))} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function _G(t,e,n){return[n*("number"==typeof t?t:t[0]),e*("number"==typeof t?t:t[1])]} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function TG(t,e,n,i=!0){let s=[];if(i)s=s.concat(e.slice(0)),s.push(t[0]/n),s=s.concat(t.slice(1));else{s=s.concat(t[0]);const n=e.length;for(let i=0;i=2*e+1||i%2==1?s.push(i):n.push(i);i.push(...n),i.push(0),i.push(...s)}return i}function IG(t,e,n,i=!0){const s=[];i?s.push(t[0]/n):s.push(t[0]*n);for(let n=1;n/g,UG=",",YG="...";function GG(t,e){const n=((t=t.replace(/\s/g,"")).length-t.replace(VG,"").length)/BG.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 ("${BG}").`);const[i,s]=t.split(BG);yA(-1===i.indexOf(YG),(()=>`The ellipsis notation ("${YG}") is not supported yet.`));const r=i.split(UG),a=r.length;if(e!==a)throw new Error(`Expected ${a} input tensors, received ${e}`);if(a>2)throw new Error("Support for more than 2 input tensors is not implemented yet.");const o=[];for(let t=0;t-1!==t.indexOf(e))))throw new Error(`Output subscripts contain the label ${e} not present in the input subscripts.`);-1===o.indexOf(e)&&o.push(e)}for(let t=0;t-1!==t)),{permutationIndices:n,expandDims:i}}function WG(t,e,n){const i=new Array(t);for(let t=0;t`Expected dimension ${i[e[t][n]]} at axis ${n} of input shaped ${JSON.stringify(s)}, but got dimension ${s[n]}`))}}function zG(t,e){const n=t,i=[];let s=0;0===t.length&&n.push(-1),s=t.length+1;for(let t=0;tt===e))}function jG(t,e){const n=[];for(let i=0;i"Number of splits must evenly divide the axis.")),i=new Array(e).fill(t.shape[n]/e);else{const s=e.reduce(((t,e)=>(-1===e&&(t+=1),t)),0);yA(s<=1,(()=>"There should be only one negative value in split array."));const r=e.indexOf(-1);if(-1!==r){const i=e.reduce(((t,e)=>e>0?t+e:t));e[r]=t.shape[n]-i}yA(t.shape[n]===e.reduce(((t,e)=>t+e)),(()=>"The sum of sizes must match the size of the axis dimension.")),i=e}return i} /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function KG(t){return`Received SparseTensor with denseShape[0] = 0 but\n indices.shape[0] = ${t}`}function QG(t,e){return`indices(${t}, 0) is invalid: ${e} < 0`}function JG(t,e,n){return`indices(${t}, 0) is invalid: ${e} >= ${n}`} /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function ZG(t,e){return`only one output dimension may be -1, not both ${t} and ${e}`}function tH(t,e){return`size ${t} must be non-negative, not ${e}`}function eH(){return"reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero"}function nH(t,e){return`Input to reshape is a SparseTensor with ${bA(t)}\n dense values, but the requested shape requires a multiple of ${bA(e)}. inputShape=${t} outputShape= ${e}`}function iH(t,e){return`Input to reshape is a tensor with ${bA(t)} dense values, but the requested shape has ${bA(e)}. inputShape=${t} outputShape=${e}`} /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function sH(){return"segment ids must be >= 0"}function rH(){return"segment ids are not increasing"}function aH(t,e){return`Segment id ${t} out of range [0, ${e}), possibly because segmentIds input is not sorted.`}function oH(t,e,n){return`Bad: indices[${t}] == ${e} out of range [0, ${n})`} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function lH(t,e){let n,i=!1;for(t<=mG?(n=t,i=!0):n=XA(t,Math.floor(Math.sqrt(t)));!i;)n>e||n===t?i=!0:n=XA(t,n+1);return n}function uH(t,e,n){const i=[],s=t.length;for(let r=0;rs))throw new Error(`Expect batchDims in the range of [-${s}, ${s}], but got ${i}`);if(i<0&&(i+=s),i>r)throw new Error(`batchDims (${i}) must be less than rank(x) (\n ${r}).`);if(nhk(t)))}catch(t){throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${t}`)}}function cH(t){return t.map((t=>uk(t)))} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ !function(){for(const t of SF)oF(t)}(); /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const dH={kernelName:dO,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>WL(t,TU(BL(n,"float32"),-1))}}},fH={kernelName:fO,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>{const e=XL(BL(n,"float32")),i=zL(fF(nF(1),e));return qF(HL(t,i))}}}},mH={kernelName:mO,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>{const e=zL(fF(XL(BL(n,"float32")),1));return HL(t,e)}}}},gH={kernelName:gO,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,i]=e,s=yF(n.shape,i.shape);return{a:()=>{let e=t;const i=TF(n.shape,s);return i.length>0&&(e=wB(e,i)),E$(e,n.shape)},b:()=>{let e=t;const n=TF(i.shape,s);return n.length>0&&(e=wB(e,n)),E$(e,i.shape)}}}},_H={kernelName:_O,saveAllInputs:!0,gradFunc:(t,e)=>{const n={};return e.forEach(((e,i)=>{n[i]=()=>t.clone()})),n}},TH={kernelName:IO,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>jL(n)}}},yH={kernelName:EO,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>jL(n)}}},IH={kernelName:bO,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>HL(t,zL(fF(nF(1),XL(BL(n,"float32")))))}}},EH={kernelName:vO,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>{const e=zL(YL(nF(1),XL(BL(n,"float32"))));return HL(t,e)}}}},bH={kernelName:xO,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,i]=e,s=yF(n.shape,i.shape);return{a:()=>{const e=YL(XL(n),XL(i));let r=WL(t,HL(i,e));const a=TF(n.shape,s);return a.length>0&&(r=wB(r,a)),E$(r,n.shape)},b:()=>{const e=YL(XL(n),XL(i));let r=qF(WL(t,HL(n,e)));const a=TF(i.shape,s);return a.length>0&&(r=wB(r,a)),E$(r,i.shape)}}}},vH={kernelName:wO,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>HL(t,YL(XL(BL(n,"float32")),1))}}},wH={kernelName:SO,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>HL(t,fF(nF(1),XL(BL(n,"float32"))))}}};const SH=uD({avgPool3dGrad_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i,s,r){const a=aD(t,"dy","avgPool3dGrad"),o=aD(e,"input","avgPool3dGrad");let l=a,u=o,h=!1;4===o.rank&&(h=!0,l=E$(a,[1,a.shape[0],a.shape[1],a.shape[2],a.shape[3]]),u=E$(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),yA(5===l.rank,(()=>`Error in avgPool3dGrad: dy must be rank 5 but got rank ${l.rank}.`)),yA(5===u.rank,(()=>`Error in avgPool3dGrad: input must be rank 5 but got rank ${u.rank}.`)),I$("avgPool3dGrad",s,r);const p={dy:l,input:u},c={filterSize:n,strides:i,pad:s,dimRoundingMode:r},d=Kk.runKernel(MO,p,c);return h?E$(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}}),xH={kernelName:OO,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[i]=e,{filterSize:s,strides:r,pad:a,dimRoundingMode:o}=n;return{x:()=>SH(t,i,s,r,a,o)}}};const RH=uD({avgPoolGrad_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i,s){const r=aD(t,"dy","avgPoolGrad"),a=aD(e,"input","avgPoolGrad");yA(a.rank===r.rank,(()=>`Rank of input (${a.rank}) does not match rank of dy (${r.rank})`));let o=a,l=r,u=!1;3===a.rank&&(u=!0,o=E$(a,[1,a.shape[0],a.shape[1],a.shape[2]]),l=E$(r,[1,r.shape[0],r.shape[1],r.shape[2]])),yA(4===l.rank,(()=>`Error in avgPoolGrad: dy must be rank 4 but got rank ${l.rank}.`)),yA(4===o.rank,(()=>`Error in avgPoolGrad: input must be rank 4 but got rank ${o.rank}.`));const h={dy:l,input:o},p={filterSize:n,strides:i,pad:s},c=Kk.runKernel(AO,h,p);return u?E$(c,[c.shape[1],c.shape[2],c.shape[3]]):c}}),AH={kernelName:RO,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[i]=e,{filterSize:s,strides:r,pad:a}=n;return{x:()=>RH(t,i,s,r,a)}}},OH={kernelName:CO,inputsToSave:["a","b"],gradFunc:(t,e,n)=>{const[i,s]=e,{transposeA:r,transposeB:a}=n;return r||a?!r&&a?{a:()=>zF(t,s,!1,!1),b:()=>zF(t,i,!0,!1)}:r&&!a?{a:()=>zF(s,t,!1,!0),b:()=>zF(i,t,!1,!1)}:{a:()=>zF(s,t,!0,!0),b:()=>zF(t,i,!0,!0)}:{a:()=>zF(t,s,!1,!0),b:()=>zF(i,t,!0,!1)}}},MH={kernelName:NO,gradFunc:(t,e,n)=>{const{blockShape:i,crops:s}=n;return{x:()=>SV(t,i,s)}}},CH={kernelName:LO,gradFunc:(t,e,n)=>{const i=n,s=i.inputShape,r=i.shape,a=Array.from(r);for(let t=s.length-1;t>=0;t--)if(s[t]===r[t])a[t]=1;else if(1!==s[t])throw new Error(`broadcastTo(): [${s}] cannot be broadcast to [${r}].`);const o=[];for(let t=0;t1&&o.push(t);return{x:()=>wB(t,o,!0)}}},NH={kernelName:PO,gradFunc:t=>({x:()=>t.clone()})},kH={kernelName:$O,gradFunc:t=>({x:()=>jL(t)})},DH={kernelName:BO,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[i]=e,{clipValueMin:s,clipValueMax:r}=n;return{x:()=>oB(QB(FB(i,s),YB(i,r)),t,jL(t))}}},LH={kernelName:UO,inputsToSave:["x"],gradFunc:dH.gradFunc},FH={kernelName:YO,saveAllInputs:!0,gradFunc:(t,e,n)=>{const i=e.map((t=>t.shape)),{axis:s}=n,r=kA(s,e[0].shape)[0],a=i.map((t=>t[r]));return dU(t,a,r).map((t=>()=>t))}},PH={kernelName:GO,inputsToSave:["x","filter"],gradFunc:(t,e,n)=>{const[i,s]=e,{dilations:r,strides:a,pad:o,dataFormat:l}=n;return yA(g$(r),(()=>`Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${r}'`)),{x:()=>z$(i.shape,t,s,a,o,l),filter:()=>WU(i,t,s.shape,a,o,l)}}},$H={kernelName:WO,inputsToSave:["dy","filter"],gradFunc:(t,e,n)=>{const[i,s]=e,{strides:r,pad:a,dataFormat:o,dimRoundingMode:l}=n;return{dy:()=>H$(t,s,r,a,o,1,l),filter:()=>WU(t,i,s.shape,r,a,o,l)}}};const BH=uD({conv3DBackpropFilter_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i,s){let r=t;4===t.rank&&(r=E$(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]]));let a=e;4===a.rank&&(a=E$(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]])),yA(5===r.rank,(()=>`Error in conv3dDerFilter: input must be rank 5, but got shape ${r.shape}.`)),yA(5===a.rank,(()=>`Error in conv3dDerFilter: dy must be rank 5, but got shape ${a.shape}.`)),yA(5===n.length,(()=>`Error in conv3dDerFilter: filterShape must be length 5, but got ${n}.`)),yA(r.shape[4]===n[3],(()=>`Error in conv3dDerFilter: depth of input ${r.shape[4]}) must match input depth in filter (${n[3]}.`)),yA(a.shape[4]===n[4],(()=>`Error in conv3dDerFilter: depth of dy (${a.shape[4]}) must match output depth for filter (${n[4]}).`));const o={x:r,dy:a},l={strides:i,pad:s,filterShape:n};return Kk.runKernel(XO,o,l)}}),VH={kernelName:zO,inputsToSave:["x","filter"],gradFunc:(t,e,n)=>{const{dilations:i,strides:s,pad:r}=n;yA(g$(i),(()=>`Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${i}'`));const[a,o]=e;return{x:()=>q$(a.shape,t,o,s,r),filter:()=>BH(a,t,o.shape,s,r)}}},UH={kernelName:qO,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>WL(qF(iU(BL(n,"float32"))),t)}}},YH={kernelName:KO,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>WL(sU(BL(n,"float32")),t)}}},GH={kernelName:JO,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[i]=e,{axis:s,exclusive:r,reverse:a}=n;return{x:()=>{const e=yB([s],i.rank);let n=tB(t,s,r,!a);return null!=e&&(n=QF(n,e)),n}}}},HH={kernelName:nM,inputsToSave:["x","filter"],gradFunc:(t,e,n)=>{const{dilations:i,strides:s,pad:r,dimRoundingMode:a}=n,o=null==i?[1,1]:i;yA(g$(o),(()=>`Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations '${o}'`));const[l,u]=e;return yA(4===l.rank,(()=>`Error in gradient of depthwiseConv2dNative: input must be rank 4, but got rank ${l.rank}.`)),yA(4===u.rank,(()=>`Error in gradient of depthwiseConv2dNative: filter must be rank 4, but got rank ${u.rank}.`)),yA(l.shape[3]===u.shape[2],(()=>`Error in gradient of depthwiseConv2d: number of input channels (${l.shape[3]}) must match the inChannels dimension in filter ${u.shape[2]}.`)),yA(_$(s,o),(()=>`Error in gradient of depthwiseConv2d: Either strides or dilations must be 1. Got strides ${s} and dilations '${o}'.`)),I$("depthwiseConv2d",r,a),{x:()=>JU(l.shape,t,u,s,r,o,a),filter:()=>QU(l,t,u.shape,s,r,o,a)}}},WH={kernelName:aM,inputsToSave:["x","filter"],gradFunc:(t,e,n)=>{const[i,s]=e,r={x:i,filter:s,dy:t},a={x:i,filter:s,dy:t};return{x:()=>Kk.runKernel(oM,r,n),filter:()=>Kk.runKernel(lM,a,n)}}},zH={kernelName:cM,outputsToSave:[!0],gradFunc:(t,e)=>{const[n]=e,i={dy:t,y:n};return{x:()=>Kk.runKernel(dM,i)}}},XH={kernelName:fM,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e,i=WL(AB(qF(XL(n))),2/Math.sqrt(Math.PI));return{x:()=>WL(t,i)}}},jH={kernelName:gM,outputsToSave:[!0],gradFunc:(t,e)=>{const[n]=e;return{x:()=>WL(t,n)}}},qH={kernelName:_M,inputsToSave:["input"],gradFunc:(t,e)=>{const[n]=e;return{input:()=>E$(t,n.shape)}}},KH={kernelName:TM,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>WL(t,AB(n))}}},QH={kernelName:bM,gradFunc:t=>({x:()=>jL(t)})},JH={kernelName:vM,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,i]=e,s=yF(n.shape,i.shape);return{a:()=>{const e=HL(t,BL(i,"float32")),r=TF(n.shape,s);return r.length>0?E$(wB(e,r),n.shape):e},b:()=>{let e=WL(t,BL(n,"float32"));const r=TF(i.shape,s);r.length>0&&(e=E$(wB(e,r),i.shape));const a=XL(i);return qF(HL(e,BL(a,"float32")))}}}},ZH={kernelName:wM,inputsToSave:["x","mean","variance","scale"],gradFunc:(t,e,n)=>{const{varianceEpsilon:i}=n,[s,r,a,o]=e,l=null==o?nF(1):o,u=TF(r.shape,s.shape),h=[];if(1===r.rank){for(let t=0;t1===r.rank?E$(WL(WL(t,CB(E$(d,[1,1,1,r.shape[0]]),h)),l),s.shape):E$(WL(WL(t,d),l),s.shape),mean:()=>{let t=WL(WL(d,nF(-1)),c);return 1===r.rank&&(t=wB(t,u)),E$(t,r.shape)},variance:()=>{let t=WL(WL(f,p),c);return 1===r.rank&&(t=wB(t,u)),E$(t,r.shape)},scale:()=>{const e=WL(p,d);let n=WL(t,e);return 1===r.rank&&(n=wB(n,u)),E$(n,r.shape)},offset:()=>{let e=t;return 1===r.rank&&(e=wB(e,u)),E$(e,r.shape)}}}},tW={kernelName:SM,inputsToSave:["x","indices"],gradFunc:(t,e,n)=>{const[i,s]=e,{axis:r,batchDims:a}=n,o=kA(r,i.shape)[0],l=(t,e,n)=>()=>{const i=t.shape,s=e.size,a=i.slice(0,o),l=a.length,u=i.slice(r,i.length).slice(1),h=u.length,p=eW(0,l),c=eW(l+1,l+1+h),d=nW([a,[s],u]),f=E$(n,d),m=E$(e,[s]),g=nW([[l],p,c]),_=QF(f,g);let T=MU(_,m,t.shape[o]);const y=IB(g);return T=QF(T,y),T};if(1===a){const e=i.shape[0],n=i.split(e,0);return{x:()=>{const e=_U(n.map(((e,n)=>l(e,s.slice(n,1),t.slice(n,1))())));return e.reshape(i.shape)},indices:()=>s}}return{x:l(i,s,t),indices:()=>s}}};function eW(t,e){const n=[];for(let i=t;i{const[n,i]=e;return{a:()=>jL(n),b:()=>jL(i)}}},sW={kernelName:OM,gradFunc:t=>({x:()=>BL(t,"float32")})},rW={kernelName:NM,gradFunc:t=>({x:()=>jL(t)})},aW={kernelName:kM,gradFunc:t=>({x:()=>jL(t)})},oW={kernelName:DM,gradFunc:t=>({x:()=>jL(t)})},lW={kernelName:LM,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[i]=e,{alpha:s}=n,r=LB(i,0);return{x:()=>oB(r,t,WL(t,s))}}},uW={kernelName:VM,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>HL(t,YL(n,1))}}},hW={kernelName:BM,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>HL(t,BL(n,"float32"))}}},pW={kernelName:WM,inputsToSave:[],outputsToSave:[!0],gradFunc:(t,e,n)=>{const[i]=e,{axis:s}=n;return{logits:()=>{const e=AB(i);return fF(t,WL(wB(t,s,!0),e))}}}};const cW=uD({localResponseNormalizationBackprop_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i=5,s=1,r=1,a=.5){const o={x:t,y:e,dy:n},l={depthRadius:i,bias:s,alpha:r,beta:a};return Kk.runKernel(jM,o,l)}}),dW={kernelName:XM,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(t,e,n)=>{const[i,s]=e,{depthRadius:r,bias:a,alpha:o,beta:l}=n;return{x:()=>cW(i,s,t,r,a,o,l)}}}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function fW(t,e,n,i){return e.rankWL(t,BL(aB(n,e),t.dtype))}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const mW={kernelName:KM,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(t,e,n)=>{const i=n,{reductionIndices:s}=i,r=e[0],a=fW(t,e[1],r,kA(s,r.shape));return{x:()=>a.x()}}},gW={kernelName:QM,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,i]=e;return{a:()=>WL(t,BL(FB(n,i),"float32")),b:()=>WL(t,BL(UB(n,i),"float32"))}}};const _W=uD({maxPool3dGrad_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i,s,r,a){const o=aD(t,"dy","maxPool3dGrad"),l=aD(e,"input","maxPool3dGrad"),u=aD(n,"output","maxPool3dGrad");let h=o,p=l,c=u,d=!1;4===l.rank&&(d=!0,h=E$(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]]),p=E$(l,[1,l.shape[0],l.shape[1],l.shape[2],l.shape[3]]),c=E$(u,[1,u.shape[0],u.shape[1],u.shape[2],u.shape[3]])),yA(5===h.rank,(()=>`Error in maxPool3dGrad: dy must be rank 5 but got rank ${h.rank}.`)),yA(5===p.rank,(()=>`Error in maxPool3dGrad: input must be rank 5 but got rank ${p.rank}.`)),yA(5===c.rank,(()=>`Error in maxPool3dGrad: output must be rank 5 but got rank ${c.rank}.`)),I$("maxPool3dGrad",r,a);const f={dy:h,input:p,output:c},m={filterSize:i,strides:s,pad:r,dimRoundingMode:a},g=Kk.runKernel(eC,f,m);return d?E$(g,[g.shape[1],g.shape[2],g.shape[3],g.shape[4]]):g}}),TW={kernelName:tC,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(t,e,n)=>{const[i,s]=e,{filterSize:r,strides:a,pad:o,dimRoundingMode:l}=n;return{x:()=>_W(t,i,s,r,a,o,l)}}};const yW=uD({maxPoolGrad_: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i,s,r,a){const o=aD(t,"dy","maxPoolGrad"),l=aD(e,"input","maxPoolGrad"),u=aD(n,"output","maxPoolGrad");yA(l.rank===o.rank,(()=>`Rank of input (${l.rank}) does not match rank of dy (${o.rank})`)),yA(4===o.rank,(()=>`Error in maxPoolGrad: dy must be rank 4 but got rank ${o.rank}.`)),yA(4===l.rank,(()=>`Error in maxPoolGrad: input must be rank 4 but got rank ${l.rank}.`)),I$("maxPoolGrad",r,a);const h={dy:o,input:l,output:u},p={filterSize:i,strides:s,pad:r,dimRoundingMode:a};return Kk.runKernel(ZM,h,p)}}),IW={kernelName:JM,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(t,e,n)=>{const[i,s]=e,{filterSize:r,strides:a,pad:o}=n;return{x:()=>yW(t,i,s,r,a,o)}}},EW={kernelName:aC,inputsToSave:["x"],gradFunc:(t,e,n)=>{const i=e[0],{paddings:s}=n,r=s.map((t=>t[0]));return{x:()=>x$(t,r,i.shape)}}},bW={kernelName:TC,inputsToSave:["x"],gradFunc:(t,e,n)=>{const i=e[0],{paddings:s}=n,r=s.map((t=>t[0]));return{x:()=>x$(t,r,i.shape)}}},vW={kernelName:IC,inputsToSave:["a","b"],outputsToSave:[!0],gradFunc:(t,e)=>{const[n,i,s]=e,r=n,a=i,o=yF(r.shape,a.shape);return{a:()=>{const e=BL(a,"float32");let n=WL(t,WL(e,dF(r,fF(e,nF(1)))));const i=TF(r.shape,o);return i.length>0&&(n=wB(n,i)),E$(n,r.shape)},b:()=>{const e=LB(r,0),n=oB(e,WB(r),jL(r));let i=WL(t,WL(s,n));const l=TF(a.shape,o);return l.length>0&&(i=wB(i,l)),E$(i,a.shape)}}}};function wW(t,e,n){const i=t.shape.length,s=i-n.length,r=yB(n,i);let a=t;null!=r&&(a=QF(t,r));const o=a.shape.slice(),l=o.splice(i-n.length,n.length).reduce(((t,e)=>t*e),1);o.push(l);let u= /** * @license * Copyright 2022 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n){const i=t.shape.slice();i[n]=1;const s=E$(e,i),r=Z$(t,n,!0,!1),a=Z$(t,n,!0,!0),o=WL(r,a);return WL(s,o)}(a.reshape(o),e,s);if(u=u.reshape(a.shape),null!=r){const t=IB(r);u=QF(u,t)}return u}const SW={kernelName:GC,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>{const e=LB(n,nF(0)),i=nF(vG),s=nF(wG),r=WL(t,s),a=WL(WL(t,i),AB(BL(n,"float32")));return oB(e,r,a)}}}},xW={kernelName:JC,gradFunc:(t,e,n)=>{const{blockShape:i,paddings:s}=n;return{x:()=>O$(t,i,s)}}},RW={kernelName:ZC,gradFunc:(t,e,n)=>{const{axis:i}=n;return{x:()=>w$(t,i)}}}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const AW=[dH,fH,mH,gH,_H,TH,yH,IH,EH,bH,vH,wH,xH,AH,OH,MH,CH,NH,kH,DH,LH,FH,$H,PH,VH,UH,YH,GH,HH,WH,{kernelName:hM,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,i]=e,s=yF(n.shape,i.shape);return{a:()=>{const e=HL(t,BL(i,"float32")),r=TF(n.shape,s);return r.length>0?E$(wB(e,r),n.shape):e},b:()=>{let e=WL(t,BL(n,"float32"));const r=TF(i.shape,s);r.length>0&&(e=E$(wB(e,r),i.shape));const a=XL(i);return qF(HL(e,BL(a,"float32")))}}}},zH,XH,jH,qH,KH,JH,QH,ZH,tW,iW,sW,rW,aW,oW,lW,uW,hW,pW,dW,mW,mW,gW,TW,IW,{kernelName:iC,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[i]=e,{axis:s}=n,r=kA(s,i.shape),a=bA(gB(i.shape,r)[1]);return{x:()=>{const e=i.shape.slice();r.forEach((t=>{e[t]=1}));const n=E$(t,e);return HL(WL(n,uV(i.shape,"float32")),a)}}}},{kernelName:sC,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(t,e,n)=>{const i=n,{axis:s}=i,[r,a]=e,o=fW(t,a,r,kA(s,r.shape));return{x:()=>o.x()}}},{kernelName:rC,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,i]=e;return{a:()=>WL(t,BL(YB(n,i),"float32")),b:()=>WL(t,BL(LB(n,i),"float32"))}}},EW,{kernelName:oC,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,i]=e,s=yF(n.shape,i.shape);return{a:()=>{const e=TF(n.shape,s);return e.length>0?E$(wB(t,e),n.shape):t},b:()=>{const e=WL(t,qF(kB(HL(n,i)))),r=TF(i.shape,s);return r.length>0?E$(wB(e,r),i.shape):e}}}},{kernelName:uC,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,i]=e,s=yF(n.shape,i.shape);return{a:()=>{const e=WL(t,BL(i,"float32")),r=TF(n.shape,s);return r.length>0?E$(wB(e,r),n.shape):e},b:()=>{const e=WL(t,BL(n,"float32")),r=TF(i.shape,s);return r.length>0?E$(wB(e,r),i.shape):e}}}},{kernelName:hC,gradFunc:t=>({x:()=>qF(t)})},{kernelName:gC,inputsToSave:["indices"],gradFunc:(t,e)=>{const n=e[0];return{indices:()=>lV(n.shape,"float32")}}},{kernelName:mC,gradFunc:t=>({x:()=>jL(t)})},{kernelName:_C,saveAllInputs:!0,gradFunc:(t,e,n)=>{const{axis:i}=n;return CU(t,i).map((t=>()=>t))}},bW,bW,vW,{kernelName:EC,inputsToSave:["x","alpha"],gradFunc:(t,e)=>{const[n,i]=e,s=LB(n,0);return{x:()=>oB(s,t,WL(t,i)),alpha:()=>{let e=oB(s,jL(t),WL(t,n));const r=TF(i.shape,t.shape);return r.length>0&&(e=wB(e,r)),E$(e,i.shape)}}}},{kernelName:bC,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[i]=e,{axis:s}=n;let r=[];return r=null==s?i.shape.map(((t,e)=>e)):"number"==typeof s?[s]:s,{x:()=>wW(i,t,r)}}},{kernelName:AC,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>HL(t,qF(XL(n)))}}},{kernelName:LC,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e,i=WL(YB(n,6),TU(n));return{x:()=>WL(t,BL(i,"float32"))}}},{kernelName:OC,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>WL(t,BL(TU(n),"float32"))}}},{kernelName:MC,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>E$(t,n.shape)}}},{kernelName:kC,inputsToSave:["images"],gradFunc:(t,e,n)=>{const[i]=e,s={dy:t,images:i};return{images:()=>Kk.runKernel(DC,s,n)}}},{kernelName:CC,inputsToSave:["images"],gradFunc:(t,e,n)=>{const[i]=e,s={dy:t,images:i};return{images:()=>Kk.runKernel(NC,s,n)}}},{kernelName:FC,gradFunc:(t,e,n)=>{const{dims:i}=n,s=kA(i,t.shape);return{x:()=>zV(t,s)}}},{kernelName:PC,gradFunc:t=>({x:()=>jL(t)})},{kernelName:$C,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>qF(HL(t,WL(dF(n,1.5),2)))}}},{kernelName:YC,inputsToSave:["condition"],gradFunc:(t,e)=>{const[n]=e;return{condition:()=>BL(jL(n),"float32"),t:()=>WL(t,BL(n,t.dtype)),e:()=>WL(t,BL(JB(n),t.dtype))}}},SW,{kernelName:jC,outputsToSave:[!0],gradFunc:(t,e)=>{const[n]=e;return{x:()=>WL(t,WL(n,fF(nF(1),n)))}}},{kernelName:XC,gradFunc:t=>({x:()=>jL(t)})},{kernelName:WC,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>WL(Q$(BL(n,"float32")),t)}}},{kernelName:zC,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>WL(J$(BL(n,"float32")),t)}}},{kernelName:HC,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[i]=e,{begin:s,size:r}=n,a=i.shape,[o,l]=OP(i,s,r),u=[];for(let e=0;eIV(t,u)}}},{kernelName:tN,outputsToSave:[!0],gradFunc:(t,e,n)=>{const[i]=e,{dim:s}=n,r=WL(t,i);return{logits:()=>fF(r,WL(wB(r,[s],true),i))}}},{kernelName:qC,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>WL(t,S$(n))}}},xW,xW,RW,RW,{kernelName:KC,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>HL(t,WL(zL(BL(n,"float32")),2))}}},{kernelName:aN,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,i]=e,s=nF(2);return{a:()=>WL(t,WL(s,fF(n,i))),b:()=>WL(t,WL(s,fF(i,n)))}}},{kernelName:oN,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>WL(t,WL(BL(n,"float32"),2))}}},{kernelName:SN,gradFunc:t=>({x:()=>jL(t)})},{kernelName:dN,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,i]=e,s=yF(n.shape,i.shape);return{a:()=>{let e=t;const i=TF(n.shape,s);return i.length>0&&(e=wB(e,i)),E$(e,n.shape)},b:()=>{let e=t;const n=TF(i.shape,s);return n.length>0&&(e=wB(e,n)),E$(qF(e),i.shape)}}}},{kernelName:QC,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[i]=e,s=i.shape.slice(),{axis:r}=n;kA(r,i.shape).forEach((t=>{s[t]=1}));const a=E$(t,s),o=WL(a,uV(i.shape,"float32"));return{x:()=>o}}},{kernelName:fN,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>HL(t,XL(Q$(n)))}}},{kernelName:mN,outputsToSave:[!0],gradFunc:(t,e)=>{const[n]=e;return{x:()=>WL(fF(nF(1),XL(n)),t)}}},{kernelName:gN,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[i]=e,{reps:s}=n;return{x:()=>{let e=jL(i);if(1===i.rank)for(let n=0;n{const i=n,{perm:s}=i,r=IB(s);return{x:()=>QF(t,r)}}},{kernelName:EN,gradFunc:(t,e,n)=>{const i=n,{axis:s}=i;return{value:()=>_U(t,s)}}},{kernelName:bN,inputsToSave:["segmentIds"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>function(t,e){const n=IF(e,jL(e)),i=DB(t,n);let s=FB(e,nF(0,"int32"));const r=i.rank-s.rank;for(let t=0;t({x:()=>jL(t)})}];for(const t of AW)BN(t); /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.abs=function(){return this.throwIfDisposed(),gF(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.acos=function(){return this.throwIfDisposed(),jP(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.acosh=function(){return this.throwIfDisposed(),qP(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.add=function(t){return this.throwIfDisposed(),YL(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.all=function(t,e){return this.throwIfDisposed(),QP(this,t,e)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.any=function(t,e){return this.throwIfDisposed(),JP(this,t,e)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.argMax=function(t){return this.throwIfDisposed(),ZP(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.argMin=function(t){return this.throwIfDisposed(),t$(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.asScalar=function(){return this.throwIfDisposed(),yA(1===this.size,(()=>"The array must have only 1 element.")),E$(this,[])}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.asType=function(t){return this.throwIfDisposed(),BL(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.as1D=function(){return this.throwIfDisposed(),E$(this,[this.size])}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.as2D=function(t,e){return this.throwIfDisposed(),E$(this,[t,e])}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.as3D=function(t,e,n){return this.throwIfDisposed(),E$(this,[t,e,n])}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.as4D=function(t,e,n,i){return this.throwIfDisposed(),E$(this,[t,e,n,i])}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.as5D=function(t,e,n,i,s){return this.throwIfDisposed(),E$(this,[t,e,n,i,s])}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.asin=function(){return this.throwIfDisposed(),e$(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.asinh=function(){return this.throwIfDisposed(),n$(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.atan=function(){return this.throwIfDisposed(),i$(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.atan2=function(t){return this.throwIfDisposed(),s$(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.atanh=function(){return this.throwIfDisposed(),r$(this)},Ok().prototype.avgPool=function(t,e,n,i){return this.throwIfDisposed(),b$(this,t,e,n,i)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.batchToSpaceND=function(t,e){return this.throwIfDisposed(),O$(this,t,e)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.batchNorm=function(t,e,n,i,s){return this.throwIfDisposed(),M$(this,t,e,n,i,s)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.broadcastTo=function(t){return this.throwIfDisposed(),P$(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.cast=function(t){return this.throwIfDisposed(),BL(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.ceil=function(){return this.throwIfDisposed(),$$(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.clipByValue=function(t,e){return this.throwIfDisposed(),B$(this,t,e)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.concat=function(t,e){return this.throwIfDisposed(),t instanceof Ak&&(t=[t]),w$([this,...t],e)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.conv1d=function(t,e,n,i,s,r){return this.throwIfDisposed(),W$(this,t,e,n,i,s,r)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.conv2dTranspose=function(t,e,n,i,s){return this.throwIfDisposed(),X$(this,t,e,n,i,s)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.conv2d=function(t,e,n,i,s,r){return this.throwIfDisposed(),H$(this,t,e,n,i,s,r)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.cos=function(){return this.throwIfDisposed(),Q$(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.cosh=function(){return this.throwIfDisposed(),J$(this)}, /** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the 'License'); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.cumprod=function(t,e,n){return this.throwIfDisposed(),Z$(this,t,e,n)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.cumsum=function(t,e,n){return this.throwIfDisposed(),tB(this,t,e,n)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.depthToSpace=function(t,e){return this.throwIfDisposed(),nB(this,t,e)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.depthwiseConv2d=function(t,e,n,i,s,r){return this.throwIfDisposed(),iB(this,t,e,n,i,s,r)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.dilation2d=function(t,e,n,i,s){return this.throwIfDisposed(),rB(this,t,e,n,i,s)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.divNoNan=function(t){return this.throwIfDisposed(),lB(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.div=function(t){return this.throwIfDisposed(),HL(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.dot=function(t){return this.throwIfDisposed(),uB(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.elu=function(){return this.throwIfDisposed(),pB(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.equal=function(t){return this.throwIfDisposed(),aB(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.erf=function(){return this.throwIfDisposed(),dB(this)}, /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.euclideanNorm=function(t,e){return this.throwIfDisposed(),RB(this,t,e)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.exp=function(){return this.throwIfDisposed(),AB(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.expandDims=function(t){return this.throwIfDisposed(),OB(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.expm1=function(){return this.throwIfDisposed(),MB(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.fft=function(){return this.throwIfDisposed(),hU(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.flatten=function(){return this.throwIfDisposed(),E$(this,[this.size])}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.floor=function(){return this.throwIfDisposed(),kB(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.floorDiv=function(t){return this.throwIfDisposed(),GL(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.gather=function(t,e,n){return this.throwIfDisposed(),DB(this,t,e,n)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.greaterEqual=function(t){return this.throwIfDisposed(),FB(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.greater=function(t){return this.throwIfDisposed(),LB(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.ifft=function(){return this.throwIfDisposed(),pU(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.irfft=function(){return this.throwIfDisposed(),cU(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.isFinite=function(){return this.throwIfDisposed(),PB(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.isInf=function(){return this.throwIfDisposed(),$B(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.isNaN=function(){return this.throwIfDisposed(),BB(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.leakyRelu=function(t){return this.throwIfDisposed(),VB(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.lessEqual=function(t){return this.throwIfDisposed(),YB(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.less=function(t){return this.throwIfDisposed(),UB(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.localResponseNormalization=function(t,e,n,i){return this.throwIfDisposed(),HB(this,t,e,n,i)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.logSigmoid=function(){return this.throwIfDisposed(),jB(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.logSoftmax=function(t){return this.throwIfDisposed(),qB(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.logSumExp=function(t,e){return this.throwIfDisposed(),KB(this,t,e)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.log=function(){return this.throwIfDisposed(),WB(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.log1p=function(){return this.throwIfDisposed(),zB(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.logicalAnd=function(t){return this.throwIfDisposed(),QB(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.logicalNot=function(){return this.throwIfDisposed(),JB(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.logicalOr=function(t){return this.throwIfDisposed(),ZB(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.logicalXor=function(t){return this.throwIfDisposed(),tV(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.matMul=function(t,e,n){return this.throwIfDisposed(),zF(this,t,e,n)},Ok().prototype.maxPool=function(t,e,n,i){return this.throwIfDisposed(),sV(this,t,e,n,i)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.max=function(t,e){return this.throwIfDisposed(),bB(this,t,e)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.maximum=function(t){return this.throwIfDisposed(),IF(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.mean=function(t,e){return this.throwIfDisposed(),oV(this,t,e)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.min=function(t,e){return this.throwIfDisposed(),vB(this,t,e)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.minimum=function(t){return this.throwIfDisposed(),pV(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.mirrorPad=function(t,e){return this.throwIfDisposed(),cV(this,t,e)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.mod=function(t){return this.throwIfDisposed(),dV(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.mul=function(t){return this.throwIfDisposed(),WL(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.neg=function(){return this.throwIfDisposed(),qF(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.norm=function(t,e,n){return this.throwIfDisposed(),xB(this,t,e,n)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.notEqual=function(t){return this.throwIfDisposed(),_V(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.oneHot=function(t,e=1,n=0){return this.throwIfDisposed(),XF(this,t,e,n)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.onesLike=function(){return this.throwIfDisposed(),TV(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.pad=function(t,e){return this.throwIfDisposed(),IV(this,t,e)},Ok().prototype.pool=function(t,e,n,i,s,r){return this.throwIfDisposed(),xV(this,t,e,n,i,s,r)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.pow=function(t){return this.throwIfDisposed(),dF(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.prelu=function(t){return this.throwIfDisposed(),RV(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.prod=function(t,e){return this.throwIfDisposed(),AV(this,t,e)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.reciprocal=function(){return this.throwIfDisposed(),GV(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.relu=function(){return this.throwIfDisposed(),HV(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.relu6=function(){return this.throwIfDisposed(),WV(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.reshapeAs=function(t){return this.throwIfDisposed(),E$(this,t.shape)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.reshape=function(t){return this.throwIfDisposed(),E$(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.resizeBilinear=function(t,e,n){return this.throwIfDisposed(),xY(this,t,e,n)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.resizeNearestNeighbor=function(t,e,n){return this.throwIfDisposed(),RY(this,t,e,n)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.reverse=function(t){return this.throwIfDisposed(),zV(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.rfft=function(){return this.throwIfDisposed(),fU(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.round=function(){return this.throwIfDisposed(),QV(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.rsqrt=function(){return this.throwIfDisposed(),JV(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.selu=function(){return this.throwIfDisposed(),ZV(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.separableConv2d=function(t,e,n,i,s,r){return this.throwIfDisposed(),tU(this,t,e,n,i,s,r)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.sigmoid=function(){return this.throwIfDisposed(),S$(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.sign=function(){return this.throwIfDisposed(),nU(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.sin=function(){return this.throwIfDisposed(),iU(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.sinh=function(){return this.throwIfDisposed(),sU(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.slice=function(t,e){return this.throwIfDisposed(),x$(this,t,e)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.softmax=function(t){return this.throwIfDisposed(),uU(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.softplus=function(){return this.throwIfDisposed(),XB(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.spaceToBatchND=function(t,e){return this.throwIfDisposed(),SV(this,t,e)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.split=function(t,e){return this.throwIfDisposed(),dU(this,t,e)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.sqrt=function(){return this.throwIfDisposed(),zL(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.square=function(){return this.throwIfDisposed(),XL(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.squaredDifference=function(t){return this.throwIfDisposed(),mU(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.squeeze=function(t){return this.throwIfDisposed(),gU(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.stack=function(t,e){this.throwIfDisposed();const n=t instanceof Ak?[this,t]:[this,...t];return _U(n,e)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.step=function(t){return this.throwIfDisposed(),TU(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.stridedSlice=function(t,e,n,i,s,r,a,o){return this.throwIfDisposed(),yU(this,t,e,n,i,s,r,a,o)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.sub=function(t){return this.throwIfDisposed(),fF(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.sum=function(t,e){return this.throwIfDisposed(),wB(this,t,e)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.tan=function(){return this.throwIfDisposed(),IU(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.tanh=function(){return this.throwIfDisposed(),R$(this)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.tile=function(t){return this.throwIfDisposed(),CB(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.toBool=function(){return this.throwIfDisposed(),BL(this,"bool")}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.toFloat=function(){return this.throwIfDisposed(),BL(this,"float32")}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.toInt=function(){return this.throwIfDisposed(),BL(this,"int32")}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.topk=function(t,e){return this.throwIfDisposed(),RU(this,t,e)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.transpose=function(t){return this.throwIfDisposed(),QF(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.unique=function(t){return this.throwIfDisposed(),OU(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.unsortedSegmentSum=function(t,e){return this.throwIfDisposed(),MU(this,t,e)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.unstack=function(t){return this.throwIfDisposed(),CU(this,t)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.where=function(t,e){return this.throwIfDisposed(),oB(t,this,e)}, /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Ok().prototype.zerosLike=function(){return this.throwIfDisposed(),jL(this)}; /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ class OW extends Error{constructor(t){super(t),Object.setPrototypeOf(this,OW.prototype)}}class MW extends Error{constructor(t){super(t),Object.setPrototypeOf(this,MW.prototype)}}class CW extends Error{constructor(t){super(t),Object.setPrototypeOf(this,CW.prototype)}}class NW extends Error{constructor(t){super(t),Object.setPrototypeOf(this,NW.prototype)}}class kW extends Error{constructor(t){super(t),Object.setPrototypeOf(this,kW.prototype)}}Error; /** * @license * Copyright 2022 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ class DW{constructor(t){this.maxEntries=t||100,this.cache=new Map}get(t){let e;return this.cache.has(t)&&(e=this.cache.get(t),this.cache.delete(t),this.cache.set(t,e)),e}put(t,e){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.maxEntries){const t=this.cache.keys().next().value;this.cache.delete(t)}this.cache.set(t,e)}getMaxEntries(){return this.maxEntries}setMaxEntries(t){if(t<0)throw new Error(`The maxEntries of LRU caches must be at least 0, but got ${t}.`);if(this.maxEntries>t)for(let e=0;ee.toUpperCase()))}let YW={};function GW(t){if(null==t)return null;const e={};return e.className=t.getClassName(),e.config=t.getConfig(),e}function HW(t){if(null!=t&&"object"==typeof t)if(Array.isArray(t))t.forEach((t=>HW(t)));else{const e=Object.keys(t);for(const n of e){const e=t[n];null!=e&&"object"==typeof e&&(Array.isArray(e)||"ndarray"!==e.type||"number"!=typeof e.value?HW(e):t[n]=e.value)}}}function WW(t,e={},n={},i="object",s=!1){if("string"==typeof t){const s=t;let r;if(s in n)r=n[s];else if(s in YW)r=YW[s];else if(r=e[s],null==r)throw new CW(`Unknown ${i}: ${t}. This may be due to one of the following reasons:\n1. The ${i} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.\n2. The custom ${i} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);return r}{const r=t;if(null==r.className||null==r.config)throw new CW(`${i}: Improper config format: ${JSON.stringify(r)}.\n'className' and 'config' must set.`);const a=r.className;let o,l;if(a in n?[o,l]=n[a]:a in YW?[o,l]=YW.className:a in e&&([o,l]=e[a]),null==o)throw new CW(`Unknown ${i}: ${a}. This may be due to one of the following reasons:\n1. The ${i} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.\n2. The custom ${i} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);if(null!=l){const t={};for(const e of Object.keys(YW))t[e]=YW[e];for(const e of Object.keys(n))t[e]=n[e];r.config.customObjects=t;const e=Object.assign({},YW);for(const t of Object.keys(n))YW[t]=n[t];HW(r.config);const i=l(o,r.config,n,s);return YW=Object.assign({},e),i}{const t=Object.assign({},YW);for(const t of Object.keys(n))YW[t]=n[t];const e=new o(r.config);return YW=Object.assign({},t),e}}}function zW(t,e){return-1*function(t,e){return te?1:0}(t,e)}function XW(t){if(null==t)return t;const e=[];for(const n of t)-1===e.indexOf(n)&&e.push(n);return e}function jW(t){if(null==t)throw new CW(`Invalid value in obj: ${JSON.stringify(t)}`);for(const e in t)if(t.hasOwnProperty(e))return!1;return!0}function qW(t,e,n){if(null!=n&&t.indexOf(n)<0)throw new CW(`${n} is not a valid ${e}. Valid values are ${t} or null/undefined.`)}function KW(t,e,n=0,i=1/0){return FW(n>=0),FW(i>=n),Array.isArray(t)&&t.length>=n&&t.length<=i&&t.every((t=>typeof t===e))}function QW(t,e){Array.isArray(t)?(yA(t.length>0,(()=>`${e} is unexpectedly an empty array.`)),t.forEach(((t,n)=>QW(t,`element ${n+1} of ${e}`)))):yA(Number.isInteger(t)&&t>0,(()=>`Expected ${e} to be a positive integer, but got ${JW(t)}.`))}function JW(t){return null===t?"null":Array.isArray(t)?"["+t.map((t=>JW(t))).join(",")+"]":"string"==typeof t?`"${t}"`:`${t}`}function ZW(t){return"relu"===t?"relu":"linear"===t?"linear":"elu"===t?"elu":null} /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ let tz=0;function ez(){return tz++}const nz={};function iz(t=""){return t in nz||(nz[t]=0),nz[t]+=1,t+nz[t].toString()} /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ const sz=["channelsFirst","channelsLast"],rz=["nearest","bilinear"],az=["valid","same","causal"],oz=["max","avg"],lz=["sum","mul","concat","ave"],uz=new Map;function hz(t){qW(sz,"DataFormat",t)}function pz(t){qW(az,"PaddingMode",t)}function cz(t){qW(oz,"PoolMode",t)}const dz=[],fz="/";function mz(t,e){dz.push(t);try{const t=e();return dz.pop(),t}catch(t){throw dz.pop(),t}}function gz(t){if(!yz(t))throw new Error("Not a valid tensor name: '"+t+"'");return(0===dz.length?"":dz.join(fz)+fz)+t}function _z(t){if(!yz(t))throw new Error("Not a valid tensor name: '"+t+"'");uz.has(t)||uz.set(t,0);const e=uz.get(t);if(uz.set(t,uz.get(t)+1),e>0){const n=`${t}_${e}`;return uz.set(n,1),n}return t}const Tz=new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);function yz(t){return!!t.match(Tz)}function Iz(t,e,n){null==e&&(e=0),null==n&&(n=t.length);let i=1;for(let s=e;se&&(e=i)}return e}function vz(t,e){if(e{switch(t.rank){case 1:return rU(t,e,n);case 2:return aU(t,[e,0],[n,t.shape[1]]);case 3:return oU(t,[e,0,0],[n,t.shape[1],t.shape[2]]);case 4:return lU(t,[e,0,0,0],[n,t.shape[1],t.shape[2],t.shape[3]]);case 5:return x$(t,[e,0,0,0,0],[n,t.shape[1],t.shape[2],t.shape[3],t.shape[4]]);case 6:return x$(t,[e,0,0,0,0,0],[n,t.shape[1],t.shape[2],t.shape[3],t.shape[4],t.shape[5]]);default:throw new CW(`sliceAlongFirstAxis() received an unsupported tensor rank: ${t.rank}`)}}))}function Oz(t,e,n){return vD((()=>{switch(t.rank){case 1:return rU(t,e,n);case 2:return aU(t,[0,e],[t.shape[0],n]);case 3:return oU(t,[0,0,e],[t.shape[0],t.shape[1],n]);case 4:return lU(t,[0,0,0,e],[t.shape[0],t.shape[1],t.shape[2],n]);default:throw new CW(`sliceAlongLastAxis() received an unsupported tensor rank: ${t.rank}`)}}))}function Mz(t,e,n,i){return vD((()=>{switch(t.rank){case 1:return rU(t,e,n);case 2:switch(i){case 1:return Az(t,e,n);case 2:return Oz(t,e,n);default:throw new CW(`The axis is not within the rank of the tensor ${i}`)}case 3:switch(i){case 1:return Az(t,e,n);case 2:return oU(t,[0,e,0],[t.shape[0],n,t.shape[2]]);case 3:return Oz(t,e,n);default:throw new CW(`The axis is not within the rank of the tensor ${i}`)}case 4:switch(i){case 1:return Az(t,e,n);case 2:return lU(t,[0,e,0,0],[t.shape[0],n,t.shape[2],t.shape[3]]);case 3:return lU(t,[0,0,e,0],[t.shape[0],t.shape[1],n,t.shape[3]]);case 4:return Oz(t,e,n);default:throw new CW(`The axis is not within the rank of the tensor ${i}`)}default:throw new CW(`sliceAlongLastAxis() received an unsupported tensor rank: ${t.rank}`)}}))}function Cz(t,e=-1){let n;return e<0&&(n=t[0].rank,e=0!==n?n:0),e===t[0].rank&&(e=-1),w$(t,e)}function Nz(t,e){switch(t.rank){case 1:return V$([t,e]);case 2:return U$([t,e],0);case 3:return Y$([t,e],0);case 4:return G$([t,e],0);default:throw new CW(`concatAlongFirstAxis() received an unsupported tensor rank: ${t.rank}`)}}function kz(t,e){if(Array.isArray(e)||(e=[e]),t.rank!==e.length)throw new CW(`The length of input n (${e.length}) does not match the number of dimensions in input x (${t.rank})`);return CB(t,e)}function Dz(t,e=0,n=1,i,s){return $V(t,e,n,i,s)}function Lz(t,e,n,i){if(t.rank<2||e.rank<2)throw new NW(`dot requires both inputs to be rank >= 2 but got x shape = ${t.shape} and y shape = ${e.shape}`);if(e.rank>=3){if(t.shape.slice(-1)[0]!==e.shape.slice(-2)[0])throw new NW(`If rank y >= 3, then the second last dim of y must equal the last dim of x but got x shape = ${t.shape} and y shape = ${e.shape}`)}if(2===t.rank&&2===e.rank){return tY({a:t,b:e,transposeA:!1,transposeB:!1,bias:i?$z(t.rank,i,"channelsLast"):null,activation:n})}{const s=t.shape.slice(),r=s.pop();t=E$(t,[-1,r]);const a=e.shape.slice(),o=a.pop(),l=a.pop(),u=[...a,o],h=Array.from({length:e.rank},((t,n)=>0===n?e.rank-2:n<=e.rank-2?n-1:n));e=E$(QF(e,h),[l,-1]);const p=[...s,...u];return E$(tY({a:t,b:e,transposeA:!1,transposeB:!1,bias:i?$z(t.rank,i,"channelsLast"):null,activation:n}),p)}}function Fz(t,e,n){return vD((()=>(e=Array.isArray(e)?EU(e,"int32"):BL(e,"int32"),DB(t,e,n))))}function Pz(t){return WL(t,t)}function $z(t,e,n){const i=e.shape;if(1!==e.rank&&e.rank!==t)throw new CW(`Unexpected bias dimensions: ${e.rank}; expected it to be 1 or ${t}`);if(5===t){if("channelsFirst"===n)return 1===i.length?E$(e,[1,i[0],1,1,1]):E$(e,[1,i[3],i[0],i[1],i[2]]);if("channelsLast"===n)return 1===i.length?E$(e,[1,1,1,1,i[0]]):E$(e,[1].concat(i))}else if(4===t){if("channelsFirst"===n)return 1===i.length?E$(e,[1,i[0],1,1]):E$(e,[1,i[2],i[0],i[1]]);if("channelsLast"===n)return 1===i.length?E$(e,[1,1,1,i[0]]):E$(e,[1].concat(i))}else if(3===t){if("channelsFirst"===n)return 1===i.length?E$(e,[1,i[0],1]):E$(e,[1,i[1],i[0]]);if("channelsLast"===n)return 1===i.length?E$(e,[1,1,i[0]]):E$(e,[1].concat(i))}else if(t<3)return e;throw new CW(`Unsupported input rank by biasAdd: ${e.rank}`)}function Bz(t,e,n){return vD((()=>(null==n&&(n="channelsLast"),hz(n),YL(t,$z(t.rank,e,n)))))}function Vz(t,e,n,i){return vD((()=>UU(t,e,n,i)))}function Uz(t,e,n=!1){return n?t():e()} /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ const Yz=["fanIn","fanOut","fanAvg"],Gz=["normal","uniform","truncatedNormal"];class Hz extends rF{fromConfigUsesCustomObjects(){return!1}getConfig(){return{}}}class Wz extends Hz{apply(t,e){return lV(t,e)}}Wz.className="Zeros",oF(Wz);class zz extends Hz{apply(t,e){return uV(t,e)}}zz.className="Ones",oF(zz);class Xz extends Hz{constructor(t){if(super(),"object"!=typeof t)throw new CW(`Expected argument of type ConstantConfig but got ${t}`);if(void 0===t.value)throw new CW(`config must have value set but got ${t}`);this.value=t.value}apply(t,e){return vD((()=>WL(nF(this.value),uV(t,e))))}getConfig(){return{value:this.value}}}Xz.className="Constant",oF(Xz);class jz extends Hz{constructor(t){super(),this.DEFAULT_MINVAL=-.05,this.DEFAULT_MAXVAL=.05,this.minval=t.minval||this.DEFAULT_MINVAL,this.maxval=t.maxval||this.DEFAULT_MAXVAL,this.seed=t.seed}apply(t,e){return VV(t,this.minval,this.maxval,e,this.seed)}getConfig(){return{minval:this.minval,maxval:this.maxval,seed:this.seed}}}jz.className="RandomUniform",oF(jz);class qz extends Hz{constructor(t){super(),this.DEFAULT_MEAN=0,this.DEFAULT_STDDEV=.05,this.mean=t.mean||this.DEFAULT_MEAN,this.stddev=t.stddev||this.DEFAULT_STDDEV,this.seed=t.seed}apply(t,e){if("float32"!==(e=e||"float32")&&"int32"!==e)throw new NW(`randomNormal does not support dType ${e}.`);return Dz(t,this.mean,this.stddev,e,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}qz.className="RandomNormal",oF(qz);class Kz extends Hz{constructor(t){super(),this.DEFAULT_MEAN=0,this.DEFAULT_STDDEV=.05,this.mean=t.mean||this.DEFAULT_MEAN,this.stddev=t.stddev||this.DEFAULT_STDDEV,this.seed=t.seed}apply(t,e){if("float32"!==(e=e||"float32")&&"int32"!==e)throw new NW(`truncatedNormal does not support dType ${e}.`);return AU(t,this.mean,this.stddev,e,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}Kz.className="TruncatedNormal",oF(Kz);class Qz extends Hz{constructor(t){super(),this.gain=null!=t.gain?t.gain:1}apply(t,e){return vD((()=>{if(2!==t.length||t[0]!==t[1])throw new CW("Identity matrix initializer can only be used for 2D square matrices.");return WL(this.gain,NB(t[0]))}))}getConfig(){return{gain:this.gain}}}Qz.className="Identity",oF(Qz);class Jz extends Hz{constructor(t){if(super(),t.scale<0)throw new CW(`scale must be a positive float. Got: ${t.scale}`); /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ var e;this.scale=null==t.scale?1:t.scale,this.mode=null==t.mode?"fanIn":t.mode,e=this.mode,qW(Yz,"FanMode",e),this.distribution=null==t.distribution?"normal":t.distribution,function(t){qW(Gz,"Distribution",t)}(this.distribution),this.seed=t.seed}apply(t,e){const n=function(t,e="channelsLast"){let n,i;if(hz(e),2===t.length)n=t[0],i=t[1];else if(-1!==[3,4,5].indexOf(t.length)){if("channelsFirst"===e){const e=Iz(t,2);n=t[1]*e,i=t[0]*e}else if("channelsLast"===e){const e=Iz(t,0,t.length-2);n=t[t.length-2]*e,i=t[t.length-1]*e}}else{const e=Iz(t);n=Math.sqrt(e),i=Math.sqrt(e)}return[n,i]}(t),i=n[0],s=n[1];let r=this.scale;if("fanIn"===this.mode?r/=Math.max(1,i):"fanOut"===this.mode?r/=Math.max(1,s):r/=Math.max(1,(i+s)/2),"normal"===this.distribution){const n=Math.sqrt(r);if("float32"!==(e=e||"float32")&&"int32"!==e)throw new NW(`${this.getClassName()} does not support dType ${e}.`);return AU(t,0,n,e,this.seed)}{const n=Math.sqrt(3*r);return VV(t,-n,n,e,this.seed)}}getConfig(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}}}Jz.className="VarianceScaling",oF(Jz);class Zz extends Jz{constructor(t){super({scale:1,mode:"fanAvg",distribution:"uniform",seed:null==t?null:t.seed})}getClassName(){return Jz.className}}Zz.className="GlorotUniform",oF(Zz);class tX extends Jz{constructor(t){super({scale:1,mode:"fanAvg",distribution:"normal",seed:null==t?null:t.seed})}getClassName(){return Jz.className}}tX.className="GlorotNormal",oF(tX);class eX extends Jz{constructor(t){super({scale:2,mode:"fanIn",distribution:"normal",seed:null==t?null:t.seed})}getClassName(){return Jz.className}}eX.className="HeNormal",oF(eX);class nX extends Jz{constructor(t){super({scale:2,mode:"fanIn",distribution:"uniform",seed:null==t?null:t.seed})}getClassName(){return Jz.className}}nX.className="HeUniform",oF(nX);class iX extends Jz{constructor(t){super({scale:1,mode:"fanIn",distribution:"normal",seed:null==t?null:t.seed})}getClassName(){return Jz.className}}iX.className="LeCunNormal",oF(iX);class sX extends Jz{constructor(t){super({scale:1,mode:"fanIn",distribution:"uniform",seed:null==t?null:t.seed})}getClassName(){return Jz.className}}sX.className="LeCunUniform",oF(sX);class rX extends Hz{constructor(t){super(),this.DEFAULT_GAIN=1,this.ELEMENTS_WARN_SLOW=2e3,this.gain=null==t.gain?this.DEFAULT_GAIN:t.gain,this.seed=t.seed}apply(t,e){return vD((()=>{if(t.length<2)throw new NW("Shape must be at least 2D.");if("int32"!==e&&"float32"!==e&&void 0!==e)throw new TypeError(`Unsupported data type ${e}.`);const n=bA(t.slice(0,-1)),i=t[t.length-1],s=n*i;s>this.ELEMENTS_WARN_SLOW&&console.warn(`Orthogonal initializer is being called on a matrix with more than ${this.ELEMENTS_WARN_SLOW} (${s}) elements: Slowness may result.`);const r=Dz([Math.max(i,n),Math.min(i,n)],0,1,e,this.seed),a=eG.qr(r,!1);let o=a[0];const l=a[1].flatten().stridedSlice([0],[Math.min(i,n)*Math.min(i,n)],[Math.min(i,n)+1]);return o=WL(o,l.sign()),nt*e));return e} /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ const mX="Variable";class gX{constructor(t,e="float32",n=mX,i=!0,s=null){this.dtype=null==e?"float32":e,this.shape=t.shape,this.id=ez(),n=null==n?mX:n,this.originalName=gz(n),this.name=_z(this.originalName),this.trainable_=i,this.constraint=s,this.val=kU(t,this.trainable_,this.name,this.dtype)}read(){return this.assertNotDisposed(),this.val}write(t){return this.assertNotDisposed(),function(t,e){if(t.shape.toString()!==e.shape.toString())throw new Error("Shape mismatch: "+JSON.stringify(t.shape)+" vs. "+JSON.stringify(e.shape))}(this.val,t),this.val.id!==t.id&&(this.val.assign(t),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(t){this.trainable_=t,this.val.trainable=t}}function _X(t){return t.map((t=>t.read()))}function TX(t){t.forEach((t=>{t[0].write(t[1])}))} /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ class yX{constructor(t){this.dtype=t.dtype,this.shape=t.shape,null!=t.shape?this.ndim=t.shape.length:this.ndim=t.ndim,this.maxNDim=t.maxNDim,this.minNDim=t.minNDim,this.axes=t.axes||{}}}class IX{constructor(t,e,n,i,s,r,a){this.dtype=t,this.shape=e,this.sourceLayer=n,this.inputs=i,this.callArgs=s,this.outputTensorIndex=a,this.id=ez(),null!=r&&(this.originalName=gz(r),this.name=_z(this.originalName)),this.rank=e.length}}let EX=0;class bX{constructor(t,e){this.callArgs=e,this.id=EX++,this.outboundLayer=t.outboundLayer,this.inboundLayers=t.inboundLayers,this.nodeIndices=t.nodeIndices,this.tensorIndices=t.tensorIndices,this.inputTensors=t.inputTensors,this.outputTensors=t.outputTensors,this.inputMasks=t.inputMasks,this.outputMasks=t.outputMasks,this.inputShapes=t.inputShapes,this.outputShapes=t.outputShapes;for(const e of t.inboundLayers)null!=e&&e.outboundNodes.push(this);t.outboundLayer.inboundNodes.push(this)}getConfig(){const t=[];for(const e of this.inboundLayers)null!=e?t.push(e.name):t.push(null);return{outboundLayer:this.outboundLayer?this.outboundLayer.name:null,inboundLayers:t,nodeIndices:this.nodeIndices,tensorIndices:this.tensorIndices}}}let vX=0;class wX extends rF{constructor(t={}){super(),this._callHook=null,this._addedWeightNames=[],this._stateful=!1,this.id=vX++,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 e=t.name;if(!e){const t=this.getClassName();e=VW(t)+"_"+iz(t)}if(this.name=e,this.trainable_=null==t.trainable||t.trainable,null!=t.inputShape||null!=t.batchInputShape){let e;if(null!=t.batchInputShape)e=t.batchInputShape;else if(null!=t.inputShape){let n=null;null!=t.batchSize&&(n=t.batchSize),e=[n].concat(t.inputShape)}this.batchInputShape=e;let n=t.dtype;null==n&&(n=t.inputDType),null==n&&(n="float32"),this.dtype=n}null!=t.weights?this.initialWeights=t.weights:this.initialWeights=null,this._refCount=null,this.fastWeightInitDuringBuild=!1}static nodeKey(t,e){return t.name+"_ib-"+e.toString()}getNodeAtIndex(t,e){if(0===this.inboundNodes.length)throw new MW(`The layer has never been called and thus has no defined ${e}.`);if(this.inboundNodes.length<=t)throw new CW(`Asked to get ${e} at node ${t}, but the layer has only ${this.inboundNodes.length} inbound nodes.`);return this.inboundNodes[t]}getInputAt(t){return $W(this.getNodeAtIndex(t,"input").inputTensors)}getOutputAt(t){return $W(this.getNodeAtIndex(t,"output").outputTensors)}get input(){if(this.inboundNodes.length>1)throw new OW(`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 OW(`Layer ${this.name} is not connected, no input to return.`);return $W(this.getNodeAtIndex(0,"input").inputTensors)}get output(){if(0===this.inboundNodes.length)throw new OW(`Layer ${this.name} has no inbound nodes.`);if(this.inboundNodes.length>1)throw new OW(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use \`getOutputAt(nodeIndex)\` instead.`);return $W(this.getNodeAtIndex(0,"output").outputTensors)}get losses(){return this._losses}calculateLosses(){return this.losses.map((t=>t()))}get updates(){return this._updates}get built(){return this._built}set built(t){this._built=t}get trainable(){return this.trainable_}set trainable(t){this._trainableWeights.forEach((e=>e.trainable=t)),this.trainable_=t}get trainableWeights(){return this.trainable_?this._trainableWeights.filter((t=>t.trainable)):[]}set trainableWeights(t){this._trainableWeights=t}get nonTrainableWeights(){return this.trainable?this._trainableWeights.filter((t=>!t.trainable)).concat(this._nonTrainableWeights):this._trainableWeights.concat(this._nonTrainableWeights)}set nonTrainableWeights(t){this._nonTrainableWeights=t}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(t){const e=BW(t);if(null==this.inputSpec||0===this.inputSpec.length)return;const n=BW(this.inputSpec);if(e.length!==n.length)throw new CW(`Layer ${this.name} expects ${n.length} inputs, but it received ${e.length} input tensors. Input received: ${t}`);for(let t=0;ts.maxNDim)throw new CW(`Input ${t} is incompatible with layer ${this.name}: expected max_ndim=${s.maxNDim}, found ndim=${r}`);if(null!=s.minNDim&&r=0?e[i]:e[e.length+i];if(null!=r&&-1===[r,null].indexOf(a))throw new CW(`Input ${t} is incompatible with layer ${this.name}: expected axis ${i} of input shape to have value ${r} but got shape ${e}.`)}}if(null!=s.shape)for(let e=0;e{if(!this.built){this.assertInputCompatibility(t);const e=[];for(const n of BW(t))e.push(n.shape);this.build($W(e)),this.built=!0,this.initialWeights&&this.setWeights(this.initialWeights),null===this._refCount&&s&&(this._refCount=1)}if(this.assertInputCompatibility(t),s){let i=this.call(t,e);this.supportsMasking&&this.setMaskMetadata(t,i);const s=BW(i),r=[];for(let t of s)-1!==n.indexOf(t)&&(t=t.clone()),r.push(t);if(i=$W(r),null!=this.activityRegularizer)throw new NW("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return i}{const n=function(t){t=BW(t);const e=[];for(const n of t)e.push(n.shape);return $W(e)}(t),i=this.computeOutputShape(n);let s;const r="float32";if(this.warnOnIncompatibleInputShape(Array.isArray(t)?n[0]:n),s=null!=i&&i.length>0&&Array.isArray(i[0])?i.map(((n,i)=>new IX(r,n,this,BW(t),e,this.name,i))):new IX(r,i,this,BW(t),e,this.name),this.addInboundNode(t,s,null,null,n,i,e),this._refCount++,null!=this.activityRegularizer)throw new NW("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return s}}))}warnOnIncompatibleInputShape(t){if(null!=this.batchInputShape)if(t.length!==this.batchInputShape.length)console.warn(`The rank of the input tensor provided (shape: ${JSON.stringify(t)}) does not match that of the batchInputShape (${JSON.stringify(this.batchInputShape)}) of the layer ${this.name}`);else{let e=!1;this.batchInputShape.forEach(((n,i)=>{null!=n&&null!=t[i]&&t[i]!==n&&(e=!0)})),e&&console.warn(`The shape of the input tensor (${JSON.stringify(t)}) 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 OW(`The layer ${this.name} has never been called and thus has no defined output shape.`);const t=[];for(const e of this.inboundNodes){const n=JSON.stringify(e.outputShapes);-1===t.indexOf(n)&&t.push(n)}if(1===t.length){const t=this.inboundNodes[0].outputShapes;return Array.isArray(t)&&Array.isArray(t[0])&&1===t.length?t[0]:t}throw new OW(`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 MW(`You tried to call countParams() on ${this.name}, but the layer is not built yet. Build it first by calling build(batchInputShape).`);return fX(this.weights)}build(t){this.built=!0}getWeights(t=!1){return _X(t?this.trainableWeights:this.weights)}setWeights(t){vD((()=>{const e=this.weights;if(e.length!==t.length)throw new CW(`You called setWeights(weights) on layer "${this.name}" with a weight list of length ${t.length}, but the layer was expecting ${e.length} weights. Provided weights: ${t}...`);if(0===e.length)return;const n=[],i=_X(e);for(let s=0;ss.apply(u.read()))),null==r&&(r=!0),r?this._trainableWeights.push(u):this._nonTrainableWeights.push(u),u}setFastWeightInitDuringBuild(t){this.fastWeightInitDuringBuild=t}addLoss(t){null==t||Array.isArray(t)&&0===t.length||(t=BW(t),void 0!==this._losses&&null!==this._losses&&this.losses.push(...t))}computeOutputShape(t){return t}computeMask(t,e){if(!this.supportsMasking){if(null!=e){if(!Array.isArray(e))throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`);e.forEach((t=>{if(null!=t)throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`)}))}return null}return e}setMaskMetadata(t,e,n){if(!this.supportsMasking)return;const i=this.computeMask(t,n),s=BW(e),r=BW(i);if(s.length!==r.length)throw new Error(`${this.name} outputs ${s.length} tensors but ${s.length} masks for those tensors`);for(let t=0;tt.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 t=0;return 0==--this._refCount&&(t=this.disposeWeights()),{refCountAfterDispose:this._refCount,numDisposedVariables:t}}}function SX(t,e,n){if((null==e||null!=n&&n>0)&&(e=t.sourceLayer,n=t.nodeIndex),0===e.inboundNodes.length)return[t];{const t=e.inboundNodes[n];if(0===t.inboundLayers.length)return t.inputTensors;{const e=[];for(let n=0;nt.name)),l=[],u=e.names();for(const t of o)-1!==u.indexOf(t)?l.push(e.getValue(t)):l.push(null);null!=i&&(i.maxNumTensors=-1/0,i.minNumTensors=1/0);const h=o.join(",")+"|"+e.names().sort().join(",");let p,c=OX.get(h);if(null==c){const t=function(t,e){yA(null!=t&&t.length>0,(()=>"Expected at least one fetch, got none"));let n=[],i={};if(1===t.length){const s=kX(t[0],e);n=s.sorted,i=s.recipientMap}else{const s=new Set;for(const r of t){const{sorted:t,recipientMap:a}=kX(r,e);for(const e of t)s.has(e.name)||(n.push(e),s.add(e.name));for(const t in a)null==i[t]&&(i[t]=new Set),a[t].forEach((e=>i[t].add(e)))}}return{sorted:n,recipientCounts:NX(i)}}(a,e);c=t.sorted,p=t.recipientCounts,OX.put(h,c),MX.put(h,p)}p={},s||Object.assign(p,MX.get(h));const d=new AX(e);for(let t=0;ti.maxNumTensors&&(i.maxNumTensors=t),t0;){const t=r[r.length-1];if(n.has(t.name)){r.pop();continue}const e=a[a.length-1]===r.length-1;if(0===t.inputs.length||e)r.pop(),i.push(t),n.add(t.name),e&&a.pop();else{a.push(r.length-1);for(const e of t.inputs)null==s[e.name]&&(s[e.name]=new Set),s[e.name].add(t.name),n.has(e.name)||r.push(e)}}return{sorted:i,recipientMap:s}}function DX(t){let e;if(1===t.sourceLayer.inboundNodes.length)e=t.sourceLayer.output;else{let n=null;for(let e=0;ezL(wB(WL(t,t),e,!0))))}lO().registerFlag("TOPOLOGICAL_SORT_CACHE_MAX_ENTRIES",(()=>100),(function(t){null!=OX&&OX.setMaxEntries(t),null!=MX&&MX.setMaxEntries(t)}));class FX extends rF{getConfig(){return{}}}class PX extends FX{constructor(t){super(),this.defaultMaxValue=2,this.defaultAxis=0,this.maxValue=null!=t.maxValue?t.maxValue:this.defaultMaxValue,this.axis=null!=t.axis?t.axis:this.defaultAxis}apply(t){return vD((()=>{const e=LX(t,this.axis),n=B$(e,0,this.maxValue);return WL(t,HL(n,YL(Sz(),e)))}))}getConfig(){return{maxValue:this.maxValue,axis:this.axis}}}PX.className="MaxNorm",oF(PX);class $X extends FX{constructor(t){super(),this.defaultAxis=0,this.axis=null!=t.axis?t.axis:this.defaultAxis}apply(t){return vD((()=>HL(t,YL(Sz(),LX(t,this.axis)))))}getConfig(){return{axis:this.axis}}}$X.className="UnitNorm",oF($X);class BX extends FX{apply(t){return HV(t)}}BX.className="NonNeg",oF(BX);class VX extends FX{constructor(t){super(),this.defaultMinValue=0,this.defaultMaxValue=1,this.defaultRate=1,this.defaultAxis=0,this.minValue=null!=t.minValue?t.minValue:this.defaultMinValue,this.maxValue=null!=t.maxValue?t.maxValue:this.defaultMaxValue,this.rate=null!=t.rate?t.rate:this.defaultRate,this.axis=null!=t.axis?t.axis:this.defaultAxis}apply(t){return vD((()=>{const e=LX(t,this.axis),n=YL(WL(this.rate,B$(e,this.minValue,this.maxValue)),WL(1-this.rate,e));return WL(t,HL(n,YL(Sz(),e)))}))}getConfig(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}}}VX.className="MinMaxNorm",oF(VX);const UX={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function YX(t){return GW(t)}function GX(t,e={}){return WW(t,aF.getMap().classNameMap,e,"constraint")}function HX(t){if(null==t)return null;if("string"==typeof t){return GX({className:t in UX?UX[t]:t,config:{}})}return t instanceof FX?t:GX(t)} /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ function WX(t){return new PX(t)}function zX(t){return new $X(t)}function XX(){return new BX}function jX(t){return new VX(t)} /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ function qX(){return new Wz}function KX(){return new zz}function QX(t){return new Xz(t)}function JX(t){return new jz(t)}function ZX(t){return new qz(t)}function tj(t){return new Kz(t)}function ej(t){return new Qz(t)}function nj(t){return new Jz(t)}function ij(t){return new Zz(t)}function sj(t){return new tX(t)}function rj(t){return new eX(t)}function aj(t){return new nX(t)}function oj(t){return new iX(t)}function lj(t){return new sX(t)}function uj(t){return new rX(t)} /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ async function hj(t){if(null==t)return;const e=[],n=[],i=[];for(const s in t){const r=t[s];if("number"!=typeof r){const t=r;e.push(t.data()),n.push(s),i.push(t)}}if(e.length>0){const s=await Promise.all(e);for(let e=0;eYL(this.totals[t],WL(i,n))));this.totals[t]=s,null!=e&&e.dispose()}}}async onEpochEnd(t,e){if(null!=e)for(const t of this.params.metrics)null!=this.totals[t]&&("number"==typeof this.totals[t]?e[t]=this.totals[t]/this.seen:vD((()=>{const n=WL(HL(1,this.seen),this.totals[t]);e[t]=n,this.totals[t].dispose(),SD(e[t])})))}}class gj extends dj{async onTrainBegin(t){this.epoch=[],this.history={}}async onEpochEnd(t,e){null==e&&(e={}),this.epoch.push(t);for(const t in e)null==this.history[t]&&(this.history[t]=[]),this.history[t].push(e[t])}async syncData(){const t=[],e=[],n=[];for(const i in this.history){const s=this.history[i];for(let r=0;r{const a=null!=n?n():ok();return a-snew _j(t,e)))}class yj{constructor(){}static registerCallbackConstructor(t,e){yA(t>=0&&Number.isInteger(t),(()=>`Verbosity level is expected to be an integer >= 0, but got ${t}`)),yj.checkForDuplicate(e),null==yj.constructors[t]&&(yj.constructors[t]=[]),yj.constructors[t].push(e)}static checkForDuplicate(t){for(const e in yj.constructors){yj.constructors[+e].forEach((e=>{if(e===t)throw new CW("Duplicate callback constructor.")}))}}static clear(){yj.constructors={}}static createCallbacks(t){const e=[];for(const n in yj.constructors){const i=+n;t>=i&&e.push(...yj.constructors[i])}return e.map((t=>new t))}}function Ij(t,e,n,i,s,r,a,o,l){const u=new gj,h=[new mj,...yj.createCallbacks(e)];null!=t&&h.push(...t),h.push(u);const p=new fj(h);return p.setParams({epochs:n,initialEpoch:i,samples:s,steps:r,batchSize:a,verbose:e,doValidation:o,metrics:l}),{callbackList:p,history:u}} /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ function Ej(t,e={},n=!1){return WW(t,aF.getMap().classNameMap,e,"layer",n)} /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ function bj(t,e){return vD((()=>{"float32"!==t.dtype&&(t=BL(t,"float32"));const n=wB(Pz(t),e,!0),i=pF(n.shape,Sz()),s=zL(IF(n,i));return HL(t,s)}))}function vj(t,e){return vD((()=>oV(Pz(fF(e,t)),-1)))}function wj(t,e){return vD((()=>oV(gF(fF(e,t)),-1)))}function Sj(t,e){return vD((()=>{const n=fF(t,e),i=B$(gF(t),Sz(),Number.MAX_VALUE),s=gF(HL(n,i));return WL(100,oV(s,-1))}))}function xj(t,e){return vD((()=>{const n=B$(e,Sz(),Number.MAX_VALUE),i=WB(YL(1,n)),s=B$(t,Sz(),Number.MAX_VALUE),r=WB(YL(1,s));return oV(Pz(fF(i,r)),-1)}))}function Rj(t,e,n=!1){return vD((()=>{if(n)e=uU(e);else{const t=wB(e,e.shape.length-1,!0);e=HL(e,t)}return e=B$(e,Sz(),1-Sz()),qF(wB(WL(BL(t,"float32"),WB(e)),e.shape.length-1))}))}function Aj(t,e,n=!1){return vD((()=>{const i=BL(kB(function(t){const e=[Iz(t.shape)];return E$(t,e)}(t)),"int32"),s=(e=B$(e,Sz(),1-Sz())).shape;return Rj(E$(XF(i,s[s.length-1]),s),e,n)}))}function Oj(t,e){return vD((()=>{let n;return n=B$(e,Sz(),1-Sz()),n=WB(HL(n,fF(1,n))),oV(function(t,e){if(!SA(t.shape,e.shape))throw new CW(`logits and labels must have the same shape, but got shapes ${JSON.stringify(t.shape)} and ${JSON.stringify(e.shape)}`);return vD((()=>{const n=HV(e),i=qF(gF(e));return YL(fF(n,WL(e,t)),zB(AB(i)))}))}(t,n),-1)}))}function Mj(t,e){return vD((()=>{const n=B$(t,Sz(),1),i=B$(e,Sz(),1);return wB(WL(t,WB(HL(n,i))),-1)}))}function Cj(t,e){return vD((()=>{const n=bj(t,-1),i=bj(e,-1),s=WL(n,i);return qF(wB(s,-1))}))}yj.constructors={};const Nj={meanSquaredError:vj,meanAbsoluteError:wj,meanAbsolutePercentageError:Sj,meanSquaredLogarithmicError:xj,squaredHinge:function(t,e){return vD((()=>{const n=IF(0,fF(1,WL(t,e)));return oV(Pz(n),-1)}))},hinge:function(t,e){return vD((()=>{const n=IF(0,fF(1,WL(t,e)));return oV(n,-1)}))},categoricalHinge:function(t,e){return vD((()=>{const n=wB(WL(t,e),-1),i=bB(WL(fF(1,t),e),-1);return IF(0,YL(1,fF(i,n)))}))},logcosh:function(t,e){return vD((()=>{const n=Math.log(2),i=fF(e,t),s=fF(YL(i,XB(WL(-2,i))),n);return oV(s,-1)}))},categoricalCrossentropy:Rj,sparseCategoricalCrossentropy:Aj,binaryCrossentropy:Oj,kullbackLeiblerDivergence:Mj,poisson:function(t,e){return vD((()=>{const n=WB(YL(Sz(),e));return oV(fF(e,WL(t,n)),-1)}))},cosineProximity:Cj};function kj(t){if("string"==typeof t){if(t in Nj)return Nj[t];let e=`Unknown loss ${t}`;throw t.toLowerCase().includes("softmaxcrossentropy")&&(e=`Unknown loss ${t}. Use "categoricalCrossentropy" as the string name for tf.losses.softmaxCrossEntropy`),new CW(e)}return t} /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ function Dj(t,e){return vD((()=>{const n=WL(.5,TV(e)),i=xz(LB(e,n),t.dtype);return oV(aB(t,i),-1)}))}function Lj(t,e){return vD((()=>xz(aB(ZP(t,-1),ZP(e,-1)),"float32")))}function Fj(t,e){return vD((()=>BL(wB(QB(aB(t,1),aB(e,1))),"float32")))}function Pj(t,e){return vD((()=>{const n=Fj(t,e),i=function(t,e){return vD((()=>BL(wB(QB(aB(t,0),aB(e,1))),"float32")))}(t,e),s=YL(n,i);return BL(oB(LB(s,0),HL(n,s),0),"float32")}))}function $j(t,e){return vD((()=>{const n=Fj(t,e),i=function(t,e){return vD((()=>BL(wB(QB(aB(t,1),aB(e,0))),"float32")))}(t,e),s=YL(n,i);return BL(oB(LB(s,0),HL(n,s),0),"float32")}))}function Bj(t,e){return Oj(t,e)}function Vj(t,e){return t.rank===e.rank&&(t=gU(t,[t.rank-1])),(e=ZP(e,-1)).dtype!==t.dtype&&(e=BL(e,t.dtype)),BL(aB(t,e),"float32")}const Uj=Rj,Yj=Aj,Gj={binaryAccuracy:Dj,categoricalAccuracy:Lj,precision:Pj,categoricalCrossentropy:Uj,sparseCategoricalCrossentropy:Yj,mse:vj,MSE:vj,mae:wj,MAE:wj,mape:Sj,MAPE:Sj,cosine:Cj};function Hj(t){if("string"==typeof t&&t in Gj)return Gj[t];if("string"!=typeof t&&null!=t)return t;throw new CW(`Unknown metric ${t}`)}function Wj(t){if(FW(null!==t,`Unknown LossOrMetricFn ${t}`),"string"==typeof t)return t;{let e;for(const n of Object.keys(Nj))if(Nj[n]===t){e=n;break}if(void 0!==e)return e;for(const n of Object.keys(Gj))if(Gj[n]===t){e=n;break}return void 0!==e?e:t.name}} /** * @license * Copyright 2019 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ const zj=1048576;function Xj(t,e,n=!1){if(null==t||"object"!=typeof t||Object.getPrototypeOf(t)!==Object.prototype||!jj(t))throw new Error("User-defined metadata is expected to be a JSON object, but is not.");if(n){const n=JSON.stringify(t);n.length>zj&&console.warn(`User-defined metadata of model "${e}" 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 jj(t){if(null===t)return!0;if("object"==typeof t){if(Object.getPrototypeOf(t)===Object.prototype){const e=Object.keys(t);for(const n of e){if("string"!=typeof n)return!1;if(!jj(t[n]))return!1}return!0}if(Array.isArray(t)){for(const e of t)if(!jj(e))return!1;return!0}return!1}{const e=typeof t;return"string"===e||"number"===e||"boolean"===e}} /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ function qj(t,e,n,i=console.log){const s=function(t){let e=!0;const n=[],i=[];for(const e in t.nodesByDepth)n.push(t.nodesByDepth[e]);for(const t of n){if(t.length>1||1===t.length&&t[0].inboundLayers.length>1){e=!1;break}i.push(...t)}if(e)for(const n of t.layers){let t=!1;for(const s of n.inboundNodes)if(-1!==i.indexOf(s)){if(t){e=!1;break}t=!0}if(!e)break}return e}(t),r=["Layer (type)","Input Shape","Output shape","Param #"];let a;if(s?(e=e||90,n=n||[.32,.61,.89,1]):(e=e||115,n=n||[.24,.48,.7,.8,1]),n[n.length-1]<=1&&(n=n.map((t=>Math.floor(e*t)))),!s){r.push("Receives inputs"),a=[];for(const e in t.nodesByDepth)a.push(...t.nodesByDepth[e])}i("_".repeat(e)),Kj(r,n,i),i("=".repeat(e));const o=t.layers;for(let t=0;t0&&(i=i.slice(0,i.length-1)+" "),i+=t[n],i=i.slice(0,e[n]),i+=" ".repeat(e[n]-i.length);n(i)}function Qj(t,e,n){let i,s;try{s=t.inboundNodes.map((t=>JSON.stringify(t.inputShapes))).join(",")}catch(t){s="multiple"}try{i=JSON.stringify(t.outputShape)}catch(t){i="multiple"}Kj([`${t.name} (${t.getClassName()})`,s,i,t.countParams().toString()],e,n)}function Jj(t,e,n,i){let s,r;try{r=t.inboundNodes.map((t=>JSON.stringify(t.inputShapes))).join(",")}catch(t){r="multiple"}try{s=JSON.stringify(t.outputShape)}catch(t){s="multiple"}const a=[];for(const e of t.inboundNodes)if(!(null!=n&&n.length>0&&-1===n.indexOf(e)))for(let t=0;tt.name))}`);XW(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((t=>t.name))}`),this.inputLayers=[],this.inputLayersNodeIndices=[],this.inputLayersTensorIndices=[],this.outputLayers=[],this.outputLayersNodeIndices=[],this.outputLayersTensorIndices=[],this.layers=[],this.internalContainerRefs=[];for(const t of this.outputs){const e=t.sourceLayer,n=t.nodeIndex,i=t.tensorIndex;this.outputLayers.push(e),this.outputLayersNodeIndices.push(n),this.outputLayersTensorIndices.push(i)}for(const t of this.inputs){const e=t.sourceLayer,n=t.nodeIndex,i=t.tensorIndex;FW(0===n,"input layer has >1 nodes"),FW(0===i,"input layer has >1 tensors"),this.inputLayers.push(e),this.inputLayersNodeIndices.push(n),this.inputLayersTensorIndices.push(i)}this.inputNames=[],this.outputNames=[],this.feedInputShapes=[],this.feedInputNames=[],this.feedOutputNames=[];for(let e=0;et.shape)),this.internalOutputShapes=this.outputs.map((t=>t.shape));const e={},n={},i={},s={},r={},a=[],o=(t,e,n,i,s,l)=>{null!=i&&null!=s&&null!=l||(i=t.sourceLayer,s=t.nodeIndex,l=t.tensorIndex);const u=i.inboundNodes[s];if(-1!==n.indexOf(u))throw new MW(`The tensor ${t.name} at layer "${i.name}" is part of a cycle.`);if(-1!==e.indexOf(u))return;this.containerNodes.add(iq.nodeKey(i,s)),i.id in r||(r[i.id]=Object.keys(r).length),-1===n.indexOf(u)&&n.push(u);const h=u.inboundLayers.length;for(let t=0;t=0;)n.splice(n.indexOf(u),1);a.push(u)},l=[],u=[];for(const t of this.outputs)o(t,l,u);const h=a.slice().reverse();for(const t of h){n[t.id]=t,t.id in e||(e[t.id]=0);let r=e[t.id];const a=null==i[t.outboundLayer.id]?0:i[t.outboundLayer.id];r=Math.max(r,a),i[t.outboundLayer.id]=r,s[t.outboundLayer.id]=t.outboundLayer,e[t.id]=r;for(let i=0;iparseInt(t,10))).sort(zW);this.layers=[];for(const t of d){const e=c[t];e.sort(((t,e)=>{const n=r[t.id],i=r[e.id];return ni?1:0}));for(const t of e)t instanceof iq&&this.internalContainerRefs.push(t),this.layers.push(t)}this.layersByDepth=c,d=Object.keys(p).map((t=>parseInt(t,10))).sort(zW);const f=this.inputs.slice(),m=[];for(const t of d)for(const e of p[t]){const t=e.outboundLayer;if(null!=t){for(const n of e.inputTensors)if(-1===f.indexOf(n))throw new MW(`Graph disconnected: cannot obtain value for tensor ${n} at layer "${t.name}". The following previous layers were accessed without issue: ${m}`);for(const t of e.outputTensors)f.push(t);m.push(t.name)}}this.nodesByDepth=p;const g=this.layers.map((t=>t.name));for(const t of g){const e=g.filter((e=>e===t)).length;if(1!==e)throw new MW(`The name "${t}" is used ${e} times in the model. All layer names should be unique. Layer names: `+JSON.stringify(g))}this.outboundNodes=[],this.inboundNodes=[],new bX({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:this.inputs.map((t=>null)),outputMasks:this.outputs.map((t=>null)),inputShapes:this.inputs.map((t=>t.shape)),outputShapes:this.outputs.map((t=>t.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 t={refCountAfterDispose:null,numDisposedVariables:0};if(0==--this._refCount){for(const e of this.layers)t.numDisposedVariables+=e.dispose().numDisposedVariables;for(const e of this.internalContainerRefs)t.numDisposedVariables+=e.dispose().numDisposedVariables}return t.refCountAfterDispose=this._refCount,t}get trainable(){return this.trainable_}set trainable(t){this.layers.forEach((e=>{e._trainableWeights.forEach((e=>e.trainable=t))})),this.trainable_=t}get trainableWeights(){if(this._trainableWeights.length>0)throw new CW("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 t=[];for(const e of this.layers)t=t.concat(e.trainableWeights);return t}get nonTrainableWeights(){const t=[];for(const e of this.layers)t.push(...e.nonTrainableWeights);if(!this.trainable){const e=[];for(const t of this.layers)e.push(...t.trainableWeights);return e.concat(t)}return t}get weights(){return this.trainableWeights.concat(this.nonTrainableWeights)}loadWeights(t,e=!0){const n={};let i=0;const s=(t=>{const e=Object.keys(t);if(0===e.length)return!1;const n=e[0].split("/");return!isNaN(parseInt(n[n.length-1],10))})(t);s&&this.parseWeights(t);for(const t of this.layers)for(const[e,r]of t.weights.entries()){const t=s?`${r.name.split("/").slice(0,-1).join("/")+"/"}${e}`:r.originalName;if(null!=n[t])throw new CW(`Duplicate weight name: ${t}`);n[t]=r,i++}const r=[];for(const i in t){let s=i;if(null==n[i]){const t=i.split("/");s=t.slice(0,-2).concat([t[t.length-1]]).join("/")}if(null!=n[s])r.push([n[s],t[i]]);else if(e)throw new CW(`Provided weight data has no target variable: ${i}`);delete n[s]}if(e){const t=[];for(const e in n)t.push(e);if(t.length>0)throw new CW(`${t.length} of ${i} weights are not set: ${t}`)}TX(r)}parseWeights(t){for(const e in Object.keys(t)){const n=e.split("/"),i=["vars","layer_checkpoint_dependencies"],s=n.map((t=>t.startsWith("_")?t.slice(1):t)).filter((t=>!i.includes(t))).join("/");s!==e&&(t[s]=t[e],delete t[e])}}updatedConfig(){const t=this.getConfig(),e={};return e.className=this.getClassName(),e.config=t,e.kerasVersion=`tfjs-layers ${nq}`,e.backend="TensorFlow.js",e}toJSON(t,e=!0){const n=eq(this.updatedConfig());return e?JSON.stringify(n):n}call(t,e){return vD((()=>{t=BW(t);const n=new AX;for(let e=0;e{let n;return t=BW(t),n=null==e?LW(null,t.length):BW(e),this.runInternalGraph(t,n)[1]}))}computeOutputShape(t){const e=pX(t);if(e.length!==this.inputLayers.length)throw new CW(`Invalid inputShape argument ${t}: model has ${this.inputLayers.length} tensor inputs.`);const n={};for(let t=0;tparseInt(t,10))).sort(zW);if(i.length>1)for(const t of i){const e=this.nodesByDepth[t];for(const t of e){const e=t.outboundLayer;if(-1!==this.inputLayers.map((t=>t.id)).indexOf(e.id))continue;const i=[];for(let e=0;eparseInt(t,10))).sort(zW);for(const t of i){const e=this.nodesByDepth[t];for(const t of e){const e=t.outboundLayer,i=t.inputTensors,s=t.outputTensors,r=new Array;for(const t of i)t.id in n&&r.push(n[t.id]);if(r.length===i.length){let i,a,o,l,u={};if(null!=t.callArgs&&(u=t.callArgs),1===r.length){const[t,n]=r[0];null==u.mask&&(u.mask=n),o=BW(e.call(t,u)),l=BW(e.computeMask(t,n)),i=[t],a=[n]}else i=r.map((t=>t[0])),a=r.map((t=>t[1])),null==u.mask&&(u.mask=a),o=BW(e.call(i,u)),l=BW(e.computeMask(i,a));if(e.activityRegularizer)throw new NW("LayersModel invocation with concrete Tensor value(s) in the presence of activity regularizer(s) is not supported yet.");for(let t=0;t{const t=[];for(const e of this.layers)for(let n=0;n0){const t=[];for(let n=0;n0&&t.apply($W(n),i)}function l(t){const n=t.name,r=Ej(t,null!=e.customObjects?e.customObjects:{});r.setFastWeightInitDuringBuild(i),s[n]=r;t.inboundNodes.forEach((t=>{if(!(t instanceof Array))throw new CW(`Corrupted configuration, expected array for nodeData: ${t}`);a(r,t)}))}const u=e.name,h=e.layers;for(const t of h)l(t);for(;!jW(r);)for(const t of h){const e=s[t.name];if(e.name in r){const t=r[e.name];delete r[e.name];for(const n of t)o(e,n)}}const p=[],c=[],d=e.inputLayers;for(const t of d){const e=t[0],n=t[1],i=t[2];FW(e in s);const r=s[e].inboundNodes[n].outputTensors;p.push(r[i])}const f=e.outputLayers;for(const t of f){const e=t[0],n=t[1],i=t[2];FW(e in s);const r=s[e].inboundNodes[n].outputTensors;c.push(r[i])}return new t({inputs:p,outputs:c,name:u})}get stateful(){if(this._stateful)throw new CW("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 t of this.layers)if(t.stateful)return!0;return!1}resetStates(){vD((()=>{this.layers.forEach((t=>{t.stateful&&t.resetStates()}))}))}} /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ function sq(t,e,n){const i=e.length;if(null==t||Array.isArray(t)&&0===t.length)return e.map((t=>null));if(1===i)return Array.isArray(t)&&1===t.length?t:"object"==typeof t&&e[0]in t?[t[e[0]]]:[t];if(Array.isArray(t)){if(t.length!==i)throw new Error(`Provided ${n} is an array of ${t.length} element(s), but the model has ${i} outputs. Make sure a set of weights is provided for each model output.`);return t}if("object"==typeof t&&Object.keys(t).length>0&&"object"==typeof t[Object.keys(t)[0]]){const n=[];return e.forEach((e=>{e in t?n.push(t[e]):n.push(null)})),n}throw new Error(`The model has multiple (${i}) outputs, so ${n} must be either an array with ${i} elements or an object with ${e} keys. Provided ${n} not understood: ${JSON.stringify(t)}`)}function rq(t,e){return sq(t,e,"classWeight")}async function aq(t,e,n,i){if(null!=e||null!=i)throw new Error("Support sampleWeight is not implemented yet");if(null!=n){const e=vD((()=>{if(1===t.shape.length)return VL(t);if(2===t.shape.length){if(t.shape[1]>1){return ZP(t,1)}if(1===t.shape[1])return E$(t,[t.shape[0]]);throw new Error(`Encountered unexpected last-dimension size (${t.shape[1]}) during handling of class weights. The size is expected to be >= 1.`)}throw new Error(`Unexpected rank of target (y) tensor (${t.rank}) during handling of class weights. The rank is expected to be 1 or 2.`)})),i=Array.from(await e.data());wD(e);const s=[];return i.forEach((t=>{if(null==n[t])throw new Error(`classWeight must contain all classes in the training data. The class ${t} exists in the data but not in classWeight`);s.push(n[t])})),EU(s,"float32")}return null}function oq(t,e){return WL(t,e)}function lq(t,e){let n,i;const s=e;n=s.xs,i=s.ys,yA(null!=n&&null!=i,(()=>`A Dataset iterator for fitDataset() is expected to generate objects of the form \`{xs: xVal, ys: yVal}\`, where the two values may be \`tf.Tensor\`, an array of Tensors, or a map of string to Tensor. The provided Dataset instead generates ${e}`));const r=uq("input",t.inputNames,n),a=uq("output",t.outputNames,i),o=r[0].shape[0];yA(r.length===t.inputs.length,(()=>`LayersModel has ${t.inputs.length} inputs, but the dataset provides ${r.length} inputs. (Expected input keys: ${JSON.stringify(t.inputNames)})`)),yA(a.length===t.outputs.length,(()=>`LayersModel has ${t.outputs.length} outputs, but the dataset provides ${a.length} outputs. (Expected output keys: ${JSON.stringify(t.outputNames)})`));for(let e=0;e`Batch size mismatch: input ${t.inputNames[e]} has ${r[e].shape[0]}; expected ${o} based on input ${t.inputNames[0]}.`));for(let e=0;e`Batch size mismatch: output ${t.outputNames[e]} has ${a[e].shape[0]}; expected ${o} based on input ${t.inputNames[0]}.`));return{xs:r,ys:a}}function uq(t,e,n){if(n instanceof Ak)return[n];if(Array.isArray(n))return yA(n.length===e.length,(()=>`Received an array of ${n.length} Tensors, but expected ${e.length} to match the ${t} keys ${e}.`)),n;{const i=[];for(const s of e){if(null==n[s])throw new CW(`The feature data generated by the dataset lacks the required ${t} key '${s}'.`);i.push(n[s])}return i}}async function hq(t,e,n){const i=null!=n.batchesPerEpoch;if(yA(null!=t.optimizer,(()=>"You must compile a model before training/testing. Use LayersModel.compile(modelCompileConfig).")),yA(null!=n,(()=>"For fitDataset(), the 2nd argument (config) is required, but it is not provided in this call.")),yA(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}`)),yA(!i||n.batchesPerEpoch>0&&Number.isInteger(n.batchesPerEpoch),(()=>`For fitDataset(), config.batchesPerEpoch is expected to be a positive integer if specified, but got ${n.batchesPerEpoch}`)),yA(null==n.validationSplit,(()=>"`validationSplit` is not supported by `fitDataset()`. Use validationData instead.")),t.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");t.isTraining=!0;try{const s=null!=n.validationData;let r,a;if(s)if(pq(n.validationData))yA(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 t=function(t){if(3===t.length)throw new NW("Validation with sample weights is not implemented yet.");return{xs:t[0],ys:t[1]}}(n.validationData);r=t.xs,a=t.ys}const o=t.makeTrainFunction(),l=t.getDedupedMetricsNames();let u;u=s?l.slice().concat(l.map((t=>"val_"+t))):l.slice();const h=Tj(n.callbacks,n.yieldEvery),p=null==n.verbose?1:n.verbose,{callbackList:c,history:d}=Ij(h,p,n.epochs,null,null,function(t,e){let n=null;null!=e.batchesPerEpoch?n=e.batchesPerEpoch:Number.isFinite(t.size)&&(n=t.size);return n}(e,n),null,s,u);c.setModel(t),t.history=d,await c.onTrainBegin(),t.stopTraining_=!1;let f=null==n.initialEpoch?0:n.initialEpoch,m=await e.iterator();for(;f=n.batchesPerEpoch:e.done){if(s){let e;e=pq(n.validationData)?BW(await t.evaluateDataset(n.validationData,{batches:n.validationBatches})):BW(t.evaluate(r,a,{batchSize:null==n.validationBatchSize?32:n.validationBatchSize,verbose:0}));for(let n=0;n0&&Number.isInteger(t),(()=>`batchSize is required to be a positive integer, but got ${t}`))}function dq(t,e,n){return null==t?[null]:Array.isArray(t)?t.map((t=>Az(t,e,n-e))):Az(t,e,n-e)}function fq(t,e){return vD((()=>null==t?null:Array.isArray(t)?t.map((t=>fq(t,e))):Fz(t,"int32"===e.dtype?e:BL(e,"int32"))))}function mq(t,e){const n=[];let i=0,s=null;for(;i=t&&(s=t),n.push([i,s]),i=s;return n}function gq(t){const e=[];t instanceof Ak&&(t=[t]);for(let n=0;nn.push(t.id)));else if(null!=e)for(const t in e){const i=e[t];n.push(i.id)}const i=[];if(t instanceof Ak)-1===n.indexOf(t.id)&&i.push(t);else if(Array.isArray(t))t.forEach((t=>{-1===n.indexOf(t.id)&&i.push(t)}));else if(null!=t)for(const e in t){const s=t[e];-1===n.indexOf(s.id)&&i.push(s)}i.forEach((t=>{t.isDisposed||t.dispose()}))}function Tq(t){return Array.isArray(t)}function yq(t){return! /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ function(t){return t instanceof Ak}(t)&&!Tq(t)}function Iq(t,e,n,i=!0,s=""){if(null==e||0===e.length){if(null!=t){let e=!1;if(Tq(t)&&t.length>0)e=!0;else if(yq(t)){for(const n in t)if(t.hasOwnProperty(n)){e=!0;break}}else e=!0;if(e)throw new CW(`Error when checking model ${s} expected no data, but got ${t}`)}return[]}if(null==t)return e.map((t=>null));let r;if(yq(t)){r=[];for(const n of e){if(null==t[n])throw new CW(`No data provided for "${n}". Need data for each key in: ${e}`);r.push(t[n])}}else if(Tq(t)){if(t.length!==e.length)throw new CW(`Error when checking model ${s}: the Array of Tensors that you are passing to your model is not the size the model expected. Expected to see ${e.length} Tensor(s), but instead got the following list of Tensor(s): ${t}`);r=t}else{if(e.length>1)throw new CW(`The model ${s} expects ${e.length} Tensor(s), but only received one Tensor. Found: Tensor with shape ${t.shape}`);r=[t]}if(r=gq(r),null!=n)for(let t=0;t=0&&r!==o)throw new CW(`${s} expected a batch of elements where each example has shape [${n[t].slice(1,n[t].length)}] (i.e.,tensor shape [*,${n[t].slice(1,n[t].length)}]) but the ${s} received an input with ${a.shape[0]} examples, each with shape [${a.shape.slice(1,a.shape.length)}] (tensor shape [${a.shape}])`)}}return r}function Eq(t,e,n,i=!0,s=""){let r;if(Array.isArray(t)){if(t.length!==e.length)throw new CW(`Error when checking model ${s}: the Array of Tensors that you are passing to your model is not the size the the model expected. Expected to see ${e.length} Tensor(s), but instead got ${t.length} Tensors(s).`);r=t}else{if(e.length>1)throw new CW(`The model expects ${e.length} ${s} Tensors, but only received one Tensor. Found: array with shape ${JSON.stringify(t.shape)}.`);r=[t]}if(null!=n)for(let t=0;trG.adagrad(.01),Adadelta:()=>rG.adadelta(1,.95,Sz()),Adam:()=>rG.adam(.001,.9,.999,Sz()),Adamax:()=>rG.adamax(.002,.9,.999,Sz(),0),RMSProp:()=>rG.rmsprop(.001,.9,0,Sz()),SGD:()=>rG.sgd(.01)};if(e.adagrad=e.Adagrad,e.adadelta=e.Adadelta,e.adam=e.Adam,e.adamax=e.Adamax,e.rmsprop=e.RMSProp,e.sgd=e.SGD,t in e)return e[t]();throw new CW(`Unknown Optimizer ${t}`)}(t.optimizer),this.isOptimizerOwned=!0;else{if(!(t.optimizer instanceof uF))throw new CW("User-defined optimizer must be an instance of tf.Optimizer.");this.optimizer_=t.optimizer,this.isOptimizerOwned=!1}let e=[];if(Array.isArray(t.loss)||"string"==typeof t.loss||"function"==typeof t.loss)if(Array.isArray(t.loss)){if(t.loss.length!==this.outputs.length)throw new CW(`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=${t.loss}.`);const n=t.loss;e=n.map((t=>kj(t)))}else{const n=kj(t.loss);this.outputs.forEach((t=>{e.push(n)}))}else{t.loss=t.loss;for(const e in t.loss)if(-1===this.outputNames.indexOf(e))throw new CW(`Unknown entry in loss dictionary: "${e}". Only expected the following keys: ${this.outputNames}`);for(const n of this.outputNames)null==t.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`),e.push(kj(t.loss[n]))}this.lossFunctions=e,this.feedOutputNames=[],this.feedOutputShapes=[],this.feedLossFns=[];for(let t=0;t{for(let t=0;t1&&(this.metricsTensors.push([e,t]),this.metricsNames.push(this.outputNames[t]+"_loss"))}}));const i=function(t,e){if(null==t||Array.isArray(t)&&0===t.length)return e.map((t=>[]));let n;if("string"==typeof t||"function"==typeof t)n=[t];else{if(!Array.isArray(t)&&"object"!=typeof t)throw new TypeError(`Type of metrics argument not understood. Expected an string,function, Array, or Object, found: ${t}`);n=t}if(Array.isArray(n))return e.map((t=>n));{const t=[];for(const i of e){let e=n.hasOwnProperty(i)?n[i]:[];Array.isArray(e)||(e=[e]),t.push(e)}return t}}(t.metrics,this.outputNames),s=(t,e,n)=>{this.outputNames.length>1&&(e=this.outputNames[t]+"_"+e),this.metricsNames.push(e),this.metricsTensors.push([n,t])};mz("metric",(()=>{for(let t=0;t{let n,i,r;for(const a of e){if("string"==typeof a&&-1!==["accuracy","acc","crossentropy","ce"].indexOf(a)){const e=this.internalOutputShapes[t];let s;1===e[e.length-1]||this.lossFunctions[t]===Oj?-1!==["accuracy","acc"].indexOf(a)?i=Dj:-1!==["crossentropy","ce"].indexOf(a)&&(i=Bj):this.lossFunctions[t]===Aj?-1!==["accuracy","acc"].indexOf(a)?i=Vj:-1!==["crossentropy","ce"].indexOf(a)&&(i=Yj):-1!==["accuracy","acc"].indexOf(a)?i=Lj:-1!==["crossentropy","ce"].indexOf(a)&&(i=Uj),-1!==["accuracy","acc"].indexOf(a)?s="acc":-1!==["crossentropy","ce"].indexOf(a)&&(s="ce"),r=i,n=""+s}else{const t=Hj(a);r=t,n=""+Wj(a)}let e;mz(n,(()=>{e=r})),s(t,n,e)}})(i[t])}})),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(t,e,n={}){const i=null==n.batchSize?32:n.batchSize;cq(i);const s=this.standardizeUserDataXY(t,e,!0,i);try{const t=s[0].concat(s[1]);this.makeTestFunction();const e=this.testFunction;return $W(this.testLoop(e,t,i,n.verbose,n.steps))}finally{_q(s[0],t),_q(s[1],e)}}async evaluateDataset(t,e){return this.makeTestFunction(),async function(t,e,n){const i=null!=(n=n||{}).batches,s=t.testFunction;let r=[];if(n.verbose>0)throw new NW("Verbose mode is not implemented yet.");yA(!i||n.batches>0&&Number.isInteger(n.batches),(()=>`Test loop expects \`batches\` to be a positive integer, but received ${JSON.stringify(n.batches)}`));const a="function"==typeof e.next?e:await e.iterator();let o=0,l=0;for(;!i||l{if(e.value){const{xs:n,ys:i}=lq(t,e.value),a=n.concat(i),u=vD((()=>s(a)));if(wD(a),0===l)for(let t=0;tYL(r[t],WL(h,e)))),l>0&&wD(n)}wD(u),o+=h,++l}return r})),e.done){i&&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 t=0;tt.name));for(let i=0;i0){const n=[];throw e.forEach(((e,i)=>{null==e&&n.push(t[i])})),new CW(`Cannot find SymbolicTensors for output name(s): ${JSON.stringify(n)}`)}return e}predictLoop(t,e=32,n=!1){return vD((()=>{const i=this.checkNumSamples(t);if(n)throw new NW("Verbose predictLoop() is not implemented yet.");const s=mq(i,e),r=this.outputs.map((t=>[]));for(let e=0;e{const n=s[e][0],i=s[e][1],r=dq(t,n,i),a=[];if(Array.isArray(r))for(let t=0;tr[e].push(t)))}return $W(r.map((t=>w$(t,0))))}))}predict(t,e={}){const n=gq(t);Eq(n,this.inputNames,this.feedInputShapes,!1);try{const t=null==e.batchSize?32:e.batchSize;return cq(t),this.predictLoop(n,t)}finally{_q(n,t)}}predictOnBatch(t){Eq(t,this.inputNames,this.feedInputShapes,!0);const e=(Array.isArray(t)?t[0]:t).shape[0];return this.predictLoop(t,e)}standardizeUserDataXY(t,e,n=!0,i){if(null==this.optimizer_)throw new MW("You must compile a model before training/testing. Use LayersModel.compile(modelCompileArgs).");const s=[];for(let t=0;tt.shape[0])));n.sort();const i=XW(e.map((t=>t.shape[0])));if(i.sort(),n.length>1)throw new CW(`All input Tensors (x) should have the same number of samples. Got array shapes: ${JSON.stringify(t.map((t=>t.shape)))}`);if(i.length>1)throw new CW(`All target Tensors (y) should have the same number of samples. Got array shapes: ${JSON.stringify(e.map((t=>t.shape)))}`);if(n.length>0&&i.length>0&&!SA(n,i))throw new CW(`Input Tensors should have the same number of samples as target Tensors. Found ${n[0]} input sample(s) and ${i[0]} target sample(s).`)}(t=Iq(t,this.feedInputNames,this.feedInputShapes,!1,"input"),e=Iq(e,this.feedOutputNames,s,!1,"target")),function(t,e,n){const i=[vj,Oj,Rj];for(let s=0;s0&&t[0].shape[0]%i!=0)throw new CW(`In a stateful network, you should only pass inputs with a number of samples that is divisible by the batch size ${i}. Found: ${t[0].shape[0]} sample(s).`);return[t,e]}async standardizeUserData(t,e,n,i,s=!0,r){const[a,o]=this.standardizeUserDataXY(t,e,s,r);if(null!=n)throw new Error("sample weight is not supported yet.");let l=null;if(null!=i){const t=rq(i,this.outputNames);l=[];for(let e=0;e{const r=this.checkNumSamples(e,n,s,"steps"),a=[];if(i>0)throw new NW("Verbose mode is not implemented yet.");if(null!=s)throw new NW("steps mode in testLoop() is not implemented yet");{const i=mq(r,n),s=EU(vz(0,r));for(let n=0;n1){s+=`_${PW(t.slice(0,n),i)}`}e.push(s)}return e}makeTrainFunction(){return t=>{const e=[],n=t.slice(0,this.inputs.length),i=t.slice(this.inputs.length,this.inputs.length+this.outputs.length),s=t.slice(this.inputs.length+this.outputs.length,this.inputs.length+2*this.outputs.length),r=[],a=this.collectedTrainableWeights.map((t=>t.read()));return[this.optimizer_.minimize((()=>{const t=[];for(let e=0;e1&&t{l=YL(l,t)})),l}),!0,a)].concat(r)}}makeTestFunction(){this.testFunction=t=>vD((()=>{const e=[];let n;const i=t.slice(0,this.inputs.length),s=t.slice(this.inputs.length,this.inputs.length+this.outputs.length),r=[];for(let t=0;t0){if(g=!0,2!==n.validationData.length)throw 3===n.validationData.length?new NW("validationData including sample weights is not supported yet."):new CW(`When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; ${n.validationData} is invalid.`);o=n.validationData[0],l=n.validationData[1];const t=!0,e=await this.standardizeUserData(o,l,null,null,t,c);u=e[0],h=e[1],m=u.concat(h)}else if(null!=n.validationSplit&&n.validationSplit>0&&n.validationSplit<1){g=!0;const t=Math.floor(i[0].shape[0]*(1-n.validationSplit)),e=i[0].shape[0];u=dq(i,t,e),r=i,i=dq(i,0,t),h=dq(s,t,e),a=s,s=dq(s,0,t),m=u.concat(h)}else null!=n.validationSteps&&(g=!0);const _=i.concat(s).concat(p);this.checkTrainableWeightsConsistency();const T=this.makeTrainFunction(),y=this.getDedupedMetricsNames();let I,E;g?(this.makeTestFunction(),I=this.testFunction,E=y.slice().concat(y.map((t=>"val_"+t)))):(I=null,m=[],E=y.slice());const b=Tj(n.callbacks,n.yieldEvery);return await this.fitLoop(T,_,y,c,n.epochs,n.verbose,b,I,m,n.shuffle,E,n.initialEpoch,null,null)}finally{this.isTraining=!1,_q(i,t),_q(s,e),_q(r,t),_q(a,e),_q(u,o),_q(h,l),null!=p&&wD(p)}}async fitLoop(t,e,n,i,s,r,a,o,l,u,h,p,c,d){null==i&&(i=32),null==s&&(s=1),null==u&&(u=!0),null==p&&(p=0);let f=!1;if(null!=o&&null!=l&&(f=!0),null!=d&&(f=!0,null==c))throw new CW("Can only use `validationSteps` when doing step-wise training, i.e., `stepsPerEpoch` must be set.");const m=this.checkNumSamples(e,i,c,"steps_per_epoch");let g;null!=m&&(g=vz(0,m)),null==r&&(r=1);const{callbackList:_,history:T}=Ij(a,r,s,p,m,c,i,f,h);_.setModel(this),this.history=T,await _.onTrainBegin(),this.stopTraining_=!1;for(let r=p;r{const p=a[u][0],c=a[u][1],d=Az(r,p,c-p);h.batch=u,h.size=c-p;const m=fq(e,d),g=t(m);for(let t=0;tVW(t)))}else{const e=Object.keys(this.loss);t={};const n=this.loss;for(const i of e){if("string"!=typeof n[i])throw new Error("Serialization of non-string loss is not supported.");t[i]=VW(n[i])}}return t}getMetricIdentifiers(){if("string"==typeof this.metrics||"function"==typeof this.metrics)return[VW(Wj(this.metrics))];if(Array.isArray(this.metrics))return this.metrics.map((t=>VW(Wj(t))));{const t={};for(const e in this.metrics)t[e]=VW(Wj(this.metrics[e]));return t}}getTrainingConfig(){return{loss:this.getLossIdentifiers(),metrics:this.getMetricIdentifiers(),optimizer_config:{class_name:this.optimizer.getClassName(),config:this.optimizer.getConfig()}}}loadTrainingConfig(t){if(null!=t.weighted_metrics)throw new Error("Loading weight_metrics is not supported yet.");if(null!=t.loss_weights)throw new Error("Loading loss_weights is not supported yet.");if(null!=t.sample_weight_mode)throw new Error("Loading sample_weight_mode is not supported yet.");const e=Ej(tq(t.optimizer_config));let n,i;if("string"==typeof t.loss)n=UW(t.loss);else if(Array.isArray(t.loss))n=t.loss.map((t=>UW(t)));else if(null!=t.loss){n={};for(const e in t.loss)n[e]=UW(t.loss[e])}if(Array.isArray(t.metrics))i=t.metrics.map((t=>UW(t)));else if(null!=t.metrics){i={};for(const e in t.metrics)i[e]=UW(t.metrics[e])}this.compile({loss:n,metrics:i,optimizer:e})}async save(t,e){if("string"==typeof t){const e=iL(t);if(0===e.length)throw new CW(`Cannot find any save handlers for URL '${t}'`);if(e.length>1)throw new CW(`Found more than one (${e.length}) save handlers for URL '${t}'`);t=e[0]}if(null==t.save)throw new CW("LayersModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");const n=await PD(this.getNamedWeights(e)),i={modelTopology:this.toJSON(null,!1),format:"layers-model",generatedBy:`TensorFlow.js tfjs-layers v${nq}`,convertedBy:null};if(null!=e&&e.includeOptimizer&&null!=this.optimizer){i.trainingConfig=this.getTrainingConfig();const t="optimizer",{data:e,specs:s}=await PD(await this.optimizer.getWeights(),t);n.specs.push(...s),n.data=XD([n.data,e])}if(null!=this.userDefinedMetadata){const t=!0;Xj(this.userDefinedMetadata,this.name,t),i.userDefinedMetadata=this.userDefinedMetadata}return i.weightData=n.data,i.weightSpecs=n.specs,t.save(i)}setUserDefinedMetadata(t){Xj(t,this.name),this.userDefinedMetadata=t}getUserDefinedMetadata(){return this.userDefinedMetadata}}bq.className="Model",oF(bq);class vq extends bq{} /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ async function wq(t,e){"modelTopology"in t||(t={modelTopology:t});let n=t.modelTopology;null!=n.model_config&&(n=n.model_config);const i=Ej(tq(n),e);if(null!=t.weightsManifest){const e=await NF(t.weightsManifest,t.pathPrefix,i.weights.map((t=>t.originalName))),n={};for(const t of i.weights)n[t.originalName]=e[t.originalName];i.loadWeights(n),wD(e)}return i}async function Sq(t,e){if(null==e&&(e={}),"string"==typeof t){const n=sL(t,e);if(0===n.length)n.push($F(t,e));else if(n.length>1)throw new CW(`Found more than one (${n.length}) load handlers for URL '${t}'`);t=n[0]}return async function(t,e,n){null==n&&(n={});if(null==t.load)throw new CW("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");const i=await t.load();let s=i.modelTopology;null!=s.model_config&&(s=s.model_config);const r=null==n.strict||n.strict,a=null!=i.weightData&&null!=i.weightSpecs&&r,o=Ej(tq(s),e,a),l=i.trainingConfig;null!=l&&o.loadTrainingConfig(l);null!=i.userDefinedMetadata&&o.setUserDefinedMetadata(i.userDefinedMetadata);if(null!=i.weightData){if(null==i.weightSpecs)throw new CW("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed.");const{modelWeights:t,optimizerWeights:e}=function(t,e){const n=$D(t,e),i={},s=[];return e.forEach((t=>{"optimizer"===t.group?s.push({name:t.name,tensor:n[t.name]}):i[t.name]=n[t.name]})),{modelWeights:i,optimizerWeights:s}}(i.weightData,i.weightSpecs);o.loadWeights(t,r),null!=o.optimizer&&e.length>0&&await o.optimizer.setWeights(e),wD(t),wD(e.map((t=>t.tensor)))}return o}(t,void 0,e)}vq.className="Functional",oF(vq);class xq extends bq{constructor(t){if(super({inputs:[],outputs:[]}),t=t||{},this.trainable=!0,this.built=!1,this.name=null!=t.name?t.name:iz("sequential_"),null!=t.layers)for(const e of t.layers)this.add(e)}checkShape(t){if(t.inboundNodes[0].outputTensors[0].shape.some((t=>t<0)))throw new CW(`Negative dimension size caused by adding layer ${t.name} with input shape [${t.inboundNodes[0].inputTensors[0].shape}]`)}add(t){const e=t instanceof xq||t instanceof bq;let n;if(e){if(n=t,1!==n.outputs.length)throw new CW("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 CW("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===t.inboundNodes.length){if(null==t.batchInputShape)throw new CW("The first layer in a Sequential model must get an `inputShape` or `batchInputShape` argument.");const e=RX({batchShape:t.batchInputShape,dtype:t.dtype,name:t.name+"_input"});t.apply(e)}if(e)this.outputs=n.outputs,this.inputs=n.inputs;else{if(1!==t.inboundNodes.length)throw new CW(`A layer added to a Sequential model must not already be connected somewhere else. LayersModel received layer ${t.name} which has ${t.inboundNodes.length} pre-existing inbound connections.`);if(1!==t.inboundNodes[0].outputTensors.length)throw new CW("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(t),this.outputs=[t.inboundNodes[0].outputTensors[0]],this.inputs=SX(this.outputs[0])}this.inboundNodes=[],new bX({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:LW(null,this.inputs.length),outputMasks:[null],inputShapes:this.inputs.map((t=>t.shape)),outputShapes:this.outputs[0].shape})}else{const e=t.apply(this.outputs[0]);if(Array.isArray(e))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(t),this.outputs=[e],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}this.layers.push(t),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 t=this.layers.length-1;this.layers[t].outboundNodes=[],this.outputs=[this.layers[t].output],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}}call(t,e){return null==this.model&&this.build(),this.model.call(t,e)}build(t){if(dX(t),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 bq({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(t,e,n=console.log){this.built||this.build(),super.summary(t,e,n)}setWeights(t){null==this.model&&this.build(),this.model.setWeights(t)}evaluate(t,e,n={}){if(!this.built)throw new MW("The model needs to be compiled before being used.");return this.model.evaluate(t,e,n)}async evaluateDataset(t,e){if(!this.built)throw new MW("The model needs to be compiled before being used.");return this.model.evaluateDataset(t,e)}predict(t,e={}){return null==this.model&&this.build(),this.model.predict(t,e)}predictOnBatch(t){return null==this.model&&this.build(),this.model.predictOnBatch(t)}compile(t){this.build(),this.model.compile(t),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(t){this.model.optimizer=t}async fit(t,e,n={}){if(!this.built)throw new MW("The model needs to be compiled before being used.");return this.model.fit(t,e,n)}async fitDataset(t,e){if(!this.built)throw new MW("The model needs to be compiled before being used.");return this.model.fitDataset(t,e)}async trainOnBatch(t,e){return this.model.trainOnBatch(t,e)}static fromConfig(t,e,n={},i=!1){let s,r={};if(e instanceof Array){if(null==e[0].className||"Merge"===e[0].className)throw new CW("Legacy serialization format not supported yet.");s=e}else yA(null!=e.layers,(()=>"When the config data for a Sequential model is not an Array, it must be an Object that contains the 'layers' field.")),s=e.layers,delete e.layers,r=e;const a=new t(r);if(!(a instanceof xq))throw new NW(`Sequential.fromConfig called on non-Sequential input: ${a}`);for(const t of s){const e=Ej(t,void 0,i);i&&e.setFastWeightInitDuringBuild(!0),a.add(e)}return a}set stopTraining(t){if(null==this.model)throw new CW("Cannot set the stopTraining property of a sequential model before it is compiled.");this.model.stopTraining=t}get stopTraining(){if(null==this.model)throw new CW("Cannot get the stopTraining property of a sequential model before it is compiled.");return this.model.stopTraining}getConfig(){const t=[];for(const e of this.layers){const n={};n.className=e.getClassName(),n.config=e.getConfig(),t.push(n)}return{name:this.name,layers:t}}} /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ function Rq(t){return new bq(t)}function Aq(t){return new xq(t)}function Oq(t){return RX(t)}function Mq(t,e){yj.registerCallbackConstructor(t,e)}xq.className="Sequential",oF(xq); /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ class Cq extends rF{getConfig(){return{}}}class Nq extends Cq{apply(t,e=1){return function(t,e=1){if(1!==e)throw new NW(`Support for alpha values other than 1 (${e}) is not implemented yet.`);return pB(t)}(t,e)}}Nq.className="elu",oF(Nq);class kq extends Cq{apply(t){return ZV(t)}}kq.className="selu",oF(kq);class Dq extends Cq{apply(t){return HV(t)}}Dq.className="relu",oF(Dq);class Lq extends Cq{apply(t){return vD((()=>pV(6,HV(t))))}}Lq.className="relu6",oF(Lq);class Fq extends Cq{apply(t){return t}}Fq.className="linear",oF(Fq);class Pq extends Cq{apply(t){return S$(t)}}Pq.className="sigmoid",oF(Pq);class $q extends Cq{apply(t){return function(t){return vD((()=>{const e=YL(.5,WL(.2,t));return B$(e,0,1)}))}(t)}}$q.className="hardSigmoid",oF($q);class Bq extends Cq{apply(t){return XB(t)}}Bq.className="softplus",oF(Bq);class Vq extends Cq{apply(t){return function(t){return vD((()=>HL(t,YL(gF(t),1))))}(t)}}Vq.className="softsign",oF(Vq);class Uq extends Cq{apply(t){return R$(t)}}Uq.className="tanh",oF(Uq);class Yq extends Cq{apply(t,e=-1){return uU(t,e)}}Yq.className="softmax",oF(Yq);class Gq extends Cq{apply(t,e=-1){return qB(t,e)}}Gq.className="logSoftmax",oF(Gq);class Hq extends Cq{apply(t){return vD((()=>vD((()=>{const e=Math.sqrt(2),n=WL(.5,YL(1,dB(HL(t,e))));return WL(t,n)}))))}}Hq.className="gelu",oF(Hq);class Wq extends Cq{apply(t){return vD((()=>WL(.5,WL(t,YL(1,R$(WL(zL(HL(2,Math.PI)),YL(t,WL(.044715,dF(t,3))))))))))}}Wq.className="gelu_new",oF(Wq);class zq extends Cq{apply(t){return vD((()=>WL(t,R$(XB(t)))))}}zq.className="mish",oF(zq);class Xq extends Cq{apply(t,e=1){return vD((()=>WL(S$(WL(t,e)),t)))}}function jq(t){return t.getClassName()}function qq(t,e={}){return WW(t,aF.getMap().classNameMap,e,"activation")}function Kq(t){if(null==t){const t={className:"linear",config:{}};return qq(t)}if("string"==typeof t){const e={};return e.className=t,e.config={},qq(e)}return t instanceof Cq?t:qq(t)} /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ function Qq(t){if(null!=t&&"object"!=typeof t)throw new Error(`Argument to L1L2 regularizer's constructor is expected to be an object, but received: ${t}`)}Xq.className="swish",oF(Xq);class Jq extends rF{}class Zq extends Jq{constructor(t){super(),Qq(t),this.l1=null==t||null==t.l1?.01:t.l1,this.l2=null==t||null==t.l2?.01:t.l2,this.hasL1=0!==this.l1,this.hasL2=0!==this.l2}apply(t){return vD((()=>{let e=lV([1]);return this.hasL1&&(e=YL(e,wB(WL(this.l1,gF(t))))),this.hasL2&&(e=YL(e,wB(WL(this.l2,Pz(t))))),E$(e,[])}))}getConfig(){return{l1:this.l1,l2:this.l2}}static fromConfig(t,e){return new t({l1:e.l1,l2:e.l2})}}Zq.className="L1L2",oF(Zq);const tK={l1l2:"L1L2"};function eK(t){return GW(t)}function nK(t,e={}){return WW(t,aF.getMap().classNameMap,e,"regularizer")}function iK(t){if(null==t)return null;if("string"==typeof t){return nK({className:t in tK?tK[t]:t,config:{}})}return t instanceof Jq?t:nK(t)} /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ class sK extends wX{constructor(t){super(null==t?{}:t),this.supportsMasking=!0,null!=t&&(this.maxValue=t.maxValue)}call(t,e){t=cX(t);let n=HV(t);return null!=this.maxValue&&(n=B$(n,0,this.maxValue)),n}computeOutputShape(t){return t}getConfig(){const t={maxValue:this.maxValue},e=super.getConfig();return Object.assign(t,e),t}}sK.className="ReLU",oF(sK);class rK extends wX{constructor(t){super(null==t?{}:t),this.DEFAULT_ALPHA=.3,null==t&&(t={}),this.alpha=null==t.alpha?this.DEFAULT_ALPHA:t.alpha}call(t,e){const n=cX(t);return VB(n,this.alpha)}computeOutputShape(t){return t}getConfig(){const t={alpha:this.alpha},e=super.getConfig();return Object.assign(t,e),t}}rK.className="LeakyReLU",oF(rK);class aK extends wX{constructor(t){if(super(null==t?{}:t),this.DEFAULT_ALPHA_INITIALIZER="zeros",null==t&&(t={}),this.supportsMasking=!0,this.alphaInitializer=uX(t.alphaInitializer||this.DEFAULT_ALPHA_INITIALIZER),this.alphaRegularizer=iK(t.alphaRegularizer),this.alphaConstraint=HX(t.alphaConstraint),null==t.sharedAxes)this.sharedAxes=null;else if(Array.isArray(t.sharedAxes))this.sharedAxes=t.sharedAxes;else{if("number"!=typeof t.sharedAxes)throw new CW(`Expected sharedAxes to be a number or an array of numbers, but got ${t.sharedAxes}`);this.sharedAxes=[t.sharedAxes]}}build(t){const e=(t=dX(t)).slice(1);if(null!=this.sharedAxes)for(const t of this.sharedAxes)e[t-1]=1;this.alpha=this.addWeight("alpha",e,"float32",this.alphaInitializer,this.alphaRegularizer,!0,this.alphaConstraint);const n={};if(null!=this.sharedAxes)for(let e=1;e{let n=cX(t);const i=e.mask;if(null!=i){const t=WL(fF(uV(n.shape),BL(i,n.dtype)),nF(-1e9));n=YL(n,t)}return this.axis instanceof Array?this.axis.length>1?AB(fF(n,KB(n,this.axis,!0))):this.softmax(n,this.axis[0]):this.softmax(n,this.axis)}))}computeOutputShape(t){return t}getConfig(){const t={axis:this.axis},e=super.getConfig();return Object.assign(t,e),t}} /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ function hK(t,e,n){if("number"==typeof t)return LW(t,e);if(t.length!==e)throw new CW(`The ${n} argument must be an integer or tuple of ${e} integers. Received: ${t.length} elements.`);for(let s=0;s(hz(e),"channelsFirst"===e?QF(t,[0,2,3,1]):t)))}function fK(t,e){return vD((()=>(hz(e),"channelsFirst"===e?QF(t,[0,2,3,4,1]):t)))}function mK(t,e,n,i=1,s="valid",r,a=1){return vD((()=>{if(null==r&&(r="channelsLast"),hz(r),3!==t.shape.length)throw new CW(`The input of a conv1dWithBias operation should be 3, but is ${t.shape.length} instead.`);if(3!==e.shape.length)throw new CW(`The kernel for a conv1dWithBias operation should be 3, but is ${e.shape.length} instead`);if(null!=n&&1!==n.shape.length)throw new CW(`The bias for a conv1dWithBias operation should be 1, but is ${n.shape.length} instead`);if("channelsFirst"===r&&(t=QF(t,[0,2,1])),"causal"===s)throw new NW("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");let o=W$(t,e,i,"same"===s?"same":"valid","NWC",a);return null!=n&&(o=Bz(o,n)),o}))}function gK(t,e,n,i=[1,1],s="valid",r,a,o=null){return vD((()=>{if(null==r&&(r="channelsLast"),hz(r),3!==t.rank&&4!==t.rank)throw new CW(`conv2dWithBiasActivation expects input to be of rank 3 or 4, but received ${t.rank}.`);if(3!==e.rank&&4!==e.rank)throw new CW(`conv2dWithBiasActivation expects kernel to be of rank 3 or 4, but received ${t.rank}.`);let l=dK(t,r);if("causal"===s)throw new NW("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");return l=KU({x:l,filter:e,strides:i,pad:"same"===s?"same":"valid",dilations:a,dataFormat:"NHWC",bias:n,activation:o}),"channelsFirst"===r&&(l=QF(l,[0,3,1,2])),l}))}function _K(t,e,n,i=[1,1,1],s="valid",r,a){return vD((()=>{if(null==r&&(r="channelsLast"),hz(r),4!==t.rank&&5!==t.rank)throw new CW(`conv3dWithBias expects input to be of rank 4 or 5, but received ${t.rank}.`);if(4!==e.rank&&5!==e.rank)throw new CW(`conv3dWithBias expects kernel to be of rank 4 or 5, but received ${t.rank}.`);let o=fK(t,r);if("causal"===s)throw new NW("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");return o=j$(o,e,i,"same"===s?"same":"valid","NDHWC",a),null!=n&&(o=Bz(o,n)),"channelsFirst"===r&&(o=QF(o,[0,4,1,2,3])),o}))}uK.className="Softmax",oF(uK);class TK extends wX{constructor(t,e){if(super(e),this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",TK.verifyArgs(e),this.rank=t,QW(this.rank,"rank"),1!==this.rank&&2!==this.rank&&3!==this.rank)throw new NW(`Convolution layer for rank other than 1, 2, or 3 (${this.rank}) is not implemented yet.`);if(this.kernelSize=hK(e.kernelSize,t,"kernelSize"),this.strides=hK(null==e.strides?1:e.strides,t,"strides"),this.padding=null==e.padding?"valid":e.padding,pz(this.padding),this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,hz(this.dataFormat),this.activation=Kq(e.activation),this.useBias=null==e.useBias||e.useBias,this.biasInitializer=uX(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.biasConstraint=HX(e.biasConstraint),this.biasRegularizer=iK(e.biasRegularizer),this.activityRegularizer=iK(e.activityRegularizer),this.dilationRate=hK(null==e.dilationRate?1:e.dilationRate,t,"dilationRate"),1===this.rank&&Array.isArray(this.dilationRate)&&1!==this.dilationRate.length)throw new CW(`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 CW(`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 CW(`dilationRate must be a number or array of three numbers for 3D convolution, but received ${JSON.stringify(this.dilationRate)}`)}static verifyArgs(t){if(FW("kernelSize"in t,"required key 'kernelSize' not in config"),"number"!=typeof t.kernelSize&&!KW(t.kernelSize,"number",1,3))throw new CW(`BaseConv expects config.kernelSize to be number or number[] with length 1, 2, or 3, but received ${JSON.stringify(t.kernelSize)}.`)}getConfig(){const t={kernelSize:this.kernelSize,strides:this.strides,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,activation:jq(this.activation),useBias:this.useBias,biasInitializer:lX(this.biasInitializer),biasRegularizer:eK(this.biasRegularizer),activityRegularizer:eK(this.activityRegularizer),biasConstraint:YX(this.biasConstraint)},e=super.getConfig();return Object.assign(t,e),t}}class yK extends TK{constructor(t,e){super(t,e),this.kernel=null,yK.verifyArgs(e),this.filters=e.filters,QW(this.filters,"filters"),this.kernelInitializer=uX(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.kernelConstraint=HX(e.kernelConstraint),this.kernelRegularizer=iK(e.kernelRegularizer)}build(t){t=dX(t);const e="channelsFirst"===this.dataFormat?1:t.length-1;if(null==t[e])throw new CW(`The channel dimension of the input should be defined. Found ${t[e]}`);const n=t[e],i=this.kernelSize.concat([n,this.filters]);this.kernel=this.addWeight("kernel",i,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:{[e]:n}}],this.built=!0}call(t,e){return vD((()=>{let e;t=cX(t);const n=null==this.bias?null:this.bias.read(),i=ZW(this.activation.getClassName());if(null!=i&&2===this.rank)e=gK(t,this.kernel.read(),n,this.strides,this.padding,this.dataFormat,this.dilationRate,i);else{if(1===this.rank)e=mK(t,this.kernel.read(),n,this.strides[0],this.padding,this.dataFormat,this.dilationRate[0]);else if(2===this.rank)e=gK(t,this.kernel.read(),n,this.strides,this.padding,this.dataFormat,this.dilationRate);else{if(3!==this.rank)throw new NW("convolutions greater than 3D are not implemented yet.");e=_K(t,this.kernel.read(),n,this.strides,this.padding,this.dataFormat,this.dilationRate)}null!=this.activation&&(e=this.activation.apply(e))}return e}))}computeOutputShape(t){t=dX(t);const e=[],n="channelsLast"===this.dataFormat?t.slice(1,t.length-1):t.slice(2);for(let t=0;t 0 but got ${JSON.stringify(t.filters)}`)}}class IK extends yK{constructor(t){super(2,t),IK.verifyArgs(t)}getConfig(){const t=super.getConfig();return delete t.rank,t}static verifyArgs(t){if("number"!=typeof t.kernelSize&&!KW(t.kernelSize,"number",1,2))throw new CW(`Conv2D expects config.kernelSize to be number or number[] with length 1 or 2, but received ${JSON.stringify(t.kernelSize)}.`)}}IK.className="Conv2D",oF(IK);class EK extends yK{constructor(t){super(3,t),EK.verifyArgs(t)}getConfig(){const t=super.getConfig();return delete t.rank,t}static verifyArgs(t){if("number"!=typeof t.kernelSize&&(!Array.isArray(t.kernelSize)||1!==t.kernelSize.length&&3!==t.kernelSize.length))throw new CW(`Conv3D expects config.kernelSize to be number or [number, number, number], but received ${JSON.stringify(t.kernelSize)}.`)}}EK.className="Conv3D",oF(EK);class bK extends IK{constructor(t){if(super(t),this.inputSpec=[new yX({ndim:4})],"same"!==this.padding&&"valid"!==this.padding)throw new CW(`Conv2DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(t){if(4!==(t=dX(t)).length)throw new CW("Input should have rank 4; Received input shape: "+JSON.stringify(t));const e="channelsFirst"===this.dataFormat?1:t.length-1;if(null==t[e])throw new CW("The channel dimension of the inputs should be defined. Found `None`.");const n=t[e],i=this.kernelSize.concat([this.filters,n]);this.kernel=this.addWeight("kernel",i,"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 yX({ndim:4,axes:{[e]:n}})],this.built=!0}call(t,e){return vD((()=>{let e=cX(t);if(4!==e.shape.length)throw new CW(`Conv2DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${e.shape.length}`);const n=e.shape,i=n[0];let s,r;"channelsFirst"===this.dataFormat?(s=2,r=3):(s=1,r=2);const a=n[s],o=n[r],l=this.kernelSize[0],u=this.kernelSize[1],h=this.strides[0],p=this.strides[1],c=[i,cK(a,h,l,this.padding),cK(o,p,u,this.padding),this.filters];"channelsLast"!==this.dataFormat&&(e=QF(e,[0,2,3,1]));let d=X$(e,this.kernel.read(),c,this.strides,this.padding);return"channelsLast"!==this.dataFormat&&(d=QF(d,[0,3,1,2])),null!=this.bias&&(d=Bz(d,this.bias.read(),this.dataFormat)),null!=this.activation&&(d=this.activation.apply(d)),d}))}computeOutputShape(t){const e=(t=dX(t)).slice();let n,i,s;"channelsFirst"===this.dataFormat?(n=1,i=2,s=3):(n=3,i=1,s=2);const r=this.kernelSize[0],a=this.kernelSize[1],o=this.strides[0],l=this.strides[1];return e[n]=this.filters,e[i]=cK(e[i],o,r,this.padding),e[s]=cK(e[s],l,a,this.padding),e}getConfig(){const t=super.getConfig();return delete t.dilationRate,t}}bK.className="Conv2DTranspose",oF(bK);class vK extends EK{constructor(t){if(super(t),this.inputSpec=[new yX({ndim:5})],"same"!==this.padding&&"valid"!==this.padding)throw new CW(`Conv3DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(t){if(5!==(t=dX(t)).length)throw new CW("Input should have rank 5; Received input shape: "+JSON.stringify(t));const e="channelsFirst"===this.dataFormat?1:t.length-1;if(null==t[e])throw new CW("The channel dimension of the inputs should be defined. Found `None`.");const n=t[e],i=this.kernelSize.concat([this.filters,n]);this.kernel=this.addWeight("kernel",i,"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 yX({ndim:5,axes:{[e]:n}})],this.built=!0}call(t,e){return vD((()=>{let e=cX(t);if(5!==e.shape.length)throw new CW(`Conv3DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${e.shape.length}`);const n=e.shape,i=n[0];let s,r,a;"channelsFirst"===this.dataFormat?(a=2,s=3,r=4):(a=1,s=2,r=3);const o=n[a],l=n[s],u=n[r],h=this.kernelSize[0],p=this.kernelSize[1],c=this.kernelSize[2],d=this.strides[0],f=this.strides[1],m=this.strides[2],g=[i,cK(o,d,h,this.padding),cK(l,f,p,this.padding),cK(u,m,c,this.padding),this.filters];"channelsLast"!==this.dataFormat&&(e=QF(e,[0,2,3,4,1]));let _=K$(e,this.kernel.read(),g,this.strides,this.padding);return"channelsLast"!==this.dataFormat&&(_=QF(_,[0,4,1,2,3])),null!==this.bias&&(_=Bz(_,this.bias.read(),this.dataFormat)),null!==this.activation&&(_=this.activation.apply(_)),_}))}computeOutputShape(t){const e=(t=dX(t)).slice();let n,i,s,r;"channelsFirst"===this.dataFormat?(n=1,i=2,s=3,r=4):(n=4,i=1,s=2,r=3);const a=this.kernelSize[0],o=this.kernelSize[1],l=this.kernelSize[2],u=this.strides[0],h=this.strides[1],p=this.strides[2];return e[n]=this.filters,e[i]=cK(e[i],u,a,this.padding),e[s]=cK(e[s],h,o,this.padding),e[r]=cK(e[r],p,l,this.padding),e}getConfig(){const t=super.getConfig();return delete t.dilationRate,t}}vK.className="Conv3DTranspose",oF(vK);class wK extends yK{constructor(t,e){if(super(t,e),this.DEFAULT_DEPTHWISE_INITIALIZER="glorotUniform",this.DEFAULT_POINTWISE_INITIALIZER="glorotUniform",this.depthwiseKernel=null,this.pointwiseKernel=null,null==e.filters)throw new CW("The `filters` configuration field is required by SeparableConv, but is unspecified.");if(null!=e.kernelInitializer||null!=e.kernelRegularizer||null!=e.kernelConstraint)throw new CW("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead.");if(null!=e.padding&&"same"!==e.padding&&"valid"!==e.padding)throw new CW(`SeparableConv${this.rank}D supports only padding modes: 'same' and 'valid', but received ${JSON.stringify(e.padding)}`);this.depthMultiplier=null==e.depthMultiplier?1:e.depthMultiplier,this.depthwiseInitializer=uX(e.depthwiseInitializer||this.DEFAULT_DEPTHWISE_INITIALIZER),this.depthwiseRegularizer=iK(e.depthwiseRegularizer),this.depthwiseConstraint=HX(e.depthwiseConstraint),this.pointwiseInitializer=uX(e.depthwiseInitializer||this.DEFAULT_POINTWISE_INITIALIZER),this.pointwiseRegularizer=iK(e.pointwiseRegularizer),this.pointwiseConstraint=HX(e.pointwiseConstraint)}build(t){if((t=dX(t)).length{let e;if(t=cX(t),1===this.rank)throw new NW("1D separable convolution is not implemented yet.");return 2===this.rank&&("channelsFirst"===this.dataFormat&&(t=QF(t,[0,2,3,1])),e=tU(t,this.depthwiseKernel.read(),this.pointwiseKernel.read(),this.strides,this.padding,this.dilationRate,"NHWC")),this.useBias&&(e=Bz(e,this.bias.read(),this.dataFormat)),null!=this.activation&&(e=this.activation.apply(e)),"channelsFirst"===this.dataFormat&&(e=QF(e,[0,3,1,2])),e}))}getConfig(){const t=super.getConfig();return delete t.rank,delete t.kernelInitializer,delete t.kernelRegularizer,delete t.kernelConstraint,t.depthwiseInitializer=lX(this.depthwiseInitializer),t.pointwiseInitializer=lX(this.pointwiseInitializer),t.depthwiseRegularizer=eK(this.depthwiseRegularizer),t.pointwiseRegularizer=eK(this.pointwiseRegularizer),t.depthwiseConstraint=YX(this.depthwiseConstraint),t.pointwiseConstraint=YX(this.pointwiseConstraint),t}}wK.className="SeparableConv";class SK extends wK{constructor(t){super(2,t)}}SK.className="SeparableConv2D",oF(SK);class xK extends yK{constructor(t){super(1,t),xK.verifyArgs(t),this.inputSpec=[{ndim:3}]}getConfig(){const t=super.getConfig();return delete t.rank,delete t.dataFormat,t}static verifyArgs(t){if("number"!=typeof t.kernelSize&&!KW(t.kernelSize,"number",1,1))throw new CW(`Conv1D expects config.kernelSize to be number or number[] with length 1, but received ${JSON.stringify(t.kernelSize)}.`)}}xK.className="Conv1D",oF(xK);class RK extends wX{constructor(t){super(t),"number"==typeof t.cropping?this.cropping=[[t.cropping,t.cropping],[t.cropping,t.cropping]]:"number"==typeof t.cropping[0]?this.cropping=[[t.cropping[0],t.cropping[0]],[t.cropping[1],t.cropping[1]]]:this.cropping=t.cropping,this.dataFormat=void 0===t.dataFormat?"channelsLast":t.dataFormat,this.inputSpec=[{ndim:4}]}computeOutputShape(t){return"channelsFirst"===this.dataFormat?[t[0],t[1],t[2]-this.cropping[0][0]-this.cropping[0][1],t[3]-this.cropping[1][0]-this.cropping[1][1]]:[t[0],t[1]-this.cropping[0][0]-this.cropping[0][1],t[2]-this.cropping[1][0]-this.cropping[1][1],t[3]]}call(t,e){return vD((()=>{if(t=cX(t),"channelsLast"===this.dataFormat){const e=Mz(t,this.cropping[0][0],t.shape[1]-this.cropping[0][0]-this.cropping[0][1],2);return Mz(e,this.cropping[1][0],t.shape[2]-this.cropping[1][1]-this.cropping[1][0],3)}{const e=Mz(t,this.cropping[0][0],t.shape[2]-this.cropping[0][0]-this.cropping[0][1],3);return Mz(e,this.cropping[1][0],t.shape[3]-this.cropping[1][1]-this.cropping[1][0],4)}}))}getConfig(){const t={cropping:this.cropping,dataFormat:this.dataFormat},e=super.getConfig();return Object.assign(t,e),t}}RK.className="Cropping2D",oF(RK);class AK extends wX{constructor(t){var e;super(t),this.DEFAULT_SIZE=[2,2],this.inputSpec=[{ndim:4}],this.size=null==t.size?this.DEFAULT_SIZE:t.size,this.dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,hz(this.dataFormat),this.interpolation=null==t.interpolation?"nearest":t.interpolation,e=this.interpolation,qW(rz,"InterpolationFormat",e)}computeOutputShape(t){if("channelsFirst"===this.dataFormat){const e=null==t[2]?null:this.size[0]*t[2],n=null==t[3]?null:this.size[1]*t[3];return[t[0],t[1],e,n]}{const e=null==t[1]?null:this.size[0]*t[1],n=null==t[2]?null:this.size[1]*t[2];return[t[0],e,n,t[3]]}}call(t,e){return vD((()=>{let e=cX(t);const n=e.shape;if("channelsFirst"===this.dataFormat){e=QF(e,[0,2,3,1]);const t=this.size[0]*n[2],i=this.size[1]*n[3],s="nearest"===this.interpolation?tG.resizeNearestNeighbor(e,[t,i]):tG.resizeBilinear(e,[t,i]);return QF(s,[0,3,1,2])}{const t=this.size[0]*n[1],i=this.size[1]*n[2];return"nearest"===this.interpolation?tG.resizeNearestNeighbor(e,[t,i]):tG.resizeBilinear(e,[t,i])}}))}getConfig(){const t={size:this.size,dataFormat:this.dataFormat,interpolation:this.interpolation},e=super.getConfig();return Object.assign(t,e),t}}AK.className="UpSampling2D",oF(AK);class OK extends TK{constructor(t){super(2,t),this.depthwiseKernel=null,this.depthMultiplier=null==t.depthMultiplier?1:t.depthMultiplier,this.depthwiseInitializer=uX(t.depthwiseInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.depthwiseConstraint=HX(t.depthwiseConstraint),this.depthwiseRegularizer=iK(t.depthwiseRegularizer)}build(t){if((t=dX(t)).length<4)throw new CW(`Inputs to DepthwiseConv2D should have rank 4. Received input shape: ${JSON.stringify(t)}.`);const e="channelsFirst"===this.dataFormat?1:3;if(null==t[e]||t[e]<0)throw new CW(`The channel dimension of the inputs to DepthwiseConv2D should be defined, but is not (${t[e]}).`);const n=t[e],i=[this.kernelSize[0],this.kernelSize[1],n,this.depthMultiplier];this.depthwiseKernel=this.addWeight("depthwise_kernel",i,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(t,e){return vD((()=>{let e= /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ function(t,e,n=[1,1],i="valid",s,r){return vD((()=>{null==s&&(s="channelsLast"),hz(s);let a=dK(t,s);if(4!==t.rank)throw new CW(`Input for depthwiseConv2d is required to be 4-D, but is instead ${t.rank}-D`);if(4!==e.rank)throw new CW(`depthwiseKernel is required to be 4-D, but is instead ${e.rank}-D`);return a=iB(a,e,n,"same"===i?"same":"valid","NHWC",r),"channelsFirst"===s&&(a=QF(a,[0,3,1,2])),a}))}(t=cX(t),this.depthwiseKernel.read(),this.strides,this.padding,this.dataFormat,null);return this.useBias&&(e=Bz(e,this.bias.read(),this.dataFormat)),null!=this.activation&&(e=this.activation.apply(e)),e}))}computeOutputShape(t){t=dX(t);const e="channelsFirst"===this.dataFormat?t[2]:t[1],n="channelsFirst"===this.dataFormat?t[3]:t[2],i="channelsFirst"===this.dataFormat?t[1]*this.depthMultiplier:t[3]*this.depthMultiplier,s=pK(e,this.kernelSize[0],this.padding,this.strides[0]),r=pK(n,this.kernelSize[1],this.padding,this.strides[1]);return"channelsFirst"===this.dataFormat?[t[0],i,s,r]:[t[0],s,r,i]}getConfig(){const t=super.getConfig();return t.depthMultiplier=this.depthMultiplier,t.depthwiseInitializer=lX(this.depthwiseInitializer),t.depthwiseRegularizer=eK(this.depthwiseRegularizer),t.depthwiseConstraint=YX(this.depthwiseRegularizer),t}} /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ function MK(t,e,n,i){if(Array.isArray(t)){if(null!=e||null!=n)throw new CW("When inputs is an array, neither initialState or constants should be provided");null!=i&&(n=t.slice(t.length-i,t.length),t=t.slice(0,t.length-i)),t.length>1&&(e=t.slice(1,t.length)),t=t[0]}function s(t){return null==t||Array.isArray(t)?t:[t]}return{inputs:t,initialState:e=s(e),constants:n=s(n)}}function CK(t,e,n,i=!1,s,r,a=!1,o=!1){return vD((()=>{const l=e.shape.length;if(l<3)throw new CW(`Input should be at least 3D, but is ${l}D.`);const u=[1,0].concat(vz(2,l));if(e=QF(e,u),null!=r)throw new NW("The rnn() functoin of the deeplearn.js backend does not support constants yet.");a&&console.warn("Backend rnn(): the unroll = true option is not applicable to the imperative deeplearn.js backend."),null!=s&&((s=BL(BL(s,"bool"),"float32")).rank===l-1&&(s=OB(s,-1)),s=QF(s,u)),i&&(e=zV(e,0),null!=s&&(s=zV(s,0)));const h=[];let p,c=n;const d=e.shape[0],f=CU(e);let m,g;null!=s&&(m=CU(s));for(let e=0;et(n,c)));if(null==s)p=i[0],c=i[1];else{const t=vD((()=>{const t=m[e],n=fF(TV(t),t);return{output:YL(WL(i[0],t),WL(c[0],n)),newStates:c.map(((e,s)=>YL(WL(i[1][s],t),WL(e,n))))}}));p=t.output,c=t.newStates}o&&h.push(p)}if(o){g=_U(h,1)}return[p,g,c]}))}OK.className="DepthwiseConv2D",oF(OK);class NK extends wX{constructor(t){let e;if(super(t),null==t.cell)throw new CW("cell property is missing for the constructor of RNN.");if(e=Array.isArray(t.cell)?new VK({cells:t.cell}):t.cell,null==e.stateSize)throw new CW("The RNN cell should have an attribute `stateSize` (tuple of integers, one integer per RNN state).");this.cell=e,this.returnSequences=null!=t.returnSequences&&t.returnSequences,this.returnState=null!=t.returnState&&t.returnState,this.goBackwards=null!=t.goBackwards&&t.goBackwards,this._stateful=null!=t.stateful&&t.stateful,this.unroll=null!=t.unroll&&t.unroll,this.supportsMasking=!0,this.inputSpec=[new yX({ndim:3})],this.stateSpec=null,this.states_=null,this.numConstants=null,this.keptStates=[]}getStates(){if(null==this.states_){return vz(0,Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1).map((t=>null))}return this.states_}setStates(t){this.states_=t}computeOutputShape(t){hX(t)&&(t=t[0]);let e=this.cell.stateSize;Array.isArray(e)||(e=[e]);const n=e[0];let i;if(i=this.returnSequences?[t[0],t[1],n]:[t[0],n],this.returnState){const n=[];for(const i of e)n.push([t[0],i]);return[i].concat(n)}return i}computeMask(t,e){return vD((()=>{Array.isArray(e)&&(e=e[0]);const t=this.returnSequences?e:null;if(this.returnState){const e=this.states.map((t=>null));return[t].concat(e)}return t}))}get states(){if(null==this.states_){const t=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1,e=[];for(let n=0;nt.shape[t.shape.length-1])),s))throw new CW(`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=s.map((t=>new yX({shape:[null,t]})));this.stateful&&this.resetStates()}resetStates(t,e=!1){vD((()=>{if(!this.stateful)throw new OW("Cannot call resetStates() on an RNN Layer that is not stateful.");const n=this.inputSpec[0].shape[0];if(null==n)throw new CW("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((t=>lV([n,t]))):this.states_=[lV([n,this.cell.stateSize])];else if(null==t)wD(this.states_),null!=this.keptStates&&(wD(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((t=>lV([n,t]))):this.states_[0]=lV([n,this.cell.stateSize]);else{if(Array.isArray(t)||(t=[t]),t.length!==this.states_.length)throw new CW(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${t.length} state value(s). Input received: ${t}`);!0===e?this.keptStates.push(this.states_.slice()):wD(this.states_);for(let e=0;eSD(t.clone())))}))}apply(t,e){let n=null==e?null:e.initialState,i=null==e?null:e.constants;null==e&&(e={});const s=MK(t,n,i,this.numConstants);t=s.inputs,n=s.initialState,i=s.constants;let r=[],a=[];if(null!=n){e.initialState=n,r=r.concat(n),this.stateSpec=[];for(const t of n)this.stateSpec.push(new yX({shape:t.shape}));a=a.concat(this.stateSpec)}null!=i&&(e.constants=i,r=r.concat(i),this.numConstants=i.length);if(r[0]instanceof IX){const n=[t].concat(r),i=this.inputSpec.concat(a),s=this.inputSpec;this.inputSpec=i;const o=super.apply(n,e);return this.inputSpec=s,o}return super.apply(t,e)}call(t,e){return vD((()=>{const n=null==e?null:e.mask,i=null==e?null:e.training;let s=null==e?null:e.initialState;t=cX(t),null==s&&(s=this.stateful?this.states_:this.getInitialState(t));const r=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1;if(s.length!==r)throw new CW(`RNN Layer has ${r} state(s) but was passed ${s.length} initial state(s).`);this.unroll&&console.warn("Ignoring unroll = true for RNN layer, due to imperative backend.");const a={training:i},o=CK(((t,e)=>{const n=this.cell.call([t].concat(e),a);return[n[0],n.slice(1)]}),t,s,this.goBackwards,n,null,this.unroll,this.returnSequences),l=o[0],u=o[1],h=o[2];this.stateful&&this.resetStates(h,i);const p=this.returnSequences?u:l;return this.returnState?[p].concat(h):p}))}getInitialState(t){return vD((()=>{let e=lV(t.shape);return e=wB(e,[1,2]),e=Rz(e),Array.isArray(this.cell.stateSize)?this.cell.stateSize.map((t=>t>1?kz(e,[1,t]):e)):this.cell.stateSize>1?[kz(e,[1,this.cell.stateSize])]:[e]}))}get trainableWeights(){return this.trainable?this.cell.trainableWeights:[]}get nonTrainableWeights(){return this.trainable?this.cell.nonTrainableWeights:this.cell.weights}setFastWeightInitDuringBuild(t){super.setFastWeightInitDuringBuild(t),null!=this.cell&&this.cell.setFastWeightInitDuringBuild(t)}getConfig(){const t=super.getConfig(),e={returnSequences:this.returnSequences,returnState:this.returnState,goBackwards:this.goBackwards,stateful:this.stateful,unroll:this.unroll};null!=this.numConstants&&(e.numConstants=this.numConstants);const n=this.cell.getConfig();return this.getClassName()===NK.className&&(e.cell={className:this.cell.getClassName(),config:n}),Object.assign(Object.assign(Object.assign({},n),t),e)}static fromConfig(t,e,n={}){const i=Ej(e.cell,n);return new t(Object.assign(e,{cell:i}))}}NK.className="RNN",oF(NK);class kK extends wX{}class DK extends kK{constructor(t){super(t),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",this.units=t.units,QW(this.units,"units"),this.activation=Kq(null==t.activation?this.DEFAULT_ACTIVATION:t.activation),this.useBias=null==t.useBias||t.useBias,this.kernelInitializer=uX(t.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=uX(t.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=uX(t.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=iK(t.kernelRegularizer),this.recurrentRegularizer=iK(t.recurrentRegularizer),this.biasRegularizer=iK(t.biasRegularizer),this.kernelConstraint=HX(t.kernelConstraint),this.recurrentConstraint=HX(t.recurrentConstraint),this.biasConstraint=HX(t.biasConstraint),this.dropout=Ez([1,bz([0,null==t.dropout?0:t.dropout])]),this.recurrentDropout=Ez([1,bz([0,null==t.recurrentDropout?0:t.recurrentDropout])]),this.dropoutFunc=t.dropoutFunc,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(t){t=dX(t),this.kernel=this.addWeight("kernel",[t[t.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(t,e){return vD((()=>{if(2!==t.length)throw new CW(`SimpleRNNCell expects 2 input Tensors, got ${t.length}.`);let n=t[1];t=t[0];const i=null!=e.training&&e.training;let s;0TV(t),rate:this.dropout,training:i,dropoutFunc:this.dropoutFunc})),0TV(n),rate:this.recurrentDropout,training:i,dropoutFunc:this.dropoutFunc}));const r=this.dropoutMask,a=this.recurrentDropoutMask;s=Lz(null!=r?WL(t,r):t,this.kernel.read()),null!=this.bias&&(s=Bz(s,this.bias.read())),null!=a&&(n=WL(n,a));let o=YL(s,Lz(n,this.recurrentKernel.read()));return null!=this.activation&&(o=this.activation.apply(o)),[o,o]}))}getConfig(){const t=super.getConfig(),e={units:this.units,activation:jq(this.activation),useBias:this.useBias,kernelInitializer:lX(this.kernelInitializer),recurrentInitializer:lX(this.recurrentInitializer),biasInitializer:lX(this.biasInitializer),kernelRegularizer:eK(this.kernelRegularizer),recurrentRegularizer:eK(this.recurrentRegularizer),biasRegularizer:eK(this.biasRegularizer),activityRegularizer:eK(this.activityRegularizer),kernelConstraint:YX(this.kernelConstraint),recurrentConstraint:YX(this.recurrentConstraint),biasConstraint:YX(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout};return Object.assign(Object.assign({},t),e)}}DK.className="SimpleRNNCell",oF(DK);class LK extends NK{constructor(t){t.cell=new DK(t),super(t)}call(t,e){return vD((()=>{null!=this.cell.dropoutMask&&(wD(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(wD(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const n=null==e?null:e.mask,i=null==e?null:e.training,s=null==e?null:e.initialState;return super.call(t,{mask:n,training:i,initialState:s})}))}static fromConfig(t,e){return new t(e)}}LK.className="SimpleRNN",oF(LK);class FK extends kK{constructor(t){if(super(t),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",t.resetAfter)throw new CW("GRUCell does not support reset_after parameter set to true.");this.units=t.units,QW(this.units,"units"),this.activation=Kq(void 0===t.activation?this.DEFAULT_ACTIVATION:t.activation),this.recurrentActivation=Kq(void 0===t.recurrentActivation?this.DEFAULT_RECURRENT_ACTIVATION:t.recurrentActivation),this.useBias=null==t.useBias||t.useBias,this.kernelInitializer=uX(t.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=uX(t.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=uX(t.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=iK(t.kernelRegularizer),this.recurrentRegularizer=iK(t.recurrentRegularizer),this.biasRegularizer=iK(t.biasRegularizer),this.kernelConstraint=HX(t.kernelConstraint),this.recurrentConstraint=HX(t.recurrentConstraint),this.biasConstraint=HX(t.biasConstraint),this.dropout=Ez([1,bz([0,null==t.dropout?0:t.dropout])]),this.recurrentDropout=Ez([1,bz([0,null==t.recurrentDropout?0:t.recurrentDropout])]),this.dropoutFunc=t.dropoutFunc,this.implementation=t.implementation,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(t){const e=(t=dX(t))[t.length-1];this.kernel=this.addWeight("kernel",[e,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(t,e){return vD((()=>{if(2!==t.length)throw new CW(`GRUCell expects 2 input Tensors (inputs, h, c), got ${t.length}.`);const n=null!=e.training&&e.training;let i=t[1];t=t[0],0TV(t),rate:this.dropout,training:n,count:3,dropoutFunc:this.dropoutFunc})),0TV(i),rate:this.recurrentDropout,training:n,count:3,dropoutFunc:this.dropoutFunc}));const s=this.dropoutMask,r=this.recurrentDropoutMask;let a,o,l;0{null!=this.cell.dropoutMask&&(wD(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(wD(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const n=null==e?null:e.mask,i=null==e?null:e.training,s=null==e?null:e.initialState;return super.call(t,{mask:n,training:i,initialState:s})}))}static fromConfig(t,e){return 0===e.implmentation&&(e.implementation=1),new t(e)}}PK.className="GRU",oF(PK);class $K extends kK{constructor(t){super(t),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=t.units,QW(this.units,"units"),this.activation=Kq(void 0===t.activation?this.DEFAULT_ACTIVATION:t.activation),this.recurrentActivation=Kq(void 0===t.recurrentActivation?this.DEFAULT_RECURRENT_ACTIVATION:t.recurrentActivation),this.useBias=null==t.useBias||t.useBias,this.kernelInitializer=uX(t.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=uX(t.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=uX(t.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.unitForgetBias=t.unitForgetBias,this.kernelRegularizer=iK(t.kernelRegularizer),this.recurrentRegularizer=iK(t.recurrentRegularizer),this.biasRegularizer=iK(t.biasRegularizer),this.kernelConstraint=HX(t.kernelConstraint),this.recurrentConstraint=HX(t.recurrentConstraint),this.biasConstraint=HX(t.biasConstraint),this.dropout=Ez([1,bz([0,null==t.dropout?0:t.dropout])]),this.recurrentDropout=Ez([1,bz([0,null==t.recurrentDropout?0:t.recurrentDropout])]),this.dropoutFunc=t.dropoutFunc,this.implementation=t.implementation,this.stateSize=[this.units,this.units],this.dropoutMask=null,this.recurrentDropoutMask=null}build(t){var e;const n=(t=dX(t))[t.length-1];let i;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 t=this.biasInitializer,n=this.units;i=new((e=class extends Hz{apply(e,i){const s=t.apply([n]),r=(new zz).apply([n]),a=t.apply([2*n]);return Nz(Nz(s,r),a)}}).className="CustomInit",e)}else i=this.biasInitializer;this.bias=this.addWeight("bias",[4*this.units],null,i,this.biasRegularizer,!0,this.biasConstraint)}else this.bias=null;this.built=!0}call(t,e){return vD((()=>{const n=null!=e.training&&e.training;if(3!==t.length)throw new CW(`LSTMCell expects 3 input Tensors (inputs, h, c), got ${t.length}.`);let i=t[1];const s=t[2];t=t[0],0TV(t),rate:this.dropout,training:n,count:4,dropoutFunc:this.dropoutFunc})),0TV(i),rate:this.recurrentDropout,training:n,count:4,dropoutFunc:this.dropoutFunc}));const r=this.dropoutMask,a=this.recurrentDropoutMask;let o,l,u,h;0{null!=this.cell.dropoutMask&&(wD(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(wD(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const n=null==e?null:e.mask,i=null==e?null:e.training,s=null==e?null:e.initialState;return super.call(t,{mask:n,training:i,initialState:s})}))}static fromConfig(t,e){return 0===e.implmentation&&(e.implementation=1),new t(e)}}BK.className="LSTM",oF(BK);class VK extends kK{constructor(t){super(t),this.cells=t.cells}get stateSize(){const t=[];for(const e of this.cells.slice().reverse())Array.isArray(e.stateSize)?t.push(...e.stateSize):t.push(e.stateSize);return t}call(t,e){return vD((()=>{let n=t.slice(1);const i=[];for(const t of this.cells.slice().reverse())Array.isArray(t.stateSize)?i.push(n.splice(0,t.stateSize.length)):i.push(n.splice(0,1));i.reverse();const s=[];let r;for(let a=0;a{mz(`RNNCell_${i}`,(()=>{n.build(t),e=Array.isArray(n.stateSize)?n.stateSize[0]:n.stateSize,t=[t[0],e]}))})),this.built=!0}getConfig(){const t=super.getConfig(),e={cells:this.cells.map((t=>({className:t.getClassName(),config:t.getConfig()})))};return Object.assign(Object.assign({},t),e)}static fromConfig(t,e,n={}){const i=[];for(const t of e.cells)i.push(Ej(t,n));return new t({cells:i})}get trainableWeights(){if(!this.trainable)return[];const t=[];for(const e of this.cells)t.push(...e.trainableWeights);return t}get nonTrainableWeights(){const t=[];for(const e of this.cells)t.push(...e.nonTrainableWeights);if(!this.trainable){const e=[];for(const t of this.cells)e.push(...t.trainableWeights);return e.concat(t)}return t}getWeights(){const t=[];for(const e of this.cells)t.push(...e.weights);return _X(t)}setWeights(t){const e=[];for(const n of this.cells){const i=n.weights.length,s=t.splice(i);for(let t=0;tnull!=r?r(e(),n):Vz(e(),n),o=()=>Uz(a,e,i);if(!s||s<=1)return SD(o().clone());return Array(s).fill(void 0).map(o).map((t=>SD(t.clone())))}VK.className="StackedRNNCells",oF(VK); /** * @license * Copyright 2020 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ var YK=function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(i=Object.getOwnPropertySymbols(t);s{if(null!=this.cell.dropoutMask&&(wD(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(wD(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null),e&&e.constants)throw new CW("ConvRNN2D cell does not support constants");const n=null==e?null:e.mask,i=null==e?null:e.training,s=null==e?null:e.initialState;return super.call(t,{mask:n,training:i,initialState:s})}))}computeOutputShape(t){let e=this.computeSingleOutputShape(t);return this.returnSequences||(e=[e[0],...e.slice(2)]),this.returnState&&(e=[e,...Array(2).fill([t[0],...e.slice(-3)])]),e}getInitialState(t){return vD((()=>{const{stateSize:e}=this.cell,n=t.shape,i=this.computeSingleOutputShape(n),s=lV([i[0],...i.slice(2)]);return Array.isArray(e)?Array(e.length).fill(s):[s]}))}resetStates(t,e=!1){vD((()=>{if(!this.stateful)throw new OW("Cannot call resetStates() on an RNN Layer that is not stateful.");const n=this.inputSpec[0].shape,i=this.computeSingleOutputShape(n),s=[i[0],...i.slice(2)];if(null==n[0])throw new CW("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((()=>lV(s))):this.states_=[lV(s)];else if(null==t)wD(this.states_),null!=this.keptStates&&(wD(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((()=>lV(s))):this.states_[0]=lV(s);else{if(Array.isArray(t)||(t=[t]),t.length!==this.states_.length)throw new CW(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${t.length} state value(s). Input received: ${t}`);e?this.keptStates.push(this.states_.slice()):wD(this.states_);for(let e=0;eSD(t.clone())))}))}computeSingleOutputShape(t){const{dataFormat:e,filters:n,kernelSize:i,padding:s,strides:r,dilationRate:a}=this.cell,o="channelsFirst"===e,l=t[o?3:2],u=t[o?4:3],h=pK(l,i[0],s,r[0],a[0]),p=pK(u,i[1],s,r[1],a[1]);return[...t.slice(0,2),...o?[n,h,p]:[h,p,n]]}}GK.className="ConvRNN2D";class HK extends $K{constructor(t){const{filters:e,kernelSize:n,strides:i,padding:s,dataFormat:r,dilationRate:a}=t;super(Object.assign(Object.assign({},t),{units:e})),this.filters=e,QW(this.filters,"filters"),this.kernelSize=hK(n,2,"kernelSize"),this.kernelSize.forEach((t=>QW(t,"kernelSize"))),this.strides=hK(i||1,2,"strides"),this.strides.forEach((t=>QW(t,"strides"))),this.padding=s||"valid",pz(this.padding),this.dataFormat=r||"channelsLast",hz(this.dataFormat),this.dilationRate=hK(a||1,2,"dilationRate"),this.dilationRate.forEach((t=>QW(t,"dilationRate")))}build(t){var e;t=dX(t);const n="channelsFirst"===this.dataFormat?1:t.length-1;if(null==t[n])throw new CW(`The channel dimension of the input should be defined. Found ${t[n]}`);const i=t[n],s=this.kernelSize.concat([i,4*this.filters]);this.kernel=this.addWeight("kernel",s,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint);const r=this.kernelSize.concat([this.filters,4*this.filters]);if(this.recurrentKernel=this.addWeight("recurrent_kernel",r,null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){let t;if(this.unitForgetBias){const n=this.biasInitializer,i=this.filters;t=new((e=class extends Hz{apply(t,e){return Cz([n.apply([i]),uV([i]),n.apply([2*i])])}}).className="CustomInit",e)}else t=this.biasInitializer;this.bias=this.addWeight("bias",[4*this.filters],null,t,this.biasRegularizer,!0,this.biasConstraint)}this.built=!0}call(t,e){return vD((()=>{if(3!==t.length)throw new CW(`ConvLSTM2DCell expects 3 input Tensors (inputs, h, c), got ${t.length}.`);const n=e.training||!1,i=t[0],s=t[1],r=t[2];0TV(i),rate:this.dropout,training:n,count:4,dropoutFunc:this.dropoutFunc}));const a=this.dropoutMask,o=(t,e,n)=>e&&e[n]?WL(e[n],t):t;let l=o(i,a,0),u=o(i,a,1),h=o(i,a,2),p=o(i,a,3);0TV(s),rate:this.recurrentDropout,training:n,count:4,dropoutFunc:this.dropoutFunc}));const c=this.recurrentDropoutMask;let d=o(s,c,0),f=o(s,c,1),m=o(s,c,2),g=o(s,c,3);const[_,T,y,I]=dU(this.kernel.read(),4,3),[E,b,v,w]=this.useBias?dU(this.bias.read(),4):[null,null,null,null];l=this.inputConv(l,_,E,this.padding),u=this.inputConv(u,T,b,this.padding),h=this.inputConv(h,y,v,this.padding),p=this.inputConv(p,I,w,this.padding);const[S,x,R,A]=dU(this.recurrentKernel.read(),4,3);d=this.recurrentConv(d,S),f=this.recurrentConv(f,x),m=this.recurrentConv(m,R),g=this.recurrentConv(g,A);const O=this.recurrentActivation.apply(YL(l,d)),M=this.recurrentActivation.apply(YL(u,f)),C=YL(WL(M,r),WL(O,this.activation.apply(YL(h,m)))),N=WL(this.recurrentActivation.apply(YL(p,g)),this.activation.apply(C));return[N,N,C]}))}getConfig(){const t=super.getConfig(),{units:e}=t,n=YK(t,["units"]),i={filters:this.filters,kernelSize:this.kernelSize,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,strides:this.strides};return Object.assign(Object.assign({},n),i)}inputConv(t,e,n,i){const s=H$(t,e,this.strides,i||"valid","channelsFirst"===this.dataFormat?"NCHW":"NHWC",this.dilationRate);return n?Bz(s,n,this.dataFormat):s}recurrentConv(t,e){return H$(t,e,1,"same","channelsFirst"===this.dataFormat?"NCHW":"NHWC")}}HK.className="ConvLSTM2DCell",oF(HK);class WK extends GK{constructor(t){const e=new HK(t);super(Object.assign(Object.assign({},t),{cell:e}))}static fromConfig(t,e){return new t(e)}}WK.className="ConvLSTM2D",oF(WK); /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ class zK extends wX{constructor(t){super(t),this.rate=Math.max(Math.min(t.rate,1),0),this.noiseShape=t.noiseShape,this.seed=t.seed,this.supportsMasking=!0}getNoiseShape(t){if(null==this.noiseShape)return this.noiseShape;const e=t.shape,n=[];for(let t=0;t{this.invokeCallHook(t,e);const n=cX(t);if(0Vz(n,this.rate,i,this.seed)),(()=>n),t)}return t}))}getConfig(){const t={rate:this.rate,noiseShape:this.noiseShape,seed:this.seed},e=super.getConfig();return Object.assign(t,e),t}dispose(){return super.dispose()}}zK.className="Dropout",oF(zK);class XK extends zK{constructor(t){super(t),this.inputSpec=[{ndim:3}]}getNoiseShape(t){const e=t.shape;return[e[0],1,e[2]]}}XK.className="SpatialDropout1D",oF(XK);class jK extends wX{constructor(t){if(super(t),this.activation=null,this.useBias=!0,this.kernel=null,this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",null==t.batchInputShape&&null==t.inputShape&&null!=t.inputDim){let e=null;null!=t.batchSize&&(e=t.batchSize),this.batchInputShape=[e,t.inputDim]}this.units=t.units,QW(this.units,"units"),this.activation=Kq(t.activation),null!=t.useBias&&(this.useBias=t.useBias),this.kernelInitializer=uX(t.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.biasInitializer=uX(t.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelConstraint=HX(t.kernelConstraint),this.biasConstraint=HX(t.biasConstraint),this.kernelRegularizer=iK(t.kernelRegularizer),this.biasRegularizer=iK(t.biasRegularizer),this.activityRegularizer=iK(t.activityRegularizer),this.supportsMasking=!0,this.inputSpec=[{minNDim:2}]}build(t){const e=(t=dX(t))[t.length-1];null==this.kernel&&(this.kernel=this.addWeight("kernel",[e,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]:e}}],this.built=!0}computeOutputShape(t){const e=(t=dX(t)).slice();return e[e.length-1]=this.units,e}call(t,e){return vD((()=>{this.invokeCallHook(t,e);const n=cX(t),i=ZW(this.activation.getClassName());let s;return null!=i?s=Lz(n,this.kernel.read(),i,this.bias?this.bias.read():null):(s=Lz(n,this.kernel.read()),null!=this.bias&&(s=Bz(s,this.bias.read())),null!=this.activation&&(s=this.activation.apply(s))),s}))}getConfig(){const t={units:this.units,activation:jq(this.activation),useBias:this.useBias,kernelInitializer:lX(this.kernelInitializer),biasInitializer:lX(this.biasInitializer),kernelRegularizer:eK(this.kernelRegularizer),biasRegularizer:eK(this.biasRegularizer),activityRegularizer:eK(this.activityRegularizer),kernelConstraint:YX(this.kernelConstraint),biasConstraint:YX(this.biasConstraint)},e=super.getConfig();return Object.assign(t,e),t}}jK.className="Dense",oF(jK);class qK extends wX{constructor(t){super(t=t||{}),this.inputSpec=[{minNDim:3}],this.dataFormat=t.dataFormat}computeOutputShape(t){t=dX(t);for(const e of t.slice(1))if(null==e)throw new CW(`The shape of the input to "Flatten" is not fully defined (got ${t.slice(1)}). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.`);return[t[0],Iz(t,1)]}call(t,e){return vD((()=>{this.invokeCallHook(t,e);let n=cX(t);if("channelsFirst"===this.dataFormat&&n.rank>1){const t=[0];for(let e=2;e{this.invokeCallHook(t,e);const n=cX(t);return this.activation.apply(n)}))}getConfig(){const t={activation:jq(this.activation)},e=super.getConfig();return Object.assign(t,e),t}}KK.className="Activation",oF(KK);class QK extends wX{constructor(t){super(t),this.n=t.n,this.inputSpec=[{ndim:2}]}computeOutputShape(t){return[t[0],this.n,t[1]]}call(t,e){return vD((()=>{return t=cX(t),e=t,n=this.n,vD((()=>{if(2!==e.shape.length)throw new CW(`repeat() expects a rank-2 tensor, but received a rank-${e.shape.length} tensor.`);return kz(Rz(e,1),[1,n,1])}));var e,n}))}getConfig(){const t={n:this.n},e=super.getConfig();return Object.assign(t,e),t}}QK.className="RepeatVector",oF(QK);class JK extends wX{constructor(t){super(t),this.targetShape=t.targetShape;for(let t=0;t{this.invokeCallHook(t,e);const n=cX(t),i=n.shape,s=i.slice(0,1).concat(this.fixUnknownDimension(i.slice(1),this.targetShape));return E$(n,s)}))}getConfig(){const t={targetShape:this.targetShape},e=super.getConfig();return Object.assign(t,e),t}}JK.className="Reshape",oF(JK);class ZK extends wX{constructor(t){if(super(t),null==t.dims)throw new Error("Required configuration field `dims` is missing during Permute constructor call.");if(!Array.isArray(t.dims))throw new Error(`Permute constructor requires \`dims\` to be an Array, but received ${t.dims} instead.`);const e=vz(1,t.dims.length+1);if(!SA(t.dims.slice().sort(),e))throw new Error("Invalid permutation `dims`: "+JSON.stringify(t.dims)+" `dims` must contain consecutive integers starting from 1.");this.dims=t.dims,this.dimsIncludingBatch=[0].concat(this.dims),this.inputSpec=[new yX({ndim:this.dims.length+1})]}computeOutputShape(t){const e=(t=dX(t)).slice();return this.dims.forEach(((n,i)=>{e[i+1]=t[n]})),e}call(t,e){return QF(cX(t),this.dimsIncludingBatch)}getConfig(){const t={dims:this.dims},e=super.getConfig();return Object.assign(t,e),t}}ZK.className="Permute",oF(ZK);class tQ extends wX{constructor(t){super(null==t?{}:t),this.supportsMasking=!0,this.maskValue=null!=t?null==t.maskValue?0:t.maskValue:0}computeOutputShape(t){return t}getConfig(){const t=super.getConfig(),e={maskValue:this.maskValue};return Object.assign(e,t),e}computeMask(t,e){const n=cX(t);return JP(_V(n,this.maskValue),-1)}call(t,e){return vD((()=>{this.invokeCallHook(t,e);const n=cX(t),i=JP(_V(n,this.maskValue),-1,!0);return WL(n,BL(i,n.dtype))}))}}tQ.className="Masking",oF(tQ); /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ class eQ extends wX{constructor(t){if(super(t),this.embeddings=null,this.DEFAULT_EMBEDDINGS_INITIALIZER="randomUniform",null==t.batchInputShape&&null==t.inputShape){let e=null;null!=t.batchSize&&(e=t.batchSize),null==t.inputLength?this.batchInputShape=[e,null]:this.batchInputShape=[e].concat(BW(t.inputLength))}this.inputDim=t.inputDim,QW(this.inputDim,"inputDim"),this.outputDim=t.outputDim,QW(this.outputDim,"outputDim"),this.embeddingsInitializer=uX(t.embeddingsInitializer||this.DEFAULT_EMBEDDINGS_INITIALIZER),this.embeddingsRegularizer=iK(t.embeddingsRegularizer),this.activityRegularizer=iK(t.activityRegularizer),this.embeddingsConstraint=HX(t.embeddingsConstraint),this.maskZero=t.maskZero,this.supportsMasking=t.maskZero,this.inputLength=t.inputLength}build(t){this.embeddings=this.addWeight("embeddings",[this.inputDim,this.outputDim],this.dtype,this.embeddingsInitializer,this.embeddingsRegularizer,!0,this.embeddingsConstraint),this.built=!0}warnOnIncompatibleInputShape(t){}computeMask(t,e){return vD((()=>this.maskZero?(t=cX(t),_V(t,jL(t))):null))}computeOutputShape(t){if(t=dX(t),null==this.inputLength)return[...t,this.outputDim];const e=BW(this.inputLength);if(e.length!==t.length-1)throw new CW(`"inputLength" is ${this.inputLength}, but received input shape has shape ${t}`);{let n=0;for(let i=0;i{this.invokeCallHook(t,e);let n=cX(t);"int32"!==n.dtype&&(n=xz(n,"int32"));const i=Fz(this.embeddings.read(),E$(n,[n.size]));return E$(i,dX(this.computeOutputShape(n.shape)))}))}getConfig(){const t={inputDim:this.inputDim,outputDim:this.outputDim,embeddingsInitializer:lX(this.embeddingsInitializer),embeddingsRegularizer:eK(this.embeddingsRegularizer),activityRegularizer:eK(this.activityRegularizer),embeddingsConstraint:YX(this.embeddingsConstraint),maskZero:this.maskZero,inputLength:this.inputLength},e=super.getConfig();return Object.assign(t,e),t}}eQ.className="Embedding",oF(eQ); /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ class nQ extends wX{constructor(t){super(t||{}),this.supportsMasking=!0}mergeFunction(t){throw new NW}computeElementwiseOpOutputShape(t,e){if(null==t||null==e)return null;if(t.length1)throw new CW(`Can not merge tensors with different batch sizes. Got tensors with shapes: ${JSON.stringify(t)}.`);let n=null==t[0]?null:t[0].slice(1);for(let e=1;et.length));-1===t.indexOf(null)&&1===XW(i).length?this.reshapeRequired=!1:this.reshapeRequired=!0}call(t,e){return vD((()=>{if(this.reshapeRequired){const e=[],n=t.map((t=>t.rank));if(-1===n.indexOf(null)){const i=bz(n);for(let n of t){const t=n.rank;for(let e=0;e1){const s=vz(1,t).concat([0]);e.push(QF(i,s)),n=!0}else e.push(i)}let i=this.mergeFunction(e);const s=i.rank;if(n)if(null==s){const t=i.shape,e=t[t.length-1],n=[e].concat(t.slice(0,t.length-1));i=E$(QF(E$(i,[-1,e]),[1,0]),n)}else if(s>1){const t=[s-1].concat(vz(0,s-1));i=QF(i,t)}return i}}return this.mergeFunction(t)}))}computeOutputShape(t){let e;e=null==t[0]?null:t[0].slice(1);for(let n=1;n{if(null==e)return null;if(!Array.isArray(e))throw new CW("`mask` should be an Array");if(!Array.isArray(t))throw new CW("`inputs` should be an Array");if(e.length!==t.length)throw new CW(`The Array 'inputs' and 'mask' are expected to have the same length, but have different lengths (${t.length} vs ${e.length})`);if(e.every((t=>null==t)))return null;let n=(e=e.map((t=>null==t?t:OB(t,0))))[0];for(let t=1;t{let e=t[0].clone();for(let n=1;n{let e=t[0].clone();for(let n=1;n{let e=t[0].clone();for(let n=1;n{let e=t[0];for(let n=1;n{let e=t[0];for(let n=1;n1)throw new CW("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: "+JSON.stringify(t))}mergeFunction(t){return vD((()=>Cz(t,this.axis)))}computeOutputShape(t){if(!Array.isArray(t)||!Array.isArray(t[0]))throw new CW("A `Concatenate` layer should be called on a list of inputs.");const e=t,n=e[0].slice(),i=this.axis<0?n.length+this.axis:this.axis;for(const t of e.slice(1)){if(null==n[i]||null==t[i]){n[i]=null;break}n[i]+=t[i]}return n}computeMask(t,e){if(null==e)return null;if(!Array.isArray(e))throw new CW("`mask` should be an array for Concatenate");if(!Array.isArray(t))throw new CW("`inputs` should be an array for Concatenate");if(e.length!==t.length)throw new CW(`Mismatch in the length of mask (${e.length}) and the legnth of inputs (${t.length})`);return vD((()=>{let n=!0;if(e.forEach((t=>{null==t||(n=!1)})),n)return null;const i=[];for(let n=0;n"A `Dot` layer should be called on a list of exactly 2 inputs."));const e=t[0],n=t[1];if(e.length>3||n.length>3)throw new NW("Dot layer does not support tensors of 4D or higher rank yet.");const i=this.interpretAxes(e,n);if(e[i[0]]!==n[i[1]])throw new CW(`Dimension incompatibility: ${e[i[0]]} !== ${n[i[1]]}`)}mergeFunction(t){if(2!==t.length)throw new CW(`A \`Dot\` layer must be called on exactly 2 inputs, but received ${t.length} input(s).`);let e,n=t[0],i=t[1];return e=Array.isArray(this.axes)?this.axes.map(((e,n)=>uQ(e,t[n].shape.length))):[uQ(this.axes,n.shape.length),uQ(this.axes,i.shape.length)],this.normalize&&(n=bj(n,e[0]),i=bj(i,e[1])),function(t,e,n){if(t.shape.length>3||e.shape.length>3)throw new NW("batchDot is not implemented for tensors of 4D or higher rank yet");if(yA(t.shape.length>=2,(()=>`batchDot requires the rank of x to be >= 2, but got ${t.shape.length}`)),yA(t.shape.length>=2,(()=>`batchDot requires the rank of y to be >= 2, but got ${e.shape.length}`)),"number"==typeof n&&(n=[n,n]),"complex64"===t.dtype||"complex64"===e.dtype)throw new NW("batchDot is not implemented for complex64-type Tensors yet.");const i=t.shape.length,s=e.shape.length;null==n&&(n=[i-1,s-2]);const r=n;return vD((()=>{let n,a;if(i>s){n=i-s;const t=[];for(let e=0;ei){n=s-i;const e=[];for(let t=0;t0){let t;t=i>s?i+s-3:i-1;const e=[];for(let i=t;i"A `Dot` layer should be called on a list of exactly 2 inputs."));const e=t[0].slice(),n=t[1].slice();if(e.length>3||n.length>3)throw new NW("Dot layer does not support tensors of 4D or higher rank yet.");const i=this.interpretAxes(e,n);e.splice(i[0],1),n.splice(i[1],1),n.splice(0,1);const s=e.concat(n);return 1===s.length&&s.push(1),s}computeMask(t,e){return null}getConfig(){const t={axes:this.axes,normalize:this.normalize},e=super.getConfig();return Object.assign(t,e),t}}hQ.className="Dot",oF(hQ); /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ class pQ extends wX{constructor(t){super(t),this.supportsMasking=!0,this.stddev=t.stddev}computeOutputShape(t){return t}getConfig(){const t=super.getConfig(),e={stddev:this.stddev};return Object.assign(e,t),e}call(t,e){return vD((()=>{this.invokeCallHook(t,e);const n=cX(t);return Uz((()=>YL(Dz(n.shape,0,this.stddev),n)),(()=>n),e.training||!1)}))}}pQ.className="GaussianNoise",oF(pQ);class cQ extends wX{constructor(t){super(t),this.supportsMasking=!0,this.rate=t.rate}computeOutputShape(t){return t}getConfig(){const t=super.getConfig(),e={rate:this.rate};return Object.assign(e,t),e}call(t,e){return vD((()=>{this.invokeCallHook(t,e);const n=cX(t);if(this.rate>0&&this.rate<1){return Uz((()=>{const t=Math.sqrt(this.rate/(1-this.rate));return WL(n,Dz(n.shape,1,t))}),(()=>n),e.training||!1)}return n}))}}cQ.className="GaussianDropout",oF(cQ);class dQ extends wX{constructor(t){super(t),this.supportsMasking=!0,this.rate=t.rate,this.noiseShape=t.noiseShape}_getNoiseShape(t){return this.noiseShape||cX(t).shape}computeOutputShape(t){return t}getConfig(){const t=super.getConfig(),e={rate:this.rate};return Object.assign(e,t),e}call(t,e){return vD((()=>{if(this.rate<1&&this.rate>0){const n=this._getNoiseShape(t),i=()=>{const e=cX(t),i=-1.7580993408473766;let s=FB(VV(n),this.rate);s=xz(s,"float32");const r=((1-this.rate)*(1+this.rate*i**2))**-.5,a=-r*i*this.rate,o=YL(WL(e,s),WL(YL(s,-1),i));return YL(WL(o,r),a)};return Uz(i,(()=>cX(t)),e.training||!1)}return t}))}} /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ function fQ(t,e,n,i,s,r=.001){let a;if(2===t.rank)a=C$(t,e,n,i,s,r);else if(3===t.rank)a=N$(t,e,n,i,s,r);else{if(4!==t.rank)throw new NW(`batchNormalization is not implemented for array of rank ${t.rank} yet`);a=k$(t,e,n,i,s,r)}return a}function mQ(t,e,n,i,s=.001){return SA(i.slice().sort(),vz(0,t.rank-1))?function(t,e,n,i,s=.001){return vD((()=>{const r=fV(t,i),a=r.mean,o=r.variance;return[fQ(t,a,o,n,e,s),a,o]}))}(t,e,n,i,s):function(t,e,n,i,s=.001){return vD((()=>{const r=fV(t,i),a=r.mean,o=r.variance,l=[];for(const e of vz(0,t.rank))-1!==i.indexOf(e)?l.push(1):l.push(t.shape[e]);const u=E$(a,l),h=E$(o,l),p=null==e?null:E$(e,l),c=null==n?null:E$(n,l);return[fQ(t,u,h,c,p,s),a,o]}))}(t,e,n,i,s)}dQ.className="AlphaDropout",oF(dQ);class gQ extends wX{constructor(t){null==t&&(t={}),super(t),this.supportsMasking=!0,this.axis=null==t.axis?-1:t.axis,this.momentum=null==t.momentum?.99:t.momentum,this.epsilon=null==t.epsilon?.001:t.epsilon,this.center=null==t.center||t.center,this.scale=null==t.scale||t.scale,this.betaInitializer=uX(t.betaInitializer||"zeros"),this.gammaInitializer=uX(t.gammaInitializer||"ones"),this.movingMeanInitializer=uX(t.movingMeanInitializer||"zeros"),this.movingVarianceInitializer=uX(t.movingVarianceInitializer||"ones"),this.betaConstraint=HX(t.betaConstraint),this.gammaConstraint=HX(t.gammaConstraint),this.betaRegularizer=iK(t.betaRegularizer),this.gammaRegularizer=iK(t.gammaRegularizer)}build(t){t=dX(t);const e=this.axis>=0?this.axis:this.axis+t.length,n=t[e];if(null==n)throw new CW(`Axis ${e} of input tensor should have a defined dimension but the layer received an input with shape ${JSON.stringify(t)}.`);this.inputSpec=[new yX({ndim:t.length,axes:{[e]:n}})];const i=[n];this.scale&&(this.gamma=this.addWeight("gamma",i,null,this.gammaInitializer,this.gammaRegularizer,!0,this.gammaConstraint)),this.center&&(this.beta=this.addWeight("beta",i,null,this.betaInitializer,this.betaRegularizer,!0,this.betaConstraint)),this.movingMean=this.addWeight("moving_mean",i,null,this.movingMeanInitializer,null,!1),this.movingVariance=this.addWeight("moving_variance",i,null,this.movingVarianceInitializer,null,!1),this.built=!0}call(t,e){return vD((()=>{const n=null!=e.training&&e.training,i=cX(t),s=i.shape,r=s.length,a=vz(0,r),o=this.axis>=0?this.axis:this.axis+r;a.splice(o,1);const l=LW(1,r);l[o]=s[o];const u=a.slice();u.sort();const h=!SA(u,vz(0,r).slice(0,r-1));if(!n)return(()=>{if(h){const t=E$(this.movingMean.read(),l),e=E$(this.movingVariance.read(),l),n=this.center?E$(this.beta.read(),l):null,s=this.scale?E$(this.gamma.read(),l):null;return fQ(i,t,e,n,s,this.epsilon)}return fQ(i,this.movingMean.read(),this.movingVariance.read(),null==this.beta?null:this.beta.read(),null==this.gamma?null:this.gamma.read(),this.epsilon)})();const[p,c,d]=mQ(i,this.gamma.read(),this.beta.read(),a,this.epsilon),f=(t,e,n)=>{vD((()=>{const i=1-n,s=t.read(),r=WL(fF(s,e),i);t.write(fF(s,r))}))};return(()=>{f(this.movingMean,c,this.momentum),f(this.movingVariance,d,this.momentum)})(),p}))}getConfig(){const t={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:lX(this.betaInitializer),gammaInitializer:lX(this.gammaInitializer),movingMeanInitializer:lX(this.movingMeanInitializer),movingVarianceInitializer:lX(this.movingVarianceInitializer),betaRegularizer:eK(this.betaRegularizer),gammaRegularizer:eK(this.gammaRegularizer),betaConstraint:YX(this.betaConstraint),gammaConstraint:YX(this.gammaConstraint)},e=super.getConfig();return Object.assign(t,e),t}}gQ.className="BatchNormalization",oF(gQ);class _Q extends wX{constructor(t){if(null==t&&(t={}),super(t),this.axis=null==t.axis?-1:t.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 t of this.axis)if(!Number.isInteger(t))throw new Error(`Expected axis to be an array of integers, but received ${JSON.stringify(this.axis)}`)}this.epsilon=null==t.epsilon?.001:t.epsilon,this.center=null==t.center||t.center,this.scale=null==t.scale||t.scale,this.betaInitializer=uX(t.betaInitializer||"zeros"),this.gammaInitializer=uX(t.gammaInitializer||"ones"),this.betaRegularizer=iK(t.betaRegularizer),this.gammaRegularizer=iK(t.gammaRegularizer),this.supportsMasking=!0}build(t){const e=(t=dX(t)).length;"number"==typeof this.axis&&(this.axis=[this.axis]);for(let t=0;t=e)throw new Error(`Invalid axis: ${t}`);if(this.axis.length!==XW(this.axis).length)throw new Error(`Found duplicate axes in: ${this.axis}`);const n=this.axis.map((e=>t[e])),i=!0;this.scale?this.gamma=this.addWeight("gamma",n,"float32",this.gammaInitializer,this.gammaRegularizer,i):this.gamma=null,this.center?this.beta=this.addWeight("beta",n,"float32",this.betaInitializer,this.betaRegularizer,i):this.beta=null,this.built=!0}call(t,e){const n=cX(t),i=n.shape,s=i.length;return vD((()=>{let{mean:t,variance:e}=fV(n,this.axis,!0);const r=LW(1,s);for(const t of this.axis)r[t]=i[t];const a=t=>null!=t&&t.shape.length!==s?E$(t,r):t;let o=this.scale?a(this.gamma.read()):null,l=this.center?a(this.beta.read()):null;const u=[],h=[];for(let t=0;t=0?t[2]+this.padding[0][0]+this.padding[0][1]:null,n=null!=t[3]&&t[3]>=0?t[3]+this.padding[1][0]+this.padding[1][1]:null,[t[0],t[1],e,n]):(e=null!=t[1]&&t[1]>=0?t[1]+this.padding[0][0]+this.padding[0][1]:null,n=null!=t[2]&&t[2]>=0?t[2]+this.padding[1][0]+this.padding[1][1]:null,[t[0],e,n,t[3]])}call(t,e){return vD((()=>{return e=cX(t),n=this.padding,i=this.dataFormat,vD((()=>{if(4!==e.rank)throw new CW(`temporalPadding expects input tensor to be 4-D, but received a ${e.rank}-D tensor.`);if(null==n&&(n=[[1,1],[1,1]]),2!==n.length||2!==n[0].length||2!==n[1].length)throw new CW("spatial2dPadding expects `padding` to be an Array of two Arrays, each of which is an Array of two integers.");if(null==i&&(i="channelsLast"),"channelsLast"!==i&&"channelsFirst"!==i)throw new CW(`Unknown data format: ${i}. Supported data formats are 'channelsLast' and 'channelsFirst.`);let t;return t="channelsFirst"===i?[[0,0],[0,0],n[0],n[1]]:[[0,0],n[0],n[1],[0,0]],IV(e,t)}));var e,n,i}))}getConfig(){const t={padding:this.padding,dataFormat:this.dataFormat},e=super.getConfig();return Object.assign(t,e),t}} /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ function yQ(t,e,n,i,s,r){return vD((()=>{let a;hz(s),cz(r),pz(i),null==n&&(n=[1,1]),null==i&&(i="valid"),null==s&&(s="channelsLast"),null==r&&(r="max"),t=dK(t,s);const o="same"===i?"same":"valid";return a="max"===r?sV(t,e,n,o):b$(t,e,n,o),"channelsFirst"===s&&(a=QF(a,[0,3,1,2])),a}))}function IQ(t,e,n,i,s,r){return vD((()=>{let a;hz(s),cz(r),pz(i),null==n&&(n=[1,1,1]),null==i&&(i="valid"),null==s&&(s="channelsLast"),null==r&&(r="max"),t=fK(t,s);const o="same"===i?"same":"valid";return a="max"===r?rV(t,e,n,o):v$(t,e,n,o),"channelsFirst"===s&&(a=QF(a,[0,4,1,2,3])),a}))}TQ.className="ZeroPadding2D",oF(TQ);class EQ extends wX{constructor(t){if(null==t.poolSize&&(t.poolSize=2),super(t),"number"==typeof t.poolSize)this.poolSize=[t.poolSize];else{if(!Array.isArray(t.poolSize)||1!==t.poolSize.length||"number"!=typeof t.poolSize[0])throw new CW(`poolSize for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(t.poolSize)}`);this.poolSize=t.poolSize}if(QW(this.poolSize,"poolSize"),null==t.strides)this.strides=this.poolSize;else if("number"==typeof t.strides)this.strides=[t.strides];else{if(!Array.isArray(t.strides)||1!==t.strides.length||"number"!=typeof t.strides[0])throw new CW(`strides for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(t.strides)}`);this.strides=t.strides}QW(this.strides,"strides"),this.padding=null==t.padding?"valid":t.padding,pz(this.padding),this.inputSpec=[new yX({ndim:3})]}computeOutputShape(t){const e=pK((t=dX(t))[1],this.poolSize[0],this.padding,this.strides[0]);return[t[0],e,t[2]]}call(t,e){return vD((()=>{this.invokeCallHook(t,e),t=Rz(cX(t),2);const n=this.poolingFunction(cX(t),[this.poolSize[0],1],[this.strides[0],1],this.padding,"channelsLast");return gU(n,[2])}))}getConfig(){const t={poolSize:this.poolSize,padding:this.padding,strides:this.strides},e=super.getConfig();return Object.assign(t,e),t}}class bQ extends EQ{constructor(t){super(t)}poolingFunction(t,e,n,i,s){return hz(s),pz(i),yQ(t,e,n,i,s,"max")}}bQ.className="MaxPooling1D",oF(bQ);class vQ extends EQ{constructor(t){super(t)}poolingFunction(t,e,n,i,s){return hz(s),pz(i),yQ(t,e,n,i,s,"avg")}}vQ.className="AveragePooling1D",oF(vQ);class wQ extends wX{constructor(t){if(null==t.poolSize&&(t.poolSize=[2,2]),super(t),this.poolSize=Array.isArray(t.poolSize)?t.poolSize:[t.poolSize,t.poolSize],null==t.strides)this.strides=this.poolSize;else if(Array.isArray(t.strides)){if(2!==t.strides.length)throw new CW(`If the strides property of a 2D pooling layer is an Array, it is expected to have a length of 2, but received length ${t.strides.length}.`);this.strides=t.strides}else this.strides=[t.strides,t.strides];QW(this.poolSize,"poolSize"),QW(this.strides,"strides"),this.padding=null==t.padding?"valid":t.padding,this.dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,hz(this.dataFormat),pz(this.padding),this.inputSpec=[new yX({ndim:4})]}computeOutputShape(t){t=dX(t);let e="channelsFirst"===this.dataFormat?t[2]:t[1],n="channelsFirst"===this.dataFormat?t[3]:t[2];return e=pK(e,this.poolSize[0],this.padding,this.strides[0]),n=pK(n,this.poolSize[1],this.padding,this.strides[1]),"channelsFirst"===this.dataFormat?[t[0],t[1],e,n]:[t[0],e,n,t[3]]}call(t,e){return vD((()=>(this.invokeCallHook(t,e),this.poolingFunction(cX(t),this.poolSize,this.strides,this.padding,this.dataFormat))))}getConfig(){const t={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},e=super.getConfig();return Object.assign(t,e),t}}class SQ extends wQ{constructor(t){super(t)}poolingFunction(t,e,n,i,s){return hz(s),pz(i),yQ(t,e,n,i,s,"max")}}SQ.className="MaxPooling2D",oF(SQ);class xQ extends wQ{constructor(t){super(t)}poolingFunction(t,e,n,i,s){return hz(s),pz(i),yQ(t,e,n,i,s,"avg")}}xQ.className="AveragePooling2D",oF(xQ);class RQ extends wX{constructor(t){if(null==t.poolSize&&(t.poolSize=[2,2,2]),super(t),this.poolSize=Array.isArray(t.poolSize)?t.poolSize:[t.poolSize,t.poolSize,t.poolSize],null==t.strides)this.strides=this.poolSize;else if(Array.isArray(t.strides)){if(3!==t.strides.length)throw new CW(`If the strides property of a 3D pooling layer is an Array, it is expected to have a length of 3, but received length ${t.strides.length}.`);this.strides=t.strides}else this.strides=[t.strides,t.strides,t.strides];QW(this.poolSize,"poolSize"),QW(this.strides,"strides"),this.padding=null==t.padding?"valid":t.padding,this.dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,hz(this.dataFormat),pz(this.padding),this.inputSpec=[new yX({ndim:5})]}computeOutputShape(t){t=dX(t);let e="channelsFirst"===this.dataFormat?t[2]:t[1],n="channelsFirst"===this.dataFormat?t[3]:t[2],i="channelsFirst"===this.dataFormat?t[4]:t[3];return e=pK(e,this.poolSize[0],this.padding,this.strides[0]),n=pK(n,this.poolSize[1],this.padding,this.strides[1]),i=pK(i,this.poolSize[2],this.padding,this.strides[2]),"channelsFirst"===this.dataFormat?[t[0],t[1],e,n,i]:[t[0],e,n,i,t[4]]}call(t,e){return vD((()=>(this.invokeCallHook(t,e),this.poolingFunction(cX(t),this.poolSize,this.strides,this.padding,this.dataFormat))))}getConfig(){const t={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},e=super.getConfig();return Object.assign(t,e),t}}class AQ extends RQ{constructor(t){super(t)}poolingFunction(t,e,n,i,s){return hz(s),pz(i),IQ(t,e,n,i,s,"max")}}AQ.className="MaxPooling3D",oF(AQ);class OQ extends RQ{constructor(t){super(t)}poolingFunction(t,e,n,i,s){return hz(s),pz(i),IQ(t,e,n,i,s,"avg")}}OQ.className="AveragePooling3D",oF(OQ);class MQ extends wX{constructor(t){super(t),this.inputSpec=[new yX({ndim:3})]}computeOutputShape(t){return[t[0],t[2]]}call(t,e){throw new NW}}class CQ extends MQ{constructor(t){super(t||{})}call(t,e){return vD((()=>{const e=cX(t);return oV(e,1)}))}}CQ.className="GlobalAveragePooling1D",oF(CQ);class NQ extends MQ{constructor(t){super(t||{})}call(t,e){return vD((()=>{const e=cX(t);return bB(e,1)}))}}NQ.className="GlobalMaxPooling1D",oF(NQ);class kQ extends wX{constructor(t){super(t),this.dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,hz(this.dataFormat),this.inputSpec=[new yX({ndim:4})]}computeOutputShape(t){return"channelsLast"===this.dataFormat?[t[0],t[3]]:[t[0],t[1]]}call(t,e){throw new NW}getConfig(){const t={dataFormat:this.dataFormat},e=super.getConfig();return Object.assign(t,e),t}}class DQ extends kQ{call(t,e){return vD((()=>{const e=cX(t);return"channelsLast"===this.dataFormat?oV(e,[1,2]):oV(e,[2,3])}))}}DQ.className="GlobalAveragePooling2D",oF(DQ);class LQ extends kQ{call(t,e){return vD((()=>{const e=cX(t);return"channelsLast"===this.dataFormat?bB(e,[1,2]):bB(e,[2,3])}))}}LQ.className="GlobalMaxPooling2D",oF(LQ); /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ class FQ extends wX{constructor(t){super(t),this.layer=t.layer}build(t){this.built=!0}get trainable(){return null!=this.layer&&this.layer.trainable}set trainable(t){null!=this.layer&&(this.layer.trainable=t)}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(t){this.layer.setWeights(t)}getConfig(){const t={layer:{className:this.layer.getClassName(),config:this.layer.getConfig()}},e=super.getConfig();return Object.assign(t,e),t}setFastWeightInitDuringBuild(t){super.setFastWeightInitDuringBuild(t),null!=this.layer&&this.layer.setFastWeightInitDuringBuild(t)}static fromConfig(t,e,n={}){const i=Ej(e.layer,n);delete e.layer;const s={layer:i};return Object.assign(s,e),new t(s)}}class PQ extends FQ{constructor(t){super(t),this.supportsMasking=!0}build(t){if((t=dX(t)).length<3)throw new CW(`TimeDistributed layer expects an input shape >= 3D, but received input shape ${JSON.stringify(t)}`);this.inputSpec=[{shape:t}];const e=[t[0]].concat(t.slice(2));this.layer.built||(this.layer.build(e),this.layer.built=!0),super.build(t)}computeOutputShape(t){const e=[(t=dX(t))[0]].concat(t.slice(2)),n=this.layer.computeOutputShape(e),i=t[1];return[n[0],i].concat(n.slice(1))}call(t,e){return vD((()=>CK(((t,n)=>[cX(this.layer.call(t,e)),[]]),t=cX(t),[],!1,null,null,!1,!0)[1]))}}PQ.className="TimeDistributed",oF(PQ);class $Q extends FQ{constructor(t){super(t);const e=t.layer.getConfig(),n={};n.className=t.layer.getClassName(),n.config=e,this.forwardLayer=Ej(n),e.goBackwards=!0!==e.goBackwards;const i={};var s;if(i.className=t.layer.getClassName(),i.config=e,this.backwardLayer=Ej(i),this.forwardLayer.name="forward_"+this.forwardLayer.name,this.backwardLayer.name="backward_"+this.backwardLayer.name,this.mergeMode=void 0===t.mergeMode?"concat":t.mergeMode,s=this.mergeMode,qW(lz,"BidirectionalMergeMode",s),t.weights)throw new NW("weights support is not implemented for Bidirectional layer yet.");this._stateful=t.layer.stateful,this.returnSequences=t.layer.returnSequences,this.returnState=t.layer.returnState,this.supportsMasking=!0,this._trainable=!0,this.inputSpec=t.layer.inputSpec,this.numConstants=null}get trainable(){return this._trainable}set trainable(t){this._trainable=t,null!=this.forwardLayer&&(this.forwardLayer.trainable=t),null!=this.backwardLayer&&(this.backwardLayer.trainable=t)}getWeights(){return this.forwardLayer.getWeights().concat(this.backwardLayer.getWeights())}setWeights(t){const e=t.length,n=Math.floor(e/2);this.forwardLayer.setWeights(t.slice(0,n)),this.backwardLayer.setWeights(t.slice(n))}computeOutputShape(t){let e,n,i,s=this.forwardLayer.computeOutputShape(t);return Array.isArray(s)&&Array.isArray(s[0])||(s=[s]),this.returnState?(i=s.slice(1),e=s[0]):e=s[0],"concat"===this.mergeMode?(e[e.length-1]*=2,n=[e]):n=null==this.mergeMode?[e,e.slice()]:[e],this.returnState?null==this.mergeMode?n.concat(i).concat(i.slice()):[e].concat(i).concat(i.slice()):$W(n)}apply(t,e){let n=null==e?null:e.initialState,i=null==e?null:e.constants;null==e&&(e={});const s=MK(t,n,i,this.numConstants);if(t=s.inputs,n=s.initialState,i=s.constants,Array.isArray(t)&&(n=t.slice(1),t=t[0]),(null==n||0===n.length)&&null==i)return super.apply(t,e);const r=[],a=[];if(null!=n){const t=n.length;if(t%2>0)throw new CW("When passing `initialState` to a Bidrectional RNN, the state should be an Array containing the states of the underlying RNNs.");e.initialState=n,r.push(...n);const i=n.map((t=>new yX({shape:t.shape})));this.forwardLayer.stateSpec=i.slice(0,t/2),this.backwardLayer.stateSpec=i.slice(t/2),a.push(...i)}if(null!=i)throw new NW("Support for constants in Bidirectional layers is not implemented yet.");const o=r[0]instanceof IX;for(const t of r)if(t instanceof IX!==o)throw new CW("The initial state of a Bidirectional layer cannot be specified as a mix of symbolic and non-symbolic tensors");if(o){const n=[t].concat(r),i=this.inputSpec.concat(a),s=this.inputSpec;this.inputSpec=i;const o=super.apply(n,e);return this.inputSpec=s,o}return super.apply(t,e)}call(t,e){return vD((()=>{const n=e.initialState;let i,s,r,a;if(null==n)i=this.forwardLayer.call(t,e),s=this.backwardLayer.call(t,e);else{const r=n.slice(0,n.length/2),a=n.slice(n.length/2);i=this.forwardLayer.call(t,Object.assign(e,{initialState:r})),s=this.backwardLayer.call(t,Object.assign(e,{initialState:a}))}return this.returnState&&(Array.isArray(i)&&(r=i.slice(1).concat(s.slice(1))),i=i[0],s=s[0]),this.returnSequences&&(s=zV(s,1)),"concat"===this.mergeMode?a=Cz([i,s]):"sum"===this.mergeMode?a=YL(i,s):"ave"===this.mergeMode?a=WL(.5,YL(i,s)):"mul"===this.mergeMode?a=WL(i,s):null==this.mergeMode&&(a=[i,s]),this.returnState?null==this.mergeMode?a.concat(r):[a].concat(r):a}))}resetStates(t){this.forwardLayer.resetStates(),this.backwardLayer.resetStates()}build(t){mz(this.forwardLayer.name,(()=>{this.forwardLayer.build(t)})),mz(this.backwardLayer.name,(()=>{this.backwardLayer.build(t)})),this.built=!0}computeMask(t,e){let n;if(Array.isArray(e)&&(e=e[0]),n=this.returnSequences?null==this.mergeMode?[e,e]:e:null==this.mergeMode?[null,null]:null,this.returnState){const t=this.forwardLayer.states.map((t=>null));return Array.isArray(n)?n.concat(t).concat(t):[n].concat(t).concat(t)}return n}get trainableWeights(){return this.forwardLayer.trainableWeights.concat(this.backwardLayer.trainableWeights)}get nonTrainableWeights(){return this.forwardLayer.nonTrainableWeights.concat(this.backwardLayer.nonTrainableWeights)}setFastWeightInitDuringBuild(t){super.setFastWeightInitDuringBuild(t),null!=this.forwardLayer&&this.forwardLayer.setFastWeightInitDuringBuild(t),null!=this.backwardLayer&&this.backwardLayer.setFastWeightInitDuringBuild(t)}getConfig(){const t={mergeMode:this.mergeMode},e=super.getConfig();return Object.assign(t,e),t}static fromConfig(t,e){const n=Ej(e.layer);if(delete e.layer,null!=e.numConstants)throw new NW("Deserialization of a Bidirectional layer with numConstants present is not supported yet.");const i=e;return i.layer=n,new t(i)}}$Q.className="Bidirectional",oF($Q); /** * @license * Copyright 2022 CodeSmith LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ class BQ extends wX{constructor(t){super(t),this.scale=t.scale,t.offset?this.offset=t.offset:this.offset=0}getConfig(){const t={scale:this.scale,offset:this.offset},e=super.getConfig();return Object.assign(t,e),t}call(t,e){return vD((()=>("float32"!==(t=cX(t)).dtype&&(t=xz(t,"float32")),YL(WL(t,this.scale),this.offset))))}}BQ.className="Rescaling",oF(BQ); /** * @license * Copyright 2022 CodeSmith LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ const{resizeBilinear:VQ,cropAndResize:UQ}=tG;class YQ extends wX{constructor(t){super(t),this.height=t.height,this.width=t.width}centerCrop(t,e,n,i,s,r,a,o){return vD((()=>{let l,u=!1;const h=[e/r,n/a,(i+e)/r,(s+n)/a],p=[];3===t.rank?(u=!0,l=_U([t])):l=t;for(let t=0;txz(VQ(t,[e,n]),i)))}call(t,e){return vD((()=>{const e=cX(t),n=e.dtype,i=e.shape,s=i[i.length-3],r=i[i.length-2];let a=0;s!==this.height&&(a=Math.floor((s-this.height)/2));let o=0;return r!==this.width&&(o=Math.floor((r-this.width)/2),0===o&&(o=1)),a>=0&&o>=0?this.centerCrop(e,a,o,this.height,this.width,s,r,n):this.upsize(t,this.height,this.width,n)}))}getConfig(){const t={height:this.height,width:this.width},e=super.getConfig();return Object.assign(t,e),t}computeOutputShape(t){const e=(t=dX(t)).length-3,n=t.length-2;return t[e]=this.height,t[n]=this.width,t}}YQ.className="CenterCrop",oF(YQ); /** * @license * Copyright 2022 CodeSmith LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ class GQ extends wX{constructor(t){super(t),this.numTokens=t.numTokens,t.outputMode?this.outputMode=t.outputMode:this.outputMode="multiHot"}getConfig(){const t={numTokens:this.numTokens,outputMode:this.outputMode},e=super.getConfig();return Object.assign(t,e),t}computeOutputShape(t){return null==(t=dX(t))?[this.numTokens]:"oneHot"===this.outputMode&&1!==t[t.length-1]?(t.push(this.numTokens),t):(t[t.length-1]=this.numTokens,t)}call(t,e){return vD((()=>{let n;if("int32"!==(t=cX(t)).dtype&&(t=xz(t,"int32")),void 0!==e.countWeights){if("count"!==this.outputMode)throw new CW(`countWeights is not used when outputMode !== count.\n Received countWeights=${e.countWeights}`);n=cX(e.countWeights)}const i=bB(t),s=vB(t),r=LB(this.numTokens,i).bufferSync().get(0),a=FB(s,0).bufferSync().get(0);if(!r||!a)throw new CW(`Input values must be between 0 < values <= numTokens with numTokens=${this.numTokens}`); /** * @license * Copyright 2022 CodeSmith LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ return function(t,e,n,i){let s=cX(t);if("int32"!==s.dtype&&(s=xz(s,"int32")),"int"===e)return s;const r=s.shape;if(0===s.rank&&(s=OB(s,-1)),"oneHot"===e&&1!==s.shape[s.shape.length-1]&&(s=OB(s,-1)),s.rank>2)throw new CW(`When outputMode is not int, maximum output rank is 2 Received outputMode ${e} and input shape ${r} which would result in output rank ${s.rank}.`);const a=["multiHot","oneHot"].includes(e),o=s;let l;if(l=eB(o,void 0!==i&&"count"===e?i:[],n,a),"tfIdf"!==e)return l;if(i)return WL(l,i);throw new CW("When outputMode is 'tfIdf', weights must be provided.")}(t,this.outputMode,this.numTokens,n)}))}}GQ.className="CategoryEncoding",oF(GQ); /** * @license * Copyright 2022 CodeSmith LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ const HQ=new Set(["bilinear","nearest"]);class WQ extends wX{constructor(t){if(super(t),this.height=t.height,this.width=t.width,t.interpolation){if(!HQ.has(t.interpolation))throw new CW(`Invalid interpolation parameter: ${t.interpolation} is not implemented`);this.interpolation=t.interpolation}else this.interpolation="bilinear";this.cropToAspectRatio=Boolean(t.cropToAspectRatio)}computeOutputShape(t){const e=(t=dX(t))[2];return[this.height,this.width,e]}getConfig(){const t={height:this.height,width:this.width,interpolation:this.interpolation,cropToAspectRatio:this.cropToAspectRatio},e=super.getConfig();return Object.assign(t,e),t}call(t,e){return vD((()=>{const e=[this.height,this.width];if("bilinear"===this.interpolation)return tG.resizeBilinear(t,e,!this.cropToAspectRatio);if("nearest"===this.interpolation)return tG.resizeNearestNeighbor(t,e,!this.cropToAspectRatio);throw new Error(`Interpolation is ${this.interpolation} but only ${[...HQ]} are supported`)}))}}WQ.className="Resizing",oF(WQ); /** * @license * Copyright 2023 CodeSmith LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ class zQ{constructor(t){this.seed=t}next(){if(void 0!==this.seed)return this.seed++}}zQ.className="RandomSeed"; /** * @license * Copyright 2023 CodeSmith LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ class XQ extends wX{constructor(t){super(t),this.randomGenerator=new zQ(t.seed)}getConfig(){const t={seed:this.randomGenerator.seed},e=super.getConfig();return Object.assign(t,e),t}}XQ.className="BaseRandomLayer"; /** * @license * Copyright 2023 CodeSmith LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ const jQ=new Set(["bilinear","nearest"]);class qQ extends XQ{constructor(t){super(t);const{factor:e,interpolation:n="bilinear"}=t;if(this.factor=e,Array.isArray(this.factor)&&2===this.factor.length)this.widthLower=this.factor[0],this.widthUpper=this.factor[1];else{if(Array.isArray(this.factor)||!(this.factor>0))throw new CW(`Invalid factor: ${this.factor}. Must be positive number or tuple of 2 numbers`);this.widthLower=-this.factor,this.widthUpper=this.factor}if(this.widthLower<-1||this.widthUpper<-1)throw new CW(`factor must have values larger than -1. Got: ${this.factor}`);if(this.widthUpper{const e=cX(t);this.imgHeight=e.shape[e.shape.length-3];const n=e.shape[e.shape.length-2];this.widthFactor=VV([1],1+this.widthLower,1+this.widthUpper,"float32",this.randomGenerator.next());let i=this.widthFactor.dataSync()[0]*n;i=Math.round(i);const s=[this.imgHeight,i];switch(this.interpolation){case"bilinear":return tG.resizeBilinear(t,s);case"nearest":return tG.resizeNearestNeighbor(t,s);default:throw new Error(`Interpolation is ${this.interpolation}\n but only ${[...jQ]} are supported`)}}))}} /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ function KQ(t){return new xX(t)}function QQ(t){return new oK(t)}function JQ(t){return new sK(t)}function ZQ(t){return new rK(t)}function tJ(t){return new aK(t)}function eJ(t){return new uK(t)}function nJ(t){return new lK(t)}function iJ(t){return new xK(t)}function sJ(t){return new IK(t)}function rJ(t){return new bK(t)}function aJ(t){return new EK(t)}function oJ(t){return new vK(t)}function lJ(t){return new SK(t)}function uJ(t){return new RK(t)}function hJ(t){return new AK(t)}function pJ(t){return new OK(t)}function cJ(t){return new KK(t)}function dJ(t){return new jK(t)}function fJ(t){return new zK(t)}function mJ(t){return new XK(t)}function gJ(t){return new qK(t)}function _J(t){return new QK(t)}function TJ(t){return new JK(t)}function yJ(t){return new ZK(t)}function IJ(t){return new eQ(t)}function EJ(t){return new iQ(t)}function bJ(t){return new rQ(t)}function vJ(t){return new lQ(t)}function wJ(t){return new aQ(t)}function SJ(t){return new oQ(t)}function xJ(t){return new sQ(t)}function RJ(t){return new hQ(t)}function AJ(t){return new gQ(t)}function OJ(t){return new _Q(t)}function MJ(t){return new TQ(t)}function CJ(t){return new vQ(t)}function NJ(t){return CJ(t)}function kJ(t){return CJ(t)}function DJ(t){return new xQ(t)}function LJ(t){return DJ(t)}function FJ(t){return DJ(t)}function PJ(t){return new OQ(t)}function $J(t){return PJ(t)}function BJ(t){return PJ(t)}function VJ(t){return new CQ(t)}function UJ(t){return new DQ(t)}function YJ(t){return new NQ(t)}function GJ(t){return new LQ(t)}function HJ(t){return new bQ(t)}function WJ(t){return new SQ(t)}function zJ(t){return new AQ(t)}function XJ(t){return new PK(t)}function jJ(t){return new FK(t)}function qJ(t){return new BK(t)}function KJ(t){return new $K(t)}function QJ(t){return new LK(t)}function JJ(t){return new DK(t)}function ZJ(t){return new WK(t)}function tZ(t){return new HK(t)}function eZ(t){return new NK(t)}function nZ(t){return new VK(t)}function iZ(t){return new $Q(t)}function sZ(t){return new PQ(t)}qQ.className="RandomWidth",oF(qQ);const rZ=YJ,aZ=GJ,oZ=HJ,lZ=WJ;function uZ(t){return new pQ(t)}function hZ(t){return new cQ(t)}function pZ(t){return new dQ(t)}function cZ(t){return new tQ(t)}function dZ(t){return new BQ(t)}function fZ(t){return new YQ(t)}function mZ(t){return new WQ(t)}function gZ(t){return new GQ(t)}function _Z(t){return new qQ(t)}function TZ(t,e){return Dj(t,e)}function yZ(t,e){return Bj(t,e)}function IZ(t,e){return Vj(t,e)}function EZ(t,e){return Lj(t,e)}function bZ(t,e){return Uj(t,e)}function vZ(t,e){return Pj(t,e)}function wZ(t,e){return $j(t,e)}function SZ(t,e){return Cj(t,e)}function xZ(t,e){return wj(t,e)}function RZ(t,e){return Sj(t,e)}function AZ(t,e){return Sj(t,e)}function OZ(t,e){return Sj(t,e)}function MZ(t,e){return vj(t,e)}function CZ(t,e){return vj(t,e)}function NZ(t,e){return vj(t,e)}function kZ(t,e){return function(t,e){return vD((()=>{const n=t.sub(e).square().sum(),i=t.sub(t.mean()).square().sum();return nF(1).sub(n.div(i))}))}(t,e)} /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ function DZ(t){return new Zq(t)}function LZ(t){return Qq(e=t),new Zq({l1:null!=e?e.l1:null,l2:0});var e}function FZ(t){return Qq(e=t),new Zq({l2:null!=e?e.l2:null,l1:0});var e} /** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ class PZ extends dj{constructor(){super(...arguments),this.model=null}setModel(t){if(!(t instanceof bq))throw new Error("model must be a LayersModel, not some other Container");this.model=t}}function $Z(t,e){return te}class VZ extends PZ{constructor(t){if(super(),null==t&&(t={}),t.restoreBestWeights)throw new NW("restoreBestWeights = True is not implemented in EarlyStopping yet.");this.monitor=t.monitor||"val_loss",this.minDelta=Math.abs(t.minDelta||0),this.patience=t.patience||0,this.verbose=t.verbose||0,this.mode=t.mode||"auto",this.baseline=t.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=$Z:"max"===this.mode||-1!==this.monitor.indexOf("acc")?this.monitorFunc=BZ:this.monitorFunc=$Z,this.monitorFunc===$Z&&(this.minDelta*=-1)}async onTrainBegin(t){this.wait=0,this.stoppedEpoch=0,null!=this.baseline?this.best=this.baseline:this.best=this.monitorFunc===$Z?1/0:-1/0}async onEpochEnd(t,e){await hj(e);const n=this.getMonitorValue(e);null!=n&&(this.monitorFunc(n-this.minDelta,this.best)?(this.best=n,this.wait=0):(this.wait++,this.wait>=this.patience&&(this.stoppedEpoch=t,this.model.stopTraining=!0)))}async onTrainEnd(t){this.stoppedEpoch>0&&this.verbose&&console.log(`Epoch ${this.stoppedEpoch}: early stopping.`)}getMonitorValue(t){null==t&&(t={});const e=t[this.monitor];return null==e&&console.warn(`Metric for EarlyStopping ${this.monitor} is not available. Available metrics are: ${Object.keys(t)}`),e}}const UZ={earlyStopping:function(t){return new VZ(t)}}; /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ var YZ,GZ;lO().registerFlag("KEEP_INTERMEDIATE_TENSORS",(()=>!1),(t=>{t&&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(t){t[t.DT_INVALID=0]="DT_INVALID",t[t.DT_FLOAT=1]="DT_FLOAT",t[t.DT_DOUBLE=2]="DT_DOUBLE",t[t.DT_INT32=3]="DT_INT32",t[t.DT_UINT8=4]="DT_UINT8",t[t.DT_INT16=5]="DT_INT16",t[t.DT_INT8=6]="DT_INT8",t[t.DT_STRING=7]="DT_STRING",t[t.DT_COMPLEX64=8]="DT_COMPLEX64",t[t.DT_INT64=9]="DT_INT64",t[t.DT_BOOL=10]="DT_BOOL",t[t.DT_QINT8=11]="DT_QINT8",t[t.DT_QUINT8=12]="DT_QUINT8",t[t.DT_QINT32=13]="DT_QINT32",t[t.DT_BFLOAT16=14]="DT_BFLOAT16",t[t.DT_QINT16=15]="DT_QINT16",t[t.DT_QUINT16=16]="DT_QUINT16",t[t.DT_UINT16=17]="DT_UINT16",t[t.DT_COMPLEX128=18]="DT_COMPLEX128",t[t.DT_HALF=19]="DT_HALF",t[t.DT_RESOURCE=20]="DT_RESOURCE",t[t.DT_VARIANT=21]="DT_VARIANT",t[t.DT_UINT32=22]="DT_UINT32",t[t.DT_UINT64=23]="DT_UINT64",t[t.DT_FLOAT_REF=101]="DT_FLOAT_REF",t[t.DT_DOUBLE_REF=102]="DT_DOUBLE_REF",t[t.DT_INT32_REF=103]="DT_INT32_REF",t[t.DT_UINT8_REF=104]="DT_UINT8_REF",t[t.DT_INT16_REF=105]="DT_INT16_REF",t[t.DT_INT8_REF=106]="DT_INT8_REF",t[t.DT_STRING_REF=107]="DT_STRING_REF",t[t.DT_COMPLEX64_REF=108]="DT_COMPLEX64_REF",t[t.DT_INT64_REF=109]="DT_INT64_REF",t[t.DT_BOOL_REF=110]="DT_BOOL_REF",t[t.DT_QINT8_REF=111]="DT_QINT8_REF",t[t.DT_QUINT8_REF=112]="DT_QUINT8_REF",t[t.DT_QINT32_REF=113]="DT_QINT32_REF",t[t.DT_BFLOAT16_REF=114]="DT_BFLOAT16_REF",t[t.DT_QINT16_REF=115]="DT_QINT16_REF",t[t.DT_QUINT16_REF=116]="DT_QUINT16_REF",t[t.DT_UINT16_REF=117]="DT_UINT16_REF",t[t.DT_COMPLEX128_REF=118]="DT_COMPLEX128_REF",t[t.DT_HALF_REF=119]="DT_HALF_REF",t[t.DT_RESOURCE_REF=120]="DT_RESOURCE_REF",t[t.DT_VARIANT_REF=121]="DT_VARIANT_REF",t[t.DT_UINT32_REF=122]="DT_UINT32_REF",t[t.DT_UINT64_REF=123]="DT_UINT64_REF"}(YZ||(YZ={})),function(t){let e;!function(t){t[t.LEGACY=0]="LEGACY",t[t.V1=1]="V1",t[t.V2=2]="V2"}(e=t.CheckpointFormatVersion||(t.CheckpointFormatVersion={}))}(GZ||(GZ={})); /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const HZ={};function WZ(t,e){const n={tfOpName:t,category:"custom",inputs:[],attrs:[],customExecutor:e};HZ[t]=n}function zZ(t){return HZ[t]}function XZ(t){delete HZ[t]} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function jZ(t,e,n,i,s){const r=e.inputParams[t];if(r&&void 0!==r.inputIndexStart){const t=r.inputIndexStart,a=0===r.inputIndexEnd?void 0:void 0===r.inputIndexEnd?t+1:r.inputIndexEnd,o=t<0?e.inputNames.length+t:t;if("tensor"===r.type)return qZ(e.inputNames[o],n,i,s);if("tensors"===r.type){const r=e.inputs.slice(t,a);return e.inputNames.slice(t,a).filter(((t,e)=>{var n;return"NoOp"!==(null===(n=r[e])||void 0===n?void 0:n.op)})).map((t=>qZ(t,n,i,s)))}const l=qZ(e.inputNames[o],n,i,s),u=l.dataSync();return"number"===r.type?u[0]:KA(l.shape,u)}const a=e.attrParams[t];return a&&a.value}function qZ(t,e,n,i){const[s,r]=ZZ(t,n);if(null!=i){const t=i.getHashTableHandleByName(s);if(null!=t)return t}const a=n.currentContextIds.find((t=>!!e[JZ(s,t)]));return void 0!==a?e[JZ(s,a)][r]:void 0}function KZ(t,e,n){return e[JZ(t,n.currentContextId)]}function QZ(t,e){const[n,i,s]=ZZ(t,e);return[JZ(n,e&&e.currentContextId),i,s]}function JZ(t,e){return e?`${t}-${e}`:t}function ZZ(t,e){if(""===t)return["",0,void 0];const n=null!=e&&null!=e.parseNodeNameCache;if(n){const n=e.parseNodeNameCache.get(t);if(null!=n)return n}const i=t.split(":");let s;if(1===i.length)s=[t,0,void 0];else{const t=i[0],e=3===i.length?i[1]:void 0;s=[t,Number(i[i.length-1]),e]}return n&&e.parseNodeNameCache.set(t,s),s}function t0(t,e,n){let i=jZ("pad",t,e,n);if("explicit"===i){i=jZ("explicitPaddings",t,e,n);const s=[[0,0],[0,0],[0,0],[0,0]];for(let t=0;t<4;t++)s[t][0]=i[2*t],s[t][1]=i[2*t+1];return s}return i}function e0(t){return t.kept?t:VL(t)} /** * @license * Copyright 2023 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const n0=[{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}]}],i0=[{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:"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}]},{tfOpName:"IsFinite",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"IsInf",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],s0=[{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"}]}],r0=[{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"}]}],a0=[{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"}]},{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:"RandomUniformInt",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"minval",name:"minval",type:"number"},{tfName:"maxval",name:"maxval",type:"number"},{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,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"}]}],o0=[{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}]}],l0=[{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"}]}],u0=[{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"}]}],h0=[{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"}]},{tfOpName:"InitializeTable",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}]},{tfOpName:"InitializeTableV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}]}],p0=[{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"}]}],c0=[{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}]},{tfOpName:"BitwiseAnd",category:"logical",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}]}],d0=[{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"}]},{tfOpName:"MatrixBandPart",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"numLower",type:"tensor"},{start:1,name:"numUpper",type:"tensor"}]}],f0=[{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"}]}],m0=[{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"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{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"}]}],g0=[{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}]},{tfOpName:"TensorScatterUpdate",category:"slice_join",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"values",type:"tensor"}]}],_0=[{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"}]}],T0=[{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}]}],y0=[{tfOpName:"StaticRegexReplace",category:"string",inputs:[{start:0,name:"input",type:"tensor"}],attrs:[{tfName:"pattern",name:"pattern",type:"string"},{tfName:"rewrite",name:"rewrite",type:"string"},{tfName:"replace_global",name:"replaceGlobal",type:"bool"}]},{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"}]}],I0=[{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:"EnsureShape",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:[]}]; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class E0{static get Instance(){return this._instance||(this._instance=new this)}constructor(){const t=[].concat(...[Rt,At,Ot,Mt,Ct,Nt,kt,Dt,Lt,Ft,Pt,$t,Bt,Vt,Ut,Yt,Gt,Ht,Wt].map((t=>t.json)));this.opMappers=t.reduce(((t,e)=>(t[e.tfOpName]=e,t)),{})}transformGraph(t,e={}){const n=t.node,i=[],s=[],r=[],a=n.reduce(((t,e)=>(t[e.name]=this.mapNode(e),e.op.startsWith("Placeholder")?i.push(t[e.name]):"Const"===e.op?s.push(t[e.name]):null!=e.input&&0!==e.input.length||r.push(t[e.name]),t)),{});let o=[];const l=[];let u={},h={};null!=e&&(u=this.mapSignatureEntries(e.inputs),h=this.mapSignatureEntries(e.outputs));const p=Object.keys(a);p.forEach((t=>{const e=a[t];e.inputNames.forEach(((t,n)=>{const[i,,s]=QZ(t),r=a[i];if(null!=r.outputs){const t=r.outputs.indexOf(s);if(-1!==t){const s=`${i}:${t}`;e.inputNames[n]=s}}e.inputs.push(r),r.children.push(e)}))})),0===Object.keys(h).length?p.forEach((t=>{const e=a[t];0===e.children.length&&l.push(e)})):Object.keys(h).forEach((t=>{const[e]=QZ(t),n=a[e];null!=n&&(n.signatureKey=h[t],l.push(n))})),Object.keys(u).length>0?Object.keys(u).forEach((t=>{const[e]=QZ(t),n=a[e];n&&(n.signatureKey=u[t],o.push(n))})):o=i;let c={};null!=t.library&&null!=t.library.function&&(c=t.library.function.reduce(((t,e)=>(t[e.signature.name]=this.mapFunction(e),t)),{}));const d={nodes:a,inputs:o,outputs:l,weights:s,placeholders:i,signature:e,functions:c};return r.length>0&&(d.initNodes=r),d}mapSignatureEntries(t){return Object.keys(t||{}).reduce(((e,n)=>(e[t[n].name]=n,e)),{})}mapNode(t){const e=zZ(t.op)||this.opMappers[t.op]||{};null==t.attr&&(t.attr={});const n={name:t.name,op:t.op,category:e.category,inputNames:(t.input||[]).map((t=>t.startsWith("^")?t.slice(1):t)),inputs:[],children:[],inputParams:{},attrParams:{},rawAttrs:t.attr,outputs:e.outputs};return null!=e.inputs&&(n.inputParams=e.inputs.reduce(((t,e)=>(t[e.name]={type:e.type,inputIndexStart:e.start,inputIndexEnd:e.end},t)),{})),null!=e.attrs&&(n.attrParams=e.attrs.reduce(((e,n)=>{const i=n.type;let s;switch(n.type){case"string":s=v0(t.attr,n.tfName,n.defaultValue),void 0===s&&n.tfDeprecatedName&&(s=v0(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"string[]":s=k0(t.attr,n.tfName,n.defaultValue),void 0===s&&n.tfDeprecatedName&&(s=k0(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"number":s=S0(t.attr,n.tfName,n.defaultValue||0),void 0===s&&n.tfDeprecatedName&&(s=S0(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"number[]":s=N0(t.attr,n.tfName,n.defaultValue),void 0===s&&n.tfDeprecatedName&&(s=N0(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool":s=w0(t.attr,n.tfName,n.defaultValue),void 0===s&&n.tfDeprecatedName&&(s=w0(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool[]":s=L0(t.attr,n.tfName,n.defaultValue),void 0===s&&n.tfDeprecatedName&&(s=L0(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape":s=C0(t.attr,n.tfName,n.defaultValue),void 0===s&&n.tfDeprecatedName&&(s=C0(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape[]":s=D0(t.attr,n.tfName,n.defaultValue),void 0===s&&n.tfDeprecatedName&&(s=D0(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype":s=A0(t.attr,n.tfName,n.defaultValue),void 0===s&&n.tfDeprecatedName&&(s=A0(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype[]":s=O0(t.attr,n.tfName,n.defaultValue),void 0===s&&n.tfDeprecatedName&&(s=O0(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"func":s=R0(t.attr,n.tfName,n.defaultValue),void 0===s&&n.tfDeprecatedName&&(s=R0(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"tensor":case"tensors":break;default:throw new Error(`Unsupported param type: ${n.type} for op: ${t.op}`)}return e[n.name]={value:s,type:i},e}),{})),n}mapFunction(t){const e=t.nodeDef,n=[];let i={};null!=e&&(i=e.reduce(((t,e)=>(t[e.name]=this.mapNode(e),"Const"===e.op&&n.push(t[e.name]),t)),{}));const s=[],r=[];t.signature.inputArg.forEach((t=>{const[e]=QZ(t.name),n={name:e,op:"Placeholder",inputs:[],inputNames:[],category:"graph",inputParams:{},attrParams:{dtype:{value:x0(t.type),type:"dtype"}},children:[]};n.signatureKey=t.name,s.push(n),i[e]=n}));Object.keys(i).forEach((t=>{const e=i[t];e.inputNames.forEach(((t,n)=>{const[s,,r]=QZ(t),a=i[s];if(null!=a.outputs){const t=a.outputs.indexOf(r);if(-1!==t){const i=`${s}:${t}`;e.inputNames[n]=i}}e.inputs.push(a),a.children.push(e)}))}));const a=t.ret;t.signature.outputArg.forEach((t=>{const[e,n]=QZ(a[t.name]),s=i[e];null!=s&&(s.defaultOutput=n,r.push(s))}));const o=this.mapArgsToSignature(t);return{nodes:i,inputs:s,outputs:r,weights:n,placeholders:[],signature:o}}mapArgsToSignature(t){return{methodName:t.signature.name,inputs:t.signature.inputArg.reduce(((t,e)=>(t[e.name]=this.mapArgToTensorInfo(e),t)),{}),outputs:t.signature.outputArg.reduce(((e,n)=>(e[n.name]=this.mapArgToTensorInfo(n,t.ret),e)),{})}}mapArgToTensorInfo(t,e){let n=t.name;return null!=e&&(n=e[n]),{name:n,dtype:t.type}}}function b0(t,e){const n=Array.isArray(t)?String.fromCharCode.apply(null,t):function(t){const e=lO().global;if(void 0!==e.atob)return e.atob(t);if("undefined"!=typeof Buffer)return new Buffer(t,"base64").toString();throw new Error("Unable to decode base64 in this environment. Missing built-in atob() or Buffer()")}(t);return e?n:n.toLowerCase()}function v0(t,e,n,i=!1){const s=t[e];return null!=s?b0(s.s,i):n}function w0(t,e,n){const i=t[e];return i?i.b:n}function S0(t,e,n){const i=t[e]||{},s=null!=i.i?i.i:null!=i.f?i.f:n;return"number"==typeof s?s:parseInt(s,10)}function x0(t){switch("string"==typeof t&&(t=YZ[t]),t){case YZ.DT_FLOAT:case YZ.DT_HALF:return"float32";case YZ.DT_INT32:case YZ.DT_INT64:case YZ.DT_INT8:case YZ.DT_UINT8:return"int32";case YZ.DT_BOOL:return"bool";case YZ.DT_DOUBLE:return"float32";case YZ.DT_STRING:return"string";case YZ.DT_COMPLEX64:case YZ.DT_COMPLEX128:return"complex64";default:return null}}function R0(t,e,n){const i=t[e];return i&&i.func?i.func.name:n}function A0(t,e,n){const i=t[e];return i&&i.type?x0(i.type):n}function O0(t,e,n){const i=t[e];return i&&i.list&&i.list.type?i.list.type.map((t=>x0(t))):n}function M0(t){if(!t.unknownRank)return null!=t.dim?t.dim.map((t=>"number"==typeof t.size?t.size:parseInt(t.size,10))):[]}function C0(t,e,n){const i=t[e];return i&&i.shape?M0(i.shape):n}function N0(t,e,n){const i=t[e];return i?((i.list.f&&i.list.f.length?i.list.f:i.list.i)||[]).map((t=>"number"==typeof t?t:parseInt(t,10))):n}function k0(t,e,n,i=!1){const s=t[e];return s&&s.list&&s.list.s?s.list.s.map((t=>b0(t,i))):n}function D0(t,e,n){const i=t[e];return i&&i.list&&i.list.shape?i.list.shape.map((t=>M0(t))):n}function L0(t,e,n){const i=t[e];return i&&i.list&&i.list.b?i.list.b:n} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class F0{constructor(t,e,n){this.node=t,this.tensorMap=e,this.context=n,this.inputs=[],this.attrs={},this.inputs=t.inputNames.map((t=>this.getInput(t))),null!=t.rawAttrs&&(this.attrs=Object.keys(t.rawAttrs).reduce(((t,e)=>(t[e]=this.getAttr(e),t)),{}))}getInput(t){return qZ(t,this.tensorMap,this.context)}getAttr(t,e){const n=this.node.rawAttrs[t];if(null!=n.tensor)return qZ(t,this.tensorMap,this.context);if(null!=n.i||null!=n.f)return S0(this.node.rawAttrs,t,e);if(null!=n.s)return v0(this.node.rawAttrs,t,e);if(null!=n.b)return w0(this.node.rawAttrs,t,e);if(null!=n.shape)return C0(this.node.rawAttrs,t,e);if(null!=n.type)return A0(this.node.rawAttrs,t,e);if(null!=n.list){if(null!=n.list.i||null!=n.list.f)return N0(this.node.rawAttrs,t,e);if(null!=n.list.s)return k0(this.node.rawAttrs,t,e);if(null!=n.list.shape)return D0(this.node.rawAttrs,t,e);if(null!=n.list.b)return L0(this.node.rawAttrs,t,e);if(null!=n.list.type)return O0(this.node.rawAttrs,t,e)}return e}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function P0(t,e,n=""){if("number"!=typeof t&&"number"!=typeof e){yA(t.length===e.length,(()=>n+` Shapes ${t} and ${e} must match`));for(let i=0;in+` Shapes ${t} and ${e} must match`))}}}function $0(t){return"number"!=typeof t&&!t.some((t=>t<0))}function B0(t,e,n){let i=V0(t,n);const s=!$0(i);if(s&&0===e.length)throw new Error(`Tried to calculate elements of an empty list with non-fully-defined elementShape: ${i}`);if(s&&e.forEach((t=>{i=V0(t.shape,i)})),!$0(i))throw new Error(`Non-fully-defined elementShape: ${i}`);return i}function V0(t,e){if("number"==typeof t)return e;if("number"==typeof e)return t;if(t.length!==e.length)throw new Error(`Incompatible ranks during merge: ${t} vs. ${e}`);const n=[];for(let i=0;i=0&&r>=0&&s!==r)throw new Error(`Incompatible shape during merge: ${t} vs. ${e}`);n[i]=s>=0?s:r}return n} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class U0{constructor(t,e,n,i,s,r,a){this.name=t,this.dtype=e,this.maxSize=n,this.elementShape=i,this.identicalElementShapes=s,this.dynamicSize=r,this.clearAfterRead=a,this.tensors=[],this.closed_=!1,this.idTensor=nF(0),SD(this.idTensor)}get id(){return this.idTensor.id}get closed(){return this.closed_}clearAndClose(t){this.tensors.forEach((e=>{null!=t&&t.has(e.tensor.id)||e.tensor.dispose()})),this.tensors=[],this.closed_=!0,this.idTensor.dispose()}size(){return this.tensors.length}read(t){if(this.closed_)throw new Error(`TensorArray ${this.name} has already been closed.`);if(t<0||t>=this.size())throw new Error(`Tried to read from index ${t}, but array size is: ${this.size()}`);const e=this.tensors[t];if(e.cleared)throw new Error(`TensorArray ${this.name}: Could not read index ${t} twice because it was cleared after a previous read (perhaps try setting clear_after_read = false?).`);return this.clearAfterRead&&(e.cleared=!0),e.read=!0,e.tensor}readMany(t){return t.map((t=>this.read(t)))}write(t,e){if(this.closed_)throw new Error(`TensorArray ${this.name} has already been closed.`);if(t<0||!this.dynamicSize&&t>=this.maxSize)throw new Error(`Tried to write to index ${t}, but array is not resizeable and size is: ${this.maxSize}`);const n=this.tensors[t]||{};if(e.dtype!==this.dtype)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${t},\n because the value dtype is ${e.dtype}, but TensorArray dtype is ${this.dtype}.`);if(0!==this.size()||null!=this.elementShape&&0!==this.elementShape.length||(this.elementShape=e.shape),P0(this.elementShape,e.shape,`TensorArray ${this.name}: Could not write to TensorArray index ${t}.`),n.read)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${t}, because it has already been read.`);if(n.written)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${t}, because it has already been written.`);n.tensor=e,SD(e),n.written=!0,this.tensors[t]=n}writeMany(t,e){if(t.length!==e.length)throw new Error(`TensorArray ${this.name}: could not write multiple tensors,because the index size: ${t.length} is not the same as tensors size: ${e.length}.`);t.forEach(((t,n)=>this.write(t,e[n])))}gather(t,e){if(e&&e!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but gather requested dtype ${e}`);if(t)t=t.slice(0,this.size());else{t=[];for(let e=0;e=this.maxSize)throw new Error(`Max index must be < array size (${n} vs. ${this.maxSize})`);this.writeMany(t,CU(e,0))}split(t,e){if(e.dtype!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${e.dtype}`);let n=0;const i=t.map((t=>(n+=t,n)));if(n!==e.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: ${e.shape}`);if(!this.dynamicSize&&t.length!==this.maxSize)throw new Error(`TensorArray's size is not equal to the size of lengths (${this.maxSize} vs. ${t.length}), and the TensorArray is not marked as dynamically resizeable`);const s=0===n?0:e.size/n,r=[];vD((()=>{e=E$(e,[1,n,s]);for(let n=0;n{if(n!==t.dtype)throw new Error(`Invalid data types; op elements ${n}, but list elements ${t.dtype}`);P0(e,t.shape,"TensorList shape mismatch: "),SD(t)})),this.idTensor=nF(0),this.maxNumElements=i,SD(this.idTensor)}copy(){return new Y0([...this.tensors],this.elementShape,this.elementDtype)}clearAndClose(t){this.tensors.forEach((e=>{null!=t&&t.has(e.id)||e.dispose()})),this.tensors.length=0,this.idTensor.dispose()}size(){return this.tensors.length}stack(t,e,n=-1){if(e!==this.elementDtype)throw new Error(`Invalid data types; op elements ${e}, 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.`);P0(t,this.elementShape,"TensorList shape mismatch: ");const i=B0(this.elementShape,this.tensors,t);return vD((()=>{const t=this.tensors.map((t=>E$(t,i)));return _U(t,0)}))}popBack(t,e){if(e!==this.elementDtype)throw new Error(`Invalid data types; op elements ${e}, but list elements ${this.elementDtype}`);if(0===this.size())throw new Error("Trying to pop from an empty list.");const n=B0(this.elementShape,this.tensors,t),i=this.tensors.pop();return i.kept=!1,P0(i.shape,t,"TensorList shape mismatch: "),E$(i,n)}pushBack(t){if(t.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t.dtype}, but list elements ${this.elementDtype}`);if(P0(t.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw new Error("Trying to push element into a full list.");SD(t),this.tensors.push(t)}resize(t){if(t<0)throw new Error(`TensorListResize expects size to be non-negative. Got: ${t}`);if(-1!==this.maxNumElements&&t>this.maxNumElements)throw new Error(`TensorListResize input size ${t} is greater maxNumElement ${this.maxNumElements}.`);const e=new Y0([],this.elementShape,this.elementDtype,this.maxNumElements);e.tensors.length=t;for(let n=0;nthis.tensors.length)throw new Error(`Trying to access element ${t} in a list with ${this.tensors.length} elements.`);if(null==this.tensors[t])throw new Error(`element at index ${t} is null.`);P0(this.tensors[t].shape,e,"TensorList shape mismatch: ");const i=B0(this.elementShape,this.tensors,e);return E$(this.tensors[t],i)}setItem(t,e){if(e.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${this.elementDtype}`);if(t<0||-1!==this.maxNumElements&&t>=this.maxNumElements)throw new Error(`Trying to set element ${t} in a list with max ${this.maxNumElements} elements.`);P0(this.elementShape,e.shape,"TensorList shape mismatch: "),SD(e),null!=this.tensors[t]&&(this.tensors[t].kept=!1),this.tensors[t]=e}gather(t,e,n){if(e!==this.elementDtype)throw new Error(`Invalid data types; op elements ${e}, but list elements ${this.elementDtype}`);P0(this.elementShape,n,"TensorList shape mismatch: "),t=t.slice(0,this.size());const i=B0(this.elementShape,this.tensors,n);return 0===t.length?cD([],[0].concat(i)):vD((()=>{const e=t.map((t=>E$(this.tensors[t],i)));return _U(e,0)}))}concat(t,e){if(t&&t!==this.elementDtype)throw new Error(`TensorList dtype is ${this.elementDtype} but concat requested dtype ${t}`);P0(this.elementShape,e,"TensorList shape mismatch: ");const n=B0(this.elementShape,this.tensors,e);return 0===this.size()?cD([],[0].concat(n)):vD((()=>{const t=this.tensors.map((t=>E$(t,n)));return w$(t,0)}))}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const G0=async(t,e,n)=>{switch(t.op){case"If":case"StatelessIf":{const i=jZ("thenBranch",t,e,n),s=jZ("elseBranch",t,e,n),r=jZ("cond",t,e,n),a=jZ("args",t,e,n);return(await r.data())[0]?n.functionMap[i].executeFunctionAsync(a,n.tensorArrayMap,n.tensorListMap):n.functionMap[s].executeFunctionAsync(a,n.tensorArrayMap,n.tensorListMap)}case"While":case"StatelessWhile":{const i=jZ("body",t,e,n),s=jZ("cond",t,e,n),r=jZ("args",t,e,n),a=await n.functionMap[s].executeFunctionAsync(r,n.tensorArrayMap,n.tensorListMap),o=r.map((t=>t.id));let l=await a[0].data();a.forEach((t=>{t.kept||-1!==o.indexOf(t.id)||t.dispose()}));let u=r;for(;l[0];){const t=u;u=await n.functionMap[i].executeFunctionAsync(u,n.tensorArrayMap,n.tensorListMap);const e=u.map((t=>t.id));t.forEach((t=>{t.kept||-1!==o.indexOf(t.id)||-1!==e.indexOf(t.id)||t.dispose()}));const r=await n.functionMap[s].executeFunctionAsync(u,n.tensorArrayMap,n.tensorListMap);l=await r[0].data(),r.forEach((t=>{t.kept||-1!==o.indexOf(t.id)||-1!==e.indexOf(t.id)||t.dispose()}))}return u}case"LoopCond":return[e0(jZ("pred",t,e,n))];case"Switch":{const i=jZ("pred",t,e,n);let s=jZ("data",t,e,n);return s.kept||(s=e0(s)),(await i.data())[0]?[void 0,s]:[s,void 0]}case"Merge":{const i=t.inputNames.find((t=>void 0!==qZ(t,e,n)));if(i){return[e0(qZ(i,e,n))]}return}case"Enter":{const i=jZ("frameName",t,e,n),s=jZ("tensor",t,e,n);return n.enterFrame(i),[e0(s)]}case"Exit":{const i=jZ("tensor",t,e,n);return n.exitFrame(),[e0(i)]}case"NextIteration":{const i=jZ("tensor",t,e,n);return n.nextIteration(),[e0(i)]}case"TensorArrayV3":{const i=jZ("size",t,e,n),s=jZ("dtype",t,e,n),r=jZ("elementShape",t,e,n),a=jZ("dynamicSize",t,e,n),o=jZ("clearAfterRead",t,e,n),l=jZ("identicalElementShapes",t,e,n),u=jZ("name",t,e,n),h=new U0(u,s,i,r,l,a,o);return n.addTensorArray(h),[h.idTensor,nF(1)]}case"TensorArrayWriteV3":{const i=jZ("tensorArrayId",t,e,n),s=jZ("index",t,e,n),r=jZ("tensor",t,e,n),a=n.getTensorArray(i.id);return a.write(s,r),[a.idTensor]}case"TensorArrayReadV3":{const i=jZ("tensorArrayId",t,e,n),s=jZ("index",t,e,n);return[n.getTensorArray(i.id).read(s)]}case"TensorArrayGatherV3":{const i=jZ("tensorArrayId",t,e,n),s=jZ("indices",t,e,n),r=jZ("dtype",t,e,n);return[n.getTensorArray(i.id).gather(s,r)]}case"TensorArrayScatterV3":{const i=jZ("tensorArrayId",t,e,n),s=jZ("indices",t,e,n),r=jZ("tensor",t,e,n),a=n.getTensorArray(i.id);return a.scatter(s,r),[a.idTensor]}case"TensorArrayConcatV3":{const i=jZ("tensorArrayId",t,e,n),s=n.getTensorArray(i.id),r=jZ("dtype",t,e,n);return[s.concat(r)]}case"TensorArraySplitV3":{const i=jZ("tensorArrayId",t,e,n),s=jZ("tensor",t,e,n),r=jZ("lengths",t,e,n),a=n.getTensorArray(i.id);return a.split(r,s),[a.idTensor]}case"TensorArraySizeV3":{const i=jZ("tensorArrayId",t,e,n);return[nF(n.getTensorArray(i.id).size(),"int32")]}case"TensorArrayCloseV3":{const i=jZ("tensorArrayId",t,e,n),s=n.getTensorArray(i.id);return s.clearAndClose(),[s.idTensor]}case"TensorListSetItem":{const i=jZ("tensorListId",t,e,n),s=jZ("index",t,e,n),r=jZ("tensor",t,e,n),a=n.getTensorList(i.id);return a.setItem(s,r),[a.idTensor]}case"TensorListGetItem":{const i=jZ("tensorListId",t,e,n),s=jZ("index",t,e,n),r=jZ("elementShape",t,e,n),a=jZ("elementDType",t,e,n);return[n.getTensorList(i.id).getItem(s,r,a)]}case"TensorListScatterV2":case"TensorListScatter":{const i=jZ("indices",t,e,n),s=function(t,e,n,i){if(e.length!==t.shape[0])throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${e.length} vs. ${t.shape[0]}`);const s=Math.max(...e);if(null!=i&&-1!==i&&s>=i)throw new Error(`Max index must be < array size (${s} vs. ${i})`);const r=new Y0([],n,t.dtype,i),a=CU(t,0);return e.forEach(((t,e)=>{r.setItem(t,a[e])})),r}(jZ("tensor",t,e,n),i,jZ("elementShape",t,e,n),jZ("numElements",t,e,n));return n.addTensorList(s),[s.idTensor]}case"TensorListReserve":case"EmptyTensorList":{const i=jZ("elementShape",t,e,n),s=jZ("elementDType",t,e,n);let r;r="TensorListReserve"===t.op?"numElements":"maxNumElements";const a=jZ(r,t,e,n),o=function(t,e,n,i){return new Y0([],t,e,i)}(i,s,0,"TensorListReserve"===t.op?-1:a);return n.addTensorList(o),[o.idTensor]}case"TensorListGather":{const i=jZ("tensorListId",t,e,n),s=jZ("indices",t,e,n),r=jZ("elementShape",t,e,n),a=jZ("elementDType",t,e,n);return[n.getTensorList(i.id).gather(s,a,r)]}case"TensorListStack":{const i=jZ("tensorListId",t,e,n),s=jZ("elementShape",t,e,n),r=jZ("elementDType",t,e,n),a=jZ("numElements",t,e,n);return[n.getTensorList(i.id).stack(s,r,a)]}case"TensorListFromTensor":{const i=function(t,e,n){const i=t.dtype;if(t.shape.length<1)throw new Error(`Tensor must be at least a vector, but saw shape: ${t.shape}`);if(t.dtype!==n)throw new Error(`Invalid data types; op elements ${t.dtype}, but list elements ${n}`);P0(t.shape.slice(1),e,"TensorList shape mismatch: ");const s=CU(t);return new Y0(s,e,i)}(jZ("tensor",t,e,n),jZ("elementShape",t,e,n),jZ("elementDType",t,e,n));return n.addTensorList(i),[i.idTensor]}case"TensorListConcat":case"TensorListConcatV2":{const i=jZ("tensorListId",t,e,n),s=n.getTensorList(i.id),r=jZ("dtype",t,e,n),a=jZ("elementShape",t,e,n);return[s.concat(r,a)]}case"TensorListPushBack":{const i=jZ("tensorListId",t,e,n),s=jZ("tensor",t,e,n),r=n.getTensorList(i.id);return r.pushBack(s),[r.idTensor]}case"TensorListPopBack":{const i=jZ("tensorListId",t,e,n),s=jZ("elementShape",t,e,n),r=jZ("elementDType",t,e,n);return[n.getTensorList(i.id).popBack(s,r)]}case"TensorListSplit":{const i=jZ("tensor",t,e,n),s=jZ("elementShape",t,e,n),r=function(t,e,n){let i=0;const s=e.map((t=>(i+=t,i)));if(i!==t.shape[0])throw new Error(`Expected sum of lengths to be equal to\n tensor.shape[0], but sum of lengths is\n ${i}, and tensor's shape is: ${t.shape}`);const r=V0(t.shape.slice(1),n),a=0===i?0:t.size/i,o=vD((()=>{const n=[];t=E$(t,[1,i,a]);for(let i=0;it.dispose())),this.tensorMap.clear(),this.handle.dispose()}size(){return this.tensorMap.size}tensorSize(){return nF(this.size(),"int32")}async import(t,e){this.checkKeyAndValueTensor(t,e);const n=await t.data();return this.tensorMap.forEach((t=>t.dispose())),this.tensorMap.clear(),vD((()=>{const t=CU(e),i=n.length,s=t.length;yA(i===s,(()=>`The number of elements doesn't match, keys has ${i} elements, the values has ${s} elements.`));for(let e=0;e{const t=[];for(let i=0;i{switch(t.category){case"arithmetic":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"BiasAdd":case"AddV2":case"Add":return[i.add(jZ("a",t,e,n),jZ("b",t,e,n))];case"AddN":return[i.addN(jZ("tensors",t,e,n))];case"FloorMod":case"Mod":return[i.mod(jZ("a",t,e,n),jZ("b",t,e,n))];case"Mul":return[i.mul(jZ("a",t,e,n),jZ("b",t,e,n))];case"RealDiv":case"Div":return[i.div(jZ("a",t,e,n),jZ("b",t,e,n))];case"DivNoNan":return[i.divNoNan(jZ("a",t,e,n),jZ("b",t,e,n))];case"FloorDiv":return[i.floorDiv(jZ("a",t,e,n),jZ("b",t,e,n))];case"Sub":return[i.sub(jZ("a",t,e,n),jZ("b",t,e,n))];case"Minimum":return[i.minimum(jZ("a",t,e,n),jZ("b",t,e,n))];case"Maximum":return[i.maximum(jZ("a",t,e,n),jZ("b",t,e,n))];case"Pow":return[i.pow(jZ("a",t,e,n),jZ("b",t,e,n))];case"SquaredDifference":return[i.squaredDifference(jZ("a",t,e,n),jZ("b",t,e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"basic_math":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"Abs":case"ComplexAbs":return[i.abs(jZ("x",t,e,n))];case"Acos":return[i.acos(jZ("x",t,e,n))];case"Acosh":return[i.acosh(jZ("x",t,e,n))];case"Asin":return[i.asin(jZ("x",t,e,n))];case"Asinh":return[i.asinh(jZ("x",t,e,n))];case"Atan":return[i.atan(jZ("x",t,e,n))];case"Atan2":return[i.atan2(jZ("x",t,e,n),jZ("y",t,e,n))];case"Atanh":return[i.atanh(jZ("x",t,e,n))];case"Ceil":return[i.ceil(jZ("x",t,e,n))];case"Complex":return[i.complex(jZ("real",t,e,n),jZ("imag",t,e,n))];case"Cos":return[i.cos(jZ("x",t,e,n))];case"Cosh":return[i.cosh(jZ("x",t,e,n))];case"Elu":return[i.elu(jZ("x",t,e,n))];case"Erf":return[i.erf(jZ("x",t,e,n))];case"Exp":return[i.exp(jZ("x",t,e,n))];case"Expm1":return[i.expm1(jZ("x",t,e,n))];case"Floor":return[i.floor(jZ("x",t,e,n))];case"Log":return[i.log(jZ("x",t,e,n))];case"Log1p":return[i.log1p(jZ("x",t,e,n))];case"Imag":return[i.imag(jZ("x",t,e,n))];case"Neg":return[i.neg(jZ("x",t,e,n))];case"Reciprocal":return[i.reciprocal(jZ("x",t,e,n))];case"Real":return[i.real(jZ("x",t,e,n))];case"Relu":return[i.relu(jZ("x",t,e,n))];case"Round":return[i.round(jZ("x",t,e,n))];case"Selu":return[i.selu(jZ("x",t,e,n))];case"Sigmoid":return[i.sigmoid(jZ("x",t,e,n))];case"Sin":return[i.sin(jZ("x",t,e,n))];case"Sign":return[i.sign(jZ("x",t,e,n))];case"Sinh":return[i.sinh(jZ("x",t,e,n))];case"Softplus":return[i.softplus(jZ("x",t,e,n))];case"Sqrt":return[i.sqrt(jZ("x",t,e,n))];case"Square":return[i.square(jZ("x",t,e,n))];case"Tanh":return[i.tanh(jZ("x",t,e,n))];case"Tan":return[i.tan(jZ("x",t,e,n))];case"ClipByValue":return[i.clipByValue(jZ("x",t,e,n),jZ("clipValueMin",t,e,n),jZ("clipValueMax",t,e,n))];case"Relu6":return[i.relu6(jZ("x",t,e,n))];case"Rsqrt":return[i.rsqrt(qZ(t.inputNames[0],e,n))];case"LeakyRelu":return[i.leakyRelu(jZ("x",t,e,n),jZ("alpha",t,e,n))];case"Prelu":return[i.prelu(jZ("x",t,e,n),jZ("alpha",t,e,n))];case"IsNan":return[i.isNaN(qZ(t.inputNames[0],e,n))];case"IsInf":return[i.isInf(qZ(t.inputNames[0],e,n))];case"IsFinite":return[i.isFinite(qZ(t.inputNames[0],e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"control":return G0(t,e,n);case"convolution":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"Conv1D":{const s=jZ("stride",t,e,n),r=jZ("pad",t,e,n),a=jZ("dataFormat",t,e,n).toUpperCase(),o=jZ("dilation",t,e,n);return[i.conv1d(jZ("x",t,e,n),jZ("filter",t,e,n),s,r,a,o)]}case"Conv2D":{const s=jZ("strides",t,e,n),r=t0(t,e,n),a=jZ("dataFormat",t,e,n).toUpperCase(),o=jZ("dilations",t,e,n);return[i.conv2d(jZ("x",t,e,n),jZ("filter",t,e,n),[s[1],s[2]],r,a,[o[1],o[2]])]}case"_FusedConv2D":{const{stride:s,pad:r,dataFormat:a,dilations:o,biasArg:l,preluArg:u,activationFunc:h,leakyreluAlpha:p}=H0(t,e,n);return[i.fused.conv2d({x:jZ("x",t,e,n),filter:jZ("filter",t,e,n),strides:[s[1],s[2]],pad:r,dataFormat:a,dilations:[o[1],o[2]],bias:l,activation:h,preluActivationWeights:u,leakyreluAlpha:p})]}case"FusedDepthwiseConv2dNative":{const{stride:s,pad:r,dataFormat:a,dilations:o,biasArg:l,preluArg:u,activationFunc:h,leakyreluAlpha:p}=H0(t,e,n);return[i.fused.depthwiseConv2d({x:jZ("x",t,e,n),filter:jZ("filter",t,e,n),strides:[s[1],s[2]],pad:r,dataFormat:a,dilations:[o[1],o[2]],bias:l,activation:h,preluActivationWeights:u,leakyreluAlpha:p})]}case"Conv2DBackpropInput":case"Conv2dTranspose":{const s=jZ("outputShape",t,e,n),r=jZ("strides",t,e,n),a=t0(t,e,n);return[i.conv2dTranspose(jZ("x",t,e,n),jZ("filter",t,e,n),s,[r[1],r[2]],a)]}case"DepthwiseConv2dNative":case"DepthwiseConv2d":{const s=jZ("strides",t,e,n),r=t0(t,e,n),a=jZ("dilations",t,e,n),o=jZ("dataFormat",t,e,n).toUpperCase();return[i.depthwiseConv2d(jZ("input",t,e,n),jZ("filter",t,e,n),[s[1],s[2]],r,o,[a[1],a[2]])]}case"Conv3D":{const s=jZ("strides",t,e,n),r=jZ("pad",t,e,n),a=jZ("dataFormat",t,e,n).toUpperCase(),o=jZ("dilations",t,e,n);return[i.conv3d(jZ("x",t,e,n),jZ("filter",t,e,n),[s[1],s[2],s[3]],r,a,[o[1],o[2],o[3]])]}case"AvgPool":{const s=jZ("strides",t,e,n),r=jZ("pad",t,e,n),a=jZ("kernelSize",t,e,n);return[i.avgPool(jZ("x",t,e,n),[a[1],a[2]],[s[1],s[2]],r)]}case"MaxPool":{const s=jZ("strides",t,e,n),r=jZ("pad",t,e,n),a=jZ("kernelSize",t,e,n);return[i.maxPool(jZ("x",t,e,n),[a[1],a[2]],[s[1],s[2]],r)]}case"MaxPoolWithArgmax":{const s=jZ("strides",t,e,n),r=jZ("pad",t,e,n),a=jZ("kernelSize",t,e,n),o=jZ("includeBatchInIndex",t,e,n),{result:l,indexes:u}=i.maxPoolWithArgmax(jZ("x",t,e,n),[a[1],a[2]],[s[1],s[2]],r,o);return[l,u]}case"AvgPool3D":{const s=jZ("strides",t,e,n),r=jZ("pad",t,e,n),a=jZ("kernelSize",t,e,n);return[i.avgPool3d(jZ("x",t,e,n),[a[1],a[2],a[3]],[s[1],s[2],s[3]],r)]}case"MaxPool3D":{const s=jZ("strides",t,e,n),r=jZ("pad",t,e,n),a=jZ("kernelSize",t,e,n);return[i.maxPool3d(jZ("x",t,e,n),[a[1],a[2],a[3]],[s[1],s[2],s[3]],r)]}case"Dilation2D":{const s=jZ("strides",t,e,n),r=jZ("pad",t,e,n),a=jZ("dilations",t,e,n),o=s[1],l=s[2],u=a[1],h=a[2];return[i.dilation2d(jZ("x",t,e,n),jZ("filter",t,e,n),[o,l],r,[u,h],"NHWC")]}default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"creation":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"Fill":{const s=jZ("shape",t,e,n),r=jZ("dtype",t,e,n),a=jZ("value",t,e,n);return[i.fill(s,a,r)]}case"LinSpace":{const s=jZ("start",t,e,n),r=jZ("stop",t,e,n),a=jZ("num",t,e,n);return[i.linspace(s,r,a)]}case"Multinomial":{const s=jZ("logits",t,e,n),r=jZ("numSamples",t,e,n),a=jZ("seed",t,e,n);return[i.multinomial(s,r,a)]}case"OneHot":{const s=jZ("indices",t,e,n),r=jZ("depth",t,e,n),a=jZ("onValue",t,e,n),o=jZ("offValue",t,e,n),l=jZ("dtype",t,e,n);return[i.oneHot(s,r,a,o,l)]}case"Ones":return[i.ones(jZ("shape",t,e,n),jZ("dtype",t,e,n))];case"OnesLike":return[i.onesLike(jZ("x",t,e,n))];case"RandomStandardNormal":return[i.randomStandardNormal(jZ("shape",t,e,n),jZ("dtype",t,e,n),jZ("seed",t,e,n))];case"RandomUniform":return[i.randomUniform(jZ("shape",t,e,n),jZ("minval",t,e,n),jZ("maxval",t,e,n),jZ("dtype",t,e,n))];case"RandomUniformInt":return[i.randomUniformInt(jZ("shape",t,e,n),jZ("minval",t,e,n),jZ("maxval",t,e,n),jZ("seed",t,e,n))];case"Range":{const s=jZ("start",t,e,n),r=jZ("stop",t,e,n),a=jZ("step",t,e,n);return[i.range(s,r,a,jZ("dtype",t,e,n))]}case"TruncatedNormal":{const s=jZ("shape",t,e,n),r=jZ("mean",t,e,n),a=jZ("stdDev",t,e,n),o=jZ("seed",t,e,n);return[i.truncatedNormal(s,r,a,jZ("dtype",t,e,n),o)]}case"Zeros":return[i.zeros(jZ("shape",t,e,n),jZ("dtype",t,e,n))];case"ZerosLike":return[i.zerosLike(jZ("x",t,e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"dynamic":return(async(t,e,n,i,s=zt)=>{switch(t.op){case"NonMaxSuppressionV5":{const{boxes:i,scores:r,maxOutputSize:a,iouThreshold:o,scoreThreshold:l,softNmsSigma:u}=W0(t,e,n),h=await s.image.nonMaxSuppressionWithScoreAsync(i,r,a,o,l,u);return[h.selectedIndices,h.selectedScores]}case"NonMaxSuppressionV4":{const{boxes:i,scores:r,maxOutputSize:a,iouThreshold:o,scoreThreshold:l}=W0(t,e,n),u=jZ("padToMaxOutputSize",t,e,n),h=await s.image.nonMaxSuppressionPaddedAsync(i,r,a,o,l,u);return[h.selectedIndices,h.validOutputs]}case"NonMaxSuppressionV3":case"NonMaxSuppressionV2":{const{boxes:i,scores:r,maxOutputSize:a,iouThreshold:o,scoreThreshold:l}=W0(t,e,n);return[await s.image.nonMaxSuppressionAsync(i,r,a,o,l)]}case"Where":{const i=s.cast(jZ("condition",t,e,n),"bool"),r=[await s.whereAsync(i)];return i.dispose(),r}case"ListDiff":return s.setdiff1dAsync(jZ("x",t,e,n),jZ("y",t,e,n));default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n);case"evaluation":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"LowerBound":{const s=jZ("sortedSequence",t,e,n),r=jZ("values",t,e,n);return[i.lowerBound(s,r)]}case"TopKV2":{const s=jZ("x",t,e,n),r=jZ("k",t,e,n),a=jZ("sorted",t,e,n),o=i.topk(s,r,a);return[o.values,o.indices]}case"UpperBound":{const s=jZ("sortedSequence",t,e,n),r=jZ("values",t,e,n);return[i.upperBound(s,r)]}case"Unique":{const s=jZ("x",t,e,n),r=i.unique(s);return[r.values,r.indices]}case"UniqueV2":{const s=jZ("x",t,e,n),r=jZ("axis",t,e,n),a=i.unique(s,r);return[a.values,a.indices]}default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"image":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"ResizeBilinear":{const s=jZ("images",t,e,n),r=jZ("size",t,e,n),a=jZ("alignCorners",t,e,n),o=jZ("halfPixelCenters",t,e,n);return[i.image.resizeBilinear(s,[r[0],r[1]],a,o)]}case"ResizeNearestNeighbor":{const s=jZ("images",t,e,n),r=jZ("size",t,e,n),a=jZ("alignCorners",t,e,n),o=jZ("halfPixelCenters",t,e,n);return[i.image.resizeNearestNeighbor(s,[r[0],r[1]],a,o)]}case"CropAndResize":{const s=jZ("image",t,e,n),r=jZ("boxes",t,e,n),a=jZ("boxInd",t,e,n),o=jZ("cropSize",t,e,n),l=jZ("method",t,e,n),u=jZ("extrapolationValue",t,e,n);return[i.image.cropAndResize(s,r,a,o,l,u)]}case"ImageProjectiveTransformV3":{const s=jZ("images",t,e,n),r=jZ("transforms",t,e,n),a=jZ("outputShape",t,e,n),o=jZ("fillValue",t,e,n),l=jZ("interpolation",t,e,n),u=jZ("fillMode",t,e,n);return[i.image.transform(s,r,l.toLowerCase(),u.toLowerCase(),o,a)]}default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"graph":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"Const":return e[t.name];case"PlaceholderWithDefault":const s=jZ("default",t,e,n);return[qZ(t.name,e,n)||s];case"Placeholder":return[qZ(t.name,e,n)];case"Identity":case"StopGradient":case"FakeQuantWithMinMaxVars":case"Snapshot":return[e0(jZ("x",t,e,n))];case"IdentityN":return jZ("x",t,e,n).map((t=>e0(t)));case"Shape":return[i.tensor1d(jZ("x",t,e,n).shape,"int32")];case"ShapeN":return jZ("x",t,e,n).map((t=>i.tensor1d(t.shape)));case"Size":return[i.scalar(jZ("x",t,e,n).size,"int32")];case"Rank":return[i.scalar(jZ("x",t,e,n).rank,"int32")];case"NoOp":return[i.scalar(1)];case"Print":const r=jZ("x",t,e,n),a=jZ("data",t,e,n),o=jZ("message",t,e,n),l=jZ("summarize",t,e,n);console.warn("The graph has a tf.print() operation,usually used for debugging, which slows down performance."),console.log(o);for(let t=0;t((t,e,n,i=zt)=>{switch(t.op){case"Equal":return[i.equal(jZ("a",t,e,n),jZ("b",t,e,n))];case"NotEqual":return[i.notEqual(jZ("a",t,e,n),jZ("b",t,e,n))];case"Greater":return[i.greater(jZ("a",t,e,n),jZ("b",t,e,n))];case"GreaterEqual":return[i.greaterEqual(jZ("a",t,e,n),jZ("b",t,e,n))];case"Less":return[i.less(jZ("a",t,e,n),jZ("b",t,e,n))];case"LessEqual":return[i.lessEqual(jZ("a",t,e,n),jZ("b",t,e,n))];case"LogicalAnd":return[i.logicalAnd(jZ("a",t,e,n),jZ("b",t,e,n))];case"LogicalNot":return[i.logicalNot(jZ("a",t,e,n))];case"LogicalOr":return[i.logicalOr(jZ("a",t,e,n),jZ("b",t,e,n))];case"Select":case"SelectV2":return[i.where(jZ("condition",t,e,n),jZ("a",t,e,n),jZ("b",t,e,n))];case"BitwiseAnd":return[i.bitwiseAnd(jZ("a",t,e,n),jZ("b",t,e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"matrices":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"BatchMatMul":case"BatchMatMulV2":case"MatMul":return[i.matMul(jZ("a",t,e,n),jZ("b",t,e,n),jZ("transposeA",t,e,n),jZ("transposeB",t,e,n))];case"Einsum":return[i.einsum(jZ("equation",t,e,n),...jZ("tensors",t,e,n))];case"Transpose":return[i.transpose(jZ("x",t,e,n),jZ("perm",t,e,n))];case"_FusedMatMul":const[s,r]=jZ("fusedOps",t,e,n),a="biasadd"===s,o="prelu"===r,l=jZ("numArgs",t,e,n),u=jZ("leakyreluAlpha",t,e,n);if(a){if(o&&2!==l)throw new Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!o&&1!==l)throw new Error("Fused MatMul with BiasAdd must have one extra argument: bias.")}const[h,p]=jZ("args",t,e,n);return[i.fused.matMul({a:jZ("a",t,e,n),b:jZ("b",t,e,n),transposeA:jZ("transposeA",t,e,n),transposeB:jZ("transposeB",t,e,n),bias:h,activation:r,preluActivationWeights:p,leakyreluAlpha:u})];case"MatrixBandPart":return[i.linalg.bandPart(jZ("a",t,e,n),jZ("numLower",t,e,n),jZ("numUpper",t,e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"normalization":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"EuclideanNorm":return[i.euclideanNorm(jZ("x",t,e,n),jZ("axis",t,e,n),jZ("keepDims",t,e,n))];case"FusedBatchNorm":case"FusedBatchNormV2":case"FusedBatchNormV3":return[i.batchNorm(jZ("x",t,e,n),jZ("mean",t,e,n),jZ("variance",t,e,n),jZ("offset",t,e,n),jZ("scale",t,e,n),jZ("epsilon",t,e,n))];case"LRN":return[i.localResponseNormalization(jZ("x",t,e,n),jZ("radius",t,e,n),jZ("bias",t,e,n),jZ("alpha",t,e,n),jZ("beta",t,e,n))];case"Softmax":return[i.softmax(jZ("x",t,e,n))];case"LogSoftmax":return[i.logSoftmax(jZ("x",t,e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"ragged":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"RaggedGather":{const{outputNestedSplits:s,outputDenseValues:r}=i.raggedGather(jZ("paramsNestedSplits",t,e,n),jZ("paramsDenseValues",t,e,n),jZ("indices",t,e,n),jZ("outputRaggedRank",t,e,n));return s.concat(r)}case"RaggedRange":{const{rtNestedSplits:s,rtDenseValues:r}=i.raggedRange(jZ("starts",t,e,n),jZ("limits",t,e,n),jZ("splits",t,e,n));return[s,r]}case"RaggedTensorToTensor":return[i.raggedTensorToTensor(jZ("shape",t,e,n),jZ("values",t,e,n),jZ("defaultValue",t,e,n),jZ("rowPartitionTensors",t,e,n),jZ("rowPartitionTypes",t,e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"reduction":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"Max":{const s=jZ("axis",t,e,n),r=jZ("keepDims",t,e,n);return[i.max(jZ("x",t,e,n),s,r)]}case"Mean":{const s=jZ("axis",t,e,n),r=jZ("keepDims",t,e,n);return[i.mean(jZ("x",t,e,n),s,r)]}case"Min":{const s=jZ("axis",t,e,n),r=jZ("keepDims",t,e,n);return[i.min(jZ("x",t,e,n),s,r)]}case"Sum":{const s=jZ("axis",t,e,n),r=jZ("keepDims",t,e,n);return[i.sum(jZ("x",t,e,n),s,r)]}case"All":{const s=jZ("axis",t,e,n),r=jZ("keepDims",t,e,n);return[i.all(jZ("x",t,e,n),s,r)]}case"Any":{const s=jZ("axis",t,e,n),r=jZ("keepDims",t,e,n);return[i.any(jZ("x",t,e,n),s,r)]}case"ArgMax":{const s=jZ("axis",t,e,n);return[i.argMax(jZ("x",t,e,n),s)]}case"ArgMin":{const s=jZ("axis",t,e,n);return[i.argMin(jZ("x",t,e,n),s)]}case"Prod":{const s=jZ("axis",t,e,n),r=jZ("keepDims",t,e,n);return[i.prod(jZ("x",t,e,n),s,r)]}case"Cumprod":{const s=jZ("axis",t,e,n),r=jZ("exclusive",t,e,n),a=jZ("reverse",t,e,n);return[i.cumprod(jZ("x",t,e,n),s,r,a)]}case"Cumsum":{const s=jZ("axis",t,e,n),r=jZ("exclusive",t,e,n),a=jZ("reverse",t,e,n);return[i.cumsum(jZ("x",t,e,n),s,r,a)]}case"Bincount":const s=jZ("x",t,e,n),r=jZ("weights",t,e,n),a=jZ("size",t,e,n);return[i.bincount(s,r,a)];case"DenseBincount":{const s=jZ("x",t,e,n),r=jZ("weights",t,e,n),a=jZ("size",t,e,n),o=jZ("binaryOutput",t,e,n);return[i.denseBincount(s,r,a,o)]}default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"slice_join":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"ConcatV2":case"Concat":{const s=jZ("n",t,e,n),r=jZ("axis",t,e,n);let a=jZ("tensors",t,e,n);return a=a.slice(0,s),[i.concat(a,r)]}case"Gather":{const s=jZ("x",t,e,n),r=jZ("indices",t,e,n);return[i.gather(s,i.cast(r,"int32"),0)]}case"GatherV2":{const s=jZ("axis",t,e,n),r=jZ("batchDims",t,e,n),a=jZ("x",t,e,n),o=jZ("indices",t,e,n);return[i.gather(a,i.cast(o,"int32"),s,r)]}case"Reverse":{const s=jZ("dims",t,e,n),r=[];for(let t=0;t{const s=jZ("axis",t,e,n),r=jZ("tensors",t,e,n),a=r[0].shape,o=i.squeeze(r[0]).shape,l=r.map((t=>{const e=SA(t.shape,a);if(!e&&!SA(i.squeeze(t).shape,o))throw new Error("the input tensors shape does not match");return e?t:i.reshape(t,a)}));return[i.stack(l,s)]}));case"Unpack":{const s=jZ("axis",t,e,n),r=jZ("tensor",t,e,n);return i.unstack(r,s)}case"Tile":{const s=jZ("reps",t,e,n);return[i.tile(jZ("x",t,e,n),s)]}case"Split":case"SplitV":{const s=jZ("axis",t,e,n),r=jZ("numOrSizeSplits",t,e,n),a=jZ("x",t,e,n);return i.split(a,r,s)}case"ScatterNd":{const s=jZ("indices",t,e,n),r=jZ("values",t,e,n),a=jZ("shape",t,e,n);return[i.scatterND(s,r,a)]}case"GatherNd":{const s=jZ("x",t,e,n),r=jZ("indices",t,e,n);return[i.gatherND(s,r)]}case"SparseToDense":{const s=jZ("sparseIndices",t,e,n),r=jZ("outputShape",t,e,n),a=jZ("sparseValues",t,e,n),o=jZ("defaultValue",t,e,n);return[i.sparseToDense(s,a,r,a.dtype===o.dtype?o:i.cast(o,a.dtype))]}case"TensorScatterUpdate":{const s=jZ("indices",t,e,n),r=jZ("values",t,e,n),a=jZ("tensor",t,e,n);return[i.tensorScatterUpdate(a,s,r)]}default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"sparse":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"SparseFillEmptyRows":{const{outputIndices:s,outputValues:r,emptyRowIndicator:a,reverseIndexMap:o}=i.sparse.sparseFillEmptyRows(jZ("indices",t,e,n),jZ("values",t,e,n),jZ("denseShape",t,e,n),jZ("defaultValue",t,e,n));return[s,r,a,o]}case"SparseReshape":{const{outputIndices:s,outputShape:r}=i.sparse.sparseReshape(jZ("inputIndices",t,e,n),jZ("inputShape",t,e,n),jZ("newShape",t,e,n));return[s,r]}case"SparseSegmentMean":return[i.sparse.sparseSegmentMean(jZ("data",t,e,n),jZ("indices",t,e,n),jZ("segmentIds",t,e,n))];case"SparseSegmentSum":return[i.sparse.sparseSegmentSum(jZ("data",t,e,n),jZ("indices",t,e,n),jZ("segmentIds",t,e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"spectral":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"FFT":return[i.fft(jZ("x",t,e,n))];case"IFFT":return[i.ifft(jZ("x",t,e,n))];case"RFFT":return[i.rfft(jZ("x",t,e,n))];case"IRFFT":return[i.irfft(jZ("x",t,e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"string":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"StaticRegexReplace":return[i.string.staticRegexReplace(jZ("input",t,e,n),jZ("pattern",t,e,n),jZ("rewrite",t,e,n),jZ("replaceGlobal",t,e,n))];case"StringNGrams":{const{nGrams:s,nGramsSplits:r}=i.string.stringNGrams(jZ("data",t,e,n),jZ("dataSplits",t,e,n),jZ("separator",t,e,n),jZ("nGramWidths",t,e,n),jZ("leftPad",t,e,n),jZ("rightPad",t,e,n),jZ("padWidth",t,e,n),jZ("preserveShortSequences",t,e,n));return[s,r]}case"StringSplit":{const{indices:s,values:r,shape:a}=i.string.stringSplit(jZ("input",t,e,n),jZ("delimiter",t,e,n),jZ("skipEmpty",t,e,n));return[s,r,a]}case"StringToHashBucketFast":return[i.string.stringToHashBucketFast(jZ("input",t,e,n),jZ("numBuckets",t,e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"transformation":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"Cast":return[i.cast(jZ("x",t,e,n),jZ("dtype",t,e,n))];case"ExpandDims":{const s=jZ("axis",t,e,n);return[i.expandDims(jZ("x",t,e,n),s)]}case"Squeeze":{const s=jZ("axis",t,e,n);return[i.squeeze(jZ("x",t,e,n),s)]}case"Reshape":return[i.reshape(jZ("x",t,e,n),jZ("shape",t,e,n))];case"EnsureShape":return[i.ensureShape(jZ("x",t,e,n),jZ("shape",t,e,n))];case"MirrorPad":return[i.mirrorPad(jZ("x",t,e,n),jZ("padding",t,e,n),jZ("mode",t,e,n))];case"PadV2":case"Pad":return[i.pad(jZ("x",t,e,n),jZ("padding",t,e,n),jZ("constantValue",t,e,n))];case"SpaceToBatchND":{const s=jZ("blockShape",t,e,n),r=jZ("paddings",t,e,n);return[i.spaceToBatchND(jZ("x",t,e,n),s,r)]}case"BatchToSpaceND":{const s=jZ("blockShape",t,e,n),r=jZ("crops",t,e,n);return[i.batchToSpaceND(jZ("x",t,e,n),s,r)]}case"DepthToSpace":{const s=jZ("blockSize",t,e,n),r=jZ("dataFormat",t,e,n).toUpperCase();return[i.depthToSpace(jZ("x",t,e,n),s,r)]}case"BroadcastTo":return[i.broadcastTo(jZ("x",t,e,n),jZ("shape",t,e,n))];case"BroadcastArgs":return[i.broadcastArgs(jZ("s0",t,e,n),jZ("s1",t,e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"hash_table":return(async(t,e,n,i)=>{switch(t.op){case"HashTable":case"HashTableV2":{const s=i.getHashTableHandleByName(t.name);if(null!=s)return[s];{const s=jZ("keyDType",t,e,n),r=jZ("valueDType",t,e,n),a=new z0(s,r);return i.addHashTable(t.name,a),[a.handle]}}case"InitializeTable":case"InitializeTableV2":case"LookupTableImport":case"LookupTableImportV2":{const s=jZ("tableHandle",t,e,n,i),r=jZ("keys",t,e,n),a=jZ("values",t,e,n),o=i.getHashTableById(s.id);return[await o.import(r,a)]}case"LookupTableFind":case"LookupTableFindV2":{const s=jZ("tableHandle",t,e,n,i),r=jZ("keys",t,e,n),a=jZ("defaultValue",t,e,n),o=i.getHashTableById(s.id);return[await o.find(r,a)]}case"LookupTableSize":case"LookupTableSizeV2":{const s=jZ("tableHandle",t,e,n,i);return[i.getHashTableById(s.id).tensorSize()]}default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n,i);case"custom":const r=zZ(t.op);if(r&&r.customExecutor)return r.customExecutor(new F0(t,e,n));throw TypeError(`Custom op ${t.op} is not registered.`);default:throw TypeError(`Unknown op '${t.op}'. File an issue at https://github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp()`)}})(t,e,n);return sO(r)?r.then((t=>[].concat(t))):[].concat(r)}class j0{constructor(t={},e={},n={},i={},s){this.weightMap=t,this.tensorArrayMap=e,this.tensorListMap=n,this.functionMap=i,this.parseNodeNameCache=s,this.rootContext={id:0,frameName:"",iterationId:0},this.contexts=[this.rootContext],this.lastId=0,this.generateCurrentContextIds()}newFrame(t,e){return{id:t,frameName:e,iterationId:0}}set currentContext(t){this.contexts!==t&&(this.contexts=t,this.generateCurrentContextIds())}get currentContext(){return this.contexts}get currentContextId(){return this._currentContextIds[0]}get currentContextIds(){return this._currentContextIds}generateCurrentContextIds(){const t=[];for(let e=0;e0===t.id&&0===t.iterationId?"":`${t.frameName}-${t.iterationId}`)).join("/"):""}enterFrame(t){this.contexts&&(this.lastId++,this.contexts=this.contexts.slice(),this.contexts.push(this.newFrame(this.lastId,t)),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 t=Object.assign({},this.contexts[this.contexts.length-1]);t.iterationId+=1,t.id=this.lastId,this.contexts.splice(-1,1,t),this._currentContextIds.splice(0,1,this.contextIdforContexts(this.contexts))}}getWeight(t){return this.weightMap[t]}addTensorArray(t){this.tensorArrayMap[t.id]=t}getTensorArray(t){return this.tensorArrayMap[t]}addTensorList(t){this.tensorListMap[t.id]=t}getTensorList(t){return this.tensorListMap[t]}dispose(t){for(const e in this.tensorArrayMap)this.tensorArrayMap[e].clearAndClose(t);for(const e in this.tensorListMap)this.tensorListMap[e].clearAndClose(t)}} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function q0(t,e,n,i){const s=new Set,r=[];let a=null,o=null;const l=new Set,u=new Set(Object.keys(t).map((t=>ZZ(t)[0])));i=i||[];const h=new Set(i.map((t=>ZZ(t.name)[0]))),p=[...e];for(;p.length>0;){const t=p.pop();(e1(t)||n1(t)||i1(t))&&null==a&&(a=t,o=a.children.map((t=>t.name)).filter((t=>s.has(t)))),s.add(t.name),null==n[t.name]&&(u.has(t.name)||h.has(t.name)||(0!==t.inputs.length?t.inputs.forEach((t=>{l.has(t.name)||(l.add(t.name),p.push(t))})):r.push(t.name)))}return{inputs:t,outputs:e,usedNodes:s,missingInputs:r,dynamicNode:a,syncInputs:o}}function K0(t,e){const{usedNodes:n,inputs:i}=e,s=Object.keys(i).map((t=>ZZ(t)[0])).map((e=>t.nodes[e])),r=t.initNodes||[],a=t=>n.has("string"==typeof t?t:t.name);function o(t){return[...new Map(t.map((t=>[t.name,t]))).values()]}const l=o([...s,...t.weights,...r]).filter(a),u=o([...l,...Object.values(t.nodes)]).filter(a),h=new Map(u.map((t=>[t.name,t]))),p={};for(const t of u){p[t.name]=p[t.name]||0;for(const e of t.children)a(e)||(p[e.name]=Number.POSITIVE_INFINITY),p[e.name]=(p[e.name]||0)+1}const c=Object.entries(p).filter((([,t])=>0===t)).map((([t])=>t)),d=[...c];for(;c.length>0;){const t=c.pop(),e=h.get(t);for(const t of e.children.filter(a))0==--p[t.name]&&(d.push(t.name),c.push(t.name))}const f=function(t,e){const n=new Map(t.map((t=>[t.name,t]))),i=e.map((t=>t.name)),s=new Set(i);for(;i.length>0;){const t=i.pop(),e=n.get(t);for(const t of e.children)n.has(t.name)&&!s.has(t.name)&&(s.add(t.name),i.push(t.name))}const r=t.filter((t=>s.has(t.name)));return r}(d.map((t=>h.get(t))),l);return function(t,e){const n=new Map(t.map(((t,e)=>[t.name,e]))),i=new Set(e.map((t=>t.name))),s=t=>i.has("string"==typeof t?t:t.name),r=new Set(t.map((t=>t.name))),a=t=>r.has("string"==typeof t?t:t.name);for(const e of t){for(const t of e.children.filter(a)){if(!n.has(t.name))throw new Q0(`Child ${t.name} of node ${e.name} is unreachable.`);if(n.get(e.name)>n.get(t.name))throw new Q0(`Node ${e.name} is scheduled to run after its child ${t.name}.`)}if(!s(e))for(const t of e.inputs){if(!n.has(t.name))throw new Q0(`Input ${t.name} of node ${e.name} is unreachable.`);if(n.get(t.name)>n.get(e.name))throw new Q0(`Node ${e.name} is scheduled to run before its input ${t.name}.`)}}}(f,l),f}class Q0 extends Error{constructor(t){super(`NodesExecutionOrderError: ${t}`)}}const J0=new Set(["Switch","Merge","Enter","Exit","NextIteration","StatelessIf","StatelessWhile","if","While"]),Z0=new Set(["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"]),t1=new Set(["HashTable","HashTableV2","LookupTableImport","LookupTableImportV2","LookupTableFind","LookupTableFindV2","LookupTableSize","LookupTableSizeV2"]);function e1(t){return J0.has(t.op)}function n1(t){return Z0.has(t.op)}function i1(t){return t1.has(t.op)} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class s1{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(t){const e=Object.keys(t).map((e=>t[e].map((t=>t.id))));this._weightIds=[].concat(...e),this._weightMap=t}set resourceManager(t){this._resourceManager=t}get inputs(){return this._inputs.map((t=>({name:t.name,shape:t.attrParams.shape?t.attrParams.shape.value:void 0,dtype:t.attrParams.dtype?t.attrParams.dtype.value:void 0})))}get outputs(){return this._outputs.map((t=>({name:t.name,shape:t.attrParams.shape?t.attrParams.shape.value:void 0,dtype:t.attrParams.dtype?t.attrParams.dtype.value:void 0})))}get inputNodes(){return this._inputs.map((t=>t.signatureKey||t.name))}get outputNodes(){return this._outputs.map((t=>{const e=t.signatureKey||t.name;return t.defaultOutput?`${e}:${t.defaultOutput}`:e}))}get functions(){return Object.keys(this._functions).reduce(((t,e)=>(t[e]=this._functions[e].signature,t)),{})}constructor(t,e){this.graph=t,this.parent=e,this.compiledMap=new Map,this.parseNodeNameCache=new Map,this._weightMap={},this.SEPARATOR=",",this._functions={},this._functionExecutorMap={},this.keepIntermediateTensors=!1,this._outputs=t.outputs,this._inputs=t.inputs,this._initNodes=t.initNodes,this._signature=t.signature,this._functions=t.functions,null!=t.functions&&Object.keys(t.functions).forEach((e=>{this._functionExecutorMap[e]=new s1(t.functions[e],this)}))}getCompilationKey(t,e){const n=t.map((t=>t.name)).sort(),i=e.map((t=>t.name)).sort();return n.join(this.SEPARATOR)+"--"+i.join(this.SEPARATOR)}compile(t,e){const n=q0(t,e,this.weightMap,this._initNodes),{missingInputs:i,dynamicNode:s,syncInputs:r}=n;if(null!=s)throw new Error(`This execution contains the node '${s.name}', which has the dynamic op '${s.op}'. Please use model.executeAsync() instead. Alternatively, to avoid the dynamic ops, specify the inputs [${r}]`);if(i.length>0){const n=e.map((t=>t.name)),s=Object.keys(t);throw new Error(`Cannot compute the outputs [${n}] from the provided inputs [${s}]. Missing the following inputs: [${i}]`)}const a=K0(this.graph,n),o=function(t){const e=new Map(t.map(((t,e)=>[t.name,e]))),n=Number.MAX_SAFE_INTEGER,i=t.map(((t,e)=>e1(t)?n:e)),s=t=>{const n=i[e.get(t.name)];return null==n?-1:n},r=t.map(((t,e)=>t.children.map(s).reduce(((t,e)=>Math.max(t,e)),i[e]))),a=new Map;for(let e=0;ethis.cloneAndKeepTensor(t)));return e}cloneTensorMap(t){return Object.fromEntries(Object.entries(t).map((([t,e])=>[t,this.cloneTensorList(e)])))}execute(t,e){this.disposeIntermediateTensors(),t=this.mapInputs(t);const n=Object.keys(t).sort();this.checkInputs(t),this.checkInputShapeAndType(t),e=this.mapOutputs(e),this.checkOutputs(e);const i=n.map((t=>this.graph.nodes[ZZ(t)[0]])),s=e.map((t=>ZZ(t)[0])),r=new Set(s);let a=s.map((t=>this.graph.nodes[t]));0===a.length&&(a=this._outputs);const o=this.getCompilationKey(i,a);let l=this.compiledMap.get(o);null==l&&(l=this.compile(t,a),this.compiledMap.set(o,l));try{this.keepIntermediateTensors=lO().getBool("KEEP_INTERMEDIATE_TENSORS")}catch(t){this.keepIntermediateTensors=!1,console.warn(t.message)}const u={},h={};return vD((()=>{const n=new j0(this.weightMap,u,h,this.functionExecutorMap,this.parseNodeNameCache),i=Object.assign({},this.weightMap);this.keepIntermediateTensors&&(this.clonedTensorsMap=this.cloneTensorMap(this.weightMap)),Object.keys(t).forEach((e=>{const[s,r]=ZZ(e,n),a=[];a[r]=t[e],i[s]=a,this.keepIntermediateTensors&&(this.clonedTensorsMap[s]=this.cloneTensorList(a))}));const s=this.getFrozenTensorIds(i),{orderedNodes:a,nodeLiveUntilMap:o}=l;for(const t of a){if(i[t.name])continue;const e=X0(t,i,n,this._resourceManager);if(sO(e))throw new Error(`The execution of the op '${t.op}' returned a promise. Please use model.executeAsync() instead.`);i[t.name]=e,this.keepIntermediateTensors&&(this.clonedTensorsMap[t.name]=this.cloneTensorList(e)),this.checkTensorForDisposalWithNodeLiveUntilInfo(t,i,n,s,r,o.get(t.name))}return null==this.parent&&n.dispose(s),e.map((t=>qZ(t,i,n)))}))}getFrozenTensorIds(t){const e=[].concat.apply([],Object.keys(t).map((e=>t[e])).map((t=>t.map((t=>t.id)))));return new Set(e)}checkTensorForDisposal(t,e,n,i,s,r,a){if(!e1(e)&&!r.has(t)){for(const i of n[t])null!=i&&(a[i.id]=(a[i.id]||0)+e.children.length);for(const t of e.inputs){if(e1(t))continue;const e=KZ(t.name,n,i);if(null!=e)for(const t of e){if(!t||t.kept||s.has(t.id))continue;const e=a[t.id];1===e?(t.dispose(),delete a[t.id]):null!=e&&a[t.id]--}}}}checkTensorForDisposalWithNodeLiveUntilInfo(t,e,n,i,s,r){function a(t){return e1(t)||s.has(t.name)}if(!e1(t)&&null!=r)for(const t of r){if(a(t))continue;const s=KZ(t.name,e,n);for(const t of s)!t||t.kept||i.has(t.id)||t.dispose()}}async executeAsync(t,e){return this._executeAsync(t,e)}disposeIntermediateTensors(){this.clonedTensorsMap&&(Object.values(this.clonedTensorsMap).forEach((t=>{for(const e of t)e&&!e.isDisposed&&e.dispose()})),this.clonedTensorsMap=null)}getIntermediateTensors(){return this.clonedTensorsMap}async _executeAsync(t,e,n=!1,i={},s={}){this.disposeIntermediateTensors(),n||(t=this.mapInputs(t),this.checkInputs(t),this.checkInputShapeAndType(t),e=this.mapOutputs(e),this.checkOutputs(e));try{this.keepIntermediateTensors=lO().getBool("KEEP_INTERMEDIATE_TENSORS")}catch(t){this.keepIntermediateTensors=!1,console.warn(t.message)}const r=new j0(this.weightMap,i,s,this.functionExecutorMap,this.parseNodeNameCache);this.keepIntermediateTensors&&(this.clonedTensorsMap=this.cloneTensorMap(this.weightMap));const a=await this.executeWithControlFlow(t,r,e,n),o=e.map((t=>qZ(t,a,r))),l=o.map((t=>t.id)),u=Object.keys(t).map((e=>t[e].id)),h=new Set([...l,...u,...this.weightIds]);return Object.values(a).forEach((t=>{t.forEach((t=>{!t||t.isDisposed||h.has(t.id)||t.dispose()}))})),null==this.parent&&r.dispose(h),o}async executeFunctionAsync(t,e,n){const i=t.reduce(((t,e,n)=>(t[this.inputs[n].name]=e,t)),{});return this._executeAsync(i,this.outputNodes,!0,e,n)}async executeWithControlFlow(t,e,n,i){const s=Object.keys(t),r=s.map((t=>this.graph.nodes[ZZ(t)[0]])),a=n.map((t=>ZZ(t)[0])),o=new Set(a);let l=a.map((t=>this.graph.nodes[t]));0===l.length&&(l=this._outputs);const{usedNodes:u,missingInputs:h,dynamicNode:p,syncInputs:c}=q0(t,l,this.weightMap,this._initNodes),d=[...r,...this.graph.weights,...this._initNodes||[]].map((t=>({node:t,contexts:e.currentContext}))),f=Object.assign({},this.weightMap);Object.keys(t).forEach((e=>{const[n,i]=ZZ(e),s=[];s[i]=t[e],f[n]=s}));const m={},g=this.getFrozenTensorIds(f),_={};for(;d.length>0;){const t=this.processStack(r,d,e,f,_,g,o,m,u);await Promise.all(t)}null!=p||i||console.warn("This model execution did not contain any nodes with control flow or dynamic output shapes. You can use model.execute() instead.");const T=l.filter((t=>!e1(t)&&!qZ(t.name,f,e))).map((t=>t.name));if(T.length>0){let t="";throw null!=p&&(t=`Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs [${c}]`),new Error(`Cannot compute the outputs [${T}] from the provided inputs [${s}]. Consider providing the following inputs: [${h}]. ${t}`)}return f}processStack(t,e,n,i,s,r,a,o,l){const u=[];for(;e.length>0;){const t=e.pop();n.currentContext=t.contexts;let h="";if("Enter"===t.node.op&&jZ("isConstant",t.node,i,n)&&([h]=QZ(t.node.name,n)),null==i[t.node.name]){const p=X0(t.node,i,n,this._resourceManager);h||([h]=QZ(t.node.name,n));const c=n.currentContext;sO(p)?u.push(p.then((u=>(i[h]=u,this.keepIntermediateTensors&&(this.clonedTensorsMap[h]=this.cloneTensorList(u)),n.currentContext=c,this.checkTensorForDisposal(h,t.node,i,n,r,a,o),this.processChildNodes(t.node,e,n,i,s,l),u)))):(i[h]=p,this.keepIntermediateTensors&&(this.clonedTensorsMap[h]=this.cloneTensorList(p)),this.checkTensorForDisposal(h,t.node,i,n,r,a,o),this.processChildNodes(t.node,e,n,i,s,l))}else this.processChildNodes(t.node,e,n,i,s,l)}return u}processChildNodes(t,e,n,i,s,r){t.children.forEach((t=>{const[a]=QZ(t.name,n);!s[a]&&r.has(t.name)&&("Merge"===t.op?t.inputNames.some((t=>!!qZ(t,i,n)))&&(s[a]=!0,e.push({contexts:n.currentContext,node:t})):t.inputNames.every((t=>!!qZ(t,i,n)))&&(s[a]=!0,e.push({contexts:n.currentContext,node:t})))}))}dispose(){Object.keys(this.weightMap).forEach((t=>this.weightMap[t].forEach((t=>t.dispose()))))}checkInputShapeAndType(t){Object.keys(t).forEach((e=>{const n=t[e],[i]=ZZ(e),s=this.graph.nodes[i];if(s.attrParams.shape&&s.attrParams.shape.value){const t=s.attrParams.shape.value;yA(t.length===n.shape.length&&n.shape.every(((e,n)=>-1===t[n]||t[n]===e)),(()=>`The shape of dict['${s.name}'] provided in model.execute(dict) must be [${t}], but was [${n.shape}]`))}s.attrParams.dtype&&s.attrParams.dtype.value&&yA(n.dtype===s.attrParams.dtype.value,(()=>`The dtype of dict['${s.name}'] provided in model.execute(dict) must be ${s.attrParams.dtype.value}, but was ${n.dtype}`))}))}mapInputs(t){var e,n;const i={};for(const s in t){const r=null===(n=null===(e=this._signature)||void 0===e?void 0:e.inputs)||void 0===n?void 0:n[s];null!=r?i[r.name]=t[s]:i[s]=t[s]}return i}checkInputs(t){const e=Object.keys(t).filter((t=>{const[e]=ZZ(t);return null==this.graph.nodes[e]}));if(e.length>0)throw new Error(`The dict provided in model.execute(dict) has keys: [${e}] that are not part of graph`)}mapOutputs(t){return t.map((t=>{var e,n;const i=null===(n=null===(e=this._signature)||void 0===e?void 0:e.outputs)||void 0===n?void 0:n[t];return null!=i?i.name:t}),{})}checkOutputs(t){t.forEach((t=>{const[e]=ZZ(t);if(!this.graph.nodes[e])throw new Error(`The output '${t}' is not found in the graph`)}))}}class r1{constructor(t={},e={}){this.hashTableNameToHandle=t,this.hashTableMap=e}addHashTable(t,e){this.hashTableNameToHandle[t]=e.handle,this.hashTableMap[e.id]=e}getHashTableHandleByName(t){return this.hashTableNameToHandle[t]}getHashTableById(t){return this.hashTableMap[t]}dispose(){for(const t in this.hashTableMap)this.hashTableMap[t].clearAndClose(),delete this.hashTableMap[t];for(const t in this.hashTableNameToHandle)this.hashTableNameToHandle[t].dispose(),delete this.hashTableNameToHandle[t]}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const a1="?tfjs-format=file",o1="model.json";class l1{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}constructor(t,e={},n=ht){this.modelUrl=t,this.loadOptions=e,this.version="n/a",this.io=n,null==e&&(this.loadOptions={}),this.resourceManager=new r1}findIOHandler(){const t=this.modelUrl;if(null!=t.load)this.handler=t;else if(null!=this.loadOptions.requestInit)this.handler=this.io.browserHTTPRequest(t,this.loadOptions);else{const e=this.io.getLoadHandlers(t,this.loadOptions);if(0===e.length)e.push(this.io.browserHTTPRequest(t,this.loadOptions));else if(e.length>1)throw new Error(`Found more than one (${e.length}) load handlers for URL '${[t]}'`);this.handler=e[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 t=this.handler.load();return sO(t)?t.then((t=>null==t.getWeightStream?this.loadSync(t):this.loadStreaming(t))):this.loadSync(t)}loadSync(t){const e=this.io.decodeWeights(t.weightData,t.weightSpecs);return this.loadWithWeightMap(t,e)}async loadStreaming(t){if(null==t.getWeightStream)throw new Error("Model artifacts missing streamWeights function");const e=await GD(t.getWeightStream(),t.weightSpecs);return this.loadWithWeightMap(t,e)}loadWithWeightMap(t,e){this.artifacts=t;const n=this.artifacts.modelTopology;let i=this.artifacts.signature;if(null!=this.artifacts.userDefinedMetadata){const t=this.artifacts.userDefinedMetadata;null!=t.signature&&(i=t.signature),null!=t.structuredOutputKeys&&(this.structuredOutputKeys=t.structuredOutputKeys)}if(this.signature=i,this.version=`${n.versions.producer}.${n.versions.minConsumer}`,this.executor=new s1(E0.Instance.transformGraph(n,this.signature)),this.executor.weightMap=this.convertTensorMapToTensorsMap(e),this.executor.resourceManager=this.resourceManager,null!=t.modelInitializer&&null!=t.modelInitializer.node){const e=E0.Instance.transformGraph(t.modelInitializer);this.initializer=new s1(e),this.initializer.weightMap=this.executor.weightMap,this.initializer.resourceManager=this.resourceManager,this.initializerSignature=t.initializerSignature}return!0}async save(t,e){if("string"==typeof t){const e=this.io.getSaveHandlers(t);if(0===e.length)throw new Error(`Cannot find any save handlers for URL '${t}'`);if(e.length>1)throw new Error(`Found more than one (${e.length}) save handlers for URL '${t}'`);t=e[0]}if(null==t.save)throw new Error("GraphModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");return t.save(this.artifacts)}addStructuredOutputNames(t){if(this.structuredOutputKeys){const e={};return(t instanceof Ak?[t]:t).forEach(((t,n)=>e[this.structuredOutputKeys[n]]=t)),e}return t}predict(t,e){const n=this.execute(t,this.outputNodes);return this.addStructuredOutputNames(n)}async predictAsync(t,e){const n=await this.executeAsync(t,this.outputNodes);return this.addStructuredOutputNames(n)}normalizeInputs(t){var e;if(!(t instanceof Ak||Array.isArray(t))){const n=null===(e=this.signature)||void 0===e?void 0:e.inputs;if(null!=n)for(const e in n){const i=n[e];null!=i.resourceId&&(t[e]=this.resourceIdToCapturedInput[i.resourceId])}return t}t=Array.isArray(t)?t:[t];const n=Object.keys(this.resourceIdToCapturedInput).length;if(t.length+n!==this.inputNodes.length)throw new Error(`Input tensor count mismatch, the graph model has ${this.inputNodes.length-n} non-resource placeholders, while there are ${t.length} input tensors provided.`);let i=0;return this.inputNodes.reduce(((e,n)=>{var s,r,a;const o=null===(a=null===(r=null===(s=this.signature)||void 0===s?void 0:s.inputs)||void 0===r?void 0:r[n])||void 0===a?void 0:a.resourceId;return e[n]=null!=o?this.resourceIdToCapturedInput[o]:t[i++],e}),{})}normalizeOutputs(t){return t=t||this.outputNodes,Array.isArray(t)?t:[t]}executeInitializerGraph(){return null==this.initializer?[]:null==this.initializerSignature?this.initializer.execute({},[]):this.initializer.execute({},Object.keys(this.initializerSignature.outputs))}async executeInitializerGraphAsync(){return null==this.initializer?[]:null==this.initializerSignature?this.initializer.executeAsync({},[]):this.initializer.executeAsync({},Object.keys(this.initializerSignature.outputs))}setResourceIdToCapturedInput(t){if(this.resourceIdToCapturedInput={},this.initializerSignature){const e=this.initializerSignature.outputs,n=Object.keys(e);for(let i=0;i1?n:n[0]}async executeAsync(t,e){null==this.resourceIdToCapturedInput&&this.setResourceIdToCapturedInput(await this.executeInitializerGraphAsync()),t=this.normalizeInputs(t),e=this.normalizeOutputs(e);const n=await this.executor.executeAsync(t,e);return n.length>1?n:n[0]}getIntermediateTensors(){return this.executor.getIntermediateTensors()}disposeIntermediateTensors(){this.executor.disposeIntermediateTensors()}convertTensorMapToTensorsMap(t){return Object.keys(t).reduce(((e,n)=>(e[n]=[t[n]],e)),{})}dispose(){this.executor.dispose(),this.initializer&&(this.initializer.dispose(),this.resourceIdToCapturedInput&&wD(this.resourceIdToCapturedInput)),this.resourceManager.dispose()}}async function u1(t,e={},n=ht){if(null==t)throw new Error("modelUrl in loadGraphModel() cannot be null. Please provide a url or an IOHandler that loads the model");null==e&&(e={}),e.fromTFHub&&"string"==typeof t&&(t=function(t){t.endsWith("/")||(t+="/");return`${t}${o1}${a1}`}(t));const i=new l1(t,e,n);return await i.load(),i}function h1(t){if(null==t)throw new Error("modelUrl in loadGraphModelSync() cannot be null. Please provide model artifacts or an IOHandler that loads the model");let e;if(t instanceof Array){const[n,i]=t;if(!n)throw new Error("modelJSON must be the first element of the array");if(!(i&&i instanceof ArrayBuffer))throw new Error("An ArrayBuffer of weights must be the second element of the array");if(!("modelTopology"in n))throw new Error("Model JSON is missing 'modelTopology'");if(!("weightsManifest"in n))throw new Error("Model JSON is missing 'weightsManifest'");e=GF(KD(n,ZD(n.weightsManifest),i))}else if("load"in t)e=t;else{if(!("modelTopology"in t&&"weightSpecs"in t&&"weightData"in t))throw new Error("Unknown model format");e=GF(t)}const n=new l1(e);return n.load(),n} /** @license See the LICENSE file. */ const p1="4.22.0";function c1(t,e,n=new Map,i=new Set){if(null==t)return null;if("function"==typeof Blob&&t instanceof Blob)return t.slice();if(i.has(t))throw new Error("Circular references are not supported.");if(n.has(t))return n.get(t);const s=e(t);if(s.recurse&&null!==s.value)throw new Error("A deep map function may not return both a value and recurse=true.");if(s.recurse){if(_1(t)){const s=Array.isArray(t)?[]:{};i.add(t);for(const r in t){const a=c1(t[r],e,n,i);s[r]=a}return i.delete(t),t.__proto__&&(s.__proto__=t.__proto__),s}throw new Error(`Can't recurse into non-iterable type: ${t}`)}return n.set(t,s.value),s.value}function d1(t,e=m1){return f1(t,e)}function f1(t,e,n=new Set){const i=t[0];if(n.has(i))throw new Error("Circular references are not supported.");const s=e(t);if(s.recurse&&null!==s.value)throw new Error("A deep zip function may not return both a value and recurse=true.");if(s.recurse){if(_1(i)){const s=Array.isArray(i)?[]:{};n.add(i);for(const r in i){const i=f1(t.map((t=>t[r])),e,n);s[r]=i}return n.delete(i),s}throw new Error(`Can't recurse into non-iterable type: ${i}`)}return s.value}function m1(t){return null===t?null:_1(t[0])?{value:null,recurse:!0}:{value:t,recurse:!1}}async function g1(t,e){const n=new Map;c1(t,e,n);for(const t of Array.from(n.keys())){const e=n.get(t);if(sO(e)){const i=await e;n.set(t,i)}}return c1(t,e,n)}function _1(t){let e=!1;if(lO().get("IS_BROWSER"))e=t instanceof TextDecoder;else{const{StringDecoder:n}=__webpack_require__(551);e=t instanceof n}return null!=t&&!ArrayBuffer.isView(t)&&(Array.isArray(t)||"object"==typeof t&&!(t instanceof Ak)&&!(t instanceof Promise)&&!e)} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ function T1(t){ /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ return function(t,e){return c1(t,e)}(t,y1)}function y1(t){return t instanceof Ak?{value:t.clone(),recurse:!1}:_1(t)?{value:null,recurse:!0}:{value:t,recurse:!1}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ class I1{constructor(t){if(this.capacity=t,this.begin=0,this.end=0,null==t)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(t<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(t),this.doubledCapacity=2*t}wrap(t){for(;t<0;)t+=this.doubledCapacity;return t%this.doubledCapacity}get(t){if(t<0)throw new RangeError("Can't get item at a negative index.");return this.data[t%this.capacity]}set(t,e){if(t<0)throw new RangeError("Can't set item at a negative index.");this.data[t%this.capacity]=e}length(){let t=this.end-this.begin;return t<0&&(t=this.doubledCapacity+t),t}isFull(){return this.length()===this.capacity}isEmpty(){return 0===this.length()}push(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,t),this.end=this.wrap(this.end+1)}pushAll(t){for(const e of t)this.push(e)}pop(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);const t=this.get(this.end);return this.set(this.end,void 0),t}unshift(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,t)}shift(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");const t=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),t}shuffleExcise(t){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");const e=this.wrap(this.begin+t),n=this.get(e);return this.set(e,this.pop()),n}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ class E1 extends I1{constructor(){super(E1.INITIAL_CAPACITY)}isFull(){return!1}push(t){super.isFull()&&this.expand(),super.push(t)}unshift(t){super.isFull()&&this.expand(),super.unshift(t)}expand(){const t=2*this.capacity,e=new Array(t),n=this.length();for(let t=0;t!0===t))}rowMajorBatch(t,e=!0){return new C1(this,t,e)}columnMajorBatch(t,e=!0,n=m1){return this.rowMajorBatch(t,e).map((t=>d1(t,n)))}concatenate(t,e){return new $1(b1([this,t]),e)}take(t){return t<0||null==t?this:new M1(this,t)}skip(t){return t<0||null==t?this:new O1(this,t)}prefetch(t){return new U1(this,t)}shuffle(t,e){return new Y1(this,t,e)}serial(){return new A1(this)}}class x1 extends S1{constructor(t){super(),this.items=t,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 t=this.items[this.trav];return this.trav++,{value:T1(t),done:!1}}}class R1 extends S1{constructor(t){super(),this.nextFn=t}summary(){return"Function call"}async next(){try{return this.nextFn()}catch(t){throw t.message=`Error thrown while iterating through a dataset: ${t.message}`,t}}}class A1 extends S1{constructor(t){super(),this.upstream=t,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 O1 extends S1{constructor(t,e){super(),this.upstream=t,this.maxCount=e,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 C1 extends S1{constructor(t,e,n=!0){super(),this.upstream=t,this.batchSize=e,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 t=[];for(;t.length0?{value:t,done:!1}:{value:null,done:!0};t.push(e.value)}return{value:t,done:!1}}}class N1 extends S1{constructor(t,e){super(),this.upstream=t,this.predicate=e,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 t=await this.upstream.next();if(t.done||this.predicate(t.value))return t;wD(t.value)}}}class k1 extends S1{constructor(t,e){super(),this.upstream=t,this.transform=e}summary(){return`${this.upstream.summary()} -> Map`}async next(){const t=await this.upstream.next();if(t.done)return{value:null,done:!0};const e=Hk(t.value),n=this.transform(t.value),i=Hk(n);for(const t of e)Gk(t,i)||t.dispose();return{value:n,done:!1}}}class D1 extends S1{constructor(t,e){super(),this.upstream=t,this.handler=e,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(t){if(!this.handler(t))return{value:null,done:!0}}}}class L1 extends S1{constructor(t,e){super(),this.upstream=t,this.transform=e}summary(){return`${this.upstream.summary()} -> AsyncMap`}async next(){const t=await this.upstream.next();if(t.done)return{value:null,done:!0};const e=Hk(t.value),n=await this.transform(t.value),i=Hk(n);for(const t of e)Gk(t,i)||t.dispose();return{value:n,done:!1}}}class F1 extends S1{constructor(){super(),this.outputQueue=new E1,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 P1 extends F1{constructor(t,e){super(),this.upstream=t,this.transform=e}summary(){return`${this.upstream.summary()} -> Flatmap`}async pump(){const t=await this.upstream.next();if(t.done)return!1;const e=Hk(t.value),n=this.transform(t.value),i=Hk(n);this.outputQueue.pushAll(n);for(const t of e)Gk(t,i)||t.dispose();return!0}}class $1 extends S1{constructor(t,e){super(),this.baseErrorHandler=e,this.lastRead=null,this.iterator=null,this.moreIterators=t}summary(){return"TODO: fill in upstream of chained summaries -> Chained"}async next(){return this.lastRead=this.readFromChain(this.lastRead),this.lastRead}async readFromChain(t){if(await t,null==this.iterator){const t=await this.moreIterators.next();if(t.done)return{value:null,done:!0};this.iterator=t.value,null!=this.baseErrorHandler&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler))}const e=await this.iterator.next();return e.done?(this.iterator=null,this.readFromChain(t)):e}}var B1;!function(t){t[t.FAIL=0]="FAIL",t[t.SHORTEST=1]="SHORTEST",t[t.LONGEST=2]="LONGEST"}(B1||(B1={}));class V1 extends S1{constructor(t,e=B1.FAIL){super(),this.iterators=t,this.mismatchMode=e,this.count=0,this.currentPromise=null}summary(){return"{TODO: fill in upstream of zip summaries} -> Zip"}async nextState(t){await t;let e=0,n=0;const i=await g1(this.iterators,(function(t){if(t instanceof S1){return{value:t.next().then((t=>(e++,t.done&&n++,t.value))),recurse:!1}}return{value:null,recurse:!0}}));if(e===n)return{value:null,done:!0};if(n>0)switch(this.mismatchMode){case B1.FAIL:throw new Error(`Zipped streams should have the same length. Mismatched at element ${this.count}.`);case B1.SHORTEST:return{value:null,done:!0};case B1.LONGEST:}return this.count++,{value:i,done:!1}}async next(){return this.currentPromise=this.nextState(this.currentPromise),this.currentPromise}}class U1 extends S1{constructor(t,e){super(),this.upstream=t,this.bufferSize=e,this.buffer=new I1(e)}summary(){return`${this.upstream.summary()} -> Prefetch`}refill(){for(;!this.buffer.isFull();){const t=this.upstream.next();this.buffer.push(t)}}next(){return this.refill(),this.buffer.shift()}}class Y1 extends U1{constructor(t,e,n){super(t,e),this.upstream=t,this.windowSize=e,this.upstreamExhausted=!1,this.random=kV.alea(n||ok().toString()),this.lastRead=Promise.resolve({value:null,done:!1})}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}randomInt(t){return Math.floor(this.random()*t)}chooseIndex(){return this.randomInt(this.buffer.length())}async serialNext(){for(this.upstreamExhausted||this.refill();!this.buffer.isEmpty();){const t=this.chooseIndex(),e=await this.buffer.shuffleExcise(t);if(!e.done)return this.refill(),e;this.upstreamExhausted=!0}return{value:null,done:!0}}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ class G1{constructor(){this.size=null}batch(t,e=!0){const n=this;let i;return yA(t>0,(()=>`batchSize needs to be positive, but it is\n ${t}`)),i=this.size===1/0||null==this.size?this.size:e?Math.ceil(this.size/t):Math.floor(this.size/t),H1((async()=>(await n.iterator()).columnMajorBatch(t,e,X1)),i)}concatenate(t){const e=this;let n;return n=this.size===1/0||t.size===1/0?1/0:null!=this.size&&null!=t.size?this.size+t.size:null,H1((async()=>(await e.iterator()).concatenate(await t.iterator())),n)}filter(t){const e=this;let n;return n=this.size===1/0?1/0:null,H1((async()=>(await e.iterator()).filter((e=>vD((()=>t(e)))))),n)}async forEachAsync(t){return(await this.iterator()).forEachAsync(t)}map(t){const e=this;return H1((async()=>(await e.iterator()).map((e=>vD((()=>t(e)))))),this.size)}mapAsync(t){const e=this;return H1((async()=>(await e.iterator()).mapAsync(t)),this.size)}prefetch(t){if(null==t)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");const e=this;return H1((async()=>(await e.iterator()).prefetch(t)),this.size)}repeat(t){const e=this;let n;return n=null!=this.size&&t>0?this.size*t:0===t?0:null!=this.size&&(void 0===t||t<0)?1/0:null,H1((async()=>w1(v1((async()=>({value:await e.iterator(),done:!1}))).take(t))),n)}skip(t){const e=this;let n;return n=null!=this.size&&t>=0&&this.size>=t?this.size-t:null!=this.size&&(this.size(await e.iterator()).skip(t)),n)}shuffle(t,e,n=!0){if(null==t||t<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 i=this,s=kV.alea(e||ok().toString());return H1((async()=>{let e=s.int32();return n&&(e+=s.int32()),(await i.iterator()).shuffle(t,e.toString())}),this.size)}take(t){const e=this;let n;return n=null!=this.size&&this.size>t?t:null!=this.size&&this.size<=t?this.size:null,H1((async()=>(await e.iterator()).take(t)),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 H1(t,e=null){return new class extends G1{constructor(){super(...arguments),this.size=e}async iterator(){return t()}}}function W1(t){return H1((async()=>b1(t)),t.length)}function z1(t){if(!_1(t))throw new Error("The argument to zip() must be an object or array.");let e;if(Array.isArray(t))for(let n=0;nfunction(t,e=B1.FAIL){return new V1(t,e)}(await g1(t,(t=>{if(t instanceof G1)return{value:t.iterator(),recurse:!1};if(_1(t))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")})),B1.SHORTEST)),e)}function X1(t){if(null===t)return null;const e=t[0];if(null==(n=e)||null===(i=n)||"object"!=typeof i&&"function"!=typeof i||Array.isArray(n)||"object"==typeof n&&n instanceof Ak||pk(n)){return{value:function(t){if(0===t.length)throw new Error("Can't make a batch of zero elements.");return t[0]instanceof Ak?_U(t):cD(t)}(t),recurse:!1}}var n,i;return{value:null,recurse:!0}}G1.MAX_BUFFER_SIZE=1e4; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ class j1 extends G1{constructor(t){super(),this.input=t}async iterator(){return(await this.input.iterator()).decodeUTF8().split("\n").map((t=>(t.endsWith("\r")&&(t=t.slice(0,-1)),t)))}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ const q1='"',K1=Symbol("out"),Q1=Symbol("field"),J1=Symbol("quote"),Z1=Symbol("quoteafterquote"),t2=Symbol("quoteinquote");class e2 extends G1{async columnNames(){return this.columnNamesValidated||await this.setColumnNames(),this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames}async setColumnNames(){const t=await this.maybeReadHeaderLine();if(!this.fullColumnNames&&!t)throw new Error("Column names must be provided if there is no header line.");this.fullColumnNames&&t&&yA(t.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 ("+t.length.toString()+").")),this.fullColumnNames||(this.fullColumnNames=t);const e=this.fullColumnNames.reduce(((t,e)=>(t[e]=t[e]+1||1,t)),{}),n=Object.keys(e).filter((t=>e[t]>1));if(yA(0===n.length,(()=>"Duplicate column names found: "+n.toString())),this.columnConfigs)for(const t of Object.keys(this.columnConfigs)){if(-1===this.fullColumnNames.indexOf(t))throw new Error('The key "'+t+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").")}this.columnNamesValidated=!0}async maybeReadHeaderLine(){if(this.hasHeader){const t=await this.base.iterator(),e=await t.next();if(e.done)throw new Error("No data was found for CSV parsing.");const n=e.value;return this.parseRow(n,!1)}return null}constructor(t,e){super(),this.input=t,this.hasHeader=!0,this.fullColumnNames=null,this.columnNamesValidated=!1,this.columnConfigs=null,this.configuredColumnsOnly=!1,this.delimiter=",",this.delimWhitespace=!1,this.base=new j1(t),e||(e={}),this.hasHeader=!1!==e.hasHeader,this.fullColumnNames=e.columnNames,this.columnConfigs=e.columnConfigs,this.configuredColumnsOnly=e.configuredColumnsOnly,e.delimWhitespace?(yA(null==e.delimiter,(()=>"Delimiter should not be provided when delimWhitespace is true.")),this.delimWhitespace=!0,this.delimiter=" "):this.delimiter=e.delimiter?e.delimiter:","}async iterator(){this.columnNamesValidated||await this.setColumnNames();let t=await this.base.iterator();return this.hasHeader&&(t=t.skip(1)),t.map((t=>this.makeDataElement(t)))}makeDataElement(t){const e=this.parseRow(t),n={},i={};for(let s=0;s14||!Number.isInteger(e))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=t.numFramesPerSpectrogram||43,this.sampleRateHz=t.sampleRateHz,this.columnTruncateLength=t.columnTruncateLength||this.fftSize,this.audioTrackConstraints=t.audioTrackConstraints,this.smoothingTimeConstant=t.smoothingTimeConstant||0,this.includeSpectrogram=!1!==t.includeSpectrogram,this.includeWaveform=!0===t.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(t={}){if(!lO().get("IS_BROWSER"))throw new Error("microphone API is only supported in browser environment.");const e=new n2(t);return await e.start(),e}async start(){try{this.stream=await navigator.mediaDevices.getUserMedia({audio:null==this.audioTrackConstraints||this.audioTrackConstraints,video:!1})}catch(t){throw new Error(`Error thrown while initializing video stream: ${t.message}`)}if(!this.stream)throw new Error("Could not obtain audio from microphone.");const t=window.AudioContext||window.webkitAudioContext;if(this.audioContext=new t,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 e=this.audioContext.createMediaStreamSource(this.stream);this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=2*this.fftSize,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,e.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 t,e;const n=await this.getAudioData();if(this.includeSpectrogram){const e=this.flattenQueue(n.freqDataQueue);t=this.getTensorFromAudioDataArray(e,[this.numFrames,this.columnTruncateLength,1])}if(this.includeWaveform){const t=this.flattenQueue(n.timeDataQueue);e=this.getTensorFromAudioDataArray(t,[this.numFrames*this.fftSize,1])}return{value:{spectrogram:t,waveform:e},done:!1}}async capture(){return(await this.next()).value}async getAudioData(){const t=[],e=[];let n=0;return new Promise((i=>{const s=setInterval((()=>{this.includeSpectrogram&&(this.analyser.getFloatFrequencyData(this.freqData),this.freqData[0]===-1/0&&i({freqDataQueue:t,timeDataQueue:e}),t.push(this.freqData.slice(0,this.columnTruncateLength))),this.includeWaveform&&(this.analyser.getFloatTimeDomainData(this.timeData),e.push(this.timeData.slice())),++n===this.numFrames&&(clearInterval(s),i({freqDataQueue:t,timeDataQueue:e}))}),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(t){const e=t[0].length,n=new Float32Array(t.length*e);return t.forEach(((t,i)=>n.set(t,i*e))),n}getTensorFromAudioDataArray(t,e){const n=new Float32Array(bA(e));return n.set(t,n.length-t.length),cD(n,e)}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ class i2 extends S1{constructor(t,e){if(super(),this.webcamVideoElement=t,this.webcamConfig=e,this.isClosed=!0,this.resize=!1,this.needToResize())if(this.resize=!0,this.cropSize=[this.webcamConfig.resizeHeight,this.webcamConfig.resizeWidth],this.cropBoxInd=EU([0],"int32"),this.webcamConfig.centerCrop){const t=1*this.webcamConfig.resizeWidth/this.webcamVideoElement.width,e=1*this.webcamConfig.resizeHeight/this.webcamVideoElement.height,n=(1-t)/2,i=(1-e)/2,s=n+t,r=e+i;this.cropBox=bU([i,n,r,s],[1,4])}else this.cropBox=bU([0,0,1,1],[1,4])}summary(){return"webcam"}static async create(t,e={}){if(!lO().get("IS_BROWSER"))throw new Error("tf.data.webcam is only supported in browser environment.");if(!t){if(t=document.createElement("video"),!e.resizeWidth||!e.resizeHeight)throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");t.width=e.resizeWidth,t.height=e.resizeHeight}const n=new i2(t,e);return await n.start(),n}async start(){this.webcamConfig.facingMode&&yA("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(t){throw t.message=`Error thrown while initializing video stream: ${t.message}`,t}if(!this.stream)throw new Error("Could not obtain video from webcam.");try{this.webcamVideoElement.srcObject=this.stream}catch(t){console.log(t),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,new Promise((t=>{this.webcamVideoElement.onloadedmetadata=()=>{t()}}))}async next(){if(this.isClosed)return{value:null,done:!0};let t;try{t=lP(this.webcamVideoElement)}catch(t){throw new Error(`Error thrown converting video to pixels: ${JSON.stringify(t)}`)}if(!this.resize)return{value:t,done:!1};try{return{value:this.cropAndResizeFrame(t),done:!1}}catch(t){throw new Error(`Error thrown cropping the video: ${t.message}`)}finally{t.dispose()}}needToResize(){return!(!this.webcamConfig.resizeWidth||!this.webcamConfig.resizeHeight||this.webcamVideoElement.width===this.webcamConfig.resizeWidth&&this.webcamVideoElement.height===this.webcamConfig.resizeHeight)}cropAndResizeFrame(t){return vD((()=>{const e=OB(BL(t,"float32"),0);let n;n=tG.cropAndResize(e,this.cropBox,this.cropBoxInd,this.cropSize,"bilinear");const i=n.shape;return E$(n,i.slice(1))}))}async capture(){return(await this.next()).value}stop(){this.stream.getTracks().forEach((t=>t.stop()));try{this.webcamVideoElement.srcObject=null}catch(t){console.log(t),this.webcamVideoElement.src=null}this.isClosed=!0}toArray(){throw new Error("Can not convert infinite video stream to array.")}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ class s2{} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ class r2 extends S1{split(t){return new a2(this,t)}}class a2 extends r2{constructor(t,e){super(),this.upstream=t,this.impl=new o2(t,e)}summary(){return this.impl.summary()}async next(){return this.impl.next()}}class o2 extends F1{constructor(t,e){super(),this.upstream=t,this.separator=e,this.carryover=""}summary(){return`${this.upstream.summary()} -> Split('${this.separator}')`}async pump(){const t=await this.upstream.next();if(t.done)return""!==this.carryover&&(this.outputQueue.push(this.carryover),this.carryover="",!0);const e=t.value.split(this.separator);e[0]=this.carryover+e[0];for(const t of e.slice(0,-1))this.outputQueue.push(t);return this.carryover=e[e.length-1],!0}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ class l2 extends S1{decodeUTF8(){return new u2(this)}}class u2 extends r2{constructor(t){super(),this.upstream=t,this.impl=new h2(t)}summary(){return this.impl.summary()}async next(){return this.impl.next()}}class h2 extends F1{constructor(t){if(super(),this.upstream=t,lO().get("IS_BROWSER"))this.decoder=new TextDecoder("utf-8");else{const{StringDecoder:t}=__webpack_require__(4530);this.decoder=new t("utf8")}}summary(){return`${this.upstream.summary()} -> Utf8`}async pump(){const t=await this.upstream.next();let e,n;return!t.done&&(e=t.value,n=lO().get("IS_BROWSER")?this.decoder.decode(e,{stream:!0}):this.decoder.write(Buffer.from(e.buffer)),this.outputQueue.push(n),!0)}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ class p2 extends l2{constructor(t,e={}){super(),this.file=t,this.options=e,yA(t instanceof Uint8Array||!!lO().get("IS_BROWSER")&&(t instanceof File||t instanceof Blob),(()=>"FileChunkIterator only supports File, Blob and Uint8Array right now.")),this.offset=e.offset||0,this.chunkSize=e.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 t=new Promise(((t,e)=>{const n=this.offset+this.chunkSize;if(this.file instanceof Uint8Array)t(new Uint8Array(this.file.slice(this.offset,n)));else{const i=new FileReader;i.onload=n=>{let s=i.result;if(s instanceof ArrayBuffer&&(s=new Uint8Array(s)),!(s instanceof Uint8Array))return e(new TypeError("FileReader returned unknown type."));t(s)},i.onabort=t=>e(new Error("Aborted")),i.onerror=t=>e(new Error(t.type));const s=this.file.slice(this.offset,n);i.readAsArrayBuffer(s)}this.offset=n}));return{value:await t,done:!1}}}const c2=t=>({method:t.method,headers:t.headers,body:t.body,mode:t.mode,credentials:t.credentials,cache:t.cache,redirect:t.redirect,referrer:t.referrer,integrity:t.integrity}); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ function d2(t){return"string"==typeof t&&"file://"===t.slice(0,7)} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ class f2 extends s2{constructor(t,e={}){super(),this.input=t,this.options=e}async iterator(){if(d2(this.input)&&lO().get("IS_NODE")){const t=__webpack_require__(8108);this.input=t.readFileSync(this.input.slice(7))}return new p2(this.input,this.options)}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ class m2 extends s2{constructor(t,e={}){super(),this.url=t,this.fileOptions=e}async iterator(){return d2(this.url)?new f2(this.url,this.fileOptions).iterator(): /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ async function(t,e={},n){let i,s;"string"==typeof t?i=t:(i=t.url,s=c2(t));const r=await(n||lk)(i,s);if(r.ok){const t=new Uint8Array(await r.arrayBuffer());return new p2(t,e)}throw new Error(r.statusText)}(this.url,this.fileOptions)}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ function g2(t,e={}){return new e2(new m2(t),e)}function _2(t){const e=v1(t);return H1((async()=>e))}function T2(t){return H1((async()=>{const e=await t();return v1((()=>e.next()))}))}async function y2(t,e){return i2.create(t,e)}async function I2(t){return n2.create(t)} /** @license See the LICENSE file. */ const E2="4.22.0"; /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function b2(t,e){Array.isArray(t)||(t=[t]),t.forEach((t=>{null!=t&&yA("complex64"!==t.dtype,(()=>`${e} does not support complex64 tensors in the CPU backend.`))}))} /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const v2=DU;class w2 extends uA{nextDataId(){return w2.nextDataId++}constructor(){super(),this.blockSize=48,this.firstUse=!0,this.data=new lA(this,ID())}write(t,e,n){this.firstUse&&(this.firstUse=!1,lO().get("IS_NODE")&&CN("\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 i={id:this.nextDataId()};return this.data.set(i,{values:t,dtype:n,refCount:1}),i}makeTensorInfo(t,e,n){let i;if("string"===e&&null!=n&&n.length>0&&YA(n[0])){const s=n.map((t=>uk(t)));i=this.write(s,t,e)}else i=this.write(n,t,e);return{dataId:i,shape:t,dtype:e}}refCount(t){if(this.data.has(t)){return this.data.get(t).refCount}return 0}incRef(t){this.data.get(t).refCount++}decRef(t){if(this.data.has(t)){this.data.get(t).refCount--}}move(t,e,n,i,s){this.data.set(t,{values:e,dtype:i,refCount:s})}numDataIds(){return this.data.numDataIds()}async read(t){return this.readSync(t)}readSync(t){const{dtype:e,complexTensorInfos:n}=this.data.get(t);if("complex64"===e){return CG(this.readSync(n.real.dataId),this.readSync(n.imag.dataId))}return QA(this.data.get(t).values,e)}bufferSync(t){const e=this.readSync(t.dataId);if("string"===t.dtype)try{const n=e.map((t=>hk(t)));return $L(t.shape,t.dtype,n)}catch(t){throw new Error("Failed to decode encoded string bytes into utf-8")}return $L(t.shape,t.dtype,e)}makeOutput(t,e,n){return ID().makeTensorFromTensorInfo(this.makeTensorInfo(e,n,t),this)}disposeData(t,e=!1){if(this.data.has(t)){if(this.data.get(t).refCount--,!e&&this.data.get(t).refCount>0)return!1;const{complexTensorInfos:n}=this.data.get(t);null!=n&&(this.disposeData(n.real.dataId,!0),this.disposeData(n.imag.dataId,!0)),this.data.delete(t)}return!0}disposeIntermediateTensorInfo(t){this.disposeData(t.dataId)}async time(t){const e=ok();t();return{kernelMs:ok()-e}}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(t){b2([t],"where");const e=this.readSync(t.dataId);return v2(t.shape,e)}dispose(){}floatPrecision(){return 32}epsilon(){return super.epsilon()}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function S2(t){const e=new Float32Array(t.length);for(let n=0;n{const{x:e}=t.inputs,n=t.backend;b2(e,"abs");let i=new Float32Array(bA(e.shape));return i=S2(n.data.get(e.dataId).values),n.makeOutput(i,e.shape,e.dtype)}}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function R2(t){return(e,n,i,s,r)=>{const a=yF(e,n),o=a.length,l=jA(a),u=LA(r,bA(a)),h=e.length,p=n.length,c=jA(e),d=jA(n),f=_F(e,a),m=_F(n,a);if(f.length+m.length===0)for(let e=0;er[t]=0));const a=nO(r,h,c),g=n.slice(-p);m.forEach((t=>g[t]=0));const _=nO(g,p,d);u[e]=t(i[a],s[_])}return[u,a]}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function A2(t){const{inputs:e,backend:n}=t,{real:i,imag:s}=e,r=n.data.get(i.dataId).values,a=n.data.get(s.dataId).values,o=n.makeTensorInfo(i.shape,"complex64");return n.data.get(o.dataId).complexTensorInfos={real:n.makeTensorInfo(i.shape,"float32",r),imag:n.makeTensorInfo(s.shape,"float32",a)},o}const O2={kernelName:VO,backendName:"cpu",kernelFunc:A2}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function M2(t,e,n="float32"){if("complex64"===n){return A2({inputs:{real:M2(t,e,"float32"),imag:M2(t,e,"float32")},backend:t})}const i=ZA(bA(e),n);return t.makeTensorInfo(e,n,i)} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function C2(t){const{inputs:e,backend:n}=t,{x:i}=e;return n.incRef(i.dataId),{dataId:i.dataId,shape:i.shape,dtype:i.dtype}}const N2={kernelName:OM,backendName:"cpu",kernelFunc:C2}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function k2(t){const{inputs:e,backend:n}=t,{input:i}=e,s=n.data.get(i.dataId).complexTensorInfos.real,r=n.data.get(s.dataId).values;return n.makeTensorInfo(s.shape,s.dtype,r)}const D2={kernelName:RC,backendName:"cpu",kernelFunc:k2}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function L2(t,e,n,i){if("int32"===i){return[e,"int32",Int32Array.from(t)]}if("bool"===i){const i=ak([0],n),[s,r]=R2(((t,e)=>t!==e?1:0))(e,[],t,i,"bool");return[r,"bool",s]}throw new Error(`Error in Cast: failed to cast ${n} to ${i}`)}function F2(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{dtype:r}=i;if("complex64"===r){if("complex64"===s.dtype)return C2({inputs:{x:s},backend:n});const t=M2(n,s.shape,s.dtype),e=F2({inputs:{x:s},backend:n,attrs:{dtype:"float32"}}),i=A2({inputs:{real:e,imag:t},backend:n});return n.disposeIntermediateTensorInfo(t),n.disposeIntermediateTensorInfo(e),i}if("complex64"===s.dtype){const t=k2({inputs:{input:s},backend:n}),e=F2({inputs:{x:t},backend:n,attrs:{dtype:r}});return n.disposeIntermediateTensorInfo(t),e}if(!BA(s.dtype,r)){const t=C2({inputs:{x:s},backend:n});return{dataId:t.dataId,shape:t.shape,dtype:r}}const a=n.data.get(s.dataId).values,[o,l,u]=L2(a,s.shape,s.dtype,r);return n.makeTensorInfo(o,l,u)}const P2={kernelName:PO,backendName:"cpu",kernelFunc:F2}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function $2(t,e,n,i){return null==n?({inputs:n,backend:s})=>{const{a:r,b:a}=n,o=s;b2([r,a],t);const l=o.data.get(r.dataId).values,u=o.data.get(a.dataId).values,h="string"===r.dtype?pH(l):l,p="string"===r.dtype?pH(u):u,c=i||r.dtype,[d,f]=e(r.shape,a.shape,h,p,c);return o.makeTensorInfo(f,c,d)}:({inputs:t,backend:s})=>{const{a:r,b:a}=t,o=s;if("complex64"===r.dtype||"complex64"===a.dtype){const t=F2({inputs:{x:r},backend:o,attrs:{dtype:"complex64"}}),e=o.data.get(t.dataId),i=e.complexTensorInfos.real,s=e.complexTensorInfos.imag,l=o.data.get(i.dataId).values,u=o.data.get(s.dataId).values,h=F2({inputs:{x:a},backend:o,attrs:{dtype:"complex64"}}),p=o.data.get(h.dataId),c=p.complexTensorInfos.real,d=p.complexTensorInfos.imag,f=o.data.get(c.dataId).values,m=o.data.get(d.dataId).values,[g,_,T]=n(r.shape,a.shape,l,u,f,m),y=o.makeTensorInfo(T,"float32",g),I=o.makeTensorInfo(T,"float32",_),E=A2({inputs:{real:y,imag:I},backend:o});return o.disposeIntermediateTensorInfo(t),o.disposeIntermediateTensorInfo(h),o.disposeIntermediateTensorInfo(y),o.disposeIntermediateTensorInfo(I),E}{const t=o.data.get(r.dataId).values,n=o.data.get(a.dataId).values,s=i||r.dtype,[l,u]=e(r.shape,a.shape,t,n,s);return o.makeTensorInfo(u,s,l)}}}function B2(t){return(e,n,i,s,r,a)=>{const o=yF(e,n),l=bA(o),u=o.length,h=jA(o),p=LA("float32",l),c=LA("float32",l),d=_F(e,o),f=_F(n,o),m=CG(i,s),g=CG(r,a),_=e.length,T=jA(e),y=n.length,I=jA(n);if(d.length+f.length===0)for(let e=0;ei[t]=0));const s=nO(i,_,T),r=n.slice(-y);f.forEach((t=>r[t]=0));const a=nO(r,y,I),o=t(m[2*s],m[2*s+1],g[2*a],g[2*a+1]);p[e]=o.real,c[e]=o.imag}return[p,c,o]}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const V2=R2(((t,e)=>t+e)),U2=B2(((t,e,n,i)=>({real:t+n,imag:e+i}))),Y2=$2(gO,V2,U2),G2={kernelName:gO,backendName:"cpu",kernelFunc:Y2}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function H2(t,e,n,i,s){const r=bA(i),a=ZA(s,n);for(let n=0;n=s||(a[i]+=r>0?e[n]:1)}return a}function W2(t,e,n,i=!1){const s=t.shape[0],r=t.shape[1],a=$L([s,n],e.dtype);for(let o=0;o=n||(i?a.set(1,o,r):e.size>0?a.set(a.get(o,r)+e.get(o,s),o,r):a.set(a.get(o,r)+1,o,r))}return a} /** * @license * Copyright 2023 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const z2=R2(((t,e)=>t&e)),X2=$2(DO,z2),j2={kernelName:DO,backendName:"cpu",kernelFunc:X2}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function q2(t){return(e,n,i)=>{const s=FA(n,e.length);for(let n=0;n{const{x:a}=i;b2(a,t);const o=r,l=o.data.get(a.dataId).values;let u;if("string"===a.dtype){if(!Array.isArray(l))throw new Error("String tensor's value was not an instance of Array");u=pH(l)}else u=l;const h=n||a.dtype,p=e(u,h,s);return o.makeTensorInfo(a.shape,h,p)}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const J2=q2((t=>Math.ceil(t))),Z2=Q2($O,J2),t3={kernelName:$O,backendName:"cpu",kernelFunc:Z2}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function e3(t,e,n,i){const s=FA(n,bA(e));if(i&&"string"!==n){let e=0;t.forEach((t=>{const n=bA(t.shape);s.set(t.vals,e),e+=n}))}else{let i=0;t.forEach((t=>{const r="string"===n?pH(t.vals):t.vals;let a=0;for(let n=0;nt===e?1:0)),i3=$2(mM,n3,null,"bool"),s3={kernelName:mM,backendName:"cpu",kernelFunc:i3},r3=q2((t=>Math.exp(t))),a3=Q2(gM,r3,"float32"),o3={kernelName:gM,backendName:"cpu",kernelFunc:a3},l3=q2((t=>Math.expm1(t))),u3=Q2(TM,l3),h3={kernelName:TM,backendName:"cpu",kernelFunc:u3},p3=q2((t=>Math.floor(t))),c3=Q2(bM,p3),d3={kernelName:bM,backendName:"cpu",kernelFunc:c3},f3=R2(((t,e)=>Math.floor(t/e))),m3=$2(vM,f3,null,"int32"),g3={kernelName:vM,backendName:"cpu",kernelFunc:m3}; /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function _3(t,e,n,i,s,r,a,o,l){const u=$L([i,r],n);for(let n=0;n=l/r)throw new Error(`Invalid indices: ${i} does not index into ${o}`);for(let t=0;tt>e?1:0)),I3=$2(RM,y3,null,"bool"),E3={kernelName:RM,backendName:"cpu",kernelFunc:I3},b3=R2(((t,e)=>t>=e?1:0)),v3=$2(AM,b3,null,"bool"),w3={kernelName:AM,backendName:"cpu",kernelFunc:v3},S3=R2(((t,e)=>tt<=e?1:0)),O3=$2(PM,A3,null,"bool"),M3={kernelName:PM,backendName:"cpu",kernelFunc:O3}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function C3(t,e,n){const i=(e-t)/(n-1),s=ZA(n,"float32");s[0]=t;for(let t=1;tMath.log(t))),k3=Q2(BM,N3),D3={kernelName:BM,backendName:"cpu",kernelFunc:k3}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function L3(t,e,n,i){const s=LA(i,bA(n));for(let n=0;nr)&&(r=e)}s[n]=r}return s} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const F3=R2(((t,e)=>Math.max(t,e))),P3=$2(QM,F3),$3={kernelName:QM,backendName:"cpu",kernelFunc:P3},B3=R2(((t,e)=>Math.min(t,e))),V3=$2(rC,B3),U3={kernelName:rC,backendName:"cpu",kernelFunc:V3},Y3=R2(((t,e)=>t*e)),G3=B2(((t,e,n,i)=>({real:t*n-e*i,imag:t*i+e*n}))),H3=$2(uC,Y3,G3),W3={kernelName:uC,backendName:"cpu",kernelFunc:H3}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function z3(t,e,n){const i=rk(-1,n);return Y3([],e,i,t,n)}const X3={kernelName:hC,backendName:"cpu",kernelFunc:function(t){const{inputs:e,backend:n}=t,{x:i}=e;b2(i,"neg");const s=n.data.get(i.dataId).values,[r,a]=z3(s,i.shape,i.dtype);return n.makeTensorInfo(a,i.dtype,r)}},j3=R2(((t,e)=>t!==e?1:0)),q3=$2(pC,j3,null,"bool"),K3={kernelName:pC,backendName:"cpu",kernelFunc:q3}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Q3(t,e,n,i,s){const r=e.length,a=bA(e),o=jA(e),l=jA(s),u=LA(n,bA(s));for(let e=0;en.disposeIntermediateTensorInfo(t))),n.makeTensorInfo(_,g,f)}};function n4(t,e,n,i){const s=[];let r=0;const a=e.length-1+n.length,o=new Array(a).fill(null).map((()=>[0]));!function(t,e){for(let n=0;ns)throw new Error("Ragged splits must not point past values");for(let t=1;ti[t])throw new Error("Ragged splits must be sorted in ascending order")}}(n,i);let l=1;for(let t=0;t=0){const t=o[s],e=t[t.length-1]-i[a];for(let t=a;t{if(t<0||t>=n){const s=iO(i,e.length,jA(e)).join(",");throw new Error(`indices[${s}] = ${t} is not in [0, ${n})`)}}))}(r,a,e[0][0]-1),0===i.length)throw new Error("params.rank must be nonzero");const l=i[0],{outSplits:u,valueSlices:h,numValues:p}=n4(r,a,t,l),c=function(t){const e=[];for(let n=0;ni[e]=t))}return e}(u),d=s4(n,i,s,h,p);return[c,d[0],d[1]]} /** * @license * Copyright 2022 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const a4=2147483647;function o4(t,e,n,i,s,r,a){if(e.length>1)throw new Error("starts must be a scalar or vector");if(s.length>1)throw new Error("limits must be a scalar or vector");if(a.length>1)throw new Error("deltas must be a scalar or vector");const o=0===e.length,l=0===s.length,u=0===a.length,h=[];o||h.push(e[0]),l||h.push(s[0]),u||h.push(a[0]);for(let t=1;t0&&sn)h=0;else if(h=Math.ceil(Math.abs((s-n)/a)),h>a4)throw new Error(`Requires ((limit - start) / delta) <= ${a4}`);c[e+1]=c[e]+h}const d=FA(n,c[p]);let f=0;for(let e=0;en&&(n=e)}return n}static getMaxWidthValueRowID(t){const e=t.length;if(0===e)return 0;let n=0,i=t[0],s=0;for(let r=1;r"Final length of result must be equal to firstDimension.")),s}calculateOutputIndexRowSplit(t,e,n,i){const s=t.length,r=[];for(let a=0;a0&&r.length!==t[s-1])throw new Error("Invalid row split size.");return r}calculateOutputIndexValueRowID(t,e,n,i){const s=t.length,r=[];if(0===s)return[];let a=0,o=t[0];if(o>=e.length)throw new Error(`Got currentValueRowId=${o}, which is not less than ${e.length}`);let l=e[o];r.push(l);for(let u=1;u=0&&(++a,a=e.length)throw new Error(`Got nextValueRowId=${s} which is not less than ${e.length}`);l=e[s]}r.push(l)}if(r.length!==t.length)throw new Error("Invalid row ids.");return r}calculateOutputIndex(t,e,n,i){const s=this.getRowPartitionTensor(t),r=this.getRowPartitionTypeByDimension(t);switch(r){case l4.VALUE_ROWIDS:return this.calculateOutputIndexValueRowID(s,e,n,i);case l4.ROW_SPLITS:if(s.length-1>e.length)throw new Error(`Row partition size is greater than output size: ${s.length-1} > ${e.length}`);return this.calculateOutputIndexRowSplit(s,e,n,i);default:throw new Error(`Unsupported partition type: ${l4[r]}`)}}getFirstDimensionSize(){const t=this.rowPartitionValues[0];if(0===this.rowPartitionTypes.length)throw new Error("No row_partition_types given.");const e=this.rowPartitionTypes[0];switch(e){case l4.FIRST_DIM_SIZE:return t[0];case l4.VALUE_ROWIDS:throw new Error("Cannot handle VALUE_ROWIDS in first dimension.");case l4.ROW_SPLITS:return this.rowPartitionValuesShapes[0][0]-1;default:throw new Error(`Cannot handle type ${l4[e]}`)}}compute(){if(this.rowPartitionValues[0].length<=0)throw new Error("Invalid first partition input. Tensor requires at least one element.");const t=this.getFirstDimensionSize(),e=this.calculateOutputSize(t),n=new Array(this.raggedRank+1);n[n.length-1]=1;for(let t=n.length-2;t>=0;--t)n[t]=n[t+1]*e[t+1];const i=p4(e,!1),s=FA(this.valuesDType,bA(i));if(n[0]*e[0]>0){let r=this.calculateFirstParentOutputIndex(t,n[0],e[0]);for(let t=1;t<=this.raggedRank;++t){r=this.calculateOutputIndex(t-1,r,n[t],e[t])}this.setOutput(this.raggedRank,r,s,i)}return[i,s]}setOutput(t,e,n,i){if(0===n.length)return;const s=this.values,r=n;let a=i.slice();a=a.slice(t+1);const o=bA(a),l=e.length;let u=this.defaultValue;if(u.length!==o&&1!==u.length){const t=this.defaultValueShape;vD((()=>{const e=E$(u,t),n=P$(e,a);u=n.dataSync()}))}let h=0,p=0,c=0;for(let t=0;t<=l;++t){let i=t=l){const t=n.length;i=Math.floor(t/o)}if(i>c)if(1===this.defaultValue.length)r.subarray(c*o,i*o).fill(this.defaultValue[0]),c=i;else for(;i>c;){h4(r.slice(c*o),u,o),++c}i<0?(h=t+1,p=c):(h=t,p=c,c=p+1)}else++c}}}function h4(t,e,n){for(let i=0;i= 0`);if(i<-1)throw new Error(`Dimension ${i} must be >= -1`);i=-1}n.push(i)}return n}function c4(t,e,n,i,s,r,a,o,l,u){return new u4(t,e,n,i,s,r,a,o,l,u).compute()} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function d4(t,e,n,i){if(t===e||t1)return ZA(0,i);const s=ZA(Math.abs(Math.ceil((e-t)/n)),i);e1/Math.sqrt(t))),m4=Q2($C,f4),g4={kernelName:$C,backendName:"cpu",kernelFunc:m4}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function _4(t,e,n,i,s,r,a,o,l,u){const h=[i/s,s],p=t.values,c=e.values;if(0===i)return $L(n,e.dtype);const d=l instanceof wk?l:$L(h,e.dtype);"string"==typeof l||"number"==typeof l?d.values.fill(l):"boolean"==typeof l&&d.values.fill(+l);for(let t=0;t=i/s)throw new Error(`Invalid indices: ${r} does not index into ${n}`);for(let n=0;n1/(1+Math.exp(-t)))),y4=K2(jC,(t=>1/(1+Math.exp(-t)))),I4={kernelName:jC,backendName:"cpu",kernelFunc:y4}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function E4(t,e,n,i,s){const r=RP(i,e,n),a=bA(n),o=jA(i);if(r){const n=AP(e,o);return"string"===s?t.slice(n,n+a):t.subarray(n,n+a)}const l=$L(i,s,"string"===s?pH(t):t),u=$L(n,s);for(let t=0;tt+e[n]));u.set(l.get(...i),...n)}return"string"===s?cH(u.values):u.values}function b4(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{begin:r,size:a}=i;b2(s,"slice");const[o,l]=OP(s,r,a);mP(s,o,l);const u=E4(n.data.get(s.dataId).values,o,l,s.shape,s.dtype);return n.makeTensorInfo(l,s.dtype,u)}const v4={kernelName:HC,backendName:"cpu",kernelFunc:b4}; /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function w4(t,e,n,i,s,r,a){const o=e[0],l=r[0],u=new Array(l),h=new Array(o),p=e[1];if(0===l){if(0!==o)throw new Error(KG(o));return[FA(n,0),[0,p],FA(s,0),u,h]}let c=!0,d=0;const f=new Array(l).fill(0);for(let e=0;e=l)throw new Error(JG(e,n,l));++f[n],c=c&&n>=d,d=n}let m=!0;for(let t=0;t0&&(f[t]+=f[t-1])}if(m&&c){const e=t,n=i;for(let t=0;t0){c[p-1]=1;for(let t=p-2;t>=0;--t)c[t]=c[t+1]*i[t+1]}const d=[];if(o>0){d[o-1]=1;for(let t=o-2;t>=0;--t)d[t]=d[t+1]*l[t+1]}const f=FA(n,a*o);for(let e=0;e0?s[o-1]+1:0;if(h<0)throw new Error("segment ids must be >= 0");const p=e.slice();p[0]=h;const c=FA(n,p.reduce(((t,e)=>t*e),1));if(0===o)return h>0&&c.fill(a),[c,p];if(h<=0)throw new Error("segment ids must be >= 0");let d=0,f=1,m=0,g=s[d];for(;;){let e=0;if(f=e)throw new Error("segment ids are not increasing")}if(g<0||g>=h)throw new Error(aH(g,h));g>m&&c.fill(a,m*u,g*u);for(let e=d;e=l[0])throw new Error(oH(e,i[e],l[0]));for(let e=0;eo)break}return mMath.sqrt(t))),A4=K2(KC,(t=>Math.sqrt(t))),O4={kernelName:KC,backendName:"cpu",kernelFunc:A4},M4=R2(((t,e)=>{const n=t-e;return n*n})),C4=$2(aN,M4),N4={kernelName:aN,backendName:"cpu",kernelFunc:C4},k4=q2(((t,e)=>{const{pattern:n,replaceGlobal:i,rewrite:s}=e;return t.replace(new RegExp(n,i?"g":""),s)})),D4=Q2(lN,k4),L4={kernelName:lN,backendName:"cpu",kernelFunc:D4}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function F4(t,e,n,i){const s=$L(t,e.dtype);for(let t=0;t0?0:a-o);let c=0;c+=l*this.leftPad.length;for(let e=0;et.forEach((t=>d[f++]=t));for(let t=0;t0){m(t[p+h-1]);for(let t=0;t0){let t=e[0];if(0!==t)throw new Error(`First split value must be 0, got ${t}`);for(let s=1;s=t;if(i=i&&e[s]<=n,!i)throw new Error(`Invalid split value ${e[s]}, must be in [${t}, ${n}]`);t=e[s]}if(t!==n)throw new Error(`Last split value must be data size. Expected ${n}, got ${t}`)}const s=i-1,r=FA("int32",i);if(0===n||0===i){const t=new Array(n);for(let t=0;t<=s;++t)r[t]=0;return[t,r]}r[0]=0;for(let t=1;t<=s;++t){const n=e[t]-e[t-1];let i=0;this.nGramWidths.forEach((t=>{i+=this.getNumNGrams(n,t)})),this.preserveShort&&n>0&&0===i&&(i=1),r[t]=r[t-1]+i}const a=new Array(r[s]);for(let n=0;n{const o=e[n+1]-e[n],l=this.getNumNGrams(o,r);this.createNGrams(t,i,a,s,l,r),s+=l})),this.preserveShort&&s===r[n]){const r=e[n+1]-e[n];if(0===r)continue;const o=r+2*this.padWidth,l=1;this.createNGrams(t,i,a,s,l,o)}}return[a,r]}}function $4(t,e,n,i,s,r,a,o){return new P4(n,i,s,r,a,o).compute(t,e)} /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function B4(t,e,n,i){if(!t.length)return;if(0===e.length){for(let e=0;et-e)),G4=B2(((t,e,n,i)=>({real:t-n,imag:e-i}))),H4=$2(dN,Y4,G4),W4={kernelName:dN,backendName:"cpu",kernelFunc:H4}; /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function z4(t,e){const n=new Array(t.rank);for(let i=0;i{const n=e.value-t.value;return 0===n?t.index-e.index:n};function j4(t,e,n=0,i=t.length-1){for(;i>n;){if(i-n>600){const s=i-n+1,r=e-n+1,a=Math.log(s),o=.5*Math.exp(2*a/3),l=.5*Math.sqrt(a*o*(s-o)/s)*Math.sign(r-s/2);j4(t,e,Math.max(n,Math.floor(e-r*o/s+l)),Math.min(i,Math.floor(e+(s-r)*o/s+l)))}const s=t[e];let r=n,a=i;for(mA(t,n,e),X4(t[i],s)>0&&mA(t,n,i);r0;)a-=1}0===X4(t[n],s)?mA(t,n,a):(a+=1,mA(t,a,i)),a<=e&&(n=a+1),e<=a&&(i=a-1)}}function q4(t,e,n,i,s){const r=e[e.length-1],[a,o]=[t.length/r,r],l=LA(n,a*i),u=LA("int32",a*i);for(let e=0;ea[e]={value:t,index:e})),i{for(let n=0;nnew w2),1); /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const J4=K2(cM,(t=>t>=0?t:Math.exp(t)-1)),Z4={kernelName:cM,backendName:"cpu",kernelFunc:J4}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function t5(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{alpha:r}=i;b2([s],"leakyRelu");const a=bA(s.shape),o=n.data.get(s.dataId).values,l=LA("float32",a);for(let t=0;tt<0?e*t:t));function i5(t){const{inputs:e,backend:n}=t,{x:i,alpha:s}=e;b2([i,s],"prelu");const r=n.data.get(i.dataId).values,a=n.data.get(s.dataId).values,[o,l]=n5(i.shape,s.shape,r,a,"float32");return n.makeTensorInfo(l,"float32",o)}const s5={kernelName:EC,backendName:"cpu",kernelFunc:i5},r5=K2(OC,(t=>Math.max(0,t))),a5={kernelName:OC,backendName:"cpu",kernelFunc:r5},o5=K2(LC,(t=>Math.min(Math.max(0,t),6))),l5={kernelName:LC,backendName:"cpu",kernelFunc:o5}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function u5(t,e,n,i,s){if("linear"===n)return C2({inputs:{x:e},backend:t});if("relu"===n)return r5({inputs:{x:e},backend:t});if("elu"===n)return J4({inputs:{x:e},backend:t});if("relu6"===n)return o5({inputs:{x:e},backend:t});if("prelu"===n)return i5({inputs:{x:e,alpha:i},backend:t});if("leakyrelu"===n)return t5({inputs:{x:e},backend:t,attrs:{alpha:s}});if("sigmoid"===n)return y4({inputs:{x:e},backend:t});throw new Error(`Activation ${n} has not been implemented for the CPU backend.`)} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function h5(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{shape:r}=i,a=bA(s.shape),o=NA(r,a),l=bA(o);yA(a===l,(()=>`The new shape (${o}) has ${l} elements and the old shape (${s.shape}) has ${a} elements. The new shape and old shape must have the same number of elements.`)),n.incRef(s.dataId);const u=n.data.get(s.dataId);if(null!=u.complexTensorInfos){const t=u.complexTensorInfos.real,e=u.complexTensorInfos.imag;t.shape=o,e.shape=o}return{dataId:s.dataId,shape:o,dtype:s.dtype}}const p5={kernelName:MC,backendName:"cpu",kernelFunc:h5}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function c5(t){const{inputs:e,backend:n,attrs:i}=t,{a:s,b:r}=e,{transposeA:a,transposeB:o}=i;b2([s,r],"matMul");const l=s.shape.length,u=r.shape.length,h=a?s.shape[l-2]:s.shape[l-1],p=o?r.shape[u-1]:r.shape[u-2],c=a?s.shape[l-1]:s.shape[l-2],d=o?r.shape[u-2]:r.shape[u-1],f=s.shape.slice(0,-2),m=r.shape.slice(0,-2),g=bA(f),_=bA(m),T=yF(s.shape.slice(0,-2),r.shape.slice(0,-2)).concat([c,d]);yA(h===p,(()=>`Error in matMul: inner shapes (${h}) and (${p}) of Tensors with shapes ${s.shape} and ${r.shape} and transposeA=${a} and transposeB=${o} must match.`));const y=o?[_,d,p]:[_,p,d],I=h5({inputs:{x:s},backend:n,attrs:{shape:a?[g,h,c]:[g,c,h]}}),E=h5({inputs:{x:r},backend:n,attrs:{shape:y}}),b=a?I.shape[1]:I.shape[2],v=a?I.shape[2]:I.shape[1],w=o?E.shape[1]:E.shape[2],S=Math.max(g,_),x=n.data.get(I.dataId).values,R=n.data.get(E.dataId).values,A=jA(I.shape),O=jA(E.shape),[M,C,N]=a?[A[0],1,A[1]]:[A[0],A[1],1],[k,D,L]=o?[1,O[1],O[0]]:[O[1],1,O[0]],F=v*w,P=$L([S,v,w],I.dtype),$=P.values,B=n.blockSize;for(let t=0;tMath.acos(t))),g5={kernelName:fO,backendName:"cpu",kernelFunc:m5},_5=K2(mO,(t=>Math.acosh(t))),T5={kernelName:mO,backendName:"cpu",kernelFunc:_5};const y5={kernelName:_O,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n}=t,i=e;b2(e,"addN");const s=i.map((t=>n.data.get(t.dataId).values)),r=$L(i[0].shape,i[0].dtype),a=r.values;for(let t=0;tn&&(n=s,i=t)}c[t]=i}return u.forEach((t=>n.disposeIntermediateTensorInfo(t))),n.makeTensorInfo(h,"int32",c)}};const v5={kernelName:EO,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r}=i;b2(s,"argMin");let a=kA(r,s.shape);const o=yB(a,s.shape.length);let l=s;const u=[];null!=o&&(l=J3({inputs:{x:s},backend:n,attrs:{perm:o}}),u.push(l),a=EB(a.length,l.shape.length)),a=[a[0]],TB("argMin",a,l.shape.length);const[h,p]=gB(l.shape,a),c=ZA(bA(h),"int32"),d=bA(p),f=n.data.get(l.dataId).values;for(let t=0;tn.disposeIntermediateTensorInfo(t))),n.makeTensorInfo(h,"int32",c)}},w5=K2(bO,(t=>Math.asin(t))),S5={kernelName:bO,backendName:"cpu",kernelFunc:w5},x5=K2(vO,(t=>Math.asinh(t))),R5={kernelName:vO,backendName:"cpu",kernelFunc:x5},A5=K2(wO,(t=>Math.atan(t))),O5={kernelName:wO,backendName:"cpu",kernelFunc:A5},M5=R2(((t,e)=>Math.atan2(t,e))),C5=$2(xO,M5),N5={kernelName:xO,backendName:"cpu",kernelFunc:C5},k5=K2(SO,(t=>Math.atanh(t))),D5={kernelName:SO,backendName:"cpu",kernelFunc:k5}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function L5(t,e,n,i,s,r){const a=s.strideHeight,o=s.strideWidth,l=s.dilationHeight,u=s.dilationWidth,h=s.effectiveFilterHeight,p=s.effectiveFilterWidth,c=s.padInfo.top,d=s.padInfo.left,f="max"===r?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,m=$L(s.outShape,n),g=m.values,_=s.outShape[1]*s.outShape[2]*s.outShape[3],T=s.outShape[2]*s.outShape[3],y=s.outShape[3];for(let e=0;e_?_=a:"avg"===r&&(T+=a,I++)}if(isNaN(_))break}g[v+n*y+e]="avg"===r?T/I:_}}}return m}function F5(t,e,n,i,s=!1,r=!1){const a=$L(i.outShape,"int32"),o=i.strideHeight,l=i.strideWidth,u=i.dilationHeight,h=i.dilationWidth,p=i.effectiveFilterHeight,c=i.effectiveFilterWidth,d=i.padInfo.top,f=i.padInfo.left,m=$L(e,n,t);for(let t=0;tI&&(I=u,E=s?r?((t*i.inHeight+n)*i.inWidth+o)*i.inChannels+e:(n*i.inWidth+o)*i.inChannels+e:a*c+l)}}a.set(E,t,n,o,e)}}return a}function P5(t,e,n,i,s,r){const a=s.strideDepth,o=s.strideHeight,l=s.strideWidth,u=s.dilationDepth,h=s.dilationHeight,p=s.dilationWidth,c=s.effectiveFilterDepth,d=s.effectiveFilterHeight,f=s.effectiveFilterWidth,m=s.padInfo.front,g=s.padInfo.top,_=s.padInfo.left,T="max"===r?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,y=$L(s.outShape,n),I=y.values,E=s.outShape[1]*s.outShape[2]*s.outShape[3]*s.outShape[4],b=s.outShape[2]*s.outShape[3]*s.outShape[4],v=s.outShape[3]*s.outShape[4],w=s.outShape[4];for(let e=0;eb?b=s:"avg"===r&&(v+=s,S++),isNaN(b))break}if(isNaN(b))break}if(isNaN(b))break}I[g+e]="avg"===r?v/Math.max(S,1):b}}}}return y}const $5={kernelName:RO,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e;b2(s,"avgPool");const{filterSize:r,strides:a,pad:o,dimRoundingMode:l}=i;yA(_$(a,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${a} and dilations '1'`));const u=o$(s.shape,r,a,1,o,l);let h;if(1===u.filterWidth&&1===u.filterHeight&&SA(u.inShape,u.outShape))h=C2({inputs:{x:s},backend:n});else{const t=n.data.get(s.dataId).values,e=jA(s.shape),i=L5(t,s.shape,s.dtype,e,u,"avg");h=n.makeTensorInfo(u.outShape,s.dtype,i.values)}return h}};const B5={kernelName:OO,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{filterSize:r,strides:a,pad:o,dimRoundingMode:l,dataFormat:u}=i;b2(s,"avgPool3d");const h=l$(s.shape,r,a,1,o,l,u),p=P5(n.data.get(s.dataId).values,s.shape,s.dtype,jA(s.shape),h,"avg");return n.makeTensorInfo(p.shape,"float32",p.values)}};const V5={kernelName:MO,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{dy:s,input:r}=e,{filterSize:a,strides:o,pad:l,dimRoundingMode:u}=i;b2([s,r],"avgPool3DGrad");const h=l$(r.shape,a,o,1,l,u),p=h.strideDepth,c=h.strideHeight,d=h.strideWidth,f=h.filterDepth,m=h.filterHeight,g=h.filterWidth,_=h.dilationDepth,T=h.dilationHeight,y=h.dilationWidth,I=h.effectiveFilterDepth,E=h.effectiveFilterHeight,b=h.effectiveFilterWidth,v=I-1-h.padInfo.front,w=b-1-h.padInfo.left,S=E-1-h.padInfo.top,x=$L(r.shape,"float32"),R=1/(f*m*g),A=n.bufferSync(s);for(let t=0;t=h.outDepth||Math.floor(i)!==i))for(let n=0;n=h.outHeight||Math.floor(s)!==s))for(let n=0;n=h.outWidth||Math.floor(r)!==r)continue;l+=A.get(t,i,s,r,e)}}}x.set(l*R,t,n,i,s,e)}return n.makeTensorInfo(x.shape,x.dtype,x.values)}};const U5={kernelName:AO,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{dy:s,input:r}=e,a=r;b2([s,r],"avgPoolGrad");const{filterSize:o,strides:l,pad:u}=i,h=o$(a.shape,o,l,1,u),p=h.strideHeight,c=h.strideWidth,d=h.filterHeight,f=h.filterWidth,m=h.dilationHeight,g=h.dilationWidth,_=h.effectiveFilterHeight,T=h.effectiveFilterWidth,y=T-1-h.padInfo.left,I=_-1-h.padInfo.top,E=$L(a.shape,"float32"),b=1/(d*f),v=n.data.get(s.dataId).values,w=$L(s.shape,"float32",v);for(let t=0;t=h.outHeight||Math.floor(i)!==i))for(let n=0;n=h.outWidth||Math.floor(s)!==s)continue;a+=w.get(t,i,s,e)}}E.set(a*b,t,n,i,e)}return n.makeTensorInfo(E.shape,E.dtype,E.values)}};const Y5={kernelName:wM,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,scale:r,offset:a,mean:o,variance:l}=e;yA(o.shape.length===l.shape.length,(()=>"Batch normalization gradient requires mean and variance to have equal ranks.")),yA(null==a||o.shape.length===a.shape.length,(()=>"Batch normalization gradient requires mean and offset to have equal ranks.")),yA(null==r||o.shape.length===r.shape.length,(()=>"Batch normalization gradient requires mean and scale to have equal ranks.")),b2([s,o,l,r,a],"batchNorm");let{varianceEpsilon:u}=i;null==u&&(u=.001);const h=n.data.get(s.dataId).values,p=n.data.get(o.dataId).values,c=n.data.get(l.dataId).values,d=r?n.data.get(r.dataId).values:new Float32Array([1]),f=a?n.data.get(a.dataId).values:new Float32Array([0]),m=new Float32Array(h.length),g=f.length,_=d.length,T=c.length,y=p.length;let I=0,E=0,b=0,v=0;for(let t=0;t=g&&(I=0),E>=y&&(E=0),b>=_&&(b=0),v>=T&&(v=0);return n.makeTensorInfo(s.shape,s.dtype,m)}};const G5={kernelName:NO,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{blockShape:r,crops:a}=i;b2([s],"batchToSpaceND");const o=r.reduce(((t,e)=>t*e)),l=TG(s.shape,r,o),u=yG(l.length,r.length),h=IG(s.shape,r,o),p=EG(a,r.length),c=bG(h,a,r.length),d=h5({inputs:{x:s},backend:n,attrs:{shape:l}}),f=J3({inputs:{x:d},backend:n,attrs:{perm:u}}),m=h5({inputs:{x:f},backend:n,attrs:{shape:h}}),g=b4({inputs:{x:m},backend:n,attrs:{begin:p,size:c}});return n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),g}};const H5={kernelName:kO,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,weights:r}=e,{size:a}=i,o=H2(n.data.get(s.dataId).values,n.data.get(r.dataId).values,r.dtype,r.shape,a);return n.makeTensorInfo([a],r.dtype,o)}};const W5={kernelName:FO,backendName:"cpu",kernelFunc: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n}=t,{s0:i,s1:s}=e,r=n.data.get(i.dataId).values,a=n.data.get(s.dataId).values,o=yF(Array.from(r),Array.from(a));return n.makeTensorInfo([o.length],"int32",Int32Array.from(o))}},z5=K2(BO,((t,e)=>{const n=e;return t>n.clipValueMax?n.clipValueMax:t{const{x:e}=t.inputs,n=t.backend,i=new Float32Array(bA(e.shape)),s=n.data.get(e.dataId),r=s.complexTensorInfos.real,a=s.complexTensorInfos.imag,o=n.data.get(r.dataId).values,l=n.data.get(a.dataId).values;for(let t=0;tt.shape)),r);let a=uG(e.map((t=>t.shape)),r);if(0===bA(a))return n.makeTensorInfo(a,e[0].dtype,[]);const o=e.filter((t=>bA(t.shape)>0));if(1===o.length)return C2({inputs:{x:o[0]},backend:n});if("complex64"===o[0].dtype){const t=o.map((t=>k2({inputs:{input:t},backend:n}))),e=o.map((t=>q5({inputs:{input:t},backend:n}))),i=Q5({inputs:t,backend:n,attrs:{axis:r}}),s=Q5({inputs:e,backend:n,attrs:{axis:r}}),a=A2({inputs:{real:i,imag:s},backend:n});return t.forEach((t=>n.disposeIntermediateTensorInfo(t))),e.forEach((t=>n.disposeIntermediateTensorInfo(t))),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(s),a}const l=o.map((t=>{const e=bA(t.shape.slice(r));return h5({inputs:{x:t},backend:n,attrs:{shape:[-1,e]}})})),u=l.map((t=>({vals:n.data.get(t.dataId).values,shape:t.shape})));a=uG(l.map((t=>t.shape)),1);const h=1===l[0].shape[0],p=e3(u,a,e[0].dtype,h),c=uG(o.map((t=>t.shape)),r),d=n.makeTensorInfo(c,e[0].dtype,p);return l.forEach((t=>n.disposeIntermediateTensorInfo(t))),d}const J5={kernelName:YO,backendName:"cpu",kernelFunc:Q5}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Z5(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,filter:r}=e,{strides:a,pad:o,dataFormat:l,dilations:u,dimRoundingMode:h}=i;b2([s,r],"conv2d");const p=y$(l),c=u$(s.shape,r.shape,a,u,o,h,!1,p),d=c.filterHeight,f=c.filterWidth,m=c.dilationHeight,g=c.dilationWidth,_=c.padInfo.left,T=c.padInfo.top,y="channelsLast"===c.dataFormat,I=new wk(c.outShape,s.dtype),E=jA(s.shape),b=jA(r.shape),v=E[0],w=y?E[1]:E[2],S=y?E[2]:1,x=y?1:E[1],R=I.strides[0],A=y?I.strides[1]:I.strides[2],O=y?I.strides[2]:1,M=y?1:I.strides[1],C=n.data.get(s.dataId).values,N=n.data.get(r.dataId).values,k=I.values;for(let t=0;t=c.inHeight)continue;const r=t*b[0],a=e+n*w;for(let t=0;t=c.inWidth)continue;const s=a+i*S;let o=r+t*b[1];for(let t=0;t=u.inDepth)continue;const r=t*S[0],a=e+n*w[1];for(let t=0;t=u.inHeight)continue;const s=r+t*S[1],o=a+i*w[2];for(let t=0;t=u.inWidth)continue;const r=s+t*S[2],a=o+e*u.inChannels;let l=r;for(let t=0;tMath.cos(t))),o6={kernelName:qO,backendName:"cpu",kernelFunc:a6},l6=K2(KO,(t=>Math.cosh(t))),u6={kernelName:KO,backendName:"cpu",kernelFunc:l6};const h6={kernelName:ZO,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{image:s,boxes:r,boxInd:a}=e,{cropSize:o,method:l,extrapolationValue:u}=i,[h,p,c,d]=s.shape,f=r.shape[0],[m,g]=o,_=$L([f,m,g,d],"float32"),T=n.data.get(r.dataId).values,y=n.data.get(a.dataId).values,I=n.data.get(s.dataId).values,E=jA(s.shape),b=jA(_.shape);for(let t=0;t=h)continue;const o=m>1?(s-n)*(p-1)/(m-1):0,f=g>1?(r-i)*(c-1)/(g-1):0;for(let e=0;e1?n*(p-1)+e*o:.5*(n+s)*(p-1);if(h<0||h>p-1)for(let n=0;n1?i*(c-1)+l*f:.5*(i+r)*(c-1);if(h<0||h>c-1){for(let n=0;n1?i*(c-1)+n*f:.5*(i+r)*(c-1);if(s<0||s>c-1){for(let i=0;it+f-e-1:(t,e)=>t+e;for(let t=0;tt+f-e-1:(t,e)=>t+e;for(let t=0;t`Only NHWC dataFormat supported on CPU for depthToSpace. Got ${a}`));const o=s.shape[0],l=s.shape[1],u=s.shape[2],h=s.shape[3],p=l*r,c=u*r,d=h/(r*r),f=n.data.get(s.dataId).values,m=new Float32Array(o*p*c*d);let g=0;for(let t=0;t`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${a} and dilations '${c}'`));const d=u$(s.shape,r.shape,a,c,o,u,!0),{filterHeight:f,filterWidth:m,dilationHeight:g,dilationWidth:_,padInfo:T}=d,y=T.left,I=T.top,E=d.outChannels/d.inChannels,b=new wk(d.outShape,s.dtype),v=n.data.get(s.dataId).values,w=n.data.get(r.dataId).values,S=b.values;for(let t=0;t=d.inHeight)continue;const r=t*p[0],a=e+n*h[1];for(let t=0;t=d.inWidth)continue;const s=r+t*p[1],o=a+i*d.inChannels;let l=e,u=s;for(let t=0;t{const{x:i,filter:s}=t,{strides:r,pad:a,dilations:o}=n,l=e,u=l.data.get(i.dataId).values,h=i.shape.length,p=l.data.get(s.dataId).values,c=s.shape.length,{batchSize:d,inHeight:f,inWidth:m,inChannels:g,outHeight:_,outWidth:T,padInfo:y,strideHeight:I,strideWidth:E,filterHeight:b,filterWidth:v,dilationHeight:w,dilationWidth:S,outShape:x}=a$(i.shape,s.shape,r,a,"NHWC",o),R=bA(x),A=x.length,O=FA(i.dtype,R);for(let t=0;t=0&&r=0&&dl&&(l=m)}}}O[nO([t,e,r,o],A,jA(x))]=l}}}return{dataId:l.write(ak(O,i.dtype),x,i.dtype),shape:x,dtype:i.dtype}}},E6={kernelName:lM,backendName:"cpu",kernelFunc:({inputs:t,backend:e,attrs:n})=>{const{x:i,filter:s,dy:r}=t,{strides:a,pad:o,dilations:l}=n,u=e,h=KA(i.shape,u.data.get(i.dataId).values),p=KA(s.shape,u.data.get(s.dataId).values),{batchSize:c,inHeight:d,inWidth:f,inChannels:m,outHeight:g,outWidth:_,padInfo:T,strideHeight:y,strideWidth:I,filterHeight:E,filterWidth:b,dilationHeight:v,dilationWidth:w,outShape:S}=a$(i.shape,s.shape,a,o,"NHWC",l);yA(r.rank===S.length,(()=>`Error in ${lM}, dy must have the same rank as output ${S.length}, but got ${r.rank}`));const x=KA(S,u.data.get(r.dataId).values),R=tO(s.shape,s.dtype);for(let t=0;t=0&&i=0&&ua&&(a=s,o=e,l=n)}}}R[o][l][r]+=x[t][e][i][r]}}}return{dataId:u.write(ak(R,i.dtype),s.shape,s.dtype),shape:s.shape,dtype:s.dtype}}},b6={kernelName:oM,backendName:"cpu",kernelFunc:({inputs:t,backend:e,attrs:n})=>{const{x:i,filter:s,dy:r}=t,{strides:a,pad:o,dilations:l}=n,u=e,h=KA(i.shape,u.data.get(i.dataId).values),p=KA(s.shape,u.data.get(s.dataId).values),{batchSize:c,inHeight:d,inWidth:f,inChannels:m,outHeight:g,outWidth:_,padInfo:T,strideHeight:y,strideWidth:I,filterHeight:E,filterWidth:b,dilationHeight:v,dilationWidth:w,outShape:S}=a$(i.shape,s.shape,a,o,"NHWC",l);yA(r.rank===S.length,(()=>`Error in ${oM}, dy must have the same rank as output ${S.length}, but got ${r.rank}`));const x=KA(S,u.data.get(r.dataId).values),R=tO(i.shape,i.dtype);for(let t=0;t=0&&i=0&&ua&&(a=s,o=i,l=u)}}}R[t][o][l][r]+=x[t][e][i][r]}}}return{dataId:u.write(ak(R,i.dtype),i.shape,i.dtype),shape:i.shape,dtype:i.dtype}}};const v6={kernelName:uM,backendName:"cpu",kernelFunc: /** * @license * Copyright 2023 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{image:s}=e,{canvas:r,options:a}=i,{contextOptions:o,imageOptions:l}=a||{},u=(null==l?void 0:l.alpha)||1,h=(null==o?void 0:o.contextType)||"2d";if("2d"!==h)throw new Error(`Context type ${o.contextType} is not supported by the CPU backend.`);const p=r.getContext(h,(null==o?void 0:o.contextAttributes)||{});if(null==p)throw new Error(`Could not get the context with ${h} type.`);const[c,d]=s.shape.slice(0,2),f=2===s.shape.length?1:s.shape[2],m=n.data.get(s.dataId).values,g="float32"===s.dtype?255:1,_=new Uint8ClampedArray(d*c*4);for(let t=0;t1)throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${i}.`)}else if("int32"===s.dtype&&(i<0||i>255))throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${i}.`);1===f?(e[0]=i*g,e[1]=i*g,e[2]=i*g):e[n]=i*g}const n=4*t;_[n+0]=Math.round(e[0]),_[n+1]=Math.round(e[1]),_[n+2]=Math.round(e[2]),_[n+3]=Math.round(e[3])}r.width=d,r.height=c;const T=new ImageData(_,d,c);return p.putImageData(T,0,0),s}}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function w6(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r,keepDims:a}=i;let o;b2(s,"sum"),o="bool"===s.dtype?F2({inputs:{x:s},backend:n,attrs:{dtype:"int32"}}):C2({inputs:{x:s},backend:n});const l=o.shape.length,u=kA(r,o.shape),h=yB(u,l);let p=u,c=o;null!=h&&(c=J3({inputs:{x:o},backend:n,attrs:{perm:h}}),p=EB(p.length,l)),TB("sum",p,c.shape.length);const[d,f]=gB(c.shape,p);let m=M2(n,d,Pk(c.dtype,"int32"));const g=bA(f),_=n.data.get(m.dataId).values,T=n.data.get(c.dataId).values;for(let t=0;t<_.length;++t){const e=t*g;let n=0;for(let t=0;t=0&&(c=w6({inputs:{x:c},backend:n,attrs:{axis:u[t]-(a.length-d),keepDims:!1}}),f.push(c)),d--)}for(const t of f)t!==c&&n.disposeIntermediateTensorInfo(t);return c}};const R6={kernelName:dM,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n}=t,{dy:i,y:s}=e;b2([i,s],"eluGrad");const r=new Float32Array(bA(s.shape)),a=n.data.get(s.dataId).values,o=n.data.get(i.dataId).values;for(let t=0;t=0?o[t]:o[t]*(e+1)}return n.makeTensorInfo(s.shape,"float32",r)}},A6=SG,O6=xG,M6=RG,C6=AG,N6=OG,k6=MG,D6=K2(fM,(t=>{const e=Math.sign(t),n=Math.abs(t),i=1/(1+A6*n);return e*(1-((((k6*i+N6)*i+C6)*i+M6)*i+O6)*i*Math.exp(-n*n))})),L6={kernelName:fM,backendName:"cpu",kernelFunc:D6}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function F6(t){const{inputs:e,backend:n,attrs:i}=t,{input:s}=e,{dim:r}=i,a=s.shape.length,o=s.shape.slice();let l=r;return r<0&&(yA(-(a+1)<=r,(()=>`Axis must be in the interval [${-(a+1)}, ${a}]`)),l=a+r+1),o.splice(l,0,1),h5({inputs:{x:s},backend:n,attrs:{shape:o}})}const P6={kernelName:_M,backendName:"cpu",kernelFunc:F6},$6=R2(((t,e)=>t/e)),B6=$2(hM,$6),V6={kernelName:hM,backendName:"cpu",kernelFunc:B6}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function U6(t,e,n){const i=t.shape,s=i[0],r=i[1],a=n.data.get(t.dataId),o=a.complexTensorInfos.real,l=a.complexTensorInfos.imag,u=[s,r],h=bA(u),p=LA("float32",h),c=LA("float32",h);for(let t=0;t{const{image:i}=t,s=n,r=LA(i.dtype,bA(i.shape)),[a,o,l,u]=i.shape,h=s.data.get(i.dataId).values;for(let t=0;t=0&&a=0,(()=>`GatherV2: the index value ${e} is not in [0, ${h-1}]`))}let p=o;null==o&&(p=0);const c=bA(r.shape),d=hH(s,r,l,p),f=h5({inputs:{x:s},backend:n,attrs:{shape:[d.batchSize,d.outerSize,d.dimSize,d.sliceSize]}}),m=h5({inputs:{x:r},backend:n,attrs:{shape:[d.batchSize,c/d.batchSize]}}),g=[d.batchSize,d.outerSize,c/d.batchSize,d.sliceSize],_=n.bufferSync(m),T=T3(n.bufferSync(f),_,g);return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),n.makeTensorInfo(d.outputShape,T.dtype,T.values)}};const J6={kernelName:MM,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n}=t,{input:i}=e,s=bA(i.shape),r=i.shape[i.shape.length-1],a=h5({inputs:{x:i},backend:n,attrs:{shape:[s/r,r]}}),o=U6(a,!0,n),l=h5({inputs:{x:o},backend:n,attrs:{shape:i.shape}});return n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(o),l}},Z6=K2(NM,(t=>Number.isFinite(t)?1:0),"bool"),t8={kernelName:NM,backendName:"cpu",kernelFunc:Z6},e8=K2(kM,(t=>Math.abs(t)===1/0?1:0),"bool"),n8={kernelName:kM,backendName:"cpu",kernelFunc:e8},i8=K2(DM,(t=>Number.isNaN(t)?1:0),"bool"),s8={kernelName:DM,backendName:"cpu",kernelFunc:i8};const r8={kernelName:$M,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{backend:e,attrs:n}=t,{start:i,stop:s,num:r}=n,a=C3(i,s,r);return e.makeTensorInfo([a.length],"float32",a)}},a8=K2(VM,(t=>Math.log1p(t))),o8={kernelName:VM,backendName:"cpu",kernelFunc:a8},l8=R2(((t,e)=>t&&e)),u8=$2(UM,l8,null,"bool"),h8={kernelName:UM,backendName:"cpu",kernelFunc:u8},p8=K2(YM,(t=>t?0:1),"bool"),c8={kernelName:YM,backendName:"cpu",kernelFunc:p8},d8=R2(((t,e)=>t||e)),f8=$2(GM,d8,null,"bool"),m8={kernelName:GM,backendName:"cpu",kernelFunc:f8};const g8={kernelName:XM,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{depthRadius:r,bias:a,alpha:o,beta:l}=i;b2(s,"LRN");const u=s.shape[3],h=u-1,p=n.data.get(s.dataId).values,c=bA(s.shape),d=new Float32Array(c);function f(t){const e=t%u;let n=t-e+Math.max(0,e-r);const i=t-e+Math.min(e+r,h);let s=0;for(;n<=i;n++){const t=p[n];s+=t*t}return s}for(let t=0;t`Error in maxPool: Either strides or dilations must be 1. Got strides ${a} and dilations '1'`));const u=o$(s.shape,r,a,1,o,l);let h;if(1===u.filterWidth&&1===u.filterHeight&&SA(u.inShape,u.outShape))h=C2({inputs:{x:s},backend:n});else{const t=n.data.get(s.dataId).values,e=jA(s.shape),i=L5(t,s.shape,s.dtype,e,u,"max");h=n.makeTensorInfo(u.outShape,s.dtype,i.values)}return h}};const E8={kernelName:tC,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{filterSize:r,strides:a,pad:o,dimRoundingMode:l,dataFormat:u}=i;b2(s,"maxPool3d");const h=l$(s.shape,r,a,1,o,l,u),p=P5(n.data.get(s.dataId).values,s.shape,s.dtype,jA(s.shape),h,"max");return n.makeTensorInfo(p.shape,"float32",p.values)}};const b8={kernelName:eC,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{dy:s,input:r}=e,{filterSize:a,strides:o,pad:l,dimRoundingMode:u}=i;b2([s,r],"maxPool3DGrad");const h=l$(r.shape,a,o,1,l,u),p=function(t,e){const n=$L(e.outShape,"int32"),i=e.strideDepth,s=e.strideHeight,r=e.strideWidth,a=e.dilationDepth,o=e.dilationHeight,l=e.dilationWidth,u=e.effectiveFilterDepth,h=e.effectiveFilterHeight,p=e.effectiveFilterWidth,c=e.padInfo.front,d=e.padInfo.top,f=e.padInfo.left;for(let m=0;m=w&&(w=o,S=n*h*p+s*h+a)}}}n.set(S,m,_,i,s,g)}}}return n}(n.bufferSync(r),h),c=h.strideDepth,d=h.strideHeight,f=h.strideWidth,m=h.dilationDepth,g=h.dilationHeight,_=h.dilationWidth,T=h.effectiveFilterDepth,y=h.effectiveFilterHeight,I=h.effectiveFilterWidth,E=T-1-h.padInfo.front,b=I-1-h.padInfo.left,v=y-1-h.padInfo.top,w=$L(r.shape,"float32"),S=n.bufferSync(s);for(let t=0;t=h.outDepth||Math.floor(i)!==i))for(let s=0;s=h.outHeight||Math.floor(r)!==r))for(let a=0;a=h.outWidth||Math.floor(u)!==u)continue;const c=T*y*I-1-p.get(t,i,r,u,e)===n*y*I+s*I+a?1:0;if(0===c)continue;l+=S.get(t,i,r,u,e)*c}}}w.set(l,t,n,i,s,e)}return n.makeTensorInfo(w.shape,w.dtype,w.values)}};const v8={kernelName:ZM,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{dy:s,input:r,output:a}=e,o=r;b2([r,a],"maxPoolGrad");const{filterSize:l,strides:u,pad:h,dimRoundingMode:p}=i,c=o$(o.shape,l,u,1,h,p),d=n.data.get(o.dataId).values,f=$L(c.outShape,o.dtype,F5(d,o.shape,o.dtype,c).values),m=c.strideHeight,g=c.strideWidth,_=c.dilationHeight,T=c.dilationWidth,y=c.effectiveFilterHeight,I=c.effectiveFilterWidth,E=I-1-c.padInfo.left,b=y-1-c.padInfo.top,v=$L(o.shape,"float32"),w=n.data.get(s.dataId).values,S=$L(s.shape,"float32",w);for(let t=0;t=c.outHeight||Math.floor(i)!==i))for(let s=0;s=c.outWidth||Math.floor(o)!==o)continue;const l=y*I-1-f.get(t,i,o,e)===n*I+s?1:0;if(0===l)continue;a+=S.get(t,i,o,e)*l}}v.set(a,t,n,i,e)}return n.makeTensorInfo(v.shape,v.dtype,v.values)}}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const w8={kernelName:nC,backendName:"cpu",kernelFunc:({inputs:t,attrs:e,backend:n})=>{const{x:i}=t,{filterSize:s,strides:r,pad:a,includeBatchInIndex:o}=e,l=n;b2(i,"MaxPoolWithArgmax");const u=l.data.get(i.dataId).values,h=o$(i.shape,s,r,[1,1],a),[p,c]= /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i,s){const r=L5(t,0,n,jA(e),s,"max"),a=F5(t,e,n,s,!0,i);return[r.values,a.values]}(u,i.shape,i.dtype,o,h),d=l.write(p,h.outShape,i.dtype),f=l.write(c,h.outShape,i.dtype);return[{dataId:d,shape:h.outShape,dtype:i.dtype},{dataId:f,shape:h.outShape,dtype:"int32"}]}};const S8={kernelName:iC,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r,keepDims:a}=i,o=kA(r,s.shape),l=bA(gB(s.shape,o)[1]),u=[],h=n.makeTensorInfo([],"float32",new Float32Array([l]));u.push(h);const p=F2({inputs:{x:s},backend:n,attrs:{dtype:"float32"}});u.push(p);const c=B6({inputs:{a:p,b:h},backend:n});u.push(c);const d=w6({inputs:{x:c},backend:n,attrs:{axis:r,keepDims:a}});return u.forEach((t=>n.disposeIntermediateTensorInfo(t))),d}};const x8={kernelName:sC,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r,keepDims:a}=i;b2(s,"min");const o=kA(r,s.shape);let l=o;const u=yB(l,s.shape.length);let h=s;null!=u&&(h=J3({inputs:{x:s},backend:n,attrs:{perm:u}}),l=EB(l.length,s.shape.length)),TB("min",l,h.shape.length);const[p,c]=gB(h.shape,l),d=bA(c),f=ZA(bA(p),h.dtype),m=n.data.get(h.dataId).values;for(let t=0;tt[0]+s.shape[e]+t[1])),l=r.map((t=>t[0])),u=r.map(((t,e)=>t[0]+s.shape[e])),h="reflect"===a?0:1,p=n.data.get(s.dataId).values,c=s.shape.length,d=jA(s.shape),f=bA(o),m=o.length,g=jA(o),_=LA(s.dtype,f);for(let t=0;t=u[t]&&(e[t]=2*(u[t]-1)-e[t]+h);e=e.map(((t,e)=>t-l[e]));const n=nO(e,c,d);_[t]=p[n]}return{dataId:n.write(_,o,s.dtype),shape:o,dtype:s.dtype}}},A8=R2(((t,e)=>{const n=t%e;return t<0&&e<0||t>=0&&e>=0?n:(n+e)%e})),O8=$2(oC,A8),M8={kernelName:oC,backendName:"cpu",kernelFunc:O8}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function C8(t){const{inputs:e,backend:n,attrs:i}=t,{logits:s}=e,{dim:r}=i,a=s.shape.length;let o=r;if(-1===o&&(o=a-1),o!==a-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${a} and dim was ${o}`);const l=kA([o],s.shape),u=T8({inputs:{x:s},backend:n,attrs:{reductionIndices:l,keepDims:!1}}),h=_B(u.shape,l),p=h5({inputs:{x:u},backend:n,attrs:{shape:h}}),c=H4({inputs:{a:s,b:p},backend:n}),d=a3({inputs:{x:c},backend:n}),f=w6({inputs:{x:d},backend:n,attrs:{axis:l,keepDims:!1}}),m=h5({inputs:{x:f},backend:n,attrs:{shape:h}}),g=B6({inputs:{a:d,b:m},backend:n});return n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),g}const N8={kernelName:tN,backendName:"cpu",kernelFunc:C8};const k8={kernelName:lC,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{logits:s}=e,{numSamples:r,seed:a,normalized:o}=i;b2(s,"multinomial");const l=o?s:C8({inputs:{logits:s},backend:n,attrs:{dim:-1}}),u=l.shape[0],h=l.shape[1],p=n.data.get(l.dataId).values,c=[u,r],d=ZA(bA(c),"int32");for(let t=0;t=0&&p[t]{IA(r,t.shape,"All tensors passed to stack must have matching shapes"),yA(a===t.dtype,(()=>"All tensors passed to stack must have matching dtypes"))}));const o=[],l=Q5({inputs:e.map((t=>{const e=F6({inputs:{input:t},backend:n,attrs:{dim:s}});return o.push(e),e})),backend:n,attrs:{axis:s}});return o.forEach((t=>n.disposeIntermediateTensorInfo(t))),l}const W8={kernelName:_C,backendName:"cpu",kernelFunc:H8};const z8={kernelName:TC,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{paddings:r,constantValue:a}=i;b2(s,"pad");const o=r.map(((t,e)=>t[0]+s.shape[e]+t[1])),l=r.map((t=>t[0])),u=n.data.get(s.dataId).values,h=bA(s.shape),p=s.shape.length,c=jA(s.shape),d=bA(o),f=o.length,m=jA(o),g=LA(s.dtype,d);0!==a&&g.fill(a);for(let t=0;tt+l[e])),f,m)]=u[t]}return{dataId:n.write(g,o,s.dtype),shape:o,dtype:s.dtype}}},X8=R2(((t,e)=>Math.pow(t,e))),j8=$2(IC,X8),q8={kernelName:IC,backendName:"cpu",kernelFunc:j8};const K8={kernelName:vC,backendName:"cpu",kernelFunc: /** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{paramsNestedSplits:s,paramsDenseValues:r,indices:a}=e,{outputRaggedRank:o}=i,l=s.map((t=>n.data.get(t.dataId).values)),u=s.map((t=>t.shape)),h=n.data.get(r.dataId).values,p=n.data.get(a.dataId).values,[c,d,f]=r4(l,u,h,r.shape,r.dtype,p,a.shape),m=c.map((t=>n.makeTensorInfo([t.length],"int32",t))),g=n.makeTensorInfo(f,r.dtype,d);return m.concat([g])}};const Q8={kernelName:wC,backendName:"cpu",kernelFunc: /** * @license * Copyright 2022 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n}=t,{starts:i,limits:s,deltas:r}=e,a=n.data.get(i.dataId).values,o=n.data.get(s.dataId).values,l=n.data.get(r.dataId).values,[u,h]=o4(a,i.shape,i.dtype,o,s.shape,l,r.shape);return[n.makeTensorInfo([u.length],"int32",u),n.makeTensorInfo([h.length],i.dtype,h)]}};const J8={kernelName:SC,backendName:"cpu",kernelFunc: /** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{shape:s,values:r,defaultValue:a,rowPartitionTensors:o}=e,{rowPartitionTypes:l}=i,u=n.data.get(s.dataId).values,h=n.data.get(r.dataId).values,p=n.data.get(a.dataId).values,c=o.map((t=>n.data.get(t.dataId).values)),d=o.map((t=>t.shape)),[f,m]=c4(u,s.shape,h,r.shape,r.dtype,p,a.shape,c,d,l);return n.makeTensorInfo(f,r.dtype,m)}};const Z8={kernelName:xC,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{backend:e,attrs:n}=t,{start:i,stop:s,dtype:r,step:a}=n,o=d4(i,s,a,r);return e.makeTensorInfo([o.length],r,o)}},t9=K2(AC,(t=>1/t)),e9={kernelName:AC,backendName:"cpu",kernelFunc:t9};const n9={kernelName:kC,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{images:s}=e,{alignCorners:r,halfPixelCenters:a,size:o}=i;b2(s,"resizeBilinear");const l=jA(s.shape),[u,h]=o,[p,c,d,f]=s.shape,m=n.data.get(s.dataId).values,g=new Float32Array(bA([p,u,h,f])),_=[r&&u>1?c-1:c,r&&h>1?d-1:d],T=[r&&u>1?u-1:u,r&&h>1?h-1:h];let y=0;const I=_[0]/T[0],E=_[1]/T[1];for(let t=0;t1?u-1:u,a&&d>1?h-1:h],g=[a&&c>1?c-1:c,a&&d>1?d-1:d],_=m[0]/g[0],T=m[1]/g[1],y=n.data.get(r.dataId).values;let I=0;for(let t=0;t1?c-1:c,r&&h>1?d-1:d],T=[r&&u>1?u-1:u,r&&h>1?h-1:h],y=_[0]/T[0],I=_[1]/T[1];let E=0;for(let t=0;t1?h-1:h,a&&f>1?p-1:p],T=[a&&d>1?d-1:d,a&&f>1?f-1:f],y=_[0]/T[0],I=_[1]/T[1],E=1/y,b=1/I,v=2*Math.ceil(E)+2,w=2*Math.ceil(b)+2;for(let t=0;t=d)continue;const c=e+u*l[1],m=u*y;if(t===Math.min(h-1,a?Math.round(m):Math.floor(m)))for(let t=0;t=f)continue;const s=c+e*l[2],r=e*I;i===Math.min(p-1,a?Math.round(r):Math.floor(r))&&(o+=g[s+n])}}m[r+n]=o}}}}return n.makeTensorInfo(s.shape,s.dtype,m)}};const a9={kernelName:FC,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{dims:r}=i;b2(s,"reverse");const a=s.shape.length,o=kA(r,s.shape);if(0===a)return C2({inputs:{x:s},backend:n});const l=new wk(s.shape,s.dtype),u=n.bufferSync(s);for(let t=0;tn[t]=s.shape[t]-1-n[t])),l.set(u.get(...n),...e)}return n.makeTensorInfo(l.shape,l.dtype,l.values)}},o9={kernelName:RN,backendName:"cpu",kernelFunc:({inputs:t,attrs:e,backend:n})=>{const{image:i}=t,{radians:s,fillValue:r,center:a}=e,o=n,l=LA(i.dtype,bA(i.shape)),[u,h,p,c]=i.shape,[d,f]=_G(a,h,p),m=Math.sin(s),g=Math.cos(s),_=o.data.get(i.dataId).values;for(let t=0;t=0&&I=0&&E{const e=Math.floor(t);return t-e<.5?Math.floor(t):t-e>.5?Math.ceil(t):e%2==0?e:e+1})),u9={kernelName:PC,backendName:"cpu",kernelFunc:l9};const h9={kernelName:BC,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{indices:s,updates:r}=e,{shape:a}=i,{sliceRank:o,numUpdates:l,sliceSize:u,strides:h,outputSize:p}=cP(0,s,a),c=_4(n.bufferSync(s),n.bufferSync(r),a,p,u,l,o,h,0,!0);return n.makeTensorInfo(a,c.dtype,c.values)}}; /** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function p9(t,e){let n=0,i=t.length,s=0;for(;n1||1===s.shape.length?1:bA(s.shape.slice(1));for(let t=0;tt>=0?g9*t:m9*(Math.exp(t)-1))),T9={kernelName:GC,backendName:"cpu",kernelFunc:_9},y9=K2(XC,(t=>t<0?-1:t>0?1:0)),I9={kernelName:XC,backendName:"cpu",kernelFunc:y9},E9=K2(WC,(t=>Math.sin(t))),b9={kernelName:WC,backendName:"cpu",kernelFunc:E9},v9=K2(zC,(t=>Math.sinh(t))),w9={kernelName:zC,backendName:"cpu",kernelFunc:v9},S9=Math.log(1.1920928955078125e-7)+2,x9=K2(qC,(t=>{const e=t>-S9,n=tNumber(t))))),n.makeTensorInfo([m.length],i.dtype,new Int32Array(m))]}};const M9={kernelName:nN,backendName:"cpu",kernelFunc: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n}=t,{inputIndices:i,inputShape:s,newShape:r}=e;if(2!==i.shape.length)throw new Error(`Input indices should be a matrix but received shape\n ${i.shape}`);if(1!==s.shape.length)throw new Error(`Input shape should be a vector but received shape\n ${s.shape}`);if(1!==r.shape.length)throw new Error(`Target shape should be a vector but received shape ${r.shape}`);const a=Array.from(n.data.get(s.dataId).values),o=n.data.get(i.dataId).values,l=Array.from(n.data.get(r.dataId).values),[u,h,p]=S4(o,i.shape,i.dtype,a,l);return[n.makeTensorInfo(h,i.dtype,u),n.makeTensorInfo([p.length],r.dtype,new Int32Array(p))]}};const C9={kernelName:iN,backendName:"cpu",kernelFunc: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n}=t,{data:i,indices:s,segmentIds:r}=e;if(i.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==s.shape.length)throw new Error(`Indices should be a vector but received shape\n ${s.shape}`);if(1!==r.shape.length)throw new Error(`Segment ids should be a vector but received shape\n ${r.shape}`);if(s.shape[0]!==r.shape[0])throw new Error("segmentIds and indices should have same size.");const a=n.data.get(i.dataId).values,o=n.data.get(s.dataId).values,l=n.data.get(r.dataId).values,[u,h]=x4(a,i.shape,i.dtype,o,l,!0);return n.makeTensorInfo(h,i.dtype,u)}};const N9={kernelName:sN,backendName:"cpu",kernelFunc: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n}=t,{data:i,indices:s,segmentIds:r}=e;if(i.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==s.shape.length)throw new Error(`Indices should be a vector but received shape\n ${s.shape}`);if(1!==r.shape.length)throw new Error(`Segment ids should be a vector but received shape\n ${r.shape}`);if(s.shape[0]!==r.shape[0])throw new Error("segmentIds and indices should have same size.");const a=n.data.get(i.dataId).values,o=n.data.get(s.dataId).values,l=n.data.get(r.dataId).values,[u,h]=x4(a,i.shape,i.dtype,o,l);return n.makeTensorInfo(h,i.dtype,u)}};const k9={kernelName:rN,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{sparseIndices:s,sparseValues:r,defaultValue:a}=e,{outputShape:o}=i,{sliceRank:l,numUpdates:u,sliceSize:h,strides:p,outputSize:c}=cP(0,s,o),d=!1,f=n.bufferSync(s);let m;switch(r.dtype){case"bool":m=_4(f,n.bufferSync(r),o,c,h,u,l,p,Boolean(n.data.get(a.dataId).values[0]),d);break;case"float32":m=_4(f,n.bufferSync(r),o,c,h,u,l,p,n.data.get(a.dataId).values[0],d);break;case"int32":m=_4(f,n.bufferSync(r),o,c,h,u,l,p,n.data.get(a.dataId).values[0],d);break;case"string":m=_4(f,n.bufferSync(r),o,c,h,u,l,p,hk(n.data.get(a.dataId).values[0]),d);break;default:throw new Error(`Unsupported type ${r.dtype}`)}return n.makeTensorInfo(o,m.dtype,m.values)}};const D9={kernelName:ZC,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{numOrSizeSplits:r,axis:a}=i,o=kA(a,s.shape)[0],l=qG(s,r,o),u=new Array(s.shape.length).fill(0),h=s.shape.slice();return l.map((t=>{const e=[...h];e[o]=t;const i=b4({inputs:{x:s},backend:n,attrs:{begin:u,size:e}});return u[o]+=t,i}))}},L9={kernelName:oN,backendName:"cpu",kernelFunc:({inputs:t,backend:e})=>{const{x:n}=t,i=e;b2(n,"square");const s=i.data.get(n.dataId).values,r=new Float32Array(s.length);for(let t=0;t{const n=e;return isNaN(t)?NaN:t>0?1:n.alpha})),P9={kernelName:SN,backendName:"cpu",kernelFunc:F9};const $9={kernelName:uN,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{begin:r,end:a,strides:o,beginMask:l,endMask:u,ellipsisMask:h,newAxisMask:p,shrinkAxisMask:c}=i;b2(s,"stridedSlice");const{finalShapeSparse:d,finalShape:f,isIdentity:m,sliceDim0:g,isSimpleSlice:_,begin:T,end:y,strides:I}=MP(s.shape,r,a,o,l,u,h,p,c);let E;if(m)E=h5({inputs:{x:s},backend:n,attrs:{shape:f}});else if(g||_){yA(s.shape.length>=1,(()=>`Input must have rank at least 1, got: ${s.shape.length}`));const t=_P(T,y,I),e=b4({inputs:{x:s},backend:n,attrs:{begin:T,size:t}});E=h5({inputs:{x:e},backend:n,attrs:{shape:f}}),n.disposeIntermediateTensorInfo(e)}else{const t=F4(d,n.bufferSync(s),I,T);E=n.makeTensorInfo(f,t.dtype,t.values)}return E}};const B9={kernelName:hN,backendName:"cpu",kernelFunc: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{separator:s,nGramWidths:r,leftPad:a,rightPad:o,padWidth:l,preserveShortSequences:u}=i,{data:h,dataSplits:p}=e,c=n.data.get(h.dataId).values,d=n.data.get(p.dataId).values,[f,m]=$4(c,d,s,r,a,o,l,u);return[n.makeTensorInfo([f.length],"string",f),n.makeTensorInfo(p.shape,"int32",m)]}};const V9={kernelName:pN,backendName:"cpu",kernelFunc: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{skipEmpty:s}=i,{input:r,delimiter:a}=e;if("string"!==r.dtype)throw new Error("Input must be of datatype string");if(1!==r.shape.length)throw new Error(`Input must be a vector, got shape: ${r.shape}`);if(0!==a.shape.length)throw new Error(`Delimiter must be a scalar, got shape: ${a.shape}`);const o=n.data.get(r.dataId).values,l=n.data.get(a.dataId).values[0],[u,h,p]=V4(o,l,s),c=h.length;return[n.makeTensorInfo([c,2],"int32",u),n.makeTensorInfo([c],"string",h),n.makeTensorInfo([2],"int32",new Int32Array(p))]}};const U9={kernelName:cN,backendName:"cpu",kernelFunc: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{numBuckets:s}=i,{input:r}=e;if("string"!==r.dtype)throw new Error("Input must be of datatype string");if(s<=0)throw new Error("Number of buckets must be at least 1");const a=U4(n.data.get(r.dataId).values,s);return n.makeTensorInfo(r.shape,"int32",a)}},Y9=K2(fN,(t=>Math.tan(t))),G9={kernelName:fN,backendName:"cpu",kernelFunc:Y9},H9=K2(mN,(t=>Math.tanh(t)));const W9={kernelName:VC,backendName:"cpu",kernelFunc: /** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n}=t,{tensor:i,indices:s,updates:r}=e,{sliceRank:a,numUpdates:o,sliceSize:l,strides:u,outputSize:h}=cP(0,s,i.shape),p=n.bufferSync(s),c=n.bufferSync(r),d=n.bufferSync(i),f=_4(p,c,i.shape,h,l,o,a,u,d,!1);return n.makeTensorInfo(i.shape,f.dtype,f.values)}};const z9={kernelName:gN,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{reps:r}=i;b2(s,"tile");const a=z4(n.bufferSync(s),r);return n.makeTensorInfo(a.shape,a.dtype,a.values)}};const X9={kernelName:_N,backendName:"cpu",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{k:r,sorted:a}=i;b2(s,"topk");const o=n.data.get(s.dataId).values,[l,u]=q4(o,s.shape,s.dtype,r,a);return[n.makeTensorInfo(l.shape,l.dtype,l.values),n.makeTensorInfo(u.shape,u.dtype,u.values)]}};const j9={kernelName:TN,backendName:"cpu",kernelFunc: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,attrs:n,backend:i}=t,{image:s,transforms:r}=e,{interpolation:a,fillMode:o,fillValue:l,outputShape:u}=n,[h,p,c,d]=s.shape,[f,m]=null!=u?u:[p,c],g=[h,f,m,d],_=jA(s.shape),T=_[0],y=_[1],I=_[2],E=jA(g),b=E[0],v=E[1],w=E[2],S=LA(s.dtype,bA(g));S.fill(l);const x=i.data.get(s.dataId).values,R=i.data.get(r.dataId).values;for(let t=0;te-1)if(e<=1)n=0;else{const t=2*e;n-=t*Math.trunc(n/t),n>=e&&(n=t-n-1)}return dA(0,n,e-1)}(t,e);case"wrap":return function(t,e){let n=t;if(n<0)if(e<=1)n=0;else{const t=e-1;n+=e*(Math.trunc(-n/t)+1)}else if(n>e-1)if(e<=1)n=0;else{const t=e-1;n-=e*Math.trunc(n/t)}return dA(0,n,e-1)}(t,e);case"nearest":return function(t,e){return dA(0,t,e-1)}(t,e);default:return function(t){return t}(t)}}function K9(t,e,n,i,s,r,a,o,l,u,h){return 0<=o&&on.disposeIntermediateTensorInfo(t))),p}},n7=[f5,x2,g5,T5,G2,y5,I5,E5,b5,v5,S5,R5,O5,N5,D5,$5,B5,V5,U5,d5,Y5,G5,H5,j2,W5,P2,t3,X5,O2,j5,J5,t6,e6,n6,i6,s6,r6,o6,u6,h6,p6,c6,d6,f6,g6,_6,T6,y6,I6,E6,b6,v6,x6,Z4,R6,s3,L6,o3,P6,h3,H6,z6,X6,d3,g3,j6,q6,K6,Q6,E3,w3,N2,J6,K5,t8,n8,s8,e5,R3,M3,r8,D3,o8,h8,c8,m8,g8,_8,y8,$3,I8,E8,b8,v8,w8,S8,x8,U3,R8,M8,k8,W3,X3,L8,P8,B8,K3,V8,G8,W8,z8,q8,s5,e4,K8,Q8,J8,Z8,D2,V6,e9,a5,l5,p5,n9,i9,s9,r9,a9,o9,u9,g4,h9,d9,f9,T9,I4,I9,b9,w9,v4,N8,R9,A9,O9,M9,C9,N9,k9,D9,O4,L9,N4,L4,P9,$9,B9,V9,U9,W4,S6,G9,{kernelName:mN,backendName:"cpu",kernelFunc:H9},W9,z9,X9,j9,Z3,Z9,t7,e7,Y8];for(const t of n7)$N(t); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const i7={},s7={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function r7(t,e){i7[t]=e}function a7(t,e){if(!(t in i7)||null!=e){const n=function(t,e){if(1!==t&&2!==t)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");const n=null==e?function(t){if(lO().getBool("IS_SAFARI")||"undefined"==typeof OffscreenCanvas||2!==t){if("undefined"!=typeof document)return document.createElement("canvas");throw new Error("Cannot create a canvas in this context")}return new OffscreenCanvas(300,150)}(t):e;n.addEventListener("webglcontextlost",(e=>{e.preventDefault(),delete i7[t]}),!1),lO().getBool("SOFTWARE_WEBGL_ENABLED")&&(s7.failIfMajorPerformanceCaveat=!1);if(1===t)return n.getContext("webgl",s7)||n.getContext("experimental-webgl",s7);return n.getContext("webgl2",s7)}(t,e);if(null===n)return console.log("Could not get context for WebGL version",t),null;i7[t]=n}const n=i7[t];return null==n||n.isContextLost()?(delete i7[t],a7(t)):(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),i7[t])} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ var o7,l7,u7;function h7(t,e){return[e,t]}function p7(t){const e=bA(t);return AA(Math.ceil(e/4))}function c7(t,e){return[Math.max(1,Math.ceil(e/2)),Math.max(1,Math.ceil(t/2))]}function d7(t,e){const n=t;let i,s,r,a,o,l,u,h,p,c;return 2===lO().getNumber("WEBGL_VERSION")?(i=n.R32F,s=n.R16F,r=n.RGBA16F,a=n.RGBA32F,o=n.RED,u=4,h=1,p=n.HALF_FLOAT,c=n.FLOAT,l=n.RGBA8):(i=t.RGBA,s=t.RGBA,r=t.RGBA,a=n.RGBA,o=t.RGBA,u=4,h=4,p=null!=e?e.HALF_FLOAT_OES:null,c=t.FLOAT,l=t.RGBA),{internalFormatFloat:i,internalFormatHalfFloat:s,internalFormatPackedHalfFloat:r,internalFormatPackedFloat:a,textureFormatFloat:o,downloadTextureFormat:l,downloadUnpackNumChannels:u,defaultNumChannels:h,textureTypeHalfFloat:p,textureTypeFloat:c}} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function f7(t,e){const n=e();return lO().getBool("DEBUG")&&function(t){const e=t.getError();if(e!==t.NO_ERROR)throw new Error("WebGL Error: "+T7(t,e))}(t),n}!function(t){t[t.DENSE=0]="DENSE",t[t.SHARED_BATCH=1]="SHARED_BATCH"}(o7||(o7={})),function(t){t[t.RENDER=0]="RENDER",t[t.UPLOAD=1]="UPLOAD",t[t.PIXELS=2]="PIXELS",t[t.DOWNLOAD=3]="DOWNLOAD"}(l7||(l7={})),function(t){t[t.UNPACKED_FLOAT16=0]="UNPACKED_FLOAT16",t[t.UNPACKED_FLOAT32=1]="UNPACKED_FLOAT32",t[t.PACKED_4X1_UNSIGNED_BYTE=2]="PACKED_4X1_UNSIGNED_BYTE",t[t.PACKED_2X2_FLOAT32=3]="PACKED_2X2_FLOAT32",t[t.PACKED_2X2_FLOAT16=4]="PACKED_2X2_FLOAT16"}(u7||(u7={}));const m7=5.96e-8,g7=65504;function _7(t){return!!(lO().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||0===t||m7t.getExtension(e)),'Extension "'+e+'" not supported on this browser.')}function I7(t,e){const n=H7(t,(()=>t.createShader(t.VERTEX_SHADER)),"Unable to create vertex WebGLShader.");if(f7(t,(()=>t.shaderSource(n,e))),f7(t,(()=>t.compileShader(n))),!1===t.getShaderParameter(n,t.COMPILE_STATUS))throw console.log(t.getShaderInfoLog(n)),new Error("Failed to compile vertex shader.");return n}function E7(t,e){const n=H7(t,(()=>t.createShader(t.FRAGMENT_SHADER)),"Unable to create fragment WebGLShader.");if(f7(t,(()=>t.shaderSource(n,e))),f7(t,(()=>t.compileShader(n))),lO().get("ENGINE_COMPILE_ONLY"))return n;if(!1===t.getShaderParameter(n,t.COMPILE_STATUS))throw v7(e,t.getShaderInfoLog(n)),new Error("Failed to compile fragment shader.");return n}const b7=/ERROR: [0-9]+:([0-9]+):/g;function v7(t,e){const n=b7.exec(e);if(null==n)return console.log(`Couldn't parse line number in error: ${e}`),void console.log(t);const i=+n[1],s=t.split("\n"),r=s.length.toString().length+2,a=s.map(((t,e)=>MA((e+1).toString(),r)+t));let o=0;for(let t=0;tt.createProgram()),"Unable to create WebGLProgram.")}function S7(t,e){if(f7(t,(()=>t.linkProgram(e))),!lO().get("ENGINE_COMPILE_ONLY")&&!1===t.getProgramParameter(e,t.LINK_STATUS))throw console.log(t.getProgramInfoLog(e)),new Error("Failed to link vertex and fragment shaders.")}function x7(t,e){if(f7(t,(()=>t.validateProgram(e))),!1===t.getProgramParameter(e,t.VALIDATE_STATUS))throw console.log(t.getProgramInfoLog(e)),new Error("Shader program validation failed.")}function R7(t,e){const n=H7(t,(()=>t.createBuffer()),"Unable to create WebGLBuffer");return f7(t,(()=>t.bindBuffer(t.ARRAY_BUFFER,n))),f7(t,(()=>t.bufferData(t.ARRAY_BUFFER,e,t.STATIC_DRAW))),n}function A7(t,e){const n=H7(t,(()=>t.createBuffer()),"Unable to create WebGLBuffer");return f7(t,(()=>t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n))),f7(t,(()=>t.bufferData(t.ELEMENT_ARRAY_BUFFER,e,t.STATIC_DRAW))),n}function O7(){return 2===lO().getNumber("WEBGL_VERSION")?1:4}function M7(t){return H7(t,(()=>t.createTexture()),"Unable to create WebGLTexture.")}function C7(t,e){const n=lO().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(t<=0||e<=0){throw new Error("Requested texture size "+`[${t}x${e}]`+" is invalid.")}if(t>n||e>n){throw new Error("Requested texture size "+`[${t}x${e}]`+" greater than WebGL maximum on this browser / GPU "+`[${n}x${n}]`+".")}}function N7(t){return H7(t,(()=>t.createFramebuffer()),"Unable to create WebGLFramebuffer.")}function k7(t,e,n,i,s,r,a){const o=t.getAttribLocation(e,n);return-1!==o&&(f7(t,(()=>t.bindBuffer(t.ARRAY_BUFFER,i))),f7(t,(()=>t.vertexAttribPointer(o,s,t.FLOAT,!1,r,a))),f7(t,(()=>t.enableVertexAttribArray(o))),!0)}function D7(t,e,n){W7(t,n),f7(t,(()=>t.activeTexture(t.TEXTURE0+n))),f7(t,(()=>t.bindTexture(t.TEXTURE_2D,e)))}function L7(t,e){W7(t,e),f7(t,(()=>t.activeTexture(t.TEXTURE0+e))),f7(t,(()=>t.bindTexture(t.TEXTURE_2D,null)))}function F7(t,e,n){return H7(t,(()=>t.getUniformLocation(e,n)),'uniform "'+n+'" not present in program.')}function P7(t,e,n){return t.getUniformLocation(e,n)}function $7(t,e,n,i){f7(t,(()=>D7(t,e,i))),f7(t,(()=>t.uniform1i(n,i)))}function B7(t){f7(t,(()=>t.bindFramebuffer(t.FRAMEBUFFER,null))),f7(t,(()=>t.viewport(0,0,t.canvas.width,t.canvas.height))),f7(t,(()=>t.scissor(0,0,t.canvas.width,t.canvas.height)))}function V7(t,e,n){f7(t,(()=>t.bindFramebuffer(t.FRAMEBUFFER,n))),f7(t,(()=>t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0)))}function U7(t,e){f7(t,(()=>t.bindFramebuffer(t.FRAMEBUFFER,e))),f7(t,(()=>t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,null,0)))}function Y7(t){const e=t.checkFramebufferStatus(t.FRAMEBUFFER);if(e!==t.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+G7(t,e))}function G7(t,e){switch(e){case t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case t.FRAMEBUFFER_UNSUPPORTED:return"FRAMEBUFFER_UNSUPPORTED";default:return`unknown error ${e}`}}function H7(t,e,n){const i=f7(t,(()=>e()));if(null==i)throw new Error(n);return i}function W7(t,e){const n=t.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,i=e+t.TEXTURE0;if(in){throw new Error(`textureUnit must be in ${`[gl.TEXTURE0, gl.TEXTURE${n}]`}.`)}}function z7(t,e=2){return bA(t.slice(0,t.length-e))}function X7(t){if(0===t.length)throw Error("Cannot get rows and columns of an empty shape array.");return[t.length>1?t[t.length-2]:1,t[t.length-1]]}function j7(t){let e=[1,1,1];return 0===t.length||1===t.length&&1===t[0]||(e=[z7(t),...X7(t)]),e}function q7(t,e=!1){let n=lO().getNumber("WEBGL_MAX_TEXTURE_SIZE"),i=lO().getNumber("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE");if(i===1/0&&lO().getBool("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE")&&(i=n/2),e&&(n*=2,i*=2,1===(t=t.map(((e,n)=>n>=t.length-2?fA(t[n]):t[n]))).length&&(t=[2,t[0]])),2!==t.length){const e=DA(t);t=e.newShape}let s=bA(t),r=null;t.length<=1&&s<=n?r=[1,s]:2===t.length&&t[0]<=n&&t[1]<=n?r=t:3===t.length&&t[0]*t[1]<=n&&t[2]<=n?r=[t[0]*t[1],t[2]]:3===t.length&&t[0]<=n&&t[1]*t[2]<=n?r=[t[0],t[1]*t[2]]:4===t.length&&t[0]*t[1]*t[2]<=n&&t[3]<=n?r=[t[0]*t[1]*t[2],t[3]]:4===t.length&&t[0]<=n&&t[1]*t[2]*t[3]<=n&&(r=[t[0],t[1]*t[2]*t[3]]);const a=null!=r&&Math.max(...r)>i&&Math.min(...r)<=(e?2:1)&&Math.min(...r)>0;if(null==r||a)if(e){const e=z7(t);let n=2,i=2;t.length&&([n,i]=X7(t)),s=e*(n/2)*(i/2),r=AA(s).map((t=>2*t))}else r=AA(s);return r}function K7(t){return t%2==0}function Q7(t,e){if(SA(t=t.slice(-2),e=e.slice(-2)))return!0;if(!t.length||!e.length)return!0;if(0===t[0]||0===t[1]||0===e[0]||0===e[1])return!0;if(t.length!==e.length){const n=t[t.length-1],i=e[e.length-1];if(n===i)return!0;if(K7(n)&&K7(i)&&(1===t[0]||1===e[0]))return!0}return t[1]===e[1]&&K7(t[0])&&K7(e[0])}let J7,Z7;function ttt(t){if(null==J7){const e=a7(t);J7=e.getParameter(e.MAX_TEXTURE_SIZE)}return J7}function ett(){J7=null}function ntt(){Z7=null}function itt(t){if(null==Z7){const e=a7(t);Z7=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,Z7)}function stt(t){if(0===t)return 0;let e;const n=a7(t);return e=rtt(n,"EXT_disjoint_timer_query_webgl2")&&2===t?2:rtt(n,"EXT_disjoint_timer_query")?1:0,e}function rtt(t,e){return null!=t.getExtension(e)}function att(t){try{if(null!=a7(t))return!0}catch(t){return console.log("Error when getting WebGL context: ",t),!1}return!1}function ott(t){if(0===t)return!1;const e=a7(t);if(1===t){if(!rtt(e,"OES_texture_float"))return!1}else if(!rtt(e,"EXT_color_buffer_float"))return!1;return utt(e)}function ltt(t){if(0===t)return!1;const e=a7(t);if(1!==t){if(rtt(e,"EXT_color_buffer_float"))return utt(e);const t="EXT_color_buffer_half_float";if(rtt(e,t)){const n=e.getExtension(t);return function(t,e){const n=d7(t,e),i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);const s=1,r=1;t.texImage2D(t.TEXTURE_2D,0,n.internalFormatHalfFloat,s,r,0,n.textureFormatFloat,n.textureTypeHalfFloat,null);const a=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,a),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0);const o=t.checkFramebufferStatus(t.FRAMEBUFFER)===t.FRAMEBUFFER_COMPLETE;return t.bindTexture(t.TEXTURE_2D,null),t.bindFramebuffer(t.FRAMEBUFFER,null),t.deleteTexture(i),t.deleteFramebuffer(a),o}(e,n)}return!1}if(!rtt(e,"OES_texture_float"))return!1;if(!rtt(e,"WEBGL_color_buffer_float"))return!1;return utt(e)}function utt(t){const e=d7(t),n=t.createTexture();t.bindTexture(t.TEXTURE_2D,n);t.texImage2D(t.TEXTURE_2D,0,e.internalFormatFloat,1,1,0,e.textureFormatFloat,e.textureTypeFloat,null);const i=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,i),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,n,0);const s=t.checkFramebufferStatus(t.FRAMEBUFFER)===t.FRAMEBUFFER_COMPLETE;return t.bindTexture(t.TEXTURE_2D,null),t.bindFramebuffer(t.FRAMEBUFFER,null),t.deleteTexture(n),t.deleteFramebuffer(i),s}function htt(t){if(2!==t)return!1;return null!=a7(t).fenceSync}function ptt(t,e){Array.isArray(t)||(t=[t]),t.forEach((t=>{null!=t&&yA("complex64"!==t.dtype,(()=>`${e} does not support complex64 tensors in the WebGL backend.`))}))} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const ctt=lO(); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function dtt(){let t,e,n,i,s,r,a,o,l,u;return 2===lO().getNumber("WEBGL_VERSION")?(t="#version 300 es",e="in",n="out",i="in",s="texture",r="outputColor",a="out vec4 outputColor;",o=lO().getBool("WEBGL2_ISNAN_CUSTOM")?"\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 ":"",l="",u="\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 "):(t="",e="attribute",n="varying",i="varying",s="texture2D",r="gl_FragColor",a="",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 ",l="\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 ",u="\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:t,attribute:e,varyingVs:n,varyingFs:i,texture2D:s,output:r,defineOutput:a,defineSpecialNaN:o,defineSpecialInf:l,defineRound:u}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function ftt(t,e,n="index"){const i=jA(e);return i.map(((e,s)=>`${`int ${t[s]} = ${n} / ${e}`}; ${s===i.length-1?`int ${t[s+1]} = ${n} - ${t[s]} * ${e}`:`index -= ${t[s]} * ${e}`};`)).join("")}function mtt(t,e,n="index"){const i=jA(e);return i.map(((e,s)=>`${`int ${t[s]} = ${n} / outShapeStrides[${s}]`}; ${s===i.length-1?`int ${t[s+1]} = ${n} - ${t[s]} * outShapeStrides[${s}]`:`index -= ${t[s]} * outShapeStrides[${s}]`};`)).join("")}function gtt(t,e,n="index"){const i=function(t,e){const n=t.length,i=t.map((t=>`${e}[${t}]`)),s=new Array(n-1);s[n-2]=i[n-1];for(let t=n-3;t>=0;--t)s[t]=`(${s[t+1]} * ${i[t+1]})`;return s}(t.map(((t,e)=>e)),e);return i.map(((e,s)=>`${`int ${t[s]} = ${n} / ${i[s]}`}; ${s===i.length-1?`int ${t[s+1]} = ${n} - ${t[s]} * ${i[s]}`:`index -= ${t[s]} * ${i[s]}`};`)).join("")}function _tt(t){const e=jA(t).map((t=>t.toString()));return`\n int getFlatIndex(ivec3 coords) {\n return coords.x * ${e[0]} + coords.y * ${e[1]} + coords.z;\n }\n`}ctt.registerFlag("HAS_WEBGL",(()=>ctt.getNumber("WEBGL_VERSION")>0)),ctt.registerFlag("WEBGL_VERSION",(()=>att(2)?2:att(1)?1:0)),ctt.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",(()=>!1)),ctt.registerFlag("WEBGL_BUFFER_SUPPORTED",(()=>2===ctt.get("WEBGL_VERSION"))),ctt.registerFlag("WEBGL_CPU_FORWARD",(()=>!0)),ctt.registerFlag("WEBGL_FORCE_F16_TEXTURES",(()=>!1)),ctt.registerFlag("WEBGL_PACK",(()=>ctt.getBool("HAS_WEBGL"))),ctt.registerFlag("WEBGL_PACK_NORMALIZATION",(()=>ctt.getBool("WEBGL_PACK"))),ctt.registerFlag("WEBGL_PACK_CLIP",(()=>ctt.getBool("WEBGL_PACK"))),ctt.registerFlag("WEBGL_PACK_DEPTHWISECONV",(()=>ctt.getBool("WEBGL_PACK"))),ctt.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",(()=>ctt.getBool("WEBGL_PACK"))),ctt.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",(()=>ctt.getBool("WEBGL_PACK"))),ctt.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",(()=>ctt.getBool("WEBGL_PACK"))),ctt.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",(()=>ctt.getBool("WEBGL_PACK"))),ctt.registerFlag("WEBGL_PACK_REDUCE",(()=>ctt.getBool("WEBGL_PACK"))),ctt.registerFlag("WEBGL_LAZILY_UNPACK",(()=>ctt.getBool("WEBGL_PACK"))),ctt.registerFlag("WEBGL_CONV_IM2COL",(()=>ctt.getBool("WEBGL_PACK"))),ctt.registerFlag("WEBGL_PACK_CONV2DTRANSPOSE",(()=>ctt.getBool("WEBGL_PACK"))),ctt.registerFlag("WEBGL_MAX_TEXTURE_SIZE",(()=>ttt(ctt.getNumber("WEBGL_VERSION")))),ctt.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",(()=>itt(ctt.getNumber("WEBGL_VERSION")))),ctt.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",(()=>{const t=ctt.getNumber("WEBGL_VERSION");return 0===t?0:stt(t)})),ctt.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",(()=>ctt.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!tD())),ctt.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",(()=>ott(ctt.getNumber("WEBGL_VERSION")))),ctt.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",(()=>!ctt.getBool("WEBGL_FORCE_F16_TEXTURES")&&ctt.getBool("WEBGL_RENDER_FLOAT32_CAPABLE"))),ctt.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",(()=>ltt(ctt.getNumber("WEBGL_VERSION")))),ctt.registerFlag("WEBGL_FENCE_API_ENABLED",(()=>htt(ctt.getNumber("WEBGL_VERSION")))),ctt.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",(()=>ctt.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0)),ctt.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD",(()=>-1),(t=>{if("number"!=typeof t)throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be a number but got ${t}.`);if(t<0&&-1!==t)throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never delete) or at least 0, but got ${t}.`)})),ctt.registerFlag("WEBGL_FLUSH_THRESHOLD",(()=>tD()?1:-1),(t=>{if("number"!=typeof t)throw new Error(`WEBGL_FLUSH_THRESHOLD must be a number but got ${t}.`);if(t<0&&-1!==t)throw new Error(`WEBGL_FLUSH_THRESHOLD must be -1 (indicating never manual flush) or at least 0, but got ${t}.`)})),ctt.registerFlag("CPU_HANDOFF_SIZE_THRESHOLD",(()=>128)),ctt.registerFlag("WEBGL_USE_SHAPES_UNIFORMS",(()=>!1)),ctt.registerFlag("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD",(()=>1e5)),ctt.registerFlag("TOPK_K_CPU_HANDOFF_THRESHOLD",(()=>128)),ctt.registerFlag("WEBGL_EXP_CONV",(()=>!1)),ctt.registerFlag("SOFTWARE_WEBGL_ENABLED",(()=>ctt.getBool("IS_TEST"))),ctt.registerFlag("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE",(()=>1/0)),ctt.registerFlag("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE",(()=>!1)),ctt.registerFlag("WEBGL2_ISNAN_CUSTOM",(()=>!1)),ctt.registerFlag("ENGINE_COMPILE_ONLY",(()=>!1));const Ttt="\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:ytt}=yt;function Itt(t,e,n){const i=[];if(t.forEach((t=>{const e=bA(t.shapeInfo.logicalShape);if(t.shapeInfo.isUniform?i.push(`uniform float ${t.name}${e>1?`[${e}]`:""};`):(i.push(`uniform sampler2D ${t.name};`),i.push(`uniform int offset${t.name};`)),n.enableShapeUniforms){const{uniformShape:e}=Ctt(n.packedInputs,t.shapeInfo.logicalShape,t.shapeInfo.texShape);switch(e.length){case 1:i.push(`uniform int ${t.name}Shape;`);break;case 2:i.push(`uniform ivec2 ${t.name}Shape;`);break;case 3:i.push(`uniform ivec3 ${t.name}Shape;`);break;case 4:i.push(`uniform ivec4 ${t.name}Shape;`)}i.push(`uniform ivec2 ${t.name}TexShape;`)}})),n.enableShapeUniforms){switch(e.logicalShape.length){case 1:i.push("uniform int outShape;");break;case 2:i.push("uniform ivec2 outShape;"),i.push("uniform int outShapeStrides;");break;case 3:i.push("uniform ivec3 outShape;"),i.push("uniform ivec2 outShapeStrides;");break;case 4:i.push("uniform ivec4 outShape;"),i.push("uniform ivec3 outShapeStrides;")}i.push("uniform ivec2 outTexShape;")}n.customUniforms&&n.customUniforms.forEach((t=>{i.push(`uniform ${t.type} ${t.name}${t.arrayIndex?`[${t.arrayIndex}]`:""};`)}));const s=i.join("\n"),r=t.map((t=>function(t,e,n=!1,i){let s="";s+=n?btt(t,i):Ett(t,i);const r=t.shapeInfo.logicalShape,a=e.logicalShape;r.length<=a.length&&(s+=n?function(t,e){const n=t.name,i=n.charAt(0).toUpperCase()+n.slice(1),s="get"+i+"AtOutCoords",r=t.shapeInfo.logicalShape.length,a=e.logicalShape.length,o=ytt(t.shapeInfo.logicalShape,e.logicalShape),l=Mtt(a),u=a-r;let h;const p=["x","y","z","w","u","v"];h=0===r?"":a<2&&o.length>=1?"coords = 0;":o.map((t=>`coords.${p[t+u]} = 0;`)).join("\n");let c="";c=a<2&&r>0?"coords":t.shapeInfo.logicalShape.map(((t,e)=>`coords.${p[e+u]}`)).join(", ");let d="return outputValue;";const f=1===bA(t.shapeInfo.logicalShape),m=bA(e.logicalShape),g=1===m;if(1!==r||f||g){if(f&&!g)d=1===a?"\n return vec4(outputValue.x, outputValue.x, 0., 0.);\n ":"\n return vec4(outputValue.x);\n ";else if(o.length){const t=r-2,e=r-1;o.indexOf(t)>-1&&o.indexOf(e)>-1?d="return vec4(outputValue.x);":o.indexOf(t)>-1?d="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":o.indexOf(e)>-1&&(d="return vec4(outputValue.xx, outputValue.zz);")}}else d="\n return vec4(outputValue.xy, outputValue.xy);\n ";return`\n vec4 ${s}() {\n ${l} coords = getOutputCoords();\n ${h}\n vec4 outputValue = get${i}(${c});\n ${d}\n }\n `}(t,e):function(t,e){const n=t.name,i=n.charAt(0).toUpperCase()+n.slice(1),s="get"+i+"AtOutCoords",r=e.texShape,a=t.shapeInfo.texShape,o=t.shapeInfo.logicalShape.length,l=e.logicalShape.length;if(!t.shapeInfo.isUniform&&o===l&&null==t.shapeInfo.flatOffset&&SA(a,r))return`\n float ${s}() {\n return sampleTexture(${n}, resultUV);\n }\n `;const u=Mtt(l),h=ytt(t.shapeInfo.logicalShape,e.logicalShape),p=l-o;let c;const d=["x","y","z","w","u","v"];c=0===o?"":l<2&&h.length>=1?"coords = 0;":h.map((t=>`coords.${d[t+p]} = 0;`)).join("\n");let f="";f=l<2&&o>0?"coords":t.shapeInfo.logicalShape.map(((t,e)=>`coords.${d[e+p]}`)).join(", ");return`\n float ${s}() {\n ${u} coords = getOutputCoords();\n ${c}\n return get${i}(${f});\n }\n `}(t,e));return s}(t,e,n.packedInputs,n.enableShapeUniforms))).join("\n"),a=e.texShape,o=dtt(),l=function(t){return`\n float sampleTexture(sampler2D textureSampler, vec2 uv) {\n return ${t.texture2D}(textureSampler, uv).r;\n }\n `}(o);let u,h,p=function(t){const e=`${t.version}\n precision highp float;\n precision highp int;\n precision highp sampler2D;\n ${t.varyingFs} vec2 resultUV;\n ${t.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 ${t.defineSpecialNaN}\n ${t.defineSpecialInf}\n ${t.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 ${vtt}\n ${wtt}\n ${Stt}\n `;return e}(o);e.isPacked?(u=function(t,e,n){switch(t.length){case 0:return Rtt();case 1:return function(t,e,n){const i=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];if(1===i[0])return 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 * ${i[1]}.0);\n }\n `;if(1===i[1])return 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 * ${i[0]}.0);\n }\n `;if(n)return"\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 ";return`\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${i[0]}, ${i[1]}));\n return 2 * (resTexRC.x * ${i[1]} + resTexRC.y);\n }\n `}(0,e,n);case 2:return function(t,e,n){const i=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];if(SA(t,e))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(${i[0]}, ${i[1]}));\n }\n `;const s=Math.ceil(t[1]/2);if(n)return"\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 ";return`\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${i[0]}, ${i[1]}));\n\n int index = resTexRC.x * ${i[1]} + resTexRC.y;\n int r = 2 * (index / ${s});\n int c = imod(index, ${s}) * 2;\n\n return ivec2(r, c);\n }\n `}(t,e,n);case 3:return function(t,e,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 i=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)],s=Math.ceil(t[2]/2),r=s*Math.ceil(t[1]/2);return`\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${i[0]}, ${i[1]}));\n int index = resTexRC.x * ${i[1]} + resTexRC.y;\n\n int b = index / ${r};\n index -= b * ${r};\n\n int r = 2 * (index / ${s});\n int c = imod(index, ${s}) * 2;\n\n return ivec3(b, r, c);\n }\n `}(t,e,n);default:return function(t,e,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 i=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)],s=Math.ceil(t[t.length-1]/2),r=s*Math.ceil(t[t.length-2]/2);let a=r,o="",l="b, r, c";for(let e=2;e1&&!SA(e,n)&&i.lengtht[e])).join(", ")}function Dtt(t,e,n){const i=[],s=[];let r,a,o,l=null,u=null;u=t.getUniformLocation(n,"NAN",!1),1===lO().getNumber("WEBGL_VERSION")&&(l=t.getUniformLocation(n,"INFINITY",!1));const h=!1;for(const s of e.variableNames){const r={name:s,uniform:t.getUniformLocation(n,s,h),offset:t.getUniformLocation(n,`offset${s}`,h)};e.enableShapeUniforms&&(r.shape=t.getUniformLocation(n,`${s}Shape`,h),r.texShape=t.getUniformLocation(n,`${s}TexShape`,h)),i.push(r)}if(e.enableShapeUniforms&&(r=t.getUniformLocation(n,"outShape",h),o=t.getUniformLocation(n,"outShapeStrides",h),a=t.getUniformLocation(n,"outTexShape",h)),e.customUniforms)for(const i of e.customUniforms)s.push(t.getUniformLocation(n,i.name,h));return{variablesLocations:i,customUniformLocations:s,infLoc:l,nanLoc:u,outShapeLocation:r,outShapeStridesLocation:o,outTexShapeLocation:a}}function Ltt(t,e){if(t.length!==e.length)throw Error(`Binary was compiled with ${t.length} inputs, but was executed with ${e.length} inputs`);t.forEach(((t,n)=>{const i=t.logicalShape,s=e[n],r=s.shape;if(!SA(i,r))throw Error(`Binary was compiled with different shapes than the current args. Shapes ${i} and ${r} must match`);if(t.isUniform&&s.isUniform)return;const a=t.texShape,o=s.isUniform?null:s.texData.texShape;if(!SA(a,o))throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${a} and ${o} must match`)}))}function Ftt(t){return lO().getBool("WEBGL_USE_SHAPES_UNIFORMS")&&t<=4} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Ptt{constructor(t){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=o7.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const e=dtt();this.outputShape=t,this.enableShapeUniforms=Ftt(this.outputShape.length),this.userCode=`\n ivec3 outCoordsFromFlatIndex(int index) {\n ${this.enableShapeUniforms?mtt(["r","c","d"],t):ftt(["r","c","d"],t)}\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 ${e.output} = result;\n }\n `}} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class $tt{constructor(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=o7.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const e=dtt();this.outputShape=t,this.enableShapeUniforms=Ftt(this.outputShape.length),this.userCode=`\n ivec3 outCoordsFromFlatIndex(int index) {\n ${this.enableShapeUniforms?mtt(["r","c","d"],t):ftt(["r","c","d"],t)}\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 ${e.output} = result;\n }\n `}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Btt{constructor(t){this.variableNames=["A"],this.outTexUsage=l7.DOWNLOAD;const e=dtt();this.outputShape=t,this.userCode=`\n ${Ttt}\n\n void main() {\n float x = getAAtOutCoords();\n ${e.output} = encode_float(x);\n }\n `}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Vtt{constructor(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=l7.DOWNLOAD;const e=dtt();this.outputShape=t,this.userCode=`\n ${Ttt}\n\n void main() {\n ivec3 coords = getOutputCoords();\n float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));\n ${e.output} = encode_float(x);\n }\n `}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const Utt={R:0,G:1,B:2,A:3};class Ytt{constructor(t,e=!1,n="RGBA"){this.variableNames=["A"],this.customUniforms=[{name:"texShape",type:"ivec2"}];const i=dtt();this.outputShape=t,this.enableShapeUniforms=Ftt(this.outputShape.length);let s="result";e&&(s="floor(result * 255. + 0.5)");let r="";for(let t=0;tt.bindTexture(o,a))),f7(t,(()=>t.texParameteri(o,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE))),f7(t,(()=>t.texParameteri(o,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE))),f7(t,(()=>t.texParameteri(o,t.TEXTURE_MIN_FILTER,t.NEAREST))),f7(t,(()=>t.texParameteri(o,t.TEXTURE_MAG_FILTER,t.NEAREST))),1===lO().getNumber("WEBGL_VERSION")?f7(t,(()=>t.texImage2D(o,0,i,e,n,0,s,r,null))):f7(t,(()=>t.texStorage2D(o,1,i,e,n))),f7(t,(()=>t.bindTexture(t.TEXTURE_2D,null))),{texture:a,texShape:[n,e]}}function jtt(t){return t.internalFormatFloat}function qtt(t,e,n,i){const[s,r]=h7(e,n);return Xtt(t,s,r,jtt(i),i.textureFormatFloat,t.FLOAT)}function Ktt(t){return t.internalFormatHalfFloat}function Qtt(t,e,n,i){const[s,r]=h7(e,n);return Xtt(t,s,r,Ktt(i),i.textureFormatFloat,i.textureTypeHalfFloat)}function Jtt(t){return t.downloadTextureFormat}function Ztt(t,e,n,i){const[s,r]=h7(e,n);return Xtt(t,s,r,Jtt(i),t.RGBA,t.UNSIGNED_BYTE)}function tet(t){return t.internalFormatPackedFloat}function eet(t,e,n,i){const[s,r]=c7(e,n);return Xtt(t,s,r,tet(i),t.RGBA,t.FLOAT)}function net(t){return t.internalFormatPackedHalfFloat}function iet(t,e,n,i){const[s,r]=c7(e,n);return Xtt(t,s,r,net(i),t.RGBA,i.textureTypeHalfFloat)}function set(t,e,n){f7(t,(()=>t.bindBuffer(t.ARRAY_BUFFER,n)));return k7(t,e,"clipSpacePos",n,3,20,0)&&k7(t,e,"uv",n,2,20,12)}function ret(t,e,n,i,s,r){let a,o,l;f7(t,(()=>t.bindTexture(t.TEXTURE_2D,e))),s instanceof Uint8Array?(a=new Uint8Array(n*i*4),o=t.UNSIGNED_BYTE,l=t.RGBA):(a=new Float32Array(n*i*4),o=t.FLOAT,l=r.internalFormatPackedFloat),a.set(s),2===lO().getNumber("WEBGL_VERSION")?f7(t,(()=>t.texSubImage2D(t.TEXTURE_2D,0,0,0,n,i,t.RGBA,o,a))):f7(t,(()=>t.texImage2D(t.TEXTURE_2D,0,l,n,i,0,t.RGBA,o,a))),f7(t,(()=>t.bindTexture(t.TEXTURE_2D,null)))}function aet(t,e,n){f7(t,(()=>t.bindTexture(t.TEXTURE_2D,e))),n.data instanceof Uint8Array?2===lO().getNumber("WEBGL_VERSION")?f7(t,(()=>t.texSubImage2D(t.TEXTURE_2D,0,0,0,n.width,n.height,t.RGBA,t.UNSIGNED_BYTE,n.data))):f7(t,(()=>t.texImage2D(t.TEXTURE_2D,0,t.RGBA,n.width,n.height,0,t.RGBA,t.UNSIGNED_BYTE,n.data))):2===lO().getNumber("WEBGL_VERSION")?f7(t,(()=>t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,n))):f7(t,(()=>t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n))),f7(t,(()=>t.bindTexture(t.TEXTURE_2D,null)))}function oet(t,e,n,i){const s=t.createBuffer();f7(t,(()=>t.bindBuffer(t.PIXEL_PACK_BUFFER,s)));const r=16*e*n;return f7(t,(()=>t.bufferData(t.PIXEL_PACK_BUFFER,r,t.STREAM_READ))),f7(t,(()=>t.readPixels(0,0,n,e,t.RGBA,t.FLOAT,0))),f7(t,(()=>t.bindBuffer(t.PIXEL_PACK_BUFFER,null))),s}function uet(t,e,n){const i=t,s=new Float32Array(n);return i.bindBuffer(i.PIXEL_PACK_BUFFER,e),i.getBufferSubData(i.PIXEL_PACK_BUFFER,0,s),i.bindBuffer(i.PIXEL_PACK_BUFFER,null),s}function het(t,e,n,i){const[s,r]=h7(e,n),a=new Uint8Array(e*n*4);return f7(t,(()=>t.readPixels(0,0,s,r,i.downloadTextureFormat,t.UNSIGNED_BYTE,a))),new Float32Array(a.buffer)}function pet(t,e,n,i,s,r,a,o){const l=t,u=new Float32Array(function(t,e){const[n,i]=c7(t,e);return n*i*4}(r,a));return l.bindBuffer(l.PIXEL_PACK_BUFFER,e),l.getBufferSubData(l.PIXEL_PACK_BUFFER,0,u),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),u}function cet(t,e,n){const i=new Float32Array(e*n*4);return f7(t,(()=>t.readPixels(0,0,n,e,t.RGBA,t.FLOAT,i))),i} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class det{constructor(t){this.outputTexture=null,this.program=null,this.disposed=!1,this.itemsToPoll=[];const e=lO().getNumber("WEBGL_VERSION");if(null!=t?(this.gl=t,r7(e,t)):this.gl=a7(e),t=this.gl,2===lO().getNumber("WEBGL_VERSION")){const e=t;this.createVertexArray=()=>f7(e,(()=>e.createVertexArray())),this.bindVertexArray=t=>f7(e,(()=>e.bindVertexArray(t))),this.deleteVertexArray=t=>f7(e,(()=>e.deleteVertexArray(t))),this.getVertexArray=()=>f7(e,(()=>e.getParameter(e.VERTEX_ARRAY_BINDING)))}else if(null!=t){const e=t.getExtension("OES_vertex_array_object");if(null==e)throw new Error("All WebGL1 implementations are expected to offer OES_vertex_array_object.");this.createVertexArray=()=>f7(t,(()=>e.createVertexArrayOES())),this.bindVertexArray=n=>f7(t,(()=>e.bindVertexArrayOES(n))),this.deleteVertexArray=n=>f7(t,(()=>e.deleteVertexArrayOES(n))),this.getVertexArray=()=>f7(t,(()=>t.getParameter(e.VERTEX_ARRAY_BINDING_OES)))}let n="WEBGL_color_buffer_float";const i="EXT_color_buffer_half_float";if(this.parallelCompilationExtension=this.gl.getExtension("KHR_parallel_shader_compile"),1===lO().getNumber("WEBGL_VERSION")){const t="OES_texture_float",e="OES_texture_half_float";if(this.textureFloatExtension=y7(this.gl,t),rtt(this.gl,e))this.textureHalfFloatExtension=y7(this.gl,e);else if(lO().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),rtt(this.gl,i))this.colorBufferHalfFloatExtension=y7(this.gl,i);else if(lO().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",rtt(this.gl,n))this.colorBufferFloatExtension=this.gl.getExtension(n);else{if(!rtt(this.gl,i))throw new Error("GL context does not support color renderable floats");this.colorBufferHalfFloatExtension=this.gl.getExtension(i)}this.vertexBuffer=Wtt(this.gl),this.indexBuffer=ztt(this.gl),this.framebuffer=N7(this.gl),this.textureConfig=d7(this.gl,this.textureHalfFloatExtension)}get debug(){return lO().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 t=this.gl;f7(t,(()=>t.finish())),f7(t,(()=>t.bindFramebuffer(t.FRAMEBUFFER,null))),f7(t,(()=>t.deleteFramebuffer(this.framebuffer))),f7(t,(()=>t.bindBuffer(t.ARRAY_BUFFER,null))),f7(t,(()=>t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null))),f7(t,(()=>t.deleteBuffer(this.indexBuffer))),this.disposed=!0}createFloat32MatrixTexture(t,e){return this.throwIfDisposed(),qtt(this.gl,t,e,this.textureConfig)}createFloat16MatrixTexture(t,e){return this.throwIfDisposed(),Qtt(this.gl,t,e,this.textureConfig)}createUnsignedBytesMatrixTexture(t,e){return this.throwIfDisposed(),Ztt(this.gl,t,e,this.textureConfig)}uploadPixelDataToTexture(t,e){this.throwIfDisposed(),aet(this.gl,t,e)}uploadDenseMatrixToTexture(t,e,n,i){this.throwIfDisposed(),ret(this.gl,t,e,n,i,this.textureConfig)}createFloat16PackedMatrixTexture(t,e){return this.throwIfDisposed(),iet(this.gl,t,e,this.textureConfig)}createPackedMatrixTexture(t,e){return this.throwIfDisposed(),eet(this.gl,t,e,this.textureConfig)}deleteMatrixTexture(t){this.throwIfDisposed(),this.outputTexture===t&&(U7(this.gl,this.framebuffer),this.outputTexture=null),f7(this.gl,(()=>this.gl.deleteTexture(t)))}downloadByteEncodedFloatMatrixFromOutputTexture(t,e,n){return this.downloadMatrixDriver(t,(()=>het(this.gl,e,n,this.textureConfig)))}downloadPackedMatrixFromBuffer(t,e,n,i,s,r){return pet(this.gl,t,0,0,0,s,r,this.textureConfig)}downloadFloat32MatrixFromBuffer(t,e){return uet(this.gl,t,e)}createBufferFromTexture(t,e,n){this.bindTextureToFrameBuffer(t);const i=oet(this.gl,e,n,this.textureConfig);return this.unbindTextureToFrameBuffer(),i}createAndWaitForFence(){const t=this.createFence(this.gl);return this.pollFence(t)}createFence(t){let e,n;if(lO().getBool("WEBGL_FENCE_API_ENABLED")){const i=t,s=i.fenceSync(i.SYNC_GPU_COMMANDS_COMPLETE,0);t.flush(),n=()=>{const t=i.clientWaitSync(s,0,0);return t===i.ALREADY_SIGNALED||t===i.CONDITION_SATISFIED},e=s}else lO().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(e=this.beginQuery(),this.endQuery(),n=()=>this.isQueryAvailable(e,lO().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))):n=()=>!0;return{query:e,isFencePassed:n}}downloadMatrixFromPackedTexture(t,e,n){return this.downloadMatrixDriver(t,(()=>cet(this.gl,e,n)))}createProgram(t){this.throwIfDisposed();const e=this.gl;null==this.vertexShader&&(this.vertexShader=Htt(e));const n=w7(e);f7(e,(()=>e.attachShader(n,this.vertexShader))),f7(e,(()=>e.attachShader(n,t))),S7(e,n);const i=Object.assign(n,{vao:this.createVertexArray()});return this.debug&&x7(e,i),i}buildVao(t){this.setProgram(t),this.bindVertexArray(t.vao);const e=this.gl;f7(e,(()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.indexBuffer))),set(e,t,this.vertexBuffer)}deleteProgram(t){this.throwIfDisposed(),t===this.program&&(this.program=null),null!=t&&(f7(this.gl,(()=>this.gl.deleteProgram(t))),this.deleteVertexArray(t.vao))}setProgram(t){this.throwIfDisposed(),this.program=t,null!=this.program&&this.debug&&x7(this.gl,this.program),f7(this.gl,(()=>this.gl.useProgram(t)))}getUniformLocation(t,e,n=!0){return this.throwIfDisposed(),n?F7(this.gl,t,e):P7(this.gl,t,e)}getAttributeLocation(t,e){return this.throwIfDisposed(),f7(this.gl,(()=>this.gl.getAttribLocation(t,e)))}getUniformLocationNoThrow(t,e){return this.throwIfDisposed(),this.gl.getUniformLocation(t,e)}setInputMatrixTexture(t,e,n){this.throwIfDisposed(),this.throwIfNoProgram(),$7(this.gl,t,e,n)}setOutputMatrixTexture(t,e,n){this.setOutputMatrixTextureDriver(t,n,e)}setOutputPackedMatrixTexture(t,e,n){this.throwIfDisposed();const[i,s]=c7(e,n);this.setOutputMatrixTextureDriver(t,i,s)}setOutputMatrixWriteRegion(t,e,n,i){this.setOutputMatrixWriteRegionDriver(n,t,i,e)}setOutputPackedMatrixWriteRegion(t,e,n,i){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")}debugValidate(){null!=this.program&&x7(this.gl,this.program),Y7(this.gl)}executeProgram(){this.throwIfDisposed(),this.throwIfNoProgram();const t=this.gl;if(this.debug){const t=this.getVertexArray();console.assert(t===this.program.vao,"VAO changed between setProgram and executeProgram!"),this.debugValidate()}f7(t,(()=>t.drawElements(t.TRIANGLES,6,t.UNSIGNED_SHORT,0)))}blockUntilAllProgramsCompleted(){this.throwIfDisposed(),f7(this.gl,(()=>this.gl.finish()))}getQueryTimerExtension(){return null==this.disjointQueryTimerExtension&&(this.disjointQueryTimerExtension=y7(this.gl,2===lO().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===lO().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){const t=this.gl,e=this.getQueryTimerExtensionWebGL2(),n=t.createQuery();return t.beginQuery(e.TIME_ELAPSED_EXT,n),n}const t=this.getQueryTimerExtensionWebGL1(),e=t.createQueryEXT();return t.beginQueryEXT(t.TIME_ELAPSED_EXT,e),e}endQuery(){if(2===lO().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){const t=this.gl,e=this.getQueryTimerExtensionWebGL2();return void t.endQuery(e.TIME_ELAPSED_EXT)}const t=this.getQueryTimerExtensionWebGL1();t.endQueryEXT(t.TIME_ELAPSED_EXT)}async waitForQueryAndGetTime(t){return await CA((()=>this.disposed||this.isQueryAvailable(t,lO().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")))),this.getQueryTime(t,lO().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}getQueryTime(t,e){if(0===e)return null;if(2===e){const e=this.gl;return e.getQueryParameter(t,e.QUERY_RESULT)/1e6}{const e=this.getQueryTimerExtensionWebGL1();return e.getQueryObjectEXT(t,e.QUERY_RESULT_EXT)/1e6}}isQueryAvailable(t,e){if(0===e)return!0;if(2===e){const e=this.gl,n=this.getQueryTimerExtensionWebGL2(),i=e.getQueryParameter(t,e.QUERY_RESULT_AVAILABLE);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(n.GPU_DISJOINT_EXT)),i&&!this.disjoint}{const e=this.getQueryTimerExtensionWebGL1(),n=e.getQueryObjectEXT(t,e.QUERY_RESULT_AVAILABLE_EXT);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(e.GPU_DISJOINT_EXT)),n&&!this.disjoint}}pollFence(t){return new Promise((e=>{this.addItemToPoll((()=>t.isFencePassed()),(()=>e()))}))}pollItems(){const t=function(t){let e=0;for(;et.isDoneFn)));for(let e=0;e<=t;++e){const{resolveFn:t}=this.itemsToPoll[e];t()}this.itemsToPoll=this.itemsToPoll.slice(t+1)}addItemToPoll(t,e){if(this.itemsToPoll.push({isDoneFn:t,resolveFn:e}),this.itemsToPoll.length>1)return;let n;"setTimeoutCustom"in lO().platform&&(n=lO().platform.setTimeoutCustom.bind(lO().platform)),CA((()=>(this.pollItems(),0===this.itemsToPoll.length)),(()=>0),null,n)}bindTextureToFrameBuffer(t){this.throwIfDisposed(),V7(this.gl,t,this.framebuffer),this.debug&&Y7(this.gl)}unbindTextureToFrameBuffer(){null!=this.outputTexture?(V7(this.gl,this.outputTexture,this.framebuffer),this.debug&&Y7(this.gl)):U7(this.gl,this.framebuffer)}downloadMatrixDriver(t,e){this.bindTextureToFrameBuffer(t);const n=e();return this.unbindTextureToFrameBuffer(),n}setOutputMatrixTextureDriver(t,e,n){this.throwIfDisposed();const i=this.gl;V7(i,t,this.framebuffer),this.debug&&Y7(i),this.outputTexture=t,f7(i,(()=>i.viewport(0,0,e,n))),f7(i,(()=>i.scissor(0,0,e,n)))}setOutputMatrixWriteRegionDriver(t,e,n,i){this.throwIfDisposed(),f7(this.gl,(()=>this.gl.scissor(t,e,n,i)))}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.")}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const{addImpl:fet,bincountImpl:met,bincountReduceImpl:get,bitwiseAndImpl:_et,castImpl:Tet,ceilImpl:yet,concatImpl:Iet,equalImpl:Eet,expImpl:bet,expm1Impl:vet,floorImpl:wet,gatherNdImpl:xet,gatherV2Impl:Ret,greaterImpl:Aet,greaterEqualImpl:Oet,lessImpl:Met,lessEqualImpl:Cet,linSpaceImpl:Net,logImpl:ket,maxImpl:Det,maximumImpl:Let,minimumImpl:Fet,multiplyImpl:Pet,negImpl:$et,notEqualImpl:Bet,prodImpl:Vet,raggedGatherImpl:Uet,raggedRangeImpl:Yet,raggedTensorToTensorImpl:Get,rangeImpl:Het,rsqrtImpl:Wet,scatterImpl:zet,sigmoidImpl:Xet,simpleAbsImpl:jet,sliceImpl:qet,sparseFillEmptyRowsImpl:Ket,sparseReshapeImpl:Qet,sparseSegmentReductionImpl:Jet,sqrtImpl:Zet,staticRegexReplaceImpl:tnt,stridedSliceImpl:ent,stringNGramsImpl:nnt,stringSplitImpl:int,stringToHashBucketFastImpl:snt,subImpl:rnt,tileImpl:ant,topKImpl:ont,transposeImpl:lnt,uniqueImpl:unt}=jt; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function hnt(t,e){return["x","y","z","w","u","v"].slice(0,e).map((e=>`${t}.${e}`))}function pnt(t,e){return 1===e?[t]:hnt(t,e)} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class cnt{constructor(t){if(this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=t,this.rank=t.length,this.enableShapeUniforms=Ftt(this.outputShape.length),0===this.rank)this.userCode="\n void main() {\n setOutput(vec4(getA(), 0., 0., 0.));\n }\n ";else{const t=pnt("rc",this.rank),e=Mtt(this.rank),n=this.getOutOfBoundsCondition(t),i=this.getSetup(t),s=this.getOutput(t);this.userCode=`\n void main() {\n ${e} rc = getOutputCoords();\n\n if(${n}) {\n setOutput(vec4(0));\n } else {\n ${i}\n\n setOutput(vec4(${s}));\n }\n }\n `}}getSourceCoordsArr(t){const e=[];for(let n=0;n<=1;n++)for(let i=0;i<=1;i++){let s=`${0===n?"r":"rp1"}, ${0===i?"c":"cp1"}`;for(let e=2;e ${this.enableShapeUniforms?"outShape":this.outputShape[0]}`;let e="";for(let n=this.rank-2;n= ${this.enableShapeUniforms?`outShape[${n}]`:this.outputShape[n]}`,n= ${n};\n bool rEdge = rp1 >= ${i};\n `}getOutput(t){const e=this.getSourceCoordsArr(t);if(1===this.rank){return`getA(rc), (rc + 1 >= ${this.enableShapeUniforms?"outShape":this.outputShape[0]} ? 0. : getA(rc + 1)), 0, 0`}return`getA(${e[0]}),\n cEdge ? 0. : getA(${e[1]}),\n rEdge ? 0. : getA(${e[2]}),\n rEdge || cEdge ? 0. : getA(${e[3]})`}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class dnt{constructor(t,e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec3"}],this.outputShape=t,this.enableShapeUniforms=Ftt(this.outputShape.length);let n="";for(let t=0;t<4;t++){let e="thisRC = rc;";t%2==1&&(e+="thisRC.z += 1;"),t>1&&(e+="thisRC.y += 1;"),n+=`\n ${e}\n ${t>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[${t}] =\n getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);\n ${t>0?"}":""}\n `}var i,s;this.userCode=`\n ${i=e,s=this.enableShapeUniforms,`\n ivec3 inputCoordsFromReshapedOutCoords(int index) {\n ${s?gtt(["r","c","d"],"inputShape"):ftt(["r","c","d"],i)}\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":_tt(t)}\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]":t[1]};\n int cols = ${this.enableShapeUniforms?"outShape[2]":t[2]};\n\n ${n}\n\n setOutput(result);\n }\n `}} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class fnt{constructor(t){this.gpgpu=t,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0,this.freeTextures={},this.usedTextures={},this.logEnabled=!1}acquireTexture(t,e,n){const i=gnt(e,n),s=_nt(t,i,n);s in this.freeTextures||(this.freeTextures[s]=[]),s in this.usedTextures||(this.usedTextures[s]=[]);const r=mnt(t,i,this.gpgpu.gl,this.gpgpu.textureConfig,n);if(this.freeTextures[s].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=r,this.log();const t=this.freeTextures[s].pop();return this.usedTextures[s].push(t),t}let a;return i===u7.PACKED_2X2_FLOAT32?a=this.gpgpu.createPackedMatrixTexture(t[0],t[1]):i===u7.PACKED_2X2_FLOAT16?a=this.gpgpu.createFloat16PackedMatrixTexture(t[0],t[1]):i===u7.UNPACKED_FLOAT32?a=this.gpgpu.createFloat32MatrixTexture(t[0],t[1]):i===u7.UNPACKED_FLOAT16?a=this.gpgpu.createFloat16MatrixTexture(t[0],t[1]):i===u7.PACKED_4X1_UNSIGNED_BYTE&&(a=this.gpgpu.createUnsignedBytesMatrixTexture(t[0],t[1])),this.usedTextures[s].push(a),this.numUsedTextures++,this._numBytesAllocated+=r,this.log(),a}releaseTexture(t,e,n,i){if(null==this.freeTextures)return;const s=gnt(n,i),r=_nt(e,s,i);r in this.freeTextures||(this.freeTextures[r]=[]);const a=mnt(e,s,this.gpgpu.gl,this.gpgpu.textureConfig,i),o=lO().getNumber("WEBGL_DELETE_TEXTURE_THRESHOLD");-1!==o&&this._numBytesAllocated>o?(this.gpgpu.deleteMatrixTexture(t.texture),this._numBytesAllocated-=a):(this.freeTextures[r].push(t),this.numFreeTextures++,this._numBytesFree+=a),this.numUsedTextures--;const l=this.usedTextures[r],u=l&&l.indexOf(t);if(null==u||u<0)throw new Error("Cannot release a texture that was never provided by this texture manager");l[u]=l[l.length-1],l.pop(),this.log()}log(){if(!this.logEnabled)return;const t=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used",`${this.numFreeTextures} / ${this.numUsedTextures}`,`(${t})`);const e=this._numBytesFree/this._numBytesAllocated;console.log(`Bytes allocated: ${this._numBytesAllocated}`),console.log(`Bytes unused: ${this._numBytesFree} (${Math.round(100*e)}%)`)}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 t in this.freeTextures)this.freeTextures[t].forEach((t=>{this.gpgpu.deleteMatrixTexture(t.texture)}));for(const t in this.usedTextures)this.usedTextures[t].forEach((t=>{this.gpgpu.deleteMatrixTexture(t.texture)}));this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0}}}function mnt(t,e,n,i,s){const r=function(t,e){switch(t){case u7.PACKED_2X2_FLOAT32:return tet(e);case u7.PACKED_2X2_FLOAT16:return net(e);case u7.UNPACKED_FLOAT32:return jtt(e);case u7.UNPACKED_FLOAT16:return Ktt(e);case u7.PACKED_4X1_UNSIGNED_BYTE:return Jtt(e);default:throw new Error(`Unknown physical texture type ${t}`)}}(e,i);let a;if(s){const[e,n]=c7(t[0],t[1]);a=e*n}else{const[e,n]=h7(t[0],t[1]);a=e*n}const o=function(t,e){const n=t;if(e===n.R32F)return 4;if(e===n.R16F)return 2;if(e===n.RGBA32F)return 16;if(e===t.RGBA)return 16;if(e===n.RGBA16F)return 8;if(e===n.RGBA8)return 4;throw new Error(`Unknown internal format ${e}`)}(n,r);return a*o}function gnt(t,e){if(t===l7.UPLOAD)return u7.PACKED_2X2_FLOAT32;if(t===l7.RENDER||null==t)return function(t){return lO().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?t?u7.PACKED_2X2_FLOAT32:u7.UNPACKED_FLOAT32:t?u7.PACKED_2X2_FLOAT16:u7.UNPACKED_FLOAT16}(e);if(t===l7.DOWNLOAD||t===l7.PIXELS)return u7.PACKED_4X1_UNSIGNED_BYTE;throw new Error(`Unknown logical texture type ${t}`)}function _nt(t,e,n){return`${t[0]}_${t[1]}_${e}_${n}`} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Tnt{constructor(t,e){this.variableNames=["A"],this.outputShape=t,this.enableShapeUniforms=Ftt(this.outputShape.length),this.userCode=`\n float unaryOperation(float x) {\n ${e}\n }\n\n void main() {\n float x = getAAtOutCoords();\n float y = unaryOperation(x);\n\n setOutput(y);\n }\n `}}const ynt="if (isnan(x)) return x;",Int="return x;",Ent="return abs(x);";const bnt="return (x >= 0.0) ? x : (exp(x) - 1.0);",vnt=ynt+"\n return (x < 0.0) ? 0.0 : x;\n",wnt=ynt+"\n return (x < 0.0) ? 0.0 : min(6.0, x);\n",Snt="return x;",xnt="return 1.0 / (1.0 + exp(-1.0 * x));",Rnt="return x;",Ant="\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",Ont="\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",Mnt="\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",Cnt="return 1.0 / (1.0 + exp(-1.0 * x));";class Nnt{constructor(t,e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.enableShapeUniforms=Ftt(this.outputShape.length),this.userCode=`\n vec4 unaryOperation(vec4 x) {\n ${e}\n }\n\n void main() {\n vec4 x = getAAtOutCoords();\n vec4 y = unaryOperation(x);\n\n setOutput(y);\n }\n `}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class knt{constructor(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=t,this.enableShapeUniforms=Ftt(this.outputShape.length);const e=t.length,n=pnt("rc",e),i=Mtt(e),s=function(t,e){if(1===t)return"rc";let n="";for(let i=0;ie.push(t)))}const e=this.texData.get(t),{values:n,shape:i,slice:s,dtype:r,complexTensorInfos:a,isPacked:o}=e;if(null!=s){let e;e=o?new Nnt(i,Snt):new Tnt(i,Snt);const n=this.runWebGLProgram(e,[{dataId:t,shape:i,dtype:r}],r),s=this.read(n.dataId);return this.disposeIntermediateTensorInfo(n),s}if(null!=n)return this.convertAndCacheOnCPU(t);if(lO().getBool("DEBUG")&&!lO().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&2===lO().getNumber("WEBGL_VERSION"))throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");let l,u,h=null;if("complex64"!==r&&lO().get("WEBGL_BUFFER_SUPPORTED")){l=this.decode(t);const e=this.texData.get(l.dataId);h=this.gpgpu.createBufferFromTexture(e.texture.texture,...p7(i))}if(this.pendingRead.set(t,[]),"complex64"!==r&&await this.gpgpu.createAndWaitForFence(),"complex64"===r){const t=await Promise.all([this.read(a.real.dataId),this.read(a.imag.dataId)]);u=CG(t[0],t[1])}else if(null==h)u=this.getValuesFromTexture(t);else{const t=bA(i);u=this.gpgpu.downloadFloat32MatrixFromBuffer(h,t)}if(null!=l&&this.disposeIntermediateTensorInfo(l),null!=h){const t=this.gpgpu.gl;f7(t,(()=>t.deleteBuffer(h)))}const p=this.convertAndCacheOnCPU(t,u),c=this.pendingRead.get(t);return this.pendingRead.delete(t),c.forEach((t=>t(p))),this.pendingDisposal.has(t)&&(this.pendingDisposal.delete(t),this.disposeData(t)&&ID().removeDataId(t,this),this.pendingDeletes--),p}readToGPU(t,e={}){const n=this.texData.get(t),{values:i,shape:s,slice:r,dtype:a,isPacked:o,texture:l}=n;if("complex64"===a)throw new Error("Does not support reading texture for complex64 dtype.");if(null!=r){let n;n=o?new Nnt(s,Snt):new Tnt(s,Snt);const i=this.runWebGLProgram(n,[{dataId:t,shape:s,dtype:a}],a),r=this.readToGPU(i,e);return this.disposeIntermediateTensorInfo(i),r}if(null==l)throw null!=i?new Error("Data is not on GPU but on CPU."):new Error("There is no data on GPU or CPU.");const u=this.decode(t,e.customTexShape),h=ID().makeTensorFromTensorInfo(u),p=this.texData.get(u.dataId);return Object.assign({tensorRef:h},p.texture)}bufferSync(t){const e=this.readSync(t.dataId);if("string"===t.dtype)try{const n=e.map((t=>hk(t)));return $L(t.shape,t.dtype,n)}catch(t){throw new Error("Failed to decode encoded string bytes into utf-8")}return $L(t.shape,t.dtype,e)}checkNumericalProblems(t){if(null!=t)for(let e=0;e0}time(t){const e=this.activeTimers,n=[];let i=!1;null==this.programTimersStack?(this.programTimersStack=n,i=!0):this.activeTimers.push(n),this.activeTimers=n,t();const s=ck(this.activeTimers.map((t=>t.query))).filter((t=>null!=t)),r=ck(this.activeTimers.map((t=>t.name))).filter((t=>null!=t));this.activeTimers=e,i&&(this.programTimersStack=null);const a={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null};return(async()=>{if(lO().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0){const t=await Promise.all(s);a.kernelMs=gA(t),a.getExtraProfileInfo=()=>t.map(((t,e)=>({name:r[e],ms:t}))).map((t=>`${t.name}: ${t.ms}`)).join(", ")}else a.kernelMs={error:"WebGL query timers are not supported in this environment."};return this.uploadWaitMs=0,this.downloadWaitMs=0,a})()}memory(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU,numBytesInGPUAllocated:this.textureManager.numBytesAllocated,numBytesInGPUFree:this.textureManager.numBytesFree}}startTimer(){return lO().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:ok(),endMs:null}}endTimer(t){return lO().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),t):(t.endMs=ok(),t)}async getQueryTime(t){if(lO().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0)return this.gpgpu.waitForQueryAndGetTime(t);const e=t;return e.endMs-e.startMs}disposeData(t,e=!1){if(this.pendingDisposal.has(t))return!1;if(!this.texData.has(t))return!0;if(e?this.texData.get(t).refCount=0:this.texData.get(t).refCount--,!e&&this.texData.get(t).refCount>0)return!1;if(this.pendingRead.has(t))return this.pendingDisposal.add(t),this.pendingDeletes++,!1;this.releaseGPUData(t);const{complexTensorInfos:n}=this.texData.get(t);return null!=n&&(this.disposeData(n.real.dataId,e),this.disposeData(n.imag.dataId,e)),this.texData.delete(t),!0}releaseGPUData(t){const{texture:e,dtype:n,texShape:i,usage:s,isPacked:r,slice:a}=this.texData.get(t),o=a&&a.origDataId||t,l=this.dataRefCount.get(o);l>1?this.dataRefCount.set(o,l-1):(this.dataRefCount.delete(o),null!=e&&(this.numBytesInGPU-=this.computeBytes(i,n),this.textureManager.releaseTexture(e,i,s,r)));const u=this.texData.get(t);u.texture=null,u.texShape=null,u.isPacked=!1,u.slice=null}getTexture(t){return this.uploadToGPU(t),this.texData.get(t).texture.texture}getDataInfo(t){return this.texData.get(t)}shouldExecuteOnCPU(t,e=Fnt){return lO().getBool("WEBGL_CPU_FORWARD")&&t.every((t=>null==this.texData.get(t.dataId).texture&&bA(t.shape)0&&YA(n[0])){const s=n.map((t=>uk(t)));i=this.write(s,t,e)}else i=this.write(n,t,e);return this.texData.get(i).usage=null,{dataId:i,shape:t,dtype:e}}makeOutput(t,e,n){return ID().makeTensorFromTensorInfo(this.makeTensorInfo(t,e,n),this)}unpackTensor(t){const e=new knt(t.shape);return this.runWebGLProgram(e,[t],t.dtype)}packTensor(t){const e=new cnt(t.shape);return this.runWebGLProgram(e,[t],t.dtype,null,!0)}packedReshape(t,e){const n=[z7(t.shape),...X7(t.shape)],i={dtype:t.dtype,shape:n,dataId:t.dataId},s=[z7(e),...X7(e)],r=new dnt(s,n),a=[n],o=this.runWebGLProgram(r,[i],t.dtype,a,!0);return{dataId:o.dataId,shape:e,dtype:o.dtype}}decode(t,e){const n=this.texData.get(t),{isPacked:i,shape:s,dtype:r}=n;if(null!=e){yA(bA(s)<=e[0]*e[1]*4,(()=>"customTexShape is too small. Row * Column * 4 should be equal or larger than the size of the tensor data."))}const a=j7(s);let o;o=i?new $tt(a):new Ptt(a);const l=[null!=e?e:p7(a)];return{dtype:r,shape:s,dataId:this.runWebGLProgram(o,[{shape:a,dtype:r,dataId:t}],r,l,!0,e).dataId}}runWebGLProgram(t,e,n,i,s=!1,r){const a=this.makeTensorInfo(t.outputShape,n),o=this.texData.get(a.dataId);if(t.packedOutput&&(o.isPacked=!0),t.outPackingScheme===o7.DENSE){const e=null!=r?r:p7(t.outputShape);o.texShape=e.map((t=>2*t))}if(null!=t.outTexUsage&&(o.usage=t.outTexUsage),0===bA(a.shape))return o.values=LA(a.dtype,0),a;const l=[],u=e.map((e=>{if("complex64"===e.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(e.dataId);if(null==n.texture){if(!t.packedInputs&&bA(e.shape)<=lO().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return{shape:e.shape,texData:null,isUniform:!0,uniformValues:n.values};t.packedInputs&&(n.isPacked=!0,n.shape=e.shape)}if(this.uploadToGPU(e.dataId),!!n.isPacked!=!!t.packedInputs)e=n.isPacked?this.unpackTensor(e):this.packTensor(e),l.push(e),n=this.texData.get(e.dataId);else if(n.isPacked&&!Q7(n.shape,e.shape)){const t=e,i=e.shape;e.shape=n.shape,e=this.packedReshape(e,i),l.push(e),n=this.texData.get(e.dataId),t.shape=i}return{shape:e.shape,texData:n,isUniform:!1}}));this.uploadToGPU(a.dataId);const h={shape:a.shape,texData:o,isUniform:!1},p=function(t,e,n){let i="";e.concat(n).forEach((e=>{const s=null!=e.texData&&null!=e.texData.slice&&e.texData.slice.flatOffset>0;if(t.enableShapeUniforms&&!e.isUniform){const r=e.texData.texShape,{useSqueezeShape:a,uniformShape:o,keptDims:l}=Ctt(t.packedInputs,e.shape,r);let u="",h="",p="";if(1===o.length&&t.packedInputs){const t=[Math.ceil(r[0]/2),Math.ceil(r[1]/2)];u=`${t[0]>1}_${t[1]>1}`}else if(2!==o.length||t.packedInputs){if(o.length>2&&!t.packedInputs){const t=jA(o);p=`${t[0]===r[1]}_${t[t.length-1]===r[1]}`}}else h=`${o[0]>1}_${o[1]>1}`;const c=e.shape.length,d=2===o.length&&SA(e.shape,r),f=1===bA(e.shape),m=_F(e.shape,n.shape),g=!t.packedInputs&&c===n.shape.length&&SA(r,n.texData.texShape),_=t.packedInputs||o.length>2?"":`${r[0]>1}_${r[1]>1}`;i+=`${c}_${g}_${a?l:""}_${o.length}_${f}_${m}_${d}_${u}_${h}_${p}_${_}_${s}`}else{const t=e.isUniform?"uniform":e.texData.texShape;i+=`${e.shape}_${t}_${s}`}}));const s=t.userCode;let r=t.constructor.name;return r+="_"+i+"_"+s+`${lO().getNumber("WEBGL_VERSION")}`,r}(t,u,h),c=this.getAndSaveBinary(p,(()=> /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i){const s=n.map(((t,n)=>{const i={logicalShape:t.shape,texShape:t.isUniform?null:t.texData.texShape,isUniform:t.isUniform,isPacked:!t.isUniform&&t.texData.isPacked,flatOffset:null};return null!=t.texData&&null!=t.texData.slice&&t.texData.slice.flatOffset>0&&(i.flatOffset=t.texData.slice.flatOffset),{name:e.variableNames[n],shapeInfo:i}})),r=s.map((t=>t.shapeInfo)),a={logicalShape:i.shape,texShape:i.texData.texShape,isUniform:!1,isPacked:i.texData.isPacked,flatOffset:null},o=Itt(s,a,e),l=E7(t.gl,o),u=t.createProgram(l);return lO().get("ENGINE_COMPILE_ONLY")?{program:e,fragmentShader:l,source:o,webGLProgram:u,inShapeInfos:r,outShapeInfo:a,variablesLocations:null,customUniformLocations:null,infLoc:null,nanLoc:null,outShapeLocation:null,outShapeStridesLocation:null,outTexShapeLocation:null}:(t.buildVao(u),Object.assign({program:e,fragmentShader:l,source:o,webGLProgram:u,inShapeInfos:r,outShapeInfo:a},Dtt(t,e,u)))}(this.gpgpu,t,u,h))),d=null!=this.activeTimers;let f;d&&(f=this.startTimer()),lO().get("ENGINE_COMPILE_ONLY")||function(t,e,n,i,s){e.program.enableShapeUniforms||(Ltt(e.inShapeInfos,n),Ltt([e.outShapeInfo],[i]));const r=i.texData.texture,a=i.texData.texShape;i.texData.isPacked?t.setOutputPackedMatrixTexture(r.texture,a[0],a[1]):t.setOutputMatrixTexture(r.texture,a[0],a[1]),t.setProgram(e.webGLProgram),t.bindVertexArray(e.webGLProgram.vao),1===lO().getNumber("WEBGL_VERSION")&&null!==e.infLoc&&t.gl.uniform1f(e.infLoc,1/0),null!==e.nanLoc&&t.gl.uniform1f(e.nanLoc,NaN);for(let i=0;ithis.disposeIntermediateTensorInfo(t))),d&&(f=this.endTimer(f),this.activeTimers.push({name:t.constructor.name,query:this.getQueryTime(f)}));const m=lO().getNumber("WEBGL_FLUSH_THRESHOLD");if(m>0){const t=ok();t-this.lastGlFlushTime>m&&(this.gpgpu.gl.flush(),this.lastGlFlushTime=t)}if(!lO().getBool("WEBGL_LAZILY_UNPACK")&&o.isPacked&&!1===s){const t=this.unpackTensor(a);return this.disposeIntermediateTensorInfo(a),t}return a}compileAndRun(t,e,n,i,s=!1){n=n||e[0].dtype;return this.runWebGLProgram(t,e,n,i,s)}getAndSaveBinary(t,e){return t in this.binaryCache||(this.binaryCache[t]=e()),this.binaryCache[t]}getTextureManager(){return this.textureManager}dispose(){if(!this.disposed){if(!lO().getBool("IS_TEST")){Object.keys(this.binaryCache).forEach((t=>{this.gpgpu.deleteProgram(this.binaryCache[t].webGLProgram),delete this.binaryCache[t]}))}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=vD((()=>{if(!lO().get("WEBGL_RENDER_FLOAT32_ENABLED")){const t=lO().getBool("DEBUG");lO().set("DEBUG",!1);const e=this.abs(nF(1e-8)).dataSync()[0];if(lO().set("DEBUG",t),e>0)return 32}return 16}))),this.floatPrecisionValue}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}uploadToGPU(t){const e=this.texData.get(t),{shape:n,dtype:i,values:s,texture:r,usage:a,isPacked:o}=e;if(null!=r)return;const l=null!=this.activeTimers;let u;l&&(u=ok());let h=e.texShape;if(null==h&&(h=q7(n,o),e.texShape=h),null!=s){const t=j7(n);let r,a=h[1],p=h[0];const c=s instanceof Uint8Array||s instanceof Uint8ClampedArray;!o&&c||([a,p]=c7(h[0],h[1])),r=o?new Gtt(t,c):new Ytt(t,c);const d=c?[p,a]:h,f=this.makeTensorInfo(d,i),m=this.texData.get(f.dataId);m.usage=c?l7.PIXELS:l7.UPLOAD,m.texShape=d,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(f.dataId),a,p,s);const g=[[p,a]],_=!0,T=this.runWebGLProgram(r,[f],i,g,_),y=this.texData.get(T.dataId);e.texShape=y.texShape,e.isPacked=y.isPacked,e.usage=y.usage,lO().get("ENGINE_COMPILE_ONLY")?this.disposeData(T.dataId):(e.texture=y.texture,e.values=null,this.texData.delete(T.dataId)),this.disposeIntermediateTensorInfo(f),l&&(this.uploadWaitMs+=ok()-u)}else{const t=this.acquireTexture(h,a,i,o);e.texture=t}}convertAndCacheOnCPU(t,e){const n=this.texData.get(t),{dtype:i}=n;return null!=e&&(n.values=function(t,e){if("float32"===e||"complex64"===e)return t;if("int32"===e||"bool"===e){const n="int32"===e?new Int32Array(t.length):new Uint8Array(t.length);for(let e=0;e1024*this.numMBBeforeWarning*1024){const t=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn(`High memory usage in GPU: ${t} MB, most likely due to a memory leak`)}return this.textureManager.acquireTexture(t,e,i)}computeBytes(t,e){return t[0]*t[1]*VA(e)}checkCompileCompletion(){for(const[,t]of Object.entries(this.binaryCache))this.checkCompletion_(t)}async checkCompileCompletionAsync(){const t=[];if(this.gpgpu.parallelCompilationExtension){for(const[,e]of Object.entries(this.binaryCache))t.push(this.checkCompletionAsync_(e));return Promise.all(t)}for(const[,e]of Object.entries(this.binaryCache)){const n=new Promise((t=>{try{this.checkCompletion_(e),t(!0)}catch(t){throw t}}));t.push(n)}return Promise.all(t)}async checkCompletionAsync_(t){return this.gpgpu.gl.getProgramParameter(t.webGLProgram,this.gpgpu.parallelCompilationExtension.COMPLETION_STATUS_KHR)?this.checkCompletion_(t):(await oG(),this.checkCompletionAsync_(t))}checkCompletion_(t){if(!1===this.gpgpu.gl.getProgramParameter(t.webGLProgram,this.gpgpu.gl.LINK_STATUS)){if(console.log(this.gpgpu.gl.getProgramInfoLog(t.webGLProgram)),!1===this.gpgpu.gl.getShaderParameter(t.fragmentShader,this.gpgpu.gl.COMPILE_STATUS))throw v7(t.source,this.gpgpu.gl.getShaderInfoLog(t.fragmentShader)),new Error("Failed to compile fragment shader.");throw new Error("Failed to link vertex and fragment shaders.")}return!0}getUniformLocations(){for(const t of Object.values(this.binaryCache)){this.gpgpu.buildVao(t.webGLProgram);const{variablesLocations:e,customUniformLocations:n,infLoc:i,nanLoc:s,outShapeLocation:r,outShapeStridesLocation:a,outTexShapeLocation:o}=Dtt(this.gpgpu,t.program,t.webGLProgram);t.variablesLocations=e,t.customUniformLocations=n,t.infLoc=i,t.nanLoc=s,t.outShapeLocation=r,t.outShapeStridesLocation=a,t.outTexShapeLocation=o}}createTensorFromGPUData(t,e,n){t.channels=t.channels||"RGBA";const{texture:i,height:s,width:r,channels:a}=t,o=ID().backend;if(!o.gpgpu.gl.isTexture(i))throw new Error("The texture is invalid. Also, please make sure the texture and the TFJS WebGL backend are using the same canvas. If you want to use your own custom canvas, you have to create and use the custom TFJS WebGL backend created from the canvas through 'new tf.MathBackendWebGL(customCanvas)'.");const l=o.writeTexture(i,e,n,s,r,a);return ID().makeTensorFromDataId(l,e,n,o)}}Pnt.nextDataId=0; /** @license See the LICENSE file. */ const $nt="4.22.0"; /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Bnt(){lO().set("WEBGL_FORCE_F16_TEXTURES",!0)} /** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ eD()&&kD("webgl",(()=>new Pnt),2);const Vnt={forceHalfFloat:Bnt},Unt="\n if (isnan(a)) return a;\n if (isnan(b)) return b;\n";class Ynt{constructor(t,e,n){this.variableNames=["A","B"],this.outputShape=yF(e,n),this.enableShapeUniforms=Ftt(this.outputShape.length),this.userCode=`\n float binaryOperation(float a, float b) {\n ${t}\n }\n\n void main() {\n float a = getAAtOutCoords();\n float b = getBAtOutCoords();\n setOutput(binaryOperation(a, b));\n }\n `}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const Gnt="\n result.r = isNaN.r ? NAN : result.r;\n result.g = isNaN.g ? NAN : result.g;\n result.b = isNaN.b ? NAN : result.b;\n result.a = isNaN.a ? NAN : result.a;\n";class Hnt{constructor(t,e,n,i=!1){this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=yF(e,n);const s=this.outputShape.length;this.enableShapeUniforms=Ftt(s);let r="";if(i)if(0===s||1===bA(this.outputShape))r="\n result.y = 0.;\n result.z = 0.;\n result.w = 0.;\n ";else{if(r=`\n ${Mtt(s)} coords = getOutputCoords();\n `,1===s)this.enableShapeUniforms?r+="\n result.y = (coords + 1) >= outShape ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n ":r+=`\n result.y = (coords + 1) >= ${this.outputShape[0]} ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n `;else{const t=pnt("coords",s);this.enableShapeUniforms?r+=`\n bool nextRowOutOfBounds =\n (${t[s-2]} + 1) >= outShape[${s} - 2];\n bool nextColOutOfBounds =\n (${t[s-1]} + 1) >= outShape[${s} - 1];\n result.y = nextColOutOfBounds ? 0. : result.y;\n result.z = nextRowOutOfBounds ? 0. : result.z;\n result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n `:r+=`\n bool nextRowOutOfBounds =\n (${t[s-2]} + 1) >= ${this.outputShape[s-2]};\n bool nextColOutOfBounds =\n (${t[s-1]} + 1) >= ${this.outputShape[s-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 ${t}\n }\n\n void main() {\n vec4 a = getAAtOutCoords();\n vec4 b = getBAtOutCoords();\n\n vec4 result = binaryOperation(a, b);\n ${r}\n\n setOutput(result);\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Wnt(t){const{inputs:e,backend:n}=t,{x:i}=e;return n.incRef(i.dataId),{dataId:i.dataId,shape:i.shape,dtype:i.dtype}}const znt={kernelName:OM,backendName:"webgl",kernelFunc:Wnt}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Xnt(t){const{inputs:e,backend:n}=t,{real:i,imag:s}=e,r=n.makeTensorInfo(i.shape,"complex64"),a=n.texData.get(r.dataId),o=Wnt({inputs:{x:i},backend:n}),l=Wnt({inputs:{x:s},backend:n});return a.complexTensorInfos={real:o,imag:l},r}const jnt={kernelName:VO,backendName:"webgl",kernelFunc:Xnt},qnt="return (a < 0.) ? b * a : a;",Knt="\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n";const Qnt={kernelName:LM,backendName:"webgl",kernelFunc:function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{alpha:r}=i,a=n.makeTensorInfo([],"float32",rk(r,"float32")),o=lO().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Hnt(Knt,s.shape,a.shape):new Ynt(qnt,s.shape,a.shape),l=n.runWebGLProgram(o,[s,a],"float32");return n.disposeIntermediateTensorInfo(a),l}},Jnt="return (a < 0.) ? b * a : a;",Znt="\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n";const tit={kernelName:EC,backendName:"webgl",kernelFunc:function(t){const{inputs:e,backend:n}=t,{x:i,alpha:s}=e,r=lO().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Hnt(Znt,i.shape,s.shape):new Ynt(Jnt,i.shape,s.shape);return n.runWebGLProgram(r,[i,s],"float32")}},eit="if (isnan(x)) return x;";function nit({opSnippet:t,packedOpSnippet:e,cpuKernelImpl:n,dtype:i}){return({inputs:s,backend:r})=>{const{x:a}=s,o=r,l=i||a.dtype;if(o.shouldExecuteOnCPU([a])&&null!=n){const t=o.texData.get(a.dataId),e=n(t.values,l);return o.makeTensorInfo(a.shape,l,e)}let u;return u=lO().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&null!=e?new Nnt(a.shape,e):new Tnt(a.shape,t),o.runWebGLProgram(u,[a],l)}}function iit({opSnippet:t,packedOpSnippet:e,checkOutOfBounds:n=!1,supportsComplex:i=!1,cpuKernelImpl:s,dtype:r}){return({inputs:a,backend:o})=>{const{a:l,b:u}=a,h=o;if(i&&"complex64"===l.dtype){const e=h.texData.get(l.dataId),n=h.texData.get(u.dataId),[i,s]=[[e.complexTensorInfos.real,n.complexTensorInfos.real],[e.complexTensorInfos.imag,n.complexTensorInfos.imag]].map((e=>{const[n,i]=e,s={dataId:n.dataId,dtype:n.dtype,shape:l.shape},r={dataId:i.dataId,dtype:i.dtype,shape:u.shape},a=new Ynt(t,l.shape,u.shape);return h.runWebGLProgram(a,[s,r],Pk(n.dtype,i.dtype))})),r=Xnt({inputs:{real:i,imag:s},backend:h});return h.disposeIntermediateTensorInfo(i),h.disposeIntermediateTensorInfo(s),r}const p=r||Pk(l.dtype,u.dtype);if(("string"===l.dtype||"string"===u.dtype||h.shouldExecuteOnCPU([l,u]))&&null!=s){const t=h.texData.get(l.dataId).values,e=h.texData.get(u.dataId).values,n="string"===l.dtype?pH(t):t,i="string"===l.dtype?pH(e):e,[r,a]=s(l.shape,u.shape,n,i,p),o=h.makeTensorInfo(a,p);return h.texData.get(o.dataId).values=r,o}let c;return c=lO().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&null!=e?new Hnt(e,l.shape,u.shape,n):new Ynt(t,l.shape,u.shape),h.runWebGLProgram(c,[l,u],p)}}function sit(t,e=!1){if("linear"===t)return e?Rnt:Int;if("relu"===t)return e?Ont:vnt;if("elu"===t)return e?Ant:bnt;if("relu6"===t)return e?Mnt:wnt;if("prelu"===t)return e?Znt:Jnt;if("leakyrelu"===t)return e?Knt:qnt;if("sigmoid"===t)return e?Cnt:xnt;throw new Error(`Activation ${t} has not been implemented for the WebGL backend.`)} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class rit{constructor(t,e,n,i=!1,s=!1,r=!1,a=null,o=!1,l=!1){this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=n,this.enableShapeUniforms=Ftt(this.outputShape.length);const u=i?t[1]:t[2],h=Math.ceil(u/2),p=i?"i * 2, rc.y":"rc.y, i * 2",c=s?"rc.z, i * 2":"i * 2, rc.z",d=i?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],f=s?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"];let m="",g="";a&&(m=o?`vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n ${a}\n }`:l?`vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n ${a}\n }`:`vec4 activation(vec4 x) {\n ${a}\n }`,g="result = activation(result);");const _=r?"result += getBiasAtOutCoords();":"";r&&this.variableNames.push("bias"),o&&this.variableNames.push("preluActivationWeights"),l&&this.variableNames.push("leakyreluAlpha");let T="rc.x",y="rc.x";t[0]`The new shape (${l}) has ${u} elements and the old shape (${s.shape}) has ${o} elements. The new shape and old shape must have the same number of elements.`));const h=a.texData.get(s.dataId);return!h.isPacked||Q7(s.shape,l)||null!==h.texture&&Q7(h.shape,l)?(a.incRef(s.dataId),{dataId:s.dataId,shape:l,dtype:s.dtype}): /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n){const i=[z7(t.shape),...X7(t.shape)],s={dtype:t.dtype,shape:i,dataId:t.dataId},r=[z7(e),...X7(e)],a=new dnt(r,i),o=[i],l=n.runWebGLProgram(a,[s],t.dtype,o,!0);return{dataId:l.dataId,shape:e,dtype:l.dtype}}(s,l,a)}const cit={kernelName:MC,backendName:"webgl",kernelFunc:pit}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class dit{constructor(t,e){this.variableNames=["x"];const{windowSize:n,batchSize:i,inSize:s,outSize:r}=t;this.outputShape=[i,r];const a=4*Math.floor(n/4),o=n%4;let l="sumValue += dot(values, ones);";if(null!=e){const t=1/e;l=`sumValue += dot(values * ${xA(t)?t.toPrecision(2):t}, ones);`}let u="";s%n>0&&(u=`\n if (inIdx < 0 || inIdx >= ${s}) {\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 ${u}\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 < ${a}; 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 ${l}\n }\n\n int inIdx = inOffset + ${a};\n if (${1===o}) {\n vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0);\n\n ${l}\n } else if (${2===o}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1), 0.0, 0.0);\n\n ${l}\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 ${l}\n }\n setOutput(sumValue);\n }\n `}} /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class fit{constructor(t,e){this.variableNames=["x"];const{windowSize:n,batchSize:i,inSize:s,outSize:r}=t;this.outputShape=[i,r];let a="0.0",o="";"prod"===e?a="1.0":"min"===e?(a="1.0 / 1e-20",o="min"):"max"===e&&(a="-1.0 / 1e-20",o="max");let l=`${e}(${e}(${e}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"sum"===e?l="sumValue":"prod"===e?l="prodValue":"all"===e?l="allValue":"any"===e&&(l="anyValue");const u=4*Math.floor(n/4),h=n%4;let p=`\n if (${"sum"===e}) {\n sumValue += dot(values, ones);\n } else if (${"prod"===e}) {\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"===e} || ${"max"===e}) {\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 `,c="vec4";"all"===e?(a="1.0",p="\n bool reducedAllValue = all(values);\n float floatedReducedAllValue = float(reducedAllValue);\n allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);\n ",c="bvec4"):"any"===e&&(a="0.0",p="\n bool reducedAnyValue = any(values);\n float floatedReducedAnyValue = float(reducedAnyValue);\n anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);\n ",c="bvec4");let d="";s%n>0&&(d=`\n if (inIdx < 0 || inIdx >= ${s}) {\n return initializationValue;\n }\n `),this.userCode=`\n const float initializationValue = ${a};\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n ${d}\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(${a});\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 < ${u}; i += 4) {\n int inIdx = inOffset + i;\n ${c} values = ${c}(\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 + ${u};\n if (${1===h}) {\n ${c} values = ${c}(\n getValue(batch, inIdx),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${p}\n } else if (${2===h}) {\n ${c} values = ${c}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n initializationValue,\n initializationValue\n );\n\n ${p}\n } else if (${3===h}) {\n ${c} values = ${c}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n initializationValue\n );\n\n ${p}\n }\n setOutput(${l});\n }\n `}}function mit(t,e,n,i){const s= /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const e=[];for(;0===e.length||1!==e[e.length-1].outSize;){const n=e.length?e[e.length-1].outSize:t[1],i=gG(n);e.push({inSize:n,windowSize:i,outSize:Math.ceil(n/i)})}return e}(t.shape);let r=t;for(let a=0;a6)throw Error(`Transpose for rank ${e} is not yet supported`);const n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],i=new Array(e);for(let e=0;e6)throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`);const i=Mtt(this.rank),s=hnt("rc",this.rank),r=new Array(this.rank);for(let t=0;t`Error in matMul: inner shapes (${p}) and (${c}) of Tensors with shapes ${t.shape} and ${e.shape} and transposeA=${n} and transposeB=${i} must match.`));const I=n?[_,p,d]:[_,d,p],E=i?[T,f,c]:[T,c,f],b=pit({inputs:{x:t},backend:s,attrs:{shape:I}}),v=pit({inputs:{x:e},backend:s,attrs:{shape:E}}),w=[b,v],S=Math.max(_,T),x=n?b.shape[1]:b.shape[2],R=null!=r,A=null!=a,O="leakyrelu"===l,M=null!=l?sit(l,!0):null;let C;if((1===d||1===f)&&x>vit&&!1===(R||A||O||null!=M)){let t=b,e=v;n&&(t=Eit({inputs:{x:b},backend:s,attrs:{perm:[0,2,1]}}),w.push(t)),i&&(e=Eit({inputs:{x:v},backend:s,attrs:{perm:[0,2,1]}}),w.push(e));const r=1===f;let a=t;1!==f&&(a=pit({inputs:{x:t},backend:s,attrs:{shape:[S,x,1]}}),w.push(a));const o=1===f?2:1;let l=e;r&&(l=pit({inputs:{x:e},backend:s,attrs:{shape:[S,1,x]}}),w.push(l));const u=uit({inputs:{a,b:l},backend:s});C=yit({inputs:{x:u},backend:s,attrs:{axis:o,keepDims:!0}}),w.push(u)}else{const l=Pk(t.dtype,e.dtype),u=new rit(I,E,[S,d,f],n,i,R,M,A,O),h=[b,v];if(null!=r&&h.push(r),A&&h.push(a),O){const t=s.makeTensorInfo([],"float32",rk(o,"float32"));h.push(t),w.push(t)}C=s.runWebGLProgram(u,h,l)}const N=pit({inputs:{x:C},backend:s,attrs:{shape:y}});w.push(C);for(const t of w)s.disposeIntermediateTensorInfo(t);return N}const Sit={kernelName:AN,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{a:s,b:r,bias:a,preluActivationWeights:o}=e,{transposeA:l,transposeB:u,activation:h,leakyreluAlpha:p}=i;return wit({a:s,b:r,transposeA:l,transposeB:u,backend:n,bias:a,preluActivationWeights:o,leakyreluAlpha:p,activation:h})}},xit="return abs(x);";const Rit={kernelName:dO,backendName:"webgl",kernelFunc:function(t){const{inputs:e,backend:n}=t,{x:i}=e;if(n.shouldExecuteOnCPU([i])&&"complex64"!==i.dtype){const t=n.texData.get(i.dataId),e=jet(t.values);return n.makeTensorInfo(i.shape,i.dtype,e)}let s;return s=lO().getBool("WEBGL_PACK_UNARY_OPERATIONS")?new Nnt(i.shape,xit):new Tnt(i.shape,xit),n.runWebGLProgram(s,[i],i.dtype)}},Ait=nit({opSnippet:ynt+"\n if (abs(x) > 1.) {\n return NAN;\n }\n return acos(x);\n"}),Oit={kernelName:fO,backendName:"webgl",kernelFunc:Ait},Mit=nit({opSnippet:ynt+"\n if (x < 1.0) return NAN;\nreturn log(x + sqrt(x * x - 1.0));"}),Cit={kernelName:mO,backendName:"webgl",kernelFunc:Mit},Nit="return a + b;",kit=iit({opSnippet:Nit,packedOpSnippet:Nit,supportsComplex:!0,cpuKernelImpl:fet}),Dit={kernelName:gO,backendName:"webgl",kernelFunc:kit}; /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Lit{constructor(t,e){this.outputShape=[],this.outputShape=t,this.variableNames=e.map(((t,e)=>`T${e}`));const n=[];this.variableNames.forEach((t=>{n.push(`float v${t} = get${t}AtOutCoords();`)}));const i=this.variableNames.map((t=>`v${t}`)).join(" + ");this.userCode=`\n void main() {\n ${n.join("\n ")}\n\n float result = ${i};\n setOutput(result);\n }\n `}} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Fit{constructor(t,e){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.variableNames=e.map(((t,e)=>`T${e}`));const n=[];this.variableNames.forEach((t=>{n.push(`vec4 v${t} = get${t}AtOutCoords();`)}));const i=this.variableNames.map((t=>`v${t}`)).join(" + ");this.userCode=`\n void main() {\n ${n.join("\n ")}\n\n vec4 result = ${i};\n setOutput(result);\n }\n `}}const Pit={kernelName:_O,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function t(e){const{inputs:n,backend:i}=e,s=n;if(1===s.length)return Wnt({inputs:{x:s[0]},backend:i});if(s.length>lO().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){const e=Math.floor(s.length/2),n=t({inputs:s.slice(0,e),backend:i}),r=t({inputs:s.slice(e),backend:i});return t({inputs:[n,r],backend:i})}const r=s.map((t=>t.dtype)).reduce(((t,e)=>Pk(t,e))),a=s.map((t=>t.shape)),o=lO().getBool("WEBGL_PACK")?new Fit(s[0].shape,a):new Lit(s[0].shape,a);return i.runWebGLProgram(o,s,r)}};const $it={kernelName:TO,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r,keepDims:a}=i,o=s.shape.length,l=kA(r,s.shape);let u=l;const h=yB(u,o);let p=s;null!=h&&(p=Eit({inputs:{x:s},backend:n,attrs:{perm:h}}),u=EB(u.length,o)),TB("all",u,o);const[c,d]=gB(p.shape,u),f=pit({inputs:{x:p},backend:n,attrs:{shape:[-1,bA(d)]}}),m=mit(f,f.dtype,"all",n);let g;if(a){g=pit({inputs:{x:m},backend:n,attrs:{shape:_B(c,l)}})}else g=pit({inputs:{x:m},backend:n,attrs:{shape:c}});return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),null!=h&&n.disposeIntermediateTensorInfo(p),g}};const Bit={kernelName:yO,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r,keepDims:a}=i,o=s.shape.length,l=kA(r,s.shape);let u=l;const h=yB(u,o);let p=s;null!=h&&(p=Eit({inputs:{x:s},backend:n,attrs:{perm:h}}),u=EB(u.length,o)),TB("any",u,o);const[c,d]=gB(p.shape,u),f=pit({inputs:{x:p},backend:n,attrs:{shape:[-1,bA(d)]}}),m=mit(f,f.dtype,"any",n);let g;if(a){g=pit({inputs:{x:m},backend:n,attrs:{shape:_B(c,l)}})}else g=pit({inputs:{x:m},backend:n,attrs:{shape:c}});return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),null!=h&&n.disposeIntermediateTensorInfo(p),g}}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Vit{constructor(t,e,n){this.variableNames=["A"];const{windowSize:i,batchSize:s,outSize:r}=t;n||this.variableNames.push("bestIndicesA"),this.outputShape=[s,r];const a="max"===e?">":"<",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 * ${i};\n\n int bestIndex = inOffset;\n float bestValue = getA(batch, bestIndex);\n\n for (int i = 0; i < ${i}; i++) {\n int inIdx = ${o};\n float candidate = getA(batch, inIdx);\n if (candidate ${a} bestValue) {\n bestValue = candidate;\n bestIndex = inIdx;\n }\n }\n setOutput(float(bestIndex));\n }\n `}} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Uit{constructor(t,e,n,i){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,yA(t.length>2,(()=>`Packed arg${n.charAt(0).toUpperCase()+n.slice(1)} supports only inputs with rank above 2.`));const s=t[t.length-1],r=Math.ceil(s/e);this.outputShape=t.slice(0,-1),r>1&&this.outputShape.push(r),i||this.variableNames.push("bestIndicesA");const a=this.outputShape,o=a.length,l=Mtt(o),u=pnt("coords",o);let h,p;if(1===r){p=o+1;const t=Mtt(p);h=`\n ${t} sourceLocR = ${t}(${u.join()}, 0);\n ++${u[o-1]};\n ${t} sourceLocG = ${t}(${u.join()}, 0);\n ++${u[o-2]};\n ${t} sourceLocA = ${t}(${u.join()}, 0);\n --${u[o-1]};\n ${t} sourceLocB = ${t}(${u.join()}, 0);\n --${u[o-2]};`}else p=o,h=`\n ${l} sourceLocR = coords;\n ++${u[o-1]};\n ${l} sourceLocG = coords;\n ++${u[o-2]};\n ${l} sourceLocA = coords;\n --${u[o-1]};\n ${l} sourceLocB = coords;\n --${u[o-2]};`;const c=["x","y","z","w","u","v"].slice(0,p),d="."+c[p-1],f=c.map((t=>"int "+t)),m=pnt("sourceLocR",p-1).concat("inIdx.r"),g=pnt("sourceLocG",p-1).concat("inIdx.g"),_=pnt("sourceLocB",p-1).concat("inIdx.b"),T=pnt("sourceLocA",p-1).concat("inIdx.a"),y="max"===n?"greaterThan":"lessThan",I=i?"":`\n inIdx = round(vec4(getBestIndicesAChannel(${m.join()}),\n getBestIndicesAChannel(${g.join()}),\n getBestIndicesAChannel(${_.join()}),\n getBestIndicesAChannel(${T.join()})));`,E=`vec4(\n getAChannel(${m.join()}),\n hasNextCol ? getAChannel(${g.join()}) : 0.,\n hasNextRow ? getAChannel(${_.join()}) : 0.,\n hasNextRow && hasNextCol ? getAChannel(${T.join()}) : 0.)`,b=i?"":`\n float getBestIndicesAChannel(${f.join()}) {\n return getChannel(getBestIndicesA(${c.join()}),\n vec2(${c.slice(-2).join()}));\n }`;this.userCode=`\n float getAChannel(${f.join()}) {\n return getChannel(getA(${c.join()}),\n vec2(${c.slice(-2).join()}));\n }\n ${b}\n void main() {\n ${l} coords = getOutputCoords();\n bool hasNextCol = ${u[o-1]} < ${a[o-1]-1};\n bool hasNextRow = ${u[o-2]} < ${a[o-2]-1};\n ${h}\n ivec4 srcIdx = ivec4(sourceLocR${d}, sourceLocG${d},\n sourceLocB${d}, sourceLocA${d}) * ${e};\n ivec4 inIdx = srcIdx;\n vec4 bestIndex = vec4(inIdx);\n vec4 bestValue = ${E};\n\n for (int i = 0; i < ${e}; i++) {\n inIdx = srcIdx;\n ${I}\n vec4 candidate = ${E};\n bvec4 nan = isnan(candidate);\n bvec4 replace = bvec4(\n vec4(${y}(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 `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Yit(t,e,n,i=null){let s=e.shape[0],r=e.shape[1];null!=i&&(s=i.shape[0],r=i.shape[1]);const a=gG(r),o={windowSize:a,inSize:r,batchSize:s,outSize:Math.ceil(r/a)},l=new Vit(o,n,null==i),u=[e];null!=i&&u.push(i);const h=t.runWebGLProgram(l,u,"int32");if(1===h.shape[1])return h;const p=Yit(t,e,n,h);return t.disposeIntermediateTensorInfo(h),p}function Git(t,e,n,i=null){const s=null!=i?i.shape:e.shape,r=gG(s[s.length-1]),a=new Uit(s,r,n,null==i),o=null==i?[e]:[e,i],l=t.runWebGLProgram(a,o,"int32");if(l.shape.length===e.shape.length){const i=Git(t,e,n,l);return t.disposeIntermediateTensorInfo(l),i}return l}function Hit(t,e,n,i){const s=[n];if(TB("arg"+i.charAt(0).toUpperCase()+i.slice(1),s,e.shape.length),!lO().getBool("WEBGL_PACK_REDUCE")||e.shape.length<=2){const n=[],r=t.texData.get(e.dataId);let a=e;null!==r&&r.isPacked&&(a=t.unpackTensor(e),n.push(a));const[o,l]=gB(a.shape,s),u=bA(l),h=pit({inputs:{x:a},backend:t,attrs:{shape:[-1,u]}});n.push(h);const p=Yit(t,h,i);n.push(p);const c=pit({inputs:{x:p},backend:t,attrs:{shape:o}});return n.forEach((e=>t.disposeIntermediateTensorInfo(e))),c}return Git(t,e,i)}const Wit={kernelName:IO,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r}=i;let a=kA(r,s.shape);const o=yB(a,s.shape.length);let l=s;const u=[];null!=o&&(l=Eit({inputs:{x:s},backend:n,attrs:{perm:o}}),u.push(l),a=EB(a.length,l.shape.length)),TB("argMax",[a[0]],l.shape.length);const h=Hit(n,l,a[0],"max");return u.forEach((t=>n.disposeIntermediateTensorInfo(t))),h}};const zit={kernelName:EO,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r}=i;let a=kA(r,s.shape);const o=yB(a,s.shape.length);let l=s;const u=[];null!=o&&(l=Eit({inputs:{x:s},backend:n,attrs:{perm:o}}),u.push(l),a=EB(a.length,l.shape.length)),TB("argMin",[a[0]],l.shape.length);const h=Hit(n,l,a[0],"min");return u.forEach((t=>n.disposeIntermediateTensorInfo(t))),h}},Xit=nit({opSnippet:ynt+"\n if (abs(x) > 1.) {\n return NAN;\n }\n return asin(x);\n"}),jit={kernelName:bO,backendName:"webgl",kernelFunc:Xit},qit=nit({opSnippet:ynt+"return log(x + sqrt(x * x + 1.0));"}),Kit={kernelName:vO,backendName:"webgl",kernelFunc:qit},Qit=nit({opSnippet:ynt+"\n return atan(x);\n"}),Jit={kernelName:wO,backendName:"webgl",kernelFunc:Qit},Zit=iit({opSnippet:Unt+"\n return atan(a, b);\n",packedOpSnippet:"\n vec4 result = atan(a, b);\n bvec4 isNaNA = isnan(a);\n bvec4 isNaNB = isnan(b);\n bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w);\n "+Gnt+"\n return result;\n"}),tst={kernelName:xO,backendName:"webgl",kernelFunc:Zit},est=nit({opSnippet:ynt+"\n if ((x < -1.0) || (x > 1.0)) return NAN;\nreturn (log(1.0 + x) - log(1.0 - x)) / 2.0;"}),nst={kernelName:SO,backendName:"webgl",kernelFunc:est}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class ist{constructor(t,e,n,i=!1,s=!1){if(this.variableNames=["x"],"avg"===e&&n)throw new Error("Cannot compute positions for average pool.");const r=t.filterWidth,a=t.strideHeight,o=t.strideWidth,l=t.dilationHeight,u=t.dilationWidth,h=t.effectiveFilterHeight,p=t.effectiveFilterWidth,c=t.padInfo.top,d=t.padInfo.left;this.outputShape=t.outShape;const f="avg"===e,m=`((batch * ${t.inHeight} + xR) * ${t.inWidth} + xC) * ${t.inChannels} + d`,g=`(xR * ${t.inWidth} + xC) * ${t.inChannels} + d`;let _="0.0";if(f||(_="-1.0 / 1e-20"),n){const e=">=";return void(this.userCode=`\n const ivec2 strides = ivec2(${a}, ${o});\n const ivec2 pads = ivec2(${c}, ${d});\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 < ${h};\n wR += ${l}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${t.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${p};\n wC += ${u}) {\n int xC = xCCorner + wC;\n\n if (xC < 0 || xC >= ${t.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 ${e} currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition = ${i?s?m:g:`wR * ${p} + wC`};\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n `)}let T=`${e}(${e}(${e}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"avg"===e&&(T="avgValue / max(count, 1.0)");const y=4*Math.floor(r/4),I=r%4,E=`\n if (${f}) {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n `;this.userCode=`\n const ivec2 strides = ivec2(${a}, ${o});\n const ivec2 pads = ivec2(${c}, ${d});\n const float initializationValue = ${_};\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 >= ${t.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(${_});\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wR = 0; wR < ${h};\n wR += ${l}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${t.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${y}; wC += 4) {\n int xC = xCCorner + wC * ${u};\n\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${u}, d),\n getValue(batch, xR, xC + 2 * ${u}, d),\n getValue(batch, xR, xC + 3 * ${u}, d)\n );\n\n ${E}\n }\n\n int xC = xCCorner + ${y};\n if (${1===I}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${E}\n } else if (${2===I}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${u}, d),\n initializationValue,\n initializationValue\n );\n\n ${E}\n } else if (${3===I}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${u}, d),\n getValue(batch, xR, xC + 2 * ${u}, d),\n initializationValue\n );\n\n ${E}\n }\n }\n setOutput(${T});\n }\n `}}class sst{constructor(t,e,n,i=!1,s=!1){if(this.variableNames=["x"],"avg"===e&&n)throw new Error("Cannot compute positions for average pool.");const r=t.filterWidth,a=t.strideDepth,o=t.strideHeight,l=t.strideWidth,u=t.dilationDepth,h=t.dilationHeight,p=t.dilationWidth,c=t.effectiveFilterDepth,d=t.effectiveFilterHeight,f=t.effectiveFilterWidth,m=t.padInfo.front,g=t.padInfo.top,_=t.padInfo.left;this.outputShape=t.outShape;const T="avg"===e;let y="0.0";if(T||(y="-1.0 / 1e-20"),n){const e=">=";return void(this.userCode=`\n const ivec3 strides =\n ivec3(${a}, ${o}, ${l});\n const ivec3 pads = ivec3(${m}, ${g}, ${_});\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 < ${c};\n wD += ${u}) {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= ${t.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${d};\n wR += ${h}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${t.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 >= ${t.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 ${e} currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition = ${i?s?`(((batch * ${t.inDepth} + xD) * ${t.inHeight} + xR) * ${t.inWidth} + xC) * ${t.inChannels} + ch`:`((xD * ${t.inHeight} + xR) * ${t.inWidth} + xC) * ${t.inChannels} + ch`:`wD * ${d} * ${f} +\n wR * ${f} + wC`};\n }\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n `)}let I=`${e}(${e}(${e}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"avg"===e&&(I="avgValue / max(count, 1.0)");const E=4*Math.floor(r/4),b=r%4,v=`\n if (${T}) {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n `;this.userCode=`\n const ivec3 strides =\n ivec3(${a}, ${o}, ${l});\n const ivec3 pads = ivec3(${m}, ${g}, ${_});\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 xD, int xR, int xC, int ch) {\n if (xC < 0 || xC >= ${t.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(${y});\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wD = 0; wD < ${c};\n wD += ${u}) {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= ${t.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${d};\n wR += ${h}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${t.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${E}; 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 ${v}\n }\n\n int xC = xCCorner + ${E};\n if (${1===b}) {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${v}\n } else if (${2===b}) {\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 ${v}\n } else if (${3===b}) {\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 ${v}\n }\n }\n }\n setOutput(${I});\n }\n `}}const rst={kernelName:RO,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e;ptt(s,"avgPool");const{filterSize:r,strides:a,pad:o,dimRoundingMode:l}=i;yA(_$(a,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${a} and dilations '1'`));const u=o$(s.shape,r,a,1,o,l);if(1===u.filterWidth&&1===u.filterHeight&&SA(u.inShape,u.outShape))return Wnt({inputs:{x:s},backend:n});const h=new ist(u,"avg",!1);return n.runWebGLProgram(h,[s],"float32")}};const ast={kernelName:OO,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{filterSize:r,strides:a,pad:o,dimRoundingMode:l,dataFormat:u}=i,h=l$(s.shape,r,a,[1,1,1],o,l,u),p=new sst(h,"avg",!1);return n.runWebGLProgram(p,[s],"float32")}}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class ost{constructor(t){this.variableNames=["dy"],this.outputShape=t.inShape;const e=t.filterHeight,n=t.filterWidth,i=t.strideHeight,s=t.strideWidth,r=t.dilationHeight,a=t.dilationWidth,o=t.effectiveFilterHeight,l=t.effectiveFilterWidth,u=o-1-t.padInfo.top,h=l-1-t.padInfo.left,p=1/(e*n);this.userCode=`\n const ivec2 pads = ivec2(${u}, ${h});\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 += ${r}) {\n float dyR = float(dyRCorner + wR) / ${i}.0;\n\n if (dyR < 0.0 || dyR >= ${t.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${l};\n wC+= ${a}) {\n float dyC = float(dyCCorner + wC) / ${s}.0;\n\n if (dyC < 0.0 || dyC >= ${t.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 lst{constructor(t){this.variableNames=["dy"],this.outputShape=t.inShape;const e=t.filterDepth,n=t.filterHeight,i=t.filterWidth,s=t.strideDepth,r=t.strideHeight,a=t.strideWidth,o=t.dilationDepth,l=t.dilationHeight,u=t.dilationWidth,h=t.effectiveFilterDepth,p=t.effectiveFilterHeight,c=t.effectiveFilterWidth,d=h-1-t.padInfo.front,f=p-1-t.padInfo.top,m=c-1-t.padInfo.left,g=1/(e*n*i);this.userCode=`\n const ivec3 pads = ivec3(${d}, ${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 < ${h};\n wD += ${o}) {\n float dyD = float(dyDCorner + wD) / ${s}.0;\n\n if (dyD < 0.0 || dyD >= ${t.outDepth}.0 || fract(dyD) > 0.0) {\n continue;\n }\n int idyD = int(dyD);\n\n for (int wR = 0; wR < ${p};\n wR += ${l}) {\n float dyR = float(dyRCorner + wR) / ${r}.0;\n\n if (dyR < 0.0 || dyR >= ${t.outHeight}.0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${c};\n wC += ${u}) {\n float dyC = float(dyCCorner + wC) / ${a}.0;\n\n if (dyC < 0.0 || dyC >= ${t.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 ust={kernelName:MO,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{dy:s,input:r}=e,a=r,{filterSize:o,strides:l,pad:u,dimRoundingMode:h}=i,p=l$(a.shape,o,l,[1,1,1],u,h),c=new lst(p);return n.runWebGLProgram(c,[s],a.dtype)}};const hst={kernelName:AO,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{dy:s,input:r}=e,a=r;ptt([s,r],"avgPoolGrad");const{filterSize:o,strides:l,pad:u}=i,h=o$(a.shape,o,l,1,u),p=new ost(h);return n.runWebGLProgram(p,[s],a.dtype)}};const pst={kernelName:CO,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{a:s,b:r}=e,{transposeA:a,transposeB:o}=i;return wit({a:s,b:r,transposeA:a,transposeB:o,backend:n})}}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class cst{constructor(t,e,n,i,s,r){this.outputShape=[],this.variableNames=["x","mean","variance"],yF(t,e),yF(t,n);let a="0.0";null!=i&&(yF(t,i),this.variableNames.push("offset"),a="getOffsetAtOutCoords()");let o="1.0";null!=s&&(yF(t,s),this.variableNames.push("scale"),o="getScaleAtOutCoords()"),this.outputShape=t,this.userCode=`\n void main() {\n float x = getXAtOutCoords();\n float mean = getMeanAtOutCoords();\n float variance = getVarianceAtOutCoords();\n float offset = ${a};\n float scale = ${o};\n float inv = scale * inversesqrt(variance + float(${r}));\n setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1)));\n }\n `}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class dst{constructor(t,e,n,i,s,r){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],yF(t,e),yF(t,n);let a="vec4(0.0)";null!=i&&(yF(t,i),this.variableNames.push("offset"),a="getOffsetAtOutCoords()");let o="vec4(1.0)";null!=s&&(yF(t,s),this.variableNames.push("scale"),o="getScaleAtOutCoords()"),this.outputShape=t,this.userCode=`\n void main() {\n vec4 offset = ${a};\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(${r}));\n\n setOutput((x - mean) * inv + offset);\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const fst={kernelName:wM,backendName:"webgl",kernelFunc:({inputs:t,backend:e,attrs:n})=>{const{x:i,mean:s,variance:r,offset:a,scale:o}=t;yA(s.shape.length===r.shape.length,(()=>"Batch normalization gradient requires mean and variance to have equal ranks.")),yA(null==a||s.shape.length===a.shape.length,(()=>"Batch normalization gradient requires mean and offset to have equal ranks.")),yA(null==o||s.shape.length===o.shape.length,(()=>"Batch normalization gradient requires mean and scale to have equal ranks."));let{varianceEpsilon:l}=n;null==l&&(l=.001);const u=[i,s,r];let h=null;null!=a&&(h=a.shape,u.push(a));let p=null;null!=o&&(p=o.shape,u.push(o));const c=lO().getBool("WEBGL_PACK_NORMALIZATION")?new dst(i.shape,s.shape,r.shape,h,p,l):new cst(i.shape,s.shape,r.shape,h,p,l);return e.runWebGLProgram(c,u,u[0].dtype)}}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class mst{constructor(t){this.variableNames=["source"],this.outputShape=t,this.rank=t.length;const e=Mtt(this.rank);this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];const n=function(t){if(1===t)return"sourceLoc";if(t<=6)return gst.slice(0,t).map((t=>"sourceLoc."+t)).join(",");throw Error(`Slicing for rank ${t} is not yet supported`)}(this.rank);let i;i=`\n ${e} sourceLoc;\n ${e} coords = getOutputCoords();\n ${t.map(((t,e)=>`sourceLoc.${gst[e]} = start[${e}] + coords.${gst[e]};`)).join("\n")}\n `,this.userCode=`\n void main() {\n ${i}\n setOutput(getSource(${n}));\n }\n `}}const gst=["x","y","z","w","u","v"]; /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class _st{constructor(t){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.rank=t.length,this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];const e=Mtt(this.rank),n=pnt("coords",this.rank),i=pnt("sourceLoc",this.rank),s=1===this.rank?"sourceLoc":`vec2(${i.slice(-2).join()})`,r=`getChannel(getSource(${i.join()}), ${s})`,a=`\n result.x = ${r};\n if (++${n[this.rank-1]} < ${t[this.rank-1]}) {\n ++${i[this.rank-1]};\n result.y = ${r};\n --${i[this.rank-1]};\n }\n `,o=1===this.rank?"":`\n --${n[this.rank-1]};\n if (++${n[this.rank-2]} < ${t[this.rank-2]}) {\n ++${i[this.rank-2]};\n result.z = ${r};\n if (++${n[this.rank-1]} < ${t[this.rank-1]}) {\n ++${i[this.rank-1]};\n result.w = ${r};\n }\n }\n `,l=this.rank<=4?`sourceLoc = coords +\n ${e}(${t.map(((t,e)=>`start[${e}]`)).join()});`:t.map(((t,e)=>`${i[e]} = ${n[e]} + start[${e}];`)).join("\n");this.userCode=`\n void main() {\n ${e} coords = getOutputCoords();\n ${e} sourceLoc;\n ${l}\n vec4 result = vec4(0.);\n ${a}\n ${o}\n setOutput(result);\n }\n `}}function Tst(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{begin:r,size:a}=i,[o,l]=OP(s,r,a);if(mP(s,o,l),0===bA(l))return n.makeTensorInfo(l,s.dtype,[]);if(n.shouldExecuteOnCPU([s])||"string"===s.dtype){const t=n.texData.get(s.dataId),e=qet(t.values,o,l,s.shape,s.dtype);return n.makeTensorInfo(l,s.dtype,e)}const{isPacked:u}=n.texData.get(s.dataId),h=RP(s.shape,o,l);if(u||!h){const t=lO().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new _st(l):new mst(l),e=[o];return n.runWebGLProgram(t,[s],s.dtype,e)}return n.uploadToGPU(s.dataId), /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i){const s=i.texData.get(t.dataId),r=i.makeTensorInfo(n,t.dtype),a=i.texData.get(r.dataId);Object.assign(a,s),a.refCount=1,a.shape=n,a.dtype=t.dtype;let o=AP(e,jA(t.shape));s.slice&&(o+=s.slice.flatOffset),a.slice={flatOffset:o,origDataId:s.slice&&s.slice.origDataId||t.dataId};const l=i.dataRefCount.get(a.slice.origDataId)||1;return i.dataRefCount.set(a.slice.origDataId,l+1),r}(s,o,l,n)}const yst={kernelName:HC,backendName:"webgl",kernelFunc:Tst},Ist={kernelName:NO,backendName:"webgl",kernelFunc:t=>{const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{blockShape:r,crops:a}=i;yA(s.shape.length<=4,(()=>"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet"));const o=r.reduce(((t,e)=>t*e)),l=TG(s.shape,r,o),u=yG(l.length,r.length),h=IG(s.shape,r,o),p=EG(a,r.length),c=bG(h,a,r.length),d=[],f=pit({inputs:{x:s},backend:n,attrs:{shape:l}}),m=Eit({inputs:{x:f},backend:n,attrs:{perm:u}}),g=pit({inputs:{x:m},backend:n,attrs:{shape:h}}),_=Tst({inputs:{x:g},backend:n,attrs:{begin:p,size:c}});return d.push(f),d.push(m),d.push(g),d.forEach((t=>n.disposeIntermediateTensorInfo(t))),_}};const Est={kernelName:kO,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,weights:r}=e,{size:a}=i,o=n.readSync(s.dataId),l=n.readSync(r.dataId),u=met(o,l,r.dtype,r.shape,a);return n.makeTensorInfo([a],r.dtype,u)}};const bst={kernelName:DO,backendName:"webgl",kernelFunc:function(t){const{inputs:e,backend:n}=t,{a:i,b:s}=e,r=lO().getBool("WEBGL_PACK_BINARY_OPERATIONS"),a=lO().getNumber("WEBGL_VERSION");if(n.shouldExecuteOnCPU([i,s])||1===a){const t=n.texData.get(i.dataId).values,e=n.texData.get(s.dataId).values,[r,a]=_et(i.shape,s.shape,t,e,i.dtype),o=n.makeTensorInfo(a,i.dtype);return n.texData.get(o.dataId).values=r,o}let o;return o=r?new Hnt("\n int r = int(a.r) & int(b.r);\n int g = int(a.g) & int(b.g);\n int rb = int(a.b) & int(b.b);\n int ra = int(a.a) & int(b.a);\n return vec4(r, g, rb, ra);\n",i.shape,s.shape,!1):new Ynt("\n return float(int(a.r) & int(b.r));\n",i.shape,s.shape),n.runWebGLProgram(o,[i,s],i.dtype)}};const vst={kernelName:FO,backendName:"webgl",kernelFunc: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n}=t,{s0:i,s1:s}=e,r=n.readSync(i.dataId),a=n.readSync(s.dataId),o=yF(Array.from(r),Array.from(a));return n.makeTensorInfo([o.length],"int32",Int32Array.from(o))}},wst=iit({opSnippet:"return float(a != b);",cpuKernelImpl:Bet,dtype:"bool"}),Sst={kernelName:pC,backendName:"webgl",kernelFunc:wst}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function xst(t){const{inputs:e,backend:n}=t,{input:i}=e;return Wnt({inputs:{x:n.texData.get(i.dataId).complexTensorInfos.real},backend:n})}const Rst={kernelName:RC,backendName:"webgl",kernelFunc:xst},Ast="return float(int(x));";const Ost={kernelName:PO,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function t(e){const{inputs:n,backend:i,attrs:s}=e,{x:r}=n,{dtype:a}=s;if("complex64"===a){if("complex64"===r.dtype)return Wnt({inputs:{x:r},backend:i});const e=lV(r.shape),n=t({inputs:{x:r},backend:i,attrs:{dtype:"float32"}}),s=Xnt({inputs:{real:n,imag:e},backend:i});return e.dispose(),i.disposeIntermediateTensorInfo(n),s}if("complex64"===r.dtype){const e=xst({inputs:{input:r},backend:i}),n=t({inputs:{x:e},backend:i,attrs:{dtype:a}});return i.disposeIntermediateTensorInfo(e),n}if(!BA(r.dtype,a)){const t=Wnt({inputs:{x:r},backend:i});return{dataId:t.dataId,shape:t.shape,dtype:a}}if(i.shouldExecuteOnCPU([r])){const t=i.texData.get(r.dataId).values,[e,n,s]=Tet(t,r.shape,r.dtype,a);return i.makeTensorInfo(e,n,s)}if("int32"===a)return function(t,e){const n=new Tnt(t.shape,Ast),i=e.runWebGLProgram(n,[t],"int32");return{dataId:i.dataId,shape:i.shape,dtype:i.dtype}}(r,i);if("bool"===a){const t=i.makeTensorInfo([],"bool",LA("bool",1)),e=wst({inputs:{a:r,b:t},backend:i});return i.disposeIntermediateTensorInfo(t),e}throw new Error(`Error in Cast: failed to cast ${r.dtype} to ${a}`)}},Mst="return ceil(x);",Cst=nit({opSnippet:Mst,packedOpSnippet:Mst,cpuKernelImpl:yet}),Nst={kernelName:$O,backendName:"webgl",kernelFunc:Cst}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class kst{constructor(t){this.variableNames=["A"],this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=t,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 "}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Dst{constructor(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=t,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 Lst={kernelName:BO,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{clipValueMin:r,clipValueMax:a}=i;let o;o=lO().getBool("WEBGL_PACK_CLIP")?new Dst(s.shape):new kst(s.shape);const l=[[r],[a]];return n.runWebGLProgram(o,[s],s.dtype,l)}}; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Fst{constructor(t){this.variableNames=["real","imag"],this.outputShape=t,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 "}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Pst(t,e){return{dataId:e.dataId,dtype:e.dtype,shape:t.shape}}const $st={kernelName:UO,backendName:"webgl",kernelFunc:function(t){const{inputs:e,backend:n}=t,{x:i}=e,s=n.texData.get(i.dataId),r=new Fst(i.shape),a=[Pst(i,s.complexTensorInfos.real),Pst(i,s.complexTensorInfos.imag)];return n.runWebGLProgram(r,a,a[0].dtype)}}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Bst{constructor(t){this.outputShape=[],this.outputShape=uG(t,1),this.variableNames=t.map(((t,e)=>`T${e}`));const e=new Array(t.length-1);e[0]=t[0][1];for(let n=1;n`T${e}`));const o=new Array(t.length-1);o[0]=t[0][e];for(let n=1;n= ${o[t-1]}) {\n return getChannel(\n getT${t}(${Ust(a,l,e)}),\n vec2(${Ust(u,l,e)}));\n }`}const c=o.length,d=o[o.length-1];p+=`\n return getChannel(\n getT${c}(${Ust(a,l,d)}),\n vec2(${Ust(u,l,d)}));`,this.userCode=`\n float getValue(${a.map((t=>"int "+t))}) {\n ${p}\n }\n\n void main() {\n ${s} coords = getOutputCoords();\n vec4 result = vec4(getValue(${r}), 0., 0., 0.);\n\n ${r[i-1]} = ${r[i-1]} + 1;\n if (${r[i-1]} < ${n[i-1]}) {\n result.g = getValue(${r});\n }\n\n ${r[i-2]} = ${r[i-2]} + 1;\n if (${r[i-2]} < ${n[i-2]}) {\n result.a = getValue(${r});\n }\n\n ${r[i-1]} = ${r[i-1]} - 1;\n if (${r[i-2]} < ${n[i-2]} &&\n ${r[i-1]} < ${n[i-1]}) {\n result.b = getValue(${r});\n }\n setOutput(result);\n }\n `}}function Ust(t,e,n){const i=t.indexOf(e);return t.map(((t,e)=>e===i?`${t} - ${n}`:t)).join()} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Yst(t){const{inputs:e,backend:n}=t,{input:i}=e;return Wnt({inputs:{x:n.texData.get(i.dataId).complexTensorInfos.imag},backend:n})}const Gst={kernelName:CM,backendName:"webgl",kernelFunc:Yst}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Hst(t,e,n){const i=t[0].dtype;if("complex64"===i){const i=t.map((t=>xst({inputs:{input:t},backend:n}))),s=t.map((t=>Yst({inputs:{input:t},backend:n}))),r=Hst(i,e,n),a=Hst(s,e,n),o=Xnt({inputs:{real:r,imag:a},backend:n});return i.forEach((t=>n.disposeIntermediateTensorInfo(t))),s.forEach((t=>n.disposeIntermediateTensorInfo(t))),n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(a),o}let s=n.shouldExecuteOnCPU(t);if("string"===i&&(s=!0),s){const s=t.map((t=>{const i=bA(t.shape.slice(e));return pit({inputs:{x:t},backend:n,attrs:{shape:[-1,i]}})})),r=s.map((t=>({vals:n.readSync(t.dataId),shape:t.shape}))),a=uG(s.map((t=>t.shape)),1),o=1===s[0].shape[0],l=Iet(r,a,i,o),u=uG(t.map((t=>t.shape)),e),h=n.makeTensorInfo(u,i,l);return s.forEach((t=>n.disposeIntermediateTensorInfo(t))),h}const r=t.filter((t=>bA(t.shape)>0)),a=lO().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&r[0].shape.length>1;if(1===r.length){const e=a?new Tnt(t[0].shape,Snt):new Nnt(t[0].shape,Snt);return n.runWebGLProgram(e,t,i)}const o=lO().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER");if(r.length>o){const t=[];for(let i=0;it.shape)),e);return n.runWebGLProgram(t,r,i)}const{tensors2D:l,outShape:u}=function(t,e,n){const i=uG(t.map((t=>t.shape)),e),s=t.map((t=>pit({inputs:{x:t},attrs:{shape:[-1,bA(t.shape.slice(e))]},backend:n})));return{tensors2D:s,outShape:i}}(r,e,n),h=new Bst(l.map((t=>t.shape))),p=n.runWebGLProgram(h,l,i);l.forEach((t=>n.disposeIntermediateTensorInfo(t)));const c=pit({inputs:{x:p},attrs:{shape:u},backend:n});return n.disposeIntermediateTensorInfo(p),c} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Wst(t){const{inputs:e,backend:n,attrs:i}=t,{axis:s}=i,r=kA(s,e[0].shape)[0];lG(e.map((t=>t.shape)),r);const a=uG(e.map((t=>t.shape)),r);if(0===bA(a))return n.makeTensorInfo(a,e[0].dtype,[]);const o=e.filter((t=>bA(t.shape)>0));return 1===o.length?Wnt({inputs:{x:o[0]},backend:n}):Hst(o,r,n)}const zst={kernelName:YO,backendName:"webgl",kernelFunc:Wst}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Xst{constructor(t,e=!1,n=null,i=!1,s=!1){this.variableNames=["x","W"],this.outputShape=t.outShape;const r=t.padInfo.top,a=t.padInfo.left,o=t.strideHeight,l=t.strideWidth,u=t.dilationHeight,h=t.dilationWidth,p=t.filterHeight,c=t.filterWidth,d=4*Math.floor(t.inChannels/4),f=t.inChannels%4,m="channelsLast"===t.dataFormat,g=m?1:2,_=m?2:3,T=m?3:1;let y="",I="";n&&(y=i?`float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:s?`float activation(float a) {\n float b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`\n float activation(float x) {\n ${n}\n }\n `,I="result = activation(result);");const E=e?"result += getBiasAtOutCoords();":"";e&&this.variableNames.push("bias"),i&&this.variableNames.push("preluActivationWeights"),s&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${y}\n\n const ivec2 strides = ivec2(${o}, ${l});\n const ivec2 pads = ivec2(${r}, ${a});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d2 = coords[${T}];\n\n ivec2 xRCCorner =\n ivec2(coords[${g}], coords[${_}]) * 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 * ${u};\n\n if (xR < 0 || xR >= ${t.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${c}; wC++) {\n int xC = xCCorner + wC * ${h};\n\n if (xC < 0 || xC >= ${t.inWidth}) {\n continue;\n }\n\n for (int d1 = 0; d1 < ${d}; 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, ${d}) *\n getW(wR, wC, ${d}, d2);\n } else {\n dotProd +=\n getX(batch, ${d}, xR, xC) *\n getW(wR, wC, ${d}, d2);\n }\n\n } else if (${2===f}) {\n vec2 wValues = vec2(\n getW(wR, wC, ${d}, d2),\n getW(wR, wC, ${d} + 1, d2)\n );\n\n if (${m}) {\n vec2 xValues = vec2(\n getX(batch, xR, xC, ${d}),\n getX(batch, xR, xC, ${d} + 1)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec2 xValues = vec2(\n getX(batch, ${d}, xR, xC),\n getX(batch, ${d} + 1, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n } else if (${3===f}) {\n vec3 wValues = vec3(\n getW(wR, wC, ${d}, d2),\n getW(wR, wC, ${d} + 1, d2),\n getW(wR, wC, ${d} + 2, d2)\n );\n\n if (${m}) {\n vec3 xValues = vec3(\n getX(batch, xR, xC, ${d}),\n getX(batch, xR, xC, ${d} + 1),\n getX(batch, xR, xC, ${d} + 2)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec3 xValues = vec3(\n getX(batch, ${d}, xR, xC),\n getX(batch, ${d} + 1, xR, xC),\n getX(batch, ${d} + 2, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n }\n }\n }\n\n float result = dotProd;\n ${E}\n ${I}\n setOutput(result);\n }\n `}}class jst{constructor(t){this.variableNames=["x","W"],this.outputShape=t.outShape;const e=t.padInfo.front,n=t.padInfo.top,i=t.padInfo.left,s=t.strideDepth,r=t.strideHeight,a=t.strideWidth,o=t.dilationDepth,l=t.dilationHeight,u=t.dilationWidth,h=t.filterDepth,p=t.filterHeight,c=t.filterWidth,d=4*Math.floor(t.inChannels/4),f=t.inChannels%4;this.userCode=`\n const ivec3 strides = ivec3(${s}, ${r}, ${a});\n const ivec3 pads = ivec3(${e}, ${n}, ${i});\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 < ${h}; wF++) {\n int xF = xFCorner + wF * ${o};\n\n if (xF < 0 || xF >= ${t.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${p}; wR++) {\n int xR = xRCorner + wR * ${l};\n\n if (xR < 0 || xR >= ${t.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${c}; wC++) {\n int xC = xCCorner + wC * ${u};\n\n if (xC < 0 || xC >= ${t.inWidth}) {\n continue;\n }\n\n for (int d1 = 0; d1 < ${d}; 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, ${d}) *\n getW(wF, wR, wC, ${d}, d2);\n } else if (${2===f}) {\n vec2 xValues = vec2(\n getX(batch, xF, xR, xC, ${d}),\n getX(batch, xF, xR, xC, ${d} + 1)\n );\n vec2 wValues = vec2(\n getW(wF, wR, wC, ${d}, d2),\n getW(wF, wR, wC, ${d} + 1, d2)\n );\n dotProd += dot(xValues, wValues);\n } else if (${3===f}) {\n vec3 xValues = vec3(\n getX(batch, xF, xR, xC, ${d}),\n getX(batch, xF, xR, xC, ${d} + 1),\n getX(batch, xF, xR, xC, ${d} + 2)\n );\n vec3 wValues = vec3(\n getW(wF, wR, wC, ${d}, d2),\n getW(wF, wR, wC, ${d} + 1, d2),\n getW(wF, wR, wC, ${d} + 2, d2)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n }\n }\n setOutput(dotProd);\n }\n `}} /** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class qst{constructor(t,e=!1,n=null,i=!1,s=!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=t.outShape,this.enableShapeUniforms=Ftt(this.outputShape.length);const r=t.padInfo.left,a=t.strideWidth,o=t.dilationWidth,l=t.filterHeight,u=t.filterWidth,h=u;let p="\n int xR; int xC; int xCOffset;\n vec4 wTexel; vec4 previous; vec4 final;";for(let t=0;t=0 && xR < inDims[0]) {\n ";for(let e=0;e<(h+1)/2;e++){const n=2*e;if(p+=`\n xC = xCCorner + ${n*o};\n `,1===a){if(n= 0 && xCOffset < inDims[1] && xTexelC${n}Ready == 0) {\n xTexelC${n} = 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${n}.zw = vec2(0.0);\n }\n xTexelC${n}Ready = 1;\n }\n `,p+=1===o&&n>0?`\n xC${n} = vec4(xTexelC${n-2}.zw, xTexelC${n}.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${n} = vec4(previous.zw, xTexelC${n}.xy);\n } else {\n xC${n} = vec4(0.0, 0.0, xTexelC${n}.xy);\n }\n `):p+=`\n if (xC >= 0 && xC < inDims[1] && xTexelC${n}Ready == 0) {\n xTexelC${n} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${n}.zw = vec2(0.0);\n }\n xTexelC${n}Ready = 1;\n }\n\n xC${n} = xTexelC${n};\n `,n+1= 0 && xCOffset < inDims[1] && xTexelC${n+1}Ready == 0) {\n xTexelC${n+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${n+1}.zw = vec2(0.0);\n }\n xTexelC${n+1}Ready = 1;\n }\n `,p+=o>1?`\n xCOffset -= 2;\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n xC${n+1} = vec4(previous.zw, xTexelC${n+1}.xy);\n } else {\n xC${n+1} = vec4(0.0, 0.0, xTexelC${n+1}.xy);\n }\n `:`\n xC${n+1} = vec4(xTexelC${n}.zw, xTexelC${n+1}.xy);\n `):p+=1===t?`\n xC${n+1} = xTexelC${n};\n `:`\n xCOffset = xC + ${t};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n+1}Ready == 0) {\n xTexelC${n+1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n+1}.zw = vec2(0.0);\n }\n xTexelC${n+1}Ready = 1;\n }\n\n xC${n+1} = xTexelC${n+1};\n `}}else n= 0 && xCOffset < inDims[1] && xTexelC${n}Ready == 0) {\n xTexelC${n} = 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${n}.zw = vec2(0.0);\n }\n xTexelC${n}Ready = 1;\n }\n\n if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${n+1}Ready == 0) {\n xTexelC${n+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${n+1}.zw = vec2(0.0);\n }\n xTexelC${n+1}Ready = 1;\n }\n\n xC${n} = vec4(xTexelC${n}.zw, xTexelC${n+1}.zw);\n `,n+1= 0 && xCOffset < inDims[1]) {\n final = getX(batch, xR, xCOffset, d1);\n }\n xC${n+1} = vec4(xTexelC${n+1}.xy, final.xy);\n `)):(p+=`\n if(xC >= 0 && xC < inDims[1] && xTexelC${n}Ready == 0) {\n xTexelC${n} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${n}.zw = vec2(0.0);\n }\n xTexelC${n}Ready = 1;\n }\n\n xCOffset = xC + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n+1}Ready == 0) {\n xTexelC${n+1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n+1}.zw = vec2(0.);\n }\n xTexelC${n+1}Ready = 1;\n }\n\n xC${n} = vec4(\n xTexelC${n}.xy, xTexelC${n+1}.xy);\n `,n+1= 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[${a}] && d1 >= 0) {\n\n ch = imod(pos, inChannels);\n\n if (${s}) {\n innerDims = vec2(d1, ch);\n result[${2*t+e}] = getChannel(\n getA(rc.x, d0, int(innerDims.x),\n int(innerDims.y)), innerDims);\n } else {\n innerDims = vec2(d0, d1);\n result[${2*t+e}] = 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 ${l}\n\n ${i.output} = result;\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Qst(t,e){const n=t.length;return n>=3?e?[...t.slice(0,-3),t[n-3]*t[n-2],t[n-1]]:[...t.slice(0,-3),t[n-3],t[n-2]*t[n-1]]:!e&&1===n&&t[0]>1?[t[0],1]:null}function Jst({x:t,filter:e,convInfo:n,backend:i,bias:s=null,preluActivationWeights:r=null,leakyreluAlpha:a=0,activation:o=null}){const l=t.shape,u=i.texData.get(t.dataId),h=n.inChannels,p=l[0]*l[1]*l[2],c=n.outChannels,d="channelsLast"===n.dataFormat,f=!1;let m;const g=[];if(null!=r){const t=Qst(r.shape,d);null!=t&&(r=pit({inputs:{x:r},backend:i,attrs:{shape:t}}),g.push(r))}if(null!=s){const t=Qst(s.shape,d);null!=t&&(s=pit({inputs:{x:s},backend:i,attrs:{shape:t}}),g.push(s))}if(!((1===p||1===c)&&h>vit)&&u.isPacked&&d&&null!=u.texture&&l[2]%2!=0&&SA(u.shape.slice(-3),l.slice(-3))){const h=l[0]*l[1]*(l[2]+1),p={dataId:t.dataId,shape:[1,h,n.inChannels],dtype:t.dtype},c=u.shape;u.shape=u.shape.slice(),u.shape[u.shape.length-2]++,yA(Q7(u.shape,p.shape),(()=>`packed reshape ${u.shape} to ${p.shape} isn't free`));const d=pit({inputs:{x:e},backend:i,attrs:{shape:[1,n.inChannels,n.outChannels]}});g.push(d);const _=wit({a:p,b:d,backend:i,transposeA:false,transposeB:f,bias:s,activation:o,preluActivationWeights:r,leakyreluAlpha:a}),T=i.texData.get(_.dataId);yA(T.isPacked,(()=>"batchMatMul result is expected to be packed")),u.shape=c,T.shape=n.outShape,m=Wnt({inputs:{x:_},backend:i}),m.shape=n.outShape,g.push(_)}else{const l=n.outHeight*n.outWidth,u=pit({inputs:{x:t},backend:i,attrs:{shape:d?[n.batchSize,l,n.inChannels]:[n.batchSize,n.inChannels,l]}}),h=pit({inputs:{x:e},backend:i,attrs:{shape:[1,n.inChannels,n.outChannels]}}),p=wit({a:d?u:h,b:d?h:u,transposeA:!d,transposeB:f,backend:i,bias:s,activation:o,preluActivationWeights:r,leakyreluAlpha:a});m=pit({inputs:{x:p},backend:i,attrs:{shape:n.outShape}}),g.push(u),g.push(h),g.push(p)}for(const t of g)i.disposeIntermediateTensorInfo(t);return m}function Zst({x:t,filter:e,convInfo:n,backend:i,bias:s=null,preluActivationWeights:r=null,leakyreluAlpha:a=0,activation:o=null}){const{filterWidth:l,filterHeight:u,inChannels:h,outWidth:p,outHeight:c,dataFormat:d}=n,f="channelsLast"===d,m=l*u*h,g=c*p,_=[n.batchSize,m,g],T=[];if(null!=r){const t=Qst(r.shape,f);null!=t&&(r=pit({inputs:{x:r},backend:i,attrs:{shape:t}}),T.push(r))}if(null!=s){const t=Qst(s.shape,f);null!=t&&(s=pit({inputs:{x:s},backend:i,attrs:{shape:t}}),T.push(s))}const y=pit({inputs:{x:e},backend:i,attrs:{shape:[1,m,bA(e.shape)/m]}});T.push(y);const I=new Kst(_,n),E=[t.shape,[n.padInfo.top,n.padInfo.left],[n.strideHeight,n.strideWidth],[n.dilationHeight,n.dilationWidth],[n.inChannels],[n.filterWidth*n.inChannels],[n.outWidth]],b=i.runWebGLProgram(I,[t],"float32",E),v=pit({inputs:{x:b},backend:i,attrs:{shape:_}});T.push(b),T.push(v);const w=null!=s,S=null!=r,x="leakyrelu"===o,R=o?sit(o,!0):null,A=new rit(f?v.shape:y.shape,f?y.shape:v.shape,f?[n.batchSize,g,n.outChannels]:[n.batchSize,n.outChannels,g],!0,!1,w,R,S,x),O=f?[v,y]:[y,v];if(s&&O.push(s),S&&O.push(r),x){const t=i.makeTensorInfo([],"float32",rk(a,"float32"));O.push(t),T.push(t)}const M=i.runWebGLProgram(A,O,"float32"),C=pit({inputs:{x:M},backend:i,attrs:{shape:n.outShape}});T.push(M);for(const t of T)i.disposeIntermediateTensorInfo(t);return C}const trt={kernelName:GO,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,filter:r}=e,{strides:a,pad:o,dataFormat:l,dilations:u,dimRoundingMode:h}=i,p=y$(l),c=u$(s.shape,r.shape,a,u,o,h,!1,p);let d;if(1!==c.filterHeight||1!==c.filterWidth||1!==c.dilationHeight||1!==c.dilationWidth||1!==c.strideHeight||1!==c.strideWidth||"SAME"!==c.padInfo.type&&"VALID"!==c.padInfo.type)if(c.strideWidth<=2&&"channelsLast"===p&&lO().getBool("WEBGL_EXP_CONV")){const t=new qst(c),e=[[c.padInfo.top,c.padInfo.left],[c.strideHeight,c.strideWidth],[c.dilationHeight,c.dilationWidth],[c.inHeight,c.inWidth]];d=n.runWebGLProgram(t,[s,r],"float32",e)}else if(lO().getBool("WEBGL_CONV_IM2COL"))d=Zst({x:s,filter:r,convInfo:c,backend:n});else{const t=new Xst(c);d=n.runWebGLProgram(t,[s,r],"float32")}else d=Jst({x:s,filter:r,convInfo:c,backend:n});const f=pit({inputs:{x:d},backend:n,attrs:{shape:c.outShape}});return n.disposeIntermediateTensorInfo(d),f}}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class ert{constructor(t){this.variableNames=["x","dy"],this.outputShape=t.filterShape;const e=t.strideHeight,n=t.strideWidth,i=t.padInfo.top,s=t.padInfo.left,r="channelsLast"===t.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 < ${t.batchSize}; b++) {\n for (int yR = 0; yR < ${t.outHeight}; yR++) {\n int xR = wR + yR * ${e} - ${i};\n\n if (xR < 0 || xR >= ${t.inHeight}) {\n continue;\n }\n\n for (int yC = 0; yC < ${t.outWidth}; yC++) {\n int xC = wC + yC * ${n} - ${s};\n\n if (xC < 0 || xC >= ${t.inWidth}) {\n continue;\n }\n\n ${r?"float dyValue = getDy(b, yR, yC, d2);\n float xValue = getX(b, xR, xC, d1);\n dotProd += (xValue * dyValue);":"float dyValue = getDy(b, d2, yR, yC);\n float xValue = getX(b, d1, xR, xC);\n dotProd += (xValue * dyValue);"}\n }\n }\n }\n setOutput(dotProd);\n }\n `}}class nrt{constructor(t){this.variableNames=["dy","W"],this.outputShape=t.inShape;const e=t.filterHeight,n=t.filterWidth,i=t.strideHeight,s=t.strideWidth,r="channelsLast"===t.dataFormat,a=e-1-t.padInfo.top,o=n-1-t.padInfo.left,l=r?1:2,u=r?2:3,h=r?3:1;this.userCode=`\n const ivec2 pads = ivec2(${a}, ${o});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords[${h}];\n\n ivec2 dyCorner = ivec2(coords[${l}], coords[${u}]) - 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 < ${e}; wR++) {\n float dyR = float(dyRCorner + wR) / ${i}.0;\n\n if (dyR < 0.0 || dyR >= ${t.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = ${e} - 1 - wR;\n\n for (int wC = 0; wC < ${n}; wC++) {\n float dyC = float(dyCCorner + wC) / ${s}.0;\n\n if (dyC < 0.0 || dyC >= ${t.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 < ${t.outChannels}; d2++) {\n\n if (${r}) {\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 irt{constructor(t){this.variableNames=["x","dy"],this.outputShape=t.filterShape;const e=t.strideDepth,n=t.strideHeight,i=t.strideWidth,s=t.padInfo.front,r=t.padInfo.top,a=t.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 < ${t.batchSize}; b++) {\n for (int yF = 0; yF < ${t.outDepth}; yF++) {\n int xF = wF + yF * ${e} - ${s};\n\n if (xF < 0 || xF >= ${t.inDepth}) {\n continue;\n }\n\n for (int yR = 0; yR < ${t.outHeight}; yR++) {\n int xR = wR + yR * ${n} - ${r};\n\n if (xR < 0 || xR >= ${t.inHeight}) {\n continue;\n }\n\n for (int yC = 0; yC < ${t.outWidth}; yC++) {\n int xC = wC + yC * ${i} - ${a};\n\n if (xC < 0 || xC >= ${t.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 srt{constructor(t){this.variableNames=["dy","W"],this.outputShape=t.inShape;const e=t.filterDepth,n=t.filterHeight,i=t.filterWidth,s=t.strideDepth,r=t.strideHeight,a=t.strideWidth,o=e-1-t.padInfo.front,l=n-1-t.padInfo.top,u=i-1-t.padInfo.left;this.userCode=`\n const ivec3 pads = ivec3(${o}, ${l}, ${u});\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 < ${e}; wF++) {\n float dyF = float(dyFCorner + wF) / ${s}.0;\n\n if (dyF < 0.0 || dyF >= ${t.outDepth}.0 || fract(dyF) > 0.0) {\n continue;\n }\n int idyF = int(dyF);\n\n int wFPerm = ${e} - 1 - wF;\n\n for (int wR = 0; wR < ${n}; wR++) {\n float dyR = float(dyRCorner + wR) / ${r}.0;\n\n if (dyR < 0.0 || dyR >= ${t.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 < ${i}; wC++) {\n float dyC = float(dyCCorner + wC) / ${a}.0;\n\n if (dyC < 0.0 || dyC >= ${t.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = ${i} - 1 - wC;\n\n for (int d2 = 0; d2 < ${t.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 rrt={kernelName:HO,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,dy:r}=e,{strides:a,pad:o,dataFormat:l,dimRoundingMode:u,filterShape:h}=i,p=y$(l),c=u$(s.shape,h,a,1,o,u,!1,p),d=new ert(c);return n.runWebGLProgram(d,[s,r],"float32")}}; /** * @license * Copyright 2023 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class art{constructor(t){this.variableNames=["dy","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"strides",type:"vec2"}],this.outputShape=t.inShape,this.enableShapeUniforms=Ftt(this.outputShape.length);const e=t.filterHeight,n=t.filterWidth,i=e-1-t.padInfo.top,s=n-1-t.padInfo.left;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\n ivec2 dyCorner = ivec2(coords[1], coords[2]) - pads;\n int dyRCorner = dyCorner.x;\n int dyCCorner = dyCorner.y;\n\n vec4 result = vec4(0.);\n for (int wR = 0; wR < ${e}; wR++) {\n float dyR = float(dyRCorner + wR) / strides[0];\n if (dyR < 0.0 || dyR >= ${t.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n int wRPerm = ${e} - 1 - wR;\n\n for (int wC = 0; wC < ${n}; wC++) {\n int wCPerm = ${n} - 1 - wC;\n\n float dyC = float(dyCCorner + wC) / strides[1];\n bool idyCVal = (dyC >= 0.0) && (dyC < ${t.outWidth}.0)\n && (fract(dyC) == 0.0);\n int idyC = int(dyC);\n\n float dyC2 = float(dyCCorner + wC + 1) / strides[1];\n bool idyCVal2 = (dyC2 >= 0.0) && (dyC2 < ${t.outWidth}.0)\n && (fract(dyC2) == 0.0);\n int idyC2 = int(dyC2);\n\n if (idyCVal && idyCVal2) {\n for (int d2 = 0; d2 < ${t.outChannels}; d2 += 2) {\n vec4 wValue = getW(wRPerm, wCPerm, d1, d2);\n vec4 dySample = getDy(batch, idyR, idyC, d2);\n vec4 dySample2 = (idyC / 2 == idyC2 / 2) ?\n dySample : getDy(batch, idyR, idyC2, d2);\n\n vec2 dyValue = mod(float(idyC), 2.) == 0. ?\n dySample.xy : dySample.zw;\n result.xy += vec2(dot(dyValue, wValue.xy),\n dot(dyValue, wValue.zw));\n\n dyValue = mod(float(idyC2), 2.) == 0. ?\n dySample2.xy : dySample2.zw;\n result.zw += vec2(dot(dyValue, wValue.xy),\n dot(dyValue, wValue.zw));\n }\n } else if (idyCVal) {\n for (int d2 = 0; d2 < ${t.outChannels}; d2 += 2) {\n vec4 wValue = getW(wRPerm, wCPerm, d1, d2);\n vec4 dySample = getDy(batch, idyR, idyC, d2);\n vec2 dyValue = mod(float(idyC), 2.) == 0. ?\n dySample.xy : dySample.zw;\n result.xy += vec2(dot(dyValue, wValue.xy),\n dot(dyValue, wValue.zw));\n }\n } else if (idyCVal2) {\n for (int d2 = 0; d2 < ${t.outChannels}; d2 += 2) {\n vec4 wValue = getW(wRPerm, wCPerm, d1, d2);\n vec4 dySample = getDy(batch, idyR, idyC2, d2);\n vec2 dyValue = mod(float(idyC2), 2.) == 0. ?\n dySample.xy : dySample.zw;\n result.zw += vec2(dot(dyValue, wValue.xy),\n dot(dyValue, wValue.zw));\n }\n }\n }\n }\n setOutput(result);\n }\n `}}const ort={kernelName:WO,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{dy:s,filter:r}=e,{inputShape:a,strides:o,pad:l,dataFormat:u,dimRoundingMode:h}=i,p=y$(u),c=u$(a,r.shape,o,1,l,h,!1,p);if(lO().getBool("WEBGL_PACK_CONV2DTRANSPOSE")&&"channelsLast"===p){const t=[[c.strideHeight,c.strideWidth]],e=new art(c);return n.runWebGLProgram(e,[s,r],"float32",t)}{const t=new nrt(c);return n.runWebGLProgram(t,[s,r],"float32")}}};const lrt={kernelName:zO,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,filter:r}=e,{strides:a,pad:o,dilations:l}=i,u=h$(s.shape,r.shape,a,l,o),h=new jst(u);return n.runWebGLProgram(h,[s,r],"float32")}};const urt={kernelName:XO,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,dy:r}=e,{strides:a,pad:o,filterShape:l}=i,u=h$(s.shape,l,a,1,o),h=new irt(u);return n.runWebGLProgram(h,[s,r],"float32")}};const hrt={kernelName:jO,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{dy:s,filter:r}=e,{pad:a,strides:o,inputShape:l}=i,u=h$(l,r.shape,o,1,a),h=new srt(u);return n.runWebGLProgram(h,[s,r],"float32")}},prt=nit({opSnippet:eit+"\n return cos(x);\n",packedOpSnippet:`\n vec4 result = cos(x);\n bvec4 isNaN = isnan(x);\n ${Gnt}\n return result;\n`}),crt={kernelName:qO,backendName:"webgl",kernelFunc:prt},drt=nit({opSnippet:"\n float e2x = exp(-x);\n return (e2x + 1.0 / e2x) / 2.0;\n"}),frt={kernelName:KO,backendName:"webgl",kernelFunc:drt}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class mrt{constructor(t,e,n,i,s){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];const[r,a,o,l]=t,[u]=e,[h,p]=n;this.outputShape=[u,h,p,l];const c="bilinear"===i?1:0,[d,f]=[a-1+".0",o-1+".0"],[m,g,_]=h>1?[""+(a-1)/(h-1),"(y2-y1) * height_ratio",`y1*${d} + float(y)*(height_scale)`]:["0.0","0.0",`0.5 * (y1+y2) * ${d}`],[T,y,I]=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(${T});\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 >= ${r}) {\n return;\n }\n\n float height_scale = ${g};\n float width_scale = ${y};\n\n float in_y = ${_};\n if( in_y < 0.0 || in_y > ${d} ) {\n setOutput(float(${s}));\n return;\n }\n float in_x = ${I};\n if( in_x < 0.0 || in_x > ${f} ) {\n setOutput(float(${s}));\n return;\n }\n\n vec2 sourceFracIndexCR = vec2(in_x,in_y);\n if(${c} == 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 `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const grt={kernelName:ZO,backendName:"webgl",kernelFunc:t=>{const{inputs:e,backend:n,attrs:i}=t,{image:s,boxes:r,boxInd:a}=e,{cropSize:o,method:l,extrapolationValue:u}=i,h=new mrt(s.shape,r.shape,o,l,u);return n.runWebGLProgram(h,[s,r,a],"float32")}};var _rt;!function(t){t.Prod="*",t.Sum="+"}(_rt||(_rt={}));class Trt{constructor(t,e,n,i){this.op=t,this.outputShape=e,this.variableNames=["x"],this.customUniforms=[{name:"index",type:"float"}];const s=this.outputShape.length,r=this.op===_rt.Prod?"1.0":"0.0",a=n?r:`getX(${yrt(s,"coords",this.op)})`,o=this.outputShape[this.outputShape.length-1];let l="",u="";n?(l=i?"end != "+(o-1):"end != 0",u=i?"end + 1":"end - 1"):(l=i?`end + pow2 < ${o}`:"end >= pow2",u=i?"end + pow2":"end - pow2"),this.userCode=`\n void main() {\n ${Mtt(s)} coords = getOutputCoords();\n int end = ${Irt(s,"coords",this.op)};\n float val = ${a};\n int pow2 = int(pow(2.0, index));\n if (${l}) {\n int idx = ${u};\n ${Irt(s,"coords",this.op)} = idx;\n val ${this.op}= getX(${yrt(s,"coords",this.op)});\n }\n setOutput(val);\n }\n `}}function yrt(t,e,n){if(1===t)return`${e}`;if(2===t)return`${e}.x, ${e}.y`;if(3===t)return`${e}.x, ${e}.y, ${e}.z`;if(4===t)return`${e}.x, ${e}.y, ${e}.z, ${e}.w`;throw new Error(`Cumulative ${n} for rank ${t} is not yet supported`)}function Irt(t,e,n){if(1===t)return`${e}`;if(2===t)return`${e}.y`;if(3===t)return`${e}.z`;if(4===t)return`${e}.w`;throw new Error(`Cumulative ${n} for rank ${t} is not yet supported`)} /** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Ert(t,e,n,i,s,r){const a=e.shape.length,o=yB([i],a);let l=e;null!=o&&(l=Eit({inputs:{x:e},backend:n,attrs:{perm:o}}));const u=EB(1,a)[0];if(u!==a-1)throw new Error(`WebGL cumprod shader expects an inner-most axis=${e.shape.length-1} but got axis=${i}`);const h=l.shape[u];let p=Wnt({inputs:{x:l},backend:n});for(let e=0;e<=Math.ceil(Math.log2(h))-1;e++){const i=new Trt(t,l.shape,!1,r),s=[[e]],a=p;p=n.runWebGLProgram(i,[p],p.dtype,s),n.disposeIntermediateTensorInfo(a)}if(s){const e=new Trt(t,l.shape,s,r),i=p;p=n.runWebGLProgram(e,[p],p.dtype),n.disposeIntermediateTensorInfo(i)}if(null!=o){const t=Eit({inputs:{x:p},backend:n,attrs:{perm:IB(o)}});return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(l),t}return p}const brt={kernelName:QO,backendName:"webgl",kernelFunc: /** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r,exclusive:a,reverse:o}=i;return Ert(_rt.Prod,s,n,r,a,o)}};const vrt={kernelName:JO,backendName:"webgl",kernelFunc: /** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r,exclusive:a,reverse:o}=i;return Ert(_rt.Sum,s,n,r,a,o)}};const wrt={kernelName:tM,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,weights:r}=e,{size:a,binaryOutput:o}=i;if(1===s.shape.length){const t=n.readSync(s.dataId),e=n.readSync(r.dataId),i=met(t,e,r.dtype,r.shape,a);return n.makeTensorInfo([a],r.dtype,i)}if(2===s.shape.length){const t=n.bufferSync(s),e=n.bufferSync(r),i=get(t,e,a,o);return n.makeTensorInfo(i.shape,r.dtype,i.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${s.shape.length}.`)}}; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Srt{constructor(t,e,n){this.variableNames=["x"],this.outputShape=[],this.outputShape=t,this.blockSize=e,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 / ${e};\n int offset_h = imod(h, ${e});\n int in_w = w / ${e};\n int offset_w = imod(w, ${e});\n int offset_d = (offset_h * ${e} + 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 xrt={kernelName:eM,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{blockSize:r,dataFormat:a}=i,o=s.shape[0],l=("NHWC"===a?s.shape[1]:s.shape[2])*r,u=("NHWC"===a?s.shape[2]:s.shape[3])*r,h=("NHWC"===a?s.shape[3]:s.shape[1])/(r*r),p=new Srt("NHWC"===a?[o,l,u,h]:[o,h,l,u],r,a);return n.runWebGLProgram(p,[s],s.dtype)}}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Rrt{constructor(t,e=!1,n=null,i=!1,s=!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=t.outShape,this.enableShapeUniforms=Ftt(this.outputShape.length);const r=t.filterHeight,a=t.filterWidth,o=t.outChannels/t.inChannels;let l="",u="";n&&(l=i?`float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:s?`float activation(float a) {\n float b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`\n float activation(float x) {\n ${n}\n }\n `,u="result = activation(result);");const h=e?"result += getBiasAtOutCoords();":"";e&&this.variableNames.push("bias"),i&&this.variableNames.push("preluActivationWeights"),s&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${l}\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 < ${r}; 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 < ${a}; 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 ${h}\n ${u}\n setOutput(result);\n }\n `}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Art{constructor(t,e=!1,n=null,i=!1,s=!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=t.outShape,this.enableShapeUniforms=Ftt(this.outputShape.length);const r=t.outChannels/t.inChannels,a=t.padInfo.left,o=t.strideWidth,l=t.dilationWidth,u=t.filterHeight,h=t.filterWidth,p=h;let c="\n int xR; int xC; int xCOffset;\n vec4 wTexel; vec4 previous; vec4 final;";for(let t=0;t=0 && xR < inDims[0]) {\n ";for(let t=0;t<(p+1)/2;t++){const e=2*t;if(c+=`\n xC = xCCorner + ${e*l};\n `,1===o){if(e= 0 && xCOffset < inDims[1] && xTexelC${e}Ready == 0) {\n xTexelC${e} = 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${e}.zw = vec2(0.0);\n }\n xTexelC${e}Ready = 1;\n }\n `,c+=1===l&&e>0?`\n xC${e} = vec4(xTexelC${e-2}.zw, xTexelC${e}.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${e} = vec4(previous.zw, xTexelC${e}.xy);\n } else {\n xC${e} = vec4(0.0, 0.0, xTexelC${e}.xy);\n }\n `):c+=`\n if (xC >= 0 && xC < inDims[1] && xTexelC${e}Ready == 0) {\n xTexelC${e} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${e}.zw = vec2(0.0);\n }\n xTexelC${e}Ready = 1;\n }\n\n xC${e} = xTexelC${e};\n `,e+1= 0 && xCOffset < inDims[1] && xTexelC${e+1}Ready == 0) {\n xTexelC${e+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${e+1}.zw = vec2(0.0);\n }\n xTexelC${e+1}Ready = 1;\n }\n `,c+=l>1?`\n xCOffset -= 2;\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n xC${e+1} = vec4(previous.zw, xTexelC${e+1}.xy);\n } else {\n xC${e+1} = vec4(0.0, 0.0, xTexelC${e+1}.xy);\n }\n `:`\n xC${e+1} = vec4(xTexelC${e}.zw, xTexelC${e+1}.xy);\n `):c+=1===t?`\n xC${e+1} = xTexelC${e};\n `:`\n xCOffset = xC + ${t};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${e+1}Ready == 0) {\n xTexelC${e+1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${e+1}.zw = vec2(0.0);\n }\n xTexelC${e+1}Ready = 1;\n }\n\n xC${e+1} = xTexelC${e+1};\n `}}else e= 0 && xCOffset < inDims[1] && xTexelC${e}Ready == 0) {\n xTexelC${e} = 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${e}.zw = vec2(0.0);\n }\n xTexelC${e}Ready = 1;\n }\n\n if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${e+1}Ready == 0) {\n xTexelC${e+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${e+1}.zw = vec2(0.0);\n }\n xTexelC${e+1}Ready = 1;\n }\n\n xC${e} = vec4(xTexelC${e}.zw, xTexelC${e+1}.zw);\n `,e+1= 0 && xCOffset < inDims[1]) {\n final = getX(batch, xR, xCOffset, d1);\n }\n xC${e+1} = vec4(xTexelC${e+1}.xy, final.xy);\n `)):(c+=`\n if(xC >= 0 && xC < inDims[1] && xTexelC${e}Ready == 0) {\n xTexelC${e} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${e}.zw = vec2(0.0);\n }\n xTexelC${e}Ready = 1;\n }\n\n xCOffset = xC + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${e+1}Ready == 0) {\n xTexelC${e+1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${e+1}.zw = vec2(0.);\n }\n xTexelC${e+1}Ready = 1;\n }\n\n xC${e} = vec4(\n xTexelC${e}.xy, xTexelC${e+1}.xy);\n `,e+1`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${a} and dilations '${h}'`));const p=u$(s.shape,r.shape,a,h,o,u,!0);let c;c=lO().getBool("WEBGL_PACK_DEPTHWISECONV")&&p.strideWidth<=2&&p.outChannels/p.inChannels==1?new Art(p):new Rrt(p);const d=[[p.padInfo.top,p.padInfo.left],[p.strideHeight,p.strideWidth],[p.dilationHeight,p.dilationWidth],[p.inHeight,p.inWidth]];return n.runWebGLProgram(c,[s,r],"float32",d)}}; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Mrt{constructor(t){this.variableNames=["x","dy"],this.outputShape=t.filterShape;const e=t.strideHeight,n=t.strideWidth,i=t.padInfo.top,s=t.padInfo.left,r=t.outChannels/t.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 * ${r} + dm;\n\n float dotProd = 0.0;\n\n // TO DO: Vec4 over the batch size\n for (int b = 0; b < ${t.batchSize}; b++) {\n for (int yR = 0; yR < ${t.outHeight}; yR++) {\n int xR = wR + yR * ${e} - ${i};\n\n if (xR < 0 || xR >= ${t.inHeight}) {\n continue;\n }\n\n for (int yC = 0; yC < ${t.outWidth}; yC++) {\n int xC = wC + yC * ${n} - ${s};\n\n if (xC < 0 || xC >= ${t.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 Crt{constructor(t){this.variableNames=["dy","W"],this.outputShape=t.inShape;const e=t.filterHeight,n=t.filterWidth,i=t.strideHeight,s=t.strideWidth,r=e-1-t.padInfo.top,a=n-1-t.padInfo.left,o=t.outChannels/t.inChannels;this.userCode=`\n const ivec2 pads = ivec2(${r}, ${a});\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 < ${e}; wR++) {\n float dyR = float(dyRCorner + wR) / ${i}.0;\n\n if (dyR < 0.0 || dyR >= ${t.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = ${e} - 1 - wR;\n\n for (int wC = 0; wC < ${n}; wC++) {\n float dyC = float(dyCCorner + wC) / ${s}.0;\n\n if (dyC < 0.0 || dyC >= ${t.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 Nrt={kernelName:iM,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,dy:r}=e,{strides:a,dilations:o,pad:l,dimRoundingMode:u,filterShape:h}=i,p=u$(s.shape,h,a,o,l,u,!0),c=new Mrt(p);return n.runWebGLProgram(c,[s,r],"float32")}};const krt={kernelName:sM,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{dy:s,filter:r}=e,{strides:a,dilations:o,pad:l,dimRoundingMode:u,inputShape:h}=i,p=u$(h,r.shape,a,o,l,u,!0),c=new Crt(p);return n.runWebGLProgram(c,[s,r],"float32")}}; /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Drt{constructor(t){this.variableNames=["X"],this.outputShape=[t,t],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 Lrt={kernelName:rM,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n}=t,{x:i}=e,s=[...i.shape,...i.shape],r=bA(i.shape),a=pit({inputs:{x:i},backend:n,attrs:{shape:[r]}}),o=new Drt(r),l=n.runWebGLProgram(o,[a],a.dtype),u=pit({inputs:{x:l},backend:n,attrs:{shape:s}});return n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(l),u}}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Frt{constructor(t){this.variableNames=["x","W"],this.outputShape=t.outShape;const{inHeight:e,inWidth:n,padInfo:i,strideHeight:s,strideWidth:r,filterHeight:a,filterWidth:o,dilationHeight:l,dilationWidth:u}=t,{top:h,left:p}=i;this.userCode=`\n const ivec2 strides = ivec2(${s}, ${r});\n const ivec2 pads = ivec2(${h}, ${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 < ${a}; h++) {\n int hIn = hBeg + h * ${l};\n\n if (hIn >= 0 && hIn < ${e}) {\n for (int w = 0; w < ${o}; w++) {\n int wIn = wBeg + w * ${u};\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 Prt={kernelName:aM,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,filter:r}=e,{strides:a,pad:o,dilations:l}=i,u=a$(s.shape,r.shape,a,o,"NHWC",l);let h;const p=new Frt(u);h=n.runWebGLProgram(p,[s,r],"float32");const c=pit({inputs:{x:h},backend:n,attrs:{shape:u.outShape}});return n.disposeIntermediateTensorInfo(h),c}};const $rt={kernelName:pM,backendName:"webgl",kernelFunc: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{equation:s}=i,r=e,{allDims:a,summedDims:o,idDims:l}=GG(s,r.length);WG(a.length,l,r);const{path:u,steps:h}=zG(o,l),p=h.length;let c=null,d=a.length;const f=[];for(let t=0;t=0&&(c=yit({inputs:{x:c},backend:n,attrs:{axis:u[t]-(a.length-d),keepDims:!1}}),f.push(c)),d--)}for(const t of f)t!==c&&n.disposeIntermediateTensorInfo(t);return c}},Brt=nit({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"}),Vrt={kernelName:cM,backendName:"webgl",kernelFunc:Brt},Urt={kernelName:dM,backendName:"webgl",kernelFunc:t=>{const{inputs:e,backend:n}=t,{dy:i,y:s}=e,r=lO().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Hnt("\n vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));\n return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));\n",i.shape,s.shape):new Ynt("return (b >= 0.0) ? a : a * (b + 1.0);",i.shape,s.shape);return n.runWebGLProgram(r,[i,s],i.dtype)}},Yrt=iit({opSnippet:"return float(a == b);",packedOpSnippet:"\n return vec4(equal(a, b));\n",dtype:"bool",cpuKernelImpl:Eet}),Grt={kernelName:mM,backendName:"webgl",kernelFunc:Yrt},Hrt=nit({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 = ${SG};\n float a1 = ${xG};\n float a2 = ${RG};\n float a3 = ${AG};\n float a4 = ${OG};\n float a5 = ${MG};\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`}),Wrt={kernelName:fM,backendName:"webgl",kernelFunc:Hrt},zrt=nit({opSnippet:eit+"\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:bet,dtype:"float32"}),Xrt={kernelName:gM,backendName:"webgl",kernelFunc:zrt}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function jrt(t){const{inputs:e,attrs:n,backend:i}=t,{dim:s}=n,{input:r}=e,a=r.shape.length,o=r.shape.slice();let l=s;return s<0&&(yA(-(a+1)<=s,(()=>`Axis must be in the interval [${-(a+1)}, ${a}]`)),l=a+s+1),o.splice(l,0,1),pit({inputs:{x:r},backend:i,attrs:{shape:o}})}const qrt={kernelName:_M,backendName:"webgl",kernelFunc:jrt},Krt="return exp(x) - 1.0;",Qrt=nit({opSnippet:Krt,packedOpSnippet:Krt,cpuKernelImpl:vet}),Jrt={kernelName:TM,backendName:"webgl",kernelFunc:Qrt}; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Zrt{constructor(t,e,n){this.variableNames=["real","imag"];const i=e[1];this.outputShape=e;const s=n?`2.0 * ${Math.PI}`:`-2.0 * ${Math.PI}`,r=n?`${i}.0`:"1.0";let a;if("real"===t)a="return real * expR - imag * expI;";else{if("imag"!==t)throw new Error(`FFT component must be either "real" or "imag", got ${t}.`);a="return real * expI + imag * expR;"}this.userCode=`\n const float exponentMultiplier = ${s};\n\n float unaryOpComplex(float real, float expR, float imag, float expI) {\n ${a}\n }\n\n float mulMatDFT(int batch, int index) {\n float indexRatio = float(index) / float(${i});\n float exponentMultiplierTimesIndexRatio =\n exponentMultiplier * indexRatio;\n\n float result = 0.0;\n\n for (int i = 0; i < ${i}; 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) / ${r};\n }\n\n return result;\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n setOutput(mulMatDFT(coords[0], coords[1]));\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function tat(t,e,n){const i=n.texData.get(t.dataId),s=bA(t.shape),r=t.shape[t.shape.length-1],a=pit({inputs:{x:t},backend:n,attrs:{shape:[s/r,r]}}),o=a.shape,l=new Zrt("real",o,e),u=new Zrt("imag",o,e),h=[{dataId:i.complexTensorInfos.real.dataId,dtype:i.complexTensorInfos.real.dtype,shape:o},{dataId:i.complexTensorInfos.imag.dataId,dtype:i.complexTensorInfos.imag.dtype,shape:o}],p=n.runWebGLProgram(l,h,"float32"),c=n.runWebGLProgram(u,h,"float32"),d=Xnt({inputs:{real:p,imag:c},backend:n});n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(c);const f=pit({inputs:{x:d},backend:n,attrs:{shape:t.shape}});return n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(d),f}const eat={kernelName:yM,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n}=t,{input:i}=e;return tat(i,!1,n)}}; /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class nat{constructor(t,e){this.outputShape=[],this.customUniforms=[{name:"value",type:"float"}],this.variableNames=["x"],this.outputShape=t,this.userCode="\n void main() {\n // Input can be obtained from uniform value.\n setOutput(value);\n }\n "}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function iat(t){const{backend:e,attrs:n}=t,{shape:i,value:s}=n;let{dtype:r}=n;if(r=r||WA(s),"string"===r){const t=FA(r,bA(i));return t.fill(s),e.makeTensorInfo(i,r,t)}{const t=new nat(i,s),n=[[s]];return e.runWebGLProgram(t,[],r,n)}}const sat={kernelName:IM,backendName:"webgl",kernelFunc:iat}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class rat{constructor(t){this.variableNames=["Image"],this.outputShape=[];const e=t[2];this.outputShape=t,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int x = coords[2];\n\n int coordX = ${e} - x - 1;\n float outputValue;\n if(coordX >= 0 && coordX < ${e}) {\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 `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const aat={kernelName:EM,backendName:"webgl",kernelFunc:({inputs:t,backend:e})=>{const{image:n}=t,i=e,s=new rat(n.shape);return i.runWebGLProgram(s,[n],n.dtype)}},oat="return floor(x);",lat=nit({opSnippet:oat,packedOpSnippet:oat,cpuKernelImpl:wet}),uat={kernelName:bM,backendName:"webgl",kernelFunc:lat},hat=iit({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"}),pat={kernelName:vM,backendName:"webgl",kernelFunc:hat}; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class cat{constructor(t){this.variableNames=["A"];const e=dtt(),[n,i]=t;this.outputShape=t,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(${i}.0, ${n}.0);\n\n vec4 values = ${e.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 `}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class dat{constructor(t){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;const e=dtt(),[n,i]=t;this.outputShape=t,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(${i}.0, ${n}.0);\n vec4 values = ${e.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 ${e.output} = result;\n }\n `}} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const fat={kernelName:xN,backendName:"webgl",kernelFunc:function(t){const{inputs:e,backend:n,attrs:i}=t;let{pixels:s}=e;const{numChannels:r}=i,a="undefined"!=typeof HTMLVideoElement&&s instanceof HTMLVideoElement,o="undefined"!=typeof HTMLImageElement&&s instanceof HTMLImageElement,[l,u]=a?[s.videoWidth,s.videoHeight]:[s.width,s.height],h=[u,l],p=[u,l,r];if(o||a){const t=lO().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");null!=mat&&t===gat||(gat=t,mat=document.createElement("canvas").getContext("2d",{willReadFrequently:gat})),mat.canvas.width=l,mat.canvas.height=u,mat.drawImage(s,0,0,l,u),s=mat.canvas}const c=n.makeTensorInfo(h,"int32");n.texData.get(c.dataId).usage=l7.PIXELS,n.gpgpu.uploadPixelDataToTexture(n.getTexture(c.dataId),s);const d=lO().getBool("WEBGL_PACK")?new dat(p):new cat(p),f=n.runWebGLProgram(d,[c],"int32");return n.disposeData(c.dataId),f}};let mat,gat=lO().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");const _at={kernelName:ON,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,filter:r,bias:a,preluActivationWeights:o}=e,{strides:l,pad:u,dataFormat:h,dilations:p,dimRoundingMode:c,activation:d,leakyreluAlpha:f}=i,m=y$(h),g=u$(s.shape,r.shape,l,p,u,c,!1,m);let _;const T=[],y=null!=a,I=null!=o,E="leakyrelu"===d,b=()=>{const t=[s,r],e=(t,e)=>{if("NCHW"===e&&1===t.shape.length&&1!==t.shape[0]){const e=pit({inputs:{x:t},backend:n,attrs:{shape:[t.shape[0],1,1]}});return T.push(e),e}return t};if(y&&t.push(e(a,h)),I&&t.push(e(o,h)),E){const e=n.makeTensorInfo([],"float32",rk(f,"float32"));t.push(e),T.push(e)}return t};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(g.strideWidth<=2&&"channelsLast"===m&&lO().getBool("WEBGL_EXP_CONV")){const t=d?sit(d,!0):null,e=new qst(g,y,t,I,E),i=[[g.padInfo.top,g.padInfo.left],[g.strideHeight,g.strideWidth],[g.dilationHeight,g.dilationWidth],[g.inHeight,g.inWidth]],s=b();_=n.runWebGLProgram(e,s,"float32",i)}else if(lO().getBool("WEBGL_CONV_IM2COL"))_=Zst({x:s,filter:r,convInfo:g,backend:n,bias:a,activation:d,preluActivationWeights:o,leakyreluAlpha:f});else{const t=d?sit(d,!1):null,e=new Xst(g,y,t,I,E),i=b();_=n.runWebGLProgram(e,i,"float32")}else _=Jst({x:s,filter:r,convInfo:g,backend:n,bias:a,activation:d,preluActivationWeights:o,leakyreluAlpha:f});const v=pit({inputs:{x:_},backend:n,attrs:{shape:g.outShape}});return T.push(_),T.forEach((t=>n.disposeIntermediateTensorInfo(t))),v}};const Tat={kernelName:MN,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,filter:r,bias:a,preluActivationWeights:o}=e,{strides:l,pad:u,dilations:h,dimRoundingMode:p,activation:c,leakyreluAlpha:d}=i,f=[];let m=h;null==m&&(m=[1,1]),yA(_$(l,m),(()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${l} and dilations '${m}'`));const g=u$(s.shape,r.shape,l,m,u,p,!0),_=lO().getBool("WEBGL_PACK_DEPTHWISECONV")&&g.strideWidth<=2&&g.outChannels/g.inChannels==1,T=c?sit(c,_):null,y=[s,r],I=null!=a,E=null!=o,b="leakyrelu"===c;if(I&&y.push(a),E&&y.push(o),b){const t=n.makeTensorInfo([],"float32",rk(d,"float32"));y.push(t),f.push(t)}let v;v=_?new Art(g,I,T,E,b):new Rrt(g,I,T,E,b);const w=[[g.padInfo.top,g.padInfo.left],[g.strideHeight,g.strideWidth],[g.dilationHeight,g.dilationWidth],[g.inHeight,g.inWidth]],S=n.runWebGLProgram(v,y,"float32",w);return f.forEach((t=>n.disposeIntermediateTensorInfo(t))),S}};class yat{constructor(t,e,n,i){this.sliceDim=t,this.strides=e,this.paramsShape=i,this.variableNames=["x","indices"],this.outputShape=n;const s=Mtt(n.length);let r="\n int index;";for(let t=0;t= ${this.paramsShape[t]};\n flattenIndex += index * ${this.strides[t]};`;this.userCode=`\n void main() {\n ${s} coords = getOutputCoords();\n int flattenIndex = 0;\n bool out_of_bounds = false;\n\n ${r}\n\n setOutput(out_of_bounds ? 0.0 : getX(flattenIndex, coords[1]));\n }\n `}}const Iat={kernelName:xM,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n}=t,{params:i,indices:s}=e,r=s.shape,a=r[r.length-1],o=bA(i.shape),[l,u,h,p]=uP(i,s),c=pit({inputs:{x:s},backend:n,attrs:{shape:[u,a]}}),d=pit({inputs:{x:i},backend:n,attrs:{shape:[bA(i.shape)/h,h]}});if(n.shouldExecuteOnCPU([i,s])||"string"===i.dtype){const t=n.readSync(s.dataId),e=n.bufferSync(i),r=xet(t,e,i.dtype,u,a,h,p,i.shape,o);return n.makeTensorInfo(l,i.dtype,r.values)}const f=new yat(a,p,[u,h],i.shape),m=n.runWebGLProgram(f,[d,c],d.dtype),g=pit({inputs:{x:m},backend:n,attrs:{shape:l}});return n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(m),g}}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Eat{constructor(t,e){this.variableNames=["A","indices"],this.outputShape=e,this.rank=e.length;const n=Mtt(this.rank),i=function(t){const e=["resRC.x","resRC.y","resRC.z","resRC.w"],n=[];for(let i=0;i= 0) && (index < ${t[2]}) ? 1.0 : 0.0;\n setOutput(inBounds * getA(${i}));\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function bat(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,indices:r}=e,{axis:a,batchDims:o}=i,l=kA(a,s.shape)[0];if(lO().get("DEBUG")){const t=n.readSync(r.dataId),e=s.shape[l];for(let n=0;n=0,(()=>`GatherV2: the index value ${i} is not in [0, ${e-1}]`))}}const u=hH(s,r,l,o),h=bA(r.shape),p=[],c=pit({inputs:{x:s},backend:n,attrs:{shape:[u.batchSize,u.outerSize,u.dimSize,u.sliceSize]}}),d=pit({inputs:{x:r},backend:n,attrs:{shape:[u.batchSize,h/u.batchSize]}});p.push(c),p.push(d);const f=[u.batchSize,u.outerSize,h/u.batchSize,u.sliceSize];if(n.shouldExecuteOnCPU([s,r])||"string"===s.dtype){const t=n.bufferSync(d),e=n.bufferSync(c),i=Ret(e,t,f);return p.forEach((t=>n.disposeIntermediateTensorInfo(t))),n.makeTensorInfo(u.outputShape,i.dtype,i.values)}const m=new Eat(c.shape,f),g=n.runWebGLProgram(m,[c,d],c.dtype);p.push(g);const _=pit({inputs:{x:g},backend:n,attrs:{shape:u.outputShape}});return p.forEach((t=>n.disposeIntermediateTensorInfo(t))),_}const vat={kernelName:SM,backendName:"webgl",kernelFunc:bat},wat=iit({opSnippet:"return float(a > b);",packedOpSnippet:"\n return vec4(greaterThan(a, b));\n",cpuKernelImpl:Aet,dtype:"bool"}),Sat={kernelName:RM,backendName:"webgl",kernelFunc:wat},xat=iit({opSnippet:"return float(a >= b);",packedOpSnippet:"\n return vec4(greaterThanEqual(a, b));\n",dtype:"bool",cpuKernelImpl:Oet}),Rat={kernelName:AM,backendName:"webgl",kernelFunc:xat};const Aat={kernelName:MM,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n}=t,{input:i}=e;return tat(i,!0,n)}},Oat=nit({opSnippet:"return float(!isnan(x) && !isinf(x));",dtype:"bool"}),Mat={kernelName:NM,backendName:"webgl",kernelFunc:Oat},Cat=nit({opSnippet:"return float(isinf(x));",dtype:"bool"}),Nat={kernelName:kM,backendName:"webgl",kernelFunc:Cat},kat=nit({opSnippet:"return float(isnan(x));",dtype:"bool"}),Dat={kernelName:DM,backendName:"webgl",kernelFunc:kat},Lat=iit({opSnippet:"return float(a < b);",packedOpSnippet:"\n return vec4(lessThan(a, b));\n",cpuKernelImpl:Met,dtype:"bool"}),Fat={kernelName:FM,backendName:"webgl",kernelFunc:Lat},Pat=iit({opSnippet:"return float(a <= b);",packedOpSnippet:"\n return vec4(lessThanEqual(a, b));\n",cpuKernelImpl:Cet,dtype:"bool"}),$at={kernelName:PM,backendName:"webgl",kernelFunc:Pat};const Bat={kernelName:$M,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{backend:e,attrs:n}=t,{start:i,stop:s,num:r}=n,a=Net(i,s,r);return e.makeTensorInfo([a.length],"float32",a)}},Vat=nit({opSnippet:eit+"\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:ket}),Uat={kernelName:BM,backendName:"webgl",kernelFunc:Vat},Yat=nit({opSnippet:eit+"\n return log(1.0 + x);\n"}),Gat={kernelName:VM,backendName:"webgl",kernelFunc:Yat},Hat=iit({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"}),Wat={kernelName:UM,backendName:"webgl",kernelFunc:Hat},zat=nit({opSnippet:"return float(!(x >= 1.0));"}),Xat={kernelName:YM,backendName:"webgl",kernelFunc:zat},jat=iit({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"}),qat={kernelName:GM,backendName:"webgl",kernelFunc:jat}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Kat{constructor(t,e,n,i,s){this.variableNames=["x"],this.outputShape=[];const r=e,a=t[3]-1;let o;this.outputShape=t;const l=`float(${n}) + float(${i}) * sum`;o=.5===s?`inversesqrt(${l})`:1===s?`1.0/(${l})`:`exp(log(${l}) * float(-${s}));`,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 = -${r}; j <= ${r}; j++) {\n int idx = d + j;\n if (idx >= 0 && idx <= ${a}) {\n float z = getX(b, r, c, idx);\n sum += z * z;\n }\n }\n float val = x * ${o};\n setOutput(val);\n }\n `}} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Qat{constructor(t,e,n,i,s){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;const r=e,a=t[3]-1;let o;this.outputShape=t;const l=`float(${n}) + float(${i}) * sum`;o=.5===s?`inversesqrt(${l})`:1===s?`1.0/(${l})`:`exp(log(${l}) * float(-${s}));`,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 - ${r};\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 = - ${r}; j <= ${r}; j++) {\n ivec2 idx = depth + j;\n bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0));\n bvec2 belowUpperBound = lessThanEqual(idx, ivec2(${a}));\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 `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const Jat={kernelName:XM,backendName:"webgl",kernelFunc:t=>{const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{depthRadius:r,bias:a,alpha:o,beta:l}=i,u=lO().getBool("WEBGL_PACK_NORMALIZATION")?new Qat(s.shape,r,a,o,l):new Kat(s.shape,r,a,o,l);return n.runWebGLProgram(u,[s],s.dtype)}}; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Zat{constructor(t,e,n,i,s){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=t,this.depth=t[3],this.depthRadius=e,this.bias=n,this.alpha=i,this.beta=s,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 - ${e})));\n int depthEnd = int(min(float(${this.depth}),\n float(d + ${e} + 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(${i}) * 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(${i})\n * float(${s})\n * getInputImage(b, r, c, k) * getOutputImage(b, r, c, d)\n / norm;\n if (k == d) {\n dyi += pow(norm, -1.0 * ${s});\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 `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const tot={kernelName:jM,backendName:"webgl",kernelFunc:t=>{const{inputs:e,backend:n,attrs:i}=t,{x:s,y:r,dy:a}=e,{depthRadius:o,bias:l,alpha:u,beta:h}=i,p=new Zat(s.shape,o,l,u,h);return n.runWebGLProgram(p,[s,r,a],s.dtype)}}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function eot(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{reductionIndices:r,keepDims:a}=i,o=s.shape.length,l=kA(r,s.shape);let u=l;const h=yB(u,o),p=null!=h,c=n.shouldExecuteOnCPU([s]);let d=s;if(p){if(c){const t=n.texData.get(d.dataId).values,e=new Array(o);for(let t=0;t`Error in maxPool: Either strides or dilations must be 1. Got strides ${a} and dilations '1'`));const u=o$(s.shape,r,a,1,o,l);if(1===u.filterWidth&&1===u.filterHeight&&SA(u.inShape,u.outShape))return Wnt({inputs:{x:s},backend:n});const h=new ist(u,"max",!1);return n.runWebGLProgram(h,[s],s.dtype)}};const aot={kernelName:tC,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{filterSize:r,strides:a,pad:o,dataFormat:l,dimRoundingMode:u}=i,h=l$(s.shape,r,a,[1,1,1],o,u,l),p=new sst(h,"max",!1);return n.runWebGLProgram(p,[s],s.dtype)}}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class oot{constructor(t){this.variableNames=["dy","maxPos"],this.outputShape=t.inShape;const e=t.strideHeight,n=t.strideWidth,i=t.dilationHeight,s=t.effectiveFilterHeight,r=t.effectiveFilterWidth,a=s-1-t.padInfo.top,o=r-1-t.padInfo.left,l=s*r-1;this.userCode=`\n const ivec2 pads = ivec2(${a}, ${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 < ${s};\n wR += ${i}) {\n float dyR = float(dyRCorner + wR) / ${e}.0;\n\n if (dyR < 0.0 || dyR >= ${t.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${r}; wC++) {\n float dyC = float(dyCCorner + wC) / ${n}.0;\n\n if (dyC < 0.0 || dyC >= ${t.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 = ${l} - 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 * ${r} + wC;\n float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n dotProd += dyValue * mask;\n }\n }\n setOutput(dotProd);\n }\n `}}class lot{constructor(t){this.variableNames=["dy","maxPos"],this.outputShape=t.inShape;const e=t.strideDepth,n=t.strideHeight,i=t.strideWidth,s=t.dilationDepth,r=t.dilationHeight,a=t.dilationWidth,o=t.effectiveFilterDepth,l=t.effectiveFilterHeight,u=t.effectiveFilterWidth,h=o-1-t.padInfo.front,p=l-1-t.padInfo.top,c=u-1-t.padInfo.left,d=o*l*u-1;this.userCode=`\n const ivec3 pads = ivec3(${h}, ${p}, ${c});\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 += ${s}) {\n float dyD = float(dyDCorner + wD) / ${e}.0;\n\n if (dyD < 0.0 || dyD >= ${t.outDepth}.0 || fract(dyD) > 0.0) {\n continue;\n }\n int idyD = int(dyD);\n\n for (int wR = 0; wR < ${l};\n wR += ${r}) {\n float dyR = float(dyRCorner + wR) / ${n}.0;\n\n if (dyR < 0.0 || dyR >= ${t.outHeight}.0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${u};\n wC += ${a}) {\n float dyC = float(dyCCorner + wC) / ${i}.0;\n\n if (dyC < 0.0 || dyC >= ${t.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 = ${d} -\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 * ${l} * ${u} +\n wR * ${u} + 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 uot={kernelName:eC,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{dy:s,input:r}=e,a=r,{filterSize:o,strides:l,pad:u,dimRoundingMode:h}=i,p=l$(a.shape,o,l,[1,1,1],u,h),c=new sst(p,"max",!0),d=n.runWebGLProgram(c,[a],a.dtype),f=new lot(p),m=n.runWebGLProgram(f,[s,d],a.dtype);return n.disposeIntermediateTensorInfo(d),m}};const hot={kernelName:ZM,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{dy:s,input:r,output:a}=e,o=r;ptt([r,a],"maxPoolGrad");const{filterSize:l,strides:u,pad:h,dimRoundingMode:p}=i,c=o$(o.shape,l,u,1,h,p),d=new ist(c,"max",!0),f=n.runWebGLProgram(d,[o],o.dtype),m=new oot(c),g=n.runWebGLProgram(m,[s,f],o.dtype);return n.disposeIntermediateTensorInfo(f),g}}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const pot={kernelName:nC,backendName:"webgl",kernelFunc:({inputs:t,attrs:e,backend:n})=>{const{x:i}=t,{filterSize:s,strides:r,pad:a,includeBatchInIndex:o}=e,l=n;yA(4===i.shape.length,(()=>`Error in maxPool: input must be rank 4 but got rank ${i.shape.length}.`));const u=[1,1];yA(_$(r,u),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${r} and dilations '${u}'`));const h=o$(i.shape,s,r,u,a),[p,c]= /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t,e,n,i){let s=new ist(n,"max",!1);const r=i.runWebGLProgram(s,[t],"float32");return s=new ist(n,"max",!0,!0,e),[r,i.runWebGLProgram(s,[t],"float32")]}(i,o,h,l);return[p,c]}}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const cot={kernelName:iC,backendName:"webgl",kernelFunc:({inputs:t,attrs:e,backend:n})=>{const{x:i}=t,{keepDims:s,axis:r}=e,a=n,o=i.shape.length,l=kA(r,i.shape);let u=l;const h=yB(u,o),p=null!=h,c=a.shouldExecuteOnCPU([i]),d=[];let f=i;if(p){if(c){const t=a.texData.get(f.dataId).values,e=new Array(o);for(let t=0;te[0]+t[n]+e[1]));const i=t.length,s=Mtt(i),r=e.map((t=>t[0])).join(","),a=e.map(((e,n)=>e[0]+t[n])).join(","),o=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,i),l="reflect"===n?0:1;this.userCode=1!==i?`\n ${s} start = ${s}(${r});\n ${s} end = ${s}(${a});\n\n void main() {\n ${s} outC = getOutputCoords();\n for (int i = 0; i < ${i}; i++) {\n if (outC[i] < start[i]) {\n outC[i] = start[i] * 2 - outC[i] - ${l};\n } else if(outC[i] >= end[i]) {\n outC[i] = (end[i] - 1) * 2 - outC[i] + ${l};\n }\n }\n ${s} coords = outC - start;\n setOutput(getX(${o}));\n }\n `:`\n int start = ${r};\n int end = ${a};\n\n void main() {\n int outC = getOutputCoords();\n if (outC < start) {\n outC = start * 2 - outC - ${l};\n } else if(outC >= end) {\n outC = (end - 1) * 2 - outC + ${l};\n }\n setOutput(getX(outC - start));\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class _ot{constructor(t,e,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e.map(((e,n)=>e[0]+t[n]+e[1]));const i=t.length,s=Mtt(i),r=e.map((t=>t[0])).join(","),a=e.map(((e,n)=>e[0]+t[n])).join(","),o=pnt("rc",i),l=pnt("source",i),u=`${o[i-1]} < ${this.outputShape[i-1]}`,h=1===i?"source":`vec2(${l.slice(-2).join()})`,p="reflect"===n?0:1;let c="";if(1===i){const t=`\n ${s} 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 `;c=`\n ${s} rc = outputLoc;\n ${t}\n result[0] = getChannel(getX(${l.join()}), ${h});\n ${o[i-1]} += 1;\n if(${u}) {\n ${t}\n result[1] = getChannel(getX(${l.join()}), ${h});\n }\n `}else{const t=`\n ${s} source = rc;\n ${s} lt = ${s}(lessThan(source, start));\n ${s} gte = ${s}(greaterThanEqual(source, end));\n ${s} 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 `;c=`\n ${s} rc = outputLoc;\n ${t}\n result[0] = getChannel(getX(${l.join()}), ${h});\n ${o[i-1]} += 1;\n if(${u}) {\n ${t}\n result[1] = getChannel(getX(${l.join()}), ${h});\n }\n rc = outputLoc;\n ${o[i-2]} += 1;\n if(${o[i-2]} < ${this.outputShape[i-2]}) {\n ${t}\n result[2] = getChannel(getX(${l.join()}), ${h});\n ${o[i-1]} += 1;\n if(${u}) {\n ${t}\n result[3] = getChannel(getX(${l.join()}), ${h});\n }\n }\n `}this.userCode=`\n const ${s} start = ${s}(${r});\n const ${s} end = ${s}(${a});\n\n void main() {\n ${s} outputLoc = getOutputCoords();\n vec4 result = vec4(0.);\n ${c}\n setOutput(result);\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const Tot={kernelName:aC,backendName:"webgl",kernelFunc:({inputs:t,backend:e,attrs:n})=>{const{x:i}=t,{paddings:s,mode:r}=n,a=lO().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new _ot(i.shape,s,r):new got(i.shape,s,r);return e.runWebGLProgram(a,[i],i.dtype)}},yot=iit({opSnippet:"if (b == 0.0) return NAN;\n return mod(a, b);",packedOpSnippet:"\n vec4 result = mod(a, b);\n bvec4 isNaN = equal(b, vec4(0.0));\n "+Gnt+"\n return result;\n"}),Iot={kernelName:oC,backendName:"webgl",kernelFunc:yot}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Eot{constructor(t,e,n){this.variableNames=["probs"],this.customUniforms=[{name:"seed",type:"float"}],this.outputShape=[t,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 < ${e-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(${e-1}));\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const bot=iit({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}),vot={kernelName:hM,backendName:"webgl",kernelFunc:bot},wot="return a - b;",Sot=iit({opSnippet:wot,packedOpSnippet:wot,supportsComplex:!0,cpuKernelImpl:rnt}),xot={kernelName:dN,backendName:"webgl",kernelFunc:Sot}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Rot(t){const{inputs:e,backend:n,attrs:i}=t,{logits:s}=e,{dim:r}=i,a=kA([r],s.shape),o=eot({inputs:{x:s},backend:n,attrs:{reductionIndices:a,keepDims:!1}}),l=_B(o.shape,a),u=pit({inputs:{x:o},backend:n,attrs:{shape:l}}),h=Sot({inputs:{a:s,b:u},backend:n}),p=zrt({inputs:{x:h},backend:n}),c=yit({inputs:{x:p},backend:n,attrs:{axis:a,keepDims:!1}}),d=pit({inputs:{x:c},backend:n,attrs:{shape:l}}),f=bot({inputs:{a:p,b:d},backend:n});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(d),f}const Aot={kernelName:tN,backendName:"webgl",kernelFunc:Rot};const Oot={kernelName:lC,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{logits:s}=e,{numSamples:r,seed:a,normalized:o}=i,l=o?s:Rot({inputs:{logits:s},backend:n,attrs:{dim:s.shape.length-1}}),u=l.shape[0],h=l.shape[1],p=new Eot(u,h,r),c=[[a]],d=n.runWebGLProgram(p,[l],"int32",c);return o||n.disposeIntermediateTensorInfo(l),d}},Mot=ynt+"\n return -x;\n";const Cot={kernelName:hC,backendName:"webgl",kernelFunc:function(t){const{inputs:e,backend:n}=t,{x:i}=e;if(n.shouldExecuteOnCPU([i])){const t=n.texData.get(i.dataId),[e,s]=$et(t.values,i.shape,i.dtype);return n.makeTensorInfo(s,i.dtype,e)}let s;return s=lO().getBool("WEBGL_PACK_UNARY_OPERATIONS")?new Nnt(i.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 Tnt(i.shape,Mot),n.runWebGLProgram(s,[i],i.dtype)}},Not=fY;const kot={kernelName:cC,backendName:"webgl",kernelFunc:function(t){CN("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:n,attrs:i}=t,{boxes:s,scores:r}=e,{maxOutputSize:a,iouThreshold:o,scoreThreshold:l}=i,u=n.readSync(s.dataId),h=n.readSync(r.dataId),{selectedIndices:p}=Not(u,h,a,o,l);return n.makeTensorInfo([p.length],"int32",new Int32Array(p))}},Dot=mY;const Lot={kernelName:dC,backendName:"webgl",kernelFunc:function(t){CN("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:n,attrs:i}=t,{boxes:s,scores:r}=e,{maxOutputSize:a,iouThreshold:o,scoreThreshold:l,padToMaxOutputSize:u}=i,h=n.readSync(s.dataId),p=n.readSync(r.dataId),{selectedIndices:c,validOutputs:d}=Dot(h,p,a,o,l,u);return[n.makeTensorInfo([c.length],"int32",new Int32Array(c)),n.makeTensorInfo([],"int32",new Int32Array([d]))]}},Fot=gY;const Pot={kernelName:fC,backendName:"webgl",kernelFunc:function(t){CN("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:n,attrs:i}=t,{boxes:s,scores:r}=e,{maxOutputSize:a,iouThreshold:o,scoreThreshold:l,softNmsSigma:u}=i,h=n.readSync(s.dataId),p=n.readSync(r.dataId),c=a,d=o,f=l,m=u,{selectedIndices:g,selectedScores:_}=Fot(h,p,c,d,f,m);return[n.makeTensorInfo([g.length],"int32",new Int32Array(g)),n.makeTensorInfo([_.length],"float32",new Float32Array(_))]}}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class $ot{constructor(t,e,n,i){this.variableNames=["indices"],this.outputShape=[t,e],this.userCode=`\n void main() {\n ivec2 coords = getOutputCoords();\n int index = round(getIndices(coords.x));\n setOutput(mix(float(${i}), float(${n}),\n float(index == coords.y)));\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const Bot={kernelName:gC,backendName:"webgl",kernelFunc:t=>{const{inputs:e,backend:n,attrs:i}=t,{indices:s}=e,{dtype:r,depth:a,onValue:o,offValue:l}=i,u=bA(s.shape),h=new $ot(u,a,o,l),p=pit({inputs:{x:s},backend:n,attrs:{shape:[u]}}),c=n.runWebGLProgram(h,[p],r);n.disposeIntermediateTensorInfo(p);const d=pit({inputs:{x:c},backend:n,attrs:{shape:[...s.shape,a]}});return n.disposeIntermediateTensorInfo(c),d}}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Vot(t){const{inputs:e,backend:n}=t,{x:i}=e;if("complex64"===i.dtype){const t=xst({inputs:{input:i},backend:n}),e=Vot({inputs:{x:t},backend:n}),s=Yst({inputs:{input:i},backend:n}),r=Vot({inputs:{x:s},backend:n}),a=Xnt({inputs:{real:e,imag:r},backend:n});return n.disposeIntermediateTensorInfo(t),n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(r),a}return iat({attrs:{shape:i.shape,dtype:i.dtype,value:"string"===i.dtype?"":0},backend:n})}const Uot={kernelName:wN,backendName:"webgl",kernelFunc:Vot};const Yot={kernelName:mC,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function t(e){const{inputs:n,backend:i}=e,{x:s}=n;if("string"===s.dtype)throw new Error("onesLike is not supported under string dtype");if("complex64"===s.dtype){const e=xst({inputs:{input:s},backend:i}),n=t({inputs:{x:e},backend:i}),r=Yst({inputs:{input:s},backend:i}),a=Vot({inputs:{x:r},backend:i}),o=Xnt({inputs:{real:n,imag:a},backend:i});return i.disposeIntermediateTensorInfo(e),i.disposeIntermediateTensorInfo(n),i.disposeIntermediateTensorInfo(r),i.disposeIntermediateTensorInfo(a),o}return iat({attrs:{shape:s.shape,dtype:s.dtype,value:1},backend:i})}};const Got={kernelName:_C,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{axis:s}=i;if(1===e.length)return jrt({inputs:{input:e[0]},backend:n,attrs:{dim:s}});const r=e[0].shape,a=e[0].dtype;e.forEach((t=>{IA(r,t.shape,"All tensors passed to stack must have matching shapes"),yA(a===t.dtype,(()=>"All tensors passed to stack must have matching dtypes"))}));const o=[],l=Wst({inputs:e.map((t=>{const e=jrt({inputs:{input:t},backend:n,attrs:{dim:s}});return o.push(e),e})),backend:n,attrs:{axis:s}});return o.forEach((t=>n.disposeIntermediateTensorInfo(t))),l}}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Hot{constructor(t,e,n){this.variableNames=["x"],this.customUniforms=[{name:"value",type:"float"}],this.outputShape=e.map(((e,n)=>e[0]+t[n]+e[1]));const i=t.length,s=Mtt(i),r=e.map((t=>t[0])).join(","),a=e.map(((e,n)=>e[0]+t[n])).join(","),o=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,i);this.userCode=1!==i?`\n ${s} start = ${s}(${r});\n ${s} end = ${s}(${a});\n\n void main() {\n ${s} outC = getOutputCoords();\n if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {\n setOutput(value);\n } else {\n ${s} coords = outC - start;\n setOutput(getX(${o}));\n }\n }\n `:`\n int start = ${r};\n int end = ${a};\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 `}} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Wot{constructor(t,e,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"value",type:"float"}],this.outputShape=e.map(((e,n)=>e[0]+t[n]+e[1]));const i=t.length,s=Mtt(i),r=e.map((t=>t[0])).join(","),a=e.map(((e,n)=>e[0]+t[n])).join(","),o=pnt("rc",i),l=pnt("source",i),u=`${o[i-1]} < ${this.outputShape[i-1]}`,h=1===i?"source":`vec2(${l.slice(-2).join()})`,p=[`${s} rc = outputLoc;`,`${o[i-1]} += 1;\n if(${u}) {\n `,1===i?"":`}\n rc = outputLoc;\n ${o[i-2]} += 1;\n if(${o[i-2]} < ${this.outputShape[i-2]}) {`,1===i?"":` ${o[i-1]} += 1;\n if(${u}) {`],c=1===i?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))";let d="";for(let t=0,e=1===i?2:4;t{const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{paddings:r,constantValue:a}=i;if(0===bA(s.shape)){const t=r.map(((t,e)=>t[0]+s.shape[e]+t[1]));return iat({backend:n,attrs:{shape:t,value:a,dtype:s.dtype}})}const o=lO().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Wot(s.shape,r,a):new Hot(s.shape,r,a),l=[[a]];return n.runWebGLProgram(o,[s],s.dtype,l)},Xot={kernelName:TC,backendName:"webgl",kernelFunc:zot},jot=iit({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 bvec4 isNaN1 = lessThan(a, vec4(0.0));\n bvec4 isNaN2 = lessThan(floor(b), b);\n bvec4 isNaN = bvec4(isNaN1.x && isNaN2.x, isNaN1.y && isNaN2.y, isNaN1.z && isNaN2.z, isNaN1.w && isNaN2.w);\n "+Gnt+"\n return result;\n"}),qot={kernelName:IC,backendName:"webgl",kernelFunc:jot};const Kot={kernelName:bC,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r,keepDims:a}=i,o=s.shape.length,l=[],u=kA(r,s.shape);let h=u;const p=yB(h,o);let c,d=s;if(null!=p&&(d=Eit({inputs:{x:s},backend:n,attrs:{perm:p}}),h=EB(h.length,o),l.push(d)),TB("prod",h,o),n.shouldExecuteOnCPU([d])){const t=n.texData.get(d.dataId).values,{outVals:e,outShape:i,outDtype:s}=Vet(d.shape,d.dtype,t,h);c=n.makeTensorInfo(i,s,e)}else{const[t,e]=gB(d.shape,h),i=bA(e),r=pit({inputs:{x:d},backend:n,attrs:{shape:[-1,i]}}),a=mit(r,$k(s.dtype),"prod",n);c=pit({inputs:{x:a},backend:n,attrs:{shape:t}}),l.push(r),l.push(a)}if(a){l.push(c);const t=_B(c.shape,u);c=pit({inputs:{x:c},backend:n,attrs:{shape:t}})}return l.forEach((t=>n.disposeIntermediateTensorInfo(t))),c}};const Qot={kernelName:vC,backendName:"webgl",kernelFunc: /** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{paramsNestedSplits:s,paramsDenseValues:r,indices:a}=e,{outputRaggedRank:o}=i,l=s.map((t=>n.readSync(t.dataId))),u=s.map((t=>t.shape)),h=n.readSync(r.dataId),p=n.readSync(a.dataId),[c,d,f]=Uet(l,u,h,r.shape,r.dtype,p,a.shape,o),m=c.map((t=>n.makeTensorInfo([t.length],"int32",t))),g=n.makeTensorInfo(f,r.dtype,d);return m.concat([g])}};const Jot={kernelName:wC,backendName:"webgl",kernelFunc: /** * @license * Copyright 2022 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n}=t,{starts:i,limits:s,deltas:r}=e,a=n.readSync(i.dataId),o=n.readSync(s.dataId),l=n.readSync(r.dataId),[u,h]=Yet(a,i.shape,i.dtype,o,s.shape,l,r.shape);return[n.makeTensorInfo([u.length],"int32",u),n.makeTensorInfo([h.length],i.dtype,h)]}};const Zot={kernelName:SC,backendName:"webgl",kernelFunc: /** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{shape:s,values:r,defaultValue:a,rowPartitionTensors:o}=e,{rowPartitionTypes:l}=i,u=n.readSync(s.dataId),h=n.readSync(r.dataId),p=n.readSync(a.dataId),c=o.map((t=>n.readSync(t.dataId))),d=o.map((t=>t.shape)),[f,m]=Get(u,s.shape,h,r.shape,r.dtype,p,a.shape,c,d,l);return n.makeTensorInfo(f,r.dtype,m)}},tlt=t=>{const{backend:e,attrs:n}=t,{start:i,stop:s,step:r,dtype:a}=n,o=Het(i,s,r,a);return e.makeTensorInfo([o.length],a,o)},elt={kernelName:xC,backendName:"webgl",kernelFunc:tlt},nlt=nit({opSnippet:"return 1.0 / x;"}),ilt={kernelName:AC,backendName:"webgl",kernelFunc:nlt},slt=nit({opSnippet:ynt+"\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"}),rlt={kernelName:OC,backendName:"webgl",kernelFunc:slt},alt=nit({opSnippet:ynt+"\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"}),olt={kernelName:LC,backendName:"webgl",kernelFunc:alt}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class llt{constructor(t,e,n,i,s){this.variableNames=["A"],this.outputShape=[];const[r,a,o,l]=t;this.outputShape=[r,e,n,l];const u=[i&&e>1?a-1:a,i&&n>1?o-1:o],h=[i&&e>1?e-1:e,i&&n>1?n-1:n];let p;p=s?"(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":"vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n ${u[0]/h[0]},\n ${u[1]/h[1]});\n const vec2 inputShapeRC = vec2(${a}.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 `}} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class ult{constructor(t,e,n,i,s){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[r,a,o,l]=t;this.outputShape=[r,e,n,l];const u=[i&&e>1?a-1:a,i&&n>1?o-1:o],h=[i&&e>1?e-1:e,i&&n>1?n-1:n];let p;p=s?"(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":"vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec3 effectiveInputOverOutputRatioRC = vec3(\n ${u[0]/h[0]},\n ${u[1]/h[1]},\n ${u[1]/h[1]});\n const vec3 inputShapeRC = vec3(${a}.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 < ${l-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 hlt={kernelName:kC,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{images:s}=e,{alignCorners:r,halfPixelCenters:a,size:o}=i,[l,u]=o,h=lO().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new ult(s.shape,l,u,r,a):new llt(s.shape,l,u,r,a);return n.runWebGLProgram(h,[s],"float32")}}; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class plt{constructor(t,e,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=e;const[,i,s]=e,[,r,a]=t,o=[n&&r>1?i-1:i,n&&a>1?s-1:s],l=[n&&r>1?r-1:r,n&&a>1?a-1:a],u=o[0]/l[0],h=o[1]/l[1],p=1/u,c=1/h,d=2*Math.ceil(p)+2,f=2*Math.ceil(c)+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(${u});\n const float widthScale = float(${h});\n\n const float invHeightScale = float(${p});\n const float invWidthScale = float(${c});\n\n const int winHeight = int(${d});\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 >= ${r}) {\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 >= ${a}) {\n continue;\n }\n\n float dxR = float(dyR) * heightScale;\n int topDxRIndex = int(floor(dxR));\n int bottomDxRIndex = int(min(ceil(dxR), ${i-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), ${s-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 clt={kernelName:DC,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{images:s,dy:r}=e,{alignCorners:a}=i,o=new plt(r.shape,s.shape,a);return n.runWebGLProgram(o,[r],r.dtype)}}; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class dlt{constructor(t,e,n,i,s){this.variableNames=["A"],this.outputShape=[];const[r,a,o,l]=t;this.outputShape=[r,e,n,l];const u=[i&&e>1?a-1:a,i&&n>1?o-1:o],h=[i&&e>1?e-1:e,i&&n>1?n-1:n],p=i?"0.5":"0.0";let c;c=s?"max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))":"vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n ${u[0]/h[0]},\n ${u[1]/h[1]});\n const vec2 inputShapeRC = vec2(${a}.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 = ${c};\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 `}} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class flt{constructor(t,e,n,i,s){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[r,a,o,l]=t;this.outputShape=[r,e,n,l];const u=[i&&e>1?a-1:a,i&&n>1?o-1:o],h=[i&&e>1?e-1:e,i&&n>1?n-1:n],p=i?"0.5":"0.0";let c;c=s?"max((vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC, vec3(0.0))":"vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec3 effectiveInputOverOutputRatioRC = vec3(\n ${u[0]/h[0]},\n ${u[1]/h[1]},\n ${u[1]/h[1]});\n const vec3 inputShapeRC = vec3(${a}.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 = ${c};\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 < ${l-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 mlt={kernelName:CC,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{images:s}=e,{alignCorners:r,halfPixelCenters:a,size:o}=i,[l,u]=o,h=lO().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new flt(s.shape,l,u,r,a):new dlt(s.shape,l,u,r,a);return n.runWebGLProgram(h,[s],s.dtype)}}; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class glt{constructor(t,e,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=e;const[,i,s]=e,[,r,a]=t,o=[n&&r>1?i-1:i,n&&a>1?s-1:s],l=[n&&r>1?r-1:r,n&&a>1?a-1:a],u=o[0]/l[0],h=o[1]/l[1],p=1/u,c=1/h,d=2*Math.ceil(p)+2,f=2*Math.ceil(c)+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(${u});\n const float widthScale = float(${h});\n\n const float invHeightScale = float(${p});\n const float invWidthScale = float(${c});\n\n const int winHeight = int(${d});\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 >= ${r}) {\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 >= ${a}) {\n continue;\n }\n\n float sourceFracRow =\n float(${o[0]}) *\n (float(dyR) / float(${l[0]}));\n\n float sourceFracCol =\n float(${o[1]}) *\n (float(dyC) / float(${l[1]}));\n\n int sourceNearestRow = int(min(\n float(int(${i}) - 1),\n ${n} ? float(round(sourceFracRow)) :\n float(floor(sourceFracRow))));\n\n int sourceNearestCol = int(min(\n float(int(${s}) - 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 _lt={kernelName:NC,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{images:s,dy:r}=e,{alignCorners:a}=i,o=new glt(r.shape,s.shape,a);return n.runWebGLProgram(o,[r],r.dtype)}}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Tlt{constructor(t,e){this.variableNames=["x"];const n=t.length;if(n>4)throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`);if(this.outputShape=t,1===n)return void(this.userCode=`\n void main() {\n int coord = getOutputCoords();\n setOutput(getX(${t[0]} - coord - 1));\n }\n `);const i=t.map(((n,i)=>(n=>-1!==e.indexOf(n)&&1!==t[n]?`${t[n]} - coords[${n}] - 1`:`coords[${n}]`)(i))).join(","),s=Mtt(n);this.userCode=`\n void main() {\n ${s} coords = getOutputCoords();\n setOutput(getX(${i}));\n }\n `}} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class ylt{constructor(t,e){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;const n=t.length;if(n>4)throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`);this.outputShape=t;const i=pnt("rc",n),s=`${i[n-1]} + 1 < ${this.outputShape[n-1]}`,r=`${i[n-2]} + 1 < ${this.outputShape[n-2]}`,a=Mtt(n);function o(n){const i=t.map(((i,s)=>function(n,i){return-1!==e.indexOf(n)&&1!==t[n]?`${t[n]} - ${i[n]} - 1`:`${i[n]}`}(s,n)));return`getChannel(getX(${i.join(",")}), vec2(${i.slice(-2).join(",")}))`}this.userCode=1===n?`\n void main(){\n int rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = getChannel(getX(${t[0]} - rc - 1),\n ${t[0]} - rc - 1);\n if(${s}){\n result.g = getChannel(getX(${t[0]} - (rc + 1) - 1),\n ${t[0]} - (rc + 1) - 1);\n }\n setOutput(result);\n }\n `:`\n void main() {\n ${a} rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = ${function(t){return o(t)}(i.slice())};\n if(${s}){\n result.g = ${function(t){return t[n-1]="("+t[n-1]+" + 1)",o(t)}(i.slice())};\n }\n if(${r}) {\n result.b = ${function(t){return t[n-2]="("+t[n-2]+" + 1)",o(t)}(i.slice())};\n if(${s}) {\n result.a = ${function(t){return t[n-1]="("+t[n-1]+" + 1)",t[n-2]="("+t[n-2]+" + 1)",o(t)}(i.slice())};\n }\n }\n setOutput(result);\n }\n `}}const Ilt={kernelName:FC,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{dims:r}=i,a=s.shape.length,o=kA(r,s.shape);if(0===a)return Wnt({inputs:{x:s},backend:n});const l=lO().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new ylt(s.shape,o):new Tlt(s.shape,o);return n.runWebGLProgram(l,[s],s.dtype)}}; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Elt{constructor(t,e){this.variableNames=["Image"],this.outputShape=[],this.customUniforms=[{name:"params",type:"vec4"}];const n=t[1],i=t[2];this.outputShape=t;let s="";s="number"==typeof e?`float outputValue = ${e.toFixed(2)};`:`\n vec3 fill = vec3(${e.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 ${s}\n if(coordX >= 0 && coordX < ${i} && coordY >= 0 && coordY < ${n}) {\n outputValue = getImage(coords[0], coordY, coordX, coords[3]);\n }\n setOutput(outputValue);\n }\n `}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const blt={kernelName:RN,backendName:"webgl",kernelFunc:({inputs:t,attrs:e,backend:n})=>{const{image:i}=t,{radians:s,fillValue:r,center:a}=e,o=n,l=new Elt(i.shape,r),[u,h]=_G(a,i.shape[1],i.shape[2]),p=[[u,h,Math.sin(s),Math.cos(s)]];return o.runWebGLProgram(l,[i],i.dtype,p)}},vlt=nit({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"}),wlt={kernelName:PC,backendName:"webgl",kernelFunc:vlt},Slt=nit({opSnippet:"return inversesqrt(x);",cpuKernelImpl:Wet}),xlt={kernelName:$C,backendName:"webgl",kernelFunc:Slt}; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Rlt{constructor(t,e,n,i,s,r,a=!0,o=!1){this.variableNames=["updates","indices","defaultValue"],this.outputShape=r;const l=Mtt(s.length),u=Mtt(r.length);let h="";1===n?h="i":2===n&&(h="i, j");const p=`getIndices(${h})`;let c="";1===i?c="i":2===i&&(c="i, coords[1]");const d=`getUpdates(${c})`;let f="";o&&(f="coords[0], coords[1]");const m=`getDefaultValue(${f})`,g=e>1?"strides[j]":"strides";this.userCode=`\n ${l} strides = ${l}(${s});\n\n void main() {\n ${u} coords = getOutputCoords();\n float sum = 0.0;\n bool found = false;\n for (int i = 0; i < ${t}; i++) {\n int flattenedIndex = 0;\n for (int j = 0; j < ${e}; j++) {\n int index = round(${p});\n flattenedIndex += index * ${g};\n }\n if (flattenedIndex == coords[0]) {\n sum += ${d};\n found = true;\n }\n }\n setOutput(mix(${m}, sum, float(found)));\n }\n `}} /** * @license * Copyright 2023 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Alt{constructor(t,e,n,i,s,r,a=!0,o=!1){this.variableNames=["updates","indices","defaultValue"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=r;const l=Mtt(s.length),u=Mtt(r.length);let h="";1===n?h="i":2===n&&(h="i, j");const p=`getIndices(${h})`;let c="";1===i?c="i":2===i&&(c="i, coords[1]");const d=`getUpdates(${c})`;let f="";o&&(f="coords[0], coords[1]");const m=`getDefaultValue(${f})`,g=e>1?"strides[j]":"strides",_=e>1?"strides[j + 1]":"strides";this.userCode=`\n ${l} strides = ${l}(${s});\n\n void main() {\n ${u} coords = getOutputCoords();\n vec4 sum = vec4(0.);\n vec4 found = vec4(0.);\n for (int i = 0; i < ${t}; i+=2) {\n ivec2 flattenedIndex = ivec2(0);\n for (int j = 0; j < ${e}; j+=2) {\n ivec4 index = round(${p});\n flattenedIndex += index.xz * ${g};\n if (j + 1 < ${e}) {\n flattenedIndex += index.yw * ${_};\n }\n }\n if (flattenedIndex[0] == coords[0] || flattenedIndex[1] == coords[0] ||\n flattenedIndex[0] == coords[0] + 1 || flattenedIndex[1] == coords[0] + 1) {\n vec4 updVals = ${d};\n if (flattenedIndex[0] == coords[0]) {\n sum.xy += updVals.xy;\n found.xy = vec2(1.);\n } else if (flattenedIndex[0] == coords[0] + 1) {\n sum.zw += updVals.xy;\n found.zw = vec2(1.);\n }\n if (flattenedIndex[1] == coords[0]) {\n sum.xy += updVals.zw;\n found.xy = vec2(1.);\n } else if (flattenedIndex[1] == coords[0] + 1) {\n sum.zw += updVals.zw;\n found.zw = vec2(1.);\n }\n }\n }\n setOutput(mix(${m}, sum, found));\n }\n `}}const Olt={kernelName:BC,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{indices:s,updates:r}=e,{shape:a}=i,{sliceRank:o,numUpdates:l,sliceSize:u,strides:h,outputSize:p}=cP(0,s,a),c=[p/u,u];if(0===p)return n.makeTensorInfo(a,s.dtype);const d=pit({inputs:{x:s},backend:n,attrs:{shape:[l,o]}}),f=pit({inputs:{x:r},backend:n,attrs:{shape:[l,u]}}),m=n.makeTensorInfo([],"float32",new Float32Array([0]));let g;g=lO().getBool("WEBGL_PACK")?new Alt(l,o,d.shape.length,f.shape.length,h,c):new Rlt(l,o,d.shape.length,f.shape.length,h,c);const _=n.runWebGLProgram(g,[f,d,m],f.dtype),T=pit({inputs:{x:_},backend:n,attrs:{shape:a}});return n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(_),n.disposeIntermediateTensorInfo(m),T}}; /** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Mlt{constructor(t,e,n,i){this.variableNames=["sortedSequence","values"],this.customUniforms=[{name:"numInputs",type:"int"}],this.outputShape=[t,n];const s=`for (int i = 0; i < ${Math.ceil(Math.log2(e+1))}; ++i) { if (left >= right) break;`,r=2===lO().getNumber("WEBGL_VERSION")?"while (left < right) {":s,a="left"===i?"<":"<=";this.userCode=`\n int findBound(int batch, float value) {\n int left = 0;\n int right = numInputs;\n int mid;\n ${r}\n mid = (left + right) / 2;\n if (getSortedSequence(batch, mid) ${a} 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 Clt={kernelName:UC,backendName:"webgl",kernelFunc: /** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{sortedSequence:s,values:r}=e,{side:a}=i,o=new Mlt(s.shape[0],s.shape[1],r.shape[1],a),l=[[s.shape[1]]];return n.runWebGLProgram(o,[s,r],"int32",l)}}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Nlt{constructor(t,e,n){let i,s;if(this.variableNames=["c","a","b"],this.outputShape=e,n>4)throw Error(`Where for rank ${n} is not yet supported`);if(1===n)s="resRC",i="resRC";else{const n=["resRC.x","resRC.y","resRC.z","resRC.w"],r=[],a=[];for(let i=0;i= 1.0) {\n setOutput(getA(${s}));\n } else {\n setOutput(getB(${s}));\n }\n }\n `}}const klt={kernelName:YC,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n}=t,{condition:i,t:s,e:r}=e,a=new Nlt(i.shape.length,s.shape,s.shape.length);return n.runWebGLProgram(a,[i,s,r],Pk(s.dtype,r.dtype))}},Dlt=nit({opSnippet:`\n // Stable and Attracting Fixed Point (0, 1) for Normalized Weights.\n // see: https://arxiv.org/abs/1706.02515\n float scaleAlpha = ${vG};\n float scale = ${wG};\n return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);\n`}),Llt={kernelName:GC,backendName:"webgl",kernelFunc:Dlt},Flt=nit({opSnippet:eit+"\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:Xet}),Plt={kernelName:jC,backendName:"webgl",kernelFunc:Flt},$lt=nit({opSnippet:"\n if (isnan(x)) { return 0.0; }\n return sign(x);\n"}),Blt={kernelName:XC,backendName:"webgl",kernelFunc:$lt},Vlt=nit({opSnippet:eit+"\n return sin(x);\n",packedOpSnippet:`\n vec4 result = sin(x);\n bvec4 isNaN = isnan(x);\n ${Gnt}\n return result;\n`}),Ult={kernelName:WC,backendName:"webgl",kernelFunc:Vlt},Ylt=nit({opSnippet:"\n float e2x = exp(x);\n return (e2x - 1.0 / e2x) / 2.0;\n"}),Glt={kernelName:zC,backendName:"webgl",kernelFunc:Ylt},Hlt=nit({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"}),Wlt={kernelName:qC,backendName:"webgl",kernelFunc:Hlt},zlt={kernelName:JC,backendName:"webgl",kernelFunc:t=>{const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{blockShape:r,paddings:a}=i;yA(s.shape.length<=4,(()=>"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet"));const o=r.reduce(((t,e)=>t*e)),l=[[0,0]];l.push(...a);for(let t=1+r.length;tn.disposeIntermediateTensorInfo(t))),g}};const Xlt={kernelName:eN,backendName:"webgl",kernelFunc: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n}=t,{indices:i,values:s,denseShape:r,defaultValue:a}=e;if(1!==r.shape.length)throw new Error(`Dense shape must be a vector, saw:\n ${r.shape}`);if(2!==i.shape.length)throw new Error(`Indices must be a matrix, saw:\n ${i.shape}`);if(1!==s.shape.length)throw new Error(`Values must be a vector, saw:\n ${s.shape}`);if(0!==a.shape.length)throw new Error(`Default value must be a scalar, saw:\n ${a.shape}`);const o=n.readSync(i.dataId),l=n.readSync(s.dataId),u=n.readSync(r.dataId),h=n.readSync(a.dataId)[0],[p,c,d,f,m]=Ket(o,i.shape,i.dtype,l,s.dtype,u,h);return[n.makeTensorInfo(c,i.dtype,p),n.makeTensorInfo([c[0]],s.dtype,d),n.makeTensorInfo([f.length],"bool",new Uint8Array(f.map((t=>Number(t))))),n.makeTensorInfo([m.length],i.dtype,new Int32Array(m))]}};const jlt={kernelName:nN,backendName:"webgl",kernelFunc: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n}=t,{inputIndices:i,inputShape:s,newShape:r}=e;if(2!==i.shape.length)throw new Error(`Input indices should be a matrix but received shape ${i.shape}`);if(1!==s.shape.length)throw new Error(`Input shape should be a vector but received shape ${s.shape}`);if(1!==r.shape.length)throw new Error(`Target shape should be a vector but received shape ${r.shape}`);const a=Array.from(n.readSync(s.dataId)),o=n.readSync(i.dataId),l=Array.from(n.readSync(r.dataId)),[u,h,p]=Qet(o,i.shape,i.dtype,a,l);return[n.makeTensorInfo(h,i.dtype,u),n.makeTensorInfo([p.length],r.dtype,new Int32Array(p))]}};const qlt={kernelName:iN,backendName:"webgl",kernelFunc: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n}=t,{data:i,indices:s,segmentIds:r}=e;if(i.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==s.shape.length)throw new Error(`Indices should be a vector but received shape\n ${s.shape}`);if(1!==r.shape.length)throw new Error(`Segment ids should be a vector but received shape\n ${r.shape}`);const a=n.readSync(i.dataId),o=n.readSync(s.dataId),l=n.readSync(r.dataId),[u,h]=Jet(a,i.shape,i.dtype,o,l,!0);return n.makeTensorInfo(h,i.dtype,u)}};const Klt={kernelName:sN,backendName:"webgl",kernelFunc: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n}=t,{data:i,indices:s,segmentIds:r}=e;if(i.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==s.shape.length)throw new Error(`Indices should be a vector but received shape\n ${s.shape}`);if(1!==r.shape.length)throw new Error(`Segment ids should be a vector but received shape\n ${r.shape}`);const a=n.readSync(i.dataId),o=n.readSync(s.dataId),l=n.readSync(r.dataId),[u,h]=Jet(a,i.shape,i.dtype,o,l);return n.makeTensorInfo(h,i.dtype,u)}};const Qlt={kernelName:rN,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{sparseIndices:s,sparseValues:r,defaultValue:a}=e,{outputShape:o}=i,{sliceRank:l,numUpdates:u,sliceSize:h,strides:p,outputSize:c}=cP(0,s,o),d=!1;if("string"===r.dtype){const t=n.bufferSync(s),e=n.bufferSync(r),i=hk(n.readSync(a.dataId)[0]),f=zet(t,e,o,c,h,u,l,p,i,d);return n.makeTensorInfo(o,f.dtype,f.values)}const f=new Rlt(u,l,s.shape.length,r.shape.length,p,[c,1],d),m=n.runWebGLProgram(f,[r,s,a],r.dtype),g=pit({inputs:{x:m},backend:n,attrs:{shape:o}});return n.disposeIntermediateTensorInfo(m),g}};const Jlt={kernelName:ZC,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{numOrSizeSplits:r,axis:a}=i,o=kA(a,s.shape)[0],l=qG(s,r,o),u=s.shape.length,h=new Array(u).fill(0),p=s.shape.slice();return l.map((t=>{const e=[...p];e[o]=t;const i=Tst({inputs:{x:s},backend:n,attrs:{begin:h,size:e}});return h[o]+=t,i}))}},Zlt="return sqrt(x);",tut=nit({opSnippet:Zlt,packedOpSnippet:Zlt,cpuKernelImpl:Zet}),eut={kernelName:KC,backendName:"webgl",kernelFunc:tut},nut=nit({opSnippet:"return x * x;"}),iut={kernelName:oN,backendName:"webgl",kernelFunc:nut},sut="return (a - b) * (a - b);",rut=iit({opSnippet:sut,packedOpSnippet:sut}),aut={kernelName:aN,backendName:"webgl",kernelFunc:rut};const out={kernelName:lN,backendName:"webgl",kernelFunc: /** * @license * Copyright 2023 Google LLC. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e;if("string"!==s.dtype)throw new Error("Input must be of datatype string");const r=pH(n.readSync(s.dataId)),a=tnt(r,"string",i);return n.makeTensorInfo(s.shape,"string",a)}};const lut={kernelName:SN,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function({inputs:t,attrs:e,backend:n}){const{x:i}=t,s=ynt+`\n return x > 0.0 ? 1.0 : float(${e.alpha});\n `,r=new Tnt(i.shape,s);return n.runWebGLProgram(r,[i],i.dtype)}}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class uut{constructor(t,e,n){this.variableNames=["x"],this.outputShape=n;const i=n.length,s=Mtt(n.length),r=Mtt(n.length);let a="";if(1===i)a="coords * strides + begin";else{let t=0;a=n.map(((e,i)=>(t++,1===n.length?`coords * strides[${i}] + begin[${i}]`:`coords[${t-1}] * strides[${i}] + begin[${i}]`))).join(",")}this.userCode=`\n ${s} begin = ${s}(${t});\n ${s} strides = ${s}(${e});\n\n void main() {\n ${r} coords = getOutputCoords();\n setOutput(getX(${a}));\n }\n `}}const hut={kernelName:uN,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{begin:r,end:a,strides:o,beginMask:l,endMask:u,ellipsisMask:h,newAxisMask:p,shrinkAxisMask:c}=i,{finalShapeSparse:d,finalShape:f,isIdentity:m,sliceDim0:g,isSimpleSlice:_,begin:T,end:y,strides:I}=MP(s.shape,r,a,o,l,u,h,p,c);let E;if(m)E=pit({inputs:{x:s},backend:n,attrs:{shape:f}});else if(g||_){yA(s.shape.length>=1,(()=>`Input must have rank at least 1, got: ${s.shape.length}`));const t=_P(T,y,I),e=Tst({inputs:{x:s},backend:n,attrs:{begin:T,size:t}});E=pit({inputs:{x:e},backend:n,attrs:{shape:f}}),n.disposeIntermediateTensorInfo(e)}else{if(n.shouldExecuteOnCPU([s])){const t=n.readSync(s.dataId),e=$L(s.shape,s.dtype,t),i=ent(d,e,I,T);E=n.makeTensorInfo(f,s.dtype,i.values)}else{const t=new uut(T,I,d);E=n.runWebGLProgram(t,[s],s.dtype)}}const b=pit({inputs:{x:E},backend:n,attrs:{shape:f}});return n.disposeIntermediateTensorInfo(E),b}};const put={kernelName:hN,backendName:"webgl",kernelFunc: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{separator:s,nGramWidths:r,leftPad:a,rightPad:o,padWidth:l,preserveShortSequences:u}=i,{data:h,dataSplits:p}=e,c=n.readSync(h.dataId),d=n.readSync(p.dataId),[f,m]=nnt(c,d,s,r,a,o,l,u);return[n.makeTensorInfo([f.length],"string",f),n.makeTensorInfo(p.shape,"int32",m)]}};const cut={kernelName:pN,backendName:"webgl",kernelFunc: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{skipEmpty:s}=i,{input:r,delimiter:a}=e;if("string"!==r.dtype)throw new Error("Input must be of datatype string");if(1!==r.shape.length)throw new Error(`Input must be a vector, got shape: ${r.shape}`);if(0!==a.shape.length)throw new Error(`Delimiter must be a scalar, got shape: ${a.shape}`);const o=n.readSync(r.dataId),l=n.readSync(a.dataId)[0],[u,h,p]=int(o,l,s),c=h.length;return[n.makeTensorInfo([c,2],"int32",u),n.makeTensorInfo([c],"string",h),n.makeTensorInfo([2],"int32",new Int32Array(p))]}};const dut={kernelName:cN,backendName:"webgl",kernelFunc: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{numBuckets:s}=i,{input:r}=e;if("string"!==r.dtype)throw new Error("Input must be of datatype string");if(s<=0)throw new Error("Number of buckets must be at least 1");const a=n.readSync(r.dataId),o=snt(a,s);return n.makeTensorInfo(r.shape,"int32",o)}},fut=nit({opSnippet:"return tan(x);"}),mut={kernelName:fN,backendName:"webgl",kernelFunc:fut},gut=nit({opSnippet:"\n float e2x = exp(-2.0 * abs(x));\n return sign(x) * (1.0 - e2x) / (1.0 + e2x);\n"}),_ut={kernelName:mN,backendName:"webgl",kernelFunc:gut};const Tut={kernelName:VC,backendName:"webgl",kernelFunc: /** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{tensor:s,indices:r,updates:a}=e,{}=i,{sliceRank:o,numUpdates:l,sliceSize:u,strides:h,outputSize:p}=cP(0,r,s.shape),c=[p/u,u];if(0===p)return n.makeTensorInfo(s.shape,r.dtype);const d=pit({inputs:{x:r},backend:n,attrs:{shape:[l,o]}}),f=pit({inputs:{x:a},backend:n,attrs:{shape:[l,u]}}),m=pit({inputs:{x:s},backend:n,attrs:{shape:c}}),g=new Rlt(l,o,d.shape.length,f.shape.length,h,c,!1,!0),_=n.runWebGLProgram(g,[f,d,m],m.dtype),T=pit({inputs:{x:_},backend:n,attrs:{shape:s.shape}});return n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(_),T}}; /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class yut{constructor(t,e){this.variableNames=["A"];const n=new Array(t.length);for(let i=0;i5)throw Error(`Tile for rank ${e} is not yet supported`);if(1===e)return`imod(resRC, ${t[0]})`;const n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],i=[];for(let e=0;e5){const t=n.readSync(s.dataId),e="string"===s.dtype?t.map((t=>hk(t))):t,i=$L(s.shape,s.dtype,e),a=ant(i,r);return n.makeTensorInfo(a.shape,a.dtype,a.values)}const a=new yut(s.shape,r);return n.runWebGLProgram(a,[s],s.dtype)}const Eut={kernelName:gN,backendName:"webgl",kernelFunc:Iut};class but{constructor(t){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=t,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 vut{constructor(t){this.variableNames=["x","indices"],this.customUniforms=[{name:"n",type:"int"},{name:"firstPass",type:"int"},{name:"k",type:"int"}],this.outputShape=t,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 "}} /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function wut(t,e){null!==e&&t.disposeIntermediateTensorInfo(e)}function Sut(t){let e=1;for(;el){const t=n.readSync(s.dataId),[e,i]=ont(t,u,s.dtype,r,a);return[n.makeTensorInfo(e.shape,e.dtype,e.values),n.makeTensorInfo(i.shape,i.dtype,i.values)]}if(0===r)return u[u.length-1]=0,[n.makeTensorInfo(u,s.dtype,[]),n.makeTensorInfo(u,"int32",[])];if(1===h)return[s,iat({attrs:{shape:u,dtype:"int32",value:0},backend:n})];const p=n.texData.get(s.dataId),c=null!==p&&p.isPacked,d=c?n.unpackTensor(s):s,f=bA(u)/h,m=pit({inputs:{x:d},attrs:{shape:[f,h]},backend:n});c&&wut(n,d);const g=Sut(r),_=Sut(h);let T=null;const y=()=>null===T?[m,m]:[m,T],I=(t,e,i)=>{const s=y(),r=new but(i),a=[[h],[null===T?1:0],[Number.NEGATIVE_INFINITY],[t],[e]],o=T;T=n.runWebGLProgram(r,s,"int32",a),wut(n,o)};for(let t=1;t=1;n/=2)I(e,n,[f,_])}for(let t=_;t>g;t/=2){const e=y(),i=new vut([f,t/2]),s=[[h],[null===T?1:0],[g]],r=T;T=n.runWebGLProgram(i,e,"int32",s),wut(n,r);const a=g/2,o=2*a;for(let t=a;t>=1;t/=2)I(o,t,T.shape)}let E=T;T=Tst({inputs:{x:T},backend:n,attrs:{begin:0,size:[f,r]}}),wut(n,E);let b=bat({inputs:{x:m,indices:T},backend:n,attrs:{axis:1,batchDims:1}});wut(n,m);const v=u.slice(0,-1);v.push(r),E=T,T=pit({inputs:{x:T},attrs:{shape:v},backend:n}),wut(n,E);const w=b;return b=pit({inputs:{x:b},attrs:{shape:v},backend:n}),wut(n,w),[b,T]}}; /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Rut{constructor(t,e,n,i,s,r){this.variableNames=["Image","Transforms"],this.outputShape=r;const a="nearest"===n?1:2;let o;switch(i){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 < ${t} && 0 <= coordX && coordX < ${e}) {\n outputValue = getImage(batch, coordY, coordX, channel);\n } else {\n outputValue = float(${s});\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(${s});\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(${e}));\n float mapY = mapCoord(inY, float(${t}));\n\n if (${a} == 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 Aut={kernelName:TN,backendName:"webgl",kernelFunc: /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{image:s,transforms:r}=e,{interpolation:a,fillMode:o,fillValue:l,outputShape:u}=i,[h,p,c,d]=s.shape,[f,m]=null!=u?u:[p,c],g=new Rut(p,c,a,o,l,[h,f,m,d]);return n.runWebGLProgram(g,[s,r],"float32")}};const Out={kernelName:IN,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,attrs:n,backend:i}=t,{axis:s}=n,{x:r}=e;ptt(r,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");const a=i.readSync(r.dataId),{outputValues:o,outputShape:l,indices:u}=unt(a,s,r.shape,r.dtype);return[i.makeTensorInfo(l,r.dtype,o),i.makeTensorInfo([u.length],"int32",u)]}};const Mut={kernelName:EN,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{value:s}=e;let{axis:r}=i;r<0&&(r+=s.shape.length);const a=s,o=a.shape.length,l=s.shape[r],u=new Array(o-1);let h=0;for(let t=0;tn.disposeIntermediateTensorInfo(t))),f}}; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class Cut{constructor(t,e){this.variableNames=["x","segmentIds"];const n=t.windowSize,i=t.batchSize,s=t.inSize,r=t.numSegments,a=r*Math.ceil(s/n);this.outputShape=[i,a];const o=4*Math.floor(n/4),l=n%4,u="\n sumValue += dot(values, segFilter);\n ";let h="";s%n>0&&(h=`\n if (inIdx < 0 || inIdx >= ${s}) {\n return initializationValue;\n }\n `);let p="";s%n>0&&(p=`\n if (inIdx < 0 || inIdx >= ${s}) {\n return -1.0;\n }\n `),this.userCode=`\n const float initializationValue = 0.0;\n\n float getValue(int batch, int inIdx) {\n ${h}\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 ${r})) * float(${n}));\n int currentSeg = int(mod(float(outIdx), float(${r})));\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 ${u}\n }\n\n int inIdx = inOffset + ${o};\n if (${1===l}) {\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 ${u}\n } else if (${2===l}) {\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 ${u}\n } else if (${3===l}) {\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 ${u}\n }\n setOutput(sumValue);\n }\n `}}const Nut={kernelName:bN,backendName:"webgl",kernelFunc: /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,segmentIds:r}=e,{numSegments:a}=i,o=s.shape.length,l=[];let u=0;const h=yB([u],o);let p=s;null!=h&&(p=Eit({inputs:{x:s},backend:n,attrs:{perm:h}}),l.push(p),u=EB(1,o)[0]);const c=uH(p.shape,u,a),d=bA([p.shape[u]]),f=pit({inputs:{x:p},backend:n,attrs:{shape:[-1,d]}});l.push(f);const m=$k(s.dtype),g=(t,e,i,s,r)=>{const a=t.shape[0],o=t.shape[1],u=lH(o,r),h=new Cut({windowSize:u,inSize:o,batchSize:a,numSegments:r},e),p=n.compileAndRun(h,[t,i],s);if(l.push(p),p.shape[1]===r)return p;const c=tlt({backend:n,attrs:{start:0,stop:r,step:1,dtype:"float32"}}),d=Iut({inputs:{x:c},backend:n,attrs:{reps:[o/u]}});l.push(c),l.push(d);return g(p,e,d,s,r)},_=pit({inputs:{x:g(f,"unsortedSegmentSum",r,m,a)},backend:n,attrs:{shape:c}});let T=_;if(null!=h){l.push(_);const t=IB(h);T=Eit({inputs:{x:T},backend:n,attrs:{perm:t}})}return l.forEach((t=>n.disposeIntermediateTensorInfo(t))),T}},kut=[Sit,Rit,Oit,Cit,Dit,Pit,$it,Bit,Wit,zit,jit,Kit,Jit,tst,nst,rst,ast,ust,hst,pst,fst,Ist,Est,bst,vst,Ost,Nst,Lst,jnt,$st,zst,trt,rrt,ort,lrt,urt,hrt,crt,frt,grt,brt,vrt,wrt,xrt,Ort,Nrt,krt,Lrt,Prt,$rt,Vrt,Urt,Grt,Wrt,Xrt,qrt,Jrt,eat,sat,aat,uat,pat,fat,_at,Tat,Iat,vat,Sat,Rat,znt,Aat,Gst,Mat,Nat,Dat,Qnt,Fat,$at,Bat,Uat,Gat,Wat,Xat,qat,Jat,tot,not,sot,rot,aot,uot,hot,pot,cot,dot,mot,Tot,Iot,Oot,hit,Cot,kot,Lot,Pot,Sst,Bot,Yot,Got,Xot,qot,tit,Kot,Qot,Jot,Zot,elt,Rst,vot,ilt,rlt,olt,cit,hlt,clt,mlt,_lt,Ilt,blt,wlt,xlt,Olt,Clt,klt,Llt,Plt,Blt,Ult,Glt,yst,Aot,Wlt,zlt,Xlt,jlt,qlt,Klt,Qlt,Jlt,eut,iut,aut,out,lut,hut,put,cut,dut,xot,Iit,mut,_ut,Tut,Eut,xut,Aut,bit,Out,Mut,Nut,Uot];for(const t of kut)$N(t); /** @license See the LICENSE file. */ const Dut={"tfjs-core":zP,"tfjs-backend-cpu":Q4,"tfjs-backend-webgl":$nt,"tfjs-data":E2,"tfjs-layers":nq,"tfjs-converter":p1,tfjs:"4.22.0"},Lut=new Zt.Registry,Fut=function(t){let e={ok:!1,buffer:null,json:function(){const t=new TextDecoder("utf-8").decode(this.buffer);return JSON.parse(t)},arrayBuffer:function(){return this.buffer}};return Lut.hasKey(t)?(e.ok=!0,e.buffer=Lut.getItem(t),e):e},Put={modelsValue:{},loadGraphModel:async function(t){return await u1(t,{fromTFHub:!1,fetchFunc:(...t)=>Fut(t[0])})},loadLayersModel:async function(t){return await Sq(t,{fromTFHub:!1,fetchFunc:(...t)=>Fut(t[0])})},setModelsValue:function(t,e){Lut.hasKey(t)&&Lut.unregister(t),Lut.register(t,e),Put.modelsValue[t]=e}};window.tensorflow=Put,oA.init(),window.tf=Qt,Object.assign(Jt.Variables,ee),Object.assign(Jt.Procedures,mh),Jt.Python=gh,Jt.generator=gh,Zt.Profile.default={},Object.assign(Jt.Blocks,t,e,n,i,s,r,a,o,l,u,h,p,c,x,R,A,O,M,C,N,k,D,L,F,P,B,V,U),Object.assign(Jt.Python.forBlock,d,f,m,g,_,T,y,I,E,b,v,w,S,Y,G,H,_T,W,z,X,j,q,K,Q,J,Z,tt,et)})()})();