@arcgis/core 4.34.0-next.86 → 4.34.0-next.87

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 (170) hide show
  1. package/Basemap.js +1 -1
  2. package/Ground.js +1 -1
  3. package/Map.js +1 -1
  4. package/analysis/ElevationProfile/ElevationProfileLineGround.d.ts +4 -0
  5. package/analysis/ElevationProfile/{ElevationProfileGroundLine.js → ElevationProfileLineGround.js} +1 -1
  6. package/analysis/ElevationProfile/ElevationProfileLineInput.d.ts +4 -0
  7. package/analysis/ElevationProfile/{ElevationProfileInputLine.js → ElevationProfileLineInput.js} +1 -1
  8. package/analysis/ElevationProfile/ElevationProfileLineQuery.d.ts +4 -0
  9. package/analysis/ElevationProfile/{ElevationProfileQueryLine.js → ElevationProfileLineQuery.js} +1 -1
  10. package/analysis/ElevationProfile/ElevationProfileLineScene.d.ts +4 -0
  11. package/analysis/ElevationProfile/{ElevationProfileSceneLine.js → ElevationProfileLineScene.js} +1 -1
  12. package/analysis/ElevationProfile/elevationProfileLineTypes.js +1 -1
  13. package/analysis/ElevationProfileAnalysis.js +1 -1
  14. package/assets/esri/core/workers/RemoteClient.js +1 -1
  15. package/assets/esri/core/workers/chunks/0074f1836d7ff69ff6ec.js +1 -0
  16. package/assets/esri/core/workers/chunks/03ef19f0753d68770444.js +1 -0
  17. package/assets/esri/core/workers/chunks/{4a06ab00d095f63598b5.js → 09c2004126f4a5242b85.js} +1 -1
  18. package/assets/esri/core/workers/chunks/0f05425954578ac796ec.js +1 -0
  19. package/assets/esri/core/workers/chunks/109149c378aa4c5f8526.js +1 -0
  20. package/assets/esri/core/workers/chunks/{8307f635a5c0c4a95825.js → 143503f6eb270c4683f8.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{6c36cef0b58b87a1f17f.js → 177840d5f0076c0de46b.js} +4 -4
  22. package/assets/esri/core/workers/chunks/1c1b0cc91fe9cb3fec61.js +1 -0
  23. package/assets/esri/core/workers/chunks/1fc6311d4f0d27e88737.js +1 -0
  24. package/assets/esri/core/workers/chunks/257fd65786feb5951b90.js +1 -0
  25. package/assets/esri/core/workers/chunks/2dc88379ee94fabdaf52.js +1 -0
  26. package/assets/esri/core/workers/chunks/366db86914a63e6d0c68.js +1 -0
  27. package/assets/esri/core/workers/chunks/481c2b01e2fe92249698.js +1 -0
  28. package/assets/esri/core/workers/chunks/639d856cd217914dfe1f.js +1 -0
  29. package/assets/esri/core/workers/chunks/7540b34e743a23e67729.js +1 -0
  30. package/assets/esri/core/workers/chunks/7be11a3ef1f49245089f.js +1 -0
  31. package/assets/esri/core/workers/chunks/819a8bc1f0a694017ee6.js +1 -0
  32. package/assets/esri/core/workers/chunks/{1537b02e674f8ef77f4a.js → 8d63b42aea32ce2e5d09.js} +1 -1
  33. package/assets/esri/core/workers/chunks/8de11aab65d91e7f1a4d.js +1 -0
  34. package/assets/esri/core/workers/chunks/9386a0ebff78b6303ed2.js +1 -0
  35. package/assets/esri/core/workers/chunks/{4d47187bc0821413492d.js → 95bae3c275f1483eb7ed.js} +1 -1
  36. package/assets/esri/core/workers/chunks/b09b34f64a6bc2b49e0a.js +1 -0
  37. package/assets/esri/core/workers/chunks/b0a03b6edbcf6e933431.js +1 -0
  38. package/assets/esri/core/workers/chunks/b8997ae5893afa0298d1.js +1 -0
  39. package/assets/esri/core/workers/chunks/c0ae186620b68d43b338.js +1 -0
  40. package/assets/esri/core/workers/chunks/{9d7a22746dae1451deaf.js → c6cae8471c5d4ae40c65.js} +1 -1
  41. package/assets/esri/core/workers/chunks/db5a985ccc6b7d0ad855.js +1 -0
  42. package/assets/esri/core/workers/chunks/f3ee035fa7bf638c8e60.js +1 -0
  43. package/assets/esri/core/workers/chunks/fc5ac54aab66562c8463.js +1 -0
  44. package/assets/esri/themes/dark/main.css +1 -1
  45. package/assets/esri/themes/light/main.css +1 -1
  46. package/assets/esri/themes/light/view.css +1 -1
  47. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis.json +1 -0
  48. package/assets/esri/widgets/Editor/t9n/Editor.json +1 -1
  49. package/assets/esri/widgets/Editor/t9n/Editor_en.json +1 -1
  50. package/config.js +1 -1
  51. package/identity/IdentityManagerBase.js +1 -1
  52. package/interfaces.d.ts +133 -127
  53. package/kernel.js +1 -1
  54. package/layers/GaussianSplatLayer.js +1 -1
  55. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  56. package/layers/IntegratedMeshLayer.js +1 -1
  57. package/layers/ParquetLayer.js +1 -1
  58. package/layers/VectorTileLayer.js +1 -1
  59. package/layers/graphics/sources/ParquetSource.js +1 -1
  60. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  61. package/layers/support/FieldConfiguration.js +1 -1
  62. package/layers/support/fieldConfigUtils.js +1 -1
  63. package/layers/support/vectorTileLayerLoader.js +1 -1
  64. package/package.json +2 -2
  65. package/portal/schemas/definitions.js +1 -1
  66. package/support/basemapEnsureType.js +1 -1
  67. package/support/revision.js +1 -1
  68. package/views/2d/analysis/ElevationProfileAnalysisView2D.js +1 -1
  69. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  70. package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
  71. package/views/2d/layers/features/Processor.js +1 -1
  72. package/views/2d/layers/features/layerAdapters/CatalogFootprintLayerAdapter.js +1 -1
  73. package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
  74. package/views/2d/layers/features/layerAdapters/InMemoryLayerAdapter.js +1 -1
  75. package/views/2d/layers/features/layerAdapters/KnowledgeGraphSublayerAdapter.js +1 -1
  76. package/views/2d/layers/features/layerAdapters/OGCFeatureLayerAdapter.js +1 -1
  77. package/views/2d/layers/features/layerAdapters/OrientedImageryLayerAdapter.js +1 -1
  78. package/views/2d/layers/features/layerAdapters/ParquetLayerAdapter.js +1 -1
  79. package/views/2d/layers/features/layerAdapters/StreamLayerAdapter.js +1 -1
  80. package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +1 -1
  81. package/views/2d/layers/features/layerAdapters/featureServiceUtils.js +1 -1
  82. package/views/2d/layers/features/schema/SourceSchema.js +1 -1
  83. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  84. package/views/2d/layers/features/sources/FeatureSourceQueryInfo.js +1 -1
  85. package/views/2d/layers/features/sources/strategies/AFeatureLoadStrategy.js +5 -0
  86. package/views/2d/layers/features/sources/strategies/AFeatureTileLoadStrategy.js +5 -0
  87. package/views/2d/layers/features/sources/strategies/ALoadStrategy.js +1 -1
  88. package/views/2d/layers/features/sources/strategies/FeatureDrillDownTileLoadStrategy.js +5 -0
  89. package/views/2d/layers/features/sources/strategies/FeaturePagedTileLoadStrategy.js +5 -0
  90. package/views/2d/layers/features/sources/strategies/FeatureSnapshotLoadStrategy.js +5 -0
  91. package/views/2d/layers/features/sources/strategies/ParquetSnapshotLoadStrategy.js +1 -1
  92. package/views/2d/layers/features/sources/strategies/ParquetTileLoadStrategy.js +1 -1
  93. package/views/2d/layers/features/sources/strategies/StreamLoadStrategy.js +1 -1
  94. package/views/2d/layers/features/sources/strategies/chunks/FeatureSnapshotSourceChunk.js +1 -1
  95. package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
  96. package/views/2d/layers/features/sources/strategies/support/queryAdapters.js +1 -1
  97. package/views/2d/layers/features/support/FeatureSetReaderParquet.js +1 -1
  98. package/views/3d/GroundView3D.js +5 -0
  99. package/views/3d/analysis/ElevationProfile/{ElevationProfileSceneLineComputation.js → ElevationProfileLineSceneComputation.js} +1 -1
  100. package/views/3d/analysis/ElevationProfileAnalysisView3D.js +1 -1
  101. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementConfiguration.js +1 -1
  102. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
  103. package/views/3d/analysis/VolumeMeasurementAnalysisView3D.js +1 -1
  104. package/views/3d/glTF/internal/Resource.js +1 -1
  105. package/views/3d/interactive/SnappingVisualizer3D.js +1 -1
  106. package/views/3d/interactive/visualElements/DrapedVisualElementResources.js +1 -1
  107. package/views/3d/interactive/visualElements/LabelVisualElement.js +1 -1
  108. package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
  109. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  110. package/views/3d/layers/DrapedSubView3D.js +1 -1
  111. package/views/3d/layers/FlowSubView3D.js +1 -1
  112. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  113. package/views/3d/layers/I3SMeshView3D.js +1 -1
  114. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  115. package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
  116. package/views/3d/layers/MediaLayerView3D.js +1 -1
  117. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  118. package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
  119. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  120. package/views/3d/support/MemoryController.js +1 -1
  121. package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
  122. package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
  123. package/views/3d/support/popupHitTest.js +1 -1
  124. package/views/3d/terrain/OverlayManager.js +1 -1
  125. package/views/3d/terrain/OverlayRenderer.js +1 -1
  126. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  127. package/views/SceneView.js +1 -1
  128. package/views/analysis/ElevationProfile/ElevationProfileChart.js +1 -1
  129. package/views/analysis/ElevationProfile/{ElevationProfileGroundLineComputation.js → ElevationProfileLineGroundComputation.js} +1 -1
  130. package/views/analysis/ElevationProfile/{ElevationProfileInputLineComputation.js → ElevationProfileLineInputComputation.js} +1 -1
  131. package/views/analysis/ElevationProfile/{ElevationProfileQueryLineComputation.js → ElevationProfileLineQueryComputation.js} +1 -1
  132. package/views/analysis/ElevationProfile/ElevationProfileTool.js +1 -1
  133. package/widgets/Editor/Upload.js +1 -1
  134. package/widgets/Editor/components/Notices.js +1 -1
  135. package/widgets/Editor/modelUploadUtils.js +1 -1
  136. package/widgets/ElevationProfile/ElevationProfileLineGround.d.ts +2 -2
  137. package/widgets/ElevationProfile/ElevationProfileLineInput.d.ts +2 -2
  138. package/widgets/ElevationProfile/ElevationProfileLineQuery.d.ts +2 -2
  139. package/analysis/ElevationProfile/ElevationProfileGroundLine.d.ts +0 -4
  140. package/analysis/ElevationProfile/ElevationProfileInputLine.d.ts +0 -4
  141. package/analysis/ElevationProfile/ElevationProfileQueryLine.d.ts +0 -4
  142. package/analysis/ElevationProfile/ElevationProfileSceneLine.d.ts +0 -4
  143. package/assets/esri/core/workers/chunks/03e5d1a00d85e4d16bff.js +0 -1
  144. package/assets/esri/core/workers/chunks/0914a52fb33af5d77fab.js +0 -1
  145. package/assets/esri/core/workers/chunks/1d491447b13f2f2b4399.js +0 -1
  146. package/assets/esri/core/workers/chunks/20850b0fdb55fb17bc90.js +0 -1
  147. package/assets/esri/core/workers/chunks/42bc1e981624ce9844a4.js +0 -1
  148. package/assets/esri/core/workers/chunks/436bbe99bedd7b331edb.js +0 -1
  149. package/assets/esri/core/workers/chunks/486ea51306c619238e41.js +0 -1
  150. package/assets/esri/core/workers/chunks/49cb78c85de0102e5f02.js +0 -1
  151. package/assets/esri/core/workers/chunks/5610dfde4e636e2333a9.js +0 -1
  152. package/assets/esri/core/workers/chunks/655a878ddea4907d830e.js +0 -1
  153. package/assets/esri/core/workers/chunks/72fe4f1f789abb5b4035.js +0 -1
  154. package/assets/esri/core/workers/chunks/7402c2853f6aed8d1bc7.js +0 -1
  155. package/assets/esri/core/workers/chunks/79a9f47dfa9ebabb5dbd.js +0 -1
  156. package/assets/esri/core/workers/chunks/86378d4f4d7f9a370c22.js +0 -1
  157. package/assets/esri/core/workers/chunks/b19d723d09f5bea9ca27.js +0 -1
  158. package/assets/esri/core/workers/chunks/b78ea9cc4d5f2fd3d871.js +0 -1
  159. package/assets/esri/core/workers/chunks/bd4125d163f372a7e978.js +0 -1
  160. package/assets/esri/core/workers/chunks/d0a149050f7f1c1ada09.js +0 -1
  161. package/assets/esri/core/workers/chunks/da42cc4f6142846cb745.js +0 -1
  162. package/assets/esri/core/workers/chunks/dd84f630466a26722d57.js +0 -1
  163. package/assets/esri/core/workers/chunks/e17df11c98dbd869302b.js +0 -1
  164. package/assets/esri/core/workers/chunks/e1b3ae6426886e2fab07.js +0 -1
  165. package/assets/esri/core/workers/chunks/f6513ec888a7d927d948.js +0 -1
  166. package/views/2d/layers/features/sources/strategies/AFetchLoadStrategy.js +0 -5
  167. package/views/2d/layers/features/sources/strategies/ATileLoadStrategy.js +0 -5
  168. package/views/2d/layers/features/sources/strategies/DrillDownTileLoadStrategy.js +0 -5
  169. package/views/2d/layers/features/sources/strategies/PagedTileLoadStrategy.js +0 -5
  170. package/views/2d/layers/features/sources/strategies/SnapshotLoadStrategy.js +0 -5
@@ -0,0 +1 @@
1
+ {"labels":{"cut":"Cut: {volume}","fill":"Fill: {volume}"}}
@@ -1 +1 @@
1
- {"addAttachment":"Add attachment","associations":{"addContent":"Add Content","addAttachment":"Add Attachment","addStructure":"Add Structure","addContainer":"Add Container","addConnectivity":"Add Connection"},"attachments":"Attachments","cancelEditTitle":"Discard edits","cancelEditWarningMessage":"Unsaved changes will be lost.","cancelRequestTitle":"Cancel workflow","cancelRequestWarningMessage":"A request has been made to cancel this workflow.","clearAreaOfInterest":"Clear area of interest","clickToFinishTemplate":"Click {button} to finish.","continueEditing":"Continue editing","createAllFeaturesTemplate":"Create all","createFeatures":"Create features","createFeaturesTimeCompleteWarning":"An operation is taking long than expected.","createFeaturesSelectionList":{"featureNotReadyToSubmit":"Needs attention","featureReadyToSubmit":"Ready to create","discard":"Discard feature","heading":"Unsaved features"},"createFeaturesSubTemplate":"1 of {numFeatures}","curveEditingWarning":"One or more layers is set to allow true curve updates by true curve clients. Editor is not a true curve client.","deleteAttachmentWarningMessage":"This attachment will be permanently removed.","deleteAttachmentWarningTitle":"Delete attachment","deleteAssociationTitle":"Delete association","deleteAssociationMessage":"The association with this feature will be deleted. The feature will remain.","discardEdits":"Discard edits","editAttachment":"Manage attachment","editFeatures":"Edit features","editFeaturesList":"Features","errorWarningEditsNotApplied":"An error occurred during editing. The edits have not been applied.","errorWarningMessageTemplate":"Edits could not be saved: {errorMessage}","errorWarningTitle":"Something went wrong","formFieldCreateError":"Features cannot be created. There is an issue with the form.","formFieldUnsupportedCreateError":"Features cannot be created. Layer contains unsupported fields.","formFieldUnsupportedUpdateError":"Feature cannot be updated. Layer contains unsupported fields.","helpMessages2d":{"select":"Click on the map to select a feature.","mesh":"","meshReprojected":"","meshTooClose":"","meshTooFar":"","meshUnderground":"","multipoint":"Click on the map to add points. Double-click to complete.","point":"Click on the map to add a point.","polygonOneVertex":"Click on the map to continue drawing.","polygonClickOneVertex":"Click on the map to finish drawing.","polygonTwoVertices":"Double-click on the map to complete.","polygonZeroVertices":"Click on the map to start drawing.","polygonZeroVerticesHybrid":"Click or drag on the map to start drawing.","polylineOneVertex":"Double-click on the map to complete.","polylineZeroVertices":"Click on the map to start drawing.","freehandStart":"Click and drag to draw.","freehandEnd":"Release to finish.","noTool":"Select a tool to start drawing.","shapeStartHybrid":"Click to place or click and drag to draw.","shapeEndHybrid":"Release to finish.","shapeStartClick":"Click to start drawing.","shapeEndClick":"Click again to finish."},"helpMessages3d":{"select":"Click in the scene to select a feature.","mesh":"Click in the scene to place the model.","meshReprojected":"The model's spatial reference differs from the layer's. The model's position was approximately adjusted, which may result in some loss of precision.","meshTooClose":"Zoom out to view the full model.","meshTooFar":"Zoom in to view the model.","meshUnderground":"The model is underground.","multipoint":"","point":"Click in the scene to add a point.","polygonOneVertex":"Click in the scene to continue drawing.","polygonClickOneVertex":"Click in the scene to complete.","polygonTwoVertices":"Double-click in the scene to complete.","polygonZeroVertices":"Click in the scene to start drawing.","polygonZeroVerticesHybrid":"Click or drag in the scene to start drawing.","polylineOneVertex":"Double-click in the scene to complete.","polylineZeroVertices":"Click in the scene to start drawing.","freehandStart":"Click and drag to draw.","freehandEnd":"Release to finish.","noTool":"Select a tool to start drawing.","shapeStartHybrid":"Click to place or click and drag to draw.","shapeEndHybrid":"Release to finish.","shapeStartClick":"Click to start drawing.","shapeEndClick":"Click again to finish."},"ignore":"Ignore","keepAttachment":"Keep attachment","keepAssociation":"Keep association","cancelAssociationEditWarning":"Unsaved changes to this associated feature will be lost.","modelUploads":{"pending":{"title":"Uploading...","description":"The model is being uploaded and prepared for display in the scene."},"success":{"title":"Upload successful"},"error":{"title":"Upload failed","uploadNew":"Upload new file","messages":{"conversionFailed":"An error occurred while converting the model.","default":"An error occurred while uploading the model.","multipleModels":"Upload only one model at a time.","noModel":"No supported model found.","loadFailed":"An error occurred while loading the uploaded model.","resourceRequestFailed":"An error occurred while fetching a linked resource.","unsupportedFeature":"The model uses unsupported glTF features or extensions."}},"cancelUploadPrompt":{"title":"Cancel upload","message":"The current upload and conversion will be canceled and the model will be discarded.","noLabel":"Continue upload","yesLabel":"Cancel upload"},"cancelPlacementPrompt":{"title":"Discard model","message":"The uploaded model will be discarded.","noLabel":"Keep model","yesLabel":"Discard model"}},"multipleFeaturesTemplate":"Multiple features ({total})","noCompatibleFeatures":"No features on this layer are compatible with network rules.","noEditableLayers":"No editable layers found.","ownerAdminNotice":"Editing is restricted but you have privileges to edit this layer.","retry":"Retry","selectFeature":"Select feature","selectTemplate":"Select feature type","sharedTemplateRelationshipNotFoundError":"Could not create features. Related record could not be created.","widgetLabel":"Editor","zoomTo":"Zoom to","batchEditing":{"editCount":"Edit ({count})","editThisFeature":"Edit this feature","editTheseFeatures":"Edit these features","featuresCount":"Features ({count})","reduceNumberOfFeatures":"Reduce the number of features to {number} or less to enable batch editing.","selectOneLayer":"Select features from a single layer to enable batch editing."},"singleFeature":{"create":"Create","delete":"Delete","deleteWarningMessage":"This feature will be permanently removed.","deleteWarningTitle":"Delete feature","editPanelTitle":"Edit feature","formFieldUpdateError":"Feature cannot be updated. There is an issue with the form.","keep":"Keep feature","update":"Update"},"multiFeature":{"create":"Create ({count})","delete":"Delete ({count})","deleteWarningMessage":"These features will be permanently removed.","deleteWarningTitle":"Delete features","editPanelTitle":"Edit features","formFieldUpdateError":"Features cannot be updated. There is an issue with the form.","keep":"Keep features","update":"Update ({count})"}}
1
+ {"addAttachment":"Add attachment","associations":{"addContent":"Add Content","addAttachment":"Add Attachment","addStructure":"Add Structure","addContainer":"Add Container","addConnectivity":"Add Connection"},"attachments":"Attachments","cancelEditTitle":"Discard edits","cancelEditWarningMessage":"Unsaved changes will be lost.","cancelRequestTitle":"Cancel workflow","cancelRequestWarningMessage":"A request has been made to cancel this workflow.","clearAreaOfInterest":"Clear area of interest","clickToFinishTemplate":"Click {button} to finish.","continueEditing":"Continue editing","createAllFeaturesTemplate":"Create all","createFeatures":"Create features","createFeaturesTimeCompleteWarning":"An operation is taking long than expected.","createFeaturesSelectionList":{"featureNotReadyToSubmit":"Needs attention","featureReadyToSubmit":"Ready to create","discard":"Discard feature","heading":"Unsaved features"},"createFeaturesSubTemplate":"1 of {numFeatures}","curveEditingWarning":"One or more layers is set to allow true curve updates by true curve clients. Editor is not a true curve client.","deleteAttachmentWarningMessage":"This attachment will be permanently removed.","deleteAttachmentWarningTitle":"Delete attachment","deleteAssociationTitle":"Delete association","deleteAssociationMessage":"The association with this feature will be deleted. The feature will remain.","discardEdits":"Discard edits","editAttachment":"Manage attachment","editFeatures":"Edit features","editFeaturesList":"Features","errorWarningEditsNotApplied":"An error occurred during editing. The edits have not been applied.","errorWarningMessageTemplate":"Edits could not be saved: {errorMessage}","errorWarningTitle":"Something went wrong","formFieldCreateError":"Features cannot be created. There is an issue with the form.","formFieldUnsupportedCreateError":"Features cannot be created. Layer contains unsupported fields.","formFieldUnsupportedUpdateError":"Feature cannot be updated. Layer contains unsupported fields.","helpMessages2d":{"select":"Click on the map to select a feature.","mesh":"","meshGeoreferenced":"","meshReprojected":"","meshTooClose":"","meshTooFar":"","meshUnderground":"","multipoint":"Click on the map to add points. Double-click to complete.","point":"Click on the map to add a point.","polygonOneVertex":"Click on the map to continue drawing.","polygonClickOneVertex":"Click on the map to finish drawing.","polygonTwoVertices":"Double-click on the map to complete.","polygonZeroVertices":"Click on the map to start drawing.","polygonZeroVerticesHybrid":"Click or drag on the map to start drawing.","polylineOneVertex":"Double-click on the map to complete.","polylineZeroVertices":"Click on the map to start drawing.","freehandStart":"Click and drag to draw.","freehandEnd":"Release to finish.","noTool":"Select a tool to start drawing.","shapeStartHybrid":"Click to place or click and drag to draw.","shapeEndHybrid":"Release to finish.","shapeStartClick":"Click to start drawing.","shapeEndClick":"Click again to finish."},"helpMessages3d":{"select":"Click in the scene to select a feature.","mesh":"Click in the scene to place the model.","meshGeoreferenced":"The model contained georeferencing information and has been automatically placed in the scene.","meshReprojected":"The model contained georeferencing information, but the spatial reference did not match the layer. The model was only approximately placed, which may result in some loss of precision.","meshTooClose":"Zoom out to view the full model.","meshTooFar":"Zoom in to view the model.","meshUnderground":"The model is underground.","multipoint":"","point":"Click in the scene to add a point.","polygonOneVertex":"Click in the scene to continue drawing.","polygonClickOneVertex":"Click in the scene to complete.","polygonTwoVertices":"Double-click in the scene to complete.","polygonZeroVertices":"Click in the scene to start drawing.","polygonZeroVerticesHybrid":"Click or drag in the scene to start drawing.","polylineOneVertex":"Double-click in the scene to complete.","polylineZeroVertices":"Click in the scene to start drawing.","freehandStart":"Click and drag to draw.","freehandEnd":"Release to finish.","noTool":"Select a tool to start drawing.","shapeStartHybrid":"Click to place or click and drag to draw.","shapeEndHybrid":"Release to finish.","shapeStartClick":"Click to start drawing.","shapeEndClick":"Click again to finish."},"ignore":"Ignore","keepAttachment":"Keep attachment","keepAssociation":"Keep association","cancelAssociationEditWarning":"Unsaved changes to this associated feature will be lost.","modelUploads":{"pending":{"title":"Uploading...","description":"The model is being uploaded and prepared for display in the scene."},"success":{"title":"Upload successful"},"error":{"title":"Upload failed","uploadNew":"Upload new file","messages":{"conversionFailed":"An error occurred while converting the model.","default":"An error occurred while uploading the model.","multipleModels":"Upload only one model at a time.","noModel":"No supported model found.","loadFailed":"An error occurred while loading the uploaded model.","resourceRequestFailed":"An error occurred while fetching a linked resource.","unsupportedFeature":"The model uses unsupported glTF features or extensions."}},"cancelUploadPrompt":{"title":"Cancel upload","message":"The current upload and conversion will be canceled and the model will be discarded.","noLabel":"Continue upload","yesLabel":"Cancel upload"},"cancelPlacementPrompt":{"title":"Discard model","message":"The uploaded model will be discarded.","noLabel":"Keep model","yesLabel":"Discard model"}},"multipleFeaturesTemplate":"Multiple features ({total})","noCompatibleFeatures":"No features on this layer are compatible with network rules.","noEditableLayers":"No editable layers found.","ownerAdminNotice":"Editing is restricted but you have privileges to edit this layer.","retry":"Retry","selectFeature":"Select feature","selectTemplate":"Select feature type","sharedTemplateRelationshipNotFoundError":"Could not create features. Related record could not be created.","widgetLabel":"Editor","zoomTo":"Zoom to","batchEditing":{"editCount":"Edit ({count})","editThisFeature":"Edit this feature","editTheseFeatures":"Edit these features","featuresCount":"Features ({count})","reduceNumberOfFeatures":"Reduce the number of features to {number} or less to enable batch editing.","selectOneLayer":"Select features from a single layer to enable batch editing."},"singleFeature":{"create":"Create","delete":"Delete","deleteWarningMessage":"This feature will be permanently removed.","deleteWarningTitle":"Delete feature","editPanelTitle":"Edit feature","formFieldUpdateError":"Feature cannot be updated. There is an issue with the form.","keep":"Keep feature","update":"Update"},"multiFeature":{"create":"Create ({count})","delete":"Delete ({count})","deleteWarningMessage":"These features will be permanently removed.","deleteWarningTitle":"Delete features","editPanelTitle":"Edit features","formFieldUpdateError":"Features cannot be updated. There is an issue with the form.","keep":"Keep features","update":"Update ({count})"}}
@@ -1 +1 @@
1
- {"addAttachment":"Add attachment","associations":{"addContent":"Add Content","addAttachment":"Add Attachment","addStructure":"Add Structure","addContainer":"Add Container","addConnectivity":"Add Connection"},"attachments":"Attachments","cancelEditTitle":"Discard edits","cancelEditWarningMessage":"Unsaved changes will be lost.","cancelRequestTitle":"Cancel workflow","cancelRequestWarningMessage":"A request has been made to cancel this workflow.","clearAreaOfInterest":"Clear area of interest","clickToFinishTemplate":"Click {button} to finish.","continueEditing":"Continue editing","createAllFeaturesTemplate":"Create all","createFeatures":"Create features","createFeaturesTimeCompleteWarning":"An operation is taking long than expected.","createFeaturesSelectionList":{"featureNotReadyToSubmit":"Needs attention","featureReadyToSubmit":"Ready to create","discard":"Discard feature","heading":"Unsaved features"},"createFeaturesSubTemplate":"1 of {numFeatures}","curveEditingWarning":"One or more layers is set to allow true curve updates by true curve clients. Editor is not a true curve client.","deleteAttachmentWarningMessage":"This attachment will be permanently removed.","deleteAttachmentWarningTitle":"Delete attachment","deleteAssociationTitle":"Delete association","deleteAssociationMessage":"The association with this feature will be deleted. The feature will remain.","discardEdits":"Discard edits","editAttachment":"Manage attachment","editFeatures":"Edit features","editFeaturesList":"Features","errorWarningEditsNotApplied":"An error occurred during editing. The edits have not been applied.","errorWarningMessageTemplate":"Edits could not be saved: {errorMessage}","errorWarningTitle":"Something went wrong","formFieldCreateError":"Features cannot be created. There is an issue with the form.","formFieldUnsupportedCreateError":"Features cannot be created. Layer contains unsupported fields.","formFieldUnsupportedUpdateError":"Feature cannot be updated. Layer contains unsupported fields.","helpMessages2d":{"select":"Click on the map to select a feature.","mesh":"","meshReprojected":"","meshTooClose":"","meshTooFar":"","meshUnderground":"","multipoint":"Click on the map to add points. Double-click to complete.","point":"Click on the map to add a point.","polygonOneVertex":"Click on the map to continue drawing.","polygonClickOneVertex":"Click on the map to finish drawing.","polygonTwoVertices":"Double-click on the map to complete.","polygonZeroVertices":"Click on the map to start drawing.","polygonZeroVerticesHybrid":"Click or drag on the map to start drawing.","polylineOneVertex":"Double-click on the map to complete.","polylineZeroVertices":"Click on the map to start drawing.","freehandStart":"Click and drag to draw.","freehandEnd":"Release to finish.","noTool":"Select a tool to start drawing.","shapeStartHybrid":"Click to place or click and drag to draw.","shapeEndHybrid":"Release to finish.","shapeStartClick":"Click to start drawing.","shapeEndClick":"Click again to finish."},"helpMessages3d":{"select":"Click in the scene to select a feature.","mesh":"Click in the scene to place the model.","meshReprojected":"The model's spatial reference differs from the layer's. The model's position was approximately adjusted, which may result in some loss of precision.","meshTooClose":"Zoom out to view the full model.","meshTooFar":"Zoom in to view the model.","meshUnderground":"The model is underground.","multipoint":"","point":"Click in the scene to add a point.","polygonOneVertex":"Click in the scene to continue drawing.","polygonClickOneVertex":"Click in the scene to complete.","polygonTwoVertices":"Double-click in the scene to complete.","polygonZeroVertices":"Click in the scene to start drawing.","polygonZeroVerticesHybrid":"Click or drag in the scene to start drawing.","polylineOneVertex":"Double-click in the scene to complete.","polylineZeroVertices":"Click in the scene to start drawing.","freehandStart":"Click and drag to draw.","freehandEnd":"Release to finish.","noTool":"Select a tool to start drawing.","shapeStartHybrid":"Click to place or click and drag to draw.","shapeEndHybrid":"Release to finish.","shapeStartClick":"Click to start drawing.","shapeEndClick":"Click again to finish."},"ignore":"Ignore","keepAttachment":"Keep attachment","keepAssociation":"Keep association","cancelAssociationEditWarning":"Unsaved changes to this associated feature will be lost.","modelUploads":{"pending":{"title":"Uploading...","description":"The model is being uploaded and prepared for display in the scene."},"success":{"title":"Upload successful"},"error":{"title":"Upload failed","uploadNew":"Upload new file","messages":{"conversionFailed":"An error occurred while converting the model.","default":"An error occurred while uploading the model.","multipleModels":"Upload only one model at a time.","noModel":"No supported model found.","loadFailed":"An error occurred while loading the uploaded model.","resourceRequestFailed":"An error occurred while fetching a linked resource.","unsupportedFeature":"The model uses unsupported glTF features or extensions."}},"cancelUploadPrompt":{"title":"Cancel upload","message":"The current upload and conversion will be canceled and the model will be discarded.","noLabel":"Continue upload","yesLabel":"Cancel upload"},"cancelPlacementPrompt":{"title":"Discard model","message":"The uploaded model will be discarded.","noLabel":"Keep model","yesLabel":"Discard model"}},"multipleFeaturesTemplate":"Multiple features ({total})","noCompatibleFeatures":"No features on this layer are compatible with network rules.","noEditableLayers":"No editable layers found.","ownerAdminNotice":"Editing is restricted but you have privileges to edit this layer.","retry":"Retry","selectFeature":"Select feature","selectTemplate":"Select feature type","sharedTemplateRelationshipNotFoundError":"Could not create features. Related record could not be created.","widgetLabel":"Editor","zoomTo":"Zoom to","batchEditing":{"editCount":"Edit ({count})","editThisFeature":"Edit this feature","editTheseFeatures":"Edit these features","featuresCount":"Features ({count})","reduceNumberOfFeatures":"Reduce the number of features to {number} or less to enable batch editing.","selectOneLayer":"Select features from a single layer to enable batch editing."},"singleFeature":{"create":"Create","delete":"Delete","deleteWarningMessage":"This feature will be permanently removed.","deleteWarningTitle":"Delete feature","editPanelTitle":"Edit feature","formFieldUpdateError":"Feature cannot be updated. There is an issue with the form.","keep":"Keep feature","update":"Update"},"multiFeature":{"create":"Create ({count})","delete":"Delete ({count})","deleteWarningMessage":"These features will be permanently removed.","deleteWarningTitle":"Delete features","editPanelTitle":"Edit features","formFieldUpdateError":"Features cannot be updated. There is an issue with the form.","keep":"Keep features","update":"Update ({count})"}}
1
+ {"addAttachment":"Add attachment","associations":{"addContent":"Add Content","addAttachment":"Add Attachment","addStructure":"Add Structure","addContainer":"Add Container","addConnectivity":"Add Connection"},"attachments":"Attachments","cancelEditTitle":"Discard edits","cancelEditWarningMessage":"Unsaved changes will be lost.","cancelRequestTitle":"Cancel workflow","cancelRequestWarningMessage":"A request has been made to cancel this workflow.","clearAreaOfInterest":"Clear area of interest","clickToFinishTemplate":"Click {button} to finish.","continueEditing":"Continue editing","createAllFeaturesTemplate":"Create all","createFeatures":"Create features","createFeaturesTimeCompleteWarning":"An operation is taking long than expected.","createFeaturesSelectionList":{"featureNotReadyToSubmit":"Needs attention","featureReadyToSubmit":"Ready to create","discard":"Discard feature","heading":"Unsaved features"},"createFeaturesSubTemplate":"1 of {numFeatures}","curveEditingWarning":"One or more layers is set to allow true curve updates by true curve clients. Editor is not a true curve client.","deleteAttachmentWarningMessage":"This attachment will be permanently removed.","deleteAttachmentWarningTitle":"Delete attachment","deleteAssociationTitle":"Delete association","deleteAssociationMessage":"The association with this feature will be deleted. The feature will remain.","discardEdits":"Discard edits","editAttachment":"Manage attachment","editFeatures":"Edit features","editFeaturesList":"Features","errorWarningEditsNotApplied":"An error occurred during editing. The edits have not been applied.","errorWarningMessageTemplate":"Edits could not be saved: {errorMessage}","errorWarningTitle":"Something went wrong","formFieldCreateError":"Features cannot be created. There is an issue with the form.","formFieldUnsupportedCreateError":"Features cannot be created. Layer contains unsupported fields.","formFieldUnsupportedUpdateError":"Feature cannot be updated. Layer contains unsupported fields.","helpMessages2d":{"select":"Click on the map to select a feature.","mesh":"","meshGeoreferenced":"","meshReprojected":"","meshTooClose":"","meshTooFar":"","meshUnderground":"","multipoint":"Click on the map to add points. Double-click to complete.","point":"Click on the map to add a point.","polygonOneVertex":"Click on the map to continue drawing.","polygonClickOneVertex":"Click on the map to finish drawing.","polygonTwoVertices":"Double-click on the map to complete.","polygonZeroVertices":"Click on the map to start drawing.","polygonZeroVerticesHybrid":"Click or drag on the map to start drawing.","polylineOneVertex":"Double-click on the map to complete.","polylineZeroVertices":"Click on the map to start drawing.","freehandStart":"Click and drag to draw.","freehandEnd":"Release to finish.","noTool":"Select a tool to start drawing.","shapeStartHybrid":"Click to place or click and drag to draw.","shapeEndHybrid":"Release to finish.","shapeStartClick":"Click to start drawing.","shapeEndClick":"Click again to finish."},"helpMessages3d":{"select":"Click in the scene to select a feature.","mesh":"Click in the scene to place the model.","meshGeoreferenced":"The model contained georeferencing information and has been automatically placed in the scene.","meshReprojected":"The model's spatial reference differs from the layer's. The model's position was approximately adjusted, which may result in some loss of precision.","meshTooClose":"Zoom out to view the full model.","meshTooFar":"Zoom in to view the model.","meshUnderground":"The model is underground.","multipoint":"","point":"Click in the scene to add a point.","polygonOneVertex":"Click in the scene to continue drawing.","polygonClickOneVertex":"Click in the scene to complete.","polygonTwoVertices":"Double-click in the scene to complete.","polygonZeroVertices":"Click in the scene to start drawing.","polygonZeroVerticesHybrid":"Click or drag in the scene to start drawing.","polylineOneVertex":"Double-click in the scene to complete.","polylineZeroVertices":"Click in the scene to start drawing.","freehandStart":"Click and drag to draw.","freehandEnd":"Release to finish.","noTool":"Select a tool to start drawing.","shapeStartHybrid":"Click to place or click and drag to draw.","shapeEndHybrid":"Release to finish.","shapeStartClick":"Click to start drawing.","shapeEndClick":"Click again to finish."},"ignore":"Ignore","keepAttachment":"Keep attachment","keepAssociation":"Keep association","cancelAssociationEditWarning":"Unsaved changes to this associated feature will be lost.","modelUploads":{"pending":{"title":"Uploading...","description":"The model is being uploaded and prepared for display in the scene."},"success":{"title":"Upload successful"},"error":{"title":"Upload failed","uploadNew":"Upload new file","messages":{"conversionFailed":"An error occurred while converting the model.","default":"An error occurred while uploading the model.","multipleModels":"Upload only one model at a time.","noModel":"No supported model found.","loadFailed":"An error occurred while loading the uploaded model.","resourceRequestFailed":"An error occurred while fetching a linked resource.","unsupportedFeature":"The model uses unsupported glTF features or extensions."}},"cancelUploadPrompt":{"title":"Cancel upload","message":"The current upload and conversion will be canceled and the model will be discarded.","noLabel":"Continue upload","yesLabel":"Cancel upload"},"cancelPlacementPrompt":{"title":"Discard model","message":"The uploaded model will be discarded.","noLabel":"Keep model","yesLabel":"Discard model"}},"multipleFeaturesTemplate":"Multiple features ({total})","noCompatibleFeatures":"No features on this layer are compatible with network rules.","noEditableLayers":"No editable layers found.","ownerAdminNotice":"Editing is restricted but you have privileges to edit this layer.","retry":"Retry","selectFeature":"Select feature","selectTemplate":"Select feature type","sharedTemplateRelationshipNotFoundError":"Could not create features. Related record could not be created.","widgetLabel":"Editor","zoomTo":"Zoom to","batchEditing":{"editCount":"Edit ({count})","editThisFeature":"Edit this feature","editTheseFeatures":"Edit these features","featuresCount":"Features ({count})","reduceNumberOfFeatures":"Reduce the number of features to {number} or less to enable batch editing.","selectOneLayer":"Select features from a single layer to enable batch editing."},"singleFeature":{"create":"Create","delete":"Delete","deleteWarningMessage":"This feature will be permanently removed.","deleteWarningTitle":"Delete feature","editPanelTitle":"Edit feature","formFieldUpdateError":"Feature cannot be updated. There is an issue with the form.","keep":"Keep feature","update":"Update"},"multiFeature":{"create":"Create ({count})","delete":"Delete ({count})","deleteWarningMessage":"These features will be permanently removed.","deleteWarningTitle":"Delete features","editPanelTitle":"Edit features","formFieldUpdateError":"Features cannot be updated. There is an issue with the form.","keep":"Keep features","update":"Update ({count})"}}
package/config.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.34/esri/copyright.txt for details.
4
4
  */
5
- import"./core/has.js";import{deepMerge as e}from"./core/object.js";const s={apiKey:void 0,apiKeys:{scopes:[]},applicationName:"",applicationUrl:globalThis.location?.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",userPrivilegesApplied:!0,portalUrl:"https://www.arcgis.com",respectPrefersReducedMotion:!0,routeServiceUrl:"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{crossOriginNoCorsDomains:null,httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],internalInterceptors:[],maxUrlLength:2e3,priority:"high",proxyRules:[],proxyUrl:null,timeout:62e3,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(s,globalThis.esriConfig,!0),delete s.has),!s.assetsPath){{const e="4.34.0-next.86";s.assetsPath=`https://cdn.jsdelivr.net/npm/@arcgis/core@${e}/assets`}s.defaultAssetsPath=s.assetsPath}export{s as default};
5
+ import"./core/has.js";import{deepMerge as e}from"./core/object.js";const s={apiKey:void 0,apiKeys:{scopes:[]},applicationName:"",applicationUrl:globalThis.location?.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",userPrivilegesApplied:!0,portalUrl:"https://www.arcgis.com",respectPrefersReducedMotion:!0,routeServiceUrl:"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{crossOriginNoCorsDomains:null,httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],internalInterceptors:[],maxUrlLength:2e3,priority:"high",proxyRules:[],proxyUrl:null,timeout:62e3,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(s,globalThis.esriConfig,!0),delete s.has),!s.assetsPath){{const e="4.34.0-next.87";s.assetsPath=`https://cdn.jsdelivr.net/npm/@arcgis/core@${e}/assets`}s.defaultAssetsPath=s.assetsPath}export{s 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../config.js";import{id as r}from"../kernel.js";import s from"../request.js";import i from"../core/Error.js";import{Evented as o,EventedAccessor as n}from"../core/Evented.js";import{on as a}from"../core/events.js";import{fixJson as h}from"../core/lang.js";import{getDeepValue as l}from"../core/object.js";import{createResolver as c,onAbort as d,isAborted as u}from"../core/promiseUtils.js";import{urlToObject as p,hasSameOrigin as _,Url as f,queryToObject as g,base64UrlEncode as m,objectToQuery as v,normalize as S,getProxyRule as w,makeAbsolute as I,addQueryParameters as k}from"../core/urlUtils.js";import{property as A}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as y}from"../core/accessorSupport/decorators/subclass.js";import U from"./IdentityModal.js";import T from"./OAuthCredential.js";import x from"./OAuthInfo.js";import O from"./ServerInfo.js";import{isSecureProxyService as P,normalizeArcGISOnlineOrgDomain as R}from"../portal/support/urlUtils.js";const C={},D=e=>{const t=new f(e.owningSystemUrl).host,r=new f(e.server).host,s=/.+\.arcgis\.com$/i;return s.test(t)&&s.test(r)},b=(e,t)=>!!(D(e)&&t&&t.some(t=>t.test(e.server)));let q=null,j=null;try{q=window.localStorage,j=window.sessionStorage}catch{}class E extends o{constructor(){super(),this._portalConfig=globalThis.esriGeowConfig,this.serverInfos=[],this.oAuthInfos=[],this.credentials=[],this._soReqs=[],this._xoReqs=[],this._portals=[],this._defaultOAuthInfo=null,this._defaultTokenValidity=60,this.dialog=null,this.tokenValidity=null,this.normalizeWebTierAuth=!1,this._appOrigin="null"!==window.origin?window.origin:window.location.origin,this._appUrlObj=p(window.location.href),this._busy=null,this._rejectOnPersistedPageShow=!1,this._oAuthLocationParams=null,this._gwTokenUrl="/sharing/rest/generateToken",this._agsRest="/rest/services",this._agsPortal=/\/sharing(\/|$)/i,this._agsAdmin=/(https?:\/\/[^/]+\/[^/]+)\/admin\/?(\/.*)?$/i,this._adminSvcs=/\/rest\/admin\/services(\/|$)/i,this._gwDomains=[{regex:/^https?:\/\/www\.arcgis\.com/i,customBaseUrl:"maps.arcgis.com",tokenServiceUrl:"https://www.arcgis.com/sharing/rest/generateToken"},{regex:/^https?:\/\/(?:dev|[a-z\d-]+\.mapsdev)\.arcgis\.com/i,customBaseUrl:"mapsdev.arcgis.com",tokenServiceUrl:"https://dev.arcgis.com/sharing/rest/generateToken"},{regex:/^https?:\/\/(?:devext|[a-z\d-]+\.mapsdevext)\.arcgis\.com/i,customBaseUrl:"mapsdevext.arcgis.com",tokenServiceUrl:"https://devext.arcgis.com/sharing/rest/generateToken"},{regex:/^https?:\/\/(?:qaext|[a-z\d-]+\.mapsqa)\.arcgis\.com/i,customBaseUrl:"mapsqa.arcgis.com",tokenServiceUrl:"https://qaext.arcgis.com/sharing/rest/generateToken"},{regex:/^https?:\/\/[a-z\d-]+\.maps\.arcgis\.com/i,customBaseUrl:"maps.arcgis.com",tokenServiceUrl:"https://www.arcgis.com/sharing/rest/generateToken"}],this._legacyFed=[],this._regexSDirUrl=/http.+\/rest\/services\/?/gi,this._regexServerType=/(\/(FeatureServer|GPServer|GeoDataServer|GeocodeServer|GeoenrichmentServer|GeometryServer|GlobeServer|ImageServer|KnowledgeGraphServer|MapServer|MissionServer|MobileServer|NAServer|NetworkDiagramServer|OGCFeatureServer|ParcelFabricServer|RelationalCatalogServer|SceneServer|StreamServer|UtilityNetworkServer|ValidationServer|VectorTileServer|VersionManagementServer|VideoServer)).*/gi,this._gwUser=/http.+\/users\/([^/]+).*/i,this._gwItem=/http.+\/items\/([^/]+).*/i,this._gwGroup=/http.+\/groups\/([^/]+).*/i,this._rePortalTokenSvc=/\/sharing(\/rest)?\/generatetoken/i,this._createDefaultOAuthInfo=!0,this._hasTestedIfAppIsOnPortal=!1,this._getPlatformSelfError=null,this._getOAuthLocationParams(),window.addEventListener("pageshow",e=>{this._pageShowHandler(e)})}registerServers(e){const t=this.serverInfos;t?(e=e.filter(e=>!this.findServerInfo(e.server)),this.serverInfos=t.concat(e)):this.serverInfos=e,e.forEach(e=>{e.owningSystemUrl&&this._portals.push(e.owningSystemUrl),e.hasPortal&&this._portals.push(e.server)})}registerOAuthInfos(e){const t=this.oAuthInfos;if(t){for(const r of e){const e=this.findOAuthInfo(r.portalUrl);e&&t.splice(t.indexOf(e),1)}this.oAuthInfos=t.concat(e)}else this.oAuthInfos=e}registerToken(e){e={...e};const t=this._sanitizeUrl(e.server),r=this._isServerRsrc(t);let s,i=this.findServerInfo(t),o=!0;i||(i=new O,i.server=this._getServerInstanceRoot(t),r?i.hasServer=!0:(i.tokenServiceUrl=this._getTokenSvcUrl(t),i.hasPortal=!0),this.registerServers([i])),s=this._findCredential(t),s?(delete e.server,Object.assign(s,e),o=!1):(s=new L({userId:e.userId,server:i.server??void 0,token:e.token,expires:e.expires,ssl:e.ssl,scope:r?"server":"portal"}),s.resources=[t],this.credentials.push(s)),s.emitTokenChange(!1),o||s.refreshServerTokens()}toJSON(){return h({serverInfos:this.serverInfos.map(e=>e.toJSON()),oAuthInfos:this.oAuthInfos.map(e=>e.toJSON()),credentials:this.credentials.map(e=>e.toJSON())})}initialize(e){if(!e)return;"string"==typeof e&&(e=JSON.parse(e));const t=e.serverInfos,r=e.oAuthInfos,s=e.credentials;if(t){const e=[];t.forEach(t=>{t.server&&t.tokenServiceUrl&&e.push(t.declaredClass?t:new O(t))}),e.length&&this.registerServers(e)}if(r){const e=[];r.forEach(t=>{t.appId&&e.push(t.declaredClass?t:new x(t))}),e.length&&this.registerOAuthInfos(e)}s&&s.forEach(e=>{e.server&&e.token&&e.expires&&e.expires>Date.now()&&((e=e.declaredClass?e:new L(e)).emitTokenChange(),this.credentials.push(e))})}findServerInfo(e){let t;e=this._sanitizeUrl(e);for(const r of this.serverInfos)if(this._hasSameServerInstance(r.server,e)){t=r;break}return t}findOAuthInfo(e){let t;e=this._sanitizeUrl(e);for(const r of this.oAuthInfos)if(this._hasSameServerInstance(r.portalUrl,e)){t=r;break}return t}findCredential(e,t){if(!e)return;let r;e=this._sanitizeUrl(e);const s=this._isServerRsrc(e)?"server":"portal";if(t){for(const i of this.credentials)if(this._hasSameServerInstance(i.server,e)&&t===i.userId&&i.scope===s){r=i;break}}else for(const i of this.credentials)if(this._hasSameServerInstance(i.server,e)&&-1!==this._getIdenticalSvcIdx(e,i)&&i.scope===s){r=i;break}return r}getCredential(e,t){let r,s=!1,o=!0;t&&(s=!(!t.token&&!t.credential),r=t.error,o=!1!==t.prompt),t={...t},e=this._sanitizeUrl(e);const n=new AbortController,a=c();if(t.signal&&d(t.signal,()=>{n.abort()}),d(n,()=>{a.reject(new i("identity-manager:user-aborted","ABORTED"))}),u(n))return a.promise;t.signal=n.signal;const h=this._isAdminResource(e),l=s?this.findCredential(e):null;let p;if(l&&498===r?.details?.httpStatus)l.destroy();else if(l)return p=new i("identity-manager:not-authorized","You are currently signed in as: '"+l.userId+"'. You do not have access to this resource: "+e,{error:r}),a.reject(p),a.promise;const f=this._findCredential(e,t);if(f)return a.resolve(f),a.promise;let g=this.findServerInfo(e);if(g)!g.hasPortal&&g.server&&g.owningSystemUrl&&this._hasSameServerInstance(g.server,g.owningSystemUrl)&&(g.hasPortal=!0),!g.hasServer&&this._isServerRsrc(e)&&(g._restInfoPms=this._getTokenSvcUrl(e),g.hasServer=!0);else{const t=this._getTokenSvcUrl(e);if(!t)return p=new i("identity-manager:unknown-resource","Unknown resource - could not find token service endpoint."),a.reject(p),a.promise;g=new O,g.server=this._getServerInstanceRoot(e),"string"==typeof t?(g.tokenServiceUrl=t,g.hasPortal=!0):(g._restInfoPms=t,g.hasServer=!0),this.registerServers([g])}return g.hasPortal&&void 0===g._selfReq&&(o||_(g.tokenServiceUrl,this._appOrigin)||this._gwDomains.some(e=>e.tokenServiceUrl===g.tokenServiceUrl))&&(g._selfReq={owningTenant:t?.owningTenant,selfDfd:this._getPortalSelf(g.tokenServiceUrl.replace(this._rePortalTokenSvc,"/sharing/rest/portals/self"),e)}),this._enqueue(e,g,t,a,h)}getResourceName(e){return this._isRESTService(e)?e.replace(this._regexSDirUrl,"").replace(this._regexServerType,"")||"":this._gwUser.test(e)&&e.replace(this._gwUser,"$1")||this._gwItem.test(e)&&e.replace(this._gwItem,"$1")||this._gwGroup.test(e)&&e.replace(this._gwGroup,"$1")||""}generateToken(e,t,r){const o=this._rePortalTokenSvc.test(e.tokenServiceUrl),n=new f(this._appOrigin),a=e.shortLivedTokenValidity;let h,l,c,d,u,p,g,m;t&&(m=this.tokenValidity||a||this._defaultTokenValidity,m>a&&a>0&&(m=a)),r&&(h=r.isAdmin,l=r.serverUrl,c=r.token,p=r.signal,g=r.ssl,e.customParameters=r.customParameters),h?d=e.adminTokenServiceUrl:(d=e.tokenServiceUrl,u=new f(d.toLowerCase()),e.webTierAuth&&r?.serverUrl&&!g&&"http"===n.scheme&&(_(n.uri,d,!0)||"https"===u.scheme&&n.host===u.host&&"7080"===n.port&&"7443"===u.port)&&(d=d.replace(/^https:/i,"http:").replace(/:7443/i,":7080")));const v={query:{request:"getToken",username:t?.username,password:t?.password,serverUrl:l,token:c,expiration:m,referer:h||o?this._appOrigin:null,client:h?"referer":null,f:"json",...e.customParameters},method:"post",authMode:"anonymous",useProxy:this._useProxy(e,r),signal:p,...r?.ioArgs};o||(v.withCredentials=!1);return s(d,v).then(r=>{const s=r.data;if(!s?.token)return new i("identity-manager:authentication-failed","Unable to generate token");const o=e.server;return C[o]||(C[o]={}),t&&(C[o][t.username]=t.password),s.validity=m,s})}isBusy(){return!!this._busy}async checkSignInStatus(e){return(await this.checkAppAccess(e,"")).credential}checkAppAccess(e,t,r){let o=!1;return this.getCredential(e,{prompt:!1}).then(n=>{let a;const h={f:"json"};if("portal"===n.scope)if(t&&(this._doPortalSignIn(e)||r?.force))a=n.server+"/sharing/rest/oauth2/validateAppAccess",h.client_id=t;else{if(!n.token)return{credential:n};a=n.server+"/sharing/rest"}else{if(!n.token)return{credential:n};a=n.server+"/rest/services"}return n.token&&(h.token=n.token),s(a,{query:h,authMode:"anonymous"}).then(e=>{if(!1===e.data.valid)throw new i("identity-manager:not-authorized",`You are currently signed in as: '${n.userId}'.`,e.data);return o=!!e.data.viewOnlyUserTypeApp,{credential:n}}).catch(e=>{if("identity-manager:not-authorized"===e.name)throw e;const t=e.details?.httpStatus;if(498===t)throw n.destroy(),new i("identity-manager:not-authenticated","User is not signed in.");if(400===t)throw new i("identity-manager:invalid-request","Bad request");return{credential:n}})}).then(e=>({credential:e.credential,viewOnly:o}))}setOAuthResponseHash(e){e&&(e.startsWith("#")&&(e=e.slice(1)),this._processOAuthPopupParams(g(e)))}setOAuthRedirectionHandler(e){this._oAuthRedirectFunc=e}setProtocolErrorHandler(e){this._protocolFunc=e}signIn(e,t,r={}){const s=c(),o=()=>{h?.remove(),l?.remove(),this.dialog?.destroy(),this.dialog=h=l=null},n=()=>{o(),this._oAuthDfd=null,s.reject(new i("identity-manager:user-aborted","ABORTED"))};r.signal&&d(r.signal,()=>{n()});const a=new U({open:!0,resource:this.getResourceName(e),server:t.server});this.dialog=a,this.emit("dialog-create");let h=a.on("cancel",n),l=a.on("submit",e=>{this.generateToken(t,e,{isAdmin:r.isAdmin,signal:r.signal}).then(i=>{o();const n=new L({userId:e.username,server:t.server??void 0,token:i.token,expires:null!=i.expires?Number(i.expires):null,ssl:!!i.ssl,isAdmin:r.isAdmin,validity:i.validity});s.resolve(n)}).catch(e=>{a.error=e,a.signingIn=!1})});return s.promise}oAuthSignIn(e,t,r,s){this._oAuthDfd=c();const o=this._oAuthDfd;let n;s?.signal&&d(s.signal,()=>{const e=this._oAuthDfd&&this._oAuthDfd.oAuthWin_;e&&!e.closed?e.close():this.dialog&&u()}),o.resUrl_=e,o.sinfo_=t,o.oinfo_=r;const a=r._oAuthCred;if(a.storage&&("authorization-code"===r.flowType||"auto"===r.flowType&&t.currentVersion>=8.4)){let e=crypto.getRandomValues(new Uint8Array(32));n=m(e),a.codeVerifier=n,e=crypto.getRandomValues(new Uint8Array(32)),a.stateUID=m(e),a.save()||(a.codeVerifier=n=null)}else a.codeVerifier=null;let h,l;this._getCodeChallenge(n).then(i=>{const o=!s||!1!==s.oAuthPopupConfirmation;if(!r.popup||!o)return void this._doOAuthSignIn(e,t,r,i);const n=new U({oAuthPrompt:!0,server:t.server,open:!0});this.dialog=n,this.emit("dialog-create"),h=n.on("cancel",u),l=n.on("submit",()=>{p(),this._doOAuthSignIn(e,t,r,i)})});const u=()=>{p(),this._oAuthDfd=null,o.reject(new i("identity-manager:user-aborted","ABORTED"))},p=()=>{h?.remove(),l?.remove(),this.dialog?.destroy(),this.dialog=null};return o.promise}destroyCredentials(){if(this.credentials){this.credentials.slice().forEach(e=>{e.destroy()})}this.emit("credentials-destroy")}enablePostMessageAuth(e="https://www.arcgis.com/sharing/rest"){this._postMessageAuthHandle&&this._postMessageAuthHandle.remove(),this._postMessageAuthHandle=a(window,"message",t=>{if((t.origin===this._appOrigin||t.origin.endsWith(".arcgis.com"))&&"arcgis:auth:requestCredential"===t.data?.type){const r=t.source;this.getCredential(e).then(e=>{r.postMessage({type:"arcgis:auth:credential",credential:{expires:e.expires,server:e.server,ssl:e.ssl,token:e.token,userId:e.userId}},t.origin)}).catch(e=>{r.postMessage({type:"arcgis:auth:error",error:{name:e.name,message:e.message}},t.origin)})}})}disablePostMessageAuth(){this._postMessageAuthHandle&&(this._postMessageAuthHandle.remove(),this._postMessageAuthHandle=null)}_getOAuthLocationParams(){let e=window.location.hash;if(e){e.startsWith("#")&&(e=e.slice(1));const t=g(e);let r=!1;if(t.access_token&&t.expires_in&&t.state&&t.hasOwnProperty("username"))try{t.state=JSON.parse(t.state),t.state.portalUrl&&(this._oAuthLocationParams=t,r=!0)}catch{}else if(t.error&&t.error_description&&(console.log("IdentityManager OAuth Error: ",t.error," - ",t.error_description),"access_denied"===t.error&&(r=!0,t.state)))try{t.state=JSON.parse(t.state)}catch{}r&&(window.location.hash=t.state?.hash||"")}let t=window.location.search;if(t){t.startsWith("?")&&(t=t.slice(1));const e=g(t);let r=!1;if(e.code&&e.state)try{e.state=JSON.parse(e.state),e.state.portalUrl&&e.state.uid&&(this._oAuthLocationParams=e,r=!0)}catch{}else if(e.error&&e.error_description&&(console.log("IdentityManager OAuth Error: ",e.error," - ",e.error_description),"access_denied"===e.error&&(r=!0,e.state)))try{e.state=JSON.parse(e.state)}catch{}if(r){const t={...e};["code","error","error_description","message_code","persist","state"].forEach(e=>{delete t[e]});const r=v(t),s=window.location.pathname+(r?`?${r}`:"")+(e.state?.hash||"");window.history.replaceState(window.history.state,"",s)}}}_getOAuthToken(e,t,r,i,o){return e=e.replace(/^http:/i,"https:"),s(`${e}/sharing/rest/oauth2/token`,{authMode:"anonymous",method:"post",query:i&&o?{grant_type:"authorization_code",code:t,redirect_uri:i,client_id:r,code_verifier:o}:{grant_type:"refresh_token",refresh_token:t,client_id:r}}).then(e=>e.data)}async _getCodeChallenge(e){if(e&&globalThis.isSecureContext){const t=(new TextEncoder).encode(e),r=await crypto.subtle.digest("SHA-256",t);return m(new Uint8Array(r))}return null}_pageShowHandler(e){if(e.persisted&&this.isBusy()&&this._rejectOnPersistedPageShow){const e=new i("identity-manager:user-aborted","ABORTED");this._errbackFunc(e)}}_findCredential(e,t){let r,s,i,o,n=-1;const a=t?.token,h=t?.resource,l=this._isServerRsrc(e)?"server":"portal",c=this.credentials.filter(t=>this._hasSameServerInstance(t.server,e)&&t.scope===l);if(e=h||e,c.length)if(1===c.length){if(r=c[0],i=this.findServerInfo(r.server),s=i?.owningSystemUrl,o=s?this.findCredential(s,r.userId):void 0,n=this._getIdenticalSvcIdx(e,r),!a)return-1===n&&r.resources.push(e),this._addResource(e,o),r;-1!==n&&(r.resources.splice(n,1),this._removeResource(e,o))}else{let t,r;if(c.some(a=>(r=this._getIdenticalSvcIdx(e,a),-1!==r&&(t=a,i=this.findServerInfo(t.server),s=i?.owningSystemUrl,o=s?this.findCredential(s,t.userId):void 0,n=r,!0))),a)t&&(t.resources.splice(n,1),this._removeResource(e,o));else if(t)return this._addResource(e,o),t}}_findOAuthInfo(e){let t=this.findOAuthInfo(e);if(!t)for(const r of this.oAuthInfos)if(this._isIdProvider(r.portalUrl,e)){t=r;break}return t}_addResource(e,t){t&&-1===this._getIdenticalSvcIdx(e,t)&&t.resources.push(e)}_removeResource(e,t){let r=-1;t&&(r=this._getIdenticalSvcIdx(e,t),r>-1&&t.resources.splice(r,1))}_useProxy(e,t){return t?.isAdmin&&!_(e.adminTokenServiceUrl,this._appOrigin)||!this._isPortalDomain(e.tokenServiceUrl)&&"10.1"===String(e.currentVersion)&&!_(e.tokenServiceUrl,this._appOrigin)}_getOrigin(e){const t=new f(e);return t.scheme+"://"+t.host+(null!=t.port?":"+t.port:"")}_getServerInstanceRoot(e){const t=e.toLowerCase();let r=t.indexOf(this._agsRest);return-1===r&&this._isAdminResource(e)&&(r=this._agsAdmin.test(e)?e.replace(this._agsAdmin,"$1").length:e.search(this._adminSvcs)),-1!==r||P(t)||(r=t.indexOf("/sharing")),-1===r&&t.endsWith("/")&&(r=t.length-1),r>-1?e.slice(0,r):e}_hasSameServerInstance(e,t){return e.endsWith("/")&&(e=e.slice(0,-1)),e=e.toLowerCase(),t=this._getServerInstanceRoot(t).toLowerCase(),e=R(e),t=R(t),(e=e.slice(Math.max(0,e.indexOf(":"))))===(t=t.slice(Math.max(0,t.indexOf(":"))))}_sanitizeUrl(e){const r=(t.request.proxyUrl||"").toLowerCase(),s=r?e.toLowerCase().indexOf(r+"?"):-1;return-1!==s&&(e=e.slice(s+r.length+1)),e=S(e),p(e).path}_isRESTService(e){return e.includes(this._agsRest)}_isAdminResource(e){return this._agsAdmin.test(e)||this._adminSvcs.test(e)}_isServerRsrc(e){return this._isRESTService(e)||this._isAdminResource(e)}_isIdenticalService(e,t){let r=!1;if(this._isRESTService(e)&&this._isRESTService(t)){const s=this._getSuffix(e).toLowerCase(),i=this._getSuffix(t).toLowerCase();if(r=s===i,!r){const e=/(.*)\/(MapServer|FeatureServer|UtilityNetworkServer).*/gi;r=s.replaceAll(e,"$1")===i.replaceAll(e,"$1")}}else this._isAdminResource(e)&&this._isAdminResource(t)?r=!0:this._isServerRsrc(e)||this._isServerRsrc(t)||!this._isPortalDomain(e)||(r=!0);return r}_isPortalDomain(e){const r=new f(e.toLowerCase()),s=this._portalConfig;let i=this._gwDomains.some(e=>e.regex.test(r.uri));return!i&&s&&(i=this._hasSameServerInstance(this._getServerInstanceRoot(s.restBaseUrl),r.uri)),i||t.portalUrl&&(i=_(r,t.portalUrl,!0)),i||(i=this._portals.some(e=>this._hasSameServerInstance(e,r.uri))),i=i||this._agsPortal.test(r.path),i}_isIdProvider(e,t){let r=-1,s=-1;this._gwDomains.forEach((i,o)=>{-1===r&&i.regex.test(e)&&(r=o),-1===s&&i.regex.test(t)&&(s=o)});let i=!1;if(r>-1&&s>-1&&(0===r||4===r?0!==s&&4!==s||(i=!0):1===r?1!==s&&2!==s||(i=!0):2===r?2===s&&(i=!0):3===r&&3===s&&(i=!0)),!i){const r=this.findServerInfo(t),s=r?.owningSystemUrl;s&&D(r)&&this._isPortalDomain(s)&&this._isIdProvider(e,s)&&(i=!0)}return i}_getIdenticalSvcIdx(e,t){let r=-1;for(let s=0;s<t.resources.length;s++){const i=t.resources[s];if(this._isIdenticalService(e,i)){r=s;break}}return r}_getSuffix(e){return e.replace(this._regexSDirUrl,"").replace(this._regexServerType,"$1")}_getTokenSvcUrl(e){let t,r,i;if(this._isRESTService(e)||this._isAdminResource(e)){const i=this._getServerInstanceRoot(e);return t=i+"/admin/generateToken",r=s(e=i+"/rest/info",{query:{f:"json"}}).then(e=>e.data),{adminUrl:t,promise:r}}if(this._isPortalDomain(e)){let t="";if(this._gwDomains.some(r=>(r.regex.test(e)&&(t=r.tokenServiceUrl),!!t)),t||this._portals.some(r=>(this._hasSameServerInstance(r,e)&&(t=r+this._gwTokenUrl),!!t)),t||(i=e.toLowerCase().indexOf("/sharing"),-1!==i&&(t=e.slice(0,i)+this._gwTokenUrl)),t||(t=this._getOrigin(e)+this._gwTokenUrl),t){const r=new f(e).port;/^http:\/\//i.test(e)&&"7080"===r&&(t=t.replace(/:7080/i,":7443")),t=t.replace(/http:/i,"https:")}return t}}_processOAuthResponseParams(e,t,r){const s=t._oAuthCred;if(e.code){const i=s.codeVerifier;return s.codeVerifier=null,s.stateUID=null,s.save(),this._getOAuthToken(r.server,e.code,t.appId,this._getRedirectURI(t,!0),i).then(i=>{const o=new L({userId:i.username,server:r.server??void 0,token:i.access_token,expires:Date.now()+1e3*i.expires_in,ssl:i.ssl,oAuthState:e.state,_oAuthCred:s});return t.userId=o.userId,s.storage=i.persist?q:j,s.refreshToken=i.refresh_token,s.token=null,s.expires=i.refresh_token_expires_in?Date.now()+1e3*i.refresh_token_expires_in:null,s.userId=o.userId,s.ssl=o.ssl,s.save(),o})}const i=new L({userId:e.username,server:r.server??void 0,token:e.access_token,expires:Date.now()+1e3*Number(e.expires_in),ssl:"true"===e.ssl,oAuthState:e.state,_oAuthCred:s});return t.userId=i.userId,s.storage=e.persist?q:j,s.refreshToken=null,s.token=i.token,s.expires=i.expires,s.userId=i.userId,s.ssl=i.ssl,s.save(),Promise.resolve(i)}_processOAuthPopupParams(e){const t=this._oAuthDfd;if(this._oAuthDfd=null,t)if(clearInterval(this._oAuthIntervalId),this._oAuthOnPopupHandle?.remove(),e.error){const r="access_denied"===e.error,s=new i(r?"identity-manager:user-aborted":"identity-manager:authentication-failed",r?"ABORTED":"OAuth: "+e.error+" - "+e.error_description);t.reject(s)}else this._processOAuthResponseParams(e,t.oinfo_,t.sinfo_).then(e=>{t.resolve(e)}).catch(e=>{t.reject(e)})}_setOAuthResponseQueryString(e){e&&(e.startsWith("?")&&(e=e.slice(1)),this._processOAuthPopupParams(g(e)))}async _exchangeToken(e,t,r){return(await s(`${e}/sharing/rest/oauth2/exchangeToken`,{authMode:"anonymous",method:"post",query:{f:"json",client_id:t,token:r}})).data.token}async _getPlatformSelf(e,t){if(this._getPlatformSelfError&&Date.now()-this._getPlatformSelfError[1]<1e3)throw this._getPlatformSelfError[0];e=e.replace(/^http:/i,"https:");try{const r=await s(`${e}/sharing/rest/oauth2/platformSelf`,{authMode:"anonymous",headers:{"X-Esri-Auth-Client-Id":t,"X-Esri-Auth-Redirect-Uri":window.location.href.replace(/#.*$/,"")},method:"post",query:{f:"json",expiration:30},withCredentials:!0});return this._getPlatformSelfError=null,r.data}catch(r){throw"OAUTH_0066"===r.details?.messageCode&&(this._getPlatformSelfError=[r,Date.now()]),r}}_getPortalSelf(e,t){let r;if(this._gwDomains.some(t=>(t.regex.test(e)&&(r=t.customBaseUrl),!!r)),r)return Promise.resolve({allSSL:!0,currentVersion:"8.4",customBaseUrl:r,portalMode:"multitenant",supportsOAuth:!0});this._appOrigin.startsWith("https:")?e=e.replace(/^http:/i,"https:").replace(/:7080/i,":7443"):/^http:/i.test(t)&&(e=e.replace(/^https:/i,"http:").replace(/:7443/i,":7080"));return s(e,{query:{f:"json"},authMode:"anonymous",withCredentials:!0}).then(e=>e.data)}_doPortalSignIn(e){const t=this._portalConfig,r=window.location.href,s=this.findServerInfo(e);return!(!t&&!this._isPortalDomain(r)||!(s?s.hasPortal||s.owningSystemUrl&&this._isPortalDomain(s.owningSystemUrl):this._isPortalDomain(e))||!(this._isIdProvider(r,e)||t&&(this._hasSameServerInstance(this._getServerInstanceRoot(t.restBaseUrl),e)||this._isIdProvider(t.restBaseUrl,e))||_(r,e,!0)))}_checkProtocol(e,t,r,s){let o=!0;const n=s?t.adminTokenServiceUrl:t.tokenServiceUrl;if(n.trim().toLowerCase().startsWith("https:")&&!this._appOrigin.startsWith("https:")&&w(n)&&(o=!!this._protocolFunc&&!!this._protocolFunc({resourceUrl:e,serverInfo:t}),!o)){r(new i("identity-manager:aborted","Aborted the Sign-In process to avoid sending password over insecure connection."))}return o}_enqueue(e,t,r,s,i,o){return s||(s=c()),s.resUrl_=e,s.sinfo_=t,s.options_=r,s.admin_=i,s.refresh_=o,this._busy?this._hasSameServerInstance(this._getServerInstanceRoot(e),this._busy.resUrl_)?(this._oAuthDfd&&this._oAuthDfd.oAuthWin_&&this._oAuthDfd.oAuthWin_.focus(),this._soReqs.push(s)):this._xoReqs.push(s):this._doSignIn(s),s.promise}_doSignIn(e){this._busy=e,this._rejectOnPersistedPageShow=!1;const t=t=>{const r=e.options_?.resource,s=e.resUrl_,i=e.refresh_;let o=!1;this.credentials.includes(t)||(i&&this.credentials.includes(i)?(i.userId=t.userId,i.token=t.token,i.expires=t.expires,i.validity=t.validity,i.ssl=t.ssl,i.creationTime=t.creationTime,o=!0,t=i):this.credentials.push(t)),t.resources||(t.resources=[]),t.resources.includes(r||s)||t.resources.push(r||s),t.scope=this._isServerRsrc(s)?"server":"portal",t.emitTokenChange();const n=this._soReqs,a={};this._soReqs=[],n.forEach(e=>{if(!this._isIdenticalService(s,e.resUrl_)){const r=this._getSuffix(e.resUrl_);a[r]||(a[r]=!0,t.resources.push(e.resUrl_))}}),e.resolve(t),n.forEach(e=>{this._hasSameServerInstance(this._getServerInstanceRoot(s),e.resUrl_)?e.resolve(t):this._soReqs.push(e)}),this._busy=e.resUrl_=e.sinfo_=e.refresh_=null,o||this.emit("credential-create",{credential:t}),this._soReqs.length?this._doSignIn(this._soReqs.shift()):this._xoReqs.length&&this._doSignIn(this._xoReqs.shift())},r=t=>{e.reject(t),this._busy=e.resUrl_=e.sinfo_=e.refresh_=null,this._soReqs.length?this._doSignIn(this._soReqs.shift()):this._xoReqs.length&&this._doSignIn(this._xoReqs.shift())},s=(o,n,h,l)=>{const c=e.sinfo_,u=!e.options_||!1!==e.options_.prompt,p=c.hasPortal&&this._findOAuthInfo(e.resUrl_);let f,g;if(o)t(new L({userId:o,server:c.server??void 0,token:h??void 0,expires:null!=l?Number(l):null,ssl:!!n}));else if(window!==window.parent&&this._appUrlObj.query?.["arcgis-auth-origin"]&&this._appUrlObj.query?.["arcgis-auth-portal"]&&this._hasSameServerInstance(this._getServerInstanceRoot(this._appUrlObj.query["arcgis-auth-portal"]),e.resUrl_)){window.parent.postMessage({type:"arcgis:auth:requestCredential"},this._appUrlObj.query["arcgis-auth-origin"]);const s=a(window,"message",e=>{e.source===window.parent&&e.data&&("arcgis:auth:credential"===e.data.type?(s.remove(),e.data.credential.expires<Date.now()?r(new i("identity-manager:credential-request-failed","Parent application's token has expired.")):t(new L(e.data.credential))):"arcgis:auth:error"===e.data.type&&(s.remove(),"tokenExpiredError"===e.data.error.name?r(new i("identity-manager:credential-request-failed","Parent application's token has expired.")):r(i.fromJSON(e.data.error))))});d(e.options_?.signal,()=>{s.remove()})}else if(p){let o=p._oAuthCred;if(!o){const e=new T(p,q),t=new T(p,j);e.isValid()&&t.isValid()?e.expires>t.expires?(o=e,t.destroy()):(o=t,e.destroy()):o=e.isValid()?e:t,p._oAuthCred=o}if(o.isValid()){f=new L({userId:o.userId??void 0,server:c.server??void 0,token:o.token??void 0,expires:o.expires,ssl:o.ssl??void 0,_oAuthCred:o});const i=p.appId!==o.appId&&this._doPortalSignIn(e.resUrl_);i||o.refreshToken?(e._pendingDfd=o.refreshToken?this._getOAuthToken(c.server,o.refreshToken,o.appId).then(e=>(f.expires=Date.now()+1e3*e.expires_in,f.token=e.access_token,f)):Promise.resolve(f),e._pendingDfd.then(e=>i?this._exchangeToken(e.server,p.appId,e.token).then(t=>(e.token=t,e)).catch(()=>e):e).then(e=>{t(e)}).catch(e=>{const t=e.details?.httpStatus;t>0&&404!==t?(o.destroy(),s()):r(e)})):t(f)}else if(this._oAuthLocationParams&&this._hasSameServerInstance(p.portalUrl,this._oAuthLocationParams.state.portalUrl)&&(this._oAuthLocationParams.access_token||this._oAuthLocationParams.code&&this._oAuthLocationParams.state.uid===o.stateUID&&o.codeVerifier)){const s=this._oAuthLocationParams;this._oAuthLocationParams=null,e._pendingDfd=this._processOAuthResponseParams(s,p,c).then(e=>{t(e)}).catch(r)}else{const s=()=>{u?e._pendingDfd=this.oAuthSignIn(e.resUrl_,c,p,e.options_).then(t,r):(g=new i("identity-manager:not-authenticated","User is not signed in."),r(g))};this._doPortalSignIn(e.resUrl_)?e._pendingDfd=this._getPlatformSelf(c.server,p.appId).then(e=>{_(e.portalUrl,this._appOrigin,!0)?(f=new L({userId:e.username,server:c.server??void 0,expires:Date.now()+1e3*e.expires_in,token:e.token}),t(f)):s()}).catch(s):s()}}else if(u){if(this._checkProtocol(e.resUrl_,c,r,e.admin_)){let s=e.options_;e.admin_&&(s=s||{},s.isAdmin=!0),e._pendingDfd=this.signIn(e.resUrl_,c,s).then(t,r)}}else g=new i("identity-manager:not-authenticated","User is not signed in."),r(g)},o=()=>{const s=e.sinfo_,i=s.owningSystemUrl,o=e.options_;let n,a,h,l;if(o&&(n=o.token,a=o.error,h=o.prompt),l=this._findCredential(i,{token:n,resource:e.resUrl_}),!l)for(const e of this.credentials)if(this._isIdProvider(i,e.server)){l=e;break}if(l){const i=this.findCredential(e.resUrl_,l.userId);if(i)t(i);else if(b(s,this._legacyFed)){const e=l.toJSON();e.server=s.server,e.resources=null,t(new L(e))}else{(e._pendingDfd=this.generateToken(this.findServerInfo(l.server),null,{serverUrl:e.resUrl_,token:l.token,signal:e.options_.signal,ssl:l.ssl})).then(r=>{t(new L({userId:l?.userId,server:s.server??void 0,token:r.token,expires:null!=r.expires?Number(r.expires):null,ssl:!!r.ssl,isAdmin:e.admin_,validity:r.validity}))},r)}}else{this._busy=null,n&&(e.options_.token=null);(e._pendingDfd=this.getCredential(i.replace(/\/?$/,"/sharing"),{resource:e.resUrl_,owningTenant:s.owningTenant,signal:e.options_.signal,token:n,error:a,prompt:h})).then(()=>{this._enqueue(e.resUrl_,e.sinfo_,e.options_,e,e.admin_)},t=>{e.resUrl_=e.sinfo_=e.refresh_=null,e.reject(t)})}};this._errbackFunc=r;const n=e.sinfo_.owningSystemUrl,h=this._isServerRsrc(e.resUrl_),c=e.sinfo_._restInfoPms;c?c.promise.then(t=>{const r=e.sinfo_;if(r._restInfoPms){r.adminTokenServiceUrl=r._restInfoPms.adminUrl,r._restInfoPms=null,r.tokenServiceUrl=(l("authInfo.tokenServicesUrl",t)||l("authInfo.tokenServiceUrl",t)||l("tokenServiceUrl",t))??null,r.shortLivedTokenValidity=l("authInfo.shortLivedTokenValidity",t)??null,r.currentVersion=t.currentVersion,r.owningTenant=t.owningTenant;const e=r.owningSystemUrl=t.owningSystemUrl;e&&this._portals.push(e)}h&&r.owningSystemUrl?o():s()},()=>{e.sinfo_._restInfoPms=null;const t=new i("identity-manager:server-identification-failed","Unknown resource - could not find token service endpoint.");r(t)}):h&&n?o():e.sinfo_._selfReq?e.sinfo_._selfReq.selfDfd.then(t=>{const r={};let s,i,o,n;return t&&(s=t.user?.username,r.username=s,r.allSSL=t.allSSL,i=t.supportsOAuth,n=parseFloat(t.currentVersion),"multitenant"===t.portalMode&&(o=t.customBaseUrl),e.sinfo_.currentVersion=n),e.sinfo_.webTierAuth=!!s,s&&this.normalizeWebTierAuth?this.generateToken(e.sinfo_,null,{ssl:r.allSSL}).catch(()=>null).then(e=>(r.portalToken=e?.token,r.tokenExpiration=e?.expires,r)):!s&&i&&n>=4.4&&!this._findOAuthInfo(e.resUrl_)?this._generateOAuthInfo({portalUrl:e.sinfo_.server,customBaseUrl:o,owningTenant:e.sinfo_._selfReq.owningTenant}).catch(()=>null).then(()=>r):r}).catch(()=>null).then(t=>{e.sinfo_._selfReq=null,t?s(t.username,t.allSSL,t.portalToken,t.tokenExpiration):s()}):s()}_generateOAuthInfo(e){let t,r=null,i=e.portalUrl;const o=e.customBaseUrl,n=e.owningTenant,a=!this._defaultOAuthInfo&&this._createDefaultOAuthInfo&&!this._hasTestedIfAppIsOnPortal;if(a){r=this._appUrlObj.path;const e=r.search(/\/(apps|home)\//);r=e>-1?r.slice(0,e):null}return a&&r?(this._hasTestedIfAppIsOnPortal=!0,t=s(r+"/sharing/rest",{query:{f:"json"}}).then(()=>{this._defaultOAuthInfo=new x({appId:"arcgisonline",popupCallbackUrl:r+"/home/oauth-callback.html"})})):t=Promise.resolve(),t.then(()=>{if(this._defaultOAuthInfo)return i=i.replace(/^http:/i,"https:"),s(i+"/sharing/rest/oauth2/validateRedirectUri",{query:{accountId:n,client_id:this._defaultOAuthInfo.appId,redirect_uri:I(this._defaultOAuthInfo.popupCallbackUrl),f:"json"}}).then(e=>{if(e.data.valid){const t=this._defaultOAuthInfo.clone();e.data.urlKey&&o?t.portalUrl="https://"+e.data.urlKey.toLowerCase()+"."+o:t.portalUrl=i,t.popup=window!==window.top||!(_(i,this._appOrigin)||this._gwDomains.some(e=>e.regex.test(i)&&e.regex.test(this._appOrigin))),this.oAuthInfos.push(t)}})})}_doOAuthSignIn(e,t,r,s){const o=r._oAuthCred,n={portalUrl:r.portalUrl};!r.popup&&r.preserveUrlHash&&window.location.hash&&(n.hash=window.location.hash),o.stateUID&&(n.uid=o.stateUID);const h={client_id:r.appId,response_type:o.codeVerifier?"code":"token",state:JSON.stringify(n),expiration:r.expiration,locale:r.locale,redirect_uri:this._getRedirectURI(r,!!o.codeVerifier)};r.forceLogin&&(h.force_login=!0),r.forceUserId&&r.userId&&(h.prepopulatedusername=r.userId),!r.popup&&this._doPortalSignIn(e)&&(h.redirectToUserOrgUrl=!0),o.codeVerifier&&(h.code_challenge=s||o.codeVerifier,h.code_challenge_method=s?"S256":"plain");const l=r.portalUrl.replace(/^http:/i,"https:")+"/sharing/oauth2/authorize",c=l+"?"+v(h);if(r.popup){const e=window.open(c,"esriJSAPIOAuth",r.popupWindowFeatures);if(e)e.focus(),this._oAuthDfd.oAuthWin_=e,this._oAuthIntervalId=setInterval(()=>{if(e.closed){clearInterval(this._oAuthIntervalId),this._oAuthOnPopupHandle.remove();const e=this._oAuthDfd;if(e){const t=new i("identity-manager:user-aborted","ABORTED");e.reject(t)}}},500),this._oAuthOnPopupHandle=a(window,["arcgis:auth:hash","arcgis:auth:location:search"],e=>{"arcgis:auth:hash"===e.type?this.setOAuthResponseHash(e.detail):this._setOAuthResponseQueryString(e.detail)});else{const e=new i("identity-manager:popup-blocked","ABORTED");this._oAuthDfd.reject(e)}}else this._rejectOnPersistedPageShow=!0,this._oAuthRedirectFunc?this._oAuthRedirectFunc({authorizeParams:h,authorizeUrl:l,resourceUrl:e,serverInfo:t,oAuthInfo:r}):window.location.href=c}_getRedirectURI(e,t){const r=window.location.href.replace(/#.*$/,"");if(e.popup)return I(e.popupCallbackUrl);if(t){const e=p(r);return e.query&&["code","error","error_description","message_code","persist","state"].forEach(t=>{delete e.query[t]}),k(e.path,e.query)}return r}}E.prototype.declaredClass="esri.identity.IdentityManagerBase";let L=class extends n{constructor(e){super(e),this._oAuthCred=null,this.tokenRefreshBuffer=2,e?._oAuthCred&&(this._oAuthCred=e._oAuthCred)}initialize(){this.resources=this.resources||[],null==this.creationTime&&(this.creationTime=Date.now())}refreshToken(){const e=r,t=e.findServerInfo(this.server),s=t?.owningSystemUrl,i=!!s&&"server"===this.scope,o=i&&b(t,e._legacyFed),n=t.webTierAuth,a=n&&e.normalizeWebTierAuth,h=C[this.server],l=h?.[this.userId];let c,d=this.resources&&this.resources[0],u=i?e.findServerInfo(s):null,p={username:this.userId,password:l};if(n&&!a)return;i&&!u&&e.serverInfos.some(t=>(e._isIdProvider(s,t.server)&&(u=t),!!u));const _=u?e.findCredential(u.server,this.userId):null;if(!i||_){if(!o){if(i)c={serverUrl:d,token:_?.token,ssl:_?.ssl};else if(a)p=null,c={ssl:this.ssl};else{if(!l){let r;return d&&(d=e._sanitizeUrl(d),this._enqueued=1,r=e._enqueue(d,t,null,null,this.isAdmin,this),r.then(()=>{this._enqueued=0,this.refreshServerTokens()}).catch(()=>{this._enqueued=0})),r}this.isAdmin&&(c={isAdmin:!0})}return e.generateToken(i?u:t,i?null:p,c).then(e=>{this.token=e.token,this.expires=null!=e.expires?Number(e.expires):null,this.creationTime=Date.now(),this.validity=e.validity,this.emitTokenChange(),this.refreshServerTokens()}).catch(()=>{})}_?.refreshToken()}}refreshServerTokens(){if("portal"===this.scope){const e=r;e.credentials.forEach(t=>{const r=e.findServerInfo(t.server),s=r?.owningSystemUrl;t!==this&&t.userId===this.userId&&s&&"server"===t.scope&&(e._hasSameServerInstance(this.server,s)||e._isIdProvider(s,this.server))&&(b(r,e._legacyFed)?(t.token=this.token,t.expires=this.expires,t.creationTime=this.creationTime,t.validity=this.validity,t.emitTokenChange()):t.refreshToken())})}}emitTokenChange(e){clearTimeout(this._refreshTimer);const t=r,s=this.server?t.findServerInfo(this.server):null,i=s?.owningSystemUrl,o=i?t.findServerInfo(i):null;!1===e||i&&"portal"!==this.scope&&(!o?.webTierAuth||t.normalizeWebTierAuth)||null==this.expires&&null==this.validity||this._startRefreshTimer(),this.emit("token-change")}destroy(){this.userId=this.server=this.token=this.expires=this.validity=this.resources=this.creationTime=null,this._oAuthCred&&(this._oAuthCred.destroy(),this._oAuthCred=null);const e=r,t=e.credentials.indexOf(this);t>-1&&e.credentials.splice(t,1),this.emitTokenChange(),this.emit("destroy")}toJSON(){const e=h({userId:this.userId,server:this.server,token:this.token,expires:this.expires,validity:this.validity,ssl:this.ssl,isAdmin:this.isAdmin,creationTime:this.creationTime,scope:this.scope}),t=this.resources;return t&&t.length>0&&(e.resources=t.slice()),e}_startRefreshTimer(){clearTimeout(this._refreshTimer);const e=6e4*this.tokenRefreshBuffer,t=2**31-1;let r=(this.validity?this.creationTime+6e4*this.validity:this.expires)-Date.now();r<0?r=0:r>t&&(r=t),this._refreshTimer=setTimeout(this.refreshToken.bind(this),r>e?r-e:r)}};e([A()],L.prototype,"creationTime",void 0),e([A()],L.prototype,"expires",void 0),e([A()],L.prototype,"isAdmin",void 0),e([A()],L.prototype,"oAuthState",void 0),e([A()],L.prototype,"resources",void 0),e([A()],L.prototype,"scope",void 0),e([A()],L.prototype,"server",void 0),e([A()],L.prototype,"ssl",void 0),e([A()],L.prototype,"token",void 0),e([A()],L.prototype,"tokenRefreshBuffer",void 0),e([A()],L.prototype,"userId",void 0),e([A()],L.prototype,"validity",void 0),L=e([y("esri.identity.Credential")],L);export{L as Credential,E as IdentityManagerBase};
5
+ import{__decorate as e}from"tslib";import t from"../config.js";import{id as r}from"../kernel.js";import s from"../request.js";import i from"../core/Error.js";import{Evented as o,EventedAccessor as n}from"../core/Evented.js";import{on as a}from"../core/events.js";import{fixJson as h}from"../core/lang.js";import{getDeepValue as l}from"../core/object.js";import{createResolver as c,onAbort as d,isAborted as u}from"../core/promiseUtils.js";import{urlToObject as p,hasSameOrigin as _,Url as f,queryToObject as g,base64UrlEncode as m,objectToQuery as v,normalize as S,getProxyRule as w,makeAbsolute as I,addQueryParameters as k}from"../core/urlUtils.js";import{property as A}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as y}from"../core/accessorSupport/decorators/subclass.js";import U from"./IdentityModal.js";import T from"./OAuthCredential.js";import x from"./OAuthInfo.js";import O from"./ServerInfo.js";import{isSecureProxyService as P,normalizeArcGISOnlineOrgDomain as R}from"../portal/support/urlUtils.js";const C={},D=e=>{const t=new f(e.owningSystemUrl).host,r=new f(e.server).host,s=/.+\.arcgis\.com$/i;return s.test(t)&&s.test(r)},b=(e,t)=>!!(D(e)&&t&&t.some(t=>t.test(e.server)));let q=null,j=null;try{q=window.localStorage,j=window.sessionStorage}catch{}class E extends o{constructor(){super(),this._portalConfig=globalThis.esriGeowConfig,this.serverInfos=[],this.oAuthInfos=[],this.credentials=[],this._soReqs=[],this._xoReqs=[],this._portals=[],this._defaultOAuthInfo=null,this._defaultTokenValidity=60,this.dialog=null,this.tokenValidity=null,this.normalizeWebTierAuth=!1,this._appOrigin="null"!==window.origin?window.origin:window.location.origin,this._appUrlObj=p(window.location.href),this._busy=null,this._rejectOnPersistedPageShow=!1,this._oAuthLocationParams=null,this._gwTokenUrl="/sharing/rest/generateToken",this._agsRest="/rest/services",this._agsPortal=/\/sharing(\/|$)/i,this._agsAdmin=/(https?:\/\/[^/]+\/[^/]+)\/admin\/?(\/.*)?$/i,this._adminSvcs=/\/rest\/admin\/services(\/|$)/i,this._gwDomains=[{regex:/^https?:\/\/www\.arcgis\.com/i,customBaseUrl:"maps.arcgis.com",tokenServiceUrl:"https://www.arcgis.com/sharing/rest/generateToken"},{regex:/^https?:\/\/(?:dev|[a-z\d-]+\.mapsdev)\.arcgis\.com/i,customBaseUrl:"mapsdev.arcgis.com",tokenServiceUrl:"https://dev.arcgis.com/sharing/rest/generateToken"},{regex:/^https?:\/\/(?:devext|[a-z\d-]+\.mapsdevext)\.arcgis\.com/i,customBaseUrl:"mapsdevext.arcgis.com",tokenServiceUrl:"https://devext.arcgis.com/sharing/rest/generateToken"},{regex:/^https?:\/\/(?:qaext|[a-z\d-]+\.mapsqa)\.arcgis\.com/i,customBaseUrl:"mapsqa.arcgis.com",tokenServiceUrl:"https://qaext.arcgis.com/sharing/rest/generateToken"},{regex:/^https?:\/\/[a-z\d-]+\.maps\.arcgis\.com/i,customBaseUrl:"maps.arcgis.com",tokenServiceUrl:"https://www.arcgis.com/sharing/rest/generateToken"}],this._legacyFed=[],this._regexSDirUrl=/http.+\/rest\/services\/?/gi,this._regexServerType=/(\/(FeatureServer|GPServer|GeoDataServer|GeocodeServer|GeoenrichmentServer|GeometryServer|GlobeServer|ImageServer|KnowledgeGraphServer|MapServer|MissionServer|MobileServer|NAServer|NetworkDiagramServer|OGCFeatureServer|ParcelFabricServer|RelationalCatalogServer|SceneServer|StreamServer|UtilityNetworkServer|ValidationServer|VectorTileServer|VersionManagementServer|VideoServer)).*/gi,this._gwUser=/http.+\/users\/([^/]+).*/i,this._gwItem=/http.+\/items\/([^/]+).*/i,this._gwGroup=/http.+\/groups\/([^/]+).*/i,this._rePortalTokenSvc=/\/sharing(\/rest)?\/generatetoken/i,this._createDefaultOAuthInfo=!0,this._hasTestedIfAppIsOnPortal=!1,this._getPlatformSelfError=null,this._getOAuthLocationParams(),window.addEventListener("pageshow",e=>{this._pageShowHandler(e)})}registerServers(e){const t=this.serverInfos;t?(e=e.filter(e=>!this.findServerInfo(e.server)),this.serverInfos=t.concat(e)):this.serverInfos=e,e.forEach(e=>{e.owningSystemUrl&&this._portals.push(e.owningSystemUrl),e.hasPortal&&this._portals.push(e.server)})}registerOAuthInfos(e){const t=this.oAuthInfos;if(t){for(const r of e){const e=this.findOAuthInfo(r.portalUrl);e&&t.splice(t.indexOf(e),1)}this.oAuthInfos=t.concat(e)}else this.oAuthInfos=e}registerToken(e){e={...e};const t=this._sanitizeUrl(e.server),r=this._isServerRsrc(t);let s,i=this.findServerInfo(t),o=!0;i||(i=new O,i.server=this._getServerInstanceRoot(t),r?i.hasServer=!0:(i.tokenServiceUrl=this._getTokenSvcUrl(t),i.hasPortal=!0),this.registerServers([i])),s=this._findCredential(t),s?(delete e.server,Object.assign(s,e),o=!1):(s=new L({userId:e.userId,server:i.server??void 0,token:e.token,expires:e.expires,ssl:e.ssl,scope:r?"server":"portal"}),s.resources=[t],this.credentials.push(s)),s.emitTokenChange(!1),o||s.refreshServerTokens()}toJSON(){return h({serverInfos:this.serverInfos.map(e=>e.toJSON()),oAuthInfos:this.oAuthInfos.map(e=>e.toJSON()),credentials:this.credentials.map(e=>e.toJSON())})}initialize(e){if(!e)return;"string"==typeof e&&(e=JSON.parse(e));const t=e.serverInfos,r=e.oAuthInfos,s=e.credentials;if(t){const e=[];t.forEach(t=>{t.server&&t.tokenServiceUrl&&e.push(t.declaredClass?t:new O(t))}),e.length&&this.registerServers(e)}if(r){const e=[];r.forEach(t=>{t.appId&&e.push(t.declaredClass?t:new x(t))}),e.length&&this.registerOAuthInfos(e)}s&&s.forEach(e=>{e.server&&e.token&&e.expires&&e.expires>Date.now()&&((e=e.declaredClass?e:new L(e)).emitTokenChange(),this.credentials.push(e))})}findServerInfo(e){let t;e=this._sanitizeUrl(e);for(const r of this.serverInfos)if(this._hasSameServerInstance(r.server,e)){t=r;break}return t}findOAuthInfo(e){let t;e=this._sanitizeUrl(e);for(const r of this.oAuthInfos)if(this._hasSameServerInstance(r.portalUrl,e)){t=r;break}return t}findCredential(e,t){if(!e)return;let r;e=this._sanitizeUrl(e);const s=this._isServerRsrc(e)?"server":"portal";if(t){for(const i of this.credentials)if(this._hasSameServerInstance(i.server,e)&&t===i.userId&&i.scope===s){r=i;break}}else for(const i of this.credentials)if(this._hasSameServerInstance(i.server,e)&&-1!==this._getIdenticalSvcIdx(e,i)&&i.scope===s){r=i;break}return r}getCredential(e,t){let r,s=!1,o=!0;t&&(s=!(!t.token&&!t.credential),r=t.error,o=!1!==t.prompt),t={...t},e=this._sanitizeUrl(e);const n=new AbortController,a=c();if(t.signal&&d(t.signal,()=>{n.abort()}),d(n,()=>{a.reject(new i("identity-manager:user-aborted","ABORTED"))}),u(n))return a.promise;t.signal=n.signal;const h=this._isAdminResource(e),l=s?this.findCredential(e):null;let p;if(l&&498===r?.details?.httpStatus)l.destroy();else if(l)return p=new i("identity-manager:not-authorized","You are currently signed in as: '"+l.userId+"'. You do not have access to this resource: "+e,{error:r}),a.reject(p),a.promise;const f=this._findCredential(e,t);if(f)return a.resolve(f),a.promise;let g=this.findServerInfo(e);if(g)!g.hasPortal&&g.server&&g.owningSystemUrl&&this._hasSameServerInstance(g.server,g.owningSystemUrl)&&(g.hasPortal=!0),!g.hasServer&&this._isServerRsrc(e)&&(g._restInfoPms=this._getTokenSvcUrl(e),g.hasServer=!0);else{const t=this._getTokenSvcUrl(e);if(!t)return p=new i("identity-manager:unknown-resource","Unknown resource - could not find token service endpoint."),a.reject(p),a.promise;g=new O,g.server=this._getServerInstanceRoot(e),"string"==typeof t?(g.tokenServiceUrl=t,g.hasPortal=!0):(g._restInfoPms=t,g.hasServer=!0),this.registerServers([g])}return g.hasPortal&&void 0===g._selfReq&&(o||_(g.tokenServiceUrl,this._appOrigin)||this._gwDomains.some(e=>e.tokenServiceUrl===g.tokenServiceUrl))&&(g._selfReq={owningTenant:t?.owningTenant,selfDfd:this._getPortalSelf(g.tokenServiceUrl.replace(this._rePortalTokenSvc,"/sharing/rest/portals/self"),e)}),this._enqueue(e,g,t,a,h)}getResourceName(e){return this._isRESTService(e)?e.replace(this._regexSDirUrl,"").replace(this._regexServerType,"")||"":this._gwUser.test(e)&&e.replace(this._gwUser,"$1")||this._gwItem.test(e)&&e.replace(this._gwItem,"$1")||this._gwGroup.test(e)&&e.replace(this._gwGroup,"$1")||""}generateToken(e,t,r){const o=this._rePortalTokenSvc.test(e.tokenServiceUrl),n=new f(this._appOrigin),a=e.shortLivedTokenValidity;let h,l,c,d,u,p,g,m;t&&(m=this.tokenValidity||a||this._defaultTokenValidity,m>a&&a>0&&(m=a)),r&&(h=r.isAdmin,l=r.serverUrl,c=r.token,p=r.signal,g=r.ssl,e.customParameters=r.customParameters),h?d=e.adminTokenServiceUrl:(d=e.tokenServiceUrl,u=new f(d.toLowerCase()),e.webTierAuth&&r?.serverUrl&&!g&&"http"===n.scheme&&(_(n.uri,d,!0)||"https"===u.scheme&&n.host===u.host&&"7080"===n.port&&"7443"===u.port)&&(d=d.replace(/^https:/i,"http:").replace(/:7443/i,":7080")));const v={query:{request:"getToken",username:t?.username,password:t?.password,serverUrl:l,token:c,expiration:m,referer:h||o?this._appOrigin:null,client:h?"referer":null,f:"json",...e.customParameters},method:"post",authMode:"anonymous",useProxy:this._useProxy(e,r),signal:p};o||(v.withCredentials=!1);return s(d,v).then(r=>{const s=r.data;if(!s?.token)return new i("identity-manager:authentication-failed","Unable to generate token");const o=e.server;return C[o]||(C[o]={}),t&&(C[o][t.username]=t.password),s.validity=m,s})}isBusy(){return!!this._busy}async checkSignInStatus(e){return(await this.checkAppAccess(e,"")).credential}checkAppAccess(e,t,r){let o=!1;return this.getCredential(e,{prompt:!1}).then(n=>{let a;const h={f:"json"};if("portal"===n.scope)if(t&&(this._doPortalSignIn(e)||r?.force))a=n.server+"/sharing/rest/oauth2/validateAppAccess",h.client_id=t;else{if(!n.token)return{credential:n};a=n.server+"/sharing/rest"}else{if(!n.token)return{credential:n};a=n.server+"/rest/services"}return n.token&&(h.token=n.token),s(a,{query:h,authMode:"anonymous"}).then(e=>{if(!1===e.data.valid)throw new i("identity-manager:not-authorized",`You are currently signed in as: '${n.userId}'.`,e.data);return o=!!e.data.viewOnlyUserTypeApp,{credential:n}}).catch(e=>{if("identity-manager:not-authorized"===e.name)throw e;const t=e.details?.httpStatus;if(498===t)throw n.destroy(),new i("identity-manager:not-authenticated","User is not signed in.");if(400===t)throw new i("identity-manager:invalid-request","Bad request");return{credential:n}})}).then(e=>({credential:e.credential,viewOnly:o}))}setOAuthResponseHash(e){e&&(e.startsWith("#")&&(e=e.slice(1)),this._processOAuthPopupParams(g(e)))}setOAuthRedirectionHandler(e){this._oAuthRedirectFunc=e}setProtocolErrorHandler(e){this._protocolFunc=e}signIn(e,t,r={}){const s=c(),o=()=>{h?.remove(),l?.remove(),this.dialog?.destroy(),this.dialog=h=l=null},n=()=>{o(),this._oAuthDfd=null,s.reject(new i("identity-manager:user-aborted","ABORTED"))};r.signal&&d(r.signal,()=>{n()});const a=new U({open:!0,resource:this.getResourceName(e),server:t.server});this.dialog=a,this.emit("dialog-create");let h=a.on("cancel",n),l=a.on("submit",e=>{this.generateToken(t,e,{isAdmin:r.isAdmin,signal:r.signal}).then(i=>{o();const n=new L({userId:e.username,server:t.server??void 0,token:i.token,expires:null!=i.expires?Number(i.expires):null,ssl:!!i.ssl,isAdmin:r.isAdmin,validity:i.validity});s.resolve(n)}).catch(e=>{a.error=e,a.signingIn=!1})});return s.promise}oAuthSignIn(e,t,r,s){this._oAuthDfd=c();const o=this._oAuthDfd;let n;s?.signal&&d(s.signal,()=>{const e=this._oAuthDfd&&this._oAuthDfd.oAuthWin_;e&&!e.closed?e.close():this.dialog&&u()}),o.resUrl_=e,o.sinfo_=t,o.oinfo_=r;const a=r._oAuthCred;if(a.storage&&("authorization-code"===r.flowType||"auto"===r.flowType&&t.currentVersion>=8.4)){let e=crypto.getRandomValues(new Uint8Array(32));n=m(e),a.codeVerifier=n,e=crypto.getRandomValues(new Uint8Array(32)),a.stateUID=m(e),a.save()||(a.codeVerifier=n=null)}else a.codeVerifier=null;let h,l;this._getCodeChallenge(n).then(i=>{const o=!s||!1!==s.oAuthPopupConfirmation;if(!r.popup||!o)return void this._doOAuthSignIn(e,t,r,i);const n=new U({oAuthPrompt:!0,server:t.server,open:!0});this.dialog=n,this.emit("dialog-create"),h=n.on("cancel",u),l=n.on("submit",()=>{p(),this._doOAuthSignIn(e,t,r,i)})});const u=()=>{p(),this._oAuthDfd=null,o.reject(new i("identity-manager:user-aborted","ABORTED"))},p=()=>{h?.remove(),l?.remove(),this.dialog?.destroy(),this.dialog=null};return o.promise}destroyCredentials(){if(this.credentials){this.credentials.slice().forEach(e=>{e.destroy()})}this.emit("credentials-destroy")}enablePostMessageAuth(e="https://www.arcgis.com/sharing/rest"){this._postMessageAuthHandle&&this._postMessageAuthHandle.remove(),this._postMessageAuthHandle=a(window,"message",t=>{if((t.origin===this._appOrigin||t.origin.endsWith(".arcgis.com"))&&"arcgis:auth:requestCredential"===t.data?.type){const r=t.source;this.getCredential(e).then(e=>{r.postMessage({type:"arcgis:auth:credential",credential:{expires:e.expires,server:e.server,ssl:e.ssl,token:e.token,userId:e.userId}},t.origin)}).catch(e=>{r.postMessage({type:"arcgis:auth:error",error:{name:e.name,message:e.message}},t.origin)})}})}disablePostMessageAuth(){this._postMessageAuthHandle&&(this._postMessageAuthHandle.remove(),this._postMessageAuthHandle=null)}_getOAuthLocationParams(){let e=window.location.hash;if(e){e.startsWith("#")&&(e=e.slice(1));const t=g(e);let r=!1;if(t.access_token&&t.expires_in&&t.state&&t.hasOwnProperty("username"))try{t.state=JSON.parse(t.state),t.state.portalUrl&&(this._oAuthLocationParams=t,r=!0)}catch{}else if(t.error&&t.error_description&&(console.log("IdentityManager OAuth Error: ",t.error," - ",t.error_description),"access_denied"===t.error&&(r=!0,t.state)))try{t.state=JSON.parse(t.state)}catch{}r&&(window.location.hash=t.state?.hash||"")}let t=window.location.search;if(t){t.startsWith("?")&&(t=t.slice(1));const e=g(t);let r=!1;if(e.code&&e.state)try{e.state=JSON.parse(e.state),e.state.portalUrl&&e.state.uid&&(this._oAuthLocationParams=e,r=!0)}catch{}else if(e.error&&e.error_description&&(console.log("IdentityManager OAuth Error: ",e.error," - ",e.error_description),"access_denied"===e.error&&(r=!0,e.state)))try{e.state=JSON.parse(e.state)}catch{}if(r){const t={...e};["code","error","error_description","message_code","persist","state"].forEach(e=>{delete t[e]});const r=v(t),s=window.location.pathname+(r?`?${r}`:"")+(e.state?.hash||"");window.history.replaceState(window.history.state,"",s)}}}_getOAuthToken(e,t,r,i,o){return e=e.replace(/^http:/i,"https:"),s(`${e}/sharing/rest/oauth2/token`,{authMode:"anonymous",method:"post",query:i&&o?{grant_type:"authorization_code",code:t,redirect_uri:i,client_id:r,code_verifier:o}:{grant_type:"refresh_token",refresh_token:t,client_id:r}}).then(e=>e.data)}async _getCodeChallenge(e){if(e&&globalThis.isSecureContext){const t=(new TextEncoder).encode(e),r=await crypto.subtle.digest("SHA-256",t);return m(new Uint8Array(r))}return null}_pageShowHandler(e){if(e.persisted&&this.isBusy()&&this._rejectOnPersistedPageShow){const e=new i("identity-manager:user-aborted","ABORTED");this._errbackFunc(e)}}_findCredential(e,t){let r,s,i,o,n=-1;const a=t?.token,h=t?.resource,l=this._isServerRsrc(e)?"server":"portal",c=this.credentials.filter(t=>this._hasSameServerInstance(t.server,e)&&t.scope===l);if(e=h||e,c.length)if(1===c.length){if(r=c[0],i=this.findServerInfo(r.server),s=i?.owningSystemUrl,o=s?this.findCredential(s,r.userId):void 0,n=this._getIdenticalSvcIdx(e,r),!a)return-1===n&&r.resources.push(e),this._addResource(e,o),r;-1!==n&&(r.resources.splice(n,1),this._removeResource(e,o))}else{let t,r;if(c.some(a=>(r=this._getIdenticalSvcIdx(e,a),-1!==r&&(t=a,i=this.findServerInfo(t.server),s=i?.owningSystemUrl,o=s?this.findCredential(s,t.userId):void 0,n=r,!0))),a)t&&(t.resources.splice(n,1),this._removeResource(e,o));else if(t)return this._addResource(e,o),t}}_findOAuthInfo(e){let t=this.findOAuthInfo(e);if(!t)for(const r of this.oAuthInfos)if(this._isIdProvider(r.portalUrl,e)){t=r;break}return t}_addResource(e,t){t&&-1===this._getIdenticalSvcIdx(e,t)&&t.resources.push(e)}_removeResource(e,t){let r=-1;t&&(r=this._getIdenticalSvcIdx(e,t),r>-1&&t.resources.splice(r,1))}_useProxy(e,t){return t?.isAdmin&&!_(e.adminTokenServiceUrl,this._appOrigin)||!this._isPortalDomain(e.tokenServiceUrl)&&"10.1"===String(e.currentVersion)&&!_(e.tokenServiceUrl,this._appOrigin)}_getOrigin(e){const t=new f(e);return t.scheme+"://"+t.host+(null!=t.port?":"+t.port:"")}_getServerInstanceRoot(e){const t=e.toLowerCase();let r=t.indexOf(this._agsRest);return-1===r&&this._isAdminResource(e)&&(r=this._agsAdmin.test(e)?e.replace(this._agsAdmin,"$1").length:e.search(this._adminSvcs)),-1!==r||P(t)||(r=t.indexOf("/sharing")),-1===r&&t.endsWith("/")&&(r=t.length-1),r>-1?e.slice(0,r):e}_hasSameServerInstance(e,t){return e.endsWith("/")&&(e=e.slice(0,-1)),e=e.toLowerCase(),t=this._getServerInstanceRoot(t).toLowerCase(),e=R(e),t=R(t),(e=e.slice(Math.max(0,e.indexOf(":"))))===(t=t.slice(Math.max(0,t.indexOf(":"))))}_sanitizeUrl(e){const r=(t.request.proxyUrl||"").toLowerCase(),s=r?e.toLowerCase().indexOf(r+"?"):-1;return-1!==s&&(e=e.slice(s+r.length+1)),e=S(e),p(e).path}_isRESTService(e){return e.includes(this._agsRest)}_isAdminResource(e){return this._agsAdmin.test(e)||this._adminSvcs.test(e)}_isServerRsrc(e){return this._isRESTService(e)||this._isAdminResource(e)}_isIdenticalService(e,t){let r=!1;if(this._isRESTService(e)&&this._isRESTService(t)){const s=this._getSuffix(e).toLowerCase(),i=this._getSuffix(t).toLowerCase();if(r=s===i,!r){const e=/(.*)\/(MapServer|FeatureServer|UtilityNetworkServer).*/gi;r=s.replaceAll(e,"$1")===i.replaceAll(e,"$1")}}else this._isAdminResource(e)&&this._isAdminResource(t)?r=!0:this._isServerRsrc(e)||this._isServerRsrc(t)||!this._isPortalDomain(e)||(r=!0);return r}_isPortalDomain(e){const r=new f(e.toLowerCase()),s=this._portalConfig;let i=this._gwDomains.some(e=>e.regex.test(r.uri));return!i&&s&&(i=this._hasSameServerInstance(this._getServerInstanceRoot(s.restBaseUrl),r.uri)),i||t.portalUrl&&(i=_(r,t.portalUrl,!0)),i||(i=this._portals.some(e=>this._hasSameServerInstance(e,r.uri))),i=i||this._agsPortal.test(r.path),i}_isIdProvider(e,t){let r=-1,s=-1;this._gwDomains.forEach((i,o)=>{-1===r&&i.regex.test(e)&&(r=o),-1===s&&i.regex.test(t)&&(s=o)});let i=!1;if(r>-1&&s>-1&&(0===r||4===r?0!==s&&4!==s||(i=!0):1===r?1!==s&&2!==s||(i=!0):2===r?2===s&&(i=!0):3===r&&3===s&&(i=!0)),!i){const r=this.findServerInfo(t),s=r?.owningSystemUrl;s&&D(r)&&this._isPortalDomain(s)&&this._isIdProvider(e,s)&&(i=!0)}return i}_getIdenticalSvcIdx(e,t){let r=-1;for(let s=0;s<t.resources.length;s++){const i=t.resources[s];if(this._isIdenticalService(e,i)){r=s;break}}return r}_getSuffix(e){return e.replace(this._regexSDirUrl,"").replace(this._regexServerType,"$1")}_getTokenSvcUrl(e){let t,r,i;if(this._isRESTService(e)||this._isAdminResource(e)){const i=this._getServerInstanceRoot(e);return t=i+"/admin/generateToken",r=s(e=i+"/rest/info",{query:{f:"json"}}).then(e=>e.data),{adminUrl:t,promise:r}}if(this._isPortalDomain(e)){let t="";if(this._gwDomains.some(r=>(r.regex.test(e)&&(t=r.tokenServiceUrl),!!t)),t||this._portals.some(r=>(this._hasSameServerInstance(r,e)&&(t=r+this._gwTokenUrl),!!t)),t||(i=e.toLowerCase().indexOf("/sharing"),-1!==i&&(t=e.slice(0,i)+this._gwTokenUrl)),t||(t=this._getOrigin(e)+this._gwTokenUrl),t){const r=new f(e).port;/^http:\/\//i.test(e)&&"7080"===r&&(t=t.replace(/:7080/i,":7443")),t=t.replace(/http:/i,"https:")}return t}}_processOAuthResponseParams(e,t,r){const s=t._oAuthCred;if(e.code){const i=s.codeVerifier;return s.codeVerifier=null,s.stateUID=null,s.save(),this._getOAuthToken(r.server,e.code,t.appId,this._getRedirectURI(t,!0),i).then(i=>{const o=new L({userId:i.username,server:r.server??void 0,token:i.access_token,expires:Date.now()+1e3*i.expires_in,ssl:i.ssl,oAuthState:e.state,_oAuthCred:s});return t.userId=o.userId,s.storage=i.persist?q:j,s.refreshToken=i.refresh_token,s.token=null,s.expires=i.refresh_token_expires_in?Date.now()+1e3*i.refresh_token_expires_in:null,s.userId=o.userId,s.ssl=o.ssl,s.save(),o})}const i=new L({userId:e.username,server:r.server??void 0,token:e.access_token,expires:Date.now()+1e3*Number(e.expires_in),ssl:"true"===e.ssl,oAuthState:e.state,_oAuthCred:s});return t.userId=i.userId,s.storage=e.persist?q:j,s.refreshToken=null,s.token=i.token,s.expires=i.expires,s.userId=i.userId,s.ssl=i.ssl,s.save(),Promise.resolve(i)}_processOAuthPopupParams(e){const t=this._oAuthDfd;if(this._oAuthDfd=null,t)if(clearInterval(this._oAuthIntervalId),this._oAuthOnPopupHandle?.remove(),e.error){const r="access_denied"===e.error,s=new i(r?"identity-manager:user-aborted":"identity-manager:authentication-failed",r?"ABORTED":"OAuth: "+e.error+" - "+e.error_description);t.reject(s)}else this._processOAuthResponseParams(e,t.oinfo_,t.sinfo_).then(e=>{t.resolve(e)}).catch(e=>{t.reject(e)})}_setOAuthResponseQueryString(e){e&&(e.startsWith("?")&&(e=e.slice(1)),this._processOAuthPopupParams(g(e)))}async _exchangeToken(e,t,r){return(await s(`${e}/sharing/rest/oauth2/exchangeToken`,{authMode:"anonymous",method:"post",query:{f:"json",client_id:t,token:r}})).data.token}async _getPlatformSelf(e,t){if(this._getPlatformSelfError&&Date.now()-this._getPlatformSelfError[1]<1e3)throw this._getPlatformSelfError[0];e=e.replace(/^http:/i,"https:");try{const r=await s(`${e}/sharing/rest/oauth2/platformSelf`,{authMode:"anonymous",headers:{"X-Esri-Auth-Client-Id":t,"X-Esri-Auth-Redirect-Uri":window.location.href.replace(/#.*$/,"")},method:"post",query:{f:"json",expiration:30},withCredentials:!0});return this._getPlatformSelfError=null,r.data}catch(r){throw"OAUTH_0066"===r.details?.messageCode&&(this._getPlatformSelfError=[r,Date.now()]),r}}_getPortalSelf(e,t){let r;if(this._gwDomains.some(t=>(t.regex.test(e)&&(r=t.customBaseUrl),!!r)),r)return Promise.resolve({allSSL:!0,currentVersion:"8.4",customBaseUrl:r,portalMode:"multitenant",supportsOAuth:!0});this._appOrigin.startsWith("https:")?e=e.replace(/^http:/i,"https:").replace(/:7080/i,":7443"):/^http:/i.test(t)&&(e=e.replace(/^https:/i,"http:").replace(/:7443/i,":7080"));return s(e,{query:{f:"json"},authMode:"anonymous",withCredentials:!0}).then(e=>e.data)}_doPortalSignIn(e){const t=this._portalConfig,r=window.location.href,s=this.findServerInfo(e);return!(!t&&!this._isPortalDomain(r)||!(s?s.hasPortal||s.owningSystemUrl&&this._isPortalDomain(s.owningSystemUrl):this._isPortalDomain(e))||!(this._isIdProvider(r,e)||t&&(this._hasSameServerInstance(this._getServerInstanceRoot(t.restBaseUrl),e)||this._isIdProvider(t.restBaseUrl,e))||_(r,e,!0)))}_checkProtocol(e,t,r,s){let o=!0;const n=s?t.adminTokenServiceUrl:t.tokenServiceUrl;if(n.trim().toLowerCase().startsWith("https:")&&!this._appOrigin.startsWith("https:")&&w(n)&&(o=!!this._protocolFunc&&!!this._protocolFunc({resourceUrl:e,serverInfo:t}),!o)){r(new i("identity-manager:aborted","Aborted the Sign-In process to avoid sending password over insecure connection."))}return o}_enqueue(e,t,r,s,i,o){return s||(s=c()),s.resUrl_=e,s.sinfo_=t,s.options_=r,s.admin_=i,s.refresh_=o,this._busy?this._hasSameServerInstance(this._getServerInstanceRoot(e),this._busy.resUrl_)?(this._oAuthDfd&&this._oAuthDfd.oAuthWin_&&this._oAuthDfd.oAuthWin_.focus(),this._soReqs.push(s)):this._xoReqs.push(s):this._doSignIn(s),s.promise}_doSignIn(e){this._busy=e,this._rejectOnPersistedPageShow=!1;const t=t=>{const r=e.options_?.resource,s=e.resUrl_,i=e.refresh_;let o=!1;this.credentials.includes(t)||(i&&this.credentials.includes(i)?(i.userId=t.userId,i.token=t.token,i.expires=t.expires,i.validity=t.validity,i.ssl=t.ssl,i.creationTime=t.creationTime,o=!0,t=i):this.credentials.push(t)),t.resources||(t.resources=[]),t.resources.includes(r||s)||t.resources.push(r||s),t.scope=this._isServerRsrc(s)?"server":"portal",t.emitTokenChange();const n=this._soReqs,a={};this._soReqs=[],n.forEach(e=>{if(!this._isIdenticalService(s,e.resUrl_)){const r=this._getSuffix(e.resUrl_);a[r]||(a[r]=!0,t.resources.push(e.resUrl_))}}),e.resolve(t),n.forEach(e=>{this._hasSameServerInstance(this._getServerInstanceRoot(s),e.resUrl_)?e.resolve(t):this._soReqs.push(e)}),this._busy=e.resUrl_=e.sinfo_=e.refresh_=null,o||this.emit("credential-create",{credential:t}),this._soReqs.length?this._doSignIn(this._soReqs.shift()):this._xoReqs.length&&this._doSignIn(this._xoReqs.shift())},r=t=>{e.reject(t),this._busy=e.resUrl_=e.sinfo_=e.refresh_=null,this._soReqs.length?this._doSignIn(this._soReqs.shift()):this._xoReqs.length&&this._doSignIn(this._xoReqs.shift())},s=(o,n,h,l)=>{const c=e.sinfo_,u=!e.options_||!1!==e.options_.prompt,p=c.hasPortal&&this._findOAuthInfo(e.resUrl_);let f,g;if(o)t(new L({userId:o,server:c.server??void 0,token:h??void 0,expires:null!=l?Number(l):null,ssl:!!n}));else if(window!==window.parent&&this._appUrlObj.query?.["arcgis-auth-origin"]&&this._appUrlObj.query?.["arcgis-auth-portal"]&&this._hasSameServerInstance(this._getServerInstanceRoot(this._appUrlObj.query["arcgis-auth-portal"]),e.resUrl_)){window.parent.postMessage({type:"arcgis:auth:requestCredential"},this._appUrlObj.query["arcgis-auth-origin"]);const s=a(window,"message",e=>{e.source===window.parent&&e.data&&("arcgis:auth:credential"===e.data.type?(s.remove(),e.data.credential.expires<Date.now()?r(new i("identity-manager:credential-request-failed","Parent application's token has expired.")):t(new L(e.data.credential))):"arcgis:auth:error"===e.data.type&&(s.remove(),"tokenExpiredError"===e.data.error.name?r(new i("identity-manager:credential-request-failed","Parent application's token has expired.")):r(i.fromJSON(e.data.error))))});d(e.options_?.signal,()=>{s.remove()})}else if(p){let o=p._oAuthCred;if(!o){const e=new T(p,q),t=new T(p,j);e.isValid()&&t.isValid()?e.expires>t.expires?(o=e,t.destroy()):(o=t,e.destroy()):o=e.isValid()?e:t,p._oAuthCred=o}if(o.isValid()){f=new L({userId:o.userId??void 0,server:c.server??void 0,token:o.token??void 0,expires:o.expires,ssl:o.ssl??void 0,_oAuthCred:o});const i=p.appId!==o.appId&&this._doPortalSignIn(e.resUrl_);i||o.refreshToken?(e._pendingDfd=o.refreshToken?this._getOAuthToken(c.server,o.refreshToken,o.appId).then(e=>(f.expires=Date.now()+1e3*e.expires_in,f.token=e.access_token,f)):Promise.resolve(f),e._pendingDfd.then(e=>i?this._exchangeToken(e.server,p.appId,e.token).then(t=>(e.token=t,e)).catch(()=>e):e).then(e=>{t(e)}).catch(e=>{const t=e.details?.httpStatus;t>0&&404!==t?(o.destroy(),s()):r(e)})):t(f)}else if(this._oAuthLocationParams&&this._hasSameServerInstance(p.portalUrl,this._oAuthLocationParams.state.portalUrl)&&(this._oAuthLocationParams.access_token||this._oAuthLocationParams.code&&this._oAuthLocationParams.state.uid===o.stateUID&&o.codeVerifier)){const s=this._oAuthLocationParams;this._oAuthLocationParams=null,e._pendingDfd=this._processOAuthResponseParams(s,p,c).then(e=>{t(e)}).catch(r)}else{const s=()=>{u?e._pendingDfd=this.oAuthSignIn(e.resUrl_,c,p,e.options_).then(t,r):(g=new i("identity-manager:not-authenticated","User is not signed in."),r(g))};this._doPortalSignIn(e.resUrl_)?e._pendingDfd=this._getPlatformSelf(c.server,p.appId).then(e=>{_(e.portalUrl,this._appOrigin,!0)?(f=new L({userId:e.username,server:c.server??void 0,expires:Date.now()+1e3*e.expires_in,token:e.token}),t(f)):s()}).catch(s):s()}}else if(u){if(this._checkProtocol(e.resUrl_,c,r,e.admin_)){let s=e.options_;e.admin_&&(s=s||{},s.isAdmin=!0),e._pendingDfd=this.signIn(e.resUrl_,c,s).then(t,r)}}else g=new i("identity-manager:not-authenticated","User is not signed in."),r(g)},o=()=>{const s=e.sinfo_,i=s.owningSystemUrl,o=e.options_;let n,a,h,l;if(o&&(n=o.token,a=o.error,h=o.prompt),l=this._findCredential(i,{token:n,resource:e.resUrl_}),!l)for(const e of this.credentials)if(this._isIdProvider(i,e.server)){l=e;break}if(l){const i=this.findCredential(e.resUrl_,l.userId);if(i)t(i);else if(b(s,this._legacyFed)){const e=l.toJSON();e.server=s.server,e.resources=null,t(new L(e))}else{(e._pendingDfd=this.generateToken(this.findServerInfo(l.server),null,{serverUrl:e.resUrl_,token:l.token,signal:e.options_.signal,ssl:l.ssl})).then(r=>{t(new L({userId:l?.userId,server:s.server??void 0,token:r.token,expires:null!=r.expires?Number(r.expires):null,ssl:!!r.ssl,isAdmin:e.admin_,validity:r.validity}))},r)}}else{this._busy=null,n&&(e.options_.token=null);(e._pendingDfd=this.getCredential(i.replace(/\/?$/,"/sharing"),{resource:e.resUrl_,owningTenant:s.owningTenant,signal:e.options_.signal,token:n,error:a,prompt:h})).then(()=>{this._enqueue(e.resUrl_,e.sinfo_,e.options_,e,e.admin_)},t=>{e.resUrl_=e.sinfo_=e.refresh_=null,e.reject(t)})}};this._errbackFunc=r;const n=e.sinfo_.owningSystemUrl,h=this._isServerRsrc(e.resUrl_),c=e.sinfo_._restInfoPms;c?c.promise.then(t=>{const r=e.sinfo_;if(r._restInfoPms){r.adminTokenServiceUrl=r._restInfoPms.adminUrl,r._restInfoPms=null,r.tokenServiceUrl=(l("authInfo.tokenServicesUrl",t)||l("authInfo.tokenServiceUrl",t)||l("tokenServiceUrl",t))??null,r.shortLivedTokenValidity=l("authInfo.shortLivedTokenValidity",t)??null,r.currentVersion=t.currentVersion,r.owningTenant=t.owningTenant;const e=r.owningSystemUrl=t.owningSystemUrl;e&&this._portals.push(e)}h&&r.owningSystemUrl?o():s()},()=>{e.sinfo_._restInfoPms=null;const t=new i("identity-manager:server-identification-failed","Unknown resource - could not find token service endpoint.");r(t)}):h&&n?o():e.sinfo_._selfReq?e.sinfo_._selfReq.selfDfd.then(t=>{const r={};let s,i,o,n;return t&&(s=t.user?.username,r.username=s,r.allSSL=t.allSSL,i=t.supportsOAuth,n=parseFloat(t.currentVersion),"multitenant"===t.portalMode&&(o=t.customBaseUrl),e.sinfo_.currentVersion=n),e.sinfo_.webTierAuth=!!s,s&&this.normalizeWebTierAuth?this.generateToken(e.sinfo_,null,{ssl:r.allSSL}).catch(()=>null).then(e=>(r.portalToken=e?.token,r.tokenExpiration=e?.expires,r)):!s&&i&&n>=4.4&&!this._findOAuthInfo(e.resUrl_)?this._generateOAuthInfo({portalUrl:e.sinfo_.server,customBaseUrl:o,owningTenant:e.sinfo_._selfReq.owningTenant}).catch(()=>null).then(()=>r):r}).catch(()=>null).then(t=>{e.sinfo_._selfReq=null,t?s(t.username,t.allSSL,t.portalToken,t.tokenExpiration):s()}):s()}_generateOAuthInfo(e){let t,r=null,i=e.portalUrl;const o=e.customBaseUrl,n=e.owningTenant,a=!this._defaultOAuthInfo&&this._createDefaultOAuthInfo&&!this._hasTestedIfAppIsOnPortal;if(a){r=this._appUrlObj.path;const e=r.search(/\/(apps|home)\//);r=e>-1?r.slice(0,e):null}return a&&r?(this._hasTestedIfAppIsOnPortal=!0,t=s(r+"/sharing/rest",{query:{f:"json"}}).then(()=>{this._defaultOAuthInfo=new x({appId:"arcgisonline",popupCallbackUrl:r+"/home/oauth-callback.html"})})):t=Promise.resolve(),t.then(()=>{if(this._defaultOAuthInfo)return i=i.replace(/^http:/i,"https:"),s(i+"/sharing/rest/oauth2/validateRedirectUri",{query:{accountId:n,client_id:this._defaultOAuthInfo.appId,redirect_uri:I(this._defaultOAuthInfo.popupCallbackUrl),f:"json"}}).then(e=>{if(e.data.valid){const t=this._defaultOAuthInfo.clone();e.data.urlKey&&o?t.portalUrl="https://"+e.data.urlKey.toLowerCase()+"."+o:t.portalUrl=i,t.popup=window!==window.top||!(_(i,this._appOrigin)||this._gwDomains.some(e=>e.regex.test(i)&&e.regex.test(this._appOrigin))),this.oAuthInfos.push(t)}})})}_doOAuthSignIn(e,t,r,s){const o=r._oAuthCred,n={portalUrl:r.portalUrl};!r.popup&&r.preserveUrlHash&&window.location.hash&&(n.hash=window.location.hash),o.stateUID&&(n.uid=o.stateUID);const h={client_id:r.appId,response_type:o.codeVerifier?"code":"token",state:JSON.stringify(n),expiration:r.expiration,locale:r.locale,redirect_uri:this._getRedirectURI(r,!!o.codeVerifier)};r.forceLogin&&(h.force_login=!0),r.forceUserId&&r.userId&&(h.prepopulatedusername=r.userId),!r.popup&&this._doPortalSignIn(e)&&(h.redirectToUserOrgUrl=!0),o.codeVerifier&&(h.code_challenge=s||o.codeVerifier,h.code_challenge_method=s?"S256":"plain");const l=r.portalUrl.replace(/^http:/i,"https:")+"/sharing/oauth2/authorize",c=l+"?"+v(h);if(r.popup){const e=window.open(c,"esriJSAPIOAuth",r.popupWindowFeatures);if(e)e.focus(),this._oAuthDfd.oAuthWin_=e,this._oAuthIntervalId=setInterval(()=>{if(e.closed){clearInterval(this._oAuthIntervalId),this._oAuthOnPopupHandle.remove();const e=this._oAuthDfd;if(e){const t=new i("identity-manager:user-aborted","ABORTED");e.reject(t)}}},500),this._oAuthOnPopupHandle=a(window,["arcgis:auth:hash","arcgis:auth:location:search"],e=>{"arcgis:auth:hash"===e.type?this.setOAuthResponseHash(e.detail):this._setOAuthResponseQueryString(e.detail)});else{const e=new i("identity-manager:popup-blocked","ABORTED");this._oAuthDfd.reject(e)}}else this._rejectOnPersistedPageShow=!0,this._oAuthRedirectFunc?this._oAuthRedirectFunc({authorizeParams:h,authorizeUrl:l,resourceUrl:e,serverInfo:t,oAuthInfo:r}):window.location.href=c}_getRedirectURI(e,t){const r=window.location.href.replace(/#.*$/,"");if(e.popup)return I(e.popupCallbackUrl);if(t){const e=p(r);return e.query&&["code","error","error_description","message_code","persist","state"].forEach(t=>{delete e.query[t]}),k(e.path,e.query)}return r}}E.prototype.declaredClass="esri.identity.IdentityManagerBase";let L=class extends n{constructor(e){super(e),this._oAuthCred=null,this.tokenRefreshBuffer=2,e?._oAuthCred&&(this._oAuthCred=e._oAuthCred)}initialize(){this.resources=this.resources||[],null==this.creationTime&&(this.creationTime=Date.now())}refreshToken(){const e=r,t=e.findServerInfo(this.server),s=t?.owningSystemUrl,i=!!s&&"server"===this.scope,o=i&&b(t,e._legacyFed),n=t.webTierAuth,a=n&&e.normalizeWebTierAuth,h=C[this.server],l=h?.[this.userId];let c,d=this.resources&&this.resources[0],u=i?e.findServerInfo(s):null,p={username:this.userId,password:l};if(n&&!a)return;i&&!u&&e.serverInfos.some(t=>(e._isIdProvider(s,t.server)&&(u=t),!!u));const _=u?e.findCredential(u.server,this.userId):null;if(!i||_){if(!o){if(i)c={serverUrl:d,token:_?.token,ssl:_?.ssl};else if(a)p=null,c={ssl:this.ssl};else{if(!l){let r;return d&&(d=e._sanitizeUrl(d),this._enqueued=1,r=e._enqueue(d,t,null,null,this.isAdmin,this),r.then(()=>{this._enqueued=0,this.refreshServerTokens()}).catch(()=>{this._enqueued=0})),r}this.isAdmin&&(c={isAdmin:!0})}return e.generateToken(i?u:t,i?null:p,c).then(e=>{this.token=e.token,this.expires=null!=e.expires?Number(e.expires):null,this.creationTime=Date.now(),this.validity=e.validity,this.emitTokenChange(),this.refreshServerTokens()}).catch(()=>{})}_?.refreshToken()}}refreshServerTokens(){if("portal"===this.scope){const e=r;e.credentials.forEach(t=>{const r=e.findServerInfo(t.server),s=r?.owningSystemUrl;t!==this&&t.userId===this.userId&&s&&"server"===t.scope&&(e._hasSameServerInstance(this.server,s)||e._isIdProvider(s,this.server))&&(b(r,e._legacyFed)?(t.token=this.token,t.expires=this.expires,t.creationTime=this.creationTime,t.validity=this.validity,t.emitTokenChange()):t.refreshToken())})}}emitTokenChange(e){clearTimeout(this._refreshTimer);const t=r,s=this.server?t.findServerInfo(this.server):null,i=s?.owningSystemUrl,o=i?t.findServerInfo(i):null;!1===e||i&&"portal"!==this.scope&&(!o?.webTierAuth||t.normalizeWebTierAuth)||null==this.expires&&null==this.validity||this._startRefreshTimer(),this.emit("token-change")}destroy(){this.userId=this.server=this.token=this.expires=this.validity=this.resources=this.creationTime=null,this._oAuthCred&&(this._oAuthCred.destroy(),this._oAuthCred=null);const e=r,t=e.credentials.indexOf(this);t>-1&&e.credentials.splice(t,1),this.emitTokenChange(),this.emit("destroy")}toJSON(){const e=h({userId:this.userId,server:this.server,token:this.token,expires:this.expires,validity:this.validity,ssl:this.ssl,isAdmin:this.isAdmin,creationTime:this.creationTime,scope:this.scope}),t=this.resources;return t&&t.length>0&&(e.resources=t.slice()),e}_startRefreshTimer(){clearTimeout(this._refreshTimer);const e=6e4*this.tokenRefreshBuffer,t=2**31-1;let r=(this.validity?this.creationTime+6e4*this.validity:this.expires)-Date.now();r<0?r=0:r>t&&(r=t),this._refreshTimer=setTimeout(this.refreshToken.bind(this),r>e?r-e:r)}};e([A()],L.prototype,"creationTime",void 0),e([A()],L.prototype,"expires",void 0),e([A()],L.prototype,"isAdmin",void 0),e([A()],L.prototype,"oAuthState",void 0),e([A()],L.prototype,"resources",void 0),e([A()],L.prototype,"scope",void 0),e([A()],L.prototype,"server",void 0),e([A()],L.prototype,"ssl",void 0),e([A()],L.prototype,"token",void 0),e([A()],L.prototype,"tokenRefreshBuffer",void 0),e([A()],L.prototype,"userId",void 0),e([A()],L.prototype,"validity",void 0),L=e([y("esri.identity.Credential")],L);export{L as Credential,E as IdentityManagerBase};