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.3 to 0.1.4

.circleci/config.yml

2

dist/lighthouse-common.js

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("lodash"),require("moment"),require("bluebird"),require("moment-timezone"),require("fetch-ponyfill")):"function"==typeof define&&define.amd?define(["lodash","moment","bluebird","moment-timezone","fetch-ponyfill"],t):"object"==typeof exports?exports["lighthouse-common"]=t(require("lodash"),require("moment"),require("bluebird"),require("moment-timezone"),require("fetch-ponyfill")):e["lighthouse-common"]=t(e._,e.moment,e.bluebird,e["moment-timezone"],e["fetch-ponyfill"])}(window,function(e,t,n,r,o){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=41)}([function(t,n){t.exports=e},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(39);Object.defineProperty(t,"buildAuditContent",{enumerable:!0,get:function(){return r.buildAuditContent}});var o=n(38);Object.defineProperty(t,"buildFetchUrl",{enumerable:!0,get:function(){return o.buildFetchUrl}});var i=n(37);Object.defineProperty(t,"buildTemplateContent",{enumerable:!0,get:function(){return i.buildTemplateContent}});var u=n(36);Object.defineProperty(t,"defaultFooter",{enumerable:!0,get:function(){return u.defaultFooter}});var a=n(35);Object.defineProperty(t,"defaultHeader",{enumerable:!0,get:function(){return a.defaultHeader}});var l=n(34);Object.defineProperty(t,"defaultStyles",{enumerable:!0,get:function(){return l.defaultStyles}});var s=n(33);Object.defineProperty(t,"fetchImage",{enumerable:!0,get:function(){return s.fetchImage}});var c=n(31);Object.defineProperty(t,"generateDefinition",{enumerable:!0,get:function(){return c.generateDefinition}});var f=n(30);Object.defineProperty(t,"getAssigneesFullNames",{enumerable:!0,get:function(){return f.getAssigneesFullNames}});var d=n(29);Object.defineProperty(t,"getAuditEntryDetails",{enumerable:!0,get:function(){return d.getAuditEntryDetails}});var m=n(28);Object.defineProperty(t,"getAuditItemsData",{enumerable:!0,get:function(){return m.getAuditItemsData}});var b=n(27);Object.defineProperty(t,"getEntityProperty",{enumerable:!0,get:function(){return b.getEntityProperty}});var g=n(26);Object.defineProperty(t,"getGeometryGeocodedString",{enumerable:!0,get:function(){return g.getGeometryGeocodedString}});var p=n(25);Object.defineProperty(t,"getIssueDetails",{enumerable:!0,get:function(){return p.getIssueDetails}});var y=n(24);Object.defineProperty(t,"getJobDetails",{enumerable:!0,get:function(){return y.getJobDetails}});var h=n(23);Object.defineProperty(t,"getLocationText",{enumerable:!0,get:function(){return h.getLocationText}});var v=n(22);Object.defineProperty(t,"getPrettyDuration",{enumerable:!0,get:function(){return v.getPrettyDuration}});var _=n(21);Object.defineProperty(t,"getReferenceDetails",{enumerable:!0,get:function(){return _.getReferenceDetails}});var T=n(20);Object.defineProperty(t,"getStatusDetails",{enumerable:!0,get:function(){return T.getStatusDetails}});var x=n(19);Object.defineProperty(t,"getTaskEntryDetails",{enumerable:!0,get:function(){return x.getTaskEntryDetails}});var O=n(18);Object.defineProperty(t,"getTimezoneDatetime",{enumerable:!0,get:function(){return O.getTimezoneDatetime}});var P=n(17);Object.defineProperty(t,"getUserFullName",{enumerable:!0,get:function(){return P.getUserFullName}});var j=n(16);Object.defineProperty(t,"getValueAsPercentage",{enumerable:!0,get:function(){return j.getValueAsPercentage}});var D=n(15);Object.defineProperty(t,"horizontalLine",{enumerable:!0,get:function(){return D.horizontalLine}});var A=n(14);Object.defineProperty(t,"imagesTable",{enumerable:!0,get:function(){return A.imagesTable}});var L=n(13);Object.defineProperty(t,"parseValue",{enumerable:!0,get:function(){return L.parseValue}});var S=n(12);Object.defineProperty(t,"table",{enumerable:!0,get:function(){return S.table}}),Object.defineProperty(t,"twoColumnTable",{enumerable:!0,get:function(){return S.twoColumnTable}}),Object.defineProperty(t,"fourColumnTable",{enumerable:!0,get:function(){return S.fourColumnTable}});var E=n(11);Object.defineProperty(t,"text",{enumerable:!0,get:function(){return E.text}})},function(e,n){e.exports=t},function(e,t){e.exports=n},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});t.ENVIRONMENT=e.env.ENVIRONMENT||"development",t.AWS_S3_BASE_URL=e.env.AWS_S3_BASE_URL||"https://uploads-test-lighthouse-io.s3.amazonaws.com",t.CLOUDINARY_BASE_URL=e.env.CLOUDINARY_BASE_URL||"https://res.cloudinary.com/lighthouseio/image/fetch",t.DEFAULT_IMAGE_ROW_LENGTH=3,t.DEFAULT_PAGE_MARGINS=[60,110,60,80],t.DEFAULT_PAGE_ORIENTATION="portrait",t.DEFAULT_PAGE_SIZE="A4",t.DEFAULT_TITLE="Lighthouse.io",t.LIGHTHOUSE_LOGO_URL="https://s3.amazonaws.com/assets-lighthouse-io/img/logo-medium.png"}).call(this,n(40))},function(e,t){e.exports=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e};t.buildTaskPdf=function(e,t){const n=`Task Report - ${(0,o.get)(t,"entity.title","Unknown")}`;return function(e){const{entity:t}=e,{entry:n,title:r}=t,o=(0,i.getTaskEntryDetails)(e),u=[[{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=(0,i.text)("Task Report",{style:"h1"}),l=(0,i.twoColumnTable)({body:u});return(0,i.buildTemplateContent)(n.formGroups).then(({details:e=[],photos:t=[]})=>[a,l,...e,...t])}(t).then(t=>(0,i.generateDefinition)(r({content:t,fileTitle:n},e)))};var o=n(0),i=n(1)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e};t.buildJobPdf=function(e,t){const n=`Job Report - ${(0,o.get)(t,"entity.title","Unknown")}`,l=function(e){const{entity:t}=e,{title:n}=t,r=(0,u.getJobDetails)(e),l=[[{text:"Location",bold:!0},r.locationText],[{text:"Author",bold:!0},r.authorFullName],[{text:"Reference",bold:!0},r.reference],[{text:"Description",bold:!0},r.description],[{text:"Due Date",bold:!0},r.dueDateTimezoneDateTime],[{text:"Assignees",bold:!0},r.assigneeNames],[{text:"Status",bold:!0},{text:r.statusText,color:r.statusColor}],[{text:"Created",bold:!0},r.createdTimezoneDateTime],[{text:"Timezone",bold:!0},r.timezoneAbbrText]],s=(0,u.text)(`Job Report: ${n}`,{style:"h1"}),c=(0,u.twoColumnTable)({body:l}),f=(0,u.text)("Job Activities",{style:"h2"}),d=function(e){const{jobActivities:t,timezone:n,users:r}=e;if((0,o.isEmpty)(t))return{body:[["No Job Activities Data"]],widths:"*"};const l=(0,o.map)(t,e=>{const{entity:t}=e,{type:a,duration:l,user:s,start:c={},end:f={}}=t,d=(0,u.getUserFullName)(r,s),m=i.default.duration(l,"minutes"),b=l?(0,u.getPrettyDuration)(m):"-",g=c.time,p=(0,o.get)(c,"geometryReverseGeocoded.label","-"),y=f.time,h=(0,o.get)(f,"geometryReverseGeocoded.label","-"),v=g?(0,u.getTimezoneDatetime)(g,n,!1):"-",_=y?(0,u.getTimezoneDatetime)(y,n,!1):"-";return[a,d,v,p,_,h,b]});return{body:[a,...l],widths:[70,80,60,"*",60,"*",50]}}(e),m=(0,u.table)(d);return[s,c,f,(0,u.horizontalLine)(),m,(0,u.horizontalLine)()]}(t);return(0,u.generateDefinition)(r({content:l,fileTitle:n,pageOrientation:"landscape"},e))};var o=n(0),i=function(e){return e&&e.__esModule?e:{default:e}}(n(2)),u=n(1);const a=[{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(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e};t.buildIssuePdf=function(e,t){const n=`Issue Report - ${(0,o.get)(t,"entity.title","Unknown")}`;return function(e){const{entity:t,timezone:n}=e,{entry:r,title:a,timeline:l=[]}=t,s=(0,i.getIssueDetails)(e),c=(0,o.map)(l,u),f=[[{text:"Title",bold:!0},a],[{text:"Status",bold:!0},{text:s.statusText,color:s.statusColor}],[{text:"Assignees",bold:!0},s.assigneeNames],[{text:"Location",bold:!0},s.locationText],[{text:"GPS Location",bold:!0},s.gpsText],[{text:"Raised by",bold:!0},s.fullName],[{text:"Created",bold:!0},s.timezoneDatetime]];s.isClosedStatus&&f.push([{text:"Duration",bold:!0},s.durationText]);const d=(0,o.isEmpty)(c)?[["No Timeline data"]]:(0,o.map)(c,function(e){return t=>{const{text:n,timestamp:r}=t,o=(0,i.getTimezoneDatetime)(r,e);return[{text:o,bold:!0},n]}}(n)),m=(0,i.text)("Issue Report",{style:"h1"}),b=(0,i.twoColumnTable)({body:f}),g=(0,i.text)("Timeline",{style:"h2"}),p=(0,i.horizontalLine)(),y=(0,i.twoColumnTable)({body:d});return(0,i.buildTemplateContent)(r.formGroups).then(({details:e=[],photos:t=[]})=>[m,b,g,p,y,...e,...t])}(t).then(t=>(0,i.generateDefinition)(r({content:t,fileTitle:n},e)))};var o=n(0),i=n(1);function u(e){const{_id:t,meta:n={},timestamp:r}=e,{field:u}=n;let a;return{_id:t,text:a="status"===u?function(e){const{meta:t,source:n,type:r}=e,u=(0,o.get)(t,"next"),a=(0,o.get)(n,"meta.firstName"),l=(0,o.get)(n,"meta.lastName"),s=a&&l?`${a} ${l}`:"Unknown User",c="issue-new"===r,f="issue-update"===r,d="open"===u,m=(0,i.getStatusDetails)(u).text;return c&&d?`Issue opened by ${s}`:c&&!d?`Issue opened with status ${m} by ${s}`:f?`Issue updated to ${m} by ${s}`:"Unknown status timeline change"}(e):null,timestamp:r}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e};t.buildAuditPdf=function(e,t){const n=`Audit Report - ${(0,o.get)(t,"entity.title","Unknown")}`;return function(e){const{entity:t}=e,{footerFields:n={},headerFields:r={},title:a="Unknown"}=t,l=(0,u.getAuditEntryDetails)(e),s=[[{text:"Title",bold:!0},a],[{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]],c=[[{text:"Total Score",bold:!0},`${l.groupedData.overallActualScore} / ${l.groupedData.overallMaximumScore}`]],f=(0,u.text)("Audit Report",{style:"h2"}),d=(0,u.twoColumnTable)({body:s}),m=(0,u.text)("Details",{style:"h2"}),b=(0,u.twoColumnTable)({body:c,style:{fontSize:12},margin:[0,20,0,10]}),g={entry:(0,u.buildAuditContent)(l.groupedData.items),footer:(0,u.buildTemplateContent)(n.formGroups),header:(0,u.buildTemplateContent)(r.formGroups)};return i.default.props(g).then(({entry:e,footer:t,header:n})=>{const{details:r=[],photos:i=[]}=e,{details:u=[],photos:a=[]}=t,{details:l=[],photos:s=[]}=n;return[f,d,m,...(0,o.reject)(l,["text","Details"]),...r,b,...(0,o.reject)(u,["text","Details"]),...s,...i,...a]})}(t).then(t=>(0,u.generateDefinition)(r({content:t,fileTitle:n},e)))};var o=n(0),i=function(e){return e&&e.__esModule?e:{default:e}}(n(3)),u=n(1)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(9);Object.defineProperty(t,"buildAuditPdf",{enumerable:!0,get:function(){return r.buildAuditPdf}});var o=n(8);Object.defineProperty(t,"buildIssuePdf",{enumerable:!0,get:function(){return o.buildIssuePdf}});var i=n(7);Object.defineProperty(t,"buildJobPdf",{enumerable:!0,get:function(){return i.buildJobPdf}});var u=n(6);Object.defineProperty(t,"buildTaskPdf",{enumerable:!0,get:function(){return u.buildTaskPdf}})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e};t.text=function(e,t={}){return r({text:e=e||"Unknown"},t)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.table=i,t.twoColumnTable=function(e){return i((0,r.defaults)({},e,{widths:[130,"*"]}))},t.fourColumnTable=function(e){return i((0,r.defaults)({},e,{widths:[130,"*","*","*"]}))};var r=n(0),o=n(1);function i(e){const{body:t,layout:n="noBorders",margin:i=[0,10,0,20],widths:u}=e;let{style:a="table"}=e;return(0,r.isObject)(a)&&(a=(0,r.defaults)({},a,o.defaultStyles.table)),{layout:n,margin:i,style:a,table:{body:t,widths:u,headerRows:1}}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseValue=function(e){if((0,r.isBoolean)(e))return e?"Yes":"No";if((0,r.isObjectLike)(e)&&(0,r.isEmpty)(e))return" - ";return e||" - "};var r=n(0)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.imagesTable=function(e){const t=(0,r.chunk)(e,o.DEFAULT_IMAGE_ROW_LENGTH);return(0,r.map)(t,e=>{const t=(0,r.fill)(Array(o.DEFAULT_IMAGE_ROW_LENGTH),{text:""}),n=(0,r.concat)(e,(0,r.slice)(t,e.length));return{table:{body:[[...n]],widths:[160,160,160]},layout:"noBorders",margin:[0,5,0,5]}})};var r=n(0),o=n(4)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.horizontalLine=function(){return{style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:(e,t)=>0===e||e===t.table.body.length?0:.5,vLineWidth:()=>0,hLineColor:()=>"#ddd"}}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getValueAsPercentage=function(e=0){return`${Math.floor(100*e)}%`}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getUserFullName=function(e,t){const n=(0,r.find)(e,["entity.user._id",t]),o=(0,r.get)(n,"entity.user");return o?`${o.firstName} ${o.lastName}`:"Unknown User"};var r=n(0)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getTimezoneDatetime=function(e,t,n=!0){const o=(0,r.default)(e).tz(t),i=o.format("MMM D h:mma"),u=o.format("z");return n?`${i} (${u})`:`${i}`},n(5);var r=function(e){return e&&e.__esModule?e:{default:e}}(n(2))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getTaskEntryDetails=function(e){const{entity:t={},timezone:n}=e,{createdAt:i,gps:u}=t,a=(0,r.get)(u,"reverseGeocoded.label","Unknown Location"),l=(0,o.getLocationText)(e),s=(0,o.getReferenceDetails)(e),c=(0,o.getTimezoneDatetime)(i,n);return{locationText:l,gpsText:a,referenceLabel:s.label,referenceValue:s.value,timezoneDatetime:c}};var r=n(0),o=n(1)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getStatusDetails=void 0;var r=n(0);t.getStatusDetails=(0,r.memoize)(e=>{switch(e){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(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getReferenceDetails=function(e){const{entity:t,users:n}=e,{user:o}=t;let i="Reference",u="Unknown Reference";if(o){const e=(0,r.getUserFullName)(n,o);i="User",u=e}return{label:i,value:u}};var r=n(1)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getPrettyDuration=function(e){const t=Math.floor(e.asDays()),n=Math.floor(e.asHours()),r=e.hours(),o=e.minutes(),i=e.seconds();if(t>0)return`${t}d ${r}h`;if(n>0)return`${n}h ${o}m`;if(o>0)return`${o}m`;return`${i}s`}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getLocationText=function(e){const{entity:t,locations:n=[],zones:i=[]}=e,{area:u,location:a,zone:l}=t;let s,c;const f=(0,r.get)(u,"label");a&&(s=(0,r.isString)(a)?(0,o.getEntityProperty)(n,a,"name"):a.name);l&&(c=(0,r.isString)(l)?(0,o.getEntityProperty)(i,l,"name"):l.name);if(s||c){const e=(0,r.compact)([s,c]);return e.join(", ")}if(f)return f;return"Unknown Location"};var r=n(0),o=n(1)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getJobDetails=function(e){const{entity:t={},timezone:n,users:u}=e,{assignees:a,author:l,createdAt:s,description:c="-",due:f,geometryReverseGeocoded:d,reference:m="-",status:b}=t,g=(0,i.getAssigneesFullNames)(u,a),p=(0,i.getUserFullName)(u,l),y=(0,i.getGeometryGeocodedString)(d),h=(0,i.getStatusDetails)(b),v=h.style,_=v.color,T=(0,r.upperCase)(h.text),x=(0,i.getTimezoneDatetime)(s,n),O=(0,i.getTimezoneDatetime)(f,n),P=(0,o.default)().tz(n).format("z");return{assigneeNames:g,authorFullName:p,createdTimezoneDateTime:x,description:c,dueDateTimezoneDateTime:O,locationText:y,statusStyle:v,statusColor:_,statusText:T,reference:m,timezoneAbbrText:P}},n(5);var r=n(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n(2)),i=n(1)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getIssueDetails=function(e){const{entity:t,timezone:n,users:u}=e,{assignees:a,createdAt:l,duration:s,gps:c,status:f,user:d}=t,m=(0,i.getAssigneesFullNames)(u,a),b=o.default.duration(s,"minutes"),g=(0,i.getPrettyDuration)(b),p=(0,i.getUserFullName)(u,d),y=(0,r.get)(c,"reverseGeocoded.label","Unknown Location"),h="closed"===f,v=(0,i.getLocationText)(e),_=(0,i.getStatusDetails)(f),T=_.style,x=T.color,O=(0,r.upperCase)(_.text),P=(0,i.getTimezoneDatetime)(l,n);return{assigneeNames:m,durationText:g,gpsText:y,fullName:p,isClosedStatus:h,locationText:v,statusStyle:T,statusColor:x,statusText:O,timezoneDatetime:P}};var r=n(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n(2)),i=n(1)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getGeometryGeocodedString=function(e,t=o){return e?(0,r.chain)(e).pick(t).values().compact().join(", ").value():"Unknown Location"};var r=n(0);const o=["label","postalcode"]},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getEntityProperty=function(e,t,n){return((0,r.find)(e,["entity._id",t])||{})[n]};var r=n(0)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getAuditItemsData=function(e){const t=(0,r.groupBy)(e,"group.id"),n={overallActualScore:0,overallMaximumScore:0};return n.items=(0,r.map)(t,(e,t)=>{const i={key:t,groupMaximumScore:0,groupActualScore:0,title:e[0].group.label};return i.items=e.map((e,u)=>{const{assets:a,comments:l,label:s,score:c,scores:f,scoreWeight:d,weight:m}=e,b=(0,r.maxBy)(f,"value").value*m,g=(0,r.find)(f,{value:c});return i.groupMaximumScore+=b,i.groupActualScore+=d,n.overallMaximumScore+=b,n.overallActualScore+=d,{assetCount:a.length,assets:a.map((e,n)=>({assetUrl:(0,o.buildFetchUrl)(e,{width:800}),key:`${t}-item-asset-${n}`,thumbnailUrl:(0,o.buildFetchUrl)(e,{width:100})})),comments:l,key:`${t}-item-${u}`,label:s,scoreLabel:g?g.label:"Unknown Score"}}),i}),n};var r=n(0),o=n(1)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getAuditEntryDetails=function(e){const{entity:t,timezone:n}=e,{createdAt:i,gps:u,items:a,score:l}=t,s=(0,o.getLocationText)(e),c=(0,r.get)(u,"reverseGeocoded.label","Unknown Location"),f=(0,o.getAuditItemsData)(a),d=(0,o.getReferenceDetails)(e),m=(0,o.getValueAsPercentage)(l.result),b=(0,o.getTimezoneDatetime)(i,n);return{gpsText:c,groupedData:f,locationText:s,referenceLabel:d.label,referenceValue:d.value,scoreText:m,timezoneDatetime:b}};var r=n(0),o=n(1)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getAssigneesFullNames=function(e,t){return(0,r.chain)(t).map(t=>(0,o.getUserFullName)(e,t)).compact().join(", ").value()||"No users assigned"};var r=n(0),o=n(1)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.generateDefinition=function(e){const{content:t,fileTitle:n,footer:a=u.defaultFooter,header:l=u.defaultHeader,logoUrl:s=i.LIGHTHOUSE_LOGO_URL,pageMargins:c=i.DEFAULT_PAGE_MARGINS,pageOrientation:f=i.DEFAULT_PAGE_ORIENTATION,pageSize:d=i.DEFAULT_PAGE_SIZE,styles:m={},title:b=i.DEFAULT_TITLE}=e,g=(0,r.defaults)({},m,u.defaultStyles),p={title:n},y=function(e){if((0,r.isFunction)(e))return o.default.resolve(e());return o.default.resolve(e)}(l(s)),h=function(e){if((0,r.isFunction)(e))return o.default.resolve(e());return o.default.resolve(e)}(t),v=function(e){if((0,r.isFunction)(e))return o.default.resolve(e());return o.default.resolve(e)}(a(i.LIGHTHOUSE_LOGO_URL,b)),_=[y,h,v];return o.default.all(_).then(([e,t,n])=>({header:e,content:t,footer:n,info:p,pageMargins:c,pageOrientation:f,pageSize:d,styles:g}))};var r=n(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n(3)),i=n(4),u=n(1)},function(e,t){e.exports=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fetchImage=function(e){return u(e).then(t=>t.ok?t.blob():o.default.reject(new Error(`Failed to fetch image: ${e}`))).then(e=>new o.default((t,n)=>{const r=new FileReader;r.onloadend=(()=>t(r.result)),r.onerror=n,r.readAsDataURL(e)}))};var r=i(n(32)),o=i(n(3));function i(e){return e&&e.__esModule?e:{default:e}}const{fetch:u}=(0,r.default)({Promise:o.default})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.defaultStyles={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"}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultHeader=function(e){return(0,r.fetchImage)(e).then(e=>({fit:[130,50],image:e,margin:[60,60,60,0]}))};var r=n(1)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultFooter=function(e,t){const n=(0,r.default)().format("D/M/YY");return(0,o.fetchImage)(e).then(e=>r=>({columns:[{fit:[80,30],image:e,margin:[60,20,0,0]},{alignment:"right",text:`${t} | ${n} | Page ${r}`,style:"small",margin:[0,25,60,0]}]}))};var r=function(e){return e&&e.__esModule?e:{default:e}}(n(2)),o=n(1)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.buildTemplateContent=function(e){const t=[],n=[];(0,r.reduce)(e,(e,t)=>{const n=(0,i.text)(t.label,{style:"h3"}),o=(0,i.horizontalLine)(),u=(0,r.chain)(t.fieldGroups).map(t=>{const n=(0,r.filter)(t.fields,e=>"list"===e.fieldtype&&"media"===e.options.type&&e.value.length>0);(0,r.each)(n,t=>{(0,r.each)(t.value,t=>{const n=(0,i.buildFetchUrl)(t,{width:800});e.images.push(n)})});const o=(0,r.filter)(t.fields,e=>"list"!==e.fieldtype);if((0,r.isEmpty)(o))return[];const u=(0,r.map)(o,e=>{const{label:t,value:n}=e,o=(0,i.parseValue)(n),u=(0,r.isArray)(o)?(0,r.join)(o,", "):function(e){return(0,r.startsWith)(e,"data:image/png;")}(o)?{alignment:"left",image:o,width:140}:o;return[t,u]}),a=(0,i.twoColumnTable)({body:u});return[a]}).flattenDeep().compact().value();if(!(0,r.isEmpty)(u))return e.details.push([n,o,...u]),e},{details:t,images:n});const u=(0,r.map)(n,e=>(0,i.buildFetchUrl)(e));return o.default.all(u).then(e=>{if((0,r.isEmpty)(t)||t.unshift((0,i.text)("Details",{style:"h2"})),(0,r.isEmpty)(e))return{details:t};const o=(0,i.text)("Photos",{pageBreak:"before",style:"h2"}),u=(0,i.horizontalLine)(),a=(0,r.map)(e,(e,t)=>{const r=n[t];return{alignment:"center",fit:[150,150],image:e,link:r}}),l=(0,i.imagesTable)(a),s=[o,u,...l];return{details:t,photos:s}})};var r=n(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n(3)),i=n(1)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.buildFetchUrl=function(e,{width:t,height:n}){const o=[];let i="";t&&o.push(`w_${t.toString()}`);n&&o.push(`h_${n.toString()}`);o.length>0&&(i=`${o.join(",")}/`);return`${r.CLOUDINARY_BASE_URL}/${i}${r.AWS_S3_BASE_URL}/${e}`};var r=n(4)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.buildAuditContent=function(e){const t=[],n=[];return(0,r.reduce)(e,(e,t)=>{const{groupActualScore:n,groupMaximumScore:u,items:a,title:l}=t,s=[[{text:"Group Score",bold:!0},`${n}/${u}`]],c=(0,i.text)(l,{style:"h3"}),f=(0,i.horizontalLine)(),d=(0,i.twoColumnTable)({body:s,margin:[0,0,0,0]}),m=[[{text:"Question",bold:!0},{text:"Score",bold:!0},{text:"Attachments",bold:!0},{text:"Comments",bold:!0}]];(0,r.each)(a,t=>{const{assetCount:n,assets:u,comments:a="",label:s="",scoreLabel:c=""}=t;if(m.push([s,c,n,a]),(0,r.isEmpty)(u))return;const f=(0,r.map)(u,e=>(0,i.fetchImage)(e.assetUrl)),d=o.default.all(f).then(e=>{const t=(0,i.text)(l,{style:"h3"}),n=(0,i.horizontalLine)(),o=(0,r.map)(e,(e,t)=>{const n=u[t];return{alignment:"center",fit:[150,150],image:e,link:n&&n.assetUrl}});return[t,...(0,i.imagesTable)(o),n]});e.imageContentPromises.push(d)});const b=(0,i.fourColumnTable)({body:m,margin:[0,0,0,0],widths:[130,"*","*","*"]});return e.details.push([c,f,b,f,d,f]),e},{details:t,imageContentPromises:n}),o.default.all(n).then(e=>{if((0,r.isEmpty)(e))return{details:t};const n=[(0,i.text)("Photos",{pageBreak:"before",style:"h2"}),(0,i.horizontalLine)(),...e];return{details:t,photos:n}})};var r=n(0),o=function(e){return e&&e.__esModule?e:{default:e}}(n(3)),i=n(1)},function(e,t){var n,r,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function a(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{r="function"==typeof clearTimeout?clearTimeout:u}catch(e){r=u}}();var l,s=[],c=!1,f=-1;function d(){c&&l&&(c=!1,l.length?s=l.concat(s):f=-1,s.length&&m())}function m(){if(!c){var e=a(d);c=!0;for(var t=s.length;t;){for(l=s,s=[];++f<t;)l&&l[f].run();f=-1,t=s.length}l=null,c=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===u||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function b(e,t){this.fun=e,this.array=t}function g(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];s.push(new b(e,t)),1!==s.length||c||a(m)},b.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=g,o.addListener=g,o.once=g,o.off=g,o.removeListener=g,o.removeAllListeners=g,o.emit=g,o.prependListener=g,o.prependOnceListener=g,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(4);Object.keys(r).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}})});var o=n(1);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})});var i=n(10);Object.keys(i).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})})}])});
!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.3",
"version": "0.1.4",
"description": "",

@@ -9,3 +9,3 @@ "main": "dist/lighthouse-common.js",

"build": "yarn clear && yarn build:es && yarn build:umd",
"build:es": "yarn clear:es && node_modules/.bin/babel src --out-dir lib/ --ignore '**/test*' --source-maps",
"build:es": "yarn clear:es && node_modules/.bin/babel src --out-dir lib/ --ignore '**/fixtures.js,**/test.js' --source-maps",
"build:umd": "yarn clear:umd && node_modules/.bin/webpack-cli --progress",

@@ -20,3 +20,5 @@ "clear": "yarn clear:es && yarn clear:umd",

"preversion": "yarn test",
"test": "echo \"Error: no test specified\" && exit 1",
"test": "node_modules/.bin/jest --config jest.config.json",
"test:coverage": "yarn test --collectCoverage",
"validate:circleci": "circleci config validate -c .circleci/config.yml",
"version": "yarn build"

@@ -38,2 +40,3 @@ },

"babel-eslint": "^8.2.6",
"babel-jest": "^23.4.0",
"babel-loader": "^7.1.4",

@@ -47,2 +50,4 @@ "babel-plugin-transform-object-rest-spread": "^6.26.0",

"husky": "^0.14.3",
"jest": "^23.4.1",
"jest-junit": "^5.1.0",
"lint-staged": "^7.2.0",

@@ -49,0 +54,0 @@ "lodash": "^4.17.10",

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

// build
export const ENVIRONMENT = process.env.ENVIRONMENT || 'development'
// services
export const AWS_S3_BASE_URL =
process.env.AWS_S3_BASE_URL ||
'https://uploads-test-lighthouse-io.s3.amazonaws.com'
export const CLOUDINARY_BASE_URL =
process.env.CLOUDINARY_BASE_URL ||
'https://res.cloudinary.com/lighthouseio/image/fetch'
// pdf

@@ -13,0 +2,0 @@ export const DEFAULT_IMAGE_ROW_LENGTH = 3

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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