Files
ADHA_mobile_project/assets/MediaLayerView2D-b0d88ec1.js
2024-02-28 17:06:42 +05:00

2 lines
12 KiB
JavaScript

import{gw as ee,D as G,P as T,eA as I,gx as te,gy as se,z as Y,s as re,M as U,gz as $,gA as ie,gB as ne,cv as ae,gC as oe,ez as le,eB as he,eC as me,a3 as ce,eD as de,eE as pe,eF as ue,eG as fe,b3 as ye,gD as _e,V as ge,T as j,y as ve,t as we,gE as Re,v as xe,ab as Te,gF as $e,gG as W,A as q,B,C as Me,eL as be,gH as Ee}from"./index-b5c8f851.js";import{i as Ve}from"./Container-f991c035.js";import"./BufferPool-f0e47fc2.js";import{T as Ce}from"./color-0916c686.js";import{n as Se,w as Ae}from"./WGLContainer-21aabd6b.js";import{D as Ge,F as Q}from"./enums-bdecffa2.js";import{e as qe,T as F}from"./Texture-507d5ea8.js";import{f as De}from"./ProgramTemplate-a9187eb2.js";import"./definitions-1467ba4a.js";import"./GeometryUtils-7a7937c3.js";import{h as k}from"./FramebufferObject-4be671ef.js";import"./StyleDefinition-29c49b98.js";import"./enums-fb086c25.js";import{l as Pe}from"./MagnifierPrograms-9f54c6e2.js";import"./OrderIndependentTransparency-6ae10952.js";import"./floatRGBA-ba8d5dad.js";import"./testSVGPremultipliedAlpha-eac2b0ee.js";import"./GraphicsView2D-dbec6ccd.js";import"./AttributeStoreView-b12ba31a.js";import"./earcut-d423749e.js";import"./featureConversionUtils-6aca8295.js";import{r as Oe}from"./vec3f32-2da9db36.js";import{d as D}from"./enums-f1a6a48a.js";import{m as He,u as Le}from"./LayerView-c5a0067c.js";import"./VertexElementDescriptor-2925c6af.js";import"./config-1337d16e.js";import"./OptimizedGeometry-d94e541f.js";import"./ExpandedCIM-0020ab0e.js";import"./BidiEngine-9a40f2f4.js";import"./visualVariablesUtils-f4ae79f2.js";import"./GeometryUtils-984e8446.js";import"./utils-ebbcf3da.js";import"./Rect-ea14f53a.js";import"./quantizationUtils-50e37a76.js";import"./rasterizingUtils-99212870.js";import"./pbf-eb90fa42.js";import"./imageutils-c59aa434.js";import"./Matcher-dd0694f8.js";import"./tileUtils-c2f19f52.js";import"./TurboLine-f7b8bf8b.js";import"./CircularArray-ef508845.js";import"./throttle-7bf02de9.js";import"./ComputedAttributeStorage-07f34ef9.js";import"./TimeOnly-99f1af45.js";import"./basicInterfaces-11f56cb3.js";import"./projectionSupport-d15822a5.js";import"./json-48e3ea08.js";import"./TiledDisplayObject-a2315f25.js";import"./util-a6af6461.js";import"./OptimizedFeatureSet-1d1ac4b9.js";import"./scaleUtils-7ebacf58.js";const y=ae(),ze={none:D.None,loop:D.Loop,oscillate:D.Oscillate};function Ie(s){return s?{...s,playAnimation:s.playing,repeatType:s.repeatType?ze[s.repeatType]:void 0}:{}}let Ue=class extends Ve{constructor(e){super(),this.elementView=e,this.isWrapAround=!1,this.perspectiveTransform=ee(),this._playHandle=null,this._vertices=new Float32Array(20),this._handles=[],this._handles.push(G(()=>this.elementView.element.opacity,t=>this.opacity=t,T),G(()=>[this.elementView.coords],()=>{this.requestRender()},T),G(()=>["animationOptions"in this.elementView.element&&this.elementView.element.animationOptions],()=>{var t;(t=this._playHandle)==null||t.remove(),this.texture=I(this.texture),this.requestRender()},T),te(()=>this.elementView.element.loaded,()=>{const t=this.elementView.element;this.ready(),t.type==="video"&&t.content!=null&&this._handles.push(se(t.content,"play",()=>this.requestRender()))},T)),e.element.load().catch(t=>{Y.getLogger("esri.views.2d.layers.MediaLayerView2D").error(new re("element-load-error","Element cannot be displayed",{element:e,error:t}))})}destroy(){var e;(e=this._playHandle)==null||e.remove(),this._handles.forEach(t=>t.remove()),this.texture=I(this.texture)}get dvsMat3(){return this.parent.dvsMat3}beforeRender(e){const{context:t}=e,r=this.elementView.element.content;if(r!=null){const i=r instanceof HTMLImageElement,n=r instanceof HTMLVideoElement,l=i?r.naturalWidth:n?r.videoWidth:r.width,a=i?r.naturalHeight:n?r.videoHeight:r.height;if(this._updatePerspectiveTransform(l,a),this.texture)n&&!r.paused&&(this.texture.setData(r),this.requestRender(),(t.type===U.WEBGL2||$(l)&&$(a))&&this.texture.generateMipmap());else{const m=new qe;if(m.wrapMode=Ge.CLAMP_TO_EDGE,m.preMultiplyAlpha=!0,m.width=l,m.height=a,"getFrame"in r){const h=o=>{this.texture?this.texture.setData(o):this.texture=new F(t,m,o),this.requestRender()};"animationOptions"in this.elementView.element&&(this._playHandle=Pe(r,Ie(this.elementView.element.animationOptions),null,h))}else this.texture=new F(t,m,r);(t.type===U.WEBGL2||$(l)&&$(a))&&this.texture.generateMipmap(),n&&!r.paused&&this.requestRender()}}super.beforeRender(e)}_createTransforms(){return null}updateDrawCoords(e,t){const r=this.elementView.coords;if(r==null)return;const[i,n,l,a]=r.rings[0],m=this._vertices,{x:h,y:o}=e,p=t!==0;p?m.set([n[0]-h,n[1]-o,i[0]-h,i[1]-o,l[0]-h,l[1]-o,a[0]-h,a[1]-o,a[0]-h,a[1]-o,n[0]+t-h,n[1]-o,n[0]+t-h,n[1]-o,i[0]+t-h,i[1]-o,l[0]+t-h,l[1]-o,a[0]+t-h,a[1]-o]):m.set([n[0]-h,n[1]-o,i[0]-h,i[1]-o,l[0]-h,l[1]-o,a[0]-h,a[1]-o]),this.isWrapAround=p}getVAO(e,t,r){if(this.elementView.coords==null)return null;const i=this._vertices;if(this._vao)this._geometryVbo.setData(i);else{this._geometryVbo=k.createVertex(e,Q.DYNAMIC_DRAW,i);const n=k.createVertex(e,Q.STATIC_DRAW,new Uint16Array([0,0,0,1,1,0,1,1,1,1,0,0,0,0,0,1,1,0,1,1]));this._vao=new De(e,r,t,{geometry:this._geometryVbo,tex:n})}return this._vao}_updatePerspectiveTransform(e,t){const r=this._vertices;ie(y,[0,0,e,0,0,t,e,t],[r[0],r[1],r[4],r[5],r[2],r[3],r[6],r[7]]),ne(this.perspectiveTransform,y[6]/y[8]*e,y[7]/y[8]*t)}};class je extends Se{constructor(){super(...arguments),this._localOrigin=oe(0,0),this._viewStateId=-1,this._dvsMat3=le()}get dvsMat3(){return this._dvsMat3}beforeRender(e){this._updateMatrices(e),this._updateOverlays(e,this.children);for(const t of this.children)t.beforeRender(e)}prepareRenderPasses(e){const t=e.registerRenderPass({name:"overlay",brushes:[Ae.overlay],target:()=>this.children,drawPhase:Ce.MAP});return[...super.prepareRenderPasses(e),t]}_updateMatrices(e){const{state:t}=e,{id:r,size:i,pixelRatio:n,resolution:l,rotation:a,viewpoint:m,displayMat3:h}=t;if(this._viewStateId===r)return;const o=Math.PI/180*a,p=n*i[0],f=n*i[1],{x:M,y:v}=m.targetGeometry,b=he(M,t.spatialReference);this._localOrigin.x=b,this._localOrigin.y=v;const E=l*p,w=l*f,c=me(this._dvsMat3);ce(c,c,h),de(c,c,pe(p/2,f/2)),ue(c,c,Oe(p/E,-f/w,1)),fe(c,c,-o),this._viewStateId=r}_updateOverlays(e,t){const{state:r}=e,{rotation:i,spatialReference:n,worldScreenWidth:l,size:a,viewpoint:m}=r,h=this._localOrigin;let o=0;const p=ye(n);if(p&&n.isWrappable){const f=a[0],M=a[1],v=180/Math.PI*i,b=Math.abs(Math.cos(v)),E=Math.abs(Math.sin(v)),w=Math.round(f*b+M*E),[c,V]=p.valid,u=_e(n),{x:P,y:J}=m.targetGeometry,K=[P,J],C=[0,0];r.toScreen(C,K);const R=[0,0];let S;S=w>l?.5*l:.5*w;const O=Math.floor((P+.5*u)/u),X=c+O*u,Z=V+O*u,A=[C[0]+S,0];r.toMap(R,A),R[0]>Z&&(o=u),A[0]=C[0]-S,r.toMap(R,A),R[0]<X&&(o=-u);for(const x of t){const H=x.elementView.bounds;if(H==null)continue;const[L,,z]=H;L<c&&z>c?x.updateDrawCoords(h,u):z>V&&L<V?x.updateDrawCoords(h,-u):x.updateDrawCoords(h,o)}}else for(const f of t)f.updateDrawCoords(h,o)}}let g=class extends He(Le){constructor(){super(...arguments),this._overlayContainer=null,this._fetchQueue=null,this._tileStrategy=null,this._elementReferences=new Map,this._debugGraphicsView=null,this.layer=null,this.elements=new ge}attach(){this.addAttachHandles([j(()=>this.layer.effectiveSource,"refresh",()=>{this._tileStrategy.refresh(s=>this._updateTile(s)),this.requestUpdate()}),j(()=>this.layer.effectiveSource,"change",({element:s})=>this._elementUpdateHandler(s))]),this._overlayContainer=new je,this.container.addChild(this._overlayContainer),this._fetchQueue=new ve({tileInfoView:this.view.featuresTilingScheme,concurrency:10,process:(s,e)=>this._queryElements(s,e)}),this._tileStrategy=new we({cachePolicy:"purge",resampling:!0,acquireTile:s=>this._acquireTile(s),releaseTile:s=>this._releaseTile(s),tileInfoView:this.view.featuresTilingScheme}),this.requestUpdate()}detach(){var s;this.elements.removeAll(),this._tileStrategy.destroy(),this._fetchQueue.destroy(),this._overlayContainer.removeAllChildren(),this.container.removeAllChildren(),this._elementReferences.clear(),(s=this._debugGraphicsView)==null||s.destroy()}supportsSpatialReference(s){return!0}moveStart(){this.requestUpdate()}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}update(s){var e;this._tileStrategy.update(s),(e=this._debugGraphicsView)==null||e.update(s)}async hitTest(s,e){const t=[],r=s.normalize(),i=[r.x,r.y];for(const{projectedElement:{normalizedCoords:n,element:l}}of this._elementReferences.values())n!=null&&Re(n.rings,i)&&t.push({type:"media",element:l,layer:this.layer,mapPoint:s,sourcePoint:l.toSource(s)});return t.reverse()}canResume(){return this.layer.source!=null&&super.canResume()}async doRefresh(){this._fetchQueue.reset(),this._tileStrategy.refresh(s=>this._updateTile(s))}_acquireTile(s){const e=new We(s.clone());return this._updateTile(e),e}_updateTile(s){this._updatingHandles.addPromise(this._fetchQueue.push(s.key).then(e=>{const[t,r]=s.setElements(e);this._referenceElements(s,t),this._dereferenceElements(s,r),this.requestUpdate()},e=>{xe(e)||Y.getLogger(this).error(e)}))}_releaseTile(s){this._fetchQueue.abort(s.key.id),s.elements&&this._dereferenceElements(s,s.elements),this.requestUpdate()}async _queryElements(s,e){const t=this.layer.effectiveSource;if(t==null)return[];this.view.featuresTilingScheme.getTileBounds(d,s,!0);const r=new Te({xmin:d[0],ymin:d[1],xmax:d[2],ymax:d[3],spatialReference:this.view.spatialReference});return t.queryElements(r,e)}_referenceElements(s,e){if(this.layer.source!=null)for(const t of e)this._referenceElement(s,t)}_referenceElement(s,e){$e(this._elementReferences,e.uid,()=>{const t=new W({element:e,spatialReference:this.view.spatialReference}),r=new Ue(t);return this._overlayContainer.addChild(r),this.elements.add(e),{tiles:new Set,projectedElement:t,overlay:r,debugGraphic:null}}).tiles.add(s)}_dereferenceElements(s,e){for(const t of e)this._dereferenceElement(s,t)}_dereferenceElement(s,e){var r;const t=this._elementReferences.get(e.uid);t.tiles.delete(s),t.tiles.size||(this._overlayContainer.removeChild(t.overlay),t.overlay.destroy(),t.projectedElement.destroy(),this._elementReferences.delete(e.uid),this.elements.remove(e),(r=this._debugGraphicsView)==null||r.graphics.remove(t.debugGraphic))}_elementUpdateHandler(s){var r;let e=this._elementReferences.get(s.uid);if(e){const i=e.projectedElement.normalizedCoords;if(i==null)return this._overlayContainer.removeChild(e.overlay),e.overlay.destroy(),e.projectedElement.destroy(),this._elementReferences.delete(s.uid),this.elements.remove(s),void((r=this._debugGraphicsView)==null?void 0:r.graphics.remove(e.debugGraphic));const n=[],l=[];for(const a of this._tileStrategy.tiles){const m=N(this.view.featuresTilingScheme,a,i);e.tiles.has(a)?m||l.push(a):m&&n.push(a)}for(const a of n)this._referenceElement(a,s);for(const a of l)this._dereferenceElement(a,s);return e=this._elementReferences.get(s.uid),void((e==null?void 0:e.debugGraphic)&&(e.debugGraphic.geometry=e.projectedElement.normalizedCoords,this._debugGraphicsView.graphicUpdateHandler({graphic:e.debugGraphic,property:"geometry"})))}const t=new W({element:s,spatialReference:this.view.spatialReference}).normalizedCoords;if(t!=null)for(const i of this._tileStrategy.tiles)N(this.view.featuresTilingScheme,i,t)&&this._referenceElement(i,s)}};q([B()],g.prototype,"layer",void 0),q([B({readOnly:!0})],g.prototype,"elements",void 0),g=q([Me("esri.views.2d.layers.MediaLayerView2D")],g);const d=be(),_={xmin:0,ymin:0,xmax:0,ymax:0};function N(s,e,t){return s.getTileBounds(d,e.key,!0),_.xmin=d[0],_.ymin=d[1],_.xmax=d[2],_.ymax=d[3],Ee(_,t)}class We{constructor(e){this.key=e,this.elements=null,this.isReady=!1,this.visible=!0}setElements(e){const t=[],r=new Set(this.elements);this.elements=e;for(const i of e)r.has(i)?r.delete(i):t.push(i);return this.isReady=!0,[t,Array.from(r)]}destroy(){}}const jt=g;export{jt as default};