!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ticketDistanceService=e():(t.ntt=t.ntt||{},t.ntt.smartit=t.ntt.smartit||{},t.ntt.smartit.ticketDistanceService=e())}(window,function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var a=e[r]={i:r,l:!1,exports:{}};return t[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)n.d(r,a,function(e){return t[e]}.bind(null,a));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(t,e,n){t.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var a=e[r]={i:r,l:!1,exports:{}};return t[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)n.d(r,a,function(e){return t[e]}.bind(null,a));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}n.r(e);const a=Symbol.for("SchemaOptions");function o(t){return l(t)&&t.hasOwnProperty("fn")&&t.hasOwnProperty("path")}function i(t){return h(t)}function s(t){return Array.isArray(t)&&t.every(i)}const c=(t,e)=>t.reduce((t,n)=>(M(t,n,f(e,n)),t),{});function u(t){return void 0===t}function l(t){const e=typeof t;return null!=t&&("object"===e||"function"===e)}function h(t){return"string"==typeof t||t instanceof String}function p(t){return"function"==typeof t}function f(t,e){const n=(e=(e=e.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"")).split(".");for(let e=0,r=n.length;e(function(t){for(var e=1;e{this.parseSchema(t,e.toString(),n)}):l(t)&&Object.keys(t).forEach(e=>{this.parseSchema(t[e],e,n)}))}*traverseBFS(){const t=[];for(t.push(this.root);t.length>0;){let e=t.shift();if(!e)return;for(let n=0,r=e.children.length;n{let{object:e}=t;return f(e,n)};if(p(n))return t=>{let{object:e,items:r,objectToCompute:a}=t;return n.call(void 0,e,r,a)};if(s(n))return t=>{let{object:e}=t;return c(n,e)};if(o(n))return t=>{let r,{object:a,items:o,objectToCompute:i}=t;try{let s;Array.isArray(n.path)?s=c(n.path,a):h(n.path)&&(s=f(a,n.path)),r=n.fn.call(void 0,s,a,o,i)}catch(t){throw t.message="Unable to set target property [".concat(e,"].\n \n An error occured when applying [").concat(n.fn.name,"] on property [").concat(n.path,"]\n \n Internal error: ").concat(t.message),t}return r};if(r===b.Property)return null;throw new Error("The action specified for ".concat(e," is not supported."))}}function N(t){return(e,n,r)=>{const a=r.value;return"function"==typeof a&&(r.value=function(){for(var e=arguments.length,n=new Array(e),r=0;rt(e)):t(o)}),r}}function P(t,e,n,r){const a=e.schemaOptions,o=[];for(const a of e.traverseBFS()){const{preparedAction:e,targetPropertyPath:i}=a.data;e&&o.push({targetPropertyPath:i,preparedAction:e({object:t,objectToCompute:r,items:n})})}return o.reduce((t,e)=>{const n=((t,e)=>u(e)?u(t)?void 0:t:e)(f(t,e.targetPropertyPath),e.preparedAction);return void 0===n?(a&&a.undefinedValues&&a.undefinedValues.strip?a.undefinedValues.default&&M(t,e.targetPropertyPath,a.undefinedValues.default(t,e.targetPropertyPath)):M(t,e.targetPropertyPath,n),t):(M(t,e.targetPropertyPath,n),t)},r)}function S(t,e){const n=v.getSchemaOptions(t);let r;if(e&&n.class&&n.class.automapping){const n=function(t,e){let n=Object.keys(new t),r=d(n,n);return Object.assign(r,e)}(e,t);r=new v(n)}else r=new v(t);return function(t){if(!t)return t;if(Array.isArray(t))return t.map(n=>{if(e){const a=new e;return P(n,r,t,a)}return P(n,r,t,{})});{const n=t;if(e){const t=new e;return P(n,r,[n],t)}return P(n,r,[n],{})}}}function O(t,e,n){switch(arguments.length){case 1:return S(t);case 2:return S(t)(e);case 3:if(n)return null!==e?S(t,n)(e):S(t,n);throw new Error("When using morphism(schema, items, type), type should be defined but value received is ".concat(n))}}function R(t,e){return N(S(t,e))}function T(t){return N(S(t))}function j(t,e){return N(S(t,e))}n.d(e,"morph",function(){return R}),n.d(e,"toJSObject",function(){return T}),n.d(e,"toClassObject",function(){return j}),n.d(e,"morphism",function(){return O}),n.d(e,"createSchema",function(){return w}),n.d(e,"Schema",function(){}),n.d(e,"StrictSchema",function(){}),n.d(e,"SchemaOptions",function(){}),n.d(e,"Mapper",function(){}),n.d(e,"SCHEMA_OPTIONS_SYMBOL",function(){return a});const _=new class{constructor(t){this._registry=null,this._registry=t||{cache:new Map}}register(t,e){if(!t&&!e)throw new Error("type paramater is required when you register a mapping");if(this.exists(t))throw new Error("A mapper for ".concat(t.name," has already been registered"));let n;return n=O(e||{},null,t),this._registry.cache.set(t,n),n}map(t,e){if(!this.exists(t)){const n=this.register(t);if(void 0===e)return n}return this.getMapper(t)(e)}getMapper(t){return this._registry.cache.get(t)}setMapper(t,e){if(e){if(this.exists(t)){let n=O(e,null,t);return this._registry.cache.set(t,n),n}throw new Error("The type ".concat(t.name," is not registered. Register it using `Mophism.register(").concat(t.name,", schema)`"))}throw new Error("The schema must be an Object. Found ".concat(e))}deleteMapper(t){return this._registry.cache.delete(t)}exists(t){return this._registry.cache.has(t)}get mappers(){return this._registry.cache}},E=O;E.register=(t,e)=>_.register(t,e),E.map=(t,e)=>_.map(t,e),E.getMapper=t=>_.getMapper(t),E.setMapper=(t,e)=>_.setMapper(t,e),E.deleteMapper=t=>_.deleteMapper(t),E.mappers=_.mappers;const A=E;e.default=A}])},function(t,e,n){"use strict";function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function a(t,e){for(var n=0;n0?m:2*i-m),w=(Math.sin(u-o)>0?2*i-y:y)-h;if(0==Math.sin(b)&&0==Math.sin(w))return null;if(Math.sin(b)*Math.sin(w)<0)return null;const v=-Math.cos(b)*Math.cos(w)+Math.sin(b)*Math.sin(w)*Math.cos(d),N=Math.atan2(Math.sin(d)*Math.sin(b)*Math.sin(w),Math.cos(w)+Math.cos(b)*v),P=Math.asin(Math.min(Math.max(Math.sin(a)*Math.cos(N)+Math.cos(a)*Math.sin(N)*Math.cos(l),-1),1)),S=o+Math.atan2(Math.sin(l)*Math.sin(N)*Math.cos(a),Math.cos(N)-Math.sin(a)*Math.sin(P)),O=P.toDegrees(),R=S.toDegrees();return new s(O,R)}crossTrackDistanceTo(t,e,n=6371e3){t instanceof s||(t=s.parse(t)),e instanceof s||(e=s.parse(e));const r=n;if(this.equals(t))return 0;const a=t.distanceTo(this,r)/r,o=t.initialBearingTo(this).toRadians(),i=t.initialBearingTo(e).toRadians();return Math.asin(Math.sin(a)*Math.sin(o-i))*r}alongTrackDistanceTo(t,e,n=6371e3){t instanceof s||(t=s.parse(t)),e instanceof s||(e=s.parse(e));const r=n;if(this.equals(t))return 0;const a=t.distanceTo(this,r)/r,o=t.initialBearingTo(this).toRadians(),i=t.initialBearingTo(e).toRadians(),c=Math.asin(Math.sin(a)*Math.sin(o-i));return Math.acos(Math.cos(a)/Math.abs(Math.cos(c)))*Math.sign(Math.cos(i-o))*r}maxLatitude(t){const e=Number(t).toRadians(),n=this.lat.toRadians();return Math.acos(Math.abs(Math.sin(e)*Math.cos(n))).toDegrees()}static crossingParallels(t,e,n){if(t.equals(e))return null;const r=Number(n).toRadians(),a=t.lat.toRadians(),i=t.lon.toRadians(),s=e.lat.toRadians(),c=e.lon.toRadians()-i,u=Math.sin(a)*Math.cos(s)*Math.cos(r)*Math.sin(c),l=Math.sin(a)*Math.cos(s)*Math.cos(r)*Math.cos(c)-Math.cos(a)*Math.sin(s)*Math.cos(r),h=Math.cos(a)*Math.cos(s)*Math.sin(r)*Math.sin(c);if(h*h>u*u+l*l)return null;const p=Math.atan2(-l,u),f=Math.acos(h/Math.sqrt(u*u+l*l)),d=i+p+f,M=(i+p-f).toDegrees(),g=d.toDegrees();return{lon1:o.wrap180(M),lon2:o.wrap180(g)}}rhumbDistanceTo(t,e=6371e3){t instanceof s||(t=s.parse(t));const n=e,r=this.lat.toRadians(),a=t.lat.toRadians(),o=a-r;let c=Math.abs(t.lon-this.lon).toRadians();Math.abs(c)>i&&(c=c>0?-(2*i-c):2*i+c);const u=Math.log(Math.tan(a/2+i/4)/Math.tan(r/2+i/4)),l=Math.abs(u)>1e-11?o/u:Math.cos(r);return Math.sqrt(o*o+l*l*c*c)*n}rhumbBearingTo(t){if(t instanceof s||(t=s.parse(t)),this.equals(t))return NaN;const e=this.lat.toRadians(),n=t.lat.toRadians();let r=(t.lon-this.lon).toRadians();Math.abs(r)>i&&(r=r>0?-(2*i-r):2*i+r);const a=Math.log(Math.tan(n/2+i/4)/Math.tan(e/2+i/4)),c=Math.atan2(r,a).toDegrees();return o.wrap360(c)}rhumbDestinationPoint(t,e,n=6371e3){const r=this.lat.toRadians(),a=this.lon.toRadians(),o=Number(e).toRadians(),c=t/n,u=c*Math.cos(o);let l=r+u;Math.abs(l)>i/2&&(l=l>0?i-l:-i-l);const h=Math.log(Math.tan(l/2+i/4)/Math.tan(r/2+i/4)),p=Math.abs(h)>1e-11?u/h:Math.cos(r),f=a+c*Math.sin(o)/p,d=l.toDegrees(),M=f.toDegrees();return new s(d,M)}rhumbMidpointTo(t){t instanceof s||(t=s.parse(t));const e=this.lat.toRadians();let n=this.lon.toRadians();const r=t.lat.toRadians(),a=t.lon.toRadians();Math.abs(a-n)>i&&(n+=2*i);const o=(e+r)/2,c=Math.tan(i/4+e/2),u=Math.tan(i/4+r/2),l=Math.tan(i/4+o/2);let h=((a-n)*Math.log(l)+n*Math.log(u)-a*Math.log(c))/Math.log(u/c);isFinite(h)||(h=(n+a)/2);const p=o.toDegrees(),f=h.toDegrees();return new s(p,f)}static areaOf(t,e=6371e3){const n=e,r=t[0].equals(t[t.length-1]);r||t.push(t[0]);const a=t.length-1;let o=0;for(let e=0;eNumber.EPSILON)&&!(Math.abs(this.lon-t.lon)>Number.EPSILON)}toGeoJSON(){return{type:"Point",coordinates:[this.lon,this.lat]}}toString(t="d",e){if(!["d","dm","dms","n"].includes(t))throw new RangeError(`invalid format ‘${t}’`);if("n"==t)return null==e&&(e=4),`${this.lat.toFixed(e)},${this.lon.toFixed(e)}`;return`${o.toLat(this.lat,t,e)}, ${o.toLon(this.lon,t,e)}`}}function c(t){return t*(180/Math.PI)}function u(t){return t*(Math.PI/180)}var l=n(0);angular.module("myitsmApp").service("nttTicketDistanceService",["nttGenericService","$q","i18nService","ModuleConfigService",function(t,e,n,r){this.getIncidentsByDistance=function(a,o,i,h,p){return e(function(e,f){var d=r.getModuleConfig("ticketDistanceService"),M=function(t,e,n){var r=t+c(n/6371),a=t-c(n/6371),o=e+c(n/6371/Math.cos(u(t))),i=e-c(n/6371/Math.cos(u(t)));return{center:[t,e],nw:[r,i],ne:[r,o],sw:[a,i],se:[a,o]}}(a,o,i),g="'666100011' <= "+M.ne[1]+" && '666100011' >= "+M.nw[1]+" && '666100012' <= "+M.ne[0]+" && '666100012' >= "+M.se[0];d&&d.replaceDotByComma&&(g=g.replace(/\./g,",")),"all"!=p&&("open"==p?g+=" && '7' <= 3":"resolved"==p?g+=" && '7' > 3 && '7' <=5":"cancelled"==p&&(g+=" && '7' == 6")),t.getArEntriesByFormAndQual({form:"HPD:Help Desk",qual:g,fields:[179,666100011,666100012,1e9,1000000161,1000000218,6,7,1000000164,666100003,1000000151,1000000019,1000000018,1000000001]}).$promise.then(function(t){var r={0:"New",1:"Assigned",2:"In Progress",3:"Pending",4:"Resolved",5:"Closed",6:"Cancelled"},c={0:"Critical",1:"High",2:"Medium",3:"Low"},u={id:"179.value",lon:"666100011.value",lat:"666100012.value",title:"1000000000.value",type:function(t){return"incident"},displayId:"1000000161.value",assignee:"1000000218.value",lastModifyDate:function(t){return DayPilot.Date(t[6].value).d},status:function(t){return r[t[7].value]},priority:function(t){return c[t[1000000164].value]},adress:"666100003.value",description:function(t){return{label:n.getLocalizedString("ntt.address.showTicketsNearBy.ticket.desc.label"),value:t[1000000151].value}},custFirstName:"1000000019.value",custLastName:"1000000018.value",contactFirstName:"1000000019.value",contactLastName:"1000000018.value",company:"1000000001.value"},p=Object(l.morphism)(u,t.items.entries);h&&(p=_.reject(p,{id:h})),p=_.sortBy(_.forEach(p,function(t,e){var n,r,i,c,u,l;t.distance=(n=o,r=a,i=t.lon,c=t.lat,u=new s(r,n),l=new s(c,i),u.distanceTo(l))}),"distance"),p=_.reject(p,function(t){return t.distance/1e3>i}),e({incidents:p})},function(t){f(t.data)})})}}])}])});