@arcgis/core 4.28.6 → 4.28.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +15 -25
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/0c08d59c5d65921ba5ae.js +1 -0
  4. package/assets/esri/core/workers/chunks/0dbf3fa096d02d83b222.js +1 -0
  5. package/assets/esri/core/workers/chunks/16453ca31cc3e09fde46.js +1 -0
  6. package/assets/esri/core/workers/chunks/{1da721608993783dc9cf.js → 24d04cca452ba2fec5d4.js} +1 -1
  7. package/assets/esri/core/workers/chunks/2c121541cde5c24b1fbe.js +1 -0
  8. package/assets/esri/core/workers/chunks/2efd2496f7310142f928.js +1 -0
  9. package/assets/esri/core/workers/chunks/42880f0fac5f1606201c.js +1 -0
  10. package/assets/esri/core/workers/chunks/70eba80261d7fdc624ad.js +1 -0
  11. package/assets/esri/core/workers/chunks/{3dcb2a82e1e4b520c9c9.js → 7b901d0b68e5cc17533a.js} +1 -1
  12. package/assets/esri/core/workers/chunks/7f68c2cc1048d136fd1b.js +1 -0
  13. package/assets/esri/core/workers/chunks/85d6dd6703b228248e30.js +1 -0
  14. package/assets/esri/core/workers/chunks/adc138e5d9983a5752d4.js +1 -0
  15. package/assets/esri/core/workers/chunks/b35e87cf2b8244e3584f.js +1 -0
  16. package/assets/esri/core/workers/chunks/b49f830a8d74c4564ed8.js +1 -0
  17. package/assets/esri/core/workers/chunks/b6d77edf9eec757e88da.js +1 -0
  18. package/assets/esri/core/workers/chunks/c9306fb3ec1a2d5e137a.js +1 -0
  19. package/assets/esri/core/workers/chunks/cd201c627e9396edf6b9.js +1 -0
  20. package/assets/esri/core/workers/chunks/ceeaa8d1b0034b59eae7.js +1 -0
  21. package/assets/esri/core/workers/chunks/dc4a71e72e56cbdff49a.js +1 -0
  22. package/assets/esri/core/workers/chunks/{5e8f02da4eae41f57383.js → f4e962ccbec7e3b06067.js} +1 -1
  23. package/assets/esri/core/workers/chunks/f78b1bfacd95a6ccf7b4.js +1 -0
  24. package/assets/esri/themes/base/widgets/_LabeledSwitch.scss +6 -1
  25. package/assets/esri/themes/dark/main.css +1 -1
  26. package/assets/esri/themes/light/main.css +1 -1
  27. package/assets/esri/themes/light/view.css +1 -1
  28. package/core/sql/WhereClause.js +1 -1
  29. package/core/sql/sqlCompareUtils.js +1 -1
  30. package/core/sql/sqlDateParsingUtils.js +1 -1
  31. package/kernel.js +1 -1
  32. package/layers/support/FieldsIndex.js +1 -1
  33. package/package.json +1 -1
  34. package/support/revision.js +1 -1
  35. package/views/2d/engine/webgl/WorldExtentClipRenderer.js +1 -1
  36. package/views/2d/layers/features/processors/SymbolProcessor.js +1 -1
  37. package/views/webgl/FramebufferObject.js +1 -1
  38. package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
  39. package/widgets/Editor/workflowUtils.js +1 -1
  40. package/widgets/Features.js +1 -1
  41. package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
  42. package/widgets/support/LabeledSwitch.js +1 -1
  43. package/assets/esri/core/workers/chunks/16b56e541afa438dfb7f.js +0 -1
  44. package/assets/esri/core/workers/chunks/340ab726ba40fe3a99c8.js +0 -1
  45. package/assets/esri/core/workers/chunks/46b4a17ec898ab744861.js +0 -1
  46. package/assets/esri/core/workers/chunks/4f0412b52844aa9c7bd4.js +0 -1
  47. package/assets/esri/core/workers/chunks/5b80ae1eb79f1db75dc6.js +0 -1
  48. package/assets/esri/core/workers/chunks/80fcb63476829b6a48d2.js +0 -1
  49. package/assets/esri/core/workers/chunks/84725021c43f1122056a.js +0 -1
  50. package/assets/esri/core/workers/chunks/8cdece03397d01767593.js +0 -1
  51. package/assets/esri/core/workers/chunks/9607460895182d31aef9.js +0 -1
  52. package/assets/esri/core/workers/chunks/a0a86383e69932a25e50.js +0 -1
  53. package/assets/esri/core/workers/chunks/a3bf50d9e24ad1de9847.js +0 -1
  54. package/assets/esri/core/workers/chunks/a5db3be5eeb3005df3c1.js +0 -1
  55. package/assets/esri/core/workers/chunks/a87ab14d6a6ccc9004a0.js +0 -1
  56. package/assets/esri/core/workers/chunks/a8cf23c3a55c1834178c.js +0 -1
  57. package/assets/esri/core/workers/chunks/ba00df2e707550939a6f.js +0 -1
  58. package/assets/esri/core/workers/chunks/cfa6d1b63b794febe70a.js +0 -1
  59. package/assets/esri/core/workers/chunks/e0382138cf58191a9697.js +0 -1
  60. package/assets/esri/core/workers/chunks/fe0c6814ef56604540b3.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{ArcadeDate as e}from"../../arcade/ArcadeDate.js";import{SqlError as t,SqlErrorCodes as a}from"../../arcade/featureset/support/errorsupport.js";import has from"../has.js";import{isAggregate as r,aggregateFunction as s}from"./AggregateFunctions.js";import{DateOnly as i}from"./DateOnly.js";import{sqlCalculateFunction as n}from"./sqlArithmeticUtils.js";import{sqlCompare as l}from"./sqlCompareUtils.js";import{isDate as o,isDateTime as u,isTimestampOffset as c,isTimeOnly as h,isDateOnly as p,convertToExecutingTimeZone as m,parseTime as d,parseTimestamp as f,parseDate as v}from"./sqlDateParsingUtils.js";import{SqlInterval as N}from"./SqlInterval.js";import{SqlTimeStampOffset as g}from"./SqlTimestampOffset.js";import{isStandardized as S,evaluateFunction as T}from"./StandardizedFunctions.js";import{TimeOnly as y}from"./TimeOnly.js";import{WhereGrammar as _}from"./WhereGrammar.js";import{DateTime as w}from"luxon";const J=new Set(["current_timestamp","current_date","current_time"]);class A{static makeBool(e){return O(e)}static featureValue(e,t,a,r){return L(e,t,a,r)}static equalsNull(e){return null===e}static applyLike(e,t,a){return j(e,t,a)}static ensureArray(e){return x(e)}static applyIn(e,t){return k(e,t)}static currentDate(e){return i.fromNow(e)}static makeSqlInterval(e,t,a){return N.createFromValueAndQualifer(e,t,a)}static convertInterval(e){return e instanceof N?e.valueInMilliseconds():e}static currentTimestamp(e){return m(new Date,e)}static compare(e,t,a,r){return l(t,a,e)}static calculate(e,t,a,r){return n(e,t,a,r)}static evaluateTime(e){return d(e)}static evaluateTimestamp(e,t,a){return f(e,t,a)}static evaluateDate(e,t){return v(e,t)}static evaluateFunction(e,t,a){return T(e,t,a)}static lookup(e,t){const a=t[e];return void 0===a?null:a}static between(e,t,a){return null==e||null==t[0]||null==t[1]?null:l(e,t[0],">=")&&l(e,t[1],"<=")}static notbetween(e,t,a){return null==e||null==t[0]||null==t[1]?null:l(e,t[0],"<")||l(e,t[1],">")}static ternaryNot(e){return F(e)}static ternaryAnd(e,t){return b(e,t)}static ternaryOr(e,t){return D(e,t)}}class I{constructor(e,t,a="UTC"){this.fieldsIndex=t,this.timeZone=a,this.parameters={},this._hasDateFunctions=void 0,this.parseTree=_.parse(e);const{isStandardized:r,isAggregate:s,referencedFieldNames:i}=this._extractExpressionInfo(t);this._referencedFieldNames=i,this.isStandardized=r,this.isAggregate=s}static convertValueToStorageFormat(e,t=null){if(null===t)return o(e)?e.getTime():u(e)?e.toMillis():c(e)?e.toStorageFormat():h(e)?e.toStorageString():p(e)?e.toStorageFormat():e;switch(t){case"date":return o(e)?e.getTime():u(e)?e.toMillis():c(e)?e.toMilliseconds():p(e)?e.toNumber():e;case"date-only":return o(e)?i.fromDateJS(e).toString():c(e)?i.fromSqlTimeStampOffset(e).toString():u(e)?i.fromDateTime(e).toString():e;case"time-only":return o(e)?y.fromDateJS(e).toStorageString():u(e)?y.fromDateTime(e).toStorageString():c(e)?y.fromSqlTimeStampOffset(e).toStorageString():h(e)?e.toStorageString():e;case"timestamp-offset":if(o(e))return g.fromJSDate(e).toStorageFormat();if(u(e))return g.fromDateTime(e).toStorageFormat();if(c(e))return e.toStorageFormat()}return e}static create(e,t,a="UTC"){return new I(e,t,a)}get fieldNames(){return this._referencedFieldNames}testSet(e,t=C){return!!this._evaluateNode(this.parseTree,null,t,e)}calculateValue(e,t=C){const a=this._evaluateNode(this.parseTree,e,t,null);return a instanceof N?a.valueInMilliseconds()/864e5:a}calculateValueCompiled(e,t=C){return null!=this.parseTree._compiledVersion?this.parseTree._compiledVersion(e,this.parameters,t,this.fieldsIndex,this.timeZone):has("esri-csp-restrictions")?this.calculateValue(e,t):(this._compileMe(),this.parseTree._compiledVersion(e,this.parameters,t,this.fieldsIndex,this.timeZone))}testFeature(e,t=C){return!!this._evaluateNode(this.parseTree,e,t,null)}testFeatureCompiled(e,t=C){return null!=this.parseTree._compiledVersion?!!this.parseTree._compiledVersion(e,this.parameters,t,this.fieldsIndex,this.timeZone):has("esri-csp-restrictions")?this.testFeature(e,t):(this._compileMe(),!!this.parseTree._compiledVersion(e,this.parameters,t,this.fieldsIndex,this.timeZone))}get hasDateFunctions(){return null!=this._hasDateFunctions||(this._hasDateFunctions=!1,this._visitAll(this.parseTree,(e=>{"current-time"===e.type?this._hasDateFunctions=!0:"function"===e.type&&(this._hasDateFunctions=this._hasDateFunctions||J.has(e.name.toLowerCase()))}))),this._hasDateFunctions}getFunctions(){const e=new Set;return this._visitAll(this.parseTree,(t=>{"function"===t.type&&e.add(t.name.toLowerCase())})),Array.from(e)}getExpressions(){const e=new Map;return this._visitAll(this.parseTree,(t=>{if("function"===t.type){const a=t.name.toLowerCase(),r=t.args.value[0];if("column-reference"===r.type){const t=r.column,s=`${a}-${t}`;e.has(s)||e.set(s,{aggregateType:a,field:t})}}})),[...e.values()]}getVariables(){const e=new Set;return this._visitAll(this.parseTree,(t=>{"parameter"===t.type&&e.add(t.value.toLowerCase())})),Array.from(e)}_compileMe(){const e="return this.convertInterval("+this.evaluateNodeToJavaScript(this.parseTree)+")";this.parseTree._compiledVersion=new Function("feature","lookups","attributeAdapter","fieldsIndex","timeZone",e).bind(A)}_extractExpressionInfo(e){const t=[],a=new Set;let s=!0,i=!1;return this._visitAll(this.parseTree,(n=>{switch(n.type){case"column-reference":{const r=e?.get(n.column);let s,i;r?s=i=r.name??"":(i=n.column,s=i.toLowerCase()),a.has(s)||(a.add(s),t.push(i)),n.column=i;break}case"function":{const{name:e,args:t}=n,a=t.value.length;s&&(s=S(e,a)),!1===i&&(i=r(e,a));break}}})),{referencedFieldNames:Array.from(t),isStandardized:s,isAggregate:i}}_visitAll(e,t){if(null!=e)switch(t(e),e.type){case"when-clause":this._visitAll(e.operand,t),this._visitAll(e.value,t);break;case"case-expression":for(const a of e.clauses)this._visitAll(a,t);"simple"===e.format&&this._visitAll(e.operand,t),null!==e.else&&this._visitAll(e.else,t);break;case"expression-list":for(const a of e.value)this._visitAll(a,t);break;case"unary-expression":this._visitAll(e.expr,t);break;case"binary-expression":this._visitAll(e.left,t),this._visitAll(e.right,t);break;case"function":this._visitAll(e.args,t)}}evaluateNodeToJavaScript(e){switch(e.type){case"interval":return"this.makeSqlInterval("+this.evaluateNodeToJavaScript(e.value)+", "+JSON.stringify(e.qualifier)+","+JSON.stringify(e.op)+")";case"case-expression":{let t="";if("simple"===e.format){const a=this.evaluateNodeToJavaScript(e.operand);t="( ";for(let r=0;r<e.clauses.length;r++)t+=" (this.compare('=',"+a+","+this.evaluateNodeToJavaScript(e.clauses[r].operand)+") ? ("+this.evaluateNodeToJavaScript(e.clauses[r].value)+") : ";null!==e.else?t+=this.evaluateNodeToJavaScript(e.else):t+="null",t+=" )"}else{t="( ";for(let a=0;a<e.clauses.length;a++)t+=" this.makeBool("+this.evaluateNodeToJavaScript(e.clauses[a].operand)+")===true ? ("+this.evaluateNodeToJavaScript(e.clauses[a].value)+") : ";null!==e.else?t+=this.evaluateNodeToJavaScript(e.else):t+="null",t+=" )"}return t}case"parameter":return"this.lookup("+JSON.stringify(e.value.toLowerCase())+",lookups)";case"expression-list":{let t="[";for(const a of e.value)"["!==t&&(t+=","),t+=this.evaluateNodeToJavaScript(a);return t+="]",t}case"unary-expression":return"this.ternaryNot("+this.evaluateNodeToJavaScript(e.expr)+")";case"binary-expression":switch(e.operator){case"AND":return"this.ternaryAnd("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+" )";case"OR":return"this.ternaryOr("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+" )";case"IS":if("null"!==e.right.type)throw new t(a.UnsupportedIsRhs);return"this.equalsNull("+this.evaluateNodeToJavaScript(e.left)+")";case"ISNOT":if("null"!==e.right.type)throw new t(a.UnsupportedIsRhs);return"(!(this.equalsNull("+this.evaluateNodeToJavaScript(e.left)+")))";case"IN":return"this.applyIn("+this.evaluateNodeToJavaScript(e.left)+",this.ensureArray("+this.evaluateNodeToJavaScript(e.right)+"))";case"NOT IN":return"this.ternaryNot(this.applyIn("+this.evaluateNodeToJavaScript(e.left)+",this.ensureArray("+this.evaluateNodeToJavaScript(e.right)+")))";case"BETWEEN":return"this.between("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+", timeZone)";case"NOTBETWEEN":return"this.notbetween("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+", timeZone)";case"LIKE":return"this.applyLike("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+","+JSON.stringify(e.escape)+")";case"NOT LIKE":return"this.ternaryNot(this.applyLike("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+","+JSON.stringify(e.escape)+"))";case"<>":case"<":case">":case">=":case"<=":case"=":return"this.compare("+JSON.stringify(e.operator)+","+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+", timeZone)";case"*":case"-":case"+":case"/":case"||":return"this.calculate("+JSON.stringify(e.operator)+","+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+", timeZone)"}throw new t(a.UnsupportedOperator,{operator:e.operator});case"null":case"boolean":case"string":case"number":return JSON.stringify(e.value);case"time":return"this.evaluateTime(JSON.stringify(node.value))";case"date":return"this.evaluateDate(JSON.stringify(node.value), 'unknown')";case"timestamp":return"this.evaluateTimestamp(JSON.stringify(node.value), 'unknown')";case"current-time":return"date"===e.mode?"this.currentDate(timeZone)":"this.currentTimestamp(timeZone)";case"column-reference":return"this.featureValue(feature,"+JSON.stringify(e.column)+",fieldsIndex,attributeAdapter)";case"function":return"this.evaluateFunction("+JSON.stringify(e.name)+","+this.evaluateNodeToJavaScript(e.args)+", timeZone)"}throw new t(a.UnsupportedSyntax,{node:e.type})}_evaluateNode(u,c,h,p){let g;switch(u.type){case"interval":{const e=this._evaluateNode(u.value,c,h,p);return N.createFromValueAndQualifer(e,u.qualifier,u.op)}case"case-expression":if("simple"===u.format){const e=this._evaluateNode(u.operand,c,h,p);for(let t=0;t<u.clauses.length;t++)if(l(e,this._evaluateNode(u.clauses[t].operand,c,h,p),"=",this.timeZone))return this._evaluateNode(u.clauses[t].value,c,h,p);if(null!==u.else)return this._evaluateNode(u.else,c,h,p)}else{for(let e=0;e<u.clauses.length;e++)if(O(this._evaluateNode(u.clauses[e].operand,c,h,p)))return this._evaluateNode(u.clauses[e].value,c,h,p);if(null!==u.else)return this._evaluateNode(u.else,c,h,p)}return null;case"parameter":return g=this.parameters[u.value.toLowerCase()],o(g)?w.fromJSDate(g):g instanceof e?g.toDateTime():g;case"expression-list":{const e=[];for(const t of u.value)e.push(this._evaluateNode(t,c,h,p));return e}case"unary-expression":return F(this._evaluateNode(u.expr,c,h,p));case"binary-expression":switch(u.operator){case"AND":return b(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p));case"OR":return D(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p));case"IS":if("null"!==u.right.type)throw new t(a.UnsupportedIsRhs);return null===this._evaluateNode(u.left,c,h,p);case"ISNOT":if("null"!==u.right.type)throw new t(a.UnsupportedIsRhs);return null!==this._evaluateNode(u.left,c,h,p);case"IN":{const e=x(this._evaluateNode(u.right,c,h,p));return k(this._evaluateNode(u.left,c,h,p),e)}case"NOT IN":{const e=x(this._evaluateNode(u.right,c,h,p));return F(k(this._evaluateNode(u.left,c,h,p),e))}case"BETWEEN":{const e=this._evaluateNode(u.left,c,h,p),t=this._evaluateNode(u.right,c,h,p);return null==e||null==t[0]||null==t[1]?null:l(e,t[0],">=",this.timeZone)&&l(e,t[1],"<=",this.timeZone)}case"NOTBETWEEN":{const e=this._evaluateNode(u.left,c,h,p),t=this._evaluateNode(u.right,c,h,p);return null==e||null==t[0]||null==t[1]?null:l(e,t[0],"<",this.timeZone)||l(e,t[1],">",this.timeZone)}case"LIKE":return j(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p),u.escape);case"NOT LIKE":return F(j(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p),u.escape));case"<>":case"<":case">":case">=":case"<=":case"=":return l(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p),u.operator,this.timeZone);case"-":case"+":case"*":case"/":case"||":return n(u.operator,this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p),this.timeZone)}case"null":case"boolean":case"string":case"number":return u.value;case"date":return u.parsedValue??=v(u.value,"unknown"),u.parsedValue;case"timestamp":return u.parsedValue??=f(u.value,"unknown"),u.parsedValue;case"time":return d(u.value);case"current-time":return"date"===u.mode?i.fromNow(this.timeZone):m(new Date,this.timeZone);case"column-reference":return L(c,u.column,this.fieldsIndex,h);case"data-type":return u.value;case"function":{if(this.isAggregate&&r(u.name,u.args.value.length)){const e=[];for(const t of u.args?.value||[]){const a=[];for(const e of p||[])a.push(this._evaluateNode(t,e,h,null));e.push(a)}return s(u.name,e)}const e=this._evaluateNode(u.args,c,h,p);return T(u.name,e,this.timeZone)}}throw new t(a.UnsupportedSyntax,{node:u.type})}}function O(e){return!0===e}function x(e){return Array.isArray(e)?e:[e]}function F(e){return null!==e?!0!==e:null}function b(e,t){return null!=e&&null!=t?!0===e&&!0===t:!1!==e&&!1!==t&&null}function D(e,t){return null!=e&&null!=t?!0===e||!0===t:!0===e||!0===t||null}function k(e,t){if(null==e)return null;let a=!1;for(const r of t)if(null==r)a=null;else if(e===r){a=!0;break}return a}const E="-[]/{}()*+?.\\^$|";var Z;function V(e,t){const a=t;let r="",s=Z.Normal;for(let i=0;i<e.length;i++){const t=e.charAt(i);switch(s){case Z.Normal:t===a?s=Z.Escaped:E.includes(t)?r+="\\"+t:r+="%"===t?".*":"_"===t?".":t;break;case Z.Escaped:E.includes(t)?r+="\\"+t:r+=t,s=Z.Normal}}return new RegExp("^"+r+"$","m")}function j(e,t,a){if(null==e)return null;return V(t,a).test(e)}function q(e){return e&&"object"==typeof e.attributes}function L(e,t,a,r){const s=r.getAttribute(e,t),n=a?.get(t);return null==s||"esriFieldTypeDate"!==n?.type&&"date"!==n?.type?null==s||"esriFieldTypeDateOnly"!==n?.type&&"date-only"!==n?.type?null==s||"esriFieldTypeTimeOnly"!==n?.type&&"time-only"!==n?.type?null==s||"esriFieldTypeTimestampOffset"!==n?.type&&"timestamp-offset"!==n?.type?s:new g(s):y.fromReader(s):i.fromReader(s):m(new Date(s),a.getTimeZone(n.name)??"UTC")}!function(e){e[e.Normal=0]="Normal",e[e.Escaped=1]="Escaped"}(Z||(Z={}));const C={getAttribute:(e,t)=>(q(e)?e.attributes:e)[t]};export{I as WhereClause,C as defaultAttributeAdapter};
