@wemap/providers 14.7.0 → 14.8.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@wemap/geo"),require("@wemap/maths"),require("@wemap/routers"),require("@wemap/utils"),require("@wemap/camera")):typeof define==`function`&&define.amd?define([`exports`,`@wemap/geo`,`@wemap/maths`,`@wemap/routers`,`@wemap/utils`,`@wemap/camera`],t):(e=typeof globalThis<`u`?globalThis:e||self,t((e.Wemap=e.Wemap||{},e.Wemap.Providers={}),e.Wemap.Geo,e.Wemap.Maths,e.Wemap.Routers,e.Wemap.Utils,e.Wemap.Camera))})(this,function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=class e extends t.UserPosition{source;static fromUserPosition(t,n){let r=new e(t.lat,t.lng,t.alt,t.level,t.time,t.accuracy,t.bearing);return r.source=n,r}clone(){return e.fromUserPosition(super.clone(),this.source)}},s=class extends t.Attitude{},c=class extends t.Attitude{},l={useMapMatching:!0,ignoreProviders:[],optionalProviders:[],stopOnError:!0,checkAvailabilityOnStart:!0,get hasPoleStar(){return this.optionalProviders.includes(`PoleStar`)}},u=Object.defineProperty,d=(e,t,n)=>t in e?u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,f=(e,t,n)=>(d(e,typeof t==`symbol`?t:t+``,n),n),p=[`error`,`ok`,`warn`,`flux`,`deprecated`,`info`,`log`,`debug`];function m(e){return`wemap`in e}var h=class e{static enable(t){e.ENABLED=!!t}static level(t){return arguments.length&&(e.LOG_LEVEL=t),e.LOG_LEVEL}static clearHistory(){e.HISTORY=[]}static _canUseLog(t){let n=p.indexOf(t),r=p.indexOf(e.LOG_LEVEL);return r!==-1&&n<=r}static _getColorByType(e){let t=null;switch(e){case`flux`:t=`background-color: #0083E0; color: #FFFFFF;`;break;case`ok`:t=`background-color: #00FF22; color: #272727;`;break;case`deprecated`:t=`background-color: #CA0AFA; color: #FFFFFF;`;break;case`error`:t=`background-color: #CC0000; color: #FFFFFF;`;break;case`warn`:t=`background-color: #DD7908; color: #FFFFFF;`;break;case`debug`:t=`background-color: #999999; color: #FFFFFF;`;break;case`info`:t=`background-color: #DCFF4E; color: #000000;`;break;default:t=`background-color: #F4F4F4; color: #999999;`;break}return t}static _getOriginByType(e,t){let n=null,r=null,i=t;if(arguments.length<2)return``;try{for(n=``,r=e.stack&&e.stack.length?e.stack.split(`
2
2
  `).splice(3):[],(i<0||i>=r.length)&&(i=r.length);i;)n+=`\r
