{"version":3,"file":"csl-add-accessed.mjs","sources":["../../../lib/citation/plugins/csl-add-accessed.ts"],"sourcesContent":["// @ts-nocheck\n/**\n * Citation-js plugin to add accessed date to CSL object\n */\n\n/**\n * Attaches the current date to the 'accessed' property in a CSL object\n * @param {Array} input the CSL object array\n * @returns a new CSL object with the accessed property attached\n */\nfunction addAccessed(input) {\n  // Get current year, month and day\n  const now = new Date();\n  const year = now.getFullYear();\n  const month = now.getMonth() + 1;\n  const day = now.getDate();\n\n  const accessed = { 'date-parts': [[year, month, day]] };\n\n  // Add accessed property to each CSL object in input\n  return input.map(csl => ({ ...csl, accessed }));\n}\n\nexport default function install(plugins: typeof import('@citation-js/core').plugins) {\n  plugins.input.add('@piveau/list+csl', {\n    parse: addAccessed,\n    parseType: {\n      dataType: 'Array',\n      elementConstraint: '@csl/object',\n      predicate: input => input.some(item => !item.accessed),\n    },\n  });\n}\n"],"names":["addAccessed","input","now","year","month","day","accessed","csl","install","plugins","item"],"mappings":"AAUA,SAASA,EAAYC,GAAO;AAEpB,QAAAC,wBAAU,QACVC,IAAOD,EAAI,eACXE,IAAQF,EAAI,SAAA,IAAa,GACzBG,IAAMH,EAAI,WAEVI,IAAW,EAAE,cAAc,CAAC,CAACH,GAAMC,GAAOC,CAAG,CAAC;AAGpD,SAAOJ,EAAM,IAAI,CAAAM,OAAQ,EAAE,GAAGA,GAAK,UAAAD,EAAW,EAAA;AAChD;AAEA,SAAwBE,EAAQC,GAAqD;AAC3E,EAAAA,EAAA,MAAM,IAAI,oBAAoB;AAAA,IACpC,OAAOT;AAAA,IACP,WAAW;AAAA,MACT,UAAU;AAAA,MACV,mBAAmB;AAAA,MACnB,WAAW,CAASC,MAAAA,EAAM,KAAK,CAAQS,MAAA,CAACA,EAAK,QAAQ;AAAA,IACvD;AAAA,EAAA,CACD;AACH;"}