@mediapipe/tasks-retrieval 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.
- package/README.md +4 -4
- package/package.json +1 -1
- package/retrieval_bundle.cjs +1 -1
- package/retrieval_bundle.cjs.map +1 -1
- package/retrieval_bundle.js +1 -1
- package/retrieval_bundle.mjs +1 -1
- package/retrieval_bundle.mjs.map +1 -1
- package/wasm/retrieval_wasm_internal.js +220 -190
- package/wasm/retrieval_wasm_internal.wasm +0 -0
- package/wasm/retrieval_wasm_module_internal.js +220 -190
- package/wasm/retrieval_wasm_module_internal.wasm +0 -0
- package/wasm/retrieval_wasm_nosimd_internal.js +220 -190
- package/wasm/retrieval_wasm_nosimd_internal.wasm +0 -0
- package/LICENSE +0 -218
- package/NOTICE +0 -32152
- package/retrieval_bundle.js.map +0 -1
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ const retrieval = await FilesetResolver.forRetrievalTasks("https://cdn.jsdelivr.
|
|
|
19
19
|
|
|
20
20
|
const embedder = await UniversalEmbedder.createFromOptions(retrieval, {
|
|
21
21
|
baseOptions: {
|
|
22
|
-
modelAssetPath: "
|
|
22
|
+
modelAssetPath: "embededder.litertlm"
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
|
|
@@ -52,18 +52,18 @@ const universalEmbedder = await UniversalEmbedder.createFromOptions(
|
|
|
52
52
|
retrieval,
|
|
53
53
|
{
|
|
54
54
|
baseOptions: {
|
|
55
|
-
modelAssetPath: "
|
|
55
|
+
modelAssetPath: "embededder.litertlm"
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
);
|
|
59
59
|
|
|
60
60
|
// Embed text
|
|
61
|
-
const textEmbeddingResult = universalEmbedder.embedText("The quick brown fox jumps over the lazy dog");
|
|
61
|
+
const textEmbeddingResult = await universalEmbedder.embedText("The quick brown fox jumps over the lazy dog");
|
|
62
62
|
console.log("Text embedding:", textEmbeddingResult.embeddings[0].floatEmbedding);
|
|
63
63
|
|
|
64
64
|
// Embed images directly from the DOM
|
|
65
65
|
const image = document.getElementById("myImage");
|
|
66
|
-
const imageEmbeddingResult = universalEmbedder.embedImage(image);
|
|
66
|
+
const imageEmbeddingResult = await universalEmbedder.embedImage(image);
|
|
67
67
|
|
|
68
68
|
// Compute similarity
|
|
69
69
|
const similarity = UniversalEmbedder.cosineSimilarity(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mediapipe/tasks-retrieval",
|
|
3
|
-
"version": "1.1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "MediaPipe Retrieval Tasks. See the privacy notice at https://goo.gle/mediapipe-privacy.",
|
|
5
5
|
"main": "retrieval_bundle.cjs",
|
|
6
6
|
"browser": "retrieval_bundle.mjs",
|
package/retrieval_bundle.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var t="undefined"!=typeof self?self:{};function e(e,r){t:{for(var n=["CLOSURE_FLAGS"],i=t,o=0;o<n.length;o++)if(null==(i=i[n[o]])){n=null;break t}n=i}return null!=(e=n&&n[e])?e:r}var r,n="undefined"!=typeof TextEncoder;function i(t){if(n)t=(r||=new TextEncoder).encode(t);else{let r=0,n=new Uint8Array(3*t.length);for(let i=0;i<t.length;i++){var e=t.charCodeAt(i);if(e<128)n[r++]=e;else{if(e<2048)n[r++]=e>>6|192;else{if(e>=55296&&e<=57343){if(e<=56319&&i<t.length){let o=t.charCodeAt(++i);if(o>=56320&&o<=57343){e=1024*(e-55296)+o-56320+65536,n[r++]=e>>18|240,n[r++]=e>>12&63|128,n[r++]=e>>6&63|128,n[r++]=63&e|128;continue}i--}e=65533}n[r++]=e>>12|224,n[r++]=e>>6&63|128}n[r++]=63&e|128}}t=r===n.length?n:n.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 u,l=t.navigator;u=l&&l.userAgentData||null;var f={},c=null;function h(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 n=new Uint8Array(r),i=0;return function(t,e){function r(e){for(;n<t.length;){let e=t.charAt(n++),r=c[e];if(null!=r)return r;if(!/^[\s\xa0]*$/.test(e))throw Error("Unknown base64 encoding at char: "+e)}return e}d();for(var n=0;;){let t=r(-1),n=r(0),i=r(64),o=r(64);if(64===o&&-1===t)break;e(t<<2|n>>4),64!=i&&(e(n<<4&240|i>>2),64!=o&&e(i<<6&192|o))}}(t,function(t){n[i++]=t}),i!==r?n.subarray(0,i):n}function d(){if(!c){c={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){let n=t.concat(e[r].split(""));f[r]=n;for(let t=0;t<n.length;t++){let e=n[t];void 0===c[e]&&(c[e]=t)}}}}var p="undefined"!=typeof Uint8Array,y=!(!(!!o&&(!!u&&u.brands.length>0))&&(-1!=s().indexOf("Trident")||-1!=s().indexOf("MSIE")))&&"function"==typeof btoa,m=/[-_.]/g,g={"-":"+",_:"/",".":"="};function v(t){return g[t]||""}function b(t){if(!y)return h(t);t=m.test(t)?t.replace(m,v):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,A={},I=class{constructor(t,e){if(E(e),this.h=t,null!=t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}};function E(t){if(t!==A)throw Error("illegal external caller")}function S(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}var x=void 0;function B(t){return S(t=Error(t),"warning"),t}function N(e,r){if(null!=e){var n=x??={},i=n[e]||0;i>=r||(n[e]=i+1,S(e=Error(),"incident"),function(e){t.setTimeout(()=>{throw e},0)}(e))}}function C(){return"function"==typeof BigInt}var _="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 T,O=j("jas",void 0,!0),F=j(void 0,"1oa"),U=j(void 0,"0ubsb"),k=j(void 0,"0actk"),M=j("m_m","ma",!0),R={ba:{value:0,configurable:!0,writable:!0,enumerable:!1}},P=Object.defineProperties,D=_?O:"ba",L=[];function z(t,e){_||D in t||P(t,R),t[D]|=e}function G(t,e){_||D in t||P(t,R),t[D]=e}G(L,7),T=Object.freeze(L);var $={};function H(t,e){return void 0===e?t.h!==W&&!!(2&t.l[D]):!!(2&e)&&t.h!==W}var W={};function J(t){return t.la=!0,t}var q=J(t=>"number"==typeof t),V=J(t=>"string"==typeof t),K=J(t=>"boolean"==typeof t),X="function"==typeof t.BigInt&&"bigint"==typeof t.BigInt(0);function Z(t){var e=t;if(V(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 X?BigInt(t):t=K(t)?t?"1":"0":V(t)?t.trim()||"0":String(t)}var Y=J(t=>X?t>=tt&&t<=rt:"-"===t[0]?nt(t,Q):nt(t,et)),Q=Number.MIN_SAFE_INTEGER.toString(),tt=X?BigInt(Number.MIN_SAFE_INTEGER):void 0,et=Number.MAX_SAFE_INTEGER.toString(),rt=X?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 n=t[r],i=e[r];if(n>i)return!1;if(n<i)return!0}}var it,ot=0,at=0;function st(t){var e=t>>>0;ot=e,at=(t-e)/4294967296>>>0}function ut(t){if(t<0){st(-t);let[e,r]=pt(ot,at);ot=e>>>0,at=r>>>0}else st(t)}function lt(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 C()?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+ct(r)+ct(t));return r}function ct(t){return t=String(t),"0000000".slice(t.length)+t}function ht(){var t=ot,e=at;if(2147483648&e)if(C())t=""+(BigInt(0|e)<<BigInt(32)|BigInt(t>>>0));else{let[r,n]=pt(t,e);t="-"+ft(r,n)}else t=ft(t,e);return t}function dt(t){if(t.length<16)ut(Number(t));else if(C())t=BigInt(t),ot=Number(t&BigInt(4294967295))>>>0,at=Number(t>>BigInt(32)&BigInt(4294967295));else{let e=+("-"===t[0]);at=ot=0;let r=t.length;for(let n=e,i=(r-e)%6+e;i<=r;n=i,i+=6){let e=Number(t.slice(n,i));at*=1e6,(ot=1e6*ot+e)>=4294967296&&(at+=Math.trunc(ot/4294967296),at>>>=0,ot>>>=0)}if(e){let[t,e]=pt(ot,at);ot=t,at=e}}}function pt(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}var yt="function"==typeof BigInt?BigInt.asIntN:void 0,mt="function"==typeof BigInt?BigInt.asUintN:void 0,gt=Number.isSafeInteger,vt=Number.isFinite,bt=Math.trunc;function wt(t){return null==t||"number"==typeof t?t:"NaN"===t||"Infinity"===t||"-Infinity"===t?Number(t):void 0}var At,It,Et,St=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function xt(t){switch(typeof t){case"bigint":return!0;case"number":return vt(t);case"string":return St.test(t);default:return!1}}function Bt(t){if(null==t)return t;if("string"==typeof t&&t)t=+t;else if("number"!=typeof t)return;return vt(t)?0|t:void 0}function Nt(t){var e=t.length;return("-"===t[0]?e<20||20===e&&t<="-9223372036854775808":e<19||19===e&&t<="9223372036854775807")?t:(dt(t),ht())}function Ct(t){if("-"===t[0])var e=!1;else e=(e=t.length)<20||20===e&&t<="18446744073709551615";return e?t:(dt(t),ft(ot,at))}function _t(t){if(t=bt(t),!gt(t)){ut(t);var e=ot,r=at;(t=2147483648&r)&&(r=~r>>>0,0==(e=1+~e>>>0)&&(r=r+1>>>0)),t="number"==typeof(e=lt(e,r))?t?-e:e:t?"-"+e:e}return t}function jt(t){return(t=bt(t))>=0&>(t)||(ut(t),t=lt(ot,at)),t}function Tt(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(yt(64,t));if(xt(t)){if("string"===e)return e=bt(Number(t)),gt(e)?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=Nt(t)),t;if("number"===e)return _t(t)}}function Ot(t){if(null==t||"string"==typeof t||t instanceof I)return t}function Ft(t){return null==t||"string"==typeof t?t:void 0}function Ut(t){return t}function kt(t,e,r,n){var i=void 0!==n;n=!!n;var o=[],a=t.length,s=4294967295,u=!1,l=!!(64&e),f=l?128&e?0:-1:void 0;if(!(1&e)){var c=a&&t[a-1];null!=c&&"object"==typeof c&&c.constructor===Object?s=--a:c=void 0,!l||128&e||i||(u=!0,s=(At??Ut)(s-f,f,t,c,void 0)+f)}for(e=void 0,i=0;i<a;i++){let a=t[i];if(null!=a&&null!=(a=r(a,n)))if(l&&i>=s){let t=i-f;(e??={})[t]=a}else o[i]=a}if(c)for(let i in c){if(null==(t=c[i])||null==(t=r(t,n)))continue;let u;a=+i,l&&!Number.isNaN(a)&&(u=a+f)<s?o[u]=t:(e??={})[i]=t}return e&&(u?o.push(e):o[s]=e),o}function Mt(t){switch(typeof t){case"number":return Number.isFinite(t)?t:""+t;case"bigint":return Y(t)?Number(t):""+t;case"boolean":return t?1:0;case"object":if(Array.isArray(t)){var e=0|t[D];return 0===t.length&&1&e?void 0:kt(t,e,Mt)}if(null!=t&&t[M]===$)return Rt(t);if(t instanceof I){if(null==(e=t.h))t="";else if("string"==typeof e)t=e;else{if(y){for(var r="",n=0,i=e.length-10240;n<i;)r+=String.fromCharCode.apply(null,e.subarray(n,n+=10240));r+=String.fromCharCode.apply(null,n?e.subarray(n):e),e=btoa(r)}else{void 0===r&&(r=0),d(),r=f[r],n=Array(Math.floor(e.length/3)),i=r[64]||"";let t=0,l=0;for(;t<e.length-2;t+=3){var o=e[t],a=e[t+1],s=e[t+2],u=r[o>>2];o=r[(3&o)<<4|a>>4],a=r[(15&a)<<2|s>>6],s=r[63&s],n[l++]=u+o+a+s}switch(u=0,s=i,e.length-t){case 2:s=r[(15&(u=e[t+1]))<<2]||i;case 1:e=e[t],n[l]=r[e>>2]+r[(3&e)<<4|u>>4]+s+i}e=n.join("")}t=t.h=e}return t}return}return t}function Rt(t){return kt(t=t.l,0|t[D],Mt)}function Pt(t,e,r,n=0){if(null==t){var i=32;r?(t=[r],i|=128):t=[],e&&(i=-16760833&i|(1023&e)<<14)}else{if(!Array.isArray(t))throw Error("narr");if(i=0|t[D],a&&1&i)throw Error("rfarr");if(2048&i&&!(2&i)&&function(){if(a)throw Error("carr");N(k,5)}(),256&i)throw Error("farr");if(64&i)return(i|n)!==i&&G(t,i|n),t;if(r&&(i|=128,r!==t[0]))throw Error("mid");t:{i|=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&i?0:-1)>=1024)throw Error("pvtlmt");for(var u in t)(o=+u)<s&&(r[o+e]=t[u],delete t[u]);i=-16760833&i|(1023&s)<<14;break t}}if(e){if((u=Math.max(e,o-(128&i?0:-1)))>1024)throw Error("spvt");i=-16760833&i|(1023&u)<<14}}}return G(t,64|i|n),t}function Dt(t,e){if("object"!=typeof t)return t;if(Array.isArray(t)){var r=0|t[D];return 0===t.length&&1&r?t=void 0:2&r||(!e||4096&r||16&r?t=Lt(t,r,!1,e&&!(16&r)):(z(t,34),4&r&&Object.freeze(t))),t}if(null!=t&&t[M]===$){let n=0|(r=t.l)[D];return H(t,n)||(2&n?e=!0:32&n&&!(4096&n)?(G(r,2|n),t.h=W,e=!0):e=!1,e?(t=new t.constructor(r)).j=W:t=Lt(r,n)),t}return t instanceof I?t:void 0}function Lt(t,e,r,n){return n??=!!(34&e),t=kt(t,e,Dt,n),n=32,r&&(n|=2),G(t,e=16769217&e|n),t}function zt(t){if(t.h!==W)return!1;var e=t.l;return z(e=Lt(e,0|e[D]),2048),t.l=e,t.h=void 0,t.j=void 0,!0}function Gt(t){if(!zt(t)&&H(t,0|t.l[D]))throw Error()}function $t(t,e){void 0===e&&(e=0|t[D]),32&e&&!(4096&e)&&G(t,4096|e)}function Ht(t,e,r){if(-1===e)return null;var n=e+(r?0:-1),i=t.length-1;if(!(i<1+(r?0:-1))){if(n>=i)if(null!=(t=t[i])&&"object"==typeof t&&t.constructor===Object)e=t[e];else{if(n!==i)return;e=t}else e=t[n];return e}}function Wt(t,e,r){Gt(t);var n=t.l;return Jt(n,0|n[D],e,r),t}function Jt(t,e,r,n,i){var o=r+(i?0:-1),a=t.length-1;if(a>=1+(i?0:-1)&&o>=a){let i=t[a];if(null!=i&&"object"==typeof i&&i.constructor===Object)return i[r]=n,e}return o<=a?(t[o]=n,e):(void 0!==n&&(r>=(a=(e??=0|t[D])>>14&1023||536870912)?null!=n&&(t[a+(i?0:-1)]={[r]:n}):t[o]=n),e)}function qt(t,e,r){return t=Ht(t,e,r),Array.isArray(t)?t:T}function Vt(t,e){return 2&e&&(t|=2),1|t}function Kt(t){return!!(2&t)&&!!(4&t)||!!(256&t)}function Xt(t){if(_)return t[F]??(t[F]=new Map);if(F in t)return t[F];var e=new Map;return Object.defineProperty(t,F,{value:e}),e}function Zt(t,e,r,n){var i=t.get(n);if(null!=i)return i;i=0;for(let t=0;t<n.length;t++){let o=n[t];null!=Ht(e,o)&&(0!==i&&(r=Jt(e,r,i)),i=o)}return t.set(n,i),i}function Yt(t){return null==t&&(t=void 0),t}function Qt(t,e,r){return Wt(t,e,r=Yt(r)),r&&!H(r)&&$t(t.l),t}function te(t,e,r){var n=bn;t:{var i=r=Yt(r);Gt(t);let s=t.l;var o=0|s[D];if(null==i){var a=Xt(s);if(Zt(a,s,o,n)!==e)break t;a.set(n,0)}else{let t=Xt(a=s),r=Zt(t,a,o,n);r!==e&&(r&&(o=Jt(a,o,r)),t.set(n,e))}Jt(s,o,e,i)}return r&&!H(r)&&$t(t.l),t}function ee(t,e){return-273&(2&e?2|t:-3&t)}function re(t,e){var r=fn;Gt(t);var n=t.l,i=n,o=0|n[D],a=H(t,o)?1:2;2===a&&zt(t)&&(o=0|(i=t.l)[D]);var s=qt(i,8),u=s===T?7:0|s[D],l=Vt(u,o);if(t=!(4&l)){var f=o;let t=!!(2&l);t&&(f|=2);let e=!t,n=!0,i=0,a=0;for(;i<s.length;i++){var c=s[i],h=r,d=f;if(null==c||c[M]!==$)if(Array.isArray(c)){let t,e=0|c[D];t=e|32&d,t|=2&d,t!==e&&G(c,t),c=new h(c)}else c=void 0;c instanceof r&&(t||(h=H(c),e&&=!h,n&&=h),s[a++]=c)}a<i&&(s.length=a),l|=4,l=n?-4097&l:4096|l,l=e?8|l:-9&l}l!==u&&(G(s,l),2&l&&Object.freeze(s)),l=u=l,1===a||4===a&&(2&u||!(16&u)&&32&o)?Kt(u)||((u|=!s.length||t&&!(4096&u)||32&o&&!(4096&u||16&u)?2:256)!==l&&G(s,u),Object.freeze(s)):(2===a&&Kt(u)&&(s=Array.prototype.slice.call(s),l=0,u=ee(u,o),o=Jt(i,o,8,s)),Kt(u)||u!==l&&G(s,u)),2&u||!(4096&u||16&u)||$t(i,o),a=s,e=null!=e?e:new r,a.push(e),t=r=a===T?7:0|a[D],(e=H(e))?(r&=-9,1===a.length&&(r&=-4097)):r|=4096,r!==t&&G(a,r),e||$t(n)}function ne(t,e,r){return Wt(t,e,null==r?r:function(t){if(!xt(t))throw B("int64");switch(typeof t){case"string":var e=bt(Number(t));return gt(e)?t=Z(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=C()?Z(yt(64,BigInt(t))):Z(Nt(t))),t;case"bigint":return Z(yt(64,t));default:return gt(t)?t=Z(_t(t)):(t=bt(t),gt(t)?t=String(t):(ut(t),t=ht()),t=Z(t)),t}}(r))}function ie(t,e,r){return Wt(t,e,null==r?r:function(t){if(!xt(t))throw B("uint64");switch(typeof t){case"string":var e=bt(Number(t));return gt(e)&&e>=0?t=Z(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=C()?Z(mt(64,BigInt(t))):Z(Ct(t))),t;case"bigint":return Z(mt(64,t));default:return gt(t)?t=Z(jt(t)):((t=bt(t))>=0&>(t)?t=String(t):(ut(t),t=ft(ot,at)),t=Z(t)),t}}(r))}function oe(t,e,r){if(null!=r&&"string"!=typeof r)throw Error();return Wt(t,e,r)}function ae(t,e,r){if(null!=r){if(!vt(r))throw B("enum");r|=0}return Wt(t,e,r)}var se=class{constructor(t,e,r){if(this.buffer=t,r&&!e)throw Error()}};function ue(t){if("string"==typeof t)return new se(b(t),!0);if(Array.isArray(t))return new se(new Uint8Array(t),!0);if(t.constructor===Uint8Array)return new se(t,!1);if(t.constructor===ArrayBuffer)return t=new Uint8Array(t),new se(t,!1);if(t.constructor===I){E(A);var e=t.h;return e=(null==(e=null==e||p&&null!=e&&e instanceof Uint8Array?e:"string"==typeof e?b(e):null)?e:t.h=e)||new Uint8Array(0),new se(e,!0,t)}if(t instanceof Uint8Array)return t=t.constructor===Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new se(t,!1);throw Error()}function le(t){return new he(4294967295&t,Math.floor(t/4294967296))}function fe(t){return t?/^\d+$/.test(t)?(dt(t),new he(ot,at)):null:ce||=new he(0,0)}var ce,he=class{constructor(t,e){this.i=t>>>0,this.h=e>>>0}};function de(t){return new Ee(4294967295&t,Math.floor(t/4294967296))}function pe(t){return t?/^-?\d+$/.test(t)?(dt(t),new Ee(ot,at)):null:ye||=new Ee(0,0)}var ye,me,ge,ve,be,we,Ae,Ie,Ee=class{constructor(t,e){this.i=t>>>0,this.h=e>>>0}};function Se(t,e,r){return"undefined"!=typeof BigInt64Array?(Ae||(Ae=new BigInt64Array(1),Ie=new Uint32Array(Ae.buffer),Ae[0]=BigInt(1),we=1===Ie[0]),Ae[0]=t,new e(Ie[t=we?0:1],Ie[1-t])):(be||(me=BigInt(Number.MIN_SAFE_INTEGER),ge=BigInt(Number.MAX_SAFE_INTEGER),ve=BigInt(4294967295),be=BigInt(32)),t>=me&&t<=ge?r(Number(t)):(t=BigInt.asUintN(64,t),new e(Number(t&ve),Number(t>>be))))}function xe(t,e,r){for(;r>0||e>127;)t.h.push(127&e|128),e=(e>>>7|r<<25)>>>0,r>>>=7;t.h.push(e)}function Be(t,e){for(;e>127;)t.h.push(127&e|128),e>>>=7;t.h.push(e)}function Ne(t,e){if(e>=0)Be(t,e);else{for(let r=0;r<9;r++)t.h.push(127&e|128),e>>=7;t.h.push(1)}}function Ce(t,e){dt(e),function(t){var e=at>>31;t(ot<<1^e,(at<<1|ot>>>31)^e)}((e,r)=>{xe(t,e>>>0,r>>>0)})}function _e(t,e){t.h.push(e>>>0&255),t.h.push(e>>>8&255),t.h.push(e>>>16&255),t.h.push(e>>>24&255)}var je=class{constructor(){this.h=[]}length(){return this.h.length}end(){var t=this.h;return this.h=[],t}};function Te(t,e){0!==e.length&&(t.j.push(e),t.i+=e.length)}function Oe(t,e,r){Be(t.h,8*e+r)}function Fe(t,e){return Oe(t,e,2),e=t.h.end(),Te(t,e),e.push(t.i),e}function Ue(t,e){var r=e.pop();for(r=t.i+t.h.length()-r;r>127;)e.push(127&r|128),r>>>=7,t.i++;e.push(r),t.i++}function ke(t,e,r){if(null!=r)switch(Oe(t,e,0),typeof r){case"number":t=t.h,ut(r),xe(t,ot,at);break;case"bigint":r=Se(r,Ee,de),xe(t.h,r.i,r.h);break;default:r=pe(r),xe(t.h,r.i,r.h)}}function Me(t,e,r){Oe(t,e,2),Be(t.h,r.length),Te(t,t.h.end()),Te(t,r)}var Re=class{constructor(){this.j=[],this.i=0,this.h=new je}};function Pe(t){if("string"==typeof t)pe(t)}function De(){var t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var Le=De(),ze=De(),Ge=De(),$e=De(),He=De(),We=De(),Je=De(),qe=De(),Ve=De(),Ke=De(),Xe=De(),Ze=De(),Ye=class{constructor(t,e){this.l=Pt(t,e,void 0,2048)}toJSON(){return Rt(this)}};Ye.prototype[M]=$,Ye.prototype.toString=function(){return this.l.toString()};var Qe=class{constructor(t,e){this.h=t,t=Le,this.i=!!t&&e===t||!1}};function tr(t,e,r,n,i){null!=(e=ur(e,n))&&(r=Fe(t,r),i(e,t),Ue(t,r))}var er,rr,nr=new Qe(tr,Le),ir=new Qe(tr,Le),or=Symbol(),ar=Symbol();function sr(t){var e=lr,r=fr,n=t[or];if(n)return n;(n={}).ja=t,n.O=function(t){switch(typeof t){case"boolean":return It||=[0,void 0,!0];case"number":return t>0?void 0:0===t?Et||=[0,void 0]:[-t,void 0];case"string":return[0,t];case"object":return t}}(t[0]);var i=t[1],o=1;i&&i.constructor===Object&&(n.W=i,"function"==typeof(i=t[++o])&&(n.ca=!0,er??=i,rr??=t[o+1],i=t[o+=2]));for(var a={};i&&Array.isArray(i)&&i.length&&"number"==typeof i[0]&&i[0]>0;){for(var s=0;s<i.length;s++)a[i[s]]=i;i=t[++o]}for(s=1;void 0!==i;){let f;"number"==typeof i&&(s+=i,i=t[++o]);var u=void 0;if(i instanceof Qe?f=i:(f=nr,o--),f?.i){i=t[++o],u=t;var l=o;"function"==typeof i&&(i=i(),u[l]=i),u=i}for(l=s+1,"number"==typeof(i=t[++o])&&i<0&&(l-=i,i=t[++o]);s<l;s++){let t=a[s];u?r(n,s,f,u,t):e(n,s,f,t)}}return t[or]=n}function ur(t,e){return t instanceof Ye?t.l:Array.isArray(t)?Pt(t,e[0],e[1]):void 0}function lr(t,e,r){t[e]=r.h}function fr(t,e,r,n){var i,o,a=r.h;t[e]=(t,e,r)=>a(t,e,r,o||=sr(n).O,i||=cr(n))}function cr(t){var e=t[ar];if(!e){let r=sr(t);e=(t,e)=>hr(t,e,r),t[ar]=e}return e}function hr(t,e,r){!function(t,e,r){var n,i=128&e?0:-1,o=t.length;(n=!!o)&&(n=null!=(n=t[o-1])&&"object"==typeof n&&n.constructor===Object);var a=o+(n?-1:0);for(e=128&e?1:0;e<a;e++)r(e-i,t[e]);if(n){t=t[o-1];for(let e in t)!isNaN(e)&&r(+e,t[e])}}(t,0|t[D],(t,n)=>{if(null!=n){var i=function(t,e){var r=t[e];if(r)return r;if((r=t.W)&&(r=r[e])){var n=(r=Array.isArray(r)?r[0]instanceof Qe?r:[ir,r]:[r,void 0])[0].h;if(r=r[1]){let e=cr(r),i=sr(r).O;r=t.ca?rr(i,e):(t,r,o)=>n(t,r,o,i,e)}else r=n;return t[e]=r}}(r,t);i?i(e,n,t):t<500||N(U,3)}})}function dr(t,e,r){if(Array.isArray(e)){var n=0|e[D];if(4&n)return e;for(var i=0,o=0;i<e.length;i++){let r=t(e[i]);null!=r&&(e[o++]=r)}return o<i&&(e.length=o),t=1|n,r&&(t=-1537&t|4),t!==n&&G(e,t),r&&2&t&&Object.freeze(e),e}}var pr=(t,e)=>{var r=new Re;hr(t.l,r,sr(e)),Te(r,r.h.end()),t=new Uint8Array(r.i);var n=(e=r.j).length,i=0;for(let r=0;r<n;r++){let n=e[r];t.set(n,i),i+=n.length}return r.j=[t],t};function yr(t,e){return new Qe(t,e)}function mr(t,e){return new Qe(t,e)}function gr(t,e,r){null!=(e=Tt(e))&&(Pe(e),ke(t,r,e))}function vr(t,e,r){null!=(e=Bt(e))&&null!=e&&(Oe(t,r,0),Ne(t.h,e))}function br(t,e,r){null!=(e=Ft(e))&&Me(t,r,i(e))}function wr(t,e,r,n,i){null!=(e=ur(e,n))&&(r=Fe(t,r),i(e,t),Ue(t,r))}function Ar(t,e,r){null!=(e=Ot(e))&&Me(t,r,ue(e).buffer)}function Ir(t,e,r){null!=(e=Bt(e))&&(e=parseInt(e,10),Oe(t,r,0),Ne(t.h,e))}var Er,Sr=yr(function(t,e,r){null!=(e=wt(e))&&(Oe(t,r,1),t=t.h,(r=it||=new DataView(new ArrayBuffer(8))).setFloat64(0,+e,!0),ot=r.getUint32(0,!0),at=r.getUint32(4,!0),_e(t,ot),_e(t,at))},Ke),xr=yr(function(t,e,r){null!=(e=wt(e))&&(Oe(t,r,5),t=t.h,(r=it||=new DataView(new ArrayBuffer(8))).setFloat32(0,+e,!0),at=0,_e(t,ot=r.getUint32(0,!0)))},Ve),Br=yr(gr,We),Nr=yr(gr,We),Cr=mr(function(t,e,r){if(null!=(e=dr(Tt,e,!1)))for(let n=0;n<e.length;n++)ke(t,r,e[n])},We),_r=yr(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(xt(t)){if("string"===e)return e=bt(Number(t)),gt(e)&&e>=0?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=Ct(t)),t;if("number"===e)return jt(t)}}(e),null!=e){if("string"==typeof e)fe(e);if(null!=e)switch(Oe(t,r,0),typeof e){case"number":t=t.h,ut(e),xe(t,ot,at);break;case"bigint":r=Se(e,he,le),xe(t.h,r.i,r.h);break;default:r=fe(e),xe(t.h,r.i,r.h)}}},Je),jr=yr(vr,$e),Tr=mr(function(t,e,r){if(null!=(e=dr(Bt,e,!0)))for(let a=0;a<e.length;a++){var n=t,i=r,o=e[a];null!=o&&(Oe(n,i,0),Ne(n.h,o))}},$e),Or=mr(function(t,e,r){if(null!=(e=dr(Bt,e,!0))&&e.length){r=Fe(t,r);for(let r=0;r<e.length;r++)Ne(t.h,e[r]);Ue(t,r)}},$e),Fr=yr(function(t,e,r){null!=(e=null==e||"boolean"==typeof e?e:"number"==typeof e?!!e:void 0)&&(Oe(t,r,0),t.h.h.push(e?1:0))},ze),Ur=yr(br,Ge),kr=mr(function(t,e,r){if(null!=(e=dr(Ft,e,!0)))for(let s=0;s<e.length;s++){var n=t,o=r,a=e[s];null!=a&&Me(n,o,i(a))}},Ge),Mr=function(t,e,r=Le){return new Qe(e,r)}(0,function(t,e,r,n,i){if(Array.isArray(e)){for(let o=0;o<e.length;o++)wr(t,e[o],r,n,i);1&(t=0|e[D])||G(e,1|t)}}),Rr=new Qe(wr,Le),Pr=yr(Ar,Xe),Dr=mr(function(t,e,r){if(null!=(e=dr(Ot,e,!1)))for(let a=0;a<e.length;a++){var n=t,i=r,o=e[a];null!=o&&Me(n,i,ue(o).buffer)}},Xe),Lr=yr(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 vt(t)?t>>>0:void 0}(e),null!=e&&null!=e&&(Oe(t,r,0),Be(t.h,e))},He),zr=yr(Ir,Ze),Gr=yr(Ir,Ze),$r=yr(function(t,e,r){if(null!=(e=Tt(e))&&(Pe(e),null!=e))switch(Oe(t,r,0),typeof e){case"number":t=t.h,e=(r=e)<0,st(r=2*Math.abs(r)),r=ot;let n=at;e&&(0==r?0==n?n=r=4294967295:(n--,r=4294967295):r--),xe(t,ot=r,at=n);break;case"bigint":t=t.h,e=e<<BigInt(1)^e>>BigInt(63),ot=Number(BigInt.asUintN(32,e)),at=Number(BigInt.asUintN(32,e>>BigInt(32))),xe(t,ot,at);break;default:Ce(t.h,e)}},qe),Hr=[0,Pr,Dr,Fr,Ur],Wr=[0,yr(br,Ge),[0,Gr,[0,yr(gr,We),yr(vr,$e)],Gr,-1,[0,zr],Gr,-1],yr(Ar,Xe)],Jr=[0,1,[0,12,jr,10,Fr],[0,7,[0,jr,-1]]],qr=globalThis.trustedTypes;var Vr=class{constructor(t){this.h=t}toString(){return this.h+""}};function Kr(t){var e;return void 0===Er&&(Er=function(){var t=null;if(!qr)return t;try{let e=t=>t;t=qr.createPolicy("goog#html",{createHTML:e,createScript:e,createScriptURL:e})}catch(t){}return t}()),t=(e=Er)?e.createScriptURL(t):t,new Vr(t)}function Xr(t,...e){if(0===e.length)return Kr(t[0]);var r=t[0];for(let n=0;n<e.length;n++)r+=encodeURIComponent(e[n])+t[n+1];return Kr(r)}function Zr(t,e){if(t.floatEmbedding&&e.floatEmbedding)return Qr(t.floatEmbedding,e.floatEmbedding);if(t.quantizedEmbedding&&e.quantizedEmbedding)return Qr(Yr(t.quantizedEmbedding),Yr(e.quantizedEmbedding));throw Error("Cannot compute cosine similarity between quantized and float embeddings.")}function Yr(t){return Array.from(t,t=>t>127?t-256:t)}function Qr(t,e){if(t.length!==e.length)throw Error(`Cannot compute cosine similarity between embeddings of different sizes (${t.length} vs. ${e.length}).`);var r=0,n=0,i=0;for(let o=0;o<t.length;o++)r+=t[o]*e[o],n+=t[o]*t[o],i+=e[o]*e[o];if(n<=0||i<=0)throw Error("Cannot compute cosine similarity on embedding with 0 norm.");return r/Math.sqrt(n*i)}function tn(t){!t.h&&t.i.length>0&&(t.h=!0,t.i.shift()())}async function en(t,e){return new Promise((r,n)=>{t.i.push(()=>{e().then(r,n).finally(()=>{t.h=!1,tn(t)})}),tn(t)})}var rn,nn=class{constructor(){this.h=!1,this.i=[]}},on=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 an(t){if(t)return!0;if(void 0===rn)try{await WebAssembly.instantiate(on),rn=!0}catch{rn=!1}return rn}async function sn(t,e,r){return{wasmLoaderPath:`${e}/${t}_${r=`wasm${r?"_module":""}${await an(r)?"":"_nosimd"}_internal`}.js`,wasmBinaryPath:`${e}/${t}_${r}.wasm`}}var un=class{};function ln(t){return ae(new fn,1,t)}un.forVisionTasks=function(t,e=!1){return sn("vision",t??Xr``,e)},un.forLiteRtLmTextTasks=function(t,e=!1){return sn("litertlm_text",t??Xr``,e)},un.forTextTasks=function(t,e=!1){return sn("text",t??Xr``,e)},un.forRetrievalTasks=function(t,e=!1){return sn("retrieval",t??Xr``,e)},un.forGenAiTasks=function(t,e=!1){return sn("genai",t??Xr``,e)},un.forDecisionTasks=function(t,e=!1){return sn("decision",t??Xr``,e)},un.forAudioTasks=function(t,e=!1){return sn("audio",t??Xr``,e)},un.isSimdSupported=function(t=!1){return an(t)};var fn=class extends Ye{constructor(t){super(t)}},cn=class extends Ye{constructor(t){super(t)}},hn=[0,zr,2,_r,-2,Nr,Mr,[0,zr,Nr]],dn=class extends Ye{constructor(t){super(t)}},pn=class extends Ye{constructor(t){super(t)}};function yn(t,e){return ae(t,1,e)}function mn(t,e){return ae(t,2,e)}var gn,vn=class extends Ye{constructor(t){super(t)}},bn=[3,4,5,6,7],wn=class extends Ye{constructor(t){super(t)}},An=class extends Ye{constructor(t){super(t)}};An.prototype.i=(gn=[0,[0,zr,Ur,-3,zr],[0,bn,zr,-1,Rr,[0,zr,Ur,_r],Rr,hn,Rr,[0,1,hn],Rr,[0,zr],Rr,[0,zr,Ur,_r]]],function(){return pr(this,gn)});var In=class{constructor(){this.h="undefined"!=typeof AbortController}async send(t,e,r){var n=this.h?new AbortController:void 0,i=n&&t.N>0?setTimeout(()=>{n.abort()},t.N):void 0;try{let i=await fetch(t.url,{method:t.fa,headers:{...t.ea},...t.body&&{body:t.body},...t.withCredentials&&{credentials:"include"},signal:t.N&&n?n.signal:null});200===i.status?e?.(await i.text()):r?.(i.status)}catch(t){if("AbortError"===t?.name)r?.(408);else r?.(400)}finally{clearTimeout(i)}}},En=class extends Ye{constructor(t){super(t,37)}},Sn=[-4,{},Jr,zr,Wr],xn=[0,Ur,zr],Bn=[0,Ur,zr],Nn=[0,Ur,zr,1,Ur,-1,zr,1,zr,1,Nr],Cn=[0,zr,Ur,-2],_n=[0,Fr,-3],jn=[0,zr,Ur,-1,Nr,jr,-1,Ur,-5,Mr,[0,Ur,-4],-1,Fr,[0,Fr,-3],zr];var Tn=class extends Ye{constructor(t){super(t,19)}},On=function(t){return e=>pr(e,t)}([-19,{},[0,zr,1,[0,Ur,-6,Nr,jr,Ur,-1,Nr],1,[0,Ur,1,Ur,-5],Ur,-1,[0,zr,Ur,-8],[0,Ur,-3],[0,Ur,zr,Ur,-2],[0,Ur,-1,zr,Ur,-1,zr,Ur,-1,[0,Mr,[0,Ur,-1],Fr,Ur,-5],[0,zr,Fr,jr,-2]],Nr,[0,Ur,-3,Nr,jr,Ur,-1],[0,zr,Ur,-1],[0,Ur,-9],[0,Ur,-6,zr,Ur,1,Ur,Fr,zr,-1,Fr,Ur,-2,zr,Ur,zr,Ur,jr,-1],1,[0,zr],1,[0,Ur,-4],1,Nn,[0,[1,2,3,4,5,6],Rr,Nn,Rr,xn,Rr,Bn,Rr,[0,zr],Rr,jn,Rr,Cn],xn,Bn,jn,[0,[0,zr,Ur,-1,Nr,jr,-1,Ur,-4,Mr,[0,Ur,-4],-1,1,_n],[0,zr,Ur,-1,Nr,jr,-1,Ur,-4,_n]],Cn,[0,Ur,[0,jr,-3,zr],zr,-2,[0,jr,-1],Fr],4,[0,Ur,zr,Ur,-1,Nr,zr,Ur,-1,zr,jr,-1]],zr,Mr,[-37,{},Br,Ur,Mr,[0,Ur,-1],Pr,1,Pr,[0,kr,-1,Tr,Cr,-1],Ur,[0,jr,Ur,-1],Fr,jr,Nr,Ur,-1,$r,Hr,Br,Pr,zr,Tr,Nr,-1,[0,zr,-1],Ur,Fr,Ur,Or,Ur,-1,Sr,1,Sr,Sn,Fr,[0,zr,[0,xr,jr,-2],[0,xr]],[0,zr,Nr]],Br,Dr,Ur,-1,Br,zr,-1,[0,Fr,-1,zr,Fr],[0,Nr,-1,Ur],[0,Br,Fr,Nr],Nr,1,Lr,1,Sn]),Fn=class{constructor(t){this.i=[],this.m=new In,this.j=t??"",this.h=setInterval(()=>{this.flush()},6e4)}close(){void 0!==this.h&&(clearInterval(this.h),this.h=void 0),this.flush()}flush(t,e){if(this.error)e?.("net-send-failed");else if(0===this.i.length)t?.();else{var r=this.i;this.i=[],r=function(t){var e=new Tn;{Gt(e=ae(e,2,1786));let l=e.l,f=0|l[D];if(null==t)Jt(l,f,3);else{var r=t===T?7:0|t[D],n=r,i=Kt(r),o=i||Object.isFrozen(t),a=!0,s=!0;for(let e=0;e<t.length;e++){var u=t[e];i||(u=H(u),a&&=!u,s&&=u)}i||(r=a?13:5,r=s?-4097&r:4096|r),o&&r===n||(t=Array.prototype.slice.call(t),n=0,r=ee(r,f)),r!==n&&G(t,r),f=Jt(l,f,3,t),2&r||!(4096&r||16&r)||$t(l,f)}}return e}(r),r=On(r),this.m.send({url:"https://odml.pa.googleapis.com/v1/log",fa:"POST",N:1e4,body:r,ka:2,ea:{"Content-Type":"application/x-protobuf","x-goog-api-key":this.j},withCredentials:!1},()=>{t?.()},t=>{this.error=Error(`Logging failed with HTTP error: ${t}`),this.i=[],void 0!==this.h&&(clearInterval(this.h),this.h=void 0),e?.("net-send-failed",t)})}}};class Un{constructor(){this.I=this.B=this.G=this.A=this.D=this.F=this.C=0}}function kn(t,e){var r=new An;if(r=Qt(r,1,t.R),r=Qt(r,2,e),e=new En,null!=(r=r.i()))if("string"==typeof r)r=r?new I(r,A):w||=new I(null,A);else if(r.constructor!==I){if(!(p&&null!=r&&r instanceof Uint8Array))throw Error();r=r.length?new I(new Uint8Array(r),A):w||=new I(null,A)}e=Wt(e,6,r),(t=t.H).error||t.i.push(e)}function Mn(t){var e=new pn;e=ie(e=ae(e,1,10),3,performance.now()-t.P),kn(t,e=te(mn(yn(new vn,t.v),0),3,e)),t.m=performance.now()}function Rn(t,e){++t.h.F,t.i.set(e,performance.now())}function Pn(t,e){var r={C:e.C-t.j.C,F:e.F-t.j.F,D:e.D-t.j.D,A:e.A-t.j.A,G:e.G-t.j.G,B:e.B,I:e.I},n=mn(yn(new vn,t.v),1);kn(t,n=te(n,4,r=Ln(r))),t.j=e}function Dn(t,e){var r=t.i.get(e);if(void 0!==r&&(t.i.delete(e),e=performance.now()-r,++t.h.D,t.h.G+=e,t.h.B=Math.max(t.h.B,e),t.u=Math.max(t.u,e),performance.now()>t.m+3e4)){for(let[n,i]of t.i.entries())e=n,i<r&&(t.h.A++,t.i.delete(e));r={...t.h,I:performance.now()-t.m},t.h.B=0,t.m=performance.now(),Pn(t,r)}}function Ln(t){var e=new cn;if(e=ie(e=ne(e=ae(e,1,10),7,t.A),5,t.B),e=ie(e,6,t.I),t.D>0&&ie(e,4,t.G/t.D),0!==t.C){var r=ln(3);re(e,r=ne(r,2,t.C))}return 0!==t.F&&re(e,t=ne(r=ln(4),2,t.F)),e}function zn(t){var e={...t.h,A:t.h.A+t.i.size,B:t.u,I:performance.now()-t.P};Pn(t,e);var r=new dn;r=Qt(r,2,e=Ln(e)),kn(t,r=te(e=mn(yn(new vn,t.v),2),5,r))}var Gn=class{constructor(t,e){this.P=performance.now(),this.m=performance.now(),this.i=new Map,this.u=0,this.h=new Un,this.j=new Un,this.H=new Fn(e),this.v=function(t){switch(t){case"AudioClassifier":return 4;case"AudioEmbedder":return 5;case"TextClassifier":return 6;case"TextEmbedder":return 7;case"GestureRecognizer":return 8;case"HandDetector":return 9;case"HandLandmarker":return 10;case"ImageClassifier":return 11;case"ImageEmbedder":return 12;case"ImageSegmenter":return 13;case"ObjectDetector":return 14;case"FaceDetector":return 15;case"FaceLandmarker":return 16;case"InteractiveSegmenter":case"InteractiveSegmenterLegacy":return 18;case"HolisticLandmarker":return 20;case"LlmInference":return 21;case"LanguageDetector":return 22;case"PoseLandmarker":return 23;case"UniversalEmbedder":return 28;case"SemanticRetriever":return 29;case"DecisionMaker":return 30;default:return 0}}(t),t=new wn,"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=oe(t=ae(t,1,e),2,""),t=oe(t,3,""),t=oe(t,4,"1.1.0"),t=oe(t,5,""),this.R=ae(t,6,4)}close(){var t=this.H;"function"==typeof t.close?t.close():t.flush()}};function $n(t){var e=atob("QUl6YVN5QS1XbGdRNjczMWpZSThjWGhKNEFxZjhuX3J1UmNLMzJZ");return new Gn(t,e)}async function Hn(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())}}}var Wn=async(t,e,r,n)=>{if(e&&await Hn(e),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(r&&(await Hn(r),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&n&&((e=self.Module).locateFile=n.locateFile,n.mainScriptUrlOrBlob&&(e.mainScriptUrlOrBlob=n.mainScriptUrlOrBlob)),n=await self.ModuleFactory(self.Module||n),self.ModuleFactory=self.Module=void 0,new t(n,null)},Jn={CHARACTER:0,WORD:1};function qn(t,e){if(t<=0)throw Error("Chunk size must be positive.");if(e<0||e>=t)throw Error("Chunk overlap must be non-negative and less than chunk size.")}function Vn(t,e,r,n="CHARACTER"){qn(e,r),t.j=e,t.i=r,t.mode=n}var Kn=class{constructor(t){this.j=512,this.i=100,this.mode="CHARACTER",this.h=t}chunk(t){if(!t||0===t.trim().length)return[];if(!this.h||"function"!=typeof this.h.defaultTextChunker_nativeChunkText)throw Error("DefaultTextChunker Wasm module is not initialized.");return(t=this.h.defaultTextChunker_nativeChunkText(t,this.j,this.i,Jn[this.mode]??0))?Array.from(t):[]}};function Xn(t){return{...t,content:t.content?t.content.map(t=>"imageBytes"in t?{...t,imageBytes:new Uint8Array(t.imageBytes)}:"audioData"in t?{...t,audioData:new Float32Array(t.audioData)}:{...t}):[],embeddings:t.embeddings?new Float32Array(t.embeddings):new Float32Array(0),metadata:t.metadata?{...t.metadata}:{},...t.childIds?{childIds:[...t.childIds]}:{}}}Kn.prototype.chunk=Kn.prototype.chunk,Kn.createFromModule=function(t,e=512,r=100,n="CHARACTER"){return qn(e,r),Vn(t=new Kn(t),e,r,n),t},Kn.create=async function(t,e=512,r=100,n="CHARACTER"){qn(e,r);var i=await Wn(Kn,t.wasmLoaderPath,t.assetLoaderPath,{locateFile:e=>e.endsWith(".wasm")?t.wasmBinaryPath.toString():e});return Vn(i,e,r,n),i};var Zn=class{constructor(){this.h=new Map}upsert(t){for(let e of t)this.h.set(e.id,Xn(e))}delete(t){var e=new Set(t);for(let r of t)if(t=this.h.get(r),t?.childIds)for(let r of t.childIds)e.add(r);for(let t of e)this.h.delete(t)}deleteByMetadata(t){var e=Object.keys(t);if(0!==e.length){var r=[];for(let n of this.h.values())n.parentId||n.metadata&&e.every(e=>n.metadata[e]===t[e])&&r.push(n.id);r.length>0&&this.delete(r)}}search(t,e,r){if(e<=0)throw Error(`'topK' must be greater than 0, got ${e}.`);var n=r?Object.keys(r):[];t=Array.from(t);var i=[];for(let e of this.h.values()){if(r&&n.length>0){if(!e.metadata)continue;if(!n.every(t=>e.metadata?.[t]===r[t]))continue}if(e.embeddings&&0!==e.embeddings.length)try{let r=Zr({floatEmbedding:t,headIndex:0,headName:""},{floatEmbedding:Array.from(e.embeddings),headIndex:0,headName:""});i.push({da:e,score:r})}catch{}}return i.sort((t,e)=>e.score-t.score),i.slice(0,e).map(t=>Xn(t.da))}get(t){var e=[];for(let r of t)(t=this.h.get(r))&&e.push(Xn(t));return e}getAllRecordIds(){var t=[];for(let[e,r]of this.h.entries()){let n=e;r.parentId||t.push(n)}return t}deleteAll(){this.h.clear()}close(){this.h.clear()}};Zn.prototype.close=Zn.prototype.close,Zn.prototype.deleteAll=Zn.prototype.deleteAll,Zn.prototype.getAllRecordIds=Zn.prototype.getAllRecordIds,Zn.prototype.get=Zn.prototype.get,Zn.prototype.search=Zn.prototype.search,Zn.prototype.deleteByMetadata=Zn.prototype.deleteByMetadata,Zn.prototype.delete=Zn.prototype.delete,Zn.prototype.upsert=Zn.prototype.upsert;var Yn=class{constructor(){this.h=[]}S(t){return this.h.push(t),this}M(){return[...this.h]}ia(t){return this.j=t,this}o(){return this.j}ha(t){return this.i=t,this}L(){return this.i}};function Qn(t){if(t.i)throw Error("SemanticRetriever has already been closed.")}Yn.prototype.textChunker=Yn.prototype.L,Yn.prototype.setTextChunker=Yn.prototype.ha,Yn.prototype.vectorStore=Yn.prototype.o,Yn.prototype.setVectorStore=Yn.prototype.ia,Yn.prototype.providers=Yn.prototype.M,Yn.prototype.addProvider=Yn.prototype.S;var ti=class{constructor(t,e,r){this.m=t,this.o=e,this.L=r,this.i=!1,this.j=0,this.h=$n("SemanticRetriever"),Mn(this.h)}async embedContent(t){for(let e of this.m.M()){let r=await e.embedContent(t);if(null!=r)return r instanceof Float32Array?r:new Float32Array(r)}throw Error("No embedding provider found that can embed this content.")}async Z(t,e,r){return Qn(this),this.K(t,[{text:e}],r)}async K(t,e,r){Qn(this),await this.o.delete([t]);var n=[],i=0;if(1===e.length&&"text"in e[0]&&"string"==typeof e[0].text){var o=await this.L.chunk(e[0].text);if(o.length>1){let r=[];for(let e of o)o=`${t}_chunk_${i++}`,r.push(o),n.push({id:o,J:[{text:e}],parentId:t});n.push({id:t,J:e,childIds:r})}else n.push({id:t,J:e})}else n.push({id:t,J:e});t=[];for(let e of n)n=void 0!==e.childIds&&e.childIds.length>0?new Float32Array(0):await this.embedContent(e.J),t.push({id:e.id,content:[...e.J],embeddings:n,metadata:r||{},parentId:e.parentId,childIds:e.childIds});await this.o.upsert(t)}async aa(t,e,r){return Qn(this),this.K(t,[{imageBytes:e}],r)}async Y(t,e,r){return Qn(this),this.K(t,[{audioData:e}],r)}async ga(t,e={}){Qn(this);var{limit:r=5,metadataFilter:n}=e;if(r<=0)throw Error(`'limit' must be greater than 0, got ${r}.`);e=this.j++;var i=this.h;++i.h.C,i.i.set(e,performance.now()),t=await this.embedContent("string"==typeof t?[{text:t}]:t),i=await this.o.search(t,3*r,n);var o=new Set;for(var a of i)a.parentId&&o.add(a.parentId);if(a=new Map,o.size>0)for(var s of o=await this.o.get(Array.from(o)))a.set(s.id,s);for(var u of(s=[],o=new Set,i))u.parentId?o.has(u.parentId)||(o.add(u.parentId),(i=a.get(u.parentId))&&s.push({id:i.id,content:i.content,embeddings:u.embeddings,metadata:i.metadata,parentId:i.parentId,childIds:i.childIds})):o.has(u.id)||(o.add(u.id),s.push(u));u=[],t=Array.from(t);for(let e of s){if(s=0,e.embeddings&&e.embeddings.length>0)try{s=Zr({floatEmbedding:t,headIndex:0,headName:""},{floatEmbedding:Array.from(e.embeddings),headIndex:0,headName:""})}catch{s=0}if(u.push({id:e.id,content:e.content?[...e.content]:[],metadata:e.metadata?{...e.metadata}:{},score:s}),u.length>=r)break}return Dn(this.h,e),u}async delete(t){Qn(this),"string"==typeof t?await this.o.delete([t]):Array.isArray(t)?await this.o.delete(t):await this.o.deleteByMetadata(t)}async getAllRecordIds(){Qn(this);var t=await this.o.getAllRecordIds();return Array.from(new Set(t))}async deleteAll(){Qn(this),await this.o.deleteAll()}close(){if(!this.i){this.i=!0,zn(this.h),this.h.close();try{this.o.close()}catch{}}}};async function ei(t,e){var r=e.baseOptions.device;r||=await ri();var n=await Wn(oi,t.wasmLoaderPath,t.assetLoaderPath,{locateFile:e=>e.endsWith(".wasm")?t.wasmBinaryPath.toString():e});return r&&(n.h.preinitializedWebGPUDevice=r),await async function(t,e,r){t.i=$n("UniversalEmbedder");var n=!1!==e.l2Normalize,i=e.baseOptions.modelAssetPath?e.baseOptions.modelAssetPath.toString():"";if((r=r||e.baseOptions.device||t.h.preinitializedWebGPUDevice)||(r=await ri()),t.h.preinitializedWebGPUDevice=r,e.baseOptions.modelAssetBuffer){i=e.baseOptions.modelAssetBuffer instanceof Uint8Array?e.baseOptions.modelAssetBuffer:await async function(t){for(var e=[],r=0;;){let{done:n,value:i}=await t.read();if(n)break;e.push(i),r+=i.length}if(0===e.length)return new Uint8Array(0);if(1===e.length)return e[0];t=new Uint8Array(r),r=0;for(let n of e)t.set(n,r),r+=n.length;return t}(e.baseOptions.modelAssetBuffer);var o=`/${r=`universal_embedder_model_${++ai}.litertlm`}`;try{t.h.FS_unlink?.(o)}catch{}t.h.FS_createDataFile("/",r,i,!0,!1,!1),t.v=o,i=t.v}if(!i)throw Error("No model asset path or buffer provided.");r=e.maxInputLength??0,o=e.visionTokensPerImage??0,e=function(t){if(void 0===t)return 0;switch(t){case"FLOAT32":return 1;case"FLOAT16":return 2;case"INT16":return 3;case"INT8":return 4;default:throw Error(`Unsupported activation data type: ${t}`)}}(e.activationDataType);try{t.j=await t.h.createUniversalEmbedder(i,n,r,o,e),Mn(t.i)}catch(e){throw ni(t),e}}(n,e,r),n}async function ri(){if("undefined"==typeof navigator||!navigator.gpu)throw Error("WebGPU is not supported on this platform.");var t=await navigator.gpu.requestAdapter({powerPreference:"high-performance"});if(!t)throw Error("No appropriate WebGPU adapter found.");var e=[];if(t.features.has("subgroups")&&e.push("subgroups"),t.features.has("shader-f16")&&e.push("shader-f16"),!(e=await t.requestDevice({requiredFeatures:e})).adapterInfo&&t.info)try{Object.defineProperty(e,"adapterInfo",{value:t.info,writable:!0,configurable:!0})}catch{}return e}function ni(t){if(t.v){try{t.h.FS_unlink?.(t.v)}catch{}t.v=void 0}}function ii(t){if(t.H||0===t.j)throw Error("UniversalEmbedder has already been closed.")}ti.prototype.close=ti.prototype.close,ti.prototype.deleteAll=ti.prototype.deleteAll,ti.prototype.getAllRecordIds=ti.prototype.getAllRecordIds,ti.prototype.delete=ti.prototype.delete,ti.prototype.retrieve=ti.prototype.ga,ti.prototype.insertAudio=ti.prototype.Y,ti.prototype.insertImage=ti.prototype.aa,ti.prototype.insertContent=ti.prototype.K,ti.prototype.insertDocument=ti.prototype.Z,ti.createFromComponents=async function(t){if(!t||0===t.M().length)throw Error("At least one EmbeddingProvider must be registered in SemanticRetrieverComponents.");var e=t.o();if(!e)throw Error("VectorStore must be provided in SemanticRetrieverComponents.");var r=t.L();if(!r)throw Error("TextChunker must be provided in SemanticRetrieverComponents.");return new ti(t,e,r)};var oi=class{constructor(t){this.H=!1,this.j=0,this.u=new nn,this.m=0,this.h=t}async V(t){return en(this.u,async()=>{ii(this);var e=this.m++;Rn(this.i,e);var r=await this.h.universalEmbedder_embedText(this.j,t);return Dn(this.i,e),{embeddings:[{floatEmbedding:r?Array.from(r):[],headIndex:0,headName:"default"}]}})}async U(t){return en(this.u,async()=>{ii(this);var e=this.m++;Rn(this.i,e);var r=await this.h.universalEmbedder_embedImage(this.j,t);return Dn(this.i,e),{embeddings:[{floatEmbedding:r?Array.from(r):[],headIndex:0,headName:"default"}]}})}async T(t){return en(this.u,async()=>{ii(this);var e=this.m++;Rn(this.i,e);var r=await this.h.universalEmbedder_embedAudio(this.j,t);return Dn(this.i,e),{embeddings:[{floatEmbedding:r?Array.from(r):[],headIndex:0,headName:"default"}]}})}async embedContent(t){if(ii(this),!Array.isArray(t))throw Error("Content must be an array of ContentParts.");return en(this.u,async()=>{ii(this);var e=this.h.universalEmbedder_createContentBuilder();try{for(let r of t)if("text"in r&&"string"==typeof r.text)this.h.universalEmbedder_builderAddText(e,r.text);else if("imageBytes"in r&&(r.imageBytes instanceof Uint8Array||"string"==typeof r.imageBytes))this.h.universalEmbedder_builderAddImage(e,r.imageBytes);else{if(!("audioData"in r)||!(r.audioData instanceof Float32Array||Array.isArray(r.audioData)))throw Error(`Unsupported or invalid ContentPart: ${JSON.stringify(r)}`);this.h.universalEmbedder_builderAddAudio(e,r.audioData)}let r=this.m++;Rn(this.i,r);let n=await this.h.universalEmbedder_executeEmbedContent(this.j,e);return Dn(this.i,r),{embeddings:[{floatEmbedding:n?Array.from(n):[],headIndex:0,headName:"default"}]}}finally{this.h.universalEmbedder_freeContentBuilder(e)}})}X(){return{embedContent:async t=>(await this.embedContent(t))?.embeddings?.[0]?.floatEmbedding??null}}close(){this.H||(this.H=!0,zn(this.i),this.i.close(),0!==this.j&&(this.h.universalEmbedder_close(this.j),this.j=0),ni(this))}};oi.prototype.close=oi.prototype.close,oi.prototype.getProvider=oi.prototype.X,oi.cosineSimilarity=function(t,e){return Zr(t,e)},oi.prototype.embedContent=oi.prototype.embedContent,oi.prototype.embedAudio=oi.prototype.T,oi.prototype.embedImage=oi.prototype.U,oi.prototype.embedText=oi.prototype.V,oi.createFromModelPath=function(t,e){return ei(t,{baseOptions:{modelAssetPath:e.toString()}})},oi.createFromModelBuffer=function(t,e){return ei(t,{baseOptions:{modelAssetBuffer:e}})},oi.createWebGpuDevice=ri,oi.createFromOptions=ei;var ai=0;exports.DefaultTextChunker=Kn,exports.FilesetResolver=un,exports.MemoryVectorStore=Zn,exports.SemanticRetriever=ti,exports.SemanticRetrieverComponents=Yn,exports.UniversalEmbedder=oi;
|
|
1
|
+
"use strict";var t="undefined"!=typeof self?self:{};function e(e,r){t:{for(var n=["CLOSURE_FLAGS"],i=t,o=0;o<n.length;o++)if(null==(i=i[n[o]])){n=null;break t}n=i}return null!=(e=n&&n[e])?e:r}var r,n="undefined"!=typeof TextEncoder;function i(t){if(n)t=(r||=new TextEncoder).encode(t);else{let r=0,n=new Uint8Array(3*t.length);for(let i=0;i<t.length;i++){var e=t.charCodeAt(i);if(e<128)n[r++]=e;else{if(e<2048)n[r++]=e>>6|192;else{if(e>=55296&&e<=57343){if(e<=56319&&i<t.length){let o=t.charCodeAt(++i);if(o>=56320&&o<=57343){e=1024*(e-55296)+o-56320+65536,n[r++]=e>>18|240,n[r++]=e>>12&63|128,n[r++]=e>>6&63|128,n[r++]=63&e|128;continue}i--}e=65533}n[r++]=e>>12|224,n[r++]=e>>6&63|128}n[r++]=63&e|128}}t=r===n.length?n:n.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 u,l=t.navigator;u=l&&l.userAgentData||null;var f={},c=null;function h(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 n=new Uint8Array(r),i=0;return function(t,e){function r(e){for(;n<t.length;){let e=t.charAt(n++),r=c[e];if(null!=r)return r;if(!/^[\s\xa0]*$/.test(e))throw Error("Unknown base64 encoding at char: "+e)}return e}d();for(var n=0;;){let t=r(-1),n=r(0),i=r(64),o=r(64);if(64===o&&-1===t)break;e(t<<2|n>>4),64!=i&&(e(n<<4&240|i>>2),64!=o&&e(i<<6&192|o))}}(t,function(t){n[i++]=t}),i!==r?n.subarray(0,i):n}function d(){if(!c){c={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){let n=t.concat(e[r].split(""));f[r]=n;for(let t=0;t<n.length;t++){let e=n[t];void 0===c[e]&&(c[e]=t)}}}}var p="undefined"!=typeof Uint8Array,y=!(!(!!o&&(!!u&&u.brands.length>0))&&(-1!=s().indexOf("Trident")||-1!=s().indexOf("MSIE")))&&"function"==typeof btoa,m=/[-_.]/g,g={"-":"+",_:"/",".":"="};function v(t){return g[t]||""}function b(t){if(!y)return h(t);t=m.test(t)?t.replace(m,v):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,A={},I=class{constructor(t,e){if(E(e),this.h=t,null!=t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}};function E(t){if(t!==A)throw Error("illegal external caller")}function S(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}var x=void 0;function B(t){return S(t=Error(t),"warning"),t}function N(e,r){if(null!=e){var n=x??={},i=n[e]||0;i>=r||(n[e]=i+1,S(e=Error(),"incident"),function(e){t.setTimeout(()=>{throw e},0)}(e))}}function C(){return"function"==typeof BigInt}var _="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 T,O=j("jas",void 0,!0),F=j(void 0,"1oa"),U=j(void 0,"0ubsb"),k=j(void 0,"0actk"),M=j("m_m","ma",!0),R={ba:{value:0,configurable:!0,writable:!0,enumerable:!1}},P=Object.defineProperties,D=_?O:"ba",L=[];function z(t,e){_||D in t||P(t,R),t[D]|=e}function G(t,e){_||D in t||P(t,R),t[D]=e}G(L,7),T=Object.freeze(L);var $={};function H(t,e){return void 0===e?t.h!==W&&!!(2&t.l[D]):!!(2&e)&&t.h!==W}var W={};function J(t){return t.la=!0,t}var q=J(t=>"number"==typeof t),V=J(t=>"string"==typeof t),K=J(t=>"boolean"==typeof t),X="function"==typeof t.BigInt&&"bigint"==typeof t.BigInt(0);function Z(t){var e=t;if(V(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 X?BigInt(t):t=K(t)?t?"1":"0":V(t)?t.trim()||"0":String(t)}var Y=J(t=>X?t>=tt&&t<=rt:"-"===t[0]?nt(t,Q):nt(t,et)),Q=Number.MIN_SAFE_INTEGER.toString(),tt=X?BigInt(Number.MIN_SAFE_INTEGER):void 0,et=Number.MAX_SAFE_INTEGER.toString(),rt=X?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 n=t[r],i=e[r];if(n>i)return!1;if(n<i)return!0}}var it,ot=0,at=0;function st(t){var e=t>>>0;ot=e,at=(t-e)/4294967296>>>0}function ut(t){if(t<0){st(-t);let[e,r]=pt(ot,at);ot=e>>>0,at=r>>>0}else st(t)}function lt(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 C()?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+ct(r)+ct(t));return r}function ct(t){return t=String(t),"0000000".slice(t.length)+t}function ht(){var t=ot,e=at;if(2147483648&e)if(C())t=""+(BigInt(0|e)<<BigInt(32)|BigInt(t>>>0));else{let[r,n]=pt(t,e);t="-"+ft(r,n)}else t=ft(t,e);return t}function dt(t){if(t.length<16)ut(Number(t));else if(C())t=BigInt(t),ot=Number(t&BigInt(4294967295))>>>0,at=Number(t>>BigInt(32)&BigInt(4294967295));else{let e=+("-"===t[0]);at=ot=0;let r=t.length;for(let n=e,i=(r-e)%6+e;i<=r;n=i,i+=6){let e=Number(t.slice(n,i));at*=1e6,(ot=1e6*ot+e)>=4294967296&&(at+=Math.trunc(ot/4294967296),at>>>=0,ot>>>=0)}if(e){let[t,e]=pt(ot,at);ot=t,at=e}}}function pt(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}var yt="function"==typeof BigInt?BigInt.asIntN:void 0,mt="function"==typeof BigInt?BigInt.asUintN:void 0,gt=Number.isSafeInteger,vt=Number.isFinite,bt=Math.trunc;function wt(t){return null==t||"number"==typeof t?t:"NaN"===t||"Infinity"===t||"-Infinity"===t?Number(t):void 0}var At,It,Et,St=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function xt(t){switch(typeof t){case"bigint":return!0;case"number":return vt(t);case"string":return St.test(t);default:return!1}}function Bt(t){if(null==t)return t;if("string"==typeof t&&t)t=+t;else if("number"!=typeof t)return;return vt(t)?0|t:void 0}function Nt(t){var e=t.length;return("-"===t[0]?e<20||20===e&&t<="-9223372036854775808":e<19||19===e&&t<="9223372036854775807")?t:(dt(t),ht())}function Ct(t){if("-"===t[0])var e=!1;else e=(e=t.length)<20||20===e&&t<="18446744073709551615";return e?t:(dt(t),ft(ot,at))}function _t(t){if(t=bt(t),!gt(t)){ut(t);var e=ot,r=at;(t=2147483648&r)&&(r=~r>>>0,0==(e=1+~e>>>0)&&(r=r+1>>>0)),t="number"==typeof(e=lt(e,r))?t?-e:e:t?"-"+e:e}return t}function jt(t){return(t=bt(t))>=0&>(t)||(ut(t),t=lt(ot,at)),t}function Tt(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(yt(64,t));if(xt(t)){if("string"===e)return e=bt(Number(t)),gt(e)?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=Nt(t)),t;if("number"===e)return _t(t)}}function Ot(t){if(null==t||"string"==typeof t||t instanceof I)return t}function Ft(t){return null==t||"string"==typeof t?t:void 0}function Ut(t){return t}function kt(t,e,r,n){var i=void 0!==n;n=!!n;var o=[],a=t.length,s=4294967295,u=!1,l=!!(64&e),f=l?128&e?0:-1:void 0;if(!(1&e)){var c=a&&t[a-1];null!=c&&"object"==typeof c&&c.constructor===Object?s=--a:c=void 0,!l||128&e||i||(u=!0,s=(At??Ut)(s-f,f,t,c,void 0)+f)}for(e=void 0,i=0;i<a;i++){let a=t[i];if(null!=a&&null!=(a=r(a,n)))if(l&&i>=s){let t=i-f;(e??={})[t]=a}else o[i]=a}if(c)for(let i in c){if(null==(t=c[i])||null==(t=r(t,n)))continue;let u;a=+i,l&&!Number.isNaN(a)&&(u=a+f)<s?o[u]=t:(e??={})[i]=t}return e&&(u?o.push(e):o[s]=e),o}function Mt(t){switch(typeof t){case"number":return Number.isFinite(t)?t:""+t;case"bigint":return Y(t)?Number(t):""+t;case"boolean":return t?1:0;case"object":if(Array.isArray(t)){var e=0|t[D];return 0===t.length&&1&e?void 0:kt(t,e,Mt)}if(null!=t&&t[M]===$)return Rt(t);if(t instanceof I){if(null==(e=t.h))t="";else if("string"==typeof e)t=e;else{if(y){for(var r="",n=0,i=e.length-10240;n<i;)r+=String.fromCharCode.apply(null,e.subarray(n,n+=10240));r+=String.fromCharCode.apply(null,n?e.subarray(n):e),e=btoa(r)}else{void 0===r&&(r=0),d(),r=f[r],n=Array(Math.floor(e.length/3)),i=r[64]||"";let t=0,l=0;for(;t<e.length-2;t+=3){var o=e[t],a=e[t+1],s=e[t+2],u=r[o>>2];o=r[(3&o)<<4|a>>4],a=r[(15&a)<<2|s>>6],s=r[63&s],n[l++]=u+o+a+s}switch(u=0,s=i,e.length-t){case 2:s=r[(15&(u=e[t+1]))<<2]||i;case 1:e=e[t],n[l]=r[e>>2]+r[(3&e)<<4|u>>4]+s+i}e=n.join("")}t=t.h=e}return t}return}return t}function Rt(t){return kt(t=t.l,0|t[D],Mt)}function Pt(t,e,r,n=0){if(null==t){var i=32;r?(t=[r],i|=128):t=[],e&&(i=-16760833&i|(1023&e)<<14)}else{if(!Array.isArray(t))throw Error("narr");if(i=0|t[D],a&&1&i)throw Error("rfarr");if(2048&i&&!(2&i)&&function(){if(a)throw Error("carr");N(k,5)}(),256&i)throw Error("farr");if(64&i)return(i|n)!==i&&G(t,i|n),t;if(r&&(i|=128,r!==t[0]))throw Error("mid");t:{i|=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&i?0:-1)>=1024)throw Error("pvtlmt");for(var u in t)(o=+u)<s&&(r[o+e]=t[u],delete t[u]);i=-16760833&i|(1023&s)<<14;break t}}if(e){if((u=Math.max(e,o-(128&i?0:-1)))>1024)throw Error("spvt");i=-16760833&i|(1023&u)<<14}}}return G(t,64|i|n),t}function Dt(t,e){if("object"!=typeof t)return t;if(Array.isArray(t)){var r=0|t[D];return 0===t.length&&1&r?t=void 0:2&r||(!e||4096&r||16&r?t=Lt(t,r,!1,e&&!(16&r)):(z(t,34),4&r&&Object.freeze(t))),t}if(null!=t&&t[M]===$){let n=0|(r=t.l)[D];return H(t,n)||(2&n?e=!0:32&n&&!(4096&n)?(G(r,2|n),t.h=W,e=!0):e=!1,e?(t=new t.constructor(r)).j=W:t=Lt(r,n)),t}return t instanceof I?t:void 0}function Lt(t,e,r,n){return n??=!!(34&e),t=kt(t,e,Dt,n),n=32,r&&(n|=2),G(t,e=16769217&e|n),t}function zt(t){if(t.h!==W)return!1;var e=t.l;return z(e=Lt(e,0|e[D]),2048),t.l=e,t.h=void 0,t.j=void 0,!0}function Gt(t){if(!zt(t)&&H(t,0|t.l[D]))throw Error()}function $t(t,e){void 0===e&&(e=0|t[D]),32&e&&!(4096&e)&&G(t,4096|e)}function Ht(t,e,r){if(-1===e)return null;var n=e+(r?0:-1),i=t.length-1;if(!(i<1+(r?0:-1))){if(n>=i)if(null!=(t=t[i])&&"object"==typeof t&&t.constructor===Object)e=t[e];else{if(n!==i)return;e=t}else e=t[n];return e}}function Wt(t,e,r){Gt(t);var n=t.l;return Jt(n,0|n[D],e,r),t}function Jt(t,e,r,n,i){var o=r+(i?0:-1),a=t.length-1;if(a>=1+(i?0:-1)&&o>=a){let i=t[a];if(null!=i&&"object"==typeof i&&i.constructor===Object)return i[r]=n,e}return o<=a?(t[o]=n,e):(void 0!==n&&(r>=(a=(e??=0|t[D])>>14&1023||536870912)?null!=n&&(t[a+(i?0:-1)]={[r]:n}):t[o]=n),e)}function qt(t,e,r){return t=Ht(t,e,r),Array.isArray(t)?t:T}function Vt(t,e){return 2&e&&(t|=2),1|t}function Kt(t){return!!(2&t)&&!!(4&t)||!!(256&t)}function Xt(t){if(_)return t[F]??(t[F]=new Map);if(F in t)return t[F];var e=new Map;return Object.defineProperty(t,F,{value:e}),e}function Zt(t,e,r,n){var i=t.get(n);if(null!=i)return i;i=0;for(let t=0;t<n.length;t++){let o=n[t];null!=Ht(e,o)&&(0!==i&&(r=Jt(e,r,i)),i=o)}return t.set(n,i),i}function Yt(t){return null==t&&(t=void 0),t}function Qt(t,e,r){return Wt(t,e,r=Yt(r)),r&&!H(r)&&$t(t.l),t}function te(t,e,r){var n=bn;t:{var i=r=Yt(r);Gt(t);let s=t.l;var o=0|s[D];if(null==i){var a=Xt(s);if(Zt(a,s,o,n)!==e)break t;a.set(n,0)}else{let t=Xt(a=s),r=Zt(t,a,o,n);r!==e&&(r&&(o=Jt(a,o,r)),t.set(n,e))}Jt(s,o,e,i)}return r&&!H(r)&&$t(t.l),t}function ee(t,e){return-273&(2&e?2|t:-3&t)}function re(t,e){var r=fn;Gt(t);var n=t.l,i=n,o=0|n[D],a=H(t,o)?1:2;2===a&&zt(t)&&(o=0|(i=t.l)[D]);var s=qt(i,8),u=s===T?7:0|s[D],l=Vt(u,o);if(t=!(4&l)){var f=o;let t=!!(2&l);t&&(f|=2);let e=!t,n=!0,i=0,a=0;for(;i<s.length;i++){var c=s[i],h=r,d=f;if(null==c||c[M]!==$)if(Array.isArray(c)){let t,e=0|c[D];t=e|32&d,t|=2&d,t!==e&&G(c,t),c=new h(c)}else c=void 0;c instanceof r&&(t||(h=H(c),e&&=!h,n&&=h),s[a++]=c)}a<i&&(s.length=a),l|=4,l=n?-4097&l:4096|l,l=e?8|l:-9&l}l!==u&&(G(s,l),2&l&&Object.freeze(s)),l=u=l,1===a||4===a&&(2&u||!(16&u)&&32&o)?Kt(u)||((u|=!s.length||t&&!(4096&u)||32&o&&!(4096&u||16&u)?2:256)!==l&&G(s,u),Object.freeze(s)):(2===a&&Kt(u)&&(s=Array.prototype.slice.call(s),l=0,u=ee(u,o),o=Jt(i,o,8,s)),Kt(u)||u!==l&&G(s,u)),2&u||!(4096&u||16&u)||$t(i,o),a=s,e=null!=e?e:new r,a.push(e),t=r=a===T?7:0|a[D],(e=H(e))?(r&=-9,1===a.length&&(r&=-4097)):r|=4096,r!==t&&G(a,r),e||$t(n)}function ne(t,e,r){return Wt(t,e,null==r?r:function(t){if(!xt(t))throw B("int64");switch(typeof t){case"string":var e=bt(Number(t));return gt(e)?t=Z(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=C()?Z(yt(64,BigInt(t))):Z(Nt(t))),t;case"bigint":return Z(yt(64,t));default:return gt(t)?t=Z(_t(t)):(t=bt(t),gt(t)?t=String(t):(ut(t),t=ht()),t=Z(t)),t}}(r))}function ie(t,e,r){return Wt(t,e,null==r?r:function(t){if(!xt(t))throw B("uint64");switch(typeof t){case"string":var e=bt(Number(t));return gt(e)&&e>=0?t=Z(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=C()?Z(mt(64,BigInt(t))):Z(Ct(t))),t;case"bigint":return Z(mt(64,t));default:return gt(t)?t=Z(jt(t)):((t=bt(t))>=0&>(t)?t=String(t):(ut(t),t=ft(ot,at)),t=Z(t)),t}}(r))}function oe(t,e,r){if(null!=r&&"string"!=typeof r)throw Error();return Wt(t,e,r)}function ae(t,e,r){if(null!=r){if(!vt(r))throw B("enum");r|=0}return Wt(t,e,r)}var se=class{constructor(t,e,r){if(this.buffer=t,r&&!e)throw Error()}};function ue(t){if("string"==typeof t)return new se(b(t),!0);if(Array.isArray(t))return new se(new Uint8Array(t),!0);if(t.constructor===Uint8Array)return new se(t,!1);if(t.constructor===ArrayBuffer)return t=new Uint8Array(t),new se(t,!1);if(t.constructor===I){E(A);var e=t.h;return e=(null==(e=null==e||p&&null!=e&&e instanceof Uint8Array?e:"string"==typeof e?b(e):null)?e:t.h=e)||new Uint8Array(0),new se(e,!0,t)}if(t instanceof Uint8Array)return t=t.constructor===Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new se(t,!1);throw Error()}function le(t){return new he(4294967295&t,Math.floor(t/4294967296))}function fe(t){return t?/^\d+$/.test(t)?(dt(t),new he(ot,at)):null:ce||=new he(0,0)}var ce,he=class{constructor(t,e){this.i=t>>>0,this.h=e>>>0}};function de(t){return new Ee(4294967295&t,Math.floor(t/4294967296))}function pe(t){return t?/^-?\d+$/.test(t)?(dt(t),new Ee(ot,at)):null:ye||=new Ee(0,0)}var ye,me,ge,ve,be,we,Ae,Ie,Ee=class{constructor(t,e){this.i=t>>>0,this.h=e>>>0}};function Se(t,e,r){return"undefined"!=typeof BigInt64Array?(Ae||(Ae=new BigInt64Array(1),Ie=new Uint32Array(Ae.buffer),Ae[0]=BigInt(1),we=1===Ie[0]),Ae[0]=t,new e(Ie[t=we?0:1],Ie[1-t])):(be||(me=BigInt(Number.MIN_SAFE_INTEGER),ge=BigInt(Number.MAX_SAFE_INTEGER),ve=BigInt(4294967295),be=BigInt(32)),t>=me&&t<=ge?r(Number(t)):(t=BigInt.asUintN(64,t),new e(Number(t&ve),Number(t>>be))))}function xe(t,e,r){for(;r>0||e>127;)t.h.push(127&e|128),e=(e>>>7|r<<25)>>>0,r>>>=7;t.h.push(e)}function Be(t,e){for(;e>127;)t.h.push(127&e|128),e>>>=7;t.h.push(e)}function Ne(t,e){if(e>=0)Be(t,e);else{for(let r=0;r<9;r++)t.h.push(127&e|128),e>>=7;t.h.push(1)}}function Ce(t,e){dt(e),function(t){var e=at>>31;t(ot<<1^e,(at<<1|ot>>>31)^e)}((e,r)=>{xe(t,e>>>0,r>>>0)})}function _e(t,e){t.h.push(e>>>0&255),t.h.push(e>>>8&255),t.h.push(e>>>16&255),t.h.push(e>>>24&255)}var je=class{constructor(){this.h=[]}length(){return this.h.length}end(){var t=this.h;return this.h=[],t}};function Te(t,e){0!==e.length&&(t.j.push(e),t.i+=e.length)}function Oe(t,e,r){Be(t.h,8*e+r)}function Fe(t,e){return Oe(t,e,2),e=t.h.end(),Te(t,e),e.push(t.i),e}function Ue(t,e){var r=e.pop();for(r=t.i+t.h.length()-r;r>127;)e.push(127&r|128),r>>>=7,t.i++;e.push(r),t.i++}function ke(t,e,r){if(null!=r)switch(Oe(t,e,0),typeof r){case"number":t=t.h,ut(r),xe(t,ot,at);break;case"bigint":r=Se(r,Ee,de),xe(t.h,r.i,r.h);break;default:r=pe(r),xe(t.h,r.i,r.h)}}function Me(t,e,r){Oe(t,e,2),Be(t.h,r.length),Te(t,t.h.end()),Te(t,r)}var Re=class{constructor(){this.j=[],this.i=0,this.h=new je}};function Pe(t){if("string"==typeof t)pe(t)}function De(){var t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var Le=De(),ze=De(),Ge=De(),$e=De(),He=De(),We=De(),Je=De(),qe=De(),Ve=De(),Ke=De(),Xe=De(),Ze=De(),Ye=class{constructor(t,e){this.l=Pt(t,e,void 0,2048)}toJSON(){return Rt(this)}};Ye.prototype[M]=$,Ye.prototype.toString=function(){return this.l.toString()};var Qe=class{constructor(t,e){this.h=t,t=Le,this.i=!!t&&e===t||!1}};function tr(t,e,r,n,i){null!=(e=ur(e,n))&&(r=Fe(t,r),i(e,t),Ue(t,r))}var er,rr,nr=new Qe(tr,Le),ir=new Qe(tr,Le),or=Symbol(),ar=Symbol();function sr(t){var e=lr,r=fr,n=t[or];if(n)return n;(n={}).ja=t,n.O=function(t){switch(typeof t){case"boolean":return It||=[0,void 0,!0];case"number":return t>0?void 0:0===t?Et||=[0,void 0]:[-t,void 0];case"string":return[0,t];case"object":return t}}(t[0]);var i=t[1],o=1;i&&i.constructor===Object&&(n.W=i,"function"==typeof(i=t[++o])&&(n.ca=!0,er??=i,rr??=t[o+1],i=t[o+=2]));for(var a={};i&&Array.isArray(i)&&i.length&&"number"==typeof i[0]&&i[0]>0;){for(var s=0;s<i.length;s++)a[i[s]]=i;i=t[++o]}for(s=1;void 0!==i;){let f;"number"==typeof i&&(s+=i,i=t[++o]);var u=void 0;if(i instanceof Qe?f=i:(f=nr,o--),f?.i){i=t[++o],u=t;var l=o;"function"==typeof i&&(i=i(),u[l]=i),u=i}for(l=s+1,"number"==typeof(i=t[++o])&&i<0&&(l-=i,i=t[++o]);s<l;s++){let t=a[s];u?r(n,s,f,u,t):e(n,s,f,t)}}return t[or]=n}function ur(t,e){return t instanceof Ye?t.l:Array.isArray(t)?Pt(t,e[0],e[1]):void 0}function lr(t,e,r){t[e]=r.h}function fr(t,e,r,n){var i,o,a=r.h;t[e]=(t,e,r)=>a(t,e,r,o||=sr(n).O,i||=cr(n))}function cr(t){var e=t[ar];if(!e){let r=sr(t);e=(t,e)=>hr(t,e,r),t[ar]=e}return e}function hr(t,e,r){!function(t,e,r){var n,i=128&e?0:-1,o=t.length;(n=!!o)&&(n=null!=(n=t[o-1])&&"object"==typeof n&&n.constructor===Object);var a=o+(n?-1:0);for(e=128&e?1:0;e<a;e++)r(e-i,t[e]);if(n){t=t[o-1];for(let e in t)!isNaN(e)&&r(+e,t[e])}}(t,0|t[D],(t,n)=>{if(null!=n){var i=function(t,e){var r=t[e];if(r)return r;if((r=t.W)&&(r=r[e])){var n=(r=Array.isArray(r)?r[0]instanceof Qe?r:[ir,r]:[r,void 0])[0].h;if(r=r[1]){let e=cr(r),i=sr(r).O;r=t.ca?rr(i,e):(t,r,o)=>n(t,r,o,i,e)}else r=n;return t[e]=r}}(r,t);i?i(e,n,t):t<500||N(U,3)}})}function dr(t,e,r){if(Array.isArray(e)){var n=0|e[D];if(4&n)return e;for(var i=0,o=0;i<e.length;i++){let r=t(e[i]);null!=r&&(e[o++]=r)}return o<i&&(e.length=o),t=1|n,r&&(t=-1537&t|4),t!==n&&G(e,t),r&&2&t&&Object.freeze(e),e}}var pr=(t,e)=>{var r=new Re;hr(t.l,r,sr(e)),Te(r,r.h.end()),t=new Uint8Array(r.i);var n=(e=r.j).length,i=0;for(let r=0;r<n;r++){let n=e[r];t.set(n,i),i+=n.length}return r.j=[t],t};function yr(t,e){return new Qe(t,e)}function mr(t,e){return new Qe(t,e)}function gr(t,e,r){null!=(e=Tt(e))&&(Pe(e),ke(t,r,e))}function vr(t,e,r){null!=(e=Bt(e))&&null!=e&&(Oe(t,r,0),Ne(t.h,e))}function br(t,e,r){null!=(e=Ft(e))&&Me(t,r,i(e))}function wr(t,e,r,n,i){null!=(e=ur(e,n))&&(r=Fe(t,r),i(e,t),Ue(t,r))}function Ar(t,e,r){null!=(e=Ot(e))&&Me(t,r,ue(e).buffer)}function Ir(t,e,r){null!=(e=Bt(e))&&(e=parseInt(e,10),Oe(t,r,0),Ne(t.h,e))}var Er,Sr=yr(function(t,e,r){null!=(e=wt(e))&&(Oe(t,r,1),t=t.h,(r=it||=new DataView(new ArrayBuffer(8))).setFloat64(0,+e,!0),ot=r.getUint32(0,!0),at=r.getUint32(4,!0),_e(t,ot),_e(t,at))},Ke),xr=yr(function(t,e,r){null!=(e=wt(e))&&(Oe(t,r,5),t=t.h,(r=it||=new DataView(new ArrayBuffer(8))).setFloat32(0,+e,!0),at=0,_e(t,ot=r.getUint32(0,!0)))},Ve),Br=yr(gr,We),Nr=yr(gr,We),Cr=mr(function(t,e,r){if(null!=(e=dr(Tt,e,!1)))for(let n=0;n<e.length;n++)ke(t,r,e[n])},We),_r=yr(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(xt(t)){if("string"===e)return e=bt(Number(t)),gt(e)&&e>=0?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=Ct(t)),t;if("number"===e)return jt(t)}}(e),null!=e){if("string"==typeof e)fe(e);if(null!=e)switch(Oe(t,r,0),typeof e){case"number":t=t.h,ut(e),xe(t,ot,at);break;case"bigint":r=Se(e,he,le),xe(t.h,r.i,r.h);break;default:r=fe(e),xe(t.h,r.i,r.h)}}},Je),jr=yr(vr,$e),Tr=mr(function(t,e,r){if(null!=(e=dr(Bt,e,!0)))for(let a=0;a<e.length;a++){var n=t,i=r,o=e[a];null!=o&&(Oe(n,i,0),Ne(n.h,o))}},$e),Or=mr(function(t,e,r){if(null!=(e=dr(Bt,e,!0))&&e.length){r=Fe(t,r);for(let r=0;r<e.length;r++)Ne(t.h,e[r]);Ue(t,r)}},$e),Fr=yr(function(t,e,r){null!=(e=null==e||"boolean"==typeof e?e:"number"==typeof e?!!e:void 0)&&(Oe(t,r,0),t.h.h.push(e?1:0))},ze),Ur=yr(br,Ge),kr=mr(function(t,e,r){if(null!=(e=dr(Ft,e,!0)))for(let s=0;s<e.length;s++){var n=t,o=r,a=e[s];null!=a&&Me(n,o,i(a))}},Ge),Mr=function(t,e,r=Le){return new Qe(e,r)}(0,function(t,e,r,n,i){if(Array.isArray(e)){for(let o=0;o<e.length;o++)wr(t,e[o],r,n,i);1&(t=0|e[D])||G(e,1|t)}}),Rr=new Qe(wr,Le),Pr=yr(Ar,Xe),Dr=mr(function(t,e,r){if(null!=(e=dr(Ot,e,!1)))for(let a=0;a<e.length;a++){var n=t,i=r,o=e[a];null!=o&&Me(n,i,ue(o).buffer)}},Xe),Lr=yr(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 vt(t)?t>>>0:void 0}(e),null!=e&&null!=e&&(Oe(t,r,0),Be(t.h,e))},He),zr=yr(Ir,Ze),Gr=yr(Ir,Ze),$r=yr(function(t,e,r){if(null!=(e=Tt(e))&&(Pe(e),null!=e))switch(Oe(t,r,0),typeof e){case"number":t=t.h,e=(r=e)<0,st(r=2*Math.abs(r)),r=ot;let n=at;e&&(0==r?0==n?n=r=4294967295:(n--,r=4294967295):r--),xe(t,ot=r,at=n);break;case"bigint":t=t.h,e=e<<BigInt(1)^e>>BigInt(63),ot=Number(BigInt.asUintN(32,e)),at=Number(BigInt.asUintN(32,e>>BigInt(32))),xe(t,ot,at);break;default:Ce(t.h,e)}},qe),Hr=[0,Pr,Dr,Fr,Ur],Wr=[0,yr(br,Ge),[0,Gr,[0,yr(gr,We),yr(vr,$e)],Gr,-1,[0,zr],Gr,-1],yr(Ar,Xe)],Jr=[0,1,[0,12,jr,10,Fr],[0,7,[0,jr,-1]]],qr=globalThis.trustedTypes;var Vr=class{constructor(t){this.h=t}toString(){return this.h+""}};function Kr(t){var e;return void 0===Er&&(Er=function(){var t=null;if(!qr)return t;try{let e=t=>t;t=qr.createPolicy("goog#html",{createHTML:e,createScript:e,createScriptURL:e})}catch(t){}return t}()),t=(e=Er)?e.createScriptURL(t):t,new Vr(t)}function Xr(t,...e){if(0===e.length)return Kr(t[0]);var r=t[0];for(let n=0;n<e.length;n++)r+=encodeURIComponent(e[n])+t[n+1];return Kr(r)}function Zr(t,e){if(t.floatEmbedding&&e.floatEmbedding)return Qr(t.floatEmbedding,e.floatEmbedding);if(t.quantizedEmbedding&&e.quantizedEmbedding)return Qr(Yr(t.quantizedEmbedding),Yr(e.quantizedEmbedding));throw Error("Cannot compute cosine similarity between quantized and float embeddings.")}function Yr(t){return Array.from(t,t=>t>127?t-256:t)}function Qr(t,e){if(t.length!==e.length)throw Error(`Cannot compute cosine similarity between embeddings of different sizes (${t.length} vs. ${e.length}).`);var r=0,n=0,i=0;for(let o=0;o<t.length;o++)r+=t[o]*e[o],n+=t[o]*t[o],i+=e[o]*e[o];if(n<=0||i<=0)throw Error("Cannot compute cosine similarity on embedding with 0 norm.");return r/Math.sqrt(n*i)}function tn(t){!t.h&&t.i.length>0&&(t.h=!0,t.i.shift()())}async function en(t,e){return new Promise((r,n)=>{t.i.push(()=>{e().then(r,n).finally(()=>{t.h=!1,tn(t)})}),tn(t)})}var rn,nn=class{constructor(){this.h=!1,this.i=[]}},on=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 an(t){if(t)return!0;if(void 0===rn)try{await WebAssembly.instantiate(on),rn=!0}catch{rn=!1}return rn}async function sn(t,e,r){return{wasmLoaderPath:`${e}/${t}_${r=`wasm${r?"_module":""}${await an(r)?"":"_nosimd"}_internal`}.js`,wasmBinaryPath:`${e}/${t}_${r}.wasm`}}var un=class{};function ln(t){return ae(new fn,1,t)}un.forVisionTasks=function(t,e=!1){return sn("vision",t??Xr``,e)},un.forLiteRtLmTextTasks=function(t,e=!1){return sn("litertlm_text",t??Xr``,e)},un.forTextTasks=function(t,e=!1){return sn("text",t??Xr``,e)},un.forRetrievalTasks=function(t,e=!1){return sn("retrieval",t??Xr``,e)},un.forGenAiTasks=function(t,e=!1){return sn("genai",t??Xr``,e)},un.forDecisionTasks=function(t,e=!1){return sn("decision",t??Xr``,e)},un.forAudioTasks=function(t,e=!1){return sn("audio",t??Xr``,e)},un.isSimdSupported=function(t=!1){return an(t)};var fn=class extends Ye{constructor(t){super(t)}},cn=class extends Ye{constructor(t){super(t)}},hn=[0,zr,2,_r,-2,Nr,Mr,[0,zr,Nr]],dn=class extends Ye{constructor(t){super(t)}},pn=class extends Ye{constructor(t){super(t)}};function yn(t,e){return ae(t,1,e)}function mn(t,e){return ae(t,2,e)}var gn,vn=class extends Ye{constructor(t){super(t)}},bn=[3,4,5,6,7],wn=class extends Ye{constructor(t){super(t)}},An=class extends Ye{constructor(t){super(t)}};An.prototype.i=(gn=[0,[0,zr,Ur,-3,zr],[0,bn,zr,-1,Rr,[0,zr,Ur,_r],Rr,hn,Rr,[0,1,hn],Rr,[0,zr],Rr,[0,zr,Ur,_r]]],function(){return pr(this,gn)});var In=class{constructor(){this.h="undefined"!=typeof AbortController}async send(t,e,r){var n=this.h?new AbortController:void 0,i=n&&t.N>0?setTimeout(()=>{n.abort()},t.N):void 0;try{let i=await fetch(t.url,{method:t.fa,headers:{...t.ea},...t.body&&{body:t.body},...t.withCredentials&&{credentials:"include"},signal:t.N&&n?n.signal:null});200===i.status?e?.(await i.text()):r?.(i.status)}catch(t){if("AbortError"===t?.name)r?.(408);else r?.(400)}finally{clearTimeout(i)}}},En=class extends Ye{constructor(t){super(t,37)}},Sn=[-4,{},Jr,zr,Wr],xn=[0,Ur,zr,1,Ur,-1,zr,1,zr,1,Nr],Bn=[0,zr,Ur,-2],Nn=[0,Ur,zr],Cn=[0,Ur,zr],_n=[0,Fr,-3],jn=[0,zr,Ur,-1,Nr,jr,-1,Ur,-5,Mr,[0,Ur,-4],-1,Fr,[0,Fr,-3],zr];var Tn=class extends Ye{constructor(t){super(t,19)}},On=function(t){return e=>pr(e,t)}([-19,{},[0,zr,1,[0,Ur,-6,Nr,jr,Ur,-1,Nr],1,[0,Ur,1,Ur,-5],Ur,-1,[0,zr,Ur,-8],[0,Ur,-3],[0,Ur,zr,Ur,-2],[0,Ur,-1,zr,Ur,-1,zr,Ur,-1,[0,Mr,[0,Ur,-1],Fr,Ur,-5],[0,zr,Fr,jr,-2]],Nr,[0,Ur,-3,Nr,jr,Ur,-1],[0,zr,Ur,-1],[0,Ur,-9],[0,Ur,-6,zr,Ur,1,Ur,Fr,zr,-1,Fr,Ur,-2,zr,Ur,zr,Ur,jr,-1],1,[0,zr],1,[0,Ur,-4],1,xn,[0,[1,2,3,4,5,6],Rr,xn,Rr,Nn,Rr,Cn,Rr,[0,zr],Rr,jn,Rr,Bn],Nn,Cn,jn,[0,[0,zr,Ur,-1,Nr,jr,-1,Ur,-4,Mr,[0,Ur,-4],-1,1,_n],[0,zr,Ur,-1,Nr,jr,-1,Ur,-4,_n]],Bn,[0,Ur,[0,jr,-3,zr],zr,-2,[0,jr,-1],Fr],4,[0,Ur,zr,Ur,-1,Nr,zr,Ur,-1,zr,jr,-1]],zr,Mr,[-37,{},Br,Ur,Mr,[0,Ur,-1],Pr,1,Pr,[0,kr,-1,Tr,Cr,-1],Ur,[0,jr,Ur,-1],Fr,jr,Nr,Ur,-1,$r,Hr,Br,Pr,zr,Tr,Nr,-1,[0,zr,-1],Ur,Fr,Ur,Or,Ur,-1,Sr,1,Sr,Sn,Fr,[0,zr,[0,xr,jr,-2],[0,xr]],[0,zr,Nr]],Br,Dr,Ur,-1,Br,zr,-1,[0,Fr,-1,zr,Fr],[0,Nr,-1,Ur],[0,Br,Fr,Nr],Nr,1,Lr,1,Sn]),Fn=class{constructor(t){this.i=[],this.m=new In,this.j=t??"",this.h=setInterval(()=>{this.flush()},6e4)}close(){void 0!==this.h&&(clearInterval(this.h),this.h=void 0),this.flush()}flush(t,e){if(this.error)e?.("net-send-failed");else if(0===this.i.length)t?.();else{var r=this.i;this.i=[],r=function(t){var e=new Tn;{Gt(e=ae(e,2,1786));let l=e.l,f=0|l[D];if(null==t)Jt(l,f,3);else{var r=t===T?7:0|t[D],n=r,i=Kt(r),o=i||Object.isFrozen(t),a=!0,s=!0;for(let e=0;e<t.length;e++){var u=t[e];i||(u=H(u),a&&=!u,s&&=u)}i||(r=a?13:5,r=s?-4097&r:4096|r),o&&r===n||(t=Array.prototype.slice.call(t),n=0,r=ee(r,f)),r!==n&&G(t,r),f=Jt(l,f,3,t),2&r||!(4096&r||16&r)||$t(l,f)}}return e}(r),r=On(r),this.m.send({url:"https://odml.pa.googleapis.com/v1/log",fa:"POST",N:1e4,body:r,ka:2,ea:{"Content-Type":"application/x-protobuf","x-goog-api-key":this.j},withCredentials:!1},()=>{t?.()},t=>{this.error=Error(`Logging failed with HTTP error: ${t}`),this.i=[],void 0!==this.h&&(clearInterval(this.h),this.h=void 0),e?.("net-send-failed",t)})}}};class Un{constructor(){this.I=this.B=this.G=this.A=this.D=this.F=this.C=0}}function kn(t,e){var r=new An;if(r=Qt(r,1,t.R),r=Qt(r,2,e),e=new En,null!=(r=r.i()))if("string"==typeof r)r=r?new I(r,A):w||=new I(null,A);else if(r.constructor!==I){if(!(p&&null!=r&&r instanceof Uint8Array))throw Error();r=r.length?new I(new Uint8Array(r),A):w||=new I(null,A)}e=Wt(e,6,r),(t=t.H).error||t.i.push(e)}function Mn(t){var e=new pn;e=ie(e=ae(e,1,10),3,performance.now()-t.P),kn(t,e=te(mn(yn(new vn,t.v),0),3,e)),t.m=performance.now()}function Rn(t,e){++t.h.F,t.i.set(e,performance.now())}function Pn(t,e){var r={C:e.C-t.j.C,F:e.F-t.j.F,D:e.D-t.j.D,A:e.A-t.j.A,G:e.G-t.j.G,B:e.B,I:e.I},n=mn(yn(new vn,t.v),1);kn(t,n=te(n,4,r=Ln(r))),t.j=e}function Dn(t,e){var r=t.i.get(e);if(void 0!==r&&(t.i.delete(e),e=performance.now()-r,++t.h.D,t.h.G+=e,t.h.B=Math.max(t.h.B,e),t.u=Math.max(t.u,e),performance.now()>t.m+3e4)){for(let[n,i]of t.i.entries())e=n,i<r&&(t.h.A++,t.i.delete(e));r={...t.h,I:performance.now()-t.m},t.h.B=0,t.m=performance.now(),Pn(t,r)}}function Ln(t){var e=new cn;if(e=ie(e=ne(e=ae(e,1,10),7,t.A),5,t.B),e=ie(e,6,t.I),t.D>0&&ie(e,4,t.G/t.D),0!==t.C){var r=ln(3);re(e,r=ne(r,2,t.C))}return 0!==t.F&&re(e,t=ne(r=ln(4),2,t.F)),e}function zn(t){var e={...t.h,A:t.h.A+t.i.size,B:t.u,I:performance.now()-t.P};Pn(t,e);var r=new dn;r=Qt(r,2,e=Ln(e)),kn(t,r=te(e=mn(yn(new vn,t.v),2),5,r))}var Gn=class{constructor(t,e){this.P=performance.now(),this.m=performance.now(),this.i=new Map,this.u=0,this.h=new Un,this.j=new Un,this.H=new Fn(e),this.v=function(t){switch(t){case"AudioClassifier":return 4;case"AudioEmbedder":return 5;case"TextClassifier":return 6;case"TextEmbedder":return 7;case"GestureRecognizer":return 8;case"HandDetector":return 9;case"HandLandmarker":return 10;case"ImageClassifier":return 11;case"ImageEmbedder":return 12;case"ImageSegmenter":return 13;case"ObjectDetector":return 14;case"FaceDetector":return 15;case"FaceLandmarker":return 16;case"InteractiveSegmenter":case"InteractiveSegmenterLegacy":return 18;case"HolisticLandmarker":return 20;case"LlmInference":return 21;case"LanguageDetector":return 22;case"PoseLandmarker":return 23;case"UniversalEmbedder":return 28;case"SemanticRetriever":return 29;case"DecisionMaker":return 30;default:return 0}}(t),t=new wn,"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=oe(t=ae(t,1,e),2,""),t=oe(t,3,""),t=oe(t,4,"1.1.0"),t=oe(t,5,""),this.R=ae(t,6,4)}close(){var t=this.H;"function"==typeof t.close?t.close():t.flush()}};function $n(t){var e=atob("QUl6YVN5QS1XbGdRNjczMWpZSThjWGhKNEFxZjhuX3J1UmNLMzJZ");return new Gn(t,e)}async function Hn(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())}}}var Wn=async(t,e,r,n)=>{if(e&&await Hn(e),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(r&&(await Hn(r),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&n&&((e=self.Module).locateFile=n.locateFile,n.mainScriptUrlOrBlob&&(e.mainScriptUrlOrBlob=n.mainScriptUrlOrBlob)),n=await self.ModuleFactory(self.Module||n),self.ModuleFactory=self.Module=void 0,new t(n,null)},Jn={CHARACTER:0,WORD:1};function qn(t,e){if(t<=0)throw Error("Chunk size must be positive.");if(e<0||e>=t)throw Error("Chunk overlap must be non-negative and less than chunk size.")}function Vn(t,e,r,n="CHARACTER"){qn(e,r),t.j=e,t.i=r,t.mode=n}var Kn=class{constructor(t){this.j=512,this.i=100,this.mode="CHARACTER",this.h=t}chunk(t){if(!t||0===t.trim().length)return[];if(!this.h||"function"!=typeof this.h.defaultTextChunker_nativeChunkText)throw Error("DefaultTextChunker Wasm module is not initialized.");return(t=this.h.defaultTextChunker_nativeChunkText(t,this.j,this.i,Jn[this.mode]??0))?Array.from(t):[]}};function Xn(t){return{...t,content:t.content?t.content.map(t=>"imageBytes"in t?{...t,imageBytes:new Uint8Array(t.imageBytes)}:"audioData"in t?{...t,audioData:new Float32Array(t.audioData)}:{...t}):[],embeddings:t.embeddings?new Float32Array(t.embeddings):new Float32Array(0),metadata:t.metadata?{...t.metadata}:{},...t.childIds?{childIds:[...t.childIds]}:{}}}Kn.prototype.chunk=Kn.prototype.chunk,Kn.createFromModule=function(t,e=512,r=100,n="CHARACTER"){return qn(e,r),Vn(t=new Kn(t),e,r,n),t},Kn.create=async function(t,e=512,r=100,n="CHARACTER"){qn(e,r);var i=await Wn(Kn,t.wasmLoaderPath,t.assetLoaderPath,{locateFile:e=>e.endsWith(".wasm")?t.wasmBinaryPath.toString():e});return Vn(i,e,r,n),i};var Zn=class{constructor(){this.h=new Map}upsert(t){for(let e of t)this.h.set(e.id,Xn(e))}delete(t){var e=new Set(t);for(let r of t)if(t=this.h.get(r),t?.childIds)for(let r of t.childIds)e.add(r);for(let t of e)this.h.delete(t)}deleteByMetadata(t){var e=Object.keys(t);if(0!==e.length){var r=[];for(let n of this.h.values())n.parentId||n.metadata&&e.every(e=>n.metadata[e]===t[e])&&r.push(n.id);r.length>0&&this.delete(r)}}search(t,e,r){if(e<=0)throw Error(`'topK' must be greater than 0, got ${e}.`);var n=r?Object.keys(r):[];t=Array.from(t);var i=[];for(let e of this.h.values()){if(r&&n.length>0){if(!e.metadata)continue;if(!n.every(t=>e.metadata?.[t]===r[t]))continue}if(e.embeddings&&0!==e.embeddings.length)try{let r=Zr({floatEmbedding:t,headIndex:0,headName:""},{floatEmbedding:Array.from(e.embeddings),headIndex:0,headName:""});i.push({da:e,score:r})}catch{}}return i.sort((t,e)=>e.score-t.score),i.slice(0,e).map(t=>Xn(t.da))}get(t){var e=[];for(let r of t)(t=this.h.get(r))&&e.push(Xn(t));return e}getAllRecordIds(){var t=[];for(let[e,r]of this.h.entries()){let n=e;r.parentId||t.push(n)}return t}deleteAll(){this.h.clear()}close(){this.h.clear()}};Zn.prototype.close=Zn.prototype.close,Zn.prototype.deleteAll=Zn.prototype.deleteAll,Zn.prototype.getAllRecordIds=Zn.prototype.getAllRecordIds,Zn.prototype.get=Zn.prototype.get,Zn.prototype.search=Zn.prototype.search,Zn.prototype.deleteByMetadata=Zn.prototype.deleteByMetadata,Zn.prototype.delete=Zn.prototype.delete,Zn.prototype.upsert=Zn.prototype.upsert;var Yn=class{constructor(){this.h=[]}S(t){return this.h.push(t),this}M(){return[...this.h]}ia(t){return this.j=t,this}o(){return this.j}ha(t){return this.i=t,this}L(){return this.i}};function Qn(t){if(t.i)throw Error("SemanticRetriever has already been closed.")}Yn.prototype.textChunker=Yn.prototype.L,Yn.prototype.setTextChunker=Yn.prototype.ha,Yn.prototype.vectorStore=Yn.prototype.o,Yn.prototype.setVectorStore=Yn.prototype.ia,Yn.prototype.providers=Yn.prototype.M,Yn.prototype.addProvider=Yn.prototype.S;var ti=class{constructor(t,e,r){this.m=t,this.o=e,this.L=r,this.i=!1,this.j=0,this.h=$n("SemanticRetriever"),Mn(this.h)}async embedContent(t){for(let e of this.m.M()){let r=await e.embedContent(t);if(null!=r)return r instanceof Float32Array?r:new Float32Array(r)}throw Error("No embedding provider found that can embed this content.")}async Z(t,e,r){return Qn(this),this.K(t,[{text:e}],r)}async K(t,e,r){Qn(this),await this.o.delete([t]);var n=[],i=0;if(1===e.length&&"text"in e[0]&&"string"==typeof e[0].text){var o=await this.L.chunk(e[0].text);if(o.length>1){let r=[];for(let e of o)o=`${t}_chunk_${i++}`,r.push(o),n.push({id:o,J:[{text:e}],parentId:t});n.push({id:t,J:e,childIds:r})}else n.push({id:t,J:e})}else n.push({id:t,J:e});t=[];for(let e of n)n=void 0!==e.childIds&&e.childIds.length>0?new Float32Array(0):await this.embedContent(e.J),t.push({id:e.id,content:[...e.J],embeddings:n,metadata:r||{},parentId:e.parentId,childIds:e.childIds});await this.o.upsert(t)}async aa(t,e,r){return Qn(this),this.K(t,[{imageBytes:e}],r)}async Y(t,e,r){return Qn(this),this.K(t,[{audioData:e}],r)}async ga(t,e={}){Qn(this);var{limit:r=5,metadataFilter:n}=e;if(r<=0)throw Error(`'limit' must be greater than 0, got ${r}.`);e=this.j++;var i=this.h;++i.h.C,i.i.set(e,performance.now()),t=await this.embedContent("string"==typeof t?[{text:t}]:t),i=await this.o.search(t,3*r,n);var o=new Set;for(var a of i)a.parentId&&o.add(a.parentId);if(a=new Map,o.size>0)for(var s of o=await this.o.get(Array.from(o)))a.set(s.id,s);for(var u of(s=[],o=new Set,i))u.parentId?o.has(u.parentId)||(o.add(u.parentId),(i=a.get(u.parentId))&&s.push({id:i.id,content:i.content,embeddings:u.embeddings,metadata:i.metadata,parentId:i.parentId,childIds:i.childIds})):o.has(u.id)||(o.add(u.id),s.push(u));u=[],t=Array.from(t);for(let e of s){if(s=0,e.embeddings&&e.embeddings.length>0)try{s=Zr({floatEmbedding:t,headIndex:0,headName:""},{floatEmbedding:Array.from(e.embeddings),headIndex:0,headName:""})}catch{s=0}if(u.push({id:e.id,content:e.content?[...e.content]:[],metadata:e.metadata?{...e.metadata}:{},score:s}),u.length>=r)break}return Dn(this.h,e),u}async delete(t){Qn(this),"string"==typeof t?await this.o.delete([t]):Array.isArray(t)?await this.o.delete(t):await this.o.deleteByMetadata(t)}async getAllRecordIds(){Qn(this);var t=await this.o.getAllRecordIds();return Array.from(new Set(t))}async deleteAll(){Qn(this),await this.o.deleteAll()}close(){if(!this.i){this.i=!0,zn(this.h),this.h.close();try{this.o.close()}catch{}}}};async function ei(t,e){var r=e.baseOptions.device;r||=await ri();var n=await Wn(oi,t.wasmLoaderPath,t.assetLoaderPath,{locateFile:e=>e.endsWith(".wasm")?t.wasmBinaryPath.toString():e});return r&&(n.h.preinitializedWebGPUDevice=r),await async function(t,e,r){t.i=$n("UniversalEmbedder");var n=!1!==e.l2Normalize,i=e.baseOptions.modelAssetPath?e.baseOptions.modelAssetPath.toString():"";if((r=r||e.baseOptions.device||t.h.preinitializedWebGPUDevice)||(r=await ri()),t.h.preinitializedWebGPUDevice=r,e.baseOptions.modelAssetBuffer){i=e.baseOptions.modelAssetBuffer instanceof Uint8Array?e.baseOptions.modelAssetBuffer:await async function(t){for(var e=[],r=0;;){let{done:n,value:i}=await t.read();if(n)break;e.push(i),r+=i.length}if(0===e.length)return new Uint8Array(0);if(1===e.length)return e[0];t=new Uint8Array(r),r=0;for(let n of e)t.set(n,r),r+=n.length;return t}(e.baseOptions.modelAssetBuffer);var o=`/${r=`universal_embedder_model_${++ai}.litertlm`}`;try{t.h.FS_unlink?.(o)}catch{}t.h.FS_createDataFile("/",r,i,!0,!1,!1),t.v=o,i=t.v}if(!i)throw Error("No model asset path or buffer provided.");r=e.maxInputLength??0,o=e.visionTokensPerImage??0,e=function(t){if(void 0===t)return 0;switch(t){case"FLOAT32":return 1;case"FLOAT16":return 2;case"INT16":return 3;case"INT8":return 4;default:throw Error(`Unsupported activation data type: ${t}`)}}(e.activationDataType);try{t.j=await t.h.createUniversalEmbedder(i,n,r,o,e),Mn(t.i)}catch(e){throw ni(t),e}}(n,e,r),n}async function ri(){if("undefined"==typeof navigator||!navigator.gpu)throw Error("WebGPU is not supported on this platform.");var t=await navigator.gpu.requestAdapter({powerPreference:"high-performance"});if(!t)throw Error("No appropriate WebGPU adapter found.");var e=[];if(t.features.has("subgroups")&&e.push("subgroups"),t.features.has("shader-f16")&&e.push("shader-f16"),!(e=await t.requestDevice({requiredFeatures:e})).adapterInfo&&t.info)try{Object.defineProperty(e,"adapterInfo",{value:t.info,writable:!0,configurable:!0})}catch{}return e}function ni(t){if(t.v){try{t.h.FS_unlink?.(t.v)}catch{}t.v=void 0}}function ii(t){if(t.H||0===t.j)throw Error("UniversalEmbedder has already been closed.")}ti.prototype.close=ti.prototype.close,ti.prototype.deleteAll=ti.prototype.deleteAll,ti.prototype.getAllRecordIds=ti.prototype.getAllRecordIds,ti.prototype.delete=ti.prototype.delete,ti.prototype.retrieve=ti.prototype.ga,ti.prototype.insertAudio=ti.prototype.Y,ti.prototype.insertImage=ti.prototype.aa,ti.prototype.insertContent=ti.prototype.K,ti.prototype.insertDocument=ti.prototype.Z,ti.createFromComponents=async function(t){if(!t||0===t.M().length)throw Error("At least one EmbeddingProvider must be registered in SemanticRetrieverComponents.");var e=t.o();if(!e)throw Error("VectorStore must be provided in SemanticRetrieverComponents.");var r=t.L();if(!r)throw Error("TextChunker must be provided in SemanticRetrieverComponents.");return new ti(t,e,r)};var oi=class{constructor(t){this.H=!1,this.j=0,this.u=new nn,this.m=0,this.h=t}async V(t){return en(this.u,async()=>{ii(this);var e=this.m++;Rn(this.i,e);var r=await this.h.universalEmbedder_embedText(this.j,t);return Dn(this.i,e),{embeddings:[{floatEmbedding:r?Array.from(r):[],headIndex:0,headName:"default"}]}})}async U(t){return en(this.u,async()=>{ii(this);var e=this.m++;Rn(this.i,e);var r=await this.h.universalEmbedder_embedImage(this.j,t);return Dn(this.i,e),{embeddings:[{floatEmbedding:r?Array.from(r):[],headIndex:0,headName:"default"}]}})}async T(t){return en(this.u,async()=>{ii(this);var e=this.m++;Rn(this.i,e);var r=await this.h.universalEmbedder_embedAudio(this.j,t);return Dn(this.i,e),{embeddings:[{floatEmbedding:r?Array.from(r):[],headIndex:0,headName:"default"}]}})}async embedContent(t){if(ii(this),!Array.isArray(t))throw Error("Content must be an array of ContentParts.");return en(this.u,async()=>{ii(this);var e=this.h.universalEmbedder_createContentBuilder();try{for(let r of t)if("text"in r&&"string"==typeof r.text)this.h.universalEmbedder_builderAddText(e,r.text);else if("imageBytes"in r&&(r.imageBytes instanceof Uint8Array||"string"==typeof r.imageBytes))this.h.universalEmbedder_builderAddImage(e,r.imageBytes);else{if(!("audioData"in r)||!(r.audioData instanceof Float32Array||Array.isArray(r.audioData)))throw Error(`Unsupported or invalid ContentPart: ${JSON.stringify(r)}`);this.h.universalEmbedder_builderAddAudio(e,r.audioData)}let r=this.m++;Rn(this.i,r);let n=await this.h.universalEmbedder_executeEmbedContent(this.j,e);return Dn(this.i,r),{embeddings:[{floatEmbedding:n?Array.from(n):[],headIndex:0,headName:"default"}]}}finally{this.h.universalEmbedder_freeContentBuilder(e)}})}X(){return{embedContent:async t=>(await this.embedContent(t))?.embeddings?.[0]?.floatEmbedding??null}}close(){this.H||(this.H=!0,zn(this.i),this.i.close(),0!==this.j&&(this.h.universalEmbedder_close(this.j),this.j=0),ni(this))}};oi.prototype.close=oi.prototype.close,oi.prototype.getProvider=oi.prototype.X,oi.cosineSimilarity=function(t,e){return Zr(t,e)},oi.prototype.embedContent=oi.prototype.embedContent,oi.prototype.embedAudio=oi.prototype.T,oi.prototype.embedImage=oi.prototype.U,oi.prototype.embedText=oi.prototype.V,oi.createFromModelPath=function(t,e){return ei(t,{baseOptions:{modelAssetPath:e.toString()}})},oi.createFromModelBuffer=function(t,e){return ei(t,{baseOptions:{modelAssetBuffer:e}})},oi.createWebGpuDevice=ri,oi.createFromOptions=ei;var ai=0;exports.DefaultTextChunker=Kn,exports.FilesetResolver=un,exports.MemoryVectorStore=Zn,exports.SemanticRetriever=ti,exports.SemanticRetrieverComponents=Yn,exports.UniversalEmbedder=oi;
|
|
2
2
|
//# sourceMappingURL=retrieval_bundle_cjs.js.map
|