/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import e from"../../../../request.js";import{FileProvider as t}from"./FileProvider.js";import{parseKnownArcGISOnlineDomain as r}from"../../../../portal/support/urlUtils.js";class s extends t{constructor(e,t,s){super(t,s),this._schema=e,this._isAgol=!!r(this._schema.itemUrl)}async update(e){throw new Error("Unsupported")}async _getParquetFileNames(){return[`${this._baseUrl}/data`]}async _getStatisticsFileName(){return null}_getCacheFileName(e){return`${this._baseUrl}/data`}async _resolveFileUrl(e){return this._resolvedUrl||(this._resolvedUrl=this._fetchResolvedUrl()),this._resolvedUrl}async _fetchLengthAndTag(e){const t=await super._fetchLengthAndTag(e);return t.cacheTag=this._schema.modified.getTime().toString(),t}async _fetchRange(e,t,r,s){try{const a=await this._resolveFileUrl(e);return await super._fetchRange(a,t,r,s)}catch{this._resolvedUrl=null}const a=await this._resolveFileUrl(e);return super._fetchRange(a,t,r,s)}get _baseUrl(){return this._schema.itemCdnUrl??this._schema.itemUrl}async _fetchResolvedUrl(){if(!this._isAgol)return`${this._baseUrl}/data`;return(await e(`${this._baseUrl}/data`,{query:{signedurl:!0,expiration:9,f:"json"}})).data.signedUrl}}export{s as PortalParquetFileProvider};
