/* COPYRIGHT Esri - https://js.arcgis.com/1.2/LICENSE.txt */
import a from"./YFLYHPA6.js";import{ta as c}from"./TRGFYBOH.js";export default $arcgis.t(([{a:p}])=>{async function R(o,r){let s=await h(r,o),l=[],a=[],d=[],u=s.map(async e=>{let m=await S(e.id,"reverse","Solution2Item",o);return{template:e,relatedItems:m}}),f=await Promise.all(u);for(let{template:e,relatedItems:m}of f)for(let w of m){let I=[];for(let t of w.relatedItemIds)I.push({controlItemId:e.id,dependencyItemId:t});let D=I.reduce((t,n)=>(t[n.controlItemId]||(t[n.controlItemId]=new Set),t[n.controlItemId].add(n.dependencyItemId),t),{}),i=Object.entries(D).filter(([t,n])=>n.size>1).flatMap(([t,n])=>Array.from(n).map(g=>({controlItemId:t,dependencyItemId:g})));i.length>0&&(d=d.concat(i))}a=Array.from(new Map([...d].map(e=>[`${e.controlItemId}:${e.dependencyItemId}`,e])).values());let y=a.map(e=>e.controlItemId);return l=[...new Set(y)],{uniqueIitemIds:l,_nonSolutionDependencyItems:a,templateInfos:s}}async function S(o,r,s,l){let a=await c(o,s,r,l);return[{relationshipType:s,relatedItemIds:a.relatedItems.map(d=>d.id)}]}async function h(o,r){return await p(o.id,r)}return{a:R,b:h}},a)