import"./rolldown-runtime-DIIn1E2Q.js";var e=[`monotone_cubic`,`linear`];function isCurveData(t){if(typeof t!=`object`||!t||Array.isArray(t))return!1;let n=t;return Array.isArray(n.points)&&n.points.every(e=>Array.isArray(e)&&e.length===2&&typeof e[0]==`number`&&typeof e[1]==`number`)&&typeof n.interpolation==`string`&&e.includes(n.interpolation)}function createLinearInterpolator(e){if(e.length===0)return()=>0;if(e.length===1)return()=>e[0][1];let t=[...e].sort((e,t)=>e[0]-t[0]),n=t.length,r=t.map(e=>e[0]),i=t.map(e=>e[1]);return e=>{if(e<=r[0])return i[0];if(e>=r[n-1])return i[n-1];let t=0,a=n-1;for(;t<a-1;){let n=t+a>>1;r[n]<=e?t=n:a=n}let o=r[a]-r[t];if(o===0)return i[t];let s=(e-r[t])/o;return i[t]+s*(i[a]-i[t])}}function createInterpolator(e,t){return t===`linear`?createLinearInterpolator(e):createMonotoneInterpolator(e)}function createMonotoneInterpolator(e){if(e.length===0)return()=>0;if(e.length===1)return()=>e[0][1];let t=[...e].sort((e,t)=>e[0]-t[0]),n=t.length,r=t.map(e=>e[0]),i=t.map(e=>e[1]),a=[],o=[];for(let e=0;e<n-1;e++){let t=r[e+1]-r[e];a.push(t===0?0:(i[e+1]-i[e])/t)}o.push(a[0]??0);for(let e=1;e<n-1;e++)a[e-1]*a[e]<=0?o.push(0):o.push((a[e-1]+a[e])/2);o.push(a[n-2]??0);for(let e=0;e<n-1;e++)if(a[e]===0)o[e]=0,o[e+1]=0;else{let t=o[e]/a[e],n=o[e+1]/a[e],r=t*t+n*n;if(r>9){let i=3/Math.sqrt(r);o[e]=i*t*a[e],o[e+1]=i*n*a[e]}}return e=>{if(e<=r[0])return i[0];if(e>=r[n-1])return i[n-1];let t=0,a=n-1;for(;t<a-1;){let n=t+a>>1;r[n]<=e?t=n:a=n}let s=r[a]-r[t];if(s===0)return i[t];let c=(e-r[t])/s,l=c*c,u=l*c,d=2*u-3*l+1,f=u-2*l+c,p=-2*u+3*l,m=u-l;return d*i[t]+f*s*o[t]+p*i[a]+m*s*o[a]}}function histogramToPath(e){let t=e.length;if(t===0)return``;let n=new Float32Array(t);for(let r=0;r<t;r++)n[r]=Math.sqrt(e[r]);let r=Array.from(n).sort((e,t)=>e-t)[Math.floor((t-1)*.995)];if(r===0)return``;let i=1/r,a=t-1,o=[`M0,1`];for(let e=0;e<t;e++){let t=a===0?.5:e/a,r=1-Math.min(1,n[e]*i);o.push(`L${t},${r}`)}return o.push(`L1,1 Z`),o.join(` `)}function curveDataToFloatLUT(e,t=256){let n=new Float32Array(t),r=createInterpolator(e.points,e.interpolation);for(let e=0;e<t;e++)n[e]=r(e/(t-1));return n}export{e as a,isCurveData as i,curveDataToFloatLUT as n,histogramToPath as r,createInterpolator as t};
//# sourceMappingURL=curveUtils-DqM5IOrH.js.map