@indxsearch/intrface 1.2.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, trademark, patent,
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2025 Indx Search
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/dist/index.es.js CHANGED
@@ -864,7 +864,7 @@ const Qt = ({
864
864
  )
865
865
  }
866
866
  );
867
- }, Rt = "_placeholder_mppwl_1", Mt = "_invalid_mppwl_10", Et = "_row_mppwl_14", Ft = "_indexNumber_mppwl_42", Nt = "_scoreNumber_mppwl_49", Me = {
867
+ }, Rt = "_placeholder_1k92x_1", Mt = "_invalid_1k92x_10", Et = "_row_1k92x_14", Ft = "_indexNumber_1k92x_38", Nt = "_scoreNumber_1k92x_45", Me = {
868
868
  placeholder: Rt,
869
869
  invalid: Mt,
870
870
  row: Et,
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(H,re){typeof exports=="object"&&typeof module<"u"?re(exports,require("@indxsearch/systm/styles.css"),require("react"),require("@indxsearch/systm")):typeof define=="function"&&define.amd?define(["exports","@indxsearch/systm/styles.css","react","@indxsearch/systm"],re):(H=typeof globalThis<"u"?globalThis:H||self,re(H.IndxIntrface={},null,H.React,H.systm))})(this,(function(H,re,s,f){"use strict";var kt=Object.defineProperty;var Et=(H,re,s)=>re in H?kt(H,re,{enumerable:!0,configurable:!0,writable:!0,value:s}):H[re]=s;var tt=(H,re,s)=>Et(H,typeof re!="symbol"?re+"":re,s);var Ve={exports:{}},Te={};/**
1
+ (function(H,re){typeof exports=="object"&&typeof module<"u"?re(exports,require("@indxsearch/systm/styles.css"),require("react"),require("@indxsearch/systm")):typeof define=="function"&&define.amd?define(["exports","@indxsearch/systm/styles.css","react","@indxsearch/systm"],re):(H=typeof globalThis<"u"?globalThis:H||self,re(H.IndxIntrface={},null,H.React,H.systm))})(this,(function(H,re,s,f){"use strict";var Ft=Object.defineProperty;var Et=(H,re,s)=>re in H?Ft(H,re,{enumerable:!0,configurable:!0,writable:!0,value:s}):H[re]=s;var tt=(H,re,s)=>Et(H,typeof re!="symbol"?re+"":re,s);var Ve={exports:{}},Te={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.js
4
4
  *
@@ -14,9 +14,9 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var De;function nt(){return De||(De=1,process.env.NODE_ENV!=="production"&&(function(){function r(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===ee?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case x:return"Fragment";case m:return"Profiler";case V:return"StrictMode";case w:return"Suspense";case v:return"SuspenseList";case Q:return"Activity"}if(typeof t=="object")switch(typeof t.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case L:return"Portal";case u:return t.displayName||"Context";case b:return(t._context.displayName||"Context")+".Consumer";case C:var a=t.render;return t=t.displayName,t||(t=a.displayName||a.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case z:return a=t.displayName||null,a!==null?a:r(t.type)||"Memo";case J:a=t._payload,t=t._init;try{return r(t(a))}catch{}}return null}function i(t){return""+t}function g(t){try{i(t);var a=!1}catch{a=!0}if(a){a=console;var j=a.error,_=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return j.call(a,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",_),i(t)}}function o(t){if(t===x)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===J)return"<...>";try{var a=r(t);return a?"<"+a+">":"<...>"}catch{return"<...>"}}function d(){var t=I.A;return t===null?null:t.getOwner()}function S(){return Error("react-stack-top-frame")}function y(t){if(ge.call(t,"key")){var a=Object.getOwnPropertyDescriptor(t,"key").get;if(a&&a.isReactWarning)return!1}return t.key!==void 0}function p(t,a){function j(){U||(U=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",a))}j.isReactWarning=!0,Object.defineProperty(t,"key",{get:j,configurable:!0})}function n(){var t=r(this.type);return pe[t]||(pe[t]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),t=this.props.ref,t!==void 0?t:null}function k(t,a,j,_,ie,me){var O=j.ref;return t={$$typeof:ne,type:t,key:a,props:j,_owner:_},(O!==void 0?O:null)!==null?Object.defineProperty(t,"ref",{enumerable:!1,get:n}):Object.defineProperty(t,"ref",{enumerable:!1,value:null}),t._store={},Object.defineProperty(t._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(t,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(t,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:ie}),Object.defineProperty(t,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:me}),Object.freeze&&(Object.freeze(t.props),Object.freeze(t)),t}function R(t,a,j,_,ie,me){var O=a.children;if(O!==void 0)if(_)if($(O)){for(_=0;_<O.length;_++)T(O[_]);Object.freeze&&Object.freeze(O)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else T(O);if(ge.call(a,"key")){O=r(t);var se=Object.keys(a).filter(function(Fe){return Fe!=="key"});_=0<se.length?"{key: someKey, "+se.join(": ..., ")+": ...}":"{key: someKey}",N[O+_]||(se=0<se.length?"{"+se.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
17
+ */var De;function nt(){return De||(De=1,process.env.NODE_ENV!=="production"&&(function(){function r(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===ee?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case x:return"Fragment";case m:return"Profiler";case V:return"StrictMode";case w:return"Suspense";case v:return"SuspenseList";case Q:return"Activity"}if(typeof t=="object")switch(typeof t.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case L:return"Portal";case u:return t.displayName||"Context";case b:return(t._context.displayName||"Context")+".Consumer";case C:var a=t.render;return t=t.displayName,t||(t=a.displayName||a.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case z:return a=t.displayName||null,a!==null?a:r(t.type)||"Memo";case J:a=t._payload,t=t._init;try{return r(t(a))}catch{}}return null}function i(t){return""+t}function g(t){try{i(t);var a=!1}catch{a=!0}if(a){a=console;var j=a.error,_=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return j.call(a,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",_),i(t)}}function o(t){if(t===x)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===J)return"<...>";try{var a=r(t);return a?"<"+a+">":"<...>"}catch{return"<...>"}}function d(){var t=I.A;return t===null?null:t.getOwner()}function S(){return Error("react-stack-top-frame")}function y(t){if(ge.call(t,"key")){var a=Object.getOwnPropertyDescriptor(t,"key").get;if(a&&a.isReactWarning)return!1}return t.key!==void 0}function p(t,a){function j(){U||(U=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",a))}j.isReactWarning=!0,Object.defineProperty(t,"key",{get:j,configurable:!0})}function n(){var t=r(this.type);return pe[t]||(pe[t]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),t=this.props.ref,t!==void 0?t:null}function F(t,a,j,_,ie,me){var O=j.ref;return t={$$typeof:ne,type:t,key:a,props:j,_owner:_},(O!==void 0?O:null)!==null?Object.defineProperty(t,"ref",{enumerable:!1,get:n}):Object.defineProperty(t,"ref",{enumerable:!1,value:null}),t._store={},Object.defineProperty(t._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(t,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(t,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:ie}),Object.defineProperty(t,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:me}),Object.freeze&&(Object.freeze(t.props),Object.freeze(t)),t}function R(t,a,j,_,ie,me){var O=a.children;if(O!==void 0)if(_)if($(O)){for(_=0;_<O.length;_++)T(O[_]);Object.freeze&&Object.freeze(O)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else T(O);if(ge.call(a,"key")){O=r(t);var se=Object.keys(a).filter(function(ke){return ke!=="key"});_=0<se.length?"{key: someKey, "+se.join(": ..., ")+": ...}":"{key: someKey}",N[O+_]||(se=0<se.length?"{"+se.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
18
  let props = %s;
19
19
  <%s {...props} />
20
20
  React keys must be passed directly to JSX without using spread:
21
21
  let props = %s;
22
- <%s key={someKey} {...props} />`,_,O,se,O),N[O+_]=!0)}if(O=null,j!==void 0&&(g(j),O=""+j),y(a)&&(g(a.key),O=""+a.key),"key"in a){j={};for(var ve in a)ve!=="key"&&(j[ve]=a[ve])}else j=a;return O&&p(j,typeof t=="function"?t.displayName||t.name||"Unknown":t),k(t,O,j,d(),ie,me)}function T(t){X(t)?t._store&&(t._store.validated=1):typeof t=="object"&&t!==null&&t.$$typeof===J&&(t._payload.status==="fulfilled"?X(t._payload.value)&&t._payload.value._store&&(t._payload.value._store.validated=1):t._store&&(t._store.validated=1))}function X(t){return typeof t=="object"&&t!==null&&t.$$typeof===ne}var E=s,ne=Symbol.for("react.transitional.element"),L=Symbol.for("react.portal"),x=Symbol.for("react.fragment"),V=Symbol.for("react.strict_mode"),m=Symbol.for("react.profiler"),b=Symbol.for("react.consumer"),u=Symbol.for("react.context"),C=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),v=Symbol.for("react.suspense_list"),z=Symbol.for("react.memo"),J=Symbol.for("react.lazy"),Q=Symbol.for("react.activity"),ee=Symbol.for("react.client.reference"),I=E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ge=Object.prototype.hasOwnProperty,$=Array.isArray,M=console.createTask?console.createTask:function(){return null};E={react_stack_bottom_frame:function(t){return t()}};var U,pe={},ue=E.react_stack_bottom_frame.bind(E,S)(),h=M(o(S)),N={};Ne.Fragment=x,Ne.jsx=function(t,a,j){var _=1e4>I.recentlyCreatedOwnerStacks++;return R(t,a,j,!1,_?Error("react-stack-top-frame"):ue,_?M(o(t)):h)},Ne.jsxs=function(t,a,j){var _=1e4>I.recentlyCreatedOwnerStacks++;return R(t,a,j,!0,_?Error("react-stack-top-frame"):ue,_?M(o(t)):h)}})()),Ne}var qe;function st(){return qe||(qe=1,process.env.NODE_ENV==="production"?Ve.exports=rt():Ve.exports=nt()),Ve.exports}var e=st();const ze=s.createContext(void 0);function ot(r,i){let g;const o=(...d)=>{clearTimeout(g),g=setTimeout(()=>r(...d),i)};return o.cancel=()=>clearTimeout(g),o}const at=({children:r,email:i,password:g,url:o,dataset:d,allowEmptySearch:S=!1,maxResults:y=10,facetDebounceDelayMillis:p=500,enableFacets:n=!0,coverageDepth:k=500,removeDuplicates:R=!0,enableCoverage:T=!0,initialCoverageSetup:X={},enableDebugLogs:E=!1,preAuthenticatedToken:ne})=>{const L=s.useRef(0),x=s.useRef(void 0),V=s.useRef(!1),m=s.useRef(!1),b=s.useRef(!1),[u,C]=s.useState({query:"",results:null,isLoading:!1,resultsSuppressed:!S,facetDebounceDelayMillis:p,filters:{},rangeFilters:{},facetStats:{},searchSettings:{maxNumberOfRecordsToReturn:y,coverageDepth:k,enableCoverage:T,removeDuplicates:R,minimumScore:0,showScore:!0,placeholderText:"Type to search",coverageSetup:{levenshteinMaxWordSize:20,minWordSize:2,coverageMinWordHitsAbs:1,coverageMinWordHitsRelative:0,coverageQLimitForErrorTolerance:5,coverageLcsErrorToleranceRelativeq:.2,coverWholeQuery:!0,coverWholeWords:!0,coverFuzzyWords:!0,coverJoinedWords:!0,coverPrefixSuffix:!0,truncate:!0,...X}}});s.useEffect(()=>{E&&console.log("SearchContext mounted on client")},[E]),s.useEffect(()=>{C(l=>({...l,facetDebounceDelayMillis:p}))},[p]);const[w,v]=s.useState(null),[z]=s.useState(n),J=s.useCallback((l,c={})=>{if(!w)throw new Error("No authentication token available");return fetch(l,{...c,headers:{...c.headers,Authorization:`Bearer ${w}`},credentials:"include"})},[w]),[Q,ee]=s.useState([]),[I,ge]=s.useState([]),[$,M]=s.useState([]),[U,pe]=s.useState(!0),[ue,h]=s.useState({}),[N,t]=s.useState({}),[a,j]=s.useState({}),[_,ie]=s.useState(""),[me,O]=s.useState(""),[se,ve]=s.useState({}),Fe=s.useRef(null),B=s.useCallback(l=>{C(c=>({...c,query:l,filters:{},rangeFilters:{},searchSettings:{...c.searchSettings,maxNumberOfRecordsToReturn:y}}))},[y]),W=s.useCallback(l=>{C(c=>({...c,facetDebounceDelayMillis:l}))},[]),Y=s.useCallback(l=>{C(c=>({...c,searchSettings:{...c.searchSettings,...l,coverageSetup:{...c.searchSettings.coverageSetup,...l.coverageSetup||{}}}}))},[]),ke=s.useCallback(l=>{b.current=!0,C(c=>({...c,searchSettings:{...c.searchSettings,maxNumberOfRecordsToReturn:l}}))},[]),Ee=s.useCallback((l,c)=>{C(F=>{const P={...F.filters},D=P[l]||[],G=D.includes(c)?D.filter(Z=>Z!==c):[...D,c];return G.length?P[l]=G:delete P[l],{...F,filters:P}})},[]),Me=s.useCallback((l,c,F)=>{C(P=>({...P,rangeFilters:{...P.rangeFilters,[l]:{min:c,max:F}}}))},[]),Ie=s.useCallback(()=>{C(l=>({...l,filters:{},rangeFilters:{}}))},[]),$e=s.useCallback((l,c)=>{C(F=>{const P={...F.filters},D={...F.rangeFilters};if(c!==void 0){const Z=(P[l]||[]).filter(ce=>ce!==c);Z.length>0?P[l]=Z:delete P[l]}else delete D[l];return{...F,filters:P,rangeFilters:D}})},[]),Ct=s.useCallback((l,c)=>{C(F=>({...F,sortBy:l||void 0,sortAscending:l?c:void 0}))},[]),Ge=s.useCallback(async(l,c,F)=>{if(l.length===0)return null;if(l.length===1)return l[0];let P=l[0];for(let D=1;D<l.length;D++){const G=await J(`${c}/api/CombineFilters/${F}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({A:P,B:l[D],useAndOperation:!0})});if(!G.ok){const Z=await G.json();throw console.error("CombineFilters failed:",Z),new Error("CombineFilters failed")}P=await G.json()}return P},[J]),Be=u.searchSettings.maxNumberOfRecordsToReturn,Xe=u.searchSettings.enableCoverage,Je=u.searchSettings.removeDuplicates,Qe=u.searchSettings.coverageDepth,Ye=u.searchSettings.minimumScore,Pe=u.sortBy,Oe=u.sortAscending,Ze=s.useMemo(()=>u.searchSettings.coverageSetup,[u.searchSettings.coverageSetup.levenshteinMaxWordSize,u.searchSettings.coverageSetup.minWordSize,u.searchSettings.coverageSetup.coverageMinWordHitsAbs,u.searchSettings.coverageSetup.coverageMinWordHitsRelative,u.searchSettings.coverageSetup.coverageQLimitForErrorTolerance,u.searchSettings.coverageSetup.coverageLcsErrorToleranceRelativeq,u.searchSettings.coverageSetup.coverWholeQuery,u.searchSettings.coverageSetup.coverWholeWords,u.searchSettings.coverageSetup.coverFuzzyWords,u.searchSettings.coverageSetup.coverJoinedWords,u.searchSettings.coverageSetup.coverPrefixSuffix,u.searchSettings.coverageSetup.truncate]),Ke=s.useCallback(async({enableFacets:l})=>{if(!w)return;const c=++L.current;C(F=>({...F,isLoading:!0}));try{const F=Object.entries(u.filters??{}),D=(await Promise.all(F.map(async([q,K])=>Promise.all(K.map(te=>J(`${o}/api/CreateValueFilter/${d}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({FieldName:q,Value:te})}).then(he=>he.json())))))).flat(),G=Object.entries(u.rangeFilters??{}),Z=await Promise.all(G.map(([q,{min:K,max:te}])=>J(`${o}/api/CreateRangeFilter/${d}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({FieldName:q,LowerLimit:K,UpperLimit:te})}).then(he=>he.json()))),ce=[...D,...Z].filter(q=>q&&typeof q.hashString=="string"),oe=await Ge(ce,o,d),xe=S||u.query.trim()!=="",Re={text:u.query,maxNumberOfRecordsToReturn:xe?Be:0,enableFacets:l,...oe?{filter:oe}:{},...Pe?{sortBy:Pe}:{},...Oe!==void 0?{sortAscending:Oe}:{},enableCoverage:Xe,removeDuplicates:Je,coverageDepth:Qe,coverageSetup:Ze};E&&console.log("[performSearch] request body:",JSON.stringify(Re,null,2));const Ce=await(await J(`${o}/api/Search/${d}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Re)})).json(),Se=Ce.truncationIndex??-1,be=Ce.records||[],we=be.map(q=>q.documentKey),A=be.map(q=>q.score);let ae=[];xe&&we.length>0&&(ae=(await(await J(`${o}/api/GetJson/${d}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(we)})).json()).map((te,he)=>({document:te,documentKey:we[he],score:A[he]})));let de={};if(l&&Ce.facets){for(const[q,K]of Object.entries(Ce.facets))if(Array.isArray(K)&&K.length>0){const te=K.map(he=>Number(he.key)).filter(he=>!isNaN(he));te.length>0&&(de[q]={min:Math.min(...te),max:Math.max(...te)})}}const _e=u.query!==_,wt=u.query!==me;let He=u.facetStats??{};if(_e?(He={...ue,...de},j(He),ie(u.query)):He={...a,...de},wt&&l){const q={...se};for(const[K,te]of Object.entries(de))q[K]=te;ve(q),O(u.query)}let Ae=Ce.facets;if(l&&(!Ae||Object.keys(Ae).length===0)){Ae={};for(const[q,K]of Object.entries(N))Ae[q]=K.map(te=>({key:te,value:null}))}if(c!==L.current)return;const Ft=ae.filter(q=>{const K=u.query.trim();return K===""||K.length===1?!0:q.score>=Ye});C(q=>({...q,results:Ft,resultsSuppressed:!xe,...l?{facets:Ae,facetStats:He}:{},isLoading:!1,truncationIndex:Se}))}catch(F){if(console.error("[Search] ❌ Search failed:",F),F instanceof TypeError&&F.message.includes("fetch")?(console.error("[Search] ❌ Network error - cannot reach INDX server"),console.error("[Search] 💡 Check if server is running at:",o)):F instanceof Error&&(F.message.includes("401")?(console.error("[Search] ❌ Authentication failed"),console.error("[Search] 💡 Your token may have expired. Get a fresh token with:"),console.error('[Search] 💡 curl -X POST "'+o+`/api/Login" -H "Content-Type: application/json" -d '{"userEmail":"your@email.com","userPassWord":"yourpassword"}'`)):F.message.includes("404")?(console.error("[Search] ❌ Dataset not found"),console.error('[Search] 💡 Check that dataset "'+d+'" exists')):console.error("[Search] 💡 Error:",F.message)),c!==L.current)return;C(P=>({...P,results:null,isLoading:!1,resultsSuppressed:!1,error:F instanceof Error?F.message:"Search failed"}))}},[u.query,u.filters,u.rangeFilters,Pe,Oe,Be,Xe,Je,Qe,Ze,Ye,J,Ge,o,d,S,w]);s.useEffect(()=>{x.current=Ke},[Ke]),s.useCallback(()=>{var l;E&&console.log("Search fired"),(l=x.current)==null||l.call(x,{enableFacets:!1})},[]);const le=s.useRef(null);return s.useEffect(()=>{var l;return(l=le.current)==null||l.cancel(),le.current=ot(()=>{var c;E&&console.log("Debounced searchWithFacets fired"),(c=x.current)==null||c.call(x,{enableFacets:!0})},u.facetDebounceDelayMillis??500),()=>{var c;(c=le.current)==null||c.cancel()}},[u.facetDebounceDelayMillis]),s.useCallback(()=>{var l;(l=le.current)==null||l.call(le)},[]),s.useEffect(()=>{var l;!U&&w&&!V.current&&(S&&((l=x.current)==null||l.call(x,{enableFacets:z})),V.current=!0)},[U,w,S,z]),s.useEffect(()=>{var P,D,G,Z,ce;if(!w||!V.current)return;const l=u.query.trim(),c=l===""&&S;if(l===""&&!S){u.resultsSuppressed||C(oe=>({...oe,resultsSuppressed:!0}));return}return c?((P=le.current)==null||P.cancel(),(D=x.current)==null||D.call(x,{enableFacets:z})):z?(E&&console.log("Search fired"),(G=x.current)==null||G.call(x,{enableFacets:!1}),(Z=le.current)==null||Z.call(le)):(ce=x.current)==null||ce.call(x,{enableFacets:!1}),()=>{var oe;(oe=le.current)==null||oe.cancel()}},[u.query,S,z]),s.useEffect(()=>{var F;if(!V.current||!w)return;if(!m.current){m.current=!0,E&&console.log("[Filter effect] First run, skipping");return}if(u.query!==_){E&&console.log("[Filter effect] Skipping because query changed");return}const l=u.query.trim();z&&!(!S&&l==="")&&(E&&console.log("[Filter effect] Firing search"),(F=x.current)==null||F.call(x,{enableFacets:!0}))},[u.filters,u.rangeFilters]),s.useEffect(()=>{var F;if(!V.current||!w)return;const l=u.query.trim();z&&!(!S&&l==="")&&((F=x.current)==null||F.call(x,{enableFacets:!0}))},[Pe,Oe]),s.useEffect(()=>{var l;!V.current||!w||b.current&&(b.current=!1,(l=x.current)==null||l.call(x,{enableFacets:!1}))},[Be,w]),s.useEffect(()=>{(async()=>{try{let c;if(ne)E&&console.log("[Auth] ✅ Using pre-authenticated token"),c=ne;else{if(!i||!g)throw console.error("[Auth] ❌ Missing credentials"),i||(console.error("[Auth] ❌ Missing email"),console.error('[Auth] 💡 Pass email="your@email.com" to SearchProvider')),g||(console.error("[Auth] ❌ Missing password"),console.error('[Auth] 💡 Pass password="yourpassword" to SearchProvider')),new Error("Email and password are required. Check console for instructions.");if(!o)throw console.error("[Auth] ❌ Missing INDX server URL"),console.error("[Auth] 💡 Add NEXT_PUBLIC_INDX_URL to your .env.local file"),new Error("INDX server URL is required. Check console for instructions.");if(!d)throw console.error("[Auth] ❌ Missing dataset name"),console.error('[Auth] 💡 Pass dataset="your-dataset-name" to SearchProvider'),new Error("Dataset name is required. Check console for instructions.");E&&console.log("[Auth] 🔐 Logging in to get session token...");const A=await fetch(`${o}/api/Login`,{method:"POST",headers:{"Content-Type":"application/json",accept:"*/*"},credentials:"include",body:JSON.stringify({userEmail:i,userPassWord:g})});if(!A.ok)throw console.error("[Auth] ❌ Login failed:",A.status,await A.text()),new Error("Login failed. Check your email and password.");if(c=(await A.json()).token,!c)throw console.error("[Auth] ❌ No token received from login response"),new Error("No token received from login.");E&&console.log("[Auth] ✅ Login successful, bearer token received (length:",c.length,")")}E&&console.log("[Auth] 🔓 Opening dataset session...");const F=await fetch(`${o}/api/CreateOrOpen/${d}/400`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${c}`},body:'""'});if(!F.ok)throw console.error("[Auth] ❌ CreateOrOpen failed:",F.status,await F.text()),new Error("Failed to open dataset session.");v(c),E&&console.log("[Auth] ✅ Dataset session established");const P=A=>fetch(A,{method:"GET",headers:{accept:"text/plain",Authorization:`Bearer ${c}`},credentials:"include"});E&&console.log("[Auth] 🔍 Checking dataset status...");const D=await P(`${o}/api/GetStatus/${d}`);if(!D.ok){if(D.status===401)throw console.error("[Auth] ❌ Authentication failed (401 Unauthorized)"),console.error("[Auth] 💡 Your token may be expired or invalid"),console.error('[Auth] 💡 Get a fresh token with: curl -X POST "'+o+`/api/Login" -H "Content-Type: application/json" -d '{"userEmail":"your@email.com","userPassWord":"yourpassword"}'`),new Error("Authentication failed (401). Token may be expired. Check console for instructions.");if(D.status===404)throw console.error('[Auth] ❌ Dataset "'+d+'" not found (404)'),console.error('[Auth] 💡 Available datasets can be checked with: curl -X GET "'+o+'/api/GetUserDataSets" -H "Authorization: Bearer YOUR_TOKEN"'),console.error("[Auth] 💡 Make sure you spelled the dataset name correctly"),new Error('Dataset "'+d+'" not found. Check console for instructions.');{const A=await D.text();throw console.error("[Auth] ❌ Failed to get dataset status:",D.status,A),console.error("[Auth] 💡 Check if your INDX server is running at:",o),new Error("Failed to connect to INDX server. Check console for details.")}}const G=await D.json();E&&console.log("[Auth] 📊 Dataset status:",G),G.state&&G.state!=="Ready"&&(console.warn("[Auth] ⚠️ Dataset is not ready yet. Current state:",G.state),console.warn("[Auth] 💡 Wait for indexing to complete before searching"));const Z=G.documentCount??G.numberOfRecords??0;Z===0?(console.warn('[Auth] ⚠️ Dataset "'+d+'" is empty (0 records)'),console.warn("[Auth] 💡 Add documents to your dataset before searching"),console.warn("[Auth] 💡 Search will work but return no results")):E&&console.log("[Auth] ✅ Dataset has",Z,"records");const[ce,oe,xe]=await Promise.all([P(`${o}/api/GetFilterableFields/${d}`),P(`${o}/api/GetFacetableFields/${d}`),P(`${o}/api/GetSortableFields/${d}`)]);if(!ce.ok)throw console.error("[Auth] ❌ GetFilterableFields failed:",ce.status,await ce.text()),new Error("Failed to get filterable fields. Check console for details.");if(!oe.ok)throw console.error("[Auth] ❌ GetFacetableFields failed:",oe.status,await oe.text()),new Error("Failed to get facetable fields. Check console for details.");if(!xe.ok)throw console.error("[Auth] ❌ GetSortableFields failed:",xe.status,await xe.text()),new Error("Failed to get sortable fields. Check console for details.");const Re=await ce.json().catch(A=>(console.error("Failed to parse GetFilterableFields response:",A),[])),et=await oe.json().catch(A=>(console.error("Failed to parse GetFacetableFields response:",A),[])),Ce=await xe.json().catch(A=>(console.error("Failed to parse GetSortableFields response:",A),[]));ee(Re||[]),ge(et||[]),M(Ce||[]);let Se={facets:{}};try{const A=await fetch(`${o}/api/Search/${d}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${c}`},credentials:"include",body:JSON.stringify({text:"",maxNumberOfRecordsToReturn:0,enableFacets:!0})});A.ok?Se=await A.json().catch(ae=>(console.warn("Failed to parse blank search response:",ae),{facets:{}})):(console.warn("Blank search failed:",A.status,A.statusText),console.warn("Continuing without initial facet data - facets will be populated after first search"))}catch(A){console.warn("Blank search error:",A),console.warn("Continuing without initial facet data - facets will be populated after first search")}const be={};if(Se.facets){for(const[A,ae]of Object.entries(Se.facets))if(Array.isArray(ae)&&ae.length>0){const de=ae.map(_e=>Number(_e.key)).filter(_e=>!isNaN(_e));de.length>0&&(be[A]={min:Math.min(...de),max:Math.max(...de)})}}const we={};if(Se.facets)for(const[A,ae]of Object.entries(Se.facets))Array.isArray(ae)&&(we[A]=ae.map(de=>de.key));Fe.current={facets:Se.facets,facetStats:be,facetKeys:we},h(be),t(we),ve(be),C(A=>({...A,facetStats:be,totalDocumentCount:Z})),E&&console.log("[Auth] ✅ Initialization complete")}catch(c){throw console.error("[Auth] ❌ Initialization failed:",c),(c instanceof Error||typeof c=="object"&&c!==null&&"message"in c)&&console.error("[Auth] 💡 Error:",c.message),c instanceof TypeError&&c.message.includes("fetch")&&(console.error("[Auth] ❌ Network error - cannot connect to INDX server"),console.error("[Auth] 💡 Check if the server is running at:",o),console.error("[Auth] 💡 Check your NEXT_PUBLIC_INDX_URL in .env.local"),console.error("[Auth] 💡 For local development, it should be: http://localhost:5001")),c}finally{pe(!1)}})()},[i,g,o,d]),e.jsx(ze.Provider,{value:{state:{...u,filterableFields:Q,facetableFields:I,sortableFields:$,rangeBounds:se},isFetchingInitial:U,allowEmptySearch:S,setQuery:B,toggleFilter:Ee,setRangeFilter:Me,resetFilters:Ie,resetSingleFilter:$e,setSort:Ct,setDebounceDelay:W,setSearchSettings:Y,fetchMoreResults:ke},children:r})},fe=()=>{const r=s.useContext(ze);if(!r)throw new Error("useSearchContext must be used within a SearchProvider");return r},it=({className:r="",autoFocus:i=!1,inputSize:g="default",showClear:o=!0,showFocus:d=!1,...S})=>{const{state:{query:y,filters:p,rangeFilters:n,searchSettings:k},setQuery:R}=fe();Object.keys(p).length>0||Object.keys(n).length>0;const T=y.length>0;return e.jsx(f.SearchField,{type:"text",value:y,onChange:X=>R(X.target.value),placeholder:k.placeholderText,autoFocus:i,className:r,showSearchIcon:!0,inputSize:g,showFocusBorder:d,...S,children:o&&T&&e.jsx(f.Button,{variant:"ghost",size:"micro",onClick:()=>R(""),"aria-label":"Clear search",children:"Clear"})})},je={placeholder:"_placeholder_mppwl_1",invalid:"_invalid_mppwl_10",row:"_row_mppwl_14",indexNumber:"_indexNumber_mppwl_42",scoreNumber:"_scoreNumber_mppwl_49"},lt=({color:r="black",size:i=21})=>{const g=.7142857142857143,o=i,d=typeof i=="number"?i*g:`calc(${i} * 0.7142857142857143)`;return e.jsx("svg",{width:o,height:d,viewBox:"0 0 7 5",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 0H3V1V2V3H2V2H1V3H2V4H3V5H4V4H5V3H6V2H5V3H4V2V1V0ZM4 3V4H3V3H4Z",fill:r})})},ct=({color:r="black",size:i=21})=>{const g=.7142857142857143,o=i,d=typeof i=="number"?i*g:`calc(${i} * 0.7142857142857143)`;return e.jsx("svg",{width:o,height:d,viewBox:"0 0 7 5",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5 0H4V1H5V2H4H3H2H1V3H2H3H4H5V4H4V5H5V4H6V3H7V2H6V1H5V0ZM6 2H5V3H6V2Z",fill:r})})},ut=({color:r="black",size:i=21})=>{const g=.7142857142857143,o=i,d=typeof i=="number"?i*g:`calc(${i} * 0.7142857142857143)`;return e.jsx("svg",{width:o,height:d,viewBox:"0 0 7 5",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5 0H6V1H5V0ZM6 1H7V2H6V1ZM0 1H1V2H0V1ZM1 1V0H2V1H1ZM6 3H7V4H6V3ZM6 4V5H5V4H6ZM1 4H2V5H1V4ZM1 4H0V3H1V4ZM2 2H5V3H2V2Z",fill:r})})},Le=({color:r="black",size:i=21})=>{const g=.7142857142857143,o=i,d=typeof i=="number"?i*g:`calc(${i} * 0.7142857142857143)`;return e.jsx("svg",{width:o,height:d,viewBox:"0 0 7 5",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M1 0H2V1H1V0ZM3 2H2V1H3V2ZM4 2H3V3H2V4H1V5H2V4H3V3H4V4H5V5H6V4H5V3H4V2ZM5 1V2H4V1H5ZM5 1V0H6V1H5Z",fill:r})})},dt=({fields:r,resultsPerPage:i,children:g})=>{const{state:{results:o,resultsSuppressed:d,searchSettings:S,truncationIndex:y,query:p},isFetchingInitial:n,fetchMoreResults:k}=fe(),R=i??30,[T,X]=s.useState(R),E=s.useRef(0),ne=s.useRef("");s.useEffect(()=>{const V=p!==ne.current;(!o||o.length<E.current||V)&&X(R),E.current=(o==null?void 0:o.length)??0,ne.current=p},[o,R,p]);const L=o&&o.length>T,x=()=>{const V=T+R;X(V),o&&V>=o.length&&(!y||y===-1||y>o.length)&&k(o.length+R)};return n||d||o===null?e.jsx("div",{className:je.placeholder,children:e.jsx(ut,{size:200,color:"var(--lv5)"})}):o.length===0?e.jsx("div",{className:je.invalid,children:e.jsx("p",{children:"No results found."})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:je.container,children:(o??[]).slice(0,T).map((V,m)=>{const b=V.document,u=V.score;let C;try{C=typeof b=="string"?JSON.parse(b):b}catch{return e.jsx("div",{className:je.invalid,children:e.jsx("p",{children:"Invalid JSON"})},m)}let w;if(r&&r.length>0){w={};for(const v of r)v in C&&(w[v]=C[v])}else w={...C};for(const v in w){const z=w[v];if(typeof z=="string"&&z.startsWith("[")&&z.endsWith("]")){const Q=z.replace(/^\[|\]$/g,"").split(",").map(ee=>ee.trim().replace(/^'|'$/g,"")).filter(ee=>ee.length>0);w[v]=Q}}return e.jsxs("div",{className:je.row,children:[e.jsx("div",{className:je.indexNumber,children:m}),g(w),S.showScore&&e.jsx("div",{className:je.scoreNumber,children:u})]},m)})}),L&&e.jsx("div",{style:{textAlign:"center",marginTop:"20px"},children:e.jsx(f.Button,{variant:"secondary",size:"micro",onClick:x,children:p.trim()===""?"Load more":y!==-1&&y!==void 0&&y>0?`Load results ${T+1}-${Math.min(T+R,o.length,y)} of ${y}`:"Load more"})})]})},ye={list:"_list_mwzqq_2",count:"_count_mwzqq_7",grid:"_grid_mwzqq_16"},ht=({field:r,label:i,preserveBlankFacetState:g=!1,preserveBlankFacetStateOrder:o=!1,sortFacetsBy:d="histogram",limit:S=10,collapsible:y=!0,startCollapsed:p=!1,displayType:n="checkbox",layout:k="list",showActivePanel:R=!1,showCount:T=!0,showNull:X=!1,displayIfEmptyQuery:E=!0,displayCondition:ne=L=>!0})=>{const{state:{facets:L,filterableFields:x,facetableFields:V,filters:m,query:b},toggleFilter:u,isFetchingInitial:C,allowEmptySearch:w}=fe(),v=s.useRef(null),[z,J]=s.useState(S);if(s.useEffect(()=>{J(S)},[L==null?void 0:L[r],S]),!w&&!b||C||!L||!ne({query:b??"",filters:m,facets:L})||!E&&!b&&Object.keys(m).length<1)return null;if(!(x!=null&&x.includes(r))||!(V!=null&&V.includes(r))){const h=[];return x!=null&&x.includes(r)||h.push("filterable"),V!=null&&V.includes(r)||h.push("facetable"),e.jsx(f.FilterPanelBase,{collapsible:!1,children:e.jsxs("div",{style:{color:"red",fontSize:"12px"},children:['Cannot render filter for "',r,'": missing ',h.join(" and "),"."]})})}const Q=L==null?void 0:L[r];if(!Q||!Array.isArray(Q))return null;const ee=(m==null?void 0:m[r])??[];g&&!v.current&&Q.length>0&&(v.current=Q.reduce((h,N)=>(h[N.key]=N.value,h),{}));const I=new Map;g&&v.current?(Object.keys(v.current).forEach(h=>{I.set(h,0)}),Q.forEach(h=>{I.set(h.key,h.value)})):Q.forEach(h=>{I.set(h.key,h.value)});const ge=n==="toggle"&&I.size===2&&I.has("true")&&(I.has("false")||I.has("null"));if(I.has("null")){const h=I.get("null")??0,N=I.get("false")??0;I.set("false",(N??0)+h),I.delete("null")}if(n==="toggle"&&!ge)return e.jsx(f.FilterPanelBase,{collapsible:!1,children:e.jsx("div",{className:ye.count,children:e.jsx(f.ToggleSwitch,{label:i,checked:!1,onChange:()=>{},disabled:!0})})});if(ge){const h=I.get("true"),N=typeof h=="number"?h:null,t=ee.includes("true"),a=N===0,j=T&&(N??0)>0?`${N}`:"";return e.jsx(f.FilterPanelBase,{collapsible:!1,children:e.jsxs("div",{className:ye.count,children:[e.jsx(f.ToggleSwitch,{label:i,checked:t,onChange:()=>u(r,"true"),disabled:a})," ",j]})})}let $=Array.from(I.entries());if(X||($=$.filter(([h])=>h!=="null")),$.length===0&&!g)return null;if(!o)if(d==="alphabetical"){const h=$.filter(([,t])=>typeof t=="number"&&t>0).sort(([t],[a])=>t.localeCompare(a)),N=$.filter(([,t])=>t===0||t===null).sort(([t],[a])=>t.localeCompare(a));$=[...h,...N]}else if(d==="numeric"){const h=(a,j)=>{const _=Number(a),ie=Number(j),me=!isNaN(_),O=!isNaN(ie);return me&&O?_-ie:a.localeCompare(j)},N=$.filter(([,a])=>typeof a=="number"&&a>0).sort(([a],[j])=>h(a,j)),t=$.filter(([,a])=>a===0||a===null).sort(([a],[j])=>h(a,j));$=[...N,...t]}else{const h=$.filter(([,t])=>typeof t=="number"&&t>0),N=$.filter(([,t])=>t===0||t===null);$=[...h,...N]}const M=typeof S=="number"&&$.length>S,U=M?$.slice(0,z):$,pe=(h,N)=>{const t=ee.includes(h),a=N===0,j=T&&(N??0)>0?` (${N})`:"",_=T&&(N??0)>0?N:"";switch(n){case"button":return k==="list"?e.jsxs("div",{className:ye.count,children:[e.jsx(f.Button,{variant:t?"primary":"secondary",onClick:()=>u(r,h),disabled:a,size:"micro",children:h}),e.jsx("span",{children:_})]}):e.jsx(f.Button,{variant:t?"primary":"secondary",onClick:()=>u(r,h),disabled:a,size:"micro",children:`${h}${j}`});case"toggle":return e.jsx(f.ToggleSwitch,{label:h,checked:t,onChange:()=>u(r,h),disabled:a});case"checkbox":default:return k==="list"?e.jsxs("div",{className:ye.count,children:[e.jsx(f.Checkbox,{label:h,score:"",checked:t,onChange:()=>u(r,h),disabled:a}),e.jsx("span",{children:_})]}):e.jsx(f.Checkbox,{label:h,score:j,checked:t,onChange:()=>u(r,h),disabled:a})}},ue=y?p:!1;return e.jsx(f.FilterPanelBase,{title:i,collapsible:y,collapsed:ue,children:e.jsxs("ul",{className:k==="grid"?ye.grid:ye.list,style:{listStyle:"none",padding:0,margin:0},children:[U.map(([h,N])=>e.jsx("li",{children:pe(h,N)},h)),M&&z<$.length&&(()=>{const h=$.length-z,N=Math.min(50,h);return e.jsx("li",{className:ye.toggleItem,children:e.jsx(f.Button,{variant:"ghost",size:"micro",onClick:()=>J(t=>t+50),children:`Show ${N} more of ${$.length} total`})})})()]})})},Ue={disabledMessage:"_disabledMessage_o89gh_1"},ft=({field:r,label:i,expectedMin:g=0,expectedMax:o=1e3,displayType:d="input",collapsible:S=!0,startCollapsed:y=!1})=>{const{state:{rangeFilters:p,rangeBounds:n,facetStats:k,query:R,facetDebounceDelayMillis:T},setRangeFilter:X,resetSingleFilter:E,allowEmptySearch:ne,isFetchingInitial:L}=fe(),x=(n==null?void 0:n[r])!==void 0,V=(n==null?void 0:n[r])??{min:g,max:o},m=V.min,b=V.max,u=(k==null?void 0:k[r])??V,C=u.min,w=u.max,v=x&&m===b,z=v?g:m,J=v?o:b,Q=p==null?void 0:p[r],ee=Q?Q.min:m,I=Q?Q.max:b,ge=Q!==void 0,$=C!==m||w!==b,[M,U]=s.useState([ee,I]),[pe,ue]=s.useState(!1),[h,N]=s.useState(!1),{finalMin:t,finalMax:a,isValidMin:j,isValidMax:_}=s.useMemo(()=>{const[B,W]=M,Y=Math.max(m,Math.min(b,B)),ke=Math.max(m,Math.min(b,W)),Ee=Math.min(Y,ke),Me=Math.max(Y,ke),Ie=Ee>=m&&Ee<Me,$e=Me<=b&&Me>Ee;return{finalMin:Ee,finalMax:Me,isValidMin:Ie,isValidMax:$e}},[M,m,b]);s.useEffect(()=>{if(v)return;if(M[0]===m&&M[1]===b){ue(!1),N(!1);return}const W=T??500,Y=setTimeout(()=>{ue(!j),N(!_)},300),ke=setTimeout(()=>{j&&_&&(t===m&&a===b?E(r):X(r,t,a))},W);return()=>{clearTimeout(Y),clearTimeout(ke)}},[t,a,j,_,m,b,r,E,X,T,v]),s.useEffect(()=>{U([ee,I]),ue(!1),N(!1)},[ee,I,r]);const ie=s.useCallback(B=>{if(v)return;const W=Math.max(m,Math.min(w,B[0])),Y=Math.max(C,Math.min(b,B[1]));U([W,Y])},[v,m,b,C,w]),me=s.useCallback(B=>{if(v)return;const W=Math.max(m,Math.min(w,B[0])),Y=Math.max(C,Math.min(b,B[1]));W===m&&Y===b?(U([m,b]),E(r)):U([W,Y])},[v,m,b,C,w,r,E]),O=s.useCallback(B=>{if(v)return;const W=Number(B.target.value);if(!isNaN(W)){const Y=Math.max(m,Math.min(w,W));U([Y,M[1]])}},[v,M,m,w]),se=s.useCallback(B=>{if(v)return;const W=Number(B.target.value);if(!isNaN(W)){const Y=Math.max(C,Math.min(b,W));U([M[0],Y])}},[v,M,C,b]),ve=s.useCallback(()=>{const B=M[0],W=Math.max(m,Math.min(w,B));W<M[1]?U([W,M[1]]):U([m,M[1]])},[M,m,w]),Fe=s.useCallback(()=>{const B=M[1],W=Math.max(C,Math.min(b,B));W>M[0]?U([M[0],W]):U([M[0],b])},[M,C,b]);return L||!ne&&!R?null:d==="slider"?e.jsxs(f.FilterPanelBase,{title:i,collapsed:y,collapsible:S,children:[v&&e.jsxs("div",{className:Ue.disabledMessage,children:["No adjustable range (all results have the same value: ",m,")."]}),e.jsx("div",{style:{padding:"10px 10px 20px 10px"},children:e.jsx(f.Slider,{min:z,max:J,value:v?[z,J]:[t,a],isRange:!0,onChange:B=>ie(B),onFinalChange:B=>me(B),disabled:v,activeMin:C,activeMax:w,isFaceted:$,highlightFaceted:ge,"aria-label":i||`Filter by ${r}`})}),e.jsxs("div",{style:{display:"flex",flex:"flex-grow",gap:"10px",alignItems:"flex-start",justifyContent:"space-between"},children:[e.jsx(f.InputField,{label:"Min:",type:"number",value:v?m:M[0],min:m,max:Math.min(w,M[1]-1),onChange:O,onBlur:ve,disabled:v,isValid:v||!pe}),e.jsx(f.InputField,{label:"Max:",type:"number",value:v?b:M[1],min:Math.max(C,M[0]+1),max:b,onChange:se,onBlur:Fe,disabled:v,isValid:v||!h})]})]}):e.jsxs(f.FilterPanelBase,{title:i,children:[v&&e.jsxs("div",{className:Ue.disabledMessage,children:["No adjustable range (all results have the same value: ",m,")."]}),e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"flex-start"},children:[e.jsx(f.InputField,{label:"Min:",type:"number",value:v?m:M[0],min:m,max:Math.min(w,M[1]-1),onChange:O,onBlur:ve,disabled:v,isValid:v||!pe}),e.jsx(f.InputField,{label:"Max:",type:"number",value:v?b:M[1],min:Math.max(C,M[0]+1),max:b,onChange:se,onBlur:Fe,disabled:v,isValid:v||!h})]})]})},gt={grid:"_grid_nvpmn_2"},pt=s.memo(({field:r,value:i,onReset:g})=>e.jsx("li",{children:e.jsxs(f.Button,{onClick:g,iconRight:e.jsx(Le,{}),variant:"primary",size:"micro",children:[r,": ",i]})})),mt=s.memo(({field:r,min:i,max:g,onReset:o})=>e.jsx("li",{children:e.jsxs(f.Button,{onClick:o,iconRight:e.jsx(Le,{}),variant:"primary",size:"micro",children:[r,": ",i," – ",g]})}));function vt(){const{state:{filters:r,rangeFilters:i},resetFilters:g,resetSingleFilter:o}=fe(),d=s.useMemo(()=>Object.entries(r).map(([p,n])=>n.map(k=>({field:p,value:k}))).flat(),[r]),S=s.useMemo(()=>Object.entries(i).map(([p,{min:n,max:k}])=>({field:p,min:n,max:k})),[i]);return s.useMemo(()=>Object.keys(r).length>0||Object.keys(i).length>0,[r,i])?e.jsx(f.FilterPanelBase,{collapsible:!1,title:"Active filters",children:e.jsxs("ul",{className:gt.grid,children:[d.map(({field:p,value:n})=>e.jsx(pt,{field:p,value:n,onReset:()=>o(p,n)},`${p}-${n}`)),S.map(({field:p,min:n,max:k})=>e.jsx(mt,{field:p,min:n,max:k,onReset:()=>o(p)},p)),e.jsx("li",{children:e.jsx(f.Button,{onClick:g,size:"micro",variant:"ghost",children:"Reset"})})]})}):null}const xt={radioGroup:"_radioGroup_nwf7i_6"},St=({displayType:r="dropdown",collapsible:i=!0,startCollapsed:g=!1})=>{const{state:{sortableFields:o,sortBy:d,sortAscending:S},setSort:y}=fe();if(!o||o.length===0)return null;const p=d?`${d}:${S?"asc":"desc"}`:"none",n=[{label:"None",value:"none"},...o.flatMap(T=>[{label:`${T} (asc)`,value:`${T}:asc`},{label:`${T} (desc)`,value:`${T}:desc`}])],k=T=>{if(T==="none"||T==="")y(null,!0);else{const[X,E]=T.split(":");y(X,E==="asc")}},R=i?g:!1;return e.jsx(f.FilterPanelBase,{title:"Sort by",collapsible:i,collapsed:R,children:r==="dropdown"?e.jsx(f.Select,{value:p,onValueChange:k,options:n,placeholder:"Select sort...","aria-label":"Sort by"}):e.jsx("div",{className:xt.radioGroup,children:n.map(T=>e.jsx(f.RadioButton,{id:`sort-${T.value}`,name:"sort-by",value:T.value,label:T.label,checked:p===T.value,onChange:X=>k(X.target.value)},T.value))})})},bt={list:"_list_1y4fk_1"};function jt(){const{state:{searchSettings:r},setSearchSettings:i}=fe(),[g,o]=s.useState(!1),d=(n,k)=>{const R=parseInt(k,10);isNaN(R)||i({[n]:R})},S=(n,k)=>{i({[n]:k})},y=(n,k)=>{const R=parseInt(k,10);isNaN(R)||i({coverageSetup:{...r.coverageSetup,[n]:R}})},p=(n,k)=>{i({coverageSetup:{...r.coverageSetup,[n]:k}})};return e.jsx(f.FilterPanelBase,{collapsed:!0,title:"Settings",children:e.jsxs("ul",{className:bt.list,children:[e.jsx("li",{children:e.jsx(f.InputField,{label:"Max Results",type:"number",value:r.maxNumberOfRecordsToReturn.toString(),onChange:n=>d("maxNumberOfRecordsToReturn",n.target.value)})}),e.jsx("li",{children:e.jsx(f.InputField,{label:"Coverage Depth",type:"number",value:r.coverageDepth.toString(),onChange:n=>d("coverageDepth",n.target.value)})}),e.jsxs("li",{children:[e.jsx(f.InputField,{label:"Minimum Score",type:"number",value:r.minimumScore.toString(),onChange:n=>{const k=parseFloat(n.target.value);isNaN(k)||i({minimumScore:k})}}),e.jsx("div",{style:{padding:"10px 10px 20px 10px"},children:e.jsx(f.Slider,{min:0,max:255,step:1,value:r.minimumScore,onChange:n=>{i({minimumScore:n})},"aria-label":"Minimum score"})})]}),e.jsx("li",{children:e.jsx(f.InputField,{label:"Placeholder text",type:"text",value:r.placeholderText,onChange:n=>{i({placeholderText:n.target.value})}})}),e.jsx("li",{children:e.jsx(f.ToggleSwitch,{label:"Show score",checked:r.showScore,onChange:n=>S("showScore",n)})}),e.jsx("li",{children:e.jsx(f.ToggleSwitch,{label:"Enable Coverage",checked:r.enableCoverage,onChange:n=>S("enableCoverage",n)})}),e.jsx("li",{children:e.jsx(f.ToggleSwitch,{label:"Remove Duplicates",checked:r.removeDuplicates,onChange:n=>S("removeDuplicates",n)})}),e.jsx("li",{children:e.jsx(f.Button,{variant:"ghost",size:"micro",iconRight:g?e.jsx(lt,{}):e.jsx(ct,{}),onClick:()=>o(n=>!n),children:g?"Hide Coverage Setup":"Show Coverage Setup"})}),g&&e.jsxs(e.Fragment,{children:[e.jsx("li",{children:e.jsx(f.ToggleSwitch,{label:"Cover Whole Query",checked:r.coverageSetup.coverWholeQuery,onChange:n=>p("coverWholeQuery",n)})}),e.jsx("li",{children:e.jsx(f.ToggleSwitch,{label:"Cover Whole Words",checked:r.coverageSetup.coverWholeWords,onChange:n=>p("coverWholeWords",n)})}),e.jsx("li",{children:e.jsx(f.ToggleSwitch,{label:"Cover Fuzzy Words",checked:r.coverageSetup.coverFuzzyWords,onChange:n=>p("coverFuzzyWords",n)})}),e.jsx("li",{children:e.jsx(f.ToggleSwitch,{label:"Cover Joined Words",checked:r.coverageSetup.coverJoinedWords,onChange:n=>p("coverJoinedWords",n)})}),e.jsx("li",{children:e.jsx(f.ToggleSwitch,{label:"Cover Prefix Suffix",checked:r.coverageSetup.coverPrefixSuffix,onChange:n=>p("coverPrefixSuffix",n)})}),e.jsx("li",{children:e.jsx(f.ToggleSwitch,{label:"Truncate list",checked:r.coverageSetup.truncate,onChange:n=>p("truncate",n)})}),e.jsx("li",{children:e.jsx(f.InputField,{label:"Levenshtein Max Word Size",type:"number",value:r.coverageSetup.levenshteinMaxWordSize.toString(),onChange:n=>y("levenshteinMaxWordSize",n.target.value)})}),e.jsx("li",{children:e.jsx(f.InputField,{label:"Min Word Size",type:"number",value:r.coverageSetup.minWordSize.toString(),onChange:n=>y("minWordSize",n.target.value)})}),e.jsx("li",{children:e.jsx(f.InputField,{label:"Coverage Min Word Hits Abs",type:"number",value:r.coverageSetup.coverageMinWordHitsAbs.toString(),onChange:n=>y("coverageMinWordHitsAbs",n.target.value)})}),e.jsx("li",{children:e.jsx(f.InputField,{label:"Coverage Min Word Hits Relative",type:"number",value:r.coverageSetup.coverageMinWordHitsRelative.toString(),onChange:n=>y("coverageMinWordHitsRelative",n.target.value)})}),e.jsx("li",{children:e.jsx(f.InputField,{label:"Coverage Q Limit For Error Tolerance",type:"number",value:r.coverageSetup.coverageQLimitForErrorTolerance.toString(),onChange:n=>y("coverageQLimitForErrorTolerance",n.target.value)})}),e.jsx("li",{children:e.jsx(f.InputField,{label:"Coverage LCS Error Tolerance Relative Q",type:"number",value:r.coverageSetup.coverageLcsErrorToleranceRelativeq.toString(),onChange:n=>y("coverageLcsErrorToleranceRelativeq",n.target.value)})})]})]})})}class yt extends s.Component{constructor(g){super(g);tt(this,"reset",()=>{this.setState({hasError:!1,error:null})});this.state={hasError:!1,error:null}}static getDerivedStateFromError(g){return{hasError:!0,error:g}}componentDidCatch(g,o){console.error("[SearchErrorBoundary] Caught error:",g,o)}render(){return this.state.hasError&&this.state.error?this.props.fallback?this.props.fallback(this.state.error,this.reset):e.jsxs("div",{style:{padding:"2rem",backgroundColor:"#fee",border:"2px solid #c33",borderRadius:"8px",maxWidth:"600px",margin:"2rem auto"},children:[e.jsx("h2",{style:{color:"#c33",marginTop:0},children:"⚠️ Search Initialization Error"}),e.jsxs("p",{style:{marginBottom:"1rem"},children:[e.jsx("strong",{children:"Error:"})," ",this.state.error.message]}),e.jsxs("div",{style:{backgroundColor:"#fff",padding:"1rem",borderRadius:"4px",marginBottom:"1rem",fontSize:"0.9rem"},children:[e.jsx("strong",{children:"💡 Common fixes:"}),e.jsxs("ul",{style:{marginBottom:0,paddingLeft:"1.5rem"},children:[e.jsx("li",{children:"Check browser console for detailed error messages"}),e.jsx("li",{children:"Verify NEXT_PUBLIC_INDX_URL is correct in .env.local"}),e.jsx("li",{children:"Verify NEXT_PUBLIC_INDX_EMAIL and NEXT_PUBLIC_INDX_PASSWORD are correct"}),e.jsx("li",{children:"Ensure INDX server is running"}),e.jsx("li",{children:"Check dataset name spelling"})]})]}),e.jsx("button",{onClick:this.reset,style:{padding:"0.5rem 1rem",backgroundColor:"#c33",color:"white",border:"none",borderRadius:"4px",cursor:"pointer",fontWeight:"bold"},children:"Try Again"})]}):this.props.children}}H.ActiveFiltersPanel=vt,H.RangeFilterPanel=ft,H.SearchErrorBoundary=yt,H.SearchInput=it,H.SearchProvider=at,H.SearchResults=dt,H.SearchSettingsPanel=jt,H.SortByPanel=St,H.ValueFilterPanel=ht,H.useSearch=fe,H.useSearchContext=fe,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})}));
22
+ <%s key={someKey} {...props} />`,_,O,se,O),N[O+_]=!0)}if(O=null,j!==void 0&&(g(j),O=""+j),y(a)&&(g(a.key),O=""+a.key),"key"in a){j={};for(var ve in a)ve!=="key"&&(j[ve]=a[ve])}else j=a;return O&&p(j,typeof t=="function"?t.displayName||t.name||"Unknown":t),F(t,O,j,d(),ie,me)}function T(t){X(t)?t._store&&(t._store.validated=1):typeof t=="object"&&t!==null&&t.$$typeof===J&&(t._payload.status==="fulfilled"?X(t._payload.value)&&t._payload.value._store&&(t._payload.value._store.validated=1):t._store&&(t._store.validated=1))}function X(t){return typeof t=="object"&&t!==null&&t.$$typeof===ne}var E=s,ne=Symbol.for("react.transitional.element"),L=Symbol.for("react.portal"),x=Symbol.for("react.fragment"),V=Symbol.for("react.strict_mode"),m=Symbol.for("react.profiler"),b=Symbol.for("react.consumer"),u=Symbol.for("react.context"),C=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),v=Symbol.for("react.suspense_list"),z=Symbol.for("react.memo"),J=Symbol.for("react.lazy"),Q=Symbol.for("react.activity"),ee=Symbol.for("react.client.reference"),I=E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ge=Object.prototype.hasOwnProperty,$=Array.isArray,M=console.createTask?console.createTask:function(){return null};E={react_stack_bottom_frame:function(t){return t()}};var U,pe={},ue=E.react_stack_bottom_frame.bind(E,S)(),h=M(o(S)),N={};Ne.Fragment=x,Ne.jsx=function(t,a,j){var _=1e4>I.recentlyCreatedOwnerStacks++;return R(t,a,j,!1,_?Error("react-stack-top-frame"):ue,_?M(o(t)):h)},Ne.jsxs=function(t,a,j){var _=1e4>I.recentlyCreatedOwnerStacks++;return R(t,a,j,!0,_?Error("react-stack-top-frame"):ue,_?M(o(t)):h)}})()),Ne}var qe;function st(){return qe||(qe=1,process.env.NODE_ENV==="production"?Ve.exports=rt():Ve.exports=nt()),Ve.exports}var e=st();const ze=s.createContext(void 0);function ot(r,i){let g;const o=(...d)=>{clearTimeout(g),g=setTimeout(()=>r(...d),i)};return o.cancel=()=>clearTimeout(g),o}const at=({children:r,email:i,password:g,url:o,dataset:d,allowEmptySearch:S=!1,maxResults:y=10,facetDebounceDelayMillis:p=500,enableFacets:n=!0,coverageDepth:F=500,removeDuplicates:R=!0,enableCoverage:T=!0,initialCoverageSetup:X={},enableDebugLogs:E=!1,preAuthenticatedToken:ne})=>{const L=s.useRef(0),x=s.useRef(void 0),V=s.useRef(!1),m=s.useRef(!1),b=s.useRef(!1),[u,C]=s.useState({query:"",results:null,isLoading:!1,resultsSuppressed:!S,facetDebounceDelayMillis:p,filters:{},rangeFilters:{},facetStats:{},searchSettings:{maxNumberOfRecordsToReturn:y,coverageDepth:F,enableCoverage:T,removeDuplicates:R,minimumScore:0,showScore:!0,placeholderText:"Type to search",coverageSetup:{levenshteinMaxWordSize:20,minWordSize:2,coverageMinWordHitsAbs:1,coverageMinWordHitsRelative:0,coverageQLimitForErrorTolerance:5,coverageLcsErrorToleranceRelativeq:.2,coverWholeQuery:!0,coverWholeWords:!0,coverFuzzyWords:!0,coverJoinedWords:!0,coverPrefixSuffix:!0,truncate:!0,...X}}});s.useEffect(()=>{E&&console.log("SearchContext mounted on client")},[E]),s.useEffect(()=>{C(l=>({...l,facetDebounceDelayMillis:p}))},[p]);const[w,v]=s.useState(null),[z]=s.useState(n),J=s.useCallback((l,c={})=>{if(!w)throw new Error("No authentication token available");return fetch(l,{...c,headers:{...c.headers,Authorization:`Bearer ${w}`},credentials:"include"})},[w]),[Q,ee]=s.useState([]),[I,ge]=s.useState([]),[$,M]=s.useState([]),[U,pe]=s.useState(!0),[ue,h]=s.useState({}),[N,t]=s.useState({}),[a,j]=s.useState({}),[_,ie]=s.useState(""),[me,O]=s.useState(""),[se,ve]=s.useState({}),ke=s.useRef(null),B=s.useCallback(l=>{C(c=>({...c,query:l,filters:{},rangeFilters:{},searchSettings:{...c.searchSettings,maxNumberOfRecordsToReturn:y}}))},[y]),W=s.useCallback(l=>{C(c=>({...c,facetDebounceDelayMillis:l}))},[]),Y=s.useCallback(l=>{C(c=>({...c,searchSettings:{...c.searchSettings,...l,coverageSetup:{...c.searchSettings.coverageSetup,...l.coverageSetup||{}}}}))},[]),Fe=s.useCallback(l=>{b.current=!0,C(c=>({...c,searchSettings:{...c.searchSettings,maxNumberOfRecordsToReturn:l}}))},[]),Ee=s.useCallback((l,c)=>{C(k=>{const P={...k.filters},D=P[l]||[],G=D.includes(c)?D.filter(Z=>Z!==c):[...D,c];return G.length?P[l]=G:delete P[l],{...k,filters:P}})},[]),Me=s.useCallback((l,c,k)=>{C(P=>({...P,rangeFilters:{...P.rangeFilters,[l]:{min:c,max:k}}}))},[]),Ie=s.useCallback(()=>{C(l=>({...l,filters:{},rangeFilters:{}}))},[]),$e=s.useCallback((l,c)=>{C(k=>{const P={...k.filters},D={...k.rangeFilters};if(c!==void 0){const Z=(P[l]||[]).filter(ce=>ce!==c);Z.length>0?P[l]=Z:delete P[l]}else delete D[l];return{...k,filters:P,rangeFilters:D}})},[]),Ct=s.useCallback((l,c)=>{C(k=>({...k,sortBy:l||void 0,sortAscending:l?c:void 0}))},[]),Ge=s.useCallback(async(l,c,k)=>{if(l.length===0)return null;if(l.length===1)return l[0];let P=l[0];for(let D=1;D<l.length;D++){const G=await J(`${c}/api/CombineFilters/${k}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({A:P,B:l[D],useAndOperation:!0})});if(!G.ok){const Z=await G.json();throw console.error("CombineFilters failed:",Z),new Error("CombineFilters failed")}P=await G.json()}return P},[J]),Be=u.searchSettings.maxNumberOfRecordsToReturn,Xe=u.searchSettings.enableCoverage,Je=u.searchSettings.removeDuplicates,Qe=u.searchSettings.coverageDepth,Ye=u.searchSettings.minimumScore,Pe=u.sortBy,Oe=u.sortAscending,Ze=s.useMemo(()=>u.searchSettings.coverageSetup,[u.searchSettings.coverageSetup.levenshteinMaxWordSize,u.searchSettings.coverageSetup.minWordSize,u.searchSettings.coverageSetup.coverageMinWordHitsAbs,u.searchSettings.coverageSetup.coverageMinWordHitsRelative,u.searchSettings.coverageSetup.coverageQLimitForErrorTolerance,u.searchSettings.coverageSetup.coverageLcsErrorToleranceRelativeq,u.searchSettings.coverageSetup.coverWholeQuery,u.searchSettings.coverageSetup.coverWholeWords,u.searchSettings.coverageSetup.coverFuzzyWords,u.searchSettings.coverageSetup.coverJoinedWords,u.searchSettings.coverageSetup.coverPrefixSuffix,u.searchSettings.coverageSetup.truncate]),Ke=s.useCallback(async({enableFacets:l})=>{if(!w)return;const c=++L.current;C(k=>({...k,isLoading:!0}));try{const k=Object.entries(u.filters??{}),D=(await Promise.all(k.map(async([q,K])=>Promise.all(K.map(te=>J(`${o}/api/CreateValueFilter/${d}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({FieldName:q,Value:te})}).then(he=>he.json())))))).flat(),G=Object.entries(u.rangeFilters??{}),Z=await Promise.all(G.map(([q,{min:K,max:te}])=>J(`${o}/api/CreateRangeFilter/${d}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({FieldName:q,LowerLimit:K,UpperLimit:te})}).then(he=>he.json()))),ce=[...D,...Z].filter(q=>q&&typeof q.hashString=="string"),oe=await Ge(ce,o,d),xe=S||u.query.trim()!=="",Re={text:u.query,maxNumberOfRecordsToReturn:xe?Be:0,enableFacets:l,...oe?{filter:oe}:{},...Pe?{sortBy:Pe}:{},...Oe!==void 0?{sortAscending:Oe}:{},enableCoverage:Xe,removeDuplicates:Je,coverageDepth:Qe,coverageSetup:Ze};E&&console.log("[performSearch] request body:",JSON.stringify(Re,null,2));const Ce=await(await J(`${o}/api/Search/${d}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Re)})).json(),Se=Ce.truncationIndex??-1,be=Ce.records||[],we=be.map(q=>q.documentKey),A=be.map(q=>q.score);let ae=[];xe&&we.length>0&&(ae=(await(await J(`${o}/api/GetJson/${d}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(we)})).json()).map((te,he)=>({document:te,documentKey:we[he],score:A[he]})));let de={};if(l&&Ce.facets){for(const[q,K]of Object.entries(Ce.facets))if(Array.isArray(K)&&K.length>0){const te=K.map(he=>Number(he.key)).filter(he=>!isNaN(he));te.length>0&&(de[q]={min:Math.min(...te),max:Math.max(...te)})}}const _e=u.query!==_,wt=u.query!==me;let He=u.facetStats??{};if(_e?(He={...ue,...de},j(He),ie(u.query)):He={...a,...de},wt&&l){const q={...se};for(const[K,te]of Object.entries(de))q[K]=te;ve(q),O(u.query)}let Ae=Ce.facets;if(l&&(!Ae||Object.keys(Ae).length===0)){Ae={};for(const[q,K]of Object.entries(N))Ae[q]=K.map(te=>({key:te,value:null}))}if(c!==L.current)return;const kt=ae.filter(q=>{const K=u.query.trim();return K===""||K.length===1?!0:q.score>=Ye});C(q=>({...q,results:kt,resultsSuppressed:!xe,...l?{facets:Ae,facetStats:He}:{},isLoading:!1,truncationIndex:Se}))}catch(k){if(console.error("[Search] ❌ Search failed:",k),k instanceof TypeError&&k.message.includes("fetch")?(console.error("[Search] ❌ Network error - cannot reach INDX server"),console.error("[Search] 💡 Check if server is running at:",o)):k instanceof Error&&(k.message.includes("401")?(console.error("[Search] ❌ Authentication failed"),console.error("[Search] 💡 Your token may have expired. Get a fresh token with:"),console.error('[Search] 💡 curl -X POST "'+o+`/api/Login" -H "Content-Type: application/json" -d '{"userEmail":"your@email.com","userPassWord":"yourpassword"}'`)):k.message.includes("404")?(console.error("[Search] ❌ Dataset not found"),console.error('[Search] 💡 Check that dataset "'+d+'" exists')):console.error("[Search] 💡 Error:",k.message)),c!==L.current)return;C(P=>({...P,results:null,isLoading:!1,resultsSuppressed:!1,error:k instanceof Error?k.message:"Search failed"}))}},[u.query,u.filters,u.rangeFilters,Pe,Oe,Be,Xe,Je,Qe,Ze,Ye,J,Ge,o,d,S,w]);s.useEffect(()=>{x.current=Ke},[Ke]),s.useCallback(()=>{var l;E&&console.log("Search fired"),(l=x.current)==null||l.call(x,{enableFacets:!1})},[]);const le=s.useRef(null);return s.useEffect(()=>{var l;return(l=le.current)==null||l.cancel(),le.current=ot(()=>{var c;E&&console.log("Debounced searchWithFacets fired"),(c=x.current)==null||c.call(x,{enableFacets:!0})},u.facetDebounceDelayMillis??500),()=>{var c;(c=le.current)==null||c.cancel()}},[u.facetDebounceDelayMillis]),s.useCallback(()=>{var l;(l=le.current)==null||l.call(le)},[]),s.useEffect(()=>{var l;!U&&w&&!V.current&&(S&&((l=x.current)==null||l.call(x,{enableFacets:z})),V.current=!0)},[U,w,S,z]),s.useEffect(()=>{var P,D,G,Z,ce;if(!w||!V.current)return;const l=u.query.trim(),c=l===""&&S;if(l===""&&!S){u.resultsSuppressed||C(oe=>({...oe,resultsSuppressed:!0}));return}return c?((P=le.current)==null||P.cancel(),(D=x.current)==null||D.call(x,{enableFacets:z})):z?(E&&console.log("Search fired"),(G=x.current)==null||G.call(x,{enableFacets:!1}),(Z=le.current)==null||Z.call(le)):(ce=x.current)==null||ce.call(x,{enableFacets:!1}),()=>{var oe;(oe=le.current)==null||oe.cancel()}},[u.query,S,z]),s.useEffect(()=>{var k;if(!V.current||!w)return;if(!m.current){m.current=!0,E&&console.log("[Filter effect] First run, skipping");return}if(u.query!==_){E&&console.log("[Filter effect] Skipping because query changed");return}const l=u.query.trim();z&&!(!S&&l==="")&&(E&&console.log("[Filter effect] Firing search"),(k=x.current)==null||k.call(x,{enableFacets:!0}))},[u.filters,u.rangeFilters]),s.useEffect(()=>{var k;if(!V.current||!w)return;const l=u.query.trim();z&&!(!S&&l==="")&&((k=x.current)==null||k.call(x,{enableFacets:!0}))},[Pe,Oe]),s.useEffect(()=>{var l;!V.current||!w||b.current&&(b.current=!1,(l=x.current)==null||l.call(x,{enableFacets:!1}))},[Be,w]),s.useEffect(()=>{(async()=>{try{let c;if(ne)E&&console.log("[Auth] ✅ Using pre-authenticated token"),c=ne;else{if(!i||!g)throw console.error("[Auth] ❌ Missing credentials"),i||(console.error("[Auth] ❌ Missing email"),console.error('[Auth] 💡 Pass email="your@email.com" to SearchProvider')),g||(console.error("[Auth] ❌ Missing password"),console.error('[Auth] 💡 Pass password="yourpassword" to SearchProvider')),new Error("Email and password are required. Check console for instructions.");if(!o)throw console.error("[Auth] ❌ Missing INDX server URL"),console.error("[Auth] 💡 Add NEXT_PUBLIC_INDX_URL to your .env.local file"),new Error("INDX server URL is required. Check console for instructions.");if(!d)throw console.error("[Auth] ❌ Missing dataset name"),console.error('[Auth] 💡 Pass dataset="your-dataset-name" to SearchProvider'),new Error("Dataset name is required. Check console for instructions.");E&&console.log("[Auth] 🔐 Logging in to get session token...");const A=await fetch(`${o}/api/Login`,{method:"POST",headers:{"Content-Type":"application/json",accept:"*/*"},credentials:"include",body:JSON.stringify({userEmail:i,userPassWord:g})});if(!A.ok)throw console.error("[Auth] ❌ Login failed:",A.status,await A.text()),new Error("Login failed. Check your email and password.");if(c=(await A.json()).token,!c)throw console.error("[Auth] ❌ No token received from login response"),new Error("No token received from login.");E&&console.log("[Auth] ✅ Login successful, bearer token received (length:",c.length,")")}E&&console.log("[Auth] 🔓 Opening dataset session...");const k=await fetch(`${o}/api/CreateOrOpen/${d}/400`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${c}`},body:'""'});if(!k.ok)throw console.error("[Auth] ❌ CreateOrOpen failed:",k.status,await k.text()),new Error("Failed to open dataset session.");v(c),E&&console.log("[Auth] ✅ Dataset session established");const P=A=>fetch(A,{method:"GET",headers:{accept:"text/plain",Authorization:`Bearer ${c}`},credentials:"include"});E&&console.log("[Auth] 🔍 Checking dataset status...");const D=await P(`${o}/api/GetStatus/${d}`);if(!D.ok){if(D.status===401)throw console.error("[Auth] ❌ Authentication failed (401 Unauthorized)"),console.error("[Auth] 💡 Your token may be expired or invalid"),console.error('[Auth] 💡 Get a fresh token with: curl -X POST "'+o+`/api/Login" -H "Content-Type: application/json" -d '{"userEmail":"your@email.com","userPassWord":"yourpassword"}'`),new Error("Authentication failed (401). Token may be expired. Check console for instructions.");if(D.status===404)throw console.error('[Auth] ❌ Dataset "'+d+'" not found (404)'),console.error('[Auth] 💡 Available datasets can be checked with: curl -X GET "'+o+'/api/GetUserDataSets" -H "Authorization: Bearer YOUR_TOKEN"'),console.error("[Auth] 💡 Make sure you spelled the dataset name correctly"),new Error('Dataset "'+d+'" not found. Check console for instructions.');{const A=await D.text();throw console.error("[Auth] ❌ Failed to get dataset status:",D.status,A),console.error("[Auth] 💡 Check if your INDX server is running at:",o),new Error("Failed to connect to INDX server. Check console for details.")}}const G=await D.json();E&&console.log("[Auth] 📊 Dataset status:",G),G.state&&G.state!=="Ready"&&(console.warn("[Auth] ⚠️ Dataset is not ready yet. Current state:",G.state),console.warn("[Auth] 💡 Wait for indexing to complete before searching"));const Z=G.documentCount??G.numberOfRecords??0;Z===0?(console.warn('[Auth] ⚠️ Dataset "'+d+'" is empty (0 records)'),console.warn("[Auth] 💡 Add documents to your dataset before searching"),console.warn("[Auth] 💡 Search will work but return no results")):E&&console.log("[Auth] ✅ Dataset has",Z,"records");const[ce,oe,xe]=await Promise.all([P(`${o}/api/GetFilterableFields/${d}`),P(`${o}/api/GetFacetableFields/${d}`),P(`${o}/api/GetSortableFields/${d}`)]);if(!ce.ok)throw console.error("[Auth] ❌ GetFilterableFields failed:",ce.status,await ce.text()),new Error("Failed to get filterable fields. Check console for details.");if(!oe.ok)throw console.error("[Auth] ❌ GetFacetableFields failed:",oe.status,await oe.text()),new Error("Failed to get facetable fields. Check console for details.");if(!xe.ok)throw console.error("[Auth] ❌ GetSortableFields failed:",xe.status,await xe.text()),new Error("Failed to get sortable fields. Check console for details.");const Re=await ce.json().catch(A=>(console.error("Failed to parse GetFilterableFields response:",A),[])),et=await oe.json().catch(A=>(console.error("Failed to parse GetFacetableFields response:",A),[])),Ce=await xe.json().catch(A=>(console.error("Failed to parse GetSortableFields response:",A),[]));ee(Re||[]),ge(et||[]),M(Ce||[]);let Se={facets:{}};try{const A=await fetch(`${o}/api/Search/${d}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${c}`},credentials:"include",body:JSON.stringify({text:"",maxNumberOfRecordsToReturn:0,enableFacets:!0})});A.ok?Se=await A.json().catch(ae=>(console.warn("Failed to parse blank search response:",ae),{facets:{}})):(console.warn("Blank search failed:",A.status,A.statusText),console.warn("Continuing without initial facet data - facets will be populated after first search"))}catch(A){console.warn("Blank search error:",A),console.warn("Continuing without initial facet data - facets will be populated after first search")}const be={};if(Se.facets){for(const[A,ae]of Object.entries(Se.facets))if(Array.isArray(ae)&&ae.length>0){const de=ae.map(_e=>Number(_e.key)).filter(_e=>!isNaN(_e));de.length>0&&(be[A]={min:Math.min(...de),max:Math.max(...de)})}}const we={};if(Se.facets)for(const[A,ae]of Object.entries(Se.facets))Array.isArray(ae)&&(we[A]=ae.map(de=>de.key));ke.current={facets:Se.facets,facetStats:be,facetKeys:we},h(be),t(we),ve(be),C(A=>({...A,facetStats:be,totalDocumentCount:Z})),E&&console.log("[Auth] ✅ Initialization complete")}catch(c){throw console.error("[Auth] ❌ Initialization failed:",c),(c instanceof Error||typeof c=="object"&&c!==null&&"message"in c)&&console.error("[Auth] 💡 Error:",c.message),c instanceof TypeError&&c.message.includes("fetch")&&(console.error("[Auth] ❌ Network error - cannot connect to INDX server"),console.error("[Auth] 💡 Check if the server is running at:",o),console.error("[Auth] 💡 Check your NEXT_PUBLIC_INDX_URL in .env.local"),console.error("[Auth] 💡 For local development, it should be: http://localhost:5001")),c}finally{pe(!1)}})()},[i,g,o,d]),e.jsx(ze.Provider,{value:{state:{...u,filterableFields:Q,facetableFields:I,sortableFields:$,rangeBounds:se},isFetchingInitial:U,allowEmptySearch:S,setQuery:B,toggleFilter:Ee,setRangeFilter:Me,resetFilters:Ie,resetSingleFilter:$e,setSort:Ct,setDebounceDelay:W,setSearchSettings:Y,fetchMoreResults:Fe},children:r})},fe=()=>{const r=s.useContext(ze);if(!r)throw new Error("useSearchContext must be used within a SearchProvider");return r},it=({className:r="",autoFocus:i=!1,inputSize:g="default",showClear:o=!0,showFocus:d=!1,...S})=>{const{state:{query:y,filters:p,rangeFilters:n,searchSettings:F},setQuery:R}=fe();Object.keys(p).length>0||Object.keys(n).length>0;const T=y.length>0;return e.jsx(f.SearchField,{type:"text",value:y,onChange:X=>R(X.target.value),placeholder:F.placeholderText,autoFocus:i,className:r,showSearchIcon:!0,inputSize:g,showFocusBorder:d,...S,children:o&&T&&e.jsx(f.Button,{variant:"ghost",size:"micro",onClick:()=>R(""),"aria-label":"Clear search",children:"Clear"})})},je={placeholder:"_placeholder_1k92x_1",invalid:"_invalid_1k92x_10",row:"_row_1k92x_14",indexNumber:"_indexNumber_1k92x_38",scoreNumber:"_scoreNumber_1k92x_45"},lt=({color:r="black",size:i=21})=>{const g=.7142857142857143,o=i,d=typeof i=="number"?i*g:`calc(${i} * 0.7142857142857143)`;return e.jsx("svg",{width:o,height:d,viewBox:"0 0 7 5",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 0H3V1V2V3H2V2H1V3H2V4H3V5H4V4H5V3H6V2H5V3H4V2V1V0ZM4 3V4H3V3H4Z",fill:r})})},ct=({color:r="black",size:i=21})=>{const g=.7142857142857143,o=i,d=typeof i=="number"?i*g:`calc(${i} * 0.7142857142857143)`;return e.jsx("svg",{width:o,height:d,viewBox:"0 0 7 5",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5 0H4V1H5V2H4H3H2H1V3H2H3H4H5V4H4V5H5V4H6V3H7V2H6V1H5V0ZM6 2H5V3H6V2Z",fill:r})})},ut=({color:r="black",size:i=21})=>{const g=.7142857142857143,o=i,d=typeof i=="number"?i*g:`calc(${i} * 0.7142857142857143)`;return e.jsx("svg",{width:o,height:d,viewBox:"0 0 7 5",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5 0H6V1H5V0ZM6 1H7V2H6V1ZM0 1H1V2H0V1ZM1 1V0H2V1H1ZM6 3H7V4H6V3ZM6 4V5H5V4H6ZM1 4H2V5H1V4ZM1 4H0V3H1V4ZM2 2H5V3H2V2Z",fill:r})})},Le=({color:r="black",size:i=21})=>{const g=.7142857142857143,o=i,d=typeof i=="number"?i*g:`calc(${i} * 0.7142857142857143)`;return e.jsx("svg",{width:o,height:d,viewBox:"0 0 7 5",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M1 0H2V1H1V0ZM3 2H2V1H3V2ZM4 2H3V3H2V4H1V5H2V4H3V3H4V4H5V5H6V4H5V3H4V2ZM5 1V2H4V1H5ZM5 1V0H6V1H5Z",fill:r})})},dt=({fields:r,resultsPerPage:i,children:g})=>{const{state:{results:o,resultsSuppressed:d,searchSettings:S,truncationIndex:y,query:p},isFetchingInitial:n,fetchMoreResults:F}=fe(),R=i??30,[T,X]=s.useState(R),E=s.useRef(0),ne=s.useRef("");s.useEffect(()=>{const V=p!==ne.current;(!o||o.length<E.current||V)&&X(R),E.current=(o==null?void 0:o.length)??0,ne.current=p},[o,R,p]);const L=o&&o.length>T,x=()=>{const V=T+R;X(V),o&&V>=o.length&&(!y||y===-1||y>o.length)&&F(o.length+R)};return n||d||o===null?e.jsx("div",{className:je.placeholder,children:e.jsx(ut,{size:200,color:"var(--lv5)"})}):o.length===0?e.jsx("div",{className:je.invalid,children:e.jsx("p",{children:"No results found."})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:je.container,children:(o??[]).slice(0,T).map((V,m)=>{const b=V.document,u=V.score;let C;try{C=typeof b=="string"?JSON.parse(b):b}catch{return e.jsx("div",{className:je.invalid,children:e.jsx("p",{children:"Invalid JSON"})},m)}let w;if(r&&r.length>0){w={};for(const v of r)v in C&&(w[v]=C[v])}else w={...C};for(const v in w){const z=w[v];if(typeof z=="string"&&z.startsWith("[")&&z.endsWith("]")){const Q=z.replace(/^\[|\]$/g,"").split(",").map(ee=>ee.trim().replace(/^'|'$/g,"")).filter(ee=>ee.length>0);w[v]=Q}}return e.jsxs("div",{className:je.row,children:[e.jsx("div",{className:je.indexNumber,children:m}),g(w),S.showScore&&e.jsx("div",{className:je.scoreNumber,children:u})]},m)})}),L&&e.jsx("div",{style:{textAlign:"center",marginTop:"20px"},children:e.jsx(f.Button,{variant:"secondary",size:"micro",onClick:x,children:p.trim()===""?"Load more":y!==-1&&y!==void 0&&y>0?`Load results ${T+1}-${Math.min(T+R,o.length,y)} of ${y}`:"Load more"})})]})},ye={list:"_list_mwzqq_2",count:"_count_mwzqq_7",grid:"_grid_mwzqq_16"},ht=({field:r,label:i,preserveBlankFacetState:g=!1,preserveBlankFacetStateOrder:o=!1,sortFacetsBy:d="histogram",limit:S=10,collapsible:y=!0,startCollapsed:p=!1,displayType:n="checkbox",layout:F="list",showActivePanel:R=!1,showCount:T=!0,showNull:X=!1,displayIfEmptyQuery:E=!0,displayCondition:ne=L=>!0})=>{const{state:{facets:L,filterableFields:x,facetableFields:V,filters:m,query:b},toggleFilter:u,isFetchingInitial:C,allowEmptySearch:w}=fe(),v=s.useRef(null),[z,J]=s.useState(S);if(s.useEffect(()=>{J(S)},[L==null?void 0:L[r],S]),!w&&!b||C||!L||!ne({query:b??"",filters:m,facets:L})||!E&&!b&&Object.keys(m).length<1)return null;if(!(x!=null&&x.includes(r))||!(V!=null&&V.includes(r))){const h=[];return x!=null&&x.includes(r)||h.push("filterable"),V!=null&&V.includes(r)||h.push("facetable"),e.jsx(f.FilterPanelBase,{collapsible:!1,children:e.jsxs("div",{style:{color:"red",fontSize:"12px"},children:['Cannot render filter for "',r,'": missing ',h.join(" and "),"."]})})}const Q=L==null?void 0:L[r];if(!Q||!Array.isArray(Q))return null;const ee=(m==null?void 0:m[r])??[];g&&!v.current&&Q.length>0&&(v.current=Q.reduce((h,N)=>(h[N.key]=N.value,h),{}));const I=new Map;g&&v.current?(Object.keys(v.current).forEach(h=>{I.set(h,0)}),Q.forEach(h=>{I.set(h.key,h.value)})):Q.forEach(h=>{I.set(h.key,h.value)});const ge=n==="toggle"&&I.size===2&&I.has("true")&&(I.has("false")||I.has("null"));if(I.has("null")){const h=I.get("null")??0,N=I.get("false")??0;I.set("false",(N??0)+h),I.delete("null")}if(n==="toggle"&&!ge)return e.jsx(f.FilterPanelBase,{collapsible:!1,children:e.jsx("div",{className:ye.count,children:e.jsx(f.ToggleSwitch,{label:i,checked:!1,onChange:()=>{},disabled:!0})})});if(ge){const h=I.get("true"),N=typeof h=="number"?h:null,t=ee.includes("true"),a=N===0,j=T&&(N??0)>0?`${N}`:"";return e.jsx(f.FilterPanelBase,{collapsible:!1,children:e.jsxs("div",{className:ye.count,children:[e.jsx(f.ToggleSwitch,{label:i,checked:t,onChange:()=>u(r,"true"),disabled:a})," ",j]})})}let $=Array.from(I.entries());if(X||($=$.filter(([h])=>h!=="null")),$.length===0&&!g)return null;if(!o)if(d==="alphabetical"){const h=$.filter(([,t])=>typeof t=="number"&&t>0).sort(([t],[a])=>t.localeCompare(a)),N=$.filter(([,t])=>t===0||t===null).sort(([t],[a])=>t.localeCompare(a));$=[...h,...N]}else if(d==="numeric"){const h=(a,j)=>{const _=Number(a),ie=Number(j),me=!isNaN(_),O=!isNaN(ie);return me&&O?_-ie:a.localeCompare(j)},N=$.filter(([,a])=>typeof a=="number"&&a>0).sort(([a],[j])=>h(a,j)),t=$.filter(([,a])=>a===0||a===null).sort(([a],[j])=>h(a,j));$=[...N,...t]}else{const h=$.filter(([,t])=>typeof t=="number"&&t>0),N=$.filter(([,t])=>t===0||t===null);$=[...h,...N]}const M=typeof S=="number"&&$.length>S,U=M?$.slice(0,z):$,pe=(h,N)=>{const t=ee.includes(h),a=N===0,j=T&&(N??0)>0?` (${N})`:"",_=T&&(N??0)>0?N:"";switch(n){case"button":return F==="list"?e.jsxs("div",{className:ye.count,children:[e.jsx(f.Button,{variant:t?"primary":"secondary",onClick:()=>u(r,h),disabled:a,size:"micro",children:h}),e.jsx("span",{children:_})]}):e.jsx(f.Button,{variant:t?"primary":"secondary",onClick:()=>u(r,h),disabled:a,size:"micro",children:`${h}${j}`});case"toggle":return e.jsx(f.ToggleSwitch,{label:h,checked:t,onChange:()=>u(r,h),disabled:a});case"checkbox":default:return F==="list"?e.jsxs("div",{className:ye.count,children:[e.jsx(f.Checkbox,{label:h,score:"",checked:t,onChange:()=>u(r,h),disabled:a}),e.jsx("span",{children:_})]}):e.jsx(f.Checkbox,{label:h,score:j,checked:t,onChange:()=>u(r,h),disabled:a})}},ue=y?p:!1;return e.jsx(f.FilterPanelBase,{title:i,collapsible:y,collapsed:ue,children:e.jsxs("ul",{className:F==="grid"?ye.grid:ye.list,style:{listStyle:"none",padding:0,margin:0},children:[U.map(([h,N])=>e.jsx("li",{children:pe(h,N)},h)),M&&z<$.length&&(()=>{const h=$.length-z,N=Math.min(50,h);return e.jsx("li",{className:ye.toggleItem,children:e.jsx(f.Button,{variant:"ghost",size:"micro",onClick:()=>J(t=>t+50),children:`Show ${N} more of ${$.length} total`})})})()]})})},Ue={disabledMessage:"_disabledMessage_o89gh_1"},ft=({field:r,label:i,expectedMin:g=0,expectedMax:o=1e3,displayType:d="input",collapsible:S=!0,startCollapsed:y=!1})=>{const{state:{rangeFilters:p,rangeBounds:n,facetStats:F,query:R,facetDebounceDelayMillis:T},setRangeFilter:X,resetSingleFilter:E,allowEmptySearch:ne,isFetchingInitial:L}=fe(),x=(n==null?void 0:n[r])!==void 0,V=(n==null?void 0:n[r])??{min:g,max:o},m=V.min,b=V.max,u=(F==null?void 0:F[r])??V,C=u.min,w=u.max,v=x&&m===b,z=v?g:m,J=v?o:b,Q=p==null?void 0:p[r],ee=Q?Q.min:m,I=Q?Q.max:b,ge=Q!==void 0,$=C!==m||w!==b,[M,U]=s.useState([ee,I]),[pe,ue]=s.useState(!1),[h,N]=s.useState(!1),{finalMin:t,finalMax:a,isValidMin:j,isValidMax:_}=s.useMemo(()=>{const[B,W]=M,Y=Math.max(m,Math.min(b,B)),Fe=Math.max(m,Math.min(b,W)),Ee=Math.min(Y,Fe),Me=Math.max(Y,Fe),Ie=Ee>=m&&Ee<Me,$e=Me<=b&&Me>Ee;return{finalMin:Ee,finalMax:Me,isValidMin:Ie,isValidMax:$e}},[M,m,b]);s.useEffect(()=>{if(v)return;if(M[0]===m&&M[1]===b){ue(!1),N(!1);return}const W=T??500,Y=setTimeout(()=>{ue(!j),N(!_)},300),Fe=setTimeout(()=>{j&&_&&(t===m&&a===b?E(r):X(r,t,a))},W);return()=>{clearTimeout(Y),clearTimeout(Fe)}},[t,a,j,_,m,b,r,E,X,T,v]),s.useEffect(()=>{U([ee,I]),ue(!1),N(!1)},[ee,I,r]);const ie=s.useCallback(B=>{if(v)return;const W=Math.max(m,Math.min(w,B[0])),Y=Math.max(C,Math.min(b,B[1]));U([W,Y])},[v,m,b,C,w]),me=s.useCallback(B=>{if(v)return;const W=Math.max(m,Math.min(w,B[0])),Y=Math.max(C,Math.min(b,B[1]));W===m&&Y===b?(U([m,b]),E(r)):U([W,Y])},[v,m,b,C,w,r,E]),O=s.useCallback(B=>{if(v)return;const W=Number(B.target.value);if(!isNaN(W)){const Y=Math.max(m,Math.min(w,W));U([Y,M[1]])}},[v,M,m,w]),se=s.useCallback(B=>{if(v)return;const W=Number(B.target.value);if(!isNaN(W)){const Y=Math.max(C,Math.min(b,W));U([M[0],Y])}},[v,M,C,b]),ve=s.useCallback(()=>{const B=M[0],W=Math.max(m,Math.min(w,B));W<M[1]?U([W,M[1]]):U([m,M[1]])},[M,m,w]),ke=s.useCallback(()=>{const B=M[1],W=Math.max(C,Math.min(b,B));W>M[0]?U([M[0],W]):U([M[0],b])},[M,C,b]);return L||!ne&&!R?null:d==="slider"?e.jsxs(f.FilterPanelBase,{title:i,collapsed:y,collapsible:S,children:[v&&e.jsxs("div",{className:Ue.disabledMessage,children:["No adjustable range (all results have the same value: ",m,")."]}),e.jsx("div",{style:{padding:"10px 10px 20px 10px"},children:e.jsx(f.Slider,{min:z,max:J,value:v?[z,J]:[t,a],isRange:!0,onChange:B=>ie(B),onFinalChange:B=>me(B),disabled:v,activeMin:C,activeMax:w,isFaceted:$,highlightFaceted:ge,"aria-label":i||`Filter by ${r}`})}),e.jsxs("div",{style:{display:"flex",flex:"flex-grow",gap:"10px",alignItems:"flex-start",justifyContent:"space-between"},children:[e.jsx(f.InputField,{label:"Min:",type:"number",value:v?m:M[0],min:m,max:Math.min(w,M[1]-1),onChange:O,onBlur:ve,disabled:v,isValid:v||!pe}),e.jsx(f.InputField,{label:"Max:",type:"number",value:v?b:M[1],min:Math.max(C,M[0]+1),max:b,onChange:se,onBlur:ke,disabled:v,isValid:v||!h})]})]}):e.jsxs(f.FilterPanelBase,{title:i,children:[v&&e.jsxs("div",{className:Ue.disabledMessage,children:["No adjustable range (all results have the same value: ",m,")."]}),e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"flex-start"},children:[e.jsx(f.InputField,{label:"Min:",type:"number",value:v?m:M[0],min:m,max:Math.min(w,M[1]-1),onChange:O,onBlur:ve,disabled:v,isValid:v||!pe}),e.jsx(f.InputField,{label:"Max:",type:"number",value:v?b:M[1],min:Math.max(C,M[0]+1),max:b,onChange:se,onBlur:ke,disabled:v,isValid:v||!h})]})]})},gt={grid:"_grid_nvpmn_2"},pt=s.memo(({field:r,value:i,onReset:g})=>e.jsx("li",{children:e.jsxs(f.Button,{onClick:g,iconRight:e.jsx(Le,{}),variant:"primary",size:"micro",children:[r,": ",i]})})),mt=s.memo(({field:r,min:i,max:g,onReset:o})=>e.jsx("li",{children:e.jsxs(f.Button,{onClick:o,iconRight:e.jsx(Le,{}),variant:"primary",size:"micro",children:[r,": ",i," – ",g]})}));function vt(){const{state:{filters:r,rangeFilters:i},resetFilters:g,resetSingleFilter:o}=fe(),d=s.useMemo(()=>Object.entries(r).map(([p,n])=>n.map(F=>({field:p,value:F}))).flat(),[r]),S=s.useMemo(()=>Object.entries(i).map(([p,{min:n,max:F}])=>({field:p,min:n,max:F})),[i]);return s.useMemo(()=>Object.keys(r).length>0||Object.keys(i).length>0,[r,i])?e.jsx(f.FilterPanelBase,{collapsible:!1,title:"Active filters",children:e.jsxs("ul",{className:gt.grid,children:[d.map(({field:p,value:n})=>e.jsx(pt,{field:p,value:n,onReset:()=>o(p,n)},`${p}-${n}`)),S.map(({field:p,min:n,max:F})=>e.jsx(mt,{field:p,min:n,max:F,onReset:()=>o(p)},p)),e.jsx("li",{children:e.jsx(f.Button,{onClick:g,size:"micro",variant:"ghost",children:"Reset"})})]})}):null}const xt={radioGroup:"_radioGroup_nwf7i_6"},St=({displayType:r="dropdown",collapsible:i=!0,startCollapsed:g=!1})=>{const{state:{sortableFields:o,sortBy:d,sortAscending:S},setSort:y}=fe();if(!o||o.length===0)return null;const p=d?`${d}:${S?"asc":"desc"}`:"none",n=[{label:"None",value:"none"},...o.flatMap(T=>[{label:`${T} (asc)`,value:`${T}:asc`},{label:`${T} (desc)`,value:`${T}:desc`}])],F=T=>{if(T==="none"||T==="")y(null,!0);else{const[X,E]=T.split(":");y(X,E==="asc")}},R=i?g:!1;return e.jsx(f.FilterPanelBase,{title:"Sort by",collapsible:i,collapsed:R,children:r==="dropdown"?e.jsx(f.Select,{value:p,onValueChange:F,options:n,placeholder:"Select sort...","aria-label":"Sort by"}):e.jsx("div",{className:xt.radioGroup,children:n.map(T=>e.jsx(f.RadioButton,{id:`sort-${T.value}`,name:"sort-by",value:T.value,label:T.label,checked:p===T.value,onChange:X=>F(X.target.value)},T.value))})})},bt={list:"_list_1y4fk_1"};function jt(){const{state:{searchSettings:r},setSearchSettings:i}=fe(),[g,o]=s.useState(!1),d=(n,F)=>{const R=parseInt(F,10);isNaN(R)||i({[n]:R})},S=(n,F)=>{i({[n]:F})},y=(n,F)=>{const R=parseInt(F,10);isNaN(R)||i({coverageSetup:{...r.coverageSetup,[n]:R}})},p=(n,F)=>{i({coverageSetup:{...r.coverageSetup,[n]:F}})};return e.jsx(f.FilterPanelBase,{collapsed:!0,title:"Settings",children:e.jsxs("ul",{className:bt.list,children:[e.jsx("li",{children:e.jsx(f.InputField,{label:"Max Results",type:"number",value:r.maxNumberOfRecordsToReturn.toString(),onChange:n=>d("maxNumberOfRecordsToReturn",n.target.value)})}),e.jsx("li",{children:e.jsx(f.InputField,{label:"Coverage Depth",type:"number",value:r.coverageDepth.toString(),onChange:n=>d("coverageDepth",n.target.value)})}),e.jsxs("li",{children:[e.jsx(f.InputField,{label:"Minimum Score",type:"number",value:r.minimumScore.toString(),onChange:n=>{const F=parseFloat(n.target.value);isNaN(F)||i({minimumScore:F})}}),e.jsx("div",{style:{padding:"10px 10px 20px 10px"},children:e.jsx(f.Slider,{min:0,max:255,step:1,value:r.minimumScore,onChange:n=>{i({minimumScore:n})},"aria-label":"Minimum score"})})]}),e.jsx("li",{children:e.jsx(f.InputField,{label:"Placeholder text",type:"text",value:r.placeholderText,onChange:n=>{i({placeholderText:n.target.value})}})}),e.jsx("li",{children:e.jsx(f.ToggleSwitch,{label:"Show score",checked:r.showScore,onChange:n=>S("showScore",n)})}),e.jsx("li",{children:e.jsx(f.ToggleSwitch,{label:"Enable Coverage",checked:r.enableCoverage,onChange:n=>S("enableCoverage",n)})}),e.jsx("li",{children:e.jsx(f.ToggleSwitch,{label:"Remove Duplicates",checked:r.removeDuplicates,onChange:n=>S("removeDuplicates",n)})}),e.jsx("li",{children:e.jsx(f.Button,{variant:"ghost",size:"micro",iconRight:g?e.jsx(lt,{}):e.jsx(ct,{}),onClick:()=>o(n=>!n),children:g?"Hide Coverage Setup":"Show Coverage Setup"})}),g&&e.jsxs(e.Fragment,{children:[e.jsx("li",{children:e.jsx(f.ToggleSwitch,{label:"Cover Whole Query",checked:r.coverageSetup.coverWholeQuery,onChange:n=>p("coverWholeQuery",n)})}),e.jsx("li",{children:e.jsx(f.ToggleSwitch,{label:"Cover Whole Words",checked:r.coverageSetup.coverWholeWords,onChange:n=>p("coverWholeWords",n)})}),e.jsx("li",{children:e.jsx(f.ToggleSwitch,{label:"Cover Fuzzy Words",checked:r.coverageSetup.coverFuzzyWords,onChange:n=>p("coverFuzzyWords",n)})}),e.jsx("li",{children:e.jsx(f.ToggleSwitch,{label:"Cover Joined Words",checked:r.coverageSetup.coverJoinedWords,onChange:n=>p("coverJoinedWords",n)})}),e.jsx("li",{children:e.jsx(f.ToggleSwitch,{label:"Cover Prefix Suffix",checked:r.coverageSetup.coverPrefixSuffix,onChange:n=>p("coverPrefixSuffix",n)})}),e.jsx("li",{children:e.jsx(f.ToggleSwitch,{label:"Truncate list",checked:r.coverageSetup.truncate,onChange:n=>p("truncate",n)})}),e.jsx("li",{children:e.jsx(f.InputField,{label:"Levenshtein Max Word Size",type:"number",value:r.coverageSetup.levenshteinMaxWordSize.toString(),onChange:n=>y("levenshteinMaxWordSize",n.target.value)})}),e.jsx("li",{children:e.jsx(f.InputField,{label:"Min Word Size",type:"number",value:r.coverageSetup.minWordSize.toString(),onChange:n=>y("minWordSize",n.target.value)})}),e.jsx("li",{children:e.jsx(f.InputField,{label:"Coverage Min Word Hits Abs",type:"number",value:r.coverageSetup.coverageMinWordHitsAbs.toString(),onChange:n=>y("coverageMinWordHitsAbs",n.target.value)})}),e.jsx("li",{children:e.jsx(f.InputField,{label:"Coverage Min Word Hits Relative",type:"number",value:r.coverageSetup.coverageMinWordHitsRelative.toString(),onChange:n=>y("coverageMinWordHitsRelative",n.target.value)})}),e.jsx("li",{children:e.jsx(f.InputField,{label:"Coverage Q Limit For Error Tolerance",type:"number",value:r.coverageSetup.coverageQLimitForErrorTolerance.toString(),onChange:n=>y("coverageQLimitForErrorTolerance",n.target.value)})}),e.jsx("li",{children:e.jsx(f.InputField,{label:"Coverage LCS Error Tolerance Relative Q",type:"number",value:r.coverageSetup.coverageLcsErrorToleranceRelativeq.toString(),onChange:n=>y("coverageLcsErrorToleranceRelativeq",n.target.value)})})]})]})})}class yt extends s.Component{constructor(g){super(g);tt(this,"reset",()=>{this.setState({hasError:!1,error:null})});this.state={hasError:!1,error:null}}static getDerivedStateFromError(g){return{hasError:!0,error:g}}componentDidCatch(g,o){console.error("[SearchErrorBoundary] Caught error:",g,o)}render(){return this.state.hasError&&this.state.error?this.props.fallback?this.props.fallback(this.state.error,this.reset):e.jsxs("div",{style:{padding:"2rem",backgroundColor:"#fee",border:"2px solid #c33",borderRadius:"8px",maxWidth:"600px",margin:"2rem auto"},children:[e.jsx("h2",{style:{color:"#c33",marginTop:0},children:"⚠️ Search Initialization Error"}),e.jsxs("p",{style:{marginBottom:"1rem"},children:[e.jsx("strong",{children:"Error:"})," ",this.state.error.message]}),e.jsxs("div",{style:{backgroundColor:"#fff",padding:"1rem",borderRadius:"4px",marginBottom:"1rem",fontSize:"0.9rem"},children:[e.jsx("strong",{children:"💡 Common fixes:"}),e.jsxs("ul",{style:{marginBottom:0,paddingLeft:"1.5rem"},children:[e.jsx("li",{children:"Check browser console for detailed error messages"}),e.jsx("li",{children:"Verify NEXT_PUBLIC_INDX_URL is correct in .env.local"}),e.jsx("li",{children:"Verify NEXT_PUBLIC_INDX_EMAIL and NEXT_PUBLIC_INDX_PASSWORD are correct"}),e.jsx("li",{children:"Ensure INDX server is running"}),e.jsx("li",{children:"Check dataset name spelling"})]})]}),e.jsx("button",{onClick:this.reset,style:{padding:"0.5rem 1rem",backgroundColor:"#c33",color:"white",border:"none",borderRadius:"4px",cursor:"pointer",fontWeight:"bold"},children:"Try Again"})]}):this.props.children}}H.ActiveFiltersPanel=vt,H.RangeFilterPanel=ft,H.SearchErrorBoundary=yt,H.SearchInput=it,H.SearchProvider=at,H.SearchResults=dt,H.SearchSettingsPanel=jt,H.SortByPanel=St,H.ValueFilterPanel=ht,H.useSearch=fe,H.useSearchContext=fe,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})}));
package/dist/intrface.css CHANGED
@@ -1 +1 @@
1
- ._placeholder_mppwl_1{min-height:600px;height:100%;max-height:1000px;opacity:.05;display:flex;align-items:center;justify-content:center}._invalid_mppwl_10 p{padding:25px;font:var(--text-base)}._row_mppwl_14{padding:20px 25px 20px 30px;border-bottom:1px solid var(--lv0);font:var(--text-xs);position:relative;color:var(--lv5)}@media(prefers-color-scheme:dark){._row_mppwl_14{border-color:var(--lv2)}}._row_mppwl_14:last-child{border-bottom:none}._row_mppwl_14 h2{font:var(--text-base);color:var(--lv8)}._row_mppwl_14>div{display:flex;flex-direction:column;gap:10px}._indexNumber_mppwl_42{position:absolute;top:25px;left:5px;font:var(--text-2xs);color:var(--lv4)}._scoreNumber_mppwl_49{position:absolute;top:25px;right:5px;font:var(--text-2xs);color:var(--lv4)}._row_mppwl_14 span{color:var(--lv6);background-color:var(--lv0);font:var(--text-xs);margin-right:5px;border-radius:10px;padding:2px 6px}._list_mwzqq_2{display:flex;flex-direction:column;gap:10px}._count_mwzqq_7{display:flex;justify-content:space-between;align-items:center;font:var(--text-xs);color:var(--lv5)}._grid_mwzqq_16{display:flex;flex-wrap:wrap;gap:10px}._grid_mwzqq_16 li{flex:0 0 auto}._disabledMessage_o89gh_1{font:var(--text-2xs);margin-bottom:10px}._grid_nvpmn_2{display:flex;flex-wrap:wrap;gap:10px;list-style:none}._grid_nvpmn_2 li{flex:0 0 auto}._select_nwf7i_1{padding:6px 10px;font-size:14px}._radioGroup_nwf7i_6{display:flex;flex-direction:column;gap:6px}._list_1y4fk_1{display:flex;flex-direction:column;gap:15px;list-style-type:none}
1
+ ._placeholder_1k92x_1{min-height:600px;height:100%;max-height:1000px;opacity:.05;display:flex;align-items:center;justify-content:center}._invalid_1k92x_10 p{padding:25px;font:var(--text-base)}._row_1k92x_14{padding:20px 25px 20px 30px;border-bottom:1px solid var(--lv0);font:var(--text-xs);position:relative;color:var(--lv5)}@media(prefers-color-scheme:dark){._row_1k92x_14{border-color:var(--lv2)}}._row_1k92x_14:last-child{border-bottom:none}._row_1k92x_14>div{display:flex;flex-direction:column;gap:10px}._indexNumber_1k92x_38{position:absolute;top:25px;left:5px;font:var(--text-2xs);color:var(--lv4)}._scoreNumber_1k92x_45{position:absolute;top:25px;right:5px;font:var(--text-2xs);color:var(--lv4)}._row_1k92x_14 span{color:var(--lv6);background-color:var(--lv0);font:var(--text-xs);margin-right:5px;border-radius:10px;padding:2px 6px}._list_mwzqq_2{display:flex;flex-direction:column;gap:10px}._count_mwzqq_7{display:flex;justify-content:space-between;align-items:center;font:var(--text-xs);color:var(--lv5)}._grid_mwzqq_16{display:flex;flex-wrap:wrap;gap:10px}._grid_mwzqq_16 li{flex:0 0 auto}._disabledMessage_o89gh_1{font:var(--text-2xs);margin-bottom:10px}._grid_nvpmn_2{display:flex;flex-wrap:wrap;gap:10px;list-style:none}._grid_nvpmn_2 li{flex:0 0 auto}._select_nwf7i_1{padding:6px 10px;font-size:14px}._radioGroup_nwf7i_6{display:flex;flex-direction:column;gap:6px}._list_1y4fk_1{display:flex;flex-direction:column;gap:15px;list-style-type:none}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indxsearch/intrface",
3
- "version": "1.2.0",
3
+ "version": "2.0.0",
4
4
  "description": "Indx Search interface components for React. Provides ready-to-use filter panels, search inputs, faceted navigation, and sorting components. Built on @indxsearch/systm.",
5
5
  "keywords": [
6
6
  "indx",
@@ -18,7 +18,7 @@
18
18
  "typescript"
19
19
  ],
20
20
  "author": "Indx Search",
21
- "license": "MIT",
21
+ "license": "Apache-2.0",
22
22
  "source": "./src/index.tsx",
23
23
  "main": "./dist/index.umd.js",
24
24
  "module": "./dist/index.es.js",