/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{collectClassPaths as e}from"./utils.js";function t(e){const t=r(e),n=[],i=p(t),s=new Map;a("api","",e.api,t,i.api,s);const c=new Map;a("spec","",e.spec,t,i.spec,c);const u=o(t);for(const[a,p]of s){if("esri/rest/support/AlgorithmicColorRamp (colorRamp_algorithmic_part_schema.json) <algorithmic>"===a)continue;const e=c.get(a),t=u.get(p.container.id),o=`${p.container.name} (${e.container.name})${p.container.typeValue?` <${p.container.typeValue}>`:""}`;n.push({name:o,api:p,spec:e,indent:t})}return n}function n(e,t,p,o,r,s,c,u,l){if(c.has(o))return l;for(const f of o.properties){const m=t?`${t}.${f.name}`:f.name,d=p?`${p}.${f.name}`:f.name,g=r.get(d);if(g){const t=s.get(g[e].id);l.push({name:m,type:"ref",ref:g,refName:t,required:f.required,nullable:f.nullable}),a(e,d,g[e],r,s,u)}else"string"==typeof f.type?l.push(i(m,f)):(c.add(o),n(e,m,d,f.type,r,s,c,u,l))}return c.delete(o),l}function a(e,t,a,p,o,r){if(r.has(a.id))return r;const i={container:a,text:null,props:[]};return o.get(a.id).forEach(e=>r.set(e,i)),n(e,"",t,a,p,o,new Set,r,i.props),i.props.sort(s),r}function p(e){const t={api:new Map,spec:new Map};for(const n of e.values()){const e=`${n.api.name} (${n.spec.name})${n.api.typeValue?` <${n.api.typeValue}>`:""}`;let a=t.api.get(n.api.id);a||(a=new Set,t.api.set(n.api.id,a)),a.add(e);let p=t.spec.get(n.spec.id);p||(p=new Set,t.spec.set(n.spec.id,p)),p.add(e)}return t}function o(e){const t=new Map;for(const n of e.keys()){const a=n?n.split(".").length:0,p=e.get(n).api.id;t.has("id")?t.set(p,Math.min(a,t.get(p))):t.set(p,a)}return t}function r(t){const n=e(t.api),a=e(t.spec),p=new Map;p.set("",{api:t.api,spec:t.spec});for(const[e,o]of n){const t=a.get(e);t&&p.set(e,{api:o,spec:t})}return p}function i(e,t){return{name:e,type:t.enum||("string"==typeof t.type?t.type:""),default:JSON.stringify(t.default),required:t.required,nullable:t.nullable}}function s(e,t){const n=e.name.localeCompare(t.name);if(0!==n)return n;const a=(e.type||"").localeCompare(t.type||"");return 0!==a?a:(e.default||"").localeCompare(t.default||"")}export{t as collect};
