@prorobotech/openapi-k8s-toolkit 1.1.0-alpha.10 → 1.1.0-alpha.12

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 (20) hide show
  1. package/dist/openapi-k8s-toolkit.es.js +1133 -839
  2. package/dist/openapi-k8s-toolkit.es.js.map +1 -1
  3. package/dist/openapi-k8s-toolkit.umd.js +1132 -838
  4. package/dist/openapi-k8s-toolkit.umd.js.map +1 -1
  5. package/dist/types/api/forms.d.ts +4 -0
  6. package/dist/types/components/molecules/BlackholeForm/index.d.ts +0 -1
  7. package/dist/types/components/molecules/BlackholeForm/molecules/index.d.ts +0 -1
  8. package/dist/types/components/molecules/ManageableSidebar/organisms/ManageableSidebarProvider/ManageableSidebarProvider.d.ts +1 -0
  9. package/dist/types/components/molecules/ManageableSidebar/organisms/ManageableSidebarProvider/utils.d.ts +2 -1
  10. package/dist/types/components/molecules/{BlackholeForm/molecules/YamlEditorSingleton → YamlEditorSingleton}/YamlEditorSingleton.d.ts +1 -1
  11. package/dist/types/components/molecules/index.d.ts +2 -1
  12. package/dist/types/components/organisms/DynamicComponents/molecules/Toggler/Toggler.d.ts +6 -0
  13. package/dist/types/components/organisms/DynamicComponents/molecules/Toggler/index.d.ts +1 -0
  14. package/dist/types/components/organisms/DynamicComponents/molecules/TogglerSegmented/TogglerSegmented.d.ts +6 -0
  15. package/dist/types/components/organisms/DynamicComponents/molecules/TogglerSegmented/index.d.ts +1 -0
  16. package/dist/types/components/organisms/DynamicComponents/molecules/index.d.ts +2 -0
  17. package/dist/types/components/organisms/DynamicComponents/types.d.ts +39 -0
  18. package/package.json +1 -1
  19. /package/dist/types/components/molecules/{BlackholeForm/molecules/YamlEditorSingleton → YamlEditorSingleton}/index.d.ts +0 -0
  20. /package/dist/types/components/molecules/{BlackholeForm/molecules/YamlEditorSingleton → YamlEditorSingleton}/styled.d.ts +0 -0
@@ -7886,19 +7886,54 @@
7886
7886
  pathToValue,
7887
7887
  body
7888
7888
  }) => {
7889
- const patchData = [
7889
+ const config = {
7890
+ headers: {
7891
+ "Content-Type": "application/json-patch+json"
7892
+ }
7893
+ };
7894
+ const replaceOp = [
7890
7895
  {
7891
7896
  op: "replace",
7892
7897
  path: pathToValue,
7893
7898
  value: body
7894
7899
  }
7895
7900
  ];
7896
- return axios.patch(endpoint, patchData, {
7897
- method: "PATCH",
7901
+ try {
7902
+ return await axios.patch(endpoint, replaceOp, config);
7903
+ } catch (error) {
7904
+ if (!isAxiosError(error)) {
7905
+ throw error;
7906
+ }
7907
+ const status = error.response?.status;
7908
+ if (status !== 422) {
7909
+ throw error;
7910
+ }
7911
+ const addOp = [
7912
+ {
7913
+ op: "add",
7914
+ path: pathToValue,
7915
+ value: body
7916
+ }
7917
+ ];
7918
+ return axios.patch(endpoint, addOp, config);
7919
+ }
7920
+ };
7921
+ const patchEntryWithDeleteOp = async ({
7922
+ endpoint,
7923
+ pathToValue
7924
+ }) => {
7925
+ const config = {
7898
7926
  headers: {
7899
7927
  "Content-Type": "application/json-patch+json"
7900
7928
  }
7901
- });
7929
+ };
7930
+ const replaceOp = [
7931
+ {
7932
+ op: "remove",
7933
+ path: pathToValue
7934
+ }
7935
+ ];
7936
+ return axios.patch(endpoint, replaceOp, config);
7902
7937
  };
7903
7938
 
7904
7939
  const DeleteModal = ({ name, onClose, endpoint }) => {
@@ -9511,9 +9546,10 @@
9511
9546
  replaceValues,
9512
9547
  pathname,
9513
9548
  idToCompare,
9549
+ fallbackIdToCompare,
9514
9550
  currentTags
9515
9551
  }) => {
9516
- const foundData = data.find((el) => el.id === idToCompare);
9552
+ const foundData = data.find((el) => el.id === idToCompare) || (fallbackIdToCompare ? data.find((el) => el.id === fallbackIdToCompare) : void 0);
9517
9553
  if (!foundData) {
9518
9554
  return void 0;
9519
9555
  }
@@ -9543,6 +9579,7 @@
9543
9579
  replaceValues,
9544
9580
  pathname,
9545
9581
  idToCompare,
9582
+ fallbackIdToCompare,
9546
9583
  currentTags,
9547
9584
  hidden,
9548
9585
  noMarginTop
@@ -9579,6 +9616,7 @@
9579
9616
  replaceValues,
9580
9617
  pathname,
9581
9618
  idToCompare,
9619
+ fallbackIdToCompare,
9582
9620
  currentTags
9583
9621
  });
9584
9622
  if (!result) {
@@ -38425,6 +38463,263 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
38425
38463
  ] });
38426
38464
  };
38427
38465
 
