/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{supportsFieldConfiguration as t,isMapImageLayer as e}from"../../../layers/support/layerUtils.js";import{isGroupColumn as i}from"./columnUtils.js";import{loadCalciteComponents as n}from"../../support/componentsUtils.js";const o={action:"EsriFeatureTableActionColumn",attachments:"EsriFeatureTableAttachmentsColumn",relationship:"EsriFeatureTableRelationshipColumn"},c=()=>n({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon")}),r=()=>Promise.all([n({input:()=>import("@esri/calcite-components/dist/components/calcite-input"),option:()=>import("@esri/calcite-components/dist/components/calcite-option"),select:()=>import("@esri/calcite-components/dist/components/calcite-select"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker")}),c()]),s=()=>Promise.all([n({"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group")}),r()]);function a(t){return null!=t&&"object"==typeof t&&"createQuery"in t&&"getField"in t&&"queryFeatureCount"in t&&"queryFeatures"in t&&"queryObjectIds"in t&&"capabilities"in t&&"fields"in t&&"fieldsIndex"in t&&"id"in t&&"load"in t&&"objectIdField"in t&&"type"in t&&"when"in t}function l(t){return a(t)&&"queryAttachments"in t}function p(e){return a(e)&&t(e)&&"fieldConfigurations"in e&&"getFieldConfiguration"in e}function m(t){return l(t)&&"addAttachment"in t&&"deleteAttachments"in t&&"updateAttachment"in t}function u(t){return a(t)&&"editingEnabled"in t&&"applyEdits"in t}function d(t){return a(t)&&"relationships"in t&&"queryRelatedFeatures"in t&&"queryRelatedFeaturesCount"in t}function f(t,e,i){if(e?.map)return b(t,[...e.map.allLayers,...e.map.allTables],i)}function b(t,i,{relatedTableId:n}){const o="scene"===t.type&&t.associatedLayer?t.associatedLayer.url:t.url,c=e=>!(!d(e)||e===t)&&("sublayer"===e.type&&e.layer?.url===t.url?e.id===n:o===e.url&&e.layerId===n);if("sublayer"===t.type&&"layer"in t&&e(t.layer)){const e=e=>d(e)&&e!==t&&e.id===n,i=t.layer,o=i.allSublayers?.find(e)||i.subtables?.find(e);if(d(o))return o}let r=null;for(const s of i)if(e(s)){const t=s.allSublayers?.find(c)||s.subtables?.find(c);if(t){r=t;break}}else if(c(s)){r=s;break}if(d(r))return r}function y(t,e){return null!=t&&Number.isInteger(t)&&t>-1&&t<e}function h(t){return null==t||0===t.trim().length}function g(t,e){return(t.relationships??[]).filter(t=>!(t.id===e&&"one-to-one"===t.cardinality)).map(({id:t})=>({relationshipId:t}))}function F(t,e){return t.relationships?.find(({id:t})=>t===e)}function w(t,e){return null==e?null:t?.fields?.find(t=>e.toLowerCase()===t.name?.toLowerCase())}function C(t,e){return e.some(e=>!("group"!==e.type||!C(t,e.columnTemplates))||e.fieldName===t)}function x(t,e){return e?.some(e=>!(!i(e)||!x(t,e.columns))||e.fieldName===t)??!1}export{w as findField,f as findRelatedLayer,b as findRelatedLayerInSources,F as findRelationship,g as getRelationshipIdsToShow,x as hasColumnForField,C as hasTemplateForField,h as isEmptyStringOrWhitespace,a as isIFeatureTableSupportedLayer,l as isIFeatureTableSupportedLayerWithAttachments,m as isIFeatureTableSupportedLayerWithAttachmentsEditing,u as isIFeatureTableSupportedLayerWithEditing,p as isIFeatureTableSupportedLayerWithFieldConfigurations,d as isIFeatureTableSupportedLayerWithRelationships,y as isPageIndexValid,c as loadColumnComponents,r as loadEditorColumnComponents,s as loadFieldColumnComponents,o as uniqueColumnNames};
