/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
function r(r,n){const c={};n=n||{continueOnCircularDependency:!1};const o=[],s={};r.forEach(r=>{const t=r[0];let n;(n=c[t])||(n=c[t]=new e(t)),r.forEach(r=>{r!==t&&(c[r]||(c[r]=new e(r)),n.afters.push(r))})});const i=Object.keys(c);return i.sort(t),i.forEach(function r(e,i){const u=c[e],a=u.id;if(s[e])return;const f=Array.isArray(i)?i:[];f.push(a),s[e]=!0,u.afters.sort(t),u.afters.forEach(e=>{if(f.includes(e)){if(n?.continueOnCircularDependency)return;throw new Error("Circular chain found: "+a+" must be before "+e+" due to a direct order specification, but "+e+" must be before "+a+" based on other specifications.")}r(e,f.slice())}),o.push(a)}),o.reverse()}class e{constructor(r){this.id=r,this.afters=[]}}function t(r,e){return r<e?1:r>e?-1:0}export{r as dependencySort};
