/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.25/esri/copyright.txt for details. */ import{blendingAlpha as e}from"../3d/webgl-engine/lib/OrderIndependentTransparency.js";import{BufferObject as t}from"./BufferObject.js";import{ContextType as r}from"./context-util.js";import{TargetType as n,DepthStencilTargetType as o,TextureType as a,TextureWrapMode as i,PixelFormat as f,PixelType as u,SizedPixelFormat as l,TextureSamplingMode as c,Usage as s,DataType as d,PrimitiveType as g}from"./enums.js";import{FramebufferObject as b}from"./FramebufferObject.js";import{makePipelineState as E}from"./renderState.js";import{VertexArrayObject as p}from"./VertexArrayObject.js";import{VertexElementDescriptor as m}from"./VertexElementDescriptor.js";var T,_,F,x={exports:{}};function A(T){if(!T.gl)return!1;if(T.type===r.WEBGL1)return!(!T.capabilities.textureFloat?.textureFloat||!T.capabilities.colorBufferFloat?.textureFloat);if(!(T.capabilities.textureFloat?.textureFloat&&T.capabilities.colorBufferFloat?.textureFloat&&T.capabilities.colorBufferFloat?.floatBlend))return!1;const _=new b(T,{colorTarget:n.TEXTURE,depthStencilTarget:o.NONE},{target:a.TEXTURE_2D,wrapMode:i.CLAMP_TO_EDGE,pixelFormat:f.RGBA,dataType:u.FLOAT,internalFormat:l.RGBA32F,samplingMode:c.NEAREST,width:1,height:1}),F=t.createVertex(T,s.STATIC_DRAW,new Uint16Array([0,0,1,0,0,1,1,1])),A=new p(T,new Map([["a_pos",0]]),{geometry:[new m("a_pos",2,d.UNSIGNED_SHORT,0,4)]},{geometry:F}),R="\n precision highp float;\n attribute vec2 a_pos;\n\n void main() {\n gl_Position = vec4(a_pos * 2.0 - 1.0, 0.0, 1.0);\n }\n ",v="\n precision highp float;\n\n void main() {\n gl_FragColor = vec4(0.5, 0.5, 0.5, 0.5);\n }\n ",S=T.programCache.acquire(R,v,new Map([["a_pos",0]]));T.useProgram(S);const h=T.getBoundFramebufferObject(),{x:P,y:L,width:B,height:C}=T.getViewport();T.bindFramebuffer(_),T.setViewport(0,0,1,1),T.bindVAO(A),T.drawArrays(g.TRIANGLE_STRIP,0,4);const w=E({blending:e});T.setPipelineState(w),T.drawArrays(g.TRIANGLE_STRIP,0,4),x.exports.init(T);const O=T.gl.getError();return T.setViewport(P,L,B,C),T.bindFramebuffer(h),S.dispose(),A.dispose(!1),F.dispose(),_.dispose(),1282!==O||(console.warn("Device claims support for WebGL extension EXT_float_blend but does not support it. Using fall back."),!1)}T=x,_=function(){var e=function(e){window.console&&window.console.log&&window.console.log(e)},t=function(t){window.console&&window.console.error?window.console.error(t):e(t)},r={enable:{1:{0:!0}},disable:{1:{0:!0}},getParameter:{1:{0:!0}},drawArrays:{3:{0:!0}},drawElements:{4:{0:!0,2:!0}},createShader:{1:{0:!0}},getShaderParameter:{2:{1:!0}},getProgramParameter:{2:{1:!0}},getShaderPrecisionFormat:{2:{0:!0,1:!0}},getVertexAttrib:{2:{1:!0}},vertexAttribPointer:{6:{2:!0}},bindTexture:{2:{0:!0}},activeTexture:{1:{0:!0}},getTexParameter:{2:{0:!0,1:!0}},texParameterf:{3:{0:!0,1:!0}},texParameteri:{3:{0:!0,1:!0,2:!0}},texImage2D:{9:{0:!0,2:!0,6:!0,7:!0},6:{0:!0,2:!0,3:!0,4:!0}},texSubImage2D:{9:{0:!0,6:!0,7:!0},7:{0:!0,4:!0,5:!0}},copyTexImage2D:{8:{0:!0,2:!0}},copyTexSubImage2D:{8:{0:!0}},generateMipmap:{1:{0:!0}},compressedTexImage2D:{7:{0:!0,2:!0}},compressedTexSubImage2D:{8:{0:!0,6:!0}},bindBuffer:{2:{0:!0}},bufferData:{3:{0:!0,2:!0}},bufferSubData:{3:{0:!0}},getBufferParameter:{2:{0:!0,1:!0}},pixelStorei:{2:{0:!0,1:!0}},readPixels:{7:{4:!0,5:!0}},bindRenderbuffer:{2:{0:!0}},bindFramebuffer:{2:{0:!0}},checkFramebufferStatus:{1:{0:!0}},framebufferRenderbuffer:{4:{0:!0,1:!0,2:!0}},framebufferTexture2D:{5:{0:!0,1:!0,2:!0}},getFramebufferAttachmentParameter:{3:{0:!0,1:!0,2:!0}},getRenderbufferParameter:{2:{0:!0,1:!0}},renderbufferStorage:{4:{0:!0,1:!0}},clear:{1:{0:{enumBitwiseOr:["COLOR_BUFFER_BIT","DEPTH_BUFFER_BIT","STENCIL_BUFFER_BIT"]}}},depthFunc:{1:{0:!0}},blendFunc:{2:{0:!0,1:!0}},blendFuncSeparate:{4:{0:!0,1:!0,2:!0,3:!0}},blendEquation:{1:{0:!0}},blendEquationSeparate:{2:{0:!0,1:!0}},stencilFunc:{3:{0:!0}},stencilFuncSeparate:{4:{0:!0,1:!0}},stencilMaskSeparate:{2:{0:!0}},stencilOp:{3:{0:!0,1:!0,2:!0}},stencilOpSeparate:{4:{0:!0,1:!0,2:!0,3:!0}},cullFace:{1:{0:!0}},frontFace:{1:{0:!0}},drawArraysInstancedANGLE:{4:{0:!0}},drawElementsInstancedANGLE:{5:{0:!0,2:!0}},blendEquationEXT:{1:{0:!0}}},n=null,o=null;function a(e){if(null==n)for(var t in n={},o={},e)"number"==typeof e[t]&&(n[e[t]]=t,o[t]=e[t])}function i(){if(null==n)throw"WebGLDebugUtils.init(ctx) not called"}function f(e){return i(),void 0!==n[e]}function u(e){i();var t=n[e];return void 0!==t?"gl."+t:"/*UNKNOWN WebGL ENUM*/ 0x"+e.toString(16)}function l(e,t,n,a){var i;if(void 0!==(i=r[e])&&void 0!==(i=i[t])&&i[n]){if("object"==typeof i[n]&&void 0!==i[n].enumBitwiseOr){for(var f=i[n].enumBitwiseOr,l=0,c=[],s=0;s=0&&setTimeout((function(){e.restoreContext()}),b)}),0)}},e.restoreContext=function(){f&&o.length&&setTimeout((function(){if(!d)throw"can not restore. webglcontestlost listener did not call event.preventDefault";R(),g(t),f=!1,c=0,d=!1;for(var e=o.slice(),r=v("context restored"),n=0;n