38466
+ const Toggler = ({ data, children }) => {
38467
+ const {
38468
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
38469
+ id,
38470
+ reqIndex,
38471
+ jsonPathToValue,
38472
+ criteria,
38473
+ notificationSuccessMessage,
38474
+ notificationSuccessMessageDescription,
38475
+ notificationErrorMessage,
38476
+ notificationErrorMessageDescription,
38477
+ containerStyle,
38478
+ endpoint,
38479
+ pathToValue,
38480
+ valueToSubmit
38481
+ } = data;
38482
+ const [api, contextHolder] = antd.notification.useNotification();
38483
+ const queryClient = reactQuery.useQueryClient();
38484
+ const { data: multiQueryData, isLoading: isMultiQueryLoading, isError: isMultiQueryErrors, errors } = useMultiQuery();
38485
+ const partsOfUrl = usePartsOfUrl();
38486
+ if (isMultiQueryLoading) {
38487
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." });
38488
+ }
38489
+ if (isMultiQueryErrors) {
38490
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
38491
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { children: "Errors:" }),
38492
+ /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: typeof e === "string" ? e : e.message }, i)) })
38493
+ ] });
38494
+ }
38495
+ const replaceValues = partsOfUrl.partsOfUrl.reduce((acc, value, index) => {
38496
+ acc[index.toString()] = value;
38497
+ return acc;
38498
+ }, {});
38499
+ const jsonRoot = multiQueryData[`req${reqIndex}`];
38500
+ if (jsonRoot === void 0) {
38501
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "No root for json path" });
38502
+ }
38503
+ const valueToCompare = jp.query(jsonRoot, `$${jsonPathToValue}`)[0];
38504
+ let valueToSwitch = false;
38505
+ if (criteria.type === "forSuccess") {
38506
+ if (criteria.operator === "exists") {
38507
+ valueToSwitch = valueToCompare !== void 0;
38508
+ }
38509
+ if (criteria.operator === "equals") {
38510
+ valueToSwitch = String(valueToCompare) === criteria.valueToCompare;
38511
+ }
38512
+ }
38513
+ if (criteria.type === "forError") {
38514
+ if (criteria.operator === "exists") {
38515
+ valueToSwitch = !valueToCompare;
38516
+ }
38517
+ if (criteria.operator === "equals") {
38518
+ valueToSwitch = String(valueToCompare) !== criteria.valueToCompare;
38519
+ }
38520
+ }
38521
+ const notificationSuccessMessagePrepared = notificationSuccessMessage ? parseAll({
38522
+ text: notificationSuccessMessage,
38523
+ replaceValues,
38524
+ multiQueryData
38525
+ }) : "Success";
38526
+ const notificationSuccessMessageDescriptionPrepared = notificationSuccessMessageDescription ? parseAll({
38527
+ text: notificationSuccessMessageDescription,
38528
+ replaceValues,
38529
+ multiQueryData
38530
+ }) : "Success";
38531
+ const notificationErrorMessagePrepared = notificationErrorMessage ? parseAll({
38532
+ text: notificationErrorMessage,
38533
+ replaceValues,
38534
+ multiQueryData
38535
+ }) : "Success";
38536
+ const notificationErrorMessageDescriptionPrepared = notificationErrorMessageDescription ? parseAll({
38537
+ text: notificationErrorMessageDescription,
38538
+ replaceValues,
38539
+ multiQueryData
38540
+ }) : "Success";
38541
+ const openNotificationSuccess = () => {
38542
+ api.success({
38543
+ message: notificationSuccessMessagePrepared,
38544
+ description: notificationSuccessMessageDescriptionPrepared,
38545
+ placement: "bottomRight"
38546
+ });
38547
+ };
38548
+ const openNotificationError = () => {
38549
+ api.error({
38550
+ message: notificationErrorMessagePrepared,
38551
+ description: notificationErrorMessageDescriptionPrepared,
38552
+ placement: "bottomRight"
38553
+ });
38554
+ };
38555
+ const endpointPrepared = endpoint ? parseAll({ text: endpoint, replaceValues, multiQueryData }) : "no-endpoint-provided";
38556
+ const pathToValuePrepared = pathToValue ? parseAll({ text: pathToValue, replaceValues, multiQueryData }) : "no-pathToValue-provided";
38557
+ const toggleOn = () => {
38558
+ patchEntryWithReplaceOp({
38559
+ endpoint: endpointPrepared,
38560
+ pathToValue: pathToValuePrepared,
38561
+ body: valueToSubmit.onValue
38562
+ }).then(() => {
38563
+ queryClient.invalidateQueries({ queryKey: ["multi"] });
38564
+ openNotificationSuccess();
38565
+ }).catch((error) => {
38566
+ openNotificationError();
38567
+ console.error(error);
38568
+ });
38569
+ };
38570
+ const toggleOff = () => {
38571
+ if (valueToSubmit.offValue !== void 0) {
38572
+ patchEntryWithReplaceOp({
38573
+ endpoint: endpointPrepared,
38574
+ pathToValue: pathToValuePrepared,
38575
+ body: valueToSubmit.offValue
38576
+ }).then(() => {
38577
+ queryClient.invalidateQueries({ queryKey: ["multi"] });
38578
+ openNotificationSuccess();
38579
+ }).catch((error) => {
38580
+ openNotificationError();
38581
+ console.error(error);
38582
+ });
38583
+ }
38584
+ if (valueToSubmit.toRemoveWhenOff) {
38585
+ patchEntryWithDeleteOp({
38586
+ endpoint: endpointPrepared,
38587
+ pathToValue: pathToValuePrepared
38588
+ }).then(() => {
38589
+ queryClient.invalidateQueries({ queryKey: ["multi"] });
38590
+ openNotificationSuccess();
38591
+ }).catch((error) => {
38592
+ openNotificationError();
38593
+ console.error(error);
38594
+ });
38595
+ }
38596
+ };
38597
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: containerStyle, children: [
38598
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
38599
+ antd.Switch,
38600
+ {
38601
+ value: valueToSwitch,
38602
+ onChange: (checked) => {
38603
+ if (checked) {
38604
+ toggleOn();
38605
+ } else {
38606
+ toggleOff();
38607
+ }
38608
+ }
38609
+ }
38610
+ ),
38611
+ children,
38612
+ contextHolder
38613
+ ] });
38614
+ };
38615
+
38616
+ const TogglerSegmented = ({
38617
+ data,
38618
+ children
38619
+ }) => {
38620
+ const {
38621
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
38622
+ id,
38623
+ reqIndex,
38624
+ jsonPathToValue,
38625
+ notificationSuccessMessage,
38626
+ notificationSuccessMessageDescription,
38627
+ notificationErrorMessage,
38628
+ notificationErrorMessageDescription,
38629
+ containerStyle,
38630
+ endpoint,
38631
+ pathToValue,
38632
+ possibleValues,
38633
+ valuesMap
38634
+ } = data;
38635
+ const [api, contextHolder] = antd.notification.useNotification();
38636
+ const queryClient = reactQuery.useQueryClient();
38637
+ const { data: multiQueryData, isLoading: isMultiQueryLoading, isError: isMultiQueryErrors, errors } = useMultiQuery();
38638
+ const partsOfUrl = usePartsOfUrl();
38639
+ if (isMultiQueryLoading) {
38640
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." });
38641
+ }
38642
+ if (isMultiQueryErrors) {
38643
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
38644
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { children: "Errors:" }),
38645
+ /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: typeof e === "string" ? e : e.message }, i)) })
38646
+ ] });
38647
+ }
38648
+ const replaceValues = partsOfUrl.partsOfUrl.reduce((acc, value, index) => {
38649
+ acc[index.toString()] = value;
38650
+ return acc;
38651
+ }, {});
38652
+ const jsonRoot = multiQueryData[`req${reqIndex}`];
38653
+ if (jsonRoot === void 0) {
38654
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "No root for json path" });
38655
+ }
38656
+ const valueToCompare = jp.query(jsonRoot, `$${jsonPathToValue}`)[0];
38657
+ const valueToSegmented = valuesMap?.find((el) => el.value === valueToCompare)?.renderedValue;
38658
+ const notificationSuccessMessagePrepared = notificationSuccessMessage ? parseAll({
38659
+ text: notificationSuccessMessage,
38660
+ replaceValues,
38661
+ multiQueryData
38662
+ }) : "Success";
38663
+ const notificationSuccessMessageDescriptionPrepared = notificationSuccessMessageDescription ? parseAll({
38664
+ text: notificationSuccessMessageDescription,
38665
+ replaceValues,
38666
+ multiQueryData
38667
+ }) : "Success";
38668
+ const notificationErrorMessagePrepared = notificationErrorMessage ? parseAll({
38669
+ text: notificationErrorMessage,
38670
+ replaceValues,
38671
+ multiQueryData
38672
+ }) : "Success";
38673
+ const notificationErrorMessageDescriptionPrepared = notificationErrorMessageDescription ? parseAll({
38674
+ text: notificationErrorMessageDescription,
38675
+ replaceValues,
38676
+ multiQueryData
38677
+ }) : "Success";
38678
+ const openNotificationSuccess = () => {
38679
+ api.success({
38680
+ message: notificationSuccessMessagePrepared,
38681
+ description: notificationSuccessMessageDescriptionPrepared,
38682
+ placement: "bottomRight"
38683
+ });
38684
+ };
38685
+ const openNotificationError = () => {
38686
+ api.error({
38687
+ message: notificationErrorMessagePrepared,
38688
+ description: notificationErrorMessageDescriptionPrepared,
38689
+ placement: "bottomRight"
38690
+ });
38691
+ };
38692
+ const endpointPrepared = endpoint ? parseAll({ text: endpoint, replaceValues, multiQueryData }) : "no-endpoint-provided";
38693
+ const pathToValuePrepared = pathToValue ? parseAll({ text: pathToValue, replaceValues, multiQueryData }) : "no-pathToValue-provided";
38694
+ const onChange = (renderedValue) => {
38695
+ const valueFromMap = valuesMap?.find((el) => el.renderedValue === renderedValue)?.value;
38696
+ const valueToSend = valueFromMap || renderedValue;
38697
+ patchEntryWithReplaceOp({
38698
+ endpoint: endpointPrepared,
38699
+ pathToValue: pathToValuePrepared,
38700
+ body: valueToSend
38701
+ }).then(() => {
38702
+ queryClient.invalidateQueries({ queryKey: ["multi"] });
38703
+ openNotificationSuccess();
38704
+ }).catch((error) => {
38705
+ openNotificationError();
38706
+ console.error(error);
38707
+ });
38708
+ };
38709
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: containerStyle, children: [
38710
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
38711
+ antd.Segmented,
38712
+ {
38713
+ options: possibleValues,
38714
+ value: valueToSegmented || "~n~e~v~e~r",
38715
+ onChange: (value) => onChange(value)
38716
+ }
38717
+ ),
38718
+ children,
38719
+ contextHolder
38720
+ ] });
38721
+ };
38722
+
38428
38723
  const DynamicComponents = {
38429
38724
  DefaultDiv,
38430
38725
  antdText: AntdText,
@@ -38462,7 +38757,9 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
38462
38757
  SecretBase64Plain,
38463
38758
  ResourceBadge,
38464
38759
  Events: Events$1,
38465
- OwnerRefs
38760
+ OwnerRefs,
38761
+ Toggler,
38762
+ TogglerSegmented
38466
38763
  };
38467
38764
 
38468
38765
  const prepareUrlsToFetchForDynamicRenderer = ({
@@ -39207,733 +39504,161 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
39207
39504
  );
39208
39505
  };
39209
39506
 
39210
- /**
39211
- * lodash (Custom Build) <https://lodash.com/>
39212
- * Build: `lodash modularize exports="npm" -o ./`
39213
- * Copyright jQuery Foundation and other contributors <https://jquery.org/>
39214
- * Released under MIT license <https://lodash.com/license>
39215
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
39216
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
39217
- */
39218
-
39219
- /** Used as the `TypeError` message for "Functions" methods. */
39220
- var FUNC_ERROR_TEXT = 'Expected a function';
39221
-
39222
- /** Used as references for various `Number` constants. */
39223
- var NAN = 0 / 0;
39507
+ function _defineProperty$1(obj, key, value) {
39508
+ if (key in obj) {
39509
+ Object.defineProperty(obj, key, {
39510
+ value: value,
39511
+ enumerable: true,
39512
+ configurable: true,
39513
+ writable: true
39514
+ });
39515
+ } else {
39516
+ obj[key] = value;
39517
+ }
39224
39518
 
39225
- /** `Object#toString` result references. */
39226
- var symbolTag = '[object Symbol]';
39519
+ return obj;
39520
+ }
39227
39521
 
39228
- /** Used to match leading and trailing whitespace. */
39229
- var reTrim = /^\s+|\s+$/g;
39522
+ function ownKeys$1(object, enumerableOnly) {
39523
+ var keys = Object.keys(object);
39230
39524
 
39231
- /** Used to detect bad signed hexadecimal string values. */
39232
- var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
39525
+ if (Object.getOwnPropertySymbols) {
39526
+ var symbols = Object.getOwnPropertySymbols(object);
39527
+ if (enumerableOnly) symbols = symbols.filter(function (sym) {
39528
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
39529
+ });
39530
+ keys.push.apply(keys, symbols);
39531
+ }
39233
39532
 
39234
- /** Used to detect binary string values. */
39235
- var reIsBinary = /^0b[01]+$/i;
39533
+ return keys;
39534
+ }
39236
39535
 
39237
- /** Used to detect octal string values. */
39238
- var reIsOctal = /^0o[0-7]+$/i;
39536
+ function _objectSpread2$1(target) {
39537
+ for (var i = 1; i < arguments.length; i++) {
39538
+ var source = arguments[i] != null ? arguments[i] : {};
39239
39539
 
39240
- /** Built-in method references without a dependency on `root`. */
39241
- var freeParseInt = parseInt;
39540
+ if (i % 2) {
39541
+ ownKeys$1(Object(source), true).forEach(function (key) {
39542
+ _defineProperty$1(target, key, source[key]);
39543
+ });
39544
+ } else if (Object.getOwnPropertyDescriptors) {
39545
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
39546
+ } else {
39547
+ ownKeys$1(Object(source)).forEach(function (key) {
39548
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
39549
+ });
39550
+ }
39551
+ }
39242
39552
 
39243
- /** Detect free variable `global` from Node.js. */
39244
- var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
39553
+ return target;
39554
+ }
39245
39555
 
39246
- /** Detect free variable `self`. */
39247
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
39556
+ function _objectWithoutPropertiesLoose(source, excluded) {
39557
+ if (source == null) return {};
39558
+ var target = {};
39559
+ var sourceKeys = Object.keys(source);
39560
+ var key, i;
39248
39561
 
39249
- /** Used as a reference to the global object. */
39250
- var root = freeGlobal || freeSelf || Function('return this')();
39562
+ for (i = 0; i < sourceKeys.length; i++) {
39563
+ key = sourceKeys[i];
39564
+ if (excluded.indexOf(key) >= 0) continue;
39565
+ target[key] = source[key];
39566
+ }
39251
39567
 
39252
- /** Used for built-in method references. */
39253
- var objectProto = Object.prototype;
39568
+ return target;
39569
+ }
39254
39570
 
