@mediapipe/tasks-decision 1.1.0-rc.20261005 → 1.1.0

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.
@@ -1,2 +1,2 @@
1
- var Decision=function(t){"use strict";var e="undefined"!=typeof self?self:{};function r(t,r){t:{for(var i=["CLOSURE_FLAGS"],n=e,o=0;o<i.length;o++)if(null==(n=n[i[o]])){i=null;break t}i=n}return null!=(t=i&&i[t])?t:r}var i,n="undefined"!=typeof TextEncoder;function o(t){if(n)t=(i||=new TextEncoder).encode(t);else{let r=0,i=new Uint8Array(3*t.length);for(let n=0;n<t.length;n++){var e=t.charCodeAt(n);if(e<128)i[r++]=e;else{if(e<2048)i[r++]=e>>6|192;else{if(e>=55296&&e<=57343){if(e<=56319&&n<t.length){let o=t.charCodeAt(++n);if(o>=56320&&o<=57343){e=1024*(e-55296)+o-56320+65536,i[r++]=e>>18|240,i[r++]=e>>12&63|128,i[r++]=e>>6&63|128,i[r++]=63&e|128;continue}n--}e=65533}i[r++]=e>>12|224,i[r++]=e>>6&63|128}i[r++]=63&e|128}}t=r===i.length?i:i.subarray(0,r)}return t}var a=r(610401301,!1),s=r(748402147,!0);function l(){var t=e.navigator;return t&&(t=t.userAgent)?t:""}var u,c=e.navigator;u=c&&c.userAgentData||null;var h={},f=null;function d(t){var e=t.length,r=3*e/4;r%3?r=Math.floor(r):-1!="=.".indexOf(t[e-1])&&(r=-1!="=.".indexOf(t[e-2])?r-2:r-1);var i=new Uint8Array(r),n=0;return function(t,e){function r(e){for(;i<t.length;){let e=t.charAt(i++),r=f[e];if(null!=r)return r;if(!/^[\s\xa0]*$/.test(e))throw Error("Unknown base64 encoding at char: "+e)}return e}p();for(var i=0;;){let t=r(-1),i=r(0),n=r(64),o=r(64);if(64===o&&-1===t)break;e(t<<2|i>>4),64!=n&&(e(i<<4&240|n>>2),64!=o&&e(n<<6&192|o))}}(t,function(t){i[n++]=t}),n!==r?i.subarray(0,n):i}function p(){if(!f){f={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){let i=t.concat(e[r].split(""));h[r]=i;for(let t=0;t<i.length;t++){let e=i[t];void 0===f[e]&&(f[e]=t)}}}}var v="undefined"!=typeof Uint8Array,g=!(!(!!a&&(!!u&&u.brands.length>0))&&(-1!=l().indexOf("Trident")||-1!=l().indexOf("MSIE")))&&"function"==typeof btoa,m=/[-_.]/g,b={"-":"+",_:"/",".":"="};function y(t){return b[t]||""}function w(t){if(!g)return d(t);t=m.test(t)?t.replace(m,y):t,t=atob(t);var e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}var S,_={},A=class{constructor(t,e){if(I(e),this.i=t,null!=t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}};function I(t){if(t!==_)throw Error("illegal external caller")}function T(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}var B=void 0;function E(t){return T(t=Error(t),"warning"),t}function x(t,r){if(null!=t){var i=B??={},n=i[t]||0;n>=r||(i[t]=n+1,T(t=Error(),"incident"),function(t){e.setTimeout(()=>{throw t},0)}(t))}}function P(){return"function"==typeof BigInt}var U="function"==typeof Symbol&&"symbol"==typeof Symbol();function j(t,e,r=!1){return"function"==typeof Symbol&&"symbol"==typeof Symbol()?r&&Symbol.for&&t?Symbol.for(t):null!=t?Symbol(t):Symbol():e}var k,L=j("jas",void 0,!0),O=j(void 0,"1oa"),N=j(void 0,"0ubsb"),V=j(void 0,"0actk"),F=j("m_m","pa",!0),D={ea:{value:0,configurable:!0,writable:!0,enumerable:!1}},M=Object.defineProperties,C=U?L:"ea",G=[];function $(t,e){U||C in t||M(t,D),t[C]|=e}function z(t,e){U||C in t||M(t,D),t[C]=e}z(G,7),k=Object.freeze(G);var W={};function R(t,e){return void 0===e?t.i!==H&&!!(2&t.m[C]):!!(2&e)&&t.i!==H}var H={};function K(t,e){if(null!=t)if("string"==typeof t)t=t?new A(t,_):S||=new A(null,_);else if(t.constructor!==A)if(v&&null!=t&&t instanceof Uint8Array)t=t.length?new A(new Uint8Array(t),_):S||=new A(null,_);else{if(!e)throw Error();t=void 0}return t}function q(t){return t.oa=!0,t}var J=q(t=>"number"==typeof t),X=q(t=>"string"==typeof t),Y=q(t=>"boolean"==typeof t),Z="function"==typeof e.BigInt&&"bigint"==typeof e.BigInt(0);function Q(t){var e=t;if(X(e)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(e))throw Error(String(e))}else if(J(e)&&!Number.isSafeInteger(e))throw Error(String(e));return Z?BigInt(t):t=Y(t)?t?"1":"0":X(t)?t.trim()||"0":String(t)}var tt=q(t=>Z?t>=rt&&t<=nt:"-"===t[0]?ot(t,et):ot(t,it)),et=Number.MIN_SAFE_INTEGER.toString(),rt=Z?BigInt(Number.MIN_SAFE_INTEGER):void 0,it=Number.MAX_SAFE_INTEGER.toString(),nt=Z?BigInt(Number.MAX_SAFE_INTEGER):void 0;function ot(t,e){if(t.length>e.length)return!1;if(t.length<e.length||t===e)return!0;for(let r=0;r<t.length;r++){let i=t[r],n=e[r];if(i>n)return!1;if(i<n)return!0}}var at,st=0,lt=0;function ut(t){var e=t>>>0;st=e,lt=(t-e)/4294967296>>>0}function ct(t){if(t<0){ut(-t);let[e,r]=gt(st,lt);st=e>>>0,lt=r>>>0}else ut(t)}function ht(t,e){var r=4294967296*e+(t>>>0);return Number.isSafeInteger(r)?r:ft(t,e)}function ft(t,e){if(t>>>=0,(e>>>=0)<=2097151)var r=""+(4294967296*e+t);else P()?r=""+(BigInt(e)<<BigInt(32)|BigInt(t)):(t=(16777215&t)+6777216*(r=16777215&(t>>>24|e<<8))+6710656*(e=e>>16&65535),r+=8147497*e,e*=2,t>=1e7&&(r+=t/1e7>>>0,t%=1e7),r>=1e7&&(e+=r/1e7>>>0,r%=1e7),r=e+dt(r)+dt(t));return r}function dt(t){return t=String(t),"0000000".slice(t.length)+t}function pt(){var t=st,e=lt;if(2147483648&e)if(P())t=""+(BigInt(0|e)<<BigInt(32)|BigInt(t>>>0));else{let[r,i]=gt(t,e);t="-"+ft(r,i)}else t=ft(t,e);return t}function vt(t){if(t.length<16)ct(Number(t));else if(P())t=BigInt(t),st=Number(t&BigInt(4294967295))>>>0,lt=Number(t>>BigInt(32)&BigInt(4294967295));else{let e=+("-"===t[0]);lt=st=0;let r=t.length;for(let i=e,n=(r-e)%6+e;n<=r;i=n,n+=6){let e=Number(t.slice(i,n));lt*=1e6,(st=1e6*st+e)>=4294967296&&(lt+=Math.trunc(st/4294967296),lt>>>=0,st>>>=0)}if(e){let[t,e]=gt(st,lt);st=t,lt=e}}}function gt(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}var mt="function"==typeof BigInt?BigInt.asIntN:void 0,bt="function"==typeof BigInt?BigInt.asUintN:void 0,yt=Number.isSafeInteger,wt=Number.isFinite,St=Math.trunc;function _t(t){return null==t||"number"==typeof t?t:"NaN"===t||"Infinity"===t||"-Infinity"===t?Number(t):void 0}var At,It,Tt,Bt=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function Et(t){switch(typeof t){case"bigint":return!0;case"number":return wt(t);case"string":return Bt.test(t);default:return!1}}function xt(t){if(null==t)return t;if("string"==typeof t&&t)t=+t;else if("number"!=typeof t)return;return wt(t)?0|t:void 0}function Pt(t){var e=t.length;return("-"===t[0]?e<20||20===e&&t<="-9223372036854775808":e<19||19===e&&t<="9223372036854775807")?t:(vt(t),pt())}function Ut(t){if("-"===t[0])var e=!1;else e=(e=t.length)<20||20===e&&t<="18446744073709551615";return e?t:(vt(t),ft(st,lt))}function jt(t){if(t=St(t),!yt(t)){ct(t);var e=st,r=lt;(t=2147483648&r)&&(r=~r>>>0,0==(e=1+~e>>>0)&&(r=r+1>>>0)),t="number"==typeof(e=ht(e,r))?t?-e:e:t?"-"+e:e}return t}function kt(t){return(t=St(t))>=0&&yt(t)||(ct(t),t=ht(st,lt)),t}function Lt(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(mt(64,t));if(Et(t)){if("string"===e)return e=St(Number(t)),yt(e)?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=Pt(t)),t;if("number"===e)return jt(t)}}function Ot(t){if(null==t||"string"==typeof t||t instanceof A)return t}function Nt(t){return null==t||"string"==typeof t?t:void 0}function Vt(t,e,r){if(null!=t&&t[F]===W)return t;if(Array.isArray(t)){var i=0|t[C];return(r=i|32&r|2&r)!==i&&z(t,r),new e(t)}}function Ft(t){return t}function Dt(t,e,r,i){var n=void 0!==i;i=!!i;var o=[],a=t.length,s=4294967295,l=!1,u=!!(64&e),c=u?128&e?0:-1:void 0;if(!(1&e)){var h=a&&t[a-1];null!=h&&"object"==typeof h&&h.constructor===Object?s=--a:h=void 0,!u||128&e||n||(l=!0,s=(At??Ft)(s-c,c,t,h,void 0)+c)}for(e=void 0,n=0;n<a;n++){let a=t[n];if(null!=a&&null!=(a=r(a,i)))if(u&&n>=s){let t=n-c;(e??={})[t]=a}else o[n]=a}if(h)for(let n in h){if(null==(t=h[n])||null==(t=r(t,i)))continue;let l;a=+n,u&&!Number.isNaN(a)&&(l=a+c)<s?o[l]=t:(e??={})[n]=t}return e&&(l?o.push(e):o[s]=e),o}function Mt(t){switch(typeof t){case"number":return Number.isFinite(t)?t:""+t;case"bigint":return tt(t)?Number(t):""+t;case"boolean":return t?1:0;case"object":if(Array.isArray(t)){var e=0|t[C];return 0===t.length&&1&e?void 0:Dt(t,e,Mt)}if(null!=t&&t[F]===W)return Ct(t);if(t instanceof A){if(null==(e=t.i))t="";else if("string"==typeof e)t=e;else{if(g){for(var r="",i=0,n=e.length-10240;i<n;)r+=String.fromCharCode.apply(null,e.subarray(i,i+=10240));r+=String.fromCharCode.apply(null,i?e.subarray(i):e),e=btoa(r)}else{void 0===r&&(r=0),p(),r=h[r],i=Array(Math.floor(e.length/3)),n=r[64]||"";let t=0,u=0;for(;t<e.length-2;t+=3){var o=e[t],a=e[t+1],s=e[t+2],l=r[o>>2];o=r[(3&o)<<4|a>>4],a=r[(15&a)<<2|s>>6],s=r[63&s],i[u++]=l+o+a+s}switch(l=0,s=n,e.length-t){case 2:s=r[(15&(l=e[t+1]))<<2]||n;case 1:e=e[t],i[u]=r[e>>2]+r[(3&e)<<4|l>>4]+s+n}e=i.join("")}t=t.i=e}return t}return}return t}function Ct(t){return Dt(t=t.m,0|t[C],Mt)}function Gt(t,e,r,i=0){if(null==t){var n=32;r?(t=[r],n|=128):t=[],e&&(n=-16760833&n|(1023&e)<<14)}else{if(!Array.isArray(t))throw Error("narr");if(n=0|t[C],s&&1&n)throw Error("rfarr");if(2048&n&&!(2&n)&&function(){if(s)throw Error("carr");x(V,5)}(),256&n)throw Error("farr");if(64&n)return(n|i)!==n&&z(t,n|i),t;if(r&&(n|=128,r!==t[0]))throw Error("mid");t:{n|=64;var o=(r=t).length;if(o){var a=o-1;let t=r[a];if(null!=t&&"object"==typeof t&&t.constructor===Object){if((a-=e=128&n?0:-1)>=1024)throw Error("pvtlmt");for(var l in t)(o=+l)<a&&(r[o+e]=t[l],delete t[l]);n=-16760833&n|(1023&a)<<14;break t}}if(e){if((l=Math.max(e,o-(128&n?0:-1)))>1024)throw Error("spvt");n=-16760833&n|(1023&l)<<14}}}return z(t,64|n|i),t}function $t(t,e){if("object"!=typeof t)return t;if(Array.isArray(t)){var r=0|t[C];return 0===t.length&&1&r?t=void 0:2&r||(!e||4096&r||16&r?t=Wt(t,r,!1,e&&!(16&r)):($(t,34),4&r&&Object.freeze(t))),t}return null!=t&&t[F]===W?R(t,r=0|(e=t.m)[C])?t:qt(t,e,r)?zt(t,e):Wt(e,r):t instanceof A?t:void 0}function zt(t,e,r){return t=new t.constructor(e),r&&(t.i=H),t.o=H,t}function Wt(t,e,r,i){return i??=!!(34&e),t=Dt(t,e,$t,i),i=32,r&&(i|=2),z(t,e=16769217&e|i),t}function Rt(t){if(t.i!==H)return!1;var e=t.m;return $(e=Wt(e,0|e[C]),2048),t.m=e,t.i=void 0,t.o=void 0,!0}function Ht(t){if(!Rt(t)&&R(t,0|t.m[C]))throw Error()}function Kt(t,e){void 0===e&&(e=0|t[C]),32&e&&!(4096&e)&&z(t,4096|e)}function qt(t,e,r){return!!(2&r)||!(!(32&r)||4096&r)&&(z(e,2|r),t.i=H,!0)}function Jt(t,e,r){if(null!==(t=Xt(t.m,e,void 0,r)))return t}function Xt(t,e,r,i){if(-1===e)return null;var n=e+(r?0:-1),o=t.length-1;if(!(o<1+(r?0:-1))){if(n>=o){var a=t[o];if(null!=a&&"object"==typeof a&&a.constructor===Object){r=a[e];var s=!0}else{if(n!==o)return;r=a}}else r=t[n];if(i&&null!=r){if(null==(i=i(r)))return i;if(!Object.is(i,r))return s?a[e]=i:t[n]=i,i}return r}}function Yt(t,e,r){Ht(t);var i=t.m;return Zt(i,0|i[C],e,r),t}function Zt(t,e,r,i,n){var o=r+(n?0:-1),a=t.length-1;if(a>=1+(n?0:-1)&&o>=a){let n=t[a];if(null!=n&&"object"==typeof n&&n.constructor===Object)return n[r]=i,e}return o<=a?(t[o]=i,e):(void 0!==i&&(r>=(a=(e??=0|t[C])>>14&1023||536870912)?null!=i&&(t[a+(n?0:-1)]={[r]:i}):t[o]=i),e)}function Qt(t,e,r){return t=Xt(t,e,r),Array.isArray(t)?t:k}function te(t,e){return 2&e&&(t|=2),1|t}function ee(t){return!!(2&t)&&!!(4&t)||!!(256&t)}function re(t){return K(t,!0)}function ie(t){if(U)return t[O]??(t[O]=new Map);if(O in t)return t[O];var e=new Map;return Object.defineProperty(t,O,{value:e}),e}function ne(t,e,r,i){var n=t.get(i);if(null!=n)return n;n=0;for(let t=0;t<i.length;t++){let o=i[t];null!=Xt(e,o)&&(0!==n&&(r=Zt(e,r,n)),n=o)}return t.set(i,n),n}function oe(t,e,r){var i=t.m,n=0|i[C];if(e=function(t,e,r,i){var n=!1;if(null!=(i=Xt(t,i,void 0,t=>{var i=Vt(t,r,e);return n=i!==t&&null!=i,i})))return n&&!R(i)&&Kt(t,e),i}(i,n,e,r),null==e)return e;if(!R(t,n=0|i[C])){var o,a=e;let s=a.m,l=0|s[C];(o=R(a,l)?qt(a,s,l)?zt(a,s,!0):new a.constructor(Wt(s,l,!1)):a)!==e&&(Rt(t)&&(n=0|(i=t.m)[C]),Kt(i,n=Zt(i,n,r,e=o)))}return e}function ae(t){return null==t&&(t=void 0),t}function se(t,e,r){return Yt(t,e,r=ae(r)),r&&!R(r)&&Kt(t.m),t}function le(t,e,r,i){t:{var n=i=ae(i);Ht(t);let s=t.m;var o=0|s[C];if(null==n){var a=ie(s);if(ne(a,s,o,r)!==e)break t;a.set(r,0)}else{let t=ie(a=s),i=ne(t,a,o,r);i!==e&&(i&&(o=Zt(a,o,i)),t.set(r,e))}Zt(s,o,e,n)}return i&&!R(i)&&Kt(t.m),t}function ue(t,e){return-273&(2&e?2|t:-3&t)}function ce(t,e){var r=mi;Ht(t);var i=t.m,n=i,o=0|i[C],a=R(t,o)?1:2;2===a&&Rt(t)&&(o=0|(n=t.m)[C]);var s=Qt(n,8),l=s===k?7:0|s[C],u=te(l,o);if(t=!(4&u)){var c=o;let t=!!(2&u);t&&(c|=2);let e=!t,i=!0,n=0,a=0;for(;n<s.length;n++){let o=Vt(s[n],r,c);if(o instanceof r){if(!t){let t=R(o);e&&=!t,i&&=t}s[a++]=o}}a<n&&(s.length=a),u|=4,u=i?-4097&u:4096|u,u=e?8|u:-9&u}u!==l&&(z(s,u),2&u&&Object.freeze(s)),u=l=u,1===a||4===a&&(2&l||!(16&l)&&32&o)?ee(l)||((l|=!s.length||t&&!(4096&l)||32&o&&!(4096&l||16&l)?2:256)!==u&&z(s,l),Object.freeze(s)):(2===a&&ee(l)&&(s=Array.prototype.slice.call(s),u=0,l=ue(l,o),o=Zt(n,o,8,s)),ee(l)||l!==u&&z(s,l)),2&l||!(4096&l||16&l)||Kt(n,o),a=s,e=null!=e?e:new r,a.push(e),t=r=a===k?7:0|a[C],(e=R(e))?(r&=-9,1===a.length&&(r&=-4097)):r|=4096,r!==t&&z(a,r),e||Kt(i)}function he(t,e,r){return Yt(t,e,null==r?r:function(t){if(!Et(t))throw E("int64");switch(typeof t){case"string":var e=St(Number(t));return yt(e)?t=Q(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=P()?Q(mt(64,BigInt(t))):Q(Pt(t))),t;case"bigint":return Q(mt(64,t));default:return yt(t)?t=Q(jt(t)):(t=St(t),yt(t)?t=String(t):(ct(t),t=pt()),t=Q(t)),t}}(r))}function fe(t,e,r){return Yt(t,e,null==r?r:function(t){if(!Et(t))throw E("uint64");switch(typeof t){case"string":var e=St(Number(t));return yt(e)&&e>=0?t=Q(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=P()?Q(bt(64,BigInt(t))):Q(Ut(t))),t;case"bigint":return Q(bt(64,t));default:return yt(t)?t=Q(kt(t)):((t=St(t))>=0&&yt(t)?t=String(t):(ct(t),t=ft(st,lt)),t=Q(t)),t}}(r))}function de(t,e,r){if(null!=r&&"string"!=typeof r)throw Error();return Yt(t,e,r)}function pe(t,e,r){if(null!=r){if(!wt(r))throw E("enum");r|=0}return Yt(t,e,r)}var ve=class{constructor(t,e,r){if(this.buffer=t,r&&!e)throw Error()}};function ge(t){if("string"==typeof t)return new ve(w(t),!0);if(Array.isArray(t))return new ve(new Uint8Array(t),!0);if(t.constructor===Uint8Array)return new ve(t,!1);if(t.constructor===ArrayBuffer)return t=new Uint8Array(t),new ve(t,!1);if(t.constructor===A){I(_);var e=t.i;return e=(null==(e=null==e||v&&null!=e&&e instanceof Uint8Array?e:"string"==typeof e?w(e):null)?e:t.i=e)||new Uint8Array(0),new ve(e,!0,t)}if(t instanceof Uint8Array)return t=t.constructor===Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new ve(t,!1);throw Error()}function me(t){return new we(4294967295&t,Math.floor(t/4294967296))}function be(t){return t?/^\d+$/.test(t)?(vt(t),new we(st,lt)):null:ye||=new we(0,0)}var ye,we=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};function Se(t){return new je(4294967295&t,Math.floor(t/4294967296))}function _e(t){return t?/^-?\d+$/.test(t)?(vt(t),new je(st,lt)):null:Ae||=new je(0,0)}var Ae,Ie,Te,Be,Ee,xe,Pe,Ue,je=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};function ke(t,e,r){return"undefined"!=typeof BigInt64Array?(Pe||(Pe=new BigInt64Array(1),Ue=new Uint32Array(Pe.buffer),Pe[0]=BigInt(1),xe=1===Ue[0]),Pe[0]=t,new e(Ue[t=xe?0:1],Ue[1-t])):(Ee||(Ie=BigInt(Number.MIN_SAFE_INTEGER),Te=BigInt(Number.MAX_SAFE_INTEGER),Be=BigInt(4294967295),Ee=BigInt(32)),t>=Ie&&t<=Te?r(Number(t)):(t=BigInt.asUintN(64,t),new e(Number(t&Be),Number(t>>Ee))))}function Le(t,e,r){for(;r>0||e>127;)t.i.push(127&e|128),e=(e>>>7|r<<25)>>>0,r>>>=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 Ne(t,e){if(e>=0)Oe(t,e);else{for(let r=0;r<9;r++)t.i.push(127&e|128),e>>=7;t.i.push(1)}}function Ve(t,e){vt(e),function(t){var e=lt>>31;t(st<<1^e,(lt<<1|st>>>31)^e)}((e,r)=>{Le(t,e>>>0,r>>>0)})}function Fe(t,e){t.i.push(e>>>0&255),t.i.push(e>>>8&255),t.i.push(e>>>16&255),t.i.push(e>>>24&255)}var De=class{constructor(){this.i=[]}length(){return this.i.length}end(){var t=this.i;return this.i=[],t}};function Me(t,e){0!==e.length&&(t.l.push(e),t.j+=e.length)}function Ce(t,e,r){Oe(t.i,8*e+r)}function Ge(t,e){return Ce(t,e,2),e=t.i.end(),Me(t,e),e.push(t.j),e}function $e(t,e){var r=e.pop();for(r=t.j+t.i.length()-r;r>127;)e.push(127&r|128),r>>>=7,t.j++;e.push(r),t.j++}function ze(t,e,r){if(null!=r)switch(Ce(t,e,0),typeof r){case"number":t=t.i,ct(r),Le(t,st,lt);break;case"bigint":r=ke(r,je,Se),Le(t.i,r.j,r.i);break;default:r=_e(r),Le(t.i,r.j,r.i)}}function We(t,e,r){Ce(t,e,2),Oe(t.i,r.length),Me(t,t.i.end()),Me(t,r)}var Re=class{constructor(){this.l=[],this.j=0,this.i=new De}};function He(t){if("string"==typeof t)_e(t)}function Ke(){var t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var qe=Ke(),Je=Ke(),Xe=Ke(),Ye=Ke(),Ze=Ke(),Qe=Ke(),tr=Ke(),er=Ke(),rr=Ke(),ir=Ke(),nr=Ke(),or=Ke(),ar=class{constructor(t,e){this.m=Gt(t,e,void 0,2048)}toJSON(){return Ct(this)}};ar.prototype[F]=W,ar.prototype.toString=function(){return this.m.toString()};var sr=class{constructor(t,e){this.i=t,t=qe,this.j=!!t&&e===t||!1}};function lr(t,e,r,i,n){null!=(e=gr(e,i))&&(r=Ge(t,r),n(e,t),$e(t,r))}var ur,cr,hr=new sr(lr,qe),fr=new sr(lr,qe),dr=Symbol(),pr=Symbol();function vr(t){var e=mr,r=br,i=t[dr];if(i)return i;(i={}).ma=t,i.Y=function(t){switch(typeof t){case"boolean":return It||=[0,void 0,!0];case"number":return t>0?void 0:0===t?Tt||=[0,void 0]:[-t,void 0];case"string":return[0,t];case"object":return t}}(t[0]);var n=t[1],o=1;n&&n.constructor===Object&&(i.ca=n,"function"==typeof(n=t[++o])&&(i.fa=!0,ur??=n,cr??=t[o+1],n=t[o+=2]));for(var a={};n&&Array.isArray(n)&&n.length&&"number"==typeof n[0]&&n[0]>0;){for(var s=0;s<n.length;s++)a[n[s]]=n;n=t[++o]}for(s=1;void 0!==n;){let c;"number"==typeof n&&(s+=n,n=t[++o]);var l=void 0;if(n instanceof sr?c=n:(c=hr,o--),c?.j){n=t[++o],l=t;var u=o;"function"==typeof n&&(n=n(),l[u]=n),l=n}for(u=s+1,"number"==typeof(n=t[++o])&&n<0&&(u-=n,n=t[++o]);s<u;s++){let t=a[s];l?r(i,s,c,l,t):e(i,s,c,t)}}return t[dr]=i}function gr(t,e){return t instanceof ar?t.m:Array.isArray(t)?Gt(t,e[0],e[1]):void 0}function mr(t,e,r){t[e]=r.i}function br(t,e,r,i){var n,o,a=r.i;t[e]=(t,e,r)=>a(t,e,r,o||=vr(i).Y,n||=yr(i))}function yr(t){var e=t[pr];if(!e){let r=vr(t);e=(t,e)=>wr(t,e,r),t[pr]=e}return e}function wr(t,e,r){!function(t,e,r){var i,n=128&e?0:-1,o=t.length;(i=!!o)&&(i=null!=(i=t[o-1])&&"object"==typeof i&&i.constructor===Object);var a=o+(i?-1:0);for(e=128&e?1:0;e<a;e++)r(e-n,t[e]);if(i){t=t[o-1];for(let e in t)!isNaN(e)&&r(+e,t[e])}}(t,0|t[C],(t,i)=>{if(null!=i){var n=function(t,e){var r=t[e];if(r)return r;if((r=t.ca)&&(r=r[e])){var i=(r=Array.isArray(r)?r[0]instanceof sr?r:[fr,r]:[r,void 0])[0].i;if(r=r[1]){let e=yr(r),n=vr(r).Y;r=t.fa?cr(n,e):(t,r,o)=>i(t,r,o,n,e)}else r=i;return t[e]=r}}(r,t);n?n(e,i,t):t<500||x(N,3)}})}function Sr(t,e,r){if(Array.isArray(e)){var i=0|e[C];if(4&i)return e;for(var n=0,o=0;n<e.length;n++){let r=t(e[n]);null!=r&&(e[o++]=r)}return o<n&&(e.length=o),t=1|i,r&&(t=-1537&t|4),t!==i&&z(e,t),r&&2&t&&Object.freeze(e),e}}var _r=(t,e)=>{var r=new Re;wr(t.m,r,vr(e)),Me(r,r.i.end()),t=new Uint8Array(r.j);var i=(e=r.l).length,n=0;for(let r=0;r<i;r++){let i=e[r];t.set(i,n),n+=i.length}return r.l=[t],t};function Ar(t,e){return new sr(t,e)}function Ir(t,e){return new sr(t,e)}function Tr(t,e,r){null!=(e=Lt(e))&&(He(e),ze(t,r,e))}function Br(t,e,r){null!=(e=xt(e))&&null!=e&&(Ce(t,r,0),Ne(t.i,e))}function Er(t,e,r){null!=(e=Nt(e))&&We(t,r,o(e))}function xr(t,e,r,i,n){null!=(e=gr(e,i))&&(r=Ge(t,r),n(e,t),$e(t,r))}function Pr(t,e,r){null!=(e=Ot(e))&&We(t,r,ge(e).buffer)}function Ur(t,e,r){null!=(e=xt(e))&&(e=parseInt(e,10),Ce(t,r,0),Ne(t.i,e))}var jr,kr=Ar(function(t,e,r){null!=(e=_t(e))&&(Ce(t,r,1),t=t.i,(r=at||=new DataView(new ArrayBuffer(8))).setFloat64(0,+e,!0),st=r.getUint32(0,!0),lt=r.getUint32(4,!0),Fe(t,st),Fe(t,lt))},ir),Lr=Ar(function(t,e,r){null!=(e=_t(e))&&(Ce(t,r,5),t=t.i,(r=at||=new DataView(new ArrayBuffer(8))).setFloat32(0,+e,!0),lt=0,Fe(t,st=r.getUint32(0,!0)))},rr),Or=Ar(Tr,Qe),Nr=Ar(Tr,Qe),Vr=Ir(function(t,e,r){if(null!=(e=Sr(Lt,e,!1)))for(let i=0;i<e.length;i++)ze(t,r,e[i])},Qe),Fr=Ar(function(t,e,r){if(e=function(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(bt(64,t));if(Et(t)){if("string"===e)return e=St(Number(t)),yt(e)&&e>=0?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=Ut(t)),t;if("number"===e)return kt(t)}}(e),null!=e){if("string"==typeof e)be(e);if(null!=e)switch(Ce(t,r,0),typeof e){case"number":t=t.i,ct(e),Le(t,st,lt);break;case"bigint":r=ke(e,we,me),Le(t.i,r.j,r.i);break;default:r=be(e),Le(t.i,r.j,r.i)}}},tr),Dr=Ar(Br,Ye),Mr=Ir(function(t,e,r){if(null!=(e=Sr(xt,e,!0)))for(let a=0;a<e.length;a++){var i=t,n=r,o=e[a];null!=o&&(Ce(i,n,0),Ne(i.i,o))}},Ye),Cr=Ir(function(t,e,r){if(null!=(e=Sr(xt,e,!0))&&e.length){r=Ge(t,r);for(let r=0;r<e.length;r++)Ne(t.i,e[r]);$e(t,r)}},Ye),Gr=Ar(function(t,e,r){null!=(e=null==e||"boolean"==typeof e?e:"number"==typeof e?!!e:void 0)&&(Ce(t,r,0),t.i.i.push(e?1:0))},Je),$r=Ar(Er,Xe),zr=Ir(function(t,e,r){if(null!=(e=Sr(Nt,e,!0)))for(let s=0;s<e.length;s++){var i=t,n=r,a=e[s];null!=a&&We(i,n,o(a))}},Xe),Wr=function(t,e,r=qe){return new sr(e,r)}(0,function(t,e,r,i,n){if(Array.isArray(e)){for(let o=0;o<e.length;o++)xr(t,e[o],r,i,n);1&(t=0|e[C])||z(e,1|t)}}),Rr=new sr(xr,qe),Hr=Ar(Pr,nr),Kr=Ir(function(t,e,r){if(null!=(e=Sr(Ot,e,!1)))for(let a=0;a<e.length;a++){var i=t,n=r,o=e[a];null!=o&&We(i,n,ge(o).buffer)}},nr),qr=Ar(function(t,e,r){e=function(t){if(null==t)return t;if("string"==typeof t&&t)t=+t;else if("number"!=typeof t)return;return wt(t)?t>>>0:void 0}(e),null!=e&&null!=e&&(Ce(t,r,0),Oe(t.i,e))},Ze),Jr=Ar(Ur,or),Xr=Ar(Ur,or),Yr=Ar(function(t,e,r){if(null!=(e=Lt(e))&&(He(e),null!=e))switch(Ce(t,r,0),typeof e){case"number":t=t.i,e=(r=e)<0,ut(r=2*Math.abs(r)),r=st;let i=lt;e&&(0==r?0==i?i=r=4294967295:(i--,r=4294967295):r--),Le(t,st=r,lt=i);break;case"bigint":t=t.i,e=e<<BigInt(1)^e>>BigInt(63),st=Number(BigInt.asUintN(32,e)),lt=Number(BigInt.asUintN(32,e>>BigInt(32))),Le(t,st,lt);break;default:Ve(t.i,e)}},er),Zr=[0,Hr,Kr,Gr,$r],Qr=[0,Ar(Er,Xe),[0,Xr,[0,Ar(Tr,Qe),Ar(Br,Ye)],Xr,-1,[0,Jr],Xr,-1],Ar(Pr,nr)],ti=[0,1,[0,12,Dr,10,Gr],[0,7,[0,Dr,-1]]],ei=globalThis.trustedTypes;var ri=class{constructor(t){this.i=t}toString(){return this.i+""}};function ii(t){var e;return void 0===jr&&(jr=function(){var t=null;if(!ei)return t;try{let e=t=>t;t=ei.createPolicy("goog#html",{createHTML:e,createScript:e,createScriptURL:e})}catch(t){}return t}()),t=(e=jr)?e.createScriptURL(t):t,new ri(t)}function ni(t,...e){if(0===e.length)return ii(t[0]);var r=t[0];for(let i=0;i<e.length;i++)r+=encodeURIComponent(e[i])+t[i+1];return ii(r)}var oi,ai=class extends ar{constructor(t){super(t)}},si=class extends ar{constructor(t){super(t)}},li=class extends ar{constructor(t){super(t)}},ui=[1,2,3,4,5,6],ci=class extends ar{constructor(t){super(t)}j(){return null!=Jt(this,1,re)}l(){return null!=Nt(Jt(this,2))}},hi=class extends ar{constructor(t){super(t)}},fi=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 di(t){if(t)return!0;if(void 0===oi)try{await WebAssembly.instantiate(fi),oi=!0}catch{oi=!1}return oi}async function pi(t,e,r){return{wasmLoaderPath:`${e}/${t}_${r=`wasm${r?"_module":""}${await di(r)?"":"_nosimd"}_internal`}.js`,wasmBinaryPath:`${e}/${t}_${r}.wasm`}}var vi=class{};function gi(t){return pe(new mi,1,t)}vi.forVisionTasks=function(t,e=!1){return pi("vision",t??ni``,e)},vi.forLiteRtLmTextTasks=function(t,e=!1){return pi("litertlm_text",t??ni``,e)},vi.forTextTasks=function(t,e=!1){return pi("text",t??ni``,e)},vi.forRetrievalTasks=function(t,e=!1){return pi("retrieval",t??ni``,e)},vi.forGenAiTasks=function(t,e=!1){return pi("genai",t??ni``,e)},vi.forDecisionTasks=function(t,e=!1){return pi("decision",t??ni``,e)},vi.forAudioTasks=function(t,e=!1){return pi("audio",t??ni``,e)},vi.isSimdSupported=function(t=!1){return di(t)};var mi=class extends ar{constructor(t){super(t)}},bi=class extends ar{constructor(t){super(t)}},yi=[0,Jr,2,Fr,-2,Nr,Wr,[0,Jr,Nr]],wi=class extends ar{constructor(t){super(t)}},Si=class extends ar{constructor(t){super(t)}};function _i(t){var e=new Ii;return e=pe(e,1,30),pe(e,2,t)}var Ai,Ii=class extends ar{constructor(t){super(t)}},Ti=[3,4,5,6,7],Bi=class extends ar{constructor(t){super(t)}},Ei=class extends ar{constructor(t){super(t)}};Ei.prototype.j=(Ai=[0,[0,Jr,$r,-3,Jr],[0,Ti,Jr,-1,Rr,[0,Jr,$r,Fr],Rr,yi,Rr,[0,1,yi],Rr,[0,Jr],Rr,[0,Jr,$r,Fr]]],function(){return _r(this,Ai)});var xi=class{constructor(){this.i="undefined"!=typeof AbortController}async send(t,e,r){var i=this.i?new AbortController:void 0,n=i&&t.U>0?setTimeout(()=>{i.abort()},t.U):void 0;try{let n=await fetch(t.url,{method:t.la,headers:{...t.ka},...t.body&&{body:t.body},...t.withCredentials&&{credentials:"include"},signal:t.U&&i?i.signal:null});200===n.status?e?.(await n.text()):r?.(n.status)}catch(t){if("AbortError"===t?.name)r?.(408);else r?.(400)}finally{clearTimeout(n)}}},Pi=class extends ar{constructor(t){super(t,37)}},Ui=[-4,{},ti,Jr,Qr],ji=[0,$r,Jr],ki=[0,$r,Jr],Li=[0,$r,Jr,1,$r,-1,Jr,1,Jr,1,Nr],Oi=[0,Jr,$r,-2],Ni=[0,Gr,-3],Vi=[0,Jr,$r,-1,Nr,Dr,-1,$r,-5,Wr,[0,$r,-4],-1,Gr,[0,Gr,-3],Jr];var Fi=class extends ar{constructor(t){super(t,19)}},Di=function(t){return e=>_r(e,t)}([-19,{},[0,Jr,1,[0,$r,-6,Nr,Dr,$r,-1,Nr],1,[0,$r,1,$r,-5],$r,-1,[0,Jr,$r,-8],[0,$r,-3],[0,$r,Jr,$r,-2],[0,$r,-1,Jr,$r,-1,Jr,$r,-1,[0,Wr,[0,$r,-1],Gr,$r,-5],[0,Jr,Gr,Dr,-2]],Nr,[0,$r,-3,Nr,Dr,$r,-1],[0,Jr,$r,-1],[0,$r,-9],[0,$r,-6,Jr,$r,1,$r,Gr,Jr,-1,Gr,$r,-2,Jr,$r,Jr,$r,Dr,-1],1,[0,Jr],1,[0,$r,-4],1,Li,[0,[1,2,3,4,5,6],Rr,Li,Rr,ji,Rr,ki,Rr,[0,Jr],Rr,Vi,Rr,Oi],ji,ki,Vi,[0,[0,Jr,$r,-1,Nr,Dr,-1,$r,-4,Wr,[0,$r,-4],-1,1,Ni],[0,Jr,$r,-1,Nr,Dr,-1,$r,-4,Ni]],Oi,[0,$r,[0,Dr,-3,Jr],Jr,-2,[0,Dr,-1],Gr],4,[0,$r,Jr,$r,-1,Nr,Jr,$r,-1,Jr,Dr,-1]],Jr,Wr,[-37,{},Or,$r,Wr,[0,$r,-1],Hr,1,Hr,[0,zr,-1,Mr,Vr,-1],$r,[0,Dr,$r,-1],Gr,Dr,Nr,$r,-1,Yr,Zr,Or,Hr,Jr,Mr,Nr,-1,[0,Jr,-1],$r,Gr,$r,Cr,$r,-1,kr,1,kr,Ui,Gr,[0,Jr,[0,Lr,Dr,-2],[0,Lr]],[0,Jr,Nr]],Or,Kr,$r,-1,Or,Jr,-1,[0,Gr,-1,Jr,Gr],[0,Nr,-1,$r],[0,Or,Gr,Nr],Nr,1,qr,1,Ui]),Mi=class{constructor(t){this.j=[],this.o=new xi,this.l=t??"",this.i=setInterval(()=>{this.flush()},6e4)}close(){void 0!==this.i&&(clearInterval(this.i),this.i=void 0),this.flush()}flush(t,e){if(this.error)e?.("net-send-failed");else if(0===this.j.length)t?.();else{var r=this.j;this.j=[],r=function(t){var e=new Fi;{Ht(e=pe(e,2,1786));let u=e.m,c=0|u[C];if(null==t)Zt(u,c,3);else{var r=t===k?7:0|t[C],i=r,n=ee(r),o=n||Object.isFrozen(t),a=!0,s=!0;for(let e=0;e<t.length;e++){var l=t[e];n||(l=R(l),a&&=!l,s&&=l)}n||(r=a?13:5,r=s?-4097&r:4096|r),o&&r===i||(t=Array.prototype.slice.call(t),i=0,r=ue(r,c)),r!==i&&z(t,r),c=Zt(u,c,3,t),2&r||!(4096&r||16&r)||Kt(u,c)}}return e}(r),r=Di(r),this.o.send({url:"https://odml.pa.googleapis.com/v1/log",la:"POST",U:1e4,body:r,na:2,ka:{"Content-Type":"application/x-protobuf","x-goog-api-key":this.l},withCredentials:!1},()=>{t?.()},t=>{this.error=Error(`Logging failed with HTTP error: ${t}`),this.j=[],void 0!==this.i&&(clearInterval(this.i),this.i=void 0),e?.("net-send-failed",t)})}}};class Ci{constructor(){this.M=this.D=this.I=this.B=this.G=this.H=this.F=0}}function Gi(t,e){var r=new Ei;r=se(r,1,t.L),r=se(r,2,e),e=Yt(e=new Pi,6,K(r=r.j(),!1)),(t=t.C).error||t.j.push(e)}function $i(t,e){var r={F:e.F-t.l.F,H:e.H-t.l.H,G:e.G-t.l.G,B:e.B-t.l.B,I:e.I-t.l.I,D:e.D,M:e.M},i=_i(1);r=zi(t,r),Gi(t,i=le(i,4,Ti,r)),t.l=e}function zi(t,e){var r=new bi;return t=fe(t=he(t=pe(r,1,t.J),7,e.B),5,e.D),t=fe(t,6,e.M),e.G>0&&fe(t,4,e.I/e.G),0!==e.F&&ce(t,r=he(r=gi(3),2,e.F)),0!==e.H&&ce(t,e=he(r=gi(4),2,e.H)),t}var Wi=class{constructor(t,e){this.K=performance.now(),this.o=performance.now(),this.j=new Map,this.A=0,this.i=new Ci,this.l=new Ci,this.C=new Mi(e),this.J=function(t){switch(t){case"IMAGE":return 11;case"VIDEO":return 12;case"LIVE_STREAM":return 13;case"AUDIO_CLIPS":return 14;case"AUDIO_STREAM":return 15;default:return 10}}(t),t=new Bi,"undefined"==typeof window?e=0:(e=navigator.userAgent,e=/Android/i.test(e)?1:/iPhone|iPad|iPod/i.test(e)?2:/Windows/i.test(e)?5:/Macintosh/i.test(e)?4:/Linux/i.test(e)?3:0),t=de(t=pe(t,1,e),2,""),t=de(t,3,""),t=de(t,4,"1.1.0"),t=de(t,5,""),this.L=pe(t,6,4)}X(){var t=new Si;t=fe(t=pe(t,1,this.J),3,performance.now()-this.K),Gi(this,t=le(_i(0),3,Ti,t)),this.o=performance.now()}R(t){var e=this.j.get(t);if(void 0!==e&&(this.j.delete(t),t=performance.now()-e,++this.i.G,this.i.I+=t,this.i.D=Math.max(this.i.D,t),this.A=Math.max(this.A,t),performance.now()>this.o+3e4)){for(let[r,i]of this.j.entries())t=r,i<e&&(this.i.B++,this.j.delete(t));e={...this.i,M:performance.now()-this.o},this.i.D=0,this.o=performance.now(),$i(this,e)}}ga(){var t={...this.i,B:this.i.B+this.j.size,D:this.A,M:performance.now()-this.K};$i(this,t);var e=new wi;e=se(e,2,t=zi(this,t)),Gi(this,e=le(t=_i(2),5,Ti,e))}close(){var t=this.C;"function"==typeof t.close?t.close():t.flush()}};function Ri(){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 Hi(t){if("function"!=typeof importScripts){let e=document.createElement("script");return e.src=t.toString(),e.crossOrigin="anonymous",new Promise((t,r)=>{e.addEventListener("load",()=>{t()},!1),e.addEventListener("error",t=>{r(t)},!1),document.body.appendChild(e)})}try{importScripts(t.toString())}catch(e){if(!(e instanceof TypeError))throw e;{let e=self.import;e?await e(t.toString()):await import(t.toString())}}}function Ki(t,e,r){t.o||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),r(e=t.h.stringToNewUTF8(e)),t.h._free(e)}function qi(t,e,r){t.o||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");var i=new Uint32Array(e.length);for(let r=0;r<e.length;r++)i[r]=t.h.stringToNewUTF8(e[r]);e=t.h._malloc(4*i.length),t.h.HEAPU32.set(i,e>>2),r(e);for(let e of i)t.h._free(e);t.h._free(e)}function Ji(t,e,r){t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=r}function Xi(t,e,r){var i=[];t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=(t,e,n)=>{e?(r(i,n),i=[]):i.push(t)}}var Yi=function(t){return class extends t{get V(){return this.h}da(){if("function"==typeof this.V._mediapipeLoggerGetEncodedApiKey){let t=this.V._mediapipeLoggerGetEncodedApiKey();return this.V._decodeBase64(t)}}}}(function(t){return class extends t{ja(){this.h._registerModelResourcesGraphService()}}}(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:Ri()?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){var 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){var r=t.length,i=this.h._malloc(r);this.h.HEAPU8.set(t,i),e?this.h._changeBinaryGraph(r,i):this.h._changeTextGraph(r,i),this.h._free(i)}configureAudio(t,e,r,i,n){this.h._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),Ki(this,i||"input_audio",i=>{Ki(this,n=n||"audio_header",n=>{this.h._configureAudio(i,n,t,e??0,r)})})}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,r){this.addAudioToStreamWithShape(t,0,0,e,r)}addAudioToStreamWithShape(t,e,r,i,n){var 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),Ki(this,i,t=>{this.h._addAudioToInputStream(this.i,e,r,t,n)})}addGpuBufferToStream(t,e,r){Ki(this,e,e=>{if(!this.h.canvas)throw Error("No OpenGL canvas configured.");e?this.h._bindTextureToStream(e):this.h._bindTextureToCanvas();var i=this.h.canvas.getContext("webgl2")||this.h.canvas.getContext("webgl");if(!i)throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");this.h.gpuOriginForWebTexturesIsBottomLeft&&i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!0),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,t),this.h.gpuOriginForWebTexturesIsBottomLeft&&i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1);var[n,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||n===this.h.canvas.width&&o===this.h.canvas.height||(this.h.canvas.width=n,this.h.canvas.height=o);var[a,s]=[n,o];this.h._addBoundTextureToStream(e,a,s,r)})}addBoolToStream(t,e,r){Ki(this,e,e=>{this.h._addBoolToInputStream(t,e,r)})}addDoubleToStream(t,e,r){Ki(this,e,e=>{this.h._addDoubleToInputStream(t,e,r)})}addFloatToStream(t,e,r){Ki(this,e,e=>{this.h._addFloatToInputStream(t,e,r)})}addIntToStream(t,e,r){Ki(this,e,e=>{this.h._addIntToInputStream(t,e,r)})}addUintToStream(t,e,r){Ki(this,e,e=>{this.h._addUintToInputStream(t,e,r)})}addStringToStream(t,e,r){Ki(this,e,e=>{Ki(this,t,t=>{this.h._addStringToInputStream(t,e,r)})})}addStringRecordToStream(t,e,r){Ki(this,e,e=>{qi(this,Object.keys(t),i=>{qi(this,Object.values(t),n=>{this.h._addFlatHashMapToInputStream(i,n,Object.keys(t).length,e,r)})})})}addProtoToStream(t,e,r,i){Ki(this,r,r=>{Ki(this,e,e=>{var n=this.h._malloc(t.length);this.h.HEAPU8.set(t,n),this.h._addProtoToInputStream(n,t.length,e,r,i),this.h._free(n)})})}addEmptyPacketToStream(t,e){Ki(this,t,t=>{this.h._addEmptyPacketToInputStream(t,e)})}addBoolVectorToStream(t,e,r){Ki(this,e,e=>{var i=this.h._allocateBoolVector(t.length);if(!i)throw Error("Unable to allocate new bool vector on heap.");for(let e of t)this.h._addBoolVectorEntry(i,e);this.h._addBoolVectorToInputStream(i,e,r)})}addDoubleVectorToStream(t,e,r){Ki(this,e,e=>{var i=this.h._allocateDoubleVector(t.length);if(!i)throw Error("Unable to allocate new double vector on heap.");for(let e of t)this.h._addDoubleVectorEntry(i,e);this.h._addDoubleVectorToInputStream(i,e,r)})}addFloatVectorToStream(t,e,r){Ki(this,e,e=>{var i=this.h._allocateFloatVector(t.length);if(!i)throw Error("Unable to allocate new float vector on heap.");for(let e of t)this.h._addFloatVectorEntry(i,e);this.h._addFloatVectorToInputStream(i,e,r)})}addIntVectorToStream(t,e,r){Ki(this,e,e=>{var i=this.h._allocateIntVector(t.length);if(!i)throw Error("Unable to allocate new int vector on heap.");for(let e of t)this.h._addIntVectorEntry(i,e);this.h._addIntVectorToInputStream(i,e,r)})}addUintVectorToStream(t,e,r){Ki(this,e,e=>{var i=this.h._allocateUintVector(t.length);if(!i)throw Error("Unable to allocate new unsigned int vector on heap.");for(let e of t)this.h._addUintVectorEntry(i,e);this.h._addUintVectorToInputStream(i,e,r)})}addStringVectorToStream(t,e,r){Ki(this,e,e=>{var i=this.h._allocateStringVector(t.length);if(!i)throw Error("Unable to allocate new string vector on heap.");for(let e of t)Ki(this,e,t=>{this.h._addStringVectorEntry(i,t)});this.h._addStringVectorToInputStream(i,e,r)})}addBoolToInputSidePacket(t,e){Ki(this,e,e=>{this.h._addBoolToInputSidePacket(t,e)})}addDoubleToInputSidePacket(t,e){Ki(this,e,e=>{this.h._addDoubleToInputSidePacket(t,e)})}addFloatToInputSidePacket(t,e){Ki(this,e,e=>{this.h._addFloatToInputSidePacket(t,e)})}addIntToInputSidePacket(t,e){Ki(this,e,e=>{this.h._addIntToInputSidePacket(t,e)})}addUintToInputSidePacket(t,e){Ki(this,e,e=>{this.h._addUintToInputSidePacket(t,e)})}addStringToInputSidePacket(t,e){Ki(this,e,e=>{Ki(this,t,t=>{this.h._addStringToInputSidePacket(t,e)})})}addProtoToInputSidePacket(t,e,r){Ki(this,r,r=>{Ki(this,e,e=>{var i=this.h._malloc(t.length);this.h.HEAPU8.set(t,i),this.h._addProtoToInputSidePacket(i,t.length,e,r),this.h._free(i)})})}addBoolVectorToInputSidePacket(t,e){Ki(this,e,e=>{var r=this.h._allocateBoolVector(t.length);if(!r)throw Error("Unable to allocate new bool vector on heap.");for(let e of t)this.h._addBoolVectorEntry(r,e);this.h._addBoolVectorToInputSidePacket(r,e)})}addDoubleVectorToInputSidePacket(t,e){Ki(this,e,e=>{var r=this.h._allocateDoubleVector(t.length);if(!r)throw Error("Unable to allocate new double vector on heap.");for(let e of t)this.h._addDoubleVectorEntry(r,e);this.h._addDoubleVectorToInputSidePacket(r,e)})}addFloatVectorToInputSidePacket(t,e){Ki(this,e,e=>{var r=this.h._allocateFloatVector(t.length);if(!r)throw Error("Unable to allocate new float vector on heap.");for(let e of t)this.h._addFloatVectorEntry(r,e);this.h._addFloatVectorToInputSidePacket(r,e)})}addIntVectorToInputSidePacket(t,e){Ki(this,e,e=>{var r=this.h._allocateIntVector(t.length);if(!r)throw Error("Unable to allocate new int vector on heap.");for(let e of t)this.h._addIntVectorEntry(r,e);this.h._addIntVectorToInputSidePacket(r,e)})}addUintVectorToInputSidePacket(t,e){Ki(this,e,e=>{var r=this.h._allocateUintVector(t.length);if(!r)throw Error("Unable to allocate new unsigned int vector on heap.");for(let e of t)this.h._addUintVectorEntry(r,e);this.h._addUintVectorToInputSidePacket(r,e)})}addStringVectorToInputSidePacket(t,e){Ki(this,e,e=>{var r=this.h._allocateStringVector(t.length);if(!r)throw Error("Unable to allocate new string vector on heap.");for(let e of t)Ki(this,e,t=>{this.h._addStringVectorEntry(r,t)});this.h._addStringVectorToInputSidePacket(r,e)})}attachBoolListener(t,e){Ji(this,t,e),Ki(this,t,t=>{this.h._attachBoolListener(t)})}attachBoolVectorListener(t,e){Xi(this,t,e),Ki(this,t,t=>{this.h._attachBoolVectorListener(t)})}attachIntListener(t,e){Ji(this,t,e),Ki(this,t,t=>{this.h._attachIntListener(t)})}attachIntVectorListener(t,e){Xi(this,t,e),Ki(this,t,t=>{this.h._attachIntVectorListener(t)})}attachUintListener(t,e){Ji(this,t,e),Ki(this,t,t=>{this.h._attachUintListener(t)})}attachUintVectorListener(t,e){Xi(this,t,e),Ki(this,t,t=>{this.h._attachUintVectorListener(t)})}attachDoubleListener(t,e){Ji(this,t,e),Ki(this,t,t=>{this.h._attachDoubleListener(t)})}attachDoubleVectorListener(t,e){Xi(this,t,e),Ki(this,t,t=>{this.h._attachDoubleVectorListener(t)})}attachFloatListener(t,e){Ji(this,t,e),Ki(this,t,t=>{this.h._attachFloatListener(t)})}attachFloatVectorListener(t,e){Xi(this,t,e),Ki(this,t,t=>{this.h._attachFloatVectorListener(t)})}attachStringListener(t,e){Ji(this,t,e),Ki(this,t,t=>{this.h._attachStringListener(t)})}attachStringVectorListener(t,e){Xi(this,t,e),Ki(this,t,t=>{this.h._attachStringVectorListener(t)})}attachProtoListener(t,e,r){Ji(this,t,e),Ki(this,t,t=>{this.h._attachProtoListener(t,r||!1)})}attachProtoVectorListener(t,e,r){Xi(this,t,e),Ki(this,t,t=>{this.h._attachProtoVectorListener(t,r||!1)})}attachAudioListener(t,e,r){this.h._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),Ji(this,t,(t,r)=>{t=new Float32Array(t.buffer,t.byteOffset,t.length/4),e(t,r)}),Ki(this,t,t=>{this.h._attachAudioListener(t,r||!1)})}finishProcessing(){this.h._waitUntilIdle()}closeGraph(){this.h._closeGraph(),this.h.simpleListeners=void 0,this.h.emptyPacketListeners=void 0}})),Zi=class extends Yi{};async function Qi(t,e){var r=await(async(t,e,r)=>{var i=gn;if(t&&await Hi(t),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(e&&(await Hi(e),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&r&&((t=self.Module).locateFile=r.locateFile,r.mainScriptUrlOrBlob&&(t.mainScriptUrlOrBlob=r.mainScriptUrlOrBlob)),r=await self.ModuleFactory(self.Module||r),self.ModuleFactory=self.Module=void 0,new i(r,null)})(t.wasmLoaderPath,t.assetLoaderPath,{locateFile:e=>e.endsWith(".wasm")?t.wasmBinaryPath.toString():t.assetBinaryPath&&e.endsWith(".data")?t.assetBinaryPath.toString():e});return tn(r,e),await r.S(e),r}function tn(t,e){e=e.qa??"";var r=t.i.da();t.l=new Wi(e,r)}function en(t,e){try{t.i.h.FS_unlink("/model.litertlm")}catch{}t.i.h.FS_createDataFile("/","model.litertlm",e,!0,!1,!1),de(e=oe(t.baseOptions,ci,1)||new ci,2,"/model.litertlm"),Yt(e,1),se(t.baseOptions,1,e)}function rn(t,e,r=!0){if(r){let r=e.baseOptions||{};if(e.baseOptions?.modelAssetBuffer&&e.baseOptions?.modelAssetPath)throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!(oe(t.baseOptions,ci,1)?.j()||oe(t.baseOptions,ci,1)?.l()||e.baseOptions?.modelAssetBuffer||e.baseOptions?.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if(function(t,e){var r=oe(t.baseOptions,li,3);if(!r){var i=r=new li,n=new si;le(i,4,ui,n)}"delegate"in e&&("GPU"===e.delegate?(e=r,i=new ai,le(e,2,ui,i)):(e=r,i=new si,le(e,4,ui,i))),se(t.baseOptions,3,r)}(t,r),r.modelAssetPath)return fetch(r.modelAssetPath.toString()).then(t=>{if(t.ok)return t.arrayBuffer();throw Error(`Failed to fetch model: ${r.modelAssetPath} (${t.status})`)}).then(e=>{en(t,new Uint8Array(e))});if(r.modelAssetBuffer instanceof Uint8Array)en(t,r.modelAssetBuffer);else if(r.modelAssetBuffer)return async function(t){for(var e=[],r=0;;){let{done:i,value:n}=await t.read();if(i)break;e.push(n),r+=n.length}if(0===e.length)return new Uint8Array(0);if(1===e.length)return e[0];t=new Uint8Array(r),r=0;for(let i of e)t.set(i,r),r+=i.length;return t}(r.modelAssetBuffer).then(e=>{en(t,e)})}return Promise.resolve()}function nn(t){try{let e=t.o.length;if(1===e)throw Error(t.o[0].message);if(e>1)throw Error("Encountered multiple errors: "+t.o.map(t=>t.message).join(", "))}finally{t.o=[]}}var on=class{constructor(t){this.i=t,this.o=[],this.i.setAutoRenderToScreen(!1)}setGraph(t,e){this.i.attachErrorListener((t,e)=>{this.o.push(Error(e))}),this.i.ja(),this.i.setGraph(t,e),this.l?.X(),nn(this)}finishProcessing(t){this.i.finishProcessing(),nn(this),this.l&&void 0!==t&&this.l.R(t)}close(){this.l?.ga(),this.l?.close(),this.i.closeGraph()}};function an(t){return(t=t.trim())?Math.max(1,Math.ceil(t.length/4)):0}function sn(t){var e={};if(t.criteria)for(let[r,i]of Object.entries(t.criteria))e[r]=i;if(t.options)for(let r of t.options)e[r.label]=r.description??"";return e}function ln(t){if(t.options&&t.options.length>0){var e=t.options.map(t=>t.description?`${t.label}: ${t.description}`:t.label),r=(t=t.options.map(t=>t.label)).map(t=>Number(t)),i=r.every(t=>Number.isFinite(t))&&t.every(t=>""!==t.trim());return r=i?r:t.map((t,e)=>e),{rubric:e,labels:t,P:r,O:i}}return t=(e=t.rubric??[]).map((t,e)=>String(e)),i=e.map((t,e)=>e),{rubric:e,labels:t,P:i,O:!1}}function un(t,e,r,i){var n=t.probabilities??[],o=0,a=-1,s=0;for(let t=0;t<n.length;t++){let e=n[t];e>a&&(a=e,o=t),s+=(t<r.length?r[t]:t)*e}return{...t,expectedScore:i&&n.length>0?s:t.expectedScore,selectedKey:o<e.length?e[o]:t.selectedKey??String(o)}}on.prototype.close=on.prototype.close;var cn=[];async function hn(t,e){var r=cn.pop();if(r){tn(t=new gn(r,null),e);try{return await t.S(e),t}catch(e){throw t.close(),e}}return async function(t,e){return Qi(t,e)}(t,e)}function fn(t,e){var r=t.Z++;return t.l&&(1===t.backendType||-1===t.backendType?function(t,e){++t.i.F,t.j.set(e,performance.now())}(t.l,r):function(t,e){++t.i.H,t.j.set(e,performance.now())}(t.l,r)),e().then(e=>(t.l?.R(r),e),e=>{throw t.l?.R(r),e})}function dn(t){if(!t)return 0;var e=t.context?an(t.context):0;for(let r of t.questions??[]){e+=an(r.prompt)+4;for(let t of r.options??[])e+=an(t.description?`${t.label}: ${t.description}`:t.label)+2}return e}function pn(t,e){if(!(t=t.i.h._malloc(e>=64?e+16:e)>>>0))throw Error(`Failed to allocate ${e} bytes on Wasm heap.`);return{u:e>=64?(t+15&-16)>>>0:t,v:t}}async function vn(t,e,r,i){var n=t.i.h;if(r instanceof Uint8Array){if(0===(i=r.byteLength))return{u:0,v:0,size:0};let{u:e,v:o}=pn(t,i);return n.HEAPU8.set(r,e),{u:e,v:o,size:i}}if(i=i&&i>0?i:0,!r&&e){if(e=e.toString(),!(r=await fetch(e)).ok||!r.body)throw Error(`Failed to fetch asset: ${e} (${r.status})`);(e=Number(r.headers.get("content-length")||0))>0&&(i=e),r=r.body.getReader()}if(!r)return{u:0,v:0,size:0};if(i>0){let{u:o,v:a}=pn(t,i);for(t=0;;){let{value:s,done:l}=await r.read();if(l)break;if(s&&s.byteLength>0){if(t+(e=Number(s.byteLength))>i)throw n._free(a),Error(`Stream exceeded expected content-length (${i} bytes).`);n.HEAPU8.set(s,o+t>>>0),t+=e}}return{u:o,v:a,size:t}}for(i=[],e=0;;){let{value:t,done:n}=await r.read();if(n)break;if(t&&t.byteLength>0){var o=Number(t.byteLength);i.push(t),e+=o}}if(0===e)return{u:0,v:0,size:0};var{u:a,v:s}=pn(t,e);for(t=0,r=0;r<i.length;r++)(o=i[r])&&(n.HEAPU8.set(o,a+t>>>0),t+=o.byteLength,i[r]=void 0);return{u:a,v:s,size:e}}var gn=class extends on{constructor(t,e){super(new Zi(t,e)),this.baseOptions=new hi,this.L=this.C=this.K=this.A=this.j=this.maxNumTokens=this.backendType=0,this.W=!1,this.Z=this.J=0}get contextWindow(){return this.maxNumTokens}get contextUsage(){return this.J}T(t){this.N=t,this.J=dn(t)}async ia(t){if(0!==this.j){var e=t.questions??[];if(0!==e.length){var r=this.i.h;"function"==typeof r.prewarmSchema?await r.prewarmSchema(this.j,t.context??"",e):"function"==typeof r.evaluateSchema&&await r.evaluateSchema(this.j,"__PREWARM__",t.context??"",e)}}}async ha(t,e){return t=e?.context?`${e.context}\n${t}`:t,dn(this.N)+an(t)}async S(t){if(0!==this.j)throw Error("Decision does not support updating options after initialization.");if("CPU"===t.baseOptions?.delegate?this.backendType=-1:void 0!==t.backendType&&(this.backendType=t.backendType),void 0!==t.maxNumTokens&&(this.maxNumTokens=t.maxNumTokens),t.schema?this.T(t.schema):(t.questions||t.context||t.expectedInputs)&&this.T({context:t.context,expectedInputs:t.expectedInputs,questions:t.questions}),-1===this.backendType){this.i.h.preinitializedWebGPUDevice=void 0;var e="undefined"!=typeof self?self:globalThis;"object"==typeof e.Module&&e.Module&&(e.Module.preinitializedWebGPUDevice=void 0)}else if("undefined"!=typeof navigator&&navigator.gpu)try{if(!(e=this.i.h).preinitializedWebGPUDevice){var r=await navigator.gpu.requestAdapter({powerPreference:"high-performance"}),i=r?.info,n=!!r?.isFallbackAdapter||/swiftshader|llvmpipe|software|lavapipe/i.test(`${i?.vendor??""} ${i?.architecture??""} ${i?.description??""}`);if(r&&!n){for(var o of(n=[],["shader-f16","subgroups","subgroups-f16"]))r.features.has(o)&&n.push(o);o={};for(let t of["maxBufferSize","maxStorageBufferBindingSize","maxStorageBuffersPerShaderStage","maxComputeWorkgroupStorageSize"]){let e=r.limits[t];"number"==typeof e&&(o[t]=e)}let t=await r.requestDevice({requiredFeatures:n,requiredLimits:o});if(!t.adapterInfo&&i)try{Object.defineProperty(t,"adapterInfo",{value:i,writable:!0,configurable:!0})}catch{try{t.adapterInfo=i}catch{}}e.preinitializedWebGPUDevice=t}}e.preinitializedWebGPUDevice&&("object"==typeof(r=self).Module&&r.Module&&(r.Module.preinitializedWebGPUDevice=e.preinitializedWebGPUDevice))}catch(t){console.warn("WebGPU device initialization failed:",t)}if(r=e=this.i.h,(i=!(!t.baseOptions||!t.baseOptions.modelAssetPath&&!t.baseOptions.modelAssetBuffer))&&"function"==typeof e.createDecisionFromBuffers&&"function"==typeof r._malloc){if(r=await vn(this,t.baseOptions?.modelAssetPath,t.baseOptions?.modelAssetBuffer,t.modelAssetSize),this.A=r.u,this.K=r.v,i=0,t.companionPleAssetPath||t.companionPleAssetBuffer)try{let e=await vn(this,t.companionPleAssetPath,t.companionPleAssetBuffer,t.companionPleAssetSize);this.C=e.u,this.L=e.v,i=e.size}catch(t){console.warn("Optional companion per-layer embedder not loaded:",t)}this.j=await e.createDecisionFromBuffers(this.A,r.size,this.C,i,this.backendType,this.maxNumTokens)}else await rn(this,t,i),this.j=await e.createDecision("/model.litertlm",this.backendType,this.maxNumTokens);this.l?.X()}evaluateBoolean(t,e){if(0===this.j)throw Error("Decision is already closed.");var r=this.i.h,i=e.context?`${e.context}\n${e.condition}`:e.condition;return fn(this,()=>r.evaluateBoolean(this.j,t,i,e.threshold??.5,e.temperature??0))}evaluateChoice(t,e){if(0===this.j)throw Error("Decision is already closed.");var r=this.i.h,i=sn(e),n=e.instructions??"",o=e.context?n?`${e.context}\n${n}`:e.context:n;return fn(this,()=>r.evaluateChoice(this.j,t,i,e.temperature??0,o))}async evaluateScore(t,e){if(0===this.j)throw Error("Decision is already closed.");var r=this.i.h,{rubric:i,labels:n,P:o,O:a}=ln(e),s=e.instructions??"",l=e.context?s?`${e.context}\n${s}`:e.context:s;return un(s=await fn(this,()=>r.evaluateScore(this.j,t,i,e.temperature??0,l)),n,o,a)}async evaluate(t,e,r){if(0===this.j)throw Error("Decision is already closed.");if(r?.signal?.aborted)throw new DOMException("The operation was aborted.","AbortError");var i=r?.context?`${r.context}\n${t}`:t,n=e.context;this.J=dn(e)+an(i);var o=this.i.h;if("function"==typeof o.evaluateSchema&&(e.questions??[]).length>0)return fn(this,()=>o.evaluateSchema(this.j,i,n??"",e.questions??[]));t={};for(let o of e.questions??[])if("binary"===o.type||"boolean"===o.type){var a=(r=await this.evaluateBoolean(i,{condition:o.prompt,context:n,threshold:o.threshold,temperature:o.temperature,normalizePrior:o.normalizePrior,options:o.options})).probabilityTrue;let e=o.options&&o.options.length>=2?o.options[0].label:"false",s=o.options&&o.options.length>=2?o.options[1].label:"true";t[o.id]={id:o.id,label:a>=(o.threshold??.5)?s:e,confidence:r.confidence,probability:a,probabilities:[{label:e,probability:Math.max(0,1-a)},{label:s,probability:a}]}}else if("categorical"===o.type||"choice"===o.type){let e=await this.evaluateChoice(i,{options:o.options,instructions:o.prompt,context:n,temperature:o.temperature,normalizePrior:o.normalizePrior});r=(r=(o.options??[]).map(t=>t.label)).length>0?r.map(t=>({label:t,probability:e.probabilities[t]??0})):Object.entries(e.probabilities).map(([t,e])=>({label:t,probability:e})),t[o.id]={id:o.id,label:e.selectedKey,confidence:e.confidence,probabilities:r,predictionSet:e.predictionSet}}else if("ordinal"===o.type||"score"===o.type){r=await this.evaluateScore(i,{options:o.options,instructions:o.prompt,context:n,temperature:o.temperature});let e=(o.options??[]).map(t=>t.label);a=(r.probabilities??[]).map((t,r)=>({label:r<e.length?e[r]:String(r),probability:t})),t[o.id]={id:o.id,label:r.selectedKey??e[0]??"0",confidence:r.confidence,expectedScore:r.expectedScore,probabilities:a}}return t}async ba(t,e,r){var i=[];for(let n of t)i.push(await this.evaluate(n,e,r));return i}async aa(t,e){if(!this.N)throw Error("No session schema configured. Pass `schema` or `questions` in DecisionMakerOptions or call setSchema() before classify().");return this.evaluate(t,this.N,e)}async evaluateBooleanBatch(t,e,r=""){if(0===this.j)throw Error("Decision is already closed.");if(0===t.length)return[];var i=this.i.h,n=e.context?`${e.context}\n${e.condition}`:e.condition;if("function"==typeof i.evaluateBooleanBatch)return fn(this,()=>i.evaluateBooleanBatch(this.j,t,n,e.threshold??.5,e.temperature??0,r));var o=[];for(let i of t)o.push(await this.evaluateBoolean(r?`${r}\n${i}`:i,e));return o}async evaluateChoiceBatch(t,e,r=""){if(0===this.j)throw Error("Decision is already closed.");if(0===t.length)return[];var i=this.i.h,n=sn(e),o=e.instructions??"",a=e.context?o?`${e.context}\n${o}`:e.context:o;if("function"==typeof i.evaluateChoiceBatch)return fn(this,()=>i.evaluateChoiceBatch(this.j,t,n,e.temperature??0,a,r));o=[];for(let i of t)o.push(await this.evaluateChoice(r?`${r}\n${i}`:i,e));return o}async evaluateScoreBatch(t,e,r=""){if(0===this.j)throw Error("Decision is already closed.");if(0===t.length)return[];var i=this.i.h,{rubric:n,labels:o,P:a,O:s}=ln(e),l=e.instructions??"",u=e.context?l?`${e.context}\n${l}`:e.context:l;if("function"==typeof i.evaluateScoreBatch)return(await fn(this,()=>i.evaluateScoreBatch(this.j,t,n,e.temperature??0,u,r))).map(t=>un(t,o,a,s));l=[];for(let i of t)l.push(await this.evaluateScore(r?`${r}\n${i}`:i,e));return l}close(){if(!this.W){this.W=!0;var t=this.i.h;if(0!==this.j){try{t.deleteDecision(this.j)}catch{}this.j=0}var e=this.K||this.A;if(0!==e){try{t._free(e)}catch{}this.K=this.A=0}if(0!==(e=this.L||this.C)){try{t._free(e)}catch{}this.L=this.C=0}super.close(),t&&!cn.includes(t)&&cn.push(t)}}};return gn.prototype.close=gn.prototype.close,gn.prototype.evaluateScoreBatch=gn.prototype.evaluateScoreBatch,gn.prototype.evaluateChoiceBatch=gn.prototype.evaluateChoiceBatch,gn.prototype.evaluateBooleanBatch=gn.prototype.evaluateBooleanBatch,gn.prototype.classify=gn.prototype.aa,gn.prototype.evaluateBatch=gn.prototype.ba,gn.prototype.evaluate=gn.prototype.evaluate,gn.prototype.evaluateScore=gn.prototype.evaluateScore,gn.prototype.evaluateChoice=gn.prototype.evaluateChoice,gn.prototype.evaluateBoolean=gn.prototype.evaluateBoolean,gn.prototype.setOptions=gn.prototype.S,gn.prototype.measureContextUsage=gn.prototype.ha,gn.prototype.prewarm=gn.prototype.ia,gn.prototype.setSchema=gn.prototype.T,gn.createFromModelBuffer=function(t,e,r=0,i=0){return hn(t,{baseOptions:{modelAssetBuffer:e},backendType:r,maxNumTokens:i})},gn.createFromModelPath=function(t,e,r=0,i=0){return hn(t,{baseOptions:{modelAssetPath:e},backendType:r,maxNumTokens:i})},gn.createFromOptions=hn,t.DecisionMaker=gn,t.FilesetResolver=vi,t.TaskRunner=on,t}({});
1
+ var Decision=function(t){"use strict";var e="undefined"!=typeof self?self:{};function r(t,r){t:{for(var i=["CLOSURE_FLAGS"],n=e,o=0;o<i.length;o++)if(null==(n=n[i[o]])){i=null;break t}i=n}return null!=(t=i&&i[t])?t:r}var i,n="undefined"!=typeof TextEncoder;function o(t){if(n)t=(i||=new TextEncoder).encode(t);else{let r=0,i=new Uint8Array(3*t.length);for(let n=0;n<t.length;n++){var e=t.charCodeAt(n);if(e<128)i[r++]=e;else{if(e<2048)i[r++]=e>>6|192;else{if(e>=55296&&e<=57343){if(e<=56319&&n<t.length){let o=t.charCodeAt(++n);if(o>=56320&&o<=57343){e=1024*(e-55296)+o-56320+65536,i[r++]=e>>18|240,i[r++]=e>>12&63|128,i[r++]=e>>6&63|128,i[r++]=63&e|128;continue}n--}e=65533}i[r++]=e>>12|224,i[r++]=e>>6&63|128}i[r++]=63&e|128}}t=r===i.length?i:i.subarray(0,r)}return t}var a=r(610401301,!1),s=r(748402147,!0);function l(){var t=e.navigator;return t&&(t=t.userAgent)?t:""}var u,c=e.navigator;u=c&&c.userAgentData||null;var h={},f=null;function d(t){var e=t.length,r=3*e/4;r%3?r=Math.floor(r):-1!="=.".indexOf(t[e-1])&&(r=-1!="=.".indexOf(t[e-2])?r-2:r-1);var i=new Uint8Array(r),n=0;return function(t,e){function r(e){for(;i<t.length;){let e=t.charAt(i++),r=f[e];if(null!=r)return r;if(!/^[\s\xa0]*$/.test(e))throw Error("Unknown base64 encoding at char: "+e)}return e}p();for(var i=0;;){let t=r(-1),i=r(0),n=r(64),o=r(64);if(64===o&&-1===t)break;e(t<<2|i>>4),64!=n&&(e(i<<4&240|n>>2),64!=o&&e(n<<6&192|o))}}(t,function(t){i[n++]=t}),n!==r?i.subarray(0,n):i}function p(){if(!f){f={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){let i=t.concat(e[r].split(""));h[r]=i;for(let t=0;t<i.length;t++){let e=i[t];void 0===f[e]&&(f[e]=t)}}}}var v="undefined"!=typeof Uint8Array,g=!(!(!!a&&(!!u&&u.brands.length>0))&&(-1!=l().indexOf("Trident")||-1!=l().indexOf("MSIE")))&&"function"==typeof btoa,m=/[-_.]/g,b={"-":"+",_:"/",".":"="};function y(t){return b[t]||""}function w(t){if(!g)return d(t);t=m.test(t)?t.replace(m,y):t,t=atob(t);var e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}var S,_={},A=class{constructor(t,e){if(I(e),this.i=t,null!=t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}};function I(t){if(t!==_)throw Error("illegal external caller")}function T(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}var B=void 0;function E(t){return T(t=Error(t),"warning"),t}function x(t,r){if(null!=t){var i=B??={},n=i[t]||0;n>=r||(i[t]=n+1,T(t=Error(),"incident"),function(t){e.setTimeout(()=>{throw t},0)}(t))}}function P(){return"function"==typeof BigInt}var U="function"==typeof Symbol&&"symbol"==typeof Symbol();function j(t,e,r=!1){return"function"==typeof Symbol&&"symbol"==typeof Symbol()?r&&Symbol.for&&t?Symbol.for(t):null!=t?Symbol(t):Symbol():e}var k,L=j("jas",void 0,!0),O=j(void 0,"1oa"),N=j(void 0,"0ubsb"),V=j(void 0,"0actk"),F=j("m_m","pa",!0),D={ea:{value:0,configurable:!0,writable:!0,enumerable:!1}},M=Object.defineProperties,C=U?L:"ea",G=[];function $(t,e){U||C in t||M(t,D),t[C]|=e}function z(t,e){U||C in t||M(t,D),t[C]=e}z(G,7),k=Object.freeze(G);var W={};function R(t,e){return void 0===e?t.i!==H&&!!(2&t.m[C]):!!(2&e)&&t.i!==H}var H={};function K(t,e){if(null!=t)if("string"==typeof t)t=t?new A(t,_):S||=new A(null,_);else if(t.constructor!==A)if(v&&null!=t&&t instanceof Uint8Array)t=t.length?new A(new Uint8Array(t),_):S||=new A(null,_);else{if(!e)throw Error();t=void 0}return t}function q(t){return t.oa=!0,t}var J=q(t=>"number"==typeof t),X=q(t=>"string"==typeof t),Y=q(t=>"boolean"==typeof t),Z="function"==typeof e.BigInt&&"bigint"==typeof e.BigInt(0);function Q(t){var e=t;if(X(e)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(e))throw Error(String(e))}else if(J(e)&&!Number.isSafeInteger(e))throw Error(String(e));return Z?BigInt(t):t=Y(t)?t?"1":"0":X(t)?t.trim()||"0":String(t)}var tt=q(t=>Z?t>=rt&&t<=nt:"-"===t[0]?ot(t,et):ot(t,it)),et=Number.MIN_SAFE_INTEGER.toString(),rt=Z?BigInt(Number.MIN_SAFE_INTEGER):void 0,it=Number.MAX_SAFE_INTEGER.toString(),nt=Z?BigInt(Number.MAX_SAFE_INTEGER):void 0;function ot(t,e){if(t.length>e.length)return!1;if(t.length<e.length||t===e)return!0;for(let r=0;r<t.length;r++){let i=t[r],n=e[r];if(i>n)return!1;if(i<n)return!0}}var at,st=0,lt=0;function ut(t){var e=t>>>0;st=e,lt=(t-e)/4294967296>>>0}function ct(t){if(t<0){ut(-t);let[e,r]=gt(st,lt);st=e>>>0,lt=r>>>0}else ut(t)}function ht(t,e){var r=4294967296*e+(t>>>0);return Number.isSafeInteger(r)?r:ft(t,e)}function ft(t,e){if(t>>>=0,(e>>>=0)<=2097151)var r=""+(4294967296*e+t);else P()?r=""+(BigInt(e)<<BigInt(32)|BigInt(t)):(t=(16777215&t)+6777216*(r=16777215&(t>>>24|e<<8))+6710656*(e=e>>16&65535),r+=8147497*e,e*=2,t>=1e7&&(r+=t/1e7>>>0,t%=1e7),r>=1e7&&(e+=r/1e7>>>0,r%=1e7),r=e+dt(r)+dt(t));return r}function dt(t){return t=String(t),"0000000".slice(t.length)+t}function pt(){var t=st,e=lt;if(2147483648&e)if(P())t=""+(BigInt(0|e)<<BigInt(32)|BigInt(t>>>0));else{let[r,i]=gt(t,e);t="-"+ft(r,i)}else t=ft(t,e);return t}function vt(t){if(t.length<16)ct(Number(t));else if(P())t=BigInt(t),st=Number(t&BigInt(4294967295))>>>0,lt=Number(t>>BigInt(32)&BigInt(4294967295));else{let e=+("-"===t[0]);lt=st=0;let r=t.length;for(let i=e,n=(r-e)%6+e;n<=r;i=n,n+=6){let e=Number(t.slice(i,n));lt*=1e6,(st=1e6*st+e)>=4294967296&&(lt+=Math.trunc(st/4294967296),lt>>>=0,st>>>=0)}if(e){let[t,e]=gt(st,lt);st=t,lt=e}}}function gt(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}var mt="function"==typeof BigInt?BigInt.asIntN:void 0,bt="function"==typeof BigInt?BigInt.asUintN:void 0,yt=Number.isSafeInteger,wt=Number.isFinite,St=Math.trunc;function _t(t){return null==t||"number"==typeof t?t:"NaN"===t||"Infinity"===t||"-Infinity"===t?Number(t):void 0}var At,It,Tt,Bt=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function Et(t){switch(typeof t){case"bigint":return!0;case"number":return wt(t);case"string":return Bt.test(t);default:return!1}}function xt(t){if(null==t)return t;if("string"==typeof t&&t)t=+t;else if("number"!=typeof t)return;return wt(t)?0|t:void 0}function Pt(t){var e=t.length;return("-"===t[0]?e<20||20===e&&t<="-9223372036854775808":e<19||19===e&&t<="9223372036854775807")?t:(vt(t),pt())}function Ut(t){if("-"===t[0])var e=!1;else e=(e=t.length)<20||20===e&&t<="18446744073709551615";return e?t:(vt(t),ft(st,lt))}function jt(t){if(t=St(t),!yt(t)){ct(t);var e=st,r=lt;(t=2147483648&r)&&(r=~r>>>0,0==(e=1+~e>>>0)&&(r=r+1>>>0)),t="number"==typeof(e=ht(e,r))?t?-e:e:t?"-"+e:e}return t}function kt(t){return(t=St(t))>=0&&yt(t)||(ct(t),t=ht(st,lt)),t}function Lt(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(mt(64,t));if(Et(t)){if("string"===e)return e=St(Number(t)),yt(e)?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=Pt(t)),t;if("number"===e)return jt(t)}}function Ot(t){if(null==t||"string"==typeof t||t instanceof A)return t}function Nt(t){return null==t||"string"==typeof t?t:void 0}function Vt(t,e,r){if(null!=t&&t[F]===W)return t;if(Array.isArray(t)){var i=0|t[C];return(r=i|32&r|2&r)!==i&&z(t,r),new e(t)}}function Ft(t){return t}function Dt(t,e,r,i){var n=void 0!==i;i=!!i;var o=[],a=t.length,s=4294967295,l=!1,u=!!(64&e),c=u?128&e?0:-1:void 0;if(!(1&e)){var h=a&&t[a-1];null!=h&&"object"==typeof h&&h.constructor===Object?s=--a:h=void 0,!u||128&e||n||(l=!0,s=(At??Ft)(s-c,c,t,h,void 0)+c)}for(e=void 0,n=0;n<a;n++){let a=t[n];if(null!=a&&null!=(a=r(a,i)))if(u&&n>=s){let t=n-c;(e??={})[t]=a}else o[n]=a}if(h)for(let n in h){if(null==(t=h[n])||null==(t=r(t,i)))continue;let l;a=+n,u&&!Number.isNaN(a)&&(l=a+c)<s?o[l]=t:(e??={})[n]=t}return e&&(l?o.push(e):o[s]=e),o}function Mt(t){switch(typeof t){case"number":return Number.isFinite(t)?t:""+t;case"bigint":return tt(t)?Number(t):""+t;case"boolean":return t?1:0;case"object":if(Array.isArray(t)){var e=0|t[C];return 0===t.length&&1&e?void 0:Dt(t,e,Mt)}if(null!=t&&t[F]===W)return Ct(t);if(t instanceof A){if(null==(e=t.i))t="";else if("string"==typeof e)t=e;else{if(g){for(var r="",i=0,n=e.length-10240;i<n;)r+=String.fromCharCode.apply(null,e.subarray(i,i+=10240));r+=String.fromCharCode.apply(null,i?e.subarray(i):e),e=btoa(r)}else{void 0===r&&(r=0),p(),r=h[r],i=Array(Math.floor(e.length/3)),n=r[64]||"";let t=0,u=0;for(;t<e.length-2;t+=3){var o=e[t],a=e[t+1],s=e[t+2],l=r[o>>2];o=r[(3&o)<<4|a>>4],a=r[(15&a)<<2|s>>6],s=r[63&s],i[u++]=l+o+a+s}switch(l=0,s=n,e.length-t){case 2:s=r[(15&(l=e[t+1]))<<2]||n;case 1:e=e[t],i[u]=r[e>>2]+r[(3&e)<<4|l>>4]+s+n}e=i.join("")}t=t.i=e}return t}return}return t}function Ct(t){return Dt(t=t.m,0|t[C],Mt)}function Gt(t,e,r,i=0){if(null==t){var n=32;r?(t=[r],n|=128):t=[],e&&(n=-16760833&n|(1023&e)<<14)}else{if(!Array.isArray(t))throw Error("narr");if(n=0|t[C],s&&1&n)throw Error("rfarr");if(2048&n&&!(2&n)&&function(){if(s)throw Error("carr");x(V,5)}(),256&n)throw Error("farr");if(64&n)return(n|i)!==n&&z(t,n|i),t;if(r&&(n|=128,r!==t[0]))throw Error("mid");t:{n|=64;var o=(r=t).length;if(o){var a=o-1;let t=r[a];if(null!=t&&"object"==typeof t&&t.constructor===Object){if((a-=e=128&n?0:-1)>=1024)throw Error("pvtlmt");for(var l in t)(o=+l)<a&&(r[o+e]=t[l],delete t[l]);n=-16760833&n|(1023&a)<<14;break t}}if(e){if((l=Math.max(e,o-(128&n?0:-1)))>1024)throw Error("spvt");n=-16760833&n|(1023&l)<<14}}}return z(t,64|n|i),t}function $t(t,e){if("object"!=typeof t)return t;if(Array.isArray(t)){var r=0|t[C];return 0===t.length&&1&r?t=void 0:2&r||(!e||4096&r||16&r?t=Wt(t,r,!1,e&&!(16&r)):($(t,34),4&r&&Object.freeze(t))),t}return null!=t&&t[F]===W?R(t,r=0|(e=t.m)[C])?t:qt(t,e,r)?zt(t,e):Wt(e,r):t instanceof A?t:void 0}function zt(t,e,r){return t=new t.constructor(e),r&&(t.i=H),t.o=H,t}function Wt(t,e,r,i){return i??=!!(34&e),t=Dt(t,e,$t,i),i=32,r&&(i|=2),z(t,e=16769217&e|i),t}function Rt(t){if(t.i!==H)return!1;var e=t.m;return $(e=Wt(e,0|e[C]),2048),t.m=e,t.i=void 0,t.o=void 0,!0}function Ht(t){if(!Rt(t)&&R(t,0|t.m[C]))throw Error()}function Kt(t,e){void 0===e&&(e=0|t[C]),32&e&&!(4096&e)&&z(t,4096|e)}function qt(t,e,r){return!!(2&r)||!(!(32&r)||4096&r)&&(z(e,2|r),t.i=H,!0)}function Jt(t,e,r){if(null!==(t=Xt(t.m,e,void 0,r)))return t}function Xt(t,e,r,i){if(-1===e)return null;var n=e+(r?0:-1),o=t.length-1;if(!(o<1+(r?0:-1))){if(n>=o){var a=t[o];if(null!=a&&"object"==typeof a&&a.constructor===Object){r=a[e];var s=!0}else{if(n!==o)return;r=a}}else r=t[n];if(i&&null!=r){if(null==(i=i(r)))return i;if(!Object.is(i,r))return s?a[e]=i:t[n]=i,i}return r}}function Yt(t,e,r){Ht(t);var i=t.m;return Zt(i,0|i[C],e,r),t}function Zt(t,e,r,i,n){var o=r+(n?0:-1),a=t.length-1;if(a>=1+(n?0:-1)&&o>=a){let n=t[a];if(null!=n&&"object"==typeof n&&n.constructor===Object)return n[r]=i,e}return o<=a?(t[o]=i,e):(void 0!==i&&(r>=(a=(e??=0|t[C])>>14&1023||536870912)?null!=i&&(t[a+(n?0:-1)]={[r]:i}):t[o]=i),e)}function Qt(t,e,r){return t=Xt(t,e,r),Array.isArray(t)?t:k}function te(t,e){return 2&e&&(t|=2),1|t}function ee(t){return!!(2&t)&&!!(4&t)||!!(256&t)}function re(t){return K(t,!0)}function ie(t){if(U)return t[O]??(t[O]=new Map);if(O in t)return t[O];var e=new Map;return Object.defineProperty(t,O,{value:e}),e}function ne(t,e,r,i){var n=t.get(i);if(null!=n)return n;n=0;for(let t=0;t<i.length;t++){let o=i[t];null!=Xt(e,o)&&(0!==n&&(r=Zt(e,r,n)),n=o)}return t.set(i,n),n}function oe(t,e,r){var i=t.m,n=0|i[C];if(e=function(t,e,r,i){var n=!1;if(null!=(i=Xt(t,i,void 0,t=>{var i=Vt(t,r,e);return n=i!==t&&null!=i,i})))return n&&!R(i)&&Kt(t,e),i}(i,n,e,r),null==e)return e;if(!R(t,n=0|i[C])){var o,a=e;let s=a.m,l=0|s[C];(o=R(a,l)?qt(a,s,l)?zt(a,s,!0):new a.constructor(Wt(s,l,!1)):a)!==e&&(Rt(t)&&(n=0|(i=t.m)[C]),Kt(i,n=Zt(i,n,r,e=o)))}return e}function ae(t){return null==t&&(t=void 0),t}function se(t,e,r){return Yt(t,e,r=ae(r)),r&&!R(r)&&Kt(t.m),t}function le(t,e,r,i){t:{var n=i=ae(i);Ht(t);let s=t.m;var o=0|s[C];if(null==n){var a=ie(s);if(ne(a,s,o,r)!==e)break t;a.set(r,0)}else{let t=ie(a=s),i=ne(t,a,o,r);i!==e&&(i&&(o=Zt(a,o,i)),t.set(r,e))}Zt(s,o,e,n)}return i&&!R(i)&&Kt(t.m),t}function ue(t,e){return-273&(2&e?2|t:-3&t)}function ce(t,e){var r=mi;Ht(t);var i=t.m,n=i,o=0|i[C],a=R(t,o)?1:2;2===a&&Rt(t)&&(o=0|(n=t.m)[C]);var s=Qt(n,8),l=s===k?7:0|s[C],u=te(l,o);if(t=!(4&u)){var c=o;let t=!!(2&u);t&&(c|=2);let e=!t,i=!0,n=0,a=0;for(;n<s.length;n++){let o=Vt(s[n],r,c);if(o instanceof r){if(!t){let t=R(o);e&&=!t,i&&=t}s[a++]=o}}a<n&&(s.length=a),u|=4,u=i?-4097&u:4096|u,u=e?8|u:-9&u}u!==l&&(z(s,u),2&u&&Object.freeze(s)),u=l=u,1===a||4===a&&(2&l||!(16&l)&&32&o)?ee(l)||((l|=!s.length||t&&!(4096&l)||32&o&&!(4096&l||16&l)?2:256)!==u&&z(s,l),Object.freeze(s)):(2===a&&ee(l)&&(s=Array.prototype.slice.call(s),u=0,l=ue(l,o),o=Zt(n,o,8,s)),ee(l)||l!==u&&z(s,l)),2&l||!(4096&l||16&l)||Kt(n,o),a=s,e=null!=e?e:new r,a.push(e),t=r=a===k?7:0|a[C],(e=R(e))?(r&=-9,1===a.length&&(r&=-4097)):r|=4096,r!==t&&z(a,r),e||Kt(i)}function he(t,e,r){return Yt(t,e,null==r?r:function(t){if(!Et(t))throw E("int64");switch(typeof t){case"string":var e=St(Number(t));return yt(e)?t=Q(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=P()?Q(mt(64,BigInt(t))):Q(Pt(t))),t;case"bigint":return Q(mt(64,t));default:return yt(t)?t=Q(jt(t)):(t=St(t),yt(t)?t=String(t):(ct(t),t=pt()),t=Q(t)),t}}(r))}function fe(t,e,r){return Yt(t,e,null==r?r:function(t){if(!Et(t))throw E("uint64");switch(typeof t){case"string":var e=St(Number(t));return yt(e)&&e>=0?t=Q(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=P()?Q(bt(64,BigInt(t))):Q(Ut(t))),t;case"bigint":return Q(bt(64,t));default:return yt(t)?t=Q(kt(t)):((t=St(t))>=0&&yt(t)?t=String(t):(ct(t),t=ft(st,lt)),t=Q(t)),t}}(r))}function de(t,e,r){if(null!=r&&"string"!=typeof r)throw Error();return Yt(t,e,r)}function pe(t,e,r){if(null!=r){if(!wt(r))throw E("enum");r|=0}return Yt(t,e,r)}var ve=class{constructor(t,e,r){if(this.buffer=t,r&&!e)throw Error()}};function ge(t){if("string"==typeof t)return new ve(w(t),!0);if(Array.isArray(t))return new ve(new Uint8Array(t),!0);if(t.constructor===Uint8Array)return new ve(t,!1);if(t.constructor===ArrayBuffer)return t=new Uint8Array(t),new ve(t,!1);if(t.constructor===A){I(_);var e=t.i;return e=(null==(e=null==e||v&&null!=e&&e instanceof Uint8Array?e:"string"==typeof e?w(e):null)?e:t.i=e)||new Uint8Array(0),new ve(e,!0,t)}if(t instanceof Uint8Array)return t=t.constructor===Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new ve(t,!1);throw Error()}function me(t){return new we(4294967295&t,Math.floor(t/4294967296))}function be(t){return t?/^\d+$/.test(t)?(vt(t),new we(st,lt)):null:ye||=new we(0,0)}var ye,we=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};function Se(t){return new je(4294967295&t,Math.floor(t/4294967296))}function _e(t){return t?/^-?\d+$/.test(t)?(vt(t),new je(st,lt)):null:Ae||=new je(0,0)}var Ae,Ie,Te,Be,Ee,xe,Pe,Ue,je=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};function ke(t,e,r){return"undefined"!=typeof BigInt64Array?(Pe||(Pe=new BigInt64Array(1),Ue=new Uint32Array(Pe.buffer),Pe[0]=BigInt(1),xe=1===Ue[0]),Pe[0]=t,new e(Ue[t=xe?0:1],Ue[1-t])):(Ee||(Ie=BigInt(Number.MIN_SAFE_INTEGER),Te=BigInt(Number.MAX_SAFE_INTEGER),Be=BigInt(4294967295),Ee=BigInt(32)),t>=Ie&&t<=Te?r(Number(t)):(t=BigInt.asUintN(64,t),new e(Number(t&Be),Number(t>>Ee))))}function Le(t,e,r){for(;r>0||e>127;)t.i.push(127&e|128),e=(e>>>7|r<<25)>>>0,r>>>=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 Ne(t,e){if(e>=0)Oe(t,e);else{for(let r=0;r<9;r++)t.i.push(127&e|128),e>>=7;t.i.push(1)}}function Ve(t,e){vt(e),function(t){var e=lt>>31;t(st<<1^e,(lt<<1|st>>>31)^e)}((e,r)=>{Le(t,e>>>0,r>>>0)})}function Fe(t,e){t.i.push(e>>>0&255),t.i.push(e>>>8&255),t.i.push(e>>>16&255),t.i.push(e>>>24&255)}var De=class{constructor(){this.i=[]}length(){return this.i.length}end(){var t=this.i;return this.i=[],t}};function Me(t,e){0!==e.length&&(t.l.push(e),t.j+=e.length)}function Ce(t,e,r){Oe(t.i,8*e+r)}function Ge(t,e){return Ce(t,e,2),e=t.i.end(),Me(t,e),e.push(t.j),e}function $e(t,e){var r=e.pop();for(r=t.j+t.i.length()-r;r>127;)e.push(127&r|128),r>>>=7,t.j++;e.push(r),t.j++}function ze(t,e,r){if(null!=r)switch(Ce(t,e,0),typeof r){case"number":t=t.i,ct(r),Le(t,st,lt);break;case"bigint":r=ke(r,je,Se),Le(t.i,r.j,r.i);break;default:r=_e(r),Le(t.i,r.j,r.i)}}function We(t,e,r){Ce(t,e,2),Oe(t.i,r.length),Me(t,t.i.end()),Me(t,r)}var Re=class{constructor(){this.l=[],this.j=0,this.i=new De}};function He(t){if("string"==typeof t)_e(t)}function Ke(){var t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var qe=Ke(),Je=Ke(),Xe=Ke(),Ye=Ke(),Ze=Ke(),Qe=Ke(),tr=Ke(),er=Ke(),rr=Ke(),ir=Ke(),nr=Ke(),or=Ke(),ar=class{constructor(t,e){this.m=Gt(t,e,void 0,2048)}toJSON(){return Ct(this)}};ar.prototype[F]=W,ar.prototype.toString=function(){return this.m.toString()};var sr=class{constructor(t,e){this.i=t,t=qe,this.j=!!t&&e===t||!1}};function lr(t,e,r,i,n){null!=(e=gr(e,i))&&(r=Ge(t,r),n(e,t),$e(t,r))}var ur,cr,hr=new sr(lr,qe),fr=new sr(lr,qe),dr=Symbol(),pr=Symbol();function vr(t){var e=mr,r=br,i=t[dr];if(i)return i;(i={}).ma=t,i.Y=function(t){switch(typeof t){case"boolean":return It||=[0,void 0,!0];case"number":return t>0?void 0:0===t?Tt||=[0,void 0]:[-t,void 0];case"string":return[0,t];case"object":return t}}(t[0]);var n=t[1],o=1;n&&n.constructor===Object&&(i.ca=n,"function"==typeof(n=t[++o])&&(i.fa=!0,ur??=n,cr??=t[o+1],n=t[o+=2]));for(var a={};n&&Array.isArray(n)&&n.length&&"number"==typeof n[0]&&n[0]>0;){for(var s=0;s<n.length;s++)a[n[s]]=n;n=t[++o]}for(s=1;void 0!==n;){let c;"number"==typeof n&&(s+=n,n=t[++o]);var l=void 0;if(n instanceof sr?c=n:(c=hr,o--),c?.j){n=t[++o],l=t;var u=o;"function"==typeof n&&(n=n(),l[u]=n),l=n}for(u=s+1,"number"==typeof(n=t[++o])&&n<0&&(u-=n,n=t[++o]);s<u;s++){let t=a[s];l?r(i,s,c,l,t):e(i,s,c,t)}}return t[dr]=i}function gr(t,e){return t instanceof ar?t.m:Array.isArray(t)?Gt(t,e[0],e[1]):void 0}function mr(t,e,r){t[e]=r.i}function br(t,e,r,i){var n,o,a=r.i;t[e]=(t,e,r)=>a(t,e,r,o||=vr(i).Y,n||=yr(i))}function yr(t){var e=t[pr];if(!e){let r=vr(t);e=(t,e)=>wr(t,e,r),t[pr]=e}return e}function wr(t,e,r){!function(t,e,r){var i,n=128&e?0:-1,o=t.length;(i=!!o)&&(i=null!=(i=t[o-1])&&"object"==typeof i&&i.constructor===Object);var a=o+(i?-1:0);for(e=128&e?1:0;e<a;e++)r(e-n,t[e]);if(i){t=t[o-1];for(let e in t)!isNaN(e)&&r(+e,t[e])}}(t,0|t[C],(t,i)=>{if(null!=i){var n=function(t,e){var r=t[e];if(r)return r;if((r=t.ca)&&(r=r[e])){var i=(r=Array.isArray(r)?r[0]instanceof sr?r:[fr,r]:[r,void 0])[0].i;if(r=r[1]){let e=yr(r),n=vr(r).Y;r=t.fa?cr(n,e):(t,r,o)=>i(t,r,o,n,e)}else r=i;return t[e]=r}}(r,t);n?n(e,i,t):t<500||x(N,3)}})}function Sr(t,e,r){if(Array.isArray(e)){var i=0|e[C];if(4&i)return e;for(var n=0,o=0;n<e.length;n++){let r=t(e[n]);null!=r&&(e[o++]=r)}return o<n&&(e.length=o),t=1|i,r&&(t=-1537&t|4),t!==i&&z(e,t),r&&2&t&&Object.freeze(e),e}}var _r=(t,e)=>{var r=new Re;wr(t.m,r,vr(e)),Me(r,r.i.end()),t=new Uint8Array(r.j);var i=(e=r.l).length,n=0;for(let r=0;r<i;r++){let i=e[r];t.set(i,n),n+=i.length}return r.l=[t],t};function Ar(t,e){return new sr(t,e)}function Ir(t,e){return new sr(t,e)}function Tr(t,e,r){null!=(e=Lt(e))&&(He(e),ze(t,r,e))}function Br(t,e,r){null!=(e=xt(e))&&null!=e&&(Ce(t,r,0),Ne(t.i,e))}function Er(t,e,r){null!=(e=Nt(e))&&We(t,r,o(e))}function xr(t,e,r,i,n){null!=(e=gr(e,i))&&(r=Ge(t,r),n(e,t),$e(t,r))}function Pr(t,e,r){null!=(e=Ot(e))&&We(t,r,ge(e).buffer)}function Ur(t,e,r){null!=(e=xt(e))&&(e=parseInt(e,10),Ce(t,r,0),Ne(t.i,e))}var jr,kr=Ar(function(t,e,r){null!=(e=_t(e))&&(Ce(t,r,1),t=t.i,(r=at||=new DataView(new ArrayBuffer(8))).setFloat64(0,+e,!0),st=r.getUint32(0,!0),lt=r.getUint32(4,!0),Fe(t,st),Fe(t,lt))},ir),Lr=Ar(function(t,e,r){null!=(e=_t(e))&&(Ce(t,r,5),t=t.i,(r=at||=new DataView(new ArrayBuffer(8))).setFloat32(0,+e,!0),lt=0,Fe(t,st=r.getUint32(0,!0)))},rr),Or=Ar(Tr,Qe),Nr=Ar(Tr,Qe),Vr=Ir(function(t,e,r){if(null!=(e=Sr(Lt,e,!1)))for(let i=0;i<e.length;i++)ze(t,r,e[i])},Qe),Fr=Ar(function(t,e,r){if(e=function(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(bt(64,t));if(Et(t)){if("string"===e)return e=St(Number(t)),yt(e)&&e>=0?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=Ut(t)),t;if("number"===e)return kt(t)}}(e),null!=e){if("string"==typeof e)be(e);if(null!=e)switch(Ce(t,r,0),typeof e){case"number":t=t.i,ct(e),Le(t,st,lt);break;case"bigint":r=ke(e,we,me),Le(t.i,r.j,r.i);break;default:r=be(e),Le(t.i,r.j,r.i)}}},tr),Dr=Ar(Br,Ye),Mr=Ir(function(t,e,r){if(null!=(e=Sr(xt,e,!0)))for(let a=0;a<e.length;a++){var i=t,n=r,o=e[a];null!=o&&(Ce(i,n,0),Ne(i.i,o))}},Ye),Cr=Ir(function(t,e,r){if(null!=(e=Sr(xt,e,!0))&&e.length){r=Ge(t,r);for(let r=0;r<e.length;r++)Ne(t.i,e[r]);$e(t,r)}},Ye),Gr=Ar(function(t,e,r){null!=(e=null==e||"boolean"==typeof e?e:"number"==typeof e?!!e:void 0)&&(Ce(t,r,0),t.i.i.push(e?1:0))},Je),$r=Ar(Er,Xe),zr=Ir(function(t,e,r){if(null!=(e=Sr(Nt,e,!0)))for(let s=0;s<e.length;s++){var i=t,n=r,a=e[s];null!=a&&We(i,n,o(a))}},Xe),Wr=function(t,e,r=qe){return new sr(e,r)}(0,function(t,e,r,i,n){if(Array.isArray(e)){for(let o=0;o<e.length;o++)xr(t,e[o],r,i,n);1&(t=0|e[C])||z(e,1|t)}}),Rr=new sr(xr,qe),Hr=Ar(Pr,nr),Kr=Ir(function(t,e,r){if(null!=(e=Sr(Ot,e,!1)))for(let a=0;a<e.length;a++){var i=t,n=r,o=e[a];null!=o&&We(i,n,ge(o).buffer)}},nr),qr=Ar(function(t,e,r){e=function(t){if(null==t)return t;if("string"==typeof t&&t)t=+t;else if("number"!=typeof t)return;return wt(t)?t>>>0:void 0}(e),null!=e&&null!=e&&(Ce(t,r,0),Oe(t.i,e))},Ze),Jr=Ar(Ur,or),Xr=Ar(Ur,or),Yr=Ar(function(t,e,r){if(null!=(e=Lt(e))&&(He(e),null!=e))switch(Ce(t,r,0),typeof e){case"number":t=t.i,e=(r=e)<0,ut(r=2*Math.abs(r)),r=st;let i=lt;e&&(0==r?0==i?i=r=4294967295:(i--,r=4294967295):r--),Le(t,st=r,lt=i);break;case"bigint":t=t.i,e=e<<BigInt(1)^e>>BigInt(63),st=Number(BigInt.asUintN(32,e)),lt=Number(BigInt.asUintN(32,e>>BigInt(32))),Le(t,st,lt);break;default:Ve(t.i,e)}},er),Zr=[0,Hr,Kr,Gr,$r],Qr=[0,Ar(Er,Xe),[0,Xr,[0,Ar(Tr,Qe),Ar(Br,Ye)],Xr,-1,[0,Jr],Xr,-1],Ar(Pr,nr)],ti=[0,1,[0,12,Dr,10,Gr],[0,7,[0,Dr,-1]]],ei=globalThis.trustedTypes;var ri=class{constructor(t){this.i=t}toString(){return this.i+""}};function ii(t){var e;return void 0===jr&&(jr=function(){var t=null;if(!ei)return t;try{let e=t=>t;t=ei.createPolicy("goog#html",{createHTML:e,createScript:e,createScriptURL:e})}catch(t){}return t}()),t=(e=jr)?e.createScriptURL(t):t,new ri(t)}function ni(t,...e){if(0===e.length)return ii(t[0]);var r=t[0];for(let i=0;i<e.length;i++)r+=encodeURIComponent(e[i])+t[i+1];return ii(r)}var oi,ai=class extends ar{constructor(t){super(t)}},si=class extends ar{constructor(t){super(t)}},li=class extends ar{constructor(t){super(t)}},ui=[1,2,3,4,5,6],ci=class extends ar{constructor(t){super(t)}j(){return null!=Jt(this,1,re)}l(){return null!=Nt(Jt(this,2))}},hi=class extends ar{constructor(t){super(t)}},fi=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 di(t){if(t)return!0;if(void 0===oi)try{await WebAssembly.instantiate(fi),oi=!0}catch{oi=!1}return oi}async function pi(t,e,r){return{wasmLoaderPath:`${e}/${t}_${r=`wasm${r?"_module":""}${await di(r)?"":"_nosimd"}_internal`}.js`,wasmBinaryPath:`${e}/${t}_${r}.wasm`}}var vi=class{};function gi(t){return pe(new mi,1,t)}vi.forVisionTasks=function(t,e=!1){return pi("vision",t??ni``,e)},vi.forLiteRtLmTextTasks=function(t,e=!1){return pi("litertlm_text",t??ni``,e)},vi.forTextTasks=function(t,e=!1){return pi("text",t??ni``,e)},vi.forRetrievalTasks=function(t,e=!1){return pi("retrieval",t??ni``,e)},vi.forGenAiTasks=function(t,e=!1){return pi("genai",t??ni``,e)},vi.forDecisionTasks=function(t,e=!1){return pi("decision",t??ni``,e)},vi.forAudioTasks=function(t,e=!1){return pi("audio",t??ni``,e)},vi.isSimdSupported=function(t=!1){return di(t)};var mi=class extends ar{constructor(t){super(t)}},bi=class extends ar{constructor(t){super(t)}},yi=[0,Jr,2,Fr,-2,Nr,Wr,[0,Jr,Nr]],wi=class extends ar{constructor(t){super(t)}},Si=class extends ar{constructor(t){super(t)}};function _i(t){var e=new Ii;return e=pe(e,1,30),pe(e,2,t)}var Ai,Ii=class extends ar{constructor(t){super(t)}},Ti=[3,4,5,6,7],Bi=class extends ar{constructor(t){super(t)}},Ei=class extends ar{constructor(t){super(t)}};Ei.prototype.j=(Ai=[0,[0,Jr,$r,-3,Jr],[0,Ti,Jr,-1,Rr,[0,Jr,$r,Fr],Rr,yi,Rr,[0,1,yi],Rr,[0,Jr],Rr,[0,Jr,$r,Fr]]],function(){return _r(this,Ai)});var xi=class{constructor(){this.i="undefined"!=typeof AbortController}async send(t,e,r){var i=this.i?new AbortController:void 0,n=i&&t.U>0?setTimeout(()=>{i.abort()},t.U):void 0;try{let n=await fetch(t.url,{method:t.la,headers:{...t.ka},...t.body&&{body:t.body},...t.withCredentials&&{credentials:"include"},signal:t.U&&i?i.signal:null});200===n.status?e?.(await n.text()):r?.(n.status)}catch(t){if("AbortError"===t?.name)r?.(408);else r?.(400)}finally{clearTimeout(n)}}},Pi=class extends ar{constructor(t){super(t,37)}},Ui=[-4,{},ti,Jr,Qr],ji=[0,$r,Jr,1,$r,-1,Jr,1,Jr,1,Nr],ki=[0,Jr,$r,-2],Li=[0,$r,Jr],Oi=[0,$r,Jr],Ni=[0,Gr,-3],Vi=[0,Jr,$r,-1,Nr,Dr,-1,$r,-5,Wr,[0,$r,-4],-1,Gr,[0,Gr,-3],Jr];var Fi=class extends ar{constructor(t){super(t,19)}},Di=function(t){return e=>_r(e,t)}([-19,{},[0,Jr,1,[0,$r,-6,Nr,Dr,$r,-1,Nr],1,[0,$r,1,$r,-5],$r,-1,[0,Jr,$r,-8],[0,$r,-3],[0,$r,Jr,$r,-2],[0,$r,-1,Jr,$r,-1,Jr,$r,-1,[0,Wr,[0,$r,-1],Gr,$r,-5],[0,Jr,Gr,Dr,-2]],Nr,[0,$r,-3,Nr,Dr,$r,-1],[0,Jr,$r,-1],[0,$r,-9],[0,$r,-6,Jr,$r,1,$r,Gr,Jr,-1,Gr,$r,-2,Jr,$r,Jr,$r,Dr,-1],1,[0,Jr],1,[0,$r,-4],1,ji,[0,[1,2,3,4,5,6],Rr,ji,Rr,Li,Rr,Oi,Rr,[0,Jr],Rr,Vi,Rr,ki],Li,Oi,Vi,[0,[0,Jr,$r,-1,Nr,Dr,-1,$r,-4,Wr,[0,$r,-4],-1,1,Ni],[0,Jr,$r,-1,Nr,Dr,-1,$r,-4,Ni]],ki,[0,$r,[0,Dr,-3,Jr],Jr,-2,[0,Dr,-1],Gr],4,[0,$r,Jr,$r,-1,Nr,Jr,$r,-1,Jr,Dr,-1]],Jr,Wr,[-37,{},Or,$r,Wr,[0,$r,-1],Hr,1,Hr,[0,zr,-1,Mr,Vr,-1],$r,[0,Dr,$r,-1],Gr,Dr,Nr,$r,-1,Yr,Zr,Or,Hr,Jr,Mr,Nr,-1,[0,Jr,-1],$r,Gr,$r,Cr,$r,-1,kr,1,kr,Ui,Gr,[0,Jr,[0,Lr,Dr,-2],[0,Lr]],[0,Jr,Nr]],Or,Kr,$r,-1,Or,Jr,-1,[0,Gr,-1,Jr,Gr],[0,Nr,-1,$r],[0,Or,Gr,Nr],Nr,1,qr,1,Ui]),Mi=class{constructor(t){this.j=[],this.o=new xi,this.l=t??"",this.i=setInterval(()=>{this.flush()},6e4)}close(){void 0!==this.i&&(clearInterval(this.i),this.i=void 0),this.flush()}flush(t,e){if(this.error)e?.("net-send-failed");else if(0===this.j.length)t?.();else{var r=this.j;this.j=[],r=function(t){var e=new Fi;{Ht(e=pe(e,2,1786));let u=e.m,c=0|u[C];if(null==t)Zt(u,c,3);else{var r=t===k?7:0|t[C],i=r,n=ee(r),o=n||Object.isFrozen(t),a=!0,s=!0;for(let e=0;e<t.length;e++){var l=t[e];n||(l=R(l),a&&=!l,s&&=l)}n||(r=a?13:5,r=s?-4097&r:4096|r),o&&r===i||(t=Array.prototype.slice.call(t),i=0,r=ue(r,c)),r!==i&&z(t,r),c=Zt(u,c,3,t),2&r||!(4096&r||16&r)||Kt(u,c)}}return e}(r),r=Di(r),this.o.send({url:"https://odml.pa.googleapis.com/v1/log",la:"POST",U:1e4,body:r,na:2,ka:{"Content-Type":"application/x-protobuf","x-goog-api-key":this.l},withCredentials:!1},()=>{t?.()},t=>{this.error=Error(`Logging failed with HTTP error: ${t}`),this.j=[],void 0!==this.i&&(clearInterval(this.i),this.i=void 0),e?.("net-send-failed",t)})}}};class Ci{constructor(){this.M=this.D=this.I=this.B=this.G=this.H=this.F=0}}function Gi(t,e){var r=new Ei;r=se(r,1,t.L),r=se(r,2,e),e=Yt(e=new Pi,6,K(r=r.j(),!1)),(t=t.C).error||t.j.push(e)}function $i(t,e){var r={F:e.F-t.l.F,H:e.H-t.l.H,G:e.G-t.l.G,B:e.B-t.l.B,I:e.I-t.l.I,D:e.D,M:e.M},i=_i(1);r=zi(t,r),Gi(t,i=le(i,4,Ti,r)),t.l=e}function zi(t,e){var r=new bi;return t=fe(t=he(t=pe(r,1,t.J),7,e.B),5,e.D),t=fe(t,6,e.M),e.G>0&&fe(t,4,e.I/e.G),0!==e.F&&ce(t,r=he(r=gi(3),2,e.F)),0!==e.H&&ce(t,e=he(r=gi(4),2,e.H)),t}var Wi=class{constructor(t,e){this.K=performance.now(),this.o=performance.now(),this.j=new Map,this.A=0,this.i=new Ci,this.l=new Ci,this.C=new Mi(e),this.J=function(t){switch(t){case"IMAGE":return 11;case"VIDEO":return 12;case"LIVE_STREAM":return 13;case"AUDIO_CLIPS":return 14;case"AUDIO_STREAM":return 15;default:return 10}}(t),t=new Bi,"undefined"==typeof window?e=0:(e=navigator.userAgent,e=/Android/i.test(e)?1:/iPhone|iPad|iPod/i.test(e)?2:/Windows/i.test(e)?5:/Macintosh/i.test(e)?4:/Linux/i.test(e)?3:0),t=de(t=pe(t,1,e),2,""),t=de(t,3,""),t=de(t,4,"1.1.0"),t=de(t,5,""),this.L=pe(t,6,4)}X(){var t=new Si;t=fe(t=pe(t,1,this.J),3,performance.now()-this.K),Gi(this,t=le(_i(0),3,Ti,t)),this.o=performance.now()}R(t){var e=this.j.get(t);if(void 0!==e&&(this.j.delete(t),t=performance.now()-e,++this.i.G,this.i.I+=t,this.i.D=Math.max(this.i.D,t),this.A=Math.max(this.A,t),performance.now()>this.o+3e4)){for(let[r,i]of this.j.entries())t=r,i<e&&(this.i.B++,this.j.delete(t));e={...this.i,M:performance.now()-this.o},this.i.D=0,this.o=performance.now(),$i(this,e)}}ga(){var t={...this.i,B:this.i.B+this.j.size,D:this.A,M:performance.now()-this.K};$i(this,t);var e=new wi;e=se(e,2,t=zi(this,t)),Gi(this,e=le(t=_i(2),5,Ti,e))}close(){var t=this.C;"function"==typeof t.close?t.close():t.flush()}};function Ri(){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 Hi(t){if("function"!=typeof importScripts){let e=document.createElement("script");return e.src=t.toString(),e.crossOrigin="anonymous",new Promise((t,r)=>{e.addEventListener("load",()=>{t()},!1),e.addEventListener("error",t=>{r(t)},!1),document.body.appendChild(e)})}try{importScripts(t.toString())}catch(e){if(!(e instanceof TypeError))throw e;{let e=self.import;e?await e(t.toString()):await import(t.toString())}}}function Ki(t,e,r){t.o||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),r(e=t.h.stringToNewUTF8(e)),t.h._free(e)}function qi(t,e,r){t.o||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");var i=new Uint32Array(e.length);for(let r=0;r<e.length;r++)i[r]=t.h.stringToNewUTF8(e[r]);e=t.h._malloc(4*i.length),t.h.HEAPU32.set(i,e>>2),r(e);for(let e of i)t.h._free(e);t.h._free(e)}function Ji(t,e,r){t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=r}function Xi(t,e,r){var i=[];t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=(t,e,n)=>{e?(r(i,n),i=[]):i.push(t)}}var Yi=function(t){return class extends t{get V(){return this.h}da(){if("function"==typeof this.V._mediapipeLoggerGetEncodedApiKey){let t=this.V._mediapipeLoggerGetEncodedApiKey();return this.V._decodeBase64(t)}}}}(function(t){return class extends t{ja(){this.h._registerModelResourcesGraphService()}}}(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:Ri()?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){var 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){var r=t.length,i=this.h._malloc(r);this.h.HEAPU8.set(t,i),e?this.h._changeBinaryGraph(r,i):this.h._changeTextGraph(r,i),this.h._free(i)}configureAudio(t,e,r,i,n){this.h._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),Ki(this,i||"input_audio",i=>{Ki(this,n=n||"audio_header",n=>{this.h._configureAudio(i,n,t,e??0,r)})})}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,r){this.addAudioToStreamWithShape(t,0,0,e,r)}addAudioToStreamWithShape(t,e,r,i,n){var 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),Ki(this,i,t=>{this.h._addAudioToInputStream(this.i,e,r,t,n)})}addGpuBufferToStream(t,e,r){Ki(this,e,e=>{if(!this.h.canvas)throw Error("No OpenGL canvas configured.");e?this.h._bindTextureToStream(e):this.h._bindTextureToCanvas();var i=this.h.canvas.getContext("webgl2")||this.h.canvas.getContext("webgl");if(!i)throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");this.h.gpuOriginForWebTexturesIsBottomLeft&&i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!0),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,t),this.h.gpuOriginForWebTexturesIsBottomLeft&&i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1);var[n,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||n===this.h.canvas.width&&o===this.h.canvas.height||(this.h.canvas.width=n,this.h.canvas.height=o);var[a,s]=[n,o];this.h._addBoundTextureToStream(e,a,s,r)})}addBoolToStream(t,e,r){Ki(this,e,e=>{this.h._addBoolToInputStream(t,e,r)})}addDoubleToStream(t,e,r){Ki(this,e,e=>{this.h._addDoubleToInputStream(t,e,r)})}addFloatToStream(t,e,r){Ki(this,e,e=>{this.h._addFloatToInputStream(t,e,r)})}addIntToStream(t,e,r){Ki(this,e,e=>{this.h._addIntToInputStream(t,e,r)})}addUintToStream(t,e,r){Ki(this,e,e=>{this.h._addUintToInputStream(t,e,r)})}addStringToStream(t,e,r){Ki(this,e,e=>{Ki(this,t,t=>{this.h._addStringToInputStream(t,e,r)})})}addStringRecordToStream(t,e,r){Ki(this,e,e=>{qi(this,Object.keys(t),i=>{qi(this,Object.values(t),n=>{this.h._addFlatHashMapToInputStream(i,n,Object.keys(t).length,e,r)})})})}addProtoToStream(t,e,r,i){Ki(this,r,r=>{Ki(this,e,e=>{var n=this.h._malloc(t.length);this.h.HEAPU8.set(t,n),this.h._addProtoToInputStream(n,t.length,e,r,i),this.h._free(n)})})}addEmptyPacketToStream(t,e){Ki(this,t,t=>{this.h._addEmptyPacketToInputStream(t,e)})}addBoolVectorToStream(t,e,r){Ki(this,e,e=>{var i=this.h._allocateBoolVector(t.length);if(!i)throw Error("Unable to allocate new bool vector on heap.");for(let e of t)this.h._addBoolVectorEntry(i,e);this.h._addBoolVectorToInputStream(i,e,r)})}addDoubleVectorToStream(t,e,r){Ki(this,e,e=>{var i=this.h._allocateDoubleVector(t.length);if(!i)throw Error("Unable to allocate new double vector on heap.");for(let e of t)this.h._addDoubleVectorEntry(i,e);this.h._addDoubleVectorToInputStream(i,e,r)})}addFloatVectorToStream(t,e,r){Ki(this,e,e=>{var i=this.h._allocateFloatVector(t.length);if(!i)throw Error("Unable to allocate new float vector on heap.");for(let e of t)this.h._addFloatVectorEntry(i,e);this.h._addFloatVectorToInputStream(i,e,r)})}addIntVectorToStream(t,e,r){Ki(this,e,e=>{var i=this.h._allocateIntVector(t.length);if(!i)throw Error("Unable to allocate new int vector on heap.");for(let e of t)this.h._addIntVectorEntry(i,e);this.h._addIntVectorToInputStream(i,e,r)})}addUintVectorToStream(t,e,r){Ki(this,e,e=>{var i=this.h._allocateUintVector(t.length);if(!i)throw Error("Unable to allocate new unsigned int vector on heap.");for(let e of t)this.h._addUintVectorEntry(i,e);this.h._addUintVectorToInputStream(i,e,r)})}addStringVectorToStream(t,e,r){Ki(this,e,e=>{var i=this.h._allocateStringVector(t.length);if(!i)throw Error("Unable to allocate new string vector on heap.");for(let e of t)Ki(this,e,t=>{this.h._addStringVectorEntry(i,t)});this.h._addStringVectorToInputStream(i,e,r)})}addBoolToInputSidePacket(t,e){Ki(this,e,e=>{this.h._addBoolToInputSidePacket(t,e)})}addDoubleToInputSidePacket(t,e){Ki(this,e,e=>{this.h._addDoubleToInputSidePacket(t,e)})}addFloatToInputSidePacket(t,e){Ki(this,e,e=>{this.h._addFloatToInputSidePacket(t,e)})}addIntToInputSidePacket(t,e){Ki(this,e,e=>{this.h._addIntToInputSidePacket(t,e)})}addUintToInputSidePacket(t,e){Ki(this,e,e=>{this.h._addUintToInputSidePacket(t,e)})}addStringToInputSidePacket(t,e){Ki(this,e,e=>{Ki(this,t,t=>{this.h._addStringToInputSidePacket(t,e)})})}addProtoToInputSidePacket(t,e,r){Ki(this,r,r=>{Ki(this,e,e=>{var i=this.h._malloc(t.length);this.h.HEAPU8.set(t,i),this.h._addProtoToInputSidePacket(i,t.length,e,r),this.h._free(i)})})}addBoolVectorToInputSidePacket(t,e){Ki(this,e,e=>{var r=this.h._allocateBoolVector(t.length);if(!r)throw Error("Unable to allocate new bool vector on heap.");for(let e of t)this.h._addBoolVectorEntry(r,e);this.h._addBoolVectorToInputSidePacket(r,e)})}addDoubleVectorToInputSidePacket(t,e){Ki(this,e,e=>{var r=this.h._allocateDoubleVector(t.length);if(!r)throw Error("Unable to allocate new double vector on heap.");for(let e of t)this.h._addDoubleVectorEntry(r,e);this.h._addDoubleVectorToInputSidePacket(r,e)})}addFloatVectorToInputSidePacket(t,e){Ki(this,e,e=>{var r=this.h._allocateFloatVector(t.length);if(!r)throw Error("Unable to allocate new float vector on heap.");for(let e of t)this.h._addFloatVectorEntry(r,e);this.h._addFloatVectorToInputSidePacket(r,e)})}addIntVectorToInputSidePacket(t,e){Ki(this,e,e=>{var r=this.h._allocateIntVector(t.length);if(!r)throw Error("Unable to allocate new int vector on heap.");for(let e of t)this.h._addIntVectorEntry(r,e);this.h._addIntVectorToInputSidePacket(r,e)})}addUintVectorToInputSidePacket(t,e){Ki(this,e,e=>{var r=this.h._allocateUintVector(t.length);if(!r)throw Error("Unable to allocate new unsigned int vector on heap.");for(let e of t)this.h._addUintVectorEntry(r,e);this.h._addUintVectorToInputSidePacket(r,e)})}addStringVectorToInputSidePacket(t,e){Ki(this,e,e=>{var r=this.h._allocateStringVector(t.length);if(!r)throw Error("Unable to allocate new string vector on heap.");for(let e of t)Ki(this,e,t=>{this.h._addStringVectorEntry(r,t)});this.h._addStringVectorToInputSidePacket(r,e)})}attachBoolListener(t,e){Ji(this,t,e),Ki(this,t,t=>{this.h._attachBoolListener(t)})}attachBoolVectorListener(t,e){Xi(this,t,e),Ki(this,t,t=>{this.h._attachBoolVectorListener(t)})}attachIntListener(t,e){Ji(this,t,e),Ki(this,t,t=>{this.h._attachIntListener(t)})}attachIntVectorListener(t,e){Xi(this,t,e),Ki(this,t,t=>{this.h._attachIntVectorListener(t)})}attachUintListener(t,e){Ji(this,t,e),Ki(this,t,t=>{this.h._attachUintListener(t)})}attachUintVectorListener(t,e){Xi(this,t,e),Ki(this,t,t=>{this.h._attachUintVectorListener(t)})}attachDoubleListener(t,e){Ji(this,t,e),Ki(this,t,t=>{this.h._attachDoubleListener(t)})}attachDoubleVectorListener(t,e){Xi(this,t,e),Ki(this,t,t=>{this.h._attachDoubleVectorListener(t)})}attachFloatListener(t,e){Ji(this,t,e),Ki(this,t,t=>{this.h._attachFloatListener(t)})}attachFloatVectorListener(t,e){Xi(this,t,e),Ki(this,t,t=>{this.h._attachFloatVectorListener(t)})}attachStringListener(t,e){Ji(this,t,e),Ki(this,t,t=>{this.h._attachStringListener(t)})}attachStringVectorListener(t,e){Xi(this,t,e),Ki(this,t,t=>{this.h._attachStringVectorListener(t)})}attachProtoListener(t,e,r){Ji(this,t,e),Ki(this,t,t=>{this.h._attachProtoListener(t,r||!1)})}attachProtoVectorListener(t,e,r){Xi(this,t,e),Ki(this,t,t=>{this.h._attachProtoVectorListener(t,r||!1)})}attachAudioListener(t,e,r){this.h._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),Ji(this,t,(t,r)=>{t=new Float32Array(t.buffer,t.byteOffset,t.length/4),e(t,r)}),Ki(this,t,t=>{this.h._attachAudioListener(t,r||!1)})}finishProcessing(){this.h._waitUntilIdle()}closeGraph(){this.h._closeGraph(),this.h.simpleListeners=void 0,this.h.emptyPacketListeners=void 0}})),Zi=class extends Yi{};async function Qi(t,e){var r=await(async(t,e,r)=>{var i=gn;if(t&&await Hi(t),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(e&&(await Hi(e),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&r&&((t=self.Module).locateFile=r.locateFile,r.mainScriptUrlOrBlob&&(t.mainScriptUrlOrBlob=r.mainScriptUrlOrBlob)),r=await self.ModuleFactory(self.Module||r),self.ModuleFactory=self.Module=void 0,new i(r,null)})(t.wasmLoaderPath,t.assetLoaderPath,{locateFile:e=>e.endsWith(".wasm")?t.wasmBinaryPath.toString():t.assetBinaryPath&&e.endsWith(".data")?t.assetBinaryPath.toString():e});return tn(r,e),await r.S(e),r}function tn(t,e){e=e.qa??"";var r=t.i.da();t.l=new Wi(e,r)}function en(t,e){try{t.i.h.FS_unlink("/model.litertlm")}catch{}t.i.h.FS_createDataFile("/","model.litertlm",e,!0,!1,!1),de(e=oe(t.baseOptions,ci,1)||new ci,2,"/model.litertlm"),Yt(e,1),se(t.baseOptions,1,e)}function rn(t,e,r=!0){if(r){let r=e.baseOptions||{};if(e.baseOptions?.modelAssetBuffer&&e.baseOptions?.modelAssetPath)throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!(oe(t.baseOptions,ci,1)?.j()||oe(t.baseOptions,ci,1)?.l()||e.baseOptions?.modelAssetBuffer||e.baseOptions?.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if(function(t,e){var r=oe(t.baseOptions,li,3);if(!r){var i=r=new li,n=new si;le(i,4,ui,n)}"delegate"in e&&("GPU"===e.delegate?(e=r,i=new ai,le(e,2,ui,i)):(e=r,i=new si,le(e,4,ui,i))),se(t.baseOptions,3,r)}(t,r),r.modelAssetPath)return fetch(r.modelAssetPath.toString()).then(t=>{if(t.ok)return t.arrayBuffer();throw Error(`Failed to fetch model: ${r.modelAssetPath} (${t.status})`)}).then(e=>{en(t,new Uint8Array(e))});if(r.modelAssetBuffer instanceof Uint8Array)en(t,r.modelAssetBuffer);else if(r.modelAssetBuffer)return async function(t){for(var e=[],r=0;;){let{done:i,value:n}=await t.read();if(i)break;e.push(n),r+=n.length}if(0===e.length)return new Uint8Array(0);if(1===e.length)return e[0];t=new Uint8Array(r),r=0;for(let i of e)t.set(i,r),r+=i.length;return t}(r.modelAssetBuffer).then(e=>{en(t,e)})}return Promise.resolve()}function nn(t){try{let e=t.o.length;if(1===e)throw Error(t.o[0].message);if(e>1)throw Error("Encountered multiple errors: "+t.o.map(t=>t.message).join(", "))}finally{t.o=[]}}var on=class{constructor(t){this.i=t,this.o=[],this.i.setAutoRenderToScreen(!1)}setGraph(t,e){this.i.attachErrorListener((t,e)=>{this.o.push(Error(e))}),this.i.ja(),this.i.setGraph(t,e),this.l?.X(),nn(this)}finishProcessing(t){this.i.finishProcessing(),nn(this),this.l&&void 0!==t&&this.l.R(t)}close(){this.l?.ga(),this.l?.close(),this.i.closeGraph()}};function an(t){return(t=t.trim())?Math.max(1,Math.ceil(t.length/4)):0}function sn(t){var e={};if(t.criteria)for(let[r,i]of Object.entries(t.criteria))e[r]=i;if(t.options)for(let r of t.options)e[r.label]=r.description??"";return e}function ln(t){if(t.options&&t.options.length>0){var e=t.options.map(t=>t.description?`${t.label}: ${t.description}`:t.label),r=(t=t.options.map(t=>t.label)).map(t=>Number(t)),i=r.every(t=>Number.isFinite(t))&&t.every(t=>""!==t.trim());return r=i?r:t.map((t,e)=>e),{rubric:e,labels:t,P:r,O:i}}return t=(e=t.rubric??[]).map((t,e)=>String(e)),i=e.map((t,e)=>e),{rubric:e,labels:t,P:i,O:!1}}function un(t,e,r,i){var n=t.probabilities??[],o=0,a=-1,s=0;for(let t=0;t<n.length;t++){let e=n[t];e>a&&(a=e,o=t),s+=(t<r.length?r[t]:t)*e}return{...t,expectedScore:i&&n.length>0?s:t.expectedScore,selectedKey:o<e.length?e[o]:t.selectedKey??String(o)}}on.prototype.close=on.prototype.close;var cn=[];async function hn(t,e){var r=cn.pop();if(r){tn(t=new gn(r,null),e);try{return await t.S(e),t}catch(e){throw t.close(),e}}return async function(t,e){return Qi(t,e)}(t,e)}function fn(t,e){var r=t.Z++;return t.l&&(1===t.backendType||-1===t.backendType?function(t,e){++t.i.F,t.j.set(e,performance.now())}(t.l,r):function(t,e){++t.i.H,t.j.set(e,performance.now())}(t.l,r)),e().then(e=>(t.l?.R(r),e),e=>{throw t.l?.R(r),e})}function dn(t){if(!t)return 0;var e=t.context?an(t.context):0;for(let r of t.questions??[]){e+=an(r.prompt)+4;for(let t of r.options??[])e+=an(t.description?`${t.label}: ${t.description}`:t.label)+2}return e}function pn(t,e){if(!(t=t.i.h._malloc(e>=64?e+64:e)>>>0))throw Error(`Failed to allocate ${e} bytes on Wasm heap.`);return{u:e>=64?(t+63&-64)>>>0:t,v:t}}async function vn(t,e,r,i){var n=t.i.h;if(r instanceof Uint8Array){if(0===(i=r.byteLength))return{u:0,v:0,size:0};let{u:e,v:o}=pn(t,i);return n.HEAPU8.set(r,e),{u:e,v:o,size:i}}if(i=i&&i>0?i:0,!r&&e){if(e=e.toString(),!(r=await fetch(e)).ok||!r.body)throw Error(`Failed to fetch asset: ${e} (${r.status})`);(e=Number(r.headers.get("content-length")||0))>0&&(i=e),r=r.body.getReader()}if(!r)return{u:0,v:0,size:0};if(i>0){let{u:o,v:a}=pn(t,i);for(t=0;;){let{value:s,done:l}=await r.read();if(l)break;if(s&&s.byteLength>0){if(t+(e=Number(s.byteLength))>i)throw n._free(a),Error(`Stream exceeded expected content-length (${i} bytes).`);n.HEAPU8.set(s,o+t>>>0),t+=e}}return{u:o,v:a,size:t}}for(i=[],e=0;;){let{value:t,done:n}=await r.read();if(n)break;if(t&&t.byteLength>0){var o=Number(t.byteLength);i.push(t),e+=o}}if(0===e)return{u:0,v:0,size:0};var{u:a,v:s}=pn(t,e);for(t=0,r=0;r<i.length;r++)(o=i[r])&&(n.HEAPU8.set(o,a+t>>>0),t+=o.byteLength,i[r]=void 0);return{u:a,v:s,size:e}}var gn=class extends on{constructor(t,e){super(new Zi(t,e)),this.baseOptions=new hi,this.L=this.C=this.K=this.A=this.j=this.maxNumTokens=this.backendType=0,this.W=!1,this.Z=this.J=0}get contextWindow(){return this.maxNumTokens}get contextUsage(){return this.J}T(t){this.N=t,this.J=dn(t)}async ia(t){if(0!==this.j){var e=t.questions??[];if(0!==e.length){var r=this.i.h;"function"==typeof r.prewarmSchema?await r.prewarmSchema(this.j,t.context??"",e):"function"==typeof r.evaluateSchema&&await r.evaluateSchema(this.j,"__PREWARM__",t.context??"",e)}}}async ha(t,e){return t=e?.context?`${e.context}\n${t}`:t,dn(this.N)+an(t)}async S(t){if(0!==this.j)throw Error("Decision does not support updating options after initialization.");if("CPU"===t.baseOptions?.delegate?this.backendType=-1:void 0!==t.backendType&&(this.backendType=t.backendType),void 0!==t.maxNumTokens&&(this.maxNumTokens=t.maxNumTokens),t.schema?this.T(t.schema):(t.questions||t.context||t.expectedInputs)&&this.T({context:t.context,expectedInputs:t.expectedInputs,questions:t.questions}),-1===this.backendType){this.i.h.preinitializedWebGPUDevice=void 0;var e="undefined"!=typeof self?self:globalThis;"object"==typeof e.Module&&e.Module&&(e.Module.preinitializedWebGPUDevice=void 0)}else if("undefined"!=typeof navigator&&navigator.gpu)try{if(!(e=this.i.h).preinitializedWebGPUDevice){var r=await navigator.gpu.requestAdapter({powerPreference:"high-performance"}),i=r?.info,n=!!r?.isFallbackAdapter||/swiftshader|llvmpipe|software|lavapipe/i.test(`${i?.vendor??""} ${i?.architecture??""} ${i?.description??""}`);if(r&&!n){for(var o of(n=[],["shader-f16","subgroups","subgroups-f16"]))r.features.has(o)&&n.push(o);o={};for(let t of["maxBufferSize","maxStorageBufferBindingSize","maxStorageBuffersPerShaderStage","maxComputeWorkgroupStorageSize"]){let e=r.limits[t];"number"==typeof e&&(o[t]=e)}let t=await r.requestDevice({requiredFeatures:n,requiredLimits:o});if(!t.adapterInfo&&i)try{Object.defineProperty(t,"adapterInfo",{value:i,writable:!0,configurable:!0})}catch{try{t.adapterInfo=i}catch{}}e.preinitializedWebGPUDevice=t}}e.preinitializedWebGPUDevice&&("object"==typeof(r=self).Module&&r.Module&&(r.Module.preinitializedWebGPUDevice=e.preinitializedWebGPUDevice))}catch(t){console.warn("WebGPU device initialization failed:",t)}if(r=e=this.i.h,(i=!(!t.baseOptions||!t.baseOptions.modelAssetPath&&!t.baseOptions.modelAssetBuffer))&&"function"==typeof e.createDecisionFromBuffers&&"function"==typeof r._malloc){if(r=await vn(this,t.baseOptions?.modelAssetPath,t.baseOptions?.modelAssetBuffer,t.modelAssetSize),this.A=r.u,this.K=r.v,i=0,t.companionPleAssetPath||t.companionPleAssetBuffer)try{let e=await vn(this,t.companionPleAssetPath,t.companionPleAssetBuffer,t.companionPleAssetSize);this.C=e.u,this.L=e.v,i=e.size}catch(t){console.warn("Optional companion per-layer embedder not loaded:",t)}this.j=await e.createDecisionFromBuffers(this.A,r.size,this.C,i,this.backendType,this.maxNumTokens)}else await rn(this,t,i),this.j=await e.createDecision("/model.litertlm",this.backendType,this.maxNumTokens);this.l?.X()}evaluateBoolean(t,e){if(0===this.j)throw Error("Decision is already closed.");var r=this.i.h,i=e.context?`${e.context}\n${e.condition}`:e.condition;return fn(this,()=>r.evaluateBoolean(this.j,t,i,e.threshold??.5,e.temperature??0))}evaluateChoice(t,e){if(0===this.j)throw Error("Decision is already closed.");var r=this.i.h,i=sn(e),n=e.instructions??"",o=e.context?n?`${e.context}\n${n}`:e.context:n;return fn(this,()=>r.evaluateChoice(this.j,t,i,e.temperature??0,o))}async evaluateScore(t,e){if(0===this.j)throw Error("Decision is already closed.");var r=this.i.h,{rubric:i,labels:n,P:o,O:a}=ln(e),s=e.instructions??"",l=e.context?s?`${e.context}\n${s}`:e.context:s;return un(s=await fn(this,()=>r.evaluateScore(this.j,t,i,e.temperature??0,l)),n,o,a)}async evaluate(t,e,r){if(0===this.j)throw Error("Decision is already closed.");if(r?.signal?.aborted)throw new DOMException("The operation was aborted.","AbortError");var i=r?.context?`${r.context}\n${t}`:t,n=e.context;this.J=dn(e)+an(i);var o=this.i.h;if("function"==typeof o.evaluateSchema&&(e.questions??[]).length>0)return fn(this,()=>o.evaluateSchema(this.j,i,n??"",e.questions??[]));t={};for(let o of e.questions??[])if("binary"===o.type||"boolean"===o.type){var a=(r=await this.evaluateBoolean(i,{condition:o.prompt,context:n,threshold:o.threshold,temperature:o.temperature,normalizePrior:o.normalizePrior,options:o.options})).probabilityTrue;let e=o.options&&o.options.length>=2?o.options[0].label:"false",s=o.options&&o.options.length>=2?o.options[1].label:"true";t[o.id]={id:o.id,label:a>=(o.threshold??.5)?s:e,confidence:r.confidence,probability:a,probabilities:[{label:e,probability:Math.max(0,1-a)},{label:s,probability:a}]}}else if("categorical"===o.type||"choice"===o.type){let e=await this.evaluateChoice(i,{options:o.options,instructions:o.prompt,context:n,temperature:o.temperature,normalizePrior:o.normalizePrior});r=(r=(o.options??[]).map(t=>t.label)).length>0?r.map(t=>({label:t,probability:e.probabilities[t]??0})):Object.entries(e.probabilities).map(([t,e])=>({label:t,probability:e})),t[o.id]={id:o.id,label:e.selectedKey,confidence:e.confidence,probabilities:r,predictionSet:e.predictionSet}}else if("ordinal"===o.type||"score"===o.type){r=await this.evaluateScore(i,{options:o.options,instructions:o.prompt,context:n,temperature:o.temperature});let e=(o.options??[]).map(t=>t.label);a=(r.probabilities??[]).map((t,r)=>({label:r<e.length?e[r]:String(r),probability:t})),t[o.id]={id:o.id,label:r.selectedKey??e[0]??"0",confidence:r.confidence,expectedScore:r.expectedScore,probabilities:a}}return t}async ba(t,e,r){var i=[];for(let n of t)i.push(await this.evaluate(n,e,r));return i}async aa(t,e){if(!this.N)throw Error("No session schema configured. Pass `schema` or `questions` in DecisionMakerOptions or call setSchema() before classify().");return this.evaluate(t,this.N,e)}async evaluateBooleanBatch(t,e,r=""){if(0===this.j)throw Error("Decision is already closed.");if(0===t.length)return[];var i=this.i.h,n=e.context?`${e.context}\n${e.condition}`:e.condition;if("function"==typeof i.evaluateBooleanBatch)return fn(this,()=>i.evaluateBooleanBatch(this.j,t,n,e.threshold??.5,e.temperature??0,r));var o=[];for(let i of t)o.push(await this.evaluateBoolean(r?`${r}\n${i}`:i,e));return o}async evaluateChoiceBatch(t,e,r=""){if(0===this.j)throw Error("Decision is already closed.");if(0===t.length)return[];var i=this.i.h,n=sn(e),o=e.instructions??"",a=e.context?o?`${e.context}\n${o}`:e.context:o;if("function"==typeof i.evaluateChoiceBatch)return fn(this,()=>i.evaluateChoiceBatch(this.j,t,n,e.temperature??0,a,r));o=[];for(let i of t)o.push(await this.evaluateChoice(r?`${r}\n${i}`:i,e));return o}async evaluateScoreBatch(t,e,r=""){if(0===this.j)throw Error("Decision is already closed.");if(0===t.length)return[];var i=this.i.h,{rubric:n,labels:o,P:a,O:s}=ln(e),l=e.instructions??"",u=e.context?l?`${e.context}\n${l}`:e.context:l;if("function"==typeof i.evaluateScoreBatch)return(await fn(this,()=>i.evaluateScoreBatch(this.j,t,n,e.temperature??0,u,r))).map(t=>un(t,o,a,s));l=[];for(let i of t)l.push(await this.evaluateScore(r?`${r}\n${i}`:i,e));return l}close(){if(!this.W){this.W=!0;var t=this.i.h;if(0!==this.j){try{t.deleteDecision(this.j)}catch{}this.j=0}var e=this.K||this.A;if(0!==e){try{t._free(e)}catch{}this.K=this.A=0}if(0!==(e=this.L||this.C)){try{t._free(e)}catch{}this.L=this.C=0}super.close(),t&&!cn.includes(t)&&cn.push(t)}}};return gn.prototype.close=gn.prototype.close,gn.prototype.evaluateScoreBatch=gn.prototype.evaluateScoreBatch,gn.prototype.evaluateChoiceBatch=gn.prototype.evaluateChoiceBatch,gn.prototype.evaluateBooleanBatch=gn.prototype.evaluateBooleanBatch,gn.prototype.classify=gn.prototype.aa,gn.prototype.evaluateBatch=gn.prototype.ba,gn.prototype.evaluate=gn.prototype.evaluate,gn.prototype.evaluateScore=gn.prototype.evaluateScore,gn.prototype.evaluateChoice=gn.prototype.evaluateChoice,gn.prototype.evaluateBoolean=gn.prototype.evaluateBoolean,gn.prototype.setOptions=gn.prototype.S,gn.prototype.measureContextUsage=gn.prototype.ha,gn.prototype.prewarm=gn.prototype.ia,gn.prototype.setSchema=gn.prototype.T,gn.createFromModelBuffer=function(t,e,r=0,i=0){return hn(t,{baseOptions:{modelAssetBuffer:e},backendType:r,maxNumTokens:i})},gn.createFromModelPath=function(t,e,r=0,i=0){return hn(t,{baseOptions:{modelAssetPath:e},backendType:r,maxNumTokens:i})},gn.createFromOptions=hn,t.DecisionMaker=gn,t.FilesetResolver=vi,t.TaskRunner=on,t}({});
2
2
  //# sourceMappingURL=decision_bundle_iife.js.map
@@ -1,2 +1,2 @@
1
- var t="undefined"!=typeof self?self:{};function e(e,r){t:{for(var i=["CLOSURE_FLAGS"],n=t,o=0;o<i.length;o++)if(null==(n=n[i[o]])){i=null;break t}i=n}return null!=(e=i&&i[e])?e:r}var r,i="undefined"!=typeof TextEncoder;function n(t){if(i)t=(r||=new TextEncoder).encode(t);else{let r=0,i=new Uint8Array(3*t.length);for(let n=0;n<t.length;n++){var e=t.charCodeAt(n);if(e<128)i[r++]=e;else{if(e<2048)i[r++]=e>>6|192;else{if(e>=55296&&e<=57343){if(e<=56319&&n<t.length){let o=t.charCodeAt(++n);if(o>=56320&&o<=57343){e=1024*(e-55296)+o-56320+65536,i[r++]=e>>18|240,i[r++]=e>>12&63|128,i[r++]=e>>6&63|128,i[r++]=63&e|128;continue}n--}e=65533}i[r++]=e>>12|224,i[r++]=e>>6&63|128}i[r++]=63&e|128}}t=r===i.length?i:i.subarray(0,r)}return t}var o=e(610401301,!1),a=e(748402147,!0);function s(){var e=t.navigator;return e&&(e=e.userAgent)?e:""}var l,u=t.navigator;l=u&&u.userAgentData||null;var c={},h=null;function f(t){var e=t.length,r=3*e/4;r%3?r=Math.floor(r):-1!="=.".indexOf(t[e-1])&&(r=-1!="=.".indexOf(t[e-2])?r-2:r-1);var i=new Uint8Array(r),n=0;return function(t,e){function r(e){for(;i<t.length;){let e=t.charAt(i++),r=h[e];if(null!=r)return r;if(!/^[\s\xa0]*$/.test(e))throw Error("Unknown base64 encoding at char: "+e)}return e}d();for(var i=0;;){let t=r(-1),i=r(0),n=r(64),o=r(64);if(64===o&&-1===t)break;e(t<<2|i>>4),64!=n&&(e(i<<4&240|n>>2),64!=o&&e(n<<6&192|o))}}(t,function(t){i[n++]=t}),n!==r?i.subarray(0,n):i}function d(){if(!h){h={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){let i=t.concat(e[r].split(""));c[r]=i;for(let t=0;t<i.length;t++){let e=i[t];void 0===h[e]&&(h[e]=t)}}}}var p="undefined"!=typeof Uint8Array,v=!(!(!!o&&(!!l&&l.brands.length>0))&&(-1!=s().indexOf("Trident")||-1!=s().indexOf("MSIE")))&&"function"==typeof btoa,g=/[-_.]/g,m={"-":"+",_:"/",".":"="};function b(t){return m[t]||""}function y(t){if(!v)return f(t);t=g.test(t)?t.replace(g,b):t,t=atob(t);var e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}var w,S={},_=class{constructor(t,e){if(A(e),this.i=t,null!=t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}};function A(t){if(t!==S)throw Error("illegal external caller")}function I(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}var T=void 0;function B(t){return I(t=Error(t),"warning"),t}function E(e,r){if(null!=e){var i=T??={},n=i[e]||0;n>=r||(i[e]=n+1,I(e=Error(),"incident"),function(e){t.setTimeout(()=>{throw e},0)}(e))}}function x(){return"function"==typeof BigInt}var P="function"==typeof Symbol&&"symbol"==typeof Symbol();function U(t,e,r=!1){return"function"==typeof Symbol&&"symbol"==typeof Symbol()?r&&Symbol.for&&t?Symbol.for(t):null!=t?Symbol(t):Symbol():e}var j,k=U("jas",void 0,!0),L=U(void 0,"1oa"),O=U(void 0,"0ubsb"),N=U(void 0,"0actk"),V=U("m_m","pa",!0),F={ea:{value:0,configurable:!0,writable:!0,enumerable:!1}},D=Object.defineProperties,M=P?k:"ea",C=[];function G(t,e){P||M in t||D(t,F),t[M]|=e}function $(t,e){P||M in t||D(t,F),t[M]=e}$(C,7),j=Object.freeze(C);var z={};function W(t,e){return void 0===e?t.i!==R&&!!(2&t.m[M]):!!(2&e)&&t.i!==R}var R={};function H(t,e){if(null!=t)if("string"==typeof t)t=t?new _(t,S):w||=new _(null,S);else if(t.constructor!==_)if(p&&null!=t&&t instanceof Uint8Array)t=t.length?new _(new Uint8Array(t),S):w||=new _(null,S);else{if(!e)throw Error();t=void 0}return t}function K(t){return t.oa=!0,t}var q=K(t=>"number"==typeof t),J=K(t=>"string"==typeof t),X=K(t=>"boolean"==typeof t),Y="function"==typeof t.BigInt&&"bigint"==typeof t.BigInt(0);function Z(t){var e=t;if(J(e)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(e))throw Error(String(e))}else if(q(e)&&!Number.isSafeInteger(e))throw Error(String(e));return Y?BigInt(t):t=X(t)?t?"1":"0":J(t)?t.trim()||"0":String(t)}var Q=K(t=>Y?t>=et&&t<=it:"-"===t[0]?nt(t,tt):nt(t,rt)),tt=Number.MIN_SAFE_INTEGER.toString(),et=Y?BigInt(Number.MIN_SAFE_INTEGER):void 0,rt=Number.MAX_SAFE_INTEGER.toString(),it=Y?BigInt(Number.MAX_SAFE_INTEGER):void 0;function nt(t,e){if(t.length>e.length)return!1;if(t.length<e.length||t===e)return!0;for(let r=0;r<t.length;r++){let i=t[r],n=e[r];if(i>n)return!1;if(i<n)return!0}}var ot,at=0,st=0;function lt(t){var e=t>>>0;at=e,st=(t-e)/4294967296>>>0}function ut(t){if(t<0){lt(-t);let[e,r]=vt(at,st);at=e>>>0,st=r>>>0}else lt(t)}function ct(t,e){var r=4294967296*e+(t>>>0);return Number.isSafeInteger(r)?r:ht(t,e)}function ht(t,e){if(t>>>=0,(e>>>=0)<=2097151)var r=""+(4294967296*e+t);else x()?r=""+(BigInt(e)<<BigInt(32)|BigInt(t)):(t=(16777215&t)+6777216*(r=16777215&(t>>>24|e<<8))+6710656*(e=e>>16&65535),r+=8147497*e,e*=2,t>=1e7&&(r+=t/1e7>>>0,t%=1e7),r>=1e7&&(e+=r/1e7>>>0,r%=1e7),r=e+ft(r)+ft(t));return r}function ft(t){return t=String(t),"0000000".slice(t.length)+t}function dt(){var t=at,e=st;if(2147483648&e)if(x())t=""+(BigInt(0|e)<<BigInt(32)|BigInt(t>>>0));else{let[r,i]=vt(t,e);t="-"+ht(r,i)}else t=ht(t,e);return t}function pt(t){if(t.length<16)ut(Number(t));else if(x())t=BigInt(t),at=Number(t&BigInt(4294967295))>>>0,st=Number(t>>BigInt(32)&BigInt(4294967295));else{let e=+("-"===t[0]);st=at=0;let r=t.length;for(let i=e,n=(r-e)%6+e;n<=r;i=n,n+=6){let e=Number(t.slice(i,n));st*=1e6,(at=1e6*at+e)>=4294967296&&(st+=Math.trunc(at/4294967296),st>>>=0,at>>>=0)}if(e){let[t,e]=vt(at,st);at=t,st=e}}}function vt(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}var gt="function"==typeof BigInt?BigInt.asIntN:void 0,mt="function"==typeof BigInt?BigInt.asUintN:void 0,bt=Number.isSafeInteger,yt=Number.isFinite,wt=Math.trunc;function St(t){return null==t||"number"==typeof t?t:"NaN"===t||"Infinity"===t||"-Infinity"===t?Number(t):void 0}var _t,At,It,Tt=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function Bt(t){switch(typeof t){case"bigint":return!0;case"number":return yt(t);case"string":return Tt.test(t);default:return!1}}function Et(t){if(null==t)return t;if("string"==typeof t&&t)t=+t;else if("number"!=typeof t)return;return yt(t)?0|t:void 0}function xt(t){var e=t.length;return("-"===t[0]?e<20||20===e&&t<="-9223372036854775808":e<19||19===e&&t<="9223372036854775807")?t:(pt(t),dt())}function Pt(t){if("-"===t[0])var e=!1;else e=(e=t.length)<20||20===e&&t<="18446744073709551615";return e?t:(pt(t),ht(at,st))}function Ut(t){if(t=wt(t),!bt(t)){ut(t);var e=at,r=st;(t=2147483648&r)&&(r=~r>>>0,0==(e=1+~e>>>0)&&(r=r+1>>>0)),t="number"==typeof(e=ct(e,r))?t?-e:e:t?"-"+e:e}return t}function jt(t){return(t=wt(t))>=0&&bt(t)||(ut(t),t=ct(at,st)),t}function kt(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(gt(64,t));if(Bt(t)){if("string"===e)return e=wt(Number(t)),bt(e)?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=xt(t)),t;if("number"===e)return Ut(t)}}function Lt(t){if(null==t||"string"==typeof t||t instanceof _)return t}function Ot(t){return null==t||"string"==typeof t?t:void 0}function Nt(t,e,r){if(null!=t&&t[V]===z)return t;if(Array.isArray(t)){var i=0|t[M];return(r=i|32&r|2&r)!==i&&$(t,r),new e(t)}}function Vt(t){return t}function Ft(t,e,r,i){var n=void 0!==i;i=!!i;var o=[],a=t.length,s=4294967295,l=!1,u=!!(64&e),c=u?128&e?0:-1:void 0;if(!(1&e)){var h=a&&t[a-1];null!=h&&"object"==typeof h&&h.constructor===Object?s=--a:h=void 0,!u||128&e||n||(l=!0,s=(_t??Vt)(s-c,c,t,h,void 0)+c)}for(e=void 0,n=0;n<a;n++){let a=t[n];if(null!=a&&null!=(a=r(a,i)))if(u&&n>=s){let t=n-c;(e??={})[t]=a}else o[n]=a}if(h)for(let n in h){if(null==(t=h[n])||null==(t=r(t,i)))continue;let l;a=+n,u&&!Number.isNaN(a)&&(l=a+c)<s?o[l]=t:(e??={})[n]=t}return e&&(l?o.push(e):o[s]=e),o}function Dt(t){switch(typeof t){case"number":return Number.isFinite(t)?t:""+t;case"bigint":return Q(t)?Number(t):""+t;case"boolean":return t?1:0;case"object":if(Array.isArray(t)){var e=0|t[M];return 0===t.length&&1&e?void 0:Ft(t,e,Dt)}if(null!=t&&t[V]===z)return Mt(t);if(t instanceof _){if(null==(e=t.i))t="";else if("string"==typeof e)t=e;else{if(v){for(var r="",i=0,n=e.length-10240;i<n;)r+=String.fromCharCode.apply(null,e.subarray(i,i+=10240));r+=String.fromCharCode.apply(null,i?e.subarray(i):e),e=btoa(r)}else{void 0===r&&(r=0),d(),r=c[r],i=Array(Math.floor(e.length/3)),n=r[64]||"";let t=0,u=0;for(;t<e.length-2;t+=3){var o=e[t],a=e[t+1],s=e[t+2],l=r[o>>2];o=r[(3&o)<<4|a>>4],a=r[(15&a)<<2|s>>6],s=r[63&s],i[u++]=l+o+a+s}switch(l=0,s=n,e.length-t){case 2:s=r[(15&(l=e[t+1]))<<2]||n;case 1:e=e[t],i[u]=r[e>>2]+r[(3&e)<<4|l>>4]+s+n}e=i.join("")}t=t.i=e}return t}return}return t}function Mt(t){return Ft(t=t.m,0|t[M],Dt)}function Ct(t,e,r,i=0){if(null==t){var n=32;r?(t=[r],n|=128):t=[],e&&(n=-16760833&n|(1023&e)<<14)}else{if(!Array.isArray(t))throw Error("narr");if(n=0|t[M],a&&1&n)throw Error("rfarr");if(2048&n&&!(2&n)&&function(){if(a)throw Error("carr");E(N,5)}(),256&n)throw Error("farr");if(64&n)return(n|i)!==n&&$(t,n|i),t;if(r&&(n|=128,r!==t[0]))throw Error("mid");t:{n|=64;var o=(r=t).length;if(o){var s=o-1;let t=r[s];if(null!=t&&"object"==typeof t&&t.constructor===Object){if((s-=e=128&n?0:-1)>=1024)throw Error("pvtlmt");for(var l in t)(o=+l)<s&&(r[o+e]=t[l],delete t[l]);n=-16760833&n|(1023&s)<<14;break t}}if(e){if((l=Math.max(e,o-(128&n?0:-1)))>1024)throw Error("spvt");n=-16760833&n|(1023&l)<<14}}}return $(t,64|n|i),t}function Gt(t,e){if("object"!=typeof t)return t;if(Array.isArray(t)){var r=0|t[M];return 0===t.length&&1&r?t=void 0:2&r||(!e||4096&r||16&r?t=zt(t,r,!1,e&&!(16&r)):(G(t,34),4&r&&Object.freeze(t))),t}return null!=t&&t[V]===z?W(t,r=0|(e=t.m)[M])?t:Kt(t,e,r)?$t(t,e):zt(e,r):t instanceof _?t:void 0}function $t(t,e,r){return t=new t.constructor(e),r&&(t.i=R),t.o=R,t}function zt(t,e,r,i){return i??=!!(34&e),t=Ft(t,e,Gt,i),i=32,r&&(i|=2),$(t,e=16769217&e|i),t}function Wt(t){if(t.i!==R)return!1;var e=t.m;return G(e=zt(e,0|e[M]),2048),t.m=e,t.i=void 0,t.o=void 0,!0}function Rt(t){if(!Wt(t)&&W(t,0|t.m[M]))throw Error()}function Ht(t,e){void 0===e&&(e=0|t[M]),32&e&&!(4096&e)&&$(t,4096|e)}function Kt(t,e,r){return!!(2&r)||!(!(32&r)||4096&r)&&($(e,2|r),t.i=R,!0)}function qt(t,e,r){if(null!==(t=Jt(t.m,e,void 0,r)))return t}function Jt(t,e,r,i){if(-1===e)return null;var n=e+(r?0:-1),o=t.length-1;if(!(o<1+(r?0:-1))){if(n>=o){var a=t[o];if(null!=a&&"object"==typeof a&&a.constructor===Object){r=a[e];var s=!0}else{if(n!==o)return;r=a}}else r=t[n];if(i&&null!=r){if(null==(i=i(r)))return i;if(!Object.is(i,r))return s?a[e]=i:t[n]=i,i}return r}}function Xt(t,e,r){Rt(t);var i=t.m;return Yt(i,0|i[M],e,r),t}function Yt(t,e,r,i,n){var o=r+(n?0:-1),a=t.length-1;if(a>=1+(n?0:-1)&&o>=a){let n=t[a];if(null!=n&&"object"==typeof n&&n.constructor===Object)return n[r]=i,e}return o<=a?(t[o]=i,e):(void 0!==i&&(r>=(a=(e??=0|t[M])>>14&1023||536870912)?null!=i&&(t[a+(n?0:-1)]={[r]:i}):t[o]=i),e)}function Zt(t,e,r){return t=Jt(t,e,r),Array.isArray(t)?t:j}function Qt(t,e){return 2&e&&(t|=2),1|t}function te(t){return!!(2&t)&&!!(4&t)||!!(256&t)}function ee(t){return H(t,!0)}function re(t){if(P)return t[L]??(t[L]=new Map);if(L in t)return t[L];var e=new Map;return Object.defineProperty(t,L,{value:e}),e}function ie(t,e,r,i){var n=t.get(i);if(null!=n)return n;n=0;for(let t=0;t<i.length;t++){let o=i[t];null!=Jt(e,o)&&(0!==n&&(r=Yt(e,r,n)),n=o)}return t.set(i,n),n}function ne(t,e,r){var i=t.m,n=0|i[M];if(e=function(t,e,r,i){var n=!1;if(null!=(i=Jt(t,i,void 0,t=>{var i=Nt(t,r,e);return n=i!==t&&null!=i,i})))return n&&!W(i)&&Ht(t,e),i}(i,n,e,r),null==e)return e;if(!W(t,n=0|i[M])){var o,a=e;let s=a.m,l=0|s[M];(o=W(a,l)?Kt(a,s,l)?$t(a,s,!0):new a.constructor(zt(s,l,!1)):a)!==e&&(Wt(t)&&(n=0|(i=t.m)[M]),Ht(i,n=Yt(i,n,r,e=o)))}return e}function oe(t){return null==t&&(t=void 0),t}function ae(t,e,r){return Xt(t,e,r=oe(r)),r&&!W(r)&&Ht(t.m),t}function se(t,e,r,i){t:{var n=i=oe(i);Rt(t);let s=t.m;var o=0|s[M];if(null==n){var a=re(s);if(ie(a,s,o,r)!==e)break t;a.set(r,0)}else{let t=re(a=s),i=ie(t,a,o,r);i!==e&&(i&&(o=Yt(a,o,i)),t.set(r,e))}Yt(s,o,e,n)}return i&&!W(i)&&Ht(t.m),t}function le(t,e){return-273&(2&e?2|t:-3&t)}function ue(t,e){var r=gi;Rt(t);var i=t.m,n=i,o=0|i[M],a=W(t,o)?1:2;2===a&&Wt(t)&&(o=0|(n=t.m)[M]);var s=Zt(n,8),l=s===j?7:0|s[M],u=Qt(l,o);if(t=!(4&u)){var c=o;let t=!!(2&u);t&&(c|=2);let e=!t,i=!0,n=0,a=0;for(;n<s.length;n++){let o=Nt(s[n],r,c);if(o instanceof r){if(!t){let t=W(o);e&&=!t,i&&=t}s[a++]=o}}a<n&&(s.length=a),u|=4,u=i?-4097&u:4096|u,u=e?8|u:-9&u}u!==l&&($(s,u),2&u&&Object.freeze(s)),u=l=u,1===a||4===a&&(2&l||!(16&l)&&32&o)?te(l)||((l|=!s.length||t&&!(4096&l)||32&o&&!(4096&l||16&l)?2:256)!==u&&$(s,l),Object.freeze(s)):(2===a&&te(l)&&(s=Array.prototype.slice.call(s),u=0,l=le(l,o),o=Yt(n,o,8,s)),te(l)||l!==u&&$(s,l)),2&l||!(4096&l||16&l)||Ht(n,o),a=s,e=null!=e?e:new r,a.push(e),t=r=a===j?7:0|a[M],(e=W(e))?(r&=-9,1===a.length&&(r&=-4097)):r|=4096,r!==t&&$(a,r),e||Ht(i)}function ce(t,e,r){return Xt(t,e,null==r?r:function(t){if(!Bt(t))throw B("int64");switch(typeof t){case"string":var e=wt(Number(t));return bt(e)?t=Z(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=x()?Z(gt(64,BigInt(t))):Z(xt(t))),t;case"bigint":return Z(gt(64,t));default:return bt(t)?t=Z(Ut(t)):(t=wt(t),bt(t)?t=String(t):(ut(t),t=dt()),t=Z(t)),t}}(r))}function he(t,e,r){return Xt(t,e,null==r?r:function(t){if(!Bt(t))throw B("uint64");switch(typeof t){case"string":var e=wt(Number(t));return bt(e)&&e>=0?t=Z(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=x()?Z(mt(64,BigInt(t))):Z(Pt(t))),t;case"bigint":return Z(mt(64,t));default:return bt(t)?t=Z(jt(t)):((t=wt(t))>=0&&bt(t)?t=String(t):(ut(t),t=ht(at,st)),t=Z(t)),t}}(r))}function fe(t,e,r){if(null!=r&&"string"!=typeof r)throw Error();return Xt(t,e,r)}function de(t,e,r){if(null!=r){if(!yt(r))throw B("enum");r|=0}return Xt(t,e,r)}var pe=class{constructor(t,e,r){if(this.buffer=t,r&&!e)throw Error()}};function ve(t){if("string"==typeof t)return new pe(y(t),!0);if(Array.isArray(t))return new pe(new Uint8Array(t),!0);if(t.constructor===Uint8Array)return new pe(t,!1);if(t.constructor===ArrayBuffer)return t=new Uint8Array(t),new pe(t,!1);if(t.constructor===_){A(S);var e=t.i;return e=(null==(e=null==e||p&&null!=e&&e instanceof Uint8Array?e:"string"==typeof e?y(e):null)?e:t.i=e)||new Uint8Array(0),new pe(e,!0,t)}if(t instanceof Uint8Array)return t=t.constructor===Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new pe(t,!1);throw Error()}function ge(t){return new ye(4294967295&t,Math.floor(t/4294967296))}function me(t){return t?/^\d+$/.test(t)?(pt(t),new ye(at,st)):null:be||=new ye(0,0)}var be,ye=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};function we(t){return new Ue(4294967295&t,Math.floor(t/4294967296))}function Se(t){return t?/^-?\d+$/.test(t)?(pt(t),new Ue(at,st)):null:_e||=new Ue(0,0)}var _e,Ae,Ie,Te,Be,Ee,xe,Pe,Ue=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};function je(t,e,r){return"undefined"!=typeof BigInt64Array?(xe||(xe=new BigInt64Array(1),Pe=new Uint32Array(xe.buffer),xe[0]=BigInt(1),Ee=1===Pe[0]),xe[0]=t,new e(Pe[t=Ee?0:1],Pe[1-t])):(Be||(Ae=BigInt(Number.MIN_SAFE_INTEGER),Ie=BigInt(Number.MAX_SAFE_INTEGER),Te=BigInt(4294967295),Be=BigInt(32)),t>=Ae&&t<=Ie?r(Number(t)):(t=BigInt.asUintN(64,t),new e(Number(t&Te),Number(t>>Be))))}function ke(t,e,r){for(;r>0||e>127;)t.i.push(127&e|128),e=(e>>>7|r<<25)>>>0,r>>>=7;t.i.push(e)}function Le(t,e){for(;e>127;)t.i.push(127&e|128),e>>>=7;t.i.push(e)}function Oe(t,e){if(e>=0)Le(t,e);else{for(let r=0;r<9;r++)t.i.push(127&e|128),e>>=7;t.i.push(1)}}function Ne(t,e){pt(e),function(t){var e=st>>31;t(at<<1^e,(st<<1|at>>>31)^e)}((e,r)=>{ke(t,e>>>0,r>>>0)})}function Ve(t,e){t.i.push(e>>>0&255),t.i.push(e>>>8&255),t.i.push(e>>>16&255),t.i.push(e>>>24&255)}var Fe=class{constructor(){this.i=[]}length(){return this.i.length}end(){var t=this.i;return this.i=[],t}};function De(t,e){0!==e.length&&(t.l.push(e),t.j+=e.length)}function Me(t,e,r){Le(t.i,8*e+r)}function Ce(t,e){return Me(t,e,2),e=t.i.end(),De(t,e),e.push(t.j),e}function Ge(t,e){var r=e.pop();for(r=t.j+t.i.length()-r;r>127;)e.push(127&r|128),r>>>=7,t.j++;e.push(r),t.j++}function $e(t,e,r){if(null!=r)switch(Me(t,e,0),typeof r){case"number":t=t.i,ut(r),ke(t,at,st);break;case"bigint":r=je(r,Ue,we),ke(t.i,r.j,r.i);break;default:r=Se(r),ke(t.i,r.j,r.i)}}function ze(t,e,r){Me(t,e,2),Le(t.i,r.length),De(t,t.i.end()),De(t,r)}var We=class{constructor(){this.l=[],this.j=0,this.i=new Fe}};function Re(t){if("string"==typeof t)Se(t)}function He(){var t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var Ke=He(),qe=He(),Je=He(),Xe=He(),Ye=He(),Ze=He(),Qe=He(),tr=He(),er=He(),rr=He(),ir=He(),nr=He(),or=class{constructor(t,e){this.m=Ct(t,e,void 0,2048)}toJSON(){return Mt(this)}};or.prototype[V]=z,or.prototype.toString=function(){return this.m.toString()};var ar=class{constructor(t,e){this.i=t,t=Ke,this.j=!!t&&e===t||!1}};function sr(t,e,r,i,n){null!=(e=vr(e,i))&&(r=Ce(t,r),n(e,t),Ge(t,r))}var lr,ur,cr=new ar(sr,Ke),hr=new ar(sr,Ke),fr=Symbol(),dr=Symbol();function pr(t){var e=gr,r=mr,i=t[fr];if(i)return i;(i={}).ma=t,i.Y=function(t){switch(typeof t){case"boolean":return At||=[0,void 0,!0];case"number":return t>0?void 0:0===t?It||=[0,void 0]:[-t,void 0];case"string":return[0,t];case"object":return t}}(t[0]);var n=t[1],o=1;n&&n.constructor===Object&&(i.ca=n,"function"==typeof(n=t[++o])&&(i.fa=!0,lr??=n,ur??=t[o+1],n=t[o+=2]));for(var a={};n&&Array.isArray(n)&&n.length&&"number"==typeof n[0]&&n[0]>0;){for(var s=0;s<n.length;s++)a[n[s]]=n;n=t[++o]}for(s=1;void 0!==n;){let c;"number"==typeof n&&(s+=n,n=t[++o]);var l=void 0;if(n instanceof ar?c=n:(c=cr,o--),c?.j){n=t[++o],l=t;var u=o;"function"==typeof n&&(n=n(),l[u]=n),l=n}for(u=s+1,"number"==typeof(n=t[++o])&&n<0&&(u-=n,n=t[++o]);s<u;s++){let t=a[s];l?r(i,s,c,l,t):e(i,s,c,t)}}return t[fr]=i}function vr(t,e){return t instanceof or?t.m:Array.isArray(t)?Ct(t,e[0],e[1]):void 0}function gr(t,e,r){t[e]=r.i}function mr(t,e,r,i){var n,o,a=r.i;t[e]=(t,e,r)=>a(t,e,r,o||=pr(i).Y,n||=br(i))}function br(t){var e=t[dr];if(!e){let r=pr(t);e=(t,e)=>yr(t,e,r),t[dr]=e}return e}function yr(t,e,r){!function(t,e,r){var i,n=128&e?0:-1,o=t.length;(i=!!o)&&(i=null!=(i=t[o-1])&&"object"==typeof i&&i.constructor===Object);var a=o+(i?-1:0);for(e=128&e?1:0;e<a;e++)r(e-n,t[e]);if(i){t=t[o-1];for(let e in t)!isNaN(e)&&r(+e,t[e])}}(t,0|t[M],(t,i)=>{if(null!=i){var n=function(t,e){var r=t[e];if(r)return r;if((r=t.ca)&&(r=r[e])){var i=(r=Array.isArray(r)?r[0]instanceof ar?r:[hr,r]:[r,void 0])[0].i;if(r=r[1]){let e=br(r),n=pr(r).Y;r=t.fa?ur(n,e):(t,r,o)=>i(t,r,o,n,e)}else r=i;return t[e]=r}}(r,t);n?n(e,i,t):t<500||E(O,3)}})}function wr(t,e,r){if(Array.isArray(e)){var i=0|e[M];if(4&i)return e;for(var n=0,o=0;n<e.length;n++){let r=t(e[n]);null!=r&&(e[o++]=r)}return o<n&&(e.length=o),t=1|i,r&&(t=-1537&t|4),t!==i&&$(e,t),r&&2&t&&Object.freeze(e),e}}var Sr=(t,e)=>{var r=new We;yr(t.m,r,pr(e)),De(r,r.i.end()),t=new Uint8Array(r.j);var i=(e=r.l).length,n=0;for(let r=0;r<i;r++){let i=e[r];t.set(i,n),n+=i.length}return r.l=[t],t};function _r(t,e){return new ar(t,e)}function Ar(t,e){return new ar(t,e)}function Ir(t,e,r){null!=(e=kt(e))&&(Re(e),$e(t,r,e))}function Tr(t,e,r){null!=(e=Et(e))&&null!=e&&(Me(t,r,0),Oe(t.i,e))}function Br(t,e,r){null!=(e=Ot(e))&&ze(t,r,n(e))}function Er(t,e,r,i,n){null!=(e=vr(e,i))&&(r=Ce(t,r),n(e,t),Ge(t,r))}function xr(t,e,r){null!=(e=Lt(e))&&ze(t,r,ve(e).buffer)}function Pr(t,e,r){null!=(e=Et(e))&&(e=parseInt(e,10),Me(t,r,0),Oe(t.i,e))}var Ur,jr=_r(function(t,e,r){null!=(e=St(e))&&(Me(t,r,1),t=t.i,(r=ot||=new DataView(new ArrayBuffer(8))).setFloat64(0,+e,!0),at=r.getUint32(0,!0),st=r.getUint32(4,!0),Ve(t,at),Ve(t,st))},rr),kr=_r(function(t,e,r){null!=(e=St(e))&&(Me(t,r,5),t=t.i,(r=ot||=new DataView(new ArrayBuffer(8))).setFloat32(0,+e,!0),st=0,Ve(t,at=r.getUint32(0,!0)))},er),Lr=_r(Ir,Ze),Or=_r(Ir,Ze),Nr=Ar(function(t,e,r){if(null!=(e=wr(kt,e,!1)))for(let i=0;i<e.length;i++)$e(t,r,e[i])},Ze),Vr=_r(function(t,e,r){if(e=function(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(mt(64,t));if(Bt(t)){if("string"===e)return e=wt(Number(t)),bt(e)&&e>=0?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=Pt(t)),t;if("number"===e)return jt(t)}}(e),null!=e){if("string"==typeof e)me(e);if(null!=e)switch(Me(t,r,0),typeof e){case"number":t=t.i,ut(e),ke(t,at,st);break;case"bigint":r=je(e,ye,ge),ke(t.i,r.j,r.i);break;default:r=me(e),ke(t.i,r.j,r.i)}}},Qe),Fr=_r(Tr,Xe),Dr=Ar(function(t,e,r){if(null!=(e=wr(Et,e,!0)))for(let a=0;a<e.length;a++){var i=t,n=r,o=e[a];null!=o&&(Me(i,n,0),Oe(i.i,o))}},Xe),Mr=Ar(function(t,e,r){if(null!=(e=wr(Et,e,!0))&&e.length){r=Ce(t,r);for(let r=0;r<e.length;r++)Oe(t.i,e[r]);Ge(t,r)}},Xe),Cr=_r(function(t,e,r){null!=(e=null==e||"boolean"==typeof e?e:"number"==typeof e?!!e:void 0)&&(Me(t,r,0),t.i.i.push(e?1:0))},qe),Gr=_r(Br,Je),$r=Ar(function(t,e,r){if(null!=(e=wr(Ot,e,!0)))for(let s=0;s<e.length;s++){var i=t,o=r,a=e[s];null!=a&&ze(i,o,n(a))}},Je),zr=function(t,e,r=Ke){return new ar(e,r)}(0,function(t,e,r,i,n){if(Array.isArray(e)){for(let o=0;o<e.length;o++)Er(t,e[o],r,i,n);1&(t=0|e[M])||$(e,1|t)}}),Wr=new ar(Er,Ke),Rr=_r(xr,ir),Hr=Ar(function(t,e,r){if(null!=(e=wr(Lt,e,!1)))for(let a=0;a<e.length;a++){var i=t,n=r,o=e[a];null!=o&&ze(i,n,ve(o).buffer)}},ir),Kr=_r(function(t,e,r){e=function(t){if(null==t)return t;if("string"==typeof t&&t)t=+t;else if("number"!=typeof t)return;return yt(t)?t>>>0:void 0}(e),null!=e&&null!=e&&(Me(t,r,0),Le(t.i,e))},Ye),qr=_r(Pr,nr),Jr=_r(Pr,nr),Xr=_r(function(t,e,r){if(null!=(e=kt(e))&&(Re(e),null!=e))switch(Me(t,r,0),typeof e){case"number":t=t.i,e=(r=e)<0,lt(r=2*Math.abs(r)),r=at;let i=st;e&&(0==r?0==i?i=r=4294967295:(i--,r=4294967295):r--),ke(t,at=r,st=i);break;case"bigint":t=t.i,e=e<<BigInt(1)^e>>BigInt(63),at=Number(BigInt.asUintN(32,e)),st=Number(BigInt.asUintN(32,e>>BigInt(32))),ke(t,at,st);break;default:Ne(t.i,e)}},tr),Yr=[0,Rr,Hr,Cr,Gr],Zr=[0,_r(Br,Je),[0,Jr,[0,_r(Ir,Ze),_r(Tr,Xe)],Jr,-1,[0,qr],Jr,-1],_r(xr,ir)],Qr=[0,1,[0,12,Fr,10,Cr],[0,7,[0,Fr,-1]]],ti=globalThis.trustedTypes;var ei=class{constructor(t){this.i=t}toString(){return this.i+""}};function ri(t){var e;return void 0===Ur&&(Ur=function(){var t=null;if(!ti)return t;try{let e=t=>t;t=ti.createPolicy("goog#html",{createHTML:e,createScript:e,createScriptURL:e})}catch(t){}return t}()),t=(e=Ur)?e.createScriptURL(t):t,new ei(t)}function ii(t,...e){if(0===e.length)return ri(t[0]);var r=t[0];for(let i=0;i<e.length;i++)r+=encodeURIComponent(e[i])+t[i+1];return ri(r)}var ni,oi=class extends or{constructor(t){super(t)}},ai=class extends or{constructor(t){super(t)}},si=class extends or{constructor(t){super(t)}},li=[1,2,3,4,5,6],ui=class extends or{constructor(t){super(t)}j(){return null!=qt(this,1,ee)}l(){return null!=Ot(qt(this,2))}},ci=class extends or{constructor(t){super(t)}},hi=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 fi(t){if(t)return!0;if(void 0===ni)try{await WebAssembly.instantiate(hi),ni=!0}catch{ni=!1}return ni}async function di(t,e,r){return{wasmLoaderPath:`${e}/${t}_${r=`wasm${r?"_module":""}${await fi(r)?"":"_nosimd"}_internal`}.js`,wasmBinaryPath:`${e}/${t}_${r}.wasm`}}var pi=class{};function vi(t){return de(new gi,1,t)}pi.forVisionTasks=function(t,e=!1){return di("vision",t??ii``,e)},pi.forLiteRtLmTextTasks=function(t,e=!1){return di("litertlm_text",t??ii``,e)},pi.forTextTasks=function(t,e=!1){return di("text",t??ii``,e)},pi.forRetrievalTasks=function(t,e=!1){return di("retrieval",t??ii``,e)},pi.forGenAiTasks=function(t,e=!1){return di("genai",t??ii``,e)},pi.forDecisionTasks=function(t,e=!1){return di("decision",t??ii``,e)},pi.forAudioTasks=function(t,e=!1){return di("audio",t??ii``,e)},pi.isSimdSupported=function(t=!1){return fi(t)};var gi=class extends or{constructor(t){super(t)}},mi=class extends or{constructor(t){super(t)}},bi=[0,qr,2,Vr,-2,Or,zr,[0,qr,Or]],yi=class extends or{constructor(t){super(t)}},wi=class extends or{constructor(t){super(t)}};function Si(t){var e=new Ai;return e=de(e,1,30),de(e,2,t)}var _i,Ai=class extends or{constructor(t){super(t)}},Ii=[3,4,5,6,7],Ti=class extends or{constructor(t){super(t)}},Bi=class extends or{constructor(t){super(t)}};Bi.prototype.j=(_i=[0,[0,qr,Gr,-3,qr],[0,Ii,qr,-1,Wr,[0,qr,Gr,Vr],Wr,bi,Wr,[0,1,bi],Wr,[0,qr],Wr,[0,qr,Gr,Vr]]],function(){return Sr(this,_i)});var Ei=class{constructor(){this.i="undefined"!=typeof AbortController}async send(t,e,r){var i=this.i?new AbortController:void 0,n=i&&t.U>0?setTimeout(()=>{i.abort()},t.U):void 0;try{let n=await fetch(t.url,{method:t.la,headers:{...t.ka},...t.body&&{body:t.body},...t.withCredentials&&{credentials:"include"},signal:t.U&&i?i.signal:null});200===n.status?e?.(await n.text()):r?.(n.status)}catch(t){if("AbortError"===t?.name)r?.(408);else r?.(400)}finally{clearTimeout(n)}}},xi=class extends or{constructor(t){super(t,37)}},Pi=[-4,{},Qr,qr,Zr],Ui=[0,Gr,qr],ji=[0,Gr,qr],ki=[0,Gr,qr,1,Gr,-1,qr,1,qr,1,Or],Li=[0,qr,Gr,-2],Oi=[0,Cr,-3],Ni=[0,qr,Gr,-1,Or,Fr,-1,Gr,-5,zr,[0,Gr,-4],-1,Cr,[0,Cr,-3],qr];var Vi=class extends or{constructor(t){super(t,19)}},Fi=function(t){return e=>Sr(e,t)}([-19,{},[0,qr,1,[0,Gr,-6,Or,Fr,Gr,-1,Or],1,[0,Gr,1,Gr,-5],Gr,-1,[0,qr,Gr,-8],[0,Gr,-3],[0,Gr,qr,Gr,-2],[0,Gr,-1,qr,Gr,-1,qr,Gr,-1,[0,zr,[0,Gr,-1],Cr,Gr,-5],[0,qr,Cr,Fr,-2]],Or,[0,Gr,-3,Or,Fr,Gr,-1],[0,qr,Gr,-1],[0,Gr,-9],[0,Gr,-6,qr,Gr,1,Gr,Cr,qr,-1,Cr,Gr,-2,qr,Gr,qr,Gr,Fr,-1],1,[0,qr],1,[0,Gr,-4],1,ki,[0,[1,2,3,4,5,6],Wr,ki,Wr,Ui,Wr,ji,Wr,[0,qr],Wr,Ni,Wr,Li],Ui,ji,Ni,[0,[0,qr,Gr,-1,Or,Fr,-1,Gr,-4,zr,[0,Gr,-4],-1,1,Oi],[0,qr,Gr,-1,Or,Fr,-1,Gr,-4,Oi]],Li,[0,Gr,[0,Fr,-3,qr],qr,-2,[0,Fr,-1],Cr],4,[0,Gr,qr,Gr,-1,Or,qr,Gr,-1,qr,Fr,-1]],qr,zr,[-37,{},Lr,Gr,zr,[0,Gr,-1],Rr,1,Rr,[0,$r,-1,Dr,Nr,-1],Gr,[0,Fr,Gr,-1],Cr,Fr,Or,Gr,-1,Xr,Yr,Lr,Rr,qr,Dr,Or,-1,[0,qr,-1],Gr,Cr,Gr,Mr,Gr,-1,jr,1,jr,Pi,Cr,[0,qr,[0,kr,Fr,-2],[0,kr]],[0,qr,Or]],Lr,Hr,Gr,-1,Lr,qr,-1,[0,Cr,-1,qr,Cr],[0,Or,-1,Gr],[0,Lr,Cr,Or],Or,1,Kr,1,Pi]),Di=class{constructor(t){this.j=[],this.o=new Ei,this.l=t??"",this.i=setInterval(()=>{this.flush()},6e4)}close(){void 0!==this.i&&(clearInterval(this.i),this.i=void 0),this.flush()}flush(t,e){if(this.error)e?.("net-send-failed");else if(0===this.j.length)t?.();else{var r=this.j;this.j=[],r=function(t){var e=new Vi;{Rt(e=de(e,2,1786));let u=e.m,c=0|u[M];if(null==t)Yt(u,c,3);else{var r=t===j?7:0|t[M],i=r,n=te(r),o=n||Object.isFrozen(t),a=!0,s=!0;for(let e=0;e<t.length;e++){var l=t[e];n||(l=W(l),a&&=!l,s&&=l)}n||(r=a?13:5,r=s?-4097&r:4096|r),o&&r===i||(t=Array.prototype.slice.call(t),i=0,r=le(r,c)),r!==i&&$(t,r),c=Yt(u,c,3,t),2&r||!(4096&r||16&r)||Ht(u,c)}}return e}(r),r=Fi(r),this.o.send({url:"https://odml.pa.googleapis.com/v1/log",la:"POST",U:1e4,body:r,na:2,ka:{"Content-Type":"application/x-protobuf","x-goog-api-key":this.l},withCredentials:!1},()=>{t?.()},t=>{this.error=Error(`Logging failed with HTTP error: ${t}`),this.j=[],void 0!==this.i&&(clearInterval(this.i),this.i=void 0),e?.("net-send-failed",t)})}}};class Mi{constructor(){this.M=this.D=this.I=this.B=this.G=this.H=this.F=0}}function Ci(t,e){var r=new Bi;r=ae(r,1,t.L),r=ae(r,2,e),e=Xt(e=new xi,6,H(r=r.j(),!1)),(t=t.C).error||t.j.push(e)}function Gi(t,e){var r={F:e.F-t.l.F,H:e.H-t.l.H,G:e.G-t.l.G,B:e.B-t.l.B,I:e.I-t.l.I,D:e.D,M:e.M},i=Si(1);r=$i(t,r),Ci(t,i=se(i,4,Ii,r)),t.l=e}function $i(t,e){var r=new mi;return t=he(t=ce(t=de(r,1,t.J),7,e.B),5,e.D),t=he(t,6,e.M),e.G>0&&he(t,4,e.I/e.G),0!==e.F&&ue(t,r=ce(r=vi(3),2,e.F)),0!==e.H&&ue(t,e=ce(r=vi(4),2,e.H)),t}var zi=class{constructor(t,e){this.K=performance.now(),this.o=performance.now(),this.j=new Map,this.A=0,this.i=new Mi,this.l=new Mi,this.C=new Di(e),this.J=function(t){switch(t){case"IMAGE":return 11;case"VIDEO":return 12;case"LIVE_STREAM":return 13;case"AUDIO_CLIPS":return 14;case"AUDIO_STREAM":return 15;default:return 10}}(t),t=new Ti,"undefined"==typeof window?e=0:(e=navigator.userAgent,e=/Android/i.test(e)?1:/iPhone|iPad|iPod/i.test(e)?2:/Windows/i.test(e)?5:/Macintosh/i.test(e)?4:/Linux/i.test(e)?3:0),t=fe(t=de(t,1,e),2,""),t=fe(t,3,""),t=fe(t,4,"1.1.0"),t=fe(t,5,""),this.L=de(t,6,4)}X(){var t=new wi;t=he(t=de(t,1,this.J),3,performance.now()-this.K),Ci(this,t=se(Si(0),3,Ii,t)),this.o=performance.now()}R(t){var e=this.j.get(t);if(void 0!==e&&(this.j.delete(t),t=performance.now()-e,++this.i.G,this.i.I+=t,this.i.D=Math.max(this.i.D,t),this.A=Math.max(this.A,t),performance.now()>this.o+3e4)){for(let[r,i]of this.j.entries())t=r,i<e&&(this.i.B++,this.j.delete(t));e={...this.i,M:performance.now()-this.o},this.i.D=0,this.o=performance.now(),Gi(this,e)}}ga(){var t={...this.i,B:this.i.B+this.j.size,D:this.A,M:performance.now()-this.K};Gi(this,t);var e=new yi;e=ae(e,2,t=$i(this,t)),Ci(this,e=se(t=Si(2),5,Ii,e))}close(){var t=this.C;"function"==typeof t.close?t.close():t.flush()}};function Wi(){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 Ri(t){if("function"!=typeof importScripts){let e=document.createElement("script");return e.src=t.toString(),e.crossOrigin="anonymous",new Promise((t,r)=>{e.addEventListener("load",()=>{t()},!1),e.addEventListener("error",t=>{r(t)},!1),document.body.appendChild(e)})}try{importScripts(t.toString())}catch(e){if(!(e instanceof TypeError))throw e;{let e=self.import;e?await e(t.toString()):await import(t.toString())}}}function Hi(t,e,r){t.o||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),r(e=t.h.stringToNewUTF8(e)),t.h._free(e)}function Ki(t,e,r){t.o||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");var i=new Uint32Array(e.length);for(let r=0;r<e.length;r++)i[r]=t.h.stringToNewUTF8(e[r]);e=t.h._malloc(4*i.length),t.h.HEAPU32.set(i,e>>2),r(e);for(let e of i)t.h._free(e);t.h._free(e)}function qi(t,e,r){t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=r}function Ji(t,e,r){var i=[];t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=(t,e,n)=>{e?(r(i,n),i=[]):i.push(t)}}var Xi=function(t){return class extends t{get V(){return this.h}da(){if("function"==typeof this.V._mediapipeLoggerGetEncodedApiKey){let t=this.V._mediapipeLoggerGetEncodedApiKey();return this.V._decodeBase64(t)}}}}(function(t){return class extends t{ja(){this.h._registerModelResourcesGraphService()}}}(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:Wi()?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){var 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){var r=t.length,i=this.h._malloc(r);this.h.HEAPU8.set(t,i),e?this.h._changeBinaryGraph(r,i):this.h._changeTextGraph(r,i),this.h._free(i)}configureAudio(t,e,r,i,n){this.h._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),Hi(this,i||"input_audio",i=>{Hi(this,n=n||"audio_header",n=>{this.h._configureAudio(i,n,t,e??0,r)})})}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,r){this.addAudioToStreamWithShape(t,0,0,e,r)}addAudioToStreamWithShape(t,e,r,i,n){var 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),Hi(this,i,t=>{this.h._addAudioToInputStream(this.i,e,r,t,n)})}addGpuBufferToStream(t,e,r){Hi(this,e,e=>{if(!this.h.canvas)throw Error("No OpenGL canvas configured.");e?this.h._bindTextureToStream(e):this.h._bindTextureToCanvas();var i=this.h.canvas.getContext("webgl2")||this.h.canvas.getContext("webgl");if(!i)throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");this.h.gpuOriginForWebTexturesIsBottomLeft&&i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!0),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,t),this.h.gpuOriginForWebTexturesIsBottomLeft&&i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1);var[n,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||n===this.h.canvas.width&&o===this.h.canvas.height||(this.h.canvas.width=n,this.h.canvas.height=o);var[a,s]=[n,o];this.h._addBoundTextureToStream(e,a,s,r)})}addBoolToStream(t,e,r){Hi(this,e,e=>{this.h._addBoolToInputStream(t,e,r)})}addDoubleToStream(t,e,r){Hi(this,e,e=>{this.h._addDoubleToInputStream(t,e,r)})}addFloatToStream(t,e,r){Hi(this,e,e=>{this.h._addFloatToInputStream(t,e,r)})}addIntToStream(t,e,r){Hi(this,e,e=>{this.h._addIntToInputStream(t,e,r)})}addUintToStream(t,e,r){Hi(this,e,e=>{this.h._addUintToInputStream(t,e,r)})}addStringToStream(t,e,r){Hi(this,e,e=>{Hi(this,t,t=>{this.h._addStringToInputStream(t,e,r)})})}addStringRecordToStream(t,e,r){Hi(this,e,e=>{Ki(this,Object.keys(t),i=>{Ki(this,Object.values(t),n=>{this.h._addFlatHashMapToInputStream(i,n,Object.keys(t).length,e,r)})})})}addProtoToStream(t,e,r,i){Hi(this,r,r=>{Hi(this,e,e=>{var n=this.h._malloc(t.length);this.h.HEAPU8.set(t,n),this.h._addProtoToInputStream(n,t.length,e,r,i),this.h._free(n)})})}addEmptyPacketToStream(t,e){Hi(this,t,t=>{this.h._addEmptyPacketToInputStream(t,e)})}addBoolVectorToStream(t,e,r){Hi(this,e,e=>{var i=this.h._allocateBoolVector(t.length);if(!i)throw Error("Unable to allocate new bool vector on heap.");for(let e of t)this.h._addBoolVectorEntry(i,e);this.h._addBoolVectorToInputStream(i,e,r)})}addDoubleVectorToStream(t,e,r){Hi(this,e,e=>{var i=this.h._allocateDoubleVector(t.length);if(!i)throw Error("Unable to allocate new double vector on heap.");for(let e of t)this.h._addDoubleVectorEntry(i,e);this.h._addDoubleVectorToInputStream(i,e,r)})}addFloatVectorToStream(t,e,r){Hi(this,e,e=>{var i=this.h._allocateFloatVector(t.length);if(!i)throw Error("Unable to allocate new float vector on heap.");for(let e of t)this.h._addFloatVectorEntry(i,e);this.h._addFloatVectorToInputStream(i,e,r)})}addIntVectorToStream(t,e,r){Hi(this,e,e=>{var i=this.h._allocateIntVector(t.length);if(!i)throw Error("Unable to allocate new int vector on heap.");for(let e of t)this.h._addIntVectorEntry(i,e);this.h._addIntVectorToInputStream(i,e,r)})}addUintVectorToStream(t,e,r){Hi(this,e,e=>{var i=this.h._allocateUintVector(t.length);if(!i)throw Error("Unable to allocate new unsigned int vector on heap.");for(let e of t)this.h._addUintVectorEntry(i,e);this.h._addUintVectorToInputStream(i,e,r)})}addStringVectorToStream(t,e,r){Hi(this,e,e=>{var i=this.h._allocateStringVector(t.length);if(!i)throw Error("Unable to allocate new string vector on heap.");for(let e of t)Hi(this,e,t=>{this.h._addStringVectorEntry(i,t)});this.h._addStringVectorToInputStream(i,e,r)})}addBoolToInputSidePacket(t,e){Hi(this,e,e=>{this.h._addBoolToInputSidePacket(t,e)})}addDoubleToInputSidePacket(t,e){Hi(this,e,e=>{this.h._addDoubleToInputSidePacket(t,e)})}addFloatToInputSidePacket(t,e){Hi(this,e,e=>{this.h._addFloatToInputSidePacket(t,e)})}addIntToInputSidePacket(t,e){Hi(this,e,e=>{this.h._addIntToInputSidePacket(t,e)})}addUintToInputSidePacket(t,e){Hi(this,e,e=>{this.h._addUintToInputSidePacket(t,e)})}addStringToInputSidePacket(t,e){Hi(this,e,e=>{Hi(this,t,t=>{this.h._addStringToInputSidePacket(t,e)})})}addProtoToInputSidePacket(t,e,r){Hi(this,r,r=>{Hi(this,e,e=>{var i=this.h._malloc(t.length);this.h.HEAPU8.set(t,i),this.h._addProtoToInputSidePacket(i,t.length,e,r),this.h._free(i)})})}addBoolVectorToInputSidePacket(t,e){Hi(this,e,e=>{var r=this.h._allocateBoolVector(t.length);if(!r)throw Error("Unable to allocate new bool vector on heap.");for(let e of t)this.h._addBoolVectorEntry(r,e);this.h._addBoolVectorToInputSidePacket(r,e)})}addDoubleVectorToInputSidePacket(t,e){Hi(this,e,e=>{var r=this.h._allocateDoubleVector(t.length);if(!r)throw Error("Unable to allocate new double vector on heap.");for(let e of t)this.h._addDoubleVectorEntry(r,e);this.h._addDoubleVectorToInputSidePacket(r,e)})}addFloatVectorToInputSidePacket(t,e){Hi(this,e,e=>{var r=this.h._allocateFloatVector(t.length);if(!r)throw Error("Unable to allocate new float vector on heap.");for(let e of t)this.h._addFloatVectorEntry(r,e);this.h._addFloatVectorToInputSidePacket(r,e)})}addIntVectorToInputSidePacket(t,e){Hi(this,e,e=>{var r=this.h._allocateIntVector(t.length);if(!r)throw Error("Unable to allocate new int vector on heap.");for(let e of t)this.h._addIntVectorEntry(r,e);this.h._addIntVectorToInputSidePacket(r,e)})}addUintVectorToInputSidePacket(t,e){Hi(this,e,e=>{var r=this.h._allocateUintVector(t.length);if(!r)throw Error("Unable to allocate new unsigned int vector on heap.");for(let e of t)this.h._addUintVectorEntry(r,e);this.h._addUintVectorToInputSidePacket(r,e)})}addStringVectorToInputSidePacket(t,e){Hi(this,e,e=>{var r=this.h._allocateStringVector(t.length);if(!r)throw Error("Unable to allocate new string vector on heap.");for(let e of t)Hi(this,e,t=>{this.h._addStringVectorEntry(r,t)});this.h._addStringVectorToInputSidePacket(r,e)})}attachBoolListener(t,e){qi(this,t,e),Hi(this,t,t=>{this.h._attachBoolListener(t)})}attachBoolVectorListener(t,e){Ji(this,t,e),Hi(this,t,t=>{this.h._attachBoolVectorListener(t)})}attachIntListener(t,e){qi(this,t,e),Hi(this,t,t=>{this.h._attachIntListener(t)})}attachIntVectorListener(t,e){Ji(this,t,e),Hi(this,t,t=>{this.h._attachIntVectorListener(t)})}attachUintListener(t,e){qi(this,t,e),Hi(this,t,t=>{this.h._attachUintListener(t)})}attachUintVectorListener(t,e){Ji(this,t,e),Hi(this,t,t=>{this.h._attachUintVectorListener(t)})}attachDoubleListener(t,e){qi(this,t,e),Hi(this,t,t=>{this.h._attachDoubleListener(t)})}attachDoubleVectorListener(t,e){Ji(this,t,e),Hi(this,t,t=>{this.h._attachDoubleVectorListener(t)})}attachFloatListener(t,e){qi(this,t,e),Hi(this,t,t=>{this.h._attachFloatListener(t)})}attachFloatVectorListener(t,e){Ji(this,t,e),Hi(this,t,t=>{this.h._attachFloatVectorListener(t)})}attachStringListener(t,e){qi(this,t,e),Hi(this,t,t=>{this.h._attachStringListener(t)})}attachStringVectorListener(t,e){Ji(this,t,e),Hi(this,t,t=>{this.h._attachStringVectorListener(t)})}attachProtoListener(t,e,r){qi(this,t,e),Hi(this,t,t=>{this.h._attachProtoListener(t,r||!1)})}attachProtoVectorListener(t,e,r){Ji(this,t,e),Hi(this,t,t=>{this.h._attachProtoVectorListener(t,r||!1)})}attachAudioListener(t,e,r){this.h._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),qi(this,t,(t,r)=>{t=new Float32Array(t.buffer,t.byteOffset,t.length/4),e(t,r)}),Hi(this,t,t=>{this.h._attachAudioListener(t,r||!1)})}finishProcessing(){this.h._waitUntilIdle()}closeGraph(){this.h._closeGraph(),this.h.simpleListeners=void 0,this.h.emptyPacketListeners=void 0}})),Yi=class extends Xi{};async function Zi(t,e){var r=await(async(t,e,r)=>{var i=vn;if(t&&await Ri(t),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(e&&(await Ri(e),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&r&&((t=self.Module).locateFile=r.locateFile,r.mainScriptUrlOrBlob&&(t.mainScriptUrlOrBlob=r.mainScriptUrlOrBlob)),r=await self.ModuleFactory(self.Module||r),self.ModuleFactory=self.Module=void 0,new i(r,null)})(t.wasmLoaderPath,t.assetLoaderPath,{locateFile:e=>e.endsWith(".wasm")?t.wasmBinaryPath.toString():t.assetBinaryPath&&e.endsWith(".data")?t.assetBinaryPath.toString():e});return Qi(r,e),await r.S(e),r}function Qi(t,e){e=e.qa??"";var r=t.i.da();t.l=new zi(e,r)}function tn(t,e){try{t.i.h.FS_unlink("/model.litertlm")}catch{}t.i.h.FS_createDataFile("/","model.litertlm",e,!0,!1,!1),fe(e=ne(t.baseOptions,ui,1)||new ui,2,"/model.litertlm"),Xt(e,1),ae(t.baseOptions,1,e)}function en(t,e,r=!0){if(r){let r=e.baseOptions||{};if(e.baseOptions?.modelAssetBuffer&&e.baseOptions?.modelAssetPath)throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!(ne(t.baseOptions,ui,1)?.j()||ne(t.baseOptions,ui,1)?.l()||e.baseOptions?.modelAssetBuffer||e.baseOptions?.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if(function(t,e){var r=ne(t.baseOptions,si,3);if(!r){var i=r=new si,n=new ai;se(i,4,li,n)}"delegate"in e&&("GPU"===e.delegate?(e=r,i=new oi,se(e,2,li,i)):(e=r,i=new ai,se(e,4,li,i))),ae(t.baseOptions,3,r)}(t,r),r.modelAssetPath)return fetch(r.modelAssetPath.toString()).then(t=>{if(t.ok)return t.arrayBuffer();throw Error(`Failed to fetch model: ${r.modelAssetPath} (${t.status})`)}).then(e=>{tn(t,new Uint8Array(e))});if(r.modelAssetBuffer instanceof Uint8Array)tn(t,r.modelAssetBuffer);else if(r.modelAssetBuffer)return async function(t){for(var e=[],r=0;;){let{done:i,value:n}=await t.read();if(i)break;e.push(n),r+=n.length}if(0===e.length)return new Uint8Array(0);if(1===e.length)return e[0];t=new Uint8Array(r),r=0;for(let i of e)t.set(i,r),r+=i.length;return t}(r.modelAssetBuffer).then(e=>{tn(t,e)})}return Promise.resolve()}function rn(t){try{let e=t.o.length;if(1===e)throw Error(t.o[0].message);if(e>1)throw Error("Encountered multiple errors: "+t.o.map(t=>t.message).join(", "))}finally{t.o=[]}}var nn=class{constructor(t){this.i=t,this.o=[],this.i.setAutoRenderToScreen(!1)}setGraph(t,e){this.i.attachErrorListener((t,e)=>{this.o.push(Error(e))}),this.i.ja(),this.i.setGraph(t,e),this.l?.X(),rn(this)}finishProcessing(t){this.i.finishProcessing(),rn(this),this.l&&void 0!==t&&this.l.R(t)}close(){this.l?.ga(),this.l?.close(),this.i.closeGraph()}};function on(t){return(t=t.trim())?Math.max(1,Math.ceil(t.length/4)):0}function an(t){var e={};if(t.criteria)for(let[r,i]of Object.entries(t.criteria))e[r]=i;if(t.options)for(let r of t.options)e[r.label]=r.description??"";return e}function sn(t){if(t.options&&t.options.length>0){var e=t.options.map(t=>t.description?`${t.label}: ${t.description}`:t.label),r=(t=t.options.map(t=>t.label)).map(t=>Number(t)),i=r.every(t=>Number.isFinite(t))&&t.every(t=>""!==t.trim());return r=i?r:t.map((t,e)=>e),{rubric:e,labels:t,P:r,O:i}}return t=(e=t.rubric??[]).map((t,e)=>String(e)),i=e.map((t,e)=>e),{rubric:e,labels:t,P:i,O:!1}}function ln(t,e,r,i){var n=t.probabilities??[],o=0,a=-1,s=0;for(let t=0;t<n.length;t++){let e=n[t];e>a&&(a=e,o=t),s+=(t<r.length?r[t]:t)*e}return{...t,expectedScore:i&&n.length>0?s:t.expectedScore,selectedKey:o<e.length?e[o]:t.selectedKey??String(o)}}nn.prototype.close=nn.prototype.close;var un=[];async function cn(t,e){var r=un.pop();if(r){Qi(t=new vn(r,null),e);try{return await t.S(e),t}catch(e){throw t.close(),e}}return async function(t,e){return Zi(t,e)}(t,e)}function hn(t,e){var r=t.Z++;return t.l&&(1===t.backendType||-1===t.backendType?function(t,e){++t.i.F,t.j.set(e,performance.now())}(t.l,r):function(t,e){++t.i.H,t.j.set(e,performance.now())}(t.l,r)),e().then(e=>(t.l?.R(r),e),e=>{throw t.l?.R(r),e})}function fn(t){if(!t)return 0;var e=t.context?on(t.context):0;for(let r of t.questions??[]){e+=on(r.prompt)+4;for(let t of r.options??[])e+=on(t.description?`${t.label}: ${t.description}`:t.label)+2}return e}function dn(t,e){if(!(t=t.i.h._malloc(e>=64?e+16:e)>>>0))throw Error(`Failed to allocate ${e} bytes on Wasm heap.`);return{u:e>=64?(t+15&-16)>>>0:t,v:t}}async function pn(t,e,r,i){var n=t.i.h;if(r instanceof Uint8Array){if(0===(i=r.byteLength))return{u:0,v:0,size:0};let{u:e,v:o}=dn(t,i);return n.HEAPU8.set(r,e),{u:e,v:o,size:i}}if(i=i&&i>0?i:0,!r&&e){if(e=e.toString(),!(r=await fetch(e)).ok||!r.body)throw Error(`Failed to fetch asset: ${e} (${r.status})`);(e=Number(r.headers.get("content-length")||0))>0&&(i=e),r=r.body.getReader()}if(!r)return{u:0,v:0,size:0};if(i>0){let{u:o,v:a}=dn(t,i);for(t=0;;){let{value:s,done:l}=await r.read();if(l)break;if(s&&s.byteLength>0){if(t+(e=Number(s.byteLength))>i)throw n._free(a),Error(`Stream exceeded expected content-length (${i} bytes).`);n.HEAPU8.set(s,o+t>>>0),t+=e}}return{u:o,v:a,size:t}}for(i=[],e=0;;){let{value:t,done:n}=await r.read();if(n)break;if(t&&t.byteLength>0){var o=Number(t.byteLength);i.push(t),e+=o}}if(0===e)return{u:0,v:0,size:0};var{u:a,v:s}=dn(t,e);for(t=0,r=0;r<i.length;r++)(o=i[r])&&(n.HEAPU8.set(o,a+t>>>0),t+=o.byteLength,i[r]=void 0);return{u:a,v:s,size:e}}var vn=class extends nn{constructor(t,e){super(new Yi(t,e)),this.baseOptions=new ci,this.L=this.C=this.K=this.A=this.j=this.maxNumTokens=this.backendType=0,this.W=!1,this.Z=this.J=0}get contextWindow(){return this.maxNumTokens}get contextUsage(){return this.J}T(t){this.N=t,this.J=fn(t)}async ia(t){if(0!==this.j){var e=t.questions??[];if(0!==e.length){var r=this.i.h;"function"==typeof r.prewarmSchema?await r.prewarmSchema(this.j,t.context??"",e):"function"==typeof r.evaluateSchema&&await r.evaluateSchema(this.j,"__PREWARM__",t.context??"",e)}}}async ha(t,e){return t=e?.context?`${e.context}\n${t}`:t,fn(this.N)+on(t)}async S(t){if(0!==this.j)throw Error("Decision does not support updating options after initialization.");if("CPU"===t.baseOptions?.delegate?this.backendType=-1:void 0!==t.backendType&&(this.backendType=t.backendType),void 0!==t.maxNumTokens&&(this.maxNumTokens=t.maxNumTokens),t.schema?this.T(t.schema):(t.questions||t.context||t.expectedInputs)&&this.T({context:t.context,expectedInputs:t.expectedInputs,questions:t.questions}),-1===this.backendType){this.i.h.preinitializedWebGPUDevice=void 0;var e="undefined"!=typeof self?self:globalThis;"object"==typeof e.Module&&e.Module&&(e.Module.preinitializedWebGPUDevice=void 0)}else if("undefined"!=typeof navigator&&navigator.gpu)try{if(!(e=this.i.h).preinitializedWebGPUDevice){var r=await navigator.gpu.requestAdapter({powerPreference:"high-performance"}),i=r?.info,n=!!r?.isFallbackAdapter||/swiftshader|llvmpipe|software|lavapipe/i.test(`${i?.vendor??""} ${i?.architecture??""} ${i?.description??""}`);if(r&&!n){for(var o of(n=[],["shader-f16","subgroups","subgroups-f16"]))r.features.has(o)&&n.push(o);o={};for(let t of["maxBufferSize","maxStorageBufferBindingSize","maxStorageBuffersPerShaderStage","maxComputeWorkgroupStorageSize"]){let e=r.limits[t];"number"==typeof e&&(o[t]=e)}let t=await r.requestDevice({requiredFeatures:n,requiredLimits:o});if(!t.adapterInfo&&i)try{Object.defineProperty(t,"adapterInfo",{value:i,writable:!0,configurable:!0})}catch{try{t.adapterInfo=i}catch{}}e.preinitializedWebGPUDevice=t}}e.preinitializedWebGPUDevice&&("object"==typeof(r=self).Module&&r.Module&&(r.Module.preinitializedWebGPUDevice=e.preinitializedWebGPUDevice))}catch(t){console.warn("WebGPU device initialization failed:",t)}if(r=e=this.i.h,(i=!(!t.baseOptions||!t.baseOptions.modelAssetPath&&!t.baseOptions.modelAssetBuffer))&&"function"==typeof e.createDecisionFromBuffers&&"function"==typeof r._malloc){if(r=await pn(this,t.baseOptions?.modelAssetPath,t.baseOptions?.modelAssetBuffer,t.modelAssetSize),this.A=r.u,this.K=r.v,i=0,t.companionPleAssetPath||t.companionPleAssetBuffer)try{let e=await pn(this,t.companionPleAssetPath,t.companionPleAssetBuffer,t.companionPleAssetSize);this.C=e.u,this.L=e.v,i=e.size}catch(t){console.warn("Optional companion per-layer embedder not loaded:",t)}this.j=await e.createDecisionFromBuffers(this.A,r.size,this.C,i,this.backendType,this.maxNumTokens)}else await en(this,t,i),this.j=await e.createDecision("/model.litertlm",this.backendType,this.maxNumTokens);this.l?.X()}evaluateBoolean(t,e){if(0===this.j)throw Error("Decision is already closed.");var r=this.i.h,i=e.context?`${e.context}\n${e.condition}`:e.condition;return hn(this,()=>r.evaluateBoolean(this.j,t,i,e.threshold??.5,e.temperature??0))}evaluateChoice(t,e){if(0===this.j)throw Error("Decision is already closed.");var r=this.i.h,i=an(e),n=e.instructions??"",o=e.context?n?`${e.context}\n${n}`:e.context:n;return hn(this,()=>r.evaluateChoice(this.j,t,i,e.temperature??0,o))}async evaluateScore(t,e){if(0===this.j)throw Error("Decision is already closed.");var r=this.i.h,{rubric:i,labels:n,P:o,O:a}=sn(e),s=e.instructions??"",l=e.context?s?`${e.context}\n${s}`:e.context:s;return ln(s=await hn(this,()=>r.evaluateScore(this.j,t,i,e.temperature??0,l)),n,o,a)}async evaluate(t,e,r){if(0===this.j)throw Error("Decision is already closed.");if(r?.signal?.aborted)throw new DOMException("The operation was aborted.","AbortError");var i=r?.context?`${r.context}\n${t}`:t,n=e.context;this.J=fn(e)+on(i);var o=this.i.h;if("function"==typeof o.evaluateSchema&&(e.questions??[]).length>0)return hn(this,()=>o.evaluateSchema(this.j,i,n??"",e.questions??[]));t={};for(let o of e.questions??[])if("binary"===o.type||"boolean"===o.type){var a=(r=await this.evaluateBoolean(i,{condition:o.prompt,context:n,threshold:o.threshold,temperature:o.temperature,normalizePrior:o.normalizePrior,options:o.options})).probabilityTrue;let e=o.options&&o.options.length>=2?o.options[0].label:"false",s=o.options&&o.options.length>=2?o.options[1].label:"true";t[o.id]={id:o.id,label:a>=(o.threshold??.5)?s:e,confidence:r.confidence,probability:a,probabilities:[{label:e,probability:Math.max(0,1-a)},{label:s,probability:a}]}}else if("categorical"===o.type||"choice"===o.type){let e=await this.evaluateChoice(i,{options:o.options,instructions:o.prompt,context:n,temperature:o.temperature,normalizePrior:o.normalizePrior});r=(r=(o.options??[]).map(t=>t.label)).length>0?r.map(t=>({label:t,probability:e.probabilities[t]??0})):Object.entries(e.probabilities).map(([t,e])=>({label:t,probability:e})),t[o.id]={id:o.id,label:e.selectedKey,confidence:e.confidence,probabilities:r,predictionSet:e.predictionSet}}else if("ordinal"===o.type||"score"===o.type){r=await this.evaluateScore(i,{options:o.options,instructions:o.prompt,context:n,temperature:o.temperature});let e=(o.options??[]).map(t=>t.label);a=(r.probabilities??[]).map((t,r)=>({label:r<e.length?e[r]:String(r),probability:t})),t[o.id]={id:o.id,label:r.selectedKey??e[0]??"0",confidence:r.confidence,expectedScore:r.expectedScore,probabilities:a}}return t}async ba(t,e,r){var i=[];for(let n of t)i.push(await this.evaluate(n,e,r));return i}async aa(t,e){if(!this.N)throw Error("No session schema configured. Pass `schema` or `questions` in DecisionMakerOptions or call setSchema() before classify().");return this.evaluate(t,this.N,e)}async evaluateBooleanBatch(t,e,r=""){if(0===this.j)throw Error("Decision is already closed.");if(0===t.length)return[];var i=this.i.h,n=e.context?`${e.context}\n${e.condition}`:e.condition;if("function"==typeof i.evaluateBooleanBatch)return hn(this,()=>i.evaluateBooleanBatch(this.j,t,n,e.threshold??.5,e.temperature??0,r));var o=[];for(let i of t)o.push(await this.evaluateBoolean(r?`${r}\n${i}`:i,e));return o}async evaluateChoiceBatch(t,e,r=""){if(0===this.j)throw Error("Decision is already closed.");if(0===t.length)return[];var i=this.i.h,n=an(e),o=e.instructions??"",a=e.context?o?`${e.context}\n${o}`:e.context:o;if("function"==typeof i.evaluateChoiceBatch)return hn(this,()=>i.evaluateChoiceBatch(this.j,t,n,e.temperature??0,a,r));o=[];for(let i of t)o.push(await this.evaluateChoice(r?`${r}\n${i}`:i,e));return o}async evaluateScoreBatch(t,e,r=""){if(0===this.j)throw Error("Decision is already closed.");if(0===t.length)return[];var i=this.i.h,{rubric:n,labels:o,P:a,O:s}=sn(e),l=e.instructions??"",u=e.context?l?`${e.context}\n${l}`:e.context:l;if("function"==typeof i.evaluateScoreBatch)return(await hn(this,()=>i.evaluateScoreBatch(this.j,t,n,e.temperature??0,u,r))).map(t=>ln(t,o,a,s));l=[];for(let i of t)l.push(await this.evaluateScore(r?`${r}\n${i}`:i,e));return l}close(){if(!this.W){this.W=!0;var t=this.i.h;if(0!==this.j){try{t.deleteDecision(this.j)}catch{}this.j=0}var e=this.K||this.A;if(0!==e){try{t._free(e)}catch{}this.K=this.A=0}if(0!==(e=this.L||this.C)){try{t._free(e)}catch{}this.L=this.C=0}super.close(),t&&!un.includes(t)&&un.push(t)}}};vn.prototype.close=vn.prototype.close,vn.prototype.evaluateScoreBatch=vn.prototype.evaluateScoreBatch,vn.prototype.evaluateChoiceBatch=vn.prototype.evaluateChoiceBatch,vn.prototype.evaluateBooleanBatch=vn.prototype.evaluateBooleanBatch,vn.prototype.classify=vn.prototype.aa,vn.prototype.evaluateBatch=vn.prototype.ba,vn.prototype.evaluate=vn.prototype.evaluate,vn.prototype.evaluateScore=vn.prototype.evaluateScore,vn.prototype.evaluateChoice=vn.prototype.evaluateChoice,vn.prototype.evaluateBoolean=vn.prototype.evaluateBoolean,vn.prototype.setOptions=vn.prototype.S,vn.prototype.measureContextUsage=vn.prototype.ha,vn.prototype.prewarm=vn.prototype.ia,vn.prototype.setSchema=vn.prototype.T,vn.createFromModelBuffer=function(t,e,r=0,i=0){return cn(t,{baseOptions:{modelAssetBuffer:e},backendType:r,maxNumTokens:i})},vn.createFromModelPath=function(t,e,r=0,i=0){return cn(t,{baseOptions:{modelAssetPath:e},backendType:r,maxNumTokens:i})},vn.createFromOptions=cn;export{vn as DecisionMaker,pi as FilesetResolver,nn as TaskRunner};
1
+ var t="undefined"!=typeof self?self:{};function e(e,r){t:{for(var i=["CLOSURE_FLAGS"],n=t,o=0;o<i.length;o++)if(null==(n=n[i[o]])){i=null;break t}i=n}return null!=(e=i&&i[e])?e:r}var r,i="undefined"!=typeof TextEncoder;function n(t){if(i)t=(r||=new TextEncoder).encode(t);else{let r=0,i=new Uint8Array(3*t.length);for(let n=0;n<t.length;n++){var e=t.charCodeAt(n);if(e<128)i[r++]=e;else{if(e<2048)i[r++]=e>>6|192;else{if(e>=55296&&e<=57343){if(e<=56319&&n<t.length){let o=t.charCodeAt(++n);if(o>=56320&&o<=57343){e=1024*(e-55296)+o-56320+65536,i[r++]=e>>18|240,i[r++]=e>>12&63|128,i[r++]=e>>6&63|128,i[r++]=63&e|128;continue}n--}e=65533}i[r++]=e>>12|224,i[r++]=e>>6&63|128}i[r++]=63&e|128}}t=r===i.length?i:i.subarray(0,r)}return t}var o=e(610401301,!1),a=e(748402147,!0);function s(){var e=t.navigator;return e&&(e=e.userAgent)?e:""}var l,u=t.navigator;l=u&&u.userAgentData||null;var c={},h=null;function f(t){var e=t.length,r=3*e/4;r%3?r=Math.floor(r):-1!="=.".indexOf(t[e-1])&&(r=-1!="=.".indexOf(t[e-2])?r-2:r-1);var i=new Uint8Array(r),n=0;return function(t,e){function r(e){for(;i<t.length;){let e=t.charAt(i++),r=h[e];if(null!=r)return r;if(!/^[\s\xa0]*$/.test(e))throw Error("Unknown base64 encoding at char: "+e)}return e}d();for(var i=0;;){let t=r(-1),i=r(0),n=r(64),o=r(64);if(64===o&&-1===t)break;e(t<<2|i>>4),64!=n&&(e(i<<4&240|n>>2),64!=o&&e(n<<6&192|o))}}(t,function(t){i[n++]=t}),n!==r?i.subarray(0,n):i}function d(){if(!h){h={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){let i=t.concat(e[r].split(""));c[r]=i;for(let t=0;t<i.length;t++){let e=i[t];void 0===h[e]&&(h[e]=t)}}}}var p="undefined"!=typeof Uint8Array,v=!(!(!!o&&(!!l&&l.brands.length>0))&&(-1!=s().indexOf("Trident")||-1!=s().indexOf("MSIE")))&&"function"==typeof btoa,g=/[-_.]/g,m={"-":"+",_:"/",".":"="};function b(t){return m[t]||""}function y(t){if(!v)return f(t);t=g.test(t)?t.replace(g,b):t,t=atob(t);var e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}var w,S={},_=class{constructor(t,e){if(A(e),this.i=t,null!=t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}};function A(t){if(t!==S)throw Error("illegal external caller")}function I(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}var T=void 0;function B(t){return I(t=Error(t),"warning"),t}function E(e,r){if(null!=e){var i=T??={},n=i[e]||0;n>=r||(i[e]=n+1,I(e=Error(),"incident"),function(e){t.setTimeout(()=>{throw e},0)}(e))}}function x(){return"function"==typeof BigInt}var P="function"==typeof Symbol&&"symbol"==typeof Symbol();function U(t,e,r=!1){return"function"==typeof Symbol&&"symbol"==typeof Symbol()?r&&Symbol.for&&t?Symbol.for(t):null!=t?Symbol(t):Symbol():e}var j,k=U("jas",void 0,!0),L=U(void 0,"1oa"),O=U(void 0,"0ubsb"),N=U(void 0,"0actk"),V=U("m_m","pa",!0),F={ea:{value:0,configurable:!0,writable:!0,enumerable:!1}},D=Object.defineProperties,M=P?k:"ea",C=[];function G(t,e){P||M in t||D(t,F),t[M]|=e}function $(t,e){P||M in t||D(t,F),t[M]=e}$(C,7),j=Object.freeze(C);var z={};function W(t,e){return void 0===e?t.i!==R&&!!(2&t.m[M]):!!(2&e)&&t.i!==R}var R={};function H(t,e){if(null!=t)if("string"==typeof t)t=t?new _(t,S):w||=new _(null,S);else if(t.constructor!==_)if(p&&null!=t&&t instanceof Uint8Array)t=t.length?new _(new Uint8Array(t),S):w||=new _(null,S);else{if(!e)throw Error();t=void 0}return t}function K(t){return t.oa=!0,t}var q=K(t=>"number"==typeof t),J=K(t=>"string"==typeof t),X=K(t=>"boolean"==typeof t),Y="function"==typeof t.BigInt&&"bigint"==typeof t.BigInt(0);function Z(t){var e=t;if(J(e)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(e))throw Error(String(e))}else if(q(e)&&!Number.isSafeInteger(e))throw Error(String(e));return Y?BigInt(t):t=X(t)?t?"1":"0":J(t)?t.trim()||"0":String(t)}var Q=K(t=>Y?t>=et&&t<=it:"-"===t[0]?nt(t,tt):nt(t,rt)),tt=Number.MIN_SAFE_INTEGER.toString(),et=Y?BigInt(Number.MIN_SAFE_INTEGER):void 0,rt=Number.MAX_SAFE_INTEGER.toString(),it=Y?BigInt(Number.MAX_SAFE_INTEGER):void 0;function nt(t,e){if(t.length>e.length)return!1;if(t.length<e.length||t===e)return!0;for(let r=0;r<t.length;r++){let i=t[r],n=e[r];if(i>n)return!1;if(i<n)return!0}}var ot,at=0,st=0;function lt(t){var e=t>>>0;at=e,st=(t-e)/4294967296>>>0}function ut(t){if(t<0){lt(-t);let[e,r]=vt(at,st);at=e>>>0,st=r>>>0}else lt(t)}function ct(t,e){var r=4294967296*e+(t>>>0);return Number.isSafeInteger(r)?r:ht(t,e)}function ht(t,e){if(t>>>=0,(e>>>=0)<=2097151)var r=""+(4294967296*e+t);else x()?r=""+(BigInt(e)<<BigInt(32)|BigInt(t)):(t=(16777215&t)+6777216*(r=16777215&(t>>>24|e<<8))+6710656*(e=e>>16&65535),r+=8147497*e,e*=2,t>=1e7&&(r+=t/1e7>>>0,t%=1e7),r>=1e7&&(e+=r/1e7>>>0,r%=1e7),r=e+ft(r)+ft(t));return r}function ft(t){return t=String(t),"0000000".slice(t.length)+t}function dt(){var t=at,e=st;if(2147483648&e)if(x())t=""+(BigInt(0|e)<<BigInt(32)|BigInt(t>>>0));else{let[r,i]=vt(t,e);t="-"+ht(r,i)}else t=ht(t,e);return t}function pt(t){if(t.length<16)ut(Number(t));else if(x())t=BigInt(t),at=Number(t&BigInt(4294967295))>>>0,st=Number(t>>BigInt(32)&BigInt(4294967295));else{let e=+("-"===t[0]);st=at=0;let r=t.length;for(let i=e,n=(r-e)%6+e;n<=r;i=n,n+=6){let e=Number(t.slice(i,n));st*=1e6,(at=1e6*at+e)>=4294967296&&(st+=Math.trunc(at/4294967296),st>>>=0,at>>>=0)}if(e){let[t,e]=vt(at,st);at=t,st=e}}}function vt(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}var gt="function"==typeof BigInt?BigInt.asIntN:void 0,mt="function"==typeof BigInt?BigInt.asUintN:void 0,bt=Number.isSafeInteger,yt=Number.isFinite,wt=Math.trunc;function St(t){return null==t||"number"==typeof t?t:"NaN"===t||"Infinity"===t||"-Infinity"===t?Number(t):void 0}var _t,At,It,Tt=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function Bt(t){switch(typeof t){case"bigint":return!0;case"number":return yt(t);case"string":return Tt.test(t);default:return!1}}function Et(t){if(null==t)return t;if("string"==typeof t&&t)t=+t;else if("number"!=typeof t)return;return yt(t)?0|t:void 0}function xt(t){var e=t.length;return("-"===t[0]?e<20||20===e&&t<="-9223372036854775808":e<19||19===e&&t<="9223372036854775807")?t:(pt(t),dt())}function Pt(t){if("-"===t[0])var e=!1;else e=(e=t.length)<20||20===e&&t<="18446744073709551615";return e?t:(pt(t),ht(at,st))}function Ut(t){if(t=wt(t),!bt(t)){ut(t);var e=at,r=st;(t=2147483648&r)&&(r=~r>>>0,0==(e=1+~e>>>0)&&(r=r+1>>>0)),t="number"==typeof(e=ct(e,r))?t?-e:e:t?"-"+e:e}return t}function jt(t){return(t=wt(t))>=0&&bt(t)||(ut(t),t=ct(at,st)),t}function kt(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(gt(64,t));if(Bt(t)){if("string"===e)return e=wt(Number(t)),bt(e)?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=xt(t)),t;if("number"===e)return Ut(t)}}function Lt(t){if(null==t||"string"==typeof t||t instanceof _)return t}function Ot(t){return null==t||"string"==typeof t?t:void 0}function Nt(t,e,r){if(null!=t&&t[V]===z)return t;if(Array.isArray(t)){var i=0|t[M];return(r=i|32&r|2&r)!==i&&$(t,r),new e(t)}}function Vt(t){return t}function Ft(t,e,r,i){var n=void 0!==i;i=!!i;var o=[],a=t.length,s=4294967295,l=!1,u=!!(64&e),c=u?128&e?0:-1:void 0;if(!(1&e)){var h=a&&t[a-1];null!=h&&"object"==typeof h&&h.constructor===Object?s=--a:h=void 0,!u||128&e||n||(l=!0,s=(_t??Vt)(s-c,c,t,h,void 0)+c)}for(e=void 0,n=0;n<a;n++){let a=t[n];if(null!=a&&null!=(a=r(a,i)))if(u&&n>=s){let t=n-c;(e??={})[t]=a}else o[n]=a}if(h)for(let n in h){if(null==(t=h[n])||null==(t=r(t,i)))continue;let l;a=+n,u&&!Number.isNaN(a)&&(l=a+c)<s?o[l]=t:(e??={})[n]=t}return e&&(l?o.push(e):o[s]=e),o}function Dt(t){switch(typeof t){case"number":return Number.isFinite(t)?t:""+t;case"bigint":return Q(t)?Number(t):""+t;case"boolean":return t?1:0;case"object":if(Array.isArray(t)){var e=0|t[M];return 0===t.length&&1&e?void 0:Ft(t,e,Dt)}if(null!=t&&t[V]===z)return Mt(t);if(t instanceof _){if(null==(e=t.i))t="";else if("string"==typeof e)t=e;else{if(v){for(var r="",i=0,n=e.length-10240;i<n;)r+=String.fromCharCode.apply(null,e.subarray(i,i+=10240));r+=String.fromCharCode.apply(null,i?e.subarray(i):e),e=btoa(r)}else{void 0===r&&(r=0),d(),r=c[r],i=Array(Math.floor(e.length/3)),n=r[64]||"";let t=0,u=0;for(;t<e.length-2;t+=3){var o=e[t],a=e[t+1],s=e[t+2],l=r[o>>2];o=r[(3&o)<<4|a>>4],a=r[(15&a)<<2|s>>6],s=r[63&s],i[u++]=l+o+a+s}switch(l=0,s=n,e.length-t){case 2:s=r[(15&(l=e[t+1]))<<2]||n;case 1:e=e[t],i[u]=r[e>>2]+r[(3&e)<<4|l>>4]+s+n}e=i.join("")}t=t.i=e}return t}return}return t}function Mt(t){return Ft(t=t.m,0|t[M],Dt)}function Ct(t,e,r,i=0){if(null==t){var n=32;r?(t=[r],n|=128):t=[],e&&(n=-16760833&n|(1023&e)<<14)}else{if(!Array.isArray(t))throw Error("narr");if(n=0|t[M],a&&1&n)throw Error("rfarr");if(2048&n&&!(2&n)&&function(){if(a)throw Error("carr");E(N,5)}(),256&n)throw Error("farr");if(64&n)return(n|i)!==n&&$(t,n|i),t;if(r&&(n|=128,r!==t[0]))throw Error("mid");t:{n|=64;var o=(r=t).length;if(o){var s=o-1;let t=r[s];if(null!=t&&"object"==typeof t&&t.constructor===Object){if((s-=e=128&n?0:-1)>=1024)throw Error("pvtlmt");for(var l in t)(o=+l)<s&&(r[o+e]=t[l],delete t[l]);n=-16760833&n|(1023&s)<<14;break t}}if(e){if((l=Math.max(e,o-(128&n?0:-1)))>1024)throw Error("spvt");n=-16760833&n|(1023&l)<<14}}}return $(t,64|n|i),t}function Gt(t,e){if("object"!=typeof t)return t;if(Array.isArray(t)){var r=0|t[M];return 0===t.length&&1&r?t=void 0:2&r||(!e||4096&r||16&r?t=zt(t,r,!1,e&&!(16&r)):(G(t,34),4&r&&Object.freeze(t))),t}return null!=t&&t[V]===z?W(t,r=0|(e=t.m)[M])?t:Kt(t,e,r)?$t(t,e):zt(e,r):t instanceof _?t:void 0}function $t(t,e,r){return t=new t.constructor(e),r&&(t.i=R),t.o=R,t}function zt(t,e,r,i){return i??=!!(34&e),t=Ft(t,e,Gt,i),i=32,r&&(i|=2),$(t,e=16769217&e|i),t}function Wt(t){if(t.i!==R)return!1;var e=t.m;return G(e=zt(e,0|e[M]),2048),t.m=e,t.i=void 0,t.o=void 0,!0}function Rt(t){if(!Wt(t)&&W(t,0|t.m[M]))throw Error()}function Ht(t,e){void 0===e&&(e=0|t[M]),32&e&&!(4096&e)&&$(t,4096|e)}function Kt(t,e,r){return!!(2&r)||!(!(32&r)||4096&r)&&($(e,2|r),t.i=R,!0)}function qt(t,e,r){if(null!==(t=Jt(t.m,e,void 0,r)))return t}function Jt(t,e,r,i){if(-1===e)return null;var n=e+(r?0:-1),o=t.length-1;if(!(o<1+(r?0:-1))){if(n>=o){var a=t[o];if(null!=a&&"object"==typeof a&&a.constructor===Object){r=a[e];var s=!0}else{if(n!==o)return;r=a}}else r=t[n];if(i&&null!=r){if(null==(i=i(r)))return i;if(!Object.is(i,r))return s?a[e]=i:t[n]=i,i}return r}}function Xt(t,e,r){Rt(t);var i=t.m;return Yt(i,0|i[M],e,r),t}function Yt(t,e,r,i,n){var o=r+(n?0:-1),a=t.length-1;if(a>=1+(n?0:-1)&&o>=a){let n=t[a];if(null!=n&&"object"==typeof n&&n.constructor===Object)return n[r]=i,e}return o<=a?(t[o]=i,e):(void 0!==i&&(r>=(a=(e??=0|t[M])>>14&1023||536870912)?null!=i&&(t[a+(n?0:-1)]={[r]:i}):t[o]=i),e)}function Zt(t,e,r){return t=Jt(t,e,r),Array.isArray(t)?t:j}function Qt(t,e){return 2&e&&(t|=2),1|t}function te(t){return!!(2&t)&&!!(4&t)||!!(256&t)}function ee(t){return H(t,!0)}function re(t){if(P)return t[L]??(t[L]=new Map);if(L in t)return t[L];var e=new Map;return Object.defineProperty(t,L,{value:e}),e}function ie(t,e,r,i){var n=t.get(i);if(null!=n)return n;n=0;for(let t=0;t<i.length;t++){let o=i[t];null!=Jt(e,o)&&(0!==n&&(r=Yt(e,r,n)),n=o)}return t.set(i,n),n}function ne(t,e,r){var i=t.m,n=0|i[M];if(e=function(t,e,r,i){var n=!1;if(null!=(i=Jt(t,i,void 0,t=>{var i=Nt(t,r,e);return n=i!==t&&null!=i,i})))return n&&!W(i)&&Ht(t,e),i}(i,n,e,r),null==e)return e;if(!W(t,n=0|i[M])){var o,a=e;let s=a.m,l=0|s[M];(o=W(a,l)?Kt(a,s,l)?$t(a,s,!0):new a.constructor(zt(s,l,!1)):a)!==e&&(Wt(t)&&(n=0|(i=t.m)[M]),Ht(i,n=Yt(i,n,r,e=o)))}return e}function oe(t){return null==t&&(t=void 0),t}function ae(t,e,r){return Xt(t,e,r=oe(r)),r&&!W(r)&&Ht(t.m),t}function se(t,e,r,i){t:{var n=i=oe(i);Rt(t);let s=t.m;var o=0|s[M];if(null==n){var a=re(s);if(ie(a,s,o,r)!==e)break t;a.set(r,0)}else{let t=re(a=s),i=ie(t,a,o,r);i!==e&&(i&&(o=Yt(a,o,i)),t.set(r,e))}Yt(s,o,e,n)}return i&&!W(i)&&Ht(t.m),t}function le(t,e){return-273&(2&e?2|t:-3&t)}function ue(t,e){var r=gi;Rt(t);var i=t.m,n=i,o=0|i[M],a=W(t,o)?1:2;2===a&&Wt(t)&&(o=0|(n=t.m)[M]);var s=Zt(n,8),l=s===j?7:0|s[M],u=Qt(l,o);if(t=!(4&u)){var c=o;let t=!!(2&u);t&&(c|=2);let e=!t,i=!0,n=0,a=0;for(;n<s.length;n++){let o=Nt(s[n],r,c);if(o instanceof r){if(!t){let t=W(o);e&&=!t,i&&=t}s[a++]=o}}a<n&&(s.length=a),u|=4,u=i?-4097&u:4096|u,u=e?8|u:-9&u}u!==l&&($(s,u),2&u&&Object.freeze(s)),u=l=u,1===a||4===a&&(2&l||!(16&l)&&32&o)?te(l)||((l|=!s.length||t&&!(4096&l)||32&o&&!(4096&l||16&l)?2:256)!==u&&$(s,l),Object.freeze(s)):(2===a&&te(l)&&(s=Array.prototype.slice.call(s),u=0,l=le(l,o),o=Yt(n,o,8,s)),te(l)||l!==u&&$(s,l)),2&l||!(4096&l||16&l)||Ht(n,o),a=s,e=null!=e?e:new r,a.push(e),t=r=a===j?7:0|a[M],(e=W(e))?(r&=-9,1===a.length&&(r&=-4097)):r|=4096,r!==t&&$(a,r),e||Ht(i)}function ce(t,e,r){return Xt(t,e,null==r?r:function(t){if(!Bt(t))throw B("int64");switch(typeof t){case"string":var e=wt(Number(t));return bt(e)?t=Z(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=x()?Z(gt(64,BigInt(t))):Z(xt(t))),t;case"bigint":return Z(gt(64,t));default:return bt(t)?t=Z(Ut(t)):(t=wt(t),bt(t)?t=String(t):(ut(t),t=dt()),t=Z(t)),t}}(r))}function he(t,e,r){return Xt(t,e,null==r?r:function(t){if(!Bt(t))throw B("uint64");switch(typeof t){case"string":var e=wt(Number(t));return bt(e)&&e>=0?t=Z(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=x()?Z(mt(64,BigInt(t))):Z(Pt(t))),t;case"bigint":return Z(mt(64,t));default:return bt(t)?t=Z(jt(t)):((t=wt(t))>=0&&bt(t)?t=String(t):(ut(t),t=ht(at,st)),t=Z(t)),t}}(r))}function fe(t,e,r){if(null!=r&&"string"!=typeof r)throw Error();return Xt(t,e,r)}function de(t,e,r){if(null!=r){if(!yt(r))throw B("enum");r|=0}return Xt(t,e,r)}var pe=class{constructor(t,e,r){if(this.buffer=t,r&&!e)throw Error()}};function ve(t){if("string"==typeof t)return new pe(y(t),!0);if(Array.isArray(t))return new pe(new Uint8Array(t),!0);if(t.constructor===Uint8Array)return new pe(t,!1);if(t.constructor===ArrayBuffer)return t=new Uint8Array(t),new pe(t,!1);if(t.constructor===_){A(S);var e=t.i;return e=(null==(e=null==e||p&&null!=e&&e instanceof Uint8Array?e:"string"==typeof e?y(e):null)?e:t.i=e)||new Uint8Array(0),new pe(e,!0,t)}if(t instanceof Uint8Array)return t=t.constructor===Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new pe(t,!1);throw Error()}function ge(t){return new ye(4294967295&t,Math.floor(t/4294967296))}function me(t){return t?/^\d+$/.test(t)?(pt(t),new ye(at,st)):null:be||=new ye(0,0)}var be,ye=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};function we(t){return new Ue(4294967295&t,Math.floor(t/4294967296))}function Se(t){return t?/^-?\d+$/.test(t)?(pt(t),new Ue(at,st)):null:_e||=new Ue(0,0)}var _e,Ae,Ie,Te,Be,Ee,xe,Pe,Ue=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};function je(t,e,r){return"undefined"!=typeof BigInt64Array?(xe||(xe=new BigInt64Array(1),Pe=new Uint32Array(xe.buffer),xe[0]=BigInt(1),Ee=1===Pe[0]),xe[0]=t,new e(Pe[t=Ee?0:1],Pe[1-t])):(Be||(Ae=BigInt(Number.MIN_SAFE_INTEGER),Ie=BigInt(Number.MAX_SAFE_INTEGER),Te=BigInt(4294967295),Be=BigInt(32)),t>=Ae&&t<=Ie?r(Number(t)):(t=BigInt.asUintN(64,t),new e(Number(t&Te),Number(t>>Be))))}function ke(t,e,r){for(;r>0||e>127;)t.i.push(127&e|128),e=(e>>>7|r<<25)>>>0,r>>>=7;t.i.push(e)}function Le(t,e){for(;e>127;)t.i.push(127&e|128),e>>>=7;t.i.push(e)}function Oe(t,e){if(e>=0)Le(t,e);else{for(let r=0;r<9;r++)t.i.push(127&e|128),e>>=7;t.i.push(1)}}function Ne(t,e){pt(e),function(t){var e=st>>31;t(at<<1^e,(st<<1|at>>>31)^e)}((e,r)=>{ke(t,e>>>0,r>>>0)})}function Ve(t,e){t.i.push(e>>>0&255),t.i.push(e>>>8&255),t.i.push(e>>>16&255),t.i.push(e>>>24&255)}var Fe=class{constructor(){this.i=[]}length(){return this.i.length}end(){var t=this.i;return this.i=[],t}};function De(t,e){0!==e.length&&(t.l.push(e),t.j+=e.length)}function Me(t,e,r){Le(t.i,8*e+r)}function Ce(t,e){return Me(t,e,2),e=t.i.end(),De(t,e),e.push(t.j),e}function Ge(t,e){var r=e.pop();for(r=t.j+t.i.length()-r;r>127;)e.push(127&r|128),r>>>=7,t.j++;e.push(r),t.j++}function $e(t,e,r){if(null!=r)switch(Me(t,e,0),typeof r){case"number":t=t.i,ut(r),ke(t,at,st);break;case"bigint":r=je(r,Ue,we),ke(t.i,r.j,r.i);break;default:r=Se(r),ke(t.i,r.j,r.i)}}function ze(t,e,r){Me(t,e,2),Le(t.i,r.length),De(t,t.i.end()),De(t,r)}var We=class{constructor(){this.l=[],this.j=0,this.i=new Fe}};function Re(t){if("string"==typeof t)Se(t)}function He(){var t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var Ke=He(),qe=He(),Je=He(),Xe=He(),Ye=He(),Ze=He(),Qe=He(),tr=He(),er=He(),rr=He(),ir=He(),nr=He(),or=class{constructor(t,e){this.m=Ct(t,e,void 0,2048)}toJSON(){return Mt(this)}};or.prototype[V]=z,or.prototype.toString=function(){return this.m.toString()};var ar=class{constructor(t,e){this.i=t,t=Ke,this.j=!!t&&e===t||!1}};function sr(t,e,r,i,n){null!=(e=vr(e,i))&&(r=Ce(t,r),n(e,t),Ge(t,r))}var lr,ur,cr=new ar(sr,Ke),hr=new ar(sr,Ke),fr=Symbol(),dr=Symbol();function pr(t){var e=gr,r=mr,i=t[fr];if(i)return i;(i={}).ma=t,i.Y=function(t){switch(typeof t){case"boolean":return At||=[0,void 0,!0];case"number":return t>0?void 0:0===t?It||=[0,void 0]:[-t,void 0];case"string":return[0,t];case"object":return t}}(t[0]);var n=t[1],o=1;n&&n.constructor===Object&&(i.ca=n,"function"==typeof(n=t[++o])&&(i.fa=!0,lr??=n,ur??=t[o+1],n=t[o+=2]));for(var a={};n&&Array.isArray(n)&&n.length&&"number"==typeof n[0]&&n[0]>0;){for(var s=0;s<n.length;s++)a[n[s]]=n;n=t[++o]}for(s=1;void 0!==n;){let c;"number"==typeof n&&(s+=n,n=t[++o]);var l=void 0;if(n instanceof ar?c=n:(c=cr,o--),c?.j){n=t[++o],l=t;var u=o;"function"==typeof n&&(n=n(),l[u]=n),l=n}for(u=s+1,"number"==typeof(n=t[++o])&&n<0&&(u-=n,n=t[++o]);s<u;s++){let t=a[s];l?r(i,s,c,l,t):e(i,s,c,t)}}return t[fr]=i}function vr(t,e){return t instanceof or?t.m:Array.isArray(t)?Ct(t,e[0],e[1]):void 0}function gr(t,e,r){t[e]=r.i}function mr(t,e,r,i){var n,o,a=r.i;t[e]=(t,e,r)=>a(t,e,r,o||=pr(i).Y,n||=br(i))}function br(t){var e=t[dr];if(!e){let r=pr(t);e=(t,e)=>yr(t,e,r),t[dr]=e}return e}function yr(t,e,r){!function(t,e,r){var i,n=128&e?0:-1,o=t.length;(i=!!o)&&(i=null!=(i=t[o-1])&&"object"==typeof i&&i.constructor===Object);var a=o+(i?-1:0);for(e=128&e?1:0;e<a;e++)r(e-n,t[e]);if(i){t=t[o-1];for(let e in t)!isNaN(e)&&r(+e,t[e])}}(t,0|t[M],(t,i)=>{if(null!=i){var n=function(t,e){var r=t[e];if(r)return r;if((r=t.ca)&&(r=r[e])){var i=(r=Array.isArray(r)?r[0]instanceof ar?r:[hr,r]:[r,void 0])[0].i;if(r=r[1]){let e=br(r),n=pr(r).Y;r=t.fa?ur(n,e):(t,r,o)=>i(t,r,o,n,e)}else r=i;return t[e]=r}}(r,t);n?n(e,i,t):t<500||E(O,3)}})}function wr(t,e,r){if(Array.isArray(e)){var i=0|e[M];if(4&i)return e;for(var n=0,o=0;n<e.length;n++){let r=t(e[n]);null!=r&&(e[o++]=r)}return o<n&&(e.length=o),t=1|i,r&&(t=-1537&t|4),t!==i&&$(e,t),r&&2&t&&Object.freeze(e),e}}var Sr=(t,e)=>{var r=new We;yr(t.m,r,pr(e)),De(r,r.i.end()),t=new Uint8Array(r.j);var i=(e=r.l).length,n=0;for(let r=0;r<i;r++){let i=e[r];t.set(i,n),n+=i.length}return r.l=[t],t};function _r(t,e){return new ar(t,e)}function Ar(t,e){return new ar(t,e)}function Ir(t,e,r){null!=(e=kt(e))&&(Re(e),$e(t,r,e))}function Tr(t,e,r){null!=(e=Et(e))&&null!=e&&(Me(t,r,0),Oe(t.i,e))}function Br(t,e,r){null!=(e=Ot(e))&&ze(t,r,n(e))}function Er(t,e,r,i,n){null!=(e=vr(e,i))&&(r=Ce(t,r),n(e,t),Ge(t,r))}function xr(t,e,r){null!=(e=Lt(e))&&ze(t,r,ve(e).buffer)}function Pr(t,e,r){null!=(e=Et(e))&&(e=parseInt(e,10),Me(t,r,0),Oe(t.i,e))}var Ur,jr=_r(function(t,e,r){null!=(e=St(e))&&(Me(t,r,1),t=t.i,(r=ot||=new DataView(new ArrayBuffer(8))).setFloat64(0,+e,!0),at=r.getUint32(0,!0),st=r.getUint32(4,!0),Ve(t,at),Ve(t,st))},rr),kr=_r(function(t,e,r){null!=(e=St(e))&&(Me(t,r,5),t=t.i,(r=ot||=new DataView(new ArrayBuffer(8))).setFloat32(0,+e,!0),st=0,Ve(t,at=r.getUint32(0,!0)))},er),Lr=_r(Ir,Ze),Or=_r(Ir,Ze),Nr=Ar(function(t,e,r){if(null!=(e=wr(kt,e,!1)))for(let i=0;i<e.length;i++)$e(t,r,e[i])},Ze),Vr=_r(function(t,e,r){if(e=function(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(mt(64,t));if(Bt(t)){if("string"===e)return e=wt(Number(t)),bt(e)&&e>=0?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=Pt(t)),t;if("number"===e)return jt(t)}}(e),null!=e){if("string"==typeof e)me(e);if(null!=e)switch(Me(t,r,0),typeof e){case"number":t=t.i,ut(e),ke(t,at,st);break;case"bigint":r=je(e,ye,ge),ke(t.i,r.j,r.i);break;default:r=me(e),ke(t.i,r.j,r.i)}}},Qe),Fr=_r(Tr,Xe),Dr=Ar(function(t,e,r){if(null!=(e=wr(Et,e,!0)))for(let a=0;a<e.length;a++){var i=t,n=r,o=e[a];null!=o&&(Me(i,n,0),Oe(i.i,o))}},Xe),Mr=Ar(function(t,e,r){if(null!=(e=wr(Et,e,!0))&&e.length){r=Ce(t,r);for(let r=0;r<e.length;r++)Oe(t.i,e[r]);Ge(t,r)}},Xe),Cr=_r(function(t,e,r){null!=(e=null==e||"boolean"==typeof e?e:"number"==typeof e?!!e:void 0)&&(Me(t,r,0),t.i.i.push(e?1:0))},qe),Gr=_r(Br,Je),$r=Ar(function(t,e,r){if(null!=(e=wr(Ot,e,!0)))for(let s=0;s<e.length;s++){var i=t,o=r,a=e[s];null!=a&&ze(i,o,n(a))}},Je),zr=function(t,e,r=Ke){return new ar(e,r)}(0,function(t,e,r,i,n){if(Array.isArray(e)){for(let o=0;o<e.length;o++)Er(t,e[o],r,i,n);1&(t=0|e[M])||$(e,1|t)}}),Wr=new ar(Er,Ke),Rr=_r(xr,ir),Hr=Ar(function(t,e,r){if(null!=(e=wr(Lt,e,!1)))for(let a=0;a<e.length;a++){var i=t,n=r,o=e[a];null!=o&&ze(i,n,ve(o).buffer)}},ir),Kr=_r(function(t,e,r){e=function(t){if(null==t)return t;if("string"==typeof t&&t)t=+t;else if("number"!=typeof t)return;return yt(t)?t>>>0:void 0}(e),null!=e&&null!=e&&(Me(t,r,0),Le(t.i,e))},Ye),qr=_r(Pr,nr),Jr=_r(Pr,nr),Xr=_r(function(t,e,r){if(null!=(e=kt(e))&&(Re(e),null!=e))switch(Me(t,r,0),typeof e){case"number":t=t.i,e=(r=e)<0,lt(r=2*Math.abs(r)),r=at;let i=st;e&&(0==r?0==i?i=r=4294967295:(i--,r=4294967295):r--),ke(t,at=r,st=i);break;case"bigint":t=t.i,e=e<<BigInt(1)^e>>BigInt(63),at=Number(BigInt.asUintN(32,e)),st=Number(BigInt.asUintN(32,e>>BigInt(32))),ke(t,at,st);break;default:Ne(t.i,e)}},tr),Yr=[0,Rr,Hr,Cr,Gr],Zr=[0,_r(Br,Je),[0,Jr,[0,_r(Ir,Ze),_r(Tr,Xe)],Jr,-1,[0,qr],Jr,-1],_r(xr,ir)],Qr=[0,1,[0,12,Fr,10,Cr],[0,7,[0,Fr,-1]]],ti=globalThis.trustedTypes;var ei=class{constructor(t){this.i=t}toString(){return this.i+""}};function ri(t){var e;return void 0===Ur&&(Ur=function(){var t=null;if(!ti)return t;try{let e=t=>t;t=ti.createPolicy("goog#html",{createHTML:e,createScript:e,createScriptURL:e})}catch(t){}return t}()),t=(e=Ur)?e.createScriptURL(t):t,new ei(t)}function ii(t,...e){if(0===e.length)return ri(t[0]);var r=t[0];for(let i=0;i<e.length;i++)r+=encodeURIComponent(e[i])+t[i+1];return ri(r)}var ni,oi=class extends or{constructor(t){super(t)}},ai=class extends or{constructor(t){super(t)}},si=class extends or{constructor(t){super(t)}},li=[1,2,3,4,5,6],ui=class extends or{constructor(t){super(t)}j(){return null!=qt(this,1,ee)}l(){return null!=Ot(qt(this,2))}},ci=class extends or{constructor(t){super(t)}},hi=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 fi(t){if(t)return!0;if(void 0===ni)try{await WebAssembly.instantiate(hi),ni=!0}catch{ni=!1}return ni}async function di(t,e,r){return{wasmLoaderPath:`${e}/${t}_${r=`wasm${r?"_module":""}${await fi(r)?"":"_nosimd"}_internal`}.js`,wasmBinaryPath:`${e}/${t}_${r}.wasm`}}var pi=class{};function vi(t){return de(new gi,1,t)}pi.forVisionTasks=function(t,e=!1){return di("vision",t??ii``,e)},pi.forLiteRtLmTextTasks=function(t,e=!1){return di("litertlm_text",t??ii``,e)},pi.forTextTasks=function(t,e=!1){return di("text",t??ii``,e)},pi.forRetrievalTasks=function(t,e=!1){return di("retrieval",t??ii``,e)},pi.forGenAiTasks=function(t,e=!1){return di("genai",t??ii``,e)},pi.forDecisionTasks=function(t,e=!1){return di("decision",t??ii``,e)},pi.forAudioTasks=function(t,e=!1){return di("audio",t??ii``,e)},pi.isSimdSupported=function(t=!1){return fi(t)};var gi=class extends or{constructor(t){super(t)}},mi=class extends or{constructor(t){super(t)}},bi=[0,qr,2,Vr,-2,Or,zr,[0,qr,Or]],yi=class extends or{constructor(t){super(t)}},wi=class extends or{constructor(t){super(t)}};function Si(t){var e=new Ai;return e=de(e,1,30),de(e,2,t)}var _i,Ai=class extends or{constructor(t){super(t)}},Ii=[3,4,5,6,7],Ti=class extends or{constructor(t){super(t)}},Bi=class extends or{constructor(t){super(t)}};Bi.prototype.j=(_i=[0,[0,qr,Gr,-3,qr],[0,Ii,qr,-1,Wr,[0,qr,Gr,Vr],Wr,bi,Wr,[0,1,bi],Wr,[0,qr],Wr,[0,qr,Gr,Vr]]],function(){return Sr(this,_i)});var Ei=class{constructor(){this.i="undefined"!=typeof AbortController}async send(t,e,r){var i=this.i?new AbortController:void 0,n=i&&t.U>0?setTimeout(()=>{i.abort()},t.U):void 0;try{let n=await fetch(t.url,{method:t.la,headers:{...t.ka},...t.body&&{body:t.body},...t.withCredentials&&{credentials:"include"},signal:t.U&&i?i.signal:null});200===n.status?e?.(await n.text()):r?.(n.status)}catch(t){if("AbortError"===t?.name)r?.(408);else r?.(400)}finally{clearTimeout(n)}}},xi=class extends or{constructor(t){super(t,37)}},Pi=[-4,{},Qr,qr,Zr],Ui=[0,Gr,qr,1,Gr,-1,qr,1,qr,1,Or],ji=[0,qr,Gr,-2],ki=[0,Gr,qr],Li=[0,Gr,qr],Oi=[0,Cr,-3],Ni=[0,qr,Gr,-1,Or,Fr,-1,Gr,-5,zr,[0,Gr,-4],-1,Cr,[0,Cr,-3],qr];var Vi=class extends or{constructor(t){super(t,19)}},Fi=function(t){return e=>Sr(e,t)}([-19,{},[0,qr,1,[0,Gr,-6,Or,Fr,Gr,-1,Or],1,[0,Gr,1,Gr,-5],Gr,-1,[0,qr,Gr,-8],[0,Gr,-3],[0,Gr,qr,Gr,-2],[0,Gr,-1,qr,Gr,-1,qr,Gr,-1,[0,zr,[0,Gr,-1],Cr,Gr,-5],[0,qr,Cr,Fr,-2]],Or,[0,Gr,-3,Or,Fr,Gr,-1],[0,qr,Gr,-1],[0,Gr,-9],[0,Gr,-6,qr,Gr,1,Gr,Cr,qr,-1,Cr,Gr,-2,qr,Gr,qr,Gr,Fr,-1],1,[0,qr],1,[0,Gr,-4],1,Ui,[0,[1,2,3,4,5,6],Wr,Ui,Wr,ki,Wr,Li,Wr,[0,qr],Wr,Ni,Wr,ji],ki,Li,Ni,[0,[0,qr,Gr,-1,Or,Fr,-1,Gr,-4,zr,[0,Gr,-4],-1,1,Oi],[0,qr,Gr,-1,Or,Fr,-1,Gr,-4,Oi]],ji,[0,Gr,[0,Fr,-3,qr],qr,-2,[0,Fr,-1],Cr],4,[0,Gr,qr,Gr,-1,Or,qr,Gr,-1,qr,Fr,-1]],qr,zr,[-37,{},Lr,Gr,zr,[0,Gr,-1],Rr,1,Rr,[0,$r,-1,Dr,Nr,-1],Gr,[0,Fr,Gr,-1],Cr,Fr,Or,Gr,-1,Xr,Yr,Lr,Rr,qr,Dr,Or,-1,[0,qr,-1],Gr,Cr,Gr,Mr,Gr,-1,jr,1,jr,Pi,Cr,[0,qr,[0,kr,Fr,-2],[0,kr]],[0,qr,Or]],Lr,Hr,Gr,-1,Lr,qr,-1,[0,Cr,-1,qr,Cr],[0,Or,-1,Gr],[0,Lr,Cr,Or],Or,1,Kr,1,Pi]),Di=class{constructor(t){this.j=[],this.o=new Ei,this.l=t??"",this.i=setInterval(()=>{this.flush()},6e4)}close(){void 0!==this.i&&(clearInterval(this.i),this.i=void 0),this.flush()}flush(t,e){if(this.error)e?.("net-send-failed");else if(0===this.j.length)t?.();else{var r=this.j;this.j=[],r=function(t){var e=new Vi;{Rt(e=de(e,2,1786));let u=e.m,c=0|u[M];if(null==t)Yt(u,c,3);else{var r=t===j?7:0|t[M],i=r,n=te(r),o=n||Object.isFrozen(t),a=!0,s=!0;for(let e=0;e<t.length;e++){var l=t[e];n||(l=W(l),a&&=!l,s&&=l)}n||(r=a?13:5,r=s?-4097&r:4096|r),o&&r===i||(t=Array.prototype.slice.call(t),i=0,r=le(r,c)),r!==i&&$(t,r),c=Yt(u,c,3,t),2&r||!(4096&r||16&r)||Ht(u,c)}}return e}(r),r=Fi(r),this.o.send({url:"https://odml.pa.googleapis.com/v1/log",la:"POST",U:1e4,body:r,na:2,ka:{"Content-Type":"application/x-protobuf","x-goog-api-key":this.l},withCredentials:!1},()=>{t?.()},t=>{this.error=Error(`Logging failed with HTTP error: ${t}`),this.j=[],void 0!==this.i&&(clearInterval(this.i),this.i=void 0),e?.("net-send-failed",t)})}}};class Mi{constructor(){this.M=this.D=this.I=this.B=this.G=this.H=this.F=0}}function Ci(t,e){var r=new Bi;r=ae(r,1,t.L),r=ae(r,2,e),e=Xt(e=new xi,6,H(r=r.j(),!1)),(t=t.C).error||t.j.push(e)}function Gi(t,e){var r={F:e.F-t.l.F,H:e.H-t.l.H,G:e.G-t.l.G,B:e.B-t.l.B,I:e.I-t.l.I,D:e.D,M:e.M},i=Si(1);r=$i(t,r),Ci(t,i=se(i,4,Ii,r)),t.l=e}function $i(t,e){var r=new mi;return t=he(t=ce(t=de(r,1,t.J),7,e.B),5,e.D),t=he(t,6,e.M),e.G>0&&he(t,4,e.I/e.G),0!==e.F&&ue(t,r=ce(r=vi(3),2,e.F)),0!==e.H&&ue(t,e=ce(r=vi(4),2,e.H)),t}var zi=class{constructor(t,e){this.K=performance.now(),this.o=performance.now(),this.j=new Map,this.A=0,this.i=new Mi,this.l=new Mi,this.C=new Di(e),this.J=function(t){switch(t){case"IMAGE":return 11;case"VIDEO":return 12;case"LIVE_STREAM":return 13;case"AUDIO_CLIPS":return 14;case"AUDIO_STREAM":return 15;default:return 10}}(t),t=new Ti,"undefined"==typeof window?e=0:(e=navigator.userAgent,e=/Android/i.test(e)?1:/iPhone|iPad|iPod/i.test(e)?2:/Windows/i.test(e)?5:/Macintosh/i.test(e)?4:/Linux/i.test(e)?3:0),t=fe(t=de(t,1,e),2,""),t=fe(t,3,""),t=fe(t,4,"1.1.0"),t=fe(t,5,""),this.L=de(t,6,4)}X(){var t=new wi;t=he(t=de(t,1,this.J),3,performance.now()-this.K),Ci(this,t=se(Si(0),3,Ii,t)),this.o=performance.now()}R(t){var e=this.j.get(t);if(void 0!==e&&(this.j.delete(t),t=performance.now()-e,++this.i.G,this.i.I+=t,this.i.D=Math.max(this.i.D,t),this.A=Math.max(this.A,t),performance.now()>this.o+3e4)){for(let[r,i]of this.j.entries())t=r,i<e&&(this.i.B++,this.j.delete(t));e={...this.i,M:performance.now()-this.o},this.i.D=0,this.o=performance.now(),Gi(this,e)}}ga(){var t={...this.i,B:this.i.B+this.j.size,D:this.A,M:performance.now()-this.K};Gi(this,t);var e=new yi;e=ae(e,2,t=$i(this,t)),Ci(this,e=se(t=Si(2),5,Ii,e))}close(){var t=this.C;"function"==typeof t.close?t.close():t.flush()}};function Wi(){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 Ri(t){if("function"!=typeof importScripts){let e=document.createElement("script");return e.src=t.toString(),e.crossOrigin="anonymous",new Promise((t,r)=>{e.addEventListener("load",()=>{t()},!1),e.addEventListener("error",t=>{r(t)},!1),document.body.appendChild(e)})}try{importScripts(t.toString())}catch(e){if(!(e instanceof TypeError))throw e;{let e=self.import;e?await e(t.toString()):await import(t.toString())}}}function Hi(t,e,r){t.o||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),r(e=t.h.stringToNewUTF8(e)),t.h._free(e)}function Ki(t,e,r){t.o||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");var i=new Uint32Array(e.length);for(let r=0;r<e.length;r++)i[r]=t.h.stringToNewUTF8(e[r]);e=t.h._malloc(4*i.length),t.h.HEAPU32.set(i,e>>2),r(e);for(let e of i)t.h._free(e);t.h._free(e)}function qi(t,e,r){t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=r}function Ji(t,e,r){var i=[];t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=(t,e,n)=>{e?(r(i,n),i=[]):i.push(t)}}var Xi=function(t){return class extends t{get V(){return this.h}da(){if("function"==typeof this.V._mediapipeLoggerGetEncodedApiKey){let t=this.V._mediapipeLoggerGetEncodedApiKey();return this.V._decodeBase64(t)}}}}(function(t){return class extends t{ja(){this.h._registerModelResourcesGraphService()}}}(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:Wi()?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){var 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){var r=t.length,i=this.h._malloc(r);this.h.HEAPU8.set(t,i),e?this.h._changeBinaryGraph(r,i):this.h._changeTextGraph(r,i),this.h._free(i)}configureAudio(t,e,r,i,n){this.h._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),Hi(this,i||"input_audio",i=>{Hi(this,n=n||"audio_header",n=>{this.h._configureAudio(i,n,t,e??0,r)})})}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,r){this.addAudioToStreamWithShape(t,0,0,e,r)}addAudioToStreamWithShape(t,e,r,i,n){var 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),Hi(this,i,t=>{this.h._addAudioToInputStream(this.i,e,r,t,n)})}addGpuBufferToStream(t,e,r){Hi(this,e,e=>{if(!this.h.canvas)throw Error("No OpenGL canvas configured.");e?this.h._bindTextureToStream(e):this.h._bindTextureToCanvas();var i=this.h.canvas.getContext("webgl2")||this.h.canvas.getContext("webgl");if(!i)throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");this.h.gpuOriginForWebTexturesIsBottomLeft&&i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!0),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,t),this.h.gpuOriginForWebTexturesIsBottomLeft&&i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1);var[n,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||n===this.h.canvas.width&&o===this.h.canvas.height||(this.h.canvas.width=n,this.h.canvas.height=o);var[a,s]=[n,o];this.h._addBoundTextureToStream(e,a,s,r)})}addBoolToStream(t,e,r){Hi(this,e,e=>{this.h._addBoolToInputStream(t,e,r)})}addDoubleToStream(t,e,r){Hi(this,e,e=>{this.h._addDoubleToInputStream(t,e,r)})}addFloatToStream(t,e,r){Hi(this,e,e=>{this.h._addFloatToInputStream(t,e,r)})}addIntToStream(t,e,r){Hi(this,e,e=>{this.h._addIntToInputStream(t,e,r)})}addUintToStream(t,e,r){Hi(this,e,e=>{this.h._addUintToInputStream(t,e,r)})}addStringToStream(t,e,r){Hi(this,e,e=>{Hi(this,t,t=>{this.h._addStringToInputStream(t,e,r)})})}addStringRecordToStream(t,e,r){Hi(this,e,e=>{Ki(this,Object.keys(t),i=>{Ki(this,Object.values(t),n=>{this.h._addFlatHashMapToInputStream(i,n,Object.keys(t).length,e,r)})})})}addProtoToStream(t,e,r,i){Hi(this,r,r=>{Hi(this,e,e=>{var n=this.h._malloc(t.length);this.h.HEAPU8.set(t,n),this.h._addProtoToInputStream(n,t.length,e,r,i),this.h._free(n)})})}addEmptyPacketToStream(t,e){Hi(this,t,t=>{this.h._addEmptyPacketToInputStream(t,e)})}addBoolVectorToStream(t,e,r){Hi(this,e,e=>{var i=this.h._allocateBoolVector(t.length);if(!i)throw Error("Unable to allocate new bool vector on heap.");for(let e of t)this.h._addBoolVectorEntry(i,e);this.h._addBoolVectorToInputStream(i,e,r)})}addDoubleVectorToStream(t,e,r){Hi(this,e,e=>{var i=this.h._allocateDoubleVector(t.length);if(!i)throw Error("Unable to allocate new double vector on heap.");for(let e of t)this.h._addDoubleVectorEntry(i,e);this.h._addDoubleVectorToInputStream(i,e,r)})}addFloatVectorToStream(t,e,r){Hi(this,e,e=>{var i=this.h._allocateFloatVector(t.length);if(!i)throw Error("Unable to allocate new float vector on heap.");for(let e of t)this.h._addFloatVectorEntry(i,e);this.h._addFloatVectorToInputStream(i,e,r)})}addIntVectorToStream(t,e,r){Hi(this,e,e=>{var i=this.h._allocateIntVector(t.length);if(!i)throw Error("Unable to allocate new int vector on heap.");for(let e of t)this.h._addIntVectorEntry(i,e);this.h._addIntVectorToInputStream(i,e,r)})}addUintVectorToStream(t,e,r){Hi(this,e,e=>{var i=this.h._allocateUintVector(t.length);if(!i)throw Error("Unable to allocate new unsigned int vector on heap.");for(let e of t)this.h._addUintVectorEntry(i,e);this.h._addUintVectorToInputStream(i,e,r)})}addStringVectorToStream(t,e,r){Hi(this,e,e=>{var i=this.h._allocateStringVector(t.length);if(!i)throw Error("Unable to allocate new string vector on heap.");for(let e of t)Hi(this,e,t=>{this.h._addStringVectorEntry(i,t)});this.h._addStringVectorToInputStream(i,e,r)})}addBoolToInputSidePacket(t,e){Hi(this,e,e=>{this.h._addBoolToInputSidePacket(t,e)})}addDoubleToInputSidePacket(t,e){Hi(this,e,e=>{this.h._addDoubleToInputSidePacket(t,e)})}addFloatToInputSidePacket(t,e){Hi(this,e,e=>{this.h._addFloatToInputSidePacket(t,e)})}addIntToInputSidePacket(t,e){Hi(this,e,e=>{this.h._addIntToInputSidePacket(t,e)})}addUintToInputSidePacket(t,e){Hi(this,e,e=>{this.h._addUintToInputSidePacket(t,e)})}addStringToInputSidePacket(t,e){Hi(this,e,e=>{Hi(this,t,t=>{this.h._addStringToInputSidePacket(t,e)})})}addProtoToInputSidePacket(t,e,r){Hi(this,r,r=>{Hi(this,e,e=>{var i=this.h._malloc(t.length);this.h.HEAPU8.set(t,i),this.h._addProtoToInputSidePacket(i,t.length,e,r),this.h._free(i)})})}addBoolVectorToInputSidePacket(t,e){Hi(this,e,e=>{var r=this.h._allocateBoolVector(t.length);if(!r)throw Error("Unable to allocate new bool vector on heap.");for(let e of t)this.h._addBoolVectorEntry(r,e);this.h._addBoolVectorToInputSidePacket(r,e)})}addDoubleVectorToInputSidePacket(t,e){Hi(this,e,e=>{var r=this.h._allocateDoubleVector(t.length);if(!r)throw Error("Unable to allocate new double vector on heap.");for(let e of t)this.h._addDoubleVectorEntry(r,e);this.h._addDoubleVectorToInputSidePacket(r,e)})}addFloatVectorToInputSidePacket(t,e){Hi(this,e,e=>{var r=this.h._allocateFloatVector(t.length);if(!r)throw Error("Unable to allocate new float vector on heap.");for(let e of t)this.h._addFloatVectorEntry(r,e);this.h._addFloatVectorToInputSidePacket(r,e)})}addIntVectorToInputSidePacket(t,e){Hi(this,e,e=>{var r=this.h._allocateIntVector(t.length);if(!r)throw Error("Unable to allocate new int vector on heap.");for(let e of t)this.h._addIntVectorEntry(r,e);this.h._addIntVectorToInputSidePacket(r,e)})}addUintVectorToInputSidePacket(t,e){Hi(this,e,e=>{var r=this.h._allocateUintVector(t.length);if(!r)throw Error("Unable to allocate new unsigned int vector on heap.");for(let e of t)this.h._addUintVectorEntry(r,e);this.h._addUintVectorToInputSidePacket(r,e)})}addStringVectorToInputSidePacket(t,e){Hi(this,e,e=>{var r=this.h._allocateStringVector(t.length);if(!r)throw Error("Unable to allocate new string vector on heap.");for(let e of t)Hi(this,e,t=>{this.h._addStringVectorEntry(r,t)});this.h._addStringVectorToInputSidePacket(r,e)})}attachBoolListener(t,e){qi(this,t,e),Hi(this,t,t=>{this.h._attachBoolListener(t)})}attachBoolVectorListener(t,e){Ji(this,t,e),Hi(this,t,t=>{this.h._attachBoolVectorListener(t)})}attachIntListener(t,e){qi(this,t,e),Hi(this,t,t=>{this.h._attachIntListener(t)})}attachIntVectorListener(t,e){Ji(this,t,e),Hi(this,t,t=>{this.h._attachIntVectorListener(t)})}attachUintListener(t,e){qi(this,t,e),Hi(this,t,t=>{this.h._attachUintListener(t)})}attachUintVectorListener(t,e){Ji(this,t,e),Hi(this,t,t=>{this.h._attachUintVectorListener(t)})}attachDoubleListener(t,e){qi(this,t,e),Hi(this,t,t=>{this.h._attachDoubleListener(t)})}attachDoubleVectorListener(t,e){Ji(this,t,e),Hi(this,t,t=>{this.h._attachDoubleVectorListener(t)})}attachFloatListener(t,e){qi(this,t,e),Hi(this,t,t=>{this.h._attachFloatListener(t)})}attachFloatVectorListener(t,e){Ji(this,t,e),Hi(this,t,t=>{this.h._attachFloatVectorListener(t)})}attachStringListener(t,e){qi(this,t,e),Hi(this,t,t=>{this.h._attachStringListener(t)})}attachStringVectorListener(t,e){Ji(this,t,e),Hi(this,t,t=>{this.h._attachStringVectorListener(t)})}attachProtoListener(t,e,r){qi(this,t,e),Hi(this,t,t=>{this.h._attachProtoListener(t,r||!1)})}attachProtoVectorListener(t,e,r){Ji(this,t,e),Hi(this,t,t=>{this.h._attachProtoVectorListener(t,r||!1)})}attachAudioListener(t,e,r){this.h._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),qi(this,t,(t,r)=>{t=new Float32Array(t.buffer,t.byteOffset,t.length/4),e(t,r)}),Hi(this,t,t=>{this.h._attachAudioListener(t,r||!1)})}finishProcessing(){this.h._waitUntilIdle()}closeGraph(){this.h._closeGraph(),this.h.simpleListeners=void 0,this.h.emptyPacketListeners=void 0}})),Yi=class extends Xi{};async function Zi(t,e){var r=await(async(t,e,r)=>{var i=vn;if(t&&await Ri(t),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(e&&(await Ri(e),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&r&&((t=self.Module).locateFile=r.locateFile,r.mainScriptUrlOrBlob&&(t.mainScriptUrlOrBlob=r.mainScriptUrlOrBlob)),r=await self.ModuleFactory(self.Module||r),self.ModuleFactory=self.Module=void 0,new i(r,null)})(t.wasmLoaderPath,t.assetLoaderPath,{locateFile:e=>e.endsWith(".wasm")?t.wasmBinaryPath.toString():t.assetBinaryPath&&e.endsWith(".data")?t.assetBinaryPath.toString():e});return Qi(r,e),await r.S(e),r}function Qi(t,e){e=e.qa??"";var r=t.i.da();t.l=new zi(e,r)}function tn(t,e){try{t.i.h.FS_unlink("/model.litertlm")}catch{}t.i.h.FS_createDataFile("/","model.litertlm",e,!0,!1,!1),fe(e=ne(t.baseOptions,ui,1)||new ui,2,"/model.litertlm"),Xt(e,1),ae(t.baseOptions,1,e)}function en(t,e,r=!0){if(r){let r=e.baseOptions||{};if(e.baseOptions?.modelAssetBuffer&&e.baseOptions?.modelAssetPath)throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!(ne(t.baseOptions,ui,1)?.j()||ne(t.baseOptions,ui,1)?.l()||e.baseOptions?.modelAssetBuffer||e.baseOptions?.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if(function(t,e){var r=ne(t.baseOptions,si,3);if(!r){var i=r=new si,n=new ai;se(i,4,li,n)}"delegate"in e&&("GPU"===e.delegate?(e=r,i=new oi,se(e,2,li,i)):(e=r,i=new ai,se(e,4,li,i))),ae(t.baseOptions,3,r)}(t,r),r.modelAssetPath)return fetch(r.modelAssetPath.toString()).then(t=>{if(t.ok)return t.arrayBuffer();throw Error(`Failed to fetch model: ${r.modelAssetPath} (${t.status})`)}).then(e=>{tn(t,new Uint8Array(e))});if(r.modelAssetBuffer instanceof Uint8Array)tn(t,r.modelAssetBuffer);else if(r.modelAssetBuffer)return async function(t){for(var e=[],r=0;;){let{done:i,value:n}=await t.read();if(i)break;e.push(n),r+=n.length}if(0===e.length)return new Uint8Array(0);if(1===e.length)return e[0];t=new Uint8Array(r),r=0;for(let i of e)t.set(i,r),r+=i.length;return t}(r.modelAssetBuffer).then(e=>{tn(t,e)})}return Promise.resolve()}function rn(t){try{let e=t.o.length;if(1===e)throw Error(t.o[0].message);if(e>1)throw Error("Encountered multiple errors: "+t.o.map(t=>t.message).join(", "))}finally{t.o=[]}}var nn=class{constructor(t){this.i=t,this.o=[],this.i.setAutoRenderToScreen(!1)}setGraph(t,e){this.i.attachErrorListener((t,e)=>{this.o.push(Error(e))}),this.i.ja(),this.i.setGraph(t,e),this.l?.X(),rn(this)}finishProcessing(t){this.i.finishProcessing(),rn(this),this.l&&void 0!==t&&this.l.R(t)}close(){this.l?.ga(),this.l?.close(),this.i.closeGraph()}};function on(t){return(t=t.trim())?Math.max(1,Math.ceil(t.length/4)):0}function an(t){var e={};if(t.criteria)for(let[r,i]of Object.entries(t.criteria))e[r]=i;if(t.options)for(let r of t.options)e[r.label]=r.description??"";return e}function sn(t){if(t.options&&t.options.length>0){var e=t.options.map(t=>t.description?`${t.label}: ${t.description}`:t.label),r=(t=t.options.map(t=>t.label)).map(t=>Number(t)),i=r.every(t=>Number.isFinite(t))&&t.every(t=>""!==t.trim());return r=i?r:t.map((t,e)=>e),{rubric:e,labels:t,P:r,O:i}}return t=(e=t.rubric??[]).map((t,e)=>String(e)),i=e.map((t,e)=>e),{rubric:e,labels:t,P:i,O:!1}}function ln(t,e,r,i){var n=t.probabilities??[],o=0,a=-1,s=0;for(let t=0;t<n.length;t++){let e=n[t];e>a&&(a=e,o=t),s+=(t<r.length?r[t]:t)*e}return{...t,expectedScore:i&&n.length>0?s:t.expectedScore,selectedKey:o<e.length?e[o]:t.selectedKey??String(o)}}nn.prototype.close=nn.prototype.close;var un=[];async function cn(t,e){var r=un.pop();if(r){Qi(t=new vn(r,null),e);try{return await t.S(e),t}catch(e){throw t.close(),e}}return async function(t,e){return Zi(t,e)}(t,e)}function hn(t,e){var r=t.Z++;return t.l&&(1===t.backendType||-1===t.backendType?function(t,e){++t.i.F,t.j.set(e,performance.now())}(t.l,r):function(t,e){++t.i.H,t.j.set(e,performance.now())}(t.l,r)),e().then(e=>(t.l?.R(r),e),e=>{throw t.l?.R(r),e})}function fn(t){if(!t)return 0;var e=t.context?on(t.context):0;for(let r of t.questions??[]){e+=on(r.prompt)+4;for(let t of r.options??[])e+=on(t.description?`${t.label}: ${t.description}`:t.label)+2}return e}function dn(t,e){if(!(t=t.i.h._malloc(e>=64?e+64:e)>>>0))throw Error(`Failed to allocate ${e} bytes on Wasm heap.`);return{u:e>=64?(t+63&-64)>>>0:t,v:t}}async function pn(t,e,r,i){var n=t.i.h;if(r instanceof Uint8Array){if(0===(i=r.byteLength))return{u:0,v:0,size:0};let{u:e,v:o}=dn(t,i);return n.HEAPU8.set(r,e),{u:e,v:o,size:i}}if(i=i&&i>0?i:0,!r&&e){if(e=e.toString(),!(r=await fetch(e)).ok||!r.body)throw Error(`Failed to fetch asset: ${e} (${r.status})`);(e=Number(r.headers.get("content-length")||0))>0&&(i=e),r=r.body.getReader()}if(!r)return{u:0,v:0,size:0};if(i>0){let{u:o,v:a}=dn(t,i);for(t=0;;){let{value:s,done:l}=await r.read();if(l)break;if(s&&s.byteLength>0){if(t+(e=Number(s.byteLength))>i)throw n._free(a),Error(`Stream exceeded expected content-length (${i} bytes).`);n.HEAPU8.set(s,o+t>>>0),t+=e}}return{u:o,v:a,size:t}}for(i=[],e=0;;){let{value:t,done:n}=await r.read();if(n)break;if(t&&t.byteLength>0){var o=Number(t.byteLength);i.push(t),e+=o}}if(0===e)return{u:0,v:0,size:0};var{u:a,v:s}=dn(t,e);for(t=0,r=0;r<i.length;r++)(o=i[r])&&(n.HEAPU8.set(o,a+t>>>0),t+=o.byteLength,i[r]=void 0);return{u:a,v:s,size:e}}var vn=class extends nn{constructor(t,e){super(new Yi(t,e)),this.baseOptions=new ci,this.L=this.C=this.K=this.A=this.j=this.maxNumTokens=this.backendType=0,this.W=!1,this.Z=this.J=0}get contextWindow(){return this.maxNumTokens}get contextUsage(){return this.J}T(t){this.N=t,this.J=fn(t)}async ia(t){if(0!==this.j){var e=t.questions??[];if(0!==e.length){var r=this.i.h;"function"==typeof r.prewarmSchema?await r.prewarmSchema(this.j,t.context??"",e):"function"==typeof r.evaluateSchema&&await r.evaluateSchema(this.j,"__PREWARM__",t.context??"",e)}}}async ha(t,e){return t=e?.context?`${e.context}\n${t}`:t,fn(this.N)+on(t)}async S(t){if(0!==this.j)throw Error("Decision does not support updating options after initialization.");if("CPU"===t.baseOptions?.delegate?this.backendType=-1:void 0!==t.backendType&&(this.backendType=t.backendType),void 0!==t.maxNumTokens&&(this.maxNumTokens=t.maxNumTokens),t.schema?this.T(t.schema):(t.questions||t.context||t.expectedInputs)&&this.T({context:t.context,expectedInputs:t.expectedInputs,questions:t.questions}),-1===this.backendType){this.i.h.preinitializedWebGPUDevice=void 0;var e="undefined"!=typeof self?self:globalThis;"object"==typeof e.Module&&e.Module&&(e.Module.preinitializedWebGPUDevice=void 0)}else if("undefined"!=typeof navigator&&navigator.gpu)try{if(!(e=this.i.h).preinitializedWebGPUDevice){var r=await navigator.gpu.requestAdapter({powerPreference:"high-performance"}),i=r?.info,n=!!r?.isFallbackAdapter||/swiftshader|llvmpipe|software|lavapipe/i.test(`${i?.vendor??""} ${i?.architecture??""} ${i?.description??""}`);if(r&&!n){for(var o of(n=[],["shader-f16","subgroups","subgroups-f16"]))r.features.has(o)&&n.push(o);o={};for(let t of["maxBufferSize","maxStorageBufferBindingSize","maxStorageBuffersPerShaderStage","maxComputeWorkgroupStorageSize"]){let e=r.limits[t];"number"==typeof e&&(o[t]=e)}let t=await r.requestDevice({requiredFeatures:n,requiredLimits:o});if(!t.adapterInfo&&i)try{Object.defineProperty(t,"adapterInfo",{value:i,writable:!0,configurable:!0})}catch{try{t.adapterInfo=i}catch{}}e.preinitializedWebGPUDevice=t}}e.preinitializedWebGPUDevice&&("object"==typeof(r=self).Module&&r.Module&&(r.Module.preinitializedWebGPUDevice=e.preinitializedWebGPUDevice))}catch(t){console.warn("WebGPU device initialization failed:",t)}if(r=e=this.i.h,(i=!(!t.baseOptions||!t.baseOptions.modelAssetPath&&!t.baseOptions.modelAssetBuffer))&&"function"==typeof e.createDecisionFromBuffers&&"function"==typeof r._malloc){if(r=await pn(this,t.baseOptions?.modelAssetPath,t.baseOptions?.modelAssetBuffer,t.modelAssetSize),this.A=r.u,this.K=r.v,i=0,t.companionPleAssetPath||t.companionPleAssetBuffer)try{let e=await pn(this,t.companionPleAssetPath,t.companionPleAssetBuffer,t.companionPleAssetSize);this.C=e.u,this.L=e.v,i=e.size}catch(t){console.warn("Optional companion per-layer embedder not loaded:",t)}this.j=await e.createDecisionFromBuffers(this.A,r.size,this.C,i,this.backendType,this.maxNumTokens)}else await en(this,t,i),this.j=await e.createDecision("/model.litertlm",this.backendType,this.maxNumTokens);this.l?.X()}evaluateBoolean(t,e){if(0===this.j)throw Error("Decision is already closed.");var r=this.i.h,i=e.context?`${e.context}\n${e.condition}`:e.condition;return hn(this,()=>r.evaluateBoolean(this.j,t,i,e.threshold??.5,e.temperature??0))}evaluateChoice(t,e){if(0===this.j)throw Error("Decision is already closed.");var r=this.i.h,i=an(e),n=e.instructions??"",o=e.context?n?`${e.context}\n${n}`:e.context:n;return hn(this,()=>r.evaluateChoice(this.j,t,i,e.temperature??0,o))}async evaluateScore(t,e){if(0===this.j)throw Error("Decision is already closed.");var r=this.i.h,{rubric:i,labels:n,P:o,O:a}=sn(e),s=e.instructions??"",l=e.context?s?`${e.context}\n${s}`:e.context:s;return ln(s=await hn(this,()=>r.evaluateScore(this.j,t,i,e.temperature??0,l)),n,o,a)}async evaluate(t,e,r){if(0===this.j)throw Error("Decision is already closed.");if(r?.signal?.aborted)throw new DOMException("The operation was aborted.","AbortError");var i=r?.context?`${r.context}\n${t}`:t,n=e.context;this.J=fn(e)+on(i);var o=this.i.h;if("function"==typeof o.evaluateSchema&&(e.questions??[]).length>0)return hn(this,()=>o.evaluateSchema(this.j,i,n??"",e.questions??[]));t={};for(let o of e.questions??[])if("binary"===o.type||"boolean"===o.type){var a=(r=await this.evaluateBoolean(i,{condition:o.prompt,context:n,threshold:o.threshold,temperature:o.temperature,normalizePrior:o.normalizePrior,options:o.options})).probabilityTrue;let e=o.options&&o.options.length>=2?o.options[0].label:"false",s=o.options&&o.options.length>=2?o.options[1].label:"true";t[o.id]={id:o.id,label:a>=(o.threshold??.5)?s:e,confidence:r.confidence,probability:a,probabilities:[{label:e,probability:Math.max(0,1-a)},{label:s,probability:a}]}}else if("categorical"===o.type||"choice"===o.type){let e=await this.evaluateChoice(i,{options:o.options,instructions:o.prompt,context:n,temperature:o.temperature,normalizePrior:o.normalizePrior});r=(r=(o.options??[]).map(t=>t.label)).length>0?r.map(t=>({label:t,probability:e.probabilities[t]??0})):Object.entries(e.probabilities).map(([t,e])=>({label:t,probability:e})),t[o.id]={id:o.id,label:e.selectedKey,confidence:e.confidence,probabilities:r,predictionSet:e.predictionSet}}else if("ordinal"===o.type||"score"===o.type){r=await this.evaluateScore(i,{options:o.options,instructions:o.prompt,context:n,temperature:o.temperature});let e=(o.options??[]).map(t=>t.label);a=(r.probabilities??[]).map((t,r)=>({label:r<e.length?e[r]:String(r),probability:t})),t[o.id]={id:o.id,label:r.selectedKey??e[0]??"0",confidence:r.confidence,expectedScore:r.expectedScore,probabilities:a}}return t}async ba(t,e,r){var i=[];for(let n of t)i.push(await this.evaluate(n,e,r));return i}async aa(t,e){if(!this.N)throw Error("No session schema configured. Pass `schema` or `questions` in DecisionMakerOptions or call setSchema() before classify().");return this.evaluate(t,this.N,e)}async evaluateBooleanBatch(t,e,r=""){if(0===this.j)throw Error("Decision is already closed.");if(0===t.length)return[];var i=this.i.h,n=e.context?`${e.context}\n${e.condition}`:e.condition;if("function"==typeof i.evaluateBooleanBatch)return hn(this,()=>i.evaluateBooleanBatch(this.j,t,n,e.threshold??.5,e.temperature??0,r));var o=[];for(let i of t)o.push(await this.evaluateBoolean(r?`${r}\n${i}`:i,e));return o}async evaluateChoiceBatch(t,e,r=""){if(0===this.j)throw Error("Decision is already closed.");if(0===t.length)return[];var i=this.i.h,n=an(e),o=e.instructions??"",a=e.context?o?`${e.context}\n${o}`:e.context:o;if("function"==typeof i.evaluateChoiceBatch)return hn(this,()=>i.evaluateChoiceBatch(this.j,t,n,e.temperature??0,a,r));o=[];for(let i of t)o.push(await this.evaluateChoice(r?`${r}\n${i}`:i,e));return o}async evaluateScoreBatch(t,e,r=""){if(0===this.j)throw Error("Decision is already closed.");if(0===t.length)return[];var i=this.i.h,{rubric:n,labels:o,P:a,O:s}=sn(e),l=e.instructions??"",u=e.context?l?`${e.context}\n${l}`:e.context:l;if("function"==typeof i.evaluateScoreBatch)return(await hn(this,()=>i.evaluateScoreBatch(this.j,t,n,e.temperature??0,u,r))).map(t=>ln(t,o,a,s));l=[];for(let i of t)l.push(await this.evaluateScore(r?`${r}\n${i}`:i,e));return l}close(){if(!this.W){this.W=!0;var t=this.i.h;if(0!==this.j){try{t.deleteDecision(this.j)}catch{}this.j=0}var e=this.K||this.A;if(0!==e){try{t._free(e)}catch{}this.K=this.A=0}if(0!==(e=this.L||this.C)){try{t._free(e)}catch{}this.L=this.C=0}super.close(),t&&!un.includes(t)&&un.push(t)}}};vn.prototype.close=vn.prototype.close,vn.prototype.evaluateScoreBatch=vn.prototype.evaluateScoreBatch,vn.prototype.evaluateChoiceBatch=vn.prototype.evaluateChoiceBatch,vn.prototype.evaluateBooleanBatch=vn.prototype.evaluateBooleanBatch,vn.prototype.classify=vn.prototype.aa,vn.prototype.evaluateBatch=vn.prototype.ba,vn.prototype.evaluate=vn.prototype.evaluate,vn.prototype.evaluateScore=vn.prototype.evaluateScore,vn.prototype.evaluateChoice=vn.prototype.evaluateChoice,vn.prototype.evaluateBoolean=vn.prototype.evaluateBoolean,vn.prototype.setOptions=vn.prototype.S,vn.prototype.measureContextUsage=vn.prototype.ha,vn.prototype.prewarm=vn.prototype.ia,vn.prototype.setSchema=vn.prototype.T,vn.createFromModelBuffer=function(t,e,r=0,i=0){return cn(t,{baseOptions:{modelAssetBuffer:e},backendType:r,maxNumTokens:i})},vn.createFromModelPath=function(t,e,r=0,i=0){return cn(t,{baseOptions:{modelAssetPath:e},backendType:r,maxNumTokens:i})},vn.createFromOptions=cn;export{vn as DecisionMaker,pi as FilesetResolver,nn as TaskRunner};
2
2
  //# sourceMappingURL=decision_bundle_mjs.js.map