@vertigis/arcgis-extensions 53.12.0 → 53.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/data/Feature.js CHANGED
@@ -1 +1 @@
1
- import{__decorate as e}from"tslib";import t from"@arcgis/core/Graphic";import s from"@arcgis/core/core/Collection";import{fromJSON as i}from"@arcgis/core/geometry/support/jsonUtils";import{EntityBase as r}from"../Entity.js";import{Hyperlink as a}from"../Hyperlink.js";import{InvalidOperationError as o}from"../InvalidOperationError.js";import{isLayerExtension as n,isTableExtension as l,ItemType as h}from"../ItemType.js";import{handles as u}from"../support/HandlesMixin.js";import{serializable as p}from"../support/Serializable.js";import{createIHandle as c,notifyChange as m,onWatch as f,watch as d,watchEvent as g}from"../support/observableUtils.js";import{CaseInsensitiveObservableMap as y}from"../utilities/CaseInsensitiveObservableMap.js";import{MapTransformCollection as _}from"../utilities/MapTransformCollection.js";import{ObservableMap as b}from"../utilities/ObservableMap.js";import{ReadOnlyMap as x}from"../utilities/ReadOnlyMap.js";import{Time as F}from"../utilities/Time.js";import{flatten as w,groupBy as v}from"../utilities/array.js";import{checkArg as I}from"../utilities/checkArg.js";import{compare as S}from"../utilities/collection.js";import{isCodedValueDomain as z,isGeometry as A}from"../utilities/esri.js";import{getArcadeExpressionFromField as E,getRelationshipFromField as j,isArcadeExpressionField as T}from"../utilities/field.js";import{esriFormatToGeocortexFormat as k,parse as R}from"../utilities/format/date.js";import{NumberFormat as O}from"../utilities/format/formats.js";import{parse as M}from"../utilities/format/number.js";import{format as N}from"../utilities/format/string.js";import{esriFormatToGeocortexFormat as D,parse as V}from"../utilities/format/time.js";import{find as U,map as P}from"../utilities/iterable.js";import{getLogger as C}from"../utilities/log.js";import{map as G}from"../utilities/promise.js";import{caseInsensitiveEquals as H}from"../utilities/string.js";import{FeatureSettings as L}from"./FeatureSettings.js";import{Schema as Z}from"./Schema.js";const $=C("geocortex.api.data.Feature");export const SCORE_FIELD="_score";export const SCORE_FIELD_ORIGINAL="_score_original";let K=class extends r{attributes;get geometry(){return this._geometry}set geometry(e){this._geometry=A(e)||!e?e:i(e),this.schema.spatialReference=this._geometry?.spatialReference,m(this,"geometryType")}settings;schema;attachments;expressionFieldValues;_itemType=h.FEATURE;get geometryType(){return this.geometry?this.geometry.type:void 0}get source(){return this._source}set source(e){this._source===e||null==this._source&&null==e||(this._source&&this.settings.parent===this._source.featureSettings&&(this.settings.parent=void 0),this._source&&this.schema.parent===this._source.schema&&(this.schema.parent=void 0),this._source=e,this.settings.parent||(this.settings.parent=e?e.featureSettings:void 0),this.schema.parent||(this.schema.parent=e?e.schema:void 0),m(this,"attachmentsInitialized"),m(this,"relatedFeaturesInitialized"))}get primaryKey(){const e=this.attributes.get(this.schema.primaryKeyField);return null!=e?`${e}`:void 0}get hasGlobalId(){return!!this.schema.fields.find((e=>"global-id"===e.type))}get globalId(){const e=this.schema.fields.find((e=>"global-id"===e.type));return e?this.attributes.get(e.name):void 0}set globalId(e){const t=this.schema.fields.find((e=>"global-id"===e.type));if(!t)throw new o("Cannot set global ID on feature -- no global ID field.");this.attributes.set(t.name,e)}get presentableAttributes(){return null==this._presentableAttributes&&(this._presentableAttributes=new W(this)),this._presentableAttributes}get title(){return this.format(this._title||"")}get description(){return this.format(this._description)}get hyperlinks(){return this._hyperlinks||(this._hyperlinks=new ie(this))}get relatedFeatures(){return this._relatedFeatures}get type(){if(this.schema.typeIdField&&this.attributes.has(this.schema.typeIdField)){const e=this.attributes.get(this.schema.typeIdField);return this.schema.types.find((t=>t.id===e))}}get attachmentsInitialized(){return!this.source||this._attachmentsInitialized}get relatedFeaturesInitialized(){return!this.source||this.source.relationships.every((e=>this._initializedRelationships.has(e)))}get expressionsInitialized(){return!this.settings.popupTemplate?.expressionInfos?.length||this._expressionsInitialized}get _hydrationStatus(){return this._featureHydrationStatus?this._featureHydrationStatus:this.source?.capabilities?.supportsQuery&&1===this.attributes.size&&void 0!==this.primaryKey?"dehydrated":"hydrated"}set _hydrationStatus(e){this._featureHydrationStatus=e}get _key(){return`${this.source?.id}//${this.primaryKey??this.globalId??this.id}`}get _title(){let e;return this.settings.popupTemplate&&(e="function"==typeof this.settings.popupTemplate.title?this.settings.popupTemplate.title():this.settings.popupTemplate.title),e||this.schema.displayField&&this.presentableAttributes.get(this.schema.displayField)||""}get _description(){if(this.settings.popupTemplate?.content){if("string"==typeof this.settings.popupTemplate.content)return this.settings.popupTemplate.content;if(Array.isArray(this.settings.popupTemplate.content)){const e=this.settings.popupTemplate.content.find((e=>"text"===e.type));if(e)return e.text}}return""}_geometry;_source;_presentableAttributes;_hyperlinks;_featureHydrationStatus;_relatedFeatures;_expressionFieldValues=new b;_expressionValuesUpdatePending=!1;_attachmentsInitialized=!1;_expressionsInitialized=!1;_initializedRelationships=new WeakSet;constructor(e){super(e),this.settings=new L,this.settings._setFeature(this),this.schema=new Z,this.schema._featureSettings=this.settings,this.attachments=new s,this.attributes=new y,this._relatedFeatures=new b,this.expressionFieldValues=new B(this._expressionFieldValues,this),this._handles.add([d(this.settings,"popupTemplate",(()=>{this._expressionsInitialized=!1,m(this,"expressionsInitialized")}),{sync:!0}),f(this,"title",(()=>{const e=d(this.settings,"popupTemplate.title",(()=>m(this,"title")),{sync:!0}),t=this.presentableAttributes.on("change",(()=>m(this,"title")));return c([e,t])})),f(this,"description",(()=>{const e=d(this.settings,"popupTemplate.content",(()=>m(this,"description")),{sync:!0}),t=this.presentableAttributes.on("change",(()=>m(this,"description")));return c([e,t])})),f(this,"relatedFeaturesInitialized",(()=>g(this,"source.relationships",["after-changes",()=>{m(this,"relatedFeaturesInitialized")}])))])}format(e,...t){let s="string"==typeof e?{format:e}:e;I("options",s).isNotMissing();const{format:i}=s;I("format",i).isNotMissing();let r=s.format.replace(Y,ee);return r=r.replace(q,((e,t,i,r,a)=>ae(this,t||i,r,{...s,format:a?`{0:${a}}`:"{0}"}))),r=r.replace(te,"{{"),s={...s},s.format=r,N(s,...t)}clearExpressionInfos(){this._expressionFieldValues.clear()}toGraphic(){return toGraphic(this)}async fetchExpressionInfos(e=!1){const{expressionInfos:t}=this.settings.popupTemplate??{};if(!t)return;const{runAsyncArcadeExpression:s}=await import("../utilities/arcade.js");if(await Promise.all(t.map((async e=>{try{const t=this.source?.layer??this.source?.sublayer;let i=this.source?.mapExtension;if(!i){const e=this.source?.layerExtension;i=e?.mapExtension}this._expressionFieldValues.set(e.name,await s(e.expression,{layer:t,map:i?.map,feature:this,spatialReference:this.schema.spatialReference}))}catch(t){t instanceof Error&&$.error({message:"Error evaluating expression '{0}': {1}.",error:t},e.name,t.message),this._expressionFieldValues.set(e.name,se)}}))),e)return this.attributes.on("change",(async e=>{this._expressionValuesUpdatePending||(this._expressionValuesUpdatePending=!0,setTimeout((async()=>{this._expressionValuesUpdatePending=!1,await this.fetchExpressionInfos()}),0))}));this._expressionsInitialized=!0,m(this,"expressionsInitialized")}async fetchRelatedFeatures(e,t){if(!this.source)return;let s=[];if(e){const t=new Set(Array.isArray(e)?e:[e]);for(const e of t){const t="string"==typeof e?this.source.relationships.find((t=>t.id===e)):e;if(!t||!this.source.relationships.includes(t))throw new o("Relationship not found in feature source.");s.push(t)}}else s=this.source.relationships.toArray();const i=await G(s,(async e=>[e,await(async()=>{const s=await e.getRelatedFeatures(this,t);return this._initializedRelationships.add(e),s})()]));for(const e of i)this._relatedFeatures.set(e[0],e[1]);m(this,"relatedFeaturesInitialized")}async fetchAttachments(){if(this.source){const e=await this.source.getAttachments(this);S(this.attachments,e,{equals:(e,t)=>e.id===t.id,onMissing:(e,t)=>{this.attachments.remove(e)},onNew:(e,t)=>{this.attachments.add(e)},onMatch:(e,t,s,i)=>{this.attachments.splice(s,1,t)}}),this._attachmentsInitialized=!0,m(this,"attachmentsInitialized")}}async addAttachment(e){return this.source?.addAttachment(this,e)}async deleteAttachments(e){return this.source?.deleteAttachments(this,e)}_getSerializableProperties(){return{...super._getSerializableProperties(),attributes:{serializeModes:["project"],serialize:e=>{const t={};if("project"===e&&this.primaryKey&&(this.source?.capabilities).supportsQuery)t[this.schema.primaryKeyField]=this.primaryKey;else for(const[e,s]of this.attributes.entries())t[e]=s;return t},deserialize:e=>{if(this.attributes.clear(),e instanceof Map||e instanceof b)e.forEach(((e,t)=>{this.attributes.set(t,e)}));else for(const[t,s]of Object.entries(e))this.attributes.set(t,s)}},geometry:{serializeModes:["project"],serialize:e=>"project"===e&&(this.source?.capabilities).supportsQuery?this.getDefault("geometry"):this.geometry?.toJSON(),deserialize:e=>{A(e)?this.geometry=e:this.geometry=e?i(e):void 0}},settings:{serializeModes:["project"],serialize:e=>"project"===e&&(this.source?.capabilities).supportsQuery?this.getDefault("settings"):this.settings.toJSON(e)},schema:{serializeModes:["project"],serialize:e=>"project"===e&&(this.source?.capabilities).supportsQuery?this.getDefault("schema"):this.schema.toJSON(e)},source:["project"]}}async _onInitialize(){const e=this._findRelationshipIds(this._title,this._description),t=this.source?this.source.relationships.map((e=>e.id)).toArray():[],s=[];for(const i of e)t.includes(i)?s.push(this.fetchRelatedFeatures(i)):$.error("Could not find relationship '{0}' referenced in feature title or description.",i);await Promise.all(s)}_findRelationshipIds(...e){const t=[];for(const s of e){let e;const i=s.replace(Y,ee);for(;e=X.exec(i),null!==e;){const s=e[0];t.includes(s)||t.push(e[1])}}return t}};K=e([p],K);export{K as Feature};export function toFeature(e,t){const s=new K(t);if(e.attributes){const t=e.attributes;for(const[e,i]of Object.entries(t))s.attributes.set(e,i)}return s.geometry=e.geometry,e.popupTemplate&&(s.settings.popupTemplate=e.popupTemplate),s}export function toGraphic(e){const s=new t;s.attributes={};for(const t of e.attributes.keys())s.attributes[t]=e.attributes.get(t);return n(e.source)&&e.source.layer&&(s.layer=e.source.layer),l(e.source)&&e.source.table&&(s.layer=e.source.table),s.geometry=e.geometry,e.settings.popupTemplate&&(s.popupTemplate=e.settings.popupTemplate),s}const J="Presentable attributes are read-only.",Q="Feature hyperlinks are read-only. Modify the feature's hyperlink templates instead.";class B extends x{_feature;_pending=new Set;constructor(e,t){super(e),this._feature=t}get(e){return super.has(e)||this._calcExpressionValue(e),super.get(e)}async _calcExpressionValue(e){if(!this._pending.has(e)){this._pending.add(e);try{const{spatialReference:t}=this._feature.schema,s=this._feature.settings.popupTemplate?.expressionInfos?.find((t=>t.name===e));if(!s)return;const{isArcadeScriptAsync:i,runAsyncArcadeExpression:r,arcadeScriptUsesGeometry:a,runArcadeExpression:o}=await import("../utilities/arcade.js");try{if(i(s.expression,t)){const i=this._feature.source?.layer??this._feature.source?.sublayer;let a=this._feature.source?.mapExtension;if(!a){const e=this._feature.source?.layerExtension;a=e?.mapExtension}this._originalMap.set(e,await r(s.expression,{feature:this._feature,layer:i,map:a?.map,spatialReference:t}))}else{if(a(s.expression,t)){const{enableGeometrySupport:e}=await import("@arcgis/core/arcade/arcade");await e()}this._originalMap.set(e,o(s.expression,{feature:this._feature,spatialReference:t}))}}catch(t){t instanceof Error&&$.error({message:"Error evaluating expression '{0}': {1}.",error:t},e,t.message),this._originalMap.set(e,se)}}finally{this._pending.delete(e)}}}}class W extends x{get size(){return this._feature.attributes.size+this._feature.schema.fields._expressionFieldsLength}_feature;_numObservers;_onAllObserversRemoved;constructor(e){super(new y),this._feature=e,this._handles.add([f(this,"size",(()=>d(this._feature.attributes,"size",(()=>m(this,"size")),{sync:!0}))),f(this,"size",(()=>d(this._feature.schema.fields,"_expressionFieldsLength",(()=>m(this,"size")),{sync:!0})))])}destroy(){this._onAllObserversRemoved?.(),this._numObservers=0,super.destroy()}clear(){throw new o(J)}delete(e){throw new o(J)}forEach(e,t){I("callback",e).isNotMissing();for(const s of this.keys())e.call(t,this.get(s),s,this)}get(e){const t=this._getFieldExtensionFormat(e);return this._formatAttribute(e,t)}has(e){for(const t of this.keys())if(H(t,e))return!0;return!1}set(...e){throw new o(J)}*entries(){yield*P(this.keys(),(e=>[e,this.get(e)]))}*keys(){yield*this._feature.attributes.keys();for(const e of this._feature.schema.fields.expressionFields)yield e.name;if(null!=this._feature.source?.relationships)for(const e of this._feature.source.relationships)if("one-to-one"===e.cardinality||"many-to-one"===e.cardinality)for(const t of e.relatedSource.schema.fields)yield`relationships/${e.id}/${t.name}`}*values(){yield*P(this.keys(),(e=>this.get(e)))}[Symbol.iterator](){return this.entries()}toJSON(){return Array.from(this.entries())}on(e,t){if(I("callback",t).isNotMissing(),!this._numObservers){const e=new Map,t=new Set,s=()=>{for(const e of t)e.remove();t.clear()};let i;const r=()=>{const t=()=>{i&&(window.clearTimeout(i),i=void 0)};t(),i=window.setTimeout((()=>{const s=[],i=[];for(const[t,i]of this.entries())i!==e.get(t)&&s.push([t,i]);for(const[t,s]of e.entries())this.has(t)&&s===this.get(t)||i.push([t,s]);if(s.length||i.length){const e={added:s,removed:i,target:this};if(this.hasEventListener("after-add"))for(const e of s)this.emit("after-add",{target:this,item:e});if(this.hasEventListener("after-remove"))for(const e of i)this.emit("after-remove",{target:this,item:e});this.emit("change",e),a()}t()}))},a=()=>{e.clear(),s();for(const s of this.keys()){const i=this._getFieldExtension(s);let a="{0}";if(i){const e=d(i,"format",r);t.add(e),i.format&&(a=i.format)}e.set(s,this._formatAttribute(s,a))}};a();const o=this._feature.attributes.on("change",r),n=this._feature.schema.fieldExtensions.on("change",r),l=[d(this._feature.settings.formatSettings,"numberFormat",r),d(this._feature.settings.formatSettings,"dateFormat",r),d(this._feature.settings.formatSettings,"timeFormat",r),d(this._feature.settings.formatSettings,"locale",r)],h=this._feature.expressionFieldValues.on("change",r),u=this._feature.schema.fields.on("change",(e=>{(e.added?.some((e=>T(e.name)))||e.removed?.some((e=>T(e.name))))&&r()})),p=d(this._feature.settings,"popupTemplate",r);this._onAllObserversRemoved=()=>{h.remove(),o.remove(),n.remove(),u.remove();for(const e of l)e.remove();p.remove(),e.clear(),s()}}const s=super.on(e,t);return this._numObservers++,{remove:()=>{s.remove(),this._numObservers--,this._numObservers||this._onAllObserversRemoved()}}}_getFieldExtension(e){const t=this._feature.schema.findFieldByName(e);if(t)return this._feature.schema.fieldExtensions.forField(t)}_getFieldExtensionFormat(e){const t=this._getFieldExtension(e);return t?t.format:"{0}"}_formatAttribute(e,t){const s=E(e);if(null!=s)return ae(this._feature,"expression",s,{format:t});const[i,r]=j(e);return null!=i?ae(this._feature,i,r,{format:t}):ae(this._feature,void 0,e,{format:t})}}const q=/\{(?:relationships[\\/]([\w-]*)[\\/])?(?:(expression)[\\/])?([_a-zA-ZÀ-ÖØ-öø-ÿ][._a-zA-ZÀ-ÖØ-öø-ÿ0-9()]*)(?::([^}]*))?\}/gi,X=/\{relationships\/([\w-]*)[\\/]([^}]*)\}/gi,Y=/{{/g,ee="\0MAGIC\0",te=new RegExp(ee,"g"),se="#INVALID";class ie extends _{_feature;_hyperlinks;constructor(e){super(e.settings.hyperlinkTemplates,(e=>this._getHyperlink(e))),this._feature=e}destroy(){for(const e of this)e.destroy();super.destroy()}_getHyperlink(e){return null==this._hyperlinks&&(this._hyperlinks=new WeakMap),this._hyperlinks.has(e)||this._hyperlinks.set(e,new re(this._feature,e)),this._hyperlinks.get(e)}}let re=class extends(u(a)){get url(){return this._template.url?this._feature.format(this._template.url):this._template.url}set url(e){throw new o(Q)}get text(){return this._template.text?this._feature.format(this._template.text):this._template.text}set text(e){throw new o(Q)}get iconUrl(){return this._template.iconUrl?this._feature.format(this._template.iconUrl):this._template.iconUrl}set iconUrl(e){throw new o(Q)}get target(){return this._template.target?this._feature.format(this._template.target):this._template.target}set target(e){throw new o(Q)}get tooltip(){return this._template.tooltip?this._feature.format(this._template.tooltip):this._template.tooltip}set tooltip(e){throw new o(Q)}_feature;_template;constructor(e,t){super(t.toJSON()),this._feature=e,this._template=t,this._handles.add(f(this,(e=>{const t=d(this._template,e,(()=>m(this,e)),{sync:!0}),s=this._feature.presentableAttributes.on("change",(()=>{m(this,e)})),i=this._feature.relatedFeatures.on("change",(()=>{m(this,e)}));return c([t,s,i])})))}_getSerializableProperties(){return{}}};function ae(e,t,s,i={format:"{0}"}){if(!H(t,"expression")){if(t){const r=U(e.relatedFeatures.keys(),(e=>H(e.id,t)));if(!r)return $.debug("Could not resolve related field '{0}/{1}",t,s),se;const a=Array.from(e.relatedFeatures.get(r));return"many-to-one"===r.cardinality||"one-to-one"===r.cardinality?a.length<1?($.debug("Could not resolve related field '{0}/{1}",t,s),se):oe(a[0],s,i):a.map((e=>oe(e,s,i))).filter((e=>""!==e)).join(",")}return oe(e,s,i)}if(!e.settings.popupTemplate?.expressionInfos?.find((e=>H(e.name,s))))return $.debug("Could not find expression '{0}'.",s),se;try{const t=e.expressionFieldValues.get(s)??i.defaultExpressionValue??"",r=e.schema.findFieldByName(`expression/${s}`),a=null==r?void 0:e.schema.fieldExtensions.forField(r);return ne(e,t,s,a?.formatSettings,i)}catch(e){if(e instanceof Error)return $.error({message:"Error evaluating expression '{0}': {1}.",error:e},s,e.message),se;throw e}}function oe(e,t,s){let i;if(i=e.attributes.get(t),null==i)return"";const r=e.schema.findFieldByName(t),a=e.type?.domains?.[r?.name??t],o=e=>e.codedValues?.find((e=>e.code.toString()===i.toString()))?.name??i;let n;if(H(t,e.schema.typeIdField)){const t=a&&"inherited"!==a.type?a:r?.domain;i="coded-value"===t?.type?o(t):e.type?.name??i}else if(a&&z(a))i=o(a);else if(r?.domain&&z(r.domain))i=o(r.domain);else if(r){switch(r.type){case"integer":case"small-integer":case"big-integer":case"single":case"double":i=M(i);break;case"date":i=R({timeZone:e.schema.timeZone},i);break;case"timestamp-offset":case"date-only":i=R({},i),"date-only"===r.type&&(s.isDateOnly=!0);break;case"time-only":i=V(i);break;default:i=`${i.toString()}`}const t=e.schema.fieldExtensions.forField(r);t&&(n=t.formatSettings)}return ne(e,i,t,n,s)}function ne(e,t,s,i,r){if("string"==typeof t&&(null==r.format||"{0}"===r.format))return t;const a={...r};if("number"==typeof t||t instanceof Date||t instanceof F){null==a.locale&&(a.locale=i?.locale??e.settings.formatSettings.locale);const r=e.settings.popupTemplate?.fieldInfos?.find((e=>H(e.fieldName,s)))?.format;"number"==typeof t?function(e,t,s,i){null==e.currency&&(e.currency=t?.currency??i.settings.formatSettings.currency);null==e.numberFormat&&(e.numberFormat=t?.numberFormat,null==e.numberFormat&&(e.numberFormat=null==s?i.settings.formatSettings.numberFormat:s.digitSeparator?O.NUMBER:O.FIXED_POINT));null==e.fractionalDigits&&(e.fractionalDigits=t?.fractionalDigits,null==e.fractionalDigits&&(e.fractionalDigits=null==s?i.settings.formatSettings.fractionalDigits:s.places))}(a,i,r,e):t instanceof Date?function(e,t,s,i){null==e.dateFormat&&(e.dateFormat=t?.dateFormat,null==e.dateFormat&&(e.dateFormat=null==s?i.settings.formatSettings.dateFormat:k(s.dateFormat)));null==e.timeZone&&(e.timeZone=t?.timeZone??i.settings.formatSettings.timeZone)}(a,i,r,e):function(e,t,s,i){null==e.timeFormat&&(e.timeFormat=t?.timeFormat,null==e.timeFormat&&(e.timeFormat=null==s?i.settings.formatSettings.timeFormat:D(s.dateFormat)))}(a,i,r,e)}return N(a,t)}re=e([p],re);export async function resolveRelatedFeatures(e){const t=v(e,(e=>e.source));await Promise.all(w([...t.keys()].map((e=>e.relationships.toArray()))).map((e=>(async e=>{[...(await e.getAllRelatedFeatures(t.get(e.source))).entries()].forEach((([t,s])=>{t.relatedFeatures.set(e,s)}))})(e))))}
1
+ import{__decorate as e}from"tslib";import t from"@arcgis/core/Graphic";import s from"@arcgis/core/core/Collection";import{fromJSON as i}from"@arcgis/core/geometry/support/jsonUtils";import{EntityBase as r}from"../Entity.js";import{Hyperlink as a}from"../Hyperlink.js";import{InvalidOperationError as o}from"../InvalidOperationError.js";import{isLayerExtension as n,isSublayerExtension as l,isTableExtension as h,ItemType as u}from"../ItemType.js";import{handles as p}from"../support/HandlesMixin.js";import{serializable as c}from"../support/Serializable.js";import{createIHandle as m,notifyChange as f,onWatch as d,watch as g,watchEvent as y}from"../support/observableUtils.js";import{CaseInsensitiveObservableMap as _}from"../utilities/CaseInsensitiveObservableMap.js";import{MapTransformCollection as b}from"../utilities/MapTransformCollection.js";import{ObservableMap as x}from"../utilities/ObservableMap.js";import{ReadOnlyMap as F}from"../utilities/ReadOnlyMap.js";import{Time as w}from"../utilities/Time.js";import{flatten as v,groupBy as I}from"../utilities/array.js";import{checkArg as S}from"../utilities/checkArg.js";import{compare as z}from"../utilities/collection.js";import{isCodedValueDomain as A,isGeometry as E}from"../utilities/esri.js";import{getArcadeExpressionFromField as j,getRelationshipFromField as T,isArcadeExpressionField as k}from"../utilities/field.js";import{esriFormatToGeocortexFormat as R,parse as O}from"../utilities/format/date.js";import{NumberFormat as M}from"../utilities/format/formats.js";import{parse as N}from"../utilities/format/number.js";import{format as D}from"../utilities/format/string.js";import{esriFormatToGeocortexFormat as V,parse as U}from"../utilities/format/time.js";import{find as P,map as C}from"../utilities/iterable.js";import{getLogger as G}from"../utilities/log.js";import{map as H}from"../utilities/promise.js";import{caseInsensitiveEquals as L}from"../utilities/string.js";import{FeatureSettings as Z}from"./FeatureSettings.js";import{Schema as $}from"./Schema.js";const K=G("geocortex.api.data.Feature");export const SCORE_FIELD="_score";export const SCORE_FIELD_ORIGINAL="_score_original";let J=class extends r{attributes;get geometry(){return this._geometry}set geometry(e){this._geometry=E(e)||!e?e:i(e),this.schema.spatialReference=this._geometry?.spatialReference,f(this,"geometryType")}settings;schema;attachments;expressionFieldValues;_itemType=u.FEATURE;get geometryType(){return this.geometry?this.geometry.type:void 0}get source(){return this._source}set source(e){this._source===e||null==this._source&&null==e||(this._source&&this.settings.parent===this._source.featureSettings&&(this.settings.parent=void 0),this._source&&this.schema.parent===this._source.schema&&(this.schema.parent=void 0),this._source=e,this.settings.parent||(this.settings.parent=e?e.featureSettings:void 0),this.schema.parent||(this.schema.parent=e?e.schema:void 0),f(this,"attachmentsInitialized"),f(this,"relatedFeaturesInitialized"))}get primaryKey(){const e=this.attributes.get(this.schema.primaryKeyField);return null!=e?`${e}`:void 0}get hasGlobalId(){return!!this.schema.fields.find((e=>"global-id"===e.type))}get globalId(){const e=this.schema.fields.find((e=>"global-id"===e.type));return e?this.attributes.get(e.name):void 0}set globalId(e){const t=this.schema.fields.find((e=>"global-id"===e.type));if(!t)throw new o("Cannot set global ID on feature -- no global ID field.");this.attributes.set(t.name,e)}get presentableAttributes(){return null==this._presentableAttributes&&(this._presentableAttributes=new q(this)),this._presentableAttributes}get title(){return this.format(this._title||"")}get description(){return this.format(this._description)}get hyperlinks(){return this._hyperlinks||(this._hyperlinks=new re(this))}get relatedFeatures(){return this._relatedFeatures}get type(){if(this.schema.typeIdField&&this.attributes.has(this.schema.typeIdField)){const e=this.attributes.get(this.schema.typeIdField);return this.schema.types.find((t=>t.id===e))}}get attachmentsInitialized(){return!this.source||this._attachmentsInitialized}get relatedFeaturesInitialized(){return!this.source||this.source.relationships.every((e=>this._initializedRelationships.has(e)))}get expressionsInitialized(){return!this.settings.popupTemplate?.expressionInfos?.length||this._expressionsInitialized}get _hydrationStatus(){return this._featureHydrationStatus?this._featureHydrationStatus:this.source?.capabilities?.supportsQuery&&1===this.attributes.size&&void 0!==this.primaryKey?"dehydrated":"hydrated"}set _hydrationStatus(e){this._featureHydrationStatus=e}get _key(){return`${this.source?.id}//${this.primaryKey??this.globalId??this.id}`}get _title(){let e;return this.settings.popupTemplate&&(e="function"==typeof this.settings.popupTemplate.title?this.settings.popupTemplate.title():this.settings.popupTemplate.title),e||this.schema.displayField&&this.presentableAttributes.get(this.schema.displayField)||""}get _description(){if(this.settings.popupTemplate?.content){if("string"==typeof this.settings.popupTemplate.content)return this.settings.popupTemplate.content;if(Array.isArray(this.settings.popupTemplate.content)){const e=this.settings.popupTemplate.content.find((e=>"text"===e.type));if(e)return e.text}}return""}_geometry;_source;_presentableAttributes;_hyperlinks;_featureHydrationStatus;_relatedFeatures;_expressionFieldValues=new x;_expressionValuesUpdatePending=!1;_attachmentsInitialized=!1;_expressionsInitialized=!1;_initializedRelationships=new WeakSet;constructor(e){super(e),this.settings=new Z,this.settings._setFeature(this),this.schema=new $,this.schema._featureSettings=this.settings,this.attachments=new s,this.attributes=new _,this._relatedFeatures=new x,this.expressionFieldValues=new W(this._expressionFieldValues,this),this._handles.add([g(this.settings,"popupTemplate",(()=>{this._expressionsInitialized=!1,f(this,"expressionsInitialized")}),{sync:!0}),d(this,"title",(()=>{const e=g(this.settings,"popupTemplate.title",(()=>f(this,"title")),{sync:!0}),t=this.presentableAttributes.on("change",(()=>f(this,"title")));return m([e,t])})),d(this,"description",(()=>{const e=g(this.settings,"popupTemplate.content",(()=>f(this,"description")),{sync:!0}),t=this.presentableAttributes.on("change",(()=>f(this,"description")));return m([e,t])})),d(this,"relatedFeaturesInitialized",(()=>y(this,"source.relationships",["after-changes",()=>{f(this,"relatedFeaturesInitialized")}])))])}format(e,...t){let s="string"==typeof e?{format:e}:e;S("options",s).isNotMissing();const{format:i}=s;S("format",i).isNotMissing();let r=s.format.replace(ee,te);return r=r.replace(X,((e,t,i,r,a)=>oe(this,t||i,r,{...s,format:a?`{0:${a}}`:"{0}"}))),r=r.replace(se,"{{"),s={...s},s.format=r,D(s,...t)}clearExpressionInfos(){this._expressionFieldValues.clear()}toGraphic(){return toGraphic(this)}async fetchExpressionInfos(e=!1){const{expressionInfos:t}=this.settings.popupTemplate??{};if(!t)return;const{runAsyncArcadeExpression:s}=await import("../utilities/arcade.js");if(await Promise.all(t.map((async e=>{try{const t=this.source?.layer??this.source?.sublayer;let i=this.source?.mapExtension;if(!i){const e=this.source?.layerExtension;i=e?.mapExtension}this._expressionFieldValues.set(e.name,await s(e.expression,{layer:t,map:i?.map,feature:this,spatialReference:this.schema.spatialReference}))}catch(t){t instanceof Error&&K.error({message:"Error evaluating expression '{0}': {1}.",error:t},e.name,t.message),this._expressionFieldValues.set(e.name,ie)}}))),e)return this.attributes.on("change",(async e=>{this._expressionValuesUpdatePending||(this._expressionValuesUpdatePending=!0,setTimeout((async()=>{this._expressionValuesUpdatePending=!1,await this.fetchExpressionInfos()}),0))}));this._expressionsInitialized=!0,f(this,"expressionsInitialized")}async fetchRelatedFeatures(e,t){if(!this.source)return;let s=[];if(e){const t=new Set(Array.isArray(e)?e:[e]);for(const e of t){const t="string"==typeof e?this.source.relationships.find((t=>t.id===e)):e;if(!t||!this.source.relationships.includes(t))throw new o("Relationship not found in feature source.");s.push(t)}}else s=this.source.relationships.toArray();const i=await H(s,(async e=>[e,await(async()=>{const s=await e.getRelatedFeatures(this,t);return this._initializedRelationships.add(e),s})()]));for(const e of i)this._relatedFeatures.set(e[0],e[1]);f(this,"relatedFeaturesInitialized")}async fetchAttachments(){if(this.source){const e=await this.source.getAttachments(this);z(this.attachments,e,{equals:(e,t)=>e.id===t.id,onMissing:(e,t)=>{this.attachments.remove(e)},onNew:(e,t)=>{this.attachments.add(e)},onMatch:(e,t,s,i)=>{this.attachments.splice(s,1,t)}}),this._attachmentsInitialized=!0,f(this,"attachmentsInitialized")}}async addAttachment(e){return this.source?.addAttachment(this,e)}async deleteAttachments(e){return this.source?.deleteAttachments(this,e)}_getSerializableProperties(){return{...super._getSerializableProperties(),attributes:{serializeModes:["project"],serialize:e=>{const t={};if("project"===e&&this.primaryKey&&(this.source?.capabilities).supportsQuery)t[this.schema.primaryKeyField]=this.primaryKey;else for(const[e,s]of this.attributes.entries())t[e]=s;return t},deserialize:e=>{if(this.attributes.clear(),e instanceof Map||e instanceof x)e.forEach(((e,t)=>{this.attributes.set(t,e)}));else for(const[t,s]of Object.entries(e))this.attributes.set(t,s)}},geometry:{serializeModes:["project"],serialize:e=>"project"===e&&(this.source?.capabilities).supportsQuery?this.getDefault("geometry"):this.geometry?.toJSON(),deserialize:e=>{E(e)?this.geometry=e:this.geometry=e?i(e):void 0}},settings:{serializeModes:["project"],serialize:e=>"project"===e&&(this.source?.capabilities).supportsQuery?this.getDefault("settings"):this.settings.toJSON(e)},schema:{serializeModes:["project"],serialize:e=>"project"===e&&(this.source?.capabilities).supportsQuery?this.getDefault("schema"):this.schema.toJSON(e)},source:["project"]}}async _onInitialize(){const e=this._findRelationshipIds(this._title,this._description),t=this.source?this.source.relationships.map((e=>e.id)).toArray():[],s=[];for(const i of e)t.includes(i)?s.push(this.fetchRelatedFeatures(i)):K.error("Could not find relationship '{0}' referenced in feature title or description.",i);await Promise.all(s)}_findRelationshipIds(...e){const t=[];for(const s of e){let e;const i=s.replace(ee,te);for(;e=Y.exec(i),null!==e;){const s=e[0];t.includes(s)||t.push(e[1])}}return t}};J=e([c],J);export{J as Feature};export function toFeature(e,t){const s=new J(t);if(e.attributes){const t=e.attributes;for(const[e,i]of Object.entries(t))s.attributes.set(e,i)}return s.geometry=e.geometry,e.popupTemplate&&(s.settings.popupTemplate=e.popupTemplate),s}export function toGraphic(e){const s=new t;s.attributes={};for(const t of e.attributes.keys())s.attributes[t]=e.attributes.get(t);return n(e.source)&&e.source.layer?s.layer=e.source.layer:l(e.source)&&e.source.sublayer&&(s.layer=e.source.sublayer),h(e.source)&&e.source.table&&(s.layer=e.source.table),s.geometry=e.geometry,e.settings.popupTemplate&&(s.popupTemplate=e.settings.popupTemplate),s}const Q="Presentable attributes are read-only.",B="Feature hyperlinks are read-only. Modify the feature's hyperlink templates instead.";class W extends F{_feature;_pending=new Set;constructor(e,t){super(e),this._feature=t}get(e){return super.has(e)||this._calcExpressionValue(e),super.get(e)}async _calcExpressionValue(e){if(!this._pending.has(e)){this._pending.add(e);try{const{spatialReference:t}=this._feature.schema,s=this._feature.settings.popupTemplate?.expressionInfos?.find((t=>t.name===e));if(!s)return;const{isArcadeScriptAsync:i,runAsyncArcadeExpression:r,arcadeScriptUsesGeometry:a,runArcadeExpression:o}=await import("../utilities/arcade.js");try{if(i(s.expression,t)){const i=this._feature.source?.layer??this._feature.source?.sublayer;let a=this._feature.source?.mapExtension;if(!a){const e=this._feature.source?.layerExtension;a=e?.mapExtension}this._originalMap.set(e,await r(s.expression,{feature:this._feature,layer:i,map:a?.map,spatialReference:t}))}else{if(a(s.expression,t)){const{enableGeometrySupport:e}=await import("@arcgis/core/arcade/arcade");await e()}this._originalMap.set(e,o(s.expression,{feature:this._feature,spatialReference:t}))}}catch(t){t instanceof Error&&K.error({message:"Error evaluating expression '{0}': {1}.",error:t},e,t.message),this._originalMap.set(e,ie)}}finally{this._pending.delete(e)}}}}class q extends F{get size(){return this._feature.attributes.size+this._feature.schema.fields._expressionFieldsLength}_feature;_numObservers;_onAllObserversRemoved;constructor(e){super(new _),this._feature=e,this._handles.add([d(this,"size",(()=>g(this._feature.attributes,"size",(()=>f(this,"size")),{sync:!0}))),d(this,"size",(()=>g(this._feature.schema.fields,"_expressionFieldsLength",(()=>f(this,"size")),{sync:!0})))])}destroy(){this._onAllObserversRemoved?.(),this._numObservers=0,super.destroy()}clear(){throw new o(Q)}delete(e){throw new o(Q)}forEach(e,t){S("callback",e).isNotMissing();for(const s of this.keys())e.call(t,this.get(s),s,this)}get(e){const t=this._getFieldExtensionFormat(e);return this._formatAttribute(e,t)}has(e){for(const t of this.keys())if(L(t,e))return!0;return!1}set(...e){throw new o(Q)}*entries(){yield*C(this.keys(),(e=>[e,this.get(e)]))}*keys(){yield*this._feature.attributes.keys();for(const e of this._feature.schema.fields.expressionFields)yield e.name;if(null!=this._feature.source?.relationships)for(const e of this._feature.source.relationships)if("one-to-one"===e.cardinality||"many-to-one"===e.cardinality)for(const t of e.relatedSource.schema.fields)yield`relationships/${e.id}/${t.name}`}*values(){yield*C(this.keys(),(e=>this.get(e)))}[Symbol.iterator](){return this.entries()}toJSON(){return Array.from(this.entries())}on(e,t){if(S("callback",t).isNotMissing(),!this._numObservers){const e=new Map,t=new Set,s=()=>{for(const e of t)e.remove();t.clear()};let i;const r=()=>{const t=()=>{i&&(window.clearTimeout(i),i=void 0)};t(),i=window.setTimeout((()=>{const s=[],i=[];for(const[t,i]of this.entries())i!==e.get(t)&&s.push([t,i]);for(const[t,s]of e.entries())this.has(t)&&s===this.get(t)||i.push([t,s]);if(s.length||i.length){const e={added:s,removed:i,target:this};if(this.hasEventListener("after-add"))for(const e of s)this.emit("after-add",{target:this,item:e});if(this.hasEventListener("after-remove"))for(const e of i)this.emit("after-remove",{target:this,item:e});this.emit("change",e),a()}t()}))},a=()=>{e.clear(),s();for(const s of this.keys()){const i=this._getFieldExtension(s);let a="{0}";if(i){const e=g(i,"format",r);t.add(e),i.format&&(a=i.format)}e.set(s,this._formatAttribute(s,a))}};a();const o=this._feature.attributes.on("change",r),n=this._feature.schema.fieldExtensions.on("change",r),l=[g(this._feature.settings.formatSettings,"numberFormat",r),g(this._feature.settings.formatSettings,"dateFormat",r),g(this._feature.settings.formatSettings,"timeFormat",r),g(this._feature.settings.formatSettings,"locale",r)],h=this._feature.expressionFieldValues.on("change",r),u=this._feature.schema.fields.on("change",(e=>{(e.added?.some((e=>k(e.name)))||e.removed?.some((e=>k(e.name))))&&r()})),p=g(this._feature.settings,"popupTemplate",r);this._onAllObserversRemoved=()=>{h.remove(),o.remove(),n.remove(),u.remove();for(const e of l)e.remove();p.remove(),e.clear(),s()}}const s=super.on(e,t);return this._numObservers++,{remove:()=>{s.remove(),this._numObservers--,this._numObservers||this._onAllObserversRemoved()}}}_getFieldExtension(e){const t=this._feature.schema.findFieldByName(e);if(t)return this._feature.schema.fieldExtensions.forField(t)}_getFieldExtensionFormat(e){const t=this._getFieldExtension(e);return t?t.format:"{0}"}_formatAttribute(e,t){const s=j(e);if(null!=s)return oe(this._feature,"expression",s,{format:t});const[i,r]=T(e);return null!=i?oe(this._feature,i,r,{format:t}):oe(this._feature,void 0,e,{format:t})}}const X=/\{(?:relationships[\\/]([\w-]*)[\\/])?(?:(expression)[\\/])?([_a-zA-ZÀ-ÖØ-öø-ÿ][._a-zA-ZÀ-ÖØ-öø-ÿ0-9()]*)(?::([^}]*))?\}/gi,Y=/\{relationships\/([\w-]*)[\\/]([^}]*)\}/gi,ee=/{{/g,te="\0MAGIC\0",se=new RegExp(te,"g"),ie="#INVALID";class re extends b{_feature;_hyperlinks;constructor(e){super(e.settings.hyperlinkTemplates,(e=>this._getHyperlink(e))),this._feature=e}destroy(){for(const e of this)e.destroy();super.destroy()}_getHyperlink(e){return null==this._hyperlinks&&(this._hyperlinks=new WeakMap),this._hyperlinks.has(e)||this._hyperlinks.set(e,new ae(this._feature,e)),this._hyperlinks.get(e)}}let ae=class extends(p(a)){get url(){return this._template.url?this._feature.format(this._template.url):this._template.url}set url(e){throw new o(B)}get text(){return this._template.text?this._feature.format(this._template.text):this._template.text}set text(e){throw new o(B)}get iconUrl(){return this._template.iconUrl?this._feature.format(this._template.iconUrl):this._template.iconUrl}set iconUrl(e){throw new o(B)}get target(){return this._template.target?this._feature.format(this._template.target):this._template.target}set target(e){throw new o(B)}get tooltip(){return this._template.tooltip?this._feature.format(this._template.tooltip):this._template.tooltip}set tooltip(e){throw new o(B)}_feature;_template;constructor(e,t){super(t.toJSON()),this._feature=e,this._template=t,this._handles.add(d(this,(e=>{const t=g(this._template,e,(()=>f(this,e)),{sync:!0}),s=this._feature.presentableAttributes.on("change",(()=>{f(this,e)})),i=this._feature.relatedFeatures.on("change",(()=>{f(this,e)}));return m([t,s,i])})))}_getSerializableProperties(){return{}}};function oe(e,t,s,i={format:"{0}"}){if(!L(t,"expression")){if(t){const r=P(e.relatedFeatures.keys(),(e=>L(e.id,t)));if(!r)return K.debug("Could not resolve related field '{0}/{1}",t,s),ie;const a=Array.from(e.relatedFeatures.get(r));return"many-to-one"===r.cardinality||"one-to-one"===r.cardinality?a.length<1?(K.debug("Could not resolve related field '{0}/{1}",t,s),ie):ne(a[0],s,i):a.map((e=>ne(e,s,i))).filter((e=>""!==e)).join(",")}return ne(e,s,i)}if(!e.settings.popupTemplate?.expressionInfos?.find((e=>L(e.name,s))))return K.debug("Could not find expression '{0}'.",s),ie;try{const t=e.expressionFieldValues.get(s)??i.defaultExpressionValue??"",r=e.schema.findFieldByName(`expression/${s}`),a=null==r?void 0:e.schema.fieldExtensions.forField(r);return le(e,t,s,a?.formatSettings,i)}catch(e){if(e instanceof Error)return K.error({message:"Error evaluating expression '{0}': {1}.",error:e},s,e.message),ie;throw e}}function ne(e,t,s){let i;if(i=e.attributes.get(t),null==i)return"";const r=e.schema.findFieldByName(t),a=e.type?.domains?.[r?.name??t],o=e=>e.codedValues?.find((e=>e.code.toString()===i.toString()))?.name??i;let n;if(L(t,e.schema.typeIdField)){const t=a&&"inherited"!==a.type?a:r?.domain;i="coded-value"===t?.type?o(t):e.type?.name??i}else if(a&&A(a))i=o(a);else if(r?.domain&&A(r.domain))i=o(r.domain);else if(r){switch(r.type){case"integer":case"small-integer":case"big-integer":case"single":case"double":i=N(i);break;case"date":i=O({timeZone:e.schema.timeZone},i);break;case"timestamp-offset":case"date-only":i=O({},i),"date-only"===r.type&&(s.isDateOnly=!0);break;case"time-only":i=U(i);break;default:i=`${i.toString()}`}const t=e.schema.fieldExtensions.forField(r);t&&(n=t.formatSettings)}return le(e,i,t,n,s)}function le(e,t,s,i,r){if("string"==typeof t&&(null==r.format||"{0}"===r.format))return t;const a={...r};if("number"==typeof t||t instanceof Date||t instanceof w){null==a.locale&&(a.locale=i?.locale??e.settings.formatSettings.locale);const r=e.settings.popupTemplate?.fieldInfos?.find((e=>L(e.fieldName,s)))?.format;"number"==typeof t?function(e,t,s,i){null==e.currency&&(e.currency=t?.currency??i.settings.formatSettings.currency);null==e.numberFormat&&(e.numberFormat=t?.numberFormat,null==e.numberFormat&&(e.numberFormat=null==s?i.settings.formatSettings.numberFormat:s.digitSeparator?M.NUMBER:M.FIXED_POINT));null==e.fractionalDigits&&(e.fractionalDigits=t?.fractionalDigits,null==e.fractionalDigits&&(e.fractionalDigits=null==s?i.settings.formatSettings.fractionalDigits:s.places))}(a,i,r,e):t instanceof Date?function(e,t,s,i){null==e.dateFormat&&(e.dateFormat=t?.dateFormat,null==e.dateFormat&&(e.dateFormat=null==s?i.settings.formatSettings.dateFormat:R(s.dateFormat)));null==e.timeZone&&(e.timeZone=t?.timeZone??i.settings.formatSettings.timeZone)}(a,i,r,e):function(e,t,s,i){null==e.timeFormat&&(e.timeFormat=t?.timeFormat,null==e.timeFormat&&(e.timeFormat=null==s?i.settings.formatSettings.timeFormat:V(s.dateFormat)))}(a,i,r,e)}return D(a,t)}ae=e([c],ae);export async function resolveRelatedFeatures(e){const t=I(e,(e=>e.source));await Promise.all(v([...t.keys()].map((e=>e.relationships.toArray()))).map((e=>(async e=>{[...(await e.getAllRelatedFeatures(t.get(e.source))).entries()].forEach((([t,s])=>{t.relatedFeatures.set(e,s)}))})(e))))}
@@ -1,2 +1,2 @@
1
- <!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>version | @vertigis/arcgis-extensions</title><meta name="description" content="Documentation for @vertigis/arcgis-extensions"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">@vertigis/arcgis-extensions</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">@vertigis/arcgis-extensions</a></li><li><a href="../modules/version.html">version</a></li><li><a href="version.version.html">version</a></li></ul><h1>Variable version<code class="tsd-tag">Const</code></h1></div><div class="tsd-signature"><span class="tsd-kind-variable">version</span><span class="tsd-signature-symbol"> = &quot;53.12.0&quot;</span></div><div class="tsd-comment tsd-typography"><p>The current version of the Geocortex ArcGIS Extensions API.</p>
1
+ <!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>version | @vertigis/arcgis-extensions</title><meta name="description" content="Documentation for @vertigis/arcgis-extensions"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">@vertigis/arcgis-extensions</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">@vertigis/arcgis-extensions</a></li><li><a href="../modules/version.html">version</a></li><li><a href="version.version.html">version</a></li></ul><h1>Variable version<code class="tsd-tag">Const</code></h1></div><div class="tsd-signature"><span class="tsd-kind-variable">version</span><span class="tsd-signature-symbol"> = &quot;53.14.0&quot;</span></div><div class="tsd-comment tsd-typography"><p>The current version of the Geocortex ArcGIS Extensions API.</p>
2
2
  </div><div class="tsd-comment tsd-typography"></div></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>@vertigis/arcgis-extensions</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><footer></footer><div class="overlay"></div></body></html>
@@ -1 +1 @@
1
- import{__decorate as e}from"tslib";import i from"@arcgis/core/core/Collection";import{serializable as t}from"../support/Serializable.js";import{notifyChange as s,onWatch as r,watch as a,watchEach as n}from"../support/observableUtils.js";import{isGroupLayer as o,layersAreEquivalent as l}from"../utilities/_layers.js";import{checkArg as y}from"../utilities/checkArg.js";import{getLogger as h}from"../utilities/log.js";import{onCollectionPropertyChange as d}from"../utilities/watch.js";import{_assignLayerExtensions as c,LayerExtension as p}from"./_LayerExtension.js";import{ExtensionBaseLayerListSettings as _}from"./support/LayerListSettings.js";import{LayerExtensionCollectionBase as u}from"./support/_LayerExtensionCollection.js";const x=h("GroupLayerExtension");let m=class extends p{_layerExtensions;_visibilityModeField;_isSwitchingGroupLayer=!1;get layer(){return super.layer}get layerExtensions(){return this._layerExtensions}get supportsSublayers(){return!0}get visibilityMode(){return this.layer?this.layer.visibilityMode:this._visibilityModeField||"independent"}set visibilityMode(e){this._visibilityModeField=e,this.layer&&(this.layer.visibilityMode=e)}get effectiveFullExtent(){return this.layerExtensions.initializedItems.length?this.layerExtensions.initializedItems.toArray().map((e=>e.layer.fullExtent)).reduce(((e,i)=>e?i?e.clone().union(i):e:i)):void 0}get effectiveMinScale(){const e=this.layerExtensions.initializedItems.map((e=>e.effectiveMinScale||1/0)).toArray(),i=Math.max(...e);return isFinite(i)?i:0}get effectiveMaxScale(){const e=this.layerExtensions.initializedItems.map((e=>e.effectiveMaxScale)).toArray(),i=Math.min(...e);return isFinite(i)?i:0}constructor(e){super(e),this._layerExtensions=this._createLayerExtensionCollection(),this._handles.add([r(this,"effectiveMinScale",(()=>n(this.layerExtensions,"[].effectiveMinScale",(()=>s(this,"effectiveMinScale")),{sync:!0}))),r(this,"effectiveMaxScale",(()=>n(this.layerExtensions,"[].effectiveMaxScale",(()=>s(this,"effectiveMaxScale")),{sync:!0}))),a(this,"layer",(()=>{this.layer&&void 0!==this._visibilityModeField&&(this.layer.visibilityMode=this._visibilityModeField)}))])}_getProjectWebmapJSON(){const e=super._getProjectWebmapJSON();return!e||this.dynamicallyAddedLayer||(e.layers=this.layerExtensions.toArray().filter((e=>e.layer)).map((e=>e._getProjectWebmapJSON()))),e}_setMapExtension(e){this.mapExtension!==e&&(super._setMapExtension(e),this._layerExtensions.onMapExtensionChanged())}async _switchLayer(e){if(e===this.layer)return;this._isSwitchingGroupLayer=!0;const i=new Map;this.layer&&this.layer.layers.forEach((e=>{i.set(e,this.layerExtensions.forLayer(e))})),await super._switchLayer(e);const t=[],s=new Set(i.keys());if(this.layer)for(const e of this.layer.layers.toArray()){const r=Array.from(s).filter((i=>l(i,e)));if(1!==r.length)continue;const a=r[0],n=i.get(a);n&&(s.delete(a),t.push((async()=>{await n._switchLayer(e),this.layerExtensions._register(n)})()))}const r=Array.from(s).map((e=>i.get(e))).filter((e=>!!e));t.push(...r.map((async e=>{this._layerExtensions._detach(e),await e.destroy()}))),await Promise.all(t),this.isInitialized&&await this._initializeChildren(),this._isSwitchingGroupLayer=!1}_getSerializableProperties(){const e=super._getSerializableProperties(),i={...e,layer:{...this._toPropertyDef(e.layer),default:{layerType:"GroupLayer"}},layerExtensions:{serializeModes:["initial","project"],deserialize:e=>{c(this.layerExtensions,e)}},visibilityMode:{...this._toPropertyDef(e.visibilityMode),isDefault:()=>void 0===this._visibilityModeField}};return delete i.visibilityMode.default,i}async _onInitialize(){await super._onInitialize(),this.layer.layers||(this.layer.layers=new i),this._layerExtensions.onParentInitialized()}async _postInitialize(){await super._postInitialize(),this._handles.add(d(this,"layer.layers",(async e=>{if(this._isSwitchingGroupLayer)return;const i=(e.added??[]).map((e=>this.layerExtensions.forLayer(e)));await Promise.all(i.map(this._onLayerAddedPostInitialize));const t=(e.removed??[]).map((e=>this._layerExtensions._forLayer(e)));await Promise.all(t.map((e=>e.destroy()))),t.forEach((e=>this.layerExtensions.remove(e)))})))}_onLayerAddedPostInitialize=async e=>{if(!this._isSwitchingGroupLayer)try{await e.initialize()}catch(i){x.error({message:`Error occurred while initializing layer extension for layer '${e.title??e.layer.id??e.id}'.`,error:i})}};async _onDestroy(){await Promise.all(this.layerExtensions.toArray().map((e=>e.destroy()))),this._layerExtensions.destroy(),await super._onDestroy()}*_initializableChildCollections(){yield*super._initializableChildCollections(),yield this.layerExtensions}_isSupportedLayer(e){return o(e)}_createLayerExtensionCollection(){return new GroupLayerExtensionCollection(this)}_createLayerListSettings(e){return new f(e,this)}};m=e([t],m);export{m as GroupLayerExtension};let f=class extends _{get _layerSupportsHideChildren(){return!0}get _esriLayer(){return this._extension.layer}get _listModePath(){return"layer.listMode"}get _supportsChildren(){return!0}};f=e([t],f);export class GroupLayerExtensionCollection extends u{get _mapExtension(){return this._parent.mapExtension}constructor(e){super(e,"layer.layers")}add(e,i){return y("layerX",e).isNotMissing(),e.parentLayerExtension&&e.parentLayerExtension!==this._parent&&e.parentLayerExtension.layerExtensions.remove(e),e._setParentLayerExtension(this._parent),super.add(e,i)}_onAdded(e){super._onAdded(e),e._setParentLayerExtension(this._parent)}_onRemoved(e){super._onRemoved(e),e._setParentLayerExtension(void 0)}}
1
+ import{__decorate as e}from"tslib";import i from"@arcgis/core/core/Collection";import{serializable as t}from"../support/Serializable.js";import{notifyChange as s,onWatch as r,watch as a,watchEach as n}from"../support/observableUtils.js";import{isGroupLayer as o,layersAreEquivalent as l}from"../utilities/_layers.js";import{checkArg as y}from"../utilities/checkArg.js";import{getLogger as h}from"../utilities/log.js";import{onCollectionPropertyChange as c}from"../utilities/watch.js";import{_assignLayerExtensions as d,LayerExtension as p}from"./_LayerExtension.js";import{ExtensionBaseLayerListSettings as _}from"./support/LayerListSettings.js";import{LayerExtensionCollectionBase as u}from"./support/_LayerExtensionCollection.js";const x=h("GroupLayerExtension");let m=class extends p{_layerExtensions;_visibilityModeField;_isSwitchingGroupLayer=!1;get layer(){return super.layer}get layerExtensions(){return this._layerExtensions}get supportsSublayers(){return!0}get visibilityMode(){return this.layer?this.layer.visibilityMode:this._visibilityModeField||"independent"}set visibilityMode(e){this._visibilityModeField=e,this.layer&&(this.layer.visibilityMode=e)}get effectiveFullExtent(){return this.layerExtensions.initializedItems.length?this.layerExtensions.initializedItems.toArray().map((e=>e.layer.fullExtent)).reduce(((e,i)=>e?i?e.clone().union(i):e:i)):void 0}get effectiveMinScale(){const e=this.parentLayerExtension?.effectiveMinScale??0,i=isFinite(this.layer.minScale)?this.layer.minScale:0;return 0===e||0===i?Math.max(e,i):Math.min(e,i)}get effectiveMaxScale(){const e=this.parentLayerExtension?.effectiveMaxScale??0,i=isFinite(this.layer.maxScale)?this.layer.maxScale:0;return Math.max(e,i)}constructor(e){super(e),this._layerExtensions=this._createLayerExtensionCollection(),this._handles.add([r(this,"effectiveMinScale",(()=>n(this.layerExtensions,"[].effectiveMinScale",(()=>s(this,"effectiveMinScale")),{sync:!0}))),r(this,"effectiveMaxScale",(()=>n(this.layerExtensions,"[].effectiveMaxScale",(()=>s(this,"effectiveMaxScale")),{sync:!0}))),a(this,"layer",(()=>{this.layer&&void 0!==this._visibilityModeField&&(this.layer.visibilityMode=this._visibilityModeField)}))])}_getProjectWebmapJSON(){const e=super._getProjectWebmapJSON();return!e||this.dynamicallyAddedLayer||(e.layers=this.layerExtensions.toArray().filter((e=>e.layer)).map((e=>e._getProjectWebmapJSON()))),e}_setMapExtension(e){this.mapExtension!==e&&(super._setMapExtension(e),this._layerExtensions.onMapExtensionChanged())}async _switchLayer(e){if(e===this.layer)return;this._isSwitchingGroupLayer=!0;const i=new Map;this.layer&&this.layer.layers.forEach((e=>{i.set(e,this.layerExtensions.forLayer(e))})),await super._switchLayer(e);const t=[],s=new Set(i.keys());if(this.layer)for(const e of this.layer.layers.toArray()){const r=Array.from(s).filter((i=>l(i,e)));if(1!==r.length)continue;const a=r[0],n=i.get(a);n&&(s.delete(a),t.push((async()=>{await n._switchLayer(e),this.layerExtensions._register(n)})()))}const r=Array.from(s).map((e=>i.get(e))).filter((e=>!!e));t.push(...r.map((async e=>{this._layerExtensions._detach(e),await e.destroy()}))),await Promise.all(t),this.isInitialized&&await this._initializeChildren(),this._isSwitchingGroupLayer=!1}_getSerializableProperties(){const e=super._getSerializableProperties(),i={...e,layer:{...this._toPropertyDef(e.layer),default:{layerType:"GroupLayer"}},layerExtensions:{serializeModes:["initial","project"],deserialize:e=>{d(this.layerExtensions,e)}},visibilityMode:{...this._toPropertyDef(e.visibilityMode),isDefault:()=>void 0===this._visibilityModeField}};return delete i.visibilityMode.default,i}async _onInitialize(){await super._onInitialize(),this.layer.layers||(this.layer.layers=new i),this._layerExtensions.onParentInitialized()}async _postInitialize(){await super._postInitialize(),this._handles.add(c(this,"layer.layers",(async e=>{if(this._isSwitchingGroupLayer)return;const i=(e.added??[]).map((e=>this.layerExtensions.forLayer(e)));await Promise.all(i.map(this._onLayerAddedPostInitialize));const t=(e.removed??[]).map((e=>this._layerExtensions._forLayer(e)));await Promise.all(t.map((e=>e.destroy()))),t.forEach((e=>this.layerExtensions.remove(e)))})))}_onLayerAddedPostInitialize=async e=>{if(!this._isSwitchingGroupLayer)try{await e.initialize()}catch(i){x.error({message:`Error occurred while initializing layer extension for layer '${e.title??e.layer.id??e.id}'.`,error:i})}};async _onDestroy(){await Promise.all(this.layerExtensions.toArray().map((e=>e.destroy()))),this._layerExtensions.destroy(),await super._onDestroy()}*_initializableChildCollections(){yield*super._initializableChildCollections(),yield this.layerExtensions}_isSupportedLayer(e){return o(e)}_createLayerExtensionCollection(){return new GroupLayerExtensionCollection(this)}_createLayerListSettings(e){return new f(e,this)}};m=e([t],m);export{m as GroupLayerExtension};let f=class extends _{get _layerSupportsHideChildren(){return!0}get _esriLayer(){return this._extension.layer}get _listModePath(){return"layer.listMode"}get _supportsChildren(){return!0}};f=e([t],f);export class GroupLayerExtensionCollection extends u{get _mapExtension(){return this._parent.mapExtension}constructor(e){super(e,"layer.layers")}add(e,i){return y("layerX",e).isNotMissing(),e.parentLayerExtension&&e.parentLayerExtension!==this._parent&&e.parentLayerExtension.layerExtensions.remove(e),e._setParentLayerExtension(this._parent),super.add(e,i)}_onAdded(e){super._onAdded(e),e._setParentLayerExtension(this._parent)}_onRemoved(e){super._onRemoved(e),e._setParentLayerExtension(void 0)}}
@@ -1 +1 @@
1
- import{__decorate as e}from"tslib";import t from"@arcgis/core/core/Collection";import{ArgumentError as i}from"../ArgumentError.js";import{InvalidOperationError as s}from"../InvalidOperationError.js";import{ItemType as r}from"../ItemType.js";import{FeatureSourceBase as a}from"../data/FeatureSourceBase.js";import{FieldExtension as n}from"../data/FieldExtension.js";import{PopupContentExtension as o}from"../data/PopupContentExtension.js";import{Schema as l}from"../data/Schema.js";import{applyJsonToLayer as y,getLayerJsonType as h,jsonToLayer as d,layerToJson as u}from"../json/LayerJson.js";import{DefaultArcGISRequestHelper as p}from"../support/ArcGISRequestHelper.js";import{ReadOnlyInitializableCollection as c}from"../support/ReadOnlyInitializableCollection.js";import{serializable as f}from"../support/Serializable.js";import{createIHandle as _,notifyChange as b,onWatch as m,watch as g,watchEach as x}from"../support/observableUtils.js";import E from"../utilities/_ReferenceCountedHandle.js";import{getEquivalencyTypeForLayers as S,getLayerUrl as L,isLayer as v}from"../utilities/_layers.js";import{checkArg as w}from"../utilities/checkArg.js";import{compare as M}from"../utilities/collection.js";import{load as I}from"../utilities/esri.js";import{isGroupLayerExtension as A}from"../utilities/extensions.js";import{hasMmapLayer as P}from"../utilities/layers.js";import{getLogger as C}from"../utilities/log.js";import{deepClone as j,objectKeys as z}from"../utilities/object.js";import{toPortalItem as H}from"../utilities/portal.js";import{onCollectionPropertyChange as T}from"../utilities/watch.js";import{_assignSublayerExtensions as R}from"./_SublayerExtension.js";import{ExtensionBaseLayerListSettings as O,fromLayerListMode as V}from"./support/LayerListSettings.js";import{SublayerExtensionCollectionBase as F}from"./support/_SublayerExtensionCollection.js";const D="Invalid type of layer for this type of layer extension.",B="This type of layer does not have features.",$="This type of layer cannot have sublayers.",N=Object.freeze({supportsAdd:!1,supportsUpdate:!1,supportsDelete:!1,supportsEditing:!1,supportsQuery:!1,supportsAttachmentEditing:!1,supportsStandardizedQueries:!1});export class LayerExtension extends a{get layer(){return this._layer}get mapExtension(){return this._mapExtension}get basemapExtension(){return this._basemapExtension}get groundExtension(){return this._groundExtension}get parentLayerExtension(){return this._parentLayerExtension}get hasFeatures(){return!1}get capabilities(){return this._capabilities()}get renderer(){}get visibilityMode(){return this._visibilityMode}set visibilityMode(e){this._visibilityMode=e,"exclusive"===e&&this._ensureAtMostOneChildSublayerVisible()}get sublayerExtensions(){return this._sublayerExtensions}get requestHelper(){return this._requestHelper||(this._requestHelper=new p),this._requestHelper}set requestHelper(e){this._requestHelper=e}get title(){return this.layer?.title??this._deferredLayerProperties?.title??("string"==typeof this._deferredLayerProperties?.$ref?this._deferredLayerProperties?.$ref:this._deferredLayerProperties?.$ref?.title??this._deferredLayerProperties?.$ref?.id)??"Layer"}get supportsSublayers(){return!1}get effectiveMinScale(){return this.layer&&this.layer.minScale||0}get effectiveMaxScale(){return this.layer&&this.layer.maxScale||0}get isEffectivelyVisible(){const e=!!this.layer&&this.layer.visible;return this.parentLayerExtension?this.parentLayerExtension.isEffectivelyVisible&&e:e}get effectiveFullExtent(){return this.layer?this.layer.fullExtent:void 0}get canChangeScale(){return!0}get canChangeOpacity(){return!0}get canChangeLabels(){return!1}get canChangeRenderer(){return!1}get canChangeDefinitionExpression(){return!1}get initialDefinitionExpression(){return this._initialDefinitionExpression}get initialRenderer(){return this._initialRenderer}get initialVisibility(){return this._initialVisibility??this.layer?.visible??!1}get _layerId(){return this.layer?.id??this._deferredLayerProperties?.$ref?.id}get _layerSupportsHideChildren(){return this.supportsSublayers}get _sublayers(){if(this.supportsSublayers)return this.layer?this.layer.sublayers:void 0}static factory;get dynamicallyAddedLayer(){return this._dynamicallyAddedLayer}set dynamicallyAddedLayer(e){this._dynamicallyAddedLayer=e}static _layerWatchHandlesKey="layer-extension-layer-watch-handles";tpkSource;layerListSettings;allSublayerExtensions;get sublayersAreReadOnly(){return!0}_itemType=r.LAYER_EXTENSION;_mapExtension;_basemapExtension;_groundExtension;_parentLayerExtension;_sublayerExtensions;_layer;_dynamicallyAddedLayer=!1;_isSwitchingLayer=!1;_deferredLayerProperties;_requestHelper;_initialDefinitionExpression;_initialRenderer;_initialVisibility;_visibilityMode="independent";_portalItem;constructor(e){super(e);const t={...this.getDefaults(),...e};w("properties.layer",t.layer).isNotMissing();const{layer:i}=t;let s;if(i?.hasOwnProperty("listMode")&&(s=V(i.listMode)),this.layerListSettings=this._createLayerListSettings({...s,...t.layerListSettings}),v(i))w("properties.layer",i).satisfies((e=>this._isSupportedLayer(e)),D),this._setLayer(i);else if(i){if(i.$portalItem){const e=i.$portalItem;this._portalItem=H(e)}this._deferredLayerProperties=i}this._sublayerExtensions=this._createSublayerExtensionCollection(),this.allSublayerExtensions=new W(this),this._handles.add([m(this,"isEffectivelyVisible",(()=>g(this,"parentLayerExtension.isEffectivelyVisible",(()=>b(this,"isEffectivelyVisible")),{sync:!0}))),m(this,"_sublayers",(()=>g(this,"layer.sublayers",(()=>b(this,"_sublayers")),{sync:!0})))])}static create(e){if(!LayerExtension.factory)throw new s("Cannot create layer extension: no layer extension factory has been registered.");return LayerExtension.factory.create(e)}static async fromPortalItem(e,t){w("portalItemLike",e).isNotMissing();const s=t??{};w("layerExtensionProperties.layer",s.layer).satisfies((e=>!v(e)));const r={...s.layer};w("layerExtensionProperties.layer.$ref",r.$ref).satisfies((e=>null==e));const a=new p,n=H(e);let o;await I(n);const l=n.typeKeywords??"";if("Map Service"===n.type)o=l.includes("Tiled")||l.includes("Hosted Service")?"ArcGISTiledMapServiceLayer":"ArcGISMapServiceLayer";else if("Feature Service"===n.type)o=l.includes("SubtypeGroupLayer")?"SubtypeGroupLayer":"ArcGISFeatureLayer";else if("Image Service"===n.type){const e=await LayerExtension._getLayerData(n.url,a);e.cacheType?"Map"===e.cacheType||l.includes("Tiled Imagery")?o="ArcGISTiledImageServiceLayer":"Elevation"===e.cacheType||l.includes("Elevation 3D Layer")?o="ArcGISTiledElevationServiceLayer":"Raster"===e.cacheType&&(o="ArcGISImageServiceLayer"):o=e.singleFusedMapCache||e.tileInfo||l.includes("Hosted Service")?"ArcGISTiledImageServiceLayer":"ArcGISImageServiceLayer"}else if("CSV"===n.type)o="CSV";else if("KML"===n.type)o="KML";else if("Scene Service"===n.type)l.includes("3DObject")||l.includes("Point")?o="ArcGISSceneServiceLayer":l.includes("IntegratedMesh")?o="IntegratedMeshLayer":l.includes("PointCloud")?o="PointCloudLayer":l.includes("Building")&&(o="BuildingSceneLayer");else if("Stream Service"===n.type)o="ArcGISStreamLayer";else if("Vector Tile Service"===n.type)o="VectorTileLayer";else if("Feature Collection"===n.type){o="ArcGISFeatureLayer";const e=await n.fetchData();r.featureCollection=e}else if("WFS"===n.type){o="WFS";const e=await n.fetchData();Object.assign(r,e)}else if("WMTS"===n.type){o="WebTiledLayer";const e=await n.fetchData();Object.assign(r,e)}else if("WMS"===n.type){o="WMS";const e=await n.fetchData();Object.assign(r,e)}if(!o)throw new i("portalItem","Could not determine correct type of LayerExtension to create from portal item");if(r.layerType&&r.layerType!==o)throw new i("layerExtensionProperties.layer.layerType","Layer type defined in layer properties does not match layer type from portal item");return r.layerType=o,r.$portalItem=n,s.layer=r,LayerExtension.create(s)}static async _getLayerData(e,t){const i=await t.request(e,{query:{f:"json"}});if(!i?.data)throw new Error(`Response to request for url ${e} was invalid.`);return i.data}getFeatures(e,t){if(!this.hasFeatures)throw new s(B);return super.getFeatures(e,t)}getFullExtent(){return this.effectiveFullExtent}async addFeatures(e,t){if(w("features",e).isNotMissing(),!this.hasFeatures)throw new s(B);await super.addFeatures(e,t)}async updateFeatures(e,t){if(w("features",e).isNotMissing(),!this.hasFeatures)throw new s(B);await super.updateFeatures(e,t)}async deleteFeatures(e,t){if(w("features",e).isNotMissing(),!this.hasFeatures)throw new s(B);await super.deleteFeatures(e,t)}async _createBackingLayer(){this._portalItem||this.layer||this._deferredLayerProperties?.$ref?!this.layer&&this._portalItem&&this._setLayer(await this._createLayer(this.getDefaults().layer)):(this._setLayer(await this._createLayer(this._deferredLayerProperties)),w("properties.layer",this._layer).satisfies((e=>this._isSupportedLayer(e)),D),this._deferredLayerProperties=void 0)}_setMapExtension(e){if(this.mapExtension===e)return;const t=this.mapExtension;this._mapExtension=e,t&&this.featureSettings.formatSettings.parent===t.formatSettings&&(this.featureSettings.formatSettings.parent=void 0),e&&(this.featureSettings.formatSettings.parent||(this.featureSettings.formatSettings.parent=e.formatSettings)),this._resolveLayer(),b(this,"mapExtension")}_setBasemapExtension(e){this.basemapExtension!==e&&(this._basemapExtension=e,this._resolveLayer(),e&&(this.taskSettings.parent=e.taskSettings),b(this,"basemapExtension"))}_setGroundExtension(e){this.groundExtension!==e&&(this._groundExtension=e,this._resolveLayer(),e&&(this.taskSettings.parent=e.taskSettings),b(this,"groundExtension"))}_setParentLayerExtension(e){if(this.parentLayerExtension===e)return;const t=this._parentLayerExtension;this._parentLayerExtension=e,t&&(this.featureSettings.formatSettings.parent===t.featureSettings.formatSettings&&(this.featureSettings.formatSettings.parent=this.mapExtension?this.mapExtension.formatSettings:void 0),this.taskSettings.parent===t.taskSettings&&(this.taskSettings.parent=void 0)),e&&((!this.featureSettings.formatSettings.parent||this.mapExtension&&this.featureSettings.formatSettings.parent===this.mapExtension.formatSettings)&&(this.featureSettings.formatSettings.parent=e.featureSettings.formatSettings),this.taskSettings.parent||(this.taskSettings.parent=e.taskSettings)),this._resolveLayer(),b(this,"parentLayerExtension")}_resolveLayer(e){if(this.layer||!this._deferredLayerProperties)return;const t=e??this.basemapExtension?.basemap?.baseLayers??this.groundExtension?.ground?.layers??this.parentLayerExtension?.layer?.layers??this.mapExtension?.map.layers;if(!t)return;const i=[];let s;for(const e of t){const t=S(e,this._deferredLayerProperties);if("none"!==t){if("solid"===t){s=e;break}i.push(e)}}s||1!==i.length||(s=i[0]),s&&this._isSupportedLayer(s)&&(this._setLayer(s),this._deferredLayerProperties.$portalItem&&K().warn("LayerExtension defined with both $ref and $portalItem. Ignoring $portalItem."))}async _switchLayer(e){if(e===this.layer)return;w("newLayer",e).isNotMissing().satisfies((e=>this._isSupportedLayer(e)),D),this._isSwitchingLayer=!0,this.isInitialized&&await I(e);const t=new Map;if(this._sublayers)for(const e of this._sublayers.toArray())t.set(e.id,this.sublayerExtensions.forSublayer(e));e.visible=this.layer.visible,e.opacity=this.layer.opacity,e.listMode=this.layer.listMode,e.hasOwnProperty("labelsVisible")&&this.layer.hasOwnProperty("labelsVisible")&&(e.labelsVisible=this.layer.labelsVisible);const i=this.schema.fieldExtensions.toArray(),s=this.featureSettings.popupContentExtensions.toArray();this._setLayer(e);const r=[];i.forEach((e=>{const t=this.schema.fields.find((t=>n.matchesRef(e,{$ref:t.name})));t?e._switchField(t):(e._setSchema(void 0),r.push(e.destroy()))})),s.forEach(((e,t)=>{const i=this.featureSettings.popupContentExtensions.find((e=>o.matchesRef(s,t,e.toJSON().content)));i?e._switchContent(i.content):(e._setFeatureSettings(void 0),r.push(e.destroy()))}));const a=new Set;if(this._sublayers){const e=this._sublayers.filter((e=>t.has(e.id))).toArray();r.push(...e.map((async e=>{const i=t.get(e.id);i&&(a.add(i),await i._switchSublayer(e),this._sublayerExtensions._register(i))})))}const l=[];for(const e of t.values())e&&!a.has(e)&&l.push(e);r.push(...l.map((async e=>{this._sublayerExtensions._detach(e),await e.destroy()}))),await Promise.all(r),this.isInitialized&&await this._initializeChildren(),this._isSwitchingLayer=!1}_getProjectWebmapJSON(){if(!this.layer)return;let e=u(this.layer);if(!this.dynamicallyAddedLayer){const{id:t,title:i,layerType:s,opacity:r}=e;e={id:t,title:i,layerType:s,visibility:this.layer.visible,opacity:r}}return e}_onSublayerAddedPostInitialize=async e=>{if(!this._isSwitchingLayer)try{await e.initialize()}catch(t){K().error({message:`Error occurred while initializing sublayer extension for sublayer '${e.title??e.sublayer.id??e.id}'.`,error:t})}};async _onDestroy(){await Promise.all(this.sublayerExtensions.map((e=>e.destroy()))),this._sublayerExtensions.destroy(),this.allSublayerExtensions.destroy(),await super._onDestroy()}_getSerializableProperties(){return{...super._getSerializableProperties(),iconUrl:{serializeModes:["initial","project"],serialize:e=>"project"!==e||this.dynamicallyAddedLayer?this.iconUrl:this.getDefault("iconUrl")},visibilityMode:{serializeModes:["initial","project"],serialize:e=>"project"!==e||this.dynamicallyAddedLayer?this.visibilityMode:this.getDefault("visibilityMode"),default:"independent"},tpkSource:{serializeModes:["initial"]},layerListSettings:{serializeModes:["initial","project"],serialize:e=>"project"!==e||this.dynamicallyAddedLayer?this.layerListSettings:this.getDefault("layerListSettings")},sublayerExtensions:{serializeModes:["initial","project"],serialize:e=>this.sublayerExtensions.map((e=>e.toItemUri())).toArray(),deserialize:e=>{R(this.sublayerExtensions,e,(e=>this._createSublayerExtension(e)))}},layer:{serializeModes:["initial","project"],serialize:e=>{if(this.layer){if((this._mapExtension||this._parentLayerExtension||this._basemapExtension||this._groundExtension)&&(this._layer.id||this._layer.title)){const e=h(this._layer),t=this._getSerializableRefLayerProperties(),i=L(this._layer),s=i?{url:i}:{};return{$ref:{id:this._layer.id,title:this._layer.title,subtype:this._getSerializableLayerType(),...s},layerType:e,...t}}return u(this.layer)}return this._deferredLayerProperties?j(this._deferredLayerProperties):void 0},isDefault:()=>{throw new Error("Missing implementation for _getSerializableProperties() > layer > default. Subclasses of LayerExtension must implement this.")},deserialize:e=>{if(v(e)){if(e!==this.layer)throw new Error("Property 'layer' is read-only.")}else if(e){if(this._layer)return this._applyLayerProperties(e,this.layer);this._deferredLayerProperties&&(this._deferredLayerProperties={...this._deferredLayerProperties,...e})}}},dynamicallyAddedLayer:{serializeModes:["project"],default:!1},requestHelper:{serialize:!1}}}_getSerializableLayerType(){}_getSerializableRefLayerProperties(){return{}}_createSublayerExtension(e){if(!this.supportsSublayers)throw new s($);throw new Error("Missing implementation for _createSublayerExtension(). Subclasses of LayerExtension that support sublayers must implement this.")}async _onInitialize(){if(await super._onInitialize(),await this._createBackingLayer(),this._portalItem&&(await I(this._portalItem),await this._applyPortalItemProperties(this._portalItem),this.layer.title=this._portalItem.title,this.layer.portalItem=this._portalItem,this.iconUrl||(this.iconUrl=this._portalItem.thumbnailUrl),await this._applyLayerProperties(this._deferredLayerProperties,this.layer),this._deferredLayerProperties=void 0),this._resolveLayer(),!this.layer){const e=this._deferredLayerProperties.$ref;throw this._mapExtension||this._parentLayerExtension||this._basemapExtension||this._groundExtension?new s(`No layer found matching reference "${"string"==typeof e?e:JSON.stringify(e)}".`):new s("Cannot resolve layer reference: missing parent.")}this._deferredLayerProperties&&(await this._applyLayerProperties(this._deferredLayerProperties,this.layer),this._deferredLayerProperties=void 0),await this._initializeLayer(),await I(this.layer),this.supportsSublayers&&!this.layer.sublayers&&this.layer._set("sublayers",new t),this._initialDefinitionExpression="definitionExpression"in this.layer?this.layer.definitionExpression:void 0,this._initialRenderer=this.renderer?.clone(),this._initialVisibility=this.layer.visible,this._sublayerExtensions.onParentInitialized()}async _postInitialize(){await super._postInitialize(),this.layerListSettings.onLayerExtensionInitialized(),this.supportsSublayers&&this._handles.add(T(this,"layer.sublayers",(async e=>{if(this._isSwitchingLayer)return;const t=(e.added??[]).map((e=>this.sublayerExtensions.forSublayer(e)));await Promise.all(t.map(this._onSublayerAddedPostInitialize))})))}_applyPortalItemProperties(e){throw new s("Cannot use this type of layer extension with a PortalItem.")}async _initializeLayer(){}_createLayerListSettings(e){return new G(e,this)}_createSublayerExtensionCollection(){return new k(this)}_capabilities(){return N}*_initializableChildCollections(){yield*super._initializableChildCollections(),yield this.sublayerExtensions}async _createLayer(e){return d(e)}_applyLayerProperties(e,t){w("layerJson",e).isNotMissing();const i=e.layerType||e.type;return w("layerJson.layerType",i).satisfies((e=>!e||e===this.getDefault("layer")?.layerType)),w("layer",t).isNotMissing().satisfies((e=>this._isSupportedLayer(e))),y(e,t)}_setLayer(e){if(this._layer=e,this._handles.remove(LayerExtension._layerWatchHandlesKey),this._handles.add([g(e,"visible",((e,t,i)=>{this._onVisibleChanged(e),this.mapExtension?.emit("layer-visibility-change",i)})),m(this,"effectiveMinScale",(()=>g(this.layer,"minScale",(()=>b(this,"effectiveMinScale")),{sync:!0}))),m(this,"effectiveMaxScale",(()=>g(this.layer,"maxScale",(()=>b(this,"effectiveMaxScale")),{sync:!0}))),m(this,"title",(()=>g(this.layer,"title",(()=>b(this,"title")),{sync:!0})))],LayerExtension._layerWatchHandlesKey),"definitionExpression"in e&&this._handles.add(g(e,"definitionExpression",((e,t,i)=>{this.mapExtension?.emit("layer-definition-expression-change",i)})),LayerExtension._layerWatchHandlesKey),this.supportsSublayers)if(this._sublayers)this._setupSublayersHandles();else{const t=g(e,"sublayers",(()=>{this._setupSublayersHandles()}),{sync:!0,once:!0});this._handles.add(t,LayerExtension._layerWatchHandlesKey)}b(this,"layer"),b(this,"title"),b(this,"effectiveMinScale"),b(this,"effectiveMaxScale"),b(this,"isEffectivelyVisible")}_setupSublayersHandles(){this._handles.add([this._sublayers.on("after-add",this._onSublayersAfterAdd),this._sublayers.on("after-remove",this._onSublayersAfterRemove),x(this._sublayers,"[].visible",this._onSublayersSublayerVisibleChanged,{sync:!0})],LayerExtension._layerWatchHandlesKey)}_onVisibleChanged=e=>{if("inherited"===this.visibilityMode&&this.supportsSublayers&&this._sublayers)for(const t of this._sublayers.toArray())t.visible=e;b(this,"isEffectivelyVisible")};_onSublayersSublayerVisibleChanged=(e,t,i)=>{e&&"exclusive"===this.visibilityMode&&this._ensureAChildSublayerVisible(i)};_onSublayersAfterAdd=e=>{1!==this._sublayers.length||e.item.visible||"exclusive"!==this.visibilityMode?e.item.visible&&"exclusive"===this.visibilityMode&&(e.item.visible=!1):e.item.visible=!0};_onSublayersAfterRemove=e=>{0!==this._sublayers.length&&"exclusive"===this.visibilityMode&&e.item.visible&&this._ensureAChildSublayerVisible(this._sublayers.getItemAt(0))};_ensureAChildSublayerVisible(e){for(const t of this._sublayers.toArray())t!==e&&(t.visible=!1)}_ensureAtMostOneChildSublayerVisible(){this.layer&&this._sublayers&&this._ensureAChildSublayerVisible(this._sublayers.find((e=>e.visible)))}}class k extends F{constructor(e){super(e,"_sublayers"),this._layerExtension=e}add(e,t){if(w("sublayerX",e).isNotMissing(),!this._layerExtension.supportsSublayers)throw new s($);const i=e.sublayer?e.sublayer.layer:void 0;return i&&i!==this._layerExtension.layer&&i.sublayers.remove(e.sublayer),super.add(e,t)}}class W extends c{get _collection(){return this._layerExtension.sublayerExtensions.flatten((e=>e.sublayerExtensions))}_layerExtension;_onChangeLayerExtensionsHandle=new E((()=>{const e=new WeakMap,i=new Set,s=r=>{const a=new t(r.added).flatten((e=>e.sublayerExtensions)),n=new t(r.moved).flatten((e=>e.sublayerExtensions)),o=new t(r.removed).flatten((e=>e.sublayerExtensions));for(const t of a)if(!e.has(t)){const r=t.sublayerExtensions.on("change",s);e.set(t,r),i.add(r)}for(const t of o){const s=e.get(t);s&&(s.remove(),e.delete(t),i.delete(s))}this.emit("change",{added:a.toArray(),moved:n.toArray(),removed:o.toArray()})};i.add(this._layerExtension.sublayerExtensions.on("change",s));const r=this._layerExtension.sublayerExtensions.flatten((e=>e.sublayerExtensions));for(const t of r){const r=t.sublayerExtensions.on("change",s);e.set(t,r),i.add(r)}return _(i)}));_onAfterAddLayerExtensionsHandle=new E((()=>{const e=new WeakMap,t=new Set,i=i=>{const s=e.get(i);s&&(s.remove(),e.delete(i),t.delete(s))},s=e=>{const t=e.item,s=t.sublayerExtensions.flatten((e=>e.sublayerExtensions));for(const e of s)i(e);i(t)},r=i=>{this.emit("after-add",{...i});const a=i.item.sublayerExtensions.flatten((e=>e.sublayerExtensions));for(const n of a)if(this.emit("after-add",{...i,item:n}),!e.has(n)){const i=n.sublayerExtensions.on("after-add",r),a=n.sublayerExtensions.on("after-remove",s),o=_([i,a]);e.set(n,o),t.add(o)}};t.add(this._layerExtension.sublayerExtensions.on("after-add",r)),t.add(this._layerExtension.sublayerExtensions.on("after-remove",s));const a=this._layerExtension.sublayerExtensions.flatten((e=>e.sublayerExtensions));for(const i of a){const a=i.sublayerExtensions.on("after-add",r),n=i.sublayerExtensions.on("after-remove",s),o=_([a,n]);e.set(i,o),t.add(o)}return _(t)}));_onAfterRemoveLayerExtensionsHandle=new E((()=>{const e=new WeakMap,t=new Set,i=i=>{const s=e.get(i);s&&(s.remove(),e.delete(i),t.delete(s))},s=e=>{this.emit("after-remove",{...e});const t=e.item,s=t.sublayerExtensions.flatten((e=>e.sublayerExtensions));for(const t of s)this.emit("after-remove",{...e,item:t}),i(t);i(t)},r=i=>{const a=i.item,n=a.sublayerExtensions.on("after-add",r),o=a.sublayerExtensions.on("after-remove",s),l=_([n,o]);e.set(a,l),t.add(l)};t.add(this._layerExtension.sublayerExtensions.on("after-remove",s)),t.add(this._layerExtension.sublayerExtensions.on("after-add",r));const a=this._layerExtension.sublayerExtensions.flatten((e=>e.sublayerExtensions));for(const i of a){const a=i.sublayerExtensions.on("after-add",r),n=i.sublayerExtensions.on("after-remove",s),o=_([a,n]);e.set(i,o),t.add(o)}return _(t)}));constructor(e){super(),this._layerExtension=e}destroy(){this._onChangeLayerExtensionsHandle.destroy(),this._onAfterAddLayerExtensionsHandle.destroy(),this._onAfterRemoveLayerExtensionsHandle.destroy(),super.destroy()}on(e,t){const i=[];return"change"===e?i.push(this._onChangeLayerExtensionsHandle.add()):"after-add"===e?i.push(this._onAfterAddLayerExtensionsHandle.add()):"after-remove"===e&&i.push(this._onAfterRemoveLayerExtensionsHandle.add()),i.push(super.on(e,t)),_(i)}findById(e){return w("id",e).isNotMissing(),this.find((t=>t.id===e))}findBySublayerId(e){return w("id",e).isNotMissing(),this.find((t=>t._sublayerId===e))}forSublayer(e){return w("sublayer",e).isNotMissing(),this.findBySublayerId(e.id)}_itemIsInitialized(e){return super._itemIsInitialized(e)&&!!e.sublayer}}let G=class extends O{get _esriLayer(){return this._extension.layer}get _listModePath(){return"layer.listMode"}get _supportsChildren(){return this._extension.supportsSublayers}};G=e([f],G);export{G as LayerExtensionLayerListSettings};export function toBindingOptions(e){return"object"==typeof e?e:{property:e}}let q=class extends l{_layerExtension;_layerBindings=new Map;constructor(e){super(),this._layerExtension=e,this._bindSettingsToLayerProperties(),e.layer?this._onLayerResolved(e.layer):this._handles.add(g(e,"layer",(()=>{this._onLayerResolved(e.layer)}),{sync:!0,once:!0}))}_getPropertyBindings(){return{}}_hasSettingIncludingAncestor(e){return!(!this._layerBindings.has(e)||!this._layerExtension.layer)||super._hasSettingIncludingAncestor(e)}_getSetting(e,t){if(this._layerBindings.has(e)){const t=toBindingOptions(this._layerBindings.get(e));if(t.hasOwnProperty("value"))return t.value;if(this._layerExtension.layer)return this._layerExtension.layer[t.property]}return super._getSetting(e,t)}_setSetting(e,t){if(this._layerBindings.has(e)){const i=toBindingOptions(this._layerBindings.get(e));if(i.readonly||i.hasOwnProperty("value"))throw new s(ERR_SCHEMA_READ_ONLY);if(this._layerExtension.layer)return void(this._layerExtension.layer[i.property]=t)}super._setSetting(e,t)}_bindSettingsToLayerProperties(){const e=this._getPropertyBindings();for(const t of z(e)){const i=toBindingOptions(e[t]);this._layerBindings.set(t,i),i.hasOwnProperty("value")||this._handles.add(m(this,t,(()=>g(this._layerExtension,`layer.${String(i.property)}`,(()=>b(this,t)),{sync:!i.hasOwnProperty("sync")||i.sync}))))}}_onLayerResolved(e){for(const t of this._layerBindings.keys())this.isModified(t)&&(e[t]=this[t],this.reset(t))}};q=e([f],q);export{q as LayerExtensionSchema};export function _assignLayerExtensions(e,t){return M(e,t,{onNew:(t,i)=>{e.add(t instanceof LayerExtension?t:LayerExtension.create(t),U(t)?void 0:i)},onMatch:(t,i,s,r)=>{i instanceof LayerExtension||t.assignProperties(i),s===r||U(i)||e.reorder(t,r)},onMissing:t=>{(P([t])||A(t)&&0===t.layerExtensions.toArray().length)&&e.remove(t)},equals:(e,t)=>{const i="solid"===S(e.layer,t.layer);return t instanceof LayerExtension?e===t||i:i||e.id===t.id}})}function K(){return C("geocortex.api.mapping.LayerExtension")}function U(e){return e instanceof LayerExtension?!!e._deferredLayerProperties?.$ref:!v(e.layer)&&!!e.layer?.$ref}let J=class extends q{_setSetting(e,t){if(this._layerBindings.has(e))throw new s(ERR_SCHEMA_READ_ONLY);super._setSetting(e,t)}};J=e([f],J);export{J as LayerExtensionReadOnlySchema};export const ERR_SCHEMA_READ_ONLY="This schema property is read-only.";
1
+ import{__decorate as e}from"tslib";import t from"@arcgis/core/core/Collection";import{ArgumentError as i}from"../ArgumentError.js";import{InvalidOperationError as s}from"../InvalidOperationError.js";import{ItemType as r}from"../ItemType.js";import{FeatureSourceBase as a}from"../data/FeatureSourceBase.js";import{FieldExtension as n}from"../data/FieldExtension.js";import{PopupContentExtension as o}from"../data/PopupContentExtension.js";import{Schema as l}from"../data/Schema.js";import{applyJsonToLayer as y,getLayerJsonType as h,jsonToLayer as d,layerToJson as u}from"../json/LayerJson.js";import{DefaultArcGISRequestHelper as p}from"../support/ArcGISRequestHelper.js";import{ReadOnlyInitializableCollection as c}from"../support/ReadOnlyInitializableCollection.js";import{serializable as f}from"../support/Serializable.js";import{createIHandle as _,notifyChange as b,onWatch as m,watch as g,watchEach as x}from"../support/observableUtils.js";import E from"../utilities/_ReferenceCountedHandle.js";import{getEquivalencyTypeForLayers as S,getLayerUrl as L,isLayer as v}from"../utilities/_layers.js";import{checkArg as w}from"../utilities/checkArg.js";import{compare as M}from"../utilities/collection.js";import{load as I}from"../utilities/esri.js";import{isGroupLayerExtension as A}from"../utilities/extensions.js";import{hasMmapLayer as P}from"../utilities/layers.js";import{getLogger as C}from"../utilities/log.js";import{deepClone as j,objectKeys as z}from"../utilities/object.js";import{toPortalItem as H}from"../utilities/portal.js";import{onCollectionPropertyChange as T}from"../utilities/watch.js";import{_assignSublayerExtensions as R}from"./_SublayerExtension.js";import{ExtensionBaseLayerListSettings as O,fromLayerListMode as V}from"./support/LayerListSettings.js";import{SublayerExtensionCollectionBase as F}from"./support/_SublayerExtensionCollection.js";const D="Invalid type of layer for this type of layer extension.",B="This type of layer does not have features.",$="This type of layer cannot have sublayers.",N=Object.freeze({supportsAdd:!1,supportsUpdate:!1,supportsDelete:!1,supportsEditing:!1,supportsQuery:!1,supportsAttachmentEditing:!1,supportsStandardizedQueries:!1});export class LayerExtension extends a{get layer(){return this._layer}get mapExtension(){return this._mapExtension}get basemapExtension(){return this._basemapExtension}get groundExtension(){return this._groundExtension}get parentLayerExtension(){return this._parentLayerExtension}get hasFeatures(){return!1}get capabilities(){return this._capabilities()}get renderer(){}get visibilityMode(){return this._visibilityMode}set visibilityMode(e){this._visibilityMode=e,"exclusive"===e&&this._ensureAtMostOneChildSublayerVisible()}get sublayerExtensions(){return this._sublayerExtensions}get requestHelper(){return this._requestHelper||(this._requestHelper=new p),this._requestHelper}set requestHelper(e){this._requestHelper=e}get title(){return this.layer?.title??this._deferredLayerProperties?.title??("string"==typeof this._deferredLayerProperties?.$ref?this._deferredLayerProperties?.$ref:this._deferredLayerProperties?.$ref?.title??this._deferredLayerProperties?.$ref?.id)??"Layer"}get supportsSublayers(){return!1}get effectiveMinScale(){const e=this.parentLayerExtension?.effectiveMinScale??0,t=this.layer?.minScale??0;return e&&t?Math.min(e,t):Math.max(e,t)}get effectiveMaxScale(){const e=this.parentLayerExtension?.effectiveMaxScale??0,t=this.layer?.maxScale??0;return Math.max(e,t)}get isEffectivelyVisible(){const e=!!this.layer&&this.layer.visible;return this.parentLayerExtension?this.parentLayerExtension.isEffectivelyVisible&&e:e}get effectiveFullExtent(){return this.layer?this.layer.fullExtent:void 0}get canChangeScale(){return!0}get canChangeOpacity(){return!0}get canChangeLabels(){return!1}get canChangeRenderer(){return!1}get canChangeDefinitionExpression(){return!1}get initialDefinitionExpression(){return this._initialDefinitionExpression}get initialRenderer(){return this._initialRenderer}get initialVisibility(){return this._initialVisibility??this.layer?.visible??!1}get _layerId(){return this.layer?.id??this._deferredLayerProperties?.$ref?.id}get _layerSupportsHideChildren(){return this.supportsSublayers}get _sublayers(){if(this.supportsSublayers)return this.layer?this.layer.sublayers:void 0}static factory;get dynamicallyAddedLayer(){return this._dynamicallyAddedLayer}set dynamicallyAddedLayer(e){this._dynamicallyAddedLayer=e}static _layerWatchHandlesKey="layer-extension-layer-watch-handles";tpkSource;layerListSettings;allSublayerExtensions;get sublayersAreReadOnly(){return!0}_itemType=r.LAYER_EXTENSION;_mapExtension;_basemapExtension;_groundExtension;_parentLayerExtension;_sublayerExtensions;_layer;_dynamicallyAddedLayer=!1;_isSwitchingLayer=!1;_deferredLayerProperties;_requestHelper;_initialDefinitionExpression;_initialRenderer;_initialVisibility;_visibilityMode="independent";_portalItem;constructor(e){super(e);const t={...this.getDefaults(),...e};w("properties.layer",t.layer).isNotMissing();const{layer:i}=t;let s;if(i?.hasOwnProperty("listMode")&&(s=V(i.listMode)),this.layerListSettings=this._createLayerListSettings({...s,...t.layerListSettings}),v(i))w("properties.layer",i).satisfies((e=>this._isSupportedLayer(e)),D),this._setLayer(i);else if(i){if(i.$portalItem){const e=i.$portalItem;this._portalItem=H(e)}this._deferredLayerProperties=i}this._sublayerExtensions=this._createSublayerExtensionCollection(),this.allSublayerExtensions=new W(this),this._handles.add([m(this,"isEffectivelyVisible",(()=>g(this,"parentLayerExtension.isEffectivelyVisible",(()=>b(this,"isEffectivelyVisible")),{sync:!0}))),m(this,"_sublayers",(()=>g(this,"layer.sublayers",(()=>b(this,"_sublayers")),{sync:!0})))])}static create(e){if(!LayerExtension.factory)throw new s("Cannot create layer extension: no layer extension factory has been registered.");return LayerExtension.factory.create(e)}static async fromPortalItem(e,t){w("portalItemLike",e).isNotMissing();const s=t??{};w("layerExtensionProperties.layer",s.layer).satisfies((e=>!v(e)));const r={...s.layer};w("layerExtensionProperties.layer.$ref",r.$ref).satisfies((e=>null==e));const a=new p,n=H(e);let o;await I(n);const l=n.typeKeywords??"";if("Map Service"===n.type)o=l.includes("Tiled")||l.includes("Hosted Service")?"ArcGISTiledMapServiceLayer":"ArcGISMapServiceLayer";else if("Feature Service"===n.type)o=l.includes("SubtypeGroupLayer")?"SubtypeGroupLayer":"ArcGISFeatureLayer";else if("Image Service"===n.type){const e=await LayerExtension._getLayerData(n.url,a);e.cacheType?"Map"===e.cacheType||l.includes("Tiled Imagery")?o="ArcGISTiledImageServiceLayer":"Elevation"===e.cacheType||l.includes("Elevation 3D Layer")?o="ArcGISTiledElevationServiceLayer":"Raster"===e.cacheType&&(o="ArcGISImageServiceLayer"):o=e.singleFusedMapCache||e.tileInfo||l.includes("Hosted Service")?"ArcGISTiledImageServiceLayer":"ArcGISImageServiceLayer"}else if("CSV"===n.type)o="CSV";else if("KML"===n.type)o="KML";else if("Scene Service"===n.type)l.includes("3DObject")||l.includes("Point")?o="ArcGISSceneServiceLayer":l.includes("IntegratedMesh")?o="IntegratedMeshLayer":l.includes("PointCloud")?o="PointCloudLayer":l.includes("Building")&&(o="BuildingSceneLayer");else if("Stream Service"===n.type)o="ArcGISStreamLayer";else if("Vector Tile Service"===n.type)o="VectorTileLayer";else if("Feature Collection"===n.type){o="ArcGISFeatureLayer";const e=await n.fetchData();r.featureCollection=e}else if("WFS"===n.type){o="WFS";const e=await n.fetchData();Object.assign(r,e)}else if("WMTS"===n.type){o="WebTiledLayer";const e=await n.fetchData();Object.assign(r,e)}else if("WMS"===n.type){o="WMS";const e=await n.fetchData();Object.assign(r,e)}if(!o)throw new i("portalItem","Could not determine correct type of LayerExtension to create from portal item");if(r.layerType&&r.layerType!==o)throw new i("layerExtensionProperties.layer.layerType","Layer type defined in layer properties does not match layer type from portal item");return r.layerType=o,r.$portalItem=n,s.layer=r,LayerExtension.create(s)}static async _getLayerData(e,t){const i=await t.request(e,{query:{f:"json"}});if(!i?.data)throw new Error(`Response to request for url ${e} was invalid.`);return i.data}getFeatures(e,t){if(!this.hasFeatures)throw new s(B);return super.getFeatures(e,t)}getFullExtent(){return this.effectiveFullExtent}async addFeatures(e,t){if(w("features",e).isNotMissing(),!this.hasFeatures)throw new s(B);await super.addFeatures(e,t)}async updateFeatures(e,t){if(w("features",e).isNotMissing(),!this.hasFeatures)throw new s(B);await super.updateFeatures(e,t)}async deleteFeatures(e,t){if(w("features",e).isNotMissing(),!this.hasFeatures)throw new s(B);await super.deleteFeatures(e,t)}async _createBackingLayer(){this._portalItem||this.layer||this._deferredLayerProperties?.$ref?!this.layer&&this._portalItem&&this._setLayer(await this._createLayer(this.getDefaults().layer)):(this._setLayer(await this._createLayer(this._deferredLayerProperties)),w("properties.layer",this._layer).satisfies((e=>this._isSupportedLayer(e)),D),this._deferredLayerProperties=void 0)}_setMapExtension(e){if(this.mapExtension===e)return;const t=this.mapExtension;this._mapExtension=e,t&&this.featureSettings.formatSettings.parent===t.formatSettings&&(this.featureSettings.formatSettings.parent=void 0),e&&(this.featureSettings.formatSettings.parent||(this.featureSettings.formatSettings.parent=e.formatSettings)),this._resolveLayer(),b(this,"mapExtension")}_setBasemapExtension(e){this.basemapExtension!==e&&(this._basemapExtension=e,this._resolveLayer(),e&&(this.taskSettings.parent=e.taskSettings),b(this,"basemapExtension"))}_setGroundExtension(e){this.groundExtension!==e&&(this._groundExtension=e,this._resolveLayer(),e&&(this.taskSettings.parent=e.taskSettings),b(this,"groundExtension"))}_setParentLayerExtension(e){if(this.parentLayerExtension===e)return;const t=this._parentLayerExtension;this._parentLayerExtension=e,t&&(this.featureSettings.formatSettings.parent===t.featureSettings.formatSettings&&(this.featureSettings.formatSettings.parent=this.mapExtension?this.mapExtension.formatSettings:void 0),this.taskSettings.parent===t.taskSettings&&(this.taskSettings.parent=void 0)),e&&((!this.featureSettings.formatSettings.parent||this.mapExtension&&this.featureSettings.formatSettings.parent===this.mapExtension.formatSettings)&&(this.featureSettings.formatSettings.parent=e.featureSettings.formatSettings),this.taskSettings.parent||(this.taskSettings.parent=e.taskSettings)),this._resolveLayer(),b(this,"parentLayerExtension")}_resolveLayer(e){if(this.layer||!this._deferredLayerProperties)return;const t=e??this.basemapExtension?.basemap?.baseLayers??this.groundExtension?.ground?.layers??this.parentLayerExtension?.layer?.layers??this.mapExtension?.map.layers;if(!t)return;const i=[];let s;for(const e of t){const t=S(e,this._deferredLayerProperties);if("none"!==t){if("solid"===t){s=e;break}i.push(e)}}s||1!==i.length||(s=i[0]),s&&this._isSupportedLayer(s)&&(this._setLayer(s),this._deferredLayerProperties.$portalItem&&K().warn("LayerExtension defined with both $ref and $portalItem. Ignoring $portalItem."))}async _switchLayer(e){if(e===this.layer)return;w("newLayer",e).isNotMissing().satisfies((e=>this._isSupportedLayer(e)),D),this._isSwitchingLayer=!0,this.isInitialized&&await I(e);const t=new Map;if(this._sublayers)for(const e of this._sublayers.toArray())t.set(e.id,this.sublayerExtensions.forSublayer(e));e.visible=this.layer.visible,e.opacity=this.layer.opacity,e.listMode=this.layer.listMode,e.hasOwnProperty("labelsVisible")&&this.layer.hasOwnProperty("labelsVisible")&&(e.labelsVisible=this.layer.labelsVisible);const i=this.schema.fieldExtensions.toArray(),s=this.featureSettings.popupContentExtensions.toArray();this._setLayer(e);const r=[];i.forEach((e=>{const t=this.schema.fields.find((t=>n.matchesRef(e,{$ref:t.name})));t?e._switchField(t):(e._setSchema(void 0),r.push(e.destroy()))})),s.forEach(((e,t)=>{const i=this.featureSettings.popupContentExtensions.find((e=>o.matchesRef(s,t,e.toJSON().content)));i?e._switchContent(i.content):(e._setFeatureSettings(void 0),r.push(e.destroy()))}));const a=new Set;if(this._sublayers){const e=this._sublayers.filter((e=>t.has(e.id))).toArray();r.push(...e.map((async e=>{const i=t.get(e.id);i&&(a.add(i),await i._switchSublayer(e),this._sublayerExtensions._register(i))})))}const l=[];for(const e of t.values())e&&!a.has(e)&&l.push(e);r.push(...l.map((async e=>{this._sublayerExtensions._detach(e),await e.destroy()}))),await Promise.all(r),this.isInitialized&&await this._initializeChildren(),this._isSwitchingLayer=!1}_getProjectWebmapJSON(){if(!this.layer)return;let e=u(this.layer);if(!this.dynamicallyAddedLayer){const{id:t,title:i,layerType:s,opacity:r}=e;e={id:t,title:i,layerType:s,visibility:this.layer.visible,opacity:r}}return e}_onSublayerAddedPostInitialize=async e=>{if(!this._isSwitchingLayer)try{await e.initialize()}catch(t){K().error({message:`Error occurred while initializing sublayer extension for sublayer '${e.title??e.sublayer.id??e.id}'.`,error:t})}};async _onDestroy(){await Promise.all(this.sublayerExtensions.map((e=>e.destroy()))),this._sublayerExtensions.destroy(),this.allSublayerExtensions.destroy(),await super._onDestroy()}_getSerializableProperties(){return{...super._getSerializableProperties(),iconUrl:{serializeModes:["initial","project"],serialize:e=>"project"!==e||this.dynamicallyAddedLayer?this.iconUrl:this.getDefault("iconUrl")},visibilityMode:{serializeModes:["initial","project"],serialize:e=>"project"!==e||this.dynamicallyAddedLayer?this.visibilityMode:this.getDefault("visibilityMode"),default:"independent"},tpkSource:{serializeModes:["initial"]},layerListSettings:{serializeModes:["initial","project"],serialize:e=>"project"!==e||this.dynamicallyAddedLayer?this.layerListSettings:this.getDefault("layerListSettings")},sublayerExtensions:{serializeModes:["initial","project"],serialize:e=>this.sublayerExtensions.map((e=>e.toItemUri())).toArray(),deserialize:e=>{R(this.sublayerExtensions,e,(e=>this._createSublayerExtension(e)))}},layer:{serializeModes:["initial","project"],serialize:e=>{if(this.layer){if((this._mapExtension||this._parentLayerExtension||this._basemapExtension||this._groundExtension)&&(this._layer.id||this._layer.title)){const e=h(this._layer),t=this._getSerializableRefLayerProperties(),i=L(this._layer),s=i?{url:i}:{};return{$ref:{id:this._layer.id,title:this._layer.title,subtype:this._getSerializableLayerType(),...s},layerType:e,...t}}return u(this.layer)}return this._deferredLayerProperties?j(this._deferredLayerProperties):void 0},isDefault:()=>{throw new Error("Missing implementation for _getSerializableProperties() > layer > default. Subclasses of LayerExtension must implement this.")},deserialize:e=>{if(v(e)){if(e!==this.layer)throw new Error("Property 'layer' is read-only.")}else if(e){if(this._layer)return this._applyLayerProperties(e,this.layer);this._deferredLayerProperties&&(this._deferredLayerProperties={...this._deferredLayerProperties,...e})}}},dynamicallyAddedLayer:{serializeModes:["project"],default:!1},requestHelper:{serialize:!1}}}_getSerializableLayerType(){}_getSerializableRefLayerProperties(){return{}}_createSublayerExtension(e){if(!this.supportsSublayers)throw new s($);throw new Error("Missing implementation for _createSublayerExtension(). Subclasses of LayerExtension that support sublayers must implement this.")}async _onInitialize(){if(await super._onInitialize(),await this._createBackingLayer(),this._portalItem&&(await I(this._portalItem),await this._applyPortalItemProperties(this._portalItem),this.layer.title=this._portalItem.title,this.layer.portalItem=this._portalItem,this.iconUrl||(this.iconUrl=this._portalItem.thumbnailUrl),await this._applyLayerProperties(this._deferredLayerProperties,this.layer),this._deferredLayerProperties=void 0),this._resolveLayer(),!this.layer){const e=this._deferredLayerProperties.$ref;throw this._mapExtension||this._parentLayerExtension||this._basemapExtension||this._groundExtension?new s(`No layer found matching reference "${"string"==typeof e?e:JSON.stringify(e)}".`):new s("Cannot resolve layer reference: missing parent.")}this._deferredLayerProperties&&(await this._applyLayerProperties(this._deferredLayerProperties,this.layer),this._deferredLayerProperties=void 0),await this._initializeLayer(),await I(this.layer),this.supportsSublayers&&!this.layer.sublayers&&this.layer._set("sublayers",new t),this._initialDefinitionExpression="definitionExpression"in this.layer?this.layer.definitionExpression:void 0,this._initialRenderer=this.renderer?.clone(),this._initialVisibility=this.layer.visible,this._sublayerExtensions.onParentInitialized()}async _postInitialize(){await super._postInitialize(),this.layerListSettings.onLayerExtensionInitialized(),this.supportsSublayers&&this._handles.add(T(this,"layer.sublayers",(async e=>{if(this._isSwitchingLayer)return;const t=(e.added??[]).map((e=>this.sublayerExtensions.forSublayer(e)));await Promise.all(t.map(this._onSublayerAddedPostInitialize))})))}_applyPortalItemProperties(e){throw new s("Cannot use this type of layer extension with a PortalItem.")}async _initializeLayer(){}_createLayerListSettings(e){return new G(e,this)}_createSublayerExtensionCollection(){return new k(this)}_capabilities(){return N}*_initializableChildCollections(){yield*super._initializableChildCollections(),yield this.sublayerExtensions}async _createLayer(e){return d(e)}_applyLayerProperties(e,t){w("layerJson",e).isNotMissing();const i=e.layerType||e.type;return w("layerJson.layerType",i).satisfies((e=>!e||e===this.getDefault("layer")?.layerType)),w("layer",t).isNotMissing().satisfies((e=>this._isSupportedLayer(e))),y(e,t)}_setLayer(e){if(this._layer=e,this._handles.remove(LayerExtension._layerWatchHandlesKey),this._handles.add([g(e,"visible",((e,t,i)=>{this._onVisibleChanged(e),this.mapExtension?.emit("layer-visibility-change",i)})),m(this,"effectiveMinScale",(()=>g(this.layer,"minScale",(()=>b(this,"effectiveMinScale")),{sync:!0}))),m(this,"effectiveMaxScale",(()=>g(this.layer,"maxScale",(()=>b(this,"effectiveMaxScale")),{sync:!0}))),m(this,"title",(()=>g(this.layer,"title",(()=>b(this,"title")),{sync:!0})))],LayerExtension._layerWatchHandlesKey),"definitionExpression"in e&&this._handles.add(g(e,"definitionExpression",((e,t,i)=>{this.mapExtension?.emit("layer-definition-expression-change",i)})),LayerExtension._layerWatchHandlesKey),this.supportsSublayers)if(this._sublayers)this._setupSublayersHandles();else{const t=g(e,"sublayers",(()=>{this._setupSublayersHandles()}),{sync:!0,once:!0});this._handles.add(t,LayerExtension._layerWatchHandlesKey)}b(this,"layer"),b(this,"title"),b(this,"effectiveMinScale"),b(this,"effectiveMaxScale"),b(this,"isEffectivelyVisible")}_setupSublayersHandles(){this._handles.add([this._sublayers.on("after-add",this._onSublayersAfterAdd),this._sublayers.on("after-remove",this._onSublayersAfterRemove),x(this._sublayers,"[].visible",this._onSublayersSublayerVisibleChanged,{sync:!0})],LayerExtension._layerWatchHandlesKey)}_onVisibleChanged=e=>{if("inherited"===this.visibilityMode&&this.supportsSublayers&&this._sublayers)for(const t of this._sublayers.toArray())t.visible=e;b(this,"isEffectivelyVisible")};_onSublayersSublayerVisibleChanged=(e,t,i)=>{e&&"exclusive"===this.visibilityMode&&this._ensureAChildSublayerVisible(i)};_onSublayersAfterAdd=e=>{1!==this._sublayers.length||e.item.visible||"exclusive"!==this.visibilityMode?e.item.visible&&"exclusive"===this.visibilityMode&&(e.item.visible=!1):e.item.visible=!0};_onSublayersAfterRemove=e=>{0!==this._sublayers.length&&"exclusive"===this.visibilityMode&&e.item.visible&&this._ensureAChildSublayerVisible(this._sublayers.getItemAt(0))};_ensureAChildSublayerVisible(e){for(const t of this._sublayers.toArray())t!==e&&(t.visible=!1)}_ensureAtMostOneChildSublayerVisible(){this.layer&&this._sublayers&&this._ensureAChildSublayerVisible(this._sublayers.find((e=>e.visible)))}}class k extends F{constructor(e){super(e,"_sublayers"),this._layerExtension=e}add(e,t){if(w("sublayerX",e).isNotMissing(),!this._layerExtension.supportsSublayers)throw new s($);const i=e.sublayer?e.sublayer.layer:void 0;return i&&i!==this._layerExtension.layer&&i.sublayers.remove(e.sublayer),super.add(e,t)}}class W extends c{get _collection(){return this._layerExtension.sublayerExtensions.flatten((e=>e.sublayerExtensions))}_layerExtension;_onChangeLayerExtensionsHandle=new E((()=>{const e=new WeakMap,i=new Set,s=r=>{const a=new t(r.added).flatten((e=>e.sublayerExtensions)),n=new t(r.moved).flatten((e=>e.sublayerExtensions)),o=new t(r.removed).flatten((e=>e.sublayerExtensions));for(const t of a)if(!e.has(t)){const r=t.sublayerExtensions.on("change",s);e.set(t,r),i.add(r)}for(const t of o){const s=e.get(t);s&&(s.remove(),e.delete(t),i.delete(s))}this.emit("change",{added:a.toArray(),moved:n.toArray(),removed:o.toArray()})};i.add(this._layerExtension.sublayerExtensions.on("change",s));const r=this._layerExtension.sublayerExtensions.flatten((e=>e.sublayerExtensions));for(const t of r){const r=t.sublayerExtensions.on("change",s);e.set(t,r),i.add(r)}return _(i)}));_onAfterAddLayerExtensionsHandle=new E((()=>{const e=new WeakMap,t=new Set,i=i=>{const s=e.get(i);s&&(s.remove(),e.delete(i),t.delete(s))},s=e=>{const t=e.item,s=t.sublayerExtensions.flatten((e=>e.sublayerExtensions));for(const e of s)i(e);i(t)},r=i=>{this.emit("after-add",{...i});const a=i.item.sublayerExtensions.flatten((e=>e.sublayerExtensions));for(const n of a)if(this.emit("after-add",{...i,item:n}),!e.has(n)){const i=n.sublayerExtensions.on("after-add",r),a=n.sublayerExtensions.on("after-remove",s),o=_([i,a]);e.set(n,o),t.add(o)}};t.add(this._layerExtension.sublayerExtensions.on("after-add",r)),t.add(this._layerExtension.sublayerExtensions.on("after-remove",s));const a=this._layerExtension.sublayerExtensions.flatten((e=>e.sublayerExtensions));for(const i of a){const a=i.sublayerExtensions.on("after-add",r),n=i.sublayerExtensions.on("after-remove",s),o=_([a,n]);e.set(i,o),t.add(o)}return _(t)}));_onAfterRemoveLayerExtensionsHandle=new E((()=>{const e=new WeakMap,t=new Set,i=i=>{const s=e.get(i);s&&(s.remove(),e.delete(i),t.delete(s))},s=e=>{this.emit("after-remove",{...e});const t=e.item,s=t.sublayerExtensions.flatten((e=>e.sublayerExtensions));for(const t of s)this.emit("after-remove",{...e,item:t}),i(t);i(t)},r=i=>{const a=i.item,n=a.sublayerExtensions.on("after-add",r),o=a.sublayerExtensions.on("after-remove",s),l=_([n,o]);e.set(a,l),t.add(l)};t.add(this._layerExtension.sublayerExtensions.on("after-remove",s)),t.add(this._layerExtension.sublayerExtensions.on("after-add",r));const a=this._layerExtension.sublayerExtensions.flatten((e=>e.sublayerExtensions));for(const i of a){const a=i.sublayerExtensions.on("after-add",r),n=i.sublayerExtensions.on("after-remove",s),o=_([a,n]);e.set(i,o),t.add(o)}return _(t)}));constructor(e){super(),this._layerExtension=e}destroy(){this._onChangeLayerExtensionsHandle.destroy(),this._onAfterAddLayerExtensionsHandle.destroy(),this._onAfterRemoveLayerExtensionsHandle.destroy(),super.destroy()}on(e,t){const i=[];return"change"===e?i.push(this._onChangeLayerExtensionsHandle.add()):"after-add"===e?i.push(this._onAfterAddLayerExtensionsHandle.add()):"after-remove"===e&&i.push(this._onAfterRemoveLayerExtensionsHandle.add()),i.push(super.on(e,t)),_(i)}findById(e){return w("id",e).isNotMissing(),this.find((t=>t.id===e))}findBySublayerId(e){return w("id",e).isNotMissing(),this.find((t=>t._sublayerId===e))}forSublayer(e){return w("sublayer",e).isNotMissing(),this.findBySublayerId(e.id)}_itemIsInitialized(e){return super._itemIsInitialized(e)&&!!e.sublayer}}let G=class extends O{get _esriLayer(){return this._extension.layer}get _listModePath(){return"layer.listMode"}get _supportsChildren(){return this._extension.supportsSublayers}};G=e([f],G);export{G as LayerExtensionLayerListSettings};export function toBindingOptions(e){return"object"==typeof e?e:{property:e}}let q=class extends l{_layerExtension;_layerBindings=new Map;constructor(e){super(),this._layerExtension=e,this._bindSettingsToLayerProperties(),e.layer?this._onLayerResolved(e.layer):this._handles.add(g(e,"layer",(()=>{this._onLayerResolved(e.layer)}),{sync:!0,once:!0}))}_getPropertyBindings(){return{}}_hasSettingIncludingAncestor(e){return!(!this._layerBindings.has(e)||!this._layerExtension.layer)||super._hasSettingIncludingAncestor(e)}_getSetting(e,t){if(this._layerBindings.has(e)){const t=toBindingOptions(this._layerBindings.get(e));if(t.hasOwnProperty("value"))return t.value;if(this._layerExtension.layer)return this._layerExtension.layer[t.property]}return super._getSetting(e,t)}_setSetting(e,t){if(this._layerBindings.has(e)){const i=toBindingOptions(this._layerBindings.get(e));if(i.readonly||i.hasOwnProperty("value"))throw new s(ERR_SCHEMA_READ_ONLY);if(this._layerExtension.layer)return void(this._layerExtension.layer[i.property]=t)}super._setSetting(e,t)}_bindSettingsToLayerProperties(){const e=this._getPropertyBindings();for(const t of z(e)){const i=toBindingOptions(e[t]);this._layerBindings.set(t,i),i.hasOwnProperty("value")||this._handles.add(m(this,t,(()=>g(this._layerExtension,`layer.${String(i.property)}`,(()=>b(this,t)),{sync:!i.hasOwnProperty("sync")||i.sync}))))}}_onLayerResolved(e){for(const t of this._layerBindings.keys())this.isModified(t)&&(e[t]=this[t],this.reset(t))}};q=e([f],q);export{q as LayerExtensionSchema};export function _assignLayerExtensions(e,t){return M(e,t,{onNew:(t,i)=>{e.add(t instanceof LayerExtension?t:LayerExtension.create(t),U(t)?void 0:i)},onMatch:(t,i,s,r)=>{i instanceof LayerExtension||t.assignProperties(i),s===r||U(i)||e.reorder(t,r)},onMissing:t=>{(P([t])||A(t)&&0===t.layerExtensions.toArray().length)&&e.remove(t)},equals:(e,t)=>{const i="solid"===S(e.layer,t.layer);return t instanceof LayerExtension?e===t||i:i||e.id===t.id}})}function K(){return C("geocortex.api.mapping.LayerExtension")}function U(e){return e instanceof LayerExtension?!!e._deferredLayerProperties?.$ref:!v(e.layer)&&!!e.layer?.$ref}let J=class extends q{_setSetting(e,t){if(this._layerBindings.has(e))throw new s(ERR_SCHEMA_READ_ONLY);super._setSetting(e,t)}};J=e([f],J);export{J as LayerExtensionReadOnlySchema};export const ERR_SCHEMA_READ_ONLY="This schema property is read-only.";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vertigis/arcgis-extensions",
3
3
  "license": "SEE LICENSE IN LICENSE",
4
- "version": "53.12.0",
4
+ "version": "53.14.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://dev.azure.com/vertigis/Studio/_git/arcgis-extensions-ts"
package/version.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * The current version of the Geocortex ArcGIS Extensions API.
3
3
  */
4
- export declare const version = "53.12.0";
4
+ export declare const version = "53.14.0";
package/version.js CHANGED
@@ -1 +1 @@
1
- export const version="53.12.0";
1
+ export const version="53.14.0";