3
- `+r[0].trim(),r=r.splice(1),i--;return n}catch{return``}}static _log(t,n,r){let i=`color: auto;`,a=`color: #6A6A6A;`,o=typeof window<`u`,s,c=null,l=null,u=null,d=null,f=``,h=!1;if(c=t,d=Error(n),o&&(l=e._getColorByType(t)),u=e._getOriginByType(d,r),c===`deprecated`&&(c=`warn`,h=`deprecated`),o&&(u=e._COLOR_TOKEN+u),s=(o?e._COLOR_TOKEN:``)+` `+d.message,f=o?e._COLOR_TOKEN:``,f+=e._TYPE_PREFIX,f+=h||t,f+=e._TYPE_SUFFIX,typeof window<`u`&&m(window)){let e=performance&&performance.now?performance.now():new Date().getTime();f+=`[`+Math.round(e-window.wemap.startTime)+`ms]`}return s=f+s,e.SHOW_ORIGIN&&(s+=u),e.HISTORY.push(s),!this._canUseLog(t)||arguments.length<2||!e.ENABLED?!1:(o?console&&t!==`ok`&&t!==`flux`&&t!==`deprecated`&&console[t]&&p.indexOf(t)<=p.indexOf(`info`)?console[t](s,l,i,a):console.log(s,l,i,a):console.log(s),!0)}static external(e){return console.log(`LIVEMAP :: `+e)}static flux(t){return e._log(`flux`,t,0)}static ok(t){return e._log(`ok`,t,1)}static error(t,n=-1){return e._log(`error`,t,n)}static warn(t,n=2){return e._log(`warn`,t,n)}static deprecated(t,n=2){return e._log(`deprecated`,t,n)}static debug(t,n=-1){return e._log(`debug`,t,n)}static info(t,n=0){return e._log(`info`,t,n)}static log(t,n=1){return e._log(`log`,t,n)}};f(h,`LOG_LEVEL`,`debug`),f(h,`SHOW_ORIGIN`,!0),f(h,`ENABLED`,!0),f(h,`HISTORY`,[]),f(h,`_COLOR_TOKEN`,`%c`),f(h,`_TYPE_PREFIX`,`<<<< `),f(h,`_TYPE_SUFFIX`,` >>>>`);for(var g=h,_=new class{_enabled=!1;currentId=0;objectsIdMap=new WeakMap;pushEvents={};pushEventsRef={};interval;initDate;get enabled(){return this._enabled}set enabled(e){this._enabled=e}initializeInterval(){this.interval||=window.setInterval(()=>{for(let[e,t]of Object.entries(this.pushEvents))g.debug(`Received `+t+` notifications from `+this.pushEventsRef[Number(e)].getName()+` last second`);this.pushEvents={},this.pushEventsRef={}},1e3)}getObjectId(e){return this.objectsIdMap.has(e)||this.objectsIdMap.set(e,++this.currentId),this.objectsIdMap.get(e)}addEvent(e,t){if(!this.enabled)return;this.initDate||=Date.now(),this.initializeInterval();let n=this.getObjectId(e),r=e.getName();g.debug(r+`[`+n+`].`+t)}incrementNotifications(e){if(!this.enabled)return;let t=this.getObjectId(e),n=this.pushEvents[t];n||(n=0,this.pushEventsRef[t]=e),this.pushEvents[t]=n+1}},v=class e extends Error{static DEFAULT_MESSAGE=`Contains ignored provider`;constructor(t){super(t||e.DEFAULT_MESSAGE)}},y=class e{static _callbackUniqueId=0;static _uniqueId=1;id;state=`stopped`;_lastEvent=null;_eventsCallbacks=[];_monitoringCallbacks=[];constructor(){this.id=e._uniqueId++,_.addEvent(this,`constructor`)}getAvailability(){return l.ignoreProviders.includes(this.getName())?Promise.resolve(new v):this.availability()}get hasNativeInterface(){return!!this.nativeInterface}get nativeInterface(){return typeof window<`u`&&window.__nativeProviders||null}get nativeJsInterface(){return typeof window>`u`?null:(window.__nativeJsProviders||(window.__nativeJsProviders={}),window.__nativeJsProviders)}get useCameraNatively(){return!1}addEventListener(t=null,n=null,r=!0){let i=++e._callbackUniqueId;if(this._eventsCallbacks.push({id:i,onEvent:t||(()=>{}),onError:n||(()=>{}),optional:!r}),!r||this.state!==`stopped`)return i;this.state=`starting`;let a=Promise.resolve();return l.checkAvailabilityOnStart&&(a=this.getAvailability()),(async()=>{let e=await a;if(e){this.state=`stopped`,this.notifyError(e);return}_.addEvent(this,`start`),this.start(),this.state=`started`,this._monitoringCallbacks.forEach(e=>e.onStarted?.())})(),i}removeEventListener(e){let t=this._eventsCallbacks.find(t=>t.id===e);t&&(this._eventsCallbacks=this._eventsCallbacks.filter(e=>e!==t),!t.optional&&(this._eventsCallbacks.find(e=>!e.optional)||this.state!==`stopped`&&(_.addEvent(this,`stop`),this.stop(),this.state=`stopped`,this._monitoringCallbacks.forEach(e=>e.onStopped?.()))))}addMonitoringListener(t,n){let r=e._callbackUniqueId++;return this._monitoringCallbacks.push({id:r,onStarted:t||null,onStopped:n||null}),r}removeMonitoringListener(e){this._monitoringCallbacks=this._monitoringCallbacks.filter(t=>t.id!==e)}notify=e=>{let t=this._adaptBeforeNotify(e);_.incrementNotifications(this),this._eventsCallbacks.forEach(e=>e.onEvent?.(t)),this._lastEvent=t};_adaptBeforeNotify(e){return e}notifyError=e=>{this._eventsCallbacks.forEach(({id:t,onError:n})=>{l.stopOnError&&this.removeEventListener(t),n?.(e)})};get lastEvent(){return this._lastEvent}},b=class{static async every(e){for(let t of e){let e=await t;if(e)return e}return null}static async some(e){let t;for(let n of e){let e=await n;if(e)t||=e;else return null}return t||null}},ee=[[0,0,0,0,0,0,0,0,0,0,0,0,0],[-29404.5,-1450.7,0,0,0,0,0,0,0,0,0,0,0],[-2500,2982,1676.8,0,0,0,0,0,0,0,0,0,0],[1363.9,-2381,1236.2,525.7,0,0,0,0,0,0,0,0,0],[903.1,809.4,86.2,-309.4,47.9,0,0,0,0,0,0,0,0],[-234.4,363.1,187.8,-140.7,-151.2,13.7,0,0,0,0,0,0,0],[65.9,65.6,73,-121.5,-36.2,13.5,-64.7,0,0,0,0,0,0],[80.6,-76.8,-8.3,56.5,15.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.4,0,.8,0,0,0,0,0,0],[-.1,-.3,-.1,.7,.2,-.5,-.8,1,0,0,0,0,0],[-.1,.1,-.1,.5,-.1,.4,.5,0,.4,0,0,0,0],[-.1,-.2,0,.4,-.3,0,.3,0,0,-.4,0,0,0],[0,0,0,.2,-.1,-.2,0,-.1,-.2,-.1,0,0,0],[0,-.1,0,0,0,-.1,0,0,-.1,-.1,-.1,-.1,0],[0,0,0,0,0,0,0,0,0,0,0,0,-.1]],re=[[0,0,0,0,0,0,0,0,0,0,0,0,0],[0,-25.1,0,0,0,0,0,0,0,0,0,0,0],[0,-30.2,-23.9,0,0,0,0,0,0,0,0,0,0],[0,5.7,-1,1.1,0,0,0,0,0,0,0,0,0],[0,.2,6.9,3.7,-5.6,0,0,0,0,0,0,0,0],[0,.1,2.5,-.9,3,.5,0,0,0,0,0,0,0],[0,.1,-1.8,-1.4,.9,.1,1,0,0,0,0,0,0],[0,.5,.6,-.7,-.2,-1.2,.2,.3,0,0,0,0,0],[0,-.3,.7,-.2,.5,-.3,-.5,.4,.1,0,0,0,0],[0,-.3,.2,-.4,.4,.1,0,-.2,.5,.2,0,0,0],[0,0,.1,-.3,.1,-.2,.1,0,-.1,.2,0,0,0],[0,0,.1,0,.2,0,0,.1,0,-.1,0,0,0],[0,0,0,-.1,.1,0,0,0,.1,0,0,0,-.1]],x={a:6378.137,b:6356.7523142,r0:6371.2},S=function(e,t){return Array(e).fill(``).map(function(e){return Array(t).fill(0)})},ie=function(){return(new Date(Date.now()).valueOf()/864e5+2440587.5-2458850)/365.25},ae=function(e,t){return Number(Math.round(Number(e+`e+`+t))+`e-`+t)},oe=function(e){return e>90?e-180:e<-90?e+180:e},C=function(e){return e*.017453292519943295},se=function(e){return e*57.29577951308232},w=S(13,13),T=S(13,13),ce=S(13,13),le=S(13,13),ue=Array(13).fill(0),de=Array(13).fill(0),fe=Array(13).fill(0),E=S(13,13).map(function(e){return e.map(function(e){return[0,0]})}),D=2;D<=12;D++)fe[D]=Math.sqrt((2*D-1)/(2*D));for(var O=0;O<=12;O++)for(var pe=O*O,D=Math.max(O+1,2);D<=12;D++)E[O][D][0]=Math.sqrt((D-1)*(D-1)-pe),E[O][D][1]=1/Math.sqrt(D*D-pe);var me=function(e,t,n){n===void 0&&(n=0);var r=Math.cos(C(e)),i=Math.sin(C(e)),a=Math.sqrt(x.a**2*r**2+x.b**2*i**2),o=Math.atan2(r*(n*a+x.a**2),i*(n*a+x.b**2)),s=Math.sqrt(n**2+2*n*a+(x.a**4-(x.a**4-x.b**4)*i**2)/(x.a**2-(x.a**2-x.b**2)*i**2)),c=Math.cos(o),l=Math.sin(o),u=1/(l+(l===0?1e-8:0));w[0][0]=1,w[1][1]=l,w[1][0]=c,T[1][0]=-l,T[1][1]=c;for(var d=2;d<=12;d++)w[d][d]=w[d-1][d-1]*l*fe[d],T[d][d]=(T[d-1][d-1]*l+w[d-1][d-1]*c)*fe[d];for(var f=0;f<=12;f++)for(var d=Math.max(f+1,2);d<=12;d++)w[d][f]=(w[d-1][f]*c*(2*d-1)-w[d-2][f]*E[f][d][0])*E[f][d][1],T[d][f]=((T[d-1][f]*c-w[d-1][f]*l)*(2*d-1)-T[d-2][f]*E[f][d][0])*E[f][d][1];for(var p=ie(),d=1;d<=12;d++)for(var f=0;f<=12;f++)ce[d][f]=ee[d][f]+p*ne[d][f],le[d][f]=te[d][f]+p*re[d][f];for(var f=0;f<=12;f++)ue[f]=Math.sin(f*C(t)),de[f]=Math.cos(f*C(t));for(var m=0,h=0,g=0,_=x.r0/s,v=_**2,d=1;d<=12;d++){for(var y=0,b=0,S=0,f=0;f<=d;f++){var D=ce[d][f]*de[f]+le[d][f]*ue[f];y+=D*w[d][f],b+=D*T[d][f],S+=f*(ce[d][f]*ue[f]-le[d][f]*de[f])*w[d][f]}v*=_,m+=(d+1)*y*v,h-=b*v,g+=S*v*u}var O=o-(Math.PI/2-C(e)),pe=Math.sin(O),me=Math.cos(O),k=-h*me-m*pe,A=g,j=h*pe-m*me,he=k!==0||A!==0?ae(se(Math.atan2(A,k)),2):0,ge=A!==0||k!==0&&j!==0?oe(se(Math.atan2(j*Math.sin(Math.atan2(A,k)),A))):0;return{declination:ae(he,2),inclination:ae(ge,2),intensity:Math.round(Math.sqrt(k**2+A**2+j**2)),northIntensity:Math.round(k),eastIntensity:Math.round(A),verticalIntensity:Math.round(j),horizontalIntensity:Math.round(Math.sqrt(k**2+A**2))}},k=class e extends Error{static DEFAULT_MESSAGE=`It seems that you ask for IMU events on a desktop browser`;constructor(t){super(t||e.DEFAULT_MESSAGE)}},A=class e extends Error{static DEFAULT_MESSAGE=`Impossible to retrieve events, a sensor is missing`;constructor(t){super(t||e.DEFAULT_MESSAGE)}from(e){return this.message+=` from `+e,this}},j=class extends A{constructor(e){super(e)}},he=class e extends Error{static DEFAULT_MESSAGE=`Geolocation api is missing`;constructor(t){super(t||e.DEFAULT_MESSAGE)}},ge=class e extends Error{static DEFAULT_MESSAGE=`Geolocation permission denied`;constructor(t){super(t||e.DEFAULT_MESSAGE)}},_e=class e extends Error{static DEFAULT_MESSAGE=`Geolocation position unavailable`;constructor(t){super(t||e.DEFAULT_MESSAGE)}},M={DEFAULT_ALTITUDE:1.6},N=new class e extends y{static DEFAULT_DISCARD_POSITIONS_ABOVE=50;discardPositionsAbove=e.DEFAULT_DISCARD_POSITIONS_ABOVE;enableHighAccuracy=!0;geoLocationId;getName=()=>`GnssWifi`;get positionOptions(){return{enableHighAccuracy:this.enableHighAccuracy,timeout:1/0,maximumAge:0}}availability(){return typeof navigator==`object`&&navigator.geolocation?Promise.resolve():Promise.resolve(new he)}start(){navigator.geolocation.getCurrentPosition(this.onNewPosition,this.onPositionError,this.positionOptions),setTimeout(()=>{this.geoLocationId=navigator.geolocation.watchPosition(this.onNewPosition,this.onPositionError,this.positionOptions)},150)}stop(){this.geoLocationId!==void 0&&navigator.geolocation.clearWatch(this.geoLocationId)}onNewPosition=e=>{let{coords:r}=e;if(!r)return;let a;r.heading&&(a=(0,n.deg2rad)(r.heading));let o=i.TimeUtils.unixTimestampToPreciseTime(e.timestamp)/1e3,s=new t.UserPosition(r.latitude,r.longitude,M.DEFAULT_ALTITUDE,null,o,r.accuracy,a);this.enableHighAccuracy&&typeof this.discardPositionsAbove==`number`&&r.accuracy>this.discardPositionsAbove||this.notify(s)};onPositionError=e=>{g.warn(`[Providers] watchPosition error: [${e.code}] ${e.message}`);let t;switch(e.code){case 1:t=new ge(e.message);break;case 2:t=new _e(e.message);break;default:t=Error(e.message)}this.notifyError(t)}},ve=class e extends Error{static DEFAULT_MESSAGE=`ARCore is missing`;constructor(t){super(t||e.DEFAULT_MESSAGE)}},ye=class e extends Error{static DEFAULT_MESSAGE=`Native interface is missing. You are maybe trying to execute a code which is not available in a web browser`;constructor(t){super(t||e.DEFAULT_MESSAGE)}},P=new class e extends y{static Payload={Pose:{ref:1,size:7},Barcode:{ref:2**1,size:1},ProjMat:{ref:2**2,size:16},ImageRef:{ref:2**3,size:1}};static RELATIVE_ATTITUDE_DRIFT=(0,n.deg2rad)(3)/60;_nativeProvider;previousPosition=[0,0,0];getName=()=>`ArCore`;availability(){try{if(!this.nativeProvider.checkAvailability())return Promise.resolve(new ve)}catch(e){return Promise.resolve(e)}return Promise.resolve()}start(){this.nativeProvider?.start(),this.pullDataLoop()}stop(){this.nativeProvider?.stop()}pullDataLoop=()=>{if(this.state===`stopped`)return;let e=JSON.parse(this.nativeProvider.getInfo());e.length>1&&this.parsePayload(e),requestAnimationFrame(this.pullDataLoop)};parsePayload(n){let r=n[0],a=1,o,c,l,u,d=i.TimeUtils.preciseTime()/1e3;if(r&e.Payload.Pose.ref){o=new s(n.slice(a,a+4),d,e.RELATIVE_ATTITUDE_DRIFT);let r=[n[a+4],n[a+5],n[a+6]];c=new t.RelativePosition(r[0]-this.previousPosition[0],r[1]-this.previousPosition[1],r[2]-this.previousPosition[2],d,1e-4),this.previousPosition=r,a+=e.Payload.Pose.size}r&e.Payload.Barcode.ref&&(u=n[a],a+=e.Payload.Barcode.size),r&e.Payload.ProjMat.ref&&(l=n.slice(a,a+e.Payload.ProjMat.size),a+=e.Payload.ProjMat.size),this.notify({relativePosition:c,relativeAttitude:o,...u&&{barcode:u},...l&&{cameraProjection:l}})}get nativeProvider(){if(!this._nativeProvider){if(!this.nativeInterface)throw new ye;if(this._nativeProvider=this.nativeInterface.getArCoreProvider(),!this._nativeProvider)throw new ve}return this._nativeProvider}enableBarcodeScanner(){try{this.nativeProvider.enableBarcodeScanner()}catch(e){this.notifyError(e)}}disableBarcodeScanner(){try{this.nativeProvider.disableBarcodeScanner()}catch(e){this.notifyError(e)}}get useCameraNatively(){return!0}},be=new class extends y{absoluteAttitudeProviderId;arCoreProviderId;absoluteAttitudeEvent;getName=()=>`GeoRelativePositionFromArCore`;availability(){return b.every([P.getAvailability(),X.getAvailability()])}start(){this.arCoreProviderId=P.addEventListener(this.onArCoreEvents,this.notifyError),this.absoluteAttitudeProviderId=X.addEventListener(e=>this.absoluteAttitudeEvent=e,this.notifyError)}stop(){P.removeEventListener(this.arCoreProviderId),X.removeEventListener(this.absoluteAttitudeProviderId)}onArCoreEvents=e=>{let t=e.relativeAttitude,n=e.relativePosition;t&&n&&this.absoluteAttitudeEvent&&this.compute(n,t,this.absoluteAttitudeEvent)};compute(e,n,r){let i=r.heading-n.heading,a=Math.cos(i)*e.x-Math.sin(i)*e.z,o=-Math.sin(i)*e.x-Math.cos(i)*e.z,s=e.y,c=new t.GeoRelativePosition(a,o,s,e.time,0,r.heading);this.notify(c)}},xe={acc:.5,gyr:.3},Se={acc:.5,gyr:.3,yc:2},Ce=class{P;accRef;cRef;noises;quaternion;constructor(e=[0,0,1],t=[-1,0,0]){this.accRef=e,this.cRef=t,this.P=n.Matrix4.fromDiagVector([,,,,].fill(.1**2)),this.quaternion=null,this.noises={},this.setRelativeNoises(xe),this.setAbsoluteNoises(Se)}setRelativeNoises(e){this.noises.relative={acc:n.Matrix3.diag([,,,].fill(e.acc**2)),gyr:n.Matrix3.diag([,,,].fill(e.gyr**2))}}setAbsoluteNoises(e){this.noises.absolute={acc:n.Matrix3.diag([,,,].fill(e.acc**2)),gyr:n.Matrix3.diag([,,,].fill(e.gyr**2)),yc:n.Matrix3.diag([,,,].fill(e.yc**2))}}tryInitialize(e,t){let r=n.Vector3.normalize(e);if(t){let e=n.Vector3.normalize(t),i=n.Vector3.normalize(n.Vector3.cross(e,r)),a=n.Vector3.cross(r,i),o=[[i[0],a[0],r[0]],[i[1],a[1],r[1]],[i[2],a[2],r[2]]];this.quaternion=n.Quaternion.fromMatrix3Matlab(o)}else{let e=n.Vector3.dot(r,this.accRef)+1,t=n.Vector3.cross(r,this.accRef),i=[e,t[0],t[1],t[2]];i=n.Quaternion.normalize(i),this.quaternion=i}return this.quaternion}update(e,t,r,i){if(!this.quaternion)return this.tryInitialize(t,i);let a=this.quaternion,o=a,s=n.Vector3.multiplyScalar(r,.5*e),c=this.computeC([1,s[0],s[1],s[2]]),l=n.Matrix4.multiplyVector(c,a),u=n.Matrix3.diag([o[0],o[0],o[0]]),d=n.Matrix3.skew([o[1],o[2],o[3]]),f=[-1*o[1],-1*o[2],-1*o[3]],p=n.Matrix.concatRow([f],n.Matrix3.sum(d,u)),m=n.Matrix4.multiplyScalar(n.Matrix.multiply(n.Matrix.multiply(p,this.noises[i?`absolute`:`relative`].gyr),n.Matrix.transpose(p)),(e/2)**2),h=n.Matrix4.sum(n.Matrix4.multiply(n.Matrix4.multiply(c,this.P),n.Matrix4.transpose(c)),m),g=n.Vector3.normalize(t),_,v,y;if(i){let e=n.Vector3.normalize(i),t=n.Vector3.cross(g,e),r=n.Vector3.normalize(t),a=n.Vector3.subtract(r,n.Quaternion.rotateMatlab(l,this.cRef)),o=n.Vector3.subtract(g,n.Quaternion.rotateMatlab(l,this.accRef));_=n.Vector.concat(a,o);let s=this.jacobianES(l,this.cRef),c=this.jacobianES(l,this.accRef);y=n.Matrix.concatRow(s,c);let u=n.Matrix.concatLine(this.noises.absolute.yc,n.Matrix3.zeros),d=n.Matrix.concatLine(n.Matrix3.zeros,this.noises.absolute.acc),f=n.Matrix.concatRow(u,d);v=n.Matrix.multiply(n.Matrix.multiply(h,n.Matrix.transpose(y)),n.Matrix.inverse(n.Matrix.sum(n.Matrix.multiply(n.Matrix.multiply(y,h),n.Matrix.transpose(y)),f)))}else{_=n.Vector3.subtract(g,n.Quaternion.rotateMatlab(l,this.accRef)),y=this.jacobianES(l,this.accRef);let e=this.noises.relative.acc;v=n.Matrix.multiply(n.Matrix.multiply(h,n.Matrix.transpose(y)),n.Matrix3.inverse(n.Matrix3.sum(n.Matrix.multiply(n.Matrix.multiply(y,h),n.Matrix.transpose(y)),e)))}a=n.Quaternion.sum(l,n.Matrix.multiplyVector(v,_));let b=n.Matrix4.multiply(n.Matrix4.subtract(n.Matrix4.identity,n.Matrix.multiply(v,y)),h);return a=n.Quaternion.normalize(a),this.quaternion=a,this.P=b,a}computeC(e){return[[e[0],-e[1],-e[2],-e[3]],[e[1],e[0],e[3],-e[2]],[e[2],-e[3],e[0],e[1]],[e[3],e[2],-e[1],e[0]]]}jacobianES(e,t){let[n,r,i,a]=e,[o,s,c]=t;return[[2*a*s-2*i*c,2*i*s+2*a*c,2*r*s-2*n*c-4*i*o,2*n*s+2*r*c-4*a*o],[2*r*c-2*a*o,2*n*c-4*r*s+2*i*o,2*r*o+2*a*c,2*i*c-2*n*o-4*a*s],[2*i*o-2*r*s,2*a*o-4*r*c-2*n*s,2*n*o-4*i*c+2*a*s,2*r*o+2*i*s]]}},F=new class extends y{getName=()=>`IMU`;availability(){return i.BrowserUtils.isMobile?Promise.resolve():Promise.resolve(new k)}start(){let e=()=>window.addEventListener(`devicemotion`,this.parseDeviceMotionEvent,!0),t=DeviceMotionEvent.requestPermission||void 0;t?t().then(t=>{if(t!==`granted`)throw Error(`Permission not granted`);e()}).catch(this.notifyError):e()}stop(){window.removeEventListener(`devicemotion`,this.parseDeviceMotionEvent,!0)}parseDeviceMotionEvent=e=>{let t=e.timeStamp/1e3,r;if(e.accelerationIncludingGravity){let{x:t,y:n,z:a}=e.accelerationIncludingGravity;typeof t==`number`&&typeof n==`number`&&typeof a==`number`&&(r=[t,n,a],(i.BrowserUtils.getName()===i.Browser.SAFARI||i.BrowserUtils.getName()===i.Browser.IOS_WEBVIEW)&&(r[0]*=-1,r[1]*=-1,r[2]*=-1))}let a;if(e.rotationRate){let{alpha:t,beta:r,gamma:i}=e.rotationRate;typeof t==`number`&&typeof r==`number`&&typeof i==`number`&&(a=[(0,n.deg2rad)(t),(0,n.deg2rad)(r),(0,n.deg2rad)(i)])}(r||a)&&this.notify({...r&&{acceleration:{timestamp:t,values:r}},...a&&{angularRate:{timestamp:t,values:a}}})}},we=class e extends A{static DEFAULT_MESSAGE=`Impossible to retrieve Acceleration data`;constructor(t){super(t||e.DEFAULT_MESSAGE)}},I=new class extends y{imuProviderId;getName=()=>`Accelerometer`;availability=()=>F.getAvailability();start(){this.imuProviderId=F.addEventListener(e=>{e.acceleration?this.notify(e.acceleration):this.notifyError(new we().from(`devicemotion`))},this.notifyError)}stop(){F.removeEventListener(this.imuProviderId)}},Te=class extends A{static DEFAULT_MESSAGE=`Impossible to retrieve Angular Rate data`;constructor(e){super(e||A.DEFAULT_MESSAGE)}},L=new class extends y{imuProviderId;getName=()=>`Gyroscope`;availability=()=>F.getAvailability();start(){this.imuProviderId=F.addEventListener(e=>{e.angularRate?this.notify(e.angularRate):this.notifyError(new Te().from(`devicemotion`))},this.notifyError)}stop(){F.removeEventListener(this.imuProviderId)}},Ee=new class e extends y{static DEFAULT_DRIFT=(0,n.deg2rad)(5)/60;accelerometerProviderId;ekfAttitude=new Ce;gyroscopeEvent;gyroscopeProviderId;lastTimestamp=0;getName=()=>`RelativeAttitudeFromEkf`;availability(){return b.every([I.getAvailability(),L.getAvailability()])}start(){this.accelerometerProviderId=I.addEventListener(e=>this.onAccelerometerEvent(e),e=>this.notifyError(e)),this.gyroscopeProviderId=L.addEventListener(e=>this.gyroscopeEvent=e,e=>this.notifyError(e))}stop(){I.removeEventListener(this.accelerometerProviderId),L.removeEventListener(this.gyroscopeProviderId)}onAccelerometerEvent=t=>{if(!this.gyroscopeEvent)return;let{values:n,timestamp:r}=t;if(this.lastTimestamp===0){this.lastTimestamp=r;return}let i=r-this.lastTimestamp;this.lastTimestamp=r;let a=this.ekfAttitude.update(i,n,this.gyroscopeEvent.values);if(a){let t=new s(a,r,e.DEFAULT_DRIFT);this.notify(t)}}},R=new class e extends y{static DEFAULT_DRIFT=(0,n.deg2rad)(5)/60;getName=()=>`RelativeAttitudeFromBrowser`;availability(){return i.BrowserUtils.isMobile?Promise.resolve():Promise.resolve(new k)}start(){let e=()=>window.addEventListener(`deviceorientation`,this.onDeviceOrientationEvent,!0),t=DeviceOrientationEvent.requestPermission||void 0;t?t().then(t=>{if(t!==`granted`)throw Error(`Permission not granted`);e()}).catch(e=>this.notifyError(e)):e()}stop(){window.removeEventListener(`deviceorientation`,this.onDeviceOrientationEvent,!0)}onDeviceOrientationEvent=t=>{if(typeof t.alpha!=`number`||typeof t.beta!=`number`||typeof t.gamma!=`number`){this.notifyError(new A().from(`deviceorientation`));return}let r=new s(n.Rotations.eulerToQuaternionZXYDegrees([t.alpha,t.beta,t.gamma]),t.timeStamp/1e3,e.DEFAULT_DRIFT);this.notify(r)}},z=new class e extends y{static THRESHOLD=10;static DELAY_CONSIDERATION=3;gyroscopeProviderId;getName=()=>`HighRotationsProvider`;availability=()=>L.getAvailability();start(){this.gyroscopeProviderId=L.addEventListener(this._parseGyroscopeEvent,this.notifyError)}stop(){L.removeEventListener(this.gyroscopeProviderId)}isInProgress(){return!this.lastEvent||!L.lastEvent?!1:L.lastEvent.timestamp-this.lastEvent.timestamp<e.DELAY_CONSIDERATION}_parseGyroscopeEvent=t=>{let{values:r,timestamp:i}=t;n.Vector3.norm(r)>e.THRESHOLD&&this.notify({timestamp:i})}},B=new class e extends y{static DEFAULT_DRIFT=(0,n.deg2rad)(5)/60;_highRotationsProviderId;listenerId;provider;getName=()=>`RelativeAttitudeFromInertial`;availability(){return b.some([Ee.getAvailability(),R.getAvailability()])}start(){Ee.getAvailability().then(e=>{this.provider=e?R:Ee,this.listenerId=this.provider.addEventListener(e=>this._parseEvent(e),this.notifyError),this._highRotationsProviderId=z.addEventListener(null,this.notifyError)})}_parseEvent(t){let n=t.clone();if(z.isInProgress()){let t=(n.accuracy||0)+e.DEFAULT_DRIFT*100;t=Math.min(t,Math.PI),n.accuracy=t}this.notify(n)}stop(){this.provider&&(this.provider.removeEventListener(this.listenerId),delete this.provider),z.removeEventListener(this._highRotationsProviderId)}},De=class e{static MIN_TIME_BETWEEN_STEPS=.4;static MAX_FRENQUENCY=4;static MIN_FRENQUENCY=1;static VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD=1;frequency=0;lastVerticalAcc=0;maxAcceleration=0;lastStepTimestamp=-e.MIN_TIME_BETWEEN_STEPS;compute(t,n){let r=!1,i=n[2],a=t-this.lastStepTimestamp;if(i>this.lastVerticalAcc)i>this.maxAcceleration&&(this.maxAcceleration=i);else if(this.maxAcceleration>e.VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD&&a>e.MIN_TIME_BETWEEN_STEPS){this.maxAcceleration=0;let n=t-this.lastStepTimestamp;this.frequency=Math.min(Math.max(1/n,e.MIN_FRENQUENCY),e.MAX_FRENQUENCY),r=!0,this.lastStepTimestamp=t}else this.maxAcceleration=0;return this.lastVerticalAcc=i,r}get lastStepSize(){return this.frequency?.45+.2*this.frequency:0}get speed(){return this.lastStepTimestamp?this.lastStepSize*this.frequency:0}},Oe=class e{static WINDOW_TIME=.3;static MIN_TIME_BETWEEN_STEPS=.4;static MAX_FRENQUENCY=4;static MIN_FRENQUENCY=1;static VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD=1.5;static VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD=-1;frequency=0;lastStepTimestamp=-e.MIN_TIME_BETWEEN_STEPS;slidingWindow=[];compute(t,n){if(this.lastStepTimestamp&&this.lastStepTimestamp+e.MIN_TIME_BETWEEN_STEPS>t)return!1;let r=-(2**53-1),i=2**53-1,a=e.WINDOW_TIME;if(this.slidingWindow.forEach((e,n,o)=>{e.timestamp<t-a?o.splice(n,1):(r=Math.max(e.verticalAcc,r),i=Math.min(e.verticalAcc,i))}),this.slidingWindow.push({timestamp:t,verticalAcc:n[2]}),r>e.VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD&&i<e.VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD){let n=this.lastStepTimestamp?t-this.lastStepTimestamp:1;return this.frequency=Math.min(Math.max(1/n,e.MIN_FRENQUENCY),e.MAX_FRENQUENCY),this.lastStepTimestamp=t,!0}return!1}get lastStepSize(){return this.frequency?.45+.2*this.frequency:0}get speed(){return this.lastStepTimestamp?this.lastStepSize*this.frequency:0}},ke=class e{static WINDOW_TIME=.3;static MIN_TIME_BETWEEN_STEPS=.4;static MAX_FRENQUENCY=4;static MIN_FRENQUENCY=1;static VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD=.75;static VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD=-.3;frequency=0;influence=.2;slidingWindow=[];lastStepTimestamp=-e.MIN_TIME_BETWEEN_STEPS;previousVerticalAcc=0;compute(t,n,r){let i=this.influence*(n[2]*2)+(1-this.influence)*this.previousVerticalAcc;if(this.previousVerticalAcc=i,Math.sqrt(r[0]**2+r[1]**2+r[2]**2)>.75||this.lastStepTimestamp&&this.lastStepTimestamp+e.MIN_TIME_BETWEEN_STEPS>t)return!1;let a=-(2**53-1),o=2**53-1;if(this.slidingWindow.forEach((n,r,i)=>{n.timestamp<t-e.WINDOW_TIME?i.splice(r,1):(a=Math.max(n.verticalAcc,a),o=Math.min(n.verticalAcc,o))}),this.slidingWindow.push({timestamp:t,verticalAcc:i}),a>e.VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD&&o<e.VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD){let n=this.lastStepTimestamp?t-this.lastStepTimestamp:1;return this.frequency=Math.min(Math.max(1/n,e.MIN_FRENQUENCY),e.MAX_FRENQUENCY),this.lastStepTimestamp=t,!0}return!1}get lastStepSize(){return this.frequency?.45+.2*this.frequency:0}get speed(){return this.lastStepSize&&this.frequency?this.lastStepSize*this.frequency:0}mean(e){let t=0,n=0;for(let n=0;n<e.length;++n)t+=e[n].verticalAcc;return n=t/e.length,n}stddev(e){let t=this.mean(e),n=0;for(let r=0;r<e.length;++r)n+=(e[r].verticalAcc-t)**2;return Math.sqrt(n/e.length)}},Ae=class e{static WINDOW_TIME=.6;static MIN_TIME_BETWEEN_STEPS=.6;static MAX_FRENQUENCY=4;static MIN_FRENQUENCY=1;static VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD=.2;static VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD=-.1;frequency=0;influence=.05;slidingWindow=[];lastStepTimestamp=-e.MIN_TIME_BETWEEN_STEPS;previousVerticalAcc=0;previousHorizontalAcc=0;compute(t,n){let r=this.influence*n[2]+(1-this.influence)*this.previousVerticalAcc;if(this.previousVerticalAcc=r,this.slidingWindow=this.slidingWindow.filter(n=>n.timestamp>=t-e.WINDOW_TIME),this.slidingWindow.push({timestamp:t,verticalAcc:r}),this.lastStepTimestamp&&this.lastStepTimestamp+e.MIN_TIME_BETWEEN_STEPS>t)return!1;let i=Number.MIN_VALUE,a=-1,o=!1;if(this.slidingWindow.forEach((t,n)=>{t.verticalAcc>i&&t.verticalAcc>=e.VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD&&(i=t.verticalAcc,a=n,o=!0)}),!o)return!1;let s=!1,c=Number.MAX_VALUE;for(let t=0;t<a;t++){let n=this.slidingWindow[t].verticalAcc;if(c=Math.min(c,n),n<e.VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD){s=!0;break}}if(!s)return!1;let l=i-c,u=i-.5*l,d=!1;for(let e=a+1;e<this.slidingWindow.length;e++)if(this.slidingWindow[e].verticalAcc<=u){d=!0;break}if(!d)return!1;let f=this.lastStepTimestamp?t-this.lastStepTimestamp:1;return this.frequency=Math.min(Math.max(1/f,e.MIN_FRENQUENCY),e.MAX_FRENQUENCY),this.lastStepTimestamp=t,!0}get lastStepSize(){return this.frequency?.45+.2*this.frequency:0}get speed(){return this.lastStepSize&&this.frequency?this.lastStepSize*this.frequency:0}mean(e){let t=0,n=0;for(let n=0;n<e.length;++n)t+=e[n];return n=t/e.length,n}stddev(e){let t=this.mean(e),n=0;for(let r=0;r<e.length;++r)n+=(e[r]-t)**2;return Math.sqrt(n/e.length)}},V=new class e extends y{static DEFAULT_STEP_SIZE_MULTIPLIER=1;static DEFAULT_ALGORITHM=`minMaxPeaks3`;accelerometerProviderId;attitudeProviderId;gyroscopeProviderId;angularRateEvent;attitudeEvent;numOfSteps=0;stepDetector;_stepSizeMultiplier=e.DEFAULT_STEP_SIZE_MULTIPLIER;_algorithm=e.DEFAULT_ALGORITHM;_accValues=[];constructor(){super(),this.algorithm=this._algorithm}getName=()=>`StepDetector`;availability(){return b.every([I.getAvailability(),L.getAvailability(),B.getAvailability()])}start(){this.numOfSteps=0,this.accelerometerProviderId=I.addEventListener(this.onAccelerometerEvent,this.notifyError),this.gyroscopeProviderId=L.addEventListener(e=>this.angularRateEvent=e,this.notifyError),this.attitudeProviderId=B.addEventListener(e=>this.attitudeEvent=e,this.notifyError)}stop(){I.removeEventListener(this.accelerometerProviderId),L.removeEventListener(this.gyroscopeProviderId),B.removeEventListener(this.attitudeProviderId)}onAccelerometerEvent=t=>{if(!this.attitudeEvent||!this.angularRateEvent)return;let{values:n,timestamp:r}=t,i=e.computeLinearAcceleration(this.attitudeEvent.quaternion,n);if(this.stepDetector.compute(r,i,this.angularRateEvent.values)){let e=this.stepDetector.lastStepSize*this._stepSizeMultiplier;this.numOfSteps++,this.notify({size:e,number:this.numOfSteps})}};static computeLinearAcceleration(e,r){let i=n.Quaternion.rotateMatlab(n.Quaternion.inverse(e),r);return i[2]-=t.Constants.EARTH_GRAVITY,i}set stepSizeMultiplier(e){this._stepSizeMultiplier=e}get stepSizeMultiplier(){return this._stepSizeMultiplier}set algorithm(e){switch(e){case`ladetto`:this.stepDetector=new De;break;case`minMaxPeaks`:this.stepDetector=new Oe;break;case`minMaxPeaks2`:this.stepDetector=new ke;break;default:e=`minMaxPeaks3`,this.stepDetector=new Ae;break}this._algorithm=e}get algorithm(){return this._algorithm}},je=new class extends y{absoluteAttitudeProviderId;stepDetectionProviderId;attitudeEvent;misalignmentError=(0,n.deg2rad)(3);getName=()=>`Pdr`;availability(){return b.every([V.getAvailability(),X.getAvailability()])}start(){this.stepDetectionProviderId=V.addEventListener(this.onStepEvent,this.notifyError),this.absoluteAttitudeProviderId=X.addEventListener(e=>this.attitudeEvent=e,this.notifyError)}stop(){V.removeEventListener(this.stepDetectionProviderId),X.removeEventListener(this.absoluteAttitudeProviderId)}onStepEvent=e=>{if(!this.attitudeEvent)return;let n=e.size,r=this.attitudeEvent,i=r.heading,a=r.accuracy+this.misalignmentError,o=n/2*Math.sin(a/2),s=r.time,c=new t.GeoRelativePosition(n*Math.sin(i),n*Math.cos(i),0,s,o,i);this.notify(c)}},H=new class extends y{providerId;geoRelativeProvider;getName=()=>`GeoRelativePosition`;availability(){return b.some([je.getAvailability(),be.getAvailability()])}async start(){let e=await be.getAvailability();this.geoRelativeProvider=e?je:be,this.providerId=this.geoRelativeProvider.addEventListener(this.notify,this.notifyError)}stop(){this.geoRelativeProvider?.removeEventListener(this.providerId),delete this.geoRelativeProvider}},Me={name:`@wemap/providers`,version:`14.6.1`,description:`Sensor, positioning and VPS providers for the Wemap SDK.`,license:`UNLICENSED`,author:`Wemap SAS`,homepage:`https://github.com/wemap/wemap-sdk-js#readme`,repository:{type:`git`,url:`git+https://github.com/wemap/wemap-sdk-js.git`,directory:`packages/providers`},bugs:{url:`https://github.com/wemap/wemap-sdk-js/issues`},keywords:[`wemap`,`sdk`,`providers`,`vps`],type:`module`,publishConfig:{access:`public`},main:`./dist/index.js`,types:`./dist/index.d.ts`,exports:{".":{import:`./dist/index.js`,types:`./dist/index.d.ts`}},sideEffects:!1,files:[`dist`],dependencies:{"@wemap/camera":`14.6.1`,"@wemap/core":`14.6.1`,"@wemap/geo":`14.6.1`,"@wemap/maths":`14.6.1`,"@wemap/osm":`14.6.1`,"@wemap/routers":`14.6.1`,"@wemap/utils":`14.6.1`},devDependencies:{"@wemap/logger-legacy":`^13.3.0`,geomag:`^1.0.0`}},Ne=new class extends y{providerId;getName=()=>`InclinationFromAcc`;availability=()=>I.getAvailability();start(){this.providerId=I.addEventListener(this.onAccelerometerEvent,this.notifyError)}stop(){I.removeEventListener(this.providerId)}onAccelerometerEvent=e=>{let t=e.values,n=window.orientation||0,r=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),i=[t[0]/r,t[1]/r,t[2]/r],a=[i[2]+1,i[1],-i[0],0],o=Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]),s=[a[0]/o,a[1]/o,a[2]/o,0],c;c=n===0?Math.asin(2*s[1]*s[0]):n===90?-Math.asin(2*s[2]*s[0]):n===-90?Math.asin(2*s[2]*s[0]):-Math.asin(2*s[1]*s[0]),this.notify(c)}},U=new class extends y{providerId;getName=()=>`InclinationFromRelativeAttitude`;availability=()=>B.getAvailability();start(){this.providerId=B.addEventListener(e=>{let t=this.enuQuatToInclination(e.quaternion);this.notify(t)},this.notifyError)}stop(){B.removeEventListener(this.providerId)}enuQuatToInclination(e){let t=window.orientation||0;return t===0?Math.asin(2*(e[2]*e[3]+e[1]*e[0])):t===90?Math.asin(2*(e[1]*e[3]-e[2]*e[0])):t===-90?Math.asin(2*(e[2]*e[0]-e[1]*e[3])):-Math.asin(2*(e[2]*e[3]+e[1]*e[0]))}},W=new class extends y{provider;providerId;getName=()=>`Inclination`;availability(){return b.some([Ne.getAvailability(),U.getAvailability()])}async start(){let e=()=>{this.provider=Ne,this.providerId=this.provider.addEventListener(this.notify,this.notifyError)};await U.getAvailability()?(this.provider=U,this.providerId=this.provider.addEventListener(this.notify,()=>{U.removeEventListener(this.providerId),e()})):e()}stop(){this.provider&&this.provider.removeEventListener(this.providerId)}},Pe=class e{size;calibration;coarse;device;constructor(e,t=null,n=null,r=null){this.size=e,this.calibration=t,this.coarse=n,this.device=r}toJson(){return{size:[this.size.width,this.size.height],...this.calibration&&{calibration:this.calibration},...this.coarse&&{coarse:{...this.coarse.attitude&&{attitude:this.coarse.attitude.toJson()},...this.coarse.position&&{position:this.coarse.position.toJson()}}},...this.device!==null&&{device:this.device}}}static fromJson(n){return new e({width:n.size[0],height:n.size[1]},n.calibration,{...n.coarse?.position&&{position:t.UserPosition.fromJson(n.coarse.position)},...n.coarse?.attitude&&{attitude:t.Attitude.fromJson(n.coarse.attitude)}},n.device)}},Fe=class e{metadata;image;imageQuality;localPose;constructor(e,t,n=.8,r=null){this.metadata=e,this.image=t,this.imageQuality=n,this.localPose=r}toJson(){return{image:(0,a.canvasToBase64)(this.image,`image/jpeg`,this.imageQuality),...this.localPose&&{local_pose:this.localPose},...this.metadata.toJson()}}static fromJson(t){return new e(Pe.fromJson(t),(0,a.base64ToCanvas)(t.image))}toFormData(){let e=this.image.toDataURL(`image/jpeg`,this.imageQuality).split(`,`)[1]||``,t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);let r=new FormData;r.append(`image`,new Blob([n],{type:`image/jpeg`}),`image.jpg`);let i=this.metadata.toJson();return i.calibration&&r.append(`calibration`,JSON.stringify(i.calibration)),i.coarse&&r.append(`coarse`,JSON.stringify(i.coarse)),i.device&&r.append(`device`,JSON.stringify(i.device)),this.localPose&&r.append(`local_pose`,JSON.stringify(this.localPose)),r}},Ie=class e{success;attitude;position;constructor(e,t=null,n=null){this.success=e,this.attitude=t,this.position=n}toJson(){return{success:this.success,attitude:this.attitude?.toJson(),position:this.position?.toJson()}}static fromJson(n,r=null){let i=null;n.attitude&&(i=t.Attitude.fromJson(n.attitude),i.time=r);let a=null;return n.position&&(a=t.UserPosition.fromJson(n.position),a.time=r),new e(n.success,i,a)}},Le=class{static _prepareRequest(e,t=null,n=null,r=null,o=null){let s=(0,a.reduceImageSize)(e,720,720),c=i.UserAgentUtils.getDeviceFromUserAgent()||{};return r&&(c.session_id=r.session_id,c.installation_id=r.installation_id,c.attempt_id=r.attempt_id,c.caller=r.caller),new Fe(new Pe({width:s.width,height:s.height},t,n,c),s,.8,o)}static async relocalize(e,t,n=null,r=null,a=null,o=null,s=null){let c=i.TimeUtils.preciseTime()/1e3,l=this._prepareRequest(t,n,r,a,o),u;try{let t=l.toFormData();u=await fetch(e,{method:`POST`,body:t,headers:Object.assign({Accept:`application/vnd.geopose+json; version=1`},s||{})})}catch{return g.debug(`[VPS] Server respond error`),null}if(u.status!==200)return g.debug(`[VPS] Server respond error`),null;let d=await u.json(),f=Ie.fromJson(d,c);return g.debug(`[VPS] Server respond ${f.success?`success`:`not found`}`),f}static getHeadingFromQuaternion(e){let[t,n,r,i]=e,a=Math.sqrt(2)/2,o=[a*(t-n),a*(t+n),a*(r+i),a*(i-r)];return-Math.atan2(2*o[3]*o[0]-2*o[2]*o[1],1-2*o[1]**2-2*o[3]**2)}},G=new class extends y{arCoreMonitoringId;arCoreProviderId;inertialProviderId;getName=()=>`RelativeAttitude`;availability=()=>B.getAvailability();start(){this.arCoreMonitoringId=P.addMonitoringListener(()=>{this.listenArCore(),this.unlistenInertial()},()=>{this.unlistenArCore(),this.listenInertial()}),P.state===`started`?this.listenArCore():this.listenInertial()}stop(){P.removeMonitoringListener(this.arCoreMonitoringId),this.unlistenArCore(),this.unlistenInertial()}listenInertial=()=>{this.inertialProviderId=B.addEventListener(this.notify,this.notifyError)};unlistenInertial=()=>{B.removeEventListener(this.inertialProviderId)};listenArCore=()=>{this.arCoreProviderId=P.addEventListener(e=>this.notify(e.relativeAttitude),null,!1)};unlistenArCore=()=>{P.removeEventListener(this.arCoreProviderId)}},Re=class{_providerId;_isRunning=!1;_dataOnStart=null;tickStart(){this._dataOnStart=null,!this._isRunning&&(this._isRunning=!0,this._providerId=R.addEventListener(e=>{this._dataOnStart||=e}))}tickEnd(){if(!this._isRunning)return g.warn(`You have to call tickStart before tickEnd`),null;if(this._internalStop(),!this._dataOnStart)return g.warn(`Delay was too short between tickStart and tickEnd or RelativeAttitudeProvider cannot be retrieved.`),null;let e=R.lastEvent;return t.Attitude.diff(this._dataOnStart,e)}_internalStop(){R.removeEventListener(this._providerId),delete this._providerId,this._isRunning=!1}release(){this._isRunning&&this._internalStop()}},ze=class e extends Error{static DEFAULT_MESSAGE=`PoleStar is missing`;constructor(t){super(t||e.DEFAULT_MESSAGE)}},K=new class extends y{getName=()=>`PoleStar`;constructor(){super(),this.addMethodsToNativeJsProvider()}availability(){try{return this.nativeProvider.checkAvailability(),Promise.resolve()}catch(e){return Promise.resolve(e)}}setApiKey(e){this.nativeProvider.setApiKey(e)}start(){this.nativeProvider.start()}stop(){this.nativeProvider.stop()}get nativeProvider(){if(!this.nativeInterface)throw new ye;let e=this.nativeInterface.getPoleStarProvider();if(!e)throw new ze;return e}addMethodsToNativeJsProvider(){this.nativeJsInterface&&(this.nativeJsInterface.polestar={callbackError:e=>this.notifyError(Error(e)),callbackPosition:e=>{let t=JSON.parse(e),r=i.TimeUtils.unixTimestampToPreciseTime(t.time)/1e3,a=new o(t.lat,t.lng,M.DEFAULT_ALTITUDE,t.alt/5,r,t.accuracy,(0,n.deg2rad)(t.bearing));this.notify(a)}})}},q=new class e extends y{static MIN_TIME_BETWEEN_TWO_REQUESTS=1e3;static DEFAULT_MIN_INCLINATION_FOR_REQUEST=(0,n.deg2rad)(60);static DEFAULT_WAIT_TIME_MIN_INCLINATION_FOR_REQUEST=200;static DEFAULT_USE_COARSE_POSE=!0;static DEFAULT_REQUEST_CALLER=`@wemap/providers(VpsProvider) ${Me.version}`;static CAMERA_TO_SMARTPHONE_ROT=n.Quaternion.fromAxisAngle([1,0,0],Math.PI);static ENU_TO_ARCORE_ROT=n.Quaternion.fromAxisAngle([1,0,0],-Math.PI/2);static _scanFailureCallbackUniqueId=0;_relativeRotationCalc;_serverError=!1;_cameraError=!1;_camera=null;_endpoint=null;_inclinationProviderId;_minInclinationForRequest=e.DEFAULT_MIN_INCLINATION_FOR_REQUEST;_waitTimeMinInclinationForRequest=e.DEFAULT_WAIT_TIME_MIN_INCLINATION_FOR_REQUEST;_useCoarsePose=e.DEFAULT_USE_COARSE_POSE;_requestCaller=e.DEFAULT_REQUEST_CALLER;_sessionId;_attemptIdCounter=0;_currentAttemptId=null;_scanFailureCallbacks=[];constructor(){super(),this._sessionId=this._generateUuid()}getName=()=>`Vps`;availability=()=>a.Camera.checkAvailability();start(){this._inclinationProviderId=W.addEventListener(),this._relativeRotationCalc=new Re,a.SharedCameras.on(`added`,this._onCameraDetected),a.SharedCameras.on(`removed`,this._onCameraRemoved),a.SharedCameras.list.length&&(a.SharedCameras.list.length>1&&g.warn(`It seems that more than 1 camera has been detected for VPS. Taking the first...`),this._useCamera(a.SharedCameras.list[0].camera))}stop(){W.removeEventListener(this._inclinationProviderId),this._relativeRotationCalc?.release(),a.SharedCameras.off(`added`,this._onCameraDetected),a.SharedCameras.off(`removed`,this._onCameraRemoved),this._camera=null}_onCameraDetected=({camera:e})=>{this._camera&&g.warn(`It seems that more than 1 camera has been detected for VPS. Taking the first...`),this._useCamera(e)};_onCameraRemoved=()=>{this._camera?(this._camera.off(`started`,this._internalStart),this._camera.off(`stopped`,this._internalStop)):g.warn(`There is no previously detected camera but once has stopped`),this._camera=null};_useCamera(e){this._camera=e,e.on(`started`,this._internalStart),e.on(`stopped`,this._internalStop),e.state===`started`&&this._internalStart()}_internalStart=async()=>{if(!this._endpoint){this.notifyError(Error(`VPS endpoint has not been set before calling start()`));return}let r=null,a=()=>this.state===`stopped`;for(;!a();){if(r!==null){let t=i.TimeUtils.preciseTime()-r,n=Math.max(0,e.MIN_TIME_BETWEEN_TWO_REQUESTS-t);await new Promise(e=>setTimeout(e,n))}if(r=i.TimeUtils.preciseTime(),a()||!this._camera||this._camera.state!==`started`)break;let o=W.lastEvent?W.lastEvent:null;if(o!==null&&o<this._minInclinationForRequest){await new Promise(e=>setTimeout(e,this._waitTimeMinInclinationForRequest));continue}this._relativeRotationCalc?.tickStart();let s=await this._camera.currentImage;if(!s)continue;let l=null,u=J.getBestPositionEvent(N.lastEvent,K.lastEvent);this._useCoarsePose&&(u||X.lastEvent)&&(l={...u&&{position:u},...X.lastEvent&&{attitude:X.lastEvent}}),this._currentAttemptId===null&&(this._attemptIdCounter+=1,this._currentAttemptId=this._attemptIdCounter);let d=G.lastEvent,f=H.lastEvent,p=d&&f?{position:n.Quaternion.rotate(e.ENU_TO_ARCORE_ROT,[f.x,f.y,f.z]),orientation:n.Quaternion.multiply(e.ENU_TO_ARCORE_ROT,d.quaternion)}:null,m=await Le.relocalize(this._endpoint,s,null,l,{session_id:this._sessionId,installation_id:null,...this._currentAttemptId!==null&&{attempt_id:this._currentAttemptId},caller:this._requestCaller},p);if(!m||!m.success){this._scanFailureCallbacks.forEach(({id:e,callback:t})=>t({listenerId:e,sessionId:this._sessionId,attemptId:this._currentAttemptId}));continue}this._currentAttemptId=null;let h=m.attitude.quaternion,g=n.Quaternion.multiply(h,e.CAMERA_TO_SMARTPHONE_ROT),_=n.Quaternion.multiply(n.Quaternion.fromAxisAngle([0,0,1],(0,n.deg2rad)(window.orientation||0)),g),v=this._relativeRotationCalc?.tickEnd()||new t.Attitude([1,0,0,0]),y=new c(n.Quaternion.multiply(_,v.quaternion),m.attitude.time,m.attitude.accuracy),b=m.position.clone();if(b.accuracy===null&&(b.accuracy=5),a())break;this.notify({absoluteAttitude:y,absolutePosition:b})}};_internalStop=()=>{};_generateUuid(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}addScanFailureListener(t){let n=++e._scanFailureCallbackUniqueId;return this._scanFailureCallbacks.push({id:n,callback:t}),n}removeScanFailureListener(e){this._scanFailureCallbacks=this._scanFailureCallbacks.filter(({id:t})=>t!==e)}resetCurrentAttempt(){this._currentAttemptId=null}get endpoint(){return this._endpoint}set endpoint(e){this._endpoint=e}get minInclinationForRequest(){return this._minInclinationForRequest}set minInclinationForRequest(e){this._minInclinationForRequest=e}get waitTimeMinInclinationForRequest(){return this._waitTimeMinInclinationForRequest}set waitTimeMinInclinationForRequest(e){this._waitTimeMinInclinationForRequest=e}get useCoarsePose(){return this._useCoarsePose}set useCoarsePose(e){this._useCoarsePose=e}get requestCaller(){return this._requestCaller}set requestCaller(e){this._requestCaller=e}},J=new class e extends y{static ACCURACY_RELOC_RATIO=1;static USE_MM_FOR_FEED=!0;_polestarProviderId;_vpsProviderId;_gnssWifiProviderId;_relativePositionProviderId;_mapMatchingHandlerId;useAllAbsolutePositions=!1;_waitUntilNextVpsPosition=!1;_lastPolestarFix=null;ignoreGnssWifi=!1;_lastKnownLevel=null;getName=()=>`AbsolutePosition`;_adaptBeforeNotify(e){return e.level===null?e.level=this._lastKnownLevel:this._lastKnownLevel=e.level,e}availability(){return b.some([H.getAvailability(),N.getAvailability(),...l.hasPoleStar?[K.getAvailability()]:[],q.getAvailability()])}start(){H.getAvailability().then(e=>{e||(this._relativePositionProviderId=H.addEventListener(e=>this._onRelativePosition(e)))}),this._gnssWifiProviderId=N.addEventListener(e=>{if(this.ignoreGnssWifi)return;let t=e.clone();t.bearing=null,this._onAbsolutePosition(t,`gnss-wifi`,!1)}),this._vpsProviderId=q.addEventListener(e=>this._onAbsolutePosition(e.absolutePosition,`vps`),this.notifyError,!1),l.hasPoleStar&&(this._polestarProviderId=K.addEventListener(e=>{if(this._lastPolestarFix=i.TimeUtils.preciseTime(),!this._onAbsolutePosition(e,`polestar`)&&this.lastEvent?.level===null){let t=this.lastEvent.clone();t.level=e.level,this.notify(t)}})),this._mapMatchingHandlerId=$.addEventListener()}stop(){this._relativePositionProviderId&&(H.removeEventListener(this._relativePositionProviderId),delete this._relativePositionProviderId),this._gnssWifiProviderId&&(N.removeEventListener(this._gnssWifiProviderId),delete this._gnssWifiProviderId),this._vpsProviderId&&(q.removeEventListener(this._vpsProviderId),delete this._vpsProviderId),this._polestarProviderId&&(K.removeEventListener(this._polestarProviderId),delete this._polestarProviderId),$.removeEventListener(this._mapMatchingHandlerId)}_shouldTakeIntoAccountNewAbsolutePosition(n,r=!0){let i=n,a=this.lastEvent||null;if(!a)return!0;let o=i.accuracy*e.ACCURACY_RELOC_RATIO<=a.accuracy;if(o)return!0;let s=a.distanceTo(i)>a.accuracy+i.accuracy;if(s)return!0;let c=s&&i.accuracy<=a.accuracy;return!!(o&&c||r&&!t.Level.equals(i.level,a.level))}_onAbsolutePosition(e,t,n=!0){if(!this._shouldTakeIntoAccountNewAbsolutePosition(e,n)&&!this.useAllAbsolutePositions)return!1;let r=o.fromUserPosition(e,t),i=this.lastEvent?this.lastEvent:null;return i&&(n||(r.level=i.level),r.bearing===null&&(r.bearing=i.bearing)),$.canUseMapMatching()?$.notifyPositionFromAbsolute(r):(this.notify(r),!0)}_onRelativePosition(e){if(!this.lastEvent||this._waitUntilNextVpsPosition)return!1;let t=this.lastEvent,n=e,r=Math.sqrt(n.x**2+n.y**2),i=Math.atan2(n.x,n.y),a=t.alt===null?null:n.z,s=t.destinationPoint(r,i,a);s.bearing=n.bearing,s.time=n.time,s.accuracy+=n.accuracy;let c=o.fromUserPosition(s,`relative`);return $.canUseMapMatching()?$.notifyPositionFromRelative(c):(this.notify(c),!0)}feed(n){let r;if(n instanceof t.UserPosition){if(n.time===null)throw Error(`the time of the position is not defined`);if(n.accuracy===null)throw Error(`the accuracy of the position is not defined`);r=o.fromUserPosition(n,n.source??`feed`)}else throw Error(`data is nor an UserPosition or an AbsolutePositionEvent`);if(!e.USE_MM_FOR_FEED||!$.canUseMapMatching()){this.notify(r);return}$.notifyPositionFromFeed(r)}getBestPositionEvent(...e){return e.reduce((e,t)=>{if(!e)return t;if(!t||t.accuracy===null||t.time===null)return e;let{accuracy:n,time:r}=t,{accuracy:i,time:a}=e;return n<i+1.3888*(r-a)?t:e},null)}},Y=new class e extends y{DEFAULT_ACCURACY=(0,n.deg2rad)(15);absolutePositionProviderId;absolutePositionEvent;declinationQuaternion;magQuaternion;magQuaternionTimestamp;iosPreviousQuat;iosIsSkyMode=null;getName=()=>`AbsoluteAttitudeFromBrowser`;availability(){return i.BrowserUtils.isMobile?Promise.resolve():Promise.resolve(new k)}start(){let e=()=>{switch(i.BrowserUtils.getName()){case i.Browser.CHROME:window.addEventListener(`deviceorientationabsolute`,this.onDeviceOrientationChromeEvent,!0);break;case i.Browser.SAFARI:case i.Browser.IOS_WEBVIEW:window.addEventListener(`deviceorientation`,this.onDeviceOrientationSafariEvent,!0);break}},t=DeviceOrientationEvent.requestPermission||void 0;t?t().then(t=>{if(t!==`granted`)throw Error(`Permission not granted`);e()}).catch(this.notifyError):e();let n=J.lastEvent;n?this.onAbsolutePositionEvent(n):this.absolutePositionProviderId=J.addEventListener(this.onAbsolutePositionEvent,this.notifyError,!1)}stop(){switch(i.BrowserUtils.getName()){case i.Browser.CHROME:window.removeEventListener(`deviceorientationabsolute`,this.onDeviceOrientationChromeEvent,!0);break;case i.Browser.SAFARI:case i.Browser.IOS_WEBVIEW:window.removeEventListener(`deviceorientation`,this.onDeviceOrientationSafariEvent,!0);break}J.removeEventListener(this.absolutePositionProviderId)}onDeviceOrientationChromeEvent=e=>{if(this.magQuaternionTimestamp=e.timeStamp/1e3,typeof e.alpha!=`number`||typeof e.beta!=`number`||typeof e.gamma!=`number`){this.notifyError(new A().from(`deviceorientationabsolute`));return}this.magQuaternion=n.Rotations.eulerToQuaternionZXYDegrees([e.alpha,e.beta,e.gamma]),this.compute()};onDeviceOrientationSafariEvent=t=>{if(this.magQuaternionTimestamp=t.timeStamp/1e3,typeof t.beta!=`number`||typeof t.gamma!=`number`){this.notifyError(new A().from(`deviceorientation`));return}if(typeof t.webkitCompassHeading!=`number`){this.notifyError(new j().from(`deviceorientation`));return}let r,[i,a,o,s]=n.Rotations.eulerToQuaternionZXYDegrees([t.webkitCompassHeading,t.beta,t.gamma]),c=(0,n.rad2deg)(Math.acos(i**2-a**2-o**2+s**2)),l=null;c>136?l=!0:c<134?l=!1:this.iosPreviousQuat&&this.iosIsSkyMode!==null&&(l=n.Quaternion.distance([i,a,o,s],this.iosPreviousQuat)<.5?this.iosIsSkyMode:!this.iosIsSkyMode),this.iosPreviousQuat=[i,a,o,s],this.iosIsSkyMode=l,l!==void 0&&(r=l?180-t.webkitCompassHeading:e.webkitCompassToHeading(t.webkitCompassHeading,t.beta,t.gamma),this.magQuaternion=n.Rotations.eulerToQuaternionZXYDegrees([r,t.beta,t.gamma]),this.compute())};compute(){if(!this.declinationQuaternion||!this.magQuaternion||!this.absolutePositionEvent)return;let e=new c(n.Quaternion.multiply(this.declinationQuaternion,this.magQuaternion),this.magQuaternionTimestamp,this.DEFAULT_ACCURACY);this.notify(e)}onAbsolutePositionEvent=e=>{this.absolutePositionEvent=e;let t=me(e.lat,e.lng);this.declinationQuaternion=n.Quaternion.fromAxisAngle([0,0,1],-(0,n.deg2rad)(t.declination)),J.removeEventListener(this.absolutePositionProviderId),delete this.absolutePositionProviderId,this.compute()};static webkitCompassToHeading(e,t,r){let i=(0,n.deg2rad)(e),a=(0,n.deg2rad)(t),o=(0,n.deg2rad)(r),s=Math.cos(i/2),c=Math.cos(a/2),l=Math.cos(o/2),u=Math.sin(i/2),d=Math.sin(a/2),f=Math.sin(o/2),p=s*c*l-u*d*f,m=u*c*l+s*d*f;return(0,n.rad2deg)(-2*Math.atan(m/p))}},X=new class e extends y{static REL_ABS_DIVERGENCE_ANGLE_THRESHOLD=(0,n.deg2rad)(25);static REL_ABS_DIVERGENCE_TIME_THRESHOLD=2.5;static REL_ABS_DIVERGENCE_INCLINATION_THRESHOLD=(0,n.deg2rad)(15);_absAttitudeFromBrowser;_vpsProviderId;fromBrowserProviderId;highRotationProviderId;inclinationProviderId;relativeAttitudeProviderId;_attitudeFromBrowserErrored=!1;_attitudeFromRelativeErrored=!1;_relativeAttitude=null;_relativeAccuracy=0;_lastForcedHeadingEvent;_relAbsQuat;_wasHighRotationInProgress=!1;_timeFirstDivergence=null;_callbackMagCalibration;getName=()=>`AbsoluteAttitude`;availability(){return b.some([Y.getAvailability(),G.getAvailability()])}start(){this.fromBrowserProviderId=Y.addEventListener(this._onAttitudeFromBrowser,e=>{this._attitudeFromBrowserErrored=!0,this._onError(e)}),this._vpsProviderId=q.addEventListener(e=>this._onAttitudeFromVps(e.absoluteAttitude),e=>this.notifyError(e),!1),this.relativeAttitudeProviderId=G.addEventListener(this._onRelativeAttitudeEvent,e=>{this._attitudeFromRelativeErrored=!0,this._onError(e)}),this.inclinationProviderId=W.addEventListener(),this.highRotationProviderId=z.addEventListener()}stop(){Y.removeEventListener(this.fromBrowserProviderId),G.removeEventListener(this.relativeAttitudeProviderId),W.removeEventListener(this.inclinationProviderId),z.removeEventListener(this.highRotationProviderId),q.removeEventListener(this._vpsProviderId)}_setCallbackMagCalibration(e){this._callbackMagCalibration=e}_onError=e=>{this._attitudeFromBrowserErrored&&this._attitudeFromRelativeErrored&&this.notifyError(e)};_forceHeadingForRelative=e=>{if(this.lastEvent&&e.accuracy>this.lastEvent.accuracy)return;let t=t=>{let r=t.heading;this._relAbsQuat=n.Quaternion.fromAxisAngle([0,0,1],r-e.heading),this._relativeAccuracy=0,this._lastForcedHeadingEvent=e};if(this._relativeAttitude){t(this._relativeAttitude);return}let r=G.addEventListener(e=>{t(e),G.removeEventListener(r)})};_onRelativeAttitudeEvent=r=>{let{quaternion:i,accuracy:a,time:o}=r;if(this._relativeAttitude&&(this._relativeAccuracy+=(o-this._relativeAttitude.time)*a),this._relativeAttitude=r,!this._lastForcedHeadingEvent||!this._relAbsQuat)return;let s=Math.min((this._lastForcedHeadingEvent.accuracy||0)+this._relativeAccuracy,Math.PI),l=z.isInProgress(),u=!1;if(this._absAttitudeFromBrowser){let{accuracy:r,heading:a}=this._absAttitudeFromBrowser;if(this._wasHighRotationInProgress&&!l)this._forceHeadingForRelative(this._absAttitudeFromBrowser);else if(r<s){let r=new t.Attitude(n.Quaternion.multiply(this._relAbsQuat,i)),s=Math.abs((0,n.diffAngle)(r.heading,a)),c=W.lastEvent;s>e.REL_ABS_DIVERGENCE_ANGLE_THRESHOLD&&c!==null&&Math.abs(c-Math.PI/4)>e.REL_ABS_DIVERGENCE_INCLINATION_THRESHOLD&&(u=!0,this._timeFirstDivergence!==null&&o-this._timeFirstDivergence>e.REL_ABS_DIVERGENCE_TIME_THRESHOLD?(this._forceHeadingForRelative(this._absAttitudeFromBrowser),this._callbackMagCalibration?.({angle:s}),this._timeFirstDivergence=null):this._timeFirstDivergence===null&&(this._timeFirstDivergence=o))}}u||(this._timeFirstDivergence=null),this._wasHighRotationInProgress=l;let d=new c(n.Quaternion.multiply(this._relAbsQuat,i),o,s);this.notify(d)};_onAttitudeFromBrowser=e=>{if(this._absAttitudeFromBrowser=e,!this._lastForcedHeadingEvent){this._forceHeadingForRelative(e);return}};_onAttitudeFromVps=e=>{this._forceHeadingForRelative(e)};feed(e){if(e instanceof t.AbsoluteHeading){if(e.time===null)throw Error(`the time of the absolute heading is not defined`);if(e.accuracy===null)throw Error(`the accuracy of the absolute heading is not defined`);this._forceHeadingForRelative(e)}else if(e instanceof c){if(e.time===null)throw Error(`the time of the attitude is not defined`);if(e.accuracy===null)throw Error(`the accuracy of the attitude is not defined`);this._forceHeadingForRelative(e)}else throw Error(`data is nor an AbsoluteHeading or an Attitude object`)}},Z=new class e extends y{static SLIDING_WINDOW_TIME=.3;static STD_THRESHOLD=.075;static CONSIDER_TURN_UNTIL=1;providerId;slidingWindow=[];getName=()=>`Turn`;availability=()=>G.getAvailability();start(){this.providerId=G.addEventListener(this._parseRelativeAttitude,this.notifyError)}stop(){G.removeEventListener(this.providerId)}isTurning(){return!this.lastEvent||!G.lastEvent?!1:G.lastEvent.time-this.lastEvent.timestamp<e.CONSIDER_TURN_UNTIL}_parseRelativeAttitude=t=>{let{heading:r}=t,i=t.time;this.slidingWindow=this.slidingWindow.filter(t=>t[0]>=i-e.SLIDING_WINDOW_TIME),this.slidingWindow.push([i,r]),(0,n.std)(this.slidingWindow.map(e=>e[1]))>e.STD_THRESHOLD&&this.notify({timestamp:i})}},Q=new class e extends y{static DEFAULT_STEPS_CONSIDERED_FOR_STRAIGHT_LINE=2;_turnProviderId;_stepProviderId;_countSteps=0;_stepsConsideredForStraightLine=e.DEFAULT_STEPS_CONSIDERED_FOR_STRAIGHT_LINE;getName=()=>`StraightLine`;availability(){return b.every([Z.getAvailability(),V.getAvailability()])}start(){this._turnProviderId=Z.addEventListener(this._onTurn),this._stepProviderId=V.addEventListener(this._onStep)}stop(){Z.removeEventListener(this._turnProviderId),V.removeEventListener(this._stepProviderId)}_onTurn=()=>{this._countSteps>=this._stepsConsideredForStraightLine&&this.notify(!1),this._countSteps=0};_onStep=()=>{this._countSteps++,this._countSteps===this._stepsConsideredForStraightLine&&this.notify(!0)};isStraight(){return this._countSteps>=this._stepsConsideredForStraightLine}get numStepsDetectedFromLastTurn(){return this._countSteps}get stepsConsideredForStraightLine(){return this._stepsConsideredForStraightLine}set stepsConsideredForStraightLine(e){this._stepsConsideredForStraightLine=e}},$=new class e extends y{static DEFAULT_MM_MAX_ANGLE=(0,n.deg2rad)(30);static DEFAULT_MM_MAX_DIST=30;static DEFAULT_USE_ITINERARY_START_AS_POSITION=!1;static DEFAULT_USE_ORIENTATION_MATCHING=!0;static DEFAULT_MM_HUGE_JUMP_DISTANCE=3;static DEFAULT_DISABLE_MM_CLOSE_TO_A_TURN_DISTANCE=2;static DEFAULT_MIN_STEPS_BETWEEN_ORIENTATION_MATCHING=3;static DEFAULT_MIN_STEPS_FOR_ORIENTATION_MATCHING=5;static DEFAULT_LAST_PROJECTIONS_WINDOW_SIZE=3;static DEFAULT_LAST_PROJECTIONS_EDGE_ANGLE_THRESHOLD=(0,n.deg2rad)(3);static DEFAULT_USE_STRICT=!1;_mapMatchingMaxDistance=e.DEFAULT_MM_MAX_DIST;_mapMatchingMaxAngleBearing=e.DEFAULT_MM_MAX_ANGLE;_useItineraryStartAsPosition=e.DEFAULT_USE_ITINERARY_START_AS_POSITION;_useOrientationMatching=e.DEFAULT_USE_ORIENTATION_MATCHING;_hugeJumpDistance=e.DEFAULT_MM_HUGE_JUMP_DISTANCE;_disableMMCloseToATurnDistance=e.DEFAULT_DISABLE_MM_CLOSE_TO_A_TURN_DISTANCE;_minStepsBetweenOrientationMatching=e.DEFAULT_MIN_STEPS_BETWEEN_ORIENTATION_MATCHING;_minStepsForOrientationMatching=e.DEFAULT_MIN_STEPS_FOR_ORIENTATION_MATCHING;_lastProjectionsWindowSize=e.DEFAULT_LAST_PROJECTIONS_WINDOW_SIZE;_lastProjectionsEdgeAngleThreshold=e.DEFAULT_LAST_PROJECTIONS_EDGE_ANGLE_THRESHOLD;_useStrict=e.DEFAULT_USE_STRICT;_graph=null;_internalProvidersStarted=!1;_straightLineProviderId;_turnProviderId;_stepProviderId;_projectionsWithAbsAndWithoutRelAttitudeInARow=[];_countStepsFromLastMatching=0;_lastProjections=[];_itineraryInfoManager=null;getName=()=>`MapMatchingHandler`;availability=()=>Promise.resolve();start(){this.graph&&this._startInternalProviders()}stop(){this._stopInternalProviders()}_manageStartStop=()=>{this.graph&&!this._internalProvidersStarted?this._startInternalProviders():!this.graph&&this._internalProvidersStarted&&this._stopInternalProviders()};_startInternalProviders(){this.enabled&&this._internalProvidersStarted||(this._straightLineProviderId=Q.addEventListener(),this._turnProviderId=Z.addEventListener(),this._stepProviderId=V.addEventListener(()=>this._countStepsFromLastMatching++),this._internalProvidersStarted=!0)}_stopInternalProviders(){this.enabled&&!this._internalProvidersStarted||(Q.removeEventListener(this._straightLineProviderId),Z.removeEventListener(this._turnProviderId),V.removeEventListener(this._stepProviderId),this._internalProvidersStarted=!1)}get enabled(){return l.useMapMatching}get graph(){return this._graph}set graph(e){this._graph=e,this._itineraryInfoManager=null,this.notify({...e&&{graph:e}}),this._manageStartStop(),this.canUseMapMatching()}set itinerary(e){this._graph=e?e.toGraph():null,this._itineraryInfoManager=new r.ItineraryInfoManager(e),this.notify({...e&&{itinerary:e}}),this._manageStartStop(),this.canUseMapMatching()&&e&&this._notifyPositionFromItineraryInput(e)}canUseMapMatching(){return this.enabled&&this.graph}_notifyPositionFromItineraryInput(e){if(!this._useItineraryStartAsPosition||!e.origin)return;let n=J.lastEvent||null,r=t.UserPosition.fromCoordinates(e.origin);if(n)r.alt=n.alt,r.time=n.time,r.accuracy=n.accuracy+r.distanceTo(n),r.bearing=n.bearing;else if(e.coords.length>=2)r.alt=M.DEFAULT_ALTITUDE,r.time=i.TimeUtils.preciseTime(),r.accuracy=0,r.bearing=e.coords[0].bearingTo(e.coords[1]);else return;let a=this.getProjection(r,!0);a?J.notify(a.coords):J.notify(r)}notifyPositionFromFeed(e){let t=this.getProjection(e,!0,!1);if(this._useStrict&&t){J.notify(t.coords);return}if(!t){J.notify(e);return}J.notify(t.coords)}notifyPositionFromAbsolute(e){if(this._useStrict){let t=this.getProjection(e);if(t)return J.notify(t.coords),!0}let t=null;if(e.bearing!==null&&(t=this.getProjection(e,!0,!0)),!t)return J.notify(e),!0;let n=t.distanceFromNearestElement>this._hugeJumpDistance;return n&&!Q.isStraight()||n&&this._detectWrongBigJump(t)?!1:(J.notify(t.coords),this.tryOrientationMatching(t),!0)}notifyPositionFromRelative(e){let t=this.getProjection(e,!0,!0);if(this._useStrict&&t)return J.notify(t.coords),!0;if(Z.isTurning())return this._projectionsWithAbsAndWithoutRelAttitudeInARow=[],this._lastProjections=[],J.notify(e),!0;if(t){this._projectionsWithAbsAndWithoutRelAttitudeInARow=[],this._lastProjections.push(t),this._lastProjections.length>this._lastProjectionsWindowSize&&this._lastProjections.shift();let n=t.distanceFromNearestElement>this._hugeJumpDistance;return n&&!Q.isStraight()||n&&this._detectWrongBigJump(t)||!this._areLastProjectionsInTheSameDirection()||this._disableMMCloseToATurnDistance>0&&this._hasTurnInCircle(t.coords,this._disableMMCloseToATurnDistance)?(J.notify(e),!0):(J.notify(t.coords),this.tryOrientationMatching(t),!0)}if(Q.isStraight()){let t=e.clone();t.bearing=Y.lastEvent?.heading||null;let n=this.getProjection(t,!0,!0);if(n)return this._projectionsWithAbsAndWithoutRelAttitudeInARow.push(n),this._projectionsWithAbsAndWithoutRelAttitudeInARow.length<3||(this._lastProjections.push(n),this._lastProjections.length>this._lastProjectionsWindowSize&&this._lastProjections.shift(),!this._areLastProjectionsInTheSameDirection())?(J.notify(e),!0):(J.notify(n.coords),this.tryOrientationMatching(n),!0)}return this._projectionsWithAbsAndWithoutRelAttitudeInARow=[],this._lastProjections=[],J.notify(e),!0}_detectWrongBigJump(e){if(this._itineraryInfoManager&&J.lastEvent){let t=this._itineraryInfoManager.getInfo(J.lastEvent),n=this._itineraryInfoManager.getInfo(e.coords);if(t&&n&&t.traveledDistance>n.traveledDistance&&t.traveledDistance-n.traveledDistance>e.origin.accuracy&&e.distanceFromNearestElement>e.origin.accuracy&&e.origin.distanceTo(J.lastEvent)<e.origin.accuracy+J.lastEvent.accuracy)return!0}return!1}_areLastProjectionsInTheSameDirection(){if(this._lastProjections.length===0)return!1;let e=this._lastProjections[0];return!this._lastProjections.some(t=>!(t.nearestElement instanceof r.Edge)||!(e.nearestElement instanceof r.Edge)||(0,n.diffAngleLines)(t.nearestElement.bearing,e.nearestElement.bearing)>this._lastProjectionsEdgeAngleThreshold)}_nodeHasTurn(t){if(!this._graph)return;let r=this._graph.edges.filter(e=>e.vertex1===t||e.vertex2===t);for(let t=0;t<r.length;t++)for(let i=t+1;i<r.length;i++)if((0,n.diffAngleLines)(r[t].bearing,r[i].bearing)>e.DEFAULT_MM_MAX_ANGLE)return!0;return!1}_hasTurnInCircle(e,n){let r=this._graph;return r?r.vertices.filter(r=>r.coords.distanceTo(e)<=n&&t.Level.intersect(r.coords.level,e.level)).some(e=>this._nodeHasTurn(e)):!1}tryOrientationMatching(e){if(!this._useOrientationMatching||this.state!==`started`||this._countStepsFromLastMatching<this._minStepsBetweenOrientationMatching||Q.numStepsDetectedFromLastTurn<this._minStepsForOrientationMatching)return;let{nearestElement:i,origin:a}=e;if(!(i instanceof r.Edge))return;let o,s=(0,n.diffAngle)(i.bearing,a.bearing),c=(0,n.diffAngle)(i.bearing+Math.PI,a.bearing);o=Math.abs(s)<Math.abs(c)?i.bearing:(i.bearing+Math.PI)%(2*Math.PI);let l=new t.AbsoluteHeading(o,a.time,0);X._forceHeadingForRelative(l),this._countStepsFromLastMatching=0}getProjection(e,t,n){let r={...t&&!this._useStrict&&{maxDistance:this._mapMatchingMaxDistance},...n&&!this._useStrict&&{maxBearingAngle:this._mapMatchingMaxAngleBearing}};return this._graph?.getProjection(e,r)}get maxDistance(){return this._mapMatchingMaxDistance}set maxDistance(e){this._mapMatchingMaxDistance=e}get maxAngleBearing(){return this._mapMatchingMaxAngleBearing}set maxAngleBearing(e){this._mapMatchingMaxAngleBearing=e}get useItineraryStartAsPosition(){return this._useItineraryStartAsPosition}set useItineraryStartAsPosition(e){this._useItineraryStartAsPosition=e}get useOrientationMatching(){return this._useOrientationMatching}set useOrientationMatching(e){this._useOrientationMatching=e}get hugeJumpDistance(){return this._hugeJumpDistance}set hugeJumpDistance(e){this._hugeJumpDistance=e}get disableMMCloseToATurnDistance(){return this._disableMMCloseToATurnDistance}set disableMMCloseToATurnDistance(e){this._disableMMCloseToATurnDistance=e}get minStepsBetweenOrientationMatching(){return this._minStepsBetweenOrientationMatching}set minStepsBetweenOrientationMatching(e){this._minStepsBetweenOrientationMatching=e}get minStepsForOrientationMatching(){return this._minStepsForOrientationMatching}set minStepsForOrientationMatching(e){this._minStepsForOrientationMatching=e}get lastProjectionsWindowSize(){return this._lastProjectionsWindowSize}set lastProjectionsWindowSize(e){this._lastProjectionsWindowSize=e}get lastProjectionsEdgeAngleThreshold(){return this._lastProjectionsEdgeAngleThreshold}set lastProjectionsEdgeAngleThreshold(e){this._lastProjectionsEdgeAngleThreshold=e}get useStrict(){return this._useStrict}set useStrict(e){this._useStrict=e}},Be=class e{static DEFAULT_FREQUENCY=60;static DEFAULT_FLYBY_TIME=1;positionsQueue=[];previousPosition=null;timeoutNotify;callback;frequency;constructor(t,n=e.DEFAULT_FREQUENCY){this.callback=t,this.frequency=n}feed(n,r=e.DEFAULT_FLYBY_TIME){if(!(n instanceof t.UserPosition))throw TypeError(`newPosition is not instance of UserPosition`);if(n.time===null)throw Error(`newPosition does not have time property`);let i;if(this.positionsQueue.length===0?i=this.previousPosition:(i=this.positionsQueue[0],this.positionsQueue=[]),i){let e=n.time,a=i.distanceTo(n),o=i.bearingTo(n),s=1,c=this.frequency*r+1,l=t.Level.clone(n.level);for(;s<c+1;){let t=i.destinationPoint(a*s/c,o);t.time=e+(s-1)/this.frequency,t.level=l,t.bearing=n.bearing,t.accuracy=Math.max(t.accuracy+(n.accuracy-t.accuracy)*s/c,0),this.positionsQueue.push(t),s++}this.timeoutNotify&&clearTimeout(this.timeoutNotify)}else this.positionsQueue.push(n.clone());this.previousPosition=n,this._notifyNext()}_notifyNext=()=>{this.positionsQueue.length&&(this.callback?.(this.positionsQueue.shift()),this.positionsQueue.length===0?delete this.timeoutNotify:this.timeoutNotify=setTimeout(this._notifyNext,1e3/this.frequency))};clear(){clearTimeout(this.timeoutNotify),delete this.timeoutNotify,this.positionsQueue=[]}},Ve=class e{static ROTATION_SPEED_JUMP_THRESHOLD=(0,n.deg2rad)(180);static ROTATION_SPEED_CONVERGENCE=(0,n.deg2rad)(10);static HIGH_JUMP_THRESHOLD=(0,n.deg2rad)(20);static ROTATION_SPEED_HIGH_JUMP_CONVERGENCE=(0,n.deg2rad)(100);static PITCH_UNCERTAINITY_HEADING_THRESHOLD=(0,n.deg2rad)(5);_previousAttitude;_smoothing=null;callback;constructor(e){this.callback=e}feed(r){if(r.time===null)throw Error(`newAttitude does not have time property`);let{_previousAttitude:i}=this;if(this._previousAttitude=r,!i){this.callback(r);return}if(e.isJump(i,r)){let a=this._smoothing===null?i:this._smoothing.interpAttitude(i),o=a.heading,s=r.heading,c=(0,n.diffAngle)(s,o),l=Math.abs(c)<e.HIGH_JUMP_THRESHOLD?e.ROTATION_SPEED_CONVERGENCE:e.ROTATION_SPEED_HIGH_JUMP_CONVERGENCE,u=a.time,d=Math.abs(c)/l,f=c<0?-1:1;this._smoothing={toTime:u+d,interpAttitude:e=>{let r=l*(e.time-u),i=o+r*f,a=n.Quaternion.fromAxisAngle([0,0,1],s-i);return new t.Attitude(n.Quaternion.multiply(a,e.quaternion),e.time,e.accuracy)}}}if(this._smoothing!==null)if(r.time>=this._smoothing.toTime)this._smoothing=null;else{let e=this._smoothing.interpAttitude(r);this.callback(e);return}this.callback(r)}static isJump(t,r){let i=t.heading,a=r.heading,o=(0,n.diffAngle)(a,i),s=r.time-t.time,[c,l,u,d]=r.quaternion;return Math.abs(Math.asin(2*(c*l+u*d))-Math.PI/4)<e.PITCH_UNCERTAINITY_HEADING_THRESHOLD?!1:Math.abs(o)>e.ROTATION_SPEED_JUMP_THRESHOLD*s}},He=new class extends y{getName=()=>`MagnetometerCalibrationProvider`;availability=()=>X.getAvailability();constructor(){super(),X._setCallbackMagCalibration(e=>this.state===`started`&&this.notify(e))}start(){}stop(){}},Ue=class e extends Error{static DEFAULT_MESSAGE=`IP Resolver failed`;constructor(t){super(t||e.DEFAULT_MESSAGE)}},We=new class extends y{getName=()=>`Ip`;availability=()=>Promise.resolve();async start(){let e=await fetch(`https://ipinfo.io/geo?token=24a7ca2f3b489d`);if(!e){this.notifyError(new Ue);return}let n=i.TimeUtils.preciseTime()/1e3,r=(await e.json()).loc.split(`,`),a=new t.UserPosition(parseFloat(r[0]),parseFloat(r[1]),null,null,n,1e5);this.notify(a)}stop(){}},Ge=class e{static MAX_CONSECUTIVE_FAILURES=10;intervalMs;enabled;timeoutId=null;listenerId=null;scanFailureListenerId=null;isBackgroundScanRunning=!1;consecutiveFailures=0;_status;statusCallbacks=new Set;onResult;onError;constructor(e,t,n){this.onResult=t,this.onError=n,this.intervalMs=e.intervalMs??3e4,this.enabled=e.enabled??!1,this._status=this.enabled?`idle`:`disabled`}get status(){return this._status}setEnabled(e){this.enabled=e,e?!this.isBackgroundScanRunning&&!this.timeoutId&&this.setStatus(`idle`):(this.clear(),this.setStatus(`disabled`))}onStatusChange(e){return this.statusCallbacks.add(e),()=>{this.offStatusChange(e)}}offStatusChange(e){this.statusCallbacks.delete(e)}schedule(){this.enabled&&(this.clearTimeoutOnly(),this.timeoutId=setTimeout(()=>{this.timeoutId=null,this.startBackgroundScan()},this.intervalMs),this.setStatus(`scheduled`))}async cancelRunningScan(){this.isBackgroundScanRunning&&(this.listenerId!==null&&(q.removeEventListener(this.listenerId),this.listenerId=null,q.stop()),this.scanFailureListenerId!==null&&(q.removeScanFailureListener(this.scanFailureListenerId),this.scanFailureListenerId=null),this.isBackgroundScanRunning=!1,this.setStatus(this.enabled?`idle`:`disabled`))}clear(){this.clearTimeoutOnly(),this.listenerId!==null&&(q.removeEventListener(this.listenerId),this.listenerId=null),this.scanFailureListenerId!==null&&(q.removeScanFailureListener(this.scanFailureListenerId),this.scanFailureListenerId=null),this.isBackgroundScanRunning=!1,this.setStatus(this.enabled?`idle`:`disabled`)}runNow(){this.enabled&&(this.clearTimeoutOnly(),this.startBackgroundScan())}clearTimeoutOnly(){this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null),this.enabled&&!this.isBackgroundScanRunning&&this.setStatus(`idle`)}async startBackgroundScan(){if(!this.enabled||this.isBackgroundScanRunning||this.listenerId!==null)return;let t=await q.getAvailability();if(t instanceof Error){this.onError(t),this.setStatus(`idle`);return}this.isBackgroundScanRunning=!0,this.setStatus(`scanning`),this.scanFailureListenerId=q.addScanFailureListener(t=>{!this.isBackgroundScanRunning||this.scanFailureListenerId===null||t.listenerId!==this.scanFailureListenerId||(this.consecutiveFailures+=1,this.consecutiveFailures>=e.MAX_CONSECUTIVE_FAILURES&&(this.consecutiveFailures=0,q.resetCurrentAttempt(),this.cleanupListener(),this.schedule()))}),this.listenerId=q.addEventListener(e=>{this.consecutiveFailures=0,this.cleanupListener(),this.onResult(e),this.schedule()},e=>{this.cleanupListener(),this.onError(e),this.schedule()})}cleanupListener(){this.listenerId!==null&&(q.removeEventListener(this.listenerId),this.listenerId=null),this.scanFailureListenerId!==null&&(q.removeScanFailureListener(this.scanFailureListenerId),this.scanFailureListenerId=null),q.stop(),this.isBackgroundScanRunning=!1,this.enabled?this.setStatus(`idle`):this.setStatus(`disabled`)}setStatus(e){this._status!==e&&(this._status=e,this.statusCallbacks.forEach(t=>{try{t(e)}catch(e){console.error(`[VpsBackgroundScanner] Error in status listener`,e)}}))}},Ke=new class extends y{providerId;getName=()=>`Barcode`;availability=()=>P.getAvailability();start(){P.enableBarcodeScanner(),this.providerId=P.addEventListener(e=>e.barcode&&this.notify(e.barcode),this.notifyError)}stop(){P.disableBarcodeScanner(),P.removeEventListener(this.providerId)}},qe=new class extends y{providerId;getName=()=>`CameraNative`;availability=()=>Promise.resolve();start(){P.state!==`stopped`&&this.notify(`started`),this.providerId=P.addMonitoringListener(()=>this.notify(`started`),()=>this.notify(`stopped`))}stop(){P.removeMonitoringListener(this.providerId)}},Je=new class extends y{providerId;getName=()=>`CameraProjectionMatrix`;availability=()=>P.getAvailability();start(){this.providerId=P.addEventListener(e=>e.cameraProjection&&this.notify(e.cameraProjection),this.notifyError)}stop(){P.removeEventListener(this.providerId)}};e.AbsoluteAttitude=c,e.AbsoluteAttitudeFromBrowserProvider=Y,e.AbsoluteAttitudeProvider=X,e.AbsolutePosition=o,e.AbsolutePositionProvider=J,e.AccelerometerProvider=I,e.ArCoreProvider=P,e.AttitudeSmoother=Ve,e.BarcodeProvider=Ke,e.CameraNativeProvider=qe,e.CameraProjectionMatrixProvider=Je,e.Constants=M,e.GeoRelativePositionFromArCoreProvider=be,e.GeoRelativePositionProvider=H,e.GnssWifiProvider=N,e.GyroscopeProvider=L,e.HighRotationsProvider=z,e.ImageRelocalization=Le,e.ImuProvider=F,e.InclinationFromAccProvider=Ne,e.InclinationFromRelativeAttitudeProvider=U,e.InclinationProvider=W,e.IpProvider=We,e.MagnetometerCalibrationProvider=He,e.MapMatchingHandler=$,e.PdrProvider=je,e.PoleStarProvider=K,e.PositionSmoother=Be,e.ProvidersLoggerOld=_,e.ProvidersOptions=l,e.RelativeAttitude=s,e.RelativeAttitudeFromBrowserProvider=R,e.RelativeAttitudeFromEkfProvider=Ee,e.RelativeAttitudeFromInertialProvider=B,e.RelativeAttitudeProvider=G,e.RelativeRotationCalc=Re,e.StepDetectionMinMaxPeaks2=ke,e.StepDetectionMinMaxPeaks3=Ae,e.StepProvider=V,e.StraightLineProvider=Q,e.TurnProvider=Z,e.VpsBackgroundScanner=Ge,e.VpsMetadata=Pe,e.VpsProvider=q,e.VpsRequest=Fe,e.VpsResponse=Ie});
3
+ `+r[0].trim(),r=r.splice(1),i--;return n}catch{return``}}static _log(t,n,r){let i=`color: auto;`,a=`color: #6A6A6A;`,o=typeof window<`u`,s,c=null,l=null,u=null,d=null,f=``,h=!1;if(c=t,d=Error(n),o&&(l=e._getColorByType(t)),u=e._getOriginByType(d,r),c===`deprecated`&&(c=`warn`,h=`deprecated`),o&&(u=e._COLOR_TOKEN+u),s=(o?e._COLOR_TOKEN:``)+` `+d.message,f=o?e._COLOR_TOKEN:``,f+=e._TYPE_PREFIX,f+=h||t,f+=e._TYPE_SUFFIX,typeof window<`u`&&m(window)){let e=performance&&performance.now?performance.now():new Date().getTime();f+=`[`+Math.round(e-window.wemap.startTime)+`ms]`}return s=f+s,e.SHOW_ORIGIN&&(s+=u),e.HISTORY.push(s),!this._canUseLog(t)||arguments.length<2||!e.ENABLED?!1:(o?console&&t!==`ok`&&t!==`flux`&&t!==`deprecated`&&console[t]&&p.indexOf(t)<=p.indexOf(`info`)?console[t](s,l,i,a):console.log(s,l,i,a):console.log(s),!0)}static external(e){return console.log(`LIVEMAP :: `+e)}static flux(t){return e._log(`flux`,t,0)}static ok(t){return e._log(`ok`,t,1)}static error(t,n=-1){return e._log(`error`,t,n)}static warn(t,n=2){return e._log(`warn`,t,n)}static deprecated(t,n=2){return e._log(`deprecated`,t,n)}static debug(t,n=-1){return e._log(`debug`,t,n)}static info(t,n=0){return e._log(`info`,t,n)}static log(t,n=1){return e._log(`log`,t,n)}};f(h,`LOG_LEVEL`,`debug`),f(h,`SHOW_ORIGIN`,!0),f(h,`ENABLED`,!0),f(h,`HISTORY`,[]),f(h,`_COLOR_TOKEN`,`%c`),f(h,`_TYPE_PREFIX`,`<<<< `),f(h,`_TYPE_SUFFIX`,` >>>>`);for(var g=h,_=new class{_enabled=!1;currentId=0;objectsIdMap=new WeakMap;pushEvents={};pushEventsRef={};interval;initDate;get enabled(){return this._enabled}set enabled(e){this._enabled=e}initializeInterval(){this.interval||=window.setInterval(()=>{for(let[e,t]of Object.entries(this.pushEvents))g.debug(`Received `+t+` notifications from `+this.pushEventsRef[Number(e)].getName()+` last second`);this.pushEvents={},this.pushEventsRef={}},1e3)}getObjectId(e){return this.objectsIdMap.has(e)||this.objectsIdMap.set(e,++this.currentId),this.objectsIdMap.get(e)}addEvent(e,t){if(!this.enabled)return;this.initDate||=Date.now(),this.initializeInterval();let n=this.getObjectId(e),r=e.getName();g.debug(r+`[`+n+`].`+t)}incrementNotifications(e){if(!this.enabled)return;let t=this.getObjectId(e),n=this.pushEvents[t];n||(n=0,this.pushEventsRef[t]=e),this.pushEvents[t]=n+1}},v=class e extends Error{static DEFAULT_MESSAGE=`Contains ignored provider`;constructor(t){super(t||e.DEFAULT_MESSAGE)}},y=class e{static _callbackUniqueId=0;static _uniqueId=1;id;state=`stopped`;_lastEvent=null;_eventsCallbacks=[];_monitoringCallbacks=[];constructor(){this.id=e._uniqueId++,_.addEvent(this,`constructor`)}getAvailability(){return l.ignoreProviders.includes(this.getName())?Promise.resolve(new v):this.availability()}get hasNativeInterface(){return!!this.nativeInterface}get nativeInterface(){return typeof window<`u`&&window.__nativeProviders||null}get nativeJsInterface(){return typeof window>`u`?null:(window.__nativeJsProviders||(window.__nativeJsProviders={}),window.__nativeJsProviders)}get useCameraNatively(){return!1}addEventListener(t=null,n=null,r=!0){let i=++e._callbackUniqueId;if(this._eventsCallbacks.push({id:i,onEvent:t||(()=>{}),onError:n||(()=>{}),optional:!r}),!r||this.state!==`stopped`)return i;this.state=`starting`;let a=Promise.resolve();return l.checkAvailabilityOnStart&&(a=this.getAvailability()),(async()=>{let e=await a;if(e){this.state=`stopped`,this.notifyError(e);return}_.addEvent(this,`start`),this.start(),this.state=`started`,this._monitoringCallbacks.forEach(e=>e.onStarted?.())})(),i}removeEventListener(e){let t=this._eventsCallbacks.find(t=>t.id===e);t&&(this._eventsCallbacks=this._eventsCallbacks.filter(e=>e!==t),!t.optional&&(this._eventsCallbacks.find(e=>!e.optional)||this.state!==`stopped`&&(_.addEvent(this,`stop`),this.stop(),this.state=`stopped`,this._monitoringCallbacks.forEach(e=>e.onStopped?.()))))}addMonitoringListener(t,n){let r=e._callbackUniqueId++;return this._monitoringCallbacks.push({id:r,onStarted:t||null,onStopped:n||null}),r}removeMonitoringListener(e){this._monitoringCallbacks=this._monitoringCallbacks.filter(t=>t.id!==e)}notify=e=>{let t=this._adaptBeforeNotify(e);_.incrementNotifications(this),this._eventsCallbacks.forEach(e=>e.onEvent?.(t)),this._lastEvent=t};_adaptBeforeNotify(e){return e}notifyError=e=>{this._eventsCallbacks.forEach(({id:t,onError:n})=>{l.stopOnError&&this.removeEventListener(t),n?.(e)})};get lastEvent(){return this._lastEvent}},b=class{static async every(e){for(let t of e){let e=await t;if(e)return e}return null}static async some(e){let t;for(let n of e){let e=await n;if(e)t||=e;else return null}return t||null}},ee=[[0,0,0,0,0,0,0,0,0,0,0,0,0],[-29404.5,-1450.7,0,0,0,0,0,0,0,0,0,0,0],[-2500,2982,1676.8,0,0,0,0,0,0,0,0,0,0],[1363.9,-2381,1236.2,525.7,0,0,0,0,0,0,0,0,0],[903.1,809.4,86.2,-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[2.8,-6.2,3.4,-12.2,0,0,0,0,0,0,0,0,0],[-1.1,-1.6,-6,5.4,-5.5,0,0,0,0,0,0,0,0],[-.3,.6,-.7,.1,1.2,1,0,0,0,0,0,0,0],[-.6,-.4,.5,1.4,-1.4,0,.8,0,0,0,0,0,0],[-.1,-.3,-.1,.7,.2,-.5,-.8,1,0,0,0,0,0],[-.1,.1,-.1,.5,-.1,.4,.5,0,.4,0,0,0,0],[-.1,-.2,0,.4,-.3,0,.3,0,0,-.4,0,0,0],[0,0,0,.2,-.1,-.2,0,-.1,-.2,-.1,0,0,0],[0,-.1,0,0,0,-.1,0,0,-.1,-.1,-.1,-.1,0],[0,0,0,0,0,0,0,0,0,0,0,0,-.1]],re=[[0,0,0,0,0,0,0,0,0,0,0,0,0],[0,-25.1,0,0,0,0,0,0,0,0,0,0,0],[0,-30.2,-23.9,0,0,0,0,0,0,0,0,0,0],[0,5.7,-1,1.1,0,0,0,0,0,0,0,0,0],[0,.2,6.9,3.7,-5.6,0,0,0,0,0,0,0,0],[0,.1,2.5,-.9,3,.5,0,0,0,0,0,0,0],[0,.1,-1.8,-1.4,.9,.1,1,0,0,0,0,0,0],[0,.5,.6,-.7,-.2,-1.2,.2,.3,0,0,0,0,0],[0,-.3,.7,-.2,.5,-.3,-.5,.4,.1,0,0,0,0],[0,-.3,.2,-.4,.4,.1,0,-.2,.5,.2,0,0,0],[0,0,.1,-.3,.1,-.2,.1,0,-.1,.2,0,0,0],[0,0,.1,0,.2,0,0,.1,0,-.1,0,0,0],[0,0,0,-.1,.1,0,0,0,.1,0,0,0,-.1]],x={a:6378.137,b:6356.7523142,r0:6371.2},S=function(e,t){return Array(e).fill(``).map(function(e){return Array(t).fill(0)})},ie=function(){return(new Date(Date.now()).valueOf()/864e5+2440587.5-2458850)/365.25},ae=function(e,t){return Number(Math.round(Number(e+`e+`+t))+`e-`+t)},oe=function(e){return e>90?e-180:e<-90?e+180:e},C=function(e){return e*.017453292519943295},se=function(e){return e*57.29577951308232},w=S(13,13),T=S(13,13),ce=S(13,13),le=S(13,13),ue=Array(13).fill(0),de=Array(13).fill(0),fe=Array(13).fill(0),E=S(13,13).map(function(e){return e.map(function(e){return[0,0]})}),D=2;D<=12;D++)fe[D]=Math.sqrt((2*D-1)/(2*D));for(var O=0;O<=12;O++)for(var k=O*O,D=Math.max(O+1,2);D<=12;D++)E[O][D][0]=Math.sqrt((D-1)*(D-1)-k),E[O][D][1]=1/Math.sqrt(D*D-k);var pe=function(e,t,n){n===void 0&&(n=0);var r=Math.cos(C(e)),i=Math.sin(C(e)),a=Math.sqrt(x.a**2*r**2+x.b**2*i**2),o=Math.atan2(r*(n*a+x.a**2),i*(n*a+x.b**2)),s=Math.sqrt(n**2+2*n*a+(x.a**4-(x.a**4-x.b**4)*i**2)/(x.a**2-(x.a**2-x.b**2)*i**2)),c=Math.cos(o),l=Math.sin(o),u=1/(l+(l===0?1e-8:0));w[0][0]=1,w[1][1]=l,w[1][0]=c,T[1][0]=-l,T[1][1]=c;for(var d=2;d<=12;d++)w[d][d]=w[d-1][d-1]*l*fe[d],T[d][d]=(T[d-1][d-1]*l+w[d-1][d-1]*c)*fe[d];for(var f=0;f<=12;f++)for(var d=Math.max(f+1,2);d<=12;d++)w[d][f]=(w[d-1][f]*c*(2*d-1)-w[d-2][f]*E[f][d][0])*E[f][d][1],T[d][f]=((T[d-1][f]*c-w[d-1][f]*l)*(2*d-1)-T[d-2][f]*E[f][d][0])*E[f][d][1];for(var p=ie(),d=1;d<=12;d++)for(var f=0;f<=12;f++)ce[d][f]=ee[d][f]+p*ne[d][f],le[d][f]=te[d][f]+p*re[d][f];for(var f=0;f<=12;f++)ue[f]=Math.sin(f*C(t)),de[f]=Math.cos(f*C(t));for(var m=0,h=0,g=0,_=x.r0/s,v=_**2,d=1;d<=12;d++){for(var y=0,b=0,S=0,f=0;f<=d;f++){var D=ce[d][f]*de[f]+le[d][f]*ue[f];y+=D*w[d][f],b+=D*T[d][f],S+=f*(ce[d][f]*ue[f]-le[d][f]*de[f])*w[d][f]}v*=_,m+=(d+1)*y*v,h-=b*v,g+=S*v*u}var O=o-(Math.PI/2-C(e)),k=Math.sin(O),pe=Math.cos(O),A=-h*pe-m*k,j=g,M=h*k-m*pe,me=A!==0||j!==0?ae(se(Math.atan2(j,A)),2):0,he=j!==0||A!==0&&M!==0?oe(se(Math.atan2(M*Math.sin(Math.atan2(j,A)),j))):0;return{declination:ae(me,2),inclination:ae(he,2),intensity:Math.round(Math.sqrt(A**2+j**2+M**2)),northIntensity:Math.round(A),eastIntensity:Math.round(j),verticalIntensity:Math.round(M),horizontalIntensity:Math.round(Math.sqrt(A**2+j**2))}},A=class e extends Error{static DEFAULT_MESSAGE=`It seems that you ask for IMU events on a desktop browser`;constructor(t){super(t||e.DEFAULT_MESSAGE)}},j=class e extends Error{static DEFAULT_MESSAGE=`Impossible to retrieve events, a sensor is missing`;constructor(t){super(t||e.DEFAULT_MESSAGE)}from(e){return this.message+=` from `+e,this}},M=class extends j{constructor(e){super(e)}},me=class e extends Error{static DEFAULT_MESSAGE=`Geolocation api is missing`;constructor(t){super(t||e.DEFAULT_MESSAGE)}},he=class e extends Error{static DEFAULT_MESSAGE=`Geolocation permission denied`;constructor(t){super(t||e.DEFAULT_MESSAGE)}},ge=class e extends Error{static DEFAULT_MESSAGE=`Geolocation position unavailable`;constructor(t){super(t||e.DEFAULT_MESSAGE)}},_e={DEFAULT_ALTITUDE:1.6},N=new class e extends y{static DEFAULT_DISCARD_POSITIONS_ABOVE=50;discardPositionsAbove=e.DEFAULT_DISCARD_POSITIONS_ABOVE;enableHighAccuracy=!0;geoLocationId;getName=()=>`GnssWifi`;get positionOptions(){return{enableHighAccuracy:this.enableHighAccuracy,timeout:1/0,maximumAge:0}}availability(){return typeof navigator==`object`&&navigator.geolocation?Promise.resolve():Promise.resolve(new me)}start(){navigator.geolocation.getCurrentPosition(this.onNewPosition,this.onPositionError,this.positionOptions),setTimeout(()=>{this.geoLocationId=navigator.geolocation.watchPosition(this.onNewPosition,this.onPositionError,this.positionOptions)},150)}stop(){this.geoLocationId!==void 0&&navigator.geolocation.clearWatch(this.geoLocationId)}onNewPosition=e=>{let{coords:r}=e;if(!r)return;let a;r.heading&&(a=(0,n.deg2rad)(r.heading));let o=i.TimeUtils.unixTimestampToPreciseTime(e.timestamp)/1e3,s=new t.UserPosition(r.latitude,r.longitude,_e.DEFAULT_ALTITUDE,null,o,r.accuracy,a);this.enableHighAccuracy&&typeof this.discardPositionsAbove==`number`&&r.accuracy>this.discardPositionsAbove||this.notify(s)};onPositionError=e=>{g.warn(`[Providers] watchPosition error: [${e.code}] ${e.message}`);let t;switch(e.code){case 1:t=new he(e.message);break;case 2:t=new ge(e.message);break;default:t=Error(e.message)}this.notifyError(t)}},ve=class e extends Error{static DEFAULT_MESSAGE=`ARCore is missing`;constructor(t){super(t||e.DEFAULT_MESSAGE)}},ye=class e extends Error{static DEFAULT_MESSAGE=`Native interface is missing. You are maybe trying to execute a code which is not available in a web browser`;constructor(t){super(t||e.DEFAULT_MESSAGE)}},P=new class e extends y{static Payload={Pose:{ref:1,size:7},Barcode:{ref:2**1,size:1},ProjMat:{ref:2**2,size:16},ImageRef:{ref:2**3,size:1}};static RELATIVE_ATTITUDE_DRIFT=(0,n.deg2rad)(3)/60;_nativeProvider;previousPosition=[0,0,0];getName=()=>`ArCore`;availability(){try{if(!this.nativeProvider.checkAvailability())return Promise.resolve(new ve)}catch(e){return Promise.resolve(e)}return Promise.resolve()}start(){this.nativeProvider?.start(),this.pullDataLoop()}stop(){this.nativeProvider?.stop()}pullDataLoop=()=>{if(this.state===`stopped`)return;let e=JSON.parse(this.nativeProvider.getInfo());e.length>1&&this.parsePayload(e),requestAnimationFrame(this.pullDataLoop)};parsePayload(n){let r=n[0],a=1,o,c,l,u,d=i.TimeUtils.preciseTime()/1e3;if(r&e.Payload.Pose.ref){o=new s(n.slice(a,a+4),d,e.RELATIVE_ATTITUDE_DRIFT);let r=[n[a+4],n[a+5],n[a+6]];c=new t.RelativePosition(r[0]-this.previousPosition[0],r[1]-this.previousPosition[1],r[2]-this.previousPosition[2],d,1e-4),this.previousPosition=r,a+=e.Payload.Pose.size}r&e.Payload.Barcode.ref&&(u=n[a],a+=e.Payload.Barcode.size),r&e.Payload.ProjMat.ref&&(l=n.slice(a,a+e.Payload.ProjMat.size),a+=e.Payload.ProjMat.size),this.notify({relativePosition:c,relativeAttitude:o,...u&&{barcode:u},...l&&{cameraProjection:l}})}get nativeProvider(){if(!this._nativeProvider){if(!this.nativeInterface)throw new ye;if(this._nativeProvider=this.nativeInterface.getArCoreProvider(),!this._nativeProvider)throw new ve}return this._nativeProvider}enableBarcodeScanner(){try{this.nativeProvider.enableBarcodeScanner()}catch(e){this.notifyError(e)}}disableBarcodeScanner(){try{this.nativeProvider.disableBarcodeScanner()}catch(e){this.notifyError(e)}}get useCameraNatively(){return!0}},be=new class extends y{absoluteAttitudeProviderId;arCoreProviderId;absoluteAttitudeEvent;getName=()=>`GeoRelativePositionFromArCore`;availability(){return b.every([P.getAvailability(),X.getAvailability()])}start(){this.arCoreProviderId=P.addEventListener(this.onArCoreEvents,this.notifyError),this.absoluteAttitudeProviderId=X.addEventListener(e=>this.absoluteAttitudeEvent=e,this.notifyError)}stop(){P.removeEventListener(this.arCoreProviderId),X.removeEventListener(this.absoluteAttitudeProviderId)}onArCoreEvents=e=>{let t=e.relativeAttitude,n=e.relativePosition;t&&n&&this.absoluteAttitudeEvent&&this.compute(n,t,this.absoluteAttitudeEvent)};compute(e,n,r){let i=r.heading-n.heading,a=Math.cos(i)*e.x-Math.sin(i)*e.z,o=-Math.sin(i)*e.x-Math.cos(i)*e.z,s=e.y,c=new t.GeoRelativePosition(a,o,s,e.time,0,r.heading);this.notify(c)}},xe={acc:.5,gyr:.3},Se={acc:.5,gyr:.3,yc:2},Ce=class{P;accRef;cRef;noises;quaternion;constructor(e=[0,0,1],t=[-1,0,0]){this.accRef=e,this.cRef=t,this.P=n.Matrix4.fromDiagVector([,,,,].fill(.1**2)),this.quaternion=null,this.noises={},this.setRelativeNoises(xe),this.setAbsoluteNoises(Se)}setRelativeNoises(e){this.noises.relative={acc:n.Matrix3.diag([,,,].fill(e.acc**2)),gyr:n.Matrix3.diag([,,,].fill(e.gyr**2))}}setAbsoluteNoises(e){this.noises.absolute={acc:n.Matrix3.diag([,,,].fill(e.acc**2)),gyr:n.Matrix3.diag([,,,].fill(e.gyr**2)),yc:n.Matrix3.diag([,,,].fill(e.yc**2))}}tryInitialize(e,t){let r=n.Vector3.normalize(e);if(t){let e=n.Vector3.normalize(t),i=n.Vector3.normalize(n.Vector3.cross(e,r)),a=n.Vector3.cross(r,i),o=[[i[0],a[0],r[0]],[i[1],a[1],r[1]],[i[2],a[2],r[2]]];this.quaternion=n.Quaternion.fromMatrix3Matlab(o)}else{let e=n.Vector3.dot(r,this.accRef)+1,t=n.Vector3.cross(r,this.accRef),i=[e,t[0],t[1],t[2]];i=n.Quaternion.normalize(i),this.quaternion=i}return this.quaternion}update(e,t,r,i){if(!this.quaternion)return this.tryInitialize(t,i);let a=this.quaternion,o=a,s=n.Vector3.multiplyScalar(r,.5*e),c=this.computeC([1,s[0],s[1],s[2]]),l=n.Matrix4.multiplyVector(c,a),u=n.Matrix3.diag([o[0],o[0],o[0]]),d=n.Matrix3.skew([o[1],o[2],o[3]]),f=[-1*o[1],-1*o[2],-1*o[3]],p=n.Matrix.concatRow([f],n.Matrix3.sum(d,u)),m=n.Matrix4.multiplyScalar(n.Matrix.multiply(n.Matrix.multiply(p,this.noises[i?`absolute`:`relative`].gyr),n.Matrix.transpose(p)),(e/2)**2),h=n.Matrix4.sum(n.Matrix4.multiply(n.Matrix4.multiply(c,this.P),n.Matrix4.transpose(c)),m),g=n.Vector3.normalize(t),_,v,y;if(i){let e=n.Vector3.normalize(i),t=n.Vector3.cross(g,e),r=n.Vector3.normalize(t),a=n.Vector3.subtract(r,n.Quaternion.rotateMatlab(l,this.cRef)),o=n.Vector3.subtract(g,n.Quaternion.rotateMatlab(l,this.accRef));_=n.Vector.concat(a,o);let s=this.jacobianES(l,this.cRef),c=this.jacobianES(l,this.accRef);y=n.Matrix.concatRow(s,c);let u=n.Matrix.concatLine(this.noises.absolute.yc,n.Matrix3.zeros),d=n.Matrix.concatLine(n.Matrix3.zeros,this.noises.absolute.acc),f=n.Matrix.concatRow(u,d);v=n.Matrix.multiply(n.Matrix.multiply(h,n.Matrix.transpose(y)),n.Matrix.inverse(n.Matrix.sum(n.Matrix.multiply(n.Matrix.multiply(y,h),n.Matrix.transpose(y)),f)))}else{_=n.Vector3.subtract(g,n.Quaternion.rotateMatlab(l,this.accRef)),y=this.jacobianES(l,this.accRef);let e=this.noises.relative.acc;v=n.Matrix.multiply(n.Matrix.multiply(h,n.Matrix.transpose(y)),n.Matrix3.inverse(n.Matrix3.sum(n.Matrix.multiply(n.Matrix.multiply(y,h),n.Matrix.transpose(y)),e)))}a=n.Quaternion.sum(l,n.Matrix.multiplyVector(v,_));let b=n.Matrix4.multiply(n.Matrix4.subtract(n.Matrix4.identity,n.Matrix.multiply(v,y)),h);return a=n.Quaternion.normalize(a),this.quaternion=a,this.P=b,a}computeC(e){return[[e[0],-e[1],-e[2],-e[3]],[e[1],e[0],e[3],-e[2]],[e[2],-e[3],e[0],e[1]],[e[3],e[2],-e[1],e[0]]]}jacobianES(e,t){let[n,r,i,a]=e,[o,s,c]=t;return[[2*a*s-2*i*c,2*i*s+2*a*c,2*r*s-2*n*c-4*i*o,2*n*s+2*r*c-4*a*o],[2*r*c-2*a*o,2*n*c-4*r*s+2*i*o,2*r*o+2*a*c,2*i*c-2*n*o-4*a*s],[2*i*o-2*r*s,2*a*o-4*r*c-2*n*s,2*n*o-4*i*c+2*a*s,2*r*o+2*i*s]]}},F=new class extends y{getName=()=>`IMU`;availability(){return i.BrowserUtils.isMobile?Promise.resolve():Promise.resolve(new A)}start(){let e=()=>window.addEventListener(`devicemotion`,this.parseDeviceMotionEvent,!0),t=DeviceMotionEvent.requestPermission||void 0;t?t().then(t=>{if(t!==`granted`)throw Error(`Permission not granted`);e()}).catch(this.notifyError):e()}stop(){window.removeEventListener(`devicemotion`,this.parseDeviceMotionEvent,!0)}parseDeviceMotionEvent=e=>{let t=e.timeStamp/1e3,r;if(e.accelerationIncludingGravity){let{x:t,y:n,z:a}=e.accelerationIncludingGravity;typeof t==`number`&&typeof n==`number`&&typeof a==`number`&&(r=[t,n,a],(i.BrowserUtils.getName()===i.Browser.SAFARI||i.BrowserUtils.getName()===i.Browser.IOS_WEBVIEW)&&(r[0]*=-1,r[1]*=-1,r[2]*=-1))}let a;if(e.rotationRate){let{alpha:t,beta:r,gamma:i}=e.rotationRate;typeof t==`number`&&typeof r==`number`&&typeof i==`number`&&(a=[(0,n.deg2rad)(t),(0,n.deg2rad)(r),(0,n.deg2rad)(i)])}(r||a)&&this.notify({...r&&{acceleration:{timestamp:t,values:r}},...a&&{angularRate:{timestamp:t,values:a}}})}},we=class e extends j{static DEFAULT_MESSAGE=`Impossible to retrieve Acceleration data`;constructor(t){super(t||e.DEFAULT_MESSAGE)}},I=new class extends y{imuProviderId;getName=()=>`Accelerometer`;availability=()=>F.getAvailability();start(){this.imuProviderId=F.addEventListener(e=>{e.acceleration?this.notify(e.acceleration):this.notifyError(new we().from(`devicemotion`))},this.notifyError)}stop(){F.removeEventListener(this.imuProviderId)}},Te=class extends j{static DEFAULT_MESSAGE=`Impossible to retrieve Angular Rate data`;constructor(e){super(e||j.DEFAULT_MESSAGE)}},L=new class extends y{imuProviderId;getName=()=>`Gyroscope`;availability=()=>F.getAvailability();start(){this.imuProviderId=F.addEventListener(e=>{e.angularRate?this.notify(e.angularRate):this.notifyError(new Te().from(`devicemotion`))},this.notifyError)}stop(){F.removeEventListener(this.imuProviderId)}},Ee=new class e extends y{static DEFAULT_DRIFT=(0,n.deg2rad)(5)/60;accelerometerProviderId;ekfAttitude=new Ce;gyroscopeEvent;gyroscopeProviderId;lastTimestamp=0;getName=()=>`RelativeAttitudeFromEkf`;availability(){return b.every([I.getAvailability(),L.getAvailability()])}start(){this.accelerometerProviderId=I.addEventListener(e=>this.onAccelerometerEvent(e),e=>this.notifyError(e)),this.gyroscopeProviderId=L.addEventListener(e=>this.gyroscopeEvent=e,e=>this.notifyError(e))}stop(){I.removeEventListener(this.accelerometerProviderId),L.removeEventListener(this.gyroscopeProviderId)}onAccelerometerEvent=t=>{if(!this.gyroscopeEvent)return;let{values:n,timestamp:r}=t;if(this.lastTimestamp===0){this.lastTimestamp=r;return}let i=r-this.lastTimestamp;this.lastTimestamp=r;let a=this.ekfAttitude.update(i,n,this.gyroscopeEvent.values);if(a){let t=new s(a,r,e.DEFAULT_DRIFT);this.notify(t)}}},R=new class e extends y{static DEFAULT_DRIFT=(0,n.deg2rad)(5)/60;getName=()=>`RelativeAttitudeFromBrowser`;availability(){return i.BrowserUtils.isMobile?Promise.resolve():Promise.resolve(new A)}start(){let e=()=>window.addEventListener(`deviceorientation`,this.onDeviceOrientationEvent,!0),t=DeviceOrientationEvent.requestPermission||void 0;t?t().then(t=>{if(t!==`granted`)throw Error(`Permission not granted`);e()}).catch(e=>this.notifyError(e)):e()}stop(){window.removeEventListener(`deviceorientation`,this.onDeviceOrientationEvent,!0)}onDeviceOrientationEvent=t=>{if(typeof t.alpha!=`number`||typeof t.beta!=`number`||typeof t.gamma!=`number`){this.notifyError(new j().from(`deviceorientation`));return}let r=new s(n.Rotations.eulerToQuaternionZXYDegrees([t.alpha,t.beta,t.gamma]),t.timeStamp/1e3,e.DEFAULT_DRIFT);this.notify(r)}},z=new class e extends y{static THRESHOLD=10;static DELAY_CONSIDERATION=3;gyroscopeProviderId;getName=()=>`HighRotationsProvider`;availability=()=>L.getAvailability();start(){this.gyroscopeProviderId=L.addEventListener(this._parseGyroscopeEvent,this.notifyError)}stop(){L.removeEventListener(this.gyroscopeProviderId)}isInProgress(){return!this.lastEvent||!L.lastEvent?!1:L.lastEvent.timestamp-this.lastEvent.timestamp<e.DELAY_CONSIDERATION}_parseGyroscopeEvent=t=>{let{values:r,timestamp:i}=t;n.Vector3.norm(r)>e.THRESHOLD&&this.notify({timestamp:i})}},B=new class e extends y{static DEFAULT_DRIFT=(0,n.deg2rad)(5)/60;_highRotationsProviderId;listenerId;provider;getName=()=>`RelativeAttitudeFromInertial`;availability(){return b.some([Ee.getAvailability(),R.getAvailability()])}start(){Ee.getAvailability().then(e=>{this.provider=e?R:Ee,this.listenerId=this.provider.addEventListener(e=>this._parseEvent(e),this.notifyError),this._highRotationsProviderId=z.addEventListener(null,this.notifyError)})}_parseEvent(t){let n=t.clone();if(z.isInProgress()){let t=(n.accuracy||0)+e.DEFAULT_DRIFT*100;t=Math.min(t,Math.PI),n.accuracy=t}this.notify(n)}stop(){this.provider&&(this.provider.removeEventListener(this.listenerId),delete this.provider),z.removeEventListener(this._highRotationsProviderId)}},De=class e{static MIN_TIME_BETWEEN_STEPS=.4;static MAX_FRENQUENCY=4;static MIN_FRENQUENCY=1;static VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD=1;frequency=0;lastVerticalAcc=0;maxAcceleration=0;lastStepTimestamp=-e.MIN_TIME_BETWEEN_STEPS;compute(t,n){let r=!1,i=n[2],a=t-this.lastStepTimestamp;if(i>this.lastVerticalAcc)i>this.maxAcceleration&&(this.maxAcceleration=i);else if(this.maxAcceleration>e.VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD&&a>e.MIN_TIME_BETWEEN_STEPS){this.maxAcceleration=0;let n=t-this.lastStepTimestamp;this.frequency=Math.min(Math.max(1/n,e.MIN_FRENQUENCY),e.MAX_FRENQUENCY),r=!0,this.lastStepTimestamp=t}else this.maxAcceleration=0;return this.lastVerticalAcc=i,r}get lastStepSize(){return this.frequency?.45+.2*this.frequency:0}get speed(){return this.lastStepTimestamp?this.lastStepSize*this.frequency:0}},Oe=class e{static WINDOW_TIME=.3;static MIN_TIME_BETWEEN_STEPS=.4;static MAX_FRENQUENCY=4;static MIN_FRENQUENCY=1;static VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD=1.5;static VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD=-1;frequency=0;lastStepTimestamp=-e.MIN_TIME_BETWEEN_STEPS;slidingWindow=[];compute(t,n){if(this.lastStepTimestamp&&this.lastStepTimestamp+e.MIN_TIME_BETWEEN_STEPS>t)return!1;let r=-(2**53-1),i=2**53-1,a=e.WINDOW_TIME;if(this.slidingWindow.forEach((e,n,o)=>{e.timestamp<t-a?o.splice(n,1):(r=Math.max(e.verticalAcc,r),i=Math.min(e.verticalAcc,i))}),this.slidingWindow.push({timestamp:t,verticalAcc:n[2]}),r>e.VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD&&i<e.VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD){let n=this.lastStepTimestamp?t-this.lastStepTimestamp:1;return this.frequency=Math.min(Math.max(1/n,e.MIN_FRENQUENCY),e.MAX_FRENQUENCY),this.lastStepTimestamp=t,!0}return!1}get lastStepSize(){return this.frequency?.45+.2*this.frequency:0}get speed(){return this.lastStepTimestamp?this.lastStepSize*this.frequency:0}},ke=class e{static WINDOW_TIME=.3;static MIN_TIME_BETWEEN_STEPS=.4;static MAX_FRENQUENCY=4;static MIN_FRENQUENCY=1;static VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD=.75;static VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD=-.3;frequency=0;influence=.2;slidingWindow=[];lastStepTimestamp=-e.MIN_TIME_BETWEEN_STEPS;previousVerticalAcc=0;compute(t,n,r){let i=this.influence*(n[2]*2)+(1-this.influence)*this.previousVerticalAcc;if(this.previousVerticalAcc=i,Math.sqrt(r[0]**2+r[1]**2+r[2]**2)>.75||this.lastStepTimestamp&&this.lastStepTimestamp+e.MIN_TIME_BETWEEN_STEPS>t)return!1;let a=-(2**53-1),o=2**53-1;if(this.slidingWindow.forEach((n,r,i)=>{n.timestamp<t-e.WINDOW_TIME?i.splice(r,1):(a=Math.max(n.verticalAcc,a),o=Math.min(n.verticalAcc,o))}),this.slidingWindow.push({timestamp:t,verticalAcc:i}),a>e.VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD&&o<e.VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD){let n=this.lastStepTimestamp?t-this.lastStepTimestamp:1;return this.frequency=Math.min(Math.max(1/n,e.MIN_FRENQUENCY),e.MAX_FRENQUENCY),this.lastStepTimestamp=t,!0}return!1}get lastStepSize(){return this.frequency?.45+.2*this.frequency:0}get speed(){return this.lastStepSize&&this.frequency?this.lastStepSize*this.frequency:0}mean(e){let t=0,n=0;for(let n=0;n<e.length;++n)t+=e[n].verticalAcc;return n=t/e.length,n}stddev(e){let t=this.mean(e),n=0;for(let r=0;r<e.length;++r)n+=(e[r].verticalAcc-t)**2;return Math.sqrt(n/e.length)}},Ae=class e{static WINDOW_TIME=.6;static MIN_TIME_BETWEEN_STEPS=.6;static MAX_FRENQUENCY=4;static MIN_FRENQUENCY=1;static VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD=.2;static VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD=-.1;frequency=0;influence=.05;slidingWindow=[];lastStepTimestamp=-e.MIN_TIME_BETWEEN_STEPS;previousVerticalAcc=0;previousHorizontalAcc=0;compute(t,n){let r=this.influence*n[2]+(1-this.influence)*this.previousVerticalAcc;if(this.previousVerticalAcc=r,this.slidingWindow=this.slidingWindow.filter(n=>n.timestamp>=t-e.WINDOW_TIME),this.slidingWindow.push({timestamp:t,verticalAcc:r}),this.lastStepTimestamp&&this.lastStepTimestamp+e.MIN_TIME_BETWEEN_STEPS>t)return!1;let i=Number.MIN_VALUE,a=-1,o=!1;if(this.slidingWindow.forEach((t,n)=>{t.verticalAcc>i&&t.verticalAcc>=e.VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD&&(i=t.verticalAcc,a=n,o=!0)}),!o)return!1;let s=!1,c=Number.MAX_VALUE;for(let t=0;t<a;t++){let n=this.slidingWindow[t].verticalAcc;if(c=Math.min(c,n),n<e.VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD){s=!0;break}}if(!s)return!1;let l=i-c,u=i-.5*l,d=!1;for(let e=a+1;e<this.slidingWindow.length;e++)if(this.slidingWindow[e].verticalAcc<=u){d=!0;break}if(!d)return!1;let f=this.lastStepTimestamp?t-this.lastStepTimestamp:1;return this.frequency=Math.min(Math.max(1/f,e.MIN_FRENQUENCY),e.MAX_FRENQUENCY),this.lastStepTimestamp=t,!0}get lastStepSize(){return this.frequency?.45+.2*this.frequency:0}get speed(){return this.lastStepSize&&this.frequency?this.lastStepSize*this.frequency:0}mean(e){let t=0,n=0;for(let n=0;n<e.length;++n)t+=e[n];return n=t/e.length,n}stddev(e){let t=this.mean(e),n=0;for(let r=0;r<e.length;++r)n+=(e[r]-t)**2;return Math.sqrt(n/e.length)}},V=new class e extends y{static DEFAULT_STEP_SIZE_MULTIPLIER=1;static DEFAULT_ALGORITHM=`minMaxPeaks3`;accelerometerProviderId;attitudeProviderId;gyroscopeProviderId;angularRateEvent;attitudeEvent;numOfSteps=0;stepDetector;_stepSizeMultiplier=e.DEFAULT_STEP_SIZE_MULTIPLIER;_algorithm=e.DEFAULT_ALGORITHM;_accValues=[];constructor(){super(),this.algorithm=this._algorithm}getName=()=>`StepDetector`;availability(){return b.every([I.getAvailability(),L.getAvailability(),B.getAvailability()])}start(){this.numOfSteps=0,this.accelerometerProviderId=I.addEventListener(this.onAccelerometerEvent,this.notifyError),this.gyroscopeProviderId=L.addEventListener(e=>this.angularRateEvent=e,this.notifyError),this.attitudeProviderId=B.addEventListener(e=>this.attitudeEvent=e,this.notifyError)}stop(){I.removeEventListener(this.accelerometerProviderId),L.removeEventListener(this.gyroscopeProviderId),B.removeEventListener(this.attitudeProviderId)}onAccelerometerEvent=t=>{if(!this.attitudeEvent||!this.angularRateEvent)return;let{values:n,timestamp:r}=t,i=e.computeLinearAcceleration(this.attitudeEvent.quaternion,n);if(this.stepDetector.compute(r,i,this.angularRateEvent.values)){let e=this.stepDetector.lastStepSize*this._stepSizeMultiplier;this.numOfSteps++,this.notify({size:e,number:this.numOfSteps})}};static computeLinearAcceleration(e,r){let i=n.Quaternion.rotateMatlab(n.Quaternion.inverse(e),r);return i[2]-=t.Constants.EARTH_GRAVITY,i}set stepSizeMultiplier(e){this._stepSizeMultiplier=e}get stepSizeMultiplier(){return this._stepSizeMultiplier}set algorithm(e){switch(e){case`ladetto`:this.stepDetector=new De;break;case`minMaxPeaks`:this.stepDetector=new Oe;break;case`minMaxPeaks2`:this.stepDetector=new ke;break;default:e=`minMaxPeaks3`,this.stepDetector=new Ae;break}this._algorithm=e}get algorithm(){return this._algorithm}},je=new class extends y{absoluteAttitudeProviderId;stepDetectionProviderId;attitudeEvent;misalignmentError=(0,n.deg2rad)(3);getName=()=>`Pdr`;availability(){return b.every([V.getAvailability(),X.getAvailability()])}start(){this.stepDetectionProviderId=V.addEventListener(this.onStepEvent,this.notifyError),this.absoluteAttitudeProviderId=X.addEventListener(e=>this.attitudeEvent=e,this.notifyError)}stop(){V.removeEventListener(this.stepDetectionProviderId),X.removeEventListener(this.absoluteAttitudeProviderId)}onStepEvent=e=>{if(!this.attitudeEvent)return;let n=e.size,r=this.attitudeEvent,i=r.heading,a=r.accuracy+this.misalignmentError,o=n/2*Math.sin(a/2),s=r.time,c=new t.GeoRelativePosition(n*Math.sin(i),n*Math.cos(i),0,s,o,i);this.notify(c)}},H=new class extends y{providerId;geoRelativeProvider;getName=()=>`GeoRelativePosition`;availability(){return b.some([je.getAvailability(),be.getAvailability()])}async start(){let e=await be.getAvailability();this.geoRelativeProvider=e?je:be,this.providerId=this.geoRelativeProvider.addEventListener(this.notify,this.notifyError)}stop(){this.geoRelativeProvider?.removeEventListener(this.providerId),delete this.geoRelativeProvider}},Me={name:`@wemap/providers`,version:`14.7.1`,description:`Sensor, positioning and VPS providers for the Wemap SDK.`,license:`UNLICENSED`,author:`Wemap SAS`,homepage:`https://github.com/wemap/wemap-sdk-js#readme`,repository:{type:`git`,url:`git+https://github.com/wemap/wemap-sdk-js.git`,directory:`packages/providers`},bugs:{url:`https://github.com/wemap/wemap-sdk-js/issues`},keywords:[`wemap`,`sdk`,`providers`,`vps`],type:`module`,publishConfig:{access:`public`},main:`./dist/index.js`,types:`./dist/index.d.ts`,exports:{".":{import:`./dist/index.js`,types:`./dist/index.d.ts`}},sideEffects:!1,files:[`dist`],dependencies:{"@wemap/camera":`14.7.1`,"@wemap/core":`14.7.1`,"@wemap/geo":`14.7.1`,"@wemap/maths":`14.7.1`,"@wemap/osm":`14.7.1`,"@wemap/routers":`14.7.1`,"@wemap/utils":`14.7.1`},devDependencies:{"@wemap/logger-legacy":`^13.3.0`,geomag:`^1.0.0`}},Ne=new class extends y{providerId;getName=()=>`InclinationFromAcc`;availability=()=>I.getAvailability();start(){this.providerId=I.addEventListener(this.onAccelerometerEvent,this.notifyError)}stop(){I.removeEventListener(this.providerId)}onAccelerometerEvent=e=>{let t=e.values,n=window.orientation||0,r=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),i=[t[0]/r,t[1]/r,t[2]/r],a=[i[2]+1,i[1],-i[0],0],o=Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]),s=[a[0]/o,a[1]/o,a[2]/o,0],c;c=n===0?Math.asin(2*s[1]*s[0]):n===90?-Math.asin(2*s[2]*s[0]):n===-90?Math.asin(2*s[2]*s[0]):-Math.asin(2*s[1]*s[0]),this.notify(c)}},U=new class extends y{providerId;getName=()=>`InclinationFromRelativeAttitude`;availability=()=>B.getAvailability();start(){this.providerId=B.addEventListener(e=>{let t=this.enuQuatToInclination(e.quaternion);this.notify(t)},this.notifyError)}stop(){B.removeEventListener(this.providerId)}enuQuatToInclination(e){let t=window.orientation||0;return t===0?Math.asin(2*(e[2]*e[3]+e[1]*e[0])):t===90?Math.asin(2*(e[1]*e[3]-e[2]*e[0])):t===-90?Math.asin(2*(e[2]*e[0]-e[1]*e[3])):-Math.asin(2*(e[2]*e[3]+e[1]*e[0]))}},W=new class extends y{provider;providerId;getName=()=>`Inclination`;availability(){return b.some([Ne.getAvailability(),U.getAvailability()])}async start(){let e=()=>{this.provider=Ne,this.providerId=this.provider.addEventListener(this.notify,this.notifyError)};await U.getAvailability()?(this.provider=U,this.providerId=this.provider.addEventListener(this.notify,()=>{U.removeEventListener(this.providerId),e()})):e()}stop(){this.provider&&this.provider.removeEventListener(this.providerId)}},Pe=class e{size;calibration;coarse;device;constructor(e,t=null,n=null,r=null){this.size=e,this.calibration=t,this.coarse=n,this.device=r}toJson(){return{size:[this.size.width,this.size.height],...this.calibration&&{calibration:this.calibration},...this.coarse&&{coarse:{...this.coarse.attitude&&{attitude:this.coarse.attitude.toJson()},...this.coarse.position&&{position:this.coarse.position.toJson()}}},...this.device!==null&&{device:this.device}}}static fromJson(n){return new e({width:n.size[0],height:n.size[1]},n.calibration,{...n.coarse?.position&&{position:t.UserPosition.fromJson(n.coarse.position)},...n.coarse?.attitude&&{attitude:t.Attitude.fromJson(n.coarse.attitude)}},n.device)}},Fe=class e{metadata;image;imageQuality;localPose;constructor(e,t,n=.8,r=null){this.metadata=e,this.image=t,this.imageQuality=n,this.localPose=r}toJson(){return{image:(0,a.canvasToBase64)(this.image,`image/jpeg`,this.imageQuality),...this.localPose&&{local_pose:this.localPose},...this.metadata.toJson()}}static fromJson(t){return new e(Pe.fromJson(t),(0,a.base64ToCanvas)(t.image))}toFormData(){let e=this.image.toDataURL(`image/jpeg`,this.imageQuality).split(`,`)[1]||``,t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);let r=new FormData;r.append(`image`,new Blob([n],{type:`image/jpeg`}),`image.jpg`);let i=this.metadata.toJson();return i.calibration&&r.append(`calibration`,JSON.stringify(i.calibration)),i.coarse&&r.append(`coarse`,JSON.stringify(i.coarse)),i.device&&r.append(`device`,JSON.stringify(i.device)),this.localPose&&r.append(`local_pose`,JSON.stringify(this.localPose)),r}},Ie=class e{success;attitude;position;constructor(e,t=null,n=null){this.success=e,this.attitude=t,this.position=n}toJson(){return{success:this.success,attitude:this.attitude?.toJson(),position:this.position?.toJson()}}static fromJson(n,r=null){let i=null;n.attitude&&(i=t.Attitude.fromJson(n.attitude),i.time=r);let a=null;return n.position&&(a=t.UserPosition.fromJson(n.position),a.time=r),new e(n.success,i,a)}},Le=class{static REQUEST_TIMEOUT_MS=2e4;static _prepareRequest(e,t=null,n=null,r=null,o=null){let s=(0,a.reduceImageSize)(e,720,720),c=i.UserAgentUtils.getDeviceFromUserAgent()||{};return r&&(c.session_id=r.session_id,c.installation_id=r.installation_id,c.attempt_id=r.attempt_id,c.caller=r.caller),new Fe(new Pe({width:s.width,height:s.height},t,n,c),s,.8,o)}static async relocalize(e,t,n=null,r=null,a=null,o=null,s=null){let c=i.TimeUtils.preciseTime()/1e3,l=this._prepareRequest(t,n,r,a,o),u;try{let t=l.toFormData();u=await fetch(e,{method:`POST`,body:t,signal:AbortSignal.timeout(this.REQUEST_TIMEOUT_MS),headers:Object.assign({Accept:`application/vnd.geopose+json; version=1`},s||{})})}catch{return g.debug(`[VPS] Server respond error`),null}if(u.status!==200)return g.debug(`[VPS] Server respond error`),null;let d=await u.json(),f=Ie.fromJson(d,c);return g.debug(`[VPS] Server respond ${f.success?`success`:`not found`}`),f}static getHeadingFromQuaternion(e){let[t,n,r,i]=e,a=Math.sqrt(2)/2,o=[a*(t-n),a*(t+n),a*(r+i),a*(i-r)];return-Math.atan2(2*o[3]*o[0]-2*o[2]*o[1],1-2*o[1]**2-2*o[3]**2)}},G=new class extends y{arCoreMonitoringId;arCoreProviderId;inertialProviderId;getName=()=>`RelativeAttitude`;availability=()=>B.getAvailability();start(){this.arCoreMonitoringId=P.addMonitoringListener(()=>{this.listenArCore(),this.unlistenInertial()},()=>{this.unlistenArCore(),this.listenInertial()}),P.state===`started`?this.listenArCore():this.listenInertial()}stop(){P.removeMonitoringListener(this.arCoreMonitoringId),this.unlistenArCore(),this.unlistenInertial()}listenInertial=()=>{this.inertialProviderId=B.addEventListener(this.notify,this.notifyError)};unlistenInertial=()=>{B.removeEventListener(this.inertialProviderId)};listenArCore=()=>{this.arCoreProviderId=P.addEventListener(e=>this.notify(e.relativeAttitude),null,!1)};unlistenArCore=()=>{P.removeEventListener(this.arCoreProviderId)}},Re=class{_providerId;_isRunning=!1;_dataOnStart=null;tickStart(){this._dataOnStart=null,!this._isRunning&&(this._isRunning=!0,this._providerId=R.addEventListener(e=>{this._dataOnStart||=e}))}tickEnd(){if(!this._isRunning)return g.warn(`You have to call tickStart before tickEnd`),null;if(this._internalStop(),!this._dataOnStart)return g.warn(`Delay was too short between tickStart and tickEnd or RelativeAttitudeProvider cannot be retrieved.`),null;let e=R.lastEvent;return t.Attitude.diff(this._dataOnStart,e)}_internalStop(){R.removeEventListener(this._providerId),delete this._providerId,this._isRunning=!1}release(){this._isRunning&&this._internalStop()}},ze=class e extends Error{static DEFAULT_MESSAGE=`PoleStar is missing`;constructor(t){super(t||e.DEFAULT_MESSAGE)}},K=new class extends y{getName=()=>`PoleStar`;constructor(){super(),this.addMethodsToNativeJsProvider()}availability(){try{return this.nativeProvider.checkAvailability(),Promise.resolve()}catch(e){return Promise.resolve(e)}}setApiKey(e){this.nativeProvider.setApiKey(e)}start(){this.nativeProvider.start()}stop(){this.nativeProvider.stop()}get nativeProvider(){if(!this.nativeInterface)throw new ye;let e=this.nativeInterface.getPoleStarProvider();if(!e)throw new ze;return e}addMethodsToNativeJsProvider(){this.nativeJsInterface&&(this.nativeJsInterface.polestar={callbackError:e=>this.notifyError(Error(e)),callbackPosition:e=>{let t=JSON.parse(e),r=i.TimeUtils.unixTimestampToPreciseTime(t.time)/1e3,a=new o(t.lat,t.lng,_e.DEFAULT_ALTITUDE,t.alt/5,r,t.accuracy,(0,n.deg2rad)(t.bearing));this.notify(a)}})}},q=new class e extends y{static MIN_TIME_BETWEEN_TWO_REQUESTS=1e3;static DEFAULT_MAX_SCAN_DURATION=12e4;static DEFAULT_MIN_INCLINATION_FOR_REQUEST=(0,n.deg2rad)(60);static DEFAULT_WAIT_TIME_MIN_INCLINATION_FOR_REQUEST=200;static DEFAULT_USE_COARSE_POSE=!0;static DEFAULT_REQUEST_CALLER=`@wemap/providers(VpsProvider) ${Me.version}`;static CAMERA_TO_SMARTPHONE_ROT=n.Quaternion.fromAxisAngle([1,0,0],Math.PI);static ENU_TO_ARCORE_ROT=n.Quaternion.fromAxisAngle([1,0,0],-Math.PI/2);static _scanFailureCallbackUniqueId=0;_relativeRotationCalc;_serverError=!1;_cameraError=!1;_camera=null;_endpoint=null;_inclinationProviderId;_maxScanDuration=e.DEFAULT_MAX_SCAN_DURATION;_minInclinationForRequest=e.DEFAULT_MIN_INCLINATION_FOR_REQUEST;_waitTimeMinInclinationForRequest=e.DEFAULT_WAIT_TIME_MIN_INCLINATION_FOR_REQUEST;_useCoarsePose=e.DEFAULT_USE_COARSE_POSE;_requestCaller=e.DEFAULT_REQUEST_CALLER;_sessionId;_loopId=0;_attemptIdCounter=0;_currentAttemptId=null;_scanFailureCallbacks=[];constructor(){super(),this._sessionId=this._generateUuid()}getName=()=>`Vps`;availability=()=>a.Camera.checkAvailability();start(){this._inclinationProviderId=W.addEventListener(),this._relativeRotationCalc=new Re,a.SharedCameras.on(`added`,this._onCameraDetected),a.SharedCameras.on(`removed`,this._onCameraRemoved),a.SharedCameras.list.length&&(a.SharedCameras.list.length>1&&g.warn(`It seems that more than 1 camera has been detected for VPS. Taking the first...`),this._useCamera(a.SharedCameras.list[0].camera))}stop(){W.removeEventListener(this._inclinationProviderId),this._relativeRotationCalc?.release(),a.SharedCameras.off(`added`,this._onCameraDetected),a.SharedCameras.off(`removed`,this._onCameraRemoved),this._camera?.off(`started`,this._internalStart),this._camera?.off(`stopped`,this._internalStop),this._camera=null}_onCameraDetected=({camera:e})=>{this._camera&&g.warn(`It seems that more than 1 camera has been detected for VPS. Taking the first...`),this._useCamera(e)};_onCameraRemoved=()=>{this._camera?(this._camera.off(`started`,this._internalStart),this._camera.off(`stopped`,this._internalStop)):g.warn(`There is no previously detected camera but once has stopped`),this._camera=null};_useCamera(e){this._camera=e,e.on(`started`,this._internalStart),e.on(`stopped`,this._internalStop),e.state===`started`&&this._internalStart()}_internalStart=async()=>{if(!this._endpoint){this.notifyError(Error(`VPS endpoint has not been set before calling start()`));return}let r=null,a=++this._loopId,o=()=>this.state===`stopped`||a!==this._loopId,s=this._maxScanDuration>0?i.TimeUtils.preciseTime()+this._maxScanDuration:null;for(;!o();){if(r!==null){let t=i.TimeUtils.preciseTime()-r,n=Math.max(0,e.MIN_TIME_BETWEEN_TWO_REQUESTS-t);await new Promise(e=>setTimeout(e,n))}if(r=i.TimeUtils.preciseTime(),o()||!this._camera||this._camera.state!==`started`)break;if(s!==null&&i.TimeUtils.preciseTime()>s){this.notifyError(Error(`VPS scan gave up after ${this._maxScanDuration} ms without a match`));break}let a=W.lastEvent?W.lastEvent:null;if(a!==null&&a<this._minInclinationForRequest){await new Promise(e=>setTimeout(e,this._waitTimeMinInclinationForRequest));continue}if(typeof document<`u`&&document.hidden){await new Promise(e=>setTimeout(e,this._waitTimeMinInclinationForRequest));continue}this._relativeRotationCalc?.tickStart();let l=await this._camera.currentImage;if(!l)continue;let u=null,d=J.getBestPositionEvent(N.lastEvent,K.lastEvent);this._useCoarsePose&&(d||X.lastEvent)&&(u={...d&&{position:d},...X.lastEvent&&{attitude:X.lastEvent}}),this._currentAttemptId===null&&(this._attemptIdCounter+=1,this._currentAttemptId=this._attemptIdCounter);let f=G.lastEvent,p=H.lastEvent,m=f&&p?{position:n.Quaternion.rotate(e.ENU_TO_ARCORE_ROT,[p.x,p.y,p.z]),orientation:n.Quaternion.multiply(e.ENU_TO_ARCORE_ROT,f.quaternion)}:null,h=await Le.relocalize(this._endpoint,l,null,u,{session_id:this._sessionId,installation_id:null,...this._currentAttemptId!==null&&{attempt_id:this._currentAttemptId},caller:this._requestCaller},m);if(!h||!h.success){this._scanFailureCallbacks.forEach(({id:e,callback:t})=>t({listenerId:e,sessionId:this._sessionId,attemptId:this._currentAttemptId}));continue}this._currentAttemptId=null;let g=h.attitude.quaternion,_=n.Quaternion.multiply(g,e.CAMERA_TO_SMARTPHONE_ROT),v=n.Quaternion.multiply(n.Quaternion.fromAxisAngle([0,0,1],(0,n.deg2rad)(window.orientation||0)),_),y=this._relativeRotationCalc?.tickEnd()||new t.Attitude([1,0,0,0]),b=new c(n.Quaternion.multiply(v,y.quaternion),h.attitude.time,h.attitude.accuracy),ee=h.position.clone();if(ee.accuracy===null&&(ee.accuracy=5),o())break;this.notify({absoluteAttitude:b,absolutePosition:ee})}};_internalStop=()=>{};_generateUuid(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}addScanFailureListener(t){let n=++e._scanFailureCallbackUniqueId;return this._scanFailureCallbacks.push({id:n,callback:t}),n}removeScanFailureListener(e){this._scanFailureCallbacks=this._scanFailureCallbacks.filter(({id:t})=>t!==e)}resetCurrentAttempt(){this._currentAttemptId=null}get endpoint(){return this._endpoint}set endpoint(e){this._endpoint=e}get maxScanDuration(){return this._maxScanDuration}set maxScanDuration(e){this._maxScanDuration=e}get minInclinationForRequest(){return this._minInclinationForRequest}set minInclinationForRequest(e){this._minInclinationForRequest=e}get waitTimeMinInclinationForRequest(){return this._waitTimeMinInclinationForRequest}set waitTimeMinInclinationForRequest(e){this._waitTimeMinInclinationForRequest=e}get useCoarsePose(){return this._useCoarsePose}set useCoarsePose(e){this._useCoarsePose=e}get requestCaller(){return this._requestCaller}set requestCaller(e){this._requestCaller=e}},J=new class e extends y{static ACCURACY_RELOC_RATIO=1;static USE_MM_FOR_FEED=!0;_polestarProviderId;_vpsProviderId;_gnssWifiProviderId;_relativePositionProviderId;_mapMatchingHandlerId;useAllAbsolutePositions=!1;_waitUntilNextVpsPosition=!1;_lastPolestarFix=null;ignoreGnssWifi=!1;_lastKnownLevel=null;getName=()=>`AbsolutePosition`;_adaptBeforeNotify(e){return e.level===null?e.level=this._lastKnownLevel:this._lastKnownLevel=e.level,e}availability(){return b.some([H.getAvailability(),N.getAvailability(),...l.hasPoleStar?[K.getAvailability()]:[],q.getAvailability()])}start(){H.getAvailability().then(e=>{e||(this._relativePositionProviderId=H.addEventListener(e=>this._onRelativePosition(e)))}),this._gnssWifiProviderId=N.addEventListener(e=>{if(this.ignoreGnssWifi)return;let t=e.clone();t.bearing=null,this._onAbsolutePosition(t,`gnss-wifi`,!1)}),this._vpsProviderId=q.addEventListener(e=>this._onAbsolutePosition(e.absolutePosition,`vps`),this.notifyError,!1),l.hasPoleStar&&(this._polestarProviderId=K.addEventListener(e=>{if(this._lastPolestarFix=i.TimeUtils.preciseTime(),!this._onAbsolutePosition(e,`polestar`)&&this.lastEvent?.level===null){let t=this.lastEvent.clone();t.level=e.level,this.notify(t)}})),this._mapMatchingHandlerId=$.addEventListener()}stop(){this._relativePositionProviderId&&(H.removeEventListener(this._relativePositionProviderId),delete this._relativePositionProviderId),this._gnssWifiProviderId&&(N.removeEventListener(this._gnssWifiProviderId),delete this._gnssWifiProviderId),this._vpsProviderId&&(q.removeEventListener(this._vpsProviderId),delete this._vpsProviderId),this._polestarProviderId&&(K.removeEventListener(this._polestarProviderId),delete this._polestarProviderId),$.removeEventListener(this._mapMatchingHandlerId)}_shouldTakeIntoAccountNewAbsolutePosition(n,r=!0){let i=n,a=this.lastEvent||null;if(!a)return!0;let o=i.accuracy*e.ACCURACY_RELOC_RATIO<=a.accuracy;if(o)return!0;let s=a.distanceTo(i)>a.accuracy+i.accuracy;if(s)return!0;let c=s&&i.accuracy<=a.accuracy;return!!(o&&c||r&&!t.Level.equals(i.level,a.level))}_onAbsolutePosition(e,t,n=!0){if(!this._shouldTakeIntoAccountNewAbsolutePosition(e,n)&&!this.useAllAbsolutePositions)return!1;let r=o.fromUserPosition(e,t),i=this.lastEvent?this.lastEvent:null;return i&&(n||(r.level=i.level),r.bearing===null&&(r.bearing=i.bearing)),$.canUseMapMatching()?$.notifyPositionFromAbsolute(r):(this.notify(r),!0)}_onRelativePosition(e){if(!this.lastEvent||this._waitUntilNextVpsPosition)return!1;let t=this.lastEvent,n=e,r=Math.sqrt(n.x**2+n.y**2),i=Math.atan2(n.x,n.y),a=t.alt===null?null:n.z,s=t.destinationPoint(r,i,a);s.bearing=n.bearing,s.time=n.time,s.accuracy+=n.accuracy;let c=o.fromUserPosition(s,`relative`);return $.canUseMapMatching()?$.notifyPositionFromRelative(c):(this.notify(c),!0)}feed(n){let r;if(n instanceof t.UserPosition){if(n.time===null)throw Error(`the time of the position is not defined`);if(n.accuracy===null)throw Error(`the accuracy of the position is not defined`);r=o.fromUserPosition(n,n.source??`feed`)}else throw Error(`data is nor an UserPosition or an AbsolutePositionEvent`);if(!e.USE_MM_FOR_FEED||!$.canUseMapMatching()){this.notify(r);return}$.notifyPositionFromFeed(r)}getBestPositionEvent(...e){return e.reduce((e,t)=>{if(!e)return t;if(!t||t.accuracy===null||t.time===null)return e;let{accuracy:n,time:r}=t,{accuracy:i,time:a}=e;return n<i+1.3888*(r-a)?t:e},null)}},Y=new class e extends y{DEFAULT_ACCURACY=(0,n.deg2rad)(15);absolutePositionProviderId;absolutePositionEvent;declinationQuaternion;magQuaternion;magQuaternionTimestamp;iosPreviousQuat;iosIsSkyMode=null;getName=()=>`AbsoluteAttitudeFromBrowser`;availability(){return i.BrowserUtils.isMobile?Promise.resolve():Promise.resolve(new A)}start(){let e=()=>{switch(i.BrowserUtils.getName()){case i.Browser.CHROME:window.addEventListener(`deviceorientationabsolute`,this.onDeviceOrientationChromeEvent,!0);break;case i.Browser.SAFARI:case i.Browser.IOS_WEBVIEW:window.addEventListener(`deviceorientation`,this.onDeviceOrientationSafariEvent,!0);break}},t=DeviceOrientationEvent.requestPermission||void 0;t?t().then(t=>{if(t!==`granted`)throw Error(`Permission not granted`);e()}).catch(this.notifyError):e();let n=J.lastEvent;n?this.onAbsolutePositionEvent(n):this.absolutePositionProviderId=J.addEventListener(this.onAbsolutePositionEvent,this.notifyError,!1)}stop(){switch(i.BrowserUtils.getName()){case i.Browser.CHROME:window.removeEventListener(`deviceorientationabsolute`,this.onDeviceOrientationChromeEvent,!0);break;case i.Browser.SAFARI:case i.Browser.IOS_WEBVIEW:window.removeEventListener(`deviceorientation`,this.onDeviceOrientationSafariEvent,!0);break}J.removeEventListener(this.absolutePositionProviderId)}onDeviceOrientationChromeEvent=e=>{if(this.magQuaternionTimestamp=e.timeStamp/1e3,typeof e.alpha!=`number`||typeof e.beta!=`number`||typeof e.gamma!=`number`){this.notifyError(new j().from(`deviceorientationabsolute`));return}this.magQuaternion=n.Rotations.eulerToQuaternionZXYDegrees([e.alpha,e.beta,e.gamma]),this.compute()};onDeviceOrientationSafariEvent=t=>{if(this.magQuaternionTimestamp=t.timeStamp/1e3,typeof t.beta!=`number`||typeof t.gamma!=`number`){this.notifyError(new j().from(`deviceorientation`));return}if(typeof t.webkitCompassHeading!=`number`){this.notifyError(new M().from(`deviceorientation`));return}let r,[i,a,o,s]=n.Rotations.eulerToQuaternionZXYDegrees([t.webkitCompassHeading,t.beta,t.gamma]),c=(0,n.rad2deg)(Math.acos(i**2-a**2-o**2+s**2)),l=null;c>136?l=!0:c<134?l=!1:this.iosPreviousQuat&&this.iosIsSkyMode!==null&&(l=n.Quaternion.distance([i,a,o,s],this.iosPreviousQuat)<.5?this.iosIsSkyMode:!this.iosIsSkyMode),this.iosPreviousQuat=[i,a,o,s],this.iosIsSkyMode=l,l!==void 0&&(r=l?180-t.webkitCompassHeading:e.webkitCompassToHeading(t.webkitCompassHeading,t.beta,t.gamma),this.magQuaternion=n.Rotations.eulerToQuaternionZXYDegrees([r,t.beta,t.gamma]),this.compute())};compute(){if(!this.declinationQuaternion||!this.magQuaternion||!this.absolutePositionEvent)return;let e=new c(n.Quaternion.multiply(this.declinationQuaternion,this.magQuaternion),this.magQuaternionTimestamp,this.DEFAULT_ACCURACY);this.notify(e)}onAbsolutePositionEvent=e=>{this.absolutePositionEvent=e;let t=pe(e.lat,e.lng);this.declinationQuaternion=n.Quaternion.fromAxisAngle([0,0,1],-(0,n.deg2rad)(t.declination)),J.removeEventListener(this.absolutePositionProviderId),delete this.absolutePositionProviderId,this.compute()};static webkitCompassToHeading(e,t,r){let i=(0,n.deg2rad)(e),a=(0,n.deg2rad)(t),o=(0,n.deg2rad)(r),s=Math.cos(i/2),c=Math.cos(a/2),l=Math.cos(o/2),u=Math.sin(i/2),d=Math.sin(a/2),f=Math.sin(o/2),p=s*c*l-u*d*f,m=u*c*l+s*d*f;return(0,n.rad2deg)(-2*Math.atan(m/p))}},X=new class e extends y{static REL_ABS_DIVERGENCE_ANGLE_THRESHOLD=(0,n.deg2rad)(25);static REL_ABS_DIVERGENCE_TIME_THRESHOLD=2.5;static REL_ABS_DIVERGENCE_INCLINATION_THRESHOLD=(0,n.deg2rad)(15);_absAttitudeFromBrowser;_vpsProviderId;fromBrowserProviderId;highRotationProviderId;inclinationProviderId;relativeAttitudeProviderId;_attitudeFromBrowserErrored=!1;_attitudeFromRelativeErrored=!1;_relativeAttitude=null;_relativeAccuracy=0;_lastForcedHeadingEvent;_relAbsQuat;_wasHighRotationInProgress=!1;_timeFirstDivergence=null;_callbackMagCalibration;getName=()=>`AbsoluteAttitude`;availability(){return b.some([Y.getAvailability(),G.getAvailability()])}start(){this.fromBrowserProviderId=Y.addEventListener(this._onAttitudeFromBrowser,e=>{this._attitudeFromBrowserErrored=!0,this._onError(e)}),this._vpsProviderId=q.addEventListener(e=>this._onAttitudeFromVps(e.absoluteAttitude),e=>this.notifyError(e),!1),this.relativeAttitudeProviderId=G.addEventListener(this._onRelativeAttitudeEvent,e=>{this._attitudeFromRelativeErrored=!0,this._onError(e)}),this.inclinationProviderId=W.addEventListener(),this.highRotationProviderId=z.addEventListener()}stop(){Y.removeEventListener(this.fromBrowserProviderId),G.removeEventListener(this.relativeAttitudeProviderId),W.removeEventListener(this.inclinationProviderId),z.removeEventListener(this.highRotationProviderId),q.removeEventListener(this._vpsProviderId)}_setCallbackMagCalibration(e){this._callbackMagCalibration=e}_onError=e=>{this._attitudeFromBrowserErrored&&this._attitudeFromRelativeErrored&&this.notifyError(e)};_forceHeadingForRelative=e=>{if(this.lastEvent&&e.accuracy>this.lastEvent.accuracy)return;let t=t=>{let r=t.heading;this._relAbsQuat=n.Quaternion.fromAxisAngle([0,0,1],r-e.heading),this._relativeAccuracy=0,this._lastForcedHeadingEvent=e};if(this._relativeAttitude){t(this._relativeAttitude);return}let r=G.addEventListener(e=>{t(e),G.removeEventListener(r)})};_onRelativeAttitudeEvent=r=>{let{quaternion:i,accuracy:a,time:o}=r;if(this._relativeAttitude&&(this._relativeAccuracy+=(o-this._relativeAttitude.time)*a),this._relativeAttitude=r,!this._lastForcedHeadingEvent||!this._relAbsQuat)return;let s=Math.min((this._lastForcedHeadingEvent.accuracy||0)+this._relativeAccuracy,Math.PI),l=z.isInProgress(),u=!1;if(this._absAttitudeFromBrowser){let{accuracy:r,heading:a}=this._absAttitudeFromBrowser;if(this._wasHighRotationInProgress&&!l)this._forceHeadingForRelative(this._absAttitudeFromBrowser);else if(r<s){let r=new t.Attitude(n.Quaternion.multiply(this._relAbsQuat,i)),s=Math.abs((0,n.diffAngle)(r.heading,a)),c=W.lastEvent;s>e.REL_ABS_DIVERGENCE_ANGLE_THRESHOLD&&c!==null&&Math.abs(c-Math.PI/4)>e.REL_ABS_DIVERGENCE_INCLINATION_THRESHOLD&&(u=!0,this._timeFirstDivergence!==null&&o-this._timeFirstDivergence>e.REL_ABS_DIVERGENCE_TIME_THRESHOLD?(this._forceHeadingForRelative(this._absAttitudeFromBrowser),this._callbackMagCalibration?.({angle:s}),this._timeFirstDivergence=null):this._timeFirstDivergence===null&&(this._timeFirstDivergence=o))}}u||(this._timeFirstDivergence=null),this._wasHighRotationInProgress=l;let d=new c(n.Quaternion.multiply(this._relAbsQuat,i),o,s);this.notify(d)};_onAttitudeFromBrowser=e=>{if(this._absAttitudeFromBrowser=e,!this._lastForcedHeadingEvent){this._forceHeadingForRelative(e);return}};_onAttitudeFromVps=e=>{this._forceHeadingForRelative(e)};feed(e){if(e instanceof t.AbsoluteHeading){if(e.time===null)throw Error(`the time of the absolute heading is not defined`);if(e.accuracy===null)throw Error(`the accuracy of the absolute heading is not defined`);this._forceHeadingForRelative(e)}else if(e instanceof c){if(e.time===null)throw Error(`the time of the attitude is not defined`);if(e.accuracy===null)throw Error(`the accuracy of the attitude is not defined`);this._forceHeadingForRelative(e)}else throw Error(`data is nor an AbsoluteHeading or an Attitude object`)}},Z=new class e extends y{static SLIDING_WINDOW_TIME=.3;static STD_THRESHOLD=.075;static CONSIDER_TURN_UNTIL=1;providerId;slidingWindow=[];getName=()=>`Turn`;availability=()=>G.getAvailability();start(){this.providerId=G.addEventListener(this._parseRelativeAttitude,this.notifyError)}stop(){G.removeEventListener(this.providerId)}isTurning(){return!this.lastEvent||!G.lastEvent?!1:G.lastEvent.time-this.lastEvent.timestamp<e.CONSIDER_TURN_UNTIL}_parseRelativeAttitude=t=>{let{heading:r}=t,i=t.time;this.slidingWindow=this.slidingWindow.filter(t=>t[0]>=i-e.SLIDING_WINDOW_TIME),this.slidingWindow.push([i,r]),(0,n.std)(this.slidingWindow.map(e=>e[1]))>e.STD_THRESHOLD&&this.notify({timestamp:i})}},Q=new class e extends y{static DEFAULT_STEPS_CONSIDERED_FOR_STRAIGHT_LINE=2;_turnProviderId;_stepProviderId;_countSteps=0;_stepsConsideredForStraightLine=e.DEFAULT_STEPS_CONSIDERED_FOR_STRAIGHT_LINE;getName=()=>`StraightLine`;availability(){return b.every([Z.getAvailability(),V.getAvailability()])}start(){this._turnProviderId=Z.addEventListener(this._onTurn),this._stepProviderId=V.addEventListener(this._onStep)}stop(){Z.removeEventListener(this._turnProviderId),V.removeEventListener(this._stepProviderId)}_onTurn=()=>{this._countSteps>=this._stepsConsideredForStraightLine&&this.notify(!1),this._countSteps=0};_onStep=()=>{this._countSteps++,this._countSteps===this._stepsConsideredForStraightLine&&this.notify(!0)};isStraight(){return this._countSteps>=this._stepsConsideredForStraightLine}get numStepsDetectedFromLastTurn(){return this._countSteps}get stepsConsideredForStraightLine(){return this._stepsConsideredForStraightLine}set stepsConsideredForStraightLine(e){this._stepsConsideredForStraightLine=e}},$=new class e extends y{static DEFAULT_MM_MAX_ANGLE=(0,n.deg2rad)(30);static DEFAULT_MM_MAX_DIST=30;static DEFAULT_USE_ITINERARY_START_AS_POSITION=!1;static DEFAULT_USE_ORIENTATION_MATCHING=!1;static DEFAULT_MM_HUGE_JUMP_DISTANCE=3;static DEFAULT_DISABLE_MM_CLOSE_TO_A_TURN_DISTANCE=2;static DEFAULT_MIN_STEPS_BETWEEN_ORIENTATION_MATCHING=3;static DEFAULT_MIN_STEPS_FOR_ORIENTATION_MATCHING=5;static DEFAULT_LAST_PROJECTIONS_WINDOW_SIZE=3;static DEFAULT_LAST_PROJECTIONS_EDGE_ANGLE_THRESHOLD=(0,n.deg2rad)(3);static DEFAULT_USE_STRICT=!1;_mapMatchingMaxDistance=e.DEFAULT_MM_MAX_DIST;_mapMatchingMaxAngleBearing=e.DEFAULT_MM_MAX_ANGLE;_useItineraryStartAsPosition=e.DEFAULT_USE_ITINERARY_START_AS_POSITION;_useOrientationMatching=e.DEFAULT_USE_ORIENTATION_MATCHING;_hugeJumpDistance=e.DEFAULT_MM_HUGE_JUMP_DISTANCE;_disableMMCloseToATurnDistance=e.DEFAULT_DISABLE_MM_CLOSE_TO_A_TURN_DISTANCE;_minStepsBetweenOrientationMatching=e.DEFAULT_MIN_STEPS_BETWEEN_ORIENTATION_MATCHING;_minStepsForOrientationMatching=e.DEFAULT_MIN_STEPS_FOR_ORIENTATION_MATCHING;_lastProjectionsWindowSize=e.DEFAULT_LAST_PROJECTIONS_WINDOW_SIZE;_lastProjectionsEdgeAngleThreshold=e.DEFAULT_LAST_PROJECTIONS_EDGE_ANGLE_THRESHOLD;_useStrict=e.DEFAULT_USE_STRICT;_graph=null;_internalProvidersStarted=!1;_straightLineProviderId;_turnProviderId;_stepProviderId;_projectionsWithAbsAndWithoutRelAttitudeInARow=[];_countStepsFromLastMatching=0;_lastProjections=[];_itineraryInfoManager=null;getName=()=>`MapMatchingHandler`;availability=()=>Promise.resolve();start(){this.graph&&this._startInternalProviders()}stop(){this._stopInternalProviders()}_manageStartStop=()=>{this.graph&&!this._internalProvidersStarted?this._startInternalProviders():!this.graph&&this._internalProvidersStarted&&this._stopInternalProviders()};_startInternalProviders(){this.enabled&&this._internalProvidersStarted||(this._straightLineProviderId=Q.addEventListener(),this._turnProviderId=Z.addEventListener(),this._stepProviderId=V.addEventListener(()=>this._countStepsFromLastMatching++),this._internalProvidersStarted=!0)}_stopInternalProviders(){this.enabled&&!this._internalProvidersStarted||(Q.removeEventListener(this._straightLineProviderId),Z.removeEventListener(this._turnProviderId),V.removeEventListener(this._stepProviderId),this._internalProvidersStarted=!1)}get enabled(){return l.useMapMatching}get graph(){return this._graph}set graph(e){this._graph=e,this._itineraryInfoManager=null,this.notify({...e&&{graph:e}}),this._manageStartStop(),this.canUseMapMatching()}set itinerary(e){this._graph=e?e.toGraph():null,this._itineraryInfoManager=new r.ItineraryInfoManager(e),this.notify({...e&&{itinerary:e}}),this._manageStartStop(),this.canUseMapMatching()&&e&&this._notifyPositionFromItineraryInput(e)}canUseMapMatching(){return this.enabled&&this.graph}_notifyPositionFromItineraryInput(e){if(!this._useItineraryStartAsPosition||!e.origin)return;let n=J.lastEvent||null,r=t.UserPosition.fromCoordinates(e.origin);if(n)r.alt=n.alt,r.time=n.time,r.accuracy=n.accuracy+r.distanceTo(n),r.bearing=n.bearing;else if(e.coords.length>=2)r.alt=_e.DEFAULT_ALTITUDE,r.time=i.TimeUtils.preciseTime(),r.accuracy=0,r.bearing=e.coords[0].bearingTo(e.coords[1]);else return;let a=this.getProjection(r,!0);a?J.notify(a.coords):J.notify(r)}notifyPositionFromFeed(e){let t=this.getProjection(e,!0,!1);if(this._useStrict&&t){J.notify(t.coords);return}if(!t){J.notify(e);return}J.notify(t.coords)}notifyPositionFromAbsolute(e){if(this._useStrict){let t=this.getProjection(e);if(t)return J.notify(t.coords),!0}let t=null;if(e.bearing!==null&&(t=this.getProjection(e,!0,!0)),!t)return J.notify(e),!0;let n=t.distanceFromNearestElement>this._hugeJumpDistance;return n&&!Q.isStraight()||n&&this._detectWrongBigJump(t)?!1:(J.notify(t.coords),this.tryOrientationMatching(t),!0)}notifyPositionFromRelative(e){let t=this.getProjection(e,!0,!0);if(this._useStrict&&t)return J.notify(t.coords),!0;if(Z.isTurning())return this._projectionsWithAbsAndWithoutRelAttitudeInARow=[],this._lastProjections=[],J.notify(e),!0;if(t){this._projectionsWithAbsAndWithoutRelAttitudeInARow=[],this._lastProjections.push(t),this._lastProjections.length>this._lastProjectionsWindowSize&&this._lastProjections.shift();let n=t.distanceFromNearestElement>this._hugeJumpDistance;return n&&!Q.isStraight()||n&&this._detectWrongBigJump(t)||!this._areLastProjectionsInTheSameDirection()||this._disableMMCloseToATurnDistance>0&&this._hasTurnInCircle(t.coords,this._disableMMCloseToATurnDistance)?(J.notify(e),!0):(J.notify(t.coords),this.tryOrientationMatching(t),!0)}if(Q.isStraight()){let t=e.clone();t.bearing=Y.lastEvent?.heading||null;let n=this.getProjection(t,!0,!0);if(n)return this._projectionsWithAbsAndWithoutRelAttitudeInARow.push(n),this._projectionsWithAbsAndWithoutRelAttitudeInARow.length<3||(this._lastProjections.push(n),this._lastProjections.length>this._lastProjectionsWindowSize&&this._lastProjections.shift(),!this._areLastProjectionsInTheSameDirection())?(J.notify(e),!0):(J.notify(n.coords),this.tryOrientationMatching(n),!0)}return this._projectionsWithAbsAndWithoutRelAttitudeInARow=[],this._lastProjections=[],J.notify(e),!0}_detectWrongBigJump(e){if(this._itineraryInfoManager&&J.lastEvent){let t=this._itineraryInfoManager.getInfo(J.lastEvent),n=this._itineraryInfoManager.getInfo(e.coords);if(t&&n&&t.traveledDistance>n.traveledDistance&&t.traveledDistance-n.traveledDistance>e.origin.accuracy&&e.distanceFromNearestElement>e.origin.accuracy&&e.origin.distanceTo(J.lastEvent)<e.origin.accuracy+J.lastEvent.accuracy)return!0}return!1}_areLastProjectionsInTheSameDirection(){if(this._lastProjections.length===0)return!1;let e=this._lastProjections[0];return!this._lastProjections.some(t=>!(t.nearestElement instanceof r.Edge)||!(e.nearestElement instanceof r.Edge)||(0,n.diffAngleLines)(t.nearestElement.bearing,e.nearestElement.bearing)>this._lastProjectionsEdgeAngleThreshold)}_nodeHasTurn(t){if(!this._graph)return;let r=this._graph.edges.filter(e=>e.vertex1===t||e.vertex2===t);for(let t=0;t<r.length;t++)for(let i=t+1;i<r.length;i++)if((0,n.diffAngleLines)(r[t].bearing,r[i].bearing)>e.DEFAULT_MM_MAX_ANGLE)return!0;return!1}_hasTurnInCircle(e,n){let r=this._graph;return r?r.vertices.filter(r=>r.coords.distanceTo(e)<=n&&t.Level.intersect(r.coords.level,e.level)).some(e=>this._nodeHasTurn(e)):!1}tryOrientationMatching(e){if(!this._useOrientationMatching||this.state!==`started`||this._countStepsFromLastMatching<this._minStepsBetweenOrientationMatching||Q.numStepsDetectedFromLastTurn<this._minStepsForOrientationMatching)return;let{nearestElement:i,origin:a}=e;if(!(i instanceof r.Edge))return;let o,s=(0,n.diffAngle)(i.bearing,a.bearing),c=(0,n.diffAngle)(i.bearing+Math.PI,a.bearing);o=Math.abs(s)<Math.abs(c)?i.bearing:(i.bearing+Math.PI)%(2*Math.PI);let l=new t.AbsoluteHeading(o,a.time,0);X._forceHeadingForRelative(l),this._countStepsFromLastMatching=0}getProjection(e,t,n){let r={...t&&!this._useStrict&&{maxDistance:this._mapMatchingMaxDistance},...n&&!this._useStrict&&{maxBearingAngle:this._mapMatchingMaxAngleBearing}};return this._graph?.getProjection(e,r)}get maxDistance(){return this._mapMatchingMaxDistance}set maxDistance(e){this._mapMatchingMaxDistance=e}get maxAngleBearing(){return this._mapMatchingMaxAngleBearing}set maxAngleBearing(e){this._mapMatchingMaxAngleBearing=e}get useItineraryStartAsPosition(){return this._useItineraryStartAsPosition}set useItineraryStartAsPosition(e){this._useItineraryStartAsPosition=e}get useOrientationMatching(){return this._useOrientationMatching}set useOrientationMatching(e){this._useOrientationMatching=e}get hugeJumpDistance(){return this._hugeJumpDistance}set hugeJumpDistance(e){this._hugeJumpDistance=e}get disableMMCloseToATurnDistance(){return this._disableMMCloseToATurnDistance}set disableMMCloseToATurnDistance(e){this._disableMMCloseToATurnDistance=e}get minStepsBetweenOrientationMatching(){return this._minStepsBetweenOrientationMatching}set minStepsBetweenOrientationMatching(e){this._minStepsBetweenOrientationMatching=e}get minStepsForOrientationMatching(){return this._minStepsForOrientationMatching}set minStepsForOrientationMatching(e){this._minStepsForOrientationMatching=e}get lastProjectionsWindowSize(){return this._lastProjectionsWindowSize}set lastProjectionsWindowSize(e){this._lastProjectionsWindowSize=e}get lastProjectionsEdgeAngleThreshold(){return this._lastProjectionsEdgeAngleThreshold}set lastProjectionsEdgeAngleThreshold(e){this._lastProjectionsEdgeAngleThreshold=e}get useStrict(){return this._useStrict}set useStrict(e){this._useStrict=e}},Be=class e{static DEFAULT_FREQUENCY=60;static DEFAULT_FLYBY_TIME=1;positionsQueue=[];previousPosition=null;timeoutNotify;callback;frequency;constructor(t,n=e.DEFAULT_FREQUENCY){this.callback=t,this.frequency=n}feed(n,r=e.DEFAULT_FLYBY_TIME){if(!(n instanceof t.UserPosition))throw TypeError(`newPosition is not instance of UserPosition`);if(n.time===null)throw Error(`newPosition does not have time property`);let i;if(this.positionsQueue.length===0?i=this.previousPosition:(i=this.positionsQueue[0],this.positionsQueue=[]),i){let e=n.time,a=i.distanceTo(n),o=i.bearingTo(n),s=1,c=this.frequency*r+1,l=t.Level.clone(n.level);for(;s<c+1;){let t=i.destinationPoint(a*s/c,o);t.time=e+(s-1)/this.frequency,t.level=l,t.bearing=n.bearing,t.accuracy=Math.max(t.accuracy+(n.accuracy-t.accuracy)*s/c,0),this.positionsQueue.push(t),s++}this.timeoutNotify&&clearTimeout(this.timeoutNotify)}else this.positionsQueue.push(n.clone());this.previousPosition=n,this._notifyNext()}_notifyNext=()=>{this.positionsQueue.length&&(this.callback?.(this.positionsQueue.shift()),this.positionsQueue.length===0?delete this.timeoutNotify:this.timeoutNotify=setTimeout(this._notifyNext,1e3/this.frequency))};clear(){clearTimeout(this.timeoutNotify),delete this.timeoutNotify,this.positionsQueue=[]}},Ve=class e{static ROTATION_SPEED_JUMP_THRESHOLD=(0,n.deg2rad)(180);static ROTATION_SPEED_CONVERGENCE=(0,n.deg2rad)(10);static HIGH_JUMP_THRESHOLD=(0,n.deg2rad)(20);static ROTATION_SPEED_HIGH_JUMP_CONVERGENCE=(0,n.deg2rad)(100);static PITCH_UNCERTAINITY_HEADING_THRESHOLD=(0,n.deg2rad)(5);_previousAttitude;_smoothing=null;callback;constructor(e){this.callback=e}feed(r){if(r.time===null)throw Error(`newAttitude does not have time property`);let{_previousAttitude:i}=this;if(this._previousAttitude=r,!i){this.callback(r);return}if(e.isJump(i,r)){let a=this._smoothing===null?i:this._smoothing.interpAttitude(i),o=a.heading,s=r.heading,c=(0,n.diffAngle)(s,o),l=Math.abs(c)<e.HIGH_JUMP_THRESHOLD?e.ROTATION_SPEED_CONVERGENCE:e.ROTATION_SPEED_HIGH_JUMP_CONVERGENCE,u=a.time,d=Math.abs(c)/l,f=c<0?-1:1;this._smoothing={toTime:u+d,interpAttitude:e=>{let r=l*(e.time-u),i=o+r*f,a=n.Quaternion.fromAxisAngle([0,0,1],s-i);return new t.Attitude(n.Quaternion.multiply(a,e.quaternion),e.time,e.accuracy)}}}if(this._smoothing!==null)if(r.time>=this._smoothing.toTime)this._smoothing=null;else{let e=this._smoothing.interpAttitude(r);this.callback(e);return}this.callback(r)}static isJump(t,r){let i=t.heading,a=r.heading,o=(0,n.diffAngle)(a,i),s=r.time-t.time,[c,l,u,d]=r.quaternion;return Math.abs(Math.asin(2*(c*l+u*d))-Math.PI/4)<e.PITCH_UNCERTAINITY_HEADING_THRESHOLD?!1:Math.abs(o)>e.ROTATION_SPEED_JUMP_THRESHOLD*s}},He=new class extends y{getName=()=>`MagnetometerCalibrationProvider`;availability=()=>X.getAvailability();constructor(){super(),X._setCallbackMagCalibration(e=>this.state===`started`&&this.notify(e))}start(){}stop(){}},Ue=class e extends Error{static DEFAULT_MESSAGE=`IP Resolver failed`;constructor(t){super(t||e.DEFAULT_MESSAGE)}},We=new class extends y{getName=()=>`Ip`;availability=()=>Promise.resolve();async start(){let e=await fetch(`https://ipinfo.io/geo?token=24a7ca2f3b489d`);if(!e){this.notifyError(new Ue);return}let n=i.TimeUtils.preciseTime()/1e3,r=(await e.json()).loc.split(`,`),a=new t.UserPosition(parseFloat(r[0]),parseFloat(r[1]),null,null,n,1e5);this.notify(a)}stop(){}},Ge=class e{static MAX_CONSECUTIVE_FAILURES=10;intervalMs;maxDurationMs;expiresAt=null;enabled;timeoutId=null;listenerId=null;scanFailureListenerId=null;isBackgroundScanRunning=!1;consecutiveFailures=0;_status;statusCallbacks=new Set;onResult;onError;constructor(e,t,n){this.onResult=t,this.onError=n,this.intervalMs=e.intervalMs??3e4,this.maxDurationMs=e.maxDurationMs??30*6e4,this.enabled=e.enabled??!1,this._status=this.enabled?`idle`:`disabled`}get status(){return this._status}setEnabled(e){this.enabled=e,e?!this.isBackgroundScanRunning&&!this.timeoutId&&this.setStatus(`idle`):(this.clear(),this.setStatus(`disabled`))}onStatusChange(e){return this.statusCallbacks.add(e),()=>{this.offStatusChange(e)}}offStatusChange(e){this.statusCallbacks.delete(e)}schedule(){if(this.enabled){if(this.maxDurationMs>0&&this.expiresAt===null&&(this.expiresAt=Date.now()+this.maxDurationMs),this.expired){this.clearTimeoutOnly();return}this.clearTimeoutOnly(),this.timeoutId=setTimeout(()=>{this.timeoutId=null,this.startBackgroundScan()},this.intervalMs),this.setStatus(`scheduled`)}}async cancelRunningScan(){this.isBackgroundScanRunning&&(this.listenerId!==null&&(q.removeEventListener(this.listenerId),this.listenerId=null,q.stop()),this.scanFailureListenerId!==null&&(q.removeScanFailureListener(this.scanFailureListenerId),this.scanFailureListenerId=null),this.isBackgroundScanRunning=!1,this.setStatus(this.enabled?`idle`:`disabled`))}clear(){this.expiresAt=null,this.clearTimeoutOnly(),this.listenerId!==null&&(q.removeEventListener(this.listenerId),this.listenerId=null),this.scanFailureListenerId!==null&&(q.removeScanFailureListener(this.scanFailureListenerId),this.scanFailureListenerId=null),this.isBackgroundScanRunning=!1,this.setStatus(this.enabled?`idle`:`disabled`)}runNow(){if(this.enabled){if(this.expired){this.clearTimeoutOnly();return}this.clearTimeoutOnly(),this.startBackgroundScan()}}resetBudget(){this.expiresAt=null}get expired(){return this.expiresAt!==null&&Date.now()>=this.expiresAt}clearTimeoutOnly(){this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null),this.enabled&&!this.isBackgroundScanRunning&&this.setStatus(`idle`)}async startBackgroundScan(){if(!this.enabled||this.isBackgroundScanRunning||this.listenerId!==null)return;if(this.expired){this.setStatus(`idle`);return}let t=await q.getAvailability();if(t instanceof Error){this.onError(t),this.setStatus(`idle`);return}this.isBackgroundScanRunning=!0,this.setStatus(`scanning`),this.scanFailureListenerId=q.addScanFailureListener(t=>{!this.isBackgroundScanRunning||this.scanFailureListenerId===null||t.listenerId!==this.scanFailureListenerId||(this.consecutiveFailures+=1,this.consecutiveFailures>=e.MAX_CONSECUTIVE_FAILURES&&(this.consecutiveFailures=0,q.resetCurrentAttempt(),this.cleanupListener(),this.schedule()))}),this.listenerId=q.addEventListener(e=>{this.consecutiveFailures=0,this.cleanupListener(),this.onResult(e),this.schedule()},e=>{this.cleanupListener(),this.onError(e),this.schedule()})}cleanupListener(){this.listenerId!==null&&(q.removeEventListener(this.listenerId),this.listenerId=null),this.scanFailureListenerId!==null&&(q.removeScanFailureListener(this.scanFailureListenerId),this.scanFailureListenerId=null),q.stop(),this.isBackgroundScanRunning=!1,this.enabled?this.setStatus(`idle`):this.setStatus(`disabled`)}setStatus(e){this._status!==e&&(this._status=e,this.statusCallbacks.forEach(t=>{try{t(e)}catch(e){console.error(`[VpsBackgroundScanner] Error in status listener`,e)}}))}},Ke=new class extends y{providerId;getName=()=>`Barcode`;availability=()=>P.getAvailability();start(){P.enableBarcodeScanner(),this.providerId=P.addEventListener(e=>e.barcode&&this.notify(e.barcode),this.notifyError)}stop(){P.disableBarcodeScanner(),P.removeEventListener(this.providerId)}},qe=new class extends y{providerId;getName=()=>`CameraNative`;availability=()=>Promise.resolve();start(){P.state!==`stopped`&&this.notify(`started`),this.providerId=P.addMonitoringListener(()=>this.notify(`started`),()=>this.notify(`stopped`))}stop(){P.removeMonitoringListener(this.providerId)}},Je=new class extends y{providerId;getName=()=>`CameraProjectionMatrix`;availability=()=>P.getAvailability();start(){this.providerId=P.addEventListener(e=>e.cameraProjection&&this.notify(e.cameraProjection),this.notifyError)}stop(){P.removeEventListener(this.providerId)}};e.AbsoluteAttitude=c,e.AbsoluteAttitudeFromBrowserProvider=Y,e.AbsoluteAttitudeProvider=X,e.AbsolutePosition=o,e.AbsolutePositionProvider=J,e.AccelerometerProvider=I,e.ArCoreProvider=P,e.AttitudeSmoother=Ve,e.BarcodeProvider=Ke,e.CameraNativeProvider=qe,e.CameraProjectionMatrixProvider=Je,e.Constants=_e,e.GeoRelativePositionFromArCoreProvider=be,e.GeoRelativePositionProvider=H,e.GnssWifiProvider=N,e.GyroscopeProvider=L,e.HighRotationsProvider=z,e.ImageRelocalization=Le,e.ImuProvider=F,e.InclinationFromAccProvider=Ne,e.InclinationFromRelativeAttitudeProvider=U,e.InclinationProvider=W,e.IpProvider=We,e.MagnetometerCalibrationProvider=He,e.MapMatchingHandler=$,e.PdrProvider=je,e.PoleStarProvider=K,e.PositionSmoother=Be,e.ProvidersLoggerOld=_,e.ProvidersOptions=l,e.RelativeAttitude=s,e.RelativeAttitudeFromBrowserProvider=R,e.RelativeAttitudeFromEkfProvider=Ee,e.RelativeAttitudeFromInertialProvider=B,e.RelativeAttitudeProvider=G,e.RelativeRotationCalc=Re,e.StepDetectionMinMaxPeaks2=ke,e.StepDetectionMinMaxPeaks3=Ae,e.StepProvider=V,e.StraightLineProvider=Q,e.TurnProvider=Z,e.VpsBackgroundScanner=Ge,e.VpsMetadata=Pe,e.VpsProvider=q,e.VpsRequest=Fe,e.VpsResponse=Ie});
package/dist/index.js CHANGED
@@ -1919,7 +1919,7 @@ var ke = function(e, t, n) {
1919
1919
  }
