/**
 * @license
 * Cesium - https://github.com/CesiumGS/cesium
 * Version 1.126
 *
 * Copyright 2011-2022 Cesium Contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Columbus View (Pat. Pend.)
 *
 * Portions licensed separately.
 * See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
 */
import{a as z}from"./chunk-E2NX4UJ2.js";import{h as I,i as b}from"./chunk-JBPQP6LH.js";import{a as W,b as O,d as L}from"./chunk-IIT3SHXK.js";import{a as m}from"./chunk-DLCTHPIV.js";import{a as v}from"./chunk-R6A52HT4.js";import{e as k}from"./chunk-D32DZSEC.js";var Z=Math.cos,B=Math.sin,p=Math.sqrt,N={computePosition:function(t,n,a,r,o,s,e){let i=n.radiiSquared,l=t.nwCorner,h=t.boundingRectangle,u=l.latitude-t.granYCos*r+o*t.granXSin,g=Z(u),c=B(u),m=i.z*c,C=l.longitude+r*t.granYSin+o*t.granXCos,S=g*Z(C),d=g*B(C),w=i.x*S,X=i.y*d,I=p(w*S+X*d+m*c);if(s.x=w/I,s.y=X/I,s.z=m/I,a){let n=t.stNwCorner;k(n)?(u=n.latitude-t.stGranYCos*r+o*t.stGranXSin,C=n.longitude+r*t.stGranYSin+o*t.stGranXCos,e.x=(C-t.stWest)*t.lonScalar,e.y=(u-t.stSouth)*t.latScalar):(e.x=(C-h.west)*t.lonScalar,e.y=(u-h.south)*t.latScalar)}}},A=new b,l=new W,F=new O,j=new W,y=new z;function D(t,n,a,r,o,s,e){let i=Math.cos(n),h=r*i,u=a*i,g=Math.sin(n),c=r*g,m=a*g;y._ellipsoid=L.default,l=y.project(t,l),l=W.subtract(l,j,l);let C=b.fromRotation(n,A);l=b.multiplyByVector(C,l,l),l=W.add(l,j,l),t=y.unproject(l,t),s-=1,e-=1;let S=t.latitude,d=S+s*m,p=S-h*e,w=S-h*e+s*m,X=Math.max(S,d,p,w),I=Math.min(S,d,p,w),O=t.longitude,f=O+s*u,Y=O+e*c,_=O+e*c+s*u,P=Math.max(O,f,Y,_),M=Math.min(O,f,Y,_);return{north:X,south:I,east:P,west:M,granYCos:h,granYSin:c,granXCos:u,granXSin:m,nwCorner:t}}N.computeOptions=function(t,n,a,r,o,s,e){let i=t.east,l=t.west,h=t.north,u=t.south,g=!1,c=!1;h===m.PI_OVER_TWO&&(g=!0),u===-m.PI_OVER_TWO&&(c=!0);let C,S=h-u;C=l>i?m.TWO_PI-l+i:i-l;let d=Math.ceil(C/n)+1,p=Math.ceil(S/n)+1,w=C/(d-1),X=S/(p-1),O=I.northwest(t,s),f=I.center(t,F);(0!==a||0!==r)&&(f.longitude<O.longitude&&(f.longitude+=m.TWO_PI),y._ellipsoid=L.default,j=y.project(f,j));let Y=X,_=w,W=0,P=0,M=I.clone(t,o),R={granYCos:Y,granYSin:W,granXCos:_,granXSin:P,nwCorner:O,boundingRectangle:M,width:d,height:p,northCap:g,southCap:c};if(0!==a){let t=D(O,a,w,X,f,d,p);if(h=t.north,u=t.south,i=t.east,l=t.west,h<-m.PI_OVER_TWO||h>m.PI_OVER_TWO||u<-m.PI_OVER_TWO||u>m.PI_OVER_TWO)throw new v("Rotated rectangle is invalid.  It crosses over either the north or south pole.");R.granYCos=t.granYCos,R.granYSin=t.granYSin,R.granXCos=t.granXCos,R.granXSin=t.granXSin,M.north=h,M.south=u,M.east=i,M.west=l}if(0!==r){a-=r;let t=I.northwest(M,e),n=D(t,a,w,X,f,d,p);R.stGranYCos=n.granYCos,R.stGranXCos=n.granXCos,R.stGranYSin=n.granYSin,R.stGranXSin=n.granXSin,R.stNwCorner=t,R.stWest=n.west,R.stSouth=n.south}return R};var st=N;export{st as a};