/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["require","exports","../../../chunks/_rollupPluginBabelHelpers","../../../core/Error","../../../core/maybe","../../../core/promiseUtils","../../../core/urlUtils","../../Point"],(function(e,n,t,r,o,s,i,l){"use strict";const u=e=>Object.freeze(Object.defineProperty({__proto__:null,default:e},Symbol.toStringTag,{value:"Module"}));function a(e,n,t){return c.apply(this,arguments)}function c(){return(c=t._asyncToGenerator((function*(n,t,r){const{loadGLTFMesh:i}=yield s.whenOrAbort(new Promise(((n,t)=>e(["./loadGLTFMesh"],n,t))),r),u=yield p(t,r),a=i(new l({x:0,y:0,z:0,spatialReference:n.spatialReference}),u.url,{resolveFile:f(u),useTransform:!0,signal:o.isSome(r)?r.signal:null});a.then((()=>u.dispose()),(()=>u.dispose()));const{vertexAttributes:c,components:y}=yield a;n.vertexAttributes=c,n.components=y}))).apply(this,arguments)}function f(e){const n=i.removeFile(e.url);return t=>{var r;const o=i.makeRelative(t,n,n),s=o?o.replace(/^ *\.\//,""):null;return null!=(r=e.files.get(s))?r:t}}function p(e,n){return y.apply(this,arguments)}function y(){return(y=t._asyncToGenerator((function*(e,n){return e instanceof Blob?w.fromBlob(e):"string"==typeof e?new w(e):Array.isArray(e)?d(e,n):m(e,n)}))).apply(this,arguments)}function d(e,n){return h.apply(this,arguments)}function h(){return h=t._asyncToGenerator((function*(e,n){const i=new Map;let l=null;const u=yield s.eachAlwaysValues(e.map(function(){var e=t._asyncToGenerator((function*(e){return{name:e.name,source:yield p(e instanceof Blob?e:e.source,n)}}));return function(n){return e.apply(this,arguments)}}())),a=[];for(const t of u)t&&(s.isAborted(n)?t.source.dispose():a.push(t));s.throwIfAborted(n);for(const{name:t,source:r}of a)(o.isNone(l)||/\.(gltf|glb)/i.test(t))&&(l=r.url),i.set(t,r.url),r.files&&r.files.forEach(((e,n)=>i.set(n,e)));if(o.isNone(l))throw new r("mesh-load-external:missing-files","Missing files to load external mesh source");return new w(l,(()=>a.forEach((({source:e})=>e.dispose()))),i)})),h.apply(this,arguments)}function m(e,n){return b.apply(this,arguments)}function b(){return b=t._asyncToGenerator((function*(n,r){const{default:o}=yield s.whenOrAbort(new Promise(((n,t)=>e(["../../../request"],(e=>n(u(e))),t))),r),i="string"==typeof n.multipart[0]?yield Promise.all(n.multipart.map(function(){var e=t._asyncToGenerator((function*(e){return(yield o(e,{responseType:"array-buffer"})).data}));return function(n){return e.apply(this,arguments)}}())):n.multipart;return w.fromBlob(new Blob(i))})),b.apply(this,arguments)}let w=function(){function e(e,n=(()=>{}),t=new Map){this.url=e,this.dispose=n,this.files=t}return e.fromBlob=function(n){const t=URL.createObjectURL(n);return new e(t,(()=>URL.revokeObjectURL(t)))},e}();n.loadExternal=a,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
