@orchestrator-ui/orchestrator-ui-components 5.8.1 → 6.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.
Files changed (58) hide show
  1. package/.turbo/turbo-build.log +9 -9
  2. package/.turbo/turbo-lint.log +10 -1
  3. package/.turbo/turbo-test.log +11 -11
  4. package/CHANGELOG.md +12 -1
  5. package/__mocks__/@copilotkit/react-core.js +9 -0
  6. package/__mocks__/@copilotkit/react-ui.js +11 -0
  7. package/dist/index.d.ts +1429 -2
  8. package/dist/index.js +3175 -169
  9. package/dist/index.js.map +1 -1
  10. package/package.json +13 -9
  11. package/src/components/WfoAgent/FilterDisplay/FilterDisplay.tsx +182 -0
  12. package/src/components/WfoAgent/FilterDisplay/index.ts +1 -0
  13. package/src/components/WfoAgent/FilterDisplay/styles.ts +62 -0
  14. package/src/components/WfoAgent/WfoAgent/WfoAgent.tsx +100 -0
  15. package/src/components/WfoAgent/WfoAgent/index.ts +1 -0
  16. package/src/components/WfoAgent/index.ts +2 -0
  17. package/src/components/WfoSearchPage/WfoConditionRow/WfoConditionRow.tsx +388 -0
  18. package/src/components/WfoSearchPage/WfoConditionRow/WfoFieldSelector.tsx +43 -0
  19. package/src/components/WfoSearchPage/WfoConditionRow/WfoOperatorSelector.tsx +100 -0
  20. package/src/components/WfoSearchPage/WfoConditionRow/WfoPathChips.tsx +193 -0
  21. package/src/components/WfoSearchPage/WfoConditionRow/WfoPathSelector.tsx +54 -0
  22. package/src/components/WfoSearchPage/WfoConditionRow/WfoRenderFunctions.tsx +107 -0
  23. package/src/components/WfoSearchPage/WfoConditionRow/WfoSelectedPathDisplay.tsx +75 -0
  24. package/src/components/WfoSearchPage/WfoConditionRow/index.ts +11 -0
  25. package/src/components/WfoSearchPage/WfoConditionRow/types.ts +84 -0
  26. package/src/components/WfoSearchPage/WfoConditionRow/utils.ts +63 -0
  27. package/src/components/WfoSearchPage/WfoFilterGroup/WfoFilterGroup.tsx +238 -0
  28. package/src/components/WfoSearchPage/WfoFilterGroup/index.ts +1 -0
  29. package/src/components/WfoSearchPage/WfoSearch/WfoSearch.tsx +453 -0
  30. package/src/components/WfoSearchPage/WfoSearch/index.ts +1 -0
  31. package/src/components/WfoSearchPage/WfoSearchResults/WfoHighlightedText.tsx +63 -0
  32. package/src/components/WfoSearchPage/WfoSearchResults/WfoPathBreadcrumb.tsx +80 -0
  33. package/src/components/WfoSearchPage/WfoSearchResults/WfoSearchEmptyState.tsx +24 -0
  34. package/src/components/WfoSearchPage/WfoSearchResults/WfoSearchLoadingState.tsx +24 -0
  35. package/src/components/WfoSearchPage/WfoSearchResults/WfoSearchMetadataHeader.tsx +24 -0
  36. package/src/components/WfoSearchPage/WfoSearchResults/WfoSearchPaginationInfo.tsx +107 -0
  37. package/src/components/WfoSearchPage/WfoSearchResults/WfoSearchResultItem.tsx +157 -0
  38. package/src/components/WfoSearchPage/WfoSearchResults/WfoSearchResults.tsx +65 -0
  39. package/src/components/WfoSearchPage/WfoSearchResults/WfoSubscriptionDetailModal.tsx +55 -0
  40. package/src/components/WfoSearchPage/WfoSearchResults/index.ts +10 -0
  41. package/src/components/WfoSearchPage/WfoValueControl/WfoValueControl.tsx +247 -0
  42. package/src/components/WfoSearchPage/WfoValueControl/index.ts +1 -0
  43. package/src/components/WfoSearchPage/constants.ts +17 -0
  44. package/src/components/WfoSearchPage/index.ts +6 -0
  45. package/src/components/WfoSearchPage/utils.ts +271 -0
  46. package/src/components/WfoTree/treeUtils.spec.ts +3 -3
  47. package/src/components/index.ts +2 -0
  48. package/src/configuration/version.ts +1 -1
  49. package/src/hooks/useDebounce.ts +21 -0
  50. package/src/hooks/usePathAutoComplete.ts +133 -0
  51. package/src/hooks/useSearch.ts +83 -0
  52. package/src/hooks/useSearchPagination.ts +148 -0
  53. package/src/hooks/useUrlParams.ts +120 -0
  54. package/src/messages/en-GB.json +77 -0
  55. package/src/rtk/endpoints/index.ts +1 -0
  56. package/src/rtk/endpoints/search.ts +90 -0
  57. package/src/types/index.ts +1 -0
  58. package/src/types/search.ts +215 -0