39255
- /**
39256
- * Used to resolve the
39257
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
39258
- * of values.
39259
- */
39260
- var objectToString = objectProto.toString;
39571
+ function _objectWithoutProperties(source, excluded) {
39572
+ if (source == null) return {};
39261
39573
 
39262
- /* Built-in method references for those with the same name as other `lodash` methods. */
39263
- var nativeMax = Math.max,
39264
- nativeMin = Math.min;
39574
+ var target = _objectWithoutPropertiesLoose(source, excluded);
39265
39575
 
39266
- /**
39267
- * Gets the timestamp of the number of milliseconds that have elapsed since
39268
- * the Unix epoch (1 January 1970 00:00:00 UTC).
39269
- *
39270
- * @static
39271
- * @memberOf _
39272
- * @since 2.4.0
39273
- * @category Date
39274
- * @returns {number} Returns the timestamp.
39275
- * @example
39276
- *
39277
- * _.defer(function(stamp) {
39278
- * console.log(_.now() - stamp);
39279
- * }, _.now());
39280
- * // => Logs the number of milliseconds it took for the deferred invocation.
39281
- */
39282
- var now = function() {
39283
- return root.Date.now();
39284
- };
39576
+ var key, i;
39285
39577
 
39286
- /**
39287
- * Creates a debounced function that delays invoking `func` until after `wait`
39288
- * milliseconds have elapsed since the last time the debounced function was
39289
- * invoked. The debounced function comes with a `cancel` method to cancel
39290
- * delayed `func` invocations and a `flush` method to immediately invoke them.
39291
- * Provide `options` to indicate whether `func` should be invoked on the
39292
- * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
39293
- * with the last arguments provided to the debounced function. Subsequent
39294
- * calls to the debounced function return the result of the last `func`
39295
- * invocation.
39296
- *
39297
- * **Note:** If `leading` and `trailing` options are `true`, `func` is
39298
- * invoked on the trailing edge of the timeout only if the debounced function
39299
- * is invoked more than once during the `wait` timeout.
39300
- *
39301
- * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
39302
- * until to the next tick, similar to `setTimeout` with a timeout of `0`.
39303
- *
39304
- * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
39305
- * for details over the differences between `_.debounce` and `_.throttle`.
39306
- *
39307
- * @static
39308
- * @memberOf _
39309
- * @since 0.1.0
39310
- * @category Function
39311
- * @param {Function} func The function to debounce.
39312
- * @param {number} [wait=0] The number of milliseconds to delay.
39313
- * @param {Object} [options={}] The options object.
39314
- * @param {boolean} [options.leading=false]
39315
- * Specify invoking on the leading edge of the timeout.
39316
- * @param {number} [options.maxWait]
39317
- * The maximum time `func` is allowed to be delayed before it's invoked.
39318
- * @param {boolean} [options.trailing=true]
39319
- * Specify invoking on the trailing edge of the timeout.
39320
- * @returns {Function} Returns the new debounced function.
39321
- * @example
39322
- *
39323
- * // Avoid costly calculations while the window size is in flux.
39324
- * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
39325
- *
39326
- * // Invoke `sendMail` when clicked, debouncing subsequent calls.
39327
- * jQuery(element).on('click', _.debounce(sendMail, 300, {
39328
- * 'leading': true,
39329
- * 'trailing': false
39330
- * }));
39331
- *
39332
- * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
39333
- * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
39334
- * var source = new EventSource('/stream');
39335
- * jQuery(source).on('message', debounced);
39336
- *
39337
- * // Cancel the trailing debounced invocation.
39338
- * jQuery(window).on('popstate', debounced.cancel);
39339
- */
39340
- function debounce(func, wait, options) {
39341
- var lastArgs,
39342
- lastThis,
39343
- maxWait,
39344
- result,
39345
- timerId,
39346
- lastCallTime,
39347
- lastInvokeTime = 0,
39348
- leading = false,
39349
- maxing = false,
39350
- trailing = true;
39578
+ if (Object.getOwnPropertySymbols) {
39579
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
39351
39580
 
39352
- if (typeof func != 'function') {
39353
- throw new TypeError(FUNC_ERROR_TEXT);
39354
- }
39355
- wait = toNumber(wait) || 0;
39356
- if (isObject$2(options)) {
39357
- leading = !!options.leading;
39358
- maxing = 'maxWait' in options;
39359
- maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
39360
- trailing = 'trailing' in options ? !!options.trailing : trailing;
39581
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
39582
+ key = sourceSymbolKeys[i];
39583
+ if (excluded.indexOf(key) >= 0) continue;
39584
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
39585
+ target[key] = source[key];
39586
+ }
39361
39587
  }
39362
39588
 
39363
- function invokeFunc(time) {
39364
- var args = lastArgs,
39365
- thisArg = lastThis;
39589
+ return target;
39590
+ }
39366
39591
 
39367
- lastArgs = lastThis = undefined;
39368
- lastInvokeTime = time;
39369
- result = func.apply(thisArg, args);
39370
- return result;
39371
- }
39592
+ function _slicedToArray(arr, i) {
39593
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
39594
+ }
39372
39595
 
39373
- function leadingEdge(time) {
39374
- // Reset any `maxWait` timer.
39375
- lastInvokeTime = time;
39376
- // Start the timer for the trailing edge.
39377
- timerId = setTimeout(timerExpired, wait);
39378
- // Invoke the leading edge.
39379
- return leading ? invokeFunc(time) : result;
39380
- }
39596
+ function _arrayWithHoles(arr) {
39597
+ if (Array.isArray(arr)) return arr;
39598
+ }
39381
39599
 
39382
- function remainingWait(time) {
39383
- var timeSinceLastCall = time - lastCallTime,
39384
- timeSinceLastInvoke = time - lastInvokeTime,
39385
- result = wait - timeSinceLastCall;
39600
+ function _iterableToArrayLimit(arr, i) {
39601
+ if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
39602
+ var _arr = [];
39603
+ var _n = true;
39604
+ var _d = false;
39605
+ var _e = undefined;
39386
39606
 
39387
- return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
39607
+ try {
39608
+ for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
39609
+ _arr.push(_s.value);
39610
+
39611
+ if (i && _arr.length === i) break;
39612
+ }
39613
+ } catch (err) {
39614
+ _d = true;
39615
+ _e = err;
39616
+ } finally {
39617
+ try {
39618
+ if (!_n && _i["return"] != null) _i["return"]();
39619
+ } finally {
39620
+ if (_d) throw _e;
39621
+ }
39388
39622
  }
39389
39623
 
39390
- function shouldInvoke(time) {
39391
- var timeSinceLastCall = time - lastCallTime,
39392
- timeSinceLastInvoke = time - lastInvokeTime;
39624
+ return _arr;
39625
+ }
39393
39626
 
39394
- // Either this is the first call, activity has stopped and we're at the
39395
- // trailing edge, the system time has gone backwards and we're treating
39396
- // it as the trailing edge, or we've hit the `maxWait` limit.
39397
- return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
39398
- (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
39399
- }
39627
+ function _unsupportedIterableToArray(o, minLen) {
39628
+ if (!o) return;
39629
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
39630
+ var n = Object.prototype.toString.call(o).slice(8, -1);
39631
+ if (n === "Object" && o.constructor) n = o.constructor.name;
39632
+ if (n === "Map" || n === "Set") return Array.from(o);
39633
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
39634
+ }
39400
39635
 
39401
- function timerExpired() {
39402
- var time = now();
39403
- if (shouldInvoke(time)) {
39404
- return trailingEdge(time);
39405
- }
39406
- // Restart the timer.
39407
- timerId = setTimeout(timerExpired, remainingWait(time));
39408
- }
39636
+ function _arrayLikeToArray(arr, len) {
39637
+ if (len == null || len > arr.length) len = arr.length;
39409
39638
 
39410
- function trailingEdge(time) {
39411
- timerId = undefined;
39639
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
39412
39640
 
39413
- // Only invoke if we have `lastArgs` which means `func` has been
39414
- // debounced at least once.
39415
- if (trailing && lastArgs) {
39416
- return invokeFunc(time);
39417
- }
39418
- lastArgs = lastThis = undefined;
39419
- return result;
39420
- }
39641
+ return arr2;
39642
+ }
39421
39643
 
39422
- function cancel() {
39423
- if (timerId !== undefined) {
39424
- clearTimeout(timerId);
39425
- }
39426
- lastInvokeTime = 0;
39427
- lastArgs = lastCallTime = lastThis = timerId = undefined;
39428
- }
39644
+ function _nonIterableRest() {
39645
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
39646
+ }
39429
39647
 
39430
- function flush() {
39431
- return timerId === undefined ? result : trailingEdge(now());
39648
+ function _defineProperty(obj, key, value) {
39649
+ if (key in obj) {
39650
+ Object.defineProperty(obj, key, {
39651
+ value: value,
39652
+ enumerable: true,
39653
+ configurable: true,
39654
+ writable: true
39655
+ });
39656
+ } else {
39657
+ obj[key] = value;
39432
39658
  }
39433
39659
 
39434
- function debounced() {
39435
- var time = now(),
39436
- isInvoking = shouldInvoke(time);
39437
-
39438
- lastArgs = arguments;
39439
- lastThis = this;
39440
- lastCallTime = time;
39441
-
39442
- if (isInvoking) {
39443
- if (timerId === undefined) {
39444
- return leadingEdge(lastCallTime);
39445
- }
39446
- if (maxing) {
39447
- // Handle invocations in a tight loop.
39448
- timerId = setTimeout(timerExpired, wait);
39449
- return invokeFunc(lastCallTime);
39450
- }
39451
- }
39452
- if (timerId === undefined) {
39453
- timerId = setTimeout(timerExpired, wait);
39454
- }
39455
- return result;
39456
- }
39457
- debounced.cancel = cancel;
39458
- debounced.flush = flush;
39459
- return debounced;
39460
- }
39461
-
39462
- /**
39463
- * Checks if `value` is the
39464
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
39465
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
39466
- *
39467
- * @static
39468
- * @memberOf _
39469
- * @since 0.1.0
39470
- * @category Lang
39471
- * @param {*} value The value to check.
39472
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
39473
- * @example
39474
- *
39475
- * _.isObject({});
39476
- * // => true
39477
- *
39478
- * _.isObject([1, 2, 3]);
39479
- * // => true
39480
- *
39481
- * _.isObject(_.noop);
39482
- * // => true
39483
- *
39484
- * _.isObject(null);
39485
- * // => false
39486
- */
39487
- function isObject$2(value) {
39488
- var type = typeof value;
39489
- return !!value && (type == 'object' || type == 'function');
39490
- }
39491
-
39492
- /**
39493
- * Checks if `value` is object-like. A value is object-like if it's not `null`
39494
- * and has a `typeof` result of "object".
39495
- *
39496
- * @static
39497
- * @memberOf _
39498
- * @since 4.0.0
39499
- * @category Lang
39500
- * @param {*} value The value to check.
39501
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
39502
- * @example
39503
- *
39504
- * _.isObjectLike({});
39505
- * // => true
39506
- *
39507
- * _.isObjectLike([1, 2, 3]);
39508
- * // => true
39509
- *
39510
- * _.isObjectLike(_.noop);
39511
- * // => false
39512
- *
39513
- * _.isObjectLike(null);
39514
- * // => false
39515
- */
39516
- function isObjectLike(value) {
39517
- return !!value && typeof value == 'object';
39518
- }
39519
-
39520
- /**
39521
- * Checks if `value` is classified as a `Symbol` primitive or object.
39522
- *
39523
- * @static
39524
- * @memberOf _
39525
- * @since 4.0.0
39526
- * @category Lang
39527
- * @param {*} value The value to check.
39528
- * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
39529
- * @example
39530
- *
39531
- * _.isSymbol(Symbol.iterator);
39532
- * // => true
39533
- *
39534
- * _.isSymbol('abc');
39535
- * // => false
39536
- */
39537
- function isSymbol(value) {
39538
- return typeof value == 'symbol' ||
39539
- (isObjectLike(value) && objectToString.call(value) == symbolTag);
39540
- }
39541
-
39542
- /**
39543
- * Converts `value` to a number.
39544
- *
39545
- * @static
39546
- * @memberOf _
39547
- * @since 4.0.0
39548
- * @category Lang
39549
- * @param {*} value The value to process.
39550
- * @returns {number} Returns the number.
39551
- * @example
39552
- *
39553
- * _.toNumber(3.2);
39554
- * // => 3.2
39555
- *
39556
- * _.toNumber(Number.MIN_VALUE);
39557
- * // => 5e-324
39558
- *
39559
- * _.toNumber(Infinity);
39560
- * // => Infinity
39561
- *
39562
- * _.toNumber('3.2');
39563
- * // => 3.2
39564
- */
39565
- function toNumber(value) {
39566
- if (typeof value == 'number') {
39567
- return value;
39568
- }
39569
- if (isSymbol(value)) {
39570
- return NAN;
39571
- }
39572
- if (isObject$2(value)) {
39573
- var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
39574
- value = isObject$2(other) ? (other + '') : other;
39575
- }
39576
- if (typeof value != 'string') {
39577
- return value === 0 ? value : +value;
39578
- }
39579
- value = value.replace(reTrim, '');
39580
- var isBinary = reIsBinary.test(value);
39581
- return (isBinary || reIsOctal.test(value))
39582
- ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
39583
- : (reIsBadHex.test(value) ? NAN : +value);
39584
- }
39585
-
39586
- var lodash_debounce = debounce;
39587
-
39588
- const debounce$1 = /*@__PURE__*/getDefaultExportFromCjs(lodash_debounce);
39589
-
39590
- function useUnmount(func) {
39591
- const funcRef = K.useRef(func);
39592
- funcRef.current = func;
39593
- K.useEffect(
39594
- () => () => {
39595
- funcRef.current();
39596
- },
39597
- []
39598
- );
39599
- }
39600
-
39601
- // src/useDebounceCallback/useDebounceCallback.ts
39602
- function useDebounceCallback(func, delay = 500, options) {
39603
- const debouncedFunc = K.useRef();
39604
- useUnmount(() => {
39605
- if (debouncedFunc.current) {
39606
- debouncedFunc.current.cancel();
39607
- }
39608
- });
39609
- const debounced = K.useMemo(() => {
39610
- const debouncedFuncInstance = debounce$1(func, delay, options);
39611
- const wrappedFunc = (...args) => {
39612
- return debouncedFuncInstance(...args);
39613
- };
39614
- wrappedFunc.cancel = () => {
39615
- debouncedFuncInstance.cancel();
39616
- };
39617
- wrappedFunc.isPending = () => {
39618
- return !!debouncedFunc.current;
39619
- };
39620
- wrappedFunc.flush = () => {
39621
- return debouncedFuncInstance.flush();
39622
- };
39623
- return wrappedFunc;
39624
- }, [func, delay, options]);
39625
- K.useEffect(() => {
39626
- debouncedFunc.current = debounce$1(func, delay, options);
39627
- }, [func, delay, options]);
39628
- return debounced;
39629
- }
39630
-
39631
- function floorToDecimal(num, decimalPlaces) {
39632
- const factor = 10 ** decimalPlaces;
39633
- return Math.floor(num * factor) / factor;
39634
- }
39635
- const parseQuotaValue = (key, val) => {
39636
- let numericValue = parseFloat(val.replace(/[a-zA-Zа-яА-Я]/g, ""));
39637
- if (key === "cpu") {
39638
- if (val.endsWith("m")) {
39639
- numericValue /= 1e3;
39640
- }
39641
- return floorToDecimal(numericValue, 1);
39642
- }
39643
- if (val.endsWith("m")) {
39644
- numericValue /= 1e3;
39645
- } else if (val.endsWith("k")) {
39646
- numericValue /= 1e6;
39647
- } else if (val.endsWith("M")) {
39648
- numericValue /= 1e3;
39649
- } else if (val.endsWith("G")) {
39650
- numericValue /= 1;
39651
- } else if (val.endsWith("T")) {
39652
- numericValue *= 1e3;
39653
- } else if (val.endsWith("Ki")) {
39654
- numericValue /= 1024;
39655
- numericValue /= 1e6;
39656
- } else if (val.endsWith("Mi")) {
39657
- numericValue /= 1e3;
39658
- numericValue /= 1e3;
39659
- } else if (/^\d+(\.\d+)?$/.test(val)) {
39660
- numericValue /= 1e9;
39661
- } else {
39662
- throw new Error("Invalid value");
39663
- }
39664
- return floorToDecimal(numericValue, 1);
39665
- };
39666
- const parseQuotaValueCpu = (val) => {
39667
- if (typeof val === "string") {
39668
- let numericValue = parseFloat(val.replace(/[a-zA-Zа-яА-Я]/g, ""));
39669
- if (val.endsWith("m")) {
39670
- numericValue /= 1e3;
39671
- }
39672
- return floorToDecimal(numericValue, 1);
39673
- }
39674
- return 0;
39675
- };
39676
- const parseQuotaValueMemoryAndStorage = (val) => {
39677
- if (typeof val === "string") {
39678
- let numericValue = parseFloat(val.replace(/[a-zA-Zа-яА-Я]/g, ""));
39679
- if (val.endsWith("k")) {
39680
- numericValue /= 1e6;
39681
- } else if (val.endsWith("m")) {
39682
- numericValue /= 1e3;
39683
- } else if (val.endsWith("M")) {
39684
- numericValue /= 1e3;
39685
- } else if (val.endsWith("G")) {
39686
- numericValue /= 1;
39687
- } else if (val.endsWith("T")) {
39688
- numericValue *= 1e3;
39689
- } else if (val.endsWith("P")) {
39690
- numericValue *= 1e6;
39691
- } else if (val.endsWith("E")) {
39692
- numericValue *= 1e9;
39693
- } else if (val.endsWith("Ki")) {
39694
- numericValue *= 1024 / 1e9;
39695
- } else if (val.endsWith("Mi")) {
39696
- numericValue /= 1048.576;
39697
- } else if (val.endsWith("Gi")) {
39698
- numericValue *= 1.073741824;
39699
- } else if (val.endsWith("Ti")) {
39700
- numericValue *= 1.099511628;
39701
- } else if (val.endsWith("Pi")) {
39702
- numericValue *= 1.125899907;
39703
- } else if (val.endsWith("Ei")) {
39704
- numericValue *= 1.152921505;
39705
- } else if (val === "0") {
39706
- return 0;
39707
- } else {
39708
- throw new Error("Invalid value");
39709
- }
39710
- return floorToDecimal(numericValue, 1);
39711
- }
39712
- return 0;
39713
- };
39714
-
39715
- const findAllPathsForObject = (obj, targetKey, targetValue, currentPath = []) => {
39716
- let paths = [];
39717
- if (typeof obj !== "object" || obj === null) {
39718
- return paths;
39719
- }
39720
- if (obj[targetKey] === targetValue) {
39721
- paths.push([...currentPath]);
39722
- }
39723
- for (const key in obj) {
39724
- if (obj.hasOwnProperty(key)) {
39725
- const value = obj[key];
39726
- if (typeof value === "object" && value !== null) {
39727
- const newPath = [...currentPath, key];
39728
- const subPaths = findAllPathsForObject(value, targetKey, targetValue, newPath);
39729
- paths = paths.concat(subPaths);
39730
- }
39731
- }
39732
- }
39733
- return paths;
39734
- };
39735
- const normalizeValuesForQuotasToNumber = (object, properties) => {
39736
- const newObject = _$1.cloneDeep(object);
39737
- const cpuPaths = findAllPathsForObject(properties, "type", "rangeInputCpu");
39738
- const memoryPaths = findAllPathsForObject(properties, "type", "rangeInputMemory");
39739
- memoryPaths.forEach((path) => {
39740
- const cleanPath = path.filter((el) => typeof el === "string").filter((el) => el !== "properties");
39741
- const value = _$1.get(newObject, cleanPath);
39742
- if (value || value === 0) {
39743
- _$1.set(newObject, cleanPath, parseQuotaValueMemoryAndStorage(value));
39744
- }
39745
- });
39746
- cpuPaths.forEach((path) => {
39747
- const cleanPath = path.filter((el) => typeof el === "string").filter((el) => el !== "properties");
39748
- const value = _$1.get(newObject, cleanPath);
39749
- if (value || value === 0) {
39750
- _$1.set(newObject, cleanPath, parseQuotaValueCpu(value));
39751
- }
39752
- });
39753
- return newObject;
39754
- };
39755
-
39756
- const getAllPathsFromObj = (obj, prefix = []) => {
39757
- const entries = Array.isArray(obj) ? obj.map((value, index) => [index, value]) : Object.entries(obj);
39758
- return entries.flatMap(([key, value]) => {
39759
- const currentPath = [...prefix, key];
39760
- return typeof value === "object" && value !== null ? [currentPath, ...getAllPathsFromObj(value, currentPath)] : [currentPath];
39761
- });
39762
- };
39763
-
39764
- const getPrefixSubarrays = (arr) => {
39765
- return arr.map((_, index) => arr.slice(0, index + 1));
39766
- };
39767
-
39768
- const deepMerge = (a, b) => {
39769
- const result = { ...a };
39770
- for (const key of Object.keys(b)) {
39771
- const aVal = a[key];
39772
- const bVal = b[key];
39773
- if (aVal !== null && bVal !== null && typeof aVal === "object" && typeof bVal === "object" && !Array.isArray(aVal) && !Array.isArray(bVal)) {
39774
- result[key] = deepMerge(aVal, bVal);
39775
- } else {
39776
- result[key] = bVal;
39777
- }
39778
- }
39779
- return result;
39780
- };
39781
-
39782
- function _defineProperty$1(obj, key, value) {
39783
- if (key in obj) {
39784
- Object.defineProperty(obj, key, {
39785
- value: value,
39786
- enumerable: true,
39787
- configurable: true,
39788
- writable: true
39789
- });
39790
- } else {
39791
- obj[key] = value;
39792
- }
39793
-
39794
- return obj;
39795
- }
39796
-
39797
- function ownKeys$1(object, enumerableOnly) {
39798
- var keys = Object.keys(object);
39799
-
39800
- if (Object.getOwnPropertySymbols) {
39801
- var symbols = Object.getOwnPropertySymbols(object);
39802
- if (enumerableOnly) symbols = symbols.filter(function (sym) {
39803
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
39804
- });
39805
- keys.push.apply(keys, symbols);
39806
- }
39807
-
39808
- return keys;
39809
- }
39810
-
39811
- function _objectSpread2$1(target) {
39812
- for (var i = 1; i < arguments.length; i++) {
39813
- var source = arguments[i] != null ? arguments[i] : {};
39814
-
39815
- if (i % 2) {
39816
- ownKeys$1(Object(source), true).forEach(function (key) {
39817
- _defineProperty$1(target, key, source[key]);
39818
- });
39819
- } else if (Object.getOwnPropertyDescriptors) {
39820
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
39821
- } else {
39822
- ownKeys$1(Object(source)).forEach(function (key) {
39823
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
39824
- });
39825
- }
39826
- }
39827
-
39828
- return target;
39829
- }
39830
-
39831
- function _objectWithoutPropertiesLoose(source, excluded) {
39832
- if (source == null) return {};
39833
- var target = {};
39834
- var sourceKeys = Object.keys(source);
39835
- var key, i;
39836
-
39837
- for (i = 0; i < sourceKeys.length; i++) {
39838
- key = sourceKeys[i];
39839
- if (excluded.indexOf(key) >= 0) continue;
39840
- target[key] = source[key];
39841
- }
39842
-
39843
- return target;
39844
- }
39845
-
39846
- function _objectWithoutProperties(source, excluded) {
39847
- if (source == null) return {};
39848
-
39849
- var target = _objectWithoutPropertiesLoose(source, excluded);
39850
-
39851
- var key, i;
39852
-
39853
- if (Object.getOwnPropertySymbols) {
39854
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
39855
-
39856
- for (i = 0; i < sourceSymbolKeys.length; i++) {
39857
- key = sourceSymbolKeys[i];
39858
- if (excluded.indexOf(key) >= 0) continue;
39859
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
39860
- target[key] = source[key];
39861
- }
39862
- }
39863
-
39864
- return target;
39865
- }
39866
-
39867
- function _slicedToArray(arr, i) {
39868
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
39869
- }
39870
-
39871
- function _arrayWithHoles(arr) {
39872
- if (Array.isArray(arr)) return arr;
39873
- }
39874
-
39875
- function _iterableToArrayLimit(arr, i) {
39876
- if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
39877
- var _arr = [];
39878
- var _n = true;
39879
- var _d = false;
39880
- var _e = undefined;
39881
-
39882
- try {
39883
- for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
39884
- _arr.push(_s.value);
39885
-
39886
- if (i && _arr.length === i) break;
39887
- }
39888
- } catch (err) {
39889
- _d = true;
39890
- _e = err;
39891
- } finally {
39892
- try {
39893
- if (!_n && _i["return"] != null) _i["return"]();
39894
- } finally {
39895
- if (_d) throw _e;
39896
- }
39897
- }
39898
-
39899
- return _arr;
39900
- }
39901
-
39902
- function _unsupportedIterableToArray(o, minLen) {
39903
- if (!o) return;
39904
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
39905
- var n = Object.prototype.toString.call(o).slice(8, -1);
39906
- if (n === "Object" && o.constructor) n = o.constructor.name;
39907
- if (n === "Map" || n === "Set") return Array.from(o);
39908
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
39909
- }
39910
-
39911
- function _arrayLikeToArray(arr, len) {
39912
- if (len == null || len > arr.length) len = arr.length;
39913
-
39914
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
39915
-
39916
- return arr2;
39917
- }
39918
-
39919
- function _nonIterableRest() {
39920
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
39921
- }
39922
-
39923
- function _defineProperty(obj, key, value) {
39924
- if (key in obj) {
39925
- Object.defineProperty(obj, key, {
39926
- value: value,
39927
- enumerable: true,
39928
- configurable: true,
39929
- writable: true
39930
- });
39931
- } else {
39932
- obj[key] = value;
39933
- }
39934
-
39935
- return obj;
39936
- }
39660
+ return obj;
39661
+ }
39937
39662
 
39938
39663
  function ownKeys(object, enumerableOnly) {
39939
39664
  var keys = Object.keys(object);
@@ -39999,7 +39724,7 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
39999
39724
  };
40000
39725
  }
