{"version":3,"sources":["webpack:///./scripts/components/myProfileSummary.js"],"names":["d3","component","momentModule","window","moment","serviceHistoryGraph","document","getElementById","innerWidth","$myProfile","$","$onthispage","$callout","next","length","after","click","userStateManager","getUserProfileData","data","isNullUndefinedEmpty","ProfileInfo","apiProblemOccured","displayErrorMessage","parent","TotalLengthOfService","Tenures","graphData","slice","renderGraph","error","innerHTML","$allHistoryBtn","$allHistoryTable","$allHistoryAccordion","$allIncidentsBtn","$allIncidentsTable","$allIncidentsAccordion","on","e","attr","parents","addClass","removeAttr","totalServiceDays","arc","staticRings","map","item","index","innerRadius","outerRadius","startAngle","endAngle","Math","PI","serviceItemsArcs","xy","percent","LengthOfService","endAngleDegrees","floor","arcPath","indexOf","textCoords","split","coords","x","parseFloat","y","staticRingsHtml","content","getStaticRingHtml","join","serviceHistoryList","querySelector","listHtml","startDate","StartDate","endDateText","EndDate","year","durationRender","duration","humanize","ServiceTypeCode","getServiceHistoryItem","html","serviceHistoryItem","onServiceItemEnter","onServiceItemLeave","handleClickAndTouch","allArcPath","querySelectorAll","highlightServiceItem","highlightArcPath","onArcEnter","onArcLeave","event","historyItems","parseIndex","currentTarget","forEach","element","setAttribute","activeIndex","highlighSelectedItem","seriviceItems","dataIndex","classList","contains","serviceItem","getAttribute"],"mappings":"4JAIIA,E,iJAEG,IAAMC,EAAS,e,EAAA,G,EAAA,yBAAG,uIACM,wDADN,cACfC,EADe,OAErBC,OAAOC,OAASF,EAAY,QAFP,SAIV,+BAJU,OAIrBF,EAJqB,OAMfK,EAAsBC,SAASC,eAAe,yBAGhDJ,OAAOK,WAAa,MACdC,EAAaC,EAAE,eACfC,EAAcD,EAAE,iBAChBE,EAAWH,EAAWI,KAAK,gBAE7BJ,EAAWK,QAAUH,EAAYG,QACjCH,EAAYI,MAAMH,GAAUG,MAAMN,GAItCC,EAAE,6BAA6BM,SAG/BX,IACAY,IAAiBC,oBAAmB,SAAUC,GAC1C,IAAKC,YAAqBD,EAAKE,aAAc,CACzC,GAA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9C,EAAO2C,GAC7BA,EAAW3C,GAAOuD,aAAa,QAAS,mBAI5C,SAASV,EAAqB7C,EAAOkD,GACjCA,EAAalD,GAAOuD,aAAa,QAAS,+BAI9C,SAASJ,EAAWpD,GAChB,OAAOA,EAAKgE,aAAa,aAAc,M","file":"21.766365177200fff18aa7.js","sourcesContent":["import { displayErrorMessage } from '../helpers/displayError';\nimport { isNullUndefinedEmpty } from '../helpers/helpers';\nimport userStateManager from '../helpers/stateManager';\n\nlet d3;\n\nexport const component = async () => {\n const momentModule = await import('moment-mini');\n window.moment = momentModule.default;\n\n d3 = await import('d3-shape');\n\n const serviceHistoryGraph = document.getElementById('service-history-graph');\n\n //move elements if mobile\n if (window.innerWidth < 768) {\n const $myProfile = $('.my-profile');\n const $onthispage = $('.on-this-page');\n const $callout = $myProfile.next('.callout-box');\n\n if ($myProfile.length && $onthispage.length) {\n $onthispage.after($callout).after($myProfile);\n }\n\n //service history should be open by default\n $('.my-profile__heading.-btn').click();\n }\n\n if (serviceHistoryGraph) {\n userStateManager.getUserProfileData(function (data) {\n if (!isNullUndefinedEmpty(data.ProfileInfo)) {\n if (data && data.apiProblemOccured) {\n displayErrorMessage($(serviceHistoryGraph).parent(), true, false);\n return;\n }\n\n if (!isNullUndefinedEmpty(data.ProfileInfo.TotalLengthOfService) && !isNullUndefinedEmpty(data.ProfileInfo.Tenures)) {\n try {\n const graphData = data.ProfileInfo.Tenures.slice(0, 3);\n renderGraph(serviceHistoryGraph, graphData, data.ProfileInfo.TotalLengthOfService);\n } catch (error) {\n console.error('There was an error setting up the service history graph: ', error);\n serviceHistoryGraph.innerHTML = '
There was an issue displaying this graph.
';\n }\n } else {\n }\n }\n });\n\n //Trigger expanding the accordions for anchor CTAs\n const $allHistoryBtn = $('.all-my-service-history-link');\n const $allHistoryTable = $('#my-service-history-table');\n const $allHistoryAccordion = $('#My-Service-History');\n const $allIncidentsBtn = $('.all-my-incidents-link');\n const $allIncidentsTable = $('#my-incidents-table');\n const $allIncidentsAccordion = $('#My-Incidents');\n\n $allHistoryBtn.on('click', function (e) {\n if ($allHistoryAccordion.attr('aria-expanded') === 'false') {\n $allHistoryAccordion.attr('aria-expanded', 'true');\n $allHistoryTable.parents('.collapse').addClass('in').removeAttr('style');\n }\n });\n\n $allIncidentsBtn.on('click', function (e) {\n if ($allIncidentsAccordion.attr('aria-expanded') === 'false') {\n $allIncidentsAccordion.attr('aria-expanded', 'true');\n $allIncidentsTable.parents('.collapse').addClass('in').removeAttr('style');\n }\n });\n }\n};\n\nfunction renderGraph(serviceHistoryGraph, graphData, totalServiceDays) {\n const arc = d3.arc(); // See d3 shapes repo for more details: https://github.com/d3/d3-shape\n\n //The first 3 rings are use for the background, these are full 360 rings and not arcs.\n //Render static bg rings for length of graph data\n var staticRings = graphData.map((item, index) => {\n return arc({\n innerRadius: 60 - index * 25,\n outerRadius: 80 - index * 25,\n startAngle: 0,\n endAngle: Math.PI * 2,\n });\n });\n\n // These arcs corresponds to the (up to three values), starting from the outer ring going down to the most innner.\n var serviceItemsArcs = graphData.map((item, index) => {\n // const startDate = moment(item.StartDate);\n // const endDate = (item.EndDate !== null) ? moment(item.EndDate) : moment();\n // const duration = moment.duration(endDate.diff(startDate)).asDays();\n const percent = item.LengthOfService / totalServiceDays;\n const endAngleDegrees = Math.floor(percent * 360);\n\n // console.log('Duration for this service: ', duration);\n // console.log('Percent for this service: ', percent);\n // console.log('endAngleDegrees for this service: ', endAngleDegrees);\n\n var arcPath = arc({\n innerRadius: 60 - index * 25,\n outerRadius: 80 - index * 25,\n startAngle: 0,\n endAngle: endAngleDegrees * (Math.PI / 180), //Convert degrees to radians\n });\n\n //Set up number label\n if (arcPath.indexOf('L') > 0) {\n const textCoords = arcPath.split('L')[1].split('A')[0]; //Get the position of the last line that closes the arc if it exists\n const coords = parseCoords(textCoords);\n\n return `\n\t\t\t\t