/**
 * @license
 * Cesium - https://github.com/CesiumGS/cesium
 * Version 1.122
 *
 * 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-EWTFJ46X.js";import{i as I,j as b}from"./chunk-5IUXF6I3.js";import{a as W,b as O,d as L}from"./chunk-RFPX772U.js";import{a as m}from"./chunk-RAYRECQS.js";import{a as v}from"./chunk-6P5KAIBX.js";import{e as k}from"./chunk-4FSVUTPL.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,S=l.longitude+r*t.granYSin+o*t.granXCos,C=g*Z(S),d=g*B(S),w=i.x*C,X=i.y*d,I=p(w*C+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,S=n.longitude+r*t.stGranYSin+o*t.stGranXCos,e.x=(S-t.stWest)*t.lonScalar,e.y=(u-t.stSouth)*t.latScalar):(e.x=(S-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 S=b.fromRotation(n,A);l=b.multiplyByVector(S,l,l),l=W.add(l,j,l),s-=1,e-=1;let C=(t=y.unproject(l,t)).latitude,d=C+s*m,p=C-h*e,w=C-h*e+s*m,X=Math.max(C,d,p,w),I=Math.min(C,d,p,w),O=t.longitude,Y=O+s*u,f=O+e*c,_=O+e*c+s*u;return{north:X,south:I,east:Math.max(O,Y,f,_),west:Math.min(O,Y,f,_),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 S,C=h-u;S=l>i?m.TWO_PI-l+i:i-l;let d=Math.ceil(S/n)+1,p=Math.ceil(C/n)+1,w=S/(d-1),X=C/(p-1),O=I.northwest(t,s),Y=I.center(t,F);(0!==a||0!==r)&&(Y.longitude<O.longitude&&(Y.longitude+=m.TWO_PI),y._ellipsoid=L.default,j=y.project(Y,j));let f=X,W=w,_=I.clone(t,o),R={granYCos:f,granYSin:0,granXCos:W,granXSin:0,nwCorner:O,boundingRectangle:_,width:d,height:p,northCap:g,southCap:c};if(0!==a){let t=D(O,a,w,X,Y,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,_.north=h,_.south=u,_.east=i,_.west=l}if(0!==r){a-=r;let t=I.northwest(_,e),n=D(t,a,w,X,Y,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};