40001
39726
 
40002
- function isObject$1(value) {
39727
+ function isObject$2(value) {
40003
39728
  return {}.toString.call(value).includes('Object');
40004
39729
  }
40005
39730
 
@@ -40016,7 +39741,7 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
40016
39741
  }
40017
39742
 
40018
39743
  function validateChanges(initial, changes) {
40019
- if (!isObject$1(changes)) errorHandler$1('changeType');
39744
+ if (!isObject$2(changes)) errorHandler$1('changeType');
40020
39745
  if (Object.keys(changes).some(function (field) {
40021
39746
  return !hasOwnProperty(initial, field);
40022
39747
  })) errorHandler$1('changeField');
@@ -40028,15 +39753,15 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
40028
39753
  }
40029
39754
 
40030
39755
  function validateHandler(handler) {
40031
- if (!(isFunction(handler) || isObject$1(handler))) errorHandler$1('handlerType');
40032
- if (isObject$1(handler) && Object.values(handler).some(function (_handler) {
39756
+ if (!(isFunction(handler) || isObject$2(handler))) errorHandler$1('handlerType');
39757
+ if (isObject$2(handler) && Object.values(handler).some(function (_handler) {
40033
39758
  return !isFunction(_handler);
40034
39759
  })) errorHandler$1('handlersType');
40035
39760
  }
40036
39761
 
40037
39762
  function validateInitial(initial) {
40038
39763
  if (!initial) errorHandler$1('initialIsRequired');
40039
- if (!isObject$1(initial)) errorHandler$1('initialType');
39764
+ if (!isObject$2(initial)) errorHandler$1('initialType');
40040
39765
  if (isEmpty$1(initial)) errorHandler$1('initialContent');
40041
39766
  }
40042
39767
 
@@ -40136,7 +39861,7 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
40136
39861
  };
40137
39862
  }
40138
39863
 
40139
- function isObject(value) {
39864
+ function isObject$1(value) {
40140
39865
  return {}.toString.call(value).includes('Object');
40141
39866
  }
40142
39867
 
@@ -40148,7 +39873,7 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
40148
39873
 
40149
39874
  function validateConfig(config) {
40150
39875
  if (!config) errorHandler('configIsRequired');
40151
- if (!isObject(config)) errorHandler('configType');
39876
+ if (!isObject$1(config)) errorHandler('configType');
40152
39877
 
40153
39878
  if (config.urls) {
40154
39879
  informAboutDeprecation();
@@ -47284,120 +47009,6 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
47284
47009
  }
47285
47010
 
47286
47011
  const BorderRadiusContainer$1 = styled.div`
47287
- height: 100%;
47288
- border: 1px solid ${({ $colorBorder }) => $colorBorder};
47289
- border-radius: 8px;
47290
- padding: 2px;
47291
-
47292
- .monaco-editor,
47293
- .overflow-guard {
47294
- border-radius: 8px;
47295
- }
47296
- `;
47297
- const Styled$k = {
47298
- BorderRadiusContainer: BorderRadiusContainer$1
47299
- };
47300
-
47301
- const YamlEditor = ({ theme, currentValues, onChange, editorUri }) => {
47302
- const { token } = antd.theme.useToken();
47303
- const [yamlData, setYamlData] = K.useState("");
47304
- const editorRef = K.useRef(null);
47305
- const monacoRef = K.useRef(null);
47306
- const isFocusedRef = K.useRef(false);
47307
- const pendingExternalYamlRef = K.useRef(null);
47308
- const isApplyingExternalUpdateRef = K.useRef(false);
47309
- K.useEffect(() => {
47310
- const next = stringify(currentValues, {
47311
- // Use literal block scalar for multiline strings
47312
- blockQuote: "literal",
47313
- // Preserve line breaks
47314
- lineWidth: 0,
47315
- // Use double quotes for strings that need escaping
47316
- doubleQuotedAsJSON: false
47317
- });
47318
- if (isFocusedRef.current) {
47319
- pendingExternalYamlRef.current = next ?? "";
47320
- return;
47321
- }
47322
- setYamlData(next ?? "");
47323
- }, [currentValues]);
47324
- K.useEffect(() => {
47325
- const editor = editorRef.current;
47326
- const monaco = monacoRef.current;
47327
- if (editor && monaco) {
47328
- if (isFocusedRef.current) return;
47329
- const uri = monaco.Uri.parse(editorUri);
47330
- let model = editor.getModel() || monaco.editor.getModel(uri);
47331
- if (!model) {
47332
- model = monaco.editor.createModel(yamlData ?? "", "yaml", uri);
47333
- }
47334
- if (model) {
47335
- monaco.editor.setModelLanguage(model, "yaml");
47336
- const current = model.getValue();
47337
- if ((yamlData ?? "") !== current) {
47338
- isApplyingExternalUpdateRef.current = true;
47339
- model.setValue(yamlData ?? "");
47340
- }
47341
- }
47342
- }
47343
- }, [yamlData, editorUri]);
47344
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$k.BorderRadiusContainer, { $colorBorder: token.colorBorder, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
47345
- Ft,
47346
- {
47347
- language: "yaml",
47348
- path: editorUri,
47349
- keepCurrentModel: true,
47350
- width: "100%",
47351
- height: "100%",
47352
- defaultValue: yamlData ?? "",
47353
- onMount: (editor, m) => {
47354
- editorRef.current = editor;
47355
- monacoRef.current = m;
47356
- try {
47357
- isFocusedRef.current = !!editor.hasTextFocus?.();
47358
- } catch {
47359
- isFocusedRef.current = false;
47360
- }
47361
- editor.onDidFocusEditorText(() => {
47362
- isFocusedRef.current = true;
47363
- });
47364
- editor.onDidBlurEditorText(() => {
47365
- isFocusedRef.current = false;
47366
- if (pendingExternalYamlRef.current !== null) {
47367
- setYamlData(pendingExternalYamlRef.current);
47368
- pendingExternalYamlRef.current = null;
47369
- }
47370
- });
47371
- const uri = m.Uri.parse("inmemory://openapi-ui/form.yaml");
47372
- let model = editor.getModel() || m.editor.getModel(uri);
47373
- if (!model) {
47374
- model = m.editor.createModel(yamlData ?? "", "yaml", uri);
47375
- }
47376
- if (model) {
47377
- m.editor.setModelLanguage(model, "yaml");
47378
- }
47379
- },
47380
- onChange: (value) => {
47381
- if (isApplyingExternalUpdateRef.current) {
47382
- isApplyingExternalUpdateRef.current = false;
47383
- setYamlData(value || "");
47384
- return;
47385
- }
47386
- try {
47387
- onChange(parse(value || ""));
47388
- } catch {
47389
- }
47390
- setYamlData(value || "");
47391
- },
47392
- theme: theme === "dark" ? "vs-dark" : theme === void 0 ? "vs-dark" : "vs",
47393
- options: {
47394
- theme: theme === "dark" ? "vs-dark" : theme === void 0 ? "vs-dark" : "vs"
47395
- }
47396
- }
47397
- ) });
47398
- };
47399
-
47400
- const BorderRadiusContainer = styled.div`
47401
47012
  height: ${({ $designNewLayoutHeight }) => $designNewLayoutHeight ? `${$designNewLayoutHeight}px` : "75vh"};
47402
47013
  border: 1px solid ${({ $colorBorder }) => $colorBorder};
47403
47014
  border-radius: 8px;
@@ -47421,12 +47032,13 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
47421
47032
  font-size: 16px;
47422
47033
  line-height: 24px;
47423
47034
  `;
47424
- const Styled$j = {
47425
- BorderRadiusContainer,
47035
+ const Styled$k = {
47036
+ BorderRadiusContainer: BorderRadiusContainer$1,
47426
47037
  ControlsRowContainer: ControlsRowContainer$1,
47427
47038
  BigText: BigText$1
47428
47039
  };
47429
47040
 
47041
+ const NOTIFICATION_KEY = "yaml-data-changed";
47430
47042
  const YamlEditorSingleton = ({
47431
47043
  theme,
47432
47044
  cluster,
@@ -47451,14 +47063,14 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
47451
47063
  const initialPrefillYamlRef = K.useRef(null);
47452
47064
  const latestPrefillYamlRef = K.useRef(null);
47453
47065
  const firstLoadRef = K.useRef(true);
47454
- const handleReload = () => {
47066
+ const handleReload = K.useCallback(() => {
47067
+ api.destroy(NOTIFICATION_KEY);
47455
47068
  const nextYaml = latestPrefillYamlRef.current ?? initialPrefillYamlRef.current;
47456
47069
  if (nextYaml !== null) {
47457
47070
  setYamlData(nextYaml);
47458
47071
  }
47459
- };
47072
+ }, [api]);
47460
47073
  const openNotificationYamlChanged = K.useCallback(() => {
47461
- const key = `open${Date.now()}`;
47462
47074
  const btn = /* @__PURE__ */ jsxRuntimeExports.jsx(
47463
47075
  antd.Button,
47464
47076
  {
@@ -47466,25 +47078,21 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
47466
47078
  size: "small",
47467
47079
  onClick: () => {
47468
47080
  handleReload();
47469
- api.destroy(key);
47470
47081
  },
47471
47082
  children: "Reload"
47472
47083
  }
47473
47084
  );
47474
47085
  api.info({
47086
+ key: NOTIFICATION_KEY,
47475
47087
  message: "Data changed",
47476
- description: "Reload will flush changes and reload data to latest",
47088
+ description: "The source data has been updated. Reload to apply the latest changes (will discard your edits).",
47477
47089
  btn,
47478
- key,
47479
- onClose: () => console.log("Notification closed"),
47480
47090
  placement: "bottomRight",
47481
47091
  duration: 30
47482
- // keep it open until user closes
47483
47092
  });
47484
- }, [api]);
47093
+ }, [api, handleReload]);
47485
47094
  K.useEffect(() => {
47486
47095
  if (prefillValuesSchema === void 0) return;
47487
- console.log(prefillValuesSchema);
47488
47096
  const nextYaml = stringify(prefillValuesSchema);
47489
47097
  if (firstLoadRef.current) {
47490
47098
  initialPrefillYamlRef.current = nextYaml;
@@ -47548,7 +47156,7 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
47548
47156
  };
47549
47157
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
47550
47158
  contextHolder,
47551
- /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$j.BorderRadiusContainer, { $designNewLayoutHeight: designNewLayoutHeight, $colorBorder: token.colorBorder, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
47159
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$k.BorderRadiusContainer, { $designNewLayoutHeight: designNewLayoutHeight, $colorBorder: token.colorBorder, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
47552
47160
  Ft,
47553
47161
  {
47554
47162
  defaultLanguage: "yaml",
@@ -47567,7 +47175,7 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
47567
47175
  }
47568
47176
  }
47569
47177
  ) }),
47570
- !readOnly && /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$j.ControlsRowContainer, { $bgColor: token.colorPrimaryBg, $designNewLayout: designNewLayout, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(antd.Flex, { gap: designNewLayout ? 10 : 16, align: "center", children: [
47178
+ !readOnly && /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$k.ControlsRowContainer, { $bgColor: token.colorPrimaryBg, $designNewLayout: designNewLayout, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(antd.Flex, { gap: designNewLayout ? 10 : 16, align: "center", children: [
47571
47179
  /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Button, { type: "primary", onClick: onSubmit, loading: isLoading, children: "Submit" }),
47572
47180
  backlink && /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Button, { onClick: () => navigate(backlink), children: "Cancel" }),
47573
47181
  /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Button, { onClick: handleReload, children: "Reload" })
@@ -47578,7 +47186,7 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
47578
47186
  open: !!error,
47579
47187
  onOk: () => setError(void 0),
47580
47188
  onCancel: () => setError(void 0),
47581
- title: /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Typography.Text, { type: "danger", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$j.BigText, { children: "Error!" }) }),
47189
+ title: /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Typography.Text, { type: "danger", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$k.BigText, { children: "Error!" }) }),
47582
47190
  cancelButtonProps: { style: { display: "none" } },
47583
47191
  children: [
47584
47192
  "An error has occurred: ",
@@ -47589,6 +47197,692 @@ if (_IS_WORKLET) registerPaint("spoiler", SpoilerPainterWorklet);
47589
47197
  ] });
47590
47198
  };
47591
47199
 
47200
+ /**
47201
+ * lodash (Custom Build) <https://lodash.com/>
47202
+ * Build: `lodash modularize exports="npm" -o ./`
47203
+ * Copyright jQuery Foundation and other contributors <https://jquery.org/>
47204
+ * Released under MIT license <https://lodash.com/license>
47205
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
47206
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
47207
+ */
47208
+
47209
+ /** Used as the `TypeError` message for "Functions" methods. */
47210
+ var FUNC_ERROR_TEXT = 'Expected a function';
47211
+
47212
+ /** Used as references for various `Number` constants. */
47213
+ var NAN = 0 / 0;
47214
+
47215
+ /** `Object#toString` result references. */
47216
+ var symbolTag = '[object Symbol]';
47217
+
47218
+ /** Used to match leading and trailing whitespace. */
47219
+ var reTrim = /^\s+|\s+$/g;
47220
+
47221
+ /** Used to detect bad signed hexadecimal string values. */
47222
+ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
47223
+
47224
+ /** Used to detect binary string values. */
47225
+ var reIsBinary = /^0b[01]+$/i;
47226
+
47227
+ /** Used to detect octal string values. */
47228
+ var reIsOctal = /^0o[0-7]+$/i;
47229
+
47230
+ /** Built-in method references without a dependency on `root`. */
47231
+ var freeParseInt = parseInt;
47232
+
47233
+ /** Detect free variable `global` from Node.js. */
47234
+ var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
47235
+
47236
+ /** Detect free variable `self`. */
47237
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
47238
+
47239
+ /** Used as a reference to the global object. */
47240
+ var root = freeGlobal || freeSelf || Function('return this')();
47241
+
47242
+ /** Used for built-in method references. */
47243
+ var objectProto = Object.prototype;
47244
+
47245
+ /**
47246
+ * Used to resolve the
47247
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
47248
+ * of values.
47249
+ */
47250
+ var objectToString = objectProto.toString;
47251
+
47252
+ /* Built-in method references for those with the same name as other `lodash` methods. */
47253
+ var nativeMax = Math.max,
47254
+ nativeMin = Math.min;
47255
+
47256
+ /**
47257
+ * Gets the timestamp of the number of milliseconds that have elapsed since
47258
+ * the Unix epoch (1 January 1970 00:00:00 UTC).
47259
+ *
47260
+ * @static
47261
+ * @memberOf _
47262
+ * @since 2.4.0
47263
+ * @category Date
47264
+ * @returns {number} Returns the timestamp.
47265
+ * @example
47266
+ *
47267
+ * _.defer(function(stamp) {
47268
+ * console.log(_.now() - stamp);
47269
+ * }, _.now());
47270
+ * // => Logs the number of milliseconds it took for the deferred invocation.
47271
+ */
47272
+ var now = function() {
47273
+ return root.Date.now();
47274
+ };
47275
+
47276
+ /**
47277
+ * Creates a debounced function that delays invoking `func` until after `wait`
47278
+ * milliseconds have elapsed since the last time the debounced function was
47279
+ * invoked. The debounced function comes with a `cancel` method to cancel
47280
+ * delayed `func` invocations and a `flush` method to immediately invoke them.
47281
+ * Provide `options` to indicate whether `func` should be invoked on the
47282
+ * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
47283
+ * with the last arguments provided to the debounced function. Subsequent
47284
+ * calls to the debounced function return the result of the last `func`
47285
+ * invocation.
47286
+ *
47287
+ * **Note:** If `leading` and `trailing` options are `true`, `func` is
47288
+ * invoked on the trailing edge of the timeout only if the debounced function
47289
+ * is invoked more than once during the `wait` timeout.
47290
+ *
47291
+ * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
47292
+ * until to the next tick, similar to `setTimeout` with a timeout of `0`.
47293
+ *
47294
+ * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
47295
+ * for details over the differences between `_.debounce` and `_.throttle`.
47296
+ *
47297
+ * @static
47298
+ * @memberOf _
47299
+ * @since 0.1.0
47300
+ * @category Function
47301
+ * @param {Function} func The function to debounce.
47302
+ * @param {number} [wait=0] The number of milliseconds to delay.
47303
+ * @param {Object} [options={}] The options object.
47304
+ * @param {boolean} [options.leading=false]
47305
+ * Specify invoking on the leading edge of the timeout.
47306
+ * @param {number} [options.maxWait]
47307
+ * The maximum time `func` is allowed to be delayed before it's invoked.
47308
+ * @param {boolean} [options.trailing=true]
47309
+ * Specify invoking on the trailing edge of the timeout.
47310
+ * @returns {Function} Returns the new debounced function.
47311
+ * @example
47312
+ *
47313
+ * // Avoid costly calculations while the window size is in flux.
47314
+ * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
47315
+ *
47316
+ * // Invoke `sendMail` when clicked, debouncing subsequent calls.
47317
+ * jQuery(element).on('click', _.debounce(sendMail, 300, {
47318
+ * 'leading': true,
47319
+ * 'trailing': false
47320
+ * }));
47321
+ *
47322
+ * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
47323
+ * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
47324
+ * var source = new EventSource('/stream');
47325
+ * jQuery(source).on('message', debounced);
47326
+ *
47327
+ * // Cancel the trailing debounced invocation.
47328
+ * jQuery(window).on('popstate', debounced.cancel);
47329
+ */
47330
+ function debounce(func, wait, options) {
47331
+ var lastArgs,
47332
+ lastThis,
47333
+ maxWait,
47334
+ result,
47335
+ timerId,
47336
+ lastCallTime,
47337
+ lastInvokeTime = 0,
47338
+ leading = false,
47339
+ maxing = false,
47340
+ trailing = true;
47341
+
47342
+ if (typeof func != 'function') {
47343
+ throw new TypeError(FUNC_ERROR_TEXT);
47344
+ }
47345
+ wait = toNumber(wait) || 0;
47346
+ if (isObject(options)) {
47347
+ leading = !!options.leading;
47348
+ maxing = 'maxWait' in options;
47349
+ maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
47350
+ trailing = 'trailing' in options ? !!options.trailing : trailing;
47351
+ }
47352
+
47353
+ function invokeFunc(time) {
47354
+ var args = lastArgs,
47355
+ thisArg = lastThis;
47356
+
47357
+ lastArgs = lastThis = undefined;
47358
+ lastInvokeTime = time;
47359
+ result = func.apply(thisArg, args);
47360
+ return result;
47361
+ }
47362
+
47363
+ function leadingEdge(time) {
47364
+ // Reset any `maxWait` timer.
47365
+ lastInvokeTime = time;
47366
+ // Start the timer for the trailing edge.
47367
+ timerId = setTimeout(timerExpired, wait);
47368
+ // Invoke the leading edge.
47369
+ return leading ? invokeFunc(time) : result;
47370
+ }
47371
+
47372
+ function remainingWait(time) {
47373
+ var timeSinceLastCall = time - lastCallTime,
47374
+ timeSinceLastInvoke = time - lastInvokeTime,
47375
+ result = wait - timeSinceLastCall;
47376
+
47377
+ return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
47378
+ }
47379
+
47380
+ function shouldInvoke(time) {
47381
+ var timeSinceLastCall = time - lastCallTime,
47382
+ timeSinceLastInvoke = time - lastInvokeTime;
47383
+
47384
+ // Either this is the first call, activity has stopped and we're at the
47385
+ // trailing edge, the system time has gone backwards and we're treating
47386
+ // it as the trailing edge, or we've hit the `maxWait` limit.
47387
+ return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
47388
+ (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
47389
+ }
47390
+
47391
+ function timerExpired() {
47392
+ var time = now();
47393
+ if (shouldInvoke(time)) {
47394
+ return trailingEdge(time);
47395
+ }
47396
+ // Restart the timer.
47397
+ timerId = setTimeout(timerExpired, remainingWait(time));
47398
+ }
47399
+
47400
+ function trailingEdge(time) {
47401
+ timerId = undefined;
47402
+
47403
+ // Only invoke if we have `lastArgs` which means `func` has been
47404
+ // debounced at least once.
47405
+ if (trailing && lastArgs) {
47406
+ return invokeFunc(time);
47407
+ }
47408
+ lastArgs = lastThis = undefined;
47409
+ return result;
47410
+ }
47411
+
47412
+ function cancel() {
47413
+ if (timerId !== undefined) {
47414
+ clearTimeout(timerId);
47415
+ }
47416
+ lastInvokeTime = 0;
47417
+ lastArgs = lastCallTime = lastThis = timerId = undefined;
47418
+ }
47419
+
47420
+ function flush() {
47421
+ return timerId === undefined ? result : trailingEdge(now());
47422
+ }
47423
+
47424
+ function debounced() {
47425
+ var time = now(),
47426
+ isInvoking = shouldInvoke(time);
47427
+
47428
+ lastArgs = arguments;
47429
+ lastThis = this;
47430
+ lastCallTime = time;
47431
+
47432
+ if (isInvoking) {
47433
+ if (timerId === undefined) {
47434
+ return leadingEdge(lastCallTime);
47435
+ }
47436
+ if (maxing) {
47437
+ // Handle invocations in a tight loop.
47438
+ timerId = setTimeout(timerExpired, wait);
47439
+ return invokeFunc(lastCallTime);
47440
+ }
47441
+ }
47442
+ if (timerId === undefined) {
47443
+ timerId = setTimeout(timerExpired, wait);
47444
+ }
47445
+ return result;
47446
+ }
47447
+ debounced.cancel = cancel;
47448
+ debounced.flush = flush;
47449
+ return debounced;
47450
+ }
47451
+
47452
+ /**
47453
+ * Checks if `value` is the
47454
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
47455
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
47456
+ *
47457
+ * @static
47458
+ * @memberOf _
47459
+ * @since 0.1.0
47460
+ * @category Lang
47461
+ * @param {*} value The value to check.
47462
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
47463
+ * @example
47464
+ *
47465
+ * _.isObject({});
47466
+ * // => true
47467
+ *
47468
+ * _.isObject([1, 2, 3]);
47469
+ * // => true
47470
+ *
47471
+ * _.isObject(_.noop);
47472
+ * // => true
47473
+ *
47474
+ * _.isObject(null);
47475
+ * // => false
47476
+ */
47477
+ function isObject(value) {
47478
+ var type = typeof value;
47479
+ return !!value && (type == 'object' || type == 'function');
47480
+ }
47481
+
47482
+ /**
47483
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
47484
+ * and has a `typeof` result of "object".
47485
+ *
47486
+ * @static
47487
+ * @memberOf _
47488
+ * @since 4.0.0
47489
+ * @category Lang
47490
+ * @param {*} value The value to check.
47491
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
47492
+ * @example
47493
+ *
47494
+ * _.isObjectLike({});
47495
+ * // => true
47496
+ *
47497
+ * _.isObjectLike([1, 2, 3]);
47498
+ * // => true
47499
+ *
47500
+ * _.isObjectLike(_.noop);
47501
+ * // => false
47502
+ *
47503
+ * _.isObjectLike(null);
47504
+ * // => false
47505
+ */
47506
+ function isObjectLike(value) {
47507
+ return !!value && typeof value == 'object';
47508
+ }
47509
+
47510
+ /**
47511
+ * Checks if `value` is classified as a `Symbol` primitive or object.
47512
+ *
47513
+ * @static
47514
+ * @memberOf _
47515
+ * @since 4.0.0
47516
+ * @category Lang
47517
+ * @param {*} value The value to check.
47518
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
47519
+ * @example
47520
+ *
47521
+ * _.isSymbol(Symbol.iterator);
47522
+ * // => true
47523
+ *
47524
+ * _.isSymbol('abc');
47525
+ * // => false
47526
+ */
47527
+ function isSymbol(value) {
47528
+ return typeof value == 'symbol' ||
47529
+ (isObjectLike(value) && objectToString.call(value) == symbolTag);
47530
+ }
47531
+
47532
+ /**
47533
+ * Converts `value` to a number.
47534
+ *
47535
+ * @static
47536
+ * @memberOf _
47537
+ * @since 4.0.0
47538
+ * @category Lang
47539
+ * @param {*} value The value to process.
47540
+ * @returns {number} Returns the number.
47541
+ * @example
47542
+ *
47543
+ * _.toNumber(3.2);
47544
+ * // => 3.2
47545
+ *
47546
+ * _.toNumber(Number.MIN_VALUE);
47547
+ * // => 5e-324
47548
+ *
47549
+ * _.toNumber(Infinity);
47550
+ * // => Infinity
47551
+ *
47552
+ * _.toNumber('3.2');
47553
+ * // => 3.2
47554
+ */
47555
+ function toNumber(value) {
47556
+ if (typeof value == 'number') {
47557
+ return value;
47558
+ }
47559
+ if (isSymbol(value)) {
47560
+ return NAN;
47561
+ }
47562
+ if (isObject(value)) {
47563
+ var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
47564
+ value = isObject(other) ? (other + '') : other;
47565
+ }
47566
+ if (typeof value != 'string') {
47567
+ return value === 0 ? value : +value;
47568
+ }
47569
+ value = value.replace(reTrim, '');
47570
+ var isBinary = reIsBinary.test(value);
47571
+ return (isBinary || reIsOctal.test(value))
47572
+ ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
47573
+ : (reIsBadHex.test(value) ? NAN : +value);
47574
+ }
47575
+
47576
+ var lodash_debounce = debounce;
47577
+
47578
+ const debounce$1 = /*@__PURE__*/getDefaultExportFromCjs(lodash_debounce);
47579
+
47580
+ function useUnmount(func) {
47581
+ const funcRef = K.useRef(func);
47582
+ funcRef.current = func;
47583
+ K.useEffect(
47584
+ () => () => {
47585
+ funcRef.current();
47586
+ },
47587
+ []
47588
+ );
47589
+ }
47590
+
47591
+ // src/useDebounceCallback/useDebounceCallback.ts
47592
+ function useDebounceCallback(func, delay = 500, options) {
47593
+ const debouncedFunc = K.useRef();
47594
+ useUnmount(() => {
47595
+ if (debouncedFunc.current) {
47596
+ debouncedFunc.current.cancel();
47597
+ }
47598
+ });
47599
+ const debounced = K.useMemo(() => {
47600
+ const debouncedFuncInstance = debounce$1(func, delay, options);
47601
+ const wrappedFunc = (...args) => {
47602
+ return debouncedFuncInstance(...args);
47603
+ };
47604
+ wrappedFunc.cancel = () => {
47605
+ debouncedFuncInstance.cancel();
47606
+ };
47607
+ wrappedFunc.isPending = () => {
47608
+ return !!debouncedFunc.current;
47609
+ };
47610
+ wrappedFunc.flush = () => {
47611
+ return debouncedFuncInstance.flush();
47612
+ };
47613
+ return wrappedFunc;
47614
+ }, [func, delay, options]);
47615
+ K.useEffect(() => {
47616
+ debouncedFunc.current = debounce$1(func, delay, options);
47617
+ }, [func, delay, options]);
47618
+ return debounced;
47619
+ }
47620
+
47621
+ function floorToDecimal(num, decimalPlaces) {
47622
+ const factor = 10 ** decimalPlaces;
47623
+ return Math.floor(num * factor) / factor;
47624
+ }
47625
+ const parseQuotaValue = (key, val) => {
47626
+ let numericValue = parseFloat(val.replace(/[a-zA-Zа-яА-Я]/g, ""));
47627
+ if (key === "cpu") {
47628
+ if (val.endsWith("m")) {
47629
+ numericValue /= 1e3;
47630
+ }
47631
+ return floorToDecimal(numericValue, 1);
47632
+ }
47633
+ if (val.endsWith("m")) {
47634
+ numericValue /= 1e3;
47635
+ } else if (val.endsWith("k")) {
47636
+ numericValue /= 1e6;
47637
+ } else if (val.endsWith("M")) {
47638
+ numericValue /= 1e3;
47639
+ } else if (val.endsWith("G")) {
47640
+ numericValue /= 1;
47641
+ } else if (val.endsWith("T")) {
47642
+ numericValue *= 1e3;
47643
+ } else if (val.endsWith("Ki")) {
47644
+ numericValue /= 1024;
47645
+ numericValue /= 1e6;
47646
+ } else if (val.endsWith("Mi")) {
47647
+ numericValue /= 1e3;
47648
+ numericValue /= 1e3;
47649
+ } else if (/^\d+(\.\d+)?$/.test(val)) {
47650
+ numericValue /= 1e9;
47651
+ } else {
47652
+ throw new Error("Invalid value");
47653
+ }
47654
+ return floorToDecimal(numericValue, 1);
47655
+ };
47656
+ const parseQuotaValueCpu = (val) => {
47657
+ if (typeof val === "string") {
47658
+ let numericValue = parseFloat(val.replace(/[a-zA-Zа-яА-Я]/g, ""));
47659
+ if (val.endsWith("m")) {
47660
+ numericValue /= 1e3;
47661
+ }
47662
+ return floorToDecimal(numericValue, 1);
47663
+ }
47664
+ return 0;
47665
+ };
47666
+ const parseQuotaValueMemoryAndStorage = (val) => {
47667
+ if (typeof val === "string") {
47668
+ let numericValue = parseFloat(val.replace(/[a-zA-Zа-яА-Я]/g, ""));
47669
+ if (val.endsWith("k")) {
47670
+ numericValue /= 1e6;
47671
+ } else if (val.endsWith("m")) {
47672
+ numericValue /= 1e3;
47673
+ } else if (val.endsWith("M")) {
47674
+ numericValue /= 1e3;
47675
+ } else if (val.endsWith("G")) {
47676
+ numericValue /= 1;
47677
+ } else if (val.endsWith("T")) {
47678
+ numericValue *= 1e3;
47679
+ } else if (val.endsWith("P")) {
47680
+ numericValue *= 1e6;
47681
+ } else if (val.endsWith("E")) {
47682
+ numericValue *= 1e9;
47683
+ } else if (val.endsWith("Ki")) {
47684
+ numericValue *= 1024 / 1e9;
47685
+ } else if (val.endsWith("Mi")) {
47686
+ numericValue /= 1048.576;
47687
+ } else if (val.endsWith("Gi")) {
47688
+ numericValue *= 1.073741824;
47689
+ } else if (val.endsWith("Ti")) {
47690
+ numericValue *= 1.099511628;
47691
+ } else if (val.endsWith("Pi")) {
47692
+ numericValue *= 1.125899907;
47693
+ } else if (val.endsWith("Ei")) {
47694
+ numericValue *= 1.152921505;
47695
+ } else if (val === "0") {
47696
+ return 0;
47697
+ } else {
47698
+ throw new Error("Invalid value");
47699
+ }
47700
+ return floorToDecimal(numericValue, 1);
47701
+ }
47702
+ return 0;
47703
+ };
47704
+
47705
+ const findAllPathsForObject = (obj, targetKey, targetValue, currentPath = []) => {
47706
+ let paths = [];
47707
+ if (typeof obj !== "object" || obj === null) {
47708
+ return paths;
47709
+ }
47710
+ if (obj[targetKey] === targetValue) {
47711
+ paths.push([...currentPath]);
47712
+ }
47713
+ for (const key in obj) {
47714
+ if (obj.hasOwnProperty(key)) {
47715
+ const value = obj[key];
47716
+ if (typeof value === "object" && value !== null) {
47717
+ const newPath = [...currentPath, key];
47718
+ const subPaths = findAllPathsForObject(value, targetKey, targetValue, newPath);
47719
+ paths = paths.concat(subPaths);
47720
+ }
47721
+ }
47722
+ }
47723
+ return paths;
47724
+ };
47725
+ const normalizeValuesForQuotasToNumber = (object, properties) => {
47726
+ const newObject = _$1.cloneDeep(object);
47727
+ const cpuPaths = findAllPathsForObject(properties, "type", "rangeInputCpu");
47728
+ const memoryPaths = findAllPathsForObject(properties, "type", "rangeInputMemory");
47729
+ memoryPaths.forEach((path) => {
47730
+ const cleanPath = path.filter((el) => typeof el === "string").filter((el) => el !== "properties");
47731
+ const value = _$1.get(newObject, cleanPath);
47732
+ if (value || value === 0) {
47733
+ _$1.set(newObject, cleanPath, parseQuotaValueMemoryAndStorage(value));
47734
+ }
47735
+ });
47736
+ cpuPaths.forEach((path) => {
47737
+ const cleanPath = path.filter((el) => typeof el === "string").filter((el) => el !== "properties");
47738
+ const value = _$1.get(newObject, cleanPath);
47739
+ if (value || value === 0) {
47740
+ _$1.set(newObject, cleanPath, parseQuotaValueCpu(value));
47741
+ }
47742
+ });
47743
+ return newObject;
47744
+ };
47745
+
47746
+ const getAllPathsFromObj = (obj, prefix = []) => {
47747
+ const entries = Array.isArray(obj) ? obj.map((value, index) => [index, value]) : Object.entries(obj);
47748
+ return entries.flatMap(([key, value]) => {
47749
+ const currentPath = [...prefix, key];
47750
+ return typeof value === "object" && value !== null ? [currentPath, ...getAllPathsFromObj(value, currentPath)] : [currentPath];
47751
+ });
47752
+ };
47753
+
47754
+ const getPrefixSubarrays = (arr) => {
47755
+ return arr.map((_, index) => arr.slice(0, index + 1));
47756
+ };
47757
+
47758
+ const deepMerge = (a, b) => {
47759
+ const result = { ...a };
47760
+ for (const key of Object.keys(b)) {
47761
+ const aVal = a[key];
47762
+ const bVal = b[key];
47763
+ if (aVal !== null && bVal !== null && typeof aVal === "object" && typeof bVal === "object" && !Array.isArray(aVal) && !Array.isArray(bVal)) {
47764
+ result[key] = deepMerge(aVal, bVal);
47765
+ } else {
47766
+ result[key] = bVal;
47767
+ }
47768
+ }
47769
+ return result;
47770
+ };
47771
+
47772
+ const BorderRadiusContainer = styled.div`
47773
+ height: 100%;
47774
+ border: 1px solid ${({ $colorBorder }) => $colorBorder};
47775
+ border-radius: 8px;
47776
+ padding: 2px;
47777
+
47778
+ .monaco-editor,
47779
+ .overflow-guard {
47780
+ border-radius: 8px;
47781
+ }
47782
+ `;
47783
+ const Styled$j = {
47784
+ BorderRadiusContainer
47785
+ };
47786
+
47787
+ const YamlEditor = ({ theme, currentValues, onChange, editorUri }) => {
47788
+ const { token } = antd.theme.useToken();
47789
+ const [yamlData, setYamlData] = K.useState("");
47790
+ const editorRef = K.useRef(null);
47791
+ const monacoRef = K.useRef(null);
47792
+ const isFocusedRef = K.useRef(false);
47793
+ const pendingExternalYamlRef = K.useRef(null);
47794
+ const isApplyingExternalUpdateRef = K.useRef(false);
47795
+ K.useEffect(() => {
47796
+ const next = stringify(currentValues, {
47797
+ // Use literal block scalar for multiline strings
47798
+ blockQuote: "literal",
47799
+ // Preserve line breaks
47800
+ lineWidth: 0,
47801
+ // Use double quotes for strings that need escaping
47802
+ doubleQuotedAsJSON: false
47803
+ });
47804
+ if (isFocusedRef.current) {
47805
+ pendingExternalYamlRef.current = next ?? "";
47806
+ return;
47807
+ }
47808
+ setYamlData(next ?? "");
47809
+ }, [currentValues]);
47810
+ K.useEffect(() => {
47811
+ const editor = editorRef.current;
47812
+ const monaco = monacoRef.current;
47813
+ if (editor && monaco) {
47814
+ if (isFocusedRef.current) return;
47815
+ const uri = monaco.Uri.parse(editorUri);
47816
+ let model = editor.getModel() || monaco.editor.getModel(uri);
47817
+ if (!model) {
47818
+ model = monaco.editor.createModel(yamlData ?? "", "yaml", uri);
47819
+ }
47820
+ if (model) {
47821
+ monaco.editor.setModelLanguage(model, "yaml");
47822
+ const current = model.getValue();
47823
+ if ((yamlData ?? "") !== current) {
47824
+ isApplyingExternalUpdateRef.current = true;
47825
+ model.setValue(yamlData ?? "");
47826
+ }
47827
+ }
47828
+ }
47829
+ }, [yamlData, editorUri]);
47830
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$j.BorderRadiusContainer, { $colorBorder: token.colorBorder, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
47831
+ Ft,
47832
+ {
47833
+ language: "yaml",
47834
+ path: editorUri,
47835
+ keepCurrentModel: true,
47836
+ width: "100%",
47837
+ height: "100%",
47838
+ defaultValue: yamlData ?? "",
47839
+ onMount: (editor, m) => {
47840
+ editorRef.current = editor;
47841
+ monacoRef.current = m;
47842
+ try {
47843
+ isFocusedRef.current = !!editor.hasTextFocus?.();
47844
+ } catch {
47845
+ isFocusedRef.current = false;
47846
+ }
47847
+ editor.onDidFocusEditorText(() => {
47848
+ isFocusedRef.current = true;
47849
+ });
47850
+ editor.onDidBlurEditorText(() => {
47851
+ isFocusedRef.current = false;
47852
+ if (pendingExternalYamlRef.current !== null) {
47853
+ setYamlData(pendingExternalYamlRef.current);
47854
+ pendingExternalYamlRef.current = null;
47855
+ }
47856
+ });
47857
+ const uri = m.Uri.parse("inmemory://openapi-ui/form.yaml");
47858
+ let model = editor.getModel() || m.editor.getModel(uri);
47859
+ if (!model) {
47860
+ model = m.editor.createModel(yamlData ?? "", "yaml", uri);
47861
+ }
47862
+ if (model) {
47863
+ m.editor.setModelLanguage(model, "yaml");
47864
+ }
47865
+ },
47866
+ onChange: (value) => {
47867
+ if (isApplyingExternalUpdateRef.current) {
47868
+ isApplyingExternalUpdateRef.current = false;
47869
+ setYamlData(value || "");
47870
+ return;
47871
+ }
47872
+ try {
47873
+ onChange(parse(value || ""));
47874
+ } catch {
47875
+ }
47876
+ setYamlData(value || "");
47877
+ },
47878
+ theme: theme === "dark" ? "vs-dark" : theme === void 0 ? "vs-dark" : "vs",
47879
+ options: {
47880
+ theme: theme === "dark" ? "vs-dark" : theme === void 0 ? "vs-dark" : "vs"
47881
+ }
47882
+ }
47883
+ ) });
47884
+ };
47885
+
47592
47886
  const getStringByName = (name) => {
47593
47887
  if (typeof name === "string") {
47594
47888
  return name;