@mediapipe/tasks-retrieval 1.2.1-rc.20261102 → 1.2.2-rc.20261103
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/NOTICE +246 -0
- 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.js.map +1 -1
- package/retrieval_bundle.mjs +1 -1
- package/retrieval_bundle.mjs.map +1 -1
- package/wasm/retrieval_wasm_internal.js +47 -45
- package/wasm/retrieval_wasm_internal.wasm +0 -0
- package/wasm/retrieval_wasm_module_internal.js +47 -45
- package/wasm/retrieval_wasm_module_internal.wasm +0 -0
package/NOTICE
CHANGED
|
@@ -9922,6 +9922,252 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
9922
9922
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
9923
9923
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
9924
9924
|
|
|
9925
|
+
=================
|
|
9926
|
+
highway
|
|
9927
|
+
This project is dual-licensed under your choice of either the Apache
|
|
9928
|
+
License 2.0 or the BSD 3-Clause License.
|
|
9929
|
+
|
|
9930
|
+
The full texts of all applicable licenses are included below, separated by
|
|
9931
|
+
'---'.
|
|
9932
|
+
|
|
9933
|
+
--------------------------------------------------------------------------------
|
|
9934
|
+
Apache License 2.0
|
|
9935
|
+
--------------------------------------------------------------------------------
|
|
9936
|
+
|
|
9937
|
+
Apache License
|
|
9938
|
+
Version 2.0, January 2004
|
|
9939
|
+
http://www.apache.org/licenses/
|
|
9940
|
+
|
|
9941
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
9942
|
+
|
|
9943
|
+
1. Definitions.
|
|
9944
|
+
|
|
9945
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
9946
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
9947
|
+
|
|
9948
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
9949
|
+
the copyright owner that is granting the License.
|
|
9950
|
+
|
|
9951
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
9952
|
+
other entities that control, are controlled by, or are under common
|
|
9953
|
+
control with that entity. For the purposes of this definition,
|
|
9954
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
9955
|
+
direction or management of such entity, whether by contract or
|
|
9956
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
9957
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
9958
|
+
|
|
9959
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
9960
|
+
exercising permissions granted by this License.
|
|
9961
|
+
|
|
9962
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
9963
|
+
including but not limited to software source code, documentation
|
|
9964
|
+
source, and configuration files.
|
|
9965
|
+
|
|
9966
|
+
"Object" form shall mean any form resulting from mechanical
|
|
9967
|
+
transformation or translation of a Source form, including but
|
|
9968
|
+
not limited to compiled object code, generated documentation,
|
|
9969
|
+
and conversions to other media types.
|
|
9970
|
+
|
|
9971
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
9972
|
+
Object form, made available under the License, as indicated by a
|
|
9973
|
+
copyright notice that is included in or attached to the work
|
|
9974
|
+
(an example is provided in the Appendix below).
|
|
9975
|
+
|
|
9976
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
9977
|
+
form, that is based on (or derived from) the Work and for which the
|
|
9978
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
9979
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
9980
|
+
of this License, Derivative Works shall not include works that remain
|
|
9981
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
9982
|
+
the Work and Derivative Works thereof.
|
|
9983
|
+
|
|
9984
|
+
"Contribution" shall mean any work of authorship, including
|
|
9985
|
+
the original version of the Work and any modifications or additions
|
|
9986
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
9987
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
9988
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
9989
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
9990
|
+
means any form of electronic, verbal, or written communication sent
|
|
9991
|
+
to the Licensor or its representatives, including but not limited to
|
|
9992
|
+
communication on electronic mailing lists, source code control systems,
|
|
9993
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
9994
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
9995
|
+
excluding communication that is conspicuously marked or otherwise
|
|
9996
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
9997
|
+
|
|
9998
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
9999
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
10000
|
+
subsequently incorporated within the Work.
|
|
10001
|
+
|
|
10002
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
10003
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
10004
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
10005
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
10006
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
10007
|
+
Work and such Derivative Works in Source or Object form.
|
|
10008
|
+
|
|
10009
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
10010
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
10011
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
10012
|
+
(except as stated in this section) patent license to make, have made,
|
|
10013
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
10014
|
+
where such license applies only to those patent claims licensable
|
|
10015
|
+
by such Contributor that are necessarily infringed by their
|
|
10016
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
10017
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
10018
|
+
institute patent litigation against any entity (including a
|
|
10019
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
10020
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
10021
|
+
or contributory patent infringement, then any patent licenses
|
|
10022
|
+
granted to You under this License for that Work shall terminate
|
|
10023
|
+
as of the date such litigation is filed.
|
|
10024
|
+
|
|
10025
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
10026
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
10027
|
+
modifications, and in Source or Object form, provided that You
|
|
10028
|
+
meet the following conditions:
|
|
10029
|
+
|
|
10030
|
+
(a) You must give any other recipients of the Work or
|
|
10031
|
+
Derivative Works a copy of this License; and
|
|
10032
|
+
|
|
10033
|
+
(b) You must cause any modified files to carry prominent notices
|
|
10034
|
+
stating that You changed the files; and
|
|
10035
|
+
|
|
10036
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
10037
|
+
that You distribute, all copyright, patent, trademark, and
|
|
10038
|
+
attribution notices from the Source form of the Work,
|
|
10039
|
+
excluding those notices that do not pertain to any part of
|
|
10040
|
+
the Derivative Works; and
|
|
10041
|
+
|
|
10042
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
10043
|
+
distribution, then any Derivative Works that You distribute must
|
|
10044
|
+
include a readable copy of the attribution notices contained
|
|
10045
|
+
within such NOTICE file, excluding those notices that do not
|
|
10046
|
+
pertain to any part of the Derivative Works, in at least one
|
|
10047
|
+
of the following places: within a NOTICE text file distributed
|
|
10048
|
+
as part of the Derivative Works; within the Source form or
|
|
10049
|
+
documentation, if provided along with the Derivative Works; or,
|
|
10050
|
+
within a display generated by the Derivative Works, if and
|
|
10051
|
+
wherever such third-party notices normally appear. The contents
|
|
10052
|
+
of the NOTICE file are for informational purposes only and
|
|
10053
|
+
do not modify the License. You may add Your own attribution
|
|
10054
|
+
notices within Derivative Works that You distribute, alongside
|
|
10055
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
10056
|
+
that such additional attribution notices cannot be construed
|
|
10057
|
+
as modifying the License.
|
|
10058
|
+
|
|
10059
|
+
You may add Your own copyright statement to Your modifications and
|
|
10060
|
+
may provide additional or different license terms and conditions
|
|
10061
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
10062
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
10063
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
10064
|
+
the conditions stated in this License.
|
|
10065
|
+
|
|
10066
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
10067
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
10068
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
10069
|
+
this License, without any additional terms or conditions.
|
|
10070
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
10071
|
+
the terms of any separate license agreement you may have executed
|
|
10072
|
+
with Licensor regarding such Contributions.
|
|
10073
|
+
|
|
10074
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
10075
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
10076
|
+
except as required for reasonable and customary use in describing the
|
|
10077
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
10078
|
+
|
|
10079
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
10080
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
10081
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
10082
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
10083
|
+
implied, including, without limitation, any warranties or conditions
|
|
10084
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
10085
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
10086
|
+
appropriateness of using or redistributing the Work and assume any
|
|
10087
|
+
risks associated with Your exercise of permissions under this License.
|
|
10088
|
+
|
|
10089
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
10090
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
10091
|
+
unless required by applicable law (such as deliberate and grossly
|
|
10092
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
10093
|
+
liable to You for damages, including any direct, indirect, special,
|
|
10094
|
+
incidental, or consequential damages of any character arising as a
|
|
10095
|
+
result of this License or out of the use or inability to use the
|
|
10096
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
10097
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
10098
|
+
other commercial damages or losses), even if such Contributor
|
|
10099
|
+
has been advised of the possibility of such damages.
|
|
10100
|
+
|
|
10101
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
10102
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
10103
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
10104
|
+
or other liability obligations and/or rights consistent with this
|
|
10105
|
+
License. However, in accepting such obligations, You may act only
|
|
10106
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
10107
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
10108
|
+
defend, and hold each Contributor harmless for any liability
|
|
10109
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
10110
|
+
of your accepting any such warranty or additional liability.
|
|
10111
|
+
|
|
10112
|
+
END OF TERMS AND CONDITIONS
|
|
10113
|
+
|
|
10114
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
10115
|
+
|
|
10116
|
+
To apply the Apache License to your work, attach the following
|
|
10117
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
10118
|
+
replaced with your own identifying information. (Don't include
|
|
10119
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
10120
|
+
comment syntax for the file format. We also recommend that a
|
|
10121
|
+
file or class name and description of purpose be included on the
|
|
10122
|
+
same "printed page" as the copyright notice for easier
|
|
10123
|
+
identification within third-party archives.
|
|
10124
|
+
|
|
10125
|
+
Copyright [yyyy] [name of copyright owner]
|
|
10126
|
+
|
|
10127
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
10128
|
+
you may not use this file except in compliance with the License.
|
|
10129
|
+
You may obtain a copy of the License at
|
|
10130
|
+
|
|
10131
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10132
|
+
|
|
10133
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10134
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
10135
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10136
|
+
See the License for the specific language governing permissions and
|
|
10137
|
+
limitations under the License.
|
|
10138
|
+
|
|
10139
|
+
--------------------------------------------------------------------------------
|
|
10140
|
+
BSD 3-Clause License
|
|
10141
|
+
--------------------------------------------------------------------------------
|
|
10142
|
+
|
|
10143
|
+
Copyright (c) The Highway Project Authors. All rights reserved.
|
|
10144
|
+
|
|
10145
|
+
Redistribution and use in source and binary forms, with or without modification,
|
|
10146
|
+
are permitted provided that the following conditions are met:
|
|
10147
|
+
|
|
10148
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
10149
|
+
list of conditions and the following disclaimer.
|
|
10150
|
+
|
|
10151
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10152
|
+
this list of conditions and the following disclaimer in the documentation
|
|
10153
|
+
and/or other materials provided with the distribution.
|
|
10154
|
+
|
|
10155
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
10156
|
+
contributors may be used to endorse or promote products derived from
|
|
10157
|
+
this software without specific prior written permission.
|
|
10158
|
+
|
|
10159
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
10160
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
10161
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
10162
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
10163
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
10164
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
10165
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
10166
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
10167
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
10168
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
10169
|
+
|
|
10170
|
+
|
|
9925
10171
|
=================
|
|
9926
10172
|
ICU4C
|
|
9927
10173
|
UNICODE LICENSE V3
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mediapipe/tasks-retrieval",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2-rc.20261103",
|
|
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:{};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;
|
|
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])&&i.length>0&&(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,!0)}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.2"),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
|