UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 1.14 kB
import{makeData as e,isAbsolute as a,join as r,isDataProtocol as t,dataComponents as i}from"../../core/urlUtils.js";import{f as n,w as l}from"../../chunks/persistableUrlUtils.js";function o(a,r,t){return r.imageData?e({mediaType:r.contentType||"image/png",isBase64:!0,data:r.imageData}):s(r.url,t)}function s(e,t){return p(t)&&!a(e)&&t?.layer?.parsedUrl?r(t.layer.parsedUrl.path,"images",e):n(e,t)}function u(e,a,r,n){if(t(e)){const t=i(e);if(!t)return;a.contentType=t.mediaType,a.imageData=t.data,r&&r.imageData===a.imageData&&r.url&&l(r.url,a,"url",n)}else l(e,a,"url",n)}const m={json:{read:{source:["imageData","url"],reader:o},write:{writer(e,a,r,t){u(e,a,this.source,t)}}}},c={readOnly:!0,json:{read:{source:["imageData","url"],reader(e,a,r){const t={};return a.imageData&&(t.imageData=a.imageData),a.contentType&&(t.contentType=a.contentType),a.url&&(t.url=s(a.url,r)),t}}}};function p(e){return!(null==e||"service"!==e.origin&&"portal-item"!==e.origin||"feature"!==e.layer?.type&&"stream"!==e.layer?.type)}export{s as read,o as readImageDataOrUrl,c as sourcePropertyDefinition,m as urlPropertyDefinition,u as writeImageDataAndUrl};