@mediapipe/tasks-retrieval 1.2.0 → 1.2.1-rc.20261031

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mediapipe/tasks-retrieval",
3
- "version": "1.2.0",
3
+ "version": "1.2.1-rc.20261031",
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",
@@ -15,8 +15,6 @@
15
15
  "./retrieval_bundle.js": "./retrieval_bundle.js",
16
16
  "./retrieval_wasm_internal.js": "./wasm/retrieval_wasm_internal.js",
17
17
  "./retrieval_wasm_internal.wasm": "./wasm/retrieval_wasm_internal.wasm",
18
- "./retrieval_wasm_nosimd_internal.js": "./wasm/retrieval_wasm_nosimd_internal.js",
19
- "./retrieval_wasm_nosimd_internal.wasm": "./wasm/retrieval_wasm_nosimd_internal.wasm",
20
18
  "./retrieval_wasm_module_internal.js": "./wasm/retrieval_wasm_module_internal.js",
21
19
  "./retrieval_wasm_module_internal.wasm": "./wasm/retrieval_wasm_module_internal.wasm"
22
20
  },
package/retrieval.d.ts CHANGED
@@ -117,25 +117,11 @@ declare type ErrorListener = (code: number, message: string) => void;
117
117
  /**
118
118
  * Resolves the files required for the MediaPipe Task APIs.
119
119
  *
120
- * This class verifies whether SIMD is supported in the current environment and
121
- * loads the SIMD files only if support is detected. The returned filesets
122
- * require that the Wasm files are published without renaming. If this is not
123
- * possible, you can invoke the MediaPipe Tasks APIs using a manually created
124
- * `WasmFileset`.
120
+ * The returned filesets require that the Wasm files are published without
121
+ * renaming. If this is not possible, you can invoke the MediaPipe Tasks APIs
122
+ * using a manually created `WasmFileset`.
125
123
  */
