/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import e from"../../core/Error.js";import{getLayersWithChartSupport as r}from"../../layers/support/layerUtils.js";async function o(e){const r=[];for(const o of e.allLayers)if("beforeSave"in o&&"function"==typeof o.beforeSave){const e=o.beforeSave();e&&r.push(e)}await Promise.allSettled(r)}const t=new Set(["layer:unsupported","property:unsupported","symbol:unsupported","symbol-layer:unsupported","url:unsupported"]);function s(r,o,s){let n=(r.messages??[]).filter(({type:e})=>"error"===e).map(({name:r,message:o,details:t})=>new e(r,o,t));if(r.blockedRelativeUrls&&(n=n.concat(r.blockedRelativeUrls.map(r=>new e("url:unsupported",`Relative url '${r}' is not supported`)))),s){const{ignoreUnsupported:e,supplementalUnsupportedErrors:r=[],requiredPropertyChecksDisabled:o}=s;e&&(n=n.filter(({name:e})=>!(t.has(e)||r.includes(e)))),o&&(n=n.filter(e=>"web-document-write:property-required"!==e.name))}if(n.length>0)throw new e(o.errorName,"Failed to save due to unsupported or invalid content. See 'details.errors' for more detailed information",{errors:n})}function n(e){return r(e).some(e=>!!e.charts?.length)}export{o as beforeSave,s as evaluateWriteErrors,n as hasCharts};
