ofsc-utility-browser 1.0.17 → 1.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ export declare function AllFiles(clientId: string, clientSecret: string, instanceUrl: string, date?: string): Promise<any>;
@@ -0,0 +1,20 @@
1
+ import { fetchWithRetry } from "../utilities";
2
+ export async function AllFiles(clientId, clientSecret, instanceUrl, date = "") {
3
+ let apiCallCount = 0;
4
+ const WAIT_AFTER_CALLS = 20;
5
+ const DELAY_MS = 10000;
6
+ const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
7
+ const fetchAllFiles = async () => {
8
+ var _a, _b;
9
+ apiCallCount++;
10
+ if (apiCallCount % WAIT_AFTER_CALLS === 0) {
11
+ console.warn(`Waiting 10 seconds after ${apiCallCount} API calls to avoid rate limits.`);
12
+ await sleep(DELAY_MS);
13
+ }
14
+ const url = `https://${instanceUrl}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/folders/dailyExtract/folders/${date}/files`;
15
+ const res = await fetchWithRetry(url, clientId, clientSecret, instanceUrl, "");
16
+ return (_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.files) === null || _b === void 0 ? void 0 : _b.items;
17
+ ;
18
+ };
19
+ return fetchAllFiles();
20
+ }
@@ -0,0 +1,2 @@
1
+ import { ResourceResponse } from "../types";
2
+ export declare function resourcePositionHistoryRange(clientId: string, clientSecret: string, instanceUrl: string, resourceId: string, fromDate: string, toDate: string, initialToken?: string): Promise<ResourceResponse[]>;
@@ -0,0 +1,89 @@
1
+ import { fetchWithRetry } from "../utilities";
2
+ export async function resourcePositionHistoryRange(clientId, clientSecret, instanceUrl, resourceId, fromDate, toDate, initialToken = "") {
3
+ let apiCallCount = 0;
4
+ const WAIT_AFTER_CALLS = 20;
5
+ const DELAY_MS = 10000;
6
+ const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
7
+ /**
8
+ * Format date as YYYY-MM-DD (LOCAL, no timezone issues)
9
+ */
10
+ const formatDate = (date) => {
11
+ const year = date.getFullYear();
12
+ const month = String(date.getMonth() + 1).padStart(2, "0");
13
+ const day = String(date.getDate()).padStart(2, "0");
14
+ return `${year}-${month}-${day}`;
15
+ };
16
+ /**
17
+ * Generate all dates between fromDate and toDate (inclusive)
18
+ */
19
+ const getDatesInRange = (start, end) => {
20
+ const dates = [];
21
+ let current = new Date(start);
22
+ const last = new Date(end);
23
+ if (current > last) {
24
+ throw new Error("fromDate cannot be greater than toDate");
25
+ }
26
+ while (current <= last) {
27
+ dates.push(formatDate(current));
28
+ current.setDate(current.getDate() + 1);
29
+ }
30
+ return dates;
31
+ };
32
+ /**
33
+ * Fetch paginated data for a single date
34
+ */
35
+ const fetchByDate = async (date, offset, token) => {
36
+ apiCallCount++;
37
+ // Rate limiting protection
38
+ if (apiCallCount % WAIT_AFTER_CALLS === 0) {
39
+ console.warn(`Waiting 10 seconds after ${apiCallCount} API calls...`);
40
+ await sleep(DELAY_MS);
41
+ }
42
+ console.log(`Calling API for date=${date}, offset=${offset}`);
43
+ const url = `https://${instanceUrl}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/${resourceId}/positionHistory/?date=${date}&offset=${offset}&limit=100`;
44
+ const res = await fetchWithRetry(url, clientId, clientSecret, instanceUrl, token);
45
+ token = res.token;
46
+ const { items = [], totalResults = 0 } = res.data || {};
47
+ const totalFetched = (items === null || items === void 0 ? void 0 : items.length) || 0;
48
+ console.log(`[${date}] Received ${totalFetched} items (Total: ${offset + totalFetched}/${totalResults})`);
49
+ // If all data fetched
50
+ if (offset + totalFetched >= totalResults) {
51
+ return { items: items, token: res.token };
52
+ }
53
+ // Fetch next page
54
+ const nextItems = await fetchByDate(date, offset + totalFetched, res.token);
55
+ return { items: [...items, ...nextItems], token: res.token };
56
+ };
57
+ /**
58
+ * MAIN EXECUTION
59
+ */
60
+ const dates = getDatesInRange(fromDate, toDate);
61
+ console.log(`Total dates to process: ${dates.length}`);
62
+ let allResults = [];
63
+ let token = initialToken;
64
+ for (let i = 0; i < dates.length; i++) {
65
+ const date = dates[i];
66
+ console.log(`\nProcessing ${i + 1}/${dates.length}: ${date}`);
67
+ const dailyResults = await fetchByDate(date, 0, token);
68
+ // allResults = [...allResults, ...dailyResults.items];
69
+ allResults = [
70
+ ...allResults,
71
+ ...dailyResults.items.map((item) => {
72
+ const { acc, alt, dir, i, s, spd, ...rest } = item;
73
+ return {
74
+ ResourceId: resourceId,
75
+ "Accuracy of the position in meters": acc,
76
+ Altitude: alt,
77
+ "direction (in degrees) in which the vehicle is headed": dir,
78
+ "Duration of the position": i,
79
+ Status: s,
80
+ Speed: spd,
81
+ ...rest,
82
+ };
83
+ })
84
+ ];
85
+ token = dailyResults.token;
86
+ }
87
+ console.log(`\n✅ Completed. Total records fetched: ${allResults.length}`);
88
+ return allResults;
89
+ }
package/dist/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  import * as Activity from "./activities";
2
+ import * as DailyExtract from "./dailyExtract";
3
+ import * as GPS from "./gps";
2
4
  import * as OauthTokenService from "./oauthTokenService";
3
5
  import * as Resources from "./resources";
4
6
  import * as Users from "./users";
5
7
  import * as Utilities from "./utilities";
6
- export { Activity, OauthTokenService, Resources, Users, Utilities };
8
+ export { Activity, DailyExtract, GPS, OauthTokenService, Resources, Users, Utilities };
7
9
  export * from "./types";
8
10
  declare const _default: {
9
11
  Activity: typeof Activity;
@@ -12,5 +14,7 @@ declare const _default: {
12
14
  Resources: typeof Resources;
13
15
  downloadCSV: (csvData: import("./types").CSVRow[]) => void;
14
16
  Users: typeof Users;
17
+ DailyExtract: typeof DailyExtract;
18
+ GPS: typeof GPS;
15
19
  };
16
20
  export default _default;
package/dist/index.js CHANGED
@@ -1,11 +1,13 @@
1
1
  import * as Activity from "./activities";
2
+ import * as DailyExtract from "./dailyExtract";
3
+ import * as GPS from "./gps";
2
4
  import * as OauthTokenService from "./oauthTokenService";
3
5
  import * as Resources from "./resources";
4
6
  import * as Users from "./users";
5
7
  import * as Utilities from "./utilities";
6
8
  import { downloadCSV } from "./utilities";
7
9
  // Export grouped namespaces
8
- export { Activity, OauthTokenService, Resources, Users, Utilities };
10
+ export { Activity, DailyExtract, GPS, OauthTokenService, Resources, Users, Utilities };
9
11
  // Export types
10
12
  export * from "./types";
11
13
  // Default export (for convenience)
@@ -15,5 +17,7 @@ export default {
15
17
  Utilities,
16
18
  Resources,
17
19
  downloadCSV,
18
- Users
20
+ Users,
21
+ DailyExtract,
22
+ GPS
19
23
  };
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).OFSC={})}(this,function(e){"use strict";async function t(e,t,n){const r=`https://${n}.fs.ocs.oraclecloud.com/rest/oauthTokenService/v2/token`,o={"Content-Type":"application/x-www-form-urlencoded",Authorization:`Basic ${btoa(`${e}@${n}:${t}`)}`},i=new URLSearchParams({grant_type:"client_credentials"});try{const e=await fetch(r,{method:"POST",headers:o,body:i});if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);return(await e.json()).access_token}catch(e){throw console.error("Error fetching OAuth token:",e),e}}var n,r=Object.freeze({__proto__:null,getOAuthToken:t}),o={},i={};var a,s={};function c(){if(a)return s;a=1;var e=/[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,t=new RegExp("[\\-\\.0-9"+e.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"),n=new RegExp("^"+e.source+t.source+"*(?::"+e.source+t.source+"*)?$");function r(e,t){this.message=e,this.locator=t,Error.captureStackTrace&&Error.captureStackTrace(this,r)}function o(){}function i(e,t){return t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}function c(e,t,n,r,o,i){function a(e,t,r){e in n.attributeNames&&i.fatalError("Attribute "+e+" redefined"),n.addValue(e,t,r)}for(var s,c=++t,u=0;;){var l=e.charAt(c);switch(l){case"=":if(1===u)s=e.slice(t,c),u=3;else{if(2!==u)throw new Error("attribute equal must after attrName");u=3}break;case"'":case'"':if(3===u||1===u){if(1===u&&(i.warning('attribute value must after "="'),s=e.slice(t,c)),t=c+1,!((c=e.indexOf(l,t))>0))throw new Error("attribute value no end '"+l+"' match");a(s,d=e.slice(t,c).replace(/&#?\w+;/g,o),t-1),u=5}else{if(4!=u)throw new Error('attribute value must after "="');a(s,d=e.slice(t,c).replace(/&#?\w+;/g,o),t),i.warning('attribute "'+s+'" missed start quot('+l+")!!"),t=c+1,u=5}break;case"/":switch(u){case 0:n.setTagName(e.slice(t,c));case 5:case 6:case 7:u=7,n.closed=!0;case 4:case 1:case 2:break;default:throw new Error("attribute invalid close char('/')")}break;case"":return i.error("unexpected end of input"),0==u&&n.setTagName(e.slice(t,c)),c;case">":switch(u){case 0:n.setTagName(e.slice(t,c));case 5:case 6:case 7:break;case 4:case 1:"/"===(d=e.slice(t,c)).slice(-1)&&(n.closed=!0,d=d.slice(0,-1));case 2:2===u&&(d=s),4==u?(i.warning('attribute "'+d+'" missed quot(")!'),a(s,d.replace(/&#?\w+;/g,o),t)):("http://www.w3.org/1999/xhtml"===r[""]&&d.match(/^(?:disabled|checked|selected)$/i)||i.warning('attribute "'+d+'" missed value!! "'+d+'" instead!!'),a(d,d,t));break;case 3:throw new Error("attribute value missed!!")}return c;case"€":l=" ";default:if(l<=" ")switch(u){case 0:n.setTagName(e.slice(t,c)),u=6;break;case 1:s=e.slice(t,c),u=2;break;case 4:var d=e.slice(t,c).replace(/&#?\w+;/g,o);i.warning('attribute "'+d+'" missed quot(")!!'),a(s,d,t);case 5:u=6}else switch(u){case 2:n.tagName,"http://www.w3.org/1999/xhtml"===r[""]&&s.match(/^(?:disabled|checked|selected)$/i)||i.warning('attribute "'+s+'" missed value!! "'+s+'" instead2!!'),a(s,s,t),t=c,u=1;break;case 5:i.warning('attribute space is required"'+s+'"!!');case 6:u=1,t=c;break;case 3:u=4,t=c;break;case 7:throw new Error("elements closed character '/' and '>' must be connected to")}}c++}}function u(e,t,n){for(var r=e.tagName,o=null,i=e.length;i--;){var a=e[i],s=a.qName,c=a.value;if((f=s.indexOf(":"))>0)var u=a.prefix=s.slice(0,f),l=s.slice(f+1),d="xmlns"===u&&l;else l=s,u=null,d="xmlns"===s&&"";a.localName=l,!1!==d&&(null==o&&(o={},m(n,n={})),n[d]=o[d]=c,a.uri="http://www.w3.org/2000/xmlns/",t.startPrefixMapping(d,c))}for(i=e.length;i--;){(u=(a=e[i]).prefix)&&("xml"===u&&(a.uri="http://www.w3.org/XML/1998/namespace"),"xmlns"!==u&&(a.uri=n[u||""]))}var f;(f=r.indexOf(":"))>0?(u=e.prefix=r.slice(0,f),l=e.localName=r.slice(f+1)):(u=null,l=e.localName=r);var p=e.uri=n[u||""];if(t.startElement(p,l,r,e),!e.closed)return e.currentNSMap=n,e.localNSMap=o,!0;if(t.endElement(p,l,r),o)for(u in o)t.endPrefixMapping(u)}function l(e,t,n,r,o){if(/^(?:script|textarea)$/i.test(n)){var i=e.indexOf("</"+n+">",t),a=e.substring(t+1,i);if(/[&<]/.test(a))return/^script$/i.test(n)?(o.characters(a,0,a.length),i):(a=a.replace(/&#?\w+;/g,r),o.characters(a,0,a.length),i)}return t+1}function d(e,t,n,r){var o=r[n];return null==o&&((o=e.lastIndexOf("</"+n+">"))<t&&(o=e.lastIndexOf("</"+n)),r[n]=o),o<t}function m(e,t){for(var n in e)t[n]=e[n]}function f(e,t,n,r){if("-"===e.charAt(t+2))return"-"===e.charAt(t+3)?(o=e.indexOf("--\x3e",t+4))>t?(n.comment(e,t+4,o-t-4),o+3):(r.error("Unclosed comment"),-1):-1;if("CDATA["==e.substr(t+3,6)){var o=e.indexOf("]]>",t+9);return n.startCDATA(),n.characters(e,t+9,o-t-9),n.endCDATA(),o+3}var i=function(e,t){var n,r=[],o=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;o.lastIndex=t,o.exec(e);for(;n=o.exec(e);)if(r.push(n),n[1])return r}(e,t),a=i.length;if(a>1&&/!doctype/i.test(i[0][0])){var s=i[1][0],c=!1,u=!1;a>3&&(/^public$/i.test(i[2][0])?(c=i[3][0],u=a>4&&i[4][0]):/^system$/i.test(i[2][0])&&(u=i[3][0]));var l=i[a-1];return n.startDTD(s,c,u),n.endDTD(),l.index+l[0].length}return-1}function p(e,t,n){var r=e.indexOf("?>",t);if(r){var o=e.substring(t,r).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);return o?(o[0].length,n.processingInstruction(o[1],o[2]),r+2):-1}return-1}function h(){this.attributeNames={}}return r.prototype=new Error,r.prototype.name=r.name,o.prototype={parse:function(e,t,n){var o=this.domBuilder;o.startDocument(),m(t,t={}),function(e,t,n,o,a){function s(e){if(e>65535){var t=55296+((e-=65536)>>10),n=56320+(1023&e);return String.fromCharCode(t,n)}return String.fromCharCode(e)}function m(e){var t=e.slice(1,-1);return t in n?n[t]:"#"===t.charAt(0)?s(parseInt(t.substr(1).replace("x","0x"))):(a.error("entity not found:"+e),e)}function g(t){if(t>x){var n=e.substring(x,t).replace(/&#?\w+;/g,m);y&&w(x),o.characters(n,0,t-x),x=t}}function w(t,n){for(;t>=N&&(n=b.exec(e));)v=n.index,N=v+n[0].length,y.lineNumber++;y.columnNumber=t-v+1}var v=0,N=0,b=/.*(?:\r\n?|\n)|.*$/g,y=o.locator,E=[{currentNSMap:t}],T={},x=0;for(;;){try{var S=e.indexOf("<",x);if(S<0){if(!e.substr(x).match(/^\s*$/)){var D=o.doc,A=D.createTextNode(e.substr(x));D.appendChild(A),o.currentElement=A}return}switch(S>x&&g(S),e.charAt(S+1)){case"/":var C=e.indexOf(">",S+3),_=e.substring(S+2,C),I=E.pop();C<0?(_=e.substring(S+2).replace(/[\s<].*/,""),a.error("end tag name: "+_+" is not complete:"+I.tagName),C=S+1+_.length):_.match(/\s</)&&(_=_.replace(/[\s<].*/,""),a.error("end tag name: "+_+" maybe not complete"),C=S+1+_.length);var R=I.localNSMap,O=I.tagName==_;if(O||I.tagName&&I.tagName.toLowerCase()==_.toLowerCase()){if(o.endElement(I.uri,I.localName,_),R)for(var $ in R)o.endPrefixMapping($);O||a.fatalError("end tag name: "+_+" is not match the current start tagName:"+I.tagName)}else E.push(I);C++;break;case"?":y&&w(S),C=p(e,S,o);break;case"!":y&&w(S),C=f(e,S,o,a);break;default:y&&w(S);var k=new h,P=E[E.length-1].currentNSMap,M=(C=c(e,S,k,P,m,a),k.length);if(!k.closed&&d(e,C,k.tagName,T)&&(k.closed=!0,n.nbsp||a.warning("unclosed xml attribute")),y&&M){for(var U=i(y,{}),F=0;F<M;F++){var j=k[F];w(j.offset),j.locator=i(y,{})}o.locator=U,u(k,o,P)&&E.push(k),o.locator=y}else u(k,o,P)&&E.push(k);"http://www.w3.org/1999/xhtml"!==k.uri||k.closed?C++:C=l(e,C,k.tagName,m,o)}}catch(e){if(e instanceof r)throw e;a.error("element parse error: "+e),C=-1}C>x?x=C:g(Math.max(S,x)+1)}}(e,t,n,o,this.errorHandler),o.endDocument()}},h.prototype={setTagName:function(e){if(!n.test(e))throw new Error("invalid tagName:"+e);this.tagName=e},addValue:function(e,t,r){if(!n.test(e))throw new Error("invalid attribute:"+e);this.attributeNames[e]=this.length,this[this.length++]={qName:e,value:t,offset:r}},length:0,getLocalName:function(e){return this[e].localName},getLocator:function(e){return this[e].locator},getQName:function(e){return this[e].qName},getURI:function(e){return this[e].uri},getValue:function(e){return this[e].value}},s.XMLReader=o,s.ParseError=r,s}var u,l,d={};function m(){if(u)return d;function e(e,t){for(var n in e)t[n]=e[n]}function t(t,n){var r=t.prototype;if(!(r instanceof n)){function o(){}o.prototype=n.prototype,e(r,o=new o),t.prototype=r=o}r.constructor!=t&&("function"!=typeof t&&console.error("unknow Class:"+t),r.constructor=t)}u=1;var n={},r=n.ELEMENT_NODE=1,o=n.ATTRIBUTE_NODE=2,i=n.TEXT_NODE=3,a=n.CDATA_SECTION_NODE=4,s=n.ENTITY_REFERENCE_NODE=5,c=n.ENTITY_NODE=6,l=n.PROCESSING_INSTRUCTION_NODE=7,m=n.COMMENT_NODE=8,f=n.DOCUMENT_NODE=9,p=n.DOCUMENT_TYPE_NODE=10,h=n.DOCUMENT_FRAGMENT_NODE=11,g=n.NOTATION_NODE=12,w={},v={};w.INDEX_SIZE_ERR=(v[1]="Index size error",1),w.DOMSTRING_SIZE_ERR=(v[2]="DOMString size error",2);var N=w.HIERARCHY_REQUEST_ERR=(v[3]="Hierarchy request error",3);w.WRONG_DOCUMENT_ERR=(v[4]="Wrong document",4),w.INVALID_CHARACTER_ERR=(v[5]="Invalid character",5),w.NO_DATA_ALLOWED_ERR=(v[6]="No data allowed",6),w.NO_MODIFICATION_ALLOWED_ERR=(v[7]="No modification allowed",7);var b=w.NOT_FOUND_ERR=(v[8]="Not found",8);w.NOT_SUPPORTED_ERR=(v[9]="Not supported",9);var y=w.INUSE_ATTRIBUTE_ERR=(v[10]="Attribute in use",10);function E(e,t){if(t instanceof Error)var n=t;else n=this,Error.call(this,v[e]),this.message=v[e],Error.captureStackTrace&&Error.captureStackTrace(this,E);return n.code=e,t&&(this.message=this.message+": "+t),n}function T(){}function x(e,t){this._node=e,this._refresh=t,S(this)}function S(t){var n=t._node._inc||t._node.ownerDocument._inc;if(t._inc!=n){var r=t._refresh(t._node);re(t,"length",r.length),e(r,t),t._inc=n}}function D(){}function A(e,t){for(var n=e.length;n--;)if(e[n]===t)return n}function C(e,t,n,r){if(r?t[A(t,r)]=n:t[t.length++]=n,e){n.ownerElement=e;var o=e.ownerDocument;o&&(r&&P(o,e,r),function(e,t,n){e&&e._inc++;var r=n.namespaceURI;"http://www.w3.org/2000/xmlns/"==r&&(t._nsMap[n.prefix?n.localName:""]=n.value)}(o,e,n))}}function _(e,t,n){var r=A(t,n);if(!(r>=0))throw E(b,new Error(e.tagName+"@"+n));for(var o=t.length-1;r<o;)t[r]=t[++r];if(t.length=o,e){var i=e.ownerDocument;i&&(P(i,e,n),n.ownerElement=null)}}function I(e){if(this._features={},e)for(var t in e)this._features=e[t]}function R(){}function O(e){return("<"==e?"&lt;":">"==e&&"&gt;")||"&"==e&&"&amp;"||'"'==e&&"&quot;"||"&#"+e.charCodeAt()+";"}function $(e,t){if(t(e))return!0;if(e=e.firstChild)do{if($(e,t))return!0}while(e=e.nextSibling)}function k(){}function P(e,t,n,r){e&&e._inc++,"http://www.w3.org/2000/xmlns/"==n.namespaceURI&&delete t._nsMap[n.prefix?n.localName:""]}function M(e,t,n){if(e&&e._inc){e._inc++;var r=t.childNodes;if(n)r[r.length++]=n;else{for(var o=t.firstChild,i=0;o;)r[i++]=o,o=o.nextSibling;r.length=i}}}function U(e,t){var n=t.previousSibling,r=t.nextSibling;return n?n.nextSibling=r:e.firstChild=r,r?r.previousSibling=n:e.lastChild=n,M(e.ownerDocument,e),t}function F(e,t,n){var r=t.parentNode;if(r&&r.removeChild(t),t.nodeType===h){var o=t.firstChild;if(null==o)return t;var i=t.lastChild}else o=i=t;var a=n?n.previousSibling:e.lastChild;o.previousSibling=a,i.nextSibling=n,a?a.nextSibling=o:e.firstChild=o,null==n?e.lastChild=i:n.previousSibling=i;do{o.parentNode=e}while(o!==i&&(o=o.nextSibling));return M(e.ownerDocument||e,e),t.nodeType==h&&(t.firstChild=t.lastChild=null),t}function j(){this._nsMap={}}function L(){}function B(){}function q(){}function z(){}function V(){}function H(){}function Y(){}function W(){}function X(){}function G(){}function Z(){}function Q(){}function J(e,t){var n=[],r=9==this.nodeType&&this.documentElement||this,o=r.prefix,i=r.namespaceURI;if(i&&null==o&&null==(o=r.lookupPrefix(i)))var a=[{namespace:i,prefix:null}];return ee(this,n,e,t,a),n.join("")}function K(e,t,n){var r=e.prefix||"",o=e.namespaceURI;if(!r&&!o)return!1;if("xml"===r&&"http://www.w3.org/XML/1998/namespace"===o||"http://www.w3.org/2000/xmlns/"==o)return!1;for(var i=n.length;i--;){var a=n[i];if(a.prefix==r)return a.namespace!=o}return!0}function ee(e,t,n,c,u){if(c){if(!(e=c(e)))return;if("string"==typeof e)return void t.push(e)}switch(e.nodeType){case r:u||(u=[]),u.length;var d=e.attributes,g=d.length,w=e.firstChild,v=e.tagName;n="http://www.w3.org/1999/xhtml"===e.namespaceURI||n,t.push("<",v);for(var N=0;N<g;N++){"xmlns"==(b=d.item(N)).prefix?u.push({prefix:b.localName,namespace:b.value}):"xmlns"==b.nodeName&&u.push({prefix:"",namespace:b.value})}for(N=0;N<g;N++){var b;if(K(b=d.item(N),0,u)){var y=b.prefix||"",E=b.namespaceURI,T=y?" xmlns:"+y:" xmlns";t.push(T,'="',E,'"'),u.push({prefix:y,namespace:E})}ee(b,t,n,c,u)}if(K(e,0,u)){y=e.prefix||"";if(E=e.namespaceURI){T=y?" xmlns:"+y:" xmlns";t.push(T,'="',E,'"'),u.push({prefix:y,namespace:E})}}if(w||n&&!/^(?:meta|link|img|br|hr|input)$/i.test(v)){if(t.push(">"),n&&/^script$/i.test(v))for(;w;)w.data?t.push(w.data):ee(w,t,n,c,u),w=w.nextSibling;else for(;w;)ee(w,t,n,c,u),w=w.nextSibling;t.push("</",v,">")}else t.push("/>");return;case f:case h:for(w=e.firstChild;w;)ee(w,t,n,c,u),w=w.nextSibling;return;case o:return t.push(" ",e.name,'="',e.value.replace(/[<&"]/g,O),'"');case i:return t.push(e.data.replace(/[<&]/g,O).replace(/]]>/g,"]]&gt;"));case a:return t.push("<![CDATA[",e.data,"]]>");case m:return t.push("\x3c!--",e.data,"--\x3e");case p:var x=e.publicId,S=e.systemId;if(t.push("<!DOCTYPE ",e.name),x)t.push(" PUBLIC ",x),S&&"."!=S&&t.push(" ",S),t.push(">");else if(S&&"."!=S)t.push(" SYSTEM ",S,">");else{var D=e.internalSubset;D&&t.push(" [",D,"]"),t.push(">")}return;case l:return t.push("<?",e.target," ",e.data,"?>");case s:return t.push("&",e.nodeName,";");default:t.push("??",e.nodeName)}}function te(e,t,n){var i;switch(t.nodeType){case r:(i=t.cloneNode(!1)).ownerDocument=e;case h:break;case o:n=!0}if(i||(i=t.cloneNode(!1)),i.ownerDocument=e,i.parentNode=null,n)for(var a=t.firstChild;a;)i.appendChild(te(e,a,n)),a=a.nextSibling;return i}function ne(e,t,n){var i=new t.constructor;for(var a in t){var s=t[a];"object"!=typeof s&&s!=i[a]&&(i[a]=s)}switch(t.childNodes&&(i.childNodes=new T),i.ownerDocument=e,i.nodeType){case r:var c=t.attributes,u=i.attributes=new D,l=c.length;u._ownerElement=i;for(var d=0;d<l;d++)i.setAttributeNode(ne(e,c.item(d),!0));break;case o:n=!0}if(n)for(var m=t.firstChild;m;)i.appendChild(ne(e,m,n)),m=m.nextSibling;return i}function re(e,t,n){e[t]=n}w.INVALID_STATE_ERR=(v[11]="Invalid state",11),w.SYNTAX_ERR=(v[12]="Syntax error",12),w.INVALID_MODIFICATION_ERR=(v[13]="Invalid modification",13),w.NAMESPACE_ERR=(v[14]="Invalid namespace",14),w.INVALID_ACCESS_ERR=(v[15]="Invalid access",15),E.prototype=Error.prototype,e(w,E),T.prototype={length:0,item:function(e){return this[e]||null},toString:function(e,t){for(var n=[],r=0;r<this.length;r++)ee(this[r],n,e,t);return n.join("")}},x.prototype.item=function(e){return S(this),this[e]},t(x,T),D.prototype={length:0,item:T.prototype.item,getNamedItem:function(e){for(var t=this.length;t--;){var n=this[t];if(n.nodeName==e)return n}},setNamedItem:function(e){var t=e.ownerElement;if(t&&t!=this._ownerElement)throw new E(y);var n=this.getNamedItem(e.nodeName);return C(this._ownerElement,this,e,n),n},setNamedItemNS:function(e){var t,n=e.ownerElement;if(n&&n!=this._ownerElement)throw new E(y);return t=this.getNamedItemNS(e.namespaceURI,e.localName),C(this._ownerElement,this,e,t),t},removeNamedItem:function(e){var t=this.getNamedItem(e);return _(this._ownerElement,this,t),t},removeNamedItemNS:function(e,t){var n=this.getNamedItemNS(e,t);return _(this._ownerElement,this,n),n},getNamedItemNS:function(e,t){for(var n=this.length;n--;){var r=this[n];if(r.localName==t&&r.namespaceURI==e)return r}return null}},I.prototype={hasFeature:function(e,t){var n=this._features[e.toLowerCase()];return!(!n||t&&!(t in n))},createDocument:function(e,t,n){var r=new k;if(r.implementation=this,r.childNodes=new T,r.doctype=n,n&&r.appendChild(n),t){var o=r.createElementNS(e,t);r.appendChild(o)}return r},createDocumentType:function(e,t,n){var r=new H;return r.name=e,r.nodeName=e,r.publicId=t,r.systemId=n,r}},R.prototype={firstChild:null,lastChild:null,previousSibling:null,nextSibling:null,attributes:null,parentNode:null,childNodes:null,ownerDocument:null,nodeValue:null,namespaceURI:null,prefix:null,localName:null,insertBefore:function(e,t){return F(this,e,t)},replaceChild:function(e,t){this.insertBefore(e,t),t&&this.removeChild(t)},removeChild:function(e){return U(this,e)},appendChild:function(e){return this.insertBefore(e,null)},hasChildNodes:function(){return null!=this.firstChild},cloneNode:function(e){return ne(this.ownerDocument||this,this,e)},normalize:function(){for(var e=this.firstChild;e;){var t=e.nextSibling;t&&t.nodeType==i&&e.nodeType==i?(this.removeChild(t),e.appendData(t.data)):(e.normalize(),e=t)}},isSupported:function(e,t){return this.ownerDocument.implementation.hasFeature(e,t)},hasAttributes:function(){return this.attributes.length>0},lookupPrefix:function(e){for(var t=this;t;){var n=t._nsMap;if(n)for(var r in n)if(n[r]==e)return r;t=t.nodeType==o?t.ownerDocument:t.parentNode}return null},lookupNamespaceURI:function(e){for(var t=this;t;){var n=t._nsMap;if(n&&e in n)return n[e];t=t.nodeType==o?t.ownerDocument:t.parentNode}return null},isDefaultNamespace:function(e){return null==this.lookupPrefix(e)}},e(n,R),e(n,R.prototype),k.prototype={nodeName:"#document",nodeType:f,doctype:null,documentElement:null,_inc:1,insertBefore:function(e,t){if(e.nodeType==h){for(var n=e.firstChild;n;){var o=n.nextSibling;this.insertBefore(n,t),n=o}return e}return null==this.documentElement&&e.nodeType==r&&(this.documentElement=e),F(this,e,t),e.ownerDocument=this,e},removeChild:function(e){return this.documentElement==e&&(this.documentElement=null),U(this,e)},importNode:function(e,t){return te(this,e,t)},getElementById:function(e){var t=null;return $(this.documentElement,function(n){if(n.nodeType==r&&n.getAttribute("id")==e)return t=n,!0}),t},getElementsByClassName:function(e){var t=new RegExp("(^|\\s)"+e+"(\\s|$)");return new x(this,function(e){var n=[];return $(e.documentElement,function(o){o!==e&&o.nodeType==r&&t.test(o.getAttribute("class"))&&n.push(o)}),n})},createElement:function(e){var t=new j;return t.ownerDocument=this,t.nodeName=e,t.tagName=e,t.childNodes=new T,(t.attributes=new D)._ownerElement=t,t},createDocumentFragment:function(){var e=new G;return e.ownerDocument=this,e.childNodes=new T,e},createTextNode:function(e){var t=new q;return t.ownerDocument=this,t.appendData(e),t},createComment:function(e){var t=new z;return t.ownerDocument=this,t.appendData(e),t},createCDATASection:function(e){var t=new V;return t.ownerDocument=this,t.appendData(e),t},createProcessingInstruction:function(e,t){var n=new Z;return n.ownerDocument=this,n.tagName=n.target=e,n.nodeValue=n.data=t,n},createAttribute:function(e){var t=new L;return t.ownerDocument=this,t.name=e,t.nodeName=e,t.localName=e,t.specified=!0,t},createEntityReference:function(e){var t=new X;return t.ownerDocument=this,t.nodeName=e,t},createElementNS:function(e,t){var n=new j,r=t.split(":"),o=n.attributes=new D;return n.childNodes=new T,n.ownerDocument=this,n.nodeName=t,n.tagName=t,n.namespaceURI=e,2==r.length?(n.prefix=r[0],n.localName=r[1]):n.localName=t,o._ownerElement=n,n},createAttributeNS:function(e,t){var n=new L,r=t.split(":");return n.ownerDocument=this,n.nodeName=t,n.name=t,n.namespaceURI=e,n.specified=!0,2==r.length?(n.prefix=r[0],n.localName=r[1]):n.localName=t,n}},t(k,R),j.prototype={nodeType:r,hasAttribute:function(e){return null!=this.getAttributeNode(e)},getAttribute:function(e){var t=this.getAttributeNode(e);return t&&t.value||""},getAttributeNode:function(e){return this.attributes.getNamedItem(e)},setAttribute:function(e,t){var n=this.ownerDocument.createAttribute(e);n.value=n.nodeValue=""+t,this.setAttributeNode(n)},removeAttribute:function(e){var t=this.getAttributeNode(e);t&&this.removeAttributeNode(t)},appendChild:function(e){return e.nodeType===h?this.insertBefore(e,null):function(e,t){var n=t.parentNode;if(n){var r=e.lastChild;n.removeChild(t),r=e.lastChild}return r=e.lastChild,t.parentNode=e,t.previousSibling=r,t.nextSibling=null,r?r.nextSibling=t:e.firstChild=t,e.lastChild=t,M(e.ownerDocument,e,t),t}(this,e)},setAttributeNode:function(e){return this.attributes.setNamedItem(e)},setAttributeNodeNS:function(e){return this.attributes.setNamedItemNS(e)},removeAttributeNode:function(e){return this.attributes.removeNamedItem(e.nodeName)},removeAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);n&&this.removeAttributeNode(n)},hasAttributeNS:function(e,t){return null!=this.getAttributeNodeNS(e,t)},getAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);return n&&n.value||""},setAttributeNS:function(e,t,n){var r=this.ownerDocument.createAttributeNS(e,t);r.value=r.nodeValue=""+n,this.setAttributeNode(r)},getAttributeNodeNS:function(e,t){return this.attributes.getNamedItemNS(e,t)},getElementsByTagName:function(e){return new x(this,function(t){var n=[];return $(t,function(o){o===t||o.nodeType!=r||"*"!==e&&o.tagName!=e||n.push(o)}),n})},getElementsByTagNameNS:function(e,t){return new x(this,function(n){var o=[];return $(n,function(i){i===n||i.nodeType!==r||"*"!==e&&i.namespaceURI!==e||"*"!==t&&i.localName!=t||o.push(i)}),o})}},k.prototype.getElementsByTagName=j.prototype.getElementsByTagName,k.prototype.getElementsByTagNameNS=j.prototype.getElementsByTagNameNS,t(j,R),L.prototype.nodeType=o,t(L,R),B.prototype={data:"",substringData:function(e,t){return this.data.substring(e,e+t)},appendData:function(e){e=this.data+e,this.nodeValue=this.data=e,this.length=e.length},insertData:function(e,t){this.replaceData(e,0,t)},appendChild:function(e){throw new Error(v[N])},deleteData:function(e,t){this.replaceData(e,t,"")},replaceData:function(e,t,n){n=this.data.substring(0,e)+n+this.data.substring(e+t),this.nodeValue=this.data=n,this.length=n.length}},t(B,R),q.prototype={nodeName:"#text",nodeType:i,splitText:function(e){var t=this.data,n=t.substring(e);t=t.substring(0,e),this.data=this.nodeValue=t,this.length=t.length;var r=this.ownerDocument.createTextNode(n);return this.parentNode&&this.parentNode.insertBefore(r,this.nextSibling),r}},t(q,B),z.prototype={nodeName:"#comment",nodeType:m},t(z,B),V.prototype={nodeName:"#cdata-section",nodeType:a},t(V,B),H.prototype.nodeType=p,t(H,R),Y.prototype.nodeType=g,t(Y,R),W.prototype.nodeType=c,t(W,R),X.prototype.nodeType=s,t(X,R),G.prototype.nodeName="#document-fragment",G.prototype.nodeType=h,t(G,R),Z.prototype.nodeType=l,t(Z,R),Q.prototype.serializeToString=function(e,t,n){return J.call(e,t,n)},R.prototype.toString=J;try{if(Object.defineProperty){function oe(e){switch(e.nodeType){case r:case h:var t=[];for(e=e.firstChild;e;)7!==e.nodeType&&8!==e.nodeType&&t.push(oe(e)),e=e.nextSibling;return t.join("");default:return e.nodeValue}}Object.defineProperty(x.prototype,"length",{get:function(){return S(this),this.$$length}}),Object.defineProperty(R.prototype,"textContent",{get:function(){return oe(this)},set:function(e){switch(this.nodeType){case r:case h:for(;this.firstChild;)this.removeChild(this.firstChild);(e||String(e))&&this.appendChild(this.ownerDocument.createTextNode(e));break;default:this.data=e,this.value=e,this.nodeValue=e}}}),re=function(e,t,n){e["$$"+t]=n}}}catch(ie){}return d.Node=R,d.DOMException=E,d.DOMImplementation=I,d.XMLSerializer=Q,d}var f=function(){if(l)return o;function e(e){this.options=e||{locator:{}}}function t(){this.cdata=!1}function r(e,t){t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber}function a(e){if(e)return"\n@"+(e.systemId||"")+"#[line:"+e.lineNumber+",col:"+e.columnNumber+"]"}function s(e,t,n){return"string"==typeof e?e.substr(t,n):e.length>=t+n||t?new java.lang.String(e,t,n)+"":e}function u(e,t){e.currentElement?e.currentElement.appendChild(t):e.doc.appendChild(t)}l=1,e.prototype.parseFromString=function(e,n){var r=this.options,o=new p,i=r.domBuilder||new t,s=r.errorHandler,c=r.locator,u=r.xmlns||{},l=/\/x?html?$/.test(n),m=l?d.entityMap:{lt:"<",gt:">",amp:"&",quot:'"',apos:"'"};return c&&i.setDocumentLocator(c),o.errorHandler=function(e,n,r){if(!e){if(n instanceof t)return n;e=n}var o={},i=e instanceof Function;function s(t){var n=e[t];!n&&i&&(n=2==e.length?function(n){e(t,n)}:e),o[t]=n&&function(e){n("[xmldom "+t+"]\t"+e+a(r))}||function(){}}return r=r||{},s("warning"),s("error"),s("fatalError"),o}(s,i,c),o.domBuilder=r.domBuilder||i,l&&(u[""]="http://www.w3.org/1999/xhtml"),u.xml=u.xml||"http://www.w3.org/XML/1998/namespace",e&&"string"==typeof e?o.parse(e,u,m):o.errorHandler.error("invalid doc source"),i.doc},t.prototype={startDocument:function(){this.doc=(new g).createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(e,t,n,o){var i=this.doc,a=i.createElementNS(e,n||t),s=o.length;u(this,a),this.currentElement=a,this.locator&&r(this.locator,a);for(var c=0;c<s;c++){e=o.getURI(c);var l=o.getValue(c),d=(n=o.getQName(c),i.createAttributeNS(e,n));this.locator&&r(o.getLocator(c),d),d.value=d.nodeValue=l,a.setAttributeNode(d)}},endElement:function(e,t,n){var r=this.currentElement;r.tagName,this.currentElement=r.parentNode},startPrefixMapping:function(e,t){},endPrefixMapping:function(e){},processingInstruction:function(e,t){var n=this.doc.createProcessingInstruction(e,t);this.locator&&r(this.locator,n),u(this,n)},ignorableWhitespace:function(e,t,n){},characters:function(e,t,n){if(e=s.apply(this,arguments)){if(this.cdata)var o=this.doc.createCDATASection(e);else o=this.doc.createTextNode(e);this.currentElement?this.currentElement.appendChild(o):/^\s*$/.test(e)&&this.doc.appendChild(o),this.locator&&r(this.locator,o)}},skippedEntity:function(e){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(e){(this.locator=e)&&(e.lineNumber=0)},comment:function(e,t,n){e=s.apply(this,arguments);var o=this.doc.createComment(e);this.locator&&r(this.locator,o),u(this,o)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(e,t,n){var o=this.doc.implementation;if(o&&o.createDocumentType){var i=o.createDocumentType(e,t,n);this.locator&&r(this.locator,i),u(this,i)}},warning:function(e){console.warn("[xmldom warning]\t"+e,a(this.locator))},error:function(e){console.error("[xmldom error]\t"+e,a(this.locator))},fatalError:function(e){throw new h(e,this.locator)}},"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(e){t.prototype[e]=function(){return null}});var d=(n||(n=1,i.entityMap={lt:"<",gt:">",amp:"&",quot:'"',apos:"'",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",times:"×",divide:"÷",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",euro:"€",trade:"™",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"}),i),f=c(),p=f.XMLReader,h=f.ParseError,g=o.DOMImplementation=m().DOMImplementation;return o.XMLSerializer=m().XMLSerializer,o.DOMParser=e,o.__DOMHandler=t,o}();const p="plugin-items";function h(){return new Promise((e,t)=>{const n=indexedDB.open("OFSC_Plugin_npm_browser",1);n.onupgradeneeded=()=>{const e=n.result;e.objectStoreNames.contains(p)||e.createObjectStore(p,{keyPath:"id"})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}var g=Object.freeze({__proto__:null,add:async function(e){const t=(await h()).transaction(p,"readwrite");return t.objectStore(p).add(e),new Promise((e,n)=>{t.oncomplete=()=>e(),t.onerror=()=>n(t.error)})},clear:async function(){const e=(await h()).transaction(p,"readwrite");return e.objectStore(p).clear(),new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error)})},get:async function(e){const t=(await h()).transaction(p,"readonly").objectStore(p).get(e);return new Promise((e,n)=>{t.onsuccess=()=>e(t.result),t.onerror=()=>n(t.error)})},getAll:async function(){const e=(await h()).transaction(p,"readonly").objectStore(p).getAll();return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})},remove:async function(e){const t=(await h()).transaction(p,"readwrite");return t.objectStore(p).delete(e),new Promise((e,n)=>{t.oncomplete=()=>e(),t.onerror=()=>n(t.error)})},update:async function(e){const t=(await h()).transaction(p,"readwrite");return t.objectStore(p).put(e),new Promise((e,n)=>{t.oncomplete=()=>e(),t.onerror=()=>n(t.error)})}});const w=async(e,n,r,o,i,a)=>{const s=async t=>fetch(e,{method:"PATCH",headers:{Authorization:`Bearer ${t}`,Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(a)});let c=await s(i);if(401===c.status&&(console.warn("⚠️ Token expired — renewing token…"),i=await t(n,r,o),c=await s(i)),!c.ok)throw new Error(`HTTP ${c.status}: ${await c.text()}`);return{data:await c.json(),token:i}},v=async(e,n,r,o,i,a=5,s=500)=>{const c=async t=>fetch(e,{method:"GET",headers:{Authorization:`Bearer ${t}`,Accept:"application/json"}});let u=await c(i);if(401===u.status&&(console.warn("⚠️ Token expired — renewing token…"),i=await t(n,r,o),u=await c(i)),429===u.status&&a>0){const t=u.headers.get("Retry-After");console.log("⚠️ 429 received. Retrying...",t);const c=t?1e3*Number(t):s;return console.warn(`⚠️ 429 received. Retrying in ${c}ms... (${a} left)`),await new Promise(e=>setTimeout(e,c)),v(e,n,r,o,i,a-1,2*s)}if(!u.ok){const e=await u.text();throw new Error(`❌ Request failed: ${u.status} ${u.statusText}\n${e}`)}return{data:await u.json(),token:i}};function N(e){if(!e||0===e.length)throw new Error("CSV creation failed: no rows provided.");const t=new Set;e.forEach(e=>{Object.keys(e).forEach(e=>t.add(e))});const n=Array.from(t);return[n.join(","),...e.map(e=>n.map(t=>function(e){if(null==e)return"";const t=String(e);if(t.includes('"')||t.includes(",")||t.includes("\n"))return`"${t.replace(/"/g,'""')}"`;return t}(e[t])).join(","))].join("\n")}const b=e=>{if(!e.length)return t="No data to download",n="error",void console.log(`[${n.toUpperCase()}] ${t}`);var t,n;const r=N(e),o=new Blob([r],{type:"text/csv;charset=utf-8;"}),i=document.createElement("a");i.href=URL.createObjectURL(o),i.download=`data_${Date.now()}.csv`,i.click(),setTimeout(()=>URL.revokeObjectURL(i.href),100)};var y=Object.freeze({__proto__:null,downloadCSV:b,fetchWithRetry:v,localStorage:g,patchWithRetry:w,stringCsv:N,xmlNodeToObjects:function(e,t){const n=(new f.DOMParser).parseFromString(e,"application/xml"),r=Array.from(n.getElementsByTagName(t));if(0===r.length)throw new Error(`No <${t}> nodes found`);return r.map(e=>{var t,n;const r={},o=Array.from(e.getElementsByTagName("Field"));for(const e of o){const o=e.getAttribute("name");o&&(r[o]=null!==(n=null===(t=e.textContent)||void 0===t?void 0:t.trim())&&void 0!==n?n:"")}return r})}});const E=e=>/^\d{4}-\d{2}-\d{2}$/.test(e);var T=Object.freeze({__proto__:null,getActivitybyId:async function(e,t,n,r,o=""){const i=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/activities/${Number(r)}/`;return console.log(`➡️ Fetching activity by ID: ${i}`),await v(i,e,t,n,o)},getAllActivities:async function(e,n,r,o,i,a,s,c,u=!1){if(!E(i)||!E(a))throw new Error("❌ Invalid date format. Expected YYYY-MM-DD.");let l=1e3,d=0;const m=[],f=await t(e,n,r);for(;;){const t=new URLSearchParams({offset:d.toString(),limit:l.toString()});s&&t.append("q",s),o&&t.append("resources",o),c&&t.append("fields",c),i&&t.append("dateFrom",i),a&&t.append("dateTo",a),u&&t.append("includeNonScheduled","true");const p=`https://${r}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/activities/?${t.toString()}`;console.error(p),console.log(`➡️ Fetching offset=${d}, limit=${l}`);const h=(await v(p,e,n,r,f)).data;if(!h.items||0===h.items.length){console.log("✔ No more items found. Stopping pagination.");break}m.push(...h.items),console.log(` ✔ Received ${h.items.length} items (Total: ${m.length})`),l=h.limit,d+=l}return m}});async function x(e,t,n,r="",o=""){let i=0;const a=async(o,s)=>{var c;i++,i%20==0&&(console.warn(` Waiting 10 seconds after ${i} API calls to avoid server rate limits.`),await(c=1e4,new Promise(e=>setTimeout(e,c))));const u=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/?offset=${o}&limit=100`,l=await v(u,e,t,n,s),{items:d,totalResults:m}=l.data,f=d.length;if(console.log(`Received ${f} items (Total: ${o+f})`),o+f>=m)return d;const p=await a(o+f,l.token);return""!==r?[...d,...p].filter(e=>e.resourceType===r&&"active"===e.status):[...d,...p]};return a(0,o)}async function S(e,t,n,r,o,i=""){return w(`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/${r}`,e,t,n,i,o)}async function D(e,t,n,r,o=""){const i=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/${encodeURIComponent(r)}/workSkills`;console.log(`➡️ Fetching workSkills by resourceID: ${r}`);const a=await v(i,e,t,n,o);return{token:a.token,data:a.data.items}}var A=Object.freeze({__proto__:null,AllResources:x,getAllResourcesWorkSkills:async function(e,t,n,r="",o=""){const i=[];let a=0;const s=e=>new Promise(t=>setTimeout(t,e)),c=await x(e,t,n,r),u=new Set(c.filter(e=>null!==e.parentResourceId).map(e=>e.parentResourceId));let l=c.filter(e=>!u.has(e.resourceId)).filter(e=>"active"===e.status).filter(e=>"Bucket"!==e.resourceType);""!=o&&(l=l.filter(e=>e.resourceType===o)),console.log(`➡️ Number of resourceID: ${l.length}`);const d=l.length;for(const o of l){if("active"!==o.status)continue;a++,a%50==0&&(console.warn(`⏳ ${a} API calls reached(Total: ${d}). Waiting 5s...`),await s(5e3));const c=await D(e,t,n,o.resourceId,r);for(const e of c.data)i.push({resourceId:o.resourceId,name:o.name,parentResourceId:o.parentResourceId,resourceStatus:o.status,resourceType:o.resourceType,...e});r=c.token}return i},getworkSkillsOfResource:D,resetResourcesEmail:async function(e,t,n,r="noreply.com",o=""){const i=(await x(e,t,n,o)).filter(e=>e.email),a=[];for(let s=0;s<i.length;s+=200){const c=i.slice(s,s+200);for(const s of c){if(console.log(`Total : ${i.length}`,`Total updated: ${a.length}`),!s.email)continue;if(!s.resourceId){console.warn(`⚠️ Resource ID not found for ${JSON.stringify(s)}`);continue}let c=s.email;if(c.includes("@")||(c=c.replace(r,`@${r}`)),c.includes(r)){a.push({id:s.resourceId,email:s.email,newEmail:"",comment:"Email already updated"});continue}c=s.email.replace(/@.*/,`@${r}`),console.log(`Updating email for ${s.resourceId} (${s.email} -> ${c}) on ${n}`);const u={email:c},l=await S(e,t,n,s.resourceId,u,o);o=l.token,a.push({id:l.data.resourceId,email:s.email,newEmail:l.data.email})}s+200<i.length&&(console.warn("⏳ Waiting 10 seconds before next batch...to avoid server rate limits."),await new Promise(e=>setTimeout(e,1e4)))}return a},updateResource:S});var C=Object.freeze({__proto__:null,AllUsers:async function(e,t,n,r=""){let o=0;const i=async(r,a)=>{var s;o++,o%20==0&&(console.warn(` Waiting 10 seconds after ${o} API calls to avoid server rate limits.`),await(s=1e4,new Promise(e=>setTimeout(e,s))));const c=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/users/?offset=${r}&limit=100`,u=await v(c,e,t,n,a),{items:l,totalResults:d}=u.data,m=l.length;if(console.log(`Received ${m} items (Total: ${r+m})`),r+m>=d)return l;const f=await i(r+m,u.token);return[...l,...f]};return i(0,r)}}),_={Activity:T,OauthTokenService:r,Utilities:y,Resources:A,downloadCSV:b,Users:C};e.Activity=T,e.OauthTokenService=r,e.Resources=A,e.Users=C,e.Utilities=y,e.default=_,Object.defineProperty(e,"__esModule",{value:!0})});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).OFSC={})}(this,function(e){"use strict";async function t(e,t,n){const r=`https://${n}.fs.ocs.oraclecloud.com/rest/oauthTokenService/v2/token`,o={"Content-Type":"application/x-www-form-urlencoded",Authorization:`Basic ${btoa(`${e}@${n}:${t}`)}`},i=new URLSearchParams({grant_type:"client_credentials"});try{const e=await fetch(r,{method:"POST",headers:o,body:i});if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);return(await e.json()).access_token}catch(e){throw console.error("Error fetching OAuth token:",e),e}}var n,r=Object.freeze({__proto__:null,getOAuthToken:t}),o={},i={};var a,s={};function c(){if(a)return s;a=1;var e=/[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,t=new RegExp("[\\-\\.0-9"+e.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"),n=new RegExp("^"+e.source+t.source+"*(?::"+e.source+t.source+"*)?$");function r(e,t){this.message=e,this.locator=t,Error.captureStackTrace&&Error.captureStackTrace(this,r)}function o(){}function i(e,t){return t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}function c(e,t,n,r,o,i){function a(e,t,r){e in n.attributeNames&&i.fatalError("Attribute "+e+" redefined"),n.addValue(e,t,r)}for(var s,c=++t,u=0;;){var l=e.charAt(c);switch(l){case"=":if(1===u)s=e.slice(t,c),u=3;else{if(2!==u)throw new Error("attribute equal must after attrName");u=3}break;case"'":case'"':if(3===u||1===u){if(1===u&&(i.warning('attribute value must after "="'),s=e.slice(t,c)),t=c+1,!((c=e.indexOf(l,t))>0))throw new Error("attribute value no end '"+l+"' match");a(s,d=e.slice(t,c).replace(/&#?\w+;/g,o),t-1),u=5}else{if(4!=u)throw new Error('attribute value must after "="');a(s,d=e.slice(t,c).replace(/&#?\w+;/g,o),t),i.warning('attribute "'+s+'" missed start quot('+l+")!!"),t=c+1,u=5}break;case"/":switch(u){case 0:n.setTagName(e.slice(t,c));case 5:case 6:case 7:u=7,n.closed=!0;case 4:case 1:case 2:break;default:throw new Error("attribute invalid close char('/')")}break;case"":return i.error("unexpected end of input"),0==u&&n.setTagName(e.slice(t,c)),c;case">":switch(u){case 0:n.setTagName(e.slice(t,c));case 5:case 6:case 7:break;case 4:case 1:"/"===(d=e.slice(t,c)).slice(-1)&&(n.closed=!0,d=d.slice(0,-1));case 2:2===u&&(d=s),4==u?(i.warning('attribute "'+d+'" missed quot(")!'),a(s,d.replace(/&#?\w+;/g,o),t)):("http://www.w3.org/1999/xhtml"===r[""]&&d.match(/^(?:disabled|checked|selected)$/i)||i.warning('attribute "'+d+'" missed value!! "'+d+'" instead!!'),a(d,d,t));break;case 3:throw new Error("attribute value missed!!")}return c;case"€":l=" ";default:if(l<=" ")switch(u){case 0:n.setTagName(e.slice(t,c)),u=6;break;case 1:s=e.slice(t,c),u=2;break;case 4:var d=e.slice(t,c).replace(/&#?\w+;/g,o);i.warning('attribute "'+d+'" missed quot(")!!'),a(s,d,t);case 5:u=6}else switch(u){case 2:n.tagName,"http://www.w3.org/1999/xhtml"===r[""]&&s.match(/^(?:disabled|checked|selected)$/i)||i.warning('attribute "'+s+'" missed value!! "'+s+'" instead2!!'),a(s,s,t),t=c,u=1;break;case 5:i.warning('attribute space is required"'+s+'"!!');case 6:u=1,t=c;break;case 3:u=4,t=c;break;case 7:throw new Error("elements closed character '/' and '>' must be connected to")}}c++}}function u(e,t,n){for(var r=e.tagName,o=null,i=e.length;i--;){var a=e[i],s=a.qName,c=a.value;if((m=s.indexOf(":"))>0)var u=a.prefix=s.slice(0,m),l=s.slice(m+1),d="xmlns"===u&&l;else l=s,u=null,d="xmlns"===s&&"";a.localName=l,!1!==d&&(null==o&&(o={},f(n,n={})),n[d]=o[d]=c,a.uri="http://www.w3.org/2000/xmlns/",t.startPrefixMapping(d,c))}for(i=e.length;i--;){(u=(a=e[i]).prefix)&&("xml"===u&&(a.uri="http://www.w3.org/XML/1998/namespace"),"xmlns"!==u&&(a.uri=n[u||""]))}var m;(m=r.indexOf(":"))>0?(u=e.prefix=r.slice(0,m),l=e.localName=r.slice(m+1)):(u=null,l=e.localName=r);var p=e.uri=n[u||""];if(t.startElement(p,l,r,e),!e.closed)return e.currentNSMap=n,e.localNSMap=o,!0;if(t.endElement(p,l,r),o)for(u in o)t.endPrefixMapping(u)}function l(e,t,n,r,o){if(/^(?:script|textarea)$/i.test(n)){var i=e.indexOf("</"+n+">",t),a=e.substring(t+1,i);if(/[&<]/.test(a))return/^script$/i.test(n)?(o.characters(a,0,a.length),i):(a=a.replace(/&#?\w+;/g,r),o.characters(a,0,a.length),i)}return t+1}function d(e,t,n,r){var o=r[n];return null==o&&((o=e.lastIndexOf("</"+n+">"))<t&&(o=e.lastIndexOf("</"+n)),r[n]=o),o<t}function f(e,t){for(var n in e)t[n]=e[n]}function m(e,t,n,r){if("-"===e.charAt(t+2))return"-"===e.charAt(t+3)?(o=e.indexOf("--\x3e",t+4))>t?(n.comment(e,t+4,o-t-4),o+3):(r.error("Unclosed comment"),-1):-1;if("CDATA["==e.substr(t+3,6)){var o=e.indexOf("]]>",t+9);return n.startCDATA(),n.characters(e,t+9,o-t-9),n.endCDATA(),o+3}var i=function(e,t){var n,r=[],o=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;o.lastIndex=t,o.exec(e);for(;n=o.exec(e);)if(r.push(n),n[1])return r}(e,t),a=i.length;if(a>1&&/!doctype/i.test(i[0][0])){var s=i[1][0],c=!1,u=!1;a>3&&(/^public$/i.test(i[2][0])?(c=i[3][0],u=a>4&&i[4][0]):/^system$/i.test(i[2][0])&&(u=i[3][0]));var l=i[a-1];return n.startDTD(s,c,u),n.endDTD(),l.index+l[0].length}return-1}function p(e,t,n){var r=e.indexOf("?>",t);if(r){var o=e.substring(t,r).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);return o?(o[0].length,n.processingInstruction(o[1],o[2]),r+2):-1}return-1}function h(){this.attributeNames={}}return r.prototype=new Error,r.prototype.name=r.name,o.prototype={parse:function(e,t,n){var o=this.domBuilder;o.startDocument(),f(t,t={}),function(e,t,n,o,a){function s(e){if(e>65535){var t=55296+((e-=65536)>>10),n=56320+(1023&e);return String.fromCharCode(t,n)}return String.fromCharCode(e)}function f(e){var t=e.slice(1,-1);return t in n?n[t]:"#"===t.charAt(0)?s(parseInt(t.substr(1).replace("x","0x"))):(a.error("entity not found:"+e),e)}function g(t){if(t>S){var n=e.substring(S,t).replace(/&#?\w+;/g,f);y&&w(S),o.characters(n,0,t-S),S=t}}function w(t,n){for(;t>=N&&(n=b.exec(e));)v=n.index,N=v+n[0].length,y.lineNumber++;y.columnNumber=t-v+1}var v=0,N=0,b=/.*(?:\r\n?|\n)|.*$/g,y=o.locator,E=[{currentNSMap:t}],T={},S=0;for(;;){try{var x=e.indexOf("<",S);if(x<0){if(!e.substr(S).match(/^\s*$/)){var D=o.doc,_=D.createTextNode(e.substr(S));D.appendChild(_),o.currentElement=_}return}switch(x>S&&g(x),e.charAt(x+1)){case"/":var A=e.indexOf(">",x+3),C=e.substring(x+2,A),I=E.pop();A<0?(C=e.substring(x+2).replace(/[\s<].*/,""),a.error("end tag name: "+C+" is not complete:"+I.tagName),A=x+1+C.length):C.match(/\s</)&&(C=C.replace(/[\s<].*/,""),a.error("end tag name: "+C+" maybe not complete"),A=x+1+C.length);var R=I.localNSMap,$=I.tagName==C;if($||I.tagName&&I.tagName.toLowerCase()==C.toLowerCase()){if(o.endElement(I.uri,I.localName,C),R)for(var O in R)o.endPrefixMapping(O);$||a.fatalError("end tag name: "+C+" is not match the current start tagName:"+I.tagName)}else E.push(I);A++;break;case"?":y&&w(x),A=p(e,x,o);break;case"!":y&&w(x),A=m(e,x,o,a);break;default:y&&w(x);var k=new h,P=E[E.length-1].currentNSMap,M=(A=c(e,x,k,P,f,a),k.length);if(!k.closed&&d(e,A,k.tagName,T)&&(k.closed=!0,n.nbsp||a.warning("unclosed xml attribute")),y&&M){for(var U=i(y,{}),F=0;F<M;F++){var j=k[F];w(j.offset),j.locator=i(y,{})}o.locator=U,u(k,o,P)&&E.push(k),o.locator=y}else u(k,o,P)&&E.push(k);"http://www.w3.org/1999/xhtml"!==k.uri||k.closed?A++:A=l(e,A,k.tagName,f,o)}}catch(e){if(e instanceof r)throw e;a.error("element parse error: "+e),A=-1}A>S?S=A:g(Math.max(x,S)+1)}}(e,t,n,o,this.errorHandler),o.endDocument()}},h.prototype={setTagName:function(e){if(!n.test(e))throw new Error("invalid tagName:"+e);this.tagName=e},addValue:function(e,t,r){if(!n.test(e))throw new Error("invalid attribute:"+e);this.attributeNames[e]=this.length,this[this.length++]={qName:e,value:t,offset:r}},length:0,getLocalName:function(e){return this[e].localName},getLocator:function(e){return this[e].locator},getQName:function(e){return this[e].qName},getURI:function(e){return this[e].uri},getValue:function(e){return this[e].value}},s.XMLReader=o,s.ParseError=r,s}var u,l,d={};function f(){if(u)return d;function e(e,t){for(var n in e)t[n]=e[n]}function t(t,n){var r=t.prototype;if(!(r instanceof n)){function o(){}o.prototype=n.prototype,e(r,o=new o),t.prototype=r=o}r.constructor!=t&&("function"!=typeof t&&console.error("unknow Class:"+t),r.constructor=t)}u=1;var n={},r=n.ELEMENT_NODE=1,o=n.ATTRIBUTE_NODE=2,i=n.TEXT_NODE=3,a=n.CDATA_SECTION_NODE=4,s=n.ENTITY_REFERENCE_NODE=5,c=n.ENTITY_NODE=6,l=n.PROCESSING_INSTRUCTION_NODE=7,f=n.COMMENT_NODE=8,m=n.DOCUMENT_NODE=9,p=n.DOCUMENT_TYPE_NODE=10,h=n.DOCUMENT_FRAGMENT_NODE=11,g=n.NOTATION_NODE=12,w={},v={};w.INDEX_SIZE_ERR=(v[1]="Index size error",1),w.DOMSTRING_SIZE_ERR=(v[2]="DOMString size error",2);var N=w.HIERARCHY_REQUEST_ERR=(v[3]="Hierarchy request error",3);w.WRONG_DOCUMENT_ERR=(v[4]="Wrong document",4),w.INVALID_CHARACTER_ERR=(v[5]="Invalid character",5),w.NO_DATA_ALLOWED_ERR=(v[6]="No data allowed",6),w.NO_MODIFICATION_ALLOWED_ERR=(v[7]="No modification allowed",7);var b=w.NOT_FOUND_ERR=(v[8]="Not found",8);w.NOT_SUPPORTED_ERR=(v[9]="Not supported",9);var y=w.INUSE_ATTRIBUTE_ERR=(v[10]="Attribute in use",10);function E(e,t){if(t instanceof Error)var n=t;else n=this,Error.call(this,v[e]),this.message=v[e],Error.captureStackTrace&&Error.captureStackTrace(this,E);return n.code=e,t&&(this.message=this.message+": "+t),n}function T(){}function S(e,t){this._node=e,this._refresh=t,x(this)}function x(t){var n=t._node._inc||t._node.ownerDocument._inc;if(t._inc!=n){var r=t._refresh(t._node);re(t,"length",r.length),e(r,t),t._inc=n}}function D(){}function _(e,t){for(var n=e.length;n--;)if(e[n]===t)return n}function A(e,t,n,r){if(r?t[_(t,r)]=n:t[t.length++]=n,e){n.ownerElement=e;var o=e.ownerDocument;o&&(r&&P(o,e,r),function(e,t,n){e&&e._inc++;var r=n.namespaceURI;"http://www.w3.org/2000/xmlns/"==r&&(t._nsMap[n.prefix?n.localName:""]=n.value)}(o,e,n))}}function C(e,t,n){var r=_(t,n);if(!(r>=0))throw E(b,new Error(e.tagName+"@"+n));for(var o=t.length-1;r<o;)t[r]=t[++r];if(t.length=o,e){var i=e.ownerDocument;i&&(P(i,e,n),n.ownerElement=null)}}function I(e){if(this._features={},e)for(var t in e)this._features=e[t]}function R(){}function $(e){return("<"==e?"&lt;":">"==e&&"&gt;")||"&"==e&&"&amp;"||'"'==e&&"&quot;"||"&#"+e.charCodeAt()+";"}function O(e,t){if(t(e))return!0;if(e=e.firstChild)do{if(O(e,t))return!0}while(e=e.nextSibling)}function k(){}function P(e,t,n,r){e&&e._inc++,"http://www.w3.org/2000/xmlns/"==n.namespaceURI&&delete t._nsMap[n.prefix?n.localName:""]}function M(e,t,n){if(e&&e._inc){e._inc++;var r=t.childNodes;if(n)r[r.length++]=n;else{for(var o=t.firstChild,i=0;o;)r[i++]=o,o=o.nextSibling;r.length=i}}}function U(e,t){var n=t.previousSibling,r=t.nextSibling;return n?n.nextSibling=r:e.firstChild=r,r?r.previousSibling=n:e.lastChild=n,M(e.ownerDocument,e),t}function F(e,t,n){var r=t.parentNode;if(r&&r.removeChild(t),t.nodeType===h){var o=t.firstChild;if(null==o)return t;var i=t.lastChild}else o=i=t;var a=n?n.previousSibling:e.lastChild;o.previousSibling=a,i.nextSibling=n,a?a.nextSibling=o:e.firstChild=o,null==n?e.lastChild=i:n.previousSibling=i;do{o.parentNode=e}while(o!==i&&(o=o.nextSibling));return M(e.ownerDocument||e,e),t.nodeType==h&&(t.firstChild=t.lastChild=null),t}function j(){this._nsMap={}}function L(){}function B(){}function q(){}function z(){}function V(){}function H(){}function W(){}function Y(){}function X(){}function G(){}function Z(){}function J(){}function Q(e,t){var n=[],r=9==this.nodeType&&this.documentElement||this,o=r.prefix,i=r.namespaceURI;if(i&&null==o&&null==(o=r.lookupPrefix(i)))var a=[{namespace:i,prefix:null}];return ee(this,n,e,t,a),n.join("")}function K(e,t,n){var r=e.prefix||"",o=e.namespaceURI;if(!r&&!o)return!1;if("xml"===r&&"http://www.w3.org/XML/1998/namespace"===o||"http://www.w3.org/2000/xmlns/"==o)return!1;for(var i=n.length;i--;){var a=n[i];if(a.prefix==r)return a.namespace!=o}return!0}function ee(e,t,n,c,u){if(c){if(!(e=c(e)))return;if("string"==typeof e)return void t.push(e)}switch(e.nodeType){case r:u||(u=[]),u.length;var d=e.attributes,g=d.length,w=e.firstChild,v=e.tagName;n="http://www.w3.org/1999/xhtml"===e.namespaceURI||n,t.push("<",v);for(var N=0;N<g;N++){"xmlns"==(b=d.item(N)).prefix?u.push({prefix:b.localName,namespace:b.value}):"xmlns"==b.nodeName&&u.push({prefix:"",namespace:b.value})}for(N=0;N<g;N++){var b;if(K(b=d.item(N),0,u)){var y=b.prefix||"",E=b.namespaceURI,T=y?" xmlns:"+y:" xmlns";t.push(T,'="',E,'"'),u.push({prefix:y,namespace:E})}ee(b,t,n,c,u)}if(K(e,0,u)){y=e.prefix||"";if(E=e.namespaceURI){T=y?" xmlns:"+y:" xmlns";t.push(T,'="',E,'"'),u.push({prefix:y,namespace:E})}}if(w||n&&!/^(?:meta|link|img|br|hr|input)$/i.test(v)){if(t.push(">"),n&&/^script$/i.test(v))for(;w;)w.data?t.push(w.data):ee(w,t,n,c,u),w=w.nextSibling;else for(;w;)ee(w,t,n,c,u),w=w.nextSibling;t.push("</",v,">")}else t.push("/>");return;case m:case h:for(w=e.firstChild;w;)ee(w,t,n,c,u),w=w.nextSibling;return;case o:return t.push(" ",e.name,'="',e.value.replace(/[<&"]/g,$),'"');case i:return t.push(e.data.replace(/[<&]/g,$).replace(/]]>/g,"]]&gt;"));case a:return t.push("<![CDATA[",e.data,"]]>");case f:return t.push("\x3c!--",e.data,"--\x3e");case p:var S=e.publicId,x=e.systemId;if(t.push("<!DOCTYPE ",e.name),S)t.push(" PUBLIC ",S),x&&"."!=x&&t.push(" ",x),t.push(">");else if(x&&"."!=x)t.push(" SYSTEM ",x,">");else{var D=e.internalSubset;D&&t.push(" [",D,"]"),t.push(">")}return;case l:return t.push("<?",e.target," ",e.data,"?>");case s:return t.push("&",e.nodeName,";");default:t.push("??",e.nodeName)}}function te(e,t,n){var i;switch(t.nodeType){case r:(i=t.cloneNode(!1)).ownerDocument=e;case h:break;case o:n=!0}if(i||(i=t.cloneNode(!1)),i.ownerDocument=e,i.parentNode=null,n)for(var a=t.firstChild;a;)i.appendChild(te(e,a,n)),a=a.nextSibling;return i}function ne(e,t,n){var i=new t.constructor;for(var a in t){var s=t[a];"object"!=typeof s&&s!=i[a]&&(i[a]=s)}switch(t.childNodes&&(i.childNodes=new T),i.ownerDocument=e,i.nodeType){case r:var c=t.attributes,u=i.attributes=new D,l=c.length;u._ownerElement=i;for(var d=0;d<l;d++)i.setAttributeNode(ne(e,c.item(d),!0));break;case o:n=!0}if(n)for(var f=t.firstChild;f;)i.appendChild(ne(e,f,n)),f=f.nextSibling;return i}function re(e,t,n){e[t]=n}w.INVALID_STATE_ERR=(v[11]="Invalid state",11),w.SYNTAX_ERR=(v[12]="Syntax error",12),w.INVALID_MODIFICATION_ERR=(v[13]="Invalid modification",13),w.NAMESPACE_ERR=(v[14]="Invalid namespace",14),w.INVALID_ACCESS_ERR=(v[15]="Invalid access",15),E.prototype=Error.prototype,e(w,E),T.prototype={length:0,item:function(e){return this[e]||null},toString:function(e,t){for(var n=[],r=0;r<this.length;r++)ee(this[r],n,e,t);return n.join("")}},S.prototype.item=function(e){return x(this),this[e]},t(S,T),D.prototype={length:0,item:T.prototype.item,getNamedItem:function(e){for(var t=this.length;t--;){var n=this[t];if(n.nodeName==e)return n}},setNamedItem:function(e){var t=e.ownerElement;if(t&&t!=this._ownerElement)throw new E(y);var n=this.getNamedItem(e.nodeName);return A(this._ownerElement,this,e,n),n},setNamedItemNS:function(e){var t,n=e.ownerElement;if(n&&n!=this._ownerElement)throw new E(y);return t=this.getNamedItemNS(e.namespaceURI,e.localName),A(this._ownerElement,this,e,t),t},removeNamedItem:function(e){var t=this.getNamedItem(e);return C(this._ownerElement,this,t),t},removeNamedItemNS:function(e,t){var n=this.getNamedItemNS(e,t);return C(this._ownerElement,this,n),n},getNamedItemNS:function(e,t){for(var n=this.length;n--;){var r=this[n];if(r.localName==t&&r.namespaceURI==e)return r}return null}},I.prototype={hasFeature:function(e,t){var n=this._features[e.toLowerCase()];return!(!n||t&&!(t in n))},createDocument:function(e,t,n){var r=new k;if(r.implementation=this,r.childNodes=new T,r.doctype=n,n&&r.appendChild(n),t){var o=r.createElementNS(e,t);r.appendChild(o)}return r},createDocumentType:function(e,t,n){var r=new H;return r.name=e,r.nodeName=e,r.publicId=t,r.systemId=n,r}},R.prototype={firstChild:null,lastChild:null,previousSibling:null,nextSibling:null,attributes:null,parentNode:null,childNodes:null,ownerDocument:null,nodeValue:null,namespaceURI:null,prefix:null,localName:null,insertBefore:function(e,t){return F(this,e,t)},replaceChild:function(e,t){this.insertBefore(e,t),t&&this.removeChild(t)},removeChild:function(e){return U(this,e)},appendChild:function(e){return this.insertBefore(e,null)},hasChildNodes:function(){return null!=this.firstChild},cloneNode:function(e){return ne(this.ownerDocument||this,this,e)},normalize:function(){for(var e=this.firstChild;e;){var t=e.nextSibling;t&&t.nodeType==i&&e.nodeType==i?(this.removeChild(t),e.appendData(t.data)):(e.normalize(),e=t)}},isSupported:function(e,t){return this.ownerDocument.implementation.hasFeature(e,t)},hasAttributes:function(){return this.attributes.length>0},lookupPrefix:function(e){for(var t=this;t;){var n=t._nsMap;if(n)for(var r in n)if(n[r]==e)return r;t=t.nodeType==o?t.ownerDocument:t.parentNode}return null},lookupNamespaceURI:function(e){for(var t=this;t;){var n=t._nsMap;if(n&&e in n)return n[e];t=t.nodeType==o?t.ownerDocument:t.parentNode}return null},isDefaultNamespace:function(e){return null==this.lookupPrefix(e)}},e(n,R),e(n,R.prototype),k.prototype={nodeName:"#document",nodeType:m,doctype:null,documentElement:null,_inc:1,insertBefore:function(e,t){if(e.nodeType==h){for(var n=e.firstChild;n;){var o=n.nextSibling;this.insertBefore(n,t),n=o}return e}return null==this.documentElement&&e.nodeType==r&&(this.documentElement=e),F(this,e,t),e.ownerDocument=this,e},removeChild:function(e){return this.documentElement==e&&(this.documentElement=null),U(this,e)},importNode:function(e,t){return te(this,e,t)},getElementById:function(e){var t=null;return O(this.documentElement,function(n){if(n.nodeType==r&&n.getAttribute("id")==e)return t=n,!0}),t},getElementsByClassName:function(e){var t=new RegExp("(^|\\s)"+e+"(\\s|$)");return new S(this,function(e){var n=[];return O(e.documentElement,function(o){o!==e&&o.nodeType==r&&t.test(o.getAttribute("class"))&&n.push(o)}),n})},createElement:function(e){var t=new j;return t.ownerDocument=this,t.nodeName=e,t.tagName=e,t.childNodes=new T,(t.attributes=new D)._ownerElement=t,t},createDocumentFragment:function(){var e=new G;return e.ownerDocument=this,e.childNodes=new T,e},createTextNode:function(e){var t=new q;return t.ownerDocument=this,t.appendData(e),t},createComment:function(e){var t=new z;return t.ownerDocument=this,t.appendData(e),t},createCDATASection:function(e){var t=new V;return t.ownerDocument=this,t.appendData(e),t},createProcessingInstruction:function(e,t){var n=new Z;return n.ownerDocument=this,n.tagName=n.target=e,n.nodeValue=n.data=t,n},createAttribute:function(e){var t=new L;return t.ownerDocument=this,t.name=e,t.nodeName=e,t.localName=e,t.specified=!0,t},createEntityReference:function(e){var t=new X;return t.ownerDocument=this,t.nodeName=e,t},createElementNS:function(e,t){var n=new j,r=t.split(":"),o=n.attributes=new D;return n.childNodes=new T,n.ownerDocument=this,n.nodeName=t,n.tagName=t,n.namespaceURI=e,2==r.length?(n.prefix=r[0],n.localName=r[1]):n.localName=t,o._ownerElement=n,n},createAttributeNS:function(e,t){var n=new L,r=t.split(":");return n.ownerDocument=this,n.nodeName=t,n.name=t,n.namespaceURI=e,n.specified=!0,2==r.length?(n.prefix=r[0],n.localName=r[1]):n.localName=t,n}},t(k,R),j.prototype={nodeType:r,hasAttribute:function(e){return null!=this.getAttributeNode(e)},getAttribute:function(e){var t=this.getAttributeNode(e);return t&&t.value||""},getAttributeNode:function(e){return this.attributes.getNamedItem(e)},setAttribute:function(e,t){var n=this.ownerDocument.createAttribute(e);n.value=n.nodeValue=""+t,this.setAttributeNode(n)},removeAttribute:function(e){var t=this.getAttributeNode(e);t&&this.removeAttributeNode(t)},appendChild:function(e){return e.nodeType===h?this.insertBefore(e,null):function(e,t){var n=t.parentNode;if(n){var r=e.lastChild;n.removeChild(t),r=e.lastChild}return r=e.lastChild,t.parentNode=e,t.previousSibling=r,t.nextSibling=null,r?r.nextSibling=t:e.firstChild=t,e.lastChild=t,M(e.ownerDocument,e,t),t}(this,e)},setAttributeNode:function(e){return this.attributes.setNamedItem(e)},setAttributeNodeNS:function(e){return this.attributes.setNamedItemNS(e)},removeAttributeNode:function(e){return this.attributes.removeNamedItem(e.nodeName)},removeAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);n&&this.removeAttributeNode(n)},hasAttributeNS:function(e,t){return null!=this.getAttributeNodeNS(e,t)},getAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);return n&&n.value||""},setAttributeNS:function(e,t,n){var r=this.ownerDocument.createAttributeNS(e,t);r.value=r.nodeValue=""+n,this.setAttributeNode(r)},getAttributeNodeNS:function(e,t){return this.attributes.getNamedItemNS(e,t)},getElementsByTagName:function(e){return new S(this,function(t){var n=[];return O(t,function(o){o===t||o.nodeType!=r||"*"!==e&&o.tagName!=e||n.push(o)}),n})},getElementsByTagNameNS:function(e,t){return new S(this,function(n){var o=[];return O(n,function(i){i===n||i.nodeType!==r||"*"!==e&&i.namespaceURI!==e||"*"!==t&&i.localName!=t||o.push(i)}),o})}},k.prototype.getElementsByTagName=j.prototype.getElementsByTagName,k.prototype.getElementsByTagNameNS=j.prototype.getElementsByTagNameNS,t(j,R),L.prototype.nodeType=o,t(L,R),B.prototype={data:"",substringData:function(e,t){return this.data.substring(e,e+t)},appendData:function(e){e=this.data+e,this.nodeValue=this.data=e,this.length=e.length},insertData:function(e,t){this.replaceData(e,0,t)},appendChild:function(e){throw new Error(v[N])},deleteData:function(e,t){this.replaceData(e,t,"")},replaceData:function(e,t,n){n=this.data.substring(0,e)+n+this.data.substring(e+t),this.nodeValue=this.data=n,this.length=n.length}},t(B,R),q.prototype={nodeName:"#text",nodeType:i,splitText:function(e){var t=this.data,n=t.substring(e);t=t.substring(0,e),this.data=this.nodeValue=t,this.length=t.length;var r=this.ownerDocument.createTextNode(n);return this.parentNode&&this.parentNode.insertBefore(r,this.nextSibling),r}},t(q,B),z.prototype={nodeName:"#comment",nodeType:f},t(z,B),V.prototype={nodeName:"#cdata-section",nodeType:a},t(V,B),H.prototype.nodeType=p,t(H,R),W.prototype.nodeType=g,t(W,R),Y.prototype.nodeType=c,t(Y,R),X.prototype.nodeType=s,t(X,R),G.prototype.nodeName="#document-fragment",G.prototype.nodeType=h,t(G,R),Z.prototype.nodeType=l,t(Z,R),J.prototype.serializeToString=function(e,t,n){return Q.call(e,t,n)},R.prototype.toString=Q;try{if(Object.defineProperty){function oe(e){switch(e.nodeType){case r:case h:var t=[];for(e=e.firstChild;e;)7!==e.nodeType&&8!==e.nodeType&&t.push(oe(e)),e=e.nextSibling;return t.join("");default:return e.nodeValue}}Object.defineProperty(S.prototype,"length",{get:function(){return x(this),this.$$length}}),Object.defineProperty(R.prototype,"textContent",{get:function(){return oe(this)},set:function(e){switch(this.nodeType){case r:case h:for(;this.firstChild;)this.removeChild(this.firstChild);(e||String(e))&&this.appendChild(this.ownerDocument.createTextNode(e));break;default:this.data=e,this.value=e,this.nodeValue=e}}}),re=function(e,t,n){e["$$"+t]=n}}}catch(ie){}return d.Node=R,d.DOMException=E,d.DOMImplementation=I,d.XMLSerializer=J,d}var m=function(){if(l)return o;function e(e){this.options=e||{locator:{}}}function t(){this.cdata=!1}function r(e,t){t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber}function a(e){if(e)return"\n@"+(e.systemId||"")+"#[line:"+e.lineNumber+",col:"+e.columnNumber+"]"}function s(e,t,n){return"string"==typeof e?e.substr(t,n):e.length>=t+n||t?new java.lang.String(e,t,n)+"":e}function u(e,t){e.currentElement?e.currentElement.appendChild(t):e.doc.appendChild(t)}l=1,e.prototype.parseFromString=function(e,n){var r=this.options,o=new p,i=r.domBuilder||new t,s=r.errorHandler,c=r.locator,u=r.xmlns||{},l=/\/x?html?$/.test(n),f=l?d.entityMap:{lt:"<",gt:">",amp:"&",quot:'"',apos:"'"};return c&&i.setDocumentLocator(c),o.errorHandler=function(e,n,r){if(!e){if(n instanceof t)return n;e=n}var o={},i=e instanceof Function;function s(t){var n=e[t];!n&&i&&(n=2==e.length?function(n){e(t,n)}:e),o[t]=n&&function(e){n("[xmldom "+t+"]\t"+e+a(r))}||function(){}}return r=r||{},s("warning"),s("error"),s("fatalError"),o}(s,i,c),o.domBuilder=r.domBuilder||i,l&&(u[""]="http://www.w3.org/1999/xhtml"),u.xml=u.xml||"http://www.w3.org/XML/1998/namespace",e&&"string"==typeof e?o.parse(e,u,f):o.errorHandler.error("invalid doc source"),i.doc},t.prototype={startDocument:function(){this.doc=(new g).createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(e,t,n,o){var i=this.doc,a=i.createElementNS(e,n||t),s=o.length;u(this,a),this.currentElement=a,this.locator&&r(this.locator,a);for(var c=0;c<s;c++){e=o.getURI(c);var l=o.getValue(c),d=(n=o.getQName(c),i.createAttributeNS(e,n));this.locator&&r(o.getLocator(c),d),d.value=d.nodeValue=l,a.setAttributeNode(d)}},endElement:function(e,t,n){var r=this.currentElement;r.tagName,this.currentElement=r.parentNode},startPrefixMapping:function(e,t){},endPrefixMapping:function(e){},processingInstruction:function(e,t){var n=this.doc.createProcessingInstruction(e,t);this.locator&&r(this.locator,n),u(this,n)},ignorableWhitespace:function(e,t,n){},characters:function(e,t,n){if(e=s.apply(this,arguments)){if(this.cdata)var o=this.doc.createCDATASection(e);else o=this.doc.createTextNode(e);this.currentElement?this.currentElement.appendChild(o):/^\s*$/.test(e)&&this.doc.appendChild(o),this.locator&&r(this.locator,o)}},skippedEntity:function(e){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(e){(this.locator=e)&&(e.lineNumber=0)},comment:function(e,t,n){e=s.apply(this,arguments);var o=this.doc.createComment(e);this.locator&&r(this.locator,o),u(this,o)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(e,t,n){var o=this.doc.implementation;if(o&&o.createDocumentType){var i=o.createDocumentType(e,t,n);this.locator&&r(this.locator,i),u(this,i)}},warning:function(e){console.warn("[xmldom warning]\t"+e,a(this.locator))},error:function(e){console.error("[xmldom error]\t"+e,a(this.locator))},fatalError:function(e){throw new h(e,this.locator)}},"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(e){t.prototype[e]=function(){return null}});var d=(n||(n=1,i.entityMap={lt:"<",gt:">",amp:"&",quot:'"',apos:"'",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",times:"×",divide:"÷",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",euro:"€",trade:"™",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"}),i),m=c(),p=m.XMLReader,h=m.ParseError,g=o.DOMImplementation=f().DOMImplementation;return o.XMLSerializer=f().XMLSerializer,o.DOMParser=e,o.__DOMHandler=t,o}();const p="plugin-items";function h(){return new Promise((e,t)=>{const n=indexedDB.open("OFSC_Plugin_npm_browser",1);n.onupgradeneeded=()=>{const e=n.result;e.objectStoreNames.contains(p)||e.createObjectStore(p,{keyPath:"id"})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}var g=Object.freeze({__proto__:null,add:async function(e){const t=(await h()).transaction(p,"readwrite");return t.objectStore(p).add(e),new Promise((e,n)=>{t.oncomplete=()=>e(),t.onerror=()=>n(t.error)})},clear:async function(){const e=(await h()).transaction(p,"readwrite");return e.objectStore(p).clear(),new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error)})},get:async function(e){const t=(await h()).transaction(p,"readonly").objectStore(p).get(e);return new Promise((e,n)=>{t.onsuccess=()=>e(t.result),t.onerror=()=>n(t.error)})},getAll:async function(){const e=(await h()).transaction(p,"readonly").objectStore(p).getAll();return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})},remove:async function(e){const t=(await h()).transaction(p,"readwrite");return t.objectStore(p).delete(e),new Promise((e,n)=>{t.oncomplete=()=>e(),t.onerror=()=>n(t.error)})},update:async function(e){const t=(await h()).transaction(p,"readwrite");return t.objectStore(p).put(e),new Promise((e,n)=>{t.oncomplete=()=>e(),t.onerror=()=>n(t.error)})}});const w=async(e,n,r,o,i,a)=>{const s=async t=>fetch(e,{method:"PATCH",headers:{Authorization:`Bearer ${t}`,Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(a)});let c=await s(i);if(401===c.status&&(console.warn("⚠️ Token expired — renewing token…"),i=await t(n,r,o),c=await s(i)),!c.ok)throw new Error(`HTTP ${c.status}: ${await c.text()}`);return{data:await c.json(),token:i}},v=async(e,n,r,o,i,a=5,s=500)=>{const c=async t=>fetch(e,{method:"GET",headers:{Authorization:`Bearer ${t}`,Accept:"application/json"}});let u=await c(i);if(401===u.status&&(console.warn("⚠️ Token expired — renewing token…"),i=await t(n,r,o),u=await c(i)),404===u.status)return console.log(JSON.stringify(await u.text())),{data:[],token:i};if(429===u.status&&a>0){const t=u.headers.get("Retry-After");console.log("⚠️ 429 received. Retrying...",t);const c=t?1e3*Number(t):s;return console.warn(`⚠️ 429 received. Retrying in ${c}ms... (${a} left)`),await new Promise(e=>setTimeout(e,c)),v(e,n,r,o,i,a-1,2*s)}if(!u.ok){const e=await u.text();throw new Error(`❌ Request failed: ${u.status} ${u.statusText}\n${e}`)}return{data:await u.json(),token:i}};function N(e){if(!e||0===e.length)throw new Error("CSV creation failed: no rows provided.");const t=new Set;e.forEach(e=>{Object.keys(e).forEach(e=>t.add(e))});const n=Array.from(t);return[n.join(","),...e.map(e=>n.map(t=>function(e){if(null==e)return"";const t=String(e);if(t.includes('"')||t.includes(",")||t.includes("\n"))return`"${t.replace(/"/g,'""')}"`;return t}(e[t])).join(","))].join("\n")}const b=e=>{if(!e.length)return t="No data to download",n="error",void console.log(`[${n.toUpperCase()}] ${t}`);var t,n;const r=N(e),o=new Blob([r],{type:"text/csv;charset=utf-8;"}),i=document.createElement("a");i.href=URL.createObjectURL(o),i.download=`data_${Date.now()}.csv`,i.click(),setTimeout(()=>URL.revokeObjectURL(i.href),100)};var y=Object.freeze({__proto__:null,downloadCSV:b,fetchWithRetry:v,localStorage:g,patchWithRetry:w,stringCsv:N,xmlNodeToObjects:function(e,t){const n=(new m.DOMParser).parseFromString(e,"application/xml"),r=Array.from(n.getElementsByTagName(t));if(0===r.length)throw new Error(`No <${t}> nodes found`);return r.map(e=>{var t,n;const r={},o=Array.from(e.getElementsByTagName("Field"));for(const e of o){const o=e.getAttribute("name");o&&(r[o]=null!==(n=null===(t=e.textContent)||void 0===t?void 0:t.trim())&&void 0!==n?n:"")}return r})}});const E=e=>/^\d{4}-\d{2}-\d{2}$/.test(e);var T=Object.freeze({__proto__:null,getActivitybyId:async function(e,t,n,r,o=""){const i=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/activities/${Number(r)}/`;return console.log(`➡️ Fetching activity by ID: ${i}`),await v(i,e,t,n,o)},getAllActivities:async function(e,n,r,o,i,a,s,c,u=!1){if(!E(i)||!E(a))throw new Error("❌ Invalid date format. Expected YYYY-MM-DD.");let l=1e3,d=0;const f=[],m=await t(e,n,r);for(;;){const t=new URLSearchParams({offset:d.toString(),limit:l.toString()});s&&t.append("q",s),o&&t.append("resources",o),c&&t.append("fields",c),i&&t.append("dateFrom",i),a&&t.append("dateTo",a),u&&t.append("includeNonScheduled","true");const p=`https://${r}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/activities/?${t.toString()}`;console.error(p),console.log(`➡️ Fetching offset=${d}, limit=${l}`);const h=(await v(p,e,n,r,m)).data;if(!h.items||0===h.items.length){console.log("✔ No more items found. Stopping pagination.");break}f.push(...h.items),console.log(` ✔ Received ${h.items.length} items (Total: ${f.length})`),l=h.limit,d+=l}return f}});var S=Object.freeze({__proto__:null,AllFiles:async function(e,t,n,r=""){let o=0;return(async()=>{var i,a,s;o++,o%20==0&&(console.warn(`Waiting 10 seconds after ${o} API calls to avoid rate limits.`),await(s=1e4,new Promise(e=>setTimeout(e,s))));const c=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/folders/dailyExtract/folders/${r}/files`;return null===(a=null===(i=(await v(c,e,t,n,"")).data)||void 0===i?void 0:i.files)||void 0===a?void 0:a.items})()}});var x=Object.freeze({__proto__:null,resourcePositionHistoryRange:async function(e,t,n,r,o,i,a=""){let s=0;const c=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,u=async(o,i,a)=>{var c;s++,s%20==0&&(console.warn(`Waiting 10 seconds after ${s} API calls...`),await(c=1e4,new Promise(e=>setTimeout(e,c)))),console.log(`Calling API for date=${o}, offset=${i}`);const l=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/${r}/positionHistory/?date=${o}&offset=${i}&limit=100`,d=await v(l,e,t,n,a);a=d.token;const{items:f=[],totalResults:m=0}=d.data||{},p=(null==f?void 0:f.length)||0;if(console.log(`[${o}] Received ${p} items (Total: ${i+p}/${m})`),i+p>=m)return{items:f,token:d.token};const h=await u(o,i+p,d.token);return{items:[...f,...h],token:d.token}},l=((e,t)=>{const n=[];let r=new Date(e);const o=new Date(t);if(r>o)throw new Error("fromDate cannot be greater than toDate");for(;r<=o;)n.push(c(r)),r.setDate(r.getDate()+1);return n})(o,i);console.log(`Total dates to process: ${l.length}`);let d=[],f=a;for(let e=0;e<l.length;e++){const t=l[e];console.log(`\nProcessing ${e+1}/${l.length}: ${t}`);const n=await u(t,0,f);d=[...d,...n.items.map(e=>{const{acc:t,alt:n,dir:o,i:i,s:a,spd:s,...c}=e;return{ResourceId:r,"Accuracy of the position in meters":t,Altitude:n,"direction (in degrees) in which the vehicle is headed":o,"Duration of the position":i,Status:a,Speed:s,...c}})],f=n.token}return console.log(`\n✅ Completed. Total records fetched: ${d.length}`),d}});async function D(e,t,n,r="",o=""){let i=0;const a=async(o,s)=>{var c;i++,i%20==0&&(console.warn(` Waiting 10 seconds after ${i} API calls to avoid server rate limits.`),await(c=1e4,new Promise(e=>setTimeout(e,c))));const u=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/?offset=${o}&limit=100`,l=await v(u,e,t,n,s),{items:d,totalResults:f}=l.data,m=d.length;if(console.log(`Received ${m} items (Total: ${o+m})`),o+m>=f)return d;const p=await a(o+m,l.token);return""!==r?[...d,...p].filter(e=>e.resourceType===r&&"active"===e.status):[...d,...p]};return a(0,o)}async function _(e,t,n,r,o,i=""){return w(`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/${r}`,e,t,n,i,o)}async function A(e,t,n,r,o=""){const i=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/${encodeURIComponent(r)}/workSkills`;console.log(`➡️ Fetching workSkills by resourceID: ${r}`);const a=await v(i,e,t,n,o);return{token:a.token,data:a.data.items}}var C=Object.freeze({__proto__:null,AllResources:D,getAllResourcesWorkSkills:async function(e,t,n,r="",o=""){const i=[];let a=0;const s=e=>new Promise(t=>setTimeout(t,e)),c=await D(e,t,n,r),u=new Set(c.filter(e=>null!==e.parentResourceId).map(e=>e.parentResourceId));let l=c.filter(e=>!u.has(e.resourceId)).filter(e=>"active"===e.status).filter(e=>"Bucket"!==e.resourceType);""!=o&&(l=l.filter(e=>e.resourceType===o)),console.log(`➡️ Number of resourceID: ${l.length}`);const d=l.length;for(const o of l){if("active"!==o.status)continue;a++,a%50==0&&(console.warn(`⏳ ${a} API calls reached(Total: ${d}). Waiting 5s...`),await s(5e3));const c=await A(e,t,n,o.resourceId,r);for(const e of c.data)i.push({resourceId:o.resourceId,name:o.name,parentResourceId:o.parentResourceId,resourceStatus:o.status,resourceType:o.resourceType,...e});r=c.token}return i},getworkSkillsOfResource:A,resetResourcesEmail:async function(e,t,n,r="noreply.com",o=""){const i=(await D(e,t,n,o)).filter(e=>e.email),a=[];for(let s=0;s<i.length;s+=200){const c=i.slice(s,s+200);for(const s of c){if(console.log(`Total : ${i.length}`,`Total updated: ${a.length}`),!s.email)continue;if(!s.resourceId){console.warn(`⚠️ Resource ID not found for ${JSON.stringify(s)}`);continue}let c=s.email;if(c.includes("@")||(c=c.replace(r,`@${r}`)),c.includes(r)){a.push({id:s.resourceId,email:s.email,newEmail:"",comment:"Email already updated"});continue}c=s.email.replace(/@.*/,`@${r}`),console.log(`Updating email for ${s.resourceId} (${s.email} -> ${c}) on ${n}`);const u={email:c},l=await _(e,t,n,s.resourceId,u,o);o=l.token,a.push({id:l.data.resourceId,email:s.email,newEmail:l.data.email})}s+200<i.length&&(console.warn("⏳ Waiting 10 seconds before next batch...to avoid server rate limits."),await new Promise(e=>setTimeout(e,1e4)))}return a},updateResource:_});var I=Object.freeze({__proto__:null,AllUsers:async function(e,t,n,r=""){let o=0;const i=async(r,a)=>{var s;o++,o%20==0&&(console.warn(` Waiting 10 seconds after ${o} API calls to avoid server rate limits.`),await(s=1e4,new Promise(e=>setTimeout(e,s))));const c=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/users/?offset=${r}&limit=100`,u=await v(c,e,t,n,a),{items:l,totalResults:d}=u.data,f=l.length;if(console.log(`Received ${f} items (Total: ${r+f})`),r+f>=d)return l;const m=await i(r+f,u.token);return[...l,...m]};return i(0,r)}}),R={Activity:T,OauthTokenService:r,Utilities:y,Resources:C,downloadCSV:b,Users:I,DailyExtract:S,GPS:x};e.Activity=T,e.DailyExtract=S,e.GPS=x,e.OauthTokenService=r,e.Resources=C,e.Users=I,e.Utilities=y,e.default=R,Object.defineProperty(e,"__esModule",{value:!0})});
2
2
  //# sourceMappingURL=ofsc-utilities-min.js.map