// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define("require exports ../../core/has ../../support/arcadeOnDemand ./gfxUtils ./previewUtils ./renderUtils ./utils ../../widgets/Legend/styles/support/relationshipUtils ../../widgets/Legend/support/relationshipRampUtils".split(" "),function(t,u,J,A,E,F,B,r,G,H){function I(a,b){if(b&&(a.style.filter=r.getCSSFilterFromEffectList(b),b=b.effects))for(const c of b)if("drop-shadow"===c?.type){0>c.offsetX?a.style.marginLeft=`${Math.abs(c.offsetX)}px`:a.style.marginRight=`${c.offsetX}px`;break}}async function C(a, b){switch(a.type){case "web-style":var {previewWebStyleSymbol:c}=await new Promise((g,d)=>t(["./previewWebStyleSymbol"],g,d));return c(a,C,b);case "label-3d":case "line-3d":case "mesh-3d":case "point-3d":case "polygon-3d":return{previewSymbol3D:c}=await new Promise((g,d)=>t(["./previewSymbol3D"],g,d)),c(a,b);case "simple-marker":case "simple-line":case "simple-fill":case "picture-marker":case "picture-fill":case "text":return{previewSymbol2D:c}=await new Promise((g,d)=>t(["./previewSymbol2D"],g,d)), c(a,b);case "cim":return{previewCIMSymbol:c}=await new Promise((g,d)=>t(["./previewCIMSymbol"],g,d)),c(a,b)}}function z(a){return a&&"opacity"in a?a.opacity*z(a.parent):1}function y(a){if(a)return"renderer"in a?a.renderer:void 0}let x=null;const D=[255,255,255];u.getDisplayedColor=async function(a,b){if(a){var {layer:c,sourceLayer:g}=a,d=z(c??g);if(null!=a.symbol&&(null==b||!0!==b.ignoreGraphicSymbol))return a="web-style"===a.symbol.type?await r.fetchWebStyleSymbol(a.symbol,b):a.symbol.clone(),r.getColorFromSymbol(a, d);var e=b?.renderer??y(c)??y(g),f=e&&"getSymbolAsync"in e?await e.getSymbolAsync(a,b):void 0;if(f){f="web-style"===f.type?await r.fetchWebStyleSymbol(f,b):f.clone();f=r.getColorFromSymbol(f,d);if(!(e&&"visualVariables"in e)||"visualVariables"in e&&!e.visualVariables||"visualVariables"in e&&!e.visualVariables?.length)return f;"arcadeRequiredForVisualVariables"in e&&e.arcadeRequiredForVisualVariables&&null==b?.arcade&&(b={...b},b.arcade=await A.loadArcade());var {getColor:m,getOpacity:p}=await new Promise((k, l)=>t(["../../renderers/visualVariables/support/visualVariableUtils"],k,l)),n=[],h=[];for(const k of e.visualVariables)switch(k.type){case "color":n.push(k);break;case "opacity":h.push(k)}e=(e=0t(["../../renderers/visualVariables/support/visualVariableUtils"],v,w)),n=[],h=[],k=[],l=[];for(var q of d.visualVariables)switch(q.type){case "color":n.push(q);break;case "opacity":h.push(q);break;case "rotation":l.push(q);break;case "size":q.target||k.push(q)}q=(q=!!n.length&&n[n.length-1])?e(q,a,b):null;h=(h=!!h.length&& h[h.length-1])?f(h,a,b):null;null!=c&&(h=null!=h?h*c:c);r.applyColorToSymbol(g,q,h);k.length&&(c=m(k,a,b),await r.applySizesToSymbol(g,c));for(const v of l)r.applyRotationToSymbol(g,p(v,a,b),v.axis);return g}}};u.getLegendLabel=async function(a,b,c){if(a){var {layer:g,sourceLayer:d}=a,e=c?.renderer??y(g)??y(d);if(!e)return null;if("visualVariables"in e&&e.visualVariables?.length){const {getRampStops:m}=await new Promise((k,l)=>t(["../../widgets/Legend/support/colorRampUtils"],k,l)),{getRampStops:p}= await new Promise((k,l)=>t(["../../widgets/Legend/support/sizeRampUtils"],k,l)),{getDateFormatOptions:n}=await new Promise((k,l)=>t(["../../widgets/Legend/support/utils"],k,l));let h=null;for(const k of e.visualVariables){var f=b?n(g,k,b.timeZone):null;let l=null;switch(k.type){case "color":l=await m(k,null,f);break;case "opacity":l=await m(k);break;case "size":k.target||(l=await p(e,k,null,c?.scale||b?.scale,b,f))}if(l?.length&&(f=l.find((q,v)=>{const w=a.attributes[k.field];return 0===v?w>=q.value: v===l?.length-1?w<=q.value:q.value===w}))){h=f.label;break}}if(h)return h}switch(e.type){case "class-breaks":return b="getClassBreakInfo"in e?await e.getClassBreakInfo(a,c):null,b?.label??(b&&1l.addColorStop(w*q,v.toString()));n.fillStyle=l;n.fillRect(0,0,m,p)}else{m=c?m/a.length:m;p=c?p:p/a.length;h=e=0;for(const l of a)n.fillStyle=l.toString(),n.fillRect(e,h,m,p),e= c?e+m:0,h=c?0:h+p}a=document.createElement("div");a.style.width=`${g}px`;a.style.height=`${d}px`;I(a,b?.effectList);a.appendChild(f);return a};u.renderDotDensityPreviewHTML=function(a,b,c){const {backgroundColor:g,outline:d,dotSize:e}=a;var f=c?.swatchSize||F.SymbolSizeDefaults.size;const m=Math.round(f*f/Math.max(e,.5)**2*.8),p=window.devicePixelRatio;a=document.createElement("canvas");const n=f*p;a.width=n;a.height=n;a.style.width=`${a.width/p}px`;a.style.height=`${a.height/p}px`;const h=a.getContext("2d"); g&&(h.fillStyle=g.toCss(!0),h.fillRect(0,0,n,n),h.fill());h.fillStyle=b?.toCss(!0)??"";if(x&&x.length/2===m)for(b=0;b<2*m;b+=2)h.fillRect(x[b],x[b+1],e*p,e*p),h.fill();else for(x=[],b=0;b<2*m;b+=2){const k=Math.floor(Math.random()*(n-0+1)),l=Math.floor(Math.random()*(n-0+1));x.push(k,l);h.fillRect(k,l,e*p,e*p);h.fill()}d&&(d.color&&(h.strokeStyle=d.color.toCss(!0)),h.lineWidth=d.width,h.strokeRect(0,0,n,n));f=new Image(f,f);f.src=a.toDataURL();f.ariaLabel=c?.ariaLabel??null;f.alt=c?.ariaLabel??""; return f};u.renderPieChartPreviewHTML=function(a,b={}){const c=b.radius||40;var g=2*Math.PI*c,d=a.length;const e=g/d,f=[],m=E.getStroke(b.outline);null!=m?.width&&(m.width*=2);(m||b.backgroundColor)&&f.push({shape:{type:"circle",cx:c,cy:c,r:c},fill:b.backgroundColor,stroke:m,offset:[0,0]});const p=b.values,n=p&&p.length===d&&100===p.reduce((k,l)=>k+l,0),h=[0];for(let k=0;kG.renderRelationshipRamp(e,b.id||"relationship",{opacity:b.opacity||1,effectList:b.effectList,ariaLabel:b.ariaLabel}));return a};Object.defineProperty(u, Symbol.toStringTag,{value:"Module"})});