126
124
  export declare class FilesetResolver {
127
- /**
128
- * Returns whether SIMD is supported in the current environment.
129
- *
130
- * If your environment requires custom locations for the MediaPipe Wasm files,
131
- * you can use `isSimdSupported()` to decide whether to load the SIMD-based
132
- * assets. Note that for ES6 Modules, SIMD is assumed to be always supported.
133
- *
134
- * @param useModule Whether to use ES6 Modules for the Wasm files.
135
- * @export
136
- * @return Whether SIMD support was detected in the current environment.
137
- */
138
- static isSimdSupported(useModule?: boolean): Promise<boolean>;
139
125
  /**
140
126
  * Creates a fileset for the MediaPipe Audio tasks.
141
127
  *
@@ -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 N(t){return S(t=Error(t),"warning"),t}function B(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 _(){return"function"==typeof BigInt}var C="function"==typeof Symbol&&"symbol"==typeof Symbol();function T(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,O=T("jas",void 0,!0),F=T(void 0,"1oa"),U=T(void 0,"0ubsb"),k=T(void 0,"0actk"),M=T("m_m","ma",!0),R={ba:{value:0,configurable:!0,writable:!0,enumerable:!1}},P=Object.defineProperties,D=C?O:"ba",L=[];function z(t,e){C||D in t||P(t,R),t[D]|=e}function G(t,e){C||D in t||P(t,R),t[D]=e}G(L,7),j=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 V=J(t=>"number"==typeof t),q=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(q(e)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(e))throw Error(String(e))}else if(V(e)&&!Number.isSafeInteger(e))throw Error(String(e));return X?BigInt(t):t=K(t)?t?"1":"0":q(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 _()?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(_())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(_())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 Nt(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 Bt(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 _t(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 Ct(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=Bt(t)),t;if("number"===e)return function(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}(t)}}function Tt(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=_t(t)),t;if("number"===e)return function(t){return(t=bt(t))>=0&&gt(t)||(ut(t),t=lt(ot,at)),t}(t)}}function jt(t){if(null==t||"string"==typeof t||t instanceof I)return t}function Ot(t){return null==t||"string"==typeof t?t:void 0}function Ft(t){return t}function Ut(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??Ft)(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 kt(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:Ut(t,e,kt)}if(null!=t&&t[M]===$)return Mt(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 Mt(t){return Ut(t=t.l,0|t[D],kt)}function Rt(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");B(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 Pt(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=Dt(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=Dt(r,n)),t}return t instanceof I?t:void 0}function Dt(t,e,r,n){return n??=!!(34&e),t=Ut(t,e,Pt,n),n=32,r&&(n|=2),G(t,e=16769217&e|n),t}function Lt(t){if(t.h!==W)return!1;var e=t.l;return z(e=Dt(e,0|e[D]),2048),t.l=e,t.h=void 0,t.j=void 0,!0}function zt(t){if(!Lt(t)&&H(t,0|t.l[D]))throw Error()}function Gt(t,e){void 0===e&&(e=0|t[D]),32&e&&!(4096&e)&&G(t,4096|e)}function $t(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 Ht(t,e,r){zt(t);var n=t.l;return Wt(n,0|n[D],e,r),t}function Wt(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 Jt(t,e,r){return t=$t(t,e,r),Array.isArray(t)?t:j}function Vt(t,e){return 2&e&&(t|=2),1|t}function qt(t){return!!(2&t)&&!!(4&t)||!!(256&t)}function Kt(t){if(C)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 Xt(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!=$t(e,o)&&(0!==i&&(r=Wt(e,r,i)),i=o)}return t.set(n,i),i}function Zt(t){return null==t&&(t=void 0),t}function Yt(t,e,r){return Ht(t,e,r=Zt(r)),r&&!H(r)&&Gt(t.l),t}function Qt(t,e,r){var n=vn;t:{var i=r=Zt(r);zt(t);let s=t.l;var o=0|s[D];if(null==i){var a=Kt(s);if(Xt(a,s,o,n)!==e)break t;a.set(n,0)}else{let t=Kt(a=s),r=Xt(t,a,o,n);r!==e&&(r&&(o=Wt(a,o,r)),t.set(n,e))}Wt(s,o,e,i)}return r&&!H(r)&&Gt(t.l),t}function te(t,e){return-273&(2&e?2|t:-3&t)}function ee(t,e){var r=ln;zt(t);var n=t.l,i=n,o=0|n[D],a=H(t,o)?1:2;2===a&&Lt(t)&&(o=0|(i=t.l)[D]);var s=Jt(i,8),u=s===j?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,(f=qt(u))&&2===a&&(s=Array.prototype.slice.call(s),l=0,u=te(u,o),o=Wt(i,o,8,s),f=!1),f||(1===a||4===a&&(2&u||!(16&u)&&32&o)?((u|=!s.length||t&&!(4096&u)||32&o&&!(4096&u||16&u)?2:256)!==l&&G(s,u),Object.freeze(s)):u!==l&&G(s,u)),2&u||!(4096&u||16&u)||Gt(i,o),a=s,e=null!=e?e:new r,a.push(e),t=r=a===j?7:0|a[D],(e=H(e))?(r&=-9,1===a.length&&(r&=-4097)):r|=4096,r!==t&&G(a,r),e||Gt(n)}function re(t,e,r){return Ht(t,e,null==r?r:function(t){if(!xt(t))throw N("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=_()?Z(yt(64,BigInt(t))):Z(Bt(t))),t;case"bigint":return Z(yt(64,t));default:return gt(t)||(t=bt(t),gt(t)?t=String(t):(ut(t),t=ht())),Z(t)}}(r))}function ne(t,e,r){return Ht(t,e,null==r?r:function(t){if(!xt(t))throw N("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=_()?Z(mt(64,BigInt(t))):Z(_t(t))),t;case"bigint":return Z(mt(64,t));default:return t>=0&&gt(t)||((t=bt(t))>=0&&gt(t)?t=String(t):(ut(t),t=ft(ot,at))),Z(t)}}(r))}function ie(t,e,r){if(null!=r&&"string"!=typeof r)throw Error();return Ht(t,e,r)}function oe(t,e,r){if(null!=r){if(!vt(r))throw N("enum");r|=0}return Ht(t,e,r)}var ae=class{constructor(t,e,r){if(this.buffer=t,r&&!e)throw Error()}};function se(t){if("string"==typeof t)return new ae(b(t),!0);if(Array.isArray(t))return new ae(new Uint8Array(t),!0);if(t.constructor===Uint8Array)return new ae(t,!1);if(t.constructor===ArrayBuffer)return t=new Uint8Array(t),new ae(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 ae(e,!0,t)}if(t instanceof Uint8Array)return t=t.constructor===Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new ae(t,!1);throw Error()}function ue(t){return new ce(4294967295&t,Math.floor(t/4294967296))}function le(t){return t?/^\d+$/.test(t)?(dt(t),new ce(ot,at)):null:fe||=new ce(0,0)}var fe,ce=class{constructor(t,e){this.i=t>>>0,this.h=e>>>0}};function he(t){return new Ie(4294967295&t,Math.floor(t/4294967296))}function de(t){return t?/^-?\d+$/.test(t)?(dt(t),new Ie(ot,at)):null:pe||=new Ie(0,0)}var pe,ye,me,ge,ve,be,we,Ae,Ie=class{constructor(t,e){this.i=t>>>0,this.h=e>>>0}};function Ee(t,e,r){return"undefined"!=typeof BigInt64Array?(we||(we=new BigInt64Array(1),Ae=new Uint32Array(we.buffer),we[0]=BigInt(1),be=1===Ae[0]),we[0]=t,new e(Ae[t=be?0:1],Ae[1-t])):(ve||(ye=BigInt(Number.MIN_SAFE_INTEGER),me=BigInt(Number.MAX_SAFE_INTEGER),ge=BigInt(4294967295),ve=BigInt(32)),t>=ye&&t<=me?r(Number(t)):(t=BigInt.asUintN(64,t),new e(Number(t&ge),Number(t>>ve))))}function Se(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 xe(t,e){for(;e>127;)t.h.push(127&e|128),e>>>=7;t.h.push(e)}function Ne(t,e){if(e>=0)xe(t,e);else{for(let r=0;r<9;r++)t.h.push(127&e|128),e>>=7;t.h.push(1)}}function Be(t,e){dt(e),function(t){var e=at>>31;t(ot<<1^e,(at<<1|ot>>>31)^e)}((e,r)=>{Se(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 Ce=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 je(t,e,r){xe(t.h,8*e+r)}function Oe(t,e){return je(t,e,2),e=t.h.end(),Te(t,e),e.push(t.i),e}function Fe(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 Ue(t,e,r){if(null!=r)switch(je(t,e,0),typeof r){case"number":t=t.h,ut(r),Se(t,ot,at);break;case"bigint":r=Ee(r,Ie,he),Se(t.h,r.i,r.h);break;default:r=de(r),Se(t.h,r.i,r.h)}}function ke(t,e,r){je(t,e,2),xe(t.h,r.length),Te(t,t.h.end()),Te(t,r)}var Me=class{constructor(){this.j=[],this.i=0,this.h=new Ce}};function Re(t){if("string"==typeof t)de(t)}function Pe(){var t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var De=Pe(),Le=Pe(),ze=Pe(),Ge=Pe(),$e=Pe(),He=Pe(),We=Pe(),Je=Pe(),Ve=Pe(),qe=Pe(),Ke=Pe(),Xe=Pe(),Ze=class{constructor(t,e){this.l=Rt(t,e,void 0,2048)}toJSON(){return Mt(this)}};Ze.prototype[M]=$,Ze.prototype.toString=function(){return this.l.toString()};var Ye=class{constructor(t,e){this.h=t,t=De,this.i=!!t&&e===t||!1}};function Qe(t,e,r,n,i){null!=(e=sr(e,n))&&(r=Oe(t,r),i(e,t),Fe(t,r))}var tr,er,rr=new Ye(Qe,De),nr=new Ye(Qe,De),ir=Symbol(),or=Symbol();function ar(t){var e=ur,r=lr,n=t[ir];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,tr??=i,er??=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 Ye?f=i:(f=rr,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[ir]=n}function sr(t,e){return t instanceof Ze?t.l:Array.isArray(t)?Rt(t,e[0],e[1]):void 0}function ur(t,e,r){t[e]=r.h}function lr(t,e,r,n){var i,o,a=r.h;t[e]=(t,e,r)=>a(t,e,r,o||=ar(n).O,i||=fr(n))}function fr(t){var e=t[or];if(!e){let r=ar(t);e=(t,e)=>cr(t,e,r),t[or]=e}return e}function cr(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 Ye?r:[nr,r]:[r,void 0])[0].h;if(r=r[1]){let e=fr(r),i=ar(r).O;r=t.ca?er(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||B(U,3)}})}function hr(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 dr=(t,e)=>{var r=new Me;cr(t.l,r,ar(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 pr(t,e){return new Ye(t,e)}function yr(t,e){return new Ye(t,e)}function mr(t,e,r){null!=(e=Ct(e))&&(Re(e),Ue(t,r,e))}function gr(t,e,r){null!=(e=Nt(e))&&null!=e&&(je(t,r,0),Ne(t.h,e))}function vr(t,e,r){null!=(e=Ot(e))&&ke(t,r,i(e))}function br(t,e,r,n,i){null!=(e=sr(e,n))&&(r=Oe(t,r),i(e,t),Fe(t,r))}function wr(t,e,r){null!=(e=jt(e))&&ke(t,r,se(e).buffer)}function Ar(t,e,r){null!=(e=Nt(e))&&(e=parseInt(e,10),je(t,r,0),Ne(t.h,e))}var Ir,Er=pr(function(t,e,r){null!=(e=wt(e))&&(je(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))},qe),Sr=pr(function(t,e,r){null!=(e=wt(e))&&(je(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),xr=pr(mr,He),Nr=pr(mr,He),Br=yr(function(t,e,r){if(null!=(e=hr(Ct,e,!1)))for(let n=0;n<e.length;n++)Ue(t,r,e[n])},He),_r=pr(function(t,e,r){if(null!=(e=Tt(e))){if("string"==typeof e)le(e);if(null!=e)switch(je(t,r,0),typeof e){case"number":t=t.h,ut(e),Se(t,ot,at);break;case"bigint":r=Ee(e,ce,ue),Se(t.h,r.i,r.h);break;default:r=le(e),Se(t.h,r.i,r.h)}}},We),Cr=pr(gr,Ge),Tr=yr(function(t,e,r){if(null!=(e=hr(Nt,e,!0)))for(let a=0;a<e.length;a++){var n=t,i=r,o=e[a];null!=o&&(je(n,i,0),Ne(n.h,o))}},Ge),jr=yr(function(t,e,r){if(null!=(e=hr(Nt,e,!0))&&e.length){r=Oe(t,r);for(let r=0;r<e.length;r++)Ne(t.h,e[r]);Fe(t,r)}},Ge),Or=pr(function(t,e,r){null!=(e=null==e||"boolean"==typeof e?e:"number"==typeof e?!!e:void 0)&&(je(t,r,0),t.h.h.push(e?1:0))},Le),Fr=pr(vr,ze),Ur=yr(function(t,e,r){if(null!=(e=hr(Ot,e,!0)))for(let s=0;s<e.length;s++){var n=t,o=r,a=e[s];null!=a&&ke(n,o,i(a))}},ze),kr=function(t,e,r=De){return new Ye(e,r)}(0,function(t,e,r,n,i){if(Array.isArray(e)){for(let o=0;o<e.length;o++)br(t,e[o],r,n,i);1&(t=0|e[D])||G(e,1|t)}}),Mr=new Ye(br,De),Rr=pr(wr,Ke),Pr=yr(function(t,e,r){if(null!=(e=hr(jt,e,!1)))for(let a=0;a<e.length;a++){var n=t,i=r,o=e[a];null!=o&&ke(n,i,se(o).buffer)}},Ke),Dr=pr(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&&(je(t,r,0),xe(t.h,e))},$e),Lr=pr(Ar,Xe),zr=pr(Ar,Xe),Gr=pr(function(t,e,r){if(null!=(e=Ct(e))&&(Re(e),null!=e))switch(je(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--),Se(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))),Se(t,ot,at);break;default:Be(t.h,e)}},Je),$r=[0,Rr,Pr,Or,Fr],Hr=[0,pr(vr,ze),[0,zr,[0,pr(mr,He),pr(gr,Ge)],zr,-1,[0,Lr],zr,-1],pr(wr,Ke)],Wr=[0,1,[0,12,Cr,10,Or],[0,7,[0,Cr,-1]]],Jr=globalThis.trustedTypes;var Vr=class{constructor(t){this.h=t}toString(){return this.h+""}};function qr(t){var e;return void 0===Ir&&(Ir=function(){var t=null;if(!Jr)return t;try{let e=t=>t;t=Jr.createPolicy("goog#html",{createHTML:e,createScript:e,createScriptURL:e})}catch(t){}return t}()),t=(e=Ir)?e.createScriptURL(t):t,new Vr(t)}function Kr(t,...e){if(0===e.length)return qr(t[0]);var r=t[0];for(let n=0;n<e.length;n++)r+=encodeURIComponent(e[n])+t[n+1];return qr(r)}function Xr(t,e){if(t.floatEmbedding&&e.floatEmbedding)return Yr(t.floatEmbedding,e.floatEmbedding);if(t.quantizedEmbedding&&e.quantizedEmbedding)return Yr(Zr(t.quantizedEmbedding),Zr(e.quantizedEmbedding));throw Error("Cannot compute cosine similarity between quantized and float embeddings.")}function Zr(t){return Array.from(t,t=>t>127?t-256:t)}function Yr(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 Qr(t){!t.h&&t.i.length>0&&(t.h=!0,t.i.shift()())}async function tn(t,e){return new Promise((r,n)=>{t.i.push(()=>{e().then(r,n).finally(()=>{t.h=!1,Qr(t)})}),Qr(t)})}var en,rn=class{constructor(){this.h=!1,this.i=[]}},nn=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 on(t){if(t)return!0;if(void 0===en)try{await WebAssembly.instantiate(nn),en=!0}catch{en=!1}return en}async function an(t,e,r){return{wasmLoaderPath:`${e}/${t}_${r=`wasm${r?"_module":""}${await on(r)?"":"_nosimd"}_internal`}.js`,wasmBinaryPath:`${e}/${t}_${r}.wasm`}}var sn=class{};function un(t){return oe(new ln,1,t)}sn.forVisionTasks=function(t,e=!1){return an("vision",t??Kr``,e)},sn.forLiteRtLmTextTasks=function(t,e=!1){return an("litertlm_text",t??Kr``,e)},sn.forTextTasks=function(t,e=!1){return an("text",t??Kr``,e)},sn.forRetrievalTasks=function(t,e=!1){return an("retrieval",t??Kr``,e)},sn.forGenAiTasks=function(t,e=!1){return an("genai",t??Kr``,e)},sn.forDecisionTasks=function(t,e=!1){return an("decision",t??Kr``,e)},sn.forAudioTasks=function(t,e=!1){return an("audio",t??Kr``,e)},sn.isSimdSupported=function(t=!1){return on(t)};var ln=class extends Ze{constructor(t){super(t)}},fn=class extends Ze{constructor(t){super(t)}},cn=[0,Lr,2,_r,-2,Nr,kr,[0,Lr,Nr]],hn=class extends Ze{constructor(t){super(t)}},dn=class extends Ze{constructor(t){super(t)}};function pn(t,e){return oe(t,1,e)}function yn(t,e){return oe(t,2,e)}var mn,gn=class extends Ze{constructor(t){super(t)}},vn=[3,4,5,6,7],bn=class extends Ze{constructor(t){super(t)}},wn=class extends Ze{constructor(t){super(t)}};wn.prototype.i=(mn=[0,[0,Lr,Fr,-3,Lr],[0,vn,Lr,-1,Mr,[0,Lr,Fr,_r],Mr,cn,Mr,[0,1,cn],Mr,[0,Lr],Mr,[0,Lr,Fr,_r]]],function(){return dr(this,mn)});var An=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)}}},In=class extends Ze{constructor(t){super(t,37)}},En=[-4,{},Wr,Lr,Hr],Sn=[0,Fr,Lr,1,Fr,-1,Lr,1,Lr,1,Nr],xn=[0,Lr,Fr,-2],Nn=[0,Fr,Lr],Bn=[0,Fr,Lr],_n=[0,Or,-3],Cn=[0,Lr,Fr,-1,Nr,Cr,-1,Fr,-5,kr,[0,Fr,-4],-1,Or,[0,Or,-3],Lr];var Tn=class extends Ze{constructor(t){super(t,19)}},jn=function(t){return e=>dr(e,t)}([-19,{},[0,Lr,1,[0,Fr,-6,Nr,Cr,Fr,-1,Nr],1,[0,Fr,1,Fr,-5],Fr,-1,[0,Lr,Fr,-8],[0,Fr,-3],[0,Fr,Lr,Fr,-2],[0,Fr,-1,Lr,Fr,-1,Lr,Fr,-1,[0,kr,[0,Fr,-1],Or,Fr,-5],[0,Lr,Or,Cr,-2]],Nr,[0,Fr,-3,Nr,Cr,Fr,-1],[0,Lr,Fr,-1],[0,Fr,-9],[0,Fr,-6,Lr,Fr,1,Fr,Or,Lr,-1,Or,Fr,-2,Lr,Fr,Lr,Fr,Cr,-1],1,[0,Lr],1,[0,Fr,-4],1,Sn,[0,[1,2,3,4,5,6],Mr,Sn,Mr,Nn,Mr,Bn,Mr,[0,Lr],Mr,Cn,Mr,xn],Nn,Bn,Cn,[0,[0,Lr,Fr,-1,Nr,Cr,-1,Fr,-4,kr,[0,Fr,-4],-1,1,_n],[0,Lr,Fr,-1,Nr,Cr,-1,Fr,-4,_n]],xn,[0,Fr,[0,Cr,-3,Lr],Lr,-2,[0,Cr,-1],Or],4,[0,Fr,Lr,Fr,-1,Nr,Lr,Fr,-1,Lr,Cr,-1]],Lr,kr,[-37,{},xr,Fr,kr,[0,Fr,-1],Rr,1,Rr,[0,Ur,-1,Tr,Br,-1],Fr,[0,Cr,Fr,-1],Or,Cr,Nr,Fr,-1,Gr,$r,xr,Rr,Lr,Tr,Nr,-1,[0,Lr,-1],Fr,Or,Fr,jr,Fr,-1,Er,1,Er,En,Or,[0,Lr,[0,Sr,Cr,-2],[0,Sr]],[0,Lr,Nr]],xr,Pr,Fr,-1,xr,Lr,-1,[0,Or,-1,Lr,Or],[0,Nr,-1,Fr],[0,xr,Or,Nr],Nr,1,Dr,1,En]),On=class{constructor(t){this.i=[],this.m=new An,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;{zt(e=oe(e,2,1786));let l=e.l,f=0|l[D];if(null==t)Wt(l,f,3);else{var r=t===j?7:0|t[D],n=r,i=qt(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=te(r,f)),r!==n&&G(t,r),f=Wt(l,f,3,t),2&r||!(4096&r||16&r)||Gt(l,f)}}return e}(r),r=jn(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 Fn{constructor(){this.I=this.B=this.G=this.A=this.D=this.F=this.C=0}}function Un(t,e){var r=new wn;if(r=Yt(r,1,t.R),r=Yt(r,2,e),e=new In,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=Ht(e,6,r),(t=t.H).error||t.i.push(e)}function kn(t){var e=new dn;e=ne(e=oe(e,1,10),3,performance.now()-t.P),Un(t,e=Qt(yn(pn(new gn,t.v),0),3,e)),t.m=performance.now()}function Mn(t,e){++t.h.F,t.i.set(e,performance.now())}function Rn(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=yn(pn(new gn,t.v),1);Un(t,n=Qt(n,4,r=Dn(r))),t.j=e}function Pn(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(),Rn(t,r)}}function Dn(t){var e=new fn;if(e=ne(e=re(e=oe(e,1,10),7,t.A),5,t.B),e=ne(e,6,t.I),t.D>0&&ne(e,4,t.G/t.D),0!==t.C){var r=un(3);ee(e,r=re(r,2,t.C))}return 0!==t.F&&ee(e,t=re(r=un(4),2,t.F)),e}function Ln(t){var e={...t.h,A:t.h.A+t.i.size,B:t.u,I:performance.now()-t.P};Rn(t,e);var r=new hn;r=Yt(r,2,e=Dn(e)),Un(t,r=Qt(e=yn(pn(new gn,t.v),2),5,r))}var zn=class{constructor(t,e){this.P=performance.now(),this.m=performance.now(),this.i=new Map,this.u=0,this.h=new Fn,this.j=new Fn,this.H=new On(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;case"TextSummarizer":return 26;case"TextProofreader":return 27;case"AudioTranscriber":return 31;case"TextToSpeech":return 32;default:return 0}}(t),t=new bn,"undefined"==typeof navigator?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=ie(t=oe(t,1,e),2,""),t=ie(t,3,""),t=ie(t,4,"1.2.0"),t=ie(t,5,""),this.R=oe(t,6,function(){var t=globalThis.__HOST_ENVIRONMENT__;if("string"==typeof t)switch(t){case"ANDROID":return 1;case"IOS":return 2;case"PYTHON":return 3;case"WEB":break;case"FLUTTER":return 5;case"FLUTTER_WEB":return 6;default:return 0}return 4}())}close(){var t=this.H;"function"==typeof t.close?t.close():t.flush()}};function Gn(t){var e=atob("QUl6YVN5QS1XbGdRNjczMWpZSThjWGhKNEFxZjhuX3J1UmNLMzJZ");return new zn(t,e)}async function $n(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 Hn=async(t,e,r,n)=>{if(e&&await $n(e),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(r&&(await $n(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)},Wn={CHARACTER:0,WORD:1};function Jn(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"){Jn(e,r),t.j=e,t.i=r,t.mode=n}var qn=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,Wn[this.mode]??0))?Array.from(t):[]}};function Kn(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]}:{}}}qn.prototype.chunk=qn.prototype.chunk,qn.createFromModule=function(t,e=512,r=100,n="CHARACTER"){return Jn(e,r),Vn(t=new qn(t),e,r,n),t},qn.create=async function(t,e=512,r=100,n="CHARACTER"){Jn(e,r);var i=await Hn(qn,t.wasmLoaderPath,t.assetLoaderPath,{locateFile:e=>e.endsWith(".wasm")?t.wasmBinaryPath.toString():e});return Vn(i,e,r,n),i};var Xn=class{constructor(){this.h=new Map}upsert(t){for(let e of t)this.h.set(e.id,Kn(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=Xr({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=>Kn(t.da))}get(t){var e=[];for(let r of t)(t=this.h.get(r))&&e.push(Kn(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()}};Xn.prototype.close=Xn.prototype.close,Xn.prototype.deleteAll=Xn.prototype.deleteAll,Xn.prototype.getAllRecordIds=Xn.prototype.getAllRecordIds,Xn.prototype.get=Xn.prototype.get,Xn.prototype.search=Xn.prototype.search,Xn.prototype.deleteByMetadata=Xn.prototype.deleteByMetadata,Xn.prototype.delete=Xn.prototype.delete,Xn.prototype.upsert=Xn.prototype.upsert;var Zn=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 Yn(t){if(t.i)throw Error("SemanticRetriever has already been closed.")}Zn.prototype.textChunker=Zn.prototype.L,Zn.prototype.setTextChunker=Zn.prototype.ha,Zn.prototype.vectorStore=Zn.prototype.o,Zn.prototype.setVectorStore=Zn.prototype.ia,Zn.prototype.providers=Zn.prototype.M,Zn.prototype.addProvider=Zn.prototype.S;var Qn=class{constructor(t,e,r){this.m=t,this.o=e,this.L=r,this.i=!1,this.j=0,this.h=Gn("SemanticRetriever"),kn(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 Yn(this),this.K(t,[{text:e}],r)}async K(t,e,r){Yn(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 Yn(this),this.K(t,[{imageBytes:e}],r)}async Y(t,e,r){return Yn(this),this.K(t,[{audioData:e}],r)}async ga(t,e={}){Yn(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=Xr({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 Pn(this.h,e),u}async delete(t){Yn(this),"string"==typeof t?await this.o.delete([t]):Array.isArray(t)?await this.o.delete(t):await this.o.deleteByMetadata(t)}async getAllRecordIds(){Yn(this);var t=await this.o.getAllRecordIds();return Array.from(new Set(t))}async deleteAll(){Yn(this),await this.o.deleteAll()}close(){if(!this.i){this.i=!0,Ln(this.h),this.h.close();try{this.o.close()}catch{}}}};async function ti(t,e){var r=e.baseOptions.device;r||=await ei();var n=await Hn(ii,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=Gn("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 ei()),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_${++oi}.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),kn(t.i)}catch(e){throw ri(t),e}}(n,e,r),n}async function ei(){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 ri(t){if(t.v){try{t.h.FS_unlink?.(t.v)}catch{}t.v=void 0}}function ni(t){if(t.H||0===t.j)throw Error("UniversalEmbedder has already been closed.")}Qn.prototype.close=Qn.prototype.close,Qn.prototype.deleteAll=Qn.prototype.deleteAll,Qn.prototype.getAllRecordIds=Qn.prototype.getAllRecordIds,Qn.prototype.delete=Qn.prototype.delete,Qn.prototype.retrieve=Qn.prototype.ga,Qn.prototype.insertAudio=Qn.prototype.Y,Qn.prototype.insertImage=Qn.prototype.aa,Qn.prototype.insertContent=Qn.prototype.K,Qn.prototype.insertDocument=Qn.prototype.Z,Qn.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 Qn(t,e,r)};var ii=class{constructor(t){this.H=!1,this.j=0,this.u=new rn,this.m=0,this.h=t}async V(t){return tn(this.u,async()=>{ni(this);var e=this.m++;Mn(this.i,e);var r=await this.h.universalEmbedder_embedText(this.j,t);return Pn(this.i,e),{embeddings:[{floatEmbedding:r?Array.from(r):[],headIndex:0,headName:"default"}]}})}async U(t){return tn(this.u,async()=>{ni(this);var e=this.m++;Mn(this.i,e);var r=await this.h.universalEmbedder_embedImage(this.j,t);return Pn(this.i,e),{embeddings:[{floatEmbedding:r?Array.from(r):[],headIndex:0,headName:"default"}]}})}async T(t){return tn(this.u,async()=>{ni(this);var e=this.m++;Mn(this.i,e);var r=await this.h.universalEmbedder_embedAudio(this.j,t);return Pn(this.i,e),{embeddings:[{floatEmbedding:r?Array.from(r):[],headIndex:0,headName:"default"}]}})}async embedContent(t){if(ni(this),!Array.isArray(t))throw Error("Content must be an array of ContentParts.");return tn(this.u,async()=>{ni(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++;Mn(this.i,r);let n=await this.h.universalEmbedder_executeEmbedContent(this.j,e);return Pn(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,Ln(this.i),this.i.close(),0!==this.j&&(this.h.universalEmbedder_close(this.j),this.j=0),ri(this))}};ii.prototype.close=ii.prototype.close,ii.prototype.getProvider=ii.prototype.X,ii.cosineSimilarity=function(t,e){return Xr(t,e)},ii.prototype.embedContent=ii.prototype.embedContent,ii.prototype.embedAudio=ii.prototype.T,ii.prototype.embedImage=ii.prototype.U,ii.prototype.embedText=ii.prototype.V,ii.createFromModelPath=function(t,e){return ti(t,{baseOptions:{modelAssetPath:e.toString()}})},ii.createFromModelBuffer=function(t,e){return ti(t,{baseOptions:{modelAssetBuffer:e}})},ii.createWebGpuDevice=ei,ii.createFromOptions=ti;var oi=0;exports.DefaultTextChunker=qn,exports.FilesetResolver=sn,exports.MemoryVectorStore=Xn,exports.SemanticRetriever=Qn,exports.SemanticRetrieverComponents=Zn,exports.UniversalEmbedder=ii;
1
+ "use strict";var t="undefined"!=typeof self?self:{};var e,r="undefined"!=typeof TextEncoder;function n(t){if(r)t=(e||=new TextEncoder).encode(t);else{let e=0,r=new Uint8Array(3*t.length);for(let i=0;i<t.length;i++){var n=t.charCodeAt(i);if(n<128)r[e++]=n;else{if(n<2048)r[e++]=n>>6|192;else{if(n>=55296&&n<=57343){if(n<=56319&&i<t.length){let o=t.charCodeAt(++i);if(o>=56320&&o<=57343){n=1024*(n-55296)+o-56320+65536,r[e++]=n>>18|240,r[e++]=n>>12&63|128,r[e++]=n>>6&63|128,r[e++]=63&n|128;continue}i--}n=65533}r[e++]=n>>12|224,r[e++]=n>>6&63|128}r[e++]=63&n|128}}t=e===r.length?r:r.subarray(0,e)}return t}function i(){var e=t.navigator;return e&&(e=e.userAgent)?e:""}var o={},a=null;function s(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=a[e];if(null!=r)return r;if(!/^[\s\xa0]*$/.test(e))throw Error("Unknown base64 encoding at char: "+e)}return e}u();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 u(){if(!a){a={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){let n=t.concat(e[r].split(""));o[r]=n;for(let t=0;t<n.length;t++){let e=n[t];void 0===a[e]&&(a[e]=t)}}}}var l="undefined"!=typeof Uint8Array,f=!(-1!=i().indexOf("Trident")||-1!=i().indexOf("MSIE"))&&"function"==typeof btoa,c=/[-_.]/g,h={"-":"+",_:"/",".":"="};function d(t){return h[t]||""}function p(t){if(!f)return s(t);t=c.test(t)?t.replace(c,d):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 m,y={},g=class{constructor(t,e){if(v(e),this.h=t,null!=t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}};function v(t){if(t!==y)throw Error("illegal external caller")}function b(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}var w,A,I=void 0;function E(t){return b(t=Error(t),"warning"),t}function S(e,r){if(null!=e){var n=I??={},i=n[e]||0;i>=r||(n[e]=i+1,b(e=Error(),"incident"),function(e){t.setTimeout(()=>{throw e},0)}(e))}}t:{for(var x=["CLOSURE_FLAGS"],N=t,B=0;B<x.length;B++)if(null==(N=N[x[B]])){A=null;break t}A=N}var _=A&&A[748402147];function C(){return"function"==typeof BigInt}w=null==_||_;var T="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 O,F=j("jas",void 0,!0),U=j(void 0,"1oa"),k=j(void 0,"0ubsb"),M=j(void 0,"0actk"),R=j("m_m","ma",!0),P={ba:{value:0,configurable:!0,writable:!0,enumerable:!1}},D=Object.defineProperties,L=T?F:"ba",z=[];function G(t,e){T||L in t||D(t,P),t[L]|=e}function $(t,e){T||L in t||D(t,P),t[L]=e}function H(t,e){return 2&e&&(t|=2),1|t}$(z,7),O=Object.freeze(z);var W={};function J(t,e){return void 0===e?t.h!==V&&!!(2&t.l[L]):!!(2&e)&&t.h!==V}var V={};function q(t){return t.la=!0,t}var K=q(t=>"number"==typeof t),X=q(t=>"string"==typeof t),Z=q(t=>"boolean"==typeof t),Y="function"==typeof t.BigInt&&"bigint"==typeof t.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(K(e)&&!Number.isSafeInteger(e))throw Error(String(e));return Y?BigInt(t):t=Z(t)?t?"1":"0":X(t)?t.trim()||"0":String(t)}var tt=q(t=>Y?t>=rt&&t<=it:"-"===t[0]?ot(t,et):ot(t,nt)),et=Number.MIN_SAFE_INTEGER.toString(),rt=Y?BigInt(Number.MIN_SAFE_INTEGER):void 0,nt=Number.MAX_SAFE_INTEGER.toString(),it=Y?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 n=t[r],i=e[r];if(n>i)return!1;if(n<i)return!0}}var at,st=0,ut=0;function lt(t){var e=t>>>0;st=e,ut=(t-e)/4294967296>>>0}function ft(t){if(t<0){lt(-t);let[e,r]=yt(st,ut);st=e>>>0,ut=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 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+dt(r)+dt(t));return r}function dt(t){return t=String(t),"0000000".slice(t.length)+t}function pt(){var t=st,e=ut;if(2147483648&e)if(C())t=""+(BigInt(0|e)<<BigInt(32)|BigInt(t>>>0));else{let[r,n]=yt(t,e);t="-"+ht(r,n)}else t=ht(t,e);return t}function mt(t){if(t.length<16)ft(Number(t));else if(C())t=BigInt(t),st=Number(t&BigInt(4294967295))>>>0,ut=Number(t>>BigInt(32)&BigInt(4294967295));else{let e=+("-"===t[0]);ut=st=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));ut*=1e6,(st=1e6*st+e)>=4294967296&&(ut+=Math.trunc(st/4294967296),ut>>>=0,st>>>=0)}if(e){let[t,e]=yt(st,ut);st=t,ut=e}}}function yt(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}var gt="function"==typeof BigInt?BigInt.asIntN:void 0,vt="function"==typeof BigInt?BigInt.asUintN:void 0,bt=Number.isSafeInteger,wt=Number.isFinite,At=Math.trunc;function It(t){return null==t||"number"==typeof t?t:"NaN"===t||"Infinity"===t||"-Infinity"===t?Number(t):void 0}var Et,St,xt,Nt=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function Bt(t){switch(typeof t){case"bigint":return!0;case"number":return wt(t);case"string":return Nt.test(t);default:return!1}}function _t(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 Ct(t){var e=t.length;return("-"===t[0]?e<20||20===e&&t<="-9223372036854775808":e<19||19===e&&t<="9223372036854775807")?t:(mt(t),pt())}function Tt(t){if("-"===t[0])var e=!1;else e=(e=t.length)<20||20===e&&t<="18446744073709551615";return e?t:(mt(t),ht(st,ut))}function jt(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=At(Number(t)),bt(e)?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=Ct(t)),t;if("number"===e)return function(t){if(t=At(t),!bt(t)){ft(t);var e=st,r=ut;(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}(t)}}function Ot(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(vt(64,t));if(Bt(t)){if("string"===e)return e=At(Number(t)),bt(e)&&e>=0?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=Tt(t)),t;if("number"===e)return function(t){return(t=At(t))>=0&&bt(t)||(ft(t),t=ct(st,ut)),t}(t)}}function Ft(t){if(null==t||"string"==typeof t||t instanceof g)return t}function Ut(t){return null==t||"string"==typeof t?t:void 0}function kt(t){return t}function Mt(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=(Et??kt)(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 Rt(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[L];return 0===t.length&&1&e?void 0:Mt(t,e,Rt)}if(null!=t&&t[R]===W)return Pt(t);if(t instanceof g){if(null==(e=t.h))t="";else if("string"==typeof e)t=e;else{if(f){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),u(),r=o[r],n=Array(Math.floor(e.length/3)),i=r[64]||"";let t=0,f=0;for(;t<e.length-2;t+=3){var a=e[t],s=e[t+1],l=e[t+2],c=r[a>>2];a=r[(3&a)<<4|s>>4],s=r[(15&s)<<2|l>>6],l=r[63&l],n[f++]=c+a+s+l}switch(c=0,l=i,e.length-t){case 2:l=r[(15&(c=e[t+1]))<<2]||i;case 1:e=e[t],n[f]=r[e>>2]+r[(3&e)<<4|c>>4]+l+i}e=n.join("")}t=t.h=e}return t}return}return t}function Pt(t){return Mt(t=t.l,0|t[L],Rt)}function Dt(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[L],w&&1&i)throw Error("rfarr");if(2048&i&&!(2&i)&&function(){if(w)throw Error("carr");S(M,5)}(),256&i)throw Error("farr");if(64&i)return(i|n)!==i&&$(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 a=o-1;let t=r[a];if(null!=t&&"object"==typeof t&&t.constructor===Object){if((a-=e=128&i?0:-1)>=1024)throw Error("pvtlmt");for(var s in t)(o=+s)<a&&(r[o+e]=t[s],delete t[s]);i=-16760833&i|(1023&a)<<14;break t}}if(e){if((s=Math.max(e,o-(128&i?0:-1)))>1024)throw Error("spvt");i=-16760833&i|(1023&s)<<14}}}return $(t,64|i|n),t}function Lt(t,e){if("object"!=typeof t)return t;if(Array.isArray(t)){var r=0|t[L];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}if(null!=t&&t[R]===W){let n=0|(r=t.l)[L];return J(t,n)||(2&n?e=!0:32&n&&!(4096&n)?($(r,2|n),t.h=V,e=!0):e=!1,e?(t=new t.constructor(r)).j=V:t=zt(r,n)),t}return t instanceof g?t:void 0}function zt(t,e,r,n){return n??=!!(34&e),t=Mt(t,e,Lt,n),n=32,r&&(n|=2),$(t,e=16769217&e|n),t}function Gt(t){if(t.h!==V)return!1;var e=t.l;return G(e=zt(e,0|e[L]),2048),t.l=e,t.h=void 0,t.j=void 0,!0}function $t(t){if(!Gt(t)&&J(t,0|t.l[L]))throw Error()}function Ht(t,e){void 0===e&&(e=0|t[L]),32&e&&!(4096&e)&&$(t,4096|e)}function Wt(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 Jt(t,e,r){$t(t);var n=t.l;return Vt(n,0|n[L],e,r),t}function Vt(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[L])>>14&1023||536870912)?null!=n&&(t[a+(i?0:-1)]={[r]:n}):t[o]=n),e)}function qt(t,e,r){return t=Wt(t,e,r),Array.isArray(t)?t:O}function Kt(t){return!!(2&t)&&!!(4&t)||!!(256&t)}function Xt(t){if(T)return t[U]??(t[U]=new Map);if(U in t)return t[U];var e=new Map;return Object.defineProperty(t,U,{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!=Wt(e,o)&&(0!==i&&(r=Vt(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 Jt(t,e,r=Yt(r)),r&&!J(r)&&Ht(t.l),t}function te(t,e,r){var n=yn;t:{var i=r=Yt(r);$t(t);let s=t.l;var o=0|s[L];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=Vt(a,o,r)),t.set(n,e))}Vt(s,o,e,i)}return r&&!J(r)&&Ht(t.l),t}function ee(t,e){return-273&(2&e?2|t:-3&t)}function re(t,e){var r=sn;$t(t);var n=t.l,i=n,o=0|n[L],a=(t?J(t,o):2&o)?1:2;2===a&&t&&Gt(t)&&(o=0|(i=t.l)[L]);var s=qt(i,8),u=s===O?7:0|s[L],l=H(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[R]!==W)if(Array.isArray(c)){let t,e=0|c[L];t=e|32&d,t|=2&d,t!==e&&$(c,t),c=new h(c)}else c=void 0;c instanceof r&&(t||(h=J(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&&($(s,l),2&l&&Object.freeze(s)),l=u=l,(f=Kt(u))&&2===a&&(s=Array.prototype.slice.call(s),l=0,u=ee(u,o),o=Vt(i,o,8,s),f=!1),f||(1===a||4===a&&(2&u||!(16&u)&&32&o)?((u|=!s.length||t&&!(4096&u)||32&o&&!(4096&u||16&u)?2:256)!==l&&$(s,u),Object.freeze(s)):u!==l&&$(s,u)),2&u||!(4096&u||16&u)||Ht(i,o),a=s,e=null!=e?e:new r,a.push(e),t=r=a===O?7:0|a[L],(e=J(e))?(r&=-9,1===a.length&&(r&=-4097)):r|=4096,r!==t&&$(a,r),e||Ht(n)}function ne(t,e,r){return Jt(t,e,null==r?r:function(t){if(!Bt(t))throw E("int64");switch(typeof t){case"string":var e=At(Number(t));return bt(e)?t=Q(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=C()?Q(gt(64,BigInt(t))):Q(Ct(t))),t;case"bigint":return Q(gt(64,t));default:return bt(t)||(t=At(t),bt(t)?t=String(t):(ft(t),t=pt())),Q(t)}}(r))}function ie(t,e,r){return Jt(t,e,null==r?r:function(t){if(!Bt(t))throw E("uint64");switch(typeof t){case"string":var e=At(Number(t));return bt(e)&&e>=0?t=Q(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=C()?Q(vt(64,BigInt(t))):Q(Tt(t))),t;case"bigint":return Q(vt(64,t));default:return t>=0&&bt(t)||((t=At(t))>=0&&bt(t)?t=String(t):(ft(t),t=ht(st,ut))),Q(t)}}(r))}function oe(t,e,r){if(null!=r&&"string"!=typeof r)throw Error();return Jt(t,e,r)}function ae(t,e,r){if(null!=r){if(!wt(r))throw E("enum");r|=0}return Jt(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(p(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===g){v(y);var e=t.h;return e=(null==(e=null==e||l&&null!=e&&e instanceof Uint8Array?e:"string"==typeof e?p(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)?(mt(t),new he(st,ut)):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)?(mt(t),new Ee(st,ut)):null:me||=new Ee(0,0)}var me,ye,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||(ye=BigInt(Number.MIN_SAFE_INTEGER),ge=BigInt(Number.MAX_SAFE_INTEGER),ve=BigInt(4294967295),be=BigInt(32)),t>=ye&&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 Ne(t,e){for(;e>127;)t.h.push(127&e|128),e>>>=7;t.h.push(e)}function Be(t,e){if(e>=0)Ne(t,e);else{for(let r=0;r<9;r++)t.h.push(127&e|128),e>>=7;t.h.push(1)}}function _e(t,e){mt(e),function(t){var e=ut>>31;t(st<<1^e,(ut<<1|st>>>31)^e)}((e,r)=>{xe(t,e>>>0,r>>>0)})}function Ce(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 Te=class{constructor(){this.h=[]}length(){return this.h.length}end(){var t=this.h;return this.h=[],t}};function je(t,e){0!==e.length&&(t.j.push(e),t.i+=e.length)}function Oe(t,e,r){Ne(t.h,8*e+r)}function Fe(t,e){return Oe(t,e,2),e=t.h.end(),je(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,ft(r),xe(t,st,ut);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),Ne(t.h,r.length),je(t,t.h.end()),je(t,r)}var Re=class{constructor(){this.j=[],this.i=0,this.h=new Te}};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(),Ve=De(),qe=De(),Ke=De(),Xe=De(),Ze=De(),Ye=class{constructor(t,e){this.l=Dt(t,e,void 0,2048)}toJSON(){return Pt(this)}};Ye.prototype[R]=W,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 St||=[0,void 0,!0];case"number":return t>0?void 0:0===t?xt||=[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)?Dt(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[L],(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||S(k,3)}})}function dr(t,e,r){if(Array.isArray(e)){var n=0|e[L];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&&$(e,t),r&&2&t&&Object.freeze(e),e}}var pr=(t,e)=>{var r=new Re;hr(t.l,r,sr(e)),je(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 mr(t,e){return new Qe(t,e)}function yr(t,e){return new Qe(t,e)}function gr(t,e,r){null!=(e=jt(e))&&(Pe(e),ke(t,r,e))}function vr(t,e,r){null!=(e=_t(e))&&null!=e&&(Oe(t,r,0),Be(t.h,e))}function br(t,e,r){null!=(e=Ut(e))&&Me(t,r,n(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=Ft(e))&&Me(t,r,ue(e).buffer)}function Ir(t,e,r){null!=(e=_t(e))&&(e=parseInt(e,10),Oe(t,r,0),Be(t.h,e))}var Er,Sr=mr(function(t,e,r){null!=(e=It(e))&&(Oe(t,r,1),t=t.h,(r=at||=new DataView(new ArrayBuffer(8))).setFloat64(0,+e,!0),st=r.getUint32(0,!0),ut=r.getUint32(4,!0),Ce(t,st),Ce(t,ut))},Ke),xr=mr(function(t,e,r){null!=(e=It(e))&&(Oe(t,r,5),t=t.h,(r=at||=new DataView(new ArrayBuffer(8))).setFloat32(0,+e,!0),ut=0,Ce(t,st=r.getUint32(0,!0)))},qe),Nr=mr(gr,We),Br=mr(gr,We),_r=yr(function(t,e,r){if(null!=(e=dr(jt,e,!1)))for(let n=0;n<e.length;n++)ke(t,r,e[n])},We),Cr=mr(function(t,e,r){if(null!=(e=Ot(e))){if("string"==typeof e)fe(e);if(null!=e)switch(Oe(t,r,0),typeof e){case"number":t=t.h,ft(e),xe(t,st,ut);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),Tr=mr(vr,$e),jr=yr(function(t,e,r){if(null!=(e=dr(_t,e,!0)))for(let a=0;a<e.length;a++){var n=t,i=r,o=e[a];null!=o&&(Oe(n,i,0),Be(n.h,o))}},$e),Or=yr(function(t,e,r){if(null!=(e=dr(_t,e,!0))&&e.length){r=Fe(t,r);for(let r=0;r<e.length;r++)Be(t.h,e[r]);Ue(t,r)}},$e),Fr=mr(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=mr(br,Ge),kr=yr(function(t,e,r){if(null!=(e=dr(Ut,e,!0)))for(let s=0;s<e.length;s++){var i=t,o=r,a=e[s];null!=a&&Me(i,o,n(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[L])||$(e,1|t)}}),Rr=new Qe(wr,Le),Pr=mr(Ar,Xe),Dr=yr(function(t,e,r){if(null!=(e=dr(Ft,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=mr(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&&(Oe(t,r,0),Ne(t.h,e))},He),zr=mr(Ir,Ze),Gr=mr(Ir,Ze),$r=mr(function(t,e,r){if(null!=(e=jt(e))&&(Pe(e),null!=e))switch(Oe(t,r,0),typeof e){case"number":t=t.h,e=(r=e)<0,lt(r=2*Math.abs(r)),r=st;let n=ut;e&&(0==r?0==n?n=r=4294967295:(n--,r=4294967295):r--),xe(t,st=r,ut=n);break;case"bigint":t=t.h,e=e<<BigInt(1)^e>>BigInt(63),st=Number(BigInt.asUintN(32,e)),ut=Number(BigInt.asUintN(32,e>>BigInt(32))),xe(t,st,ut);break;default:_e(t.h,e)}},Ve),Hr=[0,Pr,Dr,Fr,Ur],Wr=[0,mr(br,Ge),[0,Gr,[0,mr(gr,We),mr(vr,$e)],Gr,-1,[0,zr],Gr,-1],mr(Ar,Xe)],Jr=[0,1,[0,12,Tr,10,Fr],[0,7,[0,Tr,-1]]],Vr=globalThis.trustedTypes;var qr=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(!Vr)return t;try{let e=t=>t;t=Vr.createPolicy("goog#html",{createHTML:e,createScript:e,createScriptURL:e})}catch(t){}return t}()),t=(e=Er)?e.createScriptURL(t):t,new qr(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=class{constructor(){this.h=!1,this.i=[]}};function nn(t,e,r){return r=`wasm${r?"_module":""}_internal`,Promise.resolve({wasmLoaderPath:`${e}/${t}_${r}.js`,wasmBinaryPath:`${e}/${t}_${r}.wasm`})}var on=class{};function an(t){return ae(new sn,1,t)}on.forVisionTasks=function(t,e=!1){return nn("vision",t??Xr``,e)},on.forLiteRtLmTextTasks=function(t,e=!1){return nn("litertlm_text",t??Xr``,e)},on.forTextTasks=function(t,e=!1){return nn("text",t??Xr``,e)},on.forRetrievalTasks=function(t,e=!1){return nn("retrieval",t??Xr``,e)},on.forGenAiTasks=function(t,e=!1){return nn("genai",t??Xr``,e)},on.forDecisionTasks=function(t,e=!1){return nn("decision",t??Xr``,e)},on.forAudioTasks=function(t,e=!1){return nn("audio",t??Xr``,e)};var sn=class extends Ye{constructor(t){super(t)}},un=class extends Ye{constructor(t){super(t)}},ln=[0,zr,2,Cr,-2,Br,Mr,[0,zr,Br]],fn=class extends Ye{constructor(t){super(t)}},cn=class extends Ye{constructor(t){super(t)}};function hn(t,e){return ae(t,1,e)}function dn(t,e){return ae(t,2,e)}var pn,mn=class extends Ye{constructor(t){super(t)}},yn=[3,4,5,6,7],gn=class extends Ye{constructor(t){super(t)}},vn=class extends Ye{constructor(t){super(t)}};vn.prototype.i=(pn=[0,[0,zr,Ur,-3,zr],[0,yn,zr,-1,Rr,[0,zr,Ur,Cr],Rr,ln,Rr,[0,1,ln],Rr,[0,zr],Rr,[0,zr,Ur,Cr]]],function(){return pr(this,pn)});var bn=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)}}},wn=class extends Ye{constructor(t){super(t,37)}},An=[-4,{},Jr,zr,Wr],In=[0,Ur,zr,1,Ur,-1,zr,1,zr,1,Br],En=[0,zr,Ur,-2],Sn=[0,Ur,zr],xn=[0,Ur,zr],Nn=[0,Fr,-3],Bn=[0,zr,Ur,-1,Br,Tr,-1,Ur,-5,Mr,[0,Ur,-4],-1,Fr,[0,Fr,-3],zr];var _n=class extends Ye{constructor(t){super(t,19)}},Cn=function(t){return e=>pr(e,t)}([-19,{},[0,zr,1,[0,Ur,-6,Br,Tr,Ur,-1,Br],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,Tr,-2]],Br,[0,Ur,-3,Br,Tr,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,Tr,-1],1,[0,zr],1,[0,Ur,-4],1,In,[0,[1,2,3,4,5,6],Rr,In,Rr,Sn,Rr,xn,Rr,[0,zr],Rr,Bn,Rr,En],Sn,xn,Bn,[0,[0,zr,Ur,-1,Br,Tr,-1,Ur,-4,Mr,[0,Ur,-4],-1,1,Nn],[0,zr,Ur,-1,Br,Tr,-1,Ur,-4,Nn]],En,[0,Ur,[0,Tr,-3,zr],zr,-2,[0,Tr,-1],Fr],4,[0,Ur,zr,Ur,-1,Br,zr,Ur,-1,zr,Tr,-1]],zr,Mr,[-37,{},Nr,Ur,Mr,[0,Ur,-1],Pr,1,Pr,[0,kr,-1,jr,_r,-1],Ur,[0,Tr,Ur,-1],Fr,Tr,Br,Ur,-1,$r,Hr,Nr,Pr,zr,jr,Br,-1,[0,zr,-1],Ur,Fr,Ur,Or,Ur,-1,Sr,1,Sr,An,Fr,[0,zr,[0,xr,Tr,-2],[0,xr]],[0,zr,Br]],Nr,Dr,Ur,-1,Nr,zr,-1,[0,Fr,-1,zr,Fr],[0,Br,-1,Ur],[0,Nr,Fr,Br],Br,1,Lr,1,An]),Tn=class{constructor(t){this.i=[],this.m=new bn,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 _n;$t(e=ae(e,2,1786));var r=e.l,n=0|r[L];if(null==t)Vt(r,n,3);else{var i=t===O?7:0|t[L],o=i,a=Kt(i),s=a||Object.isFrozen(t),u=!0,l=!0;for(let e=0;e<t.length;e++){var f=t[e];a||(f=J(f),u&&=!f,l&&=f)}a||(i=u?13:5,i=l?-4097&i:4096|i),s&&i===o||(t=Array.prototype.slice.call(t),o=0,i=ee(i,n)),i!==o&&$(t,i),n=Vt(r,n,3,t),2&i||!(4096&i||16&i)||Ht(r,n)}return e}(r),r=Cn(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 jn{constructor(){this.I=this.B=this.G=this.A=this.D=this.F=this.C=0}}function On(t,e){var r=new vn;if(r=Qt(r,1,t.R),r=Qt(r,2,e),e=new wn,null!=(r=r.i()))if("string"==typeof r)r=r?new g(r,y):m||=new g(null,y);else if(!(r instanceof g)){if(!(l&&null!=r&&r instanceof Uint8Array))throw Error();r=r.length?new g(new Uint8Array(r),y):m||=new g(null,y)}e=Jt(e,6,r),(t=t.H).error||t.i.push(e)}function Fn(t){var e=new cn;e=ie(e=ae(e,1,10),3,performance.now()-t.P),On(t,e=te(dn(hn(new mn,t.v),0),3,e)),t.m=performance.now()}function Un(t,e){++t.h.F,t.i.set(e,performance.now())}function kn(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=dn(hn(new mn,t.v),1);On(t,n=te(n,4,r=Rn(r))),t.j=e}function Mn(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(),kn(t,r)}}function Rn(t){var e=new un;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=an(3);re(e,r=ne(r,2,t.C))}return 0!==t.F&&re(e,t=ne(r=an(4),2,t.F)),e}function Pn(t){var e={...t.h,A:t.h.A+t.i.size,B:t.u,I:performance.now()-t.P};kn(t,e);var r=new fn;r=Qt(r,2,e=Rn(e)),On(t,r=te(e=dn(hn(new mn,t.v),2),5,r))}var Dn=class{constructor(t,e){this.P=performance.now(),this.m=performance.now(),this.i=new Map,this.u=0,this.h=new jn,this.j=new jn,this.H=new Tn(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;case"TextSummarizer":return 26;case"TextProofreader":return 27;case"AudioTranscriber":return 31;case"TextToSpeech":return 32;default:return 0}}(t),t=new gn,"undefined"==typeof navigator?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.2.1"),t=oe(t,5,""),this.R=ae(t,6,function(){var t=globalThis.__HOST_ENVIRONMENT__;if("string"==typeof t)switch(t){case"ANDROID":return 1;case"IOS":return 2;case"PYTHON":return 3;case"WEB":break;case"FLUTTER":return 5;case"FLUTTER_WEB":return 6;default:return 0}return 4}())}close(){var t=this.H;"function"==typeof t.close?t.close():t.flush()}};function Ln(t){var e=atob("QUl6YVN5QS1XbGdRNjczMWpZSThjWGhKNEFxZjhuX3J1UmNLMzJZ");return new Dn(t,e)}async function zn(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 Gn=async(t,e,r,n)=>{if(e&&await zn(e),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(r&&(await zn(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)},$n={CHARACTER:0,WORD:1};function Hn(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 Wn(t,e,r,n="CHARACTER"){Hn(e,r),t.j=e,t.i=r,t.mode=n}var Jn=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,$n[this.mode]??0))?Array.from(t):[]}};function Vn(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]}:{}}}Jn.prototype.chunk=Jn.prototype.chunk,Jn.createFromModule=function(t,e=512,r=100,n="CHARACTER"){return Hn(e,r),Wn(t=new Jn(t),e,r,n),t},Jn.create=async function(t,e=512,r=100,n="CHARACTER"){Hn(e,r);var i=await Gn(Jn,t.wasmLoaderPath,t.assetLoaderPath,{locateFile:e=>e.endsWith(".wasm")?t.wasmBinaryPath.toString():e});return Wn(i,e,r,n),i};var qn=class{constructor(){this.h=new Map}upsert(t){for(let e of t)this.h.set(e.id,Vn(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=>Vn(t.da))}get(t){var e=[];for(let r of t)(t=this.h.get(r))&&e.push(Vn(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()}};qn.prototype.close=qn.prototype.close,qn.prototype.deleteAll=qn.prototype.deleteAll,qn.prototype.getAllRecordIds=qn.prototype.getAllRecordIds,qn.prototype.get=qn.prototype.get,qn.prototype.search=qn.prototype.search,qn.prototype.deleteByMetadata=qn.prototype.deleteByMetadata,qn.prototype.delete=qn.prototype.delete,qn.prototype.upsert=qn.prototype.upsert;var Kn=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 Xn(t){if(t.i)throw Error("SemanticRetriever has already been closed.")}Kn.prototype.textChunker=Kn.prototype.L,Kn.prototype.setTextChunker=Kn.prototype.ha,Kn.prototype.vectorStore=Kn.prototype.o,Kn.prototype.setVectorStore=Kn.prototype.ia,Kn.prototype.providers=Kn.prototype.M,Kn.prototype.addProvider=Kn.prototype.S;var Zn=class{constructor(t,e,r){this.m=t,this.o=e,this.L=r,this.i=!1,this.j=0,this.h=Ln("SemanticRetriever"),Fn(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 Xn(this),this.K(t,[{text:e}],r)}async K(t,e,r){Xn(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 Xn(this),this.K(t,[{imageBytes:e}],r)}async Y(t,e,r){return Xn(this),this.K(t,[{audioData:e}],r)}async ga(t,e={}){Xn(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 Mn(this.h,e),u}async delete(t){Xn(this),"string"==typeof t?await this.o.delete([t]):Array.isArray(t)?await this.o.delete(t):await this.o.deleteByMetadata(t)}async getAllRecordIds(){Xn(this);var t=await this.o.getAllRecordIds();return Array.from(new Set(t))}async deleteAll(){Xn(this),await this.o.deleteAll()}close(){if(!this.i){this.i=!0,Pn(this.h),this.h.close();try{this.o.close()}catch{}}}};async function Yn(t,e){var r=e.baseOptions.device;r||=await Qn();var n=await Gn(ri,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=Ln("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 Qn()),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_${++ni}.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),Fn(t.i)}catch(e){throw ti(t),e}}(n,e,r),n}async function Qn(){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 ti(t){if(t.v){try{t.h.FS_unlink?.(t.v)}catch{}t.v=void 0}}function ei(t){if(t.H||0===t.j)throw Error("UniversalEmbedder has already been closed.")}Zn.prototype.close=Zn.prototype.close,Zn.prototype.deleteAll=Zn.prototype.deleteAll,Zn.prototype.getAllRecordIds=Zn.prototype.getAllRecordIds,Zn.prototype.delete=Zn.prototype.delete,Zn.prototype.retrieve=Zn.prototype.ga,Zn.prototype.insertAudio=Zn.prototype.Y,Zn.prototype.insertImage=Zn.prototype.aa,Zn.prototype.insertContent=Zn.prototype.K,Zn.prototype.insertDocument=Zn.prototype.Z,Zn.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 Zn(t,e,r)};var ri=class{constructor(t){this.H=!1,this.j=0,this.u=new rn,this.m=0,this.h=t}async V(t){return en(this.u,async()=>{ei(this);var e=this.m++;Un(this.i,e);var r=await this.h.universalEmbedder_embedText(this.j,t);return Mn(this.i,e),{embeddings:[{floatEmbedding:r?Array.from(r):[],headIndex:0,headName:"default"}]}})}async U(t){return en(this.u,async()=>{ei(this);var e=this.m++;Un(this.i,e);var r=await this.h.universalEmbedder_embedImage(this.j,t);return Mn(this.i,e),{embeddings:[{floatEmbedding:r?Array.from(r):[],headIndex:0,headName:"default"}]}})}async T(t){return en(this.u,async()=>{ei(this);var e=this.m++;Un(this.i,e);var r=await this.h.universalEmbedder_embedAudio(this.j,t);return Mn(this.i,e),{embeddings:[{floatEmbedding:r?Array.from(r):[],headIndex:0,headName:"default"}]}})}async embedContent(t){if(ei(this),!Array.isArray(t))throw Error("Content must be an array of ContentParts.");return en(this.u,async()=>{ei(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++;Un(this.i,r);let n=await this.h.universalEmbedder_executeEmbedContent(this.j,e);return Mn(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,Pn(this.i),this.i.close(),0!==this.j&&(this.h.universalEmbedder_close(this.j),this.j=0),ti(this))}};ri.prototype.close=ri.prototype.close,ri.prototype.getProvider=ri.prototype.X,ri.cosineSimilarity=function(t,e){return Zr(t,e)},ri.prototype.embedContent=ri.prototype.embedContent,ri.prototype.embedAudio=ri.prototype.T,ri.prototype.embedImage=ri.prototype.U,ri.prototype.embedText=ri.prototype.V,ri.createFromModelPath=function(t,e){return Yn(t,{baseOptions:{modelAssetPath:e.toString()}})},ri.createFromModelBuffer=function(t,e){return Yn(t,{baseOptions:{modelAssetBuffer:e}})},ri.createWebGpuDevice=Qn,ri.createFromOptions=Yn;var ni=0;exports.DefaultTextChunker=Jn,exports.FilesetResolver=on,exports.MemoryVectorStore=qn,exports.SemanticRetriever=Zn,exports.SemanticRetrieverComponents=Kn,exports.UniversalEmbedder=ri;
2
2
  //# sourceMappingURL=retrieval_bundle_cjs.js.map