5
+ import{ArcadeDate as e}from"../../arcade/ArcadeDate.js";import{SqlError as t,SqlErrorCodes as a}from"../../arcade/featureset/support/errorsupport.js";import has from"../has.js";import{isAggregate as r,aggregateFunction as s}from"./AggregateFunctions.js";import{DateOnly as i}from"./DateOnly.js";import{sqlCalculateFunction as n}from"./sqlArithmeticUtils.js";import{sqlCompare as l}from"./sqlCompareUtils.js";import{isDate as o,isDateTime as u,isTimestampOffset as c,isTimeOnly as h,isDateOnly as p,convertToExecutingTimeZone as m,parseTime as d,parseTimestamp as f,parseDate as v}from"./sqlDateParsingUtils.js";import{SqlInterval as N}from"./SqlInterval.js";import{SqlTimeStampOffset as g}from"./SqlTimestampOffset.js";import{isStandardized as S,evaluateFunction as T}from"./StandardizedFunctions.js";import{TimeOnly as y}from"./TimeOnly.js";import{WhereGrammar as _}from"./WhereGrammar.js";import{DateTime as w,FixedOffsetZone as J}from"luxon";const A=new Set(["current_timestamp","current_date","current_time"]);class I{static makeBool(e){return O(e)}static featureValue(e,t,a,r){return C(e,t,a,r)}static equalsNull(e){return null===e}static applyLike(e,t,a){return j(e,t,a)}static ensureArray(e){return F(e)}static applyIn(e,t){return E(e,t)}static currentDate(e){return i.fromNow(e)}static makeSqlInterval(e,t,a){return N.createFromValueAndQualifer(e,t,a)}static convertInterval(e){return e instanceof N?e.valueInMilliseconds():e}static currentTimestamp(e){return m(new Date,e)}static compare(e,t,a,r){return l(t,a,e)}static calculate(e,t,a,r){return n(e,t,a,r)}static evaluateTime(e){return d(e)}static evaluateTimestamp(e,t,a){return f(e,t,a)}static evaluateDate(e,t){return v(e,t)}static evaluateFunction(e,t,a){return T(e,t,a)}static lookup(e,t){const a=t[e];return void 0===a?null:a}static between(e,t,a){return null==e||null==t[0]||null==t[1]?null:l(e,t[0],">=")&&l(e,t[1],"<=")}static notbetween(e,t,a){return null==e||null==t[0]||null==t[1]?null:l(e,t[0],"<")||l(e,t[1],">")}static ternaryNot(e){return b(e)}static ternaryAnd(e,t){return D(e,t)}static ternaryOr(e,t){return k(e,t)}}class x{constructor(e,t,a="UTC"){this.fieldsIndex=t,this.timeZone=a,this.parameters={},this._hasDateFunctions=void 0,this.parseTree=_.parse(e);const{isStandardized:r,isAggregate:s,referencedFieldNames:i}=this._extractExpressionInfo(t);this._referencedFieldNames=i,this.isStandardized=r,this.isAggregate=s}static convertValueToStorageFormat(e,t=null){if(null===t)return o(e)?e.getTime():u(e)?e.toMillis():c(e)?e.toStorageFormat():h(e)?e.toStorageString():p(e)?e.toStorageFormat():e;switch(t){case"date":return o(e)?e.getTime():u(e)?e.toMillis():c(e)?e.toMilliseconds():p(e)?e.toNumber():e;case"date-only":return o(e)?i.fromDateJS(e).toString():c(e)?i.fromSqlTimeStampOffset(e).toString():u(e)?i.fromDateTime(e).toString():e;case"time-only":return o(e)?y.fromDateJS(e).toStorageString():u(e)?y.fromDateTime(e).toStorageString():c(e)?y.fromSqlTimeStampOffset(e).toStorageString():h(e)?e.toStorageString():e;case"timestamp-offset":if(o(e))return g.fromJSDate(e).toStorageFormat();if(u(e))return g.fromDateTime(e).toStorageFormat();if(c(e))return e.toStorageFormat()}return e}static create(e,t,a="UTC"){return new x(e,t,a)}get fieldNames(){return this._referencedFieldNames}testSet(e,t=U){return!!this._evaluateNode(this.parseTree,null,t,e)}calculateValue(e,t=U){const a=this._evaluateNode(this.parseTree,e,t,null);return a instanceof N?a.valueInMilliseconds()/864e5:a}calculateValueCompiled(e,t=U){return null!=this.parseTree._compiledVersion?this.parseTree._compiledVersion(e,this.parameters,t,this.fieldsIndex,this.timeZone):has("esri-csp-restrictions")?this.calculateValue(e,t):(this._compileMe(),this.parseTree._compiledVersion(e,this.parameters,t,this.fieldsIndex,this.timeZone))}testFeature(e,t=U){return!!this._evaluateNode(this.parseTree,e,t,null)}testFeatureCompiled(e,t=U){return null!=this.parseTree._compiledVersion?!!this.parseTree._compiledVersion(e,this.parameters,t,this.fieldsIndex,this.timeZone):has("esri-csp-restrictions")?this.testFeature(e,t):(this._compileMe(),!!this.parseTree._compiledVersion(e,this.parameters,t,this.fieldsIndex,this.timeZone))}get hasDateFunctions(){return null!=this._hasDateFunctions||(this._hasDateFunctions=!1,this._visitAll(this.parseTree,(e=>{"current-time"===e.type?this._hasDateFunctions=!0:"function"===e.type&&(this._hasDateFunctions=this._hasDateFunctions||A.has(e.name.toLowerCase()))}))),this._hasDateFunctions}getFunctions(){const e=new Set;return this._visitAll(this.parseTree,(t=>{"function"===t.type&&e.add(t.name.toLowerCase())})),Array.from(e)}getExpressions(){const e=new Map;return this._visitAll(this.parseTree,(t=>{if("function"===t.type){const a=t.name.toLowerCase(),r=t.args.value[0];if("column-reference"===r.type){const t=r.column,s=`${a}-${t}`;e.has(s)||e.set(s,{aggregateType:a,field:t})}}})),[...e.values()]}getVariables(){const e=new Set;return this._visitAll(this.parseTree,(t=>{"parameter"===t.type&&e.add(t.value.toLowerCase())})),Array.from(e)}_compileMe(){const e="return this.convertInterval("+this.evaluateNodeToJavaScript(this.parseTree)+")";this.parseTree._compiledVersion=new Function("feature","lookups","attributeAdapter","fieldsIndex","timeZone",e).bind(I)}_extractExpressionInfo(e){const t=[],a=new Set;let s=!0,i=!1;return this._visitAll(this.parseTree,(n=>{switch(n.type){case"column-reference":{const r=e?.get(n.column);let s,i;r?s=i=r.name??"":(i=n.column,s=i.toLowerCase()),a.has(s)||(a.add(s),t.push(i)),n.column=i;break}case"function":{const{name:e,args:t}=n,a=t.value.length;s&&(s=S(e,a)),!1===i&&(i=r(e,a));break}}})),{referencedFieldNames:Array.from(t),isStandardized:s,isAggregate:i}}_visitAll(e,t){if(null!=e)switch(t(e),e.type){case"when-clause":this._visitAll(e.operand,t),this._visitAll(e.value,t);break;case"case-expression":for(const a of e.clauses)this._visitAll(a,t);"simple"===e.format&&this._visitAll(e.operand,t),null!==e.else&&this._visitAll(e.else,t);break;case"expression-list":for(const a of e.value)this._visitAll(a,t);break;case"unary-expression":this._visitAll(e.expr,t);break;case"binary-expression":this._visitAll(e.left,t),this._visitAll(e.right,t);break;case"function":this._visitAll(e.args,t)}}evaluateNodeToJavaScript(e){switch(e.type){case"interval":return"this.makeSqlInterval("+this.evaluateNodeToJavaScript(e.value)+", "+JSON.stringify(e.qualifier)+","+JSON.stringify(e.op)+")";case"case-expression":{let t="";if("simple"===e.format){const a=this.evaluateNodeToJavaScript(e.operand);t="( ";for(let r=0;r<e.clauses.length;r++)t+=" (this.compare('=',"+a+","+this.evaluateNodeToJavaScript(e.clauses[r].operand)+") ? ("+this.evaluateNodeToJavaScript(e.clauses[r].value)+") : ";null!==e.else?t+=this.evaluateNodeToJavaScript(e.else):t+="null",t+=" )"}else{t="( ";for(let a=0;a<e.clauses.length;a++)t+=" this.makeBool("+this.evaluateNodeToJavaScript(e.clauses[a].operand)+")===true ? ("+this.evaluateNodeToJavaScript(e.clauses[a].value)+") : ";null!==e.else?t+=this.evaluateNodeToJavaScript(e.else):t+="null",t+=" )"}return t}case"parameter":return"this.lookup("+JSON.stringify(e.value.toLowerCase())+",lookups)";case"expression-list":{let t="[";for(const a of e.value)"["!==t&&(t+=","),t+=this.evaluateNodeToJavaScript(a);return t+="]",t}case"unary-expression":return"this.ternaryNot("+this.evaluateNodeToJavaScript(e.expr)+")";case"binary-expression":switch(e.operator){case"AND":return"this.ternaryAnd("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+" )";case"OR":return"this.ternaryOr("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+" )";case"IS":if("null"!==e.right.type)throw new t(a.UnsupportedIsRhs);return"this.equalsNull("+this.evaluateNodeToJavaScript(e.left)+")";case"ISNOT":if("null"!==e.right.type)throw new t(a.UnsupportedIsRhs);return"(!(this.equalsNull("+this.evaluateNodeToJavaScript(e.left)+")))";case"IN":return"this.applyIn("+this.evaluateNodeToJavaScript(e.left)+",this.ensureArray("+this.evaluateNodeToJavaScript(e.right)+"))";case"NOT IN":return"this.ternaryNot(this.applyIn("+this.evaluateNodeToJavaScript(e.left)+",this.ensureArray("+this.evaluateNodeToJavaScript(e.right)+")))";case"BETWEEN":return"this.between("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+", timeZone)";case"NOTBETWEEN":return"this.notbetween("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+", timeZone)";case"LIKE":return"this.applyLike("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+","+JSON.stringify(e.escape)+")";case"NOT LIKE":return"this.ternaryNot(this.applyLike("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+","+JSON.stringify(e.escape)+"))";case"<>":case"<":case">":case">=":case"<=":case"=":return"this.compare("+JSON.stringify(e.operator)+","+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+", timeZone)";case"*":case"-":case"+":case"/":case"||":return"this.calculate("+JSON.stringify(e.operator)+","+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+", timeZone)"}throw new t(a.UnsupportedOperator,{operator:e.operator});case"null":case"boolean":case"string":case"number":return JSON.stringify(e.value);case"time":return"this.evaluateTime(JSON.stringify(node.value))";case"date":return"this.evaluateDate(JSON.stringify(node.value), 'unknown')";case"timestamp":return"this.evaluateTimestamp(JSON.stringify(node.value), 'unknown')";case"current-time":return"date"===e.mode?"this.currentDate(timeZone)":"this.currentTimestamp(timeZone)";case"column-reference":return"this.featureValue(feature,"+JSON.stringify(e.column)+",fieldsIndex,attributeAdapter)";case"function":return"this.evaluateFunction("+JSON.stringify(e.name)+","+this.evaluateNodeToJavaScript(e.args)+", timeZone)"}throw new t(a.UnsupportedSyntax,{node:e.type})}_evaluateNode(u,c,h,p){let g;switch(u.type){case"interval":{const e=this._evaluateNode(u.value,c,h,p);return N.createFromValueAndQualifer(e,u.qualifier,u.op)}case"case-expression":if("simple"===u.format){const e=this._evaluateNode(u.operand,c,h,p);for(let t=0;t<u.clauses.length;t++)if(l(e,this._evaluateNode(u.clauses[t].operand,c,h,p),"=",this.timeZone))return this._evaluateNode(u.clauses[t].value,c,h,p);if(null!==u.else)return this._evaluateNode(u.else,c,h,p)}else{for(let e=0;e<u.clauses.length;e++)if(O(this._evaluateNode(u.clauses[e].operand,c,h,p)))return this._evaluateNode(u.clauses[e].value,c,h,p);if(null!==u.else)return this._evaluateNode(u.else,c,h,p)}return null;case"parameter":return g=this.parameters[u.value.toLowerCase()],o(g)?w.fromJSDate(g):g instanceof e?g.toDateTime():g;case"expression-list":{const e=[];for(const t of u.value)e.push(this._evaluateNode(t,c,h,p));return e}case"unary-expression":return b(this._evaluateNode(u.expr,c,h,p));case"binary-expression":switch(u.operator){case"AND":return D(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p));case"OR":return k(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p));case"IS":if("null"!==u.right.type)throw new t(a.UnsupportedIsRhs);return null===this._evaluateNode(u.left,c,h,p);case"ISNOT":if("null"!==u.right.type)throw new t(a.UnsupportedIsRhs);return null!==this._evaluateNode(u.left,c,h,p);case"IN":{const e=F(this._evaluateNode(u.right,c,h,p));return E(this._evaluateNode(u.left,c,h,p),e)}case"NOT IN":{const e=F(this._evaluateNode(u.right,c,h,p));return b(E(this._evaluateNode(u.left,c,h,p),e))}case"BETWEEN":{const e=this._evaluateNode(u.left,c,h,p),t=this._evaluateNode(u.right,c,h,p);return null==e||null==t[0]||null==t[1]?null:l(e,t[0],">=",this.timeZone)&&l(e,t[1],"<=",this.timeZone)}case"NOTBETWEEN":{const e=this._evaluateNode(u.left,c,h,p),t=this._evaluateNode(u.right,c,h,p);return null==e||null==t[0]||null==t[1]?null:l(e,t[0],"<",this.timeZone)||l(e,t[1],">",this.timeZone)}case"LIKE":return j(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p),u.escape);case"NOT LIKE":return b(j(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p),u.escape));case"<>":case"<":case">":case">=":case"<=":case"=":return l(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p),u.operator,this.timeZone);case"-":case"+":case"*":case"/":case"||":return n(u.operator,this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p),this.timeZone)}case"null":case"boolean":case"string":case"number":return u.value;case"date":return u.parsedValue??=v(u.value,"unknown"),u.parsedValue;case"timestamp":return u.parsedValue??=f(u.value,"unknown"),u.parsedValue;case"time":return d(u.value);case"current-time":return"date"===u.mode?i.fromNow(this.timeZone):m(new Date,this.timeZone);case"column-reference":return C(c,u.column,this.fieldsIndex,h);case"data-type":return u.value;case"function":{if(this.isAggregate&&r(u.name,u.args.value.length)){const e=[];for(const t of u.args?.value||[]){const a=[];for(const e of p||[])a.push(this._evaluateNode(t,e,h,null));e.push(a)}return s(u.name,e)}const e=this._evaluateNode(u.args,c,h,p);return T(u.name,e,this.timeZone)}}throw new t(a.UnsupportedSyntax,{node:u.type})}}function O(e){return!0===e}function F(e){return Array.isArray(e)?e:[e]}function b(e){return null!==e?!0!==e:null}function D(e,t){return null!=e&&null!=t?!0===e&&!0===t:!1!==e&&!1!==t&&null}function k(e,t){return null!=e&&null!=t?!0===e||!0===t:!0===e||!0===t||null}function E(e,t){if(null==e)return null;let a=!1;for(const r of t)if(null==r)a=null;else if(e===r){a=!0;break}return a}const Z="-[]/{}()*+?.\\^$|";var V;function L(e,t){const a=t;let r="",s=V.Normal;for(let i=0;i<e.length;i++){const t=e.charAt(i);switch(s){case V.Normal:t===a?s=V.Escaped:Z.includes(t)?r+="\\"+t:r+="%"===t?".*":"_"===t?".":t;break;case V.Escaped:Z.includes(t)?r+="\\"+t:r+=t,s=V.Normal}}return new RegExp("^"+r+"$","m")}function j(e,t,a){if(null==e)return null;return L(t,a).test(e)}function q(e){return e&&"object"==typeof e.attributes}function C(e,t,a,r){const s=r.getAttribute(e,t),n=a?.get(t);return null==s||"esriFieldTypeDate"!==n?.type&&"date"!==n?.type?null==s||"esriFieldTypeDateOnly"!==n?.type&&"date-only"!==n?.type?null==s||"esriFieldTypeTimeOnly"!==n?.type&&"time-only"!==n?.type?null==s||"esriFieldTypeTimestampOffset"!==n?.type&&"timestamp-offset"!==n?.type?s:new g(s):y.fromReader(s):i.fromReader(s):m(new Date(s),a?.getLuxonTimeZone(n.name)??J.utcInstance)}!function(e){e[e.Normal=0]="Normal",e[e.Escaped=1]="Escaped"}(V||(V={}));const U={getAttribute:(e,t)=>(q(e)?e.attributes:e)[t]};export{x as WhereClause,U as defaultAttributeAdapter};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{SqlError as r,SqlErrorCodes as e}from"../../arcade/featureset/support/errorsupport.js";import{isDateTime as t,isTimestampOffset as n,isDateOnly as o,isTimeOnly as i,isNumber as a,isString as s}from"./sqlDateParsingUtils.js";import{SqlTimeStampOffset as u}from"./SqlTimestampOffset.js";import{isUnknownTimeZone as f,adoptTimeZone as c}from"./UnknownTimeZone.js";import{DateTime as l}from"luxon";function w(r){return!!t(r)||!!n(r)}function p(r){return!!t(r)||(!!o(r)||(!!n(r)||!!i(r)))}function m(i){if(t(i))return i.toMillis();if(o(i))return i.toNumber();if(n(i))return i.toMilliseconds();throw new r(e.InvalidDataType)}function d(d,N,x,b){if(null==d||null==N)return null;if(a(d)){if(a(N))return h(d,N,x);if(s(N))return O(d,N,x);if(p(N))throw new r(e.InvalidOperator);if(o(N))throw new r(e.InvalidOperator)}else if(s(d)){if(a(N))return v(d,N,x);if(s(N))return I(d,N,x);if(t(N))throw new r(e.InvalidOperator);if(o(N))throw new r(e.InvalidOperator);if(i(N))throw new r(e.InvalidOperator);if(n(N))throw new r(e.InvalidOperator)}else if(t(d)){if(w(N))return d instanceof l&&f(d.zone)?N instanceof l&&!1===f(N.zone)?d=c(d,N.zone):N instanceof u&&(d=c(d,N.toDateTime().zone)):N instanceof l&&f(N.zone)&&(d instanceof l&&!1===f(d.zone)?N=c(N,d.zone):d instanceof u&&(N=c(N,d.toDateTime().zone))),h(m(d),m(N),x);if(s(N))throw new r(e.InvalidOperator);if(o(N))return z(d,N,x);if(i(N))throw new r(e.InvalidOperator);if(a(N))throw new r(e.InvalidOperator)}else if(o(d)){if(n(N))return M(d,N,x);if(t(N))return T(d,N,x);if(s(N))throw new r(e.InvalidOperator);if(o(N))return h(d.toNumber(),N.toNumber(),x);if(i(N))throw new r(e.InvalidOperator);if(a(N))throw new r(e.InvalidOperator)}else if(i(d)){if(i(N))return h(d.toNumber(),N.toNumber(),x);if(s(N))throw new r(e.InvalidOperator);if(a(N))throw new r(e.InvalidOperator);if(o(N))throw new r(e.InvalidOperator);if(w(N))throw new r(e.InvalidOperator)}else if(n(d)){if(w(N))return N instanceof l&&f(N.zone)&&(N=c(N,d.toDateTime().zone)),h(m(d),m(N),x);if(s(N))throw new r(e.InvalidOperator);if(o(N))return D(d,N,x);if(i(N))throw new r(e.InvalidOperator);if(a(N))throw new r(e.InvalidOperator)}switch(x){case"<>":return d!==N;case"=":return d===N;case">":return d>N;case"<":return d<N;case">=":return d>=N;case"<=":return d<=N}}function h(r,e,t){switch(t){case"<>":return r!==e;case"=":return r===e;case">":return r>e;case"<":return r<e;case">=":return r>=e;case"<=":return r<=e}}function O(r,e,t){const n=parseFloat(e);if(!isNaN(n))return h(r,n,t);const o=r.toString();switch(t){case"<>":return o!==e;case"=":return o===e;case">":return o>e;case"<":return o<e;case">=":return o>=e;case"<=":return o<=e}}function v(r,e,t){const n=parseFloat(r);if(!isNaN(n))return h(n,e,t);const o=e.toString();switch(t){case"<>":return r!==o;case"=":return r===o;case">":return r>o;case"<":return r<o;case">=":return r>=o;case"<=":return r<=o}}function I(r,e,t){switch(t){case"<>":return r!==e;case"=":return r===e;case">":return r>e;case"<":return r<e;case">=":return r>=e;case"<=":return r<=e}}function z(r,e,t){const n=e.toDateTimeLuxon(r.zone);return h((r=r.startOf("day")).toMillis(),n.toMillis(),t)}function D(r,e,t){const n=e.toDateTimeLuxon(r.toDateTime().zone);return h((r=r.startOfDay()).toMilliseconds(),n.toMillis(),t)}function T(r,e,t){const n=r.toDateTimeLuxon(e.zone);return e=e.startOf("day"),h(n.toMillis(),e.toMillis(),t)}function M(r,e,t){const n=r.toDateTimeLuxon(e.toDateTime().zone);return e=e.startOfDay(),h(n.toMillis(),e.toMilliseconds(),t)}export{m as dateValueInMilliseconds,p as isDateOrTimeValue,w as isDateTimeComparableValue,d as sqlCompare};
5
+ import{SqlError as r,SqlErrorCodes as e}from"../../arcade/featureset/support/errorsupport.js";import{isDateTime as t,isTimestampOffset as n,isDateOnly as i,isTimeOnly as o,isNumber as a,isString as s}from"./sqlDateParsingUtils.js";import{SqlTimeStampOffset as u}from"./SqlTimestampOffset.js";import{isUnknownTimeZone as f}from"./UnknownTimeZone.js";import{DateTime as c}from"luxon";const l=321408e5,w=26784e5,p=864e5,d=36e5,m=6e4;function h(r){return!!t(r)||!!n(r)}function O(r){return!!t(r)||(!!i(r)||(!!n(r)||!!o(r)))}function v(o){if(t(o))return o.toMillis();if(i(o))return o.toNumber();if(n(o))return o.toMilliseconds();throw new r(e.InvalidDataType)}function I(l,w,p,d){if(null==l||null==w)return null;if(a(l)){if(a(w))return D(l,w,p);if(s(w))return T(l,w,p);if(O(w))throw new r(e.InvalidOperator);if(i(w))throw new r(e.InvalidOperator)}else if(s(l)){if(a(w))return M(l,w,p);if(s(w))return z(l,w,p);if(t(w))throw new r(e.InvalidOperator);if(i(w))throw new r(e.InvalidOperator);if(o(w))throw new r(e.InvalidOperator);if(n(w))throw new r(e.InvalidOperator)}else if(t(l)){if(h(w)){if(l instanceof c&&f(l.zone)){if(w instanceof c&&!1===f(w.zone))return j(l,w,p);if(w instanceof u)return j(l,w,p)}else if(w instanceof c&&f(w.zone)){if(l instanceof c&&!1===f(l.zone))return j(l,w,p);if(l instanceof u)return j(l,w,p)}return D(v(l),v(w),p)}if(s(w))throw new r(e.InvalidOperator);if(i(w))return N(l,w,p);if(o(w))throw new r(e.InvalidOperator);if(a(w))throw new r(e.InvalidOperator)}else if(i(l)){if(n(w))return b(l,w,p);if(t(w))return x(l,w,p);if(s(w))throw new r(e.InvalidOperator);if(i(w))return D(l.toNumber(),w.toNumber(),p);if(o(w))throw new r(e.InvalidOperator);if(a(w))throw new r(e.InvalidOperator)}else if(o(l)){if(o(w))return D(l.toNumber(),w.toNumber(),p);if(s(w))throw new r(e.InvalidOperator);if(a(w))throw new r(e.InvalidOperator);if(i(w))throw new r(e.InvalidOperator);if(h(w))throw new r(e.InvalidOperator)}else if(n(l)){if(h(w))return w instanceof c&&f(w.zone)?j(l,w,p):D(v(l),v(w),p);if(s(w))throw new r(e.InvalidOperator);if(i(w))return y(l,w,p);if(o(w))throw new r(e.InvalidOperator);if(a(w))throw new r(e.InvalidOperator)}switch(p){case"<>":return l!==w;case"=":return l===w;case">":return l>w;case"<":return l<w;case">=":return l>=w;case"<=":return l<=w}}function D(r,e,t){switch(t){case"<>":return r!==e;case"=":return r===e;case">":return r>e;case"<":return r<e;case">=":return r>=e;case"<=":return r<=e}}function T(r,e,t){const n=parseFloat(e);if(!isNaN(n))return D(r,n,t);const i=r.toString();switch(t){case"<>":return i!==e;case"=":return i===e;case">":return i>e;case"<":return i<e;case">=":return i>=e;case"<=":return i<=e}}function M(r,e,t){const n=parseFloat(r);if(!isNaN(n))return D(n,e,t);const i=e.toString();switch(t){case"<>":return r!==i;case"=":return r===i;case">":return r>i;case"<":return r<i;case">=":return r>=i;case"<=":return r<=i}}function z(r,e,t){switch(t){case"<>":return r!==e;case"=":return r===e;case">":return r>e;case"<":return r<e;case">=":return r>=e;case"<=":return r<=e}}function N(r,e,t){const n=e.toDateTimeLuxon(r.zone);return D((r=r.startOf("day")).toMillis(),n.toMillis(),t)}function y(r,e,t){const n=e.toDateTimeLuxon(r.toDateTime().zone);return D((r=r.startOfDay()).toMilliseconds(),n.toMillis(),t)}function x(r,e,t){const n=r.toDateTimeLuxon(e.zone);return e=e.startOf("day"),D(n.toMillis(),e.toMillis(),t)}function b(r,e,t){const n=r.toDateTimeLuxon(e.toDateTime().zone);return e=e.startOfDay(),D(n.toMillis(),e.toMilliseconds(),t)}function j(r,e,t){r instanceof u&&(r=r.toDateTime()),e instanceof u&&(e=e.toDateTime());const n=L(r),i=L(e);switch(t){case"<>":return n!==i;case"=":return n===i;case">":return n>i;case"<":return n<i;case">=":return n>=i;case"<=":return n<=i}}function L(r){return r.year*l+r.month*w+r.day*p+r.hour*d+r.minute*m+1e3*r.second+r.millisecond}export{v as dateValueInMilliseconds,O as isDateOrTimeValue,h as isDateTimeComparableValue,I as sqlCompare};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{SqlError as n,SqlErrorCodes as e}from"../../arcade/featureset/support/errorsupport.js";import{DateOnly as t}from"./DateOnly.js";import{SqlInterval as r}from"./SqlInterval.js";import{SqlTimeStampOffset as a}from"./SqlTimestampOffset.js";import{TimeOnly as s}from"./TimeOnly.js";import{UnknownTimeZone as o,substituteUnknownTimezone as i}from"./UnknownTimeZone.js";import{DateTime as p}from"luxon";const d=/^(\d{1,2}):(\d{1,2}):(\d{1,2})$/,f=/^(\d{1,2}):(\d{1,2})$/,l=/^(\d{1,2}):(\d{1,2}):(\d{1,2}).([0-9]+)$/,u=/^(\d{4})-(\d{1,2})-(\d{1,2})$/,c=/^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})(\.[0-9]+)?$/,m=/^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})(\.[0-9]+)?[ ]{0,1}(\+|\-)(\d{1,2}):(\d{1,2})$/,I=/^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2})?[ ]{0,1}(\+|\-)(\d{1,2}):(\d{1,2})$/,w=/^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2})$/;function h(n,e){switch(e){case"system":case"local":case null:return p.fromJSDate(n);default:return"unknown"===e?.toLowerCase()?p.fromMillis(n.getTime(),{zone:o.instance}):p.fromJSDate(n).setZone(e)}}function T(n){return"number"==typeof n}function v(n){return"string"==typeof n||n instanceof String}function y(n){return n instanceof r}function x(n){return n instanceof Date}function S(n){return n instanceof p}function j(n){return n instanceof t}function $(n){return n instanceof s}function D(n){return n instanceof a}function O(t){let r=d.exec(t);if(null!==r){const[,t,a,o]=r,i=s.fromParts(parseInt(t,10),parseInt(a,10),parseInt(o,10),0);if(null!==i)return i;throw new n(e.InvalidTime)}if(r=f.exec(t),null!==r){const[,t,a]=r,o=s.fromParts(parseInt(t,10),parseInt(a,10),0,0);if(null!==o)return o;throw new n(e.InvalidTime)}if(r=l.exec(t),null!==r){const[,t,a,o,i]=r,p=s.fromParts(parseInt(t,10),parseInt(a,10),parseInt(o,10),parseInt(i,10));if(null!==p)return p;throw new n(e.InvalidTime)}throw new n(e.InvalidTime)}function P(t,r,s=!1){let o=c.exec(t);if(null!==o){const[,t,a,s,d,f,l,u]=o,c=p.fromObject({year:parseInt(t,10),month:parseInt(a,10),day:parseInt(s,10),hour:parseInt(d,10),minute:parseInt(f,10),second:parseInt(l,10),millisecond:u?parseInt(u.replace(".",""),10):0},{zone:i(r)});if(!1===c.isValid)throw new n(e.InvalidTimeStamp);return c}if(o=m.exec(t),null!==o){const[,t,r,s,i,p,d,f,l,u,c]=o,m=a.fromParts(parseInt(t,10),parseInt(r,10),parseInt(s,10),parseInt(i,10),parseInt(p,10),parseInt(d,10),f?parseInt(f.replace(".",""),10):0,"-"===l,parseInt(u,10),parseInt(c,10));if(!1===m.isValid)throw new n(e.InvalidTimeStamp);return m}if(o=I.exec(t),null!==o){const[,t,r,s,i,p,d,f,l]=o,u=a.fromParts(parseInt(t,10),parseInt(r,10),parseInt(s,10),parseInt(i,10),parseInt(p,10),0,0,"-"===d,parseInt(f,10),parseInt(l,10));if(!1===u.isValid)throw new n(e.InvalidTimeStamp);return u}if(o=w.exec(t),null!==o){const[,t,a,s,d,f]=o,l=p.fromObject({year:parseInt(t,10),month:parseInt(a,10),day:parseInt(s,10),hour:parseInt(d,10),minute:parseInt(f,10),second:0},{zone:i(r)});if(!1===l.isValid)throw new n(e.InvalidTimeStamp);return l}if(o=u.exec(t),null!==o){const[,t,a,s]=o,d=p.fromObject({year:parseInt(t,10),month:parseInt(a,10),day:parseInt(s,10),hour:0,minute:0,second:0},{zone:i(r)});if(!1===d.isValid)throw new n(e.InvalidTimeStamp);return d}throw new n(e.InvalidTimeStamp)}function V(r,a){const s=u.exec(r);if(null===s)try{return P(r,a)}catch{throw new n(e.InvalidDate)}const[,o,i,p]=s,d=t.fromParts(parseInt(o,10),parseInt(i,10),parseInt(p,10));if(null===d)throw new n(e.InvalidDate);return d}export{h as convertToExecutingTimeZone,x as isDate,j as isDateOnly,S as isDateTime,T as isNumber,y as isSqlInterval,v as isString,$ as isTimeOnly,D as isTimestampOffset,V as parseDate,O as parseTime,P as parseTimestamp};
5
+ import{SqlError as n,SqlErrorCodes as e}from"../../arcade/featureset/support/errorsupport.js";import{DateOnly as t}from"./DateOnly.js";import{SqlInterval as r}from"./SqlInterval.js";import{SqlTimeStampOffset as a}from"./SqlTimestampOffset.js";import{TimeOnly as o}from"./TimeOnly.js";import{UnknownTimeZone as s,substituteUnknownTimezone as i}from"./UnknownTimeZone.js";import{Zone as f,DateTime as p}from"luxon";const l=/^(\d{1,2}):(\d{1,2}):(\d{1,2})$/,d=/^(\d{1,2}):(\d{1,2})$/,c=/^(\d{1,2}):(\d{1,2}):(\d{1,2}).([0-9]+)$/,u=/^(\d{4})-(\d{1,2})-(\d{1,2})$/,m=/^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})(\.[0-9]+)?$/,I=/^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})(\.[0-9]+)?[ ]{0,1}(\+|\-)(\d{1,2}):(\d{1,2})$/,w=/^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2})?[ ]{0,1}(\+|\-)(\d{1,2}):(\d{1,2})$/,h=/^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2})$/;function T(n,e){if(e instanceof f)return e===s.instance?p.fromMillis(n.getTime(),{zone:s.instance}):p.fromJSDate(n,{zone:e});switch(e){case"system":case"local":case null:return p.fromJSDate(n);default:return"unknown"===e?.toLowerCase()?p.fromMillis(n.getTime(),{zone:s.instance}):p.fromJSDate(n,{zone:e})}}function v(n){return"number"==typeof n}function y(n){return"string"==typeof n||n instanceof String}function S(n){return n instanceof r}function x(n){return n instanceof Date}function j(n){return n instanceof p}function $(n){return n instanceof t}function z(n){return n instanceof o}function D(n){return n instanceof a}function O(t){let r=l.exec(t);if(null!==r){const[,t,a,s]=r,i=o.fromParts(parseInt(t,10),parseInt(a,10),parseInt(s,10),0);if(null!==i)return i;throw new n(e.InvalidTime)}if(r=d.exec(t),null!==r){const[,t,a]=r,s=o.fromParts(parseInt(t,10),parseInt(a,10),0,0);if(null!==s)return s;throw new n(e.InvalidTime)}if(r=c.exec(t),null!==r){const[,t,a,s,i]=r,f=o.fromParts(parseInt(t,10),parseInt(a,10),parseInt(s,10),parseInt(i,10));if(null!==f)return f;throw new n(e.InvalidTime)}throw new n(e.InvalidTime)}function P(t,r,o=!1){let s=m.exec(t);if(null!==s){const[,t,a,o,f,l,d,c]=s,u=p.fromObject({year:parseInt(t,10),month:parseInt(a,10),day:parseInt(o,10),hour:parseInt(f,10),minute:parseInt(l,10),second:parseInt(d,10),millisecond:c?parseInt(c.replace(".",""),10):0},{zone:i(r)});if(!1===u.isValid)throw new n(e.InvalidTimeStamp);return u}if(s=I.exec(t),null!==s){const[,t,r,o,i,f,p,l,d,c,u]=s,m=a.fromParts(parseInt(t,10),parseInt(r,10),parseInt(o,10),parseInt(i,10),parseInt(f,10),parseInt(p,10),l?parseInt(l.replace(".",""),10):0,"-"===d,parseInt(c,10),parseInt(u,10));if(!1===m.isValid)throw new n(e.InvalidTimeStamp);return m}if(s=w.exec(t),null!==s){const[,t,r,o,i,f,p,l,d]=s,c=a.fromParts(parseInt(t,10),parseInt(r,10),parseInt(o,10),parseInt(i,10),parseInt(f,10),0,0,"-"===p,parseInt(l,10),parseInt(d,10));if(!1===c.isValid)throw new n(e.InvalidTimeStamp);return c}if(s=h.exec(t),null!==s){const[,t,a,o,f,l]=s,d=p.fromObject({year:parseInt(t,10),month:parseInt(a,10),day:parseInt(o,10),hour:parseInt(f,10),minute:parseInt(l,10),second:0},{zone:i(r)});if(!1===d.isValid)throw new n(e.InvalidTimeStamp);return d}if(s=u.exec(t),null!==s){const[,t,a,o]=s,f=p.fromObject({year:parseInt(t,10),month:parseInt(a,10),day:parseInt(o,10),hour:0,minute:0,second:0},{zone:i(r)});if(!1===f.isValid)throw new n(e.InvalidTimeStamp);return f}throw new n(e.InvalidTimeStamp)}function V(r,a){const o=u.exec(r);if(null===o)try{return P(r,a)}catch{throw new n(e.InvalidDate)}const[,s,i,f]=o,p=t.fromParts(parseInt(s,10),parseInt(i,10),parseInt(f,10));if(null===p)throw new n(e.InvalidDate);return p}export{T as convertToExecutingTimeZone,x as isDate,$ as isDateOnly,j as isDateTime,v as isNumber,S as isSqlInterval,y as isString,z as isTimeOnly,D as isTimestampOffset,V as parseDate,O as parseTime,P as parseTimestamp};
package/kernel.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";import{buildDate as s,commitHash as e}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const r="4.28";let t,i=r;i="4.28.6";function n(o){t=o}function m(s){const e=t?.findCredential(s);return e?.token?o(s,"token",e.token):s}has("host-webworker");export{m as addTokenParameter,s as buildDate,i as fullVersion,t as id,e as revision,n as setId,r as version};
5
+ import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";import{buildDate as s,commitHash as e}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const r="4.28";let t,i=r;i="4.28.8";function n(o){t=o}function m(s){const e=t?.findCredential(s);return e?.token?o(s,"token",e.token):s}has("host-webworker");export{m as addTokenParameter,s as buildDate,i as fullVersion,t as id,e as revision,n as setId,r as version};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../core/Error.js";import{isSerializable as i}from"../../core/JSONSupport.js";import t from"../../core/Logger.js";import{isDateField as s,isNumericField as n,isObjectIDField as l,isGlobalIDField as r,getFieldDefaultValue as d,isTimeOnlyField as o,normalizeFieldName as a}from"./fieldUtils.js";import{utc as m,unknown as u,fromTimeReference as f}from"../../time/timeZoneUtils.js";function F(e){return"timeZone"in e}function h(e){return"timeZone"in e}function p(e){return"dateFieldsTimeZone"in e}class c{static fromJSON(e){return new c(e.fields,e.timeZoneByFieldName)}static fromLayer(e){return new c(e.fields??[],T(e))}static fromLayerJSON(e){return new c(e.fields??[],T(e))}constructor(e=[],i){this._fieldsMap=new Map,this._normalizedFieldsMap=new Map,this._dateFieldsSet=new Set,this._numericFieldsSet=new Set,this._requiredFields=null,this.dateFields=[],this.numericFields=[],this.fields=e||[],this._timeZoneByFieldName=i?new Map(i):null;const t=[];for(const d of this.fields){const e=d?.name,i=_(e);if(e&&i){const o=y(e);this._fieldsMap.set(e,d),this._fieldsMap.set(o,d),this._normalizedFieldsMap.set(i,d),t.push(`${o}:${d.type}:${this._timeZoneByFieldName?.get(e)}`),s(d)?(this.dateFields.push(d),this._dateFieldsSet.add(d)):n(d)&&(this._numericFieldsSet.add(d),this.numericFields.push(d)),l(d)||r(d)||(d.editable=null==d.editable||!!d.editable,d.nullable=null==d.nullable||!!d.nullable)}}t.sort(),this.uid=t.join()}get requiredFields(){if(!this._requiredFields){this._requiredFields=[];for(const e of this.fields)l(e)||r(e)||e.nullable||void 0!==d(e)||this._requiredFields.push(e)}return this._requiredFields}equals(e){return this.uid===e?.uid}has(e){return null!=this.get(e)}get(e){if(!e)return;let i=this._fieldsMap.get(e);return i||(i=this._fieldsMap.get(y(e))??this._normalizedFieldsMap.get(_(e)),i&&this._fieldsMap.set(e,i),i)}getTimeZone(i){const s=this.get(i&&"string"!=typeof i?i.name:i);return s?this._timeZoneByFieldName?this._timeZoneByFieldName.get(s.name):"date"===s.type||"esriFieldTypeDate"===s.type?(t.getLogger("esri.layers.support.FieldsIndex").error(new e("getTimeZone:no-timezone-information",`no time zone information for field '${s.name}'`)),m):g.has(s.type)?u:null:null}isDateField(e){return this._dateFieldsSet.has(this.get(e))}isTimeOnlyField(e){return o(this.get(e))}isNumericField(e){return this._numericFieldsSet.has(this.get(e))}normalizeFieldName(e){return this.get(e)?.name??void 0}toJSON(){return{fields:this.fields.map((e=>i(e)?e.toJSON():e)),timeZoneByFieldName:this._timeZoneByFieldName?Array.from(this._timeZoneByFieldName.entries()):null}}}function y(e){return e.trim().toLowerCase()}function _(e){return a(e)?.toLowerCase()??""}const g=new Set(["time-only","date-only","timestamp-offset","esriFieldTypeDateOnly","esriFieldTypeTimeOnly","esriFieldTypeTimestampOffset"]);function T(e){const i=new Map;if(!e.fields)return i;const t=!0===e.datesInUnknownTimezone,{timeInfo:s,editFieldsInfo:n}=e,l=(s?"startField"in s?s.startField:s.startTimeField:"")??"",r=(s?"endField"in s?s.endField:s.endTimeField:"")??"",d=p(e)?e.dateFieldsTimeZone??null:e.dateFieldsTimeReference?f(e.dateFieldsTimeReference):null,o=n?F(n)?n.timeZone??d:n.dateFieldsTimeReference?f(n.dateFieldsTimeReference):d??m:null,a=s?h(s)?s.timeZone??d:s.timeReference?f(s.timeReference):d:null,c=new Map([[y(n?.creationDateField??""),o],[y(n?.editDateField??""),o],[y(l),a],[y(r),a]]);for(const{name:m,type:f}of e.fields)if(g.has(f))i.set(m,u);else if("date"!==f&&"esriFieldTypeDate"!==f)i.set(m,null);else if(t)i.set(m,u);else{const e=c.get(y(m??""))??d;i.set(m,e)}return i}export{c as default};
5
+ import e from"../../core/Error.js";import{isSerializable as i}from"../../core/JSONSupport.js";import t from"../../core/Logger.js";import{getOrCreateMapValue as s}from"../../core/MapUtils.js";import{UnknownTimeZone as n}from"../../core/sql/UnknownTimeZone.js";import{isDateField as r,isNumericField as l,isObjectIDField as o,isGlobalIDField as d,getFieldDefaultValue as a,isTimeOnlyField as m,normalizeFieldName as u}from"./fieldUtils.js";import{utc as f,unknown as F,fromTimeReference as h}from"../../time/timeZoneUtils.js";import{FixedOffsetZone as c,IANAZone as p}from"luxon";function y(e){return"timeZone"in e}function _(e){return"timeZone"in e}function g(e){return"dateFieldsTimeZone"in e}const T=new Map;class Z{static fromJSON(e){return new Z(e.fields,e.timeZoneByFieldName)}static fromLayer(e){return new Z(e.fields??[],S(e))}static fromLayerJSON(e){return new Z(e.fields??[],S(e))}constructor(e=[],i){this._fieldsMap=new Map,this._normalizedFieldsMap=new Map,this._dateFieldsSet=new Set,this._numericFieldsSet=new Set,this._requiredFields=null,this.dateFields=[],this.numericFields=[],this.fields=e||[],this._timeZoneByFieldName=i?new Map(i):null;const t=[];for(const s of this.fields){const e=s?.name,i=M(e);if(e&&i){const n=w(e);this._fieldsMap.set(e,s),this._fieldsMap.set(n,s),this._normalizedFieldsMap.set(i,s),t.push(`${n}:${s.type}:${this._timeZoneByFieldName?.get(e)}`),r(s)?(this.dateFields.push(s),this._dateFieldsSet.add(s)):l(s)&&(this._numericFieldsSet.add(s),this.numericFields.push(s)),o(s)||d(s)||(s.editable=null==s.editable||!!s.editable,s.nullable=null==s.nullable||!!s.nullable)}}t.sort(),this.uid=t.join()}get requiredFields(){if(!this._requiredFields){this._requiredFields=[];for(const e of this.fields)o(e)||d(e)||e.nullable||void 0!==a(e)||this._requiredFields.push(e)}return this._requiredFields}equals(e){return this.uid===e?.uid}has(e){return null!=this.get(e)}get(e){if(!e)return;let i=this._fieldsMap.get(e);return i||(i=this._fieldsMap.get(w(e))??this._normalizedFieldsMap.get(M(e)),i&&this._fieldsMap.set(e,i),i)}getTimeZone(i){const s=this.get(i&&"string"!=typeof i?i.name:i);return s?this._timeZoneByFieldName?this._timeZoneByFieldName.get(s.name):"date"===s.type||"esriFieldTypeDate"===s.type?(t.getLogger("esri.layers.support.FieldsIndex").error(new e("getTimeZone:no-timezone-information",`no time zone information for field '${s.name}'`)),f):N.has(s.type)?F:null:null}getLuxonTimeZone(e){const i=this.getTimeZone(e);return i?i===F?n.instance:i===f?c.utcInstance:s(T,i,(()=>p.create(i))):null}isDateField(e){return this._dateFieldsSet.has(this.get(e))}isTimeOnlyField(e){return m(this.get(e))}isNumericField(e){return this._numericFieldsSet.has(this.get(e))}normalizeFieldName(e){return this.get(e)?.name??void 0}toJSON(){return{fields:this.fields.map((e=>i(e)?e.toJSON():e)),timeZoneByFieldName:this._timeZoneByFieldName?Array.from(this._timeZoneByFieldName.entries()):null}}}function w(e){return e.trim().toLowerCase()}function M(e){return u(e)?.toLowerCase()??""}const N=new Set(["time-only","date-only","timestamp-offset","esriFieldTypeDateOnly","esriFieldTypeTimeOnly","esriFieldTypeTimestampOffset"]);function S(e){const i=new Map;if(!e.fields)return i;const t=!0===e.datesInUnknownTimezone,{timeInfo:s,editFieldsInfo:n}=e,r=(s?"startField"in s?s.startField:s.startTimeField:"")??"",l=(s?"endField"in s?s.endField:s.endTimeField:"")??"",o=g(e)?e.dateFieldsTimeZone??null:e.dateFieldsTimeReference?h(e.dateFieldsTimeReference):null,d=n?y(n)?n.timeZone??o:n.dateFieldsTimeReference?h(n.dateFieldsTimeReference):o??f:null,a=s?_(s)?s.timeZone??o:s.timeReference?h(s.timeReference):o:null,m=new Map([[w(n?.creationDateField??""),d],[w(n?.editDateField??""),d],[w(r),a],[w(l),a]]);for(const{name:u,type:f}of e.fields)if(N.has(f))i.set(u,F);else if("date"!==f&&"esriFieldTypeDate"!==f)i.set(u,null);else if(t)i.set(u,F);else{const e=m.get(w(u??""))??o;i.set(u,e)}return i}export{Z as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.28.6",
3
+ "version": "4.28.8",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- const c="20231101",e="f93dcf3e52237cc72e8ed2a8df36d88c9bba7ae7";export{c as buildDate,e as commitHash};
5
+ const e="20231107",b="2701956fe778d3eb0b5dc84951136bfe12a19332";export{e as buildDate,b as commitHash};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{disposeMaybe as t}from"../../../../core/maybe.js";import{t as s}from"../../../../chunks/common.js";import{k as i,c as e,r,h as o}from"../../../../chunks/mat3.js";import{c as a}from"../../../../chunks/mat3f32.js";import{f as n}from"../../../../chunks/vec2f64.js";import{s as c}from"../../../../chunks/vec3.js";import{c as h}from"../../../../chunks/vec3f64.js";import m from"./VertexStream.js";import{stencil as l}from"./shaders/StencilPrograms.js";import{CompareFunction as d,StencilOperation as _}from"../../../webgl/enums.js";import{createProgram as p}from"../../../webgl/ProgramTemplate.js";const u=n(-.5,-.5);class f{constructor(){this._centerNdc=h(),this._pxToNdc=h(),this._worldDimensionsPx=h(),this._mat3=a(),this._initialized=!1}dispose(){this._program=t(this._program),this._quad=t(this._quad)}render(t,s,i){const{context:e}=t,r=this._updateGeometry(t,i);if(null!=s){const{r:t,g:i,b:r,a:o}=s;e.setClearColor(o*t/255,o*i/255,o*r/255,o)}else e.setClearColor(0,0,0,0);if(e.setStencilFunction(d.ALWAYS,0,255),e.setStencilWriteMask(255),!r)return e.setClearStencil(1),void e.clear(e.gl.STENCIL_BUFFER_BIT);e.setClearStencil(0),e.clear(e.gl.STENCIL_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT),this._initialized||this._initialize(e),e.setDepthWriteEnabled(!1),e.setDepthTestEnabled(!1),e.setColorMask(!1,!1,!1,!1),e.setBlendingEnabled(!1),e.setStencilOp(_.KEEP,_.KEEP,_.REPLACE),e.setStencilFunction(d.ALWAYS,1,255),e.setStencilTestEnabled(!0),e.useProgram(this._program),this._program.setUniformMatrix3fv("u_worldExtent",this._mat3),this._quad.draw(),this._quad.unbind()}_initialize(t){if(this._initialized)return;const s=p(t,l);s&&(this._program=s,this._quad=new m(t,[0,0,1,0,0,1,1,1]),this._initialized=!0)}_updateGeometry(t,a){const{state:n,pixelRatio:h}=t,{size:m,rotation:l}=n,d=Math.round(m[0]*h),_=Math.round(m[1]*h);if(!n.spatialReference.isWrappable)return!1;const p=s(l),f=Math.abs(Math.cos(p)),g=Math.abs(Math.sin(p)),E=Math.round(d*f+_*g),S=Math.round(n.worldScreenWidth);if(E<=S)return!1;const b=d*g+_*f,x=S*h,j=(a.left-a.right)*h/d,C=(a.bottom-a.top)*h/_;c(this._worldDimensionsPx,x,b,1),c(this._pxToNdc,2/d,-2/_,1),c(this._centerNdc,j,C,1);const M=this._mat3;return i(M,this._centerNdc),e(M,M,this._pxToNdc),0!==l&&r(M,M,p),e(M,M,this._worldDimensionsPx),o(M,M,u),!0}}export{f as WorldExtentRenderer};
5
+ import{disposeMaybe as t}from"../../../../core/maybe.js";import{t as s}from"../../../../chunks/common.js";import{k as i,c as e,r,h as o}from"../../../../chunks/mat3.js";import{c as a}from"../../../../chunks/mat3f32.js";import{f as n}from"../../../../chunks/vec2f64.js";import{s as c}from"../../../../chunks/vec3.js";import{c as h}from"../../../../chunks/vec3f64.js";import l from"./VertexStream.js";import{stencil as m}from"./shaders/StencilPrograms.js";import{CompareFunction as _,StencilOperation as d}from"../../../webgl/enums.js";import{createProgram as p}from"../../../webgl/ProgramTemplate.js";const u=n(-.5,-.5);class f{constructor(){this._centerNdc=h(),this._pxToNdc=h(),this._worldDimensionsPx=h(),this._mat3=a(),this._initialized=!1}dispose(){this._program=t(this._program),this._quad=t(this._quad)}render(t,s,i){const{context:e}=t,r=this._updateGeometry(t,i);if(null!=s){const{r:t,g:i,b:r,a:o}=s;e.setClearColor(o*t/255,o*i/255,o*r/255,o)}else e.setClearColor(0,0,0,0);if(e.setStencilFunction(_.ALWAYS,0,255),e.setStencilWriteMask(255),!r)return e.setClearStencil(1),void e.clear(e.gl.STENCIL_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT);e.setClearStencil(0),e.clear(e.gl.STENCIL_BUFFER_BIT|e.gl.COLOR_BUFFER_BIT),this._initialized||this._initialize(e),e.setDepthWriteEnabled(!1),e.setDepthTestEnabled(!1),e.setColorMask(!1,!1,!1,!1),e.setBlendingEnabled(!1),e.setStencilOp(d.KEEP,d.KEEP,d.REPLACE),e.setStencilFunction(_.ALWAYS,1,255),e.setStencilTestEnabled(!0),e.useProgram(this._program),this._program.setUniformMatrix3fv("u_worldExtent",this._mat3),this._quad.draw(),this._quad.unbind()}_initialize(t){if(this._initialized)return;const s=p(t,m);s&&(this._program=s,this._quad=new l(t,[0,0,1,0,0,1,1,1]),this._initialized=!0)}_updateGeometry(t,a){const{state:n,pixelRatio:h}=t,{size:l,rotation:m}=n,_=Math.round(l[0]*h),d=Math.round(l[1]*h);if(!n.spatialReference.isWrappable)return!1;const p=s(m),f=Math.abs(Math.cos(p)),g=Math.abs(Math.sin(p)),E=Math.round(_*f+d*g),S=Math.round(n.worldScreenWidth);if(E<=S)return!1;const b=_*g+d*f,x=S*h,C=(a.left-a.right)*h/_,T=(a.bottom-a.top)*h/d;c(this._worldDimensionsPx,x,b,1),c(this._pxToNdc,2/_,-2/d,1),c(this._centerNdc,C,T,1);const j=this._mat3;return i(j,this._centerNdc),e(j,j,this._pxToNdc),0!==m&&r(j,j,p),e(j,j,this._worldDimensionsPx),o(j,j,u),!0}}export{f as WorldExtentRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import{bidiText as t}from"../../../../../core/BidiText.js";import"../../../../../core/Error.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import{assertIsSome as s}from"../../../../../core/maybe.js";import{throwIfAborted as r,isAbortError as i}from"../../../../../core/promiseUtils.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import{subclass as a}from"../../../../../core/accessorSupport/decorators/subclass.js";import{diff as o,hasDiff as n}from"../../../../../core/accessorSupport/diffUtils.js";import l from"../../../../../geometry/SpatialReference.js";import{isAggregateId as c}from"../../../engine/webgl/DisplayId.js";import{WGLSymbologyType as d}from"../../../engine/webgl/enums.js";import{MeshData as h}from"../../../engine/webgl/mesh/MeshData.js";import{WGLMeshFactory as f}from"../../../engine/webgl/mesh/factories/WGLMeshFactory.js";import{WGLTemplateStore as u}from"../../../engine/webgl/mesh/templates/WGLTemplateStore.js";import{createMatcher as m}from"../../../engine/webgl/util/Matcher.js";import{codepoints as g}from"../textUtils.js";import p from"./BaseProcessor.js";import y from"../support/ResourceManagerProxy.js";function _(e,t){const s=t-t/2,r=t+t/4;return(!e.minScale||e.minScale>=s)&&(!e.maxScale||e.maxScale<=r)}function b(e){const t=e.message,s={message:{data:{},tileKey:t.tileKey,tileKeyOrigin:t.tileKeyOrigin,version:t.version},transferList:new Array};for(const r in t.data){const e=r,i=t.data[e];if(s.message.data[e]=null,null!=i){const t=i.stride,r=i.indices.slice(0),a=i.vertices.slice(0),o=i.records.slice(0),n=i.metrics?.slice(0),l={stride:t,indices:r,vertices:a,records:o,metrics:n};s.transferList.push(r,a,o),s.message.data[e]=l}}return s}let S=class extends p{constructor(){super(...arguments),this.type="symbol",this._matchers={feature:null,aggregate:null},this._bufferData=new Map,this._bufferIds=new Map}initialize(){this.addHandles([this.tileStore.on("update",this.onTileUpdate.bind(this))]),this._resourceManagerProxy=new y(this.remoteClient)}destroy(){this._resourceManagerProxy.destroy()}get supportsTileUpdates(){return!0}forEachBufferId(e){this._bufferIds.forEach((t=>{t.forEach(e)}))}async update(e,t){const s=t.schema.processors[0];if("symbol"!==s.type)return;const r=o(this._schema,s);(n(r,"mesh")||n(r,"target"))&&(e.mesh=!0,e.why?.mesh.push("Symbology changed"),this._schema=s,this._factory=this._createFactory(s),this._factory.update(s,this.tileStore.tileScheme.tileInfo))}onTileMessage(e,t,s,i){return r(i),this._onTileData(e,t,s,i)}onTileClear(e,t){const s={clear:!0,end:t};return this._bufferData.delete(e.key.id),this._bufferIds.delete(e.key.id),this.remoteClient.invoke("tileRenderer.onTileData",{tileKey:e.id,data:s})}onTileError(e,t,s){const r=s.signal,i={tileKey:e.id,error:t};return this.remoteClient.invoke("tileRenderer.onTileError",i,{signal:r})}onTileUpdate(e){for(const t of e.removed)this._bufferData.has(t.key.id)&&this._bufferData.delete(t.key.id),this._bufferIds.has(t.key.id)&&this._bufferIds.delete(t.key.id);for(const t of e.added)this._bufferData.forEach((e=>{for(const s of e)s.message.tileKey===t.id&&this._updateTileMesh("append",t,b(s),[],!1,!1,null)}))}_addBufferData(e,t){this._bufferData.has(e)||this._bufferData.set(e,[]),this._bufferData.get(e)?.push(b(t))}_createFactory(e){const{geometryType:t,objectIdField:s,fields:r}=this.service,i=(e,t)=>this.remoteClient.invoke("tileRenderer.getMaterialItems",e,t),a={geometryType:t,fields:r,spatialReference:l.fromJSON(this.spatialReference)},o=new u(i,this.tileStore.tileScheme.tileInfo),{matcher:n,aggregateMatcher:c}=e.mesh;return this._store=o,this._matchers.feature=m(n,o,a,this._resourceManagerProxy),this._matchers.aggregate=c?m(c,o,a,this._resourceManagerProxy):null,new f(t,s,o)}async _onTileData(e,t,s,i){r(i);const{type:a,addOrUpdate:o,remove:n,clear:l,end:c}=t,d=!!this._schema.mesh.sortKey;if(!o){const t={type:a,addOrUpdate:null,remove:n,clear:l,end:c,sort:d};return this.remoteClient.invoke("tileRenderer.onTileData",{tileKey:e.id,data:t},i)}const h=this._processFeatures(e,o,s,i,t.status?.version);try{const s=await h;if(null==s){const t={type:a,addOrUpdate:null,remove:n,clear:l,end:c,sort:d};return this.remoteClient.invoke("tileRenderer.onTileData",{tileKey:e.id,data:t},i)}const r=[];for(const t of s){let s=!1;const i=t.message.bufferIds,a=e.key.id,o=t.message.tileKey;if(a!==o&&null!=i){if(!this.tileStore.get(o)){this._addBufferData(a,t),r.push(t);continue}let e=this._bufferIds.get(o);e||(e=new Set,this._bufferIds.set(o,e));const n=Array.from(i);for(const t of n){if(e.has(t)){s=!0;break}e.add(t)}}s||(this._addBufferData(a,t),r.push(t))}await Promise.all(r.map((s=>{const r=e.key.id===s.message.tileKey,o=r?t.remove:[],n=r&&t.end;return this._updateTileMesh(a,e,s,o,n,!!t.clear,i.signal)})))}catch(f){this._handleError(e,f,i)}}async _updateTileMesh(e,t,s,i,a,o,n){const l=e,c=s.message.tileKey,d=!!this._schema.mesh.sortKey;c!==t.key.id&&(a=!1);const h=s?.message,f={type:l,addOrUpdate:h,remove:i,clear:o,end:a,sort:d},u={transferList:s?.transferList??[],signal:n};return r(u),this.remoteClient.invoke("tileRenderer.onTileData",{tileKey:c,data:f},u)}async _processFeatures(e,t,s,i,a){if(null==t||!t.hasFeatures)return null;const o={transform:e.transform,hasZ:!1,hasM:!1},n=this._factory,l={viewingMode:"",scale:e.scale},c=await this._matchers.feature,d=await this._matchers.aggregate;r(i);const h=this._getLabelInfos(e,t);return await n.analyze(t.getCursor(),this._resourceManagerProxy,c,d,o,l),r(i),this._writeFeatureSet(e,t,o,h,n,s,a)}_writeFeatureSet(e,t,s,r,i,a,o){const n=t.getSize(),l=this._schema.mesh.matcher.symbologyType,c=new h(e.key.id,{features:n,records:n,metrics:0},l,a,l!==d.HEATMAP,o),f={viewingMode:"",scale:e.scale},u=t.getCursor();for(;u.next();)try{const t=u.getDisplayId(),a=null!=r?r.get(t):null;i.writeCursor(c,u,s,f,e.level,a,this._resourceManagerProxy)}catch(g){}const m=e.tileInfoView.tileInfo.isWrappable;return c.serialize(m)}_handleError(e,t,s){if(!i(t)){const r={tileKey:e.id,error:t.message};return this.remoteClient.invoke("tileRenderer.onTileError",r,{signal:s.signal})}return Promise.resolve()}_getLabelingSchemaForScale(e){const t=this._schema.mesh.labels;if(null==t)return null;if("subtype"===t.type){const s={type:"subtype",classes:{}};let r=!1;for(const i in t.classes){const a=t.classes[i].filter((t=>_(t,e.scale)));r=r||!!a.length,s.classes[i]=a}return r?s:null}const s=t.classes.filter((t=>_(t,e.scale)));return s.length?{type:"simple",classes:s}:null}_getLabels(e,t){if("subtype"===t.type){const r=this.service.subtypeField;s(r,"Expected to find subtype Field");const i=e.readAttribute(r);return null==i?[]:t.classes[i]??[]}return t.classes}_getLabelInfos(e,s){const r=this._getLabelingSchemaForScale(e);if(null==r)return null;const i=new Map,a=s.getCursor();for(;a.next();){const e=a.getDisplayId(),s=[],o=c(e),n=o&&1!==a.readAttribute("cluster_count")?"aggregate":"feature",l=this._getLabels(a,r);for(const r of l){if(r.target!==n)continue;const i=a.getStorage(),l=o&&"feature"===n?i.getComputedStringAtIndex(a.readAttribute("referenceId"),r.fieldIndex):i.getComputedStringAtIndex(e,r.fieldIndex);if(!l)continue;const c=t(l.toString()),d=c[0],h=c[1];this._store.getMosaicItem(r.symbol,g(d)).then((e=>{s[r.index]={glyphs:e.glyphMosaicItems??[],rtl:h,index:r.index}}))}i.set(e,s)}return i}};S=e([a("esri.views.2d.layers.features.processors.SymbolProcessor")],S);const w=S;export{w as default};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import{bidiText as t}from"../../../../../core/BidiText.js";import"../../../../../core/Error.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import{assertIsSome as s}from"../../../../../core/maybe.js";import{throwIfAborted as r,isAbortError as i}from"../../../../../core/promiseUtils.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import{subclass as a}from"../../../../../core/accessorSupport/decorators/subclass.js";import{diff as o,hasDiff as n}from"../../../../../core/accessorSupport/diffUtils.js";import l from"../../../../../geometry/SpatialReference.js";import{isAggregateId as c}from"../../../engine/webgl/DisplayId.js";import{WGLSymbologyType as d}from"../../../engine/webgl/enums.js";import{MeshData as h}from"../../../engine/webgl/mesh/MeshData.js";import{WGLMeshFactory as f}from"../../../engine/webgl/mesh/factories/WGLMeshFactory.js";import{WGLTemplateStore as u}from"../../../engine/webgl/mesh/templates/WGLTemplateStore.js";import{createMatcher as m}from"../../../engine/webgl/util/Matcher.js";import{codepoints as g}from"../textUtils.js";import p from"./BaseProcessor.js";import y from"../support/ResourceManagerProxy.js";function _(e,t){const s=t-t/4,r=t+t/2;return(!e.minScale||e.minScale>=s)&&(!e.maxScale||e.maxScale<=r)}function b(e){const t=e.message,s={message:{data:{},tileKey:t.tileKey,tileKeyOrigin:t.tileKeyOrigin,version:t.version},transferList:new Array};for(const r in t.data){const e=r,i=t.data[e];if(s.message.data[e]=null,null!=i){const t=i.stride,r=i.indices.slice(0),a=i.vertices.slice(0),o=i.records.slice(0),n=i.metrics?.slice(0),l={stride:t,indices:r,vertices:a,records:o,metrics:n};s.transferList.push(r,a,o),s.message.data[e]=l}}return s}let S=class extends p{constructor(){super(...arguments),this.type="symbol",this._matchers={feature:null,aggregate:null},this._bufferData=new Map,this._bufferIds=new Map}initialize(){this.addHandles([this.tileStore.on("update",this.onTileUpdate.bind(this))]),this._resourceManagerProxy=new y(this.remoteClient)}destroy(){this._resourceManagerProxy.destroy()}get supportsTileUpdates(){return!0}forEachBufferId(e){this._bufferIds.forEach((t=>{t.forEach(e)}))}async update(e,t){const s=t.schema.processors[0];if("symbol"!==s.type)return;const r=o(this._schema,s);(n(r,"mesh")||n(r,"target"))&&(e.mesh=!0,e.why?.mesh.push("Symbology changed"),this._schema=s,this._factory=this._createFactory(s),this._factory.update(s,this.tileStore.tileScheme.tileInfo))}onTileMessage(e,t,s,i){return r(i),this._onTileData(e,t,s,i)}onTileClear(e,t){const s={clear:!0,end:t};return this._bufferData.delete(e.key.id),this._bufferIds.delete(e.key.id),this.remoteClient.invoke("tileRenderer.onTileData",{tileKey:e.id,data:s})}onTileError(e,t,s){const r=s.signal,i={tileKey:e.id,error:t};return this.remoteClient.invoke("tileRenderer.onTileError",i,{signal:r})}onTileUpdate(e){for(const t of e.removed)this._bufferData.has(t.key.id)&&this._bufferData.delete(t.key.id),this._bufferIds.has(t.key.id)&&this._bufferIds.delete(t.key.id);for(const t of e.added)this._bufferData.forEach((e=>{for(const s of e)s.message.tileKey===t.id&&this._updateTileMesh("append",t,b(s),[],!1,!1,null)}))}_addBufferData(e,t){this._bufferData.has(e)||this._bufferData.set(e,[]),this._bufferData.get(e)?.push(b(t))}_createFactory(e){const{geometryType:t,objectIdField:s,fields:r}=this.service,i=(e,t)=>this.remoteClient.invoke("tileRenderer.getMaterialItems",e,t),a={geometryType:t,fields:r,spatialReference:l.fromJSON(this.spatialReference)},o=new u(i,this.tileStore.tileScheme.tileInfo),{matcher:n,aggregateMatcher:c}=e.mesh;return this._store=o,this._matchers.feature=m(n,o,a,this._resourceManagerProxy),this._matchers.aggregate=c?m(c,o,a,this._resourceManagerProxy):null,new f(t,s,o)}async _onTileData(e,t,s,i){r(i);const{type:a,addOrUpdate:o,remove:n,clear:l,end:c}=t,d=!!this._schema.mesh.sortKey;if(!o){const t={type:a,addOrUpdate:null,remove:n,clear:l,end:c,sort:d};return this.remoteClient.invoke("tileRenderer.onTileData",{tileKey:e.id,data:t},i)}const h=this._processFeatures(e,o,s,i,t.status?.version);try{const s=await h;if(null==s){const t={type:a,addOrUpdate:null,remove:n,clear:l,end:c,sort:d};return this.remoteClient.invoke("tileRenderer.onTileData",{tileKey:e.id,data:t},i)}const r=[];for(const t of s){let s=!1;const i=t.message.bufferIds,a=e.key.id,o=t.message.tileKey;if(a!==o&&null!=i){if(!this.tileStore.get(o)){this._addBufferData(a,t),r.push(t);continue}let e=this._bufferIds.get(o);e||(e=new Set,this._bufferIds.set(o,e));const n=Array.from(i);for(const t of n){if(e.has(t)){s=!0;break}e.add(t)}}s||(this._addBufferData(a,t),r.push(t))}await Promise.all(r.map((s=>{const r=e.key.id===s.message.tileKey,o=r?t.remove:[],n=r&&t.end;return this._updateTileMesh(a,e,s,o,n,!!t.clear,i.signal)})))}catch(f){this._handleError(e,f,i)}}async _updateTileMesh(e,t,s,i,a,o,n){const l=e,c=s.message.tileKey,d=!!this._schema.mesh.sortKey;c!==t.key.id&&(a=!1);const h=s?.message,f={type:l,addOrUpdate:h,remove:i,clear:o,end:a,sort:d},u={transferList:s?.transferList??[],signal:n};return r(u),this.remoteClient.invoke("tileRenderer.onTileData",{tileKey:c,data:f},u)}async _processFeatures(e,t,s,i,a){if(null==t||!t.hasFeatures)return null;const o={transform:e.transform,hasZ:!1,hasM:!1},n=this._factory,l={viewingMode:"",scale:e.scale},c=await this._matchers.feature,d=await this._matchers.aggregate;r(i);const h=this._getLabelInfos(e,t);return await n.analyze(t.getCursor(),this._resourceManagerProxy,c,d,o,l),r(i),this._writeFeatureSet(e,t,o,h,n,s,a)}_writeFeatureSet(e,t,s,r,i,a,o){const n=t.getSize(),l=this._schema.mesh.matcher.symbologyType,c=new h(e.key.id,{features:n,records:n,metrics:0},l,a,l!==d.HEATMAP,o),f={viewingMode:"",scale:e.scale},u=t.getCursor();for(;u.next();)try{const t=u.getDisplayId(),a=null!=r?r.get(t):null;i.writeCursor(c,u,s,f,e.level,a,this._resourceManagerProxy)}catch(g){}const m=e.tileInfoView.tileInfo.isWrappable;return c.serialize(m)}_handleError(e,t,s){if(!i(t)){const r={tileKey:e.id,error:t.message};return this.remoteClient.invoke("tileRenderer.onTileError",r,{signal:s.signal})}return Promise.resolve()}_getLabelingSchemaForScale(e){const t=this._schema.mesh.labels;if(null==t)return null;if("subtype"===t.type){const s={type:"subtype",classes:{}};let r=!1;for(const i in t.classes){const a=t.classes[i].filter((t=>_(t,e.scale)));r=r||!!a.length,s.classes[i]=a}return r?s:null}const s=t.classes.filter((t=>_(t,e.scale)));return s.length?{type:"simple",classes:s}:null}_getLabels(e,t){if("subtype"===t.type){const r=this.service.subtypeField;s(r,"Expected to find subtype Field");const i=e.readAttribute(r);return null==i?[]:t.classes[i]??[]}return t.classes}_getLabelInfos(e,s){const r=this._getLabelingSchemaForScale(e);if(null==r)return null;const i=new Map,a=s.getCursor();for(;a.next();){const e=a.getDisplayId(),s=[],o=c(e),n=o&&1!==a.readAttribute("cluster_count")?"aggregate":"feature",l=this._getLabels(a,r);for(const r of l){if(r.target!==n)continue;const i=a.getStorage(),l=o&&"feature"===n?i.getComputedStringAtIndex(a.readAttribute("referenceId"),r.fieldIndex):i.getComputedStringAtIndex(e,r.fieldIndex);if(!l)continue;const c=t(l.toString()),d=c[0],h=c[1];this._store.getMosaicItem(r.symbol,g(d)).then((e=>{s[r.index]={glyphs:e.glyphMosaicItems??[],rtl:h,index:r.index}}))}i.set(e,s)}return i}};S=e([a("esri.views.2d.layers.features.processors.SymbolProcessor")],S);const w=S;export{w as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import"../../core/has.js";import t from"../../core/Logger.js";import{disposeMaybe as e}from"../../core/maybe.js";import{BufferObject as i}from"./BufferObject.js";import{webglDebugEnabled as r}from"./checkWebGLError.js";import{ContextType as s}from"./contextUtils.js";import{ResourceType as h,ColorAttachment as n,PixelFormat as o,PixelType as c,DepthStencilAttachment as a,FramebufferTarget as u,TextureType as _,Usage as l,BufferType as f,RenderbufferFormat as T}from"./enums.js";import{GLObjectType as d}from"./GLObjectType.js";import{Renderbuffer as m}from"./Renderbuffer.js";import{Texture as p}from"./Texture.js";const x=t.getLogger("esri.views.webgl.FramebufferObject");class E{constructor(t,e,i=null){this._context=t,this._glName=null,this._colorAttachments=new Map,this._depthStencilBuffer=null,this._depthStencilTexture=null,this._initialized=!1,t.instanceCounter.increment(h.FramebufferObject,this);const r=g(e)?e:new p(this._context,e);if(this._colorAttachments.set(n.COLOR_ATTACHMENT0,r),this._validateTextureDescriptor(r.descriptor),this._validateColorAttachmentPoint(n.COLOR_ATTACHMENT0),null!=i)if(b(i))this._context.capabilities.depthTexture||console.error("Setting the depth/stencil texture as an attachment requires WEBGL_depth_texture or WebGL2"),this._depthStencilTexture=g(i)?i:new p(this._context,i),this._validateTextureDescriptor(this._depthStencilTexture.descriptor);else{const t=A(i)?i:new m(this._context,i);this._depthStencilBuffer=t,this._validateRenderBufferDescriptor(t.descriptor)}}dispose(){if(0===this._colorAttachments.size&&!this._glName)return;const t=this._context.getBoundFramebufferObject();if(this._colorAttachments.forEach(((t,e)=>this.detachColorTexture(e)?.dispose())),this.detachDepthStencilBuffer()?.dispose(),this.detachDepthStencilTexture()?.dispose(),this._glName){this._context.gl.deleteFramebuffer(this._glName),this._glName=null}this._context.bindFramebuffer(t),this._context.instanceCounter.decrement(h.FramebufferObject,this)}get glName(){return this._glName}get colorTexture(){return this._colorAttachments.get(n.COLOR_ATTACHMENT0)}get depthStencil(){return this._depthStencilTexture||this._depthStencilBuffer}get depthStencilTexture(){return this._depthStencilTexture}get width(){const t=this._colorAttachments.get(n.COLOR_ATTACHMENT0);return t?.descriptor?.width??0}get height(){const t=this._colorAttachments.get(n.COLOR_ATTACHMENT0);return t?.descriptor?.height??0}get gpuMemoryUsage(){return[...this._colorAttachments].reduce(((t,[e,i])=>t+i.gpuMemoryUsage),this.depthStencil?.gpuMemoryUsage??0)}getColorTexture(t){const e=this._colorAttachments.get(t);return e&&g(e)?e:null}get colorAttachments(){return[...this._colorAttachments.keys()]}attachColorTexture(t,e=n.COLOR_ATTACHMENT0){if(!t)return;this._validateColorAttachmentPoint(e);const i=t.descriptor;this._validateTextureDescriptor(i),this.detachColorTexture(e)?.dispose(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,e)),this._colorAttachments.set(e,t)}detachColorTexture(t=n.COLOR_ATTACHMENT0){const e=this._colorAttachments.get(t);if(e)return this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t)),this._colorAttachments.delete(t),e}setColorTextureTarget(t,e=n.COLOR_ATTACHMENT0){const i=this._colorAttachments.get(e);i&&this._framebufferTexture2D(i.glName,e,t)}attachDepthStencil(t){if(t)switch(t.type){case d.Texture:return this._attachDepthStencilTexture(t);case d.RenderBuffer:return this._attachDepthStencilBuffer(t)}}_attachDepthStencilTexture(t){if(null==t)return;const e=t.descriptor;e.pixelFormat!==o.DEPTH_STENCIL&&e.pixelFormat!==o.DEPTH24_STENCIL8&&console.error("Depth/Stencil texture must have a pixel type of DEPTH_STENCIL!"),e.dataType!==c.UNSIGNED_INT_24_8&&console.error("Depth/Stencil texture must have data type of UNSIGNED_INT_24_8!"),this._context.capabilities.depthTexture||console.error("Extension WEBGL_depth_texture isn't supported therefore it is no possible to set the depth/stencil texture!"),this._validateTextureDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,a)),this._depthStencilTexture?.dispose(),this._depthStencilTexture=t}detachDepthStencilTexture(){const t=this._depthStencilTexture;return t&&this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,a)),this._depthStencilTexture=null,t}_attachDepthStencilBuffer(t){if(null==t)return;const e=t.descriptor;if(this._validateRenderBufferDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized){this._context.bindFramebuffer(this);const i=this._context.gl,r=this._getGLAttachmentPoint(e);i.framebufferRenderbuffer(u.FRAMEBUFFER,r,i.RENDERBUFFER,t.glName)}this._depthStencilBuffer=t}detachDepthStencilBuffer(){const t=this._depthStencilBuffer;if(t&&this._initialized){this._context.bindFramebuffer(this);const e=this._context.gl,i=this._getGLAttachmentPoint(t.descriptor);e.framebufferRenderbuffer(u.FRAMEBUFFER,i,e.RENDERBUFFER,null)}return this._depthStencilBuffer=null,t}copyToTexture(t,e,i,r,s,h,n){(t<0||e<0||s<0||h<0)&&console.error("Offsets cannot be negative!"),(i<=0||r<=0)&&console.error("Copy width and height must be greater than zero!");const o=n.descriptor;n.descriptor.target!==_.TEXTURE_2D&&console.error("Texture target must be TEXTURE_2D!"),(null==o?.width||null==o?.height||t+i>this.width||e+r>this.height||s+i>o.width||h+r>o.height)&&console.error("Bad dimensions, the current input values will attempt to read or copy out of bounds!");const c=this._context,a=c.bindTexture(n,p.TEXTURE_UNIT_FOR_UPDATES);c.setActiveTexture(p.TEXTURE_UNIT_FOR_UPDATES),c.bindFramebuffer(this),c.gl.copyTexSubImage2D(_.TEXTURE_2D,0,s,h,t,e,i,r),c.bindTexture(a,p.TEXTURE_UNIT_FOR_UPDATES)}readPixels(t,e,i,r,s,h,n){(i<=0||r<=0)&&console.error("Copy width and height must be greater than zero!"),n||console.error("Target memory is not initialized!"),this._context.bindFramebuffer(this),this._context.gl.readPixels(t,e,i,r,s,h,n)}async readPixelsAsync(t,e,h,n,o,c,a){if(this._context.type!==s.WEBGL2)return r()&&console.warn("Attempting to read pixels using pixel buffer object without WebGL2"),void this.readPixels(t,e,h,n,o,c,a);const u=this._context.gl,_=i.createPixelPack(this._context,l.STREAM_READ,a.byteLength);this._context.bindBuffer(_),this._context.bindFramebuffer(this),u.readPixels(t,e,h,n,o,c,0),this._context.unbindBuffer(f.PIXEL_PACK_BUFFER),await _.getSubDataAsync(a),_.dispose()}resize(t,e){if(this.width===t&&this.height===e)return;const i={width:t,height:e};S(i,this._context.parameters.maxTextureSize),this._colorAttachments.forEach((t=>t.resize(i.width,i.height))),this._depthStencilTexture?.resize(i.width,i.height),this._initialized&&(S(i,this._context.parameters.maxRenderbufferSize),this._depthStencilBuffer?.resize(i.width,i.height),this._context.getBoundFramebufferObject()===this&&this._context.bindFramebuffer(null),this._initialized=!1)}initializeAndBind(t=u.FRAMEBUFFER){const e=this._context.gl;if(this._initialized)return void e.bindFramebuffer(t,this.glName);this._glName&&e.deleteFramebuffer(this._glName);const i=e.createFramebuffer();if(e.bindFramebuffer(t,i),this._colorAttachments.forEach(((e,i)=>this._framebufferTexture2D(e.glName,i,R(e),t))),this._depthStencilBuffer){const i=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);e.framebufferRenderbuffer(t,i,e.RENDERBUFFER,this._depthStencilBuffer.glName)}else this._depthStencilTexture&&this._framebufferTexture2D(this._depthStencilTexture.glName,e.DEPTH_STENCIL_ATTACHMENT,R(this._depthStencilTexture),t);if(r()){e.checkFramebufferStatus(t)!==e.FRAMEBUFFER_COMPLETE&&console.error("Framebuffer is incomplete!")}this._glName=i,this._initialized=!0}_framebufferTexture2D(t,e=n.COLOR_ATTACHMENT0,i=_.TEXTURE_2D,r=u.FRAMEBUFFER,s=0){this._context.gl.framebufferTexture2D(r,e,i,t,s)}_disposeDepthStencilAttachments(){const t=this._context.gl;if(this._depthStencilBuffer){if(this._initialized){this._context.bindFramebuffer(this);const e=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);t.framebufferRenderbuffer(u.FRAMEBUFFER,e,t.RENDERBUFFER,null)}this._depthStencilBuffer=e(this._depthStencilBuffer)}this._depthStencilTexture&&(this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t.DEPTH_STENCIL_ATTACHMENT)),this._depthStencilTexture=e(this._depthStencilTexture))}_validateTextureDescriptor(t){t.target!==_.TEXTURE_2D&&t.target!==_.TEXTURE_CUBE_MAP&&console.error("Texture type must be TEXTURE_2D or TEXTURE_CUBE_MAP!"),S(t,this._context.parameters.maxTextureSize),this._validateBufferDimensions(t)}_validateRenderBufferDescriptor(t){S(t,this._context.parameters.maxRenderbufferSize),this._validateBufferDimensions(t)}_validateBufferDimensions(t){t.width<=0&&(t.width=this.width),t.height<=0&&(t.height=this.height),this.width>0&&this.height>0&&(this.width===t.width&&this.height===t.height||console.error("Attachment size must match framebuffer size!"))}_getGLAttachmentPoint(t){switch(t.internalFormat){case T.DEPTH_COMPONENT16:case T.DEPTH_COMPONENT24:case T.DEPTH_COMPONENT32F:return this._context.gl.DEPTH_ATTACHMENT;case T.DEPTH24_STENCIL8:case T.DEPTH32F_STENCIL8:case T.DEPTH_STENCIL:return this._context.gl.DEPTH_STENCIL_ATTACHMENT;case T.STENCIL_INDEX8:return this._context.gl.STENCIL_ATTACHMENT}}_validateColorAttachmentPoint(e){if(-1===E._MAX_COLOR_ATTACHMENTS){const t=this._context.capabilities.drawBuffers;if(t){const e=this._context.gl;E._MAX_COLOR_ATTACHMENTS=e.getParameter(t.MAX_COLOR_ATTACHMENTS)}else E._MAX_COLOR_ATTACHMENTS=1}const i=e-n.COLOR_ATTACHMENT0;i+1>E._MAX_COLOR_ATTACHMENTS&&t.getLogger("esri.views.webgl.FrameBufferObject").error("esri.FrameBufferObject",`illegal attachment point for color attachment: ${i+1}. Implementation supports up to ${E._MAX_COLOR_ATTACHMENTS} color attachments`)}}function g(t){return null!=t&&"type"in t&&t.type===d.Texture}function A(t){return null!=t&&"type"in t&&t.type===d.RenderBuffer}function b(t){return g(t)||null!=t&&"pixelFormat"in t}function S(t,e){const i=Math.max(t.width,t.height);if(i>e){x.warn(`Resizing FBO attachment size ${t.width}x${t.height} to device limit ${e}`);const r=e/i;return t.width=Math.round(t.width*r),t.height=Math.round(t.height*r),!1}return!0}function R(t){return t.descriptor.target===_.TEXTURE_CUBE_MAP?_.TEXTURE_CUBE_MAP_POSITIVE_X:_.TEXTURE_2D}E._MAX_COLOR_ATTACHMENTS=-1;export{E as FramebufferObject,S as ensureAttachmentMaxSize};
5
+ import"../../core/has.js";import t from"../../core/Logger.js";import{disposeMaybe as e}from"../../core/maybe.js";import{BufferObject as i}from"./BufferObject.js";import{webglDebugEnabled as r}from"./checkWebGLError.js";import{ContextType as s}from"./contextUtils.js";import{ResourceType as h,ColorAttachment as n,PixelFormat as o,PixelType as c,DepthStencilAttachment as a,FramebufferTarget as u,TextureType as _,Usage as l,BufferType as f,RenderbufferFormat as T}from"./enums.js";import{GLObjectType as d}from"./GLObjectType.js";import{Renderbuffer as m}from"./Renderbuffer.js";import{Texture as p}from"./Texture.js";const x=t.getLogger("esri.views.webgl.FramebufferObject");class E{constructor(t,e,i=null){this._context=t,this._glName=null,this._colorAttachments=new Map,this._depthStencilBuffer=null,this._depthStencilTexture=null,this._initialized=!1,t.instanceCounter.increment(h.FramebufferObject,this);const r=g(e)?e:new p(this._context,e);if(this._colorAttachments.set(n.COLOR_ATTACHMENT0,r),this._validateTextureDescriptor(r.descriptor),this._validateColorAttachmentPoint(n.COLOR_ATTACHMENT0),null!=i)if(b(i))this._context.capabilities.depthTexture||console.error("Setting the depth/stencil texture as an attachment requires WEBGL_depth_texture or WebGL2"),this._depthStencilTexture=g(i)?i:new p(this._context,i),this._validateTextureDescriptor(this._depthStencilTexture.descriptor);else{const t=A(i)?i:new m(this._context,i);this._depthStencilBuffer=t,this._validateRenderBufferDescriptor(t.descriptor)}}dispose(){if(0===this._colorAttachments.size&&!this._glName)return;const t=this._context.getBoundFramebufferObject();if(this._colorAttachments.forEach(((t,e)=>this.detachColorTexture(e)?.dispose())),this.detachDepthStencilBuffer()?.dispose(),this.detachDepthStencilTexture()?.dispose(),this._glName){this._context.gl.deleteFramebuffer(this._glName),this._glName=null}this._context.bindFramebuffer(t),this._context.instanceCounter.decrement(h.FramebufferObject,this)}get glName(){return this._glName}get colorTexture(){return this._colorAttachments.get(n.COLOR_ATTACHMENT0)}get depthStencil(){return this._depthStencilTexture||this._depthStencilBuffer}get depthStencilTexture(){return this._depthStencilTexture}get width(){const t=this._colorAttachments.get(n.COLOR_ATTACHMENT0);return t?.descriptor?.width??0}get height(){const t=this._colorAttachments.get(n.COLOR_ATTACHMENT0);return t?.descriptor?.height??0}get gpuMemoryUsage(){return[...this._colorAttachments].reduce(((t,[e,i])=>t+i.gpuMemoryUsage),this.depthStencil?.gpuMemoryUsage??0)}getColorTexture(t){const e=this._colorAttachments.get(t);return e&&g(e)?e:null}get colorAttachments(){return[...this._colorAttachments.keys()]}attachColorTexture(t,e=n.COLOR_ATTACHMENT0){if(!t)return;this._validateColorAttachmentPoint(e);const i=t.descriptor;this._validateTextureDescriptor(i),this.detachColorTexture(e)?.dispose(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,e)),this._colorAttachments.set(e,t)}detachColorTexture(t=n.COLOR_ATTACHMENT0){const e=this._colorAttachments.get(t);if(e){if(this._initialized){const e=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t),this._context.bindFramebuffer(e)}return this._colorAttachments.delete(t),e}}setColorTextureTarget(t,e=n.COLOR_ATTACHMENT0){const i=this._colorAttachments.get(e);i&&this._framebufferTexture2D(i.glName,e,t)}attachDepthStencil(t){if(t)switch(t.type){case d.Texture:return this._attachDepthStencilTexture(t);case d.RenderBuffer:return this._attachDepthStencilBuffer(t)}}_attachDepthStencilTexture(t){if(null==t)return;const e=t.descriptor;e.pixelFormat!==o.DEPTH_STENCIL&&e.pixelFormat!==o.DEPTH24_STENCIL8&&console.error("Depth/Stencil texture must have a pixel type of DEPTH_STENCIL!"),e.dataType!==c.UNSIGNED_INT_24_8&&console.error("Depth/Stencil texture must have data type of UNSIGNED_INT_24_8!"),this._context.capabilities.depthTexture||console.error("Extension WEBGL_depth_texture isn't supported therefore it is no possible to set the depth/stencil texture!"),this._validateTextureDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,a)),this._depthStencilTexture?.dispose(),this._depthStencilTexture=t}detachDepthStencilTexture(){const t=this._depthStencilTexture;return t&&this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,a)),this._depthStencilTexture=null,t}_attachDepthStencilBuffer(t){if(null==t)return;const e=t.descriptor;if(this._validateRenderBufferDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized){this._context.bindFramebuffer(this);const i=this._context.gl,r=this._getGLAttachmentPoint(e);i.framebufferRenderbuffer(u.FRAMEBUFFER,r,i.RENDERBUFFER,t.glName)}this._depthStencilBuffer=t}detachDepthStencilBuffer(){const t=this._depthStencilBuffer;if(t&&this._initialized){this._context.bindFramebuffer(this);const e=this._context.gl,i=this._getGLAttachmentPoint(t.descriptor);e.framebufferRenderbuffer(u.FRAMEBUFFER,i,e.RENDERBUFFER,null)}return this._depthStencilBuffer=null,t}copyToTexture(t,e,i,r,s,h,n){(t<0||e<0||s<0||h<0)&&console.error("Offsets cannot be negative!"),(i<=0||r<=0)&&console.error("Copy width and height must be greater than zero!");const o=n.descriptor;n.descriptor.target!==_.TEXTURE_2D&&console.error("Texture target must be TEXTURE_2D!"),(null==o?.width||null==o?.height||t+i>this.width||e+r>this.height||s+i>o.width||h+r>o.height)&&console.error("Bad dimensions, the current input values will attempt to read or copy out of bounds!");const c=this._context,a=c.bindTexture(n,p.TEXTURE_UNIT_FOR_UPDATES);c.setActiveTexture(p.TEXTURE_UNIT_FOR_UPDATES),c.bindFramebuffer(this),c.gl.copyTexSubImage2D(_.TEXTURE_2D,0,s,h,t,e,i,r),c.bindTexture(a,p.TEXTURE_UNIT_FOR_UPDATES)}readPixels(t,e,i,r,s,h,n){(i<=0||r<=0)&&console.error("Copy width and height must be greater than zero!"),n||console.error("Target memory is not initialized!"),this._context.bindFramebuffer(this),this._context.gl.readPixels(t,e,i,r,s,h,n)}async readPixelsAsync(t,e,h,n,o,c,a){if(this._context.type!==s.WEBGL2)return r()&&console.warn("Attempting to read pixels using pixel buffer object without WebGL2"),void this.readPixels(t,e,h,n,o,c,a);const u=this._context.gl,_=i.createPixelPack(this._context,l.STREAM_READ,a.byteLength);this._context.bindBuffer(_),this._context.bindFramebuffer(this),u.readPixels(t,e,h,n,o,c,0),this._context.unbindBuffer(f.PIXEL_PACK_BUFFER),await _.getSubDataAsync(a),_.dispose()}resize(t,e){if(this.width===t&&this.height===e)return;const i={width:t,height:e};S(i,this._context.parameters.maxTextureSize),this._colorAttachments.forEach((t=>t.resize(i.width,i.height))),this._depthStencilTexture?.resize(i.width,i.height),this._initialized&&(S(i,this._context.parameters.maxRenderbufferSize),this._depthStencilBuffer?.resize(i.width,i.height),this._context.getBoundFramebufferObject()===this&&this._context.bindFramebuffer(null),this._initialized=!1)}initializeAndBind(t=u.FRAMEBUFFER){const e=this._context.gl;if(this._initialized)return void e.bindFramebuffer(t,this.glName);this._glName&&e.deleteFramebuffer(this._glName);const i=e.createFramebuffer();if(e.bindFramebuffer(t,i),this._colorAttachments.forEach(((e,i)=>this._framebufferTexture2D(e.glName,i,R(e),t))),this._depthStencilBuffer){const i=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);e.framebufferRenderbuffer(t,i,e.RENDERBUFFER,this._depthStencilBuffer.glName)}else this._depthStencilTexture&&this._framebufferTexture2D(this._depthStencilTexture.glName,e.DEPTH_STENCIL_ATTACHMENT,R(this._depthStencilTexture),t);if(r()){e.checkFramebufferStatus(t)!==e.FRAMEBUFFER_COMPLETE&&console.error("Framebuffer is incomplete!")}this._glName=i,this._initialized=!0}_framebufferTexture2D(t,e=n.COLOR_ATTACHMENT0,i=_.TEXTURE_2D,r=u.FRAMEBUFFER,s=0){this._context.gl.framebufferTexture2D(r,e,i,t,s)}_disposeDepthStencilAttachments(){const t=this._context.gl;if(this._depthStencilBuffer){if(this._initialized){this._context.bindFramebuffer(this);const e=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);t.framebufferRenderbuffer(u.FRAMEBUFFER,e,t.RENDERBUFFER,null)}this._depthStencilBuffer=e(this._depthStencilBuffer)}this._depthStencilTexture&&(this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t.DEPTH_STENCIL_ATTACHMENT)),this._depthStencilTexture=e(this._depthStencilTexture))}_validateTextureDescriptor(t){t.target!==_.TEXTURE_2D&&t.target!==_.TEXTURE_CUBE_MAP&&console.error("Texture type must be TEXTURE_2D or TEXTURE_CUBE_MAP!"),S(t,this._context.parameters.maxTextureSize),this._validateBufferDimensions(t)}_validateRenderBufferDescriptor(t){S(t,this._context.parameters.maxRenderbufferSize),this._validateBufferDimensions(t)}_validateBufferDimensions(t){t.width<=0&&(t.width=this.width),t.height<=0&&(t.height=this.height),this.width>0&&this.height>0&&(this.width===t.width&&this.height===t.height||console.error("Attachment size must match framebuffer size!"))}_getGLAttachmentPoint(t){switch(t.internalFormat){case T.DEPTH_COMPONENT16:case T.DEPTH_COMPONENT24:case T.DEPTH_COMPONENT32F:return this._context.gl.DEPTH_ATTACHMENT;case T.DEPTH24_STENCIL8:case T.DEPTH32F_STENCIL8:case T.DEPTH_STENCIL:return this._context.gl.DEPTH_STENCIL_ATTACHMENT;case T.STENCIL_INDEX8:return this._context.gl.STENCIL_ATTACHMENT}}_validateColorAttachmentPoint(e){if(-1===E._MAX_COLOR_ATTACHMENTS){const t=this._context.capabilities.drawBuffers;if(t){const e=this._context.gl;E._MAX_COLOR_ATTACHMENTS=e.getParameter(t.MAX_COLOR_ATTACHMENTS)}else E._MAX_COLOR_ATTACHMENTS=1}const i=e-n.COLOR_ATTACHMENT0;i+1>E._MAX_COLOR_ATTACHMENTS&&t.getLogger("esri.views.webgl.FrameBufferObject").error("esri.FrameBufferObject",`illegal attachment point for color attachment: ${i+1}. Implementation supports up to ${E._MAX_COLOR_ATTACHMENTS} color attachments`)}}function g(t){return null!=t&&"type"in t&&t.type===d.Texture}function A(t){return null!=t&&"type"in t&&t.type===d.RenderBuffer}function b(t){return g(t)||null!=t&&"pixelFormat"in t}function S(t,e){const i=Math.max(t.width,t.height);if(i>e){x.warn(`Resizing FBO attachment size ${t.width}x${t.height} to device limit ${e}`);const r=e/i;return t.width=Math.round(t.width*r),t.height=Math.round(t.height*r),!1}return!0}function R(t){return t.descriptor.target===_.TEXTURE_CUBE_MAP?_.TEXTURE_CUBE_MAP_POSITIVE_X:_.TEXTURE_2D}E._MAX_COLOR_ATTACHMENTS=-1;export{E as FramebufferObject,S as ensureAttachmentMaxSize};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{highlightsSupported as r}from"../../views/support/layerViewUtils.js";import a from"./UpdateFeatureWorkflowData.js";import{handleKeys as l,UpdateRecordWorkflow as c}from"./UpdateRecordWorkflow.js";import{canCreateInteractiveEditSession as d,getVisualVariableAttributes as n,setUpGeometryUpdate as h,isTerminalUpdateEventType as u,swapForEditingSession as p,cloneGraphicExceptMesh as w}from"./workflowUtils.js";var m;const y={...l,highlights:Symbol(),sketch:Symbol()};let f=m=class extends c{constructor(e){super(e),this.type="update-feature",this._layerViewEditSession=null,this._sketchGraphicClone=null,this._webStyleCache=new Map}initialize(){const{edits:{feature:e},layerView:t}=this.data;d(t)&&(this._layerViewEditSession=t.createInteractiveEditSession(e))}destroy(){this._layerViewEditSession?.rollback()}async commit(){this.removeHandles(y.sketch);try{const e=this.data.edits.stagedForDelete;await super.commit();const t=this._layerViewEditSession;e?t?.rollback():t?.commit()}catch(e){throw await this._configureSketchViewModel(),new t("editor-workflow:failed-to-commit","An error occurred when sending the updates to the service",{error:e})}}async start(){return await super.start(),this._initializeSketchViewModel()}_configureFeatureFormViewModel(){super._configureFeatureFormViewModel();const{_layerViewEditSession:e}=this,{viewModel:t}=this.data;this.addHandles(t.featureFormViewModel.on("value-change",(t=>{e?.setAttribute(t.fieldName,t.value)})),y.exit)}_configureHighlight(){const{edits:e,layerView:t}=this.data;r(t)&&this.addHandles(t.highlight(e.feature),y.highlights)}async _configureSketchViewModel(){const{data:e,_sketchGraphicClone:t}=this,{edits:i,viewModel:s}=e,o=i.feature,{featureFormViewModel:r,sketchViewModel:a,view:l}=s;a.allowDeleteKey=!1;const c=n(o),d=await h({feature:o,featureClone:t,visualVariableAttributes:c,sketchViewModel:a,view:l,onUpdate:({geometry:e,attributes:t},s)=>{if(i.updateAttributes(t),i.updateGeometry(e),r.feature.geometry=e,null!=c.rotation){const{field:e}=c.rotation;r.setValue(e,t[e])}if(null!=c.size){const{field:e}=c.size;r.setValue(e,t[e])}("undo"===s.type||"redo"===s.type||"update"===s.type&&null!=s.toolEventInfo&&u(s.toolEventInfo.type))&&r.notifyFeatureGeometryChanged()},webStyleCache:this._webStyleCache});this.addHandles(d,y.sketch)}_initializeSketchViewModel(){const{data:e,_sketchGraphicClone:t}=this,s=e.edits.feature,{sketchViewModel:o}=e.viewModel,{geometryUpdatesEnabled:r}=e.editableItem,a=o.updateOnGraphicClick;o.updateOnGraphicClick=!1,this.addHandles([i((()=>{o.updateOnGraphicClick=a}))]),r&&this.addHandles([p(o,s,t)]);const{highlights:l,sketch:c}=y;return{enter:async()=>{!this.hasHandles(c)&&r?await this._configureSketchViewModel():this.hasHandles(l)||this._configureHighlight()},exit:()=>this.removeHandles([c,l])}}_onFullFeatureLoaded(e){super._onFullFeatureLoaded(e),this._sketchGraphicClone=w(e);const{edits:t}=this.data;t.updateGeometry(e.geometry),t.trackChanges()}static async create(e){const t=new m({data:await a.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}};e([s()],f.prototype,"_layerViewEditSession",void 0),e([s()],f.prototype,"_sketchGraphicClone",void 0),f=m=e([o("esri.widgets.Editor.UpdateFeatureWorkflow")],f);export{f as UpdateFeatureWorkflow,y as handleKeys};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{highlightsSupported as r}from"../../views/support/layerViewUtils.js";import a from"./UpdateFeatureWorkflowData.js";import{handleKeys as l,UpdateRecordWorkflow as c}from"./UpdateRecordWorkflow.js";import{canCreateInteractiveEditSession as d,getVisualVariableAttributes as n,setUpGeometryUpdate as h,isTerminalUpdateEventType as u,swapForEditingSession as p,cloneGraphicExceptMesh as w}from"./workflowUtils.js";var m;const y={...l,highlights:Symbol(),sketch:Symbol()};let f=m=class extends c{constructor(e){super(e),this.type="update-feature",this._layerViewEditSession=null,this._sketchGraphicClone=null,this._webStyleCache=new Map}initialize(){const{edits:{feature:e},layerView:t}=this.data;d(t)&&(this._layerViewEditSession=t.createInteractiveEditSession(e))}destroy(){this._layerViewEditSession?.rollback()}async commit(){this.removeHandles(y.sketch);try{const e=this.data.edits.stagedForDelete;await super.commit();const t=this._layerViewEditSession;e?t?.rollback():t?.commit()}catch(e){throw await this._configureSketchViewModel(),new t("editor-workflow:failed-to-commit","An error occurred when sending the updates to the service",{error:e})}}async start(){return await super.start(),this._initializeSketchViewModel()}_configureFeatureFormViewModel(){super._configureFeatureFormViewModel();const{_layerViewEditSession:e}=this,{viewModel:t}=this.data;this.addHandles(t.featureFormViewModel.on("value-change",(t=>{e?.setAttribute(t.fieldName,t.value)})),y.exit)}_configureHighlight(){const{edits:e,layerView:t}=this.data;r(t)&&this.addHandles(t.highlight(e.feature),y.highlights)}async _configureSketchViewModel(){const{data:e,_sketchGraphicClone:t}=this,{edits:i,viewModel:s}=e,o=i.feature,{featureFormViewModel:r,sketchViewModel:a,view:l}=s;a.allowDeleteKey=!1;const c=n(o),d=await h({feature:o,featureClone:t,visualVariableAttributes:c,sketchViewModel:a,view:l,onUpdate:({geometry:e,attributes:t},s)=>{if(i.updateAttributes(t),i.updateGeometry(e),r.feature.geometry=e,null!=c.rotation){const{field:e}=c.rotation;r.setValue(e,t[e])}if(null!=c.size){const{field:e}=c.size;r.setValue(e,t[e])}("undo"===s.type||"redo"===s.type||"update"===s.type&&null!=s.toolEventInfo&&u(s.toolEventInfo.type))&&r.notifyFeatureGeometryChanged()},webStyleCache:this._webStyleCache});this.addHandles(d,y.sketch)}async _initializeSketchViewModel(){const{data:e,_sketchGraphicClone:t}=this,s=e.edits.feature,{sketchViewModel:o}=e.viewModel,{geometryUpdatesEnabled:r}=e.editableItem,a=o.updateOnGraphicClick;o.updateOnGraphicClick=!1,this.addHandles([i((()=>{o.updateOnGraphicClick=a}))]),r&&this.addHandles([await p(o,s,t)]);const{highlights:l,sketch:c}=y;return{enter:async()=>{!this.hasHandles(c)&&r?await this._configureSketchViewModel():this.hasHandles(l)||this._configureHighlight()},exit:()=>this.removeHandles([c,l])}}_onFullFeatureLoaded(e){super._onFullFeatureLoaded(e),this._sketchGraphicClone=w(e);const{edits:t}=this.data;t.updateGeometry(e.geometry),t.trackChanges()}static async create(e){const t=new m({data:await a.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}};e([s()],f.prototype,"_layerViewEditSession",void 0),e([s()],f.prototype,"_sketchGraphicClone",void 0),f=m=e([o("esri.widgets.Editor.UpdateFeatureWorkflow")],f);export{f as UpdateFeatureWorkflow,y as handleKeys};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../Graphic.js";import{addMany as t}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import"../../core/has.js";import{handlesGroup as a,makeHandle as i}from"../../core/handleUtils.js";import{clone as n}from"../../core/lang.js";import{whenOrAbort as s,throwIfAborted as l,debounce as o}from"../../core/promiseUtils.js";import{watch as c,whenOnce as u}from"../../core/reactiveUtils.js";import{px2pt as p}from"../../core/screenUtils.js";import{diff as y}from"../../core/accessorSupport/diffUtils.js";import{featureHasFields as d,fixFields as f,getDisplayFieldName as m}from"../../layers/support/fieldUtils.js";import{calculateTolerance as h}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as b}from"../../renderers/support/lengthUtils.js";import{getTransformationType as g,TransformationType as w}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getRotationAngle as v,getSize as S}from"../../renderers/visualVariables/support/visualVariableUtils.js";import{sceneLayerEditingEnabled as j,i3sPatchingEnabled as U}from"../../support/featureFlags.js";import{to3D as V}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as I}from"../../symbols/support/symbolUtils.js";import{GraphicState as z}from"../../views/3d/layers/graphics/GraphicState.js";import{createQueryGeometry as F}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as L,filterGraphicHits as T}from"../../views/support/hitTestSelectUtils.js";import{getAllTemplatesForLayer as x}from"../support/templateUtils.js";function k(e){const t=e.sourceLayer;if(!t||"feature"!==t.type||!P(t.renderer))return{rotation:null,size:null};let r=null,a=null;const i=t.renderer.getVisualVariablesForType("rotation").filter((t=>(!t.axis||"heading"===t.axis)&&t.field&&!t.valueExpression&&null!=v(t,e)));1===i.length&&(r=E(i[0],t));const n=t.renderer.getVisualVariablesForType("size").filter((t=>t.field&&!t.useSymbolValue&&!t.valueExpression&&g(t)===w.RealWorldSize&&null!=S(t,e)));return 1===n.length&&(a=M(n[0],t)),{rotation:r,size:a}}function E(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,a=e.field,i=t.fields&&t.fields.filter((e=>e.name===a)),n=i&&1===i.length?i[0].type:"double",s={initial:0,current:0};return{field:a,fieldType:n,getDefault:()=>Promise.resolve(0),getValue:e=>(s.current=s.initial-r*e,C((s.current+360)%360,n)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function A(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function O(e,t,r){if(null==t)return 0;const{symbol:a}=V(t);if(null==a||"web-style"===a.type||"cim"===a.type)return 0;const i=a.symbolLayers.at(0);if(!i)return 0;switch(i.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return i.size||Math.min(ie.icon,(await e(i,ie.icon))[0])||ie.icon}case"text":return i.size||ie.text;case"line":return i.size||ie.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return A(await t(i,e.scale/ie.viewScaleSizeFactor),r)}case"path":return(null!=i.width?i.width:i.height)||e.scale/ie.viewScaleSizeFactor;case"extrude":return i.size||e.scale/ie.viewScaleSizeFactor;default:return 0}}function M(e,t){const r=e.field,a=e.axis,i=t.fields&&t.fields.filter((e=>e.name===r)),n=i&&1===i.length?i[0].type:"double",s={updating:!1,initial:0,current:0},l=b[e.valueUnit]??1;let o;return o="area"===e.valueRepresentation?e=>(e*l/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*l/2:e=>e*l,{field:r,fieldType:n,getDefault:async(e,t)=>C(o(await O(t,e,a)),n),getValue:(e,t)=>(s.initial||(s.initial=t.pixelSizeAt(t.center)),s.current=s.initial*e,C(s.current,n)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1,displayUnit:le(e.valueUnit),axis:e.axis}}function C(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function P(e){switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function R(e,t,r){const a=await I(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=y(e.symbol,a)&&(e.symbol=a)}function D(e){if(!e)throw new Error("no geometry type");return"multipatch"===e?"mesh":e}async function G(e,t,r,n){(await Z(e,t,n)).remove();const s=e.on("create",(async a=>{if("cancel"===a.state){(await Z(e,t,n)).remove()}if("complete"===a.state){const i=a.graphic;i.sourceLayer||(i.sourceLayer=t.layer),i.attributes||(i.attributes={...t.template?.prototype.attributes});const s="2d"===e.view?.type?e.view?.scale:null;await R(i,n,s),r(i)}}));return a([s,i((()=>e.cancel()))])}async function Z(e,t,r){const a=t.layer,n={...t.template?.prototype.attributes,...t.attributeOverrides};let s=null;const{view:l}=e,u="2d"===l?.type;if(await q(e,a,n,r,u?l.scale:null),u){const t=o((t=>q(e,a,n,r,t)));s=c((()=>l.scale),(e=>t(e)))}const{data:p,editing:y}=a.capabilities;return e.layer.elevationInfo=a.elevationInfo,await e.create(D(a.geometryType),{graphicProperties:{attributes:n,sourceLayer:a},hasZ:p.supportsZ,defaultZ:(u?y.zDefault:null)??e.defaultCreateOptions.defaultZ,geometryToPlace:t.geometryToPlace??void 0}),s??i()}async function q(t,r,a,i,n){const s=new e({sourceLayer:r,attributes:a}),{rotation:l,size:o}=k(s);let c=await I(s,{useSourceLayer:!0,webStyleCache:i,scale:n}),u=!1;for(const e of[o,l]){if(null==e)continue;null==a[e.field]&&(a[e.field]=await e.getDefault(c,t.view),u=!0)}switch(u&&(c=await I(s,{useSourceLayer:!0,webStyleCache:i,scale:n})),c?.type){case"simple-fill":case"polygon-3d":t.polygonSymbol=c;break;case"simple-line":case"line-3d":t.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":t.pointSymbol=c;break;case"mesh-3d":t.meshSymbol=c}Q(t.tooltipOptions,o,l)}function Q(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function B(e,t){return e?e.find((e=>e.layer===t)):void 0}async function W(e,t,r,a){switch(t.type){case"3d":return _(e,t,r,a);case"2d":return H(e,t,r,a)}}async function _(e,r,a,i){if(0===e.length)return[];const{updatable:n,graphicsByLayer:l}=await a.async((async()=>{const{results:t}=await s(L(r,a),i),n=new Map,l=e=>{const t=e.layer,r=n.get(t);if(!r){const e=new Array;return n.set(t,e),e}return r};T(t).forEach((({graphic:e})=>l(e).push(e)));const o=e.filter((({supports:e,layer:t})=>e.includes("update")&&n.has(t)));return 0!==o.length&&a.stopPropagation(),{updatable:o,graphicsByLayer:n}}));return s(Promise.allSettled(n.map((async({layer:e})=>{const r=l.get(e),a=J(e);if(r.every((e=>d(a,e))))return r;const n=[];for(const i of r){n.push(i.getObjectId());const e=Object.keys(i.attributes);t(a,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=n,s.outFields=f(e.fieldsIndex,a),e.queryFeatures(s,{signal:i}).then((({features:e})=>e))}))),i)}async function H(e,t,r,a){if(0===e.length)return[];let i=null;const n=await r.async((async()=>{const{results:n}=await s(t.hitTest(r),a);if(0===n.length)return[];const l=new Set;i=T(n),i.forEach((({graphic:e})=>e&&l.add(e.layer)));const o=e.items.filter((({layer:e,supports:t,attachmentsOnUpdateEnabled:r})=>l.has(e)&&(t.includes("update")||t.includes("delete")||r)));return o.length>0&&r.stopPropagation(),o}));return s(Promise.allSettled(n.map((async({layer:e})=>{const n=e.createQuery();n.returnGeometry=!1,n.outFields=J(e);const s="renderer"in e?h({renderer:e.renderer,event:r}):0;n.geometry=F(r.mapPoint,s,t),n.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(n,{signal:a});return i?.forEach((({graphic:t})=>{t.layer!==e||l.some((e=>e.getObjectId()===t.getObjectId()))||l.push(t)})),l}))),a)}function J(e){return f(e.fieldsIndex,[e.objectIdField,m({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function K(e,t,r){const{sourceLayer:a}=e,i=a.createQuery();i.objectIds=[e.getAttribute(a.objectIdField)],i.outFields=["*"],i.outSpatialReference=t,i.returnM=a.capabilities.data.supportsM,i.returnZ=a.capabilities.data.supportsZ,j()&&U()&&"scene"===a.type&&null!=a.infoFor3D&&(i.returnGeometry=!0,i.formatOf3DObjects="3D_glb");const n=await a.queryFeatures(i,{signal:r});l(r);return n.features[0]}async function N(e){const{graphic:t,sketchViewModel:r,sourceLayer:a,visualVariables:i,webStyleCache:n}=e;let s=!1;const{rotation:l,size:o}=i;if([l,o].forEach((async e=>{if(null==e)return;const a=t.getAttribute(e.field);if(null!=a)e.initValue(a);else{const a=await e.getDefault(t.symbol,r.view);e.initValue(a),t.setAttribute(e.field,a),s=!0}})),s){const e="2d"===r.view?.type?r.view.scale:null;await R(t,n,e)}const c={multipleSelectionEnabled:!1};return"point"===a.geometryType&&(c.enableRotation=null!=l,c.enableScaling=null!=o),Q(r.tooltipOptions,o,l),r.layer.elevationInfo=a.elevationInfo,r.update(t,c)}function X(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function Y(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function $(e,t,r,a,i){if(null==t.geometry||"point"!==t.geometry?.type)return;const n=a.rotation,s=X(r.toolEventInfo);if(null!=n&&null!=s)if("rotate-stop"===s.type)n.isUpdatingInteractively=!1,n.initValue();else{n.isUpdatingInteractively=!0;const{field:r,getValue:a}=n;t.setAttribute(r,a(s.angle,e))}const l=a.size,o=Y(r.toolEventInfo);if(null!=l&&null!=o)if("scale-stop"===o.type)l.isUpdatingInteractively=!1,l.initValue();else{l.isUpdatingInteractively=!0;const{field:r,getValue:a}=l;t.setAttribute(r,a(o.xScale,e))}await R(t,i,"2d"===e.type?e.scale:null)}async function ee({feature:e,featureClone:t,visualVariableAttributes:r,sketchViewModel:n,view:s,onUpdate:l,webStyleCache:u}){await R(t,u,"2d"===s.type?s.scale:null);let p=null;if("2d"===n?.view?.type){const e=o((e=>R(t,u,e)));p=c((()=>n?.view?.scale),(t=>e(t)))}s.map.add(n.layer);const y=t.sourceLayer,d=pe(s,y);await ae(s,t),await N({graphic:t,sketchViewModel:n,sourceLayer:y,visualVariables:r,webStyleCache:u});let f=null;d.then((e=>f=e)).catch((()=>{}));const m=r.size,h=r.rotation,b=c((()=>e.attributes),(async e=>{let r=!1;for(const a in e){const i=e[a];i!==t.getAttribute(a)&&(t.setAttribute(a,i),null==m||m.isUpdatingInteractively||m.field!==a||m.initValue(i),null==h||h.isUpdatingInteractively||h.field!==a||h.initValue(i),(null==f||f.requiredFields.includes(a))&&(r=!0))}r&&await R(t,u,"2d"===s.type?s.scale:null)})),g=n.on("update",(async e=>{const t=e.graphics[0];if("complete"===e.state)return N({graphic:t,sketchViewModel:n,sourceLayer:y,visualVariables:r,webStyleCache:u});await $(s,t,e,r,u),l(fe(t),e)})),w=n.on(["undo","redo"],(async e=>{l(fe(e.graphics[0]),e)}));return a([w,g,i((()=>n.cancel())),b,p])}function te(e,t,n){const s=e.view;e.layer.add(n);const o=t.sourceLayer,c=t.layer,p=t.getAttribute(c.objectIdField);let y=null;function d(e){y?.abort(),y=r((async t=>{const r=await pe(s,o);l(t),r.setVisibility?.(p,e)}))}return d(!1),a([re(s,n,(e=>d(!e))),i((async()=>{d(!0);try{const e=await pe(s,o);await u((()=>!e.updating))}finally{e.layer.remove(n)}}))])}function re(e,t,r){if("3d"===e.type){const i=new z({graphic:t});return a([e.trackGraphicState(i),c((()=>i.displaying),r)])}return c((()=>t.visible),r)}async function ae(e,t){if("3d"===e.type){const r=new z({graphic:t}),a=e.trackGraphicState(r);await u((()=>r.displaying)),a.remove()}else await u((()=>t.visible))}const ie={icon:p(24),text:p(12),line:p(1),viewScaleSizeFactor:100};function ne(e,t,r){let a=!1;return e.filter((e=>!!a||(a=e===t,a))).map((e=>r[e]()))}function se(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const e=r.layer,a=x(e);1===a.length&&"scene"!==e.type&&(r.template=a[0],t.shift())}return t}function le(e){switch(e){case"unknown":case"decimal-degrees":return null;default:return e}}function oe(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}function ce(e){const{creationInfo:t,viewModel:r}=e;if(!t)return!1;const{layer:a}=t,i=r.editableItems.find((e=>e.layer===a));if(i)return i.attachmentsOnCreateEnabled;const n=a.capabilities?.data,s=r.layerInfos?.find((e=>e.layer===a));return!(!(n&&"supportsAttachment"in n&&n.supportsAttachment)||s&&(!1===s.allowAttachments||!1===s.attachmentsOnUpdateEnabled))}const ue=e=>/-stop/.test(e)||/vertex-/.test(e),pe=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function ye(e){return"createInteractiveEditSession"in e}const de=Symbol();function fe(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=n(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function me(e){const t=e.cursor;return e.cursor="progress",i((()=>e.cursor=t))}export{de as UsesSketchViewModelSymbol,se as avoidFeatureTemplateSelectionWithOnlyOneItem,ye as canCreateInteractiveEditSession,fe as cloneGraphicExceptMesh,ne as createWorkflowSteps,W as fetchCandidates,K as fetchFullFeature,B as findLayerInfo,k as getVisualVariableAttributes,ue as isTerminalUpdateEventType,oe as prepareAttachmentsForCreateWorkflow,G as setUpFeatureAdd,ee as setUpGeometryUpdate,ce as shouldShowAttachmentsForCreateWorkflow,me as showProgressCursor,ie as sizeDefaults,le as sizeVariableUnitToLengthUnit,Z as startCreatingNewFeature,N as startUpdatingFeature,te as swapForEditingSession,R as updateGraphicSymbolWhenRequired,$ as visualVariableInteractiveUpdate,pe as whenEditorLayerView,ae as whenGraphicDisplayed};
5
+ import e from"../../Graphic.js";import{addMany as t}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import"../../core/has.js";import{handlesGroup as a,makeHandle as i}from"../../core/handleUtils.js";import{clone as n}from"../../core/lang.js";import{whenOrAbort as s,throwIfAborted as l,debounce as o}from"../../core/promiseUtils.js";import{watch as c,whenOnce as u}from"../../core/reactiveUtils.js";import{px2pt as p}from"../../core/screenUtils.js";import{diff as y}from"../../core/accessorSupport/diffUtils.js";import{featureHasFields as d,fixFields as f,getDisplayFieldName as m}from"../../layers/support/fieldUtils.js";import{calculateTolerance as h}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as b}from"../../renderers/support/lengthUtils.js";import{getTransformationType as g,TransformationType as w}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getRotationAngle as v,getSize as S}from"../../renderers/visualVariables/support/visualVariableUtils.js";import{sceneLayerEditingEnabled as j,i3sPatchingEnabled as U}from"../../support/featureFlags.js";import{to3D as V}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as I}from"../../symbols/support/symbolUtils.js";import{GraphicState as z}from"../../views/3d/layers/graphics/GraphicState.js";import{createQueryGeometry as F}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as L,filterGraphicHits as T}from"../../views/support/hitTestSelectUtils.js";import{getAllTemplatesForLayer as x}from"../support/templateUtils.js";function k(e){const t=e.sourceLayer;if(!t||"feature"!==t.type||!P(t.renderer))return{rotation:null,size:null};let r=null,a=null;const i=t.renderer.getVisualVariablesForType("rotation").filter((t=>(!t.axis||"heading"===t.axis)&&t.field&&!t.valueExpression&&null!=v(t,e)));1===i.length&&(r=E(i[0],t));const n=t.renderer.getVisualVariablesForType("size").filter((t=>t.field&&!t.useSymbolValue&&!t.valueExpression&&g(t)===w.RealWorldSize&&null!=S(t,e)));return 1===n.length&&(a=M(n[0],t)),{rotation:r,size:a}}function E(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,a=e.field,i=t.fields&&t.fields.filter((e=>e.name===a)),n=i&&1===i.length?i[0].type:"double",s={initial:0,current:0};return{field:a,fieldType:n,getDefault:()=>Promise.resolve(0),getValue:e=>(s.current=s.initial-r*e,C((s.current+360)%360,n)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function A(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function O(e,t,r){if(null==t)return 0;const{symbol:a}=V(t);if(null==a||"web-style"===a.type||"cim"===a.type)return 0;const i=a.symbolLayers.at(0);if(!i)return 0;switch(i.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return i.size||Math.min(ie.icon,(await e(i,ie.icon))[0])||ie.icon}case"text":return i.size||ie.text;case"line":return i.size||ie.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return A(await t(i,e.scale/ie.viewScaleSizeFactor),r)}case"path":return(null!=i.width?i.width:i.height)||e.scale/ie.viewScaleSizeFactor;case"extrude":return i.size||e.scale/ie.viewScaleSizeFactor;default:return 0}}function M(e,t){const r=e.field,a=e.axis,i=t.fields&&t.fields.filter((e=>e.name===r)),n=i&&1===i.length?i[0].type:"double",s={updating:!1,initial:0,current:0},l=b[e.valueUnit]??1;let o;return o="area"===e.valueRepresentation?e=>(e*l/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*l/2:e=>e*l,{field:r,fieldType:n,getDefault:async(e,t)=>C(o(await O(t,e,a)),n),getValue:(e,t)=>(s.initial||(s.initial=t.pixelSizeAt(t.center)),s.current=s.initial*e,C(s.current,n)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1,displayUnit:le(e.valueUnit),axis:e.axis}}function C(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function P(e){switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function R(e,t,r){const a=await I(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=y(e.symbol,a)&&(e.symbol=a)}function D(e){if(!e)throw new Error("no geometry type");return"multipatch"===e?"mesh":e}async function G(e,t,r,n){(await Z(e,t,n)).remove();const s=e.on("create",(async a=>{if("cancel"===a.state){(await Z(e,t,n)).remove()}if("complete"===a.state){const i=a.graphic;i.sourceLayer||(i.sourceLayer=t.layer),i.attributes||(i.attributes={...t.template?.prototype.attributes});const s="2d"===e.view?.type?e.view?.scale:null;await R(i,n,s),r(i)}}));return a([s,i((()=>e.cancel()))])}async function Z(e,t,r){const a=t.layer,n={...t.template?.prototype.attributes,...t.attributeOverrides};let s=null;const{view:l}=e,u="2d"===l?.type;if(await q(e,a,n,r,u?l.scale:null),u){const t=o((t=>q(e,a,n,r,t)));s=c((()=>l.scale),(e=>t(e)))}const{data:p,editing:y}=a.capabilities;return e.layer.elevationInfo=a.elevationInfo,await e.create(D(a.geometryType),{graphicProperties:{attributes:n,sourceLayer:a},hasZ:p.supportsZ,defaultZ:(u?y.zDefault:null)??e.defaultCreateOptions.defaultZ,geometryToPlace:t.geometryToPlace??void 0}),s??i()}async function q(t,r,a,i,n){const s=new e({sourceLayer:r,attributes:a}),{rotation:l,size:o}=k(s);let c=await I(s,{useSourceLayer:!0,webStyleCache:i,scale:n}),u=!1;for(const e of[o,l]){if(null==e)continue;null==a[e.field]&&(a[e.field]=await e.getDefault(c,t.view),u=!0)}switch(u&&(c=await I(s,{useSourceLayer:!0,webStyleCache:i,scale:n})),c?.type){case"simple-fill":case"polygon-3d":t.polygonSymbol=c;break;case"simple-line":case"line-3d":t.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":t.pointSymbol=c;break;case"mesh-3d":t.meshSymbol=c}Q(t.tooltipOptions,o,l)}function Q(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function B(e,t){return e?e.find((e=>e.layer===t)):void 0}async function W(e,t,r,a){switch(t.type){case"3d":return _(e,t,r,a);case"2d":return H(e,t,r,a)}}async function _(e,r,a,i){if(0===e.length)return[];const{updatable:n,graphicsByLayer:l}=await a.async((async()=>{const{results:t}=await s(L(r,a),i),n=new Map,l=e=>{const t=e.layer,r=n.get(t);if(!r){const e=new Array;return n.set(t,e),e}return r};T(t).forEach((({graphic:e})=>l(e).push(e)));const o=e.filter((({supports:e,layer:t})=>e.includes("update")&&n.has(t)));return 0!==o.length&&a.stopPropagation(),{updatable:o,graphicsByLayer:n}}));return s(Promise.allSettled(n.map((async({layer:e})=>{const r=l.get(e),a=J(e);if(r.every((e=>d(a,e))))return r;const n=[];for(const i of r){n.push(i.getObjectId());const e=Object.keys(i.attributes);t(a,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=n,s.outFields=f(e.fieldsIndex,a),e.queryFeatures(s,{signal:i}).then((({features:e})=>e))}))),i)}async function H(e,t,r,a){if(0===e.length)return[];let i=null;const n=await r.async((async()=>{const{results:n}=await s(t.hitTest(r),a);if(0===n.length)return[];const l=new Set;i=T(n),i.forEach((({graphic:e})=>e&&l.add(e.layer)));const o=e.items.filter((({layer:e,supports:t,attachmentsOnUpdateEnabled:r})=>l.has(e)&&(t.includes("update")||t.includes("delete")||r)));return o.length>0&&r.stopPropagation(),o}));return s(Promise.allSettled(n.map((async({layer:e})=>{const n=e.createQuery();n.returnGeometry=!1,n.outFields=J(e);const s="renderer"in e?h({renderer:e.renderer,event:r}):0;n.geometry=F(r.mapPoint,s,t),n.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(n,{signal:a});return i?.forEach((({graphic:t})=>{t.layer!==e||l.some((e=>e.getObjectId()===t.getObjectId()))||l.push(t)})),l}))),a)}function J(e){return f(e.fieldsIndex,[e.objectIdField,m({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function K(e,t,r){const{sourceLayer:a}=e,i=a.createQuery();i.objectIds=[e.getAttribute(a.objectIdField)],i.outFields=["*"],i.outSpatialReference=t,i.returnM=a.capabilities.data.supportsM,i.returnZ=a.capabilities.data.supportsZ,j()&&U()&&"scene"===a.type&&null!=a.infoFor3D&&(i.returnGeometry=!0,i.formatOf3DObjects="3D_glb");const n=await a.queryFeatures(i,{signal:r});l(r);return n.features[0]}async function N(e){const{graphic:t,sketchViewModel:r,sourceLayer:a,visualVariables:i,webStyleCache:n}=e;let s=!1;const{rotation:l,size:o}=i;if([l,o].forEach((async e=>{if(null==e)return;const a=t.getAttribute(e.field);if(null!=a)e.initValue(a);else{const a=await e.getDefault(t.symbol,r.view);e.initValue(a),t.setAttribute(e.field,a),s=!0}})),s){const e="2d"===r.view?.type?r.view.scale:null;await R(t,n,e)}const c={multipleSelectionEnabled:!1};return"point"===a.geometryType&&(c.enableRotation=null!=l,c.enableScaling=null!=o),Q(r.tooltipOptions,o,l),r.layer.elevationInfo=a.elevationInfo,r.update(t,c)}function X(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function Y(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function $(e,t,r,a,i){if(null==t.geometry||"point"!==t.geometry?.type)return;const n=a.rotation,s=X(r.toolEventInfo);if(null!=n&&null!=s)if("rotate-stop"===s.type)n.isUpdatingInteractively=!1,n.initValue();else{n.isUpdatingInteractively=!0;const{field:r,getValue:a}=n;t.setAttribute(r,a(s.angle,e))}const l=a.size,o=Y(r.toolEventInfo);if(null!=l&&null!=o)if("scale-stop"===o.type)l.isUpdatingInteractively=!1,l.initValue();else{l.isUpdatingInteractively=!0;const{field:r,getValue:a}=l;t.setAttribute(r,a(o.xScale,e))}await R(t,i,"2d"===e.type?e.scale:null)}async function ee({feature:e,featureClone:t,visualVariableAttributes:r,sketchViewModel:n,view:s,onUpdate:l,webStyleCache:u}){await R(t,u,"2d"===s.type?s.scale:null);let p=null;if("2d"===n?.view?.type){const e=o((e=>R(t,u,e)));p=c((()=>n?.view?.scale),(t=>e(t)))}s.map.add(n.layer);const y=t.sourceLayer,d=pe(s,y);await N({graphic:t,sketchViewModel:n,sourceLayer:y,visualVariables:r,webStyleCache:u});let f=null;d.then((e=>f=e)).catch((()=>{}));const m=r.size,h=r.rotation,b=c((()=>e.attributes),(async e=>{let r=!1;for(const a in e){const i=e[a];i!==t.getAttribute(a)&&(t.setAttribute(a,i),null==m||m.isUpdatingInteractively||m.field!==a||m.initValue(i),null==h||h.isUpdatingInteractively||h.field!==a||h.initValue(i),(null==f||f.requiredFields.includes(a))&&(r=!0))}r&&await R(t,u,"2d"===s.type?s.scale:null)})),g=n.on("update",(async e=>{const t=e.graphics[0];if("complete"===e.state)return N({graphic:t,sketchViewModel:n,sourceLayer:y,visualVariables:r,webStyleCache:u});await $(s,t,e,r,u),l(fe(t),e)})),w=n.on(["undo","redo"],(async e=>{l(fe(e.graphics[0]),e)}));return a([w,g,i((()=>n.cancel())),b,p])}async function te(e,t,n){const s=e.view;e.layer.add(n);const o=t.sourceLayer,c=t.layer,p=t.getAttribute(c.objectIdField);let y=null;function d(e){y?.abort(),y=r((async t=>{const r=await pe(s,o);l(t),r.setVisibility?.(p,e)}))}return await ae(s,n),d(!1),a([re(s,n,(e=>d(!e))),i((async()=>{d(!0);try{const e=await pe(s,o);await u((()=>!e.updating))}finally{e.layer.remove(n)}}))])}function re(e,t,r){if("3d"===e.type){const i=new z({graphic:t});return a([e.trackGraphicState(i),c((()=>i.displaying),r)])}return c((()=>t.visible),r)}async function ae(e,t){if("3d"===e.type){const r=new z({graphic:t}),a=e.trackGraphicState(r);await u((()=>r.displaying)),a.remove()}else await u((()=>t.visible))}const ie={icon:p(24),text:p(12),line:p(1),viewScaleSizeFactor:100};function ne(e,t,r){let a=!1;return e.filter((e=>!!a||(a=e===t,a))).map((e=>r[e]()))}function se(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const e=r.layer,a=x(e);1===a.length&&"scene"!==e.type&&(r.template=a[0],t.shift())}return t}function le(e){switch(e){case"unknown":case"decimal-degrees":return null;default:return e}}function oe(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}function ce(e){const{creationInfo:t,viewModel:r}=e;if(!t)return!1;const{layer:a}=t,i=r.editableItems.find((e=>e.layer===a));if(i)return i.attachmentsOnCreateEnabled;const n=a.capabilities?.data,s=r.layerInfos?.find((e=>e.layer===a));return!(!(n&&"supportsAttachment"in n&&n.supportsAttachment)||s&&(!1===s.allowAttachments||!1===s.attachmentsOnUpdateEnabled))}const ue=e=>/-stop/.test(e)||/vertex-/.test(e),pe=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function ye(e){return"createInteractiveEditSession"in e}const de=Symbol();function fe(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=n(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function me(e){const t=e.cursor;return e.cursor="progress",i((()=>e.cursor=t))}export{de as UsesSketchViewModelSymbol,se as avoidFeatureTemplateSelectionWithOnlyOneItem,ye as canCreateInteractiveEditSession,fe as cloneGraphicExceptMesh,ne as createWorkflowSteps,W as fetchCandidates,K as fetchFullFeature,B as findLayerInfo,k as getVisualVariableAttributes,ue as isTerminalUpdateEventType,oe as prepareAttachmentsForCreateWorkflow,G as setUpFeatureAdd,ee as setUpGeometryUpdate,ce as shouldShowAttachmentsForCreateWorkflow,me as showProgressCursor,ie as sizeDefaults,le as sizeVariableUnitToLengthUnit,Z as startCreatingNewFeature,N as startUpdatingFeature,te as swapForEditingSession,R as updateGraphicSymbolWhenRequired,$ as visualVariableInteractiveUpdate,pe as whenEditorLayerView,ae as whenGraphicDisplayed};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import{eventKey as i}from"../core/events.js";import o from"../core/Logger.js";import{watch as s,when as r}from"../core/reactiveUtils.js";import{throttle as n}from"../core/throttle.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import d from"./Feature.js";import c from"./Spinner.js";import u from"./Widget.js";import{css as h}from"./Feature/resources.js";import{FeatureContentMixin as p}from"./Feature/support/FeatureContentMixin.js";import{css as m}from"./Features/css.js";import v from"./Features/FeaturesRelatedRecords.js";import w from"./Features/FeaturesViewModel.js";import g from"./Features/FeaturesVisibleElements.js";import{ActionsCollection as _}from"./Popup/actions.js";import{getPointFromGeometry as f}from"./Popup/actionUtils.js";import{loadCalciteComponents as F}from"./support/componentsUtils.js";import{globalCss as M}from"./support/globalCss.js";import{Heading as b}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as y}from"./support/decorators/messageBundle.js";import{vmEvent as I}from"./support/decorators/vmEvent.js";import{tsx as C}from"./support/jsxFactory.js";import{substitute as A}from"../intl/substitute.js";import{formatNumber as N}from"../intl/number.js";const x="selected-index",j=0,R="features-spinner",k=50;let O=class extends(p(u)){constructor(e,i){super(e,i),this._featureMenuIntersectionObserverCallback=([e])=>{e?.isIntersecting&&null!=this.viewModel.featurePage&&this.viewModel.featurePage++},this._featureMenuIntersectionObserver=new IntersectionObserver(this._featureMenuIntersectionObserverCallback,{root:window.document}),this._featureMenuIntersectionObserverNode=null,this._focusOn=null,this._spinner=null,this._feature=null,this._relatedRecordsFlowItems=new t,this._relatedRecordsWidget=new v({flowItems:this._relatedRecordsFlowItems}),this._rootFlowItemNode=null,this._featureMenuViewportNode=null,this.collapsed=!1,this.icon=null,this.featureNavigationTop=!1,this.headerActions=new _,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.responsiveActionsEnabled=!1,this.viewModel=new w,this.visibleElements=new g,this._renderAction=(e,t)=>{const i=this._getActionTitle(e),{type:o,active:s,uid:r,disabled:n,indicator:a}=e;return e.visible?C("calcite-action",{active:"toggle"===o&&e.value,appearance:"solid",bind:this,"data-action-uid":r,disabled:n,icon:this._getActionIcon(e),indicator:a,key:`action-${t}`,loading:s,onclick:this._triggerAction,scale:"s",text:i,title:this._hideActionText?i:void 0},this._getFallbackIcon(e)):null},this._openFeatureMenu=()=>{this.featureMenuOpen=!0},this._previousFeature=()=>{this.viewModel.selectedFeatureIndex--},this._nextFeature=()=>{this.viewModel.selectedFeatureIndex++},this._handleFeatureMenuBack=()=>{this.featureMenuOpen&&(this._focusOn="root-flow-item",this.featureMenuOpen=!1,this.viewModel.browseClusterEnabled=!1)},this._focusFlowItemNode=e=>{this._focusOn===e&&requestAnimationFrame((async()=>{switch(e){case"menu-flow-item":await(this._featureMenuViewportNode?.setFocus());break;case"root-flow-item":await(this._rootFlowItemNode?.setFocus())}this._focusOn=null}))},this._focusFlowItemNodeThrottled=n(this._focusFlowItemNode,k),this._displaySpinnerThrottled=n((()=>this._displaySpinner()),j),this._addSelectedFeatureIndexHandle(),this.addHandles([this._displaySpinnerThrottled,this._focusFlowItemNodeThrottled,s((()=>this.viewModel?.active),(()=>this._toggleScreenLocationEnabled())),s((()=>this.viewModel?.active),(e=>this._relatedRecordsWidget.closed=!e)),s((()=>this.visibleElements?.closeButton),(e=>this._relatedRecordsWidget.closable=e)),s((()=>this.visibleElements?.spinner),(e=>this._spinnerEnabledChange(e))),s((()=>this.viewModel?.view),((e,t)=>this._viewChange(e,t))),s((()=>this.viewModel?.view?.ready),((e,t)=>this._viewReadyChange(e??!1,t??!1))),s((()=>[this.viewModel?.waitingForResult,this.viewModel?.location]),(()=>{this._hideSpinner(),this._displaySpinnerThrottled()})),s((()=>this.selectedFeatureWidget),(()=>this._destroyRelatedRecordsFlowItemWidgets())),s((()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.title,e?.state]}),(()=>this._setTitleFromFeatureWidget())),s((()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.content,e?.state]}),(()=>this._setContentFromFeatureWidget())),s((()=>this.viewModel?.featureViewModels),(()=>this._featureMenuViewportScrollTop())),this._relatedRecordsWidget.on("close",(()=>this.close())),this._relatedRecordsWidget.on("exit",(()=>this._destroyRelatedRecordsFlowItemWidgets())),this._relatedRecordsWidget.on("open-related-feature",(({feature:e})=>this._openRelatedFeature(e)))])}loadDependencies(){return F({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),"list-item-group":()=>import("@esri/calcite-components/dist/components/calcite-list-item-group.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js")})}destroy(){this._destroyRelatedRecordsFlowItemWidgets(),this._destroySelectedFeatureWidget(),this._destroySpinner(),this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver?.disconnect(),this._relatedRecordsWidget?.destroy()}get _hideActionText(){if(!this.responsiveActionsEnabled)return!1;const e=this.view?.widthBreakpoint;return"xsmall"===e||"small"===e||"medium"===e}get _featureNavigationVisible(){return this.viewModel.active&&this.viewModel.featureCount>1&&this.visibleElements.featureNavigation}get _isCollapsed(){return this._collapseEnabled&&this.collapsed}get _collapseEnabled(){return this.visibleElements.collapseButton&&!!this.title&&!!this.content}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){const{_feature:e,headingLevel:t,_relatedRecordsFlowItems:i}=this,{selectedFeatureViewModel:o}=this.viewModel,s={title:!1};return o?(e?(e.viewModel=o,e.visibleElements=s):this._feature=new d({flowItems:i,headingLevel:t+1,viewModel:o,visibleElements:s}),this._feature):null}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}blur(){const{active:e}=this.viewModel;e?this._rootFlowItemNode?.blur():o.getLogger(this).warn("Features can only be blurred when currently active.")}clear(){return this.viewModel.clear()}close(){this.viewModel.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{active:e}=this.viewModel;e?this._setFocusOn():o.getLogger(this).warn("Features can only be focused when currently active.")}next(){return this.viewModel.next()}open(e){this.removeHandles(x);const t={collapsed:e?.collapsed??!1};this.set(t),this.viewModel.open(e),this.addHandles(r((()=>!this.viewModel.waitingForResult),(()=>this._addSelectedFeatureIndexHandle()),{once:!0}))}previous(){return this.viewModel.previous()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){return C("div",{bind:this,class:this.classes(m.base,M.widget,M.panel),onkeydown:this._onMainKeydown},this._renderHeader(),this._renderContentContainer())}_renderFeatureNavigation(){return[this._renderPagination(),this._renderFeatureMenuButton()]}_renderHeader(){return!this.featureMenuOpen&&this.featureNavigationTop&&this._featureNavigationVisible?C("div",{class:m.header,key:"header-actions"},this._renderFeatureNavigation()):null}_renderFooter(){return this.featureMenuOpen||this.featureNavigationTop||!this._featureNavigationVisible?null:C("div",{class:m.footer,key:"footer-actions",slot:"footer"},this._renderFeatureNavigation())}_renderFeatureMenuButton(){const{messages:e,viewModel:t}=this,{featureCount:i,selectedFeatureIndex:o,pendingPromisesCount:s}=t;return C("calcite-action",{appearance:"solid",bind:this,icon:"list",key:"feature-menu-button",label:e.selectFeature,loading:s>0,onclick:this._openFeatureMenu,scale:"s",text:A(e.pageText,{index:N(o+1),total:N(i)}),textEnabled:!0,title:e.selectFeature})}_renderPagination(){const{previous:e,next:t}=this.messagesCommon.pagination;return C("calcite-action-bar",{class:m.paginationActionBar,expandDisabled:!0,key:"pagination-action-bar",layout:"horizontal",overflowActionsDisabled:!0,scale:"s"},C("calcite-action-group",{scale:"s"},C("calcite-action",{appearance:"solid",class:m.paginationPrevious,icon:"chevron-left",iconFlipRtl:!0,label:e,onclick:this._previousFeature,scale:"s",text:e,title:e}),C("calcite-action",{appearance:"solid",icon:"chevron-right",iconFlipRtl:!0,label:t,onclick:this._nextFeature,scale:"s",text:t,title:t})))}_renderFeatureMenuItem(e){const{selectedFeatureViewModel:t,featureViewModels:i}=this.viewModel,o=e===t,s=i.indexOf(e);return C("calcite-list-item",{bind:this,"data-feature-index":s,key:`feature-menu-item-${e.uid}`,onblur:this._removeActiveFeature,onfocus:this._setActiveFeature,onmouseleave:this._removeActiveFeature,onmouseover:this._setActiveFeature,selected:o,onCalciteListItemSelect:this._selectFeature},C("span",{innerHTML:e.title||this.messagesCommon.untitled,slot:"content"}))}_groupResultsByLayer(){const{featureViewModels:e}=this.viewModel,t=new Map;return e.forEach((e=>{const i=e?.graphic;if(!i)return;const o=i.sourceLayer??i.layer,s=t.get(o)??[];t.set(o,[...s,e])})),t}_renderFeatureMenu(){const{featureViewModels:e}=this.viewModel,t=this._groupResultsByLayer();return e.length?C("calcite-list",{selectionAppearance:"icon",selectionMode:"single"},Array.from(t.keys()).map((e=>C("calcite-list-item-group",{heading:e?.title??this.messagesCommon.untitled,key:e?.uid||"untitled"},t.get(e)?.map((e=>this._renderFeatureMenuItem(e))))))):null}_renderHeaderAction(e,t){return e.visible?C("calcite-action",{active:"toggle"===e.type&&e.value,appearance:"solid",bind:this,"data-action-uid":e.uid,disabled:e.disabled,icon:e.icon||"",indicator:e.indicator,key:`header-action-${t}`,loading:e.active,onclick:this._triggerHeaderAction,scale:"m",slot:"header-actions-end",text:e.title||"",title:e.title||""}):null}_renderHeaderActions(){return this.headerActions.map(((e,t)=>this._renderHeaderAction(e,t))).toArray()}_renderContentFeature(){const{headingLevel:e,visibleElements:t,_isCollapsed:i,_collapseEnabled:o,featureNavigationTop:s}=this,{title:r,active:n}=this.viewModel,a=t.heading&&r?r:"";return C("calcite-flow-item",{afterCreate:this._storeRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,class:this.classes({[m.contentFeature]:!0,[m.flowItemCollapsed]:i}),closable:t.closeButton,closed:!n,collapsed:i,collapseDirection:s?"down":"up",collapsible:o,headingLevel:e,key:"root-flow-item",onCalciteFlowItemClose:this.close,onCalciteFlowItemToggle:this._handleCollapseToggle},a?C(b,{class:this.classes(m.featuresHeading,M.heading),innerHTML:a,key:"header-content",level:this.headingLevel,slot:"header-content"}):null,this._renderHeaderActions(),this._renderActionBar(),i?null:C("div",{class:this.classes(m.container,m.contentContainer)},this._renderContent()),this._renderFooter())}_renderFeatureMenuContainer(){const{viewModel:e,featureMenuOpen:t,messages:i,messagesCommon:o}=this,{active:s,featureViewModels:r,pendingPromisesCount:n}=e;return t?C("calcite-flow-item",{afterCreate:this._storeFeatureMenuFlowItemNode,afterUpdate:this._focusFeatureMenuFlowItemNode,bind:this,closable:!1,closed:!s,description:A(i.total,{total:r.length}),heading:i.selectFeature,key:"feature-menu",loading:e.waitingForContents,onCalciteFlowItemBack:this._handleFeatureMenuBack},n>0?C("calcite-loader",{class:m.loader,inline:!0,key:"feature-menu-loader",label:o.loading,scale:"m",slot:"header-actions-end"}):null,C("div",{class:m.container},this._renderFeatureMenu()),C("div",{afterCreate:this._featureMenuIntersectionObserverCreated,bind:this,class:m.featureMenuObserver}),C("calcite-button",{appearance:"transparent",onclick:this._handleFeatureMenuBack,slot:"footer-actions",width:"full"},o.back)):null}_renderContentContainer(){return C("calcite-flow",{key:"content-container"},this._renderContentFeature(),this._renderFeatureMenuContainer(),this._relatedRecordsWidget.render())}_getIconStyles(e){return{"background-image":e?`url(${e})`:""}}_getActionImage(e){const{selectedFeature:t}=this,i=t?.attributes,{image:o}=e;return o&&i?A(o,i):o??""}_getFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o=this._getActionImage(e),s={[m.icon]:!!t,[m.actionImage]:!!o};return t&&(s[t]=!0),o||t?C("span",{"aria-hidden":"true",class:this.classes(m.icon,s),key:"icon",styles:o?this._getIconStyles(o):{}}):null}_renderActionBar(){return!this._isCollapsed&&this.visibleElements.actionBar&&this.viewModel.allActions?.length?C("calcite-action-bar",{expandDisabled:!0,expanded:!this._hideActionText,key:"header-action-bar",scale:"s",slot:"action-bar"},C("calcite-action-group",{overlayPositioning:"fixed",scale:"s"},this._renderActions())):null}_renderActions(){return this.viewModel.allActions.toArray().map(this._renderAction)}_renderContent(){const e=this.viewModel?.content;return e?"string"==typeof e?C("div",{class:h.contentNode,innerHTML:e,key:e}):this.renderNodeContent(e):null}_setFocusOn(){this._focusOn=this.featureMenuOpen?"menu-flow-item":"root-flow-item",this.renderNow()}_handleCollapseToggle(){this.collapsed=!this.collapsed}async _openRelatedFeature(e){await e.viewModel.updateGeometry();const t=e.graphic,i=t?.geometry;if(null==i||null==t)return;this._destroyRelatedRecordsFlowItemWidgets(),await this.viewModel.zoomTo({target:i});const o=f(i);this.open({features:[t],location:null!=o?o:void 0})}_focusRootFlowItemNode(){this._focusFlowItemNodeThrottled("root-flow-item")}_focusFeatureMenuFlowItemNode(){this._focusFlowItemNodeThrottled("menu-flow-item")}_storeRootFlowItemNode(e){this._rootFlowItemNode=e,this._focusFlowItemNodeThrottled("root-flow-item")}_storeFeatureMenuFlowItemNode(e){this._featureMenuViewportNode=e,this._focusFlowItemNodeThrottled("menu-flow-item")}_setActiveFeature(e){const{viewModel:t}=this,i=e.currentTarget["data-feature-index"];t.activeFeature=t.features?.[i]||null}_removeActiveFeature(){this.viewModel.activeFeature=null}_selectFeature(e){const t=e.currentTarget["data-feature-index"];isNaN(t)||(this.viewModel.selectedFeatureIndex=t),this._handleFeatureMenuBack()}_unobserveFeatureMenuObserver(){this._featureMenuIntersectionObserverNode&&this._featureMenuIntersectionObserver.unobserve(this._featureMenuIntersectionObserverNode)}_featureMenuIntersectionObserverCreated(e){this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver.observe(e),this._featureMenuIntersectionObserverNode=e}_getActionIcon(e){return e.icon?e.icon:e.image||e.className?void 0:"question"}_getActionTitle(e){const{messages:t,selectedFeature:i,messagesCommon:o}=this,{id:s}=e,r=i?.attributes,n=e.title??"",a="zoom-to-feature"===s?A(n,{messages:t}):"remove-selected-feature"===s?A(n,{messages:o}):"zoom-to-clustered-features"===s||"browse-clustered-features"===s?A(n,{messages:t}):e.title;return a&&r?A(a,r):a??""}_onMainKeydown(e){const t=i(e);"ArrowLeft"===t&&(e.stopPropagation(),this._handleFeatureMenuBack(),this.previous()),"ArrowRight"===t&&(e.stopPropagation(),this._handleFeatureMenuBack(),this.next())}_featureMenuViewportScrollTop(){this._featureMenuViewportNode&&this._featureMenuViewportNode.scrollContentTo({top:0})}_setContentFromFeatureWidget(){const{selectedFeatureWidget:e}=this;e&&(this.viewModel.content=e)}_setTitleFromFeatureWidget(){const{selectedFeatureWidget:e,messagesCommon:t}=this,i=e?.viewModel;e&&(this.viewModel.title="error"===i?.state?t?.errorMessage:i?.title||"")}_addSelectedFeatureIndexHandle(){const e=s((()=>this.viewModel?.selectedFeatureIndex),((e,t)=>this._selectedFeatureIndexUpdated(e,t)));this.addHandles(e,x)}_selectedFeatureIndexUpdated(e,t){const{featureCount:i}=this.viewModel;i&&e!==t&&-1!==e&&(this._destroyRelatedRecordsFlowItemWidgets(),this._rootFlowItemNode&&this._rootFlowItemNode.scrollContentTo({top:0}))}_triggerHeaderAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,o=this.headerActions.find((({uid:e})=>e===i));o&&!o.disabled&&("toggle"===o?.type&&(o.value=!o.value),this.emit("trigger-header-action",{action:o}))}_triggerAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,{allActions:o}=this.viewModel,s=o.findIndex((e=>e.uid===i)),r=o.at(s);r&&"toggle"===r.type&&(r.value=!r.value),this.viewModel.triggerAction(s)}_createSpinner(e){e&&(this._spinner=new c({view:e}),e.ui.add(this._spinner,{key:R,position:"manual",internal:!0}))}_wireUpView(e){this._destroySpinner(),e&&this.visibleElements?.spinner&&this._createSpinner(e)}_hideSpinner(){const{_spinner:e}=this;e&&(e.location=null,e.hide())}_viewReadyChange(e,t){e?this._wireUpView(this.viewModel?.view):t&&this.viewModel.clear()}_viewChange(e,t){e&&t&&this.viewModel.clear()}_destroySelectedFeatureWidget(){const{_feature:e}=this;e&&(e.viewModel=null,!e.destroyed&&e.destroy()),this._feature=null}_destroyRelatedRecordsFlowItemWidgets(){this._relatedRecordsFlowItems.removeAll().forEach((e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy()}))}_toggleScreenLocationEnabled(){const{viewModel:e}=this;e&&(e.screenLocationEnabled=e.active)}_displaySpinner(){const{_spinner:e}=this;if(!e)return;const{location:t,waitingForResult:i}=this.viewModel;i&&t?e.show({location:t}):e.hide()}_destroySpinner(){const{_spinner:e,view:t}=this;e&&(t?.ui?.remove(e,R),e.destroy(),this._spinner=null)}_spinnerEnabledChange(e){this._destroySpinner(),e&&this._createSpinner(this.viewModel?.view)}};e([a()],O.prototype,"_focusOn",void 0),e([a()],O.prototype,"_relatedRecordsFlowItems",void 0),e([a()],O.prototype,"_hideActionText",null),e([a()],O.prototype,"_featureNavigationVisible",null),e([a()],O.prototype,"_isCollapsed",null),e([a()],O.prototype,"_collapseEnabled",null),e([a()],O.prototype,"collapsed",void 0),e([a()],O.prototype,"content",null),e([a()],O.prototype,"icon",void 0),e([a()],O.prototype,"featureMenuOpen",null),e([a()],O.prototype,"featureNavigationTop",void 0),e([a()],O.prototype,"features",null),e([a({type:_})],O.prototype,"headerActions",void 0),e([a()],O.prototype,"headingLevel",void 0),e([a()],O.prototype,"location",null),e([a()],O.prototype,"label",null),e([a(),y("esri/widgets/Features/t9n/Features")],O.prototype,"messages",void 0),e([a(),y("esri/t9n/common")],O.prototype,"messagesCommon",void 0),e([a()],O.prototype,"promises",null),e([a()],O.prototype,"responsiveActionsEnabled",void 0),e([a({readOnly:!0})],O.prototype,"selectedFeature",null),e([a()],O.prototype,"selectedFeatureIndex",null),e([a({readOnly:!0})],O.prototype,"selectedFeatureWidget",null),e([a()],O.prototype,"title",null),e([a()],O.prototype,"updateLocationEnabled",null),e([a()],O.prototype,"view",null),e([a({type:w}),I(["triggerAction","trigger-action"])],O.prototype,"viewModel",void 0),e([a({type:g,nonNullable:!0})],O.prototype,"visibleElements",void 0),e([a()],O.prototype,"visible",null),O=e([l("esri.widgets.Features")],O);const T=O;export{T as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import{eventKey as i}from"../core/events.js";import o from"../core/Logger.js";import{watch as s,when as r}from"../core/reactiveUtils.js";import{throttle as n}from"../core/throttle.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import d from"./Feature.js";import c from"./Spinner.js";import u from"./Widget.js";import{css as h}from"./Feature/resources.js";import{FeatureContentMixin as p}from"./Feature/support/FeatureContentMixin.js";import{css as m}from"./Features/css.js";import v from"./Features/FeaturesRelatedRecords.js";import w from"./Features/FeaturesViewModel.js";import g from"./Features/FeaturesVisibleElements.js";import{ActionsCollection as _}from"./Popup/actions.js";import{getPointFromGeometry as f}from"./Popup/actionUtils.js";import{loadCalciteComponents as F}from"./support/componentsUtils.js";import{globalCss as M}from"./support/globalCss.js";import{Heading as b}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as y}from"./support/decorators/messageBundle.js";import{vmEvent as I}from"./support/decorators/vmEvent.js";import{tsx as C}from"./support/jsxFactory.js";import{substitute as A}from"../intl/substitute.js";import{formatNumber as N}from"../intl/number.js";const x="selected-index",j=0,R="features-spinner",k=50;let O=class extends(p(u)){constructor(e,i){super(e,i),this._featureMenuIntersectionObserverCallback=([e])=>{e?.isIntersecting&&null!=this.viewModel.featurePage&&this.viewModel.featurePage++},this._featureMenuIntersectionObserver=new IntersectionObserver(this._featureMenuIntersectionObserverCallback,{root:window.document}),this._featureMenuIntersectionObserverNode=null,this._focusOn=null,this._spinner=null,this._feature=null,this._relatedRecordsFlowItems=new t,this._relatedRecordsWidget=new v({flowItems:this._relatedRecordsFlowItems}),this._rootFlowItemNode=null,this._featureMenuViewportNode=null,this.collapsed=!1,this.icon=null,this.featureNavigationTop=!1,this.headerActions=new _,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.responsiveActionsEnabled=!1,this.viewModel=new w,this.visibleElements=new g,this._renderAction=(e,t)=>{const i=this._getActionTitle(e),{type:o,active:s,uid:r,disabled:n,indicator:a}=e;return e.visible?C("calcite-action",{active:"toggle"===o&&e.value,appearance:"solid",bind:this,"data-action-uid":r,disabled:n,icon:this._getActionIcon(e),indicator:a,key:`action-${t}`,loading:s,onclick:this._triggerAction,scale:"s",text:i,title:this._hideActionText?i:void 0},this._getFallbackIcon(e)):null},this._openFeatureMenu=()=>{this.featureMenuOpen=!0},this._previousFeature=()=>{this.viewModel.selectedFeatureIndex--},this._nextFeature=()=>{this.viewModel.selectedFeatureIndex++},this._handleFeatureMenuBack=()=>{this.featureMenuOpen&&(this._focusOn="root-flow-item",this.featureMenuOpen=!1)},this._focusFlowItemNode=e=>{this._focusOn===e&&requestAnimationFrame((async()=>{switch(e){case"menu-flow-item":await(this._featureMenuViewportNode?.setFocus());break;case"root-flow-item":await(this._rootFlowItemNode?.setFocus())}this._focusOn=null}))},this._focusFlowItemNodeThrottled=n(this._focusFlowItemNode,k),this._displaySpinnerThrottled=n((()=>this._displaySpinner()),j),this._addSelectedFeatureIndexHandle(),this.addHandles([this._displaySpinnerThrottled,this._focusFlowItemNodeThrottled,s((()=>this.viewModel?.active),(()=>this._toggleScreenLocationEnabled())),s((()=>this.viewModel?.active),(e=>this._relatedRecordsWidget.closed=!e)),s((()=>this.visibleElements?.closeButton),(e=>this._relatedRecordsWidget.closable=e)),s((()=>this.visibleElements?.spinner),(e=>this._spinnerEnabledChange(e))),s((()=>this.viewModel?.view),((e,t)=>this._viewChange(e,t))),s((()=>this.viewModel?.view?.ready),((e,t)=>this._viewReadyChange(e??!1,t??!1))),s((()=>[this.viewModel?.waitingForResult,this.viewModel?.location]),(()=>{this._hideSpinner(),this._displaySpinnerThrottled()})),s((()=>this.selectedFeatureWidget),(()=>this._destroyRelatedRecordsFlowItemWidgets())),s((()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.title,e?.state]}),(()=>this._setTitleFromFeatureWidget())),s((()=>{const e=this.selectedFeatureWidget?.viewModel;return[e?.content,e?.state]}),(()=>this._setContentFromFeatureWidget())),s((()=>this.viewModel?.featureViewModels),(()=>this._featureMenuViewportScrollTop())),this._relatedRecordsWidget.on("close",(()=>this.close())),this._relatedRecordsWidget.on("exit",(()=>this._destroyRelatedRecordsFlowItemWidgets())),this._relatedRecordsWidget.on("open-related-feature",(({feature:e})=>this._openRelatedFeature(e)))])}loadDependencies(){return F({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),"list-item-group":()=>import("@esri/calcite-components/dist/components/calcite-list-item-group.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js")})}destroy(){this._destroyRelatedRecordsFlowItemWidgets(),this._destroySelectedFeatureWidget(),this._destroySpinner(),this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver?.disconnect(),this._relatedRecordsWidget?.destroy()}get _hideActionText(){if(!this.responsiveActionsEnabled)return!1;const e=this.view?.widthBreakpoint;return"xsmall"===e||"small"===e||"medium"===e}get _featureNavigationVisible(){return this.viewModel.active&&this.viewModel.featureCount>1&&this.visibleElements.featureNavigation}get _isCollapsed(){return this._collapseEnabled&&this.collapsed}get _collapseEnabled(){return this.visibleElements.collapseButton&&!!this.title&&!!this.content}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){const{_feature:e,headingLevel:t,_relatedRecordsFlowItems:i}=this,{selectedFeatureViewModel:o}=this.viewModel,s={title:!1};return o?(e?(e.viewModel=o,e.visibleElements=s):this._feature=new d({flowItems:i,headingLevel:t+1,viewModel:o,visibleElements:s}),this._feature):null}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}blur(){const{active:e}=this.viewModel;e?this._rootFlowItemNode?.blur():o.getLogger(this).warn("Features can only be blurred when currently active.")}clear(){return this.viewModel.clear()}close(){this.viewModel.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{active:e}=this.viewModel;e?this._setFocusOn():o.getLogger(this).warn("Features can only be focused when currently active.")}next(){return this.viewModel.next()}open(e){this.removeHandles(x);const t={collapsed:e?.collapsed??!1};this.set(t),this.viewModel.open(e),this.addHandles(r((()=>!this.viewModel.waitingForResult),(()=>this._addSelectedFeatureIndexHandle()),{once:!0}))}previous(){return this.viewModel.previous()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){return C("div",{bind:this,class:this.classes(m.base,M.widget,M.panel),onkeydown:this._onMainKeydown},this._renderHeader(),this._renderContentContainer())}_renderFeatureNavigation(){return[this._renderPagination(),this._renderFeatureMenuButton()]}_renderHeader(){return!this.featureMenuOpen&&this.featureNavigationTop&&this._featureNavigationVisible?C("div",{class:m.header,key:"header-actions"},this._renderFeatureNavigation()):null}_renderFooter(){return this.featureMenuOpen||this.featureNavigationTop||!this._featureNavigationVisible?null:C("div",{class:m.footer,key:"footer-actions",slot:"footer"},this._renderFeatureNavigation())}_renderFeatureMenuButton(){const{messages:e,viewModel:t}=this,{featureCount:i,selectedFeatureIndex:o,pendingPromisesCount:s}=t;return C("calcite-action",{appearance:"solid",bind:this,icon:"list",key:"feature-menu-button",label:e.selectFeature,loading:s>0,onclick:this._openFeatureMenu,scale:"s",text:A(e.pageText,{index:N(o+1),total:N(i)}),textEnabled:!0,title:e.selectFeature})}_renderPagination(){const{previous:e,next:t}=this.messagesCommon.pagination;return C("calcite-action-bar",{class:m.paginationActionBar,expandDisabled:!0,key:"pagination-action-bar",layout:"horizontal",overflowActionsDisabled:!0,scale:"s"},C("calcite-action-group",{scale:"s"},C("calcite-action",{appearance:"solid",class:m.paginationPrevious,icon:"chevron-left",iconFlipRtl:!0,label:e,onclick:this._previousFeature,scale:"s",text:e,title:e}),C("calcite-action",{appearance:"solid",icon:"chevron-right",iconFlipRtl:!0,label:t,onclick:this._nextFeature,scale:"s",text:t,title:t})))}_renderFeatureMenuItem(e){const{selectedFeatureViewModel:t,featureViewModels:i}=this.viewModel,o=e===t,s=i.indexOf(e);return C("calcite-list-item",{bind:this,"data-feature-index":s,key:`feature-menu-item-${e.uid}`,onblur:this._removeActiveFeature,onfocus:this._setActiveFeature,onmouseleave:this._removeActiveFeature,onmouseover:this._setActiveFeature,selected:o,onCalciteListItemSelect:this._selectFeature},C("span",{innerHTML:e.title||this.messagesCommon.untitled,slot:"content"}))}_groupResultsByLayer(){const{featureViewModels:e}=this.viewModel,t=new Map;return e.forEach((e=>{const i=e?.graphic;if(!i)return;const o=i.sourceLayer??i.layer,s=t.get(o)??[];t.set(o,[...s,e])})),t}_renderFeatureMenu(){const{featureViewModels:e}=this.viewModel,t=this._groupResultsByLayer();return e.length?C("calcite-list",{selectionAppearance:"icon",selectionMode:"single"},Array.from(t.keys()).map((e=>C("calcite-list-item-group",{heading:e?.title??this.messagesCommon.untitled,key:e?.uid||"untitled"},t.get(e)?.map((e=>this._renderFeatureMenuItem(e))))))):null}_renderHeaderAction(e,t){return e.visible?C("calcite-action",{active:"toggle"===e.type&&e.value,appearance:"solid",bind:this,"data-action-uid":e.uid,disabled:e.disabled,icon:e.icon||"",indicator:e.indicator,key:`header-action-${t}`,loading:e.active,onclick:this._triggerHeaderAction,scale:"m",slot:"header-actions-end",text:e.title||"",title:e.title||""}):null}_renderHeaderActions(){return this.headerActions.map(((e,t)=>this._renderHeaderAction(e,t))).toArray()}_renderContentFeature(){const{headingLevel:e,visibleElements:t,_isCollapsed:i,_collapseEnabled:o,featureNavigationTop:s}=this,{title:r,active:n}=this.viewModel,a=t.heading&&r?r:"";return C("calcite-flow-item",{afterCreate:this._storeRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,class:this.classes({[m.contentFeature]:!0,[m.flowItemCollapsed]:i}),closable:t.closeButton,closed:!n,collapsed:i,collapseDirection:s?"down":"up",collapsible:o,headingLevel:e,key:"root-flow-item",onCalciteFlowItemClose:this.close,onCalciteFlowItemToggle:this._handleCollapseToggle},a?C(b,{class:this.classes(m.featuresHeading,M.heading),innerHTML:a,key:"header-content",level:this.headingLevel,slot:"header-content"}):null,this._renderHeaderActions(),this._renderActionBar(),i?null:C("div",{class:this.classes(m.container,m.contentContainer)},this._renderContent()),this._renderFooter())}_renderFeatureMenuContainer(){const{viewModel:e,featureMenuOpen:t,messages:i,messagesCommon:o}=this,{active:s,featureViewModels:r,pendingPromisesCount:n}=e;return t?C("calcite-flow-item",{afterCreate:this._storeFeatureMenuFlowItemNode,afterUpdate:this._focusFeatureMenuFlowItemNode,bind:this,closable:!1,closed:!s,description:A(i.total,{total:r.length}),heading:i.selectFeature,key:"feature-menu",loading:e.waitingForContents,onCalciteFlowItemBack:this._handleFeatureMenuBack},n>0?C("calcite-loader",{class:m.loader,inline:!0,key:"feature-menu-loader",label:o.loading,scale:"m",slot:"header-actions-end"}):null,C("div",{class:m.container},this._renderFeatureMenu()),C("div",{afterCreate:this._featureMenuIntersectionObserverCreated,bind:this,class:m.featureMenuObserver}),C("calcite-button",{appearance:"transparent",onclick:this._handleFeatureMenuBack,slot:"footer-actions",width:"full"},o.back)):null}_renderContentContainer(){return C("calcite-flow",{key:"content-container"},this._renderContentFeature(),this._renderFeatureMenuContainer(),this._relatedRecordsWidget.render())}_getIconStyles(e){return{"background-image":e?`url(${e})`:""}}_getActionImage(e){const{selectedFeature:t}=this,i=t?.attributes,{image:o}=e;return o&&i?A(o,i):o??""}_getFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o=this._getActionImage(e),s={[m.icon]:!!t,[m.actionImage]:!!o};return t&&(s[t]=!0),o||t?C("span",{"aria-hidden":"true",class:this.classes(m.icon,s),key:"icon",styles:o?this._getIconStyles(o):{}}):null}_renderActionBar(){return!this._isCollapsed&&this.visibleElements.actionBar&&this.viewModel.allActions?.length?C("calcite-action-bar",{expandDisabled:!0,expanded:!this._hideActionText,key:"header-action-bar",scale:"s",slot:"action-bar"},C("calcite-action-group",{overlayPositioning:"fixed",scale:"s"},this._renderActions())):null}_renderActions(){return this.viewModel.allActions.toArray().map(this._renderAction)}_renderContent(){const e=this.viewModel?.content;return e?"string"==typeof e?C("div",{class:h.contentNode,innerHTML:e,key:e}):this.renderNodeContent(e):null}_setFocusOn(){this._focusOn=this.featureMenuOpen?"menu-flow-item":"root-flow-item",this.renderNow()}_handleCollapseToggle(){this.collapsed=!this.collapsed}async _openRelatedFeature(e){await e.viewModel.updateGeometry();const t=e.graphic,i=t?.geometry;if(null==i||null==t)return;this._destroyRelatedRecordsFlowItemWidgets(),await this.viewModel.zoomTo({target:i});const o=f(i);this.open({features:[t],location:null!=o?o:void 0})}_focusRootFlowItemNode(){this._focusFlowItemNodeThrottled("root-flow-item")}_focusFeatureMenuFlowItemNode(){this._focusFlowItemNodeThrottled("menu-flow-item")}_storeRootFlowItemNode(e){this._rootFlowItemNode=e,this._focusFlowItemNodeThrottled("root-flow-item")}_storeFeatureMenuFlowItemNode(e){this._featureMenuViewportNode=e,this._focusFlowItemNodeThrottled("menu-flow-item")}_setActiveFeature(e){const{viewModel:t}=this,i=e.currentTarget["data-feature-index"];t.activeFeature=t.features?.[i]||null}_removeActiveFeature(){this.viewModel.activeFeature=null}_selectFeature(e){const t=e.currentTarget["data-feature-index"];isNaN(t)||(this.viewModel.selectedFeatureIndex=t),this._handleFeatureMenuBack()}_unobserveFeatureMenuObserver(){this._featureMenuIntersectionObserverNode&&this._featureMenuIntersectionObserver.unobserve(this._featureMenuIntersectionObserverNode)}_featureMenuIntersectionObserverCreated(e){this._unobserveFeatureMenuObserver(),this._featureMenuIntersectionObserver.observe(e),this._featureMenuIntersectionObserverNode=e}_getActionIcon(e){return e.icon?e.icon:e.image||e.className?void 0:"question"}_getActionTitle(e){const{messages:t,selectedFeature:i,messagesCommon:o}=this,{id:s}=e,r=i?.attributes,n=e.title??"",a="zoom-to-feature"===s?A(n,{messages:t}):"remove-selected-feature"===s?A(n,{messages:o}):"zoom-to-clustered-features"===s||"browse-clustered-features"===s?A(n,{messages:t}):e.title;return a&&r?A(a,r):a??""}_onMainKeydown(e){const t=i(e);"ArrowLeft"===t&&(e.stopPropagation(),this._handleFeatureMenuBack(),this.previous()),"ArrowRight"===t&&(e.stopPropagation(),this._handleFeatureMenuBack(),this.next())}_featureMenuViewportScrollTop(){this._featureMenuViewportNode&&this._featureMenuViewportNode.scrollContentTo({top:0})}_setContentFromFeatureWidget(){const{selectedFeatureWidget:e}=this;e&&(this.viewModel.content=e)}_setTitleFromFeatureWidget(){const{selectedFeatureWidget:e,messagesCommon:t}=this,i=e?.viewModel;e&&(this.viewModel.title="error"===i?.state?t?.errorMessage:i?.title||"")}_addSelectedFeatureIndexHandle(){const e=s((()=>this.viewModel?.selectedFeatureIndex),((e,t)=>this._selectedFeatureIndexUpdated(e,t)));this.addHandles(e,x)}_selectedFeatureIndexUpdated(e,t){const{featureCount:i}=this.viewModel;i&&e!==t&&-1!==e&&(this._destroyRelatedRecordsFlowItemWidgets(),this._rootFlowItemNode&&this._rootFlowItemNode.scrollContentTo({top:0}))}_triggerHeaderAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,o=this.headerActions.find((({uid:e})=>e===i));o&&!o.disabled&&("toggle"===o?.type&&(o.value=!o.value),this.emit("trigger-header-action",{action:o}))}_triggerAction(e){const t=e.currentTarget;if(t.disabled)return;const i=t.dataset.actionUid,{allActions:o}=this.viewModel,s=o.findIndex((e=>e.uid===i)),r=o.at(s);r&&"toggle"===r.type&&(r.value=!r.value),this.viewModel.triggerAction(s)}_createSpinner(e){e&&(this._spinner=new c({view:e}),e.ui.add(this._spinner,{key:R,position:"manual",internal:!0}))}_wireUpView(e){this._destroySpinner(),e&&this.visibleElements?.spinner&&this._createSpinner(e)}_hideSpinner(){const{_spinner:e}=this;e&&(e.location=null,e.hide())}_viewReadyChange(e,t){e?this._wireUpView(this.viewModel?.view):t&&this.viewModel.clear()}_viewChange(e,t){e&&t&&this.viewModel.clear()}_destroySelectedFeatureWidget(){const{_feature:e}=this;e&&(e.viewModel=null,!e.destroyed&&e.destroy()),this._feature=null}_destroyRelatedRecordsFlowItemWidgets(){this._relatedRecordsFlowItems.removeAll().forEach((e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy()}))}_toggleScreenLocationEnabled(){const{viewModel:e}=this;e&&(e.screenLocationEnabled=e.active)}_displaySpinner(){const{_spinner:e}=this;if(!e)return;const{location:t,waitingForResult:i}=this.viewModel;i&&t?e.show({location:t}):e.hide()}_destroySpinner(){const{_spinner:e,view:t}=this;e&&(t?.ui?.remove(e,R),e.destroy(),this._spinner=null)}_spinnerEnabledChange(e){this._destroySpinner(),e&&this._createSpinner(this.viewModel?.view)}};e([a()],O.prototype,"_focusOn",void 0),e([a()],O.prototype,"_relatedRecordsFlowItems",void 0),e([a()],O.prototype,"_hideActionText",null),e([a()],O.prototype,"_featureNavigationVisible",null),e([a()],O.prototype,"_isCollapsed",null),e([a()],O.prototype,"_collapseEnabled",null),e([a()],O.prototype,"collapsed",void 0),e([a()],O.prototype,"content",null),e([a()],O.prototype,"icon",void 0),e([a()],O.prototype,"featureMenuOpen",null),e([a()],O.prototype,"featureNavigationTop",void 0),e([a()],O.prototype,"features",null),e([a({type:_})],O.prototype,"headerActions",void 0),e([a()],O.prototype,"headingLevel",void 0),e([a()],O.prototype,"location",null),e([a()],O.prototype,"label",null),e([a(),y("esri/widgets/Features/t9n/Features")],O.prototype,"messages",void 0),e([a(),y("esri/t9n/common")],O.prototype,"messagesCommon",void 0),e([a()],O.prototype,"promises",null),e([a()],O.prototype,"responsiveActionsEnabled",void 0),e([a({readOnly:!0})],O.prototype,"selectedFeature",null),e([a()],O.prototype,"selectedFeatureIndex",null),e([a({readOnly:!0})],O.prototype,"selectedFeatureWidget",null),e([a()],O.prototype,"title",null),e([a()],O.prototype,"updateLocationEnabled",null),e([a()],O.prototype,"view",null),e([a({type:w}),I(["triggerAction","trigger-action"])],O.prototype,"viewModel",void 0),e([a({type:g,nonNullable:!0})],O.prototype,"visibleElements",void 0),e([a()],O.prototype,"visible",null),O=e([l("esri.widgets.Features")],O);const T=O;export{T as default};