Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lighthouse/common

Package Overview
Dependencies
Maintainers
6
Versions
461
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lighthouse/common - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

2

dist/lighthouse-common.js

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("lodash"),require("bluebird"),require("moment"),require("moment-timezone"),require("fetch-ponyfill")):"function"==typeof define&&define.amd?define(["lodash","bluebird","moment","moment-timezone","fetch-ponyfill"],e):"object"==typeof exports?exports["lighthouse-common"]=e(require("lodash"),require("bluebird"),require("moment"),require("moment-timezone"),require("fetch-ponyfill")):t["lighthouse-common"]=e(t._,t.bluebird,t.moment,t["moment-timezone"],t["fetch-ponyfill"])}(window,function(t,e,n,r,o){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.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 o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));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=5)}([function(e,n){e.exports=t},function(t,n){t.exports=e},function(t,e){t.exports=n},function(t,e){t.exports=r},function(t,e){t.exports=o},function(t,e,n){"use strict";n.r(e);var r=3,o=[60,110,60,80],i="portrait",a="A4",u="Lighthouse.io",l="https://s3.amazonaws.com/assets-lighthouse-io/img/logo-medium.png",c=n(0),s=n(1),d=n.n(s);function f(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}function b(t){var e=[],n=[];return Object(c.reduce)(t,function(t,e){var n=e.groupActualScore,r=e.groupMaximumScore,o=e.items,i=e.title,a=[[{text:"Group Score",bold:!0},n+"/"+r]],u=Z(i,{style:"h3"}),l={style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}},s=V({body:a,margin:[0,0,0,0]}),b=[[{text:"Question",bold:!0},{text:"Score",bold:!0},{text:"Attachments",bold:!0},{text:"Comments",bold:!0}]];Object(c.each)(o,function(e){var n=e.assetCount,r=e.assets,o=e.comments,a=void 0===o?"":o,u=e.label,l=void 0===u?"":u,s=e.scoreLabel,m=void 0===s?"":s;if(b.push([l,m,n,a]),!Object(c.isEmpty)(r)){var h=Object(c.map)(r,function(t){return L(t.assetUrl)}),y=d.a.all(h).then(function(t){var e=Z(i,{style:"h3"}),n={style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}},o=q(Object(c.map)(t,function(t,e){var n=r[e];return{alignment:"center",fit:[150,150],image:t,link:n&&n.assetUrl}}));return[e].concat(f(o),[n])});t.imageContentPromises.push(y)}});var m=Y({body:b,margin:[0,0,0,0],widths:[130,"*","*","*"]});return t.details.push([u,l,m,l,s,l]),t},{details:e,imageContentPromises:n}),d.a.all(n).then(function(t){if(Object(c.isEmpty)(t))return{details:e};var n=[Z("Photos",{pageBreak:"before",style:"h2"}),{style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}}].concat(f(t));return{details:e,photos:n}})}function m(t,e){var n=e.awsS3BaseUrl,r=e.cloudinaryBaseUrl,o=e.height,i=e.width,a=[],u="";return i&&a.push("w_"+i.toString()),o&&a.push("h_"+o.toString()),a.length>0&&(u=a.join(",")+"/"),r+"/"+u+n+"/"+t}function h(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}function y(t,e){var n=e.settings,r=(n=void 0===n?{}:n).awsS3BaseUrl,o=n.cloudinaryBaseUrl,i=[],a=[];Object(c.reduce)(t,function(t,e){var n=Z(e.label,{style:"h3"}),i={style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}},a=Object(c.chain)(e.fieldGroups).map(function(e){var n=Object(c.filter)(e.fields,function(t){return"list"===t.fieldtype&&"media"===t.options.type&&t.value.length>0});Object(c.each)(n,function(e){Object(c.each)(e.value,function(e){var n=m(e,{awsS3BaseUrl:r,cloudinaryBaseUrl:o,width:800});t.images.push(n)})});var i=Object(c.filter)(e.fields,function(t){return"list"!==t.fieldtype});return Object(c.isEmpty)(i)?[]:[V({body:Object(c.map)(i,function(t){var e=t.label,n=H(t.value);return[e,Object(c.isArray)(n)?Object(c.join)(n,", "):function(t){return Object(c.startsWith)(t,"data:image/png;")}(n)?{alignment:"left",image:n,width:140}:n]})})]}).flattenDeep().compact().value();if(!Object(c.isEmpty)(a))return t.details.push([n,i].concat(h(a))),t},{details:i,images:a});var u=Object(c.map)(a,function(t){return m(t,{awsS3BaseUrl:r,cloudinaryBaseUrl:o})});return d.a.all(u).then(function(t){if(Object(c.isEmpty)(i)||i.unshift(Z("Details",{style:"h2"})),Object(c.isEmpty)(t))return{details:i};var e=Z("Photos",{pageBreak:"before",style:"h2"}),n={style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}},r=q(Object(c.map)(t,function(t,e){return{alignment:"center",fit:[150,150],image:t,link:a[e]}})),o=[e,n].concat(h(r));return{details:i,photos:o}})}var v=n(2),g=n.n(v);function p(t,e){var n=g()().format("D/M/YY");return L(t).then(function(t){return function(r){return{columns:[{fit:[80,30],image:t,margin:[60,20,0,0]},{alignment:"right",text:e+" | "+n+" | Page "+r,style:"small",margin:[0,25,60,0]}]}}})}function x(t){return L(t).then(function(t){return{fit:[130,50],image:t,margin:[60,60,60,0]}})}var O={h1:{fontSize:16,margin:[0,20,0,20],color:"#222"},h2:{fontSize:14,margin:[0,10,0,10],color:"#22"},h3:{fontSize:12,margin:[0,10,0,0],color:"#444"},horizontalLine:{margin:[0,0,0,0],fontSize:1},small:{fontSize:8,bold:!1,color:"#666"},table:{fontSize:8,lineHeight:1.1,color:"#444"}},j=n(4),A=n.n(j)()({Promise:d.a}).fetch;function L(t){return A(t).then(function(e){return e.ok?e.blob():d.a.reject(new Error("Failed to fetch image: "+t))}).then(function(t){return new d.a(function(e,n){var r=new FileReader;r.onloadend=function(){return e(r.result)},r.onerror=n,r.readAsDataURL(t)})})}var T=function(){return function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var a,u=t[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{!r&&u.return&&u.return()}finally{if(o)throw i}}return n}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();function w(t){var e=t.content,n=t.fileTitle,r=t.footer,s=void 0===r?p:r,f=t.header,b=void 0===f?x:f,m=t.logoUrl,h=void 0===m?l:m,y=t.pageMargins,v=void 0===y?o:y,g=t.pageOrientation,j=void 0===g?i:g,A=t.pageSize,L=void 0===A?a:A,w=t.styles,S=void 0===w?{}:w,z=t.title,U=void 0===z?u:z,D=Object(c.defaults)({},S,O),k={title:n},C=[function(t){if(Object(c.isFunction)(t))return d.a.resolve(t());return d.a.resolve(t)}(b(h)),function(t){if(Object(c.isFunction)(t))return d.a.resolve(t());return d.a.resolve(t)}(e),function(t){if(Object(c.isFunction)(t))return d.a.resolve(t());return d.a.resolve(t)}(s(l,U))];return d.a.all(C).then(function(t){var e=T(t,3);return{header:e[0],content:e[1],footer:e[2],info:k,pageMargins:v,pageOrientation:j,pageSize:L,styles:D}})}function S(t,e){return Object(c.isEmpty)(e)?"No users assigned":Object(c.chain)(e).map(function(e){return M(t,e)}).compact().join(", ").value()}function z(t){var e=t.entity,n=t.timezone,r=e.createdAt,o=e.gps,i=e.items,a=e.score,u=G(t),l=Object(c.get)(o,"reverseGeocoded.label","Unknown Location"),s=U(i,t),d=R(t),f=W(a.result),b=F(r,n);return{gpsText:l,groupedData:s,locationText:u,referenceLabel:d.label,referenceValue:d.value,scoreText:f,timezoneDatetime:b}}function U(t,e){var n=e.settings,r=(n=void 0===n?{}:n).awsS3BaseUrl,o=n.cloudinaryBaseUrl,i=Object(c.groupBy)(t,"group.id"),a={overallActualScore:0,overallMaximumScore:0};return a.items=Object(c.map)(i,function(t,e){var n={key:e,groupMaximumScore:0,groupActualScore:0,title:t[0].group.label};return n.items=t.map(function(t,i){var u=t.assets,l=t.comments,s=t.label,d=t.score,f=t.scores,b=t.scoreWeight,h=t.weight,y=Object(c.maxBy)(f,"value").value*h,v=Object(c.find)(f,{value:d});return n.groupMaximumScore+=y,n.groupActualScore+=b,a.overallMaximumScore+=y,a.overallActualScore+=b,{assetCount:u.length,assets:u.map(function(t,n){return{assetUrl:m(t,{awsS3BaseUrl:r,cloudinaryBaseUrl:o,width:800}),key:e+"-item-asset-"+n,thumbnailUrl:m(t,{awsS3BaseUrl:r,cloudinaryBaseUrl:o,width:100})}}),comments:l,key:e+"-item-"+i,label:s,scoreLabel:v?v.label:"Unknown Score"}}),n}),a}function D(t,e,n){return(t[e]||{})[n]}var k=["label","postalcode"];function C(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k;return t?Object(c.chain)(t).pick(e).values().compact().join(", ").value():"Unknown Location"}function E(t){var e=t.entity,n=t.timezone,r=t.users,o=e.assignees,i=e.createdAt,a=e.duration,u=e.gps,l=e.status,s=e.user,d=S(r,o),f=_(g.a.duration(a,"minutes")),b=M(r,s),m=Object(c.get)(u,"reverseGeocoded.label","Unknown Location"),h="closed"===l,y=G(t),v=B(l),p=v.style;return{assigneeNames:d,durationText:f,gpsText:m,fullName:b,isClosedStatus:h,locationText:y,statusStyle:p,statusColor:p.color,statusText:Object(c.upperCase)(v.text),timezoneDatetime:F(i,n)}}n(3);function P(t){var e=t.entity,n=void 0===e?{}:e,r=t.timezone,o=t.users,i=n.assignees,a=n.author,u=n.createdAt,l=n.description,s=void 0===l?"-":l,d=n.due,f=n.geometryReverseGeocoded,b=n.reference,m=void 0===b?"-":b,h=n.status,y=S(o,i),v=M(o,a),p=C(f),x=B(h),O=x.style,j=O.color,A=Object(c.upperCase)(x.text);return{assigneeNames:y,authorFullName:v,createdTimezoneDateTime:F(u,r),description:s,dueDateTimezoneDateTime:F(d,r),locationText:p,statusStyle:O,statusColor:j,statusText:A,reference:m,timezoneAbbrText:g()().tz(r).format("z")}}function G(t){var e=t.entity,n=t.locations,r=void 0===n?{}:n,o=t.zones,i=void 0===o?{}:o,a=e.area,u=e.location,l=e.zone,s=void 0,d=void 0,f=Object(c.get)(a,"label");return u&&(s=Object(c.isString)(u)?D(r,u,"name"):u.name),l&&(d=Object(c.isString)(l)?D(i,l,"name"):l.name),s||d?Object(c.compact)([s,d]).join(", "):f||"Unknown Location"}function _(t){var e=Math.floor(t.asDays()),n=Math.floor(t.asHours()),r=t.hours(),o=t.minutes(),i=t.seconds();return e>0?e+"d "+r+"h":n>0?n+"h "+o+"m":o>0?o+"m":i+"s"}function R(t){var e=t.entity,n=t.users,r=e.user,o="Reference",i="Unknown Reference";r&&(o="User",i=M(n,r));return{label:o,value:i}}var B=Object(c.memoize)(function(t){switch(t){case"closed":return{style:{color:"#D0021B"},text:"Closed"};case"in-progress":return{style:{color:"#00AAE4"},text:"In Progress"};case"open":return{style:{color:"#FF8C2F"},text:"Open"};default:return{style:{color:"#666666"},text:"Unknown"}}});function N(t){var e=t.entity,n=void 0===e?{}:e,r=t.timezone,o=n.createdAt,i=n.gps,a=Object(c.get)(i,"reverseGeocoded.label","Unknown Location"),u=G(t),l=R(t),s=F(o,r);return{locationText:u,gpsText:a,referenceLabel:l.label,referenceValue:l.value,timezoneDatetime:s}}function F(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=g()(t).tz(e),o=r.format("MMM D h:mma"),i=r.format("z");return n?o+" ("+i+")":""+o}function M(t,e){var n=Object(c.find)(t,["user._id",e]).user;return n?n.firstName+" "+n.lastName:"Unknown User"}function W(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return Math.floor(100*t)+"%"}function I(){return{style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}}}function q(t){var e=Object(c.chunk)(t,r);return Object(c.map)(e,function(t){var e=Object(c.fill)(Array(r),{text:""}),n=Object(c.concat)(t,Object(c.slice)(e,t.length));return{table:{body:[[].concat(function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}(n))],widths:[160,160,160]},layout:"noBorders",margin:[0,5,0,5]}})}function H(t){return Object(c.isBoolean)(t)?t?"Yes":"No":Object(c.isObjectLike)(t)&&Object(c.isEmpty)(t)?" - ":t||" - "}function J(t){var e=t.body,n=t.layout,r=void 0===n?"noBorders":n,o=t.margin,i=void 0===o?[0,10,0,20]:o,a=t.widths,u=t.style,l=void 0===u?"table":u;return Object(c.isObject)(l)&&(l=Object(c.defaults)({},l,O.table)),{layout:r,margin:i,style:l,table:{body:e,widths:a,headerRows:1}}}function V(t){return J(Object(c.defaults)({},t,{widths:[130,"*"]}))}function Y(t){return J(Object(c.defaults)({},t,{widths:[130,"*","*","*"]}))}var Q=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};function Z(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Q({text:t=t||"Unknown"},e)}var K=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};function X(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}function $(t,e){var n="Audit Report - "+Object(c.get)(e,"entity.title","Unknown");return function(t){var e=t.entity,n=e.footerFields,r=void 0===n?{}:n,o=e.headerFields,i=void 0===o?{}:o,a=e.title,u=void 0===a?"Unknown":a,l=z(t),s=[[{text:"Title",bold:!0},u],[{text:"Location",bold:!0},l.locationText],[{text:"GPS Location",bold:!0},l.gpsText],[{text:l.referenceLabel,bold:!0},l.referenceValue],[{text:"Created",bold:!0},l.timezoneDatetime],[{text:"Score",bold:!0},l.scoreText]],f=[[{text:"Total Score",bold:!0},l.groupedData.overallActualScore+" / "+l.groupedData.overallMaximumScore]],m=Z("Audit Report",{style:"h2"}),h=V({body:s}),v=Z("Details",{style:"h2"}),g=V({body:f,style:{fontSize:12},margin:[0,20,0,10]}),p={entry:b(l.groupedData.items),footer:y(r.formGroups,t),header:y(i.formGroups,t)};return d.a.props(p).then(function(t){var e=t.entry,n=t.footer,r=t.header,o=e.details,i=void 0===o?[]:o,a=e.photos,u=void 0===a?[]:a,l=n.details,s=void 0===l?[]:l,d=n.photos,f=void 0===d?[]:d,b=r.details,y=void 0===b?[]:b,p=r.photos,x=void 0===p?[]:p;return[m,h,v].concat(X(Object(c.reject)(y,["text","Details"])),X(i),[g],X(Object(c.reject)(s,["text","Details"])),X(x),X(u),X(f))})}(e).then(function(e){return w(K({content:e,fileTitle:n},t))})}var tt=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};function et(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}function nt(t,e){var n="Issue Report - "+Object(c.get)(e,"entity.title","Unknown");return function(t){var e=t.entity,n=t.timezone,r=e.entry,o=e.title,i=e.timeline,a=void 0===i?[]:i,u=E(t),l=Object(c.map)(a,rt),s=[[{text:"Title",bold:!0},o],[{text:"Status",bold:!0},{text:u.statusText,color:u.statusColor}],[{text:"Assignees",bold:!0},u.assigneeNames],[{text:"Location",bold:!0},u.locationText],[{text:"GPS Location",bold:!0},u.gpsText],[{text:"Raised by",bold:!0},u.fullName],[{text:"Created",bold:!0},u.timezoneDatetime]];u.isClosedStatus&&s.push([{text:"Duration",bold:!0},u.durationText]);var d=Object(c.isEmpty)(l)?[["No Timeline data"]]:Object(c.map)(l,function(t){return function(e){var n=e.text,r=e.timestamp,o=F(r,t);return[{text:o,bold:!0},n]}}(n)),f=Z("Issue Report",{style:"h1"}),b=V({body:s}),m=Z("Timeline",{style:"h2"}),h={style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}},v=V({body:d});return y(r.formGroups,t).then(function(t){var e=t.details,n=void 0===e?[]:e,r=t.photos,o=void 0===r?[]:r;return[f,b,m,h,v].concat(et(n),et(o))})}(e).then(function(e){return w(tt({content:e,fileTitle:n},t))})}function rt(t){var e=t._id,n=t.meta,r=void 0===n?{}:n,o=t.timestamp;return{_id:e,text:"status"===r.field?function(t){var e=t.meta,n=t.source,r=t.type,o=Object(c.get)(e,"next"),i=Object(c.get)(n,"meta.firstName"),a=Object(c.get)(n,"meta.lastName"),u=i&&a?i+" "+a:"Unknown User",l="issue-new"===r,s="issue-update"===r,d="open"===o,f=B(o).text;return l&&d?"Issue opened by "+u:l&&!d?"Issue opened with status "+f+" by "+u:s?"Issue updated to "+f+" by "+u:"Unknown status timeline change"}(t):null,timestamp:o}}var ot=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};var it=[{text:"Type",bold:!0},{text:"User",bold:!0},{text:"Start Time",bold:!0},{text:"Start Location",bold:!0},{text:"End Time",bold:!0},{text:"End Location",bold:!0},{text:"Duration",bold:!0}];function at(t,e){var n="Job Report - "+Object(c.get)(e,"entity.title","Unknown"),r=function(t){var e=t.entity.title,n=P(t),r=[[{text:"Location",bold:!0},n.locationText],[{text:"Author",bold:!0},n.authorFullName],[{text:"Reference",bold:!0},n.reference],[{text:"Description",bold:!0},n.description],[{text:"Due Date",bold:!0},n.dueDateTimezoneDateTime],[{text:"Assignees",bold:!0},n.assigneeNames],[{text:"Status",bold:!0},{text:n.statusText,color:n.statusColor}],[{text:"Created",bold:!0},n.createdTimezoneDateTime],[{text:"Timezone",bold:!0},n.timezoneAbbrText]],o=Z("Job Report: "+e,{style:"h1"}),i=V({body:r}),a=Z("Job Activities",{style:"h2"}),u=J(function(t){var e=t.jobActivities,n=t.timezone,r=t.users;if(Object(c.isEmpty)(e))return{body:[["No Job Activities Data"]],widths:"*"};var o=Object(c.map)(e,function(t){var e=t.entity,o=e.type,i=e.duration,a=e.user,u=e.start,l=void 0===u?{}:u,s=e.end,d=void 0===s?{}:s,f=M(r,a),b=g.a.duration(i,"minutes"),m=i?_(b):"-",h=l.time,y=Object(c.get)(l,"geometryReverseGeocoded.label","-"),v=d.time,p=Object(c.get)(d,"geometryReverseGeocoded.label","-"),x=h?F(h,n,!1):"-",O=v?F(v,n,!1):"-";return[o,f,x,y,O,p,m]});return{body:[it].concat(function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}(o)),widths:[70,80,60,"*",60,"*",50]}}(t));return[o,i,a,{style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}},u,{style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}}]}(e);return w(ot({content:r,fileTitle:n,pageOrientation:"landscape"},t))}var ut=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};function lt(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}function ct(t,e){var n="Task Report - "+Object(c.get)(e,"entity.title","Unknown");return function(t){var e=t.entity,n=e.entry,r=e.title,o=N(t),i=[[{text:"Title",bold:!0},r],[{text:"Location",bold:!0},o.locationText],[{text:"GPS Location",bold:!0},o.gpsText],[{text:o.referenceLabel,bold:!0},o.referenceValue],[{text:"Created",bold:!0},o.timezoneDatetime]],a=Z("Task Report",{style:"h1"}),u=V({body:i});return y(n.formGroups,t).then(function(t){var e=t.details,n=void 0===e?[]:e,r=t.photos,o=void 0===r?[]:r;return[a,u].concat(lt(n),lt(o))})}(e).then(function(e){return w(ut({content:e,fileTitle:n},t))})}n.d(e,"DEFAULT_IMAGE_ROW_LENGTH",function(){return r}),n.d(e,"DEFAULT_PAGE_MARGINS",function(){return o}),n.d(e,"DEFAULT_PAGE_ORIENTATION",function(){return i}),n.d(e,"DEFAULT_PAGE_SIZE",function(){return a}),n.d(e,"DEFAULT_TITLE",function(){return u}),n.d(e,"LIGHTHOUSE_LOGO_URL",function(){return l}),n.d(e,"buildAuditContent",function(){return b}),n.d(e,"buildFetchUrl",function(){return m}),n.d(e,"buildTemplateContent",function(){return y}),n.d(e,"defaultFooter",function(){return p}),n.d(e,"defaultHeader",function(){return x}),n.d(e,"defaultStyles",function(){return O}),n.d(e,"fetchImage",function(){return L}),n.d(e,"generateDefinition",function(){return w}),n.d(e,"getAssigneesFullNames",function(){return S}),n.d(e,"getAuditEntryDetails",function(){return z}),n.d(e,"getAuditItemsData",function(){return U}),n.d(e,"getEntityProperty",function(){return D}),n.d(e,"getGeometryGeocodedString",function(){return C}),n.d(e,"getIssueDetails",function(){return E}),n.d(e,"getJobDetails",function(){return P}),n.d(e,"getLocationText",function(){return G}),n.d(e,"getPrettyDuration",function(){return _}),n.d(e,"getReferenceDetails",function(){return R}),n.d(e,"getStatusDetails",function(){return B}),n.d(e,"getTaskEntryDetails",function(){return N}),n.d(e,"getTimezoneDatetime",function(){return F}),n.d(e,"getUserFullName",function(){return M}),n.d(e,"getValueAsPercentage",function(){return W}),n.d(e,"horizontalLine",function(){return I}),n.d(e,"imagesTable",function(){return q}),n.d(e,"parseValue",function(){return H}),n.d(e,"table",function(){return J}),n.d(e,"twoColumnTable",function(){return V}),n.d(e,"fourColumnTable",function(){return Y}),n.d(e,"text",function(){return Z}),n.d(e,"buildAuditPdf",function(){return $}),n.d(e,"buildIssuePdf",function(){return nt}),n.d(e,"buildJobPdf",function(){return at}),n.d(e,"buildTaskPdf",function(){return ct})}])});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("lodash"),require("bluebird"),require("moment"),require("moment-timezone"),require("fetch-ponyfill")):"function"==typeof define&&define.amd?define(["lodash","bluebird","moment","moment-timezone","fetch-ponyfill"],e):"object"==typeof exports?exports["lighthouse-common"]=e(require("lodash"),require("bluebird"),require("moment"),require("moment-timezone"),require("fetch-ponyfill")):t["lighthouse-common"]=e(t._,t.bluebird,t.moment,t["moment-timezone"],t["fetch-ponyfill"])}(window,function(t,e,n,r,o){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.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 o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));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=5)}([function(e,n){e.exports=t},function(t,n){t.exports=e},function(t,e){t.exports=n},function(t,e){t.exports=r},function(t,e){t.exports=o},function(t,e,n){"use strict";n.r(e);var r=3,o=[60,110,60,80],i="portrait",a="A4",u="Lighthouse.io",l="https://s3.amazonaws.com/assets-lighthouse-io/img/logo-medium.png",c=n(0),s=n(1),d=n.n(s);function f(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}function b(t){var e=[],n=[];return Object(c.reduce)(t,function(t,e){var n=e.groupActualScore,r=e.groupMaximumScore,o=e.items,i=e.title,a=[[{text:"Group Score",bold:!0},n+"/"+r]],u=Z(i,{style:"h3"}),l={style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}},s=V({body:a,margin:[0,0,0,0]}),b=[[{text:"Question",bold:!0},{text:"Score",bold:!0},{text:"Attachments",bold:!0},{text:"Comments",bold:!0}]];Object(c.each)(o,function(e){var n=e.assetCount,r=e.assets,o=e.comments,a=void 0===o?"":o,u=e.label,l=void 0===u?"":u,s=e.scoreLabel,m=void 0===s?"":s;if(b.push([l,m,n,a]),!Object(c.isEmpty)(r)){var h=Object(c.map)(r,function(t){return L(t.assetUrl)}),y=d.a.all(h).then(function(t){var e=Z(i,{style:"h3"}),n={style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}},o=q(Object(c.map)(t,function(t,e){var n=r[e];return{alignment:"center",fit:[150,150],image:t,link:n&&n.assetUrl}}));return[e].concat(f(o),[n])});t.imageContentPromises.push(y)}});var m=Y({body:b,margin:[0,0,0,0],widths:[130,"*","*","*"]});return t.details.push([u,l,m,l,s,l]),t},{details:e,imageContentPromises:n}),d.a.all(n).then(function(t){if(Object(c.isEmpty)(t))return{details:e};var n=[Z("Photos",{pageBreak:"before",style:"h2"}),{style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}}].concat(f(t));return{details:e,photos:n}})}function m(t,e){var n=e.awsS3BaseUrl,r=e.cloudinaryBaseUrl,o=e.height,i=e.width,a=[],u="";return i&&a.push("w_"+i.toString()),o&&a.push("h_"+o.toString()),a.length>0&&(u=a.join(",")+"/"),r+"/"+u+n+"/"+t}function h(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}function y(t,e){var n=e.settings,r=(n=void 0===n?{}:n).awsS3BaseUrl,o=n.cloudinaryBaseUrl,i=[],a=[];Object(c.reduce)(t,function(t,e){var n=Z(e.label,{style:"h3"}),i={style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}},a=Object(c.chain)(e.fieldGroups).map(function(e){var n=Object(c.filter)(e.fields,function(t){return"list"===t.fieldtype&&"media"===t.options.type&&t.value.length>0});Object(c.each)(n,function(e){Object(c.each)(e.value,function(e){var n=m(e,{awsS3BaseUrl:r,cloudinaryBaseUrl:o,width:800});t.images.push(n)})});var i=Object(c.filter)(e.fields,function(t){return"list"!==t.fieldtype});return Object(c.isEmpty)(i)?[]:[V({body:Object(c.map)(i,function(t){var e=t.label,n=H(t.value);return[e,Object(c.isArray)(n)?Object(c.join)(n,", "):function(t){return Object(c.startsWith)(t,"data:image/png;")}(n)?{alignment:"left",image:n,width:140}:n]})})]}).flattenDeep().compact().value();if(!Object(c.isEmpty)(a))return t.details.push([n,i].concat(h(a))),t},{details:i,images:a});var u=Object(c.map)(a,function(t){return m(t,{awsS3BaseUrl:r,cloudinaryBaseUrl:o})});return d.a.all(u).then(function(t){if(Object(c.isEmpty)(i)||i.unshift(Z("Details",{style:"h2"})),Object(c.isEmpty)(t))return{details:i};var e=Z("Photos",{pageBreak:"before",style:"h2"}),n={style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}},r=q(Object(c.map)(t,function(t,e){return{alignment:"center",fit:[150,150],image:t,link:a[e]}})),o=[e,n].concat(h(r));return{details:i,photos:o}})}var v=n(2),g=n.n(v);function p(t,e){var n=g()().format("D/M/YY");return L(t).then(function(t){return function(r){return{columns:[{fit:[80,30],image:t,margin:[60,20,0,0]},{alignment:"right",text:e+" | "+n+" | Page "+r,style:"small",margin:[0,25,60,0]}]}}})}function x(t){return L(t).then(function(t){return{fit:[130,50],image:t,margin:[60,60,60,0]}})}var O={h1:{fontSize:16,margin:[0,20,0,20],color:"#222"},h2:{fontSize:14,margin:[0,10,0,10],color:"#22"},h3:{fontSize:12,margin:[0,10,0,0],color:"#444"},horizontalLine:{margin:[0,0,0,0],fontSize:1},small:{fontSize:8,bold:!1,color:"#666"},table:{fontSize:8,lineHeight:1.1,color:"#444"}},j=n(4),A=n.n(j)()({Promise:d.a}).fetch;function L(t){return A(t).then(function(e){return e.ok?e.blob():d.a.reject(new Error("Failed to fetch image: "+t))}).then(function(t){return new d.a(function(e,n){var r=new FileReader;r.onloadend=function(){return e(r.result)},r.onerror=n,r.readAsDataURL(t)})})}var T=function(){return function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var a,u=t[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{!r&&u.return&&u.return()}finally{if(o)throw i}}return n}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();function w(t){var e=t.content,n=t.fileTitle,r=t.footer,s=void 0===r?p:r,f=t.header,b=void 0===f?x:f,m=t.logoUrl,h=void 0===m?l:m,y=t.pageMargins,v=void 0===y?o:y,g=t.pageOrientation,j=void 0===g?i:g,A=t.pageSize,L=void 0===A?a:A,w=t.styles,S=void 0===w?{}:w,z=t.title,U=void 0===z?u:z,D=Object(c.defaults)({},S,O),k={title:n},C=[function(t){if(Object(c.isFunction)(t))return d.a.resolve(t());return d.a.resolve(t)}(b(h)),function(t){if(Object(c.isFunction)(t))return d.a.resolve(t());return d.a.resolve(t)}(e),function(t){if(Object(c.isFunction)(t))return d.a.resolve(t());return d.a.resolve(t)}(s(l,U))];return d.a.all(C).then(function(t){var e=T(t,3);return{header:e[0],content:e[1],footer:e[2],info:k,pageMargins:v,pageOrientation:j,pageSize:L,styles:D}})}function S(t,e){return Object(c.isEmpty)(e)?"No users assigned":Object(c.chain)(e).map(function(e){return M(t,e)}).compact().join(", ").value()}function z(t){var e=t.entity,n=t.timezone,r=e.createdAt,o=e.gps,i=e.items,a=e.score,u=G(t),l=Object(c.get)(o,"reverseGeocoded.label","Unknown Location"),s=U(i,t),d=R(t),f=W(a.result),b=F(r,n);return{gpsText:l,groupedData:s,locationText:u,referenceLabel:d.label,referenceValue:d.value,scoreText:f,timezoneDatetime:b}}function U(t,e){var n=e.settings,r=(n=void 0===n?{}:n).awsS3BaseUrl,o=n.cloudinaryBaseUrl,i=Object(c.groupBy)(t,"group.id"),a={overallActualScore:0,overallMaximumScore:0};return a.items=Object(c.map)(i,function(t,e){var n={key:e,groupMaximumScore:0,groupActualScore:0,title:t[0].group.label};return n.items=t.map(function(t,i){var u=t.assets,l=t.comments,s=t.label,d=t.score,f=t.scores,b=t.scoreWeight,h=t.weight,y=Object(c.maxBy)(f,"value").value*h,v=Object(c.find)(f,{value:d});return n.groupMaximumScore+=y,n.groupActualScore+=b,a.overallMaximumScore+=y,a.overallActualScore+=b,{assetCount:u.length,assets:u.map(function(t,n){return{assetUrl:m(t,{awsS3BaseUrl:r,cloudinaryBaseUrl:o,width:800}),key:e+"-item-asset-"+n,thumbnailUrl:m(t,{awsS3BaseUrl:r,cloudinaryBaseUrl:o,width:100})}}),comments:l,key:e+"-item-"+i,label:s,scoreLabel:v?v.label:"Unknown Score"}}),n}),a}function D(t,e,n){return(t[e]||{})[n]}var k=["label","postalcode"];function C(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k;return t?Object(c.chain)(t).pick(e).values().compact().join(", ").value():"Unknown Location"}function E(t){var e=t.entity,n=t.timezone,r=t.users,o=e.assignees,i=e.createdAt,a=e.duration,u=e.gps,l=e.status,s=e.user,d=S(r,o),f=_(g.a.duration(a,"minutes")),b=M(r,s),m=Object(c.get)(u,"reverseGeocoded.label","Unknown Location"),h="closed"===l,y=G(t),v=B(l),p=v.style;return{assigneeNames:d,durationText:f,gpsText:m,fullName:b,isClosedStatus:h,locationText:y,statusStyle:p,statusColor:p.color,statusText:Object(c.upperCase)(v.text),timezoneDatetime:F(i,n)}}n(3);function P(t){var e=t.entity,n=void 0===e?{}:e,r=t.timezone,o=t.users,i=n.assignees,a=n.author,u=n.createdAt,l=n.description,s=void 0===l?"-":l,d=n.due,f=n.geometryReverseGeocoded,b=n.reference,m=void 0===b?"-":b,h=n.status,y=S(o,i),v=M(o,a),p=C(f),x=B(h),O=x.style,j=O.color,A=Object(c.upperCase)(x.text);return{assigneeNames:y,authorFullName:v,createdTimezoneDateTime:F(u,r),description:s,dueDateTimezoneDateTime:F(d,r),locationText:p,statusStyle:O,statusColor:j,statusText:A,reference:m,timezoneAbbrText:g()().tz(r).format("z")}}function G(t){var e=t.entity,n=t.locations,r=void 0===n?{}:n,o=t.zones,i=void 0===o?{}:o,a=e.area,u=e.location,l=e.zone,s=void 0,d=void 0,f=Object(c.get)(a,"label");return u&&(s=Object(c.isString)(u)?D(r,u,"name"):u.name),l&&(d=Object(c.isString)(l)?D(i,l,"name"):l.name),s||d?Object(c.compact)([s,d]).join(", "):f||"Unknown Location"}function _(t){var e=Math.floor(t.asDays()),n=Math.floor(t.asHours()),r=t.hours(),o=t.minutes(),i=t.seconds();return e>0?e+"d "+r+"h":n>0?n+"h "+o+"m":o>0?o+"m":i+"s"}function R(t){var e=t.entity,n=t.users,r=e.user,o="Reference",i="Unknown Reference";r&&(o="User",i=M(n,r));return{label:o,value:i}}var B=Object(c.memoize)(function(t){switch(t){case"closed":return{style:{color:"#D0021B"},text:"Closed"};case"in-progress":return{style:{color:"#00AAE4"},text:"In Progress"};case"open":return{style:{color:"#FF8C2F"},text:"Open"};default:return{style:{color:"#666666"},text:"Unknown"}}});function N(t){var e=t.entity,n=void 0===e?{}:e,r=t.timezone,o=n.createdAt,i=n.gps,a=Object(c.get)(i,"reverseGeocoded.label","Unknown Location"),u=G(t),l=R(t),s=F(o,r);return{locationText:u,gpsText:a,referenceLabel:l.label,referenceValue:l.value,timezoneDatetime:s}}function F(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=g()(t).tz(e),o=r.format("MMM D h:mma"),i=r.format("z");return n?o+" ("+i+")":""+o}function M(t,e){var n=(Object(c.find)(t,["user._id",e])||{}).user;return n?n.firstName+" "+n.lastName:"Unknown User"}function W(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return Math.floor(100*t)+"%"}function I(){return{style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}}}function q(t){var e=Object(c.chunk)(t,r);return Object(c.map)(e,function(t){var e=Object(c.fill)(Array(r),{text:""}),n=Object(c.concat)(t,Object(c.slice)(e,t.length));return{table:{body:[[].concat(function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}(n))],widths:[160,160,160]},layout:"noBorders",margin:[0,5,0,5]}})}function H(t){return Object(c.isBoolean)(t)?t?"Yes":"No":Object(c.isObjectLike)(t)&&Object(c.isEmpty)(t)?" - ":t||" - "}function J(t){var e=t.body,n=t.layout,r=void 0===n?"noBorders":n,o=t.margin,i=void 0===o?[0,10,0,20]:o,a=t.widths,u=t.style,l=void 0===u?"table":u;return Object(c.isObject)(l)&&(l=Object(c.defaults)({},l,O.table)),{layout:r,margin:i,style:l,table:{body:e,widths:a,headerRows:1}}}function V(t){return J(Object(c.defaults)({},t,{widths:[130,"*"]}))}function Y(t){return J(Object(c.defaults)({},t,{widths:[130,"*","*","*"]}))}var Q=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};function Z(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Q({text:t=t||"Unknown"},e)}var K=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};function X(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}function $(t,e){var n="Audit Report - "+Object(c.get)(e,"entity.title","Unknown");return function(t){var e=t.entity,n=e.footerFields,r=void 0===n?{}:n,o=e.headerFields,i=void 0===o?{}:o,a=e.title,u=void 0===a?"Unknown":a,l=z(t),s=[[{text:"Title",bold:!0},u],[{text:"Location",bold:!0},l.locationText],[{text:"GPS Location",bold:!0},l.gpsText],[{text:l.referenceLabel,bold:!0},l.referenceValue],[{text:"Created",bold:!0},l.timezoneDatetime],[{text:"Score",bold:!0},l.scoreText]],f=[[{text:"Total Score",bold:!0},l.groupedData.overallActualScore+" / "+l.groupedData.overallMaximumScore]],m=Z("Audit Report",{style:"h2"}),h=V({body:s}),v=Z("Details",{style:"h2"}),g=V({body:f,style:{fontSize:12},margin:[0,20,0,10]}),p={entry:b(l.groupedData.items),footer:y(r.formGroups,t),header:y(i.formGroups,t)};return d.a.props(p).then(function(t){var e=t.entry,n=t.footer,r=t.header,o=e.details,i=void 0===o?[]:o,a=e.photos,u=void 0===a?[]:a,l=n.details,s=void 0===l?[]:l,d=n.photos,f=void 0===d?[]:d,b=r.details,y=void 0===b?[]:b,p=r.photos,x=void 0===p?[]:p;return[m,h,v].concat(X(Object(c.reject)(y,["text","Details"])),X(i),[g],X(Object(c.reject)(s,["text","Details"])),X(x),X(u),X(f))})}(e).then(function(e){return w(K({content:e,fileTitle:n},t))})}var tt=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};function et(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}function nt(t,e){var n="Issue Report - "+Object(c.get)(e,"entity.title","Unknown");return function(t){var e=t.entity,n=t.timezone,r=e.entry,o=e.title,i=e.timeline,a=void 0===i?[]:i,u=E(t),l=Object(c.map)(a,rt),s=[[{text:"Title",bold:!0},o],[{text:"Status",bold:!0},{text:u.statusText,color:u.statusColor}],[{text:"Assignees",bold:!0},u.assigneeNames],[{text:"Location",bold:!0},u.locationText],[{text:"GPS Location",bold:!0},u.gpsText],[{text:"Raised by",bold:!0},u.fullName],[{text:"Created",bold:!0},u.timezoneDatetime]];u.isClosedStatus&&s.push([{text:"Duration",bold:!0},u.durationText]);var d=Object(c.isEmpty)(l)?[["No Timeline data"]]:Object(c.map)(l,function(t){return function(e){var n=e.text,r=e.timestamp,o=F(r,t);return[{text:o,bold:!0},n]}}(n)),f=Z("Issue Report",{style:"h1"}),b=V({body:s}),m=Z("Timeline",{style:"h2"}),h={style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}},v=V({body:d});return y(r.formGroups,t).then(function(t){var e=t.details,n=void 0===e?[]:e,r=t.photos,o=void 0===r?[]:r;return[f,b,m,h,v].concat(et(n),et(o))})}(e).then(function(e){return w(tt({content:e,fileTitle:n},t))})}function rt(t){var e=t._id,n=t.meta,r=void 0===n?{}:n,o=t.timestamp;return{_id:e,text:"status"===r.field?function(t){var e=t.meta,n=t.source,r=t.type,o=Object(c.get)(e,"next"),i=Object(c.get)(n,"meta.firstName"),a=Object(c.get)(n,"meta.lastName"),u=i&&a?i+" "+a:"Unknown User",l="issue-new"===r,s="issue-update"===r,d="open"===o,f=B(o).text;return l&&d?"Issue opened by "+u:l&&!d?"Issue opened with status "+f+" by "+u:s?"Issue updated to "+f+" by "+u:"Unknown status timeline change"}(t):null,timestamp:o}}var ot=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};var it=[{text:"Type",bold:!0},{text:"User",bold:!0},{text:"Start Time",bold:!0},{text:"Start Location",bold:!0},{text:"End Time",bold:!0},{text:"End Location",bold:!0},{text:"Duration",bold:!0}];function at(t,e){var n="Job Report - "+Object(c.get)(e,"entity.title","Unknown"),r=function(t){var e=t.entity.title,n=P(t),r=[[{text:"Location",bold:!0},n.locationText],[{text:"Author",bold:!0},n.authorFullName],[{text:"Reference",bold:!0},n.reference],[{text:"Description",bold:!0},n.description],[{text:"Due Date",bold:!0},n.dueDateTimezoneDateTime],[{text:"Assignees",bold:!0},n.assigneeNames],[{text:"Status",bold:!0},{text:n.statusText,color:n.statusColor}],[{text:"Created",bold:!0},n.createdTimezoneDateTime],[{text:"Timezone",bold:!0},n.timezoneAbbrText]],o=Z("Job Report: "+e,{style:"h1"}),i=V({body:r}),a=Z("Job Activities",{style:"h2"}),u=J(function(t){var e=t.jobActivities,n=t.timezone,r=t.users;if(Object(c.isEmpty)(e))return{body:[["No Job Activities Data"]],widths:"*"};var o=Object(c.map)(e,function(t){var e=t.entity,o=e.type,i=e.duration,a=e.user,u=e.start,l=void 0===u?{}:u,s=e.end,d=void 0===s?{}:s,f=M(r,a),b=g.a.duration(i,"minutes"),m=i?_(b):"-",h=l.time,y=Object(c.get)(l,"geometryReverseGeocoded.label","-"),v=d.time,p=Object(c.get)(d,"geometryReverseGeocoded.label","-"),x=h?F(h,n,!1):"-",O=v?F(v,n,!1):"-";return[o,f,x,y,O,p,m]});return{body:[it].concat(function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}(o)),widths:[70,80,60,"*",60,"*",50]}}(t));return[o,i,a,{style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}},u,{style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}}]}(e);return w(ot({content:r,fileTitle:n,pageOrientation:"landscape"},t))}var ut=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};function lt(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}function ct(t,e){var n="Task Report - "+Object(c.get)(e,"entity.title","Unknown");return function(t){var e=t.entity,n=e.entry,r=e.title,o=N(t),i=[[{text:"Title",bold:!0},r],[{text:"Location",bold:!0},o.locationText],[{text:"GPS Location",bold:!0},o.gpsText],[{text:o.referenceLabel,bold:!0},o.referenceValue],[{text:"Created",bold:!0},o.timezoneDatetime]],a=Z("Task Report",{style:"h1"}),u=V({body:i});return y(n.formGroups,t).then(function(t){var e=t.details,n=void 0===e?[]:e,r=t.photos,o=void 0===r?[]:r;return[a,u].concat(lt(n),lt(o))})}(e).then(function(e){return w(ut({content:e,fileTitle:n},t))})}n.d(e,"DEFAULT_IMAGE_ROW_LENGTH",function(){return r}),n.d(e,"DEFAULT_PAGE_MARGINS",function(){return o}),n.d(e,"DEFAULT_PAGE_ORIENTATION",function(){return i}),n.d(e,"DEFAULT_PAGE_SIZE",function(){return a}),n.d(e,"DEFAULT_TITLE",function(){return u}),n.d(e,"LIGHTHOUSE_LOGO_URL",function(){return l}),n.d(e,"buildAuditContent",function(){return b}),n.d(e,"buildFetchUrl",function(){return m}),n.d(e,"buildTemplateContent",function(){return y}),n.d(e,"defaultFooter",function(){return p}),n.d(e,"defaultHeader",function(){return x}),n.d(e,"defaultStyles",function(){return O}),n.d(e,"fetchImage",function(){return L}),n.d(e,"generateDefinition",function(){return w}),n.d(e,"getAssigneesFullNames",function(){return S}),n.d(e,"getAuditEntryDetails",function(){return z}),n.d(e,"getAuditItemsData",function(){return U}),n.d(e,"getEntityProperty",function(){return D}),n.d(e,"getGeometryGeocodedString",function(){return C}),n.d(e,"getIssueDetails",function(){return E}),n.d(e,"getJobDetails",function(){return P}),n.d(e,"getLocationText",function(){return G}),n.d(e,"getPrettyDuration",function(){return _}),n.d(e,"getReferenceDetails",function(){return R}),n.d(e,"getStatusDetails",function(){return B}),n.d(e,"getTaskEntryDetails",function(){return N}),n.d(e,"getTimezoneDatetime",function(){return F}),n.d(e,"getUserFullName",function(){return M}),n.d(e,"getValueAsPercentage",function(){return W}),n.d(e,"horizontalLine",function(){return I}),n.d(e,"imagesTable",function(){return q}),n.d(e,"parseValue",function(){return H}),n.d(e,"table",function(){return J}),n.d(e,"twoColumnTable",function(){return V}),n.d(e,"fourColumnTable",function(){return Y}),n.d(e,"text",function(){return Z}),n.d(e,"buildAuditPdf",function(){return $}),n.d(e,"buildIssuePdf",function(){return nt}),n.d(e,"buildJobPdf",function(){return at}),n.d(e,"buildTaskPdf",function(){return ct})}])});
{
"name": "@lighthouse/common",
"version": "0.1.4",
"version": "0.1.5",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/lighthouse-common.js",

import { find } from 'lodash'
export function getUserFullName(users, userId) {
const applicationUser = find(users, ['user._id', userId])
const applicationUser = find(users, ['user._id', userId]) || {}
const user = applicationUser['user']

@@ -6,0 +6,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc