@mediapipe/tasks-genai 0.10.15 → 0.10.16

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/genai_bundle.mjs CHANGED
@@ -1,2 +1,2 @@
1
- var t="undefined"!=typeof self?self:{};function e(e,n){t:{for(var r=["CLOSURE_FLAGS"],i=t,o=0;o<r.length;o++)if(null==(i=i[r[o]])){r=null;break t}r=i}return null!=(e=r&&r[e])?e:n}let n;const r="undefined"!=typeof TextEncoder;function i(t){if(r)t=(n||=new TextEncoder).encode(t);else{let n=0;const r=new Uint8Array(3*t.length);for(let i=0;i<t.length;i++){var e=t.charCodeAt(i);if(e<128)r[n++]=e;else{if(e<2048)r[n++]=e>>6|192;else{if(e>=55296&&e<=57343){if(e<=56319&&i<t.length){const o=t.charCodeAt(++i);if(o>=56320&&o<=57343){e=1024*(e-55296)+o-56320+65536,r[n++]=e>>18|240,r[n++]=e>>12&63|128,r[n++]=e>>6&63|128,r[n++]=63&e|128;continue}i--}e=65533}r[n++]=e>>12|224,r[n++]=e>>6&63|128}r[n++]=63&e|128}}t=n===r.length?r:r.subarray(0,n)}return t}var o,s=e(610401301,!1),a=e(645172343,e(1,!0)),u=e(660014094,!1);const l=t.navigator;function c(t){return!!s&&(!!o&&o.brands.some((({brand:e})=>e&&-1!=e.indexOf(t))))}function h(e){var n;return(n=t.navigator)&&(n=n.userAgent)||(n=""),-1!=n.indexOf(e)}function f(){return!!s&&(!!o&&o.brands.length>0)}function d(){return f()?c("Chromium"):(h("Chrome")||h("CriOS"))&&!(!f()&&h("Edge"))||h("Silk")}o=l&&l.userAgentData||null;var p=!f()&&(h("Trident")||h("MSIE"));!h("Android")||d(),d(),h("Safari")&&(d()||!f()&&h("Coast")||!f()&&h("Opera")||!f()&&h("Edge")||(f()?c("Microsoft Edge"):h("Edg/"))||f()&&c("Opera"));var g={},m=null;function _(t){var e=t.length,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);var r=new Uint8Array(n),i=0;return function(t,e){function n(e){for(;r<t.length;){var n=t.charAt(r++),i=m[n];if(null!=i)return i;if(!/^[\s\xa0]*$/.test(n))throw Error("Unknown base64 encoding at char: "+n)}return e}v();for(var r=0;;){var i=n(-1),o=n(0),s=n(64),a=n(64);if(64===a&&-1===i)break;e(i<<2|o>>4),64!=s&&(e(o<<4&240|s>>2),64!=a&&e(s<<6&192|a))}}(t,(function(t){r[i++]=t})),i!==n?r.subarray(0,i):r}function v(){if(!m){m={};for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"],n=0;n<5;n++){var r=t.concat(e[n].split(""));g[n]=r;for(var i=0;i<r.length;i++){var o=r[i];void 0===m[o]&&(m[o]=i)}}}}var y="undefined"!=typeof Uint8Array,b=!p&&"function"==typeof btoa;function w(t){if(!b){var e;void 0===e&&(e=0),v(),e=g[e];var n=Array(Math.floor(t.length/3)),r=e[64]||"";let u=0,l=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[l++]=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[l]=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 S=/[-_.]/g,A={"-":"+",_:"/",".":"="};function T(t){return A[t]||""}function E(t){if(!b)return _(t);S.test(t)&&(t=t.replace(S,T)),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 I(t){return y&&null!=t&&t instanceof Uint8Array}var P={};let O;function L(t){if(t!==P)throw Error("illegal external caller")}function x(){return O||=new U(null,P)}var U=class{constructor(t,e){if(L(e),this.i=t,null!=t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}};function B(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}let N;function k(){const e=Error();B(e,"incident"),function(e){t.setTimeout((()=>{throw e}),0)}(e)}function j(t){return B(t=Error(t),"warning"),t}function F(){return"function"==typeof BigInt}function D(t){return Array.prototype.slice.call(t)}var V="function"==typeof Symbol&&"symbol"==typeof Symbol();function M(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol():t}var C=M(),G=M("2ex"),R=M("1oa"),z=M("0dg"),W=V?(t,e)=>{t[C]|=e}:(t,e)=>{void 0!==t.i?t.i|=e:Object.defineProperties(t,{i:{value:e,configurable:!0,writable:!0,enumerable:!1}})},H=V?(t,e)=>{t[C]&=~e}:(t,e)=>{void 0!==t.i&&(t.i&=~e)},$=V?t=>0|t[C]:t=>0|t.i,q=V?t=>t[C]:t=>t.i,K=V?(t,e)=>{t[C]=e}:(t,e)=>{void 0!==t.i?t.i=e:Object.defineProperties(t,{i:{value:e,configurable:!0,writable:!0,enumerable:!1}})};function Y(t,e){K(e,-14591&(0|t))}function J(t,e){K(e,-14557&(34|t))}var X,Z={},Q={};function tt(t){return!(!t||"object"!=typeof t||t.i!==Q)}function et(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)&&t.constructor===Object}function nt(t){return!(!Array.isArray(t)||t.length)&&!!(1&$(t))}const rt=[];function it(t){if(2&t)throw Error()}K(rt,55),X=Object.freeze(rt);var ot=Object.freeze({});Object.freeze({});var st=Object.freeze({});let at,ut=0,lt=0;function ct(t){const e=t>>>0;ut=e,lt=(t-e)/4294967296>>>0}function ht(t){if(t<0){ct(-t);const[e,n]=gt(ut,lt);ut=e>>>0,lt=n>>>0}else ct(t)}function ft(t,e){if(t>>>=0,(e>>>=0)<=2097151)var n=""+(4294967296*e+t);else F()?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+dt(n)+dt(t));return n}function dt(t){return t=String(t),"0000000".slice(t.length)+t}function pt(t){if(t.length<16)ht(Number(t));else if(F())t=BigInt(t),ut=Number(t&BigInt(4294967295))>>>0,lt=Number(t>>BigInt(32)&BigInt(4294967295));else{const e=+("-"===t[0]);lt=ut=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));lt*=1e6,ut=1e6*ut+e,ut>=4294967296&&(lt+=Math.trunc(ut/4294967296),lt>>>=0,ut>>>=0)}if(e){const[t,e]=gt(ut,lt);ut=t,lt=e}}}function gt(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}var mt="function"==typeof t.BigInt&&"bigint"==typeof t.BigInt(0);const _t=Number.MIN_SAFE_INTEGER.toString(),vt=mt?BigInt(Number.MIN_SAFE_INTEGER):void 0,yt=Number.MAX_SAFE_INTEGER.toString(),bt=mt?BigInt(Number.MAX_SAFE_INTEGER):void 0;function wt(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}}function St(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 At(t){return null==t||"number"==typeof t?t:"NaN"===t||"Infinity"===t||"-Infinity"===t?Number(t):void 0}const Tt=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function Et(t){const e=typeof t;switch(e){case"bigint":return!0;case"number":return Number.isFinite(t)}return"string"===e&&Tt.test(t)}function It(t){if("number"!=typeof t)throw j("int32");if(!Number.isFinite(t))throw j("int32");return 0|t}function Pt(t){return null==t?t:It(t)}function Ot(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 Lt(t){if(null!=t){if("number"!=typeof t)throw j("uint32");if(!Number.isFinite(t))throw j("uint32");t>>>=0}return t}function xt(t){return"-"!==t[0]&&(t.length<20||20===t.length&&Number(t.substring(0,6))<184467)}function Ut(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(BigInt.asUintN(64,t));if(Et(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)),xt(t)||(pt(t),t=ft(ut,lt))),t;if("number"===e)return(t=Math.trunc(t))>=0&&Number.isSafeInteger(t)?t:function(t){if(t<0){ht(t);const e=ft(ut,lt);return t=Number(e),Number.isSafeInteger(t)?t:e}return xt(String(t))?t:(ht(t),4294967296*lt+(ut>>>0))}(t)}}function Bt(t){return null==t||"string"==typeof t?t:void 0}function Nt(t,e,n){if(null!=t&&"object"==typeof t&&t.M===Z)return t;if(Array.isArray(t)){var r=$(t),i=r;return 0===i&&(i|=32&n),(i|=2&n)!==r&&K(t,i),new e(t)}}function kt(t){var e=jt?.get(t);if(e)return e;if(Math.random()>.01)return t;if(void 0===Dt)if("function"!=typeof Proxy)Dt=null;else try{Dt=-1!==Proxy.toString().indexOf("[native code]")?Proxy:null}catch{Dt=null}return(e=Dt)?(function(t,e){(jt||=new WeakMap).set(t,e),(Ft||=new WeakMap).set(e,t)}(t,e=new e(t,{set:(t,e,n)=>(k(),t[e]=n,!0)})),e):t}let jt,Ft,Dt,Vt,Mt,Ct,Gt;function Rt(t,e,n){if(null==t&&(t=Vt),Vt=void 0,null==t){var r=96;n?(t=[n],r|=512):t=[],e&&(r=-16760833&r|(1023&e)<<14)}else{if(!Array.isArray(t))throw Error("narr");if(2048&(r=$(t)))throw Error("farr");if(64&r)return t;if(r|=64,n&&(r|=512,n!==t[0]))throw Error("mid");t:{const i=(n=t).length;if(i){const t=i-1;if(et(n[t])){if((e=t-(+!!(512&(r|=256))-1))>=1024)throw Error("pvtlmt");r=-16760833&r|(1023&e)<<14;break t}}if(e){if((e=Math.max(e,i-(+!!(512&r)-1)))>1024)throw Error("spvt");r=-16760833&r|(1023&e)<<14}}}return K(t,r),t}function zt(t,e,n,r,i){if(null!=t){if(Array.isArray(t))t=nt(t)?void 0:i&&2&$(t)?t:Wt(t,e,n,void 0!==r,i);else if(et(t)){const o={};for(let s in t)o[s]=zt(t[s],e,n,r,i);t=o}else t=e(t,r);return t}}function Wt(t,e,n,r,i){const o=r||n?$(t):0;r=r?!!(32&o):void 0,t=D(t);for(let o=0;o<t.length;o++)t[o]=zt(t[o],e,n,r,i);return n&&n(o,t),t}function Ht(t){return t.M===Z?t.toJSON():function(t){switch(typeof t){case"number":return isFinite(t)?t:String(t);case"bigint":return(mt?t>=vt&&t<=bt:"-"===t[0]?wt(t,_t):wt(t,yt))?Number(t):String(t);case"boolean":return t?1:0;case"object":if(t)if(Array.isArray(t)){if(nt(t))return}else{if(I(t))return w(t);if(t instanceof U){const e=t.i;return null==e?"":"string"==typeof e?e:t.i=w(e)}}}return t}(t)}function $t(t,e,n=J){if(null!=t){if(y&&t instanceof Uint8Array)return e?t:new Uint8Array(t);if(Array.isArray(t)){var r=$(t);return 2&r?t:(e&&=0===r||!!(32&r)&&!(64&r||!(16&r)),e?(K(t,-12293&(34|r)),t):Wt(t,$t,4&r?J:n,!0,!0))}return t.M===Z&&(n=t.m,t=2&(r=q(n))?t:qt(t,n,r,!0)),t}}function qt(t,e,n,r){return t=t.constructor,Vt=e=function(t,e,n){const r=n||2&e?J:Y,i=!!(32&e);return t=function(t,e,n){var r=(t=D(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=>$t(t,i,r))),W(t,32|(n?2:0)),t}(e,n,r),e=new t(e),Vt=void 0,e}function Kt(t){const e=t.m,n=q(e);return 2&n?qt(t,e,n,!1):t}function Yt(t,e,n,r){return!(4&e)||null!=n&&(!r&&0===n&&(4096&e||8192&e)&&(t.constructor[z]=1+(0|t.constructor[z]))<5&&k(),0!==n&&!(n&e))}function Jt(t,e){return Zt(t=t.m,q(t),e)}function Xt(t,e,n,r){if(!((e=r+(+!!(512&e)-1))<0||e>=t.length||e>=n))return t[e]}function Zt(t,e,n,r){if(-1===n)return null;const i=e>>14&1023||536870912;if(!(n>=i)){var o=t.length;return r&&256&e&&null!=(r=t[o-1][n])?(Xt(t,e,i,n)&&null!=G&&((e=(t=N??={})[G]||0)>=4||(t[G]=e+1,k())),r):Xt(t,e,i,n)}return 256&e?t[t.length-1][n]:void 0}function Qt(t,e,n){const r=t.m;let i=q(r);return it(i),te(r,i,e,n),t}function te(t,e,n,r,i){const o=e>>14&1023||536870912;if(n>=o||i&&!a){let s=e;if(256&e)i=t[t.length-1];else{if(null==r)return s;i=t[o+(+!!(512&e)-1)]={},s|=256}return i[n]=r,n<o&&(t[n+(+!!(512&e)-1)]=void 0),s!==e&&K(t,s),s}return t[n+(+!!(512&e)-1)]=r,256&e&&(n in(t=t[t.length-1])&&delete t[n]),e}function ee(t,e,n){return t=Zt(t,e,n),Array.isArray(t)?t:X}function ne(t,e){return 0===t&&(t=le(t,e)),1|t}function re(t){return!!(2&t)&&!!(4&t)||!!(2048&t)}function ie(t,e,n,r){t=t.m;let i=q(t);it(i),te(t,i,e,("0"===r?0===Number(n):n===r)?void 0:n)}function oe(t){if(V)return t[R]??(t[R]=new Map);if(R in t)return t[R];const e=new Map;return Object.defineProperty(t,R,{value:e}),e}function se(t,e,n){var r=yr;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!=Zt(e,n,o)&&(0!==i&&(n=te(e,n,i)),i=o)}return t.set(r,i),i}function ae(t,e,n){var r=t.m,i=q(r),o=Zt(r,i,n,!1);return(e=Nt(o,e,i))!==o&&null!=e&&te(r,i,n,e,!1),null==(r=e)||(t=t.m,2&(i=q(t))||(o=Kt(r))!==r&&te(t,i,n,r=o,!1)),r}function ue(t,e,n){return null==n&&(n=void 0),Qt(t,e,n)}function le(t,e){return-2049&(t=32|(2&e?2|t:-3&t))}function ce(t,e,n){return 32&e&&n||(t&=-33),t}function he(t,e,n,r){t=t.m;var i=q(t);it(i);var o,s=!!(2&i);const a=s?1:2;d&&=!s,s=ee(t,i,e);var u=$(s),l=!!(4&u);if(!l){var c=s,h=i,f=!!(2&(u=ne(u,i)));f&&(h|=2);let t=!f,e=!0,r=0,o=0;for(;r<c.length;r++){const i=Nt(c[r],n,h);if(i instanceof n){if(!f){const n=!!(2&$(i.m));t&&=!n,e&&=n}c[o++]=i}}o<r&&(c.length=o),u|=4,u=e?16|u:-17&u,K(c,u=t?8|u:-9&u),f&&Object.freeze(c)}if(d&&!(8&u||!s.length&&(1===a||4===a&&32&u))){re(u)&&(s=D(s),u=le(u,i),i=te(t,i,e,s));var d=s;for(c=u,u=0;u<d.length;u++)(h=d[u])!==(f=Kt(h))&&(d[u]=f);c|=8,c=d.length?-17&c:16|c,K(d,c),u=c}1===a||4===a&&32&u?re(u)||(e=u,(u|=!s.length||16&u&&(!l||32&u)?2:2048)!==e&&K(s,u),Object.freeze(s)):(l=5===a&&(!!(32&u)||re(u)||!!jt?.get(s)),(2===a||l)&&re(u)&&(s=D(s),u=ce(u=le(u,i),i,!0),K(s,u),i=te(t,i,e,s)),re(u)||(e=u,(u=ce(u,i,!0))!==e&&K(s,u)),l&&(o=kt(s))),o=o||s,n=null!=r?r:new n,o.push(n),2&$(n.m)?H(o,8):H(o,16)}function fe(t){return t??0}function de(t,e){return fe(function(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}(Jt(t,e)))}function pe(t,e,n){ie(t,e,Pt(n),0)}function ge(t,e,n){if(null!=n&&"string"!=typeof n)throw Error();ie(t,e,n,"")}function me(t,e,n){{const a=t.m;let u=q(a);if(it(u),null==n)te(a,u,e);else{n=Ft?.get(n)||n;var r,i=$(n),o=i,s=!!(2&i)||Object.isFrozen(n);if((r=!s)&&(r=void 0===st||!1),Yt(t,i))for(i=21,s&&(n=D(n),o=0,i=ce(i=le(i,u),u,!0)),t=0;t<n.length;t++)n[t]=It(n[t]);r&&(n=D(n),o=0,i=ce(i=le(i,u),u,!0)),i!==o&&K(n,i),te(a,u,e,n)}}}function _e(t,e,n){t=t.m;const r=q(t);it(r);var i=2&r;let o=Zt(t,r,e);Array.isArray(o)||(o=X);const s=!!(32&r);let a=$(o);if(0===a&&s&&!i?(a|=33,K(o,a)):1&a||(a|=1,K(o,a)),i?(2&a||W(o,34),Object.freeze(o)):(2&a||2048&a)&&(o=D(o),i=1,s&&(i|=32),K(o,i),te(t,r,e,o)),"string"!=typeof n)throw Error();o.push(n)}function ve(t){if("string"==typeof t)return{buffer:E(t),B:!1};if(Array.isArray(t))return{buffer:new Uint8Array(t),B:!1};if(t.constructor===Uint8Array)return{buffer:t,B:!1};if(t.constructor===ArrayBuffer)return{buffer:new Uint8Array(t),B:!1};if(t.constructor===U){L(P);var e=t.i;return{buffer:(null==(e=null==e||I(e)?e:"string"==typeof e?E(e):null)?e:t.i=e)||new Uint8Array(0),B:!0}}if(t instanceof Uint8Array)return{buffer:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),B:!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 ye=class{constructor(t,e){this.m=Rt(t,e)}toJSON(){return be(this)}B(){return!!(2&$(this.m))}};function be(t){t=Gt?t.m:Wt(t.m,Ht,void 0,void 0,!1);{var e=!Gt;let l=t.length;if(l){var n=t[l-1],r=et(n);r?l--:n=void 0;var i=t;if(r){t:{var o=n,s={};if(r=!1,o)for(var a in o){if(isNaN(+a)){s[a]=o[a];continue}let t=o[a];Array.isArray(t)&&(nt(t)||tt(t)&&0===t.size)&&(t=null),null==t&&(r=!0),null!=t&&(s[a]=t)}if(r){for(let t in s)break t;s=null}else s=o}o=null==s?null!=n:s!==n}for(;l>0&&(null==(a=i[l-1])||nt(a)||tt(a)&&0===a.size);l--)var u=!0;(i!==t||o||u)&&(e?(u||o||s)&&(i.length=l):i=Array.prototype.slice.call(i,0,l),s&&i.push(s)),u=i}else u=t}return u}function we(t){return t?/^\d+$/.test(t)?(pt(t),new Se(ut,lt)):null:Ae||=new Se(0,0)}ye.prototype.M=Z,ye.prototype.toString=function(){try{return Gt=!0,be(this).toString()}finally{Gt=!1}};var Se=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};let Ae;function Te(t){return t?/^-?\d+$/.test(t)?(pt(t),new Ee(ut,lt)):null:Ie||=new Ee(0,0)}var Ee=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};let Ie;function Pe(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 Oe(t,e){for(;e>127;)t.i.push(127&e|128),e>>>=7;t.i.push(e)}function Le(t,e){if(e>=0)Oe(t,e);else{for(let n=0;n<9;n++)t.i.push(127&e|128),e>>=7;t.i.push(1)}}function xe(t,e){0!==e.length&&(t.l.push(e),t.j+=e.length)}function Ue(t,e){return Oe(t.i,8*e+2),e=t.i.end(),xe(t,e),e.push(t.j),e}function Be(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 Ne(t,e,n){Oe(t.i,8*e+2),Oe(t.i,n.length),xe(t,t.i.end()),xe(t,n)}class ke{constructor(t,e){this.i=t,this.P=e}}function je(t,e){if(Array.isArray(e)){var n=$(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),K(e,-12289&(5|n)),2&n&&Object.freeze(e),e}}const Fe=Symbol(),De=Symbol();function Ve(t){let e=t[De];if(!e){const n=Re(t);e=(t,e)=>He(t,e,n),t[De]=e}return e}const Me=Symbol();function Ce(t){return t.i}function Ge(t,e){let n,r;const i=t.i;return(t,o,s)=>i(t,o,s,r||=Re(e).i,n||=Ve(e))}function Re(t){var e=t[Me];if(e)return e;var n=Ce,r=Ge;(e=t[Me]={}).i=function(t){switch(typeof t){case"boolean":return Mt||=[0,void 0,!0];case"number":return t>0?void 0:0===t?Ct||=[0,void 0]:[-t,void 0];case"string":return[0,t];case"object":return t}}(t[0]);let i=0;var o=t[++i];o&&o.constructor===Object&&(e.L=o,"function"==typeof(o=t[++i])&&(e.l=o,e.j=t[++i],o=t[++i]));const s={};for(;Array.isArray(o)&&"number"==typeof o[0]&&o[0]>0;){for(var a=0;a<o.length;a++)s[o[a]]=o;o=t[++i]}for(a=1;void 0!==o;){let f;"number"==typeof o&&(a+=o,o=t[++i]);var u=void 0;if(o instanceof ke?f=o:(f=gn,i--),f.P){o=t[++i],u=t;var l=i;"function"==typeof o&&(o=o(),u[l]=o),u=o}let d=a+1;for("number"==typeof(o=t[++i])&&o<0&&(d-=o,o=t[++i]);a<d;a++){var c=s[a];l=e;var h=a;c=u?r(f,u):n(f),l[h]=c}}return ze in t&&Fe in t&&Me in t&&(t.length=0),e}const ze=Symbol();function We(t,e){var n=t[e];if(n)return n;if(n=t.L){var r=n[e];if(r){var i=(r=Array.isArray(r)?r[0]instanceof ke?r:[pn,r]:[r,void 0])[0].i;if(r=r[1],n=n.C?.[e],!u||n){if(r){const e=Ve(r),o=Re(r).i;n=(n=t.j)?n(o,e):(t,n,r)=>i(t,n,r,o,e)}else n=i;return t[e]=n}}}}function He(t,e,n){for(var r=q(t),i=+!!(512&r)-1,o=t.length,s=512&r?1:0,a=o+(256&r?-1:0);s<a;s++){const r=t[s];if(null==r)continue;const o=s-i,a=We(n,o);if(!a)continue;const u=n.L;u?.[o]&&!u?.C?.[o]&&qe++<5&&k(),a(e,r,o)}if(256&r){t=t[o-1];for(let s in t)r=+s,!Number.isNaN(r)&&(null!=(i=t[s])&&(o=We(n,r)))&&((a=n.L)?.[r]&&!a?.C?.[r]&&qe++<5&&k(),o(e,i,r))}}function $e(t){return new ke(t,!1)}let qe=0;function Ke(t,e,n){null!=(e=Ot(e))&&null!=e&&(Oe(t.i,8*n),Le(t.i,e))}function Ye(t,e,n){null!=(e=null==e||"boolean"==typeof e?e:"number"==typeof e?!!e:void 0)&&(Oe(t.i,8*n),t.i.i.push(e?1:0))}function Je(t,e,n){null!=(e=Bt(e))&&Ne(t,n,i(e))}function Xe(t,e,n,r,i){null!=(e=e instanceof ye?e.m:Array.isArray(e)?Rt(e,r[0],r[1]):void 0)&&(n=Ue(t,n),i(e,t),Be(t,n))}function Ze(t,e,n){null!=(e=Ot(e))&&(e=parseInt(e,10),Oe(t.i,8*n),Le(t.i,e))}var Qe,tn=$e((function(t,e,n){null!=(e=At(e))&&(Oe(t.i,8*n+5),t=t.i,(n=at||=new DataView(new ArrayBuffer(8))).setFloat32(0,+e,!0),lt=0,e=ut=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))})),en=$e((function(t,e,n){e=function(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(BigInt.asIntN(64,t));if(Et(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(pt(t),t=ut,2147483648&(e=lt))if(F())t=""+(BigInt(0|e)<<BigInt(32)|BigInt(t>>>0));else{const[n,r]=gt(t,e);t="-"+ft(n,r)}else t=ft(t,e);return t}if("number"===e){if(t=Math.trunc(t),!Number.isSafeInteger(t)){ht(t),e=ut;var n=lt;(t=2147483648&n)&&(n=~n>>>0,0==(e=1+~e>>>0)&&(n=n+1>>>0)),e=4294967296*n+(e>>>0),t=t?-e:e}return t}}}(e),null!=e&&("string"==typeof e&&Te(e),null!=e&&(Oe(t.i,8*n),"number"==typeof e?(t=t.i,ht(e),Pe(t,ut,lt)):(n=Te(e),Pe(t.i,n.j,n.i))))})),nn=$e((function(t,e,n){null!=(e=Ut(e))&&("string"==typeof e&&we(e),null!=e&&(Oe(t.i,8*n),"number"==typeof e?(t=t.i,ht(e),Pe(t,ut,lt)):(n=we(e),Pe(t.i,n.j,n.i))))})),rn=$e(Ke),on=new ke((function(t,e,n){if(null!=(e=je(Ot,e))&&e.length){n=Ue(t,n);for(let n=0;n<e.length;n++)Le(t.i,e[n]);Be(t,n)}}),!1),sn=$e(Ke),an=$e(Ke),un=$e(Ye),ln=$e(Ye),cn=new ke((function(t,e,n){if(null!=(e=je(Bt,e)))for(let a=0;a<e.length;a++){var r=t,o=n,s=e[a];null!=s&&Ne(r,o,i(s))}}),!1),hn=$e(Je),fn=$e(Je),dn=$e(Je),pn=new ke(Xe,!0),gn=new ke(Xe,!0);Qe=new ke((function(t,e,n,r,i){if(Array.isArray(e))for(let o=0;o<e.length;o++)Xe(t,e[o],n,r,i)}),!0);var mn=new ke(Xe,!0),_n=$e(Ze),vn=new ke((function(t,e,n){if(null!=(e=je(Ot,e))&&e.length){n=Ue(t,n);for(let n=0;n<e.length;n++)Le(t.i,e[n]);Be(t,n)}}),!1),yn=$e(Ze);function bn(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}}}};He(this.m,e,Re(t)),xe(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 wn(t,e){if(null!=e)if(Array.isArray(e))Qt(t,2,Wt(e,Ht,void 0,void 0,!1));else{if(!("string"==typeof e||e instanceof U||I(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 U(e,P):x();else if(e.constructor!==U){if(!I(e))throw Error();e=e.length?new U(new Uint8Array(e),P):x()}ie(t,2,e,x())}}var Sn=class extends ye{constructor(t){super(t)}},An=[0,hn,$e((function(t,e,n){if(null!=e){if(e instanceof ye){const r=e.aa;return void(r&&(e=r(e),null!=e&&Ne(t,n,ve(e).buffer)))}if(Array.isArray(e))return}null!=(e=null==e||"string"==typeof e||I(e)||e instanceof U?e:void 0)&&Ne(t,n,ve(e).buffer)}))],Tn=[0,dn,un,-1,rn,[0,[1,2,3,4,5,6],mn,[0],mn,[0,un,dn,un,_n,-1,vn,dn,-1,[0,un,-1],_n,un],mn,[0,dn,-2],mn,[0,rn,un,1,un,-3],mn,[0,rn,_n,un,-1,on,_n,-1],mn,[0,dn,-2]],[0,dn],un,[0,[1,3],[2,4],mn,[0,on],-1,mn,[0,cn],-1,Qe,[0,dn,-1]],dn],En={},In=En.C={};En[336783863]=Tn,In[336783863]=1;var Pn=class extends ye{constructor(t){super(t)}},On=[0,en,-1,ln,-3,en,on,hn,sn,en,-1,ln,sn,ln,-2,hn],Ln=class extends ye{constructor(t){super(t,500)}K(t){return ue(this,7,t)}},xn=[-1,{C:{}}],Un=[0,dn,1,xn],Bn=[0,dn,cn,xn];function Nn(t,e){he(t,1,Ln,e)}var kn=class extends ye{constructor(){super(void 0,500)}K(t){return ue(this,1001,t)}};kn.prototype.i=bn([-500,Qe,[-500,hn,-1,cn,-3,[-2,En,un],Qe,An,sn,-1,Un,Bn,Qe,[0,hn,ln],hn,On,sn,cn,987,cn],4,Qe,[-500,dn,-1,[-1,{C:{}}],998,dn],Qe,[-500,dn,cn,-1,[-2,{C:{}},un],997,cn,-1],sn,Qe,[-500,dn,cn,xn,998,cn],cn,sn,Un,Bn,Qe,[0,hn,-1,xn],cn,-2,On,hn,-1,ln,979,xn,Qe,An]);var jn=class extends ye{constructor(t){super(t)}};let Fn;const Dn=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 Vn(){if(void 0===Fn)try{await WebAssembly.instantiate(Dn),Fn=!0}catch{Fn=!1}return Fn}async function Mn(t,e=""){const n=await Vn()?"wasm_internal":"wasm_nosimd_internal";return{wasmLoaderPath:`${e}/${t}_${n}.js`,wasmBinaryPath:`${e}/${t}_${n}.wasm`}}var Cn=class{};function Gn(){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 Rn(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())}Cn.forVisionTasks=function(t){return Mn("vision",t)},Cn.forTextTasks=function(t){return Mn("text",t)},Cn.forGenAiExperimentalTasks=function(t){return Mn("genai_experimental",t)},Cn.forGenAiTasks=function(t){return Mn("genai",t)},Cn.forAudioTasks=function(t){return Mn("audio",t)},Cn.isSimdSupported=function(){return Vn()};function zn(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 Wn(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 Hn(t,e,n){t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=n}function $n(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 qn=(Kn=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:Gn()?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?'),zn(this,r||"input_audio",(r=>{zn(this,i=i||"audio_header",(i=>{this.h._configureAudio(r,i,t,e,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),zn(this,r,(t=>{this.h._addAudioToInputStream(this.i,e,n,t,i)}))}addGpuBufferToStream(t,e,n){zn(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){zn(this,e,(e=>{this.h._addBoolToInputStream(t,e,n)}))}addDoubleToStream(t,e,n){zn(this,e,(e=>{this.h._addDoubleToInputStream(t,e,n)}))}addFloatToStream(t,e,n){zn(this,e,(e=>{this.h._addFloatToInputStream(t,e,n)}))}addIntToStream(t,e,n){zn(this,e,(e=>{this.h._addIntToInputStream(t,e,n)}))}addUintToStream(t,e,n){zn(this,e,(e=>{this.h._addUintToInputStream(t,e,n)}))}addStringToStream(t,e,n){zn(this,e,(e=>{zn(this,t,(t=>{this.h._addStringToInputStream(t,e,n)}))}))}addStringRecordToStream(t,e,n){zn(this,e,(e=>{Wn(this,Object.keys(t),(r=>{Wn(this,Object.values(t),(i=>{this.h._addFlatHashMapToInputStream(r,i,Object.keys(t).length,e,n)}))}))}))}addProtoToStream(t,e,n,r){zn(this,n,(n=>{zn(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){zn(this,t,(t=>{this.h._addEmptyPacketToInputStream(t,e)}))}addBoolVectorToStream(t,e,n){zn(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){zn(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){zn(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){zn(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){zn(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){zn(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)zn(this,e,(t=>{this.h._addStringVectorEntry(r,t)}));this.h._addStringVectorToInputStream(r,e,n)}))}addBoolToInputSidePacket(t,e){zn(this,e,(e=>{this.h._addBoolToInputSidePacket(t,e)}))}addDoubleToInputSidePacket(t,e){zn(this,e,(e=>{this.h._addDoubleToInputSidePacket(t,e)}))}addFloatToInputSidePacket(t,e){zn(this,e,(e=>{this.h._addFloatToInputSidePacket(t,e)}))}addIntToInputSidePacket(t,e){zn(this,e,(e=>{this.h._addIntToInputSidePacket(t,e)}))}addUintToInputSidePacket(t,e){zn(this,e,(e=>{this.h._addUintToInputSidePacket(t,e)}))}addStringToInputSidePacket(t,e){zn(this,e,(e=>{zn(this,t,(t=>{this.h._addStringToInputSidePacket(t,e)}))}))}addProtoToInputSidePacket(t,e,n){zn(this,n,(n=>{zn(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){zn(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){zn(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){zn(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){zn(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){zn(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){zn(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)zn(this,e,(t=>{this.h._addStringVectorEntry(n,t)}));this.h._addStringVectorToInputSidePacket(n,e)}))}attachBoolListener(t,e){Hn(this,t,e),zn(this,t,(t=>{this.h._attachBoolListener(t)}))}attachBoolVectorListener(t,e){$n(this,t,e),zn(this,t,(t=>{this.h._attachBoolVectorListener(t)}))}attachIntListener(t,e){Hn(this,t,e),zn(this,t,(t=>{this.h._attachIntListener(t)}))}attachIntVectorListener(t,e){$n(this,t,e),zn(this,t,(t=>{this.h._attachIntVectorListener(t)}))}attachUintListener(t,e){Hn(this,t,e),zn(this,t,(t=>{this.h._attachUintListener(t)}))}attachUintVectorListener(t,e){$n(this,t,e),zn(this,t,(t=>{this.h._attachUintVectorListener(t)}))}attachDoubleListener(t,e){Hn(this,t,e),zn(this,t,(t=>{this.h._attachDoubleListener(t)}))}attachDoubleVectorListener(t,e){$n(this,t,e),zn(this,t,(t=>{this.h._attachDoubleVectorListener(t)}))}attachFloatListener(t,e){Hn(this,t,e),zn(this,t,(t=>{this.h._attachFloatListener(t)}))}attachFloatVectorListener(t,e){$n(this,t,e),zn(this,t,(t=>{this.h._attachFloatVectorListener(t)}))}attachStringListener(t,e){Hn(this,t,e),zn(this,t,(t=>{this.h._attachStringListener(t)}))}attachStringVectorListener(t,e){$n(this,t,e),zn(this,t,(t=>{this.h._attachStringVectorListener(t)}))}attachProtoListener(t,e,n){Hn(this,t,e),zn(this,t,(t=>{this.h._attachProtoListener(t,n||!1)}))}attachProtoVectorListener(t,e,n){$n(this,t,e),zn(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?'),Hn(this,t,((t,n)=>{t=new Float32Array(t.buffer,t.byteOffset,t.length/4),e(t,n)})),zn(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 Kn{X(){this.h._registerModelResourcesGraphService()}});var Kn;async function Yn(t,e){const n=await(async(t,e,n)=>{var r=Lr;if(t&&await Rn(t),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(e&&(await Rn(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 Jn(t,e){return Yn(t,e)}function Xn(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 Zn(t,e){t.G=Math.max(t.G,e)}var Qn=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.X(),this.i.setGraph(t,e),Xn(this)}finishProcessing(){this.i.finishProcessing(),Xn(this)}close(){this.i.closeGraph()}};Qn.prototype.close=Qn.prototype.close;var tr=class extends ye{constructor(t){super(t)}};function er(t,e){ue(t,1,e)}var nr=class extends ye{constructor(){super()}},rr=[0,yn,sn,tn,-1,rn];function ir(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 or{constructor(t){this.i=[],this.data=t,this.length=t.length}}var sr=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 ar(t){if(t.i)try{t.h._free(t.j)}catch{}finally{t.i=!1}}var ur=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))}},lr=class extends ye{constructor(){super()}};lr.prototype.i=bn([0,hn,2,cn,sn,ln]);var cr=class extends ye{constructor(){super()}},hr=class extends ye{constructor(){super()}},fr=class extends ye{constructor(){super()}},dr=class extends ye{constructor(){super()}},pr=[0,sn,-6,1,sn,1,[0,ln,yn,-2],[0,ln,tn],yn,-2,[0,ln,-1,yn,tn,_n,rn],1,ln,sn,rn,-1,[0,yn,sn],ln,-1],gr=[0,[4,6],pr,sn,1,an,cn,fn,vn,[0,hn,-2],rn,[0,[0,sn,-1,Qe,[0,sn,[0,sn,-1],-1,[0,yn,-1],ln],ln,-2,sn,-1],[0,sn,-1,ln],pr,ln,sn]],mr=[0,Qe,[0,hn,nn,-1,yn],gr,sn];dr.prototype.i=bn([0,hn,8,[0,ln,-6],1,sn,1,sn,mr,[0,sn,ln,-3],1,yn,hn,gr,mr,sn,5,yn,on,1,rr]);var _r=class extends ye{constructor(){super()}},vr=class extends ye{constructor(){super()}},yr=[2,4];vr.prototype.i=bn([0,yr,sn,fn,sn,mn,[0,1,hn]]);const br=function(t){return class e extends t{static async Y(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 n=await n.requestAdapterInfo(),r.adapterInfo=n,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}S(){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 or(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 l=Math.min(r,u.length-n);if(void 0===(n=ir(u,n,l,i)))throw Error("Data has already been released.");if(e.HEAPU8.set(n,o+s),n=0,s+=l,0==(r-=l))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{R(t,e){zn(this,"lora_model_ref_in",(n=>{this.h._addRawDataSpanToInputStream(t.offset,t.size,n,e)}))}}}(class extends qn{})));class wr extends br{}var Sr=class{constructor(t){this.j=t,this.i=Ar,Ar++}},Ar=0;class Tr{constructor(){let t,e;this.promise=new Promise(((n,r)=>{t=n,e=r})),this.resolve=t,this.reject=e}}async function Er(){const t=await wr.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}e={requiredFeatures:["shader-f16"],requiredLimits:{maxStorageBufferBindingSize:524550144,maxBufferSize:e}};const n=t.features.has("chromium-experimental-subgroups"),r=t.features.has("subgroups");if(n||r){console.warn("Experimental Chromium WGSL subgroup support detected. Enabling this feature in the inference engine.");const i=["shader-f16"];r&&(i.push("subgroups"),t.features.has("subgroups-f16")&&i.push("subgroups-f16")),n&&i.push("chromium-experimental-subgroups"),e.requiredFeatures=i}return wr.Y(e,t)}function Ir(t){const e=function(t){const e=new kn;_e(e,10,"text_in"),_e(e,10,"token_cost_in"),_e(e,10,"lora_model_id_to_apply_in"),_e(e,10,"lora_model_ref_in"),_e(e,10,"lora_model_id_to_load_in"),_e(e,16,"streaming_reader"),_e(e,15,"text_out"),_e(e,15,"text_end"),_e(e,15,"token_cost_out");var n=new Ln;ge(n,2,"TokenizerInputBuildCalculator"),_e(n,3,"PROMPT:text_in"),_e(n,3,"LORA_ID:lora_model_id_to_apply_in"),_e(n,4,"prompt"),Nn(e,n),ge(n=new Ln,2,"ModelDataCalculator"),_e(n,6,"MODEL_DATA:__side_packet_1"),_e(n,6,"MODEL_TYPE:model_type"),_e(n,5,"READ_DATA_FN:streaming_reader"),_e(n,3,"LORA_MODEL_SPAN:lora_model_ref_in"),_e(n,3,"LORA_MODEL_ID:lora_model_id_to_load_in"),_e(n,4,"LORA_DATA:lora_model_data"),Nn(e,n),ge(n=new Ln,2,"Gpt2UnicodeMappingCalculator"),_e(n,5,"MODEL_TYPE:model_type"),_e(n,6,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),Nn(e,n),ge(n=new Sn,1,"type.googleapis.com/odml.infra.proto.TokenizerCalculatorOptions");var r,i=new vr,o=de(t.j,2);pe(i,1,o),ge(o=new _r,2,"spm_vocab_model"),null==o&&(o=void 0);t:{var s=i.m,a=q(s);if(it(a),null==o){var u=oe(s);if(4!==se(u,s,a))break t;u.set(yr,0)}else{var l=oe(u=s),c=se(l,u,a);4!==c&&(c&&(a=te(u,a,c)),l.set(yr,4))}te(s,a,4,o)}if(pe(i,3,2),wn(n,i.i()),ge(i=new Ln,2,"TokenizerCalculator"),he(i,8,Sn,n),_e(i,5,"MODEL_DATA:__side_packet_1"),_e(i,3,"PROMPT_AND_INPUT_OPTIONS:prompt"),_e(i,5,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),_e(i,6,"PROCESSOR_GETTER:__input_side_1"),_e(i,4,"IDS_AND_INPUT_OPTIONS:__stream_0"),Nn(e,i),ge(n=new Sn,1,"type.googleapis.com/odml.infra.proto.LlmGpuCalculatorOptions"),pe(i=new dr,12,3),ge(i,1,"llm.tflite"),pe(i,14,0),o=de(t.j,5),pe(i,22,o),o=ae(t.j,tr,3),ue(i,31,o),ie(o=new cr,1,!0,!1),ie(o,2,!0,!1),ie(o,5,!0,!1),ue(i,10,o),c=t.j,s=void 0===ot?2:5,u=c.m,o=q(u),l=2&o?1:s,s=ee(u,o,4),a=$(s),Yt(c,a,void 0,!1)){(4&a||Object.isFrozen(s))&&(s=D(s),a=le(a,o),o=te(u,o,4,s));let t=c=0;for(;c<s.length;c++){const e=Ot(s[c]);null!=e&&(s[t++]=e)}t<c&&(s.length=t),a=-4097&(20|(a=ne(a,o))),K(s,a&=-8193),2&a&&Object.freeze(s)}return 1===l||4===l&&32&a?re(a)||(o=a,(a|=2)!==o&&K(s,a),Object.freeze(s)):(c=5===l&&(!!(32&a)||re(a)||!!jt?.get(s)),(2===l||c)&&re(a)&&(s=D(s),a=ce(a=le(a,o),o,!1),K(s,a),o=te(u,o,4,s)),re(a)||(u=a,(a=ce(a,o,!1))!==u&&K(s,a)),c&&(r=kt(s))),me(i,29,r||s),r=new fr,pe(o=new hr,1,1),s=de(t.j,2),pe(o,2,s),ue(r,1,o),ue(i,20,r),wn(n,i.i()),ge(r=new Ln,2,"LlmGpuCalculator"),he(r,8,Sn,n),_e(r,3,"IDS_AND_INPUT_OPTIONS:__stream_0"),_e(r,3,"FINISH:finish"),_e(r,3,"LORA_DATA:lora_model_data"),_e(r,5,"MODEL_DATA:__side_packet_1"),_e(r,4,"DECODED_IDS:__stream_3"),_e(r,4,"OUTPUT_END:__stream_4"),ge(n=new Pn,1,"FINISH"),ie(n,2,!0,!1),he(r,13,Pn,n),Nn(e,r),ge(r=new Ln,2,"IsPacketPresentCalculator"),_e(r,3,"__stream_4"),_e(r,4,"text_end"),Nn(e,r),ge(r=new Sn,1,"type.googleapis.com/odml.infra.proto.DetokenizerCalculatorOptions"),n=new lr,t=de(t.j,5),pe(n,5,t),_e(n,4,"<eos>"),_e(n,4,"<|endoftext|>"),wn(r,n.i()),ge(t=new Ln,2,"DetokenizerCalculator"),he(t,8,Sn,r),_e(t,3,"IDS_AND_INPUT_OPTIONS:__stream_3"),_e(t,5,"PROCESSOR_GETTER:__input_side_1"),_e(t,5,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),_e(t,5,"MODEL_DATA:__side_packet_1"),_e(t,4,"FINISH_AND_INPUT_OPTIONS:finish"),_e(t,4,"WORDS:text_out"),Nn(e,t),ge(t=new Ln,2,"TokenCostCalculator"),_e(t,3,"PROMPT:token_cost_in"),_e(t,5,"PROCESSOR_GETTER:__input_side_1"),_e(t,5,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),_e(t,4,"NUM_TOKENS:token_cost_out"),Nn(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)=>{t.D[n].push(e)})),t.v&&0===t.A.length&&(t.F?t.v(e,!1):t.v(e[0],!1)),Zn(t,n)})),t.i.attachEmptyPacketListener("text_out",(e=>{Zn(t,e)})),t.i.attachBoolListener("text_end",((e,n)=>{if(t.l=!1,Zn(t,n),Pr(t),t.o&&(t.o.resolve(t.D.map((t=>t.join("")))),t.o=void 0),t.v)if(t.F){for(e=[],n=0;n<de(t.j,5);n++)e.push("");t.v(e,!0)}else t.v("",!0);t.F=void 0})),t.i.attachEmptyPacketListener("text_end",(e=>{t.l=!1,t.F=void 0,Zn(t,e),Pr(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.N=e,Zn(t,n)})),t.J&&t.i.addStreamingReaderToInputSidePacket(t.J,"streaming_reader");const n=e.i();return t.u?.removeEventListener("uncapturederror",t.I),t.i.S().then((()=>{t.u?.addEventListener("uncapturederror",t.I),t.A.length=0,t.setGraph(new Uint8Array(n),!0),t.finishProcessing()}))}function Pr(t){if(t.A.length>0){const e=[...t.A];if(t.A.length=0,!t.o)throw e;t.o.reject(e),t.o=void 0}}function Or(t,e,n,r){if(t.l)throw Error("Previous invocation or loading is still ongoing.");for(t.v="function"==typeof n?n:r,t.l=!0,t.D.length=0,r=0;r<de(t.j,5);r++)t.D[r]=[];if(r=t.G+1,t.i.addStringToStream(e,"text_in",r),n instanceof Sr){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 Tr,t.o.promise}var Lr=class extends Qn{constructor(t,e){if(super(new wr(t,e)),this.D=[],this.l=!1,this.A=[],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.A.push(t)},this.j=new nr,er(this.j,new jn),this.s=new tr,ue(this.j,3,this.s),Qt(this.j,2,Lt(512)),t=this.s,!Number.isFinite(2))throw j("enum");ie(t,1,2,0),pe(this.s,2,40),ie(this.s,3,St(1),0),Qt(this.s,5,Pt(0)),ie(this.s,4,St(.8),0),Qt(this.j,5,Lt(1))}K(t){if(this.l)throw Error("Cannot set options while loading or processing.");if(this.l=!0,t.baseOptions?.gpuOptions?.device&&(this.u&&this.u.removeEventListener("uncapturederror",this.I),this.u=t.baseOptions.gpuOptions.device,this.i.V(this.u),this.u.addEventListener("uncapturederror",this.I)),"maxTokens"in t&&Qt(this.j,2,Lt(t.maxTokens??512)),"topK"in t&&pe(this.s,2,t.topK??40),"temperature"in t&&ie(this.s,4,St(t.temperature??.8),0),"randomSeed"in t&&Qt(this.s,5,Pt(t.randomSeed??0)),"loraRanks"in t&&function(t,e){me(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.");Qt(this.j,5,Lt(e));var n=ae(this.j,tr,3);e>1&&n&&(fe(Ot(Jt(n,2)))<=1||fe(function(t){t=t.m;let e=q(t);const n=Zt(t,e,4),r=At(n);return null!=r&&r!==n&&te(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 sr([],(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 sr([new or(t)],(()=>Promise.resolve(void 0)),e)}(t.baseOptions.modelAssetBuffer,r),n=!0):t.baseOptions.modelAssetBuffer?(this.J=function(t,e){return new sr([],(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=Ir(this).then((()=>{})),Promise.all([e,t]).then((()=>{this.l=!1,Pr(this)}))}get baseOptions(){return ae(this.j,jn,1)}set baseOptions(t){er(this.j,t)}T(t,e,n){return de(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,Or(this,t,e,n).then((t=>t[0]))}U(t,e,n){return this.F=!0,Or(this,t,e,n)}Z(t){if(this.l)throw Error("Previous invocation or loading is still ongoing.");return this.l=!0,this.N=void 0,this.i.addStringToStream(t,"token_cost_in",this.G+1),this.finishProcessing(),this.l=!1,this.N}async W(t){if(this.l)throw Error("Cannot load LoRA model while loading or processing.");if(this.l=!0,t instanceof Uint8Array){var e=new ur(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 ur(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 ar(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 Sr(this),this.i.R(t,this.G+1),this.i.addUintToStream(e.i,"lora_model_id_to_load_in",this.G+1),this.finishProcessing(),ar(t),this.l=!1,e}close(){this.u?.removeEventListener("uncapturederror",this.I),super.close()}};Lr.prototype.loadLoraModel=Lr.prototype.W,Lr.prototype.sizeInTokens=Lr.prototype.Z,Lr.prototype.generateResponses=Lr.prototype.U,Lr.prototype.generateResponse=Lr.prototype.T,Lr.prototype.setOptions=Lr.prototype.K,Lr.createWebGpuDevice=Er,Lr.createFromModelPath=async function(t,e){return Jn(t,e={baseOptions:{gpuOptions:{device:await Er()},modelAssetPath:e}})},Lr.createFromModelBuffer=async function(t,e){return Jn(t,e={baseOptions:{gpuOptions:{device:await Er()},modelAssetBuffer:e}})},Lr.createFromOptions=async function(t,e){if(!e.baseOptions?.gpuOptions?.device){const t=await Er();e.baseOptions=e.baseOptions??{},e.baseOptions.gpuOptions=e?.baseOptions?.gpuOptions??{},e.baseOptions.gpuOptions.device=t}return Jn(t,e)};export{Cn as FilesetResolver,Lr as LlmInference,Qn as TaskRunner};
1
+ var t="undefined"!=typeof self?self:{};function e(e,n){t:{for(var r=["CLOSURE_FLAGS"],i=t,o=0;o<r.length;o++)if(null==(i=i[r[o]])){r=null;break t}r=i}return null!=(e=r&&r[e])?e:n}let n;const r="undefined"!=typeof TextEncoder;function i(t){if(r)t=(n||=new TextEncoder).encode(t);else{let n=0;const r=new Uint8Array(3*t.length);for(let i=0;i<t.length;i++){var e=t.charCodeAt(i);if(e<128)r[n++]=e;else{if(e<2048)r[n++]=e>>6|192;else{if(e>=55296&&e<=57343){if(e<=56319&&i<t.length){const o=t.charCodeAt(++i);if(o>=56320&&o<=57343){e=1024*(e-55296)+o-56320+65536,r[n++]=e>>18|240,r[n++]=e>>12&63|128,r[n++]=e>>6&63|128,r[n++]=63&e|128;continue}i--}e=65533}r[n++]=e>>12|224,r[n++]=e>>6&63|128}r[n++]=63&e|128}}t=n===r.length?r:r.subarray(0,n)}return t}var o,s=e(610401301,!1),a=e(653718497,e(1,!0)),u=e(660014094,!1);const l=t.navigator;function c(t){return!!s&&(!!o&&o.brands.some((({brand:e})=>e&&-1!=e.indexOf(t))))}function h(e){var n;return(n=t.navigator)&&(n=n.userAgent)||(n=""),-1!=n.indexOf(e)}function f(){return!!s&&(!!o&&o.brands.length>0)}function d(){return f()?c("Chromium"):(h("Chrome")||h("CriOS"))&&!(!f()&&h("Edge"))||h("Silk")}o=l&&l.userAgentData||null;var p=!f()&&(h("Trident")||h("MSIE"));!h("Android")||d(),d(),h("Safari")&&(d()||!f()&&h("Coast")||!f()&&h("Opera")||!f()&&h("Edge")||(f()?c("Microsoft Edge"):h("Edg/"))||f()&&c("Opera"));var g={},m=null;function _(t){var e=t.length,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);var r=new Uint8Array(n),i=0;return function(t,e){function n(e){for(;r<t.length;){var n=t.charAt(r++),i=m[n];if(null!=i)return i;if(!/^[\s\xa0]*$/.test(n))throw Error("Unknown base64 encoding at char: "+n)}return e}v();for(var r=0;;){var i=n(-1),o=n(0),s=n(64),a=n(64);if(64===a&&-1===i)break;e(i<<2|o>>4),64!=s&&(e(o<<4&240|s>>2),64!=a&&e(s<<6&192|a))}}(t,(function(t){r[i++]=t})),i!==n?r.subarray(0,i):r}function v(){if(!m){m={};for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"],n=0;n<5;n++){var r=t.concat(e[n].split(""));g[n]=r;for(var i=0;i<r.length;i++){var o=r[i];void 0===m[o]&&(m[o]=i)}}}}var b="undefined"!=typeof Uint8Array,y=!p&&"function"==typeof btoa;function w(t){if(!y){var e;void 0===e&&(e=0),v(),e=g[e];var n=Array(Math.floor(t.length/3)),r=e[64]||"";let u=0,l=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[l++]=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[l]=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 S=/[-_.]/g,A={"-":"+",_:"/",".":"="};function T(t){return A[t]||""}function E(t){if(!y)return _(t);S.test(t)&&(t=t.replace(S,T)),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 I(t){return b&&null!=t&&t instanceof Uint8Array}var P={};let O;function L(t){if(t!==P)throw Error("illegal external caller")}function N(){return O||=new U(null,P)}var U=class{constructor(t,e){if(L(e),this.M=t,null!=t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}};function B(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}let x;function k(){const e=Error();B(e,"incident"),function(e){t.setTimeout((()=>{throw e}),0)}(e)}function j(t){return B(t=Error(t),"warning"),t}function F(){return"function"==typeof BigInt}function D(t){return Array.prototype.slice.call(t)}var M="function"==typeof Symbol&&"symbol"==typeof Symbol();function V(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol():t}var C=V(),G=V("2ex"),R=V("1oa"),z=V("0dg"),W=M?(t,e)=>{t[C]|=e}:(t,e)=>{void 0!==t.s?t.s|=e:Object.defineProperties(t,{s:{value:e,configurable:!0,writable:!0,enumerable:!1}})},H=M?(t,e)=>{t[C]&=~e}:(t,e)=>{void 0!==t.s&&(t.s&=~e)},$=M?t=>0|t[C]:t=>0|t.s,q=M?t=>t[C]:t=>t.s,K=M?(t,e)=>{t[C]=e}:(t,e)=>{void 0!==t.s?t.s=e:Object.defineProperties(t,{s:{value:e,configurable:!0,writable:!0,enumerable:!1}})};function Y(t,e){K(e,-14591&(0|t))}function J(t,e){K(e,-14557&(34|t))}var X,Z={},Q={};function tt(t){return!(!t||"object"!=typeof t||t.i!==Q)}function et(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)&&t.constructor===Object}function nt(t){return!(!Array.isArray(t)||t.length)&&!!(1&$(t))}const rt=[];function it(t){if(2&t)throw Error()}K(rt,55),X=Object.freeze(rt);var ot=Object.freeze({});Object.freeze({});var st=Object.freeze({}),at="function"==typeof t.BigInt&&"bigint"==typeof t.BigInt(0);const ut=Number.MIN_SAFE_INTEGER.toString(),lt=at?BigInt(Number.MIN_SAFE_INTEGER):void 0,ct=Number.MAX_SAFE_INTEGER.toString(),ht=at?BigInt(Number.MAX_SAFE_INTEGER):void 0;function ft(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 dt,pt=0,gt=0;function mt(t){const e=t>>>0;pt=e,gt=(t-e)/4294967296>>>0}function _t(t){if(t<0){mt(-t);const[e,n]=wt(pt,gt);pt=e>>>0,gt=n>>>0}else mt(t)}function vt(t,e){if(t>>>=0,(e>>>=0)<=2097151)var n=""+(4294967296*e+t);else F()?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+bt(n)+bt(t));return n}function bt(t){return t=String(t),"0000000".slice(t.length)+t}function yt(t){if(t.length<16)_t(Number(t));else if(F())t=BigInt(t),pt=Number(t&BigInt(4294967295))>>>0,gt=Number(t>>BigInt(32)&BigInt(4294967295));else{const e=+("-"===t[0]);gt=pt=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));gt*=1e6,pt=1e6*pt+e,pt>=4294967296&&(gt+=Math.trunc(pt/4294967296),gt>>>=0,pt>>>=0)}if(e){const[t,e]=wt(pt,gt);pt=t,gt=e}}}function wt(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}function St(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 At(t){return null==t||"number"==typeof t?t:"NaN"===t||"Infinity"===t||"-Infinity"===t?Number(t):void 0}const Tt=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function Et(t){const e=typeof t;switch(e){case"bigint":return!0;case"number":return Number.isFinite(t)}return"string"===e&&Tt.test(t)}function It(t){if("number"!=typeof t)throw j("int32");if(!Number.isFinite(t))throw j("int32");return 0|t}function Pt(t){return null==t?t:It(t)}function Ot(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 Lt(t){if(null!=t){if("number"!=typeof t)throw j("uint32");if(!Number.isFinite(t))throw j("uint32");t>>>=0}return t}function Nt(t){return"-"!==t[0]&&(t.length<20||20===t.length&&Number(t.substring(0,6))<184467)}function Ut(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(BigInt.asUintN(64,t));if(Et(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)),Nt(t)||(yt(t),t=vt(pt,gt))),t;if("number"===e)return(t=Math.trunc(t))>=0&&Number.isSafeInteger(t)?t:function(t){if(t<0){_t(t);const e=vt(pt,gt);return t=Number(e),Number.isSafeInteger(t)?t:e}return Nt(String(t))?t:(_t(t),4294967296*gt+(pt>>>0))}(t)}}function Bt(t){return null==t||"string"==typeof t?t:void 0}function xt(t,e,n){if(null!=t&&"object"==typeof t&&t.O===Z)return t;if(Array.isArray(t)){var r=$(t),i=r;return 0===i&&(i|=32&n),(i|=2&n)!==r&&K(t,i),new e(t)}}function kt(t){if(void 0===Dt&&(Dt="function"==typeof Proxy?$t(Proxy):null),!Dt||!Ht())return t;let e=jt?.get(t);return e||(Math.random()>.01?t:(function(t){if(void 0===Vt){const t=new Dt([],{});Vt=1===Array.prototype.concat.call([],t).length}Vt&&"function"==typeof Symbol&&Symbol.isConcatSpreadable&&(t[Symbol.isConcatSpreadable]=!0)}(t),e=new Dt(t,{set:(t,e,n)=>(k(),t[e]=n,!0)}),function(t,e){(jt||=new Mt).set(t,e),(Ft||=new Mt).set(e,t)}(t,e),e))}let jt,Ft,Dt,Mt,Vt,Ct,Gt,Rt,zt,Wt;function Ht(){return void 0===Mt&&(Mt="function"==typeof WeakMap?$t(WeakMap):null),Mt}function $t(t){try{return-1!==t.toString().indexOf("[native code]")?t:null}catch{return null}}function qt(t,e,n){if(a&&Ht()){if(Ct?.get(e)?.get(t)){if(n)return}else if(Math.random()>.01)return;var r=t.length;n={length:r};for(var i=0;i<Math.min(r,10);i++){if(r<=10)var o=i;else{o=r/10;const t=Math.floor(i*o);o=t+Math.floor(Math.random()*(Math.floor((i+1)*o)-t))}n[o]=t[o]}Yt(t,n)?((i=(r=Ct||=new Mt).get(e))||(i=new Mt,r.set(e,i)),i.set(t,n)):(k(),Xt(t,e))}}function Kt(t,e){const n=Ct?.get(e)?.get(t);n&&!Yt(t,n)&&(k(),Xt(t,e))}function Yt(t,e){if(t.length!==e.length)return!1;for(const i in e){var n,r=Number(i);if((n=Number.isInteger(r))&&(n=t[r],r=e[r],n=!(Number.isNaN(n)?Number.isNaN(r):n===r)),n)return!1}return!0}function Jt(t){if(t&&Ct?.has(t)){var e=t.m;if(e)for(let n=0;n<e.length;n++){const r=e[n];if(n===e.length-1&&et(r))for(const e in r){const n=r[e];Array.isArray(n)&&Kt(n,t)}else Array.isArray(r)&&Kt(r,t)}}}function Xt(t,e){Ct?.get(e)?.delete(t)}function Zt(t,e,n){if(null==t&&(t=Gt),Gt=void 0,null==t){var r=96;n?(t=[n],r|=512):t=[],e&&(r=-33521665&r|(1023&e)<<15)}else{if(!Array.isArray(t))throw Error("narr");if(2048&(r=$(t)))throw Error("farr");if(64&r)return t;if(r|=64,n&&(r|=512,n!==t[0]))throw Error("mid");t:{const i=(n=t).length;if(i){const t=i-1;if(et(n[t])){if((e=t-(+!!(512&(r|=256))-1))>=1024)throw Error("pvtlmt");r=-33521665&r|(1023&e)<<15;break t}}if(e){if((e=Math.max(e,i-(+!!(512&r)-1)))>1024)throw Error("spvt");r=-33521665&r|(1023&e)<<15}}}return K(t,r),t}function Qt(t,e,n,r,i){if(null!=t){if(Array.isArray(t))t=nt(t)?void 0:i&&2&$(t)?t:te(t,e,n,void 0!==r,i);else if(et(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?$(t):0;r=r?!!(32&o):void 0,t=D(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.O===Z?t.toJSON():function(t){switch(typeof t){case"number":return isFinite(t)?t:String(t);case"bigint":return(at?t>=lt&&t<=ht:"-"===t[0]?ft(t,ut):ft(t,ct))?Number(t):String(t);case"boolean":return t?1:0;case"object":if(t)if(Array.isArray(t)){if(nt(t))return}else{if(I(t))return w(t);if(t instanceof U){const e=t.M;return null==e?"":"string"==typeof e?e:t.M=w(e)}}}return t}(t)}function ne(t,e,n=J){if(null!=t){if(b&&t instanceof Uint8Array)return e?t:new Uint8Array(t);if(Array.isArray(t)){var r=$(t);return 2&r?t:(e&&=0===r||!!(32&r)&&!(64&r||!(16&r)),e?(K(t,-12293&(34|r)),t):te(t,ne,4&r?J:n,!0,!0))}return t.O===Z&&(n=t.m,t=2&(r=q(n))?t:re(t,n,r,!0)),t}}function re(t,e,n,r){return Jt(t),t=t.constructor,Gt=e=function(t,e,n){const r=n||2&e?J:Y,i=!!(32&e);return t=function(t,e,n){var r=(t=D(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))),W(t,32|(n?2:0)),t}(e,n,r),e=new t(e),Gt=void 0,e}function ie(t){const e=t.m,n=q(e);return 2&n?re(t,e,n,!1):t}function oe(t,e,n,r){return!(4&e)||null!=n&&(!r&&0===n&&(4096&e||8192&e)&&(t.constructor[z]=1+(0|t.constructor[z]))<5&&k(),0!==n&&!(n&e))}function se(t,e){return ue(t=t.m,q(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!=G&&((e=(t=x??={})[G]||0)>=4||(t[G]=e+1,k())),r):ae(t,e,i,n)}return 256&e?t[t.length-1][n]:void 0}function le(t,e,n){const r=t.m;let i=q(r);return it(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&&K(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,o){const s=t.m;let a=q(s);r=2&a?1:r,o=!!o,i=fe(s,a,e,i);var u=$(i),l=i;if(Kt(l,t),2!==r&&1!==r||Xt(l,t),oe(t,u,void 0,o)){4&u&&(i=D(i),u=ye(u,a),a=ce(s,a,e,i));let t=l=0;for(;l<i.length;l++){const e=n(i[l]);null!=e&&(i[t++]=e)}t<l&&(i.length=t),u=-4097&(20|(u=de(u,a))),K(i,u&=-8193),2&u&&Object.freeze(i)}let c;return 1===r||4===r&&32&u?pe(u)||(t=u,(u|=2)!==t&&K(i,u),Object.freeze(i)):(n=5===r&&(!!(32&u)||pe(u)||!!jt?.get(i)),(2===r||n)&&pe(u)&&(i=D(i),u=we(u=ye(u,a),a,o),K(i,u),a=ce(s,a,e,i)),pe(u)||(e=u,(u=we(u,a,o))!==e&&K(i,u)),n?(c=kt(i),qt(i,t,!0)):2!==r||o||jt?.delete(i)),c||i}function fe(t,e,n,r){return t=ue(t,e,n,r),Array.isArray(t)?t:X}function de(t,e){return 0===t&&(t=ye(t,e)),1|t}function pe(t){return!!(2&t)&&!!(4&t)||!!(2048&t)}function ge(t,e,n,r){t=t.m;let i=q(t);it(i),ce(t,i,e,("0"===r?0===Number(n):n===r)?void 0:n)}function me(t){if(M)return t[R]??(t[R]=new Map);if(R in t)return t[R];const e=new Map;return Object.defineProperty(t,R,{value:e}),e}function _e(t,e,n){var r=Nr;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=ce(e,n,i)),i=o)}return t.set(r,i),i}function ve(t,e,n){var r=t.m,i=q(r),o=ue(r,i,n,!1);return(e=xt(o,e,i))!==o&&null!=e&&ce(r,i,n,e),null==(r=e)||(t=t.m,2&(i=q(t))||(o=ie(r))!==r&&ce(t,i,n,r=o)),r}function be(t,e,n){return null==n&&(n=void 0),le(t,e,n)}function ye(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=q(t.m);it(i);const o=t.m;var s=!!(2&i);const a=s?1:2;d&&=!s,s=fe(o,i,e);var u=$(s),l=s;if(Kt(l,t),2!==a&&1!==a||Xt(l,t),!(l=!!(4&u))){var c=s,h=i,f=!!(2&(u=de(u,i)));f&&(h|=2);let t=!f,e=!0,r=0,o=0;for(;r<c.length;r++){const i=xt(c[r],n,h);if(i instanceof n){if(!f){const n=!!(2&$(i.m));t&&=!n,e&&=n}c[o++]=i}}o<r&&(c.length=o),u|=4,u=e?16|u:-17&u,K(c,u=t?8|u:-9&u),f&&Object.freeze(c)}if(d&&!(8&u||!s.length&&(1===a||4===a&&32&u))){pe(u)?(s=D(s),u=ye(u,i),i=ce(o,i,e,s)):Xt(s,t);var d=s;for(c=u,u=0;u<d.length;u++)(h=d[u])!==(f=ie(h))&&(d[u]=f);c|=8,c=d.length?-17&c:16|c,K(d,c),u=c}if(1===a||4===a&&32&u)pe(u)||(t=u,(u|=!s.length||16&u&&(!l||32&u)?2:2048)!==t&&K(s,u),Object.freeze(s));else if(l=5===a&&(!!(32&u)||pe(u)||!!jt?.get(s)),(2===a||l)&&pe(u)&&(s=D(s),u=we(u=ye(u,i),i,!0),K(s,u),i=ce(o,i,e,s)),pe(u)||(e=u,(u=we(u,i,!0))!==e&&K(s,u)),l){var p=kt(s);qt(s,t,!0)}p=p||s,n=null!=r?r:new n,p.push(n),2&$(n.m)?H(p,8):H(p,16)}function Ae(t){return t??0}function Te(t,e){return Ae(function(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}(se(t,e)))}function Ee(t,e,n){ge(t,e,Pt(n),0)}function Ie(t,e,n){if(null!=n&&"string"!=typeof n)throw Error();ge(t,e,n,"")}function Pe(t,e,n){{const a=t.m;let u=q(a);if(it(u),null==n)ce(a,u,e);else{n=Ft?.get(n)||n;var r,i=$(n),o=i,s=!!(2&i)||Object.isFrozen(n);if((r=!s)&&(r=void 0===st||!1),oe(t,i)){i=21,s&&(n=D(n),o=0,i=we(i=ye(i,u),u,!0));for(let t=0;t<n.length;t++)n[t]=It(n[t])}r?(n=D(n),o=0,i=we(i=ye(i,u),u,!0)):s||qt(n,t),i!==o&&K(n,i),ce(a,u,e,n)}}}function Oe(t,e,n){if(it(q(t.m)),e=(t=he(t,e,Bt,2,void 0,!0)).push,"string"!=typeof n)throw Error();e.call(t,n)}function Le(t){if("string"==typeof t)return{buffer:E(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===U){L(P);var e=t.M;return{buffer:(null==(e=null==e||I(e)?e:"string"==typeof e?E(e):null)?e:t.M=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 Ne=class{constructor(t,e){this.m=Zt(t,e)}toJSON(){return Ue(this)}C(){return!!(2&$(this.m))}};function Ue(t){Jt(t),t=Wt?t.m:te(t.m,ee,void 0,void 0,!1);{var e=!Wt;let l=t.length;if(l){var n=t[l-1],r=et(n);r?l--: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)&&(nt(r)||tt(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(;l>0&&(null==(o=i[l-1])||nt(o)||tt(o)&&0===o.size);l--)var u=!0;(i!==t||s||u)&&(e?(u||s||a)&&(i.length=l):i=Array.prototype.slice.call(i,0,l),a&&i.push(a)),u=i}else u=t}return u}function Be(t){return t?/^\d+$/.test(t)?(yt(t),new xe(pt,gt)):null:ke||=new xe(0,0)}Ne.prototype.O=Z,Ne.prototype.toString=function(){try{return Wt=!0,Ue(this).toString()}finally{Wt=!1}};var xe=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};let ke;function je(t){return t?/^-?\d+$/.test(t)?(yt(t),new Fe(pt,gt)):null:De||=new Fe(0,0)}var Fe=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};let De;function Me(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 Ce(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 Ge(t,e){0!==e.length&&(t.l.push(e),t.j+=e.length)}function Re(t,e){return Ve(t.i,8*e+2),e=t.i.end(),Ge(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){Ve(t.i,8*e+2),Ve(t.i,n.length),Ge(t,t.i.end()),Ge(t,n)}class He{constructor(t,e){this.i=t,this.S=e}}function $e(t,e){if(Array.isArray(e)){var n=$(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),K(e,-12289&(5|n)),2&n&&Object.freeze(e),e}}const qe=Symbol();function Ke(t){let e=t[qe];if(!e){const n=Ze(t);e=(t,e)=>tn(t,e,n),t[qe]=e}return e}const Ye=Symbol();function Je(t){return t.i}function Xe(t,e){let n,r;const i=t.i;return(t,o,s)=>i(t,o,s,r||=Ze(e).i,n||=Ke(e))}function Ze(t){var e=t[Ye];if(e)return e;var n=Je,r=Xe;(e=t[Ye]={}).i=function(t){switch(typeof t){case"boolean":return Rt||=[0,void 0,!0];case"number":return t>0?void 0:0===t?zt||=[0,void 0]:[-t,void 0];case"string":return[0,t];case"object":return t}}(t[0]);let i=0;var o=t[++i];o&&o.constructor===Object&&(e.N=o,"function"==typeof(o=t[++i])&&(e.l=o,e.j=t[++i],o=t[++i]));const s={};for(;Array.isArray(o)&&"number"==typeof o[0]&&o[0]>0;){for(var a=0;a<o.length;a++)s[o[a]]=o;o=t[++i]}for(a=1;void 0!==o;){let f;"number"==typeof o&&(a+=o,o=t[++i]);var u=void 0;if(o instanceof He?f=o:(f=In,i--),f.S){o=t[++i],u=t;var l=i;"function"==typeof o&&(o=o(),u[l]=o),u=o}let d=a+1;for("number"==typeof(o=t[++i])&&o<0&&(d-=o,o=t[++i]);a<d;a++){var c=s[a];l=e;var h=a;c=u?r(f,u):n(f),l[h]=c}}return e}function Qe(t,e){var n=t[e];if(n)return n;if(n=t.N){var r=n[e];if(r){var i=(r=Array.isArray(r)?r[0]instanceof He?r:[En,r]:[r,void 0])[0].i;if(r=r[1],n=n.D?.[e],!u||n){if(r){const e=Ke(r),o=Ze(r).i;n=(n=t.j)?n(o,e):(t,n,r)=>i(t,n,r,o,e)}else n=i;return t[e]=n}}}}function tn(t,e,n){for(var r=q(t),i=+!!(512&r)-1,o=t.length,s=512&r?1:0,a=o+(256&r?-1:0);s<a;s++){const r=t[s];if(null==r)continue;const o=s-i,a=Qe(n,o);if(!a)continue;const u=n.N;u?.[o]&&!u?.D?.[o]&&nn++<5&&k(),a(e,r,o)}if(256&r){t=t[o-1];for(let s in t)r=+s,!Number.isNaN(r)&&(null!=(i=t[s])&&(o=Qe(n,r)))&&((a=n.N)?.[r]&&!a?.D?.[r]&&nn++<5&&k(),o(e,i,r))}}function en(t){return new He(t,!1)}let nn=0;function rn(t,e,n){null!=(e=At(e))&&(Ve(t.i,8*n+5),t=t.i,(n=dt||=new DataView(new ArrayBuffer(8))).setFloat32(0,+e,!0),gt=0,e=pt=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 on(t,e,n){null!=(e=Ot(e))&&null!=e&&(Ve(t.i,8*n),Ce(t.i,e))}function sn(t,e,n){null!=(e=null==e||"boolean"==typeof e?e:"number"==typeof e?!!e:void 0)&&(Ve(t.i,8*n),t.i.i.push(e?1:0))}function an(t,e,n){null!=(e=Bt(e))&&We(t,n,i(e))}function un(t,e,n,r,i){e instanceof Ne?(Jt(e),e=e.m):Array.isArray(e)?(e=Zt(e,r[0],r[1]),W(e,16384)):e=void 0,null!=e&&(n=Re(t,n),i(e,t),ze(t,n))}function ln(t,e,n){null!=(e=Ot(e))&&(e=parseInt(e,10),Ve(t.i,8*n),Ce(t.i,e))}var cn,hn=en(rn),fn=en(rn),dn=en((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(Et(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(yt(t),t=pt,2147483648&(e=gt))if(F())t=""+(BigInt(0|e)<<BigInt(32)|BigInt(t>>>0));else{const[n,r]=wt(t,e);t="-"+vt(n,r)}else t=vt(t,e);return t}if("number"===e){if(t=Math.trunc(t),!Number.isSafeInteger(t)){_t(t),e=pt;var n=gt;(t=2147483648&n)&&(n=~n>>>0,0==(e=1+~e>>>0)&&(n=n+1>>>0)),e=4294967296*n+(e>>>0),t=t?-e:e}return t}}}(e),null!=e){if("string"==typeof e)je(e);if(null!=e)switch(Ve(t.i,8*n),typeof e){case"number":t=t.i,_t(e),Me(t,pt,gt);break;case"bigint":n=BigInt.asUintN(64,e),n=new Fe(Number(n&BigInt(4294967295)),Number(n>>BigInt(32))),Me(t.i,n.j,n.i);break;default:n=je(e),Me(t.i,n.j,n.i)}}})),pn=en((function(t,e,n){if(null!=(e=Ut(e))){if("string"==typeof e)Be(e);if(null!=e)switch(Ve(t.i,8*n),typeof e){case"number":t=t.i,_t(e),Me(t,pt,gt);break;case"bigint":n=BigInt.asUintN(64,e),n=new xe(Number(n&BigInt(4294967295)),Number(n>>BigInt(32))),Me(t.i,n.j,n.i);break;default:n=Be(e),Me(t.i,n.j,n.i)}}})),gn=en(on),mn=new He((function(t,e,n){if(null!=(e=$e(Ot,e))&&e.length){n=Re(t,n);for(let n=0;n<e.length;n++)Ce(t.i,e[n]);ze(t,n)}}),!1),_n=en(on),vn=en(on),bn=en(sn),yn=en(sn),wn=en(an),Sn=new He((function(t,e,n){if(null!=(e=$e(Bt,e)))for(let a=0;a<e.length;a++){var r=t,o=n,s=e[a];null!=s&&We(r,o,i(s))}}),!1),An=en(an),Tn=en(an),En=new He(un,!0),In=new He(un,!0);cn=new He((function(t,e,n,r,i){if(Array.isArray(e))for(let o=0;o<e.length;o++)un(t,e[o],n,r,i)}),!0);var Pn=new He(un,!0),On=en(ln),Ln=new He((function(t,e,n){if(null!=(e=$e(Ot,e))&&e.length){n=Re(t,n);for(let n=0;n<e.length;n++)Ce(t.i,e[n]);ze(t,n)}}),!1),Nn=en(ln);function Un(t){return function(){Jt(this);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}}}};tn(this.m,e,Ze(t)),Ge(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 Bn(t,e){if(null!=e)if(Array.isArray(e))le(t,2,te(e,ee,void 0,void 0,!1));else{if(!("string"==typeof e||e instanceof U||I(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 U(e,P):N();else if(e.constructor!==U){if(!I(e))throw Error();e=e.length?new U(new Uint8Array(e),P):N()}ge(t,2,e,N())}}var xn=class extends Ne{constructor(t){super(t)}},kn=[0,An,en((function(t,e,n){if(null!=e){if(e instanceof Ne){const r=e.ca;return void(r&&(e=r(e),null!=e&&We(t,n,Le(e).buffer)))}if(Array.isArray(e))return}null!=(e=null==e||"string"==typeof e||I(e)||e instanceof U?e:void 0)&&We(t,n,Le(e).buffer)}))],jn=[0,wn,bn,-1,gn,[0,[1,2,3,4,5,6,7],Pn,[0],Pn,[0,bn,wn,bn,On,-1,Ln,wn,-1,[0,bn,-1],On,bn,-1],Pn,[0,wn,-2],Pn,[0,gn,bn,1,bn,-3],Pn,[0,gn,On,bn,-1,mn,On,-1],Pn,[0,wn,-2],Pn,[0,wn,On]],[0,wn],bn,[0,[1,3],[2,4],Pn,[0,mn],-1,Pn,[0,Sn],-1,cn,[0,wn,-1]],wn],Fn={},Dn=Fn.D={};Fn[336783863]=jn,Dn[336783863]=1;var Mn=class extends Ne{constructor(t){super(t)}},Vn=[0,dn,-1,yn,-3,dn,mn,An,_n,dn,-1,yn,_n,yn,-2,An],Cn=class extends Ne{constructor(t){super(t,500)}L(t){return be(this,7,t)}},Gn=[-1,{D:{}}],Rn=[0,wn,1,Gn],zn=[0,wn,Sn,Gn];function Wn(t,e){Se(t,1,Cn,e)}var Hn=class extends Ne{constructor(){super(void 0,500)}L(t){return be(this,1001,t)}};Hn.prototype.i=Un([-500,cn,[-500,An,-1,Sn,-3,[-2,Fn,bn],cn,kn,_n,-1,Rn,zn,cn,[0,An,yn],An,Vn,_n,Sn,987,Sn],4,cn,[-500,wn,-1,[-1,{D:{}}],998,wn],cn,[-500,wn,Sn,-1,[-2,{D:{}},bn],997,Sn,-1],_n,cn,[-500,wn,Sn,Gn,998,Sn],Sn,_n,Rn,zn,cn,[0,An,-1,Gn],Sn,-2,Vn,An,-1,yn,979,Gn,cn,kn]);var $n=class extends Ne{constructor(t){super(t)}};let qn;const Kn=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 Yn(){if(void 0===qn)try{await WebAssembly.instantiate(Kn),qn=!0}catch{qn=!1}return qn}async function Jn(t,e=""){const n=await Yn()?"wasm_internal":"wasm_nosimd_internal";return{wasmLoaderPath:`${e}/${t}_${n}.js`,wasmBinaryPath:`${e}/${t}_${n}.wasm`}}var Xn=class{};function Zn(){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 Qn(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())}Xn.forVisionTasks=function(t){return Jn("vision",t)},Xn.forTextTasks=function(t){return Jn("text",t)},Xn.forGenAiExperimentalTasks=function(t){return Jn("genai_experimental",t)},Xn.forGenAiTasks=function(t){return Jn("genai",t)},Xn.forAudioTasks=function(t){return Jn("audio",t)},Xn.isSimdSupported=function(){return Yn()};function tr(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 er(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 nr(t,e,n){t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=n}function rr(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 ir=(or=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:Zn()?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?'),tr(this,r||"input_audio",(r=>{tr(this,i=i||"audio_header",(i=>{this.h._configureAudio(r,i,t,e,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),tr(this,r,(t=>{this.h._addAudioToInputStream(this.i,e,n,t,i)}))}addGpuBufferToStream(t,e,n){tr(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){tr(this,e,(e=>{this.h._addBoolToInputStream(t,e,n)}))}addDoubleToStream(t,e,n){tr(this,e,(e=>{this.h._addDoubleToInputStream(t,e,n)}))}addFloatToStream(t,e,n){tr(this,e,(e=>{this.h._addFloatToInputStream(t,e,n)}))}addIntToStream(t,e,n){tr(this,e,(e=>{this.h._addIntToInputStream(t,e,n)}))}addUintToStream(t,e,n){tr(this,e,(e=>{this.h._addUintToInputStream(t,e,n)}))}addStringToStream(t,e,n){tr(this,e,(e=>{tr(this,t,(t=>{this.h._addStringToInputStream(t,e,n)}))}))}addStringRecordToStream(t,e,n){tr(this,e,(e=>{er(this,Object.keys(t),(r=>{er(this,Object.values(t),(i=>{this.h._addFlatHashMapToInputStream(r,i,Object.keys(t).length,e,n)}))}))}))}addProtoToStream(t,e,n,r){tr(this,n,(n=>{tr(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){tr(this,t,(t=>{this.h._addEmptyPacketToInputStream(t,e)}))}addBoolVectorToStream(t,e,n){tr(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){tr(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){tr(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){tr(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){tr(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){tr(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)tr(this,e,(t=>{this.h._addStringVectorEntry(r,t)}));this.h._addStringVectorToInputStream(r,e,n)}))}addBoolToInputSidePacket(t,e){tr(this,e,(e=>{this.h._addBoolToInputSidePacket(t,e)}))}addDoubleToInputSidePacket(t,e){tr(this,e,(e=>{this.h._addDoubleToInputSidePacket(t,e)}))}addFloatToInputSidePacket(t,e){tr(this,e,(e=>{this.h._addFloatToInputSidePacket(t,e)}))}addIntToInputSidePacket(t,e){tr(this,e,(e=>{this.h._addIntToInputSidePacket(t,e)}))}addUintToInputSidePacket(t,e){tr(this,e,(e=>{this.h._addUintToInputSidePacket(t,e)}))}addStringToInputSidePacket(t,e){tr(this,e,(e=>{tr(this,t,(t=>{this.h._addStringToInputSidePacket(t,e)}))}))}addProtoToInputSidePacket(t,e,n){tr(this,n,(n=>{tr(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){tr(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){tr(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){tr(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){tr(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){tr(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){tr(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)tr(this,e,(t=>{this.h._addStringVectorEntry(n,t)}));this.h._addStringVectorToInputSidePacket(n,e)}))}attachBoolListener(t,e){nr(this,t,e),tr(this,t,(t=>{this.h._attachBoolListener(t)}))}attachBoolVectorListener(t,e){rr(this,t,e),tr(this,t,(t=>{this.h._attachBoolVectorListener(t)}))}attachIntListener(t,e){nr(this,t,e),tr(this,t,(t=>{this.h._attachIntListener(t)}))}attachIntVectorListener(t,e){rr(this,t,e),tr(this,t,(t=>{this.h._attachIntVectorListener(t)}))}attachUintListener(t,e){nr(this,t,e),tr(this,t,(t=>{this.h._attachUintListener(t)}))}attachUintVectorListener(t,e){rr(this,t,e),tr(this,t,(t=>{this.h._attachUintVectorListener(t)}))}attachDoubleListener(t,e){nr(this,t,e),tr(this,t,(t=>{this.h._attachDoubleListener(t)}))}attachDoubleVectorListener(t,e){rr(this,t,e),tr(this,t,(t=>{this.h._attachDoubleVectorListener(t)}))}attachFloatListener(t,e){nr(this,t,e),tr(this,t,(t=>{this.h._attachFloatListener(t)}))}attachFloatVectorListener(t,e){rr(this,t,e),tr(this,t,(t=>{this.h._attachFloatVectorListener(t)}))}attachStringListener(t,e){nr(this,t,e),tr(this,t,(t=>{this.h._attachStringListener(t)}))}attachStringVectorListener(t,e){rr(this,t,e),tr(this,t,(t=>{this.h._attachStringVectorListener(t)}))}attachProtoListener(t,e,n){nr(this,t,e),tr(this,t,(t=>{this.h._attachProtoListener(t,n||!1)}))}attachProtoVectorListener(t,e,n){rr(this,t,e),tr(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?'),nr(this,t,((t,n)=>{t=new Float32Array(t.buffer,t.byteOffset,t.length/4),e(t,n)})),tr(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 or{Z(){this.h._registerModelResourcesGraphService()}});var or;async function sr(t,e){const n=await(async(t,e,n)=>{var r=Gr;if(t&&await Qn(t),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(e&&(await Qn(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.L(e),n}async function ar(t,e){return sr(t,e)}function ur(t){try{const e=t.I.length;if(1===e)throw Error(t.I[0].message);if(e>1)throw Error("Encountered multiple errors: "+t.I.map((t=>t.message)).join(", "))}finally{t.I=[]}}function lr(t,e){t.H=Math.max(t.H,e)}var cr=class{constructor(t){this.i=t,this.I=[],this.H=0,this.i.setAutoRenderToScreen(!1)}setGraph(t,e){this.i.attachErrorListener(((t,e)=>{this.I.push(Error(e))})),this.i.Z(),this.i.setGraph(t,e),ur(this)}finishProcessing(){this.i.finishProcessing(),ur(this)}close(){this.i.closeGraph()}};cr.prototype.close=cr.prototype.close;var hr=class extends Ne{constructor(t){super(t)}};function fr(t,e){be(t,1,e)}var dr=class extends Ne{constructor(){super()}},pr=[0,Nn,_n,fn,-1,gn];function gr(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 mr{constructor(t){this.i=[],this.data=t,this.length=t.length}}var _r=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 vr(t){if(t.i)try{t.h._free(t.j)}catch{}finally{t.i=!1}}var br=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))}},yr=class extends Ne{constructor(){super()}};yr.prototype.i=Un([0,An,2,Sn,_n,yn]);var wr=class extends Ne{constructor(){super()}},Sr=class extends Ne{constructor(){super()}},Ar=class extends Ne{constructor(){super()}},Tr=class extends Ne{constructor(){super()}},Er=[0,_n,-6,1,_n,1,[0,yn,Nn,-2],[0,yn,fn],Nn,-2,[0,yn,-1,Nn,fn,On,gn],1,yn,_n,gn,-1,[0,Nn,_n],yn,-1,hn],Ir=[0,[4,6],Er,_n,1,vn,Sn,Tn,Ln,[0,An,-2],gn,[0,[0,_n,-1,cn,[0,_n,[0,_n,-1],-1,[0,Nn,-1],yn],yn,-2,_n,-1],[0,_n,-1,yn],Er,yn,_n],wn,-3],Pr=[0,cn,[0,An,pn,-1,Nn],Ir,_n];Tr.prototype.i=Un([0,An,8,[0,yn,-6],1,_n,1,_n,Pr,[0,_n,yn,-3],1,Nn,An,Ir,Pr,_n,5,Nn,mn,1,pr]);var Or=class extends Ne{constructor(){super()}},Lr=class extends Ne{constructor(){super()}},Nr=[2,4];Lr.prototype.i=Un([0,Nr,_n,Tn,_n,Pn,[0,1,An]]);const Ur=function(t){return class e extends t{static async aa(t,n){let r;n||=await e.R();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 n=await n.requestAdapterInfo(),r.adapterInfo=n,r}static async R(t){if(!(t=await navigator.gpu.requestAdapter(t)))throw Error("Unable to request adapter from navigator.gpu; Ensure WebGPU is enabled.");return t}X(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}U(){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 mr(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 l=Math.min(r,u.length-n);if(void 0===(n=gr(u,n,l,i)))throw Error("Data has already been released.");if(e.HEAPU8.set(n,o+s),n=0,s+=l,0==(r-=l))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{T(t,e){tr(this,"lora_model_ref_in",(n=>{this.h._addRawDataSpanToInputStream(t.offset,t.size,n,e)}))}}}(class extends ir{})));class Br extends Ur{}var xr=class{constructor(t){this.j=t,this.i=kr,kr++}},kr=0;class jr{constructor(){let t,e;this.promise=new Promise(((n,r)=>{t=n,e=r})),this.resolve=t,this.reject=e}}function Fr(t){return 1===t?1:t+t%2}async function Dr(){const t=await Br.R({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}},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 Br.aa(e,t)}function Mr(t){const e=function(t){const e=new Hn;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 Cn;Ie(n,2,"TokenizerInputBuildCalculator"),Oe(n,3,"PROMPT:text_in"),Oe(n,3,"LORA_ID:lora_model_id_to_apply_in"),Oe(n,4,"prompt"),Wn(e,n),Ie(n=new Cn,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"),Wn(e,n),Ie(n=new Cn,2,"Gpt2UnicodeMappingCalculator"),Oe(n,5,"MODEL_TYPE:model_type"),Oe(n,6,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),Wn(e,n),Ie(n=new xn,1,"type.googleapis.com/odml.infra.proto.TokenizerCalculatorOptions");var r=new Lr,i=Te(t.j,2);Ee(r,1,i),Ie(i=new Or,2,"spm_vocab_model"),null==i&&(i=void 0);t:{var o=r.m,s=q(o);if(it(s),null==i){var a=me(o);if(4!==_e(a,o,s))break t;a.set(Nr,0)}else{const t=me(a=o),e=_e(t,a,s);4!==e&&(e&&(s=ce(a,s,e)),t.set(Nr,4))}ce(o,s,4,i)}return Ee(r,3,2),Bn(n,r.i()),Ie(r=new Cn,2,"TokenizerCalculator"),Se(r,8,xn,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"),Wn(e,r),Ie(n=new xn,1,"type.googleapis.com/odml.infra.proto.LlmGpuCalculatorOptions"),Ee(r=new Tr,12,3),Ie(r,1,"llm.tflite"),Ee(r,14,0),i=Fr(Te(t.j,5)),Ee(r,22,i),i=ve(t.j,hr,3),be(r,31,i),ge(i=new wr,1,!0,!1),ge(i,2,!0,!1),ge(i,5,!0,!1),be(r,10,i),i=he(t.j,4,Ot,void 0===ot?2:5),Pe(r,29,i),i=new Ar,Ee(o=new Sr,1,1),a=Te(t.j,2),Ee(o,2,a),be(i,1,o),be(r,20,i),Bn(n,r.i()),Ie(r=new Cn,2,"LlmGpuCalculator"),Se(r,8,xn,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"),Ie(n=new Mn,1,"FINISH"),ge(n,2,!0,!1),Se(r,13,Mn,n),Wn(e,r),Ie(n=new Cn,2,"IsPacketPresentCalculator"),Oe(n,3,"__stream_4"),Oe(n,4,"text_end"),Wn(e,n),Ie(n=new xn,1,"type.googleapis.com/odml.infra.proto.DetokenizerCalculatorOptions"),r=new yr,t=Fr(Te(t.j,5)),Ee(r,5,t),Oe(r,4,"<eos>"),Oe(r,4,"<|endoftext|>"),Bn(n,r.i()),Ie(t=new Cn,2,"DetokenizerCalculator"),Se(t,8,xn,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"),Wn(e,t),Ie(t=new Cn,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"),Wn(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.F.length),e.forEach(((e,n)=>{n<Te(t.j,5)&&t.F[n].push(e)})),t.A&&0===t.B.length&&(t.G?(e.length>Te(t.j,5)&&e.pop(),t.A(e,!1)):t.A(e[0],!1)),lr(t,n)})),t.i.attachEmptyPacketListener("text_out",(e=>{lr(t,e)})),t.i.attachBoolListener("text_end",((e,n)=>{if(t.l=!1,lr(t,n),Vr(t),t.o&&(t.o.resolve(t.F.map((t=>t.join("")))),t.o=void 0),t.A)if(t.G){for(e=[],n=0;n<Te(t.j,5);n++)e.push("");t.A(e,!0)}else t.A("",!0);t.G=void 0})),t.i.attachEmptyPacketListener("text_end",(e=>{t.l=!1,t.G=void 0,lr(t,e),Vr(t),t.o&&(t.o.resolve(t.F.map((t=>t.join("")))),t.o=void 0)})),t.i.attachIntListener("token_cost_out",((e,n)=>{t.P=e,lr(t,n)})),t.K&&t.i.addStreamingReaderToInputSidePacket(t.K,"streaming_reader");const n=e.i();return t.v?.removeEventListener("uncapturederror",t.J),t.i.U().then((()=>{t.v?.addEventListener("uncapturederror",t.J),t.B.length=0,t.setGraph(new Uint8Array(n),!0),t.finishProcessing()}))}function Vr(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 Cr(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.F.length=0,r=0;r<Te(t.j,5);r++)t.F[r]=[];if(r=t.H+1,t.i.addStringToStream(e,"text_in",r),n instanceof xr){if(n.j!==t)throw t.l=!1,t.G=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 Gr=class extends cr{constructor(t,e){super(new Br(t,e)),this.F=[],this.l=!1,this.B=[],this.J=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 dr,fr(this.j,new $n),this.u=new hr,be(this.j,3,this.u),le(this.j,2,Lt(512)),ge(this.u,1,2,0),Ee(this.u,2,40),ge(this.u,3,St(1),0),le(this.u,5,Pt(0)),ge(this.u,4,St(.8),0),le(this.j,5,Lt(1))}L(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.J),this.v=t.baseOptions.gpuOptions.device,this.i.X(this.v),this.v.addEventListener("uncapturederror",this.J)),"maxTokens"in t&&le(this.j,2,Lt(t.maxTokens??512)),"topK"in t&&Ee(this.u,2,t.topK??40),"temperature"in t&&ge(this.u,4,St(t.temperature??.8),0),"randomSeed"in t&&le(this.u,5,Pt(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.");le(this.j,5,Lt(e));var n=ve(this.j,hr,3);e>1&&n&&(Ae(Ot(se(n,2)))<=1||Ae(function(t){t=t.m;let e=q(t);const n=ue(t,e,4),r=At(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.K=function(t,e){const n=fetch(t.toString()).then((t=>t?.body?.getReader()));return new _r([],(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.K=function(t,e){return new _r([new mr(t)],(()=>Promise.resolve(void 0)),e)}(t.baseOptions.modelAssetBuffer,r),n=!0):t.baseOptions.modelAssetBuffer?(this.K=function(t,e){return new _r([],(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=Mr(this).then((()=>{})),Promise.all([e,t]).then((()=>{this.l=!1,Vr(this)}))}get baseOptions(){return ve(this.j,$n,1)}set baseOptions(t){fr(this.j,t)}V(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.G=!1,Cr(this,t,e,n).then((t=>t[0]))}W(t,e,n){return this.G=!0,Cr(this,t,e,n)}ba(t){if(this.l)throw Error("Previous invocation or loading is still ongoing.");return this.l=!0,this.P=void 0,this.i.addStringToStream(t,"token_cost_in",this.H+1),this.finishProcessing(),this.l=!1,this.P}async Y(t){if(this.l)throw Error("Cannot load LoRA model while loading or processing.");if(this.l=!0,t instanceof Uint8Array){var e=new br(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 br(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 vr(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 xr(this),this.i.T(t,this.H+1),this.i.addUintToStream(e.i,"lora_model_id_to_load_in",this.H+1),this.finishProcessing(),vr(t),this.l=!1,e}close(){this.v?.removeEventListener("uncapturederror",this.J),super.close()}};Gr.prototype.loadLoraModel=Gr.prototype.Y,Gr.prototype.sizeInTokens=Gr.prototype.ba,Gr.prototype.generateResponses=Gr.prototype.W,Gr.prototype.generateResponse=Gr.prototype.V,Gr.prototype.setOptions=Gr.prototype.L,Gr.createWebGpuDevice=Dr,Gr.createFromModelPath=async function(t,e){return ar(t,e={baseOptions:{gpuOptions:{device:await Dr()},modelAssetPath:e}})},Gr.createFromModelBuffer=async function(t,e){return ar(t,e={baseOptions:{gpuOptions:{device:await Dr()},modelAssetBuffer:e}})},Gr.createFromOptions=async function(t,e){if(!e.baseOptions?.gpuOptions?.device){const t=await Dr();e.baseOptions=e.baseOptions??{},e.baseOptions.gpuOptions=e?.baseOptions?.gpuOptions??{},e.baseOptions.gpuOptions.device=t}return ar(t,e)};export{Xn as FilesetResolver,Gr as LlmInference,cr as TaskRunner};
2
2
  //# sourceMappingURL=genai_bundle_mjs.js.map