/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
import{a as N}from"./ENDXE7YY.js";import{a as O}from"./OAOQ5BXS.js";import{G as S,H as x,J as o,S as G,g as X,h as z,i as g}from"./PGOMURMZ.js";function I(t,s,a){let i=s[0]-t[0],h=a[0]-s[0],l=s[1]-t[1],c=a[1]-s[1],r=l/(i||h<0&&0),n=c/(h||i<0&&0),e=(r*h+n*i)/(i+h);return(Math.sign(r)+Math.sign(n))*Math.min(Math.abs(r),Math.abs(n),.5*Math.abs(e))||0}function Y(t,s,a){let i=s[0]-t[0],h=s[1]-t[1];return i?(3*h/i-a)/2:a}function Z(t,s,a,i,h){let[l,c]=t,[r,n]=s,e=(r-l)/3,$=h([l+e,c+e*a]).join(","),d=h([r-e,n-e*i]).join(","),m=h([r,n]).join(",");return`C ${$} ${d} ${m}`}function A({width:t,height:s,min:a,max:i}){let h=i[0]-a[0],l=i[1]-a[1];return c=>{let r=(c[0]-a[0])/h*t,n=s-(c[1]-a[1])/l*s;return[r,n]}}function B(t){let[s,a]=t[0],i=[s,a],h=[s,a];return t.reduce(({min:l,max:c},[r,n])=>({min:[Math.min(l[0],r),Math.min(l[1],n)],max:[Math.max(c[0],r),Math.max(c[1],n)]}),{min:i,max:h})}function E({data:t,min:s,max:a,t:i}){if(t.length===0)return"";let[h,l]=i(t[0]),[c,r]=i(s),[n]=i(a),e,$,d,m=t.reduce((v,M,p)=>{if($=t[p-2],d=t[p-1],p>1){let u=I($,d,M),b=e===void 0?Y($,d,u):e,w=Z($,d,b,u,i);return e=u,`${v} ${w}`}return v},`M ${c},${r} L ${c},${l} L ${h},${l}`),L=t[t.length-1],k=Z(d,L,e,Y(d,L,e),i);return`${m} ${k} L ${n},${r} Z`}var R=X`:host{display:block;block-size:100%}.svg{fill:currentColor;stroke:transparent;margin:0;display:block;block-size:100%;inline-size:100%;padding:0}.svg .graph-path--highlight{fill:var(--calcite-graph-highlight-fill-color, var(--calcite-color-brand));opacity:.5}:host([hidden]){display:none}[hidden]{display:none}`,y={svg:"svg",graphPath:"graph-path",graphPathHighlight:"graph-path--highlight"},C="calcite-graph",f={host:t=>`${C}-${t}`,linearGradient:t=>`linear-gradient-${C}-${t}`,mask:(t,s)=>`${C}-${t}${s}`},P=class extends S{constructor(){super(...arguments),this.graphId=O(),this.resizeObserver=N("resize",()=>this.requestUpdate()),this.data=[]}static{this.properties={colorStops:[0,{},{attribute:!1}],data:[0,{},{attribute:!1}],highlightMax:[9,{},{type:Number}],highlightMin:[9,{},{type:Number}],max:[11,{},{reflect:!0,type:Number}],min:[11,{},{reflect:!0,type:Number}]}}static{this.styles=R}connectedCallback(){super.connectedCallback(),this.resizeObserver?.observe(this.el)}disconnectedCallback(){super.disconnectedCallback(),this.resizeObserver?.disconnect()}render(){let{data:s,colorStops:a,el:i,highlightMax:h,highlightMin:l,min:c,max:r}=this,n=this.graphId,{clientHeight:e,clientWidth:$}=i;if(!s||s.length===0)return z`<svg aria-hidden=true class=${x(y.svg)} height=${e??o} preserveAspectRatio=none viewBox=${`0 0 ${$} ${e}`} width=${$??o}></svg>`;let{min:d,max:m}=B(s),L=d,k=m;(c<d[0]||c>d[0])&&(L=[c,0]),(r>m[0]||r<m[0])&&(k=[r,m[1]]);let v=A({min:L,max:k,width:$,height:e}),[M]=v([l,k[1]]),[p]=v([h,k[1]]),u=E({data:s,min:d,max:m,t:v}),b=a?`url(#${f.linearGradient(n)})`:void 0;return z`<svg aria-hidden=true class=${x(y.svg)} height=${e??o} preserveAspectRatio=none viewBox=${`0 0 ${$} ${e}`} width=${$??o}>${a?g`<defs><linearGradient id=${f.linearGradient(n)??o} x1=0 x2=1 y1=0 y2=0>${a.map(({offset:w,color:j,opacity:H})=>g`<stop offset=${`${w*100}%`} stop-color=${j??o} stop-opacity=${H??o} />`)}</linearGradient></defs>`:null}${l!==void 0?[g`<mask height=100% id=${f.mask(n,1)??o} width=100% x=0% y=0%><path d=${`
            M 0,0
            L ${M-1},0
            L ${M-1},${e}
            L 0,${e}
            Z
          `} fill=white /></mask>`,g`<mask height=100% id=${f.mask(n,2)??o} width=100% x=0% y=0%><path d=${`
            M ${M+1},0
            L ${p-1},0
            L ${p-1},${e}
            L ${M+1}, ${e}
            Z
          `} fill=white /></mask>`,g`<mask height=100% id=${f.mask(n,3)??o} width=100% x=0% y=0%><path d=${`
                M ${p+1},0
                L ${$},0
                L ${$},${e}
                L ${p+1}, ${e}
                Z
              `} fill=white /></mask>`,g`<path class=${x(y.graphPath)} d=${u??o} fill=${b??o} mask=${`url(#${f.mask(n,1)})`} />`,g`<path class=${x(y.graphPathHighlight)} d=${u??o} fill=${b??o} mask=${`url(#${f.mask(n,2)})`} />`,g`<path class=${x(y.graphPath)} d=${u??o} fill=${b??o} mask=${`url(#${f.mask(n,3)})`} />`]:g`<path class=${x(y.graphPath)} d=${u??o} fill=${b??o} />`}</svg>`}};G("calcite-graph",P);export{P as Graph};
