@mediapipe/tasks-genai 0.10.20-rc.20241213 → 0.10.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
File without changes
package/genai_bundle.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t="undefined"!=typeof self?self:{};let e;const n="undefined"!=typeof TextEncoder;function r(t){if(n)t=(e||=new TextEncoder).encode(t);else{let e=0;const n=new Uint8Array(3*t.length);for(let i=0;i<t.length;i++){var r=t.charCodeAt(i);if(r<128)n[e++]=r;else{if(r<2048)n[e++]=r>>6|192;else{if(r>=55296&&r<=57343){if(r<=56319&&i<t.length){const o=t.charCodeAt(++i);if(o>=56320&&o<=57343){r=1024*(r-55296)+o-56320+65536,n[e++]=r>>18|240,n[e++]=r>>12&63|128,n[e++]=r>>6&63|128,n[e++]=63&r|128;continue}i--}r=65533}n[e++]=r>>12|224,n[e++]=r>>6&63|128}n[e++]=63&r|128}}t=e===n.length?n:n.subarray(0,e)}return t}var i,o;t:{for(var s=["CLOSURE_FLAGS"],a=t,u=0;u<s.length;u++)if(null==(a=a[s[u]])){o=null;break t}o=a}var c,l=o&&o[610401301];i=null!=l&&l;const h=t.navigator;function f(t){return!!i&&(!!c&&c.brands.some((({brand:e})=>e&&-1!=e.indexOf(t))))}function d(e){var n;return(n=t.navigator)&&(n=n.userAgent)||(n=""),-1!=n.indexOf(e)}function p(){return!!i&&(!!c&&c.brands.length>0)}function g(){return p()?f("Chromium"):(d("Chrome")||d("CriOS"))&&!(!p()&&d("Edge"))||d("Silk")}c=h&&h.userAgentData||null;var m=!p()&&(d("Trident")||d("MSIE"));!d("Android")||g(),g(),d("Safari")&&(g()||!p()&&d("Coast")||!p()&&d("Opera")||!p()&&d("Edge")||(p()?f("Microsoft Edge"):d("Edg/"))||p()&&f("Opera"));var _={},b=null;function y(t){const e=t.length;let n=3*e/4;n%3?n=Math.floor(n):-1!="=.".indexOf(t[e-1])&&(n=-1!="=.".indexOf(t[e-2])?n-2:n-1);const r=new Uint8Array(n);let i=0;return function(t,e){function n(e){for(;r<t.length;){const e=t.charAt(r++),n=b[e];if(null!=n)return n;if(!/^[\s\xa0]*$/.test(e))throw Error("Unknown base64 encoding at char: "+e)}return e}v();let r=0;for(;;){const t=n(-1),r=n(0),i=n(64),o=n(64);if(64===o&&-1===t)break;e(t<<2|r>>4),64!=i&&(e(r<<4&240|i>>2),64!=o&&e(i<<6&192|o))}}(t,(function(t){r[i++]=t})),i!==n?r.subarray(0,i):r}function v(){if(!b){b={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"];for(let n=0;n<5;n++){const r=t.concat(e[n].split(""));_[n]=r;for(let t=0;t<r.length;t++){const e=r[t];void 0===b[e]&&(b[e]=t)}}}}var w="undefined"!=typeof Uint8Array,S=!m&&"function"==typeof btoa;function A(t){if(!S){var e;void 0===e&&(e=0),v(),e=_[e];var n=Array(Math.floor(t.length/3)),r=e[64]||"";let u=0,c=0;for(;u<t.length-2;u+=3){var i=t[u],o=t[u+1],s=t[u+2],a=e[i>>2];i=e[(3&i)<<4|o>>4],o=e[(15&o)<<2|s>>6],s=e[63&s],n[c++]=a+i+o+s}switch(a=0,s=r,t.length-u){case 2:s=e[(15&(a=t[u+1]))<<2]||r;case 1:t=t[u],n[c]=e[t>>2]+e[(3&t)<<4|a>>4]+s+r}return n.join("")}for(e="",n=0,r=t.length-10240;n<r;)e+=String.fromCharCode.apply(null,t.subarray(n,n+=10240));return e+=String.fromCharCode.apply(null,n?t.subarray(n):t),btoa(e)}const T=/[-_.]/g,E={"-":"+",_:"/",".":"="};function I(t){return E[t]||""}function P(t){if(!S)return y(t);T.test(t)&&(t=t.replace(T,I)),t=atob(t);const e=new Uint8Array(t.length);for(let n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}function O(t){return w&&null!=t&&t instanceof Uint8Array}var L={};function U(){return B||=new x(null,L)}var x=class{constructor(t,e){if(k(e),this.i=t,null!=t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}};let B,N;function k(t){if(t!==L)throw Error("illegal external caller")}function j(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}function F(){const e=Error();j(e,"incident"),function(e){t.setTimeout((()=>{throw e}),0)}(e)}function D(t){return j(t=Error(t),"warning"),t}function V(){return"function"==typeof BigInt}function M(t){return Array.prototype.slice.call(t)}var C="function"==typeof Symbol&&"symbol"==typeof Symbol();function R(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol():t}var G=R(),z=R("2ex"),W=R("1oa"),H=C?(t,e)=>{t[G]|=e}:(t,e)=>{void 0!==t.s?t.s|=e:Object.defineProperties(t,{s:{value:e,configurable:!0,writable:!0,enumerable:!1}})},$=C?(t,e)=>{t[G]&=~e}:(t,e)=>{void 0!==t.s&&(t.s&=~e)},q=C?t=>0|t[G]:t=>0|t.s,K=C?t=>t[G]:t=>t.s,Y=C?(t,e)=>{t[G]=e}:(t,e)=>{void 0!==t.s?t.s=e:Object.defineProperties(t,{s:{value:e,configurable:!0,writable:!0,enumerable:!1}})};function J(t,e){Y(e,-30975&(0|t))}function X(t,e){Y(e,-30941&(34|t))}var Z,Q={},tt={};function et(t){return!(!t||"object"!=typeof t||t.i!==tt)}function nt(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)&&t.constructor===Object}function rt(t){return!(!Array.isArray(t)||t.length)&&!!(1&q(t))}const it=[];function ot(t){if(2&t)throw Error()}Y(it,55),Z=Object.freeze(it);var st=Object.freeze({});function at(t){return t.ba=!0,t}var ut=at((t=>"number"==typeof t)),ct=at((t=>"string"==typeof t)),lt=at((t=>"boolean"==typeof t)),ht="function"==typeof t.BigInt&&"bigint"==typeof t.BigInt(0),ft=at((t=>ht?t>=pt&&t<=mt:"-"===t[0]?_t(t,dt):_t(t,gt)));const dt=Number.MIN_SAFE_INTEGER.toString(),pt=ht?BigInt(Number.MIN_SAFE_INTEGER):void 0,gt=Number.MAX_SAFE_INTEGER.toString(),mt=ht?BigInt(Number.MAX_SAFE_INTEGER):void 0;function _t(t,e){if(t.length>e.length)return!1;if(t.length<e.length||t===e)return!0;for(let n=0;n<t.length;n++){const r=t[n],i=e[n];if(r>i)return!1;if(r<i)return!0}}let bt,yt=0,vt=0;function wt(t){const e=t>>>0;yt=e,vt=(t-e)/4294967296>>>0}function St(t){if(t<0){wt(-t);const[e,n]=Pt(yt,vt);yt=e>>>0,vt=n>>>0}else wt(t)}function At(t,e){const n=4294967296*e+(t>>>0);return Number.isSafeInteger(n)?n:Tt(t,e)}function Tt(t,e){if(t>>>=0,(e>>>=0)<=2097151)var n=""+(4294967296*e+t);else V()?n=""+(BigInt(e)<<BigInt(32)|BigInt(t)):(t=(16777215&t)+6777216*(n=16777215&(t>>>24|e<<8))+6710656*(e=e>>16&65535),n+=8147497*e,e*=2,t>=1e7&&(n+=t/1e7>>>0,t%=1e7),n>=1e7&&(e+=n/1e7>>>0,n%=1e7),n=e+Et(n)+Et(t));return n}function Et(t){return t=String(t),"0000000".slice(t.length)+t}function It(t){if(t.length<16)St(Number(t));else if(V())t=BigInt(t),yt=Number(t&BigInt(4294967295))>>>0,vt=Number(t>>BigInt(32)&BigInt(4294967295));else{const e=+("-"===t[0]);vt=yt=0;const n=t.length;for(let r=e,i=(n-e)%6+e;i<=n;r=i,i+=6){const e=Number(t.slice(r,i));vt*=1e6,yt=1e6*yt+e,yt>=4294967296&&(vt+=Math.trunc(yt/4294967296),vt>>>=0,yt>>>=0)}if(e){const[t,e]=Pt(yt,vt);yt=t,vt=e}}}function Pt(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}function Ot(t){if(null!=t&&"number"!=typeof t)throw Error(`Value of float/double field must be a number, found ${typeof t}: ${t}`);return t}function Lt(t){return null==t||"number"==typeof t?t:"NaN"===t||"Infinity"===t||"-Infinity"===t?Number(t):void 0}const Ut=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function xt(t){const e=typeof t;switch(e){case"bigint":return!0;case"number":return Number.isFinite(t)}return"string"===e&&Ut.test(t)}function Bt(t){if("number"!=typeof t)throw D("int32");if(!Number.isFinite(t))throw D("int32");return 0|t}function Nt(t){return null==t?t:Bt(t)}function kt(t){if(null==t)return t;if("string"==typeof t){if(!t)return;t=+t}return"number"==typeof t&&Number.isFinite(t)?0|t:void 0}function jt(t){if(null!=t){if("number"!=typeof t)throw D("uint32");if(!Number.isFinite(t))throw D("uint32");t>>>=0}return t}function Ft(t){if(null==t)return t;if("string"==typeof t){if(!t)return;t=+t}return"number"==typeof t&&Number.isFinite(t)?t>>>0:void 0}function Dt(t){return"-"!==t[0]&&(t.length<20||20===t.length&&Number(t.substring(0,6))<184467)}function Vt(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(BigInt.asUintN(64,t));if(xt(t)){if("string"===e)return e=Math.trunc(Number(t)),Number.isSafeInteger(e)&&e>=0?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),Dt(t)||(It(t),t=Tt(yt,vt))),t;if("number"===e)return(t=Math.trunc(t))>=0&&Number.isSafeInteger(t)?t:function(t){if(t<0){St(t);var e=Tt(yt,vt);return t=Number(e),Number.isSafeInteger(t)?t:e}return Dt(e=String(t))?e:(St(t),At(yt,vt))}(t)}}function Mt(t){return null==t||"string"==typeof t?t:void 0}function Ct(t,e,n){if(null!=t&&"object"==typeof t&&t.L===Q)return t;if(Array.isArray(t)){var r=q(t),i=r;return 0===i&&(i|=32&n),(i|=2&n)!==r&&Y(t,i),new e(t)}}function Rt(t){var e;return void 0===Wt&&(Wt="function"==typeof Proxy?Jt(Proxy):null),(e=!Wt)||(void 0===Ht&&(Ht="function"==typeof WeakMap?Jt(WeakMap):null),e=!Ht),e?t:(e=Gt?.get(t))?e:Math.random()>.01?t:(function(t){if(void 0===$t){const t=new Wt([],{});$t=1===Array.prototype.concat.call([],t).length}$t&&"function"==typeof Symbol&&Symbol.isConcatSpreadable&&(t[Symbol.isConcatSpreadable]=!0)}(t),function(t,e){(Gt||=new Ht).set(t,e),(zt||=new Ht).set(e,t)}(t,e=new Wt(t,{set:(t,e,n)=>(F(),t[e]=n,!0)})),e)}let Gt,zt,Wt,Ht,$t,qt,Kt,Yt;function Jt(t){try{return-1!==t.toString().indexOf("[native code]")?t:null}catch{return null}}function Xt(t,e,n){return t=Zt(t,e[0],e[1],n?1:2),e!==qt&&n&&H(t,16384),t}function Zt(t,e,n,r){if(r=r??0,null==t){var i=96;n?(t=[n],i|=512):t=[],e&&(i=-33521665&i|(1023&e)<<15)}else{if(!Array.isArray(t))throw Error("narr");if(2048&(i=q(t)))throw Error("farr");if(64&i)return t;if(1===r||2===r||(i|=64),n&&(i|=512,n!==t[0]))throw Error("mid");t:{if(r=(n=t).length){const t=r-1;if(nt(n[t])){if((e=t-(+!!(512&(i|=256))-1))>=1024)throw Error("pvtlmt");i=-33521665&i|(1023&e)<<15;break t}}if(e){if((e=Math.max(e,r-(+!!(512&i)-1)))>1024)throw Error("spvt");i=-33521665&i|(1023&e)<<15}}}return Y(t,i),t}function Qt(t,e,n,r,i){if(null!=t){if(Array.isArray(t))t=rt(t)?void 0:i&&2&q(t)?t:te(t,e,n,void 0!==r,i);else if(nt(t)){const o={};for(let s in t)o[s]=Qt(t[s],e,n,r,i);t=o}else t=e(t,r);return t}}function te(t,e,n,r,i){const o=r||n?q(t):0;r=r?!!(32&o):void 0,t=M(t);for(let o=0;o<t.length;o++)t[o]=Qt(t[o],e,n,r,i);return n&&n(o,t),t}function ee(t){return t.L===Q?t.toJSON():function(t){switch(typeof t){case"number":return isFinite(t)?t:String(t);case"bigint":return ft(t)?Number(t):String(t);case"boolean":return t?1:0;case"object":if(t)if(Array.isArray(t)){if(rt(t))return}else{if(O(t))return A(t);if(t instanceof x){const e=t.i;return null==e?"":"string"==typeof e?e:t.i=A(e)}}}return t}(t)}function ne(t,e,n=X){if(null!=t){if(w&&t instanceof Uint8Array)return e?t:new Uint8Array(t);if(Array.isArray(t)){var r=q(t);return 2&r?t:(e&&=0===r||!!(32&r)&&!(64&r||!(16&r)),e?(Y(t,-12293&(34|r)),t):te(t,ne,4&r?X:n,!0,!0))}return t.L===Q&&(n=t.m,t=2&(r=K(n))?t:new t.constructor(re(n,r,!0))),t}}function re(t,e,n){const r=n||2&e?X:J,i=!!(32&e);return t=function(t,e,n){var r=(t=M(t)).length;const i=256&e?t[r-1]:void 0;for(r+=i?-1:0,e=512&e?1:0;e<r;e++)t[e]=n(t[e]);if(i){e=t[e]={};for(const t in i)e[t]=n(i[t])}return t}(t,e,(t=>ne(t,i,r))),H(t,32|(n?2:0)),t}function ie(t){const e=t.m,n=K(e);return 2&n?new t.constructor(re(e,n,!1)):t}function oe(t,e){return ae(t=t.m,K(t),e)}function se(t,e,n,r){if(!((e=r+(+!!(512&e)-1))<0||e>=t.length||e>=n))return t[e]}function ae(t,e,n,r){if(-1===n)return null;const i=e>>15&1023||536870912;if(!(n>=i)){var o=t.length;return r&&256&e&&null!=(r=t[o-1][n])?(se(t,e,i,n)&&null!=z&&((e=(t=N??={})[z]||0)>=4||(t[z]=e+1,F())),r):se(t,e,i,n)}return 256&e?t[t.length-1][n]:void 0}function ue(t,e,n){const r=t.m;let i=K(r);return ot(i),ce(r,i,e,n),t}function ce(t,e,n,r){const i=e>>15&1023||536870912;if(n>=i){let o,s=e;if(256&e)o=t[t.length-1];else{if(null==r)return s;o=t[i+(+!!(512&e)-1)]={},s|=256}return o[n]=r,n<i&&(t[n+(+!!(512&e)-1)]=void 0),s!==e&&Y(t,s),s}return t[n+(+!!(512&e)-1)]=r,256&e&&(n in(t=t[t.length-1])&&delete t[n]),e}function le(t,e,n,r,i){const o=t.m,s=2&(t=K(o))?1:r;i=!!i,r=he(o,t,e);var a=q(r);if(!(4&a)){4&a&&(r=M(r),a=ve(a,t),t=ce(o,t,e,r));let i=0,s=0;for(;i<r.length;i++){const t=n(r[i]);null!=t&&(r[s++]=t)}s<i&&(r.length=s),a=-4097&(20|(a=fe(a,t))),Y(r,a&=-8193),2&a&&Object.freeze(r)}let u;return 1===s||4===s&&32&a?de(a)||(i=a,(a|=2)!==i&&Y(r,a),Object.freeze(r)):(n=5===s&&(!!(32&a)||de(a)||!!Gt?.get(r)),(2===s||n)&&de(a)&&(r=M(r),a=we(a=ve(a,t),t,i),Y(r,a),t=ce(o,t,e,r)),de(a)||(e=a,(a=we(a,t,i))!==e&&Y(r,a)),n?u=Rt(r):2!==s||i||Gt?.delete(r)),u||r}function he(t,e,n){return t=ae(t,e,n),Array.isArray(t)?t:Z}function fe(t,e){return 0===t&&(t=ve(t,e)),1|t}function de(t){return!!(2&t)&&!!(4&t)||!!(2048&t)}function pe(t,e,n){t=t.m;let r=K(t);if(ot(r),null==n)ce(t,r,e);else{n=zt?.get(n)||n;var i=q(n),o=i,s=de(i),a=s||Object.isFrozen(n);for(s||(i=0),a||(n=M(n),o=0,i=we(i=ve(i,r),r,!0),a=!1),i|=21,s=0;s<n.length;s++){const t=n[s],e=Bt(t);Object.is(t,e)||(a&&(n=M(n),o=0,i=we(i=ve(i,r),r,!0),a=!1),n[s]=e)}i!==o&&(a&&(n=M(n),i=we(i=ve(i,r),r,!0)),Y(n,i)),ce(t,r,e,n)}}function ge(t,e,n,r){t=t.m;let i=K(t);ot(i),ce(t,i,e,("0"===r?0===Number(n):n===r)?void 0:n)}function me(t){if(C)return t[W]??(t[W]=new Map);if(W in t)return t[W];const e=new Map;return Object.defineProperty(t,W,{value:e}),e}function _e(t,e,n){var r=Wr;let i=t.get(r);if(null!=i)return i;i=0;for(let t=0;t<r.length;t++){const o=r[t];null!=ae(e,n,o)&&(0!==i&&(n=ce(e,n,i)),i=o)}return t.set(r,i),i}function be(t,e,n){var r=t.m,i=K(r),o=ae(r,i,n,!1);return(e=Ct(o,e,i))!==o&&null!=e&&ce(r,i,n,e),null==(r=e)||(t=t.m,2&(i=K(t))||(o=ie(r))!==r&&ce(t,i,n,r=o)),r}function ye(t,e,n){return null==n&&(n=void 0),ue(t,e,n)}function ve(t,e){return-2049&(t=32|(2&e?2|t:-3&t))}function we(t,e,n){return 32&e&&n||(t&=-33),t}function Se(t,e,n,r){var i,o=K(t.m);ot(o);const s=t.m,a=(t=!!(2&o))?1:2;d&&=!t,t=he(s,o,e);var u=q(t),c=!!(4&u);if(!c){var l=t,h=o,f=!!(2&(u=fe(u,o)));f&&(h|=2);let e=!f,r=!0,i=0,s=0;for(;i<l.length;i++){const t=Ct(l[i],n,h);if(t instanceof n){if(!f){const n=!!(2&q(t.m));e&&=!n,r&&=n}l[s++]=t}}s<i&&(l.length=s),u|=4,u=r?16|u:-17&u,Y(l,u=e?8|u:-9&u),f&&Object.freeze(l)}if(d&&!(8&u||!t.length&&(1===a||4===a&&32&u))){de(u)&&(t=M(t),u=ve(u,o),o=ce(s,o,e,t));var d=t;for(l=u,u=0;u<d.length;u++)(h=d[u])!==(f=ie(h))&&(d[u]=f);l|=8,l=d.length?-17&l:16|l,Y(d,l),u=l}1===a||4===a&&32&u?de(u)||(e=u,(u|=!t.length||16&u&&(!c||32&u)?2:2048)!==e&&Y(t,u),Object.freeze(t)):(c=5===a&&(!!(32&u)||de(u)||!!Gt?.get(t)),(2===a||c)&&de(u)&&(t=M(t),u=we(u=ve(u,o),o,!0),Y(t,u),o=ce(s,o,e,t)),de(u)||(e=u,(u=we(u,o,!0))!==e&&Y(t,u)),c&&(i=Rt(t))),i=i||t,r=null!=r?r:new n,i.push(r),2&q(r.m)?$(i,8):$(i,16)}function Ae(t){return t??0}function Te(t,e){return Ae(Ft(oe(t,e)))}function Ee(t,e,n){ge(t,e,Nt(n),0)}function Ie(t,e,n){if(null!=n&&"string"!=typeof n)throw Error();ge(t,e,n,"")}function Pe(t,e,n){if(ot(K(t.m)),e=(t=le(t,e,Mt,2,!0)).push,"string"!=typeof n)throw Error();e.call(t,n)}function Oe(t){if("string"==typeof t)return{buffer:P(t),C:!1};if(Array.isArray(t))return{buffer:new Uint8Array(t),C:!1};if(t.constructor===Uint8Array)return{buffer:t,C:!1};if(t.constructor===ArrayBuffer)return{buffer:new Uint8Array(t),C:!1};if(t.constructor===x){k(L);var e=t.i;return{buffer:(null==(e=null==e||O(e)?e:"string"==typeof e?P(e):null)?e:t.i=e)||new Uint8Array(0),C:!0}}if(t instanceof Uint8Array)return{buffer:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),C:!1};throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers")}var Le=class{constructor(t,e){this.m=Zt(t,e)}toJSON(){return Ue(this)}C(){return!!(2&q(this.m))}};function Ue(t){t=t.m,t=Yt?t:te(t,ee,void 0,void 0,!1);{var e=!Yt;let c=t.length;if(c){var n=t[c-1],r=nt(n);r?c--:n=void 0;var i=t;if(r){t:{var o,s=n,a=!1;if(s)for(let t in s)isNaN(+t)?(o??={})[t]=s[t]:(r=s[t],Array.isArray(r)&&(rt(r)||et(r)&&0===r.size)&&(r=null),null==r&&(a=!0),null!=r&&((o??={})[t]=r));if(a||(o=s),o)for(let t in o){a=o;break t}a=null}s=null==a?null!=n:a!==n}for(;c>0&&(null==(o=i[c-1])||rt(o)||et(o)&&0===o.size);c--)var u=!0;(i!==t||s||u)&&(e?(u||s||a)&&(i.length=c):i=Array.prototype.slice.call(i,0,c),a&&i.push(a)),u=i}else u=t}return u}function xe(t){return t?/^\d+$/.test(t)?(It(t),new Be(yt,vt)):null:Ne||=new Be(0,0)}Le.prototype.L=Q,Le.prototype.toString=function(){try{return Yt=!0,Ue(this).toString()}finally{Yt=!1}};var Be=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};let Ne;function ke(t){return t?/^-?\d+$/.test(t)?(It(t),new je(yt,vt)):null:Fe||=new je(0,0)}var je=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};let Fe;function De(t,e,n){for(;n>0||e>127;)t.i.push(127&e|128),e=(e>>>7|n<<25)>>>0,n>>>=7;t.i.push(e)}function Ve(t,e){for(;e>127;)t.i.push(127&e|128),e>>>=7;t.i.push(e)}function Me(t,e){if(e>=0)Ve(t,e);else{for(let n=0;n<9;n++)t.i.push(127&e|128),e>>=7;t.i.push(1)}}function Ce(t,e){0!==e.length&&(t.l.push(e),t.j+=e.length)}function Re(t,e,n){Ve(t.i,8*e+n)}function Ge(t,e){return Re(t,e,2),e=t.i.end(),Ce(t,e),e.push(t.j),e}function ze(t,e){var n=e.pop();for(n=t.j+t.i.length()-n;n>127;)e.push(127&n|128),n>>>=7,t.j++;e.push(n),t.j++}function We(t,e,n){Re(t,e,2),Ve(t.i,n.length),Ce(t,t.i.end()),Ce(t,n)}function He(){const t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var $e=He(),qe=He(),Ke=He(),Ye=He(),Je=He(),Xe=He(),Ze=class{constructor(t,e){this.i=t,t=$e,this.j=!!t&&e===t||!1}};function Qe(t,e,n,r,i){null!=(e=an(e,r))&&(n=Ge(t,n),i(e,t),ze(t,n))}const tn=new Ze(Qe,$e),en=new Ze(Qe,$e);var nn=Symbol(),rn=Symbol();let on;function sn(t){var e=un,n=cn,r=t[nn];if(r)return r;(r={}).N=function(t){switch(typeof t){case"boolean":return qt||=[0,void 0,!0];case"number":return t>0?void 0:0===t?Kt||=[0,void 0]:[-t,void 0];case"string":return[0,t];case"object":return t}}(t[0]);var i=t[1];let o=1;i&&i.constructor===Object&&(r.S=i,"function"==typeof(i=t[++o])&&(r.W=!0,on??=t[o+1],i=t[o+=2]));const s={};for(;i&&Array.isArray(i)&&i.length&&"number"==typeof i[0]&&i[0]>0;){for(var a=0;a<i.length;a++)s[i[a]]=i;i=t[++o]}for(a=1;void 0!==i;){let s;"number"==typeof i&&(a+=i,i=t[++o]);var u=void 0;if(i instanceof Ze?s=i:(s=tn,o--),s?.j){i=t[++o],u=t;var c=o;"function"==typeof i&&(i=i(),u[c]=i),u=i}for(c=a+1,"number"==typeof(i=t[++o])&&i<0&&(c-=i,i=t[++o]);a<c;a++)u?n(r,a,s,u):e(r,a,s)}return t[nn]=r}function an(t,e){return t instanceof Le?t.m:Array.isArray(t)?Xt(t,e,!1):void 0}function un(t,e,n){t[e]=n.i}function cn(t,e,n,r){let i,o;const s=n.i;t[e]=(t,e,n)=>s(t,e,n,o||=sn(r).N,i||=ln(r))}function ln(t){let e=t[rn];if(!e){const n=sn(t);e=(t,e)=>hn(t,e,n),t[rn]=e}return e}function hn(t,e,n){var r=q(t),i=+!!(512&r)-1,o=t.length,s=512&r?1:0;const a=o+(256&r?-1:0);for(;s<a;s++){const r=t[s];if(null==r)continue;const o=s-i,a=fn(n,o);a&&a(e,r,o)}if(256&r){t=t[o-1];for(const s in t)r=+s,Number.isNaN(r)||null!=(i=t[r])&&(o=fn(n,r))&&o(e,i,r)}}function fn(t,e){var n=t[e];if(n)return n;if((n=t.S)&&(n=n[e])){var r=(n=Array.isArray(n)?n[0]instanceof Ze?n:[en,n]:[n,void 0])[0].i;if(n=n[1]){const e=ln(n),i=sn(n).N;n=t.W?on(i,e):(t,n,o)=>r(t,n,o,i,e)}else n=r;return t[e]=n}}var dn,pn=0,gn=pn;if(ct(gn)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(gn))throw Error(String(gn))}else if((dn=ut(gn))&&(dn=!Number.isSafeInteger(gn)),dn)throw Error(String(gn));function mn(t,e){if(Array.isArray(e)){var n=q(e);if(4&n)return e;for(var r=0,i=0;r<e.length;r++){const n=t(e[r]);null!=n&&(e[i++]=n)}return i<r&&(e.length=i),Y(e,-12289&(5|n)),2&n&&Object.freeze(e),e}}function _n(t,e){return new Ze(t,e)}function bn(t,e,n){null!=(e=Lt(e))&&(Re(t,n,5),t=t.i,(n=bt||=new DataView(new ArrayBuffer(8))).setFloat32(0,+e,!0),vt=0,e=yt=n.getUint32(0,!0),t.i.push(e>>>0&255),t.i.push(e>>>8&255),t.i.push(e>>>16&255),t.i.push(e>>>24&255))}function yn(t,e,n){null!=(e=kt(e))&&null!=e&&(Re(t,n,0),Me(t.i,e))}function vn(t,e,n){null!=(e=null==e||"boolean"==typeof e?e:"number"==typeof e?!!e:void 0)&&(Re(t,n,0),t.i.i.push(e?1:0))}function wn(t,e,n){null!=(e=Mt(e))&&We(t,n,r(e))}function Sn(t,e,n,r,i){null!=(e=an(e,r))&&(n=Ge(t,n),i(e,t),ze(t,n))}function An(t,e,n){null!=(e=kt(e))&&(e=parseInt(e,10),Re(t,n,0),Me(t.i,e))}ht||(pn=lt(pn)?pn?"1":"0":ct(pn)?pn.trim()||"0":String(pn));var Tn,En=_n(bn,Je),In=_n(bn,Je),Pn=_n((function(t,e,n){if(e=function(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(BigInt.asIntN(64,t));if(xt(t)){if("string"===e){if(e=Math.trunc(Number(t)),Number.isSafeInteger(e))t=String(e);else if(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),!("-"===t[0]?t.length<20||20===t.length&&Number(t.substring(0,7))>-922337:t.length<19||19===t.length&&Number(t.substring(0,6))<922337))if(It(t),t=yt,2147483648&(e=vt))if(V())t=""+(BigInt(0|e)<<BigInt(32)|BigInt(t>>>0));else{const[n,r]=Pt(t,e);t="-"+Tt(n,r)}else t=Tt(t,e);return t}if("number"===e){if(t=Math.trunc(t),!Number.isSafeInteger(t)){St(t),e=yt;var n=vt;(t=2147483648&n)&&(n=~n>>>0,0==(e=1+~e>>>0)&&(n=n+1>>>0)),t="number"==typeof(e=At(e,n))?t?-e:e:t?"-"+e:e}return t}}}(e),null!=e){if("string"==typeof e)ke(e);if(null!=e)switch(Re(t,n,0),typeof e){case"number":t=t.i,St(e),De(t,yt,vt);break;case"bigint":n=BigInt.asUintN(64,e),n=new je(Number(n&BigInt(4294967295)),Number(n>>BigInt(32))),De(t.i,n.j,n.i);break;default:n=ke(e),De(t.i,n.j,n.i)}}}),He()),On=_n((function(t,e,n){if(null!=(e=Vt(e))){if("string"==typeof e)xe(e);if(null!=e)switch(Re(t,n,0),typeof e){case"number":t=t.i,St(e),De(t,yt,vt);break;case"bigint":n=BigInt.asUintN(64,e),n=new Be(Number(n&BigInt(4294967295)),Number(n>>BigInt(32))),De(t.i,n.j,n.i);break;default:n=xe(e),De(t.i,n.j,n.i)}}}),He()),Ln=_n(yn,Ye);Tn=new Ze((function(t,e,n){if(null!=(e=mn(kt,e))&&e.length){n=Ge(t,n);for(let n=0;n<e.length;n++)Me(t.i,e[n]);ze(t,n)}}),Ye);var Un,xn=_n(yn,Ye),Bn=_n(yn,Ye),Nn=_n(vn,qe),kn=_n(vn,qe),jn=_n(wn,Ke);Un=new Ze((function(t,e,n){if(null!=(e=mn(Mt,e)))for(let a=0;a<e.length;a++){var i=t,o=n,s=e[a];null!=s&&We(i,o,r(s))}}),Ke);var Fn,Dn=_n(wn,Ke),Vn=_n(wn,Ke),Mn=function(t,e,n=$e){return new Ze(e,n)}(0,(function(t,e,n,r,i){if(Array.isArray(e))for(let o=0;o<e.length;o++)Sn(t,e[o],n,r,i)})),Cn=new Ze(Sn,$e),Rn=_n((function(t,e,n){null!=(e=Ft(e))&&null!=e&&(Re(t,n,0),Ve(t.i,e))}),He()),Gn=_n(An,Xe);Fn=new Ze((function(t,e,n){if(null!=(e=mn(kt,e))&&e.length){n=Ge(t,n);for(let n=0;n<e.length;n++)Me(t.i,e[n]);ze(t,n)}}),Xe);var zn=_n(An,Xe);function Wn(t){return function(){const e=new class{constructor(){this.l=[],this.j=0,this.i=new class{constructor(){this.i=[]}length(){return this.i.length}end(){const t=this.i;return this.i=[],t}}}};hn(this.m,e,sn(t)),Ce(e,e.i.end());const n=new Uint8Array(e.j),r=e.l,i=r.length;let o=0;for(let t=0;t<i;t++){const e=r[t];n.set(e,o),o+=e.length}return e.l=[n],n}}function Hn(t,e){if(null!=e)if(Array.isArray(e))ue(t,2,te(e,ee,void 0,void 0,!1));else{if(!("string"==typeof e||e instanceof x||O(e)))throw Error("invalid value in Any.value field: "+e+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");if(null!=e)if("string"==typeof e)e=e?new x(e,L):U();else if(e.constructor!==x){if(!O(e))throw Error();e=e.length?new x(new Uint8Array(e),L):U()}ge(t,2,e,U())}}var $n=class extends Le{constructor(t){super(t)}},qn=[0,Dn,_n((function(t,e,n){if(null!=e){if(e instanceof Le){const r=e.ca;return void(r&&(e=r(e),null!=e&&We(t,n,Oe(e).buffer)))}if(Array.isArray(e))return}null!=(e=null==e||"string"==typeof e||O(e)||e instanceof x?e:void 0)&&We(t,n,Oe(e).buffer)}),He())];let Kn,Yn=globalThis.trustedTypes;function Jn(t){void 0===Kn&&(Kn=function(){let t=null;if(!Yn)return t;try{const e=t=>t;t=Yn.createPolicy("goog#html",{createHTML:e,createScript:e,createScriptURL:e})}catch(t){}return t}());var e=Kn;return new class{constructor(t){this.i=t}toString(){return this.i+""}}(e?e.createScriptURL(t):t)}function Xn(t,...e){if(0===e.length)return Jn(t[0]);let n=t[0];for(let r=0;r<e.length;r++)n+=encodeURIComponent(e[r])+t[r+1];return Jn(n)}var Zn={};Zn[336783863]=[0,jn,Nn,-1,Ln,[0,[1,2,3,4,5,6,7],Cn,[0],Cn,[0,Nn,jn,Nn,Gn,-1,Fn,jn,-1,[0,Nn,-1],Gn,Nn,-1],Cn,[0,jn,-2],Cn,[0,Ln,Nn,1,Nn,-3],Cn,[0,Ln,Gn,Nn,-1,Tn,Gn,-1],Cn,[0,jn,-2],Cn,[0,jn,Gn]],[0,jn],Nn,[0,[1,3],[2,4],Cn,[0,Tn],-1,Cn,[0,Un],-1,Mn,[0,jn,-1]],jn];var Qn=class extends Le{constructor(t){super(t)}},tr=[0,Pn,-1,kn,-3,Pn,Tn,Dn,xn,Pn,-1,kn,xn,kn,-2,Dn],er=class extends Le{constructor(t){super(t,500)}K(t){return ye(this,7,t)}},nr=[-1,{}],rr=[0,jn,1,nr],ir=[0,jn,Un,nr];function or(t,e){Se(t,1,er,e)}var sr=class extends Le{constructor(t){super(t,500)}K(t){return ye(this,1001,t)}};sr.prototype.i=Wn([-500,Mn,[-500,Dn,-1,Un,-3,[-2,Zn,Nn],Mn,qn,xn,-1,rr,ir,Mn,[0,Dn,kn],Dn,tr,xn,Un,987,Un],4,Mn,[-500,jn,-1,[-1,{}],998,jn],Mn,[-500,jn,Un,-1,[-2,{},Nn],997,Un,-1],xn,Mn,[-500,jn,Un,nr,998,Un],Un,xn,rr,ir,Mn,[0,Dn,-1,nr],Un,-2,tr,Dn,-1,kn,[0,kn,Rn],978,nr,Mn,qn]);var ar=class extends Le{constructor(t){super(t)}};let ur;const cr=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);async function lr(){if(void 0===ur)try{await WebAssembly.instantiate(cr),ur=!0}catch{ur=!1}return ur}async function hr(t,e=Xn``){const n=await lr()?"wasm_internal":"wasm_nosimd_internal";return{wasmLoaderPath:`${e}/${t}_${n}.js`,wasmBinaryPath:`${e}/${t}_${n}.wasm`}}var fr=class{};function dr(){var t=navigator;return"undefined"!=typeof OffscreenCanvas&&(!function(t=navigator){return(t=t.userAgent).includes("Safari")&&!t.includes("Chrome")}(t)||!!((t=t.userAgent.match(/Version\/([\d]+).*Safari/))&&t.length>=1&&Number(t[1])>=17))}async function pr(t){if("function"!=typeof importScripts){const e=document.createElement("script");return e.src=t.toString(),e.crossOrigin="anonymous",new Promise(((t,n)=>{e.addEventListener("load",(()=>{t()}),!1),e.addEventListener("error",(t=>{n(t)}),!1),document.body.appendChild(e)}))}importScripts(t.toString())}fr.forVisionTasks=function(t){return hr("vision",t)},fr.forTextTasks=function(t){return hr("text",t)},fr.forGenAiExperimentalTasks=function(t){return hr("genai_experimental",t)},fr.forGenAiTasks=function(t){return hr("genai",t)},fr.forAudioTasks=function(t){return hr("audio",t)},fr.isSimdSupported=function(){return lr()};function gr(t,e,n){t.o||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),n(e=t.h.stringToNewUTF8(e)),t.h._free(e)}function mr(t,e,n){t.o||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");const r=new Uint32Array(e.length);for(let n=0;n<e.length;n++)r[n]=t.h.stringToNewUTF8(e[n]);e=t.h._malloc(4*r.length),t.h.HEAPU32.set(r,e>>2),n(e);for(const e of r)t.h._free(e);t.h._free(e)}function _r(t,e,n){t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=n}function br(t,e,n){let r=[];t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=(t,e,i)=>{e?(n(r,i),r=[]):r.push(t)}}const yr=(vr=class{constructor(t,e){this.l=!0,this.h=t,this.i=null,this.j=0,this.o="function"==typeof this.h._addIntToInputStream,void 0!==e?this.h.canvas=e:dr()?this.h.canvas=new OffscreenCanvas(1,1):(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.h.canvas=document.createElement("canvas"))}async initializeGraph(t){const e=await(await fetch(t)).arrayBuffer();t=!(t.endsWith(".pbtxt")||t.endsWith(".textproto")),this.setGraph(new Uint8Array(e),t)}setGraphFromString(t){this.setGraph((new TextEncoder).encode(t),!1)}setGraph(t,e){const n=t.length,r=this.h._malloc(n);this.h.HEAPU8.set(t,r),e?this.h._changeBinaryGraph(n,r):this.h._changeTextGraph(n,r),this.h._free(r)}configureAudio(t,e,n,r,i){this.h._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),gr(this,r||"input_audio",(r=>{gr(this,i=i||"audio_header",(i=>{this.h._configureAudio(r,i,t,e??0,n)}))}))}setAutoResizeCanvas(t){this.l=t}setAutoRenderToScreen(t){this.h._setAutoRenderToScreen(t)}setGpuBufferVerticalFlip(t){this.h.gpuOriginForWebTexturesIsBottomLeft=t}attachErrorListener(t){this.h.errorListener=t}attachEmptyPacketListener(t,e){this.h.emptyPacketListeners=this.h.emptyPacketListeners||{},this.h.emptyPacketListeners[t]=e}addAudioToStream(t,e,n){this.addAudioToStreamWithShape(t,0,0,e,n)}addAudioToStreamWithShape(t,e,n,r,i){const o=4*t.length;this.j!==o&&(this.i&&this.h._free(this.i),this.i=this.h._malloc(o),this.j=o),this.h.HEAPF32.set(t,this.i/4),gr(this,r,(t=>{this.h._addAudioToInputStream(this.i,e,n,t,i)}))}addGpuBufferToStream(t,e,n){gr(this,e,(e=>{if(!this.h.canvas)throw Error("No OpenGL canvas configured.");e?this.h._bindTextureToStream(e):this.h._bindTextureToCanvas();const r=this.h.canvas.getContext("webgl2")||this.h.canvas.getContext("webgl");if(!r)throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");this.h.gpuOriginForWebTexturesIsBottomLeft&&r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!0),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t),this.h.gpuOriginForWebTexturesIsBottomLeft&&r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1);const[i,o]=void 0!==t.videoWidth?[t.videoWidth,t.videoHeight]:void 0!==t.naturalWidth?[t.naturalWidth,t.naturalHeight]:void 0!==t.displayWidth?[t.displayWidth,t.displayHeight]:[t.width,t.height];!this.l||i===this.h.canvas.width&&o===this.h.canvas.height||(this.h.canvas.width=i,this.h.canvas.height=o);const[s,a]=[i,o];this.h._addBoundTextureToStream(e,s,a,n)}))}addBoolToStream(t,e,n){gr(this,e,(e=>{this.h._addBoolToInputStream(t,e,n)}))}addDoubleToStream(t,e,n){gr(this,e,(e=>{this.h._addDoubleToInputStream(t,e,n)}))}addFloatToStream(t,e,n){gr(this,e,(e=>{this.h._addFloatToInputStream(t,e,n)}))}addIntToStream(t,e,n){gr(this,e,(e=>{this.h._addIntToInputStream(t,e,n)}))}addUintToStream(t,e,n){gr(this,e,(e=>{this.h._addUintToInputStream(t,e,n)}))}addStringToStream(t,e,n){gr(this,e,(e=>{gr(this,t,(t=>{this.h._addStringToInputStream(t,e,n)}))}))}addStringRecordToStream(t,e,n){gr(this,e,(e=>{mr(this,Object.keys(t),(r=>{mr(this,Object.values(t),(i=>{this.h._addFlatHashMapToInputStream(r,i,Object.keys(t).length,e,n)}))}))}))}addProtoToStream(t,e,n,r){gr(this,n,(n=>{gr(this,e,(e=>{const i=this.h._malloc(t.length);this.h.HEAPU8.set(t,i),this.h._addProtoToInputStream(i,t.length,e,n,r),this.h._free(i)}))}))}addEmptyPacketToStream(t,e){gr(this,t,(t=>{this.h._addEmptyPacketToInputStream(t,e)}))}addBoolVectorToStream(t,e,n){gr(this,e,(e=>{const r=this.h._allocateBoolVector(t.length);if(!r)throw Error("Unable to allocate new bool vector on heap.");for(const e of t)this.h._addBoolVectorEntry(r,e);this.h._addBoolVectorToInputStream(r,e,n)}))}addDoubleVectorToStream(t,e,n){gr(this,e,(e=>{const r=this.h._allocateDoubleVector(t.length);if(!r)throw Error("Unable to allocate new double vector on heap.");for(const e of t)this.h._addDoubleVectorEntry(r,e);this.h._addDoubleVectorToInputStream(r,e,n)}))}addFloatVectorToStream(t,e,n){gr(this,e,(e=>{const r=this.h._allocateFloatVector(t.length);if(!r)throw Error("Unable to allocate new float vector on heap.");for(const e of t)this.h._addFloatVectorEntry(r,e);this.h._addFloatVectorToInputStream(r,e,n)}))}addIntVectorToStream(t,e,n){gr(this,e,(e=>{const r=this.h._allocateIntVector(t.length);if(!r)throw Error("Unable to allocate new int vector on heap.");for(const e of t)this.h._addIntVectorEntry(r,e);this.h._addIntVectorToInputStream(r,e,n)}))}addUintVectorToStream(t,e,n){gr(this,e,(e=>{const r=this.h._allocateUintVector(t.length);if(!r)throw Error("Unable to allocate new unsigned int vector on heap.");for(const e of t)this.h._addUintVectorEntry(r,e);this.h._addUintVectorToInputStream(r,e,n)}))}addStringVectorToStream(t,e,n){gr(this,e,(e=>{const r=this.h._allocateStringVector(t.length);if(!r)throw Error("Unable to allocate new string vector on heap.");for(const e of t)gr(this,e,(t=>{this.h._addStringVectorEntry(r,t)}));this.h._addStringVectorToInputStream(r,e,n)}))}addBoolToInputSidePacket(t,e){gr(this,e,(e=>{this.h._addBoolToInputSidePacket(t,e)}))}addDoubleToInputSidePacket(t,e){gr(this,e,(e=>{this.h._addDoubleToInputSidePacket(t,e)}))}addFloatToInputSidePacket(t,e){gr(this,e,(e=>{this.h._addFloatToInputSidePacket(t,e)}))}addIntToInputSidePacket(t,e){gr(this,e,(e=>{this.h._addIntToInputSidePacket(t,e)}))}addUintToInputSidePacket(t,e){gr(this,e,(e=>{this.h._addUintToInputSidePacket(t,e)}))}addStringToInputSidePacket(t,e){gr(this,e,(e=>{gr(this,t,(t=>{this.h._addStringToInputSidePacket(t,e)}))}))}addProtoToInputSidePacket(t,e,n){gr(this,n,(n=>{gr(this,e,(e=>{const r=this.h._malloc(t.length);this.h.HEAPU8.set(t,r),this.h._addProtoToInputSidePacket(r,t.length,e,n),this.h._free(r)}))}))}addBoolVectorToInputSidePacket(t,e){gr(this,e,(e=>{const n=this.h._allocateBoolVector(t.length);if(!n)throw Error("Unable to allocate new bool vector on heap.");for(const e of t)this.h._addBoolVectorEntry(n,e);this.h._addBoolVectorToInputSidePacket(n,e)}))}addDoubleVectorToInputSidePacket(t,e){gr(this,e,(e=>{const n=this.h._allocateDoubleVector(t.length);if(!n)throw Error("Unable to allocate new double vector on heap.");for(const e of t)this.h._addDoubleVectorEntry(n,e);this.h._addDoubleVectorToInputSidePacket(n,e)}))}addFloatVectorToInputSidePacket(t,e){gr(this,e,(e=>{const n=this.h._allocateFloatVector(t.length);if(!n)throw Error("Unable to allocate new float vector on heap.");for(const e of t)this.h._addFloatVectorEntry(n,e);this.h._addFloatVectorToInputSidePacket(n,e)}))}addIntVectorToInputSidePacket(t,e){gr(this,e,(e=>{const n=this.h._allocateIntVector(t.length);if(!n)throw Error("Unable to allocate new int vector on heap.");for(const e of t)this.h._addIntVectorEntry(n,e);this.h._addIntVectorToInputSidePacket(n,e)}))}addUintVectorToInputSidePacket(t,e){gr(this,e,(e=>{const n=this.h._allocateUintVector(t.length);if(!n)throw Error("Unable to allocate new unsigned int vector on heap.");for(const e of t)this.h._addUintVectorEntry(n,e);this.h._addUintVectorToInputSidePacket(n,e)}))}addStringVectorToInputSidePacket(t,e){gr(this,e,(e=>{const n=this.h._allocateStringVector(t.length);if(!n)throw Error("Unable to allocate new string vector on heap.");for(const e of t)gr(this,e,(t=>{this.h._addStringVectorEntry(n,t)}));this.h._addStringVectorToInputSidePacket(n,e)}))}attachBoolListener(t,e){_r(this,t,e),gr(this,t,(t=>{this.h._attachBoolListener(t)}))}attachBoolVectorListener(t,e){br(this,t,e),gr(this,t,(t=>{this.h._attachBoolVectorListener(t)}))}attachIntListener(t,e){_r(this,t,e),gr(this,t,(t=>{this.h._attachIntListener(t)}))}attachIntVectorListener(t,e){br(this,t,e),gr(this,t,(t=>{this.h._attachIntVectorListener(t)}))}attachUintListener(t,e){_r(this,t,e),gr(this,t,(t=>{this.h._attachUintListener(t)}))}attachUintVectorListener(t,e){br(this,t,e),gr(this,t,(t=>{this.h._attachUintVectorListener(t)}))}attachDoubleListener(t,e){_r(this,t,e),gr(this,t,(t=>{this.h._attachDoubleListener(t)}))}attachDoubleVectorListener(t,e){br(this,t,e),gr(this,t,(t=>{this.h._attachDoubleVectorListener(t)}))}attachFloatListener(t,e){_r(this,t,e),gr(this,t,(t=>{this.h._attachFloatListener(t)}))}attachFloatVectorListener(t,e){br(this,t,e),gr(this,t,(t=>{this.h._attachFloatVectorListener(t)}))}attachStringListener(t,e){_r(this,t,e),gr(this,t,(t=>{this.h._attachStringListener(t)}))}attachStringVectorListener(t,e){br(this,t,e),gr(this,t,(t=>{this.h._attachStringVectorListener(t)}))}attachProtoListener(t,e,n){_r(this,t,e),gr(this,t,(t=>{this.h._attachProtoListener(t,n||!1)}))}attachProtoVectorListener(t,e,n){br(this,t,e),gr(this,t,(t=>{this.h._attachProtoVectorListener(t,n||!1)}))}attachAudioListener(t,e,n){this.h._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),_r(this,t,((t,n)=>{t=new Float32Array(t.buffer,t.byteOffset,t.length/4),e(t,n)})),gr(this,t,(t=>{this.h._attachAudioListener(t,n||!1)}))}finishProcessing(){this.h._waitUntilIdle()}closeGraph(){this.h._closeGraph(),this.h.simpleListeners=void 0,this.h.emptyPacketListeners=void 0}},class extends vr{Y(){this.h._registerModelResourcesGraphService()}});var vr;async function wr(t,e){const n=await(async(t,e,n)=>{var r=ei;if(t&&await pr(t),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(e&&(await pr(e),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&n&&((t=self.Module).locateFile=n.locateFile,n.mainScriptUrlOrBlob&&(t.mainScriptUrlOrBlob=n.mainScriptUrlOrBlob)),n=await self.ModuleFactory(self.Module||n),self.ModuleFactory=self.Module=void 0,new r(n,null)})(t.wasmLoaderPath,t.assetLoaderPath,{locateFile:e=>e.endsWith(".wasm")?t.wasmBinaryPath.toString():t.assetBinaryPath&&e.endsWith(".data")?t.assetBinaryPath.toString():e});return await n.K(e),n}async function Sr(t,e){return wr(t,e)}function Ar(t){try{const e=t.H.length;if(1===e)throw Error(t.H[0].message);if(e>1)throw Error("Encountered multiple errors: "+t.H.map((t=>t.message)).join(", "))}finally{t.H=[]}}function Tr(t,e){t.G=Math.max(t.G,e)}var Er=class{constructor(t){this.i=t,this.H=[],this.G=0,this.i.setAutoRenderToScreen(!1)}setGraph(t,e){this.i.attachErrorListener(((t,e)=>{this.H.push(Error(e))})),this.i.Y(),this.i.setGraph(t,e),Ar(this)}finishProcessing(){this.i.finishProcessing(),Ar(this)}close(){this.i.closeGraph()}};Er.prototype.close=Er.prototype.close;var Ir=class extends Le{constructor(t){super(t)}};function Pr(t,e){ye(t,1,e)}var Or=class extends Le{constructor(t){super(t)}},Lr=[0,zn,xn,In,-1,Ln];function Ur(t,e,n,r){if(void 0!==t.data){var i=new Uint8Array(t.data.buffer,e,n);return 1===r&&function(t,e,n){t.i.push([e,n]),t.i.sort(((t,e)=>t[0]-e[0])),e=0;for(const[r,i]of t.i){const t=i;(n=r)<=e&&(e=Math.max(e,n+t))}e===t.length&&(t.data=void 0)}(t,e,n),i}}class xr{constructor(t){this.i=[],this.data=t,this.length=t.length}}var Br=class{constructor(t,e,n){this.i=t,this.j=e,this.l=n}get size(){let t=0;for(let e=0;e<this.i.length;e++)t+=this.i[e].length;return t}};function Nr(t){if(t.i)try{t.h._free(t.j)}catch{}finally{t.i=!1}}var kr=class{constructor(t,e){this.h=t,this.l=e,this.j=this.h._malloc(e)>>>0,this.o=this.h.HEAPU8,this.i=!!this.j}get offset(){if(!this.i)throw Error("WasmFileReference has been freed.");return this.j}get size(){if(!this.i)throw Error("WasmFileReference has been freed.");return this.l}set(t,e){this.o.set(t,this.j+(e??0))}},jr=class extends Le{constructor(t){super(t)}};jr.prototype.i=Wn([0,Dn,2,Un,xn,kn]);var Fr=class extends Le{constructor(t){super(t)}},Dr=class extends Le{constructor(t){super(t)}},Vr=class extends Le{constructor(t){super(t)}},Mr=class extends Le{constructor(t){super(t)}},Cr=[0,xn,-6,1,xn,1,[0,kn,zn,-2],[0,kn,In],zn,-2,[0,kn,-1,zn,In,Gn,Ln],1,kn,xn,Ln,-1,[0,zn,xn],kn,-1,En,xn,-1],Rr=[0,[4,6],Cr,xn,1,Bn,Un,Vn,Fn,[0,Dn,-2],Ln,[0,[0,xn,-1,Mn,[0,xn,[0,xn,-1],-1,[0,zn,-1],kn],kn,-2,xn,-1],[0,xn,-1,kn],Cr,kn,xn],jn,-3,[0,xn,kn],Cr];Mr.prototype.i=Wn([0,Dn,8,[0,kn,-6],1,xn,1,xn,[0,Mn,[0,Dn,On,-1,zn],Rr,xn],[0,xn,kn,-3],1,zn,1,Rr,1,xn,5,zn,Tn,1,Lr,kn]);var Gr=class extends Le{constructor(t){super(t)}},zr=class extends Le{constructor(t){super(t)}},Wr=[2,4];zr.prototype.i=Wn([0,Wr,xn,Vn,xn,Cn,[0,1,Dn]]);const Hr=function(t){return class e extends t{static async Z(t,n){let r;n||=await e.O();const i=[];for(const e of t?.requiredFeatures??[])n.features.has(e)?i.push(e):console.warn(`WebGPU feature ${e} is not supported.`);t={...t,requiredFeatures:i};try{r=await n.requestDevice(t)}catch(t){throw console.error("Unable to initialize WebGPU with the requested features."),t}return(t=r).adapterInfo||(t.adapterInfo=n.info),r}static async O(t){if(!(t=await navigator.gpu.requestAdapter(t)))throw Error("Unable to request adapter from navigator.gpu; Ensure WebGPU is enabled.");return t}V(t){if(e)"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.id="canvas_webgpu");else var e=new OffscreenCanvas(1,1);e.getContext("webgpu").configure({device:t,format:navigator.gpu.getPreferredCanvasFormat()}),this.h.preinitializedWebGPUDevice=t}R(){return this.h.ccall("closeGraph","void",[],[],{async:!0})}}}(function(t){return class extends t{addStreamingReaderToInputSidePacket(t,e){this.h.addStreamingReaderToInputSidePacket(((e,n,r)=>async function(t,e,n,r,i){if(2===i)return t.i=[],t.j=()=>Promise.resolve(void 0),setTimeout((()=>{t.l()}),0),Promise.resolve(0);for(;t.size<n+r;){var o=await t.j();if(void 0===o)break;t.i.push(new xr(o))}if(t.size<n+r)throw Error(`Data size is too small: ${t.size}, expected at least ${n+r}.`);o=e._malloc(r)>>>0;let s=0;for(let a=0;a<t.i.length;a++){const u=t.i[a];if(n>=u.length){n-=u.length;continue}const c=Math.min(r,u.length-n);if(void 0===(n=Ur(u,n,c,i)))throw Error("Data has already been released.");if(e.HEAPU8.set(n,o+s),n=0,s+=c,0==(r-=c))break}if(0!==r)throw Error("Data not found.");return Promise.resolve(o)}(t,this.h,e,n,r)),e)}}}(function(t){return class extends t{P(t,e){gr(this,"lora_model_ref_in",(n=>{this.h._addRawDataSpanToInputStream(t.offset,t.size,n,e)}))}}}(class extends yr{})));class $r extends Hr{}var qr=class{constructor(t){this.j=t,this.i=Kr,Kr++}},Kr=0;class Yr{constructor(){let t,e;this.promise=new Promise(((n,r)=>{t=n,e=r})),this.resolve=t,this.reject=e}}function Jr(t){return 1===t?1:t+t%2}async function Xr(){const t=await $r.O({powerPreference:"high-performance"});var e=t.limits.maxBufferSize;if(t.limits.maxStorageBufferBindingSize<524550144)throw Error(`The WebGPU device is unable to execute LLM tasks, because the required maxStorageBufferBindingSize is at least 524550144 but your device only supports maxStorageBufferBindingSize of ${e}`);if(e>=786825216)e=786825216;else{if(!(e>=524550144))throw Error(`The WebGPU device is unable to execute LLM tasks, because the required maxBufferSize is at least 524550144 but your device only supports maxBufferSize of ${e}`);e=524550144}if(e={requiredFeatures:["shader-f16"],requiredLimits:{maxStorageBufferBindingSize:524550144,maxBufferSize:e,maxStorageBuffersPerShaderStage:t.limits.maxStorageBuffersPerShaderStage}},t.features.has("subgroups")){console.warn("Experimental Chromium WGSL subgroup support detected. Enabling this feature in the inference engine.");const n=["shader-f16","subgroups"];t.features.has("subgroups-f16")&&n.push("subgroups-f16"),e.requiredFeatures=n}return $r.Z(e,t)}function Zr(t){const e=function(t){const e=new sr;Pe(e,10,"text_in"),Pe(e,10,"token_cost_in"),Pe(e,10,"lora_model_id_to_apply_in"),Pe(e,10,"lora_model_ref_in"),Pe(e,10,"lora_model_id_to_load_in"),Pe(e,16,"streaming_reader"),Pe(e,15,"text_out"),Pe(e,15,"text_end"),Pe(e,15,"token_cost_out");var n=new er;Ie(n,2,"TokenizerInputBuildCalculator"),Pe(n,3,"PROMPT:text_in"),Pe(n,3,"LORA_ID:lora_model_id_to_apply_in"),Pe(n,4,"prompt"),or(e,n),Ie(n=new er,2,"ModelDataCalculator"),Pe(n,6,"MODEL_DATA:__side_packet_1"),Pe(n,6,"MODEL_TYPE:model_type"),Pe(n,5,"READ_DATA_FN:streaming_reader"),Pe(n,3,"LORA_MODEL_SPAN:lora_model_ref_in"),Pe(n,3,"LORA_MODEL_ID:lora_model_id_to_load_in"),Pe(n,4,"LORA_DATA:lora_model_data"),or(e,n),Ie(n=new er,2,"Gpt2UnicodeMappingCalculator"),Pe(n,5,"MODEL_TYPE:model_type"),Pe(n,6,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),or(e,n),Ie(n=new $n,1,"type.googleapis.com/odml.infra.proto.TokenizerCalculatorOptions");var r=new zr,i=Te(t.j,2);Ee(r,1,i),Ie(i=new Gr,2,"spm_vocab_model"),null==i&&(i=void 0);t:{var o=r.m,s=K(o);if(ot(s),null==i){var a=me(o);if(4!==_e(a,o,s))break t;a.set(Wr,0)}else{const t=me(a=o),e=_e(t,a,s);4!==e&&(e&&(s=ce(a,s,e)),t.set(Wr,4))}ce(o,s,4,i)}return Ee(r,3,2),Hn(n,r.i()),Ie(r=new er,2,"TokenizerCalculator"),Se(r,8,$n,n),Pe(r,5,"MODEL_DATA:__side_packet_1"),Pe(r,3,"PROMPT_AND_INPUT_OPTIONS:prompt"),Pe(r,5,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),Pe(r,6,"PROCESSOR_GETTER:__input_side_1"),Pe(r,4,"IDS_AND_INPUT_OPTIONS:__stream_0"),or(e,r),Ie(n=new $n,1,"type.googleapis.com/odml.infra.proto.LlmGpuCalculatorOptions"),Ee(r=new Mr,12,3),Ie(r,1,"llm.tflite"),Ee(r,14,0),i=Jr(Te(t.j,5)),Ee(r,22,i),i=be(t.j,Ir,3),ye(r,31,i),ge(i=new Fr,1,!0,!1),ge(i,2,!0,!1),ge(i,5,!0,!1),ye(r,10,i),i=le(t.j,4,kt,void 0===st?2:4),pe(r,29,i),i=new Vr,Ee(o=new Dr,1,1),a=Te(t.j,2),Ee(o,2,a),ye(i,1,o),ye(r,20,i),Hn(n,r.i()),Ie(r=new er,2,"LlmGpuCalculator"),Se(r,8,$n,n),Pe(r,3,"IDS_AND_INPUT_OPTIONS:__stream_0"),Pe(r,3,"FINISH:finish"),Pe(r,3,"LORA_DATA:lora_model_data"),Pe(r,5,"MODEL_DATA:__side_packet_1"),Pe(r,4,"DECODED_IDS:__stream_3"),Pe(r,4,"OUTPUT_END:__stream_4"),Ie(n=new Qn,1,"FINISH"),ge(n,2,!0,!1),Se(r,13,Qn,n),or(e,r),Ie(n=new er,2,"IsPacketPresentCalculator"),Pe(n,3,"__stream_4"),Pe(n,4,"text_end"),or(e,n),Ie(n=new $n,1,"type.googleapis.com/odml.infra.proto.DetokenizerCalculatorOptions"),r=new jr,t=Jr(Te(t.j,5)),Ee(r,5,t),Pe(r,4,"<eos>"),Pe(r,4,"<|endoftext|>"),Hn(n,r.i()),Ie(t=new er,2,"DetokenizerCalculator"),Se(t,8,$n,n),Pe(t,3,"IDS_AND_INPUT_OPTIONS:__stream_3"),Pe(t,5,"PROCESSOR_GETTER:__input_side_1"),Pe(t,5,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),Pe(t,5,"MODEL_DATA:__side_packet_1"),Pe(t,4,"FINISH_AND_INPUT_OPTIONS:finish"),Pe(t,4,"WORDS:text_out"),or(e,t),Ie(t=new er,2,"TokenCostCalculator"),Pe(t,3,"PROMPT:token_cost_in"),Pe(t,5,"PROCESSOR_GETTER:__input_side_1"),Pe(t,5,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),Pe(t,4,"NUM_TOKENS:token_cost_out"),or(e,t),e}(t);t.i.attachStringVectorListener("text_out",((e,n)=>{e=function(t,e){return null==t||0===t.length?[]:t.map((t=>(t=(t=t.replaceAll("▁"," ")).replaceAll("<0x0A>","\n"),e&&(t=t.trimStart()),t.split("\\[eod\\]",1)[0])))}(e,0===t.D.length),e.forEach(((e,n)=>{n<Te(t.j,5)&&t.D[n].push(e)})),t.A&&0===t.B.length&&(t.F?(e.length>Te(t.j,5)&&e.pop(),t.A(e,!1)):t.A(e[0],!1)),Tr(t,n)})),t.i.attachEmptyPacketListener("text_out",(e=>{Tr(t,e)})),t.i.attachBoolListener("text_end",((e,n)=>{if(t.l=!1,Tr(t,n),Qr(t),t.o&&(t.o.resolve(t.D.map((t=>t.join("")))),t.o=void 0),t.A)if(t.F){for(e=[],n=0;n<Te(t.j,5);n++)e.push("");t.A(e,!0)}else t.A("",!0);t.F=void 0})),t.i.attachEmptyPacketListener("text_end",(e=>{t.l=!1,t.F=void 0,Tr(t,e),Qr(t),t.o&&(t.o.resolve(t.D.map((t=>t.join("")))),t.o=void 0)})),t.i.attachIntListener("token_cost_out",((e,n)=>{t.M=e,Tr(t,n)})),t.J&&t.i.addStreamingReaderToInputSidePacket(t.J,"streaming_reader");const n=e.i();return t.v?.removeEventListener("uncapturederror",t.I),t.i.R().then((()=>{t.v?.addEventListener("uncapturederror",t.I),t.B.length=0,t.setGraph(new Uint8Array(n),!0),t.finishProcessing()}))}function Qr(t){if(t.B.length>0){const e=[...t.B];if(t.B.length=0,!t.o)throw e;t.o.reject(e),t.o=void 0}}function ti(t,e,n,r){if(t.l)throw Error("Previous invocation or loading is still ongoing.");for(t.A="function"==typeof n?n:r,t.l=!0,t.D.length=0,r=0;r<Te(t.j,5);r++)t.D[r]=[];if(r=t.G+1,t.i.addStringToStream(e,"text_in",r),n instanceof qr){if(n.j!==t)throw t.l=!1,t.F=void 0,Error("The LoRA model was not loaded by this LLM Inference task.");t.i.addUintToStream(n.i,"lora_model_id_to_apply_in",r)}else t.i.addEmptyPacketToStream("lora_model_id_to_apply_in",r);return t.finishProcessing(),t.o=new Yr,t.o.promise}var ei=class extends Er{constructor(t,e){super(new $r(t,e)),this.D=[],this.l=!1,this.B=[],this.I=t=>{const e=(t=t.error).message.match(/exceeds the max buffer size limit \(([0-9]+)\)\./);e&&Number(e[1])>524550144?t=Error(`Failed to run this LLM model, but you could try a smaller LLM model. WebGPU throws: "${t.message}"`):t.message.match(/is larger than the maximum binding size/)&&(t=Error(`Failed to run LLM inference, the supported max binding size is smaller than the required size. WebGPU throws: "${t.message}"`)),this.B.push(t)},this.j=new Or,Pr(this.j,new ar),this.u=new Ir,ye(this.j,3,this.u),ue(this.j,2,jt(512)),ge(this.u,1,2,0),Ee(this.u,2,40),ge(this.u,3,Ot(1),0),ue(this.u,5,Nt(0)),ge(this.u,4,Ot(.8),0),ue(this.j,5,jt(1))}K(t){if(this.l)throw Error("Cannot set options while loading or processing.");if(this.l=!0,t.baseOptions?.gpuOptions?.device&&(this.v&&this.v.removeEventListener("uncapturederror",this.I),this.v=t.baseOptions.gpuOptions.device,this.i.V(this.v),this.v.addEventListener("uncapturederror",this.I)),"maxTokens"in t&&ue(this.j,2,jt(t.maxTokens??512)),"topK"in t&&Ee(this.u,2,t.topK??40),"temperature"in t&&ge(this.u,4,Ot(t.temperature??.8),0),"randomSeed"in t&&ue(this.u,5,Nt(t.randomSeed??0)),"loraRanks"in t&&function(t,e){pe(t,4,e)}(this.j,t.loraRanks??[]),"numResponses"in t){var e=t.numResponses??1;if(e<1)throw Error("'numResponses' must be at least 1.");ue(this.j,5,jt(e));var n=be(this.j,Ir,3);e>1&&n&&(Ae(kt(oe(n,2)))<=1||Ae(function(t){t=t.m;let e=K(t);const n=ae(t,e,4),r=Lt(n);return null!=r&&r!==n&&ce(t,e,4,r),r}(n))<=0)&&console.warn("To generate multiple responses, it is expected topK > 1 and temperature > 0; otherwise, all the generated responses may be the same.")}let r;if(e=new Promise((t=>{r=t})),t.baseOptions?.modelAssetPath||t.baseOptions?.modelAssetBuffer){if(t.baseOptions.modelAssetPath&&t.baseOptions.modelAssetBuffer)throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");n=!1,t.baseOptions.modelAssetPath?this.J=function(t,e){const n=fetch(t.toString()).then((t=>t?.body?.getReader()));return new Br([],(async()=>{let e;try{e=await n}catch(e){throw Error(`Error loading model from "${t.toString()}": ${e}`)}const{value:r,done:i}=await e.read();return i?void 0:r}),e)}(t.baseOptions.modelAssetPath,r):t.baseOptions.modelAssetBuffer instanceof Uint8Array?(this.J=function(t,e){return new Br([new xr(t)],(()=>Promise.resolve(void 0)),e)}(t.baseOptions.modelAssetBuffer,r),n=!0):t.baseOptions.modelAssetBuffer?(this.J=function(t,e){return new Br([],(async()=>{const{value:e,done:n}=await t.read();return n?void 0:e}),e)}(t.baseOptions.modelAssetBuffer,r),n=!0):r(),n&&(t.baseOptions.modelAssetBuffer=void 0)}return t=Zr(this).then((()=>{})),Promise.all([e,t]).then((()=>{this.l=!1,Qr(this)}))}get baseOptions(){return be(this.j,ar,1)}set baseOptions(t){Pr(this.j,t)}T(t,e,n){return Te(this.j,5)>1&&console.warn("'numResponses' is set larger than 1 and this function only returns the first response, so we recommend either using 'generateResponses()' to obtain multiple responses, or else setting 'numResponses' to 1 for better performance."),this.F=!1,ti(this,t,e,n).then((t=>t[0]))}U(t,e,n){return this.F=!0,ti(this,t,e,n)}aa(t){if(this.l)throw Error("Previous invocation or loading is still ongoing.");return this.l=!0,this.M=void 0,this.i.addStringToStream(t,"token_cost_in",this.G+1),this.finishProcessing(),this.l=!1,this.M}async X(t){if(this.l)throw Error("Cannot load LoRA model while loading or processing.");if(this.l=!0,t instanceof Uint8Array){var e=new kr(this.i.h,t.length);e.set(t),t=e}else t=await async function(t,e){var n=await fetch(e.toString());e=Number(n.headers.get("content-length")),t=new kr(t,e);let r=0;for(n=n?.body?.getReader();;){const{value:e,done:i}=await n.read();if(i)break;t.set(e,r),r+=e.byteLength}if(e!==r)throw Nr(t),Error(`File could not be fully loaded to memory, so was not retained. Loaded ${r}/${e} bytes before failure`);return t}(this.i.h,t);return e=new qr(this),this.i.P(t,this.G+1),this.i.addUintToStream(e.i,"lora_model_id_to_load_in",this.G+1),this.finishProcessing(),Nr(t),this.l=!1,e}close(){this.v?.removeEventListener("uncapturederror",this.I),super.close()}};ei.prototype.loadLoraModel=ei.prototype.X,ei.prototype.sizeInTokens=ei.prototype.aa,ei.prototype.generateResponses=ei.prototype.U,ei.prototype.generateResponse=ei.prototype.T,ei.prototype.setOptions=ei.prototype.K,ei.createWebGpuDevice=Xr,ei.createFromModelPath=async function(t,e){return Sr(t,e={baseOptions:{gpuOptions:{device:await Xr()},modelAssetPath:e}})},ei.createFromModelBuffer=async function(t,e){return Sr(t,e={baseOptions:{gpuOptions:{device:await Xr()},modelAssetBuffer:e}})},ei.createFromOptions=async function(t,e){if(!e.baseOptions?.gpuOptions?.device){const t=await Xr();e.baseOptions=e.baseOptions??{},e.baseOptions.gpuOptions=e?.baseOptions?.gpuOptions??{},e.baseOptions.gpuOptions.device=t}return Sr(t,e)},exports.FilesetResolver=fr,exports.LlmInference=ei,exports.TaskRunner=Er;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t="undefined"!=typeof self?self:{};let e;const n="undefined"!=typeof TextEncoder;function r(t){if(n)t=(e||=new TextEncoder).encode(t);else{let e=0;const n=new Uint8Array(3*t.length);for(let i=0;i<t.length;i++){var r=t.charCodeAt(i);if(r<128)n[e++]=r;else{if(r<2048)n[e++]=r>>6|192;else{if(r>=55296&&r<=57343){if(r<=56319&&i<t.length){const o=t.charCodeAt(++i);if(o>=56320&&o<=57343){r=1024*(r-55296)+o-56320+65536,n[e++]=r>>18|240,n[e++]=r>>12&63|128,n[e++]=r>>6&63|128,n[e++]=63&r|128;continue}i--}r=65533}n[e++]=r>>12|224,n[e++]=r>>6&63|128}n[e++]=63&r|128}}t=e===n.length?n:n.subarray(0,e)}return t}var i,o;t:{for(var s=["CLOSURE_FLAGS"],a=t,u=0;u<s.length;u++)if(null==(a=a[s[u]])){o=null;break t}o=a}var c,l=o&&o[610401301];i=null!=l&&l;const h=t.navigator;function f(t){return!!i&&(!!c&&c.brands.some((({brand:e})=>e&&-1!=e.indexOf(t))))}function d(e){var n;return(n=t.navigator)&&(n=n.userAgent)||(n=""),-1!=n.indexOf(e)}function p(){return!!i&&(!!c&&c.brands.length>0)}function g(){return p()?f("Chromium"):(d("Chrome")||d("CriOS"))&&!(!p()&&d("Edge"))||d("Silk")}c=h&&h.userAgentData||null;var m=!p()&&(d("Trident")||d("MSIE"));!d("Android")||g(),g(),d("Safari")&&(g()||!p()&&d("Coast")||!p()&&d("Opera")||!p()&&d("Edge")||(p()?f("Microsoft Edge"):d("Edg/"))||p()&&f("Opera"));var _={},b=null;function y(t){const e=t.length;let n=3*e/4;n%3?n=Math.floor(n):-1!="=.".indexOf(t[e-1])&&(n=-1!="=.".indexOf(t[e-2])?n-2:n-1);const r=new Uint8Array(n);let i=0;return function(t,e){function n(e){for(;r<t.length;){const e=t.charAt(r++),n=b[e];if(null!=n)return n;if(!/^[\s\xa0]*$/.test(e))throw Error("Unknown base64 encoding at char: "+e)}return e}v();let r=0;for(;;){const t=n(-1),r=n(0),i=n(64),o=n(64);if(64===o&&-1===t)break;e(t<<2|r>>4),64!=i&&(e(r<<4&240|i>>2),64!=o&&e(i<<6&192|o))}}(t,(function(t){r[i++]=t})),i!==n?r.subarray(0,i):r}function v(){if(!b){b={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"];for(let n=0;n<5;n++){const r=t.concat(e[n].split(""));_[n]=r;for(let t=0;t<r.length;t++){const e=r[t];void 0===b[e]&&(b[e]=t)}}}}var w="undefined"!=typeof Uint8Array,S=!m&&"function"==typeof btoa;function A(t){if(!S){var e;void 0===e&&(e=0),v(),e=_[e];var n=Array(Math.floor(t.length/3)),r=e[64]||"";let u=0,c=0;for(;u<t.length-2;u+=3){var i=t[u],o=t[u+1],s=t[u+2],a=e[i>>2];i=e[(3&i)<<4|o>>4],o=e[(15&o)<<2|s>>6],s=e[63&s],n[c++]=a+i+o+s}switch(a=0,s=r,t.length-u){case 2:s=e[(15&(a=t[u+1]))<<2]||r;case 1:t=t[u],n[c]=e[t>>2]+e[(3&t)<<4|a>>4]+s+r}return n.join("")}for(e="",n=0,r=t.length-10240;n<r;)e+=String.fromCharCode.apply(null,t.subarray(n,n+=10240));return e+=String.fromCharCode.apply(null,n?t.subarray(n):t),btoa(e)}const T=/[-_.]/g,E={"-":"+",_:"/",".":"="};function I(t){return E[t]||""}function P(t){if(!S)return y(t);T.test(t)&&(t=t.replace(T,I)),t=atob(t);const e=new Uint8Array(t.length);for(let n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}function O(t){return w&&null!=t&&t instanceof Uint8Array}var L={};function U(){return B||=new x(null,L)}var x=class{constructor(t,e){if(k(e),this.i=t,null!=t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}};let B,N;function k(t){if(t!==L)throw Error("illegal external caller")}function j(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}function F(){const e=Error();j(e,"incident"),function(e){t.setTimeout((()=>{throw e}),0)}(e)}function D(t){return j(t=Error(t),"warning"),t}function V(){return"function"==typeof BigInt}function M(t){return Array.prototype.slice.call(t)}var C="function"==typeof Symbol&&"symbol"==typeof Symbol();function R(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol():t}var G=R(),z=R("2ex"),W=R("1oa"),H=C?(t,e)=>{t[G]|=e}:(t,e)=>{void 0!==t.s?t.s|=e:Object.defineProperties(t,{s:{value:e,configurable:!0,writable:!0,enumerable:!1}})},$=C?(t,e)=>{t[G]&=~e}:(t,e)=>{void 0!==t.s&&(t.s&=~e)},q=C?t=>0|t[G]:t=>0|t.s,K=C?t=>t[G]:t=>t.s,Y=C?(t,e)=>{t[G]=e}:(t,e)=>{void 0!==t.s?t.s=e:Object.defineProperties(t,{s:{value:e,configurable:!0,writable:!0,enumerable:!1}})};function J(t,e){Y(e,-30975&(0|t))}function X(t,e){Y(e,-30941&(34|t))}var Z,Q={},tt={};function et(t){return!(!t||"object"!=typeof t||t.i!==tt)}function nt(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)&&t.constructor===Object}function rt(t){return!(!Array.isArray(t)||t.length)&&!!(1&q(t))}const it=[];function ot(t){if(2&t)throw Error()}Y(it,55),Z=Object.freeze(it);var st=Object.freeze({});function at(t){return t.ba=!0,t}var ut=at((t=>"number"==typeof t)),ct=at((t=>"string"==typeof t)),lt=at((t=>"boolean"==typeof t)),ht="function"==typeof t.BigInt&&"bigint"==typeof t.BigInt(0),ft=at((t=>ht?t>=pt&&t<=mt:"-"===t[0]?_t(t,dt):_t(t,gt)));const dt=Number.MIN_SAFE_INTEGER.toString(),pt=ht?BigInt(Number.MIN_SAFE_INTEGER):void 0,gt=Number.MAX_SAFE_INTEGER.toString(),mt=ht?BigInt(Number.MAX_SAFE_INTEGER):void 0;function _t(t,e){if(t.length>e.length)return!1;if(t.length<e.length||t===e)return!0;for(let n=0;n<t.length;n++){const r=t[n],i=e[n];if(r>i)return!1;if(r<i)return!0}}let bt,yt=0,vt=0;function wt(t){const e=t>>>0;yt=e,vt=(t-e)/4294967296>>>0}function St(t){if(t<0){wt(-t);const[e,n]=Pt(yt,vt);yt=e>>>0,vt=n>>>0}else wt(t)}function At(t,e){const n=4294967296*e+(t>>>0);return Number.isSafeInteger(n)?n:Tt(t,e)}function Tt(t,e){if(t>>>=0,(e>>>=0)<=2097151)var n=""+(4294967296*e+t);else V()?n=""+(BigInt(e)<<BigInt(32)|BigInt(t)):(t=(16777215&t)+6777216*(n=16777215&(t>>>24|e<<8))+6710656*(e=e>>16&65535),n+=8147497*e,e*=2,t>=1e7&&(n+=t/1e7>>>0,t%=1e7),n>=1e7&&(e+=n/1e7>>>0,n%=1e7),n=e+Et(n)+Et(t));return n}function Et(t){return t=String(t),"0000000".slice(t.length)+t}function It(t){if(t.length<16)St(Number(t));else if(V())t=BigInt(t),yt=Number(t&BigInt(4294967295))>>>0,vt=Number(t>>BigInt(32)&BigInt(4294967295));else{const e=+("-"===t[0]);vt=yt=0;const n=t.length;for(let r=e,i=(n-e)%6+e;i<=n;r=i,i+=6){const e=Number(t.slice(r,i));vt*=1e6,yt=1e6*yt+e,yt>=4294967296&&(vt+=Math.trunc(yt/4294967296),vt>>>=0,yt>>>=0)}if(e){const[t,e]=Pt(yt,vt);yt=t,vt=e}}}function Pt(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}function Ot(t){if(null!=t&&"number"!=typeof t)throw Error(`Value of float/double field must be a number, found ${typeof t}: ${t}`);return t}function Lt(t){return null==t||"number"==typeof t?t:"NaN"===t||"Infinity"===t||"-Infinity"===t?Number(t):void 0}const Ut=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function xt(t){const e=typeof t;switch(e){case"bigint":return!0;case"number":return Number.isFinite(t)}return"string"===e&&Ut.test(t)}function Bt(t){if("number"!=typeof t)throw D("int32");if(!Number.isFinite(t))throw D("int32");return 0|t}function Nt(t){return null==t?t:Bt(t)}function kt(t){if(null==t)return t;if("string"==typeof t){if(!t)return;t=+t}return"number"==typeof t&&Number.isFinite(t)?0|t:void 0}function jt(t){if(null!=t){if("number"!=typeof t)throw D("uint32");if(!Number.isFinite(t))throw D("uint32");t>>>=0}return t}function Ft(t){if(null==t)return t;if("string"==typeof t){if(!t)return;t=+t}return"number"==typeof t&&Number.isFinite(t)?t>>>0:void 0}function Dt(t){return"-"!==t[0]&&(t.length<20||20===t.length&&Number(t.substring(0,6))<184467)}function Vt(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(BigInt.asUintN(64,t));if(xt(t)){if("string"===e)return e=Math.trunc(Number(t)),Number.isSafeInteger(e)&&e>=0?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),Dt(t)||(It(t),t=Tt(yt,vt))),t;if("number"===e)return(t=Math.trunc(t))>=0&&Number.isSafeInteger(t)?t:function(t){if(t<0){St(t);var e=Tt(yt,vt);return t=Number(e),Number.isSafeInteger(t)?t:e}return Dt(e=String(t))?e:(St(t),At(yt,vt))}(t)}}function Mt(t){return null==t||"string"==typeof t?t:void 0}function Ct(t,e,n){if(null!=t&&"object"==typeof t&&t.L===Q)return t;if(Array.isArray(t)){var r=q(t),i=r;return 0===i&&(i|=32&n),(i|=2&n)!==r&&Y(t,i),new e(t)}}function Rt(t){var e;return void 0===Wt&&(Wt="function"==typeof Proxy?Xt(Proxy):null),(e=!Wt)||(void 0===Ht&&(Ht="function"==typeof WeakMap?Xt(WeakMap):null),e=!Ht),e?t:(e=Gt?.get(t))?e:Math.random()>.01?t:(function(t){if(void 0===$t){const t=new Wt([],{});$t=1===Array.prototype.concat.call([],t).length}$t&&"function"==typeof Symbol&&Symbol.isConcatSpreadable&&(t[Symbol.isConcatSpreadable]=!0)}(t),function(t,e){(Gt||=new Ht).set(t,e),(zt||=new Ht).set(e,t)}(t,e=new Wt(t,{set:(t,e,n)=>(F(),t[e]=n,!0)})),e)}let Gt,zt,Wt,Ht,$t,qt,Kt,Yt,Jt;function Xt(t){try{return-1!==t.toString().indexOf("[native code]")?t:null}catch{return null}}function Zt(t,e,n){return t=Qt(t,e[0],e[1],n?1:2),e!==Kt&&n&&H(t,16384),t}function Qt(t,e,n,r){if(r=r??0,null==t&&(t=qt),qt=void 0,null==t){var i=96;n?(t=[n],i|=512):t=[],e&&(i=-33521665&i|(1023&e)<<15)}else{if(!Array.isArray(t))throw Error("narr");if(2048&(i=q(t)))throw Error("farr");if(64&i)return t;if(1===r||2===r||(i|=64),n&&(i|=512,n!==t[0]))throw Error("mid");t:{if(r=(n=t).length){const t=r-1;if(nt(n[t])){if((e=t-(+!!(512&(i|=256))-1))>=1024)throw Error("pvtlmt");i=-33521665&i|(1023&e)<<15;break t}}if(e){if((e=Math.max(e,r-(+!!(512&i)-1)))>1024)throw Error("spvt");i=-33521665&i|(1023&e)<<15}}}return Y(t,i),t}function te(t,e,n,r,i){if(null!=t){if(Array.isArray(t))t=rt(t)?void 0:i&&2&q(t)?t:ee(t,e,n,void 0!==r,i);else if(nt(t)){const o={};for(let s in t)o[s]=te(t[s],e,n,r,i);t=o}else t=e(t,r);return t}}function ee(t,e,n,r,i){const o=r||n?q(t):0;r=r?!!(32&o):void 0,t=M(t);for(let o=0;o<t.length;o++)t[o]=te(t[o],e,n,r,i);return n&&n(o,t),t}function ne(t){return t.L===Q?t.toJSON():function(t){switch(typeof t){case"number":return isFinite(t)?t:String(t);case"bigint":return ft(t)?Number(t):String(t);case"boolean":return t?1:0;case"object":if(t)if(Array.isArray(t)){if(rt(t))return}else{if(O(t))return A(t);if(t instanceof x){const e=t.i;return null==e?"":"string"==typeof e?e:t.i=A(e)}}}return t}(t)}function re(t,e,n=X){if(null!=t){if(w&&t instanceof Uint8Array)return e?t:new Uint8Array(t);if(Array.isArray(t)){var r=q(t);return 2&r?t:(e&&=0===r||!!(32&r)&&!(64&r||!(16&r)),e?(Y(t,-12293&(34|r)),t):ee(t,re,4&r?X:n,!0,!0))}return t.L===Q&&(n=t.m,t=2&(r=K(n))?t:ie(t,n,r,!0)),t}}function ie(t,e,n,r){return t=t.constructor,qt=e=function(t,e,n){const r=n||2&e?X:J,i=!!(32&e);return t=function(t,e,n){var r=(t=M(t)).length;const i=256&e?t[r-1]:void 0;for(r+=i?-1:0,e=512&e?1:0;e<r;e++)t[e]=n(t[e]);if(i){e=t[e]={};for(const t in i)e[t]=n(i[t])}return t}(t,e,(t=>re(t,i,r))),H(t,32|(n?2:0)),t}(e,n,r),e=new t(e),qt=void 0,e}function oe(t){const e=t.m,n=K(e);return 2&n?ie(t,e,n,!1):t}function se(t,e){return ue(t=t.m,K(t),e)}function ae(t,e,n,r){if(!((e=r+(+!!(512&e)-1))<0||e>=t.length||e>=n))return t[e]}function ue(t,e,n,r){if(-1===n)return null;const i=e>>15&1023||536870912;if(!(n>=i)){var o=t.length;return r&&256&e&&null!=(r=t[o-1][n])?(ae(t,e,i,n)&&null!=z&&((e=(t=N??={})[z]||0)>=4||(t[z]=e+1,F())),r):ae(t,e,i,n)}return 256&e?t[t.length-1][n]:void 0}function ce(t,e,n){const r=t.m;let i=K(r);return ot(i),le(r,i,e,n),t}function le(t,e,n,r){const i=e>>15&1023||536870912;if(n>=i){let o,s=e;if(256&e)o=t[t.length-1];else{if(null==r)return s;o=t[i+(+!!(512&e)-1)]={},s|=256}return o[n]=r,n<i&&(t[n+(+!!(512&e)-1)]=void 0),s!==e&&Y(t,s),s}return t[n+(+!!(512&e)-1)]=r,256&e&&(n in(t=t[t.length-1])&&delete t[n]),e}function he(t,e,n,r,i){const o=t.m,s=2&(t=K(o))?1:r;i=!!i,r=fe(o,t,e);var a=q(r);if(!(4&a)){4&a&&(r=M(r),a=we(a,t),t=le(o,t,e,r));let i=0,s=0;for(;i<r.length;i++){const t=n(r[i]);null!=t&&(r[s++]=t)}s<i&&(r.length=s),a=-4097&(20|(a=de(a,t))),Y(r,a&=-8193),2&a&&Object.freeze(r)}let u;return 1===s||4===s&&32&a?pe(a)||(i=a,(a|=2)!==i&&Y(r,a),Object.freeze(r)):(n=5===s&&(!!(32&a)||pe(a)||!!Gt?.get(r)),(2===s||n)&&pe(a)&&(r=M(r),a=Se(a=we(a,t),t,i),Y(r,a),t=le(o,t,e,r)),pe(a)||(e=a,(a=Se(a,t,i))!==e&&Y(r,a)),n?u=Rt(r):2!==s||i||Gt?.delete(r)),u||r}function fe(t,e,n){return t=ue(t,e,n),Array.isArray(t)?t:Z}function de(t,e){return 0===t&&(t=we(t,e)),1|t}function pe(t){return!!(2&t)&&!!(4&t)||!!(2048&t)}function ge(t,e,n){t=t.m;let r=K(t);if(ot(r),null==n)le(t,r,e);else{n=zt?.get(n)||n;var i=q(n),o=i,s=pe(i),a=s||Object.isFrozen(n);for(s||(i=0),a||(n=M(n),o=0,i=Se(i=we(i,r),r,!0),a=!1),i|=21,s=0;s<n.length;s++){const t=n[s],e=Bt(t);Object.is(t,e)||(a&&(n=M(n),o=0,i=Se(i=we(i,r),r,!0),a=!1),n[s]=e)}i!==o&&(a&&(n=M(n),i=Se(i=we(i,r),r,!0)),Y(n,i)),le(t,r,e,n)}}function me(t,e,n,r){t=t.m;let i=K(t);ot(i),le(t,i,e,("0"===r?0===Number(n):n===r)?void 0:n)}function _e(t){if(C)return t[W]??(t[W]=new Map);if(W in t)return t[W];const e=new Map;return Object.defineProperty(t,W,{value:e}),e}function be(t,e,n){var r=Hr;let i=t.get(r);if(null!=i)return i;i=0;for(let t=0;t<r.length;t++){const o=r[t];null!=ue(e,n,o)&&(0!==i&&(n=le(e,n,i)),i=o)}return t.set(r,i),i}function ye(t,e,n){var r=t.m,i=K(r),o=ue(r,i,n,!1);return(e=Ct(o,e,i))!==o&&null!=e&&le(r,i,n,e),null==(r=e)||(t=t.m,2&(i=K(t))||(o=oe(r))!==r&&le(t,i,n,r=o)),r}function ve(t,e,n){return null==n&&(n=void 0),ce(t,e,n)}function we(t,e){return-2049&(t=32|(2&e?2|t:-3&t))}function Se(t,e,n){return 32&e&&n||(t&=-33),t}function Ae(t,e,n,r){var i,o=K(t.m);ot(o);const s=t.m,a=(t=!!(2&o))?1:2;d&&=!t,t=fe(s,o,e);var u=q(t),c=!!(4&u);if(!c){var l=t,h=o,f=!!(2&(u=de(u,o)));f&&(h|=2);let e=!f,r=!0,i=0,s=0;for(;i<l.length;i++){const t=Ct(l[i],n,h);if(t instanceof n){if(!f){const n=!!(2&q(t.m));e&&=!n,r&&=n}l[s++]=t}}s<i&&(l.length=s),u|=4,u=r?16|u:-17&u,Y(l,u=e?8|u:-9&u),f&&Object.freeze(l)}if(d&&!(8&u||!t.length&&(1===a||4===a&&32&u))){pe(u)&&(t=M(t),u=we(u,o),o=le(s,o,e,t));var d=t;for(l=u,u=0;u<d.length;u++)(h=d[u])!==(f=oe(h))&&(d[u]=f);l|=8,l=d.length?-17&l:16|l,Y(d,l),u=l}1===a||4===a&&32&u?pe(u)||(e=u,(u|=!t.length||16&u&&(!c||32&u)?2:2048)!==e&&Y(t,u),Object.freeze(t)):(c=5===a&&(!!(32&u)||pe(u)||!!Gt?.get(t)),(2===a||c)&&pe(u)&&(t=M(t),u=Se(u=we(u,o),o,!0),Y(t,u),o=le(s,o,e,t)),pe(u)||(e=u,(u=Se(u,o,!0))!==e&&Y(t,u)),c&&(i=Rt(t))),i=i||t,r=null!=r?r:new n,i.push(r),2&q(r.m)?$(i,8):$(i,16)}function Te(t){return t??0}function Ee(t,e){return Te(Ft(se(t,e)))}function Ie(t,e,n){me(t,e,Nt(n),0)}function Pe(t,e,n){if(null!=n&&"string"!=typeof n)throw Error();me(t,e,n,"")}function Oe(t,e,n){if(ot(K(t.m)),e=(t=he(t,e,Mt,2,!0)).push,"string"!=typeof n)throw Error();e.call(t,n)}function Le(t){if("string"==typeof t)return{buffer:P(t),C:!1};if(Array.isArray(t))return{buffer:new Uint8Array(t),C:!1};if(t.constructor===Uint8Array)return{buffer:t,C:!1};if(t.constructor===ArrayBuffer)return{buffer:new Uint8Array(t),C:!1};if(t.constructor===x){k(L);var e=t.i;return{buffer:(null==(e=null==e||O(e)?e:"string"==typeof e?P(e):null)?e:t.i=e)||new Uint8Array(0),C:!0}}if(t instanceof Uint8Array)return{buffer:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),C:!1};throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers")}var Ue=class{constructor(t,e){this.m=Qt(t,e)}toJSON(){return xe(this)}C(){return!!(2&q(this.m))}};function xe(t){t=t.m,t=Jt?t:ee(t,ne,void 0,void 0,!1);{var e=!Jt;let c=t.length;if(c){var n=t[c-1],r=nt(n);r?c--:n=void 0;var i=t;if(r){t:{var o,s=n,a=!1;if(s)for(let t in s)isNaN(+t)?(o??={})[t]=s[t]:(r=s[t],Array.isArray(r)&&(rt(r)||et(r)&&0===r.size)&&(r=null),null==r&&(a=!0),null!=r&&((o??={})[t]=r));if(a||(o=s),o)for(let t in o){a=o;break t}a=null}s=null==a?null!=n:a!==n}for(;c>0&&(null==(o=i[c-1])||rt(o)||et(o)&&0===o.size);c--)var u=!0;(i!==t||s||u)&&(e?(u||s||a)&&(i.length=c):i=Array.prototype.slice.call(i,0,c),a&&i.push(a)),u=i}else u=t}return u}function Be(t){return t?/^\d+$/.test(t)?(It(t),new Ne(yt,vt)):null:ke||=new Ne(0,0)}Ue.prototype.L=Q,Ue.prototype.toString=function(){try{return Jt=!0,xe(this).toString()}finally{Jt=!1}};var Ne=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};let ke;function je(t){return t?/^-?\d+$/.test(t)?(It(t),new Fe(yt,vt)):null:De||=new Fe(0,0)}var Fe=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};let De;function Ve(t,e,n){for(;n>0||e>127;)t.i.push(127&e|128),e=(e>>>7|n<<25)>>>0,n>>>=7;t.i.push(e)}function Me(t,e){for(;e>127;)t.i.push(127&e|128),e>>>=7;t.i.push(e)}function Ce(t,e){if(e>=0)Me(t,e);else{for(let n=0;n<9;n++)t.i.push(127&e|128),e>>=7;t.i.push(1)}}function Re(t,e){0!==e.length&&(t.l.push(e),t.j+=e.length)}function Ge(t,e,n){Me(t.i,8*e+n)}function ze(t,e){return Ge(t,e,2),e=t.i.end(),Re(t,e),e.push(t.j),e}function We(t,e){var n=e.pop();for(n=t.j+t.i.length()-n;n>127;)e.push(127&n|128),n>>>=7,t.j++;e.push(n),t.j++}function He(t,e,n){Ge(t,e,2),Me(t.i,n.length),Re(t,t.i.end()),Re(t,n)}function $e(){const t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var qe=$e(),Ke=$e(),Ye=$e(),Je=$e(),Xe=$e(),Ze=$e(),Qe=class{constructor(t,e){this.i=t,t=qe,this.j=!!t&&e===t||!1}};function tn(t,e,n,r,i){null!=(e=un(e,r))&&(n=ze(t,n),i(e,t),We(t,n))}const en=new Qe(tn,qe),nn=new Qe(tn,qe);var rn=Symbol(),on=Symbol();let sn;function an(t){var e=cn,n=ln,r=t[rn];if(r)return r;(r={}).N=function(t){switch(typeof t){case"boolean":return Kt||=[0,void 0,!0];case"number":return t>0?void 0:0===t?Yt||=[0,void 0]:[-t,void 0];case"string":return[0,t];case"object":return t}}(t[0]);var i=t[1];let o=1;i&&i.constructor===Object&&(r.S=i,"function"==typeof(i=t[++o])&&(r.W=!0,sn??=t[o+1],i=t[o+=2]));const s={};for(;i&&Array.isArray(i)&&i.length&&"number"==typeof i[0]&&i[0]>0;){for(var a=0;a<i.length;a++)s[i[a]]=i;i=t[++o]}for(a=1;void 0!==i;){let s;"number"==typeof i&&(a+=i,i=t[++o]);var u=void 0;if(i instanceof Qe?s=i:(s=en,o--),s?.j){i=t[++o],u=t;var c=o;"function"==typeof i&&(i=i(),u[c]=i),u=i}for(c=a+1,"number"==typeof(i=t[++o])&&i<0&&(c-=i,i=t[++o]);a<c;a++)u?n(r,a,s,u):e(r,a,s)}return t[rn]=r}function un(t,e){return t instanceof Ue?t.m:Array.isArray(t)?Zt(t,e,!1):void 0}function cn(t,e,n){t[e]=n.i}function ln(t,e,n,r){let i,o;const s=n.i;t[e]=(t,e,n)=>s(t,e,n,o||=an(r).N,i||=hn(r))}function hn(t){let e=t[on];if(!e){const n=an(t);e=(t,e)=>fn(t,e,n),t[on]=e}return e}function fn(t,e,n){var r=q(t),i=+!!(512&r)-1,o=t.length,s=512&r?1:0;const a=o+(256&r?-1:0);for(;s<a;s++){const r=t[s];if(null==r)continue;const o=s-i,a=dn(n,o);a&&a(e,r,o)}if(256&r){t=t[o-1];for(const s in t)r=+s,Number.isNaN(r)||null!=(i=t[r])&&(o=dn(n,r))&&o(e,i,r)}}function dn(t,e){var n=t[e];if(n)return n;if((n=t.S)&&(n=n[e])){var r=(n=Array.isArray(n)?n[0]instanceof Qe?n:[nn,n]:[n,void 0])[0].i;if(n=n[1]){const e=hn(n),i=an(n).N;n=t.W?sn(i,e):(t,n,o)=>r(t,n,o,i,e)}else n=r;return t[e]=n}}var pn,gn=0,mn=gn;if(ct(mn)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(mn))throw Error(String(mn))}else if((pn=ut(mn))&&(pn=!Number.isSafeInteger(mn)),pn)throw Error(String(mn));function _n(t,e){if(Array.isArray(e)){var n=q(e);if(4&n)return e;for(var r=0,i=0;r<e.length;r++){const n=t(e[r]);null!=n&&(e[i++]=n)}return i<r&&(e.length=i),Y(e,-12289&(5|n)),2&n&&Object.freeze(e),e}}function bn(t,e){return new Qe(t,e)}function yn(t,e,n){null!=(e=Lt(e))&&(Ge(t,n,5),t=t.i,(n=bt||=new DataView(new ArrayBuffer(8))).setFloat32(0,+e,!0),vt=0,e=yt=n.getUint32(0,!0),t.i.push(e>>>0&255),t.i.push(e>>>8&255),t.i.push(e>>>16&255),t.i.push(e>>>24&255))}function vn(t,e,n){null!=(e=kt(e))&&null!=e&&(Ge(t,n,0),Ce(t.i,e))}function wn(t,e,n){null!=(e=null==e||"boolean"==typeof e?e:"number"==typeof e?!!e:void 0)&&(Ge(t,n,0),t.i.i.push(e?1:0))}function Sn(t,e,n){null!=(e=Mt(e))&&He(t,n,r(e))}function An(t,e,n,r,i){null!=(e=un(e,r))&&(n=ze(t,n),i(e,t),We(t,n))}function Tn(t,e,n){null!=(e=kt(e))&&(e=parseInt(e,10),Ge(t,n,0),Ce(t.i,e))}ht||(gn=lt(gn)?gn?"1":"0":ct(gn)?gn.trim()||"0":String(gn));var En,In=bn(yn,Xe),Pn=bn(yn,Xe),On=bn((function(t,e,n){if(e=function(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(BigInt.asIntN(64,t));if(xt(t)){if("string"===e){if(e=Math.trunc(Number(t)),Number.isSafeInteger(e))t=String(e);else if(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),!("-"===t[0]?t.length<20||20===t.length&&Number(t.substring(0,7))>-922337:t.length<19||19===t.length&&Number(t.substring(0,6))<922337))if(It(t),t=yt,2147483648&(e=vt))if(V())t=""+(BigInt(0|e)<<BigInt(32)|BigInt(t>>>0));else{const[n,r]=Pt(t,e);t="-"+Tt(n,r)}else t=Tt(t,e);return t}if("number"===e){if(t=Math.trunc(t),!Number.isSafeInteger(t)){St(t),e=yt;var n=vt;(t=2147483648&n)&&(n=~n>>>0,0==(e=1+~e>>>0)&&(n=n+1>>>0)),t="number"==typeof(e=At(e,n))?t?-e:e:t?"-"+e:e}return t}}}(e),null!=e){if("string"==typeof e)je(e);if(null!=e)switch(Ge(t,n,0),typeof e){case"number":t=t.i,St(e),Ve(t,yt,vt);break;case"bigint":n=BigInt.asUintN(64,e),n=new Fe(Number(n&BigInt(4294967295)),Number(n>>BigInt(32))),Ve(t.i,n.j,n.i);break;default:n=je(e),Ve(t.i,n.j,n.i)}}}),$e()),Ln=bn((function(t,e,n){if(null!=(e=Vt(e))){if("string"==typeof e)Be(e);if(null!=e)switch(Ge(t,n,0),typeof e){case"number":t=t.i,St(e),Ve(t,yt,vt);break;case"bigint":n=BigInt.asUintN(64,e),n=new Ne(Number(n&BigInt(4294967295)),Number(n>>BigInt(32))),Ve(t.i,n.j,n.i);break;default:n=Be(e),Ve(t.i,n.j,n.i)}}}),$e()),Un=bn(vn,Je);En=new Qe((function(t,e,n){if(null!=(e=_n(kt,e))&&e.length){n=ze(t,n);for(let n=0;n<e.length;n++)Ce(t.i,e[n]);We(t,n)}}),Je);var xn,Bn=bn(vn,Je),Nn=bn(vn,Je),kn=bn(wn,Ke),jn=bn(wn,Ke),Fn=bn(Sn,Ye);xn=new Qe((function(t,e,n){if(null!=(e=_n(Mt,e)))for(let a=0;a<e.length;a++){var i=t,o=n,s=e[a];null!=s&&He(i,o,r(s))}}),Ye);var Dn,Vn=bn(Sn,Ye),Mn=bn(Sn,Ye),Cn=function(t,e,n=qe){return new Qe(e,n)}(0,(function(t,e,n,r,i){if(Array.isArray(e))for(let o=0;o<e.length;o++)An(t,e[o],n,r,i)})),Rn=new Qe(An,qe),Gn=bn((function(t,e,n){null!=(e=Ft(e))&&null!=e&&(Ge(t,n,0),Me(t.i,e))}),$e()),zn=bn(Tn,Ze);Dn=new Qe((function(t,e,n){if(null!=(e=_n(kt,e))&&e.length){n=ze(t,n);for(let n=0;n<e.length;n++)Ce(t.i,e[n]);We(t,n)}}),Ze);var Wn=bn(Tn,Ze);function Hn(t){return function(){const e=new class{constructor(){this.l=[],this.j=0,this.i=new class{constructor(){this.i=[]}length(){return this.i.length}end(){const t=this.i;return this.i=[],t}}}};fn(this.m,e,an(t)),Re(e,e.i.end());const n=new Uint8Array(e.j),r=e.l,i=r.length;let o=0;for(let t=0;t<i;t++){const e=r[t];n.set(e,o),o+=e.length}return e.l=[n],n}}function $n(t,e){if(null!=e)if(Array.isArray(e))ce(t,2,ee(e,ne,void 0,void 0,!1));else{if(!("string"==typeof e||e instanceof x||O(e)))throw Error("invalid value in Any.value field: "+e+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");if(null!=e)if("string"==typeof e)e=e?new x(e,L):U();else if(e.constructor!==x){if(!O(e))throw Error();e=e.length?new x(new Uint8Array(e),L):U()}me(t,2,e,U())}}var qn=class extends Ue{constructor(t){super(t)}},Kn=[0,Vn,bn((function(t,e,n){if(null!=e){if(e instanceof Ue){const r=e.ca;return void(r&&(e=r(e),null!=e&&He(t,n,Le(e).buffer)))}if(Array.isArray(e))return}null!=(e=null==e||"string"==typeof e||O(e)||e instanceof x?e:void 0)&&He(t,n,Le(e).buffer)}),$e())];let Yn,Jn=globalThis.trustedTypes;function Xn(t){void 0===Yn&&(Yn=function(){let t=null;if(!Jn)return t;try{const e=t=>t;t=Jn.createPolicy("goog#html",{createHTML:e,createScript:e,createScriptURL:e})}catch(t){}return t}());var e=Yn;return new class{constructor(t){this.i=t}toString(){return this.i+""}}(e?e.createScriptURL(t):t)}function Zn(t,...e){if(0===e.length)return Xn(t[0]);let n=t[0];for(let r=0;r<e.length;r++)n+=encodeURIComponent(e[r])+t[r+1];return Xn(n)}var Qn={};Qn[336783863]=[0,Fn,kn,-1,Un,[0,[1,2,3,4,5,6,7],Rn,[0],Rn,[0,kn,Fn,kn,zn,-1,Dn,Fn,-1,[0,kn,-1],zn,kn,-1],Rn,[0,Fn,-2],Rn,[0,Un,kn,1,kn,-3],Rn,[0,Un,zn,kn,-1,En,zn,-1],Rn,[0,Fn,-2],Rn,[0,Fn,zn]],[0,Fn],kn,[0,[1,3],[2,4],Rn,[0,En],-1,Rn,[0,xn],-1,Cn,[0,Fn,-1]],Fn];var tr=class extends Ue{constructor(t){super(t)}},er=[0,On,-1,jn,-3,On,En,Vn,Bn,On,-1,jn,Bn,jn,-2,Vn],nr=class extends Ue{constructor(t){super(t,500)}K(t){return ve(this,7,t)}},rr=[-1,{}],ir=[0,Fn,1,rr],or=[0,Fn,xn,rr];function sr(t,e){Ae(t,1,nr,e)}var ar=class extends Ue{constructor(){super(void 0,500)}K(t){return ve(this,1001,t)}};ar.prototype.i=Hn([-500,Cn,[-500,Vn,-1,xn,-3,[-2,Qn,kn],Cn,Kn,Bn,-1,ir,or,Cn,[0,Vn,jn],Vn,er,Bn,xn,987,xn],4,Cn,[-500,Fn,-1,[-1,{}],998,Fn],Cn,[-500,Fn,xn,-1,[-2,{},kn],997,xn,-1],Bn,Cn,[-500,Fn,xn,rr,998,xn],xn,Bn,ir,or,Cn,[0,Vn,-1,rr],xn,-2,er,Vn,-1,jn,[0,jn,Gn],978,rr,Cn,Kn]);var ur=class extends Ue{constructor(t){super(t)}};let cr;const lr=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);async function hr(){if(void 0===cr)try{await WebAssembly.instantiate(lr),cr=!0}catch{cr=!1}return cr}async function fr(t,e=Zn``){const n=await hr()?"wasm_internal":"wasm_nosimd_internal";return{wasmLoaderPath:`${e}/${t}_${n}.js`,wasmBinaryPath:`${e}/${t}_${n}.wasm`}}var dr=class{};function pr(){var t=navigator;return"undefined"!=typeof OffscreenCanvas&&(!function(t=navigator){return(t=t.userAgent).includes("Safari")&&!t.includes("Chrome")}(t)||!!((t=t.userAgent.match(/Version\/([\d]+).*Safari/))&&t.length>=1&&Number(t[1])>=17))}async function gr(t){if("function"!=typeof importScripts){const e=document.createElement("script");return e.src=t.toString(),e.crossOrigin="anonymous",new Promise(((t,n)=>{e.addEventListener("load",(()=>{t()}),!1),e.addEventListener("error",(t=>{n(t)}),!1),document.body.appendChild(e)}))}importScripts(t.toString())}dr.forVisionTasks=function(t){return fr("vision",t)},dr.forTextTasks=function(t){return fr("text",t)},dr.forGenAiExperimentalTasks=function(t){return fr("genai_experimental",t)},dr.forGenAiTasks=function(t){return fr("genai",t)},dr.forAudioTasks=function(t){return fr("audio",t)},dr.isSimdSupported=function(){return hr()};function mr(t,e,n){t.o||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),n(e=t.h.stringToNewUTF8(e)),t.h._free(e)}function _r(t,e,n){t.o||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");const r=new Uint32Array(e.length);for(let n=0;n<e.length;n++)r[n]=t.h.stringToNewUTF8(e[n]);e=t.h._malloc(4*r.length),t.h.HEAPU32.set(r,e>>2),n(e);for(const e of r)t.h._free(e);t.h._free(e)}function br(t,e,n){t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=n}function yr(t,e,n){let r=[];t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=(t,e,i)=>{e?(n(r,i),r=[]):r.push(t)}}const vr=(wr=class{constructor(t,e){this.l=!0,this.h=t,this.i=null,this.j=0,this.o="function"==typeof this.h._addIntToInputStream,void 0!==e?this.h.canvas=e:pr()?this.h.canvas=new OffscreenCanvas(1,1):(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.h.canvas=document.createElement("canvas"))}async initializeGraph(t){const e=await(await fetch(t)).arrayBuffer();t=!(t.endsWith(".pbtxt")||t.endsWith(".textproto")),this.setGraph(new Uint8Array(e),t)}setGraphFromString(t){this.setGraph((new TextEncoder).encode(t),!1)}setGraph(t,e){const n=t.length,r=this.h._malloc(n);this.h.HEAPU8.set(t,r),e?this.h._changeBinaryGraph(n,r):this.h._changeTextGraph(n,r),this.h._free(r)}configureAudio(t,e,n,r,i){this.h._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),mr(this,r||"input_audio",(r=>{mr(this,i=i||"audio_header",(i=>{this.h._configureAudio(r,i,t,e??0,n)}))}))}setAutoResizeCanvas(t){this.l=t}setAutoRenderToScreen(t){this.h._setAutoRenderToScreen(t)}setGpuBufferVerticalFlip(t){this.h.gpuOriginForWebTexturesIsBottomLeft=t}attachErrorListener(t){this.h.errorListener=t}attachEmptyPacketListener(t,e){this.h.emptyPacketListeners=this.h.emptyPacketListeners||{},this.h.emptyPacketListeners[t]=e}addAudioToStream(t,e,n){this.addAudioToStreamWithShape(t,0,0,e,n)}addAudioToStreamWithShape(t,e,n,r,i){const o=4*t.length;this.j!==o&&(this.i&&this.h._free(this.i),this.i=this.h._malloc(o),this.j=o),this.h.HEAPF32.set(t,this.i/4),mr(this,r,(t=>{this.h._addAudioToInputStream(this.i,e,n,t,i)}))}addGpuBufferToStream(t,e,n){mr(this,e,(e=>{if(!this.h.canvas)throw Error("No OpenGL canvas configured.");e?this.h._bindTextureToStream(e):this.h._bindTextureToCanvas();const r=this.h.canvas.getContext("webgl2")||this.h.canvas.getContext("webgl");if(!r)throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");this.h.gpuOriginForWebTexturesIsBottomLeft&&r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!0),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t),this.h.gpuOriginForWebTexturesIsBottomLeft&&r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1);const[i,o]=void 0!==t.videoWidth?[t.videoWidth,t.videoHeight]:void 0!==t.naturalWidth?[t.naturalWidth,t.naturalHeight]:void 0!==t.displayWidth?[t.displayWidth,t.displayHeight]:[t.width,t.height];!this.l||i===this.h.canvas.width&&o===this.h.canvas.height||(this.h.canvas.width=i,this.h.canvas.height=o);const[s,a]=[i,o];this.h._addBoundTextureToStream(e,s,a,n)}))}addBoolToStream(t,e,n){mr(this,e,(e=>{this.h._addBoolToInputStream(t,e,n)}))}addDoubleToStream(t,e,n){mr(this,e,(e=>{this.h._addDoubleToInputStream(t,e,n)}))}addFloatToStream(t,e,n){mr(this,e,(e=>{this.h._addFloatToInputStream(t,e,n)}))}addIntToStream(t,e,n){mr(this,e,(e=>{this.h._addIntToInputStream(t,e,n)}))}addUintToStream(t,e,n){mr(this,e,(e=>{this.h._addUintToInputStream(t,e,n)}))}addStringToStream(t,e,n){mr(this,e,(e=>{mr(this,t,(t=>{this.h._addStringToInputStream(t,e,n)}))}))}addStringRecordToStream(t,e,n){mr(this,e,(e=>{_r(this,Object.keys(t),(r=>{_r(this,Object.values(t),(i=>{this.h._addFlatHashMapToInputStream(r,i,Object.keys(t).length,e,n)}))}))}))}addProtoToStream(t,e,n,r){mr(this,n,(n=>{mr(this,e,(e=>{const i=this.h._malloc(t.length);this.h.HEAPU8.set(t,i),this.h._addProtoToInputStream(i,t.length,e,n,r),this.h._free(i)}))}))}addEmptyPacketToStream(t,e){mr(this,t,(t=>{this.h._addEmptyPacketToInputStream(t,e)}))}addBoolVectorToStream(t,e,n){mr(this,e,(e=>{const r=this.h._allocateBoolVector(t.length);if(!r)throw Error("Unable to allocate new bool vector on heap.");for(const e of t)this.h._addBoolVectorEntry(r,e);this.h._addBoolVectorToInputStream(r,e,n)}))}addDoubleVectorToStream(t,e,n){mr(this,e,(e=>{const r=this.h._allocateDoubleVector(t.length);if(!r)throw Error("Unable to allocate new double vector on heap.");for(const e of t)this.h._addDoubleVectorEntry(r,e);this.h._addDoubleVectorToInputStream(r,e,n)}))}addFloatVectorToStream(t,e,n){mr(this,e,(e=>{const r=this.h._allocateFloatVector(t.length);if(!r)throw Error("Unable to allocate new float vector on heap.");for(const e of t)this.h._addFloatVectorEntry(r,e);this.h._addFloatVectorToInputStream(r,e,n)}))}addIntVectorToStream(t,e,n){mr(this,e,(e=>{const r=this.h._allocateIntVector(t.length);if(!r)throw Error("Unable to allocate new int vector on heap.");for(const e of t)this.h._addIntVectorEntry(r,e);this.h._addIntVectorToInputStream(r,e,n)}))}addUintVectorToStream(t,e,n){mr(this,e,(e=>{const r=this.h._allocateUintVector(t.length);if(!r)throw Error("Unable to allocate new unsigned int vector on heap.");for(const e of t)this.h._addUintVectorEntry(r,e);this.h._addUintVectorToInputStream(r,e,n)}))}addStringVectorToStream(t,e,n){mr(this,e,(e=>{const r=this.h._allocateStringVector(t.length);if(!r)throw Error("Unable to allocate new string vector on heap.");for(const e of t)mr(this,e,(t=>{this.h._addStringVectorEntry(r,t)}));this.h._addStringVectorToInputStream(r,e,n)}))}addBoolToInputSidePacket(t,e){mr(this,e,(e=>{this.h._addBoolToInputSidePacket(t,e)}))}addDoubleToInputSidePacket(t,e){mr(this,e,(e=>{this.h._addDoubleToInputSidePacket(t,e)}))}addFloatToInputSidePacket(t,e){mr(this,e,(e=>{this.h._addFloatToInputSidePacket(t,e)}))}addIntToInputSidePacket(t,e){mr(this,e,(e=>{this.h._addIntToInputSidePacket(t,e)}))}addUintToInputSidePacket(t,e){mr(this,e,(e=>{this.h._addUintToInputSidePacket(t,e)}))}addStringToInputSidePacket(t,e){mr(this,e,(e=>{mr(this,t,(t=>{this.h._addStringToInputSidePacket(t,e)}))}))}addProtoToInputSidePacket(t,e,n){mr(this,n,(n=>{mr(this,e,(e=>{const r=this.h._malloc(t.length);this.h.HEAPU8.set(t,r),this.h._addProtoToInputSidePacket(r,t.length,e,n),this.h._free(r)}))}))}addBoolVectorToInputSidePacket(t,e){mr(this,e,(e=>{const n=this.h._allocateBoolVector(t.length);if(!n)throw Error("Unable to allocate new bool vector on heap.");for(const e of t)this.h._addBoolVectorEntry(n,e);this.h._addBoolVectorToInputSidePacket(n,e)}))}addDoubleVectorToInputSidePacket(t,e){mr(this,e,(e=>{const n=this.h._allocateDoubleVector(t.length);if(!n)throw Error("Unable to allocate new double vector on heap.");for(const e of t)this.h._addDoubleVectorEntry(n,e);this.h._addDoubleVectorToInputSidePacket(n,e)}))}addFloatVectorToInputSidePacket(t,e){mr(this,e,(e=>{const n=this.h._allocateFloatVector(t.length);if(!n)throw Error("Unable to allocate new float vector on heap.");for(const e of t)this.h._addFloatVectorEntry(n,e);this.h._addFloatVectorToInputSidePacket(n,e)}))}addIntVectorToInputSidePacket(t,e){mr(this,e,(e=>{const n=this.h._allocateIntVector(t.length);if(!n)throw Error("Unable to allocate new int vector on heap.");for(const e of t)this.h._addIntVectorEntry(n,e);this.h._addIntVectorToInputSidePacket(n,e)}))}addUintVectorToInputSidePacket(t,e){mr(this,e,(e=>{const n=this.h._allocateUintVector(t.length);if(!n)throw Error("Unable to allocate new unsigned int vector on heap.");for(const e of t)this.h._addUintVectorEntry(n,e);this.h._addUintVectorToInputSidePacket(n,e)}))}addStringVectorToInputSidePacket(t,e){mr(this,e,(e=>{const n=this.h._allocateStringVector(t.length);if(!n)throw Error("Unable to allocate new string vector on heap.");for(const e of t)mr(this,e,(t=>{this.h._addStringVectorEntry(n,t)}));this.h._addStringVectorToInputSidePacket(n,e)}))}attachBoolListener(t,e){br(this,t,e),mr(this,t,(t=>{this.h._attachBoolListener(t)}))}attachBoolVectorListener(t,e){yr(this,t,e),mr(this,t,(t=>{this.h._attachBoolVectorListener(t)}))}attachIntListener(t,e){br(this,t,e),mr(this,t,(t=>{this.h._attachIntListener(t)}))}attachIntVectorListener(t,e){yr(this,t,e),mr(this,t,(t=>{this.h._attachIntVectorListener(t)}))}attachUintListener(t,e){br(this,t,e),mr(this,t,(t=>{this.h._attachUintListener(t)}))}attachUintVectorListener(t,e){yr(this,t,e),mr(this,t,(t=>{this.h._attachUintVectorListener(t)}))}attachDoubleListener(t,e){br(this,t,e),mr(this,t,(t=>{this.h._attachDoubleListener(t)}))}attachDoubleVectorListener(t,e){yr(this,t,e),mr(this,t,(t=>{this.h._attachDoubleVectorListener(t)}))}attachFloatListener(t,e){br(this,t,e),mr(this,t,(t=>{this.h._attachFloatListener(t)}))}attachFloatVectorListener(t,e){yr(this,t,e),mr(this,t,(t=>{this.h._attachFloatVectorListener(t)}))}attachStringListener(t,e){br(this,t,e),mr(this,t,(t=>{this.h._attachStringListener(t)}))}attachStringVectorListener(t,e){yr(this,t,e),mr(this,t,(t=>{this.h._attachStringVectorListener(t)}))}attachProtoListener(t,e,n){br(this,t,e),mr(this,t,(t=>{this.h._attachProtoListener(t,n||!1)}))}attachProtoVectorListener(t,e,n){yr(this,t,e),mr(this,t,(t=>{this.h._attachProtoVectorListener(t,n||!1)}))}attachAudioListener(t,e,n){this.h._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),br(this,t,((t,n)=>{t=new Float32Array(t.buffer,t.byteOffset,t.length/4),e(t,n)})),mr(this,t,(t=>{this.h._attachAudioListener(t,n||!1)}))}finishProcessing(){this.h._waitUntilIdle()}closeGraph(){this.h._closeGraph(),this.h.simpleListeners=void 0,this.h.emptyPacketListeners=void 0}},class extends wr{Y(){this.h._registerModelResourcesGraphService()}});var wr;async function Sr(t,e){const n=await(async(t,e,n)=>{var r=ni;if(t&&await gr(t),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(e&&(await gr(e),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&n&&((t=self.Module).locateFile=n.locateFile,n.mainScriptUrlOrBlob&&(t.mainScriptUrlOrBlob=n.mainScriptUrlOrBlob)),n=await self.ModuleFactory(self.Module||n),self.ModuleFactory=self.Module=void 0,new r(n,null)})(t.wasmLoaderPath,t.assetLoaderPath,{locateFile:e=>e.endsWith(".wasm")?t.wasmBinaryPath.toString():t.assetBinaryPath&&e.endsWith(".data")?t.assetBinaryPath.toString():e});return await n.K(e),n}async function Ar(t,e){return Sr(t,e)}function Tr(t){try{const e=t.H.length;if(1===e)throw Error(t.H[0].message);if(e>1)throw Error("Encountered multiple errors: "+t.H.map((t=>t.message)).join(", "))}finally{t.H=[]}}function Er(t,e){t.G=Math.max(t.G,e)}var Ir=class{constructor(t){this.i=t,this.H=[],this.G=0,this.i.setAutoRenderToScreen(!1)}setGraph(t,e){this.i.attachErrorListener(((t,e)=>{this.H.push(Error(e))})),this.i.Y(),this.i.setGraph(t,e),Tr(this)}finishProcessing(){this.i.finishProcessing(),Tr(this)}close(){this.i.closeGraph()}};Ir.prototype.close=Ir.prototype.close;var Pr=class extends Ue{constructor(t){super(t)}};function Or(t,e){ve(t,1,e)}var Lr=class extends Ue{constructor(){super()}},Ur=[0,Wn,Bn,Pn,-1,Un];function xr(t,e,n,r){if(void 0!==t.data){var i=new Uint8Array(t.data.buffer,e,n);return 1===r&&function(t,e,n){t.i.push([e,n]),t.i.sort(((t,e)=>t[0]-e[0])),e=0;for(const[r,i]of t.i){const t=i;(n=r)<=e&&(e=Math.max(e,n+t))}e===t.length&&(t.data=void 0)}(t,e,n),i}}class Br{constructor(t){this.i=[],this.data=t,this.length=t.length}}var Nr=class{constructor(t,e,n){this.i=t,this.j=e,this.l=n}get size(){let t=0;for(let e=0;e<this.i.length;e++)t+=this.i[e].length;return t}};function kr(t){if(t.i)try{t.h._free(t.j)}catch{}finally{t.i=!1}}var jr=class{constructor(t,e){this.h=t,this.l=e,this.j=this.h._malloc(e)>>>0,this.o=this.h.HEAPU8,this.i=!!this.j}get offset(){if(!this.i)throw Error("WasmFileReference has been freed.");return this.j}get size(){if(!this.i)throw Error("WasmFileReference has been freed.");return this.l}set(t,e){this.o.set(t,this.j+(e??0))}},Fr=class extends Ue{constructor(){super()}};Fr.prototype.i=Hn([0,Vn,2,xn,Bn,jn]);var Dr=class extends Ue{constructor(){super()}},Vr=class extends Ue{constructor(){super()}},Mr=class extends Ue{constructor(){super()}},Cr=class extends Ue{constructor(){super()}},Rr=[0,Bn,-6,1,Bn,1,[0,jn,Wn,-2],[0,jn,Pn],Wn,-2,[0,jn,-1,Wn,Pn,zn,Un],1,jn,Bn,Un,-1,[0,Wn,Bn],jn,-1,In,Bn,-1],Gr=[0,[4,6],Rr,Bn,1,Nn,xn,Mn,Dn,[0,Vn,-2],Un,[0,[0,Bn,-1,Cn,[0,Bn,[0,Bn,-1],-1,[0,Wn,-1],jn],jn,-2,Bn,-1],[0,Bn,-1,jn],Rr,jn,Bn],Fn,-3,[0,Bn,jn],Rr];Cr.prototype.i=Hn([0,Vn,8,[0,jn,-6],1,Bn,1,Bn,[0,Cn,[0,Vn,Ln,-1,Wn],Gr,Bn],[0,Bn,jn,-3],1,Wn,1,Gr,1,Bn,5,Wn,En,1,Ur]);var zr=class extends Ue{constructor(){super()}},Wr=class extends Ue{constructor(){super()}},Hr=[2,4];Wr.prototype.i=Hn([0,Hr,Bn,Mn,Bn,Rn,[0,1,Vn]]);const $r=function(t){return class e extends t{static async Z(t,n){let r;n||=await e.O();const i=[];for(const e of t?.requiredFeatures??[])n.features.has(e)?i.push(e):console.warn(`WebGPU feature ${e} is not supported.`);t={...t,requiredFeatures:i};try{r=await n.requestDevice(t)}catch(t){throw console.error("Unable to initialize WebGPU with the requested features."),t}return(t=r).adapterInfo||(t.adapterInfo=n.info),r}static async O(t){if(!(t=await navigator.gpu.requestAdapter(t)))throw Error("Unable to request adapter from navigator.gpu; Ensure WebGPU is enabled.");return t}V(t){if(e)"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.id="canvas_webgpu");else var e=new OffscreenCanvas(1,1);e.getContext("webgpu").configure({device:t,format:navigator.gpu.getPreferredCanvasFormat()}),this.h.preinitializedWebGPUDevice=t}R(){return this.h.ccall("closeGraph","void",[],[],{async:!0})}}}(function(t){return class extends t{addStreamingReaderToInputSidePacket(t,e){this.h.addStreamingReaderToInputSidePacket(((e,n,r)=>async function(t,e,n,r,i){if(2===i)return t.i=[],t.j=()=>Promise.resolve(void 0),setTimeout((()=>{t.l()}),0),Promise.resolve(0);for(;t.size<n+r;){var o=await t.j();if(void 0===o)break;t.i.push(new Br(o))}if(t.size<n+r)throw Error(`Data size is too small: ${t.size}, expected at least ${n+r}.`);o=e._malloc(r)>>>0;let s=0;for(let a=0;a<t.i.length;a++){const u=t.i[a];if(n>=u.length){n-=u.length;continue}const c=Math.min(r,u.length-n);if(void 0===(n=xr(u,n,c,i)))throw Error("Data has already been released.");if(e.HEAPU8.set(n,o+s),n=0,s+=c,0==(r-=c))break}if(0!==r)throw Error("Data not found.");return Promise.resolve(o)}(t,this.h,e,n,r)),e)}}}(function(t){return class extends t{P(t,e){mr(this,"lora_model_ref_in",(n=>{this.h._addRawDataSpanToInputStream(t.offset,t.size,n,e)}))}}}(class extends vr{})));class qr extends $r{}var Kr=class{constructor(t){this.j=t,this.i=Yr,Yr++}},Yr=0;class Jr{constructor(){let t,e;this.promise=new Promise(((n,r)=>{t=n,e=r})),this.resolve=t,this.reject=e}}function Xr(t){return 1===t?1:t+t%2}async function Zr(){const t=await qr.O({powerPreference:"high-performance"});var e=t.limits.maxBufferSize;if(t.limits.maxStorageBufferBindingSize<524550144)throw Error(`The WebGPU device is unable to execute LLM tasks, because the required maxStorageBufferBindingSize is at least 524550144 but your device only supports maxStorageBufferBindingSize of ${e}`);if(e>=786825216)e=786825216;else{if(!(e>=524550144))throw Error(`The WebGPU device is unable to execute LLM tasks, because the required maxBufferSize is at least 524550144 but your device only supports maxBufferSize of ${e}`);e=524550144}if(e={requiredFeatures:["shader-f16"],requiredLimits:{maxStorageBufferBindingSize:524550144,maxBufferSize:e,maxStorageBuffersPerShaderStage:t.limits.maxStorageBuffersPerShaderStage}},t.features.has("subgroups")){console.warn("Experimental Chromium WGSL subgroup support detected. Enabling this feature in the inference engine.");const n=["shader-f16","subgroups"];t.features.has("subgroups-f16")&&n.push("subgroups-f16"),e.requiredFeatures=n}return qr.Z(e,t)}function Qr(t){const e=function(t){const e=new ar;Oe(e,10,"text_in"),Oe(e,10,"token_cost_in"),Oe(e,10,"lora_model_id_to_apply_in"),Oe(e,10,"lora_model_ref_in"),Oe(e,10,"lora_model_id_to_load_in"),Oe(e,16,"streaming_reader"),Oe(e,15,"text_out"),Oe(e,15,"text_end"),Oe(e,15,"token_cost_out");var n=new nr;Pe(n,2,"TokenizerInputBuildCalculator"),Oe(n,3,"PROMPT:text_in"),Oe(n,3,"LORA_ID:lora_model_id_to_apply_in"),Oe(n,4,"prompt"),sr(e,n),Pe(n=new nr,2,"ModelDataCalculator"),Oe(n,6,"MODEL_DATA:__side_packet_1"),Oe(n,6,"MODEL_TYPE:model_type"),Oe(n,5,"READ_DATA_FN:streaming_reader"),Oe(n,3,"LORA_MODEL_SPAN:lora_model_ref_in"),Oe(n,3,"LORA_MODEL_ID:lora_model_id_to_load_in"),Oe(n,4,"LORA_DATA:lora_model_data"),sr(e,n),Pe(n=new nr,2,"Gpt2UnicodeMappingCalculator"),Oe(n,5,"MODEL_TYPE:model_type"),Oe(n,6,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),sr(e,n),Pe(n=new qn,1,"type.googleapis.com/odml.infra.proto.TokenizerCalculatorOptions");var r=new Wr,i=Ee(t.j,2);Ie(r,1,i),Pe(i=new zr,2,"spm_vocab_model"),null==i&&(i=void 0);t:{var o=r.m,s=K(o);if(ot(s),null==i){var a=_e(o);if(4!==be(a,o,s))break t;a.set(Hr,0)}else{const t=_e(a=o),e=be(t,a,s);4!==e&&(e&&(s=le(a,s,e)),t.set(Hr,4))}le(o,s,4,i)}return Ie(r,3,2),$n(n,r.i()),Pe(r=new nr,2,"TokenizerCalculator"),Ae(r,8,qn,n),Oe(r,5,"MODEL_DATA:__side_packet_1"),Oe(r,3,"PROMPT_AND_INPUT_OPTIONS:prompt"),Oe(r,5,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),Oe(r,6,"PROCESSOR_GETTER:__input_side_1"),Oe(r,4,"IDS_AND_INPUT_OPTIONS:__stream_0"),sr(e,r),Pe(n=new qn,1,"type.googleapis.com/odml.infra.proto.LlmGpuCalculatorOptions"),Ie(r=new Cr,12,3),Pe(r,1,"llm.tflite"),Ie(r,14,0),i=Xr(Ee(t.j,5)),Ie(r,22,i),i=ye(t.j,Pr,3),ve(r,31,i),me(i=new Dr,1,!0,!1),me(i,2,!0,!1),me(i,5,!0,!1),ve(r,10,i),i=he(t.j,4,kt,void 0===st?2:4),ge(r,29,i),i=new Mr,Ie(o=new Vr,1,1),a=Ee(t.j,2),Ie(o,2,a),ve(i,1,o),ve(r,20,i),$n(n,r.i()),Pe(r=new nr,2,"LlmGpuCalculator"),Ae(r,8,qn,n),Oe(r,3,"IDS_AND_INPUT_OPTIONS:__stream_0"),Oe(r,3,"FINISH:finish"),Oe(r,3,"LORA_DATA:lora_model_data"),Oe(r,5,"MODEL_DATA:__side_packet_1"),Oe(r,4,"DECODED_IDS:__stream_3"),Oe(r,4,"OUTPUT_END:__stream_4"),Pe(n=new tr,1,"FINISH"),me(n,2,!0,!1),Ae(r,13,tr,n),sr(e,r),Pe(n=new nr,2,"IsPacketPresentCalculator"),Oe(n,3,"__stream_4"),Oe(n,4,"text_end"),sr(e,n),Pe(n=new qn,1,"type.googleapis.com/odml.infra.proto.DetokenizerCalculatorOptions"),r=new Fr,t=Xr(Ee(t.j,5)),Ie(r,5,t),Oe(r,4,"<eos>"),Oe(r,4,"<|endoftext|>"),$n(n,r.i()),Pe(t=new nr,2,"DetokenizerCalculator"),Ae(t,8,qn,n),Oe(t,3,"IDS_AND_INPUT_OPTIONS:__stream_3"),Oe(t,5,"PROCESSOR_GETTER:__input_side_1"),Oe(t,5,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),Oe(t,5,"MODEL_DATA:__side_packet_1"),Oe(t,4,"FINISH_AND_INPUT_OPTIONS:finish"),Oe(t,4,"WORDS:text_out"),sr(e,t),Pe(t=new nr,2,"TokenCostCalculator"),Oe(t,3,"PROMPT:token_cost_in"),Oe(t,5,"PROCESSOR_GETTER:__input_side_1"),Oe(t,5,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),Oe(t,4,"NUM_TOKENS:token_cost_out"),sr(e,t),e}(t);t.i.attachStringVectorListener("text_out",((e,n)=>{e=function(t,e){return null==t||0===t.length?[]:t.map((t=>(t=(t=t.replaceAll("▁"," ")).replaceAll("<0x0A>","\n"),e&&(t=t.trimStart()),t.split("\\[eod\\]",1)[0])))}(e,0===t.D.length),e.forEach(((e,n)=>{n<Ee(t.j,5)&&t.D[n].push(e)})),t.A&&0===t.B.length&&(t.F?(e.length>Ee(t.j,5)&&e.pop(),t.A(e,!1)):t.A(e[0],!1)),Er(t,n)})),t.i.attachEmptyPacketListener("text_out",(e=>{Er(t,e)})),t.i.attachBoolListener("text_end",((e,n)=>{if(t.l=!1,Er(t,n),ti(t),t.o&&(t.o.resolve(t.D.map((t=>t.join("")))),t.o=void 0),t.A)if(t.F){for(e=[],n=0;n<Ee(t.j,5);n++)e.push("");t.A(e,!0)}else t.A("",!0);t.F=void 0})),t.i.attachEmptyPacketListener("text_end",(e=>{t.l=!1,t.F=void 0,Er(t,e),ti(t),t.o&&(t.o.resolve(t.D.map((t=>t.join("")))),t.o=void 0)})),t.i.attachIntListener("token_cost_out",((e,n)=>{t.M=e,Er(t,n)})),t.J&&t.i.addStreamingReaderToInputSidePacket(t.J,"streaming_reader");const n=e.i();return t.v?.removeEventListener("uncapturederror",t.I),t.i.R().then((()=>{t.v?.addEventListener("uncapturederror",t.I),t.B.length=0,t.setGraph(new Uint8Array(n),!0),t.finishProcessing()}))}function ti(t){if(t.B.length>0){const e=[...t.B];if(t.B.length=0,!t.o)throw e;t.o.reject(e),t.o=void 0}}function ei(t,e,n,r){if(t.l)throw Error("Previous invocation or loading is still ongoing.");for(t.A="function"==typeof n?n:r,t.l=!0,t.D.length=0,r=0;r<Ee(t.j,5);r++)t.D[r]=[];if(r=t.G+1,t.i.addStringToStream(e,"text_in",r),n instanceof Kr){if(n.j!==t)throw t.l=!1,t.F=void 0,Error("The LoRA model was not loaded by this LLM Inference task.");t.i.addUintToStream(n.i,"lora_model_id_to_apply_in",r)}else t.i.addEmptyPacketToStream("lora_model_id_to_apply_in",r);return t.finishProcessing(),t.o=new Jr,t.o.promise}var ni=class extends Ir{constructor(t,e){super(new qr(t,e)),this.D=[],this.l=!1,this.B=[],this.I=t=>{const e=(t=t.error).message.match(/exceeds the max buffer size limit \(([0-9]+)\)\./);e&&Number(e[1])>524550144?t=Error(`Failed to run this LLM model, but you could try a smaller LLM model. WebGPU throws: "${t.message}"`):t.message.match(/is larger than the maximum binding size/)&&(t=Error(`Failed to run LLM inference, the supported max binding size is smaller than the required size. WebGPU throws: "${t.message}"`)),this.B.push(t)},this.j=new Lr,Or(this.j,new ur),this.u=new Pr,ve(this.j,3,this.u),ce(this.j,2,jt(512)),me(this.u,1,2,0),Ie(this.u,2,40),me(this.u,3,Ot(1),0),ce(this.u,5,Nt(0)),me(this.u,4,Ot(.8),0),ce(this.j,5,jt(1))}K(t){if(this.l)throw Error("Cannot set options while loading or processing.");if(this.l=!0,t.baseOptions?.gpuOptions?.device&&(this.v&&this.v.removeEventListener("uncapturederror",this.I),this.v=t.baseOptions.gpuOptions.device,this.i.V(this.v),this.v.addEventListener("uncapturederror",this.I)),"maxTokens"in t&&ce(this.j,2,jt(t.maxTokens??512)),"topK"in t&&Ie(this.u,2,t.topK??40),"temperature"in t&&me(this.u,4,Ot(t.temperature??.8),0),"randomSeed"in t&&ce(this.u,5,Nt(t.randomSeed??0)),"loraRanks"in t&&function(t,e){ge(t,4,e)}(this.j,t.loraRanks??[]),"numResponses"in t){var e=t.numResponses??1;if(e<1)throw Error("'numResponses' must be at least 1.");ce(this.j,5,jt(e));var n=ye(this.j,Pr,3);e>1&&n&&(Te(kt(se(n,2)))<=1||Te(function(t){t=t.m;let e=K(t);const n=ue(t,e,4),r=Lt(n);return null!=r&&r!==n&&le(t,e,4,r),r}(n))<=0)&&console.warn("To generate multiple responses, it is expected topK > 1 and temperature > 0; otherwise, all the generated responses may be the same.")}let r;if(e=new Promise((t=>{r=t})),t.baseOptions?.modelAssetPath||t.baseOptions?.modelAssetBuffer){if(t.baseOptions.modelAssetPath&&t.baseOptions.modelAssetBuffer)throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");n=!1,t.baseOptions.modelAssetPath?this.J=function(t,e){const n=fetch(t.toString()).then((t=>t?.body?.getReader()));return new Nr([],(async()=>{let e;try{e=await n}catch(e){throw Error(`Error loading model from "${t.toString()}": ${e}`)}const{value:r,done:i}=await e.read();return i?void 0:r}),e)}(t.baseOptions.modelAssetPath,r):t.baseOptions.modelAssetBuffer instanceof Uint8Array?(this.J=function(t,e){return new Nr([new Br(t)],(()=>Promise.resolve(void 0)),e)}(t.baseOptions.modelAssetBuffer,r),n=!0):t.baseOptions.modelAssetBuffer?(this.J=function(t,e){return new Nr([],(async()=>{const{value:e,done:n}=await t.read();return n?void 0:e}),e)}(t.baseOptions.modelAssetBuffer,r),n=!0):r(),n&&(t.baseOptions.modelAssetBuffer=void 0)}return t=Qr(this).then((()=>{})),Promise.all([e,t]).then((()=>{this.l=!1,ti(this)}))}get baseOptions(){return ye(this.j,ur,1)}set baseOptions(t){Or(this.j,t)}T(t,e,n){return Ee(this.j,5)>1&&console.warn("'numResponses' is set larger than 1 and this function only returns the first response, so we recommend either using 'generateResponses()' to obtain multiple responses, or else setting 'numResponses' to 1 for better performance."),this.F=!1,ei(this,t,e,n).then((t=>t[0]))}U(t,e,n){return this.F=!0,ei(this,t,e,n)}aa(t){if(this.l)throw Error("Previous invocation or loading is still ongoing.");return this.l=!0,this.M=void 0,this.i.addStringToStream(t,"token_cost_in",this.G+1),this.finishProcessing(),this.l=!1,this.M}async X(t){if(this.l)throw Error("Cannot load LoRA model while loading or processing.");if(this.l=!0,t instanceof Uint8Array){var e=new jr(this.i.h,t.length);e.set(t),t=e}else t=await async function(t,e){var n=await fetch(e.toString());e=Number(n.headers.get("content-length")),t=new jr(t,e);let r=0;for(n=n?.body?.getReader();;){const{value:e,done:i}=await n.read();if(i)break;t.set(e,r),r+=e.byteLength}if(e!==r)throw kr(t),Error(`File could not be fully loaded to memory, so was not retained. Loaded ${r}/${e} bytes before failure`);return t}(this.i.h,t);return e=new Kr(this),this.i.P(t,this.G+1),this.i.addUintToStream(e.i,"lora_model_id_to_load_in",this.G+1),this.finishProcessing(),kr(t),this.l=!1,e}close(){this.v?.removeEventListener("uncapturederror",this.I),super.close()}};ni.prototype.loadLoraModel=ni.prototype.X,ni.prototype.sizeInTokens=ni.prototype.aa,ni.prototype.generateResponses=ni.prototype.U,ni.prototype.generateResponse=ni.prototype.T,ni.prototype.setOptions=ni.prototype.K,ni.createWebGpuDevice=Zr,ni.createFromModelPath=async function(t,e){return Ar(t,e={baseOptions:{gpuOptions:{device:await Zr()},modelAssetPath:e}})},ni.createFromModelBuffer=async function(t,e){return Ar(t,e={baseOptions:{gpuOptions:{device:await Zr()},modelAssetBuffer:e}})},ni.createFromOptions=async function(t,e){if(!e.baseOptions?.gpuOptions?.device){const t=await Zr();e.baseOptions=e.baseOptions??{},e.baseOptions.gpuOptions=e?.baseOptions?.gpuOptions??{},e.baseOptions.gpuOptions.device=t}return Ar(t,e)},exports.FilesetResolver=dr,exports.LlmInference=ni,exports.TaskRunner=Ir;
2
2
  //# sourceMappingURL=genai_bundle_cjs.js.map