package/dist/index.js CHANGED
@@ -4922,10 +4922,10 @@ var require_markup = __commonJS({
4922
4922
  var require_css = __commonJS({
4923
4923
  "../../node_modules/refractor/lang/css.js"(exports, module) {
4924
4924
  "use strict";
4925
- module.exports = css52;
4926
- css52.displayName = "css";
4927
- css52.aliases = [];
4928
- function css52(Prism) {
4925
+ module.exports = css54;
4926
+ css54.displayName = "css";
4927
+ css54.aliases = [];
4928
+ function css54(Prism) {
4929
4929
  ;
4930
4930
  (function(Prism2) {
4931
4931
  var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
@@ -5192,7 +5192,7 @@ var require_core = __commonJS({
5192
5192
  var decode = require_parse_entities();
5193
5193
  var Prism = require_prism_core();
5194
5194
  var markup = require_markup();
5195
- var css52 = require_css();
5195
+ var css54 = require_css();
5196
5196
  var clike = require_clike();
5197
5197
  var js = require_javascript();
5198
5198
  restore();
@@ -5208,7 +5208,7 @@ var require_core = __commonJS({
5208
5208
  refract.registered = registered;
5209
5209
  refract.listLanguages = listLanguages;
5210
5210
  register(markup);
5211
- register(css52);
5211
+ register(css54);
5212
5212
  register(clike);
5213
5213
  register(js);
5214
5214
  refract.util.encode = encode;
@@ -15304,10 +15304,10 @@ var require_jsstacktrace = __commonJS({
15304
15304
  var require_jsx = __commonJS({
15305
15305
  "../../node_modules/refractor/lang/jsx.js"(exports, module) {
15306
15306
  "use strict";
15307
- module.exports = jsx271;
15308
- jsx271.displayName = "jsx";
15309
- jsx271.aliases = [];
15310
- function jsx271(Prism) {
15307
+ module.exports = jsx292;
15308
+ jsx292.displayName = "jsx";
15309
+ jsx292.aliases = [];
15310
+ function jsx292(Prism) {
15311
15311
  ;
15312
15312
  (function(Prism2) {
15313
15313
  var javascript = Prism2.util.clone(Prism2.languages.javascript);
@@ -26801,7 +26801,7 @@ var PolicyResource = /* @__PURE__ */ ((PolicyResource2) => {
26801
26801
  })(PolicyResource || {});
26802
26802
 
26803
26803
  // src/configuration/version.ts
26804
- var ORCHESTRATOR_UI_LIBRARY_VERSION = "5.8.1";
26804
+ var ORCHESTRATOR_UI_LIBRARY_VERSION = "6.0.0";
26805
26805
 
26806
26806
  // src/types/types.ts
26807
26807
  var EngineStatus = /* @__PURE__ */ ((EngineStatus3) => {
@@ -27166,10 +27166,10 @@ function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, une
27166
27166
  function assertReducerShape(reducers) {
27167
27167
  Object.keys(reducers).forEach((key) => {
27168
27168
  const reducer = reducers[key];
27169
- const initialState3 = reducer(void 0, {
27169
+ const initialState4 = reducer(void 0, {
27170
27170
  type: actionTypes_default.INIT
27171
27171
  });
27172
- if (typeof initialState3 === "undefined") {
27172
+ if (typeof initialState4 === "undefined") {
27173
27173
  throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(12) : `The slice reducer for key "${key}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);
27174
27174
  }
27175
27175
  if (typeof reducer(void 0, {
@@ -29066,6 +29066,21 @@ function executeReducerBuilderCallback(builderCallback) {
29066
29066
  actionsMap[type] = reducer;
29067
29067
  return builder;
29068
29068
  },
29069
+ addAsyncThunk(asyncThunk, reducers) {
29070
+ if (process.env.NODE_ENV !== "production") {
29071
+ if (defaultCaseReducer) {
29072
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage2(43) : "`builder.addAsyncThunk` should only be called before calling `builder.addDefaultCase`");
29073
+ }
29074
+ }
29075
+ if (reducers.pending) actionsMap[asyncThunk.pending.type] = reducers.pending;
29076
+ if (reducers.rejected) actionsMap[asyncThunk.rejected.type] = reducers.rejected;
29077
+ if (reducers.fulfilled) actionsMap[asyncThunk.fulfilled.type] = reducers.fulfilled;
29078
+ if (reducers.settled) actionMatchers.push({
29079
+ matcher: asyncThunk.settled,
29080
+ reducer: reducers.settled
29081
+ });
29082
+ return builder;
29083
+ },
29069
29084
  addMatcher(matcher, reducer) {
29070
29085
  if (process.env.NODE_ENV !== "production") {
29071
29086
  if (defaultCaseReducer) {
@@ -29094,7 +29109,7 @@ function executeReducerBuilderCallback(builderCallback) {
29094
29109
  function isStateFunction(x) {
29095
29110
  return typeof x === "function";
29096
29111
  }
29097
- function createReducer(initialState3, mapOrBuilderCallback) {
29112
+ function createReducer(initialState4, mapOrBuilderCallback) {
29098
29113
  if (process.env.NODE_ENV !== "production") {
29099
29114
  if (typeof mapOrBuilderCallback === "object") {
29100
29115
  throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage2(8) : "The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");
@@ -29102,10 +29117,10 @@ function createReducer(initialState3, mapOrBuilderCallback) {
29102
29117
  }
29103
29118
  let [actionsMap, finalActionMatchers, finalDefaultCaseReducer] = executeReducerBuilderCallback(mapOrBuilderCallback);
29104
29119
  let getInitialState;
29105
- if (isStateFunction(initialState3)) {
29106
- getInitialState = () => freezeDraftable(initialState3());
29120
+ if (isStateFunction(initialState4)) {
29121
+ getInitialState = () => freezeDraftable(initialState4());
29107
29122
  } else {
29108
- const frozenInitialState = freezeDraftable(initialState3);
29123
+ const frozenInitialState = freezeDraftable(initialState4);
29109
29124
  getInitialState = () => frozenInitialState;
29110
29125
  }
29111
29126
  function reducer(state = getInitialState(), action) {
@@ -29817,6 +29832,11 @@ function getOrInsert(map, key, value) {
29817
29832
  if (map.has(key)) return map.get(key);
29818
29833
  return map.set(key, value).get(key);
29819
29834
  }
29835
+ function getOrInsertComputed2(map, key, compute) {
29836
+ if (map.has(key)) return map.get(key);
29837
+ return map.set(key, compute(key)).get(key);
29838
+ }
29839
+ var createNewMap = () => /* @__PURE__ */ new Map();
29820
29840
  var defaultFetchFn = (...args) => fetch(...args);
29821
29841
  var defaultValidateStatus = (response) => response.status >= 200 && response.status <= 299;
29822
29842
  var defaultIsJsonContentType = (headers) => (
@@ -30028,10 +30048,13 @@ function buildInitiate({
30028
30048
  infiniteQueryThunk,
30029
30049
  mutationThunk,
30030
30050
  api,
30031
- context
30051
+ context,
30052
+ internalState
30032
30053
  }) {
30033
- const runningQueries = /* @__PURE__ */ new Map();
30034
- const runningMutations = /* @__PURE__ */ new Map();
30054
+ const {
30055
+ runningQueries,
30056
+ runningMutations
30057
+ } = internalState;
30035
30058
  const {
30036
30059
  unsubscribeQueryResult,
30037
30060
  removeMutationResult,
@@ -30266,6 +30289,7 @@ var NamedSchemaError = class extends SchemaError {
30266
30289
  this._bqMeta = _bqMeta;
30267
30290
  }
30268
30291
  };
30292
+ var shouldSkip = (skipSchemaValidation, schemaName) => Array.isArray(skipSchemaValidation) ? skipSchemaValidation.includes(schemaName) : !!skipSchemaValidation;
30269
30293
  async function parseWithSchema(schema, data, schemaName, bqMeta) {
30270
30294
  const result = await schema["~standard"].validate(data);
30271
30295
  if (result.issues) {
@@ -30397,7 +30421,7 @@ function buildThunks({
30397
30421
  skipSchemaValidation = globalSkipSchemaValidation
30398
30422
  } = endpointDefinition;
30399
30423
  try {
30400
- let transformResponse = getTransformCallbackForEndpoint(endpointDefinition, "transformResponse");
30424
+ let transformResponse = defaultTransformResponse;
30401
30425
  const baseQueryApi = {
30402
30426
  signal,
30403
30427
  abort,
@@ -30439,7 +30463,7 @@ function buildThunks({
30439
30463
  rawResponseSchema,
30440
30464
  responseSchema
30441
30465
  } = endpointDefinition;
30442
- if (argSchema && !skipSchemaValidation) {
30466
+ if (argSchema && !shouldSkip(skipSchemaValidation, "arg")) {
30443
30467
  finalQueryArg = await parseWithSchema(
30444
30468
  argSchema,
30445
30469
  finalQueryArg,
@@ -30451,6 +30475,7 @@ function buildThunks({
30451
30475
  if (forceQueryFn) {
30452
30476
  result = forceQueryFn();
30453
30477
  } else if (endpointDefinition.query) {
30478
+ transformResponse = getTransformCallbackForEndpoint(endpointDefinition, "transformResponse");
30454
30479
  result = await baseQuery(endpointDefinition.query(finalQueryArg), baseQueryApi, extraOptions);
30455
30480
  } else {
30456
30481
  result = await endpointDefinition.queryFn(finalQueryArg, baseQueryApi, extraOptions, (arg2) => baseQuery(arg2, baseQueryApi, extraOptions));
@@ -30485,11 +30510,11 @@ function buildThunks({
30485
30510
  let {
30486
30511
  data
30487
30512
  } = result;
30488
- if (rawResponseSchema && !skipSchemaValidation) {
30513
+ if (rawResponseSchema && !shouldSkip(skipSchemaValidation, "rawResponse")) {
30489
30514
  data = await parseWithSchema(rawResponseSchema, result.data, "rawResponseSchema", result.meta);
30490
30515
  }
30491
30516
  let transformedResponse = await transformResponse(data, result.meta, finalQueryArg);
30492
- if (responseSchema && !skipSchemaValidation) {
30517
+ if (responseSchema && !shouldSkip(skipSchemaValidation, "response")) {
30493
30518
  transformedResponse = await parseWithSchema(responseSchema, transformedResponse, "responseSchema", result.meta);
30494
30519
  }
30495
30520
  return {
@@ -30518,7 +30543,7 @@ function buildThunks({
30518
30543
  if ("direction" in arg && arg.direction && existingData.pages.length) {
30519
30544
  const previous = arg.direction === "backward";
30520
30545
  const pageParamFn = previous ? getPreviousPageParam : getNextPageParam;
30521
- const param = pageParamFn(infiniteQueryOptions, existingData);
30546
+ const param = pageParamFn(infiniteQueryOptions, existingData, arg.originalArgs);
30522
30547
  result = await fetchPage(existingData, param, maxPages, previous);
30523
30548
  } else {
30524
30549
  const {
@@ -30534,7 +30559,7 @@ function buildThunks({
30534
30559
  };
30535
30560
  }
30536
30561
  for (let i = 1; i < totalPages; i++) {
30537
- const param = getNextPageParam(infiniteQueryOptions, result.data);
30562
+ const param = getNextPageParam(infiniteQueryOptions, result.data, arg.originalArgs);
30538
30563
  result = await fetchPage(result.data, param, maxPages);
30539
30564
  }
30540
30565
  }
@@ -30542,7 +30567,7 @@ function buildThunks({
30542
30567
  } else {
30543
30568
  finalQueryReturnValue = await executeRequest(arg.originalArgs);
30544
30569
  }
30545
- if (metaSchema && !skipSchemaValidation && finalQueryReturnValue.meta) {
30570
+ if (metaSchema && !shouldSkip(skipSchemaValidation, "meta") && finalQueryReturnValue.meta) {
30546
30571
  finalQueryReturnValue.meta = await parseWithSchema(metaSchema, finalQueryReturnValue.meta, "metaSchema", finalQueryReturnValue.meta);
30547
30572
  }
30548
30573
  return fulfillWithValue(finalQueryReturnValue.data, addShouldAutoBatch({
@@ -30562,14 +30587,14 @@ function buildThunks({
30562
30587
  meta
30563
30588
  } = caughtError;
30564
30589
  try {
30565
- if (rawErrorResponseSchema && !skipSchemaValidation) {
30590
+ if (rawErrorResponseSchema && !shouldSkip(skipSchemaValidation, "rawErrorResponse")) {
30566
30591
  value = await parseWithSchema(rawErrorResponseSchema, value, "rawErrorResponseSchema", meta);
30567
30592
  }
30568
- if (metaSchema && !skipSchemaValidation) {
30593
+ if (metaSchema && !shouldSkip(skipSchemaValidation, "meta")) {
30569
30594
  meta = await parseWithSchema(metaSchema, meta, "metaSchema", meta);
30570
30595
  }
30571
30596
  let transformedErrorResponse = await transformErrorResponse(value, meta, arg.originalArgs);
30572
- if (errorResponseSchema && !skipSchemaValidation) {
30597
+ if (errorResponseSchema && !shouldSkip(skipSchemaValidation, "errorResponse")) {
30573
30598
  transformedErrorResponse = await parseWithSchema(errorResponseSchema, transformedErrorResponse, "errorResponseSchema", meta);
30574
30599
  }
30575
30600
  return rejectWithValue(transformedErrorResponse, addShouldAutoBatch({
@@ -30731,15 +30756,15 @@ In the case of an unhandled error, no tags will be "provided" or "invalidated".`
30731
30756
  function getNextPageParam(options, {
30732
30757
  pages,
30733
30758
  pageParams
30734
- }) {
30759
+ }, queryArg) {
30735
30760
  const lastIndex = pages.length - 1;
30736
- return options.getNextPageParam(pages[lastIndex], pages, pageParams[lastIndex], pageParams);
30761
+ return options.getNextPageParam(pages[lastIndex], pages, pageParams[lastIndex], pageParams, queryArg);
30737
30762
  }
30738
30763
  function getPreviousPageParam(options, {
30739
30764
  pages,
30740
30765
  pageParams
30741
- }) {
30742
- return options.getPreviousPageParam?.(pages[0], pages, pageParams[0], pageParams);
30766
+ }, queryArg) {
30767
+ return options.getPreviousPageParam?.(pages[0], pages, pageParams[0], pageParams, queryArg);
30743
30768
  }
30744
30769
  function calculateProvidedByThunk(action, type, endpointDefinitions, assertTagType) {
30745
30770
  return calculateProvidedBy(endpointDefinitions[action.meta.arg.endpointName][type], isFulfilled(action) ? action.payload : void 0, isRejectedWithValue(action) ? action.payload : void 0, action.meta.arg.originalArgs, "baseQueryMeta" in action.meta ? action.meta.baseQueryMeta : void 0, assertTagType);
@@ -31084,7 +31109,7 @@ function buildSlice({
31084
31109
  const {
31085
31110
  provided
31086
31111
  } = extractRehydrationInfo(action);
31087
- for (const [type, incomingTags] of Object.entries(provided)) {
31112
+ for (const [type, incomingTags] of Object.entries(provided.tags ?? {})) {
31088
31113
  for (const [id, cacheKeys] of Object.entries(incomingTags)) {
31089
31114
  const subscribedQueries = (_b = (_a = draft.tags)[type] ?? (_a[type] = {}))[_c = id || "__internal_without_id"] ?? (_b[_c] = []);
31090
31115
  for (const queryCacheKey of cacheKeys) {
@@ -31092,6 +31117,7 @@ function buildSlice({
31092
31117
  if (!alreadySubscribed) {
31093
31118
  subscribedQueries.push(queryCacheKey);
31094
31119
  }
31120
+ draft.keys[queryCacheKey] = provided.keys[queryCacheKey];
31095
31121
  }
31096
31122
  }
31097
31123
  }
@@ -31308,8 +31334,8 @@ function buildSelectors({
31308
31334
  const isBackward = direction === "backward";
31309
31335
  return {
31310
31336
  ...stateWithRequestFlags,
31311
- hasNextPage: getHasNextPage(infiniteQueryOptions, stateWithRequestFlags.data),
31312
- hasPreviousPage: getHasPreviousPage(infiniteQueryOptions, stateWithRequestFlags.data),
31337
+ hasNextPage: getHasNextPage(infiniteQueryOptions, stateWithRequestFlags.data, stateWithRequestFlags.originalArgs),
31338
+ hasPreviousPage: getHasPreviousPage(infiniteQueryOptions, stateWithRequestFlags.data, stateWithRequestFlags.originalArgs),
31313
31339
  isFetchingNextPage: isLoading && isForward,
31314
31340
  isFetchingPreviousPage: isLoading && isBackward,
31315
31341
  isFetchNextPageError: isError2 && isForward,
@@ -31365,13 +31391,13 @@ function buildSelectors({
31365
31391
  /* uninitialized */
31366
31392
  ).map((entry) => entry.originalArgs);
31367
31393
  }
31368
- function getHasNextPage(options, data) {
31394
+ function getHasNextPage(options, data, queryArg) {
31369
31395
  if (!data) return false;
31370
- return getNextPageParam(options, data) != null;
31396
+ return getNextPageParam(options, data, queryArg) != null;
31371
31397
  }
31372
- function getHasPreviousPage(options, data) {
31398
+ function getHasPreviousPage(options, data, queryArg) {
31373
31399
  if (!data || !options.getPreviousPageParam) return false;
31374
- return getPreviousPageParam(options, data) != null;
31400
+ return getPreviousPageParam(options, data, queryArg) != null;
31375
31401
  }
31376
31402
  }
31377
31403
  var cache = WeakMap ? /* @__PURE__ */ new WeakMap() : void 0;
@@ -31539,7 +31565,8 @@ function safeAssign(target, ...args) {
31539
31565
  var buildBatchedActionsHandler = ({
31540
31566
  api,
31541
31567
  queryThunk,
31542
- internalState
31568
+ internalState,
31569
+ mwApi
31543
31570
  }) => {
31544
31571
  const subscriptionsPrefix = `${api.reducerPath}/subscriptions`;
31545
31572
  let previousSubscriptions = null;
@@ -31548,16 +31575,16 @@ var buildBatchedActionsHandler = ({
31548
31575
  updateSubscriptionOptions,
31549
31576
  unsubscribeQueryResult
31550
31577
  } = api.internalActions;
31551
- const actuallyMutateSubscriptions = (mutableState, action) => {
31552
- var _a, _b;
31578
+ const actuallyMutateSubscriptions = (currentSubscriptions, action) => {
31553
31579
  if (updateSubscriptionOptions.match(action)) {
31554
31580
  const {
31555
31581
  queryCacheKey,
31556
31582
  requestId,
31557
31583
  options
31558
31584
  } = action.payload;
31559
- if (mutableState?.[queryCacheKey]?.[requestId]) {
31560
- mutableState[queryCacheKey][requestId] = options;
31585
+ const sub = currentSubscriptions.get(queryCacheKey);
31586
+ if (sub?.has(requestId)) {
31587
+ sub.set(requestId, options);
31561
31588
  }
31562
31589
  return true;
31563
31590
  }
@@ -31566,13 +31593,14 @@ var buildBatchedActionsHandler = ({
31566
31593
  queryCacheKey,
31567
31594
  requestId
31568
31595
  } = action.payload;
31569
- if (mutableState[queryCacheKey]) {
31570
- delete mutableState[queryCacheKey][requestId];
31596
+ const sub = currentSubscriptions.get(queryCacheKey);
31597
+ if (sub) {
31598
+ sub.delete(requestId);
31571
31599
  }
31572
31600
  return true;
31573
31601
  }
31574
31602
  if (api.internalActions.removeQueryResult.match(action)) {
31575
- delete mutableState[action.payload.queryCacheKey];
31603
+ currentSubscriptions.delete(action.payload.queryCacheKey);
31576
31604
  return true;
31577
31605
  }
31578
31606
  if (queryThunk.pending.match(action)) {
@@ -31582,20 +31610,13 @@ var buildBatchedActionsHandler = ({
31582
31610
  requestId
31583
31611
  }
31584
31612
  } = action;
31585
- const substate = mutableState[_a = arg.queryCacheKey] ?? (mutableState[_a] = {});
31586
- substate[`${requestId}_running`] = {};
31613
+ const substate = getOrInsertComputed2(currentSubscriptions, arg.queryCacheKey, createNewMap);
31587
31614
  if (arg.subscribe) {
31588
- substate[requestId] = arg.subscriptionOptions ?? substate[requestId] ?? {};
31615
+ substate.set(requestId, arg.subscriptionOptions ?? substate.get(requestId) ?? {});
31589
31616
  }
31590
31617
  return true;
31591
31618
  }
31592
31619
  let mutated = false;
31593
- if (queryThunk.fulfilled.match(action) || queryThunk.rejected.match(action)) {
31594
- const state = mutableState[action.meta.arg.queryCacheKey] || {};
31595
- const key = `${action.meta.requestId}_running`;
31596
- mutated || (mutated = !!state[key]);
31597
- delete state[key];
31598
- }
31599
31620
  if (queryThunk.rejected.match(action)) {
31600
31621
  const {
31601
31622
  meta: {
@@ -31605,8 +31626,8 @@ var buildBatchedActionsHandler = ({
31605
31626
  }
31606
31627
  } = action;
31607
31628
  if (condition && arg.subscribe) {
31608
- const substate = mutableState[_b = arg.queryCacheKey] ?? (mutableState[_b] = {});
31609
- substate[requestId] = arg.subscriptionOptions ?? substate[requestId] ?? {};
31629
+ const substate = getOrInsertComputed2(currentSubscriptions, arg.queryCacheKey, createNewMap);
31630
+ substate.set(requestId, arg.subscriptionOptions ?? substate.get(requestId) ?? {});
31610
31631
  mutated = true;
31611
31632
  }
31612
31633
  }
@@ -31615,24 +31636,28 @@ var buildBatchedActionsHandler = ({
31615
31636
  const getSubscriptions = () => internalState.currentSubscriptions;
31616
31637
  const getSubscriptionCount = (queryCacheKey) => {
31617
31638
  const subscriptions = getSubscriptions();
31618
- const subscriptionsForQueryArg = subscriptions[queryCacheKey] ?? {};
31619
- return countObjectKeys(subscriptionsForQueryArg);
31639
+ const subscriptionsForQueryArg = subscriptions.get(queryCacheKey);
31640
+ return subscriptionsForQueryArg?.size ?? 0;
31620
31641
  };
31621
31642
  const isRequestSubscribed = (queryCacheKey, requestId) => {
31622
31643
  const subscriptions = getSubscriptions();
31623
- return !!subscriptions?.[queryCacheKey]?.[requestId];
31644
+ return !!subscriptions?.get(queryCacheKey)?.get(requestId);
31624
31645
  };
31625
31646
  const subscriptionSelectors = {
31626
31647
  getSubscriptions,
31627
31648
  getSubscriptionCount,
31628
31649
  isRequestSubscribed
31629
31650
  };
31630
- return (action, mwApi) => {
31651
+ function serializeSubscriptions(currentSubscriptions) {
31652
+ return JSON.parse(JSON.stringify(Object.fromEntries([...currentSubscriptions].map(([k, v]) => [k, Object.fromEntries(v)]))));
31653
+ }
31654
+ return (action, mwApi2) => {
31631
31655
  if (!previousSubscriptions) {
31632
- previousSubscriptions = JSON.parse(JSON.stringify(internalState.currentSubscriptions));
31656
+ previousSubscriptions = serializeSubscriptions(internalState.currentSubscriptions);
31633
31657
  }
31634
31658
  if (api.util.resetApiState.match(action)) {
31635
- previousSubscriptions = internalState.currentSubscriptions = {};
31659
+ previousSubscriptions = {};
31660
+ internalState.currentSubscriptions.clear();
31636
31661
  updateSyncTimer = null;
31637
31662
  return [true, false];
31638
31663
  }
@@ -31641,12 +31666,15 @@ var buildBatchedActionsHandler = ({
31641
31666
  }
31642
31667
  const didMutate = actuallyMutateSubscriptions(internalState.currentSubscriptions, action);
31643
31668
  let actionShouldContinue = true;
31669
+ if (process.env.NODE_ENV === "test" && typeof action.type === "string" && action.type === `${api.reducerPath}/getPolling`) {
31670
+ return [false, internalState.currentPolls];
31671
+ }
31644
31672
  if (didMutate) {
31645
31673
  if (!updateSyncTimer) {
31646
31674
  updateSyncTimer = setTimeout(() => {
31647
- const newSubscriptions = JSON.parse(JSON.stringify(internalState.currentSubscriptions));
31675
+ const newSubscriptions = serializeSubscriptions(internalState.currentSubscriptions);
31648
31676
  const [, patches] = produceWithPatches(previousSubscriptions, () => newSubscriptions);
31649
- mwApi.next(api.internalActions.subscriptionsUpdated(patches));
31677
+ mwApi2.next(api.internalActions.subscriptionsUpdated(patches));
31650
31678
  previousSubscriptions = newSubscriptions;
31651
31679
  updateSyncTimer = null;
31652
31680
  }, 500);
@@ -31658,12 +31686,6 @@ var buildBatchedActionsHandler = ({
31658
31686
  return [actionShouldContinue, false];
31659
31687
  };
31660
31688
  };
31661
- function isObjectEmpty(obj) {
31662
- for (const k in obj) {
31663
- return false;
31664
- }
31665
- return true;
31666
- }
31667
31689
  var THIRTY_TWO_BIT_MAX_TIMER_SECONDS = 2147483647 / 1e3 - 1;
31668
31690
  var buildCacheCollectionHandler = ({
31669
31691
  reducerPath,
@@ -31674,21 +31696,29 @@ var buildCacheCollectionHandler = ({
31674
31696
  selectors: {
31675
31697
  selectQueryEntry,
31676
31698
  selectConfig
31677
- }
31699
+ },
31700
+ getRunningQueryThunk,
31701
+ mwApi
31678
31702
  }) => {
31679
31703
  const {
31680
31704
  removeQueryResult,
31681
31705
  unsubscribeQueryResult,
31682
31706
  cacheEntriesUpserted
31683
31707
  } = api.internalActions;
31708
+ const runningQueries = internalState.runningQueries.get(mwApi.dispatch);
31684
31709
  const canTriggerUnsubscribe = isAnyOf(unsubscribeQueryResult.match, queryThunk.fulfilled, queryThunk.rejected, cacheEntriesUpserted.match);
31685
31710
  function anySubscriptionsRemainingForKey(queryCacheKey) {
31686
- const subscriptions = internalState.currentSubscriptions[queryCacheKey];
31687
- return !!subscriptions && !isObjectEmpty(subscriptions);
31711
+ const subscriptions = internalState.currentSubscriptions.get(queryCacheKey);
31712
+ if (!subscriptions) {
31713
+ return false;
31714
+ }
31715
+ const hasSubscriptions = subscriptions.size > 0;
31716
+ const isRunning = runningQueries?.[queryCacheKey] !== void 0;
31717
+ return hasSubscriptions || isRunning;
31688
31718
  }
31689
31719
  const currentRemovalTimeouts = {};
31690
- const handler = (action, mwApi, internalState2) => {
31691
- const state = mwApi.getState();
31720
+ const handler = (action, mwApi2, internalState2) => {
31721
+ const state = mwApi2.getState();
31692
31722
  const config = selectConfig(state);
31693
31723
  if (canTriggerUnsubscribe(action)) {
31694
31724
  let queryCacheKeys;
@@ -31700,7 +31730,7 @@ var buildCacheCollectionHandler = ({
31700
31730
  } = unsubscribeQueryResult.match(action) ? action.payload : action.meta.arg;
31701
31731
  queryCacheKeys = [queryCacheKey];
31702
31732
  }
31703
- handleUnsubscribeMany(queryCacheKeys, mwApi, config);
31733
+ handleUnsubscribeMany(queryCacheKeys, mwApi2, config);
31704
31734
  }
31705
31735
  if (api.util.resetApiState.match(action)) {
31706
31736
  for (const [key, timeout] of Object.entries(currentRemovalTimeouts)) {
@@ -31712,14 +31742,16 @@ var buildCacheCollectionHandler = ({
31712
31742
  const {
31713
31743
  queries
31714
31744
  } = context.extractRehydrationInfo(action);
31715
- handleUnsubscribeMany(Object.keys(queries), mwApi, config);
31745
+ handleUnsubscribeMany(Object.keys(queries), mwApi2, config);
31716
31746
  }
31717
31747
  };
31718
31748
  function handleUnsubscribeMany(cacheKeys, api2, config) {
31719
31749
  const state = api2.getState();
31720
31750
  for (const queryCacheKey of cacheKeys) {
31721
31751
  const entry = selectQueryEntry(state, queryCacheKey);
31722
- handleUnsubscribe(queryCacheKey, entry?.endpointName, api2, config);
31752
+ if (entry?.endpointName) {
31753
+ handleUnsubscribe(queryCacheKey, entry.endpointName, api2, config);
31754
+ }
31723
31755
  }
31724
31756
  }
31725
31757
  function handleUnsubscribe(queryCacheKey, endpointName, api2, config) {
@@ -31736,6 +31768,11 @@ var buildCacheCollectionHandler = ({
31736
31768
  }
31737
31769
  currentRemovalTimeouts[queryCacheKey] = setTimeout(() => {
31738
31770
  if (!anySubscriptionsRemainingForKey(queryCacheKey)) {
31771
+ const entry = selectQueryEntry(api2.getState(), queryCacheKey);
31772
+ if (entry?.endpointName) {
31773
+ const runningQuery = api2.dispatch(getRunningQueryThunk(entry.endpointName, entry.originalArgs));
31774
+ runningQuery?.abort();
31775
+ }
31739
31776
  api2.dispatch(removeQueryResult({
31740
31777
  queryCacheKey
31741
31778
  }));
@@ -31940,9 +31977,9 @@ var buildInvalidationByTagsHandler = ({
31940
31977
  queryCacheKey
31941
31978
  } of valuesArray) {
31942
31979
  const querySubState = state.queries[queryCacheKey];
31943
- const subscriptionSubState = internalState.currentSubscriptions[queryCacheKey] ?? {};
31980
+ const subscriptionSubState = getOrInsertComputed2(internalState.currentSubscriptions, queryCacheKey, createNewMap);
31944
31981
  if (querySubState) {
31945
- if (countObjectKeys(subscriptionSubState) === 0) {
31982
+ if (subscriptionSubState.size === 0) {
31946
31983
  mwApi.dispatch(removeQueryResult({
31947
31984
  queryCacheKey
31948
31985
  }));
@@ -31962,25 +31999,49 @@ var buildPollingHandler = ({
31962
31999
  refetchQuery,
31963
32000
  internalState
31964
32001
  }) => {
31965
- const currentPolls = {};
32002
+ const {
32003
+ currentPolls,
32004
+ currentSubscriptions
32005
+ } = internalState;
32006
+ const pendingPollingUpdates = /* @__PURE__ */ new Set();
32007
+ let pollingUpdateTimer = null;
31966
32008
  const handler = (action, mwApi) => {
31967
32009
  if (api.internalActions.updateSubscriptionOptions.match(action) || api.internalActions.unsubscribeQueryResult.match(action)) {
31968
- updatePollingInterval(action.payload, mwApi);
32010
+ schedulePollingUpdate(action.payload.queryCacheKey, mwApi);
31969
32011
  }
31970
32012
  if (queryThunk.pending.match(action) || queryThunk.rejected.match(action) && action.meta.condition) {
31971
- updatePollingInterval(action.meta.arg, mwApi);
32013
+ schedulePollingUpdate(action.meta.arg.queryCacheKey, mwApi);
31972
32014
  }
31973
32015
  if (queryThunk.fulfilled.match(action) || queryThunk.rejected.match(action) && !action.meta.condition) {
31974
32016
  startNextPoll(action.meta.arg, mwApi);
31975
32017
  }
31976
32018
  if (api.util.resetApiState.match(action)) {
31977
32019
  clearPolls();
32020
+ if (pollingUpdateTimer) {
32021
+ clearTimeout(pollingUpdateTimer);
32022
+ pollingUpdateTimer = null;
32023
+ }
32024
+ pendingPollingUpdates.clear();
31978
32025
  }
31979
32026
  };
32027
+ function schedulePollingUpdate(queryCacheKey, api2) {
32028
+ pendingPollingUpdates.add(queryCacheKey);
32029
+ if (!pollingUpdateTimer) {
32030
+ pollingUpdateTimer = setTimeout(() => {
32031
+ for (const key of pendingPollingUpdates) {
32032
+ updatePollingInterval({
32033
+ queryCacheKey: key
32034
+ }, api2);
32035
+ }
32036
+ pendingPollingUpdates.clear();
32037
+ pollingUpdateTimer = null;
32038
+ }, 0);
32039
+ }
32040
+ }
31980
32041
  function getCacheEntrySubscriptions(queryCacheKey, api2) {
31981
32042
  const state = api2.getState()[reducerPath];
31982
32043
  const querySubState = state.queries[queryCacheKey];
31983
- const subscriptions = internalState.currentSubscriptions[queryCacheKey];
32044
+ const subscriptions = currentSubscriptions.get(queryCacheKey);
31984
32045
  if (!querySubState || querySubState.status === "uninitialized") return;
31985
32046
  return subscriptions;
31986
32047
  }
@@ -31989,20 +32050,20 @@ var buildPollingHandler = ({
31989
32050
  }, api2) {
31990
32051
  const state = api2.getState()[reducerPath];
31991
32052
  const querySubState = state.queries[queryCacheKey];
31992
- const subscriptions = internalState.currentSubscriptions[queryCacheKey];
32053
+ const subscriptions = currentSubscriptions.get(queryCacheKey);
31993
32054
  if (!querySubState || querySubState.status === "uninitialized") return;
31994
32055
  const {
31995
32056
  lowestPollingInterval,
31996
32057
  skipPollingIfUnfocused
31997
32058
  } = findLowestPollingInterval(subscriptions);
31998
32059
  if (!Number.isFinite(lowestPollingInterval)) return;
31999
- const currentPoll = currentPolls[queryCacheKey];
32060
+ const currentPoll = currentPolls.get(queryCacheKey);
32000
32061
  if (currentPoll?.timeout) {
32001
32062
  clearTimeout(currentPoll.timeout);
32002
32063
  currentPoll.timeout = void 0;
32003
32064
  }
32004
32065
  const nextPollTimestamp = Date.now() + lowestPollingInterval;
32005
- currentPolls[queryCacheKey] = {
32066
+ currentPolls.set(queryCacheKey, {
32006
32067
  nextPollTimestamp,
32007
32068
  pollingInterval: lowestPollingInterval,
32008
32069
  timeout: setTimeout(() => {
@@ -32013,25 +32074,30 @@ var buildPollingHandler = ({
32013
32074
  queryCacheKey
32014
32075
  }, api2);
32015
32076
  }, lowestPollingInterval)
32016
- };
32077
+ });
32017
32078
  }
32018
32079
  function updatePollingInterval({
32019
32080
  queryCacheKey
32020
32081
  }, api2) {
32021
32082
  const state = api2.getState()[reducerPath];
32022
32083
  const querySubState = state.queries[queryCacheKey];
32023
- const subscriptions = internalState.currentSubscriptions[queryCacheKey];
32084
+ const subscriptions = currentSubscriptions.get(queryCacheKey);
32024
32085
  if (!querySubState || querySubState.status === "uninitialized") {
32025
32086
  return;
32026
32087
  }
32027
32088
  const {
32028
32089
  lowestPollingInterval
32029
32090
  } = findLowestPollingInterval(subscriptions);
32091
+ if (process.env.NODE_ENV === "test") {
32092
+ const updateCounters = currentPolls.pollUpdateCounters ?? (currentPolls.pollUpdateCounters = {});
32093
+ updateCounters[queryCacheKey] ?? (updateCounters[queryCacheKey] = 0);
32094
+ updateCounters[queryCacheKey]++;
32095
+ }
32030
32096
  if (!Number.isFinite(lowestPollingInterval)) {
32031
32097
  cleanupPollForKey(queryCacheKey);
32032
32098
  return;
32033
32099
  }
32034
- const currentPoll = currentPolls[queryCacheKey];
32100
+ const currentPoll = currentPolls.get(queryCacheKey);
32035
32101
  const nextPollTimestamp = Date.now() + lowestPollingInterval;
32036
32102
  if (!currentPoll || nextPollTimestamp < currentPoll.nextPollTimestamp) {
32037
32103
  startNextPoll({
@@ -32040,24 +32106,24 @@ var buildPollingHandler = ({
32040
32106
  }
32041
32107
  }
32042
32108
  function cleanupPollForKey(key) {
32043
- const existingPoll = currentPolls[key];
32109
+ const existingPoll = currentPolls.get(key);
32044
32110
  if (existingPoll?.timeout) {
32045
32111
  clearTimeout(existingPoll.timeout);
32046
32112
  }
32047
- delete currentPolls[key];
32113
+ currentPolls.delete(key);
32048
32114
  }
32049
32115
  function clearPolls() {
32050
- for (const key of Object.keys(currentPolls)) {
32116
+ for (const key of currentPolls.keys()) {
32051
32117
  cleanupPollForKey(key);
32052
32118
  }
32053
32119
  }
32054
- function findLowestPollingInterval(subscribers = {}) {
32120
+ function findLowestPollingInterval(subscribers = /* @__PURE__ */ new Map()) {
32055
32121
  let skipPollingIfUnfocused = false;
32056
32122
  let lowestPollingInterval = Number.POSITIVE_INFINITY;
32057
- for (let key in subscribers) {
32058
- if (!!subscribers[key].pollingInterval) {
32059
- lowestPollingInterval = Math.min(subscribers[key].pollingInterval, lowestPollingInterval);
32060
- skipPollingIfUnfocused = subscribers[key].skipPollingIfUnfocused || skipPollingIfUnfocused;
32123
+ for (const entry of subscribers.values()) {
32124
+ if (!!entry.pollingInterval) {
32125
+ lowestPollingInterval = Math.min(entry.pollingInterval, lowestPollingInterval);
32126
+ skipPollingIfUnfocused = entry.skipPollingIfUnfocused || skipPollingIfUnfocused;
32061
32127
  }
32062
32128
  }
32063
32129
  return {
@@ -32158,13 +32224,14 @@ var buildWindowEventHandler = ({
32158
32224
  const queries = state.queries;
32159
32225
  const subscriptions = internalState.currentSubscriptions;
32160
32226
  context.batch(() => {
32161
- for (const queryCacheKey of Object.keys(subscriptions)) {
32227
+ for (const queryCacheKey of subscriptions.keys()) {
32162
32228
  const querySubState = queries[queryCacheKey];
32163
- const subscriptionSubState = subscriptions[queryCacheKey];
32229
+ const subscriptionSubState = subscriptions.get(queryCacheKey);
32164
32230
  if (!subscriptionSubState || !querySubState) continue;
32165
- const shouldRefetch = Object.values(subscriptionSubState).some((sub) => sub[type] === true) || Object.values(subscriptionSubState).every((sub) => sub[type] === void 0) && state.config[type];
32231
+ const values = [...subscriptionSubState.values()];
32232
+ const shouldRefetch = values.some((sub) => sub[type] === true) || values.every((sub) => sub[type] === void 0) && state.config[type];
32166
32233
  if (shouldRefetch) {
32167
- if (countObjectKeys(subscriptionSubState) === 0) {
32234
+ if (subscriptionSubState.size === 0) {
32168
32235
  api2.dispatch(removeQueryResult({
32169
32236
  queryCacheKey
32170
32237
  }));
@@ -32182,7 +32249,8 @@ function buildMiddleware(input) {
32182
32249
  reducerPath,
32183
32250
  queryThunk,
32184
32251
  api,
32185
- context
32252
+ context,
32253
+ internalState
32186
32254
  } = input;
32187
32255
  const {
32188
32256
  apiUid
@@ -32194,14 +32262,12 @@ function buildMiddleware(input) {
32194
32262
  const handlerBuilders = [buildDevCheckHandler, buildCacheCollectionHandler, buildInvalidationByTagsHandler, buildPollingHandler, buildCacheLifecycleHandler, buildQueryLifecycleHandler];
32195
32263
  const middleware = (mwApi) => {
32196
32264
  let initialized2 = false;
32197
- const internalState = {
32198
- currentSubscriptions: {}
32199
- };
32200
32265
  const builderArgs = {
32201
32266
  ...input,
32202
32267
  internalState,
32203
32268
  refetchQuery,
32204
- isThisApiSliceAction
32269
+ isThisApiSliceAction,
32270
+ mwApi
32205
32271
  };
32206
32272
  const handlers = handlerBuilders.map((build) => build(builderArgs));
32207
32273
  const batchedActionsHandler = buildBatchedActionsHandler(builderArgs);
@@ -32356,24 +32422,12 @@ var coreModule = ({
32356
32422
  upsertQueryEntries: sliceActions.cacheEntriesUpserted
32357
32423
  });
32358
32424
  safeAssign(api.internalActions, sliceActions);
32359
- const {
32360
- middleware,
32361
- actions: middlewareActions
32362
- } = buildMiddleware({
32363
- reducerPath,
32364
- context,
32365
- queryThunk,
32366
- mutationThunk,
32367
- infiniteQueryThunk,
32368
- api,
32369
- assertTagType,
32370
- selectors
32371
- });
32372
- safeAssign(api.util, middlewareActions);
32373
- safeAssign(api, {
32374
- reducer,
32375
- middleware
32376
- });
32425
+ const internalState = {
32426
+ currentSubscriptions: /* @__PURE__ */ new Map(),
32427
+ currentPolls: /* @__PURE__ */ new Map(),
32428
+ runningQueries: /* @__PURE__ */ new Map(),
32429
+ runningMutations: /* @__PURE__ */ new Map()
32430
+ };
32377
32431
  const {
32378
32432
  buildInitiateQuery,
32379
32433
  buildInitiateInfiniteQuery,
@@ -32388,7 +32442,8 @@ var coreModule = ({
32388
32442
  infiniteQueryThunk,
32389
32443
  api,
32390
32444
  serializeQueryArgs,
32391
- context
32445
+ context,
32446
+ internalState
32392
32447
  });
32393
32448
  safeAssign(api.util, {
32394
32449
  getRunningMutationThunk,
@@ -32396,6 +32451,26 @@ var coreModule = ({
32396
32451
  getRunningQueryThunk,
32397
32452
  getRunningQueriesThunk
32398
32453
  });
32454
+ const {
32455
+ middleware,
32456
+ actions: middlewareActions
32457
+ } = buildMiddleware({
32458
+ reducerPath,
32459
+ context,
32460
+ queryThunk,
32461
+ mutationThunk,
32462
+ infiniteQueryThunk,
32463
+ api,
32464
+ assertTagType,
32465
+ selectors,
32466
+ getRunningQueryThunk,
32467
+ internalState
32468
+ });
32469
+ safeAssign(api.util, middlewareActions);
32470
+ safeAssign(api, {
32471
+ reducer,
32472
+ middleware
32473
+ });
32399
32474
  return {
32400
32475
  name: coreModuleName,
32401
32476
  injectEndpoint(endpointName, definition) {
@@ -32463,22 +32538,15 @@ function safeAssign2(target, ...args) {
32463
32538
  return Object.assign(target, ...args);
32464
32539
  }
32465
32540
  var UNINITIALIZED_VALUE = Symbol();
32466
- function useStableQueryArgs(queryArgs, serialize, endpointDefinition, endpointName) {
32467
- const incoming = useMemo(() => ({
32468
- queryArgs,
32469
- serialized: typeof queryArgs == "object" ? serialize({
32470
- queryArgs,
32471
- endpointDefinition,
32472
- endpointName
32473
- }) : queryArgs
32474
- }), [queryArgs, serialize, endpointDefinition, endpointName]);
32475
- const cache2 = useRef(incoming);
32541
+ function useStableQueryArgs(queryArgs) {
32542
+ const cache2 = useRef(queryArgs);
32543
+ const copy = useMemo(() => copyWithStructuralSharing(cache2.current, queryArgs), [queryArgs]);
32476
32544
  useEffect(() => {
32477
- if (cache2.current.serialized !== incoming.serialized) {
32478
- cache2.current = incoming;
32545
+ if (cache2.current !== copy) {
32546
+ cache2.current = copy;
32479
32547
  }
32480
- }, [incoming]);
32481
- return cache2.current.serialized === incoming.serialized ? cache2.current.queryArgs : queryArgs;
32548
+ }, [copy]);
32549
+ return copy;
32482
32550
  }
32483
32551
  function useShallowStableValue(value) {
32484
32552
  const cache2 = useRef2(value);
@@ -32631,17 +32699,7 @@ function buildHooks({
32631
32699
  }
32632
32700
  subscriptionSelectorsRef.current = returnedValue;
32633
32701
  }
32634
- const stableArg = useStableQueryArgs(
32635
- skip ? skipToken : arg,
32636
- // Even if the user provided a per-endpoint `serializeQueryArgs` with
32637
- // a consistent return value, _here_ we want to use the default behavior
32638
- // so we can tell if _anything_ actually changed. Otherwise, we can end up
32639
- // with a case where the query args did change but the serialization doesn't,
32640
- // and then we never try to initiate a refetch.
32641
- defaultSerializeQueryArgs,
32642
- context.endpointDefinitions[endpointName],
32643
- endpointName
32644
- );
32702
+ const stableArg = useStableQueryArgs(skip ? skipToken : arg);
32645
32703
  const stableSubscriptionOptions = useShallowStableValue({
32646
32704
  refetchOnReconnect,
32647
32705
  refetchOnFocus,
@@ -32700,7 +32758,7 @@ function buildHooks({
32700
32758
  const {
32701
32759
  select
32702
32760
  } = api.endpoints[endpointName];
32703
- const stableArg = useStableQueryArgs(skip ? skipToken : arg, serializeQueryArgs, context.endpointDefinitions[endpointName], endpointName);
32761
+ const stableArg = useStableQueryArgs(skip ? skipToken : arg);
32704
32762
  const lastValue = useRef3(void 0);
32705
32763
  const selectDefaultResult = useMemo2(() => (
32706
32764
  // Normally ts-ignores are bad and should be avoided, but we're
@@ -32872,17 +32930,7 @@ function buildHooks({
32872
32930
  return promise;
32873
32931
  }, [promiseRef, dispatch, initiate]);
32874
32932
  usePromiseRefUnsubscribeOnUnmount(promiseRef);
32875
- const stableArg = useStableQueryArgs(
32876
- options.skip ? skipToken : arg,
32877
- // Even if the user provided a per-endpoint `serializeQueryArgs` with
32878
- // a consistent return value, _here_ we want to use the default behavior
32879
- // so we can tell if _anything_ actually changed. Otherwise, we can end up
32880
- // with a case where the query args did change but the serialization doesn't,
32881
- // and then we never try to initiate a refetch.
32882
- defaultSerializeQueryArgs,
32883
- context.endpointDefinitions[endpointName],
32884
- endpointName
32885
- );
32933
+ const stableArg = useStableQueryArgs(options.skip ? skipToken : arg);
32886
32934
  const refetch = useCallback(() => refetchOrErrorIfUnmounted(promiseRef), [promiseRef]);
32887
32935
  return useMemo2(() => {
32888
32936
  const fetchNextPage = () => {
@@ -35451,6 +35499,234 @@ var fileUploadApi = orchestratorApi.injectEndpoints({
35451
35499
  });
35452
35500
  var { useUploadFileMutation } = fileUploadApi;
35453
35501
 
35502
+ // src/components/WfoSearchPage/utils.ts
35503
+ function isSubscriptionSearchResult(item) {
35504
+ return "subscription" in item && typeof item.subscription === "object";
35505
+ }
35506
+ function isProcessSearchResult(item) {
35507
+ return "process" in item && typeof item.process === "object";
35508
+ }
35509
+ function isProductSearchResult(item) {
35510
+ return "product" in item && typeof item.product === "object";
35511
+ }
35512
+ function isWorkflowSearchResult(item) {
35513
+ return "workflow" in item && typeof item.workflow === "object";
35514
+ }
35515
+ var isCondition = (item) => {
35516
+ return "path" in item && "condition" in item;
35517
+ };
35518
+ var ENDPOINT_PATHS = {
35519
+ PROCESS: "processes",
35520
+ PRODUCT: "products",
35521
+ WORKFLOW: "workflows",
35522
+ SUBSCRIPTION: "subscriptions"
35523
+ };
35524
+ var getEndpointPath = (entityType) => {
35525
+ return ENDPOINT_PATHS[entityType] || ENDPOINT_PATHS.SUBSCRIPTION;
35526
+ };
35527
+ var getDisplayText = (item) => {
35528
+ if (isSubscriptionSearchResult(item)) {
35529
+ return item.subscription.description || "Subscription";
35530
+ }
35531
+ if (isProcessSearchResult(item)) {
35532
+ return item.process.workflowName;
35533
+ }
35534
+ if (isProductSearchResult(item)) {
35535
+ return item.product.name;
35536
+ }
35537
+ if (isWorkflowSearchResult(item)) {
35538
+ return item.workflow.name;
35539
+ }
35540
+ return "Unknown result type";
35541
+ };
35542
+ var getRecordId = (result) => {
35543
+ if (isSubscriptionSearchResult(result)) {
35544
+ return result.subscription.subscription_id;
35545
+ }
35546
+ if (isProductSearchResult(result)) {
35547
+ return result.product.product_id;
35548
+ }
35549
+ if (isProcessSearchResult(result)) {
35550
+ return result.process.processId;
35551
+ }
35552
+ if (isWorkflowSearchResult(result)) {
35553
+ return result.workflow.name;
35554
+ }
35555
+ return "";
35556
+ };
35557
+ var findResultIndexById = (results, recordId) => {
35558
+ return results.findIndex((result) => {
35559
+ if (isSubscriptionSearchResult(result)) {
35560
+ return result.subscription.subscription_id === recordId;
35561
+ }
35562
+ if (isProductSearchResult(result)) {
35563
+ return result.product.product_id === recordId;
35564
+ }
35565
+ if (isProcessSearchResult(result)) {
35566
+ return result.process.processId === recordId;
35567
+ }
35568
+ if (isWorkflowSearchResult(result)) {
35569
+ return result.workflow.name === recordId;
35570
+ }
35571
+ return false;
35572
+ });
35573
+ };
35574
+ var getDetailUrl = (result, baseUrl) => {
35575
+ if (isSubscriptionSearchResult(result)) {
35576
+ return `${baseUrl}/subscriptions/${result.subscription.subscription_id}`;
35577
+ }
35578
+ if (isProductSearchResult(result)) {
35579
+ return `${baseUrl}/products/${result.product.product_id}`;
35580
+ }
35581
+ if (isProcessSearchResult(result)) {
35582
+ return `${baseUrl}/processes/${result.process.processId}`;
35583
+ }
35584
+ if (isWorkflowSearchResult(result)) {
35585
+ return `${baseUrl}/workflows/${result.workflow.name}`;
35586
+ }
35587
+ return "#";
35588
+ };
35589
+ var getDescription = (result) => {
35590
+ if (isSubscriptionSearchResult(result)) {
35591
+ return result.subscription.description;
35592
+ }
35593
+ if (isProductSearchResult(result)) {
35594
+ return result.product.description || result.product.name;
35595
+ }
35596
+ if (isWorkflowSearchResult(result)) {
35597
+ return result.workflow.description || result.workflow.name;
35598
+ }
35599
+ if (isProcessSearchResult(result)) {
35600
+ return result.process.workflowName;
35601
+ }
35602
+ return "Unknown";
35603
+ };
35604
+ var ENTITY_TABS = [
35605
+ { id: "SUBSCRIPTION", label: "Subscriptions" },
35606
+ { id: "PRODUCT", label: "Products" },
35607
+ { id: "WORKFLOW", label: "Workflows" },
35608
+ { id: "PROCESS", label: "Processes" }
35609
+ ];
35610
+ var TYPE_COLOR_MAP = {
35611
+ string: "success",
35612
+ number: "primary",
35613
+ boolean: "warning",
35614
+ datetime: "accent",
35615
+ component: "primary"
35616
+ };
35617
+ var getTypeColor = (type, theme) => {
35618
+ const colorKey = TYPE_COLOR_MAP[type.toLowerCase()];
35619
+ return colorKey ? theme.colors[colorKey] : theme.colors.textSubdued;
35620
+ };
35621
+ var OPERATOR_MAP = {
35622
+ eq: { symbol: "=", description: "equals" },
35623
+ neq: { symbol: "\u2260", description: "not equals" },
35624
+ lt: { symbol: "<", description: "less than" },
35625
+ lte: { symbol: "\u2264", description: "less than or equal to" },
35626
+ gt: { symbol: ">", description: "greater than" },
35627
+ gte: { symbol: "\u2265", description: "greater than or equal to" },
35628
+ between: { symbol: "\u27F7", description: "between (range)" },
35629
+ has_component: { symbol: "\u2713", description: "has component" },
35630
+ not_has_component: { symbol: "\u2717", description: "does not have component" }
35631
+ };
35632
+ var BOOLEAN_OPERATOR_MAP = {
35633
+ eq: { symbol: "\u2713", description: "is true" },
35634
+ neq: { symbol: "\u2717", description: "is false" }
35635
+ };
35636
+ var getOperatorDisplay = (op, selectedPathInfo) => {
35637
+ if (selectedPathInfo?.type === "boolean" && BOOLEAN_OPERATOR_MAP[op]) {
35638
+ return BOOLEAN_OPERATOR_MAP[op];
35639
+ }
35640
+ return OPERATOR_MAP[op] || { symbol: op, description: op };
35641
+ };
35642
+ var getButtonColor = (op, pathInfo, condition) => {
35643
+ if (pathInfo?.type === "boolean") {
35644
+ const isSelected = op === "eq" ? condition.condition.value === true : condition.condition.value === false;
35645
+ return isSelected ? "primary" : "text";
35646
+ }
35647
+ return condition.condition.op === op ? "primary" : "text";
35648
+ };
35649
+ var getButtonFill = (op, pathInfo, condition) => {
35650
+ if (pathInfo?.type === "boolean") {
35651
+ return op === "eq" ? condition.condition.value === true : condition.condition.value === false;
35652
+ }
35653
+ return condition.condition.op === op;
35654
+ };
35655
+ var isFilterValid = (group) => {
35656
+ return group.children.every((child) => {
35657
+ if (isCondition(child)) {
35658
+ return child.path && child.condition.op && child.condition.value !== void 0;
35659
+ }
35660
+ return isFilterValid(child);
35661
+ });
35662
+ };
35663
+ var buildSearchParams = (debouncedQuery, selectedEntityTab, filterGroup, pageSize) => {
35664
+ const queryText = typeof debouncedQuery === "string" ? debouncedQuery : debouncedQuery?.text?.trim() || "";
35665
+ return {
35666
+ action: "select",
35667
+ entity_type: selectedEntityTab,
35668
+ query: queryText || "",
35669
+ filters: filterGroup?.children.length > 0 ? filterGroup : void 0,
35670
+ limit: pageSize
35671
+ };
35672
+ };
35673
+
35674
+ // src/rtk/endpoints/search.ts
35675
+ var searchApi = orchestratorApi.injectEndpoints({
35676
+ endpoints: (build) => ({
35677
+ search: build.mutation({
35678
+ query: (payload) => ({
35679
+ url: `search/${getEndpointPath(payload.entity_type)}`,
35680
+ method: "POST",
35681
+ body: payload,
35682
+ headers: {
35683
+ "Content-Type": "application/json"
35684
+ }
35685
+ }),
35686
+ extraOptions: {
35687
+ baseQueryType: "fetch" /* fetch */
35688
+ }
35689
+ }),
35690
+ searchWithPagination: build.mutation({
35691
+ query: ({ cursor, ...payload }) => ({
35692
+ url: `search/${getEndpointPath(payload.entity_type)}?cursor=${cursor}`,
35693
+ method: "POST",
35694
+ body: payload,
35695
+ headers: {
35696
+ "Content-Type": "application/json"
35697
+ }
35698
+ }),
35699
+ extraOptions: {
35700
+ baseQueryType: "fetch" /* fetch */
35701
+ }
35702
+ }),
35703
+ searchPaths: build.query({
35704
+ query: ({ q, entity_type }) => ({
35705
+ url: `search/paths?q=${encodeURIComponent(q)}&entity_type=${entity_type}`,
35706
+ method: "GET"
35707
+ }),
35708
+ extraOptions: {
35709
+ baseQueryType: "fetch" /* fetch */
35710
+ }
35711
+ }),
35712
+ searchDefinitions: build.query({
35713
+ query: () => ({
35714
+ url: "search/definitions",
35715
+ method: "GET"
35716
+ }),
35717
+ extraOptions: {
35718
+ baseQueryType: "fetch" /* fetch */
35719
+ }
35720
+ })
35721
+ })
35722
+ });
35723
+ var {
35724
+ useSearchMutation,
35725
+ useSearchWithPaginationMutation,
35726
+ useSearchPathsQuery,
35727
+ useSearchDefinitionsQuery
35728
+ } = searchApi;
35729
+
35454
35730
  // src/hooks/useCheckEngineStatus.ts
35455
35731
  var useCheckEngineStatus = () => {
35456
35732
  const { data, isLoading, refetch } = useGetEngineStatusQuery();
@@ -39060,7 +39336,7 @@ var WfoHeaderBadge = ({
39060
39336
  children,
39061
39337
  ...restProps
39062
39338
  }) => {
39063
- const css52 = restProps.iconType ? {
39339
+ const css54 = restProps.iconType ? {
39064
39340
  height: 24,
39065
39341
  display: "flex",
39066
39342
  paddingLeft: 0
@@ -39068,7 +39344,7 @@ var WfoHeaderBadge = ({
39068
39344
  height: 24,
39069
39345
  display: "flex"
39070
39346
  };
39071
- return /* @__PURE__ */ jsx73(WfoBadge, { ...restProps, css: css52, children });
39347
+ return /* @__PURE__ */ jsx73(WfoBadge, { ...restProps, css: css54, children });
39072
39348
  };
39073
39349
 
39074
39350
  // src/components/WfoBadges/WfoEnvironmentBadge/WfoEnvironmentBadge.tsx
@@ -55913,6 +56189,2610 @@ var WfoTableCodeBlock = ({
55913
56189
  ) });
55914
56190
  };
55915
56191
 
56192
+ // src/components/WfoSearchPage/WfoSearch/WfoSearch.tsx
56193
+ import { useEffect as useEffect43, useState as useState64 } from "react";
56194
+ import { useTranslations as useTranslations104 } from "next-intl";
56195
+ import {
56196
+ EuiButton as EuiButton24,
56197
+ EuiCallOut as EuiCallOut3,
56198
+ EuiFieldSearch as EuiFieldSearch3,
56199
+ EuiFlexGroup as EuiFlexGroup45,
56200
+ EuiFlexItem as EuiFlexItem52,
56201
+ EuiPanel as EuiPanel20,
56202
+ EuiSpacer as EuiSpacer32,
56203
+ EuiTab as EuiTab4,
56204
+ EuiTabs as EuiTabs4,
56205
+ EuiText as EuiText60
56206
+ } from "@elastic/eui";
56207
+
56208
+ // src/hooks/useDebounce.ts
56209
+ import { useEffect as useEffect38, useState as useState57 } from "react";
56210
+ function useDebounce(value, delay) {
56211
+ const [debouncedValue, setDebouncedValue] = useState57(value);
56212
+ useEffect38(() => {
56213
+ if (delay <= 0) {
56214
+ setDebouncedValue(value);
56215
+ return;
56216
+ }
56217
+ const handler = setTimeout(() => {
56218
+ setDebouncedValue(value);
56219
+ }, delay);
56220
+ return () => {
56221
+ clearTimeout(handler);
56222
+ };
56223
+ }, [value, delay]);
56224
+ return debouncedValue;
56225
+ }
56226
+
56227
+ // src/hooks/useSearch.ts
56228
+ import { useEffect as useEffect39, useState as useState58 } from "react";
56229
+ var useSearch = (query, entityType, filterGroup, limit) => {
56230
+ const [results, setResults] = useState58({
56231
+ data: [],
56232
+ page_info: { has_next_page: false, next_page_cursor: null },
56233
+ search_metadata: { search_type: null, description: null }
56234
+ });
56235
+ const [triggerSearch, { isLoading, isError: isError2 }] = useSearchMutation();
56236
+ useEffect39(() => {
56237
+ const queryText = typeof query === "string" ? query : query.text?.trim() || "";
56238
+ const hasFilters = filterGroup && filterGroup.children.length > 0;
56239
+ if (queryText.length < 2 && !hasFilters) {
56240
+ setResults({
56241
+ data: [],
56242
+ page_info: { has_next_page: false, next_page_cursor: null },
56243
+ search_metadata: { search_type: null, description: null }
56244
+ });
56245
+ return;
56246
+ }
56247
+ const performSearch = async () => {
56248
+ try {
56249
+ const result = await triggerSearch({
56250
+ action: "select",
56251
+ entity_type: entityType,
56252
+ query: queryText,
56253
+ filters: filterGroup && filterGroup.children.length > 0 ? filterGroup : void 0,
56254
+ limit
56255
+ }).unwrap();
56256
+ setResults({
56257
+ data: result.data || [],
56258
+ page_info: {
56259
+ has_next_page: result.page_info?.has_next_page || false,
56260
+ next_page_cursor: result.page_info?.next_page_cursor || null
56261
+ },
56262
+ search_metadata: {
56263
+ search_type: result.search_metadata?.search_type || null,
56264
+ description: result.search_metadata?.description || null
56265
+ }
56266
+ });
56267
+ } catch (error) {
56268
+ console.error("Search error:", error);
56269
+ setResults({
56270
+ data: [],
56271
+ page_info: { has_next_page: false, next_page_cursor: null },
56272
+ search_metadata: { search_type: null, description: null }
56273
+ });
56274
+ }
56275
+ };
56276
+ performSearch();
56277
+ }, [query, entityType, filterGroup, limit, triggerSearch]);
56278
+ return {
56279
+ results,
56280
+ loading: isLoading,
56281
+ error: isError2 ? "Search failed" : null,
56282
+ setResults
56283
+ };
56284
+ };
56285
+
56286
+ // src/hooks/useSearchPagination.ts
56287
+ import { useCallback as useCallback10, useState as useState59 } from "react";
56288
+ var useSearchPagination = (debouncedQuery, selectedEntityTab, filterGroup, pageSize, results, setResults) => {
56289
+ const [currentPage, setCurrentPage] = useState59(1);
56290
+ const [pageHistory, setPageHistory] = useState59([]);
56291
+ const [error, setError] = useState59(null);
56292
+ const [isLoadingMore, setIsLoadingMore] = useState59(false);
56293
+ const [triggerSearchPagination] = useSearchWithPaginationMutation();
56294
+ const handleNextPage = useCallback10(
56295
+ async (nextPageCursor) => {
56296
+ if (!nextPageCursor || isLoadingMore) return;
56297
+ setIsLoadingMore(true);
56298
+ setPageHistory((prev) => [
56299
+ ...prev.filter((p) => p.page !== currentPage),
56300
+ {
56301
+ page: currentPage,
56302
+ results: results.data,
56303
+ cursor: results.page_info.next_page_cursor
56304
+ }
56305
+ ]);
56306
+ try {
56307
+ setError(null);
56308
+ const searchParams = buildSearchParams(
56309
+ debouncedQuery,
56310
+ selectedEntityTab,
56311
+ filterGroup,
56312
+ pageSize
56313
+ );
56314
+ const res = await triggerSearchPagination({
56315
+ ...searchParams,
56316
+ cursor: nextPageCursor
56317
+ }).unwrap();
56318
+ setResults({
56319
+ data: res.data || [],
56320
+ page_info: {
56321
+ has_next_page: res.page_info.has_next_page,
56322
+ next_page_cursor: res.page_info.next_page_cursor
56323
+ },
56324
+ search_metadata: {
56325
+ search_type: res.search_metadata.search_type,
56326
+ description: res.search_metadata.description
56327
+ }
56328
+ });
56329
+ setCurrentPage((prev) => prev + 1);
56330
+ } catch (error2) {
56331
+ const errorMessage = error2 instanceof Error ? error2.message : "An unexpected error occurred while loading the next page";
56332
+ setError(errorMessage);
56333
+ console.error("Load next page error:", error2);
56334
+ } finally {
56335
+ setIsLoadingMore(false);
56336
+ }
56337
+ },
56338
+ [
56339
+ currentPage,
56340
+ results.data,
56341
+ results.page_info.next_page_cursor,
56342
+ isLoadingMore,
56343
+ debouncedQuery,
56344
+ selectedEntityTab,
56345
+ filterGroup,
56346
+ pageSize,
56347
+ setResults,
56348
+ triggerSearchPagination
56349
+ ]
56350
+ );
56351
+ const handlePrevPage = useCallback10(() => {
56352
+ const previousPage = pageHistory.find(
56353
+ (p) => p.page === currentPage - 1
56354
+ );
56355
+ if (previousPage) {
56356
+ setResults({
56357
+ data: previousPage.results,
56358
+ page_info: {
56359
+ has_next_page: true,
56360
+ next_page_cursor: previousPage.cursor
56361
+ },
56362
+ search_metadata: results.search_metadata
56363
+ });
56364
+ setCurrentPage((prev) => prev - 1);
56365
+ setPageHistory((prev) => prev.filter((p) => p.page < currentPage));
56366
+ }
56367
+ }, [currentPage, pageHistory, results.search_metadata, setResults]);
56368
+ const resetPagination = useCallback10(() => {
56369
+ setCurrentPage(1);
56370
+ setPageHistory([]);
56371
+ }, []);
56372
+ return {
56373
+ currentPage,
56374
+ pageHistory,
56375
+ error,
56376
+ isLoadingMore,
56377
+ handleNextPage,
56378
+ handlePrevPage,
56379
+ resetPagination,
56380
+ setError
56381
+ };
56382
+ };
56383
+
56384
+ // src/hooks/useUrlParams.ts
56385
+ import { useCallback as useCallback11, useEffect as useEffect40, useState as useState60 } from "react";
56386
+
56387
+ // src/components/WfoSearchPage/constants.ts
56388
+ var DEFAULT_PAGE_SIZE2 = 5;
56389
+ var DEFAULT_DEBOUNCE_DELAY = 300;
56390
+ var SMALL_RESULT_THRESHOLD = 10;
56391
+ var LAYOUT_RATIOS = {
56392
+ RESULTS_GROW: 2,
56393
+ DETAIL_GROW: 3
56394
+ };
56395
+ var VALID_ENTITY_TYPES = [
56396
+ "SUBSCRIPTION",
56397
+ "PRODUCT",
56398
+ "WORKFLOW",
56399
+ "PROCESS"
56400
+ ];
56401
+ var DEFAULT_ENTITY_TAB = "SUBSCRIPTION";
56402
+
56403
+ // src/hooks/useUrlParams.ts
56404
+ var useUrlParams = () => {
56405
+ const [urlParams, setUrlParams] = useState60(() => {
56406
+ if (typeof window !== "undefined") {
56407
+ return new URLSearchParams(window.location.search);
56408
+ }
56409
+ return new URLSearchParams();
56410
+ });
56411
+ const [query, setQuery] = useState60(() => {
56412
+ const queryParam = urlParams.get("q");
56413
+ return queryParam || "";
56414
+ });
56415
+ const [selectedEntityTab, setSelectedEntityTab] = useState60(
56416
+ () => {
56417
+ const tabParam = urlParams.get("tab");
56418
+ return tabParam && VALID_ENTITY_TYPES.includes(tabParam) ? tabParam : DEFAULT_ENTITY_TAB;
56419
+ }
56420
+ );
56421
+ const [showFilters, setShowFilters] = useState60(() => {
56422
+ return urlParams.get("filters") === "true";
56423
+ });
56424
+ const [selectedRecordIndex, setSelectedRecordIndex] = useState60(
56425
+ () => {
56426
+ const indexParam = urlParams.get("selected");
56427
+ return indexParam ? parseInt(indexParam, 10) || 0 : 0;
56428
+ }
56429
+ );
56430
+ const [selectedRecordId, setSelectedRecordId] = useState60(
56431
+ () => {
56432
+ return urlParams.get("id") || null;
56433
+ }
56434
+ );
56435
+ const updateUrl = useCallback11(() => {
56436
+ const newParams = new URLSearchParams();
56437
+ const queryText = typeof query === "string" ? query : query.text || "";
56438
+ if (queryText && queryText !== "*") {
56439
+ newParams.set("q", queryText);
56440
+ }
56441
+ if (selectedEntityTab !== DEFAULT_ENTITY_TAB) {
56442
+ newParams.set("tab", selectedEntityTab);
56443
+ }
56444
+ if (showFilters) {
56445
+ newParams.set("filters", "true");
56446
+ }
56447
+ if (selectedRecordIndex > 0) {
56448
+ newParams.set("selected", selectedRecordIndex.toString());
56449
+ }
56450
+ if (selectedRecordId) {
56451
+ newParams.set("id", selectedRecordId);
56452
+ }
56453
+ const newUrl = newParams.toString() ? `${window.location.pathname}?${newParams.toString()}` : window.location.pathname;
56454
+ window.history.replaceState({}, "", newUrl);
56455
+ setUrlParams(newParams);
56456
+ }, [
56457
+ query,
56458
+ selectedEntityTab,
56459
+ showFilters,
56460
+ selectedRecordIndex,
56461
+ selectedRecordId
56462
+ ]);
56463
+ useEffect40(() => {
56464
+ updateUrl();
56465
+ }, [updateUrl]);
56466
+ return {
56467
+ urlParams,
56468
+ query,
56469
+ selectedEntityTab,
56470
+ showFilters,
56471
+ selectedRecordIndex,
56472
+ selectedRecordId,
56473
+ setQuery,
56474
+ setSelectedEntityTab,
56475
+ setShowFilters,
56476
+ setSelectedRecordIndex,
56477
+ setSelectedRecordId
56478
+ };
56479
+ };
56480
+
56481
+ // src/components/WfoSearchPage/WfoFilterGroup/WfoFilterGroup.tsx
56482
+ import { useTranslations as useTranslations98 } from "next-intl";
56483
+ import {
56484
+ EuiButton as EuiButton22,
56485
+ EuiButtonIcon as EuiButtonIcon16,
56486
+ EuiCallOut as EuiCallOut2,
56487
+ EuiCode,
56488
+ EuiFlexGroup as EuiFlexGroup38,
56489
+ EuiFlexItem as EuiFlexItem46,
56490
+ EuiPanel as EuiPanel15,
56491
+ EuiSpacer as EuiSpacer30,
56492
+ EuiText as EuiText55
56493
+ } from "@elastic/eui";
56494
+
56495
+ // src/components/WfoSearchPage/WfoConditionRow/WfoConditionRow.tsx
56496
+ import { useState as useState62 } from "react";
56497
+ import { useTranslations as useTranslations97 } from "next-intl";
56498
+ import {
56499
+ EuiButtonIcon as EuiButtonIcon15,
56500
+ EuiFlexGroup as EuiFlexGroup37,
56501
+ EuiFlexItem as EuiFlexItem45,
56502
+ EuiFormRow as EuiFormRow25,
56503
+ EuiPanel as EuiPanel14
56504
+ } from "@elastic/eui";
56505
+
56506
+ // src/hooks/usePathAutoComplete.ts
56507
+ import { useEffect as useEffect41, useState as useState61 } from "react";
56508
+ var FALLBACK_DEFINITIONS = {
56509
+ string: {
56510
+ operators: ["eq", "neq"],
56511
+ value_schema: {
56512
+ eq: { kind: "string" },
56513
+ neq: { kind: "string" }
56514
+ }
56515
+ },
56516
+ number: {
56517
+ operators: ["eq", "neq", "lt", "lte", "gt", "gte"],
56518
+ value_schema: {
56519
+ eq: { kind: "number" },
56520
+ neq: { kind: "number" },
56521
+ lt: { kind: "number" },
56522
+ lte: { kind: "number" },
56523
+ gt: { kind: "number" },
56524
+ gte: { kind: "number" }
56525
+ }
56526
+ },
56527
+ boolean: {
56528
+ operators: ["eq", "neq"],
56529
+ value_schema: {
56530
+ eq: { kind: "boolean" },
56531
+ neq: { kind: "boolean" }
56532
+ }
56533
+ },
56534
+ datetime: {
56535
+ operators: ["eq", "neq", "lt", "lte", "gt", "gte"],
56536
+ value_schema: {
56537
+ eq: { kind: "datetime" },
56538
+ neq: { kind: "datetime" },
56539
+ lt: { kind: "datetime" },
56540
+ lte: { kind: "datetime" },
56541
+ gt: { kind: "datetime" },
56542
+ gte: { kind: "datetime" }
56543
+ }
56544
+ }
56545
+ };
56546
+ var usePathAutocomplete = (prefix, entityType) => {
56547
+ const [paths, setPaths] = useState61([]);
56548
+ const debouncedPrefix = useDebounce(prefix, 300);
56549
+ const { data: definitions = FALLBACK_DEFINITIONS, isError: defError } = useSearchDefinitionsQuery();
56550
+ const {
56551
+ data: pathData,
56552
+ isLoading,
56553
+ isError: isError2
56554
+ } = useSearchPathsQuery(
56555
+ { q: debouncedPrefix, entity_type: entityType },
56556
+ { skip: debouncedPrefix.length < 1 }
56557
+ );
56558
+ useEffect41(() => {
56559
+ if (debouncedPrefix.length < 1) {
56560
+ setPaths([]);
56561
+ return;
56562
+ }
56563
+ if (!pathData) {
56564
+ return;
56565
+ }
56566
+ const enrichedPaths = [];
56567
+ (pathData.leaves || []).forEach((leaf) => {
56568
+ const primaryType = leaf.ui_types[0] || "string";
56569
+ const typeDefinition = definitions[primaryType];
56570
+ enrichedPaths.push({
56571
+ path: leaf.name,
56572
+ type: primaryType,
56573
+ operators: typeDefinition?.operators || [],
56574
+ value_schema: typeDefinition?.value_schema || {},
56575
+ group: "leaf",
56576
+ displayLabel: leaf.name,
56577
+ ui_types: leaf.ui_types,
56578
+ availablePaths: leaf.paths || [],
56579
+ pathCount: leaf.paths ? leaf.paths.length : 0
56580
+ });
56581
+ });
56582
+ (pathData.components || []).forEach((component) => {
56583
+ const primaryType = component.ui_types[0] || "string";
56584
+ const typeDefinition = definitions[primaryType];
56585
+ enrichedPaths.push({
56586
+ path: component.name,
56587
+ type: "component",
56588
+ operators: typeDefinition?.operators || [],
56589
+ value_schema: typeDefinition?.value_schema || {},
56590
+ group: "component",
56591
+ displayLabel: component.name,
56592
+ ui_types: component.ui_types,
56593
+ availablePaths: component.paths || [],
56594
+ pathCount: component.paths ? component.paths.length : 0
56595
+ });
56596
+ });
56597
+ setPaths(enrichedPaths);
56598
+ }, [pathData, definitions]);
56599
+ const errorMessage = isError2 ? "Failed to load paths" : defError ? "Failed to load definitions" : null;
56600
+ return { paths, loading: isLoading, error: errorMessage };
56601
+ };
56602
+
56603
+ // src/components/WfoSearchPage/WfoValueControl/WfoValueControl.tsx
56604
+ import moment2 from "moment";
56605
+ import { useTranslations as useTranslations92 } from "next-intl";
56606
+ import {
56607
+ EuiComboBox as EuiComboBox2,
56608
+ EuiDatePicker as EuiDatePicker2,
56609
+ EuiFieldNumber as EuiFieldNumber3,
56610
+ EuiFieldText as EuiFieldText5,
56611
+ EuiFlexGroup as EuiFlexGroup33,
56612
+ EuiFlexItem as EuiFlexItem41,
56613
+ EuiFormHelpText,
56614
+ EuiIcon as EuiIcon7,
56615
+ EuiText as EuiText51
56616
+ } from "@elastic/eui";
56617
+ import { Fragment as Fragment63, jsx as jsx271, jsxs as jsxs143 } from "@emotion/react/jsx-runtime";
56618
+ var ValueControl = ({
56619
+ pathInfo,
56620
+ operator,
56621
+ value,
56622
+ onChange
56623
+ }) => {
56624
+ const t = useTranslations92("search.page");
56625
+ const { theme } = useOrchestratorTheme();
56626
+ if (!pathInfo || !operator) return null;
56627
+ const schema = pathInfo.value_schema[operator];
56628
+ if (!schema || schema.kind === "none") return null;
56629
+ if (pathInfo.type === "string") {
56630
+ if (operator === "like") {
56631
+ const handleLikeChange = (newValue) => {
56632
+ onChange(newValue);
56633
+ };
56634
+ const ensureWildcards = (inputValue) => {
56635
+ if (!inputValue) return inputValue;
56636
+ if (!inputValue.includes("%") && !inputValue.includes("_")) {
56637
+ return `%${inputValue}%`;
56638
+ }
56639
+ return inputValue;
56640
+ };
56641
+ const currentValue = String(value || "");
56642
+ const hasWildcards = currentValue.includes("%") || currentValue.includes("_");
56643
+ return /* @__PURE__ */ jsxs143(Fragment63, { children: [
56644
+ /* @__PURE__ */ jsx271(
56645
+ EuiFieldText5,
56646
+ {
56647
+ placeholder: "Enter pattern (% = any chars, _ = single char)",
56648
+ value: currentValue,
56649
+ onChange: (event) => handleLikeChange(event.target.value),
56650
+ onBlur: (event) => {
56651
+ const finalValue = ensureWildcards(
56652
+ event.target.value
56653
+ );
56654
+ if (finalValue !== event.target.value) {
56655
+ handleLikeChange(finalValue);
56656
+ }
56657
+ },
56658
+ prepend: /* @__PURE__ */ jsx271(EuiIcon7, { type: "search" })
56659
+ }
56660
+ ),
56661
+ /* @__PURE__ */ jsx271(EuiFormHelpText, { children: hasWildcards ? /* @__PURE__ */ jsxs143("span", { children: [
56662
+ /* @__PURE__ */ jsx271(
56663
+ EuiIcon7,
56664
+ {
56665
+ type: "checkInCircleFilled",
56666
+ color: "success",
56667
+ size: "s"
56668
+ }
56669
+ ),
56670
+ " ",
56671
+ "Pattern with wildcards:",
56672
+ " ",
56673
+ /* @__PURE__ */ jsx271("strong", { children: currentValue })
56674
+ ] }) : /* @__PURE__ */ jsxs143("span", { children: [
56675
+ "Will search for:",
56676
+ " ",
56677
+ /* @__PURE__ */ jsxs143("strong", { children: [
56678
+ "%",
56679
+ currentValue || "your-text",
56680
+ "%"
56681
+ ] }),
56682
+ " ",
56683
+ "(auto-wrapped with wildcards)"
56684
+ ] }) })
56685
+ ] });
56686
+ }
56687
+ if (pathInfo.example_values && pathInfo.example_values.length > 0) {
56688
+ const options = pathInfo.example_values.map((val) => ({
56689
+ label: val,
56690
+ value: val
56691
+ }));
56692
+ return /* @__PURE__ */ jsx271(
56693
+ EuiComboBox2,
56694
+ {
56695
+ placeholder: t("selectOrEnterValue"),
56696
+ options,
56697
+ selectedOptions: value ? [{ label: String(value), value: String(value) }] : [],
56698
+ onChange: (selected) => onChange(selected[0]?.value || ""),
56699
+ singleSelection: { asPlainText: true },
56700
+ isClearable: true
56701
+ }
56702
+ );
56703
+ }
56704
+ return /* @__PURE__ */ jsx271(
56705
+ EuiFieldText5,
56706
+ {
56707
+ placeholder: t("enterValue"),
56708
+ value: String(value || ""),
56709
+ onChange: (event) => onChange(event.target.value)
56710
+ }
56711
+ );
56712
+ }
56713
+ if (pathInfo.type === "number") {
56714
+ if (operator === "between") {
56715
+ const betweenValue = value || { start: "", end: "" };
56716
+ return /* @__PURE__ */ jsxs143(EuiFlexGroup33, { gutterSize: "s", alignItems: "center", children: [
56717
+ /* @__PURE__ */ jsx271(EuiFlexItem41, { children: /* @__PURE__ */ jsx271(
56718
+ EuiFieldNumber3,
56719
+ {
56720
+ placeholder: t("fromNumber"),
56721
+ value: betweenValue.start,
56722
+ onChange: (event) => onChange({
56723
+ ...betweenValue,
56724
+ start: parseFloat(event.target.value) || ""
56725
+ })
56726
+ }
56727
+ ) }),
56728
+ /* @__PURE__ */ jsx271(EuiFlexItem41, { grow: false, children: /* @__PURE__ */ jsx271(EuiText51, { size: "s", color: theme.colors.textSubdued, children: "to" }) }),
56729
+ /* @__PURE__ */ jsx271(EuiFlexItem41, { children: /* @__PURE__ */ jsx271(
56730
+ EuiFieldNumber3,
56731
+ {
56732
+ placeholder: t("toNumber"),
56733
+ value: betweenValue.end,
56734
+ onChange: (event) => onChange({
56735
+ ...betweenValue,
56736
+ end: parseFloat(event.target.value) || ""
56737
+ })
56738
+ }
56739
+ ) })
56740
+ ] });
56741
+ }
56742
+ return /* @__PURE__ */ jsx271(
56743
+ EuiFieldNumber3,
56744
+ {
56745
+ placeholder: t("enterNumber"),
56746
+ value: value !== void 0 && value !== null ? Number(value) : "",
56747
+ onChange: (event) => onChange(parseFloat(event.target.value) || "")
56748
+ }
56749
+ );
56750
+ }
56751
+ if (pathInfo.type === "datetime") {
56752
+ if (operator === "between") {
56753
+ const betweenValue = value || { start: null, end: null };
56754
+ return /* @__PURE__ */ jsxs143(EuiFlexGroup33, { gutterSize: "s", alignItems: "center", children: [
56755
+ /* @__PURE__ */ jsx271(EuiFlexItem41, { children: /* @__PURE__ */ jsx271(
56756
+ EuiDatePicker2,
56757
+ {
56758
+ selected: betweenValue.start ? moment2(betweenValue.start) : null,
56759
+ onChange: (date) => onChange({
56760
+ ...betweenValue,
56761
+ start: date?.toISOString()
56762
+ }),
56763
+ showTimeSelect: true,
56764
+ dateFormat: "yyyy-MM-dd HH:mm",
56765
+ placeholderText: t("fromDate")
56766
+ }
56767
+ ) }),
56768
+ /* @__PURE__ */ jsx271(EuiFlexItem41, { grow: false, children: /* @__PURE__ */ jsx271(EuiText51, { size: "s", color: theme.colors.textSubdued, children: t("valueControlTo") }) }),
56769
+ /* @__PURE__ */ jsx271(EuiFlexItem41, { children: /* @__PURE__ */ jsx271(
56770
+ EuiDatePicker2,
56771
+ {
56772
+ selected: betweenValue.end ? moment2(betweenValue.end) : null,
56773
+ onChange: (date) => onChange({
56774
+ ...betweenValue,
56775
+ end: date?.toISOString()
56776
+ }),
56777
+ showTimeSelect: true,
56778
+ dateFormat: "yyyy-MM-dd HH:mm",
56779
+ placeholderText: t("toDate")
56780
+ }
56781
+ ) })
56782
+ ] });
56783
+ }
56784
+ return /* @__PURE__ */ jsx271(
56785
+ EuiDatePicker2,
56786
+ {
56787
+ selected: value ? moment2(String(value)) : null,
56788
+ onChange: (date) => onChange(date?.toISOString()),
56789
+ showTimeSelect: true,
56790
+ dateFormat: "yyyy-MM-dd HH:mm",
56791
+ placeholderText: t("selectDateAndTime")
56792
+ }
56793
+ );
56794
+ }
56795
+ return null;
56796
+ };
56797
+
56798
+ // src/components/WfoSearchPage/WfoConditionRow/WfoFieldSelector.tsx
56799
+ import { useTranslations as useTranslations93 } from "next-intl";
56800
+ import { EuiComboBox as EuiComboBox3 } from "@elastic/eui";
56801
+ import { jsx as jsx272 } from "@emotion/react/jsx-runtime";
56802
+ var WfoFieldSelector = ({
56803
+ pathOptions,
56804
+ loading,
56805
+ error,
56806
+ onFieldSelection,
56807
+ onSearchChange,
56808
+ onClear,
56809
+ renderPathOption
56810
+ }) => {
56811
+ const t = useTranslations93("search.page");
56812
+ const handleSelectionChange = (selected) => {
56813
+ if (selected[0]?.value) {
56814
+ onFieldSelection(selected[0].value);
56815
+ } else {
56816
+ onClear();
56817
+ }
56818
+ };
56819
+ return /* @__PURE__ */ jsx272(
56820
+ EuiComboBox3,
56821
+ {
56822
+ placeholder: t("searchFieldsPlaceholder"),
56823
+ options: pathOptions,
56824
+ selectedOptions: [],
56825
+ onChange: handleSelectionChange,
56826
+ onSearchChange,
56827
+ singleSelection: { asPlainText: true },
56828
+ isLoading: loading,
56829
+ isClearable: true,
56830
+ isInvalid: !!error,
56831
+ renderOption: renderPathOption,
56832
+ rowHeight: 30
56833
+ }
56834
+ );
56835
+ };
56836
+
56837
+ // src/components/WfoSearchPage/WfoConditionRow/WfoOperatorSelector.tsx
56838
+ import { useTranslations as useTranslations94 } from "next-intl";
56839
+ import {
56840
+ EuiButton as EuiButton21,
56841
+ EuiFlexGroup as EuiFlexGroup34,
56842
+ EuiFlexItem as EuiFlexItem42,
56843
+ EuiFormRow as EuiFormRow24,
56844
+ EuiText as EuiText52
56845
+ } from "@elastic/eui";
56846
+ import { jsx as jsx273, jsxs as jsxs144 } from "@emotion/react/jsx-runtime";
56847
+ var WfoOperatorSelector = ({
56848
+ selectedPathInfo,
56849
+ condition,
56850
+ onOperatorChange
56851
+ }) => {
56852
+ const t = useTranslations94("search.page");
56853
+ const { theme } = useOrchestratorTheme();
56854
+ return /* @__PURE__ */ jsx273(EuiFormRow24, { label: t("operatorLabel"), children: /* @__PURE__ */ jsxs144(EuiFlexGroup34, { gutterSize: "xs", wrap: true, children: [
56855
+ selectedPathInfo?.operators?.map((operator) => {
56856
+ const { symbol, description } = getOperatorDisplay(
56857
+ operator,
56858
+ selectedPathInfo
56859
+ );
56860
+ const tooltipContent = operator === "like" ? /* @__PURE__ */ jsxs144("div", { children: [
56861
+ /* @__PURE__ */ jsx273("strong", { children: description }),
56862
+ /* @__PURE__ */ jsx273("br", {}),
56863
+ /* @__PURE__ */ jsx273("br", {}),
56864
+ /* @__PURE__ */ jsx273("strong", { children: "Wildcards:" }),
56865
+ /* @__PURE__ */ jsx273("br", {}),
56866
+ "\u2022 ",
56867
+ /* @__PURE__ */ jsx273("code", { children: "%" }),
56868
+ " matches any number of characters",
56869
+ /* @__PURE__ */ jsx273("br", {}),
56870
+ "\u2022 ",
56871
+ /* @__PURE__ */ jsx273("code", { children: "_" }),
56872
+ " matches exactly one character",
56873
+ /* @__PURE__ */ jsx273("br", {}),
56874
+ /* @__PURE__ */ jsx273("br", {}),
56875
+ /* @__PURE__ */ jsx273("strong", { children: "Examples:" }),
56876
+ /* @__PURE__ */ jsx273("br", {}),
56877
+ "\u2022 ",
56878
+ /* @__PURE__ */ jsx273("code", { children: "%test%" }),
56879
+ ' finds anything containing "test"',
56880
+ /* @__PURE__ */ jsx273("br", {}),
56881
+ "\u2022 ",
56882
+ /* @__PURE__ */ jsx273("code", { children: "test%" }),
56883
+ ' finds anything starting with "test"',
56884
+ /* @__PURE__ */ jsx273("br", {}),
56885
+ "\u2022 ",
56886
+ /* @__PURE__ */ jsx273("code", { children: "test_" }),
56887
+ ' finds "test" + one character'
56888
+ ] }) : description;
56889
+ return /* @__PURE__ */ jsx273(EuiFlexItem42, { grow: false, children: /* @__PURE__ */ jsx273(WfoToolTip, { tooltipContent, children: /* @__PURE__ */ jsx273(
56890
+ EuiButton21,
56891
+ {
56892
+ size: "s",
56893
+ color: getButtonColor(
56894
+ operator,
56895
+ selectedPathInfo,
56896
+ condition
56897
+ ),
56898
+ fill: getButtonFill(
56899
+ operator,
56900
+ selectedPathInfo,
56901
+ condition
56902
+ ),
56903
+ onClick: () => onOperatorChange(operator),
56904
+ style: {
56905
+ minWidth: theme.size.xxl,
56906
+ fontSize: theme.size.base,
56907
+ fontWeight: theme.font.weight.bold
56908
+ },
56909
+ children: symbol
56910
+ }
56911
+ ) }) }, operator);
56912
+ }),
56913
+ (!selectedPathInfo || selectedPathInfo.operators.length === 0) && /* @__PURE__ */ jsx273(EuiFlexItem42, { grow: false, children: /* @__PURE__ */ jsx273(EuiText52, { size: "s", color: theme.colors.textSubdued, children: t("selectFieldFirst") }) })
56914
+ ] }) });
56915
+ };
56916
+
56917
+ // src/components/WfoSearchPage/WfoConditionRow/WfoPathChips.tsx
56918
+ import { EuiIcon as EuiIcon8 } from "@elastic/eui";
56919
+ import { jsx as jsx274, jsxs as jsxs145 } from "@emotion/react/jsx-runtime";
56920
+ var WfoPathChips = ({
56921
+ fullPath,
56922
+ label,
56923
+ fieldType,
56924
+ isAnyPath = false
56925
+ }) => {
56926
+ const { theme } = useOrchestratorTheme();
56927
+ if (isAnyPath) {
56928
+ return /* @__PURE__ */ jsx274(WfoToolTip, { tooltipContent: label, children: /* @__PURE__ */ jsxs145(
56929
+ "div",
56930
+ {
56931
+ style: {
56932
+ display: "flex",
56933
+ justifyContent: "space-between",
56934
+ alignItems: "center",
56935
+ padding: `${theme.size.xs} ${theme.size.s} ${theme.size.xs} 0`,
56936
+ textDecoration: "none",
56937
+ width: "100%",
56938
+ boxSizing: "border-box",
56939
+ minHeight: theme.size.xl
56940
+ },
56941
+ children: [
56942
+ /* @__PURE__ */ jsx274(
56943
+ "div",
56944
+ {
56945
+ style: {
56946
+ display: "flex",
56947
+ gap: theme.size.xs,
56948
+ alignItems: "center",
56949
+ flexWrap: "nowrap",
56950
+ textDecoration: "none",
56951
+ marginRight: theme.size.s,
56952
+ flex: 1,
56953
+ overflow: "visible"
56954
+ },
56955
+ children: /* @__PURE__ */ jsx274(
56956
+ "div",
56957
+ {
56958
+ style: {
56959
+ textDecoration: "none",
56960
+ borderBottom: "none"
56961
+ },
56962
+ children: /* @__PURE__ */ jsx274(
56963
+ WfoBadge,
56964
+ {
56965
+ color: "primary",
56966
+ textColor: theme.colors.ghost,
56967
+ size: "xs",
56968
+ children: /* @__PURE__ */ jsx274(
56969
+ "span",
56970
+ {
56971
+ style: {
56972
+ textDecoration: "none",
56973
+ borderBottom: "none",
56974
+ outline: "none",
56975
+ textDecorationLine: "none",
56976
+ textDecorationColor: "transparent"
56977
+ },
56978
+ children: label
56979
+ }
56980
+ )
56981
+ }
56982
+ )
56983
+ }
56984
+ )
56985
+ }
56986
+ ),
56987
+ fieldType && /* @__PURE__ */ jsx274("div", { style: { flexShrink: 0 }, children: /* @__PURE__ */ jsx274(
56988
+ WfoBadge,
56989
+ {
56990
+ color: getTypeColor(fieldType, theme),
56991
+ textColor: theme.colors.ink,
56992
+ size: "xs",
56993
+ children: /* @__PURE__ */ jsx274("span", { style: { textDecoration: "none" }, children: fieldType })
56994
+ }
56995
+ ) })
56996
+ ]
56997
+ }
56998
+ ) });
56999
+ }
57000
+ const completePath = fullPath || label;
57001
+ const allSegments = completePath.split(".").filter(
57002
+ (segment) => segment && !segment.match(/^\d+$/) && !segment.includes("(")
57003
+ );
57004
+ const pathSegments = allSegments.slice(-2);
57005
+ return /* @__PURE__ */ jsx274(WfoToolTip, { tooltipContent: completePath, children: /* @__PURE__ */ jsxs145(
57006
+ "div",
57007
+ {
57008
+ style: {
57009
+ display: "flex",
57010
+ justifyContent: "space-between",
57011
+ alignItems: "center",
57012
+ padding: `${theme.size.xs} ${theme.size.s} ${theme.size.xs} 0`,
57013
+ textDecoration: "none",
57014
+ width: "100%",
57015
+ boxSizing: "border-box",
57016
+ minHeight: theme.size.xl
57017
+ },
57018
+ children: [
57019
+ /* @__PURE__ */ jsx274(
57020
+ "div",
57021
+ {
57022
+ style: {
57023
+ display: "flex",
57024
+ gap: theme.size.xs,
57025
+ alignItems: "center",
57026
+ flexWrap: "nowrap",
57027
+ textDecoration: "none",
57028
+ marginRight: theme.size.s,
57029
+ flex: 1,
57030
+ overflow: "visible"
57031
+ },
57032
+ children: pathSegments.map(
57033
+ (segment, index) => [
57034
+ /* @__PURE__ */ jsx274(
57035
+ "div",
57036
+ {
57037
+ style: {
57038
+ textDecoration: "none",
57039
+ borderBottom: "none"
57040
+ },
57041
+ children: /* @__PURE__ */ jsx274(
57042
+ WfoBadge,
57043
+ {
57044
+ color: "primary",
57045
+ textColor: theme.colors.ghost,
57046
+ size: "xs",
57047
+ children: /* @__PURE__ */ jsx274(
57048
+ "span",
57049
+ {
57050
+ style: {
57051
+ textDecoration: "none",
57052
+ borderBottom: "none",
57053
+ outline: "none",
57054
+ textDecorationLine: "none",
57055
+ textDecorationColor: "transparent"
57056
+ },
57057
+ children: segment
57058
+ }
57059
+ )
57060
+ }
57061
+ )
57062
+ },
57063
+ `segment-${index}`
57064
+ ),
57065
+ index < pathSegments.length - 1 && /* @__PURE__ */ jsx274(
57066
+ EuiIcon8,
57067
+ {
57068
+ type: "arrowRight",
57069
+ size: "s",
57070
+ color: theme.colors.mediumShade,
57071
+ title: "",
57072
+ style: {
57073
+ flexShrink: 0,
57074
+ marginTop: "1px"
57075
+ }
57076
+ },
57077
+ `arrow-${index}`
57078
+ )
57079
+ ].filter(Boolean)
57080
+ )
57081
+ }
57082
+ ),
57083
+ fieldType && /* @__PURE__ */ jsx274("div", { style: { flexShrink: 0 }, children: /* @__PURE__ */ jsx274(
57084
+ WfoBadge,
57085
+ {
57086
+ color: getTypeColor(fieldType, theme),
57087
+ textColor: theme.colors.ink,
57088
+ size: "xs",
57089
+ children: /* @__PURE__ */ jsx274("span", { style: { textDecoration: "none" }, children: fieldType })
57090
+ }
57091
+ ) })
57092
+ ]
57093
+ }
57094
+ ) });
57095
+ };
57096
+
57097
+ // src/components/WfoSearchPage/WfoConditionRow/WfoPathSelector.tsx
57098
+ import { useTranslations as useTranslations95 } from "next-intl";
57099
+ import { EuiComboBox as EuiComboBox4 } from "@elastic/eui";
57100
+ import { jsx as jsx275 } from "@emotion/react/jsx-runtime";
57101
+ var WfoPathSelector = ({
57102
+ selectedFieldName,
57103
+ pathOptions,
57104
+ onPathSelection,
57105
+ onClear,
57106
+ renderOption
57107
+ }) => {
57108
+ const t = useTranslations95("search.page");
57109
+ return /* @__PURE__ */ jsx275(
57110
+ EuiComboBox4,
57111
+ {
57112
+ placeholder: t("selectSpecificPathPlaceholder"),
57113
+ options: pathOptions,
57114
+ selectedOptions: [
57115
+ {
57116
+ label: `${selectedFieldName}:`,
57117
+ value: selectedFieldName
57118
+ }
57119
+ ],
57120
+ onChange: (selected) => {
57121
+ if (selected[0]?.value) {
57122
+ const selectedOption = pathOptions.find(
57123
+ (option) => option.value === selected[0].value
57124
+ );
57125
+ if (selectedOption) {
57126
+ onPathSelection(selectedOption);
57127
+ }
57128
+ } else if (selected.length === 0) {
57129
+ onClear();
57130
+ }
57131
+ },
57132
+ singleSelection: { asPlainText: true },
57133
+ isClearable: true,
57134
+ renderOption,
57135
+ rowHeight: 40,
57136
+ autoFocus: true,
57137
+ fullWidth: true,
57138
+ style: {
57139
+ minWidth: "500px",
57140
+ maxWidth: "100%",
57141
+ textDecoration: "none"
57142
+ },
57143
+ className: "wfo-path-selector"
57144
+ }
57145
+ );
57146
+ };
57147
+
57148
+ // src/components/WfoSearchPage/WfoConditionRow/WfoRenderFunctions.tsx
57149
+ import { useTranslations as useTranslations96 } from "next-intl";
57150
+ import { EuiFlexGroup as EuiFlexGroup35, EuiFlexItem as EuiFlexItem43, EuiText as EuiText53 } from "@elastic/eui";
57151
+ import { Fragment as Fragment64, jsx as jsx276, jsxs as jsxs146 } from "@emotion/react/jsx-runtime";
57152
+ var WfoRenderPathOption = ({
57153
+ option,
57154
+ contentClassName,
57155
+ paths
57156
+ }) => {
57157
+ const t = useTranslations96("search.page");
57158
+ const { theme } = useOrchestratorTheme();
57159
+ const pathInfo = option.value ? paths.find(({ path }) => path === option.value) : null;
57160
+ if (!pathInfo) return /* @__PURE__ */ jsx276(Fragment64, { children: option.label });
57161
+ return /* @__PURE__ */ jsxs146(
57162
+ EuiFlexGroup35,
57163
+ {
57164
+ alignItems: "center",
57165
+ gutterSize: "s",
57166
+ responsive: false,
57167
+ className: contentClassName,
57168
+ title: "",
57169
+ children: [
57170
+ /* @__PURE__ */ jsx276(EuiFlexItem43, { grow: true, children: /* @__PURE__ */ jsx276(EuiText53, { size: "s", children: pathInfo.displayLabel || pathInfo.path }) }),
57171
+ /* @__PURE__ */ jsx276(EuiFlexItem43, { grow: false, children: /* @__PURE__ */ jsxs146(
57172
+ EuiFlexGroup35,
57173
+ {
57174
+ gutterSize: "xs",
57175
+ alignItems: "center",
57176
+ responsive: false,
57177
+ children: [
57178
+ pathInfo.group === "leaf" && pathInfo.pathCount && pathInfo.pathCount > 1 && /* @__PURE__ */ jsx276(EuiFlexItem43, { grow: false, children: /* @__PURE__ */ jsx276(
57179
+ WfoBadge,
57180
+ {
57181
+ color: "default",
57182
+ textColor: theme.colors.ink,
57183
+ size: "xs",
57184
+ children: t("pathsCount", {
57185
+ count: pathInfo.pathCount
57186
+ })
57187
+ }
57188
+ ) }),
57189
+ (!pathInfo.pathCount || pathInfo.pathCount <= 1) && pathInfo.ui_types?.map((type, index) => /* @__PURE__ */ jsx276(EuiFlexItem43, { grow: false, children: /* @__PURE__ */ jsx276(
57190
+ WfoBadge,
57191
+ {
57192
+ color: getTypeColor(type, theme),
57193
+ textColor: theme.colors.ink,
57194
+ size: "xs",
57195
+ children: type
57196
+ }
57197
+ ) }, index))
57198
+ ]
57199
+ }
57200
+ ) })
57201
+ ]
57202
+ }
57203
+ );
57204
+ };
57205
+ var WfoRenderPathSelectionOption = ({ option, contentClassName, fieldType }) => {
57206
+ const { theme } = useOrchestratorTheme();
57207
+ return /* @__PURE__ */ jsx276(WfoToolTip, { tooltipContent: option.fullPath || option.label, children: /* @__PURE__ */ jsxs146(
57208
+ EuiFlexGroup35,
57209
+ {
57210
+ alignItems: "center",
57211
+ gutterSize: "s",
57212
+ responsive: false,
57213
+ className: contentClassName,
57214
+ title: "",
57215
+ children: [
57216
+ /* @__PURE__ */ jsx276(EuiFlexItem43, { grow: true, children: /* @__PURE__ */ jsx276(EuiText53, { size: "s", children: option.label }) }),
57217
+ /* @__PURE__ */ jsx276(EuiFlexItem43, { grow: false, children: /* @__PURE__ */ jsx276(
57218
+ WfoBadge,
57219
+ {
57220
+ color: getTypeColor(fieldType, theme),
57221
+ textColor: theme.colors.ink,
57222
+ size: "xs",
57223
+ children: fieldType
57224
+ }
57225
+ ) })
57226
+ ]
57227
+ }
57228
+ ) });
57229
+ };
57230
+
57231
+ // src/components/WfoSearchPage/WfoConditionRow/WfoSelectedPathDisplay.tsx
57232
+ import { EuiFlexGroup as EuiFlexGroup36, EuiFlexItem as EuiFlexItem44, EuiText as EuiText54 } from "@elastic/eui";
57233
+
57234
+ // src/components/WfoSearchPage/WfoConditionRow/utils.ts
57235
+ var createOptionsFromPaths = (paths, group) => paths.filter(({ group: pathGroup }) => pathGroup === group).map(({ displayLabel, path, type, operators }) => ({
57236
+ label: displayLabel || path,
57237
+ value: path,
57238
+ "data-type": type,
57239
+ "data-operators": operators?.join(", ") || ""
57240
+ }));
57241
+ var shouldHideValueInput = (selectedPathInfo, operatorSelected) => {
57242
+ if (!selectedPathInfo || !operatorSelected) return true;
57243
+ if (selectedPathInfo.group === "component") return true;
57244
+ if (selectedPathInfo.type === "boolean") return true;
57245
+ return false;
57246
+ };
57247
+ var isFullPathSelected = (path, selectedPathInfo) => {
57248
+ return !!(path && (path.includes(".") || selectedPathInfo && selectedPathInfo.group === "component" || !path.includes(".") && selectedPathInfo));
57249
+ };
57250
+ var getFieldNameFromPath = (path, isComponent) => {
57251
+ return isComponent ? path : path.split(".").pop() || path;
57252
+ };
57253
+ var getFieldNameFromFullPath = (fullPath) => {
57254
+ const parts = fullPath.split(".");
57255
+ return parts[parts.length - 1] || fullPath;
57256
+ };
57257
+ var getPathSelectionOptions = (selectedFieldName, paths) => {
57258
+ if (!selectedFieldName) return [];
57259
+ const fieldInfo = paths.find(({ path }) => path === selectedFieldName);
57260
+ if (!fieldInfo || !fieldInfo.availablePaths) return [];
57261
+ return fieldInfo.availablePaths.map((fullPath) => ({
57262
+ label: fullPath,
57263
+ value: fullPath,
57264
+ fullPath
57265
+ }));
57266
+ };
57267
+
57268
+ // src/components/WfoSearchPage/WfoConditionRow/WfoSelectedPathDisplay.tsx
57269
+ import { jsx as jsx277, jsxs as jsxs147 } from "@emotion/react/jsx-runtime";
57270
+ var WfoSelectedPathDisplay = ({
57271
+ condition,
57272
+ onEdit
57273
+ }) => {
57274
+ const { theme } = useOrchestratorTheme();
57275
+ const isFullPath = condition.path.includes(".");
57276
+ return /* @__PURE__ */ jsx277(
57277
+ "div",
57278
+ {
57279
+ onClick: onEdit,
57280
+ style: {
57281
+ cursor: "pointer",
57282
+ border: `1px solid ${theme.colors.lightShade}`,
57283
+ borderRadius: theme.border.radius.medium,
57284
+ padding: `${theme.size.s} ${theme.size.m}`,
57285
+ backgroundColor: theme.colors.emptyShade,
57286
+ minHeight: "40px",
57287
+ display: "flex",
57288
+ alignItems: "center"
57289
+ },
57290
+ children: /* @__PURE__ */ jsx277(
57291
+ EuiFlexGroup36,
57292
+ {
57293
+ alignItems: "center",
57294
+ gutterSize: "s",
57295
+ responsive: false,
57296
+ justifyContent: "spaceBetween",
57297
+ children: /* @__PURE__ */ jsx277(EuiFlexItem44, { grow: true, children: isFullPath ? /* @__PURE__ */ jsxs147(
57298
+ EuiFlexGroup36,
57299
+ {
57300
+ gutterSize: "none",
57301
+ alignItems: "center",
57302
+ responsive: false,
57303
+ children: [
57304
+ /* @__PURE__ */ jsx277(EuiFlexItem44, { grow: false, children: /* @__PURE__ */ jsxs147(EuiText54, { size: "s", color: theme.colors.text, children: [
57305
+ getFieldNameFromFullPath(condition.path),
57306
+ ":"
57307
+ ] }) }),
57308
+ /* @__PURE__ */ jsx277(EuiFlexItem44, { grow: false, children: /* @__PURE__ */ jsx277(
57309
+ EuiText54,
57310
+ {
57311
+ size: "s",
57312
+ style: {
57313
+ backgroundColor: theme.colors.lightestShade,
57314
+ color: theme.colors.primary,
57315
+ padding: `${theme.size.xxs} ${theme.size.xs}`,
57316
+ borderRadius: theme.border.radius.small,
57317
+ marginLeft: theme.size.xs
57318
+ },
57319
+ children: condition.path
57320
+ }
57321
+ ) })
57322
+ ]
57323
+ }
57324
+ ) : /* @__PURE__ */ jsx277(EuiText54, { size: "s", color: theme.colors.text, children: condition.path }) })
57325
+ }
57326
+ )
57327
+ }
57328
+ );
57329
+ };
57330
+
57331
+ // src/components/WfoSearchPage/WfoConditionRow/WfoConditionRow.tsx
57332
+ import { jsx as jsx278, jsxs as jsxs148 } from "@emotion/react/jsx-runtime";
57333
+ var ConditionRow = ({
57334
+ condition,
57335
+ entityType,
57336
+ onChange,
57337
+ onRemove
57338
+ }) => {
57339
+ const t = useTranslations97("search.page");
57340
+ const { theme } = useOrchestratorTheme();
57341
+ const [searchValue, setSearchValue] = useState62(condition.path);
57342
+ const [showPathSelection, setShowPathSelection] = useState62(false);
57343
+ const [selectedFieldName, setSelectedFieldName] = useState62("");
57344
+ const { paths, loading, error } = usePathAutocomplete(
57345
+ searchValue,
57346
+ entityType
57347
+ );
57348
+ const selectedPathInfo = (() => {
57349
+ if (!condition.path) return null;
57350
+ const exactMatch = paths.find(
57351
+ ({ path, fullPath }) => fullPath ? fullPath === condition.path : path === condition.path
57352
+ );
57353
+ if (exactMatch) return exactMatch;
57354
+ if (condition.path.includes(".")) {
57355
+ const fieldName = condition.path.split(".").pop();
57356
+ if (fieldName) {
57357
+ const fieldMatch = paths.find(
57358
+ ({ path, availablePaths }) => path === fieldName && availablePaths && availablePaths.includes(condition.path)
57359
+ );
57360
+ if (fieldMatch) return fieldMatch;
57361
+ }
57362
+ } else {
57363
+ const fieldMatch = paths.find(
57364
+ ({ path }) => path === condition.path
57365
+ );
57366
+ if (fieldMatch) return fieldMatch;
57367
+ }
57368
+ return null;
57369
+ })();
57370
+ const handleFieldSelection = (fieldName) => {
57371
+ const fieldInfo = paths.find(({ path }) => path === fieldName);
57372
+ if (fieldInfo && fieldInfo.group === "component") {
57373
+ onChange({
57374
+ path: fieldName,
57375
+ value_kind: fieldInfo.type,
57376
+ condition: { op: "", value: void 0 }
57377
+ });
57378
+ return;
57379
+ }
57380
+ if (fieldInfo && fieldInfo.availablePaths && fieldInfo.availablePaths.length === 1) {
57381
+ const singlePath = fieldInfo.availablePaths[0];
57382
+ onChange({
57383
+ path: singlePath,
57384
+ value_kind: fieldInfo.type,
57385
+ condition: { op: "", value: void 0 }
57386
+ });
57387
+ return;
57388
+ }
57389
+ setSelectedFieldName(fieldName);
57390
+ setShowPathSelection(true);
57391
+ };
57392
+ const handlePathSelection = (selectedOption) => {
57393
+ const fieldInfo = paths.find(({ path }) => path === selectedFieldName);
57394
+ if (fieldInfo) {
57395
+ if (selectedOption.isAnyPath) {
57396
+ onChange({
57397
+ path: selectedFieldName,
57398
+ value_kind: fieldInfo.type,
57399
+ condition: { op: "", value: void 0 }
57400
+ });
57401
+ } else {
57402
+ onChange({
57403
+ path: selectedOption.value,
57404
+ value_kind: fieldInfo.type,
57405
+ condition: { op: "", value: void 0 }
57406
+ });
57407
+ }
57408
+ }
57409
+ setShowPathSelection(false);
57410
+ setSelectedFieldName("");
57411
+ };
57412
+ const handleOperatorChange = (op) => {
57413
+ const value = void 0;
57414
+ if (selectedPathInfo?.type === "boolean") {
57415
+ const actualOp = "eq";
57416
+ const booleanValue = op === "eq" ? true : false;
57417
+ onChange({
57418
+ ...condition,
57419
+ value_kind: selectedPathInfo?.type,
57420
+ condition: { op: actualOp, value: booleanValue }
57421
+ });
57422
+ return;
57423
+ }
57424
+ onChange({
57425
+ ...condition,
57426
+ value_kind: selectedPathInfo?.type,
57427
+ condition: { op, value }
57428
+ });
57429
+ };
57430
+ const handleValueChange = (value) => {
57431
+ onChange({
57432
+ ...condition,
57433
+ value_kind: selectedPathInfo?.type,
57434
+ condition: { ...condition.condition, value }
57435
+ });
57436
+ };
57437
+ const leavesOptions = createOptionsFromPaths(paths, "leaf");
57438
+ const componentsOptions = createOptionsFromPaths(paths, "component");
57439
+ const pathOptions = [
57440
+ ...leavesOptions.length > 0 ? [
57441
+ {
57442
+ label: t("fieldsGroupLabel"),
57443
+ options: leavesOptions
57444
+ }
57445
+ ] : [],
57446
+ ...componentsOptions.length > 0 ? [
57447
+ {
57448
+ label: t("componentsGroupLabel"),
57449
+ options: componentsOptions
57450
+ }
57451
+ ] : []
57452
+ ];
57453
+ const hideValueInput = shouldHideValueInput(
57454
+ selectedPathInfo,
57455
+ !!condition.condition.op
57456
+ );
57457
+ const fullPathSelected = isFullPathSelected(
57458
+ condition.path,
57459
+ selectedPathInfo
57460
+ );
57461
+ const pathSelectionOptions = (() => {
57462
+ const baseOptions = getPathSelectionOptions(selectedFieldName, paths);
57463
+ const fieldInfo = paths.find(({ path }) => path === selectedFieldName);
57464
+ if (fieldInfo?.availablePaths && fieldInfo.availablePaths.length > 1) {
57465
+ return [
57466
+ {
57467
+ label: t("anyPathOption"),
57468
+ value: selectedFieldName,
57469
+ fullPath: selectedFieldName,
57470
+ isAnyPath: true
57471
+ },
57472
+ ...baseOptions
57473
+ ];
57474
+ }
57475
+ return baseOptions;
57476
+ })();
57477
+ const renderPathOption = (option, searchValue2, contentClassName) => /* @__PURE__ */ jsx278(
57478
+ WfoRenderPathOption,
57479
+ {
57480
+ option,
57481
+ searchValue: searchValue2,
57482
+ contentClassName,
57483
+ paths
57484
+ }
57485
+ );
57486
+ const renderPathSelectionOption = (option) => {
57487
+ const fieldInfo = paths.find(({ path }) => path === selectedFieldName);
57488
+ const fieldType = fieldInfo?.type || "string";
57489
+ return /* @__PURE__ */ jsx278(
57490
+ WfoPathChips,
57491
+ {
57492
+ fullPath: option.fullPath || "",
57493
+ label: option.label,
57494
+ fieldType,
57495
+ isAnyPath: option.isAnyPath
57496
+ }
57497
+ );
57498
+ };
57499
+ return /* @__PURE__ */ jsx278(EuiPanel14, { paddingSize: "m", color: "subdued", children: /* @__PURE__ */ jsxs148(EuiFlexGroup37, { direction: "column", gutterSize: "m", children: [
57500
+ /* @__PURE__ */ jsx278(EuiFlexItem45, { children: /* @__PURE__ */ jsx278(
57501
+ EuiFormRow25,
57502
+ {
57503
+ label: t("fieldLabel"),
57504
+ error,
57505
+ isInvalid: !!error,
57506
+ children: /* @__PURE__ */ jsxs148(EuiFlexGroup37, { gutterSize: "s", alignItems: "center", children: [
57507
+ /* @__PURE__ */ jsx278(EuiFlexItem45, { children: showPathSelection ? /* @__PURE__ */ jsx278(
57508
+ WfoPathSelector,
57509
+ {
57510
+ selectedFieldName,
57511
+ pathOptions: pathSelectionOptions,
57512
+ onPathSelection: handlePathSelection,
57513
+ onClear: () => {
57514
+ setShowPathSelection(false);
57515
+ setSelectedFieldName("");
57516
+ },
57517
+ renderOption: renderPathSelectionOption
57518
+ }
57519
+ ) : condition.path && fullPathSelected ? /* @__PURE__ */ jsx278(
57520
+ WfoSelectedPathDisplay,
57521
+ {
57522
+ condition,
57523
+ selectedPathInfo,
57524
+ onEdit: () => {
57525
+ onChange({
57526
+ path: "",
57527
+ value_kind: void 0,
57528
+ condition: {
57529
+ op: "",
57530
+ value: void 0
57531
+ }
57532
+ });
57533
+ }
57534
+ }
57535
+ ) : /* @__PURE__ */ jsx278(
57536
+ WfoFieldSelector,
57537
+ {
57538
+ pathOptions,
57539
+ loading,
57540
+ error,
57541
+ searchValue,
57542
+ onFieldSelection: handleFieldSelection,
57543
+ onSearchChange: setSearchValue,
57544
+ onClear: () => {
57545
+ onChange({
57546
+ path: "",
57547
+ value_kind: void 0,
57548
+ condition: {
57549
+ op: "",
57550
+ value: void 0
57551
+ }
57552
+ });
57553
+ },
57554
+ renderPathOption
57555
+ }
57556
+ ) }),
57557
+ condition.path && selectedPathInfo?.ui_types && selectedPathInfo.ui_types.length > 0 && /* @__PURE__ */ jsx278(EuiFlexItem45, { grow: false, children: /* @__PURE__ */ jsx278(
57558
+ EuiFlexGroup37,
57559
+ {
57560
+ gutterSize: "xs",
57561
+ alignItems: "center",
57562
+ responsive: false,
57563
+ children: selectedPathInfo.ui_types.map(
57564
+ (type, index) => /* @__PURE__ */ jsx278(
57565
+ EuiFlexItem45,
57566
+ {
57567
+ grow: false,
57568
+ children: /* @__PURE__ */ jsx278(
57569
+ WfoBadge,
57570
+ {
57571
+ color: getTypeColor(
57572
+ type,
57573
+ theme
57574
+ ),
57575
+ textColor: theme.colors.ink,
57576
+ size: "s",
57577
+ children: type
57578
+ }
57579
+ )
57580
+ },
57581
+ index
57582
+ )
57583
+ )
57584
+ }
57585
+ ) })
57586
+ ] })
57587
+ }
57588
+ ) }),
57589
+ /* @__PURE__ */ jsx278(EuiFlexItem45, { children: /* @__PURE__ */ jsxs148(EuiFlexGroup37, { gutterSize: "s", alignItems: "flexEnd", children: [
57590
+ /* @__PURE__ */ jsx278(EuiFlexItem45, { children: /* @__PURE__ */ jsx278(
57591
+ WfoOperatorSelector,
57592
+ {
57593
+ selectedPathInfo,
57594
+ condition,
57595
+ onOperatorChange: handleOperatorChange
57596
+ }
57597
+ ) }),
57598
+ !hideValueInput && /* @__PURE__ */ jsx278(EuiFlexItem45, { children: /* @__PURE__ */ jsx278(EuiFormRow25, { label: t("valueLabel"), children: /* @__PURE__ */ jsx278(
57599
+ ValueControl,
57600
+ {
57601
+ pathInfo: selectedPathInfo,
57602
+ operator: condition.condition.op,
57603
+ value: condition.condition.value,
57604
+ onChange: handleValueChange
57605
+ }
57606
+ ) }) }),
57607
+ /* @__PURE__ */ jsx278(EuiFlexItem45, { grow: false, children: /* @__PURE__ */ jsx278(
57608
+ EuiButtonIcon15,
57609
+ {
57610
+ iconType: "trash",
57611
+ color: "danger",
57612
+ onClick: onRemove,
57613
+ "aria-label": t("removeConditionAriaLabel"),
57614
+ size: "m"
57615
+ }
57616
+ ) })
57617
+ ] }) })
57618
+ ] }) });
57619
+ };
57620
+
57621
+ // src/components/WfoSearchPage/WfoFilterGroup/WfoFilterGroup.tsx
57622
+ import { Fragment as Fragment65, jsx as jsx279, jsxs as jsxs149 } from "@emotion/react/jsx-runtime";
57623
+ var FilterGroup = ({
57624
+ group,
57625
+ entityType,
57626
+ onChange,
57627
+ onRemove,
57628
+ depth = 0,
57629
+ isRoot = false
57630
+ }) => {
57631
+ const t = useTranslations98("search.page");
57632
+ const { theme } = useOrchestratorTheme();
57633
+ const MAX_DEPTH = 5;
57634
+ const canAddGroup = depth < MAX_DEPTH;
57635
+ const addCondition = () => {
57636
+ const newCondition = {
57637
+ path: "",
57638
+ condition: { op: "", value: void 0 }
57639
+ };
57640
+ onChange({
57641
+ ...group,
57642
+ children: [...group.children, newCondition]
57643
+ });
57644
+ };
57645
+ const addGroup = () => {
57646
+ if (!canAddGroup) return;
57647
+ const newGroup = {
57648
+ op: "AND",
57649
+ children: []
57650
+ };
57651
+ onChange({
57652
+ ...group,
57653
+ children: [...group.children, newGroup]
57654
+ });
57655
+ };
57656
+ const updateChild = (index, child) => {
57657
+ const newChildren = [...group.children];
57658
+ newChildren[index] = child;
57659
+ onChange({
57660
+ ...group,
57661
+ children: newChildren
57662
+ });
57663
+ };
57664
+ const removeChild = (index) => {
57665
+ onChange({
57666
+ ...group,
57667
+ children: group.children.filter((_5, i) => i !== index)
57668
+ });
57669
+ };
57670
+ const toggleOperator = () => {
57671
+ onChange({
57672
+ ...group,
57673
+ op: group.op === "AND" ? "OR" : "AND"
57674
+ });
57675
+ };
57676
+ return /* @__PURE__ */ jsxs149(
57677
+ EuiPanel15,
57678
+ {
57679
+ paddingSize: "m",
57680
+ color: depth % 2 === 0 ? "primary" : "plain",
57681
+ hasBorder: true,
57682
+ children: [
57683
+ /* @__PURE__ */ jsxs149(
57684
+ EuiFlexGroup38,
57685
+ {
57686
+ gutterSize: "s",
57687
+ alignItems: "center",
57688
+ justifyContent: "spaceBetween",
57689
+ children: [
57690
+ /* @__PURE__ */ jsx279(EuiFlexItem46, { grow: false, children: /* @__PURE__ */ jsxs149(EuiFlexGroup38, { gutterSize: "s", alignItems: "center", children: [
57691
+ /* @__PURE__ */ jsx279(EuiFlexItem46, { grow: false, children: /* @__PURE__ */ jsx279(EuiText55, { size: "s", children: /* @__PURE__ */ jsx279("strong", { children: t("groupLabel") }) }) }),
57692
+ /* @__PURE__ */ jsx279(EuiFlexItem46, { grow: false, children: /* @__PURE__ */ jsx279(
57693
+ EuiButton22,
57694
+ {
57695
+ size: "s",
57696
+ fill: true,
57697
+ color: "primary",
57698
+ onClick: toggleOperator,
57699
+ children: group.op
57700
+ }
57701
+ ) })
57702
+ ] }) }),
57703
+ /* @__PURE__ */ jsx279(EuiFlexItem46, { grow: false, children: /* @__PURE__ */ jsxs149(EuiFlexGroup38, { gutterSize: "s", alignItems: "center", children: [
57704
+ /* @__PURE__ */ jsx279(EuiFlexItem46, { grow: false, children: /* @__PURE__ */ jsx279(
57705
+ EuiButton22,
57706
+ {
57707
+ size: "s",
57708
+ iconType: "plusInCircle",
57709
+ onClick: addCondition,
57710
+ children: t("addCondition")
57711
+ }
57712
+ ) }),
57713
+ /* @__PURE__ */ jsx279(EuiFlexItem46, { grow: false, children: /* @__PURE__ */ jsx279(
57714
+ WfoToolTip,
57715
+ {
57716
+ tooltipContent: !canAddGroup ? t("maxNestingDepth") : t("addNestedGroup"),
57717
+ children: /* @__PURE__ */ jsx279(
57718
+ EuiButton22,
57719
+ {
57720
+ size: "s",
57721
+ iconType: "nested",
57722
+ onClick: addGroup,
57723
+ disabled: !canAddGroup,
57724
+ children: t("addGroup")
57725
+ }
57726
+ )
57727
+ }
57728
+ ) }),
57729
+ !isRoot && onRemove && /* @__PURE__ */ jsx279(EuiFlexItem46, { grow: false, children: /* @__PURE__ */ jsx279(
57730
+ EuiButtonIcon16,
57731
+ {
57732
+ iconType: "trash",
57733
+ color: "danger",
57734
+ onClick: onRemove,
57735
+ "aria-label": t("removeGroup")
57736
+ }
57737
+ ) })
57738
+ ] }) })
57739
+ ]
57740
+ }
57741
+ ),
57742
+ group.children.length > 0 && /* @__PURE__ */ jsxs149(Fragment65, { children: [
57743
+ /* @__PURE__ */ jsx279(EuiSpacer30, { size: "m" }),
57744
+ /* @__PURE__ */ jsx279(
57745
+ EuiPanel15,
57746
+ {
57747
+ paddingSize: isRoot ? "none" : "s",
57748
+ color: "transparent",
57749
+ hasShadow: false,
57750
+ children: group.children.map((child, index) => /* @__PURE__ */ jsxs149("div", { children: [
57751
+ index > 0 && /* @__PURE__ */ jsx279(
57752
+ EuiFlexGroup38,
57753
+ {
57754
+ gutterSize: "none",
57755
+ alignItems: "center",
57756
+ justifyContent: "center",
57757
+ children: /* @__PURE__ */ jsx279(EuiFlexItem46, { grow: false, children: /* @__PURE__ */ jsx279(
57758
+ EuiText55,
57759
+ {
57760
+ size: "s",
57761
+ color: theme.colors.textSubdued,
57762
+ textAlign: "center",
57763
+ children: /* @__PURE__ */ jsx279(EuiCode, { children: group.op })
57764
+ }
57765
+ ) })
57766
+ }
57767
+ ),
57768
+ /* @__PURE__ */ jsx279(EuiSpacer30, { size: "s" }),
57769
+ isCondition(child) ? /* @__PURE__ */ jsx279(
57770
+ ConditionRow,
57771
+ {
57772
+ condition: child,
57773
+ entityType,
57774
+ onChange: (newCondition) => updateChild(index, newCondition),
57775
+ onRemove: () => removeChild(index)
57776
+ }
57777
+ ) : /* @__PURE__ */ jsx279(
57778
+ FilterGroup,
57779
+ {
57780
+ group: child,
57781
+ entityType,
57782
+ onChange: (newGroup) => updateChild(index, newGroup),
57783
+ onRemove: () => removeChild(index),
57784
+ depth: depth + 1
57785
+ }
57786
+ ),
57787
+ /* @__PURE__ */ jsx279(EuiSpacer30, { size: "s" })
57788
+ ] }, index))
57789
+ }
57790
+ )
57791
+ ] }),
57792
+ group.children.length === 0 && /* @__PURE__ */ jsxs149(Fragment65, { children: [
57793
+ /* @__PURE__ */ jsx279(EuiSpacer30, { size: "s" }),
57794
+ /* @__PURE__ */ jsx279(
57795
+ EuiCallOut2,
57796
+ {
57797
+ title: t("emptyGroupTitle"),
57798
+ color: "primary",
57799
+ iconType: "iInCircle",
57800
+ size: "s",
57801
+ children: /* @__PURE__ */ jsx279("p", { children: t("emptyGroupDescription") })
57802
+ }
57803
+ )
57804
+ ] })
57805
+ ]
57806
+ }
57807
+ );
57808
+ };
57809
+
57810
+ // src/components/WfoSearchPage/WfoSearchResults/WfoSearchResults.tsx
57811
+ import { useState as useState63 } from "react";
57812
+ import { EuiFlexGroup as EuiFlexGroup43, EuiPanel as EuiPanel19 } from "@elastic/eui";
57813
+
57814
+ // src/components/WfoSearchPage/WfoSearchResults/WfoSearchEmptyState.tsx
57815
+ import { useTranslations as useTranslations99 } from "next-intl";
57816
+ import { EuiFlexGroup as EuiFlexGroup39, EuiFlexItem as EuiFlexItem47, EuiPanel as EuiPanel16, EuiText as EuiText56 } from "@elastic/eui";
57817
+ import { jsx as jsx280 } from "@emotion/react/jsx-runtime";
57818
+ var WfoSearchEmptyState = () => {
57819
+ const t = useTranslations99("search.page");
57820
+ const { theme } = useOrchestratorTheme();
57821
+ return /* @__PURE__ */ jsx280(EuiPanel16, { paddingSize: "l", color: "transparent", hasShadow: false, children: /* @__PURE__ */ jsx280(EuiFlexGroup39, { justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ jsx280(EuiFlexItem47, { grow: false, children: /* @__PURE__ */ jsx280(EuiText56, { size: "m", color: theme.colors.textSubdued, children: t("noResultsFound") }) }) }) });
57822
+ };
57823
+
57824
+ // src/components/WfoSearchPage/WfoSearchResults/WfoSearchLoadingState.tsx
57825
+ import { useTranslations as useTranslations100 } from "next-intl";
57826
+ import { EuiFlexGroup as EuiFlexGroup40, EuiFlexItem as EuiFlexItem48, EuiPanel as EuiPanel17, EuiText as EuiText57 } from "@elastic/eui";
57827
+ import { jsx as jsx281 } from "@emotion/react/jsx-runtime";
57828
+ var WfoSearchLoadingState = () => {
57829
+ const t = useTranslations100("search.page");
57830
+ const { theme } = useOrchestratorTheme();
57831
+ return /* @__PURE__ */ jsx281(EuiPanel17, { paddingSize: "l", color: "transparent", hasShadow: false, children: /* @__PURE__ */ jsx281(EuiFlexGroup40, { justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ jsx281(EuiFlexItem48, { grow: false, children: /* @__PURE__ */ jsx281(EuiText57, { size: "m", color: theme.colors.textSubdued, children: t("loadingSearchResults") }) }) }) });
57832
+ };
57833
+
57834
+ // src/components/WfoSearchPage/WfoSearchResults/WfoSearchResultItem.tsx
57835
+ import { useEffect as useEffect42, useRef as useRef13 } from "react";
57836
+ import { useTranslations as useTranslations101 } from "next-intl";
57837
+ import {
57838
+ EuiButtonIcon as EuiButtonIcon17,
57839
+ EuiFlexGroup as EuiFlexGroup42,
57840
+ EuiFlexItem as EuiFlexItem50,
57841
+ EuiPanel as EuiPanel18,
57842
+ EuiSpacer as EuiSpacer31,
57843
+ EuiText as EuiText58
57844
+ } from "@elastic/eui";
57845
+
57846
+ // src/components/WfoSearchPage/WfoSearchResults/WfoHighlightedText.tsx
57847
+ import { useMemo as useMemo9 } from "react";
57848
+ import { css as css52 } from "@emotion/react";
57849
+ import { Fragment as Fragment66, jsx as jsx282 } from "@emotion/react/jsx-runtime";
57850
+ var WfoHighlightedText = ({
57851
+ text,
57852
+ highlight_indices
57853
+ }) => {
57854
+ const { theme } = useOrchestratorTheme();
57855
+ const highlightStyles = css52`
57856
+ background-color: ${theme.colors.warning};
57857
+ color: ${theme.colors.plainDark};
57858
+ padding: 0 ${theme.size.xs};
57859
+ font-family: ${theme.font.family};
57860
+ font-weight: ${theme.font.weight.bold};
57861
+ border-radius: ${theme.size.xs};
57862
+ `;
57863
+ const highlightedParts = useMemo9(() => {
57864
+ if (!highlight_indices || highlight_indices.length === 0) {
57865
+ return text;
57866
+ }
57867
+ const sorted = [...highlight_indices].sort((a, b) => a[0] - b[0]);
57868
+ const parts = [];
57869
+ let lastIndex = 0;
57870
+ sorted.forEach(([start, end], idx) => {
57871
+ if (start > lastIndex) {
57872
+ parts.push(
57873
+ /* @__PURE__ */ jsx282("span", { children: text.slice(lastIndex, start) }, `plain-${idx}`)
57874
+ );
57875
+ }
57876
+ parts.push(
57877
+ /* @__PURE__ */ jsx282("span", { css: highlightStyles, children: text.slice(start, end) }, `hl-${idx}`)
57878
+ );
57879
+ lastIndex = end;
57880
+ });
57881
+ if (lastIndex < text.length) {
57882
+ parts.push(/* @__PURE__ */ jsx282("span", { children: text.slice(lastIndex) }, "plain-last"));
57883
+ }
57884
+ return parts;
57885
+ }, [text, highlight_indices, highlightStyles]);
57886
+ return /* @__PURE__ */ jsx282(Fragment66, { children: highlightedParts });
57887
+ };
57888
+
57889
+ // src/components/WfoSearchPage/WfoSearchResults/WfoPathBreadcrumb.tsx
57890
+ import { Fragment as Fragment67 } from "react";
57891
+ import { EuiFlexGroup as EuiFlexGroup41, EuiFlexItem as EuiFlexItem49, EuiIcon as EuiIcon9 } from "@elastic/eui";
57892
+ import { jsx as jsx283, jsxs as jsxs150 } from "@emotion/react/jsx-runtime";
57893
+ var WfoPathBreadcrumb = ({
57894
+ path,
57895
+ size = "m",
57896
+ maxSegments,
57897
+ showArrows = true,
57898
+ color,
57899
+ stripFirstSegment = false
57900
+ }) => {
57901
+ const { theme } = useOrchestratorTheme();
57902
+ if (!path) {
57903
+ return null;
57904
+ }
57905
+ let segments = path.split(".").filter((segment) => !/^\d+$/.test(segment));
57906
+ if (stripFirstSegment && segments.length > 1) {
57907
+ segments = segments.slice(1);
57908
+ }
57909
+ const displaySegments = maxSegments && segments.length > maxSegments ? [
57910
+ ...segments.slice(0, maxSegments - 1),
57911
+ "...",
57912
+ segments[segments.length - 1]
57913
+ ] : segments;
57914
+ const badgeColor = color || theme.colors.primary;
57915
+ return /* @__PURE__ */ jsx283(
57916
+ EuiFlexGroup41,
57917
+ {
57918
+ gutterSize: size,
57919
+ alignItems: "center",
57920
+ wrap: false,
57921
+ responsive: false,
57922
+ children: displaySegments.map((segment, index) => /* @__PURE__ */ jsxs150(Fragment67, { children: [
57923
+ /* @__PURE__ */ jsx283(EuiFlexItem49, { grow: false, children: /* @__PURE__ */ jsx283(
57924
+ WfoBadge,
57925
+ {
57926
+ color: badgeColor,
57927
+ textColor: theme.colors.ghost,
57928
+ size,
57929
+ children: segment
57930
+ }
57931
+ ) }),
57932
+ showArrows && index < displaySegments.length - 1 && /* @__PURE__ */ jsx283(EuiFlexItem49, { grow: false, children: /* @__PURE__ */ jsx283(
57933
+ EuiIcon9,
57934
+ {
57935
+ type: "arrowRight",
57936
+ size,
57937
+ color: theme.colors.link
57938
+ }
57939
+ ) })
57940
+ ] }, index))
57941
+ }
57942
+ );
57943
+ };
57944
+
57945
+ // src/components/WfoSearchPage/WfoSearchResults/WfoSearchResultItem.tsx
57946
+ import { Fragment as Fragment68, jsx as jsx284, jsxs as jsxs151 } from "@emotion/react/jsx-runtime";
57947
+ var WfoSearchResultItem = ({
57948
+ result,
57949
+ isSelected = false,
57950
+ onSelect,
57951
+ onPositionChange,
57952
+ index
57953
+ }) => {
57954
+ const t = useTranslations101("search.page");
57955
+ const matchingField = result.matching_field;
57956
+ const { theme } = useOrchestratorTheme();
57957
+ const baseUrl = `${window.location.protocol}//${window.location.host}`;
57958
+ const detailUrl = getDetailUrl(result, baseUrl);
57959
+ const itemRef = useRef13(null);
57960
+ useEffect42(() => {
57961
+ if (isSelected && onPositionChange && itemRef.current) {
57962
+ onPositionChange(index, itemRef.current);
57963
+ }
57964
+ }, [isSelected, index, onPositionChange]);
57965
+ return /* @__PURE__ */ jsx284(EuiFlexItem50, { children: /* @__PURE__ */ jsx284(
57966
+ EuiPanel18,
57967
+ {
57968
+ panelRef: itemRef,
57969
+ color: isSelected ? "primary" : "transparent",
57970
+ paddingSize: "m",
57971
+ "data-record-index": index,
57972
+ onClick: () => {
57973
+ onSelect?.();
57974
+ },
57975
+ style: isSelected ? {
57976
+ borderTop: theme.border.thick,
57977
+ borderBottom: theme.border.thick,
57978
+ borderLeft: "none",
57979
+ borderRight: "none",
57980
+ borderColor: theme.colors.primary
57981
+ } : void 0,
57982
+ children: /* @__PURE__ */ jsxs151(EuiFlexGroup42, { alignItems: "flexStart", gutterSize: "m", children: [
57983
+ /* @__PURE__ */ jsx284(EuiFlexItem50, { children: /* @__PURE__ */ jsxs151(EuiFlexGroup42, { direction: "column", gutterSize: "xs", children: [
57984
+ /* @__PURE__ */ jsx284(EuiFlexItem50, { children: /* @__PURE__ */ jsx284(
57985
+ EuiText58,
57986
+ {
57987
+ size: "m",
57988
+ style: {
57989
+ fontWeight: theme.font.weight.semiBold
57990
+ },
57991
+ children: getDescription(result)
57992
+ }
57993
+ ) }),
57994
+ matchingField && /* @__PURE__ */ jsxs151(Fragment68, { children: [
57995
+ matchingField.path && /* @__PURE__ */ jsx284(EuiFlexItem50, { children: /* @__PURE__ */ jsx284(
57996
+ WfoPathBreadcrumb,
57997
+ {
57998
+ path: matchingField.path,
57999
+ size: "s",
58000
+ maxSegments: 4,
58001
+ color: theme.colors.primary
58002
+ }
58003
+ ) }),
58004
+ /* @__PURE__ */ jsx284(EuiFlexItem50, { children: /* @__PURE__ */ jsx284(
58005
+ EuiText58,
58006
+ {
58007
+ style: {
58008
+ backgroundColor: "transparent",
58009
+ borderRadius: theme.border.radius.medium,
58010
+ fontSize: theme.size.base
58011
+ },
58012
+ children: /* @__PURE__ */ jsx284(
58013
+ WfoHighlightedText,
58014
+ {
58015
+ text: matchingField.text,
58016
+ highlight_indices: matchingField.highlight_indices
58017
+ }
58018
+ )
58019
+ }
58020
+ ) }),
58021
+ /* @__PURE__ */ jsx284(EuiSpacer31, { size: "xs" })
58022
+ ] })
58023
+ ] }) }),
58024
+ /* @__PURE__ */ jsx284(EuiFlexItem50, { grow: false, children: /* @__PURE__ */ jsxs151(
58025
+ EuiFlexGroup42,
58026
+ {
58027
+ direction: "column",
58028
+ alignItems: "flexEnd",
58029
+ gutterSize: "xs",
58030
+ children: [
58031
+ /* @__PURE__ */ jsx284(EuiFlexItem50, { children: /* @__PURE__ */ jsx284(
58032
+ WfoBadge,
58033
+ {
58034
+ color: theme.colors.primary,
58035
+ textColor: theme.colors.ghost,
58036
+ children: "score" in result && result.score ? result.score.toFixed(4) : "N/A"
58037
+ }
58038
+ ) }),
58039
+ /* @__PURE__ */ jsx284(EuiFlexItem50, { children: /* @__PURE__ */ jsx284(
58040
+ EuiButtonIcon17,
58041
+ {
58042
+ iconType: "popout",
58043
+ "aria-label": t("viewDetails"),
58044
+ onClick: (e) => {
58045
+ e.stopPropagation();
58046
+ window.open(detailUrl, "_blank");
58047
+ },
58048
+ color: "text",
58049
+ size: "m"
58050
+ }
58051
+ ) })
58052
+ ]
58053
+ }
58054
+ ) })
58055
+ ] })
58056
+ }
58057
+ ) });
58058
+ };
58059
+
58060
+ // src/components/WfoSearchPage/WfoSearchResults/WfoSubscriptionDetailModal.tsx
58061
+ import { useTranslations as useTranslations102 } from "next-intl";
58062
+ import {
58063
+ EuiButton as EuiButton23,
58064
+ EuiModal as EuiModal5,
58065
+ EuiModalBody as EuiModalBody5,
58066
+ EuiModalFooter as EuiModalFooter5,
58067
+ EuiModalHeader as EuiModalHeader5,
58068
+ EuiModalHeaderTitle as EuiModalHeaderTitle5
58069
+ } from "@elastic/eui";
58070
+ import { jsx as jsx285, jsxs as jsxs152 } from "@emotion/react/jsx-runtime";
58071
+ var WfoSubscriptionDetailModal = ({ isVisible, onClose, subscriptionData }) => {
58072
+ const t = useTranslations102("search.page");
58073
+ if (!isVisible || !subscriptionData) return null;
58074
+ const subscriptionId = subscriptionData && subscriptionData.subscription_id;
58075
+ return /* @__PURE__ */ jsxs152(EuiModal5, { onClose, maxWidth: 800, children: [
58076
+ /* @__PURE__ */ jsx285(EuiModalHeader5, { children: /* @__PURE__ */ jsx285(EuiModalHeaderTitle5, { children: t("subscriptionDetails") }) }),
58077
+ /* @__PURE__ */ jsx285(EuiModalBody5, { children: /* @__PURE__ */ jsx285(TreeProvider, { children: /* @__PURE__ */ jsx285(WfoSubscription, { subscriptionId }) }) }),
58078
+ /* @__PURE__ */ jsx285(EuiModalFooter5, { children: /* @__PURE__ */ jsx285(EuiButton23, { onClick: onClose, fill: true, children: t("closeButton") }) })
58079
+ ] });
58080
+ };
58081
+
58082
+ // src/components/WfoSearchPage/WfoSearchResults/WfoSearchResults.tsx
58083
+ import { Fragment as Fragment69, jsx as jsx286, jsxs as jsxs153 } from "@emotion/react/jsx-runtime";
58084
+ var WfoSearchResults = ({
58085
+ results,
58086
+ loading,
58087
+ selectedRecordIndex = 0,
58088
+ onRecordSelect
58089
+ }) => {
58090
+ const [modalData, setModalData] = useState63(null);
58091
+ const handleCloseModal = () => {
58092
+ setModalData(null);
58093
+ };
58094
+ if (loading) {
58095
+ return /* @__PURE__ */ jsx286(WfoSearchLoadingState, {});
58096
+ }
58097
+ if (!results || results.length === 0) {
58098
+ return /* @__PURE__ */ jsx286(WfoSearchEmptyState, {});
58099
+ }
58100
+ return /* @__PURE__ */ jsxs153(Fragment69, { children: [
58101
+ /* @__PURE__ */ jsx286(EuiPanel19, { paddingSize: "m", hasShadow: false, children: /* @__PURE__ */ jsx286(EuiFlexGroup43, { direction: "column", gutterSize: "s", children: results.map((result, idx) => /* @__PURE__ */ jsx286(
58102
+ WfoSearchResultItem,
58103
+ {
58104
+ result,
58105
+ index: idx,
58106
+ isSelected: idx === selectedRecordIndex,
58107
+ onSelect: () => onRecordSelect?.(idx)
58108
+ },
58109
+ idx
58110
+ )) }) }),
58111
+ /* @__PURE__ */ jsx286(
58112
+ WfoSubscriptionDetailModal,
58113
+ {
58114
+ isVisible: !!modalData,
58115
+ onClose: handleCloseModal,
58116
+ subscriptionData: modalData?.subscription,
58117
+ matchingField: modalData?.matchingField
58118
+ }
58119
+ )
58120
+ ] });
58121
+ };
58122
+
58123
+ // src/components/WfoSearchPage/WfoSearchResults/WfoSearchMetadataHeader.tsx
58124
+ import { jsx as jsx287 } from "@emotion/react/jsx-runtime";
58125
+ var WfoSearchMetadataHeader = ({
58126
+ search_metadata
58127
+ }) => {
58128
+ if (!search_metadata.search_type) return null;
58129
+ return /* @__PURE__ */ jsx287(WfoToolTip, { tooltipContent: search_metadata.description || "", children: /* @__PURE__ */ jsx287(WfoBadge, { color: "hollow", iconType: "search", textColor: "default", children: search_metadata.search_type }) });
58130
+ };
58131
+
58132
+ // src/components/WfoSearchPage/WfoSearchResults/WfoSearchPaginationInfo.tsx
58133
+ import { useTranslations as useTranslations103 } from "next-intl";
58134
+ import {
58135
+ EuiButtonIcon as EuiButtonIcon18,
58136
+ EuiFlexGroup as EuiFlexGroup44,
58137
+ EuiFlexItem as EuiFlexItem51,
58138
+ EuiText as EuiText59
58139
+ } from "@elastic/eui";
58140
+ import { jsx as jsx288, jsxs as jsxs154 } from "@emotion/react/jsx-runtime";
58141
+ var WfoSearchPaginationInfo = ({
58142
+ has_next_page,
58143
+ next_page_cursor,
58144
+ onNextPage,
58145
+ onPrevPage,
58146
+ isLoading = false,
58147
+ currentPage = 1,
58148
+ hasPrevPage = false,
58149
+ resultCount
58150
+ }) => {
58151
+ const t = useTranslations103("search.page");
58152
+ const { theme } = useOrchestratorTheme();
58153
+ const handleNextPage = () => {
58154
+ if (!isLoading && next_page_cursor && onNextPage)
58155
+ onNextPage(next_page_cursor);
58156
+ };
58157
+ const handlePrevPage = () => {
58158
+ if (!isLoading && onPrevPage) onPrevPage();
58159
+ };
58160
+ if (!has_next_page && !hasPrevPage) return null;
58161
+ return /* @__PURE__ */ jsxs154(
58162
+ EuiFlexGroup44,
58163
+ {
58164
+ justifyContent: "flexEnd",
58165
+ alignItems: "center",
58166
+ gutterSize: "xs",
58167
+ responsive: false,
58168
+ style: {
58169
+ whiteSpace: "nowrap",
58170
+ padding: 0,
58171
+ background: "transparent",
58172
+ border: "none"
58173
+ },
58174
+ role: "navigation",
58175
+ "aria-label": t("searchResultsPagination"),
58176
+ children: [
58177
+ /* @__PURE__ */ jsx288(EuiFlexItem51, { grow: false, children: /* @__PURE__ */ jsx288(
58178
+ EuiButtonIcon18,
58179
+ {
58180
+ iconType: "arrowLeft",
58181
+ "aria-label": t("previousPage"),
58182
+ onClick: handlePrevPage,
58183
+ disabled: !hasPrevPage || isLoading,
58184
+ color: "text",
58185
+ size: "s"
58186
+ }
58187
+ ) }),
58188
+ /* @__PURE__ */ jsx288(EuiFlexItem51, { grow: false, children: /* @__PURE__ */ jsxs154(EuiText59, { size: "xs", color: theme.colors.textSubdued, children: [
58189
+ t("page"),
58190
+ " ",
58191
+ currentPage
58192
+ ] }) }),
58193
+ /* @__PURE__ */ jsx288(EuiFlexItem51, { grow: false, children: /* @__PURE__ */ jsx288(
58194
+ EuiButtonIcon18,
58195
+ {
58196
+ iconType: "arrowRight",
58197
+ "aria-label": t("nextPage"),
58198
+ onClick: handleNextPage,
58199
+ disabled: !has_next_page || isLoading,
58200
+ color: "text",
58201
+ size: "s",
58202
+ isLoading
58203
+ }
58204
+ ) }),
58205
+ resultCount && resultCount > 0 && /* @__PURE__ */ jsx288(EuiFlexItem51, { grow: false, children: /* @__PURE__ */ jsx288(
58206
+ WfoBadge,
58207
+ {
58208
+ className: "wfoPagination__badge",
58209
+ color: "hollow",
58210
+ textColor: "default",
58211
+ children: t("resultsOnPage", { resultCount })
58212
+ }
58213
+ ) })
58214
+ ]
58215
+ }
58216
+ );
58217
+ };
58218
+
58219
+ // src/components/WfoSearchPage/WfoSearch/WfoSearch.tsx
58220
+ import { Fragment as Fragment70, jsx as jsx289, jsxs as jsxs155 } from "@emotion/react/jsx-runtime";
58221
+ var WfoSearch = () => {
58222
+ const t = useTranslations104("search.page");
58223
+ const { theme } = useOrchestratorTheme();
58224
+ const {
58225
+ urlParams,
58226
+ query,
58227
+ selectedEntityTab,
58228
+ showFilters,
58229
+ selectedRecordIndex,
58230
+ selectedRecordId,
58231
+ setQuery,
58232
+ setSelectedEntityTab,
58233
+ setShowFilters,
58234
+ setSelectedRecordIndex,
58235
+ setSelectedRecordId
58236
+ } = useUrlParams();
58237
+ const pageSize = DEFAULT_PAGE_SIZE2;
58238
+ const [filterGroup, setFilterGroup] = useState64({
58239
+ op: "AND",
58240
+ children: []
58241
+ });
58242
+ const [showDetailPanel, setShowDetailPanel] = useState64(false);
58243
+ const debouncedQuery = useDebounce(query, DEFAULT_DEBOUNCE_DELAY);
58244
+ const { results, loading, setResults } = useSearch(
58245
+ debouncedQuery,
58246
+ selectedEntityTab,
58247
+ filterGroup,
58248
+ pageSize
58249
+ );
58250
+ const [hasSearchBeenAttempted, setHasSearchBeenAttempted] = useState64(false);
58251
+ useEffect43(() => {
58252
+ const queryText = typeof debouncedQuery === "string" ? debouncedQuery : debouncedQuery?.text?.trim() || "";
58253
+ const hasFilters = filterGroup && filterGroup.children.length > 0;
58254
+ if (queryText.length >= 2 || hasFilters) {
58255
+ setHasSearchBeenAttempted(true);
58256
+ } else if (queryText === "" || queryText === "*") {
58257
+ setHasSearchBeenAttempted(false);
58258
+ }
58259
+ }, [debouncedQuery, filterGroup]);
58260
+ const {
58261
+ currentPage,
58262
+ error,
58263
+ isLoadingMore,
58264
+ handleNextPage,
58265
+ handlePrevPage,
58266
+ resetPagination,
58267
+ setError
58268
+ } = useSearchPagination(
58269
+ debouncedQuery,
58270
+ selectedEntityTab,
58271
+ filterGroup,
58272
+ pageSize,
58273
+ results,
58274
+ setResults
58275
+ );
58276
+ const [searchValue, setSearchValue] = useState64(() => {
58277
+ if (typeof query === "string") {
58278
+ return query;
58279
+ }
58280
+ const queryText = query.text || "";
58281
+ return queryText;
58282
+ });
58283
+ const handleTabChange = (tabId) => {
58284
+ setSelectedEntityTab(tabId);
58285
+ setQuery("");
58286
+ setSearchValue("");
58287
+ setFilterGroup({
58288
+ op: "AND",
58289
+ children: []
58290
+ });
58291
+ setResults({
58292
+ data: [],
58293
+ page_info: {
58294
+ has_next_page: false,
58295
+ next_page_cursor: null
58296
+ },
58297
+ search_metadata: {
58298
+ search_type: null,
58299
+ description: null
58300
+ }
58301
+ });
58302
+ setSelectedRecordIndex(0);
58303
+ setShowDetailPanel(false);
58304
+ resetPagination();
58305
+ };
58306
+ const onSearchChange = (searchText) => {
58307
+ const cleanedText = searchText.replace(/[=><[\]{}\\/#$%^&+]/g, "");
58308
+ setSearchValue(cleanedText);
58309
+ setQuery(cleanedText.trim() || "");
58310
+ };
58311
+ useEffect43(() => {
58312
+ if (typeof query === "string") {
58313
+ if (query !== searchValue) {
58314
+ setSearchValue(query);
58315
+ }
58316
+ } else {
58317
+ const queryText = query.text || "";
58318
+ if (queryText !== searchValue) {
58319
+ setSearchValue(queryText);
58320
+ }
58321
+ }
58322
+ }, [query, searchValue]);
58323
+ const currentTab = ENTITY_TABS.find((tab) => tab.id === selectedEntityTab);
58324
+ const isSearchActive = results.data.length > 0 || loading;
58325
+ const shouldShowNoResults = (() => {
58326
+ return hasSearchBeenAttempted && !loading && results.data.length === 0;
58327
+ })();
58328
+ useEffect43(() => {
58329
+ if (results.data.length > 0) {
58330
+ if (selectedRecordId) {
58331
+ const foundIndex = findResultIndexById(
58332
+ results.data,
58333
+ selectedRecordId
58334
+ );
58335
+ if (foundIndex !== -1) {
58336
+ setSelectedRecordIndex(foundIndex);
58337
+ } else if (results.data.length <= SMALL_RESULT_THRESHOLD) {
58338
+ setSelectedRecordIndex(0);
58339
+ setSelectedRecordId(null);
58340
+ }
58341
+ } else if (results.data.length <= SMALL_RESULT_THRESHOLD) {
58342
+ const indexFromUrl = urlParams.get("selected");
58343
+ if (!indexFromUrl) {
58344
+ setSelectedRecordIndex(0);
58345
+ }
58346
+ }
58347
+ }
58348
+ }, [results.data, selectedRecordId, urlParams]);
58349
+ useEffect43(() => {
58350
+ setShowDetailPanel(
58351
+ results?.data?.length > 0 && selectedRecordIndex >= 0
58352
+ );
58353
+ }, [results?.data?.length, selectedRecordIndex]);
58354
+ useEffect43(() => {
58355
+ resetPagination();
58356
+ }, [debouncedQuery, selectedEntityTab, filterGroup, resetPagination]);
58357
+ const { RESULTS_GROW, DETAIL_GROW } = LAYOUT_RATIOS;
58358
+ return /* @__PURE__ */ jsxs155(Fragment70, { children: [
58359
+ /* @__PURE__ */ jsx289(EuiTabs4, { children: ENTITY_TABS.map((tab) => /* @__PURE__ */ jsx289(
58360
+ EuiTab4,
58361
+ {
58362
+ onClick: () => handleTabChange(tab.id),
58363
+ isSelected: selectedEntityTab === tab.id,
58364
+ children: tab.label
58365
+ },
58366
+ tab.id
58367
+ )) }),
58368
+ /* @__PURE__ */ jsx289(EuiSpacer32, { size: "m" }),
58369
+ /* @__PURE__ */ jsx289(
58370
+ EuiFieldSearch3,
58371
+ {
58372
+ placeholder: t("searchPlaceholder", {
58373
+ entityType: currentTab?.label.toLowerCase()
58374
+ }),
58375
+ value: searchValue || "",
58376
+ onChange: (event) => {
58377
+ onSearchChange(event.target.value);
58378
+ },
58379
+ onSearch: (value) => {
58380
+ onSearchChange(value);
58381
+ },
58382
+ incremental: true,
58383
+ fullWidth: true
58384
+ }
58385
+ ),
58386
+ /* @__PURE__ */ jsx289(EuiSpacer32, { size: "s" }),
58387
+ /* @__PURE__ */ jsx289(EuiFlexGroup45, { gutterSize: "s", alignItems: "center", children: /* @__PURE__ */ jsx289(EuiFlexItem52, { grow: false, children: /* @__PURE__ */ jsx289(
58388
+ EuiButton24,
58389
+ {
58390
+ iconType: showFilters ? "eyeClosed" : "eye",
58391
+ size: "s",
58392
+ onClick: () => setShowFilters(!showFilters),
58393
+ children: showFilters ? t("hideFilters") : t("showFilters")
58394
+ }
58395
+ ) }) }),
58396
+ showFilters && /* @__PURE__ */ jsxs155(Fragment70, { children: [
58397
+ /* @__PURE__ */ jsx289(EuiSpacer32, { size: "m" }),
58398
+ /* @__PURE__ */ jsxs155(EuiPanel20, { hasBorder: true, paddingSize: "m", children: [
58399
+ /* @__PURE__ */ jsx289(EuiText60, { children: /* @__PURE__ */ jsx289("h4", { children: t("structuredFilters") }) }),
58400
+ /* @__PURE__ */ jsx289(EuiSpacer32, { size: "s" }),
58401
+ /* @__PURE__ */ jsx289(
58402
+ FilterGroup,
58403
+ {
58404
+ group: filterGroup,
58405
+ entityType: selectedEntityTab,
58406
+ onChange: setFilterGroup,
58407
+ isRoot: true
58408
+ }
58409
+ )
58410
+ ] })
58411
+ ] }),
58412
+ /* @__PURE__ */ jsx289(EuiSpacer32, { size: "m" }),
58413
+ error && /* @__PURE__ */ jsxs155(Fragment70, { children: [
58414
+ /* @__PURE__ */ jsxs155(
58415
+ EuiCallOut3,
58416
+ {
58417
+ title: t("searchError"),
58418
+ color: "danger",
58419
+ iconType: "alert",
58420
+ size: "s",
58421
+ children: [
58422
+ /* @__PURE__ */ jsx289("p", { children: error }),
58423
+ /* @__PURE__ */ jsx289(
58424
+ EuiButton24,
58425
+ {
58426
+ size: "s",
58427
+ color: "danger",
58428
+ onClick: () => setError(null),
58429
+ children: t("dismiss")
58430
+ }
58431
+ )
58432
+ ]
58433
+ }
58434
+ ),
58435
+ /* @__PURE__ */ jsx289(EuiSpacer32, { size: "m" })
58436
+ ] }),
58437
+ shouldShowNoResults && /* @__PURE__ */ jsxs155(Fragment70, { children: [
58438
+ /* @__PURE__ */ jsx289(EuiSpacer32, { size: "l" }),
58439
+ /* @__PURE__ */ jsxs155(
58440
+ EuiCallOut3,
58441
+ {
58442
+ title: t("noResults"),
58443
+ color: "primary",
58444
+ iconType: "search",
58445
+ size: "m",
58446
+ children: [
58447
+ /* @__PURE__ */ jsx289("p", { children: t("noResultsMessage", {
58448
+ entityType: currentTab?.label.toLowerCase()
58449
+ }) }),
58450
+ /* @__PURE__ */ jsx289(EuiSpacer32, { size: "s" }),
58451
+ /* @__PURE__ */ jsx289(EuiText60, { size: "s", color: "subdued", children: /* @__PURE__ */ jsx289("p", { children: t("noResultsSuggestions") }) })
58452
+ ]
58453
+ }
58454
+ ),
58455
+ /* @__PURE__ */ jsx289(EuiSpacer32, { size: "l" })
58456
+ ] }),
58457
+ isSearchActive && /* @__PURE__ */ jsxs155(Fragment70, { children: [
58458
+ /* @__PURE__ */ jsx289(EuiSpacer32, { size: "m" }),
58459
+ /* @__PURE__ */ jsxs155(EuiFlexGroup45, { gutterSize: "s", alignItems: "center", children: [
58460
+ /* @__PURE__ */ jsx289(EuiFlexItem52, { grow: showDetailPanel ? RESULTS_GROW : 1, children: /* @__PURE__ */ jsxs155(
58461
+ EuiFlexGroup45,
58462
+ {
58463
+ gutterSize: "s",
58464
+ alignItems: "center",
58465
+ justifyContent: "spaceBetween",
58466
+ responsive: false,
58467
+ style: { width: "100%" },
58468
+ children: [
58469
+ /* @__PURE__ */ jsx289(EuiFlexItem52, { grow: false, children: /* @__PURE__ */ jsx289(
58470
+ WfoSearchMetadataHeader,
58471
+ {
58472
+ search_metadata: results.search_metadata
58473
+ }
58474
+ ) }),
58475
+ /* @__PURE__ */ jsx289(EuiFlexItem52, { grow: false, children: /* @__PURE__ */ jsx289(
58476
+ WfoSearchPaginationInfo,
58477
+ {
58478
+ has_next_page: results.page_info.has_next_page,
58479
+ next_page_cursor: results.page_info.next_page_cursor,
58480
+ onNextPage: handleNextPage,
58481
+ onPrevPage: handlePrevPage,
58482
+ isLoading: isLoadingMore,
58483
+ currentPage,
58484
+ hasPrevPage: currentPage > 1,
58485
+ resultCount: results?.data?.length || 0
58486
+ }
58487
+ ) })
58488
+ ]
58489
+ }
58490
+ ) }),
58491
+ showDetailPanel && /* @__PURE__ */ jsx289(EuiFlexItem52, { grow: DETAIL_GROW })
58492
+ ] }),
58493
+ /* @__PURE__ */ jsx289(EuiSpacer32, { size: "s" }),
58494
+ /* @__PURE__ */ jsxs155(EuiFlexGroup45, { gutterSize: "s", alignItems: "flexStart", children: [
58495
+ /* @__PURE__ */ jsx289(EuiFlexItem52, { grow: showDetailPanel ? RESULTS_GROW : 1, children: /* @__PURE__ */ jsx289(EuiPanel20, { paddingSize: "none", hasBorder: true, children: /* @__PURE__ */ jsx289(
58496
+ WfoSearchResults,
58497
+ {
58498
+ results: results.data,
58499
+ loading,
58500
+ selectedRecordIndex,
58501
+ onRecordSelect: (index) => {
58502
+ setSelectedRecordIndex(index);
58503
+ const record = results.data[index];
58504
+ if (record) {
58505
+ const recordId = getRecordId(record);
58506
+ setSelectedRecordId(recordId);
58507
+ }
58508
+ }
58509
+ }
58510
+ ) }) }),
58511
+ showDetailPanel && /* @__PURE__ */ jsx289(EuiFlexItem52, { grow: DETAIL_GROW, children: /* @__PURE__ */ jsx289(
58512
+ EuiPanel20,
58513
+ {
58514
+ paddingSize: "m",
58515
+ hasBorder: true,
58516
+ hasShadow: false,
58517
+ color: "transparent",
58518
+ children: selectedEntityTab === "SUBSCRIPTION" && results.data[selectedRecordIndex] && isSubscriptionSearchResult(
58519
+ results.data[selectedRecordIndex]
58520
+ ) ? /* @__PURE__ */ jsx289(TreeProvider, { children: /* @__PURE__ */ jsx289(
58521
+ WfoSubscription,
58522
+ {
58523
+ subscriptionId: results.data[selectedRecordIndex].subscription.subscription_id
58524
+ }
58525
+ ) }) : /* @__PURE__ */ jsxs155(Fragment70, { children: [
58526
+ /* @__PURE__ */ jsx289(EuiText60, { children: /* @__PURE__ */ jsx289("h4", { children: t("details") }) }),
58527
+ /* @__PURE__ */ jsx289(EuiSpacer32, { size: "m" }),
58528
+ /* @__PURE__ */ jsxs155(
58529
+ EuiText60,
58530
+ {
58531
+ color: theme.colors.textSubdued,
58532
+ children: [
58533
+ /* @__PURE__ */ jsx289("p", { children: t(
58534
+ "showingDetailsForResult",
58535
+ {
58536
+ resultNumber: selectedRecordIndex + 1
58537
+ }
58538
+ ) }),
58539
+ /* @__PURE__ */ jsx289(EuiSpacer32, { size: "s" }),
58540
+ /* @__PURE__ */ jsxs155(
58541
+ WfoBadge,
58542
+ {
58543
+ color: theme.colors.primary,
58544
+ textColor: theme.colors.ghost,
58545
+ children: [
58546
+ selectedEntityTab,
58547
+ " #",
58548
+ selectedRecordIndex + 1
58549
+ ]
58550
+ }
58551
+ ),
58552
+ /* @__PURE__ */ jsx289(EuiSpacer32, { size: "m" }),
58553
+ /* @__PURE__ */ jsx289("p", { children: /* @__PURE__ */ jsx289("em", { children: t(
58554
+ "selectResultInstruction"
58555
+ ) }) })
58556
+ ]
58557
+ }
58558
+ )
58559
+ ] })
58560
+ }
58561
+ ) })
58562
+ ] })
58563
+ ] })
58564
+ ] });
58565
+ };
58566
+
58567
+ // src/components/WfoAgent/WfoAgent/WfoAgent.tsx
58568
+ import { useTranslations as useTranslations106 } from "next-intl";
58569
+ import { useCoAgent } from "@copilotkit/react-core";
58570
+ import { CopilotSidebar } from "@copilotkit/react-ui";
58571
+ import { EuiFlexGroup as EuiFlexGroup47, EuiFlexItem as EuiFlexItem54, EuiSpacer as EuiSpacer34, EuiText as EuiText62 } from "@elastic/eui";
58572
+
58573
+ // src/components/WfoAgent/FilterDisplay/FilterDisplay.tsx
58574
+ import { useTranslations as useTranslations105 } from "next-intl";
58575
+ import {
58576
+ EuiFlexGroup as EuiFlexGroup46,
58577
+ EuiFlexItem as EuiFlexItem53,
58578
+ EuiPanel as EuiPanel21,
58579
+ EuiSpacer as EuiSpacer33,
58580
+ EuiText as EuiText61
58581
+ } from "@elastic/eui";
58582
+
58583
+ // src/components/WfoAgent/FilterDisplay/styles.ts
58584
+ import { css as css53 } from "@emotion/react";
58585
+ var getFilterDisplayStyles = ({ theme }) => {
58586
+ const wrapStyle = css53({
58587
+ display: "flex",
58588
+ flexWrap: "wrap",
58589
+ gap: theme.size.s
58590
+ });
58591
+ const columnGroupWrapStyle = css53({
58592
+ display: "flex",
58593
+ flexDirection: "column",
58594
+ gap: theme.size.s,
58595
+ alignItems: "flex-start"
58596
+ });
58597
+ const chipStyle = css53({
58598
+ display: "inline-flex",
58599
+ alignItems: "center",
58600
+ borderRadius: theme.size.xl,
58601
+ border: `1px solid ${theme.border.color}`,
58602
+ backgroundColor: theme.colors.body,
58603
+ padding: `${theme.size.s} ${theme.size.m}`,
58604
+ lineHeight: 1.1,
58605
+ gap: theme.size.s
58606
+ });
58607
+ const groupStyle = css53({
58608
+ border: `1px solid ${theme.colors.lightShade}`,
58609
+ borderRadius: theme.border.radius.medium,
58610
+ padding: theme.size.s,
58611
+ margin: theme.size.xs,
58612
+ backgroundColor: theme.colors.body
58613
+ });
58614
+ const operatorStyle = css53({
58615
+ fontFamily: theme.font.familyCode,
58616
+ padding: `${theme.size.xs}px ${theme.size.s}px`,
58617
+ borderRadius: theme.size.s,
58618
+ backgroundColor: theme.colors.primary,
58619
+ color: theme.colors.ghost,
58620
+ fontSize: theme.size.m,
58621
+ fontWeight: theme.font.weight.bold,
58622
+ margin: `${theme.size.xs} 0`
58623
+ });
58624
+ const valueStyle = css53({
58625
+ fontWeight: theme.font.weight.semiBold,
58626
+ color: theme.colors.warning
58627
+ });
58628
+ return {
58629
+ wrapStyle,
58630
+ columnGroupWrapStyle,
58631
+ chipStyle,
58632
+ groupStyle,
58633
+ operatorStyle,
58634
+ valueStyle
58635
+ };
58636
+ };
58637
+
58638
+ // src/components/WfoAgent/FilterDisplay/FilterDisplay.tsx
58639
+ import { jsx as jsx290, jsxs as jsxs156 } from "@emotion/react/jsx-runtime";
58640
+ var DEPTH_INDENT = 16;
58641
+ function FilterDisplay({ parameters }) {
58642
+ const t = useTranslations105("agent.page");
58643
+ const {
58644
+ wrapStyle,
58645
+ columnGroupWrapStyle,
58646
+ chipStyle,
58647
+ groupStyle,
58648
+ operatorStyle,
58649
+ valueStyle
58650
+ } = useWithOrchestratorTheme(getFilterDisplayStyles);
58651
+ const { action, entity_type, filters, query } = parameters ?? {};
58652
+ if (!parameters || Object.keys(parameters).length === 0) return null;
58653
+ const sectionTitle = (text) => /* @__PURE__ */ jsx290(EuiText61, { size: "xs", color: "subdued", children: /* @__PURE__ */ jsx290("strong", { children: text }) });
58654
+ const formatFilterValue = (condition) => {
58655
+ if ("value" in condition && condition.value !== void 0) {
58656
+ if (condition.op === "between" && condition.value && typeof condition.value === "object") {
58657
+ const { start, end, from, to } = condition.value;
58658
+ const fromVal = start || from;
58659
+ const toVal = end || to;
58660
+ return `${fromVal} \u2026 ${toVal}`;
58661
+ }
58662
+ return String(condition.value);
58663
+ }
58664
+ return "\u2014";
58665
+ };
58666
+ const renderFilterGroup = (group, depth = 0) => {
58667
+ if (!group.children || group.children.length === 0) {
58668
+ return /* @__PURE__ */ jsx290(EuiText61, { size: "s", color: "subdued", children: /* @__PURE__ */ jsx290("em", { children: t("emptyGroup") }) });
58669
+ }
58670
+ const areChildrenGroups = group.children.length > 0 && !isCondition(group.children[0]);
58671
+ return /* @__PURE__ */ jsxs156("div", { css: groupStyle, style: { marginLeft: depth * DEPTH_INDENT }, children: [
58672
+ /* @__PURE__ */ jsx290("div", { css: operatorStyle, children: group.op }),
58673
+ /* @__PURE__ */ jsx290("div", { css: areChildrenGroups ? columnGroupWrapStyle : wrapStyle, children: group.children.map((child, i) => /* @__PURE__ */ jsx290("div", { children: isCondition(child) ? /* @__PURE__ */ jsxs156("div", { css: chipStyle, children: [
58674
+ /* @__PURE__ */ jsx290(
58675
+ WfoPathBreadcrumb,
58676
+ {
58677
+ path: child.path,
58678
+ size: "s",
58679
+ showArrows: true
58680
+ }
58681
+ ),
58682
+ /* @__PURE__ */ jsx290(
58683
+ WfoBadge,
58684
+ {
58685
+ textColor: "default",
58686
+ color: "hollow",
58687
+ children: getOperatorDisplay(
58688
+ child.condition.op,
58689
+ child.value_kind ? {
58690
+ path: child.path,
58691
+ type: child.value_kind,
58692
+ operators: [],
58693
+ value_schema: {},
58694
+ group: "leaf"
58695
+ } : void 0
58696
+ ).symbol
58697
+ }
58698
+ ),
58699
+ /* @__PURE__ */ jsx290("span", { css: valueStyle, children: formatFilterValue(child.condition) })
58700
+ ] }) : renderFilterGroup(child, depth + 1) }, i)) })
58701
+ ] });
58702
+ };
58703
+ return /* @__PURE__ */ jsxs156(EuiPanel21, { hasBorder: true, paddingSize: "m", children: [
58704
+ /* @__PURE__ */ jsxs156(EuiFlexGroup46, { gutterSize: "m", wrap: true, responsive: true, children: [
58705
+ /* @__PURE__ */ jsxs156(EuiFlexItem53, { grow: false, children: [
58706
+ sectionTitle(t("action")),
58707
+ /* @__PURE__ */ jsx290(EuiSpacer33, { size: "xs" }),
58708
+ /* @__PURE__ */ jsx290(WfoBadge, { textColor: "default", color: "hollow", children: action || "N/A" })
58709
+ ] }),
58710
+ /* @__PURE__ */ jsxs156(EuiFlexItem53, { grow: false, children: [
58711
+ sectionTitle(t("entityType")),
58712
+ /* @__PURE__ */ jsx290(EuiSpacer33, { size: "xs" }),
58713
+ /* @__PURE__ */ jsx290(WfoBadge, { textColor: "default", color: "hollow", children: entity_type || "N/A" })
58714
+ ] }),
58715
+ query ? /* @__PURE__ */ jsxs156(EuiFlexItem53, { grow: false, children: [
58716
+ sectionTitle(t("searchQuery")),
58717
+ /* @__PURE__ */ jsx290(EuiSpacer33, { size: "xs" }),
58718
+ /* @__PURE__ */ jsx290(EuiText61, { size: "s", children: /* @__PURE__ */ jsxs156("em", { children: [
58719
+ '"',
58720
+ query,
58721
+ '"'
58722
+ ] }) })
58723
+ ] }) : null
58724
+ ] }),
58725
+ /* @__PURE__ */ jsx290(EuiSpacer33, { size: "m" }),
58726
+ sectionTitle(t("activeFilters")),
58727
+ /* @__PURE__ */ jsx290(EuiSpacer33, { size: "s" }),
58728
+ filters && filters.children && filters.children.length > 0 ? renderFilterGroup(filters) : /* @__PURE__ */ jsx290(EuiText61, { size: "s", color: "subdued", children: /* @__PURE__ */ jsx290("em", { children: t("noFiltersApplied") }) })
58729
+ ] });
58730
+ }
58731
+
58732
+ // src/components/WfoAgent/WfoAgent/WfoAgent.tsx
58733
+ import { jsx as jsx291, jsxs as jsxs157 } from "@emotion/react/jsx-runtime";
58734
+ var initialState3 = {
58735
+ parameters: {
58736
+ action: "select",
58737
+ entity_type: "SUBSCRIPTION",
58738
+ filters: [],
58739
+ query: null
58740
+ },
58741
+ results: []
58742
+ };
58743
+ function WfoAgent() {
58744
+ const t = useTranslations106("agent");
58745
+ const tPage = useTranslations106("agent.page");
58746
+ const { state } = useCoAgent({
58747
+ name: "query_agent",
58748
+ initialState: initialState3
58749
+ });
58750
+ const { parameters, results } = state;
58751
+ const hasStarted = !!(state.parameters && Array.isArray(state.parameters.filters) && state.parameters.filters.length > 0);
58752
+ const isLoadingResults = hasStarted && (!state.results || state.results.length === 0);
58753
+ const displayParameters = parameters && {
58754
+ ...parameters,
58755
+ filters: Array.isArray(parameters.filters) ? { op: "AND", children: parameters.filters } : parameters.filters
58756
+ };
58757
+ return /* @__PURE__ */ jsxs157(EuiFlexGroup47, { gutterSize: "l", alignItems: "stretch", children: [
58758
+ /* @__PURE__ */ jsxs157(EuiFlexItem54, { grow: 2, children: [
58759
+ /* @__PURE__ */ jsx291(EuiText62, { children: /* @__PURE__ */ jsx291("h1", { children: t("title") }) }),
58760
+ /* @__PURE__ */ jsx291(EuiSpacer34, { size: "m" }),
58761
+ /* @__PURE__ */ jsx291(EuiText62, { size: "s", children: /* @__PURE__ */ jsx291("h2", { children: tPage("filledParameters") }) }),
58762
+ /* @__PURE__ */ jsx291(EuiSpacer34, { size: "s" }),
58763
+ displayParameters && /* @__PURE__ */ jsx291(FilterDisplay, { parameters: displayParameters }),
58764
+ /* @__PURE__ */ jsx291(EuiSpacer34, { size: "m" }),
58765
+ /* @__PURE__ */ jsx291(EuiText62, { size: "s", children: /* @__PURE__ */ jsxs157("h2", { children: [
58766
+ tPage("results"),
58767
+ " ",
58768
+ results ? `(${results.length})` : ""
58769
+ ] }) }),
58770
+ /* @__PURE__ */ jsx291(EuiSpacer34, { size: "s" }),
58771
+ /* @__PURE__ */ jsx291(
58772
+ WfoSearchResults,
58773
+ {
58774
+ results: results ?? [],
58775
+ loading: isLoadingResults,
58776
+ selectedRecordIndex: -1,
58777
+ onRecordSelect: () => {
58778
+ }
58779
+ }
58780
+ )
58781
+ ] }),
58782
+ /* @__PURE__ */ jsx291(EuiFlexItem54, { grow: 1, children: /* @__PURE__ */ jsx291(
58783
+ CopilotSidebar,
58784
+ {
58785
+ defaultOpen: true,
58786
+ clickOutsideToClose: false,
58787
+ labels: {
58788
+ title: tPage("copilot.title"),
58789
+ initial: tPage("copilot.initial")
58790
+ }
58791
+ }
58792
+ ) })
58793
+ ] });
58794
+ }
58795
+
55916
58796
  // src/rtk/endpoints/translations.ts
55917
58797
  var TRANSLATIONS_URL = "translations";
55918
58798
  var translationsApi = orchestratorApi.injectEndpoints({
@@ -56401,6 +59281,83 @@ var en_GB_default = {
56401
59281
  softwareVersions: "Software Versions",
56402
59282
  logout: "Logout",
56403
59283
  aoStatusPage: "A&O application status page"
59284
+ },
59285
+ agent: {
59286
+ title: "Search results",
59287
+ page: {
59288
+ filledParameters: "Filled parameters",
59289
+ results: "Results",
59290
+ emptyGroup: "Empty group",
59291
+ searchQuery: "Search query",
59292
+ activeFilters: "Active filters",
59293
+ noFiltersApplied: "No filters applied",
59294
+ entityType: "Entity type",
59295
+ action: "Action",
59296
+ copilot: {
59297
+ title: "Database assistant",
59298
+ initial: "Ask me things such as:\n\u2022 *Find active subscriptions for Surf*\n\u2022 *Show terminated workflows\u201D*\n\nThe filled template and results will appear on the left."
59299
+ }
59300
+ }
59301
+ },
59302
+ search: {
59303
+ page: {
59304
+ selectFieldFirst: "Select a field first",
59305
+ maxNestingDepth: "Maximum nesting depth reached",
59306
+ addNestedGroup: "Add nested group",
59307
+ addCondition: "Add condition",
59308
+ addGroup: "Add group",
59309
+ removeGroup: "Remove group",
59310
+ emptyGroupDescription: "Add conditions or nested groups to build your filter.",
59311
+ emptyGroupTitle: "Empty group",
59312
+ fieldSearchPlaceholder: "Type to search fields...",
59313
+ removeConditionAriaLabel: "Remove condition",
59314
+ groupLabel: "Group",
59315
+ hideFilters: "Hide filters",
59316
+ showFilters: "Show filters",
59317
+ structuredFilters: "Structured filters",
59318
+ searchError: "Error",
59319
+ selectResultInstruction: "Detail content will be implemented here...",
59320
+ showingDetailsForResult: "Showing details for result #{resultNumber}",
59321
+ details: "Details",
59322
+ dismiss: "Dismiss",
59323
+ searchPlaceholder: "Search for {entityType}\u2026",
59324
+ noResults: "No Results",
59325
+ noResultsMessage: "No {entityType} found matching your search criteria.",
59326
+ noResultsSuggestions: "Try adjusting your search terms, removing filters, or searching for different keywords.",
59327
+ noResultsFound: "No results found for your search.",
59328
+ loadingSearchResults: "Loading search results...",
59329
+ previousPage: "Previous page",
59330
+ page: "Page",
59331
+ nextPage: "Next page",
59332
+ resultsOnPage: "{resultCount} result(s) on this page",
59333
+ searchResultsPagination: "Search results pagination",
59334
+ viewDetails: "View details",
59335
+ closeButton: "Close",
59336
+ selectOrEnterValue: "Select or type value",
59337
+ enterValue: "Enter value",
59338
+ fromNumber: "From",
59339
+ toNumber: "To",
59340
+ fromDate: "From date",
59341
+ toDate: "To date",
59342
+ enterNumber: "Enter number",
59343
+ selectDateAndTime: "Select date",
59344
+ valueControlTo: "to",
59345
+ searchFieldsPlaceholder: "Search fields...",
59346
+ selectSpecificPathPlaceholder: "Select a specific path...",
59347
+ anyPathOption: "Any path",
59348
+ operatorLabel: "Operator",
59349
+ fieldLabel: "Field",
59350
+ valueLabel: "Value",
59351
+ fieldsGroupLabel: "Fields",
59352
+ componentsGroupLabel: "Components",
59353
+ pathsCount: "{count} paths"
59354
+ },
59355
+ tabs: {
59356
+ subscriptions: "Subscriptions",
59357
+ products: "Products",
59358
+ workflows: "Workflows",
59359
+ processes: "Processes"
59360
+ }
56404
59361
  }
56405
59362
  };
56406
59363
 
@@ -56907,6 +59864,7 @@ export {
56907
59864
  CacheTagType,
56908
59865
  ColorModes,
56909
59866
  ColumnType,
59867
+ ConditionRow,
56910
59868
  ConfirmationDialogContext,
56911
59869
  ConfirmationDialogContextWrapper,
56912
59870
  ConfirmationDialogProvider,
@@ -56923,11 +59881,14 @@ export {
56923
59881
  DEFAULT_PAGE_SIZES,
56924
59882
  DateField,
56925
59883
  DividerField,
59884
+ ENTITY_TABS,
56926
59885
  EngineStatus,
56927
59886
  Environment,
56928
59887
  ErrorField,
56929
59888
  ErrorsField,
56930
59889
  FileUploadField,
59890
+ FilterDisplay,
59891
+ FilterGroup,
56931
59892
  Footer,
56932
59893
  HIDDEN_KEYS,
56933
59894
  Header,
@@ -57035,12 +59996,14 @@ export {
57035
59996
  UnconnectedSelectField,
57036
59997
  UserInputFormWizard,
57037
59998
  VALUE_CELL_CLASS_NAME,
59999
+ ValueControl,
57038
60000
  VlanField,
57039
60001
  WFO_STATUS_COLOR_FIELD,
57040
60002
  WfoActionSettings,
57041
60003
  WfoActiveWorkflowsSummaryCard,
57042
60004
  WfoActualWork,
57043
60005
  WfoAdvancedTable,
60006
+ WfoAgent,
57044
60007
  WfoArrayField,
57045
60008
  WfoArrowDown,
57046
60009
  WfoArrowDownSvg,
@@ -57087,12 +60050,14 @@ export {
57087
60050
  WfoEyeFill,
57088
60051
  WfoFailedTasksBadge,
57089
60052
  WfoFailedTasksSummaryCard,
60053
+ WfoFieldSelector,
57090
60054
  WfoFilterTabs,
57091
60055
  WfoFirstPartUUID,
57092
60056
  WfoFlushSettings,
57093
60057
  WfoGroupedTable,
57094
60058
  WfoHeaderBadge,
57095
60059
  WfoHeroIconsWrapper,
60060
+ WfoHighlightedText,
57096
60061
  WfoInSyncField,
57097
60062
  WfoInformationModal,
57098
60063
  WfoInlineEdit,
@@ -57119,9 +60084,12 @@ export {
57119
60084
  WfoMyWorkflowsSummaryCard,
57120
60085
  WfoNoResults,
57121
60086
  WfoObjectField,
60087
+ WfoOperatorSelector,
57122
60088
  WfoPageHeader,
57123
60089
  WfoPageTemplate,
57124
60090
  WfoPageUnauthorized,
60091
+ WfoPathBreadcrumb,
60092
+ WfoPathSelector,
57125
60093
  WfoPencil,
57126
60094
  WfoPencilAlt,
57127
60095
  WfoPlannedWork,
@@ -57153,11 +60121,21 @@ export {
57153
60121
  WfoRefresh,
57154
60122
  WfoRelatedSubscriptions,
57155
60123
  WfoRenderElementOrString,
60124
+ WfoRenderPathOption,
60125
+ WfoRenderPathSelectionOption,
57156
60126
  WfoResetTextSearchIndexButton,
57157
60127
  WfoResourceTypesPage,
57158
60128
  WfoRowContextMenu,
60129
+ WfoSearch,
60130
+ WfoSearchEmptyState,
57159
60131
  WfoSearchField,
60132
+ WfoSearchLoadingState,
60133
+ WfoSearchMetadataHeader,
60134
+ WfoSearchPaginationInfo,
60135
+ WfoSearchResultItem,
60136
+ WfoSearchResults,
57160
60137
  WfoSearchStrikethrough,
60138
+ WfoSelectedPathDisplay,
57161
60139
  WfoSettingsModal,
57162
60140
  WfoSettingsPage,
57163
60141
  WfoSettingsTab,
@@ -57184,6 +60162,7 @@ export {
57184
60162
  WfoSubmitModal,
57185
60163
  WfoSubscription,
57186
60164
  WfoSubscriptionActions,
60165
+ WfoSubscriptionDetailModal,
57187
60166
  WfoSubscriptionDetailNoteEdit,
57188
60167
  WfoSubscriptionDetailPage,
57189
60168
  WfoSubscriptionDetailSection,
@@ -57239,10 +60218,12 @@ export {
57239
60218
  WorkerTypes,
57240
60219
  WorkflowTarget,
57241
60220
  addToastMessage,
60221
+ buildSearchParams,
57242
60222
  calculateTimeDifference,
57243
60223
  camelToHuman,
57244
60224
  catchErrorResponse,
57245
60225
  clearTableConfigFromLocalStorage,
60226
+ createOptionsFromPaths,
57246
60227
  createSideNavDivider,
57247
60228
  csvDownloadHandler,
57248
60229
  defaultOrchestratorTheme,
@@ -57253,10 +60234,13 @@ export {
57253
60234
  emptyOrchestratorConfig,
57254
60235
  emptyWfoErrorMonitoring,
57255
60236
  filterDataByCriteria,
60237
+ findResultIndexById,
57256
60238
  flattenArrayProps,
57257
60239
  formatDate,
57258
60240
  formatDateCetWithUtc,
57259
60241
  getAcceptFieldStyles,
60242
+ getButtonColor,
60243
+ getButtonFill,
57260
60244
  getCacheTag,
57261
60245
  getCommonFormFieldStyles,
57262
60246
  getConcatenatedPagedResult,
@@ -57269,8 +60253,14 @@ export {
57269
60253
  getDataTestId,
57270
60254
  getDate,
57271
60255
  getDefaultTableConfig,
60256
+ getDescription,
60257
+ getDetailUrl,
60258
+ getDisplayText,
60259
+ getEndpointPath,
57272
60260
  getEnvironmentVariables,
57273
60261
  getFieldFromProductBlockInstanceValues,
60262
+ getFieldNameFromFullPath,
60263
+ getFieldNameFromPath,
57274
60264
  getFirstUuidPart,
57275
60265
  getFormFieldsBaseStyle,
57276
60266
  getLastUncompletedProcess,
@@ -57279,6 +60269,7 @@ export {
57279
60269
  getNumberOfColumns,
57280
60270
  getNumberValueFromEnvironmentVariable,
57281
60271
  getObjectKeys,
60272
+ getOperatorDisplay,
57282
60273
  getOrchestratorComponentOverrideSlice,
57283
60274
  getOrchestratorConfigSlice,
57284
60275
  getOrchestratorStore,
@@ -57286,11 +60277,13 @@ export {
57286
60277
  getPageIndexChangeHandler,
57287
60278
  getPageInfoForSyncExport,
57288
60279
  getPageSizeChangeHandler,
60280
+ getPathSelectionOptions,
57289
60281
  getProductBlockTitle,
57290
60282
  getProductNamesFromProcess,
57291
60283
  getQueryStringHandler,
57292
60284
  getQueryUrl,
57293
60285
  getQueryVariablesForExport,
60286
+ getRecordId,
57294
60287
  getRowDetailData,
57295
60288
  getSortDirectionFromString,
57296
60289
  getStatusBadgeColor,
@@ -57298,6 +60291,7 @@ export {
57298
60291
  getTableConfigFromLocalStorage,
57299
60292
  getTasksListTabTypeFromString,
57300
60293
  getTotalNumberOfRows,
60294
+ getTypeColor,
57301
60295
  getTypedFieldFromObject,
57302
60296
  getUrlWithQueryParams,
57303
60297
  getUsedPrefixMin,
@@ -57321,12 +60315,19 @@ export {
57321
60315
  ipPrefixTableFieldStyling,
57322
60316
  ipamStates,
57323
60317
  isAllUpperCase,
60318
+ isCondition,
57324
60319
  isFetchBaseQueryError,
60320
+ isFilterValid,
60321
+ isFullPathSelected,
57325
60322
  isNullOrEmpty,
60323
+ isProcessSearchResult,
60324
+ isProductSearchResult,
57326
60325
  isRecord,
60326
+ isSubscriptionSearchResult,
57327
60327
  isToday,
57328
60328
  isUuid4,
57329
60329
  isValidLocalStorageTableConfig,
60330
+ isWorkflowSearchResult,
57330
60331
  localMomentToUtcTimestamp,
57331
60332
  mapGraphQlSubscriptionsResultToPageInfo,
57332
60333
  mapGraphQlSubscriptionsResultToSubscriptionListItems,
@@ -57362,6 +60363,7 @@ export {
57362
60363
  selectOrchestratorConfig,
57363
60364
  setTableConfigToLocalStorage,
57364
60365
  settingsTabs,
60366
+ shouldHideValueInput,
57365
60367
  snakeToHuman,
57366
60368
  snakeToKebab,
57367
60369
  sortProcessesByDate,
@@ -57446,6 +60448,10 @@ export {
57446
60448
  useResumeProcessMutation,
57447
60449
  useRetryAllProcessesMutation,
57448
60450
  useRetryProcessMutation,
60451
+ useSearchDefinitionsQuery,
60452
+ useSearchMutation,
60453
+ useSearchPathsQuery,
60454
+ useSearchWithPaginationMutation,
57449
60455
  useSetEngineStatusMutation,
57450
60456
  useSetSubscriptionInSyncMutation,
57451
60457
  useShowToastMessage,