1920
1920
  }(), $e = {
1921
1921
  name: "@wemap/providers",
1922
- version: "14.6.1",
1922
+ version: "14.7.1",
1923
1923
  description: "Sensor, positioning and VPS providers for the Wemap SDK.",
1924
1924
  license: "UNLICENSED",
1925
1925
  author: "Wemap SAS",
@@ -1947,13 +1947,13 @@ var ke = function(e, t, n) {
1947
1947
  sideEffects: !1,
1948
1948
  files: ["dist"],
1949
1949
  dependencies: {
1950
- "@wemap/camera": "14.6.1",
1951
- "@wemap/core": "14.6.1",
1952
- "@wemap/geo": "14.6.1",
1953
- "@wemap/maths": "14.6.1",
1954
- "@wemap/osm": "14.6.1",
1955
- "@wemap/routers": "14.6.1",
1956
- "@wemap/utils": "14.6.1"
1950
+ "@wemap/camera": "14.7.1",
1951
+ "@wemap/core": "14.7.1",
1952
+ "@wemap/geo": "14.7.1",
1953
+ "@wemap/maths": "14.7.1",
1954
+ "@wemap/osm": "14.7.1",
1955
+ "@wemap/routers": "14.7.1",
1956
+ "@wemap/utils": "14.7.1"
1957
1957
  },
1958
1958
  devDependencies: {
1959
1959
  "@wemap/logger-legacy": "^13.3.0",
@@ -2097,6 +2097,7 @@ var ke = function(e, t, n) {
2097
2097
  return n.position && (a = o.fromJson(n.position), a.time = r), new e(n.success, i, a);
2098
2098
  }
2099
2099
  }, at = class {
2100
+ static REQUEST_TIMEOUT_MS = 2e4;
2100
2101
  static _prepareRequest(e, t = null, n = null, r = null, i = null) {
2101
2102
  let a = ne(e, 720, 720), o = w.getDeviceFromUserAgent() || {};
2102
2103
  return r && (o.session_id = r.session_id, o.installation_id = r.installation_id, o.attempt_id = r.attempt_id, o.caller = r.caller), new rt(new nt({
@@ -2111,6 +2112,7 @@ var ke = function(e, t, n) {
2111
2112
  l = await fetch(e, {
2112
2113
  method: "POST",
2113
2114
  body: t,
2115
+ signal: AbortSignal.timeout(this.REQUEST_TIMEOUT_MS),
2114
2116
  headers: Object.assign({ Accept: "application/vnd.geopose+json; version=1" }, o || {})
2115
2117
  });
2116
2118
  } catch {
@@ -2221,6 +2223,7 @@ var ke = function(e, t, n) {
2221
2223
  }
2222
2224
  }(), J = new class e extends j {
2223
2225
  static MIN_TIME_BETWEEN_TWO_REQUESTS = 1e3;
2226
+ static DEFAULT_MAX_SCAN_DURATION = 12e4;
2224
2227
  static DEFAULT_MIN_INCLINATION_FOR_REQUEST = m(60);
2225
2228
  static DEFAULT_WAIT_TIME_MIN_INCLINATION_FOR_REQUEST = 200;
2226
2229
  static DEFAULT_USE_COARSE_POSE = !0;
@@ -2242,11 +2245,13 @@ var ke = function(e, t, n) {
2242
2245
  _camera = null;
2243
2246
  _endpoint = null;
2244
2247
  _inclinationProviderId;
2248
+ _maxScanDuration = e.DEFAULT_MAX_SCAN_DURATION;
2245
2249
  _minInclinationForRequest = e.DEFAULT_MIN_INCLINATION_FOR_REQUEST;
2246
2250
  _waitTimeMinInclinationForRequest = e.DEFAULT_WAIT_TIME_MIN_INCLINATION_FOR_REQUEST;
2247
2251
  _useCoarsePose = e.DEFAULT_USE_COARSE_POSE;
2248
2252
  _requestCaller = e.DEFAULT_REQUEST_CALLER;
2249
2253
  _sessionId;
2254
+ _loopId = 0;
2250
2255
  _attemptIdCounter = 0;
2251
2256
  _currentAttemptId = null;
2252
2257
  _scanFailureCallbacks = [];
@@ -2259,7 +2264,7 @@ var ke = function(e, t, n) {
2259
2264
  this._inclinationProviderId = K.addEventListener(), this._relativeRotationCalc = new ot(), T.on("added", this._onCameraDetected), T.on("removed", this._onCameraRemoved), T.list.length && (T.list.length > 1 && A.warn("It seems that more than 1 camera has been detected for VPS. Taking the first..."), this._useCamera(T.list[0].camera));
2260
2265
  }
2261
2266
  stop() {
2262
- K.removeEventListener(this._inclinationProviderId), this._relativeRotationCalc?.release(), T.off("added", this._onCameraDetected), T.off("removed", this._onCameraRemoved), this._camera = null;
2267
+ K.removeEventListener(this._inclinationProviderId), this._relativeRotationCalc?.release(), T.off("added", this._onCameraDetected), T.off("removed", this._onCameraRemoved), this._camera?.off("started", this._internalStart), this._camera?.off("stopped", this._internalStop), this._camera = null;
2263
2268
  }
2264
2269
  _onCameraDetected = ({ camera: e }) => {
2265
2270
  this._camera && A.warn("It seems that more than 1 camera has been detected for VPS. Taking the first..."), this._useCamera(e);
@@ -2275,40 +2280,48 @@ var ke = function(e, t, n) {
2275
2280
  this.notifyError(/* @__PURE__ */ Error("VPS endpoint has not been set before calling start()"));
2276
2281
  return;
2277
2282
  }
2278
- let n = null, r = () => this.state === "stopped";
2279
- for (; !r();) {
2283
+ let n = null, r = ++this._loopId, i = () => this.state === "stopped" || r !== this._loopId, a = this._maxScanDuration > 0 ? C.preciseTime() + this._maxScanDuration : null;
2284
+ for (; !i();) {
2280
2285
  if (n !== null) {
2281
2286
  let t = C.preciseTime() - n, r = Math.max(0, e.MIN_TIME_BETWEEN_TWO_REQUESTS - t);
2282
2287
  await new Promise((e) => setTimeout(e, r));
2283
2288
  }
2284
- if (n = C.preciseTime(), r() || !this._camera || this._camera.state !== "started") break;
2285
- let i = K.lastEvent ? K.lastEvent : null;
2286
- if (i !== null && i < this._minInclinationForRequest) {
2289
+ if (n = C.preciseTime(), i() || !this._camera || this._camera.state !== "started") break;
2290
+ if (a !== null && C.preciseTime() > a) {
2291
+ this.notifyError(/* @__PURE__ */ Error(`VPS scan gave up after ${this._maxScanDuration} ms without a match`));
2292
+ break;
2293
+ }
2294
+ let r = K.lastEvent ? K.lastEvent : null;
2295
+ if (r !== null && r < this._minInclinationForRequest) {
2296
+ await new Promise((e) => setTimeout(e, this._waitTimeMinInclinationForRequest));
2297
+ continue;
2298
+ }
2299
+ if (typeof document < "u" && document.hidden) {
2287
2300
  await new Promise((e) => setTimeout(e, this._waitTimeMinInclinationForRequest));
2288
2301
  continue;
2289
2302
  }
2290
2303
  this._relativeRotationCalc?.tickStart();
2291
- let a = await this._camera.currentImage;
2292
- if (!a) continue;
2293
- let o = null, s = Y.getBestPositionEvent(Ie.lastEvent, ct.lastEvent);
2294
- this._useCoarsePose && (s || X.lastEvent) && (o = {
2295
- ...s && { position: s },
2304
+ let o = await this._camera.currentImage;
2305
+ if (!o) continue;
2306
+ let s = null, c = Y.getBestPositionEvent(Ie.lastEvent, ct.lastEvent);
2307
+ this._useCoarsePose && (c || X.lastEvent) && (s = {
2308
+ ...c && { position: c },
2296
2309
  ...X.lastEvent && { attitude: X.lastEvent }
2297
2310
  }), this._currentAttemptId === null && (this._attemptIdCounter += 1, this._currentAttemptId = this._attemptIdCounter);
2298
- let c = q.lastEvent, l = Qe.lastEvent, d = c && l ? {
2311
+ let l = q.lastEvent, d = Qe.lastEvent, f = l && d ? {
2299
2312
  position: u.rotate(e.ENU_TO_ARCORE_ROT, [
2300
- l.x,
2301
- l.y,
2302
- l.z
2313
+ d.x,
2314
+ d.y,
2315
+ d.z
2303
2316
  ]),
2304
- orientation: u.multiply(e.ENU_TO_ARCORE_ROT, c.quaternion)
2305
- } : null, f = await at.relocalize(this._endpoint, a, null, o, {
2317
+ orientation: u.multiply(e.ENU_TO_ARCORE_ROT, l.quaternion)
2318
+ } : null, p = await at.relocalize(this._endpoint, o, null, s, {
2306
2319
  session_id: this._sessionId,
2307
2320
  installation_id: null,
2308
2321
  ...this._currentAttemptId !== null && { attempt_id: this._currentAttemptId },
2309
2322
  caller: this._requestCaller
2310
- }, d);
2311
- if (!f || !f.success) {
2323
+ }, f);
2324
+ if (!p || !p.success) {
2312
2325
  this._scanFailureCallbacks.forEach(({ id: e, callback: t }) => t({
2313
2326
  listenerId: e,
2314
2327
  sessionId: this._sessionId,
@@ -2317,20 +2330,20 @@ var ke = function(e, t, n) {
2317
2330
  continue;
2318
2331
  }
2319
2332
  this._currentAttemptId = null;
2320
- let p = f.attitude.quaternion, h = u.multiply(p, e.CAMERA_TO_SMARTPHONE_ROT), g = u.multiply(u.fromAxisAngle([
2333
+ let h = p.attitude.quaternion, g = u.multiply(h, e.CAMERA_TO_SMARTPHONE_ROT), _ = u.multiply(u.fromAxisAngle([
2321
2334
  0,
2322
2335
  0,
2323
2336
  1
2324
- ], m(window.orientation || 0)), h), _ = this._relativeRotationCalc?.tickEnd() || new t([
2337
+ ], m(window.orientation || 0)), g), v = this._relativeRotationCalc?.tickEnd() || new t([
2325
2338
  1,
2326
2339
  0,
2327
2340
  0,
2328
2341
  0
2329
- ]), v = new ae(u.multiply(g, _.quaternion), f.attitude.time, f.attitude.accuracy), y = f.position.clone();
2330
- if (y.accuracy === null && (y.accuracy = 5), r()) break;
2342
+ ]), y = new ae(u.multiply(_, v.quaternion), p.attitude.time, p.attitude.accuracy), b = p.position.clone();
2343
+ if (b.accuracy === null && (b.accuracy = 5), i()) break;
2331
2344
  this.notify({
2332
- absoluteAttitude: v,
2333
- absolutePosition: y
2345
+ absoluteAttitude: y,
2346
+ absolutePosition: b
2334
2347
  });
2335
2348
  }
2336
2349
  };
@@ -2360,6 +2373,12 @@ var ke = function(e, t, n) {
2360
2373
  set endpoint(e) {
2361
2374
  this._endpoint = e;
2362
2375
  }
2376
+ get maxScanDuration() {
2377
+ return this._maxScanDuration;
2378
+ }
2379
+ set maxScanDuration(e) {
2380
+ this._maxScanDuration = e;
2381
+ }
2363
2382
  get minInclinationForRequest() {
2364
2383
  return this._minInclinationForRequest;
2365
2384
  }
@@ -2724,7 +2743,7 @@ var ke = function(e, t, n) {
2724
2743
  static DEFAULT_MM_MAX_ANGLE = m(30);
2725
2744
  static DEFAULT_MM_MAX_DIST = 30;
2726
2745
  static DEFAULT_USE_ITINERARY_START_AS_POSITION = !1;
2727
- static DEFAULT_USE_ORIENTATION_MATCHING = !0;
2746
+ static DEFAULT_USE_ORIENTATION_MATCHING = !1;
2728
2747
  static DEFAULT_MM_HUGE_JUMP_DISTANCE = 3;
2729
2748
  static DEFAULT_DISABLE_MM_CLOSE_TO_A_TURN_DISTANCE = 2;
2730
2749
  static DEFAULT_MIN_STEPS_BETWEEN_ORIENTATION_MATCHING = 3;
@@ -3041,6 +3060,8 @@ var ke = function(e, t, n) {
3041
3060
  }(), ht = class e {
3042
3061
  static MAX_CONSECUTIVE_FAILURES = 10;
3043
3062
  intervalMs;
3063
+ maxDurationMs;
3064
+ expiresAt = null;
3044
3065
  enabled;
3045
3066
  timeoutId = null;
3046
3067
  listenerId = null;
@@ -3052,7 +3073,7 @@ var ke = function(e, t, n) {
3052
3073
  onResult;
3053
3074
  onError;
3054
3075
  constructor(e, t, n) {
3055
- this.onResult = t, this.onError = n, this.intervalMs = e.intervalMs ?? 3e4, this.enabled = e.enabled ?? !1, this._status = this.enabled ? "idle" : "disabled";
3076
+ this.onResult = t, this.onError = n, this.intervalMs = e.intervalMs ?? 3e4, this.maxDurationMs = e.maxDurationMs ?? 30 * 6e4, this.enabled = e.enabled ?? !1, this._status = this.enabled ? "idle" : "disabled";
3056
3077
  }
3057
3078
  get status() {
3058
3079
  return this._status;
@@ -3069,24 +3090,46 @@ var ke = function(e, t, n) {
3069
3090
  this.statusCallbacks.delete(e);
3070
3091
  }
3071
3092
  schedule() {
3072
- this.enabled && (this.clearTimeoutOnly(), this.timeoutId = setTimeout(() => {
3073
- this.timeoutId = null, this.startBackgroundScan();
3074
- }, this.intervalMs), this.setStatus("scheduled"));
3093
+ if (this.enabled) {
3094
+ if (this.maxDurationMs > 0 && this.expiresAt === null && (this.expiresAt = Date.now() + this.maxDurationMs), this.expired) {
3095
+ this.clearTimeoutOnly();
3096
+ return;
3097
+ }
3098
+ this.clearTimeoutOnly(), this.timeoutId = setTimeout(() => {
3099
+ this.timeoutId = null, this.startBackgroundScan();
3100
+ }, this.intervalMs), this.setStatus("scheduled");
3101
+ }
3075
3102
  }
3076
3103
  async cancelRunningScan() {
3077
3104
  this.isBackgroundScanRunning && (this.listenerId !== null && (J.removeEventListener(this.listenerId), this.listenerId = null, J.stop()), this.scanFailureListenerId !== null && (J.removeScanFailureListener(this.scanFailureListenerId), this.scanFailureListenerId = null), this.isBackgroundScanRunning = !1, this.setStatus(this.enabled ? "idle" : "disabled"));
3078
3105
  }
3079
3106
  clear() {
3080
- this.clearTimeoutOnly(), this.listenerId !== null && (J.removeEventListener(this.listenerId), this.listenerId = null), this.scanFailureListenerId !== null && (J.removeScanFailureListener(this.scanFailureListenerId), this.scanFailureListenerId = null), this.isBackgroundScanRunning = !1, this.setStatus(this.enabled ? "idle" : "disabled");
3107
+ this.expiresAt = null, this.clearTimeoutOnly(), this.listenerId !== null && (J.removeEventListener(this.listenerId), this.listenerId = null), this.scanFailureListenerId !== null && (J.removeScanFailureListener(this.scanFailureListenerId), this.scanFailureListenerId = null), this.isBackgroundScanRunning = !1, this.setStatus(this.enabled ? "idle" : "disabled");
3081
3108
  }
3082
3109
  runNow() {
3083
- this.enabled && (this.clearTimeoutOnly(), this.startBackgroundScan());
3110
+ if (this.enabled) {
3111
+ if (this.expired) {
3112
+ this.clearTimeoutOnly();
3113
+ return;
3114
+ }
3115
+ this.clearTimeoutOnly(), this.startBackgroundScan();
3116
+ }
3117
+ }
3118
+ resetBudget() {
3119
+ this.expiresAt = null;
3120
+ }
3121
+ get expired() {
3122
+ return this.expiresAt !== null && Date.now() >= this.expiresAt;
3084
3123
  }
3085
3124
  clearTimeoutOnly() {
3086
3125
  this.timeoutId !== null && (clearTimeout(this.timeoutId), this.timeoutId = null), this.enabled && !this.isBackgroundScanRunning && this.setStatus("idle");
3087
3126
  }
3088
3127
  async startBackgroundScan() {
3089
3128
  if (!this.enabled || this.isBackgroundScanRunning || this.listenerId !== null) return;
3129
+ if (this.expired) {
3130
+ this.setStatus("idle");
3131
+ return;
3132
+ }
3090
3133
  let t = await J.getAvailability();
3091
3134
  if (t instanceof Error) {
3092
3135
  this.onError(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;;AAED,wBAAwC"}
@@ -4,6 +4,12 @@ import { CoarsePose, VpsDeviceMetadata } from './VpsMetadata';
4
4
  import { default as VpsRequest, LocalPose } from './VpsRequest';
5
5
  import { default as VpsResponse } from './VpsResponse';
6
6
  declare class ImageRelocalization {
7
+ /**
8
+ * Give up on a `/geopose` call that never answers. Without it a stalled
9
+ * request wedges the scan loop for as long as the browser keeps the socket
10
+ * open, and the camera stays on behind it.
11
+ */
12
+ static REQUEST_TIMEOUT_MS: number;
7
13
  static _prepareRequest(imageCanvas: HTMLCanvasElement, calibration?: Calibration | null, coarsePose?: CoarsePose | null, deviceMetadata?: Pick<VpsDeviceMetadata, 'session_id' | 'installation_id' | 'attempt_id' | 'caller'> | null, localPose?: LocalPose | null): VpsRequest;
8
14
  static relocalize(endpointUrl: string, imageCanvas: HTMLCanvasElement, calibration?: Calibration | null, coarsePose?: CoarsePose | null, deviceMetadata?: Pick<VpsDeviceMetadata, 'session_id' | 'installation_id' | 'attempt_id' | 'caller'> | null, localPose?: LocalPose | null, customHeaders?: Record<string, string> | null): Promise<VpsResponse | null>;
9
15
  static getHeadingFromQuaternion(quaternion: Quaternion_t): number;
@@ -1 +1 @@
1
- {"version":3,"file":"ImageRelocalization.d.ts","sourceRoot":"","sources":["../../../../../src/providers/vision/vps/ImageRelocalization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAmB,MAAM,eAAe,CAAC;AAElE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAoB,EAAE,KAAK,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAErF,OAAO,UAAU,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,cAAM,mBAAmB;IAErB,MAAM,CAAC,eAAe,CAClB,WAAW,EAAE,iBAAiB,EAC9B,WAAW,GAAE,WAAW,GAAG,IAAW,EACt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,EAAE,YAAY,GAAG,iBAAiB,GAAG,YAAY,GAAG,QAAQ,CAAC,GAAG,IAAW,EACjH,SAAS,GAAE,SAAS,GAAG,IAAW;WAuBzB,UAAU,CACnB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,iBAAiB,EAC9B,WAAW,GAAE,WAAW,GAAG,IAAW,EACtC,UAAU,GAAE,UAAU,GAAG,IAAW,EACpC,cAAc,GAAE,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,iBAAiB,GAAG,YAAY,GAAG,QAAQ,CAAC,GAAG,IAAW,EACjH,SAAS,GAAE,SAAS,GAAG,IAAW,EAClC,aAAa,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAW;IA8CvD,MAAM,CAAC,wBAAwB,CAAC,UAAU,EAAE,YAAY;CAmB3D;AAED,eAAe,mBAAmB,CAAC"}
@@ -25,6 +25,16 @@ export interface VpsBackgroundScanOptions {
25
25
  intervalMs?: number;
26
26
  /** Whether the background scanner is enabled (default: false). */
27
27
  enabled?: boolean;
28
+ /**
29
+ * How long background scanning may keep running on its own before it stops and
30
+ * waits for the user (default: 30 minutes; `0` removes the limit).
31
+ *
32
+ * Nothing else bounds it: a page left open scans, fails, reschedules and scans
33
+ * again for as long as the tab lives. Once it is spent the scanner reports
34
+ * `'idle'` and stays there; {@link resetBudget} re-arms it, and consumers are
35
+ * expected to call it on a user-initiated scan.
36
+ */
37
+ maxDurationMs?: number;
28
38
  }
29
39
  /**
30
40
  * A small state machine around {@link VpsProvider} that can:
@@ -39,6 +49,8 @@ export interface VpsBackgroundScanOptions {
39
49
  export declare class VpsBackgroundScanner {
40
50
  private static readonly MAX_CONSECUTIVE_FAILURES;
41
51
  private readonly intervalMs;
52
+ private readonly maxDurationMs;
53
+ private expiresAt;
42
54
  private enabled;
43
55
  private timeoutId;
44
56
  private listenerId;
@@ -96,6 +108,15 @@ export declare class VpsBackgroundScanner {
96
108
  * callbacks provided to the constructor.
97
109
  */
98
110
  runNow(): void;
111
+ /**
112
+ * Re-arm the time budget.
113
+ *
114
+ * Call it whenever the user asks for a scan themselves: the budget exists to
115
+ * stop scanning for someone who walked away, not for someone still using the app.
116
+ */
117
+ resetBudget(): void;
118
+ /** Whether background scanning has used up its time budget. */
119
+ private get expired();
99
120
  private clearTimeoutOnly;
100
121
  private startBackgroundScan;
101
122
  private cleanupListener;
@@ -1 +1 @@
1
- {"version":3,"file":"VpsBackgroundScanner.d.ts","sourceRoot":"","sources":["../../../../../src/providers/vision/vps/VpsBackgroundScanner.ts"],"names":[],"mappings":"AAAA,OAAoB,EAAE,KAAK,QAAQ,EAA4B,MAAM,eAAe,CAAC;AAErF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,uBAAuB,GAAG,UAAU,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,CAAC;AAErF;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,sFAAsF;IACtF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kEAAkE;IAClE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;GASG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAAM;IAEtD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,SAAS,CAA8C;IAC/D,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,qBAAqB,CAAuB;IACpD,OAAO,CAAC,uBAAuB,CAAS;IACxC,OAAO,CAAC,mBAAmB,CAAK;IAChC,OAAO,CAAC,OAAO,CAA0B;IACzC,OAAO,CAAC,eAAe,CAAwD;IAE/E,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA4B;IACrD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;IAEjD;;;;OAIG;gBACS,OAAO,EAAE,wBAAwB,EAAE,QAAQ,EAAE,CAAC,KAAK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AmDjC,OAAO,CAAC,eAAe;IAkBvB,OAAO,CAAC,SAAS;CAclB"}
@@ -13,6 +13,12 @@ export type VpsScanFailureEvent = {
13
13
  };
14
14
  declare class VpsProvider extends Provider<VpsEvent> {
15
15
  static MIN_TIME_BETWEEN_TWO_REQUESTS: number;
16
+ /**
17
+ * How long a single scan may keep hitting `/geopose` before giving up, in ms.
18
+ * A scan nobody is watching (a tab left open on a desk) otherwise requests
19
+ * once a second forever. `0` disables the limit.
20
+ */
21
+ static DEFAULT_MAX_SCAN_DURATION: number;
16
22
  static DEFAULT_MIN_INCLINATION_FOR_REQUEST: number;
17
23
  static DEFAULT_WAIT_TIME_MIN_INCLINATION_FOR_REQUEST: number;
18
24
  static DEFAULT_USE_COARSE_POSE: boolean;
@@ -26,11 +32,13 @@ declare class VpsProvider extends Provider<VpsEvent> {
26
32
  _camera: Camera | null;
27
33
  _endpoint: string | null;
28
34
  _inclinationProviderId?: number;
35
+ _maxScanDuration: number;
29
36
  _minInclinationForRequest: number;
30
37
  _waitTimeMinInclinationForRequest: number;
31
38
  _useCoarsePose: boolean;
32
39
  _requestCaller: string;
33
40
  _sessionId: string;
41
+ _loopId: number;
34
42
  _attemptIdCounter: number;
35
43
  _currentAttemptId: number | null;
36
44
  _scanFailureCallbacks: {
@@ -55,6 +63,8 @@ declare class VpsProvider extends Provider<VpsEvent> {
55
63
  resetCurrentAttempt(): void;
56
64
  get endpoint(): string | null;
57
65
  set endpoint(endpoint: string | null);
66
+ get maxScanDuration(): number;
67
+ set maxScanDuration(maxScanDuration: number);
58
68
  get minInclinationForRequest(): number;
59
69
  set minInclinationForRequest(minInclinationForRequest: number);
60
70
  get waitTimeMinInclinationForRequest(): number;
@@ -1 +1 @@
1
- {"version":3,"file":"VpsProvider.d.ts","sourceRoot":"","sources":["../../../../../src/providers/vision/vps/VpsProvider.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,MAAM,EAAE,MAAM,eAAe,CAAC;AAOtD,OAAO,QAAQ,MAA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Aa,aAEZ;IAED,aAAa;IAab,sBAAsB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI;IAMrE,yBAAyB,CAAC,UAAU,EAAE,MAAM;IAI5C,mBAAmB;IAInB,IAAI,QAAQ,kBAEX;IAED,IAAI,QAAQ,CAAC,QAAQ,eAAA,EAEpB;IAED,IAAI,eAAe,WAElB;IAED,IAAI,eAAe,CAAC,eAAe,QAAA,EAElC;IAED,IAAI,wBAAwB,WAE3B;IAED,IAAI,wBAAwB,CAAC,wBAAwB,QAAA,EAEpD;IAED,IAAI,gCAAgC,WAEnC;IAED,IAAI,gCAAgC,CAAC,gCAAgC,QAAA,EAEpE;IAED,IAAI,aAAa,YAEhB;IAED,IAAI,aAAa,CAAC,aAAa,SAAA,EAE9B;IAED,IAAI,aAAa,WAEhB;IAED,IAAI,aAAa,CAAC,aAAa,QAAA,EAE9B;CACJ;;AAED,wBAAiC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wemap/providers",
3
- "version": "14.7.0",
3
+ "version": "14.8.0-beta.0",
4
4
  "description": "Sensor, positioning and VPS providers for the Wemap SDK.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "Wemap SAS",
@@ -36,13 +36,13 @@
36
36
  "dist"
37
37
  ],
38
38
  "dependencies": {
39
- "@wemap/camera": "14.7.0",
40
- "@wemap/core": "14.7.0",
41
- "@wemap/geo": "14.7.0",
42
- "@wemap/maths": "14.7.0",
43
- "@wemap/osm": "14.7.0",
44
- "@wemap/routers": "14.7.0",
45
- "@wemap/utils": "14.7.0"
39
+ "@wemap/camera": "14.8.0-beta.0",
40
+ "@wemap/core": "14.8.0-beta.0",
41
+ "@wemap/geo": "14.8.0-beta.0",
42
+ "@wemap/maths": "14.8.0-beta.0",
43
+ "@wemap/osm": "14.8.0-beta.0",
44
+ "@wemap/routers": "14.8.0-beta.0",
45
+ "@wemap/utils": "14.8.0-beta.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@wemap/logger-legacy": "^13.3.0",