{"version":3,"file":"respec-vc.js","mappings":";;;;;;;;;;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;;;;;;;;;;ACVA;AACA;AACA;AACa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACbA;AACA;AACA;AACa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;AC9EA;AACA;AACA;AACa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACrFA;AACA;AACA;AACa;;AAEb,kBAAkB,mBAAO,CAAC,yGAAqB;AAC/C,kBAAkB,mBAAO,CAAC,yGAAqB;AAC/C,kBAAkB,mBAAO,CAAC,yFAAa;AACvC;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;AC5BA;AACA;AACA;;AAEA;AACA,mBAAmB,aAAa;AAChC;;AAEA;AACA,eAAe,0BAA0B,qBAAqB,SAAS,cAAc,4BAA4B,YAAY,qBAAqB,2DAA2D,uCAAuC,qCAAqC,oBAAoB,GAAG,iBAAiB,4FAA4F,eAAe,wCAAwC,SAAS,GAAG,mBAAmB,8BAA8B,qDAAqD,0BAA0B,6CAA6C,sBAAsB,6DAA6D,YAAY,eAAe,SAAS,iBAAiB,iCAAiC,iBAAiB,YAAY,UAAU,sBAAsB,mBAAmB,iDAAiD,iBAAiB,kBAAkB;AAC19B;AACA,+BAA+B,kEAAkE,aAAa,iCAAiC,qGAAqG,iBAAiB;AACrQ;AACA,cAAc,YAAY,4oBAA4oB,0CAA0C,UAAU,iCAAiC,uIAAuI,8CAA8C,UAAU,8CAA8C,kKAAkK,gCAAgC,qCAAqC,qCAAqC,8CAA8C,oCAAoC,yHAAyH,2CAA2C,UAAU,2CAA2C,4HAA4H,iBAAiB;AAC5qD;AACA,cAAc,aAAa,eAAe,iCAAiC,6mCAA6mC,8DAA8D,iBAAiB,mEAAmE,aAAa,qCAAqC,0DAA0D,+DAA+D,uBAAuB,yEAAyE,uBAAuB,yEAAyE,SAAS,qDAAqD,mEAAmE,qCAAqC,YAAY,oCAAoC,qBAAqB,qDAAqD,qBAAqB,qDAAqD,mBAAmB,2CAA2C,UAAU,kCAAkC,6BAA6B,iEAAiE,YAAY,sBAAsB,mBAAmB,2CAA2C,kCAAkC,sDAAsD,eAAe,0CAA0C,+GAA+G,6CAA6C,yDAAyD,IAAI,iBAAiB;AAClsF;AACA,cAAc,2JAA2J;AACzK,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AAE2M;;;;;;;;;;;;AC5B3M;AACA;AACa;;AAEb;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA,GAAG,UAAU;AACb;;;;;;;;;;;;;;;;;;;;;;ACzBA;AACA;AACA;;AAEA;AACA,mBAAmB,aAAa;AAChC;;AAEA;AACA;AACA,MAAM,OAAO,QAAQ,WAAW,oKAAoK,SAAS,WAAW,YAAY,2EAA2E,6EAA6E,4LAA4L,wDAAwD,yJAAyJ,mBAAmB,4CAA4C,oBAAoB,6CAA6C,WAAW,oCAAoC,iBAAiB,mDAAmD,SAAS,kCAAkC,SAAS,2CAA2C,SAAS,kCAAkC,eAAe,iDAAiD,QAAQ,sDAAsD,iBAAiB,sDAAsD,2JAA2J,aAAa,sCAAsC,YAAY,8CAA8C,aAAa,iDAAiD,yBAAyB,+EAA+E,0IAA0I,kCAAkC,QAAQ,sDAAsD,uBAAuB,wEAAwE,8BAA8B,0EAA0E,iKAAiK,gEAAgE,8BAA8B,8CAA8C,+CAA+C,sDAAsD,uGAAuG,8DAA8D,iBAAiB,qEAAqE,iDAAiD,+CAA+C,8BAA8B,0EAA0E,iKAAiK,gEAAgE,8BAA8B,8CAA8C,+CAA+C,sDAAsD,uGAAuG,8DAA8D,iBAAiB,qEAAqE,iDAAiD,+CAA+C,uBAAuB,mEAAmE,iKAAiK,gEAAgE,8BAA8B,8CAA8C,+CAA+C,sDAAsD,uGAAuG,8DAA8D,iBAAiB,qEAAqE,iDAAiD,+CAA+C,mBAAmB,+DAA+D,kEAAkE,gEAAgE,8BAA8B,8CAA8C,+CAA+C,sDAAsD,uGAAuG,8DAA8D,iBAAiB,qEAAqE,iDAAiD,+CAA+C,QAAQ,gFAAgF,eAAe,MAAM,cAAc,iBAAiB,WAAW,kBAAkB,8CAA8C,EAAE,oBAAoB,QAAQ,6CAA6C,eAAe,yBAAyB,iBAAiB,SAAS,cAAc,aAAa,kCAAkC,iHAAiH,KAAK,iBAAiB,WAAW,+BAA+B,YAAY,YAAY,qCAAqC,gBAAgB,yBAAyB,oDAAoD,SAAS,GAAG;AAC3gM,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AAEqM;;;;;;;;;;;;;;;;;;;;;;ACrBrM;AACA;AACA;;AAEA;AACA,mBAAmB,aAAa;AAChC;;AAEA;AACA,eAAe,0BAA0B,qBAAqB,SAAS,cAAc,4BAA4B,YAAY,qBAAqB,2DAA2D,uCAAuC,qCAAqC,oBAAoB,GAAG,iBAAiB,4FAA4F,eAAe,wCAAwC,SAAS,GAAG,mBAAmB,8BAA8B,qDAAqD,0BAA0B,6CAA6C,sBAAsB,6DAA6D,YAAY,eAAe,SAAS,iBAAiB,iCAAiC,iBAAiB,YAAY,UAAU,sBAAsB,mBAAmB,iDAAiD,iBAAiB,kBAAkB;AAC19B;AACA,cAAc,YAAY,6CAA6C,4EAA4E,6BAA6B,yEAAyE,kDAAkD,2DAA2D,UAAU,8FAA8F,kBAAkB,oDAAoD,uBAAuB,mEAAmE,+FAA+F,6FAA6F,oDAAoD,iGAAiG,uDAAuD,4EAA4E,uDAAuD,oFAAoF,iBAAiB,yFAAyF,uBAAuB,+FAA+F,uBAAuB,+FAA+F,eAAe,yFAAyF,MAAM,sCAAsC,qBAAqB,yEAAyE,iBAAiB;AACtyD;AACA,cAAc,2IAA2I,iBAAiB;AAC1K;AACA,wBAAwB,iBAAiB,OAAO,mCAAmC,aAAa,WAAW,gBAAgB,sBAAsB,kFAAkF,iBAAiB;AACpP;AACA,SAAS,cAAc,aAAa,WAAW,kBAAkB,8CAA8C,EAAE,oBAAoB,QAAQ,6CAA6C;AAC1L,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,iEAAe,SAAS,EAAC;AACyI;;;;;;;;;;;;;;;;;;;;;;AC7BlK;AACA;AACA;;AAEA;AACA,mBAAmB,aAAa;AAChC;;AAEA;AACA,eAAe,0BAA0B,qBAAqB,SAAS,cAAc,4BAA4B,YAAY,qBAAqB,2DAA2D,uCAAuC,qCAAqC,oBAAoB,GAAG,iBAAiB,4FAA4F,eAAe,wCAAwC,SAAS,GAAG,mBAAmB,8BAA8B,qDAAqD,0BAA0B,6CAA6C,sBAAsB,6DAA6D,YAAY,eAAe,SAAS,iBAAiB,iCAAiC,iBAAiB,YAAY,UAAU,sBAAsB,mBAAmB,iDAAiD,iBAAiB,kBAAkB;AAC19B;AACA,cAAc,YAAY,6CAA6C,4EAA4E,6BAA6B,yEAAyE,kDAAkD,2DAA2D,UAAU,8FAA8F,qBAAqB,qGAAqG,uBAAuB,mEAAmE,+FAA+F,6FAA6F,oDAAoD,iGAAiG,uDAAuD,4EAA4E,uDAAuD,oFAAoF,iBAAiB,yFAAyF,uBAAuB,+FAA+F,uBAAuB,+FAA+F,eAAe,yFAAyF,aAAa,2FAA2F,qBAAqB,yEAAyE,iBAAiB;AACt5D;AACA,cAAc,2IAA2I,iBAAiB;AAC1K;AACA,wBAAwB,iBAAiB,OAAO,mCAAmC,aAAa,uBAAuB,gBAAgB,sBAAsB,kFAAkF,iBAAiB;AAChQ;AACA,SAAS,cAAc,aAAa,WAAW,kBAAkB,8CAA8C,EAAE,oBAAoB,QAAQ,6CAA6C;AAC1L,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,iEAAe,SAAS,EAAC;AACyI;;;;;;;;;;;;AC7BlK;AACA;AACA;AACa;;AAEb,kBAAkB,mBAAO,CAAC,sEAAa;AACvC,eAAe,mBAAO,CAAC,mDAAQ;AAC/B,OAAO,2CAA2C,EAAE,mBAAO,CAAC,gFAAkB;AAC9E,OAAO,gBAAgB,EAAE,mBAAO,CAAC,gEAAiB;;AAElD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,QAAQ;AAC9B,qBAAqB,QAAQ;AAC7B;AACA;AACA;AACA,2BAA2B,qBAAqB;AAChD;AACA;AACA;AACA;AACA,6BAA6B,cAAc;AAC3C;AACA;AACA;AACA;AACA,8BAA8B,UAAU;AACxC;AACA;AACA,cAAc,iBAAiB;AAC/B;AACA;AACA,uBAAuB,gCAAgC,IAAI;AAC3D;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,MAAM;AACN;AACA;;AAEA;AACA,mBAAmB;AACnB;;AAEA;AACA,iCAAiC,SAAS;;AAE1C;AACA;AACA;AACA,KAAK;;AAEL;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,QAAQ;AAC9B,qBAAqB,QAAQ;AAC7B;AACA;AACA;AACA,2BAA2B,qBAAqB;AAChD;AACA;AACA;AACA;AACA,6BAA6B,cAAc;AAC3C;AACA;AACA;AACA;AACA,8BAA8B,UAAU;AACxC;AACA;AACA,cAAc,iBAAiB;AAC/B;AACA;AACA,0BAA0B,gCAAgC,IAAI;AAC9D;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,MAAM;AACN;AACA;;AAEA;AACA,mBAAmB;AACnB;;AAEA;AACA,iCAAiC,SAAS;;AAE1C;AACA;AACA;AACA,KAAK;;AAEL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA,aAAa,2CAA2C;AACxD;AACA;AACA,aAAa,cAAc;AAC3B;AACA;AACA;AACA;AACA;AACA,aAAa,UAAU;AACvB;AACA;AACA,cAAc,SAAS,4CAA4C,GAAG;AACtE;AACA;AACA,kBAAkB;AAClB;AACA;AACA,0BAA0B,gCAAgC,IAAI;AAC9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,MAAM;AACN;AACA;;AAEA;AACA;AACA,kBAAkB;;AAElB;AACA,mCAAmC,SAAS;AAC5C;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,SAAS,oDAAoD;AAC7D;AACA;AACA,sCAAsC;AACtC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,wBAAwB;AACxB;AACA;AACA;AACA;AACA;AACA,cAAc;AACd,MAAM;AACN;AACA,cAAc;AACd;AACA;AACA;;AAEA,qBAAqB,SAAS;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;;AAEA,2CAA2C;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B,mBAAmB;AAClD;AACA,kBAAkB;AAClB;AACA;AACA,aAAa,qCAAqC;AAClD,SAAS,mDAAmD;AAC5D;AACA;AACA;AACA,gBAAgB;AAChB,MAAM;AACN,gBAAgB;AAChB;;AAEA;AACA;AACA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,oBAAoB;AACnC;AACA;AACA;AACA;AACA;AACA,WAAW;AACX,UAAU;AACV,2BAA2B;AAC3B;;AAEA;AACA;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA;AACA,UAAU;AACV;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA,CAAC;AACD;AACA,qDAAqD;AACrD,oCAAoC,yBAAyB;AAC7D;AACA;;AAEA,uDAAuD;AACvD;AACA,uEAAuE;AACvE;AACA;AACA;AACA;AACA,gCAAgC;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gCAAgC,gCAAgC;AAChE;AACA;AACA;AACA,mDAAmD;AACnD,qDAAqD;AACrD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,yEAAyE;AACzE;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;;;;;;;;;;;;AC7YA;AACA;AACA;AACa;;AAEb;AACA;AACA;AACA;AACA;AACA,aAAa,eAAe;AAC5B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACnBA;AACA;AACA;AACa;;AAEb;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,2GAAiC;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACfA;AACA;AACA;AACa;;AAEb,kBAAkB,mBAAO,CAAC,sEAAa;AACvC,OAAO,4BAA4B,EAAE,mBAAO,CAAC,2GAAiC;;AAE9E;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACbA;AACA;AACA;AACa;;AAEb,8BAA8B,wBAAwB;;AAEtD;AACA,iBAAiB,mBAAO,CAAC,oEAAY;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,UAAU;AACvB,wCAAwC;AACxC,uCAAuC;AACvC;AACA,eAAe,UAAU;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA,cAAc,OAAO;AACrB;AACA;AACA,cAAc,QAAQ;AACtB;AACA;AACA,qBAAqB,KAAK;AAC1B,CAAC;;;;;;;;;;;;ACnED;AACA;AACA;AACa;;AAEb;AACA;AACA;;AAEA;AACA,kBAAkB,mBAAO,CAAC,sEAAa;AACvC;;AAEA;AACA,iBAAiB,mBAAO,CAAC,oEAAY;AACrC,0BAA0B,mBAAO,CAAC,sFAAqB;;AAEvD;AACA;AACA;AACA;AACA,WAAW,QAAQ;AACnB;AACA;AACA,WAAW,QAAQ;AACnB,WAAW,qBAAqB;AAChC;AACA;AACA;AACA,WAAW,cAAc;AACzB;AACA;AACA;AACA,WAAW,UAAU;AACrB;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,UAAU,wCAAwC;AAC7D,WAAW,SAAS;AACpB;AACA;AACA;AACA,aAAa,iBAAiB;AAC9B;AACA;AACA;AACA,EAAE,IAAI;AACN;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B,0BAA0B;;AAEtD;AACA;AACA,iBAAiB,+BAA+B;AAChD,IAAI;AACJ;AACA,aAAa,UAAU,MAAM;AAC7B;AACA,kBAAkB,IAAI,wBAAwB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,QAAQ;AACnB;AACA,WAAW,QAAQ;AACnB,WAAW,qBAAqB;AAChC;AACA;AACA,WAAW,cAAc;AACzB;AACA;AACA;AACA,WAAW,UAAU;AACrB;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,UAAU,wCAAwC;AAC7D,WAAW,SAAS;AACpB;AACA;AACA;AACA,aAAa,iBAAiB;AAC9B;AACA;AACA;AACA,EAAE,IAAI;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B,0BAA0B;;AAEtD;AACA,+CAA+C,+BAA+B;AAC9E,IAAI;AACJ;AACA,aAAa,UAAU,MAAM;AAC7B;AACA,kBAAkB,IAAI,wBAAwB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,QAAQ;AACnB;AACA;AACA,WAAW,QAAQ;AACnB,WAAW,2CAA2C;AACtD;AACA;AACA,WAAW,cAAc;AACzB;AACA;AACA;AACA;AACA;AACA,WAAW,UAAU;AACrB;AACA,WAAW,UAAU,wCAAwC;AAC7D;AACA,YAAY,SAAS;AACrB,8BAA8B;AAC9B;AACA;AACA,wBAAwB;AACxB;AACA;AACA;AACA;AACA;AACA,EAAE,IAAI;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,+BAA+B;AAC9C,SAAS,OAAO;AAChB;AACA;AACA,aAAa,UAAU,MAAM;AAC7B;AACA,kBAAkB,IAAI,wBAAwB;AAC9C;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,8FAA0B;;AAEvC;AACA,eAAe,oGAA8B;;AAE7C;AACA,mBAAmB,mBAAO,CAAC,gFAAkB;;;;;;;;;;;;AChM7C;AACA;AACA;AACa;;AAEb;AACA;;AAEA;AACA;AACA,yBAAyB,mBAAO,CAAC,gHAAkC;AACnE,8BAA8B,mBAAO,CAAC,0HAAuC;AAC7E,0BAA0B,mBAAO,CAAC,kHAAmC;AACrE,gBAAgB,mBAAO,CAAC,8FAAyB;AACjD;;;;;;;;;;;;ACdA;AACA;AACA;AACa;;AAEb,+BAA+B,mBAAO,CAAC,yGAA0B;;AAEjE;AACA;AACA;AACA,wCAAwC,IAAI;AAC5C,WAAW,0CAA0C;AACrD;AACA;;;;;;;;;;;;ACbA;AACA;AACA;AACa;;AAEb,+BAA+B,mBAAO,CAAC,yGAA0B;;AAEjE;AACA;AACA;AACA;AACA,2DAA2D,IAAI;AAC/D,WAAW,0CAA0C;AACrD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,yBAAyB,iDAAiD;AAC1E;AACA;AACA;AACA,2DAA2D;AAC3D,wBAAwB,gBAAgB,eAAe,eAAe;AACtE;;AAEA;AACA;AACA,wDAAwD;AACxD,qBAAqB,aAAa,eAAe,YAAY;AAC7D;;AAEA;AACA,gBAAgB,iDAAiD;AACjE,MAAM;AACN,cAAc;AACd;AACA;;AAEA,uBAAuB,8CAA8C;AACrE;AACA,cAAc,8CAA8C;AAC5D;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACrDA;AACA;AACA;AACa;;AAEb,kBAAkB,mBAAO,CAAC,uEAAc;AACxC,eAAe,mBAAO,CAAC,mDAAQ;AAC/B,qBAAqB,mBAAO,CAAC,qFAAgB;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,QAAQ;AAC1B;AACA,0BAA0B,QAAQ;AAClC;AACA,oBAAoB,2BAA2B;AAC/C;AACA,iCAAiC,SAAS;AAC1C;AACA;AACA,eAAe,sDAAsD,IAAI;AACzE,WAAW,8BAA8B;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB;AACA,eAAe,SAAS,6BAA6B;AACrD;AACA,yBAAyB,iDAAiD;AAC1E;AACA;AACA,gBAAgB,iDAAiD;AACjE;AACA;AACA;;AAEA,aAAa,oBAAoB;AACjC,aAAa,gCAAgC;;AAE7C;AACA;AACA;AACA,QAAQ;AACR,eAAe,YAAY;AAC3B;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA;AACA,YAAY;AACZ;AACA;AACA;;AAEA;AACA;AACA,aAAa,UAAU;AACvB;AACA;AACA;AACA;AACA;AACA,+DAA+D;AAC/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,GAAG,qDAAqD;AACnE;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC,sBAAsB;AACxD,8CAA8C,UAAU;AACxD;AACA;AACA,MAAM;AACN,cAAc;AACd;AACA;AACA;;;;;;;;;;;;ACjIA;AACA;AACA;AACa;;AAEb;AACA;AACA,kBAAkB,QAAQ;AAC1B;AACA,oBAAoB,2BAA2B;AAC/C;AACA,iCAAiC,SAAS;AAC1C;AACA;AACA,eAAe,0CAA0C,IAAI;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC,KAAK;AACxC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,QAAQ;AAC3B;AACA;AACA,cAAc,iBAAiB;AAC/B;AACA;AACA,YAAY;AACZ,qCAAqC;AACrC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd,MAAM;AACN,cAAc;AACd;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,QAAQ;AAC3B;AACA;AACA,cAAc,iBAAiB;AAC/B;AACA;AACA,uBAAuB,kDAAkD;AACzE;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,mBAAmB,QAAQ;AAC3B;AACA,cAAc,kBAAkB;AAChC;AACA,sBAAsB,4CAA4C;AAClE;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACtGA;AACA;AACA;AACA;AACa;AACb;;AAEA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA,cAAc,YAAY;AAC1B;AACA,sBAAsB,OAAO;AAC7B;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACrBA;AACA;AACA;AACa;;AAEb;AACA;;AAEA;AACA;AACA,mBAAmB,mBAAO,CAAC,gGAA0B;AACrD,uBAAuB,mBAAO,CAAC,wGAA8B;AAC7D;;;;;;;;;;;;ACZA;AACA;AACA;AACa;;AAEb;AACA,eAAe,MAAM,IAAI;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,cAAc;AAC3B,aAAa,OAAO;AACpB,aAAa,UAAU;AACvB,aAAa,UAAU,sCAAsC;AAC7D;AACA,eAAe,iBAAiB;AAChC;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA,aAAa,cAAc;AAC3B,aAAa,OAAO;AACpB,aAAa,UAAU;AACvB;AACA,eAAe,iBAAiB;AAChC;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,cAAc;AAC3B,aAAa,OAAO;AACpB,aAAa,UAAU;AACvB,aAAa,UAAU,sCAAsC;AAC7D;AACA,eAAe,SAAS,OAAO,GAAG;AAClC;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA,eAAe,kBAAkB;AACjC;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;;;;;;;;;;;AC5EA;AACA;AACA;AACa;;AAEb,kBAAkB,mBAAO,CAAC,uEAAc;AACxC,eAAe,mBAAO,CAAC,mDAAQ;AAC/B,aAAa,mBAAO,CAAC,6DAAS;AAC9B,OAAO,cAAc,EAAE,mBAAO,CAAC,qFAAiB;AAChD,wBAAwB,mBAAO,CAAC,yFAAmB;;AAEnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA,aAAa,WAAW;AACxB;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA,cAAc,6BAA6B;AAC3C;AACA;AACA;AACA;AACA;AACA,cAAc,+BAA+B;AAC7C;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,aAAa;AAC1B;AACA,aAAa,SAAS;AACtB;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA,IAAI,IAAI;AACR,WAAW,KAAK;AAChB;AACA;AACA;AACA,wCAAwC,sBAAsB;AAC9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC,KAAK;AACxC;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,cAAc;AAC3B,aAAa,OAAO;AACpB,aAAa,UAAU;AACvB,aAAa,UAAU,sCAAsC;AAC7D;AACA,eAAe,iBAAiB;AAChC;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe;AACf,MAAM;AACN;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,OAAO,mDAAmD;;AAE1D,0CAA0C;AAC1C;AACA;AACA;AACA,cAAc,sCAAsC;;AAEpD;AACA;AACA,OAAO,0CAA0C;;AAEjD;AACA,6BAA6B,4CAA4C;;AAEzE;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB,aAAa,UAAU,sCAAsC;AAC7D;AACA,eAAe,iBAAiB;AAChC;AACA,qBAAqB,oBAAoB;AACzC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,cAAc;AAC3B,aAAa,OAAO;AACpB,aAAa,UAAU;AACvB,aAAa,UAAU,sCAAsC;AAC7D;AACA,eAAe,SAAS,OAAO,GAAG;AAClC;AACA,qBAAqB,wDAAwD;AAC7E;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS,wDAAwD;;AAEjE;AACA;AACA,SAAS,8CAA8C;;AAEvD;AACA;AACA;AACA,qCAAqC;AACrC;AACA;AACA;;AAEA,cAAc;AACd,MAAM;AACN,cAAc;AACd;AACA;;AAEA,yBAAyB,4CAA4C;AACrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA,8BAA8B,uCAAuC;AACrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB,aAAa,UAAU;AACvB,aAAa,UAAU,sCAAsC;AAC7D;AACA,eAAe,SAAS,WAAW,EAAE;AACrC;AACA,0BAA0B,8CAA8C;AACxE;AACA;AACA;AACA;AACA;AACA,WAAW,YAAY;AACvB;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA,mCAAmC,6BAA6B;AAChE,gDAAgD,qBAAqB;AACrE;AACA;;AAEA;AACA;AACA;AACA;AACA,gBAAgB,uCAAuC;AACvD,gDAAgD,yBAAyB;AACzE;AACA;;AAEA;AACA;AACA;;AAEA;AACA,wBAAwB,WAAW;AACnC,sBAAsB,QAAQ;AAC9B;AACA,mBAAmB;AACnB,sBAAsB;AACtB,4BAA4B;AAC5B;AACA,eAAe,SAAS,OAAO,GAAG;AAClC;AACA;AACA;AACA;;AAEA;AACA,sBAAsB,QAAQ;AAC9B,mBAAmB;AACnB,4BAA4B;AAC5B;AACA,+BAA+B,sBAAsB;AACrD,SAAS,oBAAoB;;AAE7B;AACA;AACA;;AAEA;AACA;AACA;;AAEA,yDAAyD;AACzD;AACA;AACA;AACA;AACA;AACA,KAAK,GAAG,qDAAqD;AAC7D;AACA,6CAA6C,oBAAoB;AACjE;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,wBAAwB,WAAW;AACnC,sBAAsB,QAAQ;AAC9B,mBAAmB;AACnB,4BAA4B;AAC5B,0BAA0B;AAC1B;AACA,eAAe,SAAS,OAAO,GAAG;AAClC;AACA;AACA;AACA;;AAEA;AACA,wBAAwB,WAAW;AACnC,gCAAgC,OAAO;AACvC,sBAAsB,QAAQ;AAC9B,mBAAmB;AACnB,4BAA4B;AAC5B,0BAA0B;AAC1B;AACA,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,SAAS;AACtB;AACA,sBAAsB,0BAA0B;AAChD,WAAW,YAAY;;AAEvB,yBAAyB,qBAAqB;AAC9C;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAY,WAAW;AACvB;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB;AACA,aAAa,SAAS;AACtB;AACA,2BAA2B,qBAAqB;AAChD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,cAAc;AACd,cAAc,2BAA2B;AACzC,gBAAgB,gCAAgC;AAChD;AACA;AACA,kCAAkC,sBAAsB;AACxD;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;;;;;;;;;;AC7cA;AACA;AACA;AACa;;AAEb;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB;AACA,YAAY,YAAY;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACtCA;AACA;AACA;AACa;;AAEb;AACA;AACA;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,mDAAS;AACrB;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,iDAAQ;AACpB,OAAO,aAAa,EAAE,mBAAO,CAAC,+CAAO;AACrC,oBAAoB,mBAAO,CAAC,+DAAe;AAC3C,wBAAwB,mBAAO,CAAC,uEAAmB;;AAEnD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,YAAY;AAC3B;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,kDAAkD;AAC/D;;AAEA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,eAAe;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,cAAc;AACtD,oCAAoC,6BAA6B;AACjE;AACA;AACA;;AAEA;AACA;;AAEA;AACA,yCAAyC;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,yBAAyB,mBAAmB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,+BAA+B,6CAA6C;AAC5E;AACA;AACA,WAAW,oBAAoB;AAC/B,OAAO,uCAAuC;;AAE9C;AACA;AACA,yBAAyB,cAAc;;AAEvC;AACA;AACA,OAAO,iDAAiD;AACxD,gCAAgC,uCAAuC;AACvE;AACA;;AAEA,uBAAuB,uCAAuC;AAC9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,qDAAqD;AAC9D;;AAEA;AACA;AACA;AACA;AACA;AACA,8BAA8B,oCAAoC;AAClE;;AAEA;AACA;AACA,iBAAiB;AACjB,MAAM;AACN,iBAAiB;AACjB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,YAAY;AACZ;AACA;;AAEA;AACA;AACA,6BAA6B;AAC7B;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B,cAAc;AAC5C;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,mBAAmB,gBAAgB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B,UAAU,oBAAoB,OAAO;AAClE;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,yBAAyB,yBAAyB;AAClD;AACA;;;;;;;;;;;;ACpQA;AACA;AACA;AACa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACtBA;AACA;AACA;AACa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;;;;;;;;;;ACnDA;AACA;AACA;AACa;;AAEb;AACA,uGAA+C;;;;;;;;;;;;ACN/C;AACA;AACA;AACa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;;;;;;;;;;;;ACrCA;AACA;AACA;AACa;;AAEb,YAAY,mBAAO,CAAC,oDAAW;;AAE/B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB;AACA;AACA;AACA,0BAA0B,yBAAyB;AACnD;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;;;;;;;;;;AC7BA;AACA;AACA;AACa;;AAEb,oBAAoB,mBAAO,CAAC,+DAAe;;AAE3C;AACA;AACA;AACA;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,mDAAS;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,6DAAc;;AAE1B;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,uDAAW;;AAEvB;AACA;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,+CAAO;;AAEnB;AACA;AACA;AACA;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,iDAAQ;;AAEpB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA,mBAAmB,oBAAoB;AACvC;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,mBAAmB;AACxC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,0BAA0B,mDAAmD;AAC7E;AACA;AACA;AACA;AACA;AACA,2CAA2C,mCAAmC;AAC9E;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA,yCAAyC,mCAAmC;AAC5E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,gDAAgD,aAAa;;AAEtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB,aAAa;AACtC;AACA,WAAW;AACX;AACA;AACA;;AAEA;AACA;AACA,WAAW,oCAAoC,aAAa;;AAE5D;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB,WAAW;AACX;AACA;AACA;;AAEA;AACA;AACA,WAAW,sCAAsC,aAAa;AAC9D;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,gDAAgD,yBAAyB;AACzE;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C,0BAA0B;AACzE;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB,WAAW;AACX;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,uBAAuB;AACvB,SAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB;AACvB,SAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA,oCAAoC;AACpC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,YAAY;AACnC;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,YAAY;AACnC;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B;AAC7B,eAAe;AACf;;AAEA;AACA;AACA;AACA;AACA;AACA,6BAA6B;AAC7B,eAAe;AACf;AACA,YAAY;AACZ;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;;AAEA;AACA;AACA;AACA,8BAA8B;AAC9B,6BAA6B,aAAa;AAC1C;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe;AACf,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B;AAC/B;AACA;AACA;AACA;AACA;AACA,eAAe;AACf,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B;AAC7B,eAAe;AACf;;AAEA;AACA;AACA;AACA;AACA;AACA,6BAA6B;AAC7B,eAAe;AACf;;AAEA;AACA;AACA;AACA;AACA;AACA,6BAA6B;AAC7B,eAAe;AACf;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA,eAAe,uCAAuC,aAAa;AACnE;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA,gBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY;AACZ,0CAA0C;AAC1C,2BAA2B,aAAa;AACxC;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA,2BAA2B;AAC3B,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,2BAA2B;AACrD;AACA,eAAe;AACf;AACA;;AAEA;AACA;AACA,kCAAkC;AAClC,2BAA2B,aAAa;AACxC;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,yBAAyB;AACtC;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,aAAa;AAC7B;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA,uBAAuB,iBAAiB;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gCAAgC,KAAK,GAAG,IAAI;AAC5C,cAAc;AACd;AACA,cAAc;AACd;AACA,cAAc;AACd;AACA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA,qCAAqC,oBAAoB,GAAG,IAAI;AAChE;AACA,UAAU;AACV,oCAAoC,oBAAoB;AACxD,UAAU;AACV;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,0CAA0C;AAC3D;AACA;AACA;AACA;AACA;AACA;AACA,yCAAyC,QAAQ;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,yBAAyB,IAAI,0BAA0B,KAAK;AAC5D;AACA,SAAS,qDAAqD;AAC9D;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA,+CAA+C,KAAK;AACpD;AACA,MAAM;AACN;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,QAAQ;AACnB;AACA;AACA;AACA,qBAAqB,0CAA0C;AAC/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB,OAAO;AACP,SAAS,6CAA6C,aAAa;AACnE,MAAM;AACN;AACA;AACA;AACA;AACA,qBAAqB;AACrB,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA,mBAAmB;AACnB,KAAK;;AAEL;AACA;;AAEA;AACA,kEAAkE,YAAY;AAC9E;AACA;AACA;AACA;AACA;AACA,iBAAiB,yBAAyB;AAC1C,uBAAuB;;AAEvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,mBAAmB;AACnB,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,2CAA2C,aAAa;AAC/D;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA,IAAI;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,QAAQ;AACnB;AACA;AACA,0CAA0C,YAAY;AACtD;AACA,8BAA8B;AAC9B;AACA,6BAA6B,4BAA4B;AACzD;AACA;;;;;;;;;;;;ACzoCA;AACA;AACA;AACa;;AAEb;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;AC/BA;AACA;AACA;AACa;;AAEb,aAAa,mBAAO,CAAC,iDAAQ;AAC7B,oBAAoB,mBAAO,CAAC,+DAAe;;AAE3C;AACA;AACA;AACA;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,mDAAS;;AAErB;AACA;AACA;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,+CAAO;;AAEnB;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,qDAAU;;AAEtB;AACA;AACA;AACA;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,iDAAQ;;AAEpB;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,MAAM,YAAY;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,SAAS,eAAe;;AAExB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,sCAAsC;AACjD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,gCAAgC;AACxD;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,iCAAiC;AACjC,+BAA+B,4CAA4C;AAC3E;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,6CAA6C;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,+CAA+C;AAC1D;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,QAAQ;AACR;AACA,QAAQ;AACR;AACA,mCAAmC;AACnC;AACA,iCAAiC,uCAAuC;AACxE;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA,mCAAmC;AACnC;AACA,iCAAiC,4CAA4C;AAC7E,QAAQ;AACR;AACA,mCAAmC;AACnC;AACA,iCAAiC,4CAA4C;AAC7E,QAAQ;AACR,+CAA+C,wBAAwB;AACvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA,mCAAmC;AACnC;AACA;AACA,WAAW,+CAA+C;AAC1D,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,mCAAmC;AACnC;AACA;AACA,WAAW,6CAA6C;AACxD;AACA;AACA;AACA,QAAQ;AACR;AACA,mCAAmC;AACnC;AACA;AACA,WAAW,6CAA6C;AACxD,QAAQ;AACR;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC;AACnC;AACA;AACA,WAAW,4CAA4C;AACvD;AACA;AACA;AACA,mCAAmC;AACnC;AACA,WAAW,oDAAoD;AAC/D;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,mCAAmC;AACnC;AACA;AACA,WAAW,4CAA4C;AACvD;AACA;AACA;AACA,mCAAmC;AACnC;AACA,WAAW,iDAAiD;AAC5D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA,mCAAmC;AACnC;AACA,WAAW,kDAAkD;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,iDAAiD;AAC9D;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,0BAA0B;AAC1B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb,YAAY;AACZ;AACA,uCAAuC;AACvC;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,QAAQ;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,oDAAoD;AAC3D;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iCAAiC;AACjC;AACA,SAAS,sDAAsD;AAC/D;AACA,IAAI;AACJ;AACA,+BAA+B;AAC/B;AACA,OAAO,sDAAsD;AAC7D,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,OAAO;AACP;AACA;AACA,IAAI;AACJ;AACA,+BAA+B;AAC/B;AACA,OAAO,mDAAmD;AAC1D;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa;AACb;;AAEA;AACA;AACA,+BAA+B;AAC/B;AACA;AACA,OAAO,mDAAmD;AAC1D;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,iCAAiC;AACjC;AACA,SAAS,mDAAmD;AAC5D;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,iCAAiC;AACjC;AACA,SAAS,oDAAoD;AAC7D;AACA;AACA;AACA,iCAAiC;AACjC;AACA,SAAS,oDAAoD;AAC7D;AACA;AACA;AACA;AACA,iCAAiC;AACjC,+BAA+B,+CAA+C;AAC9E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA,SAAS;AACT;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;;AAEA;AACA;AACA,2BAA2B,yBAAyB;AACpD;AACA;AACA;AACA,iCAAiC;AACjC;AACA,+BAA+B,+CAA+C;AAC9E;;AAEA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA,iCAAiC;AACjC;AACA,+BAA+B,+CAA+C;AAC9E;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA,SAAS;AACT;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA,MAAM;AACN;AACA;AACA,wBAAwB,yBAAyB;AACjD;AACA;AACA,mCAAmC;AACnC;AACA;AACA,WAAW,+CAA+C;AAC1D;;AAEA;AACA;AACA;AACA;AACA,4BAA4B,yBAAyB;AACrD;AACA;AACA;AACA,qCAAqC;AACrC;AACA;AACA,aAAa,+CAA+C;AAC5D;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;;AAEA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA,MAAM;AACN;AACA;AACA,MAAM;AACN;AACA;AACA;AACA,mCAAmC;AACnC;AACA,WAAW,qDAAqD;AAChE;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,iCAAiC;AACjC;AACA,SAAS,gDAAgD;AACzD;;AAEA;AACA;AACA;AACA,mCAAmC;AACnC,cAAc,KAAK;AACnB;AACA,WAAW,gDAAgD;AAC3D;AACA,MAAM;AACN;AACA;AACA,0BAA0B,yBAAyB;AACnD;AACA;AACA;AACA,mCAAmC;AACnC;AACA;AACA,WAAW,gDAAgD;AAC3D;AACA;AACA;AACA,mCAAmC;AACnC;AACA;AACA,WAAW,gDAAgD;AAC3D;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,qCAAqC;AACrC;AACA;AACA,aAAa,qDAAqD;AAClE;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA,qCAAqC;AACrC;AACA;AACA,aAAa,qDAAqD;AAClE;AACA,QAAQ;AACR;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,qCAAqC;AACrC;AACA;AACA,aAAa,gDAAgD;AAC7D;AACA;AACA,MAAM;AACN;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,iCAAiC;AACjC;AACA;AACA,SAAS,qDAAqD;AAC9D;;AAEA;AACA;AACA;AACA,iCAAiC;AACjC;AACA,SAAS,oDAAoD;AAC7D;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iCAAiC;AACjC,YAAY,gBAAgB,aAAa,KAAK;AAC9C,SAAS,mDAAmD;AAC5D;AACA;AACA;AACA,iCAAiC;AACjC,YAAY,gBAAgB,aAAa,KAAK;AAC9C,SAAS,mDAAmD;AAC5D;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iCAAiC;AACjC;AACA,SAAS,oDAAoD;AAC7D;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iCAAiC;AACjC;AACA,SAAS,mDAAmD;AAC5D;AACA;AACA;AACA,iCAAiC;AACjC;AACA,SAAS,mDAAmD;AAC5D;AACA;AACA;AACA,MAAM;AACN;AACA,iCAAiC;AACjC;AACA,SAAS,iDAAiD;AAC1D;AACA;;AAEA;AACA;AACA;AACA;AACA,iCAAiC;AACjC;AACA;AACA,SAAS,kDAAkD;AAC3D;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iCAAiC;AACjC;AACA;AACA,SAAS,+CAA+C;AACxD;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,+BAA+B;AAC/B,6BAA6B,iDAAiD;AAC9E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iCAAiC;AACjC;AACA,SAAS,6DAA6D;AACtE;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,QAAQ;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,QAAQ;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,OAAO;AACP;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B,uCAAuC;AACrE;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,oCAAoC;AACpC;AACA;AACA,cAAc;AACd;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;;AAEA;AACA;AACA;AACA,2BAA2B;AAC3B,uBAAuB;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA,UAAU;AACV;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA,iBAAiB,SAAS,GAAG,UAAU;AACvC,YAAY;AACZ;AACA,YAAY;AACZ,4DAA4D,UAAU;AACtE,YAAY;AACZ;AACA;AACA,UAAU;AACV;AACA;AACA,UAAU;AACV;AACA;AACA,kBAAkB,sBAAsB;AACxC,YAAY;AACZ;AACA;AACA,UAAU;AACV,0DAA0D,iBAAiB;AAC3E;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,eAAe;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACtkDA;AACA;AACA;AACa;;AAEb,OAAO,+BAA+B,EAAE,mBAAO,CAAC,kDAAS;AACzD,OAAO,qBAAqB,EAAE,mBAAO,CAAC,4DAAc;AACpD,oBAAoB,mBAAO,CAAC,gEAAgB;AAC5C,qBAAqB,mBAAO,CAAC,kEAAiB;AAC9C,OAAO,aAAa,EAAE,mBAAO,CAAC,gDAAQ;;AAEtC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA,EAAE,GAAG,YAAY;AACjB;AACA;AACA;;AAEA;AACA;AACA;AACA,wCAAwC;AACxC;AACA,8BAA8B,qCAAqC;AACnE;AACA;AACA;AACA,wCAAwC;AACxC;AACA,8BAA8B,qCAAqC;AACnE;;AAEA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA,SAAS,+CAA+C;AACxD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;;AAEA,eAAe;AACf;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,2CAA2C;AACtD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;;;;;;;;;;;ACpHA;AACA;AACA;AACa;;AAEb,oBAAoB,mBAAO,CAAC,+DAAe;;AAE3C;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,mDAAS;;AAErB;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,iDAAQ;;AAEpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,QAAQ;AACnB,MAAM,uBAAuB;AAC7B;AACA;AACA;AACA,0BAA0B,aAAa;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,QAAQ;AACnB,MAAM,QAAQ;AACd,MAAM,QAAQ;AACd,MAAM,QAAQ;AACd,MAAM,QAAQ;AACd,WAAW,QAAQ;AACnB,MAAM,OAAO;AACb;AACA;AACA;AACA;AACA,CAAC;AACD,WAAW,sCAAsC;AACjD;;AAEA,kBAAkB,gBAAgB;AAClC;AACA,iBAAiB,+BAA+B;AAChD;AACA;AACA;AACA,wBAAwB,yBAAyB;AACjD,MAAM;AACN,eAAe;AACf;AACA,QAAQ;AACR,MAAM;AACN;AACA,6BAA6B;AAC7B;AACA,UAAU;AACV,QAAQ;AACR;AACA;AACA,MAAM;AACN;AACA;AACA;AACA,SAAS,MAAM;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,kDAAkD,YAAY;AAC9D;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;;AAEA;AACA,gDAAgD,YAAY;AAC5D,wBAAwB,cAAc,IAAI,MAAM;AAChD;AACA;;AAEA;AACA,8DAA8D,YAAY;AAC1E;AACA,6BAA6B,cAAc,IAAI,MAAM;AACrD;AACA;AACA;;AAEA;AACA,4DAA4D,MAAM;AAClE;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,QAAQ;AACnB,MAAM,uBAAuB;AAC7B;AACA;AACA,uCAAuC,cAAc,IAAI;AACzD;AACA;;;;;;;;;;;;ACnLA;AACA;AACA;AACa;;AAEb,oBAAoB,mBAAO,CAAC,+DAAe;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,mDAAS;;AAErB;AACA;AACA;AACA;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,6DAAc;;AAE1B;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,uDAAW;;AAEvB;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,+CAAO;;AAEnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,iDAAQ;;AAEpB;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,qDAAU;;AAEtB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;;AAEA;AACA;AACA,8BAA8B,YAAY,eAAe;AACzD;;AAEA;AACA;AACA;AACA,6CAA6C,YAAY;AACzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA,yBAAyB,mDAAmD;AAC5E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,oBAAoB;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA,aAAa;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,gCAAgC,YAAY;;AAE5C;AACA;AACA;;AAEA,sEAAsE;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iCAAiC,YAAY;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA,OAAO,kDAAkD;AACzD;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,yDAAyD,YAAY;AACrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iCAAiC;AACjC;AACA,+BAA+B,4CAA4C;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iCAAiC;AACjC;AACA;AACA,+BAA+B,4CAA4C;AAC3E;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA,SAAS;AACT;AACA;AACA,MAAM;AACN;AACA;AACA;AACA,iCAAiC;AACjC;AACA,SAAS,qDAAqD;AAC9D,MAAM;AACN;AACA;AACA;AACA,iCAAiC;AACjC;AACA,+BAA+B,2CAA2C;AAC1E;AACA,IAAI;AACJ;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA,iCAAiC;AACjC;AACA;AACA,SAAS,kDAAkD;AAC3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B,4BAA4B;AAC1D;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;AACA,2DAA2D,IAAI;AAC/D;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA,QAAQ;AACR;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO,YAAY;AACnB;AACA;AACA,OAAO;;AAEP;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,yDAAyD,YAAY;;AAErE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA,mCAAmC;AACnC;AACA,WAAW,4CAA4C;AACvD;AACA;AACA;AACA;AACA;AACA,mCAAmC;AACnC;AACA,WAAW,sDAAsD;AACjE;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,qCAAqC;AACrC,mCAAmC,iCAAiC;AACpE;AACA;AACA;AACA;AACA;AACA,uCAAuC;AACvC;AACA,qCAAqC,iCAAiC;AACtE;AACA,UAAU;AACV;AACA;AACA,uCAAuC;AACvC;AACA,qCAAqC,iCAAiC;AACtE;AACA,UAAU;AACV;AACA,qCAAqC;AACrC;AACA,mCAAmC,iCAAiC;AACpE;AACA;;AAEA;AACA;AACA;AACA;AACA,iDAAiD,WAAW;AAC5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA,mBAAmB;AACnB,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA,mBAAmB;AACnB;AACA,gBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB;AACnB;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,SAAS,iCAAiC;AAC1C;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,4CAA4C,YAAY;AACxD;AACA,+CAA+C,wBAAwB;AACvE,eAAe,gCAAgC;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,wBAAwB;AACvC,eAAe,gCAAgC;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB;AACnB;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,SAAS,mCAAmC;AAC5C;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;;AAEP;AACA;AACA;AACA,mCAAmC;AACnC;AACA,iCAAiC,uCAAuC;AACxE;;AAEA;AACA,sDAAsD,sBAAsB;AAC5E;AACA;;AAEA;AACA;AACA;AACA;AACA,iCAAiC;AACjC;AACA,+BAA+B,oCAAoC;AACnE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA,4CAA4C,iCAAiC;AAC7E;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC;AACnC;AACA,WAAW,8CAA8C;AACzD;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA,aAAa;AACb;AACA;AACA;;AAEA;AACA,6CAA6C,iCAAiC;AAC9E;AACA;;AAEA;AACA;AACA;AACA;AACA,mCAAmC;AACnC;AACA,WAAW,sCAAsC;AACjD;;AAEA;;AAEA;AACA;AACA;AACA;AACA,qCAAqC;AACrC;AACA,aAAa,sCAAsC;AACnD;AACA;;AAEA;AACA;AACA,SAAS,iCAAiC;AAC1C;AACA;;AAEA;AACA;AACA;AACA;AACA,mCAAmC;AACnC;AACA,WAAW,oCAAoC;AAC/C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,mCAAmC;AACnC,iCAAiC,sCAAsC;AACvE;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA,aAAa,sBAAsB;AACnC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6CAA6C,sBAAsB;AACnE;AACA,wBAAwB,mBAAmB;AAC3C;AACA;AACA;AACA,uCAAuC;AACvC;AACA,eAAe,6DAA6D;AAC5E;AACA,iDAAiD,sBAAsB;AACvE;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;;AAEA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA,yCAAyC,YAAY;;AAErD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,uBAAuB;AACvB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,yBAAyB;AAC7D,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C,sBAAsB;AACrE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,2BAA2B;AACjD;AACA;AACA;AACA,qCAAqC;AACrC;AACA,aAAa,6DAA6D;AAC1E;AACA,uDAAuD,sBAAsB;AAC7E;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA,iCAAiC;AACjC;AACA;AACA,SAAS,2DAA2D;AACpE;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,kCAAkC,YAAY;AAC9C;AACA,mCAAmC;AACnC;AACA,WAAW,uCAAuC;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,QAAQ;AACnB;AACA;AACA;AACA,uBAAuB,0CAA0C;AACjE;AACA;AACA;AACA;;AAEA;AACA;AACA,gCAAgC,YAAY;AAC5C;AACA,yCAAyC,WAAW;AACpD,IAAI;AACJ,yCAAyC,wBAAwB;AACjE,OAAO,gCAAgC;AACvC;;AAEA;AACA;;AAEA;AACA;AACA,wDAAwD,WAAW;AACnE,sDAAsD;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA,SAAS;AACT;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA,2CAA2C,wBAAwB;AACnE;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,QAAQ;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oDAAoD,YAAY;AAChE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC;AACnC;AACA,WAAW,gDAAgD;AAC3D;AACA,mBAAmB;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA,WAAW,yDAAyD;AACpE;AACA,MAAM;AACN,gDAAgD,YAAY;AAC5D;;AAEA;AACA;AACA,wCAAwC,WAAW;AACnD,MAAM;AACN;AACA;;AAEA;AACA;AACA;AACA,gBAAgB;AAChB;AACA;AACA;AACA;AACA,UAAU;AACV;AACA,UAAU;AACV;AACA;AACA,QAAQ;AACR;AACA;AACA,mCAAmC;AACnC,sBAAsB,SAAS;AAC/B;AACA,WAAW,0CAA0C;AACrD,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;AChwCA;AACA;AACA;AACa;;AAEb;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,6DAAc;;AAE1B;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,uDAAW;;AAEvB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,kBAAkB,kBAAkB;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACrCA;AACA;AACA;AACa;;AAEb,OAAO,WAAW,EAAE,mBAAO,CAAC,uDAAW;AACvC,mBAAmB,mBAAO,CAAC,6DAAc;AACzC,cAAc,mBAAO,CAAC,mDAAS;AAC/B,aAAa,mBAAO,CAAC,iDAAQ;AAC7B,YAAY,mBAAO,CAAC,+CAAO;AAC3B,oBAAoB,mBAAO,CAAC,+DAAe;AAC3C;AACA;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,uDAAW;;AAEvB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,eAAe;AAC9B;AACA,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,4BAA4B;AAC5B,MAAM;AACN;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,oBAAoB;AACpB;AACA,iDAAiD,sBAAsB;AACvE;AACA;;AAEA;AACA;AACA;AACA,iCAAiC;AACjC,+BAA+B,oCAAoC;AACnE;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,2CAA2C;;AAE3C;AACA,6BAA6B,4BAA4B;;AAEzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,qCAAqC;AAChD;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS,0BAA0B;AACnC;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,+CAA+C,sBAAsB;AACrE;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,wBAAwB;AACxB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,yBAAyB;AAC1C;AACA,cAAc;AACd;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA,aAAa,yBAAyB;AACtC;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB,sBAAsB;AAC/C;AACA;;AAEA;AACA;AACA,gEAAgE;AAChE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kDAAkD,sBAAsB;AACxE;AACA,aAAa,yBAAyB;AACtC;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC;AACnC;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uCAAuC,QAAQ;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA,MAAM;AACN;AACA;AACA,iCAAiC;AACjC,+BAA+B,oCAAoC;AACnE;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B;AAC/B,6BAA6B,MAAM;AACnC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC;AACnC,iCAAiC,6BAA6B;AAC9D;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC;AACnC,iCAAiC,6BAA6B;AAC9D;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,2DAA2D;AAC3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,kDAAkD;AAClD;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA,UAAU;AACV;AACA;AACA,UAAU;AACV;AACA,UAAU;AACV;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,mBAAmB;;AAEnB;AACA;AACA;AACA,mBAAmB,mBAAmB;AACtC;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA,iDAAiD,0BAA0B;AAC3E,8CAA8C,0BAA0B;AACxE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6CAA6C,sBAAsB;AACnE,IAAI;AACJ;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,gCAAgC;AAChC;AACA;AACA,oCAAoC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACzzBA;AACA;AACA;AACa;;AAEb,oBAAoB,mBAAO,CAAC,+DAAe;AAC3C,mBAAmB,mBAAO,CAAC,6DAAc;AACzC,cAAc,mBAAO,CAAC,mDAAS;;AAE/B;AACA;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,iDAAQ;;AAEpB;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,qDAAU;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,2DAAa;;AAEzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,oBAAoB;AAC7B,MAAM;AACN;AACA;AACA;AACA,SAAS,oBAAoB;AAC7B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B;AAC5B;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,oBAAoB;AACpB;AACA;;AAEA;AACA;AACA,0BAA0B;AAC1B;;AAEA;AACA,yCAAyC,sBAAsB;AAC/D;AACA;;AAEA;AACA,+BAA+B,sBAAsB;;AAErD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,QAAQ;AACR;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B;AAC5B;AACA;AACA,oBAAoB,mBAAmB;AACvC;;AAEA;AACA;AACA;AACA;;AAEA;AACA,sBAAsB;AACtB;AACA;;AAEA;AACA;AACA,4BAA4B;AAC5B;;AAEA;AACA,2CAA2C,sBAAsB;AACjE;AACA;;AAEA;AACA,iCAAiC,sBAAsB;;AAEvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX,UAAU;AACV;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,iDAAiD;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY;AACZ;;AAEA;AACA,gBAAgB;;AAEhB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA,SAAS;AACT;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA,WAAW,8DAA8D;AACzE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;;AAEA;AACA;;;;;;;;;;;;AC9YA;AACA;AACA;AACa;;AAEb,cAAc,mBAAO,CAAC,mDAAS;;AAE/B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;ACvHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oDAAoD;AACpD,YAAY;AACZ;AACA;AACA;AACA;AACA,iBAAiB,mBAAO,CAAC,0DAAc;AACvC,iBAAiB,mBAAO,CAAC,iEAAY;AACrC,aAAa,mBAAO,CAAC,iDAAQ;AAC7B,wBAAwB,mBAAO,CAAC,uEAAmB;AACnD;AACA,oBAAoB,mBAAO,CAAC,+DAAe;AAC3C,YAAY,mBAAO,CAAC,oDAAW;AAC/B,eAAe,mBAAO,CAAC,qDAAU;;AAEjC,OAAO,iBAAiB,EAAE,mBAAO,CAAC,qDAAU;AAC5C,OAAO,mBAAmB,EAAE,mBAAO,CAAC,uDAAW;AAC/C,OAAO,mBAAmB,EAAE,mBAAO,CAAC,uDAAW;AAC/C,OAAO,eAAe,EAAE,mBAAO,CAAC,mDAAS;;AAEzC;AACA;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,mDAAS;;AAErB;AACA;AACA;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,mDAAS;;AAErB;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,6DAAc;;AAE1B;AACA;AACA;AACA;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,uDAAW;;AAEvB;AACA;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,uDAAW;;AAEvB;AACA;AACA;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,uDAAW;;AAEvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,qDAAU;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,uCAAuC,qCAAqC;;AAE5E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,8BAA8B,8BAA8B;AAC5D;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,mCAAmC;AAC1C,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,6CAA6C;AAC7C,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO,mCAAmC;AAC1C,GAAG;;AAEH;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN,iCAAiC;AACjC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA,iCAAiC;AACjC;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,uCAAuC,6BAA6B;AACpE;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,IAAI;AACJ;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO,mCAAmC;AAC1C,GAAG;;AAEH;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,mCAAmC;AAC1C,GAAG;;AAEH;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;;AAEA,uDAAuD;;AAEvD;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,gBAAgB;AAChB;AACA;AACA;;AAEA;AACA;AACA;AACA,4CAA4C,YAAY;AACxD;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,mCAAmC;AAC1C,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,gBAAgB;AAChB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;;AAEH,SAAS,QAAQ;AACjB,OAAO,WAAW;;AAElB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iCAAiC,OAAO;AACxC;AACA,IAAI;AACJ;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,mCAAmC;AAC1C,GAAG;;AAEH;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B,uBAAuB;AACtD;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO,mCAAmC;AAC1C,GAAG;;AAEH;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uCAAuC;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,IAAI;AACJ;AACA;;AAEA;AACA;AACA;AACA,OAAO,mCAAmC;AAC1C,GAAG;;AAEH;AACA;AACA,kBAAkB;AAClB;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA,kBAAkB;;AAElB,iBAAiB,qBAAqB;AACtC;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA,wDAAwD;AACxD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,kBAAkB,kBAAkB;AACpC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;AACA;AACA,KAAK,qCAAqC;AAC1C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,mCAAmC;AAC1C,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,gBAAgB;AAChB;;AAEA,0BAA0B,6BAA6B;AACvD;;AAEA;AACA,yBAAyB,8FAAoC;;AAE7D;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,KAAK;AACZ;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,aAAa,mBAAO,CAAC,+CAAO;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,sBAAsB,mBAAO,CAAC,iEAAgB;;AAE9C;AACA,yBAAyB,mBAAO,CAAC,uEAAmB;;AAEpD;AACA;;AAEA;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN,KAAK,eAAe;AACpB;AACA;AACA,KAAK,kCAAkC,QAAQ;AAC/C;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;;;;;;;;;;;;AC7iCA;AACA;AACA;AACa;;AAEb,OAAO,WAAW,EAAE,mBAAO,CAAC,uDAAW;AACvC,mBAAmB,mBAAO,CAAC,6DAAc;AACzC,cAAc,mBAAO,CAAC,mDAAS;AAC/B,aAAa,mBAAO,CAAC,iDAAQ;AAC7B,oBAAoB,mBAAO,CAAC,+DAAe;;AAE3C;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,kBAAkB;AAClB;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA,eAAe,eAAe;AAC9B;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,YAAY;AAC3B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,8BAA8B;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,6CAA6C;AAC1D;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC;AACnC;AACA,WAAW,qCAAqC;AAChD;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,4CAA4C,sBAAsB;AAClE;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,8BAA8B,UAAU;AACxC,WAAW,6CAA6C;AACxD;AACA,QAAQ;AACR;AACA;AACA,WAAW,6CAA6C;AACxD,QAAQ;AACR;AACA;AACA;AACA,aAAa;AACb;AACA;AACA,WAAW,6CAA6C;AACxD,QAAQ;AACR;AACA;AACA;AACA,iCAAiC,6CAA6C;AAC9E;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA,eAAe,6CAA6C;AAC5D;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACjSA;AACA;AACA;AACa;;AAEb,kBAAkB,mBAAO,CAAC,+EAAuB;;AAEjD;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;;;;;;;;;;;ACtCA;AACA;AACA;AACa;;AAEb,OAAO,eAAe,EAAE,mBAAO,CAAC,uDAAW;AAC3C,OAAO,WAAW,EAAE,mBAAO,CAAC,uDAAW;AACvC,mBAAmB,mBAAO,CAAC,6DAAc;AACzC,yBAAyB,mBAAO,CAAC,qEAAc;AAC/C,oBAAoB,mBAAO,CAAC,+DAAe;AAC3C,cAAc,mBAAO,CAAC,mDAAS;AAC/B,aAAa,mBAAO,CAAC,iDAAQ;;AAE7B;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,qDAAU;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,2DAAa;;AAEzB;AACA;AACA,EAAE,EAAE,mBAAO,CAAC,+CAAO;;AAEnB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB;AACnB;;AAEA;AACA;AACA;AACA;AACA;AACA,mBAAmB;AACnB,MAAM;AACN;AACA,qBAAqB;AACrB,QAAQ;AACR,qBAAqB;AACrB;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA,aAAa;AACb;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA,aAAa;AACb;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA,aAAa;AACb;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB,gBAAgB;AAChB,eAAe;;AAEf;AACA;AACA,yBAAyB,8CAA8C;AACvE;;AAEA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA,MAAM;AACN;AACA;AACA,qDAAqD,SAAS,GAAG,UAAU;AAC3E;AACA;AACA,MAAM;AACN;AACA;AACA;AACA,SAAS,oBAAoB;AAC7B,MAAM;AACN;AACA;AACA;AACA,SAAS,oBAAoB;AAC7B,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,OAAO;AACP;AACA;AACA;;AAEA;AACA;;;;;;;;;;;;ACrZA;AACA;AACA;AACa;;AAEb;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;AC3FA;AACA;AACA;AACa;;AAEb,cAAc,mBAAO,CAAC,mDAAS;;AAE/B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,IAAI;AACJ;;AAEA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA,MAAM;AACN;AACA;AACA;AACA,QAAQ;AACR;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,yBAAyB;AAC5C;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;AC5SA;AACA;AACA;AACa;;AAEb,mBAAmB,mBAAO,CAAC,6DAAc;AACzC,cAAc,mBAAO,CAAC,mDAAS;AAC/B;AACA,yBAAyB,kGAAwC;AACjE,oBAAoB,mBAAO,CAAC,+DAAe;;AAE3C;AACA,+BAA+B,IAAI,cAAc,IAAI;AACrD;AACA,+CAA+C;AAC/C;AACA,8CAA8C;AAC9C;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,kBAAkB;AACvC;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gCAAgC;AAChC;AACA;;AAEA;AACA;AACA,2CAA2C;AAC3C;AACA;;AAEA,wBAAwB,gCAAgC;AACxD;;AAEA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,oBAAoB;AACrC;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,6BAA6B;AAC7B;AACA;AACA,KAAK,qCAAqC;AAC1C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,gBAAgB;AACrC;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,kBAAkB;AACrC;AACA;AACA,IAAI;AACJ;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,IAAI;AACJ;AACA,IAAI;AACJ;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,oBAAoB;AACvC;AACA;AACA,IAAI;AACJ;AACA,IAAI;AACJ;AACA;AACA;AACA;;AAEA;AACA;AACA,oBAAoB,kBAAkB;AACtC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;;;;;;;;;;ACtcY;;AAEZ;AACA,gBAAgB,mBAAO,CAAC,kDAAS;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;;AAElB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,4BAA4B;;AAE5B,kBAAkB;AAClB,qBAAqB;;AAErB;AACA;AACA,2CAA2C,gBAAgB;AAC3D;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,2CAA2C,gBAAgB;AAC3D;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,iCAAiC,QAAQ;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,kDAAkD;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;AC7UA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6FAAiC;;;;;;;;;;;;ACPjC;AACA;AACA;AACa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,4BAA4B;AACvC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;AC/EA;AACA;AACA;AACa;;AAEb,mBAAO,CAAC,iEAAc;;AAEtB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB;AACxB,MAAM;AACN,wBAAwB;AACxB,MAAM;AACN,gDAAgD,UAAU;AAC1D;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,mBAAmB;AACtC;AACA;AACA;AACA;AACA;;;;;;;;;;;;AC9CA;AACA;AACA;AACa;;AAEb;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA,oBAAoB;;AAEpB;AACA;AACA,wBAAwB;AACxB,QAAQ;AACR,wBAAwB;AACxB;;AAEA;AACA,wBAAwB;;AAExB;AACA;AACA,uBAAuB;AACvB,QAAQ;AACR,uBAAuB;AACvB,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA,cAAc,QAAQ;AACtB;AACA;AACA;;AAEA;AACA;AACA,mBAAmB,QAAQ;AAC3B,MAAM;AACN,kBAAkB,QAAQ;AAC1B;;AAEA;AACA,kBAAkB,QAAQ;;AAE1B;AACA;AACA,mBAAmB,QAAQ;AAC3B,MAAM;AACN;AACA,MAAM;AACN,mBAAmB,iBAAiB;AACpC;AACA;AACA,uBAAuB,WAAW;AAClC;AACA,QAAQ;AACR,uBAAuB,iBAAiB;AACxC;AACA;;AAEA;AACA;AACA;AACA,oBAAoB,QAAQ;AAC5B,MAAM;AACN,mBAAmB,QAAQ;AAC3B;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA,0CAA0C,EAAE,sBAAsB,EAAE;AACpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;;;;;;;;;;;AClZA;AACA;AACA;AACa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,iBAAiB;AACpC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,cAAc;AACzB;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,mBAAmB,YAAY;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;;;;;;;;;;;AClFA;AACA;AACA;AACa;;AAEb,yBAAyB,mBAAO,CAAC,+EAAoB;AACrD,sBAAsB,mBAAO,CAAC,iFAAiB;AAC/C,iBAAiB,mBAAO,CAAC,+DAAY;AACrC,eAAe,mBAAO,CAAC,2DAAU;;AAEjC;AACA;AACA;AACA;AACA;AACA,IAAI,IAAI;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC,8BAA8B;AAChE,kCAAkC,6BAA6B;AAC/D,kCAAkC,4BAA4B;AAC9D;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,wCAAwC;AACxC;AACA,4BAA4B;AAC5B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yCAAyC,qBAAqB;AAC9D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA,MAAM;AACN;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,oCAAoC,uBAAuB;AAC3D;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,mBAAmB;AACnB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,sBAAsB,YAAY;;AAElC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,mBAAmB;AACnB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,YAAY;AACZ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,qBAAqB;AACpC;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;;AAEA,gCAAgC,qBAAqB;AACrD;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;;AAEA,yBAAyB,gBAAgB;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN,kCAAkC,mCAAmC;AACrE;AACA;;AAEA;AACA,KAAK,qDAAqD;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;;;;;;;;;;;AC/gBA;AACA;AACA;AACa;;AAEb,yBAAyB,mBAAO,CAAC,+EAAoB;AACrD,yBAAyB;AACzB;AACA,sBAAsB,mBAAO,CAAC,iFAAiB;AAC/C,iBAAiB,mBAAO,CAAC,+DAAY;AACrC,eAAe,mBAAO,CAAC,2DAAU;;AAEjC;AACA;AACA;AACA;AACA;AACA,IAAI,IAAI;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC,8BAA8B;AAChE,kCAAkC,6BAA6B;AAC/D,kCAAkC,4BAA4B;AAC9D;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,wCAAwC;AACxC;AACA,4BAA4B;AAC5B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC,qBAAqB;AACxD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,wBAAwB;AAChE;AACA,wCAAwC,uBAAuB;AAC/D,wCAAwC,sBAAsB;AAC9D;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA,MAAM;AACN;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,oCAAoC,uBAAuB;AAC3D;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,mBAAmB;AACnB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,sBAAsB,YAAY;;AAElC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,mBAAmB;AACnB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,YAAY;AACZ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,qBAAqB;AACpC;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;;AAEA,0BAA0B,qBAAqB;AAC/C;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;;AAEA,yBAAyB,gBAAgB;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN,kCAAkC,mCAAmC;AACrE;AACA;;AAEA;AACA,KAAK,qDAAqD;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;;AAEA;AACA,6BAA6B,UAAU;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;;;;;;;;;;;AC3fA;AACA;AACA;AACa;;AAEb,sBAAsB,mBAAO,CAAC,iFAAiB;AAC/C,kBAAkB,mBAAO,CAAC,iEAAa;;AAEvC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;;AAEA;AACA;AACA;;;;;;;;;;;;AC1FA;AACA;AACA;AACa;;AAEb,sBAAsB,mBAAO,CAAC,iFAAiB;AAC/C,sBAAsB,mBAAO,CAAC,yEAAiB;;AAE/C;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;;AAEA;AACA;AACA;;;;;;;;;;;;ACpFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oDAAoD;AACpD,YAAY;AACZ;AACA;AACA;AACA;AACa;;AAEb,kBAAkB,mBAAO,CAAC,iEAAa;AACvC,kBAAkB,mBAAO,CAAC,iEAAa;AACvC,sBAAsB,mBAAO,CAAC,yEAAiB;AAC/C,sBAAsB,mBAAO,CAAC,yEAAiB;;AAE/C;AACA;AACA;AACA,sBAAsB,mBAAO,CAAC,kCAAqB;AACnD,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,iGAAoC;AACpC,+HAAwD;;AAExD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,qBAAqB;AAChC;AACA,WAAW,QAAQ;AACnB,MAAM,QAAQ;AACd;AACA,MAAM,UAAU;AAChB;AACA,sDAAsD;AACtD;AACA;AACA,MAAM,KAAK;AACX;AACA;AACA,MAAM,SAAS;AACf,MAAM,QAAQ;AACd;AACA,oEAAoE;AACpE;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB;AAChB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,WAAW,qBAAqB;AAChC;AACA,WAAW,QAAQ;AACnB,MAAM,QAAQ;AACd;AACA,MAAM,UAAU;AAChB;AACA,sDAAsD;AACtD;AACA;AACA,MAAM,SAAS;AACf,MAAM,QAAQ;AACd;AACA,oEAAoE;AACpE;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;AC1La;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;;AAEA;AACA,EAAE,oCAAoC;AACtC,EAAE,uCAAuC;AACzC,EAAE,qCAAqC;AACvC,EAAE;AACF;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,iDAAiD;;AAEjD;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;;AAEA;AACA;;AAEA,aAAa,sBAAsB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;;AAEA;AACA;;AAEA,2CAA2C;AAC3C,QAAQ,qCAAqC;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA,uBAAuB,4BAA4B;AACnD;;AAEA;AACA;;AAEA,6CAA6C;AAC7C,QAAQ,qCAAqC;;AAE7C;AACA;AACA;;AAEA;AACA,gCAAgC;AAChC;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;;;;;;;;;;ACzJA;AACA;;AAEA;AACA;AACA;;AAEA,wBAAwB;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,iBAAiB;AACvC;AACA;AACA;AACA,mBAAmB;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,2CAA2C,uBAAuB;AAClE;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,UAAU;AACV;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,0CAA0C;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,UAAU;AACV;AACA;;AAEA,MAAM;AACN;AACA;;AAEA,MAAM;AACN;AACA;;AAEA,MAAM;AACN;AACA;;AAEA,MAAM;AACN;AACA;AACA;;AAEA;AACA;AACA,CAAC,sCAAsC,qBAAM,0BAA0B,qBAAM;;;;;;;;;;;;ACzLjE;AACZ;AACA;AACA,iCAAiC,QAAQ;AACzC;AACA;AACA;AACA;;;;;;;;;;;;ACPY;AACZ;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL,IAAI;AACJ,0CAA0C,OAAO;AACjD;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,wCAAwC,OAAO;AAC/C;AACA;AACA;AACA;;AAEA;AACA,wCAAwC,OAAO;AAC/C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,sCAAsC,iBAAiB;AACvD;AACA;AACA;AACA;;AAEA;AACA;AACA,oDAAoD,iBAAiB;AACrE;AACA;AACA;AACA;;AAEA;AACA,sCAAsC,0BAA0B;AAChE;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sCAAsC,0BAA0B;AAChE;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,+BAA+B,gBAAgB;AAC/C;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,+BAA+B,gBAAgB;AAC/C;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA,IAAI;AACJ;AACA;;AAEA,kBAAkB,iBAAiB;AACnC;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA,IAAI;AACJ;AACA;;AAEA,gCAAgC,iBAAiB;AACjD;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,sCAAsC,iBAAiB;AACvD;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,sCAAsC,iBAAiB;AACvD;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC,6BAA6B;AACnE;AACA;AACA,SAAS,2BAA2B;AACpC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gDAAgD,2BAA2B;AAC3E;AACA;AACA,SAAS,6BAA6B;AACtC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,sCAAsC,8BAA8B;AACpE;AACA;;AAEA;AACA,kBAAkB,2BAA2B;AAC7C;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,kBAAkB,kBAAkB;AACpC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,0BAA0B,iBAAiB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,IAAI;AACJ;AACA;;AAEA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;;AAEA;AACA;AACA,EAAE,mBAAO,CAAC,yDAAe;AACzB,EAAE;;;;;;;;;;;ACzaF;;;;;;;;;;ACAA;;;;;;;;;;;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,iEACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA,KAAK;;AAEL;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,EAAC;;;;;;;;;;;;;;;;;;;;;ACzUF;AACA;AACA;AACmC;;AAE5B;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACO;AACP,oCAAoC,mDAAO;;AAE3C;AACO;AACP;;AAEO,gBAAgB,mDAAO;AACvB;;;;;;;;;;;;;;;;;;;;;ACzBP;AACA;AACA;AAC8C;AACG;AACf;AACI;AACS;;AAE/C,OAAO,SAAS,kBAAkB,EAAE,8CAAK;;AAEzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEO;AACP,eAAe,kDAAkD,IAAI;AACrE,WAAW,iBAAiB;AAC5B;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC,KAAK;AACxC;AACA,MAAM;AACN;AACA;;AAEA,wCAAwC,0BAA0B;AAClE;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,mBAAmB;AAChC;AACA,aAAa,QAAQ;AACrB;AACA;AACA,eAAe,iBAAiB;AAChC;AACA;AACA,cAAc,kBAAkB;AAChC;AACA;AACA;;AAEA,mDAAmD,iBAAiB;AACpE;AACA,mCAAmC,oDAAgB;;AAEnD;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,mBAAmB;AAChC;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA,eAAe,kBAAkB;AACjC;AACA,yBAAyB,sCAAsC;AAC/D,gDAAgD,mBAAmB;AACnE;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,4BAA4B,oBAAoB;AAChD;AACA,YAAY,oBAAoB;AAChC,mDAAmD,mBAAmB;AACtE,WAAW,cAAc;AACzB;AACA;;AAEA,WAAW,YAAY;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,oDAAgB;AAClC,MAAM;AACN,kBAAkB,uDAAgB;AAClC,MAAM;AACN;AACA;AACA;AACA,4BAA4B,4BAA4B;AACxD;;AAEA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB,aAAa,UAAU;AACvB;AACA,eAAe,iBAAiB;AAChC;AACA,qBAAqB,4CAA4C;AACjE;AACA;AACA;AACA;AACA,eAAe;AACf,MAAM;AACN;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,6CAAY;AACzB;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL,0CAA0C;AAC1C;AACA;AACA,cAAc,sCAAsC;;AAEpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,MAAM;AACN;AACA,SAAS,0CAA0C;AACnD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,MAAM;AACN;AACA;AACA,SAAS,sDAAsD;AAC/D;;AAEA;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB,aAAa,UAAU;AACvB;AACA,eAAe,iBAAiB;AAChC;AACA;AACA,gBAAgB,4CAA4C;AAC5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA,eAAe,iBAAiB;AAChC;AACA,qBAAqB,MAAM;AAC3B;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB,aAAa,QAAQ;AACrB,aAAa,UAAU;AACvB;AACA,eAAe,SAAS,OAAO,GAAG;AAClC;AACA,qBAAqB,0CAA0C;AAC/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,QAAQ;AACR;AACA,WAAW,0CAA0C;AACrD;;AAEA;AACA;AACA;AACA,OAAO;;AAEP;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;;AAEA,cAAc;AACd,MAAM;AACN,cAAc;AACd;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,UAAU;AACvB;AACA,eAAe,4BAA4B;AAC3C;AACA;AACA,0BAA0B,gCAAgC;AAC1D;AACA;AACA,WAAW,YAAY;AACvB;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA,mCAAmC,eAAe;AAClD,kCAAkC,8DAAY,EAAE,qBAAqB;AACrE;AACA;;AAEA;AACA;AACA;AACA,iCAAiC,yBAAyB;AAC1D,kCAAkC,8DAAY,EAAE,yBAAyB;AACzE;AACA;AACA;AACA,WAAW,4CAAW;AACtB;;AAEA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA,aAAa,UAAU;AACvB;AACA,eAAe,QAAQ;AACvB;AACA,+BAA+B,sBAAsB;AACrD,SAAS,oBAAoB;;AAE7B;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,+CAA+C,mBAAmB;AAClE;;AAEA,WAAW,UAAU;AACrB;AACA;AACA;AACA;;AAEA,8BAA8B,yBAAyB;AACvD;AACA;AACA;AACA;AACA;AACA,6BAA6B,uCAAuC;AACpE;AACA,iCAAiC,qCAAqC;AACtE;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA,eAAe,kBAAkB;AACjC;AACA;AACA;AACA,GAAG;AACH,WAAW,mBAAmB;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,SAAS;AACtB;AACA,sBAAsB,0BAA0B;AAChD,WAAW,YAAY;;AAEvB,yBAAyB,qBAAqB;AAC9C,wBAAwB,qCAAqC;AAC7D;AACA;AACA;;AAEA;AACA;AACA;AACA,cAAc,WAAW;AACzB;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB;AACA,aAAa,SAAS;AACtB;AACA,2BAA2B,qBAAqB;AAChD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB,WAAW,cAAc;AACzB,cAAc;AACd,cAAc,kDAAkD;AAChE;AACA;AACA,kCAAkC,0BAA0B;AAC5D;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,0BAA0B,oBAAoB;AAC9C;AACA,UAAU,oBAAoB;AAC9B,+CAA+C,iBAAiB;AAChE,SAAS,cAAc;AACvB;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;;;;;;;;;;;ACpeA;AACA;AACA;AAC2D;;AAE/B;;;;;;;;;;;;;;;;ACL5B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,QAAQ;AACnB;AACA,aAAa,YAAY;AACzB;AACO,6BAA6B,OAAO;AAC3C;AACA;AACA;;;;;;;;;;;;;;;;;;ACfA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,oBAAoB;AAC/B;AACA,aAAa,QAAQ;AACrB;AACO;AACP;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,YAAY;AACvB,WAAW,YAAY;AACvB;AACA,aAAa,YAAY;AACzB;AACO;AACP;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;ACnCA;AACA;AACA;;AAEA;AACO;AACP;AACA;AACO;AACP;AACA;AACO;AACP;AACO;AACP;AACO;AACP;AACO;AACP;AACO;AACP;AACO;;;;;;;;;;;;;;;;;;;;;;ACrBP;AACA;AACA;AAC0C;AACK;;AAE/C;AACA;AACA;AACA;AACA;;AAEO;AACP,EAAE,8DAAc;AAChB;AACA;AACA,GAAG;AACH,0BAA0B,wDAAoB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEO;AACP,SAAS,gDAAY;AACrB;;AAEO;AACP,SAAS,kDAAc;AACvB;;AAEO,6BAA6B,KAAK;AACzC;AACA;;;;;;;;;;;;;;;;;;AC7CA;AACA;AACA;AACwC;;AAExC;;AAEO,uBAAuB,cAAc;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,KAAK;AACrB,aAAa,6CAAY;AACzB,KAAK;AACL;AACA;;AAEO,yBAAyB,cAAc;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,gBAAgB;AAClC,aAAa,+CAAc;AAC3B,KAAK;AACL;AACA;;;;;;;;;;;;;;;;;;;AC/BA;AACA;AACA;AAC8C;AAKtB;;AAEjB,0BAA0B,QAAQ;AACzC;AACA;AACA;AACA,MAAM,gEAAqB;AAC3B;AACA;AACA;AACA,MAAM,iEAAsB;AAC5B;AACA;AACA;;AAEO,0BAA0B,uCAAuC;AACxE;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B,oDAAgB;AAC9C;AACA,8CAA8C,gEAAqB;;AAEnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gCAAgC,oDAAgB;AAChD;AACA,0CAA0C,iEAAsB;AAChE;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA,SAAS,qEAA0B,GAAG,oDAAgB;AACtD;;;;;;;;;;;;;;;;;;;;;;;;;;AC7DA;AACA;AACA;AACiD;AACT;AACkB;AAKlC;AACgD;AAC3B;AACK;;AAE3C,yBAAyB,sBAAsB,IAAI;AAC1D;AACA;AACA,gBAAgB,gEAA+B;AAC/C,IAAI;AACJ,gBAAgB,wDAAuB;AACvC;;AAEA,SAAS,wCAAwC,EAAE,4DAAe;AAClE;AACA,GAAG;AACH;AACA,YAAY,WAAW,GAAG,mBAAmB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC,QAAQ;AAC1C;;AAEA;AACO;AACP,kBAAkB;AAClB;AACA;AACA;AACA,sBAAsB,6CAA6C;AACnE;AACA;AACA,uBAAuB,iEAAU,EAAE,kBAAkB;AACrD,sCAAsC,kBAAkB;AACxD;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,kEAAuB;AAClD;;AAEA;AACA,kCAAkC,kBAAkB;AACpD;;AAEA;AACO,wBAAwB,wBAAwB,IAAI;AAC3D;AACA,gBAAgB,kEAAuB;AACvC;AACA,wBAAwB,sEAAuB,EAAE,IAAI;AACrD;AACA;AACA,kCAAkC,sEAAuB,EAAE,IAAI;AAC/D;AACA;AACA;;AAEA;AACO,sBAAsB,4BAA4B,IAAI;AAC7D;AACA;AACA;AACA,OAAO,uDAAgB;AACvB;AACA;AACA;AACA,YAAY,uDAAgB;AAC5B;AACA;AACA;;AAEA,wCAAwC,QAAQ;AAChD;AACA,oBAAoB,4DAAa;AACjC;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,IAAI;AACV;AACA,eAAe,sBAAsB;AACrC;AACA;AACA;AACA;AACA;AACA,gDAAgD,0DAAe;AAC/D,qDAAqD,0DAAe;AACpE;AACA;AACA;AACA;AACA;AACA,aAAa,4DAAa;AAC1B;AACA,OAAO;AACP,KAAK;AACL;AACA,aAAa,eAAe;AAC5B,aAAa,yDAAY,EAAE,cAAc;AACzC,KAAK;AACL;AACA,aAAa,eAAe;AAC5B,aAAa,2DAAc,EAAE,cAAc;AAC3C;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,kEAAuB;AAClD;AACA,6BAA6B,kEAAuB;AACpD;AACA;AACA,UAAU,kEAAuB,CAAC;AAClC;AACA;;;;;;;;;;;;;;;;;;;ACjJA;AACA;AACA;AAC8C;AAKtB;AACqB;;AAE7C;AACA;AACA,gBAAgB,wEAA6B;AAC7C;AACA,GAAG;AACH;AACA,gBAAgB,wEAA6B;AAC7C;AACA,GAAG;AACH;;AAEA,qDAAqD,QAAQ;AAC7D;AACA;AACA;AACA,gBAAgB,kEAAuB;AACvC;AACA;AACA;;AAEA,qDAAqD,QAAQ;AAC7D;AACA,eAAe,oDAAgB;AAC/B;AACA;;AAEA;AACA,oBAAoB,oDAAgB;AACpC;;AAEA,SAAS,wCAAwC,EAAE,4DAAe;AAClE;AACA,GAAG;;AAEH;AACA,gBAAgB,kEAAuB;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAE+B;;;;;;;;;;;;;;;;;ACxD/B;AACA;AACA;AACiE;;AAE1D,2BAA2B,QAAQ;AAC1C,4BAA4B,4EAAqB;AACjD;AACA,6CAA6C,aAAa;AAC1D;;AAEA,SAAS,2BAA2B;AACpC;AACA;AACA;AACA,wBAAwB,8BAA8B;AACtD,8CAA8C,oBAAoB;AAClE;;AAEA,wBAAwB,QAAQ;AAChC;;AAEA,2BAA2B,qBAAqB;AAChD;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;AC1BA;AACA;AACA;AACiD;AACa;AAKtC;;AAExB,+BAA+B,0DAAe,GAAG,0DAAe;;AAEzD;AACP;AACA,EAAE,IAAI;AACN;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,2BAA2B,kEAAuB;AAClD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;;AAEA;AACA;;AAEO;AACP;AACA,CAAC;AACD;AACA;AACA;;AAEA;AACA;AACA,IAAI,EAAE,4DAAe,EAAE,uCAAuC;;AAE9D;AACA,YAAY,WAAW,GAAG,mBAAmB;AAC7C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEO,8BAA8B,KAAK,IAAI;AAC9C,SAAS,aAAa;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,uDAAgB;AACpC,0BAA0B,0DAAe;AACzC;AACA,kCAAkC,iBAAiB,GAAG;AACtD,kBAAkB,0DAAe,CAAC;AAClC;AACA;AACA;;AAEO,kCAAkC,KAAK,IAAI;AAClD,yCAAyC,IAAI;AAC7C,SAAS,oBAAoB,EAAE,4DAAe;AAC9C,cAAc;AACd,GAAG;AACH;AACA;;AAEO,8BAA8B,KAAK,IAAI;AAC9C,SAAS,aAAa;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,uDAAgB;AACpD,0BAA0B,0DAAe;AACzC;AACA,kCAAkC,iBAAiB,GAAG;AACtD,kBAAkB,0DAAe,CAAC;AAClC;AACA;AACA;;AAEO,kCAAkC,KAAK,IAAI;AAClD,yCAAyC,IAAI;AAC7C,SAAS,oBAAoB,EAAE,4DAAe;AAC9C,cAAc;AACd,GAAG;AACH;AACA;;AAEO,kCAAkC,WAAW,IAAI;AACxD,0BAA0B,0DAAe;AACzC;AACA,kCAAkC,iBAAiB,GAAG;AACtD,kBAAkB,0DAAe,CAAC;AAClC;AACA,SAAS,oBAAoB,EAAE,4DAAe;AAC9C,cAAc;AACd,GAAG;AACH;AACA;;AAEO;AACP;AACA,EAAE,IAAI;AACN,0BAA0B,0DAAe;AACzC;AACA;AACA,oCAAoC,iBAAiB,GAAG;AACxD,oBAAoB,0DAAe,CAAC;AACpC;AACA;AACA;AACA,wCAAwC,0DAAe;AACvD;AACA;AACA,SAAS,oBAAoB,EAAE,4DAAe;AAC9C,cAAc;AACd,GAAG;AACH;AACA;;;;;;;;;;;;;;;;AChKA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAY,uBAAuB;AACnC;AACA,WAAW,QAAQ;AACnB,WAAW,YAAY;AACvB,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB;AACA,aAAa,WAAW;AACxB;AACO,yBAAyB,iCAAiC;AACjE;AACA;AACA;AACA;AACA;AACA,2BAA2B,eAAe;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;AC/BA;AACA;AACA;AACsC;AACtC,OAAO,SAAS,sBAAsB,EAAE,8CAAK;AACC;AAGQ;AACQ;AACA;;AAE9D;AACA,0BAA0B,gFAA0B;AACpD;AACA,+BAA+B,gFAA0B;AACzD;AACA;;AAEO;AACP;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,UAAU;AACvB;AACA;AACA;AACA,aAAa,UAAU;AACvB;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA,aAAa,aAAa;AAC1B,aAAa,SAAS;AACtB;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,IAAI,IAAI;AACR;AACA,gDAAgD,oGAA0B;AAC1E;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,YAAY;AACzB;AACA,aAAa,QAAQ;AACrB;AACA;AACA,eAAe,iBAAiB;AAChC;AACA;AACA,cAAc,kBAAkB;AAChC;AACA;AACA;;AAEA,mDAAmD,iBAAiB;AACpE;AACA,mCAAmC,oDAAgB;;AAEnD;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,YAAY;AACzB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA,eAAe,kBAAkB;AACjC;AACA,yBAAyB,sCAAsC;AAC/D,WAAW,YAAY;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,oDAAgB;;AAE3C,SAAS,UAAU;AACnB;AACA;AACA;AACA;AACA,4BAA4B,4CAA4C;AACxE;;AAEA,kCAAkC,mBAAmB;AACrD;AACA;AACA;AACA,MAAM;AACN;AACA,MAAM;AACN,+CAA+C,wBAAwB;AACvE;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,uDAAuD,WAAW;AAClE;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,+BAA+B,sBAAsB;AACrD;AACA;AACA;AACA;AACA,8BAA8B,gBAAgB;AAC9C;;AAEA,SAAS,oBAAoB;;AAE7B;AACA;AACA;;AAEA;AACA;AACA;;AAEA,WAAW,UAAU;;AAErB;AACA;;AAEA,yCAAyC,mBAAmB;AAC5D;AACA,kCAAkC,oGAA0B;AAC5D,yCAAyC,4BAA4B;AACrE,iBAAiB,sCAAsC;AACvD;AACA;AACA;;AAEA,oBAAoB,yCAAyC;AAC7D,0BAA0B,wCAAwC;AAClE;AACA;;AAEA,gCAAgC,yCAAyC;AACzE;AACA;AACA;AACA;AACA;AACA;;AAEA,WAAW,oBAAoB;;AAE/B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB;AACA,aAAa,SAAS;AACtB;AACA,2BAA2B,qBAAqB;AAChD;AACA;AACA;AACA;;AAEA;AACA,+BAA+B,+EAAyB;;;;;;;;;;;;;;;;;;;ACtNxD;AACA;AACA;AAC0D;;AAEK;AACzC;;;;;;;;;;;;;;;;;;;;;ACNtB;AACA;AACA;AAC8C;AACG;AACF;AACZ;AACC;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEO,yCAAyC,gDAAS;AACzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA,WAAW,yCAAyC;;AAEpD;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,mBAAmB;AAC/B;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,mBAAmB,gBAAgB,GAAG,mBAAmB;AACzD;AACA;AACA,IAAI,8DAAc;AAClB;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA,eAAe,qCAAqC;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB,aAAa,4BAA4B;AACzC;AACA,eAAe,4BAA4B;AAC3C;AACA,yCAAyC,SAAS,IAAI;AACtD;AACA,qCAAqC,oDAAgB;AACrD;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA,QAAQ,oDAAgB;AACxB;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA,eAAe,qCAAqC;AACpD;AACA,6BAA6B,oCAAoC,IAAI;AACrE;AACA,gDAAgD,KAAK;AACrD;AACA;AACA;AACA;AACA,WAAW,UAAU;AACrB;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,uBAAuB;AAClC;AACA;AACA,MAAM,uDAAgB;;AAEtB;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA,aAAa,QAAQ,WAAW;AAChC,aAAa,YAAY;AACzB;AACA;AACA,eAAe,qCAAqC;AACpD;AACA;AACA,yBAAyB,yBAAyB,IAAI;AACtD;AACA;AACA,wBAAwB,mDAAO;AAC/B,MAAM;AACN,wBAAwB,mDAAO;AAC/B;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA,eAAe,4BAA4B;AAC3C;AACA;AACA,0BAA0B,aAAa,IAAI;AAC3C,2CAA2C,gCAAgC;AAC3E;;AAEA;AACA,eAAe,YAAY;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,oDAAgB;AACtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA,eAAe,YAAY;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,oDAAgB;AACtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,QAAQ,WAAW;AAChC,aAAa,SAAS;AACtB,aAAa,SAAS;AACtB,aAAa,SAAS;AACtB;AACA,eAAe,QAAQ;AACvB;AACA;AACA,UAAU,+DAA+D,IAAI;AAC7E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ,WAAW;AAChC,aAAa,SAAS;AACtB,aAAa,SAAS;AACtB;AACA,gBAAgB,iDAAiD;AACjE;AACA;AACA,SAAS,sCAAsC,IAAI;AACnD;AACA;AACA;AACA,iBAAiB;AACjB;AACA,cAAc,uDAAgB;AAC9B;AACA;AACA,cAAc,uDAAgB;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe,iBAAiB;AAChC;AACA;AACA,sBAAsB,uDAAgB;AACtC,yBAAyB,mCAAmC,UAAU,EAAE;AACxE;AACA,WAAW,uDAAgB;AAC3B,2BAA2B,mDAAO,eAAe,KAAK;AACtD;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,iBAAiB;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gCAAgC,gBAAgB;AAChD;AACA;;AAEA;AACA;AACA;AACA;AACA,oCAAoC,oCAAoC;AACxE,MAAM;AACN;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA,gBAAgB,2BAA2B;AAC3C;AACA,qBAAqB,aAAa,IAAI;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,oDAAgB;AAC1C;AACA;AACA;AACA,MAAM;AACN,cAAc;AACd;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY;AACZ;;AAEA;AACA;;AAEA;AACA,kBAAkB,KAAK;AACvB;AACA;AACA;AACA,eAAe,mDAAO;AACtB,OAAO;AACP;AACA;AACA;;AAEA;AACA;;AAEA;AACA,oBAAoB,gBAAgB;AACpC;AACA;AACA;AACA,eAAe,mDAAO;AACtB,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,iBAAiB;AAClC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,mBAAmB,oDAAgB;AACnC;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA,sCAAsC,oDAAgB;AACtD;;;;;;;;;;;;;;;;;;ACndA;AACA;AACA;AAC+C;AACL;;AAE1C;AACA;AACA;AACA;AACA;;AAEA,iEAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA,WAAW,gDAAY;AACvB,GAAG;AACH;AACA,WAAW,kDAAc;AACzB,GAAG;AACH,sBAAsB,KAAK;AAC3B;AACA;AACA,CAAC,EAAC;;AAEF;AACA,EAAE,8DAAc;AAChB;AACA;AACA,GAAG;AACH,0BAA0B,wDAAoB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;AC7CA;AACA;AACA;AAC2E;;;;;;;;;;;;;;;;ACH3E;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAY,uBAAuB;AACnC;AACA,WAAW,QAAQ;AACnB,WAAW,YAAY;AACvB,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB;AACA,aAAa,WAAW;AACxB;AACO,yBAAyB,iCAAiC;AACjE;AACA;AACA;AACA;AACA;AACA,2BAA2B,eAAe;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;AC/BA;AACA;AACA;AAC4B;;AAErB;AACP,SAAS,4CAAe;AACxB;AACA;AACA;AACA,GAAG;AACH;;;;;;;;;;;;;;;;;ACXA;AACA;AACA;AACmE;;AAE5D,+BAA+B,mBAAmB;AACzD,oBAAoB,iEAAoB;AACxC;AACA;AACA;;;;;;;;;;;;;;;;;;;;ACTA;AACA;AACA;AACuC;AACY;AACpB;AAC0B;;AAElD;AACP,UAAU;AACV,gBAAgB;AAChB,MAAM;AACN,mBAAmB;AACnB;;;;;;;;;;;;;;;;ACbA;AACA;AACA;AACO;;;;;;;;;;;;;;;;ACHP;AACA;AACA;AACO;;;;;;;;;;;;;;;;;;ACHP;AACA;AACA;AAC4B;AACU;;AAEtC,OAAO,WAAW,wBAAwB,EAAE,8CAAK;;AAEjD;AACA;AACA;AACA;AACA;AACO;AACP;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA,aAAa,oBAAoB;AACjC;AACA,aAAa,QAAQ;AACrB;AACA;AACA,eAAe,qCAAqC,IAAI;AACxD,WAAW,oCAAoC;AAC/C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB;AACA,eAAe,SAAS,6BAA6B,GAAG;AACxD;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA,OAAO;;AAEP;AACA;AACA;;AAEA,qBAAqB,6CAAgB;;AAErC;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA,cAAc;AACd,MAAM;AACN,cAAc;AACd;AACA;AACA;;;;;;;;;;;;;;;;;;;;AC/EA;AACA;AACA;AAG6B;AAGkB;AAIlB;AAIV;;AAEZ;;AAEP,SAAS,2DAAsB,IAAI,uDAAmB;AACtD,SAAS,iDAAc,IAAI,6CAAW;;AAEtC,4BAA4B,yDAAmB;AAC/C;AACA;;AAEA,4BAA4B,2EAAmB;AAC/C;AACA;;;;;;;;;;;;;;;;;AC7BA;AACA;AACA;;AAEO;AACP;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,yBAAyB,sCAAsC;;AAE/D,yBAAyB,0CAA0C;;AAEnE;AACA,yBAAyB,0CAA0C;AACnE;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,4BAA4B,uCAAuC;AACnE,4BAA4B,wCAAwC;;AAEpE,2BAA2B,qCAAqC;AAChE,2BAA2B,qCAAqC;;AAEhE,0BAA0B,qCAAqC;AAC/D,0BAA0B,qCAAqC;;AAE/D;AACA;AACA,2BAA2B,0CAA0C;AACrE;;AAEA,6BAA6B,uCAAuC;AACpE,6BAA6B,uCAAuC;AACpE,6BAA6B,yCAAyC;AACtE,6BAA6B,yCAAyC;AACtE,6BAA6B,8CAA8C;AAC3E,6BAA6B,+CAA+C;AAC5E,6BAA6B,+CAA+C;AAC5E,6BAA6B,gDAAgD;AAC7E,6BAA6B,8CAA8C;AAC3E,6BAA6B,6CAA6C;AAC1E,6BAA6B,4CAA4C;AACzE,6BAA6B,6CAA6C;AAC1E,6BAA6B,4CAA4C;AACzE,6BAA6B,2CAA2C;AACxE,6BAA6B,+CAA+C;AAC5E,6BAA6B,8CAA8C;;AAE3E;AACA,8BAA8B,wCAAwC;AACtE,8BAA8B,yCAAyC;AACvE,8BAA8B,sCAAsC;;AAEpE;AACA,8BAA8B,yCAAyC;;AAEvE;AACA,8BAA8B,0CAA0C;;AAExE,8BAA8B,yCAAyC;;AAEvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,6BAA6B,mCAAmC;AAChE,6BAA6B,0CAA0C;AACvE,6BAA6B,qCAAqC;;AAElE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,6BAA6B,yCAAyC;AACtE,6BAA6B,yCAAyC;AACtE;AACA,6BAA6B,0CAA0C;AACvE;AACA;AACA,6BAA6B,2DAA2D;AACxF;AACA,6BAA6B,6CAA6C;AAC1E;AACA,6BAA6B,+CAA+C;AAC5E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;;;;;;;;;;;;;;;;AC7MA;AACA;AACA;;AAEO;AACP;AACO;AACP;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,mBAAmB,8CAA8C;AACjE;AACA,gBAAgB,kCAAkC;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,0CAA0C;AACzD;AACA,iBAAiB,mCAAmC;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,qCAAqC;AACxD;AACA;AACA;;;;;;;;;;;;;;;;;AC7DA;AACA;AACA;AACA;AAC6C;;AAEtC;AACP,kBAAkB,wDAAQ;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yDAAyD,IAAI;AAC7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AChBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oDAAoD;AACpD,YAAY;AACZ;AACA;AACA;AACA;AAC4B;AACU;AACmC;AACH;AAC/D;AACP,EAAE,kEAAyB,CAAC,8DAAe;AACgB;AACkB;;AAE7E,OAAO,4BAA4B,EAAE,uDAAc;AACnD,OAAO,YAAY,6BAA6B,EAAE,gDAAmB;AACrE,mCAAmC,8EAA+B;;AAE/B;;AAEnC;AACA;AACO,oCAAoC,EAAE;AAC7C;AACA;AACA;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA,aAAa,QAAQ;AACrB,cAAc,SAAS;AACvB,cAAc,QAAQ;AACtB,cAAc,OAAO;AACrB,cAAc,QAAQ;AACtB;;AAEA;AACA,aAAa,QAAQ;AACrB,cAAc,SAAS;AACvB,cAAc,QAAQ;AACtB,cAAc,OAAO;AACrB,cAAc,QAAQ;AACtB;;AAEA;AACA;AACA;AACA;AACA,WAAW,QAAQ,WAAW;AAC9B;AACA,WAAW,QAAQ;AACnB,WAAW,qBAAqB;AAChC;AACA;AACA,WAAW,cAAc;AACzB;AACA;AACA;AACA,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB,WAAW,aAAa;AACxB;AACA;AACA,YAAY,OAAO;AACnB;AACA,aAAa,+BAA+B;AAC5C;AACO;AACP;AACA,gBAAgB,oFAAyB;AACzC;AACA;AACA,EAAE,IAAI;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iCAAiC,8BAA8B;AAC/D,IAAI;AACJ;AACA;AACA,8BAA8B,8BAA8B;AAC5D;;AAEA;AACA,oBAAoB,gBAAgB;;AAEpC,SAAS,mDAAU,cAAc,6CAA6C;AAC9E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,QAAQ,WAAW;AAC9B;AACA,WAAW,wBAAwB;AACnC;AACA;AACA;AACA,WAAW,2CAA2C;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,SAAS;AACpB;AACA;AACA;AACA;AACA;AACA,WAAW,4BAA4B;AACvC;AACA;AACA;AACA,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB;AACA,WAAW,UAAU;AACrB,WAAW,UAAU;AACrB;AACA,WAAW,aAAa;AACxB;AACA;AACA,aAAa,mCAAmC;AAChD;AACO,kCAAkC;AACzC,SAAS,cAAc;AACvB;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA,iBAAiB,qCAAqC;AACtD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,QAAQ,WAAW;AAC9B;AACA,WAAW,QAAQ;AACnB;AACA,WAAW,2CAA2C;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,2BAA2B;AACtC;AACA,WAAW,UAAU;AACrB,WAAW,UAAU;AACrB;AACA,WAAW,aAAa;AACxB;AACA;AACA,aAAa,iCAAiC;AAC9C;AACO,4CAA4C;AACnD,SAAS,YAAY;AACrB;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA,iBAAiB,mCAAmC;AACpD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,QAAQ,WAAW;AAC9B;AACA,WAAW,QAAQ;AACnB,WAAW,2CAA2C;AACtD;AACA,WAAW,aAAa;AACxB;AACA;AACA,YAAY,OAAO;AACnB;AACA,WAAW,2BAA2B;AACtC,WAAW,UAAU;AACrB,WAAW,UAAU;AACrB;AACA;AACA,aAAa,iCAAiC;AAC9C;AACA,6CAA6C;AAC7C,SAAS,8BAA8B;;AAEvC;AACA,oBAAoB,gBAAgB;;AAEpC;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,SAAS,YAAY;AACrB,yCAAyC,oFAAyB;AAClE;AACA,GAAG;;AAEH,uBAAuB,qDAAY;AACnC,iBAAiB,oCAAoC;;AAErD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,QAAQ;AACnB,WAAW,sBAAsB;AACjC;AACA,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB,WAAW,aAAa;AACxB;AACA;AACA,YAAY,WAAW;AACvB,YAAY,OAAO;AACnB;AACA;AACA,aAAa,cAAc;AAC3B;AACA;AACO;AACP;AACA,EAAE,IAAI;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,gBAAgB;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,QAAQ,WAAW;AAC9B;AACA;AACA,WAAW,cAAc;AACzB,WAAW,qBAAqB;AAChC;AACA;AACA,WAAW,cAAc;AACzB;AACA;AACA,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB;AACA,WAAW,UAAU;AACrB;AACA,aAAa,SAAS,uBAAuB,GAAG;AAChD;AACA;AACO,4CAA4C;AACnD,SAAS,iCAAiC;AAC1C;AACA;AACA;AACA,GAAG;;AAEH;;AAEA,SAAS,mDAAU,gBAAgB,oCAAoC;AACvE;;AAEA;AACA;AACA;AACA;AACA;AACA,WAAW,QAAQ,WAAW;AAC9B,WAAW,wBAAwB;AACnC;AACA;AACA,WAAW,2CAA2C;AACtD;AACA;AACA,WAAW,SAAS;AACpB;AACA;AACA;AACA;AACA;AACA,WAAW,4BAA4B;AACvC;AACA;AACA;AACA,WAAW,QAAQ;AACnB;AACA,WAAW,QAAQ;AACnB;AACA,WAAW,QAAQ;AACnB;AACA;AACA,WAAW,UAAU;AACrB,WAAW,UAAU;AACrB;AACA,WAAW,aAAa;AACxB;AACA;AACA,YAAY,OAAO;AACnB;AACA,aAAa,mCAAmC;AAChD;AACA,+CAA+C;AAC/C,SAAS,oCAAoC;;AAE7C;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,sBAAsB,6CAAgB;AACtC;AACA;AACA;AACA,+BAA+B,uCAAuC;AACtE,KAAK;;AAEL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,YAAY;AACZ;;AAEA,SAAS,+BAA+B;AACxC;AACA;AACA;AACA;;AAEA;AACA,oCAAoC,8BAA8B;;AAElE,mCAAmC,qDAAY;AAC/C,mBAAmB,oCAAoC;;AAEvD;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,WAAW,eAAe;AAC1B;AACA,aAAa,kBAAkB;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,WAAW,QAAQ;AACnB;AACA,YAAY;AACZ;AACA;AACO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU,2BAA2B,OAAO,4BAA4B;AACxE;AACA;;AAEA,gBAAgB,6CAAgB;;AAEhC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB;AACA,WAAW,aAAa;AACxB;AACA;AACA,YAAY;AACZ;AACA;AACO,2BAA2B,6BAA6B;AAC/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU,2BAA2B,QAAQ,2BAA2B;AACxE;AACA;;AAEA;AACA;AACA;AACA;;AAEA,MAAM,6CAAgB;AACtB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO,6CAAgB;AACvB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,WAAW,cAAc;AACzB;AACA,gEAAgE,aAAa;AAC7E;AACA;AACA;AACA;AACA;AACA,oCAAoC,kBAAkB;AACtD,6BAA6B,2BAA2B;AACxD;AACA;AACA,IAAI;AACJ;AACA,OAAO,6CAAgB;AACvB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,WAAW,WAAW;AACtB;AACA,6DAA6D,UAAU;AACvE;AACA;AACA;AACA;AACA;AACA,oCAAoC,kBAAkB;AACtD,0BAA0B,wBAAwB;AAClD;AACA;AACA;;AAEA;AACA,KAAK,6CAAgB;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,mCAAmC;AACvD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE,6CAAgB;AAClB;AACA;AACA,sBAAsB,yCAAyC;AAC/D;AACA,GAAG;;AAEH;AACA,WAAW,gBAAgB;AAC3B;AACA;AACA;AACA,kDAAkD,eAAe;AACjE;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,yBAAyB,iBAAiB;AAC1C;AACA;AACA;AACA,IAAI;AACJ,oCAAoC,aAAa,oBAAoB,GAAG;AACxE;AACA;AACA;;AAEA;AACA,4BAA4B,aAAa,oBAAoB,GAAG;AAChE;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACprBA;AACqC;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACgB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,sBAAsB;AACtC,gBAAgB,sBAAsB;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,sBAAsB;AACtC,gBAAgB,IAAI;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,6BAA6B;AAC7C,gBAAgB,6BAA6B;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B,kBAAkB;AAC/C;AACA;AACA,4BAA4B,kBAAkB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B,kBAAkB;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,UAAU;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,IAAI;AACpB;AACA;AACA;AACA;AACA,cAAc,gCAAgC;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,OAAO;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc,aAAa;AAC3B;AACA;AACA;AACA,gBAAgB,iBAAiB;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,OAAO;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc,oBAAoB;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,IAAI;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,OAAO;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC2D;AAC3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B,mBAAmB;AAChD;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,aAAa;AACxC;AACA;AACA;AACA;AACA,oBAAoB,mBAAmB;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,kBAAkB;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qEAAqE,QAAQ,MAAM,OAAO;AAC1F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,YAAY,IAAI;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,IAAI;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,eAAe;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,gBAAgB;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACO;AACP;AACA,YAAY,6BAA6B;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,6BAA6B;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,OAAO;AACnB;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP,YAAY,kBAAkB;AAC9B;AACA;AACA;AACA;AACA,YAAY,kBAAkB;AAC9B;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACO;AACP,YAAY,OAAO;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,IAAI;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC,UAAU;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,gBAAgB;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA,UAAU,4LAAU;AACpB;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,oBAAoB,cAAc;AAClC;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL,CAAC;;;;;;;;;;;;;;;;;ACx3BD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,YAAY;AACvB,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB;AACA;AACA,aAAa,QAAQ;AACrB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,aAAa,kBAAkB;AAC/B;AACA,mBAAmB,mBAAmB;AACtC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,wCAAwC;AACrD;AACA;AACA;AACA,6BAA6B,QAAQ;AACrC;AACA;;AAEA;AACA,gCAAgC,kBAAkB;AAClD;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB;AACA,aAAa,YAAY;AACzB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,mBAAmB,qBAAqB;AACxC;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,kBAAkB;AACnC;AACA;AACA;AACA;;AAEA;AACA,mBAAmB,kBAAkB;AACrC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,4CAA4C;AAC7D;AACA;;AAEA;AACA;;;;;;;;;;;;;;;;;;AC1JA;AACA;AACA;AAIoB;;AAEpB;AACA;;AAEO;AACP,SAAS,iDAAO;AAChB;;AAEO;AACP,SAAS,iDAAO;AAChB;;;;;;;;;;;;;;;;;ACjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,uBAAuB;AAClC;AACA,aAAa,QAAQ;AACrB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,QAAQ;AACnB;AACA,aAAa,YAAY;AACzB;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;;;;;;;;;;;;;;;;AClHA;AACA;AACA;AAC8C;;;;;;;;;;;;;;;;ACH9C;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB;AACO;AACP,eAAe,QAAQ,IAAI;AAC3B;AACA;;AAEA;AACA;AACA;AACA,aAAa,WAAW;AACxB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;AACrB;AACA;AACA,eAAe,oBAAoB;AACnC;AACA,6BAA6B;AAC7B;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA,cAAc,OAAO;AACrB;AACA,eAAe,oBAAoB;AACnC;AACA,4BAA4B;AAC5B;;AAEA;AACA;AACA,oCAAoC,qBAAqB;AACzD;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,SAAS;AACtB;AACA;AACA,aAAa,SAAS;AACtB;AACA;AACA,eAAe,oBAAoB;AACnC;AACA;AACA;AACA;AACA,IAAI,IAAI;AACR;AACA;AACA;AACA;;AAEA,kCAAkC,qCAAqC;AACvE;;AAEA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,UAAU;AACvB,aAAa,SAAS;AACtB;AACA;AACA,aAAa,SAAS;AACtB;AACA;AACA,eAAe,oBAAoB;AACnC;AACA;AACA;AACA;AACA,IAAI,IAAI;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ,uBAAuB;AAC/B;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4CAA4C,YAAY;AACxD;;AAEA,qCAAqC;AACrC,mBAAmB;AACnB;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA,eAAe,SAAS;AACxB;AACA,cAAc,KAAK;AACnB;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;;AAEA;AACA;AACA;AACA,yBAAyB,KAAK;AAC9B,+CAA+C,KAAK;AACpD;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;;;;;;;;;;;;;;;AChLA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,yBAAyB,IAAI;AAC5C;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA,eAAe,oBAAoB;AACnC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,SAAS;AACtB;AACA;AACA,aAAa,SAAS;AACtB;AACA;AACA,eAAe,oBAAoB;AACnC;AACA;AACA;AACA;AACA,IAAI,IAAI;AACR;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sDAAsD,iBAAiB;AACvE;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,oBAAoB;AACnC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ,WAAW;AAChC,aAAa,SAAS;AACtB,aAAa,SAAS;AACtB;AACA,eAAe,QAAQ;AACvB;AACA;AACA,UAAU,uCAAuC,IAAI;AACrD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA,wBAAwB,aAAa;AACrC;AACA;;AAEA;AACA;AACA;AACA,yBAAyB,yDAAyD;AAClF;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,oBAAoB,KAAK;AACzB;AACA,gBAAgB,iBAAiB;AACjC;AACA;AACA;AACA;AACA,kBAAkB,WAAW;AAC7B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,yBAAyB,yDAAyD;AAClF;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA,gBAAgB,mBAAmB;AACnC;AACA;AACA;AACA;AACA,oBAAoB,sBAAsB;AAC1C;AACA;AACA;AACA;AACA;;AAEA;AACA;;;;;;;;;;;;;;;;;;;AC/NA;AACA;AACA;AACuC;AACE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACJiB;AACI;AACJ;AACA;AACF;AACI;AACJ;AACZ;AACE;AACY;AACI;AACV;AACI;AACJ;AACZ;AACM;AAC0C;AACxC;AACI;AACE;AACJ;AACmB;AACY;AACP;AACzB;AACJ;AACf;AAC+B;AACH;AACP;AACf;AACyB;;;;;;;;;;;;;;;;;;;AC/BF;AACT;AACE;AAC7C;AACP;AACA,cAAc,yDAAO;AACrB;AACA;AACA,kBAAkB,uDAAU;AAC5B;AACA,YAAY,6EAA6E;AACzF;AACA,kBAAkB,uDAAU;AAC5B;AACA,4BAA4B,uEAAgB;AAC5C;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,qBAAqB;AACrB;AACA,iBAAiB;AACjB;AACA;AACA;;;;;;;;;;;;;;;;;AC1B2D;AACpD;AACP;AACA,8BAA8B,mEAAgB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;ACzBiE;AAClB;AACC;AACuC;AACrC;AACJ;AACyB;AACF;AAC1B;AACW;AACY;AAC3D;AACP;AACA,SAAS,6DAAQ;AACjB,kBAAkB,uDAAU;AAC5B;AACA;AACA,kBAAkB,uDAAU;AAC5B;AACA;AACA,kBAAkB,uDAAU;AAC5B;AACA;AACA,kBAAkB,uDAAU;AAC5B;AACA;AACA,kBAAkB,uDAAU;AAC5B;AACA;AACA,kBAAkB,uDAAU;AAC5B;AACA;AACA,kBAAkB,uDAAU;AAC5B;AACA;AACA,kBAAkB,uDAAU;AAC5B;AACA,qCAAqC,6DAAQ;AAC7C,kBAAkB,uDAAU;AAC5B;AACA,0CAA0C,6DAAQ;AAClD,kBAAkB,uDAAU;AAC5B;AACA;AACA;AACA;AACA,oCAAoC,6DAAS;AAC7C,oCAAoC,yDAAO;AAC3C;AACA;AACA,sBAAsB,uDAAU;AAChC;AACA;AACA,SAAS,+DAAU;AACnB,kBAAkB,uDAAU;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,iEAAY,CAAC,uDAAU;AAC3B;AACA;AACA,sBAAsB,uDAAU;AAChC;AACA;AACA,sBAAsB,6DAAgB;AACtC;AACA;AACA,YAAY,WAAW;AACvB;AACA,kBAAkB,uDAAU;AAC5B;AACA;AACA,kBAAkB,uDAAU;AAC5B;AACA,+CAA+C,wEAAkB;AACjE;AACA,QAAQ,wEAAkB;AAC1B;AACA,kBAAkB,8DAAiB;AACnC;AACA;AACA,kBAAkB,8DAAiB;AACnC;AACA;AACA;AACA;AACA,2BAA2B,6DAAS;AACpC;AACA;AACA,sBAAsB,uDAAU;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,0EAAoB;AACxC;AACA;AACA,uDAAuD,uDAAU,mBAAmB,6DAAgB;AACpG;AACA;AACA,cAAc,uDAAW;AACzB;AACA;AACA;AACA;AACA,aAAa,6DAAS;AACtB;AACA;AACA,kBAAkB,uDAAU;AAC5B;AACA;AACA,cAAc,6DAAS;AACvB;AACA;AACA,kBAAkB,uDAAU;AAC5B;AACA,4BAA4B,yDAAO;AACnC;AACA;AACA,yBAAyB,4DAAM,kBAAkB,yDAAO,cAAc,yDAAO;AAC7E;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,6DAAS;AAC9B;AACA;AACA,kBAAkB,uDAAU;AAC5B;AACA,0BAA0B,+DAAO;AACjC;AACA,qGAAqG,qDAAO;AAC5G;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA,iDAAiD,6DAAS;AAC1D;AACA;AACA,sBAAsB,uDAAU;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;ACrKiE;AAClB;AACC;AACP;AAC8B;AACH;AAClB;AACmB;AACf;AAC/C;AACA;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,uDAAU;AAChC;AACA,aAAa,+DAAU;AACvB,sBAAsB,uDAAU;AAChC;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ,iEAAY,CAAC,uDAAU;AAC/B;AACA;AACA,0BAA0B,uDAAU;AACpC;AACA;AACA,0BAA0B,6DAAgB;AAC1C;AACA;AACA,gBAAgB,WAAW;AAC3B;AACA,sBAAsB,uDAAU;AAChC;AACA;AACA,sBAAsB,uDAAU;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,gCAAgC,QAAQ,0EAAoB;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA,oDAAoD;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kDAAkD;AAClD;AACA;AACA;AACA;AACA,gCAAgC,sDAAU;AAC1C;AACA;AACA;AACA;AACA,8BAA8B,yDAAO,QAAQ,6DAAS;AACtD;AACA;AACA,8BAA8B,yDAAO;AACrC;AACA;AACA,wBAAwB,6DAAS;AACjC,6BAA6B,4DAAM,kBAAkB,yDAAO,cAAc,yDAAO;AACjF;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8GAA8G,qDAAO;AACrH,eAAe,kBAAkB,QAAQ,+DAAO;AAChD;AACA;AACA;AACA,eAAe,kBAAkB,QAAQ,+DAAO;AAChD;AACA;AACA,wBAAwB,6DAAS;AACjC,gBAAgB,6DAAS;AACzB,iBAAiB,6DAAS;AAC1B;AACA;AACA,gCAAgC,6DAAS;AACzC;AACA;AACA;AACA;AACA;AACA,4BAA4B,yDAAO;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;AC9K2D;AACY;AACzB;AACvC;AACP,SAAS,6DAAQ;AACjB,kBAAkB,uDAAU;AAC5B;AACA,gEAAgE,yDAAQ;AACxE,kBAAkB,uDAAU;AAC5B;AACA;AACA,kBAAkB,uDAAU;AAC5B;AACA;AACA;AACA,yBAAyB,uEAAgB;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,cAAc,gEAAmB;AACjC;;;;;;;;;;;;;;;;;;;;;;;AC9BwE;AACtB;AACP;AACO;AACqB;AACN;AACX;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA,+DAA+D,sEAAsE;AACrI;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,uDAAU;AAChC;AACA,oBAAoB;AACpB;AACA;AACA,wCAAwC,mEAAgB;AACxD;AACA;AACA;AACA;AACA,0CAA0C,kCAAkC;AAC5E;AACA;AACA;AACA,+BAA+B;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,6BAA6B;AACrD;AACA,iBAAiB,+DAAU;AAC3B,0BAA0B,uDAAU;AACpC;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,MAAM;AAC1B;AACA,0BAA0B,uDAAU;AACpC;AACA;AACA,0BAA0B,uDAAU;AACpC;AACA;AACA,0BAA0B,uDAAU;AACpC;AACA;AACA;AACA;AACA;AACA,0BAA0B,uDAAU;AACpC;AACA,YAAY,iEAAY,CAAC,uDAAU;AACnC;AACA;AACA,8BAA8B,uDAAU;AACxC;AACA;AACA;AACA,oBAAoB,uDAAW;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,6BAA6B;AACrD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4CAA4C,mEAAgB;AAC5D;AACA;AACA;AACA;AACA;AACA,kDAAkD,KAAK;AACvD;AACA;AACA;AACA,qBAAqB,8DAAW;AAChC,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,2BAA2B,QAAQ,0EAAoB;AAC3E;AACA,yHAAyH,KAAK;AAC9H,mCAAmC,6DAAS;AAC5C;AACA,kCAAkC;AAClC;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;ACjL6C;AACF;AACI;AACxC;AACP;AACA;AACA;AACA;AACA,SAAS,6DAAQ;AACjB,kBAAkB,uDAAU;AAC5B;AACA,sBAAsB,yDAAS,GAAG,8BAA8B;AAChE;AACA,kBAAkB,uDAAU;AAC5B;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;AChB0C;AACoB;AACG;AAChB;AACN;AAC3C;AACA;AACA,kBAAkB,uDAAU,IAAI,aAAa;AAC7C;AACA;AACO;AACP,SAAS,6DAAQ;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA,sBAAsB,6DAAgB;AACtC;AACA,iBAAiB,yDAAO;AACxB,WAAW,6DAAS,OAAO,8DAAM;AACjC;AACO;AACP;AACA;AACA,uDAAuD,0BAA0B,GAAG,WAAW;AAC/F;;;;;;;;;;;;;;;;;;;;;ACpD6C;AACmE;AACrE;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,6DAAgB;AACtC;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,6DAAQ;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA,sBAAsB,wDAAW;AACjC;AACA;AACA;AACA;AACA,gBAAgB,WAAW,IAAI;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,gBAAgB,iBAAiB;AACjC;AACA,sBAAsB,8DAAiB;AACvC;AACA;AACA,8BAA8B,qEAAwB;AACtD,oBAAoB,UAAU;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sDAAsD;AACtD;AACA,0BAA0B,yDAAS,GAAG,mBAAmB;AACzD;AACA,sBAAsB,wDAAW;AACjC;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;ACnHiD;AACkB;AACd;AACrD;AACA;AACA;AACA;AACA;AACA,2BAA2B,kDAAW;AACtC;AACA,gBAAgB,UAAU;AAC1B;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B,8DAAiB;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oDAAoD,kEAAS;AAC7D;AACA,iBAAiB,qDAAU;AAC3B,0BAA0B,wDAAW;AACrC;AACA,2BAA2B;AAC3B;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;AC3EqD;AAC9C;AACP;AACA,8BAA8B,6DAAa;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,cAAc,GAAG,YAAY,GAAG,cAAc;AAChE;AACA;;;;;;;;;;;;;;;;;;;AChByD;AACP;AACE;AAC7C;AACP;AACA,cAAc,yDAAO;AACrB;AACA;AACA,kBAAkB,uDAAU;AAC5B;AACA,YAAY,uDAAuD;AACnE;AACA,kBAAkB,uDAAU;AAC5B;AACA,2BAA2B,qEAAe,GAAG,gDAAgD;AAC7F,qBAAqB;AACrB;AACA,iBAAiB;AACjB;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;ACpBiE;AACxB;AACS;AACA;AACmB;AACd;AACD;AAC/C;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,uDAAU;AAChC;AACA,aAAa,+DAAU;AACvB,sBAAsB,uDAAU;AAChC;AACA;AACA;AACA;AACA;AACA,2BAA2B,iEAAY,CAAC,uDAAU;AAClD;AACA;AACA;AACA;AACA,0BAA0B,uDAAU;AACpC;AACA;AACA,gBAAgB,MAAM;AACtB;AACA,sBAAsB,uDAAU;AAChC;AACA,QAAQ,kEAAY;AACpB;AACA;AACA,sBAAsB,yDAAO,QAAQ,6DAAS;AAC9C;AACA;AACA;AACA,8BAA8B,yDAAO,QAAQ,6DAAS;AACtD;AACA;AACA,8BAA8B,yDAAO;AACrC;AACA,qBAAqB,4DAAM,kBAAkB,yDAAO;AACpD,gCAAgC,4DAAI;AACpC;AACA,uBAAuB,6DAAS;AAChC;AACA;AACA;AACA,0BAA0B,yDAAO;AACjC;AACA;AACA;AACA;AACA;AACA,4BAA4B,yDAAO;AACnC;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;AChFiE;AACpB;AACwD;AAChC;AACnB;AACJ;AACS;AACD;AACY;AAC3D;AACP;AACA,SAAS,6DAAQ;AACjB,kBAAkB,uDAAU;AAC5B;AACA;AACA,kBAAkB,uDAAU;AAC5B;AACA;AACA,kBAAkB,uDAAU;AAC5B;AACA;AACA,kBAAkB,uDAAU;AAC5B;AACA;AACA,kBAAkB,uDAAU;AAC5B;AACA,qCAAqC,6DAAQ;AAC7C,kBAAkB,uDAAU;AAC5B;AACA;AACA;AACA;AACA,oCAAoC,6DAAS;AAC7C,oCAAoC,yDAAO;AAC3C;AACA;AACA,sBAAsB,uDAAU;AAChC;AACA;AACA,SAAS,+DAAU;AACnB,kBAAkB,uDAAU;AAC5B;AACA;AACA;AACA;AACA;AACA,uBAAuB,iEAAY,CAAC,uDAAU;AAC9C;AACA;AACA;AACA;AACA,sBAAsB,uDAAU;AAChC;AACA;AACA,YAAY,MAAM;AAClB;AACA,kBAAkB,uDAAU;AAC5B;AACA,kCAAkC,uEAAkB;AACpD;AACA,kBAAkB,8DAAiB;AACnC;AACA;AACA;AACA,sBAAsB,uDAAU;AAChC;AACA;AACA;AACA,kBAAkB,uDAAU;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,kEAAY;AAChB,iBAAiB,4DAAM,CAAC,yDAAO,mEAAmE,yDAAO,gDAAgD,yDAAO;AAChK;AACA;AACA,oBAAoB,6DAAS;AAC7B;AACA;AACA,kBAAkB,uDAAU;AAC5B;AACA,2BAA2B,8DAAM;AACjC;AACA,kBAAkB,2EAA8B;AAChD;AACA;AACA;AACA;AACA,sBAAsB,6DAAS;AAC/B;AACA;AACA,sBAAsB,uDAAU;AAChC;AACA;AACA;AACA,kBAAkB,yDAAO;AACzB;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;;;;;;;;;;;;;;;;;;AClHqD;AACH;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,uDAAU;AAChC;AACA;AACA;AACA;AACA;AACA,wBAAwB,6BAA6B;AACrD;AACA,kCAAkC,6DAAa;AAC/C;AACA;AACA,oBAAoB,mBAAmB;AACvC;AACA;AACA;AACA;AACA,0BAA0B,uDAAU;AACpC;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;AClEyD;AACyB;AACpC;AACvC;AACP,SAAS,6DAAQ;AACjB,kBAAkB,uDAAU;AAC5B;AACA,gEAAgE,yDAAQ;AACxE,kBAAkB,uDAAU;AAC5B;AACA;AACA;AACA,yBAAyB,qEAAe;AACxC;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,cAAc,2EAA8B;AAC5C;;;;;;;;;;;;;;;;;;;ACvB2D;AACT;AACW;AACtD;AACP,4BAA4B,uEAAc;AAC1C,oBAAoB,kEAAU;AAC9B,YAAY,kBAAkB;AAC9B;AACA,kBAAkB,qEAAwB;AAC1C;AACA;AACA,kBAAkB,qEAAwB;AAC1C;AACA;AACA;AACA,kBAAkB,qEAAwB;AAC1C;AACA,qBAAqB;AACrB;AACA,iBAAiB;AACjB;AACA;AACA;;;;;;;;;;;;;;;;;;;ACtB2D;AACV;AACP;AACnC,yBAAyB,mDAAU;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,mEAAc,CAAC,yDAAO;AAC9C;AACA,sCAAsC;AACtC;AACA;AACA,sCAAsC;AACtC;AACA;AACA,sCAAsC;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;ACnEoC;AACO;AACT;AAC3B;AACP;AACA,aAAa,6DAAQ;AACrB;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA;AACA,8BAA8B;AAC9B;AACA;AACA,8BAA8B,uBAAuB,yDAAK,eAAe,wDAAI;AAC7E;AACA;AACA;AACA;AACA;AACA,8BAA8B;AAC9B;AACA;AACA,8BAA8B,uBAAuB,yDAAK,eAAe,wDAAI;AAC7E;AACA;AACA;AACA;AACA;AACA,8BAA8B,uBAAuB,yDAAK;AAC1D;AACA;AACA,8BAA8B;AAC9B;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;ACrDqD;AACN;AACE;AACP;AACnC,sBAAsB,mDAAU;AACvC;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,6DAAW,CAAC,yDAAO;AAC3C;AACA;AACA;AACA;AACA,sBAAsB,uDAAU;AAChC;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;ACpBqD;AACJ;AACF;AACG;AACR;AACnC,2BAA2B,mDAAU;AAC5C;AACA,uBAAuB,yDAAgB,kBAAkB,aAAa;AACtE,wBAAwB,yDAAgB;AACxC,kBAAkB,OAAO,GAAG,QAAQ;AACpC;AACA;AACA;AACA,sBAAsB,uDAAU;AAChC;AACA,gBAAgB,4DAA4D;AAC5E;AACA,sBAAsB,uDAAU;AAChC;AACA;AACA;AACA,gCAAgC,yDAAO,QAAQ,yDAAgB;AAC/D;AACA;AACA;AACA;AACA,sBAAsB,uDAAU;AAChC;AACA,wBAAwB,kEAAU,SAAS,yDAAgB;AAC3D,iBAAiB;AACjB;AACA;;;;;;;;;;;;;;;;;;;AC/ByD;AACP;AACH;AACxC;AACP;AACA,2BAA2B,qEAAa;AACxC;AACA,kBAAkB,uDAAU;AAC5B;AACA,oBAAoB,kEAAU;AAC9B,qBAAqB;AACrB;AACA,iBAAiB;AACjB;AACA;AACA;;;;;;;;;;;;;;;;;;;;ACf4D;AACE;AACd;AACzC;AACP,WAAW,wDAAY;AACvB;AACO;AACP,WAAW,yDAAa;AACxB;AACO;AACP,WAAW,kEAAQ;AACnB;;;;;;;;;;;;;;;;;ACXqE;AAC9D;AACP,WAAW,qEAAQ;AACnB;;;;;;;;;;;;;;;;;ACHoE;AAC7D;AACP,WAAW,oEAAQ;AACnB;;;;;;;;;;;;;;;;;;;;;;;;ACHoE;AACD;AAChB;AACE;AACV;AACpC;AACP;AACA;AACA;AACA,WAAW,0DAAQ;AACnB;AACO;AACP;AACA;AACA;AACA,WAAW,0DAAQ;AACnB;AACO;AACP;AACA;AACA;AACA,WAAW,2DAAS;AACpB;AACO;AACP;AACA,SAAS,6DAAQ;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,kEAAW,GAAG,yEAAyE;AAC9G;AACA,mBAAmB,6DAAe;AAClC;AACA;AACA,0BAA0B,6DAAgB;AAC1C;AACA;AACA;AACA,mBAAmB,kEAAW,GAAG,aAAa;AAC9C;AACA,sBAAsB,6DAAgB;AACtC;AACA;;;;;;;;;;;;;;;;;;;;;ACjD4C;AACA;AACX;AAC6B;AACvD;AACP;AACA,gBAAgB,kDAAU;AAC1B,YAAY,gCAAgC,QAAQ,+DAAO;AAC3D,aAAa,kBAAkB,6DAAS,WAAW,6DAAS;AAC5D;AACO;AACP;AACA,WAAW,+DAAO;AAClB;;;;;;;;;;;;;;;;;;;;;;;;ACb0C;AACnC;AACA;AACP;AACO;AACP,wCAAwC,QAAQ;AAChD;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACO;AACP;AACA;AACA;AACA;AACA,0DAA0D,cAAc,aAAa,MAAM;AAC3F;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACO;AACP;AACA;AACO;AACP;AACA;AACA,uBAAuB,mBAAmB;AAC1C;AACA;AACA;AACA;AACA,sBAAsB,8DAAM;AAC5B;AACA;AACA;;;;;;;;;;;;;;;;;;;AClDqD;AACX;AACnC;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,6DAAgB,+BAA+B,IAAI;AACzE;AACA;AACA,iEAAe,SAAS,8DAAM,qCAAqC,EAAC;;;;;;;;;;;;;;;;;;ACnBrB;AACX;AACpC;AACA,2BAA2B,iDAAS;AACpC,kBAAkB,uDAAU;AAC5B;AACA;AACA,iEAAe,aAAa,EAAC;;;;;;;;;;;;;;;;;;ACPuC;AACP;AAC7D;AACA;AACA;AACA,SAAS,mEAAS;AAClB,4BAA4B,8DAAe,cAAc,0DAAK;AAC9D;AACA;AACA,+BAA+B,0DAAK,eAAe;AACnD;AACA;AACA;AACA,SAAS,mEAAS;AAClB,4BAA4B,8DAAe,cAAc,0DAAK;AAC9D;AACA;AACA,+BAA+B,0DAAK,eAAe;AACnD;AACA;AACA,+BAA+B,0DAAK,eAAe;AACnD;AACA;AACA,+BAA+B,0DAAK,eAAe;AACnD;AACA;AACA,+BAA+B,0DAAK,eAAe;AACnD;AACA;AACA,+BAA+B,0DAAK,eAAe;AACnD;AACA;AACA;AACA;AACA;AACA;AACA,cAAc,EAAE;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iEAAe,YAAY,EAAC;;;;;;;;;;;;;;;;;AC5CmB;AAChC;AACf;AACA,kBAAkB,uDAAU;AAC5B;AACA;;;;;;;;;;;;;;;;;ACLA;AACA,2EAA2E,MAAM,UAAU,KAAK;AAChG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B,kBAAkB,OAAO,KAAK;AAC3D;AACA;AACA,6BAA6B,WAAW,KAAK,UAAU;AACvD;AACA;AACA,sBAAsB,UAAU;AAChC;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC,SAAS;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC,SAAS;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC,SAAS;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC,SAAS;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;ACvJsD;AACT;AACc;AACJ;AACO;AACG;AACV;AACV;AACE;AACT;AACa;AACnD;AACA,IAAI,8DAAY;AAChB;AACA;AACA;AACA,0BAA0B,uDAAU;AACpC;AACA;AACA;AACA;AACA,0BAA0B,uDAAU;AACpC;AACA;AACA;AACA,iBAAiB,yDAAQ;AACzB,0BAA0B,uDAAU;AACpC,iBAAiB,2DAAgB;AACjC,0BAA0B,6DAAgB;AAC1C,8BAA8B,yDAAS;AACvC;AACA;AACA;AACA;AACA,8BAA8B,uDAAU;AACxC;AACA,iCAAiC,6DAAS;AAC1C;AACA;AACA,8BAA8B,uDAAU;AACxC;AACA;AACA;AACA;AACA,8BAA8B,uDAAU;AACxC;AACA,iCAAiC,6DAAS;AAC1C;AACA;AACA,8BAA8B,uDAAU;AACxC;AACA;AACA,uCAAuC,yDAAc,yEAAyE,sDAAS;AACvI;AACA;AACA;AACA,0BAA0B,uDAAU;AACpC,mBAAmB,yDAAK;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,uDAAU;AACpC,mBAAmB,0DAAK;AACxB;AACA;AACA;AACA;AACA;AACA,0BAA0B,uDAAU;AACpC;AACA,0BAA0B,uDAAU;AACpC;AACA;AACA,0BAA0B,uDAAU;AACpC;AACA,0BAA0B,uDAAU;AACpC;AACA;AACA,sBAAsB,6DAAS;AAC/B;AACA;AACA,0BAA0B,uDAAU;AACpC;AACA,mBAAmB,4DAAO;AAC1B;AACA;AACA;AACA;AACA;AACA,0BAA0B,uDAAU;AACpC,mBAAmB,yDAAK;AACxB;AACA;AACA;AACA;AACA;AACA,0BAA0B,uDAAU;AACpC;AACA,0BAA0B,uDAAU;AACpC;AACA,0BAA0B,uDAAU;AACpC;AACA;AACA,qBAAqB,6DAAS;AAC9B;AACA;AACA,0BAA0B,uDAAU;AACpC;AACA;AACA;AACA,sBAAsB,6DAAS;AAC/B;AACA;AACA,0BAA0B,uDAAU;AACpC;AACA,mBAAmB,qDAAQ;AAC3B;AACA;AACA,sBAAsB,6DAAgB;AACtC;AACA;AACA;AACA,iEAAe,oBAAoB,EAAC;;;;;;;;;;;;;;;;;;;;;;;;;;AC9HgB;AACP;AACc;AACJ;AACO;AACM;AACf;AACR;AACE;AACE;AACjD,uFAAuF;AACvF;AACA;AACA;AACA,IAAI,8DAAY;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,2DAAgB;AACjC,0BAA0B,6DAAgB;AAC1C;AACA,oBAAoB,WAAW;AAC/B,kBAAkB,oBAAoB;AACtC,mDAAmD,2DAAgB;AACnE,oBAAoB,iBAAiB,QAAQ,yDAAS;AACtD,uCAAuC,yDAAc,uEAAuE,sDAAS;AACrI,2BAA2B,OAAO;AAClC;AACA;AACA;AACA,iCAAiC,6DAAS;AAC1C;AACA,iCAAiC,6DAAS;AAC1C;AACA;AACA;AACA;AACA,iCAAiC,uDAAW;AAC5C;AACA,iCAAiC,uDAAK;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iCAAiC,uDAAW;AAC5C,iCAAiC,0DAAK;AACtC;AACA;AACA;AACA;AACA;AACA,iCAAiC,uDAAW;AAC5C,oBAAoB,WAAW;AAC/B,eAAe,8BAA8B,QAAQ,4DAAO;AAC5D;AACA;AACA;AACA;AACA;AACA,iCAAiC,uDAAW;AAC5C,iCAAiC,uDAAK;AACtC;AACA;AACA;AACA;AACA;AACA,iCAAiC,uDAAW;AAC5C,oBAAoB,KAAK;AACzB,eAAe,8BAA8B,QAAQ,kDAAQ;AAC7D;AACA;AACA;AACA,sBAAsB,6DAAgB;AACtC;AACA;AACA,aAAa;AACb;AACA,iEAAe,oBAAoB,EAAC;;;;;;;;;;;;;;;;ACtFpC,iEAAe,2CAA2C,EAAC;;;;;;;;;;;;;;;;ACA3D,iEAAe;AACf,mCAAmC,KAAK;AACxC,yBAAyB,WAAW,SAAS,SAAS,aAAa,WAAW;AAC9E,CAAC,EAAC;;;;;;;;;;;;;;;;;ACHF;AACA;AACA;AACA,8BAA8B,iBAAiB,OAAO,KAAK;AAC3D;AACA;AACA,8BAA8B,UAAU,KAAK,SAAS;AACtD;AACA;AACA,0BAA0B,SAAS;AACnC;AACA;AACA,4BAA4B,OAAO;AACnC;AACA;AACA,qCAAqC,YAAY;AACjD;AACA;AACA;AACA,+CAA+C,wBAAwB;AACvE;AACA;AACA;AACA;AACA,iEAAe;AACf;AACA,CAAC,EAAC;AACK;AACP,kCAAkC,KAAK;AACvC;;;;;;;;;;;;;;;;AC7BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iEAAe,UAAU,EAAC;;;;;;;;;;;;;;;;ACrB1B;AACA;AACA;AACe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;ACfqD;AACX;AACnC;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,6DAAgB,+BAA+B,IAAI;AACzE;AACA;AACA,iEAAe,SAAS,8DAAM,qCAAqC,EAAC;;;;;;;;;;;;;;;;;;;;;ACnBiB;AACzC;AACb;AACF;AACS;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iEAAe,8CAA8C;AAC7D,YAAY,MAAM;AAClB;AACA;AACA;AACA,kBAAkB,qEAAwB;AAC1C;AACA;AACA;AACA,6BAA6B,qDAAO;AACpC;AACA;AACA;AACA,SAAS,yDAAQ;AACjB,kBAAkB,uDAAU;AAC5B;AACA,YAAY,8DAA8D;AAC1E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,qEAAwB,sBAAsB,MAAM;AAC1E;AACA;AACA;AACA,kBAAkB,qEAAwB;AAC1C;AACA;AACA,kBAAkB,qEAAwB;AAC1C;AACA;AACA;AACA,kBAAkB,qEAAwB;AAC1C;AACA;AACA;AACA;AACA,wBAAwB,oDAAI;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,cAAc;AAC1B,gBAAgB,qDAAK;AACrB;AACA,kBAAkB,qEAAwB;AAC1C;AACA;AACA;AACA,sBAAsB,qEAAwB;AAC9C;AACA;AACA,sBAAsB,qEAAwB;AAC9C;AACA;AACA;AACA;AACA,sBAAsB,qEAAwB;AAC9C;AACA;AACA,sBAAsB,uDAAU;AAChC;AACA;AACA;AACA;AACA,oEAAoE,oDAAI;AACxE;AACA,sBAAsB,uDAAU;AAChC;AACA;AACA,sBAAsB,qEAAwB;AAC9C;AACA;AACA;AACA,CAAC,EAAC;;;;;;;;;;;;;;;;ACrGF;AACA;AACA;AACA;AACA;AACA;AACA,iEAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,EAAC;;;;;;;;;;;;;;;;AC3CF;AACA;AACA;AACA,gCAAgC,OAAO;AACvC;AACA;AACA;AACA;AACA;AACA;AACA,iEAAe,kBAAkB,EAAC;;;;;;;;;;;;;;;;;ACVmB;AACrD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,6DAAgB,gCAAgC,UAAU;AAChF;AACA;AACA,yDAAyD,UAAU;AACnE;AACA;AACA,yDAAyD,UAAU;AACnE;AACA;AACA;AACA;AACA,iEAAe,YAAY,EAAC;;;;;;;;;;;;;;;;;;;;;;ACjCY;AACa;AACI;AACC;AACjB;AACzC;AACA;AACA,yDAAyD,IAAI;AAC7D;AACA;AACA;AACA,QAAQ,0DAAW;AACnB,QAAQ,qEAAiB;AACzB;AACA;AACA;AACA,eAAe,qDAAM;AACrB;AACA,wBAAwB,qEAAe,SAAS,kDAAK;AACrD;AACO;AACP;AACA;AACA,+BAA+B,qDAAM,iCAAiC,iDAAc;AACpF,gCAAgC,qDAAM;AACtC;AACO;AACP;AACA;AACA,+BAA+B,qDAAM,+DAA+D,iDAAc;AAClH,gCAAgC,qDAAM;AACtC;;;;;;;;;;;;;;;;;;;;;;;;;;AC/BqD;AACK;AACE;AACf;AACQ;AACZ;AACzC;AACA,SAAS,0DAAW;AACpB,4BAA4B,qEAAe,SAAS,kDAAK;AACzD;AACA;AACA;AACA;AACA;AACA,4CAA4C,SAAS;AACrD;AACA,WAAW,8DAAS,CAAC,2DAAY,sBAAsB,qDAAM,wCAAwC,uBAAuB;AAC5H;AACO;AACP;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,6DAAgB;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,8BAA8B,cAAc;AACtE;AACA;AACA;AACA;AACA;AACA,0BAA0B,wCAAwC,cAAc;AAChF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B,iCAAiC;AAC9D;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wDAAwD,2BAA2B,IAAI;AACvF;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA,sBAAsB,6DAAgB;AACtC;AACA,WAAW,qDAAM;AACjB;AACO;AACP;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,oBAAoB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,2DAAY;AACvB;AACA;AACA;AACA,gBAAgB,2DAAY;AAC5B,WAAW,8DAAS;AACpB;AACO;AACP;AACA;AACA;AACA;AACA;AACA,uEAAuE,OAAO;AAC9E;AACA;AACA;;;;;;;;;;;;;;;;;;;;ACzM0D;AACnD;AACP;AACA;AACA,oBAAoB,yDAAO;AAC3B;AACA;AACA;AACA,oBAAoB,sBAAsB;AAC1C;AACA;AACA;AACA;AACO;AACP;AACA;AACO;AACP;AACA;AACA,oBAAoB,mBAAmB;AACvC;AACA;AACA;AACA;AACO;AACP;AACA;AACA,kBAAkB,yDAAO;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;ACpCA;AACA,MAAM,+BAA+B;AACrC;AACA;AACA;AACA,iEAAe,cAAc,EAAC;;;;;;;;;;;;;;;;;ACLiB;AAC/C;AACA;AACA;AACA,kBAAkB,uDAAU,oDAAoD,UAAU,YAAY,QAAQ;AAC9G;AACA;AACA,iEAAe,cAAc,EAAC;;;;;;;;;;;;;;;;ACP9B,iEAAe;AACf;AACA,gBAAgB,gBAAgB;AAChC;AACA,mCAAmC,KAAK;AACxC;AACA;AACA,CAAC,EAAC;;;;;;;;;;;;;;;;;;;;;;;;;ACPwD;AACJ;AACH;AACE;AACqB;AACrB;AACI;AACC;AACjB;AACzC;AACA;AACA,4BAA4B,qEAAe;AAC3C;AACA;AACA,yBAAyB,qDAAM;AAC/B,yBAAyB,qDAAM;AAC/B,qBAAqB,aAAa;AAClC;AACA,KAAK;AACL,oBAAoB,4DAAM,sBAAsB,8DAAQ;AACxD,8CAA8C,qDAAM;AACpD;AACA;AACA,yBAAyB,iEAAe;AACxC;AACA;AACA;AACA;AACA,kBAAkB,gEAAmB;AACrC;AACA;AACA;AACA,yCAAyC,qDAAM,kBAAkB,qBAAqB;AACtF;AACA;AACA;AACA;AACA,kBAAkB,gEAAmB;AACrC;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,qDAAM;AAC7B;AACA;AACA,QAAQ,qEAAiB;AACzB;AACA;AACA;AACA,oCAAoC,qDAAM;AAC1C;AACA;AACA;AACA;AACA,SAAS,UAAU,4DAAM;AACzB;AACA;AACA,kBAAkB,gEAAmB;AACrC;AACA;AACA;AACA,SAAS,0DAAW;AACpB,4BAA4B,qEAAe,SAAS,kDAAK;AACzD;AACA,IAAI,mEAAa;AACjB;AACA;AACA;AACA;AACA;AACA,gBAAgB,gEAAc;AAC9B;AACA;AACA;AACA;AACA;AACA,gBAAgB,gEAAc;AAC9B;AACA;AACA,sBAAsB,6DAAgB;AACtC;AACA;AACA,iEAAe,OAAO,EAAC;;;;;;;;;;;;;;;;;ACpFa;AACpC;AACA,gCAAgC,oBAAoB;AACpD,gCAAgC,qDAAM;AACtC;AACA,iEAAe,MAAM,EAAC;;;;;;;;;;;;;;;;;;;;;;;ACLwE;AACzC;AACI;AACC;AACjB;AAClC;AACP,SAAS,0DAAW;AACpB,4BAA4B,qEAAe,eAAe,kDAAK;AAC/D;AACA,IAAI,qEAAiB;AACrB,SAAS,0DAAW;AACpB,4BAA4B,qEAAe,gBAAgB,kDAAK;AAChE;AACA,IAAI,qEAAiB;AACrB,kBAAkB,4DAAM,CAAC,oEAAc,CAAC,yDAAO,qBAAqB,oEAAc,OAAO,oEAAc,OAAO,8DAAQ;AACtH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,qDAAM;AACpD;AACA;AACA,KAAK;AACL,WAAW,+DAAS;AACpB;AACO;AACP,SAAS,0DAAW;AACpB,4BAA4B,qEAAe,SAAS,kDAAK;AACzD;AACA,WAAW,qDAAM;AACjB;AACO;AACP,SAAS,0DAAW;AACpB,4BAA4B,qEAAe,SAAS,kDAAK;AACzD;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;AC7C0D;AACJ;AACH;AACE;AACI;AACC;AACL;AACZ;AACzC;AACA;AACA,4BAA4B,qEAAe;AAC3C;AACA;AACA,yBAAyB,qDAAM;AAC/B,yBAAyB,qDAAM;AAC/B,qBAAqB,aAAa;AAClC;AACA,KAAK;AACL,4CAA4C,qDAAM;AAClD;AACA;AACA,KAAK;AACL,oBAAoB,4DAAM,sBAAsB,8DAAQ;AACxD,sCAAsC,qDAAM;AAC5C,aAAa;AACb;AACA;AACA;AACA;AACA,uBAAuB,qDAAM;AAC7B;AACA;AACA,QAAQ,qEAAiB;AACzB;AACA;AACA,2CAA2C,qDAAM;AACjD;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,aAAa;AACb;AACA;AACA,SAAS,0DAAW;AACpB,4BAA4B,qEAAe,SAAS,kDAAK;AACzD;AACA,IAAI,mEAAa;AACjB;AACA;AACA;AACA;AACA;AACA,gBAAgB,gEAAc;AAC9B;AACA;AACA;AACA;AACA;AACA,gBAAgB,gEAAc;AAC9B;AACA;AACA,sBAAsB,6DAAgB;AACtC;AACA;AACA,iEAAe,OAAO,EAAC;;;;;;;;;;;;;;;;;ACnEoC;AAC3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,sBAAsB,wDAAW;AACjC;AACA,KAAK;AACL;AACA;AACA;AACA,kBAAkB,sDAAS;AAC3B;AACA;AACA;AACA;AACA;AACA,kBAAkB,sDAAS;AAC3B;AACA;AACA,iEAAe,SAAS,EAAC;;;;;;;;;;;;;;;;;;;;ACjCW;AACiB;AACpB;AAC1B;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,2BAA2B,OAAO;AAC5D;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,sDAAM;AACzB;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA,sBAAsB,6DAAgB;AACtC;AACA,WAAW,qDAAM;AACjB;AACA;AACA;AACA;AACA;AACA,kBAAkB,6DAAgB;AAClC;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B,cAAc;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B,cAAc;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B,iCAAiC;AAC9D;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC;AAClC;AACA;AACA,8BAA8B,6DAAgB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC;AAClC;AACA;AACA;AACA;AACA,kCAAkC;AAClC;AACA;AACA,8BAA8B,6DAAgB;AAC9C;AACA;AACA;AACA;AACA,sBAAsB,6DAAgB;AACtC;AACA,YAAY,qDAAM;AAClB;;;;;;;;;;;;;;;;;;;;AC5IqD;AACI;AACC;AACjB;AAC1B;AACf,QAAQ,0DAAW;AACnB,QAAQ,qEAAiB;AACzB;AACA;AACA;AACA;AACA,gCAAgC,qEAAe,SAAS,kDAAK;AAC7D;AACA,eAAe,qDAAM,gCAAgC,aAAa,cAAc,iBAAiB;AACjG;AACA,wBAAwB,qEAAe,SAAS,kDAAK;AACrD;;;;;;;;;;;;;;;;;;AChB6C;AAC7C,iEAAe;AACf,WAAW,0DAAW;AACtB,CAAC,EAAC;AACK;;;;;;;;;;;;;;;;;;;ACJ6B;AACiB;AACA;AACrD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC,2BAA2B,kBAAkB;AAC/E;AACA;AACA;AACA;AACA;AACA,8BAA8B,6DAAgB,IAAI,SAAS;AAC3D;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC;AAClC;AACA;AACA;AACA;AACA;AACA,kCAAkC;AAClC;AACA;AACA;AACA;AACA;AACA,kCAAkC;AAClC;AACA;AACA;AACA,8BAA8B,6DAAgB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC,8BAA8B,kBAAkB;AAClF;AACA;AACA;AACA;AACA;AACA,kCAAkC,wCAAwC,kBAAkB;AAC5F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qCAAqC,qCAAqC;AAC1E;AACA;AACA;AACA;AACA,8BAA8B,6DAAgB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC;AAClC;AACA;AACA;AACA,kCAAkC;AAClC;AACA;AACA;AACA,kCAAkC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC;AAClC;AACA;AACA;AACA,8BAA8B,6DAAgB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC;AAClC;AACA;AACA;AACA,8BAA8B,6DAAgB;AAC9C;AACA;AACA;AACA;AACA,sBAAsB,6DAAgB;AACtC;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,uBAAuB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,qDAAM,yBAAyB,qDAAS;AACvD;AACA,sBAAsB;AACtB;AACA;AACA,WAAW,qDAAM;AACjB;AACA,iEAAe,KAAK,EAAC;;;;;;;;;;;;;;;;;;;;AC9IgC;AACK;AACL;AACZ;AACzC;AACA;AACA;AACA;AACA,eAAe,qDAAS;AACxB;AACA;AACA,SAAS,0DAAW;AACpB,4BAA4B,qEAAe,SAAS,kDAAK;AACzD;AACA;AACA;AACA;AACA,YAAY,iCAAiC,QAAQ,qDAAM;AAC3D;AACA;AACA,iEAAe,QAAQ,EAAC;;;;;;;;;;;;;;;;;;;;;;;;;;ACpBS;AAC0B;AACN;AACX;AACC;AACU;AACI;AACC;AACjB;AACzC;AACA;AACA,eAAe,qDAAM;AACrB;AACA,QAAQ,0DAAW;AACnB,QAAQ,qEAAiB;AACzB;AACA;AACA,wBAAwB,qEAAe,SAAS,kDAAK;AACrD;AACA;AACA,IAAI,6DAAQ;AACZ,iBAAiB,yDAAU;AAC3B;AACA;AACA,qBAAqB,iBAAiB;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,qDAAM;AAC1C;AACA;AACA,eAAe,qDAAM;AACrB;AACA;AACA;AACO,wDAAwD,sDAAM;AACrE;AACA,+BAA+B,+CAAI;AACnC,aAAa,wBAAwB,qDAAS;AAC9C;AACO;AACP;AACA,WAAW,iDAAM;AACjB;;;;;;;;;;;;;;;;;AClDoC;AACpC,iEAAe,qDAAM,sBAAsB,qDAAM,CAAC,EAAC;;;;;;;;;;;;;;;;;;;;;;;;ACDH;AACR;AACa;AACI;AACN;AACO;AACjB;AAClC;AACP,SAAS,0DAAW;AACpB,4BAA4B,qEAAe,SAAS,kDAAK;AACzD;AACA,IAAI,qEAAiB;AACrB,IAAI,gEAAc;AAClB;AACA,oCAAoC,qDAAM,gBAAgB,4DAAe;AACzE;AACA;AACA,mCAAmC,qDAAM,iCAAiC,iDAAc;AACxF,oCAAoC,qDAAM,0CAA0C,4DAAe;AACnG;AACA;AACA;AACO;AACP,SAAS,0DAAW;AACpB,4BAA4B,qEAAe,SAAS,kDAAK;AACzD;AACA,IAAI,qEAAiB;AACrB,IAAI,gEAAc;AAClB;AACA,oCAAoC,qDAAM,gBAAgB,4DAAe;AACzE;AACA;AACA,mCAAmC,qDAAM,4CAA4C,4DAAe,UAAU,iDAAc;AAC5H,oCAAoC,qDAAM;AAC1C;AACA;AACA;;;;;;;;;;;;;;;;ACpCA,iEAAe,cAAc,EAAC;;;;;;;;;;;;;;;;;;;;ACAgB;AACV;AACe;AACD;AAClD;AACA,4BAA4B,mEAAU;AACtC,IAAI,gEAAc;AAClB,4BAA4B,qDAAM,aAAa,0DAAe;AAC9D;AACA;AACA,iEAAe,IAAI,EAAC;;;;;;;;;;;;;;;;;ACViC;AACtC;AACf,wBAAwB,cAAc;AACtC;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA,qBAAqB;AACrB;AACA,qBAAqB;AACrB;AACA,sBAAsB,6DAAgB,QAAQ,KAAK;AACnD;AACA;;;;;;;;;;;;;;;;;ACzBqD;AACtC;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,6DAAgB,QAAQ,KAAK;AACnD;AACA;;;;;;;;;;;;;;;;ACXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iEAAe,eAAe,EAAC;;;;;;;;;;;;;;;;;;;;AClBe;AACV;AACe;AACC;AACpD;AACA,4BAA4B,mEAAY;AACxC,IAAI,gEAAc;AAClB,sBAAsB,0DAAe;AACrC;AACA,qBAAqB,qDAAM;AAC3B;AACA;AACA;AACA;AACA;AACA,iEAAe,MAAM,EAAC;;;;;;;;;;;;;;;;;ACftB,iEAAe,MAAM,EAAC;AACf;;;;;;;;;;;;;;;;;;ACD8C;AAC9C;AACP,cAAc,6DAAgB;AAC9B;AACO;AACP,cAAc,6DAAgB;AAC9B;;;;;;;;;;;;;;;;;;ACNqD;AAC9C,eAAe,yDAAgB;AAC/B,eAAe,yDAAgB;;;;;;;;;;;;;;;;;;;;ACFe;AACJ;AACN;AACF;AAClC;AACP;AACA,kBAAkB,kDAAU;AAC5B,YAAY,qBAAqB;AACjC;AACA,kBAAkB,kDAAU;AAC5B;AACA,kBAAkB,kDAAU;AAC5B;AACA,kBAAkB,kDAAU;AAC5B;AACA;AACA,kBAAkB,qDAAS;AAC3B;AACA;AACA,kBAAkB,kDAAU;AAC5B;AACA;AACA;AACA,4BAA4B,yDAAO;AACnC;AACA;AACA,kBAAkB,kDAAU;AAC5B;AACA,SAAS,6DAAQ;AACjB,kBAAkB,kDAAU;AAC5B;AACA;;;;;;;;;;;;;;;;;;;AC/BqD;AACJ;AACN;AACpC;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC,yDAAO,QAAQ,qDAAS;AAC1D,aAAa,6DAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACjCO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;AC7J0C;AAC1C,iEAAe,2DAAK,EAAC;;;;;;;UCDrB;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;WCtBA;WACA;WACA;WACA;WACA;WACA,iCAAiC,WAAW;WAC5C;WACA;;;;;WCPA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,sDAAsD;WACtD,sCAAsC,iEAAiE;WACvG;WACA;WACA;WACA;WACA;WACA;;;;;WCzBA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;WACA;WACA;WACA;WACA,GAAG;WACH;WACA;WACA,CAAC;;;;;WCPD;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D;;;;;;;;;;;;;;;;;;;;;;;;;;ACNqG;AAC7C;AAC3B;;AAE+B;AAEX;AAC4B;;AAEV;AACF;AAElB;AAC0B;;AAEhC;;AAEzC;AACA,uBAAuB,sEAAmB;AAC1C,mBAAmB,mDAAe,EAAE,8EAAoB,EAAE,sEAAc;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,wEAAqB;AAC9B,CAAC;;AAED;AACA,EAAE,qDAAmB;AACrB;;AAEA;AACA;AACA;;AAEA,wBAAwB,qEAAwB,GAAG,YAAY;AAC/D;AACA,oBAAoB,6EAAkB;AACtC,2CAA2C,mFAAwB;AACnE,GAAG;;AAEH;AACA;AACA;AACA,sDAAsD,gBAAgB;AACtE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA,oBAAoB,iDAAoB;AACxC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB,0DAAwB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV,wCAAwC,IAAI;AAC5C,UAAU;AACV;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,WAAW,QAAQ,WAAW;AAC9B;AACA,WAAW,QAAQ;AACnB,WAAW,UAAU;AACrB;AACA,aAAa,iCAAiC;AAC9C;AACA,uDAAuD;AACvD,UAAU,aAAa;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA,4BAA4B,oGAA0B;AACtD;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,sBAAsB,uFAAoB,GAAG,cAAc;AAC3D,UAAU;AACV;AACA,sBAAsB,6EAAkB;AACxC,yBAAyB,mFAAwB;AACjD,WAAW;AACX,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC,QAAQ;AAC1C,iBAAiB,mEAAgB;AACjC,IAAI;AACJ;AACA;AACA,kBAAkB,oCAAoC;AACtD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,0CAA0C,iBAAiB;AAC3D,0BAA0B,2CAAc;AACxC,mBAAmB;;AAEnB;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,wBAAwB,yCAAY;AACpC;AACA;;AAEA,WAAW;AACX;;AAEA;AACA,qDAAqD,iBAAiB;AACtE,UAAU,uBAAuB,mCAAmC,iBAAiB;;AAErF;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,4CAA4C,mBAAmB;AAC/D,0BAA0B,2CAAc;AACxC,mBAAmB;AACnB;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;;AAEA,wBAAwB,yCAAY;AACpC;AACA;;AAEA,WAAW;AACX;;AAEA;AACA,uDAAuD,mBAAmB;AAC1E,UAAU,uBAAuB,qCAAqC,mBAAmB;;AAEzF;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,uCAAuC,mBAAmB;AAC1D;AACA;AACA;AACA;AACA,SAAS,wDAAK,GAAG,mDAAmD;AACpE;;AAEA,yCAAyC,qBAAqB;AAC9D;AACA;AACA;AACA;AACA,SAAS,mEAAgB,GAAG,+EAA+E;AAC3G;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,6CAA6C,kBAAkB;AAC/D,gDAAgD,kBAAkB;AAClE;AACA;;AAEA;AACA;AACA;AACA,gDAAgD,kBAAkB;AAClE,mDAAmD,kBAAkB;AACrE;;AAEA;AACA;AACA;AACA,8CAA8C,kBAAkB;AAChE,iDAAiD,kBAAkB;AACnE;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,2CAA2C,kCAAkC;AAC7E;;AAEA;AACA;AACA,8CAA8C,qCAAqC;AACnF;;AAEA;AACA;AACA,4CAA4C,mCAAmC;AAC/E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,4CAA4C,4DAA4D,KAAK,eAAe;AAC5H,yCAAyC,mDAAmD;AAC5F;;AAEA;AACA;AACA,uCAAuC,iCAAiC,KAAK,eAAe;AAC5F;;AAEA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,6CAA6C,kBAAkB;AAC/D,gDAAgD,kBAAkB;AAClE;AACA;;AAEA;AACA;AACA;AACA,gDAAgD,kBAAkB;AAClE,mDAAmD,kBAAkB;AACrE;;AAEA;AACA;AACA;AACA,8CAA8C,kBAAkB;AAChE,iDAAiD,kBAAkB;AACnE;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,2CAA2C,kCAAkC;AAC7E;;AAEA;AACA;AACA,8CAA8C,qCAAqC;AACnF;;AAEA;AACA;AACA,4CAA4C,mCAAmC;AAC/E;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,4CAA4C,8DAA8D,KAAK,eAAe;AAC9H,yCAAyC,qDAAqD;AAC9F;;AAEA;AACA;AACA,uCAAuC,mCAAmC,KAAK,eAAe;AAC9F;;AAEA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,QAAQ;AACR;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;;AAEA;AACA,sEAAsE,qCAAqC;AAC3G,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,kEAAkE,uDAAuD;AACzH;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA,oBAAoB,uBAAuB,mCAAmC,mCAAmC;AACjH;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,gEAAgE,mBAAmB;AACnF,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,4DAA4D,uDAAuD;AACnH;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,MAAM;AACN;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,sEAAsE,qCAAqC;AAC3G,YAAY;AACZ;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,oBAAoB,uBAAuB,mCAAmC,mCAAmC;AACjH;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,kEAAkE,mBAAmB;AACrF,QAAQ;AACR;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,uBAAuB,mCAAmC,iBAAiB;AAC3F;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,oEAAoE,qBAAqB;AACzF,MAAM;AACN;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,MAAM;AACN;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,wBAAwB,qEAAwB;AAChD,oBAAoB,6EAAkB;AACtC,2CAA2C,mFAAwB;AACnE,GAAG;AACH,oBAAoB,iDAAoB;;AAExC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA","sources":["webpack://respec-vc/./contexts.js","webpack://respec-vc/./node_modules/@digitalbazaar/data-integrity-context/js/constants.js","webpack://respec-vc/./node_modules/@digitalbazaar/data-integrity-context/js/data-integrity-v1.js","webpack://respec-vc/./node_modules/@digitalbazaar/data-integrity-context/js/data-integrity-v2.js","webpack://respec-vc/./node_modules/@digitalbazaar/data-integrity-context/js/index.js","webpack://respec-vc/./node_modules/@digitalbazaar/security-context/dist/context.esm.js","webpack://respec-vc/./node_modules/canonicalize/lib/canonicalize.js","webpack://respec-vc/./node_modules/credentials-context/dist/context.esm.js","webpack://respec-vc/./node_modules/ed25519-signature-2018-context/dist/context.esm.js","webpack://respec-vc/./node_modules/ed25519-signature-2020-context/dist/context.esm.js","webpack://respec-vc/./node_modules/jsonld-signatures/lib/ProofSet.js","webpack://respec-vc/./node_modules/jsonld-signatures/lib/VerificationError.js","webpack://respec-vc/./node_modules/jsonld-signatures/lib/constants.js","webpack://respec-vc/./node_modules/jsonld-signatures/lib/contexts.js","webpack://respec-vc/./node_modules/jsonld-signatures/lib/documentLoader.js","webpack://respec-vc/./node_modules/jsonld-signatures/lib/jsonld-signatures.js","webpack://respec-vc/./node_modules/jsonld-signatures/lib/purposes.js","webpack://respec-vc/./node_modules/jsonld-signatures/lib/purposes/AssertionProofPurpose.js","webpack://respec-vc/./node_modules/jsonld-signatures/lib/purposes/AuthenticationProofPurpose.js","webpack://respec-vc/./node_modules/jsonld-signatures/lib/purposes/ControllerProofPurpose.js","webpack://respec-vc/./node_modules/jsonld-signatures/lib/purposes/ProofPurpose.js","webpack://respec-vc/./node_modules/jsonld-signatures/lib/sha256digest-browser.js","webpack://respec-vc/./node_modules/jsonld-signatures/lib/suites.js","webpack://respec-vc/./node_modules/jsonld-signatures/lib/suites/LinkedDataProof.js","webpack://respec-vc/./node_modules/jsonld-signatures/lib/suites/LinkedDataSignature.js","webpack://respec-vc/./node_modules/jsonld-signatures/lib/util.js","webpack://respec-vc/./node_modules/jsonld/lib/ContextResolver.js","webpack://respec-vc/./node_modules/jsonld/lib/JsonLdError.js","webpack://respec-vc/./node_modules/jsonld/lib/JsonLdProcessor.js","webpack://respec-vc/./node_modules/jsonld/lib/NQuads.js","webpack://respec-vc/./node_modules/jsonld/lib/RequestQueue.js","webpack://respec-vc/./node_modules/jsonld/lib/ResolvedContext.js","webpack://respec-vc/./node_modules/jsonld/lib/compact.js","webpack://respec-vc/./node_modules/jsonld/lib/constants.js","webpack://respec-vc/./node_modules/jsonld/lib/context.js","webpack://respec-vc/./node_modules/jsonld/lib/documentLoaders/xhr.js","webpack://respec-vc/./node_modules/jsonld/lib/events.js","webpack://respec-vc/./node_modules/jsonld/lib/expand.js","webpack://respec-vc/./node_modules/jsonld/lib/flatten.js","webpack://respec-vc/./node_modules/jsonld/lib/frame.js","webpack://respec-vc/./node_modules/jsonld/lib/fromRdf.js","webpack://respec-vc/./node_modules/jsonld/lib/graphTypes.js","webpack://respec-vc/./node_modules/jsonld/lib/jsonld.js","webpack://respec-vc/./node_modules/jsonld/lib/nodeMap.js","webpack://respec-vc/./node_modules/jsonld/lib/platform-browser.js","webpack://respec-vc/./node_modules/jsonld/lib/toRdf.js","webpack://respec-vc/./node_modules/jsonld/lib/types.js","webpack://respec-vc/./node_modules/jsonld/lib/url.js","webpack://respec-vc/./node_modules/jsonld/lib/util.js","webpack://respec-vc/./node_modules/lru-cache/index.js","webpack://respec-vc/./node_modules/rdf-canonize/index.js","webpack://respec-vc/./node_modules/rdf-canonize/lib/IdentifierIssuer.js","webpack://respec-vc/./node_modules/rdf-canonize/lib/MessageDigest-browser.js","webpack://respec-vc/./node_modules/rdf-canonize/lib/NQuads.js","webpack://respec-vc/./node_modules/rdf-canonize/lib/Permuter.js","webpack://respec-vc/./node_modules/rdf-canonize/lib/URDNA2015.js","webpack://respec-vc/./node_modules/rdf-canonize/lib/URDNA2015Sync.js","webpack://respec-vc/./node_modules/rdf-canonize/lib/URGNA2012.js","webpack://respec-vc/./node_modules/rdf-canonize/lib/URGNA2012Sync.js","webpack://respec-vc/./node_modules/rdf-canonize/lib/index.js","webpack://respec-vc/./node_modules/serialize-error/index.js","webpack://respec-vc/./node_modules/setimmediate/setImmediate.js","webpack://respec-vc/./node_modules/yallist/iterator.js","webpack://respec-vc/./node_modules/yallist/yallist.js","webpack://respec-vc/ignored|/Users/xavi/Developer/1EdTech/respec-vc/node_modules/@noble/ed25519/lib/esm|crypto","webpack://respec-vc/ignored|/Users/xavi/Developer/1EdTech/respec-vc/node_modules/rdf-canonize/lib|rdf-canonize-native","webpack://respec-vc/./node_modules/@digitalbazaar/credentials-v2-context/js/context.js","webpack://respec-vc/./node_modules/@digitalbazaar/credentials-v2-context/js/index.js","webpack://respec-vc/./node_modules/@digitalbazaar/data-integrity/lib/DataIntegrityProof.js","webpack://respec-vc/./node_modules/@digitalbazaar/data-integrity/lib/index.js","webpack://respec-vc/./node_modules/@digitalbazaar/data-integrity/lib/sha256digest-browser.js","webpack://respec-vc/./node_modules/@digitalbazaar/data-integrity/lib/util.js","webpack://respec-vc/./node_modules/@digitalbazaar/ed25519-multikey/lib/constants.js","webpack://respec-vc/./node_modules/@digitalbazaar/ed25519-multikey/lib/ed25519-browser.js","webpack://respec-vc/./node_modules/@digitalbazaar/ed25519-multikey/lib/factory.js","webpack://respec-vc/./node_modules/@digitalbazaar/ed25519-multikey/lib/helpers.js","webpack://respec-vc/./node_modules/@digitalbazaar/ed25519-multikey/lib/index.js","webpack://respec-vc/./node_modules/@digitalbazaar/ed25519-multikey/lib/keyPairTranslationMap.js","webpack://respec-vc/./node_modules/@digitalbazaar/ed25519-multikey/lib/keyPairTranslator.js","webpack://respec-vc/./node_modules/@digitalbazaar/ed25519-multikey/lib/serialize.js","webpack://respec-vc/./node_modules/@digitalbazaar/ed25519-multikey/lib/validators.js","webpack://respec-vc/./node_modules/@digitalbazaar/ed25519-signature-2020/lib/Ed25519Signature2020.js","webpack://respec-vc/./node_modules/@digitalbazaar/ed25519-signature-2020/lib/index.js","webpack://respec-vc/./node_modules/@digitalbazaar/ed25519-verification-key-2020/lib/Ed25519VerificationKey2020.js","webpack://respec-vc/./node_modules/@digitalbazaar/ed25519-verification-key-2020/lib/ed25519-browser.js","webpack://respec-vc/./node_modules/@digitalbazaar/ed25519-verification-key-2020/lib/index.js","webpack://respec-vc/./node_modules/@digitalbazaar/ed25519-verification-key-2020/lib/validators.js","webpack://respec-vc/./node_modules/@digitalbazaar/eddsa-rdfc-2022-cryptosuite/lib/canonize.js","webpack://respec-vc/./node_modules/@digitalbazaar/eddsa-rdfc-2022-cryptosuite/lib/createVerifier.js","webpack://respec-vc/./node_modules/@digitalbazaar/eddsa-rdfc-2022-cryptosuite/lib/index.js","webpack://respec-vc/./node_modules/@digitalbazaar/eddsa-rdfc-2022-cryptosuite/lib/name.js","webpack://respec-vc/./node_modules/@digitalbazaar/eddsa-rdfc-2022-cryptosuite/lib/requiredAlgorithm.js","webpack://respec-vc/./node_modules/@digitalbazaar/vc/lib/CredentialIssuancePurpose.js","webpack://respec-vc/./node_modules/@digitalbazaar/vc/lib/contexts/index.js","webpack://respec-vc/./node_modules/@digitalbazaar/vc/lib/contexts/odrl.js","webpack://respec-vc/./node_modules/@digitalbazaar/vc/lib/contexts/vc-examples-v1.js","webpack://respec-vc/./node_modules/@digitalbazaar/vc/lib/documentLoader.js","webpack://respec-vc/./node_modules/@digitalbazaar/vc/lib/index.js","webpack://respec-vc/./node_modules/@noble/ed25519/lib/esm/index.js","webpack://respec-vc/./node_modules/base58-universal/lib/baseN.js","webpack://respec-vc/./node_modules/base58-universal/lib/index.js","webpack://respec-vc/./node_modules/base64url-universal/lib/base64url.js","webpack://respec-vc/./node_modules/base64url-universal/lib/browser.js","webpack://respec-vc/./node_modules/crypto-ld/lib/CryptoLD.js","webpack://respec-vc/./node_modules/crypto-ld/lib/LDKeyPair.js","webpack://respec-vc/./node_modules/crypto-ld/lib/index.js","webpack://respec-vc/./node_modules/jose/dist/browser/index.js","webpack://respec-vc/./node_modules/jose/dist/browser/jwe/compact/decrypt.js","webpack://respec-vc/./node_modules/jose/dist/browser/jwe/compact/encrypt.js","webpack://respec-vc/./node_modules/jose/dist/browser/jwe/flattened/decrypt.js","webpack://respec-vc/./node_modules/jose/dist/browser/jwe/flattened/encrypt.js","webpack://respec-vc/./node_modules/jose/dist/browser/jwe/general/decrypt.js","webpack://respec-vc/./node_modules/jose/dist/browser/jwe/general/encrypt.js","webpack://respec-vc/./node_modules/jose/dist/browser/jwk/embedded.js","webpack://respec-vc/./node_modules/jose/dist/browser/jwk/thumbprint.js","webpack://respec-vc/./node_modules/jose/dist/browser/jwks/local.js","webpack://respec-vc/./node_modules/jose/dist/browser/jwks/remote.js","webpack://respec-vc/./node_modules/jose/dist/browser/jws/compact/sign.js","webpack://respec-vc/./node_modules/jose/dist/browser/jws/compact/verify.js","webpack://respec-vc/./node_modules/jose/dist/browser/jws/flattened/sign.js","webpack://respec-vc/./node_modules/jose/dist/browser/jws/flattened/verify.js","webpack://respec-vc/./node_modules/jose/dist/browser/jws/general/sign.js","webpack://respec-vc/./node_modules/jose/dist/browser/jws/general/verify.js","webpack://respec-vc/./node_modules/jose/dist/browser/jwt/decrypt.js","webpack://respec-vc/./node_modules/jose/dist/browser/jwt/encrypt.js","webpack://respec-vc/./node_modules/jose/dist/browser/jwt/produce.js","webpack://respec-vc/./node_modules/jose/dist/browser/jwt/sign.js","webpack://respec-vc/./node_modules/jose/dist/browser/jwt/unsecured.js","webpack://respec-vc/./node_modules/jose/dist/browser/jwt/verify.js","webpack://respec-vc/./node_modules/jose/dist/browser/key/export.js","webpack://respec-vc/./node_modules/jose/dist/browser/key/generate_key_pair.js","webpack://respec-vc/./node_modules/jose/dist/browser/key/generate_secret.js","webpack://respec-vc/./node_modules/jose/dist/browser/key/import.js","webpack://respec-vc/./node_modules/jose/dist/browser/lib/aesgcmkw.js","webpack://respec-vc/./node_modules/jose/dist/browser/lib/buffer_utils.js","webpack://respec-vc/./node_modules/jose/dist/browser/lib/cek.js","webpack://respec-vc/./node_modules/jose/dist/browser/lib/check_iv_length.js","webpack://respec-vc/./node_modules/jose/dist/browser/lib/check_key_type.js","webpack://respec-vc/./node_modules/jose/dist/browser/lib/check_p2s.js","webpack://respec-vc/./node_modules/jose/dist/browser/lib/crypto_key.js","webpack://respec-vc/./node_modules/jose/dist/browser/lib/decrypt_key_management.js","webpack://respec-vc/./node_modules/jose/dist/browser/lib/encrypt_key_management.js","webpack://respec-vc/./node_modules/jose/dist/browser/lib/epoch.js","webpack://respec-vc/./node_modules/jose/dist/browser/lib/format_pem.js","webpack://respec-vc/./node_modules/jose/dist/browser/lib/invalid_key_input.js","webpack://respec-vc/./node_modules/jose/dist/browser/lib/is_disjoint.js","webpack://respec-vc/./node_modules/jose/dist/browser/lib/is_object.js","webpack://respec-vc/./node_modules/jose/dist/browser/lib/iv.js","webpack://respec-vc/./node_modules/jose/dist/browser/lib/jwt_claims_set.js","webpack://respec-vc/./node_modules/jose/dist/browser/lib/secs.js","webpack://respec-vc/./node_modules/jose/dist/browser/lib/validate_algorithms.js","webpack://respec-vc/./node_modules/jose/dist/browser/lib/validate_crit.js","webpack://respec-vc/./node_modules/jose/dist/browser/runtime/aeskw.js","webpack://respec-vc/./node_modules/jose/dist/browser/runtime/asn1.js","webpack://respec-vc/./node_modules/jose/dist/browser/runtime/base64url.js","webpack://respec-vc/./node_modules/jose/dist/browser/runtime/bogus.js","webpack://respec-vc/./node_modules/jose/dist/browser/runtime/check_cek_length.js","webpack://respec-vc/./node_modules/jose/dist/browser/runtime/check_key_length.js","webpack://respec-vc/./node_modules/jose/dist/browser/runtime/decrypt.js","webpack://respec-vc/./node_modules/jose/dist/browser/runtime/digest.js","webpack://respec-vc/./node_modules/jose/dist/browser/runtime/ecdhes.js","webpack://respec-vc/./node_modules/jose/dist/browser/runtime/encrypt.js","webpack://respec-vc/./node_modules/jose/dist/browser/runtime/fetch_jwks.js","webpack://respec-vc/./node_modules/jose/dist/browser/runtime/generate.js","webpack://respec-vc/./node_modules/jose/dist/browser/runtime/get_sign_verify_key.js","webpack://respec-vc/./node_modules/jose/dist/browser/runtime/is_key_like.js","webpack://respec-vc/./node_modules/jose/dist/browser/runtime/jwk_to_key.js","webpack://respec-vc/./node_modules/jose/dist/browser/runtime/key_to_jwk.js","webpack://respec-vc/./node_modules/jose/dist/browser/runtime/pbes2kw.js","webpack://respec-vc/./node_modules/jose/dist/browser/runtime/random.js","webpack://respec-vc/./node_modules/jose/dist/browser/runtime/rsaes.js","webpack://respec-vc/./node_modules/jose/dist/browser/runtime/runtime.js","webpack://respec-vc/./node_modules/jose/dist/browser/runtime/sign.js","webpack://respec-vc/./node_modules/jose/dist/browser/runtime/subtle_dsa.js","webpack://respec-vc/./node_modules/jose/dist/browser/runtime/subtle_rsaes.js","webpack://respec-vc/./node_modules/jose/dist/browser/runtime/timing_safe_equal.js","webpack://respec-vc/./node_modules/jose/dist/browser/runtime/verify.js","webpack://respec-vc/./node_modules/jose/dist/browser/runtime/webcrypto.js","webpack://respec-vc/./node_modules/jose/dist/browser/runtime/zlib.js","webpack://respec-vc/./node_modules/jose/dist/browser/util/base64url.js","webpack://respec-vc/./node_modules/jose/dist/browser/util/decode_jwt.js","webpack://respec-vc/./node_modules/jose/dist/browser/util/decode_protected_header.js","webpack://respec-vc/./node_modules/jose/dist/browser/util/errors.js","webpack://respec-vc/./node_modules/jose/dist/browser/util/runtime.js","webpack://respec-vc/webpack/bootstrap","webpack://respec-vc/webpack/runtime/compat get default export","webpack://respec-vc/webpack/runtime/create fake namespace object","webpack://respec-vc/webpack/runtime/define property getters","webpack://respec-vc/webpack/runtime/global","webpack://respec-vc/webpack/runtime/hasOwnProperty shorthand","webpack://respec-vc/webpack/runtime/make namespace object","webpack://respec-vc/./index.js"],"sourcesContent":["\nconst contexts = new Map();\n\nfunction add(url, context) {\n  contexts.set(url, context);\n};\n\nmodule.exports = {\n    add,\n    contexts,\n  };\n","/*!\n * Copyright (c) 2022-2023 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nmodule.exports = {\n  CONTEXT_FILENAME_V1: 'data-integrity-v1.jsonld',\n  CONTEXT_FILENAME_V2: 'data-integrity-v2.jsonld',\n  DATA_INTEGRITY_CONTEXT_V1_URL: 'https://w3id.org/security/data-integrity/v1',\n  DATA_INTEGRITY_CONTEXT_V2_URL: 'https://w3id.org/security/data-integrity/v2',\n  CONTEXT_URL: 'https://w3id.org/security/data-integrity/v2',\n  CBORLD_VALUE_V1: 0x30,\n  CBORLD_VALUE: 0x33,\n};\n","/*!\n * Copyright (c) 2022-2023 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nmodule.exports = {\n  '@context': {\n    id: '@id',\n    type: '@type',\n    '@protected': true,\n    proof: {\n      '@id': 'https://w3id.org/security#proof',\n      '@type': '@id',\n      '@container': '@graph'\n    },\n    DataIntegrityProof: {\n      '@id': 'https://w3id.org/security#DataIntegrityProof',\n      '@context': {\n        '@protected': true,\n        id: '@id',\n        type: '@type',\n        challenge: 'https://w3id.org/security#challenge',\n        created: {\n          '@id': 'http://purl.org/dc/terms/created',\n          '@type': 'http://www.w3.org/2001/XMLSchema#dateTime'\n        },\n        domain: 'https://w3id.org/security#domain',\n        expires: {\n          '@id': 'https://w3id.org/security#expiration',\n          '@type': 'http://www.w3.org/2001/XMLSchema#dateTime'\n        },\n        nonce: 'https://w3id.org/security#nonce',\n        proofPurpose: {\n          '@id': 'https://w3id.org/security#proofPurpose',\n          '@type': '@vocab',\n          '@context': {\n            '@protected': true,\n            id: '@id',\n            type: '@type',\n            assertionMethod: {\n              '@id': 'https://w3id.org/security#assertionMethod',\n              '@type': '@id',\n              '@container': '@set'\n            },\n            authentication: {\n              '@id': 'https://w3id.org/security#authenticationMethod',\n              '@type': '@id',\n              '@container': '@set'\n            },\n            capabilityInvocation: {\n              '@id': 'https://w3id.org/security#capabilityInvocationMethod',\n              '@type': '@id',\n              '@container': '@set'\n            },\n            capabilityDelegation: {\n              '@id': 'https://w3id.org/security#capabilityDelegationMethod',\n              '@type': '@id',\n              '@container': '@set'\n            },\n            keyAgreement: {\n              '@id': 'https://w3id.org/security#keyAgreementMethod',\n              '@type': '@id',\n              '@container': '@set'\n            }\n          }\n        },\n        cryptosuite: 'https://w3id.org/security#cryptosuite',\n        proofValue: {\n          '@id': 'https://w3id.org/security#proofValue',\n          '@type': 'https://w3id.org/security#multibase'\n        },\n        verificationMethod: {\n          '@id': 'https://w3id.org/security#verificationMethod',\n          '@type': '@id'\n        }\n      }\n    }\n  }\n};\n","/*!\n * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nmodule.exports = {\n  '@context': {\n    id: '@id',\n    type: '@type',\n    '@protected': true,\n    proof: {\n      '@id': 'https://w3id.org/security#proof',\n      '@type': '@id',\n      '@container': '@graph'\n    },\n    DataIntegrityProof: {\n      '@id': 'https://w3id.org/security#DataIntegrityProof',\n      '@context': {\n        '@protected': true,\n        id: '@id',\n        type: '@type',\n        challenge: 'https://w3id.org/security#challenge',\n        created: {\n          '@id': 'http://purl.org/dc/terms/created',\n          '@type': 'http://www.w3.org/2001/XMLSchema#dateTime'\n        },\n        domain: 'https://w3id.org/security#domain',\n        expires: {\n          '@id': 'https://w3id.org/security#expiration',\n          '@type': 'http://www.w3.org/2001/XMLSchema#dateTime'\n        },\n        nonce: 'https://w3id.org/security#nonce',\n        previousProof: {\n          '@id': 'https://w3id.org/security#previousProof',\n          '@type': '@id'\n        },\n        proofPurpose: {\n          '@id': 'https://w3id.org/security#proofPurpose',\n          '@type': '@vocab',\n          '@context': {\n            '@protected': true,\n            id: '@id',\n            type: '@type',\n            assertionMethod: {\n              '@id': 'https://w3id.org/security#assertionMethod',\n              '@type': '@id',\n              '@container': '@set'\n            },\n            authentication: {\n              '@id': 'https://w3id.org/security#authenticationMethod',\n              '@type': '@id',\n              '@container': '@set'\n            },\n            capabilityInvocation: {\n              '@id': 'https://w3id.org/security#capabilityInvocationMethod',\n              '@type': '@id',\n              '@container': '@set'\n            },\n            capabilityDelegation: {\n              '@id': 'https://w3id.org/security#capabilityDelegationMethod',\n              '@type': '@id',\n              '@container': '@set'\n            },\n            keyAgreement: {\n              '@id': 'https://w3id.org/security#keyAgreementMethod',\n              '@type': '@id',\n              '@container': '@set'\n            }\n          }\n        },\n        cryptosuite: {\n          '@id': 'https://w3id.org/security#cryptosuite',\n          '@type': 'https://w3id.org/security#cryptosuiteString'\n        },\n        proofValue: {\n          '@id': 'https://w3id.org/security#proofValue',\n          '@type': 'https://w3id.org/security#multibase'\n        },\n        verificationMethod: {\n          '@id': 'https://w3id.org/security#verificationMethod',\n          '@type': '@id'\n        }\n      }\n    }\n  }\n};\n","/*!\n * Copyright (c) 2022-2023 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst contextV1 = require('./data-integrity-v1');\nconst contextV2 = require('./data-integrity-v2');\nconst constants = require('./constants');\nconst {\n  CONTEXT_URL, DATA_INTEGRITY_CONTEXT_V1_URL, DATA_INTEGRITY_CONTEXT_V2_URL,\n  CBORLD_VALUE\n} = constants;\n\nconst contexts = new Map();\ncontexts.set(DATA_INTEGRITY_CONTEXT_V1_URL, contextV1);\ncontexts.set(DATA_INTEGRITY_CONTEXT_V2_URL, contextV2);\n\nconst appContextMap = new Map();\nappContextMap.set(CONTEXT_URL, CBORLD_VALUE);\n\nmodule.exports = {\n  constants,\n  contexts,\n  appContextMap,\n  DATA_INTEGRITY_CONTEXT_V1_URL,\n  DATA_INTEGRITY_CONTEXT_V2_URL,\n  CONTEXT_URL,\n  CONTEXT: contextV2\n};\n","function unwrapExports (x) {\n\treturn x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;\n}\n\nfunction createCommonjsModule(fn, module) {\n\treturn module = { exports: {} }, fn(module, module.exports), module.exports;\n}\n\nvar context = createCommonjsModule(function (module, exports) {\n!function(e,t){for(var i in t)e[i]=t[i];}(exports,function(e){var t={};function i(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,i),a.l=!0,a.exports}return i.m=e,i.c=t,i.d=function(e,t,r){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r});},i.r=function(e){\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(e,\"__esModule\",{value:!0});},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&\"object\"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,\"default\",{enumerable:!0,value:e}),2&t&&\"string\"!=typeof e)for(var a in e)i.d(r,a,function(t){return e[t]}.bind(null,a));return r},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,\"a\",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p=\"\",i(i.s=0)}([function(e,t,i){/*!\n * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.\n */const r=i(1),a=i(2),c=i(3),{CONTEXT_URL:n,SECURITY_CONTEXT_V1_URL:o,SECURITY_CONTEXT_V2_URL:s}=c,p=new Map;p.set(o,r),p.set(s,a),e.exports={constants:c,contexts:p,SECURITY_CONTEXT_V1_URL:o,SECURITY_CONTEXT_V2_URL:s,CONTEXT_URL:n,CONTEXT:a};},function(e,t,i){/*!\n * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.\n */e.exports={\"@context\":{id:\"@id\",type:\"@type\",dc:\"http://purl.org/dc/terms/\",sec:\"https://w3id.org/security#\",xsd:\"http://www.w3.org/2001/XMLSchema#\",EcdsaKoblitzSignature2016:\"sec:EcdsaKoblitzSignature2016\",Ed25519Signature2018:\"sec:Ed25519Signature2018\",EncryptedMessage:\"sec:EncryptedMessage\",GraphSignature2012:\"sec:GraphSignature2012\",LinkedDataSignature2015:\"sec:LinkedDataSignature2015\",LinkedDataSignature2016:\"sec:LinkedDataSignature2016\",CryptographicKey:\"sec:Key\",authenticationTag:\"sec:authenticationTag\",canonicalizationAlgorithm:\"sec:canonicalizationAlgorithm\",cipherAlgorithm:\"sec:cipherAlgorithm\",cipherData:\"sec:cipherData\",cipherKey:\"sec:cipherKey\",created:{\"@id\":\"dc:created\",\"@type\":\"xsd:dateTime\"},creator:{\"@id\":\"dc:creator\",\"@type\":\"@id\"},digestAlgorithm:\"sec:digestAlgorithm\",digestValue:\"sec:digestValue\",domain:\"sec:domain\",encryptionKey:\"sec:encryptionKey\",expiration:{\"@id\":\"sec:expiration\",\"@type\":\"xsd:dateTime\"},expires:{\"@id\":\"sec:expiration\",\"@type\":\"xsd:dateTime\"},initializationVector:\"sec:initializationVector\",iterationCount:\"sec:iterationCount\",nonce:\"sec:nonce\",normalizationAlgorithm:\"sec:normalizationAlgorithm\",owner:{\"@id\":\"sec:owner\",\"@type\":\"@id\"},password:\"sec:password\",privateKey:{\"@id\":\"sec:privateKey\",\"@type\":\"@id\"},privateKeyPem:\"sec:privateKeyPem\",publicKey:{\"@id\":\"sec:publicKey\",\"@type\":\"@id\"},publicKeyBase58:\"sec:publicKeyBase58\",publicKeyPem:\"sec:publicKeyPem\",publicKeyWif:\"sec:publicKeyWif\",publicKeyService:{\"@id\":\"sec:publicKeyService\",\"@type\":\"@id\"},revoked:{\"@id\":\"sec:revoked\",\"@type\":\"xsd:dateTime\"},salt:\"sec:salt\",signature:\"sec:signature\",signatureAlgorithm:\"sec:signingAlgorithm\",signatureValue:\"sec:signatureValue\"}};},function(e,t,i){/*!\n * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.\n */e.exports={\"@context\":[{\"@version\":1.1},\"https://w3id.org/security/v1\",{AesKeyWrappingKey2019:\"sec:AesKeyWrappingKey2019\",DeleteKeyOperation:\"sec:DeleteKeyOperation\",DeriveSecretOperation:\"sec:DeriveSecretOperation\",EcdsaSecp256k1Signature2019:\"sec:EcdsaSecp256k1Signature2019\",EcdsaSecp256r1Signature2019:\"sec:EcdsaSecp256r1Signature2019\",EcdsaSecp256k1VerificationKey2019:\"sec:EcdsaSecp256k1VerificationKey2019\",EcdsaSecp256r1VerificationKey2019:\"sec:EcdsaSecp256r1VerificationKey2019\",Ed25519Signature2018:\"sec:Ed25519Signature2018\",Ed25519VerificationKey2018:\"sec:Ed25519VerificationKey2018\",EquihashProof2018:\"sec:EquihashProof2018\",ExportKeyOperation:\"sec:ExportKeyOperation\",GenerateKeyOperation:\"sec:GenerateKeyOperation\",KmsOperation:\"sec:KmsOperation\",RevokeKeyOperation:\"sec:RevokeKeyOperation\",RsaSignature2018:\"sec:RsaSignature2018\",RsaVerificationKey2018:\"sec:RsaVerificationKey2018\",Sha256HmacKey2019:\"sec:Sha256HmacKey2019\",SignOperation:\"sec:SignOperation\",UnwrapKeyOperation:\"sec:UnwrapKeyOperation\",VerifyOperation:\"sec:VerifyOperation\",WrapKeyOperation:\"sec:WrapKeyOperation\",X25519KeyAgreementKey2019:\"sec:X25519KeyAgreementKey2019\",allowedAction:\"sec:allowedAction\",assertionMethod:{\"@id\":\"sec:assertionMethod\",\"@type\":\"@id\",\"@container\":\"@set\"},authentication:{\"@id\":\"sec:authenticationMethod\",\"@type\":\"@id\",\"@container\":\"@set\"},capability:{\"@id\":\"sec:capability\",\"@type\":\"@id\"},capabilityAction:\"sec:capabilityAction\",capabilityChain:{\"@id\":\"sec:capabilityChain\",\"@type\":\"@id\",\"@container\":\"@list\"},capabilityDelegation:{\"@id\":\"sec:capabilityDelegationMethod\",\"@type\":\"@id\",\"@container\":\"@set\"},capabilityInvocation:{\"@id\":\"sec:capabilityInvocationMethod\",\"@type\":\"@id\",\"@container\":\"@set\"},caveat:{\"@id\":\"sec:caveat\",\"@type\":\"@id\",\"@container\":\"@set\"},challenge:\"sec:challenge\",ciphertext:\"sec:ciphertext\",controller:{\"@id\":\"sec:controller\",\"@type\":\"@id\"},delegator:{\"@id\":\"sec:delegator\",\"@type\":\"@id\"},equihashParameterK:{\"@id\":\"sec:equihashParameterK\",\"@type\":\"xsd:integer\"},equihashParameterN:{\"@id\":\"sec:equihashParameterN\",\"@type\":\"xsd:integer\"},invocationTarget:{\"@id\":\"sec:invocationTarget\",\"@type\":\"@id\"},invoker:{\"@id\":\"sec:invoker\",\"@type\":\"@id\"},jws:\"sec:jws\",keyAgreement:{\"@id\":\"sec:keyAgreementMethod\",\"@type\":\"@id\",\"@container\":\"@set\"},kmsModule:{\"@id\":\"sec:kmsModule\"},parentCapability:{\"@id\":\"sec:parentCapability\",\"@type\":\"@id\"},plaintext:\"sec:plaintext\",proof:{\"@id\":\"sec:proof\",\"@type\":\"@id\",\"@container\":\"@graph\"},proofPurpose:{\"@id\":\"sec:proofPurpose\",\"@type\":\"@vocab\"},proofValue:\"sec:proofValue\",referenceId:\"sec:referenceId\",unwrappedKey:\"sec:unwrappedKey\",verificationMethod:{\"@id\":\"sec:verificationMethod\",\"@type\":\"@id\"},verifyData:\"sec:verifyData\",wrappedKey:\"sec:wrappedKey\"}]};},function(e,t,i){/*!\n * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.\n */e.exports={SECURITY_CONTEXT_V1_URL:\"https://w3id.org/security/v1\",SECURITY_CONTEXT_V2_URL:\"https://w3id.org/security/v2\",CONTEXT_URL:\"https://w3id.org/security/v2\"};}]));\n});\n\nvar context$1 = unwrapExports(context);\nvar context_1 = context.contexts;\nvar context_2 = context.constants;\nvar context_3 = context.CONTEXT;\nvar context_4 = context.CONTEXT_URL;\nvar context_5 = context.SECURITY_CONTEXT_V1_URL;\nvar context_6 = context.SECURITY_CONTEXT_V2_URL;\n\nexport { context_3 as CONTEXT, context_4 as CONTEXT_URL, context_5 as SECURITY_CONTEXT_V1_URL, context_6 as SECURITY_CONTEXT_V2_URL, context_2 as constants, context_1 as contexts, context$1 as default };\n","/* jshint esversion: 6 */\n/* jslint node: true */\n'use strict';\n\nmodule.exports = function serialize (object) {\n  if (object === null || typeof object !== 'object' || object.toJSON != null) {\n    return JSON.stringify(object);\n  }\n\n  if (Array.isArray(object)) {\n    return '[' + object.reduce((t, cv, ci) => {\n      const comma = ci === 0 ? '' : ',';\n      const value = cv === undefined || typeof cv === 'symbol' ? null : cv;\n      return t + comma + serialize(value);\n    }, '') + ']';\n  }\n\n  return '{' + Object.keys(object).sort().reduce((t, cv, ci) => {\n    if (object[cv] === undefined ||\n        typeof object[cv] === 'symbol') {\n      return t;\n    }\n    const comma = t.length === 0 ? '' : ',';\n    return t + comma + serialize(cv) + ':' + serialize(object[cv]);\n  }, '') + '}';\n};\n","function unwrapExports (x) {\n\treturn x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;\n}\n\nfunction createCommonjsModule(fn, module) {\n\treturn module = { exports: {} }, fn(module, module.exports), module.exports;\n}\n\nvar context = createCommonjsModule(function (module, exports) {\n/*! For license information please see context.js.LICENSE.txt */\n(()=>{var e={717:e=>{e.exports={CONTEXT_FILENAME:\"credentials-v1.jsonld\",CONTEXT_URL:\"https://www.w3.org/2018/credentials/v1\",CREDENTIALS_CONTEXT_V1_URL:\"https://www.w3.org/2018/credentials/v1\"};},869:e=>{e.exports={\"@context\":{\"@version\":1.1,\"@protected\":!0,id:\"@id\",type:\"@type\",VerifiableCredential:{\"@id\":\"https://www.w3.org/2018/credentials#VerifiableCredential\",\"@context\":{\"@version\":1.1,\"@protected\":!0,id:\"@id\",type:\"@type\",cred:\"https://www.w3.org/2018/credentials#\",sec:\"https://w3id.org/security#\",xsd:\"http://www.w3.org/2001/XMLSchema#\",credentialSchema:{\"@id\":\"cred:credentialSchema\",\"@type\":\"@id\",\"@context\":{\"@version\":1.1,\"@protected\":!0,id:\"@id\",type:\"@type\",cred:\"https://www.w3.org/2018/credentials#\",JsonSchemaValidator2018:\"cred:JsonSchemaValidator2018\"}},credentialStatus:{\"@id\":\"cred:credentialStatus\",\"@type\":\"@id\"},credentialSubject:{\"@id\":\"cred:credentialSubject\",\"@type\":\"@id\"},evidence:{\"@id\":\"cred:evidence\",\"@type\":\"@id\"},expirationDate:{\"@id\":\"cred:expirationDate\",\"@type\":\"xsd:dateTime\"},holder:{\"@id\":\"cred:holder\",\"@type\":\"@id\"},issued:{\"@id\":\"cred:issued\",\"@type\":\"xsd:dateTime\"},issuer:{\"@id\":\"cred:issuer\",\"@type\":\"@id\"},issuanceDate:{\"@id\":\"cred:issuanceDate\",\"@type\":\"xsd:dateTime\"},proof:{\"@id\":\"sec:proof\",\"@type\":\"@id\",\"@container\":\"@graph\"},refreshService:{\"@id\":\"cred:refreshService\",\"@type\":\"@id\",\"@context\":{\"@version\":1.1,\"@protected\":!0,id:\"@id\",type:\"@type\",cred:\"https://www.w3.org/2018/credentials#\",ManualRefreshService2018:\"cred:ManualRefreshService2018\"}},termsOfUse:{\"@id\":\"cred:termsOfUse\",\"@type\":\"@id\"},validFrom:{\"@id\":\"cred:validFrom\",\"@type\":\"xsd:dateTime\"},validUntil:{\"@id\":\"cred:validUntil\",\"@type\":\"xsd:dateTime\"}}},VerifiablePresentation:{\"@id\":\"https://www.w3.org/2018/credentials#VerifiablePresentation\",\"@context\":{\"@version\":1.1,\"@protected\":!0,id:\"@id\",type:\"@type\",cred:\"https://www.w3.org/2018/credentials#\",sec:\"https://w3id.org/security#\",holder:{\"@id\":\"cred:holder\",\"@type\":\"@id\"},proof:{\"@id\":\"sec:proof\",\"@type\":\"@id\",\"@container\":\"@graph\"},verifiableCredential:{\"@id\":\"cred:verifiableCredential\",\"@type\":\"@id\",\"@container\":\"@graph\"}}},EcdsaSecp256k1Signature2019:{\"@id\":\"https://w3id.org/security#EcdsaSecp256k1Signature2019\",\"@context\":{\"@version\":1.1,\"@protected\":!0,id:\"@id\",type:\"@type\",sec:\"https://w3id.org/security#\",xsd:\"http://www.w3.org/2001/XMLSchema#\",challenge:\"sec:challenge\",created:{\"@id\":\"http://purl.org/dc/terms/created\",\"@type\":\"xsd:dateTime\"},domain:\"sec:domain\",expires:{\"@id\":\"sec:expiration\",\"@type\":\"xsd:dateTime\"},jws:\"sec:jws\",nonce:\"sec:nonce\",proofPurpose:{\"@id\":\"sec:proofPurpose\",\"@type\":\"@vocab\",\"@context\":{\"@version\":1.1,\"@protected\":!0,id:\"@id\",type:\"@type\",sec:\"https://w3id.org/security#\",assertionMethod:{\"@id\":\"sec:assertionMethod\",\"@type\":\"@id\",\"@container\":\"@set\"},authentication:{\"@id\":\"sec:authenticationMethod\",\"@type\":\"@id\",\"@container\":\"@set\"}}},proofValue:\"sec:proofValue\",verificationMethod:{\"@id\":\"sec:verificationMethod\",\"@type\":\"@id\"}}},EcdsaSecp256r1Signature2019:{\"@id\":\"https://w3id.org/security#EcdsaSecp256r1Signature2019\",\"@context\":{\"@version\":1.1,\"@protected\":!0,id:\"@id\",type:\"@type\",sec:\"https://w3id.org/security#\",xsd:\"http://www.w3.org/2001/XMLSchema#\",challenge:\"sec:challenge\",created:{\"@id\":\"http://purl.org/dc/terms/created\",\"@type\":\"xsd:dateTime\"},domain:\"sec:domain\",expires:{\"@id\":\"sec:expiration\",\"@type\":\"xsd:dateTime\"},jws:\"sec:jws\",nonce:\"sec:nonce\",proofPurpose:{\"@id\":\"sec:proofPurpose\",\"@type\":\"@vocab\",\"@context\":{\"@version\":1.1,\"@protected\":!0,id:\"@id\",type:\"@type\",sec:\"https://w3id.org/security#\",assertionMethod:{\"@id\":\"sec:assertionMethod\",\"@type\":\"@id\",\"@container\":\"@set\"},authentication:{\"@id\":\"sec:authenticationMethod\",\"@type\":\"@id\",\"@container\":\"@set\"}}},proofValue:\"sec:proofValue\",verificationMethod:{\"@id\":\"sec:verificationMethod\",\"@type\":\"@id\"}}},Ed25519Signature2018:{\"@id\":\"https://w3id.org/security#Ed25519Signature2018\",\"@context\":{\"@version\":1.1,\"@protected\":!0,id:\"@id\",type:\"@type\",sec:\"https://w3id.org/security#\",xsd:\"http://www.w3.org/2001/XMLSchema#\",challenge:\"sec:challenge\",created:{\"@id\":\"http://purl.org/dc/terms/created\",\"@type\":\"xsd:dateTime\"},domain:\"sec:domain\",expires:{\"@id\":\"sec:expiration\",\"@type\":\"xsd:dateTime\"},jws:\"sec:jws\",nonce:\"sec:nonce\",proofPurpose:{\"@id\":\"sec:proofPurpose\",\"@type\":\"@vocab\",\"@context\":{\"@version\":1.1,\"@protected\":!0,id:\"@id\",type:\"@type\",sec:\"https://w3id.org/security#\",assertionMethod:{\"@id\":\"sec:assertionMethod\",\"@type\":\"@id\",\"@container\":\"@set\"},authentication:{\"@id\":\"sec:authenticationMethod\",\"@type\":\"@id\",\"@container\":\"@set\"}}},proofValue:\"sec:proofValue\",verificationMethod:{\"@id\":\"sec:verificationMethod\",\"@type\":\"@id\"}}},RsaSignature2018:{\"@id\":\"https://w3id.org/security#RsaSignature2018\",\"@context\":{\"@version\":1.1,\"@protected\":!0,challenge:\"sec:challenge\",created:{\"@id\":\"http://purl.org/dc/terms/created\",\"@type\":\"xsd:dateTime\"},domain:\"sec:domain\",expires:{\"@id\":\"sec:expiration\",\"@type\":\"xsd:dateTime\"},jws:\"sec:jws\",nonce:\"sec:nonce\",proofPurpose:{\"@id\":\"sec:proofPurpose\",\"@type\":\"@vocab\",\"@context\":{\"@version\":1.1,\"@protected\":!0,id:\"@id\",type:\"@type\",sec:\"https://w3id.org/security#\",assertionMethod:{\"@id\":\"sec:assertionMethod\",\"@type\":\"@id\",\"@container\":\"@set\"},authentication:{\"@id\":\"sec:authenticationMethod\",\"@type\":\"@id\",\"@container\":\"@set\"}}},proofValue:\"sec:proofValue\",verificationMethod:{\"@id\":\"sec:verificationMethod\",\"@type\":\"@id\"}}},proof:{\"@id\":\"https://w3id.org/security#proof\",\"@type\":\"@id\",\"@container\":\"@graph\"}}};},858:(e,t,i)=>{const{CONTEXT_URL:d}=i(717),r=i(869);e.exports={documentLoader(e){if(e!==d)throw new Error(`Loading document \"${e}\" is not allowed.`);return {contextUrl:null,document:r,documentUrl:e}}};},243:(e,t,i)=>{const d=i(869),r=i(717),{documentLoader:o}=i(858),{CONTEXT_URL:c}=r,s=new Map;s.set(r.CONTEXT_URL,d),e.exports={constants:r,contexts:s,documentLoader:o,CONTEXT_URL:c,CREDENTIALS_CONTEXT_V1_URL:c,CONTEXT_URL_V1:c,CONTEXT:d};}},t={},i=function i(d){var r=t[d];if(void 0!==r)return r.exports;var o=t[d]={exports:{}};return e[d](o,o.exports,i),o.exports}(243),d=exports;for(var r in i)d[r]=i[r];i.__esModule&&Object.defineProperty(d,\"__esModule\",{value:!0});})();\n});\n\nvar context$1 = unwrapExports(context);\nvar context_1 = context.contexts;\nvar context_2 = context.constants;\nvar context_3 = context.CONTEXT;\nvar context_4 = context.CONTEXT_URL;\nvar context_5 = context.CONTEXT_URL_V1;\nvar context_6 = context.CREDENTIALS_CONTEXT_V1_URL;\n\nexport { context_3 as CONTEXT, context_4 as CONTEXT_URL, context_5 as CONTEXT_URL_V1, context_6 as CREDENTIALS_CONTEXT_V1_URL, context_2 as constants, context_1 as contexts, context$1 as default };\n","function unwrapExports (x) {\n\treturn x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;\n}\n\nfunction createCommonjsModule(fn, module) {\n\treturn module = { exports: {} }, fn(module, module.exports), module.exports;\n}\n\nvar context = createCommonjsModule(function (module, exports) {\n!function(t,e){for(var i in e)t[i]=e[i];}(exports,function(t){var e={};function i(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,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,r){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r});},i.r=function(t){\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(t,\"__esModule\",{value:!0});},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&\"object\"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,\"default\",{enumerable:!0,value:t}),2&e&&\"string\"!=typeof t)for(var o in t)i.d(r,o,function(e){return t[e]}.bind(null,o));return r},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,\"a\",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p=\"\",i(i.s=2)}([function(t,e,i){/*!\n * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.\n */t.exports={\"@context\":{id:\"@id\",type:\"@type\",\"@protected\":!0,proof:{\"@id\":\"https://w3id.org/security#proof\",\"@type\":\"@id\",\"@container\":\"@graph\"},Ed25519VerificationKey2018:{\"@id\":\"https://w3id.org/security#Ed25519VerificationKey2018\",\"@context\":{\"@protected\":!0,id:\"@id\",type:\"@type\",controller:{\"@id\":\"https://w3id.org/security#controller\",\"@type\":\"@id\"},revoked:{\"@id\":\"https://w3id.org/security#revoked\",\"@type\":\"http://www.w3.org/2001/XMLSchema#dateTime\"},publicKeyBase58:{\"@id\":\"https://w3id.org/security#publicKeyBase58\"}}},Ed25519Signature2018:{\"@id\":\"https://w3id.org/security#Ed25519Signature2018\",\"@context\":{\"@protected\":!0,id:\"@id\",type:\"@type\",challenge:\"https://w3id.org/security#challenge\",created:{\"@id\":\"http://purl.org/dc/terms/created\",\"@type\":\"http://www.w3.org/2001/XMLSchema#dateTime\"},domain:\"https://w3id.org/security#domain\",expires:{\"@id\":\"https://w3id.org/security#expiration\",\"@type\":\"http://www.w3.org/2001/XMLSchema#dateTime\"},nonce:\"https://w3id.org/security#nonce\",proofPurpose:{\"@id\":\"https://w3id.org/security#proofPurpose\",\"@type\":\"@vocab\",\"@context\":{\"@protected\":!0,id:\"@id\",type:\"@type\",assertionMethod:{\"@id\":\"https://w3id.org/security#assertionMethod\",\"@type\":\"@id\",\"@container\":\"@set\"},authentication:{\"@id\":\"https://w3id.org/security#authenticationMethod\",\"@type\":\"@id\",\"@container\":\"@set\"},capabilityInvocation:{\"@id\":\"https://w3id.org/security#capabilityInvocationMethod\",\"@type\":\"@id\",\"@container\":\"@set\"},capabilityDelegation:{\"@id\":\"https://w3id.org/security#capabilityDelegationMethod\",\"@type\":\"@id\",\"@container\":\"@set\"},keyAgreement:{\"@id\":\"https://w3id.org/security#keyAgreementMethod\",\"@type\":\"@id\",\"@container\":\"@set\"}}},jws:{\"@id\":\"https://w3id.org/security#jws\"},verificationMethod:{\"@id\":\"https://w3id.org/security#verificationMethod\",\"@type\":\"@id\"}}}}};},function(t,e,i){/*!\n * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.\n */t.exports={CONTEXT_FILENAME:\"ed25519-signature-2018-v1.jsonld\",CONTEXT_URL:\"https://w3id.org/security/suites/ed25519-2018/v1\",CBORLD_CODEC_VALUE:19};},function(t,e,i){/*!\n * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.\n */const r=i(0),o=i(1),{documentLoader:n}=i(3),{CONTEXT_URL:d,CBORLD_CODEC_VALUE:c}=o,s=new Map;s.set(d,r);const p=new Map;p.set(d,c),t.exports={constants:o,contexts:s,appContextMap:p,documentLoader:n,CONTEXT_URL:d,CONTEXT:r};},function(t,e,i){/*!\n * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.\n */const{CONTEXT_URL:r}=i(1),o=i(0);t.exports={documentLoader(t){if(t!==r)throw new Error(`Loading document \"${t}\" is not allowed.`);return {contextUrl:null,document:o,documentUrl:t}}};}]));\n});\n\nvar context$1 = unwrapExports(context);\nvar context_1 = context.contexts;\nvar context_2 = context.constants;\nvar context_3 = context.CONTEXT;\nvar context_4 = context.CONTEXT_URL;\nvar context_5 = context.appContextMap;\nvar context_6 = context.documentLoader;\n\nexport default context$1;\nexport { context_3 as CONTEXT, context_4 as CONTEXT_URL, context_5 as appContextMap, context_2 as constants, context_1 as contexts, context_6 as documentLoader };\n","function unwrapExports (x) {\n\treturn x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;\n}\n\nfunction createCommonjsModule(fn, module) {\n\treturn module = { exports: {} }, fn(module, module.exports), module.exports;\n}\n\nvar context = createCommonjsModule(function (module, exports) {\n!function(t,e){for(var i in e)t[i]=e[i];}(exports,function(t){var e={};function i(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,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,r){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r});},i.r=function(t){\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(t,\"__esModule\",{value:!0});},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&\"object\"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,\"default\",{enumerable:!0,value:t}),2&e&&\"string\"!=typeof t)for(var o in t)i.d(r,o,function(e){return t[e]}.bind(null,o));return r},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,\"a\",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p=\"\",i(i.s=2)}([function(t,e,i){/*!\n * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.\n */t.exports={\"@context\":{id:\"@id\",type:\"@type\",\"@protected\":!0,proof:{\"@id\":\"https://w3id.org/security#proof\",\"@type\":\"@id\",\"@container\":\"@graph\"},Ed25519VerificationKey2020:{\"@id\":\"https://w3id.org/security#Ed25519VerificationKey2020\",\"@context\":{\"@protected\":!0,id:\"@id\",type:\"@type\",controller:{\"@id\":\"https://w3id.org/security#controller\",\"@type\":\"@id\"},revoked:{\"@id\":\"https://w3id.org/security#revoked\",\"@type\":\"http://www.w3.org/2001/XMLSchema#dateTime\"},publicKeyMultibase:{\"@id\":\"https://w3id.org/security#publicKeyMultibase\",\"@type\":\"https://w3id.org/security#multibase\"}}},Ed25519Signature2020:{\"@id\":\"https://w3id.org/security#Ed25519Signature2020\",\"@context\":{\"@protected\":!0,id:\"@id\",type:\"@type\",challenge:\"https://w3id.org/security#challenge\",created:{\"@id\":\"http://purl.org/dc/terms/created\",\"@type\":\"http://www.w3.org/2001/XMLSchema#dateTime\"},domain:\"https://w3id.org/security#domain\",expires:{\"@id\":\"https://w3id.org/security#expiration\",\"@type\":\"http://www.w3.org/2001/XMLSchema#dateTime\"},nonce:\"https://w3id.org/security#nonce\",proofPurpose:{\"@id\":\"https://w3id.org/security#proofPurpose\",\"@type\":\"@vocab\",\"@context\":{\"@protected\":!0,id:\"@id\",type:\"@type\",assertionMethod:{\"@id\":\"https://w3id.org/security#assertionMethod\",\"@type\":\"@id\",\"@container\":\"@set\"},authentication:{\"@id\":\"https://w3id.org/security#authenticationMethod\",\"@type\":\"@id\",\"@container\":\"@set\"},capabilityInvocation:{\"@id\":\"https://w3id.org/security#capabilityInvocationMethod\",\"@type\":\"@id\",\"@container\":\"@set\"},capabilityDelegation:{\"@id\":\"https://w3id.org/security#capabilityDelegationMethod\",\"@type\":\"@id\",\"@container\":\"@set\"},keyAgreement:{\"@id\":\"https://w3id.org/security#keyAgreementMethod\",\"@type\":\"@id\",\"@container\":\"@set\"}}},proofValue:{\"@id\":\"https://w3id.org/security#proofValue\",\"@type\":\"https://w3id.org/security#multibase\"},verificationMethod:{\"@id\":\"https://w3id.org/security#verificationMethod\",\"@type\":\"@id\"}}}}};},function(t,e,i){/*!\n * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.\n */t.exports={CONTEXT_FILENAME:\"ed25519-signature-2020-v1.jsonld\",CONTEXT_URL:\"https://w3id.org/security/suites/ed25519-2020/v1\",CBORLD_CODEC_VALUE:20};},function(t,e,i){/*!\n * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.\n */const r=i(0),o=i(1),{documentLoader:n}=i(3),{CONTEXT_URL:d,CBORLD_CODEC_VALUE:c}=o,s=new Map;s.set(o.CONTEXT_URL,r);const p=new Map;p.set(d,c),t.exports={constants:o,contexts:s,appContextMap:p,documentLoader:n,CONTEXT_URL:d,CONTEXT:r};},function(t,e,i){/*!\n * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.\n */const{CONTEXT_URL:r}=i(1),o=i(0);t.exports={documentLoader(t){if(t!==r)throw new Error(`Loading document \"${t}\" is not allowed.`);return {contextUrl:null,document:o,documentUrl:t}}};}]));\n});\n\nvar context$1 = unwrapExports(context);\nvar context_1 = context.contexts;\nvar context_2 = context.constants;\nvar context_3 = context.CONTEXT;\nvar context_4 = context.CONTEXT_URL;\nvar context_5 = context.appContextMap;\nvar context_6 = context.documentLoader;\n\nexport default context$1;\nexport { context_3 as CONTEXT, context_4 as CONTEXT_URL, context_5 as appContextMap, context_2 as constants, context_1 as contexts, context_6 as documentLoader };\n","/*!\n * Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst constants = require('./constants');\nconst jsonld = require('jsonld');\nconst {extendContextLoader, strictDocumentLoader} = require('./documentLoader');\nconst {serializeError} = require('serialize-error');\n\nmodule.exports = class ProofSet {\n  /**\n   * Adds a Linked Data proof to a document. If the document contains other\n   * proofs, the new proof will be appended to the existing set of proofs.\n   *\n   * Important note: This method assumes that the term `proof` in the given\n   * document has the same definition as the `https://w3id.org/security/v2`\n   * JSON-LD @context.\n   *\n   * @param document {object} - JSON-LD Document to be signed.\n   * @param options {object} Options hashmap.\n   *\n   * A `suite` option is required:\n   *\n   * @param options.suite {LinkedDataSignature} a signature suite instance\n   *   that will create the proof.\n   *\n   * A `purpose` option is required:\n   *\n   * @param options.purpose {ProofPurpose} a proof purpose instance that will\n   *   augment the proof with information describing its intended purpose.\n   *\n   * Advanced optional parameters and overrides:\n   *\n   * @param [documentLoader] {function} a custom document loader,\n   *   `Promise<RemoteDocument> documentLoader(url)`.\n   *\n   * @return {Promise<object>} resolves with the signed document, with\n   *   the signature in the top-level `proof` property.\n   */\n  async add(document, {suite, purpose, documentLoader} = {}) {\n    if(!suite) {\n      throw new TypeError('\"options.suite\" is required.');\n    }\n    if(!purpose) {\n      throw new TypeError('\"options.purpose\" is required.');\n    }\n\n    if(documentLoader) {\n      documentLoader = extendContextLoader(documentLoader);\n    } else {\n      documentLoader = strictDocumentLoader;\n    }\n\n    // shallow copy document to allow removal of existing proofs\n    const input = {...document};\n    delete input.proof;\n\n    // get existing proof set, if any\n    const proofSet = _getProofs({document});\n\n    // create the new proof\n    const proof = await suite.createProof({\n      document: input, purpose, proofSet, documentLoader\n    });\n\n    jsonld.addValue(document, 'proof', proof);\n\n    return document;\n  }\n\n  /**\n   * Derives a new Linked Data document with a new `proof` from an existing\n   * document with an existing proof set.\n   *\n   * Important note: This method assumes that the term `proof` in the given\n   * document has the same definition as the `https://w3id.org/security/v2`\n   * JSON-LD @context.\n   *\n   * @param document {object} - JSON-LD Document from which to derive a proof.\n   * @param options {object} Options hashmap.\n   *\n   * A `suite` option is required:\n   *\n   * @param options.suite {LinkedDataSignature} a signature suite instance\n   *   that will derive the new document and new `proof`.\n   *\n   * A `purpose` option is required:\n   *\n   * @param options.purpose {ProofPurpose} a proof purpose instance that will\n   *   augment the proof with information describing its intended purpose.\n   *\n   * Advanced optional parameters and overrides:\n   *\n   * @param [documentLoader] {function} a custom document loader,\n   *   `Promise<RemoteDocument> documentLoader(url)`.\n   *\n   * @return {Promise<object>} resolves with the new document, with a new\n   *   top-level `proof` property.\n   */\n  async derive(document, {suite, purpose, documentLoader} = {}) {\n    if(!suite) {\n      throw new TypeError('\"options.suite\" is required.');\n    }\n    if(!purpose) {\n      throw new TypeError('\"options.purpose\" is required.');\n    }\n\n    if(documentLoader) {\n      documentLoader = extendContextLoader(documentLoader);\n    } else {\n      documentLoader = strictDocumentLoader;\n    }\n\n    // shallow copy document to allow removal of existing proofs\n    const input = {...document};\n    delete input.proof;\n\n    // get existing proof set, if any\n    const proofSet = _getProofs({document});\n\n    // create the new document and proof\n    const newDocument = await suite.derive({\n      document: input, purpose, proofSet, documentLoader\n    });\n\n    return newDocument;\n  }\n\n  /**\n   * Verifies Linked Data proof(s) on a document. The proofs to be verified\n   * must match the given proof purpose.\n   *\n   * Important note: This method assumes that the term `proof` in the given\n   * document has the same definition as the `https://w3id.org/security/v2`\n   * JSON-LD @context.\n   *\n   * @param {object} document - The JSON-LD document with one or more proofs to\n   *   be verified.\n   *\n   * @param {LinkedDataSignature|LinkedDataSignature[]} suite -\n   *   Acceptable signature suite instances for verifying the proof(s).\n   *\n   * @param {ProofPurpose} purpose - A proof purpose instance that will\n   *   match proofs to be verified and ensure they were created according to\n   *   the appropriate purpose.\n   *\n   * Advanced optional parameters and overrides:\n   *\n   * @param {function} [documentLoader]  a custom document loader,\n   *   `Promise<RemoteDocument> documentLoader(url)`.\n   *\n   * @return {Promise<{verified: boolean, results: Array, error: *}>} resolves\n   *   with an object with a `verified`boolean property that is `true` if at\n   *   least one proof matching the given purpose and suite verifies and `false`\n   *   otherwise; a `results` property with an array of detailed results;\n   *   if `false` an `error` property will be present.\n   */\n  async verify(document, {suite, purpose, documentLoader} = {}) {\n    if(!suite) {\n      throw new TypeError('\"options.suite\" is required.');\n    }\n    if(!purpose) {\n      throw new TypeError('\"options.purpose\" is required.');\n    }\n    const suites = Array.isArray(suite) ? suite : [suite];\n    if(suites.length === 0) {\n      throw new TypeError('At least one suite is required.');\n    }\n\n    if(documentLoader) {\n      documentLoader = extendContextLoader(documentLoader);\n    } else {\n      documentLoader = strictDocumentLoader;\n    }\n\n    try {\n      // shallow copy to allow for removal of proof set prior to canonize\n      document = {...document};\n\n      // get proofs from document\n      const proofSet = _getProofs({document});\n      if(proofSet.length === 0) {\n        // no possible matches\n        throw new Error('No matching proofs found in the given document.');\n      }\n      // clear proofs from shallow copy\n      delete document.proof;\n\n      // verify proofs\n      const results = await _verify(\n        {document, suites, proofSet, purpose, documentLoader});\n      if(results.length === 0) {\n        const error = new Error(\n          'Did not verify any proofs; insufficient proofs matched the ' +\n          'acceptable suite(s) and required purpose(s).');\n        error.name = 'NotFoundError';\n        throw error;\n      }\n\n      // combine results\n      const verified = results.some(r => r.verified);\n      if(!verified) {\n        const errors = [].concat(\n          ...results.filter(r => r.error).map(r => r.error));\n        const result = {verified, results};\n        if(errors.length > 0) {\n          result.error = errors;\n        }\n        return result;\n      }\n      return {verified, results};\n    } catch(error) {\n      _makeSerializable(error);\n      return {verified: false, error};\n    }\n  }\n};\n\nfunction _getProofs({document}) {\n  // handle document preprocessing to find proofs\n  let proofSet;\n  proofSet = jsonld.getValues(document, 'proof');\n\n  // shallow copy proofs and add document context or SECURITY_CONTEXT_URL\n  const context = document['@context'] || constants.SECURITY_CONTEXT_URL;\n  proofSet = proofSet.map(proof => ({\n    '@context': context,\n    ...proof\n  }));\n\n  return proofSet;\n}\n\nasync function _verify({\n  document, suites, proofSet, purpose, documentLoader\n}) {\n  // map each purpose to at least one proof to verify\n  const purposes = Array.isArray(purpose) ? purpose : [purpose];\n  const purposeToProofs = new Map();\n  const proofToSuite = new Map();\n  const suiteMatchQueue = new Map();\n  await Promise.all(purposes.map(purpose => _matchProofSet({\n    purposeToProofs, proofToSuite, purpose, proofSet, suites,\n    suiteMatchQueue, document, documentLoader\n  })));\n\n  // every purpose must have at least one matching proof or verify will fail\n  if(purposeToProofs.size < purposes.length) {\n    // insufficient proofs to verify, so don't bother verifying any\n    return [];\n  }\n\n  // verify every proof in `proofToSuite`; these proofs matched a purpose\n  const verifyResults = new Map();\n  await Promise.all([...proofToSuite.entries()].map(async ([proof, suite]) => {\n    let result;\n    try {\n      // create backwards-compatible deferred proof purpose to capture\n      // verification method from old-style suites\n      let vm;\n      const purpose = {\n        async validate(proof, {verificationMethod}) {\n          vm = verificationMethod;\n          return {valid: true};\n        }\n      };\n      const {verified, verificationMethod, error} = await suite.verifyProof(\n        {proof, document, purpose, proofSet, documentLoader});\n      if(!vm) {\n        vm = verificationMethod;\n      }\n      result = {proof, verified, verificationMethod: vm, error};\n    } catch(error) {\n      result = {proof, verified: false, error};\n    }\n\n    if(result.error) {\n      // ensure error is serializable\n      _makeSerializable(result.error);\n    }\n\n    verifyResults.set(proof, result);\n  }));\n\n  // validate proof against each purpose that matched it\n  await Promise.all([...purposeToProofs.entries()].map(\n    async ([purpose, proofs]) => {\n      for(const proof of proofs) {\n        const result = verifyResults.get(proof);\n        if(!result.verified) {\n          // if proof was not verified, so not bother validating purpose\n          continue;\n        }\n\n        // validate purpose\n        const {verificationMethod} = result;\n        const suite = proofToSuite.get(proof);\n        let purposeResult;\n        try {\n          purposeResult = await purpose.validate(proof, {\n            document, suite, verificationMethod, documentLoader\n          });\n        } catch(error) {\n          purposeResult = {valid: false, error};\n        }\n\n        // add `purposeResult` to verification result regardless of validity\n        // to ensure that all purposes are represented\n        if(result.purposeResult) {\n          if(Array.isArray(result.purposeResult)) {\n            result.purposeResult.push(purposeResult);\n          } else {\n            result.purposeResult = [result.purposeResult, purposeResult];\n          }\n        } else {\n          result.purposeResult = purposeResult;\n        }\n\n        if(!purposeResult.valid) {\n          // ensure error is serializable\n          _makeSerializable(purposeResult.error);\n\n          // if no top level error set yet, set it\n          if(!result.error) {\n            result.verified = false;\n            result.error = purposeResult.error;\n          }\n        }\n      }\n    }));\n\n  return [...verifyResults.values()];\n}\n\n// add a `toJSON` method to an error which allows for errors in validation\n// reports to be serialized properly by `JSON.stringify`.\nfunction _makeSerializable(error) {\n  Object.defineProperty(error, 'toJSON', {\n    value: function() {\n      return serializeError(this);\n    },\n    configurable: true,\n    writable: true\n  });\n}\n\nasync function _matchProofSet({\n  purposeToProofs, proofToSuite, purpose, proofSet, suites,\n  suiteMatchQueue, document, documentLoader\n}) {\n  for(const proof of proofSet) {\n    // first check if the proof matches the purpose; if it doesn't continue\n    if(!await purpose.match(proof, {document, documentLoader})) {\n      continue;\n    }\n\n    // next, find the suite that can verify the proof; if found, `matched`\n    // will be set to `true` and the proof will be added to `purposeToProofs`\n    // and `proofToSuite` to be processed -- otherwise it will not be; if\n    // no proofs are added for a given purpose, an exception will be thrown\n    let matched = false;\n    for(const s of suites) {\n      // `matchingProofs` is a map of promises that resolve to whether a\n      // proof matches a suite; multiple purposes and suites may be checked\n      // in parallel so a promise queue is used to prevent duplicate work\n      let matchingProofs = suiteMatchQueue.get(s);\n      if(!matchingProofs) {\n        suiteMatchQueue.set(s, matchingProofs = new Map());\n      }\n      let promise = matchingProofs.get(proof);\n      if(!promise) {\n        promise = s.matchProof({proof, document, documentLoader});\n        matchingProofs.set(proof, promise);\n      }\n      if(await promise) {\n        // found the matching suite for the proof; there should only be one\n        // suite that can verify a particular proof; add the proof to the\n        // map of proofs to be verified along with the matching suite\n        matched = true;\n        proofToSuite.set(proof, s);\n        break;\n      }\n    }\n\n    if(matched) {\n      // note proof was a match for the purpose and an acceptable suite; it\n      // will need to be verified by the suite and then validated against the\n      // purpose\n      const matches = purposeToProofs.get(purpose);\n      if(matches) {\n        matches.push(proof);\n      } else {\n        purposeToProofs.set(purpose, [proof]);\n      }\n    }\n  }\n}\n","/*!\n * Copyright (c) 2020 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\n/**\n * Used as an umbrella wrapper around multiple verification errors.\n */\nclass VerificationError extends Error {\n  /**\n   * @param {Error|Error[]} errors\n   */\n  constructor(errors) {\n    super('Verification error(s).');\n\n    this.name = 'VerificationError';\n    this.errors = [].concat(errors);\n  }\n}\nmodule.exports = VerificationError;\n","/*!\n * Copyright (c) 2017-2023 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst {\n  constants: securityConstants\n} = require('@digitalbazaar/security-context');\n\nmodule.exports = {\n  SECURITY_CONTEXT_URL: securityConstants.SECURITY_CONTEXT_V2_URL,\n  SECURITY_CONTEXT_V1_URL: securityConstants.SECURITY_CONTEXT_V1_URL,\n  SECURITY_CONTEXT_V2_URL: securityConstants.SECURITY_CONTEXT_V2_URL,\n  SECURITY_PROOF_URL: 'https://w3id.org/security#proof',\n  SECURITY_SIGNATURE_URL: 'https://w3id.org/security#signature'\n};\n","/*!\n * Copyright (c) 2017-2023 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst constants = require('./constants');\nconst {contexts: securityContexts} = require('@digitalbazaar/security-context');\n\nmodule.exports = new Map([\n  [constants.SECURITY_CONTEXT_V1_URL,\n    securityContexts.get(constants.SECURITY_CONTEXT_V1_URL)],\n  [constants.SECURITY_CONTEXT_V2_URL,\n    securityContexts.get(constants.SECURITY_CONTEXT_V2_URL)]\n]);\n","/*!\n * Copyright (c) 2018-2021 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\n/*eslint max-len: [\"error\", { \"ignoreComments\": true }]*/\n\n// load locally embedded contexts\nconst contexts = require('./contexts');\n\n/**\n * This is a utility module that provides a set of functions for using or\n * extending jsonld-signature's built-in JSON-LD document loader.\n * @see https://www.w3.org/TR/json-ld11-api/#loaddocumentcallback\n */\nconst api = {};\nmodule.exports = api;\n\napi.extendContextLoader = documentLoader => {\n  /**\n   * extendContextLoader extends another JSON-LD document loader.\n   * Given a document loader to extend, this method will return a\n   * new document loader that will first check for a URL in\n   * jsonld-signature's built-in context map and, if not found,\n   * it will fall back to using the passed document loader.\n   * This utility method can be used to ensure that any local,\n   * in-memory, immutable context documents provided by\n   * jsonld-signatures will be used prior to using another\n   * document loader to load other documents.\n   *\n   * @param {Function} documentLoader - A function that fetches a document.\n   * @see [node documentLoader example]{@link https://github.com/digitalbazaar/jsonld.js/blob/master/lib/documentLoaders/node.js}\n   * @see [xhr documentLoader example]{@link https://github.com/digitalbazaar/jsonld.js/blob/master/lib/documentLoaders/xhr.js}\n   *\n   * @returns {Function} A function that accepts a\n   * url then fetches a jsonld document.\n   */\n  return async url => {\n    const context = contexts.get(url);\n    if(context !== undefined) {\n      return {\n        contextUrl: null,\n        documentUrl: url,\n        document: context,\n        tag: 'static'\n      };\n    }\n    return documentLoader(url);\n  };\n};\n\napi.strictDocumentLoader = api.extendContextLoader(url => {\n  /**\n   * strictDocumentLoader extends extendContextLoader.\n   * ensuring no network calls are made so the only documents\n   * available are the built-in contexts.\n   * @see documentLoader.extendContextLoader\n   *\n   * @param {string} url - A valid url to a jsonld context.\n   *\n   * @throws {Error} Always throws an error if the\n   * url is not in the context map\n   * (i.e., not a URL for a locally available context document).\n   * @return {Object} A JSON-LD RemoteDocument\n   * that is a copy of a locally available context.\n   */\n  throw new Error(`${url} not found.`);\n});\n","/*!\n * Copyright (c) 2010-2023 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\n/* Core API */\nconst api = {};\nmodule.exports = api;\n\n/* API Constants */\nconst constants = require('./constants');\nObject.assign(api, constants);\n\n// TODO: support `ProofChain`\nconst ProofSet = require('./ProofSet');\nconst VerificationError = require('./VerificationError');\n\n/**\n * Derives a proof from the provided document, resulting in a new document\n * with a new `proof` on it as generated by the given cryptographic suite.\n *\n * @param {object} document - The JSON-LD document from which to derive a\n *   new proof.\n *\n * @param {object} options - Options hashmap.\n * @param {LinkedDataSignature} options.suite - The linked data signature\n *   cryptographic suite, containing private key material, with which to sign\n *   the document.\n *\n * @param {ProofPurpose} purpose - A proof purpose instance that will\n *   match proofs to be verified and ensure they were created according to\n *   the appropriate purpose.\n *\n * @param {function} documentLoader  - A secure document loader (it is\n *   recommended to use one that provides static known documents, instead of\n *   fetching from the web) for returning contexts, controller documents, keys,\n *   and other relevant URLs needed for the proof.\n *\n * Advanced optional parameters and overrides:\n *\n * @param {function} [options.expansionMap] - NOT SUPPORTED; do not use.\n * @param {boolean} [options.addSuiteContext=true] - Toggles the default\n *   behavior of each signature suite enforcing the presence of its own\n *   `@context` (if it is not present, it's added to the context list).\n *\n * @returns {Promise<object>} Resolves with signed document.\n */\napi.derive = async function derive(document, {\n  suite, purpose, documentLoader, addSuiteContext = true\n} = {}) {\n  if(typeof document !== 'object') {\n    throw new TypeError('The \"document\" parameter must be an object.');\n  }\n  // Ensure document contains the signature suite specific context URL\n  // or throw an error (in case an advanced user overrides the\n  // `addSuiteContext` flag to false).\n  suite.ensureSuiteContext({document, addSuiteContext});\n\n  try {\n    return await new ProofSet().derive(\n      document, {suite, purpose, documentLoader});\n  } catch(e) {\n    if(!documentLoader && e.name === 'jsonld.InvalidUrl') {\n      const {details: {url}} = e;\n      const err = new Error(\n        `A URL \"${url}\" could not be fetched; you need to pass ` +\n        '\"documentLoader\" or resolve the URL before calling \"derive\".');\n      err.cause = e;\n      throw err;\n    }\n    throw e;\n  }\n};\n\n/**\n * Cryptographically signs the provided document by adding a `proof` section,\n * based on the provided suite and proof purpose.\n *\n * @param {object} document - The JSON-LD document to be signed.\n *\n * @param {object} options - Options hashmap.\n * @param {LinkedDataSignature} options.suite - The linked data signature\n *   cryptographic suite with which to sign the document.\n *\n * @param {ProofPurpose} purpose - A proof purpose instance that will\n *   match proofs to be verified and ensure they were created according to\n *   the appropriate purpose.\n *\n * @param {function} documentLoader  - A secure document loader (it is\n *   recommended to use one that provides static known documents, instead of\n *   fetching from the web) for returning contexts, controller documents, keys,\n *   and other relevant URLs needed for the proof.\n *\n * Advanced optional parameters and overrides:\n *\n * @param {function} [options.expansionMap] - NOT SUPPORTED; do not use.\n * @param {boolean} [options.addSuiteContext=true] - Toggles the default\n *   behavior of each signature suite enforcing the presence of its own\n *   `@context` (if it is not present, it's added to the context list).\n *\n * @returns {Promise<object>} Resolves with signed document.\n */\napi.sign = async function sign(document, {\n  suite, purpose, documentLoader, expansionMap, addSuiteContext = true\n} = {}) {\n  if(expansionMap) {\n    throw new Error('\"expansionMap\" not supported.');\n  }\n  if(typeof document !== 'object') {\n    throw new TypeError('The \"document\" parameter must be an object.');\n  }\n  // Ensure document contains the signature suite specific context URL\n  // or throw an error (in case an advanced user overrides the `addSuiteContext`\n  // flag to false).\n  suite.ensureSuiteContext({document, addSuiteContext});\n\n  try {\n    return await new ProofSet().add(document, {suite, purpose, documentLoader});\n  } catch(e) {\n    if(!documentLoader && e.name === 'jsonld.InvalidUrl') {\n      const {details: {url}} = e;\n      const err = new Error(\n        `A URL \"${url}\" could not be fetched; you need to pass ` +\n        '\"documentLoader\" or resolve the URL before calling \"sign\".');\n      err.cause = e;\n      throw err;\n    }\n    throw e;\n  }\n};\n\n/**\n * Verifies the linked data signature on the provided document.\n *\n * @param {object} document - The JSON-LD document with one or more proofs to be\n *   verified.\n *\n * @param {object} options - The options to use.\n * @param {LinkedDataSignature|LinkedDataSignature[]} options.suite -\n *   Acceptable signature suite instances for verifying the proof(s).\n *\n * @param {ProofPurpose} purpose - A proof purpose instance that will\n *   match proofs to be verified and ensure they were created according to\n *   the appropriate purpose.\n *\n * Advanced optional parameters and overrides:\n *\n * @param {function} [options.documentLoader]  - A custom document loader,\n *   `Promise<RemoteDocument> documentLoader(url)`.\n * @param {function} [options.expansionMap] - NOT SUPPORTED; do not use.\n *\n * @return {Promise<{verified: boolean, results: Array,\n *   error: VerificationError}>}\n *   resolves with an object with a `verified` boolean property that is `true`\n *   if at least one proof matching the given purpose and suite verifies and\n *   `false` otherwise; a `results` property with an array of detailed results;\n *   if `false` an `error` property will be present, with `error.errors`\n *   containing all of the errors that occurred during the verification process.\n */\napi.verify = async function verify(document, {\n  suite, purpose, documentLoader, expansionMap\n} = {}) {\n  if(expansionMap) {\n    throw new Error('\"expansionMap\" not supported.');\n  }\n  if(typeof document !== 'object') {\n    throw new TypeError('The \"document\" parameter must be an object.');\n  }\n  const result = await new ProofSet().verify(\n    document, {suite, purpose, documentLoader});\n  const {error} = result;\n  if(error) {\n    if(!documentLoader && error.name === 'jsonld.InvalidUrl') {\n      const {details: {url}} = error;\n      const urlError = new Error(\n        `A URL \"${url}\" could not be fetched; you need to pass ` +\n        '\"documentLoader\" or resolve the URL before calling \"verify\".');\n      result.error = new VerificationError(urlError);\n    } else {\n      result.error = new VerificationError(error);\n    }\n  }\n  return result;\n};\n\n// expose suite classes\napi.suites = require('./suites').suites;\n\n// expose ProofPurpose classes to enable extensions\napi.purposes = require('./purposes').purposes;\n\n// expose document loader helpers\nObject.assign(api, require('./documentLoader'));\n","/*!\n * Copyright (c) 2018 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst api = {};\nmodule.exports = api;\n\n// TODO: only require dynamically as needed or according to build\napi.purposes = {\n  AssertionProofPurpose: require('./purposes/AssertionProofPurpose'),\n  AuthenticationProofPurpose: require('./purposes/AuthenticationProofPurpose'),\n  ControllerProofPurpose: require('./purposes/ControllerProofPurpose'),\n  ProofPurpose: require('./purposes/ProofPurpose')\n};\n","/*!\n * Copyright (c) 2018 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst ControllerProofPurpose = require('./ControllerProofPurpose');\n\nmodule.exports = class AssertionProofPurpose extends ControllerProofPurpose {\n  constructor({\n    term = 'assertionMethod', controller,\n    date, maxTimestampDelta = Infinity} = {}) {\n    super({term, controller, date, maxTimestampDelta});\n  }\n};\n","/*!\n * Copyright (c) 2018 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst ControllerProofPurpose = require('./ControllerProofPurpose');\n\nmodule.exports = class AuthenticationProofPurpose extends\n  ControllerProofPurpose {\n  constructor({\n    term = 'authentication', controller,\n    challenge, date, domain, maxTimestampDelta = Infinity} = {}) {\n    super({term, controller, date, maxTimestampDelta});\n    if(typeof challenge !== 'string') {\n      throw new TypeError('\"challenge\" must be a string.');\n    }\n    if(domain !== undefined && typeof domain !== 'string') {\n      throw new TypeError('\"domain\" must be a string.');\n    }\n    this.challenge = challenge;\n    this.domain = domain;\n  }\n\n  async validate(proof, {verificationMethod, documentLoader, expansionMap}) {\n    try {\n      // check challenge\n      if(proof.challenge !== this.challenge) {\n        throw new Error('The challenge is not as expected; ' +\n          `challenge=\"${proof.challenge}\", expected=\"${this.challenge}\"`);\n      }\n\n      // check domain\n      if(this.domain !== undefined && proof.domain !== this.domain) {\n        throw new Error('The domain is not as expected; ' +\n          `domain=\"${proof.domain}\", expected=\"${this.domain}\"`);\n      }\n\n      return super.validate(\n        proof, {verificationMethod, documentLoader, expansionMap});\n    } catch(error) {\n      return {valid: false, error};\n    }\n  }\n\n  async update(proof, {document, suite, documentLoader, expansionMap}) {\n    proof = await super.update(\n      proof, {document, suite, documentLoader, expansionMap});\n    proof.challenge = this.challenge;\n    if(this.domain !== undefined) {\n      proof.domain = this.domain;\n    }\n    return proof;\n  }\n};\n","/*!\n * Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst constants = require('../constants');\nconst jsonld = require('jsonld');\nconst ProofPurpose = require('./ProofPurpose');\n\n// DID documents can be specially optimized\nconst DID_CONTEXT_V1 = 'https://www.w3.org/ns/did/v1';\n// verification relationship terms that are known to appear in DID documents\nconst DID_VR_TERMS = [\n  'assertionMethod',\n  'authentication',\n  'capabilityInvocation',\n  'capabilityDelegation',\n  'keyAgreement',\n  'verificationMethod'\n];\n\nmodule.exports = class ControllerProofPurpose extends ProofPurpose {\n  /**\n   * Creates a proof purpose that will validate whether or not the verification\n   * method in a proof was authorized by its declared controller for the\n   * proof's purpose.\n   *\n   * @param term {string} the `proofPurpose` term, as defined in the\n   *    SECURITY_CONTEXT_URL `@context` or a URI if not defined in such.\n   * @param [controller] {object} the description of the controller, if it\n   *   is not to be dereferenced via a `documentLoader`.\n   * @param [date] {string or Date or integer} the expected date for\n   *   the creation of the proof.\n   * @param [maxTimestampDelta] {integer} a maximum number of seconds that\n   *   the date on the signature can deviate from, defaults to `Infinity`.\n   */\n  constructor({term, controller, date, maxTimestampDelta = Infinity} = {}) {\n    super({term, date, maxTimestampDelta});\n    if(controller !== undefined) {\n      if(typeof controller !== 'object') {\n        throw new TypeError('\"controller\" must be an object.');\n      }\n      this.controller = controller;\n    }\n    this._termDefinedByDIDContext = DID_VR_TERMS.includes(term);\n  }\n\n  /**\n   * Validates the purpose of a proof. This method is called during\n   * proof verification, after the proof value has been checked against the\n   * given verification method (e.g. in the case of a digital signature, the\n   * signature has been cryptographically verified against the public key).\n   *\n   * @param proof\n   * @param verificationMethod\n   * @param documentLoader\n   * @param expansionMap\n   *\n   * @throws {Error} If verification method not authorized by controller\n   * @throws {Error} If proof's created timestamp is out of range\n   *\n   * @returns {Promise<{valid: boolean, error: Error}>}\n   */\n  async validate(proof, {verificationMethod, documentLoader, expansionMap}) {\n    try {\n      const result = await super.validate(\n        proof, {verificationMethod, documentLoader, expansionMap});\n      if(!result.valid) {\n        throw result.error;\n      }\n\n      const {id: verificationId} = verificationMethod;\n      const {term, _termDefinedByDIDContext} = this;\n\n      // if no `controller` specified, use verification method's\n      if(this.controller) {\n        result.controller = this.controller;\n      } else {\n        const {controller} = verificationMethod;\n        let controllerId;\n        if(controller) {\n          if(typeof controller === 'object') {\n            controllerId = controller.id;\n          } else if(typeof controller !== 'string') {\n            throw new TypeError(\n              '\"controller\" must be a string representing a URL.');\n          } else {\n            controllerId = controller;\n          }\n        }\n\n        // apply optimization to controller documents that are DID documents;\n        // if `term` is one of those defined by the DID context\n        let {document} = await documentLoader(controllerId);\n        const mustFrame = !(_termDefinedByDIDContext &&\n          document['@context'] === DID_CONTEXT_V1 ||\n          (Array.isArray(document['@context']) &&\n          document['@context'][0] === DID_CONTEXT_V1));\n        if(mustFrame) {\n          // Note: `expansionMap` is intentionally not passed; we can safely\n          // drop properties here and must allow for it\n          document = await jsonld.frame(document, {\n            '@context': constants.SECURITY_CONTEXT_URL,\n            id: controllerId,\n            // this term must be in the JSON-LD controller document or\n            // verification will fail\n            [term]: {\n              '@embed': '@never',\n              id: verificationId\n            }\n          }, {documentLoader, compactToRelative: false, safe: true});\n        }\n        result.controller = document;\n      }\n\n      const verificationMethods = jsonld.getValues(result.controller, term);\n      result.valid = verificationMethods.some(vm =>\n        vm === verificationId ||\n        (typeof vm === 'object' && vm.id === verificationId));\n      if(!result.valid) {\n        throw new Error(\n          `Verification method \"${verificationMethod.id}\" not authorized ` +\n          `by controller for proof purpose \"${this.term}\".`);\n      }\n      return result;\n    } catch(error) {\n      return {valid: false, error};\n    }\n  }\n};\n","/*!\n * Copyright (c) 2018 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nmodule.exports = class ProofPurpose {\n  /**\n   * @param term {string} the `proofPurpose` term, as defined in the\n   *    SECURITY_CONTEXT_URL `@context` or a URI if not defined in such.\n   * @param [date] {string or Date or integer} the expected date for\n   *   the creation of the proof.\n   * @param [maxTimestampDelta] {integer} a maximum number of seconds that\n   *   the date on the signature can deviate from, defaults to `Infinity`.\n   */\n  constructor({term, date, maxTimestampDelta = Infinity} = {}) {\n    if(term === undefined) {\n      throw new Error('\"term\" is required.');\n    }\n    if(maxTimestampDelta !== undefined &&\n      typeof maxTimestampDelta !== 'number') {\n      throw new TypeError('\"maxTimestampDelta\" must be a number.');\n    }\n    this.term = term;\n    if(date !== undefined) {\n      this.date = new Date(date);\n      if(isNaN(this.date)) {\n        throw TypeError(`\"date\" \"${date}\" is not a valid date.`);\n      }\n    }\n    this.maxTimestampDelta = maxTimestampDelta;\n  }\n\n  /**\n   * Called to validate the purpose of a proof. This method is called during\n   * proof verification, after the proof value has been checked against the\n   * given verification method (e.g. in the case of a digital signature, the\n   * signature has been cryptographically verified against the public key).\n   *\n   * @param proof {object} the proof, in the `constants.SECURITY_CONTEXT_URL`,\n   *   with the matching purpose to validate.\n   *\n   * @return {Promise<object>} resolves to an object with `valid` and `error`.\n   */\n  async validate(\n    proof, {/*document, suite, verificationMethod,\n      documentLoader,*/ expansionMap}) {\n    if(expansionMap) {\n      throw new Error('\"expansionMap\" not supported.');\n    }\n\n    try {\n      // check expiration\n      if(this.maxTimestampDelta !== Infinity) {\n        const expected = (this.date || new Date()).getTime();\n        const delta = this.maxTimestampDelta * 1000;\n        const created = new Date(proof.created).getTime();\n        // comparing this way handles NaN case where `created` is invalid\n        if(!(created >= (expected - delta) && created <= (expected + delta))) {\n          throw new Error('The proof\\'s created timestamp is out of range.');\n        }\n      }\n      return {valid: true};\n    } catch(error) {\n      return {valid: false, error};\n    }\n  }\n\n  /**\n   * Called to update a proof when it is being created, adding any properties\n   * specific to this purpose. This method is called prior to the proof\n   * value being generated such that any properties added may be, for example,\n   * included in a digital signature value.\n   *\n   * @param proof {object} the proof, in the `constants.SECURITY_CONTEXT_URL`\n   *   to update.\n   *\n   * @return {Promise<object>} resolves to the proof instance (in the\n   *   `constants.SECURITY_CONTEXT_URL`.\n   */\n  async update(proof, {/*document, suite, documentLoader,*/ expansionMap}) {\n    if(expansionMap) {\n      throw new Error('\"expansionMap\" not supported.');\n    }\n    proof.proofPurpose = this.term;\n    return proof;\n  }\n\n  /**\n   * Determines if the given proof has a purpose that matches this instance,\n   * i.e. this ProofPurpose instance should be used to validate the given\n   * proof.\n   *\n   * @param proof {object} the proof to check.\n   *\n   * @return {Promise<boolean>} `true` if there's a match, `false` if not.\n   */\n  async match(proof, {/* document, documentLoader,*/ expansionMap}) {\n    if(expansionMap) {\n      throw new Error('\"expansionMap\" not supported.');\n    }\n    return proof.proofPurpose === this.term;\n  }\n};\n","/*\n * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.\n */\n/* eslint-env browser */\n'use strict';\nconst crypto = self && (self.crypto || self.msCrypto);\n\nmodule.exports = {\n  /**\n   * Hashes a string of data using SHA-256.\n   *\n   * @param {string} string - the string to hash.\n   *\n   * @return {Uint8Array} the hash digest.\n   */\n  async sha256digest({string}) {\n    const bytes = new TextEncoder().encode(string);\n    return new Uint8Array(\n      await crypto.subtle.digest('SHA-256', bytes)\n    );\n  }\n};\n","/*!\n * Copyright (c) 2018 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst api = {};\nmodule.exports = api;\n\n// TODO: only require dynamically as needed or according to build\napi.suites = {\n  LinkedDataProof: require('./suites/LinkedDataProof'),\n  LinkedDataSignature: require('./suites/LinkedDataSignature')\n};\n","/*!\n * Copyright (c) 2018-2023 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nmodule.exports = class LinkedDataProof {\n  constructor({type} = {}) {\n    if(typeof type !== 'string') {\n      throw new TypeError('A LinkedDataProof must have a \"type\".');\n    }\n    this.type = type;\n  }\n\n  /**\n   * @param {object} options - The options to use.\n   * @param {object} options.document - The document to be signed.\n   * @param {ProofPurpose} options.purpose - The proof purpose instance.\n   * @param {Array} options.proofSet - Any existing proof set.\n   * @param {function} options.documentLoader - The document loader to use.\n   * @param {function} options.expansionMap - NOT SUPPORTED; do not use.\n   *\n   * @returns {Promise<object>} Resolves with the created proof object.\n   */\n  async createProof({\n    /* document, purpose, proofSet, documentLoader, expansionMap */\n  }) {\n    throw new Error('\"createProof\" must be implemented in a derived class.');\n  }\n\n  /**\n   * @param {object} options - The options to use.\n   * @param {object} options.document - The document from which to derive\n   *   a new document and proof.\n   * @param {ProofPurpose} options.purpose - The proof purpose instance.\n   * @param {Array} options.proofSet - Any existing proof set.\n   * @param {function} options.documentLoader - The document loader to use.\n   *\n   * @returns {Promise<object>} Resolves with the new document with a new\n   *   `proof` field.\n   */\n  async derive({\n    /* document, purpose, proofSet, documentLoader */\n  }) {\n    throw new Error('\"deriveProof\" must be implemented in a derived class.');\n  }\n\n  /**\n   * @param {object} options - The options to use.\n   * @param {object} options.proof - The proof to be verified.\n   * @param {object} options.document - The document the proof applies to.\n   * @param {ProofPurpose} options.purpose - The proof purpose instance.\n   * @param {Array} options.proofSet - Any existing proof set.\n   * @param {function} options.documentLoader - The document loader to use.\n   * @param {function} options.expansionMap - NOT SUPPORTED; do not use.\n   *\n   * @returns {Promise<{object}>} Resolves with the verification result.\n   */\n  async verifyProof({\n    /* proof, document, purpose, proofSet, documentLoader, expansionMap */\n  }) {\n    throw new Error('\"verifyProof\" must be implemented in a derived class.');\n  }\n\n  /**\n   * Checks whether a given proof exists in the document.\n   *\n   * @param {object} options - The options to use.\n   * @param {object} options.proof - The proof to match.\n   *\n   * @returns {Promise<boolean>} Whether a match for the proof was found.\n   */\n  async matchProof({\n    proof /*, document, purpose, documentLoader, expansionMap */\n  }) {\n    return proof.type === this.type;\n  }\n};\n","/*!\n * Copyright (c) 2017-2023 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst constants = require('../constants');\nconst jsonld = require('jsonld');\nconst util = require('../util');\nconst {sha256digest} = require('../sha256digest');\nconst LinkedDataProof = require('./LinkedDataProof');\n\nmodule.exports = class LinkedDataSignature extends LinkedDataProof {\n  /**\n   * Parent class from which the various LinkDataSignature suites (such as\n   * `Ed25519Signature2020`) inherit.\n   * NOTE: Developers are never expected to use this class directly, but to\n   * only work with individual suites.\n   *\n   * @param {object} options - Options hashmap.\n   * @param {string} options.type - Suite name, provided by subclass.\n   * @typedef LDKeyPair\n   * @param {LDKeyPair} LDKeyClass - The crypto-ld key class that this suite\n   *   will use to sign/verify signatures. Provided by subclass. Used\n   *   during the `verifySignature` operation, to create an instance (containing\n   *   a `verifier()` property) of a public key fetched via a `documentLoader`.\n   *\n   * @param {string} contextUrl - JSON-LD context URL that corresponds to this\n   *   signature suite. Provided by subclass. Used for enforcing suite context\n   *   during the `sign()` operation.\n   *\n   * For `sign()` operations, either a `key` OR a `signer` is required.\n   * For `verify()` operations, you can pass in a verifier (from KMS), or\n   * the public key will be fetched via documentLoader.\n   *\n   * @param {object} [options.key] - An optional key object (containing an\n   *   `id` property, and either `signer` or `verifier`, depending on the\n   *   intended operation. Useful for when the application is managing keys\n   *   itself (when using a KMS, you never have access to the private key,\n   *   and so should use the `signer` param instead).\n   *\n   * @param {{sign: Function, id: string}} [options.signer] - Signer object\n   *   that has two properties: an async `sign()` method, and an `id`. This is\n   *   useful when interfacing with a KMS (since you don't get access to the\n   *   private key and its `signer`, the KMS client gives you only the signer\n   *   object to use).\n   *\n   * @param {{verify: Function, id: string}} [options.verifier] - Verifier\n   *   object that has two properties: an async `verify()` method, and an `id`.\n   *   Useful when working with a KMS-provided verifier.\n   *\n   * Advanced optional parameters and overrides:\n   *\n   * @param {object} [options.proof] - A JSON-LD document with options to use\n   *   for the `proof` node (e.g. any other custom fields can be provided here\n   *   using a context different from security-v2). If not provided, this is\n   *   constructed during signing.\n   * @param {string|Date} [options.date] - Signing date to use (otherwise\n   *   defaults to `now()`).\n   * @param {boolean} [options.useNativeCanonize] - Whether to use a native\n   *   canonize algorithm.\n   * @param {object} [options.canonizeOptions] - Options to pass to\n   *   canonize algorithm.\n   */\n  constructor({\n    type, proof, LDKeyClass, date, key, signer, verifier, useNativeCanonize,\n    canonizeOptions, contextUrl\n  } = {}) {\n    super({type});\n    this.LDKeyClass = LDKeyClass;\n    this.contextUrl = contextUrl;\n    this.proof = proof;\n    const vm = _processSignatureParams({key, signer, verifier});\n    this.verificationMethod = vm.verificationMethod;\n    this.key = vm.key;\n    this.signer = vm.signer;\n    this.verifier = vm.verifier;\n    this.canonizeOptions = canonizeOptions;\n    if(date) {\n      this.date = new Date(date);\n      if(isNaN(this.date)) {\n        throw TypeError(`\"date\" \"${date}\" is not a valid date.`);\n      }\n    }\n    this.useNativeCanonize = useNativeCanonize;\n    this._hashCache = null;\n  }\n\n  /**\n   * @param {object} options - The options to use.\n   * @param {object} options.document - The document to be signed.\n   * @param {ProofPurpose} options.purpose - The proof purpose instance.\n   * @param {Array} options.proofSet - Any existing proof set.\n   * @param {function} options.documentLoader - The document loader to use.\n   * @param {function} options.expansionMap - NOT SUPPORTED; do not use.\n   *\n   * @returns {Promise<object>} Resolves with the created proof object.\n   */\n  async createProof({\n    document, purpose, proofSet, documentLoader, expansionMap\n  }) {\n    if(expansionMap) {\n      throw new Error('\"expansionMap\" not supported.');\n    }\n\n    // build proof (currently known as `signature options` in spec)\n    let proof;\n    if(this.proof) {\n      // shallow copy\n      proof = {...this.proof};\n    } else {\n      // create proof JSON-LD document\n      proof = {};\n    }\n\n    // ensure proof type is set\n    proof.type = this.type;\n\n    // set default `now` date if not given in `proof` or `options`\n    let date = this.date;\n    if(proof.created === undefined && date === undefined) {\n      date = new Date();\n    }\n\n    // ensure date is in string format\n    if(date && typeof date !== 'string') {\n      date = util.w3cDate(date);\n    }\n\n    // add API overrides\n    if(date) {\n      proof.created = date;\n    }\n\n    proof.verificationMethod = this.verificationMethod;\n\n    // add any extensions to proof (mostly for legacy support)\n    proof = await this.updateProof(\n      {document, proof, proofSet, purpose, documentLoader});\n\n    // allow purpose to update the proof; the `proof` is in the\n    // SECURITY_CONTEXT_URL `@context` -- therefore the `purpose` must\n    // ensure any added fields are also represented in that same `@context`\n    proof = await purpose.update(\n      proof, {document, suite: this, documentLoader});\n\n    // create data to sign\n    const verifyData = await this.createVerifyData(\n      {document, proof, proofSet, documentLoader});\n\n    // sign data\n    proof = await this.sign({verifyData, document, proof, documentLoader});\n\n    return proof;\n  }\n\n  /**\n   * @param {object} options - The options to use.\n   * @param {object} options.proof - The proof to be updated.\n   * @param {Array} options.proofSet - Any existing proof set.\n   * @param {function} options.expansionMap - NOT SUPPORTED; do not use.\n   *\n   * @returns {Promise<object>} Resolves with the created proof object.\n   */\n  async updateProof({proof, expansionMap}) {\n    if(expansionMap) {\n      throw new Error('\"expansionMap\" not supported.');\n    }\n    // extending classes may do more\n    return proof;\n  }\n\n  /**\n   * @param {object} options - The options to use.\n   * @param {object} options.proof - The proof to be verified.\n   * @param {object} options.document - The document the proof applies to.\n   * @param {ProofPurpose} options.purpose - The proof purpose instance.\n   * @param {Array} options.proofSet - Any existing proof set.\n   * @param {function} options.documentLoader - The document loader to use.\n   * @param {function} options.expansionMap - NOT SUPPORTED; do not use.\n   *\n   * @returns {Promise<{object}>} Resolves with the verification result.\n   */\n  async verifyProof({proof, document, proofSet, documentLoader, expansionMap}) {\n    if(expansionMap) {\n      throw new Error('\"expansionMap\" not supported.');\n    }\n\n    try {\n      // create data to verify\n      const verifyData = await this.createVerifyData(\n        {document, proof, proofSet, documentLoader, expansionMap});\n\n      // fetch verification method\n      const verificationMethod = await this.getVerificationMethod(\n        {proof, document, documentLoader, expansionMap});\n\n      // verify signature on data\n      const verified = await this.verifySignature({\n        verifyData, verificationMethod, document, proof,\n        documentLoader, expansionMap});\n      if(!verified) {\n        throw new Error('Invalid signature.');\n      }\n\n      return {verified: true, verificationMethod};\n    } catch(error) {\n      return {verified: false, error};\n    }\n  }\n\n  async canonize(input, {documentLoader, expansionMap, skipExpansion}) {\n    if(expansionMap) {\n      throw new Error('\"expansionMap\" not supported.');\n    }\n    return jsonld.canonize(input, {\n      algorithm: 'URDNA2015',\n      // do not resolve any relative URLs or terms, throw errors instead\n      base: null,\n      format: 'application/n-quads',\n      documentLoader,\n      // throw errors if any values would be dropped due to missing\n      // definitions or relative URLs\n      safe: true,\n      skipExpansion,\n      useNative: this.useNativeCanonize,\n      ...this.canonizeOptions\n    });\n  }\n\n  async canonizeProof(proof, {document, documentLoader, expansionMap}) {\n    if(expansionMap) {\n      throw new Error('\"expansionMap\" not supported.');\n    }\n    // `jws`,`signatureValue`,`proofValue` must not be included in the proof\n    // options\n    proof = {\n      '@context': document['@context'] || constants.SECURITY_CONTEXT_URL,\n      ...proof\n    };\n    delete proof.jws;\n    delete proof.signatureValue;\n    delete proof.proofValue;\n    return this.canonize(proof, {\n      documentLoader,\n      expansionMap,\n      skipExpansion: false,\n      ...this.canonizeOptions\n    });\n  }\n\n  /**\n   * @param {object} options - The options to use.\n   * @param {object} options.document - The document to be signed/verified.\n   * @param {object} options.proof - The proof to be verified.\n   * @param {Array} options.proofSet - Any existing proof set.\n   * @param {function} options.documentLoader - The document loader to use.\n   * @param {function} options.expansionMap - NOT SUPPORTED; do not use.\n   *\n   * @returns {Promise<{Uint8Array}>}.\n   */\n  async createVerifyData({document, proof, documentLoader, expansionMap}) {\n    if(expansionMap) {\n      throw new Error('\"expansionMap\" not supported.');\n    }\n    // get cached document hash\n    let cachedDocHash;\n    const {_hashCache} = this;\n    if(_hashCache && _hashCache.document === document) {\n      cachedDocHash = _hashCache.hash;\n    } else {\n      this._hashCache = {\n        document,\n        // canonize and hash document\n        hash: cachedDocHash =\n          this.canonize(document, {documentLoader, expansionMap})\n            .then(c14nDocument => sha256digest({string: c14nDocument}))\n      };\n    }\n\n    // await both c14n proof hash and c14n document hash\n    const [proofHash, docHash] = await Promise.all([\n      // canonize and hash proof\n      this.canonizeProof(\n        proof, {document, documentLoader, expansionMap})\n        .then(c14nProofOptions => sha256digest({string: c14nProofOptions})),\n      cachedDocHash\n    ]);\n\n    // concatenate hash of c14n proof options and hash of c14n document\n    return util.concat(proofHash, docHash);\n  }\n\n  /**\n   * @param verifyData {Uint8Array}.\n   * @param document {object} document from which to derive a new document\n   *   and proof.\n   * @param proof {object}\n   * @param proofSet {Array}\n   * @param documentLoader {function}\n   *\n   * @returns {Promise<{object}>} The new document with `proof`.\n   */\n  async derive() {\n    throw new Error('Must be implemented by a derived class.');\n  }\n\n  /**\n   * @param document {object} to be signed.\n   * @param proof {object}\n   * @param documentLoader {function}\n   */\n  async getVerificationMethod({proof, documentLoader}) {\n    let {verificationMethod} = proof;\n\n    if(typeof verificationMethod === 'object') {\n      verificationMethod = verificationMethod.id;\n    }\n\n    if(!verificationMethod) {\n      throw new Error('No \"verificationMethod\" found in proof.');\n    }\n\n    // Note: `expansionMap` is intentionally not passed; we can safely drop\n    // properties here and must allow for it\n    const framed = await jsonld.frame(verificationMethod, {\n      '@context': constants.SECURITY_CONTEXT_URL,\n      '@embed': '@always',\n      id: verificationMethod\n    }, {documentLoader, compactToRelative: false, safe: true});\n    if(!framed) {\n      throw new Error(`Verification method ${verificationMethod} not found.`);\n    }\n\n    // ensure verification method has not been revoked\n    if(framed.revoked !== undefined) {\n      throw new Error('The verification method has been revoked.');\n    }\n\n    return framed;\n  }\n\n  /**\n   * @param verifyData {Uint8Array}.\n   * @param document {object} to be signed.\n   * @param proof {object}\n   * @param documentLoader {function}\n   * @param expansionMap {function}\n   *\n   * @returns {Promise<{object}>} the proof containing the signature value.\n   */\n  async sign() {\n    throw new Error('Must be implemented by a derived class.');\n  }\n\n  /**\n   * @param verifyData {Uint8Array}.\n   * @param verificationMethod {object}.\n   * @param document {object} to be signed.\n   * @param proof {object}\n   * @param documentLoader {function}\n   * @param expansionMap {function}\n   *\n   * @returns {Promise<boolean>}\n   */\n  async verifySignature() {\n    throw new Error('Must be implemented by a derived class.');\n  }\n\n  /**\n   * Ensures the document to be signed contains the required signature suite\n   * specific `@context`, by either adding it (if `addSuiteContext` is true),\n   * or throwing an error if it's missing.\n   *\n   * @param {object} options - Options hashmap.\n   * @param {object} options.document - JSON-LD document to be signed.\n   * @param {boolean} options.addSuiteContext - Add suite context?\n   */\n  ensureSuiteContext({document, addSuiteContext}) {\n    const {contextUrl} = this;\n\n    if(_includesContext({document, contextUrl})) {\n      // document already includes the required context\n      return;\n    }\n\n    if(!addSuiteContext) {\n      throw new TypeError(\n        `The document to be signed must contain this suite's @context, ` +\n        `\"${contextUrl}\".`);\n    }\n\n    // enforce the suite's context by adding it to the document\n    const existingContext = document['@context'] || [];\n\n    document['@context'] = Array.isArray(existingContext) ?\n      [...existingContext, contextUrl] : [existingContext, contextUrl];\n  }\n};\n\n/**\n * Tests whether a provided JSON-LD document includes a context URL in its\n * `@context` property.\n *\n * @param {object} options - Options hashmap.\n * @param {object} options.document - A JSON-LD document.\n * @param {string} options.contextUrl - A context URL.\n *\n * @returns {boolean} Returns true if document includes context.\n */\nfunction _includesContext({document, contextUrl}) {\n  const context = document['@context'];\n  return context === contextUrl ||\n    (Array.isArray(context) && context.includes(contextUrl));\n}\n\n/**\n * See constructor docstring for param details.\n *\n * @returns {{verificationMethod: string, key: LDKeyPair,\n *   signer: {sign: Function, id: string},\n *   verifier: {verify: Function, id: string}}} - Validated and initialized\n *   key-related parameters.\n */\nfunction _processSignatureParams({key, signer, verifier}) {\n  // We are explicitly not requiring a key or signer/verifier param to be\n  // present, to support the verify() use case where the verificationMethod\n  // is being fetched by the documentLoader\n\n  const vm = {};\n  if(key) {\n    vm.key = key;\n    vm.verificationMethod = key.id;\n    if(typeof key.signer === 'function') {\n      vm.signer = key.signer();\n    }\n    if(typeof key.verifier === 'function') {\n      vm.verifier = key.verifier();\n    }\n    if(!(vm.signer || vm.verifier)) {\n      throw new TypeError(\n        'The \"key\" parameter must contain a \"signer\" or \"verifier\" method.');\n    }\n  } else {\n    vm.verificationMethod = (signer && signer.id) ||\n      (verifier && verifier.id);\n    vm.signer = signer;\n    vm.verifier = verifier;\n  }\n\n  if(vm.signer) {\n    if(typeof vm.signer.sign !== 'function') {\n      throw new TypeError('A signer API has not been specified.');\n    }\n  }\n  if(vm.verifier) {\n    if(typeof vm.verifier.verify !== 'function') {\n      throw new TypeError('A verifier API has not been specified.');\n    }\n  }\n\n  return vm;\n}\n","/*\n * Copyright (c) 2017-2021 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst api = {};\nmodule.exports = api;\n\n/**\n * Converts the given date into W3C datetime format (eg: 2011-03-09T21:55:41Z).\n *\n * @param date the date to convert.\n *\n * @return the date in W3C datetime format.\n */\napi.w3cDate = date => {\n  if(date === undefined || date === null) {\n    date = new Date();\n  } else if(typeof date === 'number' || typeof date === 'string') {\n    date = new Date(date);\n  }\n  const str = date.toISOString();\n  return str.substr(0, str.length - 5) + 'Z';\n};\n\n/**\n * Concatenates two Uint8Arrays.\n *\n * @param b1 {Uint8Array}.\n * @param b2 {Uint8Array}.\n *\n * @return {Uint8Array} the result.\n */\napi.concat = (b1, b2) => {\n  const rval = new Uint8Array(b1.length + b2.length);\n  rval.set(b1, 0);\n  rval.set(b2, b1.length);\n  return rval;\n};\n","/*\n * Copyright (c) 2019 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst {\n  isArray: _isArray,\n  isObject: _isObject,\n  isString: _isString,\n} = require('./types');\nconst {\n  asArray: _asArray\n} = require('./util');\nconst {prependBase} = require('./url');\nconst JsonLdError = require('./JsonLdError');\nconst ResolvedContext = require('./ResolvedContext');\n\nconst MAX_CONTEXT_URLS = 10;\n\nmodule.exports = class ContextResolver {\n  /**\n   * Creates a ContextResolver.\n   *\n   * @param sharedCache a shared LRU cache with `get` and `set` APIs.\n   */\n  constructor({sharedCache}) {\n    this.perOpCache = new Map();\n    this.sharedCache = sharedCache;\n  }\n\n  async resolve({\n    activeCtx, context, documentLoader, base, cycles = new Set()\n  }) {\n    // process `@context`\n    if(context && _isObject(context) && context['@context']) {\n      context = context['@context'];\n    }\n\n    // context is one or more contexts\n    context = _asArray(context);\n\n    // resolve each context in the array\n    const allResolved = [];\n    for(const ctx of context) {\n      if(_isString(ctx)) {\n        // see if `ctx` has been resolved before...\n        let resolved = this._get(ctx);\n        if(!resolved) {\n          // not resolved yet, resolve\n          resolved = await this._resolveRemoteContext(\n            {activeCtx, url: ctx, documentLoader, base, cycles});\n        }\n\n        // add to output and continue\n        if(_isArray(resolved)) {\n          allResolved.push(...resolved);\n        } else {\n          allResolved.push(resolved);\n        }\n        continue;\n      }\n      if(ctx === null) {\n        // handle `null` context, nothing to cache\n        allResolved.push(new ResolvedContext({document: null}));\n        continue;\n      }\n      if(!_isObject(ctx)) {\n        _throwInvalidLocalContext(context);\n      }\n      // context is an object, get/create `ResolvedContext` for it\n      const key = JSON.stringify(ctx);\n      let resolved = this._get(key);\n      if(!resolved) {\n        // create a new static `ResolvedContext` and cache it\n        resolved = new ResolvedContext({document: ctx});\n        this._cacheResolvedContext({key, resolved, tag: 'static'});\n      }\n      allResolved.push(resolved);\n    }\n\n    return allResolved;\n  }\n\n  _get(key) {\n    // get key from per operation cache; no `tag` is used with this cache so\n    // any retrieved context will always be the same during a single operation\n    let resolved = this.perOpCache.get(key);\n    if(!resolved) {\n      // see if the shared cache has a `static` entry for this URL\n      const tagMap = this.sharedCache.get(key);\n      if(tagMap) {\n        resolved = tagMap.get('static');\n        if(resolved) {\n          this.perOpCache.set(key, resolved);\n        }\n      }\n    }\n    return resolved;\n  }\n\n  _cacheResolvedContext({key, resolved, tag}) {\n    this.perOpCache.set(key, resolved);\n    if(tag !== undefined) {\n      let tagMap = this.sharedCache.get(key);\n      if(!tagMap) {\n        tagMap = new Map();\n        this.sharedCache.set(key, tagMap);\n      }\n      tagMap.set(tag, resolved);\n    }\n    return resolved;\n  }\n\n  async _resolveRemoteContext({activeCtx, url, documentLoader, base, cycles}) {\n    // resolve relative URL and fetch context\n    url = prependBase(base, url);\n    const {context, remoteDoc} = await this._fetchContext(\n      {activeCtx, url, documentLoader, cycles});\n\n    // update base according to remote document and resolve any relative URLs\n    base = remoteDoc.documentUrl || url;\n    _resolveContextUrls({context, base});\n\n    // resolve, cache, and return context\n    const resolved = await this.resolve(\n      {activeCtx, context, documentLoader, base, cycles});\n    this._cacheResolvedContext({key: url, resolved, tag: remoteDoc.tag});\n    return resolved;\n  }\n\n  async _fetchContext({activeCtx, url, documentLoader, cycles}) {\n    // check for max context URLs fetched during a resolve operation\n    if(cycles.size > MAX_CONTEXT_URLS) {\n      throw new JsonLdError(\n        'Maximum number of @context URLs exceeded.',\n        'jsonld.ContextUrlError',\n        {\n          code: activeCtx.processingMode === 'json-ld-1.0' ?\n            'loading remote context failed' :\n            'context overflow',\n          max: MAX_CONTEXT_URLS\n        });\n    }\n\n    // check for context URL cycle\n    // shortcut to avoid extra work that would eventually hit the max above\n    if(cycles.has(url)) {\n      throw new JsonLdError(\n        'Cyclical @context URLs detected.',\n        'jsonld.ContextUrlError',\n        {\n          code: activeCtx.processingMode === 'json-ld-1.0' ?\n            'recursive context inclusion' :\n            'context overflow',\n          url\n        });\n    }\n\n    // track cycles\n    cycles.add(url);\n\n    let context;\n    let remoteDoc;\n\n    try {\n      remoteDoc = await documentLoader(url);\n      context = remoteDoc.document || null;\n      // parse string context as JSON\n      if(_isString(context)) {\n        context = JSON.parse(context);\n      }\n    } catch(e) {\n      throw new JsonLdError(\n        'Dereferencing a URL did not result in a valid JSON-LD object. ' +\n        'Possible causes are an inaccessible URL perhaps due to ' +\n        'a same-origin policy (ensure the server uses CORS if you are ' +\n        'using client-side JavaScript), too many redirects, a ' +\n        'non-JSON response, or more than one HTTP Link Header was ' +\n        'provided for a remote context.',\n        'jsonld.InvalidUrl',\n        {code: 'loading remote context failed', url, cause: e});\n    }\n\n    // ensure ctx is an object\n    if(!_isObject(context)) {\n      throw new JsonLdError(\n        'Dereferencing a URL did not result in a JSON object. The ' +\n        'response was valid JSON, but it was not a JSON object.',\n        'jsonld.InvalidUrl', {code: 'invalid remote context', url});\n    }\n\n    // use empty context if no @context key is present\n    if(!('@context' in context)) {\n      context = {'@context': {}};\n    } else {\n      context = {'@context': context['@context']};\n    }\n\n    // append @context URL to context if given\n    if(remoteDoc.contextUrl) {\n      if(!_isArray(context['@context'])) {\n        context['@context'] = [context['@context']];\n      }\n      context['@context'].push(remoteDoc.contextUrl);\n    }\n\n    return {context, remoteDoc};\n  }\n};\n\nfunction _throwInvalidLocalContext(ctx) {\n  throw new JsonLdError(\n    'Invalid JSON-LD syntax; @context must be an object.',\n    'jsonld.SyntaxError', {\n      code: 'invalid local context', context: ctx\n    });\n}\n\n/**\n * Resolve all relative `@context` URLs in the given context by inline\n * replacing them with absolute URLs.\n *\n * @param context the context.\n * @param base the base IRI to use to resolve relative IRIs.\n */\nfunction _resolveContextUrls({context, base}) {\n  if(!context) {\n    return;\n  }\n\n  const ctx = context['@context'];\n\n  if(_isString(ctx)) {\n    context['@context'] = prependBase(base, ctx);\n    return;\n  }\n\n  if(_isArray(ctx)) {\n    for(let i = 0; i < ctx.length; ++i) {\n      const element = ctx[i];\n      if(_isString(element)) {\n        ctx[i] = prependBase(base, element);\n        continue;\n      }\n      if(_isObject(element)) {\n        _resolveContextUrls({context: {'@context': element}, base});\n      }\n    }\n    return;\n  }\n\n  if(!_isObject(ctx)) {\n    // no @context URLs can be found in non-object\n    return;\n  }\n\n  // ctx is an object, resolve any context URLs in terms\n  for(const term in ctx) {\n    _resolveContextUrls({context: ctx[term], base});\n  }\n}\n","/*\n * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nmodule.exports = class JsonLdError extends Error {\n  /**\n   * Creates a JSON-LD Error.\n   *\n   * @param msg the error message.\n   * @param type the error type.\n   * @param details the error details.\n   */\n  constructor(\n    message = 'An unspecified JSON-LD error occurred.',\n    name = 'jsonld.Error',\n    details = {}) {\n    super(message);\n    this.name = name;\n    this.message = message;\n    this.details = details;\n  }\n};\n","/*\n * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nmodule.exports = jsonld => {\n  class JsonLdProcessor {\n    toString() {\n      return '[object JsonLdProcessor]';\n    }\n  }\n  Object.defineProperty(JsonLdProcessor, 'prototype', {\n    writable: false,\n    enumerable: false\n  });\n  Object.defineProperty(JsonLdProcessor.prototype, 'constructor', {\n    writable: true,\n    enumerable: false,\n    configurable: true,\n    value: JsonLdProcessor\n  });\n\n  // The Web IDL test harness will check the number of parameters defined in\n  // the functions below. The number of parameters must exactly match the\n  // required (non-optional) parameters of the JsonLdProcessor interface as\n  // defined here:\n  // https://www.w3.org/TR/json-ld-api/#the-jsonldprocessor-interface\n\n  JsonLdProcessor.compact = function(input, ctx) {\n    if(arguments.length < 2) {\n      return Promise.reject(\n        new TypeError('Could not compact, too few arguments.'));\n    }\n    return jsonld.compact(input, ctx);\n  };\n  JsonLdProcessor.expand = function(input) {\n    if(arguments.length < 1) {\n      return Promise.reject(\n        new TypeError('Could not expand, too few arguments.'));\n    }\n    return jsonld.expand(input);\n  };\n  JsonLdProcessor.flatten = function(input) {\n    if(arguments.length < 1) {\n      return Promise.reject(\n        new TypeError('Could not flatten, too few arguments.'));\n    }\n    return jsonld.flatten(input);\n  };\n\n  return JsonLdProcessor;\n};\n","/*\n * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\n// TODO: move `NQuads` to its own package\nmodule.exports = require('rdf-canonize').NQuads;\n","/*\n * Copyright (c) 2017-2019 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nmodule.exports = class RequestQueue {\n  /**\n   * Creates a simple queue for requesting documents.\n   */\n  constructor() {\n    this._requests = {};\n  }\n\n  wrapLoader(loader) {\n    const self = this;\n    self._loader = loader;\n    return function(/* url */) {\n      return self.add.apply(self, arguments);\n    };\n  }\n\n  async add(url) {\n    let promise = this._requests[url];\n    if(promise) {\n      // URL already queued, wait for it to load\n      return Promise.resolve(promise);\n    }\n\n    // queue URL and load it\n    promise = this._requests[url] = this._loader(url);\n\n    try {\n      return await promise;\n    } finally {\n      delete this._requests[url];\n    }\n  }\n};\n","/*\n * Copyright (c) 2019 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst LRU = require('lru-cache');\n\nconst MAX_ACTIVE_CONTEXTS = 10;\n\nmodule.exports = class ResolvedContext {\n  /**\n   * Creates a ResolvedContext.\n   *\n   * @param document the context document.\n   */\n  constructor({document}) {\n    this.document = document;\n    // TODO: enable customization of processed context cache\n    // TODO: limit based on size of processed contexts vs. number of them\n    this.cache = new LRU({max: MAX_ACTIVE_CONTEXTS});\n  }\n\n  getProcessed(activeCtx) {\n    return this.cache.get(activeCtx);\n  }\n\n  setProcessed(activeCtx, processedCtx) {\n    this.cache.set(activeCtx, processedCtx);\n  }\n};\n","/*\n * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst JsonLdError = require('./JsonLdError');\n\nconst {\n  isArray: _isArray,\n  isObject: _isObject,\n  isString: _isString,\n  isUndefined: _isUndefined\n} = require('./types');\n\nconst {\n  isList: _isList,\n  isValue: _isValue,\n  isGraph: _isGraph,\n  isSimpleGraph: _isSimpleGraph,\n  isSubjectReference: _isSubjectReference\n} = require('./graphTypes');\n\nconst {\n  expandIri: _expandIri,\n  getContextValue: _getContextValue,\n  isKeyword: _isKeyword,\n  process: _processContext,\n  processingMode: _processingMode\n} = require('./context');\n\nconst {\n  removeBase: _removeBase,\n  prependBase: _prependBase\n} = require('./url');\n\nconst {\n  REGEX_KEYWORD,\n  addValue: _addValue,\n  asArray: _asArray,\n  compareShortestLeast: _compareShortestLeast\n} = require('./util');\n\nconst api = {};\nmodule.exports = api;\n\n/**\n * Recursively compacts an element using the given active context. All values\n * must be in expanded form before this method is called.\n *\n * @param activeCtx the active context to use.\n * @param activeProperty the compacted property associated with the element\n *          to compact, null for none.\n * @param element the element to compact.\n * @param options the compaction options.\n *\n * @return a promise that resolves to the compacted value.\n */\napi.compact = async ({\n  activeCtx,\n  activeProperty = null,\n  element,\n  options = {}\n}) => {\n  // recursively compact array\n  if(_isArray(element)) {\n    let rval = [];\n    for(let i = 0; i < element.length; ++i) {\n      const compacted = await api.compact({\n        activeCtx,\n        activeProperty,\n        element: element[i],\n        options\n      });\n      if(compacted === null) {\n        // FIXME: need event?\n        continue;\n      }\n      rval.push(compacted);\n    }\n    if(options.compactArrays && rval.length === 1) {\n      // use single element if no container is specified\n      const container = _getContextValue(\n        activeCtx, activeProperty, '@container') || [];\n      if(container.length === 0) {\n        rval = rval[0];\n      }\n    }\n    return rval;\n  }\n\n  // use any scoped context on activeProperty\n  const ctx = _getContextValue(activeCtx, activeProperty, '@context');\n  if(!_isUndefined(ctx)) {\n    activeCtx = await _processContext({\n      activeCtx,\n      localCtx: ctx,\n      propagate: true,\n      overrideProtected: true,\n      options\n    });\n  }\n\n  // recursively compact object\n  if(_isObject(element)) {\n    if(options.link && '@id' in element &&\n      options.link.hasOwnProperty(element['@id'])) {\n      // check for a linked element to reuse\n      const linked = options.link[element['@id']];\n      for(let i = 0; i < linked.length; ++i) {\n        if(linked[i].expanded === element) {\n          return linked[i].compacted;\n        }\n      }\n    }\n\n    // do value compaction on @values and subject references\n    if(_isValue(element) || _isSubjectReference(element)) {\n      const rval =\n        api.compactValue({activeCtx, activeProperty, value: element, options});\n      if(options.link && _isSubjectReference(element)) {\n        // store linked element\n        if(!(options.link.hasOwnProperty(element['@id']))) {\n          options.link[element['@id']] = [];\n        }\n        options.link[element['@id']].push({expanded: element, compacted: rval});\n      }\n      return rval;\n    }\n\n    // if expanded property is @list and we're contained within a list\n    // container, recursively compact this item to an array\n    if(_isList(element)) {\n      const container = _getContextValue(\n        activeCtx, activeProperty, '@container') || [];\n      if(container.includes('@list')) {\n        return api.compact({\n          activeCtx,\n          activeProperty,\n          element: element['@list'],\n          options\n        });\n      }\n    }\n\n    // FIXME: avoid misuse of active property as an expanded property?\n    const insideReverse = (activeProperty === '@reverse');\n\n    const rval = {};\n\n    // original context before applying property-scoped and local contexts\n    const inputCtx = activeCtx;\n\n    // revert to previous context, if there is one,\n    // and element is not a value object or a node reference\n    if(!_isValue(element) && !_isSubjectReference(element)) {\n      activeCtx = activeCtx.revertToPreviousContext();\n    }\n\n    // apply property-scoped context after reverting term-scoped context\n    const propertyScopedCtx =\n      _getContextValue(inputCtx, activeProperty, '@context');\n    if(!_isUndefined(propertyScopedCtx)) {\n      activeCtx = await _processContext({\n        activeCtx,\n        localCtx: propertyScopedCtx,\n        propagate: true,\n        overrideProtected: true,\n        options\n      });\n    }\n\n    if(options.link && '@id' in element) {\n      // store linked element\n      if(!options.link.hasOwnProperty(element['@id'])) {\n        options.link[element['@id']] = [];\n      }\n      options.link[element['@id']].push({expanded: element, compacted: rval});\n    }\n\n    // apply any context defined on an alias of @type\n    // if key is @type and any compacted value is a term having a local\n    // context, overlay that context\n    let types = element['@type'] || [];\n    if(types.length > 1) {\n      types = Array.from(types).sort();\n    }\n    // find all type-scoped contexts based on current context, prior to\n    // updating it\n    const typeContext = activeCtx;\n    for(const type of types) {\n      const compactedType = api.compactIri(\n        {activeCtx: typeContext, iri: type, relativeTo: {vocab: true}});\n\n      // Use any type-scoped context defined on this value\n      const ctx = _getContextValue(inputCtx, compactedType, '@context');\n      if(!_isUndefined(ctx)) {\n        activeCtx = await _processContext({\n          activeCtx,\n          localCtx: ctx,\n          options,\n          propagate: false\n        });\n      }\n    }\n\n    // process element keys in order\n    const keys = Object.keys(element).sort();\n    for(const expandedProperty of keys) {\n      const expandedValue = element[expandedProperty];\n\n      // compact @id\n      if(expandedProperty === '@id') {\n        let compactedValue = _asArray(expandedValue).map(\n          expandedIri => api.compactIri({\n            activeCtx,\n            iri: expandedIri,\n            relativeTo: {vocab: false},\n            base: options.base\n          }));\n        if(compactedValue.length === 1) {\n          compactedValue = compactedValue[0];\n        }\n\n        // use keyword alias and add value\n        const alias = api.compactIri(\n          {activeCtx, iri: '@id', relativeTo: {vocab: true}});\n\n        rval[alias] = compactedValue;\n        continue;\n      }\n\n      // compact @type(s)\n      if(expandedProperty === '@type') {\n        // resolve type values against previous context\n        let compactedValue = _asArray(expandedValue).map(\n          expandedIri => api.compactIri({\n            activeCtx: inputCtx,\n            iri: expandedIri,\n            relativeTo: {vocab: true}\n          }));\n        if(compactedValue.length === 1) {\n          compactedValue = compactedValue[0];\n        }\n\n        // use keyword alias and add value\n        const alias = api.compactIri(\n          {activeCtx, iri: '@type', relativeTo: {vocab: true}});\n        const container = _getContextValue(\n          activeCtx, alias, '@container') || [];\n\n        // treat as array for @type if @container includes @set\n        const typeAsSet =\n          container.includes('@set') &&\n          _processingMode(activeCtx, 1.1);\n        const isArray =\n          typeAsSet || (_isArray(compactedValue) && expandedValue.length === 0);\n        _addValue(rval, alias, compactedValue, {propertyIsArray: isArray});\n        continue;\n      }\n\n      // handle @reverse\n      if(expandedProperty === '@reverse') {\n        // recursively compact expanded value\n        const compactedValue = await api.compact({\n          activeCtx,\n          activeProperty: '@reverse',\n          element: expandedValue,\n          options\n        });\n\n        // handle double-reversed properties\n        for(const compactedProperty in compactedValue) {\n          if(activeCtx.mappings.has(compactedProperty) &&\n            activeCtx.mappings.get(compactedProperty).reverse) {\n            const value = compactedValue[compactedProperty];\n            const container = _getContextValue(\n              activeCtx, compactedProperty, '@container') || [];\n            const useArray = (\n              container.includes('@set') || !options.compactArrays);\n            _addValue(\n              rval, compactedProperty, value, {propertyIsArray: useArray});\n            delete compactedValue[compactedProperty];\n          }\n        }\n\n        if(Object.keys(compactedValue).length > 0) {\n          // use keyword alias and add value\n          const alias = api.compactIri({\n            activeCtx,\n            iri: expandedProperty,\n            relativeTo: {vocab: true}\n          });\n          _addValue(rval, alias, compactedValue);\n        }\n\n        continue;\n      }\n\n      if(expandedProperty === '@preserve') {\n        // compact using activeProperty\n        const compactedValue = await api.compact({\n          activeCtx,\n          activeProperty,\n          element: expandedValue,\n          options\n        });\n\n        if(!(_isArray(compactedValue) && compactedValue.length === 0)) {\n          _addValue(rval, expandedProperty, compactedValue);\n        }\n        continue;\n      }\n\n      // handle @index property\n      if(expandedProperty === '@index') {\n        // drop @index if inside an @index container\n        const container = _getContextValue(\n          activeCtx, activeProperty, '@container') || [];\n        if(container.includes('@index')) {\n          continue;\n        }\n\n        // use keyword alias and add value\n        const alias = api.compactIri({\n          activeCtx,\n          iri: expandedProperty,\n          relativeTo: {vocab: true}\n        });\n        _addValue(rval, alias, expandedValue);\n        continue;\n      }\n\n      // skip array processing for keywords that aren't\n      // @graph, @list, or @included\n      if(expandedProperty !== '@graph' && expandedProperty !== '@list' &&\n        expandedProperty !== '@included' &&\n        _isKeyword(expandedProperty)) {\n        // use keyword alias and add value as is\n        const alias = api.compactIri({\n          activeCtx,\n          iri: expandedProperty,\n          relativeTo: {vocab: true}\n        });\n        _addValue(rval, alias, expandedValue);\n        continue;\n      }\n\n      // Note: expanded value must be an array due to expansion algorithm.\n      if(!_isArray(expandedValue)) {\n        throw new JsonLdError(\n          'JSON-LD expansion error; expanded value must be an array.',\n          'jsonld.SyntaxError');\n      }\n\n      // preserve empty arrays\n      if(expandedValue.length === 0) {\n        const itemActiveProperty = api.compactIri({\n          activeCtx,\n          iri: expandedProperty,\n          value: expandedValue,\n          relativeTo: {vocab: true},\n          reverse: insideReverse\n        });\n        const nestProperty = activeCtx.mappings.has(itemActiveProperty) ?\n          activeCtx.mappings.get(itemActiveProperty)['@nest'] : null;\n        let nestResult = rval;\n        if(nestProperty) {\n          _checkNestProperty(activeCtx, nestProperty, options);\n          if(!_isObject(rval[nestProperty])) {\n            rval[nestProperty] = {};\n          }\n          nestResult = rval[nestProperty];\n        }\n        _addValue(\n          nestResult, itemActiveProperty, expandedValue, {\n            propertyIsArray: true\n          });\n      }\n\n      // recusively process array values\n      for(const expandedItem of expandedValue) {\n        // compact property and get container type\n        const itemActiveProperty = api.compactIri({\n          activeCtx,\n          iri: expandedProperty,\n          value: expandedItem,\n          relativeTo: {vocab: true},\n          reverse: insideReverse\n        });\n\n        // if itemActiveProperty is a @nest property, add values to nestResult,\n        // otherwise rval\n        const nestProperty = activeCtx.mappings.has(itemActiveProperty) ?\n          activeCtx.mappings.get(itemActiveProperty)['@nest'] : null;\n        let nestResult = rval;\n        if(nestProperty) {\n          _checkNestProperty(activeCtx, nestProperty, options);\n          if(!_isObject(rval[nestProperty])) {\n            rval[nestProperty] = {};\n          }\n          nestResult = rval[nestProperty];\n        }\n\n        const container = _getContextValue(\n          activeCtx, itemActiveProperty, '@container') || [];\n\n        // get simple @graph or @list value if appropriate\n        const isGraph = _isGraph(expandedItem);\n        const isList = _isList(expandedItem);\n        let inner;\n        if(isList) {\n          inner = expandedItem['@list'];\n        } else if(isGraph) {\n          inner = expandedItem['@graph'];\n        }\n\n        // recursively compact expanded item\n        let compactedItem = await api.compact({\n          activeCtx,\n          activeProperty: itemActiveProperty,\n          element: (isList || isGraph) ? inner : expandedItem,\n          options\n        });\n\n        // handle @list\n        if(isList) {\n          // ensure @list value is an array\n          if(!_isArray(compactedItem)) {\n            compactedItem = [compactedItem];\n          }\n\n          if(!container.includes('@list')) {\n            // wrap using @list alias\n            compactedItem = {\n              [api.compactIri({\n                activeCtx,\n                iri: '@list',\n                relativeTo: {vocab: true}\n              })]: compactedItem\n            };\n\n            // include @index from expanded @list, if any\n            if('@index' in expandedItem) {\n              compactedItem[api.compactIri({\n                activeCtx,\n                iri: '@index',\n                relativeTo: {vocab: true}\n              })] = expandedItem['@index'];\n            }\n          } else {\n            _addValue(nestResult, itemActiveProperty, compactedItem, {\n              valueIsArray: true,\n              allowDuplicate: true\n            });\n            continue;\n          }\n        }\n\n        // Graph object compaction cases\n        if(isGraph) {\n          if(container.includes('@graph') && (container.includes('@id') ||\n            container.includes('@index') && _isSimpleGraph(expandedItem))) {\n            // get or create the map object\n            let mapObject;\n            if(nestResult.hasOwnProperty(itemActiveProperty)) {\n              mapObject = nestResult[itemActiveProperty];\n            } else {\n              nestResult[itemActiveProperty] = mapObject = {};\n            }\n\n            // index on @id or @index or alias of @none\n            const key = (container.includes('@id') ?\n              expandedItem['@id'] : expandedItem['@index']) ||\n              api.compactIri({activeCtx, iri: '@none',\n                relativeTo: {vocab: true}});\n            // add compactedItem to map, using value of `@id` or a new blank\n            // node identifier\n\n            _addValue(\n              mapObject, key, compactedItem, {\n                propertyIsArray:\n                  (!options.compactArrays || container.includes('@set'))\n              });\n          } else if(container.includes('@graph') &&\n            _isSimpleGraph(expandedItem)) {\n            // container includes @graph but not @id or @index and value is a\n            // simple graph object add compact value\n            // if compactedItem contains multiple values, it is wrapped in\n            // `@included`\n            if(_isArray(compactedItem) && compactedItem.length > 1) {\n              compactedItem = {'@included': compactedItem};\n            }\n            _addValue(\n              nestResult, itemActiveProperty, compactedItem, {\n                propertyIsArray:\n                  (!options.compactArrays || container.includes('@set'))\n              });\n          } else {\n            // wrap using @graph alias, remove array if only one item and\n            // compactArrays not set\n            if(_isArray(compactedItem) && compactedItem.length === 1 &&\n              options.compactArrays) {\n              compactedItem = compactedItem[0];\n            }\n            compactedItem = {\n              [api.compactIri({\n                activeCtx,\n                iri: '@graph',\n                relativeTo: {vocab: true}\n              })]: compactedItem\n            };\n\n            // include @id from expanded graph, if any\n            if('@id' in expandedItem) {\n              compactedItem[api.compactIri({\n                activeCtx,\n                iri: '@id',\n                relativeTo: {vocab: true}\n              })] = expandedItem['@id'];\n            }\n\n            // include @index from expanded graph, if any\n            if('@index' in expandedItem) {\n              compactedItem[api.compactIri({\n                activeCtx,\n                iri: '@index',\n                relativeTo: {vocab: true}\n              })] = expandedItem['@index'];\n            }\n            _addValue(\n              nestResult, itemActiveProperty, compactedItem, {\n                propertyIsArray:\n                  (!options.compactArrays || container.includes('@set'))\n              });\n          }\n        } else if(container.includes('@language') ||\n          container.includes('@index') || container.includes('@id') ||\n          container.includes('@type')) {\n          // handle language and index maps\n          // get or create the map object\n          let mapObject;\n          if(nestResult.hasOwnProperty(itemActiveProperty)) {\n            mapObject = nestResult[itemActiveProperty];\n          } else {\n            nestResult[itemActiveProperty] = mapObject = {};\n          }\n\n          let key;\n          if(container.includes('@language')) {\n            // if container is a language map, simplify compacted value to\n            // a simple string\n            if(_isValue(compactedItem)) {\n              compactedItem = compactedItem['@value'];\n            }\n            key = expandedItem['@language'];\n          } else if(container.includes('@index')) {\n            const indexKey = _getContextValue(\n              activeCtx, itemActiveProperty, '@index') || '@index';\n            const containerKey = api.compactIri(\n              {activeCtx, iri: indexKey, relativeTo: {vocab: true}});\n            if(indexKey === '@index') {\n              key = expandedItem['@index'];\n              delete compactedItem[containerKey];\n            } else {\n              let others;\n              [key, ...others] = _asArray(compactedItem[indexKey] || []);\n              if(!_isString(key)) {\n                // Will use @none if it isn't a string.\n                key = null;\n              } else {\n                switch(others.length) {\n                  case 0:\n                    delete compactedItem[indexKey];\n                    break;\n                  case 1:\n                    compactedItem[indexKey] = others[0];\n                    break;\n                  default:\n                    compactedItem[indexKey] = others;\n                    break;\n                }\n              }\n            }\n          } else if(container.includes('@id')) {\n            const idKey = api.compactIri({activeCtx, iri: '@id',\n              relativeTo: {vocab: true}});\n            key = compactedItem[idKey];\n            delete compactedItem[idKey];\n          } else if(container.includes('@type')) {\n            const typeKey = api.compactIri({\n              activeCtx,\n              iri: '@type',\n              relativeTo: {vocab: true}\n            });\n            let types;\n            [key, ...types] = _asArray(compactedItem[typeKey] || []);\n            switch(types.length) {\n              case 0:\n                delete compactedItem[typeKey];\n                break;\n              case 1:\n                compactedItem[typeKey] = types[0];\n                break;\n              default:\n                compactedItem[typeKey] = types;\n                break;\n            }\n\n            // If compactedItem contains a single entry\n            // whose key maps to @id, recompact without @type\n            if(Object.keys(compactedItem).length === 1 &&\n              '@id' in expandedItem) {\n              compactedItem = await api.compact({\n                activeCtx,\n                activeProperty: itemActiveProperty,\n                element: {'@id': expandedItem['@id']},\n                options\n              });\n            }\n          }\n\n          // if compacting this value which has no key, index on @none\n          if(!key) {\n            key = api.compactIri({activeCtx, iri: '@none',\n              relativeTo: {vocab: true}});\n          }\n          // add compact value to map object using key from expanded value\n          // based on the container type\n          _addValue(\n            mapObject, key, compactedItem, {\n              propertyIsArray: container.includes('@set')\n            });\n        } else {\n          // use an array if: compactArrays flag is false,\n          // @container is @set or @list , value is an empty\n          // array, or key is @graph\n          const isArray = (!options.compactArrays ||\n            container.includes('@set') || container.includes('@list') ||\n            (_isArray(compactedItem) && compactedItem.length === 0) ||\n            expandedProperty === '@list' || expandedProperty === '@graph');\n\n          // add compact value\n          _addValue(\n            nestResult, itemActiveProperty, compactedItem,\n            {propertyIsArray: isArray});\n        }\n      }\n    }\n\n    return rval;\n  }\n\n  // only primitives remain which are already compact\n  return element;\n};\n\n/**\n * Compacts an IRI or keyword into a term or prefix if it can be. If the\n * IRI has an associated value it may be passed.\n *\n * @param activeCtx the active context to use.\n * @param iri the IRI to compact.\n * @param value the value to check or null.\n * @param relativeTo options for how to compact IRIs:\n *          vocab: true to split after @vocab, false not to.\n * @param reverse true if a reverse property is being compacted, false if not.\n * @param base the absolute URL to use for compacting document-relative IRIs.\n *\n * @return the compacted term, prefix, keyword alias, or the original IRI.\n */\napi.compactIri = ({\n  activeCtx,\n  iri,\n  value = null,\n  relativeTo = {vocab: false},\n  reverse = false,\n  base = null\n}) => {\n  // can't compact null\n  if(iri === null) {\n    return iri;\n  }\n\n  // if context is from a property term scoped context composed with a\n  // type-scoped context, then use the previous context instead\n  if(activeCtx.isPropertyTermScoped && activeCtx.previousContext) {\n    activeCtx = activeCtx.previousContext;\n  }\n\n  const inverseCtx = activeCtx.getInverse();\n\n  // if term is a keyword, it may be compacted to a simple alias\n  if(_isKeyword(iri) &&\n    iri in inverseCtx &&\n    '@none' in inverseCtx[iri] &&\n    '@type' in inverseCtx[iri]['@none'] &&\n    '@none' in inverseCtx[iri]['@none']['@type']) {\n    return inverseCtx[iri]['@none']['@type']['@none'];\n  }\n\n  // use inverse context to pick a term if iri is relative to vocab\n  if(relativeTo.vocab && iri in inverseCtx) {\n    const defaultLanguage = activeCtx['@language'] || '@none';\n\n    // prefer @index if available in value\n    const containers = [];\n    if(_isObject(value) && '@index' in value && !('@graph' in value)) {\n      containers.push('@index', '@index@set');\n    }\n\n    // if value is a preserve object, use its value\n    if(_isObject(value) && '@preserve' in value) {\n      value = value['@preserve'][0];\n    }\n\n    // prefer most specific container including @graph, prefering @set\n    // variations\n    if(_isGraph(value)) {\n      // favor indexmap if the graph is indexed\n      if('@index' in value) {\n        containers.push(\n          '@graph@index', '@graph@index@set', '@index', '@index@set');\n      }\n      // favor idmap if the graph is has an @id\n      if('@id' in value) {\n        containers.push(\n          '@graph@id', '@graph@id@set');\n      }\n      containers.push('@graph', '@graph@set', '@set');\n      // allow indexmap if the graph is not indexed\n      if(!('@index' in value)) {\n        containers.push(\n          '@graph@index', '@graph@index@set', '@index', '@index@set');\n      }\n      // allow idmap if the graph does not have an @id\n      if(!('@id' in value)) {\n        containers.push('@graph@id', '@graph@id@set');\n      }\n    } else if(_isObject(value) && !_isValue(value)) {\n      containers.push('@id', '@id@set', '@type', '@set@type');\n    }\n\n    // defaults for term selection based on type/language\n    let typeOrLanguage = '@language';\n    let typeOrLanguageValue = '@null';\n\n    if(reverse) {\n      typeOrLanguage = '@type';\n      typeOrLanguageValue = '@reverse';\n      containers.push('@set');\n    } else if(_isList(value)) {\n      // choose the most specific term that works for all elements in @list\n      // only select @list containers if @index is NOT in value\n      if(!('@index' in value)) {\n        containers.push('@list');\n      }\n      const list = value['@list'];\n      if(list.length === 0) {\n        // any empty list can be matched against any term that uses the\n        // @list container regardless of @type or @language\n        typeOrLanguage = '@any';\n        typeOrLanguageValue = '@none';\n      } else {\n        let commonLanguage = (list.length === 0) ? defaultLanguage : null;\n        let commonType = null;\n        for(let i = 0; i < list.length; ++i) {\n          const item = list[i];\n          let itemLanguage = '@none';\n          let itemType = '@none';\n          if(_isValue(item)) {\n            if('@direction' in item) {\n              const lang = (item['@language'] || '').toLowerCase();\n              const dir = item['@direction'];\n              itemLanguage = `${lang}_${dir}`;\n            } else if('@language' in item) {\n              itemLanguage = item['@language'].toLowerCase();\n            } else if('@type' in item) {\n              itemType = item['@type'];\n            } else {\n              // plain literal\n              itemLanguage = '@null';\n            }\n          } else {\n            itemType = '@id';\n          }\n          if(commonLanguage === null) {\n            commonLanguage = itemLanguage;\n          } else if(itemLanguage !== commonLanguage && _isValue(item)) {\n            commonLanguage = '@none';\n          }\n          if(commonType === null) {\n            commonType = itemType;\n          } else if(itemType !== commonType) {\n            commonType = '@none';\n          }\n          // there are different languages and types in the list, so choose\n          // the most generic term, no need to keep iterating the list\n          if(commonLanguage === '@none' && commonType === '@none') {\n            break;\n          }\n        }\n        commonLanguage = commonLanguage || '@none';\n        commonType = commonType || '@none';\n        if(commonType !== '@none') {\n          typeOrLanguage = '@type';\n          typeOrLanguageValue = commonType;\n        } else {\n          typeOrLanguageValue = commonLanguage;\n        }\n      }\n    } else {\n      if(_isValue(value)) {\n        if('@language' in value && !('@index' in value)) {\n          containers.push('@language', '@language@set');\n          typeOrLanguageValue = value['@language'];\n          const dir = value['@direction'];\n          if(dir) {\n            typeOrLanguageValue = `${typeOrLanguageValue}_${dir}`;\n          }\n        } else if('@direction' in value && !('@index' in value)) {\n          typeOrLanguageValue = `_${value['@direction']}`;\n        } else if('@type' in value) {\n          typeOrLanguage = '@type';\n          typeOrLanguageValue = value['@type'];\n        }\n      } else {\n        typeOrLanguage = '@type';\n        typeOrLanguageValue = '@id';\n      }\n      containers.push('@set');\n    }\n\n    // do term selection\n    containers.push('@none');\n\n    // an index map can be used to index values using @none, so add as a low\n    // priority\n    if(_isObject(value) && !('@index' in value)) {\n      // allow indexing even if no @index present\n      containers.push('@index', '@index@set');\n    }\n\n    // values without type or language can use @language map\n    if(_isValue(value) && Object.keys(value).length === 1) {\n      // allow indexing even if no @index present\n      containers.push('@language', '@language@set');\n    }\n\n    const term = _selectTerm(\n      activeCtx, iri, value, containers, typeOrLanguage, typeOrLanguageValue);\n    if(term !== null) {\n      return term;\n    }\n  }\n\n  // no term match, use @vocab if available\n  if(relativeTo.vocab) {\n    if('@vocab' in activeCtx) {\n      // determine if vocab is a prefix of the iri\n      const vocab = activeCtx['@vocab'];\n      if(iri.indexOf(vocab) === 0 && iri !== vocab) {\n        // use suffix as relative iri if it is not a term in the active context\n        const suffix = iri.substr(vocab.length);\n        if(!activeCtx.mappings.has(suffix)) {\n          return suffix;\n        }\n      }\n    }\n  }\n\n  // no term or @vocab match, check for possible CURIEs\n  let choice = null;\n  // TODO: make FastCurieMap a class with a method to do this lookup\n  const partialMatches = [];\n  let iriMap = activeCtx.fastCurieMap;\n  // check for partial matches of against `iri`, which means look until\n  // iri.length - 1, not full length\n  const maxPartialLength = iri.length - 1;\n  for(let i = 0; i < maxPartialLength && iri[i] in iriMap; ++i) {\n    iriMap = iriMap[iri[i]];\n    if('' in iriMap) {\n      partialMatches.push(iriMap[''][0]);\n    }\n  }\n  // check partial matches in reverse order to prefer longest ones first\n  for(let i = partialMatches.length - 1; i >= 0; --i) {\n    const entry = partialMatches[i];\n    const terms = entry.terms;\n    for(const term of terms) {\n      // a CURIE is usable if:\n      // 1. it has no mapping, OR\n      // 2. value is null, which means we're not compacting an @value, AND\n      //   the mapping matches the IRI\n      const curie = term + ':' + iri.substr(entry.iri.length);\n      const isUsableCurie = (activeCtx.mappings.get(term)._prefix &&\n        (!activeCtx.mappings.has(curie) ||\n        (value === null && activeCtx.mappings.get(curie)['@id'] === iri)));\n\n      // select curie if it is shorter or the same length but lexicographically\n      // less than the current choice\n      if(isUsableCurie && (choice === null ||\n        _compareShortestLeast(curie, choice) < 0)) {\n        choice = curie;\n      }\n    }\n  }\n\n  // return chosen curie\n  if(choice !== null) {\n    return choice;\n  }\n\n  // If iri could be confused with a compact IRI using a term in this context,\n  // signal an error\n  for(const [term, td] of activeCtx.mappings) {\n    if(td && td._prefix && iri.startsWith(term + ':')) {\n      throw new JsonLdError(\n        `Absolute IRI \"${iri}\" confused with prefix \"${term}\".`,\n        'jsonld.SyntaxError',\n        {code: 'IRI confused with prefix', context: activeCtx});\n    }\n  }\n\n  // compact IRI relative to base\n  if(!relativeTo.vocab) {\n    if('@base' in activeCtx) {\n      if(!activeCtx['@base']) {\n        // The None case preserves rval as potentially relative\n        return iri;\n      } else {\n        const _iri = _removeBase(_prependBase(base, activeCtx['@base']), iri);\n        return REGEX_KEYWORD.test(_iri) ? `./${_iri}` : _iri;\n      }\n    } else {\n      return _removeBase(base, iri);\n    }\n  }\n\n  // return IRI as is\n  return iri;\n};\n\n/**\n * Performs value compaction on an object with '@value' or '@id' as the only\n * property.\n *\n * @param activeCtx the active context.\n * @param activeProperty the active property that points to the value.\n * @param value the value to compact.\n * @param {Object} [options] - processing options.\n *\n * @return the compaction result.\n */\napi.compactValue = ({activeCtx, activeProperty, value, options}) => {\n  // value is a @value\n  if(_isValue(value)) {\n    // get context rules\n    const type = _getContextValue(activeCtx, activeProperty, '@type');\n    const language = _getContextValue(activeCtx, activeProperty, '@language');\n    const direction = _getContextValue(activeCtx, activeProperty, '@direction');\n    const container =\n      _getContextValue(activeCtx, activeProperty, '@container') || [];\n\n    // whether or not the value has an @index that must be preserved\n    const preserveIndex = '@index' in value && !container.includes('@index');\n\n    // if there's no @index to preserve ...\n    if(!preserveIndex && type !== '@none') {\n      // matching @type or @language specified in context, compact value\n      if(value['@type'] === type) {\n        return value['@value'];\n      }\n      if('@language' in value && value['@language'] === language &&\n         '@direction' in value && value['@direction'] === direction) {\n        return value['@value'];\n      }\n      if('@language' in value && value['@language'] === language) {\n        return value['@value'];\n      }\n      if('@direction' in value && value['@direction'] === direction) {\n        return value['@value'];\n      }\n    }\n\n    // return just the value of @value if all are true:\n    // 1. @value is the only key or @index isn't being preserved\n    // 2. there is no default language or @value is not a string or\n    //   the key has a mapping with a null @language\n    const keyCount = Object.keys(value).length;\n    const isValueOnlyKey = (keyCount === 1 ||\n      (keyCount === 2 && '@index' in value && !preserveIndex));\n    const hasDefaultLanguage = ('@language' in activeCtx);\n    const isValueString = _isString(value['@value']);\n    const hasNullMapping = (activeCtx.mappings.has(activeProperty) &&\n      activeCtx.mappings.get(activeProperty)['@language'] === null);\n    if(isValueOnlyKey &&\n      type !== '@none' &&\n      (!hasDefaultLanguage || !isValueString || hasNullMapping)) {\n      return value['@value'];\n    }\n\n    const rval = {};\n\n    // preserve @index\n    if(preserveIndex) {\n      rval[api.compactIri({\n        activeCtx,\n        iri: '@index',\n        relativeTo: {vocab: true}\n      })] = value['@index'];\n    }\n\n    if('@type' in value) {\n      // compact @type IRI\n      rval[api.compactIri({\n        activeCtx,\n        iri: '@type',\n        relativeTo: {vocab: true}\n      })] = api.compactIri(\n        {activeCtx, iri: value['@type'], relativeTo: {vocab: true}});\n    } else if('@language' in value) {\n      // alias @language\n      rval[api.compactIri({\n        activeCtx,\n        iri: '@language',\n        relativeTo: {vocab: true}\n      })] = value['@language'];\n    }\n\n    if('@direction' in value) {\n      // alias @direction\n      rval[api.compactIri({\n        activeCtx,\n        iri: '@direction',\n        relativeTo: {vocab: true}\n      })] = value['@direction'];\n    }\n\n    // alias @value\n    rval[api.compactIri({\n      activeCtx,\n      iri: '@value',\n      relativeTo: {vocab: true}\n    })] = value['@value'];\n\n    return rval;\n  }\n\n  // value is a subject reference\n  const expandedProperty = _expandIri(activeCtx, activeProperty, {vocab: true},\n    options);\n  const type = _getContextValue(activeCtx, activeProperty, '@type');\n  const compacted = api.compactIri({\n    activeCtx,\n    iri: value['@id'],\n    relativeTo: {vocab: type === '@vocab'},\n    base: options.base});\n\n  // compact to scalar\n  if(type === '@id' || type === '@vocab' || expandedProperty === '@graph') {\n    return compacted;\n  }\n\n  return {\n    [api.compactIri({\n      activeCtx,\n      iri: '@id',\n      relativeTo: {vocab: true}\n    })]: compacted\n  };\n};\n\n/**\n * Picks the preferred compaction term from the given inverse context entry.\n *\n * @param activeCtx the active context.\n * @param iri the IRI to pick the term for.\n * @param value the value to pick the term for.\n * @param containers the preferred containers.\n * @param typeOrLanguage either '@type' or '@language'.\n * @param typeOrLanguageValue the preferred value for '@type' or '@language'.\n *\n * @return the preferred term.\n */\nfunction _selectTerm(\n  activeCtx, iri, value, containers, typeOrLanguage, typeOrLanguageValue) {\n  if(typeOrLanguageValue === null) {\n    typeOrLanguageValue = '@null';\n  }\n\n  // preferences for the value of @type or @language\n  const prefs = [];\n\n  // determine prefs for @id based on whether or not value compacts to a term\n  if((typeOrLanguageValue === '@id' || typeOrLanguageValue === '@reverse') &&\n    _isObject(value) && '@id' in value) {\n    // prefer @reverse first\n    if(typeOrLanguageValue === '@reverse') {\n      prefs.push('@reverse');\n    }\n    // try to compact value to a term\n    const term = api.compactIri(\n      {activeCtx, iri: value['@id'], relativeTo: {vocab: true}});\n    if(activeCtx.mappings.has(term) &&\n      activeCtx.mappings.get(term) &&\n      activeCtx.mappings.get(term)['@id'] === value['@id']) {\n      // prefer @vocab\n      prefs.push.apply(prefs, ['@vocab', '@id']);\n    } else {\n      // prefer @id\n      prefs.push.apply(prefs, ['@id', '@vocab']);\n    }\n  } else {\n    prefs.push(typeOrLanguageValue);\n\n    // consider direction only\n    const langDir = prefs.find(el => el.includes('_'));\n    if(langDir) {\n      // consider _dir portion\n      prefs.push(langDir.replace(/^[^_]+_/, '_'));\n    }\n  }\n  prefs.push('@none');\n\n  const containerMap = activeCtx.inverse[iri];\n  for(const container of containers) {\n    // if container not available in the map, continue\n    if(!(container in containerMap)) {\n      continue;\n    }\n\n    const typeOrLanguageValueMap = containerMap[container][typeOrLanguage];\n    for(const pref of prefs) {\n      // if type/language option not available in the map, continue\n      if(!(pref in typeOrLanguageValueMap)) {\n        continue;\n      }\n\n      // select term\n      return typeOrLanguageValueMap[pref];\n    }\n  }\n\n  return null;\n}\n\n/**\n * The value of `@nest` in the term definition must either be `@nest`, or a term\n * which resolves to `@nest`.\n *\n * @param activeCtx the active context.\n * @param nestProperty a term in the active context or `@nest`.\n * @param {Object} [options] - processing options.\n */\nfunction _checkNestProperty(activeCtx, nestProperty, options) {\n  if(_expandIri(activeCtx, nestProperty, {vocab: true}, options) !== '@nest') {\n    throw new JsonLdError(\n      'JSON-LD compact error; nested property must have an @nest value ' +\n      'resolving to @nest.',\n      'jsonld.SyntaxError', {code: 'invalid @nest value'});\n  }\n}\n","/*\n * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst RDF = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#';\nconst XSD = 'http://www.w3.org/2001/XMLSchema#';\n\nmodule.exports = {\n  // TODO: Deprecated and will be removed later. Use LINK_HEADER_CONTEXT.\n  LINK_HEADER_REL: 'http://www.w3.org/ns/json-ld#context',\n\n  LINK_HEADER_CONTEXT: 'http://www.w3.org/ns/json-ld#context',\n\n  RDF,\n  RDF_LIST: RDF + 'List',\n  RDF_FIRST: RDF + 'first',\n  RDF_REST: RDF + 'rest',\n  RDF_NIL: RDF + 'nil',\n  RDF_TYPE: RDF + 'type',\n  RDF_PLAIN_LITERAL: RDF + 'PlainLiteral',\n  RDF_XML_LITERAL: RDF + 'XMLLiteral',\n  RDF_JSON_LITERAL: RDF + 'JSON',\n  RDF_OBJECT: RDF + 'object',\n  RDF_LANGSTRING: RDF + 'langString',\n\n  XSD,\n  XSD_BOOLEAN: XSD + 'boolean',\n  XSD_DOUBLE: XSD + 'double',\n  XSD_INTEGER: XSD + 'integer',\n  XSD_STRING: XSD + 'string',\n};\n","/*\n * Copyright (c) 2017-2019 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst util = require('./util');\nconst JsonLdError = require('./JsonLdError');\n\nconst {\n  isArray: _isArray,\n  isObject: _isObject,\n  isString: _isString,\n  isUndefined: _isUndefined\n} = require('./types');\n\nconst {\n  isAbsolute: _isAbsoluteIri,\n  isRelative: _isRelativeIri,\n  prependBase\n} = require('./url');\n\nconst {\n  handleEvent: _handleEvent\n} = require('./events');\n\nconst {\n  REGEX_BCP47,\n  REGEX_KEYWORD,\n  asArray: _asArray,\n  compareShortestLeast: _compareShortestLeast\n} = require('./util');\n\nconst INITIAL_CONTEXT_CACHE = new Map();\nconst INITIAL_CONTEXT_CACHE_MAX_SIZE = 10000;\n\nconst api = {};\nmodule.exports = api;\n\n/**\n * Processes a local context and returns a new active context.\n *\n * @param activeCtx the current active context.\n * @param localCtx the local context to process.\n * @param options the context processing options.\n * @param propagate `true` if `false`, retains any previously defined term,\n *   which can be rolled back when the descending into a new node object.\n * @param overrideProtected `false` allows protected terms to be modified.\n *\n * @return a Promise that resolves to the new active context.\n */\napi.process = async ({\n  activeCtx, localCtx, options,\n  propagate = true,\n  overrideProtected = false,\n  cycles = new Set()\n}) => {\n  // normalize local context to an array of @context objects\n  if(_isObject(localCtx) && '@context' in localCtx &&\n    _isArray(localCtx['@context'])) {\n    localCtx = localCtx['@context'];\n  }\n  const ctxs = _asArray(localCtx);\n\n  // no contexts in array, return current active context w/o changes\n  if(ctxs.length === 0) {\n    return activeCtx;\n  }\n\n  // event handler for capturing events to replay when using a cached context\n  const events = [];\n  const eventCaptureHandler = [\n    ({event, next}) => {\n      events.push(event);\n      next();\n    }\n  ];\n  // chain to original handler\n  if(options.eventHandler) {\n    eventCaptureHandler.push(options.eventHandler);\n  }\n  // store original options to use when replaying events\n  const originalOptions = options;\n  // shallow clone options with event capture handler\n  options = {...options, eventHandler: eventCaptureHandler};\n\n  // resolve contexts\n  const resolved = await options.contextResolver.resolve({\n    activeCtx,\n    context: localCtx,\n    documentLoader: options.documentLoader,\n    base: options.base\n  });\n\n  // override propagate if first resolved context has `@propagate`\n  if(_isObject(resolved[0].document) &&\n    typeof resolved[0].document['@propagate'] === 'boolean') {\n    // retrieve early, error checking done later\n    propagate = resolved[0].document['@propagate'];\n  }\n\n  // process each context in order, update active context\n  // on each iteration to ensure proper caching\n  let rval = activeCtx;\n\n  // track the previous context\n  // if not propagating, make sure rval has a previous context\n  if(!propagate && !rval.previousContext) {\n    // clone `rval` context before updating\n    rval = rval.clone();\n    rval.previousContext = activeCtx;\n  }\n\n  for(const resolvedContext of resolved) {\n    let {document: ctx} = resolvedContext;\n\n    // update active context to one computed from last iteration\n    activeCtx = rval;\n\n    // reset to initial context\n    if(ctx === null) {\n      // We can't nullify if there are protected terms and we're\n      // not allowing overrides (e.g. processing a property term scoped context)\n      if(!overrideProtected && Object.keys(activeCtx.protected).length !== 0) {\n        throw new JsonLdError(\n          'Tried to nullify a context with protected terms outside of ' +\n          'a term definition.',\n          'jsonld.SyntaxError',\n          {code: 'invalid context nullification'});\n      }\n      rval = activeCtx = api.getInitialContext(options).clone();\n      continue;\n    }\n\n    // get processed context from cache if available\n    const processed = resolvedContext.getProcessed(activeCtx);\n    if(processed) {\n      if(originalOptions.eventHandler) {\n        // replay events with original non-capturing options\n        for(const event of processed.events) {\n          _handleEvent({event, options: originalOptions});\n        }\n      }\n\n      rval = activeCtx = processed.context;\n      continue;\n    }\n\n    // dereference @context key if present\n    if(_isObject(ctx) && '@context' in ctx) {\n      ctx = ctx['@context'];\n    }\n\n    // context must be an object by now, all URLs retrieved before this call\n    if(!_isObject(ctx)) {\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; @context must be an object.',\n        'jsonld.SyntaxError', {code: 'invalid local context', context: ctx});\n    }\n\n    // TODO: there is likely a `previousContext` cloning optimization that\n    // could be applied here (no need to copy it under certain conditions)\n\n    // clone context before updating it\n    rval = rval.clone();\n\n    // define context mappings for keys in local context\n    const defined = new Map();\n\n    // handle @version\n    if('@version' in ctx) {\n      if(ctx['@version'] !== 1.1) {\n        throw new JsonLdError(\n          'Unsupported JSON-LD version: ' + ctx['@version'],\n          'jsonld.UnsupportedVersion',\n          {code: 'invalid @version value', context: ctx});\n      }\n      if(activeCtx.processingMode &&\n        activeCtx.processingMode === 'json-ld-1.0') {\n        throw new JsonLdError(\n          '@version: ' + ctx['@version'] + ' not compatible with ' +\n          activeCtx.processingMode,\n          'jsonld.ProcessingModeConflict',\n          {code: 'processing mode conflict', context: ctx});\n      }\n      rval.processingMode = 'json-ld-1.1';\n      rval['@version'] = ctx['@version'];\n      defined.set('@version', true);\n    }\n\n    // if not set explicitly, set processingMode to \"json-ld-1.1\"\n    rval.processingMode =\n      rval.processingMode || activeCtx.processingMode;\n\n    // handle @base\n    if('@base' in ctx) {\n      let base = ctx['@base'];\n\n      if(base === null || _isAbsoluteIri(base)) {\n        // no action\n      } else if(_isRelativeIri(base)) {\n        base = prependBase(rval['@base'], base);\n      } else {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; the value of \"@base\" in a ' +\n          '@context must be an absolute IRI, a relative IRI, or null.',\n          'jsonld.SyntaxError', {code: 'invalid base IRI', context: ctx});\n      }\n\n      rval['@base'] = base;\n      defined.set('@base', true);\n    }\n\n    // handle @vocab\n    if('@vocab' in ctx) {\n      const value = ctx['@vocab'];\n      if(value === null) {\n        delete rval['@vocab'];\n      } else if(!_isString(value)) {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; the value of \"@vocab\" in a ' +\n          '@context must be a string or null.',\n          'jsonld.SyntaxError', {code: 'invalid vocab mapping', context: ctx});\n      } else if(!_isAbsoluteIri(value) && api.processingMode(rval, 1.0)) {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; the value of \"@vocab\" in a ' +\n          '@context must be an absolute IRI.',\n          'jsonld.SyntaxError', {code: 'invalid vocab mapping', context: ctx});\n      } else {\n        const vocab = _expandIri(rval, value, {vocab: true, base: true},\n          undefined, undefined, options);\n        if(!_isAbsoluteIri(vocab)) {\n          if(options.eventHandler) {\n            _handleEvent({\n              event: {\n                type: ['JsonLdEvent'],\n                code: 'relative @vocab reference',\n                level: 'warning',\n                message: 'Relative @vocab reference found.',\n                details: {\n                  vocab\n                }\n              },\n              options\n            });\n          }\n        }\n        rval['@vocab'] = vocab;\n      }\n      defined.set('@vocab', true);\n    }\n\n    // handle @language\n    if('@language' in ctx) {\n      const value = ctx['@language'];\n      if(value === null) {\n        delete rval['@language'];\n      } else if(!_isString(value)) {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; the value of \"@language\" in a ' +\n          '@context must be a string or null.',\n          'jsonld.SyntaxError',\n          {code: 'invalid default language', context: ctx});\n      } else {\n        if(!value.match(REGEX_BCP47)) {\n          if(options.eventHandler) {\n            _handleEvent({\n              event: {\n                type: ['JsonLdEvent'],\n                code: 'invalid @language value',\n                level: 'warning',\n                message: '@language value must be valid BCP47.',\n                details: {\n                  language: value\n                }\n              },\n              options\n            });\n          }\n        }\n        rval['@language'] = value.toLowerCase();\n      }\n      defined.set('@language', true);\n    }\n\n    // handle @direction\n    if('@direction' in ctx) {\n      const value = ctx['@direction'];\n      if(activeCtx.processingMode === 'json-ld-1.0') {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; @direction not compatible with ' +\n          activeCtx.processingMode,\n          'jsonld.SyntaxError',\n          {code: 'invalid context member', context: ctx});\n      }\n      if(value === null) {\n        delete rval['@direction'];\n      } else if(value !== 'ltr' && value !== 'rtl') {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; the value of \"@direction\" in a ' +\n          '@context must be null, \"ltr\", or \"rtl\".',\n          'jsonld.SyntaxError',\n          {code: 'invalid base direction', context: ctx});\n      } else {\n        rval['@direction'] = value;\n      }\n      defined.set('@direction', true);\n    }\n\n    // handle @propagate\n    // note: we've already extracted it, here we just do error checking\n    if('@propagate' in ctx) {\n      const value = ctx['@propagate'];\n      if(activeCtx.processingMode === 'json-ld-1.0') {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; @propagate not compatible with ' +\n          activeCtx.processingMode,\n          'jsonld.SyntaxError',\n          {code: 'invalid context entry', context: ctx});\n      }\n      if(typeof value !== 'boolean') {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; @propagate value must be a boolean.',\n          'jsonld.SyntaxError',\n          {code: 'invalid @propagate value', context: localCtx});\n      }\n      defined.set('@propagate', true);\n    }\n\n    // handle @import\n    if('@import' in ctx) {\n      const value = ctx['@import'];\n      if(activeCtx.processingMode === 'json-ld-1.0') {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; @import not compatible with ' +\n          activeCtx.processingMode,\n          'jsonld.SyntaxError',\n          {code: 'invalid context entry', context: ctx});\n      }\n      if(!_isString(value)) {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; @import must be a string.',\n          'jsonld.SyntaxError',\n          {code: 'invalid @import value', context: localCtx});\n      }\n\n      // resolve contexts\n      const resolvedImport = await options.contextResolver.resolve({\n        activeCtx,\n        context: value,\n        documentLoader: options.documentLoader,\n        base: options.base\n      });\n      if(resolvedImport.length !== 1) {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; @import must reference a single context.',\n          'jsonld.SyntaxError',\n          {code: 'invalid remote context', context: localCtx});\n      }\n      const processedImport = resolvedImport[0].getProcessed(activeCtx);\n      if(processedImport) {\n        // Note: if the same context were used in this active context\n        // as a reference context, then processed_input might not\n        // be a dict.\n        ctx = processedImport;\n      } else {\n        const importCtx = resolvedImport[0].document;\n        if('@import' in importCtx) {\n          throw new JsonLdError(\n            'Invalid JSON-LD syntax: ' +\n            'imported context must not include @import.',\n            'jsonld.SyntaxError',\n            {code: 'invalid context entry', context: localCtx});\n        }\n\n        // merge ctx into importCtx and replace rval with the result\n        for(const key in importCtx) {\n          if(!ctx.hasOwnProperty(key)) {\n            ctx[key] = importCtx[key];\n          }\n        }\n\n        // Note: this could potenially conflict if the import\n        // were used in the same active context as a referenced\n        // context and an import. In this case, we\n        // could override the cached result, but seems unlikely.\n        resolvedImport[0].setProcessed(activeCtx, ctx);\n      }\n\n      defined.set('@import', true);\n    }\n\n    // handle @protected; determine whether this sub-context is declaring\n    // all its terms to be \"protected\" (exceptions can be made on a\n    // per-definition basis)\n    defined.set('@protected', ctx['@protected'] || false);\n\n    // process all other keys\n    for(const key in ctx) {\n      api.createTermDefinition({\n        activeCtx: rval,\n        localCtx: ctx,\n        term: key,\n        defined,\n        options,\n        overrideProtected\n      });\n\n      if(_isObject(ctx[key]) && '@context' in ctx[key]) {\n        const keyCtx = ctx[key]['@context'];\n        let process = true;\n        if(_isString(keyCtx)) {\n          const url = prependBase(options.base, keyCtx);\n          // track processed contexts to avoid scoped context recursion\n          if(cycles.has(url)) {\n            process = false;\n          } else {\n            cycles.add(url);\n          }\n        }\n        // parse context to validate\n        if(process) {\n          try {\n            await api.process({\n              activeCtx: rval.clone(),\n              localCtx: ctx[key]['@context'],\n              overrideProtected: true,\n              options,\n              cycles\n            });\n          } catch(e) {\n            throw new JsonLdError(\n              'Invalid JSON-LD syntax; invalid scoped context.',\n              'jsonld.SyntaxError',\n              {\n                code: 'invalid scoped context',\n                context: ctx[key]['@context'],\n                term: key\n              });\n          }\n        }\n      }\n    }\n\n    // cache processed result\n    resolvedContext.setProcessed(activeCtx, {\n      context: rval,\n      events\n    });\n  }\n\n  return rval;\n};\n\n/**\n * Creates a term definition during context processing.\n *\n * @param activeCtx the current active context.\n * @param localCtx the local context being processed.\n * @param term the term in the local context to define the mapping for.\n * @param defined a map of defining/defined keys to detect cycles and prevent\n *          double definitions.\n * @param {Object} [options] - creation options.\n * @param overrideProtected `false` allows protected terms to be modified.\n */\napi.createTermDefinition = ({\n  activeCtx,\n  localCtx,\n  term,\n  defined,\n  options,\n  overrideProtected = false,\n}) => {\n  if(defined.has(term)) {\n    // term already defined\n    if(defined.get(term)) {\n      return;\n    }\n    // cycle detected\n    throw new JsonLdError(\n      'Cyclical context definition detected.',\n      'jsonld.CyclicalContext',\n      {code: 'cyclic IRI mapping', context: localCtx, term});\n  }\n\n  // now defining term\n  defined.set(term, false);\n\n  // get context term value\n  let value;\n  if(localCtx.hasOwnProperty(term)) {\n    value = localCtx[term];\n  }\n\n  if(term === '@type' &&\n     _isObject(value) &&\n     (value['@container'] || '@set') === '@set' &&\n     api.processingMode(activeCtx, 1.1)) {\n\n    const validKeys = ['@container', '@id', '@protected'];\n    const keys = Object.keys(value);\n    if(keys.length === 0 || keys.some(k => !validKeys.includes(k))) {\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; keywords cannot be overridden.',\n        'jsonld.SyntaxError',\n        {code: 'keyword redefinition', context: localCtx, term});\n    }\n  } else if(api.isKeyword(term)) {\n    throw new JsonLdError(\n      'Invalid JSON-LD syntax; keywords cannot be overridden.',\n      'jsonld.SyntaxError',\n      {code: 'keyword redefinition', context: localCtx, term});\n  } else if(term.match(REGEX_KEYWORD)) {\n    if(options.eventHandler) {\n      _handleEvent({\n        event: {\n          type: ['JsonLdEvent'],\n          code: 'reserved term',\n          level: 'warning',\n          message:\n            'Terms beginning with \"@\" are ' +\n            'reserved for future use and dropped.',\n          details: {\n            term\n          }\n        },\n        options\n      });\n    }\n    return;\n  } else if(term === '') {\n    throw new JsonLdError(\n      'Invalid JSON-LD syntax; a term cannot be an empty string.',\n      'jsonld.SyntaxError',\n      {code: 'invalid term definition', context: localCtx});\n  }\n\n  // keep reference to previous mapping for potential `@protected` check\n  const previousMapping = activeCtx.mappings.get(term);\n\n  // remove old mapping\n  if(activeCtx.mappings.has(term)) {\n    activeCtx.mappings.delete(term);\n  }\n\n  // convert short-hand value to object w/@id\n  let simpleTerm = false;\n  if(_isString(value) || value === null) {\n    simpleTerm = true;\n    value = {'@id': value};\n  }\n\n  if(!_isObject(value)) {\n    throw new JsonLdError(\n      'Invalid JSON-LD syntax; @context term values must be ' +\n      'strings or objects.',\n      'jsonld.SyntaxError',\n      {code: 'invalid term definition', context: localCtx});\n  }\n\n  // create new mapping\n  const mapping = {};\n  activeCtx.mappings.set(term, mapping);\n  mapping.reverse = false;\n\n  // make sure term definition only has expected keywords\n  const validKeys = ['@container', '@id', '@language', '@reverse', '@type'];\n\n  // JSON-LD 1.1 support\n  if(api.processingMode(activeCtx, 1.1)) {\n    validKeys.push(\n      '@context', '@direction', '@index', '@nest', '@prefix', '@protected');\n  }\n\n  for(const kw in value) {\n    if(!validKeys.includes(kw)) {\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; a term definition must not contain ' + kw,\n        'jsonld.SyntaxError',\n        {code: 'invalid term definition', context: localCtx});\n    }\n  }\n\n  // always compute whether term has a colon as an optimization for\n  // _compactIri\n  const colon = term.indexOf(':');\n  mapping._termHasColon = (colon > 0);\n\n  if('@reverse' in value) {\n    if('@id' in value) {\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; a @reverse term definition must not ' +\n        'contain @id.', 'jsonld.SyntaxError',\n        {code: 'invalid reverse property', context: localCtx});\n    }\n    if('@nest' in value) {\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; a @reverse term definition must not ' +\n        'contain @nest.', 'jsonld.SyntaxError',\n        {code: 'invalid reverse property', context: localCtx});\n    }\n    const reverse = value['@reverse'];\n    if(!_isString(reverse)) {\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; a @context @reverse value must be a string.',\n        'jsonld.SyntaxError', {code: 'invalid IRI mapping', context: localCtx});\n    }\n\n    if(reverse.match(REGEX_KEYWORD)) {\n      if(options.eventHandler) {\n        _handleEvent({\n          event: {\n            type: ['JsonLdEvent'],\n            code: 'reserved @reverse value',\n            level: 'warning',\n            message:\n              '@reverse values beginning with \"@\" are ' +\n              'reserved for future use and dropped.',\n            details: {\n              reverse\n            }\n          },\n          options\n        });\n      }\n      if(previousMapping) {\n        activeCtx.mappings.set(term, previousMapping);\n      } else {\n        activeCtx.mappings.delete(term);\n      }\n      return;\n    }\n\n    // expand and add @id mapping\n    const id = _expandIri(\n      activeCtx, reverse, {vocab: true, base: false}, localCtx, defined,\n      options);\n    if(!_isAbsoluteIri(id)) {\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; a @context @reverse value must be an ' +\n        'absolute IRI or a blank node identifier.',\n        'jsonld.SyntaxError', {code: 'invalid IRI mapping', context: localCtx});\n    }\n\n    mapping['@id'] = id;\n    mapping.reverse = true;\n  } else if('@id' in value) {\n    let id = value['@id'];\n    if(id && !_isString(id)) {\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; a @context @id value must be an array ' +\n        'of strings or a string.',\n        'jsonld.SyntaxError', {code: 'invalid IRI mapping', context: localCtx});\n    }\n    if(id === null) {\n      // reserve a null term, which may be protected\n      mapping['@id'] = null;\n    } else if(!api.isKeyword(id) && id.match(REGEX_KEYWORD)) {\n      if(options.eventHandler) {\n        _handleEvent({\n          event: {\n            type: ['JsonLdEvent'],\n            code: 'reserved @id value',\n            level: 'warning',\n            message:\n              '@id values beginning with \"@\" are ' +\n              'reserved for future use and dropped.',\n            details: {\n              id\n            }\n          },\n          options\n        });\n      }\n      if(previousMapping) {\n        activeCtx.mappings.set(term, previousMapping);\n      } else {\n        activeCtx.mappings.delete(term);\n      }\n      return;\n    } else if(id !== term) {\n      // expand and add @id mapping\n      id = _expandIri(\n        activeCtx, id, {vocab: true, base: false}, localCtx, defined, options);\n      if(!_isAbsoluteIri(id) && !api.isKeyword(id)) {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; a @context @id value must be an ' +\n          'absolute IRI, a blank node identifier, or a keyword.',\n          'jsonld.SyntaxError',\n          {code: 'invalid IRI mapping', context: localCtx});\n      }\n\n      // if term has the form of an IRI it must map the same\n      if(term.match(/(?::[^:])|\\//)) {\n        const termDefined = new Map(defined).set(term, true);\n        const termIri = _expandIri(\n          activeCtx, term, {vocab: true, base: false},\n          localCtx, termDefined, options);\n        if(termIri !== id) {\n          throw new JsonLdError(\n            'Invalid JSON-LD syntax; term in form of IRI must ' +\n            'expand to definition.',\n            'jsonld.SyntaxError',\n            {code: 'invalid IRI mapping', context: localCtx});\n        }\n      }\n\n      mapping['@id'] = id;\n      // indicate if this term may be used as a compact IRI prefix\n      mapping._prefix = (simpleTerm &&\n        !mapping._termHasColon &&\n        id.match(/[:\\/\\?#\\[\\]@]$/) !== null);\n    }\n  }\n\n  if(!('@id' in mapping)) {\n    // see if the term has a prefix\n    if(mapping._termHasColon) {\n      const prefix = term.substr(0, colon);\n      if(localCtx.hasOwnProperty(prefix)) {\n        // define parent prefix\n        api.createTermDefinition({\n          activeCtx, localCtx, term: prefix, defined, options\n        });\n      }\n\n      if(activeCtx.mappings.has(prefix)) {\n        // set @id based on prefix parent\n        const suffix = term.substr(colon + 1);\n        mapping['@id'] = activeCtx.mappings.get(prefix)['@id'] + suffix;\n      } else {\n        // term is an absolute IRI\n        mapping['@id'] = term;\n      }\n    } else if(term === '@type') {\n      // Special case, were we've previously determined that container is @set\n      mapping['@id'] = term;\n    } else {\n      // non-IRIs *must* define @ids if @vocab is not available\n      if(!('@vocab' in activeCtx)) {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; @context terms must define an @id.',\n          'jsonld.SyntaxError',\n          {code: 'invalid IRI mapping', context: localCtx, term});\n      }\n      // prepend vocab to term\n      mapping['@id'] = activeCtx['@vocab'] + term;\n    }\n  }\n\n  // Handle term protection\n  if(value['@protected'] === true ||\n    (defined.get('@protected') === true && value['@protected'] !== false)) {\n    activeCtx.protected[term] = true;\n    mapping.protected = true;\n  }\n\n  // IRI mapping now defined\n  defined.set(term, true);\n\n  if('@type' in value) {\n    let type = value['@type'];\n    if(!_isString(type)) {\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; an @context @type value must be a string.',\n        'jsonld.SyntaxError',\n        {code: 'invalid type mapping', context: localCtx});\n    }\n\n    if((type === '@json' || type === '@none')) {\n      if(api.processingMode(activeCtx, 1.0)) {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; an @context @type value must not be ' +\n          `\"${type}\" in JSON-LD 1.0 mode.`,\n          'jsonld.SyntaxError',\n          {code: 'invalid type mapping', context: localCtx});\n      }\n    } else if(type !== '@id' && type !== '@vocab') {\n      // expand @type to full IRI\n      type = _expandIri(\n        activeCtx, type, {vocab: true, base: false}, localCtx, defined,\n        options);\n      if(!_isAbsoluteIri(type)) {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; an @context @type value must be an ' +\n          'absolute IRI.',\n          'jsonld.SyntaxError',\n          {code: 'invalid type mapping', context: localCtx});\n      }\n      if(type.indexOf('_:') === 0) {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; an @context @type value must be an IRI, ' +\n          'not a blank node identifier.',\n          'jsonld.SyntaxError',\n          {code: 'invalid type mapping', context: localCtx});\n      }\n    }\n\n    // add @type to mapping\n    mapping['@type'] = type;\n  }\n\n  if('@container' in value) {\n    // normalize container to an array form\n    const container = _isString(value['@container']) ?\n      [value['@container']] : (value['@container'] || []);\n    const validContainers = ['@list', '@set', '@index', '@language'];\n    let isValid = true;\n    const hasSet = container.includes('@set');\n\n    // JSON-LD 1.1 support\n    if(api.processingMode(activeCtx, 1.1)) {\n      validContainers.push('@graph', '@id', '@type');\n\n      // check container length\n      if(container.includes('@list')) {\n        if(container.length !== 1) {\n          throw new JsonLdError(\n            'Invalid JSON-LD syntax; @context @container with @list must ' +\n            'have no other values',\n            'jsonld.SyntaxError',\n            {code: 'invalid container mapping', context: localCtx});\n        }\n      } else if(container.includes('@graph')) {\n        if(container.some(key =>\n          key !== '@graph' && key !== '@id' && key !== '@index' &&\n          key !== '@set')) {\n          throw new JsonLdError(\n            'Invalid JSON-LD syntax; @context @container with @graph must ' +\n            'have no other values other than @id, @index, and @set',\n            'jsonld.SyntaxError',\n            {code: 'invalid container mapping', context: localCtx});\n        }\n      } else {\n        // otherwise, container may also include @set\n        isValid &= container.length <= (hasSet ? 2 : 1);\n      }\n\n      if(container.includes('@type')) {\n        // If mapping does not have an @type,\n        // set it to @id\n        mapping['@type'] = mapping['@type'] || '@id';\n\n        // type mapping must be either @id or @vocab\n        if(!['@id', '@vocab'].includes(mapping['@type'])) {\n          throw new JsonLdError(\n            'Invalid JSON-LD syntax; container: @type requires @type to be ' +\n            '@id or @vocab.',\n            'jsonld.SyntaxError',\n            {code: 'invalid type mapping', context: localCtx});\n        }\n      }\n    } else {\n      // in JSON-LD 1.0, container must not be an array (it must be a string,\n      // which is one of the validContainers)\n      isValid &= !_isArray(value['@container']);\n\n      // check container length\n      isValid &= container.length <= 1;\n    }\n\n    // check against valid containers\n    isValid &= container.every(c => validContainers.includes(c));\n\n    // @set not allowed with @list\n    isValid &= !(hasSet && container.includes('@list'));\n\n    if(!isValid) {\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; @context @container value must be ' +\n        'one of the following: ' + validContainers.join(', '),\n        'jsonld.SyntaxError',\n        {code: 'invalid container mapping', context: localCtx});\n    }\n\n    if(mapping.reverse &&\n      !container.every(c => ['@index', '@set'].includes(c))) {\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; @context @container value for a @reverse ' +\n        'type definition must be @index or @set.', 'jsonld.SyntaxError',\n        {code: 'invalid reverse property', context: localCtx});\n    }\n\n    // add @container to mapping\n    mapping['@container'] = container;\n  }\n\n  // property indexing\n  if('@index' in value) {\n    if(!('@container' in value) || !mapping['@container'].includes('@index')) {\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; @index without @index in @container: ' +\n        `\"${value['@index']}\" on term \"${term}\".`, 'jsonld.SyntaxError',\n        {code: 'invalid term definition', context: localCtx});\n    }\n    if(!_isString(value['@index']) || value['@index'].indexOf('@') === 0) {\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; @index must expand to an IRI: ' +\n        `\"${value['@index']}\" on term \"${term}\".`, 'jsonld.SyntaxError',\n        {code: 'invalid term definition', context: localCtx});\n    }\n    mapping['@index'] = value['@index'];\n  }\n\n  // scoped contexts\n  if('@context' in value) {\n    mapping['@context'] = value['@context'];\n  }\n\n  if('@language' in value && !('@type' in value)) {\n    let language = value['@language'];\n    if(language !== null && !_isString(language)) {\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; @context @language value must be ' +\n        'a string or null.', 'jsonld.SyntaxError',\n        {code: 'invalid language mapping', context: localCtx});\n    }\n\n    // add @language to mapping\n    if(language !== null) {\n      language = language.toLowerCase();\n    }\n    mapping['@language'] = language;\n  }\n\n  // term may be used as a prefix\n  if('@prefix' in value) {\n    if(term.match(/:|\\//)) {\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; @context @prefix used on a compact IRI term',\n        'jsonld.SyntaxError',\n        {code: 'invalid term definition', context: localCtx});\n    }\n    if(api.isKeyword(mapping['@id'])) {\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; keywords may not be used as prefixes',\n        'jsonld.SyntaxError',\n        {code: 'invalid term definition', context: localCtx});\n    }\n    if(typeof value['@prefix'] === 'boolean') {\n      mapping._prefix = value['@prefix'] === true;\n    } else {\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; @context value for @prefix must be boolean',\n        'jsonld.SyntaxError',\n        {code: 'invalid @prefix value', context: localCtx});\n    }\n  }\n\n  if('@direction' in value) {\n    const direction = value['@direction'];\n    if(direction !== null && direction !== 'ltr' && direction !== 'rtl') {\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; @direction value must be ' +\n        'null, \"ltr\", or \"rtl\".',\n        'jsonld.SyntaxError',\n        {code: 'invalid base direction', context: localCtx});\n    }\n    mapping['@direction'] = direction;\n  }\n\n  if('@nest' in value) {\n    const nest = value['@nest'];\n    if(!_isString(nest) || (nest !== '@nest' && nest.indexOf('@') === 0)) {\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; @context @nest value must be ' +\n        'a string which is not a keyword other than @nest.',\n        'jsonld.SyntaxError',\n        {code: 'invalid @nest value', context: localCtx});\n    }\n    mapping['@nest'] = nest;\n  }\n\n  // disallow aliasing @context and @preserve\n  const id = mapping['@id'];\n  if(id === '@context' || id === '@preserve') {\n    throw new JsonLdError(\n      'Invalid JSON-LD syntax; @context and @preserve cannot be aliased.',\n      'jsonld.SyntaxError', {code: 'invalid keyword alias', context: localCtx});\n  }\n\n  // Check for overriding protected terms\n  if(previousMapping && previousMapping.protected && !overrideProtected) {\n    // force new term to continue to be protected and see if the mappings would\n    // be equal\n    activeCtx.protected[term] = true;\n    mapping.protected = true;\n    if(!_deepCompare(previousMapping, mapping)) {\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; tried to redefine a protected term.',\n        'jsonld.SyntaxError',\n        {code: 'protected term redefinition', context: localCtx, term});\n    }\n  }\n};\n\n/**\n * Expands a string to a full IRI. The string may be a term, a prefix, a\n * relative IRI, or an absolute IRI. The associated absolute IRI will be\n * returned.\n *\n * @param activeCtx the current active context.\n * @param value the string to expand.\n * @param relativeTo options for how to resolve relative IRIs:\n *          base: true to resolve against the base IRI, false not to.\n *          vocab: true to concatenate after @vocab, false not to.\n * @param {Object} [options] - processing options.\n *\n * @return the expanded value.\n */\napi.expandIri = (activeCtx, value, relativeTo, options) => {\n  return _expandIri(activeCtx, value, relativeTo, undefined, undefined,\n    options);\n};\n\n/**\n * Expands a string to a full IRI. The string may be a term, a prefix, a\n * relative IRI, or an absolute IRI. The associated absolute IRI will be\n * returned.\n *\n * @param activeCtx the current active context.\n * @param value the string to expand.\n * @param relativeTo options for how to resolve relative IRIs:\n *          base: true to resolve against the base IRI, false not to.\n *          vocab: true to concatenate after @vocab, false not to.\n * @param localCtx the local context being processed (only given if called\n *          during context processing).\n * @param defined a map for tracking cycles in context definitions (only given\n *          if called during context processing).\n * @param {Object} [options] - processing options.\n *\n * @return the expanded value.\n */\nfunction _expandIri(activeCtx, value, relativeTo, localCtx, defined, options) {\n  // already expanded\n  if(value === null || !_isString(value) || api.isKeyword(value)) {\n    return value;\n  }\n\n  // ignore non-keyword things that look like a keyword\n  if(value.match(REGEX_KEYWORD)) {\n    return null;\n  }\n\n  // define term dependency if not defined\n  if(localCtx && localCtx.hasOwnProperty(value) &&\n    defined.get(value) !== true) {\n    api.createTermDefinition({\n      activeCtx, localCtx, term: value, defined, options\n    });\n  }\n\n  relativeTo = relativeTo || {};\n  if(relativeTo.vocab) {\n    const mapping = activeCtx.mappings.get(value);\n\n    // value is explicitly ignored with a null mapping\n    if(mapping === null) {\n      return null;\n    }\n\n    if(_isObject(mapping) && '@id' in mapping) {\n      // value is a term\n      return mapping['@id'];\n    }\n  }\n\n  // split value into prefix:suffix\n  const colon = value.indexOf(':');\n  if(colon > 0) {\n    const prefix = value.substr(0, colon);\n    const suffix = value.substr(colon + 1);\n\n    // do not expand blank nodes (prefix of '_') or already-absolute\n    // IRIs (suffix of '//')\n    if(prefix === '_' || suffix.indexOf('//') === 0) {\n      return value;\n    }\n\n    // prefix dependency not defined, define it\n    if(localCtx && localCtx.hasOwnProperty(prefix)) {\n      api.createTermDefinition({\n        activeCtx, localCtx, term: prefix, defined, options\n      });\n    }\n\n    // use mapping if prefix is defined\n    const mapping = activeCtx.mappings.get(prefix);\n    if(mapping && mapping._prefix) {\n      return mapping['@id'] + suffix;\n    }\n\n    // already absolute IRI\n    if(_isAbsoluteIri(value)) {\n      return value;\n    }\n  }\n\n  // A flag that captures whether the iri being expanded is\n  // the value for an @type\n  //let typeExpansion = false;\n\n  //if(options !== undefined && options.typeExpansion !== undefined) {\n  //  typeExpansion = options.typeExpansion;\n  //}\n\n  if(relativeTo.vocab && '@vocab' in activeCtx) {\n    // prepend vocab\n    const prependedResult = activeCtx['@vocab'] + value;\n    // FIXME: needed? may be better as debug event.\n    /*\n    if(options && options.eventHandler) {\n      _handleEvent({\n        event: {\n          type: ['JsonLdEvent'],\n          code: 'prepending @vocab during expansion',\n          level: 'info',\n          message: 'Prepending @vocab during expansion.',\n          details: {\n            type: '@vocab',\n            vocab: activeCtx['@vocab'],\n            value,\n            result: prependedResult,\n            typeExpansion\n          }\n        },\n        options\n      });\n    }\n    */\n    // the null case preserves value as potentially relative\n    value = prependedResult;\n  } else if(relativeTo.base) {\n    // prepend base\n    let prependedResult;\n    let base;\n    if('@base' in activeCtx) {\n      if(activeCtx['@base']) {\n        base = prependBase(options.base, activeCtx['@base']);\n        prependedResult = prependBase(base, value);\n      } else {\n        base = activeCtx['@base'];\n        prependedResult = value;\n      }\n    } else {\n      base = options.base;\n      prependedResult = prependBase(options.base, value);\n    }\n    // FIXME: needed? may be better as debug event.\n    /*\n    if(options && options.eventHandler) {\n      _handleEvent({\n        event: {\n          type: ['JsonLdEvent'],\n          code: 'prepending @base during expansion',\n          level: 'info',\n          message: 'Prepending @base during expansion.',\n          details: {\n            type: '@base',\n            base,\n            value,\n            result: prependedResult,\n            typeExpansion\n          }\n        },\n        options\n      });\n    }\n    */\n    // the null case preserves value as potentially relative\n    value = prependedResult;\n  }\n\n  // FIXME: duplicate? needed? maybe just enable in a verbose debug mode\n  /*\n  if(!_isAbsoluteIri(value) && options && options.eventHandler) {\n    // emit event indicating a relative IRI was found, which can result in it\n    // being dropped when converting to other RDF representations\n    _handleEvent({\n      event: {\n        type: ['JsonLdEvent'],\n        code: 'relative IRI after expansion',\n        // FIXME: what level?\n        level: 'warning',\n        message: 'Relative IRI after expansion.',\n        details: {\n          relativeIri: value,\n          typeExpansion\n        }\n      },\n      options\n    });\n    // NOTE: relative reference events emitted at calling sites as needed\n  }\n  */\n\n  return value;\n}\n\n/**\n * Gets the initial context.\n *\n * @param options the options to use:\n *          [base] the document base IRI.\n *\n * @return the initial context.\n */\napi.getInitialContext = options => {\n  const key = JSON.stringify({processingMode: options.processingMode});\n  const cached = INITIAL_CONTEXT_CACHE.get(key);\n  if(cached) {\n    return cached;\n  }\n\n  const initialContext = {\n    processingMode: options.processingMode,\n    mappings: new Map(),\n    inverse: null,\n    getInverse: _createInverseContext,\n    clone: _cloneActiveContext,\n    revertToPreviousContext: _revertToPreviousContext,\n    protected: {}\n  };\n  // TODO: consider using LRU cache instead\n  if(INITIAL_CONTEXT_CACHE.size === INITIAL_CONTEXT_CACHE_MAX_SIZE) {\n    // clear whole cache -- assumes scenario where the cache fills means\n    // the cache isn't being used very efficiently anyway\n    INITIAL_CONTEXT_CACHE.clear();\n  }\n  INITIAL_CONTEXT_CACHE.set(key, initialContext);\n  return initialContext;\n\n  /**\n   * Generates an inverse context for use in the compaction algorithm, if\n   * not already generated for the given active context.\n   *\n   * @return the inverse context.\n   */\n  function _createInverseContext() {\n    const activeCtx = this;\n\n    // lazily create inverse\n    if(activeCtx.inverse) {\n      return activeCtx.inverse;\n    }\n    const inverse = activeCtx.inverse = {};\n\n    // variables for building fast CURIE map\n    const fastCurieMap = activeCtx.fastCurieMap = {};\n    const irisToTerms = {};\n\n    // handle default language\n    const defaultLanguage = (activeCtx['@language'] || '@none').toLowerCase();\n\n    // handle default direction\n    const defaultDirection = activeCtx['@direction'];\n\n    // create term selections for each mapping in the context, ordered by\n    // shortest and then lexicographically least\n    const mappings = activeCtx.mappings;\n    const terms = [...mappings.keys()].sort(_compareShortestLeast);\n    for(const term of terms) {\n      const mapping = mappings.get(term);\n      if(mapping === null) {\n        continue;\n      }\n\n      let container = mapping['@container'] || '@none';\n      container = [].concat(container).sort().join('');\n\n      if(mapping['@id'] === null) {\n        continue;\n      }\n      // iterate over every IRI in the mapping\n      const ids = _asArray(mapping['@id']);\n      for(const iri of ids) {\n        let entry = inverse[iri];\n        const isKeyword = api.isKeyword(iri);\n\n        if(!entry) {\n          // initialize entry\n          inverse[iri] = entry = {};\n\n          if(!isKeyword && !mapping._termHasColon) {\n            // init IRI to term map and fast CURIE prefixes\n            irisToTerms[iri] = [term];\n            const fastCurieEntry = {iri, terms: irisToTerms[iri]};\n            if(iri[0] in fastCurieMap) {\n              fastCurieMap[iri[0]].push(fastCurieEntry);\n            } else {\n              fastCurieMap[iri[0]] = [fastCurieEntry];\n            }\n          }\n        } else if(!isKeyword && !mapping._termHasColon) {\n          // add IRI to term match\n          irisToTerms[iri].push(term);\n        }\n\n        // add new entry\n        if(!entry[container]) {\n          entry[container] = {\n            '@language': {},\n            '@type': {},\n            '@any': {}\n          };\n        }\n        entry = entry[container];\n        _addPreferredTerm(term, entry['@any'], '@none');\n\n        if(mapping.reverse) {\n          // term is preferred for values using @reverse\n          _addPreferredTerm(term, entry['@type'], '@reverse');\n        } else if(mapping['@type'] === '@none') {\n          _addPreferredTerm(term, entry['@any'], '@none');\n          _addPreferredTerm(term, entry['@language'], '@none');\n          _addPreferredTerm(term, entry['@type'], '@none');\n        } else if('@type' in mapping) {\n          // term is preferred for values using specific type\n          _addPreferredTerm(term, entry['@type'], mapping['@type']);\n        } else if('@language' in mapping && '@direction' in mapping) {\n          // term is preferred for values using specific language and direction\n          const language = mapping['@language'];\n          const direction = mapping['@direction'];\n          if(language && direction) {\n            _addPreferredTerm(term, entry['@language'],\n              `${language}_${direction}`.toLowerCase());\n          } else if(language) {\n            _addPreferredTerm(term, entry['@language'], language.toLowerCase());\n          } else if(direction) {\n            _addPreferredTerm(term, entry['@language'], `_${direction}`);\n          } else {\n            _addPreferredTerm(term, entry['@language'], '@null');\n          }\n        } else if('@language' in mapping) {\n          _addPreferredTerm(term, entry['@language'],\n            (mapping['@language'] || '@null').toLowerCase());\n        } else if('@direction' in mapping) {\n          if(mapping['@direction']) {\n            _addPreferredTerm(term, entry['@language'],\n              `_${mapping['@direction']}`);\n          } else {\n            _addPreferredTerm(term, entry['@language'], '@none');\n          }\n        } else if(defaultDirection) {\n          _addPreferredTerm(term, entry['@language'], `_${defaultDirection}`);\n          _addPreferredTerm(term, entry['@language'], '@none');\n          _addPreferredTerm(term, entry['@type'], '@none');\n        } else {\n          // add entries for no type and no language\n          _addPreferredTerm(term, entry['@language'], defaultLanguage);\n          _addPreferredTerm(term, entry['@language'], '@none');\n          _addPreferredTerm(term, entry['@type'], '@none');\n        }\n      }\n    }\n\n    // build fast CURIE map\n    for(const key in fastCurieMap) {\n      _buildIriMap(fastCurieMap, key, 1);\n    }\n\n    return inverse;\n  }\n\n  /**\n   * Runs a recursive algorithm to build a lookup map for quickly finding\n   * potential CURIEs.\n   *\n   * @param iriMap the map to build.\n   * @param key the current key in the map to work on.\n   * @param idx the index into the IRI to compare.\n   */\n  function _buildIriMap(iriMap, key, idx) {\n    const entries = iriMap[key];\n    const next = iriMap[key] = {};\n\n    let iri;\n    let letter;\n    for(const entry of entries) {\n      iri = entry.iri;\n      if(idx >= iri.length) {\n        letter = '';\n      } else {\n        letter = iri[idx];\n      }\n      if(letter in next) {\n        next[letter].push(entry);\n      } else {\n        next[letter] = [entry];\n      }\n    }\n\n    for(const key in next) {\n      if(key === '') {\n        continue;\n      }\n      _buildIriMap(next, key, idx + 1);\n    }\n  }\n\n  /**\n   * Adds the term for the given entry if not already added.\n   *\n   * @param term the term to add.\n   * @param entry the inverse context typeOrLanguage entry to add to.\n   * @param typeOrLanguageValue the key in the entry to add to.\n   */\n  function _addPreferredTerm(term, entry, typeOrLanguageValue) {\n    if(!entry.hasOwnProperty(typeOrLanguageValue)) {\n      entry[typeOrLanguageValue] = term;\n    }\n  }\n\n  /**\n   * Clones an active context, creating a child active context.\n   *\n   * @return a clone (child) of the active context.\n   */\n  function _cloneActiveContext() {\n    const child = {};\n    child.mappings = util.clone(this.mappings);\n    child.clone = this.clone;\n    child.inverse = null;\n    child.getInverse = this.getInverse;\n    child.protected = util.clone(this.protected);\n    if(this.previousContext) {\n      child.previousContext = this.previousContext.clone();\n    }\n    child.revertToPreviousContext = this.revertToPreviousContext;\n    if('@base' in this) {\n      child['@base'] = this['@base'];\n    }\n    if('@language' in this) {\n      child['@language'] = this['@language'];\n    }\n    if('@vocab' in this) {\n      child['@vocab'] = this['@vocab'];\n    }\n    return child;\n  }\n\n  /**\n   * Reverts any type-scoped context in this active context to the previous\n   * context.\n   */\n  function _revertToPreviousContext() {\n    if(!this.previousContext) {\n      return this;\n    }\n    return this.previousContext.clone();\n  }\n};\n\n/**\n * Gets the value for the given active context key and type, null if none is\n * set or undefined if none is set and type is '@context'.\n *\n * @param ctx the active context.\n * @param key the context key.\n * @param [type] the type of value to get (eg: '@id', '@type'), if not\n *          specified gets the entire entry for a key, null if not found.\n *\n * @return the value, null, or undefined.\n */\napi.getContextValue = (ctx, key, type) => {\n  // invalid key\n  if(key === null) {\n    if(type === '@context') {\n      return undefined;\n    }\n    return null;\n  }\n\n  // get specific entry information\n  if(ctx.mappings.has(key)) {\n    const entry = ctx.mappings.get(key);\n\n    if(_isUndefined(type)) {\n      // return whole entry\n      return entry;\n    }\n    if(entry.hasOwnProperty(type)) {\n      // return entry value for type\n      return entry[type];\n    }\n  }\n\n  // get default language\n  if(type === '@language' && type in ctx) {\n    return ctx[type];\n  }\n\n  // get default direction\n  if(type === '@direction' && type in ctx) {\n    return ctx[type];\n  }\n\n  if(type === '@context') {\n    return undefined;\n  }\n  return null;\n};\n\n/**\n * Processing Mode check.\n *\n * @param activeCtx the current active context.\n * @param version the string or numeric version to check.\n *\n * @return boolean.\n */\napi.processingMode = (activeCtx, version) => {\n  if(version.toString() >= '1.1') {\n    return !activeCtx.processingMode ||\n      activeCtx.processingMode >= 'json-ld-' + version.toString();\n  } else {\n    return activeCtx.processingMode === 'json-ld-1.0';\n  }\n};\n\n/**\n * Returns whether or not the given value is a keyword.\n *\n * @param v the value to check.\n *\n * @return true if the value is a keyword, false if not.\n */\napi.isKeyword = v => {\n  if(!_isString(v) || v[0] !== '@') {\n    return false;\n  }\n  switch(v) {\n    case '@base':\n    case '@container':\n    case '@context':\n    case '@default':\n    case '@direction':\n    case '@embed':\n    case '@explicit':\n    case '@graph':\n    case '@id':\n    case '@included':\n    case '@index':\n    case '@json':\n    case '@language':\n    case '@list':\n    case '@nest':\n    case '@none':\n    case '@omitDefault':\n    case '@prefix':\n    case '@preserve':\n    case '@protected':\n    case '@requireAll':\n    case '@reverse':\n    case '@set':\n    case '@type':\n    case '@value':\n    case '@version':\n    case '@vocab':\n      return true;\n  }\n  return false;\n};\n\nfunction _deepCompare(x1, x2) {\n  // compare `null` or primitive types directly\n  if((!(x1 && typeof x1 === 'object')) ||\n     (!(x2 && typeof x2 === 'object'))) {\n    return x1 === x2;\n  }\n  // x1 and x2 are objects (also potentially arrays)\n  const x1Array = Array.isArray(x1);\n  if(x1Array !== Array.isArray(x2)) {\n    return false;\n  }\n  if(x1Array) {\n    if(x1.length !== x2.length) {\n      return false;\n    }\n    for(let i = 0; i < x1.length; ++i) {\n      if(!_deepCompare(x1[i], x2[i])) {\n        return false;\n      }\n    }\n    return true;\n  }\n  // x1 and x2 are non-array objects\n  const k1s = Object.keys(x1);\n  const k2s = Object.keys(x2);\n  if(k1s.length !== k2s.length) {\n    return false;\n  }\n  for(const k1 in x1) {\n    let v1 = x1[k1];\n    let v2 = x2[k1];\n    // special case: `@container` can be in any order\n    if(k1 === '@container') {\n      if(Array.isArray(v1) && Array.isArray(v2)) {\n        v1 = v1.slice().sort();\n        v2 = v2.slice().sort();\n      }\n    }\n    if(!_deepCompare(v1, v2)) {\n      return false;\n    }\n  }\n  return true;\n}\n","/*\n * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst {parseLinkHeader, buildHeaders} = require('../util');\nconst {LINK_HEADER_CONTEXT} = require('../constants');\nconst JsonLdError = require('../JsonLdError');\nconst RequestQueue = require('../RequestQueue');\nconst {prependBase} = require('../url');\n\nconst REGEX_LINK_HEADER = /(^|(\\r\\n))link:/i;\n\n/**\n * Creates a built-in XMLHttpRequest document loader.\n *\n * @param options the options to use:\n *          secure: require all URLs to use HTTPS.\n *          headers: an object (map) of headers which will be passed as request\n *            headers for the requested document. Accept is not allowed.\n *          [xhr]: the XMLHttpRequest API to use.\n *\n * @return the XMLHttpRequest document loader.\n */\nmodule.exports = ({\n  secure,\n  headers = {},\n  xhr\n} = {headers: {}}) => {\n  headers = buildHeaders(headers);\n  const queue = new RequestQueue();\n  return queue.wrapLoader(loader);\n\n  async function loader(url) {\n    if(url.indexOf('http:') !== 0 && url.indexOf('https:') !== 0) {\n      throw new JsonLdError(\n        'URL could not be dereferenced; only \"http\" and \"https\" URLs are ' +\n        'supported.',\n        'jsonld.InvalidUrl', {code: 'loading document failed', url});\n    }\n    if(secure && url.indexOf('https') !== 0) {\n      throw new JsonLdError(\n        'URL could not be dereferenced; secure mode is enabled and ' +\n        'the URL\\'s scheme is not \"https\".',\n        'jsonld.InvalidUrl', {code: 'loading document failed', url});\n    }\n\n    let req;\n    try {\n      req = await _get(xhr, url, headers);\n    } catch(e) {\n      throw new JsonLdError(\n        'URL could not be dereferenced, an error occurred.',\n        'jsonld.LoadDocumentError',\n        {code: 'loading document failed', url, cause: e});\n    }\n\n    if(req.status >= 400) {\n      throw new JsonLdError(\n        'URL could not be dereferenced: ' + req.statusText,\n        'jsonld.LoadDocumentError', {\n          code: 'loading document failed',\n          url,\n          httpStatusCode: req.status\n        });\n    }\n\n    let doc = {contextUrl: null, documentUrl: url, document: req.response};\n    let alternate = null;\n\n    // handle Link Header (avoid unsafe header warning by existence testing)\n    const contentType = req.getResponseHeader('Content-Type');\n    let linkHeader;\n    if(REGEX_LINK_HEADER.test(req.getAllResponseHeaders())) {\n      linkHeader = req.getResponseHeader('Link');\n    }\n    if(linkHeader && contentType !== 'application/ld+json') {\n      // only 1 related link header permitted\n      const linkHeaders = parseLinkHeader(linkHeader);\n      const linkedContext = linkHeaders[LINK_HEADER_CONTEXT];\n      if(Array.isArray(linkedContext)) {\n        throw new JsonLdError(\n          'URL could not be dereferenced, it has more than one ' +\n          'associated HTTP Link Header.',\n          'jsonld.InvalidUrl',\n          {code: 'multiple context link headers', url});\n      }\n      if(linkedContext) {\n        doc.contextUrl = linkedContext.target;\n      }\n\n      // \"alternate\" link header is a redirect\n      alternate = linkHeaders.alternate;\n      if(alternate &&\n        alternate.type == 'application/ld+json' &&\n        !(contentType || '').match(/^application\\/(\\w*\\+)?json$/)) {\n        doc = await loader(prependBase(url, alternate.target));\n      }\n    }\n\n    return doc;\n  }\n};\n\nfunction _get(xhr, url, headers) {\n  xhr = xhr || XMLHttpRequest;\n  const req = new xhr();\n  return new Promise((resolve, reject) => {\n    req.onload = () => resolve(req);\n    req.onerror = err => reject(err);\n    req.open('GET', url, true);\n    for(const k in headers) {\n      req.setRequestHeader(k, headers[k]);\n    }\n    req.send();\n  });\n}\n","/*\n * Copyright (c) 2020 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst JsonLdError = require('./JsonLdError');\n\nconst {\n  isArray: _isArray\n} = require('./types');\n\nconst {\n  asArray: _asArray\n} = require('./util');\n\nconst api = {};\nmodule.exports = api;\n\n// default handler, store as null or an array\n// exposed to allow fast external pre-handleEvent() checks\napi.defaultEventHandler = null;\n\n/**\n * Setup event handler.\n *\n * Return an array event handler constructed from an optional safe mode\n * handler, an optional options event handler, and an optional default handler.\n *\n * @param {object} options - processing options\n *   {function|object|array} [eventHandler] - an event handler.\n *\n * @return an array event handler.\n */\napi.setupEventHandler = ({options = {}}) => {\n  // build in priority order\n  const eventHandler = [].concat(\n    options.safe ? api.safeEventHandler : [],\n    options.eventHandler ? _asArray(options.eventHandler) : [],\n    api.defaultEventHandler ? api.defaultEventHandler : []\n  );\n  // null if no handlers\n  return eventHandler.length === 0 ? null : eventHandler;\n};\n\n/**\n * Handle an event.\n *\n * Top level APIs have a common 'eventHandler' option. This option can be a\n * function, array of functions, object mapping event.code to functions (with a\n * default to call next()), or any combination of such handlers. Handlers will\n * be called with an object with an 'event' entry and a 'next' function. Custom\n * handlers should process the event as appropriate. The 'next()' function\n * should be called to let the next handler process the event.\n *\n * NOTE: Only call this function if options.eventHandler is set and is an\n * array of hanlers. This is an optimization. Callers are expected to check\n * for an event handler before constructing events and calling this function.\n *\n * @param {object} event - event structure:\n *   {string} code - event code\n *   {string} level - severity level, one of: ['warning']\n *   {string} message - human readable message\n *   {object} details - event specific details\n * @param {object} options - processing options\n *   {array} eventHandler - an event handler array.\n */\napi.handleEvent = ({\n  event,\n  options\n}) => {\n  _handle({event, handlers: options.eventHandler});\n};\n\nfunction _handle({event, handlers}) {\n  let doNext = true;\n  for(let i = 0; doNext && i < handlers.length; ++i) {\n    doNext = false;\n    const handler = handlers[i];\n    if(_isArray(handler)) {\n      doNext = _handle({event, handlers: handler});\n    } else if(typeof handler === 'function') {\n      handler({event, next: () => {\n        doNext = true;\n      }});\n    } else if(typeof handler === 'object') {\n      if(event.code in handler) {\n        handler[event.code]({event, next: () => {\n          doNext = true;\n        }});\n      } else {\n        doNext = true;\n      }\n    } else {\n      throw new JsonLdError(\n        'Invalid event handler.',\n        'jsonld.InvalidEventHandler',\n        {event});\n    }\n  }\n  return doNext;\n}\n\nconst _notSafeEventCodes = new Set([\n  'empty object',\n  'free-floating scalar',\n  'invalid @language value',\n  'invalid property',\n  // NOTE: spec edge case\n  'null @id value',\n  'null @value value',\n  'object with only @id',\n  'object with only @language',\n  'object with only @list',\n  'object with only @value',\n  'relative @id reference',\n  'relative @type reference',\n  'relative @vocab reference',\n  'reserved @id value',\n  'reserved @reverse value',\n  'reserved term',\n  // toRDF\n  'blank node predicate',\n  'relative graph reference',\n  'relative object reference',\n  'relative predicate reference',\n  'relative subject reference',\n  // toRDF / fromRDF\n  'rdfDirection not set'\n]);\n\n// safe handler that rejects unsafe warning conditions\napi.safeEventHandler = function safeEventHandler({event, next}) {\n  // fail on all unsafe warnings\n  if(event.level === 'warning' && _notSafeEventCodes.has(event.code)) {\n    throw new JsonLdError(\n      'Safe mode validation error.',\n      'jsonld.ValidationError',\n      {event}\n    );\n  }\n  next();\n};\n\n// logs all events and continues\napi.logEventHandler = function logEventHandler({event, next}) {\n  console.log(`EVENT: ${event.message}`, {event});\n  next();\n};\n\n// log 'warning' level events\napi.logWarningEventHandler = function logWarningEventHandler({event, next}) {\n  if(event.level === 'warning') {\n    console.warn(`WARNING: ${event.message}`, {event});\n  }\n  next();\n};\n\n// fallback to throw errors for any unhandled events\napi.unhandledEventHandler = function unhandledEventHandler({event}) {\n  throw new JsonLdError(\n    'No handler for event.',\n    'jsonld.UnhandledEvent',\n    {event}\n  );\n};\n\n/**\n * Set default event handler.\n *\n * By default, all event are unhandled. It is recommended to pass in an\n * eventHandler into each call. However, this call allows using a default\n * eventHandler when one is not otherwise provided.\n *\n * @param {object} options - default handler options:\n *   {function|object|array} eventHandler - a default event handler.\n *     falsey to unset.\n */\napi.setDefaultEventHandler = function({eventHandler} = {}) {\n  api.defaultEventHandler = eventHandler ? _asArray(eventHandler) : null;\n};\n","/*\n * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst JsonLdError = require('./JsonLdError');\n\nconst {\n  isArray: _isArray,\n  isObject: _isObject,\n  isEmptyObject: _isEmptyObject,\n  isString: _isString,\n  isUndefined: _isUndefined\n} = require('./types');\n\nconst {\n  isList: _isList,\n  isValue: _isValue,\n  isGraph: _isGraph,\n  isSubject: _isSubject\n} = require('./graphTypes');\n\nconst {\n  expandIri: _expandIri,\n  getContextValue: _getContextValue,\n  isKeyword: _isKeyword,\n  process: _processContext,\n  processingMode: _processingMode\n} = require('./context');\n\nconst {\n  isAbsolute: _isAbsoluteIri\n} = require('./url');\n\nconst {\n  REGEX_BCP47,\n  REGEX_KEYWORD,\n  addValue: _addValue,\n  asArray: _asArray,\n  getValues: _getValues,\n  validateTypeValue: _validateTypeValue\n} = require('./util');\n\nconst {\n  handleEvent: _handleEvent\n} = require('./events');\n\nconst api = {};\nmodule.exports = api;\n\n/**\n * Recursively expands an element using the given context. Any context in\n * the element will be removed. All context URLs must have been retrieved\n * before calling this method.\n *\n * @param activeCtx the context to use.\n * @param activeProperty the property for the element, null for none.\n * @param element the element to expand.\n * @param options the expansion options.\n * @param insideList true if the element is a list, false if not.\n * @param insideIndex true if the element is inside an index container,\n *          false if not.\n * @param typeScopedContext an optional type-scoped active context for\n *          expanding values of nodes that were expressed according to\n *          a type-scoped context.\n *\n * @return a Promise that resolves to the expanded value.\n */\napi.expand = async ({\n  activeCtx,\n  activeProperty = null,\n  element,\n  options = {},\n  insideList = false,\n  insideIndex = false,\n  typeScopedContext = null\n}) => {\n  // nothing to expand\n  if(element === null || element === undefined) {\n    return null;\n  }\n\n  // disable framing if activeProperty is @default\n  if(activeProperty === '@default') {\n    options = Object.assign({}, options, {isFrame: false});\n  }\n\n  if(!_isArray(element) && !_isObject(element)) {\n    // drop free-floating scalars that are not in lists\n    if(!insideList && (activeProperty === null ||\n      _expandIri(activeCtx, activeProperty, {vocab: true},\n        options) === '@graph')) {\n      // FIXME\n      if(options.eventHandler) {\n        _handleEvent({\n          event: {\n            type: ['JsonLdEvent'],\n            code: 'free-floating scalar',\n            level: 'warning',\n            message: 'Dropping free-floating scalar not in a list.',\n            details: {\n              value: element\n              //activeProperty\n              //insideList\n            }\n          },\n          options\n        });\n      }\n      return null;\n    }\n\n    // expand element according to value expansion rules\n    return _expandValue({activeCtx, activeProperty, value: element, options});\n  }\n\n  // recursively expand array\n  if(_isArray(element)) {\n    let rval = [];\n    const container = _getContextValue(\n      activeCtx, activeProperty, '@container') || [];\n    insideList = insideList || container.includes('@list');\n    for(let i = 0; i < element.length; ++i) {\n      // expand element\n      let e = await api.expand({\n        activeCtx,\n        activeProperty,\n        element: element[i],\n        options,\n        insideIndex,\n        typeScopedContext\n      });\n      if(insideList && _isArray(e)) {\n        e = {'@list': e};\n      }\n\n      if(e === null) {\n        // FIXME: add debug event?\n        //unmappedValue: element[i],\n        //activeProperty,\n        //parent: element,\n        //index: i,\n        //expandedParent: rval,\n        //insideList\n\n        // NOTE: no-value events emitted at calling sites as needed\n        continue;\n      }\n\n      if(_isArray(e)) {\n        rval = rval.concat(e);\n      } else {\n        rval.push(e);\n      }\n    }\n    return rval;\n  }\n\n  // recursively expand object:\n\n  // first, expand the active property\n  const expandedActiveProperty = _expandIri(\n    activeCtx, activeProperty, {vocab: true}, options);\n\n  // Get any property-scoped context for activeProperty\n  const propertyScopedCtx =\n    _getContextValue(activeCtx, activeProperty, '@context');\n\n  // second, determine if any type-scoped context should be reverted; it\n  // should only be reverted when the following are all true:\n  // 1. `element` is not a value or subject reference\n  // 2. `insideIndex` is false\n  typeScopedContext = typeScopedContext ||\n    (activeCtx.previousContext ? activeCtx : null);\n  let keys = Object.keys(element).sort();\n  let mustRevert = !insideIndex;\n  if(mustRevert && typeScopedContext && keys.length <= 2 &&\n    !keys.includes('@context')) {\n    for(const key of keys) {\n      const expandedProperty = _expandIri(\n        typeScopedContext, key, {vocab: true}, options);\n      if(expandedProperty === '@value') {\n        // value found, ensure type-scoped context is used to expand it\n        mustRevert = false;\n        activeCtx = typeScopedContext;\n        break;\n      }\n      if(expandedProperty === '@id' && keys.length === 1) {\n        // subject reference found, do not revert\n        mustRevert = false;\n        break;\n      }\n    }\n  }\n\n  if(mustRevert) {\n    // revert type scoped context\n    activeCtx = activeCtx.revertToPreviousContext();\n  }\n\n  // apply property-scoped context after reverting term-scoped context\n  if(!_isUndefined(propertyScopedCtx)) {\n    activeCtx = await _processContext({\n      activeCtx,\n      localCtx: propertyScopedCtx,\n      propagate: true,\n      overrideProtected: true,\n      options\n    });\n  }\n\n  // if element has a context, process it\n  if('@context' in element) {\n    activeCtx = await _processContext(\n      {activeCtx, localCtx: element['@context'], options});\n  }\n\n  // set the type-scoped context to the context on input, for use later\n  typeScopedContext = activeCtx;\n\n  // Remember the first key found expanding to @type\n  let typeKey = null;\n\n  // look for scoped contexts on `@type`\n  for(const key of keys) {\n    const expandedProperty = _expandIri(activeCtx, key, {vocab: true}, options);\n    if(expandedProperty === '@type') {\n      // set scoped contexts from @type\n      // avoid sorting if possible\n      typeKey = typeKey || key;\n      const value = element[key];\n      const types =\n        Array.isArray(value) ?\n          (value.length > 1 ? value.slice().sort() : value) : [value];\n      for(const type of types) {\n        const ctx = _getContextValue(typeScopedContext, type, '@context');\n        if(!_isUndefined(ctx)) {\n          activeCtx = await _processContext({\n            activeCtx,\n            localCtx: ctx,\n            options,\n            propagate: false\n          });\n        }\n      }\n    }\n  }\n\n  // process each key and value in element, ignoring @nest content\n  let rval = {};\n  await _expandObject({\n    activeCtx,\n    activeProperty,\n    expandedActiveProperty,\n    element,\n    expandedParent: rval,\n    options,\n    insideList,\n    typeKey,\n    typeScopedContext\n  });\n\n  // get property count on expanded output\n  keys = Object.keys(rval);\n  let count = keys.length;\n\n  if('@value' in rval) {\n    // @value must only have @language or @type\n    if('@type' in rval && ('@language' in rval || '@direction' in rval)) {\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; an element containing \"@value\" may not ' +\n        'contain both \"@type\" and either \"@language\" or \"@direction\".',\n        'jsonld.SyntaxError', {code: 'invalid value object', element: rval});\n    }\n    let validCount = count - 1;\n    if('@type' in rval) {\n      validCount -= 1;\n    }\n    if('@index' in rval) {\n      validCount -= 1;\n    }\n    if('@language' in rval) {\n      validCount -= 1;\n    }\n    if('@direction' in rval) {\n      validCount -= 1;\n    }\n    if(validCount !== 0) {\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; an element containing \"@value\" may only ' +\n        'have an \"@index\" property and either \"@type\" ' +\n        'or either or both \"@language\" or \"@direction\".',\n        'jsonld.SyntaxError', {code: 'invalid value object', element: rval});\n    }\n    const values = rval['@value'] === null ? [] : _asArray(rval['@value']);\n    const types = _getValues(rval, '@type');\n\n    // drop null @values\n    if(_processingMode(activeCtx, 1.1) && types.includes('@json') &&\n      types.length === 1) {\n      // Any value of @value is okay if @type: @json\n    } else if(values.length === 0) {\n      // FIXME\n      if(options.eventHandler) {\n        _handleEvent({\n          event: {\n            type: ['JsonLdEvent'],\n            code: 'null @value value',\n            level: 'warning',\n            message: 'Dropping null @value value.',\n            details: {\n              value: rval\n            }\n          },\n          options\n        });\n      }\n      rval = null;\n    } else if(!values.every(v => (_isString(v) || _isEmptyObject(v))) &&\n      '@language' in rval) {\n      // if @language is present, @value must be a string\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; only strings may be language-tagged.',\n        'jsonld.SyntaxError',\n        {code: 'invalid language-tagged value', element: rval});\n    } else if(!types.every(t =>\n      (_isAbsoluteIri(t) && !(_isString(t) && t.indexOf('_:') === 0) ||\n      _isEmptyObject(t)))) {\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; an element containing \"@value\" and \"@type\" ' +\n        'must have an absolute IRI for the value of \"@type\".',\n        'jsonld.SyntaxError', {code: 'invalid typed value', element: rval});\n    }\n  } else if('@type' in rval && !_isArray(rval['@type'])) {\n    // convert @type to an array\n    rval['@type'] = [rval['@type']];\n  } else if('@set' in rval || '@list' in rval) {\n    // handle @set and @list\n    if(count > 1 && !(count === 2 && '@index' in rval)) {\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; if an element has the property \"@set\" ' +\n        'or \"@list\", then it can have at most one other property that is ' +\n        '\"@index\".', 'jsonld.SyntaxError',\n        {code: 'invalid set or list object', element: rval});\n    }\n    // optimize away @set\n    if('@set' in rval) {\n      rval = rval['@set'];\n      keys = Object.keys(rval);\n      count = keys.length;\n    }\n  } else if(count === 1 && '@language' in rval) {\n    // drop objects with only @language\n    // FIXME\n    if(options.eventHandler) {\n      _handleEvent({\n        event: {\n          type: ['JsonLdEvent'],\n          code: 'object with only @language',\n          level: 'warning',\n          message: 'Dropping object with only @language.',\n          details: {\n            value: rval\n          }\n        },\n        options\n      });\n    }\n    rval = null;\n  }\n\n  // drop certain top-level objects that do not occur in lists\n  if(_isObject(rval) &&\n    !options.keepFreeFloatingNodes && !insideList &&\n    (activeProperty === null ||\n      expandedActiveProperty === '@graph' ||\n      (_getContextValue(activeCtx, activeProperty, '@container') || [])\n        .includes('@graph')\n    )) {\n    // drop empty object, top-level @value/@list, or object with only @id\n    rval = _dropUnsafeObject({value: rval, count, options});\n  }\n\n  return rval;\n};\n\n/**\n * Drop empty object, top-level @value/@list, or object with only @id\n *\n * @param value Value to check.\n * @param count Number of properties in object.\n * @param options The expansion options.\n *\n * @return null if dropped, value otherwise.\n */\nfunction _dropUnsafeObject({\n  value,\n  count,\n  options\n}) {\n  if(count === 0 || '@value' in value || '@list' in value ||\n    (count === 1 && '@id' in value)) {\n    // FIXME\n    if(options.eventHandler) {\n      // FIXME: one event or diff event for empty, @v/@l, {@id}?\n      let code;\n      let message;\n      if(count === 0) {\n        code = 'empty object';\n        message = 'Dropping empty object.';\n      } else if('@value' in value) {\n        code = 'object with only @value';\n        message = 'Dropping object with only @value.';\n      } else if('@list' in value) {\n        code = 'object with only @list';\n        message = 'Dropping object with only @list.';\n      } else if(count === 1 && '@id' in value) {\n        code = 'object with only @id';\n        message = 'Dropping object with only @id.';\n      }\n      _handleEvent({\n        event: {\n          type: ['JsonLdEvent'],\n          code,\n          level: 'warning',\n          message,\n          details: {\n            value\n          }\n        },\n        options\n      });\n    }\n    return null;\n  }\n  return value;\n}\n\n/**\n * Expand each key and value of element adding to result\n *\n * @param activeCtx the context to use.\n * @param activeProperty the property for the element.\n * @param expandedActiveProperty the expansion of activeProperty\n * @param element the element to expand.\n * @param expandedParent the expanded result into which to add values.\n * @param options the expansion options.\n * @param insideList true if the element is a list, false if not.\n * @param typeKey first key found expanding to @type.\n * @param typeScopedContext the context before reverting.\n */\nasync function _expandObject({\n  activeCtx,\n  activeProperty,\n  expandedActiveProperty,\n  element,\n  expandedParent,\n  options = {},\n  insideList,\n  typeKey,\n  typeScopedContext\n}) {\n  const keys = Object.keys(element).sort();\n  const nests = [];\n  let unexpandedValue;\n\n  // Figure out if this is the type for a JSON literal\n  const isJsonType = element[typeKey] &&\n    _expandIri(activeCtx,\n      (_isArray(element[typeKey]) ? element[typeKey][0] : element[typeKey]),\n      {vocab: true}, {\n        ...options,\n        typeExpansion: true\n      }) === '@json';\n\n  for(const key of keys) {\n    let value = element[key];\n    let expandedValue;\n\n    // skip @context\n    if(key === '@context') {\n      continue;\n    }\n\n    // expand property\n    const expandedProperty = _expandIri(activeCtx, key, {vocab: true}, options);\n\n    // drop non-absolute IRI keys that aren't keywords\n    if(expandedProperty === null ||\n      !(_isAbsoluteIri(expandedProperty) || _isKeyword(expandedProperty))) {\n      if(options.eventHandler) {\n        _handleEvent({\n          event: {\n            type: ['JsonLdEvent'],\n            code: 'invalid property',\n            level: 'warning',\n            message: 'Dropping property that did not expand into an ' +\n              'absolute IRI or keyword.',\n            details: {\n              property: key,\n              expandedProperty\n            }\n          },\n          options\n        });\n      }\n      continue;\n    }\n\n    if(_isKeyword(expandedProperty)) {\n      if(expandedActiveProperty === '@reverse') {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; a keyword cannot be used as a @reverse ' +\n          'property.', 'jsonld.SyntaxError',\n          {code: 'invalid reverse property map', value});\n      }\n      if(expandedProperty in expandedParent &&\n         expandedProperty !== '@included' &&\n         expandedProperty !== '@type') {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; colliding keywords detected.',\n          'jsonld.SyntaxError',\n          {code: 'colliding keywords', keyword: expandedProperty});\n      }\n    }\n\n    // syntax error if @id is not a string\n    if(expandedProperty === '@id') {\n      if(!_isString(value)) {\n        if(!options.isFrame) {\n          throw new JsonLdError(\n            'Invalid JSON-LD syntax; \"@id\" value must a string.',\n            'jsonld.SyntaxError', {code: 'invalid @id value', value});\n        }\n        if(_isObject(value)) {\n          // empty object is a wildcard\n          if(!_isEmptyObject(value)) {\n            throw new JsonLdError(\n              'Invalid JSON-LD syntax; \"@id\" value an empty object or array ' +\n              'of strings, if framing',\n              'jsonld.SyntaxError', {code: 'invalid @id value', value});\n          }\n        } else if(_isArray(value)) {\n          if(!value.every(v => _isString(v))) {\n            throw new JsonLdError(\n              'Invalid JSON-LD syntax; \"@id\" value an empty object or array ' +\n              'of strings, if framing',\n              'jsonld.SyntaxError', {code: 'invalid @id value', value});\n          }\n        } else {\n          throw new JsonLdError(\n            'Invalid JSON-LD syntax; \"@id\" value an empty object or array ' +\n            'of strings, if framing',\n            'jsonld.SyntaxError', {code: 'invalid @id value', value});\n        }\n      }\n\n      _addValue(\n        expandedParent, '@id',\n        _asArray(value).map(v => {\n          if(_isString(v)) {\n            const ve = _expandIri(activeCtx, v, {base: true}, options);\n            if(options.eventHandler) {\n              if(ve === null) {\n                // NOTE: spec edge case\n                // See https://github.com/w3c/json-ld-api/issues/480\n                if(v === null) {\n                  _handleEvent({\n                    event: {\n                      type: ['JsonLdEvent'],\n                      code: 'null @id value',\n                      level: 'warning',\n                      message: 'Null @id found.',\n                      details: {\n                        id: v\n                      }\n                    },\n                    options\n                  });\n                } else {\n                  // matched KEYWORD regex\n                  _handleEvent({\n                    event: {\n                      type: ['JsonLdEvent'],\n                      code: 'reserved @id value',\n                      level: 'warning',\n                      message: 'Reserved @id found.',\n                      details: {\n                        id: v\n                      }\n                    },\n                    options\n                  });\n                }\n              } else if(!_isAbsoluteIri(ve)) {\n                _handleEvent({\n                  event: {\n                    type: ['JsonLdEvent'],\n                    code: 'relative @id reference',\n                    level: 'warning',\n                    message: 'Relative @id reference found.',\n                    details: {\n                      id: v,\n                      expandedId: ve\n                    }\n                  },\n                  options\n                });\n              }\n            }\n            return ve;\n          }\n          return v;\n        }),\n        {propertyIsArray: options.isFrame});\n      continue;\n    }\n\n    if(expandedProperty === '@type') {\n      // if framing, can be a default object, but need to expand\n      // key to determine that\n      if(_isObject(value)) {\n        value = Object.fromEntries(Object.entries(value).map(([k, v]) => [\n          _expandIri(typeScopedContext, k, {vocab: true}),\n          _asArray(v).map(vv =>\n            _expandIri(typeScopedContext, vv, {base: true, vocab: true},\n              {...options, typeExpansion: true})\n          )\n        ]));\n      }\n      _validateTypeValue(value, options.isFrame);\n      _addValue(\n        expandedParent, '@type',\n        _asArray(value).map(v => {\n          if(_isString(v)) {\n            const ve = _expandIri(typeScopedContext, v,\n              {base: true, vocab: true},\n              {...options, typeExpansion: true});\n            if(ve !== '@json' && !_isAbsoluteIri(ve)) {\n              if(options.eventHandler) {\n                _handleEvent({\n                  event: {\n                    type: ['JsonLdEvent'],\n                    code: 'relative @type reference',\n                    level: 'warning',\n                    message: 'Relative @type reference found.',\n                    details: {\n                      type: v\n                    }\n                  },\n                  options\n                });\n              }\n            }\n            return ve;\n          }\n          return v;\n        }),\n        {propertyIsArray: !!options.isFrame});\n      continue;\n    }\n\n    // Included blocks are treated as an array of separate object nodes sharing\n    // the same referencing active_property.\n    // For 1.0, it is skipped as are other unknown keywords\n    if(expandedProperty === '@included' && _processingMode(activeCtx, 1.1)) {\n      const includedResult = _asArray(await api.expand({\n        activeCtx,\n        activeProperty,\n        element: value,\n        options\n      }));\n\n      // Expanded values must be node objects\n      if(!includedResult.every(v => _isSubject(v))) {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; ' +\n          'values of @included must expand to node objects.',\n          'jsonld.SyntaxError', {code: 'invalid @included value', value});\n      }\n\n      _addValue(\n        expandedParent, '@included', includedResult, {propertyIsArray: true});\n      continue;\n    }\n\n    // @graph must be an array or an object\n    if(expandedProperty === '@graph' &&\n      !(_isObject(value) || _isArray(value))) {\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; \"@graph\" value must not be an ' +\n        'object or an array.',\n        'jsonld.SyntaxError', {code: 'invalid @graph value', value});\n    }\n\n    if(expandedProperty === '@value') {\n      // capture value for later\n      // \"colliding keywords\" check prevents this from being set twice\n      unexpandedValue = value;\n      if(isJsonType && _processingMode(activeCtx, 1.1)) {\n        // no coercion to array, and retain all values\n        expandedParent['@value'] = value;\n      } else {\n        _addValue(\n          expandedParent, '@value', value, {propertyIsArray: options.isFrame});\n      }\n      continue;\n    }\n\n    // @language must be a string\n    // it should match BCP47\n    if(expandedProperty === '@language') {\n      if(value === null) {\n        // drop null @language values, they expand as if they didn't exist\n        continue;\n      }\n      if(!_isString(value) && !options.isFrame) {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; \"@language\" value must be a string.',\n          'jsonld.SyntaxError',\n          {code: 'invalid language-tagged string', value});\n      }\n      // ensure language value is lowercase\n      value = _asArray(value).map(v => _isString(v) ? v.toLowerCase() : v);\n\n      // ensure language tag matches BCP47\n      for(const language of value) {\n        if(_isString(language) && !language.match(REGEX_BCP47)) {\n          if(options.eventHandler) {\n            _handleEvent({\n              event: {\n                type: ['JsonLdEvent'],\n                code: 'invalid @language value',\n                level: 'warning',\n                message: '@language value must be valid BCP47.',\n                details: {\n                  language\n                }\n              },\n              options\n            });\n          }\n        }\n      }\n\n      _addValue(\n        expandedParent, '@language', value, {propertyIsArray: options.isFrame});\n      continue;\n    }\n\n    // @direction must be \"ltr\" or \"rtl\"\n    if(expandedProperty === '@direction') {\n      if(!_isString(value) && !options.isFrame) {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; \"@direction\" value must be a string.',\n          'jsonld.SyntaxError',\n          {code: 'invalid base direction', value});\n      }\n\n      value = _asArray(value);\n\n      // ensure direction is \"ltr\" or \"rtl\"\n      for(const dir of value) {\n        if(_isString(dir) && dir !== 'ltr' && dir !== 'rtl') {\n          throw new JsonLdError(\n            'Invalid JSON-LD syntax; \"@direction\" must be \"ltr\" or \"rtl\".',\n            'jsonld.SyntaxError',\n            {code: 'invalid base direction', value});\n        }\n      }\n\n      _addValue(\n        expandedParent, '@direction', value,\n        {propertyIsArray: options.isFrame});\n      continue;\n    }\n\n    // @index must be a string\n    if(expandedProperty === '@index') {\n      if(!_isString(value)) {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; \"@index\" value must be a string.',\n          'jsonld.SyntaxError',\n          {code: 'invalid @index value', value});\n      }\n      _addValue(expandedParent, '@index', value);\n      continue;\n    }\n\n    // @reverse must be an object\n    if(expandedProperty === '@reverse') {\n      if(!_isObject(value)) {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; \"@reverse\" value must be an object.',\n          'jsonld.SyntaxError', {code: 'invalid @reverse value', value});\n      }\n\n      expandedValue = await api.expand({\n        activeCtx,\n        activeProperty: '@reverse',\n        element: value,\n        options\n      });\n      // properties double-reversed\n      if('@reverse' in expandedValue) {\n        for(const property in expandedValue['@reverse']) {\n          _addValue(\n            expandedParent, property, expandedValue['@reverse'][property],\n            {propertyIsArray: true});\n        }\n      }\n\n      // FIXME: can this be merged with code below to simplify?\n      // merge in all reversed properties\n      let reverseMap = expandedParent['@reverse'] || null;\n      for(const property in expandedValue) {\n        if(property === '@reverse') {\n          continue;\n        }\n        if(reverseMap === null) {\n          reverseMap = expandedParent['@reverse'] = {};\n        }\n        _addValue(reverseMap, property, [], {propertyIsArray: true});\n        const items = expandedValue[property];\n        for(let ii = 0; ii < items.length; ++ii) {\n          const item = items[ii];\n          if(_isValue(item) || _isList(item)) {\n            throw new JsonLdError(\n              'Invalid JSON-LD syntax; \"@reverse\" value must not be a ' +\n              '@value or an @list.', 'jsonld.SyntaxError',\n              {code: 'invalid reverse property value', value: expandedValue});\n          }\n          _addValue(reverseMap, property, item, {propertyIsArray: true});\n        }\n      }\n\n      continue;\n    }\n\n    // nested keys\n    if(expandedProperty === '@nest') {\n      nests.push(key);\n      continue;\n    }\n\n    // use potential scoped context for key\n    let termCtx = activeCtx;\n    const ctx = _getContextValue(activeCtx, key, '@context');\n    if(!_isUndefined(ctx)) {\n      termCtx = await _processContext({\n        activeCtx,\n        localCtx: ctx,\n        propagate: true,\n        overrideProtected: true,\n        options\n      });\n    }\n\n    const container = _getContextValue(activeCtx, key, '@container') || [];\n\n    if(container.includes('@language') && _isObject(value)) {\n      const direction = _getContextValue(termCtx, key, '@direction');\n      // handle language map container (skip if value is not an object)\n      expandedValue = _expandLanguageMap(termCtx, value, direction, options);\n    } else if(container.includes('@index') && _isObject(value)) {\n      // handle index container (skip if value is not an object)\n      const asGraph = container.includes('@graph');\n      const indexKey = _getContextValue(termCtx, key, '@index') || '@index';\n      const propertyIndex = indexKey !== '@index' &&\n        _expandIri(activeCtx, indexKey, {vocab: true}, options);\n\n      expandedValue = await _expandIndexMap({\n        activeCtx: termCtx,\n        options,\n        activeProperty: key,\n        value,\n        asGraph,\n        indexKey,\n        propertyIndex\n      });\n    } else if(container.includes('@id') && _isObject(value)) {\n      // handle id container (skip if value is not an object)\n      const asGraph = container.includes('@graph');\n      expandedValue = await _expandIndexMap({\n        activeCtx: termCtx,\n        options,\n        activeProperty: key,\n        value,\n        asGraph,\n        indexKey: '@id'\n      });\n    } else if(container.includes('@type') && _isObject(value)) {\n      // handle type container (skip if value is not an object)\n      expandedValue = await _expandIndexMap({\n        // since container is `@type`, revert type scoped context when expanding\n        activeCtx: termCtx.revertToPreviousContext(),\n        options,\n        activeProperty: key,\n        value,\n        asGraph: false,\n        indexKey: '@type'\n      });\n    } else {\n      // recurse into @list or @set\n      const isList = expandedProperty === '@list';\n      if(isList || expandedProperty === '@set') {\n        let nextActiveProperty = activeProperty;\n        if(isList && expandedActiveProperty === '@graph') {\n          nextActiveProperty = null;\n        }\n        expandedValue = await api.expand({\n          activeCtx: termCtx,\n          activeProperty: nextActiveProperty,\n          element: value,\n          options,\n          insideList: isList\n        });\n      } else if(\n        _getContextValue(activeCtx, key, '@type') === '@json') {\n        expandedValue = {\n          '@type': '@json',\n          '@value': value\n        };\n      } else {\n        // recursively expand value with key as new active property\n        expandedValue = await api.expand({\n          activeCtx: termCtx,\n          activeProperty: key,\n          element: value,\n          options,\n          insideList: false\n        });\n      }\n    }\n\n    // drop null values if property is not @value\n    if(expandedValue === null && expandedProperty !== '@value') {\n      // FIXME: event?\n      //unmappedValue: value,\n      //expandedProperty,\n      //key,\n      continue;\n    }\n\n    // convert expanded value to @list if container specifies it\n    if(expandedProperty !== '@list' && !_isList(expandedValue) &&\n      container.includes('@list')) {\n      // ensure expanded value in @list is an array\n      expandedValue = {'@list': _asArray(expandedValue)};\n    }\n\n    // convert expanded value to @graph if container specifies it\n    // and value is not, itself, a graph\n    // index cases handled above\n    if(container.includes('@graph') &&\n      !container.some(key => key === '@id' || key === '@index')) {\n      // ensure expanded values are in an array\n      expandedValue = _asArray(expandedValue);\n      if(!options.isFrame) {\n        // drop items if needed\n        expandedValue = expandedValue.filter(v => {\n          const count = Object.keys(v).length;\n          return _dropUnsafeObject({value: v, count, options}) !== null;\n        });\n      }\n      if(expandedValue.length === 0) {\n        // all items dropped, skip adding and continue\n        continue;\n      }\n      // convert to graph\n      expandedValue = expandedValue.map(v => ({'@graph': _asArray(v)}));\n    }\n\n    // FIXME: can this be merged with code above to simplify?\n    // merge in reverse properties\n    if(termCtx.mappings.has(key) && termCtx.mappings.get(key).reverse) {\n      const reverseMap =\n        expandedParent['@reverse'] = expandedParent['@reverse'] || {};\n      expandedValue = _asArray(expandedValue);\n      for(let ii = 0; ii < expandedValue.length; ++ii) {\n        const item = expandedValue[ii];\n        if(_isValue(item) || _isList(item)) {\n          throw new JsonLdError(\n            'Invalid JSON-LD syntax; \"@reverse\" value must not be a ' +\n            '@value or an @list.', 'jsonld.SyntaxError',\n            {code: 'invalid reverse property value', value: expandedValue});\n        }\n        _addValue(reverseMap, expandedProperty, item, {propertyIsArray: true});\n      }\n      continue;\n    }\n\n    // add value for property\n    // special keywords handled above\n    _addValue(expandedParent, expandedProperty, expandedValue, {\n      propertyIsArray: true\n    });\n  }\n\n  // @value must not be an object or an array (unless framing) or if @type is\n  // @json\n  if('@value' in expandedParent) {\n    if(expandedParent['@type'] === '@json' && _processingMode(activeCtx, 1.1)) {\n      // allow any value, to be verified when the object is fully expanded and\n      // the @type is @json.\n    } else if((_isObject(unexpandedValue) || _isArray(unexpandedValue)) &&\n      !options.isFrame) {\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; \"@value\" value must not be an ' +\n        'object or an array.',\n        'jsonld.SyntaxError',\n        {code: 'invalid value object value', value: unexpandedValue});\n    }\n  }\n\n  // expand each nested key\n  for(const key of nests) {\n    const nestedValues = _isArray(element[key]) ? element[key] : [element[key]];\n    for(const nv of nestedValues) {\n      if(!_isObject(nv) || Object.keys(nv).some(k =>\n        _expandIri(activeCtx, k, {vocab: true}, options) === '@value')) {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; nested value must be a node object.',\n          'jsonld.SyntaxError',\n          {code: 'invalid @nest value', value: nv});\n      }\n      await _expandObject({\n        activeCtx,\n        activeProperty,\n        expandedActiveProperty,\n        element: nv,\n        expandedParent,\n        options,\n        insideList,\n        typeScopedContext,\n        typeKey\n      });\n    }\n  }\n}\n\n/**\n * Expands the given value by using the coercion and keyword rules in the\n * given context.\n *\n * @param activeCtx the active context to use.\n * @param activeProperty the active property the value is associated with.\n * @param value the value to expand.\n * @param {Object} [options] - processing options.\n *\n * @return the expanded value.\n */\nfunction _expandValue({activeCtx, activeProperty, value, options}) {\n  // nothing to expand\n  if(value === null || value === undefined) {\n    return null;\n  }\n\n  // special-case expand @id and @type (skips '@id' expansion)\n  const expandedProperty = _expandIri(\n    activeCtx, activeProperty, {vocab: true}, options);\n  if(expandedProperty === '@id') {\n    return _expandIri(activeCtx, value, {base: true}, options);\n  } else if(expandedProperty === '@type') {\n    return _expandIri(activeCtx, value, {vocab: true, base: true},\n      {...options, typeExpansion: true});\n  }\n\n  // get type definition from context\n  const type = _getContextValue(activeCtx, activeProperty, '@type');\n\n  // do @id expansion (automatic for @graph)\n  if((type === '@id' || expandedProperty === '@graph') && _isString(value)) {\n    const expandedValue = _expandIri(activeCtx, value, {base: true}, options);\n    // NOTE: handle spec edge case and avoid invalid {\"@id\": null}\n    if(expandedValue === null && value.match(REGEX_KEYWORD)) {\n      if(options.eventHandler) {\n        _handleEvent({\n          event: {\n            type: ['JsonLdEvent'],\n            code: 'reserved @id value',\n            level: 'warning',\n            message: 'Reserved @id found.',\n            details: {\n              id: activeProperty\n            }\n          },\n          options\n        });\n      }\n    }\n    return {'@id': expandedValue};\n  }\n  // do @id expansion w/vocab\n  if(type === '@vocab' && _isString(value)) {\n    return {\n      '@id': _expandIri(activeCtx, value, {vocab: true, base: true}, options)\n    };\n  }\n\n  // do not expand keyword values\n  if(_isKeyword(expandedProperty)) {\n    return value;\n  }\n\n  const rval = {};\n\n  if(type && !['@id', '@vocab', '@none'].includes(type)) {\n    // other type\n    rval['@type'] = type;\n  } else if(_isString(value)) {\n    // check for language tagging for strings\n    const language = _getContextValue(activeCtx, activeProperty, '@language');\n    if(language !== null) {\n      rval['@language'] = language;\n    }\n    const direction = _getContextValue(activeCtx, activeProperty, '@direction');\n    if(direction !== null) {\n      rval['@direction'] = direction;\n    }\n  }\n  // do conversion of values that aren't basic JSON types to strings\n  if(!['boolean', 'number', 'string'].includes(typeof value)) {\n    value = value.toString();\n  }\n  rval['@value'] = value;\n\n  return rval;\n}\n\n/**\n * Expands a language map.\n *\n * @param activeCtx the active context to use.\n * @param languageMap the language map to expand.\n * @param direction the direction to apply to values.\n * @param {Object} [options] - processing options.\n *\n * @return the expanded language map.\n */\nfunction _expandLanguageMap(activeCtx, languageMap, direction, options) {\n  const rval = [];\n  const keys = Object.keys(languageMap).sort();\n  for(const key of keys) {\n    const expandedKey = _expandIri(activeCtx, key, {vocab: true}, options);\n    let val = languageMap[key];\n    if(!_isArray(val)) {\n      val = [val];\n    }\n    for(const item of val) {\n      if(item === null) {\n        // null values are allowed (8.5) but ignored (3.1)\n        continue;\n      }\n      if(!_isString(item)) {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; language map values must be strings.',\n          'jsonld.SyntaxError',\n          {code: 'invalid language map value', languageMap});\n      }\n      const val = {'@value': item};\n      if(expandedKey !== '@none') {\n        if(!key.match(REGEX_BCP47)) {\n          if(options.eventHandler) {\n            _handleEvent({\n              event: {\n                type: ['JsonLdEvent'],\n                code: 'invalid @language value',\n                level: 'warning',\n                message: '@language value must be valid BCP47.',\n                details: {\n                  language: key\n                }\n              },\n              options\n            });\n          }\n        }\n        val['@language'] = key.toLowerCase();\n      }\n      if(direction) {\n        val['@direction'] = direction;\n      }\n      rval.push(val);\n    }\n  }\n  return rval;\n}\n\nasync function _expandIndexMap({\n  activeCtx, options, activeProperty, value, asGraph, indexKey, propertyIndex\n}) {\n  const rval = [];\n  const keys = Object.keys(value).sort();\n  const isTypeIndex = indexKey === '@type';\n  for(let key of keys) {\n    // if indexKey is @type, there may be a context defined for it\n    if(isTypeIndex) {\n      const ctx = _getContextValue(activeCtx, key, '@context');\n      if(!_isUndefined(ctx)) {\n        activeCtx = await _processContext({\n          activeCtx,\n          localCtx: ctx,\n          propagate: false,\n          options\n        });\n      }\n    }\n\n    let val = value[key];\n    if(!_isArray(val)) {\n      val = [val];\n    }\n\n    val = await api.expand({\n      activeCtx,\n      activeProperty,\n      element: val,\n      options,\n      insideList: false,\n      insideIndex: true\n    });\n\n    // expand for @type, but also for @none\n    let expandedKey;\n    if(propertyIndex) {\n      if(key === '@none') {\n        expandedKey = '@none';\n      } else {\n        expandedKey = _expandValue(\n          {activeCtx, activeProperty: indexKey, value: key, options});\n      }\n    } else {\n      expandedKey = _expandIri(activeCtx, key, {vocab: true}, options);\n    }\n\n    if(indexKey === '@id') {\n      // expand document relative\n      key = _expandIri(activeCtx, key, {base: true}, options);\n    } else if(isTypeIndex) {\n      key = expandedKey;\n    }\n\n    for(let item of val) {\n      // If this is also a @graph container, turn items into graphs\n      if(asGraph && !_isGraph(item)) {\n        item = {'@graph': [item]};\n      }\n      if(indexKey === '@type') {\n        if(expandedKey === '@none') {\n          // ignore @none\n        } else if(item['@type']) {\n          item['@type'] = [key].concat(item['@type']);\n        } else {\n          item['@type'] = [key];\n        }\n      } else if(_isValue(item) &&\n        !['@language', '@type', '@index'].includes(indexKey)) {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; Attempt to add illegal key to value ' +\n          `object: \"${indexKey}\".`,\n          'jsonld.SyntaxError',\n          {code: 'invalid value object', value: item});\n      } else if(propertyIndex) {\n        // index is a property to be expanded, and values interpreted for that\n        // property\n        if(expandedKey !== '@none') {\n          // expand key as a value\n          _addValue(item, propertyIndex, expandedKey, {\n            propertyIsArray: true,\n            prependValue: true\n          });\n        }\n      } else if(expandedKey !== '@none' && !(indexKey in item)) {\n        item[indexKey] = key;\n      }\n      rval.push(item);\n    }\n  }\n  return rval;\n}\n","/*\n * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst {\n  isSubjectReference: _isSubjectReference\n} = require('./graphTypes');\n\nconst {\n  createMergedNodeMap: _createMergedNodeMap\n} = require('./nodeMap');\n\nconst api = {};\nmodule.exports = api;\n\n/**\n * Performs JSON-LD flattening.\n *\n * @param input the expanded JSON-LD to flatten.\n *\n * @return the flattened output.\n */\napi.flatten = input => {\n  const defaultGraph = _createMergedNodeMap(input);\n\n  // produce flattened output\n  const flattened = [];\n  const keys = Object.keys(defaultGraph).sort();\n  for(let ki = 0; ki < keys.length; ++ki) {\n    const node = defaultGraph[keys[ki]];\n    // only add full subjects to top-level\n    if(!_isSubjectReference(node)) {\n      flattened.push(node);\n    }\n  }\n  return flattened;\n};\n","/*\n * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst {isKeyword} = require('./context');\nconst graphTypes = require('./graphTypes');\nconst types = require('./types');\nconst util = require('./util');\nconst url = require('./url');\nconst JsonLdError = require('./JsonLdError');\nconst {\n  createNodeMap: _createNodeMap,\n  mergeNodeMapGraphs: _mergeNodeMapGraphs\n} = require('./nodeMap');\n\nconst api = {};\nmodule.exports = api;\n\n/**\n * Performs JSON-LD `merged` framing.\n *\n * @param input the expanded JSON-LD to frame.\n * @param frame the expanded JSON-LD frame to use.\n * @param options the framing options.\n *\n * @return the framed output.\n */\napi.frameMergedOrDefault = (input, frame, options) => {\n  // create framing state\n  const state = {\n    options,\n    embedded: false,\n    graph: '@default',\n    graphMap: {'@default': {}},\n    subjectStack: [],\n    link: {},\n    bnodeMap: {}\n  };\n\n  // produce a map of all graphs and name each bnode\n  // FIXME: currently uses subjects from @merged graph only\n  const issuer = new util.IdentifierIssuer('_:b');\n  _createNodeMap(input, state.graphMap, '@default', issuer);\n  if(options.merged) {\n    state.graphMap['@merged'] = _mergeNodeMapGraphs(state.graphMap);\n    state.graph = '@merged';\n  }\n  state.subjects = state.graphMap[state.graph];\n\n  // frame the subjects\n  const framed = [];\n  api.frame(state, Object.keys(state.subjects).sort(), frame, framed);\n\n  // If pruning blank nodes, find those to prune\n  if(options.pruneBlankNodeIdentifiers) {\n    // remove all blank nodes appearing only once, done in compaction\n    options.bnodesToClear =\n      Object.keys(state.bnodeMap).filter(id => state.bnodeMap[id].length === 1);\n  }\n\n  // remove @preserve from results\n  options.link = {};\n  return _cleanupPreserve(framed, options);\n};\n\n/**\n * Frames subjects according to the given frame.\n *\n * @param state the current framing state.\n * @param subjects the subjects to filter.\n * @param frame the frame.\n * @param parent the parent subject or top-level array.\n * @param property the parent property, initialized to null.\n */\napi.frame = (state, subjects, frame, parent, property = null) => {\n  // validate the frame\n  _validateFrame(frame);\n  frame = frame[0];\n\n  // get flags for current frame\n  const options = state.options;\n  const flags = {\n    embed: _getFrameFlag(frame, options, 'embed'),\n    explicit: _getFrameFlag(frame, options, 'explicit'),\n    requireAll: _getFrameFlag(frame, options, 'requireAll')\n  };\n\n  // get link for current graph\n  if(!state.link.hasOwnProperty(state.graph)) {\n    state.link[state.graph] = {};\n  }\n  const link = state.link[state.graph];\n\n  // filter out subjects that match the frame\n  const matches = _filterSubjects(state, subjects, frame, flags);\n\n  // add matches to output\n  const ids = Object.keys(matches).sort();\n  for(const id of ids) {\n    const subject = matches[id];\n\n    /* Note: In order to treat each top-level match as a compartmentalized\n    result, clear the unique embedded subjects map when the property is null,\n    which only occurs at the top-level. */\n    if(property === null) {\n      state.uniqueEmbeds = {[state.graph]: {}};\n    } else {\n      state.uniqueEmbeds[state.graph] = state.uniqueEmbeds[state.graph] || {};\n    }\n\n    if(flags.embed === '@link' && id in link) {\n      // TODO: may want to also match an existing linked subject against\n      // the current frame ... so different frames could produce different\n      // subjects that are only shared in-memory when the frames are the same\n\n      // add existing linked subject\n      _addFrameOutput(parent, property, link[id]);\n      continue;\n    }\n\n    // start output for subject\n    const output = {'@id': id};\n    if(id.indexOf('_:') === 0) {\n      util.addValue(state.bnodeMap, id, output, {propertyIsArray: true});\n    }\n    link[id] = output;\n\n    // validate @embed\n    if((flags.embed === '@first' || flags.embed === '@last') && state.is11) {\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; invalid value of @embed.',\n        'jsonld.SyntaxError', {code: 'invalid @embed value', frame});\n    }\n\n    if(!state.embedded && state.uniqueEmbeds[state.graph].hasOwnProperty(id)) {\n      // skip adding this node object to the top level, as it was\n      // already included in another node object\n      continue;\n    }\n\n    // if embed is @never or if a circular reference would be created by an\n    // embed, the subject cannot be embedded, just add the reference;\n    // note that a circular reference won't occur when the embed flag is\n    // `@link` as the above check will short-circuit before reaching this point\n    if(state.embedded &&\n      (flags.embed === '@never' ||\n      _createsCircularReference(subject, state.graph, state.subjectStack))) {\n      _addFrameOutput(parent, property, output);\n      continue;\n    }\n\n    // if only the first (or once) should be embedded\n    if(state.embedded &&\n       (flags.embed == '@first' || flags.embed == '@once') &&\n       state.uniqueEmbeds[state.graph].hasOwnProperty(id)) {\n      _addFrameOutput(parent, property, output);\n      continue;\n    }\n\n    // if only the last match should be embedded\n    if(flags.embed === '@last') {\n      // remove any existing embed\n      if(id in state.uniqueEmbeds[state.graph]) {\n        _removeEmbed(state, id);\n      }\n    }\n\n    state.uniqueEmbeds[state.graph][id] = {parent, property};\n\n    // push matching subject onto stack to enable circular embed checks\n    state.subjectStack.push({subject, graph: state.graph});\n\n    // subject is also the name of a graph\n    if(id in state.graphMap) {\n      let recurse = false;\n      let subframe = null;\n      if(!('@graph' in frame)) {\n        recurse = state.graph !== '@merged';\n        subframe = {};\n      } else {\n        subframe = frame['@graph'][0];\n        recurse = !(id === '@merged' || id === '@default');\n        if(!types.isObject(subframe)) {\n          subframe = {};\n        }\n      }\n\n      if(recurse) {\n        // recurse into graph\n        api.frame(\n          {...state, graph: id, embedded: false},\n          Object.keys(state.graphMap[id]).sort(), [subframe], output, '@graph');\n      }\n    }\n\n    // if frame has @included, recurse over its sub-frame\n    if('@included' in frame) {\n      api.frame(\n        {...state, embedded: false},\n        subjects, frame['@included'], output, '@included');\n    }\n\n    // iterate over subject properties\n    for(const prop of Object.keys(subject).sort()) {\n      // copy keywords to output\n      if(isKeyword(prop)) {\n        output[prop] = util.clone(subject[prop]);\n\n        if(prop === '@type') {\n          // count bnode values of @type\n          for(const type of subject['@type']) {\n            if(type.indexOf('_:') === 0) {\n              util.addValue(\n                state.bnodeMap, type, output, {propertyIsArray: true});\n            }\n          }\n        }\n        continue;\n      }\n\n      // explicit is on and property isn't in the frame, skip processing\n      if(flags.explicit && !(prop in frame)) {\n        continue;\n      }\n\n      // add objects\n      for(const o of subject[prop]) {\n        const subframe = (prop in frame ?\n          frame[prop] : _createImplicitFrame(flags));\n\n        // recurse into list\n        if(graphTypes.isList(o)) {\n          const subframe =\n            (frame[prop] && frame[prop][0] && frame[prop][0]['@list']) ?\n              frame[prop][0]['@list'] :\n              _createImplicitFrame(flags);\n\n          // add empty list\n          const list = {'@list': []};\n          _addFrameOutput(output, prop, list);\n\n          // add list objects\n          const src = o['@list'];\n          for(const oo of src) {\n            if(graphTypes.isSubjectReference(oo)) {\n              // recurse into subject reference\n              api.frame(\n                {...state, embedded: true},\n                [oo['@id']], subframe, list, '@list');\n            } else {\n              // include other values automatically\n              _addFrameOutput(list, '@list', util.clone(oo));\n            }\n          }\n        } else if(graphTypes.isSubjectReference(o)) {\n          // recurse into subject reference\n          api.frame(\n            {...state, embedded: true},\n            [o['@id']], subframe, output, prop);\n        } else if(_valueMatch(subframe[0], o)) {\n          // include other values, if they match\n          _addFrameOutput(output, prop, util.clone(o));\n        }\n      }\n    }\n\n    // handle defaults\n    for(const prop of Object.keys(frame).sort()) {\n      // skip keywords\n      if(prop === '@type') {\n        if(!types.isObject(frame[prop][0]) ||\n           !('@default' in frame[prop][0])) {\n          continue;\n        }\n        // allow through default types\n      } else if(isKeyword(prop)) {\n        continue;\n      }\n\n      // if omit default is off, then include default values for properties\n      // that appear in the next frame but are not in the matching subject\n      const next = frame[prop][0] || {};\n      const omitDefaultOn = _getFrameFlag(next, options, 'omitDefault');\n      if(!omitDefaultOn && !(prop in output)) {\n        let preserve = '@null';\n        if('@default' in next) {\n          preserve = util.clone(next['@default']);\n        }\n        if(!types.isArray(preserve)) {\n          preserve = [preserve];\n        }\n        output[prop] = [{'@preserve': preserve}];\n      }\n    }\n\n    // if embed reverse values by finding nodes having this subject as a value\n    // of the associated property\n    for(const reverseProp of Object.keys(frame['@reverse'] || {}).sort()) {\n      const subframe = frame['@reverse'][reverseProp];\n      for(const subject of Object.keys(state.subjects)) {\n        const nodeValues =\n          util.getValues(state.subjects[subject], reverseProp);\n        if(nodeValues.some(v => v['@id'] === id)) {\n          // node has property referencing this subject, recurse\n          output['@reverse'] = output['@reverse'] || {};\n          util.addValue(\n            output['@reverse'], reverseProp, [], {propertyIsArray: true});\n          api.frame(\n            {...state, embedded: true},\n            [subject], subframe, output['@reverse'][reverseProp],\n            property);\n        }\n      }\n    }\n\n    // add output to parent\n    _addFrameOutput(parent, property, output);\n\n    // pop matching subject from circular ref-checking stack\n    state.subjectStack.pop();\n  }\n};\n\n/**\n * Replace `@null` with `null`, removing it from arrays.\n *\n * @param input the framed, compacted output.\n * @param options the framing options used.\n *\n * @return the resulting output.\n */\napi.cleanupNull = (input, options) => {\n  // recurse through arrays\n  if(types.isArray(input)) {\n    const noNulls = input.map(v => api.cleanupNull(v, options));\n    return noNulls.filter(v => v); // removes nulls from array\n  }\n\n  if(input === '@null') {\n    return null;\n  }\n\n  if(types.isObject(input)) {\n    // handle in-memory linked nodes\n    if('@id' in input) {\n      const id = input['@id'];\n      if(options.link.hasOwnProperty(id)) {\n        const idx = options.link[id].indexOf(input);\n        if(idx !== -1) {\n          // already visited\n          return options.link[id][idx];\n        }\n        // prevent circular visitation\n        options.link[id].push(input);\n      } else {\n        // prevent circular visitation\n        options.link[id] = [input];\n      }\n    }\n\n    for(const key in input) {\n      input[key] = api.cleanupNull(input[key], options);\n    }\n  }\n  return input;\n};\n\n/**\n * Creates an implicit frame when recursing through subject matches. If\n * a frame doesn't have an explicit frame for a particular property, then\n * a wildcard child frame will be created that uses the same flags that the\n * parent frame used.\n *\n * @param flags the current framing flags.\n *\n * @return the implicit frame.\n */\nfunction _createImplicitFrame(flags) {\n  const frame = {};\n  for(const key in flags) {\n    if(flags[key] !== undefined) {\n      frame['@' + key] = [flags[key]];\n    }\n  }\n  return [frame];\n}\n\n/**\n * Checks the current subject stack to see if embedding the given subject\n * would cause a circular reference.\n *\n * @param subjectToEmbed the subject to embed.\n * @param graph the graph the subject to embed is in.\n * @param subjectStack the current stack of subjects.\n *\n * @return true if a circular reference would be created, false if not.\n */\nfunction _createsCircularReference(subjectToEmbed, graph, subjectStack) {\n  for(let i = subjectStack.length - 1; i >= 0; --i) {\n    const subject = subjectStack[i];\n    if(subject.graph === graph &&\n      subject.subject['@id'] === subjectToEmbed['@id']) {\n      return true;\n    }\n  }\n  return false;\n}\n\n/**\n * Gets the frame flag value for the given flag name.\n *\n * @param frame the frame.\n * @param options the framing options.\n * @param name the flag name.\n *\n * @return the flag value.\n */\nfunction _getFrameFlag(frame, options, name) {\n  const flag = '@' + name;\n  let rval = (flag in frame ? frame[flag][0] : options[name]);\n  if(name === 'embed') {\n    // default is \"@last\"\n    // backwards-compatibility support for \"embed\" maps:\n    // true => \"@last\"\n    // false => \"@never\"\n    if(rval === true) {\n      rval = '@once';\n    } else if(rval === false) {\n      rval = '@never';\n    } else if(rval !== '@always' && rval !== '@never' && rval !== '@link' &&\n      rval !== '@first' && rval !== '@last' && rval !== '@once') {\n      throw new JsonLdError(\n        'Invalid JSON-LD syntax; invalid value of @embed.',\n        'jsonld.SyntaxError', {code: 'invalid @embed value', frame});\n    }\n  }\n  return rval;\n}\n\n/**\n * Validates a JSON-LD frame, throwing an exception if the frame is invalid.\n *\n * @param frame the frame to validate.\n */\nfunction _validateFrame(frame) {\n  if(!types.isArray(frame) || frame.length !== 1 || !types.isObject(frame[0])) {\n    throw new JsonLdError(\n      'Invalid JSON-LD syntax; a JSON-LD frame must be a single object.',\n      'jsonld.SyntaxError', {frame});\n  }\n\n  if('@id' in frame[0]) {\n    for(const id of util.asArray(frame[0]['@id'])) {\n      // @id must be wildcard or an IRI\n      if(!(types.isObject(id) || url.isAbsolute(id)) ||\n        (types.isString(id) && id.indexOf('_:') === 0)) {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; invalid @id in frame.',\n          'jsonld.SyntaxError', {code: 'invalid frame', frame});\n      }\n    }\n  }\n\n  if('@type' in frame[0]) {\n    for(const type of util.asArray(frame[0]['@type'])) {\n      // @type must be wildcard, IRI, or @json\n      if(!(types.isObject(type) || url.isAbsolute(type) ||\n          (type === '@json')) ||\n        (types.isString(type) && type.indexOf('_:') === 0)) {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; invalid @type in frame.',\n          'jsonld.SyntaxError', {code: 'invalid frame', frame});\n      }\n    }\n  }\n}\n\n/**\n * Returns a map of all of the subjects that match a parsed frame.\n *\n * @param state the current framing state.\n * @param subjects the set of subjects to filter.\n * @param frame the parsed frame.\n * @param flags the frame flags.\n *\n * @return all of the matched subjects.\n */\nfunction _filterSubjects(state, subjects, frame, flags) {\n  // filter subjects in @id order\n  const rval = {};\n  for(const id of subjects) {\n    const subject = state.graphMap[state.graph][id];\n    if(_filterSubject(state, subject, frame, flags)) {\n      rval[id] = subject;\n    }\n  }\n  return rval;\n}\n\n/**\n * Returns true if the given subject matches the given frame.\n *\n * Matches either based on explicit type inclusion where the node has any\n * type listed in the frame. If the frame has empty types defined matches\n * nodes not having a @type. If the frame has a type of {} defined matches\n * nodes having any type defined.\n *\n * Otherwise, does duck typing, where the node must have all of the\n * properties defined in the frame.\n *\n * @param state the current framing state.\n * @param subject the subject to check.\n * @param frame the frame to check.\n * @param flags the frame flags.\n *\n * @return true if the subject matches, false if not.\n */\nfunction _filterSubject(state, subject, frame, flags) {\n  // check ducktype\n  let wildcard = true;\n  let matchesSome = false;\n\n  for(const key in frame) {\n    let matchThis = false;\n    const nodeValues = util.getValues(subject, key);\n    const isEmpty = util.getValues(frame, key).length === 0;\n\n    if(key === '@id') {\n      // match on no @id or any matching @id, including wildcard\n      if(types.isEmptyObject(frame['@id'][0] || {})) {\n        matchThis = true;\n      } else if(frame['@id'].length >= 0) {\n        matchThis = frame['@id'].includes(nodeValues[0]);\n      }\n      if(!flags.requireAll) {\n        return matchThis;\n      }\n    } else if(key === '@type') {\n      // check @type (object value means 'any' type,\n      // fall through to ducktyping)\n      wildcard = false;\n      if(isEmpty) {\n        if(nodeValues.length > 0) {\n          // don't match on no @type\n          return false;\n        }\n        matchThis = true;\n      } else if(frame['@type'].length === 1 &&\n        types.isEmptyObject(frame['@type'][0])) {\n        // match on wildcard @type if there is a type\n        matchThis = nodeValues.length > 0;\n      } else {\n        // match on a specific @type\n        for(const type of frame['@type']) {\n          if(types.isObject(type) && '@default' in type) {\n            // match on default object\n            matchThis = true;\n          } else {\n            matchThis = matchThis || nodeValues.some(tt => tt === type);\n          }\n        }\n      }\n      if(!flags.requireAll) {\n        return matchThis;\n      }\n    } else if(isKeyword(key)) {\n      continue;\n    } else {\n      // Force a copy of this frame entry so it can be manipulated\n      const thisFrame = util.getValues(frame, key)[0];\n      let hasDefault = false;\n      if(thisFrame) {\n        _validateFrame([thisFrame]);\n        hasDefault = '@default' in thisFrame;\n      }\n\n      // no longer a wildcard pattern if frame has any non-keyword properties\n      wildcard = false;\n\n      // skip, but allow match if node has no value for property, and frame has\n      // a default value\n      if(nodeValues.length === 0 && hasDefault) {\n        continue;\n      }\n\n      // if frame value is empty, don't match if subject has any value\n      if(nodeValues.length > 0 && isEmpty) {\n        return false;\n      }\n\n      if(thisFrame === undefined) {\n        // node does not match if values is not empty and the value of property\n        // in frame is match none.\n        if(nodeValues.length > 0) {\n          return false;\n        }\n        matchThis = true;\n      } else {\n        if(graphTypes.isList(thisFrame)) {\n          const listValue = thisFrame['@list'][0];\n          if(graphTypes.isList(nodeValues[0])) {\n            const nodeListValues = nodeValues[0]['@list'];\n\n            if(graphTypes.isValue(listValue)) {\n              // match on any matching value\n              matchThis = nodeListValues.some(lv => _valueMatch(listValue, lv));\n            } else if(graphTypes.isSubject(listValue) ||\n              graphTypes.isSubjectReference(listValue)) {\n              matchThis = nodeListValues.some(lv => _nodeMatch(\n                state, listValue, lv, flags));\n            }\n          }\n        } else if(graphTypes.isValue(thisFrame)) {\n          matchThis = nodeValues.some(nv => _valueMatch(thisFrame, nv));\n        } else if(graphTypes.isSubjectReference(thisFrame)) {\n          matchThis =\n            nodeValues.some(nv => _nodeMatch(state, thisFrame, nv, flags));\n        } else if(types.isObject(thisFrame)) {\n          matchThis = nodeValues.length > 0;\n        } else {\n          matchThis = false;\n        }\n      }\n    }\n\n    // all non-defaulted values must match if requireAll is set\n    if(!matchThis && flags.requireAll) {\n      return false;\n    }\n\n    matchesSome = matchesSome || matchThis;\n  }\n\n  // return true if wildcard or subject matches some properties\n  return wildcard || matchesSome;\n}\n\n/**\n * Removes an existing embed.\n *\n * @param state the current framing state.\n * @param id the @id of the embed to remove.\n */\nfunction _removeEmbed(state, id) {\n  // get existing embed\n  const embeds = state.uniqueEmbeds[state.graph];\n  const embed = embeds[id];\n  const parent = embed.parent;\n  const property = embed.property;\n\n  // create reference to replace embed\n  const subject = {'@id': id};\n\n  // remove existing embed\n  if(types.isArray(parent)) {\n    // replace subject with reference\n    for(let i = 0; i < parent.length; ++i) {\n      if(util.compareValues(parent[i], subject)) {\n        parent[i] = subject;\n        break;\n      }\n    }\n  } else {\n    // replace subject with reference\n    const useArray = types.isArray(parent[property]);\n    util.removeValue(parent, property, subject, {propertyIsArray: useArray});\n    util.addValue(parent, property, subject, {propertyIsArray: useArray});\n  }\n\n  // recursively remove dependent dangling embeds\n  const removeDependents = id => {\n    // get embed keys as a separate array to enable deleting keys in map\n    const ids = Object.keys(embeds);\n    for(const next of ids) {\n      if(next in embeds && types.isObject(embeds[next].parent) &&\n        embeds[next].parent['@id'] === id) {\n        delete embeds[next];\n        removeDependents(next);\n      }\n    }\n  };\n  removeDependents(id);\n}\n\n/**\n * Removes the @preserve keywords from expanded result of framing.\n *\n * @param input the framed, framed output.\n * @param options the framing options used.\n *\n * @return the resulting output.\n */\nfunction _cleanupPreserve(input, options) {\n  // recurse through arrays\n  if(types.isArray(input)) {\n    return input.map(value => _cleanupPreserve(value, options));\n  }\n\n  if(types.isObject(input)) {\n    // remove @preserve\n    if('@preserve' in input) {\n      return input['@preserve'][0];\n    }\n\n    // skip @values\n    if(graphTypes.isValue(input)) {\n      return input;\n    }\n\n    // recurse through @lists\n    if(graphTypes.isList(input)) {\n      input['@list'] = _cleanupPreserve(input['@list'], options);\n      return input;\n    }\n\n    // handle in-memory linked nodes\n    if('@id' in input) {\n      const id = input['@id'];\n      if(options.link.hasOwnProperty(id)) {\n        const idx = options.link[id].indexOf(input);\n        if(idx !== -1) {\n          // already visited\n          return options.link[id][idx];\n        }\n        // prevent circular visitation\n        options.link[id].push(input);\n      } else {\n        // prevent circular visitation\n        options.link[id] = [input];\n      }\n    }\n\n    // recurse through properties\n    for(const prop in input) {\n      // potentially remove the id, if it is an unreference bnode\n      if(prop === '@id' && options.bnodesToClear.includes(input[prop])) {\n        delete input['@id'];\n        continue;\n      }\n\n      input[prop] = _cleanupPreserve(input[prop], options);\n    }\n  }\n  return input;\n}\n\n/**\n * Adds framing output to the given parent.\n *\n * @param parent the parent to add to.\n * @param property the parent property.\n * @param output the output to add.\n */\nfunction _addFrameOutput(parent, property, output) {\n  if(types.isObject(parent)) {\n    util.addValue(parent, property, output, {propertyIsArray: true});\n  } else {\n    parent.push(output);\n  }\n}\n\n/**\n * Node matches if it is a node, and matches the pattern as a frame.\n *\n * @param state the current framing state.\n * @param pattern used to match value\n * @param value to check\n * @param flags the frame flags.\n */\nfunction _nodeMatch(state, pattern, value, flags) {\n  if(!('@id' in value)) {\n    return false;\n  }\n  const nodeObject = state.subjects[value['@id']];\n  return nodeObject && _filterSubject(state, nodeObject, pattern, flags);\n}\n\n/**\n * Value matches if it is a value and matches the value pattern\n *\n * * `pattern` is empty\n * * @values are the same, or `pattern[@value]` is a wildcard, and\n * * @types are the same or `value[@type]` is not null\n *   and `pattern[@type]` is `{}`, or `value[@type]` is null\n *   and `pattern[@type]` is null or `[]`, and\n * * @languages are the same or `value[@language]` is not null\n *   and `pattern[@language]` is `{}`, or `value[@language]` is null\n *   and `pattern[@language]` is null or `[]`.\n *\n * @param pattern used to match value\n * @param value to check\n */\nfunction _valueMatch(pattern, value) {\n  const v1 = value['@value'];\n  const t1 = value['@type'];\n  const l1 = value['@language'];\n  const v2 = pattern['@value'] ?\n    (types.isArray(pattern['@value']) ?\n      pattern['@value'] : [pattern['@value']]) :\n    [];\n  const t2 = pattern['@type'] ?\n    (types.isArray(pattern['@type']) ?\n      pattern['@type'] : [pattern['@type']]) :\n    [];\n  const l2 = pattern['@language'] ?\n    (types.isArray(pattern['@language']) ?\n      pattern['@language'] : [pattern['@language']]) :\n    [];\n\n  if(v2.length === 0 && t2.length === 0 && l2.length === 0) {\n    return true;\n  }\n  if(!(v2.includes(v1) || types.isEmptyObject(v2[0]))) {\n    return false;\n  }\n  if(!(!t1 && t2.length === 0 || t2.includes(t1) || t1 &&\n    types.isEmptyObject(t2[0]))) {\n    return false;\n  }\n  if(!(!l1 && l2.length === 0 || l2.includes(l1) || l1 &&\n    types.isEmptyObject(l2[0]))) {\n    return false;\n  }\n  return true;\n}\n","/*\n * Copyright (c) 2017-2023 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst JsonLdError = require('./JsonLdError');\nconst graphTypes = require('./graphTypes');\nconst types = require('./types');\n\nconst {\n  REGEX_BCP47,\n  addValue: _addValue\n} = require('./util');\n\nconst {\n  handleEvent: _handleEvent\n} = require('./events');\n\n// constants\nconst {\n  // RDF,\n  RDF_LIST,\n  RDF_FIRST,\n  RDF_REST,\n  RDF_NIL,\n  RDF_TYPE,\n  // RDF_PLAIN_LITERAL,\n  // RDF_XML_LITERAL,\n  RDF_JSON_LITERAL,\n  // RDF_OBJECT,\n  // RDF_LANGSTRING,\n\n  // XSD,\n  XSD_BOOLEAN,\n  XSD_DOUBLE,\n  XSD_INTEGER,\n  XSD_STRING,\n} = require('./constants');\n\nconst api = {};\nmodule.exports = api;\n\n/**\n * Converts an RDF dataset to JSON-LD.\n *\n * @param dataset the RDF dataset.\n * @param options the RDF serialization options.\n *\n * @return a Promise that resolves to the JSON-LD output.\n */\napi.fromRDF = async (\n  dataset,\n  options\n) => {\n  const {\n    useRdfType = false,\n    useNativeTypes = false,\n    rdfDirection = null\n  } = options;\n  // FIXME: use Maps?\n  const defaultGraph = {};\n  const graphMap = {'@default': defaultGraph};\n  const referencedOnce = {};\n  if(rdfDirection) {\n    if(rdfDirection === 'compound-literal') {\n      throw new JsonLdError(\n        'Unsupported rdfDirection value.',\n        'jsonld.InvalidRdfDirection',\n        {value: rdfDirection});\n    } else if(rdfDirection !== 'i18n-datatype') {\n      throw new JsonLdError(\n        'Unknown rdfDirection value.',\n        'jsonld.InvalidRdfDirection',\n        {value: rdfDirection});\n    }\n  }\n\n  for(const quad of dataset) {\n    // TODO: change 'name' to 'graph'\n    const name = (quad.graph.termType === 'DefaultGraph') ?\n      '@default' : quad.graph.value;\n    if(!(name in graphMap)) {\n      graphMap[name] = {};\n    }\n    if(name !== '@default' && !(name in defaultGraph)) {\n      defaultGraph[name] = {'@id': name};\n    }\n\n    const nodeMap = graphMap[name];\n\n    // get subject, predicate, object\n    const s = quad.subject.value;\n    const p = quad.predicate.value;\n    const o = quad.object;\n\n    if(!(s in nodeMap)) {\n      nodeMap[s] = {'@id': s};\n    }\n    const node = nodeMap[s];\n\n    const objectIsNode = o.termType.endsWith('Node');\n    if(objectIsNode && !(o.value in nodeMap)) {\n      nodeMap[o.value] = {'@id': o.value};\n    }\n\n    if(p === RDF_TYPE && !useRdfType && objectIsNode) {\n      _addValue(node, '@type', o.value, {propertyIsArray: true});\n      continue;\n    }\n\n    const value = _RDFToObject(o, useNativeTypes, rdfDirection, options);\n    _addValue(node, p, value, {propertyIsArray: true});\n\n    // object may be an RDF list/partial list node but we can't know easily\n    // until all triples are read\n    if(objectIsNode) {\n      if(o.value === RDF_NIL) {\n        // track rdf:nil uniquely per graph\n        const object = nodeMap[o.value];\n        if(!('usages' in object)) {\n          object.usages = [];\n        }\n        object.usages.push({\n          node,\n          property: p,\n          value\n        });\n      } else if(o.value in referencedOnce) {\n        // object referenced more than once\n        referencedOnce[o.value] = false;\n      } else {\n        // keep track of single reference\n        referencedOnce[o.value] = {\n          node,\n          property: p,\n          value\n        };\n      }\n    }\n  }\n\n  /*\n  for(let name in dataset) {\n    const graph = dataset[name];\n    if(!(name in graphMap)) {\n      graphMap[name] = {};\n    }\n    if(name !== '@default' && !(name in defaultGraph)) {\n      defaultGraph[name] = {'@id': name};\n    }\n    const nodeMap = graphMap[name];\n    for(let ti = 0; ti < graph.length; ++ti) {\n      const triple = graph[ti];\n\n      // get subject, predicate, object\n      const s = triple.subject.value;\n      const p = triple.predicate.value;\n      const o = triple.object;\n\n      if(!(s in nodeMap)) {\n        nodeMap[s] = {'@id': s};\n      }\n      const node = nodeMap[s];\n\n      const objectIsId = (o.type === 'IRI' || o.type === 'blank node');\n      if(objectIsId && !(o.value in nodeMap)) {\n        nodeMap[o.value] = {'@id': o.value};\n      }\n\n      if(p === RDF_TYPE && !useRdfType && objectIsId) {\n        _addValue(node, '@type', o.value, {propertyIsArray: true});\n        continue;\n      }\n\n      const value = _RDFToObject(o, useNativeTypes);\n      _addValue(node, p, value, {propertyIsArray: true});\n\n      // object may be an RDF list/partial list node but we can't know easily\n      // until all triples are read\n      if(objectIsId) {\n        if(o.value === RDF_NIL) {\n          // track rdf:nil uniquely per graph\n          const object = nodeMap[o.value];\n          if(!('usages' in object)) {\n            object.usages = [];\n          }\n          object.usages.push({\n            node: node,\n            property: p,\n            value: value\n          });\n        } else if(o.value in referencedOnce) {\n          // object referenced more than once\n          referencedOnce[o.value] = false;\n        } else {\n          // keep track of single reference\n          referencedOnce[o.value] = {\n            node: node,\n            property: p,\n            value: value\n          };\n        }\n      }\n    }\n  }*/\n\n  // convert linked lists to @list arrays\n  for(const name in graphMap) {\n    const graphObject = graphMap[name];\n\n    // no @lists to be converted, continue\n    if(!(RDF_NIL in graphObject)) {\n      continue;\n    }\n\n    // iterate backwards through each RDF list\n    const nil = graphObject[RDF_NIL];\n    if(!nil.usages) {\n      continue;\n    }\n    for(let usage of nil.usages) {\n      let node = usage.node;\n      let property = usage.property;\n      let head = usage.value;\n      const list = [];\n      const listNodes = [];\n\n      // ensure node is a well-formed list node; it must:\n      // 1. Be referenced only once.\n      // 2. Have an array for rdf:first that has 1 item.\n      // 3. Have an array for rdf:rest that has 1 item.\n      // 4. Have no keys other than: @id, rdf:first, rdf:rest, and,\n      //   optionally, @type where the value is rdf:List.\n      let nodeKeyCount = Object.keys(node).length;\n      while(property === RDF_REST &&\n        types.isObject(referencedOnce[node['@id']]) &&\n        types.isArray(node[RDF_FIRST]) && node[RDF_FIRST].length === 1 &&\n        types.isArray(node[RDF_REST]) && node[RDF_REST].length === 1 &&\n        (nodeKeyCount === 3 ||\n          (nodeKeyCount === 4 && types.isArray(node['@type']) &&\n          node['@type'].length === 1 && node['@type'][0] === RDF_LIST))) {\n        list.push(node[RDF_FIRST][0]);\n        listNodes.push(node['@id']);\n\n        // get next node, moving backwards through list\n        usage = referencedOnce[node['@id']];\n        node = usage.node;\n        property = usage.property;\n        head = usage.value;\n        nodeKeyCount = Object.keys(node).length;\n\n        // if node is not a blank node, then list head found\n        if(!graphTypes.isBlankNode(node)) {\n          break;\n        }\n      }\n\n      // transform list into @list object\n      delete head['@id'];\n      head['@list'] = list.reverse();\n      for(const listNode of listNodes) {\n        delete graphObject[listNode];\n      }\n    }\n\n    delete nil.usages;\n  }\n\n  const result = [];\n  const subjects = Object.keys(defaultGraph).sort();\n  for(const subject of subjects) {\n    const node = defaultGraph[subject];\n    if(subject in graphMap) {\n      const graph = node['@graph'] = [];\n      const graphObject = graphMap[subject];\n      const graphSubjects = Object.keys(graphObject).sort();\n      for(const graphSubject of graphSubjects) {\n        const node = graphObject[graphSubject];\n        // only add full subjects to top-level\n        if(!graphTypes.isSubjectReference(node)) {\n          graph.push(node);\n        }\n      }\n    }\n    // only add full subjects to top-level\n    if(!graphTypes.isSubjectReference(node)) {\n      result.push(node);\n    }\n  }\n\n  return result;\n};\n\n/**\n * Converts an RDF triple object to a JSON-LD object.\n *\n * @param o the RDF triple object to convert.\n * @param useNativeTypes true to output native types, false not to.\n * @param rdfDirection text direction mode [null, i18n-datatype]\n * @param options top level API options\n *\n * @return the JSON-LD object.\n */\nfunction _RDFToObject(o, useNativeTypes, rdfDirection, options) {\n  // convert NamedNode/BlankNode object to JSON-LD\n  if(o.termType.endsWith('Node')) {\n    return {'@id': o.value};\n  }\n\n  // convert literal to JSON-LD\n  const rval = {'@value': o.value};\n\n  // add language\n  if(o.language) {\n    if(!o.language.match(REGEX_BCP47)) {\n      if(options.eventHandler) {\n        _handleEvent({\n          event: {\n            type: ['JsonLdEvent'],\n            code: 'invalid @language value',\n            level: 'warning',\n            message: '@language value must be valid BCP47.',\n            details: {\n              language: o.language\n            }\n          },\n          options\n        });\n      }\n    }\n    rval['@language'] = o.language;\n  } else {\n    let type = o.datatype.value;\n    if(!type) {\n      type = XSD_STRING;\n    }\n    if(type === RDF_JSON_LITERAL) {\n      type = '@json';\n      try {\n        rval['@value'] = JSON.parse(rval['@value']);\n      } catch(e) {\n        throw new JsonLdError(\n          'JSON literal could not be parsed.',\n          'jsonld.InvalidJsonLiteral',\n          {code: 'invalid JSON literal', value: rval['@value'], cause: e});\n      }\n    }\n    // use native types for certain xsd types\n    if(useNativeTypes) {\n      if(type === XSD_BOOLEAN) {\n        if(rval['@value'] === 'true') {\n          rval['@value'] = true;\n        } else if(rval['@value'] === 'false') {\n          rval['@value'] = false;\n        }\n      } else if(types.isNumeric(rval['@value'])) {\n        if(type === XSD_INTEGER) {\n          const i = parseInt(rval['@value'], 10);\n          if(i.toFixed(0) === rval['@value']) {\n            rval['@value'] = i;\n          }\n        } else if(type === XSD_DOUBLE) {\n          rval['@value'] = parseFloat(rval['@value']);\n        }\n      }\n      // do not add native type\n      if(![XSD_BOOLEAN, XSD_INTEGER, XSD_DOUBLE, XSD_STRING].includes(type)) {\n        rval['@type'] = type;\n      }\n    } else if(rdfDirection === 'i18n-datatype' &&\n      type.startsWith('https://www.w3.org/ns/i18n#')) {\n      const [, language, direction] = type.split(/[#_]/);\n      if(language.length > 0) {\n        rval['@language'] = language;\n        if(!language.match(REGEX_BCP47)) {\n          if(options.eventHandler) {\n            _handleEvent({\n              event: {\n                type: ['JsonLdEvent'],\n                code: 'invalid @language value',\n                level: 'warning',\n                message: '@language value must be valid BCP47.',\n                details: {\n                  language\n                }\n              },\n              options\n            });\n          }\n        }\n      }\n      rval['@direction'] = direction;\n    } else if(type !== XSD_STRING) {\n      rval['@type'] = type;\n    }\n  }\n\n  return rval;\n}\n","/*\n * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst types = require('./types');\n\nconst api = {};\nmodule.exports = api;\n\n/**\n * Returns true if the given value is a subject with properties.\n *\n * @param v the value to check.\n *\n * @return true if the value is a subject with properties, false if not.\n */\napi.isSubject = v => {\n  // Note: A value is a subject if all of these hold true:\n  // 1. It is an Object.\n  // 2. It is not a @value, @set, or @list.\n  // 3. It has more than 1 key OR any existing key is not @id.\n  if(types.isObject(v) &&\n    !(('@value' in v) || ('@set' in v) || ('@list' in v))) {\n    const keyCount = Object.keys(v).length;\n    return (keyCount > 1 || !('@id' in v));\n  }\n  return false;\n};\n\n/**\n * Returns true if the given value is a subject reference.\n *\n * @param v the value to check.\n *\n * @return true if the value is a subject reference, false if not.\n */\napi.isSubjectReference = v =>\n  // Note: A value is a subject reference if all of these hold true:\n  // 1. It is an Object.\n  // 2. It has a single key: @id.\n  (types.isObject(v) && Object.keys(v).length === 1 && ('@id' in v));\n\n/**\n * Returns true if the given value is a @value.\n *\n * @param v the value to check.\n *\n * @return true if the value is a @value, false if not.\n */\napi.isValue = v =>\n  // Note: A value is a @value if all of these hold true:\n  // 1. It is an Object.\n  // 2. It has the @value property.\n  types.isObject(v) && ('@value' in v);\n\n/**\n * Returns true if the given value is a @list.\n *\n * @param v the value to check.\n *\n * @return true if the value is a @list, false if not.\n */\napi.isList = v =>\n  // Note: A value is a @list if all of these hold true:\n  // 1. It is an Object.\n  // 2. It has the @list property.\n  types.isObject(v) && ('@list' in v);\n\n/**\n * Returns true if the given value is a @graph.\n *\n * @return true if the value is a @graph, false if not.\n */\napi.isGraph = v => {\n  // Note: A value is a graph if all of these hold true:\n  // 1. It is an object.\n  // 2. It has an `@graph` key.\n  // 3. It may have '@id' or '@index'\n  return types.isObject(v) &&\n    '@graph' in v &&\n    Object.keys(v)\n      .filter(key => key !== '@id' && key !== '@index').length === 1;\n};\n\n/**\n * Returns true if the given value is a simple @graph.\n *\n * @return true if the value is a simple @graph, false if not.\n */\napi.isSimpleGraph = v => {\n  // Note: A value is a simple graph if all of these hold true:\n  // 1. It is an object.\n  // 2. It has an `@graph` key.\n  // 3. It has only 1 key or 2 keys where one of them is `@index`.\n  return api.isGraph(v) && !('@id' in v);\n};\n\n/**\n * Returns true if the given value is a blank node.\n *\n * @param v the value to check.\n *\n * @return true if the value is a blank node, false if not.\n */\napi.isBlankNode = v => {\n  // Note: A value is a blank node if all of these hold true:\n  // 1. It is an Object.\n  // 2. If it has an @id key that is not a string OR begins with '_:'.\n  // 3. It has no keys OR is not a @value, @set, or @list.\n  if(types.isObject(v)) {\n    if('@id' in v) {\n      const id = v['@id'];\n      return !types.isString(id) || id.indexOf('_:') === 0;\n    }\n    return (Object.keys(v).length === 0 ||\n      !(('@value' in v) || ('@set' in v) || ('@list' in v)));\n  }\n  return false;\n};\n","/**\n * A JavaScript implementation of the JSON-LD API.\n *\n * @author Dave Longley\n *\n * @license BSD 3-Clause License\n * Copyright (c) 2011-2022 Digital Bazaar, Inc.\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * Redistributions of source code must retain the above copyright notice,\n * this list of conditions and the following disclaimer.\n *\n * Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and/or other materials provided with the distribution.\n *\n * Neither the name of the Digital Bazaar, Inc. nor the names of its\n * contributors may be used to endorse or promote products derived from\n * this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS\n * IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED\n * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A\n * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\n * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\nconst canonize = require('rdf-canonize');\nconst platform = require('./platform');\nconst util = require('./util');\nconst ContextResolver = require('./ContextResolver');\nconst IdentifierIssuer = util.IdentifierIssuer;\nconst JsonLdError = require('./JsonLdError');\nconst LRU = require('lru-cache');\nconst NQuads = require('./NQuads');\n\nconst {expand: _expand} = require('./expand');\nconst {flatten: _flatten} = require('./flatten');\nconst {fromRDF: _fromRDF} = require('./fromRdf');\nconst {toRDF: _toRDF} = require('./toRdf');\n\nconst {\n  frameMergedOrDefault: _frameMergedOrDefault,\n  cleanupNull: _cleanupNull\n} = require('./frame');\n\nconst {\n  isArray: _isArray,\n  isObject: _isObject,\n  isString: _isString\n} = require('./types');\n\nconst {\n  isSubjectReference: _isSubjectReference,\n} = require('./graphTypes');\n\nconst {\n  expandIri: _expandIri,\n  getInitialContext: _getInitialContext,\n  process: _processContext,\n  processingMode: _processingMode\n} = require('./context');\n\nconst {\n  compact: _compact,\n  compactIri: _compactIri\n} = require('./compact');\n\nconst {\n  createNodeMap: _createNodeMap,\n  createMergedNodeMap: _createMergedNodeMap,\n  mergeNodeMaps: _mergeNodeMaps\n} = require('./nodeMap');\n\nconst {\n  logEventHandler: _logEventHandler,\n  logWarningEventHandler: _logWarningEventHandler,\n  safeEventHandler: _safeEventHandler,\n  setDefaultEventHandler: _setDefaultEventHandler,\n  setupEventHandler: _setupEventHandler,\n  strictEventHandler: _strictEventHandler,\n  unhandledEventHandler: _unhandledEventHandler\n} = require('./events');\n\n/* eslint-disable indent */\n// attaches jsonld API to the given object\nconst wrapper = function(jsonld) {\n\n/** Registered RDF dataset parsers hashed by content-type. */\nconst _rdfParsers = {};\n\n// resolved context cache\n// TODO: consider basing max on context size rather than number\nconst RESOLVED_CONTEXT_CACHE_MAX_SIZE = 100;\nconst _resolvedContextCache = new LRU({max: RESOLVED_CONTEXT_CACHE_MAX_SIZE});\n\n/* Core API */\n\n/**\n * Performs JSON-LD compaction.\n *\n * @param input the JSON-LD input to compact.\n * @param ctx the context to compact with.\n * @param [options] options to use:\n *          [base] the base IRI to use.\n *          [compactArrays] true to compact arrays to single values when\n *            appropriate, false not to (default: true).\n *          [compactToRelative] true to compact IRIs to be relative to document\n *            base, false to keep absolute (default: true)\n *          [graph] true to always output a top-level graph (default: false).\n *          [expandContext] a context to expand with.\n *          [skipExpansion] true to assume the input is expanded and skip\n *            expansion, false not to, defaults to false. Some well-formed\n *            and safe-mode checks may be omitted.\n *          [documentLoader(url, options)] the document loader.\n *          [framing] true if compaction is occuring during a framing operation.\n *          [safe] true to use safe mode. (default: false)\n *          [contextResolver] internal use only.\n *\n * @return a Promise that resolves to the compacted output.\n */\njsonld.compact = async function(input, ctx, options) {\n  if(arguments.length < 2) {\n    throw new TypeError('Could not compact, too few arguments.');\n  }\n\n  if(ctx === null) {\n    throw new JsonLdError(\n      'The compaction context must not be null.',\n      'jsonld.CompactError', {code: 'invalid local context'});\n  }\n\n  // nothing to compact\n  if(input === null) {\n    return null;\n  }\n\n  // set default options\n  options = _setDefaults(options, {\n    base: _isString(input) ? input : '',\n    compactArrays: true,\n    compactToRelative: true,\n    graph: false,\n    skipExpansion: false,\n    link: false,\n    issuer: new IdentifierIssuer('_:b'),\n    contextResolver: new ContextResolver(\n      {sharedCache: _resolvedContextCache})\n  });\n  if(options.link) {\n    // force skip expansion when linking, \"link\" is not part of the public\n    // API, it should only be called from framing\n    options.skipExpansion = true;\n  }\n  if(!options.compactToRelative) {\n    delete options.base;\n  }\n\n  // expand input\n  let expanded;\n  if(options.skipExpansion) {\n    expanded = input;\n  } else {\n    expanded = await jsonld.expand(input, options);\n  }\n\n  // process context\n  const activeCtx = await jsonld.processContext(\n    _getInitialContext(options), ctx, options);\n\n  // do compaction\n  let compacted = await _compact({\n    activeCtx,\n    element: expanded,\n    options\n  });\n\n  // perform clean up\n  if(options.compactArrays && !options.graph && _isArray(compacted)) {\n    if(compacted.length === 1) {\n      // simplify to a single item\n      compacted = compacted[0];\n    } else if(compacted.length === 0) {\n      // simplify to an empty object\n      compacted = {};\n    }\n  } else if(options.graph && _isObject(compacted)) {\n    // always use array if graph option is on\n    compacted = [compacted];\n  }\n\n  // follow @context key\n  if(_isObject(ctx) && '@context' in ctx) {\n    ctx = ctx['@context'];\n  }\n\n  // build output context\n  ctx = util.clone(ctx);\n  if(!_isArray(ctx)) {\n    ctx = [ctx];\n  }\n  // remove empty contexts\n  const tmp = ctx;\n  ctx = [];\n  for(let i = 0; i < tmp.length; ++i) {\n    if(!_isObject(tmp[i]) || Object.keys(tmp[i]).length > 0) {\n      ctx.push(tmp[i]);\n    }\n  }\n\n  // remove array if only one context\n  const hasContext = (ctx.length > 0);\n  if(ctx.length === 1) {\n    ctx = ctx[0];\n  }\n\n  // add context and/or @graph\n  if(_isArray(compacted)) {\n    // use '@graph' keyword\n    const graphAlias = _compactIri({\n      activeCtx, iri: '@graph', relativeTo: {vocab: true}\n    });\n    const graph = compacted;\n    compacted = {};\n    if(hasContext) {\n      compacted['@context'] = ctx;\n    }\n    compacted[graphAlias] = graph;\n  } else if(_isObject(compacted) && hasContext) {\n    // reorder keys so @context is first\n    const graph = compacted;\n    compacted = {'@context': ctx};\n    for(const key in graph) {\n      compacted[key] = graph[key];\n    }\n  }\n\n  return compacted;\n};\n\n/**\n * Performs JSON-LD expansion.\n *\n * @param input the JSON-LD input to expand.\n * @param [options] the options to use:\n *          [base] the base IRI to use.\n *          [expandContext] a context to expand with.\n *          [keepFreeFloatingNodes] true to keep free-floating nodes,\n *            false not to, defaults to false.\n *          [documentLoader(url, options)] the document loader.\n *          [safe] true to use safe mode. (default: false)\n *          [contextResolver] internal use only.\n *\n * @return a Promise that resolves to the expanded output.\n */\njsonld.expand = async function(input, options) {\n  if(arguments.length < 1) {\n    throw new TypeError('Could not expand, too few arguments.');\n  }\n\n  // set default options\n  options = _setDefaults(options, {\n    keepFreeFloatingNodes: false,\n    contextResolver: new ContextResolver(\n      {sharedCache: _resolvedContextCache})\n  });\n\n  // build set of objects that may have @contexts to resolve\n  const toResolve = {};\n\n  // build set of contexts to process prior to expansion\n  const contextsToProcess = [];\n\n  // if an `expandContext` has been given ensure it gets resolved\n  if('expandContext' in options) {\n    const expandContext = util.clone(options.expandContext);\n    if(_isObject(expandContext) && '@context' in expandContext) {\n      toResolve.expandContext = expandContext;\n    } else {\n      toResolve.expandContext = {'@context': expandContext};\n    }\n    contextsToProcess.push(toResolve.expandContext);\n  }\n\n  // if input is a string, attempt to dereference remote document\n  let defaultBase;\n  if(!_isString(input)) {\n    // input is not a URL, do not need to retrieve it first\n    toResolve.input = util.clone(input);\n  } else {\n    // load remote doc\n    const remoteDoc = await jsonld.get(input, options);\n    defaultBase = remoteDoc.documentUrl;\n    toResolve.input = remoteDoc.document;\n    if(remoteDoc.contextUrl) {\n      // context included in HTTP link header and must be resolved\n      toResolve.remoteContext = {'@context': remoteDoc.contextUrl};\n      contextsToProcess.push(toResolve.remoteContext);\n    }\n  }\n\n  // set default base\n  if(!('base' in options)) {\n    options.base = defaultBase || '';\n  }\n\n  // process any additional contexts\n  let activeCtx = _getInitialContext(options);\n  for(const localCtx of contextsToProcess) {\n    activeCtx = await _processContext({activeCtx, localCtx, options});\n  }\n\n  // expand resolved input\n  let expanded = await _expand({\n    activeCtx,\n    element: toResolve.input,\n    options\n  });\n\n  // optimize away @graph with no other properties\n  if(_isObject(expanded) && ('@graph' in expanded) &&\n    Object.keys(expanded).length === 1) {\n    expanded = expanded['@graph'];\n  } else if(expanded === null) {\n    expanded = [];\n  }\n\n  // normalize to an array\n  if(!_isArray(expanded)) {\n    expanded = [expanded];\n  }\n\n  return expanded;\n};\n\n/**\n * Performs JSON-LD flattening.\n *\n * @param input the JSON-LD to flatten.\n * @param ctx the context to use to compact the flattened output, or null.\n * @param [options] the options to use:\n *          [base] the base IRI to use.\n *          [expandContext] a context to expand with.\n *          [documentLoader(url, options)] the document loader.\n *          [contextResolver] internal use only.\n *\n * @return a Promise that resolves to the flattened output.\n */\njsonld.flatten = async function(input, ctx, options) {\n  if(arguments.length < 1) {\n    return new TypeError('Could not flatten, too few arguments.');\n  }\n\n  if(typeof ctx === 'function') {\n    ctx = null;\n  } else {\n    ctx = ctx || null;\n  }\n\n  // set default options\n  options = _setDefaults(options, {\n    base: _isString(input) ? input : '',\n    contextResolver: new ContextResolver(\n      {sharedCache: _resolvedContextCache})\n  });\n\n  // expand input\n  const expanded = await jsonld.expand(input, options);\n\n  // do flattening\n  const flattened = _flatten(expanded);\n\n  if(ctx === null) {\n    // no compaction required\n    return flattened;\n  }\n\n  // compact result (force @graph option to true, skip expansion)\n  options.graph = true;\n  options.skipExpansion = true;\n  const compacted = await jsonld.compact(flattened, ctx, options);\n\n  return compacted;\n};\n\n/**\n * Performs JSON-LD framing.\n *\n * @param input the JSON-LD input to frame.\n * @param frame the JSON-LD frame to use.\n * @param [options] the framing options.\n *          [base] the base IRI to use.\n *          [expandContext] a context to expand with.\n *          [embed] default @embed flag: '@last', '@always', '@never', '@link'\n *            (default: '@last').\n *          [explicit] default @explicit flag (default: false).\n *          [requireAll] default @requireAll flag (default: true).\n *          [omitDefault] default @omitDefault flag (default: false).\n *          [documentLoader(url, options)] the document loader.\n *          [safe] true to use safe mode. (default: false)\n *          [contextResolver] internal use only.\n *\n * @return a Promise that resolves to the framed output.\n */\njsonld.frame = async function(input, frame, options) {\n  if(arguments.length < 2) {\n    throw new TypeError('Could not frame, too few arguments.');\n  }\n\n  // set default options\n  options = _setDefaults(options, {\n    base: _isString(input) ? input : '',\n    embed: '@once',\n    explicit: false,\n    requireAll: false,\n    omitDefault: false,\n    bnodesToClear: [],\n    contextResolver: new ContextResolver(\n      {sharedCache: _resolvedContextCache})\n  });\n\n  // if frame is a string, attempt to dereference remote document\n  if(_isString(frame)) {\n    // load remote doc\n    const remoteDoc = await jsonld.get(frame, options);\n    frame = remoteDoc.document;\n\n    if(remoteDoc.contextUrl) {\n      // inject link header @context into frame\n      let ctx = frame['@context'];\n      if(!ctx) {\n        ctx = remoteDoc.contextUrl;\n      } else if(_isArray(ctx)) {\n        ctx.push(remoteDoc.contextUrl);\n      } else {\n        ctx = [ctx, remoteDoc.contextUrl];\n      }\n      frame['@context'] = ctx;\n    }\n  }\n\n  const frameContext = frame ? frame['@context'] || {} : {};\n\n  // process context\n  const activeCtx = await jsonld.processContext(\n    _getInitialContext(options), frameContext, options);\n\n  // mode specific defaults\n  if(!options.hasOwnProperty('omitGraph')) {\n    options.omitGraph = _processingMode(activeCtx, 1.1);\n  }\n  if(!options.hasOwnProperty('pruneBlankNodeIdentifiers')) {\n    options.pruneBlankNodeIdentifiers = _processingMode(activeCtx, 1.1);\n  }\n\n  // expand input\n  const expanded = await jsonld.expand(input, options);\n\n  // expand frame\n  const opts = {...options};\n  opts.isFrame = true;\n  opts.keepFreeFloatingNodes = true;\n  const expandedFrame = await jsonld.expand(frame, opts);\n\n  // if the unexpanded frame includes a key expanding to @graph, frame the\n  // default graph, otherwise, the merged graph\n  const frameKeys = Object.keys(frame)\n    .map(key => _expandIri(activeCtx, key, {vocab: true}));\n  opts.merged = !frameKeys.includes('@graph');\n  opts.is11 = _processingMode(activeCtx, 1.1);\n\n  // do framing\n  const framed = _frameMergedOrDefault(expanded, expandedFrame, opts);\n\n  opts.graph = !options.omitGraph;\n  opts.skipExpansion = true;\n  opts.link = {};\n  opts.framing = true;\n  let compacted = await jsonld.compact(framed, frameContext, opts);\n\n  // replace @null with null, compacting arrays\n  opts.link = {};\n  compacted = _cleanupNull(compacted, opts);\n\n  return compacted;\n};\n\n/**\n * **Experimental**\n *\n * Links a JSON-LD document's nodes in memory.\n *\n * @param input the JSON-LD document to link.\n * @param [ctx] the JSON-LD context to apply.\n * @param [options] the options to use:\n *          [base] the base IRI to use.\n *          [expandContext] a context to expand with.\n *          [documentLoader(url, options)] the document loader.\n *          [safe] true to use safe mode. (default: false)\n *          [contextResolver] internal use only.\n *\n * @return a Promise that resolves to the linked output.\n */\njsonld.link = async function(input, ctx, options) {\n  // API matches running frame with a wildcard frame and embed: '@link'\n  // get arguments\n  const frame = {};\n  if(ctx) {\n    frame['@context'] = ctx;\n  }\n  frame['@embed'] = '@link';\n  return jsonld.frame(input, frame, options);\n};\n\n/**\n * Performs RDF dataset normalization on the given input. The input is JSON-LD\n * unless the 'inputFormat' option is used. The output is an RDF dataset\n * unless the 'format' option is used.\n *\n * Note: Canonicalization sets `safe` to `true` and `base` to `null` by\n * default in order to produce safe outputs and \"fail closed\" by default. This\n * is different from the other API transformations in this version which\n * allow unsafe defaults (for cryptographic usage) in order to comply with the\n * JSON-LD 1.1 specification.\n *\n * @param input the input to normalize as JSON-LD or as a format specified by\n *          the 'inputFormat' option.\n * @param [options] the options to use:\n *          [algorithm] the normalization algorithm to use, `URDNA2015` or\n *            `URGNA2012` (default: `URDNA2015`).\n *          [base] the base IRI to use (default: `null`).\n *          [expandContext] a context to expand with.\n *          [skipExpansion] true to assume the input is expanded and skip\n *            expansion, false not to, defaults to false. Some well-formed\n *            and safe-mode checks may be omitted.\n *          [inputFormat] the format if input is not JSON-LD:\n *            'application/n-quads' for N-Quads.\n *          [format] the format if output is a string:\n *            'application/n-quads' for N-Quads.\n *          [documentLoader(url, options)] the document loader.\n *          [useNative] true to use a native canonize algorithm\n *          [rdfDirection] null or 'i18n-datatype' to support RDF\n *             transformation of @direction (default: null).\n *          [safe] true to use safe mode. (default: true).\n *          [contextResolver] internal use only.\n *\n * @return a Promise that resolves to the normalized output.\n */\njsonld.normalize = jsonld.canonize = async function(input, options) {\n  if(arguments.length < 1) {\n    throw new TypeError('Could not canonize, too few arguments.');\n  }\n\n  // set default options\n  options = _setDefaults(options, {\n    base: _isString(input) ? input : null,\n    algorithm: 'URDNA2015',\n    skipExpansion: false,\n    safe: true,\n    contextResolver: new ContextResolver(\n      {sharedCache: _resolvedContextCache})\n  });\n  if('inputFormat' in options) {\n    if(options.inputFormat !== 'application/n-quads' &&\n      options.inputFormat !== 'application/nquads') {\n      throw new JsonLdError(\n        'Unknown canonicalization input format.',\n        'jsonld.CanonizeError');\n    }\n    // TODO: `await` for async parsers\n    const parsedInput = NQuads.parse(input);\n\n    // do canonicalization\n    return canonize.canonize(parsedInput, options);\n  }\n\n  // convert to RDF dataset then do normalization\n  const opts = {...options};\n  delete opts.format;\n  opts.produceGeneralizedRdf = false;\n  const dataset = await jsonld.toRDF(input, opts);\n\n  // do canonicalization\n  return canonize.canonize(dataset, options);\n};\n\n/**\n * Converts an RDF dataset to JSON-LD.\n *\n * @param dataset a serialized string of RDF in a format specified by the\n *          format option or an RDF dataset to convert.\n * @param [options] the options to use:\n *          [format] the format if dataset param must first be parsed:\n *            'application/n-quads' for N-Quads (default).\n *          [rdfParser] a custom RDF-parser to use to parse the dataset.\n *          [useRdfType] true to use rdf:type, false to use @type\n *            (default: false).\n *          [useNativeTypes] true to convert XSD types into native types\n *            (boolean, integer, double), false not to (default: false).\n *          [rdfDirection] null or 'i18n-datatype' to support RDF\n *             transformation of @direction (default: null).\n *          [safe] true to use safe mode. (default: false)\n *\n * @return a Promise that resolves to the JSON-LD document.\n */\njsonld.fromRDF = async function(dataset, options) {\n  if(arguments.length < 1) {\n    throw new TypeError('Could not convert from RDF, too few arguments.');\n  }\n\n  // set default options\n  options = _setDefaults(options, {\n    format: _isString(dataset) ? 'application/n-quads' : undefined\n  });\n\n  const {format} = options;\n  let {rdfParser} = options;\n\n  // handle special format\n  if(format) {\n    // check supported formats\n    rdfParser = rdfParser || _rdfParsers[format];\n    if(!rdfParser) {\n      throw new JsonLdError(\n        'Unknown input format.',\n        'jsonld.UnknownFormat', {format});\n    }\n  } else {\n    // no-op parser, assume dataset already parsed\n    rdfParser = () => dataset;\n  }\n\n  // rdfParser must be synchronous or return a promise, no callback support\n  const parsedDataset = await rdfParser(dataset);\n  return _fromRDF(parsedDataset, options);\n};\n\n/**\n * Outputs the RDF dataset found in the given JSON-LD object.\n *\n * @param input the JSON-LD input.\n * @param [options] the options to use:\n *          [base] the base IRI to use.\n *          [expandContext] a context to expand with.\n *          [skipExpansion] true to assume the input is expanded and skip\n *            expansion, false not to, defaults to false. Some well-formed\n *            and safe-mode checks may be omitted.\n *          [format] the format to use to output a string:\n *            'application/n-quads' for N-Quads.\n *          [produceGeneralizedRdf] true to output generalized RDF, false\n *            to produce only standard RDF (default: false).\n *          [documentLoader(url, options)] the document loader.\n *          [safe] true to use safe mode. (default: false)\n *          [rdfDirection] null or 'i18n-datatype' to support RDF\n *             transformation of @direction (default: null).\n *          [contextResolver] internal use only.\n *\n * @return a Promise that resolves to the RDF dataset.\n */\njsonld.toRDF = async function(input, options) {\n  if(arguments.length < 1) {\n    throw new TypeError('Could not convert to RDF, too few arguments.');\n  }\n\n  // set default options\n  options = _setDefaults(options, {\n    base: _isString(input) ? input : '',\n    skipExpansion: false,\n    contextResolver: new ContextResolver(\n      {sharedCache: _resolvedContextCache})\n  });\n\n  // TODO: support toRDF custom map?\n  let expanded;\n  if(options.skipExpansion) {\n    expanded = input;\n  } else {\n    // expand input\n    expanded = await jsonld.expand(input, options);\n  }\n\n  // output RDF dataset\n  const dataset = _toRDF(expanded, options);\n  if(options.format) {\n    if(options.format === 'application/n-quads' ||\n      options.format === 'application/nquads') {\n      return NQuads.serialize(dataset);\n    }\n    throw new JsonLdError(\n      'Unknown output format.',\n      'jsonld.UnknownFormat', {format: options.format});\n  }\n\n  return dataset;\n};\n\n/**\n * **Experimental**\n *\n * Recursively flattens the nodes in the given JSON-LD input into a merged\n * map of node ID => node. All graphs will be merged into the default graph.\n *\n * @param input the JSON-LD input.\n * @param [options] the options to use:\n *          [base] the base IRI to use.\n *          [expandContext] a context to expand with.\n *          [issuer] a jsonld.IdentifierIssuer to use to label blank nodes.\n *          [documentLoader(url, options)] the document loader.\n *          [contextResolver] internal use only.\n *\n * @return a Promise that resolves to the merged node map.\n */\njsonld.createNodeMap = async function(input, options) {\n  if(arguments.length < 1) {\n    throw new TypeError('Could not create node map, too few arguments.');\n  }\n\n  // set default options\n  options = _setDefaults(options, {\n    base: _isString(input) ? input : '',\n    contextResolver: new ContextResolver(\n      {sharedCache: _resolvedContextCache})\n  });\n\n  // expand input\n  const expanded = await jsonld.expand(input, options);\n\n  return _createMergedNodeMap(expanded, options);\n};\n\n/**\n * **Experimental**\n *\n * Merges two or more JSON-LD documents into a single flattened document.\n *\n * @param docs the JSON-LD documents to merge together.\n * @param ctx the context to use to compact the merged result, or null.\n * @param [options] the options to use:\n *          [base] the base IRI to use.\n *          [expandContext] a context to expand with.\n *          [issuer] a jsonld.IdentifierIssuer to use to label blank nodes.\n *          [mergeNodes] true to merge properties for nodes with the same ID,\n *            false to ignore new properties for nodes with the same ID once\n *            the ID has been defined; note that this may not prevent merging\n *            new properties where a node is in the `object` position\n *            (default: true).\n *          [documentLoader(url, options)] the document loader.\n *          [safe] true to use safe mode. (default: false)\n *          [contextResolver] internal use only.\n *\n * @return a Promise that resolves to the merged output.\n */\njsonld.merge = async function(docs, ctx, options) {\n  if(arguments.length < 1) {\n    throw new TypeError('Could not merge, too few arguments.');\n  }\n  if(!_isArray(docs)) {\n    throw new TypeError('Could not merge, \"docs\" must be an array.');\n  }\n\n  if(typeof ctx === 'function') {\n    ctx = null;\n  } else {\n    ctx = ctx || null;\n  }\n\n  // set default options\n  options = _setDefaults(options, {\n    contextResolver: new ContextResolver(\n      {sharedCache: _resolvedContextCache})\n  });\n\n  // expand all documents\n  const expanded = await Promise.all(docs.map(doc => {\n    const opts = {...options};\n    return jsonld.expand(doc, opts);\n  }));\n\n  let mergeNodes = true;\n  if('mergeNodes' in options) {\n    mergeNodes = options.mergeNodes;\n  }\n\n  const issuer = options.issuer || new IdentifierIssuer('_:b');\n  const graphs = {'@default': {}};\n\n  for(let i = 0; i < expanded.length; ++i) {\n    // uniquely relabel blank nodes\n    const doc = util.relabelBlankNodes(expanded[i], {\n      issuer: new IdentifierIssuer('_:b' + i + '-')\n    });\n\n    // add nodes to the shared node map graphs if merging nodes, to a\n    // separate graph set if not\n    const _graphs = (mergeNodes || i === 0) ? graphs : {'@default': {}};\n    _createNodeMap(doc, _graphs, '@default', issuer);\n\n    if(_graphs !== graphs) {\n      // merge document graphs but don't merge existing nodes\n      for(const graphName in _graphs) {\n        const _nodeMap = _graphs[graphName];\n        if(!(graphName in graphs)) {\n          graphs[graphName] = _nodeMap;\n          continue;\n        }\n        const nodeMap = graphs[graphName];\n        for(const key in _nodeMap) {\n          if(!(key in nodeMap)) {\n            nodeMap[key] = _nodeMap[key];\n          }\n        }\n      }\n    }\n  }\n\n  // add all non-default graphs to default graph\n  const defaultGraph = _mergeNodeMaps(graphs);\n\n  // produce flattened output\n  const flattened = [];\n  const keys = Object.keys(defaultGraph).sort();\n  for(let ki = 0; ki < keys.length; ++ki) {\n    const node = defaultGraph[keys[ki]];\n    // only add full subjects to top-level\n    if(!_isSubjectReference(node)) {\n      flattened.push(node);\n    }\n  }\n\n  if(ctx === null) {\n    return flattened;\n  }\n\n  // compact result (force @graph option to true, skip expansion)\n  options.graph = true;\n  options.skipExpansion = true;\n  const compacted = await jsonld.compact(flattened, ctx, options);\n\n  return compacted;\n};\n\n/**\n * The default document loader for external documents.\n *\n * @param url the URL to load.\n *\n * @return a promise that resolves to the remote document.\n */\nObject.defineProperty(jsonld, 'documentLoader', {\n  get: () => jsonld._documentLoader,\n  set: v => jsonld._documentLoader = v\n});\n// default document loader not implemented\njsonld.documentLoader = async url => {\n  throw new JsonLdError(\n    'Could not retrieve a JSON-LD document from the URL. URL ' +\n    'dereferencing not implemented.', 'jsonld.LoadDocumentError',\n    {code: 'loading document failed', url});\n};\n\n/**\n * Gets a remote JSON-LD document using the default document loader or\n * one given in the passed options.\n *\n * @param url the URL to fetch.\n * @param [options] the options to use:\n *          [documentLoader] the document loader to use.\n *\n * @return a Promise that resolves to the retrieved remote document.\n */\njsonld.get = async function(url, options) {\n  let load;\n  if(typeof options.documentLoader === 'function') {\n    load = options.documentLoader;\n  } else {\n    load = jsonld.documentLoader;\n  }\n\n  const remoteDoc = await load(url);\n\n  try {\n    if(!remoteDoc.document) {\n      throw new JsonLdError(\n        'No remote document found at the given URL.',\n        'jsonld.NullRemoteDocument');\n    }\n    if(_isString(remoteDoc.document)) {\n      remoteDoc.document = JSON.parse(remoteDoc.document);\n    }\n  } catch(e) {\n    throw new JsonLdError(\n      'Could not retrieve a JSON-LD document from the URL.',\n      'jsonld.LoadDocumentError', {\n        code: 'loading document failed',\n        cause: e,\n        remoteDoc\n      });\n  }\n\n  return remoteDoc;\n};\n\n/**\n * Processes a local context, resolving any URLs as necessary, and returns a\n * new active context.\n *\n * @param activeCtx the current active context.\n * @param localCtx the local context to process.\n * @param [options] the options to use:\n *          [documentLoader(url, options)] the document loader.\n *          [safe] true to use safe mode. (default: false)\n *          [contextResolver] internal use only.\n *\n * @return a Promise that resolves to the new active context.\n */\njsonld.processContext = async function(\n  activeCtx, localCtx, options) {\n  // set default options\n  options = _setDefaults(options, {\n    base: '',\n    contextResolver: new ContextResolver(\n      {sharedCache: _resolvedContextCache})\n  });\n\n  // return initial context early for null context\n  if(localCtx === null) {\n    return _getInitialContext(options);\n  }\n\n  // get URLs in localCtx\n  localCtx = util.clone(localCtx);\n  if(!(_isObject(localCtx) && '@context' in localCtx)) {\n    localCtx = {'@context': localCtx};\n  }\n\n  return _processContext({activeCtx, localCtx, options});\n};\n\n// backwards compatibility\njsonld.getContextValue = require('./context').getContextValue;\n\n/**\n * Document loaders.\n */\njsonld.documentLoaders = {};\n\n/**\n * Assigns the default document loader for external document URLs to a built-in\n * default. Supported types currently include: 'xhr' and 'node'.\n *\n * @param type the type to set.\n * @param [params] the parameters required to use the document loader.\n */\njsonld.useDocumentLoader = function(type) {\n  if(!(type in jsonld.documentLoaders)) {\n    throw new JsonLdError(\n      'Unknown document loader type: \"' + type + '\"',\n      'jsonld.UnknownDocumentLoader',\n      {type});\n  }\n\n  // set document loader\n  jsonld.documentLoader = jsonld.documentLoaders[type].apply(\n    jsonld, Array.prototype.slice.call(arguments, 1));\n};\n\n/**\n * Registers an RDF dataset parser by content-type, for use with\n * jsonld.fromRDF. An RDF dataset parser will always be given one parameter,\n * a string of input. An RDF dataset parser can be synchronous or\n * asynchronous (by returning a promise).\n *\n * @param contentType the content-type for the parser.\n * @param parser(input) the parser function (takes a string as a parameter\n *          and either returns an RDF dataset or a Promise that resolves to one.\n */\njsonld.registerRDFParser = function(contentType, parser) {\n  _rdfParsers[contentType] = parser;\n};\n\n/**\n * Unregisters an RDF dataset parser by content-type.\n *\n * @param contentType the content-type for the parser.\n */\njsonld.unregisterRDFParser = function(contentType) {\n  delete _rdfParsers[contentType];\n};\n\n// register the N-Quads RDF parser\njsonld.registerRDFParser('application/n-quads', NQuads.parse);\njsonld.registerRDFParser('application/nquads', NQuads.parse);\n\n/* URL API */\njsonld.url = require('./url');\n\n/* Events API and handlers */\njsonld.logEventHandler = _logEventHandler;\njsonld.logWarningEventHandler = _logWarningEventHandler;\njsonld.safeEventHandler = _safeEventHandler;\njsonld.setDefaultEventHandler = _setDefaultEventHandler;\njsonld.strictEventHandler = _strictEventHandler;\njsonld.unhandledEventHandler = _unhandledEventHandler;\n\n/* Utility API */\njsonld.util = util;\n// backwards compatibility\nObject.assign(jsonld, util);\n\n// reexpose API as jsonld.promises for backwards compatability\njsonld.promises = jsonld;\n\n// backwards compatibility\njsonld.RequestQueue = require('./RequestQueue');\n\n/* WebIDL API */\njsonld.JsonLdProcessor = require('./JsonLdProcessor')(jsonld);\n\nplatform.setupGlobals(jsonld);\nplatform.setupDocumentLoaders(jsonld);\n\nfunction _setDefaults(options, {\n  documentLoader = jsonld.documentLoader,\n  ...defaults\n}) {\n  // fail if obsolete options present\n  if(options && 'compactionMap' in options) {\n    throw new JsonLdError(\n      '\"compactionMap\" not supported.',\n      'jsonld.OptionsError');\n  }\n  if(options && 'expansionMap' in options) {\n    throw new JsonLdError(\n      '\"expansionMap\" not supported.',\n      'jsonld.OptionsError');\n  }\n  return Object.assign(\n    {},\n    {documentLoader},\n    defaults,\n    options,\n    {eventHandler: _setupEventHandler({options})}\n  );\n}\n\n// end of jsonld API `wrapper` factory\nreturn jsonld;\n};\n\n// external APIs:\n\n// used to generate a new jsonld API instance\nconst factory = function() {\n  return wrapper(function() {\n    return factory();\n  });\n};\n\n// wrap the main jsonld API instance\nwrapper(factory);\n// export API\nmodule.exports = factory;\n","/*\n * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst {isKeyword} = require('./context');\nconst graphTypes = require('./graphTypes');\nconst types = require('./types');\nconst util = require('./util');\nconst JsonLdError = require('./JsonLdError');\n\nconst api = {};\nmodule.exports = api;\n\n/**\n * Creates a merged JSON-LD node map (node ID => node).\n *\n * @param input the expanded JSON-LD to create a node map of.\n * @param [options] the options to use:\n *          [issuer] a jsonld.IdentifierIssuer to use to label blank nodes.\n *\n * @return the node map.\n */\napi.createMergedNodeMap = (input, options) => {\n  options = options || {};\n\n  // produce a map of all subjects and name each bnode\n  const issuer = options.issuer || new util.IdentifierIssuer('_:b');\n  const graphs = {'@default': {}};\n  api.createNodeMap(input, graphs, '@default', issuer);\n\n  // add all non-default graphs to default graph\n  return api.mergeNodeMaps(graphs);\n};\n\n/**\n * Recursively flattens the subjects in the given JSON-LD expanded input\n * into a node map.\n *\n * @param input the JSON-LD expanded input.\n * @param graphs a map of graph name to subject map.\n * @param graph the name of the current graph.\n * @param issuer the blank node identifier issuer.\n * @param name the name assigned to the current input if it is a bnode.\n * @param list the list to append to, null for none.\n */\napi.createNodeMap = (input, graphs, graph, issuer, name, list) => {\n  // recurse through array\n  if(types.isArray(input)) {\n    for(const node of input) {\n      api.createNodeMap(node, graphs, graph, issuer, undefined, list);\n    }\n    return;\n  }\n\n  // add non-object to list\n  if(!types.isObject(input)) {\n    if(list) {\n      list.push(input);\n    }\n    return;\n  }\n\n  // add values to list\n  if(graphTypes.isValue(input)) {\n    if('@type' in input) {\n      let type = input['@type'];\n      // rename @type blank node\n      if(type.indexOf('_:') === 0) {\n        input['@type'] = type = issuer.getId(type);\n      }\n    }\n    if(list) {\n      list.push(input);\n    }\n    return;\n  } else if(list && graphTypes.isList(input)) {\n    const _list = [];\n    api.createNodeMap(input['@list'], graphs, graph, issuer, name, _list);\n    list.push({'@list': _list});\n    return;\n  }\n\n  // Note: At this point, input must be a subject.\n\n  // spec requires @type to be named first, so assign names early\n  if('@type' in input) {\n    const types = input['@type'];\n    for(const type of types) {\n      if(type.indexOf('_:') === 0) {\n        issuer.getId(type);\n      }\n    }\n  }\n\n  // get name for subject\n  if(types.isUndefined(name)) {\n    name = graphTypes.isBlankNode(input) ?\n      issuer.getId(input['@id']) : input['@id'];\n  }\n\n  // add subject reference to list\n  if(list) {\n    list.push({'@id': name});\n  }\n\n  // create new subject or merge into existing one\n  const subjects = graphs[graph];\n  const subject = subjects[name] = subjects[name] || {};\n  subject['@id'] = name;\n  const properties = Object.keys(input).sort();\n  for(let property of properties) {\n    // skip @id\n    if(property === '@id') {\n      continue;\n    }\n\n    // handle reverse properties\n    if(property === '@reverse') {\n      const referencedNode = {'@id': name};\n      const reverseMap = input['@reverse'];\n      for(const reverseProperty in reverseMap) {\n        const items = reverseMap[reverseProperty];\n        for(const item of items) {\n          let itemName = item['@id'];\n          if(graphTypes.isBlankNode(item)) {\n            itemName = issuer.getId(itemName);\n          }\n          api.createNodeMap(item, graphs, graph, issuer, itemName);\n          util.addValue(\n            subjects[itemName], reverseProperty, referencedNode,\n            {propertyIsArray: true, allowDuplicate: false});\n        }\n      }\n      continue;\n    }\n\n    // recurse into graph\n    if(property === '@graph') {\n      // add graph subjects map entry\n      if(!(name in graphs)) {\n        graphs[name] = {};\n      }\n      api.createNodeMap(input[property], graphs, name, issuer);\n      continue;\n    }\n\n    // recurse into included\n    if(property === '@included') {\n      api.createNodeMap(input[property], graphs, graph, issuer);\n      continue;\n    }\n\n    // copy non-@type keywords\n    if(property !== '@type' && isKeyword(property)) {\n      if(property === '@index' && property in subject &&\n        (input[property] !== subject[property] ||\n        input[property]['@id'] !== subject[property]['@id'])) {\n        throw new JsonLdError(\n          'Invalid JSON-LD syntax; conflicting @index property detected.',\n          'jsonld.SyntaxError',\n          {code: 'conflicting indexes', subject});\n      }\n      subject[property] = input[property];\n      continue;\n    }\n\n    // iterate over objects\n    const objects = input[property];\n\n    // if property is a bnode, assign it a new id\n    if(property.indexOf('_:') === 0) {\n      property = issuer.getId(property);\n    }\n\n    // ensure property is added for empty arrays\n    if(objects.length === 0) {\n      util.addValue(subject, property, [], {propertyIsArray: true});\n      continue;\n    }\n    for(let o of objects) {\n      if(property === '@type') {\n        // rename @type blank nodes\n        o = (o.indexOf('_:') === 0) ? issuer.getId(o) : o;\n      }\n\n      // handle embedded subject or subject reference\n      if(graphTypes.isSubject(o) || graphTypes.isSubjectReference(o)) {\n        // skip null @id\n        if('@id' in o && !o['@id']) {\n          continue;\n        }\n\n        // relabel blank node @id\n        const id = graphTypes.isBlankNode(o) ?\n          issuer.getId(o['@id']) : o['@id'];\n\n        // add reference and recurse\n        util.addValue(\n          subject, property, {'@id': id},\n          {propertyIsArray: true, allowDuplicate: false});\n        api.createNodeMap(o, graphs, graph, issuer, id);\n      } else if(graphTypes.isValue(o)) {\n        util.addValue(\n          subject, property, o,\n          {propertyIsArray: true, allowDuplicate: false});\n      } else if(graphTypes.isList(o)) {\n        // handle @list\n        const _list = [];\n        api.createNodeMap(o['@list'], graphs, graph, issuer, name, _list);\n        o = {'@list': _list};\n        util.addValue(\n          subject, property, o,\n          {propertyIsArray: true, allowDuplicate: false});\n      } else {\n        // handle @value\n        api.createNodeMap(o, graphs, graph, issuer, name);\n        util.addValue(\n          subject, property, o, {propertyIsArray: true, allowDuplicate: false});\n      }\n    }\n  }\n};\n\n/**\n * Merge separate named graphs into a single merged graph including\n * all nodes from the default graph and named graphs.\n *\n * @param graphs a map of graph name to subject map.\n *\n * @return the merged graph map.\n */\napi.mergeNodeMapGraphs = graphs => {\n  const merged = {};\n  for(const name of Object.keys(graphs).sort()) {\n    for(const id of Object.keys(graphs[name]).sort()) {\n      const node = graphs[name][id];\n      if(!(id in merged)) {\n        merged[id] = {'@id': id};\n      }\n      const mergedNode = merged[id];\n\n      for(const property of Object.keys(node).sort()) {\n        if(isKeyword(property) && property !== '@type') {\n          // copy keywords\n          mergedNode[property] = util.clone(node[property]);\n        } else {\n          // merge objects\n          for(const value of node[property]) {\n            util.addValue(\n              mergedNode, property, util.clone(value),\n              {propertyIsArray: true, allowDuplicate: false});\n          }\n        }\n      }\n    }\n  }\n\n  return merged;\n};\n\napi.mergeNodeMaps = graphs => {\n  // add all non-default graphs to default graph\n  const defaultGraph = graphs['@default'];\n  const graphNames = Object.keys(graphs).sort();\n  for(const graphName of graphNames) {\n    if(graphName === '@default') {\n      continue;\n    }\n    const nodeMap = graphs[graphName];\n    let subject = defaultGraph[graphName];\n    if(!subject) {\n      defaultGraph[graphName] = subject = {\n        '@id': graphName,\n        '@graph': []\n      };\n    } else if(!('@graph' in subject)) {\n      subject['@graph'] = [];\n    }\n    const graph = subject['@graph'];\n    for(const id of Object.keys(nodeMap).sort()) {\n      const node = nodeMap[id];\n      // only add full subjects\n      if(!graphTypes.isSubjectReference(node)) {\n        graph.push(node);\n      }\n    }\n  }\n  return defaultGraph;\n};\n","/*\n * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst xhrLoader = require('./documentLoaders/xhr');\n\nconst api = {};\nmodule.exports = api;\n\n/**\n * Setup browser document loaders.\n *\n * @param jsonld the jsonld api.\n */\napi.setupDocumentLoaders = function(jsonld) {\n  if(typeof XMLHttpRequest !== 'undefined') {\n    jsonld.documentLoaders.xhr = xhrLoader;\n    // use xhr document loader by default\n    jsonld.useDocumentLoader('xhr');\n  }\n};\n\n/**\n * Setup browser globals.\n *\n * @param jsonld the jsonld api.\n */\napi.setupGlobals = function(jsonld) {\n  // setup browser global JsonLdProcessor\n  if(typeof globalThis.JsonLdProcessor === 'undefined') {\n    Object.defineProperty(globalThis, 'JsonLdProcessor', {\n      writable: true,\n      enumerable: false,\n      configurable: true,\n      value: jsonld.JsonLdProcessor\n    });\n  }\n};\n","/*\n * Copyright (c) 2017-2023 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst {createNodeMap} = require('./nodeMap');\nconst {isKeyword} = require('./context');\nconst graphTypes = require('./graphTypes');\nconst jsonCanonicalize = require('canonicalize');\nconst JsonLdError = require('./JsonLdError');\nconst types = require('./types');\nconst util = require('./util');\n\nconst {\n  handleEvent: _handleEvent\n} = require('./events');\n\nconst {\n  // RDF,\n  // RDF_LIST,\n  RDF_FIRST,\n  RDF_REST,\n  RDF_NIL,\n  RDF_TYPE,\n  // RDF_PLAIN_LITERAL,\n  // RDF_XML_LITERAL,\n  RDF_JSON_LITERAL,\n  // RDF_OBJECT,\n  RDF_LANGSTRING,\n\n  // XSD,\n  XSD_BOOLEAN,\n  XSD_DOUBLE,\n  XSD_INTEGER,\n  XSD_STRING,\n} = require('./constants');\n\nconst {\n  isAbsolute: _isAbsoluteIri\n} = require('./url');\n\nconst api = {};\nmodule.exports = api;\n\n/**\n * Outputs an RDF dataset for the expanded JSON-LD input.\n *\n * @param input the expanded JSON-LD input.\n * @param options the RDF serialization options.\n *\n * @return the RDF dataset.\n */\napi.toRDF = (input, options) => {\n  // create node map for default graph (and any named graphs)\n  const issuer = new util.IdentifierIssuer('_:b');\n  const nodeMap = {'@default': {}};\n  createNodeMap(input, nodeMap, '@default', issuer);\n\n  const dataset = [];\n  const graphNames = Object.keys(nodeMap).sort();\n  for(const graphName of graphNames) {\n    let graphTerm;\n    if(graphName === '@default') {\n      graphTerm = {termType: 'DefaultGraph', value: ''};\n    } else if(_isAbsoluteIri(graphName)) {\n      if(graphName.startsWith('_:')) {\n        graphTerm = {termType: 'BlankNode'};\n      } else {\n        graphTerm = {termType: 'NamedNode'};\n      }\n      graphTerm.value = graphName;\n    } else {\n      // skip relative IRIs (not valid RDF)\n      if(options.eventHandler) {\n        _handleEvent({\n          event: {\n            type: ['JsonLdEvent'],\n            code: 'relative graph reference',\n            level: 'warning',\n            message: 'Relative graph reference found.',\n            details: {\n              graph: graphName\n            }\n          },\n          options\n        });\n      }\n      continue;\n    }\n    _graphToRDF(dataset, nodeMap[graphName], graphTerm, issuer, options);\n  }\n\n  return dataset;\n};\n\n/**\n * Adds RDF quads for a particular graph to the given dataset.\n *\n * @param dataset the dataset to append RDF quads to.\n * @param graph the graph to create RDF quads for.\n * @param graphTerm the graph term for each quad.\n * @param issuer a IdentifierIssuer for assigning blank node names.\n * @param options the RDF serialization options.\n *\n * @return the array of RDF triples for the given graph.\n */\nfunction _graphToRDF(dataset, graph, graphTerm, issuer, options) {\n  const ids = Object.keys(graph).sort();\n  for(const id of ids) {\n    const node = graph[id];\n    const properties = Object.keys(node).sort();\n    for(let property of properties) {\n      const items = node[property];\n      if(property === '@type') {\n        property = RDF_TYPE;\n      } else if(isKeyword(property)) {\n        continue;\n      }\n\n      for(const item of items) {\n        // RDF subject\n        const subject = {\n          termType: id.startsWith('_:') ? 'BlankNode' : 'NamedNode',\n          value: id\n        };\n\n        // skip relative IRI subjects (not valid RDF)\n        if(!_isAbsoluteIri(id)) {\n          if(options.eventHandler) {\n            _handleEvent({\n              event: {\n                type: ['JsonLdEvent'],\n                code: 'relative subject reference',\n                level: 'warning',\n                message: 'Relative subject reference found.',\n                details: {\n                  subject: id\n                }\n              },\n              options\n            });\n          }\n          continue;\n        }\n\n        // RDF predicate\n        const predicate = {\n          termType: property.startsWith('_:') ? 'BlankNode' : 'NamedNode',\n          value: property\n        };\n\n        // skip relative IRI predicates (not valid RDF)\n        if(!_isAbsoluteIri(property)) {\n          if(options.eventHandler) {\n            _handleEvent({\n              event: {\n                type: ['JsonLdEvent'],\n                code: 'relative predicate reference',\n                level: 'warning',\n                message: 'Relative predicate reference found.',\n                details: {\n                  predicate: property\n                }\n              },\n              options\n            });\n          }\n          continue;\n        }\n\n        // skip blank node predicates unless producing generalized RDF\n        if(predicate.termType === 'BlankNode' &&\n          !options.produceGeneralizedRdf) {\n          if(options.eventHandler) {\n            _handleEvent({\n              event: {\n                type: ['JsonLdEvent'],\n                code: 'blank node predicate',\n                level: 'warning',\n                message: 'Dropping blank node predicate.',\n                details: {\n                  // FIXME: add better issuer API to get reverse mapping\n                  property: issuer.getOldIds()\n                    .find(key => issuer.getId(key) === property)\n                }\n              },\n              options\n            });\n          }\n          continue;\n        }\n\n        // convert list, value or node object to triple\n        const object = _objectToRDF(\n          item, issuer, dataset, graphTerm, options.rdfDirection, options);\n        // skip null objects (they are relative IRIs)\n        if(object) {\n          dataset.push({\n            subject,\n            predicate,\n            object,\n            graph: graphTerm\n          });\n        }\n      }\n    }\n  }\n}\n\n/**\n * Converts a @list value into linked list of blank node RDF quads\n * (an RDF collection).\n *\n * @param list the @list value.\n * @param issuer a IdentifierIssuer for assigning blank node names.\n * @param dataset the array of quads to append to.\n * @param graphTerm the graph term for each quad.\n * @param options the RDF serialization options.\n *\n * @return the head of the list.\n */\nfunction _listToRDF(list, issuer, dataset, graphTerm, rdfDirection, options) {\n  const first = {termType: 'NamedNode', value: RDF_FIRST};\n  const rest = {termType: 'NamedNode', value: RDF_REST};\n  const nil = {termType: 'NamedNode', value: RDF_NIL};\n\n  const last = list.pop();\n  // Result is the head of the list\n  const result = last ? {termType: 'BlankNode', value: issuer.getId()} : nil;\n  let subject = result;\n\n  for(const item of list) {\n    const object = _objectToRDF(\n      item, issuer, dataset, graphTerm, rdfDirection, options);\n    const next = {termType: 'BlankNode', value: issuer.getId()};\n    dataset.push({\n      subject,\n      predicate: first,\n      object,\n      graph: graphTerm\n    });\n    dataset.push({\n      subject,\n      predicate: rest,\n      object: next,\n      graph: graphTerm\n    });\n    subject = next;\n  }\n\n  // Tail of list\n  if(last) {\n    const object = _objectToRDF(\n      last, issuer, dataset, graphTerm, rdfDirection, options);\n    dataset.push({\n      subject,\n      predicate: first,\n      object,\n      graph: graphTerm\n    });\n    dataset.push({\n      subject,\n      predicate: rest,\n      object: nil,\n      graph: graphTerm\n    });\n  }\n\n  return result;\n}\n\n/**\n * Converts a JSON-LD value object to an RDF literal or a JSON-LD string,\n * node object to an RDF resource, or adds a list.\n *\n * @param item the JSON-LD value or node object.\n * @param issuer a IdentifierIssuer for assigning blank node names.\n * @param dataset the dataset to append RDF quads to.\n * @param graphTerm the graph term for each quad.\n * @param options the RDF serialization options.\n *\n * @return the RDF literal or RDF resource.\n */\nfunction _objectToRDF(\n  item, issuer, dataset, graphTerm, rdfDirection, options\n) {\n  const object = {};\n\n  // convert value object to RDF\n  if(graphTypes.isValue(item)) {\n    object.termType = 'Literal';\n    object.value = undefined;\n    object.datatype = {\n      termType: 'NamedNode'\n    };\n    let value = item['@value'];\n    const datatype = item['@type'] || null;\n\n    // convert to XSD/JSON datatypes as appropriate\n    if(datatype === '@json') {\n      object.value = jsonCanonicalize(value);\n      object.datatype.value = RDF_JSON_LITERAL;\n    } else if(types.isBoolean(value)) {\n      object.value = value.toString();\n      object.datatype.value = datatype || XSD_BOOLEAN;\n    } else if(types.isDouble(value) || datatype === XSD_DOUBLE) {\n      if(!types.isDouble(value)) {\n        value = parseFloat(value);\n      }\n      // canonical double representation\n      object.value = value.toExponential(15).replace(/(\\d)0*e\\+?/, '$1E');\n      object.datatype.value = datatype || XSD_DOUBLE;\n    } else if(types.isNumber(value)) {\n      object.value = value.toFixed(0);\n      object.datatype.value = datatype || XSD_INTEGER;\n    } else if('@direction' in item && rdfDirection === 'i18n-datatype') {\n      const language = (item['@language'] || '').toLowerCase();\n      const direction = item['@direction'];\n      const datatype = `https://www.w3.org/ns/i18n#${language}_${direction}`;\n      object.datatype.value = datatype;\n      object.value = value;\n    } else if('@direction' in item && rdfDirection === 'compound-literal') {\n      throw new JsonLdError(\n        'Unsupported rdfDirection value.',\n        'jsonld.InvalidRdfDirection',\n        {value: rdfDirection});\n    } else if('@direction' in item && rdfDirection) {\n      throw new JsonLdError(\n        'Unknown rdfDirection value.',\n        'jsonld.InvalidRdfDirection',\n        {value: rdfDirection});\n    } else if('@language' in item) {\n      if('@direction' in item && !rdfDirection) {\n        if(options.eventHandler) {\n          // FIXME: only emit once?\n          _handleEvent({\n            event: {\n              type: ['JsonLdEvent'],\n              code: 'rdfDirection not set',\n              level: 'warning',\n              message: 'rdfDirection not set for @direction.',\n              details: {\n                object: object.value\n              }\n            },\n            options\n          });\n        }\n      }\n      object.value = value;\n      object.datatype.value = datatype || RDF_LANGSTRING;\n      object.language = item['@language'];\n    } else {\n      if('@direction' in item && !rdfDirection) {\n        if(options.eventHandler) {\n          // FIXME: only emit once?\n          _handleEvent({\n            event: {\n              type: ['JsonLdEvent'],\n              code: 'rdfDirection not set',\n              level: 'warning',\n              message: 'rdfDirection not set for @direction.',\n              details: {\n                object: object.value\n              }\n            },\n            options\n          });\n        }\n      }\n      object.value = value;\n      object.datatype.value = datatype || XSD_STRING;\n    }\n  } else if(graphTypes.isList(item)) {\n    const _list = _listToRDF(\n      item['@list'], issuer, dataset, graphTerm, rdfDirection, options);\n    object.termType = _list.termType;\n    object.value = _list.value;\n  } else {\n    // convert string/node object to RDF\n    const id = types.isObject(item) ? item['@id'] : item;\n    object.termType = id.startsWith('_:') ? 'BlankNode' : 'NamedNode';\n    object.value = id;\n  }\n\n  // skip relative IRIs, not valid RDF\n  if(object.termType === 'NamedNode' && !_isAbsoluteIri(object.value)) {\n    if(options.eventHandler) {\n      _handleEvent({\n        event: {\n          type: ['JsonLdEvent'],\n          code: 'relative object reference',\n          level: 'warning',\n          message: 'Relative object reference found.',\n          details: {\n            object: object.value\n          }\n        },\n        options\n      });\n    }\n    return null;\n  }\n\n  return object;\n}\n","/*\n * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst api = {};\nmodule.exports = api;\n\n/**\n * Returns true if the given value is an Array.\n *\n * @param v the value to check.\n *\n * @return true if the value is an Array, false if not.\n */\napi.isArray = Array.isArray;\n\n/**\n * Returns true if the given value is a Boolean.\n *\n * @param v the value to check.\n *\n * @return true if the value is a Boolean, false if not.\n */\napi.isBoolean = v => (typeof v === 'boolean' ||\n  Object.prototype.toString.call(v) === '[object Boolean]');\n\n/**\n * Returns true if the given value is a double.\n *\n * @param v the value to check.\n *\n * @return true if the value is a double, false if not.\n */\napi.isDouble = v => api.isNumber(v) &&\n  (String(v).indexOf('.') !== -1 || Math.abs(v) >= 1e21);\n\n/**\n * Returns true if the given value is an empty Object.\n *\n * @param v the value to check.\n *\n * @return true if the value is an empty Object, false if not.\n */\napi.isEmptyObject = v => api.isObject(v) && Object.keys(v).length === 0;\n\n/**\n * Returns true if the given value is a Number.\n *\n * @param v the value to check.\n *\n * @return true if the value is a Number, false if not.\n */\napi.isNumber = v => (typeof v === 'number' ||\n  Object.prototype.toString.call(v) === '[object Number]');\n\n/**\n * Returns true if the given value is numeric.\n *\n * @param v the value to check.\n *\n * @return true if the value is numeric, false if not.\n */\napi.isNumeric = v => !isNaN(parseFloat(v)) && isFinite(v);\n\n/**\n * Returns true if the given value is an Object.\n *\n * @param v the value to check.\n *\n * @return true if the value is an Object, false if not.\n */\napi.isObject = v => Object.prototype.toString.call(v) === '[object Object]';\n\n/**\n * Returns true if the given value is a String.\n *\n * @param v the value to check.\n *\n * @return true if the value is a String, false if not.\n */\napi.isString = v => (typeof v === 'string' ||\n  Object.prototype.toString.call(v) === '[object String]');\n\n/**\n * Returns true if the given value is undefined.\n *\n * @param v the value to check.\n *\n * @return true if the value is undefined, false if not.\n */\napi.isUndefined = v => typeof v === 'undefined';\n","/*\n * Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst types = require('./types');\n\nconst api = {};\nmodule.exports = api;\n\n// define URL parser\n// parseUri 1.2.2\n// (c) Steven Levithan <stevenlevithan.com>\n// MIT License\n// with local jsonld.js modifications\napi.parsers = {\n  simple: {\n    // RFC 3986 basic parts\n    keys: [\n      'href', 'scheme', 'authority', 'path', 'query', 'fragment'\n    ],\n    /* eslint-disable-next-line max-len */\n    regex: /^(?:([^:\\/?#]+):)?(?:\\/\\/([^\\/?#]*))?([^?#]*)(?:\\?([^#]*))?(?:#(.*))?/\n  },\n  full: {\n    keys: [\n      'href', 'protocol', 'scheme', 'authority', 'auth', 'user', 'password',\n      'hostname', 'port', 'path', 'directory', 'file', 'query', 'fragment'\n    ],\n    /* eslint-disable-next-line max-len */\n    regex: /^(([a-zA-Z][a-zA-Z0-9+-.]*):)?(?:\\/\\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\\/?#]*)(?::(\\d*))?))?(?:(((?:[^?#\\/]*\\/)*)([^?#]*))(?:\\?([^#]*))?(?:#(.*))?)/\n  }\n};\napi.parse = (str, parser) => {\n  const parsed = {};\n  const o = api.parsers[parser || 'full'];\n  const m = o.regex.exec(str);\n  let i = o.keys.length;\n  while(i--) {\n    parsed[o.keys[i]] = (m[i] === undefined) ? null : m[i];\n  }\n\n  // remove default ports in found in URLs\n  if((parsed.scheme === 'https' && parsed.port === '443') ||\n    (parsed.scheme === 'http' && parsed.port === '80')) {\n    parsed.href = parsed.href.replace(':' + parsed.port, '');\n    parsed.authority = parsed.authority.replace(':' + parsed.port, '');\n    parsed.port = null;\n  }\n\n  parsed.normalizedPath = api.removeDotSegments(parsed.path);\n  return parsed;\n};\n\n/**\n * Prepends a base IRI to the given relative IRI.\n *\n * @param base the base IRI.\n * @param iri the relative IRI.\n *\n * @return the absolute IRI.\n */\napi.prependBase = (base, iri) => {\n  // skip IRI processing\n  if(base === null) {\n    return iri;\n  }\n  // already an absolute IRI\n  if(api.isAbsolute(iri)) {\n    return iri;\n  }\n\n  // parse base if it is a string\n  if(!base || types.isString(base)) {\n    base = api.parse(base || '');\n  }\n\n  // parse given IRI\n  const rel = api.parse(iri);\n\n  // per RFC3986 5.2.2\n  const transform = {\n    protocol: base.protocol || ''\n  };\n\n  if(rel.authority !== null) {\n    transform.authority = rel.authority;\n    transform.path = rel.path;\n    transform.query = rel.query;\n  } else {\n    transform.authority = base.authority;\n\n    if(rel.path === '') {\n      transform.path = base.path;\n      if(rel.query !== null) {\n        transform.query = rel.query;\n      } else {\n        transform.query = base.query;\n      }\n    } else {\n      if(rel.path.indexOf('/') === 0) {\n        // IRI represents an absolute path\n        transform.path = rel.path;\n      } else {\n        // merge paths\n        let path = base.path;\n\n        // append relative path to the end of the last directory from base\n        path = path.substr(0, path.lastIndexOf('/') + 1);\n        if((path.length > 0 || base.authority) && path.substr(-1) !== '/') {\n          path += '/';\n        }\n        path += rel.path;\n\n        transform.path = path;\n      }\n      transform.query = rel.query;\n    }\n  }\n\n  if(rel.path !== '') {\n    // remove slashes and dots in path\n    transform.path = api.removeDotSegments(transform.path);\n  }\n\n  // construct URL\n  let rval = transform.protocol;\n  if(transform.authority !== null) {\n    rval += '//' + transform.authority;\n  }\n  rval += transform.path;\n  if(transform.query !== null) {\n    rval += '?' + transform.query;\n  }\n  if(rel.fragment !== null) {\n    rval += '#' + rel.fragment;\n  }\n\n  // handle empty base\n  if(rval === '') {\n    rval = './';\n  }\n\n  return rval;\n};\n\n/**\n * Removes a base IRI from the given absolute IRI.\n *\n * @param base the base IRI.\n * @param iri the absolute IRI.\n *\n * @return the relative IRI if relative to base, otherwise the absolute IRI.\n */\napi.removeBase = (base, iri) => {\n  // skip IRI processing\n  if(base === null) {\n    return iri;\n  }\n\n  if(!base || types.isString(base)) {\n    base = api.parse(base || '');\n  }\n\n  // establish base root\n  let root = '';\n  if(base.href !== '') {\n    root += (base.protocol || '') + '//' + (base.authority || '');\n  } else if(iri.indexOf('//')) {\n    // support network-path reference with empty base\n    root += '//';\n  }\n\n  // IRI not relative to base\n  if(iri.indexOf(root) !== 0) {\n    return iri;\n  }\n\n  // remove root from IRI and parse remainder\n  const rel = api.parse(iri.substr(root.length));\n\n  // remove path segments that match (do not remove last segment unless there\n  // is a hash or query)\n  const baseSegments = base.normalizedPath.split('/');\n  const iriSegments = rel.normalizedPath.split('/');\n  const last = (rel.fragment || rel.query) ? 0 : 1;\n  while(baseSegments.length > 0 && iriSegments.length > last) {\n    if(baseSegments[0] !== iriSegments[0]) {\n      break;\n    }\n    baseSegments.shift();\n    iriSegments.shift();\n  }\n\n  // use '../' for each non-matching base segment\n  let rval = '';\n  if(baseSegments.length > 0) {\n    // don't count the last segment (if it ends with '/' last path doesn't\n    // count and if it doesn't end with '/' it isn't a path)\n    baseSegments.pop();\n    for(let i = 0; i < baseSegments.length; ++i) {\n      rval += '../';\n    }\n  }\n\n  // prepend remaining segments\n  rval += iriSegments.join('/');\n\n  // add query and hash\n  if(rel.query !== null) {\n    rval += '?' + rel.query;\n  }\n  if(rel.fragment !== null) {\n    rval += '#' + rel.fragment;\n  }\n\n  // handle empty base\n  if(rval === '') {\n    rval = './';\n  }\n\n  return rval;\n};\n\n/**\n * Removes dot segments from a URL path.\n *\n * @param path the path to remove dot segments from.\n */\napi.removeDotSegments = path => {\n  // RFC 3986 5.2.4 (reworked)\n\n  // empty path shortcut\n  if(path.length === 0) {\n    return '';\n  }\n\n  const input = path.split('/');\n  const output = [];\n\n  while(input.length > 0) {\n    const next = input.shift();\n    const done = input.length === 0;\n\n    if(next === '.') {\n      if(done) {\n        // ensure output has trailing /\n        output.push('');\n      }\n      continue;\n    }\n\n    if(next === '..') {\n      output.pop();\n      if(done) {\n        // ensure output has trailing /\n        output.push('');\n      }\n      continue;\n    }\n\n    output.push(next);\n  }\n\n  // if path was absolute, ensure output has leading /\n  if(path[0] === '/' && output.length > 0 && output[0] !== '') {\n    output.unshift('');\n  }\n  if(output.length === 1 && output[0] === '') {\n    return '/';\n  }\n\n  return output.join('/');\n};\n\n// TODO: time better isAbsolute/isRelative checks using full regexes:\n// http://jmrware.com/articles/2009/uri_regexp/URI_regex.html\n\n// regex to check for absolute IRI (starting scheme and ':') or blank node IRI\nconst isAbsoluteRegex = /^([A-Za-z][A-Za-z0-9+-.]*|_):[^\\s]*$/;\n\n/**\n * Returns true if the given value is an absolute IRI or blank node IRI, false\n * if not.\n * Note: This weak check only checks for a correct starting scheme.\n *\n * @param v the value to check.\n *\n * @return true if the value is an absolute IRI, false if not.\n */\napi.isAbsolute = v => types.isString(v) && isAbsoluteRegex.test(v);\n\n/**\n * Returns true if the given value is a relative IRI, false if not.\n * Note: this is a weak check.\n *\n * @param v the value to check.\n *\n * @return true if the value is a relative IRI, false if not.\n */\napi.isRelative = v => types.isString(v);\n","/*\n * Copyright (c) 2017-2019 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst graphTypes = require('./graphTypes');\nconst types = require('./types');\n// TODO: move `IdentifierIssuer` to its own package\nconst IdentifierIssuer = require('rdf-canonize').IdentifierIssuer;\nconst JsonLdError = require('./JsonLdError');\n\n// constants\nconst REGEX_BCP47 = /^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$/;\nconst REGEX_LINK_HEADERS = /(?:<[^>]*?>|\"[^\"]*?\"|[^,])+/g;\nconst REGEX_LINK_HEADER = /\\s*<([^>]*?)>\\s*(?:;\\s*(.*))?/;\nconst REGEX_LINK_HEADER_PARAMS =\n  /(.*?)=(?:(?:\"([^\"]*?)\")|([^\"]*?))\\s*(?:(?:;\\s*)|$)/g;\nconst REGEX_KEYWORD = /^@[a-zA-Z]+$/;\n\nconst DEFAULTS = {\n  headers: {\n    accept: 'application/ld+json, application/json'\n  }\n};\n\nconst api = {};\nmodule.exports = api;\napi.IdentifierIssuer = IdentifierIssuer;\napi.REGEX_BCP47 = REGEX_BCP47;\napi.REGEX_KEYWORD = REGEX_KEYWORD;\n\n/**\n * Clones an object, array, Map, Set, or string/number. If a typed JavaScript\n * object is given, such as a Date, it will be converted to a string.\n *\n * @param value the value to clone.\n *\n * @return the cloned value.\n */\napi.clone = function(value) {\n  if(value && typeof value === 'object') {\n    let rval;\n    if(types.isArray(value)) {\n      rval = [];\n      for(let i = 0; i < value.length; ++i) {\n        rval[i] = api.clone(value[i]);\n      }\n    } else if(value instanceof Map) {\n      rval = new Map();\n      for(const [k, v] of value) {\n        rval.set(k, api.clone(v));\n      }\n    } else if(value instanceof Set) {\n      rval = new Set();\n      for(const v of value) {\n        rval.add(api.clone(v));\n      }\n    } else if(types.isObject(value)) {\n      rval = {};\n      for(const key in value) {\n        rval[key] = api.clone(value[key]);\n      }\n    } else {\n      rval = value.toString();\n    }\n    return rval;\n  }\n  return value;\n};\n\n/**\n * Ensure a value is an array. If the value is an array, it is returned.\n * Otherwise, it is wrapped in an array.\n *\n * @param value the value to return as an array.\n *\n * @return the value as an array.\n */\napi.asArray = function(value) {\n  return Array.isArray(value) ? value : [value];\n};\n\n/**\n * Builds an HTTP headers object for making a JSON-LD request from custom\n * headers and asserts the `accept` header isn't overridden.\n *\n * @param headers an object of headers with keys as header names and values\n *          as header values.\n *\n * @return an object of headers with a valid `accept` header.\n */\napi.buildHeaders = (headers = {}) => {\n  const hasAccept = Object.keys(headers).some(\n    h => h.toLowerCase() === 'accept');\n\n  if(hasAccept) {\n    throw new RangeError(\n      'Accept header may not be specified; only \"' +\n      DEFAULTS.headers.accept + '\" is supported.');\n  }\n\n  return Object.assign({Accept: DEFAULTS.headers.accept}, headers);\n};\n\n/**\n * Parses a link header. The results will be key'd by the value of \"rel\".\n *\n * Link: <http://json-ld.org/contexts/person.jsonld>;\n * rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"\n *\n * Parses as: {\n *   'http://www.w3.org/ns/json-ld#context': {\n *     target: http://json-ld.org/contexts/person.jsonld,\n *     type: 'application/ld+json'\n *   }\n * }\n *\n * If there is more than one \"rel\" with the same IRI, then entries in the\n * resulting map for that \"rel\" will be arrays.\n *\n * @param header the link header to parse.\n */\napi.parseLinkHeader = header => {\n  const rval = {};\n  // split on unbracketed/unquoted commas\n  const entries = header.match(REGEX_LINK_HEADERS);\n  for(let i = 0; i < entries.length; ++i) {\n    let match = entries[i].match(REGEX_LINK_HEADER);\n    if(!match) {\n      continue;\n    }\n    const result = {target: match[1]};\n    const params = match[2];\n    while((match = REGEX_LINK_HEADER_PARAMS.exec(params))) {\n      result[match[1]] = (match[2] === undefined) ? match[3] : match[2];\n    }\n    const rel = result.rel || '';\n    if(Array.isArray(rval[rel])) {\n      rval[rel].push(result);\n    } else if(rval.hasOwnProperty(rel)) {\n      rval[rel] = [rval[rel], result];\n    } else {\n      rval[rel] = result;\n    }\n  }\n  return rval;\n};\n\n/**\n * Throws an exception if the given value is not a valid @type value.\n *\n * @param v the value to check.\n */\napi.validateTypeValue = (v, isFrame) => {\n  if(types.isString(v)) {\n    return;\n  }\n\n  if(types.isArray(v) && v.every(vv => types.isString(vv))) {\n    return;\n  }\n  if(isFrame && types.isObject(v)) {\n    switch(Object.keys(v).length) {\n      case 0:\n        // empty object is wildcard\n        return;\n      case 1:\n        // default entry is all strings\n        if('@default' in v &&\n          api.asArray(v['@default']).every(vv => types.isString(vv))) {\n          return;\n        }\n    }\n  }\n\n  throw new JsonLdError(\n    'Invalid JSON-LD syntax; \"@type\" value must a string, an array of ' +\n    'strings, an empty object, ' +\n    'or a default object.', 'jsonld.SyntaxError',\n    {code: 'invalid type value', value: v});\n};\n\n/**\n * Returns true if the given subject has the given property.\n *\n * @param subject the subject to check.\n * @param property the property to look for.\n *\n * @return true if the subject has the given property, false if not.\n */\napi.hasProperty = (subject, property) => {\n  if(subject.hasOwnProperty(property)) {\n    const value = subject[property];\n    return (!types.isArray(value) || value.length > 0);\n  }\n  return false;\n};\n\n/**\n * Determines if the given value is a property of the given subject.\n *\n * @param subject the subject to check.\n * @param property the property to check.\n * @param value the value to check.\n *\n * @return true if the value exists, false if not.\n */\napi.hasValue = (subject, property, value) => {\n  if(api.hasProperty(subject, property)) {\n    let val = subject[property];\n    const isList = graphTypes.isList(val);\n    if(types.isArray(val) || isList) {\n      if(isList) {\n        val = val['@list'];\n      }\n      for(let i = 0; i < val.length; ++i) {\n        if(api.compareValues(value, val[i])) {\n          return true;\n        }\n      }\n    } else if(!types.isArray(value)) {\n      // avoid matching the set of values with an array value parameter\n      return api.compareValues(value, val);\n    }\n  }\n  return false;\n};\n\n/**\n * Adds a value to a subject. If the value is an array, all values in the\n * array will be added.\n *\n * @param subject the subject to add the value to.\n * @param property the property that relates the value to the subject.\n * @param value the value to add.\n * @param [options] the options to use:\n *        [propertyIsArray] true if the property is always an array, false\n *          if not (default: false).\n *        [valueIsArray] true if the value to be added should be preserved as\n *          an array (lists) (default: false).\n *        [allowDuplicate] true to allow duplicates, false not to (uses a\n *          simple shallow comparison of subject ID or value) (default: true).\n *        [prependValue] false to prepend value to any existing values.\n *          (default: false)\n */\napi.addValue = (subject, property, value, options) => {\n  options = options || {};\n  if(!('propertyIsArray' in options)) {\n    options.propertyIsArray = false;\n  }\n  if(!('valueIsArray' in options)) {\n    options.valueIsArray = false;\n  }\n  if(!('allowDuplicate' in options)) {\n    options.allowDuplicate = true;\n  }\n  if(!('prependValue' in options)) {\n    options.prependValue = false;\n  }\n\n  if(options.valueIsArray) {\n    subject[property] = value;\n  } else if(types.isArray(value)) {\n    if(value.length === 0 && options.propertyIsArray &&\n      !subject.hasOwnProperty(property)) {\n      subject[property] = [];\n    }\n    if(options.prependValue) {\n      value = value.concat(subject[property]);\n      subject[property] = [];\n    }\n    for(let i = 0; i < value.length; ++i) {\n      api.addValue(subject, property, value[i], options);\n    }\n  } else if(subject.hasOwnProperty(property)) {\n    // check if subject already has value if duplicates not allowed\n    const hasValue = (!options.allowDuplicate &&\n      api.hasValue(subject, property, value));\n\n    // make property an array if value not present or always an array\n    if(!types.isArray(subject[property]) &&\n      (!hasValue || options.propertyIsArray)) {\n      subject[property] = [subject[property]];\n    }\n\n    // add new value\n    if(!hasValue) {\n      if(options.prependValue) {\n        subject[property].unshift(value);\n      } else {\n        subject[property].push(value);\n      }\n    }\n  } else {\n    // add new value as set or single value\n    subject[property] = options.propertyIsArray ? [value] : value;\n  }\n};\n\n/**\n * Gets all of the values for a subject's property as an array.\n *\n * @param subject the subject.\n * @param property the property.\n *\n * @return all of the values for a subject's property as an array.\n */\napi.getValues = (subject, property) => [].concat(subject[property] || []);\n\n/**\n * Removes a property from a subject.\n *\n * @param subject the subject.\n * @param property the property.\n */\napi.removeProperty = (subject, property) => {\n  delete subject[property];\n};\n\n/**\n * Removes a value from a subject.\n *\n * @param subject the subject.\n * @param property the property that relates the value to the subject.\n * @param value the value to remove.\n * @param [options] the options to use:\n *          [propertyIsArray] true if the property is always an array, false\n *            if not (default: false).\n */\napi.removeValue = (subject, property, value, options) => {\n  options = options || {};\n  if(!('propertyIsArray' in options)) {\n    options.propertyIsArray = false;\n  }\n\n  // filter out value\n  const values = api.getValues(subject, property).filter(\n    e => !api.compareValues(e, value));\n\n  if(values.length === 0) {\n    api.removeProperty(subject, property);\n  } else if(values.length === 1 && !options.propertyIsArray) {\n    subject[property] = values[0];\n  } else {\n    subject[property] = values;\n  }\n};\n\n/**\n * Relabels all blank nodes in the given JSON-LD input.\n *\n * @param input the JSON-LD input.\n * @param [options] the options to use:\n *          [issuer] an IdentifierIssuer to use to label blank nodes.\n */\napi.relabelBlankNodes = (input, options) => {\n  options = options || {};\n  const issuer = options.issuer || new IdentifierIssuer('_:b');\n  return _labelBlankNodes(issuer, input);\n};\n\n/**\n * Compares two JSON-LD values for equality. Two JSON-LD values will be\n * considered equal if:\n *\n * 1. They are both primitives of the same type and value.\n * 2. They are both @values with the same @value, @type, @language,\n *   and @index, OR\n * 3. They both have @ids they are the same.\n *\n * @param v1 the first value.\n * @param v2 the second value.\n *\n * @return true if v1 and v2 are considered equal, false if not.\n */\napi.compareValues = (v1, v2) => {\n  // 1. equal primitives\n  if(v1 === v2) {\n    return true;\n  }\n\n  // 2. equal @values\n  if(graphTypes.isValue(v1) && graphTypes.isValue(v2) &&\n    v1['@value'] === v2['@value'] &&\n    v1['@type'] === v2['@type'] &&\n    v1['@language'] === v2['@language'] &&\n    v1['@index'] === v2['@index']) {\n    return true;\n  }\n\n  // 3. equal @ids\n  if(types.isObject(v1) &&\n    ('@id' in v1) &&\n    types.isObject(v2) &&\n    ('@id' in v2)) {\n    return v1['@id'] === v2['@id'];\n  }\n\n  return false;\n};\n\n/**\n * Compares two strings first based on length and then lexicographically.\n *\n * @param a the first string.\n * @param b the second string.\n *\n * @return -1 if a < b, 1 if a > b, 0 if a === b.\n */\napi.compareShortestLeast = (a, b) => {\n  if(a.length < b.length) {\n    return -1;\n  }\n  if(b.length < a.length) {\n    return 1;\n  }\n  if(a === b) {\n    return 0;\n  }\n  return (a < b) ? -1 : 1;\n};\n\n/**\n * Labels the blank nodes in the given value using the given IdentifierIssuer.\n *\n * @param issuer the IdentifierIssuer to use.\n * @param element the element with blank nodes to rename.\n *\n * @return the element.\n */\nfunction _labelBlankNodes(issuer, element) {\n  if(types.isArray(element)) {\n    for(let i = 0; i < element.length; ++i) {\n      element[i] = _labelBlankNodes(issuer, element[i]);\n    }\n  } else if(graphTypes.isList(element)) {\n    element['@list'] = _labelBlankNodes(issuer, element['@list']);\n  } else if(types.isObject(element)) {\n    // relabel blank node\n    if(graphTypes.isBlankNode(element)) {\n      element['@id'] = issuer.getId(element['@id']);\n    }\n\n    // recursively apply to all keys\n    const keys = Object.keys(element).sort();\n    for(let ki = 0; ki < keys.length; ++ki) {\n      const key = keys[ki];\n      if(key !== '@id') {\n        element[key] = _labelBlankNodes(issuer, element[key]);\n      }\n    }\n  }\n\n  return element;\n}\n","'use strict'\n\n// A linked list to keep track of recently-used-ness\nconst Yallist = require('yallist')\n\nconst MAX = Symbol('max')\nconst LENGTH = Symbol('length')\nconst LENGTH_CALCULATOR = Symbol('lengthCalculator')\nconst ALLOW_STALE = Symbol('allowStale')\nconst MAX_AGE = Symbol('maxAge')\nconst DISPOSE = Symbol('dispose')\nconst NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet')\nconst LRU_LIST = Symbol('lruList')\nconst CACHE = Symbol('cache')\nconst UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet')\n\nconst naiveLength = () => 1\n\n// lruList is a yallist where the head is the youngest\n// item, and the tail is the oldest.  the list contains the Hit\n// objects as the entries.\n// Each Hit object has a reference to its Yallist.Node.  This\n// never changes.\n//\n// cache is a Map (or PseudoMap) that matches the keys to\n// the Yallist.Node object.\nclass LRUCache {\n  constructor (options) {\n    if (typeof options === 'number')\n      options = { max: options }\n\n    if (!options)\n      options = {}\n\n    if (options.max && (typeof options.max !== 'number' || options.max < 0))\n      throw new TypeError('max must be a non-negative number')\n    // Kind of weird to have a default max of Infinity, but oh well.\n    const max = this[MAX] = options.max || Infinity\n\n    const lc = options.length || naiveLength\n    this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc\n    this[ALLOW_STALE] = options.stale || false\n    if (options.maxAge && typeof options.maxAge !== 'number')\n      throw new TypeError('maxAge must be a number')\n    this[MAX_AGE] = options.maxAge || 0\n    this[DISPOSE] = options.dispose\n    this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false\n    this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false\n    this.reset()\n  }\n\n  // resize the cache when the max changes.\n  set max (mL) {\n    if (typeof mL !== 'number' || mL < 0)\n      throw new TypeError('max must be a non-negative number')\n\n    this[MAX] = mL || Infinity\n    trim(this)\n  }\n  get max () {\n    return this[MAX]\n  }\n\n  set allowStale (allowStale) {\n    this[ALLOW_STALE] = !!allowStale\n  }\n  get allowStale () {\n    return this[ALLOW_STALE]\n  }\n\n  set maxAge (mA) {\n    if (typeof mA !== 'number')\n      throw new TypeError('maxAge must be a non-negative number')\n\n    this[MAX_AGE] = mA\n    trim(this)\n  }\n  get maxAge () {\n    return this[MAX_AGE]\n  }\n\n  // resize the cache when the lengthCalculator changes.\n  set lengthCalculator (lC) {\n    if (typeof lC !== 'function')\n      lC = naiveLength\n\n    if (lC !== this[LENGTH_CALCULATOR]) {\n      this[LENGTH_CALCULATOR] = lC\n      this[LENGTH] = 0\n      this[LRU_LIST].forEach(hit => {\n        hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key)\n        this[LENGTH] += hit.length\n      })\n    }\n    trim(this)\n  }\n  get lengthCalculator () { return this[LENGTH_CALCULATOR] }\n\n  get length () { return this[LENGTH] }\n  get itemCount () { return this[LRU_LIST].length }\n\n  rforEach (fn, thisp) {\n    thisp = thisp || this\n    for (let walker = this[LRU_LIST].tail; walker !== null;) {\n      const prev = walker.prev\n      forEachStep(this, fn, walker, thisp)\n      walker = prev\n    }\n  }\n\n  forEach (fn, thisp) {\n    thisp = thisp || this\n    for (let walker = this[LRU_LIST].head; walker !== null;) {\n      const next = walker.next\n      forEachStep(this, fn, walker, thisp)\n      walker = next\n    }\n  }\n\n  keys () {\n    return this[LRU_LIST].toArray().map(k => k.key)\n  }\n\n  values () {\n    return this[LRU_LIST].toArray().map(k => k.value)\n  }\n\n  reset () {\n    if (this[DISPOSE] &&\n        this[LRU_LIST] &&\n        this[LRU_LIST].length) {\n      this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value))\n    }\n\n    this[CACHE] = new Map() // hash of items by key\n    this[LRU_LIST] = new Yallist() // list of items in order of use recency\n    this[LENGTH] = 0 // length of items in the list\n  }\n\n  dump () {\n    return this[LRU_LIST].map(hit =>\n      isStale(this, hit) ? false : {\n        k: hit.key,\n        v: hit.value,\n        e: hit.now + (hit.maxAge || 0)\n      }).toArray().filter(h => h)\n  }\n\n  dumpLru () {\n    return this[LRU_LIST]\n  }\n\n  set (key, value, maxAge) {\n    maxAge = maxAge || this[MAX_AGE]\n\n    if (maxAge && typeof maxAge !== 'number')\n      throw new TypeError('maxAge must be a number')\n\n    const now = maxAge ? Date.now() : 0\n    const len = this[LENGTH_CALCULATOR](value, key)\n\n    if (this[CACHE].has(key)) {\n      if (len > this[MAX]) {\n        del(this, this[CACHE].get(key))\n        return false\n      }\n\n      const node = this[CACHE].get(key)\n      const item = node.value\n\n      // dispose of the old one before overwriting\n      // split out into 2 ifs for better coverage tracking\n      if (this[DISPOSE]) {\n        if (!this[NO_DISPOSE_ON_SET])\n          this[DISPOSE](key, item.value)\n      }\n\n      item.now = now\n      item.maxAge = maxAge\n      item.value = value\n      this[LENGTH] += len - item.length\n      item.length = len\n      this.get(key)\n      trim(this)\n      return true\n    }\n\n    const hit = new Entry(key, value, len, now, maxAge)\n\n    // oversized objects fall out of cache automatically.\n    if (hit.length > this[MAX]) {\n      if (this[DISPOSE])\n        this[DISPOSE](key, value)\n\n      return false\n    }\n\n    this[LENGTH] += hit.length\n    this[LRU_LIST].unshift(hit)\n    this[CACHE].set(key, this[LRU_LIST].head)\n    trim(this)\n    return true\n  }\n\n  has (key) {\n    if (!this[CACHE].has(key)) return false\n    const hit = this[CACHE].get(key).value\n    return !isStale(this, hit)\n  }\n\n  get (key) {\n    return get(this, key, true)\n  }\n\n  peek (key) {\n    return get(this, key, false)\n  }\n\n  pop () {\n    const node = this[LRU_LIST].tail\n    if (!node)\n      return null\n\n    del(this, node)\n    return node.value\n  }\n\n  del (key) {\n    del(this, this[CACHE].get(key))\n  }\n\n  load (arr) {\n    // reset the cache\n    this.reset()\n\n    const now = Date.now()\n    // A previous serialized cache has the most recent items first\n    for (let l = arr.length - 1; l >= 0; l--) {\n      const hit = arr[l]\n      const expiresAt = hit.e || 0\n      if (expiresAt === 0)\n        // the item was created without expiration in a non aged cache\n        this.set(hit.k, hit.v)\n      else {\n        const maxAge = expiresAt - now\n        // dont add already expired items\n        if (maxAge > 0) {\n          this.set(hit.k, hit.v, maxAge)\n        }\n      }\n    }\n  }\n\n  prune () {\n    this[CACHE].forEach((value, key) => get(this, key, false))\n  }\n}\n\nconst get = (self, key, doUse) => {\n  const node = self[CACHE].get(key)\n  if (node) {\n    const hit = node.value\n    if (isStale(self, hit)) {\n      del(self, node)\n      if (!self[ALLOW_STALE])\n        return undefined\n    } else {\n      if (doUse) {\n        if (self[UPDATE_AGE_ON_GET])\n          node.value.now = Date.now()\n        self[LRU_LIST].unshiftNode(node)\n      }\n    }\n    return hit.value\n  }\n}\n\nconst isStale = (self, hit) => {\n  if (!hit || (!hit.maxAge && !self[MAX_AGE]))\n    return false\n\n  const diff = Date.now() - hit.now\n  return hit.maxAge ? diff > hit.maxAge\n    : self[MAX_AGE] && (diff > self[MAX_AGE])\n}\n\nconst trim = self => {\n  if (self[LENGTH] > self[MAX]) {\n    for (let walker = self[LRU_LIST].tail;\n      self[LENGTH] > self[MAX] && walker !== null;) {\n      // We know that we're about to delete this one, and also\n      // what the next least recently used key will be, so just\n      // go ahead and set it now.\n      const prev = walker.prev\n      del(self, walker)\n      walker = prev\n    }\n  }\n}\n\nconst del = (self, node) => {\n  if (node) {\n    const hit = node.value\n    if (self[DISPOSE])\n      self[DISPOSE](hit.key, hit.value)\n\n    self[LENGTH] -= hit.length\n    self[CACHE].delete(hit.key)\n    self[LRU_LIST].removeNode(node)\n  }\n}\n\nclass Entry {\n  constructor (key, value, length, now, maxAge) {\n    this.key = key\n    this.value = value\n    this.length = length\n    this.now = now\n    this.maxAge = maxAge || 0\n  }\n}\n\nconst forEachStep = (self, fn, node, thisp) => {\n  let hit = node.value\n  if (isStale(self, hit)) {\n    del(self, node)\n    if (!self[ALLOW_STALE])\n      hit = undefined\n  }\n  if (hit)\n    fn.call(thisp, hit.value, hit.key, self)\n}\n\nmodule.exports = LRUCache\n","/**\n * An implementation of the RDF Dataset Normalization specification.\n *\n * @author Dave Longley\n *\n * Copyright 2010-2021 Digital Bazaar, Inc.\n */\nmodule.exports = require('./lib');\n","/*\n * Copyright (c) 2016-2021 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nmodule.exports = class IdentifierIssuer {\n  /**\n   * Creates a new IdentifierIssuer. A IdentifierIssuer issues unique\n   * identifiers, keeping track of any previously issued identifiers.\n   *\n   * @param prefix the prefix to use ('<prefix><counter>').\n   * @param existing an existing Map to use.\n   * @param counter the counter to use.\n   */\n  constructor(prefix, existing = new Map(), counter = 0) {\n    this.prefix = prefix;\n    this._existing = existing;\n    this.counter = counter;\n  }\n\n  /**\n   * Copies this IdentifierIssuer.\n   *\n   * @return a copy of this IdentifierIssuer.\n   */\n  clone() {\n    const {prefix, _existing, counter} = this;\n    return new IdentifierIssuer(prefix, new Map(_existing), counter);\n  }\n\n  /**\n   * Gets the new identifier for the given old identifier, where if no old\n   * identifier is given a new identifier will be generated.\n   *\n   * @param [old] the old identifier to get the new identifier for.\n   *\n   * @return the new identifier.\n   */\n  getId(old) {\n    // return existing old identifier\n    const existing = old && this._existing.get(old);\n    if(existing) {\n      return existing;\n    }\n\n    // get next identifier\n    const identifier = this.prefix + this.counter;\n    this.counter++;\n\n    // save mapping\n    if(old) {\n      this._existing.set(old, identifier);\n    }\n\n    return identifier;\n  }\n\n  /**\n   * Returns true if the given old identifer has already been assigned a new\n   * identifier.\n   *\n   * @param old the old identifier to check.\n   *\n   * @return true if the old identifier has been assigned a new identifier,\n   *   false if not.\n   */\n  hasId(old) {\n    return this._existing.has(old);\n  }\n\n  /**\n   * Returns all of the IDs that have been issued new IDs in the order in\n   * which they were issued new IDs.\n   *\n   * @return the list of old IDs that has been issued new IDs in order.\n   */\n  getOldIds() {\n    return [...this._existing.keys()];\n  }\n};\n","/*!\n * Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nrequire('setimmediate');\n\nconst crypto = self.crypto || self.msCrypto;\n\nmodule.exports = class MessageDigest {\n  /**\n   * Creates a new MessageDigest.\n   *\n   * @param algorithm the algorithm to use.\n   */\n  constructor(algorithm) {\n    // check if crypto.subtle is available\n    // check is here rather than top-level to only fail if class is used\n    if(!(crypto && crypto.subtle)) {\n      throw new Error('crypto.subtle not found.');\n    }\n    if(algorithm === 'sha256') {\n      this.algorithm = {name: 'SHA-256'};\n    } else if(algorithm === 'sha1') {\n      this.algorithm = {name: 'SHA-1'};\n    } else {\n      throw new Error(`Unsupported algorithm \"${algorithm}\".`);\n    }\n    this._content = '';\n  }\n\n  update(msg) {\n    this._content += msg;\n  }\n\n  async digest() {\n    const data = new TextEncoder().encode(this._content);\n    const buffer = new Uint8Array(\n      await crypto.subtle.digest(this.algorithm, data));\n    // return digest in hex\n    let hex = '';\n    for(let i = 0; i < buffer.length; ++i) {\n      hex += buffer[i].toString(16).padStart(2, '0');\n    }\n    return hex;\n  }\n};\n","/*!\n * Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\n// eslint-disable-next-line no-unused-vars\nconst TERMS = ['subject', 'predicate', 'object', 'graph'];\nconst RDF = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#';\nconst RDF_LANGSTRING = RDF + 'langString';\nconst XSD_STRING = 'http://www.w3.org/2001/XMLSchema#string';\n\nconst TYPE_NAMED_NODE = 'NamedNode';\nconst TYPE_BLANK_NODE = 'BlankNode';\nconst TYPE_LITERAL = 'Literal';\nconst TYPE_DEFAULT_GRAPH = 'DefaultGraph';\n\n// build regexes\nconst REGEX = {};\n(() => {\n  const iri = '(?:<([^:]+:[^>]*)>)';\n  // https://www.w3.org/TR/turtle/#grammar-production-BLANK_NODE_LABEL\n  const PN_CHARS_BASE =\n    'A-Z' + 'a-z' +\n    '\\u00C0-\\u00D6' +\n    '\\u00D8-\\u00F6' +\n    '\\u00F8-\\u02FF' +\n    '\\u0370-\\u037D' +\n    '\\u037F-\\u1FFF' +\n    '\\u200C-\\u200D' +\n    '\\u2070-\\u218F' +\n    '\\u2C00-\\u2FEF' +\n    '\\u3001-\\uD7FF' +\n    '\\uF900-\\uFDCF' +\n    '\\uFDF0-\\uFFFD';\n    // TODO:\n    //'\\u10000-\\uEFFFF';\n  const PN_CHARS_U =\n    PN_CHARS_BASE +\n    '_';\n  const PN_CHARS =\n    PN_CHARS_U +\n    '0-9' +\n    '-' +\n    '\\u00B7' +\n    '\\u0300-\\u036F' +\n    '\\u203F-\\u2040';\n  const BLANK_NODE_LABEL =\n    '(_:' +\n      '(?:[' + PN_CHARS_U + '0-9])' +\n      '(?:(?:[' + PN_CHARS + '.])*(?:[' + PN_CHARS + ']))?' +\n    ')';\n  const bnode = BLANK_NODE_LABEL;\n  const plain = '\"([^\"\\\\\\\\]*(?:\\\\\\\\.[^\"\\\\\\\\]*)*)\"';\n  const datatype = '(?:\\\\^\\\\^' + iri + ')';\n  const language = '(?:@([a-zA-Z]+(?:-[a-zA-Z0-9]+)*))';\n  const literal = '(?:' + plain + '(?:' + datatype + '|' + language + ')?)';\n  const ws = '[ \\\\t]+';\n  const wso = '[ \\\\t]*';\n\n  // define quad part regexes\n  const subject = '(?:' + iri + '|' + bnode + ')' + ws;\n  const property = iri + ws;\n  const object = '(?:' + iri + '|' + bnode + '|' + literal + ')' + wso;\n  const graphName = '(?:\\\\.|(?:(?:' + iri + '|' + bnode + ')' + wso + '\\\\.))';\n\n  // end of line and empty regexes\n  REGEX.eoln = /(?:\\r\\n)|(?:\\n)|(?:\\r)/g;\n  REGEX.empty = new RegExp('^' + wso + '$');\n\n  // full quad regex\n  REGEX.quad = new RegExp(\n    '^' + wso + subject + property + object + graphName + wso + '$');\n})();\n\nmodule.exports = class NQuads {\n  /**\n   * Parses RDF in the form of N-Quads.\n   *\n   * @param input the N-Quads input to parse.\n   *\n   * @return an RDF dataset (an array of quads per http://rdf.js.org/).\n   */\n  static parse(input) {\n    // build RDF dataset\n    const dataset = [];\n\n    const graphs = {};\n\n    // split N-Quad input into lines\n    const lines = input.split(REGEX.eoln);\n    let lineNumber = 0;\n    for(const line of lines) {\n      lineNumber++;\n\n      // skip empty lines\n      if(REGEX.empty.test(line)) {\n        continue;\n      }\n\n      // parse quad\n      const match = line.match(REGEX.quad);\n      if(match === null) {\n        throw new Error('N-Quads parse error on line ' + lineNumber + '.');\n      }\n\n      // create RDF quad\n      const quad = {subject: null, predicate: null, object: null, graph: null};\n\n      // get subject\n      if(match[1] !== undefined) {\n        quad.subject = {termType: TYPE_NAMED_NODE, value: match[1]};\n      } else {\n        quad.subject = {termType: TYPE_BLANK_NODE, value: match[2]};\n      }\n\n      // get predicate\n      quad.predicate = {termType: TYPE_NAMED_NODE, value: match[3]};\n\n      // get object\n      if(match[4] !== undefined) {\n        quad.object = {termType: TYPE_NAMED_NODE, value: match[4]};\n      } else if(match[5] !== undefined) {\n        quad.object = {termType: TYPE_BLANK_NODE, value: match[5]};\n      } else {\n        quad.object = {\n          termType: TYPE_LITERAL,\n          value: undefined,\n          datatype: {\n            termType: TYPE_NAMED_NODE\n          }\n        };\n        if(match[7] !== undefined) {\n          quad.object.datatype.value = match[7];\n        } else if(match[8] !== undefined) {\n          quad.object.datatype.value = RDF_LANGSTRING;\n          quad.object.language = match[8];\n        } else {\n          quad.object.datatype.value = XSD_STRING;\n        }\n        quad.object.value = _unescape(match[6]);\n      }\n\n      // get graph\n      if(match[9] !== undefined) {\n        quad.graph = {\n          termType: TYPE_NAMED_NODE,\n          value: match[9]\n        };\n      } else if(match[10] !== undefined) {\n        quad.graph = {\n          termType: TYPE_BLANK_NODE,\n          value: match[10]\n        };\n      } else {\n        quad.graph = {\n          termType: TYPE_DEFAULT_GRAPH,\n          value: ''\n        };\n      }\n\n      // only add quad if it is unique in its graph\n      if(!(quad.graph.value in graphs)) {\n        graphs[quad.graph.value] = [quad];\n        dataset.push(quad);\n      } else {\n        let unique = true;\n        const quads = graphs[quad.graph.value];\n        for(const q of quads) {\n          if(_compareTriples(q, quad)) {\n            unique = false;\n            break;\n          }\n        }\n        if(unique) {\n          quads.push(quad);\n          dataset.push(quad);\n        }\n      }\n    }\n\n    return dataset;\n  }\n\n  /**\n   * Converts an RDF dataset to N-Quads.\n   *\n   * @param dataset (array of quads) the RDF dataset to convert.\n   *\n   * @return the N-Quads string.\n   */\n  static serialize(dataset) {\n    if(!Array.isArray(dataset)) {\n      dataset = NQuads.legacyDatasetToQuads(dataset);\n    }\n    const quads = [];\n    for(const quad of dataset) {\n      quads.push(NQuads.serializeQuad(quad));\n    }\n    return quads.sort().join('');\n  }\n\n  /**\n   * Converts RDF quad components to an N-Quad string (a single quad).\n   *\n   * @param {Object} s - N-Quad subject component.\n   * @param {Object} p - N-Quad predicate component.\n   * @param {Object} o - N-Quad object component.\n   * @param {Object} g - N-Quad graph component.\n   *\n   * @return {string} the N-Quad.\n   */\n  static serializeQuadComponents(s, p, o, g) {\n    let nquad = '';\n\n    // subject can only be NamedNode or BlankNode\n    if(s.termType === TYPE_NAMED_NODE) {\n      nquad += `<${s.value}>`;\n    } else {\n      nquad += `${s.value}`;\n    }\n\n    // predicate can only be NamedNode\n    nquad += ` <${p.value}> `;\n\n    // object is NamedNode, BlankNode, or Literal\n    if(o.termType === TYPE_NAMED_NODE) {\n      nquad += `<${o.value}>`;\n    } else if(o.termType === TYPE_BLANK_NODE) {\n      nquad += o.value;\n    } else {\n      nquad += `\"${_escape(o.value)}\"`;\n      if(o.datatype.value === RDF_LANGSTRING) {\n        if(o.language) {\n          nquad += `@${o.language}`;\n        }\n      } else if(o.datatype.value !== XSD_STRING) {\n        nquad += `^^<${o.datatype.value}>`;\n      }\n    }\n\n    // graph can only be NamedNode or BlankNode (or DefaultGraph, but that\n    // does not add to `nquad`)\n    if(g.termType === TYPE_NAMED_NODE) {\n      nquad += ` <${g.value}>`;\n    } else if(g.termType === TYPE_BLANK_NODE) {\n      nquad += ` ${g.value}`;\n    }\n\n    nquad += ' .\\n';\n    return nquad;\n  }\n\n  /**\n   * Converts an RDF quad to an N-Quad string (a single quad).\n   *\n   * @param quad the RDF quad convert.\n   *\n   * @return the N-Quad string.\n   */\n  static serializeQuad(quad) {\n    return NQuads.serializeQuadComponents(\n      quad.subject, quad.predicate, quad.object, quad.graph);\n  }\n\n  /**\n   * Converts a legacy-formatted dataset to an array of quads dataset per\n   * http://rdf.js.org/.\n   *\n   * @param dataset the legacy dataset to convert.\n   *\n   * @return the array of quads dataset.\n   */\n  static legacyDatasetToQuads(dataset) {\n    const quads = [];\n\n    const termTypeMap = {\n      'blank node': TYPE_BLANK_NODE,\n      IRI: TYPE_NAMED_NODE,\n      literal: TYPE_LITERAL\n    };\n\n    for(const graphName in dataset) {\n      const triples = dataset[graphName];\n      triples.forEach(triple => {\n        const quad = {};\n        for(const componentName in triple) {\n          const oldComponent = triple[componentName];\n          const newComponent = {\n            termType: termTypeMap[oldComponent.type],\n            value: oldComponent.value\n          };\n          if(newComponent.termType === TYPE_LITERAL) {\n            newComponent.datatype = {\n              termType: TYPE_NAMED_NODE\n            };\n            if('datatype' in oldComponent) {\n              newComponent.datatype.value = oldComponent.datatype;\n            }\n            if('language' in oldComponent) {\n              if(!('datatype' in oldComponent)) {\n                newComponent.datatype.value = RDF_LANGSTRING;\n              }\n              newComponent.language = oldComponent.language;\n            } else if(!('datatype' in oldComponent)) {\n              newComponent.datatype.value = XSD_STRING;\n            }\n          }\n          quad[componentName] = newComponent;\n        }\n        if(graphName === '@default') {\n          quad.graph = {\n            termType: TYPE_DEFAULT_GRAPH,\n            value: ''\n          };\n        } else {\n          quad.graph = {\n            termType: graphName.startsWith('_:') ?\n              TYPE_BLANK_NODE : TYPE_NAMED_NODE,\n            value: graphName\n          };\n        }\n        quads.push(quad);\n      });\n    }\n\n    return quads;\n  }\n};\n\n/**\n * Compares two RDF triples for equality.\n *\n * @param t1 the first triple.\n * @param t2 the second triple.\n *\n * @return true if the triples are the same, false if not.\n */\nfunction _compareTriples(t1, t2) {\n  // compare subject and object types first as it is the quickest check\n  if(!(t1.subject.termType === t2.subject.termType &&\n    t1.object.termType === t2.object.termType)) {\n    return false;\n  }\n  // compare values\n  if(!(t1.subject.value === t2.subject.value &&\n    t1.predicate.value === t2.predicate.value &&\n    t1.object.value === t2.object.value)) {\n    return false;\n  }\n  if(t1.object.termType !== TYPE_LITERAL) {\n    // no `datatype` or `language` to check\n    return true;\n  }\n  return (\n    (t1.object.datatype.termType === t2.object.datatype.termType) &&\n    (t1.object.language === t2.object.language) &&\n    (t1.object.datatype.value === t2.object.datatype.value)\n  );\n}\n\nconst _escapeRegex = /[\"\\\\\\n\\r]/g;\n/**\n * Escape string to N-Quads literal\n */\nfunction _escape(s) {\n  return s.replace(_escapeRegex, function(match) {\n    switch(match) {\n      case '\"': return '\\\\\"';\n      case '\\\\': return '\\\\\\\\';\n      case '\\n': return '\\\\n';\n      case '\\r': return '\\\\r';\n    }\n  });\n}\n\nconst _unescapeRegex =\n  /(?:\\\\([tbnrf\"'\\\\]))|(?:\\\\u([0-9A-Fa-f]{4}))|(?:\\\\U([0-9A-Fa-f]{8}))/g;\n/**\n * Unescape N-Quads literal to string\n */\nfunction _unescape(s) {\n  return s.replace(_unescapeRegex, function(match, code, u, U) {\n    if(code) {\n      switch(code) {\n        case 't': return '\\t';\n        case 'b': return '\\b';\n        case 'n': return '\\n';\n        case 'r': return '\\r';\n        case 'f': return '\\f';\n        case '\"': return '\"';\n        case '\\'': return '\\'';\n        case '\\\\': return '\\\\';\n      }\n    }\n    if(u) {\n      return String.fromCharCode(parseInt(u, 16));\n    }\n    if(U) {\n      // FIXME: support larger values\n      throw new Error('Unsupported U escape');\n    }\n  });\n}\n","/*!\n * Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nmodule.exports = class Permuter {\n  /**\n   * A Permuter iterates over all possible permutations of the given array\n   * of elements.\n   *\n   * @param list the array of elements to iterate over.\n   */\n  constructor(list) {\n    // original array\n    this.current = list.sort();\n    // indicates whether there are more permutations\n    this.done = false;\n    // directional info for permutation algorithm\n    this.dir = new Map();\n    for(let i = 0; i < list.length; ++i) {\n      this.dir.set(list[i], true);\n    }\n  }\n\n  /**\n   * Returns true if there is another permutation.\n   *\n   * @return true if there is another permutation, false if not.\n   */\n  hasNext() {\n    return !this.done;\n  }\n\n  /**\n   * Gets the next permutation. Call hasNext() to ensure there is another one\n   * first.\n   *\n   * @return the next permutation.\n   */\n  next() {\n    // copy current permutation to return it\n    const {current, dir} = this;\n    const rval = current.slice();\n\n    /* Calculate the next permutation using the Steinhaus-Johnson-Trotter\n     permutation algorithm. */\n\n    // get largest mobile element k\n    // (mobile: element is greater than the one it is looking at)\n    let k = null;\n    let pos = 0;\n    const length = current.length;\n    for(let i = 0; i < length; ++i) {\n      const element = current[i];\n      const left = dir.get(element);\n      if((k === null || element > k) &&\n        ((left && i > 0 && element > current[i - 1]) ||\n        (!left && i < (length - 1) && element > current[i + 1]))) {\n        k = element;\n        pos = i;\n      }\n    }\n\n    // no more permutations\n    if(k === null) {\n      this.done = true;\n    } else {\n      // swap k and the element it is looking at\n      const swap = dir.get(k) ? pos - 1 : pos + 1;\n      current[pos] = current[swap];\n      current[swap] = k;\n\n      // reverse the direction of all elements larger than k\n      for(const element of current) {\n        if(element > k) {\n          dir.set(element, !dir.get(element));\n        }\n      }\n    }\n\n    return rval;\n  }\n};\n","/*!\n * Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst IdentifierIssuer = require('./IdentifierIssuer');\nconst MessageDigest = require('./MessageDigest');\nconst Permuter = require('./Permuter');\nconst NQuads = require('./NQuads');\n\nmodule.exports = class URDNA2015 {\n  constructor({\n    createMessageDigest = () => new MessageDigest('sha256'),\n    canonicalIdMap = new Map(),\n    maxDeepIterations = Infinity\n  } = {}) {\n    this.name = 'URDNA2015';\n    this.blankNodeInfo = new Map();\n    this.canonicalIssuer = new IdentifierIssuer('_:c14n', canonicalIdMap);\n    this.createMessageDigest = createMessageDigest;\n    this.maxDeepIterations = maxDeepIterations;\n    this.quads = null;\n    this.deepIterations = null;\n  }\n\n  // 4.4) Normalization Algorithm\n  async main(dataset) {\n    this.deepIterations = new Map();\n    this.quads = dataset;\n\n    // 1) Create the normalization state.\n    // 2) For every quad in input dataset:\n    for(const quad of dataset) {\n      // 2.1) For each blank node that occurs in the quad, add a reference\n      // to the quad using the blank node identifier in the blank node to\n      // quads map, creating a new entry if necessary.\n      this._addBlankNodeQuadInfo({quad, component: quad.subject});\n      this._addBlankNodeQuadInfo({quad, component: quad.object});\n      this._addBlankNodeQuadInfo({quad, component: quad.graph});\n    }\n\n    // 3) Create a list of non-normalized blank node identifiers\n    // non-normalized identifiers and populate it using the keys from the\n    // blank node to quads map.\n    // Note: We use a map here and it was generated during step 2.\n\n    // 4) `simple` flag is skipped -- loop is optimized away. This optimization\n    // is permitted because there was a typo in the hash first degree quads\n    // algorithm in the URDNA2015 spec that was implemented widely making it\n    // such that it could not be fixed; the result was that the loop only\n    // needs to be run once and the first degree quad hashes will never change.\n    // 5.1-5.2 are skipped; first degree quad hashes are generated just once\n    // for all non-normalized blank nodes.\n\n    // 5.3) For each blank node identifier identifier in non-normalized\n    // identifiers:\n    const hashToBlankNodes = new Map();\n    const nonNormalized = [...this.blankNodeInfo.keys()];\n    let i = 0;\n    for(const id of nonNormalized) {\n      // Note: batch hashing first degree quads 100 at a time\n      if(++i % 100 === 0) {\n        await this._yield();\n      }\n      // steps 5.3.1 and 5.3.2:\n      await this._hashAndTrackBlankNode({id, hashToBlankNodes});\n    }\n\n    // 5.4) For each hash to identifier list mapping in hash to blank\n    // nodes map, lexicographically-sorted by hash:\n    const hashes = [...hashToBlankNodes.keys()].sort();\n    // optimize away second sort, gather non-unique hashes in order as we go\n    const nonUnique = [];\n    for(const hash of hashes) {\n      // 5.4.1) If the length of identifier list is greater than 1,\n      // continue to the next mapping.\n      const idList = hashToBlankNodes.get(hash);\n      if(idList.length > 1) {\n        nonUnique.push(idList);\n        continue;\n      }\n\n      // 5.4.2) Use the Issue Identifier algorithm, passing canonical\n      // issuer and the single blank node identifier in identifier\n      // list, identifier, to issue a canonical replacement identifier\n      // for identifier.\n      const id = idList[0];\n      this.canonicalIssuer.getId(id);\n\n      // Note: These steps are skipped, optimized away since the loop\n      // only needs to be run once.\n      // 5.4.3) Remove identifier from non-normalized identifiers.\n      // 5.4.4) Remove hash from the hash to blank nodes map.\n      // 5.4.5) Set simple to true.\n    }\n\n    // 6) For each hash to identifier list mapping in hash to blank nodes map,\n    // lexicographically-sorted by hash:\n    // Note: sort optimized away, use `nonUnique`.\n    for(const idList of nonUnique) {\n      // 6.1) Create hash path list where each item will be a result of\n      // running the Hash N-Degree Quads algorithm.\n      const hashPathList = [];\n\n      // 6.2) For each blank node identifier identifier in identifier list:\n      for(const id of idList) {\n        // 6.2.1) If a canonical identifier has already been issued for\n        // identifier, continue to the next identifier.\n        if(this.canonicalIssuer.hasId(id)) {\n          continue;\n        }\n\n        // 6.2.2) Create temporary issuer, an identifier issuer\n        // initialized with the prefix _:b.\n        const issuer = new IdentifierIssuer('_:b');\n\n        // 6.2.3) Use the Issue Identifier algorithm, passing temporary\n        // issuer and identifier, to issue a new temporary blank node\n        // identifier for identifier.\n        issuer.getId(id);\n\n        // 6.2.4) Run the Hash N-Degree Quads algorithm, passing\n        // temporary issuer, and append the result to the hash path list.\n        const result = await this.hashNDegreeQuads(id, issuer);\n        hashPathList.push(result);\n      }\n\n      // 6.3) For each result in the hash path list,\n      // lexicographically-sorted by the hash in result:\n      hashPathList.sort(_stringHashCompare);\n      for(const result of hashPathList) {\n        // 6.3.1) For each blank node identifier, existing identifier,\n        // that was issued a temporary identifier by identifier issuer\n        // in result, issue a canonical identifier, in the same order,\n        // using the Issue Identifier algorithm, passing canonical\n        // issuer and existing identifier.\n        const oldIds = result.issuer.getOldIds();\n        for(const id of oldIds) {\n          this.canonicalIssuer.getId(id);\n        }\n      }\n    }\n\n    /* Note: At this point all blank nodes in the set of RDF quads have been\n    assigned canonical identifiers, which have been stored in the canonical\n    issuer. Here each quad is updated by assigning each of its blank nodes\n    its new identifier. */\n\n    // 7) For each quad, quad, in input dataset:\n    const normalized = [];\n    for(const quad of this.quads) {\n      // 7.1) Create a copy, quad copy, of quad and replace any existing\n      // blank node identifiers using the canonical identifiers\n      // previously issued by canonical issuer.\n      // Note: We optimize away the copy here.\n      const nQuad = NQuads.serializeQuadComponents(\n        this._componentWithCanonicalId(quad.subject),\n        quad.predicate,\n        this._componentWithCanonicalId(quad.object),\n        this._componentWithCanonicalId(quad.graph)\n      );\n      // 7.2) Add quad copy to the normalized dataset.\n      normalized.push(nQuad);\n    }\n\n    // sort normalized output\n    normalized.sort();\n\n    // 8) Return the normalized dataset.\n    return normalized.join('');\n  }\n\n  // 4.6) Hash First Degree Quads\n  async hashFirstDegreeQuads(id) {\n    // 1) Initialize nquads to an empty list. It will be used to store quads in\n    // N-Quads format.\n    const nquads = [];\n\n    // 2) Get the list of quads `quads` associated with the reference blank node\n    // identifier in the blank node to quads map.\n    const info = this.blankNodeInfo.get(id);\n    const quads = info.quads;\n\n    // 3) For each quad `quad` in `quads`:\n    for(const quad of quads) {\n      // 3.1) Serialize the quad in N-Quads format with the following special\n      // rule:\n\n      // 3.1.1) If any component in quad is an blank node, then serialize it\n      // using a special identifier as follows:\n      const copy = {\n        subject: null, predicate: quad.predicate, object: null, graph: null\n      };\n      // 3.1.2) If the blank node's existing blank node identifier matches\n      // the reference blank node identifier then use the blank node\n      // identifier _:a, otherwise, use the blank node identifier _:z.\n      copy.subject = this.modifyFirstDegreeComponent(\n        id, quad.subject, 'subject');\n      copy.object = this.modifyFirstDegreeComponent(\n        id, quad.object, 'object');\n      copy.graph = this.modifyFirstDegreeComponent(\n        id, quad.graph, 'graph');\n      nquads.push(NQuads.serializeQuad(copy));\n    }\n\n    // 4) Sort nquads in lexicographical order.\n    nquads.sort();\n\n    // 5) Return the hash that results from passing the sorted, joined nquads\n    // through the hash algorithm.\n    const md = this.createMessageDigest();\n    for(const nquad of nquads) {\n      md.update(nquad);\n    }\n    info.hash = await md.digest();\n    return info.hash;\n  }\n\n  // 4.7) Hash Related Blank Node\n  async hashRelatedBlankNode(related, quad, issuer, position) {\n    // 1) Set the identifier to use for related, preferring first the canonical\n    // identifier for related if issued, second the identifier issued by issuer\n    // if issued, and last, if necessary, the result of the Hash First Degree\n    // Quads algorithm, passing related.\n    let id;\n    if(this.canonicalIssuer.hasId(related)) {\n      id = this.canonicalIssuer.getId(related);\n    } else if(issuer.hasId(related)) {\n      id = issuer.getId(related);\n    } else {\n      id = this.blankNodeInfo.get(related).hash;\n    }\n\n    // 2) Initialize a string input to the value of position.\n    // Note: We use a hash object instead.\n    const md = this.createMessageDigest();\n    md.update(position);\n\n    // 3) If position is not g, append <, the value of the predicate in quad,\n    // and > to input.\n    if(position !== 'g') {\n      md.update(this.getRelatedPredicate(quad));\n    }\n\n    // 4) Append identifier to input.\n    md.update(id);\n\n    // 5) Return the hash that results from passing input through the hash\n    // algorithm.\n    return md.digest();\n  }\n\n  // 4.8) Hash N-Degree Quads\n  async hashNDegreeQuads(id, issuer) {\n    const deepIterations = this.deepIterations.get(id) || 0;\n    if(deepIterations > this.maxDeepIterations) {\n      throw new Error(\n        `Maximum deep iterations (${this.maxDeepIterations}) exceeded.`);\n    }\n    this.deepIterations.set(id, deepIterations + 1);\n\n    // 1) Create a hash to related blank nodes map for storing hashes that\n    // identify related blank nodes.\n    // Note: 2) and 3) handled within `createHashToRelated`\n    const md = this.createMessageDigest();\n    const hashToRelated = await this.createHashToRelated(id, issuer);\n\n    // 4) Create an empty string, data to hash.\n    // Note: We created a hash object `md` above instead.\n\n    // 5) For each related hash to blank node list mapping in hash to related\n    // blank nodes map, sorted lexicographically by related hash:\n    const hashes = [...hashToRelated.keys()].sort();\n    for(const hash of hashes) {\n      // 5.1) Append the related hash to the data to hash.\n      md.update(hash);\n\n      // 5.2) Create a string chosen path.\n      let chosenPath = '';\n\n      // 5.3) Create an unset chosen issuer variable.\n      let chosenIssuer;\n\n      // 5.4) For each permutation of blank node list:\n      const permuter = new Permuter(hashToRelated.get(hash));\n      let i = 0;\n      while(permuter.hasNext()) {\n        const permutation = permuter.next();\n        // Note: batch permutations 3 at a time\n        if(++i % 3 === 0) {\n          await this._yield();\n        }\n\n        // 5.4.1) Create a copy of issuer, issuer copy.\n        let issuerCopy = issuer.clone();\n\n        // 5.4.2) Create a string path.\n        let path = '';\n\n        // 5.4.3) Create a recursion list, to store blank node identifiers\n        // that must be recursively processed by this algorithm.\n        const recursionList = [];\n\n        // 5.4.4) For each related in permutation:\n        let nextPermutation = false;\n        for(const related of permutation) {\n          // 5.4.4.1) If a canonical identifier has been issued for\n          // related, append it to path.\n          if(this.canonicalIssuer.hasId(related)) {\n            path += this.canonicalIssuer.getId(related);\n          } else {\n            // 5.4.4.2) Otherwise:\n            // 5.4.4.2.1) If issuer copy has not issued an identifier for\n            // related, append related to recursion list.\n            if(!issuerCopy.hasId(related)) {\n              recursionList.push(related);\n            }\n            // 5.4.4.2.2) Use the Issue Identifier algorithm, passing\n            // issuer copy and related and append the result to path.\n            path += issuerCopy.getId(related);\n          }\n\n          // 5.4.4.3) If chosen path is not empty and the length of path\n          // is greater than or equal to the length of chosen path and\n          // path is lexicographically greater than chosen path, then\n          // skip to the next permutation.\n          // Note: Comparing path length to chosen path length can be optimized\n          // away; only compare lexicographically.\n          if(chosenPath.length !== 0 && path > chosenPath) {\n            nextPermutation = true;\n            break;\n          }\n        }\n\n        if(nextPermutation) {\n          continue;\n        }\n\n        // 5.4.5) For each related in recursion list:\n        for(const related of recursionList) {\n          // 5.4.5.1) Set result to the result of recursively executing\n          // the Hash N-Degree Quads algorithm, passing related for\n          // identifier and issuer copy for path identifier issuer.\n          const result = await this.hashNDegreeQuads(related, issuerCopy);\n\n          // 5.4.5.2) Use the Issue Identifier algorithm, passing issuer\n          // copy and related and append the result to path.\n          path += issuerCopy.getId(related);\n\n          // 5.4.5.3) Append <, the hash in result, and > to path.\n          path += `<${result.hash}>`;\n\n          // 5.4.5.4) Set issuer copy to the identifier issuer in\n          // result.\n          issuerCopy = result.issuer;\n\n          // 5.4.5.5) If chosen path is not empty and the length of path\n          // is greater than or equal to the length of chosen path and\n          // path is lexicographically greater than chosen path, then\n          // skip to the next permutation.\n          // Note: Comparing path length to chosen path length can be optimized\n          // away; only compare lexicographically.\n          if(chosenPath.length !== 0 && path > chosenPath) {\n            nextPermutation = true;\n            break;\n          }\n        }\n\n        if(nextPermutation) {\n          continue;\n        }\n\n        // 5.4.6) If chosen path is empty or path is lexicographically\n        // less than chosen path, set chosen path to path and chosen\n        // issuer to issuer copy.\n        if(chosenPath.length === 0 || path < chosenPath) {\n          chosenPath = path;\n          chosenIssuer = issuerCopy;\n        }\n      }\n\n      // 5.5) Append chosen path to data to hash.\n      md.update(chosenPath);\n\n      // 5.6) Replace issuer, by reference, with chosen issuer.\n      issuer = chosenIssuer;\n    }\n\n    // 6) Return issuer and the hash that results from passing data to hash\n    // through the hash algorithm.\n    return {hash: await md.digest(), issuer};\n  }\n\n  // helper for modifying component during Hash First Degree Quads\n  modifyFirstDegreeComponent(id, component) {\n    if(component.termType !== 'BlankNode') {\n      return component;\n    }\n    /* Note: A mistake in the URDNA2015 spec that made its way into\n    implementations (and therefore must stay to avoid interop breakage)\n    resulted in an assigned canonical ID, if available for\n    `component.value`, not being used in place of `_:a`/`_:z`, so\n    we don't use it here. */\n    return {\n      termType: 'BlankNode',\n      value: component.value === id ? '_:a' : '_:z'\n    };\n  }\n\n  // helper for getting a related predicate\n  getRelatedPredicate(quad) {\n    return `<${quad.predicate.value}>`;\n  }\n\n  // helper for creating hash to related blank nodes map\n  async createHashToRelated(id, issuer) {\n    // 1) Create a hash to related blank nodes map for storing hashes that\n    // identify related blank nodes.\n    const hashToRelated = new Map();\n\n    // 2) Get a reference, quads, to the list of quads in the blank node to\n    // quads map for the key identifier.\n    const quads = this.blankNodeInfo.get(id).quads;\n\n    // 3) For each quad in quads:\n    let i = 0;\n    for(const quad of quads) {\n      // Note: batch hashing related blank node quads 100 at a time\n      if(++i % 100 === 0) {\n        await this._yield();\n      }\n      // 3.1) For each component in quad, if component is the subject, object,\n      // and graph name and it is a blank node that is not identified by\n      // identifier:\n      // steps 3.1.1 and 3.1.2 occur in helpers:\n      await Promise.all([\n        this._addRelatedBlankNodeHash({\n          quad, component: quad.subject, position: 's',\n          id, issuer, hashToRelated\n        }),\n        this._addRelatedBlankNodeHash({\n          quad, component: quad.object, position: 'o',\n          id, issuer, hashToRelated\n        }),\n        this._addRelatedBlankNodeHash({\n          quad, component: quad.graph, position: 'g',\n          id, issuer, hashToRelated\n        })\n      ]);\n    }\n\n    return hashToRelated;\n  }\n\n  async _hashAndTrackBlankNode({id, hashToBlankNodes}) {\n    // 5.3.1) Create a hash, hash, according to the Hash First Degree\n    // Quads algorithm.\n    const hash = await this.hashFirstDegreeQuads(id);\n\n    // 5.3.2) Add hash and identifier to hash to blank nodes map,\n    // creating a new entry if necessary.\n    const idList = hashToBlankNodes.get(hash);\n    if(!idList) {\n      hashToBlankNodes.set(hash, [id]);\n    } else {\n      idList.push(id);\n    }\n  }\n\n  _addBlankNodeQuadInfo({quad, component}) {\n    if(component.termType !== 'BlankNode') {\n      return;\n    }\n    const id = component.value;\n    const info = this.blankNodeInfo.get(id);\n    if(info) {\n      info.quads.add(quad);\n    } else {\n      this.blankNodeInfo.set(id, {quads: new Set([quad]), hash: null});\n    }\n  }\n\n  async _addRelatedBlankNodeHash(\n    {quad, component, position, id, issuer, hashToRelated}) {\n    if(!(component.termType === 'BlankNode' && component.value !== id)) {\n      return;\n    }\n    // 3.1.1) Set hash to the result of the Hash Related Blank Node\n    // algorithm, passing the blank node identifier for component as\n    // related, quad, path identifier issuer as issuer, and position as\n    // either s, o, or g based on whether component is a subject, object,\n    // graph name, respectively.\n    const related = component.value;\n    const hash = await this.hashRelatedBlankNode(\n      related, quad, issuer, position);\n\n    // 3.1.2) Add a mapping of hash to the blank node identifier for\n    // component to hash to related blank nodes map, adding an entry as\n    // necessary.\n    const entries = hashToRelated.get(hash);\n    if(entries) {\n      entries.push(related);\n    } else {\n      hashToRelated.set(hash, [related]);\n    }\n  }\n\n  // canonical ids for 7.1\n  _componentWithCanonicalId(component) {\n    if(component.termType === 'BlankNode' &&\n      !component.value.startsWith(this.canonicalIssuer.prefix)) {\n      // create new BlankNode\n      return {\n        termType: 'BlankNode',\n        value: this.canonicalIssuer.getId(component.value)\n      };\n    }\n    return component;\n  }\n\n  async _yield() {\n    return new Promise(resolve => setImmediate(resolve));\n  }\n};\n\nfunction _stringHashCompare(a, b) {\n  return a.hash < b.hash ? -1 : a.hash > b.hash ? 1 : 0;\n}\n","/*!\n * Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst IdentifierIssuer = require('./IdentifierIssuer');\n// FIXME: do not import; convert to requiring a\n// hash factory\nconst MessageDigest = require('./MessageDigest');\nconst Permuter = require('./Permuter');\nconst NQuads = require('./NQuads');\n\nmodule.exports = class URDNA2015Sync {\n  constructor({\n    createMessageDigest = () => new MessageDigest('sha256'),\n    canonicalIdMap = new Map(),\n    maxDeepIterations = Infinity\n  } = {}) {\n    this.name = 'URDNA2015';\n    this.blankNodeInfo = new Map();\n    this.canonicalIssuer = new IdentifierIssuer('_:c14n', canonicalIdMap);\n    this.createMessageDigest = createMessageDigest;\n    this.maxDeepIterations = maxDeepIterations;\n    this.quads = null;\n    this.deepIterations = null;\n  }\n\n  // 4.4) Normalization Algorithm\n  main(dataset) {\n    this.deepIterations = new Map();\n    this.quads = dataset;\n\n    // 1) Create the normalization state.\n    // 2) For every quad in input dataset:\n    for(const quad of dataset) {\n      // 2.1) For each blank node that occurs in the quad, add a reference\n      // to the quad using the blank node identifier in the blank node to\n      // quads map, creating a new entry if necessary.\n      this._addBlankNodeQuadInfo({quad, component: quad.subject});\n      this._addBlankNodeQuadInfo({quad, component: quad.object});\n      this._addBlankNodeQuadInfo({quad, component: quad.graph});\n    }\n\n    // 3) Create a list of non-normalized blank node identifiers\n    // non-normalized identifiers and populate it using the keys from the\n    // blank node to quads map.\n    // Note: We use a map here and it was generated during step 2.\n\n    // 4) `simple` flag is skipped -- loop is optimized away. This optimization\n    // is permitted because there was a typo in the hash first degree quads\n    // algorithm in the URDNA2015 spec that was implemented widely making it\n    // such that it could not be fixed; the result was that the loop only\n    // needs to be run once and the first degree quad hashes will never change.\n    // 5.1-5.2 are skipped; first degree quad hashes are generated just once\n    // for all non-normalized blank nodes.\n\n    // 5.3) For each blank node identifier identifier in non-normalized\n    // identifiers:\n    const hashToBlankNodes = new Map();\n    const nonNormalized = [...this.blankNodeInfo.keys()];\n    for(const id of nonNormalized) {\n      // steps 5.3.1 and 5.3.2:\n      this._hashAndTrackBlankNode({id, hashToBlankNodes});\n    }\n\n    // 5.4) For each hash to identifier list mapping in hash to blank\n    // nodes map, lexicographically-sorted by hash:\n    const hashes = [...hashToBlankNodes.keys()].sort();\n    // optimize away second sort, gather non-unique hashes in order as we go\n    const nonUnique = [];\n    for(const hash of hashes) {\n      // 5.4.1) If the length of identifier list is greater than 1,\n      // continue to the next mapping.\n      const idList = hashToBlankNodes.get(hash);\n      if(idList.length > 1) {\n        nonUnique.push(idList);\n        continue;\n      }\n\n      // 5.4.2) Use the Issue Identifier algorithm, passing canonical\n      // issuer and the single blank node identifier in identifier\n      // list, identifier, to issue a canonical replacement identifier\n      // for identifier.\n      const id = idList[0];\n      this.canonicalIssuer.getId(id);\n\n      // Note: These steps are skipped, optimized away since the loop\n      // only needs to be run once.\n      // 5.4.3) Remove identifier from non-normalized identifiers.\n      // 5.4.4) Remove hash from the hash to blank nodes map.\n      // 5.4.5) Set simple to true.\n    }\n\n    // 6) For each hash to identifier list mapping in hash to blank nodes map,\n    // lexicographically-sorted by hash:\n    // Note: sort optimized away, use `nonUnique`.\n    for(const idList of nonUnique) {\n      // 6.1) Create hash path list where each item will be a result of\n      // running the Hash N-Degree Quads algorithm.\n      const hashPathList = [];\n\n      // 6.2) For each blank node identifier identifier in identifier list:\n      for(const id of idList) {\n        // 6.2.1) If a canonical identifier has already been issued for\n        // identifier, continue to the next identifier.\n        if(this.canonicalIssuer.hasId(id)) {\n          continue;\n        }\n\n        // 6.2.2) Create temporary issuer, an identifier issuer\n        // initialized with the prefix _:b.\n        const issuer = new IdentifierIssuer('_:b');\n\n        // 6.2.3) Use the Issue Identifier algorithm, passing temporary\n        // issuer and identifier, to issue a new temporary blank node\n        // identifier for identifier.\n        issuer.getId(id);\n\n        // 6.2.4) Run the Hash N-Degree Quads algorithm, passing\n        // temporary issuer, and append the result to the hash path list.\n        const result = this.hashNDegreeQuads(id, issuer);\n        hashPathList.push(result);\n      }\n\n      // 6.3) For each result in the hash path list,\n      // lexicographically-sorted by the hash in result:\n      hashPathList.sort(_stringHashCompare);\n      for(const result of hashPathList) {\n        // 6.3.1) For each blank node identifier, existing identifier,\n        // that was issued a temporary identifier by identifier issuer\n        // in result, issue a canonical identifier, in the same order,\n        // using the Issue Identifier algorithm, passing canonical\n        // issuer and existing identifier.\n        const oldIds = result.issuer.getOldIds();\n        for(const id of oldIds) {\n          this.canonicalIssuer.getId(id);\n        }\n      }\n    }\n\n    /* Note: At this point all blank nodes in the set of RDF quads have been\n    assigned canonical identifiers, which have been stored in the canonical\n    issuer. Here each quad is updated by assigning each of its blank nodes\n    its new identifier. */\n\n    // 7) For each quad, quad, in input dataset:\n    const normalized = [];\n    for(const quad of this.quads) {\n      // 7.1) Create a copy, quad copy, of quad and replace any existing\n      // blank node identifiers using the canonical identifiers\n      // previously issued by canonical issuer.\n      // Note: We optimize away the copy here.\n      const nQuad = NQuads.serializeQuadComponents(\n        this._componentWithCanonicalId({component: quad.subject}),\n        quad.predicate,\n        this._componentWithCanonicalId({component: quad.object}),\n        this._componentWithCanonicalId({component: quad.graph})\n      );\n      // 7.2) Add quad copy to the normalized dataset.\n      normalized.push(nQuad);\n    }\n\n    // sort normalized output\n    normalized.sort();\n\n    // 8) Return the normalized dataset.\n    return normalized.join('');\n  }\n\n  // 4.6) Hash First Degree Quads\n  hashFirstDegreeQuads(id) {\n    // 1) Initialize nquads to an empty list. It will be used to store quads in\n    // N-Quads format.\n    const nquads = [];\n\n    // 2) Get the list of quads `quads` associated with the reference blank node\n    // identifier in the blank node to quads map.\n    const info = this.blankNodeInfo.get(id);\n    const quads = info.quads;\n\n    // 3) For each quad `quad` in `quads`:\n    for(const quad of quads) {\n      // 3.1) Serialize the quad in N-Quads format with the following special\n      // rule:\n\n      // 3.1.1) If any component in quad is an blank node, then serialize it\n      // using a special identifier as follows:\n      const copy = {\n        subject: null, predicate: quad.predicate, object: null, graph: null\n      };\n      // 3.1.2) If the blank node's existing blank node identifier matches\n      // the reference blank node identifier then use the blank node\n      // identifier _:a, otherwise, use the blank node identifier _:z.\n      copy.subject = this.modifyFirstDegreeComponent(\n        id, quad.subject, 'subject');\n      copy.object = this.modifyFirstDegreeComponent(\n        id, quad.object, 'object');\n      copy.graph = this.modifyFirstDegreeComponent(\n        id, quad.graph, 'graph');\n      nquads.push(NQuads.serializeQuad(copy));\n    }\n\n    // 4) Sort nquads in lexicographical order.\n    nquads.sort();\n\n    // 5) Return the hash that results from passing the sorted, joined nquads\n    // through the hash algorithm.\n    const md = this.createMessageDigest();\n    for(const nquad of nquads) {\n      md.update(nquad);\n    }\n    info.hash = md.digest();\n    return info.hash;\n  }\n\n  // 4.7) Hash Related Blank Node\n  hashRelatedBlankNode(related, quad, issuer, position) {\n    // 1) Set the identifier to use for related, preferring first the canonical\n    // identifier for related if issued, second the identifier issued by issuer\n    // if issued, and last, if necessary, the result of the Hash First Degree\n    // Quads algorithm, passing related.\n    let id;\n    if(this.canonicalIssuer.hasId(related)) {\n      id = this.canonicalIssuer.getId(related);\n    } else if(issuer.hasId(related)) {\n      id = issuer.getId(related);\n    } else {\n      id = this.blankNodeInfo.get(related).hash;\n    }\n\n    // 2) Initialize a string input to the value of position.\n    // Note: We use a hash object instead.\n    const md = this.createMessageDigest();\n    md.update(position);\n\n    // 3) If position is not g, append <, the value of the predicate in quad,\n    // and > to input.\n    if(position !== 'g') {\n      md.update(this.getRelatedPredicate(quad));\n    }\n\n    // 4) Append identifier to input.\n    md.update(id);\n\n    // 5) Return the hash that results from passing input through the hash\n    // algorithm.\n    return md.digest();\n  }\n\n  // 4.8) Hash N-Degree Quads\n  hashNDegreeQuads(id, issuer) {\n    const deepIterations = this.deepIterations.get(id) || 0;\n    if(deepIterations > this.maxDeepIterations) {\n      throw new Error(\n        `Maximum deep iterations (${this.maxDeepIterations}) exceeded.`);\n    }\n    this.deepIterations.set(id, deepIterations + 1);\n\n    // 1) Create a hash to related blank nodes map for storing hashes that\n    // identify related blank nodes.\n    // Note: 2) and 3) handled within `createHashToRelated`\n    const md = this.createMessageDigest();\n    const hashToRelated = this.createHashToRelated(id, issuer);\n\n    // 4) Create an empty string, data to hash.\n    // Note: We created a hash object `md` above instead.\n\n    // 5) For each related hash to blank node list mapping in hash to related\n    // blank nodes map, sorted lexicographically by related hash:\n    const hashes = [...hashToRelated.keys()].sort();\n    for(const hash of hashes) {\n      // 5.1) Append the related hash to the data to hash.\n      md.update(hash);\n\n      // 5.2) Create a string chosen path.\n      let chosenPath = '';\n\n      // 5.3) Create an unset chosen issuer variable.\n      let chosenIssuer;\n\n      // 5.4) For each permutation of blank node list:\n      const permuter = new Permuter(hashToRelated.get(hash));\n      while(permuter.hasNext()) {\n        const permutation = permuter.next();\n\n        // 5.4.1) Create a copy of issuer, issuer copy.\n        let issuerCopy = issuer.clone();\n\n        // 5.4.2) Create a string path.\n        let path = '';\n\n        // 5.4.3) Create a recursion list, to store blank node identifiers\n        // that must be recursively processed by this algorithm.\n        const recursionList = [];\n\n        // 5.4.4) For each related in permutation:\n        let nextPermutation = false;\n        for(const related of permutation) {\n          // 5.4.4.1) If a canonical identifier has been issued for\n          // related, append it to path.\n          if(this.canonicalIssuer.hasId(related)) {\n            path += this.canonicalIssuer.getId(related);\n          } else {\n            // 5.4.4.2) Otherwise:\n            // 5.4.4.2.1) If issuer copy has not issued an identifier for\n            // related, append related to recursion list.\n            if(!issuerCopy.hasId(related)) {\n              recursionList.push(related);\n            }\n            // 5.4.4.2.2) Use the Issue Identifier algorithm, passing\n            // issuer copy and related and append the result to path.\n            path += issuerCopy.getId(related);\n          }\n\n          // 5.4.4.3) If chosen path is not empty and the length of path\n          // is greater than or equal to the length of chosen path and\n          // path is lexicographically greater than chosen path, then\n          // skip to the next permutation.\n          // Note: Comparing path length to chosen path length can be optimized\n          // away; only compare lexicographically.\n          if(chosenPath.length !== 0 && path > chosenPath) {\n            nextPermutation = true;\n            break;\n          }\n        }\n\n        if(nextPermutation) {\n          continue;\n        }\n\n        // 5.4.5) For each related in recursion list:\n        for(const related of recursionList) {\n          // 5.4.5.1) Set result to the result of recursively executing\n          // the Hash N-Degree Quads algorithm, passing related for\n          // identifier and issuer copy for path identifier issuer.\n          const result = this.hashNDegreeQuads(related, issuerCopy);\n\n          // 5.4.5.2) Use the Issue Identifier algorithm, passing issuer\n          // copy and related and append the result to path.\n          path += issuerCopy.getId(related);\n\n          // 5.4.5.3) Append <, the hash in result, and > to path.\n          path += `<${result.hash}>`;\n\n          // 5.4.5.4) Set issuer copy to the identifier issuer in\n          // result.\n          issuerCopy = result.issuer;\n\n          // 5.4.5.5) If chosen path is not empty and the length of path\n          // is greater than or equal to the length of chosen path and\n          // path is lexicographically greater than chosen path, then\n          // skip to the next permutation.\n          // Note: Comparing path length to chosen path length can be optimized\n          // away; only compare lexicographically.\n          if(chosenPath.length !== 0 && path > chosenPath) {\n            nextPermutation = true;\n            break;\n          }\n        }\n\n        if(nextPermutation) {\n          continue;\n        }\n\n        // 5.4.6) If chosen path is empty or path is lexicographically\n        // less than chosen path, set chosen path to path and chosen\n        // issuer to issuer copy.\n        if(chosenPath.length === 0 || path < chosenPath) {\n          chosenPath = path;\n          chosenIssuer = issuerCopy;\n        }\n      }\n\n      // 5.5) Append chosen path to data to hash.\n      md.update(chosenPath);\n\n      // 5.6) Replace issuer, by reference, with chosen issuer.\n      issuer = chosenIssuer;\n    }\n\n    // 6) Return issuer and the hash that results from passing data to hash\n    // through the hash algorithm.\n    return {hash: md.digest(), issuer};\n  }\n\n  // helper for modifying component during Hash First Degree Quads\n  modifyFirstDegreeComponent(id, component) {\n    if(component.termType !== 'BlankNode') {\n      return component;\n    }\n    /* Note: A mistake in the URDNA2015 spec that made its way into\n    implementations (and therefore must stay to avoid interop breakage)\n    resulted in an assigned canonical ID, if available for\n    `component.value`, not being used in place of `_:a`/`_:z`, so\n    we don't use it here. */\n    return {\n      termType: 'BlankNode',\n      value: component.value === id ? '_:a' : '_:z'\n    };\n  }\n\n  // helper for getting a related predicate\n  getRelatedPredicate(quad) {\n    return `<${quad.predicate.value}>`;\n  }\n\n  // helper for creating hash to related blank nodes map\n  createHashToRelated(id, issuer) {\n    // 1) Create a hash to related blank nodes map for storing hashes that\n    // identify related blank nodes.\n    const hashToRelated = new Map();\n\n    // 2) Get a reference, quads, to the list of quads in the blank node to\n    // quads map for the key identifier.\n    const quads = this.blankNodeInfo.get(id).quads;\n\n    // 3) For each quad in quads:\n    for(const quad of quads) {\n      // 3.1) For each component in quad, if component is the subject, object,\n      // or graph name and it is a blank node that is not identified by\n      // identifier:\n      // steps 3.1.1 and 3.1.2 occur in helpers:\n      this._addRelatedBlankNodeHash({\n        quad, component: quad.subject, position: 's',\n        id, issuer, hashToRelated\n      });\n      this._addRelatedBlankNodeHash({\n        quad, component: quad.object, position: 'o',\n        id, issuer, hashToRelated\n      });\n      this._addRelatedBlankNodeHash({\n        quad, component: quad.graph, position: 'g',\n        id, issuer, hashToRelated\n      });\n    }\n\n    return hashToRelated;\n  }\n\n  _hashAndTrackBlankNode({id, hashToBlankNodes}) {\n    // 5.3.1) Create a hash, hash, according to the Hash First Degree\n    // Quads algorithm.\n    const hash = this.hashFirstDegreeQuads(id);\n\n    // 5.3.2) Add hash and identifier to hash to blank nodes map,\n    // creating a new entry if necessary.\n    const idList = hashToBlankNodes.get(hash);\n    if(!idList) {\n      hashToBlankNodes.set(hash, [id]);\n    } else {\n      idList.push(id);\n    }\n  }\n\n  _addBlankNodeQuadInfo({quad, component}) {\n    if(component.termType !== 'BlankNode') {\n      return;\n    }\n    const id = component.value;\n    const info = this.blankNodeInfo.get(id);\n    if(info) {\n      info.quads.add(quad);\n    } else {\n      this.blankNodeInfo.set(id, {quads: new Set([quad]), hash: null});\n    }\n  }\n\n  _addRelatedBlankNodeHash(\n    {quad, component, position, id, issuer, hashToRelated}) {\n    if(!(component.termType === 'BlankNode' && component.value !== id)) {\n      return;\n    }\n    // 3.1.1) Set hash to the result of the Hash Related Blank Node\n    // algorithm, passing the blank node identifier for component as\n    // related, quad, path identifier issuer as issuer, and position as\n    // either s, o, or g based on whether component is a subject, object,\n    // graph name, respectively.\n    const related = component.value;\n    const hash = this.hashRelatedBlankNode(related, quad, issuer, position);\n\n    // 3.1.2) Add a mapping of hash to the blank node identifier for\n    // component to hash to related blank nodes map, adding an entry as\n    // necessary.\n    const entries = hashToRelated.get(hash);\n    if(entries) {\n      entries.push(related);\n    } else {\n      hashToRelated.set(hash, [related]);\n    }\n  }\n\n  // canonical ids for 7.1\n  _componentWithCanonicalId({component}) {\n    if(component.termType === 'BlankNode' &&\n      !component.value.startsWith(this.canonicalIssuer.prefix)) {\n      // create new BlankNode\n      return {\n        termType: 'BlankNode',\n        value: this.canonicalIssuer.getId(component.value)\n      };\n    }\n    return component;\n  }\n};\n\nfunction _stringHashCompare(a, b) {\n  return a.hash < b.hash ? -1 : a.hash > b.hash ? 1 : 0;\n}\n","/*!\n * Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst MessageDigest = require('./MessageDigest');\nconst URDNA2015 = require('./URDNA2015');\n\nmodule.exports = class URDNA2012 extends URDNA2015 {\n  constructor() {\n    super();\n    this.name = 'URGNA2012';\n    this.createMessageDigest = () => new MessageDigest('sha1');\n  }\n\n  // helper for modifying component during Hash First Degree Quads\n  modifyFirstDegreeComponent(id, component, key) {\n    if(component.termType !== 'BlankNode') {\n      return component;\n    }\n    if(key === 'graph') {\n      return {\n        termType: 'BlankNode',\n        value: '_:g'\n      };\n    }\n    return {\n      termType: 'BlankNode',\n      value: (component.value === id ? '_:a' : '_:z')\n    };\n  }\n\n  // helper for getting a related predicate\n  getRelatedPredicate(quad) {\n    return quad.predicate.value;\n  }\n\n  // helper for creating hash to related blank nodes map\n  async createHashToRelated(id, issuer) {\n    // 1) Create a hash to related blank nodes map for storing hashes that\n    // identify related blank nodes.\n    const hashToRelated = new Map();\n\n    // 2) Get a reference, quads, to the list of quads in the blank node to\n    // quads map for the key identifier.\n    const quads = this.blankNodeInfo.get(id).quads;\n\n    // 3) For each quad in quads:\n    let i = 0;\n    for(const quad of quads) {\n      // 3.1) If the quad's subject is a blank node that does not match\n      // identifier, set hash to the result of the Hash Related Blank Node\n      // algorithm, passing the blank node identifier for subject as related,\n      // quad, path identifier issuer as issuer, and p as position.\n      let position;\n      let related;\n      if(quad.subject.termType === 'BlankNode' && quad.subject.value !== id) {\n        related = quad.subject.value;\n        position = 'p';\n      } else if(\n        quad.object.termType === 'BlankNode' && quad.object.value !== id) {\n        // 3.2) Otherwise, if quad's object is a blank node that does not match\n        // identifier, to the result of the Hash Related Blank Node algorithm,\n        // passing the blank node identifier for object as related, quad, path\n        // identifier issuer as issuer, and r as position.\n        related = quad.object.value;\n        position = 'r';\n      } else {\n        // 3.3) Otherwise, continue to the next quad.\n        continue;\n      }\n      // Note: batch hashing related blank nodes 100 at a time\n      if(++i % 100 === 0) {\n        await this._yield();\n      }\n      // 3.4) Add a mapping of hash to the blank node identifier for the\n      // component that matched (subject or object) to hash to related blank\n      // nodes map, adding an entry as necessary.\n      const hash = await this.hashRelatedBlankNode(\n        related, quad, issuer, position);\n      const entries = hashToRelated.get(hash);\n      if(entries) {\n        entries.push(related);\n      } else {\n        hashToRelated.set(hash, [related]);\n      }\n    }\n\n    return hashToRelated;\n  }\n};\n","/*!\n * Copyright (c) 2016-2021 Digital Bazaar, Inc. All rights reserved.\n */\n'use strict';\n\nconst MessageDigest = require('./MessageDigest');\nconst URDNA2015Sync = require('./URDNA2015Sync');\n\nmodule.exports = class URDNA2012Sync extends URDNA2015Sync {\n  constructor() {\n    super();\n    this.name = 'URGNA2012';\n    this.createMessageDigest = () => new MessageDigest('sha1');\n  }\n\n  // helper for modifying component during Hash First Degree Quads\n  modifyFirstDegreeComponent(id, component, key) {\n    if(component.termType !== 'BlankNode') {\n      return component;\n    }\n    if(key === 'graph') {\n      return {\n        termType: 'BlankNode',\n        value: '_:g'\n      };\n    }\n    return {\n      termType: 'BlankNode',\n      value: (component.value === id ? '_:a' : '_:z')\n    };\n  }\n\n  // helper for getting a related predicate\n  getRelatedPredicate(quad) {\n    return quad.predicate.value;\n  }\n\n  // helper for creating hash to related blank nodes map\n  createHashToRelated(id, issuer) {\n    // 1) Create a hash to related blank nodes map for storing hashes that\n    // identify related blank nodes.\n    const hashToRelated = new Map();\n\n    // 2) Get a reference, quads, to the list of quads in the blank node to\n    // quads map for the key identifier.\n    const quads = this.blankNodeInfo.get(id).quads;\n\n    // 3) For each quad in quads:\n    for(const quad of quads) {\n      // 3.1) If the quad's subject is a blank node that does not match\n      // identifier, set hash to the result of the Hash Related Blank Node\n      // algorithm, passing the blank node identifier for subject as related,\n      // quad, path identifier issuer as issuer, and p as position.\n      let position;\n      let related;\n      if(quad.subject.termType === 'BlankNode' && quad.subject.value !== id) {\n        related = quad.subject.value;\n        position = 'p';\n      } else if(\n        quad.object.termType === 'BlankNode' && quad.object.value !== id) {\n        // 3.2) Otherwise, if quad's object is a blank node that does not match\n        // identifier, to the result of the Hash Related Blank Node algorithm,\n        // passing the blank node identifier for object as related, quad, path\n        // identifier issuer as issuer, and r as position.\n        related = quad.object.value;\n        position = 'r';\n      } else {\n        // 3.3) Otherwise, continue to the next quad.\n        continue;\n      }\n      // 3.4) Add a mapping of hash to the blank node identifier for the\n      // component that matched (subject or object) to hash to related blank\n      // nodes map, adding an entry as necessary.\n      const hash = this.hashRelatedBlankNode(related, quad, issuer, position);\n      const entries = hashToRelated.get(hash);\n      if(entries) {\n        entries.push(related);\n      } else {\n        hashToRelated.set(hash, [related]);\n      }\n    }\n\n    return hashToRelated;\n  }\n};\n","/**\n * An implementation of the RDF Dataset Normalization specification.\n * This library works in the browser and node.js.\n *\n * BSD 3-Clause License\n * Copyright (c) 2016-2023 Digital Bazaar, Inc.\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * Redistributions of source code must retain the above copyright notice,\n * this list of conditions and the following disclaimer.\n *\n * Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and/or other materials provided with the distribution.\n *\n * Neither the name of the Digital Bazaar, Inc. nor the names of its\n * contributors may be used to endorse or promote products derived from\n * this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS\n * IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED\n * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A\n * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\n * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n'use strict';\n\nconst URDNA2015 = require('./URDNA2015');\nconst URGNA2012 = require('./URGNA2012');\nconst URDNA2015Sync = require('./URDNA2015Sync');\nconst URGNA2012Sync = require('./URGNA2012Sync');\n\n// optional native support\nlet rdfCanonizeNative;\ntry {\n  rdfCanonizeNative = require('rdf-canonize-native');\n} catch(e) {}\n\n// return a dataset from input dataset or legacy dataset\nfunction _inputToDataset(input/*, options*/) {\n  // back-compat with legacy dataset\n  if(!Array.isArray(input)) {\n    return exports.NQuads.legacyDatasetToQuads(input);\n  }\n  return input;\n}\n\n// expose helpers\nexports.NQuads = require('./NQuads');\nexports.IdentifierIssuer = require('./IdentifierIssuer');\n\n/**\n * Get or set native API.\n *\n * @param api the native API.\n *\n * @return the currently set native API.\n */\nexports._rdfCanonizeNative = function(api) {\n  if(api) {\n    rdfCanonizeNative = api;\n  }\n  return rdfCanonizeNative;\n};\n\n/**\n * Asynchronously canonizes an RDF dataset.\n *\n * @param {Array|object|string} input - The input to canonize given as a\n *   dataset or legacy dataset.\n * @param {object} options - The options to use:\n *   {string} algorithm - The canonicalization algorithm to use, `URDNA2015` or\n *     `URGNA2012`.\n *   {Function} [createMessageDigest] - A factory function for creating a\n *     `MessageDigest` interface that overrides the built-in message digest\n *     implementation used by the canonize algorithm; note that using a hash\n *     algorithm (or HMAC algorithm) that differs from the one specified by\n *     the canonize algorithm will result in different output.\n *   {Map} [canonicalIdMap] - An optional Map to be populated by the canonical\n *     identifier issuer with the bnode identifier mapping generated by the\n *     canonicalization algorithm.\n *   {boolean} [useNative=false] - Use native implementation.\n *   {number} [maxDeepIterations=Infinity] - The maximum number of times to run\n *     deep comparison algorithms (such as the N-Degree Hash Quads algorithm\n *     used in URDNA2015) before bailing out and throwing an error; this is a\n *     useful setting for preventing wasted CPU cycles or DoS when canonizing\n *     meaningless or potentially malicious datasets, a recommended value is\n *     `1`.\n *\n * @return a Promise that resolves to the canonicalized RDF Dataset.\n */\nexports.canonize = async function(input, options) {\n  const dataset = _inputToDataset(input, options);\n\n  if(options.useNative) {\n    if(!rdfCanonizeNative) {\n      throw new Error('rdf-canonize-native not available');\n    }\n    if(options.createMessageDigest) {\n      throw new Error(\n        '\"createMessageDigest\" cannot be used with \"useNative\".');\n    }\n    return new Promise((resolve, reject) =>\n      rdfCanonizeNative.canonize(dataset, options, (err, canonical) =>\n        err ? reject(err) : resolve(canonical)));\n  }\n\n  if(options.algorithm === 'URDNA2015') {\n    return new URDNA2015(options).main(dataset);\n  }\n  if(options.algorithm === 'URGNA2012') {\n    if(options.createMessageDigest) {\n      throw new Error(\n        '\"createMessageDigest\" cannot be used with \"URGNA2012\".');\n    }\n    return new URGNA2012(options).main(dataset);\n  }\n  if(!('algorithm' in options)) {\n    throw new Error('No RDF Dataset Canonicalization algorithm specified.');\n  }\n  throw new Error(\n    'Invalid RDF Dataset Canonicalization algorithm: ' + options.algorithm);\n};\n\n/**\n * This method is no longer available in the public API, it is for testing\n * only. It synchronously canonizes an RDF dataset and does not work in the\n * browser.\n *\n * @param {Array|object|string} input - The input to canonize given as a\n *   dataset or legacy dataset.\n * @param {object} options - The options to use:\n *   {string} algorithm - The canonicalization algorithm to use, `URDNA2015` or\n *     `URGNA2012`.\n *   {Function} [createMessageDigest] - A factory function for creating a\n *     `MessageDigest` interface that overrides the built-in message digest\n *     implementation used by the canonize algorithm; note that using a hash\n *     algorithm (or HMAC algorithm) that differs from the one specified by\n *     the canonize algorithm will result in different output.\n *   {boolean} [useNative=false] - Use native implementation.\n *   {number} [maxDeepIterations=Infinity] - The maximum number of times to run\n *     deep comparison algorithms (such as the N-Degree Hash Quads algorithm\n *     used in URDNA2015) before bailing out and throwing an error; this is a\n *     useful setting for preventing wasted CPU cycles or DoS when canonizing\n *     meaningless or potentially malicious datasets, a recommended value is\n *     `1`.\n *\n * @return the RDF dataset in canonical form.\n */\nexports._canonizeSync = function(input, options) {\n  const dataset = _inputToDataset(input, options);\n\n  if(options.useNative) {\n    if(!rdfCanonizeNative) {\n      throw new Error('rdf-canonize-native not available');\n    }\n    if(options.createMessageDigest) {\n      throw new Error(\n        '\"createMessageDigest\" cannot be used with \"useNative\".');\n    }\n    return rdfCanonizeNative.canonizeSync(dataset, options);\n  }\n  if(options.algorithm === 'URDNA2015') {\n    return new URDNA2015Sync(options).main(dataset);\n  }\n  if(options.algorithm === 'URGNA2012') {\n    if(options.createMessageDigest) {\n      throw new Error(\n        '\"createMessageDigest\" cannot be used with \"URGNA2012\".');\n    }\n    return new URGNA2012Sync(options).main(dataset);\n  }\n  if(!('algorithm' in options)) {\n    throw new Error('No RDF Dataset Canonicalization algorithm specified.');\n  }\n  throw new Error(\n    'Invalid RDF Dataset Canonicalization algorithm: ' + options.algorithm);\n};\n","'use strict';\n\nclass NonError extends Error {\n\tconstructor(message) {\n\t\tsuper(NonError._prepareSuperMessage(message));\n\t\tObject.defineProperty(this, 'name', {\n\t\t\tvalue: 'NonError',\n\t\t\tconfigurable: true,\n\t\t\twritable: true\n\t\t});\n\n\t\tif (Error.captureStackTrace) {\n\t\t\tError.captureStackTrace(this, NonError);\n\t\t}\n\t}\n\n\tstatic _prepareSuperMessage(message) {\n\t\ttry {\n\t\t\treturn JSON.stringify(message);\n\t\t} catch {\n\t\t\treturn String(message);\n\t\t}\n\t}\n}\n\nconst commonProperties = [\n\t{property: 'name', enumerable: false},\n\t{property: 'message', enumerable: false},\n\t{property: 'stack', enumerable: false},\n\t{property: 'code', enumerable: true}\n];\n\nconst isCalled = Symbol('.toJSON called');\n\nconst toJSON = from => {\n\tfrom[isCalled] = true;\n\tconst json = from.toJSON();\n\tdelete from[isCalled];\n\treturn json;\n};\n\nconst destroyCircular = ({\n\tfrom,\n\tseen,\n\tto_,\n\tforceEnumerable,\n\tmaxDepth,\n\tdepth\n}) => {\n\tconst to = to_ || (Array.isArray(from) ? [] : {});\n\n\tseen.push(from);\n\n\tif (depth >= maxDepth) {\n\t\treturn to;\n\t}\n\n\tif (typeof from.toJSON === 'function' && from[isCalled] !== true) {\n\t\treturn toJSON(from);\n\t}\n\n\tfor (const [key, value] of Object.entries(from)) {\n\t\tif (typeof Buffer === 'function' && Buffer.isBuffer(value)) {\n\t\t\tto[key] = '[object Buffer]';\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (typeof value === 'function') {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!value || typeof value !== 'object') {\n\t\t\tto[key] = value;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!seen.includes(from[key])) {\n\t\t\tdepth++;\n\n\t\t\tto[key] = destroyCircular({\n\t\t\t\tfrom: from[key],\n\t\t\t\tseen: seen.slice(),\n\t\t\t\tforceEnumerable,\n\t\t\t\tmaxDepth,\n\t\t\t\tdepth\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\n\t\tto[key] = '[Circular]';\n\t}\n\n\tfor (const {property, enumerable} of commonProperties) {\n\t\tif (typeof from[property] === 'string') {\n\t\t\tObject.defineProperty(to, property, {\n\t\t\t\tvalue: from[property],\n\t\t\t\tenumerable: forceEnumerable ? true : enumerable,\n\t\t\t\tconfigurable: true,\n\t\t\t\twritable: true\n\t\t\t});\n\t\t}\n\t}\n\n\treturn to;\n};\n\nconst serializeError = (value, options = {}) => {\n\tconst {maxDepth = Number.POSITIVE_INFINITY} = options;\n\n\tif (typeof value === 'object' && value !== null) {\n\t\treturn destroyCircular({\n\t\t\tfrom: value,\n\t\t\tseen: [],\n\t\t\tforceEnumerable: true,\n\t\t\tmaxDepth,\n\t\t\tdepth: 0\n\t\t});\n\t}\n\n\t// People sometimes throw things besides Error objects…\n\tif (typeof value === 'function') {\n\t\t// `JSON.stringify()` discards functions. We do too, unless a function is thrown directly.\n\t\treturn `[Function: ${(value.name || 'anonymous')}]`;\n\t}\n\n\treturn value;\n};\n\nconst deserializeError = (value, options = {}) => {\n\tconst {maxDepth = Number.POSITIVE_INFINITY} = options;\n\n\tif (value instanceof Error) {\n\t\treturn value;\n\t}\n\n\tif (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n\t\tconst newError = new Error(); // eslint-disable-line unicorn/error-message\n\t\tdestroyCircular({\n\t\t\tfrom: value,\n\t\t\tseen: [],\n\t\t\tto_: newError,\n\t\t\tmaxDepth,\n\t\t\tdepth: 0\n\t\t});\n\t\treturn newError;\n\t}\n\n\treturn new NonError(value);\n};\n\nmodule.exports = {\n\tserializeError,\n\tdeserializeError\n};\n","(function (global, undefined) {\n    \"use strict\";\n\n    if (global.setImmediate) {\n        return;\n    }\n\n    var nextHandle = 1; // Spec says greater than zero\n    var tasksByHandle = {};\n    var currentlyRunningATask = false;\n    var doc = global.document;\n    var registerImmediate;\n\n    function setImmediate(callback) {\n      // Callback can either be a function or a string\n      if (typeof callback !== \"function\") {\n        callback = new Function(\"\" + callback);\n      }\n      // Copy function arguments\n      var args = new Array(arguments.length - 1);\n      for (var i = 0; i < args.length; i++) {\n          args[i] = arguments[i + 1];\n      }\n      // Store and register the task\n      var task = { callback: callback, args: args };\n      tasksByHandle[nextHandle] = task;\n      registerImmediate(nextHandle);\n      return nextHandle++;\n    }\n\n    function clearImmediate(handle) {\n        delete tasksByHandle[handle];\n    }\n\n    function run(task) {\n        var callback = task.callback;\n        var args = task.args;\n        switch (args.length) {\n        case 0:\n            callback();\n            break;\n        case 1:\n            callback(args[0]);\n            break;\n        case 2:\n            callback(args[0], args[1]);\n            break;\n        case 3:\n            callback(args[0], args[1], args[2]);\n            break;\n        default:\n            callback.apply(undefined, args);\n            break;\n        }\n    }\n\n    function runIfPresent(handle) {\n        // From the spec: \"Wait until any invocations of this algorithm started before this one have completed.\"\n        // So if we're currently running a task, we'll need to delay this invocation.\n        if (currentlyRunningATask) {\n            // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a\n            // \"too much recursion\" error.\n            setTimeout(runIfPresent, 0, handle);\n        } else {\n            var task = tasksByHandle[handle];\n            if (task) {\n                currentlyRunningATask = true;\n                try {\n                    run(task);\n                } finally {\n                    clearImmediate(handle);\n                    currentlyRunningATask = false;\n                }\n            }\n        }\n    }\n\n    function installNextTickImplementation() {\n        registerImmediate = function(handle) {\n            process.nextTick(function () { runIfPresent(handle); });\n        };\n    }\n\n    function canUsePostMessage() {\n        // The test against `importScripts` prevents this implementation from being installed inside a web worker,\n        // where `global.postMessage` means something completely different and can't be used for this purpose.\n        if (global.postMessage && !global.importScripts) {\n            var postMessageIsAsynchronous = true;\n            var oldOnMessage = global.onmessage;\n            global.onmessage = function() {\n                postMessageIsAsynchronous = false;\n            };\n            global.postMessage(\"\", \"*\");\n            global.onmessage = oldOnMessage;\n            return postMessageIsAsynchronous;\n        }\n    }\n\n    function installPostMessageImplementation() {\n        // Installs an event handler on `global` for the `message` event: see\n        // * https://developer.mozilla.org/en/DOM/window.postMessage\n        // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages\n\n        var messagePrefix = \"setImmediate$\" + Math.random() + \"$\";\n        var onGlobalMessage = function(event) {\n            if (event.source === global &&\n                typeof event.data === \"string\" &&\n                event.data.indexOf(messagePrefix) === 0) {\n                runIfPresent(+event.data.slice(messagePrefix.length));\n            }\n        };\n\n        if (global.addEventListener) {\n            global.addEventListener(\"message\", onGlobalMessage, false);\n        } else {\n            global.attachEvent(\"onmessage\", onGlobalMessage);\n        }\n\n        registerImmediate = function(handle) {\n            global.postMessage(messagePrefix + handle, \"*\");\n        };\n    }\n\n    function installMessageChannelImplementation() {\n        var channel = new MessageChannel();\n        channel.port1.onmessage = function(event) {\n            var handle = event.data;\n            runIfPresent(handle);\n        };\n\n        registerImmediate = function(handle) {\n            channel.port2.postMessage(handle);\n        };\n    }\n\n    function installReadyStateChangeImplementation() {\n        var html = doc.documentElement;\n        registerImmediate = function(handle) {\n            // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted\n            // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.\n            var script = doc.createElement(\"script\");\n            script.onreadystatechange = function () {\n                runIfPresent(handle);\n                script.onreadystatechange = null;\n                html.removeChild(script);\n                script = null;\n            };\n            html.appendChild(script);\n        };\n    }\n\n    function installSetTimeoutImplementation() {\n        registerImmediate = function(handle) {\n            setTimeout(runIfPresent, 0, handle);\n        };\n    }\n\n    // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.\n    var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);\n    attachTo = attachTo && attachTo.setTimeout ? attachTo : global;\n\n    // Don't get fooled by e.g. browserify environments.\n    if ({}.toString.call(global.process) === \"[object process]\") {\n        // For Node.js before 0.9\n        installNextTickImplementation();\n\n    } else if (canUsePostMessage()) {\n        // For non-IE10 modern browsers\n        installPostMessageImplementation();\n\n    } else if (global.MessageChannel) {\n        // For web workers, where supported\n        installMessageChannelImplementation();\n\n    } else if (doc && \"onreadystatechange\" in doc.createElement(\"script\")) {\n        // For IE 6–8\n        installReadyStateChangeImplementation();\n\n    } else {\n        // For older browsers\n        installSetTimeoutImplementation();\n    }\n\n    attachTo.setImmediate = setImmediate;\n    attachTo.clearImmediate = clearImmediate;\n}(typeof self === \"undefined\" ? typeof global === \"undefined\" ? this : global : self));\n","'use strict'\nmodule.exports = function (Yallist) {\n  Yallist.prototype[Symbol.iterator] = function* () {\n    for (let walker = this.head; walker; walker = walker.next) {\n      yield walker.value\n    }\n  }\n}\n","'use strict'\nmodule.exports = Yallist\n\nYallist.Node = Node\nYallist.create = Yallist\n\nfunction Yallist (list) {\n  var self = this\n  if (!(self instanceof Yallist)) {\n    self = new Yallist()\n  }\n\n  self.tail = null\n  self.head = null\n  self.length = 0\n\n  if (list && typeof list.forEach === 'function') {\n    list.forEach(function (item) {\n      self.push(item)\n    })\n  } else if (arguments.length > 0) {\n    for (var i = 0, l = arguments.length; i < l; i++) {\n      self.push(arguments[i])\n    }\n  }\n\n  return self\n}\n\nYallist.prototype.removeNode = function (node) {\n  if (node.list !== this) {\n    throw new Error('removing node which does not belong to this list')\n  }\n\n  var next = node.next\n  var prev = node.prev\n\n  if (next) {\n    next.prev = prev\n  }\n\n  if (prev) {\n    prev.next = next\n  }\n\n  if (node === this.head) {\n    this.head = next\n  }\n  if (node === this.tail) {\n    this.tail = prev\n  }\n\n  node.list.length--\n  node.next = null\n  node.prev = null\n  node.list = null\n\n  return next\n}\n\nYallist.prototype.unshiftNode = function (node) {\n  if (node === this.head) {\n    return\n  }\n\n  if (node.list) {\n    node.list.removeNode(node)\n  }\n\n  var head = this.head\n  node.list = this\n  node.next = head\n  if (head) {\n    head.prev = node\n  }\n\n  this.head = node\n  if (!this.tail) {\n    this.tail = node\n  }\n  this.length++\n}\n\nYallist.prototype.pushNode = function (node) {\n  if (node === this.tail) {\n    return\n  }\n\n  if (node.list) {\n    node.list.removeNode(node)\n  }\n\n  var tail = this.tail\n  node.list = this\n  node.prev = tail\n  if (tail) {\n    tail.next = node\n  }\n\n  this.tail = node\n  if (!this.head) {\n    this.head = node\n  }\n  this.length++\n}\n\nYallist.prototype.push = function () {\n  for (var i = 0, l = arguments.length; i < l; i++) {\n    push(this, arguments[i])\n  }\n  return this.length\n}\n\nYallist.prototype.unshift = function () {\n  for (var i = 0, l = arguments.length; i < l; i++) {\n    unshift(this, arguments[i])\n  }\n  return this.length\n}\n\nYallist.prototype.pop = function () {\n  if (!this.tail) {\n    return undefined\n  }\n\n  var res = this.tail.value\n  this.tail = this.tail.prev\n  if (this.tail) {\n    this.tail.next = null\n  } else {\n    this.head = null\n  }\n  this.length--\n  return res\n}\n\nYallist.prototype.shift = function () {\n  if (!this.head) {\n    return undefined\n  }\n\n  var res = this.head.value\n  this.head = this.head.next\n  if (this.head) {\n    this.head.prev = null\n  } else {\n    this.tail = null\n  }\n  this.length--\n  return res\n}\n\nYallist.prototype.forEach = function (fn, thisp) {\n  thisp = thisp || this\n  for (var walker = this.head, i = 0; walker !== null; i++) {\n    fn.call(thisp, walker.value, i, this)\n    walker = walker.next\n  }\n}\n\nYallist.prototype.forEachReverse = function (fn, thisp) {\n  thisp = thisp || this\n  for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {\n    fn.call(thisp, walker.value, i, this)\n    walker = walker.prev\n  }\n}\n\nYallist.prototype.get = function (n) {\n  for (var i = 0, walker = this.head; walker !== null && i < n; i++) {\n    // abort out of the list early if we hit a cycle\n    walker = walker.next\n  }\n  if (i === n && walker !== null) {\n    return walker.value\n  }\n}\n\nYallist.prototype.getReverse = function (n) {\n  for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {\n    // abort out of the list early if we hit a cycle\n    walker = walker.prev\n  }\n  if (i === n && walker !== null) {\n    return walker.value\n  }\n}\n\nYallist.prototype.map = function (fn, thisp) {\n  thisp = thisp || this\n  var res = new Yallist()\n  for (var walker = this.head; walker !== null;) {\n    res.push(fn.call(thisp, walker.value, this))\n    walker = walker.next\n  }\n  return res\n}\n\nYallist.prototype.mapReverse = function (fn, thisp) {\n  thisp = thisp || this\n  var res = new Yallist()\n  for (var walker = this.tail; walker !== null;) {\n    res.push(fn.call(thisp, walker.value, this))\n    walker = walker.prev\n  }\n  return res\n}\n\nYallist.prototype.reduce = function (fn, initial) {\n  var acc\n  var walker = this.head\n  if (arguments.length > 1) {\n    acc = initial\n  } else if (this.head) {\n    walker = this.head.next\n    acc = this.head.value\n  } else {\n    throw new TypeError('Reduce of empty list with no initial value')\n  }\n\n  for (var i = 0; walker !== null; i++) {\n    acc = fn(acc, walker.value, i)\n    walker = walker.next\n  }\n\n  return acc\n}\n\nYallist.prototype.reduceReverse = function (fn, initial) {\n  var acc\n  var walker = this.tail\n  if (arguments.length > 1) {\n    acc = initial\n  } else if (this.tail) {\n    walker = this.tail.prev\n    acc = this.tail.value\n  } else {\n    throw new TypeError('Reduce of empty list with no initial value')\n  }\n\n  for (var i = this.length - 1; walker !== null; i--) {\n    acc = fn(acc, walker.value, i)\n    walker = walker.prev\n  }\n\n  return acc\n}\n\nYallist.prototype.toArray = function () {\n  var arr = new Array(this.length)\n  for (var i = 0, walker = this.head; walker !== null; i++) {\n    arr[i] = walker.value\n    walker = walker.next\n  }\n  return arr\n}\n\nYallist.prototype.toArrayReverse = function () {\n  var arr = new Array(this.length)\n  for (var i = 0, walker = this.tail; walker !== null; i++) {\n    arr[i] = walker.value\n    walker = walker.prev\n  }\n  return arr\n}\n\nYallist.prototype.slice = function (from, to) {\n  to = to || this.length\n  if (to < 0) {\n    to += this.length\n  }\n  from = from || 0\n  if (from < 0) {\n    from += this.length\n  }\n  var ret = new Yallist()\n  if (to < from || to < 0) {\n    return ret\n  }\n  if (from < 0) {\n    from = 0\n  }\n  if (to > this.length) {\n    to = this.length\n  }\n  for (var i = 0, walker = this.head; walker !== null && i < from; i++) {\n    walker = walker.next\n  }\n  for (; walker !== null && i < to; i++, walker = walker.next) {\n    ret.push(walker.value)\n  }\n  return ret\n}\n\nYallist.prototype.sliceReverse = function (from, to) {\n  to = to || this.length\n  if (to < 0) {\n    to += this.length\n  }\n  from = from || 0\n  if (from < 0) {\n    from += this.length\n  }\n  var ret = new Yallist()\n  if (to < from || to < 0) {\n    return ret\n  }\n  if (from < 0) {\n    from = 0\n  }\n  if (to > this.length) {\n    to = this.length\n  }\n  for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {\n    walker = walker.prev\n  }\n  for (; walker !== null && i > from; i--, walker = walker.prev) {\n    ret.push(walker.value)\n  }\n  return ret\n}\n\nYallist.prototype.splice = function (start, deleteCount, ...nodes) {\n  if (start > this.length) {\n    start = this.length - 1\n  }\n  if (start < 0) {\n    start = this.length + start;\n  }\n\n  for (var i = 0, walker = this.head; walker !== null && i < start; i++) {\n    walker = walker.next\n  }\n\n  var ret = []\n  for (var i = 0; walker && i < deleteCount; i++) {\n    ret.push(walker.value)\n    walker = this.removeNode(walker)\n  }\n  if (walker === null) {\n    walker = this.tail\n  }\n\n  if (walker !== this.head && walker !== this.tail) {\n    walker = walker.prev\n  }\n\n  for (var i = 0; i < nodes.length; i++) {\n    walker = insert(this, walker, nodes[i])\n  }\n  return ret;\n}\n\nYallist.prototype.reverse = function () {\n  var head = this.head\n  var tail = this.tail\n  for (var walker = head; walker !== null; walker = walker.prev) {\n    var p = walker.prev\n    walker.prev = walker.next\n    walker.next = p\n  }\n  this.head = tail\n  this.tail = head\n  return this\n}\n\nfunction insert (self, node, value) {\n  var inserted = node === self.head ?\n    new Node(value, null, node, self) :\n    new Node(value, node, node.next, self)\n\n  if (inserted.next === null) {\n    self.tail = inserted\n  }\n  if (inserted.prev === null) {\n    self.head = inserted\n  }\n\n  self.length++\n\n  return inserted\n}\n\nfunction push (self, item) {\n  self.tail = new Node(item, self.tail, null, self)\n  if (!self.head) {\n    self.head = self.tail\n  }\n  self.length++\n}\n\nfunction unshift (self, item) {\n  self.head = new Node(item, null, self.head, self)\n  if (!self.tail) {\n    self.tail = self.head\n  }\n  self.length++\n}\n\nfunction Node (value, prev, next, list) {\n  if (!(this instanceof Node)) {\n    return new Node(value, prev, next, list)\n  }\n\n  this.list = list\n  this.value = value\n\n  if (prev) {\n    prev.next = this\n    this.prev = prev\n  } else {\n    this.prev = null\n  }\n\n  if (next) {\n    next.prev = this\n    this.next = next\n  } else {\n    this.next = null\n  }\n}\n\ntry {\n  // add if support for Symbol.iterator is present\n  require('./iterator.js')(Yallist)\n} catch (er) {}\n","/* (ignored) */","/* (ignored) */","/*!\n * Copyright (c) 2023-2024 Digital Bazaar, Inc. All rights reserved.\n */\n// Use JSON style for context\n/* eslint quotes: ['error', 'double'] */\n/* eslint quote-props: ['error', 'always'] */\n/* eslint-disable max-len */\n\nexport default\n{\n  \"@context\": {\n    \"@protected\": true,\n    \"@vocab\": \"https://www.w3.org/ns/credentials/issuer-dependent#\",\n\n    \"id\": \"@id\",\n    \"type\": \"@type\",\n\n    \"kid\": {\n      \"@id\": \"https://www.iana.org/assignments/jose#kid\",\n      \"@type\": \"@id\"\n    },\n    \"iss\": {\n      \"@id\": \"https://www.iana.org/assignments/jose#iss\",\n      \"@type\": \"@id\"\n    },\n    \"sub\": {\n      \"@id\": \"https://www.iana.org/assignments/jose#sub\",\n      \"@type\": \"@id\"\n    },\n    \"jku\": {\n      \"@id\": \"https://www.iana.org/assignments/jose#jku\",\n      \"@type\": \"@id\"\n    },\n    \"x5u\": {\n      \"@id\": \"https://www.iana.org/assignments/jose#x5u\",\n      \"@type\": \"@id\"\n    },\n    \"aud\": {\n      \"@id\": \"https://www.iana.org/assignments/jwt#aud\",\n      \"@type\": \"@id\"\n    },\n    \"exp\": {\n      \"@id\": \"https://www.iana.org/assignments/jwt#exp\",\n      \"@type\": \"https://www.w3.org/2001/XMLSchema#nonNegativeInteger\"\n    },\n    \"nbf\": {\n      \"@id\": \"https://www.iana.org/assignments/jwt#nbf\",\n      \"@type\": \"https://www.w3.org/2001/XMLSchema#nonNegativeInteger\"\n    },\n    \"iat\": {\n      \"@id\": \"https://www.iana.org/assignments/jwt#iat\",\n      \"@type\": \"https://www.w3.org/2001/XMLSchema#nonNegativeInteger\"\n    },\n    \"cnf\": {\n      \"@id\": \"https://www.iana.org/assignments/jwt#cnf\",\n      \"@context\": {\n        \"@protected\": true,\n        \"kid\": {\n          \"@id\": \"https://www.iana.org/assignments/jwt#kid\",\n          \"@type\": \"@id\"\n        },\n        \"jwk\": {\n          \"@id\": \"https://www.iana.org/assignments/jwt#jwk\",\n          \"@type\": \"@json\"\n        }\n      }\n    },\n    \"_sd_alg\": {\n      \"@id\": \"https://www.iana.org/assignments/jwt#_sd_alg\"\n    },\n    \"_sd\": {\n      \"@id\": \"https://www.iana.org/assignments/jwt#_sd\"\n    },\n    \"...\": {\n      \"@id\": \"https://www.iana.org/assignments/jwt#...\"\n    },\n\n    \"digestSRI\": {\n      \"@id\": \"https://www.w3.org/2018/credentials#digestSRI\",\n      \"@type\": \"https://www.w3.org/2018/credentials#sriString\"\n    },\n    \"digestMultibase\": {\n      \"@id\": \"https://w3id.org/security#digestMultibase\",\n      \"@type\": \"https://w3id.org/security#multibase\"\n    },\n\n    \"encodingFormat\": {\n      \"@id\": \"https://schema.org/encodingFormat\"\n    },\n\n    \"description\": \"https://schema.org/description\",\n    \"name\": \"https://schema.org/name\",\n\n    \"EnvelopedVerifiableCredential\":\n      \"https://www.w3.org/2018/credentials#EnvelopedVerifiableCredential\",\n\n    \"VerifiableCredential\": {\n      \"@id\": \"https://www.w3.org/2018/credentials#VerifiableCredential\",\n      \"@context\": {\n        \"@protected\": true,\n\n        \"id\": \"@id\",\n        \"type\": \"@type\",\n\n        \"credentialSchema\": {\n          \"@id\": \"https://www.w3.org/2018/credentials#credentialSchema\",\n          \"@type\": \"@id\"\n        },\n        \"credentialStatus\": {\n          \"@id\": \"https://www.w3.org/2018/credentials#credentialStatus\",\n          \"@type\": \"@id\"\n        },\n        \"credentialSubject\": {\n          \"@id\": \"https://www.w3.org/2018/credentials#credentialSubject\",\n          \"@type\": \"@id\"\n        },\n        \"description\": \"https://schema.org/description\",\n        \"evidence\": {\n          \"@id\": \"https://www.w3.org/2018/credentials#evidence\",\n          \"@type\": \"@id\"\n        },\n        \"validFrom\": {\n          \"@id\": \"https://www.w3.org/2018/credentials#validFrom\",\n          \"@type\": \"http://www.w3.org/2001/XMLSchema#dateTime\"\n        },\n        \"validUntil\": {\n          \"@id\": \"https://www.w3.org/2018/credentials#validUntil\",\n          \"@type\": \"http://www.w3.org/2001/XMLSchema#dateTime\"\n        },\n        \"issuer\": {\n          \"@id\": \"https://www.w3.org/2018/credentials#issuer\",\n          \"@type\": \"@id\"\n        },\n        \"name\": \"https://schema.org/name\",\n        \"proof\": {\n          \"@id\": \"https://w3id.org/security#proof\",\n          \"@type\": \"@id\",\n          \"@container\": \"@graph\"\n        },\n        \"refreshService\": {\n          \"@id\": \"https://www.w3.org/2018/credentials#refreshService\",\n          \"@type\": \"@id\"\n        },\n        \"termsOfUse\": {\n          \"@id\": \"https://www.w3.org/2018/credentials#termsOfUse\",\n          \"@type\": \"@id\"\n        },\n        \"confidenceMethod\": {\n          \"@id\": \"https://www.w3.org/2018/credentials#confidenceMethod\",\n          \"@type\": \"@id\"\n        },\n        \"relatedResource\": {\n          \"@id\": \"https://www.w3.org/2018/credentials#relatedResource\",\n          \"@type\": \"@id\"\n        }\n      }\n    },\n\n    \"VerifiablePresentation\": {\n      \"@id\": \"https://www.w3.org/2018/credentials#VerifiablePresentation\",\n      \"@context\": {\n        \"@protected\": true,\n\n        \"id\": \"@id\",\n        \"type\": \"@type\",\n        \"holder\": {\n          \"@id\": \"https://www.w3.org/2018/credentials#holder\",\n          \"@type\": \"@id\"\n        },\n        \"proof\": {\n          \"@id\": \"https://w3id.org/security#proof\",\n          \"@type\": \"@id\",\n          \"@container\": \"@graph\"\n        },\n        \"verifiableCredential\": {\n          \"@id\": \"https://www.w3.org/2018/credentials#verifiableCredential\",\n          \"@type\": \"@id\",\n          \"@container\": \"@graph\",\n          \"@context\": null\n        },\n        \"termsOfUse\": {\n          \"@id\": \"https://www.w3.org/2018/credentials#termsOfUse\",\n          \"@type\": \"@id\"\n        }\n      }\n    },\n\n    \"JsonSchemaCredential\": \"https://www.w3.org/2018/credentials#JsonSchemaCredential\",\n\n    \"JsonSchema\": {\n      \"@id\": \"https://www.w3.org/2018/credentials#JsonSchema\",\n      \"@context\": {\n        \"@protected\": true,\n\n        \"id\": \"@id\",\n        \"type\": \"@type\",\n\n        \"jsonSchema\": {\n          \"@id\": \"https://www.w3.org/2018/credentials#jsonSchema\",\n          \"@type\": \"@json\"\n        }\n      }\n    },\n\n    \"BitstringStatusListCredential\": \"https://www.w3.org/ns/credentials/status#BitstringStatusListCredential\",\n\n    \"BitstringStatusList\": {\n      \"@id\": \"https://www.w3.org/ns/credentials/status#BitstringStatusList\",\n      \"@context\": {\n        \"@protected\": true,\n\n        \"id\": \"@id\",\n        \"type\": \"@type\",\n\n        \"statusPurpose\":\n          \"https://www.w3.org/ns/credentials/status#statusPurpose\",\n        \"encodedList\": {\n          \"@id\": \"https://www.w3.org/ns/credentials/status#encodedList\",\n          \"@type\": \"https://w3id.org/security#multibase\"\n        },\n        \"ttl\": \"https://www.w3.org/ns/credentials/status#ttl\",\n        \"statusReference\": \"https://www.w3.org/ns/credentials/status#statusReference\",\n        \"statusSize\": \"https://www.w3.org/ns/credentials/status#statusSize\",\n        \"statusMessage\": {\n          \"@id\": \"https://www.w3.org/ns/credentials/status#statusMessage\",\n          \"@context\": {\n            \"@protected\": true,\n\n            \"id\": \"@id\",\n            \"type\": \"@type\",\n\n            \"status\": \"https://www.w3.org/ns/credentials/status#status\",\n            \"message\": \"https://www.w3.org/ns/credentials/status#message\"\n          }\n        }\n      }\n    },\n\n    \"BitstringStatusListEntry\": {\n      \"@id\":\n        \"https://www.w3.org/ns/credentials/status#BitstringStatusListEntry\",\n      \"@context\": {\n        \"@protected\": true,\n\n        \"id\": \"@id\",\n        \"type\": \"@type\",\n\n        \"statusPurpose\":\n          \"https://www.w3.org/ns/credentials/status#statusPurpose\",\n        \"statusListIndex\":\n          \"https://www.w3.org/ns/credentials/status#statusListIndex\",\n        \"statusListCredential\": {\n          \"@id\":\n            \"https://www.w3.org/ns/credentials/status#statusListCredential\",\n          \"@type\": \"@id\"\n        }\n      }\n    },\n\n    \"DataIntegrityProof\": {\n      \"@id\": \"https://w3id.org/security#DataIntegrityProof\",\n      \"@context\": {\n        \"@protected\": true,\n        \"id\": \"@id\",\n        \"type\": \"@type\",\n        \"challenge\": \"https://w3id.org/security#challenge\",\n        \"created\": {\n          \"@id\": \"http://purl.org/dc/terms/created\",\n          \"@type\": \"http://www.w3.org/2001/XMLSchema#dateTime\"\n        },\n        \"domain\": \"https://w3id.org/security#domain\",\n        \"expires\": {\n          \"@id\": \"https://w3id.org/security#expiration\",\n          \"@type\": \"http://www.w3.org/2001/XMLSchema#dateTime\"\n        },\n        \"nonce\": \"https://w3id.org/security#nonce\",\n        \"previousProof\": {\n          \"@id\": \"https://w3id.org/security#previousProof\",\n          \"@type\": \"@id\"\n        },\n        \"proofPurpose\": {\n          \"@id\": \"https://w3id.org/security#proofPurpose\",\n          \"@type\": \"@vocab\",\n          \"@context\": {\n            \"@protected\": true,\n            \"id\": \"@id\",\n            \"type\": \"@type\",\n            \"assertionMethod\": {\n              \"@id\": \"https://w3id.org/security#assertionMethod\",\n              \"@type\": \"@id\",\n              \"@container\": \"@set\"\n            },\n            \"authentication\": {\n              \"@id\": \"https://w3id.org/security#authenticationMethod\",\n              \"@type\": \"@id\",\n              \"@container\": \"@set\"\n            },\n            \"capabilityInvocation\": {\n              \"@id\": \"https://w3id.org/security#capabilityInvocationMethod\",\n              \"@type\": \"@id\",\n              \"@container\": \"@set\"\n            },\n            \"capabilityDelegation\": {\n              \"@id\": \"https://w3id.org/security#capabilityDelegationMethod\",\n              \"@type\": \"@id\",\n              \"@container\": \"@set\"\n            },\n            \"keyAgreement\": {\n              \"@id\": \"https://w3id.org/security#keyAgreementMethod\",\n              \"@type\": \"@id\",\n              \"@container\": \"@set\"\n            }\n          }\n        },\n        \"cryptosuite\": {\n          \"@id\": \"https://w3id.org/security#cryptosuite\",\n          \"@type\": \"https://w3id.org/security#cryptosuiteString\"\n        },\n        \"proofValue\": {\n          \"@id\": \"https://w3id.org/security#proofValue\",\n          \"@type\": \"https://w3id.org/security#multibase\"\n        },\n        \"verificationMethod\": {\n          \"@id\": \"https://w3id.org/security#verificationMethod\",\n          \"@type\": \"@id\"\n        }\n      }\n    }\n  }\n};\n","/*!\n * Copyright (c) 2023-2024 Digital Bazaar, Inc. All rights reserved.\n */\nimport context from './context.js';\n\nexport const constants = {\n  // default context output filename under ./contexts/\n  CONTEXT_FILENAME: 'credentials-v2.jsonld',\n  // default context well known URL id\n  CONTEXT_URL: 'https://www.w3.org/ns/credentials/v2',\n  // default context CBOR-LD codec id\n  // value between 0x0 and 0x7FFF for globally registered term codec values\n  // or >= 0x8000 for app-specific local terms\n  CBORLD_VALUE: 0x0\n};\n\n// map of all context URLs to context data\nexport const contexts = new Map();\ncontexts.set(constants.CONTEXT_URL, context);\n\n// map of all context URLs to CBOR-LD codec ids\nexport const appContextMap = new Map();\nappContextMap.set(constants.CONTEXT_URL, constants.CBORLD_VALUE);\n\nexport const CONTEXT = context;\nexport const CONTEXT_URL = constants.CONTEXT_URL;\n","/*!\n * Copyright (c) 2022-2023 Digital Bazaar, Inc. All rights reserved.\n */\nimport * as base58btc from 'base58-universal';\nimport * as base64url from 'base64url-universal';\nimport * as util from './util.js';\nimport jsigs from 'jsonld-signatures';\nimport {sha256digest} from './sha256digest.js';\n\nconst {suites: {LinkedDataProof}} = jsigs;\n\n// multibase base58-btc header\nconst MULTIBASE_BASE58BTC_HEADER = 'z';\n// multibase base64url no pad header\nconst MULTIBASE_BASE64URL_HEADER = 'u';\nconst DATA_INTEGRITY_CONTEXT_V2 = 'https://w3id.org/security/data-integrity/v2';\nconst DATA_INTEGRITY_CONTEXT_V1 = 'https://w3id.org/security/data-integrity/v1';\nconst PROOF_TYPE = 'DataIntegrityProof';\n// VCDM 2.0 core context\nconst VC_2_0_CONTEXT = 'https://www.w3.org/ns/credentials/v2';\n\nexport class DataIntegrityProof extends LinkedDataProof {\n  constructor({signer, date, cryptosuite, legacyContext = false} = {}) {\n    super({type: PROOF_TYPE});\n    const {\n      canonize, createVerifier, name, requiredAlgorithm,\n      derive, createProofValue, createVerifyData\n    } = cryptosuite;\n    // `createVerifier` is required\n    if(!(createVerifier && typeof createVerifier === 'function')) {\n      throw new TypeError(\n        '\"cryptosuite.createVerifier\" must be a function.');\n    }\n    // assert optional functions\n    if(derive && typeof derive !== 'function') {\n      throw new TypeError(\n        '\"cryptosuite.derive\" must be a function.');\n    }\n    if(createProofValue && typeof createProofValue !== 'function') {\n      throw new TypeError(\n        '\"cryptosuite.createProofValue\" must be a function.');\n    }\n    if(createVerifyData && typeof createVerifyData !== 'function') {\n      throw new TypeError(\n        '\"cryptosuite.createVerifyData\" must be a function.');\n    }\n    this.contextUrl = DATA_INTEGRITY_CONTEXT_V2;\n    if(legacyContext) {\n      this.contextUrl = DATA_INTEGRITY_CONTEXT_V1;\n    }\n    this.canonize = canonize;\n    this.createVerifier = createVerifier;\n    this.cryptosuite = name;\n    // save internal reference to cryptosuite instance\n    this._cryptosuite = cryptosuite;\n    this.requiredAlgorithm = requiredAlgorithm;\n    if(date) {\n      this.date = new Date(date);\n      if(isNaN(this.date)) {\n        throw TypeError(`\"date\" \"${date}\" is not a valid date.`);\n      }\n    } else if(date === null) {\n      this.date = null;\n    }\n\n    const vm = _processSignatureParams({signer, requiredAlgorithm});\n    this.verificationMethod = vm.verificationMethod;\n    this.signer = vm.signer;\n  }\n\n  /**\n   * Adds a signature (proofValue) field to the proof object. Called by\n   * LinkedDataSignature.createProof().\n   *\n   * @param {object} options - The options to use.\n   * @param {Uint8Array|object} options.verifyData - Data to be signed\n   *   (extracted from document, according to the suite's spec).\n   * @param {object} options.proof - Proof object (containing the proofPurpose,\n   *   verificationMethod, etc).\n   *\n   * @returns {Promise<object>} Resolves with the proof containing the signature\n   *   value.\n   */\n  async sign({verifyData, proof}) {\n    if(!(this.signer && typeof this.signer.sign === 'function')) {\n      throw new Error('A signer API has not been specified.');\n    }\n\n    const signatureBytes = await this.signer.sign({data: verifyData});\n    proof.proofValue =\n      MULTIBASE_BASE58BTC_HEADER + base58btc.encode(signatureBytes);\n\n    return proof;\n  }\n\n  /**\n   * Verifies the proof signature against the given data.\n   *\n   * @param {object} options - The options to use.\n   * @param {Uint8Array|object} options.verifyData - Verify data as produced\n   *   from `createVerifyData`.\n   * @param {object} options.verificationMethod - Key object.\n   * @param {object} options.proof - The proof to be verified.\n   *\n   * @returns {Promise<boolean>} Resolves with the verification result.\n   */\n  async verifySignature({verifyData, verificationMethod, proof}) {\n    const verifier = await this.createVerifier({verificationMethod});\n    const isSupportedAlgorithm = Array.isArray(this.requiredAlgorithm) ?\n      this.requiredAlgorithm.includes(verifier.algorithm) :\n      this.requiredAlgorithm === verifier.algorithm;\n\n    if(!isSupportedAlgorithm) {\n      const supportedAlgorithms = Array.isArray(this.requiredAlgorithm) ?\n        this.requiredAlgorithm.join(', ') : this.requiredAlgorithm;\n      const messageSuffix = Array.isArray(this.requiredAlgorithm) ?\n        `is not a supported algorithm for the cryptosuite. The supported ` +\n        `algorithms are: \"${supportedAlgorithms}\".` :\n        `does not match the required algorithm for the cryptosuite ` +\n        `\"${supportedAlgorithms}\".`;\n      const message = `The verifier's algorithm \"${verifier.algorithm}\" ` +\n        `${messageSuffix}`;\n      throw new Error(message);\n    }\n\n    const {proofValue} = proof;\n    if(!(proofValue && typeof proofValue === 'string')) {\n      throw new TypeError(\n        'The proof does not include a valid \"proofValue\" property.');\n    }\n    const multibaseHeader = proofValue[0];\n    let signature;\n    if(multibaseHeader === MULTIBASE_BASE58BTC_HEADER) {\n      signature = base58btc.decode(proofValue.slice(1));\n    } else if(multibaseHeader === MULTIBASE_BASE64URL_HEADER) {\n      signature = base64url.decode(proofValue.slice(1));\n    } else {\n      throw new Error(\n        'Only base58btc or base64url multibase encoding is supported.');\n    }\n    return verifier.verify({data: verifyData, signature});\n  }\n\n  /**\n   * @param {object} options - The options to use.\n   * @param {object} options.document - The document to create a proof for.\n   * @param {object} options.purpose - The `ProofPurpose` instance to use.\n   * @param {Array} options.proofSet - Any existing proof set.\n   * @param {Function} options.documentLoader - The document loader to use.\n   *\n   * @returns {Promise<object>} Resolves with the created proof object.\n   */\n  async createProof({document, purpose, proofSet, documentLoader}) {\n    // build proof (currently known as `signature options` in spec)\n    let proof;\n    if(this.proof) {\n      // shallow copy\n      proof = {...this.proof};\n    } else {\n      // create proof JSON-LD document\n      proof = {};\n    }\n\n    // ensure proof type is set\n    proof.type = this.type;\n\n    // set default `now` date if not given in `proof` or `options`\n    let date = this.date;\n    if(proof.created === undefined && date === undefined) {\n      date = new Date();\n    }\n\n    // ensure date is in string format\n    if(date && typeof date !== 'string') {\n      date = util.w3cDate(date);\n    }\n\n    // add API overrides\n    if(date) {\n      proof.created = date;\n    }\n    proof.verificationMethod = this.verificationMethod;\n    proof.cryptosuite = this.cryptosuite;\n\n    // add any extensions to proof (mostly for legacy support)\n    proof = await this.updateProof({\n      document, proof, purpose, proofSet, documentLoader\n    });\n\n    // allow purpose to update the proof; any terms added to `proof` must have\n    // be compatible with its context\n    proof = await purpose.update(\n      proof, {document, suite: this, documentLoader});\n\n    // create data to sign\n    let verifyData;\n    // use custom cryptosuite `createVerifyData` if available\n    if(this._cryptosuite.createVerifyData) {\n      verifyData = await this._cryptosuite.createVerifyData({\n        cryptosuite: this._cryptosuite,\n        document, proof, proofSet, documentLoader,\n        dataIntegrityProof: this\n      });\n    } else {\n      verifyData = await this.createVerifyData(\n        {document, proof, proofSet, documentLoader});\n    }\n\n    // use custom `createProofValue` if available\n    if(this._cryptosuite.createProofValue) {\n      proof.proofValue = await this._cryptosuite.createProofValue({\n        cryptosuite: this._cryptosuite,\n        verifyData, document, proof, proofSet,\n        documentLoader, dataIntegrityProof: this\n      });\n    } else {\n      // default to simple signing of data\n      proof = await this.sign(\n        {verifyData, document, proof, proofSet, documentLoader});\n    }\n\n    return proof;\n  }\n\n  /**\n   * @param {object} options - The options to use.\n   * @param {object} options.document - The document to derive from.\n   * @param {object} options.purpose - The `ProofPurpose` instance to use.\n   * @param {Array} options.proofSet - Any existing proof set.\n   * @param {Function} options.documentLoader - The document loader to use.\n   *\n   * @returns {Promise<object>} Resolves with the new document with a new\n   *   `proof` field.\n   */\n  async derive({document, purpose, proofSet, documentLoader}) {\n    // delegate entirely to cryptosuite instance\n    if(!this._cryptosuite.derive) {\n      throw new Error('\"cryptosuite.derive\" not provided.');\n    }\n    return this._cryptosuite.derive({\n      cryptosuite: this._cryptosuite, document, purpose, proofSet,\n      documentLoader, dataIntegrityProof: this\n    });\n  }\n\n  /**\n   * @param {object} options - The options to use.\n   * @param {object} options.proof - The proof to update.\n   *\n   * @returns {Promise<object>} Resolves with the created proof object.\n   */\n  async updateProof({proof}) {\n    return proof;\n  }\n\n  /**\n   * @param {object} options - The options to use.\n   * @param {object} options.proof - The proof to verify.\n   * @param {Array} options.proofSet - Any existing proof set.\n   * @param {object} options.document - The document to create a proof for.\n   * @param {Function} options.documentLoader - The document loader to use.\n   *\n   * @returns {Promise<{object}>} Resolves with the verification result.\n   */\n  async verifyProof({proof, proofSet, document, documentLoader}) {\n    try {\n      // create data to verify\n      let verifyData;\n      // use custom cryptosuite `createVerifyData` if available\n      if(this._cryptosuite.createVerifyData) {\n        verifyData = await this._cryptosuite.createVerifyData({\n          cryptosuite: this._cryptosuite,\n          document, proof, proofSet, documentLoader,\n          dataIntegrityProof: this\n        });\n      } else {\n        verifyData = await this.createVerifyData(\n          {document, proof, proofSet, documentLoader});\n      }\n\n      // fetch verification method\n      const verificationMethod = await this.getVerificationMethod({\n        proof, documentLoader\n      });\n\n      // verify signature on data\n      const verified = await this.verifySignature({\n        verifyData, verificationMethod, proof\n      });\n      if(!verified) {\n        throw new Error('Invalid signature.');\n      }\n\n      return {verified: true, verificationMethod};\n    } catch(error) {\n      return {verified: false, error};\n    }\n  }\n\n  /**\n   * @param {object} options - The options to use.\n   * @param {object} options.document - The document to create verify data for.\n   * @param {object} options.proof - The proof to create verify data for.\n   * @param {Function} options.documentLoader - The document loader to use.\n   *\n   * @returns {Promise<Uint8Array|object>} Resolves to the verify data to\n   *   be passed to `sign` or `verifySignature`.\n   */\n  async createVerifyData({document, proof, documentLoader}) {\n    // get cached document hash\n    let cachedDocHash;\n    const {_hashCache} = this;\n    if(_hashCache && _hashCache.document === document) {\n      cachedDocHash = _hashCache.hash;\n    } else {\n      this._hashCache = {\n        document,\n        // canonize and hash document\n        hash: cachedDocHash =\n          this.canonize(document, {documentLoader})\n            .then(c14nDocument => sha256digest({string: c14nDocument}))\n      };\n    }\n\n    // await both c14n proof hash and c14n document hash\n    const [proofHash, docHash] = await Promise.all([\n      // canonize and hash proof\n      this.canonizeProof(proof, {document, documentLoader})\n        .then(c14nProofOptions => sha256digest({string: c14nProofOptions})),\n      cachedDocHash\n    ]);\n    // concatenate hash of c14n proof options and hash of c14n document\n    return util.concat(proofHash, docHash);\n  }\n\n  /**\n   * @param {object} options - The options to use.\n   * @param {object} options.proof - The proof for which to get the\n   *   verification method.\n   * @param {Function} options.documentLoader - The document loader to use.\n   *\n   * @returns {object} - The verificationMethod.\n   */\n  async getVerificationMethod({proof, documentLoader}) {\n    let {verificationMethod} = proof;\n\n    if(typeof verificationMethod === 'object') {\n      verificationMethod = verificationMethod.id;\n    }\n\n    if(!verificationMethod) {\n      throw new Error('No \"verificationMethod\" found in proof.');\n    }\n\n    const result = await documentLoader(verificationMethod);\n    if(!result) {\n      throw new Error(\n        `Unable to load verification method \"${verificationMethod}\".`);\n    }\n\n    const {document} = result;\n    verificationMethod = typeof document === 'string' ?\n      JSON.parse(document) : document;\n    return verificationMethod;\n  }\n\n  async canonizeProof(proof, {documentLoader, document}) {\n    // `proofValue` must not be included in the proof options\n    proof = {\n      '@context': document['@context'],\n      ...proof\n    };\n    this.ensureSuiteContext({document: proof, addSuiteContext: true});\n    delete proof.proofValue;\n    return this.canonize(proof, {documentLoader, skipExpansion: false});\n  }\n\n  /**\n   * Checks whether a given proof exists in the document.\n   *\n   * @param {object} options - The options to use.\n   * @param {object} options.proof - The proof to match.\n   *\n   * @returns {Promise<boolean>} Whether a match for the proof was found.\n   */\n  async matchProof({\n    proof /*, document, purpose, documentLoader, expansionMap */\n  }) {\n    const {type, cryptosuite} = proof;\n    return type === this.type && cryptosuite === this.cryptosuite;\n  }\n\n  /**\n   * Ensures the document to be signed contains the required signature suite\n   * specific `@context`, by either adding it (if `addSuiteContext` is true),\n   * or throwing an error if it's missing.\n   *\n   * @param {object} options - Options hashmap.\n   * @param {object} options.document - JSON-LD document to be signed.\n   * @param {boolean} options.addSuiteContext - Add suite context?\n   */\n  ensureSuiteContext({document, addSuiteContext}) {\n    const {contextUrl} = this;\n\n    if(_includesContext({document, contextUrl}) ||\n      _includesContext({document, contextUrl: VC_2_0_CONTEXT})) {\n      // document already includes the required context\n      return;\n    }\n\n    if(!addSuiteContext) {\n      throw new TypeError(\n        `The document to be signed must contain this suite's @context, ` +\n          `\"${contextUrl}\".`);\n    }\n\n    // enforce the suite's context by adding it to the document\n    const existingContext = document['@context'] || [];\n\n    document['@context'] = Array.isArray(existingContext) ?\n      [...existingContext, contextUrl] : [existingContext, contextUrl];\n  }\n}\n\n/**\n * Tests whether a provided JSON-LD document includes a context URL in its\n * `@context` property.\n *\n * @param {object} options - Options hashmap.\n * @param {object} options.document - A JSON-LD document.\n * @param {string} options.contextUrl - A context URL.\n *\n * @returns {boolean} Returns true if document includes context.\n */\nfunction _includesContext({document, contextUrl}) {\n  const context = document['@context'];\n  return context === contextUrl ||\n    (Array.isArray(context) && context.includes(contextUrl));\n}\n\n/**\n * See constructor docstring for param details.\n *\n * @param {object} options - The options to use.\n * @param {object} options.signer - The signer to use.\n * @param {Array|string} options.requiredAlgorithm - The required algorithm.\n * @returns {{verificationMethod: string\n *   signer: {sign: Function, id: string, algorithm: string}}}} - Validated and\n *   initialized signature-related parameters.\n */\nfunction _processSignatureParams({signer, requiredAlgorithm}) {\n  const vm = {\n    verificationMethod: undefined,\n    signer: undefined\n  };\n\n  if(!signer) {\n    return vm;\n  }\n\n  if(typeof signer.sign !== 'function') {\n    throw new TypeError('A signer API has not been specified.');\n  }\n  const isSupportedAlgorithm = Array.isArray(requiredAlgorithm) ?\n    requiredAlgorithm.includes(signer.algorithm) :\n    requiredAlgorithm === signer.algorithm;\n\n  if(!isSupportedAlgorithm) {\n    const supportedAlgorithms = Array.isArray(requiredAlgorithm) ?\n      requiredAlgorithm.join(', ') : requiredAlgorithm;\n    const messageSuffix = Array.isArray(requiredAlgorithm) ?\n      `is not a supported algorithm for the cryptosuite. The supported ` +\n      `algorithms are: \"${supportedAlgorithms}\".` :\n      `does not match the required algorithm for the cryptosuite ` +\n      `\"${supportedAlgorithms}\".`;\n    const message = `The signer's algorithm \"${signer.algorithm}\" ` +\n      `${messageSuffix}`;\n    throw new Error(message);\n  }\n\n  vm.signer = signer;\n  vm.verificationMethod = signer.id;\n\n  return vm;\n}\n","/*!\n * Copyright (c) 2022 Digital Bazaar, Inc. All rights reserved.\n */\nimport {DataIntegrityProof} from './DataIntegrityProof.js';\n\nexport {DataIntegrityProof};\n","/*\n * Copyright (c) 2022 Digital Bazaar, Inc. All rights reserved.\n */\n/* eslint-env browser */\nconst crypto = self && (self.crypto || self.msCrypto);\n\n/**\n * Hashes a string of data using SHA-256.\n *\n * @param {string} string - The string to hash.\n *\n * @returns {Uint8Array} The hash digest.\n */\nexport async function sha256digest({string}) {\n  const bytes = new TextEncoder().encode(string);\n  return new Uint8Array(await crypto.subtle.digest('SHA-256', bytes));\n}\n","\n/*!\n * Copyright (c) 2022-2023 Digital Bazaar, Inc. All rights reserved.\n */\n\n/**\n * Converts the given date into W3C datetime format (eg: 2011-03-09T21:55:41Z).\n *\n * @param {Date|number|string} date - The date to convert.\n *\n * @returns {string} The date in W3C datetime format.\n */\nexport const w3cDate = date => {\n  if(date === undefined || date === null) {\n    date = new Date();\n  } else if(typeof date === 'number' || typeof date === 'string') {\n    date = new Date(date);\n  }\n  const str = date.toISOString();\n  return str.slice(0, - 5) + 'Z';\n};\n\n/**\n * Concatenates two Uint8Arrays.\n *\n * @param {Uint8Array} b1 - The first buffer to concat.\n * @param {Uint8Array} b2 - The second buffer to concat.\n *\n * @returns {Uint8Array} The result.\n */\nexport const concat = (b1, b2) => {\n  const rval = new Uint8Array(b1.length + b2.length);\n  rval.set(b1, 0);\n  rval.set(b2, b1.length);\n  return rval;\n};\n","/*!\n * Copyright (c) 2022-2024 Digital Bazaar, Inc. All rights reserved.\n */\n\n// Ed25519 Signature 2018 Context v1 URL\nexport const ED25519_SIGNATURE_2018_V1_URL =\n  'https://w3id.org/security/suites/ed25519-2018/v1';\n// Ed25519 Signature 2020 Context v1 URL\nexport const ED25519_SIGNATURE_2020_V1_URL =\n  'https://w3id.org/security/suites/ed25519-2020/v1';\n// multibase base58-btc header\nexport const MULTIBASE_BASE58BTC_HEADER = 'z';\n// multicodec ed25519-pub header as varint\nexport const MULTICODEC_PUB_HEADER = new Uint8Array([0xed, 0x01]);\n// multicodec ed25519-priv header as varint\nexport const MULTICODEC_PRIV_HEADER = new Uint8Array([0x80, 0x26]);\n// multikey context v1 url\nexport const MULTIKEY_CONTEXT_V1_URL = 'https://w3id.org/security/multikey/v1';\n// Ed25519 public key size in bytes\nexport const PUBLIC_KEY_SIZE = 32;\n// Ed25519 secret key size in bytes\nexport const SECRET_KEY_SIZE = 32;\n","/*!\n * Copyright (c) 2020-2022 Digital Bazaar, Inc. All rights reserved.\n */\nimport * as ed25519 from '@noble/ed25519';\nimport {assertKeyBytes} from './validators.js';\n\n// browser MUST provide \"crypto.getRandomValues\"\nconst crypto = globalThis.crypto;\nif(!crypto.getRandomValues) {\n  throw new Error('Browser does not provide \"crypto.getRandomValues\".');\n}\n\nexport async function generateKeyPairFromSeed(seed) {\n  assertKeyBytes({\n    bytes: seed,\n    expectedLength: 32,\n  });\n  const publicKey = await ed25519.getPublicKey(seed);\n  const secretKey = new Uint8Array(64);\n  secretKey.set(seed);\n  secretKey.set(publicKey, seed.length);\n  return {\n    publicKey,\n    secretKey\n  };\n}\n\nexport async function generateKeyPair() {\n  const seed = new Uint8Array(32);\n  crypto.getRandomValues(seed);\n  const keyPair = await generateKeyPairFromSeed(seed);\n  seed.fill(0);\n  return keyPair;\n}\n\nexport async function sign(secretKey, data) {\n  return ed25519.sign(data, secretKey.slice(0, 32));\n}\n\nexport async function verify(publicKey, data, signature) {\n  return ed25519.verify(signature, data, publicKey);\n}\n\nexport async function sha256digest({data}) {\n  return crypto.subtle.digest('SHA-256', data);\n}\n","/*!\n * Copyright (c) 2022 Digital Bazaar, Inc. All rights reserved.\n */\nimport * as ed25519 from './ed25519.js';\n\nconst ALGORITHM = 'Ed25519';\n\nexport function createSigner({id, secretKey}) {\n  if(!secretKey) {\n    throw new Error('A secret key is not available for signing.');\n  }\n  return {\n    algorithm: ALGORITHM,\n    id,\n    async sign({data}) {\n      return ed25519.sign(secretKey, data);\n    },\n  };\n}\n\nexport function createVerifier({id, publicKey}) {\n  if(!publicKey) {\n    throw new Error('A public key is not available for verifying.');\n  }\n  return {\n    algorithm: ALGORITHM,\n    id,\n    async verify({data, signature}) {\n      return ed25519.verify(publicKey, data, signature);\n    },\n  };\n}\n","/*!\n * Copyright (c) 2020-2024 Digital Bazaar, Inc. All rights reserved.\n */\nimport * as base58btc from 'base58-universal';\nimport {\n  MULTIBASE_BASE58BTC_HEADER,\n  MULTICODEC_PRIV_HEADER,\n  MULTICODEC_PUB_HEADER\n} from './constants.js';\n\nexport function mbEncodeKeyPair({keyPair}) {\n  const result = {};\n  if(keyPair.publicKey) {\n    result.publicKeyMultibase = _encodeMbKey(\n      MULTICODEC_PUB_HEADER, keyPair.publicKey);\n  }\n  if(keyPair.secretKey) {\n    result.secretKeyMultibase = _encodeMbKey(\n      MULTICODEC_PRIV_HEADER, keyPair.secretKey);\n  }\n  return result;\n}\n\nexport function mbDecodeKeyPair({publicKeyMultibase, secretKeyMultibase}) {\n  if(!(publicKeyMultibase && typeof publicKeyMultibase === 'string' &&\n  publicKeyMultibase[0] === 'z')) {\n    throw new Error(\n      '\"publicKeyMultibase\" must be a multibase, base58-encoded string.');\n  }\n  // remove multibase header\n  const publicKeyMulticodec = base58btc.decode(publicKeyMultibase.substr(1));\n  // remove multicodec header\n  const publicKey = publicKeyMulticodec.slice(MULTICODEC_PUB_HEADER.length);\n\n  let secretKey;\n  if(secretKeyMultibase) {\n    if(!(typeof secretKeyMultibase === 'string' &&\n    secretKeyMultibase[0] === 'z')) {\n      throw new Error(\n        '\"secretKeyMultibase\" must be a multibase, base58-encoded string.');\n    }\n    // remove multibase header\n    const secretKeyMulticodec = base58btc.decode(secretKeyMultibase.substr(1));\n    // remove multicodec header\n    secretKey = secretKeyMulticodec.slice(MULTICODEC_PRIV_HEADER.length);\n  }\n\n  return {\n    publicKey,\n    secretKey\n  };\n}\n\n// encode a multibase base58-btc multicodec key\nfunction _encodeMbKey(header, key) {\n  const mbKey = new Uint8Array(header.length + key.length);\n\n  mbKey.set(header);\n  mbKey.set(key, header.length);\n\n  return MULTIBASE_BASE58BTC_HEADER + base58btc.encode(mbKey);\n}\n","/*!\n * Copyright (c) 2020-2023 Digital Bazaar, Inc. All rights reserved.\n */\nimport * as base64url from 'base64url-universal';\nimport * as ed25519 from './ed25519.js';\nimport {createSigner, createVerifier} from './factory.js';\nimport {\n  exportKeyPair, importKeyPair,\n  jwkToPublicKeyMultibase,\n  jwkToSecretKeyMultibase\n} from './serialize.js';\nimport {MULTIKEY_CONTEXT_V1_URL, SECRET_KEY_SIZE} from './constants.js';\nimport {mbEncodeKeyPair} from './helpers.js';\nimport {toMultikey} from './keyPairTranslator.js';\n\nexport async function generate({id, controller, seed} = {}) {\n  let key;\n  if(seed) {\n    key = await ed25519.generateKeyPairFromSeed(seed);\n  } else {\n    key = await ed25519.generateKeyPair();\n  }\n\n  const {publicKeyMultibase, secretKeyMultibase} = mbEncodeKeyPair({\n    keyPair: key\n  });\n  if(controller && !id) {\n    id = `${controller}#${publicKeyMultibase}`;\n  }\n  const keyPair = {\n    id,\n    controller,\n    publicKeyMultibase,\n    secretKeyMultibase,\n    ...key,\n  };\n  return _createKeyPairInterface({keyPair});\n}\n\n// import key pair from JSON Multikey\nexport async function from(key) {\n  let multikey = {...key};\n  if(multikey.type !== 'Multikey') {\n    // attempt loading from JWK if `publicKeyJwk` is present\n    if(multikey.publicKeyJwk) {\n      return fromJwk({jwk: multikey.publicKeyJwk, secretKey: false});\n    }\n    if(multikey.type) {\n      multikey = await toMultikey({keyPair: multikey});\n      return _createKeyPairInterface({keyPair: multikey});\n    }\n  }\n  if(!multikey.type) {\n    multikey.type = 'Multikey';\n  }\n  if(!multikey['@context']) {\n    multikey['@context'] = MULTIKEY_CONTEXT_V1_URL;\n  }\n\n  _assertMultikey(multikey);\n  return _createKeyPairInterface({keyPair: multikey});\n}\n\n// imports key pair from JWK\nexport async function fromJwk({jwk, secretKey = false} = {}) {\n  const multikey = {\n    '@context': MULTIKEY_CONTEXT_V1_URL,\n    type: 'Multikey',\n    publicKeyMultibase: jwkToPublicKeyMultibase({jwk})\n  };\n  if(secretKey && jwk.d) {\n    multikey.secretKeyMultibase = jwkToSecretKeyMultibase({jwk});\n  }\n  return from(multikey);\n}\n\n// converts key pair to JWK\nexport async function toJwk({keyPair, secretKey = false} = {}) {\n  const jwk = {\n    kty: 'OKP',\n    crv: 'Ed25519',\n    x: base64url.encode(keyPair.publicKey)\n  };\n  const useSecretKey = secretKey && !!keyPair.secretKey;\n  if(useSecretKey) {\n    jwk.d = base64url.encode(keyPair.secretKey);\n  }\n  return jwk;\n}\n\nasync function _createKeyPairInterface({keyPair}) {\n  if(!keyPair.publicKey) {\n    keyPair = await importKeyPair(keyPair);\n  }\n  keyPair = {\n    ...keyPair,\n    async export({\n      publicKey = true, secretKey = false, includeContext = true, raw = false,\n      canonicalize = false\n    } = {}) {\n      if(raw) {\n        const {publicKey, secretKey} = keyPair;\n        const result = {};\n        if(publicKey) {\n          result.publicKey = publicKey.slice();\n        }\n        if(secretKey) {\n          if(canonicalize && secretKey.length > SECRET_KEY_SIZE) {\n            result.secretKey = secretKey.subarray(0, SECRET_KEY_SIZE).slice();\n          }\n          result.secretKey = secretKey;\n        }\n        return result;\n      }\n      return exportKeyPair({\n        keyPair, publicKey, secretKey, includeContext, canonicalize\n      });\n    },\n    signer() {\n      const {id, secretKey} = keyPair;\n      return createSigner({id, secretKey});\n    },\n    verifier() {\n      const {id, publicKey} = keyPair;\n      return createVerifier({id, publicKey});\n    }\n  };\n\n  return keyPair;\n}\n\nfunction _assertMultikey(key) {\n  if(!(key && typeof key === 'object')) {\n    throw new TypeError('\"key\" must be an object.');\n  }\n  if(key.type !== 'Multikey') {\n    throw new Error('\"key\" must be a Multikey with type \"Multikey\".');\n  }\n  if(!(key['@context'] === MULTIKEY_CONTEXT_V1_URL ||\n    (Array.isArray(key['@context']) &&\n    key['@context'].includes(MULTIKEY_CONTEXT_V1_URL)))) {\n    throw new TypeError(\n      '\"key\" must be a Multikey with context ' +\n      `\"${MULTIKEY_CONTEXT_V1_URL}\".`);\n  }\n}\n","/*!\n * Copyright (c) 2022-2024 Digital Bazaar, Inc. All rights reserved.\n */\nimport * as base58btc from 'base58-universal';\nimport {\n  ED25519_SIGNATURE_2018_V1_URL,\n  ED25519_SIGNATURE_2020_V1_URL,\n  MULTIKEY_CONTEXT_V1_URL\n} from './constants.js';\nimport {mbEncodeKeyPair} from './helpers.js';\n\nconst keyPairTranslationMap = new Map([\n  ['Ed25519VerificationKey2020', {\n    contextUrl: ED25519_SIGNATURE_2020_V1_URL,\n    translationFn: _translateEd25519VerificationKey2020\n  }],\n  ['Ed25519VerificationKey2018', {\n    contextUrl: ED25519_SIGNATURE_2018_V1_URL,\n    translationFn: _translateEd25519VerificationKey2018\n  }]\n]);\n\nasync function _translateEd25519VerificationKey2020({keyPair}) {\n  return {\n    ...keyPair,\n    type: 'Multikey',\n    '@context': MULTIKEY_CONTEXT_V1_URL,\n    secretKeyMultibase: keyPair.privateKeyMultibase\n  };\n}\n\nasync function _translateEd25519VerificationKey2018({keyPair}) {\n  const key = {\n    publicKey: base58btc.decode(keyPair.publicKeyBase58),\n    secretKey: undefined\n  };\n\n  if(keyPair.privateKeyBase58) {\n    key.secretKey = base58btc.decode(keyPair.privateKeyBase58);\n  }\n\n  const {publicKeyMultibase, secretKeyMultibase} = mbEncodeKeyPair({\n    keyPair: key\n  });\n\n  return {\n    '@context': MULTIKEY_CONTEXT_V1_URL,\n    id: keyPair.id,\n    type: 'Multikey',\n    controller: keyPair.controller,\n    revoked: keyPair.revoked,\n    publicKeyMultibase,\n    secretKeyMultibase,\n  };\n}\n\nexport {keyPairTranslationMap};\n","/*!\n * Copyright (c) 2022 Digital Bazaar, Inc. All rights reserved.\n */\nimport {keyPairTranslationMap} from './keyPairTranslationMap.js';\n\nexport async function toMultikey({keyPair}) {\n  const translationResult = keyPairTranslationMap.get(keyPair.type);\n  if(!translationResult) {\n    throw new Error(`Unsupported key type \"${keyPair.type}\".`);\n  }\n\n  const {contextUrl, translationFn} = translationResult;\n  if(!keyPair['@context']) {\n    keyPair['@context'] = contextUrl;\n  }\n  if(!_includesContext({document: keyPair, contextUrl})) {\n    throw new Error(`Context not supported \"${keyPair['@context']}\".`);\n  }\n\n  return translationFn({keyPair});\n}\n\nfunction _includesContext({document, contextUrl}) {\n  const context = document['@context'];\n  return context === contextUrl ||\n    (Array.isArray(context) && context.includes(contextUrl));\n}\n","/*!\n * Copyright (c) 2022-2024 Digital Bazaar, Inc. All rights reserved.\n */\nimport * as base64url from 'base64url-universal';\nimport {mbDecodeKeyPair, mbEncodeKeyPair} from './helpers.js';\nimport {\n  MULTIKEY_CONTEXT_V1_URL,\n  PUBLIC_KEY_SIZE,\n  SECRET_KEY_SIZE\n} from './constants.js';\n\nconst LEGACY_SECRET_KEY_SIZE = SECRET_KEY_SIZE + PUBLIC_KEY_SIZE;\n\nexport async function exportKeyPair({\n  keyPair, secretKey, publicKey, includeContext, canonicalize = false\n} = {}) {\n  if(!(publicKey || secretKey)) {\n    throw new TypeError(\n      'Export requires specifying either \"publicKey\" or \"secretKey\".');\n  }\n\n  const useSecretKey = secretKey && !!keyPair.secretKey;\n\n  // export as Multikey\n  const exported = {};\n  if(includeContext) {\n    exported['@context'] = MULTIKEY_CONTEXT_V1_URL;\n  }\n  exported.id = keyPair.id;\n  exported.type = 'Multikey';\n  exported.controller = keyPair.controller;\n\n  if(publicKey) {\n    exported.publicKeyMultibase = rawToPublicKeyMultibase(keyPair);\n  }\n  if(useSecretKey) {\n    exported.secretKeyMultibase = rawToSecretKeyMultibase({\n      ...keyPair, canonicalize\n    });\n  }\n\n  if(keyPair.revoked) {\n    exported.revoked = keyPair.revoked;\n  }\n\n  return exported;\n}\n\nexport async function importKeyPair({\n  id, controller, secretKeyMultibase, publicKeyMultibase, revoked\n}) {\n  if(!publicKeyMultibase) {\n    throw new TypeError('The \"publicKeyMultibase\" property is required.');\n  }\n\n  const {\n    publicKey, secretKey\n  } = mbDecodeKeyPair({publicKeyMultibase, secretKeyMultibase});\n\n  if(controller && !id) {\n    id = `${controller}#${publicKeyMultibase}`;\n  }\n\n  return {\n    id,\n    controller,\n    publicKey,\n    secretKey,\n    publicKeyMultibase,\n    secretKeyMultibase,\n    revoked,\n  };\n}\n\nexport function jwkToPublicKeyBytes({jwk} = {}) {\n  const {kty, crv, x} = jwk;\n  if(kty !== 'OKP') {\n    throw new TypeError('\"jwk.kty\" must be \"OKP\".');\n  }\n  if(crv !== 'Ed25519') {\n    throw new TypeError('\"jwk.crv\" must be \"Ed25519\".');\n  }\n  if(typeof x !== 'string') {\n    throw new TypeError('\"jwk.x\" must be a string.');\n  }\n  const publicKey = base64url.decode(jwk.x);\n  if(publicKey.length !== PUBLIC_KEY_SIZE) {\n    throw new Error(\n      `Invalid public key size (${publicKey.length}); ` +\n      `expected ${PUBLIC_KEY_SIZE}.`);\n  }\n  return publicKey;\n}\n\nexport function jwkToPublicKeyMultibase({jwk} = {}) {\n  const publicKey = jwkToPublicKeyBytes({jwk});\n  const {publicKeyMultibase} = mbEncodeKeyPair({\n    keyPair: {publicKey}\n  });\n  return publicKeyMultibase;\n}\n\nexport function jwkToSecretKeyBytes({jwk} = {}) {\n  const {kty, crv, d} = jwk;\n  if(kty !== 'OKP') {\n    throw new TypeError('\"jwk.kty\" must be \"OKP\".');\n  }\n  if(crv !== 'Ed25519') {\n    throw new TypeError('\"jwk.crv\" must be \"Ed25519\".');\n  }\n  if(typeof d !== 'string') {\n    throw new TypeError('\"jwk.d\" must be a string.');\n  }\n  const secretKey = Uint8Array.from(base64url.decode(jwk.d));\n  if(secretKey.length !== SECRET_KEY_SIZE) {\n    throw new Error(\n      `Invalid secret key size (${secretKey.length}); ` +\n      `expected ${SECRET_KEY_SIZE}.`);\n  }\n  return secretKey;\n}\n\nexport function jwkToSecretKeyMultibase({jwk} = {}) {\n  const secretKey = jwkToSecretKeyBytes({jwk});\n  const {secretKeyMultibase} = mbEncodeKeyPair({\n    keyPair: {secretKey}\n  });\n  return secretKeyMultibase;\n}\n\nexport function rawToPublicKeyMultibase({publicKey} = {}) {\n  if(publicKey.length !== PUBLIC_KEY_SIZE) {\n    throw new Error(\n      `Invalid public key size (${publicKey.length}); ` +\n      `expected ${PUBLIC_KEY_SIZE}.`);\n  }\n  const {publicKeyMultibase} = mbEncodeKeyPair({\n    keyPair: {publicKey}\n  });\n  return publicKeyMultibase;\n}\n\nexport function rawToSecretKeyMultibase({\n  secretKey, canonicalize = false\n} = {}) {\n  if(secretKey.length !== SECRET_KEY_SIZE) {\n    if(secretKey.length !== LEGACY_SECRET_KEY_SIZE) {\n      throw new Error(\n        `Invalid secret key size (${secretKey.length}); ` +\n        `expected ${SECRET_KEY_SIZE}.`);\n    }\n    // handle legacy concatenated (secret key + public key)\n    if(canonicalize) {\n      secretKey = secretKey.subarray(0, SECRET_KEY_SIZE);\n    }\n  }\n  const {secretKeyMultibase} = mbEncodeKeyPair({\n    keyPair: {secretKey}\n  });\n  return secretKeyMultibase;\n}\n","/*!\n * Copyright (c) 2022 Digital Bazaar, Inc. All rights reserved.\n */\n\n/**\n * Asserts that key bytes have a type of Uint8Array and a specific length.\n *\n * @throws {TypeError|SyntaxError} - Throws a Type or Syntax error.\n *\n * @param {object} options - Options to use.\n * @param {Uint8Array} options.bytes - The bytes being checked.\n * @param {number} [options.expectedLength=32] - The expected bytes length.\n * @param {string} [options.code] - An optional code for the error.\n *\n * @returns {undefined} Returns on success throws on error.\n */\nexport function assertKeyBytes({bytes, expectedLength = 32, code}) {\n  if(!(bytes instanceof Uint8Array)) {\n    throw new TypeError('\"bytes\" must be a Uint8Array.');\n  }\n  if(bytes.length !== expectedLength) {\n    const error = new Error(\n      `\"bytes\" must be a ${expectedLength}-byte Uint8Array.`);\n    // we need DataError for invalid byte length\n    error.name = 'DataError';\n    // add the error code from the did:key spec if provided\n    if(code) {\n      error.code = code;\n    }\n    throw error;\n  }\n}\n","/*!\n * Copyright (c) 2020-2021 Digital Bazaar, Inc. All rights reserved.\n */\nimport jsigs from 'jsonld-signatures';\nconst {suites: {LinkedDataSignature}} = jsigs;\nimport * as base58btc from 'base58-universal';\nimport {\n  Ed25519VerificationKey2020\n} from '@digitalbazaar/ed25519-verification-key-2020';\nimport suiteContext2018 from 'ed25519-signature-2018-context';\nimport suiteContext2020 from 'ed25519-signature-2020-context';\n\n// 'https://w3id.org/security/suites/ed25519-2020/v1'\nconst SUITE_CONTEXT_URL = suiteContext2020.constants.CONTEXT_URL;\n// 'https://w3id.org/security/suites/ed25519-2018/v1'\nconst SUITE_CONTEXT_URL_2018 = suiteContext2018.constants.CONTEXT_URL;\n// multibase base58-btc header\nconst MULTIBASE_BASE58BTC_HEADER = 'z';\n\nexport class Ed25519Signature2020 extends LinkedDataSignature {\n  /**\n   * @param {object} options - Options hashmap.\n   *\n   * Either a `key` OR at least one of `signer`/`verifier` is required:\n   *\n   * @param {object} [options.key] - An optional key object (containing an\n   *   `id` property, and either `signer` or `verifier`, depending on the\n   *   intended operation. Useful for when the application is managing keys\n   *   itself (when using a KMS, you never have access to the private key,\n   *   and so should use the `signer` param instead).\n   * @param {Function} [options.signer] - Signer function that returns an\n   *   object with an async sign() method. This is useful when interfacing\n   *   with a KMS (since you don't get access to the private key and its\n   *   `signer()`, the KMS client gives you only the signer function to use).\n   * @param {Function} [options.verifier] - Verifier function that returns\n   *   an object with an async `verify()` method. Useful when working with a\n   *   KMS-provided verifier function.\n   *\n   * Advanced optional parameters and overrides:\n   *\n   * @param {object} [options.proof] - A JSON-LD document with options to use\n   *   for the `proof` node (e.g. any other custom fields can be provided here\n   *   using a context different from security-v2).\n   * @param {string|Date} [options.date] - Signing date to use if not passed.\n   * @param {boolean} [options.useNativeCanonize] - Whether to use a native\n   *   canonize algorithm.\n   * @param {object} [options.canonizeOptions] - Options to pass to\n   *   canonize algorithm.\n   */\n  constructor({\n    key, signer, verifier, proof, date, useNativeCanonize, canonizeOptions\n  } = {}) {\n    super({\n      type: 'Ed25519Signature2020', LDKeyClass: Ed25519VerificationKey2020,\n      contextUrl: SUITE_CONTEXT_URL,\n      key, signer, verifier, proof, date, useNativeCanonize,\n      canonizeOptions\n    });\n    // Some operations may be performed with Ed25519VerificationKey2018.\n    // So, Ed25519VerificationKey2020 is recommended, but not strictly required.\n    this.requiredKeyType = 'Ed25519VerificationKey2020';\n  }\n\n  /**\n   * Adds a signature (proofValue) field to the proof object. Called by\n   * LinkedDataSignature.createProof().\n   *\n   * @param {object} options - The options to use.\n   * @param {Uint8Array} options.verifyData - Data to be signed (extracted\n   *   from document, according to the suite's spec).\n   * @param {object} options.proof - Proof object (containing the proofPurpose,\n   *   verificationMethod, etc).\n   *\n   * @returns {Promise<object>} Resolves with the proof containing the signature\n   *   value.\n   */\n  async sign({verifyData, proof}) {\n    if(!(this.signer && typeof this.signer.sign === 'function')) {\n      throw new Error('A signer API has not been specified.');\n    }\n\n    const signatureBytes = await this.signer.sign({data: verifyData});\n    proof.proofValue =\n      MULTIBASE_BASE58BTC_HEADER + base58btc.encode(signatureBytes);\n\n    return proof;\n  }\n\n  /**\n   * Verifies the proof signature against the given data.\n   *\n   * @param {object} options - The options to use.\n   * @param {Uint8Array} options.verifyData - Canonicalized hashed data.\n   * @param {object} options.verificationMethod - Key object.\n   * @param {object} options.proof - The proof to be verified.\n   *\n   * @returns {Promise<boolean>} Resolves with the verification result.\n   */\n  async verifySignature({verifyData, verificationMethod, proof}) {\n    const {proofValue} = proof;\n    if(!(proofValue && typeof proofValue === 'string')) {\n      throw new TypeError(\n        'The proof does not include a valid \"proofValue\" property.');\n    }\n    if(proofValue[0] !== MULTIBASE_BASE58BTC_HEADER) {\n      throw new Error('Only base58btc multibase encoding is supported.');\n    }\n    const signatureBytes = base58btc.decode(proofValue.substr(1));\n\n    let {verifier} = this;\n    if(!verifier) {\n      const key = await this.LDKeyClass.from(verificationMethod);\n      verifier = key.verifier();\n    }\n    return verifier.verify({data: verifyData, signature: signatureBytes});\n  }\n\n  async assertVerificationMethod({verificationMethod}) {\n    let contextUrl;\n    if(verificationMethod.type === 'Ed25519VerificationKey2020') {\n      contextUrl = SUITE_CONTEXT_URL;\n    } else if(verificationMethod.type === 'Ed25519VerificationKey2018') {\n      contextUrl = SUITE_CONTEXT_URL_2018;\n    } else {\n      throw new Error(`Unsupported key type \"${verificationMethod.type}\".`);\n    }\n    if(!_includesContext({\n      document: verificationMethod, contextUrl\n    })) {\n      // For DID Documents, since keys do not have their own contexts,\n      // the suite context is usually provided by the documentLoader logic\n      throw new TypeError(\n        `The verification method (key) must contain \"${contextUrl}\" context.`\n      );\n    }\n\n    // ensure verification method has not been revoked\n    if(verificationMethod.revoked !== undefined) {\n      throw new Error('The verification method has been revoked.');\n    }\n  }\n\n  async getVerificationMethod({proof, documentLoader}) {\n    if(this.key) {\n      // This happens most often during sign() operations. For verify(),\n      // the expectation is that the verification method will be fetched\n      // by the documentLoader (below), not provided as a `key` parameter.\n      return this.key.export({publicKey: true});\n    }\n\n    let {verificationMethod} = proof;\n\n    if(typeof verificationMethod === 'object') {\n      verificationMethod = verificationMethod.id;\n    }\n\n    if(!verificationMethod) {\n      throw new Error('No \"verificationMethod\" found in proof.');\n    }\n\n    const {document} = await documentLoader(verificationMethod);\n\n    verificationMethod = typeof document === 'string' ?\n      JSON.parse(document) : document;\n\n    await this.assertVerificationMethod({verificationMethod});\n    if(verificationMethod.type === 'Ed25519VerificationKey2018') {\n      verificationMethod = (await Ed25519VerificationKey2020\n        .fromEd25519VerificationKey2018({keyPair: verificationMethod}))\n        .export({publicKey: true, includeContext: true});\n    }\n    return verificationMethod;\n  }\n\n  async matchProof({proof, document, purpose, documentLoader}) {\n    if(!_includesContext({document, contextUrl: SUITE_CONTEXT_URL})) {\n      return false;\n    }\n\n    if(!await super.matchProof({proof, document, purpose, documentLoader})) {\n      return false;\n    }\n    if(!this.key) {\n      // no key specified, so assume this suite matches and it can be retrieved\n      return true;\n    }\n\n    const {verificationMethod} = proof;\n\n    // only match if the key specified matches the one in the proof\n    if(typeof verificationMethod === 'object') {\n      return verificationMethod.id === this.key.id;\n    }\n    return verificationMethod === this.key.id;\n  }\n}\n\n/**\n * Tests whether a provided JSON-LD document includes a context url in its\n * `@context` property.\n *\n * @param {object} options - Options hashmap.\n * @param {object} options.document - A JSON-LD document.\n * @param {string} options.contextUrl - A context url.\n *\n * @returns {boolean} Returns true if document includes context.\n */\nfunction _includesContext({document, contextUrl}) {\n  const context = document['@context'];\n  return context === contextUrl ||\n    (Array.isArray(context) && context.includes(contextUrl));\n}\n\nEd25519Signature2020.CONTEXT_URL = SUITE_CONTEXT_URL;\nEd25519Signature2020.CONTEXT = suiteContext2020.contexts.get(SUITE_CONTEXT_URL);\n","/*!\n * Copyright (c) 2020-2021 Digital Bazaar, Inc. All rights reserved.\n */\nimport suiteContext from 'ed25519-signature-2020-context';\n\nexport {Ed25519Signature2020} from './Ed25519Signature2020.js';\nexport {suiteContext};\n","/*!\n * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.\n */\nimport * as base58btc from 'base58-universal';\nimport * as base64url from 'base64url-universal';\nimport {assertKeyBytes} from './validators.js';\nimport ed25519 from './ed25519.js';\nimport {LDKeyPair} from 'crypto-ld';\n\nconst SUITE_ID = 'Ed25519VerificationKey2020';\n// multibase base58-btc header\nconst MULTIBASE_BASE58BTC_HEADER = 'z';\n// multicodec ed25519-pub header as varint\nconst MULTICODEC_ED25519_PUB_HEADER = new Uint8Array([0xed, 0x01]);\n// multicodec ed25519-priv header as varint\nconst MULTICODEC_ED25519_PRIV_HEADER = new Uint8Array([0x80, 0x26]);\n\nexport class Ed25519VerificationKey2020 extends LDKeyPair {\n  /**\n   * An implementation of the Ed25519VerificationKey2020 spec, for use with\n   * Linked Data Proofs.\n   *\n   * @see https://w3c-ccg.github.io/lds-ed25519-2020/#ed25519verificationkey2020\n   * @see https://github.com/digitalbazaar/jsonld-signatures\n   *\n   * @param {object} options - Options hashmap.\n   * @param {string} options.controller - Controller DID or document url.\n   * @param {string} [options.id] - The key ID. If not provided, will be\n   *   composed of controller and key fingerprint as hash fragment.\n   * @param {string} options.publicKeyMultibase - Multibase encoded public key\n   *   with a multicodec ed25519-pub varint header [0xed, 0x01].\n   * @param {string} [options.privateKeyMultibase] - Multibase private key\n   *   with a multicodec ed25519-priv varint header [0x80, 0x26].\n   * @param {string} [options.revoked] - Timestamp of when the key has been\n   *   revoked, in RFC3339 format. If not present, the key itself is considered\n   *   not revoked. Note that this mechanism is slightly different than DID\n   *   Document key revocation, where a DID controller can revoke a key from\n   *   that DID by removing it from the DID Document.\n   */\n  constructor(options = {}) {\n    super(options);\n    this.type = SUITE_ID;\n    const {publicKeyMultibase, privateKeyMultibase} = options;\n\n    if(!publicKeyMultibase) {\n      throw new TypeError('The \"publicKeyMultibase\" property is required.');\n    }\n\n    if(!publicKeyMultibase || !_isValidKeyHeader(\n      publicKeyMultibase, MULTICODEC_ED25519_PUB_HEADER)) {\n      throw new Error(\n        '\"publicKeyMultibase\" has invalid header bytes: ' +\n        `\"${publicKeyMultibase}\".`);\n    }\n\n    if(privateKeyMultibase && !_isValidKeyHeader(\n      privateKeyMultibase, MULTICODEC_ED25519_PRIV_HEADER)) {\n      throw new Error('\"privateKeyMultibase\" has invalid header bytes.');\n    }\n\n    // assign valid key values\n    this.publicKeyMultibase = publicKeyMultibase;\n    this.privateKeyMultibase = privateKeyMultibase;\n\n    // set key identifier if controller is provided\n    if(this.controller && !this.id) {\n      this.id = `${this.controller}#${this.fingerprint()}`;\n    }\n    // check that the passed in keyBytes are 32 bytes\n    assertKeyBytes({\n      bytes: this._publicKeyBuffer,\n      code: 'invalidPublicKeyLength',\n      expectedLength: 32\n    });\n  }\n\n  /**\n   * Creates an Ed25519 Key Pair from an existing serialized key pair.\n   *\n   * @param {object} options - Key pair options (see constructor).\n   * @example\n   * > const keyPair = await Ed25519VerificationKey2020.from({\n   * controller: 'did:ex:1234',\n   * type: 'Ed25519VerificationKey2020',\n   * publicKeyMultibase,\n   * privateKeyMultibase\n   * });\n   *\n   * @returns {Promise<Ed25519VerificationKey2020>} An Ed25519 Key Pair.\n   */\n  static async from(options) {\n    if(options.type === 'Ed25519VerificationKey2018') {\n      return Ed25519VerificationKey2020.fromEd25519VerificationKey2018(options);\n    }\n    if(options.type === 'JsonWebKey2020') {\n      return Ed25519VerificationKey2020.fromJsonWebKey2020(options);\n    }\n    return new Ed25519VerificationKey2020(options);\n  }\n\n  /**\n   * Instance creation method for backwards compatibility with the\n   * `Ed25519VerificationKey2018` key suite.\n   *\n   * @see https://github.com/digitalbazaar/ed25519-verification-key-2018\n   * @typedef {object} Ed25519VerificationKey2018\n   * @param {Ed25519VerificationKey2018} keyPair - Ed25519 2018 suite key pair.\n   *\n   * @returns {Ed25519VerificationKey2020} - 2020 suite instance.\n   */\n  static fromEd25519VerificationKey2018({keyPair} = {}) {\n    const publicKeyMultibase = _encodeMbKey(\n      MULTICODEC_ED25519_PUB_HEADER, base58btc.decode(keyPair.publicKeyBase58));\n    const keyPair2020 = new Ed25519VerificationKey2020({\n      id: keyPair.id,\n      controller: keyPair.controller,\n      publicKeyMultibase\n    });\n\n    if(keyPair.privateKeyBase58) {\n      keyPair2020.privateKeyMultibase = _encodeMbKey(\n        MULTICODEC_ED25519_PRIV_HEADER,\n        base58btc.decode(keyPair.privateKeyBase58));\n    }\n\n    return keyPair2020;\n  }\n\n  /**\n   * Creates a key pair instance (public key only) from a JsonWebKey2020\n   * object.\n   *\n   * @see https://w3c-ccg.github.io/lds-jws2020/#json-web-key-2020\n   *\n   * @param {object} options - Options hashmap.\n   * @param {string} options.id - Key id.\n   * @param {string} options.type - Key suite type.\n   * @param {string} options.controller - Key controller.\n   * @param {object} options.publicKeyJwk - JWK object.\n   *\n   * @returns {Promise<Ed25519VerificationKey2020>} Resolves with key pair.\n   */\n  static fromJsonWebKey2020({id, type, controller, publicKeyJwk} = {}) {\n    if(type !== 'JsonWebKey2020') {\n      throw new TypeError(`Invalid key type: \"${type}\".`);\n    }\n    if(!publicKeyJwk) {\n      throw new TypeError('\"publicKeyJwk\" property is required.');\n    }\n    const {kty, crv} = publicKeyJwk;\n    if(kty !== 'OKP') {\n      throw new TypeError('\"kty\" is required to be \"OKP\".');\n    }\n    if(crv !== 'Ed25519') {\n      throw new TypeError('\"crv\" is required to be \"Ed25519\".');\n    }\n    const {x: publicKeyBase64Url} = publicKeyJwk;\n    const publicKeyMultibase = _encodeMbKey(\n      MULTICODEC_ED25519_PUB_HEADER,\n      base64url.decode(publicKeyBase64Url));\n\n    return Ed25519VerificationKey2020.from({\n      id, controller, publicKeyMultibase\n    });\n  }\n\n  /**\n   * Generates a KeyPair with an optional deterministic seed.\n   *\n   * @param {object} [options={}] - Options hashmap.\n   * @param {Uint8Array} [options.seed] - A 32-byte array seed for a\n   *   deterministic key.\n   *\n   * @returns {Promise<Ed25519VerificationKey2020>} Resolves with generated\n   *   public/private key pair.\n   */\n  static async generate({seed, ...keyPairOptions} = {}) {\n    let keyObject;\n    if(seed) {\n      keyObject = await ed25519.generateKeyPairFromSeed(seed);\n    } else {\n      keyObject = await ed25519.generateKeyPair();\n    }\n    const publicKeyMultibase =\n      _encodeMbKey(MULTICODEC_ED25519_PUB_HEADER, keyObject.publicKey);\n\n    const privateKeyMultibase =\n      _encodeMbKey(MULTICODEC_ED25519_PRIV_HEADER, keyObject.secretKey);\n\n    return new Ed25519VerificationKey2020({\n      publicKeyMultibase,\n      privateKeyMultibase,\n      ...keyPairOptions\n    });\n  }\n\n  /**\n   * Creates an instance of Ed25519VerificationKey2020 from a key fingerprint.\n   *\n   * @param {object} options - Options hashmap.\n   * @param {string} options.fingerprint - Multibase encoded key fingerprint.\n   *\n   * @returns {Ed25519VerificationKey2020} Returns key pair instance (with\n   *   public key only).\n   */\n  static fromFingerprint({fingerprint} = {}) {\n    return new Ed25519VerificationKey2020({publicKeyMultibase: fingerprint});\n  }\n\n  /**\n   * @returns {Uint8Array} Public key bytes.\n   */\n  get _publicKeyBuffer() {\n    if(!this.publicKeyMultibase) {\n      return;\n    }\n    // remove multibase header\n    const publicKeyMulticodec =\n      base58btc.decode(this.publicKeyMultibase.substr(1));\n    // remove multicodec header\n    const publicKeyBytes =\n      publicKeyMulticodec.slice(MULTICODEC_ED25519_PUB_HEADER.length);\n\n    return publicKeyBytes;\n  }\n\n  /**\n   * @returns {Uint8Array} Private key bytes.\n   */\n  get _privateKeyBuffer() {\n    if(!this.privateKeyMultibase) {\n      return;\n    }\n    // remove multibase header\n    const privateKeyMulticodec =\n      base58btc.decode(this.privateKeyMultibase.substr(1));\n    // remove multicodec header\n    const privateKeyBytes =\n      privateKeyMulticodec.slice(MULTICODEC_ED25519_PRIV_HEADER.length);\n\n    return privateKeyBytes;\n  }\n\n  /**\n   * Generates and returns a multiformats encoded\n   * ed25519 public key fingerprint (for use with cryptonyms, for example).\n   *\n   * @see https://github.com/multiformats/multicodec\n   *\n   * @returns {string} The fingerprint.\n   */\n  fingerprint() {\n    return this.publicKeyMultibase;\n  }\n\n  /**\n   * Exports the serialized representation of the KeyPair\n   * and other information that JSON-LD Signatures can use to form a proof.\n   *\n   * @param {object} [options={}] - Options hashmap.\n   * @param {boolean} [options.publicKey] - Export public key material?\n   * @param {boolean} [options.privateKey] - Export private key material?\n   * @param {boolean} [options.includeContext] - Include JSON-LD context?\n   *\n   * @returns {object} A plain js object that's ready for serialization\n   *   (to JSON, etc), for use in DIDs, Linked Data Proofs, etc.\n   */\n  export({publicKey = false, privateKey = false, includeContext = false} = {}) {\n    if(!(publicKey || privateKey)) {\n      throw new TypeError(\n        'Export requires specifying either \"publicKey\" or \"privateKey\".');\n    }\n    const exportedKey = {\n      id: this.id,\n      type: this.type\n    };\n    if(includeContext) {\n      exportedKey['@context'] = Ed25519VerificationKey2020.SUITE_CONTEXT;\n    }\n    if(this.controller) {\n      exportedKey.controller = this.controller;\n    }\n    if(publicKey) {\n      exportedKey.publicKeyMultibase = this.publicKeyMultibase;\n    }\n    if(privateKey) {\n      exportedKey.privateKeyMultibase = this.privateKeyMultibase;\n    }\n    if(this.revoked) {\n      exportedKey.revoked = this.revoked;\n    }\n    return exportedKey;\n  }\n\n  /**\n   * Returns the JWK representation of this key pair.\n   *\n   * @see https://datatracker.ietf.org/doc/html/rfc8037\n   *\n   * @param {object} [options={}] - Options hashmap.\n   * @param {boolean} [options.publicKey] - Include public key?\n   * @param {boolean} [options.privateKey] - Include private key?\n   *\n   * @returns {{kty: string, crv: string, x: string, d: string}} JWK\n   *   representation.\n   */\n  toJwk({publicKey = true, privateKey = false} = {}) {\n    if(!(publicKey || privateKey)) {\n      throw TypeError('Either a \"publicKey\" or a \"privateKey\" is required.');\n    }\n    const jwk = {crv: 'Ed25519', kty: 'OKP'};\n    if(publicKey) {\n      jwk.x = base64url.encode(this._publicKeyBuffer);\n    }\n    if(privateKey) {\n      jwk.d = base64url.encode(this._privateKeyBuffer);\n    }\n    return jwk;\n  }\n\n  /**\n   * @see https://datatracker.ietf.org/doc/html/rfc8037#appendix-A.3\n   *\n   * @returns {Promise<string>} JWK Thumbprint.\n   */\n  async jwkThumbprint() {\n    const publicKey = base64url.encode(this._publicKeyBuffer);\n    const serialized = `{\"crv\":\"Ed25519\",\"kty\":\"OKP\",\"x\":\"${publicKey}\"}`;\n    const data = new TextEncoder().encode(serialized);\n    return base64url.encode(\n      new Uint8Array(await ed25519.sha256digest({data})));\n  }\n\n  /**\n   * Returns the JsonWebKey2020 representation of this key pair.\n   *\n   * @see https://w3c-ccg.github.io/lds-jws2020/#json-web-key-2020\n   *\n   * @returns {Promise<object>} JsonWebKey2020 representation.\n   */\n  async toJsonWebKey2020() {\n    return {\n      '@context': 'https://w3id.org/security/jws/v1',\n      id: this.controller + '#' + await this.jwkThumbprint(),\n      type: 'JsonWebKey2020',\n      controller: this.controller,\n      publicKeyJwk: this.toJwk({publicKey: true})\n    };\n  }\n\n  /**\n   * Tests whether the fingerprint was generated from a given key pair.\n   *\n   * @example\n   * > edKeyPair.verifyFingerprint({fingerprint: 'z6Mk2S2Q...6MkaFJewa'});\n   * {valid: true};\n   *\n   * @param {object} options - Options hashmap.\n   * @param {string} options.fingerprint - A public key fingerprint.\n   *\n   * @returns {{valid: boolean, error: *}} Result of verification.\n   */\n  verifyFingerprint({fingerprint} = {}) {\n    // fingerprint should have multibase base58-btc header\n    if(!(typeof fingerprint === 'string' &&\n      fingerprint[0] === MULTIBASE_BASE58BTC_HEADER)) {\n      return {\n        error: new Error('\"fingerprint\" must be a multibase encoded string.'),\n        valid: false\n      };\n    }\n    let fingerprintBuffer;\n    try {\n      fingerprintBuffer = base58btc.decode(fingerprint.substr(1));\n      if(!fingerprintBuffer) {\n        throw new TypeError('Invalid encoding of fingerprint.');\n      }\n    } catch(e) {\n      return {error: e, valid: false};\n    }\n\n    const buffersEqual = _isEqualBuffer(this._publicKeyBuffer,\n      fingerprintBuffer.slice(2));\n\n    // validate the first two multicodec bytes\n    const valid =\n      fingerprintBuffer[0] === MULTICODEC_ED25519_PUB_HEADER[0] &&\n      fingerprintBuffer[1] === MULTICODEC_ED25519_PUB_HEADER[1] &&\n      buffersEqual;\n    if(!valid) {\n      return {\n        error: new Error('The fingerprint does not match the public key.'),\n        valid: false\n      };\n    }\n    return {valid};\n  }\n\n  signer() {\n    const privateKeyBuffer = this._privateKeyBuffer;\n\n    return {\n      async sign({data}) {\n        if(!privateKeyBuffer) {\n          throw new Error('A private key is not available for signing.');\n        }\n        return ed25519.sign(privateKeyBuffer, data);\n      },\n      id: this.id\n    };\n  }\n\n  verifier() {\n    const publicKeyBuffer = this._publicKeyBuffer;\n\n    return {\n      async verify({data, signature}) {\n        if(!publicKeyBuffer) {\n          throw new Error('A public key is not available for verifying.');\n        }\n        return ed25519.verify(publicKeyBuffer, data, signature);\n      },\n      id: this.id\n    };\n  }\n}\n// Used by CryptoLD harness for dispatching.\nEd25519VerificationKey2020.suite = SUITE_ID;\n// Used by CryptoLD harness's fromKeyId() method.\nEd25519VerificationKey2020.SUITE_CONTEXT =\n  'https://w3id.org/security/suites/ed25519-2020/v1';\n\n// check to ensure that two buffers are byte-for-byte equal\n// WARNING: this function must only be used to check public information as\n//          timing attacks can be used for non-constant time checks on\n//          secret information.\nfunction _isEqualBuffer(buf1, buf2) {\n  if(buf1.length !== buf2.length) {\n    return false;\n  }\n  for(let i = 0; i < buf1.length; i++) {\n    if(buf1[i] !== buf2[i]) {\n      return false;\n    }\n  }\n  return true;\n}\n\n// check a multibase key for an expected header\nfunction _isValidKeyHeader(multibaseKey, expectedHeader) {\n  if(!(typeof multibaseKey === 'string' &&\n    multibaseKey[0] === MULTIBASE_BASE58BTC_HEADER)) {\n    return false;\n  }\n\n  const keyBytes = base58btc.decode(multibaseKey.slice(1));\n  return expectedHeader.every((val, i) => keyBytes[i] === val);\n}\n\n// encode a multibase base58-btc multicodec key\nfunction _encodeMbKey(header, key) {\n  const mbKey = new Uint8Array(header.length + key.length);\n\n  mbKey.set(header);\n  mbKey.set(key, header.length);\n\n  return MULTIBASE_BASE58BTC_HEADER + base58btc.encode(mbKey);\n}\n","/*!\n * Copyright (c) 2020-2022 Digital Bazaar, Inc. All rights reserved.\n */\nimport {assertKeyBytes} from './validators.js';\nimport * as ed25519 from '@noble/ed25519';\n\n// browser MUST provide \"crypto.getRandomValues\"\nconst crypto = globalThis.crypto;\nif(!crypto.getRandomValues) {\n  throw new Error('Browser does not provide \"crypto.getRandomValues\".');\n}\n\nexport default {\n  async generateKeyPair() {\n    const seed = new Uint8Array(32);\n    crypto.getRandomValues(seed);\n    const keyPair = await generateKeyPairFromSeed(seed);\n    seed.fill(0);\n    return keyPair;\n  },\n  generateKeyPairFromSeed,\n  async sign(secretKey, data) {\n    return ed25519.sign(data, secretKey.slice(0, 32));\n  },\n  async verify(publicKey, data, signature) {\n    return ed25519.verify(signature, data, publicKey);\n  },\n  async sha256digest({data}) {\n    return crypto.subtle.digest('SHA-256', data);\n  }\n};\n\nasync function generateKeyPairFromSeed(seed) {\n  assertKeyBytes({\n    bytes: seed,\n    expectedLength: 32,\n  });\n  const publicKey = await ed25519.getPublicKey(seed);\n  const secretKey = new Uint8Array(64);\n  secretKey.set(seed);\n  secretKey.set(publicKey, seed.length);\n  return {\n    publicKey,\n    secretKey\n  };\n}\n","/*!\n * Copyright (c) 2020 Digital Bazaar, Inc. All rights reserved.\n */\nexport {Ed25519VerificationKey2020} from './Ed25519VerificationKey2020.js';\n","/*!\n * Copyright (c) 2022 Digital Bazaar, Inc. All rights reserved.\n */\n\n/**\n * Asserts that key bytes have a type of Uint8Array and a specific length.\n *\n * @throws {TypeError|SyntaxError} - Throws a Type or Syntax error.\n *\n * @param {object} options - Options to use.\n * @param {Uint8Array} options.bytes - The bytes being checked.\n * @param {number} [options.expectedLength=32] - The expected bytes length.\n * @param {string} [options.code] - An optional code for the error.\n *\n * @returns {undefined} Returns on success throws on error.\n */\nexport function assertKeyBytes({bytes, expectedLength = 32, code}) {\n  if(!(bytes instanceof Uint8Array)) {\n    throw new TypeError('\"bytes\" must be a Uint8Array.');\n  }\n  if(bytes.length !== expectedLength) {\n    const error = new Error(\n      `\"bytes\" must be a ${expectedLength}-byte Uint8Array.`);\n    // we need DataError for invalid byte length\n    error.name = 'DataError';\n    // add the error code from the did:key spec if provided\n    if(code) {\n      error.code = code;\n    }\n    throw error;\n  }\n}\n","/*!\n * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.\n */\nimport jsonld from 'jsonld';\n\nexport function canonize(input, options) {\n  return jsonld.canonize(input, {\n    algorithm: 'URDNA2015',\n    format: 'application/n-quads',\n    ...options\n  });\n}\n","/*!\n * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.\n */\nimport * as Ed25519Multikey from '@digitalbazaar/ed25519-multikey';\n\nexport async function createVerifier({verificationMethod}) {\n  const key = await Ed25519Multikey.from(verificationMethod);\n  const verifier = key.verifier();\n  return verifier;\n}\n","/*!\n * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.\n*/\nimport {canonize} from './canonize.js';\nimport {createVerifier} from './createVerifier.js';\nimport {name} from './name.js';\nimport {requiredAlgorithm} from './requiredAlgorithm.js';\n\nexport const cryptosuite = {\n  canonize,\n  createVerifier,\n  name,\n  requiredAlgorithm,\n};\n","/*!\n * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.\n */\nexport const name = 'eddsa-rdfc-2022';\n","/*!\n * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.\n */\nexport const requiredAlgorithm = 'Ed25519';\n","/*!\n * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.\n */\nimport jsonld from 'jsonld';\nimport jsigs from 'jsonld-signatures';\n\nconst {purposes: {AssertionProofPurpose}} = jsigs;\n\n/**\n * Creates a proof purpose that will validate whether or not the verification\n * method in a proof was authorized by its declared controller for the\n * proof's purpose.\n */\nexport class CredentialIssuancePurpose extends AssertionProofPurpose {\n  /**\n   * @param {object} options - The options to use.\n   * @param {object} [options.controller] - The description of the controller,\n   *   if it is not to be dereferenced via a `documentLoader`.\n   * @param {string|Date|number} [options.date] - The expected date for\n   *   the creation of the proof.\n   * @param {number} [options.maxTimestampDelta=Infinity] - A maximum number\n   *   of seconds that the date on the signature can deviate from.\n   */\n  constructor({controller, date, maxTimestampDelta} = {}) {\n    super({controller, date, maxTimestampDelta});\n  }\n\n  /**\n   * Validates the purpose of a proof. This method is called during\n   * proof verification, after the proof value has been checked against the\n   * given verification method (in the case of a digital signature, the\n   * signature has been cryptographically verified against the public key).\n   *\n   * @param {object} proof - The proof to validate.\n   * @param {object} options - The options to use.\n   * @param {object} options.document - The document whose signature is\n   *   being verified.\n   * @param {object} options.suite - Signature suite used in\n   *   the proof.\n   * @param {string} options.verificationMethod - Key id URL to the paired\n   *   public key.\n   * @param {object} [options.documentLoader] - A document loader.\n   * @param {object} [options.expansionMap] - An expansion map.\n   *\n   * @throws {Error} If verification method not authorized by controller.\n   * @throws {Error} If proof's created timestamp is out of range.\n   *\n   * @returns {Promise<{valid: boolean, error: Error}>} Resolves on completion.\n   */\n  async validate(proof, {\n    document, suite, verificationMethod, documentLoader, expansionMap\n  }) {\n    try {\n      const result = await super.validate(proof, {\n        document, suite, verificationMethod, documentLoader, expansionMap\n      });\n\n      if(!result.valid) {\n        throw result.error;\n      }\n\n      const issuer = jsonld.getValues(document, 'issuer');\n\n      if(!issuer || issuer.length === 0) {\n        throw new Error('Credential issuer is required.');\n      }\n\n      const issuerId = typeof issuer[0] === 'string' ? issuer[0] : issuer[0].id;\n\n      if(result.controller.id !== issuerId) {\n        throw new Error(\n          'Credential issuer must match the verification method controller.');\n      }\n\n      return {valid: true};\n    } catch(error) {\n      return {valid: false, error};\n    }\n  }\n}\n","/*!\n * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.\n */\nimport {\n  contexts as credential1Contexts\n} from 'credentials-context';\nimport {\n  contexts as credential2Contexts\n} from '@digitalbazaar/credentials-v2-context';\nimport {\n  CONTEXT as vcExamplesV1Context,\n  CONTEXT_URL as vcExamplesV1ContextUrl\n} from './vc-examples-v1.js';\nimport {\n  CONTEXT as odrlContext,\n  CONTEXT_URL as odrlContextUrl\n} from './odrl.js';\n\nexport const contexts = {};\n\ncontexts[vcExamplesV1ContextUrl] = vcExamplesV1Context;\ncontexts[odrlContextUrl] = odrlContext;\n\nfor(const [url, context] of credential1Contexts.entries()) {\n  contexts[url] = context;\n}\n\nfor(const [url, context] of credential2Contexts.entries()) {\n  contexts[url] = context;\n}\n","/*!\n * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.\n */\n\nexport const CONTEXT_URL = 'https://www.w3.org/ns/odrl.jsonld';\n/* eslint-disable quote-props, key-spacing, max-len */\nexport const CONTEXT = {\n  '@context': {\n    'odrl':    'http://www.w3.org/ns/odrl/2/',\n    'rdf':     'http://www.w3.org/1999/02/22-rdf-syntax-ns#',\n    'rdfs':    'http://www.w3.org/2000/01/rdf-schema#',\n    'owl':     'http://www.w3.org/2002/07/owl#',\n    'skos':    'http://www.w3.org/2004/02/skos/core#',\n    'dct':     'http://purl.org/dc/terms/',\n    'xsd':     'http://www.w3.org/2001/XMLSchema#',\n    'vcard':   'http://www.w3.org/2006/vcard/ns#',\n    'foaf':    'http://xmlns.com/foaf/0.1/',\n    'schema':  'http://schema.org/',\n    'cc':      'http://creativecommons.org/ns#',\n\n    'uid':     '@id',\n    'type':    '@type',\n\n    'Policy':           'odrl:Policy',\n    'Rule':             'odrl:Rule',\n    'profile':          {'@type': '@id', '@id': 'odrl:profile'},\n\n    'inheritFrom':      {'@type': '@id', '@id': 'odrl:inheritFrom'},\n\n    'ConflictTerm':     'odrl:ConflictTerm',\n    'conflict':         {'@type': '@vocab', '@id': 'odrl:conflict'},\n    'perm':             'odrl:perm',\n    'prohibit':         'odrl:prohibit',\n    'invalid':          'odrl:invalid',\n\n    'Agreement':           'odrl:Agreement',\n    'Assertion':           'odrl:Assertion',\n    'Offer':               'odrl:Offer',\n    'Privacy':             'odrl:Privacy',\n    'Request':             'odrl:Request',\n    'Set':                 'odrl:Set',\n    'Ticket':              'odrl:Ticket',\n\n    'Asset':               'odrl:Asset',\n    'AssetCollection':     'odrl:AssetCollection',\n    'relation':            {'@type': '@id', '@id': 'odrl:relation'},\n    'hasPolicy':           {'@type': '@id', '@id': 'odrl:hasPolicy'},\n\n    'target':             {'@type': '@id', '@id': 'odrl:target'},\n    'output':             {'@type': '@id', '@id': 'odrl:output'},\n\n    'partOf':            {'@type': '@id', '@id': 'odrl:partOf'},\n    'source':            {'@type': '@id', '@id': 'odrl:source'},\n\n    'Party':              'odrl:Party',\n    'PartyCollection':    'odrl:PartyCollection',\n    'function':           {'@type': '@vocab', '@id': 'odrl:function'},\n    'PartyScope':         'odrl:PartyScope',\n\n    'assignee':             {'@type': '@id', '@id': 'odrl:assignee'},\n    'assigner':             {'@type': '@id', '@id': 'odrl:assigner'},\n    'assigneeOf':           {'@type': '@id', '@id': 'odrl:assigneeOf'},\n    'assignerOf':           {'@type': '@id', '@id': 'odrl:assignerOf'},\n    'attributedParty':      {'@type': '@id', '@id': 'odrl:attributedParty'},\n    'attributingParty':     {'@type': '@id', '@id': 'odrl:attributingParty'},\n    'compensatedParty':     {'@type': '@id', '@id': 'odrl:compensatedParty'},\n    'compensatingParty':    {'@type': '@id', '@id': 'odrl:compensatingParty'},\n    'consentingParty':      {'@type': '@id', '@id': 'odrl:consentingParty'},\n    'consentedParty':       {'@type': '@id', '@id': 'odrl:consentedParty'},\n    'informedParty':        {'@type': '@id', '@id': 'odrl:informedParty'},\n    'informingParty':       {'@type': '@id', '@id': 'odrl:informingParty'},\n    'trackingParty':        {'@type': '@id', '@id': 'odrl:trackingParty'},\n    'trackedParty':         {'@type': '@id', '@id': 'odrl:trackedParty'},\n    'contractingParty':     {'@type': '@id', '@id': 'odrl:contractingParty'},\n    'contractedParty':      {'@type': '@id', '@id': 'odrl:contractedParty'},\n\n    'Action':                'odrl:Action',\n    'action':                {'@type': '@vocab', '@id': 'odrl:action'},\n    'includedIn':            {'@type': '@id', '@id': 'odrl:includedIn'},\n    'implies':               {'@type': '@id', '@id': 'odrl:implies'},\n\n    'Permission':            'odrl:Permission',\n    'permission':            {'@type': '@id', '@id': 'odrl:permission'},\n\n    'Prohibition':           'odrl:Prohibition',\n    'prohibition':           {'@type': '@id', '@id': 'odrl:prohibition'},\n\n    'obligation':            {'@type': '@id', '@id': 'odrl:obligation'},\n\n    'use':                   'odrl:use',\n    'grantUse':              'odrl:grantUse',\n    'aggregate':             'odrl:aggregate',\n    'annotate':              'odrl:annotate',\n    'anonymize':             'odrl:anonymize',\n    'archive':               'odrl:archive',\n    'concurrentUse':         'odrl:concurrentUse',\n    'derive':                'odrl:derive',\n    'digitize':              'odrl:digitize',\n    'display':               'odrl:display',\n    'distribute':            'odrl:distribute',\n    'execute':               'odrl:execute',\n    'extract':               'odrl:extract',\n    'give':                  'odrl:give',\n    'index':                 'odrl:index',\n    'install':               'odrl:install',\n    'modify':                'odrl:modify',\n    'move':                  'odrl:move',\n    'play':                  'odrl:play',\n    'present':               'odrl:present',\n    'print':                 'odrl:print',\n    'read':                  'odrl:read',\n    'reproduce':             'odrl:reproduce',\n    'sell':                  'odrl:sell',\n    'stream':                'odrl:stream',\n    'textToSpeech':          'odrl:textToSpeech',\n    'transfer':              'odrl:transfer',\n    'transform':             'odrl:transform',\n    'translate':             'odrl:translate',\n\n    'Duty':                 'odrl:Duty',\n    'duty':                 {'@type': '@id', '@id': 'odrl:duty'},\n    'consequence':          {'@type': '@id', '@id': 'odrl:consequence'},\n    'remedy':               {'@type': '@id', '@id': 'odrl:remedy'},\n\n    'acceptTracking':       'odrl:acceptTracking',\n    'attribute':            'odrl:attribute',\n    'compensate':           'odrl:compensate',\n    'delete':               'odrl:delete',\n    'ensureExclusivity':    'odrl:ensureExclusivity',\n    'include':              'odrl:include',\n    'inform':               'odrl:inform',\n    'nextPolicy':           'odrl:nextPolicy',\n    'obtainConsent':        'odrl:obtainConsent',\n    'reviewPolicy':         'odrl:reviewPolicy',\n    'uninstall':            'odrl:uninstall',\n    'watermark':            'odrl:watermark',\n\n    'Constraint':           'odrl:Constraint',\n    'LogicalConstraint':    'odrl:LogicalConstraint',\n    'constraint':           {'@type': '@id', '@id': 'odrl:constraint'},\n    'refinement':           {'@type': '@id', '@id': 'odrl:refinement'},\n    'Operator':             'odrl:Operator',\n    'operator':             {'@type': '@vocab', '@id': 'odrl:operator'},\n    'RightOperand':         'odrl:RightOperand',\n    'rightOperand':         'odrl:rightOperand',\n    'rightOperandReference':{'@type': 'xsd:anyURI', '@id': 'odrl:rightOperandReference'},\n    'LeftOperand':          'odrl:LeftOperand',\n    'leftOperand':          {'@type': '@vocab', '@id': 'odrl:leftOperand'},\n    'unit':                 'odrl:unit',\n    'dataType':             {'@type': 'xsd:anyType', '@id': 'odrl:datatype'},\n    'status':               'odrl:status',\n\n    'absolutePosition':        'odrl:absolutePosition',\n    'absoluteSpatialPosition': 'odrl:absoluteSpatialPosition',\n    'absoluteTemporalPosition':'odrl:absoluteTemporalPosition',\n    'absoluteSize':            'odrl:absoluteSize',\n    'count':                   'odrl:count',\n    'dateTime':                'odrl:dateTime',\n    'delayPeriod':             'odrl:delayPeriod',\n    'deliveryChannel':         'odrl:deliveryChannel',\n    'elapsedTime':             'odrl:elapsedTime',\n    'event':                   'odrl:event',\n    'fileFormat':              'odrl:fileFormat',\n    'industry':                'odrl:industry:',\n    'language':                'odrl:language',\n    'media':                   'odrl:media',\n    'meteredTime':             'odrl:meteredTime',\n    'payAmount':               'odrl:payAmount',\n    'percentage':              'odrl:percentage',\n    'product':                 'odrl:product',\n    'purpose':                 'odrl:purpose',\n    'recipient':               'odrl:recipient',\n    'relativePosition':        'odrl:relativePosition',\n    'relativeSpatialPosition': 'odrl:relativeSpatialPosition',\n    'relativeTemporalPosition':'odrl:relativeTemporalPosition',\n    'relativeSize':            'odrl:relativeSize',\n    'resolution':              'odrl:resolution',\n    'spatial':                 'odrl:spatial',\n    'spatialCoordinates':      'odrl:spatialCoordinates',\n    'systemDevice':            'odrl:systemDevice',\n    'timeInterval':            'odrl:timeInterval',\n    'unitOfCount':             'odrl:unitOfCount',\n    'version':                 'odrl:version',\n    'virtualLocation':         'odrl:virtualLocation',\n\n    'eq':                   'odrl:eq',\n    'gt':                   'odrl:gt',\n    'gteq':                 'odrl:gteq',\n    'lt':                   'odrl:lt',\n    'lteq':                 'odrl:lteq',\n    'neq':                  'odrl:neg',\n    'isA':                  'odrl:isA',\n    'hasPart':              'odrl:hasPart',\n    'isPartOf':             'odrl:isPartOf',\n    'isAllOf':              'odrl:isAllOf',\n    'isAnyOf':              'odrl:isAnyOf',\n    'isNoneOf':             'odrl:isNoneOf',\n    'or':                   'odrl:or',\n    'xone':                 'odrl:xone',\n    'and':                  'odrl:and',\n    'andSequence':          'odrl:andSequence',\n\n    'policyUsage':                'odrl:policyUsage'\n\n  }\n};\n","/*!\n * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.\n */\n\nexport const CONTEXT_URL = 'https://www.w3.org/2018/credentials/examples/v1';\n/* eslint-disable quote-props */\nexport const CONTEXT = {\n  '@context': [\n    {\n      '@version': 1.1\n    },\n    'https://www.w3.org/ns/odrl.jsonld',\n    {\n      'ex': 'https://example.org/examples#',\n      'schema': 'http://schema.org/',\n      'rdf': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',\n\n      '3rdPartyCorrelation': 'ex:3rdPartyCorrelation',\n      'AllVerifiers': 'ex:AllVerifiers',\n      'AlumniCredential': 'ex:AlumniCredential',\n      'Archival': 'ex:Archival',\n      'BachelorDegree': 'ex:BachelorDegree',\n      'Child': 'ex:Child',\n      'CLCredentialDefinition2019': 'ex:CLCredentialDefinition2019',\n      'CLSignature2019': 'ex:CLSignature2019',\n      'DisputeCredential': 'ex:DisputeCredential',\n      'IssuerPolicy': 'ex:IssuerPolicy',\n      'HolderPolicy': 'ex:HolderPolicy',\n      'Mother': 'ex:Mother',\n      'PrescriptionCredential': 'ex:PrescriptionCredential',\n      'RelationshipCredential': 'ex:RelationshipCredential',\n      'UniversityDegreeCredential': 'ex:UniversityDegreeCredential',\n      'ZkpExampleSchema2018': 'ex:ZkpExampleSchema2018',\n\n      'alumniOf': {'@id': 'schema:alumniOf', '@type': 'rdf:HTML'},\n      'attributes': 'ex:attributes',\n      'child': {'@id': 'ex:child', '@type': '@id'},\n      'college': 'ex:college',\n      'currentStatus': 'ex:currentStatus',\n      'degree': 'ex:degree',\n      'degreeSchool': 'ex:degreeSchool',\n      'degreeType': 'ex:degreeType',\n      'familyName': 'schema:familyName',\n      'givenName': 'schema:givenName',\n      'issuerData': 'ex:issuerData',\n      'name': {'@id': 'schema:name', '@type': 'rdf:HTML'},\n      'nonRevocationProof': 'ex:nonRevocationProof',\n      'parent': {'@id': 'ex:parent', '@type': '@id'},\n      'prescription': 'ex:prescription',\n      'primaryProof': 'ex:primaryProof',\n      'referenceId': 'ex:referenceId',\n      'documentPresence': 'ex:documentPresence',\n      'evidenceDocument': 'ex:evidenceDocument',\n      'signature': 'ex:signature',\n      'signatureCorrectnessProof': 'ex:signatureCorrectnessProof',\n      'spouse': 'schema:spouse',\n      'statusReason': 'ex:statusReason',\n      'subjectPresence': 'ex:subjectPresence',\n      'verifier': {'@id': 'ex:verifier', '@type': '@id'},\n    }\n  ]\n};\n","/*!\n * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.\n */\n// load locally embedded contexts\nimport {contexts} from './contexts/index.js';\n\nexport async function documentLoader(url) {\n  const context = contexts[url];\n  if(context !== undefined) {\n    return {\n      contextUrl: null,\n      documentUrl: url,\n      document: context\n    };\n  }\n  throw new Error(`Document loader unable to load URL \"${url}\".`);\n}\n","/**\n * A JavaScript implementation of Verifiable Credentials.\n *\n * @author Dave Longley\n * @author David I. Lehn\n *\n * @license BSD 3-Clause License\n * Copyright (c) 2017-2022 Digital Bazaar, Inc.\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * Redistributions of source code must retain the above copyright notice,\n * this list of conditions and the following disclaimer.\n *\n * Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and/or other materials provided with the distribution.\n *\n * Neither the name of the Digital Bazaar, Inc. nor the names of its\n * contributors may be used to endorse or promote products derived from\n * this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS\n * IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED\n * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A\n * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\n * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\nimport jsonld from 'jsonld';\nimport jsigs from 'jsonld-signatures';\nimport {CredentialIssuancePurpose} from './CredentialIssuancePurpose.js';\nimport {documentLoader as _documentLoader} from './documentLoader.js';\nexport const defaultDocumentLoader =\n  jsigs.extendContextLoader(_documentLoader);\nimport * as credentials1Context from 'credentials-context';\nimport * as credentials2Context from '@digitalbazaar/credentials-v2-context';\n\nconst {AuthenticationProofPurpose} = jsigs.purposes;\nconst {constants: {CREDENTIALS_CONTEXT_V1_URL}} = credentials1Context;\nconst CREDENTIALS_CONTEXT_V2_URL = credentials2Context.CONTEXT_URL;\n\nexport {CredentialIssuancePurpose};\n\n// Z and T can be lowercase\n// RFC3339 regex\nexport const dateRegex = new RegExp('^(\\\\d{4})-(0[1-9]|1[0-2])-' +\n    '(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):' +\n    '([0-5][0-9]):([0-5][0-9]|60)' +\n    '(\\\\.[0-9]+)?(Z|(\\\\+|-)([01][0-9]|2[0-3]):' +\n    '([0-5][0-9]))$', 'i');\n\n/**\n * @typedef {object} LinkedDataSignature\n */\n\n/**\n * @typedef {object} Presentation\n */\n\n/**\n * @typedef {object} ProofPurpose\n */\n\n/**\n * @typedef {object} VerifiableCredential\n */\n\n/**\n * @typedef {object} VerifiablePresentation\n */\n\n/**\n * @typedef {object} VerifyPresentationResult\n * @property {boolean} verified - True if verified, false if not.\n * @property {object} presentationResult\n * @property {Array} credentialResults\n * @property {object} error\n */\n\n/**\n * @typedef {object} VerifyCredentialResult\n * @property {boolean} verified - True if verified, false if not.\n * @property {object} statusResult\n * @property {Array} results\n * @property {object} error\n */\n\n/**\n * Issues a verifiable credential (by taking a base credential document,\n * and adding a digital signature to it).\n *\n * @param {object} [options={}] - The options to use.\n *\n * @param {object} options.credential - Base credential document.\n * @param {LinkedDataSignature} options.suite - Signature suite (with private\n *   key material), passed in to sign().\n *\n * @param {ProofPurpose} [options.purpose] - A ProofPurpose. If not specified,\n *   a default purpose will be created.\n *\n * Other optional params passed to `sign()`:\n * @param {object} [options.documentLoader] - A document loader.\n * @param {object} [options.expansionMap] - An expansion map.\n * @param {string|Date} [options.now] - A string representing date time in\n *   ISO 8601 format or an instance of Date. Defaults to current date time.\n *\n * @throws {Error} If missing required properties.\n *\n * @returns {Promise<VerifiableCredential>} Resolves on completion.\n */\nexport async function issue({\n  credential, suite, expansionMap,\n  purpose = new CredentialIssuancePurpose(),\n  documentLoader = defaultDocumentLoader,\n  now\n} = {}) {\n  // check to make sure the `suite` has required params\n  // Note: verificationMethod defaults to publicKey.id, in suite constructor\n  if(!suite) {\n    throw new TypeError('\"suite\" parameter is required for issuing.');\n  }\n  if(!suite.verificationMethod) {\n    throw new TypeError('\"suite.verificationMethod\" property is required.');\n  }\n\n  if(!credential) {\n    throw new TypeError('\"credential\" parameter is required for issuing.');\n  }\n\n  // Set the issuance date to now(), if missing\n  if((credential['@context'][0] === CREDENTIALS_CONTEXT_V1_URL) &&\n    !credential.issuanceDate) {\n    const now = (new Date()).toJSON();\n    credential.issuanceDate = `${now.substr(0, now.length - 5)}Z`;\n  } else if((credential['@context'][0] === CREDENTIALS_CONTEXT_V2_URL) &&\n    !credential.validFrom) {\n    const now = (new Date()).toJSON();\n    credential.validFrom = `${now.substr(0, now.length - 5)}Z`;\n  }\n\n  // run common credential checks\n  _checkCredential({credential, now});\n\n  return jsigs.sign(credential, {purpose, documentLoader, suite, expansionMap});\n}\n\n/**\n * Verifies a verifiable presentation:\n *   - Checks that the presentation is well-formed\n *   - Checks the proofs (for example, checks digital signatures against the\n *     provided public keys).\n *\n * @param {object} [options={}] - The options to use.\n *\n * @param {VerifiablePresentation} options.presentation - Verifiable\n *   presentation, signed or unsigned, that may contain within it a\n *   verifiable credential.\n *\n * @param {LinkedDataSignature|LinkedDataSignature[]} options.suite - One or\n *   more signature suites that are supported by the caller's use case. This is\n *   an explicit design decision -- the calling code must specify which\n *   signature types (ed25519, RSA, etc) are allowed.\n *   Although it is expected that the secure resolution/fetching of the public\n *   key material (to verify against) is to be handled by the documentLoader,\n *   the suite param can optionally include the key directly.\n *\n * @param {boolean} [options.unsignedPresentation=false] - By default, this\n *   function assumes that a presentation is signed (and will return an error if\n *   a `proof` section is missing). Set this to `true` if you're using an\n *   unsigned presentation.\n *\n * Either pass in a proof purpose,\n * @param {AuthenticationProofPurpose} [options.presentationPurpose] - Optional\n *   proof purpose (a default one will be created if not passed in).\n *\n * or a default purpose will be created with params:\n * @param {string} [options.challenge] - Required if purpose is not passed in.\n * @param {string} [options.controller] - A controller.\n * @param {string} [options.domain] - A domain.\n *\n * @param {Function} [options.documentLoader] - A document loader.\n * @param {Function} [options.checkStatus] - Optional function for checking\n *   credential status if `credentialStatus` is present on the credential.\n * @param {string|Date} [options.now] - A string representing date time in\n *   ISO 8601 format or an instance of Date. Defaults to current date time.\n *\n * @returns {Promise<VerifyPresentationResult>} The verification result.\n */\nexport async function verify(options = {}) {\n  const {presentation} = options;\n  try {\n    if(!presentation) {\n      throw new TypeError(\n        'A \"presentation\" property is required for verifying.');\n    }\n    return _verifyPresentation(options);\n  } catch(error) {\n    return {\n      verified: false,\n      results: [{presentation, verified: false, error}],\n      error\n    };\n  }\n}\n\n/**\n * Verifies a verifiable credential:\n *   - Checks that the credential is well-formed\n *   - Checks the proofs (for example, checks digital signatures against the\n *     provided public keys).\n *\n * @param {object} [options={}] - The options.\n *\n * @param {object} options.credential - Verifiable credential.\n *\n * @param {LinkedDataSignature|LinkedDataSignature[]} options.suite - One or\n *   more signature suites that are supported by the caller's use case. This is\n *   an explicit design decision -- the calling code must specify which\n *   signature types (ed25519, RSA, etc) are allowed.\n *   Although it is expected that the secure resolution/fetching of the public\n *   key material (to verify against) is to be handled by the documentLoader,\n *   the suite param can optionally include the key directly.\n *\n * @param {CredentialIssuancePurpose} [options.purpose] - Optional\n *   proof purpose (a default one will be created if not passed in).\n * @param {Function} [options.documentLoader] - A document loader.\n * @param {Function} [options.checkStatus] - Optional function for checking\n *   credential status if `credentialStatus` is present on the credential.\n * @param {string|Date} [options.now] - A string representing date time in\n *   ISO 8601 format or an instance of Date. Defaults to current date time.\n *\n * @returns {Promise<VerifyCredentialResult>} The verification result.\n */\nexport async function verifyCredential(options = {}) {\n  const {credential} = options;\n  try {\n    if(!credential) {\n      throw new TypeError(\n        'A \"credential\" property is required for verifying.');\n    }\n    return await _verifyCredential(options);\n  } catch(error) {\n    return {\n      verified: false,\n      results: [{credential, verified: false, error}],\n      error\n    };\n  }\n}\n\n/**\n * Verifies a verifiable credential.\n *\n * @private\n * @param {object} [options={}] - The options.\n *\n * @param {object} options.credential - Verifiable credential.\n * @param {LinkedDataSignature|LinkedDataSignature[]} options.suite - See the\n *   definition in the `verify()` docstring, for this param.\n * @param {string|Date} [options.now] - A string representing date time in\n *   ISO 8601 format or an instance of Date. Defaults to current date time.\n *\n * @throws {Error} If required parameters are missing (in `_checkCredential`).\n *\n * @param {CredentialIssuancePurpose} [options.purpose] - A purpose.\n * @param {Function} [options.documentLoader] - A document loader.\n * @param {Function} [options.checkStatus] - Optional function for checking\n *   credential status if `credentialStatus` is present on the credential.\n *\n * @returns {Promise<VerifyCredentialResult>} The verification result.\n */\nasync function _verifyCredential(options = {}) {\n  const {credential, checkStatus, now} = options;\n\n  // run common credential checks\n  _checkCredential({credential, now});\n\n  // if credential status is provided, a `checkStatus` function must be given\n  if(credential.credentialStatus && typeof options.checkStatus !== 'function') {\n    throw new TypeError(\n      'A \"checkStatus\" function must be given to verify credentials with ' +\n      '\"credentialStatus\".');\n  }\n\n  const documentLoader = options.documentLoader || defaultDocumentLoader;\n\n  const {controller} = options;\n  const purpose = options.purpose || new CredentialIssuancePurpose({\n    controller\n  });\n\n  const result = await jsigs.verify(\n    credential, {purpose, documentLoader, ...options});\n\n  // if verification has already failed, skip status check\n  if(!result.verified) {\n    return result;\n  }\n\n  if(credential.credentialStatus) {\n    result.statusResult = await checkStatus(options);\n    if(!result.statusResult.verified) {\n      result.verified = false;\n    }\n  }\n\n  return result;\n}\n\n/**\n * Creates an unsigned presentation from a given verifiable credential.\n *\n * @param {object} options - Options to use.\n * @param {object|Array<object>} [options.verifiableCredential] - One or more\n *   verifiable credential.\n * @param {string} [options.id] - Optional VP id.\n * @param {string} [options.holder] - Optional presentation holder url.\n * @param {string|Date} [options.now] - A string representing date time in\n *   ISO 8601 format or an instance of Date. Defaults to current date time.\n *\n * @throws {TypeError} If verifiableCredential param is missing.\n * @throws {Error} If the credential (or the presentation params) are missing\n *   required properties.\n *\n * @returns {Presentation} The credential wrapped inside of a\n *   VerifiablePresentation.\n */\nexport function createPresentation({\n  verifiableCredential, id, holder, now\n} = {}) {\n  const presentation = {\n    '@context': [CREDENTIALS_CONTEXT_V1_URL],\n    type: ['VerifiablePresentation']\n  };\n  if(verifiableCredential) {\n    const credentials = [].concat(verifiableCredential);\n    // ensure all credentials are valid\n    for(const credential of credentials) {\n      _checkCredential({credential, now});\n    }\n    presentation.verifiableCredential = credentials;\n  }\n  if(id) {\n    presentation.id = id;\n  }\n  if(holder) {\n    presentation.holder = holder;\n  }\n\n  _checkPresentation(presentation);\n\n  return presentation;\n}\n\n/**\n * Signs a given presentation.\n *\n * @param {object} [options={}] - Options to use.\n *\n * Required:\n * @param {Presentation} options.presentation - A presentation.\n * @param {LinkedDataSignature} options.suite - passed in to sign()\n *\n * Either pass in a ProofPurpose, or a default one will be created with params:\n * @param {ProofPurpose} [options.purpose] - A ProofPurpose. If not specified,\n *   a default purpose will be created with the domain and challenge options.\n *\n * @param {string} [options.domain] - A domain.\n * @param {string} options.challenge - A required challenge.\n *\n * @param {Function} [options.documentLoader] - A document loader.\n *\n * @returns {Promise<{VerifiablePresentation}>} A VerifiablePresentation with\n *   a proof.\n */\nexport async function signPresentation(options = {}) {\n  const {presentation, domain, challenge} = options;\n  const purpose = options.purpose || new AuthenticationProofPurpose({\n    domain,\n    challenge\n  });\n\n  const documentLoader = options.documentLoader || defaultDocumentLoader;\n\n  return jsigs.sign(presentation, {purpose, documentLoader, ...options});\n}\n\n/**\n * Verifies that the VerifiablePresentation is well formed, and checks the\n * proof signature if it's present. Also verifies all the VerifiableCredentials\n * that are present in the presentation, if any.\n *\n * @param {object} [options={}] - The options.\n * @param {VerifiablePresentation} options.presentation - A\n *   VerifiablePresentation.\n *\n * @param {LinkedDataSignature|LinkedDataSignature[]} options.suite - See the\n *   definition in the `verify()` docstring, for this param.\n *\n * @param {boolean} [options.unsignedPresentation=false] - By default, this\n *   function assumes that a presentation is signed (and will return an error if\n *   a `proof` section is missing). Set this to `true` if you're using an\n *   unsigned presentation.\n *\n * Either pass in a proof purpose,\n * @param {AuthenticationProofPurpose} [options.presentationPurpose] - A\n *   ProofPurpose. If not specified, a default purpose will be created with\n *   the challenge, controller, and domain options.\n *\n * @param {string} [options.challenge] - A challenge. Required if purpose is\n *   not passed in.\n * @param {string} [options.controller] - A controller. Required if purpose is\n *   not passed in.\n * @param {string} [options.domain] - A domain. Required if purpose is not\n *   passed in.\n *\n * @param {Function} [options.documentLoader] - A document loader.\n * @param {Function} [options.checkStatus] - Optional function for checking\n *   credential status if `credentialStatus` is present on the credential.\n * @param {string|Date} [options.now] - A string representing date time in\n *   ISO 8601 format or an instance of Date. Defaults to current date time.\n *\n * @throws {Error} If presentation is missing required params.\n *\n * @returns {Promise<VerifyPresentationResult>} The verification result.\n */\nasync function _verifyPresentation(options = {}) {\n  const {presentation, unsignedPresentation} = options;\n\n  _checkPresentation(presentation);\n\n  const documentLoader = options.documentLoader || defaultDocumentLoader;\n\n  // FIXME: verify presentation first, then each individual credential\n  // only if that proof is verified\n\n  // if verifiableCredentials are present, verify them, individually\n  let credentialResults;\n  let verified = true;\n  const credentials = jsonld.getValues(presentation, 'verifiableCredential');\n  if(credentials.length > 0) {\n    // verify every credential in `verifiableCredential`\n    credentialResults = await Promise.all(credentials.map(credential => {\n      return verifyCredential({credential, documentLoader, ...options});\n    }));\n\n    for(const [i, credentialResult] of credentialResults.entries()) {\n      credentialResult.credentialId = credentials[i].id;\n    }\n\n    const allCredentialsVerified = credentialResults.every(r => r.verified);\n    if(!allCredentialsVerified) {\n      verified = false;\n    }\n  }\n\n  if(unsignedPresentation) {\n    // No need to verify the proof section of this presentation\n    return {verified, results: [presentation], credentialResults};\n  }\n\n  const {controller, domain, challenge} = options;\n  if(!options.presentationPurpose && !challenge) {\n    throw new Error(\n      'A \"challenge\" param is required for AuthenticationProofPurpose.');\n  }\n\n  const purpose = options.presentationPurpose ||\n    new AuthenticationProofPurpose({controller, domain, challenge});\n\n  const presentationResult = await jsigs.verify(\n    presentation, {purpose, documentLoader, ...options});\n\n  return {\n    presentationResult,\n    verified: verified && presentationResult.verified,\n    credentialResults,\n    error: presentationResult.error\n  };\n}\n\n/**\n * @param {string|object} obj - Either an object with an id property\n *   or a string that is an id.\n * @returns {string|undefined} Either an id or undefined.\n * @private\n *\n */\nfunction _getId(obj) {\n  if(typeof obj === 'string') {\n    return obj;\n  }\n\n  if(!('id' in obj)) {\n    return;\n  }\n\n  return obj.id;\n}\n\n// export for testing\n/**\n * @param {object} presentation - An object that could be a presentation.\n *\n * @throws {Error}\n * @private\n */\nexport function _checkPresentation(presentation) {\n  // normalize to an array to allow the common case of context being a string\n  const context = Array.isArray(presentation['@context']) ?\n    presentation['@context'] : [presentation['@context']];\n\n  // ensure first context is 'https://www.w3.org/2018/credentials/v1'\n  if((context[0] !== CREDENTIALS_CONTEXT_V1_URL) &&\n    (context[0] !== CREDENTIALS_CONTEXT_V2_URL)) {\n    throw new Error(\n      `\"${CREDENTIALS_CONTEXT_V1_URL}\" or ${CREDENTIALS_CONTEXT_V2_URL} ` +\n      'needs to be first in the list of contexts.');\n  }\n\n  const types = jsonld.getValues(presentation, 'type');\n\n  // check type presence\n  if(!types.includes('VerifiablePresentation')) {\n    throw new Error('\"type\" must include \"VerifiablePresentation\".');\n  }\n}\n\n// export for testing\n/**\n * @param {object} options - The options.\n * @param {object} options.credential - An object that could be a\n *   VerifiableCredential.\n * @param {string|Date} [options.now] - A string representing date time in\n *   ISO 8601 format or an instance of Date. Defaults to current date time.\n *\n * @throws {Error}\n * @private\n */\nexport function _checkCredential({credential, now = new Date()}) {\n  if(typeof now === 'string') {\n    now = new Date(now);\n  }\n  // ensure first context is 'https://www.w3.org/2018/credentials/v1'\n  if((credential['@context'][0] !== CREDENTIALS_CONTEXT_V1_URL) &&\n    (credential['@context'][0] !== CREDENTIALS_CONTEXT_V2_URL)) {\n    throw new Error(\n      `\"${CREDENTIALS_CONTEXT_V1_URL}\" or \"${CREDENTIALS_CONTEXT_V2_URL}\" ` +\n      'needs to be first in the list of contexts.');\n  }\n\n  // check type presence and cardinality\n  if(!credential.type) {\n    throw new Error('\"type\" property is required.');\n  }\n\n  if(!jsonld.getValues(credential, 'type').includes('VerifiableCredential')) {\n    throw new Error('\"type\" must include `VerifiableCredential`.');\n  }\n\n  if(!credential.credentialSubject) {\n    throw new Error('\"credentialSubject\" property is required.');\n  }\n\n  // If credentialSubject.id is present and is not a URI, reject it\n  if(credential.credentialSubject.id) {\n    _validateUriId({\n      id: credential.credentialSubject.id, propertyName: 'credentialSubject.id'\n    });\n  }\n\n  if(!credential.issuer) {\n    throw new Error('\"issuer\" property is required.');\n  }\n\n  // ensure first context is 'https://www.w3.org/2018/credentials/v1'\n  if(credential['@context'][0] === CREDENTIALS_CONTEXT_V1_URL) {\n    // check issuanceDate cardinality\n    if(jsonld.getValues(credential, 'issuanceDate').length > 1) {\n      throw new Error('\"issuanceDate\" property can only have one value.');\n    }\n\n    // check issued is a date\n    if(!credential.issuanceDate) {\n      throw new Error('\"issuanceDate\" property is required.');\n    }\n\n    if('issuanceDate' in credential) {\n      let {issuanceDate} = credential;\n      if(!dateRegex.test(issuanceDate)) {\n        throw new Error(`\"issuanceDate\" must be a valid date: ${issuanceDate}`);\n      }\n      // check if `now` is before `issuanceDate`\n      issuanceDate = new Date(issuanceDate);\n      if(now < issuanceDate) {\n        throw new Error(\n          `The current date time (${now.toISOString()}) is before the ` +\n          `\"issuanceDate\" (${issuanceDate.toISOString()}).`);\n      }\n    }\n  } else if(credential['@context'][0] === CREDENTIALS_CONTEXT_V2_URL) {\n    // check validFrom cardinality\n    if(jsonld.getValues(credential, 'validFrom').length > 1) {\n      throw new Error('\"validFrom\" property can only have one value.');\n    }\n\n    // check issued is a date\n    if(!credential.validFrom) {\n      throw new Error('\"validFrom\" property is required.');\n    }\n\n    if('validFrom' in credential) {\n      let {validFrom} = credential;\n      if(!dateRegex.test(validFrom)) {\n        throw new Error(`\"validFrom\" must be a valid date: ${validFrom}`);\n      }\n      // check if `now` is before `validFrom`\n      validFrom = new Date(validFrom);\n      if(now < validFrom) {\n        throw new Error(\n          `The current date time (${now.toISOString()}) is before the ` +\n          `\"validFrom\" (${validFrom.toISOString()}).`);\n      }\n    }\n  }\n\n  // check issuer cardinality\n  if(jsonld.getValues(credential, 'issuer').length > 1) {\n    throw new Error('\"issuer\" property can only have one value.');\n  }\n\n  // check issuer is a URL\n  if('issuer' in credential) {\n    const issuer = _getId(credential.issuer);\n    if(!issuer) {\n      throw new Error(`\"issuer\" id is required.`);\n    }\n    _validateUriId({id: issuer, propertyName: 'issuer'});\n  }\n\n  if('credentialStatus' in credential) {\n    if(!credential.credentialStatus.id) {\n      throw new Error('\"credentialStatus\" must include an id.');\n    }\n    if(!credential.credentialStatus.type) {\n      throw new Error('\"credentialStatus\" must include a type.');\n    }\n  }\n\n  // check evidences are URLs\n  jsonld.getValues(credential, 'evidence').forEach(evidence => {\n    const evidenceId = _getId(evidence);\n    if(evidenceId) {\n      _validateUriId({id: evidenceId, propertyName: 'evidence'});\n    }\n  });\n\n  if('expirationDate' in credential) {\n    const {expirationDate} = credential;\n    // check if `expirationDate` property is a date\n    if(!dateRegex.test(expirationDate)) {\n      throw new Error(\n        `\"expirationDate\" must be a valid date: ${expirationDate}`);\n    }\n    // check if `now` is after `expirationDate`\n    if(now > new Date(expirationDate)) {\n      throw new Error('Credential has expired.');\n    }\n  }\n}\n\nfunction _validateUriId({id, propertyName}) {\n  let parsed;\n  try {\n    parsed = new URL(id);\n  } catch(e) {\n    const error = new TypeError(`\"${propertyName}\" must be a URI: \"${id}\".`);\n    error.cause = e;\n    throw error;\n  }\n\n  if(!parsed.protocol) {\n    throw new TypeError(`\"${propertyName}\" must be a URI: \"${id}\".`);\n  }\n}\n","/*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) */\nimport * as nodeCrypto from 'crypto';\nconst _0n = BigInt(0);\nconst _1n = BigInt(1);\nconst _2n = BigInt(2);\nconst _8n = BigInt(8);\nconst CU_O = BigInt('7237005577332262213973186563042994240857116359379907606001950938285454250989');\nconst CURVE = Object.freeze({\n    a: BigInt(-1),\n    d: BigInt('37095705934669439343138083508754565189542113879843219016388785533085940283555'),\n    P: BigInt('57896044618658097711785492504343953926634992332820282019728792003956564819949'),\n    l: CU_O,\n    n: CU_O,\n    h: BigInt(8),\n    Gx: BigInt('15112221349535400772501151409588531511454012693041857206046113283949847762202'),\n    Gy: BigInt('46316835694926478169428394003475163141307993866256225615783033603165251855960'),\n});\nexport { CURVE };\nconst POW_2_256 = BigInt('0x10000000000000000000000000000000000000000000000000000000000000000');\nconst SQRT_M1 = BigInt('19681161376707505956807079304988542015446066515923890162744021073123829784752');\nconst SQRT_D = BigInt('6853475219497561581579357271197624642482790079785650197046958215289687604742');\nconst SQRT_AD_MINUS_ONE = BigInt('25063068953384623474111414158702152701244531502492656460079210482610430750235');\nconst INVSQRT_A_MINUS_D = BigInt('54469307008909316920995813868745141605393597292927456921205312896311721017578');\nconst ONE_MINUS_D_SQ = BigInt('1159843021668779879193775521855586647937357759715417654439879720876111806838');\nconst D_MINUS_ONE_SQ = BigInt('40440834346308536858101042469323190826248399146238708352240133220865137265952');\nclass ExtendedPoint {\n    constructor(x, y, z, t) {\n        this.x = x;\n        this.y = y;\n        this.z = z;\n        this.t = t;\n    }\n    static fromAffine(p) {\n        if (!(p instanceof Point)) {\n            throw new TypeError('ExtendedPoint#fromAffine: expected Point');\n        }\n        if (p.equals(Point.ZERO))\n            return ExtendedPoint.ZERO;\n        return new ExtendedPoint(p.x, p.y, _1n, mod(p.x * p.y));\n    }\n    static toAffineBatch(points) {\n        const toInv = invertBatch(points.map((p) => p.z));\n        return points.map((p, i) => p.toAffine(toInv[i]));\n    }\n    static normalizeZ(points) {\n        return this.toAffineBatch(points).map(this.fromAffine);\n    }\n    equals(other) {\n        assertExtPoint(other);\n        const { x: X1, y: Y1, z: Z1 } = this;\n        const { x: X2, y: Y2, z: Z2 } = other;\n        const X1Z2 = mod(X1 * Z2);\n        const X2Z1 = mod(X2 * Z1);\n        const Y1Z2 = mod(Y1 * Z2);\n        const Y2Z1 = mod(Y2 * Z1);\n        return X1Z2 === X2Z1 && Y1Z2 === Y2Z1;\n    }\n    negate() {\n        return new ExtendedPoint(mod(-this.x), this.y, this.z, mod(-this.t));\n    }\n    double() {\n        const { x: X1, y: Y1, z: Z1 } = this;\n        const { a } = CURVE;\n        const A = mod(X1 * X1);\n        const B = mod(Y1 * Y1);\n        const C = mod(_2n * mod(Z1 * Z1));\n        const D = mod(a * A);\n        const x1y1 = X1 + Y1;\n        const E = mod(mod(x1y1 * x1y1) - A - B);\n        const G = D + B;\n        const F = G - C;\n        const H = D - B;\n        const X3 = mod(E * F);\n        const Y3 = mod(G * H);\n        const T3 = mod(E * H);\n        const Z3 = mod(F * G);\n        return new ExtendedPoint(X3, Y3, Z3, T3);\n    }\n    add(other) {\n        assertExtPoint(other);\n        const { x: X1, y: Y1, z: Z1, t: T1 } = this;\n        const { x: X2, y: Y2, z: Z2, t: T2 } = other;\n        const A = mod((Y1 - X1) * (Y2 + X2));\n        const B = mod((Y1 + X1) * (Y2 - X2));\n        const F = mod(B - A);\n        if (F === _0n)\n            return this.double();\n        const C = mod(Z1 * _2n * T2);\n        const D = mod(T1 * _2n * Z2);\n        const E = D + C;\n        const G = B + A;\n        const H = D - C;\n        const X3 = mod(E * F);\n        const Y3 = mod(G * H);\n        const T3 = mod(E * H);\n        const Z3 = mod(F * G);\n        return new ExtendedPoint(X3, Y3, Z3, T3);\n    }\n    subtract(other) {\n        return this.add(other.negate());\n    }\n    precomputeWindow(W) {\n        const windows = 1 + 256 / W;\n        const points = [];\n        let p = this;\n        let base = p;\n        for (let window = 0; window < windows; window++) {\n            base = p;\n            points.push(base);\n            for (let i = 1; i < 2 ** (W - 1); i++) {\n                base = base.add(p);\n                points.push(base);\n            }\n            p = base.double();\n        }\n        return points;\n    }\n    wNAF(n, affinePoint) {\n        if (!affinePoint && this.equals(ExtendedPoint.BASE))\n            affinePoint = Point.BASE;\n        const W = (affinePoint && affinePoint._WINDOW_SIZE) || 1;\n        if (256 % W) {\n            throw new Error('Point#wNAF: Invalid precomputation window, must be power of 2');\n        }\n        let precomputes = affinePoint && pointPrecomputes.get(affinePoint);\n        if (!precomputes) {\n            precomputes = this.precomputeWindow(W);\n            if (affinePoint && W !== 1) {\n                precomputes = ExtendedPoint.normalizeZ(precomputes);\n                pointPrecomputes.set(affinePoint, precomputes);\n            }\n        }\n        let p = ExtendedPoint.ZERO;\n        let f = ExtendedPoint.BASE;\n        const windows = 1 + 256 / W;\n        const windowSize = 2 ** (W - 1);\n        const mask = BigInt(2 ** W - 1);\n        const maxNumber = 2 ** W;\n        const shiftBy = BigInt(W);\n        for (let window = 0; window < windows; window++) {\n            const offset = window * windowSize;\n            let wbits = Number(n & mask);\n            n >>= shiftBy;\n            if (wbits > windowSize) {\n                wbits -= maxNumber;\n                n += _1n;\n            }\n            const offset1 = offset;\n            const offset2 = offset + Math.abs(wbits) - 1;\n            const cond1 = window % 2 !== 0;\n            const cond2 = wbits < 0;\n            if (wbits === 0) {\n                f = f.add(constTimeNegate(cond1, precomputes[offset1]));\n            }\n            else {\n                p = p.add(constTimeNegate(cond2, precomputes[offset2]));\n            }\n        }\n        return ExtendedPoint.normalizeZ([p, f])[0];\n    }\n    multiply(scalar, affinePoint) {\n        return this.wNAF(normalizeScalar(scalar, CURVE.l), affinePoint);\n    }\n    multiplyUnsafe(scalar) {\n        let n = normalizeScalar(scalar, CURVE.l, false);\n        const G = ExtendedPoint.BASE;\n        const P0 = ExtendedPoint.ZERO;\n        if (n === _0n)\n            return P0;\n        if (this.equals(P0) || n === _1n)\n            return this;\n        if (this.equals(G))\n            return this.wNAF(n);\n        let p = P0;\n        let d = this;\n        while (n > _0n) {\n            if (n & _1n)\n                p = p.add(d);\n            d = d.double();\n            n >>= _1n;\n        }\n        return p;\n    }\n    isSmallOrder() {\n        return this.multiplyUnsafe(CURVE.h).equals(ExtendedPoint.ZERO);\n    }\n    isTorsionFree() {\n        let p = this.multiplyUnsafe(CURVE.l / _2n).double();\n        if (CURVE.l % _2n)\n            p = p.add(this);\n        return p.equals(ExtendedPoint.ZERO);\n    }\n    toAffine(invZ) {\n        const { x, y, z } = this;\n        const is0 = this.equals(ExtendedPoint.ZERO);\n        if (invZ == null)\n            invZ = is0 ? _8n : invert(z);\n        const ax = mod(x * invZ);\n        const ay = mod(y * invZ);\n        const zz = mod(z * invZ);\n        if (is0)\n            return Point.ZERO;\n        if (zz !== _1n)\n            throw new Error('invZ was invalid');\n        return new Point(ax, ay);\n    }\n    fromRistrettoBytes() {\n        legacyRist();\n    }\n    toRistrettoBytes() {\n        legacyRist();\n    }\n    fromRistrettoHash() {\n        legacyRist();\n    }\n}\nExtendedPoint.BASE = new ExtendedPoint(CURVE.Gx, CURVE.Gy, _1n, mod(CURVE.Gx * CURVE.Gy));\nExtendedPoint.ZERO = new ExtendedPoint(_0n, _1n, _1n, _0n);\nfunction constTimeNegate(condition, item) {\n    const neg = item.negate();\n    return condition ? neg : item;\n}\nfunction assertExtPoint(other) {\n    if (!(other instanceof ExtendedPoint))\n        throw new TypeError('ExtendedPoint expected');\n}\nfunction assertRstPoint(other) {\n    if (!(other instanceof RistrettoPoint))\n        throw new TypeError('RistrettoPoint expected');\n}\nfunction legacyRist() {\n    throw new Error('Legacy method: switch to RistrettoPoint');\n}\nclass RistrettoPoint {\n    constructor(ep) {\n        this.ep = ep;\n    }\n    static calcElligatorRistrettoMap(r0) {\n        const { d } = CURVE;\n        const r = mod(SQRT_M1 * r0 * r0);\n        const Ns = mod((r + _1n) * ONE_MINUS_D_SQ);\n        let c = BigInt(-1);\n        const D = mod((c - d * r) * mod(r + d));\n        let { isValid: Ns_D_is_sq, value: s } = uvRatio(Ns, D);\n        let s_ = mod(s * r0);\n        if (!edIsNegative(s_))\n            s_ = mod(-s_);\n        if (!Ns_D_is_sq)\n            s = s_;\n        if (!Ns_D_is_sq)\n            c = r;\n        const Nt = mod(c * (r - _1n) * D_MINUS_ONE_SQ - D);\n        const s2 = s * s;\n        const W0 = mod((s + s) * D);\n        const W1 = mod(Nt * SQRT_AD_MINUS_ONE);\n        const W2 = mod(_1n - s2);\n        const W3 = mod(_1n + s2);\n        return new ExtendedPoint(mod(W0 * W3), mod(W2 * W1), mod(W1 * W3), mod(W0 * W2));\n    }\n    static hashToCurve(hex) {\n        hex = ensureBytes(hex, 64);\n        const r1 = bytes255ToNumberLE(hex.slice(0, 32));\n        const R1 = this.calcElligatorRistrettoMap(r1);\n        const r2 = bytes255ToNumberLE(hex.slice(32, 64));\n        const R2 = this.calcElligatorRistrettoMap(r2);\n        return new RistrettoPoint(R1.add(R2));\n    }\n    static fromHex(hex) {\n        hex = ensureBytes(hex, 32);\n        const { a, d } = CURVE;\n        const emsg = 'RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint';\n        const s = bytes255ToNumberLE(hex);\n        if (!equalBytes(numberTo32BytesLE(s), hex) || edIsNegative(s))\n            throw new Error(emsg);\n        const s2 = mod(s * s);\n        const u1 = mod(_1n + a * s2);\n        const u2 = mod(_1n - a * s2);\n        const u1_2 = mod(u1 * u1);\n        const u2_2 = mod(u2 * u2);\n        const v = mod(a * d * u1_2 - u2_2);\n        const { isValid, value: I } = invertSqrt(mod(v * u2_2));\n        const Dx = mod(I * u2);\n        const Dy = mod(I * Dx * v);\n        let x = mod((s + s) * Dx);\n        if (edIsNegative(x))\n            x = mod(-x);\n        const y = mod(u1 * Dy);\n        const t = mod(x * y);\n        if (!isValid || edIsNegative(t) || y === _0n)\n            throw new Error(emsg);\n        return new RistrettoPoint(new ExtendedPoint(x, y, _1n, t));\n    }\n    toRawBytes() {\n        let { x, y, z, t } = this.ep;\n        const u1 = mod(mod(z + y) * mod(z - y));\n        const u2 = mod(x * y);\n        const u2sq = mod(u2 * u2);\n        const { value: invsqrt } = invertSqrt(mod(u1 * u2sq));\n        const D1 = mod(invsqrt * u1);\n        const D2 = mod(invsqrt * u2);\n        const zInv = mod(D1 * D2 * t);\n        let D;\n        if (edIsNegative(t * zInv)) {\n            let _x = mod(y * SQRT_M1);\n            let _y = mod(x * SQRT_M1);\n            x = _x;\n            y = _y;\n            D = mod(D1 * INVSQRT_A_MINUS_D);\n        }\n        else {\n            D = D2;\n        }\n        if (edIsNegative(x * zInv))\n            y = mod(-y);\n        let s = mod((z - y) * D);\n        if (edIsNegative(s))\n            s = mod(-s);\n        return numberTo32BytesLE(s);\n    }\n    toHex() {\n        return bytesToHex(this.toRawBytes());\n    }\n    toString() {\n        return this.toHex();\n    }\n    equals(other) {\n        assertRstPoint(other);\n        const a = this.ep;\n        const b = other.ep;\n        const one = mod(a.x * b.y) === mod(a.y * b.x);\n        const two = mod(a.y * b.y) === mod(a.x * b.x);\n        return one || two;\n    }\n    add(other) {\n        assertRstPoint(other);\n        return new RistrettoPoint(this.ep.add(other.ep));\n    }\n    subtract(other) {\n        assertRstPoint(other);\n        return new RistrettoPoint(this.ep.subtract(other.ep));\n    }\n    multiply(scalar) {\n        return new RistrettoPoint(this.ep.multiply(scalar));\n    }\n    multiplyUnsafe(scalar) {\n        return new RistrettoPoint(this.ep.multiplyUnsafe(scalar));\n    }\n}\nRistrettoPoint.BASE = new RistrettoPoint(ExtendedPoint.BASE);\nRistrettoPoint.ZERO = new RistrettoPoint(ExtendedPoint.ZERO);\nconst pointPrecomputes = new WeakMap();\nclass Point {\n    constructor(x, y) {\n        this.x = x;\n        this.y = y;\n    }\n    _setWindowSize(windowSize) {\n        this._WINDOW_SIZE = windowSize;\n        pointPrecomputes.delete(this);\n    }\n    static fromHex(hex, strict = true) {\n        const { d, P } = CURVE;\n        hex = ensureBytes(hex, 32);\n        const normed = hex.slice();\n        normed[31] = hex[31] & ~0x80;\n        const y = bytesToNumberLE(normed);\n        if (strict && y >= P)\n            throw new Error('Expected 0 < hex < P');\n        if (!strict && y >= POW_2_256)\n            throw new Error('Expected 0 < hex < 2**256');\n        const y2 = mod(y * y);\n        const u = mod(y2 - _1n);\n        const v = mod(d * y2 + _1n);\n        let { isValid, value: x } = uvRatio(u, v);\n        if (!isValid)\n            throw new Error('Point.fromHex: invalid y coordinate');\n        const isXOdd = (x & _1n) === _1n;\n        const isLastByteOdd = (hex[31] & 0x80) !== 0;\n        if (isLastByteOdd !== isXOdd) {\n            x = mod(-x);\n        }\n        return new Point(x, y);\n    }\n    static async fromPrivateKey(privateKey) {\n        return (await getExtendedPublicKey(privateKey)).point;\n    }\n    toRawBytes() {\n        const bytes = numberTo32BytesLE(this.y);\n        bytes[31] |= this.x & _1n ? 0x80 : 0;\n        return bytes;\n    }\n    toHex() {\n        return bytesToHex(this.toRawBytes());\n    }\n    toX25519() {\n        const { y } = this;\n        const u = mod((_1n + y) * invert(_1n - y));\n        return numberTo32BytesLE(u);\n    }\n    isTorsionFree() {\n        return ExtendedPoint.fromAffine(this).isTorsionFree();\n    }\n    equals(other) {\n        return this.x === other.x && this.y === other.y;\n    }\n    negate() {\n        return new Point(mod(-this.x), this.y);\n    }\n    add(other) {\n        return ExtendedPoint.fromAffine(this).add(ExtendedPoint.fromAffine(other)).toAffine();\n    }\n    subtract(other) {\n        return this.add(other.negate());\n    }\n    multiply(scalar) {\n        return ExtendedPoint.fromAffine(this).multiply(scalar, this).toAffine();\n    }\n}\nPoint.BASE = new Point(CURVE.Gx, CURVE.Gy);\nPoint.ZERO = new Point(_0n, _1n);\nclass Signature {\n    constructor(r, s) {\n        this.r = r;\n        this.s = s;\n        this.assertValidity();\n    }\n    static fromHex(hex) {\n        const bytes = ensureBytes(hex, 64);\n        const r = Point.fromHex(bytes.slice(0, 32), false);\n        const s = bytesToNumberLE(bytes.slice(32, 64));\n        return new Signature(r, s);\n    }\n    assertValidity() {\n        const { r, s } = this;\n        if (!(r instanceof Point))\n            throw new Error('Expected Point instance');\n        normalizeScalar(s, CURVE.l, false);\n        return this;\n    }\n    toRawBytes() {\n        const u8 = new Uint8Array(64);\n        u8.set(this.r.toRawBytes());\n        u8.set(numberTo32BytesLE(this.s), 32);\n        return u8;\n    }\n    toHex() {\n        return bytesToHex(this.toRawBytes());\n    }\n}\nexport { ExtendedPoint, RistrettoPoint, Point, Signature };\nfunction concatBytes(...arrays) {\n    if (!arrays.every((a) => a instanceof Uint8Array))\n        throw new Error('Expected Uint8Array list');\n    if (arrays.length === 1)\n        return arrays[0];\n    const length = arrays.reduce((a, arr) => a + arr.length, 0);\n    const result = new Uint8Array(length);\n    for (let i = 0, pad = 0; i < arrays.length; i++) {\n        const arr = arrays[i];\n        result.set(arr, pad);\n        pad += arr.length;\n    }\n    return result;\n}\nconst hexes = Array.from({ length: 256 }, (v, i) => i.toString(16).padStart(2, '0'));\nfunction bytesToHex(uint8a) {\n    if (!(uint8a instanceof Uint8Array))\n        throw new Error('Uint8Array expected');\n    let hex = '';\n    for (let i = 0; i < uint8a.length; i++) {\n        hex += hexes[uint8a[i]];\n    }\n    return hex;\n}\nfunction hexToBytes(hex) {\n    if (typeof hex !== 'string') {\n        throw new TypeError('hexToBytes: expected string, got ' + typeof hex);\n    }\n    if (hex.length % 2)\n        throw new Error('hexToBytes: received invalid unpadded hex');\n    const array = new Uint8Array(hex.length / 2);\n    for (let i = 0; i < array.length; i++) {\n        const j = i * 2;\n        const hexByte = hex.slice(j, j + 2);\n        const byte = Number.parseInt(hexByte, 16);\n        if (Number.isNaN(byte) || byte < 0)\n            throw new Error('Invalid byte sequence');\n        array[i] = byte;\n    }\n    return array;\n}\nfunction numberTo32BytesBE(num) {\n    const length = 32;\n    const hex = num.toString(16).padStart(length * 2, '0');\n    return hexToBytes(hex);\n}\nfunction numberTo32BytesLE(num) {\n    return numberTo32BytesBE(num).reverse();\n}\nfunction edIsNegative(num) {\n    return (mod(num) & _1n) === _1n;\n}\nfunction bytesToNumberLE(uint8a) {\n    if (!(uint8a instanceof Uint8Array))\n        throw new Error('Expected Uint8Array');\n    return BigInt('0x' + bytesToHex(Uint8Array.from(uint8a).reverse()));\n}\nconst MAX_255B = BigInt('0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff');\nfunction bytes255ToNumberLE(bytes) {\n    return mod(bytesToNumberLE(bytes) & MAX_255B);\n}\nfunction mod(a, b = CURVE.P) {\n    const res = a % b;\n    return res >= _0n ? res : b + res;\n}\nfunction invert(number, modulo = CURVE.P) {\n    if (number === _0n || modulo <= _0n) {\n        throw new Error(`invert: expected positive integers, got n=${number} mod=${modulo}`);\n    }\n    let a = mod(number, modulo);\n    let b = modulo;\n    let x = _0n, y = _1n, u = _1n, v = _0n;\n    while (a !== _0n) {\n        const q = b / a;\n        const r = b % a;\n        const m = x - u * q;\n        const n = y - v * q;\n        b = a, a = r, x = u, y = v, u = m, v = n;\n    }\n    const gcd = b;\n    if (gcd !== _1n)\n        throw new Error('invert: does not exist');\n    return mod(x, modulo);\n}\nfunction invertBatch(nums, p = CURVE.P) {\n    const tmp = new Array(nums.length);\n    const lastMultiplied = nums.reduce((acc, num, i) => {\n        if (num === _0n)\n            return acc;\n        tmp[i] = acc;\n        return mod(acc * num, p);\n    }, _1n);\n    const inverted = invert(lastMultiplied, p);\n    nums.reduceRight((acc, num, i) => {\n        if (num === _0n)\n            return acc;\n        tmp[i] = mod(acc * tmp[i], p);\n        return mod(acc * num, p);\n    }, inverted);\n    return tmp;\n}\nfunction pow2(x, power) {\n    const { P } = CURVE;\n    let res = x;\n    while (power-- > _0n) {\n        res *= res;\n        res %= P;\n    }\n    return res;\n}\nfunction pow_2_252_3(x) {\n    const { P } = CURVE;\n    const _5n = BigInt(5);\n    const _10n = BigInt(10);\n    const _20n = BigInt(20);\n    const _40n = BigInt(40);\n    const _80n = BigInt(80);\n    const x2 = (x * x) % P;\n    const b2 = (x2 * x) % P;\n    const b4 = (pow2(b2, _2n) * b2) % P;\n    const b5 = (pow2(b4, _1n) * x) % P;\n    const b10 = (pow2(b5, _5n) * b5) % P;\n    const b20 = (pow2(b10, _10n) * b10) % P;\n    const b40 = (pow2(b20, _20n) * b20) % P;\n    const b80 = (pow2(b40, _40n) * b40) % P;\n    const b160 = (pow2(b80, _80n) * b80) % P;\n    const b240 = (pow2(b160, _80n) * b80) % P;\n    const b250 = (pow2(b240, _10n) * b10) % P;\n    const pow_p_5_8 = (pow2(b250, _2n) * x) % P;\n    return { pow_p_5_8, b2 };\n}\nfunction uvRatio(u, v) {\n    const v3 = mod(v * v * v);\n    const v7 = mod(v3 * v3 * v);\n    const pow = pow_2_252_3(u * v7).pow_p_5_8;\n    let x = mod(u * v3 * pow);\n    const vx2 = mod(v * x * x);\n    const root1 = x;\n    const root2 = mod(x * SQRT_M1);\n    const useRoot1 = vx2 === u;\n    const useRoot2 = vx2 === mod(-u);\n    const noRoot = vx2 === mod(-u * SQRT_M1);\n    if (useRoot1)\n        x = root1;\n    if (useRoot2 || noRoot)\n        x = root2;\n    if (edIsNegative(x))\n        x = mod(-x);\n    return { isValid: useRoot1 || useRoot2, value: x };\n}\nfunction invertSqrt(number) {\n    return uvRatio(_1n, number);\n}\nfunction modlLE(hash) {\n    return mod(bytesToNumberLE(hash), CURVE.l);\n}\nfunction equalBytes(b1, b2) {\n    if (b1.length !== b2.length) {\n        return false;\n    }\n    for (let i = 0; i < b1.length; i++) {\n        if (b1[i] !== b2[i]) {\n            return false;\n        }\n    }\n    return true;\n}\nfunction ensureBytes(hex, expectedLength) {\n    const bytes = hex instanceof Uint8Array ? Uint8Array.from(hex) : hexToBytes(hex);\n    if (typeof expectedLength === 'number' && bytes.length !== expectedLength)\n        throw new Error(`Expected ${expectedLength} bytes`);\n    return bytes;\n}\nfunction normalizeScalar(num, max, strict = true) {\n    if (!max)\n        throw new TypeError('Specify max value');\n    if (typeof num === 'number' && Number.isSafeInteger(num))\n        num = BigInt(num);\n    if (typeof num === 'bigint' && num < max) {\n        if (strict) {\n            if (_0n < num)\n                return num;\n        }\n        else {\n            if (_0n <= num)\n                return num;\n        }\n    }\n    throw new TypeError('Expected valid scalar: 0 < scalar < max');\n}\nfunction adjustBytes25519(bytes) {\n    bytes[0] &= 248;\n    bytes[31] &= 127;\n    bytes[31] |= 64;\n    return bytes;\n}\nfunction decodeScalar25519(n) {\n    return bytesToNumberLE(adjustBytes25519(ensureBytes(n, 32)));\n}\nfunction checkPrivateKey(key) {\n    key =\n        typeof key === 'bigint' || typeof key === 'number'\n            ? numberTo32BytesBE(normalizeScalar(key, POW_2_256))\n            : ensureBytes(key);\n    if (key.length !== 32)\n        throw new Error(`Expected 32 bytes`);\n    return key;\n}\nfunction getKeyFromHash(hashed) {\n    const head = adjustBytes25519(hashed.slice(0, 32));\n    const prefix = hashed.slice(32, 64);\n    const scalar = modlLE(head);\n    const point = Point.BASE.multiply(scalar);\n    const pointBytes = point.toRawBytes();\n    return { head, prefix, scalar, point, pointBytes };\n}\nlet _sha512Sync;\nfunction sha512s(...m) {\n    if (typeof _sha512Sync !== 'function')\n        throw new Error('utils.sha512Sync must be set to use sync methods');\n    return _sha512Sync(...m);\n}\nasync function getExtendedPublicKey(key) {\n    return getKeyFromHash(await utils.sha512(checkPrivateKey(key)));\n}\nfunction getExtendedPublicKeySync(key) {\n    return getKeyFromHash(sha512s(checkPrivateKey(key)));\n}\nexport async function getPublicKey(privateKey) {\n    return (await getExtendedPublicKey(privateKey)).pointBytes;\n}\nfunction getPublicKeySync(privateKey) {\n    return getExtendedPublicKeySync(privateKey).pointBytes;\n}\nexport async function sign(message, privateKey) {\n    message = ensureBytes(message);\n    const { prefix, scalar, pointBytes } = await getExtendedPublicKey(privateKey);\n    const r = modlLE(await utils.sha512(prefix, message));\n    const R = Point.BASE.multiply(r);\n    const k = modlLE(await utils.sha512(R.toRawBytes(), pointBytes, message));\n    const s = mod(r + k * scalar, CURVE.l);\n    return new Signature(R, s).toRawBytes();\n}\nfunction signSync(message, privateKey) {\n    message = ensureBytes(message);\n    const { prefix, scalar, pointBytes } = getExtendedPublicKeySync(privateKey);\n    const r = modlLE(sha512s(prefix, message));\n    const R = Point.BASE.multiply(r);\n    const k = modlLE(sha512s(R.toRawBytes(), pointBytes, message));\n    const s = mod(r + k * scalar, CURVE.l);\n    return new Signature(R, s).toRawBytes();\n}\nfunction prepareVerification(sig, message, publicKey) {\n    message = ensureBytes(message);\n    if (!(publicKey instanceof Point))\n        publicKey = Point.fromHex(publicKey, false);\n    const { r, s } = sig instanceof Signature ? sig.assertValidity() : Signature.fromHex(sig);\n    const SB = ExtendedPoint.BASE.multiplyUnsafe(s);\n    return { r, s, SB, pub: publicKey, msg: message };\n}\nfunction finishVerification(publicKey, r, SB, hashed) {\n    const k = modlLE(hashed);\n    const kA = ExtendedPoint.fromAffine(publicKey).multiplyUnsafe(k);\n    const RkA = ExtendedPoint.fromAffine(r).add(kA);\n    return RkA.subtract(SB).multiplyUnsafe(CURVE.h).equals(ExtendedPoint.ZERO);\n}\nexport async function verify(sig, message, publicKey) {\n    const { r, SB, msg, pub } = prepareVerification(sig, message, publicKey);\n    const hashed = await utils.sha512(r.toRawBytes(), pub.toRawBytes(), msg);\n    return finishVerification(pub, r, SB, hashed);\n}\nfunction verifySync(sig, message, publicKey) {\n    const { r, SB, msg, pub } = prepareVerification(sig, message, publicKey);\n    const hashed = sha512s(r.toRawBytes(), pub.toRawBytes(), msg);\n    return finishVerification(pub, r, SB, hashed);\n}\nexport const sync = {\n    getExtendedPublicKey: getExtendedPublicKeySync,\n    getPublicKey: getPublicKeySync,\n    sign: signSync,\n    verify: verifySync,\n};\nexport async function getSharedSecret(privateKey, publicKey) {\n    const { head } = await getExtendedPublicKey(privateKey);\n    const u = Point.fromHex(publicKey).toX25519();\n    return curve25519.scalarMult(head, u);\n}\nPoint.BASE._setWindowSize(8);\nfunction cswap(swap, x_2, x_3) {\n    const dummy = mod(swap * (x_2 - x_3));\n    x_2 = mod(x_2 - dummy);\n    x_3 = mod(x_3 + dummy);\n    return [x_2, x_3];\n}\nfunction montgomeryLadder(pointU, scalar) {\n    const { P } = CURVE;\n    const u = normalizeScalar(pointU, P);\n    const k = normalizeScalar(scalar, P);\n    const a24 = BigInt(121665);\n    const x_1 = u;\n    let x_2 = _1n;\n    let z_2 = _0n;\n    let x_3 = u;\n    let z_3 = _1n;\n    let swap = _0n;\n    let sw;\n    for (let t = BigInt(255 - 1); t >= _0n; t--) {\n        const k_t = (k >> t) & _1n;\n        swap ^= k_t;\n        sw = cswap(swap, x_2, x_3);\n        x_2 = sw[0];\n        x_3 = sw[1];\n        sw = cswap(swap, z_2, z_3);\n        z_2 = sw[0];\n        z_3 = sw[1];\n        swap = k_t;\n        const A = x_2 + z_2;\n        const AA = mod(A * A);\n        const B = x_2 - z_2;\n        const BB = mod(B * B);\n        const E = AA - BB;\n        const C = x_3 + z_3;\n        const D = x_3 - z_3;\n        const DA = mod(D * A);\n        const CB = mod(C * B);\n        const dacb = DA + CB;\n        const da_cb = DA - CB;\n        x_3 = mod(dacb * dacb);\n        z_3 = mod(x_1 * mod(da_cb * da_cb));\n        x_2 = mod(AA * BB);\n        z_2 = mod(E * (AA + mod(a24 * E)));\n    }\n    sw = cswap(swap, x_2, x_3);\n    x_2 = sw[0];\n    x_3 = sw[1];\n    sw = cswap(swap, z_2, z_3);\n    z_2 = sw[0];\n    z_3 = sw[1];\n    const { pow_p_5_8, b2 } = pow_2_252_3(z_2);\n    const xp2 = mod(pow2(pow_p_5_8, BigInt(3)) * b2);\n    return mod(x_2 * xp2);\n}\nfunction encodeUCoordinate(u) {\n    return numberTo32BytesLE(mod(u, CURVE.P));\n}\nfunction decodeUCoordinate(uEnc) {\n    const u = ensureBytes(uEnc, 32);\n    u[31] &= 127;\n    return bytesToNumberLE(u);\n}\nexport const curve25519 = {\n    BASE_POINT_U: '0900000000000000000000000000000000000000000000000000000000000000',\n    scalarMult(privateKey, publicKey) {\n        const u = decodeUCoordinate(publicKey);\n        const p = decodeScalar25519(privateKey);\n        const pu = montgomeryLadder(u, p);\n        if (pu === _0n)\n            throw new Error('Invalid private or public key received');\n        return encodeUCoordinate(pu);\n    },\n    scalarMultBase(privateKey) {\n        return curve25519.scalarMult(privateKey, curve25519.BASE_POINT_U);\n    },\n};\nconst crypto = {\n    node: nodeCrypto,\n    web: typeof self === 'object' && 'crypto' in self ? self.crypto : undefined,\n};\nexport const utils = {\n    bytesToHex,\n    hexToBytes,\n    concatBytes,\n    getExtendedPublicKey,\n    mod,\n    invert,\n    TORSION_SUBGROUP: [\n        '0100000000000000000000000000000000000000000000000000000000000000',\n        'c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a',\n        '0000000000000000000000000000000000000000000000000000000000000080',\n        '26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05',\n        'ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f',\n        '26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85',\n        '0000000000000000000000000000000000000000000000000000000000000000',\n        'c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa',\n    ],\n    hashToPrivateScalar: (hash) => {\n        hash = ensureBytes(hash);\n        if (hash.length < 40 || hash.length > 1024)\n            throw new Error('Expected 40-1024 bytes of private key as per FIPS 186');\n        return mod(bytesToNumberLE(hash), CURVE.l - _1n) + _1n;\n    },\n    randomBytes: (bytesLength = 32) => {\n        if (crypto.web) {\n            return crypto.web.getRandomValues(new Uint8Array(bytesLength));\n        }\n        else if (crypto.node) {\n            const { randomBytes } = crypto.node;\n            return new Uint8Array(randomBytes(bytesLength).buffer);\n        }\n        else {\n            throw new Error(\"The environment doesn't have randomBytes function\");\n        }\n    },\n    randomPrivateKey: () => {\n        return utils.randomBytes(32);\n    },\n    sha512: async (...messages) => {\n        const message = concatBytes(...messages);\n        if (crypto.web) {\n            const buffer = await crypto.web.subtle.digest('SHA-512', message.buffer);\n            return new Uint8Array(buffer);\n        }\n        else if (crypto.node) {\n            return Uint8Array.from(crypto.node.createHash('sha512').update(message).digest());\n        }\n        else {\n            throw new Error(\"The environment doesn't have sha512 function\");\n        }\n    },\n    precompute(windowSize = 8, point = Point.BASE) {\n        const cached = point.equals(Point.BASE) ? point : new Point(point.x, point.y);\n        cached._setWindowSize(windowSize);\n        cached.multiply(_2n);\n        return cached;\n    },\n    sha512Sync: undefined,\n};\nObject.defineProperties(utils, {\n    sha512Sync: {\n        configurable: false,\n        get() {\n            return _sha512Sync;\n        },\n        set(val) {\n            if (!_sha512Sync)\n                _sha512Sync = val;\n        },\n    },\n});\n","/**\n * Base-N/Base-X encoding/decoding functions.\n *\n * Original implementation from base-x:\n * https://github.com/cryptocoinjs/base-x\n *\n * Which is MIT licensed:\n *\n * The MIT License (MIT)\n *\n * Copyright base-x contributors (c) 2016\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n// baseN alphabet indexes\nconst _reverseAlphabets = {};\n\n/**\n * BaseN-encodes a Uint8Array using the given alphabet.\n *\n * @param {Uint8Array} input - The bytes to encode in a Uint8Array.\n * @param {string} alphabet - The alphabet to use for encoding.\n * @param {number} maxline - The maximum number of encoded characters per line\n *          to use, defaults to none.\n *\n * @returns {string} The baseN-encoded output string.\n */\nexport function encode(input, alphabet, maxline) {\n  if(!(input instanceof Uint8Array)) {\n    throw new TypeError('\"input\" must be a Uint8Array.');\n  }\n  if(typeof alphabet !== 'string') {\n    throw new TypeError('\"alphabet\" must be a string.');\n  }\n  if(maxline !== undefined && typeof maxline !== 'number') {\n    throw new TypeError('\"maxline\" must be a number.');\n  }\n  if(input.length === 0) {\n    return '';\n  }\n\n  let output = '';\n\n  let i = 0;\n  const base = alphabet.length;\n  const first = alphabet.charAt(0);\n  const digits = [0];\n  for(i = 0; i < input.length; ++i) {\n    let carry = input[i];\n    for(let j = 0; j < digits.length; ++j) {\n      carry += digits[j] << 8;\n      digits[j] = carry % base;\n      carry = (carry / base) | 0;\n    }\n\n    while(carry > 0) {\n      digits.push(carry % base);\n      carry = (carry / base) | 0;\n    }\n  }\n\n  // deal with leading zeros\n  for(i = 0; input[i] === 0 && i < input.length - 1; ++i) {\n    output += first;\n  }\n  // convert digits to a string\n  for(i = digits.length - 1; i >= 0; --i) {\n    output += alphabet[digits[i]];\n  }\n\n  if(maxline) {\n    const regex = new RegExp('.{1,' + maxline + '}', 'g');\n    output = output.match(regex).join('\\r\\n');\n  }\n\n  return output;\n}\n\n/**\n * Decodes a baseN-encoded (using the given alphabet) string to a\n * Uint8Array.\n *\n * @param {string} input - The baseN-encoded input string.\n * @param {string} alphabet - The alphabet to use for decoding.\n *\n * @returns {Uint8Array} The decoded bytes in a Uint8Array.\n */\nexport function decode(input, alphabet) {\n  if(typeof input !== 'string') {\n    throw new TypeError('\"input\" must be a string.');\n  }\n  if(typeof alphabet !== 'string') {\n    throw new TypeError('\"alphabet\" must be a string.');\n  }\n  if(input.length === 0) {\n    return new Uint8Array();\n  }\n\n  let table = _reverseAlphabets[alphabet];\n  if(!table) {\n    // compute reverse alphabet\n    table = _reverseAlphabets[alphabet] = [];\n    for(let i = 0; i < alphabet.length; ++i) {\n      table[alphabet.charCodeAt(i)] = i;\n    }\n  }\n\n  // remove whitespace characters\n  input = input.replace(/\\s/g, '');\n\n  const base = alphabet.length;\n  const first = alphabet.charAt(0);\n  const bytes = [0];\n  for(let i = 0; i < input.length; i++) {\n    const value = table[input.charCodeAt(i)];\n    if(value === undefined) {\n      return;\n    }\n\n    let carry = value;\n    for(let j = 0; j < bytes.length; ++j) {\n      carry += bytes[j] * base;\n      bytes[j] = carry & 0xff;\n      carry >>= 8;\n    }\n\n    while(carry > 0) {\n      bytes.push(carry & 0xff);\n      carry >>= 8;\n    }\n  }\n\n  // deal with leading zeros\n  for(let k = 0; input[k] === first && k < input.length - 1; ++k) {\n    bytes.push(0);\n  }\n\n  return new Uint8Array(bytes.reverse());\n}\n","/*!\n * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.\n */\nimport {\n  encode as _encode,\n  decode as _decode\n} from './baseN.js';\n\n// base58 characters (Bitcoin alphabet)\nconst alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';\n\nexport function encode(input, maxline) {\n  return _encode(input, alphabet, maxline);\n}\n\nexport function decode(input) {\n  return _decode(input, alphabet);\n}\n","/*!\n * Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.\n */\n/**\n * Encode/Decode input according to the \"Base64url Encoding\" format as specified\n * in JSON Web Signature (JWS) RFC7517. A URL safe character set is used and\n * trailing '=', line breaks, whitespace, and other characters are omitted.\n *\n * @module base64url-universal\n */\n\nconst _alphabet =\n  'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';\nconst _alphabetIdx = [\n  62, -1, -1,\n  52, 53, 54, 55, 56, 57, 58, 59, 60, 61,\n  -1, -1, -1, 64, -1, -1, -1,\n  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,\n  13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,\n  -1, -1, -1, -1, 63, -1,\n  26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,\n  39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51\n];\n\n/**\n * Encodes input according to the \"Base64url Encoding\" format as specified\n * in JSON Web Signature (JWS) RFC7517. A URL safe character set is used and\n * trailing '=', line breaks, whitespace, and other characters are omitted.\n *\n * @alias module:base64url-universal\n * @param {(Uint8Array | string)} input - The data to encode.\n *\n * @returns {string} The encoded value.\n */\nexport function encode(input) {\n  if(!((input instanceof Uint8Array) || (typeof input === 'string'))) {\n    throw new TypeError('\"input\" be a string or Uint8Array.');\n  }\n  if(typeof input === 'string') {\n    // convert input to Uint8Array\n    input = new TextEncoder().encode(input);\n  }\n  let output = '';\n  let chr1;\n  let chr2;\n  let chr3;\n  let i = 0;\n  while(i < input.byteLength) {\n    chr1 = input[i++];\n    chr2 = input[i++];\n    chr3 = input[i++];\n\n    // encode 4 character group\n    output += _alphabet.charAt(chr1 >> 2);\n    output += _alphabet.charAt(((chr1 & 3) << 4) | (chr2 >> 4));\n    if(!isNaN(chr2)) {\n      output += _alphabet.charAt(((chr2 & 15) << 2) | (chr3 >> 6));\n      if(!isNaN(chr3)) {\n        output += _alphabet.charAt(chr3 & 63);\n      }\n    }\n  }\n  return output;\n}\n\n/**\n * Decodes input according to the \"Base64url Encoding\" format as specified\n * in JSON Web Signature (JWS) RFC7517. A URL safe character set is used and\n * trailing '=', line breaks, whitespace, and other characters are omitted.\n *\n * @alias module:base64url-universal\n * @param {string} input - The data to decode.\n *\n * @returns {Uint8Array} The decoded value.\n */\nexport function decode(input) {\n  let length = input.length;\n  const mod4 = length % 4;\n  if(mod4 === 1) {\n    throw new Error('Illegal base64 string.');\n  }\n  let diff = 0;\n  if(mod4 > 0) {\n    diff = 4 - mod4;\n    length += diff;\n  }\n\n  const output = new Uint8Array(length / 4 * 3 - diff);\n\n  let enc1;\n  let enc2;\n  let enc3;\n  let enc4;\n  let i = 0;\n  let j = 0;\n\n  while(i < length) {\n    enc1 = _alphabetIdx[input.charCodeAt(i++) - 45];\n    enc2 = _alphabetIdx[input.charCodeAt(i++) - 45];\n\n    output[j++] = (enc1 << 2) | (enc2 >> 4);\n    if(i < input.length) {\n      // can decode at least 2 bytes\n      enc3 = _alphabetIdx[input.charCodeAt(i++) - 45];\n      output[j++] = ((enc2 & 15) << 4) | (enc3 >> 2);\n      if(i < input.length) {\n        // can decode 3 bytes\n        enc4 = _alphabetIdx[input.charCodeAt(i++) - 45];\n        output[j++] = ((enc3 & 3) << 6) | enc4;\n      }\n    }\n  }\n\n  return output;\n}\n","/*!\n * Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.\n */\nexport {encode, decode} from './base64url.js';\n","/*!\n * Copyright (c) 2020-2022 Digital Bazaar, Inc. All rights reserved.\n */\n\n/**\n * General purpose key generation driver for Linked Data cryptographic key\n * pairs.\n *\n * @param {Map} [suites] - Optional map of supported suites, by suite id.\n */\nexport class CryptoLD {\n  constructor({suites} = {}) {\n    this.suites = suites || new Map();\n  }\n\n  /**\n   * Installs support for a key type (suite).\n   *\n   * @param {LDKeyPair} keyPairLib - Conforming key pair library for a suite.\n   */\n  use(keyPairLib) {\n    this.suites.set(keyPairLib.suite, keyPairLib);\n  }\n\n  /**\n   * Generates a public/private LDKeyPair.\n   *\n   * @param {object} options - Suite-specific key options.\n   * @param {string} options.type - Key suite id (for example,\n   *   'Ed25519VerificationKey2020').\n   * @param {string} [options.controller] - Controller DID or URL for the\n   *   generated key pair. If present, used to auto-initialize the key.id.\n   *\n   * @returns {Promise<LDKeyPair>} Generated key pair.\n   */\n  async generate(options = {}) {\n    const Suite = this._suiteForType(options);\n    return Suite.generate(options);\n  }\n\n  /**\n   * Imports a public/private key pair from serialized data.\n   *\n   * @param {object} serialized - Serialized key object.\n   *\n   * @throws {Error} - On missing or invalid serialized key data.\n   *\n   * @returns {Promise<LDKeyPair>} Imported key pair.\n   */\n  async from(serialized = {}) {\n    const Suite = this._suiteForType(serialized);\n\n    if(serialized['@context']) {\n      // presume this may be an untrusted (fetched, etc) key document\n      return Suite.fromKeyDocument({document: serialized});\n    }\n\n    return Suite.from(serialized);\n  }\n\n  /**\n   * Imports a key pair instance from a provided externally fetched key\n   * document (fetched via a secure JSON-LD `documentLoader` or via\n   * `cryptoLd.fromKeyId()`), optionally checking it for revocation and required\n   * context.\n   *\n   * @param {object} options - Options hashmap.\n   * @param {string} options.document - Externally fetched key document.\n   * @param {boolean} [options.checkContext=true] - Whether to check that the\n   *   fetched key document contains the context required by the key's crypto\n   *   suite.\n   * @param {boolean} [options.checkRevoked=true] - Whether to check the key\n   *   object for the presence of the `revoked` timestamp.\n   *\n   * @returns {Promise<LDKeyPair>} Resolves with the resulting key pair\n   *   instance.\n   */\n  async fromKeyDocument({\n    document, checkContext = true, checkRevoked = true\n  } = {}) {\n    if(!document) {\n      throw new TypeError('The \"document\" parameter is required.');\n    }\n    const Suite = this._suiteForType(document);\n\n    return Suite.fromKeyDocument({document, checkContext, checkRevoked});\n  }\n\n  /**\n   * Imports a key pair instance via the provided `documentLoader` function,\n   * optionally checking it for revocation and required context.\n   *\n   * @param {object} options - Options hashmap.\n   * @param {string} options.id - Key ID or URI.\n   * @param {Function} options.documentLoader - JSON-LD Document Loader.\n   * @param {boolean} [options.checkContext=true] - Whether to check that the\n   *   fetched key document contains the context required by the key's crypto\n   *   suite.\n   * @param {boolean} [options.checkRevoked=true] - Whether to check the key\n   *   object for the presence of the `revoked` timestamp.\n   *\n   * @returns {Promise<LDKeyPair>} Resolves with the appropriate key pair\n   *   instance.\n   */\n  async fromKeyId({\n    id, documentLoader, checkContext = true, checkRevoked = true\n  } = {}) {\n    if(!id) {\n      throw new TypeError('The \"id\" parameter is required.');\n    }\n    if(!documentLoader) {\n      throw new TypeError('The \"documentLoader\" parameter is required.');\n    }\n    let keyDocument;\n    try {\n      ({document: keyDocument} = await documentLoader(id));\n      // the supplied documentLoader may not be properly implemented\n      if(!keyDocument) {\n        throw new Error(\n          'The \"documentLoader\" function must return a \"document\" object.');\n      }\n    } catch(e) {\n      const error = new Error('Error fetching document: ' + e.message);\n      error.cause = e;\n      throw error;\n    }\n    const fetchedType = keyDocument.type;\n    if(!fetchedType) {\n      throw new Error('Key suite type not found in fetched document.');\n    }\n    const keySuite = this.suites.get(fetchedType);\n    if(!keySuite) {\n      throw new Error(`Support for suite \"${fetchedType}\" is not installed.`);\n    }\n\n    return keySuite.fromKeyDocument({document: keyDocument, checkContext,\n      checkRevoked});\n  }\n\n  /**\n   * Tests if a given key type is currently installed.\n   *\n   * @param {string} [type] - Key suite id ('Ed25519VerificationKey2020').\n   * @private\n   *\n   * @returns {boolean} True if key type installed.\n   */\n  _installed({type}) {\n    return this.suites.has(type);\n  }\n\n  /**\n   * Returns the installed crypto suite class for a given document's type.\n   *\n   * @param {object} document - A serialized key document (or options document).\n   * @param {string} document.type - Key suite id (for example,\n   *   'Ed25519VerificationKey2020').\n   *\n   * @returns {object} LDKeyPair (crypto suite) class.\n   */\n  _suiteForType(document) {\n    const type = document && document.type;\n\n    if(!type) {\n      throw new TypeError('Missing key type.');\n    }\n    if(!this._installed({type})) {\n      throw new Error(`Support for key type \"${type}\" is not installed.`);\n    }\n\n    return this.suites.get(type);\n  }\n}\n\n/**\n * @typedef LDKeyPair\n */\n","/*!\n * Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.\n */\n\n/**\n * When adding support for a new suite type for `crypto-ld`, developers should\n * do the following:\n *\n * 1. Create their own npm package / github repo, such as `example-key-pair`.\n * 2. Subclass LDKeyPair.\n * 3. Override relevant methods (such as `export()` and `fingerprint()`).\n * 4. Add to the key type table in the `crypto-ld` README.md (that's this repo).\n */\nexport class LDKeyPair {\n  /* eslint-disable jsdoc/require-description-complete-sentence */\n  /**\n   * Creates a public/private key pair instance. This is an abstract base class,\n   * actual key material and suite-specific methods are handled in the subclass.\n   *\n   * To generate or import a key pair, use the `cryptoLd` instance.\n   *\n   * @see CryptoLD.js\n   *\n   * @param {object} options - The options to use.\n   * @param {string} options.id - The key id, typically composed of controller\n   *   URL and key fingerprint as hash fragment.\n   * @param {string} options.controller - DID/URL of the person/entity\n   *   controlling this key.\n   * @param {string} [options.revoked] - Timestamp of when the key has been\n   *   revoked, in RFC3339 format. If not present, the key itself is\n   *   considered not revoked. (Note that this mechanism is slightly different\n   *   than DID Document key revocation, where a DID controller can revoke a\n   *   key from that DID by removing it from the DID Document.)\n   */\n  /* eslint-enable */\n  constructor({id, controller, revoked} = {}) {\n    this.id = id;\n    this.controller = controller;\n    this.revoked = revoked;\n    // this.type is set in subclass constructor\n  }\n\n  /* eslint-disable jsdoc/check-param-names */\n  /**\n   * Generates a new public/private key pair instance.\n   * Note that this method is not typically called directly by client code,\n   * but instead is used through a `cryptoLd` instance.\n   *\n   * @param {object} options - Suite-specific options for the KeyPair. For\n   *   common options, see the `LDKeyPair.constructor()` docstring.\n   *\n   * @returns {Promise<LDKeyPair>} An LDKeyPair instance.\n   */\n  /* eslint-enable */\n  static async generate(/* options */) {\n    throw new Error('Abstract method, must be implemented in subclass.');\n  }\n\n  /**\n   * Imports a key pair instance from a provided externally fetched key\n   * document (fetched via a secure JSON-LD `documentLoader` or via\n   * `cryptoLd.fromKeyId()`), optionally checking it for revocation and required\n   * context.\n   *\n   * @param {object} options - Options hashmap.\n   * @param {string} options.document - Externally fetched key document.\n   * @param {boolean} [options.checkContext=true] - Whether to check that the\n   *   fetched key document contains the context required by the key's crypto\n   *   suite.\n   * @param {boolean} [options.checkRevoked=true] - Whether to check the key\n   *   object for the presence of the `revoked` timestamp.\n   *\n   * @returns {Promise<LDKeyPair>} Resolves with the resulting key pair\n   *   instance.\n   */\n  static async fromKeyDocument({\n    document, checkContext = true, checkRevoked = true\n  } = {}) {\n    if(!document) {\n      throw new TypeError('The \"document\" parameter is required.');\n    }\n\n    if(checkContext) {\n      const fetchedDocContexts = [].concat(document['@context']);\n      if(!fetchedDocContexts.includes(this.SUITE_CONTEXT)) {\n        throw new Error('Key document does not contain required context \"' +\n          this.SUITE_CONTEXT + '\".');\n      }\n    }\n    if(checkRevoked && document.revoked) {\n      throw new Error(`Key has been revoked since: \"${document.revoked}\".`);\n    }\n    return this.from(document);\n  }\n\n  /* eslint-disable jsdoc/check-param-names */\n  /**\n   * Generates a KeyPair from some options.\n   *\n   * @param {object} options  - Will generate a key pair in multiple different\n   *   formats.\n   * @example\n   * > const options = {\n   *    type: 'Ed25519VerificationKey2020'\n   *   };\n   * > const edKeyPair = await LDKeyPair.from(options);\n   *\n   * @returns {Promise<LDKeyPair>} A LDKeyPair.\n   * @throws Unsupported Key Type.\n   */\n  /* eslint-enable */\n  static async from(/* options */) {\n    throw new Error('Abstract method from() must be implemented in subclass.');\n  }\n\n  /**\n   * Exports the serialized representation of the KeyPair\n   * and other information that json-ld Signatures can use to form a proof.\n   *\n   * NOTE: Subclasses MUST override this method (and add the exporting of\n   * their public and private key material).\n   *\n   * @param {object} [options={}] - Options hashmap.\n   * @param {boolean} [options.publicKey] - Export public key material?\n   * @param {boolean} [options.privateKey] - Export private key material?\n   *\n   * @returns {object} A public key object\n   *   information used in verification methods by signatures.\n   */\n  export({publicKey = false, privateKey = false} = {}) {\n    if(!publicKey && !privateKey) {\n      throw new Error(\n        'Export requires specifying either \"publicKey\" or \"privateKey\".');\n    }\n    const key = {\n      id: this.id,\n      type: this.type,\n      controller: this.controller\n    };\n    if(this.revoked) {\n      key.revoked = this.revoked;\n    }\n\n    return key;\n  }\n\n  /**\n   * Returns the public key fingerprint, multibase+multicodec encoded. The\n   * specific fingerprint method is determined by the key suite, and is often\n   * either a hash of the public key material (such as with RSA), or the\n   * full encoded public key (for key types with sufficiently short\n   * representations, such as ed25519).\n   * This is frequently used in initializing the key id, or generating some\n   * types of cryptonym DIDs.\n   *\n   * @returns {string} The fingerprint.\n   */\n  fingerprint() {\n    throw new Error('Abstract method, must be implemented in subclass.');\n  }\n\n  /* eslint-disable jsdoc/check-param-names */\n  /**\n   * Verifies that a given key fingerprint matches the public key material\n   * belonging to this key pair.\n   *\n   * @param {string} fingerprint - Public key fingerprint.\n   *\n   * @returns {{verified: boolean}} An object with verified flag.\n   */\n  /* eslint-enable */\n  verifyFingerprint(/* {fingerprint} */) {\n    throw new Error('Abstract method, must be implemented in subclass.');\n  }\n\n  /* eslint-disable max-len */\n  /**\n   * Returns a signer object for use with\n   * [jsonld-signatures]{@link https://github.com/digitalbazaar/jsonld-signatures}.\n   * NOTE: Applies only to verifier type keys (like ed25519).\n   *\n   * @example\n   * > const signer = keyPair.signer();\n   * > signer\n   * { sign: [AsyncFunction: sign] }\n   * > signer.sign({data});\n   *\n   * @returns {{sign: Function}} A signer for json-ld usage.\n   */\n  /* eslint-enable */\n  signer() {\n    return {\n      async sign({/* data */}) {\n        throw new Error('Abstract method, must be implemented in subclass.');\n      }\n    };\n  }\n\n  /* eslint-disable max-len */\n  /**\n   * Returns a verifier object for use with\n   * [jsonld-signatures]{@link https://github.com/digitalbazaar/jsonld-signatures}.\n   * NOTE: Applies only to verifier type keys (like ed25519).\n   *\n   * @example\n   * > const verifier = keyPair.verifier();\n   * > verifier\n   * { verify: [AsyncFunction: verify] }\n   * > verifier.verify(key);\n   *\n   * @returns {{verify: Function}} Used to verify jsonld-signatures.\n   */\n  /* eslint-enable */\n  verifier() {\n    return {\n      async verify({/* data, signature */}) {\n        throw new Error('Abstract method, must be implemented in subclass.');\n      }\n    };\n  }\n}\n\n// Implementers must override this in subclasses\nLDKeyPair.SUITE_CONTEXT = 'INVALID LDKeyPair CONTEXT';\n","/*\n * Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.\n */\nexport {CryptoLD} from './CryptoLD.js';\nexport {LDKeyPair} from './LDKeyPair.js';\n","export { compactDecrypt } from './jwe/compact/decrypt.js';\nexport { flattenedDecrypt } from './jwe/flattened/decrypt.js';\nexport { generalDecrypt } from './jwe/general/decrypt.js';\nexport { GeneralEncrypt } from './jwe/general/encrypt.js';\nexport { compactVerify } from './jws/compact/verify.js';\nexport { flattenedVerify } from './jws/flattened/verify.js';\nexport { generalVerify } from './jws/general/verify.js';\nexport { jwtVerify } from './jwt/verify.js';\nexport { jwtDecrypt } from './jwt/decrypt.js';\nexport { CompactEncrypt } from './jwe/compact/encrypt.js';\nexport { FlattenedEncrypt } from './jwe/flattened/encrypt.js';\nexport { CompactSign } from './jws/compact/sign.js';\nexport { FlattenedSign } from './jws/flattened/sign.js';\nexport { GeneralSign } from './jws/general/sign.js';\nexport { SignJWT } from './jwt/sign.js';\nexport { EncryptJWT } from './jwt/encrypt.js';\nexport { calculateJwkThumbprint, calculateJwkThumbprintUri } from './jwk/thumbprint.js';\nexport { EmbeddedJWK } from './jwk/embedded.js';\nexport { createLocalJWKSet } from './jwks/local.js';\nexport { createRemoteJWKSet } from './jwks/remote.js';\nexport { UnsecuredJWT } from './jwt/unsecured.js';\nexport { exportPKCS8, exportSPKI, exportJWK } from './key/export.js';\nexport { importSPKI, importPKCS8, importX509, importJWK } from './key/import.js';\nexport { decodeProtectedHeader } from './util/decode_protected_header.js';\nexport { decodeJwt } from './util/decode_jwt.js';\nimport * as errors_1 from './util/errors.js';\nexport { errors_1 as errors };\nexport { generateKeyPair } from './key/generate_key_pair.js';\nexport { generateSecret } from './key/generate_secret.js';\nimport * as base64url_1 from './util/base64url.js';\nexport { base64url_1 as base64url };\nexport { default as cryptoRuntime } from './util/runtime.js';\n","import { flattenedDecrypt } from '../flattened/decrypt.js';\nimport { JWEInvalid } from '../../util/errors.js';\nimport { decoder } from '../../lib/buffer_utils.js';\nexport async function compactDecrypt(jwe, key, options) {\n    if (jwe instanceof Uint8Array) {\n        jwe = decoder.decode(jwe);\n    }\n    if (typeof jwe !== 'string') {\n        throw new JWEInvalid('Compact JWE must be a string or Uint8Array');\n    }\n    const { 0: protectedHeader, 1: encryptedKey, 2: iv, 3: ciphertext, 4: tag, length, } = jwe.split('.');\n    if (length !== 5) {\n        throw new JWEInvalid('Invalid Compact JWE');\n    }\n    const decrypted = await flattenedDecrypt({\n        ciphertext,\n        iv: (iv || undefined),\n        protected: protectedHeader || undefined,\n        tag: (tag || undefined),\n        encrypted_key: encryptedKey || undefined,\n    }, key, options);\n    const result = { plaintext: decrypted.plaintext, protectedHeader: decrypted.protectedHeader };\n    if (typeof key === 'function') {\n        return { ...result, key: decrypted.key };\n    }\n    return result;\n}\n","import { FlattenedEncrypt } from '../flattened/encrypt.js';\nexport class CompactEncrypt {\n    constructor(plaintext) {\n        this._flattened = new FlattenedEncrypt(plaintext);\n    }\n    setContentEncryptionKey(cek) {\n        this._flattened.setContentEncryptionKey(cek);\n        return this;\n    }\n    setInitializationVector(iv) {\n        this._flattened.setInitializationVector(iv);\n        return this;\n    }\n    setProtectedHeader(protectedHeader) {\n        this._flattened.setProtectedHeader(protectedHeader);\n        return this;\n    }\n    setKeyManagementParameters(parameters) {\n        this._flattened.setKeyManagementParameters(parameters);\n        return this;\n    }\n    async encrypt(key, options) {\n        const jwe = await this._flattened.encrypt(key, options);\n        return [jwe.protected, jwe.encrypted_key, jwe.iv, jwe.ciphertext, jwe.tag].join('.');\n    }\n}\n","import { decode as base64url } from '../../runtime/base64url.js';\nimport decrypt from '../../runtime/decrypt.js';\nimport { inflate } from '../../runtime/zlib.js';\nimport { JOSEAlgNotAllowed, JOSENotSupported, JWEInvalid } from '../../util/errors.js';\nimport isDisjoint from '../../lib/is_disjoint.js';\nimport isObject from '../../lib/is_object.js';\nimport decryptKeyManagement from '../../lib/decrypt_key_management.js';\nimport { encoder, decoder, concat } from '../../lib/buffer_utils.js';\nimport generateCek from '../../lib/cek.js';\nimport validateCrit from '../../lib/validate_crit.js';\nimport validateAlgorithms from '../../lib/validate_algorithms.js';\nexport async function flattenedDecrypt(jwe, key, options) {\n    var _a;\n    if (!isObject(jwe)) {\n        throw new JWEInvalid('Flattened JWE must be an object');\n    }\n    if (jwe.protected === undefined && jwe.header === undefined && jwe.unprotected === undefined) {\n        throw new JWEInvalid('JOSE Header missing');\n    }\n    if (typeof jwe.iv !== 'string') {\n        throw new JWEInvalid('JWE Initialization Vector missing or incorrect type');\n    }\n    if (typeof jwe.ciphertext !== 'string') {\n        throw new JWEInvalid('JWE Ciphertext missing or incorrect type');\n    }\n    if (typeof jwe.tag !== 'string') {\n        throw new JWEInvalid('JWE Authentication Tag missing or incorrect type');\n    }\n    if (jwe.protected !== undefined && typeof jwe.protected !== 'string') {\n        throw new JWEInvalid('JWE Protected Header incorrect type');\n    }\n    if (jwe.encrypted_key !== undefined && typeof jwe.encrypted_key !== 'string') {\n        throw new JWEInvalid('JWE Encrypted Key incorrect type');\n    }\n    if (jwe.aad !== undefined && typeof jwe.aad !== 'string') {\n        throw new JWEInvalid('JWE AAD incorrect type');\n    }\n    if (jwe.header !== undefined && !isObject(jwe.header)) {\n        throw new JWEInvalid('JWE Shared Unprotected Header incorrect type');\n    }\n    if (jwe.unprotected !== undefined && !isObject(jwe.unprotected)) {\n        throw new JWEInvalid('JWE Per-Recipient Unprotected Header incorrect type');\n    }\n    let parsedProt;\n    if (jwe.protected) {\n        try {\n            const protectedHeader = base64url(jwe.protected);\n            parsedProt = JSON.parse(decoder.decode(protectedHeader));\n        }\n        catch (_b) {\n            throw new JWEInvalid('JWE Protected Header is invalid');\n        }\n    }\n    if (!isDisjoint(parsedProt, jwe.header, jwe.unprotected)) {\n        throw new JWEInvalid('JWE Protected, JWE Unprotected Header, and JWE Per-Recipient Unprotected Header Parameter names must be disjoint');\n    }\n    const joseHeader = {\n        ...parsedProt,\n        ...jwe.header,\n        ...jwe.unprotected,\n    };\n    validateCrit(JWEInvalid, new Map(), options === null || options === void 0 ? void 0 : options.crit, parsedProt, joseHeader);\n    if (joseHeader.zip !== undefined) {\n        if (!parsedProt || !parsedProt.zip) {\n            throw new JWEInvalid('JWE \"zip\" (Compression Algorithm) Header MUST be integrity protected');\n        }\n        if (joseHeader.zip !== 'DEF') {\n            throw new JOSENotSupported('Unsupported JWE \"zip\" (Compression Algorithm) Header Parameter value');\n        }\n    }\n    const { alg, enc } = joseHeader;\n    if (typeof alg !== 'string' || !alg) {\n        throw new JWEInvalid('missing JWE Algorithm (alg) in JWE Header');\n    }\n    if (typeof enc !== 'string' || !enc) {\n        throw new JWEInvalid('missing JWE Encryption Algorithm (enc) in JWE Header');\n    }\n    const keyManagementAlgorithms = options && validateAlgorithms('keyManagementAlgorithms', options.keyManagementAlgorithms);\n    const contentEncryptionAlgorithms = options &&\n        validateAlgorithms('contentEncryptionAlgorithms', options.contentEncryptionAlgorithms);\n    if (keyManagementAlgorithms && !keyManagementAlgorithms.has(alg)) {\n        throw new JOSEAlgNotAllowed('\"alg\" (Algorithm) Header Parameter not allowed');\n    }\n    if (contentEncryptionAlgorithms && !contentEncryptionAlgorithms.has(enc)) {\n        throw new JOSEAlgNotAllowed('\"enc\" (Encryption Algorithm) Header Parameter not allowed');\n    }\n    let encryptedKey;\n    if (jwe.encrypted_key !== undefined) {\n        try {\n            encryptedKey = base64url(jwe.encrypted_key);\n        }\n        catch (_c) {\n            throw new JWEInvalid('Failed to base64url decode the encrypted_key');\n        }\n    }\n    let resolvedKey = false;\n    if (typeof key === 'function') {\n        key = await key(parsedProt, jwe);\n        resolvedKey = true;\n    }\n    let cek;\n    try {\n        cek = await decryptKeyManagement(alg, key, encryptedKey, joseHeader, options);\n    }\n    catch (err) {\n        if (err instanceof TypeError || err instanceof JWEInvalid || err instanceof JOSENotSupported) {\n            throw err;\n        }\n        cek = generateCek(enc);\n    }\n    let iv;\n    let tag;\n    try {\n        iv = base64url(jwe.iv);\n    }\n    catch (_d) {\n        throw new JWEInvalid('Failed to base64url decode the iv');\n    }\n    try {\n        tag = base64url(jwe.tag);\n    }\n    catch (_e) {\n        throw new JWEInvalid('Failed to base64url decode the tag');\n    }\n    const protectedHeader = encoder.encode((_a = jwe.protected) !== null && _a !== void 0 ? _a : '');\n    let additionalData;\n    if (jwe.aad !== undefined) {\n        additionalData = concat(protectedHeader, encoder.encode('.'), encoder.encode(jwe.aad));\n    }\n    else {\n        additionalData = protectedHeader;\n    }\n    let ciphertext;\n    try {\n        ciphertext = base64url(jwe.ciphertext);\n    }\n    catch (_f) {\n        throw new JWEInvalid('Failed to base64url decode the ciphertext');\n    }\n    let plaintext = await decrypt(enc, cek, ciphertext, iv, tag, additionalData);\n    if (joseHeader.zip === 'DEF') {\n        plaintext = await ((options === null || options === void 0 ? void 0 : options.inflateRaw) || inflate)(plaintext);\n    }\n    const result = { plaintext };\n    if (jwe.protected !== undefined) {\n        result.protectedHeader = parsedProt;\n    }\n    if (jwe.aad !== undefined) {\n        try {\n            result.additionalAuthenticatedData = base64url(jwe.aad);\n        }\n        catch (_g) {\n            throw new JWEInvalid('Failed to base64url decode the aad');\n        }\n    }\n    if (jwe.unprotected !== undefined) {\n        result.sharedUnprotectedHeader = jwe.unprotected;\n    }\n    if (jwe.header !== undefined) {\n        result.unprotectedHeader = jwe.header;\n    }\n    if (resolvedKey) {\n        return { ...result, key };\n    }\n    return result;\n}\n","import { encode as base64url } from '../../runtime/base64url.js';\nimport encrypt from '../../runtime/encrypt.js';\nimport { deflate } from '../../runtime/zlib.js';\nimport generateIv from '../../lib/iv.js';\nimport encryptKeyManagement from '../../lib/encrypt_key_management.js';\nimport { JOSENotSupported, JWEInvalid } from '../../util/errors.js';\nimport isDisjoint from '../../lib/is_disjoint.js';\nimport { encoder, decoder, concat } from '../../lib/buffer_utils.js';\nimport validateCrit from '../../lib/validate_crit.js';\nexport const unprotected = Symbol();\nexport class FlattenedEncrypt {\n    constructor(plaintext) {\n        if (!(plaintext instanceof Uint8Array)) {\n            throw new TypeError('plaintext must be an instance of Uint8Array');\n        }\n        this._plaintext = plaintext;\n    }\n    setKeyManagementParameters(parameters) {\n        if (this._keyManagementParameters) {\n            throw new TypeError('setKeyManagementParameters can only be called once');\n        }\n        this._keyManagementParameters = parameters;\n        return this;\n    }\n    setProtectedHeader(protectedHeader) {\n        if (this._protectedHeader) {\n            throw new TypeError('setProtectedHeader can only be called once');\n        }\n        this._protectedHeader = protectedHeader;\n        return this;\n    }\n    setSharedUnprotectedHeader(sharedUnprotectedHeader) {\n        if (this._sharedUnprotectedHeader) {\n            throw new TypeError('setSharedUnprotectedHeader can only be called once');\n        }\n        this._sharedUnprotectedHeader = sharedUnprotectedHeader;\n        return this;\n    }\n    setUnprotectedHeader(unprotectedHeader) {\n        if (this._unprotectedHeader) {\n            throw new TypeError('setUnprotectedHeader can only be called once');\n        }\n        this._unprotectedHeader = unprotectedHeader;\n        return this;\n    }\n    setAdditionalAuthenticatedData(aad) {\n        this._aad = aad;\n        return this;\n    }\n    setContentEncryptionKey(cek) {\n        if (this._cek) {\n            throw new TypeError('setContentEncryptionKey can only be called once');\n        }\n        this._cek = cek;\n        return this;\n    }\n    setInitializationVector(iv) {\n        if (this._iv) {\n            throw new TypeError('setInitializationVector can only be called once');\n        }\n        this._iv = iv;\n        return this;\n    }\n    async encrypt(key, options) {\n        if (!this._protectedHeader && !this._unprotectedHeader && !this._sharedUnprotectedHeader) {\n            throw new JWEInvalid('either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()');\n        }\n        if (!isDisjoint(this._protectedHeader, this._unprotectedHeader, this._sharedUnprotectedHeader)) {\n            throw new JWEInvalid('JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint');\n        }\n        const joseHeader = {\n            ...this._protectedHeader,\n            ...this._unprotectedHeader,\n            ...this._sharedUnprotectedHeader,\n        };\n        validateCrit(JWEInvalid, new Map(), options === null || options === void 0 ? void 0 : options.crit, this._protectedHeader, joseHeader);\n        if (joseHeader.zip !== undefined) {\n            if (!this._protectedHeader || !this._protectedHeader.zip) {\n                throw new JWEInvalid('JWE \"zip\" (Compression Algorithm) Header MUST be integrity protected');\n            }\n            if (joseHeader.zip !== 'DEF') {\n                throw new JOSENotSupported('Unsupported JWE \"zip\" (Compression Algorithm) Header Parameter value');\n            }\n        }\n        const { alg, enc } = joseHeader;\n        if (typeof alg !== 'string' || !alg) {\n            throw new JWEInvalid('JWE \"alg\" (Algorithm) Header Parameter missing or invalid');\n        }\n        if (typeof enc !== 'string' || !enc) {\n            throw new JWEInvalid('JWE \"enc\" (Encryption Algorithm) Header Parameter missing or invalid');\n        }\n        let encryptedKey;\n        if (alg === 'dir') {\n            if (this._cek) {\n                throw new TypeError('setContentEncryptionKey cannot be called when using Direct Encryption');\n            }\n        }\n        else if (alg === 'ECDH-ES') {\n            if (this._cek) {\n                throw new TypeError('setContentEncryptionKey cannot be called when using Direct Key Agreement');\n            }\n        }\n        let cek;\n        {\n            let parameters;\n            ({ cek, encryptedKey, parameters } = await encryptKeyManagement(alg, enc, key, this._cek, this._keyManagementParameters));\n            if (parameters) {\n                if (options && unprotected in options) {\n                    if (!this._unprotectedHeader) {\n                        this.setUnprotectedHeader(parameters);\n                    }\n                    else {\n                        this._unprotectedHeader = { ...this._unprotectedHeader, ...parameters };\n                    }\n                }\n                else {\n                    if (!this._protectedHeader) {\n                        this.setProtectedHeader(parameters);\n                    }\n                    else {\n                        this._protectedHeader = { ...this._protectedHeader, ...parameters };\n                    }\n                }\n            }\n        }\n        this._iv || (this._iv = generateIv(enc));\n        let additionalData;\n        let protectedHeader;\n        let aadMember;\n        if (this._protectedHeader) {\n            protectedHeader = encoder.encode(base64url(JSON.stringify(this._protectedHeader)));\n        }\n        else {\n            protectedHeader = encoder.encode('');\n        }\n        if (this._aad) {\n            aadMember = base64url(this._aad);\n            additionalData = concat(protectedHeader, encoder.encode('.'), encoder.encode(aadMember));\n        }\n        else {\n            additionalData = protectedHeader;\n        }\n        let ciphertext;\n        let tag;\n        if (joseHeader.zip === 'DEF') {\n            const deflated = await ((options === null || options === void 0 ? void 0 : options.deflateRaw) || deflate)(this._plaintext);\n            ({ ciphertext, tag } = await encrypt(enc, deflated, cek, this._iv, additionalData));\n        }\n        else {\n            ;\n            ({ ciphertext, tag } = await encrypt(enc, this._plaintext, cek, this._iv, additionalData));\n        }\n        const jwe = {\n            ciphertext: base64url(ciphertext),\n            iv: base64url(this._iv),\n            tag: base64url(tag),\n        };\n        if (encryptedKey) {\n            jwe.encrypted_key = base64url(encryptedKey);\n        }\n        if (aadMember) {\n            jwe.aad = aadMember;\n        }\n        if (this._protectedHeader) {\n            jwe.protected = decoder.decode(protectedHeader);\n        }\n        if (this._sharedUnprotectedHeader) {\n            jwe.unprotected = this._sharedUnprotectedHeader;\n        }\n        if (this._unprotectedHeader) {\n            jwe.header = this._unprotectedHeader;\n        }\n        return jwe;\n    }\n}\n","import { flattenedDecrypt } from '../flattened/decrypt.js';\nimport { JWEDecryptionFailed, JWEInvalid } from '../../util/errors.js';\nimport isObject from '../../lib/is_object.js';\nexport async function generalDecrypt(jwe, key, options) {\n    if (!isObject(jwe)) {\n        throw new JWEInvalid('General JWE must be an object');\n    }\n    if (!Array.isArray(jwe.recipients) || !jwe.recipients.every(isObject)) {\n        throw new JWEInvalid('JWE Recipients missing or incorrect type');\n    }\n    if (!jwe.recipients.length) {\n        throw new JWEInvalid('JWE Recipients has no members');\n    }\n    for (const recipient of jwe.recipients) {\n        try {\n            return await flattenedDecrypt({\n                aad: jwe.aad,\n                ciphertext: jwe.ciphertext,\n                encrypted_key: recipient.encrypted_key,\n                header: recipient.header,\n                iv: jwe.iv,\n                protected: jwe.protected,\n                tag: jwe.tag,\n                unprotected: jwe.unprotected,\n            }, key, options);\n        }\n        catch (_a) {\n        }\n    }\n    throw new JWEDecryptionFailed();\n}\n","import { FlattenedEncrypt, unprotected } from '../flattened/encrypt.js';\nimport { JWEInvalid } from '../../util/errors.js';\nimport generateCek from '../../lib/cek.js';\nimport isDisjoint from '../../lib/is_disjoint.js';\nimport encryptKeyManagement from '../../lib/encrypt_key_management.js';\nimport { encode as base64url } from '../../runtime/base64url.js';\nimport validateCrit from '../../lib/validate_crit.js';\nclass IndividualRecipient {\n    constructor(enc, key, options) {\n        this.parent = enc;\n        this.key = key;\n        this.options = options;\n    }\n    setUnprotectedHeader(unprotectedHeader) {\n        if (this.unprotectedHeader) {\n            throw new TypeError('setUnprotectedHeader can only be called once');\n        }\n        this.unprotectedHeader = unprotectedHeader;\n        return this;\n    }\n    addRecipient(...args) {\n        return this.parent.addRecipient(...args);\n    }\n    encrypt(...args) {\n        return this.parent.encrypt(...args);\n    }\n    done() {\n        return this.parent;\n    }\n}\nexport class GeneralEncrypt {\n    constructor(plaintext) {\n        this._recipients = [];\n        this._plaintext = plaintext;\n    }\n    addRecipient(key, options) {\n        const recipient = new IndividualRecipient(this, key, { crit: options === null || options === void 0 ? void 0 : options.crit });\n        this._recipients.push(recipient);\n        return recipient;\n    }\n    setProtectedHeader(protectedHeader) {\n        if (this._protectedHeader) {\n            throw new TypeError('setProtectedHeader can only be called once');\n        }\n        this._protectedHeader = protectedHeader;\n        return this;\n    }\n    setSharedUnprotectedHeader(sharedUnprotectedHeader) {\n        if (this._unprotectedHeader) {\n            throw new TypeError('setSharedUnprotectedHeader can only be called once');\n        }\n        this._unprotectedHeader = sharedUnprotectedHeader;\n        return this;\n    }\n    setAdditionalAuthenticatedData(aad) {\n        this._aad = aad;\n        return this;\n    }\n    async encrypt(options) {\n        var _a, _b, _c;\n        if (!this._recipients.length) {\n            throw new JWEInvalid('at least one recipient must be added');\n        }\n        options = { deflateRaw: options === null || options === void 0 ? void 0 : options.deflateRaw };\n        if (this._recipients.length === 1) {\n            const [recipient] = this._recipients;\n            const flattened = await new FlattenedEncrypt(this._plaintext)\n                .setAdditionalAuthenticatedData(this._aad)\n                .setProtectedHeader(this._protectedHeader)\n                .setSharedUnprotectedHeader(this._unprotectedHeader)\n                .setUnprotectedHeader(recipient.unprotectedHeader)\n                .encrypt(recipient.key, { ...recipient.options, ...options });\n            let jwe = {\n                ciphertext: flattened.ciphertext,\n                iv: flattened.iv,\n                recipients: [{}],\n                tag: flattened.tag,\n            };\n            if (flattened.aad)\n                jwe.aad = flattened.aad;\n            if (flattened.protected)\n                jwe.protected = flattened.protected;\n            if (flattened.unprotected)\n                jwe.unprotected = flattened.unprotected;\n            if (flattened.encrypted_key)\n                jwe.recipients[0].encrypted_key = flattened.encrypted_key;\n            if (flattened.header)\n                jwe.recipients[0].header = flattened.header;\n            return jwe;\n        }\n        let enc;\n        for (let i = 0; i < this._recipients.length; i++) {\n            const recipient = this._recipients[i];\n            if (!isDisjoint(this._protectedHeader, this._unprotectedHeader, recipient.unprotectedHeader)) {\n                throw new JWEInvalid('JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint');\n            }\n            const joseHeader = {\n                ...this._protectedHeader,\n                ...this._unprotectedHeader,\n                ...recipient.unprotectedHeader,\n            };\n            const { alg } = joseHeader;\n            if (typeof alg !== 'string' || !alg) {\n                throw new JWEInvalid('JWE \"alg\" (Algorithm) Header Parameter missing or invalid');\n            }\n            if (alg === 'dir' || alg === 'ECDH-ES') {\n                throw new JWEInvalid('\"dir\" and \"ECDH-ES\" alg may only be used with a single recipient');\n            }\n            if (typeof joseHeader.enc !== 'string' || !joseHeader.enc) {\n                throw new JWEInvalid('JWE \"enc\" (Encryption Algorithm) Header Parameter missing or invalid');\n            }\n            if (!enc) {\n                enc = joseHeader.enc;\n            }\n            else if (enc !== joseHeader.enc) {\n                throw new JWEInvalid('JWE \"enc\" (Encryption Algorithm) Header Parameter must be the same for all recipients');\n            }\n            validateCrit(JWEInvalid, new Map(), recipient.options.crit, this._protectedHeader, joseHeader);\n            if (joseHeader.zip !== undefined) {\n                if (!this._protectedHeader || !this._protectedHeader.zip) {\n                    throw new JWEInvalid('JWE \"zip\" (Compression Algorithm) Header MUST be integrity protected');\n                }\n            }\n        }\n        const cek = generateCek(enc);\n        let jwe = {\n            ciphertext: '',\n            iv: '',\n            recipients: [],\n            tag: '',\n        };\n        for (let i = 0; i < this._recipients.length; i++) {\n            const recipient = this._recipients[i];\n            const target = {};\n            jwe.recipients.push(target);\n            const joseHeader = {\n                ...this._protectedHeader,\n                ...this._unprotectedHeader,\n                ...recipient.unprotectedHeader,\n            };\n            const p2c = joseHeader.alg.startsWith('PBES2') ? 2048 + i : undefined;\n            if (i === 0) {\n                const flattened = await new FlattenedEncrypt(this._plaintext)\n                    .setAdditionalAuthenticatedData(this._aad)\n                    .setContentEncryptionKey(cek)\n                    .setProtectedHeader(this._protectedHeader)\n                    .setSharedUnprotectedHeader(this._unprotectedHeader)\n                    .setUnprotectedHeader(recipient.unprotectedHeader)\n                    .setKeyManagementParameters({ p2c })\n                    .encrypt(recipient.key, {\n                    ...recipient.options,\n                    ...options,\n                    [unprotected]: true,\n                });\n                jwe.ciphertext = flattened.ciphertext;\n                jwe.iv = flattened.iv;\n                jwe.tag = flattened.tag;\n                if (flattened.aad)\n                    jwe.aad = flattened.aad;\n                if (flattened.protected)\n                    jwe.protected = flattened.protected;\n                if (flattened.unprotected)\n                    jwe.unprotected = flattened.unprotected;\n                target.encrypted_key = flattened.encrypted_key;\n                if (flattened.header)\n                    target.header = flattened.header;\n                continue;\n            }\n            const { encryptedKey, parameters } = await encryptKeyManagement(((_a = recipient.unprotectedHeader) === null || _a === void 0 ? void 0 : _a.alg) ||\n                ((_b = this._protectedHeader) === null || _b === void 0 ? void 0 : _b.alg) ||\n                ((_c = this._unprotectedHeader) === null || _c === void 0 ? void 0 : _c.alg), enc, recipient.key, cek, { p2c });\n            target.encrypted_key = base64url(encryptedKey);\n            if (recipient.unprotectedHeader || parameters)\n                target.header = { ...recipient.unprotectedHeader, ...parameters };\n        }\n        return jwe;\n    }\n}\n","import { importJWK } from '../key/import.js';\nimport isObject from '../lib/is_object.js';\nimport { JWSInvalid } from '../util/errors.js';\nexport async function EmbeddedJWK(protectedHeader, token) {\n    const joseHeader = {\n        ...protectedHeader,\n        ...token === null || token === void 0 ? void 0 : token.header,\n    };\n    if (!isObject(joseHeader.jwk)) {\n        throw new JWSInvalid('\"jwk\" (JSON Web Key) Header Parameter must be a JSON object');\n    }\n    const key = await importJWK({ ...joseHeader.jwk, ext: true }, joseHeader.alg, true);\n    if (key instanceof Uint8Array || key.type !== 'public') {\n        throw new JWSInvalid('\"jwk\" (JSON Web Key) Header Parameter must be a public key');\n    }\n    return key;\n}\n","import digest from '../runtime/digest.js';\nimport { encode as base64url } from '../runtime/base64url.js';\nimport { JOSENotSupported, JWKInvalid } from '../util/errors.js';\nimport { encoder } from '../lib/buffer_utils.js';\nimport isObject from '../lib/is_object.js';\nconst check = (value, description) => {\n    if (typeof value !== 'string' || !value) {\n        throw new JWKInvalid(`${description} missing or invalid`);\n    }\n};\nexport async function calculateJwkThumbprint(jwk, digestAlgorithm) {\n    if (!isObject(jwk)) {\n        throw new TypeError('JWK must be an object');\n    }\n    digestAlgorithm !== null && digestAlgorithm !== void 0 ? digestAlgorithm : (digestAlgorithm = 'sha256');\n    if (digestAlgorithm !== 'sha256' &&\n        digestAlgorithm !== 'sha384' &&\n        digestAlgorithm !== 'sha512') {\n        throw new TypeError('digestAlgorithm must one of \"sha256\", \"sha384\", or \"sha512\"');\n    }\n    let components;\n    switch (jwk.kty) {\n        case 'EC':\n            check(jwk.crv, '\"crv\" (Curve) Parameter');\n            check(jwk.x, '\"x\" (X Coordinate) Parameter');\n            check(jwk.y, '\"y\" (Y Coordinate) Parameter');\n            components = { crv: jwk.crv, kty: jwk.kty, x: jwk.x, y: jwk.y };\n            break;\n        case 'OKP':\n            check(jwk.crv, '\"crv\" (Subtype of Key Pair) Parameter');\n            check(jwk.x, '\"x\" (Public Key) Parameter');\n            components = { crv: jwk.crv, kty: jwk.kty, x: jwk.x };\n            break;\n        case 'RSA':\n            check(jwk.e, '\"e\" (Exponent) Parameter');\n            check(jwk.n, '\"n\" (Modulus) Parameter');\n            components = { e: jwk.e, kty: jwk.kty, n: jwk.n };\n            break;\n        case 'oct':\n            check(jwk.k, '\"k\" (Key Value) Parameter');\n            components = { k: jwk.k, kty: jwk.kty };\n            break;\n        default:\n            throw new JOSENotSupported('\"kty\" (Key Type) Parameter missing or unsupported');\n    }\n    const data = encoder.encode(JSON.stringify(components));\n    return base64url(await digest(digestAlgorithm, data));\n}\nexport async function calculateJwkThumbprintUri(jwk, digestAlgorithm) {\n    digestAlgorithm !== null && digestAlgorithm !== void 0 ? digestAlgorithm : (digestAlgorithm = 'sha256');\n    const thumbprint = await calculateJwkThumbprint(jwk, digestAlgorithm);\n    return `urn:ietf:params:oauth:jwk-thumbprint:sha-${digestAlgorithm.slice(-3)}:${thumbprint}`;\n}\n","import { importJWK } from '../key/import.js';\nimport { JWKSInvalid, JOSENotSupported, JWKSNoMatchingKey, JWKSMultipleMatchingKeys, } from '../util/errors.js';\nimport isObject from '../lib/is_object.js';\nfunction getKtyFromAlg(alg) {\n    switch (typeof alg === 'string' && alg.slice(0, 2)) {\n        case 'RS':\n        case 'PS':\n            return 'RSA';\n        case 'ES':\n            return 'EC';\n        case 'Ed':\n            return 'OKP';\n        default:\n            throw new JOSENotSupported('Unsupported \"alg\" value for a JSON Web Key Set');\n    }\n}\nexport function isJWKSLike(jwks) {\n    return (jwks &&\n        typeof jwks === 'object' &&\n        Array.isArray(jwks.keys) &&\n        jwks.keys.every(isJWKLike));\n}\nfunction isJWKLike(key) {\n    return isObject(key);\n}\nfunction clone(obj) {\n    if (typeof structuredClone === 'function') {\n        return structuredClone(obj);\n    }\n    return JSON.parse(JSON.stringify(obj));\n}\nexport class LocalJWKSet {\n    constructor(jwks) {\n        this._cached = new WeakMap();\n        if (!isJWKSLike(jwks)) {\n            throw new JWKSInvalid('JSON Web Key Set malformed');\n        }\n        this._jwks = clone(jwks);\n    }\n    async getKey(protectedHeader, token) {\n        const { alg, kid } = { ...protectedHeader, ...token === null || token === void 0 ? void 0 : token.header };\n        const kty = getKtyFromAlg(alg);\n        const candidates = this._jwks.keys.filter((jwk) => {\n            let candidate = kty === jwk.kty;\n            if (candidate && typeof kid === 'string') {\n                candidate = kid === jwk.kid;\n            }\n            if (candidate && typeof jwk.alg === 'string') {\n                candidate = alg === jwk.alg;\n            }\n            if (candidate && typeof jwk.use === 'string') {\n                candidate = jwk.use === 'sig';\n            }\n            if (candidate && Array.isArray(jwk.key_ops)) {\n                candidate = jwk.key_ops.includes('verify');\n            }\n            if (candidate && alg === 'EdDSA') {\n                candidate = jwk.crv === 'Ed25519' || jwk.crv === 'Ed448';\n            }\n            if (candidate) {\n                switch (alg) {\n                    case 'ES256':\n                        candidate = jwk.crv === 'P-256';\n                        break;\n                    case 'ES256K':\n                        candidate = jwk.crv === 'secp256k1';\n                        break;\n                    case 'ES384':\n                        candidate = jwk.crv === 'P-384';\n                        break;\n                    case 'ES512':\n                        candidate = jwk.crv === 'P-521';\n                        break;\n                }\n            }\n            return candidate;\n        });\n        const { 0: jwk, length } = candidates;\n        if (length === 0) {\n            throw new JWKSNoMatchingKey();\n        }\n        else if (length !== 1) {\n            const error = new JWKSMultipleMatchingKeys();\n            const { _cached } = this;\n            error[Symbol.asyncIterator] = async function* () {\n                for (const jwk of candidates) {\n                    try {\n                        yield await importWithAlgCache(_cached, jwk, alg);\n                    }\n                    catch (_a) {\n                        continue;\n                    }\n                }\n            };\n            throw error;\n        }\n        return importWithAlgCache(this._cached, jwk, alg);\n    }\n}\nasync function importWithAlgCache(cache, jwk, alg) {\n    const cached = cache.get(jwk) || cache.set(jwk, {}).get(jwk);\n    if (cached[alg] === undefined) {\n        const key = await importJWK({ ...jwk, ext: true }, alg);\n        if (key instanceof Uint8Array || key.type !== 'public') {\n            throw new JWKSInvalid('JSON Web Key Set members must be public keys');\n        }\n        cached[alg] = key;\n    }\n    return cached[alg];\n}\nexport function createLocalJWKSet(jwks) {\n    const set = new LocalJWKSet(jwks);\n    return async function (protectedHeader, token) {\n        return set.getKey(protectedHeader, token);\n    };\n}\n","import fetchJwks from '../runtime/fetch_jwks.js';\nimport { JWKSInvalid, JWKSNoMatchingKey } from '../util/errors.js';\nimport { isJWKSLike, LocalJWKSet } from './local.js';\nfunction isCloudflareWorkers() {\n    return (typeof WebSocketPair !== 'undefined' ||\n        (typeof navigator !== 'undefined' && navigator.userAgent === 'Cloudflare-Workers') ||\n        (typeof EdgeRuntime !== 'undefined' && EdgeRuntime === 'vercel'));\n}\nclass RemoteJWKSet extends LocalJWKSet {\n    constructor(url, options) {\n        super({ keys: [] });\n        this._jwks = undefined;\n        if (!(url instanceof URL)) {\n            throw new TypeError('url must be an instance of URL');\n        }\n        this._url = new URL(url.href);\n        this._options = { agent: options === null || options === void 0 ? void 0 : options.agent, headers: options === null || options === void 0 ? void 0 : options.headers };\n        this._timeoutDuration =\n            typeof (options === null || options === void 0 ? void 0 : options.timeoutDuration) === 'number' ? options === null || options === void 0 ? void 0 : options.timeoutDuration : 5000;\n        this._cooldownDuration =\n            typeof (options === null || options === void 0 ? void 0 : options.cooldownDuration) === 'number' ? options === null || options === void 0 ? void 0 : options.cooldownDuration : 30000;\n        this._cacheMaxAge = typeof (options === null || options === void 0 ? void 0 : options.cacheMaxAge) === 'number' ? options === null || options === void 0 ? void 0 : options.cacheMaxAge : 600000;\n    }\n    coolingDown() {\n        return typeof this._jwksTimestamp === 'number'\n            ? Date.now() < this._jwksTimestamp + this._cooldownDuration\n            : false;\n    }\n    fresh() {\n        return typeof this._jwksTimestamp === 'number'\n            ? Date.now() < this._jwksTimestamp + this._cacheMaxAge\n            : false;\n    }\n    async getKey(protectedHeader, token) {\n        if (!this._jwks || !this.fresh()) {\n            await this.reload();\n        }\n        try {\n            return await super.getKey(protectedHeader, token);\n        }\n        catch (err) {\n            if (err instanceof JWKSNoMatchingKey) {\n                if (this.coolingDown() === false) {\n                    await this.reload();\n                    return super.getKey(protectedHeader, token);\n                }\n            }\n            throw err;\n        }\n    }\n    async reload() {\n        if (this._pendingFetch && isCloudflareWorkers()) {\n            this._pendingFetch = undefined;\n        }\n        this._pendingFetch || (this._pendingFetch = fetchJwks(this._url, this._timeoutDuration, this._options)\n            .then((json) => {\n            if (!isJWKSLike(json)) {\n                throw new JWKSInvalid('JSON Web Key Set malformed');\n            }\n            this._jwks = { keys: json.keys };\n            this._jwksTimestamp = Date.now();\n            this._pendingFetch = undefined;\n        })\n            .catch((err) => {\n            this._pendingFetch = undefined;\n            throw err;\n        }));\n        await this._pendingFetch;\n    }\n}\nexport function createRemoteJWKSet(url, options) {\n    const set = new RemoteJWKSet(url, options);\n    return async function (protectedHeader, token) {\n        return set.getKey(protectedHeader, token);\n    };\n}\n","import { FlattenedSign } from '../flattened/sign.js';\nexport class CompactSign {\n    constructor(payload) {\n        this._flattened = new FlattenedSign(payload);\n    }\n    setProtectedHeader(protectedHeader) {\n        this._flattened.setProtectedHeader(protectedHeader);\n        return this;\n    }\n    async sign(key, options) {\n        const jws = await this._flattened.sign(key, options);\n        if (jws.payload === undefined) {\n            throw new TypeError('use the flattened module for creating JWS with b64: false');\n        }\n        return `${jws.protected}.${jws.payload}.${jws.signature}`;\n    }\n}\n","import { flattenedVerify } from '../flattened/verify.js';\nimport { JWSInvalid } from '../../util/errors.js';\nimport { decoder } from '../../lib/buffer_utils.js';\nexport async function compactVerify(jws, key, options) {\n    if (jws instanceof Uint8Array) {\n        jws = decoder.decode(jws);\n    }\n    if (typeof jws !== 'string') {\n        throw new JWSInvalid('Compact JWS must be a string or Uint8Array');\n    }\n    const { 0: protectedHeader, 1: payload, 2: signature, length } = jws.split('.');\n    if (length !== 3) {\n        throw new JWSInvalid('Invalid Compact JWS');\n    }\n    const verified = await flattenedVerify({ payload, protected: protectedHeader, signature }, key, options);\n    const result = { payload: verified.payload, protectedHeader: verified.protectedHeader };\n    if (typeof key === 'function') {\n        return { ...result, key: verified.key };\n    }\n    return result;\n}\n","import { encode as base64url } from '../../runtime/base64url.js';\nimport sign from '../../runtime/sign.js';\nimport isDisjoint from '../../lib/is_disjoint.js';\nimport { JWSInvalid } from '../../util/errors.js';\nimport { encoder, decoder, concat } from '../../lib/buffer_utils.js';\nimport checkKeyType from '../../lib/check_key_type.js';\nimport validateCrit from '../../lib/validate_crit.js';\nexport class FlattenedSign {\n    constructor(payload) {\n        if (!(payload instanceof Uint8Array)) {\n            throw new TypeError('payload must be an instance of Uint8Array');\n        }\n        this._payload = payload;\n    }\n    setProtectedHeader(protectedHeader) {\n        if (this._protectedHeader) {\n            throw new TypeError('setProtectedHeader can only be called once');\n        }\n        this._protectedHeader = protectedHeader;\n        return this;\n    }\n    setUnprotectedHeader(unprotectedHeader) {\n        if (this._unprotectedHeader) {\n            throw new TypeError('setUnprotectedHeader can only be called once');\n        }\n        this._unprotectedHeader = unprotectedHeader;\n        return this;\n    }\n    async sign(key, options) {\n        if (!this._protectedHeader && !this._unprotectedHeader) {\n            throw new JWSInvalid('either setProtectedHeader or setUnprotectedHeader must be called before #sign()');\n        }\n        if (!isDisjoint(this._protectedHeader, this._unprotectedHeader)) {\n            throw new JWSInvalid('JWS Protected and JWS Unprotected Header Parameter names must be disjoint');\n        }\n        const joseHeader = {\n            ...this._protectedHeader,\n            ...this._unprotectedHeader,\n        };\n        const extensions = validateCrit(JWSInvalid, new Map([['b64', true]]), options === null || options === void 0 ? void 0 : options.crit, this._protectedHeader, joseHeader);\n        let b64 = true;\n        if (extensions.has('b64')) {\n            b64 = this._protectedHeader.b64;\n            if (typeof b64 !== 'boolean') {\n                throw new JWSInvalid('The \"b64\" (base64url-encode payload) Header Parameter must be a boolean');\n            }\n        }\n        const { alg } = joseHeader;\n        if (typeof alg !== 'string' || !alg) {\n            throw new JWSInvalid('JWS \"alg\" (Algorithm) Header Parameter missing or invalid');\n        }\n        checkKeyType(alg, key, 'sign');\n        let payload = this._payload;\n        if (b64) {\n            payload = encoder.encode(base64url(payload));\n        }\n        let protectedHeader;\n        if (this._protectedHeader) {\n            protectedHeader = encoder.encode(base64url(JSON.stringify(this._protectedHeader)));\n        }\n        else {\n            protectedHeader = encoder.encode('');\n        }\n        const data = concat(protectedHeader, encoder.encode('.'), payload);\n        const signature = await sign(alg, key, data);\n        const jws = {\n            signature: base64url(signature),\n            payload: '',\n        };\n        if (b64) {\n            jws.payload = decoder.decode(payload);\n        }\n        if (this._unprotectedHeader) {\n            jws.header = this._unprotectedHeader;\n        }\n        if (this._protectedHeader) {\n            jws.protected = decoder.decode(protectedHeader);\n        }\n        return jws;\n    }\n}\n","import { decode as base64url } from '../../runtime/base64url.js';\nimport verify from '../../runtime/verify.js';\nimport { JOSEAlgNotAllowed, JWSInvalid, JWSSignatureVerificationFailed } from '../../util/errors.js';\nimport { concat, encoder, decoder } from '../../lib/buffer_utils.js';\nimport isDisjoint from '../../lib/is_disjoint.js';\nimport isObject from '../../lib/is_object.js';\nimport checkKeyType from '../../lib/check_key_type.js';\nimport validateCrit from '../../lib/validate_crit.js';\nimport validateAlgorithms from '../../lib/validate_algorithms.js';\nexport async function flattenedVerify(jws, key, options) {\n    var _a;\n    if (!isObject(jws)) {\n        throw new JWSInvalid('Flattened JWS must be an object');\n    }\n    if (jws.protected === undefined && jws.header === undefined) {\n        throw new JWSInvalid('Flattened JWS must have either of the \"protected\" or \"header\" members');\n    }\n    if (jws.protected !== undefined && typeof jws.protected !== 'string') {\n        throw new JWSInvalid('JWS Protected Header incorrect type');\n    }\n    if (jws.payload === undefined) {\n        throw new JWSInvalid('JWS Payload missing');\n    }\n    if (typeof jws.signature !== 'string') {\n        throw new JWSInvalid('JWS Signature missing or incorrect type');\n    }\n    if (jws.header !== undefined && !isObject(jws.header)) {\n        throw new JWSInvalid('JWS Unprotected Header incorrect type');\n    }\n    let parsedProt = {};\n    if (jws.protected) {\n        try {\n            const protectedHeader = base64url(jws.protected);\n            parsedProt = JSON.parse(decoder.decode(protectedHeader));\n        }\n        catch (_b) {\n            throw new JWSInvalid('JWS Protected Header is invalid');\n        }\n    }\n    if (!isDisjoint(parsedProt, jws.header)) {\n        throw new JWSInvalid('JWS Protected and JWS Unprotected Header Parameter names must be disjoint');\n    }\n    const joseHeader = {\n        ...parsedProt,\n        ...jws.header,\n    };\n    const extensions = validateCrit(JWSInvalid, new Map([['b64', true]]), options === null || options === void 0 ? void 0 : options.crit, parsedProt, joseHeader);\n    let b64 = true;\n    if (extensions.has('b64')) {\n        b64 = parsedProt.b64;\n        if (typeof b64 !== 'boolean') {\n            throw new JWSInvalid('The \"b64\" (base64url-encode payload) Header Parameter must be a boolean');\n        }\n    }\n    const { alg } = joseHeader;\n    if (typeof alg !== 'string' || !alg) {\n        throw new JWSInvalid('JWS \"alg\" (Algorithm) Header Parameter missing or invalid');\n    }\n    const algorithms = options && validateAlgorithms('algorithms', options.algorithms);\n    if (algorithms && !algorithms.has(alg)) {\n        throw new JOSEAlgNotAllowed('\"alg\" (Algorithm) Header Parameter not allowed');\n    }\n    if (b64) {\n        if (typeof jws.payload !== 'string') {\n            throw new JWSInvalid('JWS Payload must be a string');\n        }\n    }\n    else if (typeof jws.payload !== 'string' && !(jws.payload instanceof Uint8Array)) {\n        throw new JWSInvalid('JWS Payload must be a string or an Uint8Array instance');\n    }\n    let resolvedKey = false;\n    if (typeof key === 'function') {\n        key = await key(parsedProt, jws);\n        resolvedKey = true;\n    }\n    checkKeyType(alg, key, 'verify');\n    const data = concat(encoder.encode((_a = jws.protected) !== null && _a !== void 0 ? _a : ''), encoder.encode('.'), typeof jws.payload === 'string' ? encoder.encode(jws.payload) : jws.payload);\n    let signature;\n    try {\n        signature = base64url(jws.signature);\n    }\n    catch (_c) {\n        throw new JWSInvalid('Failed to base64url decode the signature');\n    }\n    const verified = await verify(alg, key, signature, data);\n    if (!verified) {\n        throw new JWSSignatureVerificationFailed();\n    }\n    let payload;\n    if (b64) {\n        try {\n            payload = base64url(jws.payload);\n        }\n        catch (_d) {\n            throw new JWSInvalid('Failed to base64url decode the payload');\n        }\n    }\n    else if (typeof jws.payload === 'string') {\n        payload = encoder.encode(jws.payload);\n    }\n    else {\n        payload = jws.payload;\n    }\n    const result = { payload };\n    if (jws.protected !== undefined) {\n        result.protectedHeader = parsedProt;\n    }\n    if (jws.header !== undefined) {\n        result.unprotectedHeader = jws.header;\n    }\n    if (resolvedKey) {\n        return { ...result, key };\n    }\n    return result;\n}\n","import { FlattenedSign } from '../flattened/sign.js';\nimport { JWSInvalid } from '../../util/errors.js';\nclass IndividualSignature {\n    constructor(sig, key, options) {\n        this.parent = sig;\n        this.key = key;\n        this.options = options;\n    }\n    setProtectedHeader(protectedHeader) {\n        if (this.protectedHeader) {\n            throw new TypeError('setProtectedHeader can only be called once');\n        }\n        this.protectedHeader = protectedHeader;\n        return this;\n    }\n    setUnprotectedHeader(unprotectedHeader) {\n        if (this.unprotectedHeader) {\n            throw new TypeError('setUnprotectedHeader can only be called once');\n        }\n        this.unprotectedHeader = unprotectedHeader;\n        return this;\n    }\n    addSignature(...args) {\n        return this.parent.addSignature(...args);\n    }\n    sign(...args) {\n        return this.parent.sign(...args);\n    }\n    done() {\n        return this.parent;\n    }\n}\nexport class GeneralSign {\n    constructor(payload) {\n        this._signatures = [];\n        this._payload = payload;\n    }\n    addSignature(key, options) {\n        const signature = new IndividualSignature(this, key, options);\n        this._signatures.push(signature);\n        return signature;\n    }\n    async sign() {\n        if (!this._signatures.length) {\n            throw new JWSInvalid('at least one signature must be added');\n        }\n        const jws = {\n            signatures: [],\n            payload: '',\n        };\n        for (let i = 0; i < this._signatures.length; i++) {\n            const signature = this._signatures[i];\n            const flattened = new FlattenedSign(this._payload);\n            flattened.setProtectedHeader(signature.protectedHeader);\n            flattened.setUnprotectedHeader(signature.unprotectedHeader);\n            const { payload, ...rest } = await flattened.sign(signature.key, signature.options);\n            if (i === 0) {\n                jws.payload = payload;\n            }\n            else if (jws.payload !== payload) {\n                throw new JWSInvalid('inconsistent use of JWS Unencoded Payload (RFC7797)');\n            }\n            jws.signatures.push(rest);\n        }\n        return jws;\n    }\n}\n","import { flattenedVerify } from '../flattened/verify.js';\nimport { JWSInvalid, JWSSignatureVerificationFailed } from '../../util/errors.js';\nimport isObject from '../../lib/is_object.js';\nexport async function generalVerify(jws, key, options) {\n    if (!isObject(jws)) {\n        throw new JWSInvalid('General JWS must be an object');\n    }\n    if (!Array.isArray(jws.signatures) || !jws.signatures.every(isObject)) {\n        throw new JWSInvalid('JWS Signatures missing or incorrect type');\n    }\n    for (const signature of jws.signatures) {\n        try {\n            return await flattenedVerify({\n                header: signature.header,\n                payload: jws.payload,\n                protected: signature.protected,\n                signature: signature.signature,\n            }, key, options);\n        }\n        catch (_a) {\n        }\n    }\n    throw new JWSSignatureVerificationFailed();\n}\n","import { compactDecrypt } from '../jwe/compact/decrypt.js';\nimport jwtPayload from '../lib/jwt_claims_set.js';\nimport { JWTClaimValidationFailed } from '../util/errors.js';\nexport async function jwtDecrypt(jwt, key, options) {\n    const decrypted = await compactDecrypt(jwt, key, options);\n    const payload = jwtPayload(decrypted.protectedHeader, decrypted.plaintext, options);\n    const { protectedHeader } = decrypted;\n    if (protectedHeader.iss !== undefined && protectedHeader.iss !== payload.iss) {\n        throw new JWTClaimValidationFailed('replicated \"iss\" claim header parameter mismatch', 'iss', 'mismatch');\n    }\n    if (protectedHeader.sub !== undefined && protectedHeader.sub !== payload.sub) {\n        throw new JWTClaimValidationFailed('replicated \"sub\" claim header parameter mismatch', 'sub', 'mismatch');\n    }\n    if (protectedHeader.aud !== undefined &&\n        JSON.stringify(protectedHeader.aud) !== JSON.stringify(payload.aud)) {\n        throw new JWTClaimValidationFailed('replicated \"aud\" claim header parameter mismatch', 'aud', 'mismatch');\n    }\n    const result = { payload, protectedHeader };\n    if (typeof key === 'function') {\n        return { ...result, key: decrypted.key };\n    }\n    return result;\n}\n","import { CompactEncrypt } from '../jwe/compact/encrypt.js';\nimport { encoder } from '../lib/buffer_utils.js';\nimport { ProduceJWT } from './produce.js';\nexport class EncryptJWT extends ProduceJWT {\n    setProtectedHeader(protectedHeader) {\n        if (this._protectedHeader) {\n            throw new TypeError('setProtectedHeader can only be called once');\n        }\n        this._protectedHeader = protectedHeader;\n        return this;\n    }\n    setKeyManagementParameters(parameters) {\n        if (this._keyManagementParameters) {\n            throw new TypeError('setKeyManagementParameters can only be called once');\n        }\n        this._keyManagementParameters = parameters;\n        return this;\n    }\n    setContentEncryptionKey(cek) {\n        if (this._cek) {\n            throw new TypeError('setContentEncryptionKey can only be called once');\n        }\n        this._cek = cek;\n        return this;\n    }\n    setInitializationVector(iv) {\n        if (this._iv) {\n            throw new TypeError('setInitializationVector can only be called once');\n        }\n        this._iv = iv;\n        return this;\n    }\n    replicateIssuerAsHeader() {\n        this._replicateIssuerAsHeader = true;\n        return this;\n    }\n    replicateSubjectAsHeader() {\n        this._replicateSubjectAsHeader = true;\n        return this;\n    }\n    replicateAudienceAsHeader() {\n        this._replicateAudienceAsHeader = true;\n        return this;\n    }\n    async encrypt(key, options) {\n        const enc = new CompactEncrypt(encoder.encode(JSON.stringify(this._payload)));\n        if (this._replicateIssuerAsHeader) {\n            this._protectedHeader = { ...this._protectedHeader, iss: this._payload.iss };\n        }\n        if (this._replicateSubjectAsHeader) {\n            this._protectedHeader = { ...this._protectedHeader, sub: this._payload.sub };\n        }\n        if (this._replicateAudienceAsHeader) {\n            this._protectedHeader = { ...this._protectedHeader, aud: this._payload.aud };\n        }\n        enc.setProtectedHeader(this._protectedHeader);\n        if (this._iv) {\n            enc.setInitializationVector(this._iv);\n        }\n        if (this._cek) {\n            enc.setContentEncryptionKey(this._cek);\n        }\n        if (this._keyManagementParameters) {\n            enc.setKeyManagementParameters(this._keyManagementParameters);\n        }\n        return enc.encrypt(key, options);\n    }\n}\n","import epoch from '../lib/epoch.js';\nimport isObject from '../lib/is_object.js';\nimport secs from '../lib/secs.js';\nexport class ProduceJWT {\n    constructor(payload) {\n        if (!isObject(payload)) {\n            throw new TypeError('JWT Claims Set MUST be an object');\n        }\n        this._payload = payload;\n    }\n    setIssuer(issuer) {\n        this._payload = { ...this._payload, iss: issuer };\n        return this;\n    }\n    setSubject(subject) {\n        this._payload = { ...this._payload, sub: subject };\n        return this;\n    }\n    setAudience(audience) {\n        this._payload = { ...this._payload, aud: audience };\n        return this;\n    }\n    setJti(jwtId) {\n        this._payload = { ...this._payload, jti: jwtId };\n        return this;\n    }\n    setNotBefore(input) {\n        if (typeof input === 'number') {\n            this._payload = { ...this._payload, nbf: input };\n        }\n        else {\n            this._payload = { ...this._payload, nbf: epoch(new Date()) + secs(input) };\n        }\n        return this;\n    }\n    setExpirationTime(input) {\n        if (typeof input === 'number') {\n            this._payload = { ...this._payload, exp: input };\n        }\n        else {\n            this._payload = { ...this._payload, exp: epoch(new Date()) + secs(input) };\n        }\n        return this;\n    }\n    setIssuedAt(input) {\n        if (typeof input === 'undefined') {\n            this._payload = { ...this._payload, iat: epoch(new Date()) };\n        }\n        else {\n            this._payload = { ...this._payload, iat: input };\n        }\n        return this;\n    }\n}\n","import { CompactSign } from '../jws/compact/sign.js';\nimport { JWTInvalid } from '../util/errors.js';\nimport { encoder } from '../lib/buffer_utils.js';\nimport { ProduceJWT } from './produce.js';\nexport class SignJWT extends ProduceJWT {\n    setProtectedHeader(protectedHeader) {\n        this._protectedHeader = protectedHeader;\n        return this;\n    }\n    async sign(key, options) {\n        var _a;\n        const sig = new CompactSign(encoder.encode(JSON.stringify(this._payload)));\n        sig.setProtectedHeader(this._protectedHeader);\n        if (Array.isArray((_a = this._protectedHeader) === null || _a === void 0 ? void 0 : _a.crit) &&\n            this._protectedHeader.crit.includes('b64') &&\n            this._protectedHeader.b64 === false) {\n            throw new JWTInvalid('JWTs MUST NOT use unencoded payload');\n        }\n        return sig.sign(key, options);\n    }\n}\n","import * as base64url from '../runtime/base64url.js';\nimport { decoder } from '../lib/buffer_utils.js';\nimport { JWTInvalid } from '../util/errors.js';\nimport jwtPayload from '../lib/jwt_claims_set.js';\nimport { ProduceJWT } from './produce.js';\nexport class UnsecuredJWT extends ProduceJWT {\n    encode() {\n        const header = base64url.encode(JSON.stringify({ alg: 'none' }));\n        const payload = base64url.encode(JSON.stringify(this._payload));\n        return `${header}.${payload}.`;\n    }\n    static decode(jwt, options) {\n        if (typeof jwt !== 'string') {\n            throw new JWTInvalid('Unsecured JWT must be a string');\n        }\n        const { 0: encodedHeader, 1: encodedPayload, 2: signature, length } = jwt.split('.');\n        if (length !== 3 || signature !== '') {\n            throw new JWTInvalid('Invalid Unsecured JWT');\n        }\n        let header;\n        try {\n            header = JSON.parse(decoder.decode(base64url.decode(encodedHeader)));\n            if (header.alg !== 'none')\n                throw new Error();\n        }\n        catch (_a) {\n            throw new JWTInvalid('Invalid Unsecured JWT');\n        }\n        const payload = jwtPayload(header, base64url.decode(encodedPayload), options);\n        return { payload, header };\n    }\n}\n","import { compactVerify } from '../jws/compact/verify.js';\nimport jwtPayload from '../lib/jwt_claims_set.js';\nimport { JWTInvalid } from '../util/errors.js';\nexport async function jwtVerify(jwt, key, options) {\n    var _a;\n    const verified = await compactVerify(jwt, key, options);\n    if (((_a = verified.protectedHeader.crit) === null || _a === void 0 ? void 0 : _a.includes('b64')) && verified.protectedHeader.b64 === false) {\n        throw new JWTInvalid('JWTs MUST NOT use unencoded payload');\n    }\n    const payload = jwtPayload(verified.protectedHeader, verified.payload, options);\n    const result = { payload, protectedHeader: verified.protectedHeader };\n    if (typeof key === 'function') {\n        return { ...result, key: verified.key };\n    }\n    return result;\n}\n","import { toSPKI as exportPublic } from '../runtime/asn1.js';\nimport { toPKCS8 as exportPrivate } from '../runtime/asn1.js';\nimport keyToJWK from '../runtime/key_to_jwk.js';\nexport async function exportSPKI(key) {\n    return exportPublic(key);\n}\nexport async function exportPKCS8(key) {\n    return exportPrivate(key);\n}\nexport async function exportJWK(key) {\n    return keyToJWK(key);\n}\n","import { generateKeyPair as generate } from '../runtime/generate.js';\nexport async function generateKeyPair(alg, options) {\n    return generate(alg, options);\n}\n","import { generateSecret as generate } from '../runtime/generate.js';\nexport async function generateSecret(alg, options) {\n    return generate(alg, options);\n}\n","import { decode as decodeBase64URL } from '../runtime/base64url.js';\nimport { fromSPKI, fromPKCS8, fromX509 } from '../runtime/asn1.js';\nimport asKeyObject from '../runtime/jwk_to_key.js';\nimport { JOSENotSupported } from '../util/errors.js';\nimport isObject from '../lib/is_object.js';\nexport async function importSPKI(spki, alg, options) {\n    if (typeof spki !== 'string' || spki.indexOf('-----BEGIN PUBLIC KEY-----') !== 0) {\n        throw new TypeError('\"spki\" must be SPKI formatted string');\n    }\n    return fromSPKI(spki, alg, options);\n}\nexport async function importX509(x509, alg, options) {\n    if (typeof x509 !== 'string' || x509.indexOf('-----BEGIN CERTIFICATE-----') !== 0) {\n        throw new TypeError('\"x509\" must be X.509 formatted string');\n    }\n    return fromX509(x509, alg, options);\n}\nexport async function importPKCS8(pkcs8, alg, options) {\n    if (typeof pkcs8 !== 'string' || pkcs8.indexOf('-----BEGIN PRIVATE KEY-----') !== 0) {\n        throw new TypeError('\"pkcs8\" must be PKCS#8 formatted string');\n    }\n    return fromPKCS8(pkcs8, alg, options);\n}\nexport async function importJWK(jwk, alg, octAsKeyObject) {\n    var _a;\n    if (!isObject(jwk)) {\n        throw new TypeError('JWK must be an object');\n    }\n    alg || (alg = jwk.alg);\n    switch (jwk.kty) {\n        case 'oct':\n            if (typeof jwk.k !== 'string' || !jwk.k) {\n                throw new TypeError('missing \"k\" (Key Value) Parameter value');\n            }\n            octAsKeyObject !== null && octAsKeyObject !== void 0 ? octAsKeyObject : (octAsKeyObject = jwk.ext !== true);\n            if (octAsKeyObject) {\n                return asKeyObject({ ...jwk, alg, ext: (_a = jwk.ext) !== null && _a !== void 0 ? _a : false });\n            }\n            return decodeBase64URL(jwk.k);\n        case 'RSA':\n            if (jwk.oth !== undefined) {\n                throw new JOSENotSupported('RSA JWK \"oth\" (Other Primes Info) Parameter value is not supported');\n            }\n        case 'EC':\n        case 'OKP':\n            return asKeyObject({ ...jwk, alg });\n        default:\n            throw new JOSENotSupported('Unsupported \"kty\" (Key Type) Parameter value');\n    }\n}\n","import encrypt from '../runtime/encrypt.js';\nimport decrypt from '../runtime/decrypt.js';\nimport generateIv from './iv.js';\nimport { encode as base64url } from '../runtime/base64url.js';\nexport async function wrap(alg, key, cek, iv) {\n    const jweAlgorithm = alg.slice(0, 7);\n    iv || (iv = generateIv(jweAlgorithm));\n    const { ciphertext: encryptedKey, tag } = await encrypt(jweAlgorithm, cek, key, iv, new Uint8Array(0));\n    return { encryptedKey, iv: base64url(iv), tag: base64url(tag) };\n}\nexport async function unwrap(alg, key, encryptedKey, iv, tag) {\n    const jweAlgorithm = alg.slice(0, 7);\n    return decrypt(jweAlgorithm, key, encryptedKey, iv, tag, new Uint8Array(0));\n}\n","import digest from '../runtime/digest.js';\nexport const encoder = new TextEncoder();\nexport const decoder = new TextDecoder();\nconst MAX_INT32 = 2 ** 32;\nexport function concat(...buffers) {\n    const size = buffers.reduce((acc, { length }) => acc + length, 0);\n    const buf = new Uint8Array(size);\n    let i = 0;\n    buffers.forEach((buffer) => {\n        buf.set(buffer, i);\n        i += buffer.length;\n    });\n    return buf;\n}\nexport function p2s(alg, p2sInput) {\n    return concat(encoder.encode(alg), new Uint8Array([0]), p2sInput);\n}\nfunction writeUInt32BE(buf, value, offset) {\n    if (value < 0 || value >= MAX_INT32) {\n        throw new RangeError(`value must be >= 0 and <= ${MAX_INT32 - 1}. Received ${value}`);\n    }\n    buf.set([value >>> 24, value >>> 16, value >>> 8, value & 0xff], offset);\n}\nexport function uint64be(value) {\n    const high = Math.floor(value / MAX_INT32);\n    const low = value % MAX_INT32;\n    const buf = new Uint8Array(8);\n    writeUInt32BE(buf, high, 0);\n    writeUInt32BE(buf, low, 4);\n    return buf;\n}\nexport function uint32be(value) {\n    const buf = new Uint8Array(4);\n    writeUInt32BE(buf, value);\n    return buf;\n}\nexport function lengthAndInput(input) {\n    return concat(uint32be(input.length), input);\n}\nexport async function concatKdf(secret, bits, value) {\n    const iterations = Math.ceil((bits >> 3) / 32);\n    const res = new Uint8Array(iterations * 32);\n    for (let iter = 0; iter < iterations; iter++) {\n        const buf = new Uint8Array(4 + secret.length + value.length);\n        buf.set(uint32be(iter + 1));\n        buf.set(secret, 4);\n        buf.set(value, 4 + secret.length);\n        res.set(await digest('sha256', buf), iter * 32);\n    }\n    return res.slice(0, bits >> 3);\n}\n","import { JOSENotSupported } from '../util/errors.js';\nimport random from '../runtime/random.js';\nexport function bitLength(alg) {\n    switch (alg) {\n        case 'A128GCM':\n            return 128;\n        case 'A192GCM':\n            return 192;\n        case 'A256GCM':\n        case 'A128CBC-HS256':\n            return 256;\n        case 'A192CBC-HS384':\n            return 384;\n        case 'A256CBC-HS512':\n            return 512;\n        default:\n            throw new JOSENotSupported(`Unsupported JWE Algorithm: ${alg}`);\n    }\n}\nexport default (alg) => random(new Uint8Array(bitLength(alg) >> 3));\n","import { JWEInvalid } from '../util/errors.js';\nimport { bitLength } from './iv.js';\nconst checkIvLength = (enc, iv) => {\n    if (iv.length << 3 !== bitLength(enc)) {\n        throw new JWEInvalid('Invalid Initialization Vector length');\n    }\n};\nexport default checkIvLength;\n","import { withAlg as invalidKeyInput } from './invalid_key_input.js';\nimport isKeyLike, { types } from '../runtime/is_key_like.js';\nconst symmetricTypeCheck = (alg, key) => {\n    if (key instanceof Uint8Array)\n        return;\n    if (!isKeyLike(key)) {\n        throw new TypeError(invalidKeyInput(alg, key, ...types, 'Uint8Array'));\n    }\n    if (key.type !== 'secret') {\n        throw new TypeError(`${types.join(' or ')} instances for symmetric algorithms must be of type \"secret\"`);\n    }\n};\nconst asymmetricTypeCheck = (alg, key, usage) => {\n    if (!isKeyLike(key)) {\n        throw new TypeError(invalidKeyInput(alg, key, ...types));\n    }\n    if (key.type === 'secret') {\n        throw new TypeError(`${types.join(' or ')} instances for asymmetric algorithms must not be of type \"secret\"`);\n    }\n    if (usage === 'sign' && key.type === 'public') {\n        throw new TypeError(`${types.join(' or ')} instances for asymmetric algorithm signing must be of type \"private\"`);\n    }\n    if (usage === 'decrypt' && key.type === 'public') {\n        throw new TypeError(`${types.join(' or ')} instances for asymmetric algorithm decryption must be of type \"private\"`);\n    }\n    if (key.algorithm && usage === 'verify' && key.type === 'private') {\n        throw new TypeError(`${types.join(' or ')} instances for asymmetric algorithm verifying must be of type \"public\"`);\n    }\n    if (key.algorithm && usage === 'encrypt' && key.type === 'private') {\n        throw new TypeError(`${types.join(' or ')} instances for asymmetric algorithm encryption must be of type \"public\"`);\n    }\n};\nconst checkKeyType = (alg, key, usage) => {\n    const symmetric = alg.startsWith('HS') ||\n        alg === 'dir' ||\n        alg.startsWith('PBES2') ||\n        /^A\\d{3}(?:GCM)?KW$/.test(alg);\n    if (symmetric) {\n        symmetricTypeCheck(alg, key);\n    }\n    else {\n        asymmetricTypeCheck(alg, key, usage);\n    }\n};\nexport default checkKeyType;\n","import { JWEInvalid } from '../util/errors.js';\nexport default function checkP2s(p2s) {\n    if (!(p2s instanceof Uint8Array) || p2s.length < 8) {\n        throw new JWEInvalid('PBES2 Salt Input must be 8 or more octets');\n    }\n}\n","function unusable(name, prop = 'algorithm.name') {\n    return new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);\n}\nfunction isAlgorithm(algorithm, name) {\n    return algorithm.name === name;\n}\nfunction getHashLength(hash) {\n    return parseInt(hash.name.slice(4), 10);\n}\nfunction getNamedCurve(alg) {\n    switch (alg) {\n        case 'ES256':\n            return 'P-256';\n        case 'ES384':\n            return 'P-384';\n        case 'ES512':\n            return 'P-521';\n        default:\n            throw new Error('unreachable');\n    }\n}\nfunction checkUsage(key, usages) {\n    if (usages.length && !usages.some((expected) => key.usages.includes(expected))) {\n        let msg = 'CryptoKey does not support this operation, its usages must include ';\n        if (usages.length > 2) {\n            const last = usages.pop();\n            msg += `one of ${usages.join(', ')}, or ${last}.`;\n        }\n        else if (usages.length === 2) {\n            msg += `one of ${usages[0]} or ${usages[1]}.`;\n        }\n        else {\n            msg += `${usages[0]}.`;\n        }\n        throw new TypeError(msg);\n    }\n}\nexport function checkSigCryptoKey(key, alg, ...usages) {\n    switch (alg) {\n        case 'HS256':\n        case 'HS384':\n        case 'HS512': {\n            if (!isAlgorithm(key.algorithm, 'HMAC'))\n                throw unusable('HMAC');\n            const expected = parseInt(alg.slice(2), 10);\n            const actual = getHashLength(key.algorithm.hash);\n            if (actual !== expected)\n                throw unusable(`SHA-${expected}`, 'algorithm.hash');\n            break;\n        }\n        case 'RS256':\n        case 'RS384':\n        case 'RS512': {\n            if (!isAlgorithm(key.algorithm, 'RSASSA-PKCS1-v1_5'))\n                throw unusable('RSASSA-PKCS1-v1_5');\n            const expected = parseInt(alg.slice(2), 10);\n            const actual = getHashLength(key.algorithm.hash);\n            if (actual !== expected)\n                throw unusable(`SHA-${expected}`, 'algorithm.hash');\n            break;\n        }\n        case 'PS256':\n        case 'PS384':\n        case 'PS512': {\n            if (!isAlgorithm(key.algorithm, 'RSA-PSS'))\n                throw unusable('RSA-PSS');\n            const expected = parseInt(alg.slice(2), 10);\n            const actual = getHashLength(key.algorithm.hash);\n            if (actual !== expected)\n                throw unusable(`SHA-${expected}`, 'algorithm.hash');\n            break;\n        }\n        case 'EdDSA': {\n            if (key.algorithm.name !== 'Ed25519' && key.algorithm.name !== 'Ed448') {\n                throw unusable('Ed25519 or Ed448');\n            }\n            break;\n        }\n        case 'ES256':\n        case 'ES384':\n        case 'ES512': {\n            if (!isAlgorithm(key.algorithm, 'ECDSA'))\n                throw unusable('ECDSA');\n            const expected = getNamedCurve(alg);\n            const actual = key.algorithm.namedCurve;\n            if (actual !== expected)\n                throw unusable(expected, 'algorithm.namedCurve');\n            break;\n        }\n        default:\n            throw new TypeError('CryptoKey does not support this operation');\n    }\n    checkUsage(key, usages);\n}\nexport function checkEncCryptoKey(key, alg, ...usages) {\n    switch (alg) {\n        case 'A128GCM':\n        case 'A192GCM':\n        case 'A256GCM': {\n            if (!isAlgorithm(key.algorithm, 'AES-GCM'))\n                throw unusable('AES-GCM');\n            const expected = parseInt(alg.slice(1, 4), 10);\n            const actual = key.algorithm.length;\n            if (actual !== expected)\n                throw unusable(expected, 'algorithm.length');\n            break;\n        }\n        case 'A128KW':\n        case 'A192KW':\n        case 'A256KW': {\n            if (!isAlgorithm(key.algorithm, 'AES-KW'))\n                throw unusable('AES-KW');\n            const expected = parseInt(alg.slice(1, 4), 10);\n            const actual = key.algorithm.length;\n            if (actual !== expected)\n                throw unusable(expected, 'algorithm.length');\n            break;\n        }\n        case 'ECDH': {\n            switch (key.algorithm.name) {\n                case 'ECDH':\n                case 'X25519':\n                case 'X448':\n                    break;\n                default:\n                    throw unusable('ECDH, X25519, or X448');\n            }\n            break;\n        }\n        case 'PBES2-HS256+A128KW':\n        case 'PBES2-HS384+A192KW':\n        case 'PBES2-HS512+A256KW':\n            if (!isAlgorithm(key.algorithm, 'PBKDF2'))\n                throw unusable('PBKDF2');\n            break;\n        case 'RSA-OAEP':\n        case 'RSA-OAEP-256':\n        case 'RSA-OAEP-384':\n        case 'RSA-OAEP-512': {\n            if (!isAlgorithm(key.algorithm, 'RSA-OAEP'))\n                throw unusable('RSA-OAEP');\n            const expected = parseInt(alg.slice(9), 10) || 1;\n            const actual = getHashLength(key.algorithm.hash);\n            if (actual !== expected)\n                throw unusable(`SHA-${expected}`, 'algorithm.hash');\n            break;\n        }\n        default:\n            throw new TypeError('CryptoKey does not support this operation');\n    }\n    checkUsage(key, usages);\n}\n","import { unwrap as aesKw } from '../runtime/aeskw.js';\nimport * as ECDH from '../runtime/ecdhes.js';\nimport { decrypt as pbes2Kw } from '../runtime/pbes2kw.js';\nimport { decrypt as rsaEs } from '../runtime/rsaes.js';\nimport { decode as base64url } from '../runtime/base64url.js';\nimport { JOSENotSupported, JWEInvalid } from '../util/errors.js';\nimport { bitLength as cekLength } from '../lib/cek.js';\nimport { importJWK } from '../key/import.js';\nimport checkKeyType from './check_key_type.js';\nimport isObject from './is_object.js';\nimport { unwrap as aesGcmKw } from './aesgcmkw.js';\nasync function decryptKeyManagement(alg, key, encryptedKey, joseHeader, options) {\n    checkKeyType(alg, key, 'decrypt');\n    switch (alg) {\n        case 'dir': {\n            if (encryptedKey !== undefined)\n                throw new JWEInvalid('Encountered unexpected JWE Encrypted Key');\n            return key;\n        }\n        case 'ECDH-ES':\n            if (encryptedKey !== undefined)\n                throw new JWEInvalid('Encountered unexpected JWE Encrypted Key');\n        case 'ECDH-ES+A128KW':\n        case 'ECDH-ES+A192KW':\n        case 'ECDH-ES+A256KW': {\n            if (!isObject(joseHeader.epk))\n                throw new JWEInvalid(`JOSE Header \"epk\" (Ephemeral Public Key) missing or invalid`);\n            if (!ECDH.ecdhAllowed(key))\n                throw new JOSENotSupported('ECDH with the provided key is not allowed or not supported by your javascript runtime');\n            const epk = await importJWK(joseHeader.epk, alg);\n            let partyUInfo;\n            let partyVInfo;\n            if (joseHeader.apu !== undefined) {\n                if (typeof joseHeader.apu !== 'string')\n                    throw new JWEInvalid(`JOSE Header \"apu\" (Agreement PartyUInfo) invalid`);\n                try {\n                    partyUInfo = base64url(joseHeader.apu);\n                }\n                catch (_a) {\n                    throw new JWEInvalid('Failed to base64url decode the apu');\n                }\n            }\n            if (joseHeader.apv !== undefined) {\n                if (typeof joseHeader.apv !== 'string')\n                    throw new JWEInvalid(`JOSE Header \"apv\" (Agreement PartyVInfo) invalid`);\n                try {\n                    partyVInfo = base64url(joseHeader.apv);\n                }\n                catch (_b) {\n                    throw new JWEInvalid('Failed to base64url decode the apv');\n                }\n            }\n            const sharedSecret = await ECDH.deriveKey(epk, key, alg === 'ECDH-ES' ? joseHeader.enc : alg, alg === 'ECDH-ES' ? cekLength(joseHeader.enc) : parseInt(alg.slice(-5, -2), 10), partyUInfo, partyVInfo);\n            if (alg === 'ECDH-ES')\n                return sharedSecret;\n            if (encryptedKey === undefined)\n                throw new JWEInvalid('JWE Encrypted Key missing');\n            return aesKw(alg.slice(-6), sharedSecret, encryptedKey);\n        }\n        case 'RSA1_5':\n        case 'RSA-OAEP':\n        case 'RSA-OAEP-256':\n        case 'RSA-OAEP-384':\n        case 'RSA-OAEP-512': {\n            if (encryptedKey === undefined)\n                throw new JWEInvalid('JWE Encrypted Key missing');\n            return rsaEs(alg, key, encryptedKey);\n        }\n        case 'PBES2-HS256+A128KW':\n        case 'PBES2-HS384+A192KW':\n        case 'PBES2-HS512+A256KW': {\n            if (encryptedKey === undefined)\n                throw new JWEInvalid('JWE Encrypted Key missing');\n            if (typeof joseHeader.p2c !== 'number')\n                throw new JWEInvalid(`JOSE Header \"p2c\" (PBES2 Count) missing or invalid`);\n            const p2cLimit = (options === null || options === void 0 ? void 0 : options.maxPBES2Count) || 10000;\n            if (joseHeader.p2c > p2cLimit)\n                throw new JWEInvalid(`JOSE Header \"p2c\" (PBES2 Count) out is of acceptable bounds`);\n            if (typeof joseHeader.p2s !== 'string')\n                throw new JWEInvalid(`JOSE Header \"p2s\" (PBES2 Salt) missing or invalid`);\n            let p2s;\n            try {\n                p2s = base64url(joseHeader.p2s);\n            }\n            catch (_c) {\n                throw new JWEInvalid('Failed to base64url decode the p2s');\n            }\n            return pbes2Kw(alg, key, encryptedKey, joseHeader.p2c, p2s);\n        }\n        case 'A128KW':\n        case 'A192KW':\n        case 'A256KW': {\n            if (encryptedKey === undefined)\n                throw new JWEInvalid('JWE Encrypted Key missing');\n            return aesKw(alg, key, encryptedKey);\n        }\n        case 'A128GCMKW':\n        case 'A192GCMKW':\n        case 'A256GCMKW': {\n            if (encryptedKey === undefined)\n                throw new JWEInvalid('JWE Encrypted Key missing');\n            if (typeof joseHeader.iv !== 'string')\n                throw new JWEInvalid(`JOSE Header \"iv\" (Initialization Vector) missing or invalid`);\n            if (typeof joseHeader.tag !== 'string')\n                throw new JWEInvalid(`JOSE Header \"tag\" (Authentication Tag) missing or invalid`);\n            let iv;\n            try {\n                iv = base64url(joseHeader.iv);\n            }\n            catch (_d) {\n                throw new JWEInvalid('Failed to base64url decode the iv');\n            }\n            let tag;\n            try {\n                tag = base64url(joseHeader.tag);\n            }\n            catch (_e) {\n                throw new JWEInvalid('Failed to base64url decode the tag');\n            }\n            return aesGcmKw(alg, key, encryptedKey, iv, tag);\n        }\n        default: {\n            throw new JOSENotSupported('Invalid or unsupported \"alg\" (JWE Algorithm) header value');\n        }\n    }\n}\nexport default decryptKeyManagement;\n","import { wrap as aesKw } from '../runtime/aeskw.js';\nimport * as ECDH from '../runtime/ecdhes.js';\nimport { encrypt as pbes2Kw } from '../runtime/pbes2kw.js';\nimport { encrypt as rsaEs } from '../runtime/rsaes.js';\nimport { encode as base64url } from '../runtime/base64url.js';\nimport generateCek, { bitLength as cekLength } from '../lib/cek.js';\nimport { JOSENotSupported } from '../util/errors.js';\nimport { exportJWK } from '../key/export.js';\nimport checkKeyType from './check_key_type.js';\nimport { wrap as aesGcmKw } from './aesgcmkw.js';\nasync function encryptKeyManagement(alg, enc, key, providedCek, providedParameters = {}) {\n    let encryptedKey;\n    let parameters;\n    let cek;\n    checkKeyType(alg, key, 'encrypt');\n    switch (alg) {\n        case 'dir': {\n            cek = key;\n            break;\n        }\n        case 'ECDH-ES':\n        case 'ECDH-ES+A128KW':\n        case 'ECDH-ES+A192KW':\n        case 'ECDH-ES+A256KW': {\n            if (!ECDH.ecdhAllowed(key)) {\n                throw new JOSENotSupported('ECDH with the provided key is not allowed or not supported by your javascript runtime');\n            }\n            const { apu, apv } = providedParameters;\n            let { epk: ephemeralKey } = providedParameters;\n            ephemeralKey || (ephemeralKey = (await ECDH.generateEpk(key)).privateKey);\n            const { x, y, crv, kty } = await exportJWK(ephemeralKey);\n            const sharedSecret = await ECDH.deriveKey(key, ephemeralKey, alg === 'ECDH-ES' ? enc : alg, alg === 'ECDH-ES' ? cekLength(enc) : parseInt(alg.slice(-5, -2), 10), apu, apv);\n            parameters = { epk: { x, crv, kty } };\n            if (kty === 'EC')\n                parameters.epk.y = y;\n            if (apu)\n                parameters.apu = base64url(apu);\n            if (apv)\n                parameters.apv = base64url(apv);\n            if (alg === 'ECDH-ES') {\n                cek = sharedSecret;\n                break;\n            }\n            cek = providedCek || generateCek(enc);\n            const kwAlg = alg.slice(-6);\n            encryptedKey = await aesKw(kwAlg, sharedSecret, cek);\n            break;\n        }\n        case 'RSA1_5':\n        case 'RSA-OAEP':\n        case 'RSA-OAEP-256':\n        case 'RSA-OAEP-384':\n        case 'RSA-OAEP-512': {\n            cek = providedCek || generateCek(enc);\n            encryptedKey = await rsaEs(alg, key, cek);\n            break;\n        }\n        case 'PBES2-HS256+A128KW':\n        case 'PBES2-HS384+A192KW':\n        case 'PBES2-HS512+A256KW': {\n            cek = providedCek || generateCek(enc);\n            const { p2c, p2s } = providedParameters;\n            ({ encryptedKey, ...parameters } = await pbes2Kw(alg, key, cek, p2c, p2s));\n            break;\n        }\n        case 'A128KW':\n        case 'A192KW':\n        case 'A256KW': {\n            cek = providedCek || generateCek(enc);\n            encryptedKey = await aesKw(alg, key, cek);\n            break;\n        }\n        case 'A128GCMKW':\n        case 'A192GCMKW':\n        case 'A256GCMKW': {\n            cek = providedCek || generateCek(enc);\n            const { iv } = providedParameters;\n            ({ encryptedKey, ...parameters } = await aesGcmKw(alg, key, cek, iv));\n            break;\n        }\n        default: {\n            throw new JOSENotSupported('Invalid or unsupported \"alg\" (JWE Algorithm) header value');\n        }\n    }\n    return { cek, encryptedKey, parameters };\n}\nexport default encryptKeyManagement;\n","export default (date) => Math.floor(date.getTime() / 1000);\n","export default (b64, descriptor) => {\n    const newlined = (b64.match(/.{1,64}/g) || []).join('\\n');\n    return `-----BEGIN ${descriptor}-----\\n${newlined}\\n-----END ${descriptor}-----`;\n};\n","function message(msg, actual, ...types) {\n    if (types.length > 2) {\n        const last = types.pop();\n        msg += `one of type ${types.join(', ')}, or ${last}.`;\n    }\n    else if (types.length === 2) {\n        msg += `one of type ${types[0]} or ${types[1]}.`;\n    }\n    else {\n        msg += `of type ${types[0]}.`;\n    }\n    if (actual == null) {\n        msg += ` Received ${actual}`;\n    }\n    else if (typeof actual === 'function' && actual.name) {\n        msg += ` Received function ${actual.name}`;\n    }\n    else if (typeof actual === 'object' && actual != null) {\n        if (actual.constructor && actual.constructor.name) {\n            msg += ` Received an instance of ${actual.constructor.name}`;\n        }\n    }\n    return msg;\n}\nexport default (actual, ...types) => {\n    return message('Key must be ', actual, ...types);\n};\nexport function withAlg(alg, actual, ...types) {\n    return message(`Key for the ${alg} algorithm must be `, actual, ...types);\n}\n","const isDisjoint = (...headers) => {\n    const sources = headers.filter(Boolean);\n    if (sources.length === 0 || sources.length === 1) {\n        return true;\n    }\n    let acc;\n    for (const header of sources) {\n        const parameters = Object.keys(header);\n        if (!acc || acc.size === 0) {\n            acc = new Set(parameters);\n            continue;\n        }\n        for (const parameter of parameters) {\n            if (acc.has(parameter)) {\n                return false;\n            }\n            acc.add(parameter);\n        }\n    }\n    return true;\n};\nexport default isDisjoint;\n","function isObjectLike(value) {\n    return typeof value === 'object' && value !== null;\n}\nexport default function isObject(input) {\n    if (!isObjectLike(input) || Object.prototype.toString.call(input) !== '[object Object]') {\n        return false;\n    }\n    if (Object.getPrototypeOf(input) === null) {\n        return true;\n    }\n    let proto = input;\n    while (Object.getPrototypeOf(proto) !== null) {\n        proto = Object.getPrototypeOf(proto);\n    }\n    return Object.getPrototypeOf(input) === proto;\n}\n","import { JOSENotSupported } from '../util/errors.js';\nimport random from '../runtime/random.js';\nexport function bitLength(alg) {\n    switch (alg) {\n        case 'A128GCM':\n        case 'A128GCMKW':\n        case 'A192GCM':\n        case 'A192GCMKW':\n        case 'A256GCM':\n        case 'A256GCMKW':\n            return 96;\n        case 'A128CBC-HS256':\n        case 'A192CBC-HS384':\n        case 'A256CBC-HS512':\n            return 128;\n        default:\n            throw new JOSENotSupported(`Unsupported JWE Algorithm: ${alg}`);\n    }\n}\nexport default (alg) => random(new Uint8Array(bitLength(alg) >> 3));\n","import { JWTClaimValidationFailed, JWTExpired, JWTInvalid } from '../util/errors.js';\nimport { decoder } from './buffer_utils.js';\nimport epoch from './epoch.js';\nimport secs from './secs.js';\nimport isObject from './is_object.js';\nconst normalizeTyp = (value) => value.toLowerCase().replace(/^application\\//, '');\nconst checkAudiencePresence = (audPayload, audOption) => {\n    if (typeof audPayload === 'string') {\n        return audOption.includes(audPayload);\n    }\n    if (Array.isArray(audPayload)) {\n        return audOption.some(Set.prototype.has.bind(new Set(audPayload)));\n    }\n    return false;\n};\nexport default (protectedHeader, encodedPayload, options = {}) => {\n    const { typ } = options;\n    if (typ &&\n        (typeof protectedHeader.typ !== 'string' ||\n            normalizeTyp(protectedHeader.typ) !== normalizeTyp(typ))) {\n        throw new JWTClaimValidationFailed('unexpected \"typ\" JWT header value', 'typ', 'check_failed');\n    }\n    let payload;\n    try {\n        payload = JSON.parse(decoder.decode(encodedPayload));\n    }\n    catch (_a) {\n    }\n    if (!isObject(payload)) {\n        throw new JWTInvalid('JWT Claims Set must be a top-level JSON object');\n    }\n    const { requiredClaims = [], issuer, subject, audience, maxTokenAge } = options;\n    if (maxTokenAge !== undefined)\n        requiredClaims.push('iat');\n    if (audience !== undefined)\n        requiredClaims.push('aud');\n    if (subject !== undefined)\n        requiredClaims.push('sub');\n    if (issuer !== undefined)\n        requiredClaims.push('iss');\n    for (const claim of new Set(requiredClaims.reverse())) {\n        if (!(claim in payload)) {\n            throw new JWTClaimValidationFailed(`missing required \"${claim}\" claim`, claim, 'missing');\n        }\n    }\n    if (issuer && !(Array.isArray(issuer) ? issuer : [issuer]).includes(payload.iss)) {\n        throw new JWTClaimValidationFailed('unexpected \"iss\" claim value', 'iss', 'check_failed');\n    }\n    if (subject && payload.sub !== subject) {\n        throw new JWTClaimValidationFailed('unexpected \"sub\" claim value', 'sub', 'check_failed');\n    }\n    if (audience &&\n        !checkAudiencePresence(payload.aud, typeof audience === 'string' ? [audience] : audience)) {\n        throw new JWTClaimValidationFailed('unexpected \"aud\" claim value', 'aud', 'check_failed');\n    }\n    let tolerance;\n    switch (typeof options.clockTolerance) {\n        case 'string':\n            tolerance = secs(options.clockTolerance);\n            break;\n        case 'number':\n            tolerance = options.clockTolerance;\n            break;\n        case 'undefined':\n            tolerance = 0;\n            break;\n        default:\n            throw new TypeError('Invalid clockTolerance option type');\n    }\n    const { currentDate } = options;\n    const now = epoch(currentDate || new Date());\n    if ((payload.iat !== undefined || maxTokenAge) && typeof payload.iat !== 'number') {\n        throw new JWTClaimValidationFailed('\"iat\" claim must be a number', 'iat', 'invalid');\n    }\n    if (payload.nbf !== undefined) {\n        if (typeof payload.nbf !== 'number') {\n            throw new JWTClaimValidationFailed('\"nbf\" claim must be a number', 'nbf', 'invalid');\n        }\n        if (payload.nbf > now + tolerance) {\n            throw new JWTClaimValidationFailed('\"nbf\" claim timestamp check failed', 'nbf', 'check_failed');\n        }\n    }\n    if (payload.exp !== undefined) {\n        if (typeof payload.exp !== 'number') {\n            throw new JWTClaimValidationFailed('\"exp\" claim must be a number', 'exp', 'invalid');\n        }\n        if (payload.exp <= now - tolerance) {\n            throw new JWTExpired('\"exp\" claim timestamp check failed', 'exp', 'check_failed');\n        }\n    }\n    if (maxTokenAge) {\n        const age = now - payload.iat;\n        const max = typeof maxTokenAge === 'number' ? maxTokenAge : secs(maxTokenAge);\n        if (age - tolerance > max) {\n            throw new JWTExpired('\"iat\" claim timestamp check failed (too far in the past)', 'iat', 'check_failed');\n        }\n        if (age < 0 - tolerance) {\n            throw new JWTClaimValidationFailed('\"iat\" claim timestamp check failed (it should be in the past)', 'iat', 'check_failed');\n        }\n    }\n    return payload;\n};\n","const minute = 60;\nconst hour = minute * 60;\nconst day = hour * 24;\nconst week = day * 7;\nconst year = day * 365.25;\nconst REGEX = /^(\\d+|\\d+\\.\\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)$/i;\nexport default (str) => {\n    const matched = REGEX.exec(str);\n    if (!matched) {\n        throw new TypeError('Invalid time period format');\n    }\n    const value = parseFloat(matched[1]);\n    const unit = matched[2].toLowerCase();\n    switch (unit) {\n        case 'sec':\n        case 'secs':\n        case 'second':\n        case 'seconds':\n        case 's':\n            return Math.round(value);\n        case 'minute':\n        case 'minutes':\n        case 'min':\n        case 'mins':\n        case 'm':\n            return Math.round(value * minute);\n        case 'hour':\n        case 'hours':\n        case 'hr':\n        case 'hrs':\n        case 'h':\n            return Math.round(value * hour);\n        case 'day':\n        case 'days':\n        case 'd':\n            return Math.round(value * day);\n        case 'week':\n        case 'weeks':\n        case 'w':\n            return Math.round(value * week);\n        default:\n            return Math.round(value * year);\n    }\n};\n","const validateAlgorithms = (option, algorithms) => {\n    if (algorithms !== undefined &&\n        (!Array.isArray(algorithms) || algorithms.some((s) => typeof s !== 'string'))) {\n        throw new TypeError(`\"${option}\" option must be an array of strings`);\n    }\n    if (!algorithms) {\n        return undefined;\n    }\n    return new Set(algorithms);\n};\nexport default validateAlgorithms;\n","import { JOSENotSupported } from '../util/errors.js';\nfunction validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {\n    if (joseHeader.crit !== undefined && protectedHeader.crit === undefined) {\n        throw new Err('\"crit\" (Critical) Header Parameter MUST be integrity protected');\n    }\n    if (!protectedHeader || protectedHeader.crit === undefined) {\n        return new Set();\n    }\n    if (!Array.isArray(protectedHeader.crit) ||\n        protectedHeader.crit.length === 0 ||\n        protectedHeader.crit.some((input) => typeof input !== 'string' || input.length === 0)) {\n        throw new Err('\"crit\" (Critical) Header Parameter MUST be an array of non-empty strings when present');\n    }\n    let recognized;\n    if (recognizedOption !== undefined) {\n        recognized = new Map([...Object.entries(recognizedOption), ...recognizedDefault.entries()]);\n    }\n    else {\n        recognized = recognizedDefault;\n    }\n    for (const parameter of protectedHeader.crit) {\n        if (!recognized.has(parameter)) {\n            throw new JOSENotSupported(`Extension Header Parameter \"${parameter}\" is not recognized`);\n        }\n        if (joseHeader[parameter] === undefined) {\n            throw new Err(`Extension Header Parameter \"${parameter}\" is missing`);\n        }\n        else if (recognized.get(parameter) && protectedHeader[parameter] === undefined) {\n            throw new Err(`Extension Header Parameter \"${parameter}\" MUST be integrity protected`);\n        }\n    }\n    return new Set(protectedHeader.crit);\n}\nexport default validateCrit;\n","import bogusWebCrypto from './bogus.js';\nimport crypto, { isCryptoKey } from './webcrypto.js';\nimport { checkEncCryptoKey } from '../lib/crypto_key.js';\nimport invalidKeyInput from '../lib/invalid_key_input.js';\nimport { types } from './is_key_like.js';\nfunction checkKeySize(key, alg) {\n    if (key.algorithm.length !== parseInt(alg.slice(1, 4), 10)) {\n        throw new TypeError(`Invalid key size for alg: ${alg}`);\n    }\n}\nfunction getCryptoKey(key, alg, usage) {\n    if (isCryptoKey(key)) {\n        checkEncCryptoKey(key, alg, usage);\n        return key;\n    }\n    if (key instanceof Uint8Array) {\n        return crypto.subtle.importKey('raw', key, 'AES-KW', true, [usage]);\n    }\n    throw new TypeError(invalidKeyInput(key, ...types, 'Uint8Array'));\n}\nexport const wrap = async (alg, key, cek) => {\n    const cryptoKey = await getCryptoKey(key, alg, 'wrapKey');\n    checkKeySize(cryptoKey, alg);\n    const cryptoKeyCek = await crypto.subtle.importKey('raw', cek, ...bogusWebCrypto);\n    return new Uint8Array(await crypto.subtle.wrapKey('raw', cryptoKeyCek, cryptoKey, 'AES-KW'));\n};\nexport const unwrap = async (alg, key, encryptedKey) => {\n    const cryptoKey = await getCryptoKey(key, alg, 'unwrapKey');\n    checkKeySize(cryptoKey, alg);\n    const cryptoKeyCek = await crypto.subtle.unwrapKey('raw', encryptedKey, cryptoKey, 'AES-KW', ...bogusWebCrypto);\n    return new Uint8Array(await crypto.subtle.exportKey('raw', cryptoKeyCek));\n};\n","import crypto, { isCryptoKey } from './webcrypto.js';\nimport invalidKeyInput from '../lib/invalid_key_input.js';\nimport { encodeBase64, decodeBase64 } from './base64url.js';\nimport formatPEM from '../lib/format_pem.js';\nimport { JOSENotSupported } from '../util/errors.js';\nimport { types } from './is_key_like.js';\nconst genericExport = async (keyType, keyFormat, key) => {\n    if (!isCryptoKey(key)) {\n        throw new TypeError(invalidKeyInput(key, ...types));\n    }\n    if (!key.extractable) {\n        throw new TypeError('CryptoKey is not extractable');\n    }\n    if (key.type !== keyType) {\n        throw new TypeError(`key is not a ${keyType} key`);\n    }\n    return formatPEM(encodeBase64(new Uint8Array(await crypto.subtle.exportKey(keyFormat, key))), `${keyType.toUpperCase()} KEY`);\n};\nexport const toSPKI = (key) => {\n    return genericExport('public', 'spki', key);\n};\nexport const toPKCS8 = (key) => {\n    return genericExport('private', 'pkcs8', key);\n};\nconst findOid = (keyData, oid, from = 0) => {\n    if (from === 0) {\n        oid.unshift(oid.length);\n        oid.unshift(0x06);\n    }\n    let i = keyData.indexOf(oid[0], from);\n    if (i === -1)\n        return false;\n    const sub = keyData.subarray(i, i + oid.length);\n    if (sub.length !== oid.length)\n        return false;\n    return sub.every((value, index) => value === oid[index]) || findOid(keyData, oid, i + 1);\n};\nconst getNamedCurve = (keyData) => {\n    switch (true) {\n        case findOid(keyData, [0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07]):\n            return 'P-256';\n        case findOid(keyData, [0x2b, 0x81, 0x04, 0x00, 0x22]):\n            return 'P-384';\n        case findOid(keyData, [0x2b, 0x81, 0x04, 0x00, 0x23]):\n            return 'P-521';\n        case findOid(keyData, [0x2b, 0x65, 0x6e]):\n            return 'X25519';\n        case findOid(keyData, [0x2b, 0x65, 0x6f]):\n            return 'X448';\n        case findOid(keyData, [0x2b, 0x65, 0x70]):\n            return 'Ed25519';\n        case findOid(keyData, [0x2b, 0x65, 0x71]):\n            return 'Ed448';\n        default:\n            throw new JOSENotSupported('Invalid or unsupported EC Key Curve or OKP Key Sub Type');\n    }\n};\nconst genericImport = async (replace, keyFormat, pem, alg, options) => {\n    var _a;\n    let algorithm;\n    let keyUsages;\n    const keyData = new Uint8Array(atob(pem.replace(replace, ''))\n        .split('')\n        .map((c) => c.charCodeAt(0)));\n    const isPublic = keyFormat === 'spki';\n    switch (alg) {\n        case 'PS256':\n        case 'PS384':\n        case 'PS512':\n            algorithm = { name: 'RSA-PSS', hash: `SHA-${alg.slice(-3)}` };\n            keyUsages = isPublic ? ['verify'] : ['sign'];\n            break;\n        case 'RS256':\n        case 'RS384':\n        case 'RS512':\n            algorithm = { name: 'RSASSA-PKCS1-v1_5', hash: `SHA-${alg.slice(-3)}` };\n            keyUsages = isPublic ? ['verify'] : ['sign'];\n            break;\n        case 'RSA-OAEP':\n        case 'RSA-OAEP-256':\n        case 'RSA-OAEP-384':\n        case 'RSA-OAEP-512':\n            algorithm = {\n                name: 'RSA-OAEP',\n                hash: `SHA-${parseInt(alg.slice(-3), 10) || 1}`,\n            };\n            keyUsages = isPublic ? ['encrypt', 'wrapKey'] : ['decrypt', 'unwrapKey'];\n            break;\n        case 'ES256':\n            algorithm = { name: 'ECDSA', namedCurve: 'P-256' };\n            keyUsages = isPublic ? ['verify'] : ['sign'];\n            break;\n        case 'ES384':\n            algorithm = { name: 'ECDSA', namedCurve: 'P-384' };\n            keyUsages = isPublic ? ['verify'] : ['sign'];\n            break;\n        case 'ES512':\n            algorithm = { name: 'ECDSA', namedCurve: 'P-521' };\n            keyUsages = isPublic ? ['verify'] : ['sign'];\n            break;\n        case 'ECDH-ES':\n        case 'ECDH-ES+A128KW':\n        case 'ECDH-ES+A192KW':\n        case 'ECDH-ES+A256KW': {\n            const namedCurve = getNamedCurve(keyData);\n            algorithm = namedCurve.startsWith('P-') ? { name: 'ECDH', namedCurve } : { name: namedCurve };\n            keyUsages = isPublic ? [] : ['deriveBits'];\n            break;\n        }\n        case 'EdDSA':\n            algorithm = { name: getNamedCurve(keyData) };\n            keyUsages = isPublic ? ['verify'] : ['sign'];\n            break;\n        default:\n            throw new JOSENotSupported('Invalid or unsupported \"alg\" (Algorithm) value');\n    }\n    return crypto.subtle.importKey(keyFormat, keyData, algorithm, (_a = options === null || options === void 0 ? void 0 : options.extractable) !== null && _a !== void 0 ? _a : false, keyUsages);\n};\nexport const fromPKCS8 = (pem, alg, options) => {\n    return genericImport(/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\\s)/g, 'pkcs8', pem, alg, options);\n};\nexport const fromSPKI = (pem, alg, options) => {\n    return genericImport(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\\s)/g, 'spki', pem, alg, options);\n};\nfunction getElement(seq) {\n    let result = [];\n    let next = 0;\n    while (next < seq.length) {\n        let nextPart = parseElement(seq.subarray(next));\n        result.push(nextPart);\n        next += nextPart.byteLength;\n    }\n    return result;\n}\nfunction parseElement(bytes) {\n    let position = 0;\n    let tag = bytes[0] & 0x1f;\n    position++;\n    if (tag === 0x1f) {\n        tag = 0;\n        while (bytes[position] >= 0x80) {\n            tag = tag * 128 + bytes[position] - 0x80;\n            position++;\n        }\n        tag = tag * 128 + bytes[position] - 0x80;\n        position++;\n    }\n    let length = 0;\n    if (bytes[position] < 0x80) {\n        length = bytes[position];\n        position++;\n    }\n    else if (length === 0x80) {\n        length = 0;\n        while (bytes[position + length] !== 0 || bytes[position + length + 1] !== 0) {\n            if (length > bytes.byteLength) {\n                throw new TypeError('invalid indefinite form length');\n            }\n            length++;\n        }\n        const byteLength = position + length + 2;\n        return {\n            byteLength,\n            contents: bytes.subarray(position, position + length),\n            raw: bytes.subarray(0, byteLength),\n        };\n    }\n    else {\n        let numberOfDigits = bytes[position] & 0x7f;\n        position++;\n        length = 0;\n        for (let i = 0; i < numberOfDigits; i++) {\n            length = length * 256 + bytes[position];\n            position++;\n        }\n    }\n    const byteLength = position + length;\n    return {\n        byteLength,\n        contents: bytes.subarray(position, byteLength),\n        raw: bytes.subarray(0, byteLength),\n    };\n}\nfunction spkiFromX509(buf) {\n    const tbsCertificate = getElement(getElement(parseElement(buf).contents)[0].contents);\n    return encodeBase64(tbsCertificate[tbsCertificate[0].raw[0] === 0xa0 ? 6 : 5].raw);\n}\nfunction getSPKI(x509) {\n    const pem = x509.replace(/(?:-----(?:BEGIN|END) CERTIFICATE-----|\\s)/g, '');\n    const raw = decodeBase64(pem);\n    return formatPEM(spkiFromX509(raw), 'PUBLIC KEY');\n}\nexport const fromX509 = (pem, alg, options) => {\n    let spki;\n    try {\n        spki = getSPKI(pem);\n    }\n    catch (cause) {\n        throw new TypeError('Failed to parse the X.509 certificate', { cause });\n    }\n    return fromSPKI(spki, alg, options);\n};\n","import { encoder, decoder } from '../lib/buffer_utils.js';\nexport const encodeBase64 = (input) => {\n    let unencoded = input;\n    if (typeof unencoded === 'string') {\n        unencoded = encoder.encode(unencoded);\n    }\n    const CHUNK_SIZE = 0x8000;\n    const arr = [];\n    for (let i = 0; i < unencoded.length; i += CHUNK_SIZE) {\n        arr.push(String.fromCharCode.apply(null, unencoded.subarray(i, i + CHUNK_SIZE)));\n    }\n    return btoa(arr.join(''));\n};\nexport const encode = (input) => {\n    return encodeBase64(input).replace(/=/g, '').replace(/\\+/g, '-').replace(/\\//g, '_');\n};\nexport const decodeBase64 = (encoded) => {\n    const binary = atob(encoded);\n    const bytes = new Uint8Array(binary.length);\n    for (let i = 0; i < binary.length; i++) {\n        bytes[i] = binary.charCodeAt(i);\n    }\n    return bytes;\n};\nexport const decode = (input) => {\n    let encoded = input;\n    if (encoded instanceof Uint8Array) {\n        encoded = decoder.decode(encoded);\n    }\n    encoded = encoded.replace(/-/g, '+').replace(/_/g, '/').replace(/\\s/g, '');\n    try {\n        return decodeBase64(encoded);\n    }\n    catch (_a) {\n        throw new TypeError('The input to be decoded is not correctly encoded.');\n    }\n};\n","const bogusWebCrypto = [\n    { hash: 'SHA-256', name: 'HMAC' },\n    true,\n    ['sign'],\n];\nexport default bogusWebCrypto;\n","import { JWEInvalid } from '../util/errors.js';\nconst checkCekLength = (cek, expected) => {\n    const actual = cek.byteLength << 3;\n    if (actual !== expected) {\n        throw new JWEInvalid(`Invalid Content Encryption Key length. Expected ${expected} bits, got ${actual} bits`);\n    }\n};\nexport default checkCekLength;\n","export default (alg, key) => {\n    if (alg.startsWith('RS') || alg.startsWith('PS')) {\n        const { modulusLength } = key.algorithm;\n        if (typeof modulusLength !== 'number' || modulusLength < 2048) {\n            throw new TypeError(`${alg} requires key modulusLength to be 2048 bits or larger`);\n        }\n    }\n};\n","import { concat, uint64be } from '../lib/buffer_utils.js';\nimport checkIvLength from '../lib/check_iv_length.js';\nimport checkCekLength from './check_cek_length.js';\nimport timingSafeEqual from './timing_safe_equal.js';\nimport { JOSENotSupported, JWEDecryptionFailed } from '../util/errors.js';\nimport crypto, { isCryptoKey } from './webcrypto.js';\nimport { checkEncCryptoKey } from '../lib/crypto_key.js';\nimport invalidKeyInput from '../lib/invalid_key_input.js';\nimport { types } from './is_key_like.js';\nasync function cbcDecrypt(enc, cek, ciphertext, iv, tag, aad) {\n    if (!(cek instanceof Uint8Array)) {\n        throw new TypeError(invalidKeyInput(cek, 'Uint8Array'));\n    }\n    const keySize = parseInt(enc.slice(1, 4), 10);\n    const encKey = await crypto.subtle.importKey('raw', cek.subarray(keySize >> 3), 'AES-CBC', false, ['decrypt']);\n    const macKey = await crypto.subtle.importKey('raw', cek.subarray(0, keySize >> 3), {\n        hash: `SHA-${keySize << 1}`,\n        name: 'HMAC',\n    }, false, ['sign']);\n    const macData = concat(aad, iv, ciphertext, uint64be(aad.length << 3));\n    const expectedTag = new Uint8Array((await crypto.subtle.sign('HMAC', macKey, macData)).slice(0, keySize >> 3));\n    let macCheckPassed;\n    try {\n        macCheckPassed = timingSafeEqual(tag, expectedTag);\n    }\n    catch (_a) {\n    }\n    if (!macCheckPassed) {\n        throw new JWEDecryptionFailed();\n    }\n    let plaintext;\n    try {\n        plaintext = new Uint8Array(await crypto.subtle.decrypt({ iv, name: 'AES-CBC' }, encKey, ciphertext));\n    }\n    catch (_b) {\n    }\n    if (!plaintext) {\n        throw new JWEDecryptionFailed();\n    }\n    return plaintext;\n}\nasync function gcmDecrypt(enc, cek, ciphertext, iv, tag, aad) {\n    let encKey;\n    if (cek instanceof Uint8Array) {\n        encKey = await crypto.subtle.importKey('raw', cek, 'AES-GCM', false, ['decrypt']);\n    }\n    else {\n        checkEncCryptoKey(cek, enc, 'decrypt');\n        encKey = cek;\n    }\n    try {\n        return new Uint8Array(await crypto.subtle.decrypt({\n            additionalData: aad,\n            iv,\n            name: 'AES-GCM',\n            tagLength: 128,\n        }, encKey, concat(ciphertext, tag)));\n    }\n    catch (_a) {\n        throw new JWEDecryptionFailed();\n    }\n}\nconst decrypt = async (enc, cek, ciphertext, iv, tag, aad) => {\n    if (!isCryptoKey(cek) && !(cek instanceof Uint8Array)) {\n        throw new TypeError(invalidKeyInput(cek, ...types, 'Uint8Array'));\n    }\n    checkIvLength(enc, iv);\n    switch (enc) {\n        case 'A128CBC-HS256':\n        case 'A192CBC-HS384':\n        case 'A256CBC-HS512':\n            if (cek instanceof Uint8Array)\n                checkCekLength(cek, parseInt(enc.slice(-3), 10));\n            return cbcDecrypt(enc, cek, ciphertext, iv, tag, aad);\n        case 'A128GCM':\n        case 'A192GCM':\n        case 'A256GCM':\n            if (cek instanceof Uint8Array)\n                checkCekLength(cek, parseInt(enc.slice(1, 4), 10));\n            return gcmDecrypt(enc, cek, ciphertext, iv, tag, aad);\n        default:\n            throw new JOSENotSupported('Unsupported JWE Content Encryption Algorithm');\n    }\n};\nexport default decrypt;\n","import crypto from './webcrypto.js';\nconst digest = async (algorithm, data) => {\n    const subtleDigest = `SHA-${algorithm.slice(-3)}`;\n    return new Uint8Array(await crypto.subtle.digest(subtleDigest, data));\n};\nexport default digest;\n","import { encoder, concat, uint32be, lengthAndInput, concatKdf } from '../lib/buffer_utils.js';\nimport crypto, { isCryptoKey } from './webcrypto.js';\nimport { checkEncCryptoKey } from '../lib/crypto_key.js';\nimport invalidKeyInput from '../lib/invalid_key_input.js';\nimport { types } from './is_key_like.js';\nexport async function deriveKey(publicKey, privateKey, algorithm, keyLength, apu = new Uint8Array(0), apv = new Uint8Array(0)) {\n    if (!isCryptoKey(publicKey)) {\n        throw new TypeError(invalidKeyInput(publicKey, ...types));\n    }\n    checkEncCryptoKey(publicKey, 'ECDH');\n    if (!isCryptoKey(privateKey)) {\n        throw new TypeError(invalidKeyInput(privateKey, ...types));\n    }\n    checkEncCryptoKey(privateKey, 'ECDH', 'deriveBits');\n    const value = concat(lengthAndInput(encoder.encode(algorithm)), lengthAndInput(apu), lengthAndInput(apv), uint32be(keyLength));\n    let length;\n    if (publicKey.algorithm.name === 'X25519') {\n        length = 256;\n    }\n    else if (publicKey.algorithm.name === 'X448') {\n        length = 448;\n    }\n    else {\n        length =\n            Math.ceil(parseInt(publicKey.algorithm.namedCurve.substr(-3), 10) / 8) << 3;\n    }\n    const sharedSecret = new Uint8Array(await crypto.subtle.deriveBits({\n        name: publicKey.algorithm.name,\n        public: publicKey,\n    }, privateKey, length));\n    return concatKdf(sharedSecret, keyLength, value);\n}\nexport async function generateEpk(key) {\n    if (!isCryptoKey(key)) {\n        throw new TypeError(invalidKeyInput(key, ...types));\n    }\n    return crypto.subtle.generateKey(key.algorithm, true, ['deriveBits']);\n}\nexport function ecdhAllowed(key) {\n    if (!isCryptoKey(key)) {\n        throw new TypeError(invalidKeyInput(key, ...types));\n    }\n    return (['P-256', 'P-384', 'P-521'].includes(key.algorithm.namedCurve) ||\n        key.algorithm.name === 'X25519' ||\n        key.algorithm.name === 'X448');\n}\n","import { concat, uint64be } from '../lib/buffer_utils.js';\nimport checkIvLength from '../lib/check_iv_length.js';\nimport checkCekLength from './check_cek_length.js';\nimport crypto, { isCryptoKey } from './webcrypto.js';\nimport { checkEncCryptoKey } from '../lib/crypto_key.js';\nimport invalidKeyInput from '../lib/invalid_key_input.js';\nimport { JOSENotSupported } from '../util/errors.js';\nimport { types } from './is_key_like.js';\nasync function cbcEncrypt(enc, plaintext, cek, iv, aad) {\n    if (!(cek instanceof Uint8Array)) {\n        throw new TypeError(invalidKeyInput(cek, 'Uint8Array'));\n    }\n    const keySize = parseInt(enc.slice(1, 4), 10);\n    const encKey = await crypto.subtle.importKey('raw', cek.subarray(keySize >> 3), 'AES-CBC', false, ['encrypt']);\n    const macKey = await crypto.subtle.importKey('raw', cek.subarray(0, keySize >> 3), {\n        hash: `SHA-${keySize << 1}`,\n        name: 'HMAC',\n    }, false, ['sign']);\n    const ciphertext = new Uint8Array(await crypto.subtle.encrypt({\n        iv,\n        name: 'AES-CBC',\n    }, encKey, plaintext));\n    const macData = concat(aad, iv, ciphertext, uint64be(aad.length << 3));\n    const tag = new Uint8Array((await crypto.subtle.sign('HMAC', macKey, macData)).slice(0, keySize >> 3));\n    return { ciphertext, tag };\n}\nasync function gcmEncrypt(enc, plaintext, cek, iv, aad) {\n    let encKey;\n    if (cek instanceof Uint8Array) {\n        encKey = await crypto.subtle.importKey('raw', cek, 'AES-GCM', false, ['encrypt']);\n    }\n    else {\n        checkEncCryptoKey(cek, enc, 'encrypt');\n        encKey = cek;\n    }\n    const encrypted = new Uint8Array(await crypto.subtle.encrypt({\n        additionalData: aad,\n        iv,\n        name: 'AES-GCM',\n        tagLength: 128,\n    }, encKey, plaintext));\n    const tag = encrypted.slice(-16);\n    const ciphertext = encrypted.slice(0, -16);\n    return { ciphertext, tag };\n}\nconst encrypt = async (enc, plaintext, cek, iv, aad) => {\n    if (!isCryptoKey(cek) && !(cek instanceof Uint8Array)) {\n        throw new TypeError(invalidKeyInput(cek, ...types, 'Uint8Array'));\n    }\n    checkIvLength(enc, iv);\n    switch (enc) {\n        case 'A128CBC-HS256':\n        case 'A192CBC-HS384':\n        case 'A256CBC-HS512':\n            if (cek instanceof Uint8Array)\n                checkCekLength(cek, parseInt(enc.slice(-3), 10));\n            return cbcEncrypt(enc, plaintext, cek, iv, aad);\n        case 'A128GCM':\n        case 'A192GCM':\n        case 'A256GCM':\n            if (cek instanceof Uint8Array)\n                checkCekLength(cek, parseInt(enc.slice(1, 4), 10));\n            return gcmEncrypt(enc, plaintext, cek, iv, aad);\n        default:\n            throw new JOSENotSupported('Unsupported JWE Content Encryption Algorithm');\n    }\n};\nexport default encrypt;\n","import { JOSEError, JWKSTimeout } from '../util/errors.js';\nconst fetchJwks = async (url, timeout, options) => {\n    let controller;\n    let id;\n    let timedOut = false;\n    if (typeof AbortController === 'function') {\n        controller = new AbortController();\n        id = setTimeout(() => {\n            timedOut = true;\n            controller.abort();\n        }, timeout);\n    }\n    const response = await fetch(url.href, {\n        signal: controller ? controller.signal : undefined,\n        redirect: 'manual',\n        headers: options.headers,\n    }).catch((err) => {\n        if (timedOut)\n            throw new JWKSTimeout();\n        throw err;\n    });\n    if (id !== undefined)\n        clearTimeout(id);\n    if (response.status !== 200) {\n        throw new JOSEError('Expected 200 OK from the JSON Web Key Set HTTP response');\n    }\n    try {\n        return await response.json();\n    }\n    catch (_a) {\n        throw new JOSEError('Failed to parse the JSON Web Key Set HTTP response as JSON');\n    }\n};\nexport default fetchJwks;\n","import crypto from './webcrypto.js';\nimport { JOSENotSupported } from '../util/errors.js';\nimport random from './random.js';\nexport async function generateSecret(alg, options) {\n    var _a;\n    let length;\n    let algorithm;\n    let keyUsages;\n    switch (alg) {\n        case 'HS256':\n        case 'HS384':\n        case 'HS512':\n            length = parseInt(alg.slice(-3), 10);\n            algorithm = { name: 'HMAC', hash: `SHA-${length}`, length };\n            keyUsages = ['sign', 'verify'];\n            break;\n        case 'A128CBC-HS256':\n        case 'A192CBC-HS384':\n        case 'A256CBC-HS512':\n            length = parseInt(alg.slice(-3), 10);\n            return random(new Uint8Array(length >> 3));\n        case 'A128KW':\n        case 'A192KW':\n        case 'A256KW':\n            length = parseInt(alg.slice(1, 4), 10);\n            algorithm = { name: 'AES-KW', length };\n            keyUsages = ['wrapKey', 'unwrapKey'];\n            break;\n        case 'A128GCMKW':\n        case 'A192GCMKW':\n        case 'A256GCMKW':\n        case 'A128GCM':\n        case 'A192GCM':\n        case 'A256GCM':\n            length = parseInt(alg.slice(1, 4), 10);\n            algorithm = { name: 'AES-GCM', length };\n            keyUsages = ['encrypt', 'decrypt'];\n            break;\n        default:\n            throw new JOSENotSupported('Invalid or unsupported JWK \"alg\" (Algorithm) Parameter value');\n    }\n    return crypto.subtle.generateKey(algorithm, (_a = options === null || options === void 0 ? void 0 : options.extractable) !== null && _a !== void 0 ? _a : false, keyUsages);\n}\nfunction getModulusLengthOption(options) {\n    var _a;\n    const modulusLength = (_a = options === null || options === void 0 ? void 0 : options.modulusLength) !== null && _a !== void 0 ? _a : 2048;\n    if (typeof modulusLength !== 'number' || modulusLength < 2048) {\n        throw new JOSENotSupported('Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used');\n    }\n    return modulusLength;\n}\nexport async function generateKeyPair(alg, options) {\n    var _a, _b, _c;\n    let algorithm;\n    let keyUsages;\n    switch (alg) {\n        case 'PS256':\n        case 'PS384':\n        case 'PS512':\n            algorithm = {\n                name: 'RSA-PSS',\n                hash: `SHA-${alg.slice(-3)}`,\n                publicExponent: new Uint8Array([0x01, 0x00, 0x01]),\n                modulusLength: getModulusLengthOption(options),\n            };\n            keyUsages = ['sign', 'verify'];\n            break;\n        case 'RS256':\n        case 'RS384':\n        case 'RS512':\n            algorithm = {\n                name: 'RSASSA-PKCS1-v1_5',\n                hash: `SHA-${alg.slice(-3)}`,\n                publicExponent: new Uint8Array([0x01, 0x00, 0x01]),\n                modulusLength: getModulusLengthOption(options),\n            };\n            keyUsages = ['sign', 'verify'];\n            break;\n        case 'RSA-OAEP':\n        case 'RSA-OAEP-256':\n        case 'RSA-OAEP-384':\n        case 'RSA-OAEP-512':\n            algorithm = {\n                name: 'RSA-OAEP',\n                hash: `SHA-${parseInt(alg.slice(-3), 10) || 1}`,\n                publicExponent: new Uint8Array([0x01, 0x00, 0x01]),\n                modulusLength: getModulusLengthOption(options),\n            };\n            keyUsages = ['decrypt', 'unwrapKey', 'encrypt', 'wrapKey'];\n            break;\n        case 'ES256':\n            algorithm = { name: 'ECDSA', namedCurve: 'P-256' };\n            keyUsages = ['sign', 'verify'];\n            break;\n        case 'ES384':\n            algorithm = { name: 'ECDSA', namedCurve: 'P-384' };\n            keyUsages = ['sign', 'verify'];\n            break;\n        case 'ES512':\n            algorithm = { name: 'ECDSA', namedCurve: 'P-521' };\n            keyUsages = ['sign', 'verify'];\n            break;\n        case 'EdDSA':\n            keyUsages = ['sign', 'verify'];\n            const crv = (_a = options === null || options === void 0 ? void 0 : options.crv) !== null && _a !== void 0 ? _a : 'Ed25519';\n            switch (crv) {\n                case 'Ed25519':\n                case 'Ed448':\n                    algorithm = { name: crv };\n                    break;\n                default:\n                    throw new JOSENotSupported('Invalid or unsupported crv option provided');\n            }\n            break;\n        case 'ECDH-ES':\n        case 'ECDH-ES+A128KW':\n        case 'ECDH-ES+A192KW':\n        case 'ECDH-ES+A256KW': {\n            keyUsages = ['deriveKey', 'deriveBits'];\n            const crv = (_b = options === null || options === void 0 ? void 0 : options.crv) !== null && _b !== void 0 ? _b : 'P-256';\n            switch (crv) {\n                case 'P-256':\n                case 'P-384':\n                case 'P-521': {\n                    algorithm = { name: 'ECDH', namedCurve: crv };\n                    break;\n                }\n                case 'X25519':\n                case 'X448':\n                    algorithm = { name: crv };\n                    break;\n                default:\n                    throw new JOSENotSupported('Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, X25519, and X448');\n            }\n            break;\n        }\n        default:\n            throw new JOSENotSupported('Invalid or unsupported JWK \"alg\" (Algorithm) Parameter value');\n    }\n    return (crypto.subtle.generateKey(algorithm, (_c = options === null || options === void 0 ? void 0 : options.extractable) !== null && _c !== void 0 ? _c : false, keyUsages));\n}\n","import crypto, { isCryptoKey } from './webcrypto.js';\nimport { checkSigCryptoKey } from '../lib/crypto_key.js';\nimport invalidKeyInput from '../lib/invalid_key_input.js';\nimport { types } from './is_key_like.js';\nexport default function getCryptoKey(alg, key, usage) {\n    if (isCryptoKey(key)) {\n        checkSigCryptoKey(key, alg, usage);\n        return key;\n    }\n    if (key instanceof Uint8Array) {\n        if (!alg.startsWith('HS')) {\n            throw new TypeError(invalidKeyInput(key, ...types));\n        }\n        return crypto.subtle.importKey('raw', key, { hash: `SHA-${alg.slice(-3)}`, name: 'HMAC' }, false, [usage]);\n    }\n    throw new TypeError(invalidKeyInput(key, ...types, 'Uint8Array'));\n}\n","import { isCryptoKey } from './webcrypto.js';\nexport default (key) => {\n    return isCryptoKey(key);\n};\nexport const types = ['CryptoKey'];\n","import crypto from './webcrypto.js';\nimport { JOSENotSupported } from '../util/errors.js';\nimport { decode as base64url } from './base64url.js';\nfunction subtleMapping(jwk) {\n    let algorithm;\n    let keyUsages;\n    switch (jwk.kty) {\n        case 'oct': {\n            switch (jwk.alg) {\n                case 'HS256':\n                case 'HS384':\n                case 'HS512':\n                    algorithm = { name: 'HMAC', hash: `SHA-${jwk.alg.slice(-3)}` };\n                    keyUsages = ['sign', 'verify'];\n                    break;\n                case 'A128CBC-HS256':\n                case 'A192CBC-HS384':\n                case 'A256CBC-HS512':\n                    throw new JOSENotSupported(`${jwk.alg} keys cannot be imported as CryptoKey instances`);\n                case 'A128GCM':\n                case 'A192GCM':\n                case 'A256GCM':\n                case 'A128GCMKW':\n                case 'A192GCMKW':\n                case 'A256GCMKW':\n                    algorithm = { name: 'AES-GCM' };\n                    keyUsages = ['encrypt', 'decrypt'];\n                    break;\n                case 'A128KW':\n                case 'A192KW':\n                case 'A256KW':\n                    algorithm = { name: 'AES-KW' };\n                    keyUsages = ['wrapKey', 'unwrapKey'];\n                    break;\n                case 'PBES2-HS256+A128KW':\n                case 'PBES2-HS384+A192KW':\n                case 'PBES2-HS512+A256KW':\n                    algorithm = { name: 'PBKDF2' };\n                    keyUsages = ['deriveBits'];\n                    break;\n                default:\n                    throw new JOSENotSupported('Invalid or unsupported JWK \"alg\" (Algorithm) Parameter value');\n            }\n            break;\n        }\n        case 'RSA': {\n            switch (jwk.alg) {\n                case 'PS256':\n                case 'PS384':\n                case 'PS512':\n                    algorithm = { name: 'RSA-PSS', hash: `SHA-${jwk.alg.slice(-3)}` };\n                    keyUsages = jwk.d ? ['sign'] : ['verify'];\n                    break;\n                case 'RS256':\n                case 'RS384':\n                case 'RS512':\n                    algorithm = { name: 'RSASSA-PKCS1-v1_5', hash: `SHA-${jwk.alg.slice(-3)}` };\n                    keyUsages = jwk.d ? ['sign'] : ['verify'];\n                    break;\n                case 'RSA-OAEP':\n                case 'RSA-OAEP-256':\n                case 'RSA-OAEP-384':\n                case 'RSA-OAEP-512':\n                    algorithm = {\n                        name: 'RSA-OAEP',\n                        hash: `SHA-${parseInt(jwk.alg.slice(-3), 10) || 1}`,\n                    };\n                    keyUsages = jwk.d ? ['decrypt', 'unwrapKey'] : ['encrypt', 'wrapKey'];\n                    break;\n                default:\n                    throw new JOSENotSupported('Invalid or unsupported JWK \"alg\" (Algorithm) Parameter value');\n            }\n            break;\n        }\n        case 'EC': {\n            switch (jwk.alg) {\n                case 'ES256':\n                    algorithm = { name: 'ECDSA', namedCurve: 'P-256' };\n                    keyUsages = jwk.d ? ['sign'] : ['verify'];\n                    break;\n                case 'ES384':\n                    algorithm = { name: 'ECDSA', namedCurve: 'P-384' };\n                    keyUsages = jwk.d ? ['sign'] : ['verify'];\n                    break;\n                case 'ES512':\n                    algorithm = { name: 'ECDSA', namedCurve: 'P-521' };\n                    keyUsages = jwk.d ? ['sign'] : ['verify'];\n                    break;\n                case 'ECDH-ES':\n                case 'ECDH-ES+A128KW':\n                case 'ECDH-ES+A192KW':\n                case 'ECDH-ES+A256KW':\n                    algorithm = { name: 'ECDH', namedCurve: jwk.crv };\n                    keyUsages = jwk.d ? ['deriveBits'] : [];\n                    break;\n                default:\n                    throw new JOSENotSupported('Invalid or unsupported JWK \"alg\" (Algorithm) Parameter value');\n            }\n            break;\n        }\n        case 'OKP': {\n            switch (jwk.alg) {\n                case 'EdDSA':\n                    algorithm = { name: jwk.crv };\n                    keyUsages = jwk.d ? ['sign'] : ['verify'];\n                    break;\n                case 'ECDH-ES':\n                case 'ECDH-ES+A128KW':\n                case 'ECDH-ES+A192KW':\n                case 'ECDH-ES+A256KW':\n                    algorithm = { name: jwk.crv };\n                    keyUsages = jwk.d ? ['deriveBits'] : [];\n                    break;\n                default:\n                    throw new JOSENotSupported('Invalid or unsupported JWK \"alg\" (Algorithm) Parameter value');\n            }\n            break;\n        }\n        default:\n            throw new JOSENotSupported('Invalid or unsupported JWK \"kty\" (Key Type) Parameter value');\n    }\n    return { algorithm, keyUsages };\n}\nconst parse = async (jwk) => {\n    var _a, _b;\n    if (!jwk.alg) {\n        throw new TypeError('\"alg\" argument is required when \"jwk.alg\" is not present');\n    }\n    const { algorithm, keyUsages } = subtleMapping(jwk);\n    const rest = [\n        algorithm,\n        (_a = jwk.ext) !== null && _a !== void 0 ? _a : false,\n        (_b = jwk.key_ops) !== null && _b !== void 0 ? _b : keyUsages,\n    ];\n    if (algorithm.name === 'PBKDF2') {\n        return crypto.subtle.importKey('raw', base64url(jwk.k), ...rest);\n    }\n    const keyData = { ...jwk };\n    delete keyData.alg;\n    delete keyData.use;\n    return crypto.subtle.importKey('jwk', keyData, ...rest);\n};\nexport default parse;\n","import crypto, { isCryptoKey } from './webcrypto.js';\nimport invalidKeyInput from '../lib/invalid_key_input.js';\nimport { encode as base64url } from './base64url.js';\nimport { types } from './is_key_like.js';\nconst keyToJWK = async (key) => {\n    if (key instanceof Uint8Array) {\n        return {\n            kty: 'oct',\n            k: base64url(key),\n        };\n    }\n    if (!isCryptoKey(key)) {\n        throw new TypeError(invalidKeyInput(key, ...types, 'Uint8Array'));\n    }\n    if (!key.extractable) {\n        throw new TypeError('non-extractable CryptoKey cannot be exported as a JWK');\n    }\n    const { ext, key_ops, alg, use, ...jwk } = await crypto.subtle.exportKey('jwk', key);\n    return jwk;\n};\nexport default keyToJWK;\n","import random from './random.js';\nimport { p2s as concatSalt } from '../lib/buffer_utils.js';\nimport { encode as base64url } from './base64url.js';\nimport { wrap, unwrap } from './aeskw.js';\nimport checkP2s from '../lib/check_p2s.js';\nimport crypto, { isCryptoKey } from './webcrypto.js';\nimport { checkEncCryptoKey } from '../lib/crypto_key.js';\nimport invalidKeyInput from '../lib/invalid_key_input.js';\nimport { types } from './is_key_like.js';\nfunction getCryptoKey(key, alg) {\n    if (key instanceof Uint8Array) {\n        return crypto.subtle.importKey('raw', key, 'PBKDF2', false, ['deriveBits']);\n    }\n    if (isCryptoKey(key)) {\n        checkEncCryptoKey(key, alg, 'deriveBits', 'deriveKey');\n        return key;\n    }\n    throw new TypeError(invalidKeyInput(key, ...types, 'Uint8Array'));\n}\nasync function deriveKey(p2s, alg, p2c, key) {\n    checkP2s(p2s);\n    const salt = concatSalt(alg, p2s);\n    const keylen = parseInt(alg.slice(13, 16), 10);\n    const subtleAlg = {\n        hash: `SHA-${alg.slice(8, 11)}`,\n        iterations: p2c,\n        name: 'PBKDF2',\n        salt,\n    };\n    const wrapAlg = {\n        length: keylen,\n        name: 'AES-KW',\n    };\n    const cryptoKey = await getCryptoKey(key, alg);\n    if (cryptoKey.usages.includes('deriveBits')) {\n        return new Uint8Array(await crypto.subtle.deriveBits(subtleAlg, cryptoKey, keylen));\n    }\n    if (cryptoKey.usages.includes('deriveKey')) {\n        return crypto.subtle.deriveKey(subtleAlg, cryptoKey, wrapAlg, false, ['wrapKey', 'unwrapKey']);\n    }\n    throw new TypeError('PBKDF2 key \"usages\" must include \"deriveBits\" or \"deriveKey\"');\n}\nexport const encrypt = async (alg, key, cek, p2c = 2048, p2s = random(new Uint8Array(16))) => {\n    const derived = await deriveKey(p2s, alg, p2c, key);\n    const encryptedKey = await wrap(alg.slice(-6), derived, cek);\n    return { encryptedKey, p2c, p2s: base64url(p2s) };\n};\nexport const decrypt = async (alg, key, encryptedKey, p2c, p2s) => {\n    const derived = await deriveKey(p2s, alg, p2c, key);\n    return unwrap(alg.slice(-6), derived, encryptedKey);\n};\n","import crypto from './webcrypto.js';\nexport default crypto.getRandomValues.bind(crypto);\n","import subtleAlgorithm from './subtle_rsaes.js';\nimport bogusWebCrypto from './bogus.js';\nimport crypto, { isCryptoKey } from './webcrypto.js';\nimport { checkEncCryptoKey } from '../lib/crypto_key.js';\nimport checkKeyLength from './check_key_length.js';\nimport invalidKeyInput from '../lib/invalid_key_input.js';\nimport { types } from './is_key_like.js';\nexport const encrypt = async (alg, key, cek) => {\n    if (!isCryptoKey(key)) {\n        throw new TypeError(invalidKeyInput(key, ...types));\n    }\n    checkEncCryptoKey(key, alg, 'encrypt', 'wrapKey');\n    checkKeyLength(alg, key);\n    if (key.usages.includes('encrypt')) {\n        return new Uint8Array(await crypto.subtle.encrypt(subtleAlgorithm(alg), key, cek));\n    }\n    if (key.usages.includes('wrapKey')) {\n        const cryptoKeyCek = await crypto.subtle.importKey('raw', cek, ...bogusWebCrypto);\n        return new Uint8Array(await crypto.subtle.wrapKey('raw', cryptoKeyCek, key, subtleAlgorithm(alg)));\n    }\n    throw new TypeError('RSA-OAEP key \"usages\" must include \"encrypt\" or \"wrapKey\" for this operation');\n};\nexport const decrypt = async (alg, key, encryptedKey) => {\n    if (!isCryptoKey(key)) {\n        throw new TypeError(invalidKeyInput(key, ...types));\n    }\n    checkEncCryptoKey(key, alg, 'decrypt', 'unwrapKey');\n    checkKeyLength(alg, key);\n    if (key.usages.includes('decrypt')) {\n        return new Uint8Array(await crypto.subtle.decrypt(subtleAlgorithm(alg), key, encryptedKey));\n    }\n    if (key.usages.includes('unwrapKey')) {\n        const cryptoKeyCek = await crypto.subtle.unwrapKey('raw', encryptedKey, key, subtleAlgorithm(alg), ...bogusWebCrypto);\n        return new Uint8Array(await crypto.subtle.exportKey('raw', cryptoKeyCek));\n    }\n    throw new TypeError('RSA-OAEP key \"usages\" must include \"decrypt\" or \"unwrapKey\" for this operation');\n};\n","export default 'WebCryptoAPI';\n","import subtleAlgorithm from './subtle_dsa.js';\nimport crypto from './webcrypto.js';\nimport checkKeyLength from './check_key_length.js';\nimport getSignKey from './get_sign_verify_key.js';\nconst sign = async (alg, key, data) => {\n    const cryptoKey = await getSignKey(alg, key, 'sign');\n    checkKeyLength(alg, cryptoKey);\n    const signature = await crypto.subtle.sign(subtleAlgorithm(alg, cryptoKey.algorithm), cryptoKey, data);\n    return new Uint8Array(signature);\n};\nexport default sign;\n","import { JOSENotSupported } from '../util/errors.js';\nexport default function subtleDsa(alg, algorithm) {\n    const hash = `SHA-${alg.slice(-3)}`;\n    switch (alg) {\n        case 'HS256':\n        case 'HS384':\n        case 'HS512':\n            return { hash, name: 'HMAC' };\n        case 'PS256':\n        case 'PS384':\n        case 'PS512':\n            return { hash, name: 'RSA-PSS', saltLength: alg.slice(-3) >> 3 };\n        case 'RS256':\n        case 'RS384':\n        case 'RS512':\n            return { hash, name: 'RSASSA-PKCS1-v1_5' };\n        case 'ES256':\n        case 'ES384':\n        case 'ES512':\n            return { hash, name: 'ECDSA', namedCurve: algorithm.namedCurve };\n        case 'EdDSA':\n            return { name: algorithm.name };\n        default:\n            throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);\n    }\n}\n","import { JOSENotSupported } from '../util/errors.js';\nexport default function subtleRsaEs(alg) {\n    switch (alg) {\n        case 'RSA-OAEP':\n        case 'RSA-OAEP-256':\n        case 'RSA-OAEP-384':\n        case 'RSA-OAEP-512':\n            return 'RSA-OAEP';\n        default:\n            throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);\n    }\n}\n","const timingSafeEqual = (a, b) => {\n    if (!(a instanceof Uint8Array)) {\n        throw new TypeError('First argument must be a buffer');\n    }\n    if (!(b instanceof Uint8Array)) {\n        throw new TypeError('Second argument must be a buffer');\n    }\n    if (a.length !== b.length) {\n        throw new TypeError('Input buffers must have the same length');\n    }\n    const len = a.length;\n    let out = 0;\n    let i = -1;\n    while (++i < len) {\n        out |= a[i] ^ b[i];\n    }\n    return out === 0;\n};\nexport default timingSafeEqual;\n","import subtleAlgorithm from './subtle_dsa.js';\nimport crypto from './webcrypto.js';\nimport checkKeyLength from './check_key_length.js';\nimport getVerifyKey from './get_sign_verify_key.js';\nconst verify = async (alg, key, signature, data) => {\n    const cryptoKey = await getVerifyKey(alg, key, 'verify');\n    checkKeyLength(alg, cryptoKey);\n    const algorithm = subtleAlgorithm(alg, cryptoKey.algorithm);\n    try {\n        return await crypto.subtle.verify(algorithm, cryptoKey, signature, data);\n    }\n    catch (_a) {\n        return false;\n    }\n};\nexport default verify;\n","export default crypto;\nexport const isCryptoKey = (key) => key instanceof CryptoKey;\n","import { JOSENotSupported } from '../util/errors.js';\nexport const inflate = async () => {\n    throw new JOSENotSupported('JWE \"zip\" (Compression Algorithm) Header Parameter is not supported by your javascript runtime. You need to use the `inflateRaw` decrypt option to provide Inflate Raw implementation.');\n};\nexport const deflate = async () => {\n    throw new JOSENotSupported('JWE \"zip\" (Compression Algorithm) Header Parameter is not supported by your javascript runtime. You need to use the `deflateRaw` encrypt option to provide Deflate Raw implementation.');\n};\n","import * as base64url from '../runtime/base64url.js';\nexport const encode = base64url.encode;\nexport const decode = base64url.decode;\n","import { decode as base64url } from './base64url.js';\nimport { decoder } from '../lib/buffer_utils.js';\nimport isObject from '../lib/is_object.js';\nimport { JWTInvalid } from './errors.js';\nexport function decodeJwt(jwt) {\n    if (typeof jwt !== 'string')\n        throw new JWTInvalid('JWTs must use Compact JWS serialization, JWT must be a string');\n    const { 1: payload, length } = jwt.split('.');\n    if (length === 5)\n        throw new JWTInvalid('Only JWTs using Compact JWS serialization can be decoded');\n    if (length !== 3)\n        throw new JWTInvalid('Invalid JWT');\n    if (!payload)\n        throw new JWTInvalid('JWTs must contain a payload');\n    let decoded;\n    try {\n        decoded = base64url(payload);\n    }\n    catch (_a) {\n        throw new JWTInvalid('Failed to base64url decode the payload');\n    }\n    let result;\n    try {\n        result = JSON.parse(decoder.decode(decoded));\n    }\n    catch (_b) {\n        throw new JWTInvalid('Failed to parse the decoded payload as JSON');\n    }\n    if (!isObject(result))\n        throw new JWTInvalid('Invalid JWT Claims Set');\n    return result;\n}\n","import { decode as base64url } from './base64url.js';\nimport { decoder } from '../lib/buffer_utils.js';\nimport isObject from '../lib/is_object.js';\nexport function decodeProtectedHeader(token) {\n    let protectedB64u;\n    if (typeof token === 'string') {\n        const parts = token.split('.');\n        if (parts.length === 3 || parts.length === 5) {\n            ;\n            [protectedB64u] = parts;\n        }\n    }\n    else if (typeof token === 'object' && token) {\n        if ('protected' in token) {\n            protectedB64u = token.protected;\n        }\n        else {\n            throw new TypeError('Token does not contain a Protected Header');\n        }\n    }\n    try {\n        if (typeof protectedB64u !== 'string' || !protectedB64u) {\n            throw new Error();\n        }\n        const result = JSON.parse(decoder.decode(base64url(protectedB64u)));\n        if (!isObject(result)) {\n            throw new Error();\n        }\n        return result;\n    }\n    catch (_a) {\n        throw new TypeError('Invalid Token or Protected Header formatting');\n    }\n}\n","export class JOSEError extends Error {\n    static get code() {\n        return 'ERR_JOSE_GENERIC';\n    }\n    constructor(message) {\n        var _a;\n        super(message);\n        this.code = 'ERR_JOSE_GENERIC';\n        this.name = this.constructor.name;\n        (_a = Error.captureStackTrace) === null || _a === void 0 ? void 0 : _a.call(Error, this, this.constructor);\n    }\n}\nexport class JWTClaimValidationFailed extends JOSEError {\n    static get code() {\n        return 'ERR_JWT_CLAIM_VALIDATION_FAILED';\n    }\n    constructor(message, claim = 'unspecified', reason = 'unspecified') {\n        super(message);\n        this.code = 'ERR_JWT_CLAIM_VALIDATION_FAILED';\n        this.claim = claim;\n        this.reason = reason;\n    }\n}\nexport class JWTExpired extends JOSEError {\n    static get code() {\n        return 'ERR_JWT_EXPIRED';\n    }\n    constructor(message, claim = 'unspecified', reason = 'unspecified') {\n        super(message);\n        this.code = 'ERR_JWT_EXPIRED';\n        this.claim = claim;\n        this.reason = reason;\n    }\n}\nexport class JOSEAlgNotAllowed extends JOSEError {\n    constructor() {\n        super(...arguments);\n        this.code = 'ERR_JOSE_ALG_NOT_ALLOWED';\n    }\n    static get code() {\n        return 'ERR_JOSE_ALG_NOT_ALLOWED';\n    }\n}\nexport class JOSENotSupported extends JOSEError {\n    constructor() {\n        super(...arguments);\n        this.code = 'ERR_JOSE_NOT_SUPPORTED';\n    }\n    static get code() {\n        return 'ERR_JOSE_NOT_SUPPORTED';\n    }\n}\nexport class JWEDecryptionFailed extends JOSEError {\n    constructor() {\n        super(...arguments);\n        this.code = 'ERR_JWE_DECRYPTION_FAILED';\n        this.message = 'decryption operation failed';\n    }\n    static get code() {\n        return 'ERR_JWE_DECRYPTION_FAILED';\n    }\n}\nexport class JWEDecompressionFailed extends JOSEError {\n    constructor() {\n        super(...arguments);\n        this.code = 'ERR_JWE_DECOMPRESSION_FAILED';\n        this.message = 'decompression operation failed';\n    }\n    static get code() {\n        return 'ERR_JWE_DECOMPRESSION_FAILED';\n    }\n}\nexport class JWEInvalid extends JOSEError {\n    constructor() {\n        super(...arguments);\n        this.code = 'ERR_JWE_INVALID';\n    }\n    static get code() {\n        return 'ERR_JWE_INVALID';\n    }\n}\nexport class JWSInvalid extends JOSEError {\n    constructor() {\n        super(...arguments);\n        this.code = 'ERR_JWS_INVALID';\n    }\n    static get code() {\n        return 'ERR_JWS_INVALID';\n    }\n}\nexport class JWTInvalid extends JOSEError {\n    constructor() {\n        super(...arguments);\n        this.code = 'ERR_JWT_INVALID';\n    }\n    static get code() {\n        return 'ERR_JWT_INVALID';\n    }\n}\nexport class JWKInvalid extends JOSEError {\n    constructor() {\n        super(...arguments);\n        this.code = 'ERR_JWK_INVALID';\n    }\n    static get code() {\n        return 'ERR_JWK_INVALID';\n    }\n}\nexport class JWKSInvalid extends JOSEError {\n    constructor() {\n        super(...arguments);\n        this.code = 'ERR_JWKS_INVALID';\n    }\n    static get code() {\n        return 'ERR_JWKS_INVALID';\n    }\n}\nexport class JWKSNoMatchingKey extends JOSEError {\n    constructor() {\n        super(...arguments);\n        this.code = 'ERR_JWKS_NO_MATCHING_KEY';\n        this.message = 'no applicable key found in the JSON Web Key Set';\n    }\n    static get code() {\n        return 'ERR_JWKS_NO_MATCHING_KEY';\n    }\n}\nexport class JWKSMultipleMatchingKeys extends JOSEError {\n    constructor() {\n        super(...arguments);\n        this.code = 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';\n        this.message = 'multiple matching keys found in the JSON Web Key Set';\n    }\n    static get code() {\n        return 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';\n    }\n}\nSymbol.asyncIterator;\nexport class JWKSTimeout extends JOSEError {\n    constructor() {\n        super(...arguments);\n        this.code = 'ERR_JWKS_TIMEOUT';\n        this.message = 'request timed out';\n    }\n    static get code() {\n        return 'ERR_JWKS_TIMEOUT';\n    }\n}\nexport class JWSSignatureVerificationFailed extends JOSEError {\n    constructor() {\n        super(...arguments);\n        this.code = 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';\n        this.message = 'signature verification failed';\n    }\n    static get code() {\n        return 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';\n    }\n}\n","import value from '../runtime/runtime.js';\nexport default value;\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","var getProto = Object.getPrototypeOf ? (obj) => (Object.getPrototypeOf(obj)) : (obj) => (obj.__proto__);\nvar leafPrototypes;\n// create a fake namespace object\n// mode & 1: value is a module id, require it\n// mode & 2: merge all properties of value into the ns\n// mode & 4: return value when already ns object\n// mode & 16: return value when it's Promise-like\n// mode & 8|1: behave like require\n__webpack_require__.t = function(value, mode) {\n\tif(mode & 1) value = this(value);\n\tif(mode & 8) return value;\n\tif(typeof value === 'object' && value) {\n\t\tif((mode & 4) && value.__esModule) return value;\n\t\tif((mode & 16) && typeof value.then === 'function') return value;\n\t}\n\tvar ns = Object.create(null);\n\t__webpack_require__.r(ns);\n\tvar def = {};\n\tleafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)];\n\tfor(var current = mode & 2 && value; typeof current == 'object' && !~leafPrototypes.indexOf(current); current = getProto(current)) {\n\t\tObject.getOwnPropertyNames(current).forEach((key) => (def[key] = () => (value[key])));\n\t}\n\tdef['default'] = () => (value);\n\t__webpack_require__.d(ns, def);\n\treturn ns;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { defaultDocumentLoader, issue, signPresentation, verifyCredential } from '@digitalbazaar/vc';\nimport { extendContextLoader } from 'jsonld-signatures';\nimport * as jose from 'jose';\n\nimport ed25519Context from 'ed25519-signature-2020-context';\nimport { Ed25519VerificationKey2020 } from\n  '@digitalbazaar/ed25519-verification-key-2020';\nimport { Ed25519Signature2020 } from '@digitalbazaar/ed25519-signature-2020';\n\nimport * as Ed25519Multikey from '@digitalbazaar/ed25519-multikey';\nimport {DataIntegrityProof} from '@digitalbazaar/data-integrity';\nimport {cryptosuite as eddsaRdfc2022CryptoSuite} from\n  '@digitalbazaar/eddsa-rdfc-2022-cryptosuite';\nimport dataIntegrityContext from '@digitalbazaar/data-integrity-context';\n\nimport internalContext from './contexts';\n\n// setup static document loader\nconst documentLoader = extendContextLoader(async url => {\n  const context = [internalContext, dataIntegrityContext, ed25519Context]\n    .map(d => d.contexts.get(url))\n    .find(c => c !== undefined);\n  if (context !== undefined) {\n    return {\n      contextUrl: null,\n      documentUrl: url,\n      document: context\n    };\n  }\n  console.log(\"could not find context \" + url)\n  return defaultDocumentLoader(url);\n});\n\nfunction addDocument(url, context) {\n  internalContext.add(url, context);\n}\n\nconst suites = new Map();\nasync function getSuite(controller) {\n  if (suites.has(controller)) return suites.get(controller);\n\n  const keyPair = await Ed25519Multikey.generate({ controller });\n  // console.log(\"signing keys\", JSON.stringify(keyPair, null, 2));\n  const suite = new DataIntegrityProof({\n    signer: keyPair.signer(), cryptosuite: eddsaRdfc2022CryptoSuite\n  });\n\n  // console.log(\"signing suite\", JSON.stringify(suite, null, 2));\n  suites.set(controller, suite);\n  // add the verification method document for the generated key to the documentLoader cache.\n  const verificationMethodDoc = await keyPair.export({publicKey: true});\n  addDocument(suite.signer.id, verificationMethodDoc);\n\n  // add a controller document for the generated eddsa multikey to the documentLoader cache.\n  // The \"id\" must equal the vc.issuer.id to prove the issuer has control of the key.\n  addDocument(controller, {\n    \"@context\": [\n      \"https://www.w3.org/ns/did/v1\",\n      \"https://w3id.org/security/multikey/v1\"\n    ],\n    \"id\": controller,\n    \"assertionMethod\": [\n      suite.signer.id\n    ]\n  });\n  return suite;\n}\n\nconst jwks = new Map();\nasync function getJwk(controller) {\n  if (jwks.has(controller)) return jwks.get(controller);\n  const jwk = await jose.generateKeyPair('RS256');\n  jwks.set(controller, jwk);\n  return jwk;\n}\n\nasync function loadContexts(exampleContexts) {\n  const promises = new Array();\n  for (const url of exampleContexts) {\n    if (typeof url === \"object\") continue;\n    let context = internalContext.contexts.get(url);\n    if (context === undefined) {\n      promises.push(new Promise(async (resolve, reject) => {\n        try {\n          const response = await fetch(url);\n          if (response.ok) {\n            context = await response.json();\n            addDocument(url, context);\n          }\n        } catch (e) {\n          console.error(`Cannot fetch ${url}`);\n        } finally {\n          resolve();\n        }\n      }));\n    }\n  }\n  await Promise.all(promises);\n}\n\n/**\n * Verifies a verifiable credential using information in the proofs\n *   - Creates an array of suites from the proofs attached to the credential\n *   - Calls vc.verifyCredential to perform the actual verification\n *\n * @param {object} [options={}] - The options.\n *\n * @param {object} options.credential - Verifiable credential.\n * @param {Function} [options.documentLoader] - A document loader.\n *\n * @returns {Promise<VerifyCredentialResult>} The verification result.\n */\nasync function verifyCredentialUsingProofs(options = {}) {\n  const { credential } = options;\n  try {\n    if (!credential) {\n      throw new TypeError(\n        'A \"credential\" property is required for verifying.');\n    }\n    if (!credential.proof) {\n      throw new TypeError(\n        'A \"proof\" property is required for verifying.');\n    }\n    const suites = new Map();\n    for (const proof of credential.proof) {\n      if (!suites.has(proof.verificationMethod)) {\n        let controller;\n        let publicKeyMultibase;\n        if (proof.verificationMethod.includes(\"#\")) {\n          controller = proof.verificationMethod.split(\"#\")[0];\n          publicKeyMultibase = proof.verificationMethod.split(\"#\")[1];\n        } else {\n          controller = proof.verificationMethod;\n          publicKeyMultibase = proof.verificationMethod.split(\"did:key:\")[1];\n        }\n        let suite;\n        const keypair = new Ed25519VerificationKey2020({\n          id: proof.verificationMethod,\n          controller,\n          publicKeyMultibase\n        });\n      if (proof.type === \"Ed25519Signature2020\") {\n          // console.log(\"reconstructed keypair\", JSON.stringify(keypair, null, 2));\n          suite = new Ed25519Signature2020({ key: keypair });\n        } else if  (proof.type === \"DataIntegrityProof\") {\n          // const ed25519Multikey = await Ed25519Multikey.from(keypair);\n          suite = new DataIntegrityProof({\n            cryptosuite: eddsaRdfc2022CryptoSuite\n          });\n        } else {\n          throw new TypeError(\n            'A valid \"proof.type\" property is required for verifying.');\n        }\n        // console.log(\"reconstructed suite\", JSON.stringify(suite, null, 2));\n        suites.set(proof.verificationMethod, suite);\n      }\n    }\n    options.suite = Array.from(suites.values());\n    // don't check the status of the credential\n    options.checkStatus = () => { return {verified: true}; };\n    return await verifyCredential(options);\n  } catch (error) {\n    return {\n      verified: false,\n      results: [{ credential, verified: false, error }],\n      error\n    };\n  }\n}\n\n// convert an XML Schema v1.` Datetime value to a UNIX timestamp\nfunction xmlDateTimeToUnixTimestamp(xmlDateTime) {\n  if (!xmlDateTime) {\n    return undefined;\n  }\n\n  return Date.parse(xmlDateTime) / 1000;\n}\n\n// transform the input credential to a signed JWT\nasync function transformCredentialToJwt({ credential, jwk }) {\n  const publicKey = await jose.exportJWK(jwk.publicKey);\n  const header = { alg: 'RS256', typ: 'JWT', jwk: publicKey };\n\n  let payload;\n  // vcdm  1.1\n  if (credential['@context'].includes(\"https://www.w3.org/2018/credentials/v1\")) {\n    payload = {\n      vc: credential\n    };\n  } else if (credential['@context'].includes(\"https://www.w3.org/ns/credentials/v2\")){\n    // vcdm 2.0\n    payload = credential;\n  }\n\n  if (credential.expirationDate) {\n    payload.exp = xmlDateTimeToUnixTimestamp(credential.expirationDate);\n  }\n  if (credential.issuer) {\n    if (typeof credential.issuer === \"string\") {\n      payload.iss = credential.issuer;\n    } else if (credential.issuer.id) {\n      payload.iss = credential.issuer.id;\n    }\n  }\n  if (credential.issuanceDate) {\n    payload.nbf = xmlDateTimeToUnixTimestamp(credential.issuanceDate);\n  }\n  if (credential.id) {\n    payload.jti = credential.id;\n  }\n  if (credential.credentialSubject.id) {\n    payload.sub = credential.credentialSubject.id;\n  }\n\n  const jwt = await new jose.SignJWT(payload)\n    .setProtectedHeader(header)\n    .sign(jwk.privateKey);\n\n  return { header, payload, jwt };\n};\n\n// transform the input credential to a JWT description\nasync function transformCredentialToJwtDescription({ credential, jwk }) {\n  const { header, payload, jwt } = await transformCredentialToJwt({ credential, jwk });\n\n  // create the JWT description\n  let description = '---------------- JWT header ---------------\\n' +\n    JSON.stringify(header, null, 2);\n\n  description += '\\n\\n--------------- JWT payload ---------------\\n' +\n    '// NOTE: The example below uses a valid VC-JWT serialization\\n' +\n    '//       that duplicates the iss, nbf, jti, and sub fields in the\\n' +\n    '//       Verifiable Credential (vc) field.\\n\\n' +\n    JSON.stringify(payload, null, 2);\n\n  return description + '\\n\\n--------------- JWT ---------------\\n\\n' + jwt;\n};\n\n// transform the input presentation to a JWT\nasync function transformPresentationToJwt({ presentation, jwk }) {\n  const publicKey = await jose.exportJWK(jwk.publicKey);\n  const header = { alg: 'RS256', typ: 'JWT', jwk: publicKey };\n  const payload = {\n    vp: presentation\n  };\n  if (presentation.holder) {\n    if (typeof presentation.holder === \"string\") {\n      payload.iss = presentation.holder;\n    } else if (presentation.holder.id) {\n      payload.iss = presentation.holderid;\n    }\n  }\n  if (presentation.id) {\n    payload.jti = presentation.id;\n  }\n\n  const jwt = await new jose.SignJWT(payload)\n    .setProtectedHeader(header)\n    .sign(jwk.privateKey);\n\n  return { header, payload, jwt };\n};\n\n// transform the input presentation to a JWT description\nasync function transformPresentationToJwtDescription({ presentation, jwk }) {\n  const { header, payload, jwt } = await transformPresentationToJwt({ presentation, jwk });\n\n  // create the JWT description\n  let description = '---------------- JWT header ---------------\\n' +\n    JSON.stringify(header, null, 2);\n\n  description += '\\n\\n--------------- JWT payload ---------------\\n' +\n    '// NOTE: The example below uses a valid VP-JWT serialization\\n' +\n    '//       that duplicates the iss and jti fields in the\\n' +\n    '//       Verifiable Presentation (vp) field.\\n\\n' +\n    JSON.stringify(payload, null, 2);\n\n  return description + '\\n\\n--------------- JWT ---------------\\n\\n' + jwt;\n};\n\nasync function attachCredentialProof({ credential, suite }) {\n  const credentialCopy = JSON.parse(JSON.stringify(credential));\n  if (!(\"proof\" in credentialCopy)) {\n    credentialCopy.proof = new Array();\n  }\n  return issue({ credential: credentialCopy, suite, documentLoader });\n};\n\nasync function attachPresentationProof({ presentation, suite }) {\n  const presentationCopy = JSON.parse(JSON.stringify(presentation));\n  if (!(\"proof\" in presentationCopy)) {\n    presentationCopy.proof = new Array();\n  }\n  return signPresentation({ presentation: presentationCopy, challenge: \"challenge\", suite, documentLoader });\n};\n\nfunction addVcExampleStyles() {\n  const exampleStyles = document.createElement('style');\n\n  exampleStyles.innerHTML += `\n  .vc-tabbed, .vp-tabbed {\n    overflow-x: hidden;\n    margin: 0 0;\n  }\n\n  .vc-tabbed [type=\"radio\"], .vp-tabbed [type=\"radio\"] {\n    display: none;\n  }\n\n  .vc-tabs, .vp-tabs {\n    display: flex;\n    align-items: stretch;\n    list-style: none;\n    padding: 0;\n    border-bottom: 1px solid #ccc;\n  }\n\n  li.vc-tab, li.vp-tab {\n    margin: unset;\n  }\n\n  .vc-tab > label, .vp-tab > label {\n    display: block;\n    margin-bottom: -1px;\n    padding: .4em .5em;\n    border: 1px solid #ccc;\n    border-top-right-radius: .4em;\n    border-top-left-radius: .4em;\n    background: #eee;\n    color: #666;\n    cursor: pointer;\n    transition: all 0.3s;\n  }\n  .vc-tab:hover label, .vp-tab:hover {\n    border-left-color: #333;\n    border-top-color: #333;\n    border-right-color: #333;\n    color: #333;\n  }\n\n  .vc-tab-content, .vp-tab-content {\n    display: none;\n  }\n\n  .vc-tabbed [type=\"radio\"]:nth-of-type(1):checked ~ .vc-tabs .vc-tab:nth-of-type(1) label,\n  .vc-tabbed [type=\"radio\"]:nth-of-type(2):checked ~ .vc-tabs .vc-tab:nth-of-type(2) label,\n  .vc-tabbed [type=\"radio\"]:nth-of-type(3):checked ~ .vc-tabs .vc-tab:nth-of-type(3) label {\n    border-bottom-color: #fff;\n    background: #fff;\n    color: #222;\n  }\n\n  .vc-tabbed [type=\"radio\"]:nth-of-type(1):checked ~ .vc-tab-content:nth-of-type(1),\n  .vc-tabbed [type=\"radio\"]:nth-of-type(2):checked ~ .vc-tab-content:nth-of-type(2),\n  .vc-tabbed [type=\"radio\"]:nth-of-type(3):checked ~ .vc-tab-content:nth-of-type(3) {\n    display: block;\n  }\n\n  .vp-tabbed [type=\"radio\"]:nth-of-type(1):checked ~ .vp-tabs .vp-tab:nth-of-type(1) label,\n  .vp-tabbed [type=\"radio\"]:nth-of-type(2):checked ~ .vp-tabs .vp-tab:nth-of-type(2) label,\n  .vp-tabbed [type=\"radio\"]:nth-of-type(3):checked ~ .vp-tabs .vp-tab:nth-of-type(3) label {\n    border-bottom-color: #fff;\n    background: #fff;\n    color: #222;\n  }\n\n  .vp-tabbed [type=\"radio\"]:nth-of-type(1):checked ~ .vp-tab-content:nth-of-type(1),\n  .vp-tabbed [type=\"radio\"]:nth-of-type(2):checked ~ .vp-tab-content:nth-of-type(2),\n  .vp-tabbed [type=\"radio\"]:nth-of-type(3):checked ~ .vp-tab-content:nth-of-type(3) {\n    display: block;\n  }`;\n\n  document.getElementsByTagName('head')[0].appendChild(exampleStyles);\n}\n\nfunction createCredentialTabs(example, proofExampleIndex, verifiableCredentialProof, verifiableCredentialJwt) {\n  // set up the tabbed content\n  const tabbedContent = document.createElement('div');\n  tabbedContent.setAttribute('class', 'vc-tabbed');\n\n  // set up the unsigned button\n  const unsignedTabBtn = document.createElement('input');\n  unsignedTabBtn.setAttribute('type', 'radio');\n  unsignedTabBtn.setAttribute('id', `vc-tab${proofExampleIndex}1`);\n  unsignedTabBtn.setAttribute('name', `vc-tabs${proofExampleIndex}`);\n  unsignedTabBtn.setAttribute('checked', 'checked');\n  tabbedContent.appendChild(unsignedTabBtn);\n\n  // set up the signed proof button\n  const signedProofTabBtn = document.createElement('input');\n  signedProofTabBtn.setAttribute('type', 'radio');\n  signedProofTabBtn.setAttribute('id', `vc-tab${proofExampleIndex}2`);\n  signedProofTabBtn.setAttribute('name', `vc-tabs${proofExampleIndex}`);\n  tabbedContent.appendChild(signedProofTabBtn);\n\n  // set up the signed JWT button\n  const signedJwtTabBtn = document.createElement('input');\n  signedJwtTabBtn.setAttribute('type', 'radio');\n  signedJwtTabBtn.setAttribute('id', `vc-tab${proofExampleIndex}3`);\n  signedJwtTabBtn.setAttribute('name', `vc-tabs${proofExampleIndex}`);\n  tabbedContent.appendChild(signedJwtTabBtn);\n\n  // set up the tab labels\n  const tabLabels = document.createElement(\"ul\");\n  tabLabels.setAttribute('class', 'vc-tabs');\n  tabbedContent.appendChild(tabLabels);\n\n  const unsignedLabel = document.createElement(\"li\");\n  unsignedLabel.setAttribute('class', 'vc-tab');\n  unsignedLabel.innerHTML = `<label for='${unsignedTabBtn.getAttribute('id')}'>Credential</label>`;\n  tabLabels.appendChild(unsignedLabel)\n\n  const signedProofLabel = document.createElement(\"li\");\n  signedProofLabel.setAttribute('class', 'vc-tab');\n  signedProofLabel.innerHTML = `<label for='${signedProofTabBtn.getAttribute('id')}'>Verifiable Credential (with proof)</label>`;\n  tabLabels.appendChild(signedProofLabel)\n\n  const signedJwtLabel = document.createElement(\"li\");\n  signedJwtLabel.setAttribute('class', 'vc-tab');\n  signedJwtLabel.innerHTML = `<label for='${signedJwtTabBtn.getAttribute('id')}'>Verifiable Credential (as JWT)</label>`;\n  tabLabels.appendChild(signedJwtLabel)\n\n  // append the tabbed content\n  const container = example.parentNode;\n  const unsignedContent = document.createElement('div');\n  unsignedContent.setAttribute('class', 'vc-tab-content');\n  // Move the credential example to the unsigned tab\n  unsignedContent.append(example);\n  tabbedContent.appendChild(unsignedContent);\n\n  const signedProofContent = document.createElement('div');\n  signedProofContent.setAttribute('class', 'vc-tab-content');\n  // signedProofContent.innerHTML = `<pre>${JSON.stringify(verifiableCredentialProof, null, 2).match(/.{1,80}/g).join('\\n')}</pre>`;\n  signedProofContent.innerHTML = `<pre>${JSON.stringify(verifiableCredentialProof, null, 2)}</pre>`;\n  tabbedContent.appendChild(signedProofContent);\n\n  const signedJwtContent = document.createElement('div');\n  signedJwtContent.setAttribute('class', 'vc-tab-content');\n  signedJwtContent.innerHTML = `<pre>${verifiableCredentialJwt.match(/.{1,80}/g).join('\\n')}</pre>`;\n  tabbedContent.appendChild(signedJwtContent);\n\n  // replace the original example with the tabbed content\n\n  container.append(tabbedContent);\n}\n\nfunction createPresentationTabs(example, proofExampleIndex, verifiablePresentationProof, verifiablePresentationJwt) {\n\n  // set up the tabbed content\n  const tabbedContent = document.createElement('div');\n  tabbedContent.setAttribute('class', 'vp-tabbed');\n\n  // set up the unsigned button\n  const unsignedTabBtn = document.createElement('input');\n  unsignedTabBtn.setAttribute('type', 'radio');\n  unsignedTabBtn.setAttribute('id', `vp-tab${proofExampleIndex}1`);\n  unsignedTabBtn.setAttribute('name', `vp-tabs${proofExampleIndex}`);\n  unsignedTabBtn.setAttribute('checked', 'checked');\n  tabbedContent.appendChild(unsignedTabBtn);\n\n  // set up the signed proof button\n  const signedProofTabBtn = document.createElement('input');\n  signedProofTabBtn.setAttribute('type', 'radio');\n  signedProofTabBtn.setAttribute('id', `vp-tab${proofExampleIndex}2`);\n  signedProofTabBtn.setAttribute('name', `vp-tabs${proofExampleIndex}`);\n  tabbedContent.appendChild(signedProofTabBtn);\n\n  // set up the signed JWT button\n  const signedJwtTabBtn = document.createElement('input');\n  signedJwtTabBtn.setAttribute('type', 'radio');\n  signedJwtTabBtn.setAttribute('id', `vp-tab${proofExampleIndex}3`);\n  signedJwtTabBtn.setAttribute('name', `vp-tabs${proofExampleIndex}`);\n  tabbedContent.appendChild(signedJwtTabBtn);\n\n  // set up the tab labels\n  const tabLabels = document.createElement(\"ul\");\n  tabLabels.setAttribute('class', 'vp-tabs');\n  tabbedContent.appendChild(tabLabels);\n\n  const unsignedLabel = document.createElement(\"li\");\n  unsignedLabel.setAttribute('class', 'vp-tab');\n  unsignedLabel.innerHTML = `<label for='${unsignedTabBtn.getAttribute('id')}'>Presentation</label>`;\n  tabLabels.appendChild(unsignedLabel)\n\n  const signedProofLabel = document.createElement(\"li\");\n  signedProofLabel.setAttribute('class', 'vp-tab');\n  signedProofLabel.innerHTML = `<label for='${signedProofTabBtn.getAttribute('id')}'>Verifiable Presentation (with proof)</label>`;\n  tabLabels.appendChild(signedProofLabel)\n\n  const signedJwtLabel = document.createElement(\"li\");\n  signedJwtLabel.setAttribute('class', 'vp-tab');\n  signedJwtLabel.innerHTML = `<label for='${signedJwtTabBtn.getAttribute('id')}'>Verifiable Presentation (as JWT)</label>`;\n  tabLabels.appendChild(signedJwtLabel)\n\n  // append the tabbed content\n\n  const container = example.parentNode;\n  const unsignedContent = document.createElement('div');\n  unsignedContent.setAttribute('class', 'vp-tab-content');\n  // Move the presentation example to the unsigned tab\n  unsignedContent.append(example);\n  tabbedContent.appendChild(unsignedContent);\n\n  const signedProofContent = document.createElement('div');\n  signedProofContent.setAttribute('class', 'vp-tab-content');\n  // signedProofContent.innerHTML = `<pre>${JSON.stringify(verifiablePresentationProof, null, 2).match(/.{1,80}/g).join('\\n')}</pre>`;\n  signedProofContent.innerHTML = `<pre>${JSON.stringify(verifiablePresentationProof, null, 2)}</pre>`;\n  tabbedContent.appendChild(signedProofContent);\n\n  const signedJwtContent = document.createElement('div');\n  signedJwtContent.setAttribute('class', 'vp-tab-content');\n  signedJwtContent.innerHTML = `<pre>${verifiablePresentationJwt.match(/.{1,80}/g).join('\\n')}</pre>`;\n  tabbedContent.appendChild(signedJwtContent);\n\n  // replace the original example with the tabbed content\n\n  container.append(tabbedContent);\n}\n\nasync function createCredentialExamples() {\n\n  // process every example that needs a vc-proof\n  const vcProofExamples = document.querySelectorAll(\".vc\");\n  let proofExampleIndex = 0;\n  for (const example of vcProofExamples) {\n    proofExampleIndex++;\n\n    // extract and sign the example\n    let credential = {};\n    try {\n      let exampleText = example.innerText;\n      exampleText = exampleText.replace(/\\/\\/ .*$/gm, '');\n      credential = JSON.parse(exampleText);\n    } catch (e) {\n      console.error('respec-vc error: Failed to create Verifiable Credential.',\n        e, example.innerText);\n      continue;\n    }\n\n    const nestedCredentialProofs = new Array();\n    const nestedCredentialJwts = new Array();\n\n    const verificationMethod = example.getAttribute('data-vc-vm');\n    if (verificationMethod) getSuite(verificationMethod)\n\n    if (Array.from(credential.type).includes(\"ClrCredential\")) {\n      // process each nested credential\n      if (credential.credentialSubject.verifiableCredential === undefined) {\n        console.warn(\"respec-vc warning: ClrCredential does not contain nested credentials.\")\n      } else {\n        for (const nestedCredential of credential.credentialSubject.verifiableCredential) {\n\n          const issuerId = (typeof (nestedCredential.issuer) === \"object\") ? nestedCredential.issuer.id : nestedCredential.issuer;\n\n          // pre-load the contexts\n          const nestedContexts = nestedCredential[\"@context\"];\n          if (nestedContexts) {\n            await loadContexts(nestedContexts);\n          }\n\n          // attach the proof\n          let verifiableCredentialProof;\n          let suite;\n          let jwk;\n\n          if (verificationMethod) {\n            // Use the verificationMethod that was passed in\n            suite = await getSuite(verificationMethod);\n            jwk = await getJwk(verificationMethod);\n          } else {\n            // Create a keyPair and suite specific to the credential.issuer.\n            suite = await getSuite(issuerId);\n            jwk = await getJwk(issuerId);\n          }\n\n          try {\n            verifiableCredentialProof = await attachCredentialProof({ credential: nestedCredential, suite });\n          } catch (e) {\n            console.error(\n              'respec-vc error: Failed to attach proof to Verifiable Credential.',\n              e, example.innerText);\n            if (e.details && e.details.event) {\n              console.error(\n                e.details.event.message,\n                e.details.event.details\n              );\n            }\n            continue;\n          }\n\n          try {\n            // Verify the credential using the proof\n            if (verifiableCredentialProof) {\n              const results = await verifyCredentialUsingProofs({ credential: verifiableCredentialProof, documentLoader });\n              console.log(verifiableCredentialProof.type.toString(), \"Verified: \" + results.verified, results.results);\n            }\n          } catch (e) {\n            if (e.details && e.details.event) {\n              console.error(\n                \"Failed to verify credential: \" + e.details.event.message,\n                e.details.event.details\n              );\n            } else {\n              console.error(\"Failed to verify credential:\", e, example.innerText);\n            }\n          }\n\n          // convert to JWT\n          let verifiableCredentialJwt;\n          try {\n            const { header, payload, jwt } = await transformCredentialToJwt({ credential: nestedCredential, jwk });\n            verifiableCredentialJwt = jwt;\n          } catch (e) {\n            console.error(\n              'respec-vc error: Failed to convert nested credential to JWT.',\n              e, JSON.stringify(credential, 2));\n            continue;\n          }\n\n          nestedCredentialProofs.push(verifiableCredentialProof);\n          nestedCredentialJwts.push(verifiableCredentialJwt);\n        }\n      }\n    }\n\n    const issuerId = (typeof (credential.issuer) === \"object\") ? credential.issuer.id : credential.issuer;\n\n    // pre-load the contexts\n    await loadContexts(credential[\"@context\"]);\n\n    // attach the proof\n    let verifiableCredentialProof;\n    let suite;\n    let jwk;\n    if (verificationMethod) {\n      // Use the verificationMethod that was passed in\n      suite = await getSuite(verificationMethod);\n      jwk = await getJwk(verificationMethod);\n    } else {\n      // Create a keyPair and suite specific to the credential.issuer.\n      suite = await getSuite(issuerId);\n      jwk = await getJwk(issuerId);\n    }\n\n    try {\n      if (Array.from(credential.type).includes(\"ClrCredential\") && nestedCredentialProofs.length > 0) {\n        credential.credentialSubject.verifiableCredential = nestedCredentialProofs;\n      }\n      verifiableCredentialProof = await attachCredentialProof({ credential, suite });\n    } catch (e) {\n      console.error(\n        'respec-vc error: Failed to attach proof to Verifiable Credential.',\n        e, example.innerText);\n      if (e.details && e.details.event) {\n        console.error(\n          e.details.event.message,\n          e.details.event.details\n        );\n      }\n    }\n\n    try {\n      // Verify the credential using the proof\n      if (verifiableCredentialProof) {\n        const results = await verifyCredentialUsingProofs({ credential: verifiableCredentialProof, documentLoader });\n        console.log(verifiableCredentialProof.type.toString(), \"Verified: \" + results.verified, results.results);\n      }\n    } catch (e) {\n      if (e.details && e.details.event) {\n        console.error(\n          \"Failed to verify credential: \" + e.details.event.message,\n          e.details.event.details\n        );\n      } else {\n        console.error(\"Failed to verify credential:\", e, example.innerText);\n      }\n    }\n\n    // convert to a JWT\n    let verifiableCredentialJwt;\n    try {\n      if (Array.from(credential.type).includes(\"ClrCredential\") && nestedCredentialJwts.length > 0) {\n        credential.credentialSubject.verifiableCredential = nestedCredentialJwts;\n      }\n      verifiableCredentialJwt = await transformCredentialToJwtDescription({\n        credential, jwk\n      });\n    } catch (e) {\n      console.error(\n        'respec-vc error: Failed to convert Credential to JWT.',\n        e, example.innerText);\n      continue;\n    }\n\n    createCredentialTabs(example, proofExampleIndex, verifiableCredentialProof, verifiableCredentialJwt);\n  }\n}\n\nasync function createPresentationExamples(suite, jwk) {\n  // process every example that needs a vp-proof\n  const vpProofExamples = document.querySelectorAll(\".vp\");\n  let proofExampleIndex = 0;\n  for (const example of vpProofExamples) {\n    proofExampleIndex++;\n    const verificationMethod = example.getAttribute(\"data-vp-vm\");\n    suite.verificationMethod =\n      verificationMethod || \"did:key:\" + suite.signer.publicKeyMultibase;\n\n    // extract and sign the example\n    const originalText = example.innerHTML;\n    let presentation = {};\n    try {\n      let exampleText = example.innerText;\n      exampleText = exampleText.replace(/\\/\\/ .*$/gm, '');\n      presentation = JSON.parse(exampleText);\n    } catch (e) {\n      console.error(\n        'respec-vc error: Failed to create Presentation.',\n        e, example.innerText);\n      continue;\n    }\n\n    const credentialJwts = new Array();\n    const credentialProofs = new Array();\n\n    // process each nested credential\n    for (const credential of presentation.verifiableCredential) {\n\n      const nestedCredentialJwts = new Array();\n      const nestedCredentialProofs = new Array();\n\n      if (Array.from(credential.type).includes(\"ClrCredential\")) {\n\n        if (credential.credentialSubject.verifiableCredential === undefined) {\n          console.warn(\"respec-vc warning: ClrCredential does not contain any nested credentials.\");\n          continue;\n        }\n\n        // process each nested credential\n        for (const nestedCredential of credential.credentialSubject.verifiableCredential) {\n\n          // pre-load the contexts\n          await loadContexts(nestedCredential[\"@context\"]);\n\n          // attach the proof\n          let verifiableCredentialProof;\n          try {\n            verifiableCredentialProof = await attachCredentialProof({ credential: nestedCredential, suite });\n          } catch (e) {\n            console.error(\n              'respec-vc error: Failed to attach proof to nested credential.',\n              e, JSON.stringify(credential, 2));\n            continue;\n          }\n\n          // convert to JWT\n          let verifiableCredentialJwt;\n          try {\n            const { header, payload, jwt } = await transformCredentialToJwt({ credential: nestedCredential, jwk });\n            verifiableCredentialJwt = jwt;\n          } catch (e) {\n            console.error(\n              'respec-vc error: Failed to convert nested credential to JWT.',\n              e, JSON.stringify(credential, 2));\n            continue;\n          }\n\n          nestedCredentialProofs.push(verifiableCredentialProof);\n          nestedCredentialJwts.push(verifiableCredentialJwt);\n        }\n      }\n\n      // pre-load the contexts\n      await loadContexts(credential[\"@context\"]);\n\n      // attach the proof\n      let verifiableCredentialProof;\n      try {\n        if (Array.from(credential.type).includes(\"ClrCredential\")) {\n          credential.credentialSubject.verifiableCredential = nestedCredentialProofs;\n        }\n        verifiableCredentialProof = await attachCredentialProof({ credential, suite });\n      } catch (e) {\n        console.error(\n          'respec-vc error: Failed to attach proof to Credential.',\n          e, JSON.stringify(credential, 2));\n        continue;\n      }\n\n      // convert to JWT\n      let verifiableCredentialJwt;\n      try {\n        if (Array.from(credential.type).includes(\"ClrCredential\")) {\n          credential.credentialSubject.verifiableCredential = nestedCredentialJwts;\n        }\n        const { header, payload, jwt } = await transformCredentialToJwt({ credential, jwk });\n        verifiableCredentialJwt = jwt;\n      } catch (e) {\n        console.error(\n          'respec-vc error: Failed to convert Credential to JWT.',\n          e, JSON.stringify(credential, 2));\n        continue;\n      }\n\n      credentialProofs.push(verifiableCredentialProof);\n      credentialJwts.push(verifiableCredentialJwt);\n    }\n\n    // pre-load the contexts\n    await loadContexts(presentation[\"@context\"]);\n\n    // attach the proof\n    let verifiablePresentationProof;\n    try {\n      presentation.verifiableCredential = credentialProofs;\n      verifiablePresentationProof = await attachPresentationProof({ presentation, suite });\n    } catch (e) {\n      console.error(\n        'respec-vc error: Failed to attach proof to Presentation.',\n        e, example.innerText);\n      continue;\n    }\n\n    // convert to a JWT\n    let verifiablePresentationJwt;\n    try {\n      presentation.verifiableCredential = credentialJwts;\n      verifiablePresentationJwt = await transformPresentationToJwtDescription({\n        presentation, jwk\n      });\n    } catch (e) {\n      console.error(\n        'respec-vc error: Failed to convert Presentation to JWT.',\n        e, example.innerText);\n      continue;\n    }\n\n    createPresentationTabs(example, proofExampleIndex, verifiablePresentationProof, verifiablePresentationJwt);\n  }\n}\n\nasync function createVcExamples() {\n  // add styles for examples\n  addVcExampleStyles();\n\n  // generate base keypair and signature suite\n  const keyPair = await Ed25519Multikey.generate();\n  const suite = new DataIntegrityProof({\n    signer: keyPair.signer(), cryptosuite: eddsaRdfc2022CryptoSuite\n  });\n  const jwk = await jose.generateKeyPair('RS256');\n\n  await createCredentialExamples();\n  await createPresentationExamples(suite, jwk);\n}\n\n// setup exports on window\nwindow.respecVc = {\n  addContext: addDocument,\n  createVcExamples\n}\n"],"names":[],"sourceRoot":""}