@payloadcms/ui 3.56.0-internal.299316b → 3.56.0-internal.457de85

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.
@@ -1 +1 @@
1
- {"version":3,"file":"getTextFieldsToBeSearched.d.ts","sourceRoot":"","sources":["../../../src/elements/ListControls/getTextFieldsToBeSearched.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAI1C,eAAO,MAAM,yBAAyB,yBACd,MAAM,EAAE,UACtB,WAAW,EAAE,QACf,UAAU,KACf,WAAW,EAab,CAAA"}
1
+ {"version":3,"file":"getTextFieldsToBeSearched.d.ts","sourceRoot":"","sources":["../../../src/elements/ListControls/getTextFieldsToBeSearched.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAI1C,eAAO,MAAM,yBAAyB,yBACd,MAAM,EAAE,UACtB,WAAW,EAAE,QACf,UAAU,KACf,WAAW,EAqBb,CAAA"}
@@ -7,7 +7,15 @@ export const getTextFieldsToBeSearched = (listSearchableFields, fields, i18n) =>
7
7
  i18n,
8
8
  moveSubFieldsToTop: true
9
9
  });
10
- return flattenedFields.filter(field => fieldAffectsData(field) && listSearchableFields.includes(field.name));
10
+ const searchableFieldNames = new Set(listSearchableFields);
11
+ const matchingFields = [];
12
+ for (const field of flattenedFields) {
13
+ if (fieldAffectsData(field) && searchableFieldNames.has(field.name)) {
14
+ matchingFields.push(field);
15
+ searchableFieldNames.delete(field.name);
16
+ }
17
+ }
18
+ return matchingFields;
11
19
  }
12
20
  return null;
13
21
  };
@@ -1 +1 @@
1
- {"version":3,"file":"getTextFieldsToBeSearched.js","names":["fieldAffectsData","flattenTopLevelFields","getTextFieldsToBeSearched","listSearchableFields","fields","i18n","flattenedFields","moveSubFieldsToTop","filter","field","includes","name"],"sources":["../../../src/elements/ListControls/getTextFieldsToBeSearched.ts"],"sourcesContent":["'use client'\nimport type { I18nClient } from '@payloadcms/translations'\nimport type { ClientField } from 'payload'\n\nimport { fieldAffectsData, flattenTopLevelFields } from 'payload/shared'\n\nexport const getTextFieldsToBeSearched = (\n listSearchableFields: string[],\n fields: ClientField[],\n i18n: I18nClient,\n): ClientField[] => {\n if (listSearchableFields) {\n const flattenedFields = flattenTopLevelFields(fields, {\n i18n,\n moveSubFieldsToTop: true,\n }) as ClientField[]\n\n return flattenedFields.filter(\n (field) => fieldAffectsData(field) && listSearchableFields.includes(field.name),\n )\n }\n\n return null\n}\n"],"mappings":"AAAA;;AAIA,SAASA,gBAAgB,EAAEC,qBAAqB,QAAQ;AAExD,OAAO,MAAMC,yBAAA,GAA4BA,CACvCC,oBAAA,EACAC,MAAA,EACAC,IAAA;EAEA,IAAIF,oBAAA,EAAsB;IACxB,MAAMG,eAAA,GAAkBL,qBAAA,CAAsBG,MAAA,EAAQ;MACpDC,IAAA;MACAE,kBAAA,EAAoB;IACtB;IAEA,OAAOD,eAAA,CAAgBE,MAAM,CAC1BC,KAAA,IAAUT,gBAAA,CAAiBS,KAAA,KAAUN,oBAAA,CAAqBO,QAAQ,CAACD,KAAA,CAAME,IAAI;EAElF;EAEA,OAAO;AACT","ignoreList":[]}
1
+ {"version":3,"file":"getTextFieldsToBeSearched.js","names":["fieldAffectsData","flattenTopLevelFields","getTextFieldsToBeSearched","listSearchableFields","fields","i18n","flattenedFields","moveSubFieldsToTop","searchableFieldNames","Set","matchingFields","field","has","name","push","delete"],"sources":["../../../src/elements/ListControls/getTextFieldsToBeSearched.ts"],"sourcesContent":["'use client'\nimport type { I18nClient } from '@payloadcms/translations'\nimport type { ClientField } from 'payload'\n\nimport { fieldAffectsData, flattenTopLevelFields } from 'payload/shared'\n\nexport const getTextFieldsToBeSearched = (\n listSearchableFields: string[],\n fields: ClientField[],\n i18n: I18nClient,\n): ClientField[] => {\n if (listSearchableFields) {\n const flattenedFields = flattenTopLevelFields(fields, {\n i18n,\n moveSubFieldsToTop: true,\n }) as ClientField[]\n\n const searchableFieldNames = new Set(listSearchableFields)\n const matchingFields: typeof flattenedFields = []\n\n for (const field of flattenedFields) {\n if (fieldAffectsData(field) && searchableFieldNames.has(field.name)) {\n matchingFields.push(field)\n searchableFieldNames.delete(field.name)\n }\n }\n\n return matchingFields\n }\n\n return null\n}\n"],"mappings":"AAAA;;AAIA,SAASA,gBAAgB,EAAEC,qBAAqB,QAAQ;AAExD,OAAO,MAAMC,yBAAA,GAA4BA,CACvCC,oBAAA,EACAC,MAAA,EACAC,IAAA;EAEA,IAAIF,oBAAA,EAAsB;IACxB,MAAMG,eAAA,GAAkBL,qBAAA,CAAsBG,MAAA,EAAQ;MACpDC,IAAA;MACAE,kBAAA,EAAoB;IACtB;IAEA,MAAMC,oBAAA,GAAuB,IAAIC,GAAA,CAAIN,oBAAA;IACrC,MAAMO,cAAA,GAAyC,EAAE;IAEjD,KAAK,MAAMC,KAAA,IAASL,eAAA,EAAiB;MACnC,IAAIN,gBAAA,CAAiBW,KAAA,KAAUH,oBAAA,CAAqBI,GAAG,CAACD,KAAA,CAAME,IAAI,GAAG;QACnEH,cAAA,CAAeI,IAAI,CAACH,KAAA;QACpBH,oBAAA,CAAqBO,MAAM,CAACJ,KAAA,CAAME,IAAI;MACxC;IACF;IAEA,OAAOH,cAAA;EACT;EAEA,OAAO;AACT","ignoreList":[]}
@@ -3,7 +3,7 @@ import type { AddCondition, ReducedField, RemoveCondition, UpdateCondition, Valu
3
3
  export type Props = {
4
4
  readonly addCondition: AddCondition;
5
5
  readonly andIndex: number;
6
- readonly fieldName: string;
6
+ readonly fieldPath: string;
7
7
  readonly filterOptions: ResolvedFilterOptions;
8
8
  readonly operator: Operator;
9
9
  readonly orIndex: number;
@@ -15,7 +15,7 @@ export const Condition = props => {
15
15
  const {
16
16
  addCondition,
17
17
  andIndex,
18
- fieldName,
18
+ fieldPath,
19
19
  filterOptions,
20
20
  operator,
21
21
  orIndex,
@@ -28,7 +28,7 @@ export const Condition = props => {
28
28
  const {
29
29
  t
30
30
  } = useTranslation();
31
- const reducedField = reducedFields.find(field => field.value === fieldName);
31
+ const reducedField = reducedFields.find(field => field.value === fieldPath);
32
32
  const [internalValue, setInternalValue] = useState(value);
33
33
  const debouncedValue = useDebounce(internalValue, 300);
34
34
  const booleanSelect = ['exists'].includes(operator) || reducedField?.field?.type === 'checkbox';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["React","useCallback","useEffect","useState","useDebounce","useEffectEvent","useTranslation","Button","ReactSelect","DefaultFilter","getOperatorValueTypes","baseClass","Condition","props","addCondition","andIndex","fieldName","filterOptions","operator","orIndex","reducedFields","removeCondition","RenderedFilter","updateCondition","value","t","reducedField","find","field","internalValue","setInternalValue","debouncedValue","booleanSelect","includes","type","valueOptions","label","options","updateValue","disabled","admin","disableListFilter","handleFieldChange","undefined","option","handleOperatorChange","operatorValueTypes","validOperatorValue","isValidValue","_jsx","className","_jsxs","filterOption","inputValue","data","plainTextLabel","toLowerCase","isClearable","onChange","filter","operators","o","internalField","buttonStyle","icon","iconStyle","onClick","round","relation"],"sources":["../../../../src/elements/WhereBuilder/Condition/index.tsx"],"sourcesContent":["'use client'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type {\n AddCondition,\n ReducedField,\n RemoveCondition,\n UpdateCondition,\n Value,\n} from '../types.js'\n\nexport type Props = {\n readonly addCondition: AddCondition\n readonly andIndex: number\n readonly fieldName: string\n readonly filterOptions: ResolvedFilterOptions\n readonly operator: Operator\n readonly orIndex: number\n readonly reducedFields: ReducedField[]\n readonly removeCondition: RemoveCondition\n readonly RenderedFilter: React.ReactNode\n readonly updateCondition: UpdateCondition\n readonly value: Value\n}\n\nimport type { Operator, Option as PayloadOption, ResolvedFilterOptions } from 'payload'\n\nimport type { Option } from '../../ReactSelect/index.js'\n\nimport { useDebounce } from '../../../hooks/useDebounce.js'\nimport { useEffectEvent } from '../../../hooks/useEffectEvent.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { Button } from '../../Button/index.js'\nimport { ReactSelect } from '../../ReactSelect/index.js'\nimport { DefaultFilter } from './DefaultFilter/index.js'\nimport { getOperatorValueTypes } from './validOperators.js'\nimport './index.scss'\n\nconst baseClass = 'condition'\n\nexport const Condition: React.FC<Props> = (props) => {\n const {\n addCondition,\n andIndex,\n fieldName,\n filterOptions,\n operator,\n orIndex,\n reducedFields,\n removeCondition,\n RenderedFilter,\n updateCondition,\n value,\n } = props\n\n const { t } = useTranslation()\n\n const reducedField = reducedFields.find((field) => field.value === fieldName)\n\n const [internalValue, setInternalValue] = useState<Value>(value)\n\n const debouncedValue = useDebounce(internalValue, 300)\n\n const booleanSelect = ['exists'].includes(operator) || reducedField?.field?.type === 'checkbox'\n\n let valueOptions: PayloadOption[] = []\n\n if (booleanSelect) {\n valueOptions = [\n { label: t('general:true'), value: 'true' },\n { label: t('general:false'), value: 'false' },\n ]\n } else if (reducedField?.field && 'options' in reducedField.field) {\n valueOptions = reducedField.field.options\n }\n\n const updateValue = useEffectEvent(async (debouncedValue) => {\n if (operator) {\n await updateCondition({\n andIndex,\n field: reducedField,\n operator,\n orIndex,\n value: debouncedValue === null ? '' : debouncedValue,\n })\n }\n })\n\n useEffect(() => {\n void updateValue(debouncedValue)\n }, [debouncedValue])\n\n const disabled =\n (!reducedField?.value && typeof reducedField?.value !== 'number') ||\n reducedField?.field?.admin?.disableListFilter\n\n const handleFieldChange = useCallback(\n async (field: Option<string>) => {\n setInternalValue(undefined)\n await updateCondition({\n andIndex,\n field: reducedFields.find((option) => option.value === field.value),\n operator,\n orIndex,\n value: undefined,\n })\n },\n [andIndex, operator, orIndex, reducedFields, updateCondition],\n )\n\n const handleOperatorChange = useCallback(\n async (operator: Option<Operator>) => {\n const operatorValueTypes = getOperatorValueTypes(reducedField.field.type)\n const validOperatorValue = operatorValueTypes[operator.value] || 'any'\n const isValidValue =\n validOperatorValue === 'any' ||\n typeof value === validOperatorValue ||\n (validOperatorValue === 'boolean' && (value === 'true' || value === 'false'))\n\n if (!isValidValue) {\n // if the current value is not valid for the new operator\n // reset the value before passing it to updateCondition\n setInternalValue(undefined)\n }\n\n await updateCondition({\n andIndex,\n field: reducedField,\n operator: operator.value,\n orIndex,\n value: isValidValue ? value : undefined,\n })\n },\n [andIndex, reducedField, orIndex, updateCondition, value],\n )\n\n return (\n <div className={baseClass}>\n <div className={`${baseClass}__wrap`}>\n <div className={`${baseClass}__inputs`}>\n <div className={`${baseClass}__field`}>\n <ReactSelect\n disabled={disabled}\n filterOption={(option, inputValue) =>\n ((option?.data?.plainTextLabel as string) || option.label)\n .toLowerCase()\n .includes(inputValue.toLowerCase())\n }\n isClearable={false}\n onChange={handleFieldChange}\n options={reducedFields.filter((field) => !field.field.admin.disableListFilter)}\n value={\n reducedField || {\n value: reducedField?.value,\n }\n }\n />\n </div>\n <div className={`${baseClass}__operator`}>\n <ReactSelect\n disabled={disabled}\n isClearable={false}\n onChange={handleOperatorChange}\n options={reducedField?.operators}\n value={reducedField?.operators.find((o) => operator === o.value) || null}\n />\n </div>\n <div className={`${baseClass}__value`}>\n {RenderedFilter || (\n <DefaultFilter\n booleanSelect={booleanSelect}\n disabled={\n !operator || !reducedField || reducedField?.field?.admin?.disableListFilter\n }\n filterOptions={filterOptions}\n internalField={reducedField}\n onChange={setInternalValue}\n operator={operator}\n options={valueOptions}\n value={internalValue ?? ''}\n />\n )}\n </div>\n </div>\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__actions-remove`}\n icon=\"x\"\n iconStyle=\"with-border\"\n onClick={() =>\n removeCondition({\n andIndex,\n orIndex,\n })\n }\n round\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__actions-add`}\n icon=\"plus\"\n iconStyle=\"with-border\"\n onClick={() =>\n addCondition({\n andIndex: andIndex + 1,\n field: reducedFields.find((field) => !field.field.admin?.disableListFilter),\n orIndex,\n relation: 'and',\n })\n }\n round\n />\n </div>\n </div>\n </div>\n )\n}\n"],"mappings":"AAAA;;;AACA,OAAOA,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ;AA4BxD,SAASC,WAAW,QAAQ;AAC5B,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,MAAM,QAAQ;AACvB,SAASC,WAAW,QAAQ;AAC5B,SAASC,aAAa,QAAQ;AAC9B,SAASC,qBAAqB,QAAQ;AACtC,OAAO;AAEP,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,SAAA,GAA8BC,KAAA;EACzC,MAAM;IACJC,YAAY;IACZC,QAAQ;IACRC,SAAS;IACTC,aAAa;IACbC,QAAQ;IACRC,OAAO;IACPC,aAAa;IACbC,eAAe;IACfC,cAAc;IACdC,eAAe;IACfC;EAAK,CACN,GAAGX,KAAA;EAEJ,MAAM;IAAEY;EAAC,CAAE,GAAGnB,cAAA;EAEd,MAAMoB,YAAA,GAAeN,aAAA,CAAcO,IAAI,CAAEC,KAAA,IAAUA,KAAA,CAAMJ,KAAK,KAAKR,SAAA;EAEnE,MAAM,CAACa,aAAA,EAAeC,gBAAA,CAAiB,GAAG3B,QAAA,CAAgBqB,KAAA;EAE1D,MAAMO,cAAA,GAAiB3B,WAAA,CAAYyB,aAAA,EAAe;EAElD,MAAMG,aAAA,GAAgB,CAAC,SAAS,CAACC,QAAQ,CAACf,QAAA,KAAaQ,YAAA,EAAcE,KAAA,EAAOM,IAAA,KAAS;EAErF,IAAIC,YAAA,GAAgC,EAAE;EAEtC,IAAIH,aAAA,EAAe;IACjBG,YAAA,GAAe,CACb;MAAEC,KAAA,EAAOX,CAAA,CAAE;MAAiBD,KAAA,EAAO;IAAO,GAC1C;MAAEY,KAAA,EAAOX,CAAA,CAAE;MAAkBD,KAAA,EAAO;IAAQ,EAC7C;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AAA;YACAiD,QAAA,EAAU;UACZ;UAEFD,KAAK;;;;;AAMjB","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["React","useCallback","useEffect","useState","useDebounce","useEffectEvent","useTranslation","Button","ReactSelect","DefaultFilter","getOperatorValueTypes","baseClass","Condition","props","addCondition","andIndex","fieldPath","filterOptions","operator","orIndex","reducedFields","removeCondition","RenderedFilter","updateCondition","value","t","reducedField","find","field","internalValue","setInternalValue","debouncedValue","booleanSelect","includes","type","valueOptions","label","options","updateValue","disabled","admin","disableListFilter","handleFieldChange","undefined","option","handleOperatorChange","operatorValueTypes","validOperatorValue","isValidValue","_jsx","className","_jsxs","filterOption","inputValue","data","plainTextLabel","toLowerCase","isClearable","onChange","filter","operators","o","internalField","buttonStyle","icon","iconStyle","onClick","round","relation"],"sources":["../../../../src/elements/WhereBuilder/Condition/index.tsx"],"sourcesContent":["'use client'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type {\n AddCondition,\n ReducedField,\n RemoveCondition,\n UpdateCondition,\n Value,\n} from '../types.js'\n\nexport type Props = {\n readonly addCondition: AddCondition\n readonly andIndex: number\n readonly fieldPath: string\n readonly filterOptions: ResolvedFilterOptions\n readonly operator: Operator\n readonly orIndex: number\n readonly reducedFields: ReducedField[]\n readonly removeCondition: RemoveCondition\n readonly RenderedFilter: React.ReactNode\n readonly updateCondition: UpdateCondition\n readonly value: Value\n}\n\nimport type { Operator, Option as PayloadOption, ResolvedFilterOptions } from 'payload'\n\nimport type { Option } from '../../ReactSelect/index.js'\n\nimport { useDebounce } from '../../../hooks/useDebounce.js'\nimport { useEffectEvent } from '../../../hooks/useEffectEvent.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { Button } from '../../Button/index.js'\nimport { ReactSelect } from '../../ReactSelect/index.js'\nimport { DefaultFilter } from './DefaultFilter/index.js'\nimport { getOperatorValueTypes } from './validOperators.js'\nimport './index.scss'\n\nconst baseClass = 'condition'\n\nexport const Condition: React.FC<Props> = (props) => {\n const {\n addCondition,\n andIndex,\n fieldPath,\n filterOptions,\n operator,\n orIndex,\n reducedFields,\n removeCondition,\n RenderedFilter,\n updateCondition,\n value,\n } = props\n\n const { t } = useTranslation()\n\n const reducedField = reducedFields.find((field) => field.value === fieldPath)\n\n const [internalValue, setInternalValue] = useState<Value>(value)\n\n const debouncedValue = useDebounce(internalValue, 300)\n\n const booleanSelect = ['exists'].includes(operator) || reducedField?.field?.type === 'checkbox'\n\n let valueOptions: PayloadOption[] = []\n\n if (booleanSelect) {\n valueOptions = [\n { label: t('general:true'), value: 'true' },\n { label: t('general:false'), value: 'false' },\n ]\n } else if (reducedField?.field && 'options' in reducedField.field) {\n valueOptions = reducedField.field.options\n }\n\n const updateValue = useEffectEvent(async (debouncedValue) => {\n if (operator) {\n await updateCondition({\n andIndex,\n field: reducedField,\n operator,\n orIndex,\n value: debouncedValue === null ? '' : debouncedValue,\n })\n }\n })\n\n useEffect(() => {\n void updateValue(debouncedValue)\n }, [debouncedValue])\n\n const disabled =\n (!reducedField?.value && typeof reducedField?.value !== 'number') ||\n reducedField?.field?.admin?.disableListFilter\n\n const handleFieldChange = useCallback(\n async (field: Option<string>) => {\n setInternalValue(undefined)\n await updateCondition({\n andIndex,\n field: reducedFields.find((option) => option.value === field.value),\n operator,\n orIndex,\n value: undefined,\n })\n },\n [andIndex, operator, orIndex, reducedFields, updateCondition],\n )\n\n const handleOperatorChange = useCallback(\n async (operator: Option<Operator>) => {\n const operatorValueTypes = getOperatorValueTypes(reducedField.field.type)\n const validOperatorValue = operatorValueTypes[operator.value] || 'any'\n const isValidValue =\n validOperatorValue === 'any' ||\n typeof value === validOperatorValue ||\n (validOperatorValue === 'boolean' && (value === 'true' || value === 'false'))\n\n if (!isValidValue) {\n // if the current value is not valid for the new operator\n // reset the value before passing it to updateCondition\n setInternalValue(undefined)\n }\n\n await updateCondition({\n andIndex,\n field: reducedField,\n operator: operator.value,\n orIndex,\n value: isValidValue ? value : undefined,\n })\n },\n [andIndex, reducedField, orIndex, updateCondition, value],\n )\n\n return (\n <div className={baseClass}>\n <div className={`${baseClass}__wrap`}>\n <div className={`${baseClass}__inputs`}>\n <div className={`${baseClass}__field`}>\n <ReactSelect\n disabled={disabled}\n filterOption={(option, inputValue) =>\n ((option?.data?.plainTextLabel as string) || option.label)\n .toLowerCase()\n .includes(inputValue.toLowerCase())\n }\n isClearable={false}\n onChange={handleFieldChange}\n options={reducedFields.filter((field) => !field.field.admin.disableListFilter)}\n value={\n reducedField || {\n value: reducedField?.value,\n }\n }\n />\n </div>\n <div className={`${baseClass}__operator`}>\n <ReactSelect\n disabled={disabled}\n isClearable={false}\n onChange={handleOperatorChange}\n options={reducedField?.operators}\n value={reducedField?.operators.find((o) => operator === o.value) || null}\n />\n </div>\n <div className={`${baseClass}__value`}>\n {RenderedFilter || (\n <DefaultFilter\n booleanSelect={booleanSelect}\n disabled={\n !operator || !reducedField || reducedField?.field?.admin?.disableListFilter\n }\n filterOptions={filterOptions}\n internalField={reducedField}\n onChange={setInternalValue}\n operator={operator}\n options={valueOptions}\n value={internalValue ?? ''}\n />\n )}\n </div>\n </div>\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__actions-remove`}\n icon=\"x\"\n iconStyle=\"with-border\"\n onClick={() =>\n removeCondition({\n andIndex,\n orIndex,\n })\n }\n round\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__actions-add`}\n icon=\"plus\"\n iconStyle=\"with-border\"\n onClick={() =>\n addCondition({\n andIndex: andIndex + 1,\n field: reducedFields.find((field) => !field.field.admin?.disableListFilter),\n orIndex,\n relation: 'and',\n })\n }\n round\n />\n </div>\n </div>\n </div>\n )\n}\n"],"mappings":"AAAA;;;AACA,OAAOA,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ;AA4BxD,SAASC,WAAW,QAAQ;AAC5B,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B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AAA,SAAkB;oBAClCW,cAAA,iBACC2B,IAAA,CAACxC,aAAA;YACCuB,aAAA,EAAeA,aAAA;YACfO,QAAA,EACE,CAACrB,QAAA,IAAY,CAACQ,YAAA,IAAgBA,YAAA,EAAcE,KAAA,EAAOY,KAAA,EAAOC,iBAAA;YAE5DxB,aAAA,EAAeA,aAAA;YACf6C,aAAA,EAAepC,YAAA;YACfgC,QAAA,EAAU5B,gBAAA;YACVZ,QAAA,EAAUA,QAAA;YACVmB,OAAA,EAASF,YAAA;YACTX,KAAA,EAAOK,aAAA,IAAiB;;;uBAKhCsB,KAAA,CAAC;QAAID,SAAA,EAAW,GAAGvC,SAAA,WAAoB;gCACrCsC,IAAA,CAAC1C,MAAA;UACCwD,WAAA,EAAY;UACZb,SAAA,EAAW,GAAGvC,SAAA,kBAA2B;UACzCqD,IAAA,EAAK;UACLC,SAAA,EAAU;UACVC,OAAA,EAASA,CAAA,KACP7C,eAAA,CAAgB;YACdN,QAAA;YACAI;UACF;UAEFgD,KAAK;yBAEPlB,IAAA,CAAC1C,MAAA;UACCwD,WAAA,EAAY;UACZb,SAAA,EAAW,GAAGvC,SAAA,eAAwB;UACtCqD,IAAA,EAAK;UACLC,SAAA,EAAU;UACVC,OAAA,EAASA,CAAA,KACPpD,YAAA,CAAa;YACXC,QAAA,EAAUA,QAAA,GAAW;YACrBa,KAAA,EAAOR,aAAA,CAAcO,IAAI,CAAEC,OAAA,IAAU,CAACA,OAAA,CAAMA,KAAK,CAACY,KAAK,EAAEC,iBAAA;YACzDtB,OAAA;YACAiD,QAAA,EAAU;UACZ;UAEFD,KAAK;;;;;AAMjB","ignoreList":[]}
@@ -139,9 +139,9 @@ export const WhereBuilder = props => {
139
139
  className: `${baseClass}__and-filters`,
140
140
  children: Array.isArray(or?.and) && or.and.map((_, andIndex_2) => {
141
141
  const condition = conditions[orIndex_2].and[andIndex_2];
142
- const fieldName = Object.keys(condition)[0];
143
- const operator_0 = Object.keys(condition?.[fieldName] || {})?.[0] || undefined;
144
- const value_0 = condition?.[fieldName]?.[operator_0] || undefined;
142
+ const fieldPath = Object.keys(condition)[0];
143
+ const operator_0 = Object.keys(condition?.[fieldPath] || {})?.[0] || undefined;
144
+ const value_0 = condition?.[fieldPath]?.[operator_0] || undefined;
145
145
  return /*#__PURE__*/_jsxs("li", {
146
146
  children: [andIndex_2 !== 0 && /*#__PURE__*/_jsx("div", {
147
147
  className: `${baseClass}__label`,
@@ -149,13 +149,13 @@ export const WhereBuilder = props => {
149
149
  }), /*#__PURE__*/_jsx(Condition, {
150
150
  addCondition: addCondition,
151
151
  andIndex: andIndex_2,
152
- fieldName: fieldName,
153
- filterOptions: resolvedFilterOptions?.get(fieldName),
152
+ fieldPath: fieldPath,
153
+ filterOptions: resolvedFilterOptions?.get(fieldPath),
154
154
  operator: operator_0,
155
155
  orIndex: orIndex_2,
156
156
  reducedFields: reducedFields,
157
157
  removeCondition: removeCondition,
158
- RenderedFilter: renderedFilters?.get(fieldName),
158
+ RenderedFilter: renderedFilters?.get(fieldPath),
159
159
  updateCondition: updateCondition,
160
160
  value: value_0
161
161
  })]
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["getTranslation","transformWhereQuery","validateWhereQuery","React","useMemo","useListQuery","useTranslation","reduceFieldsToOptions","Button","Condition","fieldTypes","baseClass","WhereBuilder","props","collectionPluralLabel","fields","renderedFilters","resolvedFilterOptions","i18n","t","reducedFields","handleWhereChange","query","conditions","whereFromSearch","where","or","transformedWhere","console","warn","JSON","stringify","addCondition","useCallback","andIndex","field","orIndex","relation","newConditions","defaultOperator","type","operators","value","and","splice","String","undefined","push","updateCondition","operator","incomingOperator","valueArg","existingCondition","defaults","valueChanged","operatorChanged","Object","keys","newRowCondition","removeCondition","length","_jsxs","className","Fragment","_jsx","label","map","compoundOrKey","Array","isArray","_","condition","fieldName","filterOptions","get","RenderedFilter","buttonStyle","icon","iconPosition","iconStyle","onClick","find","admin","disableListFilter"],"sources":["../../../src/elements/WhereBuilder/index.tsx"],"sourcesContent":["'use client'\nimport type { Operator } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { transformWhereQuery, validateWhereQuery } from 'payload/shared'\nimport React, { useMemo } from 'react'\n\nimport type { AddCondition, RemoveCondition, UpdateCondition, WhereBuilderProps } from './types.js'\n\nimport { useListQuery } from '../../providers/ListQuery/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { reduceFieldsToOptions } from '../../utilities/reduceFieldsToOptions.js'\nimport { Button } from '../Button/index.js'\nimport { Condition } from './Condition/index.js'\nimport fieldTypes from './field-types.js'\nimport './index.scss'\n\nconst baseClass = 'where-builder'\n\nexport { WhereBuilderProps }\n\n/**\n * The WhereBuilder component is used to render the filter controls for a collection's list view.\n * It is part of the {@link ListControls} component which is used to render the controls (search, filter, where).\n */\nexport const WhereBuilder: React.FC<WhereBuilderProps> = (props) => {\n const { collectionPluralLabel, fields, renderedFilters, resolvedFilterOptions } = props\n const { i18n, t } = useTranslation()\n\n const reducedFields = useMemo(() => reduceFieldsToOptions({ fields, i18n }), [fields, i18n])\n\n const { handleWhereChange, query } = useListQuery()\n\n const conditions = useMemo(() => {\n const whereFromSearch = query.where\n\n if (whereFromSearch) {\n if (validateWhereQuery(whereFromSearch)) {\n return whereFromSearch.or\n }\n\n // Transform the where query to be in the right format. This will transform something simple like [text][equals]=example%20post to the right format\n const transformedWhere = transformWhereQuery(whereFromSearch)\n\n if (validateWhereQuery(transformedWhere)) {\n return transformedWhere.or\n }\n\n console.warn(`Invalid where query in URL: ${JSON.stringify(whereFromSearch)}`) // eslint-disable-line no-console\n }\n\n return []\n }, [query.where])\n\n const addCondition: AddCondition = React.useCallback(\n async ({ andIndex, field, orIndex, relation }) => {\n const newConditions = [...conditions]\n\n const defaultOperator = fieldTypes[field.field.type].operators[0].value\n\n if (relation === 'and') {\n newConditions[orIndex].and.splice(andIndex, 0, {\n [String(field.value)]: {\n [defaultOperator]: undefined,\n },\n })\n } else {\n newConditions.push({\n and: [\n {\n [String(field.value)]: {\n [defaultOperator]: undefined,\n },\n },\n ],\n })\n }\n\n await handleWhereChange({ or: newConditions })\n },\n [conditions, handleWhereChange],\n )\n\n const updateCondition: UpdateCondition = React.useCallback(\n async ({ andIndex, field, operator: incomingOperator, orIndex, value: valueArg }) => {\n const existingCondition = conditions[orIndex].and[andIndex]\n\n const defaults = fieldTypes[field.field.type]\n const operator = incomingOperator || defaults.operators[0].value\n\n if (typeof existingCondition === 'object' && field.value) {\n const value = valueArg ?? existingCondition?.[operator]\n\n const valueChanged = value !== existingCondition?.[String(field.value)]?.[String(operator)]\n\n const operatorChanged =\n operator !== Object.keys(existingCondition?.[String(field.value)] || {})?.[0]\n\n if (valueChanged || operatorChanged) {\n const newRowCondition = {\n [String(field.value)]: { [operator]: value },\n }\n\n const newConditions = [...conditions]\n newConditions[orIndex].and[andIndex] = newRowCondition\n\n await handleWhereChange({ or: newConditions })\n }\n }\n },\n [conditions, handleWhereChange],\n )\n\n const removeCondition: RemoveCondition = React.useCallback(\n async ({ andIndex, orIndex }) => {\n const newConditions = [...conditions]\n newConditions[orIndex].and.splice(andIndex, 1)\n\n if (newConditions[orIndex].and.length === 0) {\n newConditions.splice(orIndex, 1)\n }\n\n await handleWhereChange({ or: newConditions })\n },\n [conditions, handleWhereChange],\n )\n\n return (\n <div className={baseClass}>\n {conditions.length > 0 && (\n <React.Fragment>\n <p className={`${baseClass}__label`}>\n {t('general:filterWhere', { label: getTranslation(collectionPluralLabel, i18n) })}\n </p>\n <ul className={`${baseClass}__or-filters`}>\n {conditions.map((or, orIndex) => {\n const compoundOrKey = `${orIndex}_${Array.isArray(or?.and) ? or.and.length : ''}`\n\n return (\n <li key={compoundOrKey}>\n {orIndex !== 0 && <div className={`${baseClass}__label`}>{t('general:or')}</div>}\n <ul className={`${baseClass}__and-filters`}>\n {Array.isArray(or?.and) &&\n or.and.map((_, andIndex) => {\n const condition = conditions[orIndex].and[andIndex]\n const fieldName = Object.keys(condition)[0]\n\n const operator =\n (Object.keys(condition?.[fieldName] || {})?.[0] as Operator) || undefined\n\n const value = condition?.[fieldName]?.[operator] || undefined\n\n return (\n <li key={andIndex}>\n {andIndex !== 0 && (\n <div className={`${baseClass}__label`}>{t('general:and')}</div>\n )}\n <Condition\n addCondition={addCondition}\n andIndex={andIndex}\n fieldName={fieldName}\n filterOptions={resolvedFilterOptions?.get(fieldName)}\n operator={operator}\n orIndex={orIndex}\n reducedFields={reducedFields}\n removeCondition={removeCondition}\n RenderedFilter={renderedFilters?.get(fieldName)}\n updateCondition={updateCondition}\n value={value}\n />\n </li>\n )\n })}\n </ul>\n </li>\n )\n })}\n </ul>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__add-or`}\n icon=\"plus\"\n iconPosition=\"left\"\n iconStyle=\"with-border\"\n onClick={async () => {\n await addCondition({\n andIndex: 0,\n field: reducedFields.find((field) => !field.field.admin?.disableListFilter),\n orIndex: conditions.length,\n relation: 'or',\n })\n }}\n >\n {t('general:or')}\n </Button>\n </React.Fragment>\n )}\n {conditions.length === 0 && (\n <div className={`${baseClass}__no-filters`}>\n <div className={`${baseClass}__label`}>{t('general:noFiltersSet')}</div>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__add-first-filter`}\n icon=\"plus\"\n iconPosition=\"left\"\n iconStyle=\"with-border\"\n onClick={async () => {\n if (reducedFields.length > 0) {\n await addCondition({\n andIndex: 0,\n field: reducedFields.find((field) => !field.field.admin?.disableListFilter),\n orIndex: conditions.length,\n relation: 'or',\n })\n }\n }}\n >\n {t('general:addFilter')}\n </Button>\n </div>\n )}\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,cAAc,QAAQ;AAC/B,SAASC,mBAAmB,EAAEC,kBAAkB,QAAQ;AACxD,OAAOC,KAAA,IAASC,OAAO,QAAQ;AAI/B,SAASC,YAAY,QAAQ;AAC7B,SAASC,cAAc,QAAQ;AAC/B,SAASC,qBAAqB,QAAQ;AACtC,SAASC,MAAM,QAAQ;AACv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AAA,CAAa;cACjBE,QAAA,EAAU;cACVC,KAAA,EAAOf,aAAA,CAAc6D,IAAI,CAAE9C,OAAA,IAAU,CAACA,OAAA,CAAMA,KAAK,CAAC+C,KAAK,EAAEC,iBAAA;cACzD/C,OAAA,EAASb,UAAA,CAAWqC,MAAM;cAC1BvB,QAAA,EAAU;YACZ;UACF;QACF;kBAEClB,CAAA,CAAE;;;;AAMf","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["getTranslation","transformWhereQuery","validateWhereQuery","React","useMemo","useListQuery","useTranslation","reduceFieldsToOptions","Button","Condition","fieldTypes","baseClass","WhereBuilder","props","collectionPluralLabel","fields","renderedFilters","resolvedFilterOptions","i18n","t","reducedFields","handleWhereChange","query","conditions","whereFromSearch","where","or","transformedWhere","console","warn","JSON","stringify","addCondition","useCallback","andIndex","field","orIndex","relation","newConditions","defaultOperator","type","operators","value","and","splice","String","undefined","push","updateCondition","operator","incomingOperator","valueArg","existingCondition","defaults","valueChanged","operatorChanged","Object","keys","newRowCondition","removeCondition","length","_jsxs","className","Fragment","_jsx","label","map","compoundOrKey","Array","isArray","_","condition","fieldPath","filterOptions","get","RenderedFilter","buttonStyle","icon","iconPosition","iconStyle","onClick","find","admin","disableListFilter"],"sources":["../../../src/elements/WhereBuilder/index.tsx"],"sourcesContent":["'use client'\nimport type { Operator } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { transformWhereQuery, validateWhereQuery } from 'payload/shared'\nimport React, { useMemo } from 'react'\n\nimport type { AddCondition, RemoveCondition, UpdateCondition, WhereBuilderProps } from './types.js'\n\nimport { useListQuery } from '../../providers/ListQuery/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { reduceFieldsToOptions } from '../../utilities/reduceFieldsToOptions.js'\nimport { Button } from '../Button/index.js'\nimport { Condition } from './Condition/index.js'\nimport fieldTypes from './field-types.js'\nimport './index.scss'\n\nconst baseClass = 'where-builder'\n\nexport { WhereBuilderProps }\n\n/**\n * The WhereBuilder component is used to render the filter controls for a collection's list view.\n * It is part of the {@link ListControls} component which is used to render the controls (search, filter, where).\n */\nexport const WhereBuilder: React.FC<WhereBuilderProps> = (props) => {\n const { collectionPluralLabel, fields, renderedFilters, resolvedFilterOptions } = props\n const { i18n, t } = useTranslation()\n\n const reducedFields = useMemo(() => reduceFieldsToOptions({ fields, i18n }), [fields, i18n])\n\n const { handleWhereChange, query } = useListQuery()\n\n const conditions = useMemo(() => {\n const whereFromSearch = query.where\n\n if (whereFromSearch) {\n if (validateWhereQuery(whereFromSearch)) {\n return whereFromSearch.or\n }\n\n // Transform the where query to be in the right format. This will transform something simple like [text][equals]=example%20post to the right format\n const transformedWhere = transformWhereQuery(whereFromSearch)\n\n if (validateWhereQuery(transformedWhere)) {\n return transformedWhere.or\n }\n\n console.warn(`Invalid where query in URL: ${JSON.stringify(whereFromSearch)}`) // eslint-disable-line no-console\n }\n\n return []\n }, [query.where])\n\n const addCondition: AddCondition = React.useCallback(\n async ({ andIndex, field, orIndex, relation }) => {\n const newConditions = [...conditions]\n\n const defaultOperator = fieldTypes[field.field.type].operators[0].value\n\n if (relation === 'and') {\n newConditions[orIndex].and.splice(andIndex, 0, {\n [String(field.value)]: {\n [defaultOperator]: undefined,\n },\n })\n } else {\n newConditions.push({\n and: [\n {\n [String(field.value)]: {\n [defaultOperator]: undefined,\n },\n },\n ],\n })\n }\n\n await handleWhereChange({ or: newConditions })\n },\n [conditions, handleWhereChange],\n )\n\n const updateCondition: UpdateCondition = React.useCallback(\n async ({ andIndex, field, operator: incomingOperator, orIndex, value: valueArg }) => {\n const existingCondition = conditions[orIndex].and[andIndex]\n\n const defaults = fieldTypes[field.field.type]\n const operator = incomingOperator || defaults.operators[0].value\n\n if (typeof existingCondition === 'object' && field.value) {\n const value = valueArg ?? existingCondition?.[operator]\n\n const valueChanged = value !== existingCondition?.[String(field.value)]?.[String(operator)]\n\n const operatorChanged =\n operator !== Object.keys(existingCondition?.[String(field.value)] || {})?.[0]\n\n if (valueChanged || operatorChanged) {\n const newRowCondition = {\n [String(field.value)]: { [operator]: value },\n }\n\n const newConditions = [...conditions]\n newConditions[orIndex].and[andIndex] = newRowCondition\n\n await handleWhereChange({ or: newConditions })\n }\n }\n },\n [conditions, handleWhereChange],\n )\n\n const removeCondition: RemoveCondition = React.useCallback(\n async ({ andIndex, orIndex }) => {\n const newConditions = [...conditions]\n newConditions[orIndex].and.splice(andIndex, 1)\n\n if (newConditions[orIndex].and.length === 0) {\n newConditions.splice(orIndex, 1)\n }\n\n await handleWhereChange({ or: newConditions })\n },\n [conditions, handleWhereChange],\n )\n\n return (\n <div className={baseClass}>\n {conditions.length > 0 && (\n <React.Fragment>\n <p className={`${baseClass}__label`}>\n {t('general:filterWhere', { label: getTranslation(collectionPluralLabel, i18n) })}\n </p>\n <ul className={`${baseClass}__or-filters`}>\n {conditions.map((or, orIndex) => {\n const compoundOrKey = `${orIndex}_${Array.isArray(or?.and) ? or.and.length : ''}`\n\n return (\n <li key={compoundOrKey}>\n {orIndex !== 0 && <div className={`${baseClass}__label`}>{t('general:or')}</div>}\n <ul className={`${baseClass}__and-filters`}>\n {Array.isArray(or?.and) &&\n or.and.map((_, andIndex) => {\n const condition = conditions[orIndex].and[andIndex]\n const fieldPath = Object.keys(condition)[0]\n\n const operator =\n (Object.keys(condition?.[fieldPath] || {})?.[0] as Operator) || undefined\n\n const value = condition?.[fieldPath]?.[operator] || undefined\n\n return (\n <li key={andIndex}>\n {andIndex !== 0 && (\n <div className={`${baseClass}__label`}>{t('general:and')}</div>\n )}\n <Condition\n addCondition={addCondition}\n andIndex={andIndex}\n fieldPath={fieldPath}\n filterOptions={resolvedFilterOptions?.get(fieldPath)}\n operator={operator}\n orIndex={orIndex}\n reducedFields={reducedFields}\n removeCondition={removeCondition}\n RenderedFilter={renderedFilters?.get(fieldPath)}\n updateCondition={updateCondition}\n value={value}\n />\n </li>\n )\n })}\n </ul>\n </li>\n )\n })}\n </ul>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__add-or`}\n icon=\"plus\"\n iconPosition=\"left\"\n iconStyle=\"with-border\"\n onClick={async () => {\n await addCondition({\n andIndex: 0,\n field: reducedFields.find((field) => !field.field.admin?.disableListFilter),\n orIndex: conditions.length,\n relation: 'or',\n })\n }}\n >\n {t('general:or')}\n </Button>\n </React.Fragment>\n )}\n {conditions.length === 0 && (\n <div className={`${baseClass}__no-filters`}>\n <div className={`${baseClass}__label`}>{t('general:noFiltersSet')}</div>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__add-first-filter`}\n icon=\"plus\"\n iconPosition=\"left\"\n iconStyle=\"with-border\"\n onClick={async () => {\n if (reducedFields.length > 0) {\n await addCondition({\n andIndex: 0,\n field: reducedFields.find((field) => !field.field.admin?.disableListFilter),\n orIndex: conditions.length,\n relation: 'or',\n })\n }\n }}\n >\n {t('general:addFilter')}\n </Button>\n </div>\n )}\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,cAAc,QAAQ;AAC/B,SAASC,mBAAmB,EAAEC,kBAAkB,QAAQ;AACxD,OAAOC,KAAA,IAASC,OAAO,QAAQ;AAI/B,SAASC,YAAY,QAAQ;AAC7B,SAASC,cAAc,QAAQ;AAC/B,SAASC,qBAAqB,QAAQ;AACtC,SAASC,MAAM,QAAQ;AACvB,SAASC,SAAS,QAAQ;AAC1B,OAAOC,UAAA,MAAgB;AACvB,OAAO;AAEP,MAAMC,SAAA,GAAY;AAIlB;;;;AAIA,OAAO,MAAMC,YAAA,GAA6CC,KAAA;EACxD,MAAM;IAAEC,qBAAqB;IAAEC,MAAM;IAAEC,eAAe;IAAEC;EAAqB,CAAE,GAAGJ,KAAA;EAClF,MAAM;IAAEK,IAAI;IAAEC;EAAC,CAAE,GAAGb,cAAA;EAEpB,MAAMc,aAAA,GAAgBhB,OAAA,CAAQ,MAAMG,qBAAA,CAAsB;IAAEQ,MAAA;IAAQG;EAAK,IAAI,CAACH,MAAA,EAAQG,IAAA,CAAK;EAE3F,M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,EAAY;QACZd,SAAA,EAAW,GAAGnD,SAAA,UAAmB;QACjCkE,IAAA,EAAK;QACLC,YAAA,EAAa;QACbC,SAAA,EAAU;QACVC,OAAA,EAAS,MAAAA,CAAA;UACP,MAAMhD,YAAA,CAAa;YACjBE,QAAA,EAAU;YACVC,KAAA,EAAOf,aAAA,CAAc6D,IAAI,CAAE9C,OAAA,IAAU,CAACA,OAAA,CAAMA,KAAK,CAAC+C,KAAK,EAAEC,iBAAA;YACzD/C,OAAA,EAASb,UAAA,CAAWqC,MAAM;YAC1BvB,QAAA,EAAU;UACZ;QACF;kBAEClB,CAAA,CAAE;;QAIRI,UAAA,CAAWqC,MAAM,KAAK,kBACrBC,KAAA,CAAC;MAAIC,SAAA,EAAW,GAAGnD,SAAA,cAAuB;8BACxCqD,IAAA,CAAC;QAAIF,SAAA,EAAW,GAAGnD,SAAA,SAAkB;kBAAGQ,CAAA,CAAE;uBAC1C6C,IAAA,CAACxD,MAAA;QACCoE,WAAA,EAAY;QACZd,SAAA,EAAW,GAAGnD,SAAA,oBAA6B;QAC3CkE,IAAA,EAAK;QACLC,YAAA,EAAa;QACbC,SAAA,EAAU;QACVC,OAAA,EAAS,MAAAA,CAAA;UACP,IAAI5D,aAAA,CAAcwC,MAAM,GAAG,GAAG;YAC5B,MAAM5B,YAAA,CAAa;cACjBE,QAAA,EAAU;cACVC,KAAA,EAAOf,aAAA,CAAc6D,IAAI,CAAE9C,OAAA,IAAU,CAACA,OAAA,CAAMA,KAAK,CAAC+C,KAAK,EAAEC,iBAAA;cACzD/C,OAAA,EAASb,UAAA,CAAWqC,MAAM;cAC1BvB,QAAA,EAAU;YACZ;UACF;QACF;kBAEClB,CAAA,CAAE;;;;AAMf","ignoreList":[]}
@@ -10,5 +10,5 @@ function require(m) {
10
10
  }
11
11
  // Workaround end
12
12
 
13
- import{i as a}from"./chunk-KPQQ5IUL.js";import"./chunk-5LKBKI4T.js";export{a as default};
14
- //# sourceMappingURL=CodeEditor-URFJPG6I.js.map
13
+ import{j as a}from"./chunk-HBCG32CP.js";import"./chunk-5LKBKI4T.js";export{a as default};
14
+ //# sourceMappingURL=CodeEditor-4J4OH4TD.js.map
@@ -0,0 +1,26 @@
1
+ "use client";
2
+ // Workaround for react-datepicker and other cjs dependencies potentially inserting require("react") statements
3
+ import * as requireReact from 'react';
4
+ import * as requireReactDom from 'react-dom';
5
+
6
+ function require(m) {
7
+ if (m === 'react') return requireReact;
8
+ if (m === 'react-dom') return requireReactDom;
9
+ throw new Error(`Unknown module ${m}`);
10
+ }
11
+ // Workaround end
12
+
13
+ import{c as Er}from"react/compiler-runtime";import{jsx as Ue}from"react/jsx-runtime";function Ke(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function fe(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),r.push.apply(r,n)}return r}function ne(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?fe(Object(r),!0).forEach(function(n){Ke(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):fe(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Ge(t,e){if(t==null)return{};var r={},n=Object.keys(t),o,i;for(i=0;i<n.length;i++)o=n[i],!(e.indexOf(o)>=0)&&(r[o]=t[o]);return r}function me(t,e){if(t==null)return{};var r=Ge(t,e),n,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(o=0;o<i.length;o++)n=i[o],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function pe(t,e){return Ye(t)||Je(t,e)||Qe(t,e)||Xe()}function Ye(t){if(Array.isArray(t))return t}function Je(t,e){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(t)))){var r=[],n=!0,o=!1,i=void 0;try{for(var a=t[Symbol.iterator](),c;!(n=(c=a.next()).done)&&(r.push(c.value),!(e&&r.length===e));n=!0);}catch(u){o=!0,i=u}finally{try{!n&&a.return!=null&&a.return()}finally{if(o)throw i}}return r}}function Qe(t,e){if(t){if(typeof t=="string")return de(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return de(t,e)}}function de(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Xe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
14
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ze(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ge(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),r.push.apply(r,n)}return r}function he(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ge(Object(r),!0).forEach(function(n){Ze(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ge(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function et(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return function(n){return e.reduceRight(function(o,i){return i(o)},n)}}function V(t){return function e(){for(var r=this,n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return o.length>=t.length?t.apply(this,o):function(){for(var a=arguments.length,c=new Array(a),u=0;u<a;u++)c[u]=arguments[u];return e.apply(r,[].concat(o,c))}}}function G(t){return{}.toString.call(t).includes("Object")}function tt(t){return!Object.keys(t).length}function B(t){return typeof t=="function"}function rt(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function nt(t,e){return G(e)||L("changeType"),Object.keys(e).some(function(r){return!rt(t,r)})&&L("changeField"),e}function ot(t){B(t)||L("selectorType")}function it(t){B(t)||G(t)||L("handlerType"),G(t)&&Object.values(t).some(function(e){return!B(e)})&&L("handlersType")}function at(t){t||L("initialIsRequired"),G(t)||L("initialType"),tt(t)&&L("initialContent")}function ct(t,e){throw new Error(t[e]||t.default)}var ut={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},L=V(ct)(ut),K={changes:nt,selector:ot,handler:it,initial:at};function st(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};K.initial(t),K.handler(e);var r={current:t},n=V(dt)(r,e),o=V(ft)(r),i=V(K.changes)(t),a=V(lt)(r);function c(){var s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(d){return d};return K.selector(s),s(r.current)}function u(s){et(n,o,i,a)(s)}return[c,u]}function lt(t,e){return B(e)?e(t.current):e}function ft(t,e){return t.current=he(he({},t.current),e),e}function dt(t,e,r){return B(e)?e(t.current):Object.keys(r).forEach(function(n){var o;return(o=e[n])===null||o===void 0?void 0:o.call(e,t.current[n])}),r}var mt={create:st},ve=mt;var pt={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.52.2/min/vs"}},ye=pt;function gt(t){return function e(){for(var r=this,n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return o.length>=t.length?t.apply(this,o):function(){for(var a=arguments.length,c=new Array(a),u=0;u<a;u++)c[u]=arguments[u];return e.apply(r,[].concat(o,c))}}}var be=gt;function ht(t){return{}.toString.call(t).includes("Object")}var we=ht;function vt(t){return t||Oe("configIsRequired"),we(t)||Oe("configType"),t.urls?(yt(),{paths:{vs:t.urls.monacoBase}}):t}function yt(){console.warn(je.deprecation)}function bt(t,e){throw new Error(t[e]||t.default)}var je={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
15
+ You are using deprecated way of configuration.
16
+
17
+ Instead of using
18
+ monaco.config({ urls: { monacoBase: '...' } })
19
+ use
20
+ monaco.config({ paths: { vs: '...' } })
21
+
22
+ For more please check the link https://github.com/suren-atoyan/monaco-loader#config
23
+ `},Oe=be(bt)(je),wt={config:vt},Me=wt;var Ot=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return function(o){return r.reduceRight(function(i,a){return a(i)},o)}},Se=Ot;function xe(t,e){return Object.keys(e).forEach(function(r){e[r]instanceof Object&&t[r]&&Object.assign(e[r],xe(t[r],e[r]))}),ne(ne({},t),e)}var Ce=xe;var jt={type:"cancelation",msg:"operation is manually canceled"};function Mt(t){var e=!1,r=new Promise(function(n,o){t.then(function(i){return e?o(jt):n(i)}),t.catch(o)});return r.cancel=function(){return e=!0},r}var Y=Mt;var St=ve.create({config:ye,isInitialized:!1,resolve:null,reject:null,monaco:null}),Ee=pe(St,2),H=Ee[0],J=Ee[1];function xt(t){var e=Me.config(t),r=e.monaco,n=me(e,["monaco"]);J(function(o){return{config:Ce(o.config,n),monaco:r}})}function Ct(){var t=H(function(e){var r=e.monaco,n=e.isInitialized,o=e.resolve;return{monaco:r,isInitialized:n,resolve:o}});if(!t.isInitialized){if(J({isInitialized:!0}),t.monaco)return t.resolve(t.monaco),Y(oe);if(window.monaco&&window.monaco.editor)return Pe(window.monaco),t.resolve(window.monaco),Y(oe);Se(Et,Tt)(Rt)}return Y(oe)}function Et(t){return document.body.appendChild(t)}function Pt(t){var e=document.createElement("script");return t&&(e.src=t),e}function Tt(t){var e=H(function(n){var o=n.config,i=n.reject;return{config:o,reject:i}}),r=Pt("".concat(e.config.paths.vs,"/loader.js"));return r.onload=function(){return t()},r.onerror=e.reject,r}function Rt(){var t=H(function(r){var n=r.config,o=r.resolve,i=r.reject;return{config:n,resolve:o,reject:i}}),e=window.require;e.config(t.config),e(["vs/editor/editor.main"],function(r){Pe(r),t.resolve(r)},function(r){t.reject(r)})}function Pe(t){H().monaco||J({monaco:t})}function It(){return H(function(t){var e=t.monaco;return e})}var oe=new Promise(function(t,e){return J({resolve:t,reject:e})}),At={config:xt,init:Ct,__getMonacoInstance:It},_=At;import{memo as Dt}from"react";import Lt,{useState as Te,useRef as k,useCallback as Re,useEffect as Ie}from"react";import{memo as _t}from"react";import ie from"react";import $t from"react";import{useEffect as Ut}from"react";import{useEffect as Kt,useRef as Gt}from"react";import{useState as pn}from"react";import{memo as er}from"react";import tr,{useState as Ae,useEffect as Q,useRef as A,useCallback as rr}from"react";import{useEffect as nr,useRef as or}from"react";var kt={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},ae=kt,Wt={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Nt=Wt;function Vt({children:t}){return $t.createElement("div",{style:Nt.container},t)}var Bt=Vt,Ht=Bt;function zt({width:t,height:e,isEditorReady:r,loading:n,_ref:o,className:i,wrapperProps:a}){return ie.createElement("section",{style:{...ae.wrapper,width:t,height:e},...a},!r&&ie.createElement(Ht,null,n),ie.createElement("div",{ref:o,style:{...ae.fullWidth,...!r&&ae.hide},className:i}))}var Ft=zt,De=_t(Ft);function qt(t){Ut(t,[])}var Le=qt;function Yt(t,e,r=!0){let n=Gt(!0);Kt(n.current||!r?()=>{n.current=!1}:t,e)}var C=Yt;function z(){}function $(t,e,r,n){return Jt(t,n)||Qt(t,e,r,n)}function Jt(t,e){return t.editor.getModel(_e(t,e))}function Qt(t,e,r,n){return t.editor.createModel(e,r,n?_e(t,n):void 0)}function _e(t,e){return t.Uri.parse(e)}function Xt({original:t,modified:e,language:r,originalLanguage:n,modifiedLanguage:o,originalModelPath:i,modifiedModelPath:a,keepCurrentOriginalModel:c=!1,keepCurrentModifiedModel:u=!1,theme:s="light",loading:d="Loading...",options:l={},height:b="100%",width:g="100%",className:O,wrapperProps:j={},beforeMount:M=z,onMount:E=z}){let[w,R]=Te(!1),[P,v]=Te(!0),y=k(null),m=k(null),T=k(null),h=k(E),f=k(M),I=k(!1);Le(()=>{let p=_.init();return p.then(S=>(m.current=S)&&v(!1)).catch(S=>S?.type!=="cancelation"&&console.error("Monaco initialization: error:",S)),()=>y.current?N():p.cancel()}),C(()=>{if(y.current&&m.current){let p=y.current.getOriginalEditor(),S=$(m.current,t||"",n||r||"text",i||"");S!==p.getModel()&&p.setModel(S)}},[i],w),C(()=>{if(y.current&&m.current){let p=y.current.getModifiedEditor(),S=$(m.current,e||"",o||r||"text",a||"");S!==p.getModel()&&p.setModel(S)}},[a],w),C(()=>{let p=y.current.getModifiedEditor();p.getOption(m.current.editor.EditorOption.readOnly)?p.setValue(e||""):e!==p.getValue()&&(p.executeEdits("",[{range:p.getModel().getFullModelRange(),text:e||"",forceMoveMarkers:!0}]),p.pushUndoStop())},[e],w),C(()=>{y.current?.getModel()?.original.setValue(t||"")},[t],w),C(()=>{let{original:p,modified:S}=y.current.getModel();m.current.editor.setModelLanguage(p,n||r||"text"),m.current.editor.setModelLanguage(S,o||r||"text")},[r,n,o],w),C(()=>{m.current?.editor.setTheme(s)},[s],w),C(()=>{y.current?.updateOptions(l)},[l],w);let U=Re(()=>{if(!m.current)return;f.current(m.current);let p=$(m.current,t||"",n||r||"text",i||""),S=$(m.current,e||"",o||r||"text",a||"");y.current?.setModel({original:p,modified:S})},[r,e,o,t,n,i,a]),q=Re(()=>{!I.current&&T.current&&(y.current=m.current.editor.createDiffEditor(T.current,{automaticLayout:!0,...l}),U(),m.current?.editor.setTheme(s),R(!0),I.current=!0)},[l,s,U]);Ie(()=>{w&&h.current(y.current,m.current)},[w]),Ie(()=>{!P&&!w&&q()},[P,w,q]);function N(){let p=y.current?.getModel();c||p?.original?.dispose(),u||p?.modified?.dispose(),y.current?.dispose()}return Lt.createElement(De,{width:g,height:b,isEditorReady:w,loading:d,_ref:T,className:O,wrapperProps:j})}var Zt=Xt,dn=Dt(Zt);function ir(t){let e=or();return nr(()=>{e.current=t},[t]),e.current}var ar=ir,X=new Map;function cr({defaultValue:t,defaultLanguage:e,defaultPath:r,value:n,language:o,path:i,theme:a="light",line:c,loading:u="Loading...",options:s={},overrideServices:d={},saveViewState:l=!0,keepCurrentModel:b=!1,width:g="100%",height:O="100%",className:j,wrapperProps:M={},beforeMount:E=z,onMount:w=z,onChange:R,onValidate:P=z}){let[v,y]=Ae(!1),[m,T]=Ae(!0),h=A(null),f=A(null),I=A(null),U=A(w),q=A(E),N=A(),p=A(n),S=ar(i),se=A(!1),ee=A(!1);Le(()=>{let x=_.init();return x.then(D=>(h.current=D)&&T(!1)).catch(D=>D?.type!=="cancelation"&&console.error("Monaco initialization: error:",D)),()=>f.current?qe():x.cancel()}),C(()=>{let x=$(h.current,t||n||"",e||o||"",i||r||"");x!==f.current?.getModel()&&(l&&X.set(S,f.current?.saveViewState()),f.current?.setModel(x),l&&f.current?.restoreViewState(X.get(i)))},[i],v),C(()=>{f.current?.updateOptions(s)},[s],v),C(()=>{!f.current||n===void 0||(f.current.getOption(h.current.editor.EditorOption.readOnly)?f.current.setValue(n):n!==f.current.getValue()&&(ee.current=!0,f.current.executeEdits("",[{range:f.current.getModel().getFullModelRange(),text:n,forceMoveMarkers:!0}]),f.current.pushUndoStop(),ee.current=!1))},[n],v),C(()=>{let x=f.current?.getModel();x&&o&&h.current?.editor.setModelLanguage(x,o)},[o],v),C(()=>{c!==void 0&&f.current?.revealLine(c)},[c],v),C(()=>{h.current?.editor.setTheme(a)},[a],v);let le=rr(()=>{if(!(!I.current||!h.current)&&!se.current){q.current(h.current);let x=i||r,D=$(h.current,n||t||"",e||o||"",x||"");f.current=h.current?.editor.create(I.current,{model:D,automaticLayout:!0,...s},d),l&&f.current.restoreViewState(X.get(x)),h.current.editor.setTheme(a),c!==void 0&&f.current.revealLine(c),y(!0),se.current=!0}},[t,e,r,n,o,i,s,d,l,a,c]);Q(()=>{v&&U.current(f.current,h.current)},[v]),Q(()=>{!m&&!v&&le()},[m,v,le]),p.current=n,Q(()=>{v&&R&&(N.current?.dispose(),N.current=f.current?.onDidChangeModelContent(x=>{ee.current||R(f.current.getValue(),x)}))},[v,R]),Q(()=>{if(v){let x=h.current.editor.onDidChangeMarkers(D=>{let te=f.current.getModel()?.uri;if(te&&D.find(re=>re.path===te.path)){let re=h.current.editor.getModelMarkers({resource:te});P?.(re)}});return()=>{x?.dispose()}}return()=>{}},[v,P]);function qe(){N.current?.dispose(),b?l&&X.set(i,f.current.saveViewState()):f.current.getModel()?.dispose(),f.current.dispose()}return tr.createElement(De,{width:g,height:O,isEditorReady:v,loading:u,_ref:I,className:j,wrapperProps:M})}var ur=cr,sr=er(ur),Z=sr;import{useState as Pr}from"react";import{c as vr}from"react/compiler-runtime";import{jsx as yr}from"react/jsx-runtime";import{createContext as br,use as wr,useEffect as Or,useState as Ve}from"react";import{c as lr}from"react/compiler-runtime";import{jsx as $e}from"react/jsx-runtime";import{createContext as fr,use as dr,useCallback as mr,useEffect as We,useMemo as ke,useRef as pr,useState as gr}from"react";var Ne=fr(void 0),hr=({children:t,config:e})=>{let[r,n]=gr(e),o=pr(!0);We(()=>{if(o.current){o.current=!1;return}n(e)},[e,n]);let{collectionsBySlug:i,globalsBySlug:a}=ke(()=>{let s={},d={};for(let l of r.collections)s[l.slug]=l;for(let l of r.globals)d[l.slug]=l;return{collectionsBySlug:s,globalsBySlug:d}},[r]),c=mr(s=>"collectionSlug"in s?i[s.collectionSlug]??null:"globalSlug"in s?a[s.globalSlug]??null:null,[i,a]),u=ke(()=>({config:r,getEntityConfig:c,setConfig:n}),[r,c,n]);return $e(Ne,{value:u,children:t})},ce=()=>dr(Ne),xn=t=>{let e=lr(7),{children:r,config:n}=t,{config:o,setConfig:i}=ce(),a,c;if(e[0]!==n||e[1]!==i?(a=()=>{i(n)},c=[n,i],e[0]=n,e[1]=i,e[2]=a,e[3]=c):(a=e[2],c=e[3]),We(a,c),o!==n&&o.unauthenticated!==n.unauthenticated){let u;return e[4]!==r||e[5]!==n?(u=$e(hr,{config:n,children:r}),e[4]=r,e[5]=n,e[6]=u):u=e[6],u}return r};var jr={autoMode:!0,setTheme:()=>null,theme:"light"},He=br(jr);function Be(t,e,r){let n=new Date;n.setTime(n.getTime()+r*24*60*60*1e3);let o="expires="+n.toUTCString();document.cookie=t+"="+e+";"+o+";path=/"}var Mr=t=>{let e,r=window.document.cookie.split("; ").find(n=>n.startsWith(`${t}=`))?.split("=")[1];return r==="light"||r==="dark"?e=r:e=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",document.documentElement.setAttribute("data-theme",e),{theme:e,themeFromCookies:r}},Sr="light",Dn=t=>{let e=vr(11),{children:r,theme:n}=t,{config:o}=ce(),i=o.admin.theme,a=`${o.cookiePrefix||"payload"}-theme`,[c,u]=Ve(n||Sr),[s,d]=Ve(),l,b;e[0]!==a||e[1]!==i?(l=()=>{if(i!=="all")return;let{theme:M,themeFromCookies:E}=Mr(a);u(M),d(!E)},b=[i,a],e[0]=a,e[1]=i,e[2]=l,e[3]=b):(l=e[2],b=e[3]),Or(l,b);let g;e[4]!==a?(g=M=>{if(M==="light"||M==="dark")u(M),d(!1),Be(a,M,365),document.documentElement.setAttribute("data-theme",M);else if(M==="auto"){Be(a,M,-1);let E=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";document.documentElement.setAttribute("data-theme",E),d(!0),u(E)}},e[4]=a,e[5]=g):g=e[5];let O=g,j;return e[6]!==s||e[7]!==r||e[8]!==O||e[9]!==c?(j=yr(He,{value:{autoMode:s,setTheme:O,theme:c},children:r}),e[6]=s,e[7]=r,e[8]=O,e[9]=c,e[10]=j):j=e[10],j},ze=()=>wr(He);import{c as Cr}from"react/compiler-runtime";import{jsx as F}from"react/jsx-runtime";import"react";import{c as xr}from"react/compiler-runtime";import*as W from"react";var Fe=(t,e)=>{let r=xr(9),n=e===void 0?!1:e,[o,i]=W.useState(!1),a=W.useRef(void 0),c;r[0]!==t?(c=()=>(i(!1),clearTimeout(a.current),a.current=setTimeout(()=>{i(!0)},t),()=>{clearTimeout(a.current)}),r[0]=t,r[1]=c):c=r[1];let u=c,s,d;r[2]!==u||r[3]!==n?(s=()=>{n&&u()},d=[u,n],r[2]=u,r[3]=n,r[4]=s,r[5]=d):(s=r[4],d=r[5]),W.useEffect(s,d);let l;return r[6]!==o||r[7]!==u?(l=[o,u],r[6]=o,r[7]=u,r[8]=l):l=r[8],l};var ue=({animationDelay:t="0ms",className:e,disableInlineStyles:r=!1,height:n="60px",width:o="100%"})=>F("div",{className:["shimmer-effect",e].filter(Boolean).join(" "),style:{height:!r&&(typeof n=="number"?`${n}px`:n),width:!r&&(typeof o=="number"?`${o}px`:o)},children:F("div",{className:"shimmer-effect__shine",style:{animationDelay:t}})}),Bn=t=>{let e=Cr(7),{className:r,count:n,height:o,renderDelay:i,shimmerDelay:a,shimmerItemClassName:c,width:u}=t,s=i===void 0?500:i,d=a===void 0?25:a,l=typeof d=="number"?`${d}ms`:d,[b]=Fe(s,!0);if(!b)return null;let g;return e[0]!==r||e[1]!==n||e[2]!==o||e[3]!==l||e[4]!==c||e[5]!==u?(g=F("div",{className:r,children:[...Array(n)].map((O,j)=>F("div",{className:c,children:F(ue,{animationDelay:`calc(${j} * ${l})`,height:o,width:u})},j))}),e[0]=r,e[1]=n,e[2]=o,e[3]=l,e[4]=c,e[5]=u,e[6]=g):g=e[6],g};var Tr="default"in Z?Z.default:Z,Rr="code-editor",Ir=t=>{let e=Er(42),r,n,o,i,a,c;e[0]!==t?({className:r,maxHeight:n,minHeight:o,options:i,readOnly:a,...c}=t,e[0]=t,e[1]=r,e[2]=n,e[3]=o,e[4]=i,e[5]=a,e[6]=c):(r=e[1],n=e[2],o=e[3],i=e[4],a=e[5],c=e[6]);let u=o??56,s;e[7]!==i?(s=i||{},e[7]=i,e[8]=s):s=e[8];let d,l,b,g;e[9]!==s?({insertSpaces:l,tabSize:b,trimAutoWhitespace:g,...d}=s,e[9]=s,e[10]=d,e[11]=l,e[12]=b,e[13]=g):(d=e[10],l=e[11],b=e[12],g=e[13]);let O=i?.padding?(i.padding.top||0)+(i.padding?.bottom||0):0,[j,M]=Pr(u),{theme:E}=ze(),w=c?.defaultLanguage?`language--${c.defaultLanguage}`:"",R=a&&"read-only",P;e[14]!==r||e[15]!==w||e[16]!==R?(P=[Rr,r,w,R].filter(Boolean),e[14]=r,e[15]=w,e[16]=R,e[17]=P):P=e[17];let v=P.join(" "),y;if(e[18]!==u||e[19]!==v||e[20]!==j||e[21]!==d||e[22]!==l||e[23]!==n||e[24]!==O||e[25]!==a||e[26]!==c||e[27]!==b||e[28]!==E||e[29]!==g){let m;e[31]!==u||e[32]!==O||e[33]!==c?(m=(h,f)=>{c.onChange?.(h,f),M(Math.max(u,h.split(`
24
+ `).length*18+2+O))},e[31]=u,e[32]=O,e[33]=c,e[34]=m):m=e[34];let T;e[35]!==u||e[36]!==l||e[37]!==O||e[38]!==c||e[39]!==b||e[40]!==g?(T=(h,f)=>{c.onMount?.(h,f);let I=h.getModel();I&&I.updateOptions({insertSpaces:l??!0,tabSize:b??4,trimAutoWhitespace:g??!0}),M(Math.max(u,h.getValue().split(`
25
+ `).length*18+2+O))},e[35]=u,e[36]=l,e[37]=O,e[38]=c,e[39]=b,e[40]=g,e[41]=T):T=e[41],y=Ue(Tr,{className:v,loading:Ue(ue,{height:j}),options:{detectIndentation:!1,hideCursorInOverviewRuler:!0,insertSpaces:!1,minimap:{enabled:!1},overviewRulerBorder:!1,readOnly:!!a,scrollbar:{alwaysConsumeMouseWheel:!1},scrollBeyondLastLine:!1,trimAutoWhitespace:!1,wordWrap:"on",...d},theme:E==="dark"?"vs-dark":"vs",...c,height:n?Math.min(j,n):j,onChange:m,onMount:T}),e[18]=u,e[19]=v,e[20]=j,e[21]=d,e[22]=l,e[23]=n,e[24]=O,e[25]=a,e[26]=c,e[27]=b,e[28]=E,e[29]=g,e[30]=y}else y=e[30];return y},Jn=Ir;export{hr as a,ce as b,xn as c,Fe as d,ue as e,Bn as f,Sr as g,Dn as h,ze as i,Jn as j};
26
+ //# sourceMappingURL=chunk-HBCG